diff --git a/src/d_netcmd.c b/src/d_netcmd.c index 8357e99b..f08c7554 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -3117,12 +3117,12 @@ static void Got_Teamchange(UINT8 **cp, INT32 playernum) { if (!players[playernum].spectator) P_DamageMobj(players[playernum].mo, NULL, NULL, 10000); - else + /*else { P_RemoveMobj(players[playernum].mo); players[playernum].mo = NULL; players[playernum].playerstate = PST_REBORN; - } + }*/ } else players[playernum].playerstate = PST_REBORN; @@ -3139,7 +3139,7 @@ static void Got_Teamchange(UINT8 **cp, INT32 playernum) } else if (NetPacket.packet.newteam != 3) // .newteam == 1 or 2. { - players[playernum].spectator = false; + 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. @@ -3149,7 +3149,7 @@ static void Got_Teamchange(UINT8 **cp, INT32 playernum) } else // Just join the game. { - players[playernum].spectator = false; + 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))) @@ -3169,7 +3169,7 @@ static void Got_Teamchange(UINT8 **cp, INT32 playernum) else { players[playernum].ctfteam = NetPacket.packet.newteam; - players[playernum].spectator = false; + players[playernum].pflags |= PF_WANTSTOJOIN; //players[playernum].spectator = false; } } else if (G_GametypeHasSpectators()) @@ -3177,7 +3177,7 @@ static void Got_Teamchange(UINT8 **cp, INT32 playernum) if (!NetPacket.packet.newteam) players[playernum].spectator = true; else - players[playernum].spectator = false; + players[playernum].pflags |= PF_WANTSTOJOIN; //players[playernum].spectator = false; } if (NetPacket.packet.autobalance) @@ -3209,7 +3209,7 @@ static void Got_Teamchange(UINT8 **cp, INT32 playernum) 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 == 3) - CONS_Printf(M_GetText("%s entered the game.\n"), player_names[playernum]); + /*CONS_Printf(M_GetText("%s entered the game.\n"), player_names[playernum])*/; else CONS_Printf(M_GetText("%s became a spectator.\n"), player_names[playernum]); diff --git a/src/d_player.h b/src/d_player.h index d2a9de0a..f184d4cf 100644 --- a/src/d_player.h +++ b/src/d_player.h @@ -108,8 +108,8 @@ typedef enum // Did you get a time-over? PF_TIMEOVER = 1<<10, - // Ready for Super? - PF_SUPERREADY = 1<<11, + // SRB2Kart: Spectator that wants to join + PF_WANTSTOJOIN = 1<<11, // Character action status PF_JUMPED = 1<<12, diff --git a/src/dehacked.c b/src/dehacked.c index 0c37bda6..1c2ac477 100644 --- a/src/dehacked.c +++ b/src/dehacked.c @@ -7391,8 +7391,8 @@ static const char *const PLAYERFLAG_LIST[] = { // Did you get a time-over? "TIMEOVER", - // Ready for Super? - "SUPERREADY", + // SRB2Kart: spectator that wants to join + "WANTSTOJOIN", // Character action status "JUMPED", diff --git a/src/g_game.c b/src/g_game.c index 0e12bcda..a57ac794 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -2175,6 +2175,9 @@ void G_Ticker(boolean run) if (run) { + if (G_GametypeHasSpectators() && (gamestate == GS_LEVEL || gamestate == GS_INTERMISSION || gamestate == GS_VOTING)) + K_CheckSpectateStatus(); + if (pausedelay) pausedelay--; @@ -2227,14 +2230,6 @@ static inline void G_PlayerFinishLevel(INT32 player) p->starpostnum = 0; p->starpostcount = 0; - // SRB2Kart: exitlevel shouldn't get you the points - if (!p->exiting && !(p->pflags & PF_TIMEOVER)) - { - p->pflags |= PF_TIMEOVER; - if (G_RaceGametype()) - S_ChangeMusicInternal("racent", true); - } - // SRB2kart: Increment the "matches played" counter. if (player == consoleplayer) { @@ -3232,7 +3227,7 @@ INT16 G_RandMap(INT16 tolflags, INT16 pprevmap, boolean dontadd, boolean ignoreb // static void G_DoCompleted(void) { - INT32 i; + INT32 i, j = 0; boolean gottoken = false; tokenlist = 0; // Reset the list @@ -3246,7 +3241,20 @@ static void G_DoCompleted(void) for (i = 0; i < MAXPLAYERS; i++) if (playeringame[i]) + { + // SRB2Kart: exitlevel shouldn't get you the points + if (!players[i].exiting && !(players[i].pflags & PF_TIMEOVER)) + { + players[i].pflags |= PF_TIMEOVER; + if (P_IsLocalPlayer(&players[i])) + j++; + } G_PlayerFinishLevel(i); // take away cards and stuff + } + + // play some generic music if there's no win/cool/lose music going on (for exitlevel commands) + if (G_RaceGametype() && j == splitscreen+1) + S_ChangeMusicInternal("racent", true); if (automapactive) AM_Stop(); diff --git a/src/info.c b/src/info.c index ae55d144..d30a2d17 100644 --- a/src/info.c +++ b/src/info.c @@ -2565,12 +2565,12 @@ state_t states[NUMSTATES] = {SPR_RPOP, FF_FULLBRIGHT|2, 5, {NULL}, 0, 0, S_RANDOMITEMPOP4}, // S_RANDOMITEMPOP3 {SPR_RPOP, FF_FULLBRIGHT|3, 5, {NULL}, 0, 0, S_NULL}, // S_RANDOMITEMPOP4 - {SPR_DRIF, 0, 2, {NULL}, 0, 0, S_DRIFTSPARK2}, // S_DRIFTSPARK1 - {SPR_DRIF, 1, 2, {NULL}, 0, 0, S_DRIFTSPARK3}, // S_DRIFTSPARK2 - {SPR_DRIF, 2, 2, {NULL}, 0, 0, S_DRIFTSPARK1}, // S_DRIFTSPARK3 - {SPR_DRIF, 3, 2, {NULL}, 0, 0, S_DRIFTSPARK5}, // S_DRIFTSPARK4 - {SPR_DRIF, 4, 2, {NULL}, 0, 0, S_DRIFTSPARK6}, // S_DRIFTSPARK5 - {SPR_DRIF, 5, 2, {NULL}, 0, 0, S_DRIFTSPARK4}, // S_DRIFTSPARK6 + {SPR_DRIF, 0|FF_FULLBRIGHT, 2, {NULL}, 0, 0, S_DRIFTSPARK2}, // S_DRIFTSPARK1 + {SPR_DRIF, 1|FF_FULLBRIGHT, 2, {NULL}, 0, 0, S_DRIFTSPARK3}, // S_DRIFTSPARK2 + {SPR_DRIF, 2|FF_FULLBRIGHT, 2, {NULL}, 0, 0, S_DRIFTSPARK1}, // S_DRIFTSPARK3 + {SPR_DRIF, 3|FF_FULLBRIGHT, 2, {NULL}, 0, 0, S_DRIFTSPARK5}, // S_DRIFTSPARK4 + {SPR_DRIF, 4|FF_FULLBRIGHT, 2, {NULL}, 0, 0, S_DRIFTSPARK6}, // S_DRIFTSPARK5 + {SPR_DRIF, 5|FF_FULLBRIGHT, 2, {NULL}, 0, 0, S_DRIFTSPARK4}, // S_DRIFTSPARK6 {SPR_DUST, 0, 3, {NULL}, 0, 0, S_DRIFTDUST2}, // S_DRIFTDUST1 {SPR_DUST, 1, 3, {NULL}, 0, 0, S_DRIFTDUST3}, // S_DRIFTDUST2 diff --git a/src/k_kart.c b/src/k_kart.c index 578ac11b..02ce994c 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -3444,10 +3444,6 @@ void K_MoveKartPlayer(player_t *player, boolean onground) if (player->kartstuff[k_positiondelay]) player->kartstuff[k_positiondelay]--; - // Race force spectate - if (player->spectator && netgame && G_RaceGametype() && P_FindHighestLap() > 0) - player->powers[pw_flashing] = 5; - if ((player->pflags & PF_ATTACKDOWN) && !(cmd->buttons & BT_ATTACK)) player->pflags &= ~PF_ATTACKDOWN; else if (cmd->buttons & BT_ATTACK) @@ -4157,6 +4153,49 @@ void K_CheckBumpers(void) P_DoPlayerExit(&players[i]); } +void K_CheckSpectateStatus(void) +{ + UINT8 respawnlist[MAXPLAYERS]; + UINT8 i, no = 0; + UINT8 numingame = 0, numjoiners = 0; + + for (i = 0; i < MAXPLAYERS; i++) + { + if (!playeringame[i]) + continue; + + if (!players[i].spectator) + { + numingame++; + if (gamestate != GS_LEVEL) + continue; + if (G_RaceGametype() && players[i].laps > 0) + return; + } + + if (cv_allowteamchange.value && !(players[i].pflags & PF_WANTSTOJOIN)) + continue; + + respawnlist[no++] = i; + } + + numjoiners = no; // Move the map change stuff up here when it gets a delay, and remove this redundant numjoiners var + + while (no) + P_SpectatorJoinGame(&players[respawnlist[--no]]); + + if (!server) + return; + + // Reset the match if you're in an empty server, TODO: put it on a short 5-10 second timer, so you have a chance to roam. + if (gamestate == GS_LEVEL && (numingame < 2 && numingame+numjoiners >= 2)) + { + CONS_Printf("Here comes a new challenger! Resetting map...\n"); + D_MapChange(gamemap, gametype, ultimatemode, true, 0, false, false); + return; + } +} + //} //{ SRB2kart HUD Code @@ -5464,19 +5503,24 @@ static void K_drawKartFinish(void) if ((stplyr->kartstuff[k_cardanimation] % (2*5)) / 5) // blink pnum = 1; - if (splitscreen) + if (splitscreen > 1) { V_DrawTinyScaledPatch(STCD_X - (SHORT(kp_racefinish[pnum]->width)/8), STCD_Y - (SHORT(kp_racefinish[pnum]->height)/8), splitflags, kp_racefinish[pnum]); return; } { - INT32 x = ((vid.width<width)<<(FRACBITS)); + INT32 scaleshift = (FRACBITS - splitscreen); // FRACUNIT or FRACUNIT/2 + INT32 x = ((vid.width<width)<kartstuff[k_cardanimation])*(xval > x ? xval : x))/TICRATE; - V_DrawFixedPatch(x + ((STCD_X - (SHORT(kp_racefinish[pnum]->width)/2))<height)/2))<width)<<(scaleshift-1)), + (STCD_Y<height)<<(scaleshift-1)), + (1<powers[pw_emeralds])) && player->health > 50) + /*if ((ALL7EMERALDS(emeralds) || ALL7EMERALDS(player->powers[pw_emeralds])) && player->health > 50) player->pflags |= PF_SUPERREADY; else - player->pflags &= ~PF_SUPERREADY; + player->pflags &= ~PF_SUPERREADY;*/ if (player->powers[pw_super]) { @@ -3690,7 +3690,7 @@ static void P_DoSuperStuff(player_t *player) // // Returns true if player is ready to turn super, duh // -boolean P_SuperReady(player_t *player) +/*boolean P_SuperReady(player_t *player) { if ((player->pflags & PF_SUPERREADY) && !player->powers[pw_super] && !player->powers[pw_tailsfly] && !(player->powers[pw_shield] & SH_NOSTACK) @@ -3701,7 +3701,7 @@ boolean P_SuperReady(player_t *player) return true; return false; -} +}*/ // // P_DoJump @@ -8814,20 +8814,13 @@ boolean P_MoveChaseCamera(player_t *player, camera_t *thiscam, boolean resetcall boolean P_SpectatorJoinGame(player_t *player) { - if (!G_GametypeHasSpectators() && G_IsSpecialStage(gamemap) && useNightsSS) // Special Stage spectators should NEVER be allowed to rejoin the game - { - if (P_IsLocalPlayer(player)) - CONS_Printf(M_GetText("You cannot enter the game while a special stage is in progress.\n")); - player->powers[pw_flashing] += 2*TICRATE; //to prevent message spam. - } - - else if (!cv_allowteamchange.value) + // Team changing isn't allowed. + if (!cv_allowteamchange.value) { if (P_IsLocalPlayer(player)) CONS_Printf(M_GetText("Server does not allow team change.\n")); player->powers[pw_flashing] += 2*TICRATE; //to prevent message spam. } - // 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. @@ -8864,6 +8857,7 @@ boolean P_SpectatorJoinGame(player_t *player) player->mo = NULL; } player->spectator = false; + player->pflags &= ~PF_WANTSTOJOIN; player->ctfteam = changeto; player->playerstate = PST_REBORN; @@ -8881,43 +8875,21 @@ boolean P_SpectatorJoinGame(player_t *player) // Joining in game from firing. else { - // Exception for hide and seek. Don't join a game when you simply - // respawn in place and sit there for the rest of the round. - if (!(gametype == GT_HIDEANDSEEK && leveltime > (hidetime * TICRATE))) + if (player->mo) { - if (player->mo) - { - P_RemoveMobj(player->mo); - player->mo = NULL; - } - player->spectator = false; - player->playerstate = PST_REBORN; - - if (gametype == GT_TAG) - { - //Make joining players "it" after hidetime. - if (leveltime > (hidetime * TICRATE)) - { - CONS_Printf(M_GetText("%s is now IT!\n"), player_names[player-players]); // Tell everyone who is it! - player->pflags |= PF_TAGIT; - } - - P_CheckSurvivors(); - } - - //Reset away view - if (P_IsLocalPlayer(player) && displayplayer != consoleplayer) - displayplayer = consoleplayer; - - CONS_Printf(M_GetText("%s entered the game.\n"), player_names[player-players]); - return true; // no more player->mo, cannot continue. - } - else - { - if (P_IsLocalPlayer(player)) - CONS_Printf(M_GetText("You must wait until next round to enter the game.\n")); - player->powers[pw_flashing] += 2*TICRATE; //to prevent message spam. + P_RemoveMobj(player->mo); + player->mo = NULL; } + player->spectator = false; + player->pflags &= ~PF_WANTSTOJOIN; + player->playerstate = PST_REBORN; + + //Reset away view + if (P_IsLocalPlayer(player) && displayplayer != consoleplayer) + displayplayer = consoleplayer; + + CONS_Printf(M_GetText("%s entered the game.\n"), player_names[player-players]); + return true; // no more player->mo, cannot continue. } return false; } @@ -9335,8 +9307,10 @@ void P_PlayerThink(player_t *player) if ((netgame || splitscreen) && player->spectator && cmd->buttons & BT_ATTACK && !player->powers[pw_flashing]) { - if (P_SpectatorJoinGame(player)) - return; // player->mo was removed. + player->pflags ^= PF_WANTSTOJOIN; + player->powers[pw_flashing] += 2*TICRATE; + /*if (P_SpectatorJoinGame(player)) + return; // player->mo was removed.*/ } // Even if not NiGHTS, pull in nearby objects when walking around as John Q. Elliot. diff --git a/src/st_stuff.c b/src/st_stuff.c index aff392af..aecfe34d 100644 --- a/src/st_stuff.c +++ b/src/st_stuff.c @@ -1952,12 +1952,12 @@ static void ST_overlayDrawer(void) { // SRB2kart: changed positions & text V_DrawString(2, BASEVIDHEIGHT-50, V_HUDTRANSHALF|V_YELLOWMAP, M_GetText("- SPECTATING -")); - /*if (G_GametypeHasTeams()) - V_DrawString(2, BASEVIDHEIGHT-40, V_HUDTRANSHALF, M_GetText("Item - Join Team")); - else if (G_IsSpecialStage(gamemap) && useNightsSS) - V_DrawString(2, BASEVIDHEIGHT-40, V_HUDTRANSHALF|V_REDMAP, M_GetText("- CANNOT JOIN -")); - else*/ - V_DrawString(2, BASEVIDHEIGHT-40, V_HUDTRANSHALF, M_GetText("Item - Enter Game")); + if (stplyr->pflags & PF_WANTSTOJOIN) + V_DrawString(2, BASEVIDHEIGHT-40, V_HUDTRANSHALF, M_GetText("Item - Cancel Join")); + /*else if (G_GametypeHasTeams()) + V_DrawString(2, BASEVIDHEIGHT-40, V_HUDTRANSHALF, M_GetText("Item - Join Team"));*/ + else + V_DrawString(2, BASEVIDHEIGHT-40, V_HUDTRANSHALF, M_GetText("Item - Join Game")); V_DrawString(2, BASEVIDHEIGHT-30, V_HUDTRANSHALF, M_GetText("F12 - Change View")); V_DrawString(2, BASEVIDHEIGHT-20, V_HUDTRANSHALF, M_GetText("Accelerate - Float")); V_DrawString(2, BASEVIDHEIGHT-10, V_HUDTRANSHALF, M_GetText("Brake - Sink"));