// *************************************************************** // Function: MapChangeRequest.cpp // *************************************************************** #include "Main.h" #include "../../src/SharedStructures.h" #include "../../src/IC.h" #include "LocalData.h" #include "GameServerData.h" GAMESERVER_DATA* GetOptimalGameSrv(); //************************************ // Name: ProcessMapChangeRequest // // Allows or denies a map change request from the GS // // Parameters: // pData - Network data // // Return: // //************************************ void ProcessMapChangeRequest(NetMessage* pData) { REQUEST_MAP_CHANGE r; Read_Struct(pData->pData+2, &r, sizeof(REQUEST_MAP_CHANGE)); LOCAL_DATA* pLir=AccessLocalData(r.asNetworkId); if (pLir!=NULL) { //Make sure the specified networkID is authenticated if (BIT_TEST(pLir->bitfield, LD_AUTHENTICATED)==false) { gpLoginServer->Kick(pLir->networkId); } //We should verify that we can change zones if (false) { gpLoginServer->Kick(pLir->networkId); return; } //Set the new information pLir->zoneId=r.zoneId; //Get a game server GAMESERVER_DATA *opt_game_serv=GetOptimalGameSrv(); if (opt_game_serv!=NULL && !(pLir->accessLevel==50 && gServerStatus.adminLock)) { BIT_SET(pLir->bitfield, LD_LOAD_INTO_INSTANCE); char random_long[4]; for (int n=0; n<4; n++){random_long[n]=rand()%256;} memcpy(&pLir->transferId1, random_long, 4); for (int n=0; n<4; n++){random_long[n]=rand()%256;} memcpy(&pLir->transferId2, random_long, 4); CHANGE_MAP c; c.transferId1=pLir->transferId1; c.transferId2=pLir->transferId2; c.zoneId=pLir->zoneId; c.gsNetworkId=r.gsNetworkId; c.timesZoned=pLir->timesZoned; memcpy(c.ip, opt_game_serv->ip, 4); unsigned char pck[sizeof(CHANGE_MAP)+2]; NetMessage s; s.networkId=pData->networkId; s.pData=pck; s.dataSize=PreparePacket(LS_CHANGE_MAP, &c, sizeof(CHANGE_MAP), pck); gpInternalComm->SendData(&s); BIT_SET(pLir->bitfield, LD_DISPATCHED); opt_game_serv->currentPlayers++; pLir->gameServerId=0; pLir->timesZoned++; } //No game servers available else { gpLoginServer->Kick(pLir->networkId); pLir->gameServerId=0; } } }