Browse Source

Zone based expansion flag and preinit_zone_script LUA function for ZoneScripts

Part of Issue #104
Image 3 years ago
parent
commit
8d06858971
2 changed files with 15 additions and 0 deletions
  1. 11 0
      EQ2/source/WorldServer/zoneserver.cpp
  2. 4 0
      EQ2/source/WorldServer/zoneserver.h

+ 11 - 0
EQ2/source/WorldServer/zoneserver.cpp

@@ -150,6 +150,7 @@ ZoneServer::ZoneServer(const char* name) {
 	dawn_hour = 0;
 	dawn_minute = 0;
 	reloading_spellprocess = false;
+	expansion_flag = 0;
 	MMasterZoneLock = new CriticalSection(MUTEX_ATTRIBUTE_RECURSIVE);
 	
 	Grid = nullptr;
@@ -1241,6 +1242,16 @@ bool ZoneServer::Process()
 	{
 #endif
 		if (LoadingData) {
+			if (lua_interface) {
+				string tmpScript("ZoneScripts/");
+				tmpScript.append(GetZoneName());
+				tmpScript.append(".lua");
+				struct stat buffer;
+				bool fileExists = (stat(tmpScript.c_str(), &buffer) == 0);
+				if (fileExists)
+					lua_interface->RunZoneScript(tmpScript.c_str(), "preinit_zone_script", this);
+			}
+
 			while (zoneID == 0) { //this is loaded by world
 				Sleep(10);
 			}

+ 4 - 0
EQ2/source/WorldServer/zoneserver.h

@@ -550,6 +550,9 @@ public:
 	void	SetWeatherPattern(int8 val) { weather_pattern = val; }
 	void	SetWeatherLastChangedTime(int32 val) { weather_last_changed_time = val; }
 
+	int32	GetExpansionFlag() { return expansion_flag; }
+	void	SetExpansionFlag(int32 val) { expansion_flag = val; }
+
 	void	RemoveClientImmediately(Client* client);
 
 	void	ClearHate(Entity* entity);
@@ -825,6 +828,7 @@ private:
 	int		dusk_minute;
 	int		dawn_minute;
 	int32	spawn_delete_timer;
+	int32	expansion_flag;
 	map<int16, PacketStruct*> versioned_pos_structs;
 	map<int16, PacketStruct*> versioned_info_structs;
 	map<int16, PacketStruct*> versioned_vis_structs;