int CNWNXMessages::SendCCMessage( CNWSObject * ply, char * text ){ CNWSMessage * mess = (*NWN_AppManager)->app_server->GetNWSMessage(); CNWSPlayer * cli = (*NWN_AppManager)->app_server->GetClientObjectByObjectId( ply->obj_generic.obj_id ); if( !cli ) return 0; CNWCCMessageData * ccmess = (CNWCCMessageData *)mem.nwnx_malloc(sizeof(CNWCCMessageData)); if( !ccmess ) return 0; memset( ccmess, 0, sizeof(CNWCCMessageData) ); DWORD chan; char * temp = strstr( text, "|" ); *temp = '\0'; temp++; sscanf( text, "%u", &chan ); LASTSTR->CExoStringCpy( temp ); ccmess->SetString( 0, *LASTSTR ); //int nRet = CNWSMessage__SendServerToPlayerCCMessage( mess, cli->pl_id, (unsigned char)chan, ccmess, NULL ); int nRet = mess->SendServerToPlayerCCMessage( cli->pl_id, (unsigned char)chan, ccmess, NULL ); Log( "o SendCCMessage (%u): %08X: (%u) %s\n", chan, ply->obj_generic.obj_id, LASTSTR->len, LASTSTR->text ); mem.nwnx_free( ccmess ); return nRet; }
int SendMsg(const int mode, const int id, char *msg, const int to) { CNWSMessage *pMessage = reinterpret_cast<CNWSMessage *>(g_pAppManager->ServerExoApp->GetNWSMessage()); CExoString xz; CExoString m(msg); pMessage->SendServerToPlayerChatMessage(mode, id, m, to, xz); return 1; }
int CNssPlayer::PopUpMessage(CGameObject *oObject, char *Params) { CNWSPlayer *Player = (*NWN_AppManager)->app_server->GetClientObjectByObjectId(oObject->obj_id); if (Player) { CNWSMessage *Msg = (*NWN_AppManager)->app_server->GetNWSMessage(); CGameObjectArray *CGA = (*NWN_AppManager)->app_server->GetObjectArray(); CGameObject go; ((CNWMessage*)Msg)->CreateWriteMessage(128, Player->pl_id, 1); Msg->WriteOBJECTIDServer(oObject->obj_id); CExoString Text = Params; char *pMessageData = 0; nwn_objid_t Sender = 0; DWORD oldMask; ((CNWMessage*)Msg)->WriteBOOL(1); // addicted2rpg: This line is definitely failing. It crashes at 0x773DE41B writing to a null pointer. // addicted2rpg: I don't have the time to debug it and fix it. Commenting it out sends a blank // popup, which I would rather do until its fixed. // ((CNWMessage*)Msg)->WriteCExoString(Text, 32); if (((CNWMessage*)Msg)->GetWriteMessage(&pMessageData, &Sender)) { Msg->SendServerToPlayerMessage(Player->pl_id, 27, 4, pMessageData, Sender); //addicted2rpg: just experimenting below. This line actually preserves the server, but crashes the client! //Msg->SendServerToPlayerMessage(Player->pl_id, 27, 4, (void *)&Params, Sender); } return 1; } return 0; }
int CNWNXConnect::SendhakList( CNWSPlayer * ply ){ if( !ply ) return 0; CNWSMessage * msg = (*NWN_AppManager)->app_server->GetNWSMessage(); CNWNXMemory mem; CNWMessage * mess = NWNX_CreateMessage( ); if( !mess ){ return 0; } mess->WriteINT( HAKLen, 32 ); for( int n=0;n<HAKLen;n++ ){ mess->WriteCExoString( HAK[n], 32 ); } mess->WriteCExoString( *TLK, 32 ); char * data=0; DWORD len=0; if( mess->GetWriteMessage( &data, &len ) ){ msg->SendServerToPlayerMessage( ply->pl_id, 100, 0, data, len ); NWNX_DestroyMessage( mess ); return 1; } else NWNX_DestroyMessage( mess ); return 0; }
int SendMsgSingle(int mode, int conn, int speaker, char *msg) { CNWSMessage *pMessage = reinterpret_cast<CNWSMessage *>(g_pAppManager->ServerExoApp->GetNWSMessage()); // printf("in SendMsgTalk: %d %x '%s'; pServThis=%p pMessage=%p pChatThis=%p\n", conn, speaker, msg, pServThis, pMessage, pChatThis); if (!pMessage) { printf("pMessage is nil? wtf.\n"); return 0; } CExoString str; str.Text = strdup(msg); str.Length = strlen(msg); switch (mode) { // Talk case 1: return pMessage->SendServerToPlayerChat_Talk(conn, speaker, str); // Shout case 2: return pMessage->SendServerToPlayerChat_Shout(conn, speaker, str); // Whisper case 3: return pMessage->SendServerToPlayerChat_Whisper(conn, speaker, str); // Private case 4: return pMessage->SendServerToPlayerChat_Tell(conn, speaker, str); // Server_Msg case 5: return pMessage->SendServerToPlayerChat_ServerTell(conn, str); // Party case 6: return pMessage->SendServerToPlayerChat_Party(conn, speaker, str); // Talk_DM case 17: return pMessage->SendServerToPlayerChat_DM_Talk(conn, speaker, str); // Whisper_DM case 19: return pMessage->SendServerToPlayerChat_DM_Whisper(conn, speaker, str); default: // Unsupported. return 0; } }