mirror of
https://github.com/mangosfour/server.git
synced 2025-12-14 16:37:01 +00:00
Replaced dynamic by static allocation in server packets header. Added command to test large packets.
This commit is contained in:
parent
dbc228370c
commit
dfa29a883f
4 changed files with 13 additions and 12 deletions
|
|
@ -201,6 +201,7 @@ ChatCommand * ChatHandler::getCommandTable()
|
||||||
{ "anim", SEC_GAMEMASTER, false, &ChatHandler::HandleAnimCommand, "", NULL },
|
{ "anim", SEC_GAMEMASTER, false, &ChatHandler::HandleAnimCommand, "", NULL },
|
||||||
{ "lootrecipient", SEC_GAMEMASTER, false, &ChatHandler::HandleGetLootRecipient, "", NULL },
|
{ "lootrecipient", SEC_GAMEMASTER, false, &ChatHandler::HandleGetLootRecipient, "", NULL },
|
||||||
{ "arena", SEC_ADMINISTRATOR, false, &ChatHandler::HandleDebugArenaCommand, "", NULL },
|
{ "arena", SEC_ADMINISTRATOR, false, &ChatHandler::HandleDebugArenaCommand, "", NULL },
|
||||||
|
{ "sendlargepacket",SEC_ADMINISTRATOR, false, &ChatHandler::HandleSendLargePacketCommand, "", NULL },
|
||||||
{ NULL, 0, false, NULL, "", NULL }
|
{ NULL, 0, false, NULL, "", NULL }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -435,6 +435,7 @@ class ChatHandler
|
||||||
bool HandleGetLootRecipient(const char * args);
|
bool HandleGetLootRecipient(const char * args);
|
||||||
bool HandleDebugArenaCommand(const char * args);
|
bool HandleDebugArenaCommand(const char * args);
|
||||||
bool HandleSpawnVehicle(const char * args);
|
bool HandleSpawnVehicle(const char * args);
|
||||||
|
bool HandleSendLargePacketCommand(const char * args);
|
||||||
|
|
||||||
Player* getSelectedPlayer();
|
Player* getSelectedPlayer();
|
||||||
Creature* getSelectedCreature();
|
Creature* getSelectedCreature();
|
||||||
|
|
|
||||||
|
|
@ -61,14 +61,8 @@ struct ServerPktHeader
|
||||||
if(isLargePacket())
|
if(isLargePacket())
|
||||||
{
|
{
|
||||||
sLog.outDebug("initializing large server to client packet. Size: %u, cmd: %u", size, cmd);
|
sLog.outDebug("initializing large server to client packet. Size: %u, cmd: %u", size, cmd);
|
||||||
header= new uint8[5];
|
|
||||||
header[headerIndex++] = 0x80|(0xFF &(size>>16));
|
header[headerIndex++] = 0x80|(0xFF &(size>>16));
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
header= new uint8[4];
|
|
||||||
}
|
|
||||||
|
|
||||||
header[headerIndex++] = 0xFF &(size>>8);
|
header[headerIndex++] = 0xFF &(size>>8);
|
||||||
header[headerIndex++] = 0xFF &size;
|
header[headerIndex++] = 0xFF &size;
|
||||||
|
|
||||||
|
|
@ -76,11 +70,6 @@ struct ServerPktHeader
|
||||||
header[headerIndex++] = 0xFF & (cmd>>8);
|
header[headerIndex++] = 0xFF & (cmd>>8);
|
||||||
}
|
}
|
||||||
|
|
||||||
~ServerPktHeader()
|
|
||||||
{
|
|
||||||
delete[] header;
|
|
||||||
}
|
|
||||||
|
|
||||||
uint8 getHeaderLength()
|
uint8 getHeaderLength()
|
||||||
{
|
{
|
||||||
// cmd = 2 bytes, size= 2||3bytes
|
// cmd = 2 bytes, size= 2||3bytes
|
||||||
|
|
@ -93,7 +82,7 @@ struct ServerPktHeader
|
||||||
}
|
}
|
||||||
|
|
||||||
const uint32 size;
|
const uint32 size;
|
||||||
uint8 *header;
|
uint8 header[5];
|
||||||
};
|
};
|
||||||
|
|
||||||
struct ClientPktHeader
|
struct ClientPktHeader
|
||||||
|
|
|
||||||
|
|
@ -576,3 +576,13 @@ bool ChatHandler::HandleSpawnVehicle(const char* args)
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool ChatHandler::HandleSendLargePacketCommand(const char* args)
|
||||||
|
{
|
||||||
|
const char* stuffingString = "This is a dummy string to push the packet's size beyond 128000 bytes. ";
|
||||||
|
std::ostringstream ss;
|
||||||
|
while(strlen(ss.str().c_str()) < 128000)
|
||||||
|
ss << stuffingString;
|
||||||
|
SendSysMessage(ss.str().c_str());
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue