Emagi 1 vuosi sitten
vanhempi
commit
3dcf790bff

+ 0 - 8
EQ2/source/WorldServer/LuaFunctions.cpp

@@ -575,16 +575,8 @@ int EQ2Emu_lua_GetSpawnListBySpawnID(lua_State* state) {
 				lua_interface->SetSpawnValue(state, spawns.at(i));
 				lua_rawseti(state, newTable, i + 1);
 			}
-			
-			printf("Spawns available %u\n", spawns.size());
 			return 1;
 		}
-		else {
-			printf("Spawns available 0\n");
-		}
-	}
-	else {
-		printf("NO SPAWN!!!\n");
 	}
 	return 0;
 }

+ 24 - 6
EQ2/source/WorldServer/client.cpp

@@ -158,7 +158,7 @@ Client::Client(EQStream* ieqs) : underworld_cooldown_timer(5000), pos_update(125
 	if (world.GetServerStatisticValue(STAT_SERVER_MOST_CONNECTIONS) < numclients)
 		world.UpdateServerStatistic(STAT_SERVER_MOST_CONNECTIONS, numclients, true);
 	remove_from_list = false;
-	new_client_login = false;
+	new_client_login = NewLoginState::LOGIN_NONE;
 	UpdateWindowTitle(0);
 	num_active_failures = 0;
 	player = new Player();
@@ -3100,11 +3100,24 @@ bool Client::Process(bool zone_process) {
 		return true;
 	}
 
-	if (new_client_login) {
-		LogWrite(CCLIENT__DEBUG, 0, "Client", "SendLoginInfo to new client...");
-		SendLoginInfo();
-		new_client_login = false;
+	switch(new_client_login) {
+		case NewLoginState::LOGIN_ALLOWED: {
+			LogWrite(CCLIENT__DEBUG, 0, "Client", "SendLoginInfo to new client...");
+			SendLoginInfo();
+			new_client_login = NewLoginState::LOGIN_NONE;
+			break;
+		}
+		case NewLoginState::LOGIN_DELAYED: {
+			LogWrite(CCLIENT__INFO, 0, "Client", "Wait for zone %s to load for new client %s...", GetCurrentZone()->GetZoneName(), GetPlayer()->GetName());
+			if(!GetCurrentZone()->IsLoading()) {
+				new_client_login = NewLoginState::LOGIN_ALLOWED;
+			}
+			
+			return true;
+			break;	
+		}
 	}
+	
 	bool ret = true;
 	sockaddr_in to;
 
@@ -10305,7 +10318,12 @@ bool Client::HandleNewLogin(int32 account_id, int32 access_code)
 				GetCurrentZone()->AddClient(this); //add to zones client list
 				zone_list.AddClientToMap(player->GetName(), this);
 				// this initiates additional DB loading and client offloading within the Zone the player resides, need the client already added in zone and to the map above.
-				new_client_login = true;
+				if(GetCurrentZone()->IsLoading()) {
+					new_client_login = NewLoginState::LOGIN_DELAYED;
+				}
+				else {
+					new_client_login = NewLoginState::LOGIN_ALLOWED;
+				}
 
 				const char* zone_script = world.GetZoneScript(GetCurrentZone()->GetZoneID());
 				if (zone_script && lua_interface)

+ 3 - 1
EQ2/source/WorldServer/client.h

@@ -646,7 +646,9 @@ private:
 	float	zoning_z;
 	float	zoning_h;
 	bool	firstlogin;
-	bool	new_client_login;
+	
+	enum 	NewLoginState { LOGIN_NONE, LOGIN_DELAYED, LOGIN_ALLOWED };
+	NewLoginState	new_client_login; // 1 = delayed state, 2 = let client in
 	Timer	underworld_cooldown_timer;
 	Timer	pos_update;
 	Timer	quest_pos_timer;

+ 42 - 23
EQ2/source/WorldServer/zoneserver.cpp

@@ -1430,16 +1430,31 @@ bool ZoneServer::Process()
 			RemoveLocationGrids();
 			database.LoadLocationGrids(this);
 
-			LoadingData = false;
 
-			spawn_range.Trigger();
-			spawn_check_add.Trigger();
+			MMasterZoneLock->unlock();
+			
+			while(true) {
+				ProcessPendingSpawns();
+				Sleep(20);
+				MPendingSpawnListAdd.readlock(__FUNCTION__, __LINE__);
+				int32 count = pending_spawn_list_add.size();
+				MPendingSpawnListAdd.releasereadlock(__FUNCTION__, __LINE__);
+				if(count < 1)
+					break;
+			}
+	
+			MMasterZoneLock->lock();
+			
+			LoadingData = false;
 
 			const char* zone_script = world.GetZoneScript(this->GetZoneID());
 			if (lua_interface && zone_script) {
 				RemoveLocationProximities();
 				lua_interface->RunZoneScript(zone_script, "init_zone_script", this);
 			}
+
+			spawn_range.Trigger();
+			spawn_check_add.Trigger();
 		}
 
 		if(shutdownTimer.Enabled() && shutdownTimer.Check() && connected_clients.size(true) == 0) {
@@ -1671,26 +1686,7 @@ bool ZoneServer::SpawnProcess(){
 
 		// Check to see if there are spawns waiting to be added to the spawn list, if so add them all
 		if (pending_spawn_list_add.size() > 0) {
-			MSpawnList.writelock(__FUNCTION__, __LINE__);
-			MPendingSpawnListAdd.writelock(__FUNCTION__, __LINE__);
-			list<Spawn*>::iterator itr2;
-			for (itr2 = pending_spawn_list_add.begin(); itr2 != pending_spawn_list_add.end(); itr2++) {
-				Spawn* spawn = *itr2;
-				if (spawn)
-					spawn_list[spawn->GetID()] = spawn;
-				
-				if(spawn->IsCollector()) {
-					subspawn_list[SUBSPAWN_TYPES::COLLECTOR].insert(make_pair(spawn->GetID(),spawn));
-				}
-				if(spawn->GetPickupItemID()) {
-					subspawn_list[SUBSPAWN_TYPES::HOUSE_ITEM_SPAWN].insert(make_pair(spawn->GetPickupItemID(),spawn));
-					housing_spawn_map.insert(make_pair(spawn->GetID(), spawn->GetPickupItemID()));
-				}
-			}
-
-			pending_spawn_list_add.clear();
-			MPendingSpawnListAdd.releasewritelock(__FUNCTION__, __LINE__);
-			MSpawnList.releasewritelock(__FUNCTION__, __LINE__);
+			ProcessPendingSpawns();
 		}
 
 		MSpawnList.readlock(__FUNCTION__, __LINE__);
@@ -8415,4 +8411,27 @@ bool ZoneServer::HouseItemSpawnExists(int32 item_id) {
 	}
 	MSpawnList.releasereadlock(__FUNCTION__, __LINE__);
 	return exists;
+}
+
+void ZoneServer::ProcessPendingSpawns() {
+	MSpawnList.writelock(__FUNCTION__, __LINE__);
+	MPendingSpawnListAdd.writelock(__FUNCTION__, __LINE__);
+	list<Spawn*>::iterator itr2;
+	for (itr2 = pending_spawn_list_add.begin(); itr2 != pending_spawn_list_add.end(); itr2++) {
+		Spawn* spawn = *itr2;
+		if (spawn)
+			spawn_list[spawn->GetID()] = spawn;
+		
+		if(spawn->IsCollector()) {
+			subspawn_list[SUBSPAWN_TYPES::COLLECTOR].insert(make_pair(spawn->GetID(),spawn));
+		}
+		if(spawn->GetPickupItemID()) {
+			subspawn_list[SUBSPAWN_TYPES::HOUSE_ITEM_SPAWN].insert(make_pair(spawn->GetPickupItemID(),spawn));
+			housing_spawn_map.insert(make_pair(spawn->GetID(), spawn->GetPickupItemID()));
+		}
+	}
+
+	pending_spawn_list_add.clear();
+	MPendingSpawnListAdd.releasewritelock(__FUNCTION__, __LINE__);
+	MSpawnList.releasewritelock(__FUNCTION__, __LINE__);
 }

+ 2 - 1
EQ2/source/WorldServer/zoneserver.h

@@ -699,7 +699,8 @@ public:
 	Client*	RemoveZoneServerFromClient(ZoneServer* zone);
 	
 	void	SendSubSpawnUpdates(SUBSPAWN_TYPES subtype);
-	bool	HouseItemSpawnExists(int32 item_id);	
+	bool	HouseItemSpawnExists(int32 item_id);
+	void	ProcessPendingSpawns();
 private:
 #ifndef WIN32
 	pthread_t ZoneThread;