mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-10 18:18:18 +00:00
- Added timeout penalty
- Applied PR feedback
This commit is contained in:
parent
94dbae981f
commit
cf7fb72dbf
|
@ -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")
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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];
|
||||
|
|
Loading…
Reference in a new issue