feat: add server tower place detection
This commit is contained in:
@@ -144,7 +144,16 @@ void ServerConnexion::initConnection() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void ServerConnexion::HandlePacket(protocol::PlaceTowerPacket* packet) {
|
void ServerConnexion::HandlePacket(protocol::PlaceTowerPacket* packet) {
|
||||||
// process packet
|
game::TowerType towerType = packet->getTowerType();
|
||||||
|
const game::TowerInfo& towerInfo = game::getTowerInfo(towerType);
|
||||||
|
const game::World* world = m_Server->getGame().getWorld();
|
||||||
|
if (towerInfo.isBigTower()) {
|
||||||
|
if (!world->CanPlaceBigTower({ packet->getTowerX(), packet->getTowerY() }))
|
||||||
|
return;
|
||||||
|
} else {
|
||||||
|
if (!world->CanPlaceLittleTower({ packet->getTowerX(), packet->getTowerY() }))
|
||||||
|
return;
|
||||||
|
}
|
||||||
protocol::WorldAddTowerPacket addTowerPacket(packet->getTowerX(), packet->getTowerY(), packet->getTowerType(), m_ID);
|
protocol::WorldAddTowerPacket addTowerPacket(packet->getTowerX(), packet->getTowerY(), packet->getTowerType(), m_ID);
|
||||||
m_Server->broadcastPacket(&addTowerPacket);
|
m_Server->broadcastPacket(&addTowerPacket);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user