mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-09 17:48:19 +00:00
Several Fixes and some more on the way
This commit is contained in:
parent
d68e853ca7
commit
604ae5286f
|
@ -955,9 +955,9 @@ void CServer::SendServerInfo(NETADDR *pAddr, int Token)
|
|||
i |= SERVER_FLAG_VERSION;
|
||||
if(g_Config.m_Password[0]) // password set
|
||||
i |= SERVER_FLAG_PASSWORD;
|
||||
if(g_Config.m_SvTeam == 0)
|
||||
if(g_Config.m_SvTeam == 1)
|
||||
i |= SERVER_FLAG_TEAMS1;
|
||||
else if(g_Config.m_SvTeam == 1)
|
||||
else if(g_Config.m_SvTeam == 2)
|
||||
i |= SERVER_FLAG_TEAMS2;
|
||||
if(g_Config.m_SvTeamStrict)
|
||||
i |= SERVER_FLAG_STRICTTEAMS;
|
||||
|
|
|
@ -164,7 +164,7 @@ MACRO_CONFIG_STR(SvRulesLine9, sv_rules_line9, 40, "", CFGFLAG_SERVER, "Rules li
|
|||
MACRO_CONFIG_STR(SvRulesLine10, sv_rules_line10, 40, "", CFGFLAG_SERVER, "Rules line 10", 4)
|
||||
//MACRO_CONFIG_INT(SvReconnectTime, sv_reconnect_time,5,0,9999,CFGFLAG_SERVER, "The time in seconds between leaves and joins of clients with the same ip", 3)
|
||||
|
||||
MACRO_CONFIG_INT(SvTeam, sv_team, 0, -1, 1, CFGFLAG_SERVER, "Teams configuration", 4)
|
||||
MACRO_CONFIG_INT(SvTeam, sv_team, 1, 0, 2, CFGFLAG_SERVER, "Teams configuration (0 = off, 1 = on but optional, 2 = must play only with teams)", 4)
|
||||
MACRO_CONFIG_INT(SvTeamStrict, sv_team_strict, 0, 0, 1, CFGFLAG_SERVER, "Kill or not all team if someone left game in team", 4)
|
||||
MACRO_CONFIG_INT(SvStickyTeams, sv_sticky_teams, 1, 0, 1, CFGFLAG_SERVER, "Whether players stays in a team after death or not", 4)
|
||||
|
||||
|
|
|
@ -61,6 +61,7 @@ CONSOLE_COMMAND("showothers", "", CFGFLAG_SERVER, ConShowOthers, this, "Whether
|
|||
CONSOLE_COMMAND("ask", "s", CFGFLAG_SERVER, ConAsk, this, "Ask to join a player in a team or to start one with him the asker is the leader if the player is not already in a team", -1)
|
||||
CONSOLE_COMMAND("yes", "", CFGFLAG_SERVER, ConYes, this, "Reply yes", -1)
|
||||
CONSOLE_COMMAND("no", "", CFGFLAG_SERVER, ConNo, this, "Reply no", -1)
|
||||
CONSOLE_COMMAND("strict", "", CFGFLAG_SERVER, ConToggleStrict, this, "Toggle Strictness", -1)
|
||||
CONSOLE_COMMAND("invite", "s", CFGFLAG_SERVER, ConInvite, this, "Invite a player to your team (You must be the leader)", -1)
|
||||
CONSOLE_COMMAND("mute", "", CFGFLAG_SERVER, ConMute, this, "", 2);
|
||||
CONSOLE_COMMAND("muteid", "vi", CFGFLAG_SERVER, ConMuteID, this, "", 2);
|
||||
|
|
|
@ -565,7 +565,7 @@ void CGameContext::ConSettings(IConsole::IResult *pResult, void *pUserData, int
|
|||
}
|
||||
else if(str_comp(pArg, "teams") == 0)
|
||||
{
|
||||
str_format(aBuf, sizeof(aBuf), "%s %s", !g_Config.m_SvTeam?"Teams are available on this server":g_Config.m_SvTeam==-1?"Teams are not available on this server":"You have to be in a team to play on this server", !g_Config.m_SvTeamStrict?"and if you die in a team only you die":"and if you die in a team all of you die");
|
||||
str_format(aBuf, sizeof(aBuf), "%s %s", g_Config.m_SvTeam == 1 ? "Teams are available on this server" : !g_Config.m_SvTeam ? "Teams are not available on this server" : "You have to be in a team to play on this server", !g_Config.m_SvTeamStrict ? "and if you die in a team only you die" : "and if you die in a team all of you die");
|
||||
pSelf->Console()->PrintResponse(IConsole::OUTPUT_LEVEL_STANDARD, "info", aBuf);
|
||||
}
|
||||
else if(str_comp(pArg, "collision") == 0)
|
||||
|
@ -774,12 +774,12 @@ void CGameContext::ConJoinTeam(IConsole::IResult *pResult, void *pUserData, int
|
|||
|
||||
CGameContext *pSelf = (CGameContext *)pUserData;
|
||||
CGameControllerDDRace* Controller = (CGameControllerDDRace*)pSelf->m_pController;
|
||||
if(g_Config.m_SvTeam == -1)
|
||||
if(g_Config.m_SvTeam == 0)
|
||||
{
|
||||
pSelf->Console()->PrintResponse(IConsole::OUTPUT_LEVEL_STANDARD, "info", "Admin disable teams");
|
||||
return;
|
||||
}
|
||||
else if (g_Config.m_SvTeam == 1)
|
||||
else if(g_Config.m_SvTeam == 2)
|
||||
{
|
||||
pSelf->Console()->PrintResponse(IConsole::OUTPUT_LEVEL_STANDARD, "info", "You must join to any team and play with anybody or you will not play");
|
||||
}
|
||||
|
@ -1168,6 +1168,30 @@ void CGameContext::ConInvite(IConsole::IResult *pResult, void *pUserData, int Cl
|
|||
return;
|
||||
}
|
||||
|
||||
void CGameContext::ConToggleStrict(IConsole::IResult *pResult, void *pUserData, int ClientID)
|
||||
{
|
||||
CGameContext *pSelf = (CGameContext *)pUserData;
|
||||
CServer* pServ = (CServer*)pSelf->Server();
|
||||
CGameControllerDDRace* Controller = (CGameControllerDDRace*)pSelf->m_pController;
|
||||
CCharacter* pChar = pSelf->m_apPlayers[ClientID]->GetCharacter();
|
||||
char aBuf[512];
|
||||
|
||||
if(!pChar || !pChar->IsAlive())
|
||||
str_format(aBuf, sizeof(aBuf), "You can\'t while you are dead.");
|
||||
else if(pChar->Team() == 0)
|
||||
str_format(aBuf, sizeof(aBuf), "You are in team %d, that can't be strict!", pChar->Team());
|
||||
else if(pChar->Team() && ClientID != Controller->m_Teams.GetTeamLeader(pChar->Team()))
|
||||
str_format(aBuf, sizeof(aBuf), "You are not the leader of team %, you can't change it's strictness.", pChar->Team());
|
||||
else
|
||||
{
|
||||
Controller->m_Teams.ToggleStrictness(pChar->Team());
|
||||
str_format(aBuf, sizeof(aBuf), "Done.", pChar->Team());
|
||||
}
|
||||
|
||||
pSelf->Console()->PrintResponse(IConsole::OUTPUT_LEVEL_STANDARD, "info", aBuf);
|
||||
return;
|
||||
}
|
||||
|
||||
void CGameContext::Mute(const char *pIP, int Secs, const char *pDisplayName)
|
||||
{
|
||||
char aBuf[128];
|
||||
|
|
|
@ -1004,7 +1004,6 @@ void CCharacter::OnFinish()
|
|||
GameServer()->m_pController->m_CurrentRecord = time;
|
||||
//dbg_msg("character", "Finish");
|
||||
NeedToSendNewRecord = true;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1340,7 +1339,7 @@ void CCharacter::HandleTiles(int Index)
|
|||
if(((m_TileIndex == TILE_BEGIN) || (m_TileFIndex == TILE_BEGIN) || FTile1 == TILE_BEGIN || FTile2 == TILE_BEGIN || FTile3 == TILE_BEGIN || FTile4 == TILE_BEGIN || Tile1 == TILE_BEGIN || Tile2 == TILE_BEGIN || Tile3 == TILE_BEGIN || Tile4 == TILE_BEGIN) && (m_DDRaceState == DDRACE_NONE || m_DDRaceState == DDRACE_FINISHED || (m_DDRaceState == DDRACE_STARTED && !Team())))
|
||||
{
|
||||
bool CanBegin = true;
|
||||
if(g_Config.m_SvTeam == 1 && (Team() == TEAM_FLOCK || Teams()->Count(Team()) <= 1))
|
||||
if(g_Config.m_SvTeam == 2 && (Team() == TEAM_FLOCK || Teams()->Count(Team()) <= 1))
|
||||
{
|
||||
if(m_LastStartWarning < Server()->Tick() - 3 * Server()->TickSpeed())
|
||||
{
|
||||
|
@ -1351,7 +1350,7 @@ void CCharacter::HandleTiles(int Index)
|
|||
}
|
||||
if(CanBegin)
|
||||
{
|
||||
Controller->m_Teams.OnCharacterStart(m_pPlayer->GetCID());
|
||||
Teams()->OnCharacterStart(m_pPlayer->GetCID());
|
||||
m_CpActive = -2;
|
||||
} else {
|
||||
|
||||
|
@ -1607,7 +1606,7 @@ void CCharacter::DDRaceInit()
|
|||
m_Core.m_Id = GetPlayer()->GetCID();
|
||||
if(m_pPlayer->m_RconFreeze) Freeze(-1);
|
||||
if(GetPlayer()->m_IsUsingDDRaceClient) ((CGameControllerDDRace*)GameServer()->m_pController)->m_Teams.SendTeamsState(GetPlayer()->GetCID());
|
||||
if(g_Config.m_SvTeam == 1)
|
||||
if(g_Config.m_SvTeam == 2)
|
||||
{
|
||||
GameServer()->SendChatTarget(GetPlayer()->GetCID(),"Please join a team before you start");
|
||||
m_LastStartWarning = Server()->Tick();
|
||||
|
|
|
@ -244,6 +244,7 @@ private:
|
|||
static void ConYes(IConsole::IResult *pResult, void *pUserData, int ClientID);
|
||||
static void ConNo(IConsole::IResult *pResult, void *pUserData, int ClientID);
|
||||
static void ConInvite(IConsole::IResult *pResult, void *pUserData, int ClientID);
|
||||
static void ConToggleStrict(IConsole::IResult *pResult, void *pUserData, int ClientID);
|
||||
static void ConMute(IConsole::IResult *pResult, void *pUserData, int ClientID);
|
||||
static void ConMuteID(IConsole::IResult *pResult, void *pUserData, int ClientID);
|
||||
static void ConMuteIP(IConsole::IResult *pResult, void *pUserData, int ClientID);
|
||||
|
|
|
@ -141,6 +141,7 @@ void CPlayer::Snap(int SnappingClient)
|
|||
|
||||
void CPlayer::OnDisconnect()
|
||||
{
|
||||
|
||||
KillCharacter();
|
||||
|
||||
if(Server()->ClientIngame(m_ClientID))
|
||||
|
@ -152,6 +153,8 @@ void CPlayer::OnDisconnect()
|
|||
str_format(aBuf, sizeof(aBuf), "leave player='%d:%s'", m_ClientID, Server()->ClientName(m_ClientID));
|
||||
GameServer()->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "game", aBuf);
|
||||
}
|
||||
CGameControllerDDRace* Controller = (CGameControllerDDRace*)GameServer()->m_pController;
|
||||
Controller->m_Teams.m_Core.Team(m_ClientID, 0);
|
||||
}
|
||||
|
||||
void CPlayer::OnPredictedInput(CNetObj_PlayerInput *NewInput)
|
||||
|
|
|
@ -18,6 +18,7 @@ void CGameTeams::Reset()
|
|||
m_LastChat[i] = 0;
|
||||
m_TeamLeader[i] = -1;
|
||||
m_TeeJoinTick[i] = -1;
|
||||
m_TeamStrict[i] = g_Config.m_SvTeamStrict;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -36,6 +37,26 @@ void CGameTeams::OnCharacterStart(int ClientID)
|
|||
StartingChar->m_StartTime = Tick;
|
||||
StartingChar->m_RefreshTime = Tick;
|
||||
}
|
||||
else if(Count(Team) == 1)
|
||||
{
|
||||
if(m_TeamState[Team] <= TEAMSTATE_CLOSED)
|
||||
{
|
||||
ChangeTeamState(Team, TEAMSTATE_STARTED);
|
||||
for(int i = 0; i < MAX_CLIENTS; ++i)
|
||||
{
|
||||
if(Team == m_Core.Team(i))
|
||||
{
|
||||
CCharacter* pChar = Character(i);
|
||||
if(pChar && pChar->IsAlive())
|
||||
{
|
||||
pChar->m_DDRaceState = DDRACE_STARTED;
|
||||
pChar->m_StartTime = Tick;
|
||||
pChar->m_RefreshTime = Tick;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
bool Waiting = false;
|
||||
|
@ -103,6 +124,16 @@ void CGameTeams::OnCharacterFinish(int ClientID)
|
|||
{
|
||||
Character(ClientID)->OnFinish();
|
||||
}
|
||||
else if(Count(Team) == 1)
|
||||
{
|
||||
m_TeeFinished[ClientID] = true;
|
||||
if(TeamFinished(Team))
|
||||
{
|
||||
ChangeTeamState(Team, TEAMSTATE_OPEN);
|
||||
Character(ClientID)->OnFinish();
|
||||
m_TeeFinished[ClientID] = false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
m_TeeFinished[ClientID] = true;
|
||||
|
@ -113,7 +144,7 @@ void CGameTeams::OnCharacterFinish(int ClientID)
|
|||
{
|
||||
if(Team == m_Core.Team(i))
|
||||
{
|
||||
CCharacter * pChar = Character(i);
|
||||
CCharacter* pChar = Character(i);
|
||||
if(pChar != 0 && pChar->m_DDRaceState == DDRACE_STARTED)
|
||||
{
|
||||
pChar->OnFinish();
|
||||
|
@ -121,22 +152,24 @@ void CGameTeams::OnCharacterFinish(int ClientID)
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CGameTeams::OnCharacterDeath(int ClientID)
|
||||
{
|
||||
if(g_Config.m_SvTeamStrict && m_Core.Team(ClientID) != TEAM_FLOCK && m_Core.Team(ClientID) != TEAM_SUPER)
|
||||
for(int LoopClientID = 0; LoopClientID < MAX_CLIENTS; ++LoopClientID)
|
||||
if(m_TeamStrict[m_Core.Team(ClientID)] && m_Core.Team(ClientID) != TEAM_FLOCK && m_Core.Team(ClientID) != TEAM_SUPER)
|
||||
{
|
||||
if(m_Core.Team(ClientID) == m_Core.Team(LoopClientID))
|
||||
for(int LoopClientID = 0; LoopClientID < MAX_CLIENTS; ++LoopClientID)
|
||||
{
|
||||
CCharacter* pChar = Character(LoopClientID);
|
||||
if(pChar)
|
||||
pChar->Die(ClientID, WEAPON_SELF);
|
||||
if(m_Core.Team(ClientID) == m_Core.Team(LoopClientID))
|
||||
{
|
||||
CCharacter* pChar = Character(LoopClientID);
|
||||
if(pChar)
|
||||
pChar->Die(ClientID, WEAPON_SELF);
|
||||
}
|
||||
}
|
||||
ChangeTeamState(m_Core.Team(ClientID), TEAMSTATE_OPEN);
|
||||
}
|
||||
|
||||
if(!g_Config.m_SvStickyTeams && m_Core.Team(ClientID) != TEAM_FLOCK && m_Core.Team(ClientID) != TEAM_SUPER)
|
||||
|
@ -229,7 +262,10 @@ void CGameTeams::SetForceCharacterTeam(int ClientID, int Team)
|
|||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
SetTeamLeader(OldTeam, -1);
|
||||
m_TeamStrict[OldTeam] = g_Config.m_SvTeamStrict;
|
||||
}
|
||||
}
|
||||
|
||||
dbg_msg1("Teams", "Id = %d Team = %d", ClientID, Team);
|
||||
|
@ -314,3 +350,19 @@ void CGameTeams::SetTeamLeader(int Team, int ClientID)
|
|||
str_format(aBuf, sizeof(aBuf), "You are now the team %d leader.", Team);
|
||||
GameServer()->SendChatTarget(ClientID, aBuf);
|
||||
}
|
||||
|
||||
int CGameTeams::ToggleStrictness(int Team)
|
||||
{
|
||||
char aBuf[64];
|
||||
str_format(aBuf, sizeof(aBuf), "\'%s\' Toggled Team Strictness to %d.", Server()->ClientName(m_TeamLeader[Team]), m_TeamStrict[Team]);
|
||||
if(Count(Team) > 1)
|
||||
{
|
||||
for (int LoopClientID = 0; LoopClientID < MAX_CLIENTS; ++LoopClientID)
|
||||
if(m_Core.Team(LoopClientID) == Team)
|
||||
GameServer()->SendChatTarget(LoopClientID, aBuf);
|
||||
}
|
||||
else
|
||||
GameServer()->SendChatTarget(m_TeamLeader[Team], aBuf);
|
||||
|
||||
return m_TeamStrict[Team] = !m_TeamStrict[Team];
|
||||
}
|
||||
|
|
|
@ -11,6 +11,7 @@ class CGameTeams
|
|||
bool m_TeeFinished[MAX_CLIENTS];
|
||||
int m_TeamLeader[MAX_CLIENTS];
|
||||
int m_TeeJoinTick[MAX_CLIENTS];
|
||||
bool m_TeamStrict[MAX_CLIENTS];
|
||||
|
||||
class CGameContext * m_pGameContext;
|
||||
|
||||
|
@ -70,6 +71,7 @@ public:
|
|||
int GetTeamLeader(int Team) { return m_TeamLeader[Team]; };
|
||||
|
||||
void SetTeamLeader(int Team, int ClientID);
|
||||
int ToggleStrictness(int Team);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -26,6 +26,6 @@
|
|||
# add_path mods/mymod
|
||||
####
|
||||
|
||||
add_path $USERDIR
|
||||
add_path E:\Users\shereef\Teeworlds
|
||||
add_path $DATADIR
|
||||
add_path $CURRENTDIR
|
||||
|
|
Loading…
Reference in a new issue