[Code] AdventureManager Global to Singleton Cleanup (#4931)

* [Code] AdventureManager Global to Singleton Cleanup

* Post merge fix

---------

Co-authored-by: Chris Miles <akkadius1@gmail.com>
This commit is contained in:
Alex King 2025-06-25 15:38:24 -04:00 committed by GitHub
parent 128732e05d
commit 004e2ca63f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 26 additions and 34 deletions

View File

@ -17,7 +17,7 @@
extern ZSList zoneserver_list;
extern ClientList client_list;
extern AdventureManager adventure_manager;
extern EQ::Random emu_random;
Adventure::Adventure(AdventureTemplate *t)
{
@ -215,7 +215,7 @@ void Adventure::SetStatus(AdventureStatus new_status)
auto iter = players.begin();
while(iter != players.end())
{
adventure_manager.GetAdventureData((*iter).c_str());
AdventureManager::Instance()->GetAdventureData((*iter).c_str());
++iter;
}
}
@ -330,7 +330,7 @@ void Adventure::Finished(AdventureWinStatus ws)
afe.win = false;
afe.points = 0;
}
adventure_manager.AddFinishedEvent(afe);
AdventureManager::Instance()->AddFinishedEvent(afe);
database.UpdateAdventureStatsEntry(character_id, GetTemplate()->theme, (ws != AWS_Lose) ? true : false);
}
}
@ -351,12 +351,12 @@ void Adventure::Finished(AdventureWinStatus ws)
afe.win = false;
afe.points = 0;
}
adventure_manager.AddFinishedEvent(afe);
AdventureManager::Instance()->AddFinishedEvent(afe);
database.UpdateAdventureStatsEntry(character_id, GetTemplate()->theme, (ws != AWS_Lose) ? true : false);
}
++iter;
}
adventure_manager.GetAdventureData(this);
AdventureManager::Instance()->GetAdventureData(this);
}
void Adventure::MoveCorpsesToGraveyard()

View File

@ -40,6 +40,12 @@ public:
AdventureTemplate *GetAdventureTemplate(int theme, int id);
AdventureTemplate *GetAdventureTemplate(int id);
void GetZoneData(uint16 instance_id);
static AdventureManager* Instance()
{
static AdventureManager instance;
return &instance;
}
protected:
bool IsInExcludedZoneList(std::list<AdventureZones> excluded_zones, std::string zone_name, int version);
bool IsInExcludedZoneInList(std::list<AdventureZoneIn> excluded_zone_ins, int zone_id, int door_object);

View File

@ -94,14 +94,8 @@
ClientList client_list;
GroupLFPList LFPGroupList;
ZSList zoneserver_list;
<<<<<<< kinglykrab/ucsconnection-global-to-singleton
LoginServerList loginserverlist;
=======
UCSConnection UCSLink;
>>>>>>> master
QueryServConnection QSLink;
LauncherList launcher_list;
AdventureManager adventure_manager;
WorldEventScheduler event_scheduler;
volatile bool RunLoops = true;
uint32 numclients = 0;
@ -471,7 +465,7 @@ int main(int argc, char **argv)
zoneserver_list.Process();
launcher_list.Process();
LFPGroupList.Process();
adventure_manager.Process();
AdventureManager::Instance()->Process();
SharedTaskManager::Instance()->Process();
dynamic_zone_manager.Process();

View File

@ -224,7 +224,6 @@ void WorldBoot::RegisterLoginservers()
}
}
extern AdventureManager adventure_manager;
extern WorldEventScheduler event_scheduler;
bool WorldBoot::DatabaseLoadRoutines(int argc, char **argv)
@ -359,15 +358,15 @@ bool WorldBoot::DatabaseLoadRoutines(int argc, char **argv)
LogInfo("Deleted [{}] stale player corpses from database", database.DeleteStalePlayerCorpses());
LogInfo("Loading adventures");
if (!adventure_manager.LoadAdventureTemplates()) {
if (!AdventureManager::Instance()->LoadAdventureTemplates()) {
LogInfo("Unable to load adventure templates");
}
if (!adventure_manager.LoadAdventureEntries()) {
if (!AdventureManager::Instance()->LoadAdventureEntries()) {
LogInfo("Unable to load adventure templates");
}
adventure_manager.LoadLeaderboardInfo();
AdventureManager::Instance()->LoadLeaderboardInfo();
LogInfo("Purging expired dynamic zones and members");
dynamic_zone_manager.PurgeExpiredDynamicZones();

View File

@ -57,7 +57,6 @@ extern GroupLFPList LFPGroupList;
extern ZSList zoneserver_list;
extern volatile bool RunLoops;
extern volatile bool UCSServerAvailable_;
extern AdventureManager adventure_manager;
extern QueryServConnection QSLink;
void CatchSignal(int sig_num);
@ -1292,46 +1291,46 @@ void ZoneServer::HandleMessage(uint16 opcode, const EQ::Net::Packet &p) {
break;
}
case ServerOP_AdventureRequest: {
adventure_manager.CalculateAdventureRequestReply((const char*) pack->pBuffer);
AdventureManager::Instance()->CalculateAdventureRequestReply((const char*) pack->pBuffer);
break;
}
case ServerOP_AdventureRequestCreate: {
adventure_manager.TryAdventureCreate((const char*) pack->pBuffer);
AdventureManager::Instance()->TryAdventureCreate((const char*) pack->pBuffer);
break;
}
case ServerOP_AdventureDataRequest: {
AdventureFinishEvent fe;
while (adventure_manager.PopFinishedEvent((const char*) pack->pBuffer, fe)) {
adventure_manager.SendAdventureFinish(fe);
while (AdventureManager::Instance()->PopFinishedEvent((const char*) pack->pBuffer, fe)) {
AdventureManager::Instance()->SendAdventureFinish(fe);
}
adventure_manager.GetAdventureData((const char*) pack->pBuffer);
AdventureManager::Instance()->GetAdventureData((const char*) pack->pBuffer);
break;
}
case ServerOP_AdventureClickDoor: {
auto pcad = (ServerPlayerClickedAdventureDoor_Struct*) pack->pBuffer;
adventure_manager.PlayerClickedDoor(pcad->player, pcad->zone_id, pcad->id);
AdventureManager::Instance()->PlayerClickedDoor(pcad->player, pcad->zone_id, pcad->id);
break;
}
case ServerOP_AdventureLeave: {
adventure_manager.LeaveAdventure((const char*) pack->pBuffer);
AdventureManager::Instance()->LeaveAdventure((const char*) pack->pBuffer);
break;
}
case ServerOP_AdventureCountUpdate: {
auto sc = (ServerAdventureCount_Struct*) pack->pBuffer;
adventure_manager.IncrementCount(sc->instance_id);
AdventureManager::Instance()->IncrementCount(sc->instance_id);
break;
}
case ServerOP_AdventureAssaCountUpdate: {
adventure_manager.IncrementAssassinationCount(*((uint16*) pack->pBuffer));
AdventureManager::Instance()->IncrementAssassinationCount(*((uint16*) pack->pBuffer));
break;
}
case ServerOP_AdventureZoneData: {
adventure_manager.GetZoneData(*((uint16*) pack->pBuffer));
AdventureManager::Instance()->GetZoneData(*((uint16*) pack->pBuffer));
break;
}
case ServerOP_AdventureLeaderboard: {
auto lr = (ServerLeaderboardRequest_Struct*) pack->pBuffer;
adventure_manager.DoLeaderboardRequest(lr->player, lr->type);
AdventureManager::Instance()->DoLeaderboardRequest(lr->player, lr->type);
break;
}
case ServerOP_LSAccountUpdate: {

View File

@ -105,12 +105,6 @@ QuestParserCollection *parse = 0;
ZoneEventScheduler event_scheduler;
WorldContentService content_service;
PlayerEventLogs player_event_logs;
<<<<<<< kinglykrab/evolvingitemsmanager-global-to-singleton
DatabaseUpdate database_update;
SkillCaps skill_caps;
=======
EvolvingItemsManager evolving_items_manager;
>>>>>>> master
const SPDat_Spell_Struct* spells;
int32 SPDAT_RECORDS = -1;