diff --git a/src/qcommon/files.c b/src/qcommon/files.c index 7dcdb2945..d94debb36 100644 --- a/src/qcommon/files.c +++ b/src/qcommon/files.c @@ -3512,7 +3512,6 @@ static void FS_Startup(const char *gameName) } } -#if !defined(DO_LIGHT_DEDICATED) /* ===================== FS_LoadedPakChecksums @@ -3606,7 +3605,6 @@ const char *FS_LoadedPakPureChecksums(void) Q_strcat(info, sizeof(info), va("%i ", search->pack->pure_checksum)); } - // DO_LIGHT_DEDICATED // only comment out when you need a new pure checksums string //Com_DPrintf("FS_LoadPakPureChecksums: %s\n", info); @@ -3690,9 +3688,8 @@ Servers with sv_pure set will get this string back from clients for pure validat The string has a specific order, "cgame ui @ ref1 ref2 ref3 ..." -NOTE TTimo - DO_LIGHT_DEDICATED -this function is only used by the client to build the string sent back to server -we don't have any need of overriding it for light, but it's useless in dedicated +this function is only used by the client to build the string sent back to server, +it's useless in dedicated ===================== */ const char *FS_ReferencedPakPureChecksums(void) @@ -3740,352 +3737,6 @@ const char *FS_ReferencedPakPureChecksums(void) return info; } -#else // DO_LIGHT_DEDICATED implementation follows - -/* -========================================================================================= -DO_LIGHT_DEDICATED, general notes -we are going to fake the checksums sent to the clients -that only matters to the pk3 we have replaced by their lighter version, currently: - -Cvar_Set2: sv_pakNames mp_pakmaps0 mp_pak2 mp_pak1 mp_pak0 pak0 -Cvar_Set2: sv_paks -1153491798 125907563 -1023558518 764840216 1886207346 - -all the files above have their 'server required' content collapsed into a single pak0.pk3 - -the other .pk3 files should be handled as usual - -more details are in unix/dedicated-only.txt - -========================================================================================= -*/ - -// our target faked checksums -// those don't need to be encrypted or anything, that's what you see in the +set developer 1 -static const char *pak_checksums = "-137448799 131270674 125907563 -1023558518 764840216 1886207346"; -static const char *pak_names = "mp_pak4 mp_pak3 mp_pak2 mp_pak1 mp_pak0 pak0"; - -/* -this is the pure checksum string for a constant value of fs_checksumFeed we have choosen (see SV_SpawnServer) -to obtain the new string for a different fs_checksumFeed value, run a regular server and enable the relevant -verbosity code in SV_SpawnServer and FS_LoadedPakPureChecksums (the full server version of course) - -NOTE: if you have an mp_bin in the middle, you need to take out it's checksum - (we keep mp_bin out of the faked stuff because we don't want to have to update those feeds too often heh) - -once you have the clear versions, you can shift them by commenting out the code chunk in FS_RandChecksumFeed -you need to use the right line in FS_LoadedPakPureChecksums wether you are running on clear strings, or shifted ones -*/ - -/* -// clear checksums, rebuild those from a regular server and you will shift them next -static const int feeds[5] = { - 0x14d48835, 0xc44ed670, 0xd1c8da0d, 0x98df0626, 0xb4e51e7a -}; - -static const char* pak_purechecksums[5] = { - "-631058236 1439191868 -1758535722 -1109639830 -756342425 -26055934", - "420891163 -2077045804 -1212476885 273103692 1907819222 -1162012968", - "724865970 393950398 1987220301 679766798 -966287476 -1045306141", - "468836794 -690412926 -481399336 1089964294 -1538547350 394664641", - "-1484520489 -1891368444 -510451918 -919424191 -1623567814 889557862" -}; -*/ - -static const int feeds[5] = -{ - 0x14d48835, 0xc44ed670, 0xd1c8da0d, 0x98df0626, 0xb4e51e7a -}; - -// shifted strings, so that it's not directly scannable from exe -// see FS_RandChecksumFeed to generate them -static const char *pak_purechecksums[5] = -{ - // rain - escaped ?s to prevent parsing as trigraph - ":C@>=BE?@C->A@F>F>ECE-:>DBEB@BD\?\?-:>>=FC@FE@=-:DBC@A?A?B-:?C=BBF@A", - "B@>FG??DA.;@>EE>BCF>B.;?@?@BEDFFC.@EA?>ADG@.?G>EF?G@@@.;??D@>?@GDF", - "FACGEDHF?/BHBHD?BHG/@HGFAA?B?@/EFHFEEFHG/BEIEFCAEIJ1>BIJBDGIEEE1>FBAEFBJBI1>JBJECEBJB1>BGCDFGHIBE1IIJFFHIGC" -}; - -// counter to walk through the randomized list -static int feed_index = -1; - -static int lookup_randomized[5] = { 0, 1, 2, 3, 4 }; - -/* -===================== -randomize the order of the 5 checksums we rely on -5 random swaps of the table -===================== -*/ -void FS_InitRandomFeed() -{ - int i, swap, aux; - - for (i = 0; i < 5; i++) - { - swap = (int)(5.0 * rand() / (RAND_MAX + 1.0)); - aux = lookup_randomized[i]; - lookup_randomized[i] = lookup_randomized[swap]; - lookup_randomized[swap] = aux; - } -} - -/* -===================== -FS_RandChecksumFeed - -Return a random checksum feed among our list -we keep the seed and use it when requested for the pure checksum -===================== -*/ -int FS_RandChecksumFeed() -{ - /* - // use this to dump shifted versions of the pure checksum strings - int i; - for(i=0;i<5;i++) - { - Com_Printf("FS_RandChecksumFeed: %s\n", FS_ShiftStr(pak_purechecksums[i], 13+i)); - } - */ - if (feed_index == -1) - { - FS_InitRandomFeed(); - } - feed_index = (feed_index + 1) % 5; - - return feeds[lookup_randomized[feed_index]]; -} - -/* -===================== -FS_LoadedPakChecksums - -Returns a space separated string containing the checksums of all loaded pk3 files. -Servers with sv_pure set will get this string and pass it to clients. - -DO_LIGHT_DEDICATED: -drop lightweight pak0 checksum, put the faked pk3s checksums instead -===================== -*/ -const char *FS_LoadedPakChecksums(void) -{ - static char info[BIG_INFO_STRING]; - searchpath_t *search; - - info[0] = 0; - - for (search = fs_searchpaths ; search ; search = search->next) - { - // is the element a pak file? - if (!search->pack) - { - continue; - } - - if (strcmp(search->pack->pakBasename, "pak0")) - { - // this is a regular pk3 - Q_strcat(info, sizeof(info), va("%i ", search->pack->checksum)); - } - else - { - // this is the light pk3 - Q_strcat(info, sizeof(info), va("%s ", pak_checksums)); - } - } - - return info; -} - -/* -===================== -FS_LoadedPakNames - -Returns a space separated string containing the names of all loaded pk3 files. -Servers with sv_pure set will get this string and pass it to clients. - -DO_LIGHT_DEDICATED: -drop lightweight pak0 name, put the faked pk3s names instead -===================== -*/ -const char *FS_LoadedPakNames(void) -{ - static char info[BIG_INFO_STRING]; - searchpath_t *search; - - info[0] = 0; - - for (search = fs_searchpaths ; search ; search = search->next) - { - // is the element a pak file? - if (!search->pack) - { - continue; - } - - if (*info) - { - Q_strcat(info, sizeof(info), " "); - } - if (strcmp(search->pack->pakBasename, "pak0")) - { - // regular pk3 - Q_strcat(info, sizeof(info), search->pack->pakBasename); - } - else - { - // light pk3 - Q_strcat(info, sizeof(info), pak_names); - } - } - - return info; -} - -/* -===================== -FS_LoadedPakPureChecksums - -Returns a space separated string containing the pure checksums of all loaded pk3 files. -Servers with sv_pure use these checksums to compare with the checksums the clients send -back to the server. - -DO_LIGHT_DEDICATED: -FS_LoadPakChecksums to send the pak string to the client -FS_LoadPakPureChecksums is used locally to compare against what the client sends back - -the pure_checksums are computed by Com_MemoryBlockChecksum with a random key (fs_checksumFeed) -since we can't do this on restricted server, we always use the same fs_checksumFeed value - -drop lightweight pak0 checksum, put the faked pk3s pure checksums instead - -===================== -*/ -const char *FS_LoadedPakPureChecksums(void) -{ - static char info[BIG_INFO_STRING]; - searchpath_t *search; - - info[0] = 0; - - for (search = fs_searchpaths ; search ; search = search->next) - { - // is the element a pak file? - if (!search->pack) - { - continue; - } - - if (strcmp(search->pack->pakBasename, "pak0")) - { - // this is a regular pk3 - Q_strcat(info, sizeof(info), va("%i ", search->pack->pure_checksum)); - } - else - { - // this is the light pk3 - // use this if you are running on shifted strings - Q_strcat(info, sizeof(info), va("%s ", FS_ShiftStr(pak_purechecksums[lookup_randomized[feed_index]], -13 - lookup_randomized[feed_index]))); - // use this if you are running on clear checksum strings instead of shifted ones - //Q_strcat( info, sizeof( info ), va("%s ", pak_purechecksums[lookup_randomized[feed_index]] ) ); - } - } - - return info; -} - -/* -===================== -FS_ReferencedPakChecksums - -Returns a space separated string containing the checksums of all referenced pk3 files. -The server will send this to the clients so they can check which files should be auto-downloaded. - -DO_LIGHT_DEDICATED: -don't send the checksum of pak0 (even if it's referenced) - -NOTE: -do we need to fake referenced paks too? -those are Id paks, so you can't download them -mp_pakmaps0 would be a worthy candidate for download though, but we don't have it anyway -the only thing if we omit sending of some referenced stuff, you don't get the console message that says "you're missing this" -===================== -*/ -const char *FS_ReferencedPakChecksums(void) -{ - static char info[BIG_INFO_STRING]; - searchpath_t *search; - - info[0] = 0; - - for (search = fs_searchpaths ; search ; search = search->next) - { - // is the element a pak file? - if (search->pack) - { - if (search->pack->referenced) - { - if (strcmp(search->pack->pakBasename, "pak0")) - { - // this is not the light pk3 - Q_strcat(info, sizeof(info), va("%i ", search->pack->checksum)); - } - } - } - } - - return info; -} - -/* -===================== -FS_ReferencedPakNames - -Returns a space separated string containing the names of all referenced pk3 files. -The server will send this to the clients so they can check which files should be auto-downloaded. - -DO_LIGHT_DEDICATED: -don't send pak0 see above for details -===================== -*/ -const char *FS_ReferencedPakNames(void) -{ - static char info[BIG_INFO_STRING]; - searchpath_t *search; - - info[0] = 0; - - // we want to return ALL pk3's from the fs_game path - // and referenced one's from baseq3 - for (search = fs_searchpaths ; search ; search = search->next) - { - // is the element a pak file? - if (search->pack) - { - if (*info) - { - Q_strcat(info, sizeof(info), " "); - } - if (search->pack->referenced) - { - if (strcmp(search->pack->pakBasename, "pak0")) - { - // this is not the light pk3 - Q_strcat(info, sizeof(info), search->pack->pakGamename); - Q_strcat(info, sizeof(info), "/"); - Q_strcat(info, sizeof(info), search->pack->pakBasename); - } - } - } - } - - return info; -} -#endif /* ===================== diff --git a/src/qcommon/qcommon.h b/src/qcommon/qcommon.h index 8e2044458..140b56e64 100644 --- a/src/qcommon/qcommon.h +++ b/src/qcommon/qcommon.h @@ -737,10 +737,6 @@ extern int cl_connectedToPureServer; qboolean FS_CL_ExtractFromPakFile(const char *base, const char *gamedir, const char *filename); #endif -#if defined(DO_LIGHT_DEDICATED) -int FS_RandChecksumFeed(); -#endif - char *FS_ShiftStr(const char *string, int shift); void FS_CopyFile(char *fromOSPath, char *toOSPath); diff --git a/src/server/sv_init.c b/src/server/sv_init.c index c531030a3..a30a5fd4f 100644 --- a/src/server/sv_init.c +++ b/src/server/sv_init.c @@ -580,22 +580,13 @@ void SV_SpawnServer(char *server) // make sure we are not paused Cvar_Set("cl_paused", "0"); -#if !defined(DO_LIGHT_DEDICATED) // get a new checksum feed and restart the file system srand(Sys_Milliseconds()); sv.checksumFeed = (((int) rand() << 16) ^ rand()) ^ Sys_Milliseconds(); - // DO_LIGHT_DEDICATED // only comment out when you need a new pure checksum string and it's associated random feed // Com_DPrintf("SV_SpawnServer checksum feed: %p\n", sv.checksumFeed); -#else // DO_LIGHT_DEDICATED implementation below - // we are not able to randomize the checksum feed since the feed is used as key for pure_checksum computations - // files.c 1776 : pack->pure_checksum = Com_BlockChecksumKey( fs_headerLongs, 4 * fs_numHeaderLongs, LittleLong(fs_checksumFeed) ); - // we request a fake randomized feed, files.c knows the answer - srand(Sys_Milliseconds()); - sv.checksumFeed = FS_RandChecksumFeed(); -#endif FS_Restart(sv.checksumFeed); CM_LoadMap(va("maps/%s.bsp", server), qfalse, &checksum);