mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-10 10:08:18 +00:00
parent
55098cd313
commit
60e6025e7a
|
@ -358,15 +358,14 @@ void CGameContext::ConToTeleporter(IConsole::IResult *pResult, void *pUserData)
|
||||||
{
|
{
|
||||||
CGameContext *pSelf = (CGameContext *)pUserData;
|
CGameContext *pSelf = (CGameContext *)pUserData;
|
||||||
unsigned int TeleTo = pResult->GetInteger(0);
|
unsigned int TeleTo = pResult->GetInteger(0);
|
||||||
CGameControllerDDRace *pGameControllerDDRace = (CGameControllerDDRace *)pSelf->m_pController;
|
|
||||||
|
|
||||||
if(!pGameControllerDDRace->m_TeleOuts[TeleTo - 1].empty())
|
if(!pSelf->m_pController->m_TeleOuts[TeleTo - 1].empty())
|
||||||
{
|
{
|
||||||
CCharacter *pChr = pSelf->GetPlayerChar(pResult->m_ClientID);
|
CCharacter *pChr = pSelf->GetPlayerChar(pResult->m_ClientID);
|
||||||
if(pChr)
|
if(pChr)
|
||||||
{
|
{
|
||||||
int TeleOut = pSelf->m_World.m_Core.RandomOr0(pGameControllerDDRace->m_TeleOuts[TeleTo - 1].size());
|
int TeleOut = pSelf->m_World.m_Core.RandomOr0(pSelf->m_pController->m_TeleOuts[TeleTo - 1].size());
|
||||||
pSelf->Teleport(pChr, pGameControllerDDRace->m_TeleOuts[TeleTo - 1][TeleOut]);
|
pSelf->Teleport(pChr, pSelf->m_pController->m_TeleOuts[TeleTo - 1][TeleOut]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -375,15 +374,14 @@ void CGameContext::ConToCheckTeleporter(IConsole::IResult *pResult, void *pUserD
|
||||||
{
|
{
|
||||||
CGameContext *pSelf = (CGameContext *)pUserData;
|
CGameContext *pSelf = (CGameContext *)pUserData;
|
||||||
unsigned int TeleTo = pResult->GetInteger(0);
|
unsigned int TeleTo = pResult->GetInteger(0);
|
||||||
CGameControllerDDRace *pGameControllerDDRace = (CGameControllerDDRace *)pSelf->m_pController;
|
|
||||||
|
|
||||||
if(!pGameControllerDDRace->m_TeleCheckOuts[TeleTo - 1].empty())
|
if(!pSelf->m_pController->m_TeleCheckOuts[TeleTo - 1].empty())
|
||||||
{
|
{
|
||||||
CCharacter *pChr = pSelf->GetPlayerChar(pResult->m_ClientID);
|
CCharacter *pChr = pSelf->GetPlayerChar(pResult->m_ClientID);
|
||||||
if(pChr)
|
if(pChr)
|
||||||
{
|
{
|
||||||
int TeleOut = pSelf->m_World.m_Core.RandomOr0(pGameControllerDDRace->m_TeleCheckOuts[TeleTo - 1].size());
|
int TeleOut = pSelf->m_World.m_Core.RandomOr0(pSelf->m_pController->m_TeleCheckOuts[TeleTo - 1].size());
|
||||||
pSelf->Teleport(pChr, pGameControllerDDRace->m_TeleCheckOuts[TeleTo - 1][TeleOut]);
|
pSelf->Teleport(pChr, pSelf->m_pController->m_TeleCheckOuts[TeleTo - 1][TeleOut]);
|
||||||
pChr->m_TeleCheckpoint = TeleTo;
|
pChr->m_TeleCheckpoint = TeleTo;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -166,11 +166,10 @@ void CLaser::DoBounce()
|
||||||
}
|
}
|
||||||
m_ZeroEnergyBounceInLastTick = Distance == 0.0f;
|
m_ZeroEnergyBounceInLastTick = Distance == 0.0f;
|
||||||
|
|
||||||
CGameControllerDDRace *pControllerDDRace = (CGameControllerDDRace *)GameServer()->m_pController;
|
if(Res == TILE_TELEINWEAPON && !GameServer()->m_pController->m_TeleOuts[z - 1].empty())
|
||||||
if(Res == TILE_TELEINWEAPON && !pControllerDDRace->m_TeleOuts[z - 1].empty())
|
|
||||||
{
|
{
|
||||||
int TeleOut = GameServer()->m_World.m_Core.RandomOr0(pControllerDDRace->m_TeleOuts[z - 1].size());
|
int TeleOut = GameServer()->m_World.m_Core.RandomOr0(GameServer()->m_pController->m_TeleOuts[z - 1].size());
|
||||||
m_TelePos = pControllerDDRace->m_TeleOuts[z - 1][TeleOut];
|
m_TelePos = GameServer()->m_pController->m_TeleOuts[z - 1][TeleOut];
|
||||||
m_WasTele = true;
|
m_WasTele = true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
|
@ -276,11 +276,10 @@ void CProjectile::Tick()
|
||||||
z = GameServer()->Collision()->IsTeleport(x);
|
z = GameServer()->Collision()->IsTeleport(x);
|
||||||
else
|
else
|
||||||
z = GameServer()->Collision()->IsTeleportWeapon(x);
|
z = GameServer()->Collision()->IsTeleportWeapon(x);
|
||||||
CGameControllerDDRace *pControllerDDRace = (CGameControllerDDRace *)GameServer()->m_pController;
|
if(z && !GameServer()->m_pController->m_TeleOuts[z - 1].empty())
|
||||||
if(z && !pControllerDDRace->m_TeleOuts[z - 1].empty())
|
|
||||||
{
|
{
|
||||||
int TeleOut = GameServer()->m_World.m_Core.RandomOr0(pControllerDDRace->m_TeleOuts[z - 1].size());
|
int TeleOut = GameServer()->m_World.m_Core.RandomOr0(GameServer()->m_pController->m_TeleOuts[z - 1].size());
|
||||||
m_Pos = pControllerDDRace->m_TeleOuts[z - 1][TeleOut];
|
m_Pos = GameServer()->m_pController->m_TeleOuts[z - 1][TeleOut];
|
||||||
m_StartTick = Server()->Tick();
|
m_StartTick = Server()->Tick();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -38,6 +38,8 @@ IGameController::IGameController(class CGameContext *pGameServer)
|
||||||
m_ForceBalanced = false;
|
m_ForceBalanced = false;
|
||||||
|
|
||||||
m_CurrentRecord = 0;
|
m_CurrentRecord = 0;
|
||||||
|
|
||||||
|
InitTeleporter();
|
||||||
}
|
}
|
||||||
|
|
||||||
IGameController::~IGameController() = default;
|
IGameController::~IGameController() = default;
|
||||||
|
@ -484,6 +486,8 @@ void IGameController::OnCharacterSpawn(class CCharacter *pChr)
|
||||||
// give default weapons
|
// give default weapons
|
||||||
pChr->GiveWeapon(WEAPON_HAMMER);
|
pChr->GiveWeapon(WEAPON_HAMMER);
|
||||||
pChr->GiveWeapon(WEAPON_GUN);
|
pChr->GiveWeapon(WEAPON_GUN);
|
||||||
|
|
||||||
|
pChr->SetTeleports(&m_TeleOuts, &m_TeleCheckOuts);
|
||||||
}
|
}
|
||||||
|
|
||||||
void IGameController::HandleCharacterTiles(CCharacter *pChr, int MapIndex)
|
void IGameController::HandleCharacterTiles(CCharacter *pChr, int MapIndex)
|
||||||
|
@ -727,6 +731,31 @@ CClientMask IGameController::GetMaskForPlayerWorldEvent(int Asker, int ExceptID)
|
||||||
return CClientMask().set().reset(ExceptID);
|
return CClientMask().set().reset(ExceptID);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void IGameController::InitTeleporter()
|
||||||
|
{
|
||||||
|
if(!GameServer()->Collision()->Layers()->TeleLayer())
|
||||||
|
return;
|
||||||
|
int Width = GameServer()->Collision()->Layers()->TeleLayer()->m_Width;
|
||||||
|
int Height = GameServer()->Collision()->Layers()->TeleLayer()->m_Height;
|
||||||
|
|
||||||
|
for(int i = 0; i < Width * Height; i++)
|
||||||
|
{
|
||||||
|
int Number = GameServer()->Collision()->TeleLayer()[i].m_Number;
|
||||||
|
int Type = GameServer()->Collision()->TeleLayer()[i].m_Type;
|
||||||
|
if(Number > 0)
|
||||||
|
{
|
||||||
|
if(Type == TILE_TELEOUT)
|
||||||
|
{
|
||||||
|
m_TeleOuts[Number - 1].emplace_back(i % Width * 32.0f + 16.0f, i / Width * 32.0f + 16.0f);
|
||||||
|
}
|
||||||
|
else if(Type == TILE_TELECHECKOUT)
|
||||||
|
{
|
||||||
|
m_TeleCheckOuts[Number - 1].emplace_back(i % Width * 32.0f + 16.0f, i / Width * 32.0f + 16.0f);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void IGameController::DoTeamChange(CPlayer *pPlayer, int Team, bool DoChatMsg)
|
void IGameController::DoTeamChange(CPlayer *pPlayer, int Team, bool DoChatMsg)
|
||||||
{
|
{
|
||||||
Team = ClampTeam(Team);
|
Team = ClampTeam(Team);
|
||||||
|
|
|
@ -7,6 +7,7 @@
|
||||||
#include <engine/map.h>
|
#include <engine/map.h>
|
||||||
#include <engine/shared/protocol.h>
|
#include <engine/shared/protocol.h>
|
||||||
|
|
||||||
|
#include <map>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -143,10 +144,13 @@ public:
|
||||||
int ClampTeam(int Team);
|
int ClampTeam(int Team);
|
||||||
|
|
||||||
virtual CClientMask GetMaskForPlayerWorldEvent(int Asker, int ExceptID = -1);
|
virtual CClientMask GetMaskForPlayerWorldEvent(int Asker, int ExceptID = -1);
|
||||||
|
virtual void InitTeleporter();
|
||||||
|
|
||||||
// DDRace
|
// DDRace
|
||||||
|
|
||||||
float m_CurrentRecord;
|
float m_CurrentRecord;
|
||||||
|
std::map<int, std::vector<vec2>> m_TeleOuts;
|
||||||
|
std::map<int, std::vector<vec2>> m_TeleCheckOuts;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -18,8 +18,6 @@ CGameControllerDDRace::CGameControllerDDRace(class CGameContext *pGameServer) :
|
||||||
IGameController(pGameServer), m_Teams(pGameServer), m_pLoadBestTimeResult(nullptr)
|
IGameController(pGameServer), m_Teams(pGameServer), m_pLoadBestTimeResult(nullptr)
|
||||||
{
|
{
|
||||||
m_pGameType = g_Config.m_SvTestingCommands ? TEST_TYPE_NAME : GAME_TYPE_NAME;
|
m_pGameType = g_Config.m_SvTestingCommands ? TEST_TYPE_NAME : GAME_TYPE_NAME;
|
||||||
|
|
||||||
InitTeleporter();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
CGameControllerDDRace::~CGameControllerDDRace() = default;
|
CGameControllerDDRace::~CGameControllerDDRace() = default;
|
||||||
|
@ -33,7 +31,6 @@ void CGameControllerDDRace::OnCharacterSpawn(CCharacter *pChr)
|
||||||
{
|
{
|
||||||
IGameController::OnCharacterSpawn(pChr);
|
IGameController::OnCharacterSpawn(pChr);
|
||||||
pChr->SetTeams(&m_Teams);
|
pChr->SetTeams(&m_Teams);
|
||||||
pChr->SetTeleports(&m_TeleOuts, &m_TeleCheckOuts);
|
|
||||||
m_Teams.OnCharacterSpawn(pChr->GetPlayer()->GetCID());
|
m_Teams.OnCharacterSpawn(pChr->GetPlayer()->GetCID());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -219,31 +216,6 @@ CClientMask CGameControllerDDRace::GetMaskForPlayerWorldEvent(int Asker, int Exc
|
||||||
return m_Teams.TeamMask(GetPlayerTeam(Asker), ExceptID, Asker);
|
return m_Teams.TeamMask(GetPlayerTeam(Asker), ExceptID, Asker);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CGameControllerDDRace::InitTeleporter()
|
|
||||||
{
|
|
||||||
if(!GameServer()->Collision()->Layers()->TeleLayer())
|
|
||||||
return;
|
|
||||||
int Width = GameServer()->Collision()->Layers()->TeleLayer()->m_Width;
|
|
||||||
int Height = GameServer()->Collision()->Layers()->TeleLayer()->m_Height;
|
|
||||||
|
|
||||||
for(int i = 0; i < Width * Height; i++)
|
|
||||||
{
|
|
||||||
int Number = GameServer()->Collision()->TeleLayer()[i].m_Number;
|
|
||||||
int Type = GameServer()->Collision()->TeleLayer()[i].m_Type;
|
|
||||||
if(Number > 0)
|
|
||||||
{
|
|
||||||
if(Type == TILE_TELEOUT)
|
|
||||||
{
|
|
||||||
m_TeleOuts[Number - 1].emplace_back(i % Width * 32.0f + 16.0f, i / Width * 32.0f + 16.0f);
|
|
||||||
}
|
|
||||||
else if(Type == TILE_TELECHECKOUT)
|
|
||||||
{
|
|
||||||
m_TeleCheckOuts[Number - 1].emplace_back(i % Width * 32.0f + 16.0f, i / Width * 32.0f + 16.0f);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
int CGameControllerDDRace::GetPlayerTeam(int ClientID) const
|
int CGameControllerDDRace::GetPlayerTeam(int ClientID) const
|
||||||
{
|
{
|
||||||
return m_Teams.m_Core.Team(ClientID);
|
return m_Teams.m_Core.Team(ClientID);
|
||||||
|
|
|
@ -5,9 +5,6 @@
|
||||||
#include <game/server/gamecontroller.h>
|
#include <game/server/gamecontroller.h>
|
||||||
#include <game/server/teams.h>
|
#include <game/server/teams.h>
|
||||||
|
|
||||||
#include <map>
|
|
||||||
#include <vector>
|
|
||||||
|
|
||||||
struct CScoreLoadBestTimeResult;
|
struct CScoreLoadBestTimeResult;
|
||||||
class CGameControllerDDRace : public IGameController
|
class CGameControllerDDRace : public IGameController
|
||||||
{
|
{
|
||||||
|
@ -31,15 +28,10 @@ public:
|
||||||
|
|
||||||
CClientMask GetMaskForPlayerWorldEvent(int Asker, int ExceptID = -1) override;
|
CClientMask GetMaskForPlayerWorldEvent(int Asker, int ExceptID = -1) override;
|
||||||
|
|
||||||
void InitTeleporter();
|
|
||||||
|
|
||||||
int GetPlayerTeam(int ClientID) const;
|
int GetPlayerTeam(int ClientID) const;
|
||||||
|
|
||||||
CGameTeams m_Teams;
|
CGameTeams m_Teams;
|
||||||
|
|
||||||
std::map<int, std::vector<vec2>> m_TeleOuts;
|
|
||||||
std::map<int, std::vector<vec2>> m_TeleCheckOuts;
|
|
||||||
|
|
||||||
std::shared_ptr<CScoreLoadBestTimeResult> m_pLoadBestTimeResult;
|
std::shared_ptr<CScoreLoadBestTimeResult> m_pLoadBestTimeResult;
|
||||||
};
|
};
|
||||||
#endif // GAME_SERVER_GAMEMODES_DDRACE_H
|
#endif // GAME_SERVER_GAMEMODES_DDRACE_H
|
||||||
|
|
Loading…
Reference in a new issue