mirror of
https://github.com/OpenFusionProject/OpenFusion.git
synced 2024-11-22 13:30:06 +00:00
Fixed crash on killing summoned NPC
This commit is contained in:
parent
4cd7b7cb53
commit
3c734e3e76
@ -15,6 +15,7 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
std::map<int32_t, Mob*> MobManager::Mobs;
|
std::map<int32_t, Mob*> MobManager::Mobs;
|
||||||
|
std::queue<int32_t> MobManager::RemovalQueue;
|
||||||
|
|
||||||
void MobManager::init() {
|
void MobManager::init() {
|
||||||
REGISTER_SHARD_TIMER(step, 200);
|
REGISTER_SHARD_TIMER(step, 200);
|
||||||
@ -241,10 +242,10 @@ void MobManager::deadStep(Mob *mob, time_t currTime) {
|
|||||||
|
|
||||||
NPCManager::sendToViewable(mob, &pkt, P_FE2CL_NPC_EXIT, sizeof(sP_FE2CL_NPC_EXIT));
|
NPCManager::sendToViewable(mob, &pkt, P_FE2CL_NPC_EXIT, sizeof(sP_FE2CL_NPC_EXIT));
|
||||||
|
|
||||||
// if it was summoned, remove it permanently
|
// if it was summoned, mark it for removal
|
||||||
if (mob->summoned) {
|
if (mob->summoned) {
|
||||||
std::cout << "[INFO] Deallocating killed summoned mob" << std::endl;
|
std::cout << "[INFO] Queueing killed summoned mob for removal" << std::endl;
|
||||||
NPCManager::destroyNPC(mob->appearanceData.iNPC_ID);
|
RemovalQueue.push(mob->appearanceData.iNPC_ID);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -452,6 +453,7 @@ void MobManager::retreatStep(Mob *mob, time_t currTime) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void MobManager::step(CNServer *serv, time_t currTime) {
|
void MobManager::step(CNServer *serv, time_t currTime) {
|
||||||
|
|
||||||
for (auto& pair : Mobs) {
|
for (auto& pair : Mobs) {
|
||||||
int x = pair.second->appearanceData.iX;
|
int x = pair.second->appearanceData.iX;
|
||||||
int y = pair.second->appearanceData.iY;
|
int y = pair.second->appearanceData.iY;
|
||||||
@ -487,6 +489,12 @@ void MobManager::step(CNServer *serv, time_t currTime) {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// deallocate all NPCs queued for removal
|
||||||
|
while (RemovalQueue.size() > 0) {
|
||||||
|
NPCManager::destroyNPC(RemovalQueue.front());
|
||||||
|
RemovalQueue.pop();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -772,4 +780,4 @@ void MobManager::resendMobHP(Mob *mob) {
|
|||||||
heal->iHP = mob->appearanceData.iHP;
|
heal->iHP = mob->appearanceData.iHP;
|
||||||
|
|
||||||
NPCManager::sendToViewable(mob, (void*)&respbuf, P_FE2CL_CHAR_TIME_BUFF_TIME_TICK, resplen);
|
NPCManager::sendToViewable(mob, (void*)&respbuf, P_FE2CL_CHAR_TIME_BUFF_TIME_TICK, resplen);
|
||||||
}
|
}
|
||||||
|
@ -8,6 +8,7 @@
|
|||||||
#include "contrib/JSON.hpp"
|
#include "contrib/JSON.hpp"
|
||||||
|
|
||||||
#include <map>
|
#include <map>
|
||||||
|
#include <queue>
|
||||||
|
|
||||||
enum class MobState {
|
enum class MobState {
|
||||||
INACTIVE,
|
INACTIVE,
|
||||||
@ -83,6 +84,7 @@ struct Mob : public BaseNPC {
|
|||||||
|
|
||||||
namespace MobManager {
|
namespace MobManager {
|
||||||
extern std::map<int32_t, Mob*> Mobs;
|
extern std::map<int32_t, Mob*> Mobs;
|
||||||
|
extern std::queue<int32_t> RemovalQueue;
|
||||||
|
|
||||||
void init();
|
void init();
|
||||||
void step(CNServer*, time_t);
|
void step(CNServer*, time_t);
|
||||||
|
Loading…
Reference in New Issue
Block a user