diff --git a/EQ2/source/WorldServer/NPC_AI.cpp b/EQ2/source/WorldServer/NPC_AI.cpp index d38967319..8df59b6fc 100644 --- a/EQ2/source/WorldServer/NPC_AI.cpp +++ b/EQ2/source/WorldServer/NPC_AI.cpp @@ -54,10 +54,6 @@ Brain::~Brain() { void Brain::Think() { - // Get the entity this NPC hates the most, - // GetMostHated() will handle dead spawns so no need to check the health in this function - Entity* target = GetMostHated(); - // If mezzed, stunned or feared we can't do anything so skip if (!m_body->IsMezzedOrStunned()) { // Not mezzed or stunned @@ -65,6 +61,10 @@ void Brain::Think() { // Get the distance to the runback location float run_back_distance = m_body->GetRunbackDistance(); + // Get the entity this NPC hates the most, + // GetMostHated() will handle dead spawns so no need to check the health in this function + Entity* target = GetMostHated(); + if (target) { LogWrite(NPC_AI__DEBUG, 7, "NPC_AI", "%s has %s targeted.", m_body->GetName(), target->GetName()); // NPC has an entity that it hates diff --git a/EQ2/source/WorldServer/Player.cpp b/EQ2/source/WorldServer/Player.cpp index bed3646f0..8a317d6ff 100644 --- a/EQ2/source/WorldServer/Player.cpp +++ b/EQ2/source/WorldServer/Player.cpp @@ -4090,17 +4090,12 @@ void Player::ClearRemovedSpawn(Spawn* spawn){ } bool Player::ShouldSendSpawn(Spawn* spawn){ - // Added a try catch to attempt to prevent a zone crash when an invalid spawn is passed to this function. - // Think invalid spawns are coming from the mutex list, if spawn is invalid return false. - try - { - if((WasSentSpawn(spawn->GetID()) == false || NeedsSpawnResent(spawn)) && (!spawn->IsPrivateSpawn() || spawn->AllowedAccess(this))) - return true; - } - catch (...) - { - LogWrite(SPAWN__ERROR, 0, "Spawn", "Invalid spawn passes to player->ShouldSendSpawn()"); - } + + bool wasSentSpawn = WasSentSpawn(spawn->GetID()); + if((!wasSentSpawn || (wasSentSpawn && WasSpawnRemoved(spawn))) + && (!spawn->IsPrivateSpawn() || spawn->AllowedAccess(this))) + return true; + return false; } diff --git a/EQ2/source/WorldServer/net.cpp b/EQ2/source/WorldServer/net.cpp index 531a8b631..166e0fc13 100644 --- a/EQ2/source/WorldServer/net.cpp +++ b/EQ2/source/WorldServer/net.cpp @@ -440,6 +440,7 @@ int main(int argc, char** argv) { connecting_clients[eqs] = Timer::GetCurrentTime2(); } } + if(connecting_clients.size() > 0){ for(cc_itr = connecting_clients.begin(); cc_itr!=connecting_clients.end(); cc_itr++){ if(cc_itr->first && cc_itr->first->CheckActive() && client_list.ContainsStream(cc_itr->first) == false){ @@ -488,7 +489,7 @@ int main(int argc, char** argv) { Sleep(10); continue; } - Sleep(1); + Sleep(10); } LogWrite(WORLD__DEBUG, 0, "World", "The world is ending!"); diff --git a/EQ2/source/WorldServer/zoneserver.cpp b/EQ2/source/WorldServer/zoneserver.cpp index feb64a286..a11b5ff1b 100644 --- a/EQ2/source/WorldServer/zoneserver.cpp +++ b/EQ2/source/WorldServer/zoneserver.cpp @@ -237,7 +237,7 @@ void ZoneServer::Init() /* Static Timers */ // JA - haven't decided yet if these should remain hard-coded. Changing them could break EQ2Emu functionality - spawn_check_add.Start(100); + spawn_check_add.Start(1000); spawn_check_remove.Start(30000); spawn_expire_timer.Start(10000); respawn_timer.Start(10000); @@ -1056,7 +1056,7 @@ void ZoneServer::CheckSendSpawnToClient(Client* client, bool initial_login) { if(initial_login || client->IsConnected()) { MutexMap::iterator spawn_iter = spawn_range_map.Get(client)->begin(); while(spawn_iter.Next()) { - spawn = GetSpawnByID(spawn_iter->first); + spawn = GetSpawnByID(spawn_iter->first, !initial_login); if(spawn && spawn->GetPrivateQuestSpawn()) { if(!spawn->IsPrivateSpawn()) spawn->AddAllowAccessSpawn(spawn); @@ -1242,6 +1242,10 @@ bool ZoneServer::Process() { #endif if (LoadingData) { + while (zoneID == 0) { //this is loaded by world + Sleep(10); + } + if (lua_interface) { string tmpScript("ZoneScripts/"); tmpScript.append(GetZoneName()); @@ -1252,10 +1256,6 @@ bool ZoneServer::Process() lua_interface->RunZoneScript(tmpScript.c_str(), "preinit_zone_script", this); } - while (zoneID == 0) { //this is loaded by world - Sleep(10); - } - if (reloading) { LogWrite(COMMAND__DEBUG, 0, "Command", "-Loading Entity Commands..."); database.LoadEntityCommands(this); @@ -1530,14 +1530,18 @@ bool ZoneServer::SpawnProcess(){ spawn->ProcessMovement(true); // update last_movement_update for all spawns (used for time_step) spawn->last_movement_update = Timer::GetCurrentTime2(); + + // Process combat for the spawn + if (!aggroCheck) + CombatProcess(spawn); } // Makes NPC's KOS to other NPC's or players if (aggroCheck) + { ProcessAggroChecks(spawn); - - // Process combat for the spawn - CombatProcess(spawn); + CombatProcess(spawn); + } } else { // unable to get a valid spawn, lets add the id to another list to remove from the spawn list after this loop is finished @@ -1861,7 +1865,7 @@ void ZoneServer::SendSpawnChanges(){ MutexList::iterator spawn_iter = changed_spawns.begin(); int count = 0; while(spawn_iter.Next()){ - spawn = GetSpawnByID(spawn_iter->value); + spawn = GetSpawnByID(spawn_iter->value, true); if(spawn){ spawns_to_send.insert(spawn); } @@ -6306,7 +6310,7 @@ ThreadReturnType ZoneLoop(void* tmp) { if(zs->GetClientCount() == 0) Sleep(1000); else - Sleep(10); + Sleep(20); } zs->Process(); //run loop once more to clean up some functions safe_delete(zs); diff --git a/EQ2/source/common/EQStreamFactory.cpp b/EQ2/source/common/EQStreamFactory.cpp index 31c657cb9..2e8e95fd4 100644 --- a/EQ2/source/common/EQStreamFactory.cpp +++ b/EQ2/source/common/EQStreamFactory.cpp @@ -340,7 +340,9 @@ void EQStreamFactory::CombinePacketLoop(){ } MStreams.unlock(); if(!packets_waiting) - Sleep(25); + Sleep(20); + + Sleep(10); } }