Fix issue with Quest types

This commit is contained in:
Michael Cook (mackal) 2018-07-09 14:01:52 -04:00
parent 46bdbfc454
commit 07f3ab955f

View File

@ -299,17 +299,19 @@ bool TaskManager::SaveClientState(Client *c, ClientTaskState *state)
if (taskID == TASKSLOTEMPTY) if (taskID == TASKSLOTEMPTY)
continue; continue;
int slot = state->ActiveTasks[task].slot;
if (state->ActiveTasks[task].Updated) { if (state->ActiveTasks[task].Updated) {
Log(Logs::General, Logs::Tasks, Log(Logs::General, Logs::Tasks,
"[CLIENTSAVE] TaskManager::SaveClientState for character ID %d, Updating TaskIndex " "[CLIENTSAVE] TaskManager::SaveClientState for character ID %d, Updating TaskIndex "
"%i TaskID %i", "%i TaskID %i",
characterID, task, taskID); characterID, slot, taskID);
std::string query = StringFormat( std::string query = StringFormat(
"REPLACE INTO character_tasks (charid, taskid, slot, type, acceptedtime) " "REPLACE INTO character_tasks (charid, taskid, slot, type, acceptedtime) "
"VALUES (%i, %i, %i, %i, %i)", "VALUES (%i, %i, %i, %i, %i)",
characterID, taskID, task, static_cast<int>(Tasks[taskID]->type), characterID, taskID, slot, static_cast<int>(Tasks[taskID]->type),
state->ActiveTasks[task].AcceptedTime); state->ActiveTasks[task].AcceptedTime);
auto results = database.QueryDatabase(query); auto results = database.QueryDatabase(query);
if (!results.Success()) { if (!results.Success()) {
@ -332,7 +334,7 @@ bool TaskManager::SaveClientState(Client *c, ClientTaskState *state)
Log(Logs::General, Logs::Tasks, Log(Logs::General, Logs::Tasks,
"[CLIENTSAVE] TaskManager::SaveClientSate for character ID %d, Updating Activity " "[CLIENTSAVE] TaskManager::SaveClientSate for character ID %d, Updating Activity "
"%i, %i", "%i, %i",
characterID, task, activityIndex); characterID, slot, activityIndex);
if (updatedActivityCount == 0) if (updatedActivityCount == 0)
query += 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 // 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"); 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; Ret = true;
} }
} }
@ -1639,6 +1641,7 @@ int ClientTaskState::ActiveSpeakActivity(int NPCTypeID, int TaskID) {
} }
return 0; return 0;
} }
void ClientTaskState::UpdateTasksForItem(Client *c, ActivityType Type, int ItemID, int Count) { 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 // 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 // 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"); 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 // 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?) // (Only a goal count of 1 makes sense for explore activities?)
Log(Logs::General, Logs::Tasks, "[UPDATE] Increment on explore"); 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); Task->Activity[j].GoalCount - cur_task->Activity[j].DoneCount);
} }
} }
@ -1834,7 +1837,7 @@ bool ClientTaskState::UpdateTasksOnDeliver(Client *c, std::list<EQEmu::ItemInsta
} }
// We found an active task related to this item, so increment the done count // We found an active task related to this item, so increment the done count
Log(Logs::General, Logs::Tasks, "[UPDATE] Increment on GiveItem"); Log(Logs::General, Logs::Tasks, "[UPDATE] Increment on GiveItem");
IncrementDoneCount(c, Task, i, j, k->GetCharges() <= 0 ? 1 : k->GetCharges()); IncrementDoneCount(c, Task, cur_task->slot, j, k->GetCharges() <= 0 ? 1 : k->GetCharges());
Ret = true; 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 // 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?) // (Only a goal count of 1 makes sense for touch activities?)
Log(Logs::General, Logs::Tasks, "[UPDATE] Increment on Touch"); 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); Task->Activity[j].GoalCount - cur_task->Activity[j].DoneCount);
} }
} }
@ -2863,20 +2866,21 @@ void TaskManager::SendActiveTasksToClient(Client *c, bool TaskComplete)
GetActivityCount(TaskID)); GetActivityCount(TaskID));
int Sequence = 0; int Sequence = 0;
int fixed_index = Tasks[TaskID]->type == TaskType::Task ? 0 : TaskIndex - 1; // hmmm fuck
for (int Activity = 0; Activity < GetActivityCount(TaskID); Activity++) { 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, 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) if (Activity == GetActivityCount(TaskID) - 1)
SendTaskActivityLong(c, TaskID, Activity, TaskIndex, SendTaskActivityLong(c, TaskID, Activity, fixed_index,
Tasks[TaskID]->Activity[Activity].Optional, TaskComplete); Tasks[TaskID]->Activity[Activity].Optional, TaskComplete);
else else
SendTaskActivityLong(c, TaskID, Activity, TaskIndex, SendTaskActivityLong(c, TaskID, Activity, fixed_index,
Tasks[TaskID]->Activity[Activity].Optional, 0); Tasks[TaskID]->Activity[Activity].Optional, 0);
} else { } else {
Log(Logs::General, Logs::Tasks, "[UPDATE] Short: %i, %i, %i", TaskID, Activity, Log(Logs::General, Logs::Tasks, "[UPDATE] Short: %i, %i, %i", TaskID, Activity,
TaskIndex); fixed_index);
SendTaskActivityShort(c, TaskID, Activity, TaskIndex); SendTaskActivityShort(c, TaskID, Activity, fixed_index);
} }
Sequence++; Sequence++;
} }