mirror of
https://github.com/OpenFusionProject/OpenFusion.git
synced 2024-12-23 03:40:05 +00:00
Added more nano features (commands, equip & unequip, powers) (#26)
* Revert "fixed window build" This reverts commitb94f602537
. * Revert "Revert "fixed window build"" This reverts commitdac4457ed2
. * Add nano power feature * Update CNShardServer.hpp * Update CNShardServer.hpp * Test: Add nano power feature Nano powers are set to the first power in its selection by default. * Update NanoManager.cpp * Test: More nano features * Update NanoManager.hpp * Update PlayerManager.hpp * Update PlayerManager.cpp * Updated indentations * Update PlayerManager.cpp * Add DEBUGLOG() Co-authored-by: CPunch <sethtstubbs@gmail.com>
This commit is contained in:
parent
11fed7db10
commit
56bf0db20d
@ -5,6 +5,50 @@
|
||||
|
||||
void NanoManager::init() {
|
||||
REGISTER_SHARD_PACKET(P_CL2FE_REQ_NANO_ACTIVE, nanoSummonHandler);
|
||||
REGISTER_SHARD_PACKET(P_CL2FE_REQ_NANO_EQUIP, nanoEquipHandler);
|
||||
REGISTER_SHARD_PACKET(P_CL2FE_REQ_NANO_UNEQUIP, nanoUnEquipHandler);
|
||||
REGISTER_SHARD_PACKET(P_CL2FE_REQ_PC_GIVE_NANO, nanoGMGiveHandler);
|
||||
REGISTER_SHARD_PACKET(P_CL2FE_REQ_NANO_TUNE, nanoSkillSetHandler);
|
||||
REGISTER_SHARD_PACKET(P_CL2FE_REQ_NANO_SKILL_USE, nanoSkillUseHandler);
|
||||
}
|
||||
|
||||
void NanoManager::nanoEquipHandler(CNSocket* sock, CNPacketData* data) {
|
||||
if (data->size != sizeof(sP_CL2FE_REQ_NANO_EQUIP))
|
||||
return; // malformed packet
|
||||
|
||||
sP_CL2FE_REQ_NANO_EQUIP* nano = (sP_CL2FE_REQ_NANO_EQUIP*)data->buf;
|
||||
sP_FE2CL_REP_NANO_EQUIP_SUCC* resp = (sP_FE2CL_REP_NANO_EQUIP_SUCC*)xmalloc(sizeof(sP_FE2CL_REP_NANO_EQUIP_SUCC));
|
||||
resp->iNanoID = nano->iNanoID;
|
||||
resp->iNanoSlotNum = nano->iNanoSlotNum;
|
||||
|
||||
sock->sendPacket(new CNPacketData((void*)resp, P_FE2CL_REP_NANO_EQUIP_SUCC, sizeof(sP_FE2CL_REP_NANO_EQUIP_SUCC), sock->getFEKey()));
|
||||
}
|
||||
|
||||
void NanoManager::nanoUnEquipHandler(CNSocket* sock, CNPacketData* data) {
|
||||
if (data->size != sizeof(sP_CL2FE_REQ_NANO_UNEQUIP))
|
||||
return; // malformed packet
|
||||
|
||||
sP_CL2FE_REQ_NANO_UNEQUIP* nano = (sP_CL2FE_REQ_NANO_UNEQUIP*)data->buf;
|
||||
sP_FE2CL_REP_NANO_UNEQUIP_SUCC* resp = (sP_FE2CL_REP_NANO_UNEQUIP_SUCC*)xmalloc(sizeof(sP_FE2CL_REP_NANO_UNEQUIP_SUCC));
|
||||
resp->iNanoSlotNum = nano->iNanoSlotNum;
|
||||
|
||||
sock->sendPacket(new CNPacketData((void*)resp, P_FE2CL_REP_NANO_UNEQUIP_SUCC, sizeof(sP_FE2CL_REP_NANO_UNEQUIP_SUCC), sock->getFEKey()));
|
||||
}
|
||||
|
||||
void NanoManager::nanoGMGiveHandler(CNSocket* sock, CNPacketData* data) {
|
||||
if (data->size != sizeof(sP_CL2FE_REQ_PC_GIVE_NANO))
|
||||
return; // ignore the malformed packet
|
||||
|
||||
// Cmd: /nano <nanoId>
|
||||
sP_CL2FE_REQ_PC_GIVE_NANO* nano = (sP_CL2FE_REQ_PC_GIVE_NANO*)data->buf;
|
||||
Player plr = PlayerManager::getPlayer(sock);
|
||||
|
||||
// Add nano to player
|
||||
addNano(sock, nano->iNanoID, 0);
|
||||
|
||||
DEBUGLOG(
|
||||
std::cout << U16toU8(plr.PCStyle.szFirstName) << U16toU8(plr.PCStyle.szLastName) << " requested to add nano id: " << nano->iNanoID << std::endl;
|
||||
)
|
||||
}
|
||||
|
||||
void NanoManager::nanoSummonHandler(CNSocket* sock, CNPacketData* data) {
|
||||
@ -19,5 +63,89 @@ void NanoManager::nanoSummonHandler(CNSocket* sock, CNPacketData* data) {
|
||||
resp->iActiveNanoSlotNum = nano->iNanoSlotNum;
|
||||
sock->sendPacket(new CNPacketData((void*)resp, P_FE2CL_REP_NANO_ACTIVE_SUCC, sizeof(sP_FE2CL_REP_NANO_ACTIVE_SUCC), sock->getFEKey()));
|
||||
|
||||
std::cout << U16toU8(plr.plr.PCStyle.szFirstName) << U16toU8(plr.plr.PCStyle.szLastName) << " requested to summon nano slot: " << nano->iNanoSlotNum << std::endl;
|
||||
DEBUGLOG(
|
||||
std::cout << U16toU8(plr.plr.PCStyle.szFirstName) << U16toU8(plr.plr.PCStyle.szLastName) << " requested to summon nano slot: " << nano->iNanoSlotNum << std::endl;
|
||||
)
|
||||
}
|
||||
|
||||
void NanoManager::nanoSkillUseHandler(CNSocket* sock, CNPacketData* data) {
|
||||
if (data->size != sizeof(sP_CL2FE_REQ_NANO_SKILL_USE))
|
||||
return; // malformed packet
|
||||
|
||||
sP_CL2FE_REQ_NANO_SKILL_USE* skill = (sP_CL2FE_REQ_NANO_SKILL_USE*)data->buf;
|
||||
PlayerView plr = PlayerManager::players[sock];
|
||||
|
||||
// Send to client
|
||||
sP_FE2CL_NANO_SKILL_USE_SUCC* resp = (sP_FE2CL_NANO_SKILL_USE_SUCC*)xmalloc(sizeof(sP_FE2CL_NANO_SKILL_USE_SUCC));
|
||||
resp->iArg1 = skill->iArg1;
|
||||
resp->iArg2 = skill->iArg2;
|
||||
resp->iArg3 = skill->iArg3;
|
||||
resp->iBulletID = skill->iBulletID;
|
||||
resp->iTargetCnt = skill->iTargetCnt;
|
||||
resp->iPC_ID = plr.plr.iID;
|
||||
resp->iNanoStamina = 150; // Hardcoded for now
|
||||
|
||||
sock->sendPacket(new CNPacketData((void*)resp, P_FE2CL_NANO_SKILL_USE_SUCC, sizeof(sP_FE2CL_NANO_SKILL_USE_SUCC), sock->getFEKey()));
|
||||
DEBUGLOG(
|
||||
std::cout << U16toU8(plr.plr.PCStyle.szFirstName) << U16toU8(plr.plr.PCStyle.szLastName) << " requested to summon nano skill " << std::endl;
|
||||
)
|
||||
}
|
||||
|
||||
void NanoManager::nanoSkillSetHandler(CNSocket* sock, CNPacketData* data) {
|
||||
if (data->size != sizeof(sP_CL2FE_REQ_NANO_TUNE))
|
||||
return; // malformed packet
|
||||
|
||||
sP_CL2FE_REQ_NANO_TUNE* skill = (sP_CL2FE_REQ_NANO_TUNE*)data->buf;
|
||||
setNanoSkill(sock, skill->iNanoID, skill->iTuneID);
|
||||
}
|
||||
|
||||
#pragma region Helper methods
|
||||
void NanoManager::addNano(CNSocket* sock, int16_t nanoId, int16_t slot) {
|
||||
Player plr = PlayerManager::getPlayer(sock);
|
||||
|
||||
// Send to client
|
||||
sP_FE2CL_REP_PC_NANO_CREATE_SUCC* resp = new sP_FE2CL_REP_PC_NANO_CREATE_SUCC();
|
||||
resp->Nano.iID = nanoId;
|
||||
resp->Nano.iStamina = 150;
|
||||
resp->iQuestItemSlotNum = slot;
|
||||
|
||||
sock->sendPacket(new CNPacketData((void*)resp, P_FE2CL_REP_PC_NANO_CREATE_SUCC, sizeof(sP_FE2CL_REP_PC_NANO_CREATE_SUCC), sock->getFEKey()));
|
||||
|
||||
// Update player
|
||||
plr.Nanos[nanoId] = resp->Nano;
|
||||
PlayerManager::updatePlayer(sock, plr);
|
||||
}
|
||||
|
||||
void NanoManager::setNanoSkill(CNSocket* sock, int16_t nanoId, int16_t skillId) {
|
||||
Player plr = PlayerManager::getPlayer(sock);
|
||||
sNano nano = plr.Nanos[nanoId];
|
||||
|
||||
nano.iSkillID = skillId;
|
||||
plr.Nanos[nanoId] = nano;
|
||||
|
||||
// Send to client
|
||||
sP_FE2CL_REP_NANO_TUNE_SUCC* resp = (sP_FE2CL_REP_NANO_TUNE_SUCC*)xmalloc(sizeof(sP_FE2CL_REP_NANO_TUNE_SUCC));
|
||||
resp->iNanoID = nanoId;
|
||||
resp->iSkillID = skillId;
|
||||
|
||||
sock->sendPacket(new CNPacketData((void*)resp, P_FE2CL_REP_NANO_TUNE_SUCC, sizeof(sP_FE2CL_REP_NANO_TUNE_SUCC), sock->getFEKey()));
|
||||
|
||||
DEBUGLOG(
|
||||
std::cout << U16toU8(plr.PCStyle.szFirstName) << U16toU8(plr.PCStyle.szLastName) << " set skill id " << skillId << " for nano: " << nanoId << std::endl;
|
||||
)
|
||||
|
||||
// Update the player
|
||||
PlayerManager::updatePlayer(sock, plr);
|
||||
}
|
||||
|
||||
void NanoManager::resetNanoSkill(CNSocket* sock, int16_t nanoId) {
|
||||
Player plr = PlayerManager::getPlayer(sock);
|
||||
sNano nano = plr.Nanos[nanoId];
|
||||
|
||||
nano.iSkillID = 0;
|
||||
plr.Nanos[nanoId] = nano;
|
||||
|
||||
// Update the player
|
||||
PlayerManager::updatePlayer(sock, plr);
|
||||
}
|
||||
#pragma endregion
|
@ -6,6 +6,16 @@
|
||||
namespace NanoManager {
|
||||
void init();
|
||||
void nanoSummonHandler(CNSocket* sock, CNPacketData* data);
|
||||
void nanoEquipHandler(CNSocket* sock, CNPacketData* data);
|
||||
void nanoUnEquipHandler(CNSocket* sock, CNPacketData* data);
|
||||
void nanoGMGiveHandler(CNSocket* sock, CNPacketData* data);
|
||||
void nanoSkillUseHandler(CNSocket* sock, CNPacketData* data);
|
||||
void nanoSkillSetHandler(CNSocket* sock, CNPacketData* data);
|
||||
|
||||
// Helper methods
|
||||
void addNano(CNSocket* sock, int16_t nanoId, int16_t slot);
|
||||
void setNanoSkill(CNSocket* sock, int16_t nanoId, int16_t skillId);
|
||||
void resetNanoSkill(CNSocket* sock, int16_t nanoId);
|
||||
}
|
||||
|
||||
#endif
|
@ -17,6 +17,7 @@ struct Player {
|
||||
int slot;
|
||||
sPCStyle PCStyle;
|
||||
sPCStyle2 PCStyle2;
|
||||
sNano Nanos[37];
|
||||
|
||||
int x, y, z, angle;
|
||||
sItemBase Equip[AEQUIP_COUNT];
|
||||
|
@ -82,7 +82,8 @@ void PlayerManager::updatePlayerPosition(CNSocket* sock, int X, int Y, int Z) {
|
||||
|
||||
if (diffX < settings::VIEWDISTANCE && diffY < settings::VIEWDISTANCE) {
|
||||
yesView.push_back(pair.first);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
noView.push_back(pair.first);
|
||||
}
|
||||
}
|
||||
@ -95,7 +96,7 @@ void PlayerManager::updatePlayerPosition(CNSocket* sock, int X, int Y, int Z) {
|
||||
|
||||
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;
|
||||
|
||||
@ -164,13 +165,13 @@ void PlayerManager::enterPlayer(CNSocket* sock, CNPacketData* data) {
|
||||
|
||||
DEBUGLOG(
|
||||
std::cout << "P_CL2FE_REQ_PC_ENTER:" << std::endl;
|
||||
std::cout << "\tID: " << U16toU8(enter->szID) << std::endl;
|
||||
std::cout << "\tSerial: " << enter->iEnterSerialKey << std::endl;
|
||||
std::cout << "\tTemp: " << enter->iTempValue << std::endl;
|
||||
std::cout << "\tPC_UID: " << plr.PCStyle.iPC_UID << std::endl;
|
||||
std::cout << "\tID: " << U16toU8(enter->szID) << std::endl;
|
||||
std::cout << "\tSerial: " << enter->iEnterSerialKey << std::endl;
|
||||
std::cout << "\tTemp: " << enter->iTempValue << std::endl;
|
||||
std::cout << "\tPC_UID: " << plr.PCStyle.iPC_UID << std::endl;
|
||||
)
|
||||
|
||||
response->iID = rand();
|
||||
response->iID = rand();
|
||||
response->uiSvrTime = getTime();
|
||||
response->PCLoadData2CL.iUserLevel = 1;
|
||||
response->PCLoadData2CL.iHP = 1000 * plr.level;
|
||||
@ -213,9 +214,10 @@ void PlayerManager::enterPlayer(CNSocket* sock, CNPacketData* data) {
|
||||
response->PCLoadData2CL.aNanoBank[i].iStamina = 150;
|
||||
}
|
||||
|
||||
response->PCLoadData2CL.aNanoSlots[0] = 1;
|
||||
response->PCLoadData2CL.aNanoSlots[1] = 2;
|
||||
response->PCLoadData2CL.aNanoSlots[2] = 3;
|
||||
// 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.aQuestFlag[0] = -1;
|
||||
|
||||
@ -245,10 +247,10 @@ void PlayerManager::loadPlayer(CNSocket* sock, CNPacketData* data) {
|
||||
|
||||
DEBUGLOG(
|
||||
std::cout << "P_CL2FE_REQ_PC_LOADING_COMPLETE:" << std::endl;
|
||||
std::cout << "\tPC_ID: " << complete->iPC_ID << 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()));
|
||||
}
|
||||
@ -256,7 +258,7 @@ void PlayerManager::loadPlayer(CNSocket* sock, CNPacketData* data) {
|
||||
void PlayerManager::movePlayer(CNSocket* sock, CNPacketData* data) {
|
||||
if (data->size != sizeof(sP_CL2FE_REQ_PC_MOVE))
|
||||
return; // ignore the malformed packet
|
||||
|
||||
|
||||
sP_CL2FE_REQ_PC_MOVE* moveData = (sP_CL2FE_REQ_PC_MOVE*)data->buf;
|
||||
updatePlayerPosition(sock, moveData->iX, moveData->iY, moveData->iZ);
|
||||
|
||||
@ -276,7 +278,7 @@ void PlayerManager::movePlayer(CNSocket* sock, CNPacketData* data) {
|
||||
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;
|
||||
@ -313,7 +315,7 @@ void PlayerManager::stopPlayer(CNSocket* sock, CNPacketData* data) {
|
||||
void PlayerManager::jumpPlayer(CNSocket* sock, CNPacketData* data) {
|
||||
if (data->size != sizeof(sP_CL2FE_REQ_PC_JUMP))
|
||||
return; // ignore the malformed packet
|
||||
|
||||
|
||||
sP_CL2FE_REQ_PC_JUMP* jumpData = (sP_CL2FE_REQ_PC_JUMP*)data->buf;
|
||||
updatePlayerPosition(sock, jumpData->iX, jumpData->iY, jumpData->iZ);
|
||||
|
||||
@ -332,7 +334,7 @@ void PlayerManager::jumpPlayer(CNSocket* sock, CNPacketData* data) {
|
||||
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;
|
||||
@ -344,7 +346,7 @@ void PlayerManager::jumpPlayer(CNSocket* sock, CNPacketData* data) {
|
||||
void PlayerManager::jumppadPlayer(CNSocket* sock, CNPacketData* data) {
|
||||
if (data->size != sizeof(sP_CL2FE_REQ_PC_JUMPPAD))
|
||||
return; // ignore the malformed packet
|
||||
|
||||
|
||||
sP_CL2FE_REQ_PC_JUMPPAD* jumppadData = (sP_CL2FE_REQ_PC_JUMPPAD*)data->buf;
|
||||
updatePlayerPosition(sock, jumppadData->iX, jumppadData->iY, jumppadData->iZ);
|
||||
|
||||
@ -362,7 +364,7 @@ void PlayerManager::jumppadPlayer(CNSocket* sock, CNPacketData* data) {
|
||||
jumppadResponse->iVX = jumppadData->iVX;
|
||||
jumppadResponse->iVY = jumppadData->iVY;
|
||||
jumppadResponse->iVZ = jumppadData->iVZ;
|
||||
|
||||
|
||||
jumppadResponse->iCliTime = jumppadData->iCliTime;
|
||||
jumppadResponse->iSvrTime = tm;
|
||||
|
||||
@ -373,7 +375,7 @@ void PlayerManager::jumppadPlayer(CNSocket* sock, CNPacketData* data) {
|
||||
void PlayerManager::launchPlayer(CNSocket* sock, CNPacketData* data) {
|
||||
if (data->size != sizeof(sP_CL2FE_REQ_PC_LAUNCHER))
|
||||
return; // ignore the malformed packet
|
||||
|
||||
|
||||
sP_CL2FE_REQ_PC_LAUNCHER* launchData = (sP_CL2FE_REQ_PC_LAUNCHER*)data->buf;
|
||||
updatePlayerPosition(sock, launchData->iX, launchData->iY, launchData->iZ);
|
||||
|
||||
@ -392,7 +394,7 @@ void PlayerManager::launchPlayer(CNSocket* sock, CNPacketData* data) {
|
||||
launchResponse->iVZ = launchData->iVZ;
|
||||
launchResponse->iSpeed = launchData->iSpeed;
|
||||
launchResponse->iAngle = launchData->iAngle;
|
||||
|
||||
|
||||
launchResponse->iCliTime = launchData->iCliTime;
|
||||
launchResponse->iSvrTime = tm;
|
||||
|
||||
@ -513,12 +515,12 @@ void PlayerManager::gotoPlayer(CNSocket* sock, CNPacketData* data) {
|
||||
|
||||
DEBUGLOG(
|
||||
std::cout << "P_CL2FE_REQ_PC_GOTO:" << std::endl;
|
||||
std::cout << "\tX: " << gotoData->iToX << std::endl;
|
||||
std::cout << "\tY: " << gotoData->iToY << std::endl;
|
||||
std::cout << "\tZ: " << gotoData->iToZ << std::endl;
|
||||
std::cout << "\tX: " << gotoData->iToX << std::endl;
|
||||
std::cout << "\tY: " << gotoData->iToY << std::endl;
|
||||
std::cout << "\tZ: " << gotoData->iToZ << std::endl;
|
||||
)
|
||||
|
||||
response->iX = gotoData->iToX;
|
||||
response->iX = gotoData->iToX;
|
||||
response->iY = gotoData->iToY;
|
||||
response->iZ = gotoData->iToZ;
|
||||
|
||||
@ -534,12 +536,12 @@ void PlayerManager::setSpecialPlayer(CNSocket* sock, CNPacketData* data) {
|
||||
|
||||
DEBUGLOG(
|
||||
std::cout << "P_CL2FE_GM_REQ_PC_SET_VALUE:" << std::endl;
|
||||
std::cout << "\tPC_ID: " << setData->iPC_ID << std::endl;
|
||||
std::cout << "\tSetValueType: " << setData->iSetValueType << std::endl;
|
||||
std::cout << "\tSetValue: " << setData->iSetValue << std::endl;
|
||||
std::cout << "\tPC_ID: " << setData->iPC_ID << std::endl;
|
||||
std::cout << "\tSetValueType: " << setData->iSetValueType << std::endl;
|
||||
std::cout << "\tSetValue: " << setData->iSetValue << std::endl;
|
||||
)
|
||||
|
||||
response->iPC_ID = setData->iPC_ID;
|
||||
response->iPC_ID = setData->iPC_ID;
|
||||
response->iSetValue = setData->iSetValue;
|
||||
response->iSetValueType = setData->iSetValueType;
|
||||
|
||||
@ -559,3 +561,10 @@ void PlayerManager::exitGame(CNSocket* sock, CNPacketData* data) {
|
||||
|
||||
sock->sendPacket(new CNPacketData((void*)response, P_FE2CL_REP_PC_EXIT_SUCC, sizeof(sP_FE2CL_REP_PC_EXIT_SUCC), sock->getFEKey()));
|
||||
}
|
||||
|
||||
void PlayerManager::updatePlayer(CNSocket* key, Player plr) {
|
||||
PlayerView plrv = players[key];
|
||||
plrv.plr = plr;
|
||||
|
||||
players[key] = plrv;
|
||||
}
|
@ -25,6 +25,7 @@ namespace PlayerManager {
|
||||
void removePlayer(CNSocket* key);
|
||||
Player getPlayer(CNSocket* key);
|
||||
|
||||
void updatePlayer(CNSocket* key, Player plr);
|
||||
void updatePlayerPosition(CNSocket* sock, int X, int Y, int Z);
|
||||
|
||||
void enterPlayer(CNSocket* sock, CNPacketData* data);
|
||||
|
Loading…
Reference in New Issue
Block a user