uint32_t MoveEvents::onCreatureMove(Creature* creature, Tile* tile, bool isIn) { MoveEvent_t eventType; if(isIn){ eventType = MOVE_EVENT_STEP_IN; } else{ eventType = MOVE_EVENT_STEP_OUT; } uint32_t ret = 1; MoveEvent* moveEvent = getEvent(tile, eventType); if(moveEvent){ ret = ret & moveEvent->fireStepEvent(creature, NULL, tile->getPosition()); } int32_t j = tile->__getLastIndex(); Item* tileItem = NULL; for(int32_t i = tile->__getFirstIndex(); i < j; ++i){ Thing* thing = tile->__getThing(i); if(thing && (tileItem = thing->getItem())){ moveEvent = getEvent(tileItem, eventType); if(moveEvent){ ret = ret & moveEvent->fireStepEvent(creature, tileItem, tile->getPosition()); } } } return ret; }
uint32_t MoveEvents::onCreatureMove(Creature* creature, const Tile* tile, const Position& fromPos, MoveEvent_t eventType) { const Position& pos = tile->getPosition(); uint32_t ret = 1; MoveEvent* moveEvent = getEvent(tile, eventType); if (moveEvent) { ret &= moveEvent->fireStepEvent(creature, nullptr, pos, fromPos); } for (size_t i = tile->getFirstIndex(), j = tile->getLastIndex(); i < j; ++i) { Thing* thing = tile->getThing(i); if (!thing) { continue; } Item* tileItem = thing->getItem(); if (!tileItem) { continue; } moveEvent = getEvent(tileItem, eventType); if (moveEvent) { ret &= moveEvent->fireStepEvent(creature, tileItem, pos, fromPos); } } return ret; }
uint32_t MoveEvents::onCreatureMove(Creature* creature, const Tile* tile, bool isIn) { MoveEvent_t eventType; if (isIn) { eventType = MOVE_EVENT_STEP_IN; } else { eventType = MOVE_EVENT_STEP_OUT; } Position pos = tile->getPosition(); uint32_t ret = 1; MoveEvent* moveEvent = getEvent(tile, eventType); if (moveEvent) { ret = ret & moveEvent->fireStepEvent(creature, nullptr, pos); } for (int32_t i = tile->__getFirstIndex(), j = tile->__getLastIndex(); i < j; ++i) { Thing* thing = tile->__getThing(i); if (thing) { Item* tileItem = thing->getItem(); if (tileItem) { moveEvent = getEvent(tileItem, eventType); if (moveEvent) { ret = ret & moveEvent->fireStepEvent(creature, tileItem, pos); } } } } return ret; }
uint32_t MoveEvents::onCreatureMove(Creature* creature, const Tile* fromTile, const Tile* toTile, bool isIn) { MoveEvent_t eventType; const Tile* tile = NULL; if (isIn) { tile = toTile; eventType = MOVE_EVENT_STEP_IN; } else { tile = fromTile; eventType = MOVE_EVENT_STEP_OUT; } Position fromPos(0, 0, 0); if (fromTile) { fromPos = fromTile->getPosition(); } Position toPos(0, 0, 0); if (toTile) { toPos = toTile->getPosition(); } uint32_t ret = 1; MoveEvent* moveEvent = getEvent(tile, eventType); if (moveEvent) { ret = ret & moveEvent->fireStepEvent(creature, NULL, fromPos, toPos); } Item* tileItem = NULL; if (m_lastCacheTile == tile) { if (m_lastCacheItemVector.empty()) { return ret; } //We can not use iterators here since the scripts can invalidate the iterator for (uint32_t i = 0; i < m_lastCacheItemVector.size(); ++i) { tileItem = m_lastCacheItemVector[i]; if (tileItem) { moveEvent = getEvent(tileItem, eventType); if (moveEvent) { ret = ret & moveEvent->fireStepEvent(creature, tileItem, fromPos, toPos); } } } return ret; } m_lastCacheTile = tile; m_lastCacheItemVector.clear(); //We can not use iterators here since the scripts can invalidate the iterator int32_t j = tile->__getLastIndex(); for (int32_t i = tile->__getFirstIndex(); i < j; ++i) { Thing* thing = tile->__getThing(i); if (thing && (tileItem = thing->getItem())) { moveEvent = getEvent(tileItem, eventType); if (moveEvent) { m_lastCacheItemVector.push_back(tileItem); ret = ret & moveEvent->fireStepEvent(creature, tileItem, fromPos, toPos); } else if (hasTileEvent(tileItem)) { m_lastCacheItemVector.push_back(tileItem); } } } return ret; }