mirror of
https://github.com/OpenFusionProject/OpenFusion.git
synced 2024-11-22 05:20:05 +00:00
[refactor] Continue work on switching over to new sendPacket() wrapper
I also moved the give nano GM command to BuiltinCommands, and added a perms check Haven't checked the following files yet: Eggs Groups Missions MobAI
This commit is contained in:
parent
4a22449f5e
commit
b428eb08e9
@ -3,6 +3,7 @@
|
|||||||
#include "Chat.hpp"
|
#include "Chat.hpp"
|
||||||
#include "Items.hpp"
|
#include "Items.hpp"
|
||||||
#include "Missions.hpp"
|
#include "Missions.hpp"
|
||||||
|
#include "Nanos.hpp"
|
||||||
|
|
||||||
// helper function, not a packet handler
|
// helper function, not a packet handler
|
||||||
void BuiltinCommands::setSpecialState(CNSocket* sock, CNPacketData* data) {
|
void BuiltinCommands::setSpecialState(CNSocket* sock, CNPacketData* data) {
|
||||||
@ -312,10 +313,26 @@ static void itemGMGiveHandler(CNSocket* sock, CNPacketData* data) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void nanoGMGiveHandler(CNSocket* sock, CNPacketData* data) {
|
||||||
|
auto nano = (sP_CL2FE_REQ_PC_GIVE_NANO*)data->buf;
|
||||||
|
Player *plr = PlayerManager::getPlayer(sock);
|
||||||
|
|
||||||
|
if (plr->accountLevel > 50)
|
||||||
|
return;
|
||||||
|
|
||||||
|
// Add nano to player
|
||||||
|
Nanos::addNano(sock, nano->iNanoID, 0);
|
||||||
|
|
||||||
|
DEBUGLOG(
|
||||||
|
std::cout << PlayerManager::getPlayerName(plr) << " requested to add nano id: " << nano->iNanoID << std::endl;
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
void BuiltinCommands::init() {
|
void BuiltinCommands::init() {
|
||||||
REGISTER_SHARD_PACKET(P_CL2FE_REQ_PC_GOTO, gotoPlayer);
|
REGISTER_SHARD_PACKET(P_CL2FE_REQ_PC_GOTO, gotoPlayer);
|
||||||
REGISTER_SHARD_PACKET(P_CL2FE_GM_REQ_PC_SET_VALUE, setValuePlayer);
|
REGISTER_SHARD_PACKET(P_CL2FE_GM_REQ_PC_SET_VALUE, setValuePlayer);
|
||||||
REGISTER_SHARD_PACKET(P_CL2FE_REQ_PC_GIVE_ITEM, itemGMGiveHandler);
|
REGISTER_SHARD_PACKET(P_CL2FE_REQ_PC_GIVE_ITEM, itemGMGiveHandler);
|
||||||
|
REGISTER_SHARD_PACKET(P_CL2FE_REQ_PC_GIVE_NANO, nanoGMGiveHandler);
|
||||||
|
|
||||||
REGISTER_SHARD_PACKET(P_CL2FE_GM_REQ_PC_SPECIAL_STATE_SWITCH, setGMSpecialSwitchPlayer);
|
REGISTER_SHARD_PACKET(P_CL2FE_GM_REQ_PC_SPECIAL_STATE_SWITCH, setGMSpecialSwitchPlayer);
|
||||||
REGISTER_SHARD_PACKET(P_CL2FE_GM_REQ_TARGET_PC_SPECIAL_STATE_ONOFF, setGMSpecialOnOff);
|
REGISTER_SHARD_PACKET(P_CL2FE_GM_REQ_TARGET_PC_SPECIAL_STATE_ONOFF, setGMSpecialOnOff);
|
||||||
|
@ -110,7 +110,7 @@ static void npcBarkHandler(CNSocket* sock, CNPacketData* data) {
|
|||||||
INITSTRUCT(sP_FE2CL_REP_BARKER, resp);
|
INITSTRUCT(sP_FE2CL_REP_BARKER, resp);
|
||||||
resp.iNPC_ID = req->iNPC_ID;
|
resp.iNPC_ID = req->iNPC_ID;
|
||||||
resp.iMissionStringID = barks[rand() % barks.size()];
|
resp.iMissionStringID = barks[rand() % barks.size()];
|
||||||
sock->sendPacket((void*)&resp, P_FE2CL_REP_BARKER, sizeof(sP_FE2CL_REP_BARKER));
|
sock->sendPacket(resp, P_FE2CL_REP_BARKER);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void npcUnsummonHandler(CNSocket* sock, CNPacketData* data) {
|
static void npcUnsummonHandler(CNSocket* sock, CNPacketData* data) {
|
||||||
@ -148,7 +148,7 @@ BaseNPC *NPCManager::summonNPC(int x, int y, int z, uint64_t instance, int type,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void npcSummonHandler(CNSocket* sock, CNPacketData* data) {
|
static void npcSummonHandler(CNSocket* sock, CNPacketData* data) {
|
||||||
sP_CL2FE_REQ_NPC_SUMMON* req = (sP_CL2FE_REQ_NPC_SUMMON*)data->buf;
|
auto req = (sP_CL2FE_REQ_NPC_SUMMON*)data->buf;
|
||||||
Player* plr = PlayerManager::getPlayer(sock);
|
Player* plr = PlayerManager::getPlayer(sock);
|
||||||
|
|
||||||
int limit = NPCData.back()["m_iNpcNumber"];
|
int limit = NPCData.back()["m_iNpcNumber"];
|
||||||
@ -175,13 +175,13 @@ static void handleWarp(CNSocket* sock, int32_t warpId) {
|
|||||||
|
|
||||||
// send to self
|
// send to self
|
||||||
INITSTRUCT(sP_FE2CL_PC_VEHICLE_OFF_SUCC, off);
|
INITSTRUCT(sP_FE2CL_PC_VEHICLE_OFF_SUCC, off);
|
||||||
sock->sendPacket((void*)&off, P_FE2CL_PC_VEHICLE_OFF_SUCC, sizeof(sP_FE2CL_PC_VEHICLE_OFF_SUCC));
|
sock->sendPacket(off, P_FE2CL_PC_VEHICLE_OFF_SUCC);
|
||||||
|
|
||||||
// send to others
|
// send to others
|
||||||
INITSTRUCT(sP_FE2CL_PC_STATE_CHANGE, chg);
|
INITSTRUCT(sP_FE2CL_PC_STATE_CHANGE, chg);
|
||||||
chg.iPC_ID = plr->iID;
|
chg.iPC_ID = plr->iID;
|
||||||
chg.iState = plr->iPCState;
|
chg.iState = plr->iPCState;
|
||||||
PlayerManager::sendToViewable(sock, (void*)&chg, P_FE2CL_PC_STATE_CHANGE, sizeof(sP_FE2CL_PC_STATE_CHANGE));
|
PlayerManager::sendToViewable(sock, chg, P_FE2CL_PC_STATE_CHANGE);
|
||||||
}
|
}
|
||||||
|
|
||||||
// std::cerr << "Warped to Map Num:" << Warps[warpId].instanceID << " NPC ID " << Warps[warpId].npcID << std::endl;
|
// std::cerr << "Warped to Map Num:" << Warps[warpId].instanceID << " NPC ID " << Warps[warpId].npcID << std::endl;
|
||||||
@ -225,13 +225,13 @@ static void handleWarp(CNSocket* sock, int32_t warpId) {
|
|||||||
|
|
||||||
// send to self
|
// send to self
|
||||||
INITSTRUCT(sP_FE2CL_PC_VEHICLE_OFF_SUCC, off);
|
INITSTRUCT(sP_FE2CL_PC_VEHICLE_OFF_SUCC, off);
|
||||||
sockTo->sendPacket((void*)&off, P_FE2CL_PC_VEHICLE_OFF_SUCC, sizeof(sP_FE2CL_PC_VEHICLE_OFF_SUCC));
|
sockTo->sendPacket(off, P_FE2CL_PC_VEHICLE_OFF_SUCC);
|
||||||
|
|
||||||
// send to others
|
// send to others
|
||||||
INITSTRUCT(sP_FE2CL_PC_STATE_CHANGE, chg);
|
INITSTRUCT(sP_FE2CL_PC_STATE_CHANGE, chg);
|
||||||
chg.iPC_ID = otherPlr->iID;
|
chg.iPC_ID = otherPlr->iID;
|
||||||
chg.iState = otherPlr->iPCState;
|
chg.iState = otherPlr->iPCState;
|
||||||
PlayerManager::sendToViewable(sockTo, (void*)&chg, P_FE2CL_PC_STATE_CHANGE, sizeof(sP_FE2CL_PC_STATE_CHANGE));
|
PlayerManager::sendToViewable(sockTo, chg, P_FE2CL_PC_STATE_CHANGE);
|
||||||
}
|
}
|
||||||
|
|
||||||
PlayerManager::sendPlayerTo(sockTo, Warps[warpId].x, Warps[warpId].y, Warps[warpId].z, instanceID);
|
PlayerManager::sendPlayerTo(sockTo, Warps[warpId].x, Warps[warpId].y, Warps[warpId].z, instanceID);
|
||||||
@ -249,7 +249,7 @@ static void handleWarp(CNSocket* sock, int32_t warpId) {
|
|||||||
uint64_t fromInstance = plr->instanceID; // pre-warp instance, saved for post-warp
|
uint64_t fromInstance = plr->instanceID; // pre-warp instance, saved for post-warp
|
||||||
plr->instanceID = INSTANCE_OVERWORLD;
|
plr->instanceID = INSTANCE_OVERWORLD;
|
||||||
Missions::failInstancedMissions(sock); // fail any instanced missions
|
Missions::failInstancedMissions(sock); // fail any instanced missions
|
||||||
sock->sendPacket((void*)&resp, P_FE2CL_REP_PC_WARP_USE_NPC_SUCC, sizeof(sP_FE2CL_REP_PC_WARP_USE_NPC_SUCC));
|
sock->sendPacket(resp, P_FE2CL_REP_PC_WARP_USE_NPC_SUCC);
|
||||||
|
|
||||||
Chunking::updatePlayerChunk(sock, plr->chunkPos, std::make_tuple(0, 0, 0)); // force player to reload chunks
|
Chunking::updatePlayerChunk(sock, plr->chunkPos, std::make_tuple(0, 0, 0)); // force player to reload chunks
|
||||||
PlayerManager::updatePlayerPosition(sock, resp.iX, resp.iY, resp.iZ, INSTANCE_OVERWORLD, plr->angle);
|
PlayerManager::updatePlayerPosition(sock, resp.iX, resp.iY, resp.iZ, INSTANCE_OVERWORLD, plr->angle);
|
||||||
@ -264,7 +264,7 @@ static void handleWarp(CNSocket* sock, int32_t warpId) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void npcWarpHandler(CNSocket* sock, CNPacketData* data) {
|
static void npcWarpHandler(CNSocket* sock, CNPacketData* data) {
|
||||||
sP_CL2FE_REQ_PC_WARP_USE_NPC* warpNpc = (sP_CL2FE_REQ_PC_WARP_USE_NPC*)data->buf;
|
auto warpNpc = (sP_CL2FE_REQ_PC_WARP_USE_NPC*)data->buf;
|
||||||
handleWarp(sock, warpNpc->iWarpID);
|
handleWarp(sock, warpNpc->iWarpID);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -51,7 +51,7 @@ void Nanos::addNano(CNSocket* sock, int16_t nanoID, int16_t slot, bool spendfm)
|
|||||||
// Update player
|
// Update player
|
||||||
plr->Nanos[nanoID] = resp.Nano;
|
plr->Nanos[nanoID] = resp.Nano;
|
||||||
|
|
||||||
sock->sendPacket((void*)&resp, P_FE2CL_REP_PC_NANO_CREATE_SUCC, sizeof(sP_FE2CL_REP_PC_NANO_CREATE_SUCC));
|
sock->sendPacket(resp, P_FE2CL_REP_PC_NANO_CREATE_SUCC);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* iPC_Level in NANO_CREATE_SUCC sets the player's level.
|
* iPC_Level in NANO_CREATE_SUCC sets the player's level.
|
||||||
@ -66,7 +66,7 @@ void Nanos::addNano(CNSocket* sock, int16_t nanoID, int16_t slot, bool spendfm)
|
|||||||
resp2.iPC_Level = level;
|
resp2.iPC_Level = level;
|
||||||
|
|
||||||
// Update other players' perception of the player's level
|
// Update other players' perception of the player's level
|
||||||
PlayerManager::sendToViewable(sock, (void*)&resp2, P_FE2CL_REP_PC_CHANGE_LEVEL, sizeof(sP_FE2CL_REP_PC_CHANGE_LEVEL));
|
PlayerManager::sendToViewable(sock, resp2, P_FE2CL_REP_PC_CHANGE_LEVEL);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Nanos::summonNano(CNSocket *sock, int slot, bool silent) {
|
void Nanos::summonNano(CNSocket *sock, int slot, bool silent) {
|
||||||
@ -119,13 +119,13 @@ void Nanos::summonNano(CNSocket *sock, int slot, bool silent) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!silent) // silent nano death but only for the summoning player
|
if (!silent) // silent nano death but only for the summoning player
|
||||||
sock->sendPacket((void*)&resp, P_FE2CL_REP_NANO_ACTIVE_SUCC, sizeof(sP_FE2CL_REP_NANO_ACTIVE_SUCC));
|
sock->sendPacket(resp, P_FE2CL_REP_NANO_ACTIVE_SUCC);
|
||||||
|
|
||||||
// Send to other players, these players can't handle silent nano deaths so this packet needs to be sent.
|
// Send to other players, these players can't handle silent nano deaths so this packet needs to be sent.
|
||||||
INITSTRUCT(sP_FE2CL_NANO_ACTIVE, pkt1);
|
INITSTRUCT(sP_FE2CL_NANO_ACTIVE, pkt1);
|
||||||
pkt1.iPC_ID = plr->iID;
|
pkt1.iPC_ID = plr->iID;
|
||||||
pkt1.Nano = plr->Nanos[nanoID];
|
pkt1.Nano = plr->Nanos[nanoID];
|
||||||
PlayerManager::sendToViewable(sock, (void*)&pkt1, P_FE2CL_NANO_ACTIVE, sizeof(sP_FE2CL_NANO_ACTIVE));
|
PlayerManager::sendToViewable(sock, pkt1, P_FE2CL_NANO_ACTIVE);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void setNanoSkill(CNSocket* sock, sP_CL2FE_REQ_NANO_TUNE* skill) {
|
static void setNanoSkill(CNSocket* sock, sP_CL2FE_REQ_NANO_TUNE* skill) {
|
||||||
@ -152,7 +152,7 @@ static void setNanoSkill(CNSocket* sock, sP_CL2FE_REQ_NANO_TUNE* skill) {
|
|||||||
// check if there's any garbage in the item slot array (this'll happen when a nano station isn't used)
|
// check if there's any garbage in the item slot array (this'll happen when a nano station isn't used)
|
||||||
for (int i = 0; i < 10; i++) {
|
for (int i = 0; i < 10; i++) {
|
||||||
if (skill->aiNeedItemSlotNum[i] < 0 || skill->aiNeedItemSlotNum[i] >= AINVEN_COUNT) {
|
if (skill->aiNeedItemSlotNum[i] < 0 || skill->aiNeedItemSlotNum[i] >= AINVEN_COUNT) {
|
||||||
sock->sendPacket((void*)&resp, P_FE2CL_REP_NANO_TUNE_SUCC, sizeof(sP_FE2CL_REP_NANO_TUNE_SUCC));
|
sock->sendPacket(resp, P_FE2CL_REP_NANO_TUNE_SUCC);
|
||||||
return; // stop execution, don't run consumption logic
|
return; // stop execution, don't run consumption logic
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -194,7 +194,7 @@ static void setNanoSkill(CNSocket* sock, sP_CL2FE_REQ_NANO_TUNE* skill) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
sock->sendPacket((void*)&resp, P_FE2CL_REP_NANO_TUNE_SUCC, sizeof(sP_FE2CL_REP_NANO_TUNE_SUCC));
|
sock->sendPacket(resp, P_FE2CL_REP_NANO_TUNE_SUCC);
|
||||||
|
|
||||||
DEBUGLOG(
|
DEBUGLOG(
|
||||||
std::cout << PlayerManager::getPlayerName(plr) << " set skill id " << skill->iTuneID << " for nano: " << skill->iNanoID << std::endl;
|
std::cout << PlayerManager::getPlayerName(plr) << " set skill id " << skill->iTuneID << " for nano: " << skill->iNanoID << std::endl;
|
||||||
@ -218,7 +218,7 @@ bool Nanos::getNanoBoost(Player* plr) {
|
|||||||
#pragma endregion
|
#pragma endregion
|
||||||
|
|
||||||
static void nanoEquipHandler(CNSocket* sock, CNPacketData* data) {
|
static void nanoEquipHandler(CNSocket* sock, CNPacketData* data) {
|
||||||
sP_CL2FE_REQ_NANO_EQUIP* nano = (sP_CL2FE_REQ_NANO_EQUIP*)data->buf;
|
auto nano = (sP_CL2FE_REQ_NANO_EQUIP*)data->buf;
|
||||||
INITSTRUCT(sP_FE2CL_REP_NANO_EQUIP_SUCC, resp);
|
INITSTRUCT(sP_FE2CL_REP_NANO_EQUIP_SUCC, resp);
|
||||||
Player *plr = PlayerManager::getPlayer(sock);
|
Player *plr = PlayerManager::getPlayer(sock);
|
||||||
|
|
||||||
@ -241,18 +241,18 @@ static void nanoEquipHandler(CNSocket* sock, CNPacketData* data) {
|
|||||||
pkt.eTBU = 2; // eTimeBuffUpdate
|
pkt.eTBU = 2; // eTimeBuffUpdate
|
||||||
pkt.eTBT = 1; // eTimeBuffType 1 means nano
|
pkt.eTBT = 1; // eTimeBuffType 1 means nano
|
||||||
pkt.iConditionBitFlag = plr->iConditionBitFlag &= ~value1;
|
pkt.iConditionBitFlag = plr->iConditionBitFlag &= ~value1;
|
||||||
sock->sendPacket((void*)&pkt, P_FE2CL_PC_BUFF_UPDATE, sizeof(sP_FE2CL_PC_BUFF_UPDATE));
|
sock->sendPacket(pkt, P_FE2CL_PC_BUFF_UPDATE);
|
||||||
}
|
}
|
||||||
|
|
||||||
// unsummon nano if replaced
|
// unsummon nano if replaced
|
||||||
if (plr->activeNano == plr->equippedNanos[nano->iNanoSlotNum])
|
if (plr->activeNano == plr->equippedNanos[nano->iNanoSlotNum])
|
||||||
summonNano(sock, -1);
|
summonNano(sock, -1);
|
||||||
|
|
||||||
sock->sendPacket((void*)&resp, P_FE2CL_REP_NANO_EQUIP_SUCC, sizeof(sP_FE2CL_REP_NANO_EQUIP_SUCC));
|
sock->sendPacket(resp, P_FE2CL_REP_NANO_EQUIP_SUCC);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void nanoUnEquipHandler(CNSocket* sock, CNPacketData* data) {
|
static void nanoUnEquipHandler(CNSocket* sock, CNPacketData* data) {
|
||||||
sP_CL2FE_REQ_NANO_UNEQUIP* nano = (sP_CL2FE_REQ_NANO_UNEQUIP*)data->buf;
|
auto nano = (sP_CL2FE_REQ_NANO_UNEQUIP*)data->buf;
|
||||||
INITSTRUCT(sP_FE2CL_REP_NANO_UNEQUIP_SUCC, resp);
|
INITSTRUCT(sP_FE2CL_REP_NANO_UNEQUIP_SUCC, resp);
|
||||||
Player *plr = PlayerManager::getPlayer(sock);
|
Player *plr = PlayerManager::getPlayer(sock);
|
||||||
|
|
||||||
@ -269,24 +269,11 @@ static void nanoUnEquipHandler(CNSocket* sock, CNPacketData* data) {
|
|||||||
// update player
|
// update player
|
||||||
plr->equippedNanos[nano->iNanoSlotNum] = 0;
|
plr->equippedNanos[nano->iNanoSlotNum] = 0;
|
||||||
|
|
||||||
sock->sendPacket((void*)&resp, P_FE2CL_REP_NANO_UNEQUIP_SUCC, sizeof(sP_FE2CL_REP_NANO_UNEQUIP_SUCC));
|
sock->sendPacket(resp, P_FE2CL_REP_NANO_UNEQUIP_SUCC);
|
||||||
}
|
|
||||||
|
|
||||||
static void nanoGMGiveHandler(CNSocket* sock, CNPacketData* data) {
|
|
||||||
// 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 << PlayerManager::getPlayerName(plr) << " requested to add nano id: " << nano->iNanoID << std::endl;
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void nanoSummonHandler(CNSocket* sock, CNPacketData* data) {
|
static void nanoSummonHandler(CNSocket* sock, CNPacketData* data) {
|
||||||
sP_CL2FE_REQ_NANO_ACTIVE* pkt = (sP_CL2FE_REQ_NANO_ACTIVE*)data->buf;
|
auto pkt = (sP_CL2FE_REQ_NANO_ACTIVE*)data->buf;
|
||||||
Player *plr = PlayerManager::getPlayer(sock);
|
Player *plr = PlayerManager::getPlayer(sock);
|
||||||
|
|
||||||
summonNano(sock, pkt->iNanoSlotNum);
|
summonNano(sock, pkt->iNanoSlotNum);
|
||||||
@ -325,17 +312,17 @@ static void nanoSkillUseHandler(CNSocket* sock, CNPacketData* data) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void nanoSkillSetHandler(CNSocket* sock, CNPacketData* data) {
|
static void nanoSkillSetHandler(CNSocket* sock, CNPacketData* data) {
|
||||||
sP_CL2FE_REQ_NANO_TUNE* skill = (sP_CL2FE_REQ_NANO_TUNE*)data->buf;
|
auto skill = (sP_CL2FE_REQ_NANO_TUNE*)data->buf;
|
||||||
setNanoSkill(sock, skill);
|
setNanoSkill(sock, skill);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void nanoSkillSetGMHandler(CNSocket* sock, CNPacketData* data) {
|
static void nanoSkillSetGMHandler(CNSocket* sock, CNPacketData* data) {
|
||||||
sP_CL2FE_REQ_NANO_TUNE* skillGM = (sP_CL2FE_REQ_NANO_TUNE*)data->buf;
|
auto skillGM = (sP_CL2FE_REQ_NANO_TUNE*)data->buf;
|
||||||
setNanoSkill(sock, skillGM);
|
setNanoSkill(sock, skillGM);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void nanoRecallRegisterHandler(CNSocket* sock, CNPacketData* data) {
|
static void nanoRecallRegisterHandler(CNSocket* sock, CNPacketData* data) {
|
||||||
sP_CL2FE_REQ_REGIST_RXCOM* recallData = (sP_CL2FE_REQ_REGIST_RXCOM*)data->buf;
|
auto recallData = (sP_CL2FE_REQ_REGIST_RXCOM*)data->buf;
|
||||||
|
|
||||||
if (NPCManager::NPCs.find(recallData->iNPCID) == NPCManager::NPCs.end())
|
if (NPCManager::NPCs.find(recallData->iNPCID) == NPCManager::NPCs.end())
|
||||||
return;
|
return;
|
||||||
@ -349,11 +336,11 @@ static void nanoRecallRegisterHandler(CNSocket* sock, CNPacketData* data) {
|
|||||||
response.iX = plr->recallX = npc->appearanceData.iX;
|
response.iX = plr->recallX = npc->appearanceData.iX;
|
||||||
response.iY = plr->recallY = npc->appearanceData.iY;
|
response.iY = plr->recallY = npc->appearanceData.iY;
|
||||||
response.iZ = plr->recallZ = npc->appearanceData.iZ;
|
response.iZ = plr->recallZ = npc->appearanceData.iZ;
|
||||||
sock->sendPacket((void*)&response, P_FE2CL_REP_REGIST_RXCOM, sizeof(sP_FE2CL_REP_REGIST_RXCOM));
|
sock->sendPacket(response, P_FE2CL_REP_REGIST_RXCOM);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void nanoRecallHandler(CNSocket* sock, CNPacketData* data) {
|
static void nanoRecallHandler(CNSocket* sock, CNPacketData* data) {
|
||||||
sP_CL2FE_REQ_WARP_USE_RECALL* recallData = (sP_CL2FE_REQ_WARP_USE_RECALL*)data->buf;
|
auto recallData = (sP_CL2FE_REQ_WARP_USE_RECALL*)data->buf;
|
||||||
|
|
||||||
Player* plr = PlayerManager::getPlayer(sock);
|
Player* plr = PlayerManager::getPlayer(sock);
|
||||||
Player* otherPlr = PlayerManager::getPlayerFromID(recallData->iGroupMemberID);
|
Player* otherPlr = PlayerManager::getPlayerFromID(recallData->iGroupMemberID);
|
||||||
@ -372,7 +359,7 @@ static void nanoRecallHandler(CNSocket* sock, CNPacketData* data) {
|
|||||||
PlayerManager::sendPlayerTo(sock, otherPlr->recallX, otherPlr->recallY, otherPlr->recallZ, otherPlr->recallInstance);
|
PlayerManager::sendPlayerTo(sock, otherPlr->recallX, otherPlr->recallY, otherPlr->recallZ, otherPlr->recallInstance);
|
||||||
else {
|
else {
|
||||||
INITSTRUCT(sP_FE2CL_REP_WARP_USE_RECALL_FAIL, response)
|
INITSTRUCT(sP_FE2CL_REP_WARP_USE_RECALL_FAIL, response)
|
||||||
sock->sendPacket((void*)&response, P_FE2CL_REP_WARP_USE_RECALL_FAIL, sizeof(sP_FE2CL_REP_WARP_USE_RECALL_FAIL));
|
sock->sendPacket(response, P_FE2CL_REP_WARP_USE_RECALL_FAIL);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -396,7 +383,7 @@ static void nanoPotionHandler(CNSocket* sock, CNPacketData* data) {
|
|||||||
response.iNanoStamina = nano.iStamina + difference;
|
response.iNanoStamina = nano.iStamina + difference;
|
||||||
response.iBatteryN = player->batteryN - difference;
|
response.iBatteryN = player->batteryN - difference;
|
||||||
|
|
||||||
sock->sendPacket((void*)&response, P_FE2CL_REP_CHARGE_NANO_STAMINA, sizeof(sP_FE2CL_REP_CHARGE_NANO_STAMINA));
|
sock->sendPacket(response, P_FE2CL_REP_CHARGE_NANO_STAMINA);
|
||||||
// now update serverside
|
// now update serverside
|
||||||
player->batteryN -= difference;
|
player->batteryN -= difference;
|
||||||
player->Nanos[nano.iID].iStamina += difference;
|
player->Nanos[nano.iID].iStamina += difference;
|
||||||
@ -407,7 +394,6 @@ void Nanos::init() {
|
|||||||
REGISTER_SHARD_PACKET(P_CL2FE_REQ_NANO_ACTIVE, nanoSummonHandler);
|
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_EQUIP, nanoEquipHandler);
|
||||||
REGISTER_SHARD_PACKET(P_CL2FE_REQ_NANO_UNEQUIP, nanoUnEquipHandler);
|
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_TUNE, nanoSkillSetHandler);
|
||||||
REGISTER_SHARD_PACKET(P_CL2FE_REQ_PC_GIVE_NANO_SKILL, nanoSkillSetGMHandler);
|
REGISTER_SHARD_PACKET(P_CL2FE_REQ_PC_GIVE_NANO_SKILL, nanoSkillSetGMHandler);
|
||||||
REGISTER_SHARD_PACKET(P_CL2FE_REQ_NANO_SKILL_USE, nanoSkillUseHandler);
|
REGISTER_SHARD_PACKET(P_CL2FE_REQ_NANO_SKILL_USE, nanoSkillUseHandler);
|
||||||
|
@ -13,7 +13,7 @@ std::map<CNSocket*, EPRace> Racing::EPRaces;
|
|||||||
std::map<int32_t, std::pair<std::vector<int>, std::vector<int>>> Racing::EPRewards;
|
std::map<int32_t, std::pair<std::vector<int>, std::vector<int>>> Racing::EPRewards;
|
||||||
|
|
||||||
static void racingStart(CNSocket* sock, CNPacketData* data) {
|
static void racingStart(CNSocket* sock, CNPacketData* data) {
|
||||||
sP_CL2FE_REQ_EP_RACE_START* req = (sP_CL2FE_REQ_EP_RACE_START*)data->buf;
|
auto req = (sP_CL2FE_REQ_EP_RACE_START*)data->buf;
|
||||||
|
|
||||||
if (NPCManager::NPCs.find(req->iStartEcomID) == NPCManager::NPCs.end())
|
if (NPCManager::NPCs.find(req->iStartEcomID) == NPCManager::NPCs.end())
|
||||||
return; // starting line agent not found
|
return; // starting line agent not found
|
||||||
@ -30,14 +30,14 @@ static void racingStart(CNSocket* sock, CNPacketData* data) {
|
|||||||
resp.iStartTick = 0; // ignored
|
resp.iStartTick = 0; // ignored
|
||||||
resp.iLimitTime = EPData[mapNum].maxTime;
|
resp.iLimitTime = EPData[mapNum].maxTime;
|
||||||
|
|
||||||
sock->sendPacket((void*)&resp, P_FE2CL_REP_EP_RACE_START_SUCC, sizeof(sP_FE2CL_REP_EP_RACE_START_SUCC));
|
sock->sendPacket(resp, P_FE2CL_REP_EP_RACE_START_SUCC);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void racingGetPod(CNSocket* sock, CNPacketData* data) {
|
static void racingGetPod(CNSocket* sock, CNPacketData* data) {
|
||||||
if (EPRaces.find(sock) == EPRaces.end())
|
if (EPRaces.find(sock) == EPRaces.end())
|
||||||
return; // race not found
|
return; // race not found
|
||||||
|
|
||||||
sP_CL2FE_REQ_EP_GET_RING* req = (sP_CL2FE_REQ_EP_GET_RING*)data->buf;
|
auto req = (sP_CL2FE_REQ_EP_GET_RING*)data->buf;
|
||||||
|
|
||||||
// without an anticheat system, we really don't have a choice but to honor the request
|
// without an anticheat system, we really don't have a choice but to honor the request
|
||||||
EPRaces[sock].ringCount++;
|
EPRaces[sock].ringCount++;
|
||||||
@ -47,7 +47,7 @@ static void racingGetPod(CNSocket* sock, CNPacketData* data) {
|
|||||||
resp.iRingLID = req->iRingLID; // could be used to check for proximity in the future
|
resp.iRingLID = req->iRingLID; // could be used to check for proximity in the future
|
||||||
resp.iRingCount_Get = EPRaces[sock].ringCount;
|
resp.iRingCount_Get = EPRaces[sock].ringCount;
|
||||||
|
|
||||||
sock->sendPacket((void*)&resp, P_FE2CL_REP_EP_GET_RING_SUCC, sizeof(sP_FE2CL_REP_EP_GET_RING_SUCC));
|
sock->sendPacket(resp, P_FE2CL_REP_EP_GET_RING_SUCC);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void racingCancel(CNSocket* sock, CNPacketData* data) {
|
static void racingCancel(CNSocket* sock, CNPacketData* data) {
|
||||||
@ -57,14 +57,14 @@ static void racingCancel(CNSocket* sock, CNPacketData* data) {
|
|||||||
EPRaces.erase(sock);
|
EPRaces.erase(sock);
|
||||||
|
|
||||||
INITSTRUCT(sP_FE2CL_REP_EP_RACE_CANCEL_SUCC, resp);
|
INITSTRUCT(sP_FE2CL_REP_EP_RACE_CANCEL_SUCC, resp);
|
||||||
sock->sendPacket((void*)&resp, P_FE2CL_REP_EP_RACE_CANCEL_SUCC, sizeof(sP_FE2CL_REP_EP_RACE_CANCEL_SUCC));
|
sock->sendPacket(resp, P_FE2CL_REP_EP_RACE_CANCEL_SUCC);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void racingEnd(CNSocket* sock, CNPacketData* data) {
|
static void racingEnd(CNSocket* sock, CNPacketData* data) {
|
||||||
if (EPRaces.find(sock) == EPRaces.end())
|
if (EPRaces.find(sock) == EPRaces.end())
|
||||||
return; // race not found
|
return; // race not found
|
||||||
|
|
||||||
sP_CL2FE_REQ_EP_RACE_END* req = (sP_CL2FE_REQ_EP_RACE_END*)data->buf;
|
auto req = (sP_CL2FE_REQ_EP_RACE_END*)data->buf;
|
||||||
Player* plr = PlayerManager::getPlayer(sock);
|
Player* plr = PlayerManager::getPlayer(sock);
|
||||||
|
|
||||||
if (NPCManager::NPCs.find(req->iEndEcomID) == NPCManager::NPCs.end())
|
if (NPCManager::NPCs.find(req->iEndEcomID) == NPCManager::NPCs.end())
|
||||||
@ -144,7 +144,7 @@ static void racingEnd(CNSocket* sock, CNPacketData* data) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
EPRaces.erase(sock);
|
EPRaces.erase(sock);
|
||||||
sock->sendPacket((void*)&resp, P_FE2CL_REP_EP_RACE_END_SUCC, sizeof(sP_FE2CL_REP_EP_RACE_END_SUCC));
|
sock->sendPacket(resp, P_FE2CL_REP_EP_RACE_END_SUCC);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Racing::init() {
|
void Racing::init() {
|
||||||
|
@ -18,7 +18,7 @@ std::unordered_map<CNSocket*, std::queue<WarpLocation>> Transport::SkywayQueues;
|
|||||||
std::unordered_map<int32_t, std::queue<WarpLocation>> Transport::NPCQueues;
|
std::unordered_map<int32_t, std::queue<WarpLocation>> Transport::NPCQueues;
|
||||||
|
|
||||||
static void transportRegisterLocationHandler(CNSocket* sock, CNPacketData* data) {
|
static void transportRegisterLocationHandler(CNSocket* sock, CNPacketData* data) {
|
||||||
sP_CL2FE_REQ_REGIST_TRANSPORTATION_LOCATION* transport = (sP_CL2FE_REQ_REGIST_TRANSPORTATION_LOCATION*)data->buf;
|
auto transport = (sP_CL2FE_REQ_REGIST_TRANSPORTATION_LOCATION*)data->buf;
|
||||||
Player* plr = PlayerManager::getPlayer(sock);
|
Player* plr = PlayerManager::getPlayer(sock);
|
||||||
|
|
||||||
bool newReg = false; // this is a new registration
|
bool newReg = false; // this is a new registration
|
||||||
@ -32,7 +32,7 @@ static void transportRegisterLocationHandler(CNSocket* sock, CNPacketData* data)
|
|||||||
failResp.iErrorCode = 0; // TODO: review what error code to use here
|
failResp.iErrorCode = 0; // TODO: review what error code to use here
|
||||||
failResp.iLocationID = transport->iLocationID;
|
failResp.iLocationID = transport->iLocationID;
|
||||||
|
|
||||||
sock->sendPacket((void*)&failResp, P_FE2CL_REP_PC_REGIST_TRANSPORTATION_LOCATION_FAIL, sizeof(sP_FE2CL_REP_PC_REGIST_TRANSPORTATION_LOCATION_FAIL));
|
sock->sendPacket(failResp, P_FE2CL_REP_PC_REGIST_TRANSPORTATION_LOCATION_FAIL);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -51,7 +51,7 @@ static void transportRegisterLocationHandler(CNSocket* sock, CNPacketData* data)
|
|||||||
failResp.iErrorCode = 0; // TODO: review what error code to use here
|
failResp.iErrorCode = 0; // TODO: review what error code to use here
|
||||||
failResp.iLocationID = transport->iLocationID;
|
failResp.iLocationID = transport->iLocationID;
|
||||||
|
|
||||||
sock->sendPacket((void*)&failResp, P_FE2CL_REP_PC_REGIST_TRANSPORTATION_LOCATION_FAIL, sizeof(sP_FE2CL_REP_PC_REGIST_TRANSPORTATION_LOCATION_FAIL));
|
sock->sendPacket(failResp, P_FE2CL_REP_PC_REGIST_TRANSPORTATION_LOCATION_FAIL);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -72,7 +72,7 @@ static void transportRegisterLocationHandler(CNSocket* sock, CNPacketData* data)
|
|||||||
failResp.iErrorCode = 0; // TODO: review what error code to use here
|
failResp.iErrorCode = 0; // TODO: review what error code to use here
|
||||||
failResp.iLocationID = transport->iLocationID;
|
failResp.iLocationID = transport->iLocationID;
|
||||||
|
|
||||||
sock->sendPacket((void*)&failResp, P_FE2CL_REP_PC_REGIST_TRANSPORTATION_LOCATION_FAIL, sizeof(sP_FE2CL_REP_PC_REGIST_TRANSPORTATION_LOCATION_FAIL));
|
sock->sendPacket(failResp, P_FE2CL_REP_PC_REGIST_TRANSPORTATION_LOCATION_FAIL);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -87,11 +87,11 @@ static void transportRegisterLocationHandler(CNSocket* sock, CNPacketData* data)
|
|||||||
resp.aWyvernLocationFlag[0] = plr->aSkywayLocationFlag[0];
|
resp.aWyvernLocationFlag[0] = plr->aSkywayLocationFlag[0];
|
||||||
resp.aWyvernLocationFlag[1] = plr->aSkywayLocationFlag[1];
|
resp.aWyvernLocationFlag[1] = plr->aSkywayLocationFlag[1];
|
||||||
|
|
||||||
sock->sendPacket((void*)&resp, P_FE2CL_REP_PC_REGIST_TRANSPORTATION_LOCATION_SUCC, sizeof(sP_FE2CL_REP_PC_REGIST_TRANSPORTATION_LOCATION_SUCC));
|
sock->sendPacket(resp, P_FE2CL_REP_PC_REGIST_TRANSPORTATION_LOCATION_SUCC);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void transportWarpHandler(CNSocket* sock, CNPacketData* data) {
|
static void transportWarpHandler(CNSocket* sock, CNPacketData* data) {
|
||||||
sP_CL2FE_REQ_PC_WARP_USE_TRANSPORTATION* req = (sP_CL2FE_REQ_PC_WARP_USE_TRANSPORTATION*)data->buf;
|
auto req = (sP_CL2FE_REQ_PC_WARP_USE_TRANSPORTATION*)data->buf;
|
||||||
Player* plr = PlayerManager::getPlayer(sock);
|
Player* plr = PlayerManager::getPlayer(sock);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -108,7 +108,7 @@ static void transportWarpHandler(CNSocket* sock, CNPacketData* data) {
|
|||||||
failResp.iErrorCode = 0; // TODO: error code
|
failResp.iErrorCode = 0; // TODO: error code
|
||||||
failResp.iTransportationID = req->iTransporationID;
|
failResp.iTransportationID = req->iTransporationID;
|
||||||
|
|
||||||
sock->sendPacket((void*)&failResp, P_FE2CL_REP_PC_WARP_USE_TRANSPORTATION_FAIL, sizeof(sP_FE2CL_REP_PC_WARP_USE_TRANSPORTATION_FAIL));
|
sock->sendPacket(failResp, P_FE2CL_REP_PC_WARP_USE_TRANSPORTATION_FAIL);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -144,7 +144,7 @@ static void transportWarpHandler(CNSocket* sock, CNPacketData* data) {
|
|||||||
alert.iAnnounceType = 0; // don't think this lets us make a confirm dialog
|
alert.iAnnounceType = 0; // don't think this lets us make a confirm dialog
|
||||||
alert.iDuringTime = 3;
|
alert.iDuringTime = 3;
|
||||||
U8toU16("Skyway route " + std::to_string(route.mssRouteNum) + " isn't pathed yet. You will not be charged any taros.", (char16_t*)alert.szAnnounceMsg, sizeof(alert.szAnnounceMsg));
|
U8toU16("Skyway route " + std::to_string(route.mssRouteNum) + " isn't pathed yet. You will not be charged any taros.", (char16_t*)alert.szAnnounceMsg, sizeof(alert.szAnnounceMsg));
|
||||||
sock->sendPacket((void*)&alert, P_FE2CL_ANNOUNCE_MSG, sizeof(sP_FE2CL_ANNOUNCE_MSG));
|
sock->sendPacket(alert, P_FE2CL_ANNOUNCE_MSG);
|
||||||
|
|
||||||
std::cout << "[WARN] MSS route " << route.mssRouteNum << " not pathed" << std::endl;
|
std::cout << "[WARN] MSS route " << route.mssRouteNum << " not pathed" << std::endl;
|
||||||
break;
|
break;
|
||||||
@ -160,7 +160,7 @@ static void transportWarpHandler(CNSocket* sock, CNPacketData* data) {
|
|||||||
resp.iX = (target == nullptr) ? plr->x : target->x;
|
resp.iX = (target == nullptr) ? plr->x : target->x;
|
||||||
resp.iY = (target == nullptr) ? plr->y : target->y;
|
resp.iY = (target == nullptr) ? plr->y : target->y;
|
||||||
resp.iZ = (target == nullptr) ? plr->z : target->z;
|
resp.iZ = (target == nullptr) ? plr->z : target->z;
|
||||||
sock->sendPacket((void*)&resp, P_FE2CL_REP_PC_WARP_USE_TRANSPORTATION_SUCC, sizeof(sP_FE2CL_REP_PC_WARP_USE_TRANSPORTATION_SUCC));
|
sock->sendPacket(resp, P_FE2CL_REP_PC_WARP_USE_TRANSPORTATION_SUCC);
|
||||||
|
|
||||||
if (target == nullptr)
|
if (target == nullptr)
|
||||||
return;
|
return;
|
||||||
@ -212,9 +212,9 @@ static void stepSkywaySystem() {
|
|||||||
rideSucc.eRT = 0;
|
rideSucc.eRT = 0;
|
||||||
rideBroadcast.iPC_ID = plr->iID;
|
rideBroadcast.iPC_ID = plr->iID;
|
||||||
rideBroadcast.eRT = 0;
|
rideBroadcast.eRT = 0;
|
||||||
it->first->sendPacket((void*)&rideSucc, P_FE2CL_REP_PC_RIDING_SUCC, sizeof(sP_FE2CL_REP_PC_RIDING_SUCC));
|
it->first->sendPacket(rideSucc, P_FE2CL_REP_PC_RIDING_SUCC);
|
||||||
// send packet to players in view
|
// send packet to players in view
|
||||||
PlayerManager::sendToViewable(it->first, (void*)&rideBroadcast, P_FE2CL_PC_RIDING, sizeof(sP_FE2CL_PC_RIDING));
|
PlayerManager::sendToViewable(it->first, rideBroadcast, P_FE2CL_PC_RIDING);
|
||||||
it = SkywayQueues.erase(it); // remove player from tracking map + update iterator
|
it = SkywayQueues.erase(it); // remove player from tracking map + update iterator
|
||||||
plr->onMonkey = false;
|
plr->onMonkey = false;
|
||||||
} else {
|
} else {
|
||||||
@ -226,11 +226,11 @@ static void stepSkywaySystem() {
|
|||||||
bmstk.iToX = point.x;
|
bmstk.iToX = point.x;
|
||||||
bmstk.iToY = point.y;
|
bmstk.iToY = point.y;
|
||||||
bmstk.iToZ = point.z;
|
bmstk.iToZ = point.z;
|
||||||
it->first->sendPacket((void*)&bmstk, P_FE2CL_PC_BROOMSTICK_MOVE, sizeof(sP_FE2CL_PC_BROOMSTICK_MOVE));
|
it->first->sendPacket(bmstk, P_FE2CL_PC_BROOMSTICK_MOVE);
|
||||||
// set player location to point to update viewables
|
// set player location to point to update viewables
|
||||||
PlayerManager::updatePlayerPosition(it->first, point.x, point.y, point.z, plr->instanceID, plr->angle);
|
PlayerManager::updatePlayerPosition(it->first, point.x, point.y, point.z, plr->instanceID, plr->angle);
|
||||||
// send packet to players in view
|
// send packet to players in view
|
||||||
PlayerManager::sendToViewable(it->first, (void*)&bmstk, P_FE2CL_PC_BROOMSTICK_MOVE, sizeof(sP_FE2CL_PC_BROOMSTICK_MOVE));
|
PlayerManager::sendToViewable(it->first, bmstk, P_FE2CL_PC_BROOMSTICK_MOVE);
|
||||||
|
|
||||||
it++; // go to next entry in map
|
it++; // go to next entry in map
|
||||||
}
|
}
|
||||||
|
@ -5,7 +5,7 @@ using namespace Vendor;
|
|||||||
std::map<int32_t, std::vector<VendorListing>> Vendor::VendorTables;
|
std::map<int32_t, std::vector<VendorListing>> Vendor::VendorTables;
|
||||||
|
|
||||||
static void vendorBuy(CNSocket* sock, CNPacketData* data) {
|
static void vendorBuy(CNSocket* sock, CNPacketData* data) {
|
||||||
sP_CL2FE_REQ_PC_VENDOR_ITEM_BUY* req = (sP_CL2FE_REQ_PC_VENDOR_ITEM_BUY*)data->buf;
|
auto req = (sP_CL2FE_REQ_PC_VENDOR_ITEM_BUY*)data->buf;
|
||||||
Player* plr = PlayerManager::getPlayer(sock);
|
Player* plr = PlayerManager::getPlayer(sock);
|
||||||
|
|
||||||
// prepare fail packet
|
// prepare fail packet
|
||||||
@ -16,20 +16,20 @@ static void vendorBuy(CNSocket* sock, CNPacketData* data) {
|
|||||||
|
|
||||||
if (itemDat == nullptr) {
|
if (itemDat == nullptr) {
|
||||||
std::cout << "[WARN] Item id " << req->Item.iID << " with type " << req->Item.iType << " not found (buy)" << std::endl;
|
std::cout << "[WARN] Item id " << req->Item.iID << " with type " << req->Item.iType << " not found (buy)" << std::endl;
|
||||||
sock->sendPacket((void*)&failResp, P_FE2CL_REP_PC_VENDOR_ITEM_BUY_FAIL, sizeof(sP_FE2CL_REP_PC_VENDOR_ITEM_BUY_FAIL));
|
sock->sendPacket(failResp, P_FE2CL_REP_PC_VENDOR_ITEM_BUY_FAIL);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
int itemCost = itemDat->buyPrice * (itemDat->stackSize > 1 ? req->Item.iOpt : 1);
|
int itemCost = itemDat->buyPrice * (itemDat->stackSize > 1 ? req->Item.iOpt : 1);
|
||||||
int slot = Items::findFreeSlot(plr);
|
int slot = Items::findFreeSlot(plr);
|
||||||
if (itemCost > plr->money || slot == -1) {
|
if (itemCost > plr->money || slot == -1) {
|
||||||
sock->sendPacket((void*)&failResp, P_FE2CL_REP_PC_VENDOR_ITEM_BUY_FAIL, sizeof(sP_FE2CL_REP_PC_VENDOR_ITEM_BUY_FAIL));
|
sock->sendPacket(failResp, P_FE2CL_REP_PC_VENDOR_ITEM_BUY_FAIL);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// crates don't have a stack size in TableData, so we can't check those
|
// crates don't have a stack size in TableData, so we can't check those
|
||||||
if (itemDat->stackSize != 0 && req->Item.iOpt > itemDat->stackSize) {
|
if (itemDat->stackSize != 0 && req->Item.iOpt > itemDat->stackSize) {
|
||||||
sock->sendPacket((void*)&failResp, P_FE2CL_REP_PC_VENDOR_ITEM_BUY_FAIL, sizeof(sP_FE2CL_REP_PC_VENDOR_ITEM_BUY_FAIL));
|
sock->sendPacket(failResp, P_FE2CL_REP_PC_VENDOR_ITEM_BUY_FAIL);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -53,11 +53,11 @@ static void vendorBuy(CNSocket* sock, CNPacketData* data) {
|
|||||||
resp.iInvenSlotNum = slot;
|
resp.iInvenSlotNum = slot;
|
||||||
resp.Item = req->Item;
|
resp.Item = req->Item;
|
||||||
|
|
||||||
sock->sendPacket((void*)&resp, P_FE2CL_REP_PC_VENDOR_ITEM_BUY_SUCC, sizeof(sP_FE2CL_REP_PC_VENDOR_ITEM_BUY_SUCC));
|
sock->sendPacket(resp, P_FE2CL_REP_PC_VENDOR_ITEM_BUY_SUCC);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void vendorSell(CNSocket* sock, CNPacketData* data) {
|
static void vendorSell(CNSocket* sock, CNPacketData* data) {
|
||||||
sP_CL2FE_REQ_PC_VENDOR_ITEM_SELL* req = (sP_CL2FE_REQ_PC_VENDOR_ITEM_SELL*)data->buf;
|
auto req = (sP_CL2FE_REQ_PC_VENDOR_ITEM_SELL*)data->buf;
|
||||||
Player* plr = PlayerManager::getPlayer(sock);
|
Player* plr = PlayerManager::getPlayer(sock);
|
||||||
|
|
||||||
// prepare a fail packet
|
// prepare a fail packet
|
||||||
@ -66,7 +66,7 @@ static void vendorSell(CNSocket* sock, CNPacketData* data) {
|
|||||||
|
|
||||||
if (req->iInvenSlotNum < 0 || req->iInvenSlotNum >= AINVEN_COUNT || req->iItemCnt < 0) {
|
if (req->iInvenSlotNum < 0 || req->iInvenSlotNum >= AINVEN_COUNT || req->iItemCnt < 0) {
|
||||||
std::cout << "[WARN] Client failed to sell item in slot " << req->iInvenSlotNum << std::endl;
|
std::cout << "[WARN] Client failed to sell item in slot " << req->iInvenSlotNum << std::endl;
|
||||||
sock->sendPacket((void*)&failResp, P_FE2CL_REP_PC_VENDOR_ITEM_SELL_FAIL, sizeof(sP_FE2CL_REP_PC_VENDOR_ITEM_SELL_FAIL));
|
sock->sendPacket(failResp, P_FE2CL_REP_PC_VENDOR_ITEM_SELL_FAIL);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -75,13 +75,13 @@ static void vendorSell(CNSocket* sock, CNPacketData* data) {
|
|||||||
|
|
||||||
if (itemData == nullptr || !itemData->sellable || item->iOpt < req->iItemCnt) { // sanity + sellable check
|
if (itemData == nullptr || !itemData->sellable || item->iOpt < req->iItemCnt) { // sanity + sellable check
|
||||||
std::cout << "[WARN] Item id " << item->iID << " with type " << item->iType << " not found (sell)" << std::endl;
|
std::cout << "[WARN] Item id " << item->iID << " with type " << item->iType << " not found (sell)" << std::endl;
|
||||||
sock->sendPacket((void*)&failResp, P_FE2CL_REP_PC_VENDOR_ITEM_SELL_FAIL, sizeof(sP_FE2CL_REP_PC_VENDOR_ITEM_SELL_FAIL));
|
sock->sendPacket(failResp, P_FE2CL_REP_PC_VENDOR_ITEM_SELL_FAIL);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// fail to sell croc-potted items
|
// fail to sell croc-potted items
|
||||||
if (item->iOpt >= 1 << 16) {
|
if (item->iOpt >= 1 << 16) {
|
||||||
sock->sendPacket((void*)&failResp, P_FE2CL_REP_PC_VENDOR_ITEM_SELL_FAIL, sizeof(sP_FE2CL_REP_PC_VENDOR_ITEM_SELL_FAIL));
|
sock->sendPacket(failResp, P_FE2CL_REP_PC_VENDOR_ITEM_SELL_FAIL);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -116,11 +116,11 @@ static void vendorSell(CNSocket* sock, CNPacketData* data) {
|
|||||||
resp.Item = original; // the item that gets sent to buyback
|
resp.Item = original; // the item that gets sent to buyback
|
||||||
resp.ItemStay = *item; // the void item that gets put in the slot
|
resp.ItemStay = *item; // the void item that gets put in the slot
|
||||||
|
|
||||||
sock->sendPacket((void*)&resp, P_FE2CL_REP_PC_VENDOR_ITEM_SELL_SUCC, sizeof(sP_FE2CL_REP_PC_VENDOR_ITEM_SELL_SUCC));
|
sock->sendPacket(resp, P_FE2CL_REP_PC_VENDOR_ITEM_SELL_SUCC);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void vendorBuyback(CNSocket* sock, CNPacketData* data) {
|
static void vendorBuyback(CNSocket* sock, CNPacketData* data) {
|
||||||
sP_CL2FE_REQ_PC_VENDOR_ITEM_RESTORE_BUY* req = (sP_CL2FE_REQ_PC_VENDOR_ITEM_RESTORE_BUY*)data->buf;
|
auto req = (sP_CL2FE_REQ_PC_VENDOR_ITEM_RESTORE_BUY*)data->buf;
|
||||||
Player* plr = PlayerManager::getPlayer(sock);
|
Player* plr = PlayerManager::getPlayer(sock);
|
||||||
|
|
||||||
// prepare fail packet
|
// prepare fail packet
|
||||||
@ -134,7 +134,7 @@ static void vendorBuyback(CNSocket* sock, CNPacketData* data) {
|
|||||||
|
|
||||||
// sanity check
|
// sanity check
|
||||||
if (idx < 0 || idx >= plr->buyback.size()) {
|
if (idx < 0 || idx >= plr->buyback.size()) {
|
||||||
sock->sendPacket((void*)&failResp, P_FE2CL_REP_PC_VENDOR_ITEM_RESTORE_BUY_FAIL, sizeof(sP_FE2CL_REP_PC_VENDOR_ITEM_RESTORE_BUY_FAIL));
|
sock->sendPacket(failResp, P_FE2CL_REP_PC_VENDOR_ITEM_RESTORE_BUY_FAIL);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -166,7 +166,7 @@ static void vendorBuyback(CNSocket* sock, CNPacketData* data) {
|
|||||||
|
|
||||||
if (itemDat == nullptr) {
|
if (itemDat == nullptr) {
|
||||||
std::cout << "[WARN] Item id " << item.iID << " with type " << item.iType << " not found (rebuy)" << std::endl;
|
std::cout << "[WARN] Item id " << item.iID << " with type " << item.iType << " not found (rebuy)" << std::endl;
|
||||||
sock->sendPacket((void*)&failResp, P_FE2CL_REP_PC_VENDOR_ITEM_RESTORE_BUY_FAIL, sizeof(sP_FE2CL_REP_PC_VENDOR_ITEM_RESTORE_BUY_FAIL));
|
sock->sendPacket(failResp, P_FE2CL_REP_PC_VENDOR_ITEM_RESTORE_BUY_FAIL);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -174,7 +174,7 @@ static void vendorBuyback(CNSocket* sock, CNPacketData* data) {
|
|||||||
int itemCost = itemDat->sellPrice * (itemDat->stackSize > 1 ? item.iOpt : 1);
|
int itemCost = itemDat->sellPrice * (itemDat->stackSize > 1 ? item.iOpt : 1);
|
||||||
int slot = Items::findFreeSlot(plr);
|
int slot = Items::findFreeSlot(plr);
|
||||||
if (itemCost > plr->money || slot == -1) {
|
if (itemCost > plr->money || slot == -1) {
|
||||||
sock->sendPacket((void*)&failResp, P_FE2CL_REP_PC_VENDOR_ITEM_RESTORE_BUY_FAIL, sizeof(sP_FE2CL_REP_PC_VENDOR_ITEM_RESTORE_BUY_FAIL));
|
sock->sendPacket(failResp, P_FE2CL_REP_PC_VENDOR_ITEM_RESTORE_BUY_FAIL);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -192,11 +192,11 @@ static void vendorBuyback(CNSocket* sock, CNPacketData* data) {
|
|||||||
resp.iInvenSlotNum = slot;
|
resp.iInvenSlotNum = slot;
|
||||||
resp.Item = item;
|
resp.Item = item;
|
||||||
|
|
||||||
sock->sendPacket((void*)&resp, P_FE2CL_REP_PC_VENDOR_ITEM_RESTORE_BUY_SUCC, sizeof(sP_FE2CL_REP_PC_VENDOR_ITEM_RESTORE_BUY_SUCC));
|
sock->sendPacket(resp, P_FE2CL_REP_PC_VENDOR_ITEM_RESTORE_BUY_SUCC);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void vendorTable(CNSocket* sock, CNPacketData* data) {
|
static void vendorTable(CNSocket* sock, CNPacketData* data) {
|
||||||
sP_CL2FE_REQ_PC_VENDOR_TABLE_UPDATE* req = (sP_CL2FE_REQ_PC_VENDOR_TABLE_UPDATE*)data->buf;
|
auto req = (sP_CL2FE_REQ_PC_VENDOR_TABLE_UPDATE*)data->buf;
|
||||||
|
|
||||||
if (req->iVendorID != req->iNPC_ID || Vendor::VendorTables.find(req->iVendorID) == Vendor::VendorTables.end())
|
if (req->iVendorID != req->iNPC_ID || Vendor::VendorTables.find(req->iVendorID) == Vendor::VendorTables.end())
|
||||||
return;
|
return;
|
||||||
@ -221,28 +221,28 @@ static void vendorTable(CNSocket* sock, CNPacketData* data) {
|
|||||||
resp.item[i] = vItem;
|
resp.item[i] = vItem;
|
||||||
}
|
}
|
||||||
|
|
||||||
sock->sendPacket((void*)&resp, P_FE2CL_REP_PC_VENDOR_TABLE_UPDATE_SUCC, sizeof(sP_FE2CL_REP_PC_VENDOR_TABLE_UPDATE_SUCC));
|
sock->sendPacket(resp, P_FE2CL_REP_PC_VENDOR_TABLE_UPDATE_SUCC);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void vendorStart(CNSocket* sock, CNPacketData* data) {
|
static void vendorStart(CNSocket* sock, CNPacketData* data) {
|
||||||
sP_CL2FE_REQ_PC_VENDOR_START* req = (sP_CL2FE_REQ_PC_VENDOR_START*)data->buf;
|
auto req = (sP_CL2FE_REQ_PC_VENDOR_START*)data->buf;
|
||||||
INITSTRUCT(sP_FE2CL_REP_PC_VENDOR_START_SUCC, resp);
|
INITSTRUCT(sP_FE2CL_REP_PC_VENDOR_START_SUCC, resp);
|
||||||
|
|
||||||
resp.iNPC_ID = req->iNPC_ID;
|
resp.iNPC_ID = req->iNPC_ID;
|
||||||
resp.iVendorID = req->iVendorID;
|
resp.iVendorID = req->iVendorID;
|
||||||
|
|
||||||
sock->sendPacket((void*)&resp, P_FE2CL_REP_PC_VENDOR_START_SUCC, sizeof(sP_FE2CL_REP_PC_VENDOR_START_SUCC));
|
sock->sendPacket(resp, P_FE2CL_REP_PC_VENDOR_START_SUCC);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void vendorBuyBattery(CNSocket* sock, CNPacketData* data) {
|
static void vendorBuyBattery(CNSocket* sock, CNPacketData* data) {
|
||||||
sP_CL2FE_REQ_PC_VENDOR_BATTERY_BUY* req = (sP_CL2FE_REQ_PC_VENDOR_BATTERY_BUY*)data->buf;
|
auto req = (sP_CL2FE_REQ_PC_VENDOR_BATTERY_BUY*)data->buf;
|
||||||
Player* plr = PlayerManager::getPlayer(sock);
|
Player* plr = PlayerManager::getPlayer(sock);
|
||||||
|
|
||||||
int cost = req->Item.iOpt * 100;
|
int cost = req->Item.iOpt * 100;
|
||||||
if ((req->Item.iID == 3 ? (plr->batteryW >= 9999) : (plr->batteryN >= 9999)) || plr->money < cost || req->Item.iOpt < 0) { // sanity check
|
if ((req->Item.iID == 3 ? (plr->batteryW >= 9999) : (plr->batteryN >= 9999)) || plr->money < cost || req->Item.iOpt < 0) { // sanity check
|
||||||
INITSTRUCT(sP_FE2CL_REP_PC_VENDOR_BATTERY_BUY_FAIL, failResp);
|
INITSTRUCT(sP_FE2CL_REP_PC_VENDOR_BATTERY_BUY_FAIL, failResp);
|
||||||
failResp.iErrorCode = 0;
|
failResp.iErrorCode = 0;
|
||||||
sock->sendPacket((void*)&failResp, P_FE2CL_REP_PC_VENDOR_BATTERY_BUY_FAIL, sizeof(sP_FE2CL_REP_PC_VENDOR_BATTERY_BUY_FAIL));
|
sock->sendPacket(failResp, P_FE2CL_REP_PC_VENDOR_BATTERY_BUY_FAIL);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -265,11 +265,11 @@ static void vendorBuyBattery(CNSocket* sock, CNPacketData* data) {
|
|||||||
resp.iBatteryW = plr->batteryW;
|
resp.iBatteryW = plr->batteryW;
|
||||||
resp.iBatteryN = plr->batteryN;
|
resp.iBatteryN = plr->batteryN;
|
||||||
|
|
||||||
sock->sendPacket((void*)&resp, P_FE2CL_REP_PC_VENDOR_BATTERY_BUY_SUCC, sizeof(sP_FE2CL_REP_PC_VENDOR_BATTERY_BUY_SUCC));
|
sock->sendPacket(resp, P_FE2CL_REP_PC_VENDOR_BATTERY_BUY_SUCC);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void vendorCombineItems(CNSocket* sock, CNPacketData* data) {
|
static void vendorCombineItems(CNSocket* sock, CNPacketData* data) {
|
||||||
sP_CL2FE_REQ_PC_ITEM_COMBINATION* req = (sP_CL2FE_REQ_PC_ITEM_COMBINATION*)data->buf;
|
auto req = (sP_CL2FE_REQ_PC_ITEM_COMBINATION*)data->buf;
|
||||||
Player* plr = PlayerManager::getPlayer(sock);
|
Player* plr = PlayerManager::getPlayer(sock);
|
||||||
|
|
||||||
// prepare fail packet
|
// prepare fail packet
|
||||||
@ -281,7 +281,7 @@ static void vendorCombineItems(CNSocket* sock, CNPacketData* data) {
|
|||||||
// sanity check slot indices
|
// sanity check slot indices
|
||||||
if (req->iCostumeItemSlot < 0 || req->iCostumeItemSlot >= AINVEN_COUNT || req->iStatItemSlot < 0 || req->iStatItemSlot >= AINVEN_COUNT) {
|
if (req->iCostumeItemSlot < 0 || req->iCostumeItemSlot >= AINVEN_COUNT || req->iStatItemSlot < 0 || req->iStatItemSlot >= AINVEN_COUNT) {
|
||||||
std::cout << "[WARN] Inventory slot(s) out of range (" << req->iStatItemSlot << " and " << req->iCostumeItemSlot << ")" << std::endl;
|
std::cout << "[WARN] Inventory slot(s) out of range (" << req->iStatItemSlot << " and " << req->iCostumeItemSlot << ")" << std::endl;
|
||||||
sock->sendPacket((void*)&failResp, P_FE2CL_REP_PC_ITEM_COMBINATION_FAIL, sizeof(sP_FE2CL_REP_PC_ITEM_COMBINATION_FAIL));
|
sock->sendPacket(failResp, P_FE2CL_REP_PC_ITEM_COMBINATION_FAIL);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -294,7 +294,7 @@ static void vendorCombineItems(CNSocket* sock, CNPacketData* data) {
|
|||||||
if (itemStatsDat == nullptr || itemLooksDat == nullptr
|
if (itemStatsDat == nullptr || itemLooksDat == nullptr
|
||||||
|| Items::CrocPotTable.find(abs(itemStatsDat->level - itemLooksDat->level)) == Items::CrocPotTable.end()) {
|
|| Items::CrocPotTable.find(abs(itemStatsDat->level - itemLooksDat->level)) == Items::CrocPotTable.end()) {
|
||||||
std::cout << "[WARN] Either item ids or croc pot value set not found" << std::endl;
|
std::cout << "[WARN] Either item ids or croc pot value set not found" << std::endl;
|
||||||
sock->sendPacket((void*)&failResp, P_FE2CL_REP_PC_ITEM_COMBINATION_FAIL, sizeof(sP_FE2CL_REP_PC_ITEM_COMBINATION_FAIL));
|
sock->sendPacket(failResp, P_FE2CL_REP_PC_ITEM_COMBINATION_FAIL);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -302,7 +302,7 @@ static void vendorCombineItems(CNSocket* sock, CNPacketData* data) {
|
|||||||
if (itemStats->iType != itemLooks->iType
|
if (itemStats->iType != itemLooks->iType
|
||||||
|| (itemStats->iType == 0 && itemStatsDat->weaponType != itemLooksDat->weaponType)) {
|
|| (itemStats->iType == 0 && itemStatsDat->weaponType != itemLooksDat->weaponType)) {
|
||||||
std::cout << "[WARN] Player attempted to combine mismatched items" << std::endl;
|
std::cout << "[WARN] Player attempted to combine mismatched items" << std::endl;
|
||||||
sock->sendPacket((void*)&failResp, P_FE2CL_REP_PC_ITEM_COMBINATION_FAIL, sizeof(sP_FE2CL_REP_PC_ITEM_COMBINATION_FAIL));
|
sock->sendPacket(failResp, P_FE2CL_REP_PC_ITEM_COMBINATION_FAIL);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -357,7 +357,7 @@ static void vendorCombineItems(CNSocket* sock, CNPacketData* data) {
|
|||||||
resp.iStatItemSlot = req->iStatItemSlot;
|
resp.iStatItemSlot = req->iStatItemSlot;
|
||||||
resp.sNewItem = *itemLooks;
|
resp.sNewItem = *itemLooks;
|
||||||
|
|
||||||
sock->sendPacket((void*)&resp, P_FE2CL_REP_PC_ITEM_COMBINATION_SUCC, sizeof(sP_FE2CL_REP_PC_ITEM_COMBINATION_SUCC));
|
sock->sendPacket(resp, P_FE2CL_REP_PC_ITEM_COMBINATION_SUCC);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Vendor::init() {
|
void Vendor::init() {
|
||||||
|
Loading…
Reference in New Issue
Block a user