diff --git a/world/shared_tasks.cpp b/world/shared_tasks.cpp index ee8fdbbd1..a1840df55 100644 --- a/world/shared_tasks.cpp +++ b/world/shared_tasks.cpp @@ -112,6 +112,32 @@ void SharedTaskManager::HandleTaskRequestReply(ServerPacket *pack) 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() { --missing_count; diff --git a/world/shared_tasks.h b/world/shared_tasks.h index 620db404d..791c7cf30 100644 --- a/world/shared_tasks.h +++ b/world/shared_tasks.h @@ -34,15 +34,17 @@ private: class SharedTaskManager { public: - SharedTaskManager() {} + SharedTaskManager() : next_id(0) {} ~SharedTaskManager() {} + bool LoadSharedTaskState(); + // IPC packet processing void HandleTaskRequest(ServerPacket *pack); void HandleTaskRequestReply(ServerPacket *pack); private: - inline int GetNextID() { return ++next_id; } + int GetNextID(); int next_id; std::unordered_map tasks; };