Loading...   

  • Created By Uleat On: 07:46 PM August 23, 2014
  • Link

 zone/entity.cpp                  |  2 +-
 zone/lua_general.cpp             | 14 +++++++-------
 zone/mob_ai.cpp                  | 28 +++++++++++++++++++++++++++-
 zone/quest_parser_collection.cpp |  4 ++--
 zone/zone.cpp                    | 13 +++++++++++++
 5 files changed, 50 insertions(+), 11 deletions(-)

diff --git a/zone/entity.cpp b/zone/entity.cpp
index 469bf81..6fc2a6a 100644
--- a/zone/entity.cpp
+++ b/zone/entity.cpp
@@ -1598,7 +1598,7 @@ Corpse *EntityList::GetCorpseByName(const char *name)
 
 Spawn2 *EntityList::GetSpawnByID(uint32 id)
 {
-	if (!zone)
+	if (!zone)// || !zone->IsLoaded())
 		return nullptr;
 
 	LinkedListIterator<Spawn2 *> iterator(zone->spawn2_list);
diff --git a/zone/lua_general.cpp b/zone/lua_general.cpp
index 878f822..2a589ef 100644
--- a/zone/lua_general.cpp
+++ b/zone/lua_general.cpp
@@ -812,35 +812,35 @@ Lua_EntityList lua_get_entity_list() {
 }
 
 int lua_get_zone_id() {
-	if(!zone)
+	if(!zone)// || !zone->IsLoaded())
 		return 0;
 
 	return zone->GetZoneID();
 }
 
 const char *lua_get_zone_long_name() {
-	if(!zone)
+	if(!zone)// || !zone->IsLoaded())
 		return "";
 
 	return zone->GetLongName();
 }
 
 const char *lua_get_zone_short_name() {
-	if(!zone)
+	if(!zone)// || !zone->IsLoaded())
 		return "";
 
 	return zone->GetShortName();
 }
 
 int lua_get_zone_instance_id() {
-	if(!zone)
+	if(!zone)// || !zone->IsLoaded())
 		return 0;
 
 	return zone->GetInstanceID();
 }
 
 int lua_get_zone_instance_version() {
-	if(!zone)
+	if(!zone)// || !zone->IsLoaded())
 		return 0;
 
 	return zone->GetInstanceVersion();
@@ -862,7 +862,7 @@ luabind::adl::object lua_get_characters_in_instance(lua_State *L, uint16 instanc
 }
 
 int lua_get_zone_weather() {
-	if(!zone)
+	if(!zone)// || !zone->IsLoaded())
 		return 0;
 
 	return zone->zone_weather;
@@ -910,7 +910,7 @@ void lua_remove_spawn_point(uint32 spawn2_id) {
 }
 
 void lua_add_spawn_point(luabind::adl::object table) {
-	if(!zone)
+	if(!zone)// || !zone->IsLoaded())
 		return;
 
 	if(luabind::type(table) == LUA_TTABLE) {
diff --git a/zone/mob_ai.cpp b/zone/mob_ai.cpp
index 87fc2ea..13eccb7 100644
--- a/zone/mob_ai.cpp
+++ b/zone/mob_ai.cpp
@@ -545,9 +545,35 @@ void Mob::AI_Stop() {
 	safe_delete(AIthink_timer);
 	safe_delete(AIwalking_timer);
 	safe_delete(AImovement_timer);
-	safe_delete(AItarget_check_timer)
+	safe_delete(AItarget_check_timer);
 	safe_delete(AIscanarea_timer);
 	safe_delete(AIfeignremember_timer);
+
+	safe_delete(PathingLOSCheckTimer);
+	safe_delete(PathingRouteUpdateTimerShort);
+	safe_delete(PathingRouteUpdateTimerLong);
+
+	attack_timer.Disable();
+	attack_dw_timer.Disable();
+	ranged_timer.Disable();
+	tic_timer.Disable();
+	mana_timer.Disable();
+	spellend_timer.Disable();
+	projectile_timer.Disable();
+	rewind_timer.Disable();
+	bindwound_timer.Disable();
+	stunned_timer.Disable();
+	spun_timer.Disable();
+	bardsong_timer.Disable();
+	gravity_timer.Disable();
+	viral_timer.Disable();
+	flee_timer.Disable();
+
+	for (int sat = 0; sat < MAX_SPECIAL_ATTACK; ++sat) {
+		if (SpecialAbilities[sat].timer)
+			SpecialAbilities[sat].timer->Disable();
+	}
+
 	hate_list.Wipe();
 }
 
diff --git a/zone/quest_parser_collection.cpp b/zone/quest_parser_collection.cpp
index 376c121..590b730 100644
--- a/zone/quest_parser_collection.cpp
+++ b/zone/quest_parser_collection.cpp
@@ -601,8 +601,8 @@ QuestInterface *QuestParserCollection::GetQIByNPCQuest(uint32 npcid, std::string
 
 QuestInterface *QuestParserCollection::GetQIByPlayerQuest(std::string &filename) {
 
-	if(!zone)
-	return nullptr;
+	if(!zone || !zone->IsLoaded())
+		return nullptr;
 
 	//first look for /quests/zone/player_v[instance_version].ext (precedence)
 	filename = "quests/";
diff --git a/zone/zone.cpp b/zone/zone.cpp
index a302642..77ac440 100644
--- a/zone/zone.cpp
+++ b/zone/zone.cpp
@@ -718,11 +718,24 @@ void Zone::DBAWComplete(uint8 workpt_b1, DBAsyncWork* dbaw) {
 	}
 }
 
+bool Zone::IsLoaded() {
+	return ZoneLoaded;
+}
+
 void Zone::Shutdown(bool quite)
 {
 	if (!ZoneLoaded)
 		return;
 
+	std::list<Mob*> mob_list;
+	entity_list.GetMobList(mob_list);
+	std::list<Mob*>::iterator mob_itr = mob_list.begin();
+	while (mob_itr != mob_list.end()) {
+		Mob* mob_inst = *mob_itr;
+		mob_inst->AI_Stop();
+		++mob_itr;
+	}
+
 	std::map<uint32,NPCType *>::iterator itr;
 	while(zone->npctable.size()) {
 		itr=zone->npctable.begin();

Raw Paste Data