diff --git a/world/CMakeLists.txt b/world/CMakeLists.txt index 366244fd4..c042a7364 100644 --- a/world/CMakeLists.txt +++ b/world/CMakeLists.txt @@ -42,7 +42,6 @@ SET(world_headers lfplist.h login_server.h login_server_list.h - net.h queryserv.h sof_char_create_data.h ucs.h diff --git a/zone/CMakeLists.txt b/zone/CMakeLists.txt index f4632b9dc..f75e963f9 100644 --- a/zone/CMakeLists.txt +++ b/zone/CMakeLists.txt @@ -79,6 +79,7 @@ SET(zone_sources horse.cpp inventory.cpp loottables.cpp + main.cpp map.cpp merc.cpp mob.cpp @@ -87,7 +88,6 @@ SET(zone_sources mob_movement_manager.cpp mob_info.cpp mod_functions.cpp - net.cpp npc.cpp npc_ai.cpp npc_scale_manager.cpp @@ -210,7 +210,6 @@ SET(zone_headers merc.h mob.h mob_movement_manager.h - net.h npc.h npc_ai.h npc_scale_manager.h diff --git a/zone/client.cpp b/zone/client.cpp index 6a0a10f5d..66b533984 100644 --- a/zone/client.cpp +++ b/zone/client.cpp @@ -41,7 +41,6 @@ extern volatile bool RunLoops; #include "../common/profanity_manager.h" #include "data_bucket.h" #include "position.h" -#include "net.h" #include "worldserver.h" #include "zonedb.h" #include "petitions.h" @@ -67,6 +66,8 @@ extern PetitionList petition_list; bool commandlogged; char entirecommand[255]; +void UpdateWindowTitle(char* iNewTitle); + Client::Client(EQStreamInterface* ieqs) : Mob("No name", // name "", // lastname @@ -244,7 +245,7 @@ Client::Client(EQStreamInterface* ieqs) PendingRezzSpellID = 0; numclients++; // emuerror; - UpdateWindowTitle(); + UpdateWindowTitle(nullptr); horseId = 0; tgb = false; tribute_master_id = 0xFFFFFFFF; @@ -449,7 +450,7 @@ Client::~Client() { ClearRespawnOptions(); numclients--; - UpdateWindowTitle(); + UpdateWindowTitle(nullptr); if(zone) zone->RemoveAuth(GetName(), lskey); diff --git a/zone/entity.cpp b/zone/entity.cpp index 084e0fc93..7f016f197 100644 --- a/zone/entity.cpp +++ b/zone/entity.cpp @@ -33,7 +33,6 @@ #include "../common/guilds.h" #include "guild_mgr.h" -#include "net.h" #include "petitions.h" #include "quest_parser_collection.h" #include "raids.h" @@ -56,7 +55,6 @@ extern Zone *zone; extern volatile bool is_zone_loaded; extern WorldServer worldserver; -extern NetConnection net; extern uint32 numclients; extern PetitionList petition_list; @@ -300,6 +298,13 @@ const Bot *Entity::CastToBot() const #endif EntityList::EntityList() + : + object_timer(5000), + door_timer(5000), + corpse_timer(2000), + group_timer(1000), + raid_timer(1000), + trap_timer(1000) { // set up ids between 1 and 1500 // neither client or server performs well if you have @@ -349,7 +354,7 @@ void EntityList::TrapProcess() return; if (trap_list.empty()) { - net.trap_timer.Disable(); + trap_timer.Disable(); return; } @@ -388,7 +393,7 @@ void EntityList::GroupProcess() return; if (group_list.empty()) { - net.group_timer.Disable(); + group_timer.Disable(); return; } @@ -412,7 +417,7 @@ void EntityList::RaidProcess() return; if (raid_list.empty()) { - net.raid_timer.Disable(); + raid_timer.Disable(); return; } @@ -427,7 +432,7 @@ void EntityList::DoorProcess() return; #endif if (door_list.empty()) { - net.door_timer.Disable(); + door_timer.Disable(); return; } @@ -445,7 +450,7 @@ void EntityList::DoorProcess() void EntityList::ObjectProcess() { if (object_list.empty()) { - net.object_timer.Disable(); + object_timer.Disable(); return; } @@ -464,7 +469,7 @@ void EntityList::ObjectProcess() void EntityList::CorpseProcess() { if (corpse_list.empty()) { - net.corpse_timer.Disable(); // No corpses in list + corpse_timer.Disable(); // No corpses in list return; } @@ -606,8 +611,8 @@ void EntityList::AddGroup(Group *group, uint32 gid) { group->SetID(gid); group_list.push_back(group); - if (!net.group_timer.Enabled()) - net.group_timer.Start(); + if (!group_timer.Enabled()) + group_timer.Start(); #if EQDEBUG >= 5 CheckGroupList(__FILE__, __LINE__); #endif @@ -631,8 +636,8 @@ void EntityList::AddRaid(Raid *raid, uint32 gid) { raid->SetID(gid); raid_list.push_back(raid); - if (!net.raid_timer.Enabled()) - net.raid_timer.Start(); + if (!raid_timer.Enabled()) + raid_timer.Start(); } @@ -649,8 +654,8 @@ void EntityList::AddCorpse(Corpse *corpse, uint32 in_id) corpse->CalcCorpseName(); corpse_list.insert(std::pair(corpse->GetID(), corpse)); - if (!net.corpse_timer.Enabled()) - net.corpse_timer.Start(); + if (!corpse_timer.Enabled()) + corpse_timer.Start(); } void EntityList::AddNPC(NPC *npc, bool SendSpawnPacket, bool dontqueue) @@ -752,8 +757,8 @@ void EntityList::AddObject(Object *obj, bool SendSpawnPacket) object_list.insert(std::pair(obj->GetID(), obj)); - if (!net.object_timer.Enabled()) - net.object_timer.Start(); + if (!object_timer.Enabled()) + object_timer.Start(); } void EntityList::AddDoor(Doors *door) @@ -761,16 +766,16 @@ void EntityList::AddDoor(Doors *door) door->SetEntityID(GetFreeID()); door_list.insert(std::pair(door->GetEntityID(), door)); - if (!net.door_timer.Enabled()) - net.door_timer.Start(); + if (!door_timer.Enabled()) + door_timer.Start(); } void EntityList::AddTrap(Trap *trap) { trap->SetID(GetFreeID()); trap_list.insert(std::pair(trap->GetID(), trap)); - if (!net.trap_timer.Enabled()) - net.trap_timer.Start(); + if (!trap_timer.Enabled()) + trap_timer.Start(); } void EntityList::AddBeacon(Beacon *beacon) diff --git a/zone/entity.h b/zone/entity.h index 339bbfd8a..6b22f1a4c 100644 --- a/zone/entity.h +++ b/zone/entity.h @@ -538,6 +538,13 @@ private: std::list area_list; std::queue free_ids; + Timer object_timer; + Timer door_timer; + Timer corpse_timer; + Timer group_timer; + Timer raid_timer; + Timer trap_timer; + // Please Do Not Declare Any EntityList Class Members After This Comment #ifdef BOTS public: diff --git a/zone/net.cpp b/zone/main.cpp similarity index 92% rename from zone/net.cpp rename to zone/main.cpp index 0ce901359..9ee3eda25 100644 --- a/zone/net.cpp +++ b/zone/main.cpp @@ -47,7 +47,6 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA #include "zone_config.h" #include "masterentity.h" #include "worldserver.h" -#include "net.h" #include "zone.h" #include "queryserv.h" #include "command.h" @@ -96,7 +95,6 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA volatile bool RunLoops = true; extern volatile bool is_zone_loaded; -NetConnection net; EntityList entity_list; WorldServer worldserver; uint32 numclients = 0; @@ -115,6 +113,9 @@ const ZoneConfig *Config; double frame_time = 0.0; void Shutdown(); +void UpdateWindowTitle(char* iNewTitle); +void CatchSignal(int sig_num); + extern void MapOpcodes(); int main(int argc, char** argv) { @@ -440,7 +441,7 @@ int main(int argc, char** argv) { bool websocker_server_opened = false; Timer quest_timers(100); - UpdateWindowTitle(); + UpdateWindowTitle(nullptr); std::shared_ptr eqss; EQStreamInterface *eqsi; std::unique_ptr eqsm; @@ -514,23 +515,12 @@ int main(int argc, char** argv) { if (is_zone_loaded) { { - if (net.group_timer.Enabled() && net.group_timer.Check()) - entity_list.GroupProcess(); - - if (net.door_timer.Enabled() && net.door_timer.Check()) - entity_list.DoorProcess(); - - if (net.object_timer.Enabled() && net.object_timer.Check()) - entity_list.ObjectProcess(); - - if (net.corpse_timer.Enabled() && net.corpse_timer.Check()) - entity_list.CorpseProcess(); - - if (net.trap_timer.Enabled() && net.trap_timer.Check()) - entity_list.TrapProcess(); - - if (net.raid_timer.Enabled() && net.raid_timer.Check()) - entity_list.RaidProcess(); + entity_list.GroupProcess(); + entity_list.DoorProcess(); + entity_list.ObjectProcess(); + entity_list.CorpseProcess(); + entity_list.TrapProcess(); + entity_list.RaidProcess(); entity_list.Process(); entity_list.MobProcess(); @@ -622,60 +612,6 @@ void Shutdown() LogSys.CloseFileLogs(); } -uint32 NetConnection::GetIP() -{ - char name[255 + 1]; - size_t len = 0; - hostent* host = 0; - - if (gethostname(name, len) < 0 || len <= 0) - { - return 0; - } - - host = (hostent*)gethostbyname(name); - if (host == 0) - { - return 0; - } - - return inet_addr(host->h_addr); -} - -uint32 NetConnection::GetIP(char* name) -{ - hostent* host = 0; - - host = (hostent*)gethostbyname(name); - if (host == 0) - { - return 0; - } - - return inet_addr(host->h_addr); - -} - -NetConnection::NetConnection() - : - object_timer(5000), - door_timer(5000), - corpse_timer(2000), - group_timer(1000), - raid_timer(1000), - trap_timer(1000) -{ - group_timer.Disable(); - raid_timer.Disable(); - corpse_timer.Disable(); - door_timer.Disable(); - object_timer.Disable(); - trap_timer.Disable(); -} - -NetConnection::~NetConnection() { -} - /* Update Window Title with relevant information */ void UpdateWindowTitle(char* iNewTitle) { #ifdef _WINDOWS diff --git a/zone/net.h b/zone/net.h deleted file mode 100644 index 4d44b6058..000000000 --- a/zone/net.h +++ /dev/null @@ -1,48 +0,0 @@ -/* EQEMu: Everquest Server Emulator - Copyright (C) 2001-2002 EQEMu Development Team (http://eqemu.org) - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; version 2 of the License. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY except by those people which sell it, which - are required to give you total support for your newly bought product; - without even the implied warranty of MERCHANTABILITY or FITNESS FOR - A PARTICULAR PURPOSE. See the GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -*/ -#ifdef _WINDOWS - #include - #include -#else - #include - #include - #include - #include - #include -#endif - -#include "../common/types.h" -#include "../common/timer.h" -void CatchSignal(int); -void UpdateWindowTitle(char* iNewTitle = 0); - -class NetConnection -{ -public: - ~NetConnection(); - NetConnection(); - - uint32 GetIP(); - uint32 GetIP(char* name); - Timer object_timer; - Timer door_timer; - Timer corpse_timer; - Timer group_timer; - Timer raid_timer; - Timer trap_timer; -}; diff --git a/zone/queryserv.cpp b/zone/queryserv.cpp index 691943a7c..6e8b57423 100644 --- a/zone/queryserv.cpp +++ b/zone/queryserv.cpp @@ -21,7 +21,6 @@ Copyright (C) 2001-2014 EQEMu Development Team (http://eqemulator.net) #include "../common/string_util.h" #include "queryserv.h" #include "worldserver.h" -#include "net.h" extern WorldServer worldserver; diff --git a/zone/worldserver.cpp b/zone/worldserver.cpp index 1ed7d4998..4f7e35ace 100644 --- a/zone/worldserver.cpp +++ b/zone/worldserver.cpp @@ -44,7 +44,6 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA #include "quest_parser_collection.h" #include "guild_mgr.h" #include "mob.h" -#include "net.h" #include "petitions.h" #include "raids.h" #include "string_ids.h" @@ -59,7 +58,6 @@ extern Zone* zone; extern volatile bool is_zone_loaded; extern void CatchSignal(int); extern WorldServer worldserver; -extern NetConnection net; extern PetitionList petition_list; extern uint32 numclients; extern volatile bool RunLoops; diff --git a/zone/zone.cpp b/zone/zone.cpp index 1bb8b8c36..99c120cab 100755 --- a/zone/zone.cpp +++ b/zone/zone.cpp @@ -39,7 +39,6 @@ #include "guild_mgr.h" #include "map.h" -#include "net.h" #include "npc.h" #include "object.h" #include "pathfinder_null.h" @@ -68,7 +67,6 @@ #endif extern bool staticzone; -extern NetConnection net; extern PetitionList petition_list; extern QuestParserCollection* parse; extern uint32 numclients; @@ -81,6 +79,8 @@ Mutex MZoneShutdown; volatile bool is_zone_loaded = false; Zone* zone = 0; +void UpdateWindowTitle(char* iNewTitle); + bool Zone::Bootup(uint32 iZoneID, uint32 iInstanceID, bool iStaticZone) { const char* zonename = database.GetZoneName(iZoneID); @@ -147,7 +147,7 @@ bool Zone::Bootup(uint32 iZoneID, uint32 iInstanceID, bool iStaticZone) { LogInfo("---- Zone server [{}], listening on port:[{}] ----", zonename, ZoneConfig::get()->ZonePort); LogInfo("Zone Bootup: [{}] ([{}]: [{}])", zonename, iZoneID, iInstanceID); parse->Init(); - UpdateWindowTitle(); + UpdateWindowTitle(nullptr); zone->GetTimeSync(); zone->RequestUCSServerStatus(); @@ -727,7 +727,7 @@ void Zone::Shutdown(bool quiet) safe_delete(zone); entity_list.ClearAreas(); parse->ReloadQuests(true); - UpdateWindowTitle(); + UpdateWindowTitle(nullptr); LogSys.CloseFileLogs(); @@ -2422,4 +2422,4 @@ void Zone::CalculateNpcUpdateDistanceSpread() update_distance, combined_spread ); -} \ No newline at end of file +}