View Single Post
  #1  
Old 02-19-2015, 11:18 AM
Nibiuno
Hill Giant
 
Join Date: Mar 2010
Posts: 101
Default Crash in RoF2 codetrain for garbled messages

Im getting crashes when people dont have language skills or something on occasion. I get a message about an iterator error on my zone.exe file, and the zone crashes. Here is the crash info and the section of code.

Quote:
[02-19-2015 :: 10:20:17] [Crash] f:\dd\vctools\crt_bld\self_x86\crt\src\isctype.c (56): _chvalidator
[02-19-2015 :: 10:20:17] [Crash] f:\dd\vctools\crt_bld\self_x86\crt\src\_ctype.c (69): isalpha
[02-19-2015 :: 10:20:17] [Crash] c:\eq\sourcerof2\zone\client.cpp (7429): Client::GarbleMessage
[02-19-2015 :: 10:20:17] [Crash] c:\eq\sourcerof2\zone\client.cpp (1103): Client::ChannelMessageSend
[02-19-2015 :: 10:20:17] [Crash] c:\eq\sourcerof2\zone\entity.cpp (1107): EntityList::ChannelMessage
[02-19-2015 :: 10:20:17] [Crash] c:\eq\sourcerof2\zone\client.cpp (976): Client::ChannelMessageReceived
[02-19-2015 :: 10:20:17] [Crash] c:\eq\sourcerof2\zone\client_packet.cpp (4153): Client::Handle_OP_ChannelMessage
[02-19-2015 :: 10:20:17] [Crash] c:\eq\sourcerof2\zone\client_packet.cpp (46: Client::HandlePacket
[02-19-2015 :: 10:20:17] [Crash] c:\eq\sourcerof2\zone\client_process.cpp (683): Client::Process
[02-19-2015 :: 10:20:17] [Crash] c:\eq\sourcerof2\zone\entity.cpp (472): EntityList::MobProcess
Quote:
void Client::GarbleMessage(char *message, uint8 variance)
{
// Garble message by variance%
const char alpha_list[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvw xyz"; // only change alpha characters for now
const char delimiter = 0x12;
int delimiter_count = 0;

for (size_t i = 0; i < strlen(message); i++) {
// Client expects hex values inside of a text link body
if (message[i] == delimiter) {
if (!(delimiter_count & 1)) { i += EmuConstants::TEXT_LINK_BODY_LENGTH; }
++delimiter_count;
continue;
}

uint8 chance = (uintzone->random.Int(0, 115); // variation just over worst possible scrambling
if (isalpha(message[i]) && (chance <= variance)) {
uint8 rand_char = (uintzone->random.Int(0,51); // choose a random character from the alpha list
message[i] = alpha_list[rand_char];
}
}
}
Reply With Quote