diff --git a/src/b_bot.c b/src/b_bot.c index 2bdbbbee9..8100fc414 100644 --- a/src/b_bot.c +++ b/src/b_bot.c @@ -132,20 +132,55 @@ void B_BuildTiccmd(player_t *player, ticcmd_t *cmd) void B_KeysToTiccmd(mobj_t *mo, ticcmd_t *cmd, boolean forward, boolean backward, boolean left, boolean right, boolean strafeleft, boolean straferight, boolean jump, boolean spin) { - (void)mo; - - if (forward) - cmd->forwardmove += MAXPLMOVE<>16; - if (backward) - cmd->forwardmove -= MAXPLMOVE<>16; - if (left) - cmd->angleturn += 1280; - if (right) - cmd->angleturn -= 1280; - if (strafeleft) - cmd->sidemove -= MAXPLMOVE<>16; - if (straferight) - cmd->sidemove += MAXPLMOVE<>16; + // Turn the virtual keypresses into ticcmd_t. + if (twodlevel || mo->flags2 & MF2_TWOD) { + if (players[consoleplayer].climbing + || mo->player->pflags & PF_GLIDING) { + // Don't mess with bot inputs during these unhandled movement conditions. + // The normal AI doesn't use abilities, so custom AI should be sending us exactly what it wants anyway. + if (forward) + cmd->forwardmove += MAXPLMOVE<>16; + if (backward) + cmd->forwardmove -= MAXPLMOVE<>16; + if (left || strafeleft) + cmd->sidemove -= MAXPLMOVE<>16; + if (right || straferight) + cmd->sidemove += MAXPLMOVE<>16; + } else { + // In standard 2D mode, interpret "forward" as "the way you're facing" and everything else as "the way you're not facing" + if (left || right) + backward = true; + left = right = false; + if (forward) { + if (mo->angle < ANGLE_90 || mo->angle > ANGLE_270) + right = true; + else + left = true; + } else if (backward) { + if (mo->angle < ANGLE_90 || mo->angle > ANGLE_270) + left = true; + else + right = true; + } + if (left || strafeleft) + cmd->sidemove -= MAXPLMOVE<>16; + if (right || straferight) + cmd->sidemove += MAXPLMOVE<>16; + } + } else { + if (forward) + cmd->forwardmove += MAXPLMOVE<>16; + if (backward) + cmd->forwardmove -= MAXPLMOVE<>16; + if (left) + cmd->angleturn += 1280; + if (right) + cmd->angleturn -= 1280; + if (strafeleft) + cmd->sidemove -= MAXPLMOVE<>16; + if (straferight) + cmd->sidemove += MAXPLMOVE<>16; + } if (jump) cmd->buttons |= BT_DRIFT; if (spin) diff --git a/src/d_clisrv.c b/src/d_clisrv.c index 5b307f160..4820515ca 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -802,6 +802,110 @@ static void resynch_read_player(resynch_pak *rsp) P_SetThingPosition(players[i].mo); } +static inline void resynch_write_ctf(resynchend_pak *rst) +{ + mobj_t *mflag; + UINT8 i, j; + + for (i = 0, mflag = redflag; i < 2; ++i, mflag = blueflag) + { + rst->flagx[i] = rst->flagy[i] = rst->flagz[i] = 0; + rst->flagloose[i] = rst->flagflags[i] = 0; + rst->flagplayer[i] = -1; + + if (!mflag) + { + // Should be held by a player + for (j = 0; j < MAXPLAYERS; ++j) + { + // GF_REDFLAG is 1, GF_BLUEFLAG is 2 + // redflag handling is i=0, blueflag is i=1 + // so check for gotflag == (i+1) + if (!playeringame[j] || players[j].gotflag != (i+1)) + continue; + rst->flagplayer[i] = (SINT8)j; + break; + } + if (j == MAXPLAYERS) // fine, no I_Error + { + CONS_Alert(CONS_ERROR, "One of the flags has gone completely missing...\n"); + rst->flagplayer[i] = -2; + } + continue; + } + + rst->flagx[i] = (fixed_t)LONG(mflag->x); + rst->flagy[i] = (fixed_t)LONG(mflag->y); + rst->flagz[i] = (fixed_t)LONG(mflag->z); + rst->flagflags[i] = LONG(mflag->flags2); + rst->flagloose[i] = LONG(mflag->fuse); // Dropped or not? + } +} + +static inline void resynch_read_ctf(resynchend_pak *p) +{ + UINT8 i; + + for (i = 0; i < MAXPLAYERS; ++i) + players[i].gotflag = 0; + + // Red flag + if (p->flagplayer[0] == -2) + ; // The server doesn't even know what happened to it... + else if (p->flagplayer[0] != -1) // Held by a player + { + if (!playeringame[p->flagplayer[0]]) + I_Error("Invalid red flag player %d who isn't in the game!", (INT32)p->flagplayer[0]); + players[p->flagplayer[0]].gotflag = GF_REDFLAG; + if (redflag) + { + P_RemoveMobj(redflag); + redflag = NULL; + } + } + else + { + if (!redflag) + redflag = P_SpawnMobj(0,0,0,MT_REDFLAG); + + P_UnsetThingPosition(redflag); + redflag->x = (fixed_t)LONG(p->flagx[0]); + redflag->y = (fixed_t)LONG(p->flagy[0]); + redflag->z = (fixed_t)LONG(p->flagz[0]); + redflag->flags2 = LONG(p->flagflags[0]); + redflag->fuse = LONG(p->flagloose[0]); + P_SetThingPosition(redflag); + } + + // Blue flag + if (p->flagplayer[1] == -2) + ; // The server doesn't even know what happened to it... + else if (p->flagplayer[1] != -1) // Held by a player + { + if (!playeringame[p->flagplayer[1]]) + I_Error("Invalid blue flag player %d who isn't in the game!", (INT32)p->flagplayer[1]); + players[p->flagplayer[1]].gotflag = GF_BLUEFLAG; + if (blueflag) + { + P_RemoveMobj(blueflag); + blueflag = NULL; + } + } + else + { + if (!blueflag) + blueflag = P_SpawnMobj(0,0,0,MT_BLUEFLAG); + + P_UnsetThingPosition(blueflag); + blueflag->x = (fixed_t)LONG(p->flagx[1]); + blueflag->y = (fixed_t)LONG(p->flagy[1]); + blueflag->z = (fixed_t)LONG(p->flagz[1]); + blueflag->flags2 = LONG(p->flagflags[1]); + blueflag->fuse = LONG(p->flagloose[1]); + P_SetThingPosition(blueflag); + } +} + static inline void resynch_write_others(resynchend_pak *rst) { UINT8 i; @@ -902,6 +1006,8 @@ static void SV_SendResynch(INT32 node) netbuffer->packettype = PT_RESYNCHEND; netbuffer->u.resynchend.randomseed = P_GetRandSeed(); + if (gametype == GT_CTF) + resynch_write_ctf(&netbuffer->u.resynchend); resynch_write_others(&netbuffer->u.resynchend); HSendPacket(node, true, 0, (sizeof(resynchend_pak))); @@ -1508,10 +1614,20 @@ static void SV_SendPlayerInfo(INT32 node) //No, don't do that, you fuckface. memset(netbuffer->u.playerinfo[i].address, 0, 4); - if (players[i].spectator) - netbuffer->u.playerinfo[i].team = 255; + if (G_GametypeHasTeams()) + { + if (!players[i].ctfteam) + netbuffer->u.playerinfo[i].team = 255; + else + netbuffer->u.playerinfo[i].team = (UINT8)players[i].ctfteam; + } else - netbuffer->u.playerinfo[i].team = 0; + { + if (players[i].spectator) + netbuffer->u.playerinfo[i].team = 255; + else + netbuffer->u.playerinfo[i].team = 0; + } netbuffer->u.playerinfo[i].score = LONG(players[i].score); netbuffer->u.playerinfo[i].timeinserver = SHORT((UINT16)(players[i].jointime / TICRATE)); @@ -3088,6 +3204,9 @@ void CL_RemovePlayer(INT32 playernum, INT32 reason) if (K_IsPlayerWanted(&players[playernum])) K_CalculateBattleWanted(); + if (gametype == GT_CTF) + P_PlayerFlagBurst(&players[playernum], false); // Don't take the flag with you! + // If in a special stage, redistribute the player's rings across // the remaining players. if (G_IsSpecialStage(gamemap)) @@ -5446,6 +5565,9 @@ static void HandlePacketFromPlayer(SINT8 node) resynch_local_inprogress = false; P_SetRandSeed(netbuffer->u.resynchend.randomseed); + + if (gametype == GT_CTF) + resynch_read_ctf(&netbuffer->u.resynchend); resynch_read_others(&netbuffer->u.resynchend); break; diff --git a/src/d_clisrv.h b/src/d_clisrv.h index 5ddec0437..4e81621d9 100644 --- a/src/d_clisrv.h +++ b/src/d_clisrv.h @@ -182,6 +182,14 @@ typedef struct { UINT32 randomseed; + // CTF flag stuff + SINT8 flagplayer[2]; + INT32 flagloose[2]; + INT32 flagflags[2]; + fixed_t flagx[2]; + fixed_t flagy[2]; + fixed_t flagz[2]; + UINT32 ingame; // Spectator bit for each player INT32 ctfteam[MAXPLAYERS]; // Which team? (can't be 1 bit, since in regular Match there are no teams) diff --git a/src/d_netcmd.c b/src/d_netcmd.c index c2ad1be2e..e49f6c17a 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -16,6 +16,7 @@ #include "console.h" #include "command.h" +#include "dehacked.h" #include "i_time.h" #include "i_system.h" #include "g_game.h" @@ -141,6 +142,8 @@ static void Command_Addfile(void); static void Command_Addskins(void); static void Command_GLocalSkin(void); static void Command_ListWADS_f(void); +static void Command_ListDoomednums_f(void); +static void Command_ListUnusedSprites_f(void); static void Command_RunSOC(void); static void Command_Pause(void); static void Command_Respawn(void); @@ -705,6 +708,8 @@ void D_RegisterServerCommands(void) COM_AddCommand("addskins", Command_Addskins); COM_AddCommand("localskin", Command_GLocalSkin); COM_AddCommand("listwad", Command_ListWADS_f); + COM_AddCommand("listmapthings", Command_ListDoomednums_f); + COM_AddCommand("listunusedsprites", Command_ListUnusedSprites_f); COM_AddCommand("runsoc", Command_RunSOC); COM_AddCommand("pause", Command_Pause); @@ -1521,10 +1526,24 @@ UINT8 CanChangeSkin(INT32 playernum) // Server has skin change restrictions. if (cv_restrictskinchange.value) { + if (gametype == GT_COOP) + return true; + // Can change skin during initial countdown. if (leveltime < starttime) return true; + if (G_TagGametype()) + { + // Can change skin during hidetime. + if (leveltime < hidetime * TICRATE) + return true; + + // IT players can always change skins to persue players hiding in character only locations. + if (players[playernum].pflags & PF_TAGIT) + return true; + } + if (players[playernum].spectator || players[playernum].playerstate == PST_DEAD || players[playernum].playerstate == PST_REBORN) return true; @@ -1570,6 +1589,15 @@ static void SendNameAndColor(void) p = buf; + // normal player colors + if (G_GametypeHasTeams()) + { + if (players[consoleplayer].ctfteam == 1 && cv_playercolor.value != skincolor_redteam) + CV_StealthSetValue(&cv_playercolor, skincolor_redteam); + else if (players[consoleplayer].ctfteam == 2 && cv_playercolor.value != skincolor_blueteam) + CV_StealthSetValue(&cv_playercolor, skincolor_blueteam); + } + // never allow the color "none" if (!cv_playercolor.value) { @@ -1679,6 +1707,15 @@ static void SendNameAndColor2(void) p = buf; + // normal player colors + if (G_GametypeHasTeams()) + { + if (players[secondplaya].ctfteam == 1 && cv_playercolor2.value != skincolor_redteam) + CV_StealthSetValue(&cv_playercolor2, skincolor_redteam); + else if (players[secondplaya].ctfteam == 2 && cv_playercolor2.value != skincolor_blueteam) + CV_StealthSetValue(&cv_playercolor2, skincolor_blueteam); + } + // never allow the color "none" if (!cv_playercolor2.value) { @@ -1783,6 +1820,15 @@ static void SendNameAndColor3(void) p = buf; + // normal player colors + if (G_GametypeHasTeams()) + { + if (players[thirdplaya].ctfteam == 1 && cv_playercolor3.value != skincolor_redteam) + CV_StealthSetValue(&cv_playercolor3, skincolor_redteam); + else if (players[thirdplaya].ctfteam == 2 && cv_playercolor3.value != skincolor_blueteam) + CV_StealthSetValue(&cv_playercolor3, skincolor_blueteam); + } + // never allow the color "none" if (!cv_playercolor3.value) { @@ -1895,6 +1941,15 @@ static void SendNameAndColor4(void) p = buf; + // normal player colors + if (G_GametypeHasTeams()) + { + if (players[fourthplaya].ctfteam == 1 && cv_playercolor4.value != skincolor_redteam) + CV_StealthSetValue(&cv_playercolor4, skincolor_redteam); + else if (players[fourthplaya].ctfteam == 2 && cv_playercolor4.value != skincolor_blueteam) + CV_StealthSetValue(&cv_playercolor4, skincolor_blueteam); + } + // never allow the color "none" if (!cv_playercolor4.value) { @@ -2028,6 +2083,15 @@ static void Got_NameAndColor(UINT8 **cp, INT32 playernum) { boolean kick = false; + // team colors + if (G_GametypeHasTeams()) + { + if (p->ctfteam == 1 && p->skincolor != skincolor_redteam) + kick = true; + else if (p->ctfteam == 2 && p->skincolor != skincolor_blueteam) + kick = true; + } + // don't allow color "none" if (!p->skincolor) kick = true; @@ -3259,14 +3323,27 @@ static void Command_Teamchange_f(void) if (COM_Argc() <= 1) { - if (G_GametypeHasSpectators()) + if (G_GametypeHasTeams()) + CONS_Printf(M_GetText("changeteam : switch to a new team (%s)\n"), "red, blue or spectator"); + else if (G_GametypeHasSpectators()) CONS_Printf(M_GetText("changeteam : switch to a new team (%s)\n"), "spectator or playing"); else CONS_Alert(CONS_NOTICE, M_GetText("This command cannot be used in this gametype.\n")); return; } - if (G_GametypeHasSpectators()) + if (G_GametypeHasTeams()) + { + if (!strcasecmp(COM_Argv(1), "red") || !strcasecmp(COM_Argv(1), "1")) + NetPacket.packet.newteam = 1; + else if (!strcasecmp(COM_Argv(1), "blue") || !strcasecmp(COM_Argv(1), "2")) + NetPacket.packet.newteam = 2; + else if (!strcasecmp(COM_Argv(1), "spectator") || !strcasecmp(COM_Argv(1), "0")) + NetPacket.packet.newteam = 0; + else + error = true; + } + else if (G_GametypeHasSpectators()) { if (!strcasecmp(COM_Argv(1), "spectator") || !strcasecmp(COM_Argv(1), "0")) NetPacket.packet.newteam = 0; @@ -3283,13 +3360,17 @@ static void Command_Teamchange_f(void) if (error) { - if (G_GametypeHasSpectators()) + if (G_GametypeHasTeams()) + CONS_Printf(M_GetText("changeteam : switch to a new team (%s)\n"), "red, blue or spectator"); + else if (G_GametypeHasSpectators()) CONS_Printf(M_GetText("changeteam : switch to a new team (%s)\n"), "spectator or playing"); return; } if (players[consoleplayer].spectator) error = !(NetPacket.packet.newteam || (players[consoleplayer].pflags & PF_WANTSTOJOIN)); // :lancer: + else if (G_GametypeHasTeams()) + error = (NetPacket.packet.newteam == (unsigned)players[consoleplayer].ctfteam); else if (G_GametypeHasSpectators() && !players[consoleplayer].spectator) error = (NetPacket.packet.newteam == 3); #ifdef PARANOIA @@ -3309,6 +3390,13 @@ static void Command_Teamchange_f(void) return; } + //additional check for hide and seek. Don't allow change of status after hidetime ends. + if (gametype == GT_HIDEANDSEEK && leveltime >= (hidetime * TICRATE)) + { + CONS_Alert(CONS_NOTICE, M_GetText("Hiding time expired; no Hide and Seek status changes allowed!\n")); + return; + } + usvalue = SHORT(NetPacket.value.l|NetPacket.value.b); SendNetXCmdForPlayer(0, XD_TEAMCHANGE, &usvalue, sizeof(usvalue)); } @@ -3325,14 +3413,27 @@ static void Command_Teamchange2_f(void) if (COM_Argc() <= 1) { - if (G_GametypeHasSpectators()) + if (G_GametypeHasTeams()) + CONS_Printf(M_GetText("changeteam2 : switch to a new team (%s)\n"), "red, blue or spectator"); + else if (G_GametypeHasSpectators()) CONS_Printf(M_GetText("changeteam2 : switch to a new team (%s)\n"), "spectator or playing"); else CONS_Alert(CONS_NOTICE, M_GetText("This command cannot be used in this gametype.\n")); return; } - if (G_GametypeHasSpectators()) + if (G_GametypeHasTeams()) + { + if (!strcasecmp(COM_Argv(1), "red") || !strcasecmp(COM_Argv(1), "1")) + NetPacket.packet.newteam = 1; + else if (!strcasecmp(COM_Argv(1), "blue") || !strcasecmp(COM_Argv(1), "2")) + NetPacket.packet.newteam = 2; + else if (!strcasecmp(COM_Argv(1), "spectator") || !strcasecmp(COM_Argv(1), "0")) + NetPacket.packet.newteam = 0; + else + error = true; + } + else if (G_GametypeHasSpectators()) { if (!strcasecmp(COM_Argv(1), "spectator") || !strcasecmp(COM_Argv(1), "0")) NetPacket.packet.newteam = 0; @@ -3350,13 +3451,17 @@ static void Command_Teamchange2_f(void) if (error) { - if (G_GametypeHasSpectators()) + if (G_GametypeHasTeams()) + CONS_Printf(M_GetText("changeteam2 : switch to a new team (%s)\n"), "red, blue or spectator"); + else if (G_GametypeHasSpectators()) CONS_Printf(M_GetText("changeteam2 : switch to a new team (%s)\n"), "spectator or playing"); return; } if (players[displayplayers[1]].spectator) error = !(NetPacket.packet.newteam || (players[displayplayers[1]].pflags & PF_WANTSTOJOIN)); + else if (G_GametypeHasTeams()) + error = (NetPacket.packet.newteam == (unsigned)players[displayplayers[1]].ctfteam); else if (G_GametypeHasSpectators() && !players[displayplayers[1]].spectator) error = (NetPacket.packet.newteam == 3); #ifdef PARANOIA @@ -3376,6 +3481,13 @@ static void Command_Teamchange2_f(void) return; } + //additional check for hide and seek. Don't allow change of status after hidetime ends. + if (gametype == GT_HIDEANDSEEK && leveltime >= (hidetime * TICRATE)) + { + CONS_Alert(CONS_NOTICE, M_GetText("Hiding time expired; no Hide and Seek status changes allowed!\n")); + return; + } + usvalue = SHORT(NetPacket.value.l|NetPacket.value.b); SendNetXCmdForPlayer(1, XD_TEAMCHANGE, &usvalue, sizeof(usvalue)); } @@ -3392,14 +3504,27 @@ static void Command_Teamchange3_f(void) if (COM_Argc() <= 1) { - if (G_GametypeHasSpectators()) + if (G_GametypeHasTeams()) + CONS_Printf(M_GetText("changeteam3 : switch to a new team (%s)\n"), "red, blue or spectator"); + else if (G_GametypeHasSpectators()) CONS_Printf(M_GetText("changeteam3 : switch to a new team (%s)\n"), "spectator or playing"); else CONS_Alert(CONS_NOTICE, M_GetText("This command cannot be used in this gametype.\n")); return; } - if (G_GametypeHasSpectators()) + if (G_GametypeHasTeams()) + { + if (!strcasecmp(COM_Argv(1), "red") || !strcasecmp(COM_Argv(1), "1")) + NetPacket.packet.newteam = 1; + else if (!strcasecmp(COM_Argv(1), "blue") || !strcasecmp(COM_Argv(1), "2")) + NetPacket.packet.newteam = 2; + else if (!strcasecmp(COM_Argv(1), "spectator") || !strcasecmp(COM_Argv(1), "0")) + NetPacket.packet.newteam = 0; + else + error = true; + } + else if (G_GametypeHasSpectators()) { if (!strcasecmp(COM_Argv(1), "spectator") || !strcasecmp(COM_Argv(1), "0")) NetPacket.packet.newteam = 0; @@ -3417,13 +3542,17 @@ static void Command_Teamchange3_f(void) if (error) { - if (G_GametypeHasSpectators()) + if (G_GametypeHasTeams()) + CONS_Printf(M_GetText("changeteam3 : switch to a new team (%s)\n"), "red, blue or spectator"); + else if (G_GametypeHasSpectators()) CONS_Printf(M_GetText("changeteam3 : switch to a new team (%s)\n"), "spectator or playing"); return; } if (players[displayplayers[2]].spectator) error = !(NetPacket.packet.newteam || (players[displayplayers[2]].pflags & PF_WANTSTOJOIN)); + else if (G_GametypeHasTeams()) + error = (NetPacket.packet.newteam == (unsigned)players[displayplayers[2]].ctfteam); else if (G_GametypeHasSpectators() && !players[displayplayers[2]].spectator) error = (NetPacket.packet.newteam == 3); #ifdef PARANOIA @@ -3443,6 +3572,13 @@ static void Command_Teamchange3_f(void) return; } + //additional check for hide and seek. Don't allow change of status after hidetime ends. + if (gametype == GT_HIDEANDSEEK && leveltime >= (hidetime * TICRATE)) + { + CONS_Alert(CONS_NOTICE, M_GetText("Hiding time expired; no Hide and Seek status changes allowed!\n")); + return; + } + usvalue = SHORT(NetPacket.value.l|NetPacket.value.b); SendNetXCmdForPlayer(2, XD_TEAMCHANGE, &usvalue, sizeof(usvalue)); } @@ -3459,14 +3595,27 @@ static void Command_Teamchange4_f(void) if (COM_Argc() <= 1) { - if (G_GametypeHasSpectators()) + if (G_GametypeHasTeams()) + CONS_Printf(M_GetText("changeteam4 : switch to a new team (%s)\n"), "red, blue or spectator"); + else if (G_GametypeHasSpectators()) CONS_Printf(M_GetText("changeteam4 : switch to a new team (%s)\n"), "spectator or playing"); else CONS_Alert(CONS_NOTICE, M_GetText("This command cannot be used in this gametype.\n")); return; } - if (G_GametypeHasSpectators()) + if (G_GametypeHasTeams()) + { + if (!strcasecmp(COM_Argv(1), "red") || !strcasecmp(COM_Argv(1), "1")) + NetPacket.packet.newteam = 1; + else if (!strcasecmp(COM_Argv(1), "blue") || !strcasecmp(COM_Argv(1), "2")) + NetPacket.packet.newteam = 2; + else if (!strcasecmp(COM_Argv(1), "spectator") || !strcasecmp(COM_Argv(1), "0")) + NetPacket.packet.newteam = 0; + else + error = true; + } + else if (G_GametypeHasSpectators()) { if (!strcasecmp(COM_Argv(1), "spectator") || !strcasecmp(COM_Argv(1), "0")) NetPacket.packet.newteam = 0; @@ -3484,13 +3633,17 @@ static void Command_Teamchange4_f(void) if (error) { - if (G_GametypeHasSpectators()) + if (G_GametypeHasTeams()) + CONS_Printf(M_GetText("changeteam4 : switch to a new team (%s)\n"), "red, blue or spectator"); + else if (G_GametypeHasSpectators()) CONS_Printf(M_GetText("changeteam4 : switch to a new team (%s)\n"), "spectator or playing"); return; } if (players[displayplayers[3]].spectator) error = !(NetPacket.packet.newteam || (players[displayplayers[3]].pflags & PF_WANTSTOJOIN)); + else if (G_GametypeHasTeams()) + error = (NetPacket.packet.newteam == (unsigned)players[displayplayers[3]].ctfteam); else if (G_GametypeHasSpectators() && !players[displayplayers[3]].spectator) error = (NetPacket.packet.newteam == 3); #ifdef PARANOIA @@ -3510,6 +3663,13 @@ static void Command_Teamchange4_f(void) return; } + //additional check for hide and seek. Don't allow change of status after hidetime ends. + if (gametype == GT_HIDEANDSEEK && leveltime >= (hidetime * TICRATE)) + { + CONS_Alert(CONS_NOTICE, M_GetText("Hiding time expired; no Hide and Seek status changes allowed!\n")); + return; + } + usvalue = SHORT(NetPacket.value.l|NetPacket.value.b); SendNetXCmdForPlayer(3, XD_TEAMCHANGE, &usvalue, sizeof(usvalue)); } @@ -3532,14 +3692,42 @@ static void Command_ServerTeamChange_f(void) if (COM_Argc() < 3) { - if (G_GametypeHasSpectators()) + if (G_TagGametype()) + CONS_Printf(M_GetText("serverchangeteam : switch player to a new team (%s)\n"), "it, notit, playing, or spectator"); + else if (G_GametypeHasTeams()) + CONS_Printf(M_GetText("serverchangeteam : switch player to a new team (%s)\n"), "red, blue or spectator"); + else if (G_GametypeHasSpectators()) CONS_Printf(M_GetText("serverchangeteam : switch player to a new team (%s)\n"), "spectator or playing"); else CONS_Alert(CONS_NOTICE, M_GetText("This command cannot be used in this gametype.\n")); return; } - if (G_GametypeHasSpectators()) + if (G_TagGametype()) + { + if (!strcasecmp(COM_Argv(2), "it") || !strcasecmp(COM_Argv(2), "1")) + NetPacket.packet.newteam = 1; + else if (!strcasecmp(COM_Argv(2), "notit") || !strcasecmp(COM_Argv(2), "2")) + NetPacket.packet.newteam = 2; + else if (!strcasecmp(COM_Argv(2), "playing") || !strcasecmp(COM_Argv(2), "3")) + NetPacket.packet.newteam = 3; + else if (!strcasecmp(COM_Argv(2), "spectator") || !strcasecmp(COM_Argv(2), "0")) + NetPacket.packet.newteam = 0; + else + error = true; + } + else if (G_GametypeHasTeams()) + { + if (!strcasecmp(COM_Argv(2), "red") || !strcasecmp(COM_Argv(2), "1")) + NetPacket.packet.newteam = 1; + else if (!strcasecmp(COM_Argv(2), "blue") || !strcasecmp(COM_Argv(2), "2")) + NetPacket.packet.newteam = 2; + else if (!strcasecmp(COM_Argv(2), "spectator") || !strcasecmp(COM_Argv(2), "0")) + NetPacket.packet.newteam = 0; + else + error = true; + } + else if (G_GametypeHasSpectators()) { if (!strcasecmp(COM_Argv(2), "spectator") || !strcasecmp(COM_Argv(2), "0")) NetPacket.packet.newteam = 0; @@ -3556,7 +3744,11 @@ static void Command_ServerTeamChange_f(void) if (error) { - if (G_GametypeHasSpectators()) + if (G_TagGametype()) + CONS_Printf(M_GetText("serverchangeteam : switch player to a new team (%s)\n"), "it, notit, playing, or spectator"); + else if (G_GametypeHasTeams()) + CONS_Printf(M_GetText("serverchangeteam : switch player to a new team (%s)\n"), "red, blue or spectator"); + else if (G_GametypeHasSpectators()) CONS_Printf(M_GetText("serverchangeteam : switch player to a new team (%s)\n"), "spectator or playing"); return; } @@ -3569,7 +3761,21 @@ static void Command_ServerTeamChange_f(void) return; } - if (G_GametypeHasSpectators()) + if (G_TagGametype()) + { + if (( (players[NetPacket.packet.playernum].pflags & PF_TAGIT) && NetPacket.packet.newteam == 1) || + (!(players[NetPacket.packet.playernum].pflags & PF_TAGIT) && NetPacket.packet.newteam == 2) || + ( players[NetPacket.packet.playernum].spectator && !NetPacket.packet.newteam) || + (!players[NetPacket.packet.playernum].spectator && NetPacket.packet.newteam == 3)) + error = true; + } + else if (G_GametypeHasTeams()) + { + if (NetPacket.packet.newteam == (unsigned)players[NetPacket.packet.playernum].ctfteam || + (players[NetPacket.packet.playernum].spectator && !NetPacket.packet.newteam)) + error = true; + } + else if (G_GametypeHasSpectators()) { if ((players[NetPacket.packet.playernum].spectator && !NetPacket.packet.newteam) || (!players[NetPacket.packet.playernum].spectator && NetPacket.packet.newteam == 3)) @@ -3586,6 +3792,13 @@ static void Command_ServerTeamChange_f(void) return; } + //additional check for hide and seek. Don't allow change of status after hidetime ends. + if (gametype == GT_HIDEANDSEEK && leveltime >= (hidetime * TICRATE)) + { + CONS_Alert(CONS_NOTICE, M_GetText("Hiding time expired; no Hide and Seek status changes allowed!\n")); + return; + } + NetPacket.packet.verification = true; // This signals that it's a server change usvalue = SHORT(NetPacket.value.l|NetPacket.value.b); @@ -3599,7 +3812,7 @@ static void Got_Teamchange(UINT8 **cp, INT32 playernum) boolean error = false, wasspectator = false; NetPacket.value.l = NetPacket.value.b = READINT16(*cp); - if (!G_GametypeHasSpectators()) //Make sure you're in the right gametype. + if (!G_GametypeHasTeams() && !G_GametypeHasSpectators()) //Make sure you're in the right gametype. { // this should never happen unless the client is hacked/buggy CONS_Alert(CONS_WARNING, M_GetText("Illegal team change received from player %s\n"), player_names[playernum]); @@ -3634,6 +3847,18 @@ static void Got_Teamchange(UINT8 **cp, INT32 playernum) // Prevent multiple changes in one go. if (players[playernum].spectator && !(players[playernum].pflags & PF_WANTSTOJOIN) && !NetPacket.packet.newteam) return; + else if (G_TagGametype()) + { + if (((players[playernum].pflags & PF_TAGIT) && NetPacket.packet.newteam == 1) || + (!(players[playernum].pflags & PF_TAGIT) && NetPacket.packet.newteam == 2) || + (!players[playernum].spectator && NetPacket.packet.newteam == 3)) + return; + } + else if (G_GametypeHasTeams()) + { + if (NetPacket.packet.newteam && (NetPacket.packet.newteam == (unsigned)players[playernum].ctfteam)) + return; + } else if (G_GametypeHasSpectators()) { if (!players[playernum].spectator && NetPacket.packet.newteam == 3) @@ -3656,16 +3881,45 @@ static void Got_Teamchange(UINT8 **cp, INT32 playernum) return; } + //Make sure that the right team number is sent. Keep in mind that normal clients cannot change to certain teams in certain gametypes. + switch (gametype) + { + case GT_HIDEANDSEEK: + //no status changes after hidetime + if (leveltime >= (hidetime * TICRATE)) + { + error = true; + break; + } + /* FALLTHRU */ + case GT_TAG: + switch (NetPacket.packet.newteam) + { + case 0: + break; + case 1: case 2: + if (!NetPacket.packet.verification) + error = true; //Only admin can change player's IT status' in tag. + break; + case 3: //Join game via console. + if (!NetPacket.packet.verification && !cv_allowteamchange.value) + error = true; + break; + } + + break; + default: #ifdef PARANOIA - if (!G_GametypeHasSpectators()) - I_Error("Invalid gametype after initial checks!"); + if (!G_GametypeHasTeams() && !G_GametypeHasSpectators()) + I_Error("Invalid gametype after initial checks!"); #endif - //Make sure that the right team number is sent. Keep in mind that normal clients cannot change to certain teams in certain gametypes. - if (!cv_allowteamchange.value) - { - if (!NetPacket.packet.verification && NetPacket.packet.newteam) - error = true; //Only admin can change status, unless changing to spectator. + if (!cv_allowteamchange.value) + { + if (!NetPacket.packet.verification && NetPacket.packet.newteam) + error = true; //Only admin can change status, unless changing to spectator. + } + break; //Otherwise, you don't need special permissions. } if (server && ((NetPacket.packet.newteam < 0 || NetPacket.packet.newteam > 3) || error)) @@ -3694,7 +3948,50 @@ static void Got_Teamchange(UINT8 **cp, INT32 playernum) //Now that we've done our error checking and killed the player //if necessary, put the player on the correct team/status. - if (G_GametypeHasSpectators()) + if (G_TagGametype()) + { + if (!NetPacket.packet.newteam) + { + players[playernum].spectator = true; + players[playernum].pflags &= ~PF_TAGIT; + players[playernum].pflags &= ~PF_TAGGED; + } + else if (NetPacket.packet.newteam != 3) // .newteam == 1 or 2. + { + players[playernum].pflags |= PF_WANTSTOJOIN; //players[playernum].spectator = false; + players[playernum].pflags &= ~PF_TAGGED;//Just in case. + + if (NetPacket.packet.newteam == 1) //Make the player IT. + players[playernum].pflags |= PF_TAGIT; + else + players[playernum].pflags &= ~PF_TAGIT; + } + else // Just join the game. + { + players[playernum].pflags |= PF_WANTSTOJOIN; //players[playernum].spectator = false; + + //If joining after hidetime in normal tag, default to being IT. + if (gametype == GT_TAG && (leveltime > (hidetime * TICRATE))) + { + NetPacket.packet.newteam = 1; //minor hack, causes the "is it" message to be printed later. + players[playernum].pflags |= PF_TAGIT; //make the player IT. + } + } + } + else if (G_GametypeHasTeams()) + { + if (!NetPacket.packet.newteam) + { + players[playernum].ctfteam = 0; + players[playernum].spectator = true; + } + else + { + players[playernum].ctfteam = NetPacket.packet.newteam; + players[playernum].pflags |= PF_WANTSTOJOIN; //players[playernum].spectator = false; + } + } + else if (G_GametypeHasSpectators()) { if (!NetPacket.packet.newteam) players[playernum].spectator = true; @@ -3718,11 +4015,17 @@ static void Got_Teamchange(UINT8 **cp, INT32 playernum) } else if (NetPacket.packet.newteam == 1) { - CONS_Printf(M_GetText("%s switched to the %c%s%c.\n"), player_names[playernum], '\x85', M_GetText("Red Team"), '\x80'); + if (G_TagGametype()) + CONS_Printf(M_GetText("%s is now IT!\n"), player_names[playernum]); + else + CONS_Printf(M_GetText("%s switched to the %c%s%c.\n"), player_names[playernum], '\x85', M_GetText("Red Team"), '\x80'); } else if (NetPacket.packet.newteam == 2) { - CONS_Printf(M_GetText("%s switched to the %c%s%c.\n"), player_names[playernum], '\x84', M_GetText("Blue Team"), '\x80'); + if (G_TagGametype()) + CONS_Printf(M_GetText("%s is no longer IT!\n"), player_names[playernum]); + else + CONS_Printf(M_GetText("%s switched to the %c%s%c.\n"), player_names[playernum], '\x84', M_GetText("Blue Team"), '\x80'); } else if (NetPacket.packet.newteam == 0 && !wasspectator) HU_AddChatText(va("\x82*%s became a spectator.", player_names[playernum]), false); // "entered the game" text was moved to P_SpectatorJoinGame @@ -3731,6 +4034,21 @@ static void Got_Teamchange(UINT8 **cp, INT32 playernum) if (playernum == consoleplayer || displayplayers[0] == playernum) displayplayers[0] = consoleplayer; + if (G_GametypeHasTeams()) + { + if (NetPacket.packet.newteam) + { + if (playernum == consoleplayer) //CTF and Team Match colors. + CV_SetValue(&cv_playercolor, NetPacket.packet.newteam + 5); + else if (playernum == displayplayers[1]) + CV_SetValue(&cv_playercolor2, NetPacket.packet.newteam + 5); + else if (playernum == displayplayers[2]) + CV_SetValue(&cv_playercolor3, NetPacket.packet.newteam + 5); + else if (playernum == displayplayers[3]) + CV_SetValue(&cv_playercolor4, NetPacket.packet.newteam + 5); + } + } + if (gamestate != GS_LEVEL) return; @@ -4604,6 +4922,151 @@ static void Command_ListWADS_f(void) } } +#define MAXDOOMEDNUM 4095 + +static void Command_ListDoomednums_f(void) +{ + INT16 i, j, k = 0, l = 0; + INT32 argc = COM_Argc(); + INT16 table[MAXDOOMEDNUM]; + + switch (argc) + { + case 1: + l = MAXDOOMEDNUM; + break; + case 3: + l = atoi(COM_Argv(2)); + if (l < 1 || l > MAXDOOMEDNUM) + { + CONS_Printf("arg 2: doomednum \x82""%d \x85out of range (1-4095)\n", k); + return; + } + //FALLTHRU + case 2: + k = atoi(COM_Argv(1)); + if (k < 1 || k > MAXDOOMEDNUM) + { + CONS_Printf("arg 1: doomednum \x82""%d \x85out of range (1-4095)\n", k); + return; + } + if (!l) + l = k; + else if (l < k) // silently and helpfully swap. + { + j = k; + k = l; + l = j; + } + break; + default: + CONS_Printf("listmapthings: \x86too many arguments!\n"); + return; + } + + // see P_SpawnNonMobjMapThing + memset(table, 0, sizeof(table)); + for (i = 1; i <= MAXPLAYERS; i++) + table[i-1] = MT_PLAYER; // playerstarts + table[33-1] = table[34-1] = table[35-1] = MT_PLAYER; // battle/team starts + table[750-1] = table[777-1] = table[778-1] = MT_UNKNOWN; // slopes + for (i = 600; i <= 609; i++) + table[i-1] = MT_RING; // placement patterns + table[1705-1] = table[1713-1] = MT_HOOP; // types of hoop + + CONS_Printf("\x82""Checking for double defines...\n"); + for (i = 1; i < MT_FIRSTFREESLOT+NUMMOBJFREESLOTS; i++) + { + j = mobjinfo[i].doomednum; + if (j < (k ? k : 1) || j > (l ? l : MAXDOOMEDNUM)) + continue; + if (table[j-1]) + { + CONS_Printf(" doomednum \x82""%d""\x80 is \x85""double-defined\x80 by ", j); + if (i < MT_FIRSTFREESLOT) + { + CONS_Printf("\x87""hardcode %s <-- MAJOR ERROR\n", MOBJTYPE_LIST[i]); + continue; + } + CONS_Printf("\x81""freeslot MT_""%s\n", FREE_MOBJS[i-MT_FIRSTFREESLOT]); + continue; + } + table[j-1] = i; + } + CONS_Printf("\x82Printing doomednum usage...\n"); + if (!k) + { + i = 35; // skip MT_PLAYER spam + CONS_Printf(" doomednums \x82""1-35""\x80 are used by ""\x87""hardcode MT_PLAYER\n"); + } + else + i = k-1; + + for (; i < l; i++) + { + if (!table[i]) + { + if (k) + { + CONS_Printf(" doomednum \x82""%d""\x80 is \x83""free!", i+1); + if (i < 99) // above the humble crawla? how dare you + CONS_Printf(" (Don't freeslot this low...)"); + CONS_Printf("\n"); + } + continue; + } + CONS_Printf(" doomednum \x82""%d""\x80 is used by ", i+1); + if (table[i] < MT_FIRSTFREESLOT) + { + CONS_Printf("\x87""hardcode %s\n", MOBJTYPE_LIST[table[i]]); + continue; + } + CONS_Printf("\x81""freeslot MT_""%s\n", FREE_MOBJS[table[i]-MT_FIRSTFREESLOT]); + } +} + +#undef MAXDOOMEDNUM + +void Command_ListUnusedSprites_f(void) +{ + size_t i, j; + + CONS_Printf("\x82Printing sprite non-usage...\n"); + + for (i = 0; i < NUMSPRITES; i++) + { + if (sprites[i].numframes) + { + // We're only showing unused sprites... + continue; + } + + if (i < SPR_FIRSTFREESLOT) + { + CONS_Printf(" \x87""hardcode SPR_""%.4s\n", sprnames[i]); + continue; + } + + if (used_spr[(i-SPR_FIRSTFREESLOT)/8] == 0xFF) + { + for (j = 0; j < 8; j++) + { + CONS_Printf(" \x81""freeslot SPR_""%.4s\n", sprnames[i+j]); + } + + i += j; + } + + if (used_spr[(i-SPR_FIRSTFREESLOT)/8] & (1<<(i%8))) + { + CONS_Printf(" \x81""freeslot SPR_""%.4s\n", sprnames[i]); + continue; + } + + break; + } +} + // ========================================================================= // MISC. COMMANDS // ========================================================================= @@ -4750,7 +5213,7 @@ static void PointLimit_OnChange(void) if (cv_pointlimit.value) { CONS_Printf(M_GetText("Levels will end after %s scores %d point%s.\n"), - M_GetText("someone"), + G_GametypeHasTeams() ? M_GetText("a team") : M_GetText("someone"), cv_pointlimit.value, cv_pointlimit.value > 1 ? "s" : ""); } @@ -4805,7 +5268,11 @@ static void TimeLimit_OnChange(void) if (cv_timelimit.value != 0) { CONS_Printf(M_GetText("Levels will end after %d minute%s.\n"),cv_timelimit.value,cv_timelimit.value == 1 ? "" : "s"); // Graue 11-17-2003 - timelimitintics = cv_timelimit.value * 60 * TICRATE;; + timelimitintics = cv_timelimit.value * 60 * TICRATE; + + //add hidetime for tag too! + if (G_TagGametype()) + timelimitintics += hidetime * TICRATE; // Note the deliberate absence of any code preventing // pointlimit and timelimit from being set simultaneously. @@ -4844,19 +5311,46 @@ void D_GameTypeChanged(INT32 lastgametype) // There will always be a server, and this only needs to be done once. if (server && (multiplayer || netgame)) { - if (!cv_itemrespawn.changed) + if (gametype == GT_COMPETITION || gametype == GT_COOP) + CV_SetValue(&cv_itemrespawn, 0); + else if (!cv_itemrespawn.changed) CV_SetValue(&cv_itemrespawn, 1); - if (gametype == GT_MATCH) + switch (gametype) { - if (!cv_timelimit.changed && !cv_pointlimit.changed) // user hasn't changed limits - { - // default settings for match: no timelimit, no pointlimit - CV_SetValue(&cv_pointlimit, 0); - CV_SetValue(&cv_timelimit, 0); - } - if (!cv_itemrespawntime.changed) - CV_Set(&cv_itemrespawntime, cv_itemrespawntime.defaultvalue); // respawn normally + case GT_MATCH: + case GT_TEAMMATCH: + if (!cv_timelimit.changed && !cv_pointlimit.changed) // user hasn't changed limits + { + // default settings for match: no timelimit, no pointlimit + CV_SetValue(&cv_pointlimit, 0); + CV_SetValue(&cv_timelimit, 0); + } + if (!cv_itemrespawntime.changed) + CV_Set(&cv_itemrespawntime, cv_itemrespawntime.defaultvalue); // respawn normally + break; + case GT_TAG: + case GT_HIDEANDSEEK: + if (!cv_timelimit.changed && !cv_pointlimit.changed) // user hasn't changed limits + { + // default settings for tag: 5 mins, no pointlimit + // Note that tag mode also uses an alternate timing mechanism in tandem with timelimit. + CV_SetValue(&cv_timelimit, 5); + CV_SetValue(&cv_pointlimit, 0); + } + if (!cv_itemrespawntime.changed) + CV_Set(&cv_itemrespawntime, cv_itemrespawntime.defaultvalue); // respawn normally + break; + case GT_CTF: + if (!cv_timelimit.changed && !cv_pointlimit.changed) // user hasn't changed limits + { + // default settings for CTF: no timelimit, pointlimit 5 + CV_SetValue(&cv_timelimit, 0); + CV_SetValue(&cv_pointlimit, 5); + } + if (!cv_itemrespawntime.changed) + CV_Set(&cv_itemrespawntime, cv_itemrespawntime.defaultvalue); // respawn normally + break; } } else if (!multiplayer && !netgame) @@ -4874,6 +5368,29 @@ void D_GameTypeChanged(INT32 lastgametype) if (cv_pointlimit.value) CV_SetValue(&cv_pointlimit, 0); } + else if ((cv_pointlimit.changed || cv_timelimit.changed) && cv_pointlimit.value) + { + if (lastgametype != GT_CTF && gametype == GT_CTF) + CV_SetValue(&cv_pointlimit, cv_pointlimit.value / 500); + else if (lastgametype == GT_CTF && gametype != GT_CTF) + CV_SetValue(&cv_pointlimit, cv_pointlimit.value * 500); + } + } + + // don't retain teams in other modes or between changes from ctf to team match. + // also, stop any and all forms of team scrambling that might otherwise take place. + if (G_GametypeHasTeams()) + { + INT32 i; + for (i = 0; i < MAXPLAYERS; i++) + if (playeringame[i]) + players[i].ctfteam = 0; + + if (server || (IsPlayerAdmin(consoleplayer))) + { + CV_StealthSetValue(&cv_teamscramble, 0); + teamscramble = 0; + } } } @@ -4937,6 +5454,14 @@ static void AutoBalance_OnChange(void) static void TeamScramble_OnChange(void) { + INT16 i = 0, j = 0, playercount = 0; + boolean repick = true; + INT32 blue = 0, red = 0; + INT32 maxcomposition = 0; + INT16 newteam = 0; + INT32 retries = 0; + boolean success = false; + // Don't trigger outside level or intermission! if (!(gamestate == GS_LEVEL || gamestate == GS_INTERMISSION || gamestate == GS_VOTING)) return; @@ -4944,17 +5469,152 @@ static void TeamScramble_OnChange(void) if (!cv_teamscramble.value) teamscramble = 0; - if (server || IsPlayerAdmin(consoleplayer)) + if (!G_GametypeHasTeams() && (server || IsPlayerAdmin(consoleplayer))) { CONS_Alert(CONS_NOTICE, M_GetText("This command cannot be used in this gametype.\n")); CV_StealthSetValue(&cv_teamscramble, 0); return; } + + // If a team scramble is already in progress, do not allow another one to be started! + if (teamscramble) + return; + +retryscramble: + + // Clear related global variables. These will get used again in p_tick.c/y_inter.c as the teams are scrambled. + memset(&scrambleplayers, 0, sizeof(scrambleplayers)); + memset(&scrambleteams, 0, sizeof(scrambleplayers)); + scrambletotal = scramblecount = 0; + blue = red = maxcomposition = newteam = playercount = 0; + repick = true; + + // Put each player's node in the array. + for (i = 0; i < MAXPLAYERS; i++) + { + if (playeringame[i] && !players[i].spectator) + { + scrambleplayers[playercount] = i; + playercount++; + } + } + + if (playercount < 2) + { + CV_StealthSetValue(&cv_teamscramble, 0); + return; // Don't scramble one or zero players. + } + + // Randomly place players on teams. + if (cv_teamscramble.value == 1) + { + maxcomposition = playercount / 2; + + // Now randomly assign players to teams. + // If the teams get out of hand, assign the rest to the other team. + for (i = 0; i < playercount; i++) + { + if (repick) + newteam = (INT16)((M_RandomByte() % 2) + 1); + + // One team has the most players they can get, assign the rest to the other team. + if (red == maxcomposition || blue == maxcomposition) + { + if (red == maxcomposition) + newteam = 2; + else if (blue == maxcomposition) + newteam = 1; + + repick = false; + } + + scrambleteams[i] = newteam; + + if (newteam == 1) + red++; + else + blue++; + } + } + else if (cv_teamscramble.value == 2) // Same as before, except split teams based on current score. + { + // Now, sort the array based on points scored. + for (i = 1; i < playercount; i++) + { + for (j = i; j < playercount; j++) + { + INT16 tempplayer = 0; + + if ((players[scrambleplayers[i-1]].score > players[scrambleplayers[j]].score)) + { + tempplayer = scrambleplayers[i-1]; + scrambleplayers[i-1] = scrambleplayers[j]; + scrambleplayers[j] = tempplayer; + } + } + } + + // Now assign players to teams based on score. Scramble in pairs. + // If there is an odd number, one team will end up with the unlucky slob who has no points. =( + for (i = 0; i < playercount; i++) + { + if (repick) + { + newteam = (INT16)((M_RandomByte() % 2) + 1); + repick = false; + } + else + { + // We will only randomly pick the team for the first guy. + // Otherwise, just alternate back and forth, distributing players. + if (newteam == 1) + newteam = 2; + else + newteam = 1; + } + + scrambleteams[i] = newteam; + } + } + + // Check to see if our random selection actually + // changed anybody. If not, we run through and try again. + for (i = 0; i < playercount; i++) + { + if (players[scrambleplayers[i]].ctfteam != scrambleteams[i]) + success = true; + } + + if (!success && retries < 5) + { + retries++; + goto retryscramble; //try again + } + + // Display a witty message, but only during scrambles specifically triggered by an admin. + if (cv_teamscramble.value) + { + scrambletotal = playercount; + teamscramble = (INT16)cv_teamscramble.value; + + if (!(gamestate == GS_INTERMISSION && cv_scrambleonchange.value)) + CONS_Printf(M_GetText("Teams will be scrambled next round.\n")); + } } static void Hidetime_OnChange(void) { + if (Playing() && G_TagGametype() && leveltime >= (hidetime * TICRATE)) + { + // Don't allow hidetime changes after it expires. + CV_StealthSetValue(&cv_hidetime, hidetime); + return; + } hidetime = cv_hidetime.value; + + //uh oh, gotta change timelimitintics now too + if (G_TagGametype()) + timelimitintics = (cv_timelimit.value * 60 * TICRATE) + (hidetime * TICRATE); } static void Command_Showmap_f(void) @@ -4996,7 +5656,7 @@ static void Command_Mapmd5_f(void) static void Command_ExitLevel_f(void) { - if (!(netgame || multiplayer) && !cv_debug) + if (!(netgame || (multiplayer && gametype != GT_COOP)) && !cv_debug) CONS_Printf(M_GetText("This only works in a netgame.\n")); else if (!(server || (IsPlayerAdmin(consoleplayer)))) CONS_Printf(M_GetText("Only the server or a remote admin can use this.\n")); diff --git a/src/dehacked.c b/src/dehacked.c index 85d3fe319..e4b4028ef 100644 --- a/src/dehacked.c +++ b/src/dehacked.c @@ -14,7 +14,6 @@ #include "d_main.h" // for srb2home #include "g_game.h" #include "sounds.h" -#include "info.h" #include "d_think.h" #include "m_argv.h" #include "z_zone.h" @@ -33,12 +32,12 @@ #include "r_sky.h" #include "r_draw.h" // translation colormap consts (for lua) #include "fastcmp.h" -#include "lua_script.h" -#include "lua_glib.h" -#include "lua_hook.h" + #include "d_clisrv.h" #include "v_video.h" // video flags (for lua) +#include "lua_glib.h" +#include "lua_hook.h" #include "lua_script.h" #include "lua_libs.h" @@ -48,13 +47,14 @@ // Free slot names // The crazy word-reading stuff uses these. -static char *FREE_STATES[NUMSTATEFREESLOTS]; -static char *FREE_MOBJS[NUMMOBJFREESLOTS]; -static UINT8 used_spr[(NUMSPRITEFREESLOTS / 8) + 1]; // Bitwise flag for sprite freeslot in use! I would use ceil() here if I could, but it only saves 1 byte of memory anyway. +char *FREE_STATES[NUMSTATEFREESLOTS]; +char *FREE_MOBJS[NUMMOBJFREESLOTS]; +UINT8 used_spr[(NUMSPRITEFREESLOTS / 8) + 1]; // Bitwise flag for sprite freeslot in use! I would use ceil() here if I could, but it only saves 1 byte of memory anyway. + #define initfreeslots() {\ -memset(FREE_STATES,0,sizeof(char *) * NUMSTATEFREESLOTS);\ -memset(FREE_MOBJS,0,sizeof(char *) * NUMMOBJFREESLOTS);\ -memset(used_spr,0,sizeof(UINT8) * ((NUMSPRITEFREESLOTS / 8) + 1));\ + memset(FREE_STATES,0,sizeof(char *) * NUMSTATEFREESLOTS);\ + memset(FREE_MOBJS,0,sizeof(char *) * NUMMOBJFREESLOTS);\ + memset(used_spr,0,sizeof(UINT8) * ((NUMSPRITEFREESLOTS / 8) + 1));\ } // Crazy word-reading stuff @@ -257,6 +257,8 @@ static void clear_levels(void) // Custom map header info // (no need to set num to 0, we're freeing the entire header shortly) Z_Free(mapheaderinfo[i]->customopts); + + P_DeleteGrades(i); Z_Free(mapheaderinfo[i]); mapheaderinfo[i] = NULL; } @@ -800,8 +802,22 @@ static void readlevelheader(MYFILE *f, INT32 num, INT32 wadnum) // Now go to uppercase strupr(word2); + // NiGHTS grades + if (fastncmp(word, "GRADES", 6)) + { + UINT8 mare = (UINT8)atoi(word + 6); + + if (mare <= 0 || mare > 8) + { + deh_warning("Level header %d: unknown word '%s'", num, word); + continue; + } + + P_AddGradesForMare((INT16)(num-1), mare-1, word2); + } + // Strings that can be truncated - if (fastcmp(word, "SCRIPTNAME")) + else if (fastcmp(word, "SCRIPTNAME")) { deh_strlcpy(mapheaderinfo[num-1]->scriptname, word2, sizeof(mapheaderinfo[num-1]->scriptname), va("Level header %d: scriptname", num)); @@ -3131,7 +3147,7 @@ void DEH_LoadDehackedLump(lumpnum_t lumpnum) // RegEx to generate this from info.h: ^\tS_([^,]+), --> \t"S_\1", // I am leaving the prefixes solely for clarity to programmers, // because sadly no one remembers this place while searching for full state names. -static const char *const STATE_LIST[] = { // array length left dynamic for sanity testing later. +const char *const STATE_LIST[] = { // array length left dynamic for sanity testing later. "S_NULL", "S_UNKNOWN", "S_INVISIBLE", // state for invisible sprite @@ -6345,7 +6361,7 @@ static const char *const STATE_LIST[] = { // array length left dynamic for sanit // RegEx to generate this from info.h: ^\tMT_([^,]+), --> \t"MT_\1", // I am leaving the prefixes solely for clarity to programmers, // because sadly no one remembers this place while searching for full state names. -static const char *const MOBJTYPE_LIST[] = { // array length left dynamic for sanity testing later. +const char *const MOBJTYPE_LIST[] = { // array length left dynamic for sanity testing later. "MT_NULL", "MT_UNKNOWN", @@ -7136,7 +7152,7 @@ static const char *const MOBJTYPE_LIST[] = { // array length left dynamic for s #endif }; -static const char *const MOBJFLAG_LIST[] = { +const char *const MOBJFLAG_LIST[] = { "SPECIAL", "SOLID", "SHOOTABLE", @@ -7172,7 +7188,7 @@ static const char *const MOBJFLAG_LIST[] = { }; // \tMF2_(\S+).*// (.+) --> \t"\1", // \2 -static const char *const MOBJFLAG2_LIST[] = { +const char *const MOBJFLAG2_LIST[] = { "AXIS", // It's a NiGHTS axis! (For faster checking) "TWOD", // Moves like it's in a 2D level "DONTRESPAWN", // Don't respawn this object! @@ -7205,7 +7221,7 @@ static const char *const MOBJFLAG2_LIST[] = { NULL }; -static const char *const MOBJEFLAG_LIST[] = { +const char *const MOBJEFLAG_LIST[] = { "ONGROUND", // The mobj stands on solid floor (not on another mobj or in air) "JUSTHITFLOOR", // The mobj just hit the floor while falling, this is cleared on next frame "TOUCHWATER", // The mobj stands in a sector with water, and touches the surface @@ -7223,14 +7239,14 @@ static const char *const MOBJEFLAG_LIST[] = { NULL }; -static const char *const MAPTHINGFLAG_LIST[4] = { +const char *const MAPTHINGFLAG_LIST[4] = { NULL, "OBJECTFLIP", // Reverse gravity flag for objects. "OBJECTSPECIAL", // Special flag used with certain objects. "AMBUSH" // Deaf monsters/do not react to sound. }; -static const char *const PLAYERFLAG_LIST[] = { +const char *const PLAYERFLAG_LIST[] = { // Flip camera angle with gravity flip prefrence. "FLIPCAM", @@ -7302,7 +7318,7 @@ static const char *const PLAYERFLAG_LIST[] = { }; // Linedef flags -static const char *const ML_LIST[16] = { +const char *const ML_LIST[16] = { "IMPASSIBLE", "BLOCKMONSTERS", "TWOSIDED", @@ -7323,7 +7339,7 @@ static const char *const ML_LIST[16] = { // This DOES differ from r_draw's Color_Names, unfortunately. // Also includes Super colors -static const char *COLOR_ENUMS[] = { // Rejigged for Kart. +const char *COLOR_ENUMS[] = { // Rejigged for Kart. "NONE", // SKINCOLOR_NONE "WHITE", // SKINCOLOR_WHITE "SILVER", // SKINCOLOR_SILVER @@ -7491,7 +7507,7 @@ static const char *COLOR_ENUMS[] = { // Rejigged for Kart. "CSUPER5" // SKINCOLOR_CSUPER5, }; -static const char *const POWERS_LIST[] = { +const char *const POWERS_LIST[] = { "INVULNERABILITY", "SNEAKERS", "FLASHING", @@ -7526,7 +7542,7 @@ static const char *const POWERS_LIST[] = { "INGOOP" // In goop }; -static const char *const KARTSTUFF_LIST[] = { +const char *const KARTSTUFF_LIST[] = { "POSITION", "OLDPOSITION", "POSITIONDELAY", @@ -7613,7 +7629,7 @@ static const char *const KARTSTUFF_LIST[] = { "GROWCANCEL" }; -static const char *const HUDITEMS_LIST[] = { +const char *const HUDITEMS_LIST[] = { "LIVESNAME", "LIVESPIC", "LIVESNUM", @@ -8522,13 +8538,13 @@ static int lua_enumlib_basic_fallback(lua_State* L) static int lua_enumlib_mariomode_get(lua_State *L) { - lua_pushboolean(L, false); + lua_pushboolean(L, mariomode != 0); return 1; } static int lua_enumlib_twodlevel_get(lua_State *L) { - lua_pushboolean(L, false); + lua_pushboolean(L, twodlevel); return 1; } diff --git a/src/dehacked.h b/src/dehacked.h index 0d3778b28..eb22c5f6a 100644 --- a/src/dehacked.h +++ b/src/dehacked.h @@ -14,6 +14,26 @@ #define __DEHACKED_H__ #include "m_fixed.h" // for get_number +#include "info.h" + +// Free slot names +// The crazy word-reading stuff uses these. +extern char *FREE_STATES[NUMSTATEFREESLOTS]; +extern char *FREE_MOBJS[NUMMOBJFREESLOTS]; +extern UINT8 used_spr[(NUMSPRITEFREESLOTS / 8) + 1]; // Bitwise flag for sprite freeslot in use! I would use ceil() here if I could, but it only saves 1 byte of memory anyway. + +extern const char *const STATE_LIST[]; +extern const char *const MOBJTYPE_LIST[]; +extern const char *const MOBJFLAG_LIST[]; +extern const char *const MOBJFLAG2_LIST[]; // \tMF2_(\S+).*// (.+) --> \t"\1", // \2 +extern const char *const MOBJEFLAG_LIST[]; +extern const char *const MAPTHINGFLAG_LIST[4]; +extern const char *const PLAYERFLAG_LIST[]; +extern const char *const ML_LIST[]; // Linedef flags +extern const char *COLOR_ENUMS[]; +extern const char *const POWERS_LIST[]; +extern const char *const KARTSTUFF_LIST[]; +extern const char *const HUDITEMS_LIST[]; void DEH_LoadDehackedLump(lumpnum_t lumpnum); void DEH_LoadDehackedLumpPwad(UINT16 wad, UINT16 lump); diff --git a/src/doomstat.h b/src/doomstat.h index 524d507f7..f70f97059 100644 --- a/src/doomstat.h +++ b/src/doomstat.h @@ -323,6 +323,15 @@ enum GameType // SRB2Kart GT_RACE = 0, // also used in record attack GT_MATCH, // battle, but renaming would be silly NUMGAMETYPES, + + // TODO: This is *horrid*. Remove this hack ASAP. + // the following have been left in on account of just not wanting to deal with removing all the checks for them + GT_COOP, + GT_COMPETITION, + GT_TEAMMATCH, + GT_TAG, + GT_HIDEANDSEEK, + GT_CTF }; // If you alter this list, update dehacked.c, and Gametype_Names in g_game.c diff --git a/src/g_game.c b/src/g_game.c index 7e1c0e04c..6c45c99a4 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -2336,6 +2336,9 @@ void G_PlayerReborn(INT32 player) if (leveltime > (starttime + (TICRATE/2)) && !p->spectator) p->kartstuff[k_respawn] = 48; // Respawn effect + if (gametype == GT_COOP) + P_FindEmerald(); // scan for emeralds to hunt for + // Reset Nights score and max link to 0 on death p->maxlink = 0; @@ -2406,9 +2409,19 @@ void G_SpawnPlayer(INT32 playernum, boolean starpost) return; } + // -- CTF -- + // Order: CTF->DM->Coop + if (gametype == GT_CTF && players[playernum].ctfteam) + { + if (!(spawnpoint = G_FindCTFStart(playernum)) // find a CTF start + && !(spawnpoint = G_FindMatchStart(playernum))) // find a DM start + spawnpoint = G_FindRaceStart(playernum); // fallback + } + // -- DM/Tag/CTF-spectator/etc -- // Order: DM->CTF->Coop - if (gametype == GT_MATCH && !(players[playernum].pflags & PF_TAGIT)) + else if (gametype == GT_MATCH || gametype == GT_TEAMMATCH || gametype == GT_CTF + || ((gametype == GT_TAG || gametype == GT_HIDEANDSEEK) && !(players[playernum].pflags & PF_TAGIT))) { if (!(spawnpoint = G_FindMatchStart(playernum)) // find a DM start && !(spawnpoint = G_FindCTFStart(playernum))) // find a CTF start @@ -2722,6 +2735,14 @@ void G_ExitLevel(void) gameaction = ga_completed; lastdraw = true; + // If you want your teams scrambled on map change, start the process now. + // The teams will scramble at the start of the next round. + if (cv_scrambleonchange.value && G_GametypeHasTeams()) + { + if (server) + CV_SetValue(&cv_teamscramble, cv_scrambleonchange.value); + } + if (netgame || multiplayer) CON_LogMessage(M_GetText("The round has ended.\n")); @@ -2767,6 +2788,29 @@ boolean G_IsSpecialStage(INT32 mapnum) return false; } +// +// G_GametypeUsesLives +// +// Returns true if the current gametype uses +// the lives system. False otherwise. +// +boolean G_GametypeUsesLives(void) +{ + // SRB2kart NEEDS no lives + return false; +} + +// +// G_GametypeHasTeams +// +// Returns true if the current gametype uses +// Red/Blue teams. False otherwise. +// +boolean G_GametypeHasTeams(void) +{ + return (gametype == GT_TEAMMATCH || gametype == GT_CTF); +} + // // G_GametypeHasSpectators // @@ -2884,6 +2928,16 @@ boolean G_RaceGametype(void) return (gametype == GT_RACE); } +// +// G_TagGametype +// +// For Jazz's Tag/HnS modes that have a lot of special cases... +// SRB2Kart: do we actually want to add Kart tag later? :V +// +boolean G_TagGametype(void) +{ + return (gametype == GT_TAG || gametype == GT_HIDEANDSEEK); +} /** Get the typeoflevel flag needed to indicate support of a gametype. * In single-player, this always returns TOL_SP. @@ -2894,8 +2948,14 @@ boolean G_RaceGametype(void) INT16 G_TOLFlag(INT32 pgametype) { if (!multiplayer) return TOL_SP; + if (pgametype == GT_COOP) return TOL_RACE; // SRB2kart + if (pgametype == GT_COMPETITION) return TOL_COMPETITION; if (pgametype == GT_RACE) return TOL_RACE; if (pgametype == GT_MATCH) return TOL_MATCH; + if (pgametype == GT_TEAMMATCH) return TOL_MATCH; + if (pgametype == GT_TAG) return TOL_TAG; + if (pgametype == GT_HIDEANDSEEK) return TOL_TAG; + if (pgametype == GT_CTF) return TOL_CTF; CONS_Alert(CONS_ERROR, M_GetText("Unknown gametype! %d\n"), pgametype); return INT16_MAX; @@ -3174,15 +3234,42 @@ static void G_DoCompleted(void) if (nextmap >= 1100-1 && nextmap <= 1102-1 && G_RaceGametype()) nextmap = (INT16)(spstage_start-1); + if (gametype == GT_COOP && token) + { + token--; + gottoken = true; + + if (!(emeralds & EMERALD1)) + nextmap = (INT16)(sstage_start - 1); // Special Stage 1 + else if (!(emeralds & EMERALD2)) + nextmap = (INT16)(sstage_start); // Special Stage 2 + else if (!(emeralds & EMERALD3)) + nextmap = (INT16)(sstage_start + 1); // Special Stage 3 + else if (!(emeralds & EMERALD4)) + nextmap = (INT16)(sstage_start + 2); // Special Stage 4 + else if (!(emeralds & EMERALD5)) + nextmap = (INT16)(sstage_start + 3); // Special Stage 5 + else if (!(emeralds & EMERALD6)) + nextmap = (INT16)(sstage_start + 4); // Special Stage 6 + else if (!(emeralds & EMERALD7)) + nextmap = (INT16)(sstage_start + 5); // Special Stage 7 + else + gottoken = false; + } + if (G_IsSpecialStage(gamemap) && !gottoken) nextmap = lastmap; // Exiting from a special stage? Go back to the game. Tails 08-11-2001 automapactive = false; - if (cv_advancemap.value == 0) // Stay on same map. - nextmap = prevmap; - else if (cv_advancemap.value == 2) // Go to random map. - nextmap = G_RandMap(G_TOLFlag(gametype), prevmap, false, 0, false, NULL); + if (gametype != GT_COOP) + { + if (cv_advancemap.value == 0) // Stay on same map. + nextmap = prevmap; + else if (cv_advancemap.value == 2) // Go to random map. + nextmap = G_RandMap(G_TOLFlag(gametype), prevmap, false, 0, false, NULL); + } + // We are committed to this map now. // We may as well allocate its header if it doesn't exist @@ -3371,6 +3458,21 @@ void G_EndGame(void) else if (demo.recording) G_ResetDemoRecording(); + // Only do evaluation and credits in coop games. + if (gametype == GT_COOP) + { + if (nextmap == 1102-1) // end game with credits + { + F_StartCredits(); + return; + } + if (nextmap == 1101-1) // end game with evaluation + { + F_StartGameEvaluation(); + return; + } + } + // 1100 or competitive multiplayer, so go back to title screen. D_StartTitle(); } diff --git a/src/g_game.h b/src/g_game.h index d528ace86..1cb36869c 100644 --- a/src/g_game.h +++ b/src/g_game.h @@ -379,11 +379,14 @@ boolean G_DemoTitleResponder(event_t *ev); INT32 G_GetGametypeByName(const char *gametypestr); boolean G_IsSpecialStage(INT32 mapnum); +boolean G_GametypeUsesLives(void); +boolean G_GametypeHasTeams(void); boolean G_GametypeHasSpectators(void); boolean G_BattleGametype(void); UINT8 G_SometimesGetDifferentGametype(UINT8 prefgametype); UINT8 G_GetGametypeColor(INT16 gt); boolean G_RaceGametype(void); +boolean G_TagGametype(void); void G_ExitLevel(void); void G_NextLevel(void); void G_Continue(void); diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index 73407874a..f2de96a79 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -4351,9 +4351,9 @@ static void HWR_AddSprites(sector_t *sec) // -------------------------------------------------------------------------- static void HWR_AddPrecipitationSprites(void) { - //const fixed_t drawdist = cv_drawdist_precip.value * mapobjectscale; fixed_t drawdist; - fixed_t precipscale = cv_mobjscaleprecip.value ? mapobjectscale : FRACUNIT; + fixed_t precipscale = (cv_mobjscaleprecip.value ? mapobjectscale : FRACUNIT); + //const fixed_t drawdist = cv_drawdist_precip.value * mapobjectscale; INT32 xl, xh, yl, yh, bx, by; precipmobj_t *th; @@ -4361,7 +4361,7 @@ static void HWR_AddPrecipitationSprites(void) if (current_bsp_culling_distance) drawdist = min((fixed_t)current_bsp_culling_distance, (fixed_t)(cv_drawdist_precip.value) * precipscale); else - drawdist = (fixed_t)(cv_drawdist_precip.value) * precipscale; + drawdist = ((fixed_t)(cv_drawdist_precip.value) * precipscale); // No to infinite precipitation draw distance. if (drawdist == 0 || curWeather == PRECIP_BLANK || curWeather == PRECIP_STORM_NORAIN) @@ -4427,7 +4427,7 @@ static void HWR_ProjectSprite(mobj_t *thing) angle_t sliptiderollangle = 0; #endif - if (!thing) + if (P_MobjWasRemoved(thing) || thing->subsector == NULL) return; // uncapped/interpolation @@ -4891,20 +4891,22 @@ static void HWR_ProjectPrecipitationSprite(precipmobj_t *thing) static gl_sky_t gl_sky; +#define DEG2RADGL(a) ((a * M_PIl) / 180.0f) + static void HWR_SkyDomeVertex(gl_sky_t *sky, gl_skyvertex_t *vbo, int r, int c, signed char yflip, float delta, boolean foglayer) { - const float radians = (float)(M_PIl / 180.0f); - const float scale = 10000.0f; - const float maxSideAngle = 60.0f; + static const float scale = 10000.0f; + static const float maxSideAngle = DEG2RADGL(60.0f); - float topAngle = (c / (float)sky->columns * 360.0f); - float sideAngle = (maxSideAngle * (sky->rows - r) / sky->rows); - float height = (float)(sin(sideAngle * radians)); - float realRadius = (float)(scale * cos(sideAngle * radians)); - float x = (float)(realRadius * cos(topAngle * radians)); + float topAngle = DEG2RADGL(c / (float)sky->columns * 360.0f); + float sideAngle = (maxSideAngle * (float)(sky->rows - r) / (float)sky->rows); + float height = (float)(sin(sideAngle)); + float realRadius = (scale * (float)cos(sideAngle)); + float x = (realRadius * (float)cos(topAngle)); float y = (!yflip) ? scale * height : -scale * height; - float z = (float)(realRadius * sin(topAngle * radians)); + float z = (realRadius * (float)sin(topAngle)); float timesRepeat = (4 * (256.0f / sky->width)); + if (fpclassify(timesRepeat) == FP_ZERO) timesRepeat = 1.0f; diff --git a/src/hu_stuff.c b/src/hu_stuff.c index 73f2c23b9..6cbb46148 100644 --- a/src/hu_stuff.c +++ b/src/hu_stuff.c @@ -775,7 +775,10 @@ static void Command_Sayteam_f(void) return; } - DoSayCommand(0, 1, 0); + if (G_GametypeHasTeams()) // revert to normal say if we don't have teams in this gametype. + DoSayCommand(-1, 1, 0); + else + DoSayCommand(0, 1, 0); } /** Send a message to everyone, to be displayed by CECHO. Only @@ -1392,7 +1395,7 @@ boolean HU_Responder(event_t *ev) chat_on = true; w_chat_buf[0] = 0; M_TextInputInit(&w_chat, w_chat_buf, sizeof w_chat_buf); - teamtalk = false; + teamtalk = G_GametypeHasTeams(); // Don't teamtalk if we don't have teams. chat_scrollmedown = true; typelines = 1; return true; @@ -2608,6 +2611,7 @@ static inline void HU_DrawSpectatorTicker(void) // static void HU_DrawRankings(void) { + patch_t *p; playersort_t tab[MAXPLAYERS]; INT32 i, j, scorelines, hilicol, numplayersingame = 0; boolean completed[MAXPLAYERS]; @@ -2639,6 +2643,25 @@ static void HU_DrawRankings(void) Z_Free(maptitle); } + if (G_GametypeHasTeams()) + { + if (gametype == GT_CTF) + p = bflagico; + else + p = bmatcico; + + V_DrawSmallScaledPatch(128 - SHORT(p->width)/4, 4, 0, p); + V_DrawCenteredString(128, 16, 0, va("%u", bluescore)); + + if (gametype == GT_CTF) + p = rflagico; + else + p = rmatcico; + + V_DrawSmallScaledPatch(192 - SHORT(p->width)/4, 4, 0, p); + V_DrawCenteredString(192, 16, 0, va("%u", redscore)); + } + if (!G_RaceGametype()) { if (cv_timelimit.value && timelimitintics > 0) diff --git a/src/i_video.h b/src/i_video.h index 76055a6aa..70321d138 100644 --- a/src/i_video.h +++ b/src/i_video.h @@ -142,9 +142,6 @@ boolean I_UseNativeKeyboard(void); boolean I_CheckNativeRes(void); #ifdef USE_FBO_OGL -#if defined (__unix__) -extern boolean xwaylandcrap; -#endif void RefreshOGLSDLSurface(void); void I_DownSample(void); diff --git a/src/info.c b/src/info.c index 91fb99b5a..f8cb9a6f1 100644 --- a/src/info.c +++ b/src/info.c @@ -66,7 +66,7 @@ char sprnames[NUMSPRITES + 1][5] = "CNDL","DOCH","DUCK","GTRE","CHES","CHIM","DRGN","LZMN","PGSS","ZTCH", "MKMA","MKMP","RTCH","BOWL","BOWH","BRRL","BRRR","HRSE","TOAH","BFRT", "OFRT","RFRT","PFRT","ASPK","HBST","HBSO","HBSF","WBLZ","WBLN","OPUL", - "TGEM","TCOI","FWRK","XMS4","XMS5","VIEW", + "TGEM","TCOI","FWRK","XMS4","XMS5","VIEW" }; // Doesn't work with g++, needs actionf_p1 (don't modify this comment) diff --git a/src/k_kart.c b/src/k_kart.c index b27789cfc..67de6275e 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -4772,6 +4772,10 @@ player_t *K_FindJawzTarget(mobj_t *actor, player_t *source) if (player == source) continue; + // Don't home in on teammates. + if (G_GametypeHasTeams() && source->ctfteam == player->ctfteam) + continue; + // Invisible, don't bother if (player->kartstuff[k_hyudorotimer]) continue; diff --git a/src/lua_baselib.c b/src/lua_baselib.c index b1d77d737..6bca10cbe 100644 --- a/src/lua_baselib.c +++ b/src/lua_baselib.c @@ -455,7 +455,14 @@ static int lib_pSpawnAlteredDirectionMissile(lua_State *L) static int lib_pColorTeamMissile(lua_State *L) { - (void)L; + mobj_t *missile = *((mobj_t **)luaL_checkudata(L, 1, META_MOBJ)); + player_t *source = *((player_t **)luaL_checkudata(L, 2, META_PLAYER)); + NOHUD + if (!missile) + return LUA_ErrInvalid(L, "mobj_t"); + if (!source) + return LUA_ErrInvalid(L, "player_t"); + P_ColorTeamMissile(missile, source); return 0; } @@ -1251,7 +1258,12 @@ static int lib_pPlayerEmeraldBurst(lua_State *L) static int lib_pPlayerFlagBurst(lua_State *L) { - (void)L; + player_t *player = *((player_t **)luaL_checkudata(L, 1, META_PLAYER)); + boolean toss = lua_optboolean(L, 2); + NOHUD + if (!player) + return LUA_ErrInvalid(L, "player_t"); + P_PlayerFlagBurst(player, toss); return 0; } @@ -1817,7 +1829,7 @@ static int lib_sStartSoundAtVolume(lua_State *L) return LUA_ErrInvalid(L, "player_t"); } if (!player || P_IsLocalPlayer(player)) - S_StartSoundAtVolume(origin, sound_id, volume); + S_StartSoundAtVolume(origin, sound_id, volume); return 0; } @@ -1919,7 +1931,7 @@ static int lib_sChangeMusic(lua_State *L) music_flags = (UINT16)((music_num & 0x7FFF0000) >> 16); else #endif - music_flags = (UINT16)luaL_optinteger(L, 4, 0); + music_flags = (UINT16)luaL_optinteger(L, 4, 0); position = (UINT32)luaL_optinteger(L, 5, 0); prefadems = (UINT32)luaL_optinteger(L, 6, 0); @@ -2446,14 +2458,14 @@ static int lib_gIsSpecialStage(lua_State *L) static int lib_gGametypeUsesLives(lua_State *L) { //HUDSAFE - lua_pushboolean(L, false); + lua_pushboolean(L, G_GametypeUsesLives()); return 1; } static int lib_gGametypeHasTeams(lua_State *L) { //HUDSAFE - lua_pushboolean(L, false); + lua_pushboolean(L, G_GametypeHasTeams()); return 1; } @@ -2481,7 +2493,7 @@ static int lib_gRaceGametype(lua_State *L) static int lib_gTagGametype(lua_State *L) { //HUDSAFE - lua_pushboolean(L, false); + lua_pushboolean(L, G_TagGametype()); return 1; } diff --git a/src/m_cheat.c b/src/m_cheat.c index 9d0ea6a26..5f8648cbd 100644 --- a/src/m_cheat.c +++ b/src/m_cheat.c @@ -945,6 +945,9 @@ boolean OP_FreezeObjectplace(void) if (!objectplacing) return false; + if ((maptol & TOL_NIGHTS) && (players[consoleplayer].pflags & PF_NIGHTSMODE)) + return false; + return true; } diff --git a/src/m_menu.c b/src/m_menu.c index 7523c1014..a4121d448 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -3324,19 +3324,34 @@ static void Newgametype_OnChange(void) P_AllocMapHeader((INT16)(cv_nextmap.value-1)); if ((cv_newgametype.value == GT_RACE && !(mapheaderinfo[cv_nextmap.value-1]->typeoflevel & TOL_RACE)) || // SRB2kart - (cv_newgametype.value == GT_MATCH && !(mapheaderinfo[cv_nextmap.value-1]->typeoflevel & TOL_MATCH))) + ((cv_newgametype.value == GT_MATCH || cv_newgametype.value == GT_TEAMMATCH) && !(mapheaderinfo[cv_nextmap.value-1]->typeoflevel & TOL_MATCH))) { INT32 value = 0; switch (cv_newgametype.value) { + case GT_COOP: + value = TOL_RACE; // SRB2kart + break; + case GT_COMPETITION: + value = TOL_COMPETITION; + break; case GT_RACE: value = TOL_RACE; break; case GT_MATCH: + case GT_TEAMMATCH: value = TOL_MATCH; break; + case GT_TAG: + case GT_HIDEANDSEEK: + value = TOL_TAG; + break; + case GT_CTF: + value = TOL_CTF; + break; } + CV_SetValue(&cv_nextmap, M_FindFirstMap(value)); } } @@ -4457,6 +4472,9 @@ void M_StartControlPanel(void) { MPauseMenu[mpause_switchmap].status = IT_STRING | IT_CALL; MPauseMenu[mpause_addons].status = IT_STRING | IT_CALL; + + if (G_GametypeHasTeams()) + MPauseMenu[mpause_scramble].status = IT_STRING | IT_SUBMENU; } if (server || (!cv_showlocalskinmenus.value)) @@ -4477,7 +4495,16 @@ void M_StartControlPanel(void) if (netgame) { - if (G_GametypeHasSpectators()) + if (G_GametypeHasTeams()) + { + MPauseMenu[mpause_switchteam].status = IT_STRING | IT_SUBMENU; + MPauseMenu[mpause_switchteam].alphaKey += ((splitscreen+1) * 8); + MPauseMenu[mpause_localskin].alphaKey += 8; + MPauseMenu[mpause_options].alphaKey += 8; + MPauseMenu[mpause_title].alphaKey += 8; + MPauseMenu[mpause_quit].alphaKey += 8; + } + else if (G_GametypeHasSpectators()) { MPauseMenu[mpause_switchspectate].status = IT_STRING | IT_SUBMENU; MPauseMenu[mpause_switchspectate].alphaKey += ((splitscreen+1) * 8); @@ -4511,7 +4538,9 @@ void M_StartControlPanel(void) { MPauseMenu[mpause_psetup].status = IT_STRING | IT_CALL; - if (G_GametypeHasSpectators()) + if (G_GametypeHasTeams()) + MPauseMenu[mpause_switchteam].status = IT_STRING | IT_SUBMENU; + else if (G_GametypeHasSpectators()) { if (!players[consoleplayer].spectator) MPauseMenu[mpause_spectate].status = IT_STRING | IT_CALL; @@ -5654,7 +5683,7 @@ boolean M_CanShowLevelInList(INT32 mapnum, INT32 gt) if (M_MapLocked(mapnum+1)) // not unlocked return cv_showallmaps.value; - if (gt == GT_MATCH && (mapheaderinfo[mapnum]->typeoflevel & TOL_MATCH)) + if ((gt == GT_MATCH || gt == GT_TEAMMATCH) && (mapheaderinfo[mapnum]->typeoflevel & TOL_MATCH)) return true; if (gt == GT_RACE && (mapheaderinfo[mapnum]->typeoflevel & TOL_RACE)) diff --git a/src/m_misc.c b/src/m_misc.c index aec2aad1d..a3768120d 100644 --- a/src/m_misc.c +++ b/src/m_misc.c @@ -27,6 +27,8 @@ // Extended map support. #include +#include "am_map.h" + #include "doomdef.h" #include "g_game.h" #include "m_misc.h" diff --git a/src/p_enemy.c b/src/p_enemy.c index 6e47def15..96b0a16df 100644 --- a/src/p_enemy.c +++ b/src/p_enemy.c @@ -456,7 +456,10 @@ boolean P_Move(mobj_t *actor, fixed_t speed) I_Assert(movedir < NUMDIRS); tryx = actor->x + FixedMul(speed*xspeed[movedir], actor->scale); - tryy = actor->y + FixedMul(speed*yspeed[movedir], actor->scale); + if (twodlevel || actor->flags2 & MF2_TWOD) + tryy = actor->y; + else + tryy = actor->y + FixedMul(speed*yspeed[movedir], actor->scale); if (actor->type == MT_SKIM && !P_WaterInSector(actor, tryx, tryy)) // bail out if sector lacks water return false; @@ -530,6 +533,8 @@ void P_NewChaseDir(mobj_t *actor) else d[1] = DI_NODIR; + if (twodlevel || actor->flags2 & MF2_TWOD) + d[2] = DI_NODIR; if (deltay < -FixedMul(10*FRACUNIT, actor->scale)) d[2] = DI_SOUTH; else if (deltay > FixedMul(10*FRACUNIT, actor->scale)) @@ -2947,7 +2952,9 @@ void A_Invincibility(mobj_t *actor) if (P_IsLocalPlayer(player) && !player->powers[pw_super]) { S_StopMusic(); - S_ChangeMusicInternal("invinc", false); + if (mariomode) + G_GhostAddColor((INT32) (player - players), GHC_INVINCIBLE); + S_ChangeMusicInternal((mariomode) ? "minvnc" : "invinc", false); } } @@ -3045,7 +3052,11 @@ void A_ExtraLife(mobj_t *actor) return; } - P_GivePlayerRings(player, 100); + // In shooter gametypes, give the player 100 rings instead of an extra life. + if (gametype != GT_COOP && gametype != GT_COMPETITION) + P_GivePlayerRings(player, 100); + else + P_GivePlayerLives(player, 1); P_PlayLivesJingle(player); } @@ -3727,6 +3738,11 @@ void A_ThrownRing(mobj_t *actor) if (player->mo == actor->target) continue; + // Don't home in on teammates. + if (gametype == GT_CTF + && actor->target->player->ctfteam == player->ctfteam) + continue; + if (actor->target->player->kartstuff[k_position] < player->kartstuff[k_position]) // SRB2kart - Jawz only go after people ahead of you continue; @@ -3787,6 +3803,11 @@ static inline boolean PIT_GrenadeRing(mobj_t *thing) || (G_BattleGametype() && thing->player && thing->player->kartstuff[k_bumper] <= 0 && thing->player->kartstuff[k_comebacktimer]))) return true; + if ((gametype == GT_CTF || gametype == GT_TEAMMATCH) + && !cv_friendlyfire.value && grenade->target->player && thing->player + && grenade->target->player->ctfteam == thing->player->ctfteam) // Don't blow up at your teammates, unless friendlyfire is on + return true; + // see if it went over / under if (grenade->z - explodedist > thing->z + thing->height) return true; // overhead @@ -4488,7 +4509,12 @@ void A_MouseThink(mobj_t *actor) || (actor->eflags & MFE_VERTICALFLIP && actor->z + actor->height == actor->ceilingz)) && !actor->reactiontime) { - if (P_RandomChance(FRACUNIT/2)) + if (twodlevel || actor->flags2 & MF2_TWOD) + { + if (P_RandomChance(FRACUNIT/2)) + actor->angle += ANGLE_180; + } + else if (P_RandomChance(FRACUNIT/2)) actor->angle += ANGLE_90; else actor->angle -= ANGLE_90; @@ -5295,8 +5321,7 @@ void A_RingExplode(mobj_t *actor) // var1 = object # to explode as debris // var2 = unused // -void A_OldRingExplode(mobj_t *actor) -{ +void A_OldRingExplode(mobj_t *actor) { UINT8 i; mobj_t *mo; const fixed_t ns = FixedMul(20 * FRACUNIT, actor->scale); @@ -5330,10 +5355,10 @@ void A_OldRingExplode(mobj_t *actor) if (changecolor) { - if (actor->target->player->ctfteam == 2) - mo->color = skincolor_bluering; - else + if (gametype != GT_CTF) mo->color = actor->target->color; //copy color + else if (actor->target->player->ctfteam == 2) + mo->color = skincolor_bluering; } } @@ -5346,10 +5371,10 @@ void A_OldRingExplode(mobj_t *actor) if (changecolor) { - if (actor->target->player->ctfteam == 2) - mo->color = skincolor_bluering; - else + if (gametype != GT_CTF) mo->color = actor->target->color; //copy color + else if (actor->target->player->ctfteam == 2) + mo->color = skincolor_bluering; } mo = P_SpawnMobj(actor->x, actor->y, actor->z, locvar1); @@ -5361,10 +5386,10 @@ void A_OldRingExplode(mobj_t *actor) if (changecolor) { - if (actor->target->player->ctfteam == 2) - mo->color = skincolor_bluering; - else + if (gametype != GT_CTF) mo->color = actor->target->color; //copy color + else if (actor->target->player->ctfteam == 2) + mo->color = skincolor_bluering; } } @@ -5388,7 +5413,7 @@ void A_MixUp(mobj_t *actor) // No mix-up monitors in hide and seek or time only race. // The random factor is okay for other game modes, but in these, it is cripplingly unfair. - if (gametype == GT_RACE) + if (gametype == GT_HIDEANDSEEK || gametype == GT_RACE) return; numplayers = 0; diff --git a/src/p_inter.c b/src/p_inter.c index 6fb8b7c67..d4a5b3c1d 100644 --- a/src/p_inter.c +++ b/src/p_inter.c @@ -662,6 +662,9 @@ void P_TouchSpecialThing(mobj_t *special, mobj_t *toucher, boolean heightcheck) special->momx = special->momy = special->momz = 0; P_GivePlayerRings(player, 1); + + if ((maptol & TOL_NIGHTS) && special->type != MT_FLINGRING) + P_DoNightsScore(player); break; case MT_COIN: @@ -671,6 +674,9 @@ void P_TouchSpecialThing(mobj_t *special, mobj_t *toucher, boolean heightcheck) special->momx = special->momy = 0; P_GivePlayerRings(player, 1); + + if ((maptol & TOL_NIGHTS) && special->type != MT_FLINGCOIN) + P_DoNightsScore(player); break; case MT_BLUEBALL: if (!(P_CanPickupItem(player, 0))) @@ -684,6 +690,9 @@ void P_TouchSpecialThing(mobj_t *special, mobj_t *toucher, boolean heightcheck) special->scalespeed = FixedDiv(FixedDiv(special->destscale, special->scale), states[special->info->deathstate].tics<scalespeed = 4*FRACUNIT/5; + + if (maptol & TOL_NIGHTS) + P_DoNightsScore(player); break; case MT_AUTOPICKUP: case MT_BOUNCEPICKUP: @@ -833,6 +842,8 @@ void P_TouchSpecialThing(mobj_t *special, mobj_t *toucher, boolean heightcheck) return; if (special->fuse == 1) return; +// if (special->momz > 0) +// return; { UINT8 flagteam = (special->type == MT_REDFLAG) ? 1 : 2; const char *flagtext; @@ -1330,6 +1341,10 @@ void P_TouchSpecialThing(mobj_t *special, mobj_t *toucher, boolean heightcheck) return; // SRB2kart - don't need bubbles mucking with the player if ((player->powers[pw_shield] & SH_NOSTACK) == SH_ELEMENTAL) return; + if (maptol & TOL_NIGHTS) + return; + if (mariomode) + return; else if (toucher->eflags & MFE_VERTICALFLIP) { if (special->z+special->height < toucher->z + toucher->height / 3 @@ -1418,36 +1433,46 @@ void P_CheckTimeLimit(void) if (gamestate == GS_LEVEL && (leveltime == (timelimitintics + TICRATE))) S_StartSound(NULL, sfx_strpst); - //Store the nodes of participating players in an array. - for (i = 0; i < MAXPLAYERS; i++) + // Normal Match + if (!G_GametypeHasTeams()) { - if (playeringame[i] && !players[i].spectator) + //Store the nodes of participating players in an array. + for (i = 0; i < MAXPLAYERS; i++) { - playerarray[playercount] = i; - playercount++; - } - } - - if (playercount > MAXPLAYERS) - playercount = MAXPLAYERS; - - //Sort 'em. - for (i = 1; i < playercount; i++) - { - for (k = i; k < playercount; k++) - { - if (players[playerarray[i-1]].marescore < players[playerarray[k]].marescore) + if (playeringame[i] && !players[i].spectator) { - tempplayer = playerarray[i-1]; - playerarray[i-1] = playerarray[k]; - playerarray[k] = tempplayer; + playerarray[playercount] = i; + playercount++; } } - } - //End the round if the top players aren't tied. - if (players[playerarray[0]].marescore == players[playerarray[1]].marescore) - return; + if (playercount > MAXPLAYERS) + playercount = MAXPLAYERS; + + //Sort 'em. + for (i = 1; i < playercount; i++) + { + for (k = i; k < playercount; k++) + { + if (players[playerarray[i-1]].marescore < players[playerarray[k]].marescore) + { + tempplayer = playerarray[i-1]; + playerarray[i-1] = playerarray[k]; + playerarray[k] = tempplayer; + } + } + } + + //End the round if the top players aren't tied. + if (players[playerarray[0]].marescore == players[playerarray[1]].marescore) + return; + } + else + { + //In team match and CTF, determining a tie is much simpler. =P + if (redscore == bluescore) + return; + } } } @@ -1694,6 +1719,21 @@ void P_KillMobj(mobj_t *target, mobj_t *inflictor, mobj_t *source) P_UnsetThingPosition(target); target->flags |= MF_NOBLOCKMAP|MF_NOCLIPHEIGHT; P_SetThingPosition(target); + + if (!target->player->bot && !G_IsSpecialStage(gamemap) + && G_GametypeUsesLives()) + { + target->player->lives -= 1; // Lose a life Tails 03-11-2000 + + if (target->player->lives <= 0) // Tails 03-14-2000 + { + if (P_IsLocalPlayer(target->player)/* && target->player == &players[consoleplayer] */) + { + S_StopMusic(); // Stop the Music! Tails 03-14-2000 + S_ChangeMusicInternal("gmover", false); // Yousa dead now, Okieday? Tails 03-14-2000 + } + } + } target->player->playerstate = PST_DEAD; if (cv_birdmusic.value && cv_fading.value && P_IsLocalPlayer(target->player)) @@ -1745,7 +1785,8 @@ void P_KillMobj(mobj_t *target, mobj_t *inflictor, mobj_t *source) // Drop stuff. // This determines the kind of object spawned // during the death frame of a thing. - if (target->flags & MF_ENEMY) + if (!mariomode // Don't show birds, etc. in Mario Mode Tails 12-23-2001 + && target->flags & MF_ENEMY) { if (cv_soniccd.value) item = MT_SEED; @@ -2118,9 +2159,90 @@ static inline void P_NiGHTSDamage(mobj_t *target, mobj_t *source) } } -static inline boolean P_PlayerHitsPlayer(mobj_t *target, mobj_t *source) +static inline boolean P_TagDamage(mobj_t *target, mobj_t *inflictor, mobj_t *source, INT32 damage) { player_t *player = target->player; + (void)damage; //unused parm + + // If flashing or invulnerable, ignore the tag, + if (player->powers[pw_flashing] || player->powers[pw_invulnerability]) + return false; + + // Ignore IT players shooting each other, unless friendlyfire is on. + if ((player->pflags & PF_TAGIT && !(cv_friendlyfire.value && + source && source->player && source->player->pflags & PF_TAGIT))) + return false; + + // Don't allow any damage before the round starts. + if (leveltime <= hidetime * TICRATE) + return false; + + // Don't allow players on the same team to hurt one another, + // unless cv_friendlyfire is on. + if (!cv_friendlyfire.value && (player->pflags & PF_TAGIT) == (source->player->pflags & PF_TAGIT)) + { + if (!(inflictor->flags & MF_FIRE)) + P_GivePlayerRings(player, 1); + if (inflictor->flags2 & MF2_BOUNCERING) + inflictor->fuse = 0; // bounce ring disappears at -1 not 0 + return false; + } + + P_DoPlayerPain(player, source, inflictor); + + // Check for a shield + if (player->powers[pw_shield]) + { + P_RemoveShield(player); + S_StartSound(target, sfx_shldls); + return true; + } + + if (target->health <= 1) // Death + { + P_PlayDeathSound(target); + P_PlayVictorySound(source); // Killer laughs at you! LAUGHS! BWAHAHAHHAHAA!! + } + else if (target->health > 1) // Ring loss + { + P_PlayRinglossSound(target, source); + P_PlayerRingBurst(player, player->mo->health - 1); + } + + if (inflictor && ((inflictor->flags & MF_MISSILE) || inflictor->player) && player->powers[pw_super] && ALL7EMERALDS(player->powers[pw_emeralds])) + { + player->health -= 10; + if (player->health < 2) + player->health = 2; + target->health = player->health; + } + else + player->health = target->health = 1; + + return true; +} + +static inline boolean P_PlayerHitsPlayer(mobj_t *target, mobj_t *inflictor, mobj_t *source, INT32 damage) +{ + player_t *player = target->player; + + // Tag handling + if (G_TagGametype()) + return P_TagDamage(target, inflictor, source, damage); + else if (G_GametypeHasTeams()) // CTF + Team Match + { + // Don't allow players on the same team to hurt one another, + // unless cv_friendlyfire is on. + if (!cv_friendlyfire.value && target->player->ctfteam == source->player->ctfteam) + { + if (!(inflictor->flags & MF_FIRE)) + P_GivePlayerRings(target->player, 1); + if (inflictor->flags2 & MF2_BOUNCERING) + inflictor->fuse = 0; // bounce ring disappears at -1 not 0 + + return false; + } + } // Add pity. if (!player->powers[pw_flashing] && !player->powers[pw_invulnerability] && !player->powers[pw_super] @@ -2361,6 +2483,9 @@ boolean P_DamageMobj(mobj_t *target, mobj_t *inflictor, mobj_t *source, INT32 da { if (player->exiting) return false; + + if (!(target->player->pflags & (PF_NIGHTSMODE|PF_NIGHTSFALL)) && (maptol & TOL_NIGHTS)) + return false; } if (player->pflags & PF_NIGHTSMODE) // NiGHTS damage handling @@ -2369,6 +2494,10 @@ boolean P_DamageMobj(mobj_t *target, mobj_t *inflictor, mobj_t *source, INT32 da { if (source == target) return false; // Don't hit yourself with your own paraloop, baka + if (source && source->player && !cv_friendlyfire.value + && (gametype == GT_COOP + || (G_GametypeHasTeams() && target->player->ctfteam == source->player->ctfteam))) + return false; // Don't run eachother over in special stages and team games and such } if (LUA_HookMobjDamage(target, inflictor, source, damage)) @@ -2401,7 +2530,7 @@ boolean P_DamageMobj(mobj_t *target, mobj_t *inflictor, mobj_t *source, INT32 da // Player hits another player if (!force && source && source->player) { - if (!P_PlayerHitsPlayer(target, source)) + if (!P_PlayerHitsPlayer(target, inflictor, source, damage)) return false; } @@ -2455,6 +2584,9 @@ boolean P_DamageMobj(mobj_t *target, mobj_t *inflictor, mobj_t *source, INT32 da if (player->health < 2) player->health = 2; } + + if (gametype == GT_CTF && (player->gotflag & (GF_REDFLAG|GF_BLUEFLAG))) + P_PlayerFlagBurst(player, false); } else { @@ -2606,7 +2738,9 @@ void P_PlayerRingBurst(player_t *player, INT32 num_rings) { ns = FixedMul(((i*FRACUNIT)/16)+2*FRACUNIT, mo->scale); mo->momx = FixedMul(FINECOSINE(fa),ns); - mo->momy = FixedMul(FINESINE(fa),ns); + + if (!(twodlevel || (player->mo->flags2 & MF2_TWOD))) + mo->momy = FixedMul(FINESINE(fa),ns); P_SetObjectMomZ(mo, 8*FRACUNIT, false); mo->fuse = 20*TICRATE; // Adjust fuse for NiGHTS @@ -2628,7 +2762,9 @@ void P_PlayerRingBurst(player_t *player, INT32 num_rings) ns = FixedMul(momxy, mo->scale); mo->momx = FixedMul(FINECOSINE(fa),ns); - mo->momy = FixedMul(FINESINE(fa),ns); + + if (!(twodlevel || (player->mo->flags2 & MF2_TWOD))) + mo->momy = FixedMul(FINESINE(fa),ns); ns = momz; P_SetObjectMomZ(mo, ns, false); @@ -2733,7 +2869,9 @@ void P_PlayerWeaponPanelBurst(player_t *player) // >16 ring type spillout ns = FixedMul(3*FRACUNIT, mo->scale); mo->momx = FixedMul(FINECOSINE(fa),ns); - mo->momy = FixedMul(FINESINE(fa),ns); + + if (!(twodlevel || (player->mo->flags2 & MF2_TWOD))) + mo->momy = FixedMul(FINESINE(fa),ns); P_SetObjectMomZ(mo, 4*FRACUNIT, false); @@ -2815,7 +2953,9 @@ void P_PlayerWeaponAmmoBurst(player_t *player) // Spill them! ns = FixedMul(2*FRACUNIT, mo->scale); mo->momx = FixedMul(FINECOSINE(fa), ns); - mo->momy = FixedMul(FINESINE(fa),ns); + + if (!(twodlevel || (player->mo->flags2 & MF2_TWOD))) + mo->momy = FixedMul(FINESINE(fa),ns); P_SetObjectMomZ(mo, 3*FRACUNIT, false); @@ -2929,7 +3069,11 @@ void P_PlayerEmeraldBurst(player_t *player, boolean toss) } momx = FixedMul(FINECOSINE(fa), ns); - momy = FixedMul(FINESINE(fa),ns); + + if (!(twodlevel || (player->mo->flags2 & MF2_TWOD))) + momy = FixedMul(FINESINE(fa),ns); + else + momy = 0; mo = P_SpawnMobj(player->mo->x, player->mo->y, z, MT_FLINGEMERALD); mo->health = 1; @@ -2953,3 +3097,88 @@ void P_PlayerEmeraldBurst(player_t *player, boolean toss) } } } + +/** Makes an injured or dead player lose possession of the flag. + * + * \param player The player with the flag, about to lose it. + * \sa P_PlayerRingBurst + */ +void P_PlayerFlagBurst(player_t *player, boolean toss) +{ + mobj_t *flag; + mobjtype_t type; + + if (!(player->gotflag & (GF_REDFLAG|GF_BLUEFLAG))) + return; + + if (player->gotflag & GF_REDFLAG) + type = MT_REDFLAG; + else + type = MT_BLUEFLAG; + + flag = P_SpawnMobj(player->mo->x, player->mo->y, player->mo->z, type); + + if (player->mo->eflags & MFE_VERTICALFLIP) + flag->z += player->mo->height - flag->height; + + if (toss) + P_InstaThrust(flag, player->mo->angle, FixedMul(6*FRACUNIT, player->mo->scale)); + else + { + angle_t fa = P_RandomByte()*FINEANGLES/256; + flag->momx = FixedMul(FINECOSINE(fa), FixedMul(6*FRACUNIT, player->mo->scale)); + if (!(twodlevel || (player->mo->flags2 & MF2_TWOD))) + flag->momy = FixedMul(FINESINE(fa), FixedMul(6*FRACUNIT, player->mo->scale)); + } + + flag->momz = FixedMul(8*FRACUNIT, player->mo->scale); + if (player->mo->eflags & MFE_VERTICALFLIP) + flag->momz = -flag->momz; + + if (type == MT_REDFLAG) + flag->spawnpoint = rflagpoint; + else + flag->spawnpoint = bflagpoint; + + flag->fuse = cv_flagtime.value * TICRATE; + 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) + { + 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; + + // Pointers set for displaying time value and for consistency restoration. + if (type == MT_REDFLAG) + redflag = flag; + else + blueflag = flag; + + if (toss) + player->tossdelay = 2*TICRATE; + + return; +} diff --git a/src/p_local.h b/src/p_local.h index 08323e052..ea0bff603 100644 --- a/src/p_local.h +++ b/src/p_local.h @@ -57,6 +57,9 @@ #define AIMINGTOSLOPE(aiming) FINESINE((aiming>>ANGLETOFINESHIFT) & FINEMASK) +#define mariomode (maptol & TOL_MARIO) +#define twodlevel (maptol & TOL_2D) + // // P_TICK // @@ -287,6 +290,7 @@ mobj_t *P_SPMAngle(mobj_t *source, mobjtype_t type, angle_t angle, UINT8 aimtype #ifdef SEENAMES #define P_SpawnNameFinder(s,t) P_SPMAngle(s,t,s->angle,true,0) #endif +void P_ColorTeamMissile(mobj_t *missile, player_t *source); // P_MobjFlip // Special utility to return +1 or -1 depending on mobj's gravity @@ -438,6 +442,7 @@ void P_PlayerWeaponAmmoBurst(player_t *player); void P_PlayerEmeraldBurst(player_t *player, boolean toss); void P_TouchSpecialThing(mobj_t *special, mobj_t *toucher, boolean heightcheck); +void P_PlayerFlagBurst(player_t *player, boolean toss); void P_CheckTimeLimit(void); void P_CheckPointLimit(void); boolean P_CheckRacers(void); diff --git a/src/p_map.c b/src/p_map.c index 6c141eb16..6825141a4 100644 --- a/src/p_map.c +++ b/src/p_map.c @@ -371,6 +371,11 @@ static boolean PIT_CheckThing(mobj_t *thing) if (!(thing->flags & (MF_SOLID|MF_SPECIAL|MF_PAIN|MF_SHOOTABLE)) || (thing->flags & MF_NOCLIPTHING)) return true; + // Don't collide with your buddies while NiGHTS-flying. + if (tmthing->player && thing->player && (maptol & TOL_NIGHTS) + && ((tmthing->player->pflags & PF_NIGHTSMODE) || (thing->player->pflags & PF_NIGHTSMODE))) + return true; + blockdist = thing->radius + tmthing->radius; if (abs(thing->x - tmx) >= blockdist || abs(thing->y - tmy) >= blockdist) @@ -2161,6 +2166,7 @@ boolean P_TryCameraMove(fixed_t x, fixed_t y, camera_t *thiscam) { subsector_t *s = R_PointInSubsector(x, y); boolean retval = true; + boolean itsatwodlevel = false; UINT8 i; floatok = false; @@ -2168,7 +2174,22 @@ boolean P_TryCameraMove(fixed_t x, fixed_t y, camera_t *thiscam) if (dedicated) // this crashes so don't even try it return false; - if (players[displayplayers[0]].mo) + if (twodlevel) + itsatwodlevel = true; + else + { + for (i = 0; i <= splitscreen; i++) + { + if (thiscam == &camera[i] && players[displayplayers[i]].mo + && (players[displayplayers[i]].mo->flags2 & MF2_TWOD)) + { + itsatwodlevel = true; + break; + } + } + } + + if (!itsatwodlevel && players[displayplayers[0]].mo) { fixed_t tryx = thiscam->x; fixed_t tryy = thiscam->y; @@ -3162,8 +3183,16 @@ stairstep: P_HitSlideLine(bestslideline); // clip the moves - mo->momx = tmxmove; - mo->momy = tmymove; + if ((twodlevel || (mo->flags2 & MF2_TWOD)) && mo->player) + { + mo->momx = tmxmove; + tmymove = 0; + } + else + { + mo->momx = tmxmove; + mo->momy = tmymove; + } do { if (tmxmove > mo->radius) { diff --git a/src/p_mobj.c b/src/p_mobj.c index 6af0a6cad..021271c49 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -1177,7 +1177,7 @@ static void P_XYFriction(mobj_t *mo, fixed_t oldx, fixed_t oldy) } else if (abs(player->rmomx) < FixedMul(STOPSPEED, mo->scale) && abs(player->rmomy) < FixedMul(STOPSPEED, mo->scale) - && (!player->cmd.forwardmove && !player->cmd.sidemove && !(player->pflags & PF_SPINNING)) + && (!(player->cmd.forwardmove && !(twodlevel || mo->flags2 & MF2_TWOD)) && !player->cmd.sidemove && !(player->pflags & PF_SPINNING)) && !(player->mo->standingslope && (!(player->mo->standingslope->flags & SL_NOPHYSICS)) && (abs(player->mo->standingslope->zdelta) >= FRACUNIT/2)) ) { @@ -2220,7 +2220,10 @@ static boolean P_ZMovement(mobj_t *mo) || mo->type == MT_CANNONBALLDECOR || mo->type == MT_FALLINGROCK) { - mom.z = -FixedMul(mom.z, FixedDiv(17*FRACUNIT,20*FRACUNIT)); + if (maptol & TOL_NIGHTS) + mom.z = -FixedDiv(mom.z, 10*FRACUNIT); + else + mom.z = -FixedMul(mom.z, FixedDiv(17*FRACUNIT,20*FRACUNIT)); if (mo->type == MT_BIGTUMBLEWEED || mo->type == MT_LITTLETUMBLEWEED) { @@ -2358,7 +2361,12 @@ static boolean P_ZMovement(mobj_t *mo) else // Flags bounce if (mo->type == MT_REDFLAG || mo->type == MT_BLUEFLAG) - mo->momz = -FixedMul(mo->momz, FixedDiv(17*FRACUNIT,20*FRACUNIT)); + { + if (maptol & TOL_NIGHTS) + mo->momz = -FixedDiv(mo->momz, 10*FRACUNIT); + else + mo->momz = -FixedMul(mo->momz, FixedDiv(17*FRACUNIT,20*FRACUNIT)); + } else mo->momz = 0; } @@ -2661,6 +2669,10 @@ nightsdone: } // Ugly ugly billions of braces! Argh! } + // hit the ceiling + if (mariomode) + S_StartSound(mo, sfx_mario1); + if (!mo->player->climbing) mo->momz = 0; } @@ -3224,6 +3236,7 @@ void P_DestroyRobots(void) // the below is chasecam only, if you're curious. check out P_CalcPostImg in p_user.c for first person static void P_CalcChasePostImg(player_t *player, camera_t *thiscam) { + boolean itsatwodlevel = false; const boolean flipcam = (player->pflags & PF_FLIPCAM && !(player->pflags & PF_NIGHTSMODE) && player->mo->eflags & MFE_VERTICALFLIP); UINT16 postimgflags = 0; UINT8 i; @@ -3233,6 +3246,21 @@ static void P_CalcChasePostImg(player_t *player, camera_t *thiscam) if (flipcam) postimgflags |= POSTIMG_FLIP; + if (twodlevel) + itsatwodlevel = true; + else + { + for (i = 0; i <= splitscreen; i++) + { + if (thiscam == &camera[i] && players[displayplayers[i]].mo + && (players[displayplayers[i]].mo->flags2 & MF2_TWOD)) + { + itsatwodlevel = true; + break; + } + } + } + if (player->awayviewtics && player->awayviewmobj && !P_MobjWasRemoved(player->awayviewmobj)) // Camera must obviously exist { camera_t dummycam; @@ -3306,9 +3334,8 @@ boolean P_CameraThinker(player_t *player, camera_t *thiscam, boolean resetcalled } } -#ifndef NOCLIPCAM + if (!itsatwodlevel) P_CheckCameraPosition(thiscam->x, thiscam->y, thiscam); -#endif thiscam->subsector = R_PointInSubsectorFast(thiscam->x, thiscam->y); thiscam->floorz = tmfloorz; @@ -3320,7 +3347,7 @@ boolean P_CameraThinker(player_t *player, camera_t *thiscam, boolean resetcalled thiscam->z += thiscam->momz + player->mo->pmomz; #ifndef NOCLIPCAM - if (!(player->pflags & PF_NOCLIP || leveltime < introtime)) + if (!itsatwodlevel && !(player->pflags & PF_NOCLIP || leveltime < introtime)) { // clip movement if (thiscam->z <= thiscam->floorz) // hit the floor @@ -3363,13 +3390,13 @@ boolean P_CameraThinker(player_t *player, camera_t *thiscam, boolean resetcalled #endif } - if (thiscam->ceilingz - thiscam->z < thiscam->height - && thiscam->ceilingz >= thiscam->z) + if (itsatwodlevel + || (thiscam->ceilingz - thiscam->z < thiscam->height + && thiscam->ceilingz >= thiscam->z)) { thiscam->ceilingz = thiscam->z + thiscam->height; thiscam->floorz = thiscam->z; } - return false; } @@ -10522,8 +10549,11 @@ void P_RespawnSpecials(void) } //CTF rings should continue to respawn as normal rings outside of CTF. - if (i == MT_REDTEAMRING || i == MT_BLUETEAMRING) - i = MT_RING; + if (gametype != GT_CTF) + { + if (i == MT_REDTEAMRING || i == MT_BLUETEAMRING) + i = MT_RING; + } if (mthing->options & MTF_OBJECTFLIP) { @@ -10596,7 +10626,48 @@ void P_SpawnPlayer(INT32 playernum) } else if (multiplayer && !netgame) { - p->spectator = false; + // If you're in a team game and you don't have a team assigned yet... + if (G_GametypeHasTeams() && p->ctfteam == 0) + { + changeteam_union NetPacket; + UINT16 usvalue; + NetPacket.value.l = NetPacket.value.b = 0; + + // Spawn as a spectator, + // yes even in splitscreen mode + p->spectator = true; + p->spectatorreentry = 0; //(cv_spectatorreentry.value * TICRATE); + + if (playernum&1) p->skincolor = skincolor_redteam; + else p->skincolor = skincolor_blueteam; + + // but immediately send a team change packet. + NetPacket.packet.playernum = playernum; + NetPacket.packet.verification = true; + NetPacket.packet.newteam = !(playernum&1) + 1; + + usvalue = SHORT(NetPacket.value.l|NetPacket.value.b); + SendNetXCmd(XD_TEAMCHANGE, &usvalue, sizeof(usvalue)); + } + else // Otherwise, never spectator. + p->spectator = false; + } + + if (G_GametypeHasTeams()) + { + // Fix stupid non spectator spectators. + if (!p->spectator && !p->ctfteam) + { + p->spectator = true; + p->spectatorreentry = 0; //(cv_spectatorreentry.value * TICRATE); + } + + // Fix team colors. + // This code isn't being done right somewhere else. Oh well. + if (p->ctfteam == 1) + p->skincolor = skincolor_redteam; + else if (p->ctfteam == 2) + p->skincolor = skincolor_blueteam; } mobj = P_SpawnMobj(0, 0, 0, MT_PLAYER); @@ -10997,14 +11068,36 @@ void P_SpawnMapThing(mapthing_t *mthing) return; if (i >= MT_EMERALD1 && i <= MT_EMERALD7) // Pickupable Emeralds - return; + { + if (gametype != GT_COOP) // Don't place emeralds in non-coop modes + return; + + if (metalrecording) + return; // Metal Sonic isn't for collecting emeralds. + + if (emeralds & mobjinfo[i].speed) // You already have this emerald! + return; + } if (!G_BattleGametype() || !cv_specialrings.value) if (P_WeaponOrPanel(i)) return; // Don't place weapons/panels in non-ringslinger modes if (i == MT_EMERHUNT) + { + // Emerald Hunt is Coop only. + if (gametype != GT_COOP) + return; + + ss = R_PointInSubsector(mthing->x << FRACBITS, mthing->y << FRACBITS); + mthing->z = (INT16)((( + ss->sector->f_slope ? P_GetZAt(ss->sector->f_slope, mthing->x << FRACBITS, mthing->y << FRACBITS) : + ss->sector->floorheight)>>FRACBITS) + (mthing->options >> ZSHIFT)); + + if (numhuntemeralds < MAXHUNTEMERALDS) + huntemeralds[numhuntemeralds++] = mthing; return; + } if (i == MT_EMERALDSPAWN) { @@ -11021,28 +11114,56 @@ void P_SpawnMapThing(mapthing_t *mthing) if ((mobjinfo[i].flags & MF_ENEMY) || (mobjinfo[i].flags & MF_BOSS)) return; - // Set powerup boxes to user settings for other netplay modes - if ((mobjinfo[i].flags & MF_MONITOR) && cv_matchboxes.value) // not Normal + // Set powerup boxes to user settings for competition. + if (gametype == GT_COMPETITION) { - if (cv_matchboxes.value == 1) // Random - i = MT_QUESTIONBOX; - else if (cv_matchboxes.value == 3) // Don't spawn - return; - else // cv_matchboxes.value == 2, Non-Random + if ((mobjinfo[i].flags & MF_MONITOR) && cv_competitionboxes.value) // not Normal { - if (i == MT_QUESTIONBOX) - return; // don't spawn in Non-Random - - mthing->options &= ~(MTF_AMBUSH|MTF_OBJECTSPECIAL); // no random respawning! + if (cv_competitionboxes.value == 1) // Random + i = MT_QUESTIONBOX; + else if (cv_competitionboxes.value == 2) // Teleports + i = MT_MIXUPBOX; + else if (cv_competitionboxes.value == 3) // None + return; // Don't spawn! } } - if (i == MT_BLUETEAMRING || i == MT_REDTEAMRING) - i = MT_RING; - else if (i == MT_BLUERINGBOX || i == MT_REDRINGBOX) - i = MT_SUPERRINGBOX; - else if (i == MT_BLUEFLAG || i == MT_REDFLAG) - return; // No flags in non-CTF modes! + // Set powerup boxes to user settings for other netplay modes + else if (gametype != GT_COOP) + { + if ((mobjinfo[i].flags & MF_MONITOR) && cv_matchboxes.value) // not Normal + { + if (cv_matchboxes.value == 1) // Random + i = MT_QUESTIONBOX; + else if (cv_matchboxes.value == 3) // Don't spawn + return; + else // cv_matchboxes.value == 2, Non-Random + { + if (i == MT_QUESTIONBOX) + return; // don't spawn in Non-Random + + mthing->options &= ~(MTF_AMBUSH|MTF_OBJECTSPECIAL); // no random respawning! + } + } + } + + if (gametype != GT_CTF) // CTF specific things + { + if (i == MT_BLUETEAMRING || i == MT_REDTEAMRING) + i = MT_RING; + else if (i == MT_BLUERINGBOX || i == MT_REDRINGBOX) + i = MT_SUPERRINGBOX; + else if (i == MT_BLUEFLAG || i == MT_REDFLAG) + return; // No flags in non-CTF modes! + } + else + { + if ((i == MT_BLUEFLAG && blueflag) || (i == MT_REDFLAG && redflag)) + { + CONS_Alert(CONS_ERROR, M_GetText("Only one flag per team allowed in CTF!\n")); + return; + } + } if (!G_RaceGametype() && (i == MT_SIGN || i == MT_STARPOST)) return; // Don't spawn exit signs or starposts in wrong game modes @@ -11073,7 +11194,7 @@ void P_SpawnMapThing(mapthing_t *mthing) return; // No rings in Ultimate mode (except special stages) } - if (i == MT_EMMY && (ultimatemode || tokenbits == 30 || tokenlist & (1 << tokenbits++))) + if (i == MT_EMMY && (gametype != GT_COOP || ultimatemode || tokenbits == 30 || tokenlist & (1 << tokenbits++))) return; // you already got this token, or there are too many, or the gametype's not right // Objectplace landing point @@ -12248,6 +12369,21 @@ mobj_t *P_SpawnMissile(mobj_t *source, mobj_t *dest, mobjtype_t type) return dist ? th : NULL; } +// +// P_ColorTeamMissile +// Colors a player's ring based on their team +// +void P_ColorTeamMissile(mobj_t *missile, player_t *source) +{ + if (G_GametypeHasTeams()) + { + if (source->ctfteam == 2) + missile->color = skincolor_bluering; + else if (source->ctfteam == 1) + missile->color = skincolor_redring; + } +} + // // P_SPMAngle // Fires missile at angle from what is presumably a player diff --git a/src/p_setup.c b/src/p_setup.c index 89e2a0334..c0ca1d0a6 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -319,6 +319,8 @@ static void P_ClearSingleMapHeaderInfo(INT16 i) mapheaderinfo[num]->saveoverride = SAVE_DEFAULT; mapheaderinfo[num]->levelflags = 0; mapheaderinfo[num]->menuflags = (mainwads ? 0 : LF2_EXISTSHACK); // see p_setup.c - prevents replacing maps in addons with easier versions + // TODO grades support for delfile (pfft yeah right) + P_DeleteGrades(num); // SRB2Kart //mapheaderinfo[num]->automap = false; mapheaderinfo[num]->mobj_scale = FRACUNIT; @@ -341,6 +343,103 @@ void P_AllocMapHeader(INT16 i) P_ClearSingleMapHeaderInfo(i + 1); } +/** NiGHTS Grades are a special structure, + * we initialize them here. + * + * \param i Index of header to allocate grades for + * \param mare The mare we're adding grades for + * \param grades the string from DeHackEd, we work with it ourselves + */ +void P_AddGradesForMare(INT16 i, UINT8 mare, char *gtext) +{ + INT32 g; + char *spos = gtext; + + CONS_Debug(DBG_SETUP, "Map %d Mare %d: ", i+1, (UINT16)mare+1); + + if (mapheaderinfo[i]->numGradedMares < mare+1) + { + mapheaderinfo[i]->numGradedMares = mare+1; + mapheaderinfo[i]->grades = Z_Realloc(mapheaderinfo[i]->grades, sizeof(nightsgrades_t) * mapheaderinfo[i]->numGradedMares, PU_STATIC, NULL); + } + + for (g = 0; g < 6; ++g) + { + // Allow "partial" grading systems + if (spos != NULL) + { + mapheaderinfo[i]->grades[mare].grade[g] = atoi(spos); + CONS_Debug(DBG_SETUP, "%u ", atoi(spos)); + // Grab next comma + spos = strchr(spos, ','); + if (spos) + ++spos; + } + else + { + // Grade not reachable + mapheaderinfo[i]->grades[mare].grade[g] = UINT32_MAX; + } + } + + CONS_Debug(DBG_SETUP, "\n"); +} + +/** And this removes the grades safely. + * + * \param i The header to remove grades from + */ +void P_DeleteGrades(INT16 i) +{ + if (mapheaderinfo[i]->grades) + Z_Free(mapheaderinfo[i]->grades); + + mapheaderinfo[i]->grades = NULL; + mapheaderinfo[i]->numGradedMares = 0; +} + +/** And this fetches the grades + * + * \param pscore The player's score. + * \param map The game map. + * \param mare The mare to test. + */ +UINT8 P_GetGrade(UINT32 pscore, INT16 map, UINT8 mare) +{ + INT32 i; + + // Determining the grade + if (mapheaderinfo[map-1] && mapheaderinfo[map-1]->grades && mapheaderinfo[map-1]->numGradedMares >= mare + 1) + { + INT32 pgrade = 0; + for (i = 0; i < 6; ++i) + { + if (pscore >= mapheaderinfo[map-1]->grades[mare].grade[i]) + ++pgrade; + } + return (UINT8)pgrade; + } + return 0; +} + +UINT8 P_HasGrades(INT16 map, UINT8 mare) +{ + // Determining the grade + // Mare 0 is treated as overall and is true if ANY grades exist + if (mapheaderinfo[map-1] && mapheaderinfo[map-1]->grades + && (mare == 0 || mapheaderinfo[map-1]->numGradedMares >= mare)) + return true; + return false; +} + +UINT32 P_GetScoreForGrade(INT16 map, UINT8 mare, UINT8 grade) +{ + // Get the score for the grade... if it exists + if (grade == GRADE_F || grade > GRADE_S || !P_HasGrades(map, mare)) return 0; + + return mapheaderinfo[map-1]->grades[mare].grade[grade-1]; +} + // Loads the vertexes for a level. FUNCINLINE static ATTRINLINE void P_LoadRawVertexes(UINT8 *data) { @@ -2347,6 +2446,7 @@ static void P_SetupCamera(UINT8 pnum, camera_t *cam) switch (gametype) { case GT_MATCH: + case GT_TAG: thing = deathmatchstarts[0]; break; @@ -2762,7 +2862,44 @@ boolean P_SetupLevel(boolean skipprecip, boolean reloadinggamestate) if (modeattacking == ATTACKING_RECORD && !demo.playback) P_LoadRecordGhosts(); - if (G_RaceGametype() && server) + if (G_TagGametype()) + { + INT32 realnumplayers = 0; + INT32 playersactive[MAXPLAYERS]; + + //I just realized how problematic this code can be. + //D_NumPlayers() will not always cover the scope of the netgame. + //What if one player is node 0 and the other node 31? + //The solution? Make a temp array of all players that are currently playing and pick from them. + //Future todo? When a player leaves, shift all nodes down so D_NumPlayers() can be used as intended? + //Also, you'd never have to loop through all 32 players slots to find anything ever again. + for (i = 0; i < MAXPLAYERS; i++) + { + if (playeringame[i] && !players[i].spectator) + { + playersactive[realnumplayers] = i; //stores the player's node in the array. + realnumplayers++; + } + } + + if (realnumplayers) //this should also fix the dedicated crash bug. You only pick a player if one exists to be picked. + { + i = P_RandomKey(realnumplayers); + players[playersactive[i]].pflags |= PF_TAGIT; //choose our initial tagger before map starts. + + // Taken and modified from G_DoReborn() + // Remove the player so he can respawn elsewhere. + // first dissasociate the corpse + if (players[playersactive[i]].mo) + P_RemoveMobj(players[playersactive[i]].mo); + + G_SpawnPlayer(playersactive[i], false); //respawn the lucky player in his dedicated spawn location. + } + else + CONS_Printf(M_GetText("No player currently available to become IT. Awaiting available players.\n")); + + } + else if (G_RaceGametype() && server) CV_StealthSetValue(&cv_numlaps, ((netgame || multiplayer) && cv_basenumlaps.value && (!(mapheaderinfo[gamemap - 1]->levelflags & LF_SECTIONRACE) diff --git a/src/p_setup.h b/src/p_setup.h index 295258fd8..7f90564e0 100644 --- a/src/p_setup.h +++ b/src/p_setup.h @@ -97,4 +97,11 @@ void P_UpdateSegLightOffset(seg_t *li); size_t P_PrecacheLevelFlats(void); void P_AllocMapHeader(INT16 i); +// Needed for NiGHTS +void P_DeleteGrades(INT16 i); +void P_AddGradesForMare(INT16 i, UINT8 mare, char *gtext); +UINT8 P_GetGrade(UINT32 pscore, INT16 map, UINT8 mare); +UINT8 P_HasGrades(INT16 map, UINT8 mare); +UINT32 P_GetScoreForGrade(INT16 map, UINT8 mare, UINT8 grade); + #endif diff --git a/src/p_spec.c b/src/p_spec.c index 2472c5dbf..8ccfed3c3 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -2605,6 +2605,14 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) mo->flags2 &= ~MF2_TWOD; else mo->flags2 |= MF2_TWOD; + + // 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)) + { + bot->flags2 = (bot->flags2 & ~MF2_TWOD) | (mo->flags2 & MF2_TWOD); + P_SetOrigin(bot, mo->x, mo->y, mo->z); + } } break; @@ -3368,6 +3376,9 @@ void P_ProcessSpecialSector(player_t *player, sector_t *sector, sector_t *rovers } P_DoPlayerPain(player, NULL, NULL); // this does basically everything that was here before + + if (gametype == GT_CTF && player->gotflag & (GF_REDFLAG|GF_BLUEFLAG)) + P_PlayerFlagBurst(player, false); break; case 12: // Wall Sector (Don't step-up/down) case 13: // Ramp Sector (Increase step-up/down) @@ -3387,7 +3398,7 @@ void P_ProcessSpecialSector(player_t *player, sector_t *sector, sector_t *rovers case 3: // Linedef executor requires all players present // Trigger Linedef Exec (Floor Touch, All Players) /// \todo check continues for proper splitscreen support? for (i = 0; i < MAXPLAYERS; i++) - if (playeringame[i] && !players[i].bot && players[i].mo && players[i].lives > 0) + if (playeringame[i] && !players[i].bot && players[i].mo && (gametype != GT_COOP || players[i].lives > 0)) { if (roversector) { @@ -3657,12 +3668,95 @@ DoneSection2: sstimer = 6; // Just let P_Ticker take care of the rest. // Exit (for FOF exits; others are handled in P_PlayerThink in p_user.c) - P_DoPlayerExit(player); - P_SetupSignExit(player); + { + INT32 lineindex; + + P_DoPlayerExit(player); + + P_SetupSignExit(player); + // important: use sector->tag on next line instead of player->mo->subsector->tag + // this part is different from in P_PlayerThink, this is what was causing + // FOF custom exits not to work. + lineindex = P_FindSpecialLineFromTag(2, sector->tag, -1); + + if (gametype == GT_COOP && lineindex != -1) // Custom exit! + { + // Special goodies with the block monsters flag depending on emeralds collected + if ((lines[lineindex].flags & ML_BLOCKMONSTERS) && ALL7EMERALDS(emeralds)) + nextmapoverride = (INT16)(lines[lineindex].frontsector->ceilingheight>>FRACBITS); + else + nextmapoverride = (INT16)(lines[lineindex].frontsector->floorheight>>FRACBITS); + + if (lines[lineindex].flags & ML_NOCLIMB) + skipstats = true; + } + } break; case 3: // Red Team's Base + if (gametype == GT_CTF && P_IsObjectOnGround(player->mo)) + { + if (player->ctfteam == 1 && (player->gotflag & GF_BLUEFLAG)) + { + mobj_t *mo; + + // Make sure the red team still has their own + // flag at their base so they can score. + if (!P_IsFlagAtBase(MT_REDFLAG)) + break; + + HU_SetCEchoFlags(0); + HU_SetCEchoDuration(5); + HU_DoCEcho(va(M_GetText("%s\\captured the blue flag.\\\\\\\\"), player_names[player-players])); + + if (splitscreen || players[consoleplayer].ctfteam == 1) + S_StartSound(NULL, sfx_flgcap); + else if (players[consoleplayer].ctfteam == 2) + S_StartSound(NULL, sfx_lose); + + mo = P_SpawnMobj(player->mo->x,player->mo->y,player->mo->z,MT_BLUEFLAG); + player->gotflag &= ~GF_BLUEFLAG; + mo->flags &= ~MF_SPECIAL; + mo->fuse = TICRATE; + mo->spawnpoint = bflagpoint; + mo->flags2 |= MF2_JUSTATTACKED; + redscore += 1; + P_AddPlayerScore(player, 5); + } + } + break; + case 4: // Blue Team's Base + if (gametype == GT_CTF && P_IsObjectOnGround(player->mo)) + { + if (player->ctfteam == 2 && (player->gotflag & GF_REDFLAG)) + { + mobj_t *mo; + + // Make sure the blue team still has their own + // flag at their base so they can score. + if (!P_IsFlagAtBase(MT_BLUEFLAG)) + break; + + HU_SetCEchoFlags(0); + HU_SetCEchoDuration(5); + HU_DoCEcho(va(M_GetText("%s\\captured the red flag.\\\\\\\\"), player_names[player-players])); + + if (splitscreen || players[consoleplayer].ctfteam == 2) + S_StartSound(NULL, sfx_flgcap); + else if (players[consoleplayer].ctfteam == 1) + S_StartSound(NULL, sfx_lose); + + mo = P_SpawnMobj(player->mo->x,player->mo->y,player->mo->z,MT_REDFLAG); + player->gotflag &= ~GF_REDFLAG; + mo->flags &= ~MF_SPECIAL; + mo->fuse = TICRATE; + mo->spawnpoint = rflagpoint; + mo->flags2 |= MF2_JUSTATTACKED; + bluescore += 1; + P_AddPlayerScore(player, 5); + } + } break; case 5: // Fan sector @@ -5962,7 +6056,8 @@ void P_SpawnSpecials(INT32 fromnetsave, boolean reloadinggamestate) // Linedef executor triggers for CTF teams. case 309: case 311: - lines[i].special = 0; + if (gametype != GT_CTF) + lines[i].special = 0; break; // Each time executors diff --git a/src/p_user.c b/src/p_user.c index e9942bdf8..355c19dfd 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -76,7 +76,9 @@ void P_Thrust(mobj_t *mo, angle_t angle, fixed_t move) angle >>= ANGLETOFINESHIFT; mo->momx += FixedMul(move, FINECOSINE(angle)); - mo->momy += FixedMul(move, FINESINE(angle)); + + if (!(twodlevel || (mo->flags2 & MF2_TWOD))) + mo->momy += FixedMul(move, FINESINE(angle)); } @@ -91,7 +93,9 @@ void P_InstaThrust(mobj_t *mo, angle_t angle, fixed_t move) angle >>= ANGLETOFINESHIFT; mo->momx = FixedMul(move, FINECOSINE(angle)); - mo->momy = FixedMul(move,FINESINE(angle)); + + if (!(twodlevel || (mo->flags2 & MF2_TWOD))) + mo->momy = FixedMul(move,FINESINE(angle)); } void P_InstaThrustEvenIn2D(mobj_t *mo, angle_t angle, fixed_t move) @@ -451,6 +455,24 @@ void P_GivePlayerRings(player_t *player, INT32 num_rings) player->health = 1; } //} + + // Now extra life bonuses are handled here instead of in P_MovePlayer, since why not? + if (!ultimatemode && !modeattacking && !G_IsSpecialStage(gamemap) && G_GametypeUsesLives()) + { + INT32 gainlives = 0; + + while (player->xtralife < maxXtraLife && player->health > 100 * (player->xtralife+1)) + { + ++gainlives; + ++player->xtralife; + } + + if (gainlives) + { + P_GivePlayerLives(player, gainlives); + P_PlayLivesJingle(player); + } + } } // @@ -498,6 +520,15 @@ void P_AddPlayerScore(player_t *player, UINT32 amount) player->marescore += amount; else player->marescore = MAXSCORE; + + // In team match, all awarded points are incremented to the team's running score. + if (gametype == GT_TEAMMATCH) + { + if (player->ctfteam == 1) + redscore += amount; + else if (player->ctfteam == 2) + bluescore += amount; + } } // @@ -510,6 +541,8 @@ void P_PlayLivesJingle(player_t *player) if (use1upSound) S_StartSound(NULL, sfx_oneup); + else if (mariomode) + S_StartSound(NULL, sfx_marioa); else { if (player) @@ -541,7 +574,7 @@ void P_PlayRinglossSound(mobj_t *source, mobj_t *damager) S_StartSound(NULL, sfx); } else - S_StartSound(source, sfx_khurt1 + key); + S_StartSound(source, (mariomode) ? sfx_mario8 : sfx_khurt1 + key); } else S_StartSound(source, sfx_slip); @@ -1715,6 +1748,58 @@ static void P_DoBubbleBreath(player_t *player) return; } +// +// P_DoPlayerHeadSigns +// +// Spawns "IT" and "GOT FLAG" signs for Tag and CTF respectively +// +static void P_DoPlayerHeadSigns(player_t *player) +{ + if (G_TagGametype()) + { + // If you're "IT", show a big "IT" over your head for others to see. + if (player->pflags & PF_TAGIT) + { + if (!P_IsDisplayPlayer(player)) // Don't display it on your own view. + { + if (!(player->mo->eflags & MFE_VERTICALFLIP)) + P_SpawnMobj(player->mo->x, player->mo->y, player->mo->z + player->mo->height, MT_TAG); + else + P_SpawnMobj(player->mo->x, player->mo->y, player->mo->z - mobjinfo[MT_TAG].height, MT_TAG)->eflags |= MFE_VERTICALFLIP; + } + } + } + else if (gametype == GT_CTF) + { + if (player->gotflag & (GF_REDFLAG|GF_BLUEFLAG)) // If you have the flag (duh). + { + // Spawn a got-flag message over the head of the player that + // has it (but not on your own screen if you have the flag). + if (splitscreen || player != &players[consoleplayer]) + { + if (player->gotflag & GF_REDFLAG) + { + if (!(player->mo->eflags & MFE_VERTICALFLIP)) + P_SpawnMobj(player->mo->x+player->mo->momx, player->mo->y+player->mo->momy, + player->mo->z+P_GetPlayerHeight(player)+FixedMul(16*FRACUNIT, player->mo->scale)+player->mo->momz, MT_GOTFLAG); + else + P_SpawnMobj(player->mo->x+player->mo->momx, player->mo->y+player->mo->momy, + player->mo->z+player->mo->height-P_GetPlayerHeight(player)-mobjinfo[MT_GOTFLAG].height-FixedMul(16*FRACUNIT, player->mo->scale)+player->mo->momz, MT_GOTFLAG)->eflags |= MFE_VERTICALFLIP; + } + if (player->gotflag & GF_BLUEFLAG) + { + if (!(player->mo->eflags & MFE_VERTICALFLIP)) + P_SpawnMobj(player->mo->x+player->mo->momx, player->mo->y+player->mo->momy, + player->mo->z+P_GetPlayerHeight(player)+FixedMul(16*FRACUNIT, player->mo->scale)+player->mo->momz, MT_GOTFLAG2); + else + P_SpawnMobj(player->mo->x+player->mo->momx, player->mo->y+player->mo->momy, + player->mo->z+player->mo->height-P_GetPlayerHeight(player)-mobjinfo[MT_GOTFLAG2].height-FixedMul(16*FRACUNIT, player->mo->scale)+player->mo->momz, MT_GOTFLAG2)->eflags |= MFE_VERTICALFLIP; + } + } + } + } +} + // // P_DoJumpShield // @@ -2149,6 +2234,38 @@ static void P_MovePlayer(player_t *player) } // note: don't unset stasis here + if (!player->spectator && G_TagGametype()) + { + // If we have stasis already here, it's because it's forced on us + // by a linedef executor or what have you + boolean forcestasis = false; + + //During hide time, taggers cannot move. + if (leveltime < hidetime * TICRATE) + { + if (player->pflags & PF_TAGIT) + forcestasis = true; + } + else if (gametype == GT_HIDEANDSEEK) + { + if (!(player->pflags & PF_TAGIT)) + { + forcestasis = true; + if (player->pflags & PF_TAGGED) // Already hit. + player->powers[pw_flashing] = 5; + } + } + + if (forcestasis) + { + player->pflags |= PF_FULLSTASIS; + // If you're in stasis in tag, you don't drown. + /*if (player->powers[pw_underwater] <= 12*TICRATE + 1) + P_RestoreMusic(player);*/ + player->powers[pw_underwater] = player->powers[pw_spacetime] = 0; + } + } + if (player->spectator) { P_SpectatorMovement(player); @@ -2215,6 +2332,9 @@ static void P_MovePlayer(player_t *player) P_3dMovement(player); } + if (maptol & TOL_2D) + runspd = FixedMul(runspd, 2*FRACUNIT/3); + ///////////////////////// // MOVEMENT ANIMATIONS // ///////////////////////// @@ -2648,6 +2768,10 @@ boolean P_LookForEnemies(player_t *player) player->mo->z-mo->z) > FixedMul(RING_DIST, player->mo->scale)) continue; // out of range + if ((twodlevel || player->mo->flags2 & MF2_TWOD) + && abs(player->mo->y-mo->y) > player->mo->radius) + continue; // not in your 2d plane + if (mo->type == MT_PLAYER) // Don't chase after other players! continue; @@ -3780,7 +3904,7 @@ boolean P_MoveChaseCamera(player_t *player, camera_t *thiscam, boolean resetcall if (player->playerstate != PST_DEAD && !((player->pflags & PF_NIGHTSMODE) && player->exiting)) angle += (focusaiming < ANGLE_180 ? focusaiming/2 : InvAngle(InvAngle(focusaiming)/2)); // overcomplicated version of '((signed)focusaiming)/2;' - if (!camstill && !timeover) // Keep the view still... + if (twodlevel || (mo->flags2 & MF2_TWOD) || (!camstill && !timeover)) // Keep the view still... { G_ClipAimingPitch((INT32 *)&angle); @@ -3846,7 +3970,63 @@ boolean P_SpectatorJoinGame(player_t *player) if (P_IsLocalPlayer(player)) CONS_Printf(M_GetText("Server does not allow team change.\n")); } - else // Joining in game from firing. + // Team changing in Team Match and CTF + // Pressing fire assigns you to a team that needs players if allowed. + // Partial code reproduction from p_tick.c autobalance code. + else if (G_GametypeHasTeams()) + { + INT32 changeto = 0; + INT32 z, numplayersred = 0, numplayersblue = 0; + + //find a team by num players, score, or random if all else fails. + for (z = 0; z < MAXPLAYERS; ++z) + if (playeringame[z]) + { + if (players[z].ctfteam == 1) + ++numplayersred; + else if (players[z].ctfteam == 2) + ++numplayersblue; + } + // for z + + if (numplayersblue > numplayersred) + changeto = 1; + else if (numplayersred > numplayersblue) + changeto = 2; + else if (bluescore > redscore) + changeto = 1; + else if (redscore > bluescore) + changeto = 2; + else + changeto = (P_RandomFixed() & 1) + 1; + + if (player->mo) + { + P_RemoveMobj(player->mo); + player->mo = NULL; + } + player->spectator = false; + player->pflags &= ~PF_WANTSTOJOIN; + player->kartstuff[k_spectatewait] = 0; + player->ctfteam = changeto; + player->playerstate = PST_REBORN; + + //center camera + P_ResetLocalCamAiming(player); + + //Reset away view + if (P_IsLocalPlayer(player) && displayplayers[0] != consoleplayer) + displayplayers[0] = consoleplayer; + + if (changeto == 1) + CONS_Printf(M_GetText("%s switched to the %c%s%c.\n"), player_names[player-players], '\x85', M_GetText("Red team"), '\x80'); + else if (changeto == 2) + CONS_Printf(M_GetText("%s switched to the %c%s%c.\n"), player_names[player-players], '\x84', M_GetText("Blue team"), '\x80'); + + return true; // no more player->mo, cannot continue. + } + // Joining in game from firing. + else { if (player->mo) { @@ -4147,7 +4327,8 @@ void P_PlayerThink(player_t *player) { seenplayer = NULL; - if (cv_seenames.value && cv_allowseenames.value) + if (cv_seenames.value && cv_allowseenames.value && + !(G_TagGametype() && (player->pflags & PF_TAGIT))) { mobj_t *mo = P_SpawnNameFinder(player->mo, MT_NAMECHECK); @@ -4422,6 +4603,39 @@ void P_PlayerThink(player_t *player) { player->pflags ^= PF_WANTSTOJOIN; player->powers[pw_flashing] = TICRATE/2 + 1; + /*if (P_SpectatorJoinGame(player)) + return; // player->mo was removed.*/ + } + + // Even if not NiGHTS, pull in nearby objects when walking around as John Q. Elliot. + if (!objectplacing && !((netgame || multiplayer) && player->spectator) + && maptol & TOL_NIGHTS && (!(player->pflags & PF_NIGHTSMODE) || player->powers[pw_nights_helper])) + { + thinker_t *th; + mobj_t *mo2; + fixed_t x = player->mo->x; + fixed_t y = player->mo->y; + fixed_t z = player->mo->z; + + for (th = thinkercap.next; th != &thinkercap; th = th->next) + { + if (th->function.acp1 != (actionf_p1)P_MobjThinker) + continue; + + mo2 = (mobj_t *)th; + + if (!(mo2->type == MT_NIGHTSWING || mo2->type == MT_RING || mo2->type == MT_COIN + || mo2->type == MT_BLUEBALL)) + continue; + + if (P_AproxDistance(P_AproxDistance(mo2->x - x, mo2->y - y), mo2->z - z) > FixedMul(128*FRACUNIT, player->mo->scale)) + continue; + + // Yay! The thing's in reach! Pull it in! + mo2->flags |= MF_NOCLIP|MF_NOCLIPHEIGHT; + mo2->flags2 |= MF2_NIGHTSPULL; + P_SetTarget(&mo2->tracer, player->mo); + } } if (player->linktimer && !player->powers[pw_nights_linkfreeze]) @@ -4462,7 +4676,9 @@ void P_PlayerThink(player_t *player) P_DoBubbleBreath(player); // Spawn Sonic's bubbles P_CheckInvincibilityTimer(player); // Spawn Invincibility Sparkles + P_DoPlayerHeadSigns(player); // Spawn Tag/CTF signs over player's head +#if 1 // "Blur" a bit when you have speed shoes and are going fast enough if ((player->powers[pw_super] || player->powers[pw_sneakers] || player->kartstuff[k_driftboost] || player->kartstuff[k_sneakertimer] || player->kartstuff[k_startboost]) && !player->kartstuff[k_invincibilitytimer] // SRB2kart @@ -4490,6 +4706,7 @@ void P_PlayerThink(player_t *player) } } } +#endif // check for use if (!(player->pflags & PF_NIGHTSMODE)) @@ -4698,7 +4915,8 @@ void P_PlayerAfterThink(player_t *player) else if (cmd->forwardmove < 0 && player->mo->tracer->target->lastlook > player->mo->tracer->target->movecount) player->mo->tracer->target->lastlook -= 2; - if (!(player->mo->tracer->target->flags & MF_SLIDEME)) // Noclimb on chain parameters gives this + if (!(player->mo->tracer->target->flags & MF_SLIDEME) // Noclimb on chain parameters gives this + && !(twodlevel || player->mo->flags2 & MF2_TWOD)) // why on earth would you want to turn them in 2D mode? { player->mo->tracer->target->health += cmd->sidemove; player->mo->angle += cmd->sidemove< ANGLE_MAX diff --git a/src/r_main.c b/src/r_main.c index 5d340e5d5..6dbd8f059 100644 --- a/src/r_main.c +++ b/src/r_main.c @@ -1161,6 +1161,7 @@ void R_SkyboxFrame(int s) { player_t *player = &players[displayplayers[s]]; camera_t *thiscam = &camera[s]; + subsector_t * subsector = NULL; R_SetViewContext(VIEWCONTEXT_SKY1 + s); @@ -1168,7 +1169,7 @@ void R_SkyboxFrame(int s) newview->sky = true; viewmobj = skyboxmo[0]; #ifdef PARANOIA - if (!viewmobj) + if (P_MobjWasRemoved(viewmobj)) { const size_t playeri = (size_t)(player - players); I_Error("R_SkyboxFrame: viewmobj null (player %s)", sizeu1(playeri)); @@ -1247,7 +1248,10 @@ void R_SkyboxFrame(int s) } #undef SETUPSKYVIEW - R_SetupCommonFrame(player, viewmobj->subsector); + if (!P_MobjWasRemoved(viewmobj)) + subsector = viewmobj->subsector; + + R_SetupCommonFrame(player, subsector); } void R_SetupFrame(int s, boolean skybox) @@ -1255,6 +1259,7 @@ void R_SetupFrame(int s, boolean skybox) player_t *player = &players[displayplayers[s]]; camera_t *thiscam = &camera[s]; boolean chasecam = (cv_chasecam[s].value != 0); + subsector_t * subsector = NULL; R_SetViewContext(VIEWCONTEXT_PLAYER1 + s); if (thiscam->reset) @@ -1289,7 +1294,10 @@ void R_SetupFrame(int s, boolean skybox) newview->y = viewmobj->y; newview->z = viewmobj->z + 20*FRACUNIT; - R_SetupCommonFrame(player, viewmobj->subsector); + if (!P_MobjWasRemoved(viewmobj)) + subsector = viewmobj->subsector; + + R_SetupCommonFrame(player, subsector); } else if (!player->spectator && (thiscam && chasecam)) // use outside cam view { @@ -1310,7 +1318,10 @@ void R_SetupFrame(int s, boolean skybox) newview->y = viewmobj->y; newview->z = player->viewz; - R_SetupCommonFrame(player, viewmobj->subsector); + if (!P_MobjWasRemoved(viewmobj)) + subsector = viewmobj->subsector; + + R_SetupCommonFrame(player, subsector); } } diff --git a/src/r_things.c b/src/r_things.c index 0c3e13a1b..94d108fec 100644 --- a/src/r_things.c +++ b/src/r_things.c @@ -1116,8 +1116,6 @@ fixed_t R_GetShadowZ(mobj_t *thing, pslope_t **shadowslope) // static void R_ProjectSprite(mobj_t *thing) { - mobj_t *oldthing = thing; - fixed_t tr_x, tr_y; fixed_t gxt, gyt; fixed_t tx, tz; @@ -1135,9 +1133,6 @@ static void R_ProjectSprite(mobj_t *thing) size_t rot; UINT8 flip; - boolean mirrored = thing->mirrored; - boolean hflip = (!(thing->frame & FF_HORIZONTALFLIP) != !mirrored); - INT32 lindex; vissprite_t *vis; @@ -1149,12 +1144,12 @@ static void R_ProjectSprite(mobj_t *thing) fixed_t iscale; fixed_t scalestep; // toast '16 fixed_t offset, offset2; - boolean papersprite = (thing->frame & FF_PAPERSPRITE); fixed_t paperoffset = 0, paperdistance = 0; angle_t centerangle = 0; //SoM: 3/17/2000 fixed_t gz, gzt; INT32 heightsec, phs; + INT32 dist = -1; INT32 light = 0; fixed_t this_scale; fixed_t spritexscale, spriteyscale; @@ -1170,7 +1165,15 @@ static void R_ProjectSprite(mobj_t *thing) angle_t sliptiderollangle = 0; #endif - INT32 dist = -1; + if (P_MobjWasRemoved(thing) || thing->subsector == NULL) + return; + + mobj_t *oldthing = thing; + + const boolean mirrored = thing->mirrored; + const boolean vflip = (thing->eflags & MFE_VERTICALFLIP); + const boolean hflip = (!(thing->frame & FF_HORIZONTALFLIP) != !mirrored); + const boolean papersprite = (thing->frame & FF_PAPERSPRITE); if (cv_maxinterpdist.value) dist = R_QuickCamDist(thing->x, thing->y); @@ -1541,7 +1544,7 @@ static void R_ProjectSprite(mobj_t *thing) } //SoM: 3/17/2000: Disregard sprites that are out of view.. - if (thing->eflags & MFE_VERTICALFLIP) + if (vflip) { // When vertical flipped, draw sprites from the top down, at least as far as offsets are concerned. // sprite height - sprite topoffset is the proper inverse of the vertical offset, of course. @@ -1707,10 +1710,7 @@ static void R_ProjectSprite(mobj_t *thing) vis->precip = false; - if (thing->eflags & MFE_VERTICALFLIP) - vis->vflip = true; - else - vis->vflip = false; + vis->vflip = vflip; vis->isScaled = false; @@ -1744,6 +1744,9 @@ static void R_ProjectPrecipitationSprite(precipmobj_t *thing) INT32 dist = 1; + if (!thing || thing->subsector == NULL) + return; + if (cv_maxinterpdist.value) dist = R_QuickCamDist(thing->x, thing->y); @@ -1946,6 +1949,7 @@ void R_AddSprites(sector_t *sec, INT32 lightlevel) // Handle all things in sector. // If a limit exists, handle things a tiny bit different. const fixed_t limit_dist = (fixed_t)(cv_drawdist.value) * mapobjectscale; + for (thing = sec->thinglist; thing; thing = thing->snext) { if (!R_ThingWithinDist(thing, limit_dist)) @@ -1965,7 +1969,8 @@ void R_AddSprites(sector_t *sec, INT32 lightlevel) // void R_AddPrecipitationSprites(void) { - fixed_t drawdist = (fixed_t)(cv_drawdist_precip.value) * (cv_mobjscaleprecip.value ? mapobjectscale : FRACUNIT); + fixed_t precipscale = (cv_mobjscaleprecip.value ? mapobjectscale : FRACUNIT); + fixed_t drawdist = ((fixed_t)(cv_drawdist_precip.value) * precipscale); INT32 xl, xh, yl, yh, bx, by; precipmobj_t *th, *next; @@ -2764,7 +2769,7 @@ boolean R_ThingVisible (mobj_t *thing) if (thing->sprite == SPR_NULL || thing->flags2 & MF2_DONTDRAW) return false; - if (viewmobj && (thing == viewmobj)) + if (!P_MobjWasRemoved(viewmobj) && (thing == viewmobj)) return false; if (splitscreen) diff --git a/src/s_sound.c b/src/s_sound.c index 119b0cbb9..747585db9 100644 --- a/src/s_sound.c +++ b/src/s_sound.c @@ -652,6 +652,43 @@ void S_StartSound(const void *origin, sfxenum_t sfx_id) if (S_SoundDisabled()) return; + if (mariomode) // Sounds change in Mario mode! + { + switch (sfx_id) + { + case sfx_thok: + sfx_id = sfx_mario7; + break; + case sfx_pop: + sfx_id = sfx_mario5; + break; + case sfx_jump: + sfx_id = sfx_mario6; + break; + case sfx_shield: + sfx_id = sfx_mario3; + break; + case sfx_itemup: + sfx_id = sfx_mario4; + break; + default: + break; + } + } + if (maptol & TOL_XMAS) // Some sounds change for xmas + { + switch (sfx_id) + { + case sfx_ideya: + case sfx_nbmper: + case sfx_ncitem: + case sfx_ngdone: + ++sfx_id; + default: + break; + } + } + // the volume is handled 8 bits #ifdef HW3SOUND if (hws_mode != HWS_DEFAULT_MODE) diff --git a/src/sdl/i_video.c b/src/sdl/i_video.c index aaea21f48..ca81b8043 100644 --- a/src/sdl/i_video.c +++ b/src/sdl/i_video.c @@ -128,6 +128,10 @@ consvar_t cv_keyboardlayout = {"keyboardlayout", "Default US", CV_SAVE|CV_CALL, static void Impl_SetVsync(void); +static INT32 desktopwidth = 0, desktopheight = 0; + +static void I_CheckDesktopRes(void); + // synchronize page flipping with screen refresh consvar_t cv_vidwait = {"vid_wait", "Off", CV_SAVE|CV_CALL|CV_NOINIT, CV_OnOff, Impl_SetVsync, 0, NULL, NULL, 0, 0, NULL}; static consvar_t cv_stretch = {"stretch", "Off", CV_SAVE|CV_NOSHOWHELP, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; @@ -217,10 +221,6 @@ static SDL_bool Impl_CreateWindow(SDL_bool fullscreen); static void Impl_SetWindowIcon(void); #ifdef USE_FBO_OGL -#if defined (__unix__) -static void I_FixXwaylandNvidia(void); -boolean xwaylandcrap = false; -#endif boolean downsample = false; void RefreshOGLSDLSurface(void) { @@ -278,10 +278,8 @@ static void SDLSetMode(INT32 width, INT32 height, SDL_bool fullscreen) #ifdef HWRENDER if (rendermode == render_opengl) { + I_CheckDesktopRes(); #ifdef USE_FBO_OGL -#if defined (__unix__) - I_FixXwaylandNvidia(); -#endif I_DownSample(); #endif OglSdlSurface(vid.width, vid.height); @@ -702,92 +700,86 @@ static INT32 SDLJoyAxis(const Sint16 axis, evtype_t which) return raxis; } -boolean I_CheckNativeRes(void) +static void I_CheckDesktopRes(void) { - static int oldwidth = 0, oldheight = 0; - static boolean resstate = false; - int currentDisplayIndex = 0; + int currentDisplayIndex = -1; SDL_DisplayMode curmode; - if (oldwidth == vid.width && oldheight == vid.height) + if (desktopwidth == vid.width && desktopheight == vid.height) { - return resstate; + return; } + desktopwidth = 0; + desktopheight = 0; + currentDisplayIndex = SDL_GetWindowDisplayIndex(window); - if (SDL_GetCurrentDisplayMode(currentDisplayIndex, &curmode) != 0) + // No valid index + if (currentDisplayIndex < 0) { - return resstate; + return; } - resstate = ((vid.width == curmode.w) && (vid.height == curmode.h)); - oldwidth = vid.width; - oldheight = vid.height; - return resstate; + if (SDL_GetCurrentDisplayMode(currentDisplayIndex, &curmode) != 0) + { + return; + } + + desktopwidth = curmode.w; + desktopheight = curmode.h; +} + +boolean I_CheckNativeRes(void) +{ + return (vid.width == desktopwidth && vid.height == desktopheight); } #ifdef USE_FBO_OGL void I_DownSample(void) { - if (!cv_glframebuffer.value || !supportFBO || I_CheckNativeRes()) //no sense to do this crap if we cant benefit from it + boolean needrefresh = false; + + if (!cv_glframebuffer.value || !supportFBO || (cv_glscreentextures.value == 0)) // no sense to do this crap if we cant benefit from it { downsample = false; return; } - int currentDisplayIndex = SDL_GetWindowDisplayIndex(window); - SDL_DisplayMode curmode; - - if (SDL_GetCurrentDisplayMode(currentDisplayIndex, &curmode) != 0) + if (I_CheckNativeRes() && (downsample == true)) { - downsample = false; // couldnt get display info so turn the thing off + downsample = false; RefreshOGLSDLSurface(); return; } - if ((vid.width > curmode.w) || (vid.height > curmode.h)) //check if current resolution is higher than current display resolution + if ((vid.width > desktopwidth) || (vid.height > desktopheight)) //check if current resolution is higher than current display resolution { downsample = true; + needrefresh = true; + } + else if (downsample == true) + { + downsample = false; + needrefresh = true; + } + + if (needrefresh) + { RefreshOGLSDLSurface(); - } - else - { - if (downsample == true) - { - downsample = false; // its not so no need to do crap - RefreshOGLSDLSurface(); - } + needrefresh = false; } } - -#if defined (__unix__) -static void I_FixXwaylandNvidia(void) //dumbass crap, fix ur shit nvidia -{ - if (!supportFBO) - { - xwaylandcrap = false; - return; - } - - // enable fbo resize shit, update the ogl surface and turn crap back off lol - xwaylandcrap = true; - RefreshOGLSDLSurface(); - xwaylandcrap = false; - RefreshOGLSDLSurface(); -} -#endif #endif static void Impl_HandleWindowEvent(SDL_WindowEvent evt) { #define FOCUSUNION (mousefocus | (kbfocus << 1) | (windowmoved << 2)) + static SDL_bool firsttimeonmouse = SDL_TRUE; static SDL_bool mousefocus = SDL_TRUE; static SDL_bool kbfocus = SDL_TRUE; -#ifdef USE_FBO_OGL static SDL_bool windowmoved = SDL_FALSE; -#endif const unsigned int oldfocus = FOCUSUNION; @@ -809,11 +801,9 @@ static void Impl_HandleWindowEvent(SDL_WindowEvent evt) break; case SDL_WINDOWEVENT_MAXIMIZED: break; -#ifdef USE_FBO_OGL case SDL_WINDOWEVENT_MOVED: windowmoved = SDL_TRUE; break; -#endif } if (FOCUSUNION == oldfocus) // No state change @@ -821,12 +811,13 @@ static void Impl_HandleWindowEvent(SDL_WindowEvent evt) return; } -#ifdef USE_FBO_OGL if (windowmoved && rendermode == render_opengl) { + I_CheckDesktopRes(); +#ifdef USE_FBO_OGL I_DownSample(); - } #endif + } if (mousefocus && kbfocus) { diff --git a/src/sdl/ogl_sdl.c b/src/sdl/ogl_sdl.c index fa18c0b1b..eeac3b84b 100644 --- a/src/sdl/ogl_sdl.c +++ b/src/sdl/ogl_sdl.c @@ -69,15 +69,16 @@ PFNglGetString pglGetString; #endif #ifdef USE_FBO_OGL + #if defined (__unix__) -static boolean isnvidiagpu = false; +static boolean xwaylandcrap = false; #endif boolean UseScreenFBO(void) { return ((supportFBO && cv_glframebuffer.value && downsample) #if defined (__unix__) - || (supportFBO && isnvidiagpu && xwaylandcrap) + || (supportFBO && xwaylandcrap) #endif ); } @@ -187,8 +188,8 @@ boolean OglSdlSurface(INT32 w, INT32 h) #if defined (__unix__) #ifdef USE_FBO_OGL - if (strstr((const char*)gl_renderer, "NVIDIA")) - isnvidiagpu = true; + if (supportFBO && strstr((const char*)gl_renderer, "NVIDIA")) + xwaylandcrap = true; #endif #endif } @@ -213,13 +214,6 @@ boolean OglSdlSurface(INT32 w, INT32 h) pglClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT|GL_STENCIL_BUFFER_BIT); #ifdef USE_FBO_OGL - - if (!supportFBO) - { - if (cv_glframebuffer.value) - CV_SetValue(&cv_glframebuffer, 0); - } - if (UseScreenFBO()) GLFramebuffer_Enable(); else @@ -245,6 +239,11 @@ void OglSdlFinishUpdate(boolean waitvbl) { static boolean oldwaitvbl = false; int sdlw, sdlh; + +#ifdef USE_FBO_OGL + const boolean usefbo = UseScreenFBO(); +#endif + if (oldwaitvbl != waitvbl) { SDL_GL_SetSwapInterval(waitvbl ? 1 : 0); @@ -256,15 +255,19 @@ void OglSdlFinishUpdate(boolean waitvbl) HWR_MakeScreenFinalTexture(); #ifdef USE_FBO_OGL - if (UseScreenFBO()) + if (usefbo) + { GLFramebuffer_Unbind(); + } #endif HWR_DrawScreenFinalTexture(sdlw, sdlh, HWR_ShouldUsePaletteRendering()); #ifdef USE_FBO_OGL - if (UseScreenFBO()) + if (usefbo) + { GLFramebuffer_Enable(); + } #endif SDL_GL_SwapWindow(window); @@ -273,12 +276,19 @@ void OglSdlFinishUpdate(boolean waitvbl) // Sryder: We need to draw the final screen texture again into the other buffer in the original position so that // effects that want to take the old screen can do so after this - if ((!I_CheckNativeRes()) // well we dont need it on native res it seems + // well we dont need it on native res it seems #ifdef USE_FBO_OGL - && (!UseScreenFBO()) + if ((!I_CheckNativeRes() && !usefbo) || WipeInAction) +#else + if (!I_CheckNativeRes() || WipeInAction) #endif - ) HWR_DrawScreenFinalTexture(realwidth, realheight, false); + +#if defined (__unix__) +#ifdef USE_FBO_OGL + xwaylandcrap = false; +#endif +#endif } EXPORT void HWRAPI(OglSdlSetPalette) (RGBA_t *palette) diff --git a/src/sounds.c b/src/sounds.c index 51961b906..c3d92c853 100644 --- a/src/sounds.c +++ b/src/sounds.c @@ -14,7 +14,7 @@ #include "doomtype.h" #include "i_sound.h" #include "sounds.h" -#include "s_sound.h" //for soundprecaching +#include "s_sound.h" // for soundprecaching #include "m_argv.h" #include "r_defs.h" #include "r_things.h" diff --git a/src/sounds.h b/src/sounds.h index 6621dc6bf..a6128189d 100644 --- a/src/sounds.h +++ b/src/sounds.h @@ -14,6 +14,8 @@ #ifndef __SOUNDS__ #define __SOUNDS__ +#include "doomdef.h" + // Customisable sounds for Skins typedef enum { diff --git a/src/st_stuff.c b/src/st_stuff.c index 05d5bcfc3..30b8b5cf7 100644 --- a/src/st_stuff.c +++ b/src/st_stuff.c @@ -220,6 +220,13 @@ boolean ST_SameTeam(player_t *a, player_t *b) if (a->spectator && b->spectator) return true; + // Team chat. + if (G_GametypeHasTeams()) + return a->ctfteam == b->ctfteam; + + if (G_TagGametype()) + return ((a->pflags & PF_TAGIT) == (b->pflags & PF_TAGIT)); + return false; } @@ -743,6 +750,8 @@ static void ST_overlayDrawer(void) itemtxt = M_GetText("Item - . . ."); else if (stplyr->pflags & PF_WANTSTOJOIN) itemtxt = M_GetText("Item - Cancel Join"); + else if (G_GametypeHasTeams()) + itemtxt = M_GetText("Item - Join Team"); if (cv_ingamecap.value) { @@ -952,10 +961,10 @@ void ST_Drawer(void) V_DrawCenteredString(BASEVIDWIDTH/2, BASEVIDHEIGHT/2 + 15, V_HUDTRANSHALF, player_names[seenplayer-players]); else if (cv_seenames.value == 2) V_DrawCenteredString(BASEVIDWIDTH/2, BASEVIDHEIGHT/2 + 15, V_HUDTRANSHALF, - va("%s%s", "", player_names[seenplayer-players])); + va("%s%s", G_GametypeHasTeams() ? ((seenplayer->ctfteam == 1) ? "\x85" : "\x84") : "", player_names[seenplayer-players])); else //if (cv_seenames.value == 3) V_DrawCenteredString(BASEVIDWIDTH/2, BASEVIDHEIGHT/2 + 15, V_HUDTRANSHALF, - va("%s%s", !G_BattleGametype() + va("%s%s", !G_BattleGametype() || (G_GametypeHasTeams() && players[consoleplayer].ctfteam == seenplayer->ctfteam) ? "\x83" : "\x85", player_names[seenplayer-players])); } #endif diff --git a/src/v_video.c b/src/v_video.c index d2604b5e8..987a40a03 100644 --- a/src/v_video.c +++ b/src/v_video.c @@ -138,7 +138,11 @@ static boolean InitCube(void) #define diffcons(cv) (cv.value != atoi(cv.defaultvalue)) +#ifdef BACKWARDSCOMPATCORRECTION + doinggamma = (cv_globalgamma.value < 0); //dont mess up gamma when raising brightness pls +#else doinggamma = diffcons(cv_globalgamma); +#endif #define gammascale 8 globalgammamul = (cv_globalgamma.value ? ((255 - (gammascale*abs(cv_globalgamma.value)))/255.0) : 1.0); @@ -438,44 +442,21 @@ static void LoadPalette(const char *lumpname) pLocalPalette[i].s.alpha = 0xFF; // lerp of colour cubing! if you want, make it smoother yourself - if (Cubeapply) - V_CubeApply(&pLocalPalette[i].s.red, &pLocalPalette[i].s.green, &pLocalPalette[i].s.blue); + + if (!Cubeapply) + continue; + + V_CubeApply(&pLocalPalette[i].s.red, &pLocalPalette[i].s.green, &pLocalPalette[i].s.blue); } } -#ifdef BACKWARDSCOMPATCORRECTION -static boolean V_ShouldCube(void) -{ -#define diffcons(cv) (cv.value != atoi(cv.defaultvalue)) - return (diffcons(cv_globalsaturation) - || diffcons(cv_rhue) - || diffcons(cv_yhue) - || diffcons(cv_ghue) - || diffcons(cv_chue) - || diffcons(cv_bhue) - || diffcons(cv_mhue) - || diffcons(cv_rgamma) - || diffcons(cv_ygamma) - || diffcons(cv_ggamma) - || diffcons(cv_cgamma) - || diffcons(cv_bgamma) - || diffcons(cv_mgamma) - || (cv_globalgamma.value <= 0)); -#undef diffcons -} -#endif - void V_CubeApply(UINT8 *red, UINT8 *green, UINT8 *blue) { float working[4][3]; float linear; UINT8 q; - if (!Cubeapply -#ifdef BACKWARDSCOMPATCORRECTION - || !V_ShouldCube() -#endif - ) + if (!Cubeapply) return; linear = (*red/255.0); @@ -1170,32 +1151,37 @@ void V_DrawFill(INT32 x, INT32 y, INT32 w, INT32 h, INT32 c) // This is now a function since it's otherwise repeated 2 times and honestly looks retarded: static UINT32 V_GetHWConsBackColor(void) { - UINT32 hwcolor; + UINT8 r, g, b; + switch (cons_backcolor.value) { - case 0: hwcolor = 0xffffff00; break; // White - case 1: hwcolor = 0x80808000; break; // Gray - case 2: hwcolor = 0xdeb88700; break; // Sepia - case 3: hwcolor = 0x40201000; break; // Brown - case 4: hwcolor = 0xfa807200; break; // Pink - case 5: hwcolor = 0xff69b400; break; // Raspberry - case 6: hwcolor = 0xff000000; break; // Red - case 7: hwcolor = 0xffd68300; break; // Creamsicle - case 8: hwcolor = 0xff800000; break; // Orange - case 9: hwcolor = 0xdaa52000; break; // Gold - case 10: hwcolor = 0x80800000; break; // Yellow - case 11: hwcolor = 0x00ff0000; break; // Emerald - case 12: hwcolor = 0x00800000; break; // Green - case 13: hwcolor = 0x4080ff00; break; // Cyan - case 14: hwcolor = 0x4682b400; break; // Steel - case 15: hwcolor = 0x1e90ff00; break; // Periwinkle - case 16: hwcolor = 0x0000ff00; break; // Blue - case 17: hwcolor = 0xff00ff00; break; // Purple - case 18: hwcolor = 0xee82ee00; break; // Lavender + case 0: r = 0xff; g = 0xff; b = 0xff; break; // White + case 1: r = 0x80; g = 0x80; b = 0x80; break; // Black + case 2: r = 0xde; g = 0xb8; b = 0x87; break; // Sepia + case 3: r = 0x40; g = 0x20; b = 0x10; break; // Brown + case 4: r = 0xfa; g = 0x80; b = 0x72; break; // Pink + case 5: r = 0xff; g = 0x69; b = 0xb4; break; // Raspberry + case 6: r = 0xff; g = 0x00; b = 0x00; break; // Red + case 7: r = 0xff; g = 0xd6; b = 0x83; break; // Creamsicle + case 8: r = 0xff; g = 0x80; b = 0x00; break; // Orange + case 9: r = 0xda; g = 0xa5; b = 0x20; break; // Gold + case 10: r = 0x80; g = 0x80; b = 0x00; break; // Yellow + case 11: r = 0x00; g = 0xff; b = 0x00; break; // Emerald + case 12: r = 0x00; g = 0x80; b = 0x00; break; // Green + case 13: r = 0x40; g = 0x80; b = 0xff; break; // Cyan + case 14: r = 0x46; g = 0x82; b = 0xb4; break; // Steel + case 15: r = 0x1e; g = 0x90; b = 0xff; break; // Periwinkle + case 16: r = 0x00; g = 0x00; b = 0xff; break; // Blue + case 17: r = 0xff; g = 0x00; b = 0xff; break; // Purple + case 18: r = 0xee; g = 0x82; b = 0xee; break; // Lavender // Default green - default: hwcolor = 0x00800000; break; + default: r = 0x00; g = 0x80; b = 0x00; break; } - return hwcolor; + + if (!HWR_ShouldUsePaletteRendering()) + V_CubeApply(&r, &g, &b); + + return (r << 24) | (g << 16) | (b << 8); } #endif diff --git a/src/y_inter.c b/src/y_inter.c index 55e092eaa..61f4a069b 100644 --- a/src/y_inter.c +++ b/src/y_inter.c @@ -810,7 +810,9 @@ void Y_StartIntermission(void) } else { - if (demo.playback) // Override inttime (which is pulled from the replay anyway + if (cv_inttime.value == 0 && gametype == GT_COOP) + timer = 0; + else if (demo.playback) // Override inttime (which is pulled from the replay anyway timer = 10*TICRATE; else {