PDA

View Full Version : Socials and emotes code review


lacidar
03-04-2002, 07:48 PM
Here's my take on socials and emotes.

ep_opcodes.h

// Socials
#define OP_Social_Text 0x1520
#define OP_Social_Action 0xa120


eq_packet_structs.h

//OP_Social_Text
struct Emote_Text {
int16 unknown1;
char message[1024];
};

//OP_Social_Action
struct Social_Action_Struct {
int8 unknown1[4];
int8 action;
int8 unknown2[7];
};


client_process.cpp

case OP_Social_Text: {
cout << "Social Text: " << app->size << endl; //DumpPacket(app);
APPLAYER *outapp = new APPLAYER;
outapp->opcode = app->opcode;
outapp->size = sizeof(Emote_Text);
outapp->pBuffer = new uchar[outapp->size];
outapp->pBuffer[0] = app->pBuffer[0];
outapp->pBuffer[1] = app->pBuffer[1];
uchar *cptr = outapp->pBuffer + 2;
cptr += sprintf((char *)cptr, "%s", GetName());
cptr += sprintf((char *)cptr, "%s", app->pBuffer + 2);
cout << "Check target" << endl;
if(target != NULL && target->IsClient())
{
cout << "Client targeted" << endl;
entity_list.QueueCloseClients(this, outapp, true, 100, target);
//cptr += sprintf((char *)cptr, " Special message for you, the target");
cptr = outapp->pBuffer + 2;

// not sure if live does this or not. thought it was a nice feature, but would take a lot to clean up grammatical and other errors. Maybe with a regex parser...
/*
replacestr((char *)cptr, target->GetName(), "you");
replacestr((char *)cptr, " he", " you");
replacestr((char *)cptr, " she", " you");
replacestr((char *)cptr, " him", " you");
replacestr((char *)cptr, " her", " you");
*/
entity_list.GetMob(target->GetName())->CastToClient()->QueuePacket(outapp);
}
else
entity_list.QueueCloseClients(this, outapp, true, 100);
delete outapp;
break;
}
case OP_Social_Action: {
cout << "Social Action: " << app->size << endl;
//DumpPacket(app);
entity_list.QueueCloseClients(this, app, true);
break;
}

DeletedUser
03-05-2002, 03:02 PM
I just added your code into the main brance. It will be in the next pre-release (4). Thanks:)