Advertisement
Guest User

Untitled

a guest
Sep 15th, 2024
25
0
174 days
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.03 KB | None | 0 0
  1. void Spawn::idle(int32_t t)
  2. {
  3.     SpawnedMap::iterator it;
  4.     for(it = spawnedmap.begin(); it != spawnedmap.end();)
  5.     {
  6.         if (it->second->isRemoved == true /*it->second->health <= 0*/)
  7.         {
  8.             if(it->first != 0)
  9.             {
  10.                 spawnmap[it->first].lastspawn = OTSYS_TIME();
  11.             }
  12.             it->second->releaseThing();
  13.             //delete it->second;
  14.             spawnedmap.erase(it++);
  15.         }
  16.         else if(!isInSpawnRange(it->second->pos) && it->first != 0)
  17.         {
  18.             spawnedmap.insert(spawned_pair(0, it->second));
  19.             spawnedmap.erase(it++);
  20.         }
  21.         else
  22.             ++it; // LINIA 445 CRASH
  23.     }
  24.     for(SpawnMap::iterator sit = spawnmap.begin(); sit != spawnmap.end(); ++sit)
  25.     {
  26.  
  27.         if(spawnedmap.count(sit->first) == 0)
  28.         {
  29.             if((OTSYS_TIME() - sit->second.lastspawn) >= sit->second.spawntime)
  30.             {
  31.  
  32.                 SpectatorVec list;
  33.                 SpectatorVec::iterator it;
  34.  
  35.                 //game->getSpectators(Range(sit->second.pos, false), list); // bylo true FIX
  36.                 game->getSpectators(Range(sit->second.pos, false), list, true, false);
  37.  
  38.                 bool playerFound = false;
  39.                 for(it = list.begin(); it != list.end(); ++it)
  40.                 {
  41.                     Player *player = dynamic_cast<Player*>(*it);
  42.  
  43.                     if(player && player->access < g_config.ACCESS_PROTECT)
  44.                     {
  45.                         playerFound = true;
  46.                         break;
  47.                     }
  48.                 }
  49.  
  50.                 if(playerFound)
  51.                 {
  52.                     sit->second.lastspawn = OTSYS_TIME();
  53.                     continue;
  54.                 }
  55.  
  56.                 respawn(sit->first, sit->second.pos, sit->second.name, sit->second.dir);
  57.             }
  58.         }
  59.     }
  60. }
  61.  
  62. void SpawnManager::checkSpawns(int32_t t)
  63. {
  64.     for(spawnsList::iterator it = spawns.begin(); it != spawns.end(); ++it)
  65.     {
  66.         (*it)->idle(t);
  67.     }
  68. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement