Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <=====><=====><=====><=====><=====><=====>
- <=====><=====>Błąd 1<=====><=====><=====>
- <=====><=====><=====><=====><=====><=====>
- ==1749== Invalid read of size 4
- ==1749== at 0x187D20: Game::creatureBroadcastTileUpdated(Position const&) (game.cpp:9545)
- void Game::creatureBroadcastTileUpdated(const Position& pos)
- {
- OTSYS_THREAD_LOCK_CLASS lockClass(gameLock, "Game::creatureBroadcastTileUpdated()");
- SpectatorVec list;
- SpectatorVec::iterator it;
- //getSpectators(Range(pos, true), list);
- getSpectators(Range(pos, true), list, false, false); // linia 9545
- //players
- for(it = list.begin(); it != list.end(); ++it)
- {
- if(dynamic_cast<Player*>(*it))
- {
- (*it)->onTileUpdated(pos);
- }
- }
- //none-players
- for(it = list.begin(); it != list.end(); ++it)
- {
- if(!dynamic_cast<Player*>(*it))
- {
- (*it)->onTileUpdated(pos);
- }
- }
- }
- <=====><=====><=====><=====><=====><=====>
- <=====><=====>Błąd 2<=====><=====><=====>
- <=====><=====><=====><=====><=====><=====
- ==1749== Invalid read of size 4
- ==1749== at 0x26A4FA: Protocol76::AddTileUpdated(NetworkMessage&, Position const&) (protocol76.cpp:2121)
- void Protocol76::AddTileUpdated(NetworkMessage &msg, const Position &pos)
- {
- #ifdef __DEBUG__
- std::cout << "Pop-up item from below..." << std::endl;
- #endif
- if (CanSee(pos.x, pos.y, pos.z)) // linia 2121
- {
- msg.AddByte(0x69);
- msg.AddPosition(pos);
- Tile* tile = game->getTile(pos.x, pos.y, pos.z);
- if(tile)
- {
- #ifdef TRS_GM_INVISIBLE
- GetTileDescription(tile, msg, player);
- #else
- GetTileDescription(tile, msg);
- #endif //TRS_GM_INVISIBLE
- msg.AddByte(0);
- msg.AddByte(0xFF);
- }
- else {
- msg.AddByte(0x01);
- msg.AddByte(0xFF);
- }
- }
- }
- ==1749== by 0x26A619: Protocol76::sendTileUpdated(Position const&) (protocol76.cpp:2147)
- void Protocol76::sendTileUpdated(const Position &pos)
- {
- NetworkMessage msg;
- AddTileUpdated(msg, pos); // linia 2147
- WriteBuffer(msg);
- }
- ==1749== by 0x24E3DD: Player::onTileUpdated(Position const&) (player.cpp:2397)
- void Player::onTileUpdated(const Position &pos)
- {
- client->sendTileUpdated(pos); // linia 2397
- }
- ==1749== by 0x187E24: Game::creatureBroadcastTileUpdated(Position const&) (game.cpp:9552)
- void Game::creatureBroadcastTileUpdated(const Position& pos)
- {
- OTSYS_THREAD_LOCK_CLASS lockClass(gameLock, "Game::creatureBroadcastTileUpdated()");
- SpectatorVec list;
- SpectatorVec::iterator it;
- //getSpectators(Range(pos, true), list);
- getSpectators(Range(pos, true), list, false, false);
- //players
- for(it = list.begin(); it != list.end(); ++it)
- {
- if(dynamic_cast<Player*>(*it))
- {
- (*it)->onTileUpdated(pos); // linia 9552
- }
- }
- //none-players
- for(it = list.begin(); it != list.end(); ++it)
- {
- if(!dynamic_cast<Player*>(*it))
- {
- (*it)->onTileUpdated(pos);
- }
- }
- }
- ==1749== by 0x293829: Tile::clean() (tile.cpp:702)
- int32_t Tile::clean()
- {
- if (house)
- return 0L;
- std::list<Item*> trash;
- for (int32_t i = 0; i < getThingCount(); i++)
- {
- Item* item = dynamic_cast<Item*>(getThingByStackPos(i));
- #ifdef SCORPION_CLEAN
- if (item && item->isPickupable() && !item->decoration && item->isCleanable())
- trash.push_back(item);
- #else
- if (item && item->isPickupable() && !item->decoration)
- trash.push_back(item);
- #endif //SCORPION_CLEAN
- }
- for (std::list<Item*>::iterator iter = trash.begin(); iter != trash.end(); ++iter)
- {
- Item* item = *iter;
- Container* container = dynamic_cast<Container*>(item);
- if (container) // check if anyone has this container opened and close it
- {
- AutoList<Player>::listiterator piter = Player::listPlayer.list.begin();
- while (piter != Player::listPlayer.list.end()) // iterate players
- {
- Player* player = piter->second;
- containerLayout::const_iterator citer = player->getContainers();
- while (citer != player->getEndContainer()) // iterate containers opened by player
- {
- // close container if it is child of the one on the groud
- if (citer->second->getTopParent() == container)
- citer = player->closeContainer(citer->first);
- else
- ++citer;
- }
- ++piter;
- }
- }
- if (removeThing(item))
- item->releaseThing();
- g_game.creatureBroadcastTileUpdated(item->pos); //on clean update tiles // linia 702
- }
- return (int32_t)trash.size();
- }
- <=====><=====><=====><=====><=====><=====>
- <=====><=====>Błąd 3<=====><=====><=====>
- <=====><=====><=====><=====><=====><=====
- ==1749== Invalid read of size 4
- ==1749== at 0x2315E9: NetworkMessage::AddPosition(Position const&) (networkmessage.cpp:200)
- void NetworkMessage::AddPosition(const Position &pos)
- {
- AddU16(pos.x); // linia 200
- AddU16(pos.y); // linia 201
- AddByte(pos.z);
- }
- ==1749== by 0x26A532: Protocol76::AddTileUpdated(NetworkMessage&, Position const&) (protocol76.cpp:2124)
- void Protocol76::AddTileUpdated(NetworkMessage &msg, const Position &pos)
- {
- #ifdef __DEBUG__
- std::cout << "Pop-up item from below..." << std::endl;
- #endif
- if (CanSee(pos.x, pos.y, pos.z))
- {
- msg.AddByte(0x69);
- msg.AddPosition(pos); // linia 2124
- Tile* tile = game->getTile(pos.x, pos.y, pos.z);
- if(tile)
- {
- #ifdef TRS_GM_INVISIBLE
- GetTileDescription(tile, msg, player);
- #else
- GetTileDescription(tile, msg);
- #endif //TRS_GM_INVISIBLE
- msg.AddByte(0);
- msg.AddByte(0xFF);
- }
- else {
- msg.AddByte(0x01);
- msg.AddByte(0xFF);
- }
- }
- }
- ==1749== by 0x26A619: Protocol76::sendTileUpdated(Position const&) (protocol76.cpp:2147)
- ==1749== by 0x24E3DD: Player::onTileUpdated(Position const&) (player.cpp:2397)
- ==1749== by 0x187E24: Game::creatureBroadcastTileUpdated(Position const&) (game.cpp:9552)
- ==1749== by 0x293829: Tile::clean() (tile.cpp:702)
- ==1749== by 0x219FEB: Map::clean() (map.cpp:1124)
- int32_t Map::clean()
- {
- uint64_t start = OTSYS_TIME();
- size_t tiles = 0;
- int32_t RemovedItems = 0;
- for (auto tile : g_game.getTilesToClean())
- {
- if (!tile) {continue;}
- ++tiles;
- RemovedItems += tile->clean(); // linia 1124
- }
- g_game.clearTilesToClean();
- std::cout << "> CLEAN: Removed " << RemovedItems << " item" << (RemovedItems != 1 ? "s" : "")
- << " from " << tiles << " tile" << (tiles != 1 ? "s" : "") << " in "
- << (OTSYS_TIME() - start) / (1000.) << " seconds." << std::endl;
- return RemovedItems;
- }
- ==1749== by 0x18C5E4: Game::cleanMap() (game.cpp:10454)
- int32_t Game::cleanMap()
- {
- OTSYS_THREAD_LOCK_CLASS lockClass(gameLock, "Game::cleanMap()");
- return map->clean(); // linia 10454
- }
- <=====><=====><=====><=====><=====><=====>
- <=====><=====>Błąd 4<=====><=====><=====>
- <=====><=====><=====><=====><=====><=====
- ==1749== Invalid read of size 4
- ==1749== at 0x26A551: Protocol76::AddTileUpdated(NetworkMessage&, Position const&) (protocol76.cpp:2126)
- void Protocol76::AddTileUpdated(NetworkMessage &msg, const Position &pos)
- {
- #ifdef __DEBUG__
- std::cout << "Pop-up item from below..." << std::endl;
- #endif
- if (CanSee(pos.x, pos.y, pos.z))
- {
- msg.AddByte(0x69);
- msg.AddPosition(pos);
- Tile* tile = game->getTile(pos.x, pos.y, pos.z); // linia 2126
- if(tile)
- {
- #ifdef TRS_GM_INVISIBLE
- GetTileDescription(tile, msg, player);
- #else
- GetTileDescription(tile, msg);
- #endif //TRS_GM_INVISIBLE
- msg.AddByte(0);
- msg.AddByte(0xFF);
- }
- else {
- msg.AddByte(0x01);
- msg.AddByte(0xFF);
- }
- }
- }
- ==1749== by 0x26A619: Protocol76::sendTileUpdated(Position const&) (protocol76.cpp:2147)
- ==1749== by 0x24E3DD: Player::onTileUpdated(Position const&) (player.cpp:2397)
- ==1749== by 0x187E24: Game::creatureBroadcastTileUpdated(Position const&) (game.cpp:9552)
- Dodam ze drugi blad w tym temacie wlasnie wskazywal na funckje GetSpectators (skompilowane z flaga SPECTATOR_FIX)
- game.cpp
- void Game::getSpectators(const Range& range, SpectatorVec& list, bool onlyPlayers /*=true*/, bool checkDuplicate /*=false*/)
- {
- if(map){
- map->getSpectators(range, list, onlyPlayers, checkDuplicate);
- }
- }
- map.cpp
- #ifdef SPECTATOR_FIX
- 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
- list.push_back((*cit));
- }
- }
- }
- }
- }
- }
- #else
- void Map::getSpectators(const Range& range, SpectatorVec& list, bool onlyPlayers /*=true*/, bool checkDuplicate /*=false*/)
- {
- Position centerPos = range.centerpos;
- if(centerPos.z >= MAP_LAYER){
- return;
- }
- bool multifloor = false;
- if(range.minRange.z != range.maxRange.z){
- multifloor = true;
- }
- bool foundCache = false;
- bool cacheResult = false;
- if(range.minRange.x == -9 && range.maxRange.x == 9 && range.minRange.y == -7 && range.maxRange.y == 7 && multifloor){
- if(onlyPlayers){
- SpectatorCache::iterator it = playersSpectatorCache.find(centerPos);
- if(it != playersSpectatorCache.end()){
- SpectatorVec playersList;
- playersList = *it->second;
- if(list.empty()){
- list = playersList;
- }
- else
- {
- list.insert(list.end(), playersList.begin(), playersList.end());
- /*
- SpectatorVec::iterator pit;
- for(pit = playersList.begin(); pit != playersList.end(); ++pit){
- list.push_back(*pit);
- }*/
- }
- foundCache = true;
- }
- }
- if(!foundCache){
- SpectatorCache::iterator it = spectatorCache.find(centerPos);
- if(it != spectatorCache.end()){
- if(!onlyPlayers){
- SpectatorVec creaturesList;
- creaturesList = *it->second;
- if(list.empty()){
- list = creaturesList;
- }
- else
- {
- list.insert(list.end(), creaturesList.begin(), creaturesList.end());
- /*
- SpectatorVec::iterator cit;
- for(cit = creaturesList.begin(); cit != creaturesList.end(); ++cit){
- list.push_back(*cit);
- }*/
- }
- }
- else
- {
- SpectatorVec playersList;
- playersList = *it->second;
- SpectatorVec::iterator pit;
- Player* playerSpectator = NULL;
- for(pit = playersList.begin(); pit != playersList.end(); ++pit){
- playerSpectator = dynamic_cast<Player*>(*pit);
- if(playerSpectator){
- list.push_back(playerSpectator);
- }
- }
- }
- foundCache = true;
- }
- else
- {
- cacheResult = true;
- }
- }
- }
- if(!foundCache){
- /*CreatureVector::iterator cit;
- Tile* tile = NULL;
- int32_t offsetz;
- for(int 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(int nx = range.minRange.x + offsetz; nx <= range.maxRange.x + offsetz; ++nx){
- for(int 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){
- if(checkDuplicate){
- if(std::find(list.begin(), list.end(), *cit) == list.end()){
- list.push_back(*cit);
- }
- }
- else
- {
- list.push_back(*cit);
- }
- }
- }
- }
- }
- }*/
- int16_t min_y = centerPos.y + range.minRange.y;
- int16_t min_x = centerPos.x + range.minRange.x;
- int16_t max_y = centerPos.y + range.maxRange.y;
- int16_t max_x = centerPos.x + range.maxRange.x;
- int32_t minoffset = centerPos.z - range.maxRange.z;
- uint16_t x1 = std::min<uint32_t>(0xFFFF, std::max<int32_t>(0, (min_x + minoffset)));
- uint16_t y1 = std::min<uint32_t>(0xFFFF, std::max<int32_t>(0, (min_y + minoffset)));
- int32_t maxoffset = centerPos.z - range.minRange.z;
- uint16_t x2 = std::min<uint32_t>(0xFFFF, std::max<int32_t>(0, (max_x + maxoffset)));
- uint16_t y2 = std::min<uint32_t>(0xFFFF, std::max<int32_t>(0, (max_y + maxoffset)));
- int32_t startx1 = x1 - (x1 % FLOOR_SIZE);
- int32_t starty1 = y1 - (y1 % FLOOR_SIZE);
- int32_t endx2 = x2 - (x2 % FLOOR_SIZE);
- int32_t endy2 = y2 - (y2 % FLOOR_SIZE);
- QTreeLeafNode* startLeaf = QTreeNode::getLeafStatic(&root, startx1, starty1);
- QTreeLeafNode* leafS = startLeaf;
- QTreeLeafNode* leafE;
- Creature* creature = NULL;
- for(int_fast32_t ny = starty1; ny <= endy2; ny += FLOOR_SIZE){
- leafE = leafS;
- for(int_fast32_t nx = startx1; nx <= endx2; nx += FLOOR_SIZE){
- if(leafE){
- CreatureVector& node_list = (onlyPlayers ? leafE->player_list : leafE->creature_list);
- for(CreatureVector::const_iterator it = node_list.begin(); it != node_list.end(); ++it){
- creature = (*it);
- const Position& cpos = creature->pos;
- if(range.minRange.z > cpos.z || range.maxRange.z < cpos.z){
- continue;
- }
- int16_t offsetZ = centerPos.z - cpos.z;
- if((min_y + offsetZ) > cpos.y || (max_y + offsetZ) < cpos.y || (min_x + offsetZ) > cpos.x || (max_x + offsetZ) < cpos.x){
- continue;
- }
- if(checkDuplicate){
- if(std::find(list.begin(), list.end(), creature) == list.end()){
- list.push_back(creature);
- }
- }
- else
- {
- list.push_back(creature);
- }
- }
- leafE = leafE->stepEast();
- }
- else
- {
- leafE = getLeaf(nx + FLOOR_SIZE, ny);
- }
- }
- if(leafS){
- leafS = leafS->stepSouth();
- }
- else
- {
- leafS = getLeaf(startx1, ny + FLOOR_SIZE);
- }
- }
- if(cacheResult){
- if(onlyPlayers){
- playersSpectatorCache[centerPos].reset(new SpectatorVec(list));
- }
- else
- {
- spectatorCache[centerPos].reset(new SpectatorVec(list)); // tu crashowalo
- }
- }
- }
- }
- #endif //SPECTATOR_FIX
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement