Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- bool Game::placeCreature(Position &pos, Creature* c
- #ifdef YUR_LOGIN_QUEUE
- , int32_t* placeInQueue
- #endif //YUR_LOGIN_QUEUE
- )
- {
- OTSYS_THREAD_LOCK_CLASS lockClass(gameLock, "Game::placeCreature()");
- bool success = false;
- Player *p = dynamic_cast<Player*>(c);
- Monster *monsterzin = dynamic_cast<Monster*>(c);
- #ifdef YUR_LOGIN_QUEUE
- if (!p || c->access >= g_config.ACCESS_ENTER ||
- #ifdef YUR_PREMIUM_PROMOTION
- (p->isPremium() && !g_config.QUEUE_PREMMY) ||
- #endif //YUR_PREMIUM_PROMOTION
- loginQueue.login(p->accountNumber, getPlayersOnline(), max_players, placeInQueue)){
- #else //YUR_LOGIN_QUEUE
- if (!p || c->access >= g_config.ACCESS_ENTER || getPlayersOnline() < max_players){
- #endif //YUR_LOGIN_QUEUE
- success = map->placeCreature(pos, c);
- if(success)
- {
- c->useThing();
- c->setID();
- //std::cout << "place: " << c << " " << c->getID() << std::endl;
- listCreature.addList(c);
- c->addList();
- c->isRemoved = false;
- #ifdef _BBK_DEATH_DELAY
- c->isDead = false;
- #endif //_BBK_DEATH_DELAY
- sendAddThing(NULL,c->pos,c); // linia 1845 CRASH
- if(p)
- {
- ....
- ....
- void Game::sendAddThing(Player* player,const Position &pos,const Thing* thing){
- if(pos.x == 0xFFFF) {
- if(!player)
- return;
- if(pos.y & 0x40) { //container
- if(!thing)
- return;
- const Item *item = dynamic_cast<const Item*>(thing);
- if(!item)
- return;
- uint8_t containerid = pos.y & 0x0F;
- Container* container = player->getContainer(containerid);
- if(!container)
- return;
- SpectatorVec list;
- SpectatorVec::iterator it;
- Position centerpos = (container->pos.x == 0xFFFF ? player->pos : container->pos);
- //getSpectators(Range(centerpos,2,2,2,2,false), list);
- getSpectators(Range(centerpos,2,2,2,2, false), list, true, false);
- if(!list.empty()) {
- for(it = list.begin(); it != list.end(); ++it) {
- Player *spectator = dynamic_cast<Player*>(*it);
- if(spectator)
- spectator->onItemAddContainer(container,item);
- }
- }
- else
- player->onItemAddContainer(container,item);
- }
- else //inventory
- {
- player->sendInventory(pos.y);
- }
- }
- else //ground
- {
- if(!thing)
- return;
- SpectatorVec list;
- SpectatorVec::iterator it;
- //getSpectators(Range(pos,true), list);
- getSpectators(Range(pos, true), list, false, false); // LINIA 8249 CRASH
- //players
- for(it = list.begin(); it != list.end(); ++it) {
- if(dynamic_cast<Player*>(*it)) {
- (*it)->onThingAppear(thing);
- }
- }
- //none-players
- for(it = list.begin(); it != list.end(); ++it) {
- if(!dynamic_cast<Player*>(*it)) {
- (*it)->onThingAppear(thing);
- }
- }
- }
- }
- void Game::getSpectators(const Range& range, SpectatorVec& list, bool onlyPlayers /*=true*/, bool checkDuplicate /*=false*/)
- {
- if(map){
- map->getSpectators(range, list, onlyPlayers, checkDuplicate); // LINIA 4502 CRASH
- }
- }
- --- map.cpp --
- void Map::getSpectators(const Range& range, SpectatorVec& list, bool onlyPlayers /*=true*/, bool checkDuplicate /*=false*/)
- {
- /*
- #ifdef __DEBUG__
- std::cout << "Viewer position at x: " << range.centerpos.x
- << ", y: " << range.centerpos.y
- << ", z: " << range.centerpos.z << std::endl;
- std::cout << "Min Range x: " << range.minRange.x
- << ", y: " << range.minRange.y
- << ", z: " << range.minRange.z << std::endl;
- std::cout << "Max Range x: " << range.maxRange.x
- << ", y: " << range.maxRange.y
- << ", z: " << range.maxRange.z << std::endl;
- #endif
- */
- int32_t offsetz;
- CreatureVector::iterator cit;
- Tile *tile;
- for(int32_t nz = range.minRange.z; nz != range.maxRange.z + range.zstep; nz += range.zstep)
- {
- offsetz = range.centerpos.z - nz;
- //negative offset means that the player is on a lower floor than ourself
- for (int32_t nx = range.minRange.x + offsetz; nx <= range.maxRange.x + offsetz; ++nx)
- {
- for (int32_t ny = range.minRange.y + offsetz; ny <= range.maxRange.y + offsetz; ++ny)
- {
- tile = getTile(nx + range.centerpos.x, ny + range.centerpos.y, nz);
- if (tile)
- {
- for (cit = tile->creatures.begin(); cit != tile->creatures.end(); ++cit)
- {
- /*
- #ifdef __DEBUG__
- std::cout << "Found " << (*cit)->getName() << " at x: " << (*cit)->pos.x << ", y: " << (*cit)->pos.y << ", z: " << (*cit)->pos.z << ", offset: " << offsetz << std::endl;
- #endif
- */
- if (*cit) // dodane przeze mnie dla pewnosci // linia 327 CRASH
- list.push_back((*cit));
- }
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement