#include "Main.h" #include "Player.h" //Check for chat packet int HandleOpcode_CHAT_MESSAGE(NetMessage* pData, PLAYER_DATA* pLir) { Player* pPlayer=(Player*)pLir->pPlayer; Instance* pInstance=AccessInstance(pLir->instanceId); Agent* pAgent=pPlayer->GetAgent(); int retSize=0; //check what type of chat this is for and process accordingly switch(pData->pData[4]) { //All chat case '!': retSize=pInstance->ProcessLocalChat(pData->pData, pData, pLir); break; //Guild chat case '@': //retSize=pInstance->ProcessGuildChat(pData->networkId, pData->pData); retSize=pData->dataSize; break; //Team chat case '#': //retSize=pInstance->ProcessTeamChat(pData->pData, pData, pLir); retSize=pData->dataSize; break; //Trade case '$': retSize=pInstance->ProcessTradeChat(pData->pData, pData, pLir); break; //Alliance chat case '%': retSize=pData->dataSize; break; //Whisper case '"': //retSize=pInstance->ProcessWhisperChat(pData->pData, pData, pLir); retSize=pData->dataSize; break; //Commands case '/': retSize=pInstance->ProcessCommand(pData->pData, pData, pLir); break; } return retSize; } //If we just started connecting to an instance //We need to send our character information to the client int HandleOpcode_INSTANCE_LOAD_REQUEST_ITEMS(NetMessage* pData, PLAYER_DATA* pLir) { AccessInstance(pLir->instanceId)->SendCharacterInfo(pLir); gCoreLog.debug("CharInfo sent"); return 4; } //If the client wants the 18 byte packet with ? in it int HandleOpcode_INSTANCE_LOAD_REQUEST_SPAWN_POINT(NetMessage* pData, PLAYER_DATA* pLir) { Player* pPlayer=(Player*)pLir->pPlayer; Instance* pInstance=AccessInstance(pLir->instanceId); Agent* pAgent=pPlayer->GetAgent(); pPlayer->StartCharInfoTimer(); if (!pPlayer->GetFlag(SPAWN_PACKET_SENT)) { unsigned char retp[18]; memset(&retp[0], 0, 18); retp[0] = ServerOpcode(19) & 0xFF; retp[1] = 0x01; memcpy(&retp[2], &ZoneInfos[pInstance->GetZoneInfoSlot()].zoneLocation, 4); memcpy(&retp[6], &ZoneInfos[pInstance->GetZoneInfoSlot()].spawnX, 4); memcpy(&retp[10], &ZoneInfos[pInstance->GetZoneInfoSlot()].spawnY, 4); pAgent->SetCurrentPosition(Vertex(ZoneInfos[pInstance->GetZoneInfoSlot()].spawnX, ZoneInfos[pInstance->GetZoneInfoSlot()].spawnY, 0)); NetMessage s; s.networkId=pData->networkId; s.pData = retp; s.dataSize = 18; gpGameServer->SendData(&s); pPlayer->SetFlag(SPAWN_PACKET_SENT, true); pPlayer->SetPingTimeSent(1); } return 2; } //If the client wants the zone information now int HandleOpcode_INSTANCE_LOAD_REQUEST_ZONE_DATA(NetMessage* pData, PLAYER_DATA* pLir) { Instance* pInstance=AccessInstance(pLir->instanceId); if (true) { pInstance->InitZoneStream(pLir); } else { NetMessage s; s.networkId=pData->networkId; PacketMan pman; pman.Load("Data/Packets/TempZone/"); gCoreLog.debug("Sending zone information for zone: %d", pInstance->GetZoneId()); srand(TimerGetTime()); pman.DirSwitch("Data/Packets/TempZone/"); while((s.pData=pman.GetData("datacomp", &s.dataSize, 2919))!=NULL) { //CoreLog.LogKnownData("datacomp", s->data, s->dataSize); gpGameServer->SendData(&s); }//*/ } return 2; } //Check if the client is asking for a CLIENT_IM_HERE packet int HandleOpcode_REQUEST_SERVER_IM_HERE(NetMessage* pData, PLAYER_DATA* pLir) { Player* pPlayer=(Player*)pLir->pPlayer; pPlayer->SetPingTimeSent(1); return 2; } //Process ping int HandleOpcode_PING(NetMessage* pData, PLAYER_DATA* pLir) { Player* pPlayer=(Player*)pLir->pPlayer; if (pPlayer!=NULL) { CompiledPacket pck; pck.AddShort(ServerOpcode(43)); pck.AddLong(pData->extra1-pLir->pingTimer); NetMessage s; s.networkId=pLir->networkId; pPlayer->CreateCih(&pck, &s); pPlayer->mLastPing=pData->extra1-pLir->pingTimer; } return 6; } //Check for movement packets //This assumes all locations are allowed int HandleOpcode_CLICK_LOCATION(NetMessage* pData, PLAYER_DATA* pLir) { Player* pPlayer=(Player*)pLir->pPlayer; Agent* pAgent=pPlayer->GetAgent(); Vertex pos(Read_Float(pData->pData+2), Read_Float(pData->pData+6), Read_Float(pData->pData+10)); pAgent->GotoLocation(pos, true); //Debugging /*char mess[250]; sprintf(mess, "CTL(%f, %f, %f)", pos.x, pos.y, pos.z); ConsoleWrite(mess, false, p->GetnetworkId(), 5);//*/ /* if (GetAgentID()==8002) { Instance *ins=AccessInstance(GetLir()->instanceID); ins->SpawnGhost("W/Mo", pos); }//*/ return 14; } //check for keyboard movement packets int HandleOpcode_KEYBOARD_MOVE(NetMessage* pData, PLAYER_DATA* pLir) { Player* pPlayer=(Player*)pLir->pPlayer; Agent* pAgent=pPlayer->GetAgent(); Vertex pos(Read_Float(pData->pData+2), Read_Float(pData->pData+6), Read_Float(pData->pData+10)); Vertex delta(Read_Float(pData->pData+14), Read_Float(pData->pData+18)); int moveType=pData->pData[22]; pAgent->MoveKeyboard(&pos, &delta, moveType); return 26; } int HandleOpcode_KEYBOARD_MOVE_CLIENT_STOP(NetMessage* pData, PLAYER_DATA* pLir) { Player* pPlayer=(Player*)pLir->pPlayer; Agent* pAgent=pPlayer->GetAgent(); Vertex clientPos(Read_Float(pData->pData+2), Read_Float(pData->pData+6), Read_Float(pData->pData+10)); pAgent->StopMovement(&clientPos); //agent->StopMovement(NULL); return 14; } //Check for keyboard rotation int HandleOpcode_KEYBOARD_ROTATE(NetMessage* pData, PLAYER_DATA* pLir) { Player* pPlayer=(Player*)pLir->pPlayer; Agent* pAgent=pPlayer->GetAgent(); Vertex rotation(Read_Float(pData->pData+2), Read_Float(pData->pData+6)); pAgent->RotateAgent(rotation); return 10; } //Process the logout packet int HandleOpcode_LOGOUT(NetMessage* pData, PLAYER_DATA* pLir) { if (pLir->instanceId>0) { //Create the logout packet // *GS_LOGOUT (byte) // *4 // *AccountID if (!pLir->flags.test(LD_CHANGING_MAP)) { CompiledPacket pck; pck.AddByte(GS_LOGOUT); pck.AddByte(4); pck.AddLong(pLir->accountId); NetMessage is; is.networkId=gpInternalComm->GetClientModeId(); is.pData=pck.GetString(&is.dataSize); gpInternalComm->SendData(&is); pck.Clear(); } } gpGameServer->Kick(pData->networkId); return true; }