Advertisement
Guest User

Untitled

a guest
Jul 21st, 2017
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.22 KB | None | 0 0
  1. /*
  2.     Hi, i have a problem for sending a message ingame. I have 2 functions, one for construct the packet and one for sending to all players the packet, it's look like that :
  3. */
  4.  
  5.  
  6. SendMessageToBg(true, "The player %s join the battleground", pPlayer->GetName());
  7.  
  8. void EasyBG::SendMessageToBg(bool isArea, const char *message, ...)
  9. {
  10.     DistributePacketToAll((isArea) ? SendChatMessage(true, message) : SendChatMessage(false, message));
  11. }
  12.  
  13. WorldPacket * EasyBG::SendChatMessage(bool isArea, const char *message)
  14. {
  15.     char msg[500];
  16.     va_list ap;
  17.     va_start(ap, message);
  18.     vsnprintf(msg, 500, message, ap); // Crash here
  19.     va_end(ap);
  20.    
  21.     if(isArea)
  22.     {
  23.         /*WorldPacket *data = new WorldPacket(SMSG_AREA_TRIGGER_MESSAGE, 6 + strlen(msg));
  24.         *data << (uint32)0 << msg << (uint8)0x00;
  25.         return data;*/
  26.         WorldPacket data(SMSG_AREA_TRIGGER_MESSAGE, 6 + strlen(msg));
  27.         data << (uint32)0 << msg << (uint8)0x00;
  28.         return &data;
  29.     }
  30.     else
  31.         return sChatHandler.FillSystemMessageData(msg);
  32. }
  33.  
  34. /*
  35.     I created a crashdump and there is a problem for the player name :
  36.     message : message   0x00be2a60 "The player %s join the battlground" const char *
  37.     msg : msg   0x049ef79c "The player ÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌ̐9*Û¢  "   char [500]
  38.  
  39.     So i think it crash because msg is over 500 character...
  40. */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement