mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-10 10:08:18 +00:00
Implementing the FrontLayer
Also trimmed the trailings Signed-off-by: GreYFoXGTi <GreYFoXGTi@GMaiL.CoM>
This commit is contained in:
parent
8450116185
commit
6bb5fcf316
|
@ -21,10 +21,6 @@ CCollision::CCollision()
|
||||||
m_pSpeedup = 0;
|
m_pSpeedup = 0;
|
||||||
m_pFront = 0;
|
m_pFront = 0;
|
||||||
}
|
}
|
||||||
int CCollision::IsSolid(int x, int y)
|
|
||||||
{
|
|
||||||
return (GetTile(x,y)&COLFLAG_SOLID);
|
|
||||||
}
|
|
||||||
|
|
||||||
void CCollision::Init(class CLayers *pLayers)
|
void CCollision::Init(class CLayers *pLayers)
|
||||||
{
|
{
|
||||||
|
@ -113,7 +109,9 @@ int CCollision::GetMapIndex(vec2 PrevPos, vec2 Pos)
|
||||||
else dbg_msg("GetMapIndex(","ny*m_Width+nx %d",ny*m_Width+nx);//REMOVE */
|
else dbg_msg("GetMapIndex(","ny*m_Width+nx %d",ny*m_Width+nx);//REMOVE */
|
||||||
|
|
||||||
if((m_pTiles[ny*m_Width+nx].m_Index >= TILE_THROUGH && m_pTiles[ny*m_Width+nx].m_Index < TILE_TELEIN) ||
|
if((m_pTiles[ny*m_Width+nx].m_Index >= TILE_THROUGH && m_pTiles[ny*m_Width+nx].m_Index < TILE_TELEIN) ||
|
||||||
((m_pTiles[ny*m_Width+nx].m_Index >TILE_BOOST)&&(m_pTiles[ny*m_Width+nx].m_Index <= TILE_NPH) ) ||
|
((m_pTiles[ny*m_Width+nx].m_Index >TILE_BOOST)&&(m_pTiles[ny*m_Width+nx].m_Index <= TILE_NPH) ) ||
|
||||||
|
(m_pFront && (m_pFront[ny*m_Width+nx].m_Index >= TILE_THROUGH && m_pFront[ny*m_Width+nx].m_Index < TILE_TELEIN)) ||
|
||||||
|
(m_pFront && ((m_pFront[ny*m_Width+nx].m_Index >TILE_BOOST)&&(m_pFront[ny*m_Width+nx].m_Index <= TILE_NPH))) ||
|
||||||
(m_pTele && (m_pTele[ny*m_Width+nx].m_Type == TILE_TELEIN || m_pTele[ny*m_Width+nx].m_Type == TILE_TELEOUT)) ||
|
(m_pTele && (m_pTele[ny*m_Width+nx].m_Type == TILE_TELEIN || m_pTele[ny*m_Width+nx].m_Type == TILE_TELEOUT)) ||
|
||||||
(m_pSpeedup && m_pSpeedup[ny*m_Width+nx].m_Force > 0))
|
(m_pSpeedup && m_pSpeedup[ny*m_Width+nx].m_Force > 0))
|
||||||
{
|
{
|
||||||
|
@ -133,9 +131,11 @@ int CCollision::GetMapIndex(vec2 PrevPos, vec2 Pos)
|
||||||
nx = clamp((int)Tmp.x/32, 0, m_Width-1);
|
nx = clamp((int)Tmp.x/32, 0, m_Width-1);
|
||||||
ny = clamp((int)Tmp.y/32, 0, m_Height-1);
|
ny = clamp((int)Tmp.y/32, 0, m_Height-1);
|
||||||
if((m_pTiles[ny*m_Width+nx].m_Index >= TILE_THROUGH && m_pTiles[ny*m_Width+nx].m_Index < TILE_TELEIN) ||
|
if((m_pTiles[ny*m_Width+nx].m_Index >= TILE_THROUGH && m_pTiles[ny*m_Width+nx].m_Index < TILE_TELEIN) ||
|
||||||
((m_pTiles[ny*m_Width+nx].m_Index >TILE_BOOST)&&(m_pTiles[ny*m_Width+nx].m_Index <= TILE_NPH) ) ||
|
((m_pTiles[ny*m_Width+nx].m_Index >TILE_BOOST)&&(m_pTiles[ny*m_Width+nx].m_Index <= TILE_NPH) ) ||
|
||||||
(m_pTele && (m_pTele[ny*m_Width+nx].m_Type == TILE_TELEIN || m_pTele[ny*m_Width+nx].m_Type == TILE_TELEOUT)) ||
|
(m_pFront && (m_pFront[ny*m_Width+nx].m_Index >= TILE_THROUGH && m_pFront[ny*m_Width+nx].m_Index < TILE_TELEIN)) ||
|
||||||
(m_pSpeedup && m_pSpeedup[ny*m_Width+nx].m_Force > 0))
|
(m_pFront && ((m_pFront[ny*m_Width+nx].m_Index >TILE_BOOST)&&(m_pFront[ny*m_Width+nx].m_Index <= TILE_NPH))) ||
|
||||||
|
(m_pTele && (m_pTele[ny*m_Width+nx].m_Type == TILE_TELEIN || m_pTele[ny*m_Width+nx].m_Type == TILE_TELEOUT)) ||
|
||||||
|
(m_pSpeedup && m_pSpeedup[ny*m_Width+nx].m_Force > 0))
|
||||||
{
|
{
|
||||||
return ny*m_Width+nx;
|
return ny*m_Width+nx;
|
||||||
}
|
}
|
||||||
|
@ -159,6 +159,13 @@ int CCollision::GetCollisionDDRace(int Index)
|
||||||
return 0;
|
return 0;
|
||||||
return m_pTiles[Index].m_Index;
|
return m_pTiles[Index].m_Index;
|
||||||
}
|
}
|
||||||
|
int CCollision::GetCollisionDDRace2(int Index)
|
||||||
|
{
|
||||||
|
/*dbg_msg("GetCollisionDDRace2","m_pFront[%d].m_Index = %d",Index,m_pFront[Index].m_Index);//Remove*/
|
||||||
|
if(Index < 0)
|
||||||
|
return 0;
|
||||||
|
return m_pFront[Index].m_Index;
|
||||||
|
}
|
||||||
|
|
||||||
int CCollision::GetTile(int x, int y)
|
int CCollision::GetTile(int x, int y)
|
||||||
{
|
{
|
||||||
|
@ -173,9 +180,9 @@ int CCollision::GetTile(int x, int y)
|
||||||
else
|
else
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
int CCollision::Entitiy(int x, int y)
|
int CCollision::Entity(int x, int y, bool Front)
|
||||||
{
|
{
|
||||||
int Index = m_pTiles[y*m_Width+x].m_Index;
|
int Index = Front?m_pFront[y*m_Width+x].m_Index:m_pTiles[y*m_Width+x].m_Index;
|
||||||
return Index-ENTITY_OFFSET;
|
return Index-ENTITY_OFFSET;
|
||||||
}
|
}
|
||||||
void CCollision::SetCollisionAt(float x, float y, int flag)
|
void CCollision::SetCollisionAt(float x, float y, int flag)
|
||||||
|
@ -379,6 +386,11 @@ bool CCollision::TestBox(vec2 Pos, vec2 Size)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int CCollision::IsSolid(int x, int y)
|
||||||
|
{
|
||||||
|
return (GetTile(x,y)&COLFLAG_SOLID);
|
||||||
|
}
|
||||||
|
|
||||||
int CCollision::IsNoLaser(int x, int y)
|
int CCollision::IsNoLaser(int x, int y)
|
||||||
{
|
{
|
||||||
return (CCollision::GetTile(x,y) & COLFLAG_NOLASER);
|
return (CCollision::GetTile(x,y) & COLFLAG_NOLASER);
|
||||||
|
@ -444,10 +456,11 @@ bool CCollision::IsFront(int x, int y)
|
||||||
|
|
||||||
if(m_pFront[ny*m_pLayers->FrontLayer()->m_Width+nx].m_Index > 0)
|
if(m_pFront[ny*m_pLayers->FrontLayer()->m_Width+nx].m_Index > 0)
|
||||||
{
|
{
|
||||||
dbg_msg("IsFront","True m_Index=%d",m_pFront[ny*m_pLayers->FrontLayer()->m_Width+nx].m_Index);//Remove*/
|
/*dbg_msg("IsFront","True m_Index=%d",m_pFront[ny*m_pLayers->FrontLayer()->m_Width+nx].m_Index);//Remove*/
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else dbg_msg("IsFront","Welcome to the front layer m_Index=%d",m_pFront[ny*m_pLayers->FrontLayer()->m_Width+nx].m_Index);//Remove*/
|
/*else dbg_msg("IsFront","Welcome to the front layer m_Index=%d",m_pFront[ny*m_pLayers->FrontLayer()->m_Width+nx].m_Index);//Remove*/
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
int CCollision::IsCp(int x, int y)
|
int CCollision::IsCp(int x, int y)
|
||||||
|
|
|
@ -34,11 +34,12 @@ public:
|
||||||
void MoveBox(vec2 *pInoutPos, vec2 *pInoutVel, vec2 Size, float Elasticity);
|
void MoveBox(vec2 *pInoutPos, vec2 *pInoutVel, vec2 Size, float Elasticity);
|
||||||
bool TestBox(vec2 Pos, vec2 Size);
|
bool TestBox(vec2 Pos, vec2 Size);
|
||||||
int GetTile(int x, int y);
|
int GetTile(int x, int y);
|
||||||
int Entitiy(int x, int y);
|
int Entity(int x, int y, bool Front);
|
||||||
//DDRace
|
//DDRace
|
||||||
int GetMapIndex(vec2 PrevPos, vec2 Pos);
|
int GetMapIndex(vec2 PrevPos, vec2 Pos);
|
||||||
vec2 GetPos(int Index);
|
vec2 GetPos(int Index);
|
||||||
int GetCollisionDDRace(int Index);
|
int GetCollisionDDRace(int Index);
|
||||||
|
int GetCollisionDDRace2(int Index);
|
||||||
int IsTeleport(int x, int y);
|
int IsTeleport(int x, int y);
|
||||||
int IsCheckpoint(int Index);
|
int IsCheckpoint(int Index);
|
||||||
bool IsSpeedup(int x, int y);
|
bool IsSpeedup(int x, int y);
|
||||||
|
|
|
@ -558,7 +558,8 @@ void CCharacter::OnDirectInput(CNetObj_PlayerInput *pNewInput)
|
||||||
void CCharacter::Tick()
|
void CCharacter::Tick()
|
||||||
{
|
{
|
||||||
int MapIndex = GameServer()->Collision()->GetMapIndex(m_PrevPos, m_Pos);
|
int MapIndex = GameServer()->Collision()->GetMapIndex(m_PrevPos, m_Pos);
|
||||||
int TileIndex = GameServer()->Collision()->GetCollisionDDRace(MapIndex);
|
int TileIndex1 = GameServer()->Collision()->GetCollisionDDRace(MapIndex);
|
||||||
|
int TileIndex2 = GameServer()->Collision()->GetCollisionDDRace2(MapIndex);
|
||||||
if(m_RaceState == RACE_PAUSE) {
|
if(m_RaceState == RACE_PAUSE) {
|
||||||
m_Input.m_Direction = 0;
|
m_Input.m_Direction = 0;
|
||||||
m_Input.m_Jump = 0;
|
m_Input.m_Jump = 0;
|
||||||
|
@ -600,7 +601,7 @@ void CCharacter::Tick()
|
||||||
m_Core.m_HookTick = 0;
|
m_Core.m_HookTick = 0;
|
||||||
if (m_Super && m_Core.m_Jumped > 1)
|
if (m_Super && m_Core.m_Jumped > 1)
|
||||||
m_Core.m_Jumped = 1;
|
m_Core.m_Jumped = 1;
|
||||||
/*dbg_msg("character","TileIndex%d",TileIndex); //REMOVE*/
|
/*dbg_msg("character","TileIndex1=%d , TileIndex2=%d",TileIndex1,TileIndex2); //REMOVE*/
|
||||||
//DDRace
|
//DDRace
|
||||||
char aBuftime[128];
|
char aBuftime[128];
|
||||||
float time = (float)(Server()->Tick() - m_StartTime) / ((float)Server()->TickSpeed());
|
float time = (float)(Server()->Tick() - m_StartTime) / ((float)Server()->TickSpeed());
|
||||||
|
@ -619,13 +620,13 @@ void CCharacter::Tick()
|
||||||
}
|
}
|
||||||
m_RefreshTime = Server()->Tick();
|
m_RefreshTime = Server()->Tick();
|
||||||
}
|
}
|
||||||
else if((TileIndex == TILE_BEGIN) && (m_RaceState == RACE_NONE || m_RaceState == RACE_STARTED))
|
if(((TileIndex1 == TILE_BEGIN) || (TileIndex2 == TILE_BEGIN)) && (m_RaceState == RACE_NONE || m_RaceState == RACE_STARTED))
|
||||||
{
|
{
|
||||||
m_StartTime = Server()->Tick();
|
m_StartTime = Server()->Tick();
|
||||||
m_RefreshTime = Server()->Tick();
|
m_RefreshTime = Server()->Tick();
|
||||||
m_RaceState = RACE_STARTED;
|
m_RaceState = RACE_STARTED;
|
||||||
}
|
}
|
||||||
else if((TileIndex == TILE_END) && m_RaceState == RACE_STARTED)
|
if(((TileIndex1 == TILE_END) || (TileIndex2 == TILE_END)) && m_RaceState == RACE_STARTED)
|
||||||
{
|
{
|
||||||
char aBuf[128];
|
char aBuf[128];
|
||||||
if ((int)time / 60 != 0)
|
if ((int)time / 60 != 0)
|
||||||
|
@ -649,60 +650,103 @@ void CCharacter::Tick()
|
||||||
if(strncmp(Server()->ClientName(m_pPlayer->GetCID()), "nameless tee", 12) != 0)
|
if(strncmp(Server()->ClientName(m_pPlayer->GetCID()), "nameless tee", 12) != 0)
|
||||||
((CGameControllerDDRace*)GameServer()->m_pController)->m_Score.ParsePlayer(Server()->ClientName(m_pPlayer->GetCID()), (float)time);
|
((CGameControllerDDRace*)GameServer()->m_pController)->m_Score.ParsePlayer(Server()->ClientName(m_pPlayer->GetCID()), (float)time);
|
||||||
}
|
}
|
||||||
else if((TileIndex == TILE_FREEZE) && !m_Super)
|
if(((TileIndex1 == TILE_FREEZE) || (TileIndex2 == TILE_FREEZE)) && !m_Super)
|
||||||
{
|
{
|
||||||
Freeze(Server()->TickSpeed()*3);
|
Freeze(Server()->TickSpeed()*3);
|
||||||
}
|
}
|
||||||
else if(TileIndex == TILE_UNFREEZE)
|
else if((TileIndex1 == TILE_UNFREEZE) || (TileIndex2 == TILE_UNFREEZE))
|
||||||
{
|
{
|
||||||
UnFreeze();
|
UnFreeze();
|
||||||
}
|
}
|
||||||
else if ((TileIndex >= TILE_BOOST_L && TileIndex <= TILE_BOOST_U) || (TileIndex >= TILE_BOOST_L2 && TileIndex <= TILE_BOOST_U2))
|
if (((TileIndex1 >= TILE_BOOST_L && TileIndex1 <= TILE_BOOST_U) || (TileIndex1 >= TILE_BOOST_L2 && TileIndex1 <= TILE_BOOST_U2)))
|
||||||
{
|
{
|
||||||
int booster = TileIndex;
|
int booster = TileIndex1;
|
||||||
|
m_Core.m_Vel += GameServer()->Collision()->BoostAccelerator(booster);
|
||||||
|
}
|
||||||
|
if ((TileIndex2 >= TILE_BOOST_L && TileIndex2 <= TILE_BOOST_U) || (TileIndex2 >= TILE_BOOST_L2 && TileIndex2 <= TILE_BOOST_U2))
|
||||||
|
{
|
||||||
|
int booster = TileIndex2;
|
||||||
m_Core.m_Vel += GameServer()->Collision()->BoostAccelerator(booster);
|
m_Core.m_Vel += GameServer()->Collision()->BoostAccelerator(booster);
|
||||||
}
|
}
|
||||||
else if(GameServer()->Collision()->GetCollisionDDRace(TileIndex) == TILE_STOPL)
|
if(TileIndex1 == TILE_STOPL)
|
||||||
{
|
{
|
||||||
if(m_Core.m_Vel.x > 0)
|
if(m_Core.m_Vel.x > 0)
|
||||||
{
|
{
|
||||||
if((int)GameServer()->Collision()->GetPos(TileIndex).x < (int)m_Core.m_Pos.x)
|
if((int)GameServer()->Collision()->GetPos(TileIndex1).x < (int)m_Core.m_Pos.x)
|
||||||
m_Core.m_Pos.x = m_PrevPos.x;
|
m_Core.m_Pos.x = m_PrevPos.x;
|
||||||
m_Core.m_Vel.x = 0;
|
m_Core.m_Vel.x = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if(GameServer()->Collision()->GetCollisionDDRace(TileIndex) == TILE_STOPR)
|
if(TileIndex2 == TILE_STOPL)
|
||||||
|
{
|
||||||
|
if(m_Core.m_Vel.x > 0)
|
||||||
|
{
|
||||||
|
if((int)GameServer()->Collision()->GetPos(TileIndex2).x < (int)m_Core.m_Pos.x)
|
||||||
|
m_Core.m_Pos.x = m_PrevPos.x;
|
||||||
|
m_Core.m_Vel.x = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(TileIndex1 == TILE_STOPR)
|
||||||
{
|
{
|
||||||
if(m_Core.m_Vel.x < 0)
|
if(m_Core.m_Vel.x < 0)
|
||||||
{
|
{
|
||||||
if((int)GameServer()->Collision()->GetPos(TileIndex).x > (int)m_Core.m_Pos.x)
|
if((int)GameServer()->Collision()->GetPos(TileIndex1).x > (int)m_Core.m_Pos.x)
|
||||||
m_Core.m_Pos.x = m_PrevPos.x;
|
m_Core.m_Pos.x = m_PrevPos.x;
|
||||||
m_Core.m_Vel.x = 0;
|
m_Core.m_Vel.x = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if(GameServer()->Collision()->GetCollisionDDRace(TileIndex) == TILE_STOPB)
|
if(TileIndex1 == TILE_STOPB)
|
||||||
{
|
{
|
||||||
if(m_Core.m_Vel.y < 0)
|
if(m_Core.m_Vel.y < 0)
|
||||||
{
|
{
|
||||||
if((int)GameServer()->Collision()->GetPos(TileIndex).y > (int)m_Core.m_Pos.y)
|
if((int)GameServer()->Collision()->GetPos(TileIndex1).y > (int)m_Core.m_Pos.y)
|
||||||
m_Core.m_Pos.y = m_PrevPos.y;
|
m_Core.m_Pos.y = m_PrevPos.y;
|
||||||
m_Core.m_Vel.y = 0;
|
m_Core.m_Vel.y = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if(GameServer()->Collision()->GetCollisionDDRace(TileIndex) == TILE_STOPT)
|
if(TileIndex1 == TILE_STOPT)
|
||||||
{
|
{
|
||||||
if(m_Core.m_Vel.y > 0)
|
if(m_Core.m_Vel.y > 0)
|
||||||
{
|
{
|
||||||
if((int)GameServer()->Collision()->GetPos(TileIndex).y < (int)m_Core.m_Pos.y)
|
if((int)GameServer()->Collision()->GetPos(TileIndex1).y < (int)m_Core.m_Pos.y)
|
||||||
m_Core.m_Pos.y = m_PrevPos.y;
|
m_Core.m_Pos.y = m_PrevPos.y;
|
||||||
if(m_Jumped&3 && m_Core.m_Jumped != m_Jumped) // check double jump
|
if(m_Jumped&3 && m_Core.m_Jumped != m_Jumped) // check double jump
|
||||||
m_Core.m_Jumped = m_Jumped;
|
m_Core.m_Jumped = m_Jumped;
|
||||||
m_Core.m_Vel.y = 0;
|
m_Core.m_Vel.y = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if(GameServer()->Collision()->IsFront((int)m_Core.m_Pos.x, (int)m_Core.m_Pos.y))
|
if(TileIndex2 == TILE_STOPR)
|
||||||
|
{
|
||||||
|
if(m_Core.m_Vel.x < 0)
|
||||||
|
{
|
||||||
|
if((int)GameServer()->Collision()->GetPos(TileIndex2).x > (int)m_Core.m_Pos.x)
|
||||||
|
m_Core.m_Pos.x = m_PrevPos.x;
|
||||||
|
m_Core.m_Vel.x = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(TileIndex2 == TILE_STOPB)
|
||||||
|
{
|
||||||
|
if(m_Core.m_Vel.y < 0)
|
||||||
|
{
|
||||||
|
if((int)GameServer()->Collision()->GetPos(TileIndex2).y > (int)m_Core.m_Pos.y)
|
||||||
|
m_Core.m_Pos.y = m_PrevPos.y;
|
||||||
|
m_Core.m_Vel.y = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(TileIndex2 == TILE_STOPT)
|
||||||
|
{
|
||||||
|
if(m_Core.m_Vel.y > 0)
|
||||||
|
{
|
||||||
|
if((int)GameServer()->Collision()->GetPos(TileIndex2).y < (int)m_Core.m_Pos.y)
|
||||||
|
m_Core.m_Pos.y = m_PrevPos.y;
|
||||||
|
if(m_Jumped&3 && m_Core.m_Jumped != m_Jumped) // check double jump
|
||||||
|
m_Core.m_Jumped = m_Jumped;
|
||||||
|
m_Core.m_Vel.y = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(GameServer()->Collision()->IsFront((int)m_Core.m_Pos.x, (int)m_Core.m_Pos.y))
|
||||||
;
|
;
|
||||||
else if(GameServer()->Collision()->IsSpeedup((int)m_Core.m_Pos.x, (int)m_Core.m_Pos.y))
|
if(GameServer()->Collision()->IsSpeedup((int)m_Core.m_Pos.x, (int)m_Core.m_Pos.y))
|
||||||
{
|
{
|
||||||
vec2 Direction;
|
vec2 Direction;
|
||||||
int Force;
|
int Force;
|
||||||
|
@ -710,7 +754,7 @@ void CCharacter::Tick()
|
||||||
|
|
||||||
m_Core.m_Vel += Direction*Force;
|
m_Core.m_Vel += Direction*Force;
|
||||||
}
|
}
|
||||||
else if(z)
|
if(z)
|
||||||
{
|
{
|
||||||
m_Core.m_HookedPlayer = -1;
|
m_Core.m_HookedPlayer = -1;
|
||||||
m_Core.m_HookState = HOOK_RETRACTED;
|
m_Core.m_HookState = HOOK_RETRACTED;
|
||||||
|
|
|
@ -21,10 +21,10 @@ void CGameContext::Construct(int Resetting)
|
||||||
{
|
{
|
||||||
m_Resetting = 0;
|
m_Resetting = 0;
|
||||||
m_pServer = 0;
|
m_pServer = 0;
|
||||||
|
|
||||||
for(int i = 0; i < MAX_CLIENTS; i++)
|
for(int i = 0; i < MAX_CLIENTS; i++)
|
||||||
m_apPlayers[i] = 0;
|
m_apPlayers[i] = 0;
|
||||||
|
|
||||||
m_pController = 0;
|
m_pController = 0;
|
||||||
m_VoteCloseTime = 0;
|
m_VoteCloseTime = 0;
|
||||||
m_pVoteOptionFirst = 0;
|
m_pVoteOptionFirst = 0;
|
||||||
|
@ -65,7 +65,7 @@ void CGameContext::Clear()
|
||||||
this->~CGameContext();
|
this->~CGameContext();
|
||||||
mem_zero(this, sizeof(*this));
|
mem_zero(this, sizeof(*this));
|
||||||
new (this) CGameContext(RESET);
|
new (this) CGameContext(RESET);
|
||||||
//this->m_Cheats = cheats;
|
//this->m_Cheats = cheats;
|
||||||
|
|
||||||
m_pVoteOptionHeap = pVoteOptionHeap;
|
m_pVoteOptionHeap = pVoteOptionHeap;
|
||||||
m_pVoteOptionFirst = pVoteOptionFirst;
|
m_pVoteOptionFirst = pVoteOptionFirst;
|
||||||
|
@ -143,7 +143,7 @@ void CGameContext::CreateExplosion(vec2 p, int Owner, int Weapon, bool NoDamage)
|
||||||
apEnts[i]->TakeDamage(ForceDir*Dmg*2, (int)Dmg, Owner, Weapon);
|
apEnts[i]->TakeDamage(ForceDir*Dmg*2, (int)Dmg, Owner, Weapon);
|
||||||
if(!g_Config.m_SvHit) break;
|
if(!g_Config.m_SvHit) break;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -240,7 +240,7 @@ void CGameContext::SendChat(int ChatterClientId, int Team, const char *pText)
|
||||||
Msg.m_Team = 1;
|
Msg.m_Team = 1;
|
||||||
Msg.m_Cid = ChatterClientId;
|
Msg.m_Cid = ChatterClientId;
|
||||||
Msg.m_pMessage = pText;
|
Msg.m_pMessage = pText;
|
||||||
|
|
||||||
// pack one for the recording only
|
// pack one for the recording only
|
||||||
Server()->SendPackMsg(&Msg, MSGFLAG_VITAL|MSGFLAG_NOSEND, -1);
|
Server()->SendPackMsg(&Msg, MSGFLAG_VITAL|MSGFLAG_NOSEND, -1);
|
||||||
|
|
||||||
|
@ -276,7 +276,7 @@ void CGameContext::SendBroadcast(const char *pText, int ClientId)
|
||||||
Server()->SendPackMsg(&Msg, MSGFLAG_VITAL, ClientId);
|
Server()->SendPackMsg(&Msg, MSGFLAG_VITAL, ClientId);
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
void CGameContext::StartVote(const char *pDesc, const char *pCommand)
|
void CGameContext::StartVote(const char *pDesc, const char *pCommand)
|
||||||
{
|
{
|
||||||
// check if a vote is already running
|
// check if a vote is already running
|
||||||
|
@ -293,7 +293,7 @@ void CGameContext::StartVote(const char *pDesc, const char *pCommand)
|
||||||
m_apPlayers[i]->m_VotePos = 0;
|
m_apPlayers[i]->m_VotePos = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// start vote
|
// start vote
|
||||||
m_VoteCloseTime = time_get() + time_freq()*25;
|
m_VoteCloseTime = time_get() + time_freq()*25;
|
||||||
str_copy(m_aVoteDescription, pDesc, sizeof(m_aVoteDescription));
|
str_copy(m_aVoteDescription, pDesc, sizeof(m_aVoteDescription));
|
||||||
|
@ -336,7 +336,7 @@ void CGameContext::SendVoteStatus(int ClientId, int Total, int Yes, int No)
|
||||||
Msg.m_Pass = Total - (Yes+No);
|
Msg.m_Pass = Total - (Yes+No);
|
||||||
|
|
||||||
Server()->SendPackMsg(&Msg, MSGFLAG_VITAL, ClientId);
|
Server()->SendPackMsg(&Msg, MSGFLAG_VITAL, ClientId);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CGameContext::AbortVoteKickOnDisconnect(int ClientId)
|
void CGameContext::AbortVoteKickOnDisconnect(int ClientId)
|
||||||
|
@ -351,7 +351,7 @@ void CGameContext::CheckPureTuning()
|
||||||
// might not be created yet during start up
|
// might not be created yet during start up
|
||||||
if(!m_pController)
|
if(!m_pController)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if( str_comp(m_pController->m_pGameType, "DM")==0 ||
|
if( str_comp(m_pController->m_pGameType, "DM")==0 ||
|
||||||
str_comp(m_pController->m_pGameType, "TDM")==0 ||
|
str_comp(m_pController->m_pGameType, "TDM")==0 ||
|
||||||
str_comp(m_pController->m_pGameType, "CTF")==0)
|
str_comp(m_pController->m_pGameType, "CTF")==0)
|
||||||
|
@ -362,13 +362,13 @@ void CGameContext::CheckPureTuning()
|
||||||
dbg_msg("server", "resetting tuning due to pure server");
|
dbg_msg("server", "resetting tuning due to pure server");
|
||||||
m_Tuning = p;
|
m_Tuning = p;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CGameContext::SendTuningParams(int Cid)
|
void CGameContext::SendTuningParams(int Cid)
|
||||||
{
|
{
|
||||||
CheckPureTuning();
|
CheckPureTuning();
|
||||||
|
|
||||||
CMsgPacker Msg(NETMSGTYPE_SV_TUNEPARAMS);
|
CMsgPacker Msg(NETMSGTYPE_SV_TUNEPARAMS);
|
||||||
int *pParams = (int *)&m_Tuning;
|
int *pParams = (int *)&m_Tuning;
|
||||||
for(unsigned i = 0; i < sizeof(m_Tuning)/sizeof(int); i++)
|
for(unsigned i = 0; i < sizeof(m_Tuning)/sizeof(int); i++)
|
||||||
|
@ -387,13 +387,13 @@ void CGameContext::OnTick()
|
||||||
|
|
||||||
//if(world.paused) // make sure that the game object always updates
|
//if(world.paused) // make sure that the game object always updates
|
||||||
m_pController->Tick();
|
m_pController->Tick();
|
||||||
|
|
||||||
for(int i = 0; i < MAX_CLIENTS; i++)
|
for(int i = 0; i < MAX_CLIENTS; i++)
|
||||||
{
|
{
|
||||||
if(m_apPlayers[i])
|
if(m_apPlayers[i])
|
||||||
m_apPlayers[i]->Tick();
|
m_apPlayers[i]->Tick();
|
||||||
}
|
}
|
||||||
|
|
||||||
// update voting
|
// update voting
|
||||||
if(m_VoteCloseTime)
|
if(m_VoteCloseTime)
|
||||||
{
|
{
|
||||||
|
@ -418,10 +418,10 @@ void CGameContext::OnTick()
|
||||||
{
|
{
|
||||||
if(!m_apPlayers[i] || m_apPlayers[i]->GetTeam() == -1 || aVoteChecked[i]) // don't count in votes by spectators
|
if(!m_apPlayers[i] || m_apPlayers[i]->GetTeam() == -1 || aVoteChecked[i]) // don't count in votes by spectators
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
int ActVote = m_apPlayers[i]->m_Vote;
|
int ActVote = m_apPlayers[i]->m_Vote;
|
||||||
int ActVotePos = m_apPlayers[i]->m_VotePos;
|
int ActVotePos = m_apPlayers[i]->m_VotePos;
|
||||||
|
|
||||||
// check for more players with the same ip (only use the vote of the one who voted first)
|
// check for more players with the same ip (only use the vote of the one who voted first)
|
||||||
for(int j = i+1; j < MAX_CLIENTS; ++j)
|
for(int j = i+1; j < MAX_CLIENTS; ++j)
|
||||||
{
|
{
|
||||||
|
@ -448,7 +448,7 @@ void CGameContext::OnTick()
|
||||||
else if(No >= Total/2+1 || Yes+No == Total)
|
else if(No >= Total/2+1 || Yes+No == Total)
|
||||||
m_VoteEnforce = VOTE_ENFORCE_NO;
|
m_VoteEnforce = VOTE_ENFORCE_NO;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(m_VoteEnforce == VOTE_ENFORCE_YES)
|
if(m_VoteEnforce == VOTE_ENFORCE_YES)
|
||||||
{
|
{
|
||||||
//Console()->ExecuteLine(m_aVoteCommand, 4, -1);
|
//Console()->ExecuteLine(m_aVoteCommand, 4, -1);
|
||||||
|
@ -483,7 +483,7 @@ void CGameContext::OnTick()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#ifdef CONF_DEBUG
|
#ifdef CONF_DEBUG
|
||||||
if(g_Config.m_DbgDummies)
|
if(g_Config.m_DbgDummies)
|
||||||
|
@ -495,7 +495,7 @@ void CGameContext::OnTick()
|
||||||
m_apPlayers[MAX_CLIENTS-i-1]->OnPredictedInput(&Input);
|
m_apPlayers[MAX_CLIENTS-i-1]->OnPredictedInput(&Input);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
// Server hooks
|
// Server hooks
|
||||||
|
@ -520,7 +520,7 @@ void CGameContext::OnClientEnter(int ClientId)
|
||||||
|
|
||||||
char aBuf[512];
|
char aBuf[512];
|
||||||
str_format(aBuf, sizeof(aBuf), "%s entered and joined the %s", Server()->ClientName(ClientId), m_pController->GetTeamName(m_apPlayers[ClientId]->GetTeam()));
|
str_format(aBuf, sizeof(aBuf), "%s entered and joined the %s", Server()->ClientName(ClientId), m_pController->GetTeamName(m_apPlayers[ClientId]->GetTeam()));
|
||||||
SendChat(-1, CGameContext::CHAT_ALL, aBuf);
|
SendChat(-1, CGameContext::CHAT_ALL, aBuf);
|
||||||
SendChatTarget(ClientId, "DDRace Mod. Version: " DDRACE_VERSION);
|
SendChatTarget(ClientId, "DDRace Mod. Version: " DDRACE_VERSION);
|
||||||
SendChatTarget(ClientId, "Official site: DDRace.info");
|
SendChatTarget(ClientId, "Official site: DDRace.info");
|
||||||
SendChatTarget(ClientId, "For more Info /CMDList");
|
SendChatTarget(ClientId, "For more Info /CMDList");
|
||||||
|
@ -532,15 +532,15 @@ void CGameContext::OnClientEnter(int ClientId)
|
||||||
m_VoteUpdate = true;
|
m_VoteUpdate = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool compare_players(CPlayer *pl1, CPlayer *pl2)
|
bool compare_players(CPlayer *pl1, CPlayer *pl2)
|
||||||
{
|
{
|
||||||
if (pl1->m_Authed>pl2->m_Authed)
|
if (pl1->m_Authed>pl2->m_Authed)
|
||||||
return true;
|
return true;
|
||||||
else
|
else
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CGameContext::OnSetAuthed(int client_id, int Level)
|
void CGameContext::OnSetAuthed(int client_id, int Level)
|
||||||
{
|
{
|
||||||
if(m_apPlayers[client_id])
|
if(m_apPlayers[client_id])
|
||||||
{
|
{
|
||||||
|
@ -554,12 +554,12 @@ void CGameContext::OnSetAuthed(int client_id, int Level)
|
||||||
dbg_msg("hooks","Aborting vote");
|
dbg_msg("hooks","Aborting vote");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CGameContext::OnSetResistent(int client_id, int Resistent)
|
void CGameContext::OnSetResistent(int client_id, int Resistent)
|
||||||
{
|
{
|
||||||
if(m_apPlayers[client_id])
|
if(m_apPlayers[client_id])
|
||||||
m_apPlayers[client_id]->m_Resistent = Resistent;
|
m_apPlayers[client_id]->m_Resistent = Resistent;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CGameContext::OnClientConnected(int ClientId)
|
void CGameContext::OnClientConnected(int ClientId)
|
||||||
|
@ -570,7 +570,7 @@ void CGameContext::OnClientConnected(int ClientId)
|
||||||
m_apPlayers[ClientId] = new(ClientId) CPlayer(this, ClientId, StartTeam);
|
m_apPlayers[ClientId] = new(ClientId) CPlayer(this, ClientId, StartTeam);
|
||||||
//players[client_id].init(client_id);
|
//players[client_id].init(client_id);
|
||||||
//players[client_id].client_id = client_id;
|
//players[client_id].client_id = client_id;
|
||||||
|
|
||||||
//(void)m_pController->CheckTeamBalance();
|
//(void)m_pController->CheckTeamBalance();
|
||||||
|
|
||||||
#ifdef CONF_DEBUG
|
#ifdef CONF_DEBUG
|
||||||
|
@ -597,7 +597,7 @@ void CGameContext::OnClientDrop(int ClientId)
|
||||||
m_apPlayers[ClientId]->OnDisconnect();
|
m_apPlayers[ClientId]->OnDisconnect();
|
||||||
delete m_apPlayers[ClientId];
|
delete m_apPlayers[ClientId];
|
||||||
m_apPlayers[ClientId] = 0;
|
m_apPlayers[ClientId] = 0;
|
||||||
|
|
||||||
//(void)m_pController->CheckTeamBalance();
|
//(void)m_pController->CheckTeamBalance();
|
||||||
m_VoteUpdate = true;
|
m_VoteUpdate = true;
|
||||||
}
|
}
|
||||||
|
@ -606,13 +606,13 @@ void CGameContext::OnMessage(int MsgId, CUnpacker *pUnpacker, int ClientId)
|
||||||
{
|
{
|
||||||
void *pRawMsg = m_NetObjHandler.SecureUnpackMsg(MsgId, pUnpacker);
|
void *pRawMsg = m_NetObjHandler.SecureUnpackMsg(MsgId, pUnpacker);
|
||||||
CPlayer *p = m_apPlayers[ClientId];
|
CPlayer *p = m_apPlayers[ClientId];
|
||||||
|
|
||||||
if(!pRawMsg)
|
if(!pRawMsg)
|
||||||
{
|
{
|
||||||
dbg_msg("server", "dropped weird message '%s' (%d), failed on '%s'", m_NetObjHandler.GetMsgName(MsgId), MsgId, m_NetObjHandler.FailedMsgOn());
|
dbg_msg("server", "dropped weird message '%s' (%d), failed on '%s'", m_NetObjHandler.GetMsgName(MsgId), MsgId, m_NetObjHandler.FailedMsgOn());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(MsgId == NETMSGTYPE_CL_SAY)
|
if(MsgId == NETMSGTYPE_CL_SAY)
|
||||||
{
|
{
|
||||||
CNetMsg_Cl_Say *pMsg = (CNetMsg_Cl_Say *)pRawMsg;
|
CNetMsg_Cl_Say *pMsg = (CNetMsg_Cl_Say *)pRawMsg;
|
||||||
|
@ -621,14 +621,14 @@ void CGameContext::OnMessage(int MsgId, CUnpacker *pUnpacker, int ClientId)
|
||||||
Team = p->GetTeam();
|
Team = p->GetTeam();
|
||||||
else
|
else
|
||||||
Team = CGameContext::CHAT_ALL;
|
Team = CGameContext::CHAT_ALL;
|
||||||
|
|
||||||
if(g_Config.m_SvSpamprotection && p->m_Last_Chat && p->m_Last_Chat+Server()->TickSpeed() > Server()->Tick())
|
if(g_Config.m_SvSpamprotection && p->m_Last_Chat && p->m_Last_Chat+Server()->TickSpeed() > Server()->Tick())
|
||||||
return;
|
return;
|
||||||
if(str_length(pMsg->m_pMessage)>370) {
|
if(str_length(pMsg->m_pMessage)>370) {
|
||||||
SendChatTarget(ClientId, "Your Message is too long");
|
SendChatTarget(ClientId, "Your Message is too long");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
p->m_Last_Chat = Server()->Tick();
|
p->m_Last_Chat = Server()->Tick();
|
||||||
|
|
||||||
// check for invalid chars
|
// check for invalid chars
|
||||||
|
@ -653,11 +653,11 @@ void CGameContext::OnMessage(int MsgId, CUnpacker *pUnpacker, int ClientId)
|
||||||
{
|
{
|
||||||
CCharacter* chr = m_apPlayers[ClientId]->GetCharacter();
|
CCharacter* chr = m_apPlayers[ClientId]->GetCharacter();
|
||||||
if(chr)
|
if(chr)
|
||||||
{
|
{
|
||||||
if(chr->m_RaceState==RACE_STARTED)
|
if(chr->m_RaceState==RACE_STARTED)
|
||||||
chr->m_RaceState = RACE_PAUSE;
|
chr->m_RaceState = RACE_PAUSE;
|
||||||
else if(chr->m_RaceState==RACE_PAUSE)
|
else if(chr->m_RaceState==RACE_PAUSE)
|
||||||
chr->m_RaceState = RACE_STARTED;
|
chr->m_RaceState = RACE_STARTED;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if(!str_comp_nocase(pMsg->m_pMessage, "/info"))
|
} else if(!str_comp_nocase(pMsg->m_pMessage, "/info"))
|
||||||
|
@ -740,15 +740,15 @@ void CGameContext::OnMessage(int MsgId, CUnpacker *pUnpacker, int ClientId)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
SendChatTarget(ClientId, "No such command!");
|
SendChatTarget(ClientId, "No such command!");
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
if (m_apPlayers[ClientId]->m_Muted == 0)
|
if (m_apPlayers[ClientId]->m_Muted == 0)
|
||||||
SendChat(ClientId, Team, pMsg->m_pMessage);
|
SendChat(ClientId, Team, pMsg->m_pMessage);
|
||||||
else
|
else
|
||||||
SendChatTarget(ClientId, "You are muted");
|
SendChatTarget(ClientId, "You are muted");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
else if(MsgId == NETMSGTYPE_CL_CALLVOTE)
|
else if(MsgId == NETMSGTYPE_CL_CALLVOTE)
|
||||||
{
|
{
|
||||||
|
@ -768,7 +768,7 @@ void CGameContext::OnMessage(int MsgId, CUnpacker *pUnpacker, int ClientId)
|
||||||
SendChatTarget(ClientId, "Wait for current vote to end before calling a new one.");
|
SendChatTarget(ClientId, "Wait for current vote to end before calling a new one.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
int Timeleft = p->m_Last_VoteCall + Server()->TickSpeed()*60 - Now;
|
int Timeleft = p->m_Last_VoteCall + Server()->TickSpeed()*60 - Now;
|
||||||
if(p->m_Last_VoteCall && Timeleft > 0)
|
if(p->m_Last_VoteCall && Timeleft > 0)
|
||||||
{
|
{
|
||||||
|
@ -777,7 +777,7 @@ void CGameContext::OnMessage(int MsgId, CUnpacker *pUnpacker, int ClientId)
|
||||||
SendChatTarget(ClientId, aChatmsg);
|
SendChatTarget(ClientId, aChatmsg);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
char aChatmsg[512] = {0};
|
char aChatmsg[512] = {0};
|
||||||
char aDesc[512] = {0};
|
char aDesc[512] = {0};
|
||||||
char aCmd[512] = {0};
|
char aCmd[512] = {0};
|
||||||
|
@ -791,11 +791,11 @@ void CGameContext::OnMessage(int MsgId, CUnpacker *pUnpacker, int ClientId)
|
||||||
if(str_comp_nocase(pMsg->m_Value, pOption->m_aCommand) == 0)
|
if(str_comp_nocase(pMsg->m_Value, pOption->m_aCommand) == 0)
|
||||||
{
|
{
|
||||||
if(m_apPlayers[ClientId]->m_Authed == 0 && strncmp(pOption->m_aCommand, "sv_map ", 7) == 0 && time_get() < last_mapvote + (time_freq() * g_Config.m_SvVoteMapTimeDelay))
|
if(m_apPlayers[ClientId]->m_Authed == 0 && strncmp(pOption->m_aCommand, "sv_map ", 7) == 0 && time_get() < last_mapvote + (time_freq() * g_Config.m_SvVoteMapTimeDelay))
|
||||||
{
|
{
|
||||||
char chatmsg[512] = {0};
|
char chatmsg[512] = {0};
|
||||||
str_format(chatmsg, sizeof(chatmsg), "There's a %d second delay between map-votes,Please wait %d Second(s)", g_Config.m_SvVoteMapTimeDelay,((last_mapvote+(g_Config.m_SvVoteMapTimeDelay * time_freq()))/time_freq())-(time_get()/time_freq()));
|
str_format(chatmsg, sizeof(chatmsg), "There's a %d second delay between map-votes,Please wait %d Second(s)", g_Config.m_SvVoteMapTimeDelay,((last_mapvote+(g_Config.m_SvVoteMapTimeDelay * time_freq()))/time_freq())-(time_get()/time_freq()));
|
||||||
SendChatTarget(ClientId, chatmsg);
|
SendChatTarget(ClientId, chatmsg);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
str_format(aChatmsg, sizeof(aChatmsg), "%s called vote to change server option '%s'", Server()->ClientName(ClientId), pOption->m_aCommand);
|
str_format(aChatmsg, sizeof(aChatmsg), "%s called vote to change server option '%s'", Server()->ClientName(ClientId), pOption->m_aCommand);
|
||||||
|
@ -807,7 +807,7 @@ void CGameContext::OnMessage(int MsgId, CUnpacker *pUnpacker, int ClientId)
|
||||||
|
|
||||||
pOption = pOption->m_pNext;
|
pOption = pOption->m_pNext;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!pOption)
|
if(!pOption)
|
||||||
{
|
{
|
||||||
str_format(aChatmsg, sizeof(aChatmsg), "'%s' isn't an option on this server", pMsg->m_Value);
|
str_format(aChatmsg, sizeof(aChatmsg), "'%s' isn't an option on this server", pMsg->m_Value);
|
||||||
|
@ -818,9 +818,9 @@ void CGameContext::OnMessage(int MsgId, CUnpacker *pUnpacker, int ClientId)
|
||||||
}
|
}
|
||||||
else if(str_comp_nocase(pMsg->m_Type, "kick") == 0)
|
else if(str_comp_nocase(pMsg->m_Type, "kick") == 0)
|
||||||
{
|
{
|
||||||
if(m_apPlayers[ClientId]->m_Authed == 0 && time_get() < m_apPlayers[ClientId]->m_Last_KickVote + (time_freq() * 5))
|
if(m_apPlayers[ClientId]->m_Authed == 0 && time_get() < m_apPlayers[ClientId]->m_Last_KickVote + (time_freq() * 5))
|
||||||
return;
|
return;
|
||||||
else if(m_apPlayers[ClientId]->m_Authed == 0 && time_get() < m_apPlayers[ClientId]->m_Last_KickVote + (time_freq() * g_Config.m_SvVoteKickTimeDelay))
|
else if(m_apPlayers[ClientId]->m_Authed == 0 && time_get() < m_apPlayers[ClientId]->m_Last_KickVote + (time_freq() * g_Config.m_SvVoteKickTimeDelay))
|
||||||
{
|
{
|
||||||
char chatmsg[512] = {0};
|
char chatmsg[512] = {0};
|
||||||
str_format(chatmsg, sizeof(chatmsg), "There's a %d second waittime between kickvotes for each player please wait %d second(s)",
|
str_format(chatmsg, sizeof(chatmsg), "There's a %d second waittime between kickvotes for each player please wait %d second(s)",
|
||||||
|
@ -837,7 +837,7 @@ void CGameContext::OnMessage(int MsgId, CUnpacker *pUnpacker, int ClientId)
|
||||||
m_apPlayers[ClientId]->m_Last_KickVote = time_get();
|
m_apPlayers[ClientId]->m_Last_KickVote = time_get();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
int KickId = str_toint(pMsg->m_Value);
|
int KickId = str_toint(pMsg->m_Value);
|
||||||
if(KickId < 0 || KickId >= MAX_CLIENTS || !m_apPlayers[KickId])
|
if(KickId < 0 || KickId >= MAX_CLIENTS || !m_apPlayers[KickId])
|
||||||
{
|
{
|
||||||
|
@ -859,7 +859,7 @@ void CGameContext::OnMessage(int MsgId, CUnpacker *pUnpacker, int ClientId)
|
||||||
SendChatTarget(KickId, aBufKick);
|
SendChatTarget(KickId, aBufKick);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
str_format(aChatmsg, sizeof(aChatmsg), "%s called for vote to kick '%s'", Server()->ClientName(ClientId), Server()->ClientName(KickId));
|
str_format(aChatmsg, sizeof(aChatmsg), "%s called for vote to kick '%s'", Server()->ClientName(ClientId), Server()->ClientName(KickId));
|
||||||
str_format(aDesc, sizeof(aDesc), "Kick '%s'", Server()->ClientName(KickId));
|
str_format(aDesc, sizeof(aDesc), "Kick '%s'", Server()->ClientName(KickId));
|
||||||
if (!g_Config.m_SvVoteKickBanTime)
|
if (!g_Config.m_SvVoteKickBanTime)
|
||||||
|
@ -872,7 +872,7 @@ void CGameContext::OnMessage(int MsgId, CUnpacker *pUnpacker, int ClientId)
|
||||||
}
|
}
|
||||||
m_apPlayers[ClientId]->m_Last_KickVote = time_get();
|
m_apPlayers[ClientId]->m_Last_KickVote = time_get();
|
||||||
}
|
}
|
||||||
|
|
||||||
if(aCmd[0])
|
if(aCmd[0])
|
||||||
{
|
{
|
||||||
SendChat(-1, CGameContext::CHAT_ALL, aChatmsg);
|
SendChat(-1, CGameContext::CHAT_ALL, aChatmsg);
|
||||||
|
@ -902,7 +902,7 @@ void CGameContext::OnMessage(int MsgId, CUnpacker *pUnpacker, int ClientId)
|
||||||
else if (MsgId == NETMSGTYPE_CL_SETTEAM && !m_World.m_Paused)
|
else if (MsgId == NETMSGTYPE_CL_SETTEAM && !m_World.m_Paused)
|
||||||
{
|
{
|
||||||
CNetMsg_Cl_SetTeam *pMsg = (CNetMsg_Cl_SetTeam *)pRawMsg;
|
CNetMsg_Cl_SetTeam *pMsg = (CNetMsg_Cl_SetTeam *)pRawMsg;
|
||||||
|
|
||||||
if(p->GetTeam() == pMsg->m_Team || (g_Config.m_SvSpamprotection && p->m_Last_SetTeam && p->m_Last_SetTeam+Server()->TickSpeed()*3 > Server()->Tick()))
|
if(p->GetTeam() == pMsg->m_Team || (g_Config.m_SvSpamprotection && p->m_Last_SetTeam && p->m_Last_SetTeam+Server()->TickSpeed()*3 > Server()->Tick()))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -930,10 +930,10 @@ void CGameContext::OnMessage(int MsgId, CUnpacker *pUnpacker, int ClientId)
|
||||||
else if (MsgId == NETMSGTYPE_CL_CHANGEINFO || MsgId == NETMSGTYPE_CL_STARTINFO)
|
else if (MsgId == NETMSGTYPE_CL_CHANGEINFO || MsgId == NETMSGTYPE_CL_STARTINFO)
|
||||||
{
|
{
|
||||||
CNetMsg_Cl_ChangeInfo *pMsg = (CNetMsg_Cl_ChangeInfo *)pRawMsg;
|
CNetMsg_Cl_ChangeInfo *pMsg = (CNetMsg_Cl_ChangeInfo *)pRawMsg;
|
||||||
|
|
||||||
if(g_Config.m_SvSpamprotection && p->m_Last_ChangeInfo && p->m_Last_ChangeInfo+Server()->TickSpeed()*5 > Server()->Tick())
|
if(g_Config.m_SvSpamprotection && p->m_Last_ChangeInfo && p->m_Last_ChangeInfo+Server()->TickSpeed()*5 > Server()->Tick())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
p->m_Last_ChangeInfo = time_get();
|
p->m_Last_ChangeInfo = time_get();
|
||||||
if (!p->m_ColorSet|| g_Config.m_SvAllowColorChange)
|
if (!p->m_ColorSet|| g_Config.m_SvAllowColorChange)
|
||||||
{
|
{
|
||||||
|
@ -945,7 +945,7 @@ void CGameContext::OnMessage(int MsgId, CUnpacker *pUnpacker, int ClientId)
|
||||||
// copy old name
|
// copy old name
|
||||||
char aOldName[MAX_NAME_LENGTH];
|
char aOldName[MAX_NAME_LENGTH];
|
||||||
str_copy(aOldName, Server()->ClientName(ClientId), MAX_NAME_LENGTH);
|
str_copy(aOldName, Server()->ClientName(ClientId), MAX_NAME_LENGTH);
|
||||||
|
|
||||||
Server()->SetClientName(ClientId, pMsg->m_pName);
|
Server()->SetClientName(ClientId, pMsg->m_pName);
|
||||||
if(MsgId == NETMSGTYPE_CL_CHANGEINFO && str_comp(aOldName, Server()->ClientName(ClientId)) != 0)
|
if(MsgId == NETMSGTYPE_CL_CHANGEINFO && str_comp(aOldName, Server()->ClientName(ClientId)) != 0)
|
||||||
{
|
{
|
||||||
|
@ -953,12 +953,12 @@ void CGameContext::OnMessage(int MsgId, CUnpacker *pUnpacker, int ClientId)
|
||||||
str_format(aChatText, sizeof(aChatText), "%s changed name to %s", aOldName, Server()->ClientName(ClientId));
|
str_format(aChatText, sizeof(aChatText), "%s changed name to %s", aOldName, Server()->ClientName(ClientId));
|
||||||
SendChat(-1, CGameContext::CHAT_ALL, aChatText);
|
SendChat(-1, CGameContext::CHAT_ALL, aChatText);
|
||||||
}
|
}
|
||||||
|
|
||||||
// set skin
|
// set skin
|
||||||
str_copy(p->m_TeeInfos.m_SkinName, pMsg->m_pSkin, sizeof(p->m_TeeInfos.m_SkinName));
|
str_copy(p->m_TeeInfos.m_SkinName, pMsg->m_pSkin, sizeof(p->m_TeeInfos.m_SkinName));
|
||||||
|
|
||||||
//m_pController->OnPlayerInfoChange(p);
|
//m_pController->OnPlayerInfoChange(p);
|
||||||
|
|
||||||
if(MsgId == NETMSGTYPE_CL_STARTINFO)
|
if(MsgId == NETMSGTYPE_CL_STARTINFO)
|
||||||
{
|
{
|
||||||
// send vote options
|
// send vote options
|
||||||
|
@ -972,7 +972,7 @@ void CGameContext::OnMessage(int MsgId, CUnpacker *pUnpacker, int ClientId)
|
||||||
Server()->SendPackMsg(&OptionMsg, MSGFLAG_VITAL, ClientId);
|
Server()->SendPackMsg(&OptionMsg, MSGFLAG_VITAL, ClientId);
|
||||||
pCurrent = pCurrent->m_pNext;
|
pCurrent = pCurrent->m_pNext;
|
||||||
}
|
}
|
||||||
|
|
||||||
// send tuning parameters to client
|
// send tuning parameters to client
|
||||||
SendTuningParams(ClientId);
|
SendTuningParams(ClientId);
|
||||||
|
|
||||||
|
@ -984,19 +984,19 @@ void CGameContext::OnMessage(int MsgId, CUnpacker *pUnpacker, int ClientId)
|
||||||
else if (MsgId == NETMSGTYPE_CL_EMOTICON && !m_World.m_Paused)
|
else if (MsgId == NETMSGTYPE_CL_EMOTICON && !m_World.m_Paused)
|
||||||
{
|
{
|
||||||
CNetMsg_Cl_Emoticon *pMsg = (CNetMsg_Cl_Emoticon *)pRawMsg;
|
CNetMsg_Cl_Emoticon *pMsg = (CNetMsg_Cl_Emoticon *)pRawMsg;
|
||||||
|
|
||||||
if(g_Config.m_SvSpamprotection && p->m_Last_Emote && p->m_Last_Emote+Server()->TickSpeed()*3 > Server()->Tick())
|
if(g_Config.m_SvSpamprotection && p->m_Last_Emote && p->m_Last_Emote+Server()->TickSpeed()*3 > Server()->Tick())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
p->m_Last_Emote = Server()->Tick();
|
p->m_Last_Emote = Server()->Tick();
|
||||||
|
|
||||||
SendEmoticon(ClientId, pMsg->m_Emoticon);
|
SendEmoticon(ClientId, pMsg->m_Emoticon);
|
||||||
}
|
}
|
||||||
else if (MsgId == NETMSGTYPE_CL_KILL && !m_World.m_Paused)
|
else if (MsgId == NETMSGTYPE_CL_KILL && !m_World.m_Paused)
|
||||||
{
|
{
|
||||||
if(p->m_Last_Kill && p->m_Last_Kill+Server()->TickSpeed()*3 > Server()->Tick())
|
if(p->m_Last_Kill && p->m_Last_Kill+Server()->TickSpeed()*3 > Server()->Tick())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
p->m_Last_Kill = Server()->Tick();
|
p->m_Last_Kill = Server()->Tick();
|
||||||
p->KillCharacter(WEAPON_SELF);
|
p->KillCharacter(WEAPON_SELF);
|
||||||
p->m_RespawnTick = Server()->Tick()+Server()->TickSpeed()*3;
|
p->m_RespawnTick = Server()->Tick()+Server()->TickSpeed()*3;
|
||||||
|
@ -1070,12 +1070,12 @@ void CGameContext::ConSetTeam(IConsole::IResult *pResult, void *pUserData, int c
|
||||||
CGameContext *pSelf = (CGameContext *)pUserData;
|
CGameContext *pSelf = (CGameContext *)pUserData;
|
||||||
int ClientId = clamp(pResult->GetInteger(0), 0, (int)MAX_CLIENTS-1);
|
int ClientId = clamp(pResult->GetInteger(0), 0, (int)MAX_CLIENTS-1);
|
||||||
int Team = clamp(pResult->GetInteger(1), -1, 1);
|
int Team = clamp(pResult->GetInteger(1), -1, 1);
|
||||||
|
|
||||||
dbg_msg("set_team", "%d %d", ClientId, Team);
|
dbg_msg("set_team", "%d %d", ClientId, Team);
|
||||||
|
|
||||||
if(!pSelf->m_apPlayers[ClientId] || !compare_players(pSelf->m_apPlayers[cid], pSelf->m_apPlayers[ClientId]))
|
if(!pSelf->m_apPlayers[ClientId] || !compare_players(pSelf->m_apPlayers[cid], pSelf->m_apPlayers[ClientId]))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
pSelf->m_apPlayers[ClientId]->SetTeam(Team);
|
pSelf->m_apPlayers[ClientId]->SetTeam(Team);
|
||||||
//(void)pSelf->m_pController->CheckTeamBalance();
|
//(void)pSelf->m_pController->CheckTeamBalance();
|
||||||
}
|
}
|
||||||
|
@ -1084,7 +1084,7 @@ void CGameContext::ConAddVote(IConsole::IResult *pResult, void *pUserData, int C
|
||||||
{
|
{
|
||||||
CGameContext *pSelf = (CGameContext *)pUserData;
|
CGameContext *pSelf = (CGameContext *)pUserData;
|
||||||
int Len = str_length(pResult->GetString(0));
|
int Len = str_length(pResult->GetString(0));
|
||||||
|
|
||||||
CGameContext::CVoteOption *pOption = (CGameContext::CVoteOption *)pSelf->m_pVoteOptionHeap->Allocate(sizeof(CGameContext::CVoteOption) + Len);
|
CGameContext::CVoteOption *pOption = (CGameContext::CVoteOption *)pSelf->m_pVoteOptionHeap->Allocate(sizeof(CGameContext::CVoteOption) + Len);
|
||||||
pOption->m_pNext = 0;
|
pOption->m_pNext = 0;
|
||||||
pOption->m_pPrev = pSelf->m_pVoteOptionLast;
|
pOption->m_pPrev = pSelf->m_pVoteOptionLast;
|
||||||
|
@ -1093,7 +1093,7 @@ void CGameContext::ConAddVote(IConsole::IResult *pResult, void *pUserData, int C
|
||||||
pSelf->m_pVoteOptionLast = pOption;
|
pSelf->m_pVoteOptionLast = pOption;
|
||||||
if(!pSelf->m_pVoteOptionFirst)
|
if(!pSelf->m_pVoteOptionFirst)
|
||||||
pSelf->m_pVoteOptionFirst = pOption;
|
pSelf->m_pVoteOptionFirst = pOption;
|
||||||
|
|
||||||
mem_copy(pOption->m_aCommand, pResult->GetString(0), Len+1);
|
mem_copy(pOption->m_aCommand, pResult->GetString(0), Len+1);
|
||||||
dbg_msg("server", "added option '%s'", pOption->m_aCommand);
|
dbg_msg("server", "added option '%s'", pOption->m_aCommand);
|
||||||
|
|
||||||
|
@ -1136,7 +1136,7 @@ bool CGameContext::CheatsAvailable(int cid) {
|
||||||
|
|
||||||
void CGameContext::ConGoLeft(IConsole::IResult *pResult, void *pUserData, int cid) {
|
void CGameContext::ConGoLeft(IConsole::IResult *pResult, void *pUserData, int cid) {
|
||||||
CGameContext *pSelf = (CGameContext *)pUserData;
|
CGameContext *pSelf = (CGameContext *)pUserData;
|
||||||
|
|
||||||
if (!pSelf->CheatsAvailable(cid))
|
if (!pSelf->CheatsAvailable(cid))
|
||||||
return;
|
return;
|
||||||
CCharacter* chr = pSelf->GetPlayerChar(cid);
|
CCharacter* chr = pSelf->GetPlayerChar(cid);
|
||||||
|
@ -1219,7 +1219,7 @@ void CGameContext::ConKillPlayer(IConsole::IResult *pResult, void *pUserData, in
|
||||||
int cid1 = clamp(pResult->GetInteger(0), 0, (int)MAX_CLIENTS-1);
|
int cid1 = clamp(pResult->GetInteger(0), 0, (int)MAX_CLIENTS-1);
|
||||||
if(!pSelf->m_apPlayers[cid1])
|
if(!pSelf->m_apPlayers[cid1])
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (pSelf->m_apPlayers[cid1] && compare_players(pSelf->m_apPlayers[cid],pSelf->m_apPlayers[cid1]))
|
if (pSelf->m_apPlayers[cid1] && compare_players(pSelf->m_apPlayers[cid],pSelf->m_apPlayers[cid1]))
|
||||||
{
|
{
|
||||||
pSelf->m_apPlayers[cid1]->KillCharacter(WEAPON_GAME);
|
pSelf->m_apPlayers[cid1]->KillCharacter(WEAPON_GAME);
|
||||||
|
@ -1232,7 +1232,7 @@ void CGameContext::ConKillPlayer(IConsole::IResult *pResult, void *pUserData, in
|
||||||
void CGameContext::ConNinjaMe(IConsole::IResult *pResult, void *pUserData, int cid) {
|
void CGameContext::ConNinjaMe(IConsole::IResult *pResult, void *pUserData, int cid) {
|
||||||
CGameContext *pSelf = (CGameContext *)pUserData;
|
CGameContext *pSelf = (CGameContext *)pUserData;
|
||||||
if(!pSelf->CheatsAvailable(cid)) return;
|
if(!pSelf->CheatsAvailable(cid)) return;
|
||||||
|
|
||||||
CCharacter* chr = pSelf->GetPlayerChar(cid);
|
CCharacter* chr = pSelf->GetPlayerChar(cid);
|
||||||
if(chr) {
|
if(chr) {
|
||||||
chr->GiveNinja();
|
chr->GiveNinja();
|
||||||
|
@ -1259,7 +1259,7 @@ void CGameContext::ConHammer(IConsole::IResult *pResult, void *pUserData, int ci
|
||||||
CGameContext *pSelf = (CGameContext *)pUserData;
|
CGameContext *pSelf = (CGameContext *)pUserData;
|
||||||
if(!pSelf->CheatsAvailable(cid)) return;
|
if(!pSelf->CheatsAvailable(cid)) return;
|
||||||
char buf[128];
|
char buf[128];
|
||||||
|
|
||||||
int cid1 = clamp(pResult->GetInteger(0), 0, (int)MAX_CLIENTS-1);
|
int cid1 = clamp(pResult->GetInteger(0), 0, (int)MAX_CLIENTS-1);
|
||||||
int type = pResult->GetInteger(1);
|
int type = pResult->GetInteger(1);
|
||||||
CCharacter* chr = pSelf->GetPlayerChar(cid1);
|
CCharacter* chr = pSelf->GetPlayerChar(cid1);
|
||||||
|
@ -1281,7 +1281,7 @@ void CGameContext::ConHammer(IConsole::IResult *pResult, void *pUserData, int ci
|
||||||
}
|
}
|
||||||
|
|
||||||
void CGameContext::ConHammerMe(IConsole::IResult *pResult, void *pUserData, int cid)
|
void CGameContext::ConHammerMe(IConsole::IResult *pResult, void *pUserData, int cid)
|
||||||
{
|
{
|
||||||
CGameContext *pSelf = (CGameContext *)pUserData;
|
CGameContext *pSelf = (CGameContext *)pUserData;
|
||||||
if(!pSelf->CheatsAvailable(cid)) return;
|
if(!pSelf->CheatsAvailable(cid)) return;
|
||||||
char buf[128];
|
char buf[128];
|
||||||
|
@ -1306,7 +1306,7 @@ void CGameContext::ConHammerMe(IConsole::IResult *pResult, void *pUserData, int
|
||||||
|
|
||||||
|
|
||||||
void CGameContext::ConSuper(IConsole::IResult *pResult, void *pUserData, int cid)
|
void CGameContext::ConSuper(IConsole::IResult *pResult, void *pUserData, int cid)
|
||||||
{
|
{
|
||||||
CGameContext *pSelf = (CGameContext *)pUserData;
|
CGameContext *pSelf = (CGameContext *)pUserData;
|
||||||
if(!pSelf->CheatsAvailable(cid)) return;
|
if(!pSelf->CheatsAvailable(cid)) return;
|
||||||
int cid1 = clamp(pResult->GetInteger(0), 0, (int)MAX_CLIENTS-1);
|
int cid1 = clamp(pResult->GetInteger(0), 0, (int)MAX_CLIENTS-1);
|
||||||
|
@ -1323,7 +1323,7 @@ void CGameContext::ConSuper(IConsole::IResult *pResult, void *pUserData, int cid
|
||||||
}
|
}
|
||||||
|
|
||||||
void CGameContext::ConUnSuper(IConsole::IResult *pResult, void *pUserData, int cid)
|
void CGameContext::ConUnSuper(IConsole::IResult *pResult, void *pUserData, int cid)
|
||||||
{
|
{
|
||||||
CGameContext *pSelf = (CGameContext *)pUserData;
|
CGameContext *pSelf = (CGameContext *)pUserData;
|
||||||
if(!pSelf->CheatsAvailable(cid)) return;
|
if(!pSelf->CheatsAvailable(cid)) return;
|
||||||
int cid1 = clamp(pResult->GetInteger(0), 0, (int)MAX_CLIENTS-1);
|
int cid1 = clamp(pResult->GetInteger(0), 0, (int)MAX_CLIENTS-1);
|
||||||
|
@ -1338,7 +1338,7 @@ void CGameContext::ConUnSuper(IConsole::IResult *pResult, void *pUserData, int c
|
||||||
}
|
}
|
||||||
|
|
||||||
void CGameContext::ConSuperMe(IConsole::IResult *pResult, void *pUserData, int cid)
|
void CGameContext::ConSuperMe(IConsole::IResult *pResult, void *pUserData, int cid)
|
||||||
{
|
{
|
||||||
CGameContext *pSelf = (CGameContext *)pUserData;
|
CGameContext *pSelf = (CGameContext *)pUserData;
|
||||||
if(!pSelf->CheatsAvailable(cid)) return;
|
if(!pSelf->CheatsAvailable(cid)) return;
|
||||||
if (pSelf->m_apPlayers[cid])
|
if (pSelf->m_apPlayers[cid])
|
||||||
|
@ -1354,7 +1354,7 @@ void CGameContext::ConSuperMe(IConsole::IResult *pResult, void *pUserData, int c
|
||||||
}
|
}
|
||||||
|
|
||||||
void CGameContext::ConUnSuperMe(IConsole::IResult *pResult, void *pUserData, int cid)
|
void CGameContext::ConUnSuperMe(IConsole::IResult *pResult, void *pUserData, int cid)
|
||||||
{
|
{
|
||||||
CGameContext *pSelf = (CGameContext *)pUserData;
|
CGameContext *pSelf = (CGameContext *)pUserData;
|
||||||
if(!pSelf->CheatsAvailable(cid)) return;
|
if(!pSelf->CheatsAvailable(cid)) return;
|
||||||
if (pSelf->m_apPlayers[cid])
|
if (pSelf->m_apPlayers[cid])
|
||||||
|
@ -1425,10 +1425,10 @@ void CGameContext::ConTimer(IConsole::IResult *pResult, void *pUserData, int cid
|
||||||
char buf[128];
|
char buf[128];
|
||||||
CServer* serv = (CServer*)pSelf->Server();
|
CServer* serv = (CServer*)pSelf->Server();
|
||||||
if(!g_Config.m_SvTimer) {
|
if(!g_Config.m_SvTimer) {
|
||||||
|
|
||||||
int cid1 = clamp(pResult->GetInteger(0), 0, (int)MAX_CLIENTS-1);
|
int cid1 = clamp(pResult->GetInteger(0), 0, (int)MAX_CLIENTS-1);
|
||||||
int type = pResult->GetInteger(1);
|
int type = pResult->GetInteger(1);
|
||||||
|
|
||||||
CCharacter* chr = pSelf->GetPlayerChar(cid1);
|
CCharacter* chr = pSelf->GetPlayerChar(cid1);
|
||||||
if (!chr)
|
if (!chr)
|
||||||
return;
|
return;
|
||||||
|
@ -1437,7 +1437,7 @@ void CGameContext::ConTimer(IConsole::IResult *pResult, void *pUserData, int cid
|
||||||
serv->SendRconLine(cid, "Select 0 for no time & 1 for with time");
|
serv->SendRconLine(cid, "Select 0 for no time & 1 for with time");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if(type)
|
if(type)
|
||||||
{
|
{
|
||||||
chr->m_RaceState = RACE_STARTED;
|
chr->m_RaceState = RACE_STARTED;
|
||||||
|
@ -1451,7 +1451,7 @@ void CGameContext::ConTimer(IConsole::IResult *pResult, void *pUserData, int cid
|
||||||
serv->SendRconLine(cid1, buf);
|
serv->SendRconLine(cid1, buf);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
serv->SendRconLine(cid, "Command timer does't allowed");
|
serv->SendRconLine(cid, "Command timer does't allowed");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1461,9 +1461,9 @@ void CGameContext::ConTimerReset(IConsole::IResult *pResult, void *pUserData, in
|
||||||
CGameContext *pSelf = (CGameContext *)pUserData;
|
CGameContext *pSelf = (CGameContext *)pUserData;
|
||||||
if(!pSelf->CheatsAvailable(cid)) return;
|
if(!pSelf->CheatsAvailable(cid)) return;
|
||||||
char buf[128];
|
char buf[128];
|
||||||
|
|
||||||
int cid1 = clamp(pResult->GetInteger(0), 0, (int)MAX_CLIENTS-1);
|
int cid1 = clamp(pResult->GetInteger(0), 0, (int)MAX_CLIENTS-1);
|
||||||
|
|
||||||
CCharacter* chr = pSelf->GetPlayerChar(cid1);
|
CCharacter* chr = pSelf->GetPlayerChar(cid1);
|
||||||
if (!chr)
|
if (!chr)
|
||||||
return;
|
return;
|
||||||
|
@ -1472,38 +1472,38 @@ void CGameContext::ConTimerReset(IConsole::IResult *pResult, void *pUserData, in
|
||||||
str_format(buf, sizeof(buf), "Cid=%d time resetted.",cid1);
|
str_format(buf, sizeof(buf), "Cid=%d time resetted.",cid1);
|
||||||
CServer* serv = (CServer*)pSelf->Server();
|
CServer* serv = (CServer*)pSelf->Server();
|
||||||
serv->SendRconLine(cid1, buf);
|
serv->SendRconLine(cid1, buf);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CGameContext::OnConsoleInit()
|
void CGameContext::OnConsoleInit()
|
||||||
{
|
{
|
||||||
m_pServer = Kernel()->RequestInterface<IServer>();
|
m_pServer = Kernel()->RequestInterface<IServer>();
|
||||||
m_pConsole = Kernel()->RequestInterface<IConsole>();
|
m_pConsole = Kernel()->RequestInterface<IConsole>();
|
||||||
|
|
||||||
Console()->Register("timer", "ii", CFGFLAG_SERVER, ConTimer, this, "Sets the timer of player i1 to i2 0/1 on/off",2);
|
Console()->Register("timer", "ii", CFGFLAG_SERVER, ConTimer, this, "Sets the timer of player i1 to i2 0/1 on/off",2);
|
||||||
Console()->Register("timerreset", "i", CFGFLAG_SERVER, ConTimerReset, this, "resets the timer of player i (to start count again timer cid 1)",1);
|
Console()->Register("timerreset", "i", CFGFLAG_SERVER, ConTimerReset, this, "resets the timer of player i (to start count again timer cid 1)",1);
|
||||||
|
|
||||||
Console()->Register("tele", "ii", CFGFLAG_SERVER, ConTeleport, this, "",2);
|
Console()->Register("tele", "ii", CFGFLAG_SERVER, ConTeleport, this, "",2);
|
||||||
|
|
||||||
Console()->Register("weapons", "i", CFGFLAG_SERVER, ConWeapons, this, "",2);
|
Console()->Register("weapons", "i", CFGFLAG_SERVER, ConWeapons, this, "",2);
|
||||||
Console()->Register("weapons_me", "", CFGFLAG_SERVER, ConWeaponsMe, this, "",1);
|
Console()->Register("weapons_me", "", CFGFLAG_SERVER, ConWeaponsMe, this, "",1);
|
||||||
|
|
||||||
Console()->Register("super", "i", CFGFLAG_SERVER, ConSuper, this, "",2);
|
Console()->Register("super", "i", CFGFLAG_SERVER, ConSuper, this, "",2);
|
||||||
Console()->Register("unsuper", "i", CFGFLAG_SERVER, ConUnSuper, this, "",2);
|
Console()->Register("unsuper", "i", CFGFLAG_SERVER, ConUnSuper, this, "",2);
|
||||||
Console()->Register("super_me", "", CFGFLAG_SERVER, ConSuperMe, this, "",1);
|
Console()->Register("super_me", "", CFGFLAG_SERVER, ConSuperMe, this, "",1);
|
||||||
Console()->Register("unsuper_me", "", CFGFLAG_SERVER, ConUnSuperMe, this, "",1);// Mo
|
Console()->Register("unsuper_me", "", CFGFLAG_SERVER, ConUnSuperMe, this, "",1);// Mo
|
||||||
|
|
||||||
Console()->Register("hammer_me", "i", CFGFLAG_SERVER, ConHammerMe, this, "",1);
|
Console()->Register("hammer_me", "i", CFGFLAG_SERVER, ConHammerMe, this, "",1);
|
||||||
Console()->Register("hammer", "ii", CFGFLAG_SERVER, ConHammer, this, "",2);
|
Console()->Register("hammer", "ii", CFGFLAG_SERVER, ConHammer, this, "",2);
|
||||||
|
|
||||||
Console()->Register("ninja", "i", CFGFLAG_SERVER, ConNinja, this, "",2);
|
Console()->Register("ninja", "i", CFGFLAG_SERVER, ConNinja, this, "",2);
|
||||||
Console()->Register("ninja_me", "", CFGFLAG_SERVER, ConNinjaMe, this, "",1);
|
Console()->Register("ninja_me", "", CFGFLAG_SERVER, ConNinjaMe, this, "",1);
|
||||||
|
|
||||||
|
|
||||||
Console()->Register("kill_pl", "i", CFGFLAG_SERVER, ConKillPlayer, this, "",2);
|
Console()->Register("kill_pl", "i", CFGFLAG_SERVER, ConKillPlayer, this, "",2);
|
||||||
Console()->Register("auth", "ii", CFGFLAG_SERVER, ConSetlvl, this, "",3);
|
Console()->Register("auth", "ii", CFGFLAG_SERVER, ConSetlvl, this, "",3);
|
||||||
Console()->Register("mute", "ii", CFGFLAG_SERVER, ConMute, this, "", 2);
|
Console()->Register("mute", "ii", CFGFLAG_SERVER, ConMute, this, "", 2);
|
||||||
|
|
||||||
Console()->Register("tune", "si", CFGFLAG_SERVER, ConTuneParam, this, "", 4);
|
Console()->Register("tune", "si", CFGFLAG_SERVER, ConTuneParam, this, "", 4);
|
||||||
Console()->Register("tune_reset", "", CFGFLAG_SERVER, ConTuneReset, this, "", 4);
|
Console()->Register("tune_reset", "", CFGFLAG_SERVER, ConTuneReset, this, "", 4);
|
||||||
Console()->Register("tune_dump", "", CFGFLAG_SERVER, ConTuneDump, this, "", 4);
|
Console()->Register("tune_dump", "", CFGFLAG_SERVER, ConTuneDump, this, "", 4);
|
||||||
|
@ -1513,7 +1513,7 @@ void CGameContext::OnConsoleInit()
|
||||||
Console()->Register("broadcast", "r", CFGFLAG_SERVER, ConBroadcast, this, "", 3);
|
Console()->Register("broadcast", "r", CFGFLAG_SERVER, ConBroadcast, this, "", 3);
|
||||||
Console()->Register("say", "r", CFGFLAG_SERVER, ConSay, this, "", 3);
|
Console()->Register("say", "r", CFGFLAG_SERVER, ConSay, this, "", 3);
|
||||||
Console()->Register("set_team", "ii", CFGFLAG_SERVER, ConSetTeam, this, "", 2);
|
Console()->Register("set_team", "ii", CFGFLAG_SERVER, ConSetTeam, this, "", 2);
|
||||||
|
|
||||||
Console()->Register("left", "", CFGFLAG_SERVER, ConGoLeft, this, "",1);
|
Console()->Register("left", "", CFGFLAG_SERVER, ConGoLeft, this, "",1);
|
||||||
Console()->Register("right", "", CFGFLAG_SERVER, ConGoRight, this, "",1);
|
Console()->Register("right", "", CFGFLAG_SERVER, ConGoRight, this, "",1);
|
||||||
Console()->Register("up", "", CFGFLAG_SERVER, ConGoUp, this, "",1);
|
Console()->Register("up", "", CFGFLAG_SERVER, ConGoUp, this, "",1);
|
||||||
|
@ -1523,7 +1523,7 @@ void CGameContext::OnConsoleInit()
|
||||||
Console()->Register("vote", "r", CFGFLAG_SERVER, ConVote, this, "", 3);
|
Console()->Register("vote", "r", CFGFLAG_SERVER, ConVote, this, "", 3);
|
||||||
|
|
||||||
Console()->Chain("sv_motd", ConchainSpecialMotdupdate, this);
|
Console()->Chain("sv_motd", ConchainSpecialMotdupdate, this);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CGameContext::OnInit(/*class IKernel *pKernel*/)
|
void CGameContext::OnInit(/*class IKernel *pKernel*/)
|
||||||
|
@ -1532,10 +1532,10 @@ void CGameContext::OnInit(/*class IKernel *pKernel*/)
|
||||||
m_pConsole = Kernel()->RequestInterface<IConsole>();
|
m_pConsole = Kernel()->RequestInterface<IConsole>();
|
||||||
m_World.SetGameServer(this);
|
m_World.SetGameServer(this);
|
||||||
m_Events.SetGameServer(this);
|
m_Events.SetGameServer(this);
|
||||||
|
|
||||||
//if(!data) // only load once
|
//if(!data) // only load once
|
||||||
//data = load_data_from_memory(internal_data);
|
//data = load_data_from_memory(internal_data);
|
||||||
|
|
||||||
for(int i = 0; i < NUM_NETOBJTYPES; i++)
|
for(int i = 0; i < NUM_NETOBJTYPES; i++)
|
||||||
Server()->SnapSetStaticsize(i, m_NetObjHandler.GetObjSize(i));
|
Server()->SnapSetStaticsize(i, m_NetObjHandler.GetObjSize(i));
|
||||||
|
|
||||||
|
@ -1546,22 +1546,22 @@ void CGameContext::OnInit(/*class IKernel *pKernel*/)
|
||||||
//world = new GAMEWORLD;
|
//world = new GAMEWORLD;
|
||||||
//players = new CPlayer[MAX_CLIENTS];
|
//players = new CPlayer[MAX_CLIENTS];
|
||||||
|
|
||||||
char buf[512];
|
char buf[512];
|
||||||
str_format(buf, sizeof(buf), "data/maps/%s.cfg", g_Config.m_SvMap); //
|
str_format(buf, sizeof(buf), "data/maps/%s.cfg", g_Config.m_SvMap); //
|
||||||
Console()->ExecuteFile(buf);
|
Console()->ExecuteFile(buf);
|
||||||
str_format(buf, sizeof(buf), "data/maps/%s.map.cfg", g_Config.m_SvMap);
|
str_format(buf, sizeof(buf), "data/maps/%s.map.cfg", g_Config.m_SvMap);
|
||||||
Console()->ExecuteFile(buf);
|
Console()->ExecuteFile(buf);
|
||||||
// dbg_msg("Note","For map cfgs in windows and linux u need the files");
|
// dbg_msg("Note","For map cfgs in windows and linux u need the files");
|
||||||
// dbg_msg("Note","in a folder i nthe same dir as teeworlds_srv");
|
// dbg_msg("Note","in a folder i nthe same dir as teeworlds_srv");
|
||||||
// dbg_msg("Note","data/maps/%s.cfg", config.sv_map);
|
// dbg_msg("Note","data/maps/%s.cfg", config.sv_map);
|
||||||
// select gametype
|
// select gametype
|
||||||
m_pController = new CGameControllerDDRace(this);
|
m_pController = new CGameControllerDDRace(this);
|
||||||
//float temp;
|
//float temp;
|
||||||
//m_Tuning.Get("player_hooking",&temp);
|
//m_Tuning.Get("player_hooking",&temp);
|
||||||
//g_Config.m_SvPhook = temp;
|
//g_Config.m_SvPhook = temp;
|
||||||
//m_Tuning.Get("player_collision",&temp);
|
//m_Tuning.Get("player_collision",&temp);
|
||||||
//g_Config.m_SvNpc=(!temp);
|
//g_Config.m_SvNpc=(!temp);
|
||||||
|
|
||||||
Server()->SetBrowseInfo(m_pController->m_pGameType, -1);
|
Server()->SetBrowseInfo(m_pController->m_pGameType, -1);
|
||||||
|
|
||||||
// setup core world
|
// setup core world
|
||||||
|
@ -1571,18 +1571,29 @@ void CGameContext::OnInit(/*class IKernel *pKernel*/)
|
||||||
// create all entities from the game layer
|
// create all entities from the game layer
|
||||||
CMapItemLayerTilemap *pTileMap = m_Layers.GameLayer();
|
CMapItemLayerTilemap *pTileMap = m_Layers.GameLayer();
|
||||||
CTile *pTiles = (CTile *)Kernel()->RequestInterface<IMap>()->GetData(pTileMap->m_Data);
|
CTile *pTiles = (CTile *)Kernel()->RequestInterface<IMap>()->GetData(pTileMap->m_Data);
|
||||||
|
//CMapItemLayerTilemap *pFrontMap = m_Layers.FrontLayer(); not needed game layer and front layer are always the same size
|
||||||
//windows usually crshes here
|
CTile *pFront=0;
|
||||||
|
if (m_Layers.FrontLayer())
|
||||||
|
pFront = (CTile *)Kernel()->RequestInterface<IMap>()->GetData(pTileMap->m_Front);
|
||||||
|
|
||||||
for(int y = 0; y < pTileMap->m_Height; y++)
|
for(int y = 0; y < pTileMap->m_Height; y++)
|
||||||
{
|
{
|
||||||
for(int x = 0; x < pTileMap->m_Width; x++)
|
for(int x = 0; x < pTileMap->m_Width; x++)
|
||||||
{
|
{
|
||||||
int Index = pTiles[y*pTileMap->m_Width+x].m_Index;
|
int Index = pTiles[y*pTileMap->m_Width+x].m_Index;
|
||||||
|
|
||||||
if(Index >= ENTITY_OFFSET)
|
if(Index >= ENTITY_OFFSET)
|
||||||
{
|
{
|
||||||
vec2 Pos(x*32.0f+16.0f, y*32.0f+16.0f);
|
vec2 Pos(x*32.0f+16.0f, y*32.0f+16.0f);
|
||||||
m_pController->OnEntity(Index-ENTITY_OFFSET, Pos);
|
m_pController->OnEntity(Index-ENTITY_OFFSET, Pos,false);
|
||||||
|
}
|
||||||
|
if (pFront)
|
||||||
|
{
|
||||||
|
int FIndex = pFront[y*pTileMap->m_Width+x].m_Index;
|
||||||
|
if(FIndex >= ENTITY_OFFSET)
|
||||||
|
{
|
||||||
|
vec2 Pos(x*32.0f+16.0f, y*32.0f+16.0f);
|
||||||
|
m_pController->OnEntity(FIndex-ENTITY_OFFSET, Pos,true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1610,7 +1621,7 @@ void CGameContext::OnSnap(int ClientId)
|
||||||
m_World.Snap(ClientId);
|
m_World.Snap(ClientId);
|
||||||
m_pController->Snap(ClientId);
|
m_pController->Snap(ClientId);
|
||||||
m_Events.Snap(ClientId);
|
m_Events.Snap(ClientId);
|
||||||
|
|
||||||
for(int i = 0; i < MAX_CLIENTS; i++)
|
for(int i = 0; i < MAX_CLIENTS; i++)
|
||||||
{
|
{
|
||||||
if(m_apPlayers[i])
|
if(m_apPlayers[i])
|
||||||
|
|
|
@ -8,13 +8,13 @@
|
||||||
#include "gamecontroller.h"
|
#include "gamecontroller.h"
|
||||||
#include "gamecontext.h"
|
#include "gamecontext.h"
|
||||||
|
|
||||||
#include "entities/light.h"
|
#include "entities/light.h"
|
||||||
#include "entities/drager.h"
|
#include "entities/drager.h"
|
||||||
#include "entities/gun.h"
|
#include "entities/gun.h"
|
||||||
#include "entities/projectile.h"
|
#include "entities/projectile.h"
|
||||||
#include "entities/plasma.h"
|
#include "entities/plasma.h"
|
||||||
#include "entities/trigger.h"
|
#include "entities/trigger.h"
|
||||||
#include "entities/door.h"
|
#include "entities/door.h"
|
||||||
|
|
||||||
#include <game/layers.h>
|
#include <game/layers.h>
|
||||||
|
|
||||||
|
@ -24,7 +24,7 @@ IGameController::IGameController(class CGameContext *pGameServer)
|
||||||
m_pGameServer = pGameServer;
|
m_pGameServer = pGameServer;
|
||||||
m_pServer = m_pGameServer->Server();
|
m_pServer = m_pGameServer->Server();
|
||||||
m_pGameType = "unknown";
|
m_pGameType = "unknown";
|
||||||
|
|
||||||
//
|
//
|
||||||
DoWarmup(g_Config.m_SvWarmup);
|
DoWarmup(g_Config.m_SvWarmup);
|
||||||
m_GameOverTick = -1;
|
m_GameOverTick = -1;
|
||||||
|
@ -35,10 +35,10 @@ IGameController::IGameController(class CGameContext *pGameServer)
|
||||||
//m_aTeamscore[0] = 0;
|
//m_aTeamscore[0] = 0;
|
||||||
//m_aTeamscore[1] = 0;
|
//m_aTeamscore[1] = 0;
|
||||||
m_aMapWish[0] = 0;
|
m_aMapWish[0] = 0;
|
||||||
|
|
||||||
m_UnbalancedTick = -1;
|
m_UnbalancedTick = -1;
|
||||||
m_ForceBalanced = false;
|
m_ForceBalanced = false;
|
||||||
|
|
||||||
m_aNumSpawnPoints[0] = 0;
|
m_aNumSpawnPoints[0] = 0;
|
||||||
m_aNumSpawnPoints[1] = 0;
|
m_aNumSpawnPoints[1] = 0;
|
||||||
m_aNumSpawnPoints[2] = 0;
|
m_aNumSpawnPoints[2] = 0;
|
||||||
|
@ -58,14 +58,14 @@ float IGameController::EvaluateSpawnPos(CSpawnEval *pEval, vec2 Pos)
|
||||||
float Scoremod = 1.0f;
|
float Scoremod = 1.0f;
|
||||||
if(pEval->m_FriendlyTeam != -1 && pC->GetPlayer()->GetTeam() == pEval->m_FriendlyTeam)
|
if(pEval->m_FriendlyTeam != -1 && pC->GetPlayer()->GetTeam() == pEval->m_FriendlyTeam)
|
||||||
Scoremod = 0.5f;
|
Scoremod = 0.5f;
|
||||||
|
|
||||||
float d = distance(Pos, pC->m_Pos);
|
float d = distance(Pos, pC->m_Pos);
|
||||||
if(d == 0)
|
if(d == 0)
|
||||||
Score += 1000000000.0f;
|
Score += 1000000000.0f;
|
||||||
else
|
else
|
||||||
Score += 1.0f/d;
|
Score += 1.0f/d;
|
||||||
}
|
}
|
||||||
|
|
||||||
return Score;
|
return Score;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -88,15 +88,15 @@ void IGameController::EvaluateSpawnType(CSpawnEval *pEval, int T)
|
||||||
bool IGameController::CanSpawn(CPlayer *pPlayer, vec2 *pOutPos)
|
bool IGameController::CanSpawn(CPlayer *pPlayer, vec2 *pOutPos)
|
||||||
{
|
{
|
||||||
CSpawnEval Eval;
|
CSpawnEval Eval;
|
||||||
|
|
||||||
// spectators can't spawn
|
// spectators can't spawn
|
||||||
if(pPlayer->GetTeam() == -1)
|
if(pPlayer->GetTeam() == -1)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
/*if(IsTeamplay())
|
/*if(IsTeamplay())
|
||||||
{
|
{
|
||||||
Eval.m_FriendlyTeam = pPlayer->GetTeam();
|
Eval.m_FriendlyTeam = pPlayer->GetTeam();
|
||||||
|
|
||||||
// try first try own team spawn, then normal spawn and then enemy
|
// try first try own team spawn, then normal spawn and then enemy
|
||||||
EvaluateSpawnType(&Eval, 1+(pPlayer->GetTeam()&1));
|
EvaluateSpawnType(&Eval, 1+(pPlayer->GetTeam()&1));
|
||||||
if(!Eval.m_Got)
|
if(!Eval.m_Got)
|
||||||
|
@ -112,37 +112,40 @@ bool IGameController::CanSpawn(CPlayer *pPlayer, vec2 *pOutPos)
|
||||||
EvaluateSpawnType(&Eval, 1);
|
EvaluateSpawnType(&Eval, 1);
|
||||||
EvaluateSpawnType(&Eval, 2);
|
EvaluateSpawnType(&Eval, 2);
|
||||||
//}
|
//}
|
||||||
|
|
||||||
*pOutPos = Eval.m_Pos;
|
*pOutPos = Eval.m_Pos;
|
||||||
return Eval.m_Got;
|
return Eval.m_Got;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool IGameController::OnEntity(int Index, vec2 Pos)
|
bool IGameController::OnEntity(int Index, vec2 Pos, bool Front)
|
||||||
{
|
{
|
||||||
|
//if (Index<0)
|
||||||
|
//return false;
|
||||||
|
dbg_msg("OnEntity","Index=%d, Pos=(%d,%d), Front=%d",Index,Pos.x,Pos.y,Front);//Remove*/
|
||||||
int Type = -1;
|
int Type = -1;
|
||||||
int SubType = 0;
|
int SubType = 0;
|
||||||
int x,y;
|
int x,y;
|
||||||
x=(Pos.x-16.0f)/32.0f;
|
x=(Pos.x-16.0f)/32.0f;
|
||||||
y=(Pos.y-16.0f)/32.0f;
|
y=(Pos.y-16.0f)/32.0f;
|
||||||
dbg_msg("OnEntity","Pos(%d,%d)",x,y);
|
/*dbg_msg("OnEntity","Pos(%d,%d)",x,y);//Remove*/
|
||||||
int sides[8];
|
int sides[8];
|
||||||
sides[0]=GameServer()->Collision()->Entitiy(x,y+1);
|
sides[0]=GameServer()->Collision()->Entity(x,y+1, Front);
|
||||||
sides[1]=GameServer()->Collision()->Entitiy(x+1,y+1);
|
sides[1]=GameServer()->Collision()->Entity(x+1,y+1, Front);
|
||||||
sides[2]=GameServer()->Collision()->Entitiy(x+1,y);
|
sides[2]=GameServer()->Collision()->Entity(x+1,y, Front);
|
||||||
sides[3]=GameServer()->Collision()->Entitiy(x+1,y-1);
|
sides[3]=GameServer()->Collision()->Entity(x+1,y-1, Front);
|
||||||
sides[4]=GameServer()->Collision()->Entitiy(x,y-1);
|
sides[4]=GameServer()->Collision()->Entity(x,y-1, Front);
|
||||||
sides[5]=GameServer()->Collision()->Entitiy(x-1,y-1);
|
sides[5]=GameServer()->Collision()->Entity(x-1,y-1, Front);
|
||||||
sides[6]=GameServer()->Collision()->Entitiy(x-1,y);
|
sides[6]=GameServer()->Collision()->Entity(x-1,y, Front);
|
||||||
sides[7]=GameServer()->Collision()->Entitiy(x-1,y+1);
|
sides[7]=GameServer()->Collision()->Entity(x-1,y+1, Front);
|
||||||
|
|
||||||
|
|
||||||
if(Index == ENTITY_SPAWN)
|
if(Index == ENTITY_SPAWN)
|
||||||
m_aaSpawnPoints[0][m_aNumSpawnPoints[0]++] = Pos;
|
m_aaSpawnPoints[0][m_aNumSpawnPoints[0]++] = Pos;
|
||||||
else if(Index == ENTITY_SPAWN_RED)
|
else if(Index == ENTITY_SPAWN_RED)
|
||||||
m_aaSpawnPoints[1][m_aNumSpawnPoints[1]++] = Pos;
|
m_aaSpawnPoints[1][m_aNumSpawnPoints[1]++] = Pos;
|
||||||
else if(Index == ENTITY_SPAWN_BLUE)
|
else if(Index == ENTITY_SPAWN_BLUE)
|
||||||
m_aaSpawnPoints[2][m_aNumSpawnPoints[2]++] = Pos;
|
m_aaSpawnPoints[2][m_aNumSpawnPoints[2]++] = Pos;
|
||||||
|
|
||||||
if(Index == ENTITY_DOOR)
|
if(Index == ENTITY_DOOR)
|
||||||
{
|
{
|
||||||
for(int i=0; i<8;i++)
|
for(int i=0; i<8;i++)
|
||||||
|
@ -152,7 +155,7 @@ bool IGameController::OnEntity(int Index, vec2 Pos)
|
||||||
CDoor * door = new CDoor(&GameServer()->m_World, Pos, pi/4*i, 32*3 + 32*(sides[i] - ENTITY_LASER_SHORT)*3, false);
|
CDoor * door = new CDoor(&GameServer()->m_World, Pos, pi/4*i, 32*3 + 32*(sides[i] - ENTITY_LASER_SHORT)*3, false);
|
||||||
//for (int j = 0; j < 8; j++)
|
//for (int j = 0; j < 8; j++)
|
||||||
// if (j != i)
|
// if (j != i)
|
||||||
Connector(vec2(x, y), door);
|
Connector(vec2(x, y), door, Front);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -163,7 +166,7 @@ bool IGameController::OnEntity(int Index, vec2 Pos)
|
||||||
if (Index - ENTITY_CRAZY_SHOTGUN_U_EX == i)
|
if (Index - ENTITY_CRAZY_SHOTGUN_U_EX == i)
|
||||||
{
|
{
|
||||||
float Deg = i*(pi/2);
|
float Deg = i*(pi/2);
|
||||||
CProjectile *bullet = new CProjectile(&GameServer()->m_World,
|
CProjectile *bullet = new CProjectile(&GameServer()->m_World,
|
||||||
WEAPON_SHOTGUN, //Type
|
WEAPON_SHOTGUN, //Type
|
||||||
-1, //Owner
|
-1, //Owner
|
||||||
Pos, //Pos
|
Pos, //Pos
|
||||||
|
@ -171,8 +174,8 @@ bool IGameController::OnEntity(int Index, vec2 Pos)
|
||||||
-2, //Span
|
-2, //Span
|
||||||
true, //Freeze
|
true, //Freeze
|
||||||
true, //Explosive
|
true, //Explosive
|
||||||
0,
|
0,
|
||||||
SOUND_GRENADE_EXPLODE,
|
SOUND_GRENADE_EXPLODE,
|
||||||
WEAPON_SHOTGUN);
|
WEAPON_SHOTGUN);
|
||||||
bullet->SetBouncing(2 - (i % 2));
|
bullet->SetBouncing(2 - (i % 2));
|
||||||
|
|
||||||
|
@ -186,7 +189,7 @@ bool IGameController::OnEntity(int Index, vec2 Pos)
|
||||||
if (Index - ENTITY_CRAZY_SHOTGUN_U == i)
|
if (Index - ENTITY_CRAZY_SHOTGUN_U == i)
|
||||||
{
|
{
|
||||||
float Deg = i*(pi/2);
|
float Deg = i*(pi/2);
|
||||||
CProjectile *bullet = new CProjectile(&GameServer()->m_World,
|
CProjectile *bullet = new CProjectile(&GameServer()->m_World,
|
||||||
WEAPON_SHOTGUN, //Type
|
WEAPON_SHOTGUN, //Type
|
||||||
-1, //Owner
|
-1, //Owner
|
||||||
Pos, //Pos
|
Pos, //Pos
|
||||||
|
@ -194,14 +197,14 @@ bool IGameController::OnEntity(int Index, vec2 Pos)
|
||||||
-2, //Span
|
-2, //Span
|
||||||
true, //Freeze
|
true, //Freeze
|
||||||
false, //Explosive
|
false, //Explosive
|
||||||
0,
|
0,
|
||||||
SOUND_GRENADE_EXPLODE,
|
SOUND_GRENADE_EXPLODE,
|
||||||
WEAPON_SHOTGUN);
|
WEAPON_SHOTGUN);
|
||||||
bullet->SetBouncing(2 - (i % 2));
|
bullet->SetBouncing(2 - (i % 2));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(Index == ENTITY_ARMOR_1)
|
if(Index == ENTITY_ARMOR_1)
|
||||||
Type = POWERUP_ARMOR;
|
Type = POWERUP_ARMOR;
|
||||||
else if(Index == ENTITY_HEALTH_1)
|
else if(Index == ENTITY_HEALTH_1)
|
||||||
|
@ -226,76 +229,76 @@ bool IGameController::OnEntity(int Index, vec2 Pos)
|
||||||
Type = POWERUP_NINJA;
|
Type = POWERUP_NINJA;
|
||||||
SubType = WEAPON_NINJA;
|
SubType = WEAPON_NINJA;
|
||||||
}
|
}
|
||||||
else if(Index >= ENTITY_LASER_FAST_CW && Index <= ENTITY_LASER_FAST_CCW)
|
else if(Index >= ENTITY_LASER_FAST_CW && Index <= ENTITY_LASER_FAST_CCW)
|
||||||
{
|
{
|
||||||
int sides2[8];
|
int sides2[8];
|
||||||
sides2[0]=GameServer()->Collision()->Entitiy(x,y+2);
|
sides2[0]=GameServer()->Collision()->Entity(x,y+2, Front);
|
||||||
sides2[1]=GameServer()->Collision()->Entitiy(x+2,y+2);
|
sides2[1]=GameServer()->Collision()->Entity(x+2,y+2, Front);
|
||||||
sides2[2]=GameServer()->Collision()->Entitiy(x+2,y);
|
sides2[2]=GameServer()->Collision()->Entity(x+2,y, Front);
|
||||||
sides2[3]=GameServer()->Collision()->Entitiy(x+2,y-2);
|
sides2[3]=GameServer()->Collision()->Entity(x+2,y-2, Front);
|
||||||
sides2[4]=GameServer()->Collision()->Entitiy(x,y-2);
|
sides2[4]=GameServer()->Collision()->Entity(x,y-2, Front);
|
||||||
sides2[5]=GameServer()->Collision()->Entitiy(x-2,y-2);
|
sides2[5]=GameServer()->Collision()->Entity(x-2,y-2, Front);
|
||||||
sides2[6]=GameServer()->Collision()->Entitiy(x-2,y);
|
sides2[6]=GameServer()->Collision()->Entity(x-2,y, Front);
|
||||||
sides2[7]=GameServer()->Collision()->Entitiy(x-2,y+2);
|
sides2[7]=GameServer()->Collision()->Entity(x-2,y+2, Front);
|
||||||
|
|
||||||
float ang_speed;
|
float ang_speed;
|
||||||
int ind=Index-ENTITY_LASER_STOP;
|
int ind=Index-ENTITY_LASER_STOP;
|
||||||
int m;
|
int m;
|
||||||
if (ind<0)
|
if (ind<0)
|
||||||
{
|
{
|
||||||
ind=-ind;
|
ind=-ind;
|
||||||
m=1;
|
m=1;
|
||||||
}
|
}
|
||||||
else if(ind==0)
|
else if(ind==0)
|
||||||
m=0;
|
m=0;
|
||||||
else
|
else
|
||||||
m=-1;
|
m=-1;
|
||||||
|
|
||||||
|
|
||||||
if (ind==0)
|
|
||||||
ang_speed=0.0f;
|
|
||||||
else if (ind==1)
|
|
||||||
ang_speed=pi/360;
|
|
||||||
else if (ind==2)
|
|
||||||
ang_speed=pi/180;
|
|
||||||
else if (ind==3)
|
|
||||||
ang_speed=pi/90;
|
|
||||||
ang_speed*=m;
|
|
||||||
|
|
||||||
for(int i=0; i<8;i++)
|
|
||||||
{
|
|
||||||
if (sides[i] >= ENTITY_LASER_SHORT && sides[i] <= ENTITY_LASER_LONG)
|
|
||||||
{
|
|
||||||
CLight *lgt = new CLight(&GameServer()->m_World, Pos, pi/4*i,32*3 + 32*(sides[i] - ENTITY_LASER_SHORT)*3);
|
|
||||||
lgt->ang_speed=ang_speed;
|
|
||||||
if (sides2[i]>=ENTITY_LASER_C_SLOW && sides2[i]<=ENTITY_LASER_C_FAST)
|
|
||||||
{
|
|
||||||
lgt->speed=1+(sides2[i]-ENTITY_LASER_C_SLOW)*2;
|
|
||||||
lgt->cur_length=lgt->length;
|
|
||||||
}
|
|
||||||
else if(sides2[i]>=ENTITY_LASER_O_SLOW && sides2[i]<=ENTITY_LASER_O_FAST)
|
|
||||||
{
|
|
||||||
lgt->speed=1+(sides2[i]-ENTITY_LASER_O_SLOW)*2;
|
|
||||||
lgt->cur_length=0;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
lgt->cur_length=lgt->length;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
else if(Index>=ENTITY_DRAGGER_WEAK && Index <=ENTITY_DRAGGER_STRONG)
|
if (ind==0)
|
||||||
{
|
ang_speed=0.0f;
|
||||||
new CDrager(&GameServer()->m_World,Pos,Index-ENTITY_DRAGGER_WEAK+1);
|
else if (ind==1)
|
||||||
}
|
ang_speed=pi/360;
|
||||||
else if(Index>=ENTITY_DRAGGER_WEAK_NW && Index <=ENTITY_DRAGGER_STRONG_NW)
|
else if (ind==2)
|
||||||
{
|
ang_speed=pi/180;
|
||||||
new CDrager(&GameServer()->m_World, Pos,Index-ENTITY_DRAGGER_WEAK_NW+1,true);
|
else if (ind==3)
|
||||||
}
|
ang_speed=pi/90;
|
||||||
else if(Index==ENTITY_PLASMA)
|
ang_speed*=m;
|
||||||
{
|
|
||||||
new CGun(&GameServer()->m_World, Pos);
|
for(int i=0; i<8;i++)
|
||||||
}
|
{
|
||||||
|
if (sides[i] >= ENTITY_LASER_SHORT && sides[i] <= ENTITY_LASER_LONG)
|
||||||
|
{
|
||||||
|
CLight *lgt = new CLight(&GameServer()->m_World, Pos, pi/4*i,32*3 + 32*(sides[i] - ENTITY_LASER_SHORT)*3);
|
||||||
|
lgt->ang_speed=ang_speed;
|
||||||
|
if (sides2[i]>=ENTITY_LASER_C_SLOW && sides2[i]<=ENTITY_LASER_C_FAST)
|
||||||
|
{
|
||||||
|
lgt->speed=1+(sides2[i]-ENTITY_LASER_C_SLOW)*2;
|
||||||
|
lgt->cur_length=lgt->length;
|
||||||
|
}
|
||||||
|
else if(sides2[i]>=ENTITY_LASER_O_SLOW && sides2[i]<=ENTITY_LASER_O_FAST)
|
||||||
|
{
|
||||||
|
lgt->speed=1+(sides2[i]-ENTITY_LASER_O_SLOW)*2;
|
||||||
|
lgt->cur_length=0;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
lgt->cur_length=lgt->length;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
else if(Index>=ENTITY_DRAGGER_WEAK && Index <=ENTITY_DRAGGER_STRONG)
|
||||||
|
{
|
||||||
|
new CDrager(&GameServer()->m_World,Pos,Index-ENTITY_DRAGGER_WEAK+1);
|
||||||
|
}
|
||||||
|
else if(Index>=ENTITY_DRAGGER_WEAK_NW && Index <=ENTITY_DRAGGER_STRONG_NW)
|
||||||
|
{
|
||||||
|
new CDrager(&GameServer()->m_World, Pos,Index-ENTITY_DRAGGER_WEAK_NW+1,true);
|
||||||
|
}
|
||||||
|
else if(Index==ENTITY_PLASMA)
|
||||||
|
{
|
||||||
|
new CGun(&GameServer()->m_World, Pos);
|
||||||
|
}
|
||||||
if(Type != -1)
|
if(Type != -1)
|
||||||
{
|
{
|
||||||
CPickup *pPickup = new CPickup(&GameServer()->m_World, Type, SubType);
|
CPickup *pPickup = new CPickup(&GameServer()->m_World, Type, SubType);
|
||||||
|
@ -322,21 +325,21 @@ vec2 GetSidePos(int side) {
|
||||||
return vec2(0, 0);
|
return vec2(0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void IGameController::Connector(vec2 Pos, CDoor* Door) {
|
void IGameController::Connector(vec2 Pos, CDoor* Door, bool Front) {
|
||||||
int sides[8];
|
int sides[8];
|
||||||
sides[0] = GameServer()->Collision()->Entitiy(Pos.x, Pos.y + 1);
|
sides[0] = GameServer()->Collision()->Entity(Pos.x, Pos.y + 1, Front);
|
||||||
sides[1] = GameServer()->Collision()->Entitiy(Pos.x + 1, Pos.y + 1);
|
sides[1] = GameServer()->Collision()->Entity(Pos.x + 1, Pos.y + 1, Front);
|
||||||
sides[2] = GameServer()->Collision()->Entitiy(Pos.x + 1, Pos.y);
|
sides[2] = GameServer()->Collision()->Entity(Pos.x + 1, Pos.y, Front);
|
||||||
sides[3] = GameServer()->Collision()->Entitiy(Pos.x + 1, Pos.y - 1);
|
sides[3] = GameServer()->Collision()->Entity(Pos.x + 1, Pos.y - 1, Front);
|
||||||
sides[4] = GameServer()->Collision()->Entitiy(Pos.x, Pos.y - 1);
|
sides[4] = GameServer()->Collision()->Entity(Pos.x, Pos.y - 1, Front);
|
||||||
sides[5] = GameServer()->Collision()->Entitiy(Pos.x - 1, Pos.y - 1);
|
sides[5] = GameServer()->Collision()->Entity(Pos.x - 1, Pos.y - 1, Front);
|
||||||
sides[6] = GameServer()->Collision()->Entitiy(Pos.x - 1, Pos.y);
|
sides[6] = GameServer()->Collision()->Entity(Pos.x - 1, Pos.y, Front);
|
||||||
sides[7] = GameServer()->Collision()->Entitiy(Pos.x - 1, Pos.y + 1);
|
sides[7] = GameServer()->Collision()->Entity(Pos.x - 1, Pos.y + 1, Front);
|
||||||
for (int i=0;i<8;i++)
|
for (int i=0;i<8;i++)
|
||||||
{
|
{
|
||||||
vec2 shift = GetSidePos(i);
|
vec2 shift = GetSidePos(i);
|
||||||
if (sides[i]==ENTITY_CONNECTOR_D+(i+4) % 8)
|
if (sides[i]==ENTITY_CONNECTOR_D+(i+4) % 8)
|
||||||
Connector(Pos + shift, Door);
|
Connector(Pos + shift, Door, Front);
|
||||||
else if(sides[i]==ENTITY_TRIGGER)
|
else if(sides[i]==ENTITY_TRIGGER)
|
||||||
{
|
{
|
||||||
vec2 pos((Pos.x + shift.x)*32.0f + 16.0f, (Pos.y + shift.y)*32.0f + 16.0f);
|
vec2 pos((Pos.x + shift.x)*32.0f + 16.0f, (Pos.y + shift.y)*32.0f + 16.0f);
|
||||||
|
@ -349,7 +352,7 @@ void IGameController::EndRound()
|
||||||
{
|
{
|
||||||
if(m_Warmup) // game can't end when we are running warmup
|
if(m_Warmup) // game can't end when we are running warmup
|
||||||
return;
|
return;
|
||||||
|
|
||||||
GameServer()->m_World.m_Paused = true;
|
GameServer()->m_World.m_Paused = true;
|
||||||
m_GameOverTick = Server()->Tick();
|
m_GameOverTick = Server()->Tick();
|
||||||
m_SuddenDeath = 0;
|
m_SuddenDeath = 0;
|
||||||
|
@ -373,7 +376,7 @@ bool IsSeparator(char c) { return c == ';' || c == ' ' || c == ',' || c == '\t';
|
||||||
void IGameController::StartRound()
|
void IGameController::StartRound()
|
||||||
{
|
{
|
||||||
ResetGame();
|
ResetGame();
|
||||||
|
|
||||||
m_RoundStartTick = Server()->Tick();
|
m_RoundStartTick = Server()->Tick();
|
||||||
m_SuddenDeath = 0;
|
m_SuddenDeath = 0;
|
||||||
m_GameOverTick = -1;
|
m_GameOverTick = -1;
|
||||||
|
@ -403,11 +406,11 @@ void IGameController::CycleMap()
|
||||||
|
|
||||||
if(m_RoundCount < g_Config.m_SvRoundsPerMap-1)
|
if(m_RoundCount < g_Config.m_SvRoundsPerMap-1)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// handle maprotation
|
// handle maprotation
|
||||||
const char *pMapRotation = g_Config.m_SvMaprotation;
|
const char *pMapRotation = g_Config.m_SvMaprotation;
|
||||||
const char *pCurrentMap = g_Config.m_SvMap;
|
const char *pCurrentMap = g_Config.m_SvMap;
|
||||||
|
|
||||||
int CurrentMapLen = str_length(pCurrentMap);
|
int CurrentMapLen = str_length(pCurrentMap);
|
||||||
const char *pNextMap = pMapRotation;
|
const char *pNextMap = pMapRotation;
|
||||||
while(*pNextMap)
|
while(*pNextMap)
|
||||||
|
@ -415,25 +418,25 @@ void IGameController::CycleMap()
|
||||||
int WordLen = 0;
|
int WordLen = 0;
|
||||||
while(pNextMap[WordLen] && !IsSeparator(pNextMap[WordLen]))
|
while(pNextMap[WordLen] && !IsSeparator(pNextMap[WordLen]))
|
||||||
WordLen++;
|
WordLen++;
|
||||||
|
|
||||||
if(WordLen == CurrentMapLen && str_comp_num(pNextMap, pCurrentMap, CurrentMapLen) == 0)
|
if(WordLen == CurrentMapLen && str_comp_num(pNextMap, pCurrentMap, CurrentMapLen) == 0)
|
||||||
{
|
{
|
||||||
// map found
|
// map found
|
||||||
pNextMap += CurrentMapLen;
|
pNextMap += CurrentMapLen;
|
||||||
while(*pNextMap && IsSeparator(*pNextMap))
|
while(*pNextMap && IsSeparator(*pNextMap))
|
||||||
pNextMap++;
|
pNextMap++;
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
pNextMap++;
|
pNextMap++;
|
||||||
}
|
}
|
||||||
|
|
||||||
// restart rotation
|
// restart rotation
|
||||||
if(pNextMap[0] == 0)
|
if(pNextMap[0] == 0)
|
||||||
pNextMap = pMapRotation;
|
pNextMap = pMapRotation;
|
||||||
|
|
||||||
// cut out the next map
|
// cut out the next map
|
||||||
char Buf[512];
|
char Buf[512];
|
||||||
for(int i = 0; i < 512; i++)
|
for(int i = 0; i < 512; i++)
|
||||||
{
|
{
|
||||||
|
@ -444,14 +447,14 @@ void IGameController::CycleMap()
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// skip spaces
|
// skip spaces
|
||||||
int i = 0;
|
int i = 0;
|
||||||
while(IsSeparator(Buf[i]))
|
while(IsSeparator(Buf[i]))
|
||||||
i++;
|
i++;
|
||||||
|
|
||||||
m_RoundCount = 0;
|
m_RoundCount = 0;
|
||||||
|
|
||||||
dbg_msg("game", "rotating map to %s", &Buf[i]);
|
dbg_msg("game", "rotating map to %s", &Buf[i]);
|
||||||
str_copy(g_Config.m_SvMap, &Buf[i], sizeof(g_Config.m_SvMap));
|
str_copy(g_Config.m_SvMap, &Buf[i], sizeof(g_Config.m_SvMap));
|
||||||
}
|
}
|
||||||
|
@ -469,7 +472,7 @@ void IGameController::PostReset()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
void IGameController::OnPlayerInfoChange(class CPlayer *pP)
|
void IGameController::OnPlayerInfoChange(class CPlayer *pP)
|
||||||
{
|
{
|
||||||
const int aTeamColors[2] = {65387, 10223467};
|
const int aTeamColors[2] = {65387, 10223467};
|
||||||
|
@ -507,7 +510,7 @@ void IGameController::OnCharacterSpawn(class CCharacter *pChr)
|
||||||
{
|
{
|
||||||
// default health
|
// default health
|
||||||
pChr->IncreaseHealth(10);
|
pChr->IncreaseHealth(10);
|
||||||
|
|
||||||
// give default weapons
|
// give default weapons
|
||||||
//pChr->GiveAllWeapons();
|
//pChr->GiveAllWeapons();
|
||||||
pChr->GiveWeapon(WEAPON_HAMMER, -1);
|
pChr->GiveWeapon(WEAPON_HAMMER, -1);
|
||||||
|
@ -526,16 +529,16 @@ bool IGameController::IsFriendlyFire(int Cid1, int Cid2)
|
||||||
{
|
{
|
||||||
if(Cid1 == Cid2)
|
if(Cid1 == Cid2)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if(IsTeamplay())
|
if(IsTeamplay())
|
||||||
{
|
{
|
||||||
if(!GameServer()->m_apPlayers[Cid1] || !GameServer()->m_apPlayers[Cid2])
|
if(!GameServer()->m_apPlayers[Cid1] || !GameServer()->m_apPlayers[Cid2])
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if(GameServer()->m_apPlayers[Cid1]->GetTeam() == GameServer()->m_apPlayers[Cid2]->GetTeam())
|
if(GameServer()->m_apPlayers[Cid1]->GetTeam() == GameServer()->m_apPlayers[Cid2]->GetTeam())
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
@ -564,7 +567,7 @@ void IGameController::Tick()
|
||||||
if(!m_Warmup)
|
if(!m_Warmup)
|
||||||
StartRound();
|
StartRound();
|
||||||
}
|
}
|
||||||
|
|
||||||
if(m_GameOverTick != -1)
|
if(m_GameOverTick != -1)
|
||||||
{
|
{
|
||||||
// game over.. wait for restart
|
// game over.. wait for restart
|
||||||
|
@ -580,7 +583,7 @@ void IGameController::Tick()
|
||||||
if (IsTeamplay() && m_UnbalancedTick != -1 && Server()->Tick() > m_UnbalancedTick+g_Config.m_SvTeambalanceTime*Server()->TickSpeed()*60)
|
if (IsTeamplay() && m_UnbalancedTick != -1 && Server()->Tick() > m_UnbalancedTick+g_Config.m_SvTeambalanceTime*Server()->TickSpeed()*60)
|
||||||
{
|
{
|
||||||
dbg_msg("game", "Balancing teams");
|
dbg_msg("game", "Balancing teams");
|
||||||
|
|
||||||
int aT[2] = {0,0};
|
int aT[2] = {0,0};
|
||||||
float aTScore[2] = {0,0};
|
float aTScore[2] = {0,0};
|
||||||
float aPScore[MAX_CLIENTS] = {0.0f};
|
float aPScore[MAX_CLIENTS] = {0.0f};
|
||||||
|
@ -594,13 +597,13 @@ void IGameController::Tick()
|
||||||
aTScore[GameServer()->m_apPlayers[i]->GetTeam()] += aPScore[i];
|
aTScore[GameServer()->m_apPlayers[i]->GetTeam()] += aPScore[i];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// are teams unbalanced?
|
// are teams unbalanced?
|
||||||
if(absolute(aT[0]-aT[1]) >= 2)
|
if(absolute(aT[0]-aT[1]) >= 2)
|
||||||
{
|
{
|
||||||
int M = (aT[0] > aT[1]) ? 0 : 1;
|
int M = (aT[0] > aT[1]) ? 0 : 1;
|
||||||
int NumBalance = absolute(aT[0]-aT[1]) / 2;
|
int NumBalance = absolute(aT[0]-aT[1]) / 2;
|
||||||
|
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
CPlayer *pP = 0;
|
CPlayer *pP = 0;
|
||||||
|
@ -616,14 +619,14 @@ void IGameController::Tick()
|
||||||
PD = absolute((aTScore[M^1]+aPScore[i]) - (aTScore[M]-aPScore[i]));
|
PD = absolute((aTScore[M^1]+aPScore[i]) - (aTScore[M]-aPScore[i]));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// move the player to the other team
|
// move the player to the other team
|
||||||
pP->SetTeam(M^1);
|
pP->SetTeam(M^1);
|
||||||
|
|
||||||
pP->Respawn();
|
pP->Respawn();
|
||||||
pP->m_ForceBalanced = true;
|
pP->m_ForceBalanced = true;
|
||||||
} while (--NumBalance);
|
} while (--NumBalance);
|
||||||
|
|
||||||
m_ForceBalanced = true;
|
m_ForceBalanced = true;
|
||||||
}
|
}
|
||||||
m_UnbalancedTick = -1;
|
m_UnbalancedTick = -1;
|
||||||
|
@ -670,18 +673,18 @@ void IGameController::Snap(int SnappingClient)
|
||||||
pGameObj->m_Paused = GameServer()->m_World.m_Paused;
|
pGameObj->m_Paused = GameServer()->m_World.m_Paused;
|
||||||
pGameObj->m_GameOver = m_GameOverTick==-1?0:1;
|
pGameObj->m_GameOver = m_GameOverTick==-1?0:1;
|
||||||
pGameObj->m_SuddenDeath = m_SuddenDeath;
|
pGameObj->m_SuddenDeath = m_SuddenDeath;
|
||||||
|
|
||||||
//pGameObj->m_ScoreLimit = g_Config.m_SvScorelimit;
|
//pGameObj->m_ScoreLimit = g_Config.m_SvScorelimit;
|
||||||
//pGameObj->m_TimeLimit = g_Config.m_SvTimelimit;
|
//pGameObj->m_TimeLimit = g_Config.m_SvTimelimit;
|
||||||
pGameObj->m_RoundStartTick = m_RoundStartTick;
|
pGameObj->m_RoundStartTick = m_RoundStartTick;
|
||||||
pGameObj->m_Flags = m_GameFlags;
|
pGameObj->m_Flags = m_GameFlags;
|
||||||
|
|
||||||
pGameObj->m_Warmup = m_Warmup;
|
pGameObj->m_Warmup = m_Warmup;
|
||||||
|
|
||||||
pGameObj->m_RoundNum = /*(str_length(g_Config.m_SvMaprotation) && g_Config.m_SvRoundsPerMap) ? g_Config.m_SvRoundsPerMap :*/ 0;
|
pGameObj->m_RoundNum = /*(str_length(g_Config.m_SvMaprotation) && g_Config.m_SvRoundsPerMap) ? g_Config.m_SvRoundsPerMap :*/ 0;
|
||||||
pGameObj->m_RoundCurrent = m_RoundCount+1;
|
pGameObj->m_RoundCurrent = m_RoundCount+1;
|
||||||
|
|
||||||
|
|
||||||
if(SnappingClient == -1)
|
if(SnappingClient == -1)
|
||||||
{
|
{
|
||||||
// we are recording a demo, just set the scores
|
// we are recording a demo, just set the scores
|
||||||
|
@ -701,7 +704,7 @@ int IGameController::GetAutoTeam(int Notthisid)
|
||||||
// this will force the auto balancer to work overtime aswell
|
// this will force the auto balancer to work overtime aswell
|
||||||
if(g_Config.m_DbgStress)
|
if(g_Config.m_DbgStress)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
int aNumplayers[2] = {0,0};
|
int aNumplayers[2] = {0,0};
|
||||||
for(int i = 0; i < MAX_CLIENTS; i++)
|
for(int i = 0; i < MAX_CLIENTS; i++)
|
||||||
{
|
{
|
||||||
|
@ -715,7 +718,7 @@ int IGameController::GetAutoTeam(int Notthisid)
|
||||||
int Team = 0;
|
int Team = 0;
|
||||||
//if(IsTeamplay())
|
//if(IsTeamplay())
|
||||||
// Team = aNumplayers[0] > aNumplayers[1] ? 1 : 0;
|
// Team = aNumplayers[0] > aNumplayers[1] ? 1 : 0;
|
||||||
|
|
||||||
if(CanJoinTeam(Team, Notthisid))
|
if(CanJoinTeam(Team, Notthisid))
|
||||||
return Team;
|
return Team;
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -735,7 +738,7 @@ bool IGameController::CanJoinTeam(int Team, int Notthisid)
|
||||||
aNumplayers[GameServer()->m_apPlayers[i]->GetTeam()]++;
|
aNumplayers[GameServer()->m_apPlayers[i]->GetTeam()]++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return (aNumplayers[0] + aNumplayers[1]) < g_Config.m_SvMaxClients-g_Config.m_SvSpectatorSlots;
|
return (aNumplayers[0] + aNumplayers[1]) < g_Config.m_SvMaxClients-g_Config.m_SvSpectatorSlots;
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
|
@ -743,7 +746,7 @@ bool IGameController::CheckTeamBalance()
|
||||||
{
|
{
|
||||||
if(!IsTeamplay() || !g_Config.m_SvTeambalanceTime)
|
if(!IsTeamplay() || !g_Config.m_SvTeambalanceTime)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
int aT[2] = {0, 0};
|
int aT[2] = {0, 0};
|
||||||
for(int i = 0; i < MAX_CLIENTS; i++)
|
for(int i = 0; i < MAX_CLIENTS; i++)
|
||||||
{
|
{
|
||||||
|
@ -751,7 +754,7 @@ bool IGameController::CheckTeamBalance()
|
||||||
if(pP && pP->GetTeam() != -1)
|
if(pP && pP->GetTeam() != -1)
|
||||||
aT[pP->GetTeam()]++;
|
aT[pP->GetTeam()]++;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(absolute(aT[0]-aT[1]) >= 2)
|
if(absolute(aT[0]-aT[1]) >= 2)
|
||||||
{
|
{
|
||||||
dbg_msg("game", "Team is NOT balanced (red=%d blue=%d)", aT[0], aT[1]);
|
dbg_msg("game", "Team is NOT balanced (red=%d blue=%d)", aT[0], aT[1]);
|
||||||
|
@ -770,22 +773,22 @@ bool IGameController::CheckTeamBalance()
|
||||||
bool IGameController::CanChangeTeam(CPlayer *pPlayer, int JoinTeam)
|
bool IGameController::CanChangeTeam(CPlayer *pPlayer, int JoinTeam)
|
||||||
{
|
{
|
||||||
int aT[2] = {0, 0};
|
int aT[2] = {0, 0};
|
||||||
|
|
||||||
if (!IsTeamplay() || JoinTeam == -1 || !g_Config.m_SvTeambalanceTime)
|
if (!IsTeamplay() || JoinTeam == -1 || !g_Config.m_SvTeambalanceTime)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
for(int i = 0; i < MAX_CLIENTS; i++)
|
for(int i = 0; i < MAX_CLIENTS; i++)
|
||||||
{
|
{
|
||||||
CPlayer *pP = GameServer()->m_apPlayers[i];
|
CPlayer *pP = GameServer()->m_apPlayers[i];
|
||||||
if(pP && pP->GetTeam() != -1)
|
if(pP && pP->GetTeam() != -1)
|
||||||
aT[pP->GetTeam()]++;
|
aT[pP->GetTeam()]++;
|
||||||
}
|
}
|
||||||
|
|
||||||
// simulate what would happen if changed team
|
// simulate what would happen if changed team
|
||||||
aT[JoinTeam]++;
|
aT[JoinTeam]++;
|
||||||
if (pPlayer->GetTeam() != -1)
|
if (pPlayer->GetTeam() != -1)
|
||||||
aT[JoinTeam^1]--;
|
aT[JoinTeam^1]--;
|
||||||
|
|
||||||
// there is a player-difference of at least 2
|
// there is a player-difference of at least 2
|
||||||
if(absolute(aT[0]-aT[1]) >= 2)
|
if(absolute(aT[0]-aT[1]) >= 2)
|
||||||
{
|
{
|
||||||
|
@ -819,7 +822,7 @@ void IGameController::DoPlayerScoreWincheck()
|
||||||
TopscoreCount++;
|
TopscoreCount++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// check score win condition
|
// check score win condition
|
||||||
if((g_Config.m_SvScorelimit > 0 && Topscore >= g_Config.m_SvScorelimit) ||
|
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))
|
(g_Config.m_SvTimelimit > 0 && (Server()->Tick()-m_RoundStartTick) >= g_Config.m_SvTimelimit*Server()->TickSpeed()*60))
|
||||||
|
@ -858,4 +861,4 @@ int IGameController::ClampTeam(int Team)
|
||||||
//if(IsTeamplay())
|
//if(IsTeamplay())
|
||||||
// return Team&1;
|
// return Team&1;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -101,9 +101,9 @@ public:
|
||||||
Returns:
|
Returns:
|
||||||
bool?
|
bool?
|
||||||
*/
|
*/
|
||||||
virtual bool OnEntity(int Index, vec2 Pos);
|
virtual bool OnEntity(int Index, vec2 Pos, bool Front);
|
||||||
|
|
||||||
virtual void Connector(vec2 Pos, CDoor* Door);
|
virtual void Connector(vec2 Pos, CDoor* Door, bool Front);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Function: on_CCharacter_spawn
|
Function: on_CCharacter_spawn
|
||||||
|
|
|
@ -10,7 +10,7 @@ CGameWorld::CGameWorld()
|
||||||
{
|
{
|
||||||
m_pGameServer = 0x0;
|
m_pGameServer = 0x0;
|
||||||
m_pServer = 0x0;
|
m_pServer = 0x0;
|
||||||
|
|
||||||
m_Paused = false;
|
m_Paused = false;
|
||||||
m_ResetRequested = false;
|
m_ResetRequested = false;
|
||||||
m_pFirstEntity = 0x0;
|
m_pFirstEntity = 0x0;
|
||||||
|
@ -159,7 +159,7 @@ void CGameWorld::Tick()
|
||||||
// update all objects
|
// update all objects
|
||||||
for(CEntity *pEnt = m_pFirstEntity; pEnt; pEnt = pEnt->m_pNextEntity)
|
for(CEntity *pEnt = m_pFirstEntity; pEnt; pEnt = pEnt->m_pNextEntity)
|
||||||
pEnt->Tick();
|
pEnt->Tick();
|
||||||
|
|
||||||
for(CEntity *pEnt = m_pFirstEntity; pEnt; pEnt = pEnt->m_pNextEntity)
|
for(CEntity *pEnt = m_pFirstEntity; pEnt; pEnt = pEnt->m_pNextEntity)
|
||||||
pEnt->TickDefered();
|
pEnt->TickDefered();
|
||||||
}
|
}
|
||||||
|
@ -181,7 +181,7 @@ CCharacter *CGameWorld::IntersectCharacter(vec2 Pos0, vec2 Pos1, float Radius, v
|
||||||
{
|
{
|
||||||
if(p == pNotThis)
|
if(p == pNotThis)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
vec2 IntersectPos = closest_point_on_line(Pos0, Pos1, p->m_Pos);
|
vec2 IntersectPos = closest_point_on_line(Pos0, Pos1, p->m_Pos);
|
||||||
float Len = distance(p->m_Pos, IntersectPos);
|
float Len = distance(p->m_Pos, IntersectPos);
|
||||||
if(Len < p->m_ProximityRadius+Radius)
|
if(Len < p->m_ProximityRadius+Radius)
|
||||||
|
@ -194,7 +194,7 @@ CCharacter *CGameWorld::IntersectCharacter(vec2 Pos0, vec2 Pos1, float Radius, v
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return pClosest;
|
return pClosest;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -204,13 +204,13 @@ CCharacter *CGameWorld::ClosestCharacter(vec2 Pos, float Radius, CEntity *pNotTh
|
||||||
// Find other players
|
// Find other players
|
||||||
float ClosestRange = Radius*2;
|
float ClosestRange = Radius*2;
|
||||||
CCharacter *pClosest = 0;
|
CCharacter *pClosest = 0;
|
||||||
|
|
||||||
CCharacter *p = (CCharacter *)GameServer()->m_World.FindFirst(NETOBJTYPE_CHARACTER);
|
CCharacter *p = (CCharacter *)GameServer()->m_World.FindFirst(NETOBJTYPE_CHARACTER);
|
||||||
for(; p; p = (CCharacter *)p->TypeNext())
|
for(; p; p = (CCharacter *)p->TypeNext())
|
||||||
{
|
{
|
||||||
if(p == pNotThis)
|
if(p == pNotThis)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
float Len = distance(Pos, p->m_Pos);
|
float Len = distance(Pos, p->m_Pos);
|
||||||
if(Len < p->m_ProximityRadius+Radius)
|
if(Len < p->m_ProximityRadius+Radius)
|
||||||
{
|
{
|
||||||
|
@ -221,6 +221,6 @@ CCharacter *CGameWorld::ClosestCharacter(vec2 Pos, float Radius, CEntity *pNotTh
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return pClosest;
|
return pClosest;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue