More changes to task system

This commit is contained in:
Michael Cook (mackal) 2018-06-13 17:08:21 -04:00
parent 4662f29f11
commit 0765d273ea
3 changed files with 41 additions and 23 deletions

View File

@ -0,0 +1,2 @@
ALTER TABLE `tasks` ADD `type` TINYINT NOT NULL DEFAULT '0' AFTER `id`;
ALTER TABLE `tasks` ADD `duration_code` TINYINT NOT NULL DEFAULT '0' AFTER `duration`;

View File

@ -115,16 +115,14 @@ bool TaskManager::LoadTasks(int singleTask)
if (!LoadTaskSets())
Log(Logs::Detail, Logs::Tasks, "TaskManager::LoadTasks LoadTaskSets failed");
query = StringFormat("SELECT `id`, `duration`, `title`, `description`, `reward`, "
"`rewardid`, `cashreward`, `xpreward`, `rewardmethod`, "
"`startzone`, `minlevel`, `maxlevel`, `repeatable` "
"FROM `tasks` WHERE `id` < %i",
query = StringFormat("SELECT `id`, `type`, `duration`, `duration_code`, `title`, `description`, "
"`reward`, `rewardid`, `cashreward`, `xpreward`, `rewardmethod`, `startzone`, "
"`minlevel`, `maxlevel`, `repeatable` FROM `tasks` WHERE `id` < %i",
MAXTASKS);
} else
query = StringFormat("SELECT `id`, `duration`, `title`, `description`, `reward`, "
"`rewardid`, `cashreward`, `xpreward`, `rewardmethod`, "
"`startzone`, `minlevel`, `maxlevel`, `repeatable` "
"FROM `tasks` WHERE `id` = %i",
query = StringFormat("SELECT `id`, `type`, `duration`, `duration_code`, `title`, `description`, "
"`reward`, `rewardid`, `cashreward`, `xpreward`, `rewardmethod`, `startzone`, "
"`minlevel`, `maxlevel`, `repeatable` FROM `tasks` WHERE `id` = %i",
singleTask);
const char *ERR_MYSQLERROR = "[TASKS]Error in TaskManager::LoadTasks: %s";
@ -146,18 +144,20 @@ bool TaskManager::LoadTasks(int singleTask)
}
Tasks[taskID] = new TaskInformation;
Tasks[taskID]->Duration = atoi(row[1]);
Tasks[taskID]->Title = row[2];
Tasks[taskID]->Description = row[3];
Tasks[taskID]->Reward = row[4];
Tasks[taskID]->RewardID = atoi(row[5]);
Tasks[taskID]->CashReward = atoi(row[6]);
Tasks[taskID]->XPReward = atoi(row[7]);
Tasks[taskID]->RewardMethod = (TaskMethodType)atoi(row[8]);
Tasks[taskID]->StartZone = atoi(row[9]);
Tasks[taskID]->MinLevel = atoi(row[10]);
Tasks[taskID]->MaxLevel = atoi(row[11]);
Tasks[taskID]->Repeatable = atoi(row[12]);
Tasks[taskID]->type = static_cast<TaskType>(atoi(row[1]));
Tasks[taskID]->Duration = atoi(row[2]);
Tasks[taskID]->dur_code = static_cast<DurationCode>(atoi(row[3]));
Tasks[taskID]->Title = row[4];
Tasks[taskID]->Description = row[5];
Tasks[taskID]->Reward = row[6];
Tasks[taskID]->RewardID = atoi(row[7]);
Tasks[taskID]->CashReward = atoi(row[8]);
Tasks[taskID]->XPReward = atoi(row[9]);
Tasks[taskID]->RewardMethod = (TaskMethodType)atoi(row[10]);
Tasks[taskID]->StartZone = atoi(row[11]);
Tasks[taskID]->MinLevel = atoi(row[12]);
Tasks[taskID]->MaxLevel = atoi(row[13]);
Tasks[taskID]->Repeatable = atoi(row[14]);
Tasks[taskID]->ActivityCount = 0;
Tasks[taskID]->SequenceMode = ActivitiesSequential;
Tasks[taskID]->LastStep = 0;
@ -1069,7 +1069,7 @@ void TaskManager::SendTaskSelector(Client *c, Mob *mob, int TaskCount, int *Task
AvailableTaskData1->TimeLimit = Tasks[TaskList[i]]->Duration;
AvailableTaskData1->unknown2 = 0;
AvailableTaskData1->unknown2 = static_cast<int>(Tasks[TaskList[i]]->dur_code); // guess
Ptr = (char *)AvailableTaskData1 + sizeof(AvailableTaskData1_Struct);
@ -1185,7 +1185,7 @@ void TaskManager::SendTaskSelectorNew(Client *c, Mob *mob, int TaskCount, int *T
outapp->WriteUInt32(TaskList[i]); // TaskID
outapp->WriteFloat(1.0f); // affects color, difficulty?
outapp->WriteUInt32(Tasks[TaskList[i]]->Duration);
outapp->WriteUInt32(0); // 1 = Short, 2 = Medium, 3 = Long, anything else Unlimited
outapp->WriteUInt32(static_cast<int>(Tasks[TaskList[i]]->dur_code)); // 1 = Short, 2 = Medium, 3 = Long, anything else Unlimited
outapp->WriteString(Tasks[TaskList[i]]->Title.c_str()); // max 64 with null
outapp->WriteString(Tasks[TaskList[i]]->Description.c_str()); // max 4000 with null

View File

@ -115,10 +115,26 @@ struct ActivityInformation {
typedef enum { ActivitiesSequential = 0, ActivitiesStepped = 1 } SequenceType;
enum class TaskType {
Task = 0, // can have at max 1
Shared = 1, // can have at max 1
Quest = 2, // can have at max 19 or 29 depending on client
E = 3 // can have at max 19 or 29 depending on client, not present in live anymore
};
enum class DurationCode {
None = 0,
Short = 1,
Medium = 2,
Long = 3
};
struct TaskInformation {
TaskType type;
int Duration;
DurationCode dur_code; // description for time investment for when Duration == 0
std::string Title; // max length 64
std::string Description; // max length 4000
std::string Description; // max length 4000, 2048 on Tit
std::string Reward;
int RewardID;
int CashReward; // Expressed in copper