More work on importing... I need my escape stuff from other branch for this though

This commit is contained in:
KimLS 2013-10-21 16:41:34 -07:00
parent cdb29be4f3
commit ec6c5519a5
2 changed files with 54 additions and 4 deletions

View File

@ -95,7 +95,7 @@ void ExportSpells(SharedDatabase *db) {
fclose(f);
}
bool skill_usable(SharedDatabase *db, int skill_id, int class_id) {
bool SkillUsable(SharedDatabase *db, int skill_id, int class_id) {
char errbuf[MYSQL_ERRMSG_SIZE];
char *query = nullptr;
MYSQL_RES *result;
@ -117,7 +117,7 @@ bool skill_usable(SharedDatabase *db, int skill_id, int class_id) {
return res;
}
int get_skill(SharedDatabase *db, int skill_id, int class_id, int level) {
int GetSkill(SharedDatabase *db, int skill_id, int class_id, int level) {
char errbuf[MYSQL_ERRMSG_SIZE];
char *query = nullptr;
MYSQL_RES *result;
@ -148,10 +148,10 @@ void ExportSkillCaps(SharedDatabase *db) {
for(int cl = 1; cl <= 16; ++cl) {
for(int skill = 0; skill <= 77; ++skill) {
if(skill_usable(db, skill, cl)) {
if(SkillUsable(db, skill, cl)) {
int previous_cap = 0;
for(int level = 1; level <= 100; ++level) {
int cap = get_skill(db, skill, cl, level);
int cap = GetSkill(db, skill, cl, level);
if(cap < previous_cap) {
cap = previous_cap;
}

View File

@ -22,6 +22,7 @@
#include "../../common/platform.h"
#include "../../common/crash.h"
#include "../../common/rulesys.h"
#include "../../common/StringUtil.h"
void ImportSpells(SharedDatabase *db);
void ImportSkillCaps(SharedDatabase *db);
@ -58,11 +59,60 @@ int main(int argc, char **argv) {
return 0;
}
int GetSpellColumns(SharedDatabase *db) {
char errbuf[MYSQL_ERRMSG_SIZE];
char *query = "DESCRIBE spells_new";
MYSQL_RES *result;
MYSQL_ROW row;
int res = 0;
if(db->RunQuery(query, strlen(query), errbuf, &result)) {
while(row = mysql_fetch_row(result)) {
++res;
}
mysql_free_result(result);
} else {
LogFile->write(EQEMuLog::Error, "Error in GetSpellColumns query '%s' %s", query, errbuf);
}
return res;
}
void ImportSpells(SharedDatabase *db) {
LogFile->write(EQEMuLog::Status, "Importing Spells...");
FILE *f = fopen("import/spells_us.txt", "r");
if(!f) {
LogFile->write(EQEMuLog::Error, "Unable to open import/spells_us.txt to read, skipping.");
return;
}
int columns = GetSpellColumns(db);
char buffer[2048];
while(fgets(buffer, 2048, f)) {
auto split = SplitString(buffer, '^');
}
fclose(f);
}
void ImportSkillCaps(SharedDatabase *db) {
LogFile->write(EQEMuLog::Status, "Importing Skill Caps...");
FILE *f = fopen("import/SkillCaps.txt", "r");
if(!f) {
LogFile->write(EQEMuLog::Error, "Unable to open import/SkillCaps.txt to read, skipping.");
return;
}
fclose(f);
}
void ImportBaseData(SharedDatabase *db) {
LogFile->write(EQEMuLog::Status, "Importing Base Data...");
FILE *f = fopen("import/BaseData.txt", "r");
if(!f) {
LogFile->write(EQEMuLog::Error, "Unable to open import/BaseData.txt to read, skipping.");
return;
}
fclose(f);
}