| 211 | } |
| 212 | |
| 213 | void GameEntity::fireDropEntity(Player* playerPicking, Tile* tile) |
| 214 | { |
| 215 | // If the player is a human, we send an asynchronous message to be as reactive as |
| 216 | // possible. If it is an AI, we queue the message because it might have been created |
| 217 | // during this turn (and, thus, not exist on client side) |
| 218 | int seatId = playerPicking->getSeat()->getId(); |
| 219 | for(Seat* seat : getGameMap()->getSeats()) |
| 220 | { |
| 221 | if(seat->getPlayer() == nullptr) |
| 222 | continue; |
| 223 | if(!seat->getPlayer()->getIsHuman()) |
| 224 | continue; |
| 225 | if(!seat->hasVisionOnTile(tile)) |
| 226 | continue; |
| 227 | |
| 228 | // For players with vision on the tile where the entity is dropped, we send an add message |
| 229 | if(seat->getPlayer() != playerPicking) |
| 230 | { |
| 231 | // Because the entity is dropped, it is not on the map for the other players so no need |
| 232 | // to check |
| 233 | mSeatsWithVisionNotified.push_back(seat); |
| 234 | fireAddEntity(seat, false); |
| 235 | continue; |
| 236 | } |
| 237 | |
| 238 | // If the creature was dropped by a human, we send an async message |
| 239 | if(playerPicking->getIsHuman()) |
| 240 | { |
| 241 | ServerNotification serverNotification( |
| 242 | ServerNotificationType::entityDropped, seat->getPlayer()); |
| 243 | serverNotification.mPacket << seatId; |
| 244 | getGameMap()->tileToPacket(serverNotification.mPacket, tile); |
| 245 | ODServer::getSingleton().sendAsyncMsg(serverNotification); |
| 246 | } |
| 247 | else |
| 248 | { |
| 249 | ServerNotification* serverNotification = new ServerNotification( |
| 250 | ServerNotificationType::entityDropped, seat->getPlayer()); |
| 251 | serverNotification->mPacket << seatId; |
| 252 | getGameMap()->tileToPacket(serverNotification->mPacket, tile); |
| 253 | ODServer::getSingleton().queueServerNotification(serverNotification); |
| 254 | } |
| 255 | } |
| 256 | |
| 257 | for(auto it = mGameEntityListeners.begin(); it != mGameEntityListeners.end();) |
| 258 | { |
| 259 | GameEntityListener* listener = *it; |
| 260 | if(listener->notifyDropped(this)) |
| 261 | { |
| 262 | ++it; |
| 263 | continue; |
| 264 | } |
| 265 | |
| 266 | it = mGameEntityListeners.erase(it); |
| 267 | } |
| 268 | } |
| 269 | |
| 270 | void GameEntity::notifySeatsWithVision(const std::vector<Seat*>& seats) |
no test coverage detected