@@ -1311,18 +1311,39 @@ void CExtensionManager::OnRootConsoleCommand(const char *cmdname, const ICommand
13111311 {
13121312 if (argcount < 4 )
13131313 {
1314- rootmenu->ConsolePrint (" [SM] Usage: sm exts reload <#>" );
1314+ rootmenu->ConsolePrint (" [SM] Usage: sm exts reload <# or file >" );
13151315 return ;
13161316 }
1317-
1317+
13181318 const char *arg = command->Arg (3 );
13191319 unsigned int num = atoi (arg);
1320- CExtension *pExt = FindByOrder (num) ;
1320+ CExtension *pExt;
13211321
1322- if (!pExt )
1322+ if (num != 0 )
13231323 {
1324- rootmenu->ConsolePrint (" [SM] Extension number %d was not found." , num);
1325- return ;
1324+ pExt = FindByOrder (num);
1325+ if (!pExt)
1326+ {
1327+ rootmenu->ConsolePrint (" [SM] Extension number %d was not found." , num);
1328+ return ;
1329+ }
1330+ }
1331+ else
1332+ {
1333+ char path[PLATFORM_MAX_PATH ];
1334+ ke::SafeSprintf (path, sizeof (path), " %s%s" , arg, !strstr (arg, " .ext" ) ? " .ext" : " " );
1335+
1336+ /* Strip platform extension if present, m_File doesn't include it. */
1337+ const char *ext = libsys->GetFileExtension (path);
1338+ if (ext && strcmp (ext, PLATFORM_LIB_EXT ) == 0 )
1339+ path[strlen (path) - strlen (PLATFORM_LIB_EXT ) - 1 ] = ' \0 ' ;
1340+
1341+ pExt = (CExtension *)FindExtensionByFile (path);
1342+ if (!pExt)
1343+ {
1344+ rootmenu->ConsolePrint (" [SM] Extension %s is not loaded." , path);
1345+ return ;
1346+ }
13261347 }
13271348
13281349 if (pExt->IsLoaded ())
@@ -1357,7 +1378,7 @@ void CExtensionManager::OnRootConsoleCommand(const char *cmdname, const ICommand
13571378 rootmenu->DrawGenericOption (" info" , " Extra extension information" );
13581379 rootmenu->DrawGenericOption (" list" , " List extensions" );
13591380 rootmenu->DrawGenericOption (" load" , " Load an extension" );
1360- rootmenu->DrawGenericOption (" reload" , " Reload an extension" );
1381+ rootmenu->DrawGenericOption (" reload" , " Reload an extension by # or file " );
13611382 rootmenu->DrawGenericOption (" unload" , " Unload an extension" );
13621383}
13631384
0 commit comments