- do not use the command line but the module filename to create the progdir path.

argv[0] is not guaranteed to contain anything usable and in cmd.exe it doesn't.
This commit is contained in:
Christoph Oelckers 2019-11-03 13:39:42 +01:00
parent 250fa0b847
commit b179767d4a
4 changed files with 9 additions and 5 deletions

View file

@ -562,7 +562,7 @@ void OSD_Init(void)
OSD_RegisterFunction("unbindall", "unbindall: unbinds all keys", osdcmd_unbindall); OSD_RegisterFunction("unbindall", "unbindall: unbinds all keys", osdcmd_unbindall);
OSD_RegisterFunction("quit", "quit: exits the game immediately", osdcmd_quit); OSD_RegisterFunction("quit", "quit: exits the game immediately", osdcmd_quit);
OSD_RegisterFunction("exit", "exit: exits the game immediately", osdcmd_quit); OSD_RegisterFunction("exit", "exit: exits the game immediately", osdcmd_quit);
OSD_RegisterFunction("changelevel", "changelevel <level>: warps to the given level", osdcmd_changelevel); //OSD_RegisterFunction("changelevel", "changelevel <level>: warps to the given level", osdcmd_changelevel);
// atexit(OSD_Cleanup); // atexit(OSD_Cleanup);
} }

View file

@ -44,7 +44,7 @@ static int osdcmd_changelevel(osdcmdptr_t parm)
int32_t volume=0,level; int32_t volume=0,level;
char *p; char *p;
if ((g_gameType & GAMEFLAG_DUKE) && (g_gameType & GAMEFLAG_SHAREWARE)) if (!VOLUMEONE)
{ {
if (parm->numparms != 2) return OSDCMD_SHOWHELP; if (parm->numparms != 2) return OSDCMD_SHOWHELP;
@ -1135,9 +1135,11 @@ int32_t registerosdcommands(void)
OSD_RegisterFunction("playerinfo", "Prints information about the current player", osdcmd_playerinfo); OSD_RegisterFunction("playerinfo", "Prints information about the current player", osdcmd_playerinfo);
#endif #endif
if (!VOLUMEONE) if (VOLUMEONE)
OSD_RegisterFunction("changelevel","changelevel <level>: warps to the given level", osdcmd_changelevel);
else else
{ {
OSD_RegisterFunction("changelevel","changelevel <volume> <level>: warps to the given level", osdcmd_changelevel);
OSD_RegisterFunction("map","map <mapfile>: loads the given user map", osdcmd_map); OSD_RegisterFunction("map","map <mapfile>: loads the given user map", osdcmd_map);
OSD_RegisterFunction("demo","demo <demofile or demonum>: starts the given demo", osdcmd_demo); OSD_RegisterFunction("demo","demo <demofile or demonum>: starts the given demo", osdcmd_demo);
} }

View file

@ -130,7 +130,10 @@ int32_t win_buildargs(char **argvbuf)
} }
// Figure out what directory the program resides in. // Figure out what directory the program resides in.
progdir = argvbuf[0];
wchar_t buffer[256];
GetModuleFileNameW(0, buffer, 256);
progdir = buffer;
progdir.Substitute("\\", "/"); progdir.Substitute("\\", "/");
auto lastsep = progdir.LastIndexOf('/'); auto lastsep = progdir.LastIndexOf('/');
if (lastsep != -1) if (lastsep != -1)

View file

@ -916,7 +916,6 @@ int32_t registerosdcommands(void)
{ {
if (!VOLUMEONE) if (!VOLUMEONE)
else
{ {
OSD_RegisterFunction("map","map <mapfile>: loads the given user map", osdcmd_map); OSD_RegisterFunction("map","map <mapfile>: loads the given user map", osdcmd_map);
OSD_RegisterFunction("demo","demo <demofile or demonum>: starts the given demo", osdcmd_demo); OSD_RegisterFunction("demo","demo <demofile or demonum>: starts the given demo", osdcmd_demo);