SHARE
TWEET

Untitled

a guest Dec 11th, 2019 76 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. void ProtocolGame::checkCreatureAsKnown(uint32_t id, bool& known, uint32_t& removedKnown)
  2. {
  3.     // loop through the known creature list and check if the given creature is in
  4.     for(std::list<uint32_t>::iterator it = knownCreatureList.begin(); it != knownCreatureList.end(); ++it)
  5.     {
  6.         if((*it) != id)
  7.             continue;
  8.  
  9.         // know... make the creature even more known...
  10.         knownCreatureList.erase(it);
  11.         knownCreatureList.push_front(id);
  12.  
  13.         known = true;
  14.         return;
  15.     }
  16.  
  17.     // ok, he is unknown...
  18.     known = false;
  19.     // ... but not in future
  20.     knownCreatureList.push_front(id);
  21.     // too many known creatures?
  22.     if(knownCreatureList.size() > 250)
  23.     {
  24.         // lets try to remove one from the end of the list
  25.         Creature* c = NULL;
  26.         for(int32_t n = 0; n < 250; n++)
  27.         {
  28.             removedKnown = knownCreatureList.front();
  29.             if(!(c = g_game.getCreatureByID(removedKnown)) || !canSee(c))
  30.                 break;
  31.  
  32.             // this creature we can't remove, still in sight, so back to the end
  33.             knownCreatureList.pop_back();
  34.             knownCreatureList.push_front(removedKnown);
  35.         }
  36.  
  37.         // hopefully we found someone to remove :S, we got only 250 tries
  38.         // if not... lets kick some players with debug errors :)
  39.         knownCreatureList.pop_back();
  40.     }
  41.     else // we can cache without problems :)
  42.         removedKnown = 0;
  43. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top