Yet more cleanup

This commit is contained in:
Akkadius 2021-02-07 15:00:16 -06:00
parent 8414973077
commit 0c533071d4
14 changed files with 461 additions and 476 deletions

View File

@ -76,7 +76,7 @@
extern QueryServ* QServ; extern QueryServ* QServ;
extern WorldServer worldserver; extern WorldServer worldserver;
extern TaskManager *p_task_manager; extern TaskManager *task_manager;
void CatchSignal(int sig_num); void CatchSignal(int sig_num);

View File

@ -88,7 +88,7 @@ namespace EQ
#define XTARGET_HARDCAP 20 #define XTARGET_HARDCAP 20
extern Zone* zone; extern Zone* zone;
extern TaskManager *p_task_manager; extern TaskManager *task_manager;
class CLIENTPACKET class CLIENTPACKET
{ {
@ -1039,7 +1039,7 @@ public:
} }
inline bool SaveTaskState() inline bool SaveTaskState()
{ {
return p_task_manager != nullptr && p_task_manager->SaveClientState(this, task_state); return task_manager != nullptr && task_manager->SaveClientState(this, task_state);
} }
inline bool IsTaskStateLoaded() { return task_state != nullptr; } inline bool IsTaskStateLoaded() { return task_state != nullptr; }
inline bool IsTaskActive(int task_id) { return task_state != nullptr && task_state->IsTaskActive(task_id); } inline bool IsTaskActive(int task_id) { return task_state != nullptr && task_state->IsTaskActive(task_id); }
@ -1137,8 +1137,8 @@ public:
} }
inline void TaskSetSelector(Mob *mob, int task_set_id) inline void TaskSetSelector(Mob *mob, int task_set_id)
{ {
if (p_task_manager) { if (task_manager) {
p_task_manager->TaskSetSelector( task_manager->TaskSetSelector(
this, this,
task_state, task_state,
mob, mob,
@ -1148,8 +1148,8 @@ public:
} }
inline void TaskQuestSetSelector(Mob *mob, int count, int *tasks) inline void TaskQuestSetSelector(Mob *mob, int count, int *tasks)
{ {
if (p_task_manager) { if (task_manager) {
p_task_manager->TaskQuestSetSelector( task_manager->TaskQuestSetSelector(
this, this,
task_state, task_state,
mob, mob,

View File

@ -77,7 +77,7 @@
extern QueryServ* QServ; extern QueryServ* QServ;
extern WorldServer worldserver; extern WorldServer worldserver;
extern TaskManager *p_task_manager; extern TaskManager *task_manager;
extern FastMath g_Math; extern FastMath g_Math;
void CatchSignal(int sig_num); void CatchSignal(int sig_num);

View File

@ -32,6 +32,7 @@
#include "../common/features.h" #include "../common/features.h"
#include "../common/guilds.h" #include "../common/guilds.h"
#include "entity.h"
#include "dynamiczone.h" #include "dynamiczone.h"
#include "guild_mgr.h" #include "guild_mgr.h"
#include "petitions.h" #include "petitions.h"
@ -3900,22 +3901,24 @@ void EntityList::ProcessProximitySay(const char *Message, Client *c, uint8 langu
void EntityList::SaveAllClientsTaskState() void EntityList::SaveAllClientsTaskState()
{ {
if (!p_task_manager) if (!task_manager) {
return; return;
}
auto it = client_list.begin(); auto it = client_list.begin();
while (it != client_list.end()) { while (it != client_list.end()) {
Client *client = it->second; Client *client = it->second;
if (client->IsTaskStateLoaded()) if (client->IsTaskStateLoaded()) {
client->SaveTaskState(); client->SaveTaskState();
}
++it; ++it;
} }
} }
void EntityList::ReloadAllClientsTaskState(int TaskID) void EntityList::ReloadAllClientsTaskState(int task_id)
{ {
if (!p_task_manager) if (!task_manager)
return; return;
auto it = client_list.begin(); auto it = client_list.begin();
@ -3924,11 +3927,11 @@ void EntityList::ReloadAllClientsTaskState(int TaskID)
if (client->IsTaskStateLoaded()) { if (client->IsTaskStateLoaded()) {
// If we have been passed a TaskID, only reload the client state if they have // If we have been passed a TaskID, only reload the client state if they have
// that Task active. // that Task active.
if ((!TaskID) || (TaskID && client->IsTaskActive(TaskID))) { if ((!task_id) || (task_id && client->IsTaskActive(task_id))) {
Log(Logs::General, Logs::Tasks, "[CLIENTLOAD] Reloading Task State For Client %s", client->GetName()); Log(Logs::General, Logs::Tasks, "[CLIENTLOAD] Reloading Task State For Client %s", client->GetName());
client->RemoveClientTaskState(); client->RemoveClientTaskState();
client->LoadClientTaskState(); client->LoadClientTaskState();
p_task_manager->SendActiveTasksToClient(client); task_manager->SendActiveTasksToClient(client);
} }
} }
++it; ++it;

View File

@ -483,7 +483,7 @@ public:
void SendGroupLeader(uint32 gid, const char *lname, const char *oldlname); void SendGroupLeader(uint32 gid, const char *lname, const char *oldlname);
void SaveAllClientsTaskState(); void SaveAllClientsTaskState();
void ReloadAllClientsTaskState(int TaskID=0); void ReloadAllClientsTaskState(int task_id=0);
uint16 CreateGroundObject(uint32 itemid, const glm::vec4& position, uint32 decay_time = 300000); uint16 CreateGroundObject(uint32 itemid, const glm::vec4& position, uint32 decay_time = 300000);
uint16 CreateGroundObjectFromModel(const char *model, const glm::vec4& position, uint8 type = 0x00, uint32 decay_time = 0); uint16 CreateGroundObjectFromModel(const char *model, const glm::vec4& position, uint8 type = 0x00, uint32 decay_time = 0);
uint16 CreateDoor(const char *model, const glm::vec4& position, uint8 type = 0, uint16 size = 100); uint16 CreateDoor(const char *model, const glm::vec4& position, uint8 type = 0, uint16 size = 100);

View File

@ -22,26 +22,18 @@
#define PLATFORM_ZONE 1 #define PLATFORM_ZONE 1
#include "../common/global_define.h" #include "../common/global_define.h"
#include "../common/features.h"
#include "../common/queue.h"
#include "../common/timer.h" #include "../common/timer.h"
#include "../common/eq_packet_structs.h" #include "../common/eq_packet_structs.h"
#include "../common/mutex.h" #include "../common/mutex.h"
#include "../common/version.h"
#include "../common/packet_dump_file.h"
#include "../common/opcodemgr.h" #include "../common/opcodemgr.h"
#include "../common/guilds.h" #include "../common/guilds.h"
#include "../common/eq_stream_ident.h" #include "../common/eq_stream_ident.h"
#include "../common/patches/patches.h" #include "../common/patches/patches.h"
#include "../common/rulesys.h" #include "../common/rulesys.h"
#include "../common/profanity_manager.h" #include "../common/profanity_manager.h"
#include "../common/misc_functions.h"
#include "../common/string_util.h" #include "../common/string_util.h"
#include "../common/platform.h"
#include "../common/crash.h" #include "../common/crash.h"
#include "../common/ipc_mutex.h"
#include "../common/memory_mapped_file.h" #include "../common/memory_mapped_file.h"
#include "../common/eqemu_exception.h"
#include "../common/spdat.h" #include "../common/spdat.h"
#include "../common/eqemu_logsys.h" #include "../common/eqemu_logsys.h"
@ -57,32 +49,21 @@
#endif #endif
#include "zonedb.h" #include "zonedb.h"
#include "zone_store.h" #include "zone_store.h"
#include "zone_config.h"
#include "titles.h" #include "titles.h"
#include "guild_mgr.h" #include "guild_mgr.h"
#include "tasks.h" #include "task_manager.h"
#include "quest_parser_collection.h" #include "quest_parser_collection.h"
#include "embparser.h" #include "embparser.h"
#include "lua_parser.h" #include "lua_parser.h"
#include "questmgr.h" #include "questmgr.h"
#include "npc_scale_manager.h" #include "npc_scale_manager.h"
#include "../common/event/event_loop.h"
#include "../common/event/timer.h"
#include "../common/net/eqstream.h" #include "../common/net/eqstream.h"
#include "../common/net/servertalk_server.h"
#include "../common/content/world_content_service.h" #include "../common/content/world_content_service.h"
#include "../common/repositories/content_flags_repository.h"
#include <iostream>
#include <string>
#include <fstream>
#include <stdlib.h> #include <stdlib.h>
#include <stdio.h>
#include <signal.h> #include <signal.h>
#include <time.h> #include <time.h>
#include <ctime>
#include <thread>
#include <chrono> #include <chrono>
#ifdef _CRTDBG_MAP_ALLOC #ifdef _CRTDBG_MAP_ALLOC
@ -115,8 +96,8 @@ char errorname[32];
extern Zone* zone; extern Zone* zone;
npcDecayTimes_Struct npcCorpseDecayTimes[100]; npcDecayTimes_Struct npcCorpseDecayTimes[100];
TitleManager title_manager; TitleManager title_manager;
QueryServ *QServ = 0; QueryServ *QServ = 0;
TaskManager *p_task_manager = 0; TaskManager *task_manager = 0;
NpcScaleManager *npc_scale_manager; NpcScaleManager *npc_scale_manager;
QuestParserCollection *parse = 0; QuestParserCollection *parse = 0;
EQEmuLogSys LogSys; EQEmuLogSys LogSys;
@ -426,8 +407,8 @@ int main(int argc, char** argv) {
#endif #endif
if (RuleB(TaskSystem, EnableTaskSystem)) { if (RuleB(TaskSystem, EnableTaskSystem)) {
p_task_manager = new TaskManager; task_manager = new TaskManager;
p_task_manager->LoadTasks(); task_manager->LoadTasks();
} }
parse = new QuestParserCollection(); parse = new QuestParserCollection();
@ -606,7 +587,7 @@ int main(int argc, char** argv) {
if (zone != 0) if (zone != 0)
Zone::Shutdown(true); Zone::Shutdown(true);
//Fix for Linux world server problem. //Fix for Linux world server problem.
safe_delete(p_task_manager); safe_delete(task_manager);
command_deinit(); command_deinit();
#ifdef BOTS #ifdef BOTS
bot_command_deinit(); bot_command_deinit();

View File

@ -2223,27 +2223,27 @@ bool QuestManager::createBot(const char *name, const char *lastname, uint8 level
void QuestManager::taskselector(int taskcount, int *tasks) { void QuestManager::taskselector(int taskcount, int *tasks) {
QuestManagerCurrentQuestVars(); QuestManagerCurrentQuestVars();
if(RuleB(TaskSystem, EnableTaskSystem) && initiator && owner && p_task_manager) if(RuleB(TaskSystem, EnableTaskSystem) && initiator && owner && task_manager)
initiator->TaskQuestSetSelector(owner, taskcount, tasks); initiator->TaskQuestSetSelector(owner, taskcount, tasks);
} }
void QuestManager::enabletask(int taskcount, int *tasks) { void QuestManager::enabletask(int taskcount, int *tasks) {
QuestManagerCurrentQuestVars(); QuestManagerCurrentQuestVars();
if(RuleB(TaskSystem, EnableTaskSystem) && initiator && p_task_manager) if(RuleB(TaskSystem, EnableTaskSystem) && initiator && task_manager)
initiator->EnableTask(taskcount, tasks); initiator->EnableTask(taskcount, tasks);
} }
void QuestManager::disabletask(int taskcount, int *tasks) { void QuestManager::disabletask(int taskcount, int *tasks) {
QuestManagerCurrentQuestVars(); QuestManagerCurrentQuestVars();
if(RuleB(TaskSystem, EnableTaskSystem) && initiator && p_task_manager) if(RuleB(TaskSystem, EnableTaskSystem) && initiator && task_manager)
initiator->DisableTask(taskcount, tasks); initiator->DisableTask(taskcount, tasks);
} }
bool QuestManager::istaskenabled(int taskid) { bool QuestManager::istaskenabled(int taskid) {
QuestManagerCurrentQuestVars(); QuestManagerCurrentQuestVars();
if(RuleB(TaskSystem, EnableTaskSystem) && initiator && p_task_manager) if(RuleB(TaskSystem, EnableTaskSystem) && initiator && task_manager)
return initiator->IsTaskEnabled(taskid); return initiator->IsTaskEnabled(taskid);
return false; return false;
@ -2252,7 +2252,7 @@ bool QuestManager::istaskenabled(int taskid) {
void QuestManager::tasksetselector(int tasksetid) { void QuestManager::tasksetselector(int tasksetid) {
QuestManagerCurrentQuestVars(); QuestManagerCurrentQuestVars();
Log(Logs::General, Logs::Tasks, "[UPDATE] TaskSetSelector called for task set %i", tasksetid); Log(Logs::General, Logs::Tasks, "[UPDATE] TaskSetSelector called for task set %i", tasksetid);
if(RuleB(TaskSystem, EnableTaskSystem) && initiator && owner && p_task_manager) if(RuleB(TaskSystem, EnableTaskSystem) && initiator && owner && task_manager)
initiator->TaskSetSelector(owner, tasksetid); initiator->TaskSetSelector(owner, tasksetid);
} }
@ -2341,8 +2341,8 @@ int QuestManager::enabledtaskcount(int taskset) {
int QuestManager::firsttaskinset(int taskset) { int QuestManager::firsttaskinset(int taskset) {
QuestManagerCurrentQuestVars(); QuestManagerCurrentQuestVars();
if(RuleB(TaskSystem, EnableTaskSystem) && p_task_manager) if(RuleB(TaskSystem, EnableTaskSystem) && task_manager)
return p_task_manager->FirstTaskInSet(taskset); return task_manager->FirstTaskInSet(taskset);
return -1; return -1;
} }
@ -2350,8 +2350,8 @@ int QuestManager::firsttaskinset(int taskset) {
int QuestManager::lasttaskinset(int taskset) { int QuestManager::lasttaskinset(int taskset) {
QuestManagerCurrentQuestVars(); QuestManagerCurrentQuestVars();
if(RuleB(TaskSystem, EnableTaskSystem) && p_task_manager) if(RuleB(TaskSystem, EnableTaskSystem) && task_manager)
return p_task_manager->LastTaskInSet(taskset); return task_manager->LastTaskInSet(taskset);
return -1; return -1;
} }
@ -2359,8 +2359,8 @@ int QuestManager::lasttaskinset(int taskset) {
int QuestManager::nexttaskinset(int taskset, int taskid) { int QuestManager::nexttaskinset(int taskset, int taskid) {
QuestManagerCurrentQuestVars(); QuestManagerCurrentQuestVars();
if(RuleB(TaskSystem, EnableTaskSystem) && p_task_manager) if(RuleB(TaskSystem, EnableTaskSystem) && task_manager)
return p_task_manager->NextTaskInSet(taskset, taskid); return task_manager->NextTaskInSet(taskset, taskid);
return -1; return -1;
} }
@ -2412,8 +2412,8 @@ int QuestManager::completedtasksinset(int taskset) {
bool QuestManager::istaskappropriate(int task) { bool QuestManager::istaskappropriate(int task) {
QuestManagerCurrentQuestVars(); QuestManagerCurrentQuestVars();
if(RuleB(TaskSystem, EnableTaskSystem) && initiator && p_task_manager) if(RuleB(TaskSystem, EnableTaskSystem) && initiator && task_manager)
return p_task_manager->ValidateLevel(task, initiator->GetLevel()); return task_manager->ValidateLevel(task, initiator->GetLevel());
return false; return false;
} }
@ -2422,7 +2422,7 @@ std::string QuestManager::gettaskname(uint32 task_id) {
QuestManagerCurrentQuestVars(); QuestManagerCurrentQuestVars();
if (RuleB(TaskSystem, EnableTaskSystem)) { if (RuleB(TaskSystem, EnableTaskSystem)) {
return p_task_manager->GetTaskName(task_id); return task_manager->GetTaskName(task_id);
} }
return std::string(); return std::string();

File diff suppressed because it is too large Load Diff

View File

@ -14,7 +14,7 @@ public:
ClientTaskState(); ClientTaskState();
~ClientTaskState(); ~ClientTaskState();
void ShowClientTasks(Client *client); void ShowClientTasks(Client *client);
inline int GetActiveTaskCount() { return active_task_count; } inline int GetActiveTaskCount() { return m_active_task_count; }
int GetActiveTaskID(int index); int GetActiveTaskID(int index);
bool IsTaskActivityCompleted(TaskType task_type, int index, int activity_id); bool IsTaskActivityCompleted(TaskType task_type, int index, int activity_id);
int GetTaskActivityDoneCount(TaskType task_type, int index, int activity_id); int GetTaskActivityDoneCount(TaskType task_type, int index, int activity_id);
@ -55,7 +55,7 @@ public:
int CompletedTasksInSet(int task_set_id); int CompletedTasksInSet(int task_set_id);
bool HasSlotForTask(TaskInformation *task); bool HasSlotForTask(TaskInformation *task);
inline bool HasFreeTaskSlot() { return active_task.task_id == TASKSLOTEMPTY; } inline bool HasFreeTaskSlot() { return m_active_task.task_id == TASKSLOTEMPTY; }
friend class TaskManager; friend class TaskManager;
@ -69,20 +69,21 @@ private:
int count = 1, int count = 1,
bool ignore_quest_update = false bool ignore_quest_update = false
); );
inline ClientTaskInformation *GetClientTaskInfo(TaskType task_type, int index) inline ClientTaskInformation *GetClientTaskInfo(TaskType task_type, int index)
{ {
ClientTaskInformation *info = nullptr; ClientTaskInformation *info = nullptr;
switch (task_type) { switch (task_type) {
case TaskType::Task: case TaskType::Task:
if (index == 0) { if (index == 0) {
info = &active_task; info = &m_active_task;
} }
break; break;
case TaskType::Shared: case TaskType::Shared:
break; break;
case TaskType::Quest: case TaskType::Quest:
if (index < MAXACTIVEQUESTS) { if (index < MAXACTIVEQUESTS) {
info = &active_quests[index]; info = &m_active_quests[index];
} }
break; break;
default: default:
@ -90,20 +91,20 @@ private:
} }
return info; return info;
} }
int active_task_count;
union { // easier to loop over union { // easier to loop over
struct { struct {
ClientTaskInformation active_task; // only one ClientTaskInformation m_active_task; // only one
ClientTaskInformation active_quests[MAXACTIVEQUESTS]; ClientTaskInformation m_active_quests[MAXACTIVEQUESTS];
}; };
ClientTaskInformation active_tasks[MAXACTIVEQUESTS + 1]; ClientTaskInformation m_active_tasks[MAXACTIVEQUESTS + 1];
}; };
// Shared tasks should be limited to 1 as well // Shared tasks should be limited to 1 as well
std::vector<int> enabled_tasks; int m_active_task_count;
std::vector<CompletedTaskInformation> completed_tasks; std::vector<int> m_enabled_tasks;
int last_completed_task_loaded; std::vector<CompletedTaskInformation> m_completed_tasks;
bool checked_touch_activities; int m_last_completed_task_loaded;
bool m_checked_touch_activities;
}; };

File diff suppressed because it is too large Load Diff

View File

@ -25,7 +25,7 @@ public:
void ReloadGoalLists(); void ReloadGoalLists();
inline void LoadProximities(int zone_id) inline void LoadProximities(int zone_id)
{ {
proximity_manager.LoadProximities(zone_id); m_proximity_manager.LoadProximities(zone_id);
} }
bool LoadTaskSets(); bool LoadTaskSets();
bool LoadClientState(Client *client, ClientTaskState *client_task_state); bool LoadClientState(Client *client, ClientTaskState *client_task_state);
@ -79,10 +79,10 @@ public:
private: private:
TaskGoalListManager goal_list_manager; TaskGoalListManager m_goal_list_manager;
TaskProximityManager proximity_manager; TaskProximityManager m_proximity_manager;
TaskInformation *p_task_data[MAXTASKS]{}; TaskInformation *m_task_data[MAXTASKS]{};
std::vector<int> task_sets[MAXTASKSETS]; std::vector<int> m_task_sets[MAXTASKSETS];
void SendActiveTaskDescription( void SendActiveTaskDescription(
Client *client, Client *client,
int task_id, int task_id,

View File

@ -12,18 +12,18 @@ extern QueryServ *QServ;
void Client::LoadClientTaskState() void Client::LoadClientTaskState()
{ {
if (RuleB(TaskSystem, EnableTaskSystem) && p_task_manager) { if (RuleB(TaskSystem, EnableTaskSystem) && task_manager) {
if (task_state) { if (task_state) {
safe_delete(task_state); safe_delete(task_state);
} }
task_state = new ClientTaskState; task_state = new ClientTaskState;
if (!p_task_manager->LoadClientState(this, task_state)) { if (!task_manager->LoadClientState(this, task_state)) {
safe_delete(task_state); safe_delete(task_state);
} }
else { else {
p_task_manager->SendActiveTasksToClient(this); task_manager->SendActiveTasksToClient(this);
p_task_manager->SendCompletedTasksToClient(this, task_state); task_manager->SendCompletedTasksToClient(this, task_state);
} }
} }
} }

View File

@ -3100,16 +3100,16 @@ void WorldServer::HandleReloadTasks(ServerPacket *pack)
if (rts->Parameter == 0) { if (rts->Parameter == 0) {
Log(Logs::General, Logs::Tasks, "[GLOBALLOAD] Reload ALL tasks"); Log(Logs::General, Logs::Tasks, "[GLOBALLOAD] Reload ALL tasks");
safe_delete(p_task_manager); safe_delete(task_manager);
p_task_manager = new TaskManager; task_manager = new TaskManager;
p_task_manager->LoadTasks(); task_manager->LoadTasks();
if (zone) if (zone)
p_task_manager->LoadProximities(zone->GetZoneID()); task_manager->LoadProximities(zone->GetZoneID());
entity_list.ReloadAllClientsTaskState(); entity_list.ReloadAllClientsTaskState();
} }
else { else {
Log(Logs::General, Logs::Tasks, "[GLOBALLOAD] Reload only task %i", rts->Parameter); Log(Logs::General, Logs::Tasks, "[GLOBALLOAD] Reload only task %i", rts->Parameter);
p_task_manager->LoadTasks(rts->Parameter); task_manager->LoadTasks(rts->Parameter);
entity_list.ReloadAllClientsTaskState(rts->Parameter); entity_list.ReloadAllClientsTaskState(rts->Parameter);
} }
@ -3118,18 +3118,18 @@ void WorldServer::HandleReloadTasks(ServerPacket *pack)
case RELOADTASKPROXIMITIES: case RELOADTASKPROXIMITIES:
if (zone) { if (zone) {
Log(Logs::General, Logs::Tasks, "[GLOBALLOAD] Reload task proximities"); Log(Logs::General, Logs::Tasks, "[GLOBALLOAD] Reload task proximities");
p_task_manager->LoadProximities(zone->GetZoneID()); task_manager->LoadProximities(zone->GetZoneID());
} }
break; break;
case RELOADTASKGOALLISTS: case RELOADTASKGOALLISTS:
Log(Logs::General, Logs::Tasks, "[GLOBALLOAD] Reload task goal lists"); Log(Logs::General, Logs::Tasks, "[GLOBALLOAD] Reload task goal lists");
p_task_manager->ReloadGoalLists(); task_manager->ReloadGoalLists();
break; break;
case RELOADTASKSETS: case RELOADTASKSETS:
Log(Logs::General, Logs::Tasks, "[GLOBALLOAD] Reload task sets"); Log(Logs::General, Logs::Tasks, "[GLOBALLOAD] Reload task sets");
p_task_manager->LoadTaskSets(); task_manager->LoadTaskSets();
break; break;
default: default:

View File

@ -964,7 +964,7 @@ Zone::Zone(uint32 in_zoneid, uint32 in_instanceid, const char* in_short_name)
lootvar = 0; lootvar = 0;
if(RuleB(TaskSystem, EnableTaskSystem)) { if(RuleB(TaskSystem, EnableTaskSystem)) {
p_task_manager->LoadProximities(zoneid); task_manager->LoadProximities(zoneid);
} }
short_name = strcpy(new char[strlen(in_short_name)+1], in_short_name); short_name = strcpy(new char[strlen(in_short_name)+1], in_short_name);