feat: add server tower place detection

This commit is contained in:
2021-09-19 18:32:47 +02:00
parent 37f76a3e78
commit fee1ab6638

View File

@@ -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);
} }