db: prepare boot data queries
This commit is contained in:
@@ -899,21 +899,63 @@ bool CClientManager::InitializeItemTable()
|
||||
|
||||
bool CClientManager::InitializeSkillTable()
|
||||
{
|
||||
char query[4096];
|
||||
snprintf(query, sizeof(query),
|
||||
"SELECT dwVnum, szName, bType, bMaxLevel, dwSplashRange, "
|
||||
"szPointOn, szPointPoly, szSPCostPoly, szDurationPoly, szDurationSPCostPoly, "
|
||||
"szCooldownPoly, szMasterBonusPoly, setFlag+0, setAffectFlag+0, "
|
||||
"szPointOn2, szPointPoly2, szDurationPoly2, setAffectFlag2+0, "
|
||||
"szPointOn3, szPointPoly3, szDurationPoly3, szGrandMasterAddSPCostPoly, "
|
||||
"bLevelStep, bLevelLimit, prerequisiteSkillVnum, prerequisiteSkillLevel, iMaxHit, szSplashAroundDamageAdjustPoly, eSkillType+0, dwTargetRange "
|
||||
"FROM skill_proto%s ORDER BY dwVnum",
|
||||
GetTablePostfix());
|
||||
CStmt stmt;
|
||||
TSkillTable t;
|
||||
const std::string query = std::string(
|
||||
"SELECT dwVnum, COALESCE(szName, ''), bType, bMaxLevel, dwSplashRange, "
|
||||
"COALESCE(szPointOn, ''), COALESCE(szPointPoly, ''), COALESCE(szSPCostPoly, ''), "
|
||||
"COALESCE(szDurationPoly, ''), COALESCE(szDurationSPCostPoly, ''), COALESCE(szCooldownPoly, ''), "
|
||||
"COALESCE(szMasterBonusPoly, ''), setFlag+0, setAffectFlag+0, COALESCE(szPointOn2, ''), "
|
||||
"COALESCE(szPointPoly2, ''), COALESCE(szDurationPoly2, ''), setAffectFlag2+0, "
|
||||
"COALESCE(szPointOn3, ''), COALESCE(szPointPoly3, ''), COALESCE(szDurationPoly3, ''), "
|
||||
"COALESCE(szGrandMasterAddSPCostPoly, ''), bLevelStep, bLevelLimit, prerequisiteSkillVnum, "
|
||||
"prerequisiteSkillLevel, iMaxHit, COALESCE(szSplashAroundDamageAdjustPoly, ''), eSkillType+0, dwTargetRange "
|
||||
"FROM skill_proto")
|
||||
+ GetTablePostfix() + " ORDER BY dwVnum";
|
||||
|
||||
auto pkMsg = CDBManager::instance().DirectQuery(query);
|
||||
SQLResult * pRes = pkMsg->Get();
|
||||
memset(&t, 0, sizeof(t));
|
||||
|
||||
if (!pRes->uiNumRows)
|
||||
if (!PrepareBootStmt(stmt, query))
|
||||
return false;
|
||||
|
||||
if (!stmt.BindResult(MYSQL_TYPE_LONG, &t.dwVnum)
|
||||
|| !stmt.BindResult(MYSQL_TYPE_STRING, t.szName, sizeof(t.szName))
|
||||
|| !stmt.BindResult(MYSQL_TYPE_TINY, &t.bType)
|
||||
|| !stmt.BindResult(MYSQL_TYPE_TINY, &t.bMaxLevel)
|
||||
|| !stmt.BindResult(MYSQL_TYPE_LONG, &t.dwSplashRange)
|
||||
|| !stmt.BindResult(MYSQL_TYPE_STRING, t.szPointOn, sizeof(t.szPointOn))
|
||||
|| !stmt.BindResult(MYSQL_TYPE_STRING, t.szPointPoly, sizeof(t.szPointPoly))
|
||||
|| !stmt.BindResult(MYSQL_TYPE_STRING, t.szSPCostPoly, sizeof(t.szSPCostPoly))
|
||||
|| !stmt.BindResult(MYSQL_TYPE_STRING, t.szDurationPoly, sizeof(t.szDurationPoly))
|
||||
|| !stmt.BindResult(MYSQL_TYPE_STRING, t.szDurationSPCostPoly, sizeof(t.szDurationSPCostPoly))
|
||||
|| !stmt.BindResult(MYSQL_TYPE_STRING, t.szCooldownPoly, sizeof(t.szCooldownPoly))
|
||||
|| !stmt.BindResult(MYSQL_TYPE_STRING, t.szMasterBonusPoly, sizeof(t.szMasterBonusPoly))
|
||||
|| !stmt.BindResult(MYSQL_TYPE_LONG, &t.dwFlag)
|
||||
|| !stmt.BindResult(MYSQL_TYPE_LONG, &t.dwAffectFlag)
|
||||
|| !stmt.BindResult(MYSQL_TYPE_STRING, t.szPointOn2, sizeof(t.szPointOn2))
|
||||
|| !stmt.BindResult(MYSQL_TYPE_STRING, t.szPointPoly2, sizeof(t.szPointPoly2))
|
||||
|| !stmt.BindResult(MYSQL_TYPE_STRING, t.szDurationPoly2, sizeof(t.szDurationPoly2))
|
||||
|| !stmt.BindResult(MYSQL_TYPE_LONG, &t.dwAffectFlag2)
|
||||
|| !stmt.BindResult(MYSQL_TYPE_STRING, t.szPointOn3, sizeof(t.szPointOn3))
|
||||
|| !stmt.BindResult(MYSQL_TYPE_STRING, t.szPointPoly3, sizeof(t.szPointPoly3))
|
||||
|| !stmt.BindResult(MYSQL_TYPE_STRING, t.szDurationPoly3, sizeof(t.szDurationPoly3))
|
||||
|| !stmt.BindResult(MYSQL_TYPE_STRING, t.szGrandMasterAddSPCostPoly, sizeof(t.szGrandMasterAddSPCostPoly))
|
||||
|| !stmt.BindResult(MYSQL_TYPE_TINY, &t.bLevelStep)
|
||||
|| !stmt.BindResult(MYSQL_TYPE_TINY, &t.bLevelLimit)
|
||||
|| !stmt.BindResult(MYSQL_TYPE_LONG, &t.preSkillVnum)
|
||||
|| !stmt.BindResult(MYSQL_TYPE_TINY, &t.preSkillLevel)
|
||||
|| !stmt.BindResult(MYSQL_TYPE_LONG, &t.lMaxHit)
|
||||
|| !stmt.BindResult(MYSQL_TYPE_STRING, t.szSplashAroundDamageAdjustPoly, sizeof(t.szSplashAroundDamageAdjustPoly))
|
||||
|| !stmt.BindResult(MYSQL_TYPE_TINY, &t.bSkillAttrType)
|
||||
|| !stmt.BindResult(MYSQL_TYPE_LONG, &t.dwTargetRange))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!stmt.Execute())
|
||||
return false;
|
||||
|
||||
if (!stmt.iRows)
|
||||
{
|
||||
sys_err("no result from skill_proto");
|
||||
return false;
|
||||
@@ -925,63 +967,31 @@ bool CClientManager::InitializeSkillTable()
|
||||
m_vec_skillTable.clear();
|
||||
}
|
||||
|
||||
m_vec_skillTable.reserve(pRes->uiNumRows);
|
||||
m_vec_skillTable.reserve(stmt.iRows);
|
||||
|
||||
MYSQL_ROW data;
|
||||
int col;
|
||||
|
||||
while ((data = mysql_fetch_row(pRes->pSQLResult)))
|
||||
while (stmt.Fetch())
|
||||
{
|
||||
TSkillTable t;
|
||||
memset(&t, 0, sizeof(t));
|
||||
|
||||
col = 0;
|
||||
|
||||
str_to_number(t.dwVnum, data[col++]);
|
||||
strlcpy(t.szName, data[col++], sizeof(t.szName));
|
||||
str_to_number(t.bType, data[col++]);
|
||||
str_to_number(t.bMaxLevel, data[col++]);
|
||||
str_to_number(t.dwSplashRange, data[col++]);
|
||||
|
||||
strlcpy(t.szPointOn, data[col++], sizeof(t.szPointOn));
|
||||
strlcpy(t.szPointPoly, data[col++], sizeof(t.szPointPoly));
|
||||
strlcpy(t.szSPCostPoly, data[col++], sizeof(t.szSPCostPoly));
|
||||
strlcpy(t.szDurationPoly, data[col++], sizeof(t.szDurationPoly));
|
||||
strlcpy(t.szDurationSPCostPoly, data[col++], sizeof(t.szDurationSPCostPoly));
|
||||
strlcpy(t.szCooldownPoly, data[col++], sizeof(t.szCooldownPoly));
|
||||
strlcpy(t.szMasterBonusPoly, data[col++], sizeof(t.szMasterBonusPoly));
|
||||
|
||||
str_to_number(t.dwFlag, data[col++]);
|
||||
str_to_number(t.dwAffectFlag, data[col++]);
|
||||
|
||||
strlcpy(t.szPointOn2, data[col++], sizeof(t.szPointOn2));
|
||||
strlcpy(t.szPointPoly2, data[col++], sizeof(t.szPointPoly2));
|
||||
strlcpy(t.szDurationPoly2, data[col++], sizeof(t.szDurationPoly2));
|
||||
str_to_number(t.dwAffectFlag2, data[col++]);
|
||||
|
||||
// ADD_GRANDMASTER_SKILL
|
||||
strlcpy(t.szPointOn3, data[col++], sizeof(t.szPointOn3));
|
||||
strlcpy(t.szPointPoly3, data[col++], sizeof(t.szPointPoly3));
|
||||
strlcpy(t.szDurationPoly3, data[col++], sizeof(t.szDurationPoly3));
|
||||
|
||||
strlcpy(t.szGrandMasterAddSPCostPoly, data[col++], sizeof(t.szGrandMasterAddSPCostPoly));
|
||||
// END_OF_ADD_GRANDMASTER_SKILL
|
||||
|
||||
str_to_number(t.bLevelStep, data[col++]);
|
||||
str_to_number(t.bLevelLimit, data[col++]);
|
||||
str_to_number(t.preSkillVnum, data[col++]);
|
||||
str_to_number(t.preSkillLevel, data[col++]);
|
||||
|
||||
str_to_number(t.lMaxHit, data[col++]);
|
||||
|
||||
strlcpy(t.szSplashAroundDamageAdjustPoly, data[col++], sizeof(t.szSplashAroundDamageAdjustPoly));
|
||||
|
||||
str_to_number(t.bSkillAttrType, data[col++]);
|
||||
str_to_number(t.dwTargetRange, data[col++]);
|
||||
NullTerminateResult(t.szName, stmt.GetResultLength(1));
|
||||
NullTerminateResult(t.szPointOn, stmt.GetResultLength(5));
|
||||
NullTerminateResult(t.szPointPoly, stmt.GetResultLength(6));
|
||||
NullTerminateResult(t.szSPCostPoly, stmt.GetResultLength(7));
|
||||
NullTerminateResult(t.szDurationPoly, stmt.GetResultLength(8));
|
||||
NullTerminateResult(t.szDurationSPCostPoly, stmt.GetResultLength(9));
|
||||
NullTerminateResult(t.szCooldownPoly, stmt.GetResultLength(10));
|
||||
NullTerminateResult(t.szMasterBonusPoly, stmt.GetResultLength(11));
|
||||
NullTerminateResult(t.szPointOn2, stmt.GetResultLength(14));
|
||||
NullTerminateResult(t.szPointPoly2, stmt.GetResultLength(15));
|
||||
NullTerminateResult(t.szDurationPoly2, stmt.GetResultLength(16));
|
||||
NullTerminateResult(t.szPointOn3, stmt.GetResultLength(18));
|
||||
NullTerminateResult(t.szPointPoly3, stmt.GetResultLength(19));
|
||||
NullTerminateResult(t.szDurationPoly3, stmt.GetResultLength(20));
|
||||
NullTerminateResult(t.szGrandMasterAddSPCostPoly, stmt.GetResultLength(21));
|
||||
NullTerminateResult(t.szSplashAroundDamageAdjustPoly, stmt.GetResultLength(27));
|
||||
|
||||
sys_log(0, "SKILL: #%d %s flag %u point %s affect %u cooldown %s", t.dwVnum, t.szName, t.dwFlag, t.szPointOn, t.dwAffectFlag, t.szCooldownPoly);
|
||||
|
||||
m_vec_skillTable.push_back(t);
|
||||
memset(&t, 0, sizeof(t));
|
||||
}
|
||||
|
||||
return true;
|
||||
@@ -991,24 +1001,33 @@ bool CClientManager::InitializeBanwordTable()
|
||||
{
|
||||
m_vec_banwordTable.clear();
|
||||
|
||||
auto pkMsg = CDBManager::instance().DirectQuery("SELECT word FROM banword");
|
||||
CStmt stmt;
|
||||
TBanwordTable t;
|
||||
|
||||
SQLResult * pRes = pkMsg->Get();
|
||||
memset(&t, 0, sizeof(t));
|
||||
|
||||
if (pRes->uiNumRows == 0)
|
||||
if (!PrepareBootStmt(stmt, "SELECT COALESCE(word, '') FROM banword"))
|
||||
return false;
|
||||
|
||||
if (!stmt.BindResult(MYSQL_TYPE_STRING, t.szWord, sizeof(t.szWord)))
|
||||
return false;
|
||||
|
||||
if (!stmt.Execute())
|
||||
return false;
|
||||
|
||||
if (stmt.iRows == 0)
|
||||
return true;
|
||||
|
||||
MYSQL_ROW data;
|
||||
|
||||
while ((data = mysql_fetch_row(pRes->pSQLResult)))
|
||||
while (stmt.Fetch())
|
||||
{
|
||||
TBanwordTable t;
|
||||
NullTerminateResult(t.szWord, stmt.GetResultLength(0));
|
||||
|
||||
if (data[0])
|
||||
if (t.szWord[0])
|
||||
{
|
||||
strlcpy(t.szWord, data[0], sizeof(t.szWord));
|
||||
m_vec_banwordTable.push_back(t);
|
||||
}
|
||||
|
||||
memset(&t, 0, sizeof(t));
|
||||
}
|
||||
|
||||
sys_log(0, "BANWORD: total %d", m_vec_banwordTable.size());
|
||||
@@ -1017,15 +1036,40 @@ bool CClientManager::InitializeBanwordTable()
|
||||
|
||||
bool CClientManager::InitializeItemAttrTable()
|
||||
{
|
||||
char query[4096];
|
||||
snprintf(query, sizeof(query),
|
||||
"SELECT apply, apply+0, prob, lv1, lv2, lv3, lv4, lv5, weapon, body, wrist, foots, neck, head, shield, ear FROM item_attr%s ORDER BY apply",
|
||||
GetTablePostfix());
|
||||
CStmt stmt;
|
||||
TItemAttrTable t;
|
||||
const std::string query = std::string(
|
||||
"SELECT COALESCE(apply, ''), apply+0, prob, lv1, lv2, lv3, lv4, lv5, weapon, body, wrist, foots, neck, head, shield, ear "
|
||||
"FROM item_attr")
|
||||
+ GetTablePostfix() + " ORDER BY apply";
|
||||
|
||||
auto pkMsg = CDBManager::instance().DirectQuery(query);
|
||||
SQLResult * pRes = pkMsg->Get();
|
||||
if (!PrepareBootStmt(stmt, query))
|
||||
return false;
|
||||
|
||||
if (!pRes->uiNumRows)
|
||||
if (!stmt.BindResult(MYSQL_TYPE_STRING, t.szApply, sizeof(t.szApply))
|
||||
|| !stmt.BindResult(MYSQL_TYPE_LONG, &t.dwApplyIndex)
|
||||
|| !stmt.BindResult(MYSQL_TYPE_LONG, &t.dwProb)
|
||||
|| !stmt.BindResult(MYSQL_TYPE_LONG, &t.lValues[0])
|
||||
|| !stmt.BindResult(MYSQL_TYPE_LONG, &t.lValues[1])
|
||||
|| !stmt.BindResult(MYSQL_TYPE_LONG, &t.lValues[2])
|
||||
|| !stmt.BindResult(MYSQL_TYPE_LONG, &t.lValues[3])
|
||||
|| !stmt.BindResult(MYSQL_TYPE_LONG, &t.lValues[4])
|
||||
|| !stmt.BindResult(MYSQL_TYPE_TINY, &t.bMaxLevelBySet[ATTRIBUTE_SET_WEAPON])
|
||||
|| !stmt.BindResult(MYSQL_TYPE_TINY, &t.bMaxLevelBySet[ATTRIBUTE_SET_BODY])
|
||||
|| !stmt.BindResult(MYSQL_TYPE_TINY, &t.bMaxLevelBySet[ATTRIBUTE_SET_WRIST])
|
||||
|| !stmt.BindResult(MYSQL_TYPE_TINY, &t.bMaxLevelBySet[ATTRIBUTE_SET_FOOTS])
|
||||
|| !stmt.BindResult(MYSQL_TYPE_TINY, &t.bMaxLevelBySet[ATTRIBUTE_SET_NECK])
|
||||
|| !stmt.BindResult(MYSQL_TYPE_TINY, &t.bMaxLevelBySet[ATTRIBUTE_SET_HEAD])
|
||||
|| !stmt.BindResult(MYSQL_TYPE_TINY, &t.bMaxLevelBySet[ATTRIBUTE_SET_SHIELD])
|
||||
|| !stmt.BindResult(MYSQL_TYPE_TINY, &t.bMaxLevelBySet[ATTRIBUTE_SET_EAR]))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!stmt.Execute())
|
||||
return false;
|
||||
|
||||
if (!stmt.iRows)
|
||||
{
|
||||
sys_err("no result from item_attr");
|
||||
return false;
|
||||
@@ -1037,34 +1081,11 @@ bool CClientManager::InitializeItemAttrTable()
|
||||
m_vec_itemAttrTable.clear();
|
||||
}
|
||||
|
||||
m_vec_itemAttrTable.reserve(pRes->uiNumRows);
|
||||
m_vec_itemAttrTable.reserve(stmt.iRows);
|
||||
|
||||
MYSQL_ROW data;
|
||||
|
||||
while ((data = mysql_fetch_row(pRes->pSQLResult)))
|
||||
while (stmt.Fetch())
|
||||
{
|
||||
TItemAttrTable t;
|
||||
|
||||
memset(&t, 0, sizeof(TItemAttrTable));
|
||||
|
||||
int col = 0;
|
||||
|
||||
strlcpy(t.szApply, data[col++], sizeof(t.szApply));
|
||||
str_to_number(t.dwApplyIndex, data[col++]);
|
||||
str_to_number(t.dwProb, data[col++]);
|
||||
str_to_number(t.lValues[0], data[col++]);
|
||||
str_to_number(t.lValues[1], data[col++]);
|
||||
str_to_number(t.lValues[2], data[col++]);
|
||||
str_to_number(t.lValues[3], data[col++]);
|
||||
str_to_number(t.lValues[4], data[col++]);
|
||||
str_to_number(t.bMaxLevelBySet[ATTRIBUTE_SET_WEAPON], data[col++]);
|
||||
str_to_number(t.bMaxLevelBySet[ATTRIBUTE_SET_BODY], data[col++]);
|
||||
str_to_number(t.bMaxLevelBySet[ATTRIBUTE_SET_WRIST], data[col++]);
|
||||
str_to_number(t.bMaxLevelBySet[ATTRIBUTE_SET_FOOTS], data[col++]);
|
||||
str_to_number(t.bMaxLevelBySet[ATTRIBUTE_SET_NECK], data[col++]);
|
||||
str_to_number(t.bMaxLevelBySet[ATTRIBUTE_SET_HEAD], data[col++]);
|
||||
str_to_number(t.bMaxLevelBySet[ATTRIBUTE_SET_SHIELD], data[col++]);
|
||||
str_to_number(t.bMaxLevelBySet[ATTRIBUTE_SET_EAR], data[col++]);
|
||||
NullTerminateResult(t.szApply, stmt.GetResultLength(0));
|
||||
|
||||
sys_log(0, "ITEM_ATTR: %-20s %4lu { %3d %3d %3d %3d %3d } { %d %d %d %d %d %d %d }",
|
||||
t.szApply,
|
||||
@@ -1084,6 +1105,7 @@ bool CClientManager::InitializeItemAttrTable()
|
||||
t.bMaxLevelBySet[ATTRIBUTE_SET_EAR]);
|
||||
|
||||
m_vec_itemAttrTable.push_back(t);
|
||||
t = TItemAttrTable();
|
||||
}
|
||||
|
||||
return true;
|
||||
@@ -1091,15 +1113,40 @@ bool CClientManager::InitializeItemAttrTable()
|
||||
|
||||
bool CClientManager::InitializeItemRareTable()
|
||||
{
|
||||
char query[4096];
|
||||
snprintf(query, sizeof(query),
|
||||
"SELECT apply, apply+0, prob, lv1, lv2, lv3, lv4, lv5, weapon, body, wrist, foots, neck, head, shield, ear FROM item_attr_rare%s ORDER BY apply",
|
||||
GetTablePostfix());
|
||||
CStmt stmt;
|
||||
TItemAttrTable t;
|
||||
const std::string query = std::string(
|
||||
"SELECT COALESCE(apply, ''), apply+0, prob, lv1, lv2, lv3, lv4, lv5, weapon, body, wrist, foots, neck, head, shield, ear "
|
||||
"FROM item_attr_rare")
|
||||
+ GetTablePostfix() + " ORDER BY apply";
|
||||
|
||||
auto pkMsg = CDBManager::instance().DirectQuery(query);
|
||||
SQLResult * pRes = pkMsg->Get();
|
||||
if (!PrepareBootStmt(stmt, query))
|
||||
return false;
|
||||
|
||||
if (!pRes->uiNumRows)
|
||||
if (!stmt.BindResult(MYSQL_TYPE_STRING, t.szApply, sizeof(t.szApply))
|
||||
|| !stmt.BindResult(MYSQL_TYPE_LONG, &t.dwApplyIndex)
|
||||
|| !stmt.BindResult(MYSQL_TYPE_LONG, &t.dwProb)
|
||||
|| !stmt.BindResult(MYSQL_TYPE_LONG, &t.lValues[0])
|
||||
|| !stmt.BindResult(MYSQL_TYPE_LONG, &t.lValues[1])
|
||||
|| !stmt.BindResult(MYSQL_TYPE_LONG, &t.lValues[2])
|
||||
|| !stmt.BindResult(MYSQL_TYPE_LONG, &t.lValues[3])
|
||||
|| !stmt.BindResult(MYSQL_TYPE_LONG, &t.lValues[4])
|
||||
|| !stmt.BindResult(MYSQL_TYPE_TINY, &t.bMaxLevelBySet[ATTRIBUTE_SET_WEAPON])
|
||||
|| !stmt.BindResult(MYSQL_TYPE_TINY, &t.bMaxLevelBySet[ATTRIBUTE_SET_BODY])
|
||||
|| !stmt.BindResult(MYSQL_TYPE_TINY, &t.bMaxLevelBySet[ATTRIBUTE_SET_WRIST])
|
||||
|| !stmt.BindResult(MYSQL_TYPE_TINY, &t.bMaxLevelBySet[ATTRIBUTE_SET_FOOTS])
|
||||
|| !stmt.BindResult(MYSQL_TYPE_TINY, &t.bMaxLevelBySet[ATTRIBUTE_SET_NECK])
|
||||
|| !stmt.BindResult(MYSQL_TYPE_TINY, &t.bMaxLevelBySet[ATTRIBUTE_SET_HEAD])
|
||||
|| !stmt.BindResult(MYSQL_TYPE_TINY, &t.bMaxLevelBySet[ATTRIBUTE_SET_SHIELD])
|
||||
|| !stmt.BindResult(MYSQL_TYPE_TINY, &t.bMaxLevelBySet[ATTRIBUTE_SET_EAR]))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!stmt.Execute())
|
||||
return false;
|
||||
|
||||
if (!stmt.iRows)
|
||||
{
|
||||
sys_err("no result from item_attr_rare");
|
||||
return false;
|
||||
@@ -1111,34 +1158,11 @@ bool CClientManager::InitializeItemRareTable()
|
||||
m_vec_itemRareTable.clear();
|
||||
}
|
||||
|
||||
m_vec_itemRareTable.reserve(pRes->uiNumRows);
|
||||
m_vec_itemRareTable.reserve(stmt.iRows);
|
||||
|
||||
MYSQL_ROW data;
|
||||
|
||||
while ((data = mysql_fetch_row(pRes->pSQLResult)))
|
||||
while (stmt.Fetch())
|
||||
{
|
||||
TItemAttrTable t;
|
||||
|
||||
memset(&t, 0, sizeof(TItemAttrTable));
|
||||
|
||||
int col = 0;
|
||||
|
||||
strlcpy(t.szApply, data[col++], sizeof(t.szApply));
|
||||
str_to_number(t.dwApplyIndex, data[col++]);
|
||||
str_to_number(t.dwProb, data[col++]);
|
||||
str_to_number(t.lValues[0], data[col++]);
|
||||
str_to_number(t.lValues[1], data[col++]);
|
||||
str_to_number(t.lValues[2], data[col++]);
|
||||
str_to_number(t.lValues[3], data[col++]);
|
||||
str_to_number(t.lValues[4], data[col++]);
|
||||
str_to_number(t.bMaxLevelBySet[ATTRIBUTE_SET_WEAPON], data[col++]);
|
||||
str_to_number(t.bMaxLevelBySet[ATTRIBUTE_SET_BODY], data[col++]);
|
||||
str_to_number(t.bMaxLevelBySet[ATTRIBUTE_SET_WRIST], data[col++]);
|
||||
str_to_number(t.bMaxLevelBySet[ATTRIBUTE_SET_FOOTS], data[col++]);
|
||||
str_to_number(t.bMaxLevelBySet[ATTRIBUTE_SET_NECK], data[col++]);
|
||||
str_to_number(t.bMaxLevelBySet[ATTRIBUTE_SET_HEAD], data[col++]);
|
||||
str_to_number(t.bMaxLevelBySet[ATTRIBUTE_SET_SHIELD], data[col++]);
|
||||
str_to_number(t.bMaxLevelBySet[ATTRIBUTE_SET_EAR], data[col++]);
|
||||
NullTerminateResult(t.szApply, stmt.GetResultLength(0));
|
||||
|
||||
sys_log(0, "ITEM_RARE: %-20s %4lu { %3d %3d %3d %3d %3d } { %d %d %d %d %d %d %d }",
|
||||
t.szApply,
|
||||
@@ -1158,6 +1182,7 @@ bool CClientManager::InitializeItemRareTable()
|
||||
t.bMaxLevelBySet[ATTRIBUTE_SET_EAR]);
|
||||
|
||||
m_vec_itemRareTable.push_back(t);
|
||||
t = TItemAttrTable();
|
||||
}
|
||||
|
||||
return true;
|
||||
@@ -1167,15 +1192,38 @@ bool CClientManager::InitializeLandTable()
|
||||
{
|
||||
using namespace building;
|
||||
|
||||
char query[4096];
|
||||
|
||||
snprintf(query, sizeof(query),
|
||||
CStmt stmt;
|
||||
TLand t;
|
||||
int32_t mapIndex = 0;
|
||||
int32_t x = 0;
|
||||
int32_t y = 0;
|
||||
int32_t width = 0;
|
||||
int32_t height = 0;
|
||||
const std::string query = std::string(
|
||||
"SELECT id, map_index, x, y, width, height, guild_id, guild_level_limit, price "
|
||||
"FROM land%s WHERE enable='YES' ORDER BY id",
|
||||
GetTablePostfix());
|
||||
"FROM land")
|
||||
+ GetTablePostfix() + " WHERE enable='YES' ORDER BY id";
|
||||
|
||||
auto pkMsg = CDBManager::instance().DirectQuery(query);
|
||||
SQLResult * pRes = pkMsg->Get();
|
||||
memset(&t, 0, sizeof(t));
|
||||
|
||||
if (!PrepareBootStmt(stmt, query))
|
||||
return false;
|
||||
|
||||
if (!stmt.BindResult(MYSQL_TYPE_LONG, &t.dwID)
|
||||
|| !stmt.BindResult(MYSQL_TYPE_LONG, &mapIndex)
|
||||
|| !stmt.BindResult(MYSQL_TYPE_LONG, &x)
|
||||
|| !stmt.BindResult(MYSQL_TYPE_LONG, &y)
|
||||
|| !stmt.BindResult(MYSQL_TYPE_LONG, &width)
|
||||
|| !stmt.BindResult(MYSQL_TYPE_LONG, &height)
|
||||
|| !stmt.BindResult(MYSQL_TYPE_LONG, &t.dwGuildID)
|
||||
|| !stmt.BindResult(MYSQL_TYPE_TINY, &t.bGuildLevelLimit)
|
||||
|| !stmt.BindResult(MYSQL_TYPE_LONG, &t.dwPrice))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!stmt.Execute())
|
||||
return false;
|
||||
|
||||
if (!m_vec_kLandTable.empty())
|
||||
{
|
||||
@@ -1183,33 +1231,22 @@ bool CClientManager::InitializeLandTable()
|
||||
m_vec_kLandTable.clear();
|
||||
}
|
||||
|
||||
m_vec_kLandTable.reserve(pRes->uiNumRows);
|
||||
if (stmt.iRows > 0)
|
||||
m_vec_kLandTable.reserve(stmt.iRows);
|
||||
|
||||
MYSQL_ROW data;
|
||||
while (stmt.Fetch())
|
||||
{
|
||||
t.lMapIndex = mapIndex;
|
||||
t.x = x;
|
||||
t.y = y;
|
||||
t.width = width;
|
||||
t.height = height;
|
||||
|
||||
if (pRes->uiNumRows > 0)
|
||||
while ((data = mysql_fetch_row(pRes->pSQLResult)))
|
||||
{
|
||||
TLand t;
|
||||
sys_log(0, "LAND: %lu map %-4ld %7ldx%-7ld w %-4ld h %-4ld", t.dwID, t.lMapIndex, t.x, t.y, t.width, t.height);
|
||||
|
||||
memset(&t, 0, sizeof(t));
|
||||
|
||||
int col = 0;
|
||||
|
||||
str_to_number(t.dwID, data[col++]);
|
||||
str_to_number(t.lMapIndex, data[col++]);
|
||||
str_to_number(t.x, data[col++]);
|
||||
str_to_number(t.y, data[col++]);
|
||||
str_to_number(t.width, data[col++]);
|
||||
str_to_number(t.height, data[col++]);
|
||||
str_to_number(t.dwGuildID, data[col++]);
|
||||
str_to_number(t.bGuildLevelLimit, data[col++]);
|
||||
str_to_number(t.dwPrice, data[col++]);
|
||||
|
||||
sys_log(0, "LAND: %lu map %-4ld %7ldx%-7ld w %-4ld h %-4ld", t.dwID, t.lMapIndex, t.x, t.y, t.width, t.height);
|
||||
|
||||
m_vec_kLandTable.push_back(t);
|
||||
}
|
||||
m_vec_kLandTable.push_back(t);
|
||||
memset(&t, 0, sizeof(t));
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -1271,14 +1308,41 @@ bool CClientManager::InitializeObjectProto()
|
||||
{
|
||||
using namespace building;
|
||||
|
||||
char query[4096];
|
||||
snprintf(query, sizeof(query),
|
||||
"SELECT vnum, price, materials, upgrade_vnum, upgrade_limit_time, life, reg_1, reg_2, reg_3, reg_4, npc, group_vnum, dependent_group "
|
||||
"FROM object_proto%s ORDER BY vnum",
|
||||
GetTablePostfix());
|
||||
CStmt stmt;
|
||||
TObjectProto t;
|
||||
char materials[512];
|
||||
int32_t life = 0;
|
||||
int32_t regions[4] = {};
|
||||
const std::string query = std::string(
|
||||
"SELECT vnum, price, COALESCE(materials, ''), upgrade_vnum, upgrade_limit_time, life, reg_1, reg_2, reg_3, reg_4, npc, group_vnum, dependent_group "
|
||||
"FROM object_proto")
|
||||
+ GetTablePostfix() + " ORDER BY vnum";
|
||||
|
||||
auto pkMsg = CDBManager::instance().DirectQuery(query);
|
||||
SQLResult * pRes = pkMsg->Get();
|
||||
memset(&t, 0, sizeof(t));
|
||||
memset(materials, 0, sizeof(materials));
|
||||
|
||||
if (!PrepareBootStmt(stmt, query))
|
||||
return false;
|
||||
|
||||
if (!stmt.BindResult(MYSQL_TYPE_LONG, &t.dwVnum)
|
||||
|| !stmt.BindResult(MYSQL_TYPE_LONG, &t.dwPrice)
|
||||
|| !stmt.BindResult(MYSQL_TYPE_STRING, materials, sizeof(materials))
|
||||
|| !stmt.BindResult(MYSQL_TYPE_LONG, &t.dwUpgradeVnum)
|
||||
|| !stmt.BindResult(MYSQL_TYPE_LONG, &t.dwUpgradeLimitTime)
|
||||
|| !stmt.BindResult(MYSQL_TYPE_LONG, &life)
|
||||
|| !stmt.BindResult(MYSQL_TYPE_LONG, ®ions[0])
|
||||
|| !stmt.BindResult(MYSQL_TYPE_LONG, ®ions[1])
|
||||
|| !stmt.BindResult(MYSQL_TYPE_LONG, ®ions[2])
|
||||
|| !stmt.BindResult(MYSQL_TYPE_LONG, ®ions[3])
|
||||
|| !stmt.BindResult(MYSQL_TYPE_LONG, &t.dwNPCVnum)
|
||||
|| !stmt.BindResult(MYSQL_TYPE_LONG, &t.dwGroupVnum)
|
||||
|| !stmt.BindResult(MYSQL_TYPE_LONG, &t.dwDependOnGroupVnum))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!stmt.Execute())
|
||||
return false;
|
||||
|
||||
if (!m_vec_kObjectProto.empty())
|
||||
{
|
||||
@@ -1286,56 +1350,39 @@ bool CClientManager::InitializeObjectProto()
|
||||
m_vec_kObjectProto.clear();
|
||||
}
|
||||
|
||||
m_vec_kObjectProto.reserve(MAX(0, pRes->uiNumRows));
|
||||
if (stmt.iRows > 0)
|
||||
m_vec_kObjectProto.reserve(stmt.iRows);
|
||||
|
||||
MYSQL_ROW data;
|
||||
while (stmt.Fetch())
|
||||
{
|
||||
std::vector<std::pair<int, int> > vec;
|
||||
NullTerminateResult(materials, stmt.GetResultLength(2));
|
||||
parse_pair_number_string(materials, vec);
|
||||
|
||||
if (pRes->uiNumRows > 0)
|
||||
while ((data = mysql_fetch_row(pRes->pSQLResult)))
|
||||
t.lLife = life;
|
||||
t.lRegion[0] = regions[0];
|
||||
t.lRegion[1] = regions[1];
|
||||
t.lRegion[2] = regions[2];
|
||||
t.lRegion[3] = regions[3];
|
||||
|
||||
for (unsigned int i = 0; i < OBJECT_MATERIAL_MAX_NUM && i < vec.size(); ++i)
|
||||
{
|
||||
TObjectProto t;
|
||||
|
||||
memset(&t, 0, sizeof(t));
|
||||
|
||||
int col = 0;
|
||||
|
||||
str_to_number(t.dwVnum, data[col++]);
|
||||
str_to_number(t.dwPrice, data[col++]);
|
||||
|
||||
std::vector<std::pair<int, int> > vec;
|
||||
parse_pair_number_string(data[col++], vec);
|
||||
|
||||
for (unsigned int i = 0; i < OBJECT_MATERIAL_MAX_NUM && i < vec.size(); ++i)
|
||||
{
|
||||
std::pair<int, int> & r = vec[i];
|
||||
|
||||
t.kMaterials[i].dwItemVnum = r.first;
|
||||
t.kMaterials[i].dwCount = r.second;
|
||||
}
|
||||
|
||||
str_to_number(t.dwUpgradeVnum, data[col++]);
|
||||
str_to_number(t.dwUpgradeLimitTime, data[col++]);
|
||||
str_to_number(t.lLife, data[col++]);
|
||||
str_to_number(t.lRegion[0], data[col++]);
|
||||
str_to_number(t.lRegion[1], data[col++]);
|
||||
str_to_number(t.lRegion[2], data[col++]);
|
||||
str_to_number(t.lRegion[3], data[col++]);
|
||||
|
||||
// ADD_BUILDING_NPC
|
||||
str_to_number(t.dwNPCVnum, data[col++]);
|
||||
str_to_number(t.dwGroupVnum, data[col++]);
|
||||
str_to_number(t.dwDependOnGroupVnum, data[col++]);
|
||||
|
||||
t.lNPCX = 0;
|
||||
t.lNPCY = MAX(t.lRegion[1], t.lRegion[3])+300;
|
||||
// END_OF_ADD_BUILDING_NPC
|
||||
|
||||
sys_log(0, "OBJ_PROTO: vnum %lu price %lu mat %lu %lu",
|
||||
t.dwVnum, t.dwPrice, t.kMaterials[0].dwItemVnum, t.kMaterials[0].dwCount);
|
||||
|
||||
m_vec_kObjectProto.push_back(t);
|
||||
std::pair<int, int>& r = vec[i];
|
||||
t.kMaterials[i].dwItemVnum = r.first;
|
||||
t.kMaterials[i].dwCount = r.second;
|
||||
}
|
||||
|
||||
t.lNPCX = 0;
|
||||
t.lNPCY = MAX(t.lRegion[1], t.lRegion[3]) + 300;
|
||||
|
||||
sys_log(0, "OBJ_PROTO: vnum %lu price %lu mat %lu %lu",
|
||||
t.dwVnum, t.dwPrice, t.kMaterials[0].dwItemVnum, t.kMaterials[0].dwCount);
|
||||
|
||||
m_vec_kObjectProto.push_back(t);
|
||||
memset(&t, 0, sizeof(t));
|
||||
memset(materials, 0, sizeof(materials));
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -1343,11 +1390,41 @@ bool CClientManager::InitializeObjectTable()
|
||||
{
|
||||
using namespace building;
|
||||
|
||||
char query[4096];
|
||||
snprintf(query, sizeof(query), "SELECT id, land_id, vnum, map_index, x, y, x_rot, y_rot, z_rot, life FROM object%s ORDER BY id", GetTablePostfix());
|
||||
CStmt stmt;
|
||||
uint32_t id = 0;
|
||||
uint32_t landId = 0;
|
||||
uint32_t vnum = 0;
|
||||
int32_t mapIndex = 0;
|
||||
int32_t x = 0;
|
||||
int32_t y = 0;
|
||||
float xRot = 0.0f;
|
||||
float yRot = 0.0f;
|
||||
float zRot = 0.0f;
|
||||
int32_t life = 0;
|
||||
const std::string query = std::string(
|
||||
"SELECT id, land_id, vnum, map_index, x, y, x_rot, y_rot, z_rot, life "
|
||||
"FROM object")
|
||||
+ GetTablePostfix() + " ORDER BY id";
|
||||
|
||||
auto pkMsg = CDBManager::instance().DirectQuery(query);
|
||||
SQLResult * pRes = pkMsg->Get();
|
||||
if (!PrepareBootStmt(stmt, query))
|
||||
return false;
|
||||
|
||||
if (!stmt.BindResult(MYSQL_TYPE_LONG, &id)
|
||||
|| !stmt.BindResult(MYSQL_TYPE_LONG, &landId)
|
||||
|| !stmt.BindResult(MYSQL_TYPE_LONG, &vnum)
|
||||
|| !stmt.BindResult(MYSQL_TYPE_LONG, &mapIndex)
|
||||
|| !stmt.BindResult(MYSQL_TYPE_LONG, &x)
|
||||
|| !stmt.BindResult(MYSQL_TYPE_LONG, &y)
|
||||
|| !stmt.BindResult(MYSQL_TYPE_FLOAT, &xRot)
|
||||
|| !stmt.BindResult(MYSQL_TYPE_FLOAT, &yRot)
|
||||
|| !stmt.BindResult(MYSQL_TYPE_FLOAT, &zRot)
|
||||
|| !stmt.BindResult(MYSQL_TYPE_LONG, &life))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!stmt.Execute())
|
||||
return false;
|
||||
|
||||
if (!m_map_pkObjectTable.empty())
|
||||
{
|
||||
@@ -1355,33 +1432,27 @@ bool CClientManager::InitializeObjectTable()
|
||||
m_map_pkObjectTable.clear();
|
||||
}
|
||||
|
||||
MYSQL_ROW data;
|
||||
while (stmt.Fetch())
|
||||
{
|
||||
TObject* k = new TObject;
|
||||
memset(k, 0, sizeof(TObject));
|
||||
|
||||
if (pRes->uiNumRows > 0)
|
||||
while ((data = mysql_fetch_row(pRes->pSQLResult)))
|
||||
{
|
||||
TObject * k = new TObject;
|
||||
k->dwID = id;
|
||||
k->dwLandID = landId;
|
||||
k->dwVnum = vnum;
|
||||
k->lMapIndex = mapIndex;
|
||||
k->x = x;
|
||||
k->y = y;
|
||||
k->xRot = xRot;
|
||||
k->yRot = yRot;
|
||||
k->zRot = zRot;
|
||||
k->lLife = life;
|
||||
|
||||
memset(k, 0, sizeof(TObject));
|
||||
sys_log(0, "OBJ: %lu vnum %lu map %-4ld %7ldx%-7ld life %ld",
|
||||
k->dwID, k->dwVnum, k->lMapIndex, k->x, k->y, k->lLife);
|
||||
|
||||
int col = 0;
|
||||
|
||||
str_to_number(k->dwID, data[col++]);
|
||||
str_to_number(k->dwLandID, data[col++]);
|
||||
str_to_number(k->dwVnum, data[col++]);
|
||||
str_to_number(k->lMapIndex, data[col++]);
|
||||
str_to_number(k->x, data[col++]);
|
||||
str_to_number(k->y, data[col++]);
|
||||
str_to_number(k->xRot, data[col++]);
|
||||
str_to_number(k->yRot, data[col++]);
|
||||
str_to_number(k->zRot, data[col++]);
|
||||
str_to_number(k->lLife, data[col++]);
|
||||
|
||||
sys_log(0, "OBJ: %lu vnum %lu map %-4ld %7ldx%-7ld life %ld",
|
||||
k->dwID, k->dwVnum, k->lMapIndex, k->x, k->y, k->lLife);
|
||||
|
||||
m_map_pkObjectTable.insert(std::make_pair(k->dwID, k));
|
||||
}
|
||||
m_map_pkObjectTable.insert(std::make_pair(k->dwID, k));
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user