Palace Plugin - Cant examine or consume USERMOVE message
OK,
I donwloaded the Server_SDK.ZIP for Palace and complied and ran the example plugin perfectly.
I want to make a plugin that can selectively prevent a user from moving around in a room, sort of like the `PIN command, but freezing them at their current location and not changing their avatar.
As a test I tried to examine the MSG_USERMOVE message and consume it with my plugin. Thinking this would prevent ALL users from moving. This crashes my Palace server. If I comment out the examination code, the server runs but people can still move as if I have not consumed the message...
Anybody can help would be appreciated... Code for message handler pasted in below:
ClientMsg *handleMessage(ServerState *state, AnyType pluginDat, ClientMsg *msg)
{
char buf[256];
char *text;
int textLength;
/* talk messages */
if (msg->eventType == MSG_TALK || msg->eventType == MSG_XTALK)
{
ClientMsg_xTalk *xmsg = (ClientMsg_xTalk *) &msg->msg;
if (msg->eventType == MSG_TALK)
{
/* Normal talk messages just have plain text... */
ClientMsg_talk *tmsg = (ClientMsg_talk *) &msg->msg;
text = tmsg->text;
}
else
{
/* ...but xtalk messages need to be "decrypted". */
if (msg->length < sizeof(uint16))
{
/* Abort if badly formed xstring */
return msg;
}
textLength = *(uint16 *)(xmsg->text) - 3;
if (textLength > 255)
{
/* Avoid nasty buffer overrun opportunity */
return msg;
}
DecryptCString((StringPtr) xmsg->text + 2, buf, textLength, FALSE);
text = buf;
}
/* Handle commands, if present */
if (checkCommands((PluginID) pluginDat, text, state->currentUser))
{
/* Consume commands */
return NULL;
}
return msg;
}
char smBuff[32];
sprintf(smBuff, "Message: %08x", msg->eventType);
UserPrivateMessage(state->currentUser, smBuff);
if (msg->eventType == MSG_USERMOVE)
{
Point *pt = (Point *) msg->msg;
char medBuff[64];
sprintf(medBuff, "New Pos: v=%d, h=%d", (int) pt->v, (int) pt->h);
UserPrivateMessage(state->currentUser, medBuff);
/* Consume commands */
return NULL;
}
return msg;
}
Thanks,
Macore
|