Some tweaks to next ID logic and comment up a load function

This commit is contained in:
Michael Cook (mackal) 2019-04-30 17:25:20 -04:00
parent 20aa1cbe77
commit cd1306d52c
2 changed files with 30 additions and 2 deletions

View File

@ -112,6 +112,32 @@ void SharedTaskManager::HandleTaskRequestReply(ServerPacket *pack)
tasks.erase(it); tasks.erase(it);
} }
/*
* This is called once during boot of world
* We need to load next_id, clean up expired tasks (?), and populate the map
*/
bool SharedTaskManager::LoadSharedTaskState()
{
// clean up expired tasks ... We may not want to do this if world crashes and has to be restarted
// May need to wait to do it to cleanly inform existing zones to clean up expired tasks
// Load existing tasks. We may not want to actually do this here and wait for a client to log in
// But the crash case may actually dictate we should :P
// set next_id to highest used ID + 1
return true;
}
int SharedTaskManger::GetNextID()
{
next_id++;
// let's not be extra clever here ...
while (tasks.count(next_id) != 0)
next_id++;
return next_id;
}
bool SharedTask::DecrementMissingCount() bool SharedTask::DecrementMissingCount()
{ {
--missing_count; --missing_count;

View File

@ -34,15 +34,17 @@ private:
class SharedTaskManager { class SharedTaskManager {
public: public:
SharedTaskManager() {} SharedTaskManager() : next_id(0) {}
~SharedTaskManager() {} ~SharedTaskManager() {}
bool LoadSharedTaskState();
// IPC packet processing // IPC packet processing
void HandleTaskRequest(ServerPacket *pack); void HandleTaskRequest(ServerPacket *pack);
void HandleTaskRequestReply(ServerPacket *pack); void HandleTaskRequestReply(ServerPacket *pack);
private: private:
inline int GetNextID() { return ++next_id; } int GetNextID();
int next_id; int next_id;
std::unordered_map<int, SharedTask> tasks; std::unordered_map<int, SharedTask> tasks;
}; };