diff --git a/zone/tasks.cpp b/zone/tasks.cpp index 30c724d5b..3739a41f0 100644 --- a/zone/tasks.cpp +++ b/zone/tasks.cpp @@ -299,17 +299,19 @@ bool TaskManager::SaveClientState(Client *c, ClientTaskState *state) if (taskID == TASKSLOTEMPTY) continue; + int slot = state->ActiveTasks[task].slot; + if (state->ActiveTasks[task].Updated) { Log(Logs::General, Logs::Tasks, "[CLIENTSAVE] TaskManager::SaveClientState for character ID %d, Updating TaskIndex " "%i TaskID %i", - characterID, task, taskID); + characterID, slot, taskID); std::string query = StringFormat( "REPLACE INTO character_tasks (charid, taskid, slot, type, acceptedtime) " "VALUES (%i, %i, %i, %i, %i)", - characterID, taskID, task, static_cast(Tasks[taskID]->type), + characterID, taskID, slot, static_cast(Tasks[taskID]->type), state->ActiveTasks[task].AcceptedTime); auto results = database.QueryDatabase(query); if (!results.Success()) { @@ -332,7 +334,7 @@ bool TaskManager::SaveClientState(Client *c, ClientTaskState *state) Log(Logs::General, Logs::Tasks, "[CLIENTSAVE] TaskManager::SaveClientSate for character ID %d, Updating Activity " "%i, %i", - characterID, task, activityIndex); + characterID, slot, activityIndex); if (updatedActivityCount == 0) query += @@ -1557,7 +1559,7 @@ bool ClientTaskState::UpdateTasksByNPC(Client *c, int ActivityType, int NPCTypeI } // We found an active task to kill this type of NPC, so increment the done count Log(Logs::General, Logs::Tasks, "[UPDATE] Calling increment done count ByNPC"); - IncrementDoneCount(c, Task, i, j); + IncrementDoneCount(c, Task, cur_task->slot, j); Ret = true; } } @@ -1639,6 +1641,7 @@ int ClientTaskState::ActiveSpeakActivity(int NPCTypeID, int TaskID) { } return 0; } + void ClientTaskState::UpdateTasksForItem(Client *c, ActivityType Type, int ItemID, int Count) { // This method updates the client's task activities of the specified type which relate @@ -1697,7 +1700,7 @@ void ClientTaskState::UpdateTasksForItem(Client *c, ActivityType Type, int ItemI } // We found an active task related to this item, so increment the done count Log(Logs::General, Logs::Tasks, "[UPDATE] Calling increment done count ForItem"); - IncrementDoneCount(c, Task, i, j, Count); + IncrementDoneCount(c, Task, cur_task->slot, j, Count); } } @@ -1759,7 +1762,7 @@ void ClientTaskState::UpdateTasksOnExplore(Client *c, int ExploreID) // We found an active task to explore this area, so set done count to goal count // (Only a goal count of 1 makes sense for explore activities?) Log(Logs::General, Logs::Tasks, "[UPDATE] Increment on explore"); - IncrementDoneCount(c, Task, i, j, + IncrementDoneCount(c, Task, cur_task->slot, j, Task->Activity[j].GoalCount - cur_task->Activity[j].DoneCount); } } @@ -1834,7 +1837,7 @@ bool ClientTaskState::UpdateTasksOnDeliver(Client *c, std::listGetCharges() <= 0 ? 1 : k->GetCharges()); + IncrementDoneCount(c, Task, cur_task->slot, j, k->GetCharges() <= 0 ? 1 : k->GetCharges()); Ret = true; } } @@ -1882,7 +1885,7 @@ void ClientTaskState::UpdateTasksOnTouch(Client *c, int ZoneID) // We found an active task to zone into this zone, so set done count to goal count // (Only a goal count of 1 makes sense for touch activities?) Log(Logs::General, Logs::Tasks, "[UPDATE] Increment on Touch"); - IncrementDoneCount(c, Task, i, j, + IncrementDoneCount(c, Task, cur_task->slot, j, Task->Activity[j].GoalCount - cur_task->Activity[j].DoneCount); } } @@ -2863,20 +2866,21 @@ void TaskManager::SendActiveTasksToClient(Client *c, bool TaskComplete) GetActivityCount(TaskID)); int Sequence = 0; + int fixed_index = Tasks[TaskID]->type == TaskType::Task ? 0 : TaskIndex - 1; // hmmm fuck for (int Activity = 0; Activity < GetActivityCount(TaskID); Activity++) { - if (c->GetTaskActivityState(Tasks[TaskID]->type, TaskIndex, Activity) != ActivityHidden) { + if (c->GetTaskActivityState(Tasks[TaskID]->type, fixed_index, Activity) != ActivityHidden) { Log(Logs::General, Logs::Tasks, "[UPDATE] Long: %i, %i, %i Complete=%i", TaskID, - Activity, TaskIndex, TaskComplete); + Activity, fixed_index, TaskComplete); if (Activity == GetActivityCount(TaskID) - 1) - SendTaskActivityLong(c, TaskID, Activity, TaskIndex, + SendTaskActivityLong(c, TaskID, Activity, fixed_index, Tasks[TaskID]->Activity[Activity].Optional, TaskComplete); else - SendTaskActivityLong(c, TaskID, Activity, TaskIndex, + SendTaskActivityLong(c, TaskID, Activity, fixed_index, Tasks[TaskID]->Activity[Activity].Optional, 0); } else { Log(Logs::General, Logs::Tasks, "[UPDATE] Short: %i, %i, %i", TaskID, Activity, - TaskIndex); - SendTaskActivityShort(c, TaskID, Activity, TaskIndex); + fixed_index); + SendTaskActivityShort(c, TaskID, Activity, fixed_index); } Sequence++; }