diff --git a/src/d_netcmd.c b/src/d_netcmd.c index 725e50a6c..9dc9040a3 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -184,6 +184,7 @@ static void Command_AcceptInvite_f(void); static void Command_RejectInvite_f(void); static void Command_LeaveParty_f(void); +static void Command_Addfilelocal(void); static void Command_Addfile(void); static void Command_ListWADS_f(void); static void Command_ListDoomednums_f(void); @@ -858,6 +859,7 @@ void D_RegisterServerCommands(void) COM_AddCommand("showmap", Command_Showmap_f); COM_AddCommand("maphash", Command_Maphash_f); + COM_AddCommand("addfilelocal", Command_Addfilelocal); COM_AddCommand("addfile", Command_Addfile); COM_AddCommand("listwad", Command_ListWADS_f); COM_AddCommand("listmapthings", Command_ListDoomednums_f); @@ -4763,6 +4765,44 @@ static void Got_RunSOCcmd(UINT8 **cp, INT32 playernum) G_SetGameModified(true, false); } +static void Command_Addfilelocal(void) +{ + const char *fn; + INT32 i; + size_t docompat = COM_CheckPartialParm("-c"); + size_t nocompat = COM_CheckPartialParm("-n"); + wadcompat_t compat = WC_AUTO; + + if (docompat && nocompat) + { + CONS_Printf(M_GetText("Please specify only one of -c or -n\n")); + return; + } + else if (docompat) + compat = WC_ON; + else if (nocompat) + compat = WC_OFF; + + if (COM_Argc() != 2 + (docompat || nocompat)) + { + CONS_Printf(M_GetText("addfilelocal [-c|-n] : Load local add-on\n" + "-c forces compatmode, -n disables it.\n")); + return; + } + else + fn = COM_Argv(1); + + // Disallow non-printing characters and semicolons. + for (i = 0; fn[i] != '\0'; i++) + if (!isprint(fn[i]) || fn[i] == ';') + return; + + // Add any wad file, ignoring checks for if it contains complex things like + // lua. Great for complex but client-side customizations, like different + // level cards or anything like that. + P_AddWadFile(fn, compat, true); +} + /** Adds a pwad at runtime. * Searches for sounds, maps, music, new images. */ @@ -4856,7 +4896,7 @@ static void Command_Addfile(void) // Add file on your client directly if it is trivial, or you aren't in a netgame. if (!(netgame || multiplayer) || musiconly) { - P_AddWadFile(fn, compat); + P_AddWadFile(fn, compat, false); addedfiles[numfilesadded++] = fn; continue; } @@ -4996,7 +5036,7 @@ static void Got_Addfilecmd(UINT8 **cp, INT32 playernum) ncs = findfile(filename, filehash, true); - if (ncs != FS_FOUND || !P_AddWadFile(filename, compat)) + if (ncs != FS_FOUND || !P_AddWadFile(filename, compat, false)) { Command_ExitGame_f(); if (ncs == FS_FOUND) diff --git a/src/d_netfil.c b/src/d_netfil.c index 469b8df3f..b107637af 100644 --- a/src/d_netfil.c +++ b/src/d_netfil.c @@ -563,7 +563,7 @@ INT32 CL_CheckFiles(void) // CONS_Printf("checking %d of %d / %d of %d?\n", i, fileneedednum, j, numwadfiles); // CONS_Printf("i: %s / j: %s \n", fileneeded[i].filename, wadfiles[j]->filename); - if (j < numwadfiles && !wadfiles[j]->important) + if (j < numwadfiles && !wadfiles[j]->important && !wadfiles[j]->localfile) { // Unimportant on our side. ++j; @@ -656,7 +656,7 @@ boolean CL_LoadServerFiles(void) continue; // Already loaded else if (fileneeded[i].status == FS_FOUND) { - P_PartialAddWadFile(fileneeded[i].filename, fileneeded[i].compatmode ? WC_ON : WC_OFF); + P_PartialAddWadFile(fileneeded[i].filename, fileneeded[i].compatmode ? WC_ON : WC_OFF, false); G_SetGameModified(true, false); fileneeded[i].status = FS_OPEN; return false; diff --git a/src/g_demo.c b/src/g_demo.c index 4ece52183..94e77c897 100644 --- a/src/g_demo.c +++ b/src/g_demo.c @@ -3082,7 +3082,7 @@ static void G_LoadDemoExtraFiles(demoheader_t *header) } else { - P_PartialAddWadFile(file->filename, file->compatmode ? WC_ON : WC_OFF); + P_PartialAddWadFile(file->filename, file->compatmode ? WC_ON : WC_OFF, false); } } } diff --git a/src/p_setup.c b/src/p_setup.c index fd29591b7..d7aec5693 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -9128,7 +9128,7 @@ boolean P_RunSOC(const char *socfilename) lumpnum_t lump; if (strstr(socfilename, ".soc") != NULL) - return P_AddWadFile(socfilename, WC_AUTO); + return P_AddWadFile(socfilename, WC_AUTO, false); lump = W_CheckNumForName(socfilename); if (lump == LUMPERROR) @@ -9348,11 +9348,11 @@ UINT8 P_InitMapData(boolean existingmapheaders) // Add a wadfile to the active wad files, // replace sounds, musics, patches, textures, sprites and maps // -boolean P_AddWadFile(const char *wadfilename, wadcompat_t compat) +boolean P_AddWadFile(const char *wadfilename, wadcompat_t compat, boolean local) { UINT16 wadnum; - if ((wadnum = P_PartialAddWadFile(wadfilename, compat)) == UINT16_MAX) + if ((wadnum = P_PartialAddWadFile(wadfilename, compat, local)) == UINT16_MAX) return false; P_MultiSetupWadFiles(true); @@ -9450,7 +9450,7 @@ static boolean P_CheckVoteReplacements(char *name) // Add a WAD file and do the per-WAD setup stages. // Call P_MultiSetupWadFiles as soon as possible after any number of these. // -UINT16 P_PartialAddWadFile(const char *wadfilename, wadcompat_t compat) +UINT16 P_PartialAddWadFile(const char *wadfilename, wadcompat_t compat, boolean local) { size_t i; UINT16 numlumps, wadnum; @@ -9486,6 +9486,9 @@ UINT16 P_PartialAddWadFile(const char *wadfilename, wadcompat_t compat) { partadd_important = true; } + + wadfiles[wadnum]->localfile = local; + if (partadd_stage != 0) { partadd_earliestfile = wadnum; @@ -9573,14 +9576,20 @@ UINT16 P_PartialAddWadFile(const char *wadfilename, wadcompat_t compat) K_InitBrightmapsPwad(wadnum); // Reload TERRAIN - if (K_InitTerrainPwad(wadnum)) - partadd_terrainloaded = true; + if (!local) + { + if (K_InitTerrainPwad(wadnum)) + partadd_terrainloaded = true; + } // // look for skins // - R_AddSkins(wadnum); // faB: wadfile index in wadfiles[] - R_PatchSkins(wadnum); // toast: PATCH PATCH + if (!local) + { + R_AddSkins(wadnum); // faB: wadfile index in wadfiles[] + R_PatchSkins(wadnum); // toast: PATCH PATCH + } // // edit music defs diff --git a/src/p_setup.h b/src/p_setup.h index 8c6d03bf1..53e0d274a 100644 --- a/src/p_setup.h +++ b/src/p_setup.h @@ -88,7 +88,7 @@ void P_PostLoadLevel(void); void HWR_LoadLevel(void); #endif void P_UnloadLevel(void); -boolean P_AddWadFile(const char *wadfilename, wadcompat_t compat); +boolean P_AddWadFile(const char *wadfilename, wadcompat_t compat, boolean local); #define MAPRET_ADDED (1) #define MAPRET_CURRENTREPLACED (1<<1) @@ -100,7 +100,7 @@ extern INT16 wadnamemap; // WARNING: The following functions should be grouped as follows: // any amount of PartialAdds followed by MultiSetups until returned true, // as soon as possible. -UINT16 P_PartialAddWadFile(const char *wadfilename, wadcompat_t compat); +UINT16 P_PartialAddWadFile(const char *wadfilename, wadcompat_t compat, boolean local); // Run a single stage of multisetup, or all of them if fullsetup set. // fullsetup true: run everything // otherwise diff --git a/src/sdl/i_video.cpp b/src/sdl/i_video.cpp index 28bf4c54e..b6dc062a6 100644 --- a/src/sdl/i_video.cpp +++ b/src/sdl/i_video.cpp @@ -1142,7 +1142,7 @@ void I_GetEvent(void) break; case SDL_DROPFILE: dropped_filedir = evt.drop.file; - P_AddWadFile(dropped_filedir, WC_AUTO); + P_AddWadFile(dropped_filedir, WC_AUTO, false); SDL_free(dropped_filedir); // Free dropped_filedir memory break; case SDL_QUIT: diff --git a/src/w_wad.h b/src/w_wad.h index cd8ed1250..3780eddce 100644 --- a/src/w_wad.h +++ b/src/w_wad.h @@ -131,6 +131,7 @@ struct wadfile_t boolean important; // also network - !W_VerifyNMUSlumps boolean compatmode; + boolean localfile; }; typedef enum wadcompat