send map when arriving late

This commit is contained in:
2025-08-22 12:24:58 +02:00
parent 688b6e93ea
commit 5b6254c690
12 changed files with 52 additions and 16 deletions

View File

@@ -7,10 +7,12 @@
namespace td {
namespace server {
GameState::GameState(Server& a_Server, const std::shared_ptr<game::World>& a_World) : ServerState(a_Server), m_World(a_World), m_Simulation(*m_World, STEP_TIME), m_Time(0) {
GameState::GameState(Server& a_Server, const std::shared_ptr<game::World>& a_World) :
ServerState(a_Server), m_World(a_World), m_Simulation(*m_World, STEP_TIME), m_Time(0) {
std::cout << "[Server] Switched to Game state !\n";
BroadcastPacket(a_World->GetPacketHeader());
BroadcastPacket(a_World->GetPacketData());
BroadcastPacket(protocol::packets::BeginGamePacket());
BroadcastPacket(m_Simulation.MakePacket());
}
@@ -30,5 +32,16 @@ void GameState::Update(float a_Delta) {
}
}
void GameState::OnPlayerJoin(PlayerID a_Id, const td::PlayerInfo& a_Info) {
SendPacket(a_Id, m_World->GetPacketHeader());
SendPacket(a_Id, m_World->GetPacketData());
// TODO: real teams
std::vector<PlayerInfo> team;
std::vector<protocol::LockStep> locksteps = m_Simulation.GetFirstLocksteps();
BroadcastPacket(protocol::packets::BeginGamePacket(team, team, locksteps));
}
} // namespace server
} // namespace td