void ClusterInterface::HandlePackedPlayerInfo(WorldPacket & pck) { uint32 real_size; pck >> real_size; uLongf rsize = real_size; ByteBuffer buf(real_size); buf.resize(real_size); if(uncompress((uint8*)buf.contents(), &rsize, pck.contents() + 4, (u_long)pck.size() - 4) != Z_OK) { printf("Uncompress of player info failed.\n"); return; } RPlayerInfo * pi; uint32 count; buf >> count; for(uint32 i = 0; i < count; ++i) { pi = new RPlayerInfo; pi->Unpack(buf); _onlinePlayers[pi->Guid] = pi; } }
void ClusterInterface::HandlePlayerInfo(WorldPacket & pck) { uint32 guid; pck >> guid; RPlayerInfo * pRPlayer = GetPlayer(guid); if(!pRPlayer) pRPlayer = new RPlayerInfo; pRPlayer->Unpack(pck); _onlinePlayers[pRPlayer->Guid] = pRPlayer; }
void ClusterInterface::HandlePackedPlayerInfo(WorldPacket & pck) { RPlayerInfo * pi; // todo: uncompress uint32 count; pck >> count; for(uint32 i = 0; i < count; ++i) { pi = new RPlayerInfo; pi->Unpack(pck); _onlinePlayers[pi->Guid] = pi; } }
bool HandlePlayerInfoCommand(BaseConsole * pConsole, int argc, const char * argv[]) { if(argc < 2) return false; RPlayerInfo* plr = sClientMgr.GetRPlayer(std::string(argv[1])); if( plr == NULL || plr->GetSession() == NULL ) { pConsole->Write("Player not found.\r\n"); return true; } pConsole->Write("Player: %s\r\n", plr->Name); pConsole->Write("IP: %s\r\n", plr->GetSession()->GetSocket() ? plr->GetSession()->GetSocket()->GetRemoteIP().c_str() : "disconnected"); pConsole->Write("Level: %u\r\n", plr->Level); pConsole->Write("Account: %s\r\n", plr->GetSession()->GetAccountName()); return true; }
void ClientMgr::SendPackedClientInfo(WServer * server) { if(!m_clients.size()) return; WorldPacket data(ISMSG_PACKED_PLAYER_INFO, sizeof(RPlayerInfo) * m_clients.size() + 4); data << uint32(m_clients.size()); /* pack them all togther, w000t! */ ClientMap::iterator itr = m_clients.begin(); RPlayerInfo * pi; for(; itr != m_clients.end(); ++itr) { pi = itr->second; pi->Pack(data); } /* TODO: compress the packet */ server->SendPacket(&data); }
bool HandleKickCommand(BaseConsole * pConsole, int argc, const char * argv[]) { if(argc < 3) return false; RPlayerInfo* pPlayer; pPlayer = sClientMgr.GetRPlayer(std::string(argv[1])); if( pPlayer == NULL || pPlayer->GetSession() == NULL) { pConsole->Write("Could not find player, %s.\r\n", argv[1]); return true; } //bye f****r :D pPlayer->GetSession()->GetSocket()->Disconnect(); pConsole->Write("Kicked player %s.\r\n", pPlayer->Name); return true; }
bool HandleKickCommand(BaseConsole * pConsole, int argc, const char * argv[]) { if(argc < 3) return false; RPlayerInfo* pPlayer; pPlayer = sClientMgr.GetRPlayer(std::string(argv[1])); if( pPlayer == NULL || pPlayer->GetSession() == NULL) { pConsole->Write("Could not find player, %s.\r\n", argv[1]); return true; } //bye f****r :D pPlayer->GetSession()->GetSocket()->Disconnect(); /* char pAnnounce[1024]; Player* pPlayer; pPlayer = objmgr.GetPlayer(argv[1]); if( pPlayer == NULL ) { pConsole->Write("Could not find player, %s.\r\n", argv[1]); return true; } string outstr; ConcatArgs(outstr, argc, 1, argv); snprintf(pAnnounce, 1024, "%sConsole:|r %s was kicked from the server for: %s.", MSG_COLOR_LIGHTBLUE, pPlayer->GetName(), argv[2]); pPlayer->BroadcastMessage("You were kicked by the console for: %s", argv[2]); sWorld.SendWorldText(pAnnounce, NULL); pPlayer->Kick(5000);*/ pConsole->Write("Kicked player %s.\r\n", pPlayer->Name); return true; }
void ClientMgr::SendPackedClientInfo(WServer * server) { if(!m_clients.size()) return; ByteBuffer uncompressed(40000 * 19 + 8); uncompressed << uint32(m_clients.size()); /* pack them all togther, w000t! */ ClientMap::iterator itr = m_clients.begin(); RPlayerInfo * pi; for(; itr != m_clients.end(); ++itr) { pi = itr->second; pi->Pack(uncompressed); } // I still got no idea where this came from :p size_t destsize = uncompressed.size() + uncompressed.size()/10 + 16; WorldPacket data(ISMSG_PACKED_PLAYER_INFO, destsize + 4); data.resize(destsize + 4); z_stream stream; stream.zalloc = 0; stream.zfree = 0; stream.opaque = 0; if(deflateInit(&stream, 1) != Z_OK) { printf("deflateInit failed."); return; } // set up stream pointers stream.next_out = (Bytef*)((uint8*)data.contents())+4; stream.avail_out = (uInt)destsize; stream.next_in = (Bytef*)uncompressed.contents(); stream.avail_in = (uInt)uncompressed.size(); // call the actual process if(deflate(&stream, Z_NO_FLUSH) != Z_OK || stream.avail_in != 0) { printf("deflate failed."); return; } // finish the deflate if(deflate(&stream, Z_FINISH) != Z_STREAM_END) { printf("deflate failed: did not end stream"); return; } // finish up if(deflateEnd(&stream) != Z_OK) { printf("deflateEnd failed."); return; } // put real size at the beginning of the packet *(uint32*)data.contents() = (uint32)uncompressed.size(); data.resize(stream.total_out + 4); server->SendPacket(&data); }
void ClusterInterface::HandleTeleportResult(WorldPacket & pck) { uint32 sessionid; uint8 result; uint32 mapid, instanceid; LocationVector vec; float o; pck >> sessionid; WorldSession* s = GetSession(sessionid); if (!s) { //tell the realm-server we have no session WorldPacket data(ICMSG_ERROR_HANDLER, 5); data << uint8(1); //1 = no session data << sessionid; sClusterInterface.SendPacket(&data); return; } pck >> result >> mapid >> instanceid >> vec >> o; //the destination is on the same server if (result == 1) { if (s->GetPlayer() != NULL) sEventMgr.AddEvent(s->GetPlayer(), &Player::EventClusterMapChange, mapid, instanceid, vec, EVENT_UNK, 1, 1, EVENT_FLAG_DO_NOT_EXECUTE_IN_WORLD_CONTEXT); } else { //make this non-async, needs redone to support packing the player //since were saving it HAS TO BE HERE so the new server has the correct data WorldPacket nw(SMSG_NEW_WORLD); nw << mapid << vec << o; s->SendPacket(&nw); uint32 oldmapid = s->GetPlayer()->GetMapId(); uint32 oldinstanceid = s->GetPlayer()->GetInstanceID(); uint32 playerlowguid = s->GetPlayer()->GetLowGUID(); s->GetPlayer()->SetMapId(mapid); s->GetPlayer()->SetInstanceID(instanceid); s->GetPlayer()->SetPosition(vec.x, vec.y, vec.z, o); s->GetPlayer()->SaveToDB(true); //need to shift back to old ones for removing from world :) s->GetPlayer()->SetMapId(oldmapid); s->GetPlayer()->SetInstanceID(oldinstanceid); WorldPacket data(ICMSG_SWITCH_SERVER, 100); data << sessionid << playerlowguid << mapid << instanceid << vec << o; sClusterInterface.SendPacket(&data); RPlayerInfo * pRPlayer = GetPlayer(playerlowguid); bool newRplr = false; if(pRPlayer == NULL) { pRPlayer = new RPlayerInfo; newRplr = true; } s->GetPlayer()->UpdateRPlayerInfo(pRPlayer, newRplr); pRPlayer->MapId = mapid; pRPlayer->InstanceId = instanceid; data.Initialize(ICMSG_PLAYER_INFO); pRPlayer->Pack(data); sClusterInterface.SendPacket(&data); sEventMgr.AddEvent(s->GetPlayer(), &Player::HandleClusterRemove, EVENT_UNK, 1, 1, EVENT_FLAG_DO_NOT_EXECUTE_IN_WORLD_CONTEXT); } }
void WServer::HandleTeleportRequest(WorldPacket & pck) { WorldPacket data(ISMSG_TELEPORT_RESULT, 100); RPlayerInfo * pi; Session * s; Instance * dest; uint32 mapid, sessionid, instanceid; /* this packet is only used upon changing main maps! */ pck >> sessionid >> mapid >> instanceid; s = sClientMgr.GetSession(sessionid); if(s) { pi = s->GetPlayer(); ASSERT(pi); /* find the destination server */ if(instanceid == 0) dest = sClusterMgr.GetInstanceByMapId(mapid); else dest = sClusterMgr.GetInstanceByInstanceId(instanceid); /* server up? */ if(!dest) { data.Initialize(SMSG_TRANSFER_ABORTED); data << uint32(0x02); // INSTANCE_ABORT_NOT_FOUND s->SendPacket(&data); } else { /* server found! */ LocationVector vec; pck >> vec >> vec.o; pi->MapId = mapid; pi->InstanceId = dest->InstanceId; pi->PositionX = vec.x; pi->PositionY = vec.y; if(dest->Server == s->GetServer()) { /* we're not changing servers, the new instance is on the same server */ data << sessionid << uint8(1) << mapid << instanceid << vec << vec.o; SendPacket(&data); } else { /* notify the old server to pack the player info together to send to the new server, and delete the player */ data << sessionid << uint8(0) << mapid << instanceid << vec << vec.o; SendPacket(&data); } data.Initialize(ISMSG_PLAYER_INFO); pi->Pack(data); sClusterMgr.DistributePacketToAll(&data, this); data.Initialize(SMSG_NEW_WORLD); data << mapid << vec << vec.o; s->SendPacket(&data); } } }
void WServer::HandleTeleportRequest(WorldPacket & pck) { WorldPacket data(ISMSG_TELEPORT_RESULT, 100); RPlayerInfo * pi; Session * s; Instance * dest; uint32 mapid, sessionid, instanceid; /* this packet is only used upon changing main maps! */ pck >> sessionid >> mapid >> instanceid; DEBUG_LOG("TeleportRequest", "session %u, mapid %u, instanceid %u", sessionid, mapid, instanceid); s = sClientMgr.GetSession(sessionid); if(s) { pi = s->GetPlayer(); ASSERT(pi); if(IS_MAIN_MAP(mapid) || instanceid == 0) { /* we're on a continent, try to find the world server we're going to */ dest = sClusterMgr.GetInstanceByMapId(mapid); } else { /* we're in an instanced map, try to find the world server we're going to */ dest = sClusterMgr.GetInstanceByInstanceId(instanceid); } //try and find a prototype instance, and its server if (dest == NULL) { DEBUG_LOG("TeleportRequest", "Could not find instance, will use prototype..."); dest = sClusterMgr.GetPrototypeInstanceByMapId(mapid); } /* server up? */ if(!dest) { DEBUG_LOG("TeleportRequest", "INSTANCE_ABORT_NOT_FOUND"); data.Initialize(SMSG_TRANSFER_ABORTED); data << uint32(0x02); // INSTANCE_ABORT_NOT_FOUND s->SendPacket(&data); } else { /* server found! */ LocationVector vec; pck >> vec >> vec.o; pi->MapId = mapid; pi->InstanceId = dest->InstanceId; pi->PositionX = vec.x; pi->PositionY = vec.y; if(dest->Server == s->GetServer()) { DEBUG_LOG("TeleportRequest", "intra-server teleport"); /* we're not changing servers, the new instance is on the same server */ data << sessionid << uint8(1) << mapid << instanceid << vec << vec.o; SendPacket(&data); } else { DEBUG_LOG("TeleportRequest", "inter-server teleport"); /* notify the old server to pack the player info together to send to the new server, and delete the player */ data << sessionid << uint8(0) << mapid << instanceid << vec << vec.o; //cache this to next server and switch servers when were ready :P s->SetNextServer(dest->Server); SendPacket(&data); } data.Initialize(ISMSG_PLAYER_INFO); pi->Pack(data); sClusterMgr.DistributePacketToAll(&data, this); data.Initialize(SMSG_NEW_WORLD); data << mapid << vec << vec.o; s->SendPacket(&data); } } }