Alecta_SZ

EqEmu Remove Item Links

Aug 29th, 2013
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.13 KB | None | 0 0
  1. void Client::ChannelMessageReceived(uint8 chan_num, uint8 language, uint8 lang_skill, const char* orig_message, const char* targetname) {
  2.  
  3. (...)
  4.  
  5.   int length, i, j; bool isMidItemLink = false;
  6.  
  7.   length = strlen(message);
  8.   for (i=0, j=0; i < length; i++, j++)  
  9.   {
  10.  
  11.     // jump the second 0x12 for the termination of the item link
  12.     // need to test for this before the next check so consecutive item links are handled properly
  13.     if (message[j] == 0x12 && isMidItemLink) {
  14.       j++;                    
  15.       isMidItemLink = false;
  16.     }
  17.    
  18.     // grab the begining of an item link
  19.     // update the read location to skip over the item id
  20.     if (message[j] == 0x12 && !isMidItemLink)    
  21.     {
  22.       j += 46;                  
  23.       isMidItemLink = true;
  24.     }
  25.  
  26.     // this should always be the case, but what if client sends (intentionally?) malformed string.
  27.     // could also do a input sanitization check 32 <= message[i] <= 126 or something similar
  28.     if (j < length)          
  29.     {                        
  30.       message[i] = message[j];
  31.     } else {
  32.       message[i] = NULL;
  33.     }
  34.   }
  35.  
  36.  
  37. (...)
  38.  
  39. }
Advertisement
Add Comment
Please, Sign In to add comment