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 WorldServer worldserver;
extern TaskManager *p_task_manager;
extern TaskManager *task_manager;
void CatchSignal(int sig_num);

View File

@ -88,7 +88,7 @@ namespace EQ
#define XTARGET_HARDCAP 20
extern Zone* zone;
extern TaskManager *p_task_manager;
extern TaskManager *task_manager;
class CLIENTPACKET
{
@ -1039,7 +1039,7 @@ public:
}
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 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)
{
if (p_task_manager) {
p_task_manager->TaskSetSelector(
if (task_manager) {
task_manager->TaskSetSelector(
this,
task_state,
mob,
@ -1148,8 +1148,8 @@ public:
}
inline void TaskQuestSetSelector(Mob *mob, int count, int *tasks)
{
if (p_task_manager) {
p_task_manager->TaskQuestSetSelector(
if (task_manager) {
task_manager->TaskQuestSetSelector(
this,
task_state,
mob,

View File

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

View File

@ -32,6 +32,7 @@
#include "../common/features.h"
#include "../common/guilds.h"
#include "entity.h"
#include "dynamiczone.h"
#include "guild_mgr.h"
#include "petitions.h"
@ -3900,22 +3901,24 @@ void EntityList::ProcessProximitySay(const char *Message, Client *c, uint8 langu
void EntityList::SaveAllClientsTaskState()
{
if (!p_task_manager)
if (!task_manager) {
return;
}
auto it = client_list.begin();
while (it != client_list.end()) {
Client *client = it->second;
if (client->IsTaskStateLoaded())
if (client->IsTaskStateLoaded()) {
client->SaveTaskState();
}
++it;
}
}
void EntityList::ReloadAllClientsTaskState(int TaskID)
void EntityList::ReloadAllClientsTaskState(int task_id)
{
if (!p_task_manager)
if (!task_manager)
return;
auto it = client_list.begin();
@ -3924,11 +3927,11 @@ void EntityList::ReloadAllClientsTaskState(int TaskID)
if (client->IsTaskStateLoaded()) {
// If we have been passed a TaskID, only reload the client state if they have
// 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());
client->RemoveClientTaskState();
client->LoadClientTaskState();
p_task_manager->SendActiveTasksToClient(client);
task_manager->SendActiveTasksToClient(client);
}
}
++it;
@ -4136,7 +4139,7 @@ void EntityList::AddTempPetsToHateList(Mob *owner, Mob* other, bool bFrenzy)
if (n->GetSwarmInfo()) {
if (n->GetSwarmInfo()->owner_id == owner->GetID()) {
if (
!n->GetSpecialAbility(IMMUNE_AGGRO) &&
!n->GetSpecialAbility(IMMUNE_AGGRO) &&
!(n->GetSpecialAbility(IMMUNE_AGGRO_CLIENT) && other->IsClient()) &&
!(n->GetSpecialAbility(IMMUNE_AGGRO_NPC) && other->IsNPC())
) {

View File

@ -483,7 +483,7 @@ public:
void SendGroupLeader(uint32 gid, const char *lname, const char *oldlname);
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 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);

View File

@ -22,26 +22,18 @@
#define PLATFORM_ZONE 1
#include "../common/global_define.h"
#include "../common/features.h"
#include "../common/queue.h"
#include "../common/timer.h"
#include "../common/eq_packet_structs.h"
#include "../common/mutex.h"
#include "../common/version.h"
#include "../common/packet_dump_file.h"
#include "../common/opcodemgr.h"
#include "../common/guilds.h"
#include "../common/eq_stream_ident.h"
#include "../common/patches/patches.h"
#include "../common/rulesys.h"
#include "../common/profanity_manager.h"
#include "../common/misc_functions.h"
#include "../common/string_util.h"
#include "../common/platform.h"
#include "../common/crash.h"
#include "../common/ipc_mutex.h"
#include "../common/memory_mapped_file.h"
#include "../common/eqemu_exception.h"
#include "../common/spdat.h"
#include "../common/eqemu_logsys.h"
@ -57,32 +49,21 @@
#endif
#include "zonedb.h"
#include "zone_store.h"
#include "zone_config.h"
#include "titles.h"
#include "guild_mgr.h"
#include "tasks.h"
#include "task_manager.h"
#include "quest_parser_collection.h"
#include "embparser.h"
#include "lua_parser.h"
#include "questmgr.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/servertalk_server.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 <stdio.h>
#include <signal.h>
#include <time.h>
#include <ctime>
#include <thread>
#include <chrono>
#ifdef _CRTDBG_MAP_ALLOC
@ -115,8 +96,8 @@ char errorname[32];
extern Zone* zone;
npcDecayTimes_Struct npcCorpseDecayTimes[100];
TitleManager title_manager;
QueryServ *QServ = 0;
TaskManager *p_task_manager = 0;
QueryServ *QServ = 0;
TaskManager *task_manager = 0;
NpcScaleManager *npc_scale_manager;
QuestParserCollection *parse = 0;
EQEmuLogSys LogSys;
@ -426,8 +407,8 @@ int main(int argc, char** argv) {
#endif
if (RuleB(TaskSystem, EnableTaskSystem)) {
p_task_manager = new TaskManager;
p_task_manager->LoadTasks();
task_manager = new TaskManager;
task_manager->LoadTasks();
}
parse = new QuestParserCollection();
@ -606,7 +587,7 @@ int main(int argc, char** argv) {
if (zone != 0)
Zone::Shutdown(true);
//Fix for Linux world server problem.
safe_delete(p_task_manager);
safe_delete(task_manager);
command_deinit();
#ifdef BOTS
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) {
QuestManagerCurrentQuestVars();
if(RuleB(TaskSystem, EnableTaskSystem) && initiator && owner && p_task_manager)
if(RuleB(TaskSystem, EnableTaskSystem) && initiator && owner && task_manager)
initiator->TaskQuestSetSelector(owner, taskcount, tasks);
}
void QuestManager::enabletask(int taskcount, int *tasks) {
QuestManagerCurrentQuestVars();
if(RuleB(TaskSystem, EnableTaskSystem) && initiator && p_task_manager)
if(RuleB(TaskSystem, EnableTaskSystem) && initiator && task_manager)
initiator->EnableTask(taskcount, tasks);
}
void QuestManager::disabletask(int taskcount, int *tasks) {
QuestManagerCurrentQuestVars();
if(RuleB(TaskSystem, EnableTaskSystem) && initiator && p_task_manager)
if(RuleB(TaskSystem, EnableTaskSystem) && initiator && task_manager)
initiator->DisableTask(taskcount, tasks);
}
bool QuestManager::istaskenabled(int taskid) {
QuestManagerCurrentQuestVars();
if(RuleB(TaskSystem, EnableTaskSystem) && initiator && p_task_manager)
if(RuleB(TaskSystem, EnableTaskSystem) && initiator && task_manager)
return initiator->IsTaskEnabled(taskid);
return false;
@ -2252,7 +2252,7 @@ bool QuestManager::istaskenabled(int taskid) {
void QuestManager::tasksetselector(int tasksetid) {
QuestManagerCurrentQuestVars();
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);
}
@ -2341,8 +2341,8 @@ int QuestManager::enabledtaskcount(int taskset) {
int QuestManager::firsttaskinset(int taskset) {
QuestManagerCurrentQuestVars();
if(RuleB(TaskSystem, EnableTaskSystem) && p_task_manager)
return p_task_manager->FirstTaskInSet(taskset);
if(RuleB(TaskSystem, EnableTaskSystem) && task_manager)
return task_manager->FirstTaskInSet(taskset);
return -1;
}
@ -2350,8 +2350,8 @@ int QuestManager::firsttaskinset(int taskset) {
int QuestManager::lasttaskinset(int taskset) {
QuestManagerCurrentQuestVars();
if(RuleB(TaskSystem, EnableTaskSystem) && p_task_manager)
return p_task_manager->LastTaskInSet(taskset);
if(RuleB(TaskSystem, EnableTaskSystem) && task_manager)
return task_manager->LastTaskInSet(taskset);
return -1;
}
@ -2359,8 +2359,8 @@ int QuestManager::lasttaskinset(int taskset) {
int QuestManager::nexttaskinset(int taskset, int taskid) {
QuestManagerCurrentQuestVars();
if(RuleB(TaskSystem, EnableTaskSystem) && p_task_manager)
return p_task_manager->NextTaskInSet(taskset, taskid);
if(RuleB(TaskSystem, EnableTaskSystem) && task_manager)
return task_manager->NextTaskInSet(taskset, taskid);
return -1;
}
@ -2412,8 +2412,8 @@ int QuestManager::completedtasksinset(int taskset) {
bool QuestManager::istaskappropriate(int task) {
QuestManagerCurrentQuestVars();
if(RuleB(TaskSystem, EnableTaskSystem) && initiator && p_task_manager)
return p_task_manager->ValidateLevel(task, initiator->GetLevel());
if(RuleB(TaskSystem, EnableTaskSystem) && initiator && task_manager)
return task_manager->ValidateLevel(task, initiator->GetLevel());
return false;
}
@ -2422,7 +2422,7 @@ std::string QuestManager::gettaskname(uint32 task_id) {
QuestManagerCurrentQuestVars();
if (RuleB(TaskSystem, EnableTaskSystem)) {
return p_task_manager->GetTaskName(task_id);
return task_manager->GetTaskName(task_id);
}
return std::string();

File diff suppressed because it is too large Load Diff

View File

@ -14,7 +14,7 @@ public:
ClientTaskState();
~ClientTaskState();
void ShowClientTasks(Client *client);
inline int GetActiveTaskCount() { return active_task_count; }
inline int GetActiveTaskCount() { return m_active_task_count; }
int GetActiveTaskID(int index);
bool IsTaskActivityCompleted(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);
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;
@ -69,20 +69,21 @@ private:
int count = 1,
bool ignore_quest_update = false
);
inline ClientTaskInformation *GetClientTaskInfo(TaskType task_type, int index)
{
ClientTaskInformation *info = nullptr;
switch (task_type) {
case TaskType::Task:
if (index == 0) {
info = &active_task;
info = &m_active_task;
}
break;
case TaskType::Shared:
break;
case TaskType::Quest:
if (index < MAXACTIVEQUESTS) {
info = &active_quests[index];
info = &m_active_quests[index];
}
break;
default:
@ -90,20 +91,20 @@ private:
}
return info;
}
int active_task_count;
union { // easier to loop over
struct {
ClientTaskInformation active_task; // only one
ClientTaskInformation active_quests[MAXACTIVEQUESTS];
ClientTaskInformation m_active_task; // only one
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
std::vector<int> enabled_tasks;
std::vector<CompletedTaskInformation> completed_tasks;
int last_completed_task_loaded;
bool checked_touch_activities;
int m_active_task_count;
std::vector<int> m_enabled_tasks;
std::vector<CompletedTaskInformation> m_completed_tasks;
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();
inline void LoadProximities(int zone_id)
{
proximity_manager.LoadProximities(zone_id);
m_proximity_manager.LoadProximities(zone_id);
}
bool LoadTaskSets();
bool LoadClientState(Client *client, ClientTaskState *client_task_state);
@ -79,10 +79,10 @@ public:
private:
TaskGoalListManager goal_list_manager;
TaskProximityManager proximity_manager;
TaskInformation *p_task_data[MAXTASKS]{};
std::vector<int> task_sets[MAXTASKSETS];
TaskGoalListManager m_goal_list_manager;
TaskProximityManager m_proximity_manager;
TaskInformation *m_task_data[MAXTASKS]{};
std::vector<int> m_task_sets[MAXTASKSETS];
void SendActiveTaskDescription(
Client *client,
int task_id,

View File

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

View File

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

View File

@ -964,7 +964,7 @@ Zone::Zone(uint32 in_zoneid, uint32 in_instanceid, const char* in_short_name)
lootvar = 0;
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);