[WIP] Rename Entity.type -> Entity.kind

This commit is contained in:
gsemaj 2021-06-20 14:12:40 -04:00
parent 32db574700
commit 7ab01b098d
13 changed files with 40 additions and 40 deletions

View File

@ -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;
}

View File

@ -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

View File

@ -114,7 +114,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;
}
@ -486,7 +486,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;
}
@ -696,7 +696,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;
}

View File

@ -283,10 +283,10 @@ static void unsummonWCommand(std::string full, std::vector<std::string>& 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<std::string>& 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<std::string>& 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<std::string>& 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<std::string>& 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<std::string>& 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<std::string>& 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));

View File

@ -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;
}

View File

@ -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 {

View File

@ -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;
}

View File

@ -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)

View File

@ -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;
}

View File

@ -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;

View File

@ -85,7 +85,7 @@ struct Player : public Entity {
time_t lastShot = 0;
std::vector<sItemBase> buyback = {};
Player() { type = EntityType::PLAYER; }
Player() { kind = EntityType::PLAYER; }
virtual void enterIntoViewOf(CNSocket *sock) override;
virtual void disappearFromViewOf(CNSocket *sock) override;

View File

@ -1226,7 +1226,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;
@ -1259,7 +1259,7 @@ void TableData::flush() {
int x, y, z;
std::vector<Mob*> followers;
if (npc->type == EntityType::MOB) {
if (npc->kind == EntityType::MOB) {
Mob* m = (Mob*)npc;
x = m->spawnX;
y = m->spawnY;
@ -1271,7 +1271,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;
}

View File

@ -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;