mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-19 06:28:19 +00:00
parent
87407be1c5
commit
506602d472
|
@ -570,7 +570,7 @@ void CGameContext::ConPractice(IConsole::IResult *pResult, void *pUserData)
|
|||
|
||||
int Team = Teams.m_Core.Team(pResult->m_ClientID);
|
||||
|
||||
if(Team <= TEAM_FLOCK || Team >= TEAM_SUPER)
|
||||
if(Team < TEAM_FLOCK || (Team == TEAM_FLOCK && g_Config.m_SvTeam == 3) || Team >= TEAM_SUPER)
|
||||
{
|
||||
pSelf->Console()->Print(
|
||||
IConsole::OUTPUT_LEVEL_STANDARD,
|
||||
|
@ -803,6 +803,13 @@ void CGameContext::ConUnlockTeam(IConsole::IResult *pResult, void *pUserData)
|
|||
if (!CheckClientID(pResult->m_ClientID))
|
||||
return;
|
||||
|
||||
if(g_Config.m_SvTeam == 0 || g_Config.m_SvTeam == 3)
|
||||
{
|
||||
pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "unlock",
|
||||
"Teams are disabled");
|
||||
return;
|
||||
}
|
||||
|
||||
int Team = ((CGameControllerDDRace*) pSelf->m_pController)->m_Teams.m_Core.Team(pResult->m_ClientID);
|
||||
|
||||
if(Team <= TEAM_FLOCK || Team >= TEAM_SUPER)
|
||||
|
|
|
@ -658,6 +658,13 @@ void CGameContext::ConSetDDRTeam(IConsole::IResult *pResult, void *pUserData)
|
|||
CGameContext *pSelf = (CGameContext *)pUserData;
|
||||
CGameControllerDDRace *pController = (CGameControllerDDRace *)pSelf->m_pController;
|
||||
|
||||
if(g_Config.m_SvTeam == 0 || g_Config.m_SvTeam == 3)
|
||||
{
|
||||
pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "join",
|
||||
"Teams are disabled");
|
||||
return;
|
||||
}
|
||||
|
||||
int Target = pResult->GetVictim();
|
||||
int Team = pResult->GetInteger(1);
|
||||
|
||||
|
|
|
@ -1910,7 +1910,7 @@ void CCharacter::HandleTiles(int Index)
|
|||
|
||||
m_StartTime -= (min * 60 + sec) * Server()->TickSpeed();
|
||||
|
||||
if (Team != TEAM_FLOCK && Team != TEAM_SUPER)
|
||||
if ((g_Config.m_SvTeam == 3 || Team != TEAM_FLOCK) && Team != TEAM_SUPER)
|
||||
{
|
||||
for (int i = 0; i < MAX_CLIENTS; i++)
|
||||
{
|
||||
|
@ -1936,7 +1936,7 @@ void CCharacter::HandleTiles(int Index)
|
|||
if (m_StartTime > Server()->Tick())
|
||||
m_StartTime = Server()->Tick();
|
||||
|
||||
if (Team != TEAM_FLOCK && Team != TEAM_SUPER)
|
||||
if ((g_Config.m_SvTeam == 3 || Team != TEAM_FLOCK) && Team != TEAM_SUPER)
|
||||
{
|
||||
for (int i = 0; i < MAX_CLIENTS; i++)
|
||||
{
|
||||
|
@ -2187,7 +2187,10 @@ void CCharacter::DDRaceTick()
|
|||
HandleTuneLayer(); // need this before coretick
|
||||
|
||||
// look for save position for rescue feature
|
||||
if(g_Config.m_SvRescue || (Team() > TEAM_FLOCK && Team() < TEAM_SUPER)) {
|
||||
if(g_Config.m_SvRescue
|
||||
|| ((g_Config.m_SvTeam == 3 || Team() > TEAM_FLOCK)
|
||||
&& Team() >= TEAM_FLOCK
|
||||
&& Team() < TEAM_SUPER)) {
|
||||
int index = GameServer()->Collision()->GetPureMapIndex(m_Pos);
|
||||
int tile = GameServer()->Collision()->GetTileIndex(index);
|
||||
int ftile = GameServer()->Collision()->GetFTileIndex(index);
|
||||
|
|
|
@ -2971,6 +2971,21 @@ void CGameContext::OnInit(/*class IKernel *pKernel*/)
|
|||
|
||||
m_MapBugs.Dump();
|
||||
|
||||
if(g_Config.m_SvSoloServer)
|
||||
{
|
||||
g_Config.m_SvTeam = 3;
|
||||
g_Config.m_SvShowOthersDefault = 1;
|
||||
|
||||
Tuning()->Set("player_collision", 0);
|
||||
Tuning()->Set("player_hooking", 0);
|
||||
|
||||
for (int i = 0; i < NUM_TUNEZONES; i++)
|
||||
{
|
||||
TuningList()[i].Set("player_collision", 0);
|
||||
TuningList()[i].Set("player_hooking", 0);
|
||||
}
|
||||
}
|
||||
|
||||
m_pController = new CGameControllerDDRace(this);
|
||||
((CGameControllerDDRace*)m_pController)->m_Teams.Reset();
|
||||
|
||||
|
@ -3036,21 +3051,6 @@ void CGameContext::OnInit(/*class IKernel *pKernel*/)
|
|||
}
|
||||
}
|
||||
|
||||
if(g_Config.m_SvSoloServer)
|
||||
{
|
||||
g_Config.m_SvTeam = 3;
|
||||
g_Config.m_SvShowOthersDefault = 1;
|
||||
|
||||
Tuning()->Set("player_collision", 0);
|
||||
Tuning()->Set("player_hooking", 0);
|
||||
|
||||
for (int i = 0; i < NUM_TUNEZONES; i++)
|
||||
{
|
||||
TuningList()[i].Set("player_collision", 0);
|
||||
TuningList()[i].Set("player_hooking", 0);
|
||||
}
|
||||
}
|
||||
|
||||
// delete old score object
|
||||
if(m_pScore)
|
||||
delete m_pScore;
|
||||
|
|
|
@ -479,7 +479,8 @@ void CPlayer::OnDisconnect(const char *pReason)
|
|||
}
|
||||
|
||||
CGameControllerDDRace* Controller = (CGameControllerDDRace*)GameServer()->m_pController;
|
||||
Controller->m_Teams.SetForceCharacterTeam(m_ClientID, 0);
|
||||
if(g_Config.m_SvTeam != 3)
|
||||
Controller->m_Teams.SetForceCharacterTeam(m_ClientID, TEAM_FLOCK);
|
||||
}
|
||||
|
||||
void CPlayer::OnPredictedInput(CNetObj_PlayerInput *NewInput)
|
||||
|
@ -618,7 +619,8 @@ void CPlayer::SetTeam(int Team, bool DoChatMsg)
|
|||
if(Team == TEAM_SPECTATORS)
|
||||
{
|
||||
CGameControllerDDRace* Controller = (CGameControllerDDRace*)GameServer()->m_pController;
|
||||
Controller->m_Teams.SetForceCharacterTeam(m_ClientID, 0);
|
||||
if(g_Config.m_SvTeam != 3)
|
||||
Controller->m_Teams.SetForceCharacterTeam(m_ClientID, TEAM_FLOCK);
|
||||
}
|
||||
|
||||
KillCharacter();
|
||||
|
@ -703,8 +705,6 @@ void CPlayer::TryRespawn()
|
|||
if(!GameServer()->m_pController->CanSpawn(m_Team, &SpawnPos))
|
||||
return;
|
||||
|
||||
CGameControllerDDRace* Controller = (CGameControllerDDRace*)GameServer()->m_pController;
|
||||
|
||||
m_WeakHookSpawn = false;
|
||||
m_Spawning = false;
|
||||
m_pCharacter = new(m_ClientID) CCharacter(&GameServer()->m_World);
|
||||
|
@ -712,18 +712,7 @@ void CPlayer::TryRespawn()
|
|||
GameServer()->CreatePlayerSpawn(SpawnPos, m_pCharacter->Teams()->TeamMask(m_pCharacter->Team(), -1, m_ClientID));
|
||||
|
||||
if(g_Config.m_SvTeam == 3)
|
||||
{
|
||||
int NewTeam = 1;
|
||||
for(; NewTeam < TEAM_SUPER; NewTeam++)
|
||||
if(Controller->m_Teams.Count(NewTeam) == 0)
|
||||
break;
|
||||
|
||||
if(NewTeam == TEAM_SUPER)
|
||||
NewTeam = 0;
|
||||
|
||||
Controller->m_Teams.SetForceCharacterTeam(GetCID(), NewTeam);
|
||||
m_pCharacter->SetSolo(true);
|
||||
}
|
||||
}
|
||||
|
||||
bool CPlayer::AfkTimer(int NewTargetX, int NewTargetY)
|
||||
|
|
|
@ -1687,7 +1687,7 @@ void CSqlScore::LoadTeam(const char* Code, int ClientID)
|
|||
int Team = pController->m_Teams.m_Core.Team(ClientID);
|
||||
if(pController->m_Teams.GetSaving(Team))
|
||||
return;
|
||||
if(Team <= 0 || Team >= MAX_CLIENTS)
|
||||
if(Team < TEAM_FLOCK || Team >= MAX_CLIENTS || (g_Config.m_SvTeam != 3 && Team == TEAM_FLOCK))
|
||||
{
|
||||
GameServer()->SendChatTarget(ClientID, "You have to be in a team (from 1-63)");
|
||||
return;
|
||||
|
|
|
@ -31,10 +31,10 @@ void CGameTeams::OnCharacterStart(int ClientID)
|
|||
CCharacter* pStartingChar = Character(ClientID);
|
||||
if(!pStartingChar)
|
||||
return;
|
||||
if(m_Core.Team(ClientID) != TEAM_FLOCK && pStartingChar->m_DDRaceState == DDRACE_FINISHED)
|
||||
if((g_Config.m_SvTeam == 3 || m_Core.Team(ClientID) != TEAM_FLOCK) && pStartingChar->m_DDRaceState == DDRACE_FINISHED)
|
||||
return;
|
||||
if(m_Core.Team(ClientID) == TEAM_FLOCK
|
||||
|| m_Core.Team(ClientID) == TEAM_SUPER)
|
||||
if(g_Config.m_SvTeam != 3 &&
|
||||
(m_Core.Team(ClientID) == TEAM_FLOCK || m_Core.Team(ClientID) == TEAM_SUPER))
|
||||
{
|
||||
pStartingChar->m_DDRaceState = DDRACE_STARTED;
|
||||
pStartingChar->m_StartTime = Tick;
|
||||
|
@ -136,6 +136,7 @@ void CGameTeams::OnCharacterStart(int ClientID)
|
|||
void CGameTeams::OnCharacterFinish(int ClientID)
|
||||
{
|
||||
if (m_Core.Team(ClientID) == TEAM_FLOCK
|
||||
|| g_Config.m_SvTeam == 3
|
||||
|| m_Core.Team(ClientID) == TEAM_SUPER)
|
||||
{
|
||||
CPlayer* pPlayer = GetPlayer(ClientID);
|
||||
|
@ -302,7 +303,7 @@ void CGameTeams::ForceLeaveTeam(int ClientID)
|
|||
{
|
||||
m_TeeFinished[ClientID] = false;
|
||||
|
||||
if (m_Core.Team(ClientID) != TEAM_FLOCK
|
||||
if((m_Core.Team(ClientID) != TEAM_FLOCK || g_Config.m_SvTeam == 3)
|
||||
&& m_Core.Team(ClientID) != TEAM_SUPER
|
||||
&& m_TeamState[m_Core.Team(ClientID)] != TEAMSTATE_EMPTY)
|
||||
{
|
||||
|
@ -515,7 +516,7 @@ void CGameTeams::OnTeamFinish(CPlayer** Players, unsigned int Size, float Time,
|
|||
|
||||
if(g_Config.m_SvRejoinTeam0 && g_Config.m_SvTeam != 3 && (m_Core.Team(Players[i]->GetCID()) >= TEAM_SUPER || !m_TeamLocked[m_Core.Team(Players[i]->GetCID())]))
|
||||
{
|
||||
SetForceCharacterTeam(Players[i]->GetCID(), 0);
|
||||
SetForceCharacterTeam(Players[i]->GetCID(), TEAM_FLOCK);
|
||||
char aBuf[512];
|
||||
str_format(aBuf, sizeof(aBuf), "%s joined team 0",
|
||||
GameServer()->Server()->ClientName(Players[i]->GetCID()));
|
||||
|
@ -742,7 +743,10 @@ void CGameTeams::OnCharacterSpawn(int ClientID)
|
|||
|
||||
if (m_Core.Team(ClientID) >= TEAM_SUPER || !m_TeamLocked[Team])
|
||||
{
|
||||
SetForceCharacterTeam(ClientID, 0);
|
||||
if(g_Config.m_SvTeam != 3)
|
||||
SetForceCharacterTeam(ClientID, TEAM_FLOCK);
|
||||
else
|
||||
SetForceCharacterTeam(ClientID, ClientID); // initialize team
|
||||
CheckTeamFinished(Team);
|
||||
}
|
||||
}
|
||||
|
@ -756,12 +760,12 @@ void CGameTeams::OnCharacterDeath(int ClientID, int Weapon)
|
|||
return;
|
||||
bool Locked = TeamLocked(Team) && Weapon != WEAPON_GAME;
|
||||
|
||||
if(!Locked)
|
||||
if(g_Config.m_SvTeam == 3)
|
||||
{
|
||||
SetForceCharacterTeam(ClientID, 0);
|
||||
CheckTeamFinished(Team);
|
||||
m_TeamState[Team] = CGameTeams::TEAMSTATE_OPEN;
|
||||
m_Practice[Team] = false;
|
||||
}
|
||||
else
|
||||
else if(Locked)
|
||||
{
|
||||
SetForceCharacterTeam(ClientID, Team);
|
||||
|
||||
|
@ -790,6 +794,11 @@ void CGameTeams::OnCharacterDeath(int ClientID, int Weapon)
|
|||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
SetForceCharacterTeam(ClientID, TEAM_FLOCK);
|
||||
CheckTeamFinished(Team);
|
||||
}
|
||||
}
|
||||
|
||||
void CGameTeams::SetTeamLock(int Team, bool Lock)
|
||||
|
@ -828,11 +837,18 @@ void CGameTeams::KillSavedTeam(int ClientID, int Team)
|
|||
|
||||
void CGameTeams::ResetSavedTeam(int ClientID, int Team)
|
||||
{
|
||||
for (int i = 0; i < MAX_CLIENTS; i++)
|
||||
if(g_Config.m_SvTeam == 3)
|
||||
{
|
||||
if(m_Core.Team(i) == Team && GameServer()->m_apPlayers[i])
|
||||
ChangeTeamState(Team, CGameTeams::TEAMSTATE_OPEN);
|
||||
}
|
||||
else
|
||||
{
|
||||
for (int i = 0; i < MAX_CLIENTS; i++)
|
||||
{
|
||||
SetForceCharacterTeam(i, 0);
|
||||
if(m_Core.Team(i) == Team && GameServer()->m_apPlayers[i])
|
||||
{
|
||||
SetForceCharacterTeam(i, TEAM_FLOCK);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
#ifndef GAME_SERVER_TEAMS_H
|
||||
#define GAME_SERVER_TEAMS_H
|
||||
|
||||
#include <engine/shared/config.h>
|
||||
#include <game/teamscore.h>
|
||||
#include <game/server/gamecontext.h>
|
||||
|
||||
|
@ -123,7 +124,9 @@ public:
|
|||
|
||||
bool GetSaving(int TeamID)
|
||||
{
|
||||
if(TeamID <= TEAM_FLOCK || TeamID >= TEAM_SUPER)
|
||||
if(TeamID < TEAM_FLOCK || TeamID >= TEAM_SUPER)
|
||||
return false;
|
||||
if(g_Config.m_SvTeam != 3 && TeamID == TEAM_FLOCK)
|
||||
return false;
|
||||
|
||||
return m_pSaveTeamResult[TeamID] != nullptr;
|
||||
|
@ -131,7 +134,9 @@ public:
|
|||
|
||||
void EnablePractice(int Team)
|
||||
{
|
||||
if(Team <= TEAM_FLOCK || Team >= TEAM_SUPER)
|
||||
if(Team < TEAM_FLOCK || Team >= TEAM_SUPER)
|
||||
return;
|
||||
if(g_Config.m_SvTeam != 3 && Team == TEAM_FLOCK)
|
||||
return;
|
||||
|
||||
m_Practice[Team] = true;
|
||||
|
@ -139,7 +144,9 @@ public:
|
|||
|
||||
bool IsPractice(int Team)
|
||||
{
|
||||
if(Team <= TEAM_FLOCK || Team >= TEAM_SUPER)
|
||||
if(Team < TEAM_FLOCK || Team >= TEAM_SUPER)
|
||||
return false;
|
||||
if(g_Config.m_SvTeam != 3 && Team == TEAM_FLOCK)
|
||||
return false;
|
||||
|
||||
return m_Practice[Team];
|
||||
|
|
|
@ -45,7 +45,10 @@ void CTeamsCore::Reset()
|
|||
|
||||
for (int i = 0; i < MAX_CLIENTS; ++i)
|
||||
{
|
||||
m_Team[i] = TEAM_FLOCK;
|
||||
if(g_Config.m_SvTeam == 3)
|
||||
m_Team[i] = i;
|
||||
else
|
||||
m_Team[i] = TEAM_FLOCK;
|
||||
m_IsSolo[i] = false;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
#ifndef GAME_TEAMSCORE_H
|
||||
#define GAME_TEAMSCORE_H
|
||||
|
||||
#include <engine/shared/config.h>
|
||||
#include <engine/shared/protocol.h>
|
||||
|
||||
enum
|
||||
|
|
Loading…
Reference in a new issue