mirror of
https://github.com/EQEmu/Server.git
synced 2026-05-31 09:06:46 +00:00
Finish SharedTaskManager::HandleTaskRequest
Cleaned up some other functions as well
This commit is contained in:
+1
-19
@@ -229,15 +229,6 @@ struct ClientReward
|
||||
uint32 amount;
|
||||
};
|
||||
|
||||
#define PENDING_TASK_TIMEOUT 60000
|
||||
struct PendingSharedTask {
|
||||
int id;
|
||||
int task_master_id;
|
||||
Timer timeout; // so if we take a very long time to get messages back from world, we time out and fail
|
||||
std::vector<std::string> members; // members ahh I guess if verification takes a long time raid could change?
|
||||
PendingSharedTask() : id(0), task_master_id(0) {}
|
||||
};
|
||||
|
||||
class ClientFactory {
|
||||
public:
|
||||
Client *MakeClient(std::shared_ptr<EQStreamInterface> ieqs);
|
||||
@@ -1035,7 +1026,7 @@ public:
|
||||
inline bool IsTaskEnabled(int TaskID) { return (taskstate ? taskstate->IsTaskEnabled(TaskID) : false); }
|
||||
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) { if (taskstate) taskstate->AcceptNewSharedTask(this, TaskID, NPCID, id); }
|
||||
inline void AssignSharedTask(int TaskID, int NPCID, int id, std::vector<std::string> &members) { if (taskstate) taskstate->AcceptNewSharedTask(this, TaskID, NPCID, id, members); }
|
||||
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); }
|
||||
@@ -1055,14 +1046,6 @@ public:
|
||||
inline int GetTaskLockoutExpire(int id) { return 0; } // stub
|
||||
inline int GetTaskLockoutTimeLeft(int id) { return 0; } // stub
|
||||
|
||||
inline void SetPendingTask(int id, int task_master_id) { pending_task.id = id; pending_task.task_master_id = task_master_id; }
|
||||
inline bool HasPendingTask() const { return pending_task.id != 0; }
|
||||
inline int GetPendingTaskID() const { return pending_task.id; }
|
||||
inline int GetPendingTaskMasterID() const { return pending_task.task_master_id; }
|
||||
inline void StartPendingTimer() { pending_task.timeout.Start(PENDING_TASK_TIMEOUT); }
|
||||
inline void ResetPendingTask() { pending_task.id = 0; pending_task.task_master_id = 0; pending_task.timeout.Disable(); pending_task.members.clear(); }
|
||||
inline void PendingTaskAddMember(const char *name) { pending_task.members.push_back(name); }
|
||||
|
||||
inline const EQEmu::versions::ClientVersion ClientVersion() const { return m_ClientVersion; }
|
||||
inline const uint32 ClientVersionBit() const { return m_ClientVersionBit; }
|
||||
inline void SetClientVersion(EQEmu::versions::ClientVersion client_version) { m_ClientVersion = client_version; }
|
||||
@@ -1586,7 +1569,6 @@ private:
|
||||
std::set<uint32> zone_flags;
|
||||
|
||||
ClientTaskState *taskstate;
|
||||
PendingSharedTask pending_task;
|
||||
int TotalSecondsPlayed;
|
||||
|
||||
//Anti Spam Stuff
|
||||
|
||||
@@ -159,11 +159,6 @@ bool Client::Process() {
|
||||
if (TaskPeriodic_Timer.Check() && taskstate)
|
||||
taskstate->TaskPeriodicChecks(this);
|
||||
|
||||
if (pending_task.timeout.Check(false)) {
|
||||
Message(13, "Shared task timed out.");
|
||||
ResetPendingTask();
|
||||
}
|
||||
|
||||
if (linkdead_timer.Check()) {
|
||||
LeaveGroup();
|
||||
Save();
|
||||
|
||||
+2
-3
@@ -3429,8 +3429,6 @@ void ClientTaskState::PendSharedTask(Client *c, int TaskID, int NPCID, bool enfo
|
||||
player_count = raid->RaidCount();
|
||||
}
|
||||
|
||||
// TODO: check task lockouts I guess it's simpler to require everyone to be in zone so we can verify lockouts ...
|
||||
|
||||
if (!EQEmu::ValueWithin(player_count, task->min_players, task->max_players)) {
|
||||
if (player_count < task->min_players)
|
||||
c->Message_StringID(13, TASK_REJECT_MIN_COUNT);
|
||||
@@ -3442,6 +3440,7 @@ void ClientTaskState::PendSharedTask(Client *c, int TaskID, int NPCID, bool enfo
|
||||
// okay, we verified a few things on the requestor, now we need to fire off to world to do the rest
|
||||
SerializeBuffer buf(25 + 10 * player_count);
|
||||
buf.WriteInt32(TaskID); // Task ID
|
||||
buf.WriteInt32(NPCID); // NPC we're requesting from
|
||||
buf.WriteString(c->GetName()); // leader name
|
||||
buf.WriteInt32(player_count - 1); // count, not leader
|
||||
if (group) {
|
||||
@@ -3562,7 +3561,7 @@ void ClientTaskState::PendSharedTask(Client *c, int TaskID, int NPCID, bool enfo
|
||||
|
||||
}
|
||||
|
||||
void ClientTaskState::AcceptNewSharedTask(Client *c, int TaskID, int NPCID, int id)
|
||||
void ClientTaskState::AcceptNewSharedTask(Client *c, int TaskID, int NPCID, int id, std::vector<std::string> &members)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
+1
-1
@@ -148,7 +148,7 @@ public:
|
||||
int GetTaskActivityDoneCountFromTaskID(int TaskID, int ActivityID);
|
||||
int GetTaskStartTime(TaskType type, int index);
|
||||
void AcceptNewTask(Client *c, int TaskID, int NPCID, bool enforce_level_requirement = false);
|
||||
void AcceptNewSharedTask(Client *c, int TaskID, int NPCID, int id);
|
||||
void AcceptNewSharedTask(Client *c, int TaskID, int NPCID, int id, std::vector<std::string> &members);
|
||||
void PendSharedTask(Client *c, int TaskID, int NPCID, bool enforce_level_requirement = false);
|
||||
void FailTask(Client *c, int TaskID);
|
||||
int TaskTimeLeft(int TaskID);
|
||||
|
||||
+15
-4
@@ -1945,22 +1945,33 @@ void WorldServer::HandleMessage(uint16 opcode, const EQ::Net::Packet &p)
|
||||
case ServerOP_TaskGrant:
|
||||
{
|
||||
int id = pack->ReadUInt32();
|
||||
int task_id = pack->ReadUInt32();
|
||||
int taskmaster_id = pack->ReadUInt32();
|
||||
char name[64] = { 0 };
|
||||
pack->ReadString(name);
|
||||
auto client = entity_list.GetClientByName(name);
|
||||
if (client && client->HasPendingTask()) // if they don't have it, ignore it I guess :P
|
||||
client->AssignSharedTask(client->GetPendingTaskID(), client->GetPendingTaskMasterID(), id);
|
||||
if (client) { // guess we just do nothing if they're not here
|
||||
std::vector<std::string> members;
|
||||
int count = pack->ReadUInt32();
|
||||
for (int i = 0; i < count; ++i) {
|
||||
pack->ReadString(name);
|
||||
members.push_back(name);
|
||||
}
|
||||
client->AssignSharedTask(task_id, taskmaster_id, id, members);
|
||||
} else {
|
||||
// TODO: something failed, tell world to clean up
|
||||
}
|
||||
break;
|
||||
}
|
||||
case ServerOP_TaskReject:
|
||||
{
|
||||
// this will be reworked to not use the pend shit, we will depend on hoping successive requests just get thrown out
|
||||
int message = pack->ReadUInt32();
|
||||
int taskmaster_id = pack->ReadUInt32();
|
||||
char name[64] = { 0 };
|
||||
pack->ReadString(name);
|
||||
auto client = entity_list.GetClientByName(name);
|
||||
if (client && client->HasPendingTask()) {
|
||||
client->ResetPendingTask();
|
||||
if (client) {
|
||||
if (message == 0)
|
||||
client->Message(13, "Shared task assignment has failed.");
|
||||
else if (message > 0)
|
||||
|
||||
Reference in New Issue
Block a user