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