mirror of
https://github.com/OpenFusionProject/OpenFusion.git
synced 2024-11-24 14:01:05 +00:00
[refactor] Remove the word 'Manager' from most source files/namespaces
ChatManager -> Chat MissionManager -> Missions NanoManager -> Nanos TransportManager -> Transport ChunkManager -> Chunking BuddyManager -> Buddies GroupManager -> Groups RacingManager -> Racing ItemManager -> Items NPCManager and PlayerManager remain. Note: You can use git log --follow src/file.cpp to trace the history of a file from before it was renamed.
This commit is contained in:
parent
cee09f6344
commit
e9bc2fe561
36
Makefile
36
Makefile
@ -42,7 +42,7 @@ CXXSRC=\
|
|||||||
src/db/shard.cpp\
|
src/db/shard.cpp\
|
||||||
src/db/player.cpp\
|
src/db/player.cpp\
|
||||||
src/db/email.cpp\
|
src/db/email.cpp\
|
||||||
src/ChatManager.cpp\
|
src/Chat.cpp\
|
||||||
src/CustomCommands.cpp\
|
src/CustomCommands.cpp\
|
||||||
src/CNLoginServer.cpp\
|
src/CNLoginServer.cpp\
|
||||||
src/CNProtocol.cpp\
|
src/CNProtocol.cpp\
|
||||||
@ -51,24 +51,24 @@ CXXSRC=\
|
|||||||
src/Defines.cpp\
|
src/Defines.cpp\
|
||||||
src/Email.cpp\
|
src/Email.cpp\
|
||||||
src/main.cpp\
|
src/main.cpp\
|
||||||
src/MissionManager.cpp\
|
src/Missions.cpp\
|
||||||
src/MobAI.cpp\
|
src/MobAI.cpp\
|
||||||
src/Combat.cpp\
|
src/Combat.cpp\
|
||||||
src/NanoManager.cpp\
|
src/Nanos.cpp\
|
||||||
src/Abilities.cpp\
|
src/Abilities.cpp\
|
||||||
src/ItemManager.cpp\
|
src/Items.cpp\
|
||||||
src/NPCManager.cpp\
|
src/NPCManager.cpp\
|
||||||
src/PlayerManager.cpp\
|
src/PlayerManager.cpp\
|
||||||
src/PlayerMovement.cpp\
|
src/PlayerMovement.cpp\
|
||||||
src/BuiltinCommands.cpp\
|
src/BuiltinCommands.cpp\
|
||||||
src/settings.cpp\
|
src/settings.cpp\
|
||||||
src/TransportManager.cpp\
|
src/Transport.cpp\
|
||||||
src/TableData.cpp\
|
src/TableData.cpp\
|
||||||
src/ChunkManager.cpp\
|
src/Chunking.cpp\
|
||||||
src/BuddyManager.cpp\
|
src/Buddies.cpp\
|
||||||
src/GroupManager.cpp\
|
src/Groups.cpp\
|
||||||
src/Monitor.cpp\
|
src/Monitor.cpp\
|
||||||
src/RacingManager.cpp\
|
src/Racing.cpp\
|
||||||
src/Vendor.cpp\
|
src/Vendor.cpp\
|
||||||
src/Trading.cpp\
|
src/Trading.cpp\
|
||||||
|
|
||||||
@ -81,7 +81,7 @@ CXXHDR=\
|
|||||||
vendor/JSON.hpp\
|
vendor/JSON.hpp\
|
||||||
src/db/Database.hpp\
|
src/db/Database.hpp\
|
||||||
src/db/internal.hpp\
|
src/db/internal.hpp\
|
||||||
src/ChatManager.hpp\
|
src/Chat.hpp\
|
||||||
src/CustomCommands.hpp\
|
src/CustomCommands.hpp\
|
||||||
src/CNLoginServer.hpp\
|
src/CNLoginServer.hpp\
|
||||||
src/CNProtocol.hpp\
|
src/CNProtocol.hpp\
|
||||||
@ -90,25 +90,25 @@ CXXHDR=\
|
|||||||
src/CNStructs.hpp\
|
src/CNStructs.hpp\
|
||||||
src/Defines.hpp\
|
src/Defines.hpp\
|
||||||
src/Email.hpp\
|
src/Email.hpp\
|
||||||
src/MissionManager.hpp\
|
src/Missions.hpp\
|
||||||
src/MobAI.hpp\
|
src/MobAI.hpp\
|
||||||
src/Combat.hpp\
|
src/Combat.hpp\
|
||||||
src/NanoManager.hpp\
|
src/Nanos.hpp\
|
||||||
src/Abilities.hpp\
|
src/Abilities.hpp\
|
||||||
src/ItemManager.hpp\
|
src/Items.hpp\
|
||||||
src/NPCManager.hpp\
|
src/NPCManager.hpp\
|
||||||
src/Player.hpp\
|
src/Player.hpp\
|
||||||
src/PlayerManager.hpp\
|
src/PlayerManager.hpp\
|
||||||
src/PlayerMovement.hpp\
|
src/PlayerMovement.hpp\
|
||||||
src/BuiltinCommands.hpp\
|
src/BuiltinCommands.hpp\
|
||||||
src/settings.hpp\
|
src/settings.hpp\
|
||||||
src/TransportManager.hpp\
|
src/Transport.hpp\
|
||||||
src/TableData.hpp\
|
src/TableData.hpp\
|
||||||
src/ChunkManager.hpp\
|
src/Chunking.hpp\
|
||||||
src/BuddyManager.hpp\
|
src/Buddies.hpp\
|
||||||
src/GroupManager.hpp\
|
src/Groups.hpp\
|
||||||
src/Monitor.hpp\
|
src/Monitor.hpp\
|
||||||
src/RacingManager.hpp\
|
src/Racing.hpp\
|
||||||
src/Vendor.hpp\
|
src/Vendor.hpp\
|
||||||
src/Trading.hpp\
|
src/Trading.hpp\
|
||||||
|
|
||||||
|
@ -2,21 +2,21 @@
|
|||||||
#include "PlayerManager.hpp"
|
#include "PlayerManager.hpp"
|
||||||
#include "Player.hpp"
|
#include "Player.hpp"
|
||||||
#include "NPCManager.hpp"
|
#include "NPCManager.hpp"
|
||||||
#include "NanoManager.hpp"
|
#include "Nanos.hpp"
|
||||||
#include "GroupManager.hpp"
|
#include "Groups.hpp"
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* TODO: This file is in desperate need of deduplication and rewriting.
|
* TODO: This file is in desperate need of deduplication and rewriting.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
std::map<int32_t, SkillData> NanoManager::SkillTable;
|
std::map<int32_t, SkillData> Nanos::SkillTable;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* targetData approach
|
* targetData approach
|
||||||
* first integer is the count
|
* first integer is the count
|
||||||
* second to fifth integers are IDs, these can be either player iID or mob's iID
|
* second to fifth integers are IDs, these can be either player iID or mob's iID
|
||||||
*/
|
*/
|
||||||
std::vector<int> NanoManager::findTargets(Player* plr, int skillID, CNPacketData* data) {
|
std::vector<int> Nanos::findTargets(Player* plr, int skillID, CNPacketData* data) {
|
||||||
std::vector<int> tD(5);
|
std::vector<int> tD(5);
|
||||||
|
|
||||||
if (SkillTable[skillID].targetType <= 2 && data != nullptr) { // client gives us the targets
|
if (SkillTable[skillID].targetType <= 2 && data != nullptr) { // client gives us the targets
|
||||||
@ -65,7 +65,7 @@ std::vector<int> NanoManager::findTargets(Player* plr, int skillID, CNPacketData
|
|||||||
return tD;
|
return tD;
|
||||||
}
|
}
|
||||||
|
|
||||||
void NanoManager::nanoUnbuff(CNSocket* sock, std::vector<int> targetData, int32_t bitFlag, int16_t timeBuffID, int16_t amount, bool groupPower) {
|
void Nanos::nanoUnbuff(CNSocket* sock, std::vector<int> targetData, int32_t bitFlag, int16_t timeBuffID, int16_t amount, bool groupPower) {
|
||||||
Player *plr = PlayerManager::getPlayer(sock);
|
Player *plr = PlayerManager::getPlayer(sock);
|
||||||
|
|
||||||
plr->iSelfConditionBitFlag &= ~bitFlag;
|
plr->iSelfConditionBitFlag &= ~bitFlag;
|
||||||
@ -75,7 +75,7 @@ void NanoManager::nanoUnbuff(CNSocket* sock, std::vector<int> targetData, int32_
|
|||||||
plr->iGroupConditionBitFlag &= ~bitFlag;
|
plr->iGroupConditionBitFlag &= ~bitFlag;
|
||||||
Player *leader = PlayerManager::getPlayerFromID(plr->iIDGroup);
|
Player *leader = PlayerManager::getPlayerFromID(plr->iIDGroup);
|
||||||
if (leader != nullptr)
|
if (leader != nullptr)
|
||||||
groupFlags = GroupManager::getGroupFlags(leader);
|
groupFlags = Groups::getGroupFlags(leader);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 0; i < targetData[0]; i++) {
|
for (int i = 0; i < targetData[0]; i++) {
|
||||||
@ -100,7 +100,7 @@ void NanoManager::nanoUnbuff(CNSocket* sock, std::vector<int> targetData, int32_
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int NanoManager::applyBuff(CNSocket* sock, int skillID, int eTBU, int eTBT, int32_t groupFlags) {
|
int Nanos::applyBuff(CNSocket* sock, int skillID, int eTBU, int eTBT, int32_t groupFlags) {
|
||||||
if (SkillTable[skillID].drainType == 1)
|
if (SkillTable[skillID].drainType == 1)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
@ -133,7 +133,7 @@ int NanoManager::applyBuff(CNSocket* sock, int skillID, int eTBU, int eTBT, int3
|
|||||||
}
|
}
|
||||||
|
|
||||||
#pragma region Nano Powers
|
#pragma region Nano Powers
|
||||||
namespace NanoManager {
|
namespace Nanos {
|
||||||
|
|
||||||
bool doDebuff(CNSocket *sock, sSkillResult_Buff *respdata, int i, int32_t targetID, int32_t bitFlag, int16_t timeBuffID, int16_t duration, int16_t amount) {
|
bool doDebuff(CNSocket *sock, sSkillResult_Buff *respdata, int i, int32_t targetID, int32_t bitFlag, int16_t timeBuffID, int16_t duration, int16_t amount) {
|
||||||
if (MobAI::Mobs.find(targetID) == MobAI::Mobs.end()) {
|
if (MobAI::Mobs.find(targetID) == MobAI::Mobs.end()) {
|
||||||
|
@ -49,7 +49,7 @@ struct SkillData {
|
|||||||
int powerIntensity[4];
|
int powerIntensity[4];
|
||||||
};
|
};
|
||||||
|
|
||||||
namespace NanoManager {
|
namespace Nanos {
|
||||||
extern std::vector<NanoPower> NanoPowers;
|
extern std::vector<NanoPower> NanoPowers;
|
||||||
extern std::map<int32_t, SkillData> SkillTable;
|
extern std::map<int32_t, SkillData> SkillTable;
|
||||||
|
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
#include "CNShardServer.hpp"
|
#include "CNShardServer.hpp"
|
||||||
#include "CNStructs.hpp"
|
#include "CNStructs.hpp"
|
||||||
#include "ChatManager.hpp"
|
#include "Buddies.hpp"
|
||||||
#include "PlayerManager.hpp"
|
#include "PlayerManager.hpp"
|
||||||
#include "BuddyManager.hpp"
|
#include "Buddies.hpp"
|
||||||
#include "db/Database.hpp"
|
#include "db/Database.hpp"
|
||||||
#include "ItemManager.hpp"
|
#include "Items.hpp"
|
||||||
#include "db/Database.hpp"
|
#include "db/Database.hpp"
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
@ -12,7 +12,7 @@
|
|||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <thread>
|
#include <thread>
|
||||||
|
|
||||||
using namespace BuddyManager;
|
using namespace Buddies;
|
||||||
|
|
||||||
#pragma region Helper methods
|
#pragma region Helper methods
|
||||||
|
|
||||||
@ -36,7 +36,7 @@ static bool playerHasBuddyWithID(Player* plr, int buddyID) {
|
|||||||
#pragma endregion
|
#pragma endregion
|
||||||
|
|
||||||
// Refresh buddy list
|
// Refresh buddy list
|
||||||
void BuddyManager::refreshBuddyList(CNSocket* sock) {
|
void Buddies::refreshBuddyList(CNSocket* sock) {
|
||||||
Player* plr = PlayerManager::getPlayer(sock);
|
Player* plr = PlayerManager::getPlayer(sock);
|
||||||
int buddyCnt = Database::getNumBuddies(plr);
|
int buddyCnt = Database::getNumBuddies(plr);
|
||||||
|
|
||||||
@ -483,7 +483,7 @@ fail:
|
|||||||
sock->sendPacket((void*)&resp, P_FE2CL_REP_PC_BUDDY_WARP_FAIL, sizeof(sP_FE2CL_REP_PC_BUDDY_WARP_FAIL));
|
sock->sendPacket((void*)&resp, P_FE2CL_REP_PC_BUDDY_WARP_FAIL, sizeof(sP_FE2CL_REP_PC_BUDDY_WARP_FAIL));
|
||||||
}
|
}
|
||||||
|
|
||||||
void BuddyManager::init() {
|
void Buddies::init() {
|
||||||
REGISTER_SHARD_PACKET(P_CL2FE_REQ_REQUEST_MAKE_BUDDY, requestBuddy);
|
REGISTER_SHARD_PACKET(P_CL2FE_REQ_REQUEST_MAKE_BUDDY, requestBuddy);
|
||||||
REGISTER_SHARD_PACKET(P_CL2FE_REQ_PC_FIND_NAME_MAKE_BUDDY, reqBuddyByName);
|
REGISTER_SHARD_PACKET(P_CL2FE_REQ_PC_FIND_NAME_MAKE_BUDDY, reqBuddyByName);
|
||||||
REGISTER_SHARD_PACKET(P_CL2FE_REQ_ACCEPT_MAKE_BUDDY, reqAcceptBuddy);
|
REGISTER_SHARD_PACKET(P_CL2FE_REQ_ACCEPT_MAKE_BUDDY, reqAcceptBuddy);
|
@ -5,7 +5,7 @@
|
|||||||
#include "CNStructs.hpp"
|
#include "CNStructs.hpp"
|
||||||
#include "CNProtocol.hpp"
|
#include "CNProtocol.hpp"
|
||||||
|
|
||||||
namespace BuddyManager {
|
namespace Buddies {
|
||||||
void init();
|
void init();
|
||||||
|
|
||||||
// Buddy list
|
// Buddy list
|
@ -1,8 +1,8 @@
|
|||||||
#include "BuiltinCommands.hpp"
|
#include "BuiltinCommands.hpp"
|
||||||
#include "PlayerManager.hpp"
|
#include "PlayerManager.hpp"
|
||||||
#include "ChatManager.hpp"
|
#include "Chat.hpp"
|
||||||
#include "ItemManager.hpp"
|
#include "Items.hpp"
|
||||||
#include "MissionManager.hpp"
|
#include "Missions.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) {
|
||||||
@ -14,7 +14,7 @@ void BuiltinCommands::setSpecialState(CNSocket* sock, CNPacketData* data) {
|
|||||||
|
|
||||||
// HACK: work around the invisible weapon bug
|
// HACK: work around the invisible weapon bug
|
||||||
if (setData->iSpecialStateFlag == CN_SPECIAL_STATE_FLAG__FULL_UI)
|
if (setData->iSpecialStateFlag == CN_SPECIAL_STATE_FLAG__FULL_UI)
|
||||||
ItemManager::updateEquips(sock, plr);
|
Items::updateEquips(sock, plr);
|
||||||
|
|
||||||
INITSTRUCT(sP_FE2CL_PC_SPECIAL_STATE_CHANGE, response);
|
INITSTRUCT(sP_FE2CL_PC_SPECIAL_STATE_CHANGE, response);
|
||||||
|
|
||||||
@ -93,7 +93,7 @@ static void setValuePlayer(CNSocket* sock, CNPacketData* data) {
|
|||||||
plr->batteryN = 9999;
|
plr->batteryN = 9999;
|
||||||
break;
|
break;
|
||||||
case 4:
|
case 4:
|
||||||
MissionManager::updateFusionMatter(sock, setData->iSetValue - plr->fusionmatter);
|
Missions::updateFusionMatter(sock, setData->iSetValue - plr->fusionmatter);
|
||||||
break;
|
break;
|
||||||
case 5:
|
case 5:
|
||||||
plr->money = setData->iSetValue;
|
plr->money = setData->iSetValue;
|
||||||
@ -133,7 +133,7 @@ static void setGMSpecialOnOff(CNSocket *sock, CNPacketData *data) {
|
|||||||
CNSocket *otherSock = PlayerManager::getSockFromAny(req->eTargetSearchBy, req->iTargetPC_ID, req->iTargetPC_UID,
|
CNSocket *otherSock = PlayerManager::getSockFromAny(req->eTargetSearchBy, req->iTargetPC_ID, req->iTargetPC_UID,
|
||||||
U16toU8(req->szTargetPC_FirstName), U16toU8(req->szTargetPC_LastName));
|
U16toU8(req->szTargetPC_FirstName), U16toU8(req->szTargetPC_LastName));
|
||||||
if (otherSock == nullptr) {
|
if (otherSock == nullptr) {
|
||||||
ChatManager::sendServerMessage(sock, "player to teleport not found");
|
Chat::sendServerMessage(sock, "player to teleport not found");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -161,7 +161,7 @@ static void locatePlayer(CNSocket *sock, CNPacketData *data) {
|
|||||||
CNSocket *otherSock = PlayerManager::getSockFromAny(req->eTargetSearchBy, req->iTargetPC_ID, req->iTargetPC_UID,
|
CNSocket *otherSock = PlayerManager::getSockFromAny(req->eTargetSearchBy, req->iTargetPC_ID, req->iTargetPC_UID,
|
||||||
U16toU8(req->szTargetPC_FirstName), U16toU8(req->szTargetPC_LastName));
|
U16toU8(req->szTargetPC_FirstName), U16toU8(req->szTargetPC_LastName));
|
||||||
if (otherSock == nullptr) {
|
if (otherSock == nullptr) {
|
||||||
ChatManager::sendServerMessage(sock, "player not found");
|
Chat::sendServerMessage(sock, "player not found");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -199,14 +199,14 @@ static void kickPlayer(CNSocket *sock, CNPacketData *data) {
|
|||||||
CNSocket *otherSock = PlayerManager::getSockFromAny(req->eTargetSearchBy, req->iTargetPC_ID, req->iTargetPC_UID,
|
CNSocket *otherSock = PlayerManager::getSockFromAny(req->eTargetSearchBy, req->iTargetPC_ID, req->iTargetPC_UID,
|
||||||
U16toU8(req->szTargetPC_FirstName), U16toU8(req->szTargetPC_LastName));
|
U16toU8(req->szTargetPC_FirstName), U16toU8(req->szTargetPC_LastName));
|
||||||
if (otherSock == nullptr) {
|
if (otherSock == nullptr) {
|
||||||
ChatManager::sendServerMessage(sock, "player not found");
|
Chat::sendServerMessage(sock, "player not found");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Player *otherPlr = PlayerManager::getPlayer(otherSock);
|
Player *otherPlr = PlayerManager::getPlayer(otherSock);
|
||||||
|
|
||||||
if (plr->accountLevel > otherPlr->accountLevel) {
|
if (plr->accountLevel > otherPlr->accountLevel) {
|
||||||
ChatManager::sendServerMessage(sock, "player has higher access level");
|
Chat::sendServerMessage(sock, "player has higher access level");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -236,7 +236,7 @@ static void warpToPlayer(CNSocket *sock, CNPacketData *data) {
|
|||||||
|
|
||||||
Player *otherPlr = PlayerManager::getPlayerFromID(req->iPC_ID);
|
Player *otherPlr = PlayerManager::getPlayerFromID(req->iPC_ID);
|
||||||
if (otherPlr == nullptr) {
|
if (otherPlr == nullptr) {
|
||||||
ChatManager::sendServerMessage(sock, "player not found");
|
Chat::sendServerMessage(sock, "player not found");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -260,7 +260,7 @@ static void teleportPlayer(CNSocket *sock, CNPacketData *data) {
|
|||||||
CNSocket *targetSock = PlayerManager::getSockFromAny(req->eTargetPCSearchBy, req->iTargetPC_ID, req->iTargetPC_UID,
|
CNSocket *targetSock = PlayerManager::getSockFromAny(req->eTargetPCSearchBy, req->iTargetPC_ID, req->iTargetPC_UID,
|
||||||
U16toU8(req->szTargetPC_FirstName), U16toU8(req->szTargetPC_LastName));
|
U16toU8(req->szTargetPC_FirstName), U16toU8(req->szTargetPC_LastName));
|
||||||
if (targetSock == nullptr) {
|
if (targetSock == nullptr) {
|
||||||
ChatManager::sendServerMessage(sock, "player to teleport not found");
|
Chat::sendServerMessage(sock, "player to teleport not found");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -285,7 +285,7 @@ static void teleportPlayer(CNSocket *sock, CNPacketData *data) {
|
|||||||
goalSock = PlayerManager::getSockFromAny(req->eGoalPCSearchBy, req->iGoalPC_ID, req->iGoalPC_UID,
|
goalSock = PlayerManager::getSockFromAny(req->eGoalPCSearchBy, req->iGoalPC_ID, req->iGoalPC_UID,
|
||||||
U16toU8(req->szGoalPC_FirstName), U16toU8(req->szGoalPC_LastName));
|
U16toU8(req->szGoalPC_FirstName), U16toU8(req->szGoalPC_LastName));
|
||||||
if (goalSock == nullptr) {
|
if (goalSock == nullptr) {
|
||||||
ChatManager::sendServerMessage(sock, "teleportation target player not found");
|
Chat::sendServerMessage(sock, "teleportation target player not found");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
goalPlr = PlayerManager::getPlayer(goalSock);
|
goalPlr = PlayerManager::getPlayer(goalSock);
|
||||||
@ -318,7 +318,7 @@ static void itemGMGiveHandler(CNSocket* sock, CNPacketData* data) {
|
|||||||
// sock->sendPacket(new CNPacketData((void*)resp, P_FE2CL_REP_PC_GIVE_ITEM_FAIL, sizeof(sP_FE2CL_REP_PC_GIVE_ITEM_FAIL), sock->getFEKey()));
|
// sock->sendPacket(new CNPacketData((void*)resp, P_FE2CL_REP_PC_GIVE_ITEM_FAIL, sizeof(sP_FE2CL_REP_PC_GIVE_ITEM_FAIL), sock->getFEKey()));
|
||||||
} else if (itemreq->eIL == 1 && itemreq->Item.iType >= 0 && itemreq->Item.iType <= 10) {
|
} else if (itemreq->eIL == 1 && itemreq->Item.iType >= 0 && itemreq->Item.iType <= 10) {
|
||||||
|
|
||||||
if (ItemManager::ItemData.find(std::pair<int32_t, int32_t>(itemreq->Item.iID, itemreq->Item.iType)) == ItemManager::ItemData.end()) {
|
if (Items::ItemData.find(std::pair<int32_t, int32_t>(itemreq->Item.iID, itemreq->Item.iType)) == Items::ItemData.end()) {
|
||||||
// invalid item
|
// invalid item
|
||||||
std::cout << "[WARN] Item id " << itemreq->Item.iID << " with type " << itemreq->Item.iType << " is invalid (give item)" << std::endl;
|
std::cout << "[WARN] Item id " << itemreq->Item.iID << " with type " << itemreq->Item.iType << " is invalid (give item)" << std::endl;
|
||||||
return;
|
return;
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
#include "CNStructs.hpp"
|
#include "CNStructs.hpp"
|
||||||
#include "db/Database.hpp"
|
#include "db/Database.hpp"
|
||||||
#include "PlayerManager.hpp"
|
#include "PlayerManager.hpp"
|
||||||
#include "ItemManager.hpp"
|
#include "Items.hpp"
|
||||||
#include <regex>
|
#include <regex>
|
||||||
#include "bcrypt/BCrypt.hpp"
|
#include "bcrypt/BCrypt.hpp"
|
||||||
|
|
||||||
@ -364,7 +364,7 @@ bool validateCharacterCreation(sP_CL2LS_REQ_CHAR_CREATE* character) {
|
|||||||
// once we have a static database perhaps we can check for the exact char creation items,
|
// once we have a static database perhaps we can check for the exact char creation items,
|
||||||
// for now only checking if it's a valid lvl1 item
|
// for now only checking if it's a valid lvl1 item
|
||||||
for (int i = 0; i < 3; i++) {
|
for (int i = 0; i < 3; i++) {
|
||||||
if (ItemManager::ItemData.find(items[i]) == ItemManager::ItemData.end() || ItemManager::ItemData[items[i]].level != 1)
|
if (Items::ItemData.find(items[i]) == Items::ItemData.end() || Items::ItemData[items[i]].level != 1)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
@ -1,13 +1,13 @@
|
|||||||
#include "ChatManager.hpp"
|
#include "Chat.hpp"
|
||||||
#include "PlayerManager.hpp"
|
#include "PlayerManager.hpp"
|
||||||
#include "GroupManager.hpp"
|
#include "Groups.hpp"
|
||||||
#include "CustomCommands.hpp"
|
#include "CustomCommands.hpp"
|
||||||
|
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
|
||||||
std::vector<std::string> ChatManager::dump;
|
std::vector<std::string> Chat::dump;
|
||||||
|
|
||||||
using namespace ChatManager;
|
using namespace Chat;
|
||||||
|
|
||||||
static void chatHandler(CNSocket* sock, CNPacketData* data) {
|
static void chatHandler(CNSocket* sock, CNPacketData* data) {
|
||||||
if (data->size != sizeof(sP_CL2FE_REQ_SEND_FREECHAT_MESSAGE))
|
if (data->size != sizeof(sP_CL2FE_REQ_SEND_FREECHAT_MESSAGE))
|
||||||
@ -88,7 +88,7 @@ static void emoteHandler(CNSocket* sock, CNPacketData* data) {
|
|||||||
PlayerManager::sendToViewable(sock, (void*)&resp, P_FE2CL_REP_PC_AVATAR_EMOTES_CHAT, sizeof(sP_FE2CL_REP_PC_AVATAR_EMOTES_CHAT));
|
PlayerManager::sendToViewable(sock, (void*)&resp, P_FE2CL_REP_PC_AVATAR_EMOTES_CHAT, sizeof(sP_FE2CL_REP_PC_AVATAR_EMOTES_CHAT));
|
||||||
}
|
}
|
||||||
|
|
||||||
void ChatManager::sendServerMessage(CNSocket* sock, std::string msg) {
|
void Chat::sendServerMessage(CNSocket* sock, std::string msg) {
|
||||||
INITSTRUCT(sP_FE2CL_PC_MOTD_LOGIN, motd);
|
INITSTRUCT(sP_FE2CL_PC_MOTD_LOGIN, motd);
|
||||||
|
|
||||||
motd.iType = 1;
|
motd.iType = 1;
|
||||||
@ -276,7 +276,7 @@ static void groupChatHandler(CNSocket* sock, CNPacketData* data) {
|
|||||||
resp.iSendPCID = plr->iID;
|
resp.iSendPCID = plr->iID;
|
||||||
resp.iEmoteCode = chat->iEmoteCode;
|
resp.iEmoteCode = chat->iEmoteCode;
|
||||||
|
|
||||||
GroupManager::sendToGroup(otherPlr, (void*)&resp, P_FE2CL_REP_SEND_ALL_GROUP_FREECHAT_MESSAGE_SUCC, sizeof(sP_FE2CL_REP_SEND_ALL_GROUP_FREECHAT_MESSAGE_SUCC));
|
Groups::sendToGroup(otherPlr, (void*)&resp, P_FE2CL_REP_SEND_ALL_GROUP_FREECHAT_MESSAGE_SUCC, sizeof(sP_FE2CL_REP_SEND_ALL_GROUP_FREECHAT_MESSAGE_SUCC));
|
||||||
}
|
}
|
||||||
|
|
||||||
static void groupMenuChatHandler(CNSocket* sock, CNPacketData* data) {
|
static void groupMenuChatHandler(CNSocket* sock, CNPacketData* data) {
|
||||||
@ -303,11 +303,11 @@ static void groupMenuChatHandler(CNSocket* sock, CNPacketData* data) {
|
|||||||
resp.iSendPCID = plr->iID;
|
resp.iSendPCID = plr->iID;
|
||||||
resp.iEmoteCode = chat->iEmoteCode;
|
resp.iEmoteCode = chat->iEmoteCode;
|
||||||
|
|
||||||
GroupManager::sendToGroup(otherPlr, (void*)&resp, P_FE2CL_REP_SEND_ALL_GROUP_MENUCHAT_MESSAGE_SUCC, sizeof(sP_FE2CL_REP_SEND_ALL_GROUP_MENUCHAT_MESSAGE_SUCC));
|
Groups::sendToGroup(otherPlr, (void*)&resp, P_FE2CL_REP_SEND_ALL_GROUP_MENUCHAT_MESSAGE_SUCC, sizeof(sP_FE2CL_REP_SEND_ALL_GROUP_MENUCHAT_MESSAGE_SUCC));
|
||||||
}
|
}
|
||||||
|
|
||||||
// we only allow plain ascii, at least for now
|
// we only allow plain ascii, at least for now
|
||||||
std::string ChatManager::sanitizeText(std::string text, bool allowNewlines) {
|
std::string Chat::sanitizeText(std::string text, bool allowNewlines) {
|
||||||
int i;
|
int i;
|
||||||
const int BUFSIZE = 512;
|
const int BUFSIZE = 512;
|
||||||
char buf[BUFSIZE];
|
char buf[BUFSIZE];
|
||||||
@ -330,7 +330,7 @@ std::string ChatManager::sanitizeText(std::string text, bool allowNewlines) {
|
|||||||
return std::string(buf);
|
return std::string(buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ChatManager::init() {
|
void Chat::init() {
|
||||||
REGISTER_SHARD_PACKET(P_CL2FE_REQ_SEND_FREECHAT_MESSAGE, chatHandler);
|
REGISTER_SHARD_PACKET(P_CL2FE_REQ_SEND_FREECHAT_MESSAGE, chatHandler);
|
||||||
REGISTER_SHARD_PACKET(P_CL2FE_REQ_PC_AVATAR_EMOTES_CHAT, emoteHandler);
|
REGISTER_SHARD_PACKET(P_CL2FE_REQ_PC_AVATAR_EMOTES_CHAT, emoteHandler);
|
||||||
REGISTER_SHARD_PACKET(P_CL2FE_REQ_SEND_MENUCHAT_MESSAGE, menuChatHandler);
|
REGISTER_SHARD_PACKET(P_CL2FE_REQ_SEND_MENUCHAT_MESSAGE, menuChatHandler);
|
@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
#include "CNShardServer.hpp"
|
#include "CNShardServer.hpp"
|
||||||
|
|
||||||
namespace ChatManager {
|
namespace Chat {
|
||||||
extern std::vector<std::string> dump;
|
extern std::vector<std::string> dump;
|
||||||
void init();
|
void init();
|
||||||
|
|
@ -1,12 +1,12 @@
|
|||||||
#include "ChunkManager.hpp"
|
#include "Chunking.hpp"
|
||||||
#include "PlayerManager.hpp"
|
#include "PlayerManager.hpp"
|
||||||
#include "NPCManager.hpp"
|
#include "NPCManager.hpp"
|
||||||
#include "settings.hpp"
|
#include "settings.hpp"
|
||||||
#include "Combat.hpp"
|
#include "Combat.hpp"
|
||||||
|
|
||||||
using namespace ChunkManager;
|
using namespace Chunking;
|
||||||
|
|
||||||
std::map<ChunkPos, Chunk*> ChunkManager::chunks;
|
std::map<ChunkPos, Chunk*> Chunking::chunks;
|
||||||
|
|
||||||
static void newChunk(ChunkPos pos) {
|
static void newChunk(ChunkPos pos) {
|
||||||
if (chunkExists(pos)) {
|
if (chunkExists(pos)) {
|
||||||
@ -53,21 +53,21 @@ static void deleteChunk(ChunkPos pos) {
|
|||||||
delete chunk; // free from memory
|
delete chunk; // free from memory
|
||||||
}
|
}
|
||||||
|
|
||||||
void ChunkManager::trackPlayer(ChunkPos chunkPos, CNSocket* sock) {
|
void Chunking::trackPlayer(ChunkPos chunkPos, CNSocket* sock) {
|
||||||
if (!chunkExists(chunkPos))
|
if (!chunkExists(chunkPos))
|
||||||
return; // shouldn't happen
|
return; // shouldn't happen
|
||||||
|
|
||||||
chunks[chunkPos]->players.insert(sock);
|
chunks[chunkPos]->players.insert(sock);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ChunkManager::trackNPC(ChunkPos chunkPos, int32_t id) {
|
void Chunking::trackNPC(ChunkPos chunkPos, int32_t id) {
|
||||||
if (!chunkExists(chunkPos))
|
if (!chunkExists(chunkPos))
|
||||||
return; // shouldn't happen
|
return; // shouldn't happen
|
||||||
|
|
||||||
chunks[chunkPos]->NPCs.insert(id);
|
chunks[chunkPos]->NPCs.insert(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ChunkManager::untrackPlayer(ChunkPos chunkPos, CNSocket* sock) {
|
void Chunking::untrackPlayer(ChunkPos chunkPos, CNSocket* sock) {
|
||||||
if (!chunkExists(chunkPos))
|
if (!chunkExists(chunkPos))
|
||||||
return; // do nothing if chunk doesn't even exist
|
return; // do nothing if chunk doesn't even exist
|
||||||
|
|
||||||
@ -80,7 +80,7 @@ void ChunkManager::untrackPlayer(ChunkPos chunkPos, CNSocket* sock) {
|
|||||||
deleteChunk(chunkPos);
|
deleteChunk(chunkPos);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ChunkManager::untrackNPC(ChunkPos chunkPos, int32_t id) {
|
void Chunking::untrackNPC(ChunkPos chunkPos, int32_t id) {
|
||||||
if (!chunkExists(chunkPos))
|
if (!chunkExists(chunkPos))
|
||||||
return; // do nothing if chunk doesn't even exist
|
return; // do nothing if chunk doesn't even exist
|
||||||
|
|
||||||
@ -93,7 +93,7 @@ void ChunkManager::untrackNPC(ChunkPos chunkPos, int32_t id) {
|
|||||||
deleteChunk(chunkPos);
|
deleteChunk(chunkPos);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ChunkManager::addPlayerToChunks(std::set<Chunk*> chnks, CNSocket* sock) {
|
void Chunking::addPlayerToChunks(std::set<Chunk*> chnks, CNSocket* sock) {
|
||||||
INITSTRUCT(sP_FE2CL_PC_NEW, newPlayer);
|
INITSTRUCT(sP_FE2CL_PC_NEW, newPlayer);
|
||||||
|
|
||||||
for (Chunk* chunk : chnks) {
|
for (Chunk* chunk : chnks) {
|
||||||
@ -165,7 +165,7 @@ void ChunkManager::addPlayerToChunks(std::set<Chunk*> chnks, CNSocket* sock) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ChunkManager::addNPCToChunks(std::set<Chunk*> chnks, int32_t id) {
|
void Chunking::addNPCToChunks(std::set<Chunk*> chnks, int32_t id) {
|
||||||
BaseNPC* npc = NPCManager::NPCs[id];
|
BaseNPC* npc = NPCManager::NPCs[id];
|
||||||
|
|
||||||
switch (npc->npcClass) {
|
switch (npc->npcClass) {
|
||||||
@ -209,7 +209,7 @@ void ChunkManager::addNPCToChunks(std::set<Chunk*> chnks, int32_t id) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ChunkManager::removePlayerFromChunks(std::set<Chunk*> chnks, CNSocket* sock) {
|
void Chunking::removePlayerFromChunks(std::set<Chunk*> chnks, CNSocket* sock) {
|
||||||
INITSTRUCT(sP_FE2CL_PC_EXIT, exitPlayer);
|
INITSTRUCT(sP_FE2CL_PC_EXIT, exitPlayer);
|
||||||
|
|
||||||
// for chunks that need the player to be removed from
|
// for chunks that need the player to be removed from
|
||||||
@ -253,7 +253,7 @@ void ChunkManager::removePlayerFromChunks(std::set<Chunk*> chnks, CNSocket* sock
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ChunkManager::removeNPCFromChunks(std::set<Chunk*> chnks, int32_t id) {
|
void Chunking::removeNPCFromChunks(std::set<Chunk*> chnks, int32_t id) {
|
||||||
BaseNPC* npc = NPCManager::NPCs[id];
|
BaseNPC* npc = NPCManager::NPCs[id];
|
||||||
|
|
||||||
switch (npc->npcClass) {
|
switch (npc->npcClass) {
|
||||||
@ -320,7 +320,7 @@ static void emptyChunk(ChunkPos chunkPos) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ChunkManager::updatePlayerChunk(CNSocket* sock, ChunkPos from, ChunkPos to) {
|
void Chunking::updatePlayerChunk(CNSocket* sock, ChunkPos from, ChunkPos to) {
|
||||||
Player* plr = PlayerManager::getPlayer(sock);
|
Player* plr = PlayerManager::getPlayer(sock);
|
||||||
|
|
||||||
// if the new chunk doesn't exist, make it first
|
// if the new chunk doesn't exist, make it first
|
||||||
@ -356,7 +356,7 @@ void ChunkManager::updatePlayerChunk(CNSocket* sock, ChunkPos from, ChunkPos to)
|
|||||||
plr->viewableChunks->insert(newViewables.begin(), newViewables.end());
|
plr->viewableChunks->insert(newViewables.begin(), newViewables.end());
|
||||||
}
|
}
|
||||||
|
|
||||||
void ChunkManager::updateNPCChunk(int32_t id, ChunkPos from, ChunkPos to) {
|
void Chunking::updateNPCChunk(int32_t id, ChunkPos from, ChunkPos to) {
|
||||||
BaseNPC* npc = NPCManager::NPCs[id];
|
BaseNPC* npc = NPCManager::NPCs[id];
|
||||||
|
|
||||||
// if the new chunk doesn't exist, make it first
|
// if the new chunk doesn't exist, make it first
|
||||||
@ -392,15 +392,15 @@ void ChunkManager::updateNPCChunk(int32_t id, ChunkPos from, ChunkPos to) {
|
|||||||
npc->viewableChunks->insert(newViewables.begin(), newViewables.end());
|
npc->viewableChunks->insert(newViewables.begin(), newViewables.end());
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ChunkManager::chunkExists(ChunkPos chunk) {
|
bool Chunking::chunkExists(ChunkPos chunk) {
|
||||||
return chunks.find(chunk) != chunks.end();
|
return chunks.find(chunk) != chunks.end();
|
||||||
}
|
}
|
||||||
|
|
||||||
ChunkPos ChunkManager::chunkPosAt(int posX, int posY, uint64_t instanceID) {
|
ChunkPos Chunking::chunkPosAt(int posX, int posY, uint64_t instanceID) {
|
||||||
return std::make_tuple(posX / (settings::VIEWDISTANCE / 3), posY / (settings::VIEWDISTANCE / 3), instanceID);
|
return std::make_tuple(posX / (settings::VIEWDISTANCE / 3), posY / (settings::VIEWDISTANCE / 3), instanceID);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::set<Chunk*> ChunkManager::getViewableChunks(ChunkPos chunk) {
|
std::set<Chunk*> Chunking::getViewableChunks(ChunkPos chunk) {
|
||||||
std::set<Chunk*> chnks;
|
std::set<Chunk*> chnks;
|
||||||
|
|
||||||
int x, y;
|
int x, y;
|
||||||
@ -439,7 +439,7 @@ static std::vector<ChunkPos> getChunksInMap(uint64_t mapNum) {
|
|||||||
/*
|
/*
|
||||||
* Used only for eggs; use npc->playersInView for everything visible
|
* Used only for eggs; use npc->playersInView for everything visible
|
||||||
*/
|
*/
|
||||||
bool ChunkManager::inPopulatedChunks(std::set<Chunk*>* chnks) {
|
bool Chunking::inPopulatedChunks(std::set<Chunk*>* chnks) {
|
||||||
|
|
||||||
for (auto it = chnks->begin(); it != chnks->end(); it++) {
|
for (auto it = chnks->begin(); it != chnks->end(); it++) {
|
||||||
if (!(*it)->players.empty())
|
if (!(*it)->players.empty())
|
||||||
@ -449,7 +449,7 @@ bool ChunkManager::inPopulatedChunks(std::set<Chunk*>* chnks) {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ChunkManager::createInstance(uint64_t instanceID) {
|
void Chunking::createInstance(uint64_t instanceID) {
|
||||||
|
|
||||||
std::vector<ChunkPos> templateChunks = getChunksInMap(MAPNUM(instanceID)); // base instance chunks
|
std::vector<ChunkPos> templateChunks = getChunksInMap(MAPNUM(instanceID)); // base instance chunks
|
||||||
if (getChunksInMap(instanceID).size() == 0) { // only instantiate if the instance doesn't exist already
|
if (getChunksInMap(instanceID).size() == 0) { // only instantiate if the instance doesn't exist already
|
||||||
@ -517,7 +517,7 @@ static void destroyInstance(uint64_t instanceID) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ChunkManager::destroyInstanceIfEmpty(uint64_t instanceID) {
|
void Chunking::destroyInstanceIfEmpty(uint64_t instanceID) {
|
||||||
if (PLAYERID(instanceID) == 0)
|
if (PLAYERID(instanceID) == 0)
|
||||||
return; // don't clean up overworld/IZ chunks
|
return; // don't clean up overworld/IZ chunks
|
||||||
|
|
@ -21,7 +21,7 @@ enum {
|
|||||||
INSTANCE_UNIQUE // these aren't actually used
|
INSTANCE_UNIQUE // these aren't actually used
|
||||||
};
|
};
|
||||||
|
|
||||||
namespace ChunkManager {
|
namespace Chunking {
|
||||||
extern std::map<ChunkPos, Chunk*> chunks;
|
extern std::map<ChunkPos, Chunk*> chunks;
|
||||||
|
|
||||||
void updatePlayerChunk(CNSocket* sock, ChunkPos from, ChunkPos to);
|
void updatePlayerChunk(CNSocket* sock, ChunkPos from, ChunkPos to);
|
@ -1,12 +1,12 @@
|
|||||||
#include "Combat.hpp"
|
#include "Combat.hpp"
|
||||||
#include "PlayerManager.hpp"
|
#include "PlayerManager.hpp"
|
||||||
#include "NanoManager.hpp"
|
#include "Nanos.hpp"
|
||||||
#include "NPCManager.hpp"
|
#include "NPCManager.hpp"
|
||||||
#include "ItemManager.hpp"
|
#include "Items.hpp"
|
||||||
#include "MissionManager.hpp"
|
#include "Missions.hpp"
|
||||||
#include "GroupManager.hpp"
|
#include "Groups.hpp"
|
||||||
#include "TransportManager.hpp"
|
#include "Transport.hpp"
|
||||||
#include "RacingManager.hpp"
|
#include "Racing.hpp"
|
||||||
#include "Abilities.hpp"
|
#include "Abilities.hpp"
|
||||||
|
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
@ -119,7 +119,7 @@ static void pcAttackNpcs(CNSocket *sock, CNPacketData *data) {
|
|||||||
damage.first = plr->pointDamage;
|
damage.first = plr->pointDamage;
|
||||||
|
|
||||||
int difficulty = (int)mob->data["m_iNpcLevel"];
|
int difficulty = (int)mob->data["m_iNpcLevel"];
|
||||||
damage = getDamage(damage.first, (int)mob->data["m_iProtection"], true, (plr->batteryW > 6 + difficulty), NanoManager::nanoStyle(plr->activeNano), (int)mob->data["m_iNpcStyle"], difficulty);
|
damage = getDamage(damage.first, (int)mob->data["m_iProtection"], true, (plr->batteryW > 6 + difficulty), Nanos::nanoStyle(plr->activeNano), (int)mob->data["m_iNpcStyle"], difficulty);
|
||||||
|
|
||||||
if (plr->batteryW >= 6 + difficulty)
|
if (plr->batteryW >= 6 + difficulty)
|
||||||
plr->batteryW -= 6 + difficulty;
|
plr->batteryW -= 6 + difficulty;
|
||||||
@ -241,8 +241,8 @@ void Combat::killMob(CNSocket *sock, Mob *mob) {
|
|||||||
int rolledQItem = rand();
|
int rolledQItem = rand();
|
||||||
|
|
||||||
if (plr->groupCnt == 1 && plr->iIDGroup == plr->iID) {
|
if (plr->groupCnt == 1 && plr->iIDGroup == plr->iID) {
|
||||||
ItemManager::giveMobDrop(sock, mob, rolledBoosts, rolledPotions, rolledCrate, rolledCrateType, rolledEvent);
|
Items::giveMobDrop(sock, mob, rolledBoosts, rolledPotions, rolledCrate, rolledCrateType, rolledEvent);
|
||||||
MissionManager::mobKilled(sock, mob->appearanceData.iNPCType, rolledQItem);
|
Missions::mobKilled(sock, mob->appearanceData.iNPCType, rolledQItem);
|
||||||
} else {
|
} else {
|
||||||
Player* otherPlayer = PlayerManager::getPlayerFromID(plr->iIDGroup);
|
Player* otherPlayer = PlayerManager::getPlayerFromID(plr->iIDGroup);
|
||||||
|
|
||||||
@ -261,8 +261,8 @@ void Combat::killMob(CNSocket *sock, Mob *mob) {
|
|||||||
if (dist > 5000)
|
if (dist > 5000)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
ItemManager::giveMobDrop(sockTo, mob, rolledBoosts, rolledPotions, rolledCrate, rolledCrateType, rolledEvent);
|
Items::giveMobDrop(sockTo, mob, rolledBoosts, rolledPotions, rolledCrate, rolledCrateType, rolledEvent);
|
||||||
MissionManager::mobKilled(sockTo, mob->appearanceData.iNPCType, rolledQItem);
|
Missions::mobKilled(sockTo, mob->appearanceData.iNPCType, rolledQItem);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -275,8 +275,8 @@ void Combat::killMob(CNSocket *sock, Mob *mob) {
|
|||||||
if (event.trigger == ON_KILLED && event.npcType == mob->appearanceData.iNPCType)
|
if (event.trigger == ON_KILLED && event.npcType == mob->appearanceData.iNPCType)
|
||||||
event.handler(sock, mob);
|
event.handler(sock, mob);
|
||||||
|
|
||||||
auto it = TransportManager::NPCQueues.find(mob->appearanceData.iNPC_ID);
|
auto it = Transport::NPCQueues.find(mob->appearanceData.iNPC_ID);
|
||||||
if (it == TransportManager::NPCQueues.end() || it->second.empty())
|
if (it == Transport::NPCQueues.end() || it->second.empty())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// rewind or empty the movement queue
|
// rewind or empty the movement queue
|
||||||
@ -293,7 +293,7 @@ void Combat::killMob(CNSocket *sock, Mob *mob) {
|
|||||||
queue.push(point);
|
queue.push(point);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
TransportManager::NPCQueues.erase(mob->appearanceData.iNPC_ID);
|
Transport::NPCQueues.erase(mob->appearanceData.iNPC_ID);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -366,7 +366,7 @@ static void dealGooDamage(CNSocket *sock, int amount) {
|
|||||||
if (plr->Nanos[plr->activeNano].iStamina <= 0) {
|
if (plr->Nanos[plr->activeNano].iStamina <= 0) {
|
||||||
dmg->bNanoDeactive = 1;
|
dmg->bNanoDeactive = 1;
|
||||||
plr->Nanos[plr->activeNano].iStamina = 0;
|
plr->Nanos[plr->activeNano].iStamina = 0;
|
||||||
NanoManager::summonNano(PlayerManager::getSockFromID(plr->iID), -1, true);
|
Nanos::summonNano(PlayerManager::getSockFromID(plr->iID), -1, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -472,7 +472,7 @@ static void pcAttackChars(CNSocket *sock, CNPacketData *data) {
|
|||||||
int difficulty = (int)mob->data["m_iNpcLevel"];
|
int difficulty = (int)mob->data["m_iNpcLevel"];
|
||||||
|
|
||||||
damage = getDamage(damage.first, (int)mob->data["m_iProtection"], true, (plr->batteryW > 6 + difficulty),
|
damage = getDamage(damage.first, (int)mob->data["m_iProtection"], true, (plr->batteryW > 6 + difficulty),
|
||||||
NanoManager::nanoStyle(plr->activeNano), (int)mob->data["m_iNpcStyle"], difficulty);
|
Nanos::nanoStyle(plr->activeNano), (int)mob->data["m_iNpcStyle"], difficulty);
|
||||||
|
|
||||||
if (plr->batteryW >= 6 + difficulty)
|
if (plr->batteryW >= 6 + difficulty)
|
||||||
plr->batteryW -= 6 + difficulty;
|
plr->batteryW -= 6 + difficulty;
|
||||||
@ -667,7 +667,7 @@ static void projectileHit(CNSocket* sock, CNPacketData* data) {
|
|||||||
damage.first = pkt->iTargetCnt > 1 ? bullet->groupDamage : bullet->pointDamage;
|
damage.first = pkt->iTargetCnt > 1 ? bullet->groupDamage : bullet->pointDamage;
|
||||||
|
|
||||||
int difficulty = (int)mob->data["m_iNpcLevel"];
|
int difficulty = (int)mob->data["m_iNpcLevel"];
|
||||||
damage = getDamage(damage.first, (int)mob->data["m_iProtection"], true, bullet->weaponBoost, NanoManager::nanoStyle(plr->activeNano), (int)mob->data["m_iNpcStyle"], difficulty);
|
damage = getDamage(damage.first, (int)mob->data["m_iProtection"], true, bullet->weaponBoost, Nanos::nanoStyle(plr->activeNano), (int)mob->data["m_iNpcStyle"], difficulty);
|
||||||
|
|
||||||
damage.first = hitMob(sock, mob, damage.first);
|
damage.first = hitMob(sock, mob, damage.first);
|
||||||
|
|
||||||
@ -696,7 +696,7 @@ static void playerTick(CNServer *serv, time_t currTime) {
|
|||||||
|
|
||||||
// group ticks
|
// group ticks
|
||||||
if (plr->groupCnt > 1)
|
if (plr->groupCnt > 1)
|
||||||
GroupManager::groupTickInfo(plr);
|
Groups::groupTickInfo(plr);
|
||||||
|
|
||||||
// do not tick dead players
|
// do not tick dead players
|
||||||
if (plr->HP <= 0)
|
if (plr->HP <= 0)
|
||||||
@ -723,7 +723,7 @@ static void playerTick(CNServer *serv, time_t currTime) {
|
|||||||
plr->Nanos[plr->activeNano].iStamina -= 1 + plr->nanoDrainRate / 5;
|
plr->Nanos[plr->activeNano].iStamina -= 1 + plr->nanoDrainRate / 5;
|
||||||
|
|
||||||
if (plr->Nanos[plr->activeNano].iStamina <= 0)
|
if (plr->Nanos[plr->activeNano].iStamina <= 0)
|
||||||
NanoManager::summonNano(sock, -1, true); // unsummon nano silently
|
Nanos::summonNano(sock, -1, true); // unsummon nano silently
|
||||||
|
|
||||||
transmit = true;
|
transmit = true;
|
||||||
} else if (plr->Nanos[plr->equippedNanos[i]].iStamina < 150) { // regain stamina
|
} else if (plr->Nanos[plr->equippedNanos[i]].iStamina < 150) { // regain stamina
|
||||||
|
@ -1,13 +1,13 @@
|
|||||||
#include "CustomCommands.hpp"
|
#include "CustomCommands.hpp"
|
||||||
#include "ChatManager.hpp"
|
#include "Chat.hpp"
|
||||||
#include "PlayerManager.hpp"
|
#include "PlayerManager.hpp"
|
||||||
#include "TableData.hpp"
|
#include "TableData.hpp"
|
||||||
#include "NPCManager.hpp"
|
#include "NPCManager.hpp"
|
||||||
#include "MobAI.hpp"
|
#include "MobAI.hpp"
|
||||||
#include "ItemManager.hpp"
|
#include "Items.hpp"
|
||||||
#include "db/Database.hpp"
|
#include "db/Database.hpp"
|
||||||
#include "TransportManager.hpp"
|
#include "Transport.hpp"
|
||||||
#include "MissionManager.hpp"
|
#include "Missions.hpp"
|
||||||
|
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
#include <iterator>
|
#include <iterator>
|
||||||
@ -48,36 +48,36 @@ bool CustomCommands::runCmd(std::string full, CNSocket* sock) {
|
|||||||
command.handlr(full, args, sock);
|
command.handlr(full, args, sock);
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
ChatManager::sendServerMessage(sock, "You don't have access to that command!");
|
Chat::sendServerMessage(sock, "You don't have access to that command!");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ChatManager::sendServerMessage(sock, "Unknown command!");
|
Chat::sendServerMessage(sock, "Unknown command!");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void helpCommand(std::string full, std::vector<std::string>& args, CNSocket* sock) {
|
static void helpCommand(std::string full, std::vector<std::string>& args, CNSocket* sock) {
|
||||||
ChatManager::sendServerMessage(sock, "Commands available to you:");
|
Chat::sendServerMessage(sock, "Commands available to you:");
|
||||||
Player *plr = PlayerManager::getPlayer(sock);
|
Player *plr = PlayerManager::getPlayer(sock);
|
||||||
|
|
||||||
for (auto& cmd : commands) {
|
for (auto& cmd : commands) {
|
||||||
if (cmd.second.requiredAccLevel >= plr->accountLevel)
|
if (cmd.second.requiredAccLevel >= plr->accountLevel)
|
||||||
ChatManager::sendServerMessage(sock, "/" + cmd.first + (cmd.second.help.length() > 0 ? " - " + cmd.second.help : ""));
|
Chat::sendServerMessage(sock, "/" + cmd.first + (cmd.second.help.length() > 0 ? " - " + cmd.second.help : ""));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void accessCommand(std::string full, std::vector<std::string>& args, CNSocket* sock) {
|
static void accessCommand(std::string full, std::vector<std::string>& args, CNSocket* sock) {
|
||||||
ChatManager::sendServerMessage(sock, "Your access level is " + std::to_string(PlayerManager::getPlayer(sock)->accountLevel));
|
Chat::sendServerMessage(sock, "Your access level is " + std::to_string(PlayerManager::getPlayer(sock)->accountLevel));
|
||||||
}
|
}
|
||||||
|
|
||||||
static void populationCommand(std::string full, std::vector<std::string>& args, CNSocket* sock) {
|
static void populationCommand(std::string full, std::vector<std::string>& args, CNSocket* sock) {
|
||||||
ChatManager::sendServerMessage(sock, std::to_string(PlayerManager::players.size()) + " players online");
|
Chat::sendServerMessage(sock, std::to_string(PlayerManager::players.size()) + " players online");
|
||||||
}
|
}
|
||||||
|
|
||||||
static void levelCommand(std::string full, std::vector<std::string>& args, CNSocket* sock) {
|
static void levelCommand(std::string full, std::vector<std::string>& args, CNSocket* sock) {
|
||||||
if (args.size() < 2) {
|
if (args.size() < 2) {
|
||||||
ChatManager::sendServerMessage(sock, "/level: no level specified");
|
Chat::sendServerMessage(sock, "/level: no level specified");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -105,8 +105,8 @@ static void levelCommand(std::string full, std::vector<std::string>& args, CNSoc
|
|||||||
|
|
||||||
static void mssCommand(std::string full, std::vector<std::string>& args, CNSocket* sock) {
|
static void mssCommand(std::string full, std::vector<std::string>& args, CNSocket* sock) {
|
||||||
if (args.size() < 2) {
|
if (args.size() < 2) {
|
||||||
ChatManager::sendServerMessage(sock, "[MSS] Too few arguments");
|
Chat::sendServerMessage(sock, "[MSS] Too few arguments");
|
||||||
ChatManager::sendServerMessage(sock, "[MSS] Usage: /mss <route> <add/remove/goto/clear/test/export> <<height>>");
|
Chat::sendServerMessage(sock, "[MSS] Usage: /mss <route> <add/remove/goto/clear/test/export> <<height>>");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -115,13 +115,13 @@ static void mssCommand(std::string full, std::vector<std::string>& args, CNSocke
|
|||||||
int routeNum = std::strtol(args[1].c_str(), &routeNumC, 10);
|
int routeNum = std::strtol(args[1].c_str(), &routeNumC, 10);
|
||||||
if (*routeNumC) {
|
if (*routeNumC) {
|
||||||
// not an integer
|
// not an integer
|
||||||
ChatManager::sendServerMessage(sock, "[MSS] Invalid route number '" + args[1] + "'");
|
Chat::sendServerMessage(sock, "[MSS] Invalid route number '" + args[1] + "'");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (args.size() < 3) {
|
if (args.size() < 3) {
|
||||||
ChatManager::sendServerMessage(sock, "[MSS] Too few arguments");
|
Chat::sendServerMessage(sock, "[MSS] Too few arguments");
|
||||||
ChatManager::sendServerMessage(sock, "[MSS] Usage: /mss <route> <add/remove/goto/clear/test> <<height>>");
|
Chat::sendServerMessage(sock, "[MSS] Usage: /mss <route> <add/remove/goto/clear/test> <<height>>");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -132,41 +132,41 @@ static void mssCommand(std::string full, std::vector<std::string>& args, CNSocke
|
|||||||
if (args[2] == "add") {
|
if (args[2] == "add") {
|
||||||
// make sure height token exists
|
// make sure height token exists
|
||||||
if (args.size() < 4) {
|
if (args.size() < 4) {
|
||||||
ChatManager::sendServerMessage(sock, "[MSS] Point height must be specified");
|
Chat::sendServerMessage(sock, "[MSS] Point height must be specified");
|
||||||
ChatManager::sendServerMessage(sock, "[MSS] Usage: /mss <route> add <height>");
|
Chat::sendServerMessage(sock, "[MSS] Usage: /mss <route> add <height>");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// validate height token
|
// validate height token
|
||||||
char* heightC;
|
char* heightC;
|
||||||
int height = std::strtol(args[3].c_str(), &heightC, 10);
|
int height = std::strtol(args[3].c_str(), &heightC, 10);
|
||||||
if (*heightC) {
|
if (*heightC) {
|
||||||
ChatManager::sendServerMessage(sock, "[MSS] Invalid height " + args[3]);
|
Chat::sendServerMessage(sock, "[MSS] Invalid height " + args[3]);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Player* plr = PlayerManager::getPlayer(sock);
|
Player* plr = PlayerManager::getPlayer(sock);
|
||||||
route->push_back({ plr->x, plr->y, height }); // add point
|
route->push_back({ plr->x, plr->y, height }); // add point
|
||||||
ChatManager::sendServerMessage(sock, "[MSS] Added point (" + std::to_string(plr->x) + ", " + std::to_string(plr->y) + ", " + std::to_string(height) + ") to route " + std::to_string(routeNum));
|
Chat::sendServerMessage(sock, "[MSS] Added point (" + std::to_string(plr->x) + ", " + std::to_string(plr->y) + ", " + std::to_string(height) + ") to route " + std::to_string(routeNum));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// mss <route> remove
|
// mss <route> remove
|
||||||
if (args[2] == "remove") {
|
if (args[2] == "remove") {
|
||||||
if (route->empty()) {
|
if (route->empty()) {
|
||||||
ChatManager::sendServerMessage(sock, "[MSS] Route " + std::to_string(routeNum) + " is empty");
|
Chat::sendServerMessage(sock, "[MSS] Route " + std::to_string(routeNum) + " is empty");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
WarpLocation pulled = route->back();
|
WarpLocation pulled = route->back();
|
||||||
route->pop_back(); // remove point at top of stack
|
route->pop_back(); // remove point at top of stack
|
||||||
ChatManager::sendServerMessage(sock, "[MSS] Removed point (" + std::to_string(pulled.x) + ", " + std::to_string(pulled.y) + ", " + std::to_string(pulled.z) + ") from route " + std::to_string(routeNum));
|
Chat::sendServerMessage(sock, "[MSS] Removed point (" + std::to_string(pulled.x) + ", " + std::to_string(pulled.y) + ", " + std::to_string(pulled.z) + ") from route " + std::to_string(routeNum));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// mss <route> goto
|
// mss <route> goto
|
||||||
if (args[2] == "goto") {
|
if (args[2] == "goto") {
|
||||||
if (route->empty()) {
|
if (route->empty()) {
|
||||||
ChatManager::sendServerMessage(sock, "[MSS] Route " + std::to_string(routeNum) + " is empty");
|
Chat::sendServerMessage(sock, "[MSS] Route " + std::to_string(routeNum) + " is empty");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -178,37 +178,37 @@ static void mssCommand(std::string full, std::vector<std::string>& args, CNSocke
|
|||||||
// mss <route> clear
|
// mss <route> clear
|
||||||
if (args[2] == "clear") {
|
if (args[2] == "clear") {
|
||||||
route->clear();
|
route->clear();
|
||||||
ChatManager::sendServerMessage(sock, "[MSS] Cleared route " + std::to_string(routeNum));
|
Chat::sendServerMessage(sock, "[MSS] Cleared route " + std::to_string(routeNum));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// mss <route> test
|
// mss <route> test
|
||||||
if (args[2] == "test") {
|
if (args[2] == "test") {
|
||||||
if (route->empty()) {
|
if (route->empty()) {
|
||||||
ChatManager::sendServerMessage(sock, "[MSS] Route " + std::to_string(routeNum) + " is empty");
|
Chat::sendServerMessage(sock, "[MSS] Route " + std::to_string(routeNum) + " is empty");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
WarpLocation pulled = route->front();
|
WarpLocation pulled = route->front();
|
||||||
PlayerManager::sendPlayerTo(sock, pulled.x, pulled.y, pulled.z);
|
PlayerManager::sendPlayerTo(sock, pulled.x, pulled.y, pulled.z);
|
||||||
TransportManager::testMssRoute(sock, route);
|
Transport::testMssRoute(sock, route);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// for compatibility: mss <route> export
|
// for compatibility: mss <route> export
|
||||||
if (args[2] == "export") {
|
if (args[2] == "export") {
|
||||||
ChatManager::sendServerMessage(sock, "Wrote gruntwork to " + settings::GRUNTWORKJSON);
|
Chat::sendServerMessage(sock, "Wrote gruntwork to " + settings::GRUNTWORKJSON);
|
||||||
TableData::flush();
|
TableData::flush();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// mss ????
|
// mss ????
|
||||||
ChatManager::sendServerMessage(sock, "[MSS] Unknown command '" + args[2] + "'");
|
Chat::sendServerMessage(sock, "[MSS] Unknown command '" + args[2] + "'");
|
||||||
}
|
}
|
||||||
|
|
||||||
static void summonWCommand(std::string full, std::vector<std::string>& args, CNSocket* sock) {
|
static void summonWCommand(std::string full, std::vector<std::string>& args, CNSocket* sock) {
|
||||||
if (args.size() < 2) {
|
if (args.size() < 2) {
|
||||||
ChatManager::sendServerMessage(sock, "/summonW: no mob type specified");
|
Chat::sendServerMessage(sock, "/summonW: no mob type specified");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Player* plr = PlayerManager::getPlayer(sock);
|
Player* plr = PlayerManager::getPlayer(sock);
|
||||||
@ -216,7 +216,7 @@ static void summonWCommand(std::string full, std::vector<std::string>& args, CNS
|
|||||||
char *rest;
|
char *rest;
|
||||||
int type = std::strtol(args[1].c_str(), &rest, 10);
|
int type = std::strtol(args[1].c_str(), &rest, 10);
|
||||||
if (*rest) {
|
if (*rest) {
|
||||||
ChatManager::sendServerMessage(sock, "Invalid NPC number: " + args[1]);
|
Chat::sendServerMessage(sock, "Invalid NPC number: " + args[1]);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -240,7 +240,7 @@ static void summonWCommand(std::string full, std::vector<std::string>& args, CNS
|
|||||||
NPCManager::updateNPCPosition(npc->appearanceData.iNPC_ID, plr->x, plr->y, plr->z, npc->instanceID, npc->appearanceData.iAngle);
|
NPCManager::updateNPCPosition(npc->appearanceData.iNPC_ID, plr->x, plr->y, plr->z, npc->instanceID, npc->appearanceData.iAngle);
|
||||||
}
|
}
|
||||||
|
|
||||||
ChatManager::sendServerMessage(sock, "/summonW: placed mob with type: " + std::to_string(type) +
|
Chat::sendServerMessage(sock, "/summonW: placed mob with type: " + std::to_string(type) +
|
||||||
", id: " + std::to_string(npc->appearanceData.iNPC_ID));
|
", id: " + std::to_string(npc->appearanceData.iNPC_ID));
|
||||||
TableData::RunningMobs[npc->appearanceData.iNPC_ID] = npc; // only record the one in the template
|
TableData::RunningMobs[npc->appearanceData.iNPC_ID] = npc; // only record the one in the template
|
||||||
}
|
}
|
||||||
@ -251,12 +251,12 @@ static void unsummonWCommand(std::string full, std::vector<std::string>& args, C
|
|||||||
BaseNPC* npc = NPCManager::getNearestNPC(plr->viewableChunks, plr->x, plr->y, plr->z);
|
BaseNPC* npc = NPCManager::getNearestNPC(plr->viewableChunks, plr->x, plr->y, plr->z);
|
||||||
|
|
||||||
if (npc == nullptr) {
|
if (npc == nullptr) {
|
||||||
ChatManager::sendServerMessage(sock, "/unsummonW: No NPCs found nearby");
|
Chat::sendServerMessage(sock, "/unsummonW: No NPCs found nearby");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (TableData::RunningEggs.find(npc->appearanceData.iNPC_ID) != TableData::RunningEggs.end()) {
|
if (TableData::RunningEggs.find(npc->appearanceData.iNPC_ID) != TableData::RunningEggs.end()) {
|
||||||
ChatManager::sendServerMessage(sock, "/unsummonW: removed egg with type: " + std::to_string(npc->appearanceData.iNPCType) +
|
Chat::sendServerMessage(sock, "/unsummonW: removed egg with type: " + std::to_string(npc->appearanceData.iNPCType) +
|
||||||
", id: " + std::to_string(npc->appearanceData.iNPC_ID));
|
", id: " + std::to_string(npc->appearanceData.iNPC_ID));
|
||||||
TableData::RunningEggs.erase(npc->appearanceData.iNPC_ID);
|
TableData::RunningEggs.erase(npc->appearanceData.iNPC_ID);
|
||||||
NPCManager::destroyNPC(npc->appearanceData.iNPC_ID);
|
NPCManager::destroyNPC(npc->appearanceData.iNPC_ID);
|
||||||
@ -265,7 +265,7 @@ static void unsummonWCommand(std::string full, std::vector<std::string>& args, C
|
|||||||
|
|
||||||
if (TableData::RunningMobs.find(npc->appearanceData.iNPC_ID) == TableData::RunningMobs.end()
|
if (TableData::RunningMobs.find(npc->appearanceData.iNPC_ID) == TableData::RunningMobs.end()
|
||||||
&& TableData::RunningGroups.find(npc->appearanceData.iNPC_ID) == TableData::RunningGroups.end()) {
|
&& TableData::RunningGroups.find(npc->appearanceData.iNPC_ID) == TableData::RunningGroups.end()) {
|
||||||
ChatManager::sendServerMessage(sock, "/unsummonW: Closest NPC is not a gruntwork mob.");
|
Chat::sendServerMessage(sock, "/unsummonW: Closest NPC is not a gruntwork mob.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -289,12 +289,12 @@ static void unsummonWCommand(std::string full, std::vector<std::string>& args, C
|
|||||||
}
|
}
|
||||||
TableData::RunningGroups.erase(leadId);
|
TableData::RunningGroups.erase(leadId);
|
||||||
NPCManager::destroyNPC(leadId);
|
NPCManager::destroyNPC(leadId);
|
||||||
ChatManager::sendServerMessage(sock, "/unsummonW: Mob group destroyed.");
|
Chat::sendServerMessage(sock, "/unsummonW: Mob group destroyed.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ChatManager::sendServerMessage(sock, "/unsummonW: removed mob with type: " + std::to_string(npc->appearanceData.iNPCType) +
|
Chat::sendServerMessage(sock, "/unsummonW: removed mob with type: " + std::to_string(npc->appearanceData.iNPCType) +
|
||||||
", id: " + std::to_string(npc->appearanceData.iNPC_ID));
|
", id: " + std::to_string(npc->appearanceData.iNPC_ID));
|
||||||
|
|
||||||
TableData::RunningMobs.erase(npc->appearanceData.iNPC_ID);
|
TableData::RunningMobs.erase(npc->appearanceData.iNPC_ID);
|
||||||
@ -333,7 +333,7 @@ static void npcRotateCommand(std::string full, std::vector<std::string>& args, C
|
|||||||
BaseNPC* npc = NPCManager::getNearestNPC(plr->viewableChunks, plr->x, plr->y, plr->z);
|
BaseNPC* npc = NPCManager::getNearestNPC(plr->viewableChunks, plr->x, plr->y, plr->z);
|
||||||
|
|
||||||
if (npc == nullptr) {
|
if (npc == nullptr) {
|
||||||
ChatManager::sendServerMessage(sock, "[NPCR] No NPCs found nearby");
|
Chat::sendServerMessage(sock, "[NPCR] No NPCs found nearby");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -344,12 +344,12 @@ static void npcRotateCommand(std::string full, std::vector<std::string>& args, C
|
|||||||
if (TableData::RunningMobs.find(npc->appearanceData.iNPC_ID) != TableData::RunningMobs.end()) {
|
if (TableData::RunningMobs.find(npc->appearanceData.iNPC_ID) != TableData::RunningMobs.end()) {
|
||||||
NPCManager::updateNPCPosition(npc->appearanceData.iNPC_ID, npc->appearanceData.iX, npc->appearanceData.iY, npc->appearanceData.iZ, npc->instanceID, angle);
|
NPCManager::updateNPCPosition(npc->appearanceData.iNPC_ID, npc->appearanceData.iX, npc->appearanceData.iY, npc->appearanceData.iZ, npc->instanceID, angle);
|
||||||
|
|
||||||
ChatManager::sendServerMessage(sock, "[NPCR] Successfully set angle to " + std::to_string(angle) + " for gruntwork NPC "
|
Chat::sendServerMessage(sock, "[NPCR] Successfully set angle to " + std::to_string(angle) + " for gruntwork NPC "
|
||||||
+ std::to_string(npc->appearanceData.iNPC_ID));
|
+ std::to_string(npc->appearanceData.iNPC_ID));
|
||||||
} else {
|
} else {
|
||||||
TableData::RunningNPCRotations[npc->appearanceData.iNPC_ID] = angle;
|
TableData::RunningNPCRotations[npc->appearanceData.iNPC_ID] = angle;
|
||||||
|
|
||||||
ChatManager::sendServerMessage(sock, "[NPCR] Successfully set angle to " + std::to_string(angle) + " for NPC "
|
Chat::sendServerMessage(sock, "[NPCR] Successfully set angle to " + std::to_string(angle) + " for NPC "
|
||||||
+ std::to_string(npc->appearanceData.iNPC_ID));
|
+ std::to_string(npc->appearanceData.iNPC_ID));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -363,8 +363,8 @@ static void refreshCommand(std::string full, std::vector<std::string>& args, CNS
|
|||||||
Player* plr = PlayerManager::getPlayer(sock);
|
Player* plr = PlayerManager::getPlayer(sock);
|
||||||
ChunkPos currentChunk = plr->chunkPos;
|
ChunkPos currentChunk = plr->chunkPos;
|
||||||
ChunkPos nullChunk = std::make_tuple(0, 0, 0);
|
ChunkPos nullChunk = std::make_tuple(0, 0, 0);
|
||||||
ChunkManager::updatePlayerChunk(sock, currentChunk, nullChunk);
|
Chunking::updatePlayerChunk(sock, currentChunk, nullChunk);
|
||||||
ChunkManager::updatePlayerChunk(sock, nullChunk, currentChunk);
|
Chunking::updatePlayerChunk(sock, nullChunk, currentChunk);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void instanceCommand(std::string full, std::vector<std::string>& args, CNSocket* sock) {
|
static void instanceCommand(std::string full, std::vector<std::string>& args, CNSocket* sock) {
|
||||||
@ -372,8 +372,8 @@ static void instanceCommand(std::string full, std::vector<std::string>& args, CN
|
|||||||
|
|
||||||
// no additional arguments: report current instance ID
|
// no additional arguments: report current instance ID
|
||||||
if (args.size() < 2) {
|
if (args.size() < 2) {
|
||||||
ChatManager::sendServerMessage(sock, "[INST] Current instance ID: " + std::to_string(plr->instanceID));
|
Chat::sendServerMessage(sock, "[INST] Current instance ID: " + std::to_string(plr->instanceID));
|
||||||
ChatManager::sendServerMessage(sock, "[INST] (Map " + std::to_string(MAPNUM(plr->instanceID)) + ", instance " + std::to_string(PLAYERID(plr->instanceID)) + ")");
|
Chat::sendServerMessage(sock, "[INST] (Map " + std::to_string(MAPNUM(plr->instanceID)) + ", instance " + std::to_string(PLAYERID(plr->instanceID)) + ")");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -382,7 +382,7 @@ static void instanceCommand(std::string full, std::vector<std::string>& args, CN
|
|||||||
char* instanceS;
|
char* instanceS;
|
||||||
uint64_t instance = std::strtoll(args[1].c_str(), &instanceS, 10);
|
uint64_t instance = std::strtoll(args[1].c_str(), &instanceS, 10);
|
||||||
if (*instanceS) {
|
if (*instanceS) {
|
||||||
ChatManager::sendServerMessage(sock, "[INST] Invalid instance ID: " + args[1]);
|
Chat::sendServerMessage(sock, "[INST] Invalid instance ID: " + args[1]);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -392,7 +392,7 @@ static void instanceCommand(std::string full, std::vector<std::string>& args, CN
|
|||||||
|
|
||||||
if (playerid != 0) {
|
if (playerid != 0) {
|
||||||
instance |= playerid << 32ULL;
|
instance |= playerid << 32ULL;
|
||||||
ChunkManager::createInstance(instance);
|
Chunking::createInstance(instance);
|
||||||
|
|
||||||
// a precaution
|
// a precaution
|
||||||
plr->recallInstance = 0;
|
plr->recallInstance = 0;
|
||||||
@ -400,22 +400,22 @@ static void instanceCommand(std::string full, std::vector<std::string>& args, CN
|
|||||||
}
|
}
|
||||||
|
|
||||||
PlayerManager::sendPlayerTo(sock, plr->x, plr->y, plr->z, instance);
|
PlayerManager::sendPlayerTo(sock, plr->x, plr->y, plr->z, instance);
|
||||||
ChatManager::sendServerMessage(sock, "[INST] Switched to instance with ID " + std::to_string(instance));
|
Chat::sendServerMessage(sock, "[INST] Switched to instance with ID " + std::to_string(instance));
|
||||||
}
|
}
|
||||||
|
|
||||||
static void npcInstanceCommand(std::string full, std::vector<std::string>& args, CNSocket* sock) {
|
static void npcInstanceCommand(std::string full, std::vector<std::string>& args, CNSocket* sock) {
|
||||||
Player* plr = PlayerManager::getPlayer(sock);
|
Player* plr = PlayerManager::getPlayer(sock);
|
||||||
|
|
||||||
if (args.size() < 2) {
|
if (args.size() < 2) {
|
||||||
ChatManager::sendServerMessage(sock, "[NPCI] Instance ID must be specified");
|
Chat::sendServerMessage(sock, "[NPCI] Instance ID must be specified");
|
||||||
ChatManager::sendServerMessage(sock, "[NPCI] Usage: /npci <instance ID>");
|
Chat::sendServerMessage(sock, "[NPCI] Usage: /npci <instance ID>");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
BaseNPC* npc = NPCManager::getNearestNPC(plr->viewableChunks, plr->x, plr->y, plr->z);
|
BaseNPC* npc = NPCManager::getNearestNPC(plr->viewableChunks, plr->x, plr->y, plr->z);
|
||||||
|
|
||||||
if (npc == nullptr) {
|
if (npc == nullptr) {
|
||||||
ChatManager::sendServerMessage(sock, "[NPCI] No NPCs found nearby");
|
Chat::sendServerMessage(sock, "[NPCI] No NPCs found nearby");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -423,34 +423,34 @@ static void npcInstanceCommand(std::string full, std::vector<std::string>& args,
|
|||||||
char* instanceS;
|
char* instanceS;
|
||||||
int instance = std::strtol(args[1].c_str(), &instanceS, 10);
|
int instance = std::strtol(args[1].c_str(), &instanceS, 10);
|
||||||
if (*instanceS) {
|
if (*instanceS) {
|
||||||
ChatManager::sendServerMessage(sock, "[NPCI] Invalid instance ID: " + args[1]);
|
Chat::sendServerMessage(sock, "[NPCI] Invalid instance ID: " + args[1]);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
ChatManager::sendServerMessage(sock, "[NPCI] Moving NPC with ID " + std::to_string(npc->appearanceData.iNPC_ID) + " to instance " + std::to_string(instance));
|
Chat::sendServerMessage(sock, "[NPCI] Moving NPC with ID " + std::to_string(npc->appearanceData.iNPC_ID) + " to instance " + std::to_string(instance));
|
||||||
TableData::RunningNPCMapNumbers[npc->appearanceData.iNPC_ID] = instance;
|
TableData::RunningNPCMapNumbers[npc->appearanceData.iNPC_ID] = instance;
|
||||||
NPCManager::updateNPCPosition(npc->appearanceData.iNPC_ID, npc->appearanceData.iX, npc->appearanceData.iY, npc->appearanceData.iZ, instance, npc->appearanceData.iAngle);
|
NPCManager::updateNPCPosition(npc->appearanceData.iNPC_ID, npc->appearanceData.iX, npc->appearanceData.iY, npc->appearanceData.iZ, instance, npc->appearanceData.iAngle);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void minfoCommand(std::string full, std::vector<std::string>& args, CNSocket* sock) {
|
static void minfoCommand(std::string full, std::vector<std::string>& args, CNSocket* sock) {
|
||||||
Player* plr = PlayerManager::getPlayer(sock);
|
Player* plr = PlayerManager::getPlayer(sock);
|
||||||
ChatManager::sendServerMessage(sock, "[MINFO] Current mission ID: " + std::to_string(plr->CurrentMissionID));
|
Chat::sendServerMessage(sock, "[MINFO] Current mission ID: " + std::to_string(plr->CurrentMissionID));
|
||||||
|
|
||||||
for (int i = 0; i < ACTIVE_MISSION_COUNT; i++) {
|
for (int i = 0; i < ACTIVE_MISSION_COUNT; i++) {
|
||||||
if (plr->tasks[i] != 0) {
|
if (plr->tasks[i] != 0) {
|
||||||
TaskData& task = *MissionManager::Tasks[plr->tasks[i]];
|
TaskData& task = *Missions::Tasks[plr->tasks[i]];
|
||||||
if ((int)(task["m_iHMissionID"]) == plr->CurrentMissionID) {
|
if ((int)(task["m_iHMissionID"]) == plr->CurrentMissionID) {
|
||||||
ChatManager::sendServerMessage(sock, "[MINFO] Current task ID: " + std::to_string(plr->tasks[i]));
|
Chat::sendServerMessage(sock, "[MINFO] Current task ID: " + std::to_string(plr->tasks[i]));
|
||||||
ChatManager::sendServerMessage(sock, "[MINFO] Current task type: " + std::to_string((int)(task["m_iHTaskType"])));
|
Chat::sendServerMessage(sock, "[MINFO] Current task type: " + std::to_string((int)(task["m_iHTaskType"])));
|
||||||
ChatManager::sendServerMessage(sock, "[MINFO] Current waypoint NPC ID: " + std::to_string((int)(task["m_iSTGrantWayPoint"])));
|
Chat::sendServerMessage(sock, "[MINFO] Current waypoint NPC ID: " + std::to_string((int)(task["m_iSTGrantWayPoint"])));
|
||||||
ChatManager::sendServerMessage(sock, "[MINFO] Current terminator NPC ID: " + std::to_string((int)(task["m_iHTerminatorNPCID"])));
|
Chat::sendServerMessage(sock, "[MINFO] Current terminator NPC ID: " + std::to_string((int)(task["m_iHTerminatorNPCID"])));
|
||||||
|
|
||||||
if ((int)(task["m_iSTGrantTimer"]) != 0)
|
if ((int)(task["m_iSTGrantTimer"]) != 0)
|
||||||
ChatManager::sendServerMessage(sock, "[MINFO] Current task timer: " + std::to_string((int)(task["m_iSTGrantTimer"])));
|
Chat::sendServerMessage(sock, "[MINFO] Current task timer: " + std::to_string((int)(task["m_iSTGrantTimer"])));
|
||||||
|
|
||||||
for (int j = 0; j < 3; j++)
|
for (int j = 0; j < 3; j++)
|
||||||
if ((int)(task["m_iCSUEnemyID"][j]) != 0)
|
if ((int)(task["m_iCSUEnemyID"][j]) != 0)
|
||||||
ChatManager::sendServerMessage(sock, "[MINFO] Current task mob #" + std::to_string(j+1) +": " + std::to_string((int)(task["m_iCSUEnemyID"][j])));
|
Chat::sendServerMessage(sock, "[MINFO] Current task mob #" + std::to_string(j+1) +": " + std::to_string((int)(task["m_iCSUEnemyID"][j])));
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -464,16 +464,16 @@ static void tasksCommand(std::string full, std::vector<std::string>& args, CNSoc
|
|||||||
|
|
||||||
for (int i = 0; i < ACTIVE_MISSION_COUNT; i++) {
|
for (int i = 0; i < ACTIVE_MISSION_COUNT; i++) {
|
||||||
if (plr->tasks[i] != 0) {
|
if (plr->tasks[i] != 0) {
|
||||||
TaskData& task = *MissionManager::Tasks[plr->tasks[i]];
|
TaskData& task = *Missions::Tasks[plr->tasks[i]];
|
||||||
ChatManager::sendServerMessage(sock, "[TASK-" + std::to_string(i) + "] mission ID: " + std::to_string((int)(task["m_iHMissionID"])));
|
Chat::sendServerMessage(sock, "[TASK-" + std::to_string(i) + "] mission ID: " + std::to_string((int)(task["m_iHMissionID"])));
|
||||||
ChatManager::sendServerMessage(sock, "[TASK-" + std::to_string(i) + "] task ID: " + std::to_string(plr->tasks[i]));
|
Chat::sendServerMessage(sock, "[TASK-" + std::to_string(i) + "] task ID: " + std::to_string(plr->tasks[i]));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void buffCommand(std::string full, std::vector<std::string>& args, CNSocket* sock) {
|
static void buffCommand(std::string full, std::vector<std::string>& args, CNSocket* sock) {
|
||||||
if (args.size() < 3) {
|
if (args.size() < 3) {
|
||||||
ChatManager::sendServerMessage(sock, "/buff: no skill Id and duration time specified");
|
Chat::sendServerMessage(sock, "/buff: no skill Id and duration time specified");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -486,13 +486,13 @@ static void buffCommand(std::string full, std::vector<std::string>& args, CNSock
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
if (NPCManager::eggBuffPlayer(sock, skillId, 0, duration)<0)
|
if (NPCManager::eggBuffPlayer(sock, skillId, 0, duration)<0)
|
||||||
ChatManager::sendServerMessage(sock, "/buff: unknown skill Id");
|
Chat::sendServerMessage(sock, "/buff: unknown skill Id");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void eggCommand(std::string full, std::vector<std::string>& args, CNSocket* sock) {
|
static void eggCommand(std::string full, std::vector<std::string>& args, CNSocket* sock) {
|
||||||
if (args.size() < 2) {
|
if (args.size() < 2) {
|
||||||
ChatManager::sendServerMessage(sock, "/egg: no egg type specified");
|
Chat::sendServerMessage(sock, "/egg: no egg type specified");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -502,7 +502,7 @@ static void eggCommand(std::string full, std::vector<std::string>& args, CNSocke
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
if (NPCManager::EggTypes.find(eggType) == NPCManager::EggTypes.end()) {
|
if (NPCManager::EggTypes.find(eggType) == NPCManager::EggTypes.end()) {
|
||||||
ChatManager::sendServerMessage(sock, "/egg: Unknown egg type");
|
Chat::sendServerMessage(sock, "/egg: Unknown egg type");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -530,22 +530,22 @@ static void notifyCommand(std::string full, std::vector<std::string>& args, CNSo
|
|||||||
|
|
||||||
if (plr->notify) {
|
if (plr->notify) {
|
||||||
plr->notify = false;
|
plr->notify = false;
|
||||||
ChatManager::sendServerMessage(sock, "[ADMIN] No longer receiving join notifications");
|
Chat::sendServerMessage(sock, "[ADMIN] No longer receiving join notifications");
|
||||||
} else {
|
} else {
|
||||||
plr->notify = true;
|
plr->notify = true;
|
||||||
ChatManager::sendServerMessage(sock, "[ADMIN] Receiving join notifications");
|
Chat::sendServerMessage(sock, "[ADMIN] Receiving join notifications");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void playersCommand(std::string full, std::vector<std::string>& args, CNSocket* sock) {
|
static void playersCommand(std::string full, std::vector<std::string>& args, CNSocket* sock) {
|
||||||
ChatManager::sendServerMessage(sock, "[ADMIN] Players on the server:");
|
Chat::sendServerMessage(sock, "[ADMIN] Players on the server:");
|
||||||
for (auto pair : PlayerManager::players)
|
for (auto pair : PlayerManager::players)
|
||||||
ChatManager::sendServerMessage(sock, PlayerManager::getPlayerName(pair.second));
|
Chat::sendServerMessage(sock, PlayerManager::getPlayerName(pair.second));
|
||||||
}
|
}
|
||||||
|
|
||||||
static void summonGroupCommand(std::string full, std::vector<std::string>& args, CNSocket* sock) {
|
static void summonGroupCommand(std::string full, std::vector<std::string>& args, CNSocket* sock) {
|
||||||
if (args.size() < 4) {
|
if (args.size() < 4) {
|
||||||
ChatManager::sendServerMessage(sock, "/summonGroup(W) <leadermob> <mob> <number> [distance]");
|
Chat::sendServerMessage(sock, "/summonGroup(W) <leadermob> <mob> <number> [distance]");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Player* plr = PlayerManager::getPlayer(sock);
|
Player* plr = PlayerManager::getPlayer(sock);
|
||||||
@ -561,7 +561,7 @@ static void summonGroupCommand(std::string full, std::vector<std::string>& args,
|
|||||||
distance = std::strtol(args[4].c_str(), &rest, 10);
|
distance = std::strtol(args[4].c_str(), &rest, 10);
|
||||||
|
|
||||||
if (*rest) {
|
if (*rest) {
|
||||||
ChatManager::sendServerMessage(sock, "Invalid NPC number: " + args[1]);
|
Chat::sendServerMessage(sock, "Invalid NPC number: " + args[1]);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -569,7 +569,7 @@ static void summonGroupCommand(std::string full, std::vector<std::string>& args,
|
|||||||
|
|
||||||
// permission & sanity check
|
// permission & sanity check
|
||||||
if (type > limit || type2 > limit || count > 5) {
|
if (type > limit || type2 > limit || count > 5) {
|
||||||
ChatManager::sendServerMessage(sock, "Invalid parameters; double check types and count");
|
Chat::sendServerMessage(sock, "Invalid parameters; double check types and count");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -621,7 +621,7 @@ static void summonGroupCommand(std::string full, std::vector<std::string>& args,
|
|||||||
NPCManager::updateNPCPosition(npc->appearanceData.iNPC_ID, x, y, z, plr->instanceID, npc->appearanceData.iAngle);
|
NPCManager::updateNPCPosition(npc->appearanceData.iNPC_ID, x, y, z, plr->instanceID, npc->appearanceData.iAngle);
|
||||||
}
|
}
|
||||||
|
|
||||||
ChatManager::sendServerMessage(sock, "/summonGroup(W): placed mob with type: " + std::to_string(type) +
|
Chat::sendServerMessage(sock, "/summonGroup(W): placed mob with type: " + std::to_string(type) +
|
||||||
", id: " + std::to_string(npc->appearanceData.iNPC_ID));
|
", id: " + std::to_string(npc->appearanceData.iNPC_ID));
|
||||||
|
|
||||||
if (i == 0 && team == 2) {
|
if (i == 0 && team == 2) {
|
||||||
@ -644,7 +644,7 @@ static void summonGroupCommand(std::string full, std::vector<std::string>& args,
|
|||||||
|
|
||||||
static void flushCommand(std::string full, std::vector<std::string>& args, CNSocket* sock) {
|
static void flushCommand(std::string full, std::vector<std::string>& args, CNSocket* sock) {
|
||||||
TableData::flush();
|
TableData::flush();
|
||||||
ChatManager::sendServerMessage(sock, "Wrote gruntwork to " + settings::GRUNTWORKJSON);
|
Chat::sendServerMessage(sock, "Wrote gruntwork to " + settings::GRUNTWORKJSON);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void whoisCommand(std::string full, std::vector<std::string>& args, CNSocket* sock) {
|
static void whoisCommand(std::string full, std::vector<std::string>& args, CNSocket* sock) {
|
||||||
@ -652,31 +652,31 @@ static void whoisCommand(std::string full, std::vector<std::string>& args, CNSoc
|
|||||||
BaseNPC* npc = NPCManager::getNearestNPC(plr->viewableChunks, plr->x, plr->y, plr->z);
|
BaseNPC* npc = NPCManager::getNearestNPC(plr->viewableChunks, plr->x, plr->y, plr->z);
|
||||||
|
|
||||||
if (npc == nullptr) {
|
if (npc == nullptr) {
|
||||||
ChatManager::sendServerMessage(sock, "[WHOIS] No NPCs found nearby");
|
Chat::sendServerMessage(sock, "[WHOIS] No NPCs found nearby");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
ChatManager::sendServerMessage(sock, "[WHOIS] ID: " + std::to_string(npc->appearanceData.iNPC_ID));
|
Chat::sendServerMessage(sock, "[WHOIS] ID: " + std::to_string(npc->appearanceData.iNPC_ID));
|
||||||
ChatManager::sendServerMessage(sock, "[WHOIS] Type: " + std::to_string(npc->appearanceData.iNPCType));
|
Chat::sendServerMessage(sock, "[WHOIS] Type: " + std::to_string(npc->appearanceData.iNPCType));
|
||||||
ChatManager::sendServerMessage(sock, "[WHOIS] HP: " + std::to_string(npc->appearanceData.iHP));
|
Chat::sendServerMessage(sock, "[WHOIS] HP: " + std::to_string(npc->appearanceData.iHP));
|
||||||
ChatManager::sendServerMessage(sock, "[WHOIS] CBF: " + std::to_string(npc->appearanceData.iConditionBitFlag));
|
Chat::sendServerMessage(sock, "[WHOIS] CBF: " + std::to_string(npc->appearanceData.iConditionBitFlag));
|
||||||
ChatManager::sendServerMessage(sock, "[WHOIS] Class: " + std::to_string(npc->npcClass));
|
Chat::sendServerMessage(sock, "[WHOIS] Class: " + std::to_string(npc->npcClass));
|
||||||
ChatManager::sendServerMessage(sock, "[WHOIS] X: " + std::to_string(npc->appearanceData.iX));
|
Chat::sendServerMessage(sock, "[WHOIS] X: " + std::to_string(npc->appearanceData.iX));
|
||||||
ChatManager::sendServerMessage(sock, "[WHOIS] Y: " + std::to_string(npc->appearanceData.iY));
|
Chat::sendServerMessage(sock, "[WHOIS] Y: " + std::to_string(npc->appearanceData.iY));
|
||||||
ChatManager::sendServerMessage(sock, "[WHOIS] Z: " + std::to_string(npc->appearanceData.iZ));
|
Chat::sendServerMessage(sock, "[WHOIS] Z: " + std::to_string(npc->appearanceData.iZ));
|
||||||
ChatManager::sendServerMessage(sock, "[WHOIS] Angle: " + std::to_string(npc->appearanceData.iAngle));
|
Chat::sendServerMessage(sock, "[WHOIS] Angle: " + std::to_string(npc->appearanceData.iAngle));
|
||||||
std::string chunkPosition = std::to_string(std::get<0>(npc->chunkPos)) + ", " + std::to_string(std::get<1>(npc->chunkPos)) + ", " + std::to_string(std::get<2>(npc->chunkPos));
|
std::string chunkPosition = std::to_string(std::get<0>(npc->chunkPos)) + ", " + std::to_string(std::get<1>(npc->chunkPos)) + ", " + std::to_string(std::get<2>(npc->chunkPos));
|
||||||
ChatManager::sendServerMessage(sock, "[WHOIS] Chunk: {" + chunkPosition + "}");
|
Chat::sendServerMessage(sock, "[WHOIS] Chunk: {" + chunkPosition + "}");
|
||||||
ChatManager::sendServerMessage(sock, "[WHOIS] MapNum: " + std::to_string(MAPNUM(npc->instanceID)));
|
Chat::sendServerMessage(sock, "[WHOIS] MapNum: " + std::to_string(MAPNUM(npc->instanceID)));
|
||||||
ChatManager::sendServerMessage(sock, "[WHOIS] Instance: " + std::to_string(PLAYERID(npc->instanceID)));
|
Chat::sendServerMessage(sock, "[WHOIS] Instance: " + std::to_string(PLAYERID(npc->instanceID)));
|
||||||
}
|
}
|
||||||
|
|
||||||
static void lairUnlockCommand(std::string full, std::vector<std::string>& args, CNSocket* sock) {
|
static void lairUnlockCommand(std::string full, std::vector<std::string>& args, CNSocket* sock) {
|
||||||
Player* plr = PlayerManager::getPlayer(sock);
|
Player* plr = PlayerManager::getPlayer(sock);
|
||||||
if (!ChunkManager::chunkExists(plr->chunkPos))
|
if (!Chunking::chunkExists(plr->chunkPos))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
Chunk* chnk = ChunkManager::chunks[plr->chunkPos];
|
Chunk* chnk = Chunking::chunks[plr->chunkPos];
|
||||||
int taskID = -1;
|
int taskID = -1;
|
||||||
int missionID = -1;
|
int missionID = -1;
|
||||||
int found = 0;
|
int found = 0;
|
||||||
@ -688,7 +688,7 @@ static void lairUnlockCommand(std::string full, std::vector<std::string>& args,
|
|||||||
for (auto it = NPCManager::Warps.begin(); it != NPCManager::Warps.end(); it++) {
|
for (auto it = NPCManager::Warps.begin(); it != NPCManager::Warps.end(); it++) {
|
||||||
if ((*it).second.npcID == npc->appearanceData.iNPCType) {
|
if ((*it).second.npcID == npc->appearanceData.iNPCType) {
|
||||||
taskID = (*it).second.limitTaskID;
|
taskID = (*it).second.limitTaskID;
|
||||||
missionID = MissionManager::Tasks[taskID]->task["m_iHMissionID"];
|
missionID = Missions::Tasks[taskID]->task["m_iHMissionID"];
|
||||||
found++;
|
found++;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -696,17 +696,17 @@ static void lairUnlockCommand(std::string full, std::vector<std::string>& args,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (missionID == -1 || taskID == -1) {
|
if (missionID == -1 || taskID == -1) {
|
||||||
ChatManager::sendServerMessage(sock, "You are NOT standing near a lair portal; move around and try again!");
|
Chat::sendServerMessage(sock, "You are NOT standing near a lair portal; move around and try again!");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (found > 1) {
|
if (found > 1) {
|
||||||
ChatManager::sendServerMessage(sock, "More than one lair found; decrease chunk size and try again!");
|
Chat::sendServerMessage(sock, "More than one lair found; decrease chunk size and try again!");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
INITSTRUCT(sP_FE2CL_REP_PC_TASK_START_SUCC, taskResp);
|
INITSTRUCT(sP_FE2CL_REP_PC_TASK_START_SUCC, taskResp);
|
||||||
MissionManager::startTask(plr, taskID);
|
Missions::startTask(plr, taskID);
|
||||||
taskResp.iTaskNum = taskID;
|
taskResp.iTaskNum = taskID;
|
||||||
taskResp.iRemainTime = 0;
|
taskResp.iRemainTime = 0;
|
||||||
sock->sendPacket((void*)&taskResp, P_FE2CL_REP_PC_TASK_START_SUCC, sizeof(sP_FE2CL_REP_PC_TASK_START_SUCC));
|
sock->sendPacket((void*)&taskResp, P_FE2CL_REP_PC_TASK_START_SUCC, sizeof(sP_FE2CL_REP_PC_TASK_START_SUCC));
|
||||||
@ -720,35 +720,35 @@ static void lairUnlockCommand(std::string full, std::vector<std::string>& args,
|
|||||||
static void hideCommand(std::string full, std::vector<std::string>& args, CNSocket* sock) {
|
static void hideCommand(std::string full, std::vector<std::string>& args, CNSocket* sock) {
|
||||||
Player* plr = PlayerManager::getPlayer(sock);
|
Player* plr = PlayerManager::getPlayer(sock);
|
||||||
if (plr->hidden) {
|
if (plr->hidden) {
|
||||||
ChatManager::sendServerMessage(sock, "[HIDE] You're already hidden from the map.");
|
Chat::sendServerMessage(sock, "[HIDE] You're already hidden from the map.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
plr->hidden = true;
|
plr->hidden = true;
|
||||||
ChatManager::sendServerMessage(sock, "[HIDE] Successfully hidden from the map.");
|
Chat::sendServerMessage(sock, "[HIDE] Successfully hidden from the map.");
|
||||||
}
|
}
|
||||||
|
|
||||||
static void unhideCommand(std::string full, std::vector<std::string>& args, CNSocket* sock) {
|
static void unhideCommand(std::string full, std::vector<std::string>& args, CNSocket* sock) {
|
||||||
Player* plr = PlayerManager::getPlayer(sock);
|
Player* plr = PlayerManager::getPlayer(sock);
|
||||||
if (!plr->hidden) {
|
if (!plr->hidden) {
|
||||||
ChatManager::sendServerMessage(sock, "[HIDE] You're already visible from the map.");
|
Chat::sendServerMessage(sock, "[HIDE] You're already visible from the map.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
plr->hidden = false;
|
plr->hidden = false;
|
||||||
ChatManager::sendServerMessage(sock, "[HIDE] Successfully un-hidden from the map.");
|
Chat::sendServerMessage(sock, "[HIDE] Successfully un-hidden from the map.");
|
||||||
}
|
}
|
||||||
|
|
||||||
static void redeemCommand(std::string full, std::vector<std::string>& args, CNSocket* sock) {
|
static void redeemCommand(std::string full, std::vector<std::string>& args, CNSocket* sock) {
|
||||||
if (args.size() < 2) {
|
if (args.size() < 2) {
|
||||||
ChatManager::sendServerMessage(sock, "/redeem: No code specified");
|
Chat::sendServerMessage(sock, "/redeem: No code specified");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// convert string to all lowercase
|
// convert string to all lowercase
|
||||||
const char* codeRaw = args[1].c_str();
|
const char* codeRaw = args[1].c_str();
|
||||||
if (args[1].size() > 256) { // prevent overflow
|
if (args[1].size() > 256) { // prevent overflow
|
||||||
ChatManager::sendServerMessage(sock, "/redeem: Code too long");
|
Chat::sendServerMessage(sock, "/redeem: Code too long");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -757,25 +757,25 @@ static void redeemCommand(std::string full, std::vector<std::string>& args, CNSo
|
|||||||
buf[i] = std::tolower(codeRaw[i]);
|
buf[i] = std::tolower(codeRaw[i]);
|
||||||
std::string code(buf, args[1].size());
|
std::string code(buf, args[1].size());
|
||||||
|
|
||||||
if (ItemManager::CodeItems.find(code) == ItemManager::CodeItems.end()) {
|
if (Items::CodeItems.find(code) == Items::CodeItems.end()) {
|
||||||
ChatManager::sendServerMessage(sock, "/redeem: Unknown code");
|
Chat::sendServerMessage(sock, "/redeem: Unknown code");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Player* plr = PlayerManager::getPlayer(sock);
|
Player* plr = PlayerManager::getPlayer(sock);
|
||||||
|
|
||||||
if (Database::isCodeRedeemed(plr->iID, code)) {
|
if (Database::isCodeRedeemed(plr->iID, code)) {
|
||||||
ChatManager::sendServerMessage(sock, "/redeem: You have already redeemed this code item");
|
Chat::sendServerMessage(sock, "/redeem: You have already redeemed this code item");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
int itemCount = ItemManager::CodeItems[code].size();
|
int itemCount = Items::CodeItems[code].size();
|
||||||
std::vector<int> slots;
|
std::vector<int> slots;
|
||||||
|
|
||||||
for (int i = 0; i < itemCount; i++) {
|
for (int i = 0; i < itemCount; i++) {
|
||||||
slots.push_back(ItemManager::findFreeSlot(plr));
|
slots.push_back(Items::findFreeSlot(plr));
|
||||||
if (slots[i] == -1) {
|
if (slots[i] == -1) {
|
||||||
ChatManager::sendServerMessage(sock, "/redeem: Not enough space in inventory");
|
Chat::sendServerMessage(sock, "/redeem: Not enough space in inventory");
|
||||||
|
|
||||||
// delete any temp items we might have set
|
// delete any temp items we might have set
|
||||||
for (int j = 0; j < i; j++) {
|
for (int j = 0; j < i; j++) {
|
||||||
@ -790,7 +790,7 @@ static void redeemCommand(std::string full, std::vector<std::string>& args, CNSo
|
|||||||
Database::recordCodeRedemption(plr->iID, code);
|
Database::recordCodeRedemption(plr->iID, code);
|
||||||
|
|
||||||
for (int i = 0; i < itemCount; i++) {
|
for (int i = 0; i < itemCount; i++) {
|
||||||
std::pair<int32_t, int32_t> item = ItemManager::CodeItems[code][i];
|
std::pair<int32_t, int32_t> item = Items::CodeItems[code][i];
|
||||||
INITSTRUCT(sP_FE2CL_REP_PC_GIVE_ITEM_SUCC, resp);
|
INITSTRUCT(sP_FE2CL_REP_PC_GIVE_ITEM_SUCC, resp);
|
||||||
|
|
||||||
resp.eIL = 1;
|
resp.eIL = 1;
|
||||||
@ -806,7 +806,7 @@ static void redeemCommand(std::string full, std::vector<std::string>& args, CNSo
|
|||||||
sock->sendPacket((void*)&resp, P_FE2CL_REP_PC_GIVE_ITEM_SUCC, sizeof(sP_FE2CL_REP_PC_GIVE_ITEM_SUCC));
|
sock->sendPacket((void*)&resp, P_FE2CL_REP_PC_GIVE_ITEM_SUCC, sizeof(sP_FE2CL_REP_PC_GIVE_ITEM_SUCC));
|
||||||
}
|
}
|
||||||
std::string msg = itemCount == 1 ? "You have redeemed a code item" : "You have redeemed code items";
|
std::string msg = itemCount == 1 ? "You have redeemed a code item" : "You have redeemed code items";
|
||||||
ChatManager::sendServerMessage(sock, msg);
|
Chat::sendServerMessage(sock, msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void unwarpableCommand(std::string full, std::vector<std::string>& args, CNSocket* sock) {
|
static void unwarpableCommand(std::string full, std::vector<std::string>& args, CNSocket* sock) {
|
||||||
@ -857,14 +857,14 @@ static void banCommand(std::string full, std::vector<std::string>& args, CNSocke
|
|||||||
Player* plr = PlayerManager::getPlayer(sock);
|
Player* plr = PlayerManager::getPlayer(sock);
|
||||||
|
|
||||||
if (args.size() < 2) {
|
if (args.size() < 2) {
|
||||||
ChatManager::sendServerMessage(sock, "Usage: /ban PlayerID [reason...]");
|
Chat::sendServerMessage(sock, "Usage: /ban PlayerID [reason...]");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
char *rest;
|
char *rest;
|
||||||
int playerId = std::strtol(args[1].c_str(), &rest, 10);
|
int playerId = std::strtol(args[1].c_str(), &rest, 10);
|
||||||
if (*rest) {
|
if (*rest) {
|
||||||
ChatManager::sendServerMessage(sock, "Invalid PlayerID: " + args[1]);
|
Chat::sendServerMessage(sock, "Invalid PlayerID: " + args[1]);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -880,17 +880,17 @@ static void banCommand(std::string full, std::vector<std::string>& args, CNSocke
|
|||||||
// ban the account that player belongs to
|
// ban the account that player belongs to
|
||||||
if (!Database::banPlayer(playerId, reason)) {
|
if (!Database::banPlayer(playerId, reason)) {
|
||||||
// propagating a more descriptive error message from banPlayer() would be too much work
|
// propagating a more descriptive error message from banPlayer() would be too much work
|
||||||
ChatManager::sendServerMessage(sock, "Failed to ban target player. Check server logs.");
|
Chat::sendServerMessage(sock, "Failed to ban target player. Check server logs.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
ChatManager::sendServerMessage(sock, "Banned target player.");
|
Chat::sendServerMessage(sock, "Banned target player.");
|
||||||
std::cout << "[INFO] " << PlayerManager::getPlayerName(plr) << " banned player " << playerId << std::endl;
|
std::cout << "[INFO] " << PlayerManager::getPlayerName(plr) << " banned player " << playerId << std::endl;
|
||||||
|
|
||||||
// if the player is online, kick them
|
// if the player is online, kick them
|
||||||
CNSocket *otherSock = PlayerManager::getSockFromID(playerId);
|
CNSocket *otherSock = PlayerManager::getSockFromID(playerId);
|
||||||
if (otherSock == nullptr) {
|
if (otherSock == nullptr) {
|
||||||
ChatManager::sendServerMessage(sock, "Player wasn't online. Didn't need to kick.");
|
Chat::sendServerMessage(sock, "Player wasn't online. Didn't need to kick.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -907,29 +907,29 @@ static void banCommand(std::string full, std::vector<std::string>& args, CNSocke
|
|||||||
// ensure that the connection has terminated
|
// ensure that the connection has terminated
|
||||||
otherSock->kill();
|
otherSock->kill();
|
||||||
|
|
||||||
ChatManager::sendServerMessage(sock, PlayerManager::getPlayerName(otherPlr) + " was online. Kicked.");
|
Chat::sendServerMessage(sock, PlayerManager::getPlayerName(otherPlr) + " was online. Kicked.");
|
||||||
}
|
}
|
||||||
|
|
||||||
static void unbanCommand(std::string full, std::vector<std::string>& args, CNSocket *sock) {
|
static void unbanCommand(std::string full, std::vector<std::string>& args, CNSocket *sock) {
|
||||||
Player* plr = PlayerManager::getPlayer(sock);
|
Player* plr = PlayerManager::getPlayer(sock);
|
||||||
|
|
||||||
if (args.size() < 2) {
|
if (args.size() < 2) {
|
||||||
ChatManager::sendServerMessage(sock, "Usage: /unban PlayerID");
|
Chat::sendServerMessage(sock, "Usage: /unban PlayerID");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
char *rest;
|
char *rest;
|
||||||
int playerId = std::strtol(args[1].c_str(), &rest, 10);
|
int playerId = std::strtol(args[1].c_str(), &rest, 10);
|
||||||
if (*rest) {
|
if (*rest) {
|
||||||
ChatManager::sendServerMessage(sock, "Invalid PlayerID: " + args[1]);
|
Chat::sendServerMessage(sock, "Invalid PlayerID: " + args[1]);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Database::unbanPlayer(playerId)) {
|
if (Database::unbanPlayer(playerId)) {
|
||||||
ChatManager::sendServerMessage(sock, "Unbanned player.");
|
Chat::sendServerMessage(sock, "Unbanned player.");
|
||||||
std::cout << "[INFO] " << PlayerManager::getPlayerName(plr) << " unbanned player " << playerId << std::endl;
|
std::cout << "[INFO] " << PlayerManager::getPlayerName(plr) << " unbanned player " << playerId << std::endl;
|
||||||
} else {
|
} else {
|
||||||
ChatManager::sendServerMessage(sock, "Failed to unban player. Check server logs.");
|
Chat::sendServerMessage(sock, "Failed to unban player. Check server logs.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -6,8 +6,8 @@
|
|||||||
|
|
||||||
#include "db/Database.hpp"
|
#include "db/Database.hpp"
|
||||||
#include "PlayerManager.hpp"
|
#include "PlayerManager.hpp"
|
||||||
#include "ItemManager.hpp"
|
#include "Items.hpp"
|
||||||
#include "ChatManager.hpp"
|
#include "Chat.hpp"
|
||||||
|
|
||||||
using namespace Email;
|
using namespace Email;
|
||||||
|
|
||||||
@ -149,7 +149,7 @@ static void emailReceiveItemAll(CNSocket* sock, CNPacketData* data) {
|
|||||||
Player* plr = PlayerManager::getPlayer(sock);
|
Player* plr = PlayerManager::getPlayer(sock);
|
||||||
sItemBase* itemsFrom = Database::getEmailAttachments(plr->iID, pkt->iEmailIndex);
|
sItemBase* itemsFrom = Database::getEmailAttachments(plr->iID, pkt->iEmailIndex);
|
||||||
for (int i = 0; i < 4; i++) {
|
for (int i = 0; i < 4; i++) {
|
||||||
int slot = ItemManager::findFreeSlot(plr);
|
int slot = Items::findFreeSlot(plr);
|
||||||
if (slot < 0 || slot >= AINVEN_COUNT) {
|
if (slot < 0 || slot >= AINVEN_COUNT) {
|
||||||
INITSTRUCT(sP_FE2CL_REP_PC_RECV_EMAIL_ITEM_ALL_FAIL, failResp);
|
INITSTRUCT(sP_FE2CL_REP_PC_RECV_EMAIL_ITEM_ALL_FAIL, failResp);
|
||||||
failResp.iEmailIndex = pkt->iEmailIndex;
|
failResp.iEmailIndex = pkt->iEmailIndex;
|
||||||
@ -292,8 +292,8 @@ static void emailSend(CNSocket* sock, CNPacketData* data) {
|
|||||||
plr->iID, // SenderID
|
plr->iID, // SenderID
|
||||||
U16toU8(plr->PCStyle.szFirstName), // SenderFirstName
|
U16toU8(plr->PCStyle.szFirstName), // SenderFirstName
|
||||||
U16toU8(plr->PCStyle.szLastName), // SenderLastName
|
U16toU8(plr->PCStyle.szLastName), // SenderLastName
|
||||||
ChatManager::sanitizeText(U16toU8(pkt->szSubject)), // SubjectLine
|
Chat::sanitizeText(U16toU8(pkt->szSubject)), // SubjectLine
|
||||||
ChatManager::sanitizeText(U16toU8(pkt->szContent), true), // MsgBody
|
Chat::sanitizeText(U16toU8(pkt->szContent), true), // MsgBody
|
||||||
pkt->iCash, // Taros
|
pkt->iCash, // Taros
|
||||||
(uint64_t)getTimestamp(), // SendTime
|
(uint64_t)getTimestamp(), // SendTime
|
||||||
0 // DeleteTime (unimplemented)
|
0 // DeleteTime (unimplemented)
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
#include "CNShardServer.hpp"
|
#include "CNShardServer.hpp"
|
||||||
#include "CNStructs.hpp"
|
#include "CNStructs.hpp"
|
||||||
#include "PlayerManager.hpp"
|
#include "PlayerManager.hpp"
|
||||||
#include "GroupManager.hpp"
|
#include "Groups.hpp"
|
||||||
#include "NanoManager.hpp"
|
#include "Nanos.hpp"
|
||||||
#include "Abilities.hpp"
|
#include "Abilities.hpp"
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
@ -10,7 +10,7 @@
|
|||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <thread>
|
#include <thread>
|
||||||
|
|
||||||
using namespace GroupManager;
|
using namespace Groups;
|
||||||
|
|
||||||
static void requestGroup(CNSocket* sock, CNPacketData* data) {
|
static void requestGroup(CNSocket* sock, CNPacketData* data) {
|
||||||
if (data->size != sizeof(sP_CL2FE_REQ_PC_GROUP_INVITE))
|
if (data->size != sizeof(sP_CL2FE_REQ_PC_GROUP_INVITE))
|
||||||
@ -137,10 +137,10 @@ static void joinGroup(CNSocket* sock, CNPacketData* data) {
|
|||||||
// client doesnt read nano data here
|
// client doesnt read nano data here
|
||||||
|
|
||||||
if (varPlr != plr) { // apply the new member's buffs to the group and the group's buffs to the new member
|
if (varPlr != plr) { // apply the new member's buffs to the group and the group's buffs to the new member
|
||||||
if (NanoManager::SkillTable[varPlr->Nanos[varPlr->activeNano].iSkillID].targetType == 3)
|
if (Nanos::SkillTable[varPlr->Nanos[varPlr->activeNano].iSkillID].targetType == 3)
|
||||||
NanoManager::applyBuff(sock, varPlr->Nanos[varPlr->activeNano].iSkillID, 1, 1, bitFlag);
|
Nanos::applyBuff(sock, varPlr->Nanos[varPlr->activeNano].iSkillID, 1, 1, bitFlag);
|
||||||
if (NanoManager::SkillTable[plr->Nanos[plr->activeNano].iSkillID].targetType == 3)
|
if (Nanos::SkillTable[plr->Nanos[plr->activeNano].iSkillID].targetType == 3)
|
||||||
NanoManager::applyBuff(sockTo, plr->Nanos[plr->activeNano].iSkillID, 1, 1, bitFlag);
|
Nanos::applyBuff(sockTo, plr->Nanos[plr->activeNano].iSkillID, 1, 1, bitFlag);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -152,7 +152,7 @@ static void leaveGroup(CNSocket* sock, CNPacketData* data) {
|
|||||||
groupKickPlayer(plr);
|
groupKickPlayer(plr);
|
||||||
}
|
}
|
||||||
|
|
||||||
void GroupManager::sendToGroup(Player* plr, void* buf, uint32_t type, size_t size) {
|
void Groups::sendToGroup(Player* plr, void* buf, uint32_t type, size_t size) {
|
||||||
for (int i = 0; i < plr->groupCnt; i++) {
|
for (int i = 0; i < plr->groupCnt; i++) {
|
||||||
CNSocket* sock = PlayerManager::getSockFromID(plr->groupIDs[i]);
|
CNSocket* sock = PlayerManager::getSockFromID(plr->groupIDs[i]);
|
||||||
|
|
||||||
@ -168,7 +168,7 @@ void GroupManager::sendToGroup(Player* plr, void* buf, uint32_t type, size_t siz
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void GroupManager::groupTickInfo(Player* plr) {
|
void Groups::groupTickInfo(Player* plr) {
|
||||||
if (!validOutVarPacket(sizeof(sP_FE2CL_PC_GROUP_MEMBER_INFO), plr->groupCnt, sizeof(sPCGroupMemberInfo))) {
|
if (!validOutVarPacket(sizeof(sP_FE2CL_PC_GROUP_MEMBER_INFO), plr->groupCnt, sizeof(sPCGroupMemberInfo))) {
|
||||||
std::cout << "[WARN] bad sP_FE2CL_PC_GROUP_JOIN packet size\n";
|
std::cout << "[WARN] bad sP_FE2CL_PC_GROUP_JOIN packet size\n";
|
||||||
return;
|
return;
|
||||||
@ -223,12 +223,12 @@ static void groupUnbuff(Player* plr) {
|
|||||||
Player* otherPlr = PlayerManager::getPlayerFromID(plr->groupIDs[i]);
|
Player* otherPlr = PlayerManager::getPlayerFromID(plr->groupIDs[i]);
|
||||||
CNSocket* sock = PlayerManager::getSockFromID(plr->groupIDs[n]);
|
CNSocket* sock = PlayerManager::getSockFromID(plr->groupIDs[n]);
|
||||||
|
|
||||||
NanoManager::applyBuff(sock, otherPlr->Nanos[otherPlr->activeNano].iSkillID, 2, 1, 0);
|
Nanos::applyBuff(sock, otherPlr->Nanos[otherPlr->activeNano].iSkillID, 2, 1, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void GroupManager::groupKickPlayer(Player* plr) {
|
void Groups::groupKickPlayer(Player* plr) {
|
||||||
// if you are the group leader, destroy your own group and kick everybody
|
// if you are the group leader, destroy your own group and kick everybody
|
||||||
if (plr->iID == plr->iIDGroup) {
|
if (plr->iID == plr->iIDGroup) {
|
||||||
groupUnbuff(plr);
|
groupUnbuff(plr);
|
||||||
@ -297,10 +297,10 @@ void GroupManager::groupKickPlayer(Player* plr) {
|
|||||||
moveDown = 1;
|
moveDown = 1;
|
||||||
otherPlr->groupIDs[i] = 0;
|
otherPlr->groupIDs[i] = 0;
|
||||||
} else { // remove the leaving member's buffs from the group and remove the group buffs from the leaving member.
|
} else { // remove the leaving member's buffs from the group and remove the group buffs from the leaving member.
|
||||||
if (NanoManager::SkillTable[varPlr->Nanos[varPlr->activeNano].iSkillID].targetType == 3)
|
if (Nanos::SkillTable[varPlr->Nanos[varPlr->activeNano].iSkillID].targetType == 3)
|
||||||
NanoManager::applyBuff(sock, varPlr->Nanos[varPlr->activeNano].iSkillID, 2, 1, 0);
|
Nanos::applyBuff(sock, varPlr->Nanos[varPlr->activeNano].iSkillID, 2, 1, 0);
|
||||||
if (NanoManager::SkillTable[plr->Nanos[varPlr->activeNano].iSkillID].targetType == 3)
|
if (Nanos::SkillTable[plr->Nanos[varPlr->activeNano].iSkillID].targetType == 3)
|
||||||
NanoManager::applyBuff(sockTo, plr->Nanos[plr->activeNano].iSkillID, 2, 1, bitFlag);
|
Nanos::applyBuff(sockTo, plr->Nanos[plr->activeNano].iSkillID, 2, 1, bitFlag);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -313,7 +313,7 @@ void GroupManager::groupKickPlayer(Player* plr) {
|
|||||||
sock->sendPacket((void*)&resp1, P_FE2CL_PC_GROUP_LEAVE_SUCC, sizeof(sP_FE2CL_PC_GROUP_LEAVE_SUCC));
|
sock->sendPacket((void*)&resp1, P_FE2CL_PC_GROUP_LEAVE_SUCC, sizeof(sP_FE2CL_PC_GROUP_LEAVE_SUCC));
|
||||||
}
|
}
|
||||||
|
|
||||||
int GroupManager::getGroupFlags(Player* plr) {
|
int Groups::getGroupFlags(Player* plr) {
|
||||||
int bitFlag = 0;
|
int bitFlag = 0;
|
||||||
|
|
||||||
for (int i = 0; i < plr->groupCnt; i++) {
|
for (int i = 0; i < plr->groupCnt; i++) {
|
||||||
@ -328,7 +328,7 @@ int GroupManager::getGroupFlags(Player* plr) {
|
|||||||
return bitFlag;
|
return bitFlag;
|
||||||
}
|
}
|
||||||
|
|
||||||
void GroupManager::init() {
|
void Groups::init() {
|
||||||
REGISTER_SHARD_PACKET(P_CL2FE_REQ_PC_GROUP_INVITE, requestGroup);
|
REGISTER_SHARD_PACKET(P_CL2FE_REQ_PC_GROUP_INVITE, requestGroup);
|
||||||
REGISTER_SHARD_PACKET(P_CL2FE_REQ_PC_GROUP_INVITE_REFUSE, refuseGroup);
|
REGISTER_SHARD_PACKET(P_CL2FE_REQ_PC_GROUP_INVITE_REFUSE, refuseGroup);
|
||||||
REGISTER_SHARD_PACKET(P_CL2FE_REQ_PC_GROUP_JOIN, joinGroup);
|
REGISTER_SHARD_PACKET(P_CL2FE_REQ_PC_GROUP_JOIN, joinGroup);
|
@ -8,7 +8,7 @@
|
|||||||
#include <map>
|
#include <map>
|
||||||
#include <list>
|
#include <list>
|
||||||
|
|
||||||
namespace GroupManager {
|
namespace Groups {
|
||||||
void init();
|
void init();
|
||||||
|
|
||||||
void sendToGroup(Player* plr, void* buf, uint32_t type, size_t size);
|
void sendToGroup(Player* plr, void* buf, uint32_t type, size_t size);
|
@ -1,31 +1,31 @@
|
|||||||
#include "CNShardServer.hpp"
|
#include "CNShardServer.hpp"
|
||||||
#include "CNStructs.hpp"
|
#include "CNStructs.hpp"
|
||||||
#include "ItemManager.hpp"
|
#include "Items.hpp"
|
||||||
#include "PlayerManager.hpp"
|
#include "PlayerManager.hpp"
|
||||||
#include "NanoManager.hpp"
|
#include "Nanos.hpp"
|
||||||
#include "NPCManager.hpp"
|
#include "NPCManager.hpp"
|
||||||
#include "Player.hpp"
|
#include "Player.hpp"
|
||||||
#include "Abilities.hpp"
|
#include "Abilities.hpp"
|
||||||
#include "MissionManager.hpp"
|
#include "Missions.hpp"
|
||||||
|
|
||||||
#include <string.h> // for memset()
|
#include <string.h> // for memset()
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
|
||||||
using namespace ItemManager;
|
using namespace Items;
|
||||||
|
|
||||||
std::map<std::pair<int32_t, int32_t>, ItemManager::Item> ItemManager::ItemData;
|
std::map<std::pair<int32_t, int32_t>, Items::Item> Items::ItemData;
|
||||||
std::map<int32_t, CrocPotEntry> ItemManager::CrocPotTable;
|
std::map<int32_t, CrocPotEntry> Items::CrocPotTable;
|
||||||
std::map<int32_t, std::vector<int>> ItemManager::RarityRatios;
|
std::map<int32_t, std::vector<int>> Items::RarityRatios;
|
||||||
std::map<int32_t, Crate> ItemManager::Crates;
|
std::map<int32_t, Crate> Items::Crates;
|
||||||
// pair Itemset, Rarity -> vector of pointers (map iterators) to records in ItemData
|
// pair Itemset, Rarity -> vector of pointers (map iterators) to records in ItemData
|
||||||
std::map<std::pair<int32_t, int32_t>, std::vector<std::map<std::pair<int32_t, int32_t>, ItemManager::Item>::iterator>> ItemManager::CrateItems;
|
std::map<std::pair<int32_t, int32_t>, std::vector<std::map<std::pair<int32_t, int32_t>, Items::Item>::iterator>> Items::CrateItems;
|
||||||
std::map<std::string, std::vector<std::pair<int32_t, int32_t>>> ItemManager::CodeItems;
|
std::map<std::string, std::vector<std::pair<int32_t, int32_t>>> Items::CodeItems;
|
||||||
|
|
||||||
std::map<int32_t, MobDropChance> ItemManager::MobDropChances;
|
std::map<int32_t, MobDropChance> Items::MobDropChances;
|
||||||
std::map<int32_t, MobDrop> ItemManager::MobDrops;
|
std::map<int32_t, MobDrop> Items::MobDrops;
|
||||||
|
|
||||||
#ifdef ACADEMY
|
#ifdef ACADEMY
|
||||||
std::map<int32_t, int32_t> ItemManager::NanoCapsules; // crate id -> nano id
|
std::map<int32_t, int32_t> Items::NanoCapsules; // crate id -> nano id
|
||||||
|
|
||||||
static void nanoCapsuleHandler(CNSocket* sock, int slot, sItemBase *chest) {
|
static void nanoCapsuleHandler(CNSocket* sock, int slot, sItemBase *chest) {
|
||||||
Player* plr = PlayerManager::getPlayer(sock);
|
Player* plr = PlayerManager::getPlayer(sock);
|
||||||
@ -77,7 +77,7 @@ static void nanoCapsuleHandler(CNSocket* sock, int slot, sItemBase *chest) {
|
|||||||
sock->sendPacket((void*)&msg, P_FE2CL_GM_REP_PC_ANNOUNCE, sizeof(sP_FE2CL_GM_REP_PC_ANNOUNCE));
|
sock->sendPacket((void*)&msg, P_FE2CL_GM_REP_PC_ANNOUNCE, sizeof(sP_FE2CL_GM_REP_PC_ANNOUNCE));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
NanoManager::addNano(sock, nanoId, -1, false);
|
Nanos::addNano(sock, nanoId, -1, false);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -360,7 +360,7 @@ static void itemUseHandler(CNSocket* sock, CNPacketData* data) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// sanity check, check if gumball type matches nano style
|
// sanity check, check if gumball type matches nano style
|
||||||
int nanoStyle = NanoManager::nanoStyle(nano.iID);
|
int nanoStyle = Nanos::nanoStyle(nano.iID);
|
||||||
if (!((gumball.iID == 119 && nanoStyle == 0) ||
|
if (!((gumball.iID == 119 && nanoStyle == 0) ||
|
||||||
( gumball.iID == 120 && nanoStyle == 1) ||
|
( gumball.iID == 120 && nanoStyle == 1) ||
|
||||||
( gumball.iID == 121 && nanoStyle == 2))) {
|
( gumball.iID == 121 && nanoStyle == 2))) {
|
||||||
@ -417,7 +417,7 @@ static void itemUseHandler(CNSocket* sock, CNPacketData* data) {
|
|||||||
player->Inven[resp->iSlotNum] = resp->RemainItem;
|
player->Inven[resp->iSlotNum] = resp->RemainItem;
|
||||||
|
|
||||||
std::pair<CNSocket*, int32_t> key = std::make_pair(sock, value1);
|
std::pair<CNSocket*, int32_t> key = std::make_pair(sock, value1);
|
||||||
time_t until = getTime() + (time_t)NanoManager::SkillTable[144].durationTime[0] * 100;
|
time_t until = getTime() + (time_t)Nanos::SkillTable[144].durationTime[0] * 100;
|
||||||
NPCManager::EggBuffs[key] = until;
|
NPCManager::EggBuffs[key] = until;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -532,8 +532,8 @@ static void chestOpenHandler(CNSocket *sock, CNPacketData *data) {
|
|||||||
sock->sendPacket((void*)&resp, P_FE2CL_REP_ITEM_CHEST_OPEN_SUCC, sizeof(sP_FE2CL_REP_ITEM_CHEST_OPEN_SUCC));
|
sock->sendPacket((void*)&resp, P_FE2CL_REP_ITEM_CHEST_OPEN_SUCC, sizeof(sP_FE2CL_REP_ITEM_CHEST_OPEN_SUCC));
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: use this in cleaned up ItemManager
|
// TODO: use this in cleaned up Items
|
||||||
int ItemManager::findFreeSlot(Player *plr) {
|
int Items::findFreeSlot(Player *plr) {
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
for (i = 0; i < AINVEN_COUNT; i++)
|
for (i = 0; i < AINVEN_COUNT; i++)
|
||||||
@ -544,13 +544,13 @@ int ItemManager::findFreeSlot(Player *plr) {
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
Item* ItemManager::getItemData(int32_t id, int32_t type) {
|
Item* Items::getItemData(int32_t id, int32_t type) {
|
||||||
if(ItemData.find(std::make_pair(id, type)) != ItemData.end())
|
if(ItemData.find(std::make_pair(id, type)) != ItemData.end())
|
||||||
return &ItemData[std::make_pair(id, type)];
|
return &ItemData[std::make_pair(id, type)];
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ItemManager::checkItemExpire(CNSocket* sock, Player* player) {
|
void Items::checkItemExpire(CNSocket* sock, Player* player) {
|
||||||
if (player->toRemoveVehicle.eIL == 0 && player->toRemoveVehicle.iSlotNum == 0)
|
if (player->toRemoveVehicle.eIL == 0 && player->toRemoveVehicle.iSlotNum == 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@ -585,7 +585,7 @@ void ItemManager::checkItemExpire(CNSocket* sock, Player* player) {
|
|||||||
player->toRemoveVehicle.iSlotNum = 0;
|
player->toRemoveVehicle.iSlotNum = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ItemManager::setItemStats(Player* plr) {
|
void Items::setItemStats(Player* plr) {
|
||||||
|
|
||||||
plr->pointDamage = 8 + plr->level * 2;
|
plr->pointDamage = 8 + plr->level * 2;
|
||||||
plr->groupDamage = 8 + plr->level * 2;
|
plr->groupDamage = 8 + plr->level * 2;
|
||||||
@ -609,7 +609,7 @@ void ItemManager::setItemStats(Player* plr) {
|
|||||||
|
|
||||||
// HACK: work around the invisible weapon bug
|
// HACK: work around the invisible weapon bug
|
||||||
// TODO: I don't think this makes a difference at all? Check and remove, if necessary.
|
// TODO: I don't think this makes a difference at all? Check and remove, if necessary.
|
||||||
void ItemManager::updateEquips(CNSocket* sock, Player* plr) {
|
void Items::updateEquips(CNSocket* sock, Player* plr) {
|
||||||
for (int i = 0; i < 4; i++) {
|
for (int i = 0; i < 4; i++) {
|
||||||
INITSTRUCT(sP_FE2CL_PC_EQUIP_CHANGE, resp);
|
INITSTRUCT(sP_FE2CL_PC_EQUIP_CHANGE, resp);
|
||||||
|
|
||||||
@ -696,7 +696,7 @@ static void giveEventDrop(CNSocket* sock, Player* player, int rolled) {
|
|||||||
sock->sendPacket((void*)respbuf, P_FE2CL_REP_REWARD_ITEM, resplen);
|
sock->sendPacket((void*)respbuf, P_FE2CL_REP_REWARD_ITEM, resplen);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ItemManager::giveMobDrop(CNSocket *sock, Mob* mob, int rolledBoosts, int rolledPotions,
|
void Items::giveMobDrop(CNSocket *sock, Mob* mob, int rolledBoosts, int rolledPotions,
|
||||||
int rolledCrate, int rolledCrateType, int rolledEvent) {
|
int rolledCrate, int rolledCrateType, int rolledEvent) {
|
||||||
Player *plr = PlayerManager::getPlayer(sock);
|
Player *plr = PlayerManager::getPlayer(sock);
|
||||||
|
|
||||||
@ -723,7 +723,7 @@ void ItemManager::giveMobDrop(CNSocket *sock, Mob* mob, int rolledBoosts, int ro
|
|||||||
// money nano boost
|
// money nano boost
|
||||||
if (plr->iConditionBitFlag & CSB_BIT_REWARD_CASH) {
|
if (plr->iConditionBitFlag & CSB_BIT_REWARD_CASH) {
|
||||||
int boost = 0;
|
int boost = 0;
|
||||||
if (NanoManager::getNanoBoost(plr)) // for gumballs
|
if (Nanos::getNanoBoost(plr)) // for gumballs
|
||||||
boost = 1;
|
boost = 1;
|
||||||
plr->money += drop.taros * (5 + boost) / 25;
|
plr->money += drop.taros * (5 + boost) / 25;
|
||||||
}
|
}
|
||||||
@ -736,12 +736,12 @@ void ItemManager::giveMobDrop(CNSocket *sock, Mob* mob, int rolledBoosts, int ro
|
|||||||
// scavenger nano boost
|
// scavenger nano boost
|
||||||
if (plr->iConditionBitFlag & CSB_BIT_REWARD_BLOB) {
|
if (plr->iConditionBitFlag & CSB_BIT_REWARD_BLOB) {
|
||||||
int boost = 0;
|
int boost = 0;
|
||||||
if (NanoManager::getNanoBoost(plr)) // for gumballs
|
if (Nanos::getNanoBoost(plr)) // for gumballs
|
||||||
boost = 1;
|
boost = 1;
|
||||||
fm += fm * (5 + boost) / 25;
|
fm += fm * (5 + boost) / 25;
|
||||||
}
|
}
|
||||||
|
|
||||||
MissionManager::updateFusionMatter(sock, fm);
|
Missions::updateFusionMatter(sock, fm);
|
||||||
|
|
||||||
// give boosts 1 in 3 times
|
// give boosts 1 in 3 times
|
||||||
if (drop.boosts > 0) {
|
if (drop.boosts > 0) {
|
||||||
@ -800,7 +800,7 @@ void ItemManager::giveMobDrop(CNSocket *sock, Mob* mob, int rolledBoosts, int ro
|
|||||||
giveEventDrop(sock, plr, rolledEvent);
|
giveEventDrop(sock, plr, rolledEvent);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ItemManager::init() {
|
void Items::init() {
|
||||||
REGISTER_SHARD_PACKET(P_CL2FE_REQ_ITEM_MOVE, itemMoveHandler);
|
REGISTER_SHARD_PACKET(P_CL2FE_REQ_ITEM_MOVE, itemMoveHandler);
|
||||||
REGISTER_SHARD_PACKET(P_CL2FE_REQ_PC_ITEM_DELETE, itemDeleteHandler);
|
REGISTER_SHARD_PACKET(P_CL2FE_REQ_PC_ITEM_DELETE, itemDeleteHandler);
|
||||||
// this one is for gumballs
|
// this one is for gumballs
|
@ -27,7 +27,7 @@ struct MobDrop {
|
|||||||
int boosts;
|
int boosts;
|
||||||
};
|
};
|
||||||
|
|
||||||
namespace ItemManager {
|
namespace Items {
|
||||||
enum class SlotType {
|
enum class SlotType {
|
||||||
EQUIP = 0,
|
EQUIP = 0,
|
||||||
INVENTORY = 1,
|
INVENTORY = 1,
|
@ -1,17 +1,17 @@
|
|||||||
#include "CNShardServer.hpp"
|
#include "CNShardServer.hpp"
|
||||||
#include "CNStructs.hpp"
|
#include "CNStructs.hpp"
|
||||||
#include "MissionManager.hpp"
|
#include "Missions.hpp"
|
||||||
#include "PlayerManager.hpp"
|
#include "PlayerManager.hpp"
|
||||||
#include "NanoManager.hpp"
|
#include "Nanos.hpp"
|
||||||
#include "ItemManager.hpp"
|
#include "Items.hpp"
|
||||||
|
|
||||||
#include "string.h"
|
#include "string.h"
|
||||||
|
|
||||||
using namespace MissionManager;
|
using namespace Missions;
|
||||||
|
|
||||||
std::map<int32_t, Reward*> MissionManager::Rewards;
|
std::map<int32_t, Reward*> Missions::Rewards;
|
||||||
std::map<int32_t, TaskData*> MissionManager::Tasks;
|
std::map<int32_t, TaskData*> Missions::Tasks;
|
||||||
nlohmann::json MissionManager::AvatarGrowth[37];
|
nlohmann::json Missions::AvatarGrowth[37];
|
||||||
|
|
||||||
static void saveMission(Player* player, int missionId) {
|
static void saveMission(Player* player, int missionId) {
|
||||||
// sanity check missionID so we don't get exceptions
|
// sanity check missionID so we don't get exceptions
|
||||||
@ -127,7 +127,7 @@ static int giveMissionReward(CNSocket *sock, int task, int choice=0) {
|
|||||||
|
|
||||||
int slots[4];
|
int slots[4];
|
||||||
for (int i = 0; i < nrewards; i++) {
|
for (int i = 0; i < nrewards; i++) {
|
||||||
slots[i] = ItemManager::findFreeSlot(plr);
|
slots[i] = Items::findFreeSlot(plr);
|
||||||
if (slots[i] == -1) {
|
if (slots[i] == -1) {
|
||||||
std::cout << "Not enough room to complete task" << std::endl;
|
std::cout << "Not enough room to complete task" << std::endl;
|
||||||
INITSTRUCT(sP_FE2CL_REP_PC_TASK_END_FAIL, fail);
|
INITSTRUCT(sP_FE2CL_REP_PC_TASK_END_FAIL, fail);
|
||||||
@ -160,14 +160,14 @@ static int giveMissionReward(CNSocket *sock, int task, int choice=0) {
|
|||||||
plr->money += reward->money;
|
plr->money += reward->money;
|
||||||
if (plr->iConditionBitFlag & CSB_BIT_REWARD_CASH) { // nano boost for taros
|
if (plr->iConditionBitFlag & CSB_BIT_REWARD_CASH) { // nano boost for taros
|
||||||
int boost = 0;
|
int boost = 0;
|
||||||
if (NanoManager::getNanoBoost(plr)) // for gumballs
|
if (Nanos::getNanoBoost(plr)) // for gumballs
|
||||||
boost = 1;
|
boost = 1;
|
||||||
plr->money += reward->money * (5 + boost) / 25;
|
plr->money += reward->money * (5 + boost) / 25;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (plr->iConditionBitFlag & CSB_BIT_REWARD_BLOB) { // nano boost for fm
|
if (plr->iConditionBitFlag & CSB_BIT_REWARD_BLOB) { // nano boost for fm
|
||||||
int boost = 0;
|
int boost = 0;
|
||||||
if (NanoManager::getNanoBoost(plr)) // for gumballs
|
if (Nanos::getNanoBoost(plr)) // for gumballs
|
||||||
boost = 1;
|
boost = 1;
|
||||||
updateFusionMatter(sock, reward->fusionmatter * (30 + boost) / 25);
|
updateFusionMatter(sock, reward->fusionmatter * (30 + boost) / 25);
|
||||||
} else
|
} else
|
||||||
@ -259,7 +259,7 @@ static bool endTask(CNSocket *sock, int32_t taskNum, int choice=0) {
|
|||||||
|
|
||||||
// if it's a nano mission, reward the nano.
|
// if it's a nano mission, reward the nano.
|
||||||
if (task["m_iSTNanoID"] != 0)
|
if (task["m_iSTNanoID"] != 0)
|
||||||
NanoManager::addNano(sock, task["m_iSTNanoID"], 0, true);
|
Nanos::addNano(sock, task["m_iSTNanoID"], 0, true);
|
||||||
|
|
||||||
// remove current mission
|
// remove current mission
|
||||||
plr->CurrentMissionID = 0;
|
plr->CurrentMissionID = 0;
|
||||||
@ -268,13 +268,13 @@ static bool endTask(CNSocket *sock, int32_t taskNum, int choice=0) {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool MissionManager::startTask(Player* plr, int TaskID) {
|
bool Missions::startTask(Player* plr, int TaskID) {
|
||||||
if (MissionManager::Tasks.find(TaskID) == MissionManager::Tasks.end()) {
|
if (Missions::Tasks.find(TaskID) == Missions::Tasks.end()) {
|
||||||
std::cout << "[WARN] Player submitted unknown task!?" << std::endl;
|
std::cout << "[WARN] Player submitted unknown task!?" << std::endl;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
TaskData& task = *MissionManager::Tasks[TaskID];
|
TaskData& task = *Missions::Tasks[TaskID];
|
||||||
|
|
||||||
// client freaks out if nano mission isn't sent first after relogging, so it's easiest to set it here
|
// client freaks out if nano mission isn't sent first after relogging, so it's easiest to set it here
|
||||||
if (task["m_iSTNanoID"] != 0 && plr->tasks[0] != 0) {
|
if (task["m_iSTNanoID"] != 0 && plr->tasks[0] != 0) {
|
||||||
@ -357,7 +357,7 @@ static void taskEnd(CNSocket* sock, CNPacketData* data) {
|
|||||||
|
|
||||||
// failed timed missions give an iNPC_ID of 0
|
// failed timed missions give an iNPC_ID of 0
|
||||||
if (missionData->iNPC_ID == 0) {
|
if (missionData->iNPC_ID == 0) {
|
||||||
TaskData* task = MissionManager::Tasks[missionData->iTaskNum];
|
TaskData* task = Missions::Tasks[missionData->iTaskNum];
|
||||||
if (task->task["m_iSTGrantTimer"] > 0) { // its a timed mission
|
if (task->task["m_iSTGrantTimer"] > 0) { // its a timed mission
|
||||||
Player* plr = PlayerManager::getPlayer(sock);
|
Player* plr = PlayerManager::getPlayer(sock);
|
||||||
/*
|
/*
|
||||||
@ -384,7 +384,7 @@ static void taskEnd(CNSocket* sock, CNPacketData* data) {
|
|||||||
|
|
||||||
int failTaskID = task->task["m_iFOutgoingTask"];
|
int failTaskID = task->task["m_iFOutgoingTask"];
|
||||||
if (failTaskID != 0) {
|
if (failTaskID != 0) {
|
||||||
MissionManager::quitTask(sock, missionData->iTaskNum, false);
|
Missions::quitTask(sock, missionData->iTaskNum, false);
|
||||||
|
|
||||||
for (int i = 0; i < 6; i++)
|
for (int i = 0; i < 6; i++)
|
||||||
if (plr->tasks[i] == missionData->iTaskNum)
|
if (plr->tasks[i] == missionData->iTaskNum)
|
||||||
@ -428,7 +428,7 @@ static void quitMission(CNSocket* sock, CNPacketData* data) {
|
|||||||
quitTask(sock, missionData->iTaskNum, true);
|
quitTask(sock, missionData->iTaskNum, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MissionManager::quitTask(CNSocket* sock, int32_t taskNum, bool manual) {
|
void Missions::quitTask(CNSocket* sock, int32_t taskNum, bool manual) {
|
||||||
Player* plr = PlayerManager::getPlayer(sock);
|
Player* plr = PlayerManager::getPlayer(sock);
|
||||||
|
|
||||||
if (Tasks.find(taskNum) == Tasks.end())
|
if (Tasks.find(taskNum) == Tasks.end())
|
||||||
@ -478,7 +478,7 @@ void MissionManager::quitTask(CNSocket* sock, int32_t taskNum, bool manual) {
|
|||||||
sock->sendPacket((void*)&response, P_FE2CL_REP_PC_TASK_STOP_SUCC, sizeof(sP_FE2CL_REP_PC_TASK_STOP_SUCC));
|
sock->sendPacket((void*)&response, P_FE2CL_REP_PC_TASK_STOP_SUCC, sizeof(sP_FE2CL_REP_PC_TASK_STOP_SUCC));
|
||||||
}
|
}
|
||||||
|
|
||||||
void MissionManager::updateFusionMatter(CNSocket* sock, int fusion) {
|
void Missions::updateFusionMatter(CNSocket* sock, int fusion) {
|
||||||
Player *plr = PlayerManager::getPlayer(sock);
|
Player *plr = PlayerManager::getPlayer(sock);
|
||||||
|
|
||||||
plr->fusionmatter += fusion;
|
plr->fusionmatter += fusion;
|
||||||
@ -521,7 +521,7 @@ void MissionManager::updateFusionMatter(CNSocket* sock, int fusion) {
|
|||||||
if (plr->level >= 36)
|
if (plr->level >= 36)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
plr->fusionmatter -= (int)MissionManager::AvatarGrowth[plr->level]["m_iReqBlob_NanoCreate"];
|
plr->fusionmatter -= (int)Missions::AvatarGrowth[plr->level]["m_iReqBlob_NanoCreate"];
|
||||||
plr->level++;
|
plr->level++;
|
||||||
|
|
||||||
INITSTRUCT(sP_FE2CL_REP_PC_CHANGE_LEVEL_SUCC, response);
|
INITSTRUCT(sP_FE2CL_REP_PC_CHANGE_LEVEL_SUCC, response);
|
||||||
@ -539,7 +539,7 @@ void MissionManager::updateFusionMatter(CNSocket* sock, int fusion) {
|
|||||||
PlayerManager::sendToViewable(sock, (void*)&bcast, P_FE2CL_PC_EVENT, sizeof(sP_FE2CL_PC_EVENT));
|
PlayerManager::sendToViewable(sock, (void*)&bcast, P_FE2CL_PC_EVENT, sizeof(sP_FE2CL_PC_EVENT));
|
||||||
}
|
}
|
||||||
|
|
||||||
void MissionManager::mobKilled(CNSocket *sock, int mobid, int rolledQItem) {
|
void Missions::mobKilled(CNSocket *sock, int mobid, int rolledQItem) {
|
||||||
Player *plr = PlayerManager::getPlayer(sock);
|
Player *plr = PlayerManager::getPlayer(sock);
|
||||||
|
|
||||||
bool missionmob = false;
|
bool missionmob = false;
|
||||||
@ -587,26 +587,26 @@ void MissionManager::mobKilled(CNSocket *sock, int mobid, int rolledQItem) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void MissionManager::failInstancedMissions(CNSocket* sock) {
|
void Missions::failInstancedMissions(CNSocket* sock) {
|
||||||
// loop through all tasks; if the required instance is being left, "fail" the task
|
// loop through all tasks; if the required instance is being left, "fail" the task
|
||||||
Player* plr = PlayerManager::getPlayer(sock);
|
Player* plr = PlayerManager::getPlayer(sock);
|
||||||
for (int i = 0; i < 6; i++) {
|
for (int i = 0; i < 6; i++) {
|
||||||
int taskNum = plr->tasks[i];
|
int taskNum = plr->tasks[i];
|
||||||
if (MissionManager::Tasks.find(taskNum) == MissionManager::Tasks.end())
|
if (Missions::Tasks.find(taskNum) == Missions::Tasks.end())
|
||||||
continue; // sanity check
|
continue; // sanity check
|
||||||
|
|
||||||
TaskData* task = MissionManager::Tasks[taskNum];
|
TaskData* task = Missions::Tasks[taskNum];
|
||||||
if (task->task["m_iRequireInstanceID"] != 0) { // mission is instanced
|
if (task->task["m_iRequireInstanceID"] != 0) { // mission is instanced
|
||||||
int failTaskID = task->task["m_iFOutgoingTask"];
|
int failTaskID = task->task["m_iFOutgoingTask"];
|
||||||
if (failTaskID != 0) {
|
if (failTaskID != 0) {
|
||||||
MissionManager::quitTask(sock, taskNum, false);
|
Missions::quitTask(sock, taskNum, false);
|
||||||
//plr->tasks[i] = failTaskID; // this causes the client to freak out and send a dupe task
|
//plr->tasks[i] = failTaskID; // this causes the client to freak out and send a dupe task
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void MissionManager::init() {
|
void Missions::init() {
|
||||||
REGISTER_SHARD_PACKET(P_CL2FE_REQ_PC_TASK_START, taskStart);
|
REGISTER_SHARD_PACKET(P_CL2FE_REQ_PC_TASK_START, taskStart);
|
||||||
REGISTER_SHARD_PACKET(P_CL2FE_REQ_PC_TASK_END, taskEnd);
|
REGISTER_SHARD_PACKET(P_CL2FE_REQ_PC_TASK_END, taskEnd);
|
||||||
REGISTER_SHARD_PACKET(P_CL2FE_REQ_PC_SET_CURRENT_MISSION_ID, setMission);
|
REGISTER_SHARD_PACKET(P_CL2FE_REQ_PC_SET_CURRENT_MISSION_ID, setMission);
|
@ -35,7 +35,7 @@ struct TaskData {
|
|||||||
auto operator[](std::string s) { return task[s]; }
|
auto operator[](std::string s) { return task[s]; }
|
||||||
};
|
};
|
||||||
|
|
||||||
namespace MissionManager {
|
namespace Missions {
|
||||||
extern std::map<int32_t, Reward*> Rewards;
|
extern std::map<int32_t, Reward*> Rewards;
|
||||||
extern std::map<int32_t, TaskData*> Tasks;
|
extern std::map<int32_t, TaskData*> Tasks;
|
||||||
extern nlohmann::json AvatarGrowth[37];
|
extern nlohmann::json AvatarGrowth[37];
|
@ -1,8 +1,8 @@
|
|||||||
#include "MobAI.hpp"
|
#include "MobAI.hpp"
|
||||||
#include "Player.hpp"
|
#include "Player.hpp"
|
||||||
#include "RacingManager.hpp"
|
#include "Racing.hpp"
|
||||||
#include "TransportManager.hpp"
|
#include "Transport.hpp"
|
||||||
#include "NanoManager.hpp"
|
#include "Nanos.hpp"
|
||||||
#include "Combat.hpp"
|
#include "Combat.hpp"
|
||||||
#include "Abilities.hpp"
|
#include "Abilities.hpp"
|
||||||
|
|
||||||
@ -19,7 +19,7 @@ bool MobAI::simulateMobs;
|
|||||||
static void roamingStep(Mob *mob, time_t currTime);
|
static void roamingStep(Mob *mob, time_t currTime);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Dynamic lerp; distinct from TransportManager::lerp(). This one doesn't care about height and
|
* Dynamic lerp; distinct from Transport::lerp(). This one doesn't care about height and
|
||||||
* only returns the first step, since the rest will need to be recalculated anyway if chasing player.
|
* only returns the first step, since the rest will need to be recalculated anyway if chasing player.
|
||||||
*/
|
*/
|
||||||
static std::pair<int,int> lerp(int x1, int y1, int x2, int y2, int speed) {
|
static std::pair<int,int> lerp(int x1, int y1, int x2, int y2, int speed) {
|
||||||
@ -130,7 +130,7 @@ bool MobAI::aggroCheck(Mob *mob, time_t currTime) {
|
|||||||
int mobRange = mob->sightRange;
|
int mobRange = mob->sightRange;
|
||||||
|
|
||||||
if (plr->iConditionBitFlag & CSB_BIT_UP_STEALTH
|
if (plr->iConditionBitFlag & CSB_BIT_UP_STEALTH
|
||||||
|| RacingManager::EPRaces.find(s) != RacingManager::EPRaces.end())
|
|| Racing::EPRaces.find(s) != Racing::EPRaces.end())
|
||||||
mobRange /= 3;
|
mobRange /= 3;
|
||||||
|
|
||||||
// 0.33x - 1.66x the range
|
// 0.33x - 1.66x the range
|
||||||
@ -223,10 +223,10 @@ static void dealCorruption(Mob *mob, std::vector<int> targetData, int skillID, i
|
|||||||
respdata[i].iActiveNanoSlotNum = n;
|
respdata[i].iActiveNanoSlotNum = n;
|
||||||
respdata[i].iNanoID = plr->activeNano;
|
respdata[i].iNanoID = plr->activeNano;
|
||||||
|
|
||||||
int style2 = NanoManager::nanoStyle(plr->activeNano);
|
int style2 = Nanos::nanoStyle(plr->activeNano);
|
||||||
if (style2 == -1) { // no nano
|
if (style2 == -1) { // no nano
|
||||||
respdata[i].iHitFlag = 8;
|
respdata[i].iHitFlag = 8;
|
||||||
respdata[i].iDamage = NanoManager::SkillTable[skillID].powerIntensity[0] * PC_MAXHEALTH((int)mob->data["m_iNpcLevel"]) / 1500;
|
respdata[i].iDamage = Nanos::SkillTable[skillID].powerIntensity[0] * PC_MAXHEALTH((int)mob->data["m_iNpcLevel"]) / 1500;
|
||||||
} else if (style == style2) {
|
} else if (style == style2) {
|
||||||
respdata[i].iHitFlag = 8; // tie
|
respdata[i].iHitFlag = 8; // tie
|
||||||
respdata[i].iDamage = 0;
|
respdata[i].iDamage = 0;
|
||||||
@ -239,12 +239,12 @@ static void dealCorruption(Mob *mob, std::vector<int> targetData, int skillID, i
|
|||||||
respdata[i].iNanoStamina = plr->Nanos[plr->activeNano].iStamina = 150;
|
respdata[i].iNanoStamina = plr->Nanos[plr->activeNano].iStamina = 150;
|
||||||
// fire damage power disguised as a corruption attack back at the enemy
|
// fire damage power disguised as a corruption attack back at the enemy
|
||||||
std::vector<int> targetData2 = {1, mob->appearanceData.iNPC_ID, 0, 0, 0};
|
std::vector<int> targetData2 = {1, mob->appearanceData.iNPC_ID, 0, 0, 0};
|
||||||
for (auto& pwr : NanoManager::NanoPowers)
|
for (auto& pwr : Nanos::NanoPowers)
|
||||||
if (pwr.skillType == EST_DAMAGE)
|
if (pwr.skillType == EST_DAMAGE)
|
||||||
pwr.handle(sock, targetData2, plr->activeNano, skillID, 0, 200);
|
pwr.handle(sock, targetData2, plr->activeNano, skillID, 0, 200);
|
||||||
} else {
|
} else {
|
||||||
respdata[i].iHitFlag = 16; // lose
|
respdata[i].iHitFlag = 16; // lose
|
||||||
respdata[i].iDamage = NanoManager::SkillTable[skillID].powerIntensity[0] * PC_MAXHEALTH((int)mob->data["m_iNpcLevel"]) / 1500;
|
respdata[i].iDamage = Nanos::SkillTable[skillID].powerIntensity[0] * PC_MAXHEALTH((int)mob->data["m_iNpcLevel"]) / 1500;
|
||||||
respdata[i].iNanoStamina = plr->Nanos[plr->activeNano].iStamina -= 90;
|
respdata[i].iNanoStamina = plr->Nanos[plr->activeNano].iStamina -= 90;
|
||||||
if (plr->Nanos[plr->activeNano].iStamina < 0) {
|
if (plr->Nanos[plr->activeNano].iStamina < 0) {
|
||||||
respdata[i].bNanoDeactive = 1;
|
respdata[i].bNanoDeactive = 1;
|
||||||
@ -305,7 +305,7 @@ static void useAbilities(Mob *mob, time_t currTime) {
|
|||||||
continue;
|
continue;
|
||||||
|
|
||||||
int distance = hypot(mob->hitX - plr->x, mob->hitY - plr->y);
|
int distance = hypot(mob->hitX - plr->x, mob->hitY - plr->y);
|
||||||
if (distance < NanoManager::SkillTable[skillID].effectArea) {
|
if (distance < Nanos::SkillTable[skillID].effectArea) {
|
||||||
targetData[0] += 1;
|
targetData[0] += 1;
|
||||||
targetData[targetData[0]] = plr->iID;
|
targetData[targetData[0]] = plr->iID;
|
||||||
if (targetData[0] > 3) // make sure not to have more than 4
|
if (targetData[0] > 3) // make sure not to have more than 4
|
||||||
@ -315,8 +315,8 @@ static void useAbilities(Mob *mob, time_t currTime) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (auto& pwr : Combat::MobPowers)
|
for (auto& pwr : Combat::MobPowers)
|
||||||
if (pwr.skillType == NanoManager::SkillTable[skillID].skillType)
|
if (pwr.skillType == Nanos::SkillTable[skillID].skillType)
|
||||||
pwr.handle(mob, targetData, skillID, NanoManager::SkillTable[skillID].durationTime[0], NanoManager::SkillTable[skillID].powerIntensity[0]);
|
pwr.handle(mob, targetData, skillID, Nanos::SkillTable[skillID].durationTime[0], Nanos::SkillTable[skillID].powerIntensity[0]);
|
||||||
mob->skillStyle = -3; // eruption cooldown
|
mob->skillStyle = -3; // eruption cooldown
|
||||||
mob->nextAttack = currTime + 1000;
|
mob->nextAttack = currTime + 1000;
|
||||||
return;
|
return;
|
||||||
@ -336,10 +336,10 @@ static void useAbilities(Mob *mob, time_t currTime) {
|
|||||||
int skillID = (int)mob->data["m_iActiveSkill1"];
|
int skillID = (int)mob->data["m_iActiveSkill1"];
|
||||||
std::vector<int> targetData = {1, plr->iID, 0, 0, 0};
|
std::vector<int> targetData = {1, plr->iID, 0, 0, 0};
|
||||||
for (auto& pwr : Combat::MobPowers)
|
for (auto& pwr : Combat::MobPowers)
|
||||||
if (pwr.skillType == NanoManager::SkillTable[skillID].skillType) {
|
if (pwr.skillType == Nanos::SkillTable[skillID].skillType) {
|
||||||
if (pwr.bitFlag != 0 && (plr->iConditionBitFlag & pwr.bitFlag))
|
if (pwr.bitFlag != 0 && (plr->iConditionBitFlag & pwr.bitFlag))
|
||||||
return; // prevent debuffing a player twice
|
return; // prevent debuffing a player twice
|
||||||
pwr.handle(mob, targetData, skillID, NanoManager::SkillTable[skillID].durationTime[0], NanoManager::SkillTable[skillID].powerIntensity[0]);
|
pwr.handle(mob, targetData, skillID, Nanos::SkillTable[skillID].durationTime[0], Nanos::SkillTable[skillID].powerIntensity[0]);
|
||||||
}
|
}
|
||||||
mob->nextAttack = currTime + (int)mob->data["m_iDelayTime"] * 100;
|
mob->nextAttack = currTime + (int)mob->data["m_iDelayTime"] * 100;
|
||||||
return;
|
return;
|
||||||
@ -353,7 +353,7 @@ static void useAbilities(Mob *mob, time_t currTime) {
|
|||||||
pkt.iValue1 = plr->x;
|
pkt.iValue1 = plr->x;
|
||||||
pkt.iValue2 = plr->y;
|
pkt.iValue2 = plr->y;
|
||||||
pkt.iValue3 = plr->z;
|
pkt.iValue3 = plr->z;
|
||||||
mob->skillStyle = NanoManager::nanoStyle(plr->activeNano) - 1;
|
mob->skillStyle = Nanos::nanoStyle(plr->activeNano) - 1;
|
||||||
if (mob->skillStyle == -1)
|
if (mob->skillStyle == -1)
|
||||||
mob->skillStyle = 2;
|
mob->skillStyle = 2;
|
||||||
if (mob->skillStyle == -2)
|
if (mob->skillStyle == -2)
|
||||||
@ -394,8 +394,8 @@ void MobAI::enterCombat(CNSocket *sock, Mob *mob) {
|
|||||||
int skillID = (int)mob->data["m_iPassiveBuff"]; // cast passive
|
int skillID = (int)mob->data["m_iPassiveBuff"]; // cast passive
|
||||||
std::vector<int> targetData = {1, mob->appearanceData.iNPC_ID, 0, 0, 0};
|
std::vector<int> targetData = {1, mob->appearanceData.iNPC_ID, 0, 0, 0};
|
||||||
for (auto& pwr : Combat::MobPowers)
|
for (auto& pwr : Combat::MobPowers)
|
||||||
if (pwr.skillType == NanoManager::SkillTable[skillID].skillType)
|
if (pwr.skillType == Nanos::SkillTable[skillID].skillType)
|
||||||
pwr.handle(mob, targetData, skillID, NanoManager::SkillTable[skillID].durationTime[0], NanoManager::SkillTable[skillID].powerIntensity[0]);
|
pwr.handle(mob, targetData, skillID, Nanos::SkillTable[skillID].durationTime[0], Nanos::SkillTable[skillID].powerIntensity[0]);
|
||||||
|
|
||||||
for (NPCEvent& event : NPCManager::NPCEvents) // trigger an ON_COMBAT
|
for (NPCEvent& event : NPCManager::NPCEvents) // trigger an ON_COMBAT
|
||||||
if (event.trigger == ON_COMBAT && event.npcType == mob->appearanceData.iNPCType)
|
if (event.trigger == ON_COMBAT && event.npcType == mob->appearanceData.iNPCType)
|
||||||
@ -652,7 +652,7 @@ static void roamingStep(Mob *mob, time_t currTime) {
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
* mob->nextMovement is also updated whenever the path queue is traversed in
|
* mob->nextMovement is also updated whenever the path queue is traversed in
|
||||||
* TransportManager::stepNPCPathing() (which ticks at a higher frequency than nextMovement),
|
* Transport::stepNPCPathing() (which ticks at a higher frequency than nextMovement),
|
||||||
* so we don't have to check if there's already entries in the queue since we know there won't be.
|
* so we don't have to check if there's already entries in the queue since we know there won't be.
|
||||||
*/
|
*/
|
||||||
if (mob->nextMovement != 0 && currTime < mob->nextMovement)
|
if (mob->nextMovement != 0 && currTime < mob->nextMovement)
|
||||||
@ -694,9 +694,9 @@ static void roamingStep(Mob *mob, time_t currTime) {
|
|||||||
WarpLocation from = { mob->appearanceData.iX, mob->appearanceData.iY, mob->appearanceData.iZ };
|
WarpLocation from = { mob->appearanceData.iX, mob->appearanceData.iY, mob->appearanceData.iZ };
|
||||||
WarpLocation to = { farX, farY, mob->appearanceData.iZ };
|
WarpLocation to = { farX, farY, mob->appearanceData.iZ };
|
||||||
|
|
||||||
// add a route to the queue; to be processed in TransportManager::stepNPCPathing()
|
// add a route to the queue; to be processed in Transport::stepNPCPathing()
|
||||||
TransportManager::lerp(&queue, from, to, speed);
|
Transport::lerp(&queue, from, to, speed);
|
||||||
TransportManager::NPCQueues[mob->appearanceData.iNPC_ID] = queue;
|
Transport::NPCQueues[mob->appearanceData.iNPC_ID] = queue;
|
||||||
|
|
||||||
if (mob->groupLeader != 0 && mob->groupLeader == mob->appearanceData.iNPC_ID) {
|
if (mob->groupLeader != 0 && mob->groupLeader == mob->appearanceData.iNPC_ID) {
|
||||||
// make followers follow this npc.
|
// make followers follow this npc.
|
||||||
@ -713,8 +713,8 @@ static void roamingStep(Mob *mob, time_t currTime) {
|
|||||||
Mob* followerMob = Mobs[mob->groupMember[i]];
|
Mob* followerMob = Mobs[mob->groupMember[i]];
|
||||||
from = { followerMob->appearanceData.iX, followerMob->appearanceData.iY, followerMob->appearanceData.iZ };
|
from = { followerMob->appearanceData.iX, followerMob->appearanceData.iY, followerMob->appearanceData.iZ };
|
||||||
to = { farX + followerMob->offsetX, farY + followerMob->offsetY, followerMob->appearanceData.iZ };
|
to = { farX + followerMob->offsetX, farY + followerMob->offsetY, followerMob->appearanceData.iZ };
|
||||||
TransportManager::lerp(&queue2, from, to, speed);
|
Transport::lerp(&queue2, from, to, speed);
|
||||||
TransportManager::NPCQueues[followerMob->appearanceData.iNPC_ID] = queue2;
|
Transport::NPCQueues[followerMob->appearanceData.iNPC_ID] = queue2;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -757,8 +757,8 @@ static void retreatStep(Mob *mob, time_t currTime) {
|
|||||||
// cast a return home heal spell, this is the right way(tm)
|
// cast a return home heal spell, this is the right way(tm)
|
||||||
std::vector<int> targetData = {1, 0, 0, 0, 0};
|
std::vector<int> targetData = {1, 0, 0, 0, 0};
|
||||||
for (auto& pwr : Combat::MobPowers)
|
for (auto& pwr : Combat::MobPowers)
|
||||||
if (pwr.skillType == NanoManager::SkillTable[110].skillType)
|
if (pwr.skillType == Nanos::SkillTable[110].skillType)
|
||||||
pwr.handle(mob, targetData, 110, NanoManager::SkillTable[110].durationTime[0], NanoManager::SkillTable[110].powerIntensity[0]);
|
pwr.handle(mob, targetData, 110, Nanos::SkillTable[110].durationTime[0], Nanos::SkillTable[110].powerIntensity[0]);
|
||||||
// clear outlying debuffs
|
// clear outlying debuffs
|
||||||
clearDebuff(mob);
|
clearDebuff(mob);
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
#include "CNShardServer.hpp"
|
#include "CNShardServer.hpp"
|
||||||
#include "PlayerManager.hpp"
|
#include "PlayerManager.hpp"
|
||||||
#include "ChatManager.hpp"
|
#include "Chat.hpp"
|
||||||
#include "CNStructs.hpp"
|
#include "CNStructs.hpp"
|
||||||
#include "Monitor.hpp"
|
#include "Monitor.hpp"
|
||||||
#include "settings.hpp"
|
#include "settings.hpp"
|
||||||
@ -64,7 +64,7 @@ outer:
|
|||||||
}
|
}
|
||||||
|
|
||||||
// chat
|
// chat
|
||||||
for (auto& str : ChatManager::dump) {
|
for (auto& str : Chat::dump) {
|
||||||
n = std::snprintf(buff, sizeof(buff), "chat %s\n", str.c_str());
|
n = std::snprintf(buff, sizeof(buff), "chat %s\n", str.c_str());
|
||||||
|
|
||||||
if (!transmit(it, buff, n))
|
if (!transmit(it, buff, n))
|
||||||
@ -77,7 +77,7 @@ outer:
|
|||||||
it++;
|
it++;
|
||||||
}
|
}
|
||||||
|
|
||||||
ChatManager::dump.clear();
|
Chat::dump.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Monitor::acceptConnection(SOCKET fd, uint16_t revents) {
|
bool Monitor::acceptConnection(SOCKET fd, uint16_t revents) {
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "CNStructs.hpp"
|
#include "CNStructs.hpp"
|
||||||
#include "ChunkManager.hpp"
|
#include "Chunking.hpp"
|
||||||
|
|
||||||
class BaseNPC {
|
class BaseNPC {
|
||||||
public:
|
public:
|
||||||
|
@ -1,13 +1,13 @@
|
|||||||
#include "NPCManager.hpp"
|
#include "NPCManager.hpp"
|
||||||
#include "ItemManager.hpp"
|
#include "Items.hpp"
|
||||||
#include "settings.hpp"
|
#include "settings.hpp"
|
||||||
#include "Combat.hpp"
|
#include "Combat.hpp"
|
||||||
#include "MissionManager.hpp"
|
#include "Missions.hpp"
|
||||||
#include "ChunkManager.hpp"
|
#include "Chunking.hpp"
|
||||||
#include "NanoManager.hpp"
|
#include "Nanos.hpp"
|
||||||
#include "TableData.hpp"
|
#include "TableData.hpp"
|
||||||
#include "GroupManager.hpp"
|
#include "Groups.hpp"
|
||||||
#include "RacingManager.hpp"
|
#include "Racing.hpp"
|
||||||
#include "Vendor.hpp"
|
#include "Vendor.hpp"
|
||||||
#include "Abilities.hpp"
|
#include "Abilities.hpp"
|
||||||
|
|
||||||
@ -49,16 +49,16 @@ void NPCManager::destroyNPC(int32_t id) {
|
|||||||
BaseNPC* entity = NPCs[id];
|
BaseNPC* entity = NPCs[id];
|
||||||
|
|
||||||
// sanity check
|
// sanity check
|
||||||
if (!ChunkManager::chunkExists(entity->chunkPos)) {
|
if (!Chunking::chunkExists(entity->chunkPos)) {
|
||||||
std::cout << "chunk not found!" << std::endl;
|
std::cout << "chunk not found!" << std::endl;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// remove NPC from the chunk
|
// remove NPC from the chunk
|
||||||
ChunkManager::untrackNPC(entity->chunkPos, id);
|
Chunking::untrackNPC(entity->chunkPos, id);
|
||||||
|
|
||||||
// remove from viewable chunks
|
// remove from viewable chunks
|
||||||
ChunkManager::removeNPCFromChunks(ChunkManager::getViewableChunks(entity->chunkPos), id);
|
Chunking::removeNPCFromChunks(Chunking::getViewableChunks(entity->chunkPos), id);
|
||||||
|
|
||||||
// remove from mob manager
|
// remove from mob manager
|
||||||
if (MobAI::Mobs.find(id) != MobAI::Mobs.end())
|
if (MobAI::Mobs.find(id) != MobAI::Mobs.end())
|
||||||
@ -78,14 +78,14 @@ void NPCManager::updateNPCPosition(int32_t id, int X, int Y, int Z, uint64_t I,
|
|||||||
BaseNPC* npc = NPCs[id];
|
BaseNPC* npc = NPCs[id];
|
||||||
npc->appearanceData.iAngle = angle;
|
npc->appearanceData.iAngle = angle;
|
||||||
ChunkPos oldChunk = npc->chunkPos;
|
ChunkPos oldChunk = npc->chunkPos;
|
||||||
ChunkPos newChunk = ChunkManager::chunkPosAt(X, Y, I);
|
ChunkPos newChunk = Chunking::chunkPosAt(X, Y, I);
|
||||||
npc->appearanceData.iX = X;
|
npc->appearanceData.iX = X;
|
||||||
npc->appearanceData.iY = Y;
|
npc->appearanceData.iY = Y;
|
||||||
npc->appearanceData.iZ = Z;
|
npc->appearanceData.iZ = Z;
|
||||||
npc->instanceID = I;
|
npc->instanceID = I;
|
||||||
if (oldChunk == newChunk)
|
if (oldChunk == newChunk)
|
||||||
return; // didn't change chunks
|
return; // didn't change chunks
|
||||||
ChunkManager::updateNPCChunk(id, oldChunk, newChunk);
|
Chunking::updateNPCChunk(id, oldChunk, newChunk);
|
||||||
}
|
}
|
||||||
|
|
||||||
void NPCManager::sendToViewable(BaseNPC *npc, void *buf, uint32_t type, size_t size) {
|
void NPCManager::sendToViewable(BaseNPC *npc, void *buf, uint32_t type, size_t size) {
|
||||||
@ -104,7 +104,7 @@ static void npcBarkHandler(CNSocket* sock, CNPacketData* data) {
|
|||||||
sP_CL2FE_REQ_BARKER* req = (sP_CL2FE_REQ_BARKER*)data->buf;
|
sP_CL2FE_REQ_BARKER* req = (sP_CL2FE_REQ_BARKER*)data->buf;
|
||||||
|
|
||||||
// get bark IDs from task data
|
// get bark IDs from task data
|
||||||
TaskData* td = MissionManager::Tasks[req->iMissionTaskID];
|
TaskData* td = Missions::Tasks[req->iMissionTaskID];
|
||||||
std::vector<int> barks;
|
std::vector<int> barks;
|
||||||
for (int i = 0; i < 4; i++) {
|
for (int i = 0; i < 4; i++) {
|
||||||
if (td->task["m_iHBarkerTextID"][i] != 0) // non-zeroes only
|
if (td->task["m_iHBarkerTextID"][i] != 0) // non-zeroes only
|
||||||
@ -204,7 +204,7 @@ static void handleWarp(CNSocket* sock, int32_t warpId) {
|
|||||||
// if warp requires you to be on a mission, it's gotta be a unique instance
|
// if warp requires you to be on a mission, it's gotta be a unique instance
|
||||||
if (Warps[warpId].limitTaskID != 0 || instanceID == 14) { // 14 is a special case for the Time Lab
|
if (Warps[warpId].limitTaskID != 0 || instanceID == 14) { // 14 is a special case for the Time Lab
|
||||||
instanceID += ((uint64_t)plr->iIDGroup << 32); // upper 32 bits are leader ID
|
instanceID += ((uint64_t)plr->iIDGroup << 32); // upper 32 bits are leader ID
|
||||||
ChunkManager::createInstance(instanceID);
|
Chunking::createInstance(instanceID);
|
||||||
|
|
||||||
// save Lair entrance coords as a pseudo-Resurrect 'Em
|
// save Lair entrance coords as a pseudo-Resurrect 'Em
|
||||||
plr->recallX = Warps[warpId].x;
|
plr->recallX = Warps[warpId].x;
|
||||||
@ -261,18 +261,18 @@ static void handleWarp(CNSocket* sock, int32_t warpId) {
|
|||||||
resp.eIL = 4; // do not take away any items
|
resp.eIL = 4; // do not take away any items
|
||||||
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;
|
||||||
MissionManager::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((void*)&resp, P_FE2CL_REP_PC_WARP_USE_NPC_SUCC, sizeof(sP_FE2CL_REP_PC_WARP_USE_NPC_SUCC));
|
||||||
|
|
||||||
ChunkManager::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);
|
||||||
|
|
||||||
// remove the player's ongoing race, if any
|
// remove the player's ongoing race, if any
|
||||||
if (RacingManager::EPRaces.find(sock) != RacingManager::EPRaces.end())
|
if (Racing::EPRaces.find(sock) != Racing::EPRaces.end())
|
||||||
RacingManager::EPRaces.erase(sock);
|
Racing::EPRaces.erase(sock);
|
||||||
|
|
||||||
// post-warp: check if the source instance has no more players in it and delete it if so
|
// post-warp: check if the source instance has no more players in it and delete it if so
|
||||||
ChunkManager::destroyInstanceIfEmpty(fromInstance);
|
Chunking::destroyInstanceIfEmpty(fromInstance);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -316,8 +316,8 @@ int NPCManager::eggBuffPlayer(CNSocket* sock, int skillId, int eggId, int durati
|
|||||||
Player* plr = PlayerManager::getPlayer(sock);
|
Player* plr = PlayerManager::getPlayer(sock);
|
||||||
Player* otherPlr = PlayerManager::getPlayerFromID(plr->iIDGroup);
|
Player* otherPlr = PlayerManager::getPlayerFromID(plr->iIDGroup);
|
||||||
|
|
||||||
int bitFlag = GroupManager::getGroupFlags(otherPlr);
|
int bitFlag = Groups::getGroupFlags(otherPlr);
|
||||||
int CBFlag = NanoManager::applyBuff(sock, skillId, 1, 3, bitFlag);
|
int CBFlag = Nanos::applyBuff(sock, skillId, 1, 3, bitFlag);
|
||||||
|
|
||||||
size_t resplen;
|
size_t resplen;
|
||||||
|
|
||||||
@ -339,7 +339,7 @@ int NPCManager::eggBuffPlayer(CNSocket* sock, int skillId, int eggId, int durati
|
|||||||
memset(respbuf, 0, resplen);
|
memset(respbuf, 0, resplen);
|
||||||
skill->eCT = 1;
|
skill->eCT = 1;
|
||||||
skill->iID = plr->iID;
|
skill->iID = plr->iID;
|
||||||
skill->iDamage = PC_MAXHEALTH(plr->level) * NanoManager::SkillTable[skillId].powerIntensity[0] / 1000;
|
skill->iDamage = PC_MAXHEALTH(plr->level) * Nanos::SkillTable[skillId].powerIntensity[0] / 1000;
|
||||||
plr->HP -= skill->iDamage;
|
plr->HP -= skill->iDamage;
|
||||||
if (plr->HP < 0)
|
if (plr->HP < 0)
|
||||||
plr->HP = 0;
|
plr->HP = 0;
|
||||||
@ -349,7 +349,7 @@ int NPCManager::eggBuffPlayer(CNSocket* sock, int skillId, int eggId, int durati
|
|||||||
memset(respbuf, 0, resplen);
|
memset(respbuf, 0, resplen);
|
||||||
skill->eCT = 1;
|
skill->eCT = 1;
|
||||||
skill->iID = plr->iID;
|
skill->iID = plr->iID;
|
||||||
skill->iHealHP = PC_MAXHEALTH(plr->level) * NanoManager::SkillTable[skillId].powerIntensity[0] / 1000;
|
skill->iHealHP = PC_MAXHEALTH(plr->level) * Nanos::SkillTable[skillId].powerIntensity[0] / 1000;
|
||||||
plr->HP += skill->iHealHP;
|
plr->HP += skill->iHealHP;
|
||||||
if (plr->HP > PC_MAXHEALTH(plr->level))
|
if (plr->HP > PC_MAXHEALTH(plr->level))
|
||||||
plr->HP = PC_MAXHEALTH(plr->level);
|
plr->HP = PC_MAXHEALTH(plr->level);
|
||||||
@ -364,7 +364,7 @@ int NPCManager::eggBuffPlayer(CNSocket* sock, int skillId, int eggId, int durati
|
|||||||
|
|
||||||
skillUse->iNPC_ID = eggId;
|
skillUse->iNPC_ID = eggId;
|
||||||
skillUse->iSkillID = skillId;
|
skillUse->iSkillID = skillId;
|
||||||
skillUse->eST = NanoManager::SkillTable[skillId].skillType;
|
skillUse->eST = Nanos::SkillTable[skillId].skillType;
|
||||||
skillUse->iTargetCnt = 1;
|
skillUse->iTargetCnt = 1;
|
||||||
|
|
||||||
sock->sendPacket((void*)&respbuf, P_FE2CL_NPC_SKILL_HIT, resplen);
|
sock->sendPacket((void*)&respbuf, P_FE2CL_NPC_SKILL_HIT, resplen);
|
||||||
@ -397,8 +397,8 @@ static void eggStep(CNServer* serv, time_t currTime) {
|
|||||||
Player* plr = PlayerManager::getPlayer(sock);
|
Player* plr = PlayerManager::getPlayer(sock);
|
||||||
Player* otherPlr = PlayerManager::getPlayerFromID(plr->iIDGroup);
|
Player* otherPlr = PlayerManager::getPlayerFromID(plr->iIDGroup);
|
||||||
|
|
||||||
int groupFlags = GroupManager::getGroupFlags(otherPlr);
|
int groupFlags = Groups::getGroupFlags(otherPlr);
|
||||||
for (auto& pwr : NanoManager::NanoPowers) {
|
for (auto& pwr : Nanos::NanoPowers) {
|
||||||
if (pwr.bitFlag == CBFlag) { // pick the power with the right flag and unbuff
|
if (pwr.bitFlag == CBFlag) { // pick the power with the right flag and unbuff
|
||||||
INITSTRUCT(sP_FE2CL_PC_BUFF_UPDATE, resp);
|
INITSTRUCT(sP_FE2CL_PC_BUFF_UPDATE, resp);
|
||||||
resp.eCSTB = pwr.timeBuffID;
|
resp.eCSTB = pwr.timeBuffID;
|
||||||
@ -422,7 +422,7 @@ static void eggStep(CNServer* serv, time_t currTime) {
|
|||||||
|
|
||||||
// check dead eggs and eggs in inactive chunks
|
// check dead eggs and eggs in inactive chunks
|
||||||
for (auto egg : Eggs) {
|
for (auto egg : Eggs) {
|
||||||
if (!egg.second->dead || !ChunkManager::inPopulatedChunks(egg.second->viewableChunks))
|
if (!egg.second->dead || !Chunking::inPopulatedChunks(egg.second->viewableChunks))
|
||||||
continue;
|
continue;
|
||||||
if (egg.second->deadUntil <= timeStamp) {
|
if (egg.second->deadUntil <= timeStamp) {
|
||||||
// respawn it
|
// respawn it
|
||||||
@ -430,7 +430,7 @@ static void eggStep(CNServer* serv, time_t currTime) {
|
|||||||
egg.second->deadUntil = 0;
|
egg.second->deadUntil = 0;
|
||||||
egg.second->appearanceData.iHP = 400;
|
egg.second->appearanceData.iHP = 400;
|
||||||
|
|
||||||
ChunkManager::addNPCToChunks(ChunkManager::getViewableChunks(egg.second->chunkPos), egg.first);
|
Chunking::addNPCToChunks(Chunking::getViewableChunks(egg.second->chunkPos), egg.first);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -525,7 +525,7 @@ static void eggPickup(CNSocket* sock, CNPacketData* data) {
|
|||||||
reward->iFatigue_Level = 1;
|
reward->iFatigue_Level = 1;
|
||||||
reward->iItemCnt = 1; // remember to update resplen if you change this
|
reward->iItemCnt = 1; // remember to update resplen if you change this
|
||||||
|
|
||||||
int slot = ItemManager::findFreeSlot(plr);
|
int slot = Items::findFreeSlot(plr);
|
||||||
|
|
||||||
// no space for drop
|
// no space for drop
|
||||||
if (slot != -1) {
|
if (slot != -1) {
|
||||||
@ -546,7 +546,7 @@ static void eggPickup(CNSocket* sock, CNPacketData* data) {
|
|||||||
if (egg->summoned)
|
if (egg->summoned)
|
||||||
destroyNPC(eggId);
|
destroyNPC(eggId);
|
||||||
else {
|
else {
|
||||||
ChunkManager::removeNPCFromChunks(ChunkManager::getViewableChunks(egg->chunkPos), eggId);
|
Chunking::removeNPCFromChunks(Chunking::getViewableChunks(egg->chunkPos), eggId);
|
||||||
egg->dead = true;
|
egg->dead = true;
|
||||||
egg->deadUntil = getTime() + (time_t)type->regen * 1000;
|
egg->deadUntil = getTime() + (time_t)type->regen * 1000;
|
||||||
egg->appearanceData.iHP = 0;
|
egg->appearanceData.iHP = 0;
|
||||||
|
@ -1,22 +1,22 @@
|
|||||||
#include "CNShardServer.hpp"
|
#include "CNShardServer.hpp"
|
||||||
#include "CNStructs.hpp"
|
#include "CNStructs.hpp"
|
||||||
#include "NanoManager.hpp"
|
#include "Nanos.hpp"
|
||||||
#include "PlayerManager.hpp"
|
#include "PlayerManager.hpp"
|
||||||
#include "NPCManager.hpp"
|
#include "NPCManager.hpp"
|
||||||
#include "Combat.hpp"
|
#include "Combat.hpp"
|
||||||
#include "MissionManager.hpp"
|
#include "Missions.hpp"
|
||||||
#include "GroupManager.hpp"
|
#include "Groups.hpp"
|
||||||
#include "Abilities.hpp"
|
#include "Abilities.hpp"
|
||||||
|
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
|
|
||||||
using namespace NanoManager;
|
using namespace Nanos;
|
||||||
|
|
||||||
std::map<int32_t, NanoData> NanoManager::NanoTable;
|
std::map<int32_t, NanoData> Nanos::NanoTable;
|
||||||
std::map<int32_t, NanoTuning> NanoManager::NanoTunings;
|
std::map<int32_t, NanoTuning> Nanos::NanoTunings;
|
||||||
|
|
||||||
#pragma region Helper methods
|
#pragma region Helper methods
|
||||||
void NanoManager::addNano(CNSocket* sock, int16_t nanoID, int16_t slot, bool spendfm) {
|
void Nanos::addNano(CNSocket* sock, int16_t nanoID, int16_t slot, bool spendfm) {
|
||||||
if (nanoID <= 0 || nanoID >= NANO_COUNT)
|
if (nanoID <= 0 || nanoID >= NANO_COUNT)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@ -35,7 +35,7 @@ void NanoManager::addNano(CNSocket* sock, int16_t nanoID, int16_t slot, bool spe
|
|||||||
plr->level = level;
|
plr->level = level;
|
||||||
|
|
||||||
if (spendfm)
|
if (spendfm)
|
||||||
MissionManager::updateFusionMatter(sock, -(int)MissionManager::AvatarGrowth[plr->level-1]["m_iReqBlob_NanoCreate"]);
|
Missions::updateFusionMatter(sock, -(int)Missions::AvatarGrowth[plr->level-1]["m_iReqBlob_NanoCreate"]);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Send to client
|
// Send to client
|
||||||
@ -70,7 +70,7 @@ void NanoManager::addNano(CNSocket* sock, int16_t nanoID, int16_t slot, bool spe
|
|||||||
PlayerManager::sendToViewable(sock, (void*)&resp2, P_FE2CL_REP_PC_CHANGE_LEVEL, sizeof(sP_FE2CL_REP_PC_CHANGE_LEVEL));
|
PlayerManager::sendToViewable(sock, (void*)&resp2, P_FE2CL_REP_PC_CHANGE_LEVEL, sizeof(sP_FE2CL_REP_PC_CHANGE_LEVEL));
|
||||||
}
|
}
|
||||||
|
|
||||||
void NanoManager::summonNano(CNSocket *sock, int slot, bool silent) {
|
void Nanos::summonNano(CNSocket *sock, int slot, bool silent) {
|
||||||
INITSTRUCT(sP_FE2CL_REP_NANO_ACTIVE_SUCC, resp);
|
INITSTRUCT(sP_FE2CL_REP_NANO_ACTIVE_SUCC, resp);
|
||||||
resp.iActiveNanoSlotNum = slot;
|
resp.iActiveNanoSlotNum = slot;
|
||||||
Player *plr = PlayerManager::getPlayer(sock);
|
Player *plr = PlayerManager::getPlayer(sock);
|
||||||
@ -159,11 +159,11 @@ static void setNanoSkill(CNSocket* sock, sP_CL2FE_REQ_NANO_TUNE* skill) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#ifndef ACADEMY
|
#ifndef ACADEMY
|
||||||
if (plr->fusionmatter < (int)MissionManager::AvatarGrowth[plr->level]["m_iReqBlob_NanoTune"]) // sanity check
|
if (plr->fusionmatter < (int)Missions::AvatarGrowth[plr->level]["m_iReqBlob_NanoTune"]) // sanity check
|
||||||
return;
|
return;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
plr->fusionmatter -= (int)MissionManager::AvatarGrowth[plr->level]["m_iReqBlob_NanoTune"];
|
plr->fusionmatter -= (int)Missions::AvatarGrowth[plr->level]["m_iReqBlob_NanoTune"];
|
||||||
|
|
||||||
int reqItemCount = NanoTunings[skill->iTuneID].reqItemCount;
|
int reqItemCount = NanoTunings[skill->iTuneID].reqItemCount;
|
||||||
int reqItemID = NanoTunings[skill->iTuneID].reqItems;
|
int reqItemID = NanoTunings[skill->iTuneID].reqItems;
|
||||||
@ -203,13 +203,13 @@ static void setNanoSkill(CNSocket* sock, sP_CL2FE_REQ_NANO_TUNE* skill) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 0=A 1=B 2=C -1=Not found
|
// 0=A 1=B 2=C -1=Not found
|
||||||
int NanoManager::nanoStyle(int nanoID) {
|
int Nanos::nanoStyle(int nanoID) {
|
||||||
if (nanoID < 1 || nanoID >= (int)NanoTable.size())
|
if (nanoID < 1 || nanoID >= (int)NanoTable.size())
|
||||||
return -1;
|
return -1;
|
||||||
return NanoTable[nanoID].style;
|
return NanoTable[nanoID].style;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool NanoManager::getNanoBoost(Player* plr) {
|
bool Nanos::getNanoBoost(Player* plr) {
|
||||||
for (int i = 0; i < 3; i++)
|
for (int i = 0; i < 3; i++)
|
||||||
if (plr->equippedNanos[i] == plr->activeNano)
|
if (plr->equippedNanos[i] == plr->activeNano)
|
||||||
if (plr->iConditionBitFlag & (CSB_BIT_STIMPAKSLOT1 << i))
|
if (plr->iConditionBitFlag & (CSB_BIT_STIMPAKSLOT1 << i))
|
||||||
@ -431,7 +431,7 @@ static void nanoPotionHandler(CNSocket* sock, CNPacketData* data) {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void NanoManager::init() {
|
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);
|
@ -15,7 +15,7 @@ struct NanoTuning {
|
|||||||
int reqItems;
|
int reqItems;
|
||||||
};
|
};
|
||||||
|
|
||||||
namespace NanoManager {
|
namespace Nanos {
|
||||||
extern std::map<int32_t, NanoData> NanoTable;
|
extern std::map<int32_t, NanoData> NanoTable;
|
||||||
extern std::map<int32_t, NanoTuning> NanoTunings;
|
extern std::map<int32_t, NanoTuning> NanoTunings;
|
||||||
void init();
|
void init();
|
@ -5,7 +5,7 @@
|
|||||||
|
|
||||||
#include "CNProtocol.hpp"
|
#include "CNProtocol.hpp"
|
||||||
#include "CNStructs.hpp"
|
#include "CNStructs.hpp"
|
||||||
#include "ChunkManager.hpp"
|
#include "Chunking.hpp"
|
||||||
|
|
||||||
#define ACTIVE_MISSION_COUNT 6
|
#define ACTIVE_MISSION_COUNT 6
|
||||||
|
|
||||||
|
@ -1,15 +1,15 @@
|
|||||||
#include "PlayerManager.hpp"
|
#include "PlayerManager.hpp"
|
||||||
#include "NPCManager.hpp"
|
#include "NPCManager.hpp"
|
||||||
#include "CNShardServer.hpp"
|
#include "CNShardServer.hpp"
|
||||||
#include "MissionManager.hpp"
|
#include "Missions.hpp"
|
||||||
#include "ItemManager.hpp"
|
#include "Items.hpp"
|
||||||
#include "NanoManager.hpp"
|
#include "Nanos.hpp"
|
||||||
#include "GroupManager.hpp"
|
#include "Groups.hpp"
|
||||||
#include "ChatManager.hpp"
|
#include "Chat.hpp"
|
||||||
#include "db/Database.hpp"
|
#include "db/Database.hpp"
|
||||||
#include "BuddyManager.hpp"
|
#include "Buddies.hpp"
|
||||||
#include "Combat.hpp"
|
#include "Combat.hpp"
|
||||||
#include "RacingManager.hpp"
|
#include "Racing.hpp"
|
||||||
#include "BuiltinCommands.hpp"
|
#include "BuiltinCommands.hpp"
|
||||||
#include "Abilities.hpp"
|
#include "Abilities.hpp"
|
||||||
|
|
||||||
@ -44,20 +44,20 @@ void PlayerManager::removePlayer(CNSocket* key) {
|
|||||||
Player* plr = getPlayer(key);
|
Player* plr = getPlayer(key);
|
||||||
uint64_t fromInstance = plr->instanceID;
|
uint64_t fromInstance = plr->instanceID;
|
||||||
|
|
||||||
GroupManager::groupKickPlayer(plr);
|
Groups::groupKickPlayer(plr);
|
||||||
|
|
||||||
// remove player's bullets
|
// remove player's bullets
|
||||||
Combat::Bullets.erase(plr->iID);
|
Combat::Bullets.erase(plr->iID);
|
||||||
|
|
||||||
// remove player's ongoing race, if it exists
|
// remove player's ongoing race, if it exists
|
||||||
RacingManager::EPRaces.erase(key);
|
Racing::EPRaces.erase(key);
|
||||||
|
|
||||||
// save player to DB
|
// save player to DB
|
||||||
Database::updatePlayer(plr);
|
Database::updatePlayer(plr);
|
||||||
|
|
||||||
// remove player visually and untrack
|
// remove player visually and untrack
|
||||||
ChunkManager::removePlayerFromChunks(ChunkManager::getViewableChunks(plr->chunkPos), key);
|
Chunking::removePlayerFromChunks(Chunking::getViewableChunks(plr->chunkPos), key);
|
||||||
ChunkManager::untrackPlayer(plr->chunkPos, key);
|
Chunking::untrackPlayer(plr->chunkPos, key);
|
||||||
|
|
||||||
std::cout << getPlayerName(plr) << " has left!" << std::endl;
|
std::cout << getPlayerName(plr) << " has left!" << std::endl;
|
||||||
|
|
||||||
@ -67,7 +67,7 @@ void PlayerManager::removePlayer(CNSocket* key) {
|
|||||||
players.erase(key);
|
players.erase(key);
|
||||||
|
|
||||||
// if the player was in a lair, clean it up
|
// if the player was in a lair, clean it up
|
||||||
ChunkManager::destroyInstanceIfEmpty(fromInstance);
|
Chunking::destroyInstanceIfEmpty(fromInstance);
|
||||||
|
|
||||||
// remove player's buffs from the server
|
// remove player's buffs from the server
|
||||||
auto it = NPCManager::EggBuffs.begin();
|
auto it = NPCManager::EggBuffs.begin();
|
||||||
@ -86,14 +86,14 @@ void PlayerManager::updatePlayerPosition(CNSocket* sock, int X, int Y, int Z, ui
|
|||||||
Player* plr = getPlayer(sock);
|
Player* plr = getPlayer(sock);
|
||||||
plr->angle = angle;
|
plr->angle = angle;
|
||||||
ChunkPos oldChunk = plr->chunkPos;
|
ChunkPos oldChunk = plr->chunkPos;
|
||||||
ChunkPos newChunk = ChunkManager::chunkPosAt(X, Y, I);
|
ChunkPos newChunk = Chunking::chunkPosAt(X, Y, I);
|
||||||
plr->x = X;
|
plr->x = X;
|
||||||
plr->y = Y;
|
plr->y = Y;
|
||||||
plr->z = Z;
|
plr->z = Z;
|
||||||
plr->instanceID = I;
|
plr->instanceID = I;
|
||||||
if (oldChunk == newChunk)
|
if (oldChunk == newChunk)
|
||||||
return; // didn't change chunks
|
return; // didn't change chunks
|
||||||
ChunkManager::updatePlayerChunk(sock, oldChunk, newChunk);
|
Chunking::updatePlayerChunk(sock, oldChunk, newChunk);
|
||||||
}
|
}
|
||||||
|
|
||||||
void PlayerManager::sendPlayerTo(CNSocket* sock, int X, int Y, int Z, uint64_t I) {
|
void PlayerManager::sendPlayerTo(CNSocket* sock, int X, int Y, int Z, uint64_t I) {
|
||||||
@ -108,7 +108,7 @@ void PlayerManager::sendPlayerTo(CNSocket* sock, int X, int Y, int Z, uint64_t I
|
|||||||
plr->lastAngle = plr->angle;
|
plr->lastAngle = plr->angle;
|
||||||
}
|
}
|
||||||
|
|
||||||
MissionManager::failInstancedMissions(sock); // fail any instanced missions
|
Missions::failInstancedMissions(sock); // fail any instanced missions
|
||||||
|
|
||||||
uint64_t fromInstance = plr->instanceID; // pre-warp instance, saved for post-warp
|
uint64_t fromInstance = plr->instanceID; // pre-warp instance, saved for post-warp
|
||||||
|
|
||||||
@ -127,8 +127,8 @@ void PlayerManager::sendPlayerTo(CNSocket* sock, int X, int Y, int Z, uint64_t I
|
|||||||
INITSTRUCT(sP_FE2CL_INSTANCE_MAP_INFO, pkt);
|
INITSTRUCT(sP_FE2CL_INSTANCE_MAP_INFO, pkt);
|
||||||
pkt.iInstanceMapNum = (int32_t)MAPNUM(I); // lower 32 bits are mapnum
|
pkt.iInstanceMapNum = (int32_t)MAPNUM(I); // lower 32 bits are mapnum
|
||||||
if (I != fromInstance // do not retransmit MAP_INFO on recall
|
if (I != fromInstance // do not retransmit MAP_INFO on recall
|
||||||
&& RacingManager::EPData.find(pkt.iInstanceMapNum) != RacingManager::EPData.end()) {
|
&& Racing::EPData.find(pkt.iInstanceMapNum) != Racing::EPData.end()) {
|
||||||
EPInfo* ep = &RacingManager::EPData[pkt.iInstanceMapNum];
|
EPInfo* ep = &Racing::EPData[pkt.iInstanceMapNum];
|
||||||
pkt.iEP_ID = ep->EPID;
|
pkt.iEP_ID = ep->EPID;
|
||||||
pkt.iMapCoordX_Min = ep->zoneX * 51200;
|
pkt.iMapCoordX_Min = ep->zoneX * 51200;
|
||||||
pkt.iMapCoordX_Max = (ep->zoneX + 1) * 51200;
|
pkt.iMapCoordX_Max = (ep->zoneX + 1) * 51200;
|
||||||
@ -146,16 +146,16 @@ void PlayerManager::sendPlayerTo(CNSocket* sock, int X, int Y, int Z, uint64_t I
|
|||||||
pkt2.iY = Y;
|
pkt2.iY = Y;
|
||||||
pkt2.iZ = Z;
|
pkt2.iZ = Z;
|
||||||
sock->sendPacket((void*)&pkt2, P_FE2CL_REP_PC_GOTO_SUCC, sizeof(sP_FE2CL_REP_PC_GOTO_SUCC));
|
sock->sendPacket((void*)&pkt2, P_FE2CL_REP_PC_GOTO_SUCC, sizeof(sP_FE2CL_REP_PC_GOTO_SUCC));
|
||||||
ChunkManager::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
|
||||||
updatePlayerPosition(sock, X, Y, Z, I, plr->angle);
|
updatePlayerPosition(sock, X, Y, Z, I, plr->angle);
|
||||||
|
|
||||||
// post-warp: check if the source instance has no more players in it and delete it if so
|
// post-warp: check if the source instance has no more players in it and delete it if so
|
||||||
ChunkManager::destroyInstanceIfEmpty(fromInstance);
|
Chunking::destroyInstanceIfEmpty(fromInstance);
|
||||||
|
|
||||||
// clean up EPRaces if we were likely in an IZ and left
|
// clean up EPRaces if we were likely in an IZ and left
|
||||||
if (fromInstance != INSTANCE_OVERWORLD && fromInstance != I
|
if (fromInstance != INSTANCE_OVERWORLD && fromInstance != I
|
||||||
&& RacingManager::EPRaces.find(sock) != RacingManager::EPRaces.end())
|
&& Racing::EPRaces.find(sock) != Racing::EPRaces.end())
|
||||||
RacingManager::EPRaces.erase(sock);
|
Racing::EPRaces.erase(sock);
|
||||||
}
|
}
|
||||||
|
|
||||||
void PlayerManager::sendPlayerTo(CNSocket* sock, int X, int Y, int Z) {
|
void PlayerManager::sendPlayerTo(CNSocket* sock, int X, int Y, int Z) {
|
||||||
@ -266,7 +266,7 @@ static void enterPlayer(CNSocket* sock, CNPacketData* data) {
|
|||||||
if (plr.tasks[i] == 0)
|
if (plr.tasks[i] == 0)
|
||||||
break;
|
break;
|
||||||
response.PCLoadData2CL.aRunningQuest[i].m_aCurrTaskID = plr.tasks[i];
|
response.PCLoadData2CL.aRunningQuest[i].m_aCurrTaskID = plr.tasks[i];
|
||||||
TaskData &task = *MissionManager::Tasks[plr.tasks[i]];
|
TaskData &task = *Missions::Tasks[plr.tasks[i]];
|
||||||
for (int j = 0; j < 3; j++) {
|
for (int j = 0; j < 3; j++) {
|
||||||
response.PCLoadData2CL.aRunningQuest[i].m_aKillNPCID[j] = (int)task["m_iCSUEnemyID"][j];
|
response.PCLoadData2CL.aRunningQuest[i].m_aKillNPCID[j] = (int)task["m_iCSUEnemyID"][j];
|
||||||
response.PCLoadData2CL.aRunningQuest[i].m_aKillNPCCount[j] = plr.RemainingNPCCount[i][j];
|
response.PCLoadData2CL.aRunningQuest[i].m_aKillNPCCount[j] = plr.RemainingNPCCount[i][j];
|
||||||
@ -307,25 +307,25 @@ static void enterPlayer(CNSocket* sock, CNPacketData* data) {
|
|||||||
sock->sendPacket((void*)&response, P_FE2CL_REP_PC_ENTER_SUCC, sizeof(sP_FE2CL_REP_PC_ENTER_SUCC));
|
sock->sendPacket((void*)&response, P_FE2CL_REP_PC_ENTER_SUCC, sizeof(sP_FE2CL_REP_PC_ENTER_SUCC));
|
||||||
|
|
||||||
// transmit MOTD after entering the game, so the client hopefully changes modes on time
|
// transmit MOTD after entering the game, so the client hopefully changes modes on time
|
||||||
ChatManager::sendServerMessage(sock, settings::MOTDSTRING);
|
Chat::sendServerMessage(sock, settings::MOTDSTRING);
|
||||||
|
|
||||||
addPlayer(sock, plr);
|
addPlayer(sock, plr);
|
||||||
// check if there is an expiring vehicle
|
// check if there is an expiring vehicle
|
||||||
ItemManager::checkItemExpire(sock, getPlayer(sock));
|
Items::checkItemExpire(sock, getPlayer(sock));
|
||||||
|
|
||||||
// set player equip stats
|
// set player equip stats
|
||||||
ItemManager::setItemStats(getPlayer(sock));
|
Items::setItemStats(getPlayer(sock));
|
||||||
|
|
||||||
MissionManager::failInstancedMissions(sock);
|
Missions::failInstancedMissions(sock);
|
||||||
|
|
||||||
sendNanoBookSubset(sock);
|
sendNanoBookSubset(sock);
|
||||||
|
|
||||||
// initial buddy sync
|
// initial buddy sync
|
||||||
BuddyManager::refreshBuddyList(sock);
|
Buddies::refreshBuddyList(sock);
|
||||||
|
|
||||||
for (auto& pair : players)
|
for (auto& pair : players)
|
||||||
if (pair.second->notify)
|
if (pair.second->notify)
|
||||||
ChatManager::sendServerMessage(pair.first, "[ADMIN]" + getPlayerName(&plr) + " has joined.");
|
Chat::sendServerMessage(pair.first, "[ADMIN]" + getPlayerName(&plr) + " has joined.");
|
||||||
}
|
}
|
||||||
|
|
||||||
void PlayerManager::sendToViewable(CNSocket* sock, void* buf, uint32_t type, size_t size) {
|
void PlayerManager::sendToViewable(CNSocket* sock, void* buf, uint32_t type, size_t size) {
|
||||||
@ -411,7 +411,7 @@ static void revivePlayer(CNSocket* sock, CNPacketData* data) {
|
|||||||
// nano revive
|
// nano revive
|
||||||
plr->Nanos[plr->activeNano].iStamina = 0;
|
plr->Nanos[plr->activeNano].iStamina = 0;
|
||||||
plr->HP = PC_MAXHEALTH(plr->level);
|
plr->HP = PC_MAXHEALTH(plr->level);
|
||||||
NanoManager::applyBuff(sock, plr->Nanos[plr->activeNano].iSkillID, 2, 1, 0);
|
Nanos::applyBuff(sock, plr->Nanos[plr->activeNano].iSkillID, 2, 1, 0);
|
||||||
} else if (reviveData->iRegenType == 4) {
|
} else if (reviveData->iRegenType == 4) {
|
||||||
plr->HP = PC_MAXHEALTH(plr->level);
|
plr->HP = PC_MAXHEALTH(plr->level);
|
||||||
} else {
|
} else {
|
||||||
@ -471,7 +471,7 @@ static void revivePlayer(CNSocket* sock, CNPacketData* data) {
|
|||||||
|
|
||||||
Player *otherPlr = getPlayerFromID(plr->iIDGroup);
|
Player *otherPlr = getPlayerFromID(plr->iIDGroup);
|
||||||
if (otherPlr != nullptr) {
|
if (otherPlr != nullptr) {
|
||||||
int bitFlag = GroupManager::getGroupFlags(otherPlr);
|
int bitFlag = Groups::getGroupFlags(otherPlr);
|
||||||
resp2.PCRegenDataForOtherPC.iConditionBitFlag = plr->iConditionBitFlag = plr->iSelfConditionBitFlag | bitFlag;
|
resp2.PCRegenDataForOtherPC.iConditionBitFlag = plr->iConditionBitFlag = plr->iSelfConditionBitFlag | bitFlag;
|
||||||
|
|
||||||
resp2.PCRegenDataForOtherPC.iPCState = plr->iPCState;
|
resp2.PCRegenDataForOtherPC.iPCState = plr->iPCState;
|
||||||
@ -484,7 +484,7 @@ static void revivePlayer(CNSocket* sock, CNPacketData* data) {
|
|||||||
if (!move)
|
if (!move)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
ChunkManager::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
|
||||||
updatePlayerPosition(sock, x, y, z, plr->instanceID, plr->angle);
|
updatePlayerPosition(sock, x, y, z, plr->instanceID, plr->angle);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -512,7 +512,7 @@ static void enterPlayerVehicle(CNSocket* sock, CNPacketData* data) {
|
|||||||
if (expired) {
|
if (expired) {
|
||||||
plr->toRemoveVehicle.eIL = 0;
|
plr->toRemoveVehicle.eIL = 0;
|
||||||
plr->toRemoveVehicle.iSlotNum = 8;
|
plr->toRemoveVehicle.iSlotNum = 8;
|
||||||
ItemManager::checkItemExpire(sock, plr);
|
Items::checkItemExpire(sock, plr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -558,11 +558,11 @@ static void changePlayerGuide(CNSocket *sock, CNPacketData *data) {
|
|||||||
// remove all active missions
|
// remove all active missions
|
||||||
for (int i = 0; i < ACTIVE_MISSION_COUNT; i++) {
|
for (int i = 0; i < ACTIVE_MISSION_COUNT; i++) {
|
||||||
if (plr->tasks[i] != 0)
|
if (plr->tasks[i] != 0)
|
||||||
MissionManager::quitTask(sock, plr->tasks[i], true);
|
Missions::quitTask(sock, plr->tasks[i], true);
|
||||||
}
|
}
|
||||||
|
|
||||||
// start Blossom nano mission if applicable
|
// start Blossom nano mission if applicable
|
||||||
MissionManager::updateFusionMatter(sock, 0);
|
Missions::updateFusionMatter(sock, 0);
|
||||||
}
|
}
|
||||||
// save it on player
|
// save it on player
|
||||||
plr->mentor = pkt->iMentor;
|
plr->mentor = pkt->iMentor;
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
#include "CNProtocol.hpp"
|
#include "CNProtocol.hpp"
|
||||||
#include "CNStructs.hpp"
|
#include "CNStructs.hpp"
|
||||||
#include "CNShardServer.hpp"
|
#include "CNShardServer.hpp"
|
||||||
#include "ChunkManager.hpp"
|
#include "Chunking.hpp"
|
||||||
|
|
||||||
#include <utility>
|
#include <utility>
|
||||||
#include <map>
|
#include <map>
|
||||||
|
@ -1,17 +1,17 @@
|
|||||||
#include "CNShardServer.hpp"
|
#include "CNShardServer.hpp"
|
||||||
#include "CNStructs.hpp"
|
#include "CNStructs.hpp"
|
||||||
#include "RacingManager.hpp"
|
#include "Racing.hpp"
|
||||||
#include "PlayerManager.hpp"
|
#include "PlayerManager.hpp"
|
||||||
#include "MissionManager.hpp"
|
#include "Missions.hpp"
|
||||||
#include "ItemManager.hpp"
|
#include "Items.hpp"
|
||||||
#include "db/Database.hpp"
|
#include "db/Database.hpp"
|
||||||
#include "NPCManager.hpp"
|
#include "NPCManager.hpp"
|
||||||
|
|
||||||
using namespace RacingManager;
|
using namespace Racing;
|
||||||
|
|
||||||
std::map<int32_t, EPInfo> RacingManager::EPData;
|
std::map<int32_t, EPInfo> Racing::EPData;
|
||||||
std::map<CNSocket*, EPRace> RacingManager::EPRaces;
|
std::map<CNSocket*, EPRace> Racing::EPRaces;
|
||||||
std::map<int32_t, std::pair<std::vector<int>, std::vector<int>>> RacingManager::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) {
|
||||||
if (data->size != sizeof(sP_CL2FE_REQ_EP_RACE_START))
|
if (data->size != sizeof(sP_CL2FE_REQ_EP_RACE_START))
|
||||||
@ -135,14 +135,14 @@ static void racingEnd(CNSocket* sock, CNPacketData* data) {
|
|||||||
resp.iEPRaceMode = EPRaces[sock].mode;
|
resp.iEPRaceMode = EPRaces[sock].mode;
|
||||||
resp.iEPRewardFM = fm;
|
resp.iEPRewardFM = fm;
|
||||||
|
|
||||||
MissionManager::updateFusionMatter(sock, resp.iEPRewardFM);
|
Missions::updateFusionMatter(sock, resp.iEPRewardFM);
|
||||||
|
|
||||||
resp.iFusionMatter = plr->fusionmatter;
|
resp.iFusionMatter = plr->fusionmatter;
|
||||||
resp.iFatigue = 50;
|
resp.iFatigue = 50;
|
||||||
resp.iFatigue_Level = 1;
|
resp.iFatigue_Level = 1;
|
||||||
|
|
||||||
sItemReward reward;
|
sItemReward reward;
|
||||||
reward.iSlotNum = ItemManager::findFreeSlot(plr);
|
reward.iSlotNum = Items::findFreeSlot(plr);
|
||||||
reward.eIL = 1;
|
reward.eIL = 1;
|
||||||
sItemBase item;
|
sItemBase item;
|
||||||
item.iID = rankRewards->at(rank); // rank scores and rewards line up
|
item.iID = rankRewards->at(rank); // rank scores and rewards line up
|
||||||
@ -160,7 +160,7 @@ static void racingEnd(CNSocket* sock, CNPacketData* data) {
|
|||||||
sock->sendPacket((void*)&resp, P_FE2CL_REP_EP_RACE_END_SUCC, sizeof(sP_FE2CL_REP_EP_RACE_END_SUCC));
|
sock->sendPacket((void*)&resp, P_FE2CL_REP_EP_RACE_END_SUCC, sizeof(sP_FE2CL_REP_EP_RACE_END_SUCC));
|
||||||
}
|
}
|
||||||
|
|
||||||
void RacingManager::init() {
|
void Racing::init() {
|
||||||
REGISTER_SHARD_PACKET(P_CL2FE_REQ_EP_RACE_START, racingStart);
|
REGISTER_SHARD_PACKET(P_CL2FE_REQ_EP_RACE_START, racingStart);
|
||||||
REGISTER_SHARD_PACKET(P_CL2FE_REQ_EP_GET_RING, racingGetPod);
|
REGISTER_SHARD_PACKET(P_CL2FE_REQ_EP_GET_RING, racingGetPod);
|
||||||
REGISTER_SHARD_PACKET(P_CL2FE_REQ_EP_RACE_CANCEL, racingCancel);
|
REGISTER_SHARD_PACKET(P_CL2FE_REQ_EP_RACE_CANCEL, racingCancel);
|
@ -11,7 +11,7 @@ struct EPRace {
|
|||||||
time_t startTime;
|
time_t startTime;
|
||||||
};
|
};
|
||||||
|
|
||||||
namespace RacingManager {
|
namespace Racing {
|
||||||
extern std::map<int32_t, EPInfo> EPData;
|
extern std::map<int32_t, EPInfo> EPData;
|
||||||
extern std::map<CNSocket*, EPRace> EPRaces;
|
extern std::map<CNSocket*, EPRace> EPRaces;
|
||||||
extern std::map<int32_t, std::pair<std::vector<int>, std::vector<int>>> EPRewards;
|
extern std::map<int32_t, std::pair<std::vector<int>, std::vector<int>>> EPRewards;
|
@ -1,12 +1,12 @@
|
|||||||
#include "TableData.hpp"
|
#include "TableData.hpp"
|
||||||
#include "NPCManager.hpp"
|
#include "NPCManager.hpp"
|
||||||
#include "TransportManager.hpp"
|
#include "Transport.hpp"
|
||||||
#include "ItemManager.hpp"
|
#include "Items.hpp"
|
||||||
#include "settings.hpp"
|
#include "settings.hpp"
|
||||||
#include "MissionManager.hpp"
|
#include "Missions.hpp"
|
||||||
#include "ChunkManager.hpp"
|
#include "Chunking.hpp"
|
||||||
#include "NanoManager.hpp"
|
#include "Nanos.hpp"
|
||||||
#include "RacingManager.hpp"
|
#include "Racing.hpp"
|
||||||
#include "Vendor.hpp"
|
#include "Vendor.hpp"
|
||||||
#include "Abilities.hpp"
|
#include "Abilities.hpp"
|
||||||
|
|
||||||
@ -48,11 +48,11 @@ static void constructPathSkyway(nlohmann::json::iterator _pathData) {
|
|||||||
for (_point++; _point != pathPoints.end(); _point++) {
|
for (_point++; _point != pathPoints.end(); _point++) {
|
||||||
point = _point.value();
|
point = _point.value();
|
||||||
WarpLocation coords = { point["iX"] , point["iY"] , point["iZ"] };
|
WarpLocation coords = { point["iX"] , point["iY"] , point["iZ"] };
|
||||||
TransportManager::lerp(&points, last, coords, pathData["iMonkeySpeed"]);
|
Transport::lerp(&points, last, coords, pathData["iMonkeySpeed"]);
|
||||||
points.push(coords); // add keyframe to the queue
|
points.push(coords); // add keyframe to the queue
|
||||||
last = coords; // update start pos
|
last = coords; // update start pos
|
||||||
}
|
}
|
||||||
TransportManager::SkywayPaths[pathData["iRouteID"]] = points;
|
Transport::SkywayPaths[pathData["iRouteID"]] = points;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void constructPathNPC(nlohmann::json::iterator _pathData, int32_t id=0) {
|
static void constructPathNPC(nlohmann::json::iterator _pathData, int32_t id=0) {
|
||||||
@ -69,7 +69,7 @@ static void constructPathNPC(nlohmann::json::iterator _pathData, int32_t id=0) {
|
|||||||
for(int i = 0; i < stopTime + 1; i++) // repeat point if it's a stop
|
for(int i = 0; i < stopTime + 1; i++) // repeat point if it's a stop
|
||||||
points.push(from); // add point A to the queue
|
points.push(from); // add point A to the queue
|
||||||
WarpLocation to = { point["iX"] , point["iY"] , point["iZ"] }; // point B coords
|
WarpLocation to = { point["iX"] , point["iY"] , point["iZ"] }; // point B coords
|
||||||
TransportManager::lerp(&points, from, to, pathData["iBaseSpeed"]); // lerp from A to B
|
Transport::lerp(&points, from, to, pathData["iBaseSpeed"]); // lerp from A to B
|
||||||
from = to; // update point A
|
from = to; // update point A
|
||||||
stopTime = point["stop"];
|
stopTime = point["stop"];
|
||||||
}
|
}
|
||||||
@ -77,7 +77,7 @@ static void constructPathNPC(nlohmann::json::iterator _pathData, int32_t id=0) {
|
|||||||
if (id == 0)
|
if (id == 0)
|
||||||
id = pathData["iNPCID"];
|
id = pathData["iNPCID"];
|
||||||
|
|
||||||
TransportManager::NPCQueues[id] = points;
|
Transport::NPCQueues[id] = points;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -96,7 +96,7 @@ static void loadPaths(int* nextId) {
|
|||||||
for (nlohmann::json::iterator skywayPath = pathDataSkyway.begin(); skywayPath != pathDataSkyway.end(); skywayPath++) {
|
for (nlohmann::json::iterator skywayPath = pathDataSkyway.begin(); skywayPath != pathDataSkyway.end(); skywayPath++) {
|
||||||
constructPathSkyway(skywayPath);
|
constructPathSkyway(skywayPath);
|
||||||
}
|
}
|
||||||
std::cout << "[INFO] Loaded " << TransportManager::SkywayPaths.size() << " skyway paths" << std::endl;
|
std::cout << "[INFO] Loaded " << Transport::SkywayPaths.size() << " skyway paths" << std::endl;
|
||||||
|
|
||||||
// slider circuit
|
// slider circuit
|
||||||
nlohmann::json pathDataSlider = pathData["slider"];
|
nlohmann::json pathDataSlider = pathData["slider"];
|
||||||
@ -121,7 +121,7 @@ static void loadPaths(int* nextId) {
|
|||||||
} else if (point["stop"]) { // point B is a stop
|
} else if (point["stop"]) { // point B is a stop
|
||||||
curve = 0.375f;//0.35f;
|
curve = 0.375f;//0.35f;
|
||||||
}
|
}
|
||||||
TransportManager::lerp(&route, from, to, SLIDER_SPEED * curve, 1); // lerp from A to B (arbitrary speed)
|
Transport::lerp(&route, from, to, SLIDER_SPEED * curve, 1); // lerp from A to B (arbitrary speed)
|
||||||
from = to; // update point A
|
from = to; // update point A
|
||||||
stopTime = point["stop"] ? SLIDER_STOP_TICKS : 0; // set stop ticks for next point A
|
stopTime = point["stop"] ? SLIDER_STOP_TICKS : 0; // set stop ticks for next point A
|
||||||
}
|
}
|
||||||
@ -141,7 +141,7 @@ static void loadPaths(int* nextId) {
|
|||||||
BaseNPC* slider = new BaseNPC(point.x, point.y, point.z, 0, INSTANCE_OVERWORLD, 1, (*nextId)++, NPC_BUS);
|
BaseNPC* slider = new BaseNPC(point.x, point.y, point.z, 0, INSTANCE_OVERWORLD, 1, (*nextId)++, NPC_BUS);
|
||||||
NPCManager::NPCs[slider->appearanceData.iNPC_ID] = slider;
|
NPCManager::NPCs[slider->appearanceData.iNPC_ID] = slider;
|
||||||
NPCManager::updateNPCPosition(slider->appearanceData.iNPC_ID, slider->appearanceData.iX, slider->appearanceData.iY, slider->appearanceData.iZ, INSTANCE_OVERWORLD, 0);
|
NPCManager::updateNPCPosition(slider->appearanceData.iNPC_ID, slider->appearanceData.iX, slider->appearanceData.iY, slider->appearanceData.iZ, INSTANCE_OVERWORLD, 0);
|
||||||
TransportManager::NPCQueues[slider->appearanceData.iNPC_ID] = route;
|
Transport::NPCQueues[slider->appearanceData.iNPC_ID] = route;
|
||||||
}
|
}
|
||||||
// rotate
|
// rotate
|
||||||
route.pop();
|
route.pop();
|
||||||
@ -177,7 +177,7 @@ static void loadPaths(int* nextId) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
std::cout << "[INFO] Loaded " << TransportManager::NPCQueues.size() << " NPC paths" << std::endl;
|
std::cout << "[INFO] Loaded " << Transport::NPCQueues.size() << " NPC paths" << std::endl;
|
||||||
}
|
}
|
||||||
catch (const std::exception& err) {
|
catch (const std::exception& err) {
|
||||||
std::cerr << "[FATAL] Malformed paths.json file! Reason:" << err.what() << std::endl;
|
std::cerr << "[FATAL] Malformed paths.json file! Reason:" << err.what() << std::endl;
|
||||||
@ -206,7 +206,7 @@ static void loadDrops() {
|
|||||||
for (nlohmann::json::iterator _cratesRatio = dropChance["CratesRatio"].begin(); _cratesRatio != dropChance["CratesRatio"].end(); _cratesRatio++) {
|
for (nlohmann::json::iterator _cratesRatio = dropChance["CratesRatio"].begin(); _cratesRatio != dropChance["CratesRatio"].end(); _cratesRatio++) {
|
||||||
toAdd.cratesRatio.push_back((int)_cratesRatio.value());
|
toAdd.cratesRatio.push_back((int)_cratesRatio.value());
|
||||||
}
|
}
|
||||||
ItemManager::MobDropChances[(int)dropChance["Type"]] = toAdd;
|
Items::MobDropChances[(int)dropChance["Type"]] = toAdd;
|
||||||
}
|
}
|
||||||
|
|
||||||
// MobDrops
|
// MobDrops
|
||||||
@ -220,21 +220,21 @@ static void loadDrops() {
|
|||||||
|
|
||||||
toAdd.dropChanceType = (int)drop["DropChance"];
|
toAdd.dropChanceType = (int)drop["DropChance"];
|
||||||
// Check if DropChance exists
|
// Check if DropChance exists
|
||||||
if (ItemManager::MobDropChances.find(toAdd.dropChanceType) == ItemManager::MobDropChances.end()) {
|
if (Items::MobDropChances.find(toAdd.dropChanceType) == Items::MobDropChances.end()) {
|
||||||
throw TableException(" MobDropChance not found: " + std::to_string((toAdd.dropChanceType)));
|
throw TableException(" MobDropChance not found: " + std::to_string((toAdd.dropChanceType)));
|
||||||
}
|
}
|
||||||
// Check if number of crates is correct
|
// Check if number of crates is correct
|
||||||
if (!(ItemManager::MobDropChances[(int)drop["DropChance"]].cratesRatio.size() == toAdd.crateIDs.size())) {
|
if (!(Items::MobDropChances[(int)drop["DropChance"]].cratesRatio.size() == toAdd.crateIDs.size())) {
|
||||||
throw TableException(" DropType " + std::to_string((int)drop["DropType"]) + " contains invalid number of crates");
|
throw TableException(" DropType " + std::to_string((int)drop["DropType"]) + " contains invalid number of crates");
|
||||||
}
|
}
|
||||||
|
|
||||||
toAdd.taros = (int)drop["Taros"];
|
toAdd.taros = (int)drop["Taros"];
|
||||||
toAdd.fm = (int)drop["FM"];
|
toAdd.fm = (int)drop["FM"];
|
||||||
toAdd.boosts = (int)drop["Boosts"];
|
toAdd.boosts = (int)drop["Boosts"];
|
||||||
ItemManager::MobDrops[(int)drop["DropType"]] = toAdd;
|
Items::MobDrops[(int)drop["DropType"]] = toAdd;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::cout << "[INFO] Loaded " << ItemManager::MobDrops.size() << " Mob Drop Types"<< std::endl;
|
std::cout << "[INFO] Loaded " << Items::MobDrops.size() << " Mob Drop Types"<< std::endl;
|
||||||
|
|
||||||
// Rarity Ratios
|
// Rarity Ratios
|
||||||
nlohmann::json rarities = dropData["RarityRatios"];
|
nlohmann::json rarities = dropData["RarityRatios"];
|
||||||
@ -244,7 +244,7 @@ static void loadDrops() {
|
|||||||
for (nlohmann::json::iterator _ratio = rarity["Ratio"].begin(); _ratio != rarity["Ratio"].end(); _ratio++){
|
for (nlohmann::json::iterator _ratio = rarity["Ratio"].begin(); _ratio != rarity["Ratio"].end(); _ratio++){
|
||||||
toAdd.push_back((int)_ratio.value());
|
toAdd.push_back((int)_ratio.value());
|
||||||
}
|
}
|
||||||
ItemManager::RarityRatios[(int)rarity["Type"]] = toAdd;
|
Items::RarityRatios[(int)rarity["Type"]] = toAdd;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Crates
|
// Crates
|
||||||
@ -256,7 +256,7 @@ static void loadDrops() {
|
|||||||
for (nlohmann::json::iterator _itemSet = crate["ItemSets"].begin(); _itemSet != crate["ItemSets"].end(); _itemSet++) {
|
for (nlohmann::json::iterator _itemSet = crate["ItemSets"].begin(); _itemSet != crate["ItemSets"].end(); _itemSet++) {
|
||||||
toAdd.itemSets.push_back((int)_itemSet.value());
|
toAdd.itemSets.push_back((int)_itemSet.value());
|
||||||
}
|
}
|
||||||
ItemManager::Crates[(int)crate["Id"]] = toAdd;
|
Items::Crates[(int)crate["Id"]] = toAdd;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Crate Items
|
// Crate Items
|
||||||
@ -267,21 +267,21 @@ static void loadDrops() {
|
|||||||
std::pair<int32_t, int32_t> itemSetkey = std::make_pair((int)item["ItemSet"], (int)item["Rarity"]);
|
std::pair<int32_t, int32_t> itemSetkey = std::make_pair((int)item["ItemSet"], (int)item["Rarity"]);
|
||||||
std::pair<int32_t, int32_t> itemDataKey = std::make_pair((int)item["Id"], (int)item["Type"]);
|
std::pair<int32_t, int32_t> itemDataKey = std::make_pair((int)item["Id"], (int)item["Type"]);
|
||||||
|
|
||||||
if (ItemManager::ItemData.find(itemDataKey) == ItemManager::ItemData.end()) {
|
if (Items::ItemData.find(itemDataKey) == Items::ItemData.end()) {
|
||||||
char buff[255];
|
char buff[255];
|
||||||
sprintf(buff, "Unknown item with Id %d and Type %d", (int)item["Id"], (int)item["Type"]);
|
sprintf(buff, "Unknown item with Id %d and Type %d", (int)item["Id"], (int)item["Type"]);
|
||||||
throw TableException(std::string(buff));
|
throw TableException(std::string(buff));
|
||||||
}
|
}
|
||||||
|
|
||||||
std::map<std::pair<int32_t, int32_t>, ItemManager::Item>::iterator toAdd = ItemManager::ItemData.find(itemDataKey);
|
std::map<std::pair<int32_t, int32_t>, Items::Item>::iterator toAdd = Items::ItemData.find(itemDataKey);
|
||||||
|
|
||||||
// if item collection doesn't exist, start a new one
|
// if item collection doesn't exist, start a new one
|
||||||
if (ItemManager::CrateItems.find(itemSetkey) == ItemManager::CrateItems.end()) {
|
if (Items::CrateItems.find(itemSetkey) == Items::CrateItems.end()) {
|
||||||
std::vector<std::map<std::pair<int32_t, int32_t>, ItemManager::Item>::iterator> vector;
|
std::vector<std::map<std::pair<int32_t, int32_t>, Items::Item>::iterator> vector;
|
||||||
vector.push_back(toAdd);
|
vector.push_back(toAdd);
|
||||||
ItemManager::CrateItems[itemSetkey] = vector;
|
Items::CrateItems[itemSetkey] = vector;
|
||||||
} else // else add a new element to existing collection
|
} else // else add a new element to existing collection
|
||||||
ItemManager::CrateItems[itemSetkey].push_back(toAdd);
|
Items::CrateItems[itemSetkey].push_back(toAdd);
|
||||||
|
|
||||||
itemCount++;
|
itemCount++;
|
||||||
}
|
}
|
||||||
@ -291,7 +291,7 @@ static void loadDrops() {
|
|||||||
|
|
||||||
for (nlohmann::json::iterator _capsule = capsules.begin(); _capsule != capsules.end(); _capsule++) {
|
for (nlohmann::json::iterator _capsule = capsules.begin(); _capsule != capsules.end(); _capsule++) {
|
||||||
auto capsule = _capsule.value();
|
auto capsule = _capsule.value();
|
||||||
ItemManager::NanoCapsules[(int)capsule["Crate"]] = (int)capsule["Nano"];
|
Items::NanoCapsules[(int)capsule["Crate"]] = (int)capsule["Nano"];
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
nlohmann::json codes = dropData["CodeItems"];
|
nlohmann::json codes = dropData["CodeItems"];
|
||||||
@ -300,13 +300,13 @@ static void loadDrops() {
|
|||||||
std::string codeStr = code["Code"];
|
std::string codeStr = code["Code"];
|
||||||
std::pair<int32_t, int32_t> item = std::make_pair((int)code["Id"], (int)code["Type"]);
|
std::pair<int32_t, int32_t> item = std::make_pair((int)code["Id"], (int)code["Type"]);
|
||||||
|
|
||||||
if (ItemManager::CodeItems.find(codeStr) == ItemManager::CodeItems.end())
|
if (Items::CodeItems.find(codeStr) == Items::CodeItems.end())
|
||||||
ItemManager::CodeItems[codeStr] = std::vector<std::pair<int32_t, int32_t>>();
|
Items::CodeItems[codeStr] = std::vector<std::pair<int32_t, int32_t>>();
|
||||||
|
|
||||||
ItemManager::CodeItems[codeStr].push_back(item);
|
Items::CodeItems[codeStr].push_back(item);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::cout << "[INFO] Loaded " << ItemManager::Crates.size() << " Crates containing "
|
std::cout << "[INFO] Loaded " << Items::Crates.size() << " Crates containing "
|
||||||
<< itemCount << " items" << std::endl;
|
<< itemCount << " items" << std::endl;
|
||||||
|
|
||||||
// Racing rewards
|
// Racing rewards
|
||||||
@ -317,7 +317,7 @@ static void loadDrops() {
|
|||||||
|
|
||||||
// find the instance data corresponding to the EPID
|
// find the instance data corresponding to the EPID
|
||||||
int EPMap = -1;
|
int EPMap = -1;
|
||||||
for (auto it = RacingManager::EPData.begin(); it != RacingManager::EPData.end(); it++) {
|
for (auto it = Racing::EPData.begin(); it != Racing::EPData.end(); it++) {
|
||||||
if (it->second.EPID == raceEPID) {
|
if (it->second.EPID == raceEPID) {
|
||||||
EPMap = it->first;
|
EPMap = it->first;
|
||||||
}
|
}
|
||||||
@ -329,7 +329,7 @@ static void loadDrops() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// time limit isn't stored in the XDT, so we include it in the reward table instead
|
// time limit isn't stored in the XDT, so we include it in the reward table instead
|
||||||
RacingManager::EPData[EPMap].maxTime = race["TimeLimit"];
|
Racing::EPData[EPMap].maxTime = race["TimeLimit"];
|
||||||
|
|
||||||
// score cutoffs
|
// score cutoffs
|
||||||
std::vector<int> rankScores;
|
std::vector<int> rankScores;
|
||||||
@ -349,10 +349,10 @@ static void loadDrops() {
|
|||||||
throw TableException(std::string(buff));
|
throw TableException(std::string(buff));
|
||||||
}
|
}
|
||||||
|
|
||||||
RacingManager::EPRewards[raceEPID] = std::make_pair(rankScores, rankRewards);
|
Racing::EPRewards[raceEPID] = std::make_pair(rankScores, rankRewards);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::cout << "[INFO] Loaded rewards for " << RacingManager::EPRewards.size() << " IZ races" << std::endl;
|
std::cout << "[INFO] Loaded rewards for " << Racing::EPRewards.size() << " IZ races" << std::endl;
|
||||||
|
|
||||||
}
|
}
|
||||||
catch (const std::exception& err) {
|
catch (const std::exception& err) {
|
||||||
@ -620,17 +620,17 @@ void TableData::init() {
|
|||||||
for (nlohmann::json::iterator _tLoc = transLocData.begin(); _tLoc != transLocData.end(); _tLoc++) {
|
for (nlohmann::json::iterator _tLoc = transLocData.begin(); _tLoc != transLocData.end(); _tLoc++) {
|
||||||
auto tLoc = _tLoc.value();
|
auto tLoc = _tLoc.value();
|
||||||
TransportLocation transLoc = { tLoc["m_iNPCID"], tLoc["m_iXpos"], tLoc["m_iYpos"], tLoc["m_iZpos"] };
|
TransportLocation transLoc = { tLoc["m_iNPCID"], tLoc["m_iXpos"], tLoc["m_iYpos"], tLoc["m_iZpos"] };
|
||||||
TransportManager::Locations[tLoc["m_iLocationID"]] = transLoc;
|
Transport::Locations[tLoc["m_iLocationID"]] = transLoc;
|
||||||
}
|
}
|
||||||
std::cout << "[INFO] Loaded " << TransportManager::Locations.size() << " S.C.A.M.P.E.R. locations" << std::endl;
|
std::cout << "[INFO] Loaded " << Transport::Locations.size() << " S.C.A.M.P.E.R. locations" << std::endl;
|
||||||
|
|
||||||
for (nlohmann::json::iterator _tRoute = transRouteData.begin(); _tRoute != transRouteData.end(); _tRoute++) {
|
for (nlohmann::json::iterator _tRoute = transRouteData.begin(); _tRoute != transRouteData.end(); _tRoute++) {
|
||||||
auto tRoute = _tRoute.value();
|
auto tRoute = _tRoute.value();
|
||||||
TransportRoute transRoute = { tRoute["m_iMoveType"], tRoute["m_iStartLocation"], tRoute["m_iEndLocation"],
|
TransportRoute transRoute = { tRoute["m_iMoveType"], tRoute["m_iStartLocation"], tRoute["m_iEndLocation"],
|
||||||
tRoute["m_iCost"] , tRoute["m_iSpeed"], tRoute["m_iRouteNum"] };
|
tRoute["m_iCost"] , tRoute["m_iSpeed"], tRoute["m_iRouteNum"] };
|
||||||
TransportManager::Routes[tRoute["m_iVehicleID"]] = transRoute;
|
Transport::Routes[tRoute["m_iVehicleID"]] = transRoute;
|
||||||
}
|
}
|
||||||
std::cout << "[INFO] Loaded " << TransportManager::Routes.size() << " transportation routes" << std::endl;
|
std::cout << "[INFO] Loaded " << Transport::Routes.size() << " transportation routes" << std::endl;
|
||||||
|
|
||||||
// load mission-related data
|
// load mission-related data
|
||||||
nlohmann::json tasks = xdtData["m_pMissionTable"]["m_pMissionData"];
|
nlohmann::json tasks = xdtData["m_pMissionTable"]["m_pMissionData"];
|
||||||
@ -644,11 +644,11 @@ void TableData::init() {
|
|||||||
Reward *rew = new Reward(_rew["m_iMissionRewardID"], _rew["m_iMissionRewarItemType"],
|
Reward *rew = new Reward(_rew["m_iMissionRewardID"], _rew["m_iMissionRewarItemType"],
|
||||||
_rew["m_iMissionRewardItemID"], _rew["m_iCash"], _rew["m_iFusionMatter"]);
|
_rew["m_iMissionRewardItemID"], _rew["m_iCash"], _rew["m_iFusionMatter"]);
|
||||||
|
|
||||||
MissionManager::Rewards[task["m_iHTaskID"]] = rew;
|
Missions::Rewards[task["m_iHTaskID"]] = rew;
|
||||||
}
|
}
|
||||||
|
|
||||||
// everything else lol. see TaskData comment.
|
// everything else lol. see TaskData comment.
|
||||||
MissionManager::Tasks[task["m_iHTaskID"]] = new TaskData(task);
|
Missions::Tasks[task["m_iHTaskID"]] = new TaskData(task);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::cout << "[INFO] Loaded mission-related data" << std::endl;
|
std::cout << "[INFO] Loaded mission-related data" << std::endl;
|
||||||
@ -669,7 +669,7 @@ void TableData::init() {
|
|||||||
for (nlohmann::json::iterator _item = itemSet.begin(); _item != itemSet.end(); _item++) {
|
for (nlohmann::json::iterator _item = itemSet.begin(); _item != itemSet.end(); _item++) {
|
||||||
auto item = _item.value();
|
auto item = _item.value();
|
||||||
int itemID = item["m_iItemNumber"];
|
int itemID = item["m_iItemNumber"];
|
||||||
INITSTRUCT(ItemManager::Item, itemData);
|
INITSTRUCT(Items::Item, itemData);
|
||||||
itemData.tradeable = item["m_iTradeAble"] == 1;
|
itemData.tradeable = item["m_iTradeAble"] == 1;
|
||||||
itemData.sellable = item["m_iSellAble"] == 1;
|
itemData.sellable = item["m_iSellAble"] == 1;
|
||||||
itemData.buyPrice = item["m_iItemPrice"];
|
itemData.buyPrice = item["m_iItemPrice"];
|
||||||
@ -687,18 +687,18 @@ void TableData::init() {
|
|||||||
} else {
|
} else {
|
||||||
itemData.rarity = 1;
|
itemData.rarity = 1;
|
||||||
}
|
}
|
||||||
ItemManager::ItemData[std::make_pair(itemID, i)] = itemData;
|
Items::ItemData[std::make_pair(itemID, i)] = itemData;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
std::cout << "[INFO] Loaded " << ItemManager::ItemData.size() << " items" << std::endl;
|
std::cout << "[INFO] Loaded " << Items::ItemData.size() << " items" << std::endl;
|
||||||
|
|
||||||
// load player limits from m_pAvatarTable.m_pAvatarGrowData
|
// load player limits from m_pAvatarTable.m_pAvatarGrowData
|
||||||
|
|
||||||
nlohmann::json growth = xdtData["m_pAvatarTable"]["m_pAvatarGrowData"];
|
nlohmann::json growth = xdtData["m_pAvatarTable"]["m_pAvatarGrowData"];
|
||||||
|
|
||||||
for (int i = 0; i < 37; i++) {
|
for (int i = 0; i < 37; i++) {
|
||||||
MissionManager::AvatarGrowth[i] = growth[i];
|
Missions::AvatarGrowth[i] = growth[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
// load vendor listings
|
// load vendor listings
|
||||||
@ -718,10 +718,10 @@ void TableData::init() {
|
|||||||
for (nlohmann::json::iterator croc = crocs.begin(); croc != crocs.end(); croc++) {
|
for (nlohmann::json::iterator croc = crocs.begin(); croc != crocs.end(); croc++) {
|
||||||
CrocPotEntry crocEntry = { croc.value()["m_iStatConstant"], croc.value()["m_iLookConstant"], croc.value()["m_fLevelGapStandard"],
|
CrocPotEntry crocEntry = { croc.value()["m_iStatConstant"], croc.value()["m_iLookConstant"], croc.value()["m_fLevelGapStandard"],
|
||||||
croc.value()["m_fSameGrade"], croc.value()["m_fOneGrade"], croc.value()["m_fTwoGrade"], croc.value()["m_fThreeGrade"] };
|
croc.value()["m_fSameGrade"], croc.value()["m_fOneGrade"], croc.value()["m_fTwoGrade"], croc.value()["m_fThreeGrade"] };
|
||||||
ItemManager::CrocPotTable[croc.value()["m_iLevelGap"]] = crocEntry;
|
Items::CrocPotTable[croc.value()["m_iLevelGap"]] = crocEntry;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::cout << "[INFO] Loaded " << ItemManager::CrocPotTable.size() << " croc pot value sets" << std::endl;
|
std::cout << "[INFO] Loaded " << Items::CrocPotTable.size() << " croc pot value sets" << std::endl;
|
||||||
|
|
||||||
// load nano info
|
// load nano info
|
||||||
nlohmann::json nanoInfo = xdtData["m_pNanoTable"]["m_pNanoData"];
|
nlohmann::json nanoInfo = xdtData["m_pNanoTable"]["m_pNanoData"];
|
||||||
@ -729,10 +729,10 @@ void TableData::init() {
|
|||||||
auto nano = _nano.value();
|
auto nano = _nano.value();
|
||||||
NanoData nanoData;
|
NanoData nanoData;
|
||||||
nanoData.style = nano["m_iStyle"];
|
nanoData.style = nano["m_iStyle"];
|
||||||
NanoManager::NanoTable[NanoManager::NanoTable.size()] = nanoData;
|
Nanos::NanoTable[Nanos::NanoTable.size()] = nanoData;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::cout << "[INFO] Loaded " << NanoManager::NanoTable.size() << " nanos" << std::endl;
|
std::cout << "[INFO] Loaded " << Nanos::NanoTable.size() << " nanos" << std::endl;
|
||||||
|
|
||||||
nlohmann::json nanoTuneInfo = xdtData["m_pNanoTable"]["m_pNanoTuneData"];
|
nlohmann::json nanoTuneInfo = xdtData["m_pNanoTable"]["m_pNanoTuneData"];
|
||||||
for (nlohmann::json::iterator _nano = nanoTuneInfo.begin(); _nano != nanoTuneInfo.end(); _nano++) {
|
for (nlohmann::json::iterator _nano = nanoTuneInfo.begin(); _nano != nanoTuneInfo.end(); _nano++) {
|
||||||
@ -740,10 +740,10 @@ void TableData::init() {
|
|||||||
NanoTuning nanoData;
|
NanoTuning nanoData;
|
||||||
nanoData.reqItems = nano["m_iReqItemID"];
|
nanoData.reqItems = nano["m_iReqItemID"];
|
||||||
nanoData.reqItemCount = nano["m_iReqItemCount"];
|
nanoData.reqItemCount = nano["m_iReqItemCount"];
|
||||||
NanoManager::NanoTunings[nano["m_iSkillID"]] = nanoData;
|
Nanos::NanoTunings[nano["m_iSkillID"]] = nanoData;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::cout << "[INFO] Loaded " << NanoManager::NanoTable.size() << " nano tunings" << std::endl;
|
std::cout << "[INFO] Loaded " << Nanos::NanoTable.size() << " nano tunings" << std::endl;
|
||||||
|
|
||||||
// load nano powers
|
// load nano powers
|
||||||
nlohmann::json skills = xdtData["m_pSkillTable"]["m_pSkillData"];
|
nlohmann::json skills = xdtData["m_pSkillTable"]["m_pSkillData"];
|
||||||
@ -756,10 +756,10 @@ void TableData::init() {
|
|||||||
skillData.durationTime[i] = skills["m_iDurationTime"][i];
|
skillData.durationTime[i] = skills["m_iDurationTime"][i];
|
||||||
skillData.powerIntensity[i] = skills["m_iValueA"][i];
|
skillData.powerIntensity[i] = skills["m_iValueA"][i];
|
||||||
}
|
}
|
||||||
NanoManager::SkillTable[skills["m_iSkillNumber"]] = skillData;
|
Nanos::SkillTable[skills["m_iSkillNumber"]] = skillData;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::cout << "[INFO] Loaded " << NanoManager::SkillTable.size() << " nano skills" << std::endl;
|
std::cout << "[INFO] Loaded " << Nanos::SkillTable.size() << " nano skills" << std::endl;
|
||||||
|
|
||||||
// load EP data
|
// load EP data
|
||||||
nlohmann::json instances = xdtData["m_pInstanceTable"]["m_pInstanceData"];
|
nlohmann::json instances = xdtData["m_pInstanceTable"]["m_pInstanceData"];
|
||||||
@ -767,10 +767,10 @@ void TableData::init() {
|
|||||||
for (nlohmann::json::iterator _instance = instances.begin(); _instance != instances.end(); _instance++) {
|
for (nlohmann::json::iterator _instance = instances.begin(); _instance != instances.end(); _instance++) {
|
||||||
auto instance = _instance.value();
|
auto instance = _instance.value();
|
||||||
EPInfo epInfo = {instance["m_iZoneX"], instance["m_iZoneY"], instance["m_iIsEP"], (int)instance["m_ScoreMax"]};
|
EPInfo epInfo = {instance["m_iZoneX"], instance["m_iZoneY"], instance["m_iIsEP"], (int)instance["m_ScoreMax"]};
|
||||||
RacingManager::EPData[instance["m_iInstanceNameID"]] = epInfo;
|
Racing::EPData[instance["m_iInstanceNameID"]] = epInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::cout << "[INFO] Loaded " << RacingManager::EPData.size() << " instances" << std::endl;
|
std::cout << "[INFO] Loaded " << Racing::EPData.size() << " instances" << std::endl;
|
||||||
|
|
||||||
}
|
}
|
||||||
catch (const std::exception& err) {
|
catch (const std::exception& err) {
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "ItemManager.hpp"
|
#include "Items.hpp"
|
||||||
|
|
||||||
namespace Trading {
|
namespace Trading {
|
||||||
void init();
|
void init();
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
#include "CNShardServer.hpp"
|
#include "CNShardServer.hpp"
|
||||||
#include "CNStructs.hpp"
|
#include "CNStructs.hpp"
|
||||||
#include "PlayerManager.hpp"
|
#include "PlayerManager.hpp"
|
||||||
#include "NanoManager.hpp"
|
#include "Nanos.hpp"
|
||||||
#include "TransportManager.hpp"
|
#include "Transport.hpp"
|
||||||
#include "TableData.hpp"
|
#include "TableData.hpp"
|
||||||
#include "Combat.hpp"
|
#include "Combat.hpp"
|
||||||
#include "MobAI.hpp"
|
#include "MobAI.hpp"
|
||||||
@ -10,13 +10,13 @@
|
|||||||
#include <unordered_map>
|
#include <unordered_map>
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
|
|
||||||
using namespace TransportManager;
|
using namespace Transport;
|
||||||
|
|
||||||
std::map<int32_t, TransportRoute> TransportManager::Routes;
|
std::map<int32_t, TransportRoute> Transport::Routes;
|
||||||
std::map<int32_t, TransportLocation> TransportManager::Locations;
|
std::map<int32_t, TransportLocation> Transport::Locations;
|
||||||
std::map<int32_t, std::queue<WarpLocation>> TransportManager::SkywayPaths;
|
std::map<int32_t, std::queue<WarpLocation>> Transport::SkywayPaths;
|
||||||
std::unordered_map<CNSocket*, std::queue<WarpLocation>> TransportManager::SkywayQueues;
|
std::unordered_map<CNSocket*, std::queue<WarpLocation>> Transport::SkywayQueues;
|
||||||
std::unordered_map<int32_t, std::queue<WarpLocation>> TransportManager::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) {
|
||||||
if (data->size != sizeof(sP_CL2FE_REQ_REGIST_TRANSPORTATION_LOCATION))
|
if (data->size != sizeof(sP_CL2FE_REQ_REGIST_TRANSPORTATION_LOCATION))
|
||||||
@ -133,13 +133,13 @@ static void transportWarpHandler(CNSocket* sock, CNPacketData* data) {
|
|||||||
plr->lastY = plr->y;
|
plr->lastY = plr->y;
|
||||||
plr->lastZ = plr->z;
|
plr->lastZ = plr->z;
|
||||||
if (SkywayPaths.find(route.mssRouteNum) != SkywayPaths.end()) { // check if route exists
|
if (SkywayPaths.find(route.mssRouteNum) != SkywayPaths.end()) { // check if route exists
|
||||||
NanoManager::summonNano(sock, -1); // make sure that no nano is active during the ride
|
Nanos::summonNano(sock, -1); // make sure that no nano is active during the ride
|
||||||
SkywayQueues[sock] = SkywayPaths[route.mssRouteNum]; // set socket point queue to route
|
SkywayQueues[sock] = SkywayPaths[route.mssRouteNum]; // set socket point queue to route
|
||||||
plr->onMonkey = true;
|
plr->onMonkey = true;
|
||||||
break;
|
break;
|
||||||
} else if (TableData::RunningSkywayRoutes.find(route.mssRouteNum) != TableData::RunningSkywayRoutes.end()) {
|
} else if (TableData::RunningSkywayRoutes.find(route.mssRouteNum) != TableData::RunningSkywayRoutes.end()) {
|
||||||
std::vector<WarpLocation>* _route = &TableData::RunningSkywayRoutes[route.mssRouteNum];
|
std::vector<WarpLocation>* _route = &TableData::RunningSkywayRoutes[route.mssRouteNum];
|
||||||
NanoManager::summonNano(sock, -1);
|
Nanos::summonNano(sock, -1);
|
||||||
testMssRoute(sock, _route);
|
testMssRoute(sock, _route);
|
||||||
plr->onMonkey = true;
|
plr->onMonkey = true;
|
||||||
break;
|
break;
|
||||||
@ -172,18 +172,18 @@ static void transportWarpHandler(CNSocket* sock, CNPacketData* data) {
|
|||||||
if (target == nullptr)
|
if (target == nullptr)
|
||||||
return;
|
return;
|
||||||
// we warped; update position and chunks
|
// we warped; update position and chunks
|
||||||
ChunkManager::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, target->x, target->y, target->z, INSTANCE_OVERWORLD, plr->angle);
|
PlayerManager::updatePlayerPosition(sock, target->x, target->y, target->z, INSTANCE_OVERWORLD, plr->angle);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TransportManager::testMssRoute(CNSocket *sock, std::vector<WarpLocation>* route) {
|
void Transport::testMssRoute(CNSocket *sock, std::vector<WarpLocation>* route) {
|
||||||
int speed = 1500; // TODO: make this adjustable
|
int speed = 1500; // TODO: make this adjustable
|
||||||
std::queue<WarpLocation> path;
|
std::queue<WarpLocation> path;
|
||||||
WarpLocation last = route->front(); // start pos
|
WarpLocation last = route->front(); // start pos
|
||||||
|
|
||||||
for (int i = 1; i < route->size(); i++) {
|
for (int i = 1; i < route->size(); i++) {
|
||||||
WarpLocation coords = route->at(i);
|
WarpLocation coords = route->at(i);
|
||||||
TransportManager::lerp(&path, last, coords, speed);
|
Transport::lerp(&path, last, coords, speed);
|
||||||
path.push(coords); // add keyframe to the queue
|
path.push(coords); // add keyframe to the queue
|
||||||
last = coords; // update start pos
|
last = coords; // update start pos
|
||||||
}
|
}
|
||||||
@ -332,7 +332,7 @@ static void tickTransportationSystem(CNServer* serv, time_t currTime) {
|
|||||||
/*
|
/*
|
||||||
* Linearly interpolate between two points and insert the results into a queue.
|
* Linearly interpolate between two points and insert the results into a queue.
|
||||||
*/
|
*/
|
||||||
void TransportManager::lerp(std::queue<WarpLocation>* queue, WarpLocation start, WarpLocation end, int gapSize, float curve) {
|
void Transport::lerp(std::queue<WarpLocation>* queue, WarpLocation start, WarpLocation end, int gapSize, float curve) {
|
||||||
int dXY = hypot(end.x - start.x, end.y - start.y); // XY plane distance
|
int dXY = hypot(end.x - start.x, end.y - start.y); // XY plane distance
|
||||||
int distanceBetween = hypot(dXY, end.z - start.z); // total distance
|
int distanceBetween = hypot(dXY, end.z - start.z); // total distance
|
||||||
int lerps = distanceBetween / gapSize; // number of intermediate points to add
|
int lerps = distanceBetween / gapSize; // number of intermediate points to add
|
||||||
@ -347,11 +347,11 @@ void TransportManager::lerp(std::queue<WarpLocation>* queue, WarpLocation start,
|
|||||||
queue->push(lerp); // add lerp'd point
|
queue->push(lerp); // add lerp'd point
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
void TransportManager::lerp(std::queue<WarpLocation>* queue, WarpLocation start, WarpLocation end, int gapSize) {
|
void Transport::lerp(std::queue<WarpLocation>* queue, WarpLocation start, WarpLocation end, int gapSize) {
|
||||||
lerp(queue, start, end, gapSize, 1);
|
lerp(queue, start, end, gapSize, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TransportManager::init() {
|
void Transport::init() {
|
||||||
REGISTER_SHARD_TIMER(tickTransportationSystem, 1000);
|
REGISTER_SHARD_TIMER(tickTransportationSystem, 1000);
|
||||||
|
|
||||||
REGISTER_SHARD_PACKET(P_CL2FE_REQ_REGIST_TRANSPORTATION_LOCATION, transportRegisterLocationHandler);
|
REGISTER_SHARD_PACKET(P_CL2FE_REQ_REGIST_TRANSPORTATION_LOCATION, transportRegisterLocationHandler);
|
@ -19,7 +19,7 @@ struct TransportLocation {
|
|||||||
int npcID, x, y, z;
|
int npcID, x, y, z;
|
||||||
};
|
};
|
||||||
|
|
||||||
namespace TransportManager {
|
namespace Transport {
|
||||||
extern std::map<int32_t, TransportRoute> Routes;
|
extern std::map<int32_t, TransportRoute> Routes;
|
||||||
extern std::map<int32_t, TransportLocation> Locations;
|
extern std::map<int32_t, TransportLocation> Locations;
|
||||||
extern std::map<int32_t, std::queue<WarpLocation>> SkywayPaths; // predefined skyway paths with points
|
extern std::map<int32_t, std::queue<WarpLocation>> SkywayPaths; // predefined skyway paths with points
|
@ -15,7 +15,7 @@ static void vendorBuy(CNSocket* sock, CNPacketData* data) {
|
|||||||
INITSTRUCT(sP_FE2CL_REP_PC_VENDOR_ITEM_BUY_FAIL, failResp);
|
INITSTRUCT(sP_FE2CL_REP_PC_VENDOR_ITEM_BUY_FAIL, failResp);
|
||||||
failResp.iErrorCode = 0;
|
failResp.iErrorCode = 0;
|
||||||
|
|
||||||
ItemManager::Item* itemDat = ItemManager::getItemData(req->Item.iID, req->Item.iType);
|
Items::Item* itemDat = Items::getItemData(req->Item.iID, req->Item.iType);
|
||||||
|
|
||||||
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;
|
||||||
@ -24,7 +24,7 @@ static void vendorBuy(CNSocket* sock, CNPacketData* data) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int itemCost = itemDat->buyPrice * (itemDat->stackSize > 1 ? req->Item.iOpt : 1);
|
int itemCost = itemDat->buyPrice * (itemDat->stackSize > 1 ? req->Item.iOpt : 1);
|
||||||
int slot = ItemManager::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((void*)&failResp, P_FE2CL_REP_PC_VENDOR_ITEM_BUY_FAIL, sizeof(sP_FE2CL_REP_PC_VENDOR_ITEM_BUY_FAIL));
|
||||||
return;
|
return;
|
||||||
@ -77,7 +77,7 @@ static void vendorSell(CNSocket* sock, CNPacketData* data) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
sItemBase* item = &plr->Inven[req->iInvenSlotNum];
|
sItemBase* item = &plr->Inven[req->iInvenSlotNum];
|
||||||
ItemManager::Item* itemData = ItemManager::getItemData(item->iID, item->iType);
|
Items::Item* itemData = Items::getItemData(item->iID, item->iType);
|
||||||
|
|
||||||
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;
|
||||||
@ -171,7 +171,7 @@ static void vendorBuyback(CNSocket* sock, CNPacketData* data) {
|
|||||||
}
|
}
|
||||||
//std::cout << (int)plr->buyback->size() << " items in buyback\n";
|
//std::cout << (int)plr->buyback->size() << " items in buyback\n";
|
||||||
|
|
||||||
ItemManager::Item* itemDat = ItemManager::getItemData(item.iID, item.iType);
|
Items::Item* itemDat = Items::getItemData(item.iID, item.iType);
|
||||||
|
|
||||||
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;
|
||||||
@ -181,7 +181,7 @@ static void vendorBuyback(CNSocket* sock, CNPacketData* data) {
|
|||||||
|
|
||||||
// sell price is used on rebuy. ternary identifies stacked items
|
// sell price is used on rebuy. ternary identifies stacked items
|
||||||
int itemCost = itemDat->sellPrice * (itemDat->stackSize > 1 ? item.iOpt : 1);
|
int itemCost = itemDat->sellPrice * (itemDat->stackSize > 1 ? item.iOpt : 1);
|
||||||
int slot = ItemManager::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((void*)&failResp, P_FE2CL_REP_PC_VENDOR_ITEM_RESTORE_BUY_FAIL, sizeof(sP_FE2CL_REP_PC_VENDOR_ITEM_RESTORE_BUY_FAIL));
|
||||||
return;
|
return;
|
||||||
@ -308,12 +308,12 @@ static void vendorCombineItems(CNSocket* sock, CNPacketData* data) {
|
|||||||
|
|
||||||
sItemBase* itemStats = &plr->Inven[req->iStatItemSlot];
|
sItemBase* itemStats = &plr->Inven[req->iStatItemSlot];
|
||||||
sItemBase* itemLooks = &plr->Inven[req->iCostumeItemSlot];
|
sItemBase* itemLooks = &plr->Inven[req->iCostumeItemSlot];
|
||||||
ItemManager::Item* itemStatsDat = ItemManager::getItemData(itemStats->iID, itemStats->iType);
|
Items::Item* itemStatsDat = Items::getItemData(itemStats->iID, itemStats->iType);
|
||||||
ItemManager::Item* itemLooksDat = ItemManager::getItemData(itemLooks->iID, itemLooks->iType);
|
Items::Item* itemLooksDat = Items::getItemData(itemLooks->iID, itemLooks->iType);
|
||||||
|
|
||||||
// sanity check item and combination entry existence
|
// sanity check item and combination entry existence
|
||||||
if (itemStatsDat == nullptr || itemLooksDat == nullptr
|
if (itemStatsDat == nullptr || itemLooksDat == nullptr
|
||||||
|| ItemManager::CrocPotTable.find(abs(itemStatsDat->level - itemLooksDat->level)) == ItemManager::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((void*)&failResp, P_FE2CL_REP_PC_ITEM_COMBINATION_FAIL, sizeof(sP_FE2CL_REP_PC_ITEM_COMBINATION_FAIL));
|
||||||
return;
|
return;
|
||||||
@ -327,7 +327,7 @@ static void vendorCombineItems(CNSocket* sock, CNPacketData* data) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
CrocPotEntry* recipe = &ItemManager::CrocPotTable[abs(itemStatsDat->level - itemLooksDat->level)];
|
CrocPotEntry* recipe = &Items::CrocPotTable[abs(itemStatsDat->level - itemLooksDat->level)];
|
||||||
int cost = itemStatsDat->buyPrice * recipe->multStats + itemLooksDat->buyPrice * recipe->multLooks;
|
int cost = itemStatsDat->buyPrice * recipe->multStats + itemLooksDat->buyPrice * recipe->multLooks;
|
||||||
float successChance = recipe->base / 100.0f; // base success chance
|
float successChance = recipe->base / 100.0f; // base success chance
|
||||||
|
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
#include "CNStructs.hpp"
|
#include "CNStructs.hpp"
|
||||||
#include "CNShardServer.hpp"
|
#include "CNShardServer.hpp"
|
||||||
|
|
||||||
#include "ItemManager.hpp"
|
#include "Items.hpp"
|
||||||
#include "PlayerManager.hpp"
|
#include "PlayerManager.hpp"
|
||||||
|
|
||||||
struct VendorListing {
|
struct VendorListing {
|
||||||
|
32
src/main.cpp
32
src/main.cpp
@ -3,21 +3,21 @@
|
|||||||
#include "PlayerManager.hpp"
|
#include "PlayerManager.hpp"
|
||||||
#include "PlayerMovement.hpp"
|
#include "PlayerMovement.hpp"
|
||||||
#include "BuiltinCommands.hpp"
|
#include "BuiltinCommands.hpp"
|
||||||
#include "ChatManager.hpp"
|
#include "Buddies.hpp"
|
||||||
#include "CustomCommands.hpp"
|
#include "CustomCommands.hpp"
|
||||||
#include "Combat.hpp"
|
#include "Combat.hpp"
|
||||||
#include "MobAI.hpp"
|
#include "MobAI.hpp"
|
||||||
#include "ItemManager.hpp"
|
#include "Items.hpp"
|
||||||
#include "MissionManager.hpp"
|
#include "Missions.hpp"
|
||||||
#include "NanoManager.hpp"
|
#include "Nanos.hpp"
|
||||||
#include "NPCManager.hpp"
|
#include "NPCManager.hpp"
|
||||||
#include "TransportManager.hpp"
|
#include "Transport.hpp"
|
||||||
#include "BuddyManager.hpp"
|
#include "Buddies.hpp"
|
||||||
#include "db/Database.hpp"
|
#include "db/Database.hpp"
|
||||||
#include "TableData.hpp"
|
#include "TableData.hpp"
|
||||||
#include "GroupManager.hpp"
|
#include "Groups.hpp"
|
||||||
#include "Monitor.hpp"
|
#include "Monitor.hpp"
|
||||||
#include "RacingManager.hpp"
|
#include "Racing.hpp"
|
||||||
#include "Trading.hpp"
|
#include "Trading.hpp"
|
||||||
#include "Email.hpp"
|
#include "Email.hpp"
|
||||||
#include "Vendor.hpp"
|
#include "Vendor.hpp"
|
||||||
@ -101,20 +101,20 @@ int main() {
|
|||||||
PlayerManager::init();
|
PlayerManager::init();
|
||||||
PlayerMovement::init();
|
PlayerMovement::init();
|
||||||
BuiltinCommands::init();
|
BuiltinCommands::init();
|
||||||
ChatManager::init();
|
Buddies::init();
|
||||||
CustomCommands::init();
|
CustomCommands::init();
|
||||||
Combat::init();
|
Combat::init();
|
||||||
MobAI::init();
|
MobAI::init();
|
||||||
ItemManager::init();
|
Items::init();
|
||||||
MissionManager::init();
|
Missions::init();
|
||||||
NanoManager::init();
|
Nanos::init();
|
||||||
NPCManager::init();
|
NPCManager::init();
|
||||||
Vendor::init();
|
Vendor::init();
|
||||||
TransportManager::init();
|
Transport::init();
|
||||||
BuddyManager::init();
|
Buddies::init();
|
||||||
Email::init();
|
Email::init();
|
||||||
GroupManager::init();
|
Groups::init();
|
||||||
RacingManager::init();
|
Racing::init();
|
||||||
Database::open();
|
Database::open();
|
||||||
Trading::init();
|
Trading::init();
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user