本文整理汇总了C++中SpectatorVec::begin方法的典型用法代码示例。如果您正苦于以下问题:C++ SpectatorVec::begin方法的具体用法?C++ SpectatorVec::begin怎么用?C++ SpectatorVec::begin使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SpectatorVec
的用法示例。
在下文中一共展示了SpectatorVec::begin方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: onRemoveTileItem
void Tile::onRemoveTileItem(const SpectatorVec& list, std::vector<uint32_t>& oldStackPosVector, Item* item)
{
updateTileFlags(item, true);
const Position& cylinderMapPos = getPosition();
const ItemType& iType = Item::items[item->getID()];
SpectatorVec::const_iterator it;
//send to client
Player* tmpPlayer = NULL;
uint32_t i = 0;
for (it = list.begin(); it != list.end(); ++it)
{
if ((tmpPlayer = (*it)->getPlayer()))
{
tmpPlayer->sendRemoveTileItem(this, cylinderMapPos, oldStackPosVector[i], item);
++i;
}
}
//event methods
for (it = list.begin(); it != list.end(); ++it)
{
(*it)->onRemoveTileItem(this, cylinderMapPos, iType, item);
}
}
示例2: onRemoveTileItem
void Tile::onRemoveTileItem(const SpectatorVec& list, std::vector<uint32_t>& oldStackPosVector, Item* item)
{
if (item->hasProperty(MOVEABLE) || item->getContainer()) {
Game::BrowseFieldMap::const_iterator it = g_game.browseFields.find(this);
if (it != g_game.browseFields.end()) {
it->second->__removeThing(item, item->getItemCount());
}
}
updateTileFlags(item, true);
const Position& cylinderMapPos = getPosition();
const ItemType& iType = Item::items[item->getID()];
SpectatorVec::const_iterator end = list.end();
//send to client
int32_t i = 0;
for (SpectatorVec::const_iterator it = list.begin(); it != end; ++it) {
if (Player* tmpPlayer = (*it)->getPlayer()) {
tmpPlayer->sendRemoveTileItem(this, cylinderMapPos, oldStackPosVector[i], item);
++i;
}
}
//event methods
for (SpectatorVec::const_iterator it = list.begin(); it != end; ++it) {
(*it)->onRemoveTileItem(this, cylinderMapPos, iType, item);
}
}
示例3: onUpdateTile
void Tile::onUpdateTile()
{
const Position& cylinderMapPos = getPosition();
SpectatorVec list;
SpectatorVec::iterator it;
g_game.getSpectators(Range(cylinderMapPos, true), list);
//send to client
Player* player = NULL;
for(it = list.begin(); it != list.end(); ++it){
if(player = (*it)->getPlayer()){
player->sendUpdateTile(cylinderMapPos);
}
}
g_game.isExecutingEvents = true;
//event methods
for(it = list.begin(); it != list.end(); ++it){
(*it)->onUpdateTile(cylinderMapPos);
}
g_game.isExecutingEvents = false;
}
示例4: moveCreature
void Tile::moveCreature(Creature* creature, Cylinder* toCylinder, bool teleport /* = false*/)
{
int32_t oldStackPos = __getIndexOfThing(creature);
//remove the creature
__removeThing(creature, 0);
//add the creature
toCylinder->__addThing(creature);
Position fromPos = getPosition();
Position toPos = toCylinder->getPosition();
if(!teleport){
if(fromPos.y > toPos.y)
creature->setDirection(NORTH);
else if(fromPos.y < toPos.y)
creature->setDirection(SOUTH);
if(fromPos.x < toPos.x)
creature->setDirection(EAST);
else if(fromPos.x > toPos.x)
creature->setDirection(WEST);
}
SpectatorVec list;
SpectatorVec::iterator it;
g_game.getSpectators(Range(fromPos, true), list);
g_game.getSpectators(Range(toPos, true), list);
//send to client
Player* player = NULL;
for(it = list.begin(); it != list.end(); ++it) {
if(player = (*it)->getPlayer()){
player->sendCreatureMove(creature, fromPos, oldStackPos, teleport);
}
}
g_game.isExecutingEvents = true;
//event method
for(it = list.begin(); it != list.end(); ++it) {
(*it)->onCreatureMove(creature, fromPos, oldStackPos, teleport);
}
g_game.isExecutingEvents = false;
toCylinder->postAddNotification(creature);
postRemoveNotification(creature);
}
示例5: postRemoveNotification
void Tile::postRemoveNotification(Thing* thing, const Cylinder* newParent, int32_t index, bool isCompleteRemoval, cylinderlink_t link /*= LINK_OWNER*/)
{
const Position& cylinderMapPos = getPosition();
SpectatorVec list;
g_game.getSpectators(list, cylinderMapPos, true, true);
if (/*isCompleteRemoval &&*/ getThingCount() > 8) {
onUpdateTile(list);
}
for (SpectatorVec::const_iterator it = list.begin(), end = list.end(); it != end; ++it) {
(*it)->getPlayer()->postRemoveNotification(thing, newParent, index, isCompleteRemoval, LINK_NEAR);
}
//calling movement scripts
Creature* creature = thing->getCreature();
if (creature) {
g_moveEvents->onCreatureMove(creature, this, false);
} else {
Item* item = thing->getItem();
if (item) {
g_moveEvents->onItemMove(item, this, false);
}
}
}
示例6: luaActionDoSendAnimatedText
int ActionScript::luaActionDoSendAnimatedText(lua_State *L)
{
//doSendAnimatedText(position,text,color)
int color = (int)internalGetNumber(L);
const char * text = internalGetString(L);
PositionEx pos;
internalGetPositionEx(L,pos);
ActionScript *action = getActionScript(L);
Position realpos = internalGetRealPosition(action, action->_player,(Position&)pos);
SpectatorVec list;
SpectatorVec::iterator it;
action->game->getSpectators(Range(realpos, true), list);
for(it = list.begin(); it != list.end(); ++it) {
Player *p = dynamic_cast<Player*>(*it);
if(p)
p->sendAnimatedText(realpos, color, text);
}
lua_pushnumber(L, 0);
return 1;
}
示例7: onAddContainerItem
void Container::onAddContainerItem(Item* item)
{
const Position& cylinderMapPos = getPosition();
SpectatorVec list;
g_game.getSpectators(list, cylinderMapPos, false, true, 2, 2, 2, 2);
SpectatorVec::const_iterator end = list.end();
//send to client
for(SpectatorVec::const_iterator it = list.begin(); it != end; ++it)
(*it)->getPlayer()->sendAddContainerItem(this, item);
//event methods
for(SpectatorVec::const_iterator it = list.begin(); it != end; ++it)
(*it)->getPlayer()->onAddContainerItem(this, item);
}
示例8: onUpdateContainerItem
void Container::onUpdateContainerItem(uint32_t index, Item* oldItem, const ItemType& oldType,
Item* newItem, const ItemType& newType)
{
const Position& cylinderMapPos = getPosition();
SpectatorVec list;
g_game.getSpectators(list, cylinderMapPos, false, true, 2, 2, 2, 2);
SpectatorVec::const_iterator end = list.end();
//send to client
for(SpectatorVec::const_iterator it = list.begin(); it != end; ++it)
(*it)->getPlayer()->sendUpdateContainerItem(this, index, oldItem, newItem);
//event methods
for(SpectatorVec::const_iterator it = list.begin(); it != end; ++it)
(*it)->getPlayer()->onUpdateContainerItem(this, index, oldItem, oldType, newItem, newType);
}
示例9: onRemoveContainerItem
void Container::onRemoveContainerItem(uint32_t index, Item* item)
{
const Position& cylinderMapPos = getPosition();
SpectatorVec list;
g_game.getSpectators(list, cylinderMapPos, false, true, 2, 2, 2, 2);
SpectatorVec::const_iterator end = list.end();
//send change to client
Item* lastItem = getItem(maxSize);
for(SpectatorVec::const_iterator it = list.begin(); it != end; ++it)
(*it)->getPlayer()->sendRemoveContainerItem(this, index, lastItem);
//event methods
for(SpectatorVec::const_iterator it = list.begin(); it != end; ++it)
(*it)->getPlayer()->onRemoveContainerItem(this, index, item);
}
示例10: onUpdateTile
void Tile::onUpdateTile(const SpectatorVec& list)
{
const Position& cylinderMapPos = getPosition();
//send to clients
for (SpectatorVec::const_iterator it = list.begin(), end = list.end(); it != end; ++it) {
(*it)->getPlayer()->sendUpdateTile(this, cylinderMapPos);
}
}
示例11: findPlayer
bool Spawn::findPlayer(const Position& pos)
{
SpectatorVec list;
g_game.getSpectators(list, pos, false, true);
for (SpectatorVec::const_iterator it = list.begin(), end = list.end(); it != end; ++it) {
if (!(*it)->getPlayer()->hasFlag(PlayerFlag_IgnoredByMonsters)) {
return true;
}
}
return false;
}
示例12: postAddNotification
void Tile::postAddNotification(Thing* thing, const Cylinder* oldParent, int32_t index, cylinderlink_t link /*= LINK_OWNER*/)
{
const Position& cylinderMapPos = getPosition();
SpectatorVec list;
g_game.getSpectators(list, cylinderMapPos, true, true);
for (SpectatorVec::const_iterator it = list.begin(), end = list.end(); it != end; ++it) {
(*it)->getPlayer()->postAddNotification(thing, oldParent, index, LINK_NEAR);
}
//add a reference to this item, it may be deleted after being added (mailbox for example)
thing->useThing2();
if (link == LINK_OWNER) {
//calling movement scripts
Creature* creature = thing->getCreature();
if (creature) {
g_moveEvents->onCreatureMove(creature, this, true);
} else {
Item* item = thing->getItem();
if (item) {
g_moveEvents->onItemMove(item, this, true);
}
}
if (hasFlag(TILESTATE_TELEPORT)) {
Teleport* teleport = getTeleportItem();
if (teleport) {
teleport->__addThing(thing);
}
} else if (hasFlag(TILESTATE_TRASHHOLDER)) {
TrashHolder* trashholder = getTrashHolder();
if (trashholder) {
trashholder->__addThing(thing);
}
} else if (hasFlag(TILESTATE_MAILBOX)) {
Mailbox* mailbox = getMailbox();
if (mailbox) {
mailbox->__addThing(thing);
}
}
}
//release the reference to this item onces we are finished
g_game.FreeThing(thing);
}
示例13: onRemoveContainerItem
void Container::onRemoveContainerItem(uint32_t index, Item* item)
{
const Position& cylinderMapPos = getPosition();
SpectatorVec list;
SpectatorVec::iterator it;
g_game.getSpectators(list, cylinderMapPos, false, false, 2, 2, 2, 2);
//send change to client
Player* player = NULL;
for(it = list.begin(); it != list.end(); ++it)
{
if((player = (*it)->getPlayer()))
player->sendRemoveContainerItem(this, index, item);
}
//event methods
for(it = list.begin(); it != list.end(); ++it)
{
if((player = (*it)->getPlayer()))
player->onRemoveContainerItem(this, index, item);
}
}
示例14: idle
void Spawn::idle(int t)
{
SpawnedMap::iterator it;
for(it = spawnedmap.begin(); it != spawnedmap.end();) {
if (it->second->isRemoved == true /*it->second->health <= 0*/) {
if(it->first != 0) {
spawnmap[it->first].lastspawn = OTSYS_TIME();
}
it->second->releaseThing();
//delete it->second;
spawnedmap.erase(it++);
}
else if(!isInSpawnRange(it->second->pos) && it->first != 0) {
spawnedmap.insert(spawned_pair(0, it->second));
spawnedmap.erase(it++);
}
else
++it;
}
for(SpawnMap::iterator sit = spawnmap.begin(); sit != spawnmap.end(); ++sit) {
if(spawnedmap.count(sit->first) == 0) {
if((OTSYS_TIME() - sit->second.lastspawn) >= sit->second.spawntime) {
SpectatorVec list;
SpectatorVec::iterator it;
game->getSpectators(Range(sit->second.pos, true), list);
bool playerFound = false;
for(it = list.begin(); it != list.end(); ++it) {
Player *player = dynamic_cast<Player*>(*it);
if(player && player->access < g_config.ACCESS_PROTECT) {
playerFound = true;
break;
}
}
if(playerFound) {
sit->second.lastspawn = OTSYS_TIME();
continue;
}
respawn(sit->first, sit->second.pos, sit->second.name, sit->second.dir);
}
}
}
}
示例15: findPlayer
bool Spawn::findPlayer(const Position& pos)
{
SpectatorVec list;
g_game.getSpectators(list, pos);
Player* tmpPlayer = NULL;
for(SpectatorVec::iterator it = list.begin(); it != list.end(); ++it)
{
if((tmpPlayer = (*it)->getPlayer()) && !tmpPlayer->hasFlag(PlayerFlag_IgnoredByMonsters))
return true;
}
return false;
}