Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void Client::ChannelMessageReceived(uint8 chan_num, uint8 language, uint8 lang_skill, const char* orig_message, const char* targetname) {
- (...)
- int length, i, j; bool isMidItemLink = false;
- length = strlen(message);
- for (i=0, j=0; i < length; i++, j++)
- {
- // jump the second 0x12 for the termination of the item link
- // need to test for this before the next check so consecutive item links are handled properly
- if (message[j] == 0x12 && isMidItemLink) {
- j++;
- isMidItemLink = false;
- }
- // grab the begining of an item link
- // update the read location to skip over the item id
- if (message[j] == 0x12 && !isMidItemLink)
- {
- j += 46;
- isMidItemLink = true;
- }
- // this should always be the case, but what if client sends (intentionally?) malformed string.
- // could also do a input sanitization check 32 <= message[i] <= 126 or something similar
- if (j < length)
- {
- message[i] = message[j];
- } else {
- message[i] = NULL;
- }
- }
- (...)
- }
Advertisement
Add Comment
Please, Sign In to add comment