mirror of
https://github.com/EQEmu/Server.git
synced 2025-12-12 05:21:29 +00:00
LoadTaskSets converted to QueryDatabase
This commit is contained in:
parent
2bee906784
commit
be7d2e9457
@ -60,41 +60,32 @@ TaskManager::~TaskManager() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool TaskManager::LoadTaskSets() {
|
bool TaskManager::LoadTaskSets() {
|
||||||
const char *TaskSetQuery = "SELECT `id`, `taskid` from `tasksets` WHERE `id` > 0 AND `id` < %i "
|
|
||||||
"AND `taskid` >= 0 AND `taskid` < %i ORDER BY `id`, `taskid` ASC";
|
|
||||||
const char *ERR_MYSQLERROR = "[TASKS]Error in TaskManager::LoadTaskSets: %s";
|
|
||||||
|
|
||||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
|
||||||
char* query = 0;
|
|
||||||
MYSQL_RES *result;
|
|
||||||
MYSQL_ROW row;
|
|
||||||
|
|
||||||
// Clear all task sets in memory. Done so we can reload them on the fly if required by just calling
|
// Clear all task sets in memory. Done so we can reload them on the fly if required by just calling
|
||||||
// this method again.
|
// this method again.
|
||||||
for(int i=0; i<MAXTASKSETS; i++) {
|
for(int i=0; i<MAXTASKSETS; i++)
|
||||||
TaskSets[i].clear();
|
TaskSets[i].clear();
|
||||||
}
|
|
||||||
|
|
||||||
if(database.RunQuery(query,MakeAnyLenString(&query,TaskSetQuery,MAXTASKSETS,MAXTASKS),errbuf,&result)) {
|
std::string query = StringFormat("SELECT `id`, `taskid` from `tasksets` "
|
||||||
|
"WHERE `id` > 0 AND `id` < %i "
|
||||||
while((row = mysql_fetch_row(result))) {
|
"AND `taskid` >= 0 AND `taskid` < %i "
|
||||||
int TaskSet = atoi(row[0]);
|
"ORDER BY `id`, `taskid` ASC",
|
||||||
int TaskID = atoi(row[1]);
|
MAXTASKSETS, MAXTASKS);
|
||||||
|
auto results = database.QueryDatabase(query);
|
||||||
TaskSets[TaskSet].push_back(TaskID);
|
if (!results.Success()) {
|
||||||
_log(TASKS__GLOBALLOAD, "Adding TaskID %4i to TaskSet %4i", TaskID, TaskSet);
|
LogFile->write(EQEMuLog::Error, "[TASKS]Error in TaskManager::LoadTaskSets: %s", results.ErrorMessage().c_str());
|
||||||
}
|
|
||||||
mysql_free_result(result);
|
|
||||||
safe_delete_array(query);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
LogFile->write(EQEMuLog::Error, ERR_MYSQLERROR, errbuf);
|
|
||||||
safe_delete_array(query);
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (auto row = results.begin(); row != results.end(); ++row) {
|
||||||
|
int taskSet = atoi(row[0]);
|
||||||
|
int taskID = atoi(row[1]);
|
||||||
|
|
||||||
|
TaskSets[taskSet].push_back(taskID);
|
||||||
|
_log(TASKS__GLOBALLOAD, "Adding TaskID %4i to TaskSet %4i", taskID, taskSet);
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool TaskManager::LoadSingleTask(int TaskID) {
|
bool TaskManager::LoadSingleTask(int TaskID) {
|
||||||
@ -1152,7 +1143,7 @@ void TaskManager::SendTaskSelector(Client *c, Mob *mob, int TaskCount, int *Task
|
|||||||
if(Tasks[TaskList[i]] != nullptr) break;
|
if(Tasks[TaskList[i]] != nullptr) break;
|
||||||
}
|
}
|
||||||
|
|
||||||
// FIXME: The 10 and 5 values in this calculation are to account for the string "ABCD" we are putting in 3 times.
|
// FIXME: The 10 and 5 values in this calculation are to account for the string "ABCD" we are putting in 3 times.
|
||||||
//
|
//
|
||||||
// Calculate how big the packet needs to be pased on the number of tasks and the
|
// Calculate how big the packet needs to be pased on the number of tasks and the
|
||||||
// size of the variable length strings.
|
// size of the variable length strings.
|
||||||
@ -1230,9 +1221,9 @@ void TaskManager::SendTaskSelector(Client *c, Mob *mob, int TaskCount, int *Task
|
|||||||
// FIXME: In live packets, these two strings appear to be the same as the Text1 and Text2
|
// FIXME: In live packets, these two strings appear to be the same as the Text1 and Text2
|
||||||
// strings from the first activity in the task, however the task chooser/selector
|
// strings from the first activity in the task, however the task chooser/selector
|
||||||
// does not appear to make use of them.
|
// does not appear to make use of them.
|
||||||
sprintf(Ptr, "ABCD");
|
sprintf(Ptr, "ABCD");
|
||||||
Ptr = Ptr + strlen(Ptr) + 1;
|
Ptr = Ptr + strlen(Ptr) + 1;
|
||||||
sprintf(Ptr, "ABCD");
|
sprintf(Ptr, "ABCD");
|
||||||
Ptr = Ptr + strlen(Ptr) + 1;
|
Ptr = Ptr + strlen(Ptr) + 1;
|
||||||
|
|
||||||
AvailableTaskTrailer = (AvailableTaskTrailer_Struct*)Ptr;
|
AvailableTaskTrailer = (AvailableTaskTrailer_Struct*)Ptr;
|
||||||
@ -1247,7 +1238,7 @@ void TaskManager::SendTaskSelector(Client *c, Mob *mob, int TaskCount, int *Task
|
|||||||
|
|
||||||
// In some packets, this next string looks like a short task summary, however it doesn't
|
// In some packets, this next string looks like a short task summary, however it doesn't
|
||||||
// appear anywhere in the client window.
|
// appear anywhere in the client window.
|
||||||
sprintf(Ptr, "ABCD");
|
sprintf(Ptr, "ABCD");
|
||||||
Ptr = Ptr + strlen(Ptr) + 1;
|
Ptr = Ptr + strlen(Ptr) + 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1979,7 +1970,7 @@ void ClientTaskState::IncrementDoneCount(Client *c, TaskInformation* Task, int T
|
|||||||
taskmanager->SendSingleActiveTaskToClient(c, TaskIndex, TaskComplete, false);
|
taskmanager->SendSingleActiveTaskToClient(c, TaskIndex, TaskComplete, false);
|
||||||
// Inform the client the task has been updated, both by a chat message
|
// Inform the client the task has been updated, both by a chat message
|
||||||
c->Message(0, "Your task '%s' has been updated.", Task->Title);
|
c->Message(0, "Your task '%s' has been updated.", Task->Title);
|
||||||
|
|
||||||
if(Task->Activity[ActivityID].GoalMethod != METHODQUEST) {
|
if(Task->Activity[ActivityID].GoalMethod != METHODQUEST) {
|
||||||
char buf[24];
|
char buf[24];
|
||||||
snprintf(buf, 23, "%d %d", ActiveTasks[TaskIndex].TaskID, ActiveTasks[TaskIndex].Activity[ActivityID].ActivityID);
|
snprintf(buf, 23, "%d %d", ActiveTasks[TaskIndex].TaskID, ActiveTasks[TaskIndex].Activity[ActivityID].ActivityID);
|
||||||
@ -1992,7 +1983,7 @@ void ClientTaskState::IncrementDoneCount(Client *c, TaskInformation* Task, int T
|
|||||||
QServ->PlayerLogEvent(Player_Log_Task_Updates, c->CharacterID(), event_desc);
|
QServ->PlayerLogEvent(Player_Log_Task_Updates, c->CharacterID(), event_desc);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// If this task is now complete, the Completed tasks will have been
|
// If this task is now complete, the Completed tasks will have been
|
||||||
// updated in UnlockActivities. Send the completed task list to the
|
// updated in UnlockActivities. Send the completed task list to the
|
||||||
// client. This is the same sequence the packets are sent on live.
|
// client. This is the same sequence the packets are sent on live.
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user