mirror of
https://github.com/EQEmu/Server.git
synced 2026-03-10 06:02:25 +00:00
LoadLootDrops converted to QueryDatabase
This commit is contained in:
parent
c7faf8a03c
commit
74b8f38030
@ -1801,57 +1801,52 @@ void SharedDatabase::LoadLootTables(void *data, uint32 size) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void SharedDatabase::LoadLootDrops(void *data, uint32 size) {
|
void SharedDatabase::LoadLootDrops(void *data, uint32 size) {
|
||||||
EQEmu::FixedMemoryVariableHashSet<LootDrop_Struct> hash(reinterpret_cast<uint8*>(data), size);
|
|
||||||
const char *query = "SELECT lootdrop.id, lootdrop_entries.item_id, lootdrop_entries.item_charges, "
|
|
||||||
"lootdrop_entries.equip_item, lootdrop_entries.chance, lootdrop_entries.minlevel, "
|
|
||||||
"lootdrop_entries.maxlevel, lootdrop_entries.multiplier FROM lootdrop JOIN lootdrop_entries "
|
|
||||||
"ON lootdrop.id = lootdrop_entries.lootdrop_id ORDER BY lootdrop_id";
|
|
||||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
|
||||||
MYSQL_RES *result;
|
|
||||||
MYSQL_ROW row;
|
|
||||||
|
|
||||||
|
EQEmu::FixedMemoryVariableHashSet<LootDrop_Struct> hash(reinterpret_cast<uint8*>(data), size);
|
||||||
uint8 loot_drop[sizeof(LootDrop_Struct) + (sizeof(LootDropEntries_Struct) * 1260)];
|
uint8 loot_drop[sizeof(LootDrop_Struct) + (sizeof(LootDropEntries_Struct) * 1260)];
|
||||||
LootDrop_Struct *ld = reinterpret_cast<LootDrop_Struct*>(loot_drop);
|
LootDrop_Struct *ld = reinterpret_cast<LootDrop_Struct*>(loot_drop);
|
||||||
if(RunQuery(query, strlen(query), errbuf, &result)) {
|
|
||||||
uint32 current_id = 0;
|
|
||||||
uint32 current_entry = 0;
|
|
||||||
while(row = mysql_fetch_row(result)) {
|
|
||||||
uint32 id = static_cast<uint32>(atoul(row[0]));
|
|
||||||
if(id != current_id) {
|
|
||||||
if(current_id != 0) {
|
|
||||||
hash.insert(current_id, loot_drop, (sizeof(LootDrop_Struct) +
|
|
||||||
(sizeof(LootDropEntries_Struct) * ld->NumEntries)));
|
|
||||||
}
|
|
||||||
|
|
||||||
memset(loot_drop, 0, sizeof(LootDrop_Struct) + (sizeof(LootDropEntries_Struct) * 1260));
|
const std::string query = "SELECT lootdrop.id, lootdrop_entries.item_id, lootdrop_entries.item_charges, "
|
||||||
current_entry = 0;
|
"lootdrop_entries.equip_item, lootdrop_entries.chance, lootdrop_entries.minlevel, "
|
||||||
current_id = id;
|
"lootdrop_entries.maxlevel, lootdrop_entries.multiplier FROM lootdrop JOIN lootdrop_entries "
|
||||||
}
|
"ON lootdrop.id = lootdrop_entries.lootdrop_id ORDER BY lootdrop_id";
|
||||||
|
auto results = QueryDatabase(query);
|
||||||
|
if (!results.Success()) {
|
||||||
|
LogFile->write(EQEMuLog::Error, "Error getting loot drop info from database: %s, %s", query.c_str(), results.ErrorMessage().c_str());
|
||||||
|
}
|
||||||
|
|
||||||
if(current_entry >= 1260) {
|
uint32 current_id = 0;
|
||||||
continue;
|
uint32 current_entry = 0;
|
||||||
}
|
|
||||||
|
|
||||||
ld->Entries[current_entry].item_id = static_cast<uint32>(atoul(row[1]));
|
for (auto row = results.begin(); row != results.end(); ++row) {
|
||||||
ld->Entries[current_entry].item_charges = static_cast<int8>(atoi(row[2]));
|
uint32 id = static_cast<uint32>(atoul(row[0]));
|
||||||
ld->Entries[current_entry].equip_item = static_cast<uint8>(atoi(row[3]));
|
if(id != current_id) {
|
||||||
ld->Entries[current_entry].chance = static_cast<float>(atof(row[4]));
|
if(current_id != 0)
|
||||||
ld->Entries[current_entry].minlevel = static_cast<uint8>(atoi(row[5]));
|
hash.insert(current_id, loot_drop, (sizeof(LootDrop_Struct) +(sizeof(LootDropEntries_Struct) * ld->NumEntries)));
|
||||||
ld->Entries[current_entry].maxlevel = static_cast<uint8>(atoi(row[6]));
|
|
||||||
ld->Entries[current_entry].multiplier = static_cast<uint8>(atoi(row[7]));
|
|
||||||
|
|
||||||
++(ld->NumEntries);
|
memset(loot_drop, 0, sizeof(LootDrop_Struct) + (sizeof(LootDropEntries_Struct) * 1260));
|
||||||
++current_entry;
|
current_entry = 0;
|
||||||
}
|
current_id = id;
|
||||||
if(current_id != 0) {
|
}
|
||||||
hash.insert(current_id, loot_drop, (sizeof(LootDrop_Struct) +
|
|
||||||
(sizeof(LootDropEntries_Struct) * ld->NumEntries)));
|
if(current_entry >= 1260)
|
||||||
}
|
continue;
|
||||||
|
|
||||||
|
ld->Entries[current_entry].item_id = static_cast<uint32>(atoul(row[1]));
|
||||||
|
ld->Entries[current_entry].item_charges = static_cast<int8>(atoi(row[2]));
|
||||||
|
ld->Entries[current_entry].equip_item = static_cast<uint8>(atoi(row[3]));
|
||||||
|
ld->Entries[current_entry].chance = static_cast<float>(atof(row[4]));
|
||||||
|
ld->Entries[current_entry].minlevel = static_cast<uint8>(atoi(row[5]));
|
||||||
|
ld->Entries[current_entry].maxlevel = static_cast<uint8>(atoi(row[6]));
|
||||||
|
ld->Entries[current_entry].multiplier = static_cast<uint8>(atoi(row[7]));
|
||||||
|
|
||||||
|
++(ld->NumEntries);
|
||||||
|
++current_entry;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(current_id != 0)
|
||||||
|
hash.insert(current_id, loot_drop, (sizeof(LootDrop_Struct) + (sizeof(LootDropEntries_Struct) * ld->NumEntries)));
|
||||||
|
|
||||||
mysql_free_result(result);
|
|
||||||
} else {
|
|
||||||
LogFile->write(EQEMuLog::Error, "Error getting loot drop info from database: %s, %s", query, errbuf);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SharedDatabase::LoadLoot() {
|
bool SharedDatabase::LoadLoot() {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user