about summary refs log tree commit diff
path: root/src/game
diff options
context:
space:
mode:
Diffstat (limited to 'src/game')
-rw-r--r--src/game/server/gamecontext.cpp5
-rw-r--r--src/game/server/player.cpp4
-rw-r--r--src/game/server/player.h1
3 files changed, 8 insertions, 2 deletions
diff --git a/src/game/server/gamecontext.cpp b/src/game/server/gamecontext.cpp
index 2374d5ff..e4c66cff 100644
--- a/src/game/server/gamecontext.cpp
+++ b/src/game/server/gamecontext.cpp
@@ -1093,8 +1093,9 @@ void CGameContext::OnMessage(int MsgID, CUnpacker *pUnpacker, int ClientID)
 			}
 			else
 			{
-				char aBuf[256];
-				str_format(aBuf, sizeof(aBuf), "You will join automatically when \"%s\" dies.", Server()->ClientName(pPlayer->m_CaughtBy));
+				char aBuf[128];
+				pPlayer->m_zCatchJoinSpecWhenReleased = !pPlayer->m_zCatchJoinSpecWhenReleased;
+				str_format(aBuf, sizeof(aBuf), "You will join the %s when '%s' dies.", m_pController->GetTeamName(pPlayer->m_zCatchJoinSpecWhenReleased ? TEAM_SPECTATORS : TEAM_RED), Server()->ClientName(pPlayer->m_CaughtBy));
 				SendChatTarget(ClientID, aBuf);
 				return;
 			}
diff --git a/src/game/server/player.cpp b/src/game/server/player.cpp
index d2d621b7..91a75c9d 100644
--- a/src/game/server/player.cpp
+++ b/src/game/server/player.cpp
@@ -421,6 +421,7 @@ void CPlayer::AddZCatchVictim(int ClientID, int reason)
 		// set victim's status
 		victim->m_CaughtBy = m_ClientID;
 		victim->m_SpecExplicit = false;
+		victim->m_zCatchJoinSpecWhenReleased = false;
 		victim->SetTeamDirect(TEAM_SPECTATORS);
 		victim->m_SpectatorID = m_ClientID;
 	}
@@ -443,6 +444,9 @@ void CPlayer::ReleaseZCatchVictim(int ClientID, int limit)
 				victim->m_CaughtBy = ZCATCH_NOT_CAUGHT;
 				victim->SetTeamDirect(GameServer()->m_pController->ClampTeam(1));
 				victim->m_SpectatorID = SPEC_FREEVIEW;
+				// SetTeam after SetTeamDirect, otherwise it would skip the message for joining the spectators
+				if(victim->m_zCatchJoinSpecWhenReleased)
+					victim->SetTeam(GameServer()->m_pController->ClampTeam(TEAM_SPECTATORS));
 			}
 			// delete from list
 			tmp = (*v)->prev;
diff --git a/src/game/server/player.h b/src/game/server/player.h
index e6595245..97fb299c 100644
--- a/src/game/server/player.h
+++ b/src/game/server/player.h
@@ -130,6 +130,7 @@ public:
 	CZCatchVictim *m_ZCatchVictims;
 	int m_zCatchNumVictims;
 	int m_zCatchNumKillsInARow;
+	bool m_zCatchJoinSpecWhenReleased;
 	void AddZCatchVictim(int ClientID, int reason = ZCATCH_CAUGHT_REASON_JOINING);
 	void ReleaseZCatchVictim(int ClientID, int limit = 0);
 	bool HasZCatchVictims() { return (m_ZCatchVictims != NULL); }