Networked compatmode
This commit is contained in:
parent
f3176ed7d0
commit
f6f43943d7
8 changed files with 62 additions and 19 deletions
|
|
@ -4381,9 +4381,24 @@ static void Command_Addfile(void)
|
|||
const char *addedfiles[argc]; // list of filenames already processed
|
||||
size_t numfilesadded = 0; // the amount of filenames processed
|
||||
|
||||
if (argc < 2)
|
||||
size_t docompat = COM_CheckPartialParm("-c");
|
||||
size_t nocompat = COM_CheckPartialParm("-n");
|
||||
wadcompat_t compat = WC_AUTO;
|
||||
|
||||
if (docompat && nocompat)
|
||||
{
|
||||
CONS_Printf(M_GetText("addfile <filename.pk3/wad/lua/soc> [filename2...] [...]: Load add-ons\n"));
|
||||
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 (argc < 2 + (docompat || nocompat))
|
||||
{
|
||||
CONS_Printf(M_GetText("addfile [-c|-n] <filename.pk3/wad/lua/soc> [filename2...]: Load add-ons\n"
|
||||
"-c forces compatmode, -n disables it.\n"));
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -4398,6 +4413,9 @@ static void Command_Addfile(void)
|
|||
int musiconly; // W_VerifyNMUSlumps isn't boolean
|
||||
boolean fileadded = false;
|
||||
|
||||
if (curarg == docompat || curarg == nocompat)
|
||||
continue;
|
||||
|
||||
fn = COM_Argv(curarg);
|
||||
|
||||
// For the amount of filenames previously processed...
|
||||
|
|
@ -4445,7 +4463,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);
|
||||
P_AddWadFile(fn, compat);
|
||||
addedfiles[numfilesadded++] = fn;
|
||||
continue;
|
||||
}
|
||||
|
|
@ -4504,6 +4522,8 @@ static void Command_Addfile(void)
|
|||
WRITEMEM(buf_p, md5sum, 16);
|
||||
}
|
||||
|
||||
WRITEUINT8(buf_p, compat);
|
||||
|
||||
addedfiles[numfilesadded++] = fn;
|
||||
|
||||
if (IsPlayerAdmin(consoleplayer) && (!server)) // Request to add file
|
||||
|
|
@ -4524,6 +4544,7 @@ static void Got_RequestAddfilecmd(UINT8 **cp, INT32 playernum)
|
|||
|
||||
READSTRINGN(*cp, filename, 240);
|
||||
READMEM(*cp, md5sum, 16);
|
||||
wadcompat_t compat = READUINT8(*cp);
|
||||
|
||||
// Only the server processes this message.
|
||||
if (client)
|
||||
|
|
@ -4569,7 +4590,7 @@ static void Got_RequestAddfilecmd(UINT8 **cp, INT32 playernum)
|
|||
return;
|
||||
}
|
||||
|
||||
COM_BufAddText(va("addfile %s\n", filename));
|
||||
COM_BufAddText(va("addfile %s %s\n", compat == WC_ON ? "-c" : (compat == WC_OFF ? "-n" : ""), filename));
|
||||
}
|
||||
|
||||
static void Got_Addfilecmd(UINT8 **cp, INT32 playernum)
|
||||
|
|
@ -4580,6 +4601,7 @@ static void Got_Addfilecmd(UINT8 **cp, INT32 playernum)
|
|||
|
||||
READSTRINGN(*cp, filename, 240);
|
||||
READMEM(*cp, md5sum, 16);
|
||||
wadcompat_t compat = READUINT8(*cp);
|
||||
|
||||
if (playernum != serverplayer)
|
||||
{
|
||||
|
|
@ -4591,7 +4613,7 @@ static void Got_Addfilecmd(UINT8 **cp, INT32 playernum)
|
|||
|
||||
ncs = findfile(filename,md5sum,true);
|
||||
|
||||
if (ncs != FS_FOUND || !P_AddWadFile(filename))
|
||||
if (ncs != FS_FOUND || !P_AddWadFile(filename, compat))
|
||||
{
|
||||
Command_ExitGame_f();
|
||||
if (ncs == FS_FOUND)
|
||||
|
|
|
|||
|
|
@ -214,6 +214,7 @@ UINT8 *PutFileNeeded(UINT16 firstfile)
|
|||
WRITEUINT32(p, wadfiles[i]->filesize);
|
||||
WRITESTRINGN(p, wadfilename, MAX_WADPATH);
|
||||
WRITEMEM(p, wadfiles[i]->md5sum, 16);
|
||||
WRITEUINT8(p, wadfiles[i]->compatmode);
|
||||
}
|
||||
if (netbuffer->packettype == PT_MOREFILESNEEDED)
|
||||
netbuffer->u.filesneededcfg.num = count;
|
||||
|
|
@ -247,6 +248,7 @@ void D_ParseFileneeded(INT32 fileneedednum_parm, UINT8 *fileneededstr, UINT16 fi
|
|||
fileneeded[i].file = NULL; // The file isn't open yet
|
||||
READSTRINGN(p, fileneeded[i].filename, MAX_WADPATH); // The next bytes are the file name
|
||||
READMEM(p, fileneeded[i].md5sum, 16); // The last 16 bytes are the file checksum
|
||||
fileneeded[i].compatmode = READUINT8(p);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -581,6 +583,10 @@ INT32 CL_CheckFiles(void)
|
|||
if (memcmp(wadfiles[j]->md5sum, fileneeded[i].md5sum, 16))
|
||||
return 2;
|
||||
|
||||
// compatmode has to match too!
|
||||
if (wadfiles[j]->compatmode != fileneeded[i].compatmode)
|
||||
return 2;
|
||||
|
||||
// It's accounted for! let's keep going.
|
||||
CONS_Debug(DBG_NETPLAY, "'%s' accounted for\n", fileneeded[i].filename);
|
||||
fileneeded[i].status = FS_OPEN;
|
||||
|
|
@ -652,7 +658,7 @@ boolean CL_LoadServerFiles(void)
|
|||
continue; // Already loaded
|
||||
else if (fileneeded[i].status == FS_FOUND)
|
||||
{
|
||||
P_PartialAddWadFile(fileneeded[i].filename);
|
||||
P_PartialAddWadFile(fileneeded[i].filename, fileneeded[i].compatmode ? WC_ON : WC_OFF);
|
||||
G_SetGameModified(true, false);
|
||||
fileneeded[i].status = FS_OPEN;
|
||||
return false;
|
||||
|
|
|
|||
|
|
@ -48,6 +48,7 @@ struct fileneeded_t
|
|||
UINT8 md5sum[16];
|
||||
filestatus_t status; // The value returned by recsearch
|
||||
boolean justdownloaded; // To prevent late fragments from causing an I_Error
|
||||
boolean compatmode;
|
||||
|
||||
// Used only for download
|
||||
FILE *file;
|
||||
|
|
|
|||
|
|
@ -2053,6 +2053,7 @@ void G_BeginRecording(void)
|
|||
nameonly(( filename = va("%s", wadfiles[i]->filename) ));
|
||||
WRITESTRINGN(demobuf.p, filename, MAX_WADPATH);
|
||||
WRITEMEM(demobuf.p, wadfiles[i]->md5sum, 16);
|
||||
WRITEUINT8(demobuf.p, wadfiles[i]->compatmode);
|
||||
|
||||
totalfiles++;
|
||||
}
|
||||
|
|
@ -2285,6 +2286,7 @@ static void G_LoadDemoExtraFiles(UINT8 **pp)
|
|||
boolean toomany = false;
|
||||
boolean alreadyloaded;
|
||||
UINT8 i, j;
|
||||
boolean compatmode;
|
||||
|
||||
totalfiles = READUINT8((*pp));
|
||||
for (i = 0; i < totalfiles; ++i)
|
||||
|
|
@ -2297,6 +2299,7 @@ static void G_LoadDemoExtraFiles(UINT8 **pp)
|
|||
SKIPSTRING((*pp));
|
||||
}
|
||||
READMEM((*pp), md5sum, 16);
|
||||
compatmode = READUINT8((*pp));
|
||||
|
||||
if (!toomany)
|
||||
{
|
||||
|
|
@ -2339,7 +2342,7 @@ static void G_LoadDemoExtraFiles(UINT8 **pp)
|
|||
}
|
||||
else
|
||||
{
|
||||
P_PartialAddWadFile(filename);
|
||||
P_PartialAddWadFile(filename, compatmode ? WC_ON : WC_OFF);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -2385,6 +2388,7 @@ static UINT8 G_CheckDemoExtraFiles(UINT8 **pp, boolean quick)
|
|||
SKIPSTRING((*pp));
|
||||
}
|
||||
READMEM((*pp), md5sum, 16);
|
||||
(void)READUINT8((*pp)); // compatmode
|
||||
|
||||
if (!toomany)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -8583,7 +8583,7 @@ boolean P_RunSOC(const char *socfilename)
|
|||
lumpnum_t lump;
|
||||
|
||||
if (strstr(socfilename, ".soc") != NULL)
|
||||
return P_AddWadFile(socfilename);
|
||||
return P_AddWadFile(socfilename, WC_AUTO);
|
||||
|
||||
lump = W_CheckNumForName(socfilename);
|
||||
if (lump == LUMPERROR)
|
||||
|
|
@ -8665,11 +8665,11 @@ static lumpinfo_t* FindFolder(const char *folName, UINT16 *start, UINT16 *end, l
|
|||
// Add a wadfile to the active wad files,
|
||||
// replace sounds, musics, patches, textures, sprites and maps
|
||||
//
|
||||
boolean P_AddWadFile(const char *wadfilename)
|
||||
boolean P_AddWadFile(const char *wadfilename, wadcompat_t compat)
|
||||
{
|
||||
UINT16 wadnum;
|
||||
|
||||
if ((wadnum = P_PartialAddWadFile(wadfilename)) == UINT16_MAX)
|
||||
if ((wadnum = P_PartialAddWadFile(wadfilename, compat)) == UINT16_MAX)
|
||||
return false;
|
||||
|
||||
P_MultiSetupWadFiles(true);
|
||||
|
|
@ -8680,7 +8680,7 @@ boolean P_AddWadFile(const char *wadfilename)
|
|||
// 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)
|
||||
UINT16 P_PartialAddWadFile(const char *wadfilename, wadcompat_t compat)
|
||||
{
|
||||
size_t i, j, sreplaces = 0, mreplaces = 0, digmreplaces = 0;
|
||||
UINT16 numlumps, wadnum;
|
||||
|
|
@ -8702,7 +8702,7 @@ UINT16 P_PartialAddWadFile(const char *wadfilename)
|
|||
// UINT16 mapPos, mapNum = 0;
|
||||
|
||||
// Init file.
|
||||
if ((numlumps = W_InitFile(wadfilename, false, false)) == INT16_MAX)
|
||||
if ((numlumps = W_InitFile(wadfilename, false, false, compat)) == INT16_MAX)
|
||||
{
|
||||
refreshdirmenu |= REFRESHDIR_NOTLOADED;
|
||||
return UINT16_MAX;
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@
|
|||
#include "doomstat.h"
|
||||
#include "r_defs.h"
|
||||
#include "k_terrain.h"
|
||||
#include "w_wad.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
|
|
@ -110,12 +111,12 @@ void P_PostLoadLevel(void);
|
|||
#ifdef HWRENDER
|
||||
void HWR_LoadLevel(void);
|
||||
#endif
|
||||
boolean P_AddWadFile(const char *wadfilename);
|
||||
boolean P_AddWadFile(const char *wadfilename, wadcompat_t compat);
|
||||
|
||||
// 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);
|
||||
UINT16 P_PartialAddWadFile(const char *wadfilename, wadcompat_t compat);
|
||||
// Run a single stage of multisetup, or all of them if fullsetup set.
|
||||
// fullsetup true: run everything
|
||||
// otherwise
|
||||
|
|
|
|||
|
|
@ -739,7 +739,7 @@ static UINT16 W_InitFileError (const char *filename, boolean exitworthy)
|
|||
//
|
||||
// Can now load dehacked files (.soc)
|
||||
//
|
||||
UINT16 W_InitFile(const char *filename, boolean mainfile, boolean startup)
|
||||
UINT16 W_InitFile(const char *filename, boolean mainfile, boolean startup, wadcompat_t compat)
|
||||
{
|
||||
FILE *handle;
|
||||
lumpinfo_t *lumpinfo = NULL;
|
||||
|
|
@ -880,7 +880,9 @@ UINT16 W_InitFile(const char *filename, boolean mainfile, boolean startup)
|
|||
#endif // HWRENDER
|
||||
|
||||
// check if compatmode is needed
|
||||
switch (wadfile->type)
|
||||
if (compat != WC_AUTO)
|
||||
wadfile->compatmode = compat == WC_ON ? true : false;
|
||||
else switch (wadfile->type)
|
||||
{
|
||||
case RET_WAD:
|
||||
wadfile->compatmode = CheckCompatWad(numwadfiles - 1);
|
||||
|
|
@ -941,7 +943,7 @@ INT32 W_InitMultipleFiles(char **filenames, boolean addons)
|
|||
G_SetGameModified(true, false);
|
||||
|
||||
//CONS_Debug(DBG_SETUP, "Loading %s\n", *filenames);
|
||||
rc = W_InitFile(*filenames, !addons, true);
|
||||
rc = W_InitFile(*filenames, !addons, true, WC_AUTO);
|
||||
if (rc == INT16_MAX)
|
||||
CONS_Printf(M_GetText("Errors occurred while loading %s; not added.\n"), *filenames);
|
||||
overallrc &= (rc != INT16_MAX) ? 1 : 0;
|
||||
|
|
|
|||
11
src/w_wad.h
11
src/w_wad.h
|
|
@ -128,9 +128,16 @@ struct wadfile_t
|
|||
UINT8 md5sum[16];
|
||||
|
||||
boolean important; // also network - !W_VerifyNMUSlumps
|
||||
boolean compatmode; // TODO: network this too!
|
||||
boolean compatmode;
|
||||
};
|
||||
|
||||
typedef enum wadcompat
|
||||
{
|
||||
WC_AUTO, // haha WC
|
||||
WC_ON,
|
||||
WC_OFF,
|
||||
} wadcompat_t;
|
||||
|
||||
#define WADFILENUM(lumpnum) (UINT16)((lumpnum)>>16) // wad flumpnum>>16) // wad file number in upper word
|
||||
#define LUMPNUM(lumpnum) (UINT16)((lumpnum)&0xFFFF) // lump number for this pwad
|
||||
|
||||
|
|
@ -144,7 +151,7 @@ void W_Shutdown(void);
|
|||
// Opens a WAD file. Returns the FILE * handle for the file, or NULL if not found or could not be opened
|
||||
FILE *W_OpenWadFile(const char **filename, boolean useerrors);
|
||||
// Load and add a wadfile to the active wad files, returns numbers of lumps, INT16_MAX on error
|
||||
UINT16 W_InitFile(const char *filename, boolean mainfile, boolean startup);
|
||||
UINT16 W_InitFile(const char *filename, boolean mainfile, boolean startup, wadcompat_t compat);
|
||||
|
||||
// W_InitMultipleFiles returns 1 if all is okay, 0 otherwise,
|
||||
// so that it stops with a message if a file was not found, but not if all is okay.
|
||||
|
|
|
|||
Loading…
Reference in a new issue