| 136 | } |
| 137 | |
| 138 | bool TrapFactory::buildTrapDefault(GameMap* gameMap, Trap* trap, Seat* seat, const std::vector<Tile*>& tiles) const |
| 139 | { |
| 140 | if(tiles.empty()) |
| 141 | return false; |
| 142 | |
| 143 | trap->setupTrap(gameMap->nextUniqueNameTrap(trap->getType()), seat, tiles); |
| 144 | trap->addToGameMap(); |
| 145 | trap->createMesh(); |
| 146 | |
| 147 | if((seat->getPlayer() != nullptr) && |
| 148 | (seat->getPlayer()->getIsHuman())) |
| 149 | { |
| 150 | // We notify the clients with vision of the changed tiles. Note that we need |
| 151 | // to calculate per seat since they could have vision on different parts of the building |
| 152 | std::map<Seat*,std::vector<Tile*>> tilesPerSeat; |
| 153 | const std::vector<Seat*>& seats = gameMap->getSeats(); |
| 154 | for(Seat* tmpSeat : seats) |
| 155 | { |
| 156 | if(tmpSeat->getPlayer() == nullptr) |
| 157 | continue; |
| 158 | if(!tmpSeat->getPlayer()->getIsHuman()) |
| 159 | continue; |
| 160 | |
| 161 | for(Tile* tile : tiles) |
| 162 | { |
| 163 | if(!tmpSeat->hasVisionOnTile(tile)) |
| 164 | continue; |
| 165 | |
| 166 | tile->changeNotifiedForSeat(tmpSeat); |
| 167 | tilesPerSeat[tmpSeat].push_back(tile); |
| 168 | } |
| 169 | } |
| 170 | |
| 171 | for(const std::pair<Seat* const,std::vector<Tile*>>& p : tilesPerSeat) |
| 172 | { |
| 173 | uint32_t nbTiles = p.second.size(); |
| 174 | ServerNotification serverNotification( |
| 175 | ServerNotificationType::refreshTiles, p.first->getPlayer()); |
| 176 | serverNotification.mPacket << nbTiles; |
| 177 | for(Tile* tile : p.second) |
| 178 | { |
| 179 | gameMap->tileToPacket(serverNotification.mPacket, tile); |
| 180 | p.first->updateTileStateForSeat(tile, false); |
| 181 | tile->exportToPacketForUpdate(serverNotification.mPacket, p.first); |
| 182 | } |
| 183 | ODServer::getSingleton().sendAsyncMsg(serverNotification); |
| 184 | } |
| 185 | } |
| 186 | |
| 187 | trap->updateActiveSpots(); |
| 188 | |
| 189 | return true; |
| 190 | } |
| 191 | |
| 192 | void TrapFactory::checkBuildTrapDefaultEditor(GameMap* gameMap, TrapType type, const InputManager& inputManager, InputCommand& inputCommand) const |
| 193 | { |
nothing calls this directly
no test coverage detected