diff --git a/src/Abilities.cpp b/src/Abilities.cpp index 721114b..27f36b9 100644 --- a/src/Abilities.cpp +++ b/src/Abilities.cpp @@ -142,7 +142,7 @@ bool doDebuff(CNSocket *sock, sSkillResult_Buff *respdata, int i, int32_t target } BaseNPC* npc = NPCManager::NPCs[targetID]; - if (npc->type != EntityType::MOB) { + if (npc->kind != EntityType::MOB) { std::cout << "[WARN] doDebuff: NPC is not a mob" << std::endl; return false; } @@ -213,7 +213,7 @@ bool doDamageNDebuff(CNSocket *sock, sSkillResult_Damage_N_Debuff *respdata, int } BaseNPC* npc = NPCManager::NPCs[targetID]; - if (npc->type != EntityType::MOB) { + if (npc->kind != EntityType::MOB) { std::cout << "[WARN] doDamageNDebuff: NPC is not a mob" << std::endl; return false; } @@ -281,7 +281,7 @@ bool doDamage(CNSocket *sock, sSkillResult_Damage *respdata, int i, int32_t targ } BaseNPC* npc = NPCManager::NPCs[targetID]; - if (npc->type != EntityType::MOB) { + if (npc->kind != EntityType::MOB) { std::cout << "[WARN] doDamage: NPC is not a mob" << std::endl; return false; } @@ -337,7 +337,7 @@ bool doLeech(CNSocket *sock, sSkillResult_Heal_HP *healdata, int i, int32_t targ } BaseNPC* npc = NPCManager::NPCs[targetID]; - if (npc->type != EntityType::MOB) { + if (npc->kind != EntityType::MOB) { std::cout << "[WARN] doLeech: NPC is not a mob" << std::endl; return false; } @@ -468,7 +468,7 @@ bool doHeal(Mob* mob, sSkillResult_Heal_HP* respdata, int i, int32_t targetID, i } BaseNPC* npc = NPCManager::NPCs[targetID]; - if (npc->type != EntityType::MOB) { + if (npc->kind != EntityType::MOB) { std::cout << "[WARN] doHeal: NPC is not a mob" << std::endl; return false; } diff --git a/src/Chunking.cpp b/src/Chunking.cpp index 3d3330a..fcc9150 100644 --- a/src/Chunking.cpp +++ b/src/Chunking.cpp @@ -275,7 +275,7 @@ void Chunking::createInstance(uint64_t instanceID) { BaseNPC* baseNPC = (BaseNPC*)ref.getEntity(); // make a copy of each NPC in the template chunks and put them in the new instance - if (baseNPC->type == EntityType::MOB) { + if (baseNPC->kind == EntityType::MOB) { if (((Mob*)baseNPC)->groupLeader != 0 && ((Mob*)baseNPC)->groupLeader != npcID) continue; // follower; don't copy individually diff --git a/src/Combat.cpp b/src/Combat.cpp index 1320be7..d95459b 100644 --- a/src/Combat.cpp +++ b/src/Combat.cpp @@ -105,7 +105,7 @@ static void pcAttackNpcs(CNSocket *sock, CNPacketData *data) { BaseNPC* npc = NPCManager::NPCs[targets[i]]; - if (npc->type != EntityType::MOB) { + if (npc->kind != EntityType::MOB) { std::cout << "[WARN] pcAttackNpcs: NPC is not a mob" << std::endl; return; } @@ -477,7 +477,7 @@ static void pcAttackChars(CNSocket *sock, CNPacketData *data) { } BaseNPC* npc = NPCManager::NPCs[pktdata[i * 2]]; - if (npc->type != EntityType::MOB) { + if (npc->kind != EntityType::MOB) { std::cout << "[WARN] pcAttackChars: NPC is not a mob" << std::endl; return; } @@ -687,7 +687,7 @@ static void projectileHit(CNSocket* sock, CNPacketData* data) { } BaseNPC* npc = NPCManager::NPCs[pktdata[i]]; - if (npc->type != EntityType::MOB) { + if (npc->kind != EntityType::MOB) { std::cout << "[WARN] projectileHit: NPC is not a mob" << std::endl; return; } diff --git a/src/CustomCommands.cpp b/src/CustomCommands.cpp index 06d9d69..b277328 100644 --- a/src/CustomCommands.cpp +++ b/src/CustomCommands.cpp @@ -283,10 +283,10 @@ static void unsummonWCommand(std::string full, std::vector& args, C return; } - if (NPCManager::NPCs.find(npc->appearanceData.iNPC_ID) != NPCManager::NPCs.end() && NPCManager::NPCs[npc->appearanceData.iNPC_ID]->type == EntityType::MOB) { + if (NPCManager::NPCs.find(npc->appearanceData.iNPC_ID) != NPCManager::NPCs.end() && NPCManager::NPCs[npc->appearanceData.iNPC_ID]->kind == EntityType::MOB) { int leadId = ((Mob*)npc)->groupLeader; if (leadId != 0) { - if (NPCManager::NPCs.find(leadId) == NPCManager::NPCs.end() || NPCManager::NPCs[leadId]->type != EntityType::MOB) { + if (NPCManager::NPCs.find(leadId) == NPCManager::NPCs.end() || NPCManager::NPCs[leadId]->kind != EntityType::MOB) { std::cout << "[WARN] unsummonW: leader not found!" << std::endl; } Mob* leadNpc = (Mob*)NPCManager::NPCs[leadId]; @@ -294,7 +294,7 @@ static void unsummonWCommand(std::string full, std::vector& args, C if (leadNpc->groupMember[i] == 0) break; - if (NPCManager::NPCs.find(leadNpc->groupMember[i]) == NPCManager::NPCs.end() || NPCManager::NPCs[leadNpc->groupMember[i]]->type != EntityType::MOB) { + if (NPCManager::NPCs.find(leadNpc->groupMember[i]) == NPCManager::NPCs.end() || NPCManager::NPCs[leadNpc->groupMember[i]]->kind != EntityType::MOB) { std::cout << "[WARN] unsommonW: leader can't find a group member!" << std::endl; continue; } @@ -324,7 +324,7 @@ static void toggleAiCommand(std::string full, std::vector& args, CN // return all mobs to their spawn points for (auto& pair : NPCManager::NPCs) { - if (pair.second->type != EntityType::MOB) + if (pair.second->kind != EntityType::MOB) continue; Mob* mob = (Mob*)pair.second; @@ -609,7 +609,7 @@ static void summonGroupCommand(std::string full, std::vector& args, } BaseNPC *npc = NPCManager::summonNPC(x, y, z, plr->instanceID, type, wCommand); - if (team == 2 && i > 0 && npc->type == EntityType::MOB) { + if (team == 2 && i > 0 && npc->kind == EntityType::MOB) { leadNpc->groupMember[i-1] = npc->appearanceData.iNPC_ID; Mob* mob = (Mob*)NPCManager::NPCs[npc->appearanceData.iNPC_ID]; mob->groupLeader = leadNpc->appearanceData.iNPC_ID; @@ -624,7 +624,7 @@ static void summonGroupCommand(std::string full, std::vector& args, if (PLAYERID(plr->instanceID) != 0) { npc = NPCManager::summonNPC(plr->x, plr->y, plr->z, plr->instanceID, type, wCommand, true); - if (team == 2 && i > 0 && npc->type == EntityType::MOB) { + if (team == 2 && i > 0 && npc->kind == EntityType::MOB) { leadNpc->groupMember[i-1] = npc->appearanceData.iNPC_ID; Mob* mob = (Mob*)NPCManager::NPCs[npc->appearanceData.iNPC_ID]; mob->groupLeader = leadNpc->appearanceData.iNPC_ID; @@ -639,7 +639,7 @@ static void summonGroupCommand(std::string full, std::vector& args, Chat::sendServerMessage(sock, "/summonGroup(W): placed mob with type: " + std::to_string(type) + ", id: " + std::to_string(npc->appearanceData.iNPC_ID)); - if (i == 0 && team == 2 && npc->type == EntityType::MOB) { + if (i == 0 && team == 2 && npc->kind == EntityType::MOB) { type = type2; leadNpc = (Mob*)NPCManager::NPCs[npc->appearanceData.iNPC_ID]; leadNpc->groupLeader = leadNpc->appearanceData.iNPC_ID; @@ -675,7 +675,7 @@ static void whoisCommand(std::string full, std::vector& args, CNSoc Chat::sendServerMessage(sock, "[WHOIS] Type: " + std::to_string(npc->appearanceData.iNPCType)); Chat::sendServerMessage(sock, "[WHOIS] HP: " + std::to_string(npc->appearanceData.iHP)); Chat::sendServerMessage(sock, "[WHOIS] CBF: " + std::to_string(npc->appearanceData.iConditionBitFlag)); - Chat::sendServerMessage(sock, "[WHOIS] EntityType: " + std::to_string((int)npc->type)); + Chat::sendServerMessage(sock, "[WHOIS] EntityType: " + std::to_string((int)npc->kind)); Chat::sendServerMessage(sock, "[WHOIS] X: " + std::to_string(npc->x)); Chat::sendServerMessage(sock, "[WHOIS] Y: " + std::to_string(npc->y)); Chat::sendServerMessage(sock, "[WHOIS] Z: " + std::to_string(npc->z)); diff --git a/src/Eggs.cpp b/src/Eggs.cpp index 5b5a79c..52fa35e 100644 --- a/src/Eggs.cpp +++ b/src/Eggs.cpp @@ -124,7 +124,7 @@ static void eggStep(CNServer* serv, time_t currTime) { // check dead eggs and eggs in inactive chunks for (auto npc : NPCManager::NPCs) { - if (npc.second->type != EntityType::EGG) + if (npc.second->kind != EntityType::EGG) continue; auto egg = (Egg*)npc.second; @@ -163,7 +163,7 @@ static void eggPickup(CNSocket* sock, CNPacketData* data) { return; } auto egg = (Egg*)eggRef.getEntity(); - if (egg->type != EntityType::EGG) { + if (egg->kind != EntityType::EGG) { std::cout << "[WARN] Player tried to open something other than an?!" << std::endl; return; } diff --git a/src/Entities.cpp b/src/Entities.cpp index 973a78c..ea52eba 100644 --- a/src/Entities.cpp +++ b/src/Entities.cpp @@ -20,7 +20,7 @@ EntityRef::EntityRef(int32_t i) { id = i; assert(NPCManager::NPCs.find(id) != NPCManager::NPCs.end()); - type = NPCManager::NPCs[id]->type; + type = NPCManager::NPCs[id]->kind; } bool EntityRef::isValid() const { diff --git a/src/Entities.hpp b/src/Entities.hpp index 4975279..a231541 100644 --- a/src/Entities.hpp +++ b/src/Entities.hpp @@ -17,7 +17,7 @@ enum class EntityType : uint8_t { }; struct Entity { - EntityType type = EntityType::INVALID; + EntityType kind = EntityType::INVALID; int x = 0, y = 0, z = 0; uint64_t instanceID = 0; ChunkPos chunkPos = {}; @@ -129,7 +129,7 @@ struct Egg : public BaseNPC { Egg(int x, int y, int z, uint64_t iID, int t, int32_t id, bool summon) : BaseNPC(x, y, z, 0, iID, t, id) { summoned = summon; - type = EntityType::EGG; + kind = EntityType::EGG; } virtual bool isAlive() override { return !dead; } @@ -142,7 +142,7 @@ struct Egg : public BaseNPC { struct Bus : public BaseNPC { Bus(int x, int y, int z, int angle, uint64_t iID, int t, int id) : BaseNPC(x, y, z, angle, iID, t, id) { - type = EntityType::BUS; + kind = EntityType::BUS; loopingPath = true; } diff --git a/src/MobAI.cpp b/src/MobAI.cpp index 21a05da..562ccce 100644 --- a/src/MobAI.cpp +++ b/src/MobAI.cpp @@ -58,13 +58,13 @@ void MobAI::clearDebuff(Mob *mob) { } void MobAI::followToCombat(Mob *mob) { - if (NPCManager::NPCs.find(mob->groupLeader) != NPCManager::NPCs.end() && NPCManager::NPCs[mob->groupLeader]->type == EntityType::MOB) { + if (NPCManager::NPCs.find(mob->groupLeader) != NPCManager::NPCs.end() && NPCManager::NPCs[mob->groupLeader]->kind == EntityType::MOB) { Mob* leadMob = (Mob*)NPCManager::NPCs[mob->groupLeader]; for (int i = 0; i < 4; i++) { if (leadMob->groupMember[i] == 0) break; - if (NPCManager::NPCs.find(leadMob->groupMember[i]) == NPCManager::NPCs.end() || NPCManager::NPCs[leadMob->groupMember[i]]->type != EntityType::MOB) { + if (NPCManager::NPCs.find(leadMob->groupMember[i]) == NPCManager::NPCs.end() || NPCManager::NPCs[leadMob->groupMember[i]]->kind != EntityType::MOB) { std::cout << "[WARN] roamingStep: leader can't find a group member!" << std::endl; continue; } @@ -84,7 +84,7 @@ void MobAI::followToCombat(Mob *mob) { } void MobAI::groupRetreat(Mob *mob) { - if (NPCManager::NPCs.find(mob->groupLeader) == NPCManager::NPCs.end() || NPCManager::NPCs[mob->groupLeader]->type != EntityType::MOB) + if (NPCManager::NPCs.find(mob->groupLeader) == NPCManager::NPCs.end() || NPCManager::NPCs[mob->groupLeader]->kind != EntityType::MOB) return; Mob* leadMob = (Mob*)NPCManager::NPCs[mob->groupLeader]; @@ -92,7 +92,7 @@ void MobAI::groupRetreat(Mob *mob) { if (leadMob->groupMember[i] == 0) break; - if (NPCManager::NPCs.find(leadMob->groupMember[i]) == NPCManager::NPCs.end() || NPCManager::NPCs[leadMob->groupMember[i]]->type != EntityType::MOB) { + if (NPCManager::NPCs.find(leadMob->groupMember[i]) == NPCManager::NPCs.end() || NPCManager::NPCs[leadMob->groupMember[i]]->kind != EntityType::MOB) { std::cout << "[WARN] roamingStep: leader can't find a group member!" << std::endl; continue; } @@ -479,7 +479,7 @@ static void deadStep(Mob *mob, time_t currTime) { // if mob is a group leader/follower, spawn where the group is. if (mob->groupLeader != 0) { - if (NPCManager::NPCs.find(mob->groupLeader) != NPCManager::NPCs.end() && NPCManager::NPCs[mob->groupLeader]->type == EntityType::MOB) { + if (NPCManager::NPCs.find(mob->groupLeader) != NPCManager::NPCs.end() && NPCManager::NPCs[mob->groupLeader]->kind == EntityType::MOB) { Mob* leaderMob = (Mob*)NPCManager::NPCs[mob->groupLeader]; mob->x = leaderMob->x + mob->offsetX; mob->y = leaderMob->y + mob->offsetY; @@ -721,7 +721,7 @@ static void roamingStep(Mob *mob, time_t currTime) { if (mob->groupMember[i] == 0) break; - if (NPCManager::NPCs.find(mob->groupMember[i]) == NPCManager::NPCs.end() || NPCManager::NPCs[mob->groupMember[i]]->type != EntityType::MOB) { + if (NPCManager::NPCs.find(mob->groupMember[i]) == NPCManager::NPCs.end() || NPCManager::NPCs[mob->groupMember[i]]->kind != EntityType::MOB) { std::cout << "[WARN] roamingStep: leader can't find a group member!" << std::endl; continue; } @@ -782,7 +782,7 @@ static void retreatStep(Mob *mob, time_t currTime) { } void MobAI::step(CombatNPC *npc, time_t currTime) { - assert(npc->type == EntityType::MOB); + assert(npc->kind == EntityType::MOB); auto mob = (Mob*)npc; if (mob->playersInView < 0) diff --git a/src/MobAI.hpp b/src/MobAI.hpp index c526561..452f6c6 100644 --- a/src/MobAI.hpp +++ b/src/MobAI.hpp @@ -77,7 +77,7 @@ struct Mob : public CombatNPC { // NOTE: there appear to be discrepancies in the dump appearanceData.iHP = maxHealth; - type = EntityType::MOB; + kind = EntityType::MOB; _stepAI = MobAI::step; } diff --git a/src/NPCManager.cpp b/src/NPCManager.cpp index 901bfb3..eb262d9 100644 --- a/src/NPCManager.cpp +++ b/src/NPCManager.cpp @@ -352,7 +352,7 @@ void NPCManager::queueNPCRemoval(int32_t id) { static void step(CNServer *serv, time_t currTime) { for (auto& pair : NPCs) { - if (pair.second->type != EntityType::COMBAT_NPC && pair.second->type != EntityType::MOB) + if (pair.second->kind != EntityType::COMBAT_NPC && pair.second->kind != EntityType::MOB) continue; auto npc = (CombatNPC*)pair.second; diff --git a/src/Player.hpp b/src/Player.hpp index baa77b1..7821593 100644 --- a/src/Player.hpp +++ b/src/Player.hpp @@ -85,7 +85,7 @@ struct Player : public Entity { time_t lastShot = 0; std::vector buyback = {}; - Player() { type = EntityType::PLAYER; } + Player() { kind = EntityType::PLAYER; } virtual void enterIntoViewOf(CNSocket *sock) override; virtual void disappearFromViewOf(CNSocket *sock) override; diff --git a/src/TableData.cpp b/src/TableData.cpp index 0667093..99ff117 100644 --- a/src/TableData.cpp +++ b/src/TableData.cpp @@ -1176,7 +1176,7 @@ void TableData::flush() { continue; int x, y, z; - if (npc->type == EntityType::MOB) { + if (npc->kind == EntityType::MOB) { Mob *m = (Mob*)npc; x = m->spawnX; y = m->spawnY; @@ -1209,7 +1209,7 @@ void TableData::flush() { int x, y, z; std::vector followers; - if (npc->type == EntityType::MOB) { + if (npc->kind == EntityType::MOB) { Mob* m = (Mob*)npc; x = m->spawnX; y = m->spawnY; @@ -1221,7 +1221,7 @@ void TableData::flush() { // add follower data to vector; go until OOB or until follower ID is 0 for (int i = 0; i < 4 && m->groupMember[i] > 0; i++) { - if (NPCManager::NPCs.find(m->groupMember[i]) == NPCManager::NPCs.end() || NPCManager::NPCs[m->groupMember[i]]->type != EntityType::MOB) { + if (NPCManager::NPCs.find(m->groupMember[i]) == NPCManager::NPCs.end() || NPCManager::NPCs[m->groupMember[i]]->kind != EntityType::MOB) { std::cout << "[WARN] Follower with ID " << m->groupMember[i] << " not found; skipping\n"; continue; } diff --git a/src/Transport.cpp b/src/Transport.cpp index 0fe4f10..7ed5836 100644 --- a/src/Transport.cpp +++ b/src/Transport.cpp @@ -257,13 +257,13 @@ static void stepNPCPathing() { } // skip if not simulating mobs - if (npc->type == EntityType::MOB && !MobAI::simulateMobs) { + if (npc->kind == EntityType::MOB && !MobAI::simulateMobs) { it++; continue; } // do not roam if not roaming - if (npc->type == EntityType::MOB && ((Mob*)npc)->state != MobState::ROAMING) { + if (npc->kind == EntityType::MOB && ((Mob*)npc)->state != MobState::ROAMING) { it++; continue; } @@ -279,7 +279,7 @@ static void stepNPCPathing() { NPCManager::updateNPCPosition(npc->appearanceData.iNPC_ID, point.x, point.y, point.z, npc->instanceID, npc->appearanceData.iAngle); // TODO: move walking logic into Entity stack - switch (npc->type) { + switch (npc->kind) { case EntityType::BUS: INITSTRUCT(sP_FE2CL_TRANSPORTATION_MOVE, busMove); @@ -385,7 +385,7 @@ NPCPath* Transport::findApplicablePath(int32_t id, int32_t type, int taskID) { void Transport::constructPathNPC(int32_t id, NPCPath* path) { BaseNPC* npc = NPCManager::NPCs[id]; - if (npc->type == EntityType::MOB) + if (npc->kind == EntityType::MOB) ((Mob*)(npc))->staticPath = true; npc->loopingPath = path->isLoop;