mirror of
https://git.do.srb2.org/KartKrew/Kart-Public.git
synced 2025-04-22 10:10:49 +00:00
Only pack MD5 checksum of base files in fileneeded
Not including patch.kart. This actually saves only 78 bytes in fileneeded.
This commit is contained in:
parent
b128f44986
commit
c36f2a7765
7 changed files with 68 additions and 48 deletions
27
src/d_main.c
27
src/d_main.c
|
@ -1228,31 +1228,32 @@ void D_SRB2Main(void)
|
|||
D_CleanFile(startupwadfiles);
|
||||
|
||||
mainwads = 0;
|
||||
basewads = 0;
|
||||
|
||||
#ifndef DEVELOP
|
||||
// Check MD5s of autoloaded files
|
||||
// Note: Do not add any files that ignore MD5!
|
||||
W_VerifyFileMD5(mainwads, ASSET_HASH_SRB2_SRB); // srb2.srb/srb2.wad
|
||||
W_VerifyFileMD5(mainwads, ASSET_HASH_SRB2_SRB); basewads++; // srb2.srb/srb2.wad
|
||||
#ifdef USE_PATCH_DTA
|
||||
mainwads++; W_VerifyFileMD5(mainwads, ASSET_HASH_PATCH_DTA); // patch.dta
|
||||
mainwads++; W_VerifyFileMD5(mainwads, ASSET_HASH_PATCH_DTA); basewads++; // patch.dta
|
||||
#endif
|
||||
mainwads++; W_VerifyFileMD5(mainwads, ASSET_HASH_GFX_KART); // gfx.kart
|
||||
mainwads++; W_VerifyFileMD5(mainwads, ASSET_HASH_TEXTURES_KART); // textures.kart
|
||||
mainwads++; W_VerifyFileMD5(mainwads, ASSET_HASH_CHARS_KART); // chars.kart
|
||||
mainwads++; W_VerifyFileMD5(mainwads, ASSET_HASH_MAPS_KART); // maps.kart -- 4 - If you touch this, make sure to touch up the majormods stuff below.
|
||||
mainwads++; W_VerifyFileMD5(mainwads, ASSET_HASH_GFX_KART); basewads++; // gfx.kart
|
||||
mainwads++; W_VerifyFileMD5(mainwads, ASSET_HASH_TEXTURES_KART); basewads++; // textures.kart
|
||||
mainwads++; W_VerifyFileMD5(mainwads, ASSET_HASH_CHARS_KART); basewads++; // chars.kart
|
||||
mainwads++; W_VerifyFileMD5(mainwads, ASSET_HASH_MAPS_KART); basewads++; // maps.kart -- 4 - If you touch this, make sure to touch up the majormods stuff below.
|
||||
#ifdef USE_PATCH_KART
|
||||
mainwads++; W_VerifyFileMD5(mainwads, ASSET_HASH_PATCH_KART); // patch.kart
|
||||
mainwads++; W_VerifyFileMD5(mainwads, ASSET_HASH_PATCH_KART); // patch.kart
|
||||
#endif
|
||||
#else
|
||||
#ifdef USE_PATCH_DTA
|
||||
mainwads++; // patch.dta
|
||||
mainwads++; basewads++; // patch.dta
|
||||
#endif
|
||||
mainwads++; // gfx.kart
|
||||
mainwads++; // textures.kart
|
||||
mainwads++; // chars.kart
|
||||
mainwads++; // maps.kart
|
||||
mainwads++; basewads++; // gfx.kart
|
||||
mainwads++; basewads++; // textures.kart
|
||||
mainwads++; basewads++; // chars.kart
|
||||
mainwads++; basewads++; // maps.kart
|
||||
#ifdef USE_PATCH_KART
|
||||
mainwads++; // patch.kart
|
||||
mainwads++; // patch.kart
|
||||
#endif
|
||||
|
||||
#endif //ifndef DEVELOP
|
||||
|
|
|
@ -114,7 +114,16 @@ UINT8 *PutFileNeeded(void)
|
|||
char wadfilename[MAX_WADPATH] = "";
|
||||
UINT8 filestatus;
|
||||
|
||||
for (i = 0; i < numwadfiles; i++)
|
||||
#ifdef USE_PATCH_KART
|
||||
WRITEUINT8(p, 1);/* We will never send patch.kart! */
|
||||
count++;
|
||||
WRITEUINT32(p, wadfiles[mainwads]->filesize);
|
||||
nameonly(strcpy(wadfilename, wadfiles[mainwads]->filename));
|
||||
WRITESTRINGN(p, wadfilename, MAX_WADPATH);
|
||||
WRITEMEM(p, wadfiles[mainwads]->md5sum, 16);
|
||||
#endif
|
||||
|
||||
for (i = mainwads+1; i < numwadfiles; i++)
|
||||
{
|
||||
// If it has only music/sound lumps, don't put it in the list
|
||||
if (!wadfiles[i]->important)
|
||||
|
@ -140,6 +149,14 @@ UINT8 *PutFileNeeded(void)
|
|||
}
|
||||
netbuffer->u.serverinfo.fileneedednum = (UINT8)count;
|
||||
|
||||
for (i = 0; i < basewads; ++i)
|
||||
{
|
||||
if (!wadfiles[i]->important)
|
||||
continue;
|
||||
|
||||
WRITEMEM(p, wadfiles[i]->md5sum, 16);
|
||||
}
|
||||
|
||||
return p;
|
||||
}
|
||||
|
||||
|
@ -155,9 +172,9 @@ void D_ParseFileneeded(INT32 fileneedednum_parm, UINT8 *fileneededstr)
|
|||
UINT8 *p;
|
||||
UINT8 filestatus;
|
||||
|
||||
fileneedednum = fileneedednum_parm;
|
||||
fileneedednum = basewads + fileneedednum_parm;
|
||||
p = (UINT8 *)fileneededstr;
|
||||
for (i = 0; i < fileneedednum; i++)
|
||||
for (i = basewads; i < fileneedednum; i++)
|
||||
{
|
||||
fileneeded[i].status = FS_NOTFOUND; // We haven't even started looking for the file yet
|
||||
filestatus = READUINT8(p); // The first byte is the file status
|
||||
|
@ -167,6 +184,12 @@ void D_ParseFileneeded(INT32 fileneedednum_parm, UINT8 *fileneededstr)
|
|||
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
|
||||
}
|
||||
for (i = 0; i < basewads; ++i)
|
||||
{
|
||||
fileneeded[i].status = FS_NOTFOUND;
|
||||
fileneeded[i].willsend = 0;
|
||||
READMEM(p, fileneeded[i].md5sum, 16);
|
||||
}
|
||||
}
|
||||
|
||||
void CL_PrepareDownloadSaveGame(const char *tmpsave)
|
||||
|
@ -189,7 +212,7 @@ boolean CL_CheckDownloadable(void)
|
|||
{
|
||||
UINT8 i,dlstatus = 0;
|
||||
|
||||
for (i = 0; i < fileneedednum; i++)
|
||||
for (i = basewads; i < fileneedednum; i++)
|
||||
if (fileneeded[i].status != FS_FOUND && fileneeded[i].status != FS_OPEN)
|
||||
{
|
||||
if (fileneeded[i].willsend == 1)
|
||||
|
@ -210,7 +233,7 @@ boolean CL_CheckDownloadable(void)
|
|||
|
||||
// not downloadable, put reason in console
|
||||
CONS_Alert(CONS_NOTICE, M_GetText("You need additional files to connect to this server:\n"));
|
||||
for (i = 0; i < fileneedednum; i++)
|
||||
for (i = basewads; i < fileneedednum; i++)
|
||||
if (fileneeded[i].status != FS_FOUND && fileneeded[i].status != FS_OPEN)
|
||||
{
|
||||
CONS_Printf(" * \"%s\" (%dK)", fileneeded[i].filename, fileneeded[i].totalsize >> 10);
|
||||
|
@ -262,7 +285,7 @@ boolean CL_SendRequestFile(void)
|
|||
if (M_CheckParm("-nodownload"))
|
||||
I_Error("Attempted to download files in -nodownload mode");
|
||||
|
||||
for (i = 0; i < fileneedednum; i++)
|
||||
for (i = basewads; i < fileneedednum; i++)
|
||||
if (fileneeded[i].status != FS_FOUND && fileneeded[i].status != FS_OPEN
|
||||
&& (fileneeded[i].willsend == 0 || fileneeded[i].willsend == 2))
|
||||
{
|
||||
|
@ -272,7 +295,7 @@ boolean CL_SendRequestFile(void)
|
|||
|
||||
netbuffer->packettype = PT_REQUESTFILE;
|
||||
p = (char *)netbuffer->u.textcmd;
|
||||
for (i = 0; i < fileneedednum; i++)
|
||||
for (i = basewads; i < fileneedednum; i++)
|
||||
if ((fileneeded[i].status == FS_NOTFOUND || fileneeded[i].status == FS_MD5SUMBAD))
|
||||
{
|
||||
totalfreespaceneeded += fileneeded[i].totalsize;
|
||||
|
@ -335,18 +358,15 @@ INT32 CL_CheckFiles(void)
|
|||
// if (M_CheckParm("-nofiles"))
|
||||
// return 1;
|
||||
|
||||
// the first is the iwad (the main wad file)
|
||||
// we don't care if it's called srb2.srb or srb2.wad.
|
||||
// Never download the IWAD, just assume it's there and identical
|
||||
fileneeded[0].status = FS_OPEN;
|
||||
|
||||
// Modified game handling -- check for an identical file list
|
||||
// must be identical in files loaded AND in order
|
||||
// Return 2 on failure -- disconnect from server
|
||||
//
|
||||
// Also, don't download any base files! Including patch.kart.
|
||||
if (modifiedgame)
|
||||
{
|
||||
CONS_Debug(DBG_NETPLAY, "game is modified; only doing basic checks\n");
|
||||
for (i = 1, j = 1; i < fileneedednum || j < numwadfiles;)
|
||||
for (i = basewads, j = basewads; i < fileneedednum || j < numwadfiles;)
|
||||
{
|
||||
if (j < numwadfiles && !wadfiles[j]->important)
|
||||
{
|
||||
|
@ -376,12 +396,20 @@ INT32 CL_CheckFiles(void)
|
|||
// See W_LoadWadFile in w_wad.c
|
||||
packetsize = packetsizetally;
|
||||
|
||||
for (i = 1; i < fileneedednum; i++)
|
||||
for (i = 0; i < basewads; ++i)
|
||||
{
|
||||
if (memcmp(wadfiles[i]->md5sum, fileneeded[i].md5sum, 16) == 0)
|
||||
fileneeded[i].status = FS_OPEN;
|
||||
else
|
||||
fileneeded[i].status = FS_MD5SUMBAD;
|
||||
}
|
||||
|
||||
for (i = basewads; i < fileneedednum; i++)
|
||||
{
|
||||
CONS_Debug(DBG_NETPLAY, "searching for '%s' ", fileneeded[i].filename);
|
||||
|
||||
// Check in already loaded files
|
||||
for (j = 1; wadfiles[j]; j++)
|
||||
for (j = basewads; wadfiles[j]; j++)
|
||||
{
|
||||
nameonly(strcpy(wadfilename, wadfiles[j]->filename));
|
||||
if (!stricmp(wadfilename, fileneeded[i].filename) &&
|
||||
|
@ -419,7 +447,7 @@ void CL_LoadServerFiles(void)
|
|||
// if (M_CheckParm("-nofiles"))
|
||||
// return;
|
||||
|
||||
for (i = 1; i < fileneedednum; i++)
|
||||
for (i = basewads; i < fileneedednum; i++)
|
||||
{
|
||||
if (fileneeded[i].status == FS_OPEN)
|
||||
continue; // Already loaded
|
||||
|
@ -755,20 +783,6 @@ void Got_Filetxpak(void)
|
|||
char *filename = file->filename;
|
||||
static INT32 filetime = 0;
|
||||
|
||||
if (!(strcmp(filename, "srb2.srb")
|
||||
&& strcmp(filename, "srb2.wad")
|
||||
&& strcmp(filename, "patch.dta")
|
||||
//&& strcmp(filename, "music.dta")
|
||||
&& strcmp(filename, "gfx.kart")
|
||||
&& strcmp(filename, "textures.kart")
|
||||
&& strcmp(filename, "chars.kart")
|
||||
&& strcmp(filename, "maps.kart")
|
||||
&& strcmp(filename, "sounds.kart")
|
||||
&& strcmp(filename, "music.kart")
|
||||
&& strcmp(filename, "patch.kart")
|
||||
))
|
||||
I_Error("Tried to download \"%s\"", filename);
|
||||
|
||||
if (filenum >= fileneedednum)
|
||||
{
|
||||
DEBFILE(va("fileframent not needed %d>%d\n", filenum, fileneedednum));
|
||||
|
|
|
@ -56,6 +56,7 @@ extern boolean gamecomplete;
|
|||
extern boolean modifiedgame;
|
||||
extern boolean majormods;
|
||||
extern UINT16 mainwads;
|
||||
extern UINT16 basewads;
|
||||
extern boolean savemoddata; // This mod saves time/emblem data.
|
||||
extern boolean imcontinuing; // Temporary flag while continuing
|
||||
extern boolean metalrecording;
|
||||
|
|
|
@ -87,6 +87,7 @@ INT16 lastmapsaved = 0; // Last map we auto-saved at
|
|||
boolean gamecomplete = false;
|
||||
|
||||
UINT16 mainwads = 0;
|
||||
UINT16 basewads = 0;
|
||||
boolean modifiedgame = false; // Set if homebrew PWAD stuff has been added.
|
||||
boolean majormods = false; // Set if Lua/Gameplay SOC/replacement map has been added.
|
||||
boolean savemoddata = false;
|
||||
|
|
|
@ -3353,7 +3353,7 @@ boolean P_AddWadFile(const char *wadfilename)
|
|||
boolean mapsadded = false;
|
||||
boolean replacedcurrentmap = false;
|
||||
|
||||
if ((numlumps = W_InitFile(wadfilename)) == INT16_MAX)
|
||||
if ((numlumps = W_InitFile(wadfilename, false)) == INT16_MAX)
|
||||
{
|
||||
refreshdirmenu |= REFRESHDIR_NOTLOADED;
|
||||
CONS_Printf(M_GetText("Errors occurred while loading %s; not added.\n"), wadfilename);
|
||||
|
|
|
@ -644,7 +644,7 @@ static lumpinfo_t* ResGetLumpsZip (FILE* handle, UINT16* nlmp)
|
|||
//
|
||||
// Can now load dehacked files (.soc)
|
||||
//
|
||||
UINT16 W_InitFile(const char *filename)
|
||||
UINT16 W_InitFile(const char *filename, boolean addon)
|
||||
{
|
||||
FILE *handle;
|
||||
lumpinfo_t *lumpinfo = NULL;
|
||||
|
@ -689,7 +689,10 @@ UINT16 W_InitFile(const char *filename)
|
|||
// see PutFileNeeded in d_netfil.c
|
||||
if ((important = !W_VerifyNMUSlumps(filename)))
|
||||
{
|
||||
packetsize = packetsizetally + nameonlylength(filename) + 22;
|
||||
if (addon)
|
||||
packetsize = packetsizetally + 16;/* only md5sum--for base files! */
|
||||
else
|
||||
packetsize = packetsizetally + nameonlylength(filename) + 22;
|
||||
|
||||
if (packetsize > MAXFILENEEDED*sizeof(UINT8))
|
||||
{
|
||||
|
@ -866,7 +869,7 @@ INT32 W_InitMultipleFiles(char **filenames, boolean addons)
|
|||
G_SetGameModified(true, false);
|
||||
|
||||
//CONS_Debug(DBG_SETUP, "Loading %s\n", *filenames);
|
||||
rc &= (W_InitFile(*filenames) != INT16_MAX) ? 1 : 0;
|
||||
rc &= (W_InitFile(*filenames, addons) != INT16_MAX) ? 1 : 0;
|
||||
}
|
||||
|
||||
if (!numwadfiles)
|
||||
|
|
|
@ -126,7 +126,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);
|
||||
UINT16 W_InitFile(const char *filename, boolean addon);
|
||||
#ifdef DELFILE
|
||||
void W_UnloadWadFile(UINT16 num);
|
||||
#endif
|
||||
|
|
Loading…
Reference in a new issue