mirror of
https://github.com/KartKrewDev/RingRacers.git
synced 2025-12-11 18:42:46 +00:00
Give the addfile command variable argument support.
This commit is contained in:
parent
ffeb48ab4d
commit
79861c1a98
1 changed files with 108 additions and 79 deletions
|
|
@ -3247,20 +3247,45 @@ static void Got_RunSOCcmd(UINT8 **cp, INT32 playernum)
|
||||||
* Searches for sounds, maps, music, new images.
|
* Searches for sounds, maps, music, new images.
|
||||||
*/
|
*/
|
||||||
static void Command_Addfile(void)
|
static void Command_Addfile(void)
|
||||||
|
{
|
||||||
|
size_t argc = COM_Argc(); // amount of arguments total
|
||||||
|
size_t curarg; // current argument index
|
||||||
|
|
||||||
|
const char *addedfiles[argc]; // list of filenames already processed
|
||||||
|
size_t numfilesadded = 0; // the amount of filenames processed
|
||||||
|
|
||||||
|
if (argc < 2)
|
||||||
|
{
|
||||||
|
CONS_Printf(M_GetText("addfile <wadfile.wad>: load wad file\n"));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// start at one to skip command name
|
||||||
|
for (curarg = 1; curarg < argc; curarg++)
|
||||||
{
|
{
|
||||||
const char *fn, *p;
|
const char *fn, *p;
|
||||||
char buf[256];
|
char buf[256];
|
||||||
char *buf_p = buf;
|
char *buf_p = buf;
|
||||||
INT32 i;
|
INT32 i;
|
||||||
int musiconly; // W_VerifyNMUSlumps isn't boolean
|
int musiconly; // W_VerifyNMUSlumps isn't boolean
|
||||||
|
boolean fileadded = false;
|
||||||
|
|
||||||
if (COM_Argc() != 2)
|
fn = COM_Argv(curarg);
|
||||||
|
|
||||||
|
// For the amount of filenames previously processed...
|
||||||
|
for (size_t ii = 0; ii < numfilesadded; ii++)
|
||||||
{
|
{
|
||||||
CONS_Printf(M_GetText("addfile <wadfile.wad>: load wad file\n"));
|
// If this is one of them, don't try to add it.
|
||||||
return;
|
if (!strcmp(fn, addedfiles[ii]))
|
||||||
|
{
|
||||||
|
fileadded = true;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
else
|
}
|
||||||
fn = COM_Argv(1);
|
|
||||||
|
// If we've added this one, skip to the next one.
|
||||||
|
if (fileadded)
|
||||||
|
continue;
|
||||||
|
|
||||||
// Disallow non-printing characters and semicolons.
|
// Disallow non-printing characters and semicolons.
|
||||||
for (i = 0; fn[i] != '\0'; i++)
|
for (i = 0; fn[i] != '\0'; i++)
|
||||||
|
|
@ -3275,7 +3300,7 @@ static void Command_Addfile(void)
|
||||||
if (netgame && !(server || IsPlayerAdmin(consoleplayer)))
|
if (netgame && !(server || IsPlayerAdmin(consoleplayer)))
|
||||||
{
|
{
|
||||||
CONS_Printf(M_GetText("Only the server or a remote admin can use this.\n"));
|
CONS_Printf(M_GetText("Only the server or a remote admin can use this.\n"));
|
||||||
return;
|
continue;
|
||||||
}
|
}
|
||||||
G_SetGameModified(multiplayer);
|
G_SetGameModified(multiplayer);
|
||||||
}
|
}
|
||||||
|
|
@ -3284,7 +3309,8 @@ static void Command_Addfile(void)
|
||||||
if (!(netgame || multiplayer) || musiconly)
|
if (!(netgame || multiplayer) || musiconly)
|
||||||
{
|
{
|
||||||
P_AddWadFile(fn);
|
P_AddWadFile(fn);
|
||||||
return;
|
addedfiles[numfilesadded++] = fn;
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
p = fn+strlen(fn);
|
p = fn+strlen(fn);
|
||||||
|
|
@ -3321,25 +3347,28 @@ static void Command_Addfile(void)
|
||||||
fclose(fhandle);
|
fclose(fhandle);
|
||||||
}
|
}
|
||||||
else // file not found
|
else // file not found
|
||||||
return;
|
continue;
|
||||||
|
|
||||||
for (i = 0; i < numwadfiles; i++)
|
for (i = 0; i < numwadfiles; i++)
|
||||||
{
|
{
|
||||||
if (!memcmp(wadfiles[i]->md5sum, md5sum, 16))
|
if (!memcmp(wadfiles[i]->md5sum, md5sum, 16))
|
||||||
{
|
{
|
||||||
CONS_Alert(CONS_ERROR, M_GetText("%s is already loaded\n"), fn);
|
CONS_Alert(CONS_ERROR, M_GetText("%s is already loaded\n"), fn);
|
||||||
return;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
WRITEMEM(buf_p, md5sum, 16);
|
WRITEMEM(buf_p, md5sum, 16);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
addedfiles[numfilesadded++] = fn;
|
||||||
|
|
||||||
if (IsPlayerAdmin(consoleplayer) && (!server)) // Request to add file
|
if (IsPlayerAdmin(consoleplayer) && (!server)) // Request to add file
|
||||||
SendNetXCmd(XD_REQADDFILE, buf, buf_p - buf);
|
SendNetXCmd(XD_REQADDFILE, buf, buf_p - buf);
|
||||||
else
|
else
|
||||||
SendNetXCmd(XD_ADDFILE, buf, buf_p - buf);
|
SendNetXCmd(XD_ADDFILE, buf, buf_p - buf);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static void Got_RequestAddfilecmd(UINT8 **cp, INT32 playernum)
|
static void Got_RequestAddfilecmd(UINT8 **cp, INT32 playernum)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue