Work on getting tasks sent to other members

Some stuff just stubbed out for now
This commit is contained in:
Michael Cook (mackal) 2019-06-08 23:43:36 -04:00
parent 2a637a031b
commit bd96d676be
4 changed files with 62 additions and 1 deletions

View File

@ -1027,6 +1027,7 @@ public:
inline void ProcessTaskProximities(float X, float Y, float Z) { if(taskstate) taskstate->ProcessTaskProximities(this, X, Y, Z); }
inline void AssignTask(int TaskID, int NPCID, bool enforce_level_requirement = false) { if (taskstate) taskstate->AcceptNewTask(this, TaskID, NPCID, enforce_level_requirement); }
inline void AssignSharedTask(int TaskID, int NPCID, int id, int accepted_time, std::vector<std::string> &members) { if (taskstate) taskstate->AcceptNewSharedTask(this, TaskID, NPCID, id, accepted_time, members); }
inline void AddToSharedTask(int TaskID) { if (taskstate) taskstate->AddToSharedTask(this, TaskID); }
inline int ActiveSpeakTask(int NPCID) { if(taskstate) return taskstate->ActiveSpeakTask(NPCID); else return 0; }
inline int ActiveSpeakActivity(int NPCID, int TaskID) { if(taskstate) return taskstate->ActiveSpeakActivity(NPCID, TaskID); else return 0; }
inline void FailTask(int TaskID) { if(taskstate) taskstate->FailTask(this, TaskID); }

View File

@ -3074,6 +3074,21 @@ void TaskManager::SendActiveTaskDescription(Client *c, int TaskID, ClientTaskInf
safe_delete(outapp);
}
// TODO: stub
SharedTaskState *TaskManager::LoadSharedTask(int id)
{
return nullptr;
}
SharedTaskState *TaskManager::GetSharedTask(int id)
{
auto it = SharedTasks.find(id);
if (it == SharedTasks.end())
return nullptr;
return &(it->second);
}
bool ClientTaskState::IsTaskActivityCompleted(TaskType type, int index, int ActivityID)
{
switch (type) {
@ -3546,6 +3561,38 @@ void ClientTaskState::AcceptNewSharedTask(Client *c, int TaskID, int NPCID, int
// there are a few issues we need to solve with this
}
/*
* This function is called when world sends ServerOP_TaskZoneCreated to trigger
* members to join. If the task doesn't already exist, we need to load it from
* the DB.
*
* This is also called in LoadClientTaskState() when they notice they have a
* shared task they need to join. (Called from first OP_ZoneEntry)
*/
void ClientTaskState::AddToSharedTask(Client *c, int TaskID)
{
auto task = taskmanager->GetSharedTask(TaskID);
if (!task)
task = taskmanager->LoadSharedTask(TaskID);
if (!task) {// FUCK
return;
}
task->MemberEnterZone(c);
// send packets
auto task_activity = task->GetActivity();
taskmanager->SendSingleActiveTaskToClient(c, *task_activity, false, true);
task->SendMembersList(c);
// So normally getting a task we would send EVENT_TASK_ACCEPTED here, but
// this isn't an accept step. I guess we should add another event in case
// they need the same thing TODO
return;
}
void ClientTaskState::ProcessTaskProximities(Client *c, float X, float Y, float Z) {
float LastX = c->ProximityX();

View File

@ -180,6 +180,7 @@ public:
bool HasSlotForTask(TaskInformation *task);
// shared task related functions
void AcceptNewSharedTask(Client *c, int TaskID, int NPCID, int id, int accepted_time, std::vector<std::string> &members);
void AddToSharedTask(Client *c, int TaskID);
void RequestSharedTask(Client *c, int TaskID, int NPCID, bool enforce_level_requirement = false);
inline bool HasFreeTaskSlot() { return ActiveTask.TaskID == TASKSLOTEMPTY; }
@ -267,8 +268,9 @@ public:
bool IsTaskRepeatable(int TaskID);
friend class ClientTaskState;
void LoadSharedTask(int id); // loads the shared task state
SharedTaskState *LoadSharedTask(int id); // loads the shared task state
SharedTaskState *CreateSharedTask(int id, int task_id);
SharedTaskState *GetSharedTask(int id);
private:
TaskGoalListManager GoalListManager;

View File

@ -1981,6 +1981,17 @@ void WorldServer::HandleMessage(uint16 opcode, const EQ::Net::Packet &p)
}
break;
}
case ServerOP_TaskZoneCreated:
{
int task_id = pack->ReadUInt32();
char name[64] = { 0 };
pack->ReadString(name);
auto client = entity_list.GetClientByName(name);
if (client)
client->AddToSharedTask(task_id);
break;
}
default: {
std::cout << " Unknown ZSopcode:" << (int)pack->opcode;
std::cout << " size:" << pack->size << std::endl;