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

Method dropHand

source/game/Player.cpp:311–346  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

309}
310
311void Player::dropHand(Tile *t, unsigned int index)
312{
313 // Add the creature to the map
314 if(index >= mObjectsInHand.size())
315 {
316 OD_LOG_ERR("seatId=" + Helper::toString(getSeat()->getId()) + ", index=" + Helper::toString(index) + ", size=" + Helper::toString(mObjectsInHand.size()));
317 return;
318 }
319
320 GameEntity *entity = mObjectsInHand[index];
321 mObjectsInHand.erase(mObjectsInHand.begin() + index);
322
323 Ogre::Vector3 pos(static_cast<Ogre::Real>(t->getX()),
324 static_cast<Ogre::Real>(t->getY()), entity->getPosition().z);
325 if(mGameMap->isServerGameMap())
326 {
327 entity->drop(pos);
328 entity->fireDropEntity(this, t);
329 return;
330 }
331
332 entity->correctDropPosition(pos);
333 OD_LOG_INF("player seatId=" + Helper::toString(getSeat()->getId()) + " drop " + entity->getName() + " on tile=" + Tile::displayAsString(t));
334 entity->drop(pos);
335
336 // If this is the result of another player dropping the creature it is currently not visible so we need to create a mesh for it
337 //cout << "\nthis: " << this << "\nme: " << gameMap->getLocalPlayer() << endl;
338 //cout.flush();
339 if (this != mGameMap->getLocalPlayer())
340 {
341 OD_LOG_ERR("cannot pickup entity player seat=" + Helper::toString(getSeat()->getId()) + ", localPlayer seat id=" + Helper::toString(mGameMap->getLocalPlayer()->getSeat()->getId()) + ", entity=" + entity->getName());
342 return;
343 }
344 // Send a render request to rearrange the creatures in the hand to move them all forward 1 place
345 RenderManager::getSingleton().rrDropHand(entity, this);
346}
347
348void Player::rotateHand(Direction d)
349{

Callers 6

processMessageMethod · 0.80
saveWoundedCreaturesMethod · 0.80
handleDefenseMethod · 0.80
handleTiredCreaturesMethod · 0.80
handleHungryCreaturesMethod · 0.80

Calls 11

isServerGameMapMethod · 0.80
fireDropEntityMethod · 0.80
getLocalPlayerMethod · 0.80
rrDropHandMethod · 0.80
toStringFunction · 0.70
getIdMethod · 0.45
getXMethod · 0.45
getYMethod · 0.45
dropMethod · 0.45
correctDropPositionMethod · 0.45
getSeatMethod · 0.45

Tested by

no test coverage detected