本文整理汇总了C++中MapComposite::getWholeMapIterator方法的典型用法代码示例。如果您正苦于以下问题:C++ MapComposite::getWholeMapIterator方法的具体用法?C++ MapComposite::getWholeMapIterator怎么用?C++ MapComposite::getWholeMapIterator使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MapComposite
的用法示例。
在下文中一共展示了MapComposite::getWholeMapIterator方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: handlePartyInvite
void GameHandler::handlePartyInvite(GameClient &client, MessageIn &message)
{
MapComposite *map = client.character->getMap();
const int visualRange = Configuration::getValue("game_visualRange", 448);
std::string invitee = message.readString();
if (invitee == client.character->getComponent<BeingComponent>()->getName())
return;
for (CharacterIterator it(map->getWholeMapIterator()); it; ++it)
{
if ((*it)->getComponent<BeingComponent>()->getName() == invitee)
{
// calculate if the invitee is within the visual range
auto *inviterComponent =
client.character->getComponent<ActorComponent>();
auto *inviteeComponent = (*it)->getComponent<ActorComponent>();
const Point &inviterPosition = inviterComponent->getPosition();
const Point &inviteePosition = inviteeComponent->getPosition();
const int dx = std::abs(inviterPosition.x - inviteePosition.x);
const int dy = std::abs(inviterPosition.y - inviteePosition.y);
if (visualRange > std::max(dx, dy))
{
MessageOut out(GCMSG_PARTY_INVITE);
out.writeString(client.character
->getComponent<BeingComponent>()->getName());
out.writeString(invitee);
accountHandler->send(out);
return;
}
break;
}
}
// Invitee was not found or is too far away
MessageOut out(GPMSG_PARTY_INVITE_ERROR);
out.writeString(invitee);
client.send(out);
}
示例2: update
void GameState::update(int tick)
{
currentTick = tick;
#ifndef NDEBUG
dbgLockObjects = true;
#endif
ScriptManager::currentState()->update();
// Update game state (update AI, etc.)
const MapManager::Maps &maps = MapManager::getMaps();
for (MapManager::Maps::const_iterator m = maps.begin(),
m_end = maps.end(); m != m_end; ++m)
{
MapComposite *map = m->second;
if (!map->isActive())
continue;
map->update();
for (CharacterIterator p(map->getWholeMapIterator()); p; ++p)
{
informPlayer(map, *p);
}
for (ActorIterator it(map->getWholeMapIterator()); it; ++it)
{
Actor *a = *it;
a->clearUpdateFlags();
if (a->canFight())
{
static_cast< Being * >(a)->clearHitsTaken();
}
}
}
# ifndef NDEBUG
dbgLockObjects = false;
# endif
// Take care of events that were delayed because of their side effects.
for (DelayedEvents::iterator it = delayedEvents.begin(),
it_end = delayedEvents.end(); it != it_end; ++it)
{
const DelayedEvent &e = it->second;
Actor *o = it->first;
switch (e.type)
{
case EVENT_REMOVE:
remove(o);
if (o->getType() == OBJECT_CHARACTER)
{
Character *ch = static_cast< Character * >(o);
ch->disconnected();
gameHandler->kill(ch);
}
delete o;
break;
case EVENT_INSERT:
insertOrDelete(o);
break;
case EVENT_WARP:
assert(o->getType() == OBJECT_CHARACTER);
warp(static_cast< Character * >(o), e.map, e.x, e.y);
break;
}
}
delayedEvents.clear();
}
示例3: update
void GameState::update(int worldTime)
{
# ifndef NDEBUG
dbgLockObjects = true;
# endif
// Update game state (update AI, etc.)
const MapManager::Maps &maps = MapManager::getMaps();
for (MapManager::Maps::const_iterator m = maps.begin(), m_end = maps.end(); m != m_end; ++m)
{
MapComposite *map = m->second;
if (!map->isActive())
{
continue;
}
updateMap(map);
for (CharacterIterator p(map->getWholeMapIterator()); p; ++p)
{
informPlayer(map, *p);
/*
sending the whole character is overhead for the database, it should
be replaced by a syncbuffer. see: game-server/accountconnection:
AccountConnection::syncChanges()
if (worldTime % 2000 == 0)
{
accountHandler->sendCharacterData(*p);
}
*/
}
for (ActorIterator i(map->getWholeMapIterator()); i; ++i)
{
Actor *a = *i;
a->clearUpdateFlags();
if (a->canFight())
{
static_cast< Being * >(a)->clearHitsTaken();
}
}
}
# ifndef NDEBUG
dbgLockObjects = false;
# endif
// Take care of events that were delayed because of their side effects.
for (DelayedEvents::iterator i = delayedEvents.begin(),
i_end = delayedEvents.end(); i != i_end; ++i)
{
const DelayedEvent &e = i->second;
Actor *o = i->first;
switch (e.type)
{
case EVENT_REMOVE:
remove(o);
if (o->getType() == OBJECT_CHARACTER)
{
Character *ch = static_cast< Character * >(o);
ch->disconnected();
gameHandler->kill(ch);
}
delete o;
break;
case EVENT_INSERT:
insertSafe(o);
break;
case EVENT_WARP:
assert(o->getType() == OBJECT_CHARACTER);
warp(static_cast< Character * >(o), e.map, e.x, e.y);
break;
}
}
delayedEvents.clear();
}