MCPcopy Create free account
hub / github.com/OpenDungeons/OpenDungeons / checkBuildTrapDefaultEditor

Method checkBuildTrapDefaultEditor

source/traps/TrapManager.cpp:192–230  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

190}
191
192void TrapFactory::checkBuildTrapDefaultEditor(GameMap* gameMap, TrapType type, const InputManager& inputManager, InputCommand& inputCommand) const
193{
194 std::string txt = TrapManager::getTrapReadableName(type);
195 inputCommand.displayText(Ogre::ColourValue::White, txt);
196 if(inputManager.mCommandState == InputCommandState::infoOnly)
197 {
198 inputCommand.selectSquaredTiles(inputManager.mXPos, inputManager.mYPos, inputManager.mXPos,
199 inputManager.mYPos);
200 return;
201 }
202
203 std::vector<Tile*> tiles = gameMap->rectangularRegion(inputManager.mXPos,
204 inputManager.mYPos, inputManager.mLStartDragX, inputManager.mLStartDragY);
205
206 std::vector<Tile*> buildableTiles;
207 for(Tile* tile : tiles)
208 {
209 // We accept any tile if there is no building
210 if(tile->getIsBuilding())
211 continue;
212
213 buildableTiles.push_back(tile);
214 }
215 if(inputManager.mCommandState == InputCommandState::building)
216 {
217 inputCommand.selectTiles(buildableTiles);
218 return;
219 }
220
221 ClientNotification *clientNotification = TrapManager::createTrapClientNotificationEditor(type);
222 uint32_t nbTiles = buildableTiles.size();
223 int32_t seatId = inputManager.mSeatIdSelected;
224 clientNotification->mPacket << seatId;
225 clientNotification->mPacket << nbTiles;
226 for(Tile* tile : buildableTiles)
227 gameMap->tileToPacket(clientNotification->mPacket, tile);
228
229 ODClient::getSingleton().queueClientNotification(clientNotification);
230}
231
232bool TrapFactory::buildTrapDefaultEditor(GameMap* gameMap, Trap* trap, ODPacket& packet) const
233{

Callers

nothing calls this directly

Calls 7

rectangularRegionMethod · 0.80
getIsBuildingMethod · 0.80
tileToPacketMethod · 0.80
displayTextMethod · 0.45
selectSquaredTilesMethod · 0.45
selectTilesMethod · 0.45

Tested by

no test coverage detected