This is the origal connection
Code:
void CDb::loadWeaponskillRanks(void)
MYSQL_RES * res;
MYSQL_ROW row;
MYSQL* mysqlConn;
char query[1024];
memset(query, 0, 1024);
int count;
sprintf(query, "SELECT max(id) FROM skill_ranks");
count = (int) strlen(query);
mysqlConn=CDb::getConn(); //get conn
mysql_real_query(mysqlConn, query, count);
res = mysql_store_result(mysqlConn);
CDb::pushConn(mysqlConn); //release conn
if (!res)
{
sLog.outError("Query to determine the number of weaponskills failed!");
return;
}
row = mysql_fetch_row(res);
unsigned char numWeaponSkills = atoi(row[0]);
mysql_free_result(res);
if (numWeaponSkills == 0)
{
sLog.outError("Failed to load weapon skill ranks from db! No weapon skills in table skill_ranks");
return;
}
maxWeaponSkillId = numWeaponSkills;
m_pSkillRanks = new char*[NUMJOBS];
for (int job = 0; job < NUMJOBS; job++)
{
m_pSkillRanks[job] = new char[numWeaponSkills];
for (int wsId = 0; wsId < numWeaponSkills; wsId++)
m_pSkillRanks[job][wsId] = 0;
}
sprintf(query, "SELECT id,WAR,MNK,WHM,BLM,RDM,THF,PLD,DRK,BST,BRD,RNG,SAM,NIN,DRG,SMN,BLU,COR,PUP,DNC,SCH FROM skill_ranks ORDER BY skill_ranks.id ASC");
count = (int) strlen(query);
mysqlConn=CDb::getConn(); //get conn
mysql_real_query(mysqlConn, query, count);
res = mysql_store_result(mysqlConn);
CDb::pushConn(mysqlConn); //release conn
if (!res)
{
sLog.outError("Failed to query all weaponskills ranks!");
return;
}
int weaponSkillId;
while ((row = mysql_fetch_row(res))!=NULL)
{
weaponSkillId = atoi(row[0]);
for (int job = 1; job<=NUMJOBS; job++)
m_pSkillRanks[job-1][weaponSkillId-1] = atoi(row[job]);
}
sLog.outDebug("Successfully loaded weaponskill ranks!");
mysql_free_result(res);
}
BUT I HAVE BEEN TRYING TO CONVET IT TO A NEW DATABASE TYPE SYSTEM LIKE THIS.
Code:
void CDb::loadWeaponskillRanks(void)
{
/*
//We will need to clear this if we make a relaod command:::: m_WeaponSkillRanksclearMap.clear();
QueryResult *result = CharacterDatabase.Query("SELECT max(id) FROM skill_ranks");
if( !result )
{
barGoLink bar( 1 );
bar.step();
sLog.outString();
sLog.RedConsoleMsg(">> Loaded `skill_ranks`, table is empty.");
return;
}
barGoLink bar( result->GetRowCount() );
do
{
Field *fields = result->Fetch();
bar.step();
uint32 entry = fields[0].GetUInt32();
unsigned char numWeaponSkills = result->NextRow();//atoi(row[0]); << HERE IS WRONG TOO
if (numWeaponSkills == 0)
{
sLog.RedConsoleMsg("Failed to load weapon skill ranks from db! No weapon skills in table skill_ranks");
return;
}
maxWeaponSkillId = numWeaponSkills;
m_pSkillRanks = new char*[NUMJOBS];
for (int job = 0; job < NUMJOBS; job++)
{
m_pSkillRanks[job] = new char[numWeaponSkills];
for (int wsId = 0; wsId < numWeaponSkills; wsId++)
m_pSkillRanks[job][wsId] = 0;
}
} while (result->NextRow());
delete result;
sLog.outString();
QueryResult *result1 = CharacterDatabase.Query("SELECT id,WAR,MNK,WHM,BLM,RDM,THF,PLD,DRK,BST,BRD,RNG,SAM,NIN,DRG,SMN,BLU,COR,PUP,DNC,SCH FROM skill_ranks ORDER BY skill_ranks.id ASC");
if( !result1 )
{
barGoLink bar( 1 );
bar.step();
sLog.outString();
sLog.RedConsoleMsg(">> Loaded `skill_ranks`, table is empty.");
return;
}
barGoLink bar1( result1->GetRowCount() );
do
{
int weaponSkillId;
Field *fields = result1->Fetch();
bar1.step();
uint32 entry = fields[0].GetUInt32();
weaponSkillId = fields[0].GetUInt32();
for (int job = 1; job<=NUMJOBS; job++)
m_pSkillRanks[job-1][weaponSkillId-1] = result1->NextRow();//atoi(result1->Fetch()[job]); <<-- HERE IS WRONG I KNOW
}
while (result1->NextRow());
delete result1;
sLog.outString();
*/
}
Im trying to change this old code to this new code. but I dont know how to do it right becasue is has 2 connections scrings in one fuction block. I have been adding your database and tread and socket code with ace wrappers to our project at projectxi.org
But our new core test Idea is at wow-bro.com
You can check out the SVN here and tell me if you can help fix all the database connections I have ben trying to add the 3 database connections types. and were doing really well. every thing is there and working it just changing it it now to make it work for the database. I know that makes no sence.
Code:
https://getintoxi.svn.sourceforge.net/svnroot/getintoxi/
please help me.