Advertisement
jewalky

Untitled

Jan 23rd, 2017
280
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.61 KB | None | 0 0
  1. DEFINE_ACTION_FUNCTION(ADehackedPickup, DetermineType)
  2. {
  3.     PARAM_SELF_PROLOGUE(AInventory);
  4.  
  5.     // Look at the actor's current sprite to determine what kind of
  6.     // item to pretend to me.
  7.     int min = 0;
  8.     int max = countof(DehSpriteMappings) - 1;
  9.  
  10.     while (min <= max)
  11.     {
  12.         int mid = (min + max) / 2;
  13.         int lex = memcmp (DehSpriteMappings[mid].Sprite, sprites[self->sprite].name, 4);
  14.         if (lex == 0)
  15.         {
  16.             ACTION_RETURN_OBJECT(PClass::FindActor(DehSpriteMappings[mid].ClassName));
  17.         }
  18.         else if (lex < 0)
  19.         {
  20.             min = mid + 1;
  21.         }
  22.         else
  23.         {
  24.             max = mid - 1;
  25.         }
  26.     }
  27.     ACTION_RETURN_OBJECT(nullptr);
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement