mirror of
https://github.com/EQEmu/Server.git
synced 2026-02-27 03:02:26 +00:00
LoadMercTypes converted to QueryDatabase
This commit is contained in:
parent
87efd22394
commit
e907ab4f3e
@ -5851,35 +5851,30 @@ void Client::SendMercAssignPacket(uint32 entityID, uint32 unk01, uint32 unk02) {
|
|||||||
FastQueuePacket(&outapp);
|
FastQueuePacket(&outapp);
|
||||||
}
|
}
|
||||||
|
|
||||||
void NPC::LoadMercTypes(){
|
void NPC::LoadMercTypes() {
|
||||||
std::string errorMessage;
|
|
||||||
char* Query = 0;
|
|
||||||
char TempErrorMessageBuffer[MYSQL_ERRMSG_SIZE];
|
|
||||||
MYSQL_RES* DatasetResult;
|
|
||||||
MYSQL_ROW DataRow;
|
|
||||||
|
|
||||||
if(!database.RunQuery(Query, MakeAnyLenString(&Query, "SELECT DISTINCT MTyp.dbstring, MTyp.clientversion FROM merc_merchant_entries MME, merc_merchant_template_entries MMTE, merc_types MTyp, merc_templates MTem WHERE MME.merchant_id = %i AND MME.merc_merchant_template_id = MMTE.merc_merchant_template_id AND MMTE.merc_template_id = MTem.merc_template_id AND MTem.merc_type_id = MTyp.merc_type_id;", GetNPCTypeID()), TempErrorMessageBuffer, &DatasetResult)) {
|
std::string query = StringFormat("SELECT DISTINCT MTyp.dbstring, MTyp.clientversion "
|
||||||
errorMessage = std::string(TempErrorMessageBuffer);
|
"FROM merc_merchant_entries MME, merc_merchant_template_entries MMTE, "
|
||||||
}
|
"merc_types MTyp, merc_templates MTem "
|
||||||
else {
|
"WHERE MME.merchant_id = %i "
|
||||||
while(DataRow = mysql_fetch_row(DatasetResult)) {
|
"AND MME.merc_merchant_template_id = MMTE.merc_merchant_template_id "
|
||||||
MercType tempMercType;
|
"AND MMTE.merc_template_id = MTem.merc_template_id "
|
||||||
|
"AND MTem.merc_type_id = MTyp.merc_type_id;", GetNPCTypeID());
|
||||||
|
auto results = database.QueryDatabase(query);
|
||||||
|
if (!results.Success()) {
|
||||||
|
LogFile->write(EQEMuLog::Error, "Error in NPC::LoadMercTypes()");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
tempMercType.Type = atoi(DataRow[0]);
|
for (auto row = results.begin(); row != results.end(); ++row) {
|
||||||
tempMercType.ClientVersion = atoi(DataRow[1]);
|
MercType tempMercType;
|
||||||
|
|
||||||
mercTypeList.push_back(tempMercType);
|
tempMercType.Type = atoi(row[0]);
|
||||||
}
|
tempMercType.ClientVersion = atoi(row[1]);
|
||||||
|
|
||||||
mysql_free_result(DatasetResult);
|
mercTypeList.push_back(tempMercType);
|
||||||
}
|
}
|
||||||
|
|
||||||
safe_delete_array(Query);
|
|
||||||
Query = 0;
|
|
||||||
|
|
||||||
if(!errorMessage.empty()) {
|
|
||||||
LogFile->write(EQEMuLog::Error, "Error in NPC::LoadMercTypes()");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void NPC::LoadMercs(){
|
void NPC::LoadMercs(){
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user