diff --git a/src/d_main.c b/src/d_main.c index dc64ba6f7..da2c7bd7d 100644 --- a/src/d_main.c +++ b/src/d_main.c @@ -1057,25 +1057,23 @@ static INT32 D_DetectFileType(const char* filename) { if (pathisdirectory(filename) == 1) return 1; - else - { - if (!stricmp(&filename[strlen(filename) - 4], ".wad")) - return 2; - else if (!stricmp(&filename[strlen(filename) - 4], ".pk3")) - return 3; - else if (!stricmp(&filename[strlen(filename) - 5], ".kart")) - return 4; - else if (!stricmp(&filename[strlen(filename) - 4], ".lua")) - return 5; - else if (!stricmp(&filename[strlen(filename) - 4], ".soc")) - return 6; + const size_t len = strlen(filename); - else if (!stricmp(&filename[strlen(filename) - 4], ".cfg")) - return 7; - else if (!stricmp(&filename[strlen(filename) - 4], ".txt")) - return 8; - } + if (!stricmp(&filename[len - 4], ".wad")) + return 2; + else if (!stricmp(&filename[len - 4], ".pk3")) + return 3; + else if (!stricmp(&filename[len - 5], ".kart")) + return 4; + else if (!stricmp(&filename[len - 4], ".lua")) + return 5; + else if (!stricmp(&filename[len - 4], ".soc")) + return 6; + else if (!stricmp(&filename[len - 4], ".cfg")) + return 7; + else if (!stricmp(&filename[len - 4], ".txt")) + return 8; return 0; } @@ -1241,35 +1239,11 @@ static boolean AddIWAD(void) return false; } -// extra graphic patches for saturn specific thingies +// Optional saturn extra files boolean found_extra_kart = false; boolean found_extra2_kart = false; boolean found_extra3_kart = false; -boolean xtra_speedo = false; // extra speedometer check -boolean xtra_speedo_clr = false; // extra speedometer colour check -boolean xtra_speedo3 = false; // 80x 11 extra speedometer check -boolean xtra_speedo_clr3 = false; // 80x 11 extra speedometer colour check -boolean achi_speedo = false; // achiiro speedometer check -boolean achi_speedo_clr = false; // extra speedometer colour check -boolean dial_speedo = false; // dial speedometer check -boolean dial_speedo_clr = false; // dial speedometer colour check -boolean kartz_speedo = false; // kartZ speedo -boolean kartz_speedo_smol = false; // kartZ speedo but smol - -boolean clr_hud = false; // colour hud check -boolean driftgaugegfx_clr = false; // driftgauge colour check -boolean big_lap = false; // bigger lap counter -boolean big_lap_color = false; // bigger lap counter but colour -boolean statdp = false; // stat display for extended player setup -boolean nametaggfx = false; // Nametag stuffs -boolean driftgaugegfx = false; // Driftgauge stuffs -boolean multiitem_icon = false; // Extra icons for Sneakers, Banana and Jawz -boolean joystickicon = false; // Extra icons for the joystick input display -boolean minidoticon = false; // Dot graphic for minimap player angle display -boolean minilighticon = false; // mkwii-style minimap headlight -// - static void IdentifyVersion(void) { const char *srb2waddir = NULL; @@ -1318,30 +1292,39 @@ static void IdentifyVersion(void) D_AddFile(va(pandf,srb2waddir,"patch.dta")); #endif - D_AddFile(va(pandf,srb2waddir,"gfx.kart"), startupwadfiles); - D_AddFile(va(pandf,srb2waddir,"textures.kart"), startupwadfiles); - D_AddFile(va(pandf,srb2waddir,"chars.kart"), startupwadfiles); - D_AddFile(va(pandf,srb2waddir,"maps.kart"), startupwadfiles); + D_AddFile(va(pandf, srb2waddir, "gfx.kart"), startupwadfiles); + D_AddFile(va(pandf, srb2waddir, "textures.kart"), startupwadfiles); + D_AddFile(va(pandf, srb2waddir, "chars.kart"), startupwadfiles); + D_AddFile(va(pandf, srb2waddir, "maps.kart"), startupwadfiles); #ifdef USE_PATCH_KART D_AddFile(va(pandf,srb2waddir,"patch.kart"), startupwadfiles); #endif + + const char *path = NULL; + + path = va(pandf, srb2waddir, "extra.kart"); + // completely optional - if (FIL_ReadFileOK(va(pandf,srb2waddir,"extra.kart"))) + if (FIL_ReadFileOK(path)) { - D_AddFile(va(pandf,srb2waddir,"extra.kart"), startupwadfiles); + D_AddFile(path, startupwadfiles); found_extra_kart = true; } + path = va(pandf, srb2waddir, "extra2.kart"); + // completely optional 2: Back with a vengence - if (FIL_ReadFileOK(va(pandf,srb2waddir,"extra2.kart"))) + if (FIL_ReadFileOK(path)) { - D_AddFile(va(pandf,srb2waddir,"extra2.kart"), startupwadfiles); + D_AddFile(path, startupwadfiles); found_extra2_kart = true; } - if (FIL_ReadFileOK(va(pandf,srb2waddir,"extra3.kart"))) + path = va(pandf, srb2waddir, "extra3.kart"); + + if (FIL_ReadFileOK(path)) { - D_AddFile(va(pandf,srb2waddir,"extra3.kart"), startupwadfiles); + D_AddFile(path, startupwadfiles); found_extra3_kart = true; } @@ -1378,11 +1361,12 @@ static inline void D_MakeTitleString(char *s) char *t; const char *u; INT32 i; + const size_t len = (80-strlen(s))/2; for (i = 0, t = temp; i < 82; i++) *t++=' '; - for (t = temp + (80-strlen(s))/2, u = s; *u != '\0' ;) + for (t = temp + len, u = s; *u != '\0' ;) *t++ = *u++; u = compdate; @@ -1396,6 +1380,31 @@ static inline void D_MakeTitleString(char *s) strcpy(s, temp); } +// extra graphic patches for saturn specific thingies +boolean xtra_speedo = false; // extra speedometer check +boolean xtra_speedo_clr = false; // extra speedometer colour check +boolean xtra_speedo3 = false; // 80x 11 extra speedometer check +boolean xtra_speedo_clr3 = false; // 80x 11 extra speedometer colour check +boolean achi_speedo = false; // achiiro speedometer check +boolean achi_speedo_clr = false; // extra speedometer colour check +boolean dial_speedo = false; // dial speedometer check +boolean dial_speedo_clr = false; // dial speedometer colour check +boolean kartz_speedo = false; // kartZ speedo +boolean kartz_speedo_smol = false; // kartZ speedo but smol + +boolean clr_hud = false; // colour hud check +boolean driftgaugegfx_clr = false; // driftgauge colour check +boolean big_lap = false; // bigger lap counter +boolean big_lap_color = false; // bigger lap counter but colour +boolean statdp = false; // stat display for extended player setup +boolean nametaggfx = false; // Nametag stuffs +boolean driftgaugegfx = false; // Driftgauge stuffs +boolean multiitem_icon = false; // Extra icons for Sneakers, Banana and Jawz +boolean joystickicon = false; // Extra icons for the joystick input display +boolean minidoticon = false; // Dot graphic for minimap player angle display +boolean minilighticon = false; // mkwii-style minimap headlight +// + static void D_CheckSaturnExtraFiles(void) { // Possible value that changes depending on whether required files for speedometer are found or not @@ -1497,12 +1506,14 @@ static void D_CheckSaturnExtraFiles(void) PUSHCONS(inputdisplay_cons_temp, last_inputdisplay_i, 3, "StickGFX"); } + // minimap dot if (W_LumpExists("MMAPDOT")) { minidoticon = true; PUSHCONS(minimapdot_cons_temp, last_minimapdot_i, 1, "Dot"); } + // minimap headlight if (W_LumpExists("MMAPHDLT")) { minilighticon = true; @@ -1981,13 +1992,7 @@ void D_SRB2Main(void) R_Init(); // setting up sound - if (dedicated) - { - sound_disabled = true; - music_disabled = true; - } - - if (M_CheckParm("-noaudio")) // combines -nosound and -nomusic + if (dedicated || M_CheckParm("-noaudio")) // combines -nosound and -nomusic { sound_disabled = true; music_disabled = true; @@ -2125,12 +2130,6 @@ void D_SRB2Main(void) } #endif - /*if (M_CheckParm("-ultimatemode")) - { - autostart = true; - ultimatemode = true; - }*/ - if (autostart || netgame) { gameaction = ga_nothing; @@ -2275,6 +2274,9 @@ const char *D_Home(void) } #endif// !__CYGWIN__ #endif// _WIN32 - if (usehome) return userhome; - else return NULL; + + if (usehome) + return userhome; + else + return NULL; } diff --git a/src/k_hud.c b/src/k_hud.c index 93d9b7b09..f433edcdd 100644 --- a/src/k_hud.c +++ b/src/k_hud.c @@ -1089,6 +1089,11 @@ boolean K_UseColorHud(void) return (cv_colorizedhud.value && clr_hud); } +// Since all our extra Saturn things are in optional files +// we gotta do a bunch of extra checks to determine +// if the according Assets are actually loaded +// see D_CheckSaturnExtraFiles in d_main.c + enum { SPEEDO_VANILLA, @@ -1175,7 +1180,7 @@ boolean K_UseHighResPortraits(void) return (cv_highresportrait.value && K_IsHighResolution()); } -// returns the players faceprefix +// returns the players faceprefix patch // accounts for localskins patch_t *K_GetFacePrefix(player_t *player, INT32 skinnum) { @@ -4002,7 +4007,6 @@ static void K_drawBattleFullscreen(void) else V_DrawFixedPatch(x<kartstuff[k_comebacktimer]/TICRATE)); } } diff --git a/src/w_wad.c b/src/w_wad.c index 906d5a7b9..4de33071c 100644 --- a/src/w_wad.c +++ b/src/w_wad.c @@ -253,6 +253,7 @@ static inline void W_LoadDehackedLumpsPK3(UINT16 wadnum) lumpinfo_t *lump_p = &wadfiles[wadnum]->lumpinfo[posStart]; size_t length = strlen(wadfiles[wadnum]->filename) + 1 + strlen(lump_p->fullname); // length of file name, '|', and lump name char *name = malloc(length + 1); + sprintf(name, "%s|%s", wadfiles[wadnum]->filename, lump_p->fullname); name[length] = '\0'; CONS_Printf(M_GetText("Loading SOC from %s\n"), name); @@ -278,6 +279,7 @@ static inline void W_LoadDehackedLumps(UINT16 wadnum) { lumpinfo_t *lump_p = wadfiles[wadnum]->lumpinfo; for (lump = 0; lump < wadfiles[wadnum]->numlumps; lump++, lump_p++) + { if (memcmp(lump_p->name,"SOC_",4)==0) // Check for generic SOC lump { // shameless copy+paste of code from LUA_LoadLump size_t length = strlen(wadfiles[wadnum]->filename) + 1 + strlen(lump_p->fullname); // length of file name, '|', and lump name @@ -299,6 +301,7 @@ static inline void W_LoadDehackedLumps(UINT16 wadnum) CONS_Printf(M_GetText("Loading object config from %s\n"), wadfiles[wadnum]->filename); DEH_LoadDehackedLumpPwad(wadnum, lump); } + } } } @@ -353,11 +356,13 @@ UINT32 W_HashLumpName(const char *name) */ static restype_t ResourceFileDetect (const char* filename) { - if (!stricmp(&filename[strlen(filename) - 4], ".pk3")) + size_t len = strlen(filename) - 4; + + if (!stricmp(&filename[len], ".pk3")) return RET_PK3; - if (!stricmp(&filename[strlen(filename) - 4], ".soc")) + if (!stricmp(&filename[len], ".soc")) return RET_SOC; - if (!stricmp(&filename[strlen(filename) - 4], ".lua")) + if (!stricmp(&filename[len], ".lua")) return RET_LUA; return RET_WAD; @@ -368,6 +373,7 @@ static restype_t ResourceFileDetect (const char* filename) static lumpinfo_t* ResGetLumpsStandalone (FILE* handle, UINT16* numlumps, const char* lumpname) { lumpinfo_t* lumpinfo = Z_Calloc(sizeof (*lumpinfo), PU_STATIC, NULL); + lumpinfo->position = 0; fseek(handle, 0, SEEK_END); lumpinfo->size = ftell(handle); @@ -1445,9 +1451,11 @@ boolean W_IsLumpWad(lumpnum_t lumpnum) { const char *lumpfullName = (wadfiles[WADFILENUM(lumpnum)]->lumpinfo + LUMPNUM(lumpnum))->fullname; - if (strlen(lumpfullName) < 4) + size_t len = strlen(lumpfullName); + + if (len < 4) return false; // can't possibly be a WAD can it? - return !strnicmp(lumpfullName + strlen(lumpfullName) - 4, ".wad", 4); + return !strnicmp(lumpfullName + len - 4, ".wad", 4); } return false; // WADs should never be inside non-PK3s as far as SRB2 is concerned @@ -2308,16 +2316,17 @@ int W_VerifyNMUSlumps(const char *filename, FILE *handle, boolean exit_on_error) }; int status = 0; + size_t len = strlen(filename) - 4; - if (stricmp(&filename[strlen(filename) - 4], ".pk3") == 0) + if (stricmp(&filename[len], ".pk3") == 0) { status = W_VerifyPK3(handle, NMUSlist, false); } else { // detect wad file by the absence of the other supported extensions - if (stricmp(&filename[strlen(filename) - 4], ".soc") - && stricmp(&filename[strlen(filename) - 4], ".lua")) + if (stricmp(&filename[len], ".soc") + && stricmp(&filename[len], ".lua")) { status = W_VerifyWAD(handle, NMUSlist, false); @@ -2538,13 +2547,15 @@ static int W_CheckFileContains(const char *filename, lumpchecklist_t *checklist) if ((handle = W_OpenWadFile(&filename, false)) == NULL) return -1; - if (stricmp(&filename[strlen(filename) - 4], ".pk3") == 0) + size_t len = strlen(filename) - 4; + + if (stricmp(&filename[len], ".pk3") == 0) contains = W_CheckPK3Contains(handle, checklist); else { // detect wad file by the absence of the other supported extensions - if (stricmp(&filename[strlen(filename) - 4], ".soc") - && stricmp(&filename[strlen(filename) - 4], ".lua")) + if (stricmp(&filename[len], ".soc") + && stricmp(&filename[len], ".lua")) { contains = W_CheckWADContains(handle, checklist); } @@ -2623,6 +2634,7 @@ virtres_t* vres_GetMap(lumpnum_t lumpnum) vlumps[i].size = vsizecache[realentry]; const char *name = (fileinfo + realentry)->name; + if (strlen(name) == 5 && memcmp(name, "MAP", 3) == 0) { numlumps--; // We skip map marker, so 1 of entries becomes empty @@ -2660,6 +2672,7 @@ virtres_t* vres_GetMap(lumpnum_t lumpnum) { // Check if it is map marker. It is not always first lump sadly, so we need to expect it anywhere const char *name = W_CheckNameForNum(lumpnum); + if (strlen(name) == 5 && memcmp(name, "MAP", 3) == 0) { --i; // Decrement so on next iteration we write on same i, so we don't leave corrupted vlumps entry