refactor: use of unique_ptr instead of new

This commit is contained in:
2021-11-06 13:02:53 +01:00
parent 26290d8332
commit 6825a6327f
19 changed files with 136 additions and 134 deletions

View File

@@ -12,20 +12,20 @@ WorldClient::WorldClient(ClientGame* game) : game::World(game), protocol::Packet
GetDispatcher()->RegisterHandler(protocol::PacketType::SpawnMob, this);
}
void WorldClient::HandlePacket(protocol::WorldBeginDataPacket* packet) {
void WorldClient::HandlePacket(const protocol::WorldBeginDataPacket* packet) {
loadMap(packet);
}
void WorldClient::HandlePacket(protocol::WorldDataPacket* packet) {
void WorldClient::HandlePacket(const protocol::WorldDataPacket* packet) {
loadMap(packet);
}
void WorldClient::HandlePacket(protocol::SpawnMobPacket* packet) {
void WorldClient::HandlePacket(const protocol::SpawnMobPacket* packet) {
spawnMobAt(packet->getMobID(), packet->getMobType(), packet->getMobLevel(), packet->getSender(),
packet->getMobX(), packet->getMobY(), packet->getMobDirection());
}
void WorldClient::HandlePacket(protocol::UpgradeTowerPacket* packet) {
void WorldClient::HandlePacket(const protocol::UpgradeTowerPacket* packet) {
game::TowerPtr tower = getTowerById(packet->getTowerID());
if(tower == nullptr) return; // this should not happen but who knows ?
tower->upgrade(packet->getTowerLevel().getLevel(), packet->getTowerLevel().getPath());