diff --git a/src/game/ddracechat.h b/src/game/ddracechat.h index 285e9023e..2cc4790e1 100644 --- a/src/game/ddracechat.h +++ b/src/game/ddracechat.h @@ -27,7 +27,7 @@ CHAT_COMMAND("dnd", "", CFGFLAG_CHAT | CFGFLAG_SERVER | CFGFLAG_NONTEEHISTORIC, CHAT_COMMAND("mapinfo", "?r[map]", CFGFLAG_CHAT | CFGFLAG_SERVER, ConMapInfo, this, "Show info about the map with name r gives (current map by default)") CHAT_COMMAND("timeout", "?s[code]", CFGFLAG_CHAT | CFGFLAG_SERVER, ConTimeout, this, "Set timeout protection code s") CHAT_COMMAND("practice", "?i['0'|'1']", CFGFLAG_CHAT | CFGFLAG_SERVER, ConPractice, this, "Enable cheats (currently only /rescue) for your current team's run, but you can't earn a rank") -CHAT_COMMAND("swap", "?r[player name]", CFGFLAG_CHAT | CFGFLAG_SERVER, ConSwap, this, "Swaps your position with a teammates") +CHAT_COMMAND("swap", "?r[player name]", CFGFLAG_CHAT | CFGFLAG_SERVER, ConSwap, this, "Request to swap your tee with another team member") CHAT_COMMAND("save", "?r[code]", CFGFLAG_CHAT | CFGFLAG_SERVER, ConSave, this, "Save team with code r.") CHAT_COMMAND("load", "?r[code]", CFGFLAG_CHAT | CFGFLAG_SERVER, ConLoad, this, "Load with code r. /load to check your existing saves") CHAT_COMMAND("map", "?r[map]", CFGFLAG_CHAT | CFGFLAG_SERVER | CFGFLAG_NONTEEHISTORIC, ConMap, this, "Vote a map by name") diff --git a/src/game/server/ddracechat.cpp b/src/game/server/ddracechat.cpp index a77e41d96..bc51cc084 100644 --- a/src/game/server/ddracechat.cpp +++ b/src/game/server/ddracechat.cpp @@ -712,44 +712,37 @@ void CGameContext::ConSwap(IConsole::IResult *pResult, void *pUserData) } } - bool TargetNotFound = TargetClientId < 0; - if(TargetNotFound) + if(TargetClientId < 0) { pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "swap", "Player not found"); return; } - bool TargetIsSelf = TargetClientId == pResult->m_ClientID; - if(TargetIsSelf) + if(TargetClientId == pResult->m_ClientID) { - pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "swap", "Can't swap with yourself."); + pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "swap", "Can't swap with yourself"); return; } int TargetTeam = Teams.m_Core.Team(TargetClientId); - bool DifferentTeam = TargetTeam != Team; - if(DifferentTeam) + if(TargetTeam != Team) { pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "swap", "Player on a different team"); return; } - CPlayer *pSwapPlayer = pSelf->m_apPlayers[TargetClientId]; - if(!pSwapPlayer) - { //Not sure what could cause this state. - pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "swap", "Swap failed, try again in a few seconds."); - return; - } + CPlayer *pSwapPlayer = pSelf->m_apPlayers[TargetClientId]; + bool SwapPending = pSwapPlayer->m_ClientSwapID != pResult->m_ClientID; if(SwapPending) { pPlayer->m_ClientSwapID = TargetClientId; - pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "swap", "Swap request sent. Player needs to confirm swap."); + pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "swap", "Swap request sent. The player needs to confirm it."); char aBuf[512]; - str_format(aBuf, sizeof(aBuf), "'%s' has requested to swap positions with you. Type /swap to confirm the swap.)", pSelf->Server()->ClientName(pResult->m_ClientID)); + str_format(aBuf, sizeof(aBuf), "'%s' has requested to swap positions with you. Type /swap to confirm the swap.", pSelf->Server()->ClientName(pResult->m_ClientID)); pSelf->SendChatTarget(TargetClientId, aBuf); return; @@ -766,6 +759,9 @@ void CGameContext::ConSwap(IConsole::IResult *pResult, void *pUserData) pPlayer->m_ClientSwapID = -1; pSwapPlayer->m_ClientSwapID = -1; + + int TimePenalty = ((float)pSelf->Server()->TickSpeed()) * 60 * 5; + Teams.IncreaseTeamTime(Team, TimePenalty); } void CGameContext::ConSave(IConsole::IResult *pResult, void *pUserData) diff --git a/src/game/server/teams.cpp b/src/game/server/teams.cpp index 27ceb70cb..381fdacb0 100644 --- a/src/game/server/teams.cpp +++ b/src/game/server/teams.cpp @@ -831,6 +831,18 @@ void CGameTeams::ResetInvited(int Team) m_Invited[Team] = 0; } +void CGameTeams::IncreaseTeamTime(int Team, int Time) +{ + for (int i = 0; i < MAX_CLIENTS; i++) + { + if(m_Core.Team(i) == Team && GameServer()->m_apPlayers[i]) + { + CCharacter *pChar = Character(i); + pChar->m_StartTime = pChar->m_StartTime - Time; + } + } +} + void CGameTeams::SetClientInvited(int Team, int ClientID, bool Invited) { if(Team > TEAM_FLOCK && Team < TEAM_SUPER) diff --git a/src/game/server/teams.h b/src/game/server/teams.h index cceda0354..eab2533f4 100644 --- a/src/game/server/teams.h +++ b/src/game/server/teams.h @@ -82,6 +82,7 @@ public: void SendTeamsState(int ClientID); void SetTeamLock(int Team, bool Lock); void ResetInvited(int Team); + void IncreaseTeamTime(int Team, int time); void SetClientInvited(int Team, int ClientID, bool Invited); int m_LastChat[MAX_CLIENTS];