mirror of
https://github.com/EQEmu/Server.git
synced 2026-01-04 19:53:52 +00:00
Bulk load goallists
This commit is contained in:
parent
423bb7f0b3
commit
5c7eb0707f
@ -20,7 +20,7 @@
|
||||
*/
|
||||
|
||||
/**
|
||||
* This repository was automatically generated on Apr 5, 2020 and is NOT
|
||||
* This repository was automatically generated on Apr11, 2020 and is NOT
|
||||
* to be modified directly. Any repository modifications are meant to be made to
|
||||
* the repository extending the base. Any modifications to base repositories are to
|
||||
* be made by the generator only
|
||||
@ -41,7 +41,7 @@ public:
|
||||
|
||||
static std::string PrimaryKey()
|
||||
{
|
||||
return std::string("entry");
|
||||
return std::string("listid");
|
||||
}
|
||||
|
||||
static std::vector<std::string> Columns()
|
||||
@ -111,7 +111,7 @@ public:
|
||||
)
|
||||
{
|
||||
for (auto &goallists : goallistss) {
|
||||
if (goallists.entry == goallists_id) {
|
||||
if (goallists.listid == goallists_id) {
|
||||
return goallists;
|
||||
}
|
||||
}
|
||||
@ -168,7 +168,8 @@ public:
|
||||
|
||||
auto columns = Columns();
|
||||
|
||||
|
||||
update_values.push_back(columns[0] + " = " + std::to_string(goallists_entry.listid));
|
||||
update_values.push_back(columns[1] + " = " + std::to_string(goallists_entry.entry));
|
||||
|
||||
auto results = content_db.QueryDatabase(
|
||||
fmt::format(
|
||||
@ -176,7 +177,7 @@ public:
|
||||
TableName(),
|
||||
implode(", ", update_values),
|
||||
PrimaryKey(),
|
||||
goallists_entry.entry
|
||||
goallists_entry.listid
|
||||
)
|
||||
);
|
||||
|
||||
@ -189,7 +190,8 @@ public:
|
||||
{
|
||||
std::vector<std::string> insert_values;
|
||||
|
||||
|
||||
insert_values.push_back(std::to_string(goallists_entry.listid));
|
||||
insert_values.push_back(std::to_string(goallists_entry.entry));
|
||||
|
||||
auto results = content_db.QueryDatabase(
|
||||
fmt::format(
|
||||
@ -200,7 +202,7 @@ public:
|
||||
);
|
||||
|
||||
if (results.Success()) {
|
||||
goallists_entry.id = results.LastInsertedID();
|
||||
goallists_entry.listid = results.LastInsertedID();
|
||||
return goallists_entry;
|
||||
}
|
||||
|
||||
@ -218,7 +220,8 @@ public:
|
||||
for (auto &goallists_entry: goallists_entries) {
|
||||
std::vector<std::string> insert_values;
|
||||
|
||||
|
||||
insert_values.push_back(std::to_string(goallists_entry.listid));
|
||||
insert_values.push_back(std::to_string(goallists_entry.entry));
|
||||
|
||||
insert_chunks.push_back("(" + implode(",", insert_values) + ")");
|
||||
}
|
||||
|
||||
@ -30,7 +30,8 @@ Copyright (C) 2001-2008 EQEMu Development Team (http://eqemulator.net)
|
||||
#include "../common/rulesys.h"
|
||||
#include "../common/string_util.h"
|
||||
#include "../common/say_link.h"
|
||||
|
||||
#include "zonedb.h"
|
||||
#include "../common/repositories/goallists_repository.h"
|
||||
#include "client.h"
|
||||
#include "entity.h"
|
||||
#include "mob.h"
|
||||
@ -972,7 +973,7 @@ int TaskManager::GetTaskMinLevel(int TaskID)
|
||||
{
|
||||
return Tasks[TaskID]->MinLevel;
|
||||
}
|
||||
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -3370,42 +3371,44 @@ bool TaskGoalListManager::LoadLists()
|
||||
|
||||
TaskGoalLists.reserve(NumberOfLists);
|
||||
|
||||
int listIndex = 0;
|
||||
int list_index = 0;
|
||||
|
||||
for (auto row = results.begin(); row != results.end(); ++row) {
|
||||
int listID = atoi(row[0]);
|
||||
int listID = atoi(row[0]);
|
||||
int listSize = atoi(row[1]);
|
||||
|
||||
TaskGoalLists.push_back({listID, 0, 0});
|
||||
|
||||
TaskGoalLists[listIndex].GoalItemEntries.reserve(listSize);
|
||||
TaskGoalLists[list_index].GoalItemEntries.reserve(listSize);
|
||||
|
||||
listIndex++;
|
||||
list_index++;
|
||||
}
|
||||
|
||||
for (int listIndex = 0; listIndex < NumberOfLists; listIndex++) {
|
||||
auto goal_lists = GoallistsRepository::GetWhere("TRUE ORDER BY listid, entry ASC");
|
||||
|
||||
int listID = TaskGoalLists[listIndex].ListID;
|
||||
auto size = TaskGoalLists[listIndex].GoalItemEntries.capacity(); // this was only done for manual memory management, shouldn't need to do this
|
||||
query = StringFormat("SELECT `entry` from `goallists` "
|
||||
"WHERE `listid` = %i "
|
||||
"ORDER BY `entry` ASC LIMIT %i",
|
||||
listID, size);
|
||||
results = content_db.QueryDatabase(query);
|
||||
if (!results.Success()) {
|
||||
continue;
|
||||
}
|
||||
for (list_index = 0; list_index < NumberOfLists; list_index++) {
|
||||
|
||||
for (auto row = results.begin(); row != results.end(); ++row) {
|
||||
int list_id = TaskGoalLists[list_index].ListID;
|
||||
|
||||
int entry = atoi(row[0]);
|
||||
for (auto &entry: goal_lists) {
|
||||
if (entry.listid == list_id) {
|
||||
if (entry.entry < TaskGoalLists[list_index].Min) {
|
||||
TaskGoalLists[list_index].Min = entry.entry;
|
||||
}
|
||||
|
||||
if (entry < TaskGoalLists[listIndex].Min)
|
||||
TaskGoalLists[listIndex].Min = entry;
|
||||
if (entry.entry > TaskGoalLists[list_index].Max) {
|
||||
TaskGoalLists[list_index].Max = entry.entry;
|
||||
}
|
||||
|
||||
if (entry > TaskGoalLists[listIndex].Max)
|
||||
TaskGoalLists[listIndex].Max = entry;
|
||||
TaskGoalLists[list_index].GoalItemEntries.push_back(entry.entry);
|
||||
|
||||
TaskGoalLists[listIndex].GoalItemEntries.push_back(entry);
|
||||
LogTasksDetail(
|
||||
"Goal list index [{}] loading list [{}] entry [{}]",
|
||||
list_index,
|
||||
list_id,
|
||||
entry.entry
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user