Clean up MOTD processing

This commit is contained in:
Michael Cook (mackal) 2021-03-05 15:24:40 -05:00
parent 66f89416d5
commit 224c26620e

View File

@ -473,20 +473,16 @@ void WorldServer::HandleMessage(uint16 opcode, const EQ::Net::Packet &p)
break; break;
} }
case ServerOP_Motd: { case ServerOP_Motd: {
if (pack->size != sizeof(ServerMotd_Struct))
break;
ServerMotd_Struct *smotd = (ServerMotd_Struct *)pack->pBuffer; ServerMotd_Struct *smotd = (ServerMotd_Struct *)pack->pBuffer;
EQApplicationPacket *outapp; SerializeBuffer buf(100);
outapp = new EQApplicationPacket(OP_MOTD); buf.WriteString(smotd->motd);
char tmp[500] = { 0 };
sprintf(tmp, "%s", smotd->motd);
outapp->size = strlen(tmp) + 1; auto outapp = std::make_unique<EQApplicationPacket>(OP_MOTD, buf);
outapp->pBuffer = new uchar[outapp->size];
memset(outapp->pBuffer, 0, outapp->size);
strcpy((char*)outapp->pBuffer, tmp);
entity_list.QueueClients(0, outapp);
safe_delete(outapp);
entity_list.QueueClients(0, outapp.get());
break; break;
} }
case ServerOP_ShutdownAll: { case ServerOP_ShutdownAll: {