mirror of
https://github.com/EQEmu/Server.git
synced 2026-04-10 03:42:25 +00:00
client_files/export main formatting [skip ci]
This commit is contained in:
parent
7ee28d6361
commit
ea98a71f22
@ -34,7 +34,8 @@ void ExportSkillCaps(SharedDatabase *db);
|
|||||||
void ExportBaseData(SharedDatabase *db);
|
void ExportBaseData(SharedDatabase *db);
|
||||||
void ExportDBStrings(SharedDatabase *db);
|
void ExportDBStrings(SharedDatabase *db);
|
||||||
|
|
||||||
int main(int argc, char **argv) {
|
int main(int argc, char **argv)
|
||||||
|
{
|
||||||
RegisterExecutablePlatform(ExePlatformClientExport);
|
RegisterExecutablePlatform(ExePlatformClientExport);
|
||||||
LogSys.LoadLogSettingsDefaults();
|
LogSys.LoadLogSettingsDefaults();
|
||||||
set_exception_handler();
|
set_exception_handler();
|
||||||
@ -49,8 +50,13 @@ int main(int argc, char **argv) {
|
|||||||
|
|
||||||
SharedDatabase database;
|
SharedDatabase database;
|
||||||
LogInfo("Connecting to database");
|
LogInfo("Connecting to database");
|
||||||
if(!database.Connect(Config->DatabaseHost.c_str(), Config->DatabaseUsername.c_str(),
|
if (!database.Connect(
|
||||||
Config->DatabasePassword.c_str(), Config->DatabaseDB.c_str(), Config->DatabasePort)) {
|
Config->DatabaseHost.c_str(),
|
||||||
|
Config->DatabaseUsername.c_str(),
|
||||||
|
Config->DatabasePassword.c_str(),
|
||||||
|
Config->DatabaseDB.c_str(),
|
||||||
|
Config->DatabasePort
|
||||||
|
)) {
|
||||||
LogError("Unable to connect to the database, cannot continue without a database connection");
|
LogError("Unable to connect to the database, cannot continue without a database connection");
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
@ -92,7 +98,8 @@ int main(int argc, char **argv) {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ExportSpells(SharedDatabase *db) {
|
void ExportSpells(SharedDatabase *db)
|
||||||
|
{
|
||||||
LogInfo("Exporting Spells");
|
LogInfo("Exporting Spells");
|
||||||
|
|
||||||
FILE *f = fopen("export/spells_us.txt", "w");
|
FILE *f = fopen("export/spells_us.txt", "w");
|
||||||
@ -120,50 +127,61 @@ void ExportSpells(SharedDatabase *db) {
|
|||||||
|
|
||||||
fprintf(f, "%s\n", line.c_str());
|
fprintf(f, "%s\n", line.c_str());
|
||||||
}
|
}
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
}
|
}
|
||||||
|
|
||||||
fclose(f);
|
fclose(f);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SkillUsable(SharedDatabase *db, int skill_id, int class_id) {
|
bool SkillUsable(SharedDatabase *db, int skill_id, int class_id)
|
||||||
|
{
|
||||||
|
|
||||||
bool res = false;
|
bool res = false;
|
||||||
|
|
||||||
std::string query = StringFormat("SELECT max(cap) FROM skill_caps WHERE class=%d AND skillID=%d",
|
std::string query = StringFormat(
|
||||||
class_id, skill_id);
|
"SELECT max(cap) FROM skill_caps WHERE class=%d AND skillID=%d",
|
||||||
|
class_id, skill_id
|
||||||
|
);
|
||||||
auto results = db->QueryDatabase(query);
|
auto results = db->QueryDatabase(query);
|
||||||
if (!results.Success()) {
|
if (!results.Success()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (results.RowCount() == 0)
|
if (results.RowCount() == 0) {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
auto row = results.begin();
|
auto row = results.begin();
|
||||||
if(row[0] && atoi(row[0]) > 0)
|
if (row[0] && atoi(row[0]) > 0) {
|
||||||
return true;
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
int GetSkill(SharedDatabase *db, int skill_id, int class_id, int level) {
|
int GetSkill(SharedDatabase *db, int skill_id, int class_id, int level)
|
||||||
|
{
|
||||||
|
|
||||||
std::string query = StringFormat("SELECT cap FROM skill_caps WHERE class=%d AND skillID=%d AND level=%d",
|
std::string query = StringFormat(
|
||||||
class_id, skill_id, level);
|
"SELECT cap FROM skill_caps WHERE class=%d AND skillID=%d AND level=%d",
|
||||||
|
class_id, skill_id, level
|
||||||
|
);
|
||||||
auto results = db->QueryDatabase(query);
|
auto results = db->QueryDatabase(query);
|
||||||
if (!results.Success()) {
|
if (!results.Success()) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (results.RowCount() == 0)
|
if (results.RowCount() == 0) {
|
||||||
return 0;
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
auto row = results.begin();
|
auto row = results.begin();
|
||||||
return atoi(row[0]);
|
return atoi(row[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ExportSkillCaps(SharedDatabase *db) {
|
void ExportSkillCaps(SharedDatabase *db)
|
||||||
|
{
|
||||||
LogInfo("Exporting Skill Caps");
|
LogInfo("Exporting Skill Caps");
|
||||||
|
|
||||||
FILE *f = fopen("export/SkillCaps.txt", "w");
|
FILE *f = fopen("export/SkillCaps.txt", "w");
|
||||||
@ -192,7 +210,8 @@ void ExportSkillCaps(SharedDatabase *db) {
|
|||||||
fclose(f);
|
fclose(f);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ExportBaseData(SharedDatabase *db) {
|
void ExportBaseData(SharedDatabase *db)
|
||||||
|
{
|
||||||
LogInfo("Exporting Base Data");
|
LogInfo("Exporting Base Data");
|
||||||
|
|
||||||
FILE *f = fopen("export/BaseData.txt", "w");
|
FILE *f = fopen("export/BaseData.txt", "w");
|
||||||
@ -208,8 +227,9 @@ void ExportBaseData(SharedDatabase *db) {
|
|||||||
std::string line;
|
std::string line;
|
||||||
unsigned int fields = results.ColumnCount();
|
unsigned int fields = results.ColumnCount();
|
||||||
for (unsigned int rowIndex = 0; rowIndex < fields; ++rowIndex) {
|
for (unsigned int rowIndex = 0; rowIndex < fields; ++rowIndex) {
|
||||||
if(rowIndex != 0)
|
if (rowIndex != 0) {
|
||||||
line.push_back('^');
|
line.push_back('^');
|
||||||
|
}
|
||||||
|
|
||||||
if (row[rowIndex] != nullptr) {
|
if (row[rowIndex] != nullptr) {
|
||||||
line += row[rowIndex];
|
line += row[rowIndex];
|
||||||
@ -223,7 +243,8 @@ void ExportBaseData(SharedDatabase *db) {
|
|||||||
fclose(f);
|
fclose(f);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ExportDBStrings(SharedDatabase *db) {
|
void ExportDBStrings(SharedDatabase *db)
|
||||||
|
{
|
||||||
LogInfo("Exporting DB Strings");
|
LogInfo("Exporting DB Strings");
|
||||||
|
|
||||||
FILE *f = fopen("export/dbstr_us.txt", "w");
|
FILE *f = fopen("export/dbstr_us.txt", "w");
|
||||||
@ -240,8 +261,9 @@ void ExportDBStrings(SharedDatabase *db) {
|
|||||||
std::string line;
|
std::string line;
|
||||||
unsigned int fields = results.ColumnCount();
|
unsigned int fields = results.ColumnCount();
|
||||||
for (unsigned int rowIndex = 0; rowIndex < fields; ++rowIndex) {
|
for (unsigned int rowIndex = 0; rowIndex < fields; ++rowIndex) {
|
||||||
if(rowIndex != 0)
|
if (rowIndex != 0) {
|
||||||
line.push_back('^');
|
line.push_back('^');
|
||||||
|
}
|
||||||
|
|
||||||
if (row[rowIndex] != nullptr) {
|
if (row[rowIndex] != nullptr) {
|
||||||
line += row[rowIndex];
|
line += row[rowIndex];
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user