mirror of
https://github.com/OpenFusionProject/OpenFusion.git
synced 2025-09-28 18:57:35 +00:00
major refactoring
This commit is contained in:
@@ -48,10 +48,10 @@ void PlayerManager::removePlayer(CNSocket* key) {
|
||||
players[otherSock].viewable.remove(key); // gone
|
||||
|
||||
// now sent PC_EXIT packet
|
||||
sP_FE2CL_PC_EXIT* exitPacket = (sP_FE2CL_PC_EXIT*)xmalloc(sizeof(sP_FE2CL_PC_EXIT));
|
||||
exitPacket->iID = players[key].plr.iID;
|
||||
sP_FE2CL_PC_EXIT exitPacket;
|
||||
exitPacket.iID = players[key].plr.iID;
|
||||
|
||||
otherSock->sendPacket(new CNPacketData((void*)exitPacket, P_FE2CL_PC_EXIT, sizeof(sP_FE2CL_PC_EXIT), otherSock->getFEKey()));
|
||||
otherSock->sendPacket((void*)&exitPacket, P_FE2CL_PC_EXIT, sizeof(sP_FE2CL_PC_EXIT));
|
||||
}
|
||||
|
||||
players.erase(key);
|
||||
@@ -88,21 +88,20 @@ void PlayerManager::updatePlayerPosition(CNSocket* sock, int X, int Y, int Z) {
|
||||
}
|
||||
}
|
||||
|
||||
sP_FE2CL_PC_EXIT exitPacket;
|
||||
|
||||
std::list<CNSocket*>::iterator i = players[sock].viewable.begin();
|
||||
while (i != players[sock].viewable.end()) {
|
||||
CNSocket* otherSock = *i;
|
||||
if (std::find(noView.begin(), noView.end(), otherSock) != noView.end()) {
|
||||
// sock shouldn't be visible, send PC_EXIT packet & remove them
|
||||
|
||||
sP_FE2CL_PC_EXIT* exitPacket = (sP_FE2CL_PC_EXIT*)xmalloc(sizeof(sP_FE2CL_PC_EXIT));
|
||||
sP_FE2CL_PC_EXIT* exitPacketOther = (sP_FE2CL_PC_EXIT*)xmalloc(sizeof(sP_FE2CL_PC_EXIT));
|
||||
|
||||
exitPacket->iID = players[sock].plr.iID;
|
||||
exitPacketOther->iID = players[otherSock].plr.iID;
|
||||
|
||||
otherSock->sendPacket(new CNPacketData((void*)exitPacket, P_FE2CL_PC_EXIT, sizeof(sP_FE2CL_PC_EXIT), otherSock->getFEKey()));
|
||||
sock->sendPacket(new CNPacketData((void*)exitPacketOther, P_FE2CL_PC_EXIT, sizeof(sP_FE2CL_PC_EXIT), sock->getFEKey()));
|
||||
// sock shouldn't be visible, send PC_EXIT packet
|
||||
exitPacket.iID = players[sock].plr.iID;
|
||||
otherSock->sendPacket((void*)&exitPacket, P_FE2CL_PC_EXIT, sizeof(sP_FE2CL_PC_EXIT));
|
||||
exitPacket.iID = players[otherSock].plr.iID;
|
||||
sock->sendPacket((void*)&exitPacket, P_FE2CL_PC_EXIT, sizeof(sP_FE2CL_PC_EXIT));
|
||||
|
||||
// remove them from the viewable list
|
||||
players[sock].viewable.erase(i++);
|
||||
players[otherSock].viewable.remove(sock);
|
||||
continue;
|
||||
@@ -111,38 +110,37 @@ void PlayerManager::updatePlayerPosition(CNSocket* sock, int X, int Y, int Z) {
|
||||
++i;
|
||||
}
|
||||
|
||||
sP_FE2CL_PC_NEW newPlayer;
|
||||
for (CNSocket* otherSock : yesView) {
|
||||
if (std::find(players[sock].viewable.begin(), players[sock].viewable.end(), otherSock) == players[sock].viewable.end()) {
|
||||
// this needs to be added to the viewable players, send PC_ENTER
|
||||
|
||||
sP_FE2CL_PC_NEW* newPlayer = (sP_FE2CL_PC_NEW*)xmalloc(sizeof(sP_FE2CL_PC_NEW)); // current connection to other player
|
||||
sP_FE2CL_PC_NEW* newOtherPlayer = (sP_FE2CL_PC_NEW*)xmalloc(sizeof(sP_FE2CL_PC_NEW)); // other player to current connection
|
||||
|
||||
Player otherPlr = players[otherSock].plr;
|
||||
Player plr = players[sock].plr;
|
||||
|
||||
newPlayer->PCAppearanceData.iID = plr.iID;
|
||||
newPlayer->PCAppearanceData.iHP = plr.HP;
|
||||
newPlayer->PCAppearanceData.iLv = plr.level;
|
||||
newPlayer->PCAppearanceData.iX = plr.x;
|
||||
newPlayer->PCAppearanceData.iY = plr.y;
|
||||
newPlayer->PCAppearanceData.iZ = plr.z;
|
||||
newPlayer->PCAppearanceData.iAngle = plr.angle;
|
||||
newPlayer->PCAppearanceData.PCStyle = plr.PCStyle;
|
||||
memcpy(newPlayer->PCAppearanceData.ItemEquip, plr.Equip, sizeof(sItemBase) * AEQUIP_COUNT);
|
||||
newPlayer.PCAppearanceData.iID = plr.iID;
|
||||
newPlayer.PCAppearanceData.iHP = plr.HP;
|
||||
newPlayer.PCAppearanceData.iLv = plr.level;
|
||||
newPlayer.PCAppearanceData.iX = plr.x;
|
||||
newPlayer.PCAppearanceData.iY = plr.y;
|
||||
newPlayer.PCAppearanceData.iZ = plr.z;
|
||||
newPlayer.PCAppearanceData.iAngle = plr.angle;
|
||||
newPlayer.PCAppearanceData.PCStyle = plr.PCStyle;
|
||||
memcpy(newPlayer.PCAppearanceData.ItemEquip, plr.Equip, sizeof(sItemBase) * AEQUIP_COUNT);
|
||||
|
||||
newOtherPlayer->PCAppearanceData.iID = otherPlr.iID;
|
||||
newOtherPlayer->PCAppearanceData.iHP = otherPlr.HP;
|
||||
newOtherPlayer->PCAppearanceData.iLv = otherPlr.level;
|
||||
newOtherPlayer->PCAppearanceData.iX = otherPlr.x;
|
||||
newOtherPlayer->PCAppearanceData.iY = otherPlr.y;
|
||||
newOtherPlayer->PCAppearanceData.iZ = otherPlr.z;
|
||||
newOtherPlayer->PCAppearanceData.iAngle = otherPlr.angle;
|
||||
newOtherPlayer->PCAppearanceData.PCStyle = otherPlr.PCStyle;
|
||||
memcpy(newOtherPlayer->PCAppearanceData.ItemEquip, otherPlr.Equip, sizeof(sItemBase) * AEQUIP_COUNT);
|
||||
otherSock->sendPacket((void*)&newPlayer, P_FE2CL_PC_NEW, sizeof(sP_FE2CL_PC_NEW));
|
||||
|
||||
sock->sendPacket(new CNPacketData((void*)newOtherPlayer, P_FE2CL_PC_NEW, sizeof(sP_FE2CL_PC_NEW), sock->getFEKey()));
|
||||
otherSock->sendPacket(new CNPacketData((void*)newPlayer, P_FE2CL_PC_NEW, sizeof(sP_FE2CL_PC_NEW), otherSock->getFEKey()));
|
||||
newPlayer.PCAppearanceData.iID = otherPlr.iID;
|
||||
newPlayer.PCAppearanceData.iHP = otherPlr.HP;
|
||||
newPlayer.PCAppearanceData.iLv = otherPlr.level;
|
||||
newPlayer.PCAppearanceData.iX = otherPlr.x;
|
||||
newPlayer.PCAppearanceData.iY = otherPlr.y;
|
||||
newPlayer.PCAppearanceData.iZ = otherPlr.z;
|
||||
newPlayer.PCAppearanceData.iAngle = otherPlr.angle;
|
||||
newPlayer.PCAppearanceData.PCStyle = otherPlr.PCStyle;
|
||||
memcpy(newPlayer.PCAppearanceData.ItemEquip, otherPlr.Equip, sizeof(sItemBase) * AEQUIP_COUNT);
|
||||
|
||||
sock->sendPacket((void*)&newPlayer, P_FE2CL_PC_NEW, sizeof(sP_FE2CL_PC_NEW));
|
||||
|
||||
players[sock].viewable.push_back(otherSock);
|
||||
players[otherSock].viewable.push_back(sock);
|
||||
@@ -157,8 +155,8 @@ void PlayerManager::enterPlayer(CNSocket* sock, CNPacketData* data) {
|
||||
return; // ignore the malformed packet
|
||||
|
||||
sP_CL2FE_REQ_PC_ENTER* enter = (sP_CL2FE_REQ_PC_ENTER*)data->buf;
|
||||
sP_FE2CL_REP_PC_ENTER_SUCC* response = (sP_FE2CL_REP_PC_ENTER_SUCC*)xmalloc(sizeof(sP_FE2CL_REP_PC_ENTER_SUCC));
|
||||
sP_FE2CL_PC_MOTD_LOGIN* motd = (sP_FE2CL_PC_MOTD_LOGIN*)xmalloc(sizeof(sP_FE2CL_PC_MOTD_LOGIN));
|
||||
sP_FE2CL_REP_PC_ENTER_SUCC response;
|
||||
sP_FE2CL_PC_MOTD_LOGIN motd;
|
||||
|
||||
// TODO: check if serialkey exists, if it doesn't send sP_FE2CL_REP_PC_ENTER_FAIL
|
||||
Player plr = CNSharedData::getPlayer(enter->iEnterSerialKey);
|
||||
@@ -171,69 +169,57 @@ void PlayerManager::enterPlayer(CNSocket* sock, CNPacketData* data) {
|
||||
std::cout << "\tPC_UID: " << plr.PCStyle.iPC_UID << std::endl;
|
||||
)
|
||||
|
||||
response->iID = rand();
|
||||
response->uiSvrTime = getTime();
|
||||
response->PCLoadData2CL.iUserLevel = 1;
|
||||
response->PCLoadData2CL.iHP = 1000 * plr.level;
|
||||
response->PCLoadData2CL.iLevel = plr.level;
|
||||
response->PCLoadData2CL.iMentor = 1;
|
||||
response->PCLoadData2CL.iMentorCount = 4;
|
||||
response->PCLoadData2CL.iMapNum = 0;
|
||||
response->PCLoadData2CL.iX = plr.x;
|
||||
response->PCLoadData2CL.iY = plr.y;
|
||||
response->PCLoadData2CL.iZ = plr.z;
|
||||
response->PCLoadData2CL.iActiveNanoSlotNum = -1;
|
||||
response->PCLoadData2CL.iFatigue = 50;
|
||||
response->PCLoadData2CL.PCStyle = plr.PCStyle;
|
||||
response->PCLoadData2CL.PCStyle2 = plr.PCStyle2;
|
||||
response.iID = rand();
|
||||
response.uiSvrTime = getTime();
|
||||
response.PCLoadData2CL.iUserLevel = 1;
|
||||
response.PCLoadData2CL.iHP = 1000 * plr.level;
|
||||
response.PCLoadData2CL.iLevel = plr.level;
|
||||
response.PCLoadData2CL.iMentor = 1;
|
||||
response.PCLoadData2CL.iMentorCount = 4;
|
||||
response.PCLoadData2CL.iMapNum = 0;
|
||||
response.PCLoadData2CL.iX = plr.x;
|
||||
response.PCLoadData2CL.iY = plr.y;
|
||||
response.PCLoadData2CL.iZ = plr.z;
|
||||
response.PCLoadData2CL.iActiveNanoSlotNum = -1;
|
||||
response.PCLoadData2CL.iFatigue = 50;
|
||||
response.PCLoadData2CL.PCStyle = plr.PCStyle;
|
||||
response.PCLoadData2CL.PCStyle2 = plr.PCStyle2;
|
||||
|
||||
for (int i = 0; i < AEQUIP_COUNT; i++)
|
||||
response->PCLoadData2CL.aEquip[i] = plr.Equip[i];
|
||||
response.PCLoadData2CL.aEquip[i] = plr.Equip[i];
|
||||
|
||||
// protocol-agnostic sItemBase usage
|
||||
sItemBase item;
|
||||
memset(&item, 0, sizeof(sItemBase));
|
||||
item.iID = 495;
|
||||
|
||||
for (int i = 0; i < AINVEN_COUNT; i++) {
|
||||
switch (i) {
|
||||
case 6: case 8: case 11: case 13: case 20:
|
||||
case 24: case 26: case 27: case 28:
|
||||
plr.Inven[i] = item;
|
||||
break;
|
||||
default:
|
||||
memset(&plr.Inven[i], 0, sizeof(sItemBase));
|
||||
}
|
||||
response->PCLoadData2CL.aInven[i] = plr.Inven[i];
|
||||
}
|
||||
for (int i = 0; i < AINVEN_COUNT; i++)
|
||||
response.PCLoadData2CL.aInven[i] = plr.Inven[i];
|
||||
|
||||
// don't ask..
|
||||
for (int i = 1; i < 37; i++) {
|
||||
response->PCLoadData2CL.aNanoBank[i].iID = i;
|
||||
response->PCLoadData2CL.aNanoBank[i].iSkillID = 1;
|
||||
response->PCLoadData2CL.aNanoBank[i].iStamina = 150;
|
||||
response.PCLoadData2CL.aNanoBank[i].iID = i;
|
||||
response.PCLoadData2CL.aNanoBank[i].iSkillID = 1;
|
||||
response.PCLoadData2CL.aNanoBank[i].iStamina = 150;
|
||||
}
|
||||
|
||||
// temporarily not add nanos for nano add test through commands
|
||||
//response->PCLoadData2CL.aNanoSlots[0] = 1;
|
||||
//response->PCLoadData2CL.aNanoSlots[1] = 2;
|
||||
//response->PCLoadData2CL.aNanoSlots[2] = 3;
|
||||
//response.PCLoadData2CL.aNanoSlots[0] = 1;
|
||||
//response.PCLoadData2CL.aNanoSlots[1] = 2;
|
||||
//response.PCLoadData2CL.aNanoSlots[2] = 3;
|
||||
|
||||
response->PCLoadData2CL.aQuestFlag[0] = -1;
|
||||
response.PCLoadData2CL.aQuestFlag[0] = -1;
|
||||
|
||||
plr.iID = response->iID;
|
||||
plr.iID = response.iID;
|
||||
plr.SerialKey = enter->iEnterSerialKey;
|
||||
plr.HP = response->PCLoadData2CL.iHP;
|
||||
plr.HP = response.PCLoadData2CL.iHP;
|
||||
|
||||
motd->iType = 1;
|
||||
U8toU16(settings::MOTDSTRING, (char16_t*)motd->szSystemMsg);
|
||||
motd.iType = 1;
|
||||
U8toU16(settings::MOTDSTRING, (char16_t*)motd.szSystemMsg);
|
||||
|
||||
sock->setEKey(CNSocketEncryption::createNewKey(response->uiSvrTime, response->iID + 1, response->PCLoadData2CL.iFusionMatter + 1));
|
||||
sock->setEKey(CNSocketEncryption::createNewKey(response.uiSvrTime, response.iID + 1, response.PCLoadData2CL.iFusionMatter + 1));
|
||||
sock->setFEKey(plr.FEKey);
|
||||
sock->setActiveKey(SOCKETKEY_FE); // send all packets using the FE key from now on
|
||||
|
||||
sock->sendPacket((void*)&response, P_FE2CL_REP_PC_ENTER_SUCC, sizeof(sP_FE2CL_REP_PC_ENTER_SUCC));
|
||||
|
||||
sock->sendPacket(new CNPacketData((void*)response, P_FE2CL_REP_PC_ENTER_SUCC, sizeof(sP_FE2CL_REP_PC_ENTER_SUCC), sock->getFEKey()));
|
||||
// transmit MOTD after entering the game, so the client hopefully changes modes on time
|
||||
sock->sendPacket(new CNPacketData((void*)motd, P_FE2CL_PC_MOTD_LOGIN, sizeof(sP_FE2CL_PC_MOTD_LOGIN), sock->getFEKey()));
|
||||
sock->sendPacket((void*)&motd, P_FE2CL_PC_MOTD_LOGIN, sizeof(sP_FE2CL_PC_MOTD_LOGIN));
|
||||
|
||||
addPlayer(sock, plr);
|
||||
}
|
||||
@@ -243,16 +229,16 @@ void PlayerManager::loadPlayer(CNSocket* sock, CNPacketData* data) {
|
||||
return; // ignore the malformed packet
|
||||
|
||||
sP_CL2FE_REQ_PC_LOADING_COMPLETE* complete = (sP_CL2FE_REQ_PC_LOADING_COMPLETE*)data->buf;
|
||||
sP_FE2CL_REP_PC_LOADING_COMPLETE_SUCC* response = (sP_FE2CL_REP_PC_LOADING_COMPLETE_SUCC*)xmalloc(sizeof(sP_FE2CL_REP_PC_LOADING_COMPLETE_SUCC));
|
||||
sP_FE2CL_REP_PC_LOADING_COMPLETE_SUCC response;
|
||||
|
||||
DEBUGLOG(
|
||||
std::cout << "P_CL2FE_REQ_PC_LOADING_COMPLETE:" << std::endl;
|
||||
std::cout << "\tPC_ID: " << complete->iPC_ID << std::endl;
|
||||
)
|
||||
|
||||
response->iPC_ID = complete->iPC_ID;
|
||||
response.iPC_ID = complete->iPC_ID;
|
||||
|
||||
sock->sendPacket(new CNPacketData((void*)response, P_FE2CL_REP_PC_LOADING_COMPLETE_SUCC, sizeof(sP_FE2CL_REP_PC_LOADING_COMPLETE_SUCC), sock->getFEKey()));
|
||||
sock->sendPacket((void*)&response, P_FE2CL_REP_PC_LOADING_COMPLETE_SUCC, sizeof(sP_FE2CL_REP_PC_LOADING_COMPLETE_SUCC));
|
||||
}
|
||||
|
||||
void PlayerManager::movePlayer(CNSocket* sock, CNPacketData* data) {
|
||||
@@ -265,25 +251,25 @@ void PlayerManager::movePlayer(CNSocket* sock, CNPacketData* data) {
|
||||
players[sock].plr.angle = moveData->iAngle;
|
||||
uint64_t tm = getTime();
|
||||
|
||||
sP_FE2CL_PC_MOVE moveResponse;
|
||||
|
||||
moveResponse.iID = players[sock].plr.iID;
|
||||
moveResponse.cKeyValue = moveData->cKeyValue;
|
||||
|
||||
moveResponse.iX = moveData->iX;
|
||||
moveResponse.iY = moveData->iY;
|
||||
moveResponse.iZ = moveData->iZ;
|
||||
moveResponse.iAngle = moveData->iAngle;
|
||||
moveResponse.fVX = moveData->fVX;
|
||||
moveResponse.fVY = moveData->fVY;
|
||||
moveResponse.fVZ = moveData->fVZ;
|
||||
|
||||
moveResponse.iSpeed = moveData->iSpeed;
|
||||
moveResponse.iCliTime = moveData->iCliTime; // maybe don't send this??? seems unneeded...
|
||||
moveResponse.iSvrTime = tm;
|
||||
|
||||
for (CNSocket* otherSock : players[sock].viewable) {
|
||||
sP_FE2CL_PC_MOVE* moveResponse = (sP_FE2CL_PC_MOVE*)xmalloc(sizeof(sP_FE2CL_PC_MOVE));
|
||||
|
||||
moveResponse->iID = players[sock].plr.iID;
|
||||
moveResponse->cKeyValue = moveData->cKeyValue;
|
||||
|
||||
moveResponse->iX = moveData->iX;
|
||||
moveResponse->iY = moveData->iY;
|
||||
moveResponse->iZ = moveData->iZ;
|
||||
moveResponse->iAngle = moveData->iAngle;
|
||||
moveResponse->fVX = moveData->fVX;
|
||||
moveResponse->fVY = moveData->fVY;
|
||||
moveResponse->fVZ = moveData->fVZ;
|
||||
|
||||
moveResponse->iSpeed = moveData->iSpeed;
|
||||
moveResponse->iCliTime = moveData->iCliTime; // maybe don't send this??? seems unneeded...
|
||||
moveResponse->iSvrTime = tm;
|
||||
|
||||
otherSock->sendPacket(new CNPacketData((void*)moveResponse, P_FE2CL_PC_MOVE, sizeof(sP_FE2CL_PC_MOVE), otherSock->getFEKey()));
|
||||
otherSock->sendPacket((void*)&moveResponse, P_FE2CL_PC_MOVE, sizeof(sP_FE2CL_PC_MOVE));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -296,19 +282,19 @@ void PlayerManager::stopPlayer(CNSocket* sock, CNPacketData* data) {
|
||||
|
||||
uint64_t tm = getTime();
|
||||
|
||||
sP_FE2CL_PC_STOP stopResponse;
|
||||
|
||||
stopResponse.iID = players[sock].plr.iID;
|
||||
|
||||
stopResponse.iX = stopData->iX;
|
||||
stopResponse.iY = stopData->iY;
|
||||
stopResponse.iZ = stopData->iZ;
|
||||
|
||||
stopResponse.iCliTime = stopData->iCliTime; // maybe don't send this??? seems unneeded...
|
||||
stopResponse.iSvrTime = tm;
|
||||
|
||||
for (CNSocket* otherSock : players[sock].viewable) {
|
||||
sP_FE2CL_PC_STOP* stopResponse = (sP_FE2CL_PC_STOP*)xmalloc(sizeof(sP_FE2CL_PC_STOP));
|
||||
|
||||
stopResponse->iID = players[sock].plr.iID;
|
||||
|
||||
stopResponse->iX = stopData->iX;
|
||||
stopResponse->iY = stopData->iY;
|
||||
stopResponse->iZ = stopData->iZ;
|
||||
|
||||
stopResponse->iCliTime = stopData->iCliTime; // maybe don't send this??? seems unneeded...
|
||||
stopResponse->iSvrTime = tm;
|
||||
|
||||
otherSock->sendPacket(new CNPacketData((void*)stopResponse, P_FE2CL_PC_STOP, sizeof(sP_FE2CL_PC_STOP), otherSock->getFEKey()));
|
||||
otherSock->sendPacket((void*)&stopResponse, P_FE2CL_PC_STOP, sizeof(sP_FE2CL_PC_STOP));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -321,25 +307,25 @@ void PlayerManager::jumpPlayer(CNSocket* sock, CNPacketData* data) {
|
||||
|
||||
uint64_t tm = getTime();
|
||||
|
||||
sP_FE2CL_PC_JUMP jumpResponse;
|
||||
|
||||
jumpResponse.iID = players[sock].plr.iID;
|
||||
jumpResponse.cKeyValue = jumpData->cKeyValue;
|
||||
|
||||
jumpResponse.iX = jumpData->iX;
|
||||
jumpResponse.iY = jumpData->iY;
|
||||
jumpResponse.iZ = jumpData->iZ;
|
||||
jumpResponse.iAngle = jumpData->iAngle;
|
||||
jumpResponse.iVX = jumpData->iVX;
|
||||
jumpResponse.iVY = jumpData->iVY;
|
||||
jumpResponse.iVZ = jumpData->iVZ;
|
||||
|
||||
jumpResponse.iSpeed = jumpData->iSpeed;
|
||||
jumpResponse.iCliTime = jumpData->iCliTime; // maybe don't send this??? seems unneeded...
|
||||
jumpResponse.iSvrTime = tm;
|
||||
|
||||
for (CNSocket* otherSock : players[sock].viewable) {
|
||||
sP_FE2CL_PC_JUMP* jumpResponse = (sP_FE2CL_PC_JUMP*)xmalloc(sizeof(sP_FE2CL_PC_JUMP));
|
||||
|
||||
jumpResponse->iID = players[sock].plr.iID;
|
||||
jumpResponse->cKeyValue = jumpData->cKeyValue;
|
||||
|
||||
jumpResponse->iX = jumpData->iX;
|
||||
jumpResponse->iY = jumpData->iY;
|
||||
jumpResponse->iZ = jumpData->iZ;
|
||||
jumpResponse->iAngle = jumpData->iAngle;
|
||||
jumpResponse->iVX = jumpData->iVX;
|
||||
jumpResponse->iVY = jumpData->iVY;
|
||||
jumpResponse->iVZ = jumpData->iVZ;
|
||||
|
||||
jumpResponse->iSpeed = jumpData->iSpeed;
|
||||
jumpResponse->iCliTime = jumpData->iCliTime; // maybe don't send this??? seems unneeded...
|
||||
jumpResponse->iSvrTime = tm;
|
||||
|
||||
otherSock->sendPacket(new CNPacketData((void*)jumpResponse, P_FE2CL_PC_JUMP, sizeof(sP_FE2CL_PC_JUMP), otherSock->getFEKey()));
|
||||
otherSock->sendPacket((void*)&jumpResponse, P_FE2CL_PC_JUMP, sizeof(sP_FE2CL_PC_JUMP));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -352,23 +338,23 @@ void PlayerManager::jumppadPlayer(CNSocket* sock, CNPacketData* data) {
|
||||
|
||||
uint64_t tm = getTime();
|
||||
|
||||
sP_FE2CL_PC_JUMPPAD jumppadResponse;
|
||||
|
||||
jumppadResponse.iPC_ID = players[sock].plr.iID;
|
||||
jumppadResponse.cKeyValue = jumppadData->cKeyValue;
|
||||
|
||||
jumppadResponse.iX = jumppadData->iX;
|
||||
jumppadResponse.iY = jumppadData->iY;
|
||||
jumppadResponse.iZ = jumppadData->iZ;
|
||||
jumppadResponse.iVX = jumppadData->iVX;
|
||||
jumppadResponse.iVY = jumppadData->iVY;
|
||||
jumppadResponse.iVZ = jumppadData->iVZ;
|
||||
|
||||
jumppadResponse.iCliTime = jumppadData->iCliTime;
|
||||
jumppadResponse.iSvrTime = tm;
|
||||
|
||||
for (CNSocket* otherSock : players[sock].viewable) {
|
||||
sP_FE2CL_PC_JUMPPAD* jumppadResponse = (sP_FE2CL_PC_JUMPPAD*)xmalloc(sizeof(sP_FE2CL_PC_JUMPPAD));
|
||||
|
||||
jumppadResponse->iPC_ID = players[sock].plr.iID;
|
||||
jumppadResponse->cKeyValue = jumppadData->cKeyValue;
|
||||
|
||||
jumppadResponse->iX = jumppadData->iX;
|
||||
jumppadResponse->iY = jumppadData->iY;
|
||||
jumppadResponse->iZ = jumppadData->iZ;
|
||||
jumppadResponse->iVX = jumppadData->iVX;
|
||||
jumppadResponse->iVY = jumppadData->iVY;
|
||||
jumppadResponse->iVZ = jumppadData->iVZ;
|
||||
|
||||
jumppadResponse->iCliTime = jumppadData->iCliTime;
|
||||
jumppadResponse->iSvrTime = tm;
|
||||
|
||||
otherSock->sendPacket(new CNPacketData((void*)jumppadResponse, P_FE2CL_PC_JUMPPAD, sizeof(sP_FE2CL_PC_JUMPPAD), otherSock->getFEKey()));
|
||||
otherSock->sendPacket((void*)&jumppadResponse, P_FE2CL_PC_JUMPPAD, sizeof(sP_FE2CL_PC_JUMPPAD));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -381,24 +367,24 @@ void PlayerManager::launchPlayer(CNSocket* sock, CNPacketData* data) {
|
||||
|
||||
uint64_t tm = getTime();
|
||||
|
||||
sP_FE2CL_PC_LAUNCHER launchResponse;
|
||||
|
||||
launchResponse.iPC_ID = players[sock].plr.iID;
|
||||
|
||||
launchResponse.iX = launchData->iX;
|
||||
launchResponse.iY = launchData->iY;
|
||||
launchResponse.iZ = launchData->iZ;
|
||||
launchResponse.iVX = launchData->iVX;
|
||||
launchResponse.iVY = launchData->iVY;
|
||||
launchResponse.iVZ = launchData->iVZ;
|
||||
launchResponse.iSpeed = launchData->iSpeed;
|
||||
launchResponse.iAngle = launchData->iAngle;
|
||||
|
||||
launchResponse.iCliTime = launchData->iCliTime;
|
||||
launchResponse.iSvrTime = tm;
|
||||
|
||||
for (CNSocket* otherSock : players[sock].viewable) {
|
||||
sP_FE2CL_PC_LAUNCHER* launchResponse = (sP_FE2CL_PC_LAUNCHER*)xmalloc(sizeof(sP_FE2CL_PC_LAUNCHER));
|
||||
|
||||
launchResponse->iPC_ID = players[sock].plr.iID;
|
||||
|
||||
launchResponse->iX = launchData->iX;
|
||||
launchResponse->iY = launchData->iY;
|
||||
launchResponse->iZ = launchData->iZ;
|
||||
launchResponse->iVX = launchData->iVX;
|
||||
launchResponse->iVY = launchData->iVY;
|
||||
launchResponse->iVZ = launchData->iVZ;
|
||||
launchResponse->iSpeed = launchData->iSpeed;
|
||||
launchResponse->iAngle = launchData->iAngle;
|
||||
|
||||
launchResponse->iCliTime = launchData->iCliTime;
|
||||
launchResponse->iSvrTime = tm;
|
||||
|
||||
otherSock->sendPacket(new CNPacketData((void*)launchResponse, P_FE2CL_PC_LAUNCHER, sizeof(sP_FE2CL_PC_LAUNCHER), otherSock->getFEKey()));
|
||||
otherSock->sendPacket((void*)&launchResponse, P_FE2CL_PC_LAUNCHER, sizeof(sP_FE2CL_PC_LAUNCHER));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -411,32 +397,31 @@ void PlayerManager::ziplinePlayer(CNSocket* sock, CNPacketData* data) {
|
||||
|
||||
uint64_t tm = getTime();
|
||||
|
||||
sP_FE2CL_PC_ZIPLINE ziplineResponse;
|
||||
|
||||
ziplineResponse.iPC_ID = players[sock].plr.iID;
|
||||
ziplineResponse.iCliTime = ziplineData->iCliTime;
|
||||
ziplineResponse.iSvrTime = tm;
|
||||
ziplineResponse.iX = ziplineData->iX;
|
||||
ziplineResponse.iY = ziplineData->iY;
|
||||
ziplineResponse.iZ = ziplineData->iZ;
|
||||
ziplineResponse.fVX = ziplineData->fVX;
|
||||
ziplineResponse.fVY = ziplineData->fVY;
|
||||
ziplineResponse.fVZ = ziplineData->fVZ;
|
||||
ziplineResponse.fMovDistance = ziplineData->fMovDistance;
|
||||
ziplineResponse.fMaxDistance = ziplineData->fMaxDistance;
|
||||
ziplineResponse.fDummy = ziplineData->fDummy; //wtf is this for?
|
||||
ziplineResponse.iStX = ziplineData->iStX;
|
||||
ziplineResponse.iStY = ziplineData->iStY;
|
||||
ziplineResponse.iStZ = ziplineData->iStZ;
|
||||
ziplineResponse.bDown = ziplineData->bDown;
|
||||
ziplineResponse.iSpeed = ziplineData->iSpeed;
|
||||
ziplineResponse.iAngle = ziplineData->iAngle;
|
||||
ziplineResponse.iRollMax = ziplineData->iRollMax;
|
||||
ziplineResponse.iRoll = ziplineData->iRoll;
|
||||
|
||||
for (CNSocket* otherSock : players[sock].viewable) {
|
||||
|
||||
sP_FE2CL_PC_ZIPLINE* ziplineResponse = (sP_FE2CL_PC_ZIPLINE*)xmalloc(sizeof(sP_FE2CL_PC_ZIPLINE));
|
||||
|
||||
ziplineResponse->iPC_ID = players[sock].plr.iID;
|
||||
ziplineResponse->iCliTime = ziplineData->iCliTime;
|
||||
ziplineResponse->iSvrTime = tm;
|
||||
ziplineResponse->iX = ziplineData->iX;
|
||||
ziplineResponse->iY = ziplineData->iY;
|
||||
ziplineResponse->iZ = ziplineData->iZ;
|
||||
ziplineResponse->fVX = ziplineData->fVX;
|
||||
ziplineResponse->fVY = ziplineData->fVY;
|
||||
ziplineResponse->fVZ = ziplineData->fVZ;
|
||||
ziplineResponse->fMovDistance = ziplineData->fMovDistance;
|
||||
ziplineResponse->fMaxDistance = ziplineData->fMaxDistance;
|
||||
ziplineResponse->fDummy = ziplineData->fDummy; //wtf is this for?
|
||||
ziplineResponse->iStX = ziplineData->iStX;
|
||||
ziplineResponse->iStY = ziplineData->iStY;
|
||||
ziplineResponse->iStZ = ziplineData->iStZ;
|
||||
ziplineResponse->bDown = ziplineData->bDown;
|
||||
ziplineResponse->iSpeed = ziplineData->iSpeed;
|
||||
ziplineResponse->iAngle = ziplineData->iAngle;
|
||||
ziplineResponse->iRollMax = ziplineData->iRollMax;
|
||||
ziplineResponse->iRoll = ziplineData->iRoll;
|
||||
|
||||
otherSock->sendPacket(new CNPacketData((void*)ziplineResponse, P_FE2CL_PC_ZIPLINE, sizeof(sP_FE2CL_PC_ZIPLINE), otherSock->getFEKey()));
|
||||
otherSock->sendPacket((void*)&ziplineResponse, P_FE2CL_PC_ZIPLINE, sizeof(sP_FE2CL_PC_ZIPLINE));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -449,29 +434,28 @@ void PlayerManager::movePlatformPlayer(CNSocket* sock, CNPacketData* data) {
|
||||
|
||||
uint64_t tm = getTime();
|
||||
|
||||
sP_FE2CL_PC_MOVEPLATFORM platResponse;
|
||||
|
||||
platResponse.iPC_ID = players[sock].plr.iID;
|
||||
platResponse.iCliTime = platformData->iCliTime;
|
||||
platResponse.iSvrTime = tm;
|
||||
platResponse.iX = platformData->iX;
|
||||
platResponse.iY = platformData->iY;
|
||||
platResponse.iZ = platformData->iZ;
|
||||
platResponse.iAngle = platformData->iAngle;
|
||||
platResponse.fVX = platformData->fVX;
|
||||
platResponse.fVY = platformData->fVY;
|
||||
platResponse.fVZ = platformData->fVZ;
|
||||
platResponse.iLcX = platformData->iLcX;
|
||||
platResponse.iLcY = platformData->iLcY;
|
||||
platResponse.iLcZ = platformData->iLcZ;
|
||||
platResponse.iSpeed = platformData->iSpeed;
|
||||
platResponse.bDown = platformData->bDown;
|
||||
platResponse.cKeyValue = platformData->cKeyValue;
|
||||
platResponse.iPlatformID = platformData->iPlatformID;
|
||||
|
||||
for (CNSocket* otherSock : players[sock].viewable) {
|
||||
|
||||
sP_FE2CL_PC_MOVEPLATFORM* platResponse = (sP_FE2CL_PC_MOVEPLATFORM*)xmalloc(sizeof(sP_FE2CL_PC_MOVEPLATFORM));
|
||||
|
||||
platResponse->iPC_ID = players[sock].plr.iID;
|
||||
platResponse->iCliTime = platformData->iCliTime;
|
||||
platResponse->iSvrTime = tm;
|
||||
platResponse->iX = platformData->iX;
|
||||
platResponse->iY = platformData->iY;
|
||||
platResponse->iZ = platformData->iZ;
|
||||
platResponse->iAngle = platformData->iAngle;
|
||||
platResponse->fVX = platformData->fVX;
|
||||
platResponse->fVY = platformData->fVY;
|
||||
platResponse->fVZ = platformData->fVZ;
|
||||
platResponse->iLcX = platformData->iLcX;
|
||||
platResponse->iLcY = platformData->iLcY;
|
||||
platResponse->iLcZ = platformData->iLcZ;
|
||||
platResponse->iSpeed = platformData->iSpeed;
|
||||
platResponse->bDown = platformData->bDown;
|
||||
platResponse->cKeyValue = platformData->cKeyValue;
|
||||
platResponse->iPlatformID = platformData->iPlatformID;
|
||||
|
||||
otherSock->sendPacket(new CNPacketData((void*)platResponse, P_FE2CL_PC_MOVEPLATFORM, sizeof(sP_FE2CL_PC_MOVEPLATFORM), otherSock->getFEKey()));
|
||||
otherSock->sendPacket((void*)&platResponse, P_FE2CL_PC_MOVEPLATFORM, sizeof(sP_FE2CL_PC_MOVEPLATFORM));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -484,25 +468,24 @@ void PlayerManager::moveSlopePlayer(CNSocket* sock, CNPacketData* data) {
|
||||
|
||||
uint64_t tm = getTime();
|
||||
|
||||
sP_FE2CL_PC_SLOPE slopeResponse;
|
||||
|
||||
slopeResponse.iPC_ID = players[sock].plr.iID;
|
||||
slopeResponse.iCliTime = slopeData->iCliTime;
|
||||
slopeResponse.iSvrTime = tm;
|
||||
slopeResponse.iX = slopeData->iX;
|
||||
slopeResponse.iY = slopeData->iY;
|
||||
slopeResponse.iZ = slopeData->iZ;
|
||||
slopeResponse.iAngle = slopeData->iAngle;
|
||||
slopeResponse.fVX = slopeData->fVX;
|
||||
slopeResponse.fVY = slopeData->fVY;
|
||||
slopeResponse.fVZ = slopeData->fVZ;
|
||||
slopeResponse.iSpeed = slopeData->iSpeed;
|
||||
slopeResponse.cKeyValue = slopeData->cKeyValue;
|
||||
slopeResponse.iSlopeID = slopeData->iSlopeID;
|
||||
|
||||
for (CNSocket* otherSock : players[sock].viewable) {
|
||||
|
||||
sP_FE2CL_PC_SLOPE* slopeResponse = (sP_FE2CL_PC_SLOPE*)xmalloc(sizeof(sP_FE2CL_PC_SLOPE));
|
||||
|
||||
slopeResponse->iPC_ID = players[sock].plr.iID;
|
||||
slopeResponse->iCliTime = slopeData->iCliTime;
|
||||
slopeResponse->iSvrTime = tm;
|
||||
slopeResponse->iX = slopeData->iX;
|
||||
slopeResponse->iY = slopeData->iY;
|
||||
slopeResponse->iZ = slopeData->iZ;
|
||||
slopeResponse->iAngle = slopeData->iAngle;
|
||||
slopeResponse->fVX = slopeData->fVX;
|
||||
slopeResponse->fVY = slopeData->fVY;
|
||||
slopeResponse->fVZ = slopeData->fVZ;
|
||||
slopeResponse->iSpeed = slopeData->iSpeed;
|
||||
slopeResponse->cKeyValue = slopeData->cKeyValue;
|
||||
slopeResponse->iSlopeID = slopeData->iSlopeID;
|
||||
|
||||
otherSock->sendPacket(new CNPacketData((void*)slopeResponse, P_FE2CL_PC_SLOPE, sizeof(sP_FE2CL_PC_SLOPE), otherSock->getFEKey()));
|
||||
otherSock->sendPacket((void*)&slopeResponse, P_FE2CL_PC_SLOPE, sizeof(sP_FE2CL_PC_SLOPE));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -511,7 +494,7 @@ void PlayerManager::gotoPlayer(CNSocket* sock, CNPacketData* data) {
|
||||
return; // ignore the malformed packet
|
||||
|
||||
sP_CL2FE_REQ_PC_GOTO* gotoData = (sP_CL2FE_REQ_PC_GOTO*)data->buf;
|
||||
sP_FE2CL_REP_PC_GOTO_SUCC* response = (sP_FE2CL_REP_PC_GOTO_SUCC*)xmalloc(sizeof(sP_FE2CL_REP_PC_GOTO_SUCC));
|
||||
sP_FE2CL_REP_PC_GOTO_SUCC response;
|
||||
|
||||
DEBUGLOG(
|
||||
std::cout << "P_CL2FE_REQ_PC_GOTO:" << std::endl;
|
||||
@@ -520,11 +503,11 @@ void PlayerManager::gotoPlayer(CNSocket* sock, CNPacketData* data) {
|
||||
std::cout << "\tZ: " << gotoData->iToZ << std::endl;
|
||||
)
|
||||
|
||||
response->iX = gotoData->iToX;
|
||||
response->iY = gotoData->iToY;
|
||||
response->iZ = gotoData->iToZ;
|
||||
response.iX = gotoData->iToX;
|
||||
response.iY = gotoData->iToY;
|
||||
response.iZ = gotoData->iToZ;
|
||||
|
||||
sock->sendPacket(new CNPacketData((void*)response, P_FE2CL_REP_PC_GOTO_SUCC, sizeof(sP_FE2CL_REP_PC_GOTO_SUCC), sock->getFEKey()));
|
||||
sock->sendPacket((void*)&response, P_FE2CL_REP_PC_GOTO_SUCC, sizeof(sP_FE2CL_REP_PC_GOTO_SUCC));
|
||||
}
|
||||
|
||||
void PlayerManager::setSpecialPlayer(CNSocket* sock, CNPacketData* data) {
|
||||
@@ -532,7 +515,7 @@ void PlayerManager::setSpecialPlayer(CNSocket* sock, CNPacketData* data) {
|
||||
return; // ignore the malformed packet
|
||||
|
||||
sP_CL2FE_GM_REQ_PC_SET_VALUE* setData = (sP_CL2FE_GM_REQ_PC_SET_VALUE*)data->buf;
|
||||
sP_FE2CL_GM_REP_PC_SET_VALUE* response = (sP_FE2CL_GM_REP_PC_SET_VALUE*)xmalloc(sizeof(sP_FE2CL_GM_REP_PC_SET_VALUE));
|
||||
sP_FE2CL_GM_REP_PC_SET_VALUE response;
|
||||
|
||||
DEBUGLOG(
|
||||
std::cout << "P_CL2FE_GM_REQ_PC_SET_VALUE:" << std::endl;
|
||||
@@ -541,11 +524,11 @@ void PlayerManager::setSpecialPlayer(CNSocket* sock, CNPacketData* data) {
|
||||
std::cout << "\tSetValue: " << setData->iSetValue << std::endl;
|
||||
)
|
||||
|
||||
response->iPC_ID = setData->iPC_ID;
|
||||
response->iSetValue = setData->iSetValue;
|
||||
response->iSetValueType = setData->iSetValueType;
|
||||
response.iPC_ID = setData->iPC_ID;
|
||||
response.iSetValue = setData->iSetValue;
|
||||
response.iSetValueType = setData->iSetValueType;
|
||||
|
||||
sock->sendPacket(new CNPacketData((void*)response, P_FE2CL_GM_REP_PC_SET_VALUE, sizeof(sP_FE2CL_GM_REP_PC_SET_VALUE), sock->getFEKey()));
|
||||
sock->sendPacket((void*)&response, P_FE2CL_GM_REP_PC_SET_VALUE, sizeof(sP_FE2CL_GM_REP_PC_SET_VALUE));
|
||||
}
|
||||
|
||||
void PlayerManager::heartbeatPlayer(CNSocket* sock, CNPacketData* data) {
|
||||
@@ -557,12 +540,12 @@ void PlayerManager::exitGame(CNSocket* sock, CNPacketData* data) {
|
||||
return;
|
||||
|
||||
sP_CL2FE_REQ_PC_EXIT* exitData = (sP_CL2FE_REQ_PC_EXIT*)data->buf;
|
||||
sP_FE2CL_REP_PC_EXIT_SUCC* response = (sP_FE2CL_REP_PC_EXIT_SUCC*)xmalloc(sizeof(sP_FE2CL_REP_PC_EXIT_SUCC));
|
||||
sP_FE2CL_REP_PC_EXIT_SUCC response;
|
||||
|
||||
response->iID = exitData->iID;
|
||||
response->iExitCode = 1;
|
||||
response.iID = exitData->iID;
|
||||
response.iExitCode = 1;
|
||||
|
||||
sock->sendPacket(new CNPacketData((void*)response, P_FE2CL_REP_PC_EXIT_SUCC, sizeof(sP_FE2CL_REP_PC_EXIT_SUCC), sock->getFEKey()));
|
||||
sock->sendPacket((void*)&response, P_FE2CL_REP_PC_EXIT_SUCC, sizeof(sP_FE2CL_REP_PC_EXIT_SUCC));
|
||||
}
|
||||
|
||||
void PlayerManager::updatePlayer(CNSocket* key, Player plr) {
|
||||
|
Reference in New Issue
Block a user