fix login crash
This commit is contained in:
@@ -2,6 +2,9 @@
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
#define SAFE_CHECK(expr) if(!(expr)) return
|
||||
|
||||
|
||||
namespace td {
|
||||
|
||||
static constexpr float PI = 3.141592653f;
|
||||
|
||||
@@ -77,6 +77,9 @@ void ClientGame::HandlePacket(const protocol::PlayerListPacket* packet) {
|
||||
|
||||
void ClientGame::HandlePacket(const protocol::UpdatePlayerTeamPacket* packet) {
|
||||
game::Player* player = &m_Players[packet->GetPlayerID()];
|
||||
|
||||
SAFE_CHECK(player);
|
||||
|
||||
if (player->GetTeamColor() == game::TeamColor::None) { //join a team
|
||||
GetTeam(packet->GetSelectedTeam()).AddPlayer(player);
|
||||
} else if (packet->GetSelectedTeam() == game::TeamColor::None) { // leave a team
|
||||
@@ -101,10 +104,14 @@ void ClientGame::HandlePacket(const protocol::UpdateLobbyTimePacket* packet) {
|
||||
}
|
||||
|
||||
void ClientGame::HandlePacket(const protocol::UpdateMoneyPacket* packet) {
|
||||
SAFE_CHECK(m_Player);
|
||||
|
||||
m_Player->SetGold(packet->GetGold());
|
||||
}
|
||||
|
||||
void ClientGame::HandlePacket(const protocol::UpdateExpPacket* packet) {
|
||||
SAFE_CHECK(m_Player);
|
||||
|
||||
m_Player->SetExp(packet->GetExp());
|
||||
}
|
||||
|
||||
|
||||
@@ -28,8 +28,6 @@
|
||||
|
||||
#define KEEP_ALIVE_TIMEOUT 10 * 1000 // 10s
|
||||
|
||||
#define SAFE_CHECK(expr) if(!(expr)) return
|
||||
|
||||
namespace td {
|
||||
namespace server {
|
||||
|
||||
|
||||
Reference in New Issue
Block a user