From 977ee8ccfc5ea4a197afd39d69f0563c3177319a Mon Sep 17 00:00:00 2001 From: Alug Date: Tue, 23 Jul 2024 21:48:38 +0200 Subject: [PATCH 1/6] make backup of kartconfig before writing to it --- src/m_misc.c | 49 +++++++++++++++++++++++++++++++++++++++++++++++++ src/m_misc.h | 1 + 2 files changed, 50 insertions(+) diff --git a/src/m_misc.c b/src/m_misc.c index c40848ecd..8cf20fd65 100644 --- a/src/m_misc.c +++ b/src/m_misc.c @@ -334,6 +334,38 @@ boolean FIL_FileOK(char const *name) return access(name,6)+1; //R_OK|W_OK } +/** Copies contents of one file to another + * + * \param src File to copy from + * \param dst File to write into + * \return true if copy was succesful, false if it doesn't. + */ +boolean FIL_CopyFile(const char *src, const char *dst) +{ + FILE *srcFile = fopen(src, "rb"); + + if (srcFile == NULL) + return false; + + FILE *dstFile = fopen(dst, "wb"); + + if (dstFile == NULL) + { + fclose(srcFile); + return false; + } + + char buffer[1024]; + size_t n; + + while ((n = fread(buffer, 1, sizeof(buffer), srcFile)) > 0) + fwrite(buffer, 1, n, dstFile); + + fclose(srcFile); + fclose(dstFile); + + return true; +} /** Checks if a pathname has a file extension and adds the extension provided * if not. @@ -525,11 +557,28 @@ void M_SaveConfig(const char *filename) { FILE *f; char *filepath; + char backupfile[MAX_WADPATH+4]; // make sure not to write back the config until it's been correctly loaded if (!gameconfig_loaded) return; + // Create backup of the config file + snprintf(backupfile, sizeof backupfile, "%s.bak", configfile); + backupfile[sizeof backupfile - 1] = '\0'; + + FILE *config = fopen(configfile, "r"); + + if (config != NULL) + { + fclose(config); + if (FIL_CopyFile(configfile, backupfile) != false) + { + CONS_Alert(CONS_WARNING,"Failed to create a backup of the configuration file. Will not attempt to write to file\n"); + return; + } + } + // can change the file name if (filename) { diff --git a/src/m_misc.h b/src/m_misc.h index 103b1d88a..333398161 100644 --- a/src/m_misc.h +++ b/src/m_misc.h @@ -54,6 +54,7 @@ boolean FIL_FileExists(const char *name); boolean FIL_WriteFileOK(char const *name); boolean FIL_ReadFileOK(char const *name); boolean FIL_FileOK(char const *name); +boolean FIL_CopyFile(const char *src, const char *dst); void FIL_DefaultExtension (char *path, const char *extension); void FIL_ForceExtension(char *path, const char *extension); From dff6b15263313790e1a3b73a47338a7661501f7c Mon Sep 17 00:00:00 2001 From: Alug Date: Tue, 23 Jul 2024 22:02:54 +0200 Subject: [PATCH 2/6] fix fail condition --- src/m_misc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/m_misc.c b/src/m_misc.c index 8cf20fd65..b8c88abb5 100644 --- a/src/m_misc.c +++ b/src/m_misc.c @@ -572,7 +572,7 @@ void M_SaveConfig(const char *filename) if (config != NULL) { fclose(config); - if (FIL_CopyFile(configfile, backupfile) != false) + if (FIL_CopyFile(configfile, backupfile) == false) { CONS_Alert(CONS_WARNING,"Failed to create a backup of the configuration file. Will not attempt to write to file\n"); return; From 59e4f9ce4ab1d7d514eeab847dee095dc9e4db4b Mon Sep 17 00:00:00 2001 From: Alug Date: Thu, 25 Jul 2024 16:42:33 +0200 Subject: [PATCH 3/6] let autoload run later to mitigate server join issues itll now run at a similar place to postautoload this may hopefully prevent some issuess with freeslotting lua however sadly this makes menu replacements not work at startup anymore --- src/d_clisrv.c | 11 ++--------- src/d_main.c | 36 +++++++++++++++++++++++++++++------- src/d_main.h | 3 +++ 3 files changed, 34 insertions(+), 16 deletions(-) diff --git a/src/d_clisrv.c b/src/d_clisrv.c index 3e791f7ab..c03584043 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -1913,15 +1913,6 @@ static void CL_LoadReceivedSavegame(void) demo.title = false; automapactive = false; - if (!postautoloaded) - { - CONS_Printf("D_AutoloadFile(): Loading autoloaded addons...\n"); - if (W_AddAutoloadedLocalFiles(autoloadwadfilespost) == 0) - CONS_Printf("D_AutoloadFile(): Are you sure you put in valid files or what?\n"); - D_CleanFile(autoloadwadfilespost); - postautoloaded = true; - } - // load a base level if (P_LoadNetGame()) { @@ -4308,6 +4299,8 @@ static void Got_AddPlayer(UINT8 **p, INT32 playernum) if (server && multiplayer && motd[0] != '\0') COM_BufAddText(va("sayto %d %s\n", newplayernum, motd)); + D_AddAutoloadFiles(); + LUAh_PlayerJoin(newplayernum); if (newplayernum == consoleplayer) diff --git a/src/d_main.c b/src/d_main.c index d223f8a5c..f1d05a1c0 100644 --- a/src/d_main.c +++ b/src/d_main.c @@ -103,11 +103,12 @@ static char *startupwadfiles[MAX_WADFILES]; static char *startuppwads[MAX_WADFILES]; // autoloading -static char *autoloadwadfiles[MAX_WADFILES]; +char *autoloadwadfiles[MAX_WADFILES]; char *autoloadwadfilespost[MAX_WADFILES]; boolean autoloading; boolean autoloaded; -boolean postautoloaded; +boolean postautoloaded = false; +boolean wasautoloaded = false; boolean devparm = false; // started game with -devparm @@ -1105,6 +1106,32 @@ static void D_FindAddonsToAutoload(void) fclose(autoloadconfigfile); } +void D_AddAutoloadFiles(void) +{ + if (wasautoloaded && postautoloaded) + return; + + if (!wasautoloaded && !modeattacking) + { + CONS_Printf("D_AutoloadFile(): Loading autoloaded addons...\n"); + if (W_AddAutoloadedLocalFiles(autoloadwadfiles) == 0) + CONS_Printf("D_AutoloadFile(): Are you sure you put in valid files or what?\n"); + D_CleanFile(autoloadwadfiles); + + wasautoloaded = true; + } + + if ((!postautoloaded) && netgame) + { + CONS_Printf("D_AutoloadFile(): Loading postloaded addons...\n"); + if (W_AddAutoloadedLocalFiles(autoloadwadfilespost) == 0) + CONS_Printf("D_AutoloadFile(): Are you sure you put in valid files or what?\n"); + D_CleanFile(autoloadwadfilespost); + + postautoloaded = true; + } +} + void D_CleanFile(char **filearray) { size_t pnumwadfiles; @@ -1791,11 +1818,6 @@ void D_SRB2Main(void) CONS_Printf("ST_Init(): Init status bar.\n"); ST_Init(); - CONS_Printf("D_AutoloadFile(): Loading autoloaded addons...\n"); - if (W_AddAutoloadedLocalFiles(autoloadwadfiles) == 0) - CONS_Printf("D_AutoloadFile(): Are you sure you put in valid files or what?\n"); - D_CleanFile(autoloadwadfiles); - // Set up splitscreen players before joining! if (!dedicated && (M_CheckParm("-splitscreen") && M_IsNextParm())) { diff --git a/src/d_main.h b/src/d_main.h index 23fb31619..d4d3e6e95 100644 --- a/src/d_main.h +++ b/src/d_main.h @@ -43,12 +43,15 @@ extern boolean statdp; // stat display for extended player setup extern boolean nametaggfx; // Nametag stuffs extern boolean driftgaugegfx; +void D_AddAutoloadFiles(void); extern boolean autoloading; extern boolean autoloaded; extern boolean postautoloaded; +extern boolean wasautoloaded; extern char *autoloadwadfilespost[MAX_WADFILES]; +extern char *autoloadwadfiles[MAX_WADFILES]; // the infinite loop of D_SRB2Loop() called from win_main for windows version void D_SRB2Loop(void) FUNCNORETURN; From f614725fcb41ab6f7f63ccd93417d6f6f043c0fc Mon Sep 17 00:00:00 2001 From: Alug Date: Thu, 25 Jul 2024 19:05:44 +0200 Subject: [PATCH 4/6] some cleanup --- src/p_inter.c | 631 ++++--------------------------------------------- src/p_mobj.c | 83 ++++--- src/p_setup.c | 63 ----- src/p_setup.h | 3 - src/p_spec.c | 423 +-------------------------------- src/r_bsp.c | 4 +- src/r_things.c | 25 +- src/s_sound.c | 66 +++--- src/st_stuff.c | 145 ------------ src/v_video.c | 7 +- src/w_wad.c | 22 +- 11 files changed, 175 insertions(+), 1297 deletions(-) diff --git a/src/p_inter.c b/src/p_inter.c index 90bb3f8da..dbc6e6a3b 100644 --- a/src/p_inter.c +++ b/src/p_inter.c @@ -254,26 +254,21 @@ void P_TouchSpecialThing(mobj_t *special, mobj_t *toucher, boolean heightcheck) if (heightcheck) { - /*if (special->type == MT_FLINGEMERALD) // little hack here... - { // flingemerald sprites are low to the ground, so extend collision radius down some. - if (toucher->z > (special->z + special->height)) - return; - if (special->z - special->height > (toucher->z + toucher->height)) - return; - } - else*/ + if (toucher->momz < 0) { - if (toucher->momz < 0) { - if (toucher->z + toucher->momz > special->z + special->height) - return; - } else if (toucher->z > special->z + special->height) - return; - if (toucher->momz > 0) { - if (toucher->z + toucher->height + toucher->momz < special->z) - return; - } else if (toucher->z + toucher->height < special->z) + if (toucher->z + toucher->momz > special->z + special->height) return; } + else if (toucher->z > special->z + special->height) + return; + + if (toucher->momz > 0) + { + if (toucher->z + toucher->height + toucher->momz < special->z) + return; + } + else if (toucher->z + toucher->height < special->z) + return; } if (special->health <= 0) @@ -384,16 +379,8 @@ void P_TouchSpecialThing(mobj_t *special, mobj_t *toucher, boolean heightcheck) player->kartstuff[k_roulettetype] = 2; } -#if 0 - // Eggbox snipe! - if (special->type == MT_EGGMANITEM && special->health > 1) - S_StartSound(toucher, sfx_bsnipe); -#endif - - { - mobj_t *poof = P_SpawnMobj(special->x, special->y, special->z, MT_EXPLODE); - S_StartSound(poof, special->info->deathsound); - } + mobj_t *poof = P_SpawnMobj(special->x, special->y, special->z, MT_EXPLODE); + S_StartSound(poof, special->info->deathsound); if (special->target && special->target->player) { @@ -584,10 +571,6 @@ void P_TouchSpecialThing(mobj_t *special, mobj_t *toucher, boolean heightcheck) else K_SpinPlayer(player, special->target, 0, special, false); return; - /*case MT_EERIEFOG: - special->frame &= ~FF_TRANS80; - special->frame |= FF_TRANS90; - return;*/ case MT_SMK_MOLE: if (special->target && !P_MobjWasRemoved(special->target)) return; @@ -936,12 +919,6 @@ void P_TouchSpecialThing(mobj_t *special, mobj_t *toucher, boolean heightcheck) player->flyangle = special->threshold; player->speed = FixedMul(special->info->speed, special->scale); - // Potentially causes axis transfer failures. - // Also rarely worked properly anyway. - //P_UnsetThingPosition(player->mo); - //player->mo->x = special->x; - //player->mo->y = special->y; - //P_SetThingPosition(player->mo); toucher->z = special->z+(special->height/4); } else // More like a spring @@ -986,140 +963,6 @@ void P_TouchSpecialThing(mobj_t *special, mobj_t *toucher, boolean heightcheck) } } return; - /*case MT_NIGHTSSUPERLOOP: - if (player->bot || !(player->pflags & PF_NIGHTSMODE)) - return; - if (!G_IsSpecialStage(gamemap)) - player->powers[pw_nights_superloop] = (UINT16)special->info->speed; - else - { - for (i = 0; i < MAXPLAYERS; i++) - if (playeringame[i] && players[i].pflags & PF_NIGHTSMODE) - players[i].powers[pw_nights_superloop] = (UINT16)special->info->speed; - if (special->info->deathsound != sfx_None) - S_StartSound(NULL, special->info->deathsound); - } - - // CECHO showing you what this item is - if (player == &players[displayplayers[0]] || G_IsSpecialStage(gamemap)) - { - HU_SetCEchoFlags(V_AUTOFADEOUT); - HU_SetCEchoDuration(4); - HU_DoCEcho(M_GetText("\\\\\\\\\\\\\\\\Super Paraloop")); - } - break; - case MT_NIGHTSDRILLREFILL: - if (player->bot || !(player->pflags & PF_NIGHTSMODE)) - return; - if (!G_IsSpecialStage(gamemap)) - player->drillmeter = special->info->speed; - else - { - for (i = 0; i < MAXPLAYERS; i++) - if (playeringame[i] && players[i].pflags & PF_NIGHTSMODE) - players[i].drillmeter = special->info->speed; - if (special->info->deathsound != sfx_None) - S_StartSound(NULL, special->info->deathsound); - } - - // CECHO showing you what this item is - if (player == &players[displayplayers[0]] || G_IsSpecialStage(gamemap)) - { - HU_SetCEchoFlags(V_AUTOFADEOUT); - HU_SetCEchoDuration(4); - HU_DoCEcho(M_GetText("\\\\\\\\\\\\\\\\Drill Refill")); - } - break; - case MT_NIGHTSHELPER: - if (player->bot || !(player->pflags & PF_NIGHTSMODE)) - return; - if (!G_IsSpecialStage(gamemap)) - { - // A flicky orbits us now - mobj_t *flickyobj = P_SpawnMobj(toucher->x, toucher->y, toucher->z + toucher->info->height, MT_NIGHTOPIANHELPER); - P_SetTarget(&flickyobj->target, toucher); - - player->powers[pw_nights_helper] = (UINT16)special->info->speed; - } - else - { - mobj_t *flickyobj; - for (i = 0; i < MAXPLAYERS; i++) - if (playeringame[i] && players[i].mo && players[i].pflags & PF_NIGHTSMODE) { - players[i].powers[pw_nights_helper] = (UINT16)special->info->speed; - flickyobj = P_SpawnMobj(players[i].mo->x, players[i].mo->y, players[i].mo->z + players[i].mo->info->height, MT_NIGHTOPIANHELPER); - P_SetTarget(&flickyobj->target, players[i].mo); - } - if (special->info->deathsound != sfx_None) - S_StartSound(NULL, special->info->deathsound); - } - - // CECHO showing you what this item is - if (player == &players[displayplayers[0]] || G_IsSpecialStage(gamemap)) - { - HU_SetCEchoFlags(V_AUTOFADEOUT); - HU_SetCEchoDuration(4); - HU_DoCEcho(M_GetText("\\\\\\\\\\\\\\\\Nightopian Helper")); - } - break; - case MT_NIGHTSEXTRATIME: - if (player->bot || !(player->pflags & PF_NIGHTSMODE)) - return; - if (!G_IsSpecialStage(gamemap)) - { - player->nightstime += special->info->speed; - player->startedtime += special->info->speed; - P_RestoreMusic(player); - } - else - { - for (i = 0; i < MAXPLAYERS; i++) - if (playeringame[i] && players[i].pflags & PF_NIGHTSMODE) - { - players[i].nightstime += special->info->speed; - players[i].startedtime += special->info->speed; - P_RestoreMusic(&players[i]); - } - if (special->info->deathsound != sfx_None) - S_StartSound(NULL, special->info->deathsound); - } - - // CECHO showing you what this item is - if (player == &players[displayplayers[0]] || G_IsSpecialStage(gamemap)) - { - HU_SetCEchoFlags(V_AUTOFADEOUT); - HU_SetCEchoDuration(4); - HU_DoCEcho(M_GetText("\\\\\\\\\\\\\\\\Extra Time")); - } - break; - case MT_NIGHTSLINKFREEZE: - if (player->bot || !(player->pflags & PF_NIGHTSMODE)) - return; - if (!G_IsSpecialStage(gamemap)) - { - player->powers[pw_nights_linkfreeze] = (UINT16)special->info->speed; - player->linktimer = 2*TICRATE; - } - else - { - for (i = 0; i < MAXPLAYERS; i++) - if (playeringame[i] && players[i].pflags & PF_NIGHTSMODE) - { - players[i].powers[pw_nights_linkfreeze] += (UINT16)special->info->speed; - players[i].linktimer = 2*TICRATE; - } - if (special->info->deathsound != sfx_None) - S_StartSound(NULL, special->info->deathsound); - } - - // CECHO showing you what this item is - if (player == &players[displayplayers[0]] || G_IsSpecialStage(gamemap)) - { - HU_SetCEchoFlags(V_AUTOFADEOUT); - HU_SetCEchoDuration(4); - HU_DoCEcho(M_GetText("\\\\\\\\\\\\\\\\Link Freeze")); - } - break;*/ case MT_NIGHTSWING: if (G_IsSpecialStage(gamemap) && useNightsSS) { // Pseudo-ring. @@ -1515,23 +1358,6 @@ void P_TouchSpecialThing(mobj_t *special, mobj_t *toucher, boolean heightcheck) || special->z > toucher->z + (toucher->height*2/3)) return; // Only go in the mouth - /* // SRB2kart - Can't drown. - // Eaten by player! - if (player->powers[pw_underwater] && player->powers[pw_underwater] <= 12*TICRATE + 1) - P_RestoreMusic(player); - - if (player->powers[pw_underwater] < underwatertics + 1) - player->powers[pw_underwater] = underwatertics + 1; - */ - - /* - if (!player->climbing) - { - P_SetPlayerMobjState(toucher, S_PLAY_GASP); - P_ResetPlayer(player); - } - */ - toucher->momx = toucher->momy = toucher->momz = 0; break; @@ -1588,26 +1414,7 @@ void P_CheckTimeLimit(void) if (gameaction == ga_completed) return; - //Tagmode round end but only on the tic before the - //XD_EXITLEVEL packet is received by all players. - /*if (G_TagGametype()) - { - if (leveltime == (timelimitintics + 1)) - { - for (i = 0; i < MAXPLAYERS; i++) - { - if (!playeringame[i] || players[i].spectator - || (players[i].pflags & PF_TAGGED) || (players[i].pflags & PF_TAGIT)) - continue; - - CONS_Printf(M_GetText("%s received double points for surviving the round.\n"), player_names[i]); - P_AddPlayerScore(&players[i], players[i].score); - } - } - } - - //Optional tie-breaker for Match/CTF - else*/ if (cv_overtime.value) + if (cv_overtime.value) { INT32 playerarray[MAXPLAYERS]; INT32 tempplayer = 0; @@ -1680,9 +1487,6 @@ void P_CheckTimeLimit(void) return; P_DoPlayerExit(&players[i]); } - - /*if (server) - SendNetXCmd(XD_EXITLEVEL, NULL, 0);*/ } /** Checks if a player's score is over the pointlimit and the round should end. @@ -1704,127 +1508,27 @@ void P_CheckPointLimit(void) if (G_RaceGametype()) return; - // pointlimit is nonzero, check if it's been reached by this player - /*if (G_GametypeHasTeams()) + for (i = 0; i < MAXPLAYERS; i++) { - // Just check both teams - if ((UINT32)cv_pointlimit.value <= redscore || (UINT32)cv_pointlimit.value <= bluescore) - { - if (server) - SendNetXCmd(XD_EXITLEVEL, NULL, 0); - } - } - else*/ - { - for (i = 0; i < MAXPLAYERS; i++) - { - if (!playeringame[i] || players[i].spectator) - continue; + if (!playeringame[i] || players[i].spectator) + continue; - if ((UINT32)cv_pointlimit.value <= players[i].marescore) + if ((UINT32)cv_pointlimit.value <= players[i].marescore) + { + for (i = 0; i < MAXPLAYERS; i++) // AAAAA nested loop using the same iteration variable ;; { - for (i = 0; i < MAXPLAYERS; i++) // AAAAA nested loop using the same iteration variable ;; - { - if (!playeringame[i] || players[i].spectator) - continue; - if (players[i].exiting) - return; - P_DoPlayerExit(&players[i]); - } - - /*if (server) - SendNetXCmd(XD_EXITLEVEL, NULL, 0);*/ - return; // good thing we're leaving the function immediately instead of letting the loop get mangled! + if (!playeringame[i] || players[i].spectator) + continue; + if (players[i].exiting) + return; + P_DoPlayerExit(&players[i]); } + + return; // good thing we're leaving the function immediately instead of letting the loop get mangled! } } } -/*Checks for untagged remaining players in both tag derivitave modes. - *If no untagged players remain, end the round. - *Also serves as error checking if the only IT player leaves.*/ -/*void P_CheckSurvivors(void) -{ - INT32 i; - INT32 survivors = 0; - INT32 taggers = 0; - INT32 spectators = 0; - INT32 survivorarray[MAXPLAYERS]; - - if (!D_NumPlayers()) //no players in the game, no check performed. - return; - - for (i=0; i < MAXPLAYERS; i++) //figure out counts of taggers, survivors and spectators. - { - if (playeringame[i]) - { - if (players[i].spectator) - spectators++; - else if (players[i].pflags & PF_TAGIT) - taggers++; - else if (!(players[i].pflags & PF_TAGGED)) - { - survivorarray[survivors] = i; - survivors++; - } - } - } - - if (!taggers) //If there are no taggers, pick a survivor at random to be it. - { - // Exception for hide and seek. If a round has started and the IT player leaves, end the round. - if (gametype == GT_HIDEANDSEEK && (leveltime >= (hidetime * TICRATE))) - { - CONS_Printf(M_GetText("The IT player has left the game.\n")); - if (server) - SendNetXCmd(XD_EXITLEVEL, NULL, 0); - - return; - } - - if (survivors) - { - INT32 newtagger = survivorarray[P_RandomKey(survivors)]; - - CONS_Printf(M_GetText("%s is now IT!\n"), player_names[newtagger]); // Tell everyone who is it! - players[newtagger].pflags |= PF_TAGIT; - - survivors--; //Get rid of the guy we just made IT. - - //Yeah, we have an eligible tagger, but we may not have anybody for him to tag! - //If there is only one guy waiting on the game to fill or spectators to enter game, don't bother. - if (!survivors && (D_NumPlayers() - spectators) > 1) - { - CONS_Printf(M_GetText("All players have been tagged!\n")); - if (server) - SendNetXCmd(XD_EXITLEVEL, NULL, 0); - } - - return; - } - - //If we reach this point, no player can replace the one that was IT. - //Unless it is one player waiting on a game, end the round. - if ((D_NumPlayers() - spectators) > 1) - { - CONS_Printf(M_GetText("There are no players able to become IT.\n")); - if (server) - SendNetXCmd(XD_EXITLEVEL, NULL, 0); - } - - return; - } - - //If there are taggers, but no survivors, end the round. - //Except when the tagger is by himself and the rest of the game are spectators. - if (!survivors && (D_NumPlayers() - spectators) > 1) - { - CONS_Printf(M_GetText("All players have been tagged!\n")); - if (server) - SendNetXCmd(XD_EXITLEVEL, NULL, 0); - } -}*/ - // Checks whether or not to end a race netgame. boolean P_CheckRacers(void) { @@ -1993,14 +1697,6 @@ void P_KillMobj(mobj_t *target, mobj_t *inflictor, mobj_t *source) { if (metalrecording) // Ack! Metal Sonic shouldn't die! Cut the tape, end recording! G_StopMetalRecording(); - /*if (gametype == GT_MATCH && cv_match_scoring.value == 0 // note, no team match suicide penalty - && ((target == source) || (source == NULL && inflictor == NULL) || (source && !source->player))) - { // Suicide penalty - Not in Kart - if (target->player->score >= 50) - target->player->score -= 50; - else - target->player->score = 0; - }*/ target->flags2 &= ~MF2_DONTDRAW; } @@ -2017,85 +1713,6 @@ void P_KillMobj(mobj_t *target, mobj_t *inflictor, mobj_t *source) target->fuse = cv_itemrespawntime.value*TICRATE + 2; // Random box generation } } - - // Award Score Tails - /*{ // Enemies shouldn't award points in Kart - INT32 score = 0; - - if (maptol & TOL_NIGHTS) // Enemies always worth 200, bosses don't do anything. - { - if ((target->flags & MF_ENEMY) && !(target->flags & (MF_MISSILE|MF_BOSS))) - { - score = 200; - - if (source->player->bonustime) - score *= 2; - - // Also, add to the link. - // I don't know if NiGHTS did this, but - // Sonic Time Attacked did and it seems like a good enough incentive - // to make people want to actually dash towards/paraloop enemies - if (++source->player->linkcount > source->player->maxlink) - source->player->maxlink = source->player->linkcount; - source->player->linktimer = 2*TICRATE; - } - } - else - { - if (target->flags & MF_BOSS) - score = 1000; - else if ((target->flags & MF_ENEMY) && !(target->flags & MF_MISSILE)) - { - mobj_t *scoremobj; - UINT32 scorestate = mobjinfo[MT_SCORE].spawnstate; - - scoremobj = P_SpawnMobj(target->x, target->y, target->z + (target->height / 2), MT_SCORE); - - // On ground? No chain starts. - if (!source->player->powers[pw_invulnerability] && P_IsObjectOnGround(source)) - { - source->player->scoreadd = 0; - score = 100; - } - // Mario Mode has Mario-like chain point values - else if (mariomode) switch (++source->player->scoreadd) - { - case 1: score = 100; break; - case 2: score = 200; scorestate += 1; break; - case 3: score = 400; scorestate += 5; break; - case 4: score = 800; scorestate += 6; break; - case 5: score = 1000; scorestate += 3; break; - case 6: score = 2000; scorestate += 7; break; - case 7: score = 4000; scorestate += 8; break; - case 8: score = 8000; scorestate += 9; break; - default: // 1up for a chain this long - if (modeattacking) // but 1ups don't exist in record attack! - { // So we just go back to 10k points. - score = 10000; scorestate += 4; break; - } - P_GivePlayerLives(source->player, 1); - P_PlayLivesJingle(source->player); - scorestate += 10; - break; - } - // More Sonic-like point system - else switch (++source->player->scoreadd) - { - case 1: score = 100; break; - case 2: score = 200; scorestate += 1; break; - case 3: score = 500; scorestate += 2; break; - case 4: case 5: case 6: case 7: case 8: case 9: - case 10: case 11: case 12: case 13: case 14: - score = 1000; scorestate += 3; break; - default: score = 10000; scorestate += 4; break; - } - - P_SetMobjState(scoremobj, scorestate); - } - } - - P_AddPlayerScore(source->player, score); - }*/ } // if a player avatar dies... @@ -2159,42 +1776,7 @@ void P_KillMobj(mobj_t *target, mobj_t *inflictor, mobj_t *source) if (target->player == &players[displayplayers[3]]) localaiming[3] = 0; - //tag deaths handled differently in suicide cases. Don't count spectators! - /*if (G_TagGametype() - && !(target->player->pflags & PF_TAGIT) && (!source || !source->player) && !(target->player->spectator)) - { - // if you accidentally die before you run out of time to hide, ignore it. - // allow them to try again, rather than sitting the whole thing out. - if (leveltime >= hidetime * TICRATE) - { - if (gametype == GT_TAG)//suiciding in survivor makes you IT. - { - target->player->pflags |= PF_TAGIT; - CONS_Printf(M_GetText("%s is now IT!\n"), player_names[target->player-players]); // Tell everyone who is it! - P_CheckSurvivors(); - } - else - { - if (!(target->player->pflags & PF_TAGGED)) - { - //otherwise, increment the tagger's score. - //in hide and seek, suiciding players are counted as found. - INT32 w; - - for (w=0; w < MAXPLAYERS; w++) - { - if (players[w].pflags & PF_TAGIT) - P_AddPlayerScore(&players[w], 1); - } - - target->player->pflags |= PF_TAGGED; - CONS_Printf(M_GetText("%s was found!\n"), player_names[target->player-players]); - P_CheckSurvivors(); - } - } - } - } - else*/ if (G_BattleGametype()) + if (G_BattleGametype()) K_CheckBumpers(); target->player->kartstuff[k_pogospring] = 0; @@ -2611,26 +2193,6 @@ static inline boolean P_TagDamage(mobj_t *target, mobj_t *inflictor, mobj_t *sou return false; } - // The tag occurs so long as you aren't shooting another tagger with friendlyfire on. - /*if (source->player->pflags & PF_TAGIT && !(player->pflags & PF_TAGIT)) - { - P_AddPlayerScore(source->player, 1); //award points to tagger. - - if (gametype == GT_TAG) //survivor - { - player->pflags |= PF_TAGIT; //in survivor, the player becomes IT and helps hunt down the survivors. - CONS_Printf(M_GetText("%s is now IT!\n"), player_names[player-players]); // Tell everyone who is it! - } - else - { - player->pflags |= PF_TAGGED; //in hide and seek, the player is tagged and stays stationary. - CONS_Printf(M_GetText("%s was found!\n"), player_names[player-players]); // Tell everyone who is it! - } - - //checks if tagger has tagged all players, if so, end round early. - P_CheckSurvivors(); - }*/ - P_DoPlayerPain(player, source, inflictor); // Check for a shield @@ -2669,15 +2231,6 @@ static inline boolean P_PlayerHitsPlayer(mobj_t *target, mobj_t *inflictor, mobj { player_t *player = target->player; - // You can't kill yourself, idiot... // Unless it's Mario kart. Which it is. In this mod. All the time. - //if (source == target) - // return false; - - // In COOP/RACE/CHAOS, you can't hurt other players unless cv_friendlyfire is on - // ...But in SRB2kart, you can! - //if (!cv_friendlyfire.value && (G_RaceGametype())) - // return false; - // Tag handling if (G_TagGametype()) return P_TagDamage(target, inflictor, source, damage); @@ -2729,32 +2282,6 @@ static void P_KillPlayer(player_t *player, mobj_t *source, INT32 damage) P_SetPlayerMobjState(player->mo, player->mo->info->deathstate); - /*if (gametype == GT_CTF && (player->gotflag & (GF_REDFLAG|GF_BLUEFLAG))) - { - P_PlayerFlagBurst(player, false); - if (source && source->player) - { - // Award no points when players shoot each other when cv_friendlyfire is on. - if (!G_GametypeHasTeams() || !(source->player->ctfteam == player->ctfteam && source != player->mo)) - P_AddPlayerScore(source->player, 1); - } - } - if (source && source->player && !player->powers[pw_super]) //don't score points against super players - { - // Award no points when players shoot each other when cv_friendlyfire is on. - if (!G_GametypeHasTeams() || !(source->player->ctfteam == player->ctfteam && source != player->mo)) - P_AddPlayerScore(source->player, 1); - } - - // If the player was super, tell them he/she ain't so super nomore. - if (gametype != GT_COOP && player->powers[pw_super]) - { - S_StartSound(NULL, sfx_s3k66); //let all players hear it. - HU_SetCEchoFlags(0); - HU_SetCEchoDuration(5); - HU_DoCEcho(va("%s\\is no longer super.\\\\\\\\", player_names[player-players])); - }*/ - if (player->pflags & PF_TIMEOVER) { mobj_t *boom; @@ -2815,44 +2342,8 @@ void P_RemoveShield(player_t *player) player->powers[pw_shield] = player->powers[pw_shield] & SH_STACK; } -/* -static void P_ShieldDamage(player_t *player, mobj_t *inflictor, mobj_t *source, INT32 damage) // SRB2kart - unused. -{ - // Must do pain first to set flashing -- P_RemoveShield can cause damage - P_DoPlayerPain(player, source, inflictor); - - P_RemoveShield(player); - - P_ForceFeed(player, 40, 10, TICRATE, 40 + min(damage, 100)*2); - - if (source && (source->type == MT_SPIKE || (source->type == MT_NULL && source->threshold == 43))) // spikes - S_StartSound(player->mo, sfx_spkdth); - else - S_StartSound (player->mo, sfx_shldls); // Ba-Dum! Shield loss. - - if (gametype == GT_CTF && (player->gotflag & (GF_REDFLAG|GF_BLUEFLAG))) - { - P_PlayerFlagBurst(player, false); - if (source && source->player) - { - // Award no points when players shoot each other when cv_friendlyfire is on. - if (!G_GametypeHasTeams() || !(source->player->ctfteam == player->ctfteam && source != player->mo)) - P_AddPlayerScore(source->player, 25); - } - } - if (source && source->player && !player->powers[pw_super]) //don't score points against super players - { - // Award no points when players shoot each other when cv_friendlyfire is on. - if (!G_GametypeHasTeams() || !(source->player->ctfteam == player->ctfteam && source != player->mo)) - P_AddPlayerScore(source->player, cv_match_scoring.value == 1 ? 25 : 50); - } -} -*/ - static void P_RingDamage(player_t *player, mobj_t *inflictor, mobj_t *source, INT32 damage) { - //const UINT8 scoremultiply = ((K_IsWantedPlayer(player) && !trapitem) : 2 ? 1); - if (!(inflictor && ((inflictor->flags & MF_MISSILE) || inflictor->player) && player->powers[pw_super] && ALL7EMERALDS(player->powers[pw_emeralds]))) { P_DoPlayerPain(player, source, inflictor); @@ -2863,24 +2354,6 @@ static void P_RingDamage(player_t *player, mobj_t *inflictor, mobj_t *source, IN S_StartSound(player->mo, sfx_spkdth); } - /*if (source && source->player && !player->powers[pw_super]) //don't score points against super players - { - // Award no points when players shoot each other when cv_friendlyfire is on. - if (!G_GametypeHasTeams() || !(source->player->ctfteam == player->ctfteam && source != player->mo)) - P_AddPlayerScore(source->player, scoremultiply); - } - - if (gametype == GT_CTF && (player->gotflag & (GF_REDFLAG|GF_BLUEFLAG))) - { - P_PlayerFlagBurst(player, false); - if (source && source->player) - { - // Award no points when players shoot each other when cv_friendlyfire is on. - if (!G_GametypeHasTeams() || !(source->player->ctfteam == player->ctfteam && source != player->mo)) - P_AddPlayerScore(source->player, scoremultiply); - } - }*/ - // Ring loss sound plays despite hitting spikes P_PlayRinglossSound(player->mo); // Ringledingle! } @@ -3680,32 +3153,30 @@ void P_PlayerFlagBurst(player_t *player, boolean toss) P_SetTarget(&flag->target, player->mo); // Flag text + char plname[MAXPLAYERNAME+4]; + const char *flagtext; + char flagcolor; + + snprintf(plname, sizeof(plname), "%s%s%s", + CTFTEAMCODE(player), + player_names[player - players], + CTFTEAMENDCODE(player)); + + if (type == MT_REDFLAG) { - char plname[MAXPLAYERNAME+4]; - const char *flagtext; - char flagcolor; - - snprintf(plname, sizeof(plname), "%s%s%s", - CTFTEAMCODE(player), - player_names[player - players], - CTFTEAMENDCODE(player)); - - if (type == MT_REDFLAG) - { - flagtext = M_GetText("Red flag"); - flagcolor = '\x85'; - } - else - { - flagtext = M_GetText("Blue flag"); - flagcolor = '\x84'; - } - - if (toss) - CONS_Printf(M_GetText("%s tossed the %c%s%c.\n"), plname, flagcolor, flagtext, 0x80); - else - CONS_Printf(M_GetText("%s dropped the %c%s%c.\n"), plname, flagcolor, flagtext, 0x80); + flagtext = M_GetText("Red flag"); + flagcolor = '\x85'; } + else + { + flagtext = M_GetText("Blue flag"); + flagcolor = '\x84'; + } + + if (toss) + CONS_Printf(M_GetText("%s tossed the %c%s%c.\n"), plname, flagcolor, flagtext, 0x80); + else + CONS_Printf(M_GetText("%s dropped the %c%s%c.\n"), plname, flagcolor, flagtext, 0x80); player->gotflag = 0; diff --git a/src/p_mobj.c b/src/p_mobj.c index 5ac421e73..5e5b9924b 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -4988,13 +4988,15 @@ static void P_Boss9Thinker(mobj_t *mobj) else mobj->momz = (mobj->watertop-mobj->z)/40; // Float to your desired position - if (mobj->movecount == 2) { + if (mobj->movecount == 2) + { mobj_t *spawner; fixed_t dist = 0; angle = 0x06000000*leveltime; // Alter your energy bubble's size/position - if (mobj->health > 3) { + if (mobj->health > 3) + { mobj->tracer->destscale = FRACUNIT + (4*TICRATE - mobj->fuse)*(FRACUNIT/2)/TICRATE + FixedMul(FINECOSINE(angle>>ANGLETOFINESHIFT),FRACUNIT/2); P_SetScale(mobj->tracer, mobj->tracer->destscale); P_SetOrigin(mobj->tracer, mobj->x, mobj->y, mobj->z + mobj->height/2 - mobj->tracer->height/2); @@ -5030,8 +5032,10 @@ static void P_Boss9Thinker(mobj_t *mobj) } // Pre-threshold reactiontime stuff for attack phases - if (mobj->reactiontime && mobj->movecount == 3) { - if (mobj->movedir == 0 || mobj->movedir == 2) { // Pausing between bounces in the pinball phase + if (mobj->reactiontime && mobj->movecount == 3) + { + if (mobj->movedir == 0 || mobj->movedir == 2) // Pausing between bounces in the pinball phase + { if (mobj->target->player->powers[pw_tailsfly]) // Trying to escape, eh? mobj->watertop = mobj->target->z + mobj->target->momz*6; // Readjust your aim. >:3 else @@ -5045,13 +5049,16 @@ static void P_Boss9Thinker(mobj_t *mobj) } // threshold is used for attacks/maneuvers. - if (mobj->threshold) { + if (mobj->threshold) + { fixed_t speed = 20*FRACUNIT + FixedMul(40*FRACUNIT, FixedDiv((mobj->info->spawnhealth - mobj->health)<info->spawnhealth<movecount == 3 && mobj->movedir == 1) { - if (!(mobj->threshold&1)) { + if (mobj->movecount == 3 && mobj->movedir == 1) + { + if (!(mobj->threshold&1)) + { mobj_t *missile; if (mobj->info->seesound) S_StartSound(mobj, mobj->info->seesound); @@ -5063,18 +5070,21 @@ static void P_Boss9Thinker(mobj_t *mobj) A_FaceTarget(mobj); missile = P_SpawnMissile(mobj, mobj->target, mobj->info->speed); - if (mobj->extravalue1 == 2 || mobj->extravalue1 == 3) { + if (mobj->extravalue1 == 2 || mobj->extravalue1 == 3) + { missile->destscale = FRACUNIT>>1; P_SetScale(missile, missile->destscale); } missile->fuse = 3*TICRATE; missile->z -= missile->height/2; - if (mobj->extravalue1 == 2) { + if (mobj->extravalue1 == 2) + { int i; mobj_t *spread; missile->flags |= MF_MISSILE; - for (i = 0; i < 5; i++) { + for (i = 0; i < 5; i++) + { if (i == 2) continue; spread = P_SpawnMobj(missile->x, missile->y, missile->z, missile->type); @@ -5087,7 +5097,9 @@ static void P_Boss9Thinker(mobj_t *mobj) } missile->flags &= ~MF_MISSILE; } - } else { + } + else + { P_SetMobjState(mobj, mobj->state->nextstate); if (mobj->extravalue1 == 3) mobj->reactiontime = TICRATE/8; @@ -5101,7 +5113,8 @@ static void P_Boss9Thinker(mobj_t *mobj) P_SpawnGhostMobj(mobj); // Pinball attack! - if (mobj->movecount == 3 && (mobj->movedir == 0 || mobj->movedir == 2)) { + if (mobj->movecount == 3 && (mobj->movedir == 0 || mobj->movedir == 2)) + { if ((statenum_t)(mobj->state-states) != mobj->info->seestate) P_SetMobjState(mobj, mobj->info->seestate); if (mobj->movedir == 0) // mobj health == 1 @@ -5110,16 +5123,22 @@ static void P_Boss9Thinker(mobj_t *mobj) P_InstaThrust(mobj, mobj->angle, 22*FRACUNIT); else // mobj health == 2 P_InstaThrust(mobj, mobj->angle, 30*FRACUNIT); - if (!P_TryMove(mobj, mobj->x+mobj->momx, mobj->y+mobj->momy, true)) { // Hit a wall? Find a direction to bounce + + if (!P_TryMove(mobj, mobj->x+mobj->momx, mobj->y+mobj->momy, true)) // Hit a wall? Find a direction to bounce + { mobj->threshold--; - if (mobj->threshold) { + if (mobj->threshold) + { P_SetMobjState(mobj, mobj->state->nextstate); if (mobj->info->mass) S_StartSound(mobj, mobj->info->mass); - if (!(mobj->threshold%4)) { // We've decided to lock onto the player this bounce. + if (!(mobj->threshold%4)) // We've decided to lock onto the player this bounce. + { mobj->angle = R_PointToAngle2(mobj->x, mobj->y, mobj->target->x + mobj->target->momx*4, mobj->target->y + mobj->target->momy*4); mobj->reactiontime = TICRATE; // targetting time - } else { // No homing, just use P_BounceMove + } + else // No homing, just use P_BounceMove + { P_BounceMove(mobj); mobj->angle = R_PointToAngle2(0,0,mobj->momx,mobj->momy); mobj->reactiontime = TICRATE/4; // just a pause before you bounce away @@ -5133,7 +5152,8 @@ static void P_Boss9Thinker(mobj_t *mobj) // Vector form dodge! mobj->angle += mobj->movedir; P_InstaThrust(mobj, mobj->angle, -speed); - while (!P_TryMove(mobj, mobj->x+mobj->momx, mobj->y+mobj->momy, true) && tries++ < 16) { + while (!P_TryMove(mobj, mobj->x+mobj->momx, mobj->y+mobj->momy, true) && tries++ < 16) + { mobj->angle += mobj->movedir; P_InstaThrust(mobj, mobj->angle, -speed); } @@ -5189,9 +5209,10 @@ static void P_Boss9Thinker(mobj_t *mobj) if (mobj->flags2 & MF2_FRET) return; - if (mobj->state == &states[mobj->info->raisestate]) - { // Charging energy - if (mobj->momx != 0 || mobj->momy != 0) { // Apply the air breaks + if (mobj->state == &states[mobj->info->raisestate]) // Charging energy + { + if (mobj->momx != 0 || mobj->momy != 0) // Apply the air breaks + { if (abs(mobj->momx)+abs(mobj->momy) < FRACUNIT) mobj->momx = mobj->momy = 0; else @@ -5216,7 +5237,8 @@ static void P_Boss9Thinker(mobj_t *mobj) mobj->watertop = mobj->target->floorz + 256*FRACUNIT; break; - case 1: { + case 1: + { // Okay, we're up? Good, time to gather energy... if (mobj->health > mobj->info->damage) { // No more bubble if we're broken (pinch phase) @@ -5242,7 +5264,8 @@ static void P_Boss9Thinker(mobj_t *mobj) P_SetTarget(&mobj->tracer, mobj->hnext); P_RemoveMobj(removemobj); } - if (mobj->health <= mobj->info->damage) { + if (mobj->health <= mobj->info->damage) + { // Attack 1: Pinball dash! if (mobj->health == 1) mobj->movedir = 0; @@ -5257,7 +5280,9 @@ static void P_Boss9Thinker(mobj_t *mobj) mobj->threshold = 32; // bounce 32 times mobj->watertop = mobj->target->floorz + 16*FRACUNIT; P_LinedefExecute(LE_PINCHPHASE, mobj, NULL); - } else { + } + else + { // Attack 2: Energy shot! mobj->movedir = 1; @@ -5270,7 +5295,8 @@ static void P_Boss9Thinker(mobj_t *mobj) else mobj->extravalue1 = 3; - switch(mobj->extravalue1) { + switch(mobj->extravalue1) + { case 0: // shoot once case 2: // spread-shot default: @@ -5334,7 +5360,8 @@ static void P_Boss9Thinker(mobj_t *mobj) danger = false; if (mobj->target->z+mobj->target->momz*2 > mobj->z+mobj->height) danger = false; - if (danger) { + if (danger) + { // An incoming attack is detected! What should we do?! // Go into vector form! mobj->movedir = ANGLE_11hh - FixedAngle(FixedMul(AngleFixed(ANGLE_11hh), FixedDiv((mobj->info->spawnhealth - mobj->health)<info->spawnhealth-1)<hnext; mo = mo->hnext) ; @@ -5881,7 +5909,8 @@ static void P_AddShadow(mobj_t *thing) if (shadowcap == NULL) P_SetTarget(&shadowcap, thing); - else { + else + { mobj_t *mo; for (mo = shadowcap; mo && mo->hnext; mo = mo->hnext) ; diff --git a/src/p_setup.c b/src/p_setup.c index 0a868ef8c..a1f0ff8e8 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -800,69 +800,6 @@ void P_ReloadRings(void) } } -#ifdef SCANTHINGS -void P_ScanThings(INT16 mapnum, INT16 wadnum, INT16 lumpnum) -{ - size_t i, n; - UINT8 *data, *datastart; - UINT16 type, maprings; - INT16 tol; - UINT32 flags; - - tol = mapheaderinfo[mapnum-1]->typeoflevel; - if (!(tol & TOL_SP)) - return; - flags = mapheaderinfo[mapnum-1]->levelflags; - - n = W_LumpLengthPwad(wadnum, lumpnum) / (5 * sizeof (INT16)); - //CONS_Printf("%u map things found!\n", n); - - maprings = 0; - data = datastart = W_CacheLumpNumPwad(wadnum, lumpnum, PU_STATIC); - for (i = 0; i < n; i++) - { - data += 3 * sizeof (INT16); // skip x y position, angle - type = READUINT16(data) & 4095; - data += sizeof (INT16); // skip options - - switch (type) - { - case 300: // MT_RING - case 1800: // MT_COIN - case 308: // red team ring - case 309: // blue team ring - maprings++; - break; - case 400: // MT_SUPERRINGBOX - case 414: // red ring box - case 415: // blue ring box - case 603: // 10 diagonal rings - maprings += 10; - break; - case 600: // 5 vertical rings - case 601: // 5 vertical rings - case 602: // 5 diagonal rings - maprings += 5; - break; - case 604: // 8 circle rings - case 609: // 16 circle rings & wings - maprings += 8; - break; - case 605: // 16 circle rings - maprings += 16; - break; - case 608: // 8 circle rings & wings - maprings += 4; - break; - } - } - Z_Free(datastart); - - if (maprings) - CONS_Printf("%s has %u rings\n", G_BuildMapName(mapnum), maprings); -} -#endif - // // P_LoadThings // diff --git a/src/p_setup.h b/src/p_setup.h index 5df0f0b68..8a77c690b 100644 --- a/src/p_setup.h +++ b/src/p_setup.h @@ -59,9 +59,6 @@ extern size_t nummapthings; extern mapthing_t *mapthings; void P_SetupLevelSky(INT32 skynum, boolean global); -#ifdef SCANTHINGS -void P_ScanThings(INT16 mapnum, INT16 wadnum, INT16 lumpnum); -#endif void P_LoadThingsOnly(void); boolean P_SetupLevel(boolean skipprecip); #ifdef HWRENDER diff --git a/src/p_spec.c b/src/p_spec.c index 1bde9a72e..e0092f1ee 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -622,48 +622,6 @@ void P_SetupLevelFlatAnims(void) // UTILITIES // -#if 0 -/** Gets a side from a sector line. - * - * \param currentSector Sector the line is in. - * \param line Index of the line within the sector. - * \param side 0 for front, 1 for back. - * \return Pointer to the side_t of the side you want. - * \sa getSector, twoSided, getNextSector - */ -static inline side_t *getSide(INT32 currentSector, INT32 line, INT32 side) -{ - return &sides[(sectors[currentSector].lines[line])->sidenum[side]]; -} - -/** Gets a sector from a sector line. - * - * \param currentSector Sector the line is in. - * \param line Index of the line within the sector. - * \param side 0 for front, 1 for back. - * \return Pointer to the ::sector_t of the sector on that side. - * \sa getSide, twoSided, getNextSector - */ -static inline sector_t *getSector(INT32 currentSector, INT32 line, INT32 side) -{ - return sides[(sectors[currentSector].lines[line])->sidenum[side]].sector; -} - -/** Determines whether a sector line is two-sided. - * Uses the Boom method, checking if the line's back side is set to -1, rather - * than looking for ::ML_TWOSIDED. - * - * \param sector The sector. - * \param line Line index within the sector. - * \return 1 if the sector is two-sided, 0 otherwise. - * \sa getSide, getSector, getNextSector - */ -static inline boolean twoSided(INT32 sector, INT32 line) -{ - return (sectors[sector].lines[line])->sidenum[1] != 0xffff; -} -#endif - /** Finds sector next to current. * * \param line Pointer to the line to cross. @@ -822,77 +780,6 @@ fixed_t P_FindNextLowestFloor(sector_t *sec, fixed_t currentheight) return currentheight; } -#if 0 -/** Finds next lowest ceiling in adjacent sectors. - * - * \param sec Sector to start in. - * \param currentheight Height to start at. - * \return Next lowest ceiling height in an adjacent sector, or currentheight - * if there are none lower. - * \sa P_FindLowestCeilingSurrounding, P_FindNextHighestCeiling, - * P_FindNextLowestFloor - * \author Lee Killough - */ -static fixed_t P_FindNextLowestCeiling(sector_t *sec, fixed_t currentheight) -{ - sector_t *other; - size_t i; - fixed_t height; - - for (i = 0; i < sec->linecount; i++) - { - other = getNextSector(sec->lines[i],sec); - if (other && other->ceilingheight < currentheight) - { - height = other->ceilingheight; - while (++i < sec->linecount) - { - other = getNextSector(sec->lines[i],sec); - if (other && other->ceilingheight > height - && other->ceilingheight < currentheight) - height = other->ceilingheight; - } - return height; - } - } - return currentheight; -} - -/** Finds next highest ceiling in adjacent sectors. - * - * \param sec Sector to start in. - * \param currentheight Height to start at. - * \return Next highest ceiling height in an adjacent sector, or currentheight - * if there are none higher. - * \sa P_FindHighestCeilingSurrounding, P_FindNextLowestCeiling, - * P_FindNextHighestFloor - * \author Lee Killough - */ -static fixed_t P_FindNextHighestCeiling(sector_t *sec, fixed_t currentheight) -{ - sector_t *other; - size_t i; - fixed_t height; - - for (i = 0; i < sec->linecount; i++) - { - other = getNextSector(sec->lines[i], sec); - if (other && other->ceilingheight > currentheight) - { - height = other->ceilingheight; - while (++i < sec->linecount) - { - other = getNextSector(sec->lines[i],sec); - if (other && other->ceilingheight < height - && other->ceilingheight > currentheight) - height = other->ceilingheight; - } - return height; - } - } - return currentheight; -} -#endif //////////////////////////// // End New Boom functions @@ -962,133 +849,6 @@ fixed_t P_FindHighestCeilingSurrounding(sector_t *sec) return height; } -#if 0 -//SoM: 3/7/2000: UTILS..... -// -// P_FindShortestTextureAround() -// -// Passed a sector number, returns the shortest lower texture on a -// linedef bounding the sector. -// -// -static fixed_t P_FindShortestTextureAround(INT32 secnum) -{ - fixed_t minsize = 32000<linecount; i++) - { - if (twoSided(secnum, i)) - { - side = getSide(secnum,i,0); - if (side->bottomtexture > 0) - if (textureheight[side->bottomtexture] < minsize) - minsize = textureheight[side->bottomtexture]; - side = getSide(secnum,i,1); - if (side->bottomtexture > 0) - if (textureheight[side->bottomtexture] < minsize) - minsize = textureheight[side->bottomtexture]; - } - } - return minsize; -} - -//SoM: 3/7/2000: Stuff.... (can you tell I'm getting tired? It's 12 : 30!) -// -// P_FindShortestUpperAround() -// -// Passed a sector number, returns the shortest upper texture on a -// linedef bounding the sector. -// -// -static fixed_t P_FindShortestUpperAround(INT32 secnum) -{ - fixed_t minsize = 32000<linecount; i++) - { - if (twoSided(secnum, i)) - { - side = getSide(secnum,i,0); - if (side->toptexture > 0) - if (textureheight[side->toptexture] < minsize) - minsize = textureheight[side->toptexture]; - side = getSide(secnum,i,1); - if (side->toptexture > 0) - if (textureheight[side->toptexture] < minsize) - minsize = textureheight[side->toptexture]; - } - } - return minsize; -} - -//SoM: 3/7/2000 -// -// P_FindModelFloorSector() -// -// Passed a floor height and a sector number, return a pointer to a -// a sector with that floor height across the lowest numbered two sided -// line surrounding the sector. -// -// Note: If no sector at that height bounds the sector passed, return NULL -// -// -static sector_t *P_FindModelFloorSector(fixed_t floordestheight, INT32 secnum) -{ - size_t i; - sector_t *sec = §ors[secnum]; - - for (i = 0; i < sec->linecount; i++) - { - if (twoSided(secnum, i)) - { - if (getSide(secnum,i,0)->sector-sectors == secnum) - sec = getSector(secnum,i,1); - else - sec = getSector(secnum,i,0); - - if (sec->floorheight == floordestheight) - return sec; - } - } - return NULL; -} - -// -// P_FindModelCeilingSector() -// -// Passed a ceiling height and a sector number, return a pointer to a -// a sector with that ceiling height across the lowest numbered two sided -// line surrounding the sector. -// -// Note: If no sector at that height bounds the sector passed, return NULL -// -static sector_t *P_FindModelCeilingSector(fixed_t ceildestheight, INT32 secnum) -{ - size_t i; - sector_t *sec = §ors[secnum]; - - for (i = 0; i < sec->linecount; i++) - { - if (twoSided(secnum, i)) - { - if (getSide(secnum, i, 0)->sector - sectors == secnum) - sec = getSector(secnum, i, 1); - else - sec = getSector(secnum, i, 0); - - if (sec->ceilingheight == ceildestheight) - return sec; - } - } - return NULL; -} -#endif /** Searches the tag lists for the next sector tagged to a line. * @@ -1176,37 +936,8 @@ static INT32 P_FindLineFromLineTag(const line_t *line, INT32 start) return start; } } -#if 0 -/** Searches the tag lists for the next line with a given tag and special. - * - * \param tag Tag number. - * \param start -1 to start anew, or the result of a previous call to keep - * searching. - * \return Number of next suitable line found. - * \sa P_FindLineFromLineTag - * \author Graue - */ -static INT32 P_FindLineFromTag(INT32 tag, INT32 start) -{ - if (tag == -1) - { - start++; - if (start >= numlines) - return -1; - return start; - } - else - { - start = start >= 0 ? lines[start].nexttag : - lines[(unsigned)tag % numlines].firsttag; - while (start >= 0 && lines[start].tag != tag) - start = lines[start].nexttag; - return start; - } -} -#endif // // P_FindSpecialLineFromTag // @@ -1707,17 +1438,11 @@ boolean P_RunTriggerLinedef(line_t *triggerline, mobj_t *actor, sector_t *caller if (actor && actor->player && triggerline->flags & ML_EFFECT4) { - /*if (maptol & TOL_NIGHTS) - lap = actor->player->mare; - else*/ - lap = actor->player->laps; + lap = actor->player->laps; } else { - /*if (maptol & TOL_NIGHTS) - lap = P_FindLowestMare(); - else*/ - lap = P_FindLowestLap(); + lap = P_FindLowestLap(); } if (triggerline->flags & ML_NOCLIMB) // Need higher than or equal to @@ -1754,12 +1479,6 @@ boolean P_RunTriggerLinedef(line_t *triggerline, mobj_t *actor, sector_t *caller switch (specialtype) { - /*case 305: // continuous - case 306: // each time - case 307: // once - if (!(actor && actor->player && actor->player->charability == dist/10)) - return false; - break;*/ case 309: // continuous case 310: // each time // Only red team members can activate this. @@ -1930,9 +1649,8 @@ boolean P_RunTriggerLinedef(line_t *triggerline, mobj_t *actor, sector_t *caller // "Trigger on X calls" linedefs reset if noclimb is set if ((specialtype == 321 || specialtype == 322) && triggerline->flags & ML_NOCLIMB) triggerline->callcount = sides[triggerline->sidenum[0]].textureoffset>>FRACBITS; - else // These special types work only once - if (specialtype == 302 // Once + else if (specialtype == 302 // Once || specialtype == 304 // Ring count - Once || specialtype == 307 // Character ability - Once || specialtype == 308 // Race only - Once @@ -2300,22 +2018,6 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) EV_DoCeiling(line, moveCeilingByFrontTexture); break; -/* case 405: // Lower floor by line, dx = speed, dy = amount to lower - EV_DoFloor(line, lowerFloorByLine); - break; - - case 406: // Raise floor by line, dx = speed, dy = amount to raise - EV_DoFloor(line, raiseFloorByLine); - break; - - case 407: // Lower ceiling by line, dx = speed, dy = amount to lower - EV_DoCeiling(line, lowerCeilingByLine); - break; - - case 408: // Raise ceiling by line, dx = speed, dy = amount to raise - EV_DoCeiling(line, raiseCeilingByLine); - break;*/ - case 409: // Change tagged sectors' tag // (formerly "Change calling sectors' tag", but behavior was changed) { @@ -2901,7 +2603,8 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) // Copy effect to bot if necessary // (Teleport them to you so they don't break it.) - if (bot && (bot->flags2 & MF2_TWOD) != (mo->flags2 & MF2_TWOD)) { + if (bot && (bot->flags2 & MF2_TWOD) != (mo->flags2 & MF2_TWOD)) + { bot->flags2 = (bot->flags2 & ~MF2_TWOD) | (mo->flags2 & MF2_TWOD); P_SetOrigin(bot, mo->x, mo->y, mo->z); } @@ -2934,7 +2637,8 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) P_SetTarget(&dummy->target, mo); A_CustomPower(dummy); - if (bot) { + if (bot) + { P_SetTarget(&dummy->target, bot); A_CustomPower(dummy); } @@ -3528,10 +3232,6 @@ static boolean P_ThingIsOnThe3DFloor(mobj_t *mo, sector_t *sector, sector_t *tar if (rover->master->frontsector != sector) continue; - // we're assuming the FOF existed when the first player touched it - //if (!(rover->flags & FF_EXISTS)) - // return false; - top = P_GetSpecialTopZ(mo, sector, targetsec); bottom = P_GetSpecialBottomZ(mo, sector, targetsec); @@ -4067,8 +3767,6 @@ DoneSection2: player->mo->momz = mobjinfo[MT_FAN].mass; P_ResetPlayer(player); - //if (player->panim != PA_FALL) // SRB2kart - // P_SetPlayerMobjState(player->mo, S_PLAY_FALL1); break; case 6: // SRB2kart 190117 - Sneaker Panel @@ -4240,12 +3938,6 @@ DoneSection2: if (!(player->mo->state >= &states[S_KART_RUN1] && player->mo->state <= &states[S_KART_RUN2])) P_SetPlayerMobjState(player->mo, S_KART_RUN1); - - //if (!(player->mo->state >= &states[S_PLAY_ATK1] && player->mo->state <= &states[S_PLAY_ATK4])) // SRB2kart - //{ - // P_SetPlayerMobjState(player->mo, S_PLAY_ATK1); - // S_StartSound(player->mo, sfx_spin); - //} } break; @@ -4900,12 +4592,6 @@ static void P_RunSpecialSectorCheck(player_t *player, sector_t *sector) break; } - // Check Section 3 -/* switch(GETSECSPECIAL(sector->special, 3)) - { - - }*/ - // Check Section 4 switch(GETSECSPECIAL(sector->special, 4)) { @@ -5319,42 +5005,6 @@ static void P_AddFloatThinker(sector_t *sec, INT32 tag, line_t *sourceline) R_CreateInterpolator_SectorPlane(&floater->thinker, sec, true); } -/** Adds a bridge thinker. - * Bridge thinkers cause a group of FOFs to behave like - * a bridge made up of pieces, that bows under weight. - * - * \param sec Control sector. - * \sa P_SpawnSpecials, T_BridgeThinker - * \author SSNTails - */ -/* -static inline void P_AddBridgeThinker(line_t *sourceline, sector_t *sec) -{ - levelspecthink_t *bridge; - - // create an initialize new thinker - bridge = Z_Calloc(sizeof (*bridge), PU_LEVSPEC, NULL); - P_AddThinker(&bridge->thinker); - - bridge->thinker.function.acp1 = (actionf_p1)T_BridgeThinker; - - bridge->sector = sec; - bridge->vars[0] = sourceline->frontsector->floorheight; - bridge->vars[1] = sourceline->frontsector->ceilingheight; - bridge->vars[2] = P_AproxDistance(sourceline->dx, sourceline->dy); // Speed - bridge->vars[2] = FixedDiv(bridge->vars[2], 16*FRACUNIT); - bridge->vars[3] = bridge->vars[2]; - - // Start tag and end tag are TARGET SECTORS, not CONTROL SECTORS - // Control sector tags should be End_Tag + (End_Tag - Start_Tag) - bridge->vars[4] = sourceline->tag; // Start tag - bridge->vars[5] = (sides[sourceline->sidenum[0]].textureoffset>>FRACBITS); // End tag - - // interpolation - R_CreateInterpolator_SectorPlane(&bridge->thinker, §ors[affectee], false); -} -*/ - /** Adds a Mario block thinker, which changes the block's texture between blank * and ? depending on whether it has contents. * Needed in case objects respawn inside. @@ -5772,12 +5422,6 @@ void P_SpawnSpecials(INT32 fromnetsave) break; } - // Process Section 3 -/* switch(GETSECSPECIAL(player->specialsector, 3)) - { - - }*/ - // Process Section 4 switch(GETSECSPECIAL(sector->special, 4)) { @@ -5863,16 +5507,6 @@ void P_SpawnSpecials(INT32 fromnetsave) lines[i].special = 0; continue; } - /*else -- commented out because irrelevant to kart. keeping here because we can use these flags for something else now - { - if ((players[consoleplayer].charability == CA_THOK && (lines[i].flags & ML_NOSONIC)) - || (players[consoleplayer].charability == CA_FLY && (lines[i].flags & ML_NOTAILS)) - || (players[consoleplayer].charability == CA_GLIDEANDCLIMB && (lines[i].flags & ML_NOKNUX))) - { - lines[i].special = 0; - continue; - } - }*/ } switch (lines[i].special) @@ -6053,12 +5687,14 @@ void P_SpawnSpecials(INT32 fromnetsave) break; case 64: // Appearing/Disappearing FOF option - if (lines[i].flags & ML_BLOCKMONSTERS) { // Find FOFs by control sector tag + if (lines[i].flags & ML_BLOCKMONSTERS) // Find FOFs by control sector tag + { for (s = -1; (s = P_FindSectorFromLineTag(lines + i, s)) >= 0 ;) for (j = 0; (unsigned)j < sectors[s].linecount; j++) if (sectors[s].lines[j]->special >= 100 && sectors[s].lines[j]->special < 300) Add_MasterDisappearer(abs(lines[i].dx>>FRACBITS), abs(lines[i].dy>>FRACBITS), abs(sides[lines[i].sidenum[0]].sector->floorheight>>FRACBITS), (INT32)(sectors[s].lines[j]-lines), (INT32)i); - } else // Find FOFs by effect sector tag + } + else // Find FOFs by effect sector tag for (s = -1; (s = P_FindLineFromLineTag(lines + i, s)) >= 0 ;) { if ((size_t)s == i) @@ -6069,10 +5705,6 @@ void P_SpawnSpecials(INT32 fromnetsave) break; case 65: // Bridge Thinker - /* - // Disable this until it's working right! - for (s = -1; (s = P_FindSectorFromLineTag(lines + i, s)) >= 0 ;) - P_AddBridgeThinker(&lines[i], §ors[s]);*/ break; case 100: // FOF (solid, opaque, shadows) @@ -7301,7 +6933,7 @@ void T_Disappear(disappear_t *d) if (*rover->t_slope) sectors[s].soundorg.z = P_GetZAt(*rover->t_slope, sectors[s].soundorg.x, sectors[s].soundorg.y); else - sectors[s].soundorg.z = *rover->topheight; + sectors[s].soundorg.z = *rover->topheight; S_StartSound(§ors[s].soundorg, sfx_appear); } } @@ -7375,17 +7007,6 @@ void T_Friction(friction_t *f) //{ referrer = sectors + f->referrer; - /* if (!(GETSECSPECIAL(referrer->special, 3) == 1 - || GETSECSPECIAL(referrer->special, 3) == 3)) - return; - } - else - { - if (!(GETSECSPECIAL(sec->special, 3) == 1 - || GETSECSPECIAL(sec->special, 3) == 3)) - return; - }*/ - // Assign the friction value to players on the floor, non-floating, // and clipped. Normally the object's friction value is kept at // ORIG_FRICTION and this thinker changes it for icy or muddy floors. @@ -7725,14 +7346,11 @@ void T_Pusher(pusher_t *p) { referrer = §ors[p->referrer]; - //if (!(GETSECSPECIAL(referrer->special, 3) == 2 - // || GETSECSPECIAL(referrer->special, 3) == 3)) if (GETSECSPECIAL(referrer->special, 3) != 2) return; } - //else if (!(GETSECSPECIAL(sec->special, 3) == 2 - // || GETSECSPECIAL(sec->special, 3) == 3)) else if (GETSECSPECIAL(sec->special, 3) != 2) + // For constant pushers (wind/current) there are 3 situations: // // 1) Affected Thing is above the floor. @@ -7970,14 +7588,6 @@ void T_Pusher(pusher_t *p) else localangle[3] += (thing->angle - localangle[3]) / 8; } - /*if (thing->player == &players[consoleplayer]) - localangle[0] = thing->angle; - else if (thing->player == &players[displayplayers[1]]) - localangle[1] = thing->angle; - else if (thing->player == &players[displayplayers[2]]) - localangle[2] = thing->angle; - else if (thing->player == &players[displayplayers[3]]) - localangle[3] = thing->angle;*/ } } @@ -8089,13 +7699,6 @@ static void P_SearchForDisableLinedefs(void) } else if ((lines[i].flags & ML_NETONLY) == ML_NETONLY) continue; // Net-only never triggers in single player - // commented out because irrelevant to kart. keeping here because we can use these flags for something else now - /*else if (players[consoleplayer].charability == CA_THOK && (lines[i].flags & ML_NOSONIC)) - continue; - else if (players[consoleplayer].charability == CA_FLY && (lines[i].flags & ML_NOTAILS)) - continue; - else if (players[consoleplayer].charability == CA_GLIDEANDCLIMB && (lines[i].flags & ML_NOKNUX)) - continue;*/ // Disable any linedef specials with our tag. for (j = -1; (j = P_FindLineFromLineTag(&lines[i], j)) >= 0;) diff --git a/src/r_bsp.c b/src/r_bsp.c index 4559c0f58..58573eb99 100644 --- a/src/r_bsp.c +++ b/src/r_bsp.c @@ -1142,7 +1142,7 @@ static void R_Subsector(size_t num) { // CONS_Debug(DBG_GAMELOGIC, "Adding normal line %d...(%d)\n", line->linedef-lines, leveltime); if (!line->polyseg) // ignore segs that belong to polyobjects - R_AddLine(line); + R_AddLine(line); line++; curline = NULL; /* cph 2001/11/18 - must clear curline now we're done with it, so stuff doesn't try using it for other things */ } @@ -1204,7 +1204,7 @@ void R_Prep3DFloors(sector_t *sector) rover->lastlight = 0; if (!(rover->flags & FF_EXISTS) || (rover->flags & FF_NOSHADE && !(rover->flags & FF_CUTLEVEL) && !(rover->flags & FF_CUTSPRITES))) - continue; + continue; heighttest = *rover->t_slope ? P_GetZAt(*rover->t_slope, sector->soundorg.x, sector->soundorg.y) : *rover->topheight; diff --git a/src/r_things.c b/src/r_things.c index 4345f8203..0f5da1873 100644 --- a/src/r_things.c +++ b/src/r_things.c @@ -2202,13 +2202,15 @@ static void R_CreateDrawNodes(void) } } // Check for a polyobject plane, but only if this is a front line - if (ds->curline->polyseg && ds->curline->polyseg->visplane && !ds->curline->side) { + if (ds->curline->polyseg && ds->curline->polyseg->visplane && !ds->curline->side) + { plane = ds->curline->polyseg->visplane; R_PlaneBounds(plane); if (plane->low < 0 || plane->high > vid.height || plane->high > plane->low) ; - else { + else + { // Put it in! entry = R_CreateDrawNode(&nodehead); entry->plane = plane; @@ -2231,6 +2233,7 @@ static void R_CreateDrawNodes(void) { if (!ds->ffloorplanes[p]) continue; + plane = ds->ffloorplanes[p]; R_PlaneBounds(plane); @@ -2303,10 +2306,12 @@ static void R_CreateDrawNodes(void) continue; // Effective height may be different for each comparison in the case of slopes - if (r2->plane->slope) { + if (r2->plane->slope) + { planeobjectz = P_GetZAt(r2->plane->slope, rover->gx, rover->gy); planecameraz = P_GetZAt(r2->plane->slope, viewx, viewy); - } else + } + else planeobjectz = planecameraz = r2->plane->height; if (rover->mobjflags & MF_NOCLIPHEIGHT) @@ -2365,16 +2370,20 @@ static void R_CreateDrawNodes(void) if (scale <= rover->sortscale) continue; - if (*r2->ffloor->t_slope) { + if (*r2->ffloor->t_slope) + { topplaneobjectz = P_GetZAt(*r2->ffloor->t_slope, rover->gx, rover->gy); topplanecameraz = P_GetZAt(*r2->ffloor->t_slope, viewx, viewy); - } else + } + else topplaneobjectz = topplanecameraz = *r2->ffloor->topheight; - if (*r2->ffloor->b_slope) { + if (*r2->ffloor->b_slope) + { botplaneobjectz = P_GetZAt(*r2->ffloor->b_slope, rover->gx, rover->gy); botplanecameraz = P_GetZAt(*r2->ffloor->b_slope, viewx, viewy); - } else + } + else botplaneobjectz = botplanecameraz = *r2->ffloor->bottomheight; if ((topplanecameraz > viewz && botplanecameraz < viewz) || diff --git a/src/s_sound.c b/src/s_sound.c index ae036a3db..e6f2af24a 100644 --- a/src/s_sound.c +++ b/src/s_sound.c @@ -1375,17 +1375,7 @@ void S_LoadMusicDefs(UINT16 wadnum) // Find music def while (stoken) { - /*if ((stoken[0] == '/' && stoken[1] == '/') - || (stoken[0] == '#')) // skip comments - { - stoken = strtok(NULL, "\r\n"); // skip end of line - if (def) - stoken = strtok(NULL, "\r\n= "); - else - stoken = strtok(NULL, "\r\n "); - line++; - } - else*/ if (!stricmp(stoken, "lump")) + if (!stricmp(stoken, "lump")) { value = strtok(NULL, "\r\n "); @@ -1460,35 +1450,44 @@ skip_lump: return; } - if (!stricmp(stoken, "usage")) { + if (!stricmp(stoken, "usage")) + { STRBUFCPY(def->usage, value); for (value = def->usage; *value; value++) if (*value == '_') *value = ' '; // turn _ into spaces. //CONS_Printf("S_LoadMusicDefs: Set usage to '%s'\n", def->usage); - } else if (!stricmp(stoken, "source")) { + } + else if (!stricmp(stoken, "source")) + { STRBUFCPY(def->source, value); for (value = def->source; *value; value++) if (*value == '_') *value = ' '; // turn _ into spaces. //CONS_Printf("S_LoadMusicDefs: Set source to '%s'\n", def->source); - } else if (!stricmp(stoken, "title")) { + } + else if (!stricmp(stoken, "title")) + { def->use_info = true; STRBUFCPY(def->title, value); for (value = def->title; *value; value++) if (*value == '_') *value = ' '; // turn _ into spaces. //CONS_Printf("S_LoadMusicDefs: Set source to '%s'\n", def->source); - } else if (!stricmp(stoken, "alttitle")) { + } + else if (!stricmp(stoken, "alttitle")) + { STRBUFCPY(def->alttitle, value); for (value = def->alttitle; *value; value++) if (*value == '_') *value = ' '; // turn _ into spaces. //CONS_Printf("S_LoadMusicDefs: Set source to '%s'\n", def->source); - } else if (!stricmp(stoken, "authors")) { + } + else if (!stricmp(stoken, "authors")) + { STRBUFCPY(def->authors, value); for (value = def->authors; *value; value++) if (*value == '_') *value = ' '; // turn _ into spaces. //CONS_Printf("S_LoadMusicDefs: Set source to '%s'\n", def->source); - } else { - CONS_Alert(CONS_WARNING, "MUSICDEF: Invalid field '%s'. (file %s, line %d)\n", stoken, wadfiles[wadnum]->filename, line); } + else + CONS_Alert(CONS_WARNING, "MUSICDEF: Invalid field '%s'. (file %s, line %d)\n", stoken, wadfiles[wadnum]->filename, line); skip_field: stoken = strtok(NULL, "\r\n= "); @@ -1559,17 +1558,7 @@ void S_LoadMTDefs(UINT16 wadnum) // Find music def while (stoken) { - /*if ((stoken[0] == '/' && stoken[1] == '/') - || (stoken[0] == '#')) // skip comments - { - stoken = strtok(NULL, "\r\n"); // skip end of line - if (def) - stoken = strtok(NULL, "\r\n= "); - else - stoken = strtok(NULL, "\r\n "); - line++; - } - else*/ if (!stricmp(stoken, "lump")) + if (!stricmp(stoken, "lump")) { value = strtok(NULL, "\r\n "); @@ -1638,25 +1627,30 @@ skip_lump: return; } - if (!stricmp(stoken, "title")) { + if (!stricmp(stoken, "title")) + { def->use_info = true; STRBUFCPY(def->title, value); for (value = def->title; *value; value++) if (*value == '_') *value = ' '; // turn _ into spaces. //CONS_Printf("S_LoadMusicDefs: Set source to '%s'\n", def->source); - } else if (!stricmp(stoken, "alttitle")) { + } + else if (!stricmp(stoken, "alttitle")) + { STRBUFCPY(def->alttitle, value); for (value = def->alttitle; *value; value++) if (*value == '_') *value = ' '; // turn _ into spaces. //CONS_Printf("S_LoadMusicDefs: Set source to '%s'\n", def->source); - } else if (!stricmp(stoken, "authors")) { + } + else if (!stricmp(stoken, "authors")) + { STRBUFCPY(def->authors, value); for (value = def->authors; *value; value++) if (*value == '_') *value = ' '; // turn _ into spaces. //CONS_Printf("S_LoadMusicDefs: Set source to '%s'\n", def->source); - } else { - CONS_Alert(CONS_WARNING, "MUSCINFO: Invalid field '%s'. (file %s, line %d)\n", stoken, wadfiles[wadnum]->filename, line); } + else + CONS_Alert(CONS_WARNING, "MUSCINFO: Invalid field '%s'. (file %s, line %d)\n", stoken, wadfiles[wadnum]->filename, line); skip_field: stoken = strtok(NULL, "\r\n= "); @@ -2363,9 +2357,8 @@ static void Command_ShowMusicCredit_f(void) musicdef_t *def = S_FindMusicCredit(musname); - if (def) { + if (def) CONS_Printf("%.6s - %.255s\n", musname, def->source); - } } static void GameSounds_OnChange(void) @@ -2396,6 +2389,7 @@ static void SoundPrecache_OnChange(void) else if (!S_PrecacheSound()) { S_ClearSfx(); + if (!sound_disabled) S_InitSfxChannels(cv_soundvolume.value); } diff --git a/src/st_stuff.c b/src/st_stuff.c index 681f2d920..a89d49793 100644 --- a/src/st_stuff.c +++ b/src/st_stuff.c @@ -526,17 +526,7 @@ static void ST_drawDebugInfo(void) if (cv_debug & DBG_DETAILED) { - //V_DrawRightAlignedString(320, height - 104, V_MONOSPACE, va("SHIELD: %5x", stplyr->powers[pw_shield])); V_DrawRightAlignedString(320, height - 96, V_MONOSPACE, va("SCALE: %5d%%", (stplyr->mo->scale*100)/FRACUNIT)); - //V_DrawRightAlignedString(320, height - 88, V_MONOSPACE, va("DASH: %3d/%3d", stplyr->dashspeed>>FRACBITS, FixedMul(stplyr->maxdash,stplyr->mo->scale)>>FRACBITS)); - //V_DrawRightAlignedString(320, height - 80, V_MONOSPACE, va("AIR: %4d, %3d", stplyr->powers[pw_underwater], stplyr->powers[pw_spacetime])); - - // Flags - //V_DrawRightAlignedString(304-64, height - 72, V_MONOSPACE, "Flags:"); - //V_DrawString(304-60, height - 72, (stplyr->jumping) ? V_GREENMAP : V_REDMAP, "JM"); - //V_DrawString(304-40, height - 72, (stplyr->pflags & PF_JUMPED) ? V_GREENMAP : V_REDMAP, "JD"); - //V_DrawString(304-20, height - 72, (stplyr->pflags & PF_SPINNING) ? V_GREENMAP : V_REDMAP, "SP"); - //V_DrawString(304, height - 72, (stplyr->pflags & PF_STARTDASH) ? V_GREENMAP : V_REDMAP, "ST"); V_DrawRightAlignedString(320, height - 64, V_MONOSPACE, va("CEILZ: %6d", stplyr->mo->ceilingz>>FRACBITS)); V_DrawRightAlignedString(320, height - 56, V_MONOSPACE, va("FLOORZ: %6d", stplyr->mo->floorz>>FRACBITS)); @@ -570,132 +560,6 @@ static void ST_drawDebugInfo(void) V_DrawRightAlignedString(320, height, V_MONOSPACE, va("Heap used: %7sKB", sizeu1(Z_TagsUsage(0, INT32_MAX)>>10))); } -/* -static void ST_drawScore(void) -{ - // SCORE: - ST_DrawPatchFromHud(HUD_SCORE, sboscore); - if (objectplacing) - { - if (op_displayflags > UINT16_MAX) - ST_DrawOverlayPatch(SCX(hudinfo[HUD_SCORENUM].x-tallminus->width), SCY(hudinfo[HUD_SCORENUM].y), tallminus); - else - ST_DrawNumFromHud(HUD_SCORENUM, op_displayflags); - } - else - ST_DrawNumFromHud(HUD_SCORENUM, stplyr->score); -} -*/ - -/* -static void ST_drawTime(void) -{ - INT32 seconds, minutes, tictrn, tics; - - // TIME: - ST_DrawPatchFromHudWS(HUD_TIME, sbotime); - - if (objectplacing) - { - tics = objectsdrawn; - seconds = objectsdrawn%100; - minutes = objectsdrawn/100; - tictrn = 0; - } - else - { - tics = stplyr->realtime; - seconds = G_TicsToSeconds(tics); - minutes = G_TicsToMinutes(tics, true); - tictrn = G_TicsToCentiseconds(tics); - } - - if (cv_timetic.value == 1) // Tics only -- how simple is this? - ST_DrawNumFromHudWS(HUD_SECONDS, tics); - else - { - ST_DrawNumFromHudWS(HUD_MINUTES, minutes); // Minutes - ST_DrawPatchFromHudWS(HUD_TIMECOLON, sbocolon); // Colon - ST_DrawPadNumFromHudWS(HUD_SECONDS, seconds, 2); // Seconds - - if (!splitscreen && (cv_timetic.value == 2 || modeattacking)) // there's not enough room for tics in splitscreen, don't even bother trying! - { - ST_DrawPatchFromHud(HUD_TIMETICCOLON, sboperiod); // Period - ST_DrawPadNumFromHud(HUD_TICS, tictrn, 2); // Tics - } - } -} -*/ - -/* -static inline void ST_drawRings(void) // SRB2kart - unused. -{ - INT32 ringnum = max(stplyr->health-1, 0); - - ST_DrawPatchFromHudWS(HUD_RINGS, ((stplyr->health <= 1 && leveltime/5 & 1) ? rrings : sborings)); - - if (objectplacing) - ringnum = op_currentdoomednum; - else if (!useNightsSS && G_IsSpecialStage(gamemap)) - { - INT32 i; - ringnum = 0; - for (i = 0; i < MAXPLAYERS; i++) - if (playeringame[i] && players[i].mo && players[i].mo->health > 1) - ringnum += players[i].mo->health - 1; - } - - ST_DrawNumFromHudWS(HUD_RINGSNUM, ringnum); -} -*/ - -/* -static void ST_drawLives(void) // SRB2kart - unused. -{ - const INT32 v_splitflag = (splitscreen && stplyr == &players[displayplayers[0]] ? V_SPLITSCREEN : 0); - - if (!stplyr->skincolor) - return; // Just joined a server, skin isn't loaded yet! - - // face background - V_DrawSmallScaledPatch(hudinfo[HUD_LIVESPIC].x, hudinfo[HUD_LIVESPIC].y + (v_splitflag ? -12 : 0), - V_SNAPTOLEFT|V_SNAPTOBOTTOM|V_HUDTRANS|v_splitflag, livesback); - - // face - if (stplyr->mo && stplyr->mo->color) - { - // skincolor face/super - UINT8 *colormap = R_GetTranslationColormap(stplyr->skin, stplyr->mo->color, GTC_CACHE); - patch_t *face = facerankprefix[stplyr->skin]; - if (stplyr->powers[pw_super] || stplyr->pflags & PF_NIGHTSMODE) - face = facewantprefix[stplyr->skin]; - V_DrawSmallMappedPatch(hudinfo[HUD_LIVESPIC].x, hudinfo[HUD_LIVESPIC].y + (v_splitflag ? -12 : 0), - V_SNAPTOLEFT|V_SNAPTOBOTTOM|V_HUDTRANS|v_splitflag,face, colormap); - } - else if (stplyr->skincolor) - { - // skincolor face - UINT8 *colormap = R_GetTranslationColormap(stplyr->skin, stplyr->skincolor, GTC_CACHE); - V_DrawSmallMappedPatch(hudinfo[HUD_LIVESPIC].x, hudinfo[HUD_LIVESPIC].y + (v_splitflag ? -12 : 0), - V_SNAPTOLEFT|V_SNAPTOBOTTOM|V_HUDTRANS|v_splitflag,facerankprefix[stplyr->skin], colormap); - } - - // name - if (strlen(skins[stplyr->skin].hudname) > 8) - V_DrawThinString(hudinfo[HUD_LIVESNAME].x, hudinfo[HUD_LIVESNAME].y + (v_splitflag ? -12 : 0), - V_HUDTRANS|V_SNAPTOLEFT|V_SNAPTOBOTTOM|V_MONOSPACE|V_YELLOWMAP|v_splitflag, skins[stplyr->skin].hudname); - else - V_DrawString(hudinfo[HUD_LIVESNAME].x, hudinfo[HUD_LIVESNAME].y + (v_splitflag ? -12 : 0), - V_HUDTRANS|V_SNAPTOLEFT|V_SNAPTOBOTTOM|V_MONOSPACE|V_YELLOWMAP|v_splitflag, skins[stplyr->skin].hudname); - // x - V_DrawScaledPatch(hudinfo[HUD_LIVESX].x, hudinfo[HUD_LIVESX].y + (v_splitflag ? -4 : 0), - V_SNAPTOLEFT|V_SNAPTOBOTTOM|V_HUDTRANS|v_splitflag, stlivex); - // lives - V_DrawRightAlignedString(hudinfo[HUD_LIVESNUM].x, hudinfo[HUD_LIVESNUM].y + (v_splitflag ? -4 : 0), - V_SNAPTOLEFT|V_SNAPTOBOTTOM|V_HUDTRANS|v_splitflag, va("%d",stplyr->lives)); -} -*/ - static void ST_drawLevelTitle(void) { char *lvlttl = mapheaderinfo[gamemap-1]->lvlttl; @@ -832,15 +696,6 @@ static void ST_overlayDrawer(void) } } } - - // This is where we draw all the fun cheese if you have the chasecam off! - /*if ((stplyr == &players[displayplayers[0]] && !camera[0].chase) - || ((splitscreen && stplyr == &players[displayplayers[1]]) && !camera[1].chase) - || ((splitscreen > 1 && stplyr == &players[displayplayers[2]]) && !camera[2].chase) - || ((splitscreen > 2 && stplyr == &players[displayplayers[3]]) && !camera[3].chase)) - { - ST_drawFirstPersonHUD(); - }*/ } if (!(netgame || multiplayer) || !hu_showscores) diff --git a/src/v_video.c b/src/v_video.c index bc1dd4159..4c5e1cfd3 100644 --- a/src/v_video.c +++ b/src/v_video.c @@ -15,6 +15,7 @@ #include "doomdef.h" #include "r_local.h" +#include "p_local.h" #include "v_video.h" #include "hu_stuff.h" #include "r_draw.h" @@ -3135,7 +3136,7 @@ INT32 heatindex[MAXSPLITSCREENPLAYERS] = {0, 0, 0, 0}; // // Perform a particular image postprocessing function. // -#include "p_local.h" + void V_DoPostProcessor(INT32 view, postimg_t type, INT32 param) { #if NUMSCREENS < 5 @@ -3203,8 +3204,8 @@ void V_DoPostProcessor(INT32 view, postimg_t type, INT32 param) } } -/* -Unoptimized version + /* + Unoptimized version for (x = 0; x < vid.width*vid.bpp; x++) { newpix = (x + sine); diff --git a/src/w_wad.c b/src/w_wad.c index 04015d614..762cdc417 100644 --- a/src/w_wad.c +++ b/src/w_wad.c @@ -62,9 +62,6 @@ #include "md5.h" #include "lua_script.h" #include "st_stuff.h" -#ifdef SCANTHINGS -#include "p_setup.h" // P_ScanThings -#endif #include "m_misc.h" // M_MapNumber #include "p_setup.h" // P_PartialAddFile mayb @@ -117,7 +114,8 @@ void W_Shutdown(void) if (wad->handle) fclose(wad->handle); Z_Free(wad->filename); - while (wad->numlumps--) { + while (wad->numlumps--) + { Z_Free(wad->lumpinfo[wad->numlumps].longname); Z_Free(wad->lumpinfo[wad->numlumps].fullname); } @@ -287,22 +285,6 @@ static inline void W_LoadDehackedLumps(UINT16 wadnum) DEH_LoadDehackedLumpPwad(wadnum, lump); } } - -#ifdef SCANTHINGS - // Scan maps for emblems 'n shit - { - lumpinfo_t *lump_p = wadfiles[wadnum]->lumpinfo; - for (lump = 0; lump < wadfiles[wadnum]->numlumps; lump++, lump_p++) - { - const char *name = lump_p->name; - if (name[0] == 'M' && name[1] == 'A' && name[2] == 'P' && name[5]=='\0') - { - INT16 mapnum = (INT16)M_MapNumber(name[3], name[4]); - P_ScanThings(mapnum, wadnum, lump + ML_THINGS); - } - } - } -#endif } /** Compute MD5 message digest for bytes read from STREAM of this filname. From f545cce6febaf2bb3a7d688d8d7f9d5d87053ced Mon Sep 17 00:00:00 2001 From: Indev Date: Thu, 25 Jul 2024 22:50:53 +0300 Subject: [PATCH 5/6] Add check for if lua state exist in UnArchiveExtVars, since server can have local luas that may add player/mobj fields into savegame --- src/lua_script.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/lua_script.c b/src/lua_script.c index 160c92180..6528a515e 100644 --- a/src/lua_script.c +++ b/src/lua_script.c @@ -1432,7 +1432,12 @@ static void UnArchiveExtVars(void *pointer) if (field_count == 0) return; - I_Assert(gL != NULL); + + // Technically possible new, since server may have local lua scripts but no "public" ones, so + // field_count would be non zero (there is no way to tell local field from non-local, so + // everything gets archived) + if (!gL) + return; TABLESINDEX = lua_gettop(gL); lua_createtable(gL, 0, field_count); // pointer's ext vars subtable From ce2398fdb774cee0b863a1a430db207b5a44f259 Mon Sep 17 00:00:00 2001 From: Alug Date: Fri, 26 Jul 2024 13:59:37 +0200 Subject: [PATCH 6/6] add some extra safety to orbit and bananachain funcs --- src/k_kart.c | 22 ++++++++++++++++------ src/p_inter.c | 4 ++-- 2 files changed, 18 insertions(+), 8 deletions(-) diff --git a/src/k_kart.c b/src/k_kart.c index 1ce92dc30..a113eb6ae 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -4086,6 +4086,9 @@ void K_KillBananaChain(mobj_t *banana, mobj_t *inflictor, mobj_t *source) mobj_t *cachenext; killnext: + if (P_MobjWasRemoved(banana)) + return; + cachenext = banana->hnext; if (banana->health) @@ -4126,6 +4129,13 @@ void K_UpdateHnextList(player_t *player, boolean clean) P_RemoveMobj(work); } + + if (player->mo->hnext == NULL || P_MobjWasRemoved(player->mo->hnext)) + { + // Like below, try to clean up the pointer if it's NULL. + // Maybe this was a cause of the shrink/eggbox fails? + P_SetTarget(&player->mo->hnext, NULL); + } } // For getting hit! @@ -4373,10 +4383,8 @@ void K_RepairOrbitChain(mobj_t *orbit) } // Then recount to make sure item amount is correct - if (orbit->target && orbit->target->player) + if (orbit->target && orbit->target->player && !P_MobjWasRemoved(orbit->target)) { - player_t *player = orbit->target->player; - INT32 num = 0; mobj_t *cur = orbit->target->hnext; @@ -4386,14 +4394,14 @@ void K_RepairOrbitChain(mobj_t *orbit) { prev = cur; cur = cur->hnext; - if (++num > player->kartstuff[k_itemamount]) + if (++num > orbit->target->player->kartstuff[k_itemamount]) P_RemoveMobj(prev); else prev->movedir = num; } - if (player->kartstuff[k_itemamount] != num) - player->kartstuff[k_itemamount] = num; + if (orbit->target && !P_MobjWasRemoved(orbit->target) && orbit->target->player->kartstuff[k_itemamount] != num) + orbit->target->player->kartstuff[k_itemamount] = num; } } @@ -4406,6 +4414,7 @@ static void K_MoveHeldObjects(player_t *player) if (!player->mo->hnext) { player->kartstuff[k_bananadrag] = 0; + if (player->kartstuff[k_eggmanheld]) player->kartstuff[k_eggmanheld] = 0; else if (player->kartstuff[k_itemheld]) @@ -4421,6 +4430,7 @@ static void K_MoveHeldObjects(player_t *player) // we need this here too because this is done in afterthink - pointers are cleaned up at the START of each tic... P_SetTarget(&player->mo->hnext, NULL); player->kartstuff[k_bananadrag] = 0; + if (player->kartstuff[k_eggmanheld]) player->kartstuff[k_eggmanheld] = 0; else if (player->kartstuff[k_itemheld]) diff --git a/src/p_inter.c b/src/p_inter.c index dbc6e6a3b..c23bfe286 100644 --- a/src/p_inter.c +++ b/src/p_inter.c @@ -1648,7 +1648,7 @@ void P_KillMobj(mobj_t *target, mobj_t *inflictor, mobj_t *source) // SRB2kart // I wish I knew a better way to do this - if (target->target && target->target->player && target->target->player->mo) + if (!P_MobjWasRemoved(target->target) && target->target->player && !P_MobjWasRemoved(target->target->player->mo)) { if (target->target->player->kartstuff[k_eggmanheld] && target->type == MT_EGGMANITEM_SHIELD) target->target->player->kartstuff[k_eggmanheld] = 0; @@ -1665,7 +1665,7 @@ void P_KillMobj(mobj_t *target, mobj_t *inflictor, mobj_t *source) K_KillBananaChain(target->target->hnext, inflictor, source); target->target->player->kartstuff[k_itemamount] = 0; } - else + else if (target->target->player->kartstuff[k_itemamount]) target->target->player->kartstuff[k_itemamount]--; } else if ((target->type == MT_ORBINAUT_SHIELD && target->target->player->kartstuff[k_itemtype] == KITEM_ORBINAUT) // orbit items