mirror of
https://github.com/OpenFusionProject/OpenFusion.git
synced 2024-11-04 22:40:05 +00:00
Merge pull request #124 from gsemaj/bugfix1
Fixed crash on killing summoned NPC
This commit is contained in:
commit
600c26024b
@ -15,6 +15,7 @@
|
||||
#endif
|
||||
|
||||
std::map<int32_t, Mob*> MobManager::Mobs;
|
||||
std::queue<int32_t> MobManager::RemovalQueue;
|
||||
|
||||
void MobManager::init() {
|
||||
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));
|
||||
|
||||
// if it was summoned, remove it permanently
|
||||
// if it was summoned, mark it for removal
|
||||
if (mob->summoned) {
|
||||
std::cout << "[INFO] Deallocating killed summoned mob" << std::endl;
|
||||
NPCManager::destroyNPC(mob->appearanceData.iNPC_ID);
|
||||
std::cout << "[INFO] Queueing killed summoned mob for removal" << std::endl;
|
||||
RemovalQueue.push(mob->appearanceData.iNPC_ID);
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -452,6 +453,7 @@ void MobManager::retreatStep(Mob *mob, time_t currTime) {
|
||||
}
|
||||
|
||||
void MobManager::step(CNServer *serv, time_t currTime) {
|
||||
|
||||
for (auto& pair : Mobs) {
|
||||
int x = pair.second->appearanceData.iX;
|
||||
int y = pair.second->appearanceData.iY;
|
||||
@ -487,6 +489,12 @@ void MobManager::step(CNServer *serv, time_t currTime) {
|
||||
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;
|
||||
|
||||
NPCManager::sendToViewable(mob, (void*)&respbuf, P_FE2CL_CHAR_TIME_BUFF_TIME_TICK, resplen);
|
||||
}
|
||||
}
|
||||
|
@ -8,6 +8,7 @@
|
||||
#include "contrib/JSON.hpp"
|
||||
|
||||
#include <map>
|
||||
#include <queue>
|
||||
|
||||
enum class MobState {
|
||||
INACTIVE,
|
||||
@ -83,6 +84,7 @@ struct Mob : public BaseNPC {
|
||||
|
||||
namespace MobManager {
|
||||
extern std::map<int32_t, Mob*> Mobs;
|
||||
extern std::queue<int32_t> RemovalQueue;
|
||||
|
||||
void init();
|
||||
void step(CNServer*, time_t);
|
||||
|
Loading…
Reference in New Issue
Block a user