mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-10 01:58:19 +00:00
Merge #1675
1675: Remove unused vanilla code (closed #1658) r=def- a=ChillerDragon Removed vanilla code from gamecontext and gamecontroller. I didn't search for the code all over the place I just remember seing it there a lot. Also removed some empty lines. Wanted to do this for a long time :) thought there is an reason it is there. But we have git and the vanilla repo so I don't see any point keeping it there. Co-authored-by: ChillerDragon <chillerdragon@gmail.com>
This commit is contained in:
commit
70b3f1db21
|
@ -16,10 +16,6 @@
|
|||
#include <game/version.h>
|
||||
#include <game/collision.h>
|
||||
#include <game/gamecore.h>
|
||||
/*#include "gamemodes/dm.h"
|
||||
#include "gamemodes/tdm.h"
|
||||
#include "gamemodes/ctf.h"
|
||||
#include "gamemodes/mod.h"*/
|
||||
|
||||
#include "gamemodes/DDRace.h"
|
||||
#include "score.h"
|
||||
|
@ -170,63 +166,47 @@ void CGameContext::CreateExplosion(vec2 Pos, int Owner, int Weapon, bool NoDamag
|
|||
pEvent->m_X = (int)Pos.x;
|
||||
pEvent->m_Y = (int)Pos.y;
|
||||
}
|
||||
/*
|
||||
if (!NoDamage)
|
||||
|
||||
// deal damage
|
||||
CCharacter *apEnts[MAX_CLIENTS];
|
||||
float Radius = 135.0f;
|
||||
float InnerRadius = 48.0f;
|
||||
int Num = m_World.FindEntities(Pos, Radius, (CEntity**)apEnts, MAX_CLIENTS, CGameWorld::ENTTYPE_CHARACTER);
|
||||
int64_t TeamMask = -1;
|
||||
for(int i = 0; i < Num; i++)
|
||||
{
|
||||
*/
|
||||
// deal damage
|
||||
CCharacter *apEnts[MAX_CLIENTS];
|
||||
float Radius = 135.0f;
|
||||
float InnerRadius = 48.0f;
|
||||
int Num = m_World.FindEntities(Pos, Radius, (CEntity**)apEnts, MAX_CLIENTS, CGameWorld::ENTTYPE_CHARACTER);
|
||||
int64_t TeamMask = -1;
|
||||
for(int i = 0; i < Num; i++)
|
||||
vec2 Diff = apEnts[i]->m_Pos - Pos;
|
||||
vec2 ForceDir(0,1);
|
||||
float l = length(Diff);
|
||||
if(l)
|
||||
ForceDir = normalize(Diff);
|
||||
l = 1-clamp((l-InnerRadius)/(Radius-InnerRadius), 0.0f, 1.0f);
|
||||
float Strength;
|
||||
if (Owner == -1 || !m_apPlayers[Owner] || !m_apPlayers[Owner]->m_TuneZone)
|
||||
Strength = Tuning()->m_ExplosionStrength;
|
||||
else
|
||||
Strength = TuningList()[m_apPlayers[Owner]->m_TuneZone].m_ExplosionStrength;
|
||||
|
||||
float Dmg = Strength * l;
|
||||
if(!(int)Dmg) continue;
|
||||
|
||||
if((GetPlayerChar(Owner) ? !(GetPlayerChar(Owner)->m_Hit&CCharacter::DISABLE_HIT_GRENADE) : g_Config.m_SvHit || NoDamage) || Owner == apEnts[i]->GetPlayer()->GetCID())
|
||||
{
|
||||
vec2 Diff = apEnts[i]->m_Pos - Pos;
|
||||
vec2 ForceDir(0,1);
|
||||
float l = length(Diff);
|
||||
if(l)
|
||||
ForceDir = normalize(Diff);
|
||||
l = 1-clamp((l-InnerRadius)/(Radius-InnerRadius), 0.0f, 1.0f);
|
||||
float Strength;
|
||||
if (Owner == -1 || !m_apPlayers[Owner] || !m_apPlayers[Owner]->m_TuneZone)
|
||||
Strength = Tuning()->m_ExplosionStrength;
|
||||
else
|
||||
Strength = TuningList()[m_apPlayers[Owner]->m_TuneZone].m_ExplosionStrength;
|
||||
if(Owner != -1 && apEnts[i]->IsAlive() && !apEnts[i]->CanCollide(Owner)) continue;
|
||||
if(Owner == -1 && ActivatedTeam != -1 && apEnts[i]->IsAlive() && apEnts[i]->Team() != ActivatedTeam) continue;
|
||||
|
||||
float Dmg = Strength * l;
|
||||
if(!(int)Dmg) continue;
|
||||
|
||||
if((GetPlayerChar(Owner) ? !(GetPlayerChar(Owner)->m_Hit&CCharacter::DISABLE_HIT_GRENADE) : g_Config.m_SvHit || NoDamage) || Owner == apEnts[i]->GetPlayer()->GetCID())
|
||||
// Explode at most once per team
|
||||
int PlayerTeam = ((CGameControllerDDRace*)m_pController)->m_Teams.m_Core.Team(apEnts[i]->GetPlayer()->GetCID());
|
||||
if(GetPlayerChar(Owner) ? GetPlayerChar(Owner)->m_Hit&CCharacter::DISABLE_HIT_GRENADE : !g_Config.m_SvHit || NoDamage)
|
||||
{
|
||||
if(Owner != -1 && apEnts[i]->IsAlive() && !apEnts[i]->CanCollide(Owner)) continue;
|
||||
if(Owner == -1 && ActivatedTeam != -1 && apEnts[i]->IsAlive() && apEnts[i]->Team() != ActivatedTeam) continue;
|
||||
|
||||
// Explode at most once per team
|
||||
int PlayerTeam = ((CGameControllerDDRace*)m_pController)->m_Teams.m_Core.Team(apEnts[i]->GetPlayer()->GetCID());
|
||||
if(GetPlayerChar(Owner) ? GetPlayerChar(Owner)->m_Hit&CCharacter::DISABLE_HIT_GRENADE : !g_Config.m_SvHit || NoDamage)
|
||||
{
|
||||
if(!CmaskIsSet(TeamMask, PlayerTeam)) continue;
|
||||
TeamMask = CmaskUnset(TeamMask, PlayerTeam);
|
||||
}
|
||||
|
||||
apEnts[i]->TakeDamage(ForceDir*Dmg*2, (int)Dmg, Owner, Weapon);
|
||||
if(!CmaskIsSet(TeamMask, PlayerTeam)) continue;
|
||||
TeamMask = CmaskUnset(TeamMask, PlayerTeam);
|
||||
}
|
||||
}
|
||||
//}
|
||||
}
|
||||
|
||||
/*
|
||||
void create_smoke(vec2 Pos)
|
||||
{
|
||||
// create the event
|
||||
EV_EXPLOSION *pEvent = (EV_EXPLOSION *)events.create(EVENT_SMOKE, sizeof(EV_EXPLOSION));
|
||||
if(pEvent)
|
||||
{
|
||||
pEvent->x = (int)Pos.x;
|
||||
pEvent->y = (int)Pos.y;
|
||||
apEnts[i]->TakeDamage(ForceDir*Dmg*2, (int)Dmg, Owner, Weapon);
|
||||
}
|
||||
}
|
||||
}*/
|
||||
}
|
||||
|
||||
void CGameContext::CreatePlayerSpawn(vec2 Pos, int64_t Mask)
|
||||
{
|
||||
|
@ -326,14 +306,8 @@ void CGameContext::SendChatTeam(int Team, const char *pText)
|
|||
void CGameContext::SendChat(int ChatterClientID, int Team, const char *pText, int SpamProtectionClientID)
|
||||
{
|
||||
if(SpamProtectionClientID >= 0 && SpamProtectionClientID < MAX_CLIENTS)
|
||||
{
|
||||
if(ProcessSpamProtection(SpamProtectionClientID))
|
||||
{
|
||||
//SendChatTarget(SpamProtectionClientID, "Muted text:");
|
||||
//SendChatTarget(SpamProtectionClientID, pText);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
char aBuf[256], aText[256];
|
||||
str_copy(aText, pText, sizeof(aText));
|
||||
|
@ -621,23 +595,7 @@ void CGameContext::SendTuningParams(int ClientID, int Zone)
|
|||
}
|
||||
Server()->SendMsg(&Msg, MSGFLAG_VITAL, ClientID);
|
||||
}
|
||||
/*
|
||||
void CGameContext::SwapTeams()
|
||||
{
|
||||
if(!m_pController->IsTeamplay())
|
||||
return;
|
||||
|
||||
SendChat(-1, CGameContext::CHAT_ALL, "Teams were swapped");
|
||||
|
||||
for(int i = 0; i < MAX_CLIENTS; ++i)
|
||||
{
|
||||
if(m_apPlayers[i] && m_apPlayers[i]->GetTeam() != TEAM_SPECTATORS)
|
||||
m_apPlayers[i]->SetTeam(m_apPlayers[i]->GetTeam()^1, false);
|
||||
}
|
||||
|
||||
(void)m_pController->CheckTeamBalance();
|
||||
}
|
||||
*/
|
||||
void CGameContext::OnTick()
|
||||
{
|
||||
// check tuning
|
||||
|
@ -1120,8 +1078,6 @@ void CGameContext::OnClientConnected(int ClientID)
|
|||
//players[client_id].init(client_id);
|
||||
//players[client_id].client_id = client_id;
|
||||
|
||||
//(void)m_pController->CheckTeamBalance();
|
||||
|
||||
#ifdef CONF_DEBUG
|
||||
if(g_Config.m_DbgDummies)
|
||||
{
|
||||
|
@ -1251,8 +1207,6 @@ void CGameContext::OnMessage(int MsgID, CUnpacker *pUnpacker, int ClientID)
|
|||
if(Length == 0 || (pMsg->m_pMessage[0]!='/' && (g_Config.m_SvSpamprotection && pPlayer->m_LastChat && pPlayer->m_LastChat+Server()->TickSpeed()*((31+Length)/32) > Server()->Tick())))
|
||||
return;
|
||||
|
||||
//pPlayer->m_LastChat = Server()->Tick();
|
||||
|
||||
int GameTeam = ((CGameControllerDDRace*)m_pController)->m_Teams.m_Core.Team(pPlayer->GetCID());
|
||||
if(Team)
|
||||
Team = ((pPlayer->GetTeam() == -1) ? CHAT_SPEC : GameTeam);
|
||||
|
@ -1666,17 +1620,9 @@ void CGameContext::OnMessage(int MsgID, CUnpacker *pUnpacker, int ClientID)
|
|||
{
|
||||
CNetMsg_Cl_SetTeam *pMsg = (CNetMsg_Cl_SetTeam *)pRawMsg;
|
||||
|
||||
//if(pPlayer->GetTeam() == pMsg->m_Team || (g_Config.m_SvSpamprotection && pPlayer->m_LastSetTeam && pPlayer->m_LastSetTeam+Server()->TickSpeed()*3 > Server()->Tick()))
|
||||
if(pPlayer->GetTeam() == pMsg->m_Team || (g_Config.m_SvSpamprotection && pPlayer->m_LastSetTeam && pPlayer->m_LastSetTeam + Server()->TickSpeed() * g_Config.m_SvTeamChangeDelay > Server()->Tick()))
|
||||
return;
|
||||
|
||||
/*if(pMsg->m_Team != TEAM_SPECTATORS && m_LockTeams)
|
||||
{
|
||||
pPlayer->m_LastSetTeam = Server()->Tick();
|
||||
SendBroadcast("Teams are locked", ClientID);
|
||||
return;
|
||||
}*/
|
||||
|
||||
//Kill Protection
|
||||
CCharacter *pChr = pPlayer->GetCharacter();
|
||||
if(pChr)
|
||||
|
@ -1702,21 +1648,15 @@ void CGameContext::OnMessage(int MsgID, CUnpacker *pUnpacker, int ClientID)
|
|||
// Switch team on given client and kill/respawn him
|
||||
if(m_pController->CanJoinTeam(pMsg->m_Team, ClientID))
|
||||
{
|
||||
//if(m_pController->CanChangeTeam(pPlayer, pMsg->m_Team))
|
||||
|
||||
if(pPlayer->IsPaused())
|
||||
SendChatTarget(ClientID,"Use /pause first then you can kill");
|
||||
else
|
||||
{
|
||||
//pPlayer->m_LastSetTeam = Server()->Tick();
|
||||
if(pPlayer->GetTeam() == TEAM_SPECTATORS || pMsg->m_Team == TEAM_SPECTATORS)
|
||||
m_VoteUpdate = true;
|
||||
pPlayer->SetTeam(pMsg->m_Team);
|
||||
//(void)m_pController->CheckTeamBalance();
|
||||
pPlayer->m_TeamChangeTick = Server()->Tick();
|
||||
}
|
||||
//else
|
||||
//SendBroadcast("Teams must be balanced, please join other team", ClientID);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -1862,7 +1802,6 @@ void CGameContext::OnMessage(int MsgID, CUnpacker *pUnpacker, int ClientID)
|
|||
pPlayer->m_TeeInfos.m_ColorBody = pMsg->m_ColorBody;
|
||||
pPlayer->m_TeeInfos.m_ColorFeet = pMsg->m_ColorFeet;
|
||||
pPlayer->FindDuplicateSkins();
|
||||
//m_pController->OnPlayerInfoChange(pPlayer);
|
||||
}
|
||||
else if (MsgID == NETMSGTYPE_CL_EMOTICON && !m_World.m_Paused)
|
||||
{
|
||||
|
@ -1963,7 +1902,6 @@ void CGameContext::OnMessage(int MsgID, CUnpacker *pUnpacker, int ClientID)
|
|||
pPlayer->m_TeeInfos.m_UseCustomColor = pMsg->m_UseCustomColor;
|
||||
pPlayer->m_TeeInfos.m_ColorBody = pMsg->m_ColorBody;
|
||||
pPlayer->m_TeeInfos.m_ColorFeet = pMsg->m_ColorFeet;
|
||||
//m_pController->OnPlayerInfoChange(pPlayer);
|
||||
|
||||
// send clear vote options
|
||||
CNetMsg_Sv_VoteClearOptions ClearMsg;
|
||||
|
@ -2170,7 +2108,6 @@ void CGameContext::ConMapbug(IConsole::IResult *pResult, void *pUserData)
|
|||
default:
|
||||
dbg_assert(0, "unreachable");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void CGameContext::ConSwitchOpen(IConsole::IResult *pResult, void *pUserData)
|
||||
|
@ -2191,9 +2128,6 @@ void CGameContext::ConPause(IConsole::IResult *pResult, void *pUserData)
|
|||
{
|
||||
CGameContext *pSelf = (CGameContext *)pUserData;
|
||||
|
||||
/*if(pSelf->m_pController->IsGameOver())
|
||||
return;*/
|
||||
|
||||
pSelf->m_World.m_Paused ^= 1;
|
||||
}
|
||||
|
||||
|
@ -2283,7 +2217,6 @@ void CGameContext::ConSetTeam(IConsole::IResult *pResult, void *pUserData)
|
|||
pSelf->m_apPlayers[ClientID]->SetTeam(Team);
|
||||
if(Team == TEAM_SPECTATORS)
|
||||
pSelf->m_apPlayers[ClientID]->Pause(CPlayer::PAUSE_NONE, true);
|
||||
// (void)pSelf->m_pController->CheckTeamBalance();
|
||||
}
|
||||
|
||||
void CGameContext::ConSetTeamAll(IConsole::IResult *pResult, void *pUserData)
|
||||
|
@ -2298,69 +2231,8 @@ void CGameContext::ConSetTeamAll(IConsole::IResult *pResult, void *pUserData)
|
|||
for(int i = 0; i < MAX_CLIENTS; ++i)
|
||||
if(pSelf->m_apPlayers[i])
|
||||
pSelf->m_apPlayers[i]->SetTeam(Team, false);
|
||||
|
||||
// (void)pSelf->m_pController->CheckTeamBalance();
|
||||
}
|
||||
/*
|
||||
void CGameContext::ConSwapTeams(IConsole::IResult *pResult, void *pUserData)
|
||||
{
|
||||
CGameContext *pSelf = (CGameContext *)pUserData;
|
||||
pSelf->SwapTeams();
|
||||
}
|
||||
|
||||
void CGameContext::ConShuffleTeams(IConsole::IResult *pResult, void *pUserData)
|
||||
{
|
||||
CGameContext *pSelf = (CGameContext *)pUserData;
|
||||
if(!pSelf->m_pController->IsTeamplay())
|
||||
return;
|
||||
|
||||
int CounterRed = 0;
|
||||
int CounterBlue = 0;
|
||||
int PlayerTeam = 0;
|
||||
for(int i = 0; i < MAX_CLIENTS; ++i)
|
||||
if(pSelf->m_apPlayers[i] && pSelf->m_apPlayers[i]->GetTeam() != TEAM_SPECTATORS)
|
||||
++PlayerTeam;
|
||||
PlayerTeam = (PlayerTeam+1)/2;
|
||||
|
||||
pSelf->SendChat(-1, CGameContext::CHAT_ALL, "Teams were shuffled");
|
||||
|
||||
for(int i = 0; i < MAX_CLIENTS; ++i)
|
||||
{
|
||||
if(pSelf->m_apPlayers[i] && pSelf->m_apPlayers[i]->GetTeam() != TEAM_SPECTATORS)
|
||||
{
|
||||
if(CounterRed == PlayerTeam)
|
||||
pSelf->m_apPlayers[i]->SetTeam(TEAM_BLUE, false);
|
||||
else if(CounterBlue == PlayerTeam)
|
||||
pSelf->m_apPlayers[i]->SetTeam(TEAM_RED, false);
|
||||
else
|
||||
{
|
||||
if(rand() % 2)
|
||||
{
|
||||
pSelf->m_apPlayers[i]->SetTeam(TEAM_BLUE, false);
|
||||
++CounterBlue;
|
||||
}
|
||||
else
|
||||
{
|
||||
pSelf->m_apPlayers[i]->SetTeam(TEAM_RED, false);
|
||||
++CounterRed;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// (void)pSelf->m_pController->CheckTeamBalance();
|
||||
}
|
||||
|
||||
void CGameContext::ConLockTeams(IConsole::IResult *pResult, void *pUserData)
|
||||
{
|
||||
CGameContext *pSelf = (CGameContext *)pUserData;
|
||||
pSelf->m_LockTeams ^= 1;
|
||||
if(pSelf->m_LockTeams)
|
||||
pSelf->SendChat(-1, CGameContext::CHAT_ALL, "Teams were locked");
|
||||
else
|
||||
pSelf->SendChat(-1, CGameContext::CHAT_ALL, "Teams were unlocked");
|
||||
}
|
||||
*/
|
||||
void CGameContext::ConAddVote(IConsole::IResult *pResult, void *pUserData)
|
||||
{
|
||||
CGameContext *pSelf = (CGameContext *)pUserData;
|
||||
|
@ -2840,15 +2712,6 @@ void CGameContext::OnInit(/*class IKernel *pKernel*/)
|
|||
CMapItemLayerTilemap *pTileMap = m_Layers.GameLayer();
|
||||
CTile *pTiles = (CTile *)Kernel()->RequestInterface<IMap>()->GetData(pTileMap->m_Data);
|
||||
|
||||
|
||||
|
||||
|
||||
/*
|
||||
num_spawn_points[0] = 0;
|
||||
num_spawn_points[1] = 0;
|
||||
num_spawn_points[2] = 0;
|
||||
*/
|
||||
|
||||
CTile *pFront = 0;
|
||||
CSwitchTile *pSwitch = 0;
|
||||
if(m_Layers.FrontLayer())
|
||||
|
|
|
@ -100,9 +100,6 @@ class CGameContext : public IGameServer
|
|||
static void ConSay(IConsole::IResult *pResult, void *pUserData);
|
||||
static void ConSetTeam(IConsole::IResult *pResult, void *pUserData);
|
||||
static void ConSetTeamAll(IConsole::IResult *pResult, void *pUserData);
|
||||
//static void ConSwapTeams(IConsole::IResult *pResult, void *pUserData);
|
||||
//static void ConShuffleTeams(IConsole::IResult *pResult, void *pUserData);
|
||||
//static void ConLockTeams(IConsole::IResult *pResult, void *pUserData);
|
||||
static void ConAddVote(IConsole::IResult *pResult, void *pUserData);
|
||||
static void ConRemoveVote(IConsole::IResult *pResult, void *pUserData);
|
||||
static void ConForceVote(IConsole::IResult *pResult, void *pUserData);
|
||||
|
@ -139,8 +136,6 @@ public:
|
|||
class CCharacter *GetPlayerChar(int ClientID);
|
||||
bool EmulateBug(int Bug);
|
||||
|
||||
//int m_LockTeams;
|
||||
|
||||
// voting
|
||||
void StartVote(const char *pDesc, const char *pCommand, const char *pReason);
|
||||
void EndVote();
|
||||
|
@ -212,8 +207,6 @@ public:
|
|||
void ProgressVoteOptions(int ClientID);
|
||||
|
||||
//
|
||||
//void SwapTeams();
|
||||
|
||||
void LoadMapSettings();
|
||||
|
||||
// engine events
|
||||
|
|
|
@ -31,8 +31,6 @@ IGameController::IGameController(class CGameContext *pGameServer)
|
|||
m_RoundStartTick = Server()->Tick();
|
||||
m_RoundCount = 0;
|
||||
m_GameFlags = 0;
|
||||
//m_aTeamscore[TEAM_RED] = 0;
|
||||
//m_aTeamscore[TEAM_BLUE] = 0;
|
||||
m_aMapWish[0] = 0;
|
||||
|
||||
m_UnbalancedTick = -1;
|
||||
|
@ -112,32 +110,14 @@ bool IGameController::CanSpawn(int Team, vec2 *pOutPos)
|
|||
if(Team == TEAM_SPECTATORS)
|
||||
return false;
|
||||
|
||||
/*if(IsTeamplay())
|
||||
{
|
||||
Eval.m_FriendlyTeam = Team;
|
||||
|
||||
// first try own team spawn, then normal spawn and then enemy
|
||||
EvaluateSpawnType(&Eval, 1+(Team&1));
|
||||
if(!Eval.m_Got)
|
||||
{
|
||||
EvaluateSpawnType(&Eval, 0);
|
||||
if(!Eval.m_Got)
|
||||
EvaluateSpawnType(&Eval, 1+((Team+1)&1));
|
||||
}
|
||||
}
|
||||
else
|
||||
{*/
|
||||
EvaluateSpawnType(&Eval, 0);
|
||||
EvaluateSpawnType(&Eval, 1);
|
||||
EvaluateSpawnType(&Eval, 2);
|
||||
//}
|
||||
EvaluateSpawnType(&Eval, 0);
|
||||
EvaluateSpawnType(&Eval, 1);
|
||||
EvaluateSpawnType(&Eval, 2);
|
||||
|
||||
*pOutPos = Eval.m_Pos;
|
||||
return Eval.m_Got;
|
||||
}
|
||||
|
||||
|
||||
//bool IGameController::OnEntity(int Index, vec2 Pos)
|
||||
bool IGameController::OnEntity(int Index, vec2 Pos, int Layer, int Flags, int Number)
|
||||
{
|
||||
if (Index < 0)
|
||||
|
@ -159,7 +139,6 @@ bool IGameController::OnEntity(int Index, vec2 Pos, int Layer, int Flags, int Nu
|
|||
sides[6]=GameServer()->Collision()->Entity(x-1,y, Layer);
|
||||
sides[7]=GameServer()->Collision()->Entity(x-1,y+1, Layer);
|
||||
|
||||
|
||||
if(Index == ENTITY_SPAWN)
|
||||
m_aaSpawnPoints[0][m_aNumSpawnPoints[0]++] = Pos;
|
||||
else if(Index == ENTITY_SPAWN_RED)
|
||||
|
@ -264,7 +243,6 @@ bool IGameController::OnEntity(int Index, vec2 Pos, int Layer, int Flags, int Nu
|
|||
Type = POWERUP_WEAPON;
|
||||
SubType = WEAPON_RIFLE;
|
||||
}
|
||||
//else if(Index == ENTITY_POWERUP_NINJA && g_Config.m_SvPowerups)
|
||||
else if(Index == ENTITY_POWERUP_NINJA)
|
||||
{
|
||||
Type = POWERUP_NINJA;
|
||||
|
@ -355,7 +333,6 @@ bool IGameController::OnEntity(int Index, vec2 Pos, int Layer, int Flags, int Nu
|
|||
|
||||
if(Type != -1)
|
||||
{
|
||||
//CPickup *pPickup = new CPickup(&GameServer()->m_World, Type, SubType);
|
||||
CPickup *pPickup = new CPickup(&GameServer()->m_World, Type, SubType, Layer, Number);
|
||||
pPickup->m_Pos = Pos;
|
||||
return true;
|
||||
|
@ -380,20 +357,7 @@ void IGameController::ResetGame()
|
|||
}
|
||||
|
||||
const char *IGameController::GetTeamName(int Team)
|
||||
{/*
|
||||
if(IsTeamplay())
|
||||
{
|
||||
if(Team == TEAM_RED)
|
||||
return "red team";
|
||||
else if(Team == TEAM_BLUE)
|
||||
return "blue team";
|
||||
}
|
||||
else
|
||||
{
|
||||
if(Team == 0)
|
||||
return "game";
|
||||
}*/
|
||||
|
||||
{
|
||||
if(Team == 0)
|
||||
return "game";
|
||||
return "spectators";
|
||||
|
@ -409,8 +373,6 @@ void IGameController::StartRound()
|
|||
m_SuddenDeath = 0;
|
||||
m_GameOverTick = -1;
|
||||
GameServer()->m_World.m_Paused = false;
|
||||
//m_aTeamscore[TEAM_RED] = 0;
|
||||
//m_aTeamscore[TEAM_BLUE] = 0;
|
||||
m_ForceBalanced = false;
|
||||
Server()->DemoRecorder_HandleAutoStart();
|
||||
char aBuf[256];
|
||||
|
@ -420,137 +382,18 @@ void IGameController::StartRound()
|
|||
|
||||
void IGameController::ChangeMap(const char *pToMap)
|
||||
{
|
||||
/*str_copy(m_aMapWish, pToMap, sizeof(m_aMapWish));
|
||||
EndRound();*/
|
||||
str_copy(g_Config.m_SvMap, pToMap, sizeof(g_Config.m_SvMap));
|
||||
}
|
||||
|
||||
/*void IGameController::CycleMap()
|
||||
{
|
||||
if(m_aMapWish[0] != 0)
|
||||
{
|
||||
char aBuf[256];
|
||||
str_format(aBuf, sizeof(aBuf), "rotating map to %s", m_aMapWish);
|
||||
GameServer()->Console()->Print(IConsole::OUTPUT_LEVEL_DEBUG, "game", aBuf);
|
||||
str_copy(g_Config.m_SvMap, m_aMapWish, sizeof(g_Config.m_SvMap));
|
||||
m_aMapWish[0] = 0;
|
||||
m_RoundCount = 0;
|
||||
return;
|
||||
}
|
||||
if(!str_length(g_Config.m_SvMaprotation))
|
||||
return;
|
||||
|
||||
if(m_RoundCount < g_Config.m_SvRoundsPerMap-1)
|
||||
{
|
||||
if(g_Config.m_SvRoundSwap)
|
||||
GameServer()->SwapTeams();
|
||||
return;
|
||||
}
|
||||
|
||||
// handle maprotation
|
||||
const char *pMapRotation = g_Config.m_SvMaprotation;
|
||||
const char *pCurrentMap = g_Config.m_SvMap;
|
||||
|
||||
int CurrentMapLen = str_length(pCurrentMap);
|
||||
const char *pNextMap = pMapRotation;
|
||||
while(*pNextMap)
|
||||
{
|
||||
int WordLen = 0;
|
||||
while(pNextMap[WordLen] && !IsSeparator(pNextMap[WordLen]))
|
||||
WordLen++;
|
||||
|
||||
if(WordLen == CurrentMapLen && str_comp_num(pNextMap, pCurrentMap, CurrentMapLen) == 0)
|
||||
{
|
||||
// map found
|
||||
pNextMap += CurrentMapLen;
|
||||
while(*pNextMap && IsSeparator(*pNextMap))
|
||||
pNextMap++;
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
pNextMap++;
|
||||
}
|
||||
|
||||
// restart rotation
|
||||
if(pNextMap[0] == 0)
|
||||
pNextMap = pMapRotation;
|
||||
|
||||
// cut out the next map
|
||||
char aBuf[512] = {0};
|
||||
for(int i = 0; i < 511; i++)
|
||||
{
|
||||
aBuf[i] = pNextMap[i];
|
||||
if(IsSeparator(pNextMap[i]) || pNextMap[i] == 0)
|
||||
{
|
||||
aBuf[i] = 0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// skip spaces
|
||||
int i = 0;
|
||||
while(IsSeparator(aBuf[i]))
|
||||
i++;
|
||||
|
||||
m_RoundCount = 0;
|
||||
|
||||
char aBufMsg[256];
|
||||
str_format(aBufMsg, sizeof(aBufMsg), "rotating map to %s", &aBuf[i]);
|
||||
GameServer()->Console()->Print(IConsole::OUTPUT_LEVEL_DEBUG, "game", aBuf);
|
||||
str_copy(g_Config.m_SvMap, &aBuf[i], sizeof(g_Config.m_SvMap));
|
||||
}*/
|
||||
|
||||
void IGameController::PostReset()
|
||||
{
|
||||
for(int i = 0; i < MAX_CLIENTS; i++)
|
||||
{
|
||||
if(GameServer()->m_apPlayers[i])
|
||||
{
|
||||
GameServer()->m_apPlayers[i]->Respawn();
|
||||
//GameServer()->m_apPlayers[i]->m_Score = 0;
|
||||
//GameServer()->m_apPlayers[i]->m_ScoreStartTick = Server()->Tick();
|
||||
//GameServer()->m_apPlayers[i]->m_RespawnTick = Server()->Tick()+Server()->TickSpeed()/2;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*void IGameController::OnPlayerInfoChange(class CPlayer *pP)
|
||||
{
|
||||
const int aTeamColors[2] = {65387, 10223467};
|
||||
if(IsTeamplay())
|
||||
{
|
||||
pP->m_TeeInfos.m_UseCustomColor = 1;
|
||||
if(pP->GetTeam() >= TEAM_RED && pP->GetTeam() <= TEAM_BLUE)
|
||||
{
|
||||
pP->m_TeeInfos.m_ColorBody = aTeamColors[pP->GetTeam()];
|
||||
pP->m_TeeInfos.m_ColorFeet = aTeamColors[pP->GetTeam()];
|
||||
}
|
||||
else
|
||||
{
|
||||
pP->m_TeeInfos.m_ColorBody = 12895054;
|
||||
pP->m_TeeInfos.m_ColorFeet = 12895054;
|
||||
}
|
||||
}
|
||||
}*/
|
||||
|
||||
|
||||
int IGameController::OnCharacterDeath(class CCharacter *pVictim, class CPlayer *pKiller, int Weapon)
|
||||
{
|
||||
/*// do scoreing
|
||||
if(!pKiller || Weapon == WEAPON_GAME)
|
||||
return 0;
|
||||
if(pKiller == pVictim->GetPlayer())
|
||||
pVictim->GetPlayer()->m_Score--; // suicide
|
||||
else
|
||||
{
|
||||
if(IsTeamplay() && pVictim->GetPlayer()->GetTeam() == pKiller->GetTeam())
|
||||
pKiller->m_Score--; // teamkill
|
||||
else
|
||||
pKiller->m_Score++; // normal kill
|
||||
}
|
||||
if(Weapon == WEAPON_SELF)
|
||||
pVictim->GetPlayer()->m_RespawnTick = Server()->Tick()+Server()->TickSpeed()*3.0f;*/
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -572,34 +415,12 @@ void IGameController::DoWarmup(int Seconds)
|
|||
m_Warmup = Seconds*Server()->TickSpeed();
|
||||
}
|
||||
|
||||
/*bool IGameController::IsFriendlyFire(int ClientID1, int ClientID2)
|
||||
{
|
||||
if(ClientID1 == ClientID2)
|
||||
return false;
|
||||
|
||||
if(IsTeamplay())
|
||||
{
|
||||
if(!GameServer()->m_apPlayers[ClientID1] || !GameServer()->m_apPlayers[ClientID2])
|
||||
return false;
|
||||
|
||||
if(GameServer()->m_apPlayers[ClientID1]->GetTeam() == GameServer()->m_apPlayers[ClientID2]->GetTeam())
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}*/
|
||||
|
||||
bool IGameController::IsForceBalanced()
|
||||
{
|
||||
/*if(m_ForceBalanced)
|
||||
{
|
||||
m_ForceBalanced = false;
|
||||
return true;
|
||||
}
|
||||
else*/
|
||||
return false;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
bool IGameController::CanBeMovedOnBalance(int ClientID)
|
||||
{
|
||||
return true;
|
||||
|
@ -620,72 +441,10 @@ void IGameController::Tick()
|
|||
// game over.. wait for restart
|
||||
if(Server()->Tick() > m_GameOverTick+Server()->TickSpeed()*10)
|
||||
{
|
||||
//CycleMap();
|
||||
StartRound();
|
||||
m_RoundCount++;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
// game is Paused
|
||||
if(GameServer()->m_World.m_Paused)
|
||||
++m_RoundStartTick;
|
||||
|
||||
// do team-balancing
|
||||
if(IsTeamplay() && m_UnbalancedTick != -1 && Server()->Tick() > m_UnbalancedTick+g_Config.m_SvTeambalanceTime*Server()->TickSpeed()*60)
|
||||
{
|
||||
GameServer()->Console()->Print(IConsole::OUTPUT_LEVEL_DEBUG, "game", "Balancing teams");
|
||||
|
||||
int aT[2] = {0,0};
|
||||
float aTScore[2] = {0,0};
|
||||
float aPScore[MAX_CLIENTS] = {0.0f};
|
||||
for(int i = 0; i < MAX_CLIENTS; i++)
|
||||
{
|
||||
if(GameServer()->m_apPlayers[i] && GameServer()->m_apPlayers[i]->GetTeam() != TEAM_SPECTATORS)
|
||||
{
|
||||
aT[GameServer()->m_apPlayers[i]->GetTeam()]++;
|
||||
aPScore[i] = GameServer()->m_apPlayers[i]->m_Score*Server()->TickSpeed()*60.0f/
|
||||
(Server()->Tick()-GameServer()->m_apPlayers[i]->m_ScoreStartTick);
|
||||
aTScore[GameServer()->m_apPlayers[i]->GetTeam()] += aPScore[i];
|
||||
}
|
||||
}
|
||||
|
||||
// are teams unbalanced?
|
||||
if(absolute(aT[0]-aT[1]) >= 2)
|
||||
{
|
||||
int M = (aT[0] > aT[1]) ? 0 : 1;
|
||||
int NumBalance = absolute(aT[0]-aT[1]) / 2;
|
||||
|
||||
do
|
||||
{
|
||||
CPlayer *pP = 0;
|
||||
float PD = aTScore[M];
|
||||
for(int i = 0; i < MAX_CLIENTS; i++)
|
||||
{
|
||||
if(!GameServer()->m_apPlayers[i] || !CanBeMovedOnBalance(i))
|
||||
continue;
|
||||
// remember the player who would cause lowest score-difference
|
||||
if(GameServer()->m_apPlayers[i]->GetTeam() == M && (!pP || absolute((aTScore[M^1]+aPScore[i]) - (aTScore[M]-aPScore[i])) < PD))
|
||||
{
|
||||
pP = GameServer()->m_apPlayers[i];
|
||||
PD = absolute((aTScore[M^1]+aPScore[i]) - (aTScore[M]-aPScore[i]));
|
||||
}
|
||||
}
|
||||
|
||||
// move the player to the other team
|
||||
int Temp = pP->m_LastActionTick;
|
||||
pP->SetTeam(M^1);
|
||||
pP->m_LastActionTick = Temp;
|
||||
|
||||
pP->Respawn();
|
||||
pP->m_ForceBalanced = true;
|
||||
} while (--NumBalance);
|
||||
|
||||
m_ForceBalanced = true;
|
||||
}
|
||||
m_UnbalancedTick = -1;
|
||||
}
|
||||
*/
|
||||
// check for inactive players
|
||||
if(g_Config.m_SvInactiveKickTime > 0)
|
||||
{
|
||||
|
@ -733,16 +492,8 @@ void IGameController::Tick()
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
//DoWincheck();
|
||||
}
|
||||
|
||||
|
||||
/*bool IGameController::IsTeamplay() const
|
||||
{
|
||||
return m_GameFlags&GAMEFLAG_TEAMS;
|
||||
}*/
|
||||
|
||||
void IGameController::Snap(int SnappingClient)
|
||||
{
|
||||
CNetObj_GameInfo *pGameInfoObj = (CNetObj_GameInfo *)Server()->SnapNewItem(NETOBJTYPE_GAMEINFO, 0, sizeof(CNetObj_GameInfo));
|
||||
|
@ -760,10 +511,7 @@ void IGameController::Snap(int SnappingClient)
|
|||
pGameInfoObj->m_RoundStartTick = m_RoundStartTick;
|
||||
pGameInfoObj->m_WarmupTimer = m_Warmup;
|
||||
|
||||
//pGameInfoObj->m_ScoreLimit = g_Config.m_SvScorelimit;
|
||||
//pGameInfoObj->m_TimeLimit = g_Config.m_SvTimelimit;
|
||||
|
||||
pGameInfoObj->m_RoundNum = /*(str_length(g_Config.m_SvMaprotation) && g_Config.m_SvRoundsPerMap) ? g_Config.m_SvRoundsPerMap :*/ 0;
|
||||
pGameInfoObj->m_RoundNum = 0;
|
||||
pGameInfoObj->m_RoundCurrent = m_RoundCount+1;
|
||||
|
||||
CCharacter *pChr;
|
||||
|
@ -809,8 +557,6 @@ int IGameController::GetAutoTeam(int NotThisID)
|
|||
}
|
||||
|
||||
int Team = 0;
|
||||
//if(IsTeamplay())
|
||||
//Team = aNumplayers[TEAM_RED] > aNumplayers[TEAM_BLUE] ? TEAM_BLUE : TEAM_RED;
|
||||
|
||||
if(CanJoinTeam(Team, NotThisID))
|
||||
return Team;
|
||||
|
@ -835,123 +581,9 @@ bool IGameController::CanJoinTeam(int Team, int NotThisID)
|
|||
return (aNumplayers[0] + aNumplayers[1]) < Server()->MaxClients()-g_Config.m_SvSpectatorSlots;
|
||||
}
|
||||
|
||||
/*bool IGameController::CheckTeamBalance()
|
||||
{
|
||||
if(!IsTeamplay() || !g_Config.m_SvTeambalanceTime)
|
||||
return true;
|
||||
|
||||
int aT[2] = {0, 0};
|
||||
for(int i = 0; i < MAX_CLIENTS; i++)
|
||||
{
|
||||
CPlayer *pP = GameServer()->m_apPlayers[i];
|
||||
if(pP && pP->GetTeam() != TEAM_SPECTATORS)
|
||||
aT[pP->GetTeam()]++;
|
||||
}
|
||||
|
||||
char aBuf[256];
|
||||
if(absolute(aT[0]-aT[1]) >= 2)
|
||||
{
|
||||
str_format(aBuf, sizeof(aBuf), "Teams are NOT balanced (red=%d blue=%d)", aT[0], aT[1]);
|
||||
GameServer()->Console()->Print(IConsole::OUTPUT_LEVEL_DEBUG, "game", aBuf);
|
||||
if(GameServer()->m_pController->m_UnbalancedTick == -1)
|
||||
GameServer()->m_pController->m_UnbalancedTick = Server()->Tick();
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
str_format(aBuf, sizeof(aBuf), "Teams are balanced (red=%d blue=%d)", aT[0], aT[1]);
|
||||
GameServer()->Console()->Print(IConsole::OUTPUT_LEVEL_DEBUG, "game", aBuf);
|
||||
GameServer()->m_pController->m_UnbalancedTick = -1;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
bool IGameController::CanChangeTeam(CPlayer *pPlayer, int JoinTeam)
|
||||
{
|
||||
int aT[2] = {0, 0};
|
||||
|
||||
if (!IsTeamplay() || JoinTeam == TEAM_SPECTATORS || !g_Config.m_SvTeambalanceTime)
|
||||
return true;
|
||||
|
||||
for(int i = 0; i < MAX_CLIENTS; i++)
|
||||
{
|
||||
CPlayer *pP = GameServer()->m_apPlayers[i];
|
||||
if(pP && pP->GetTeam() != TEAM_SPECTATORS)
|
||||
aT[pP->GetTeam()]++;
|
||||
}
|
||||
|
||||
// simulate what would happen if changed team
|
||||
aT[JoinTeam]++;
|
||||
if (pPlayer->GetTeam() != TEAM_SPECTATORS)
|
||||
aT[JoinTeam^1]--;
|
||||
|
||||
// there is a player-difference of at least 2
|
||||
if(absolute(aT[0]-aT[1]) >= 2)
|
||||
{
|
||||
// player wants to join team with less players
|
||||
if ((aT[0] < aT[1] && JoinTeam == TEAM_RED) || (aT[0] > aT[1] && JoinTeam == TEAM_BLUE))
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
else
|
||||
return true;
|
||||
}
|
||||
|
||||
void IGameController::DoWincheck()
|
||||
{
|
||||
if(m_GameOverTick == -1 && !m_Warmup && !GameServer()->m_World.m_ResetRequested)
|
||||
{
|
||||
if(IsTeamplay())
|
||||
{
|
||||
// check score win condition
|
||||
if((g_Config.m_SvScorelimit > 0 && (m_aTeamscore[TEAM_RED] >= g_Config.m_SvScorelimit || m_aTeamscore[TEAM_BLUE] >= g_Config.m_SvScorelimit)) ||
|
||||
(g_Config.m_SvTimelimit > 0 && (Server()->Tick()-m_RoundStartTick) >= g_Config.m_SvTimelimit*Server()->TickSpeed()*60))
|
||||
{
|
||||
if(m_aTeamscore[TEAM_RED] != m_aTeamscore[TEAM_BLUE])
|
||||
EndRound();
|
||||
else
|
||||
m_SuddenDeath = 1;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// gather some stats
|
||||
int Topscore = 0;
|
||||
int TopscoreCount = 0;
|
||||
for(int i = 0; i < MAX_CLIENTS; i++)
|
||||
{
|
||||
if(GameServer()->m_apPlayers[i])
|
||||
{
|
||||
if(GameServer()->m_apPlayers[i]->m_Score > Topscore)
|
||||
{
|
||||
Topscore = GameServer()->m_apPlayers[i]->m_Score;
|
||||
TopscoreCount = 1;
|
||||
}
|
||||
else if(GameServer()->m_apPlayers[i]->m_Score == Topscore)
|
||||
TopscoreCount++;
|
||||
}
|
||||
}
|
||||
|
||||
// check score win condition
|
||||
if((g_Config.m_SvScorelimit > 0 && Topscore >= g_Config.m_SvScorelimit) ||
|
||||
(g_Config.m_SvTimelimit > 0 && (Server()->Tick()-m_RoundStartTick) >= g_Config.m_SvTimelimit*Server()->TickSpeed()*60))
|
||||
{
|
||||
if(TopscoreCount == 1)
|
||||
EndRound();
|
||||
else
|
||||
m_SuddenDeath = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
*/
|
||||
int IGameController::ClampTeam(int Team)
|
||||
{
|
||||
if(Team < 0)
|
||||
return TEAM_SPECTATORS;
|
||||
//if(IsTeamplay())
|
||||
//return Team&1;
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -52,7 +52,6 @@ protected:
|
|||
float EvaluateSpawnPos(CSpawnEval *pEval, vec2 Pos);
|
||||
void EvaluateSpawnType(CSpawnEval *pEval, int Type);
|
||||
|
||||
//void CycleMap();
|
||||
void ResetGame();
|
||||
|
||||
char m_aMapWish[128];
|
||||
|
@ -62,8 +61,6 @@ protected:
|
|||
int m_GameOverTick;
|
||||
int m_SuddenDeath;
|
||||
|
||||
//int m_aTeamscore[2];
|
||||
|
||||
int m_Warmup;
|
||||
int m_RoundCount;
|
||||
|
||||
|
@ -74,14 +71,9 @@ protected:
|
|||
public:
|
||||
const char *m_pGameType;
|
||||
|
||||
//bool IsTeamplay() const;
|
||||
//bool IsGameOver() const { return m_GameOverTick != -1; }
|
||||
|
||||
IGameController(class CGameContext *pGameServer);
|
||||
virtual ~IGameController();
|
||||
|
||||
// virtual void DoWincheck();
|
||||
|
||||
void DoWarmup(int Seconds);
|
||||
|
||||
void StartRound();
|
||||
|
@ -138,8 +130,6 @@ public:
|
|||
virtual int OnCharacterDeath(class CCharacter *pVictim, class CPlayer *pKiller, int Weapon);
|
||||
|
||||
|
||||
//virtual void OnPlayerInfoChange(class CPlayer *pP);
|
||||
|
||||
//
|
||||
virtual bool CanSpawn(int Team, vec2 *pPos);
|
||||
|
||||
|
@ -149,8 +139,6 @@ public:
|
|||
virtual const char *GetTeamName(int Team);
|
||||
virtual int GetAutoTeam(int NotThisID);
|
||||
virtual bool CanJoinTeam(int Team, int NotThisID);
|
||||
//bool CheckTeamBalance();
|
||||
//bool CanChangeTeam(CPlayer *pPplayer, int JoinTeam);
|
||||
int ClampTeam(int Team);
|
||||
|
||||
virtual void PostReset();
|
||||
|
|
Loading…
Reference in a new issue