mirror of
https://github.com/EQEmu/Server.git
synced 2026-05-22 20:33:01 +00:00
Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 29bdc86d12 | |||
| f2f05479dc | |||
| 5e0b388cf9 |
@@ -1,87 +1,3 @@
|
||||
## [22.62.1] 1/27/2025
|
||||
|
||||
### Memory Leak
|
||||
|
||||
* Revert "Change raw pointer to unique_ptr to avoid potential leak in dbg stream" ([#4616](https://github.com/EQEmu/Server/pull/4616)) @Akkadius 2025-01-27
|
||||
|
||||
### Performance
|
||||
|
||||
* Re-use ClientUpdate packet memory ([#4619](https://github.com/EQEmu/Server/pull/4619)) @Akkadius 2025-01-27
|
||||
* Re-use OP_Animation packet ([#4621](https://github.com/EQEmu/Server/pull/4621)) @Akkadius 2025-01-27
|
||||
* Re-use OP_Damage packet memory ([#4625](https://github.com/EQEmu/Server/pull/4625)) @Akkadius 2025-01-27
|
||||
* Re-use OP_HPUpdate packet memory ([#4622](https://github.com/EQEmu/Server/pull/4622)) @Akkadius 2025-01-27
|
||||
* Re-use OP_PlayerStateAdd packet memory ([#4626](https://github.com/EQEmu/Server/pull/4626)) @Akkadius 2025-01-27
|
||||
* Re-use OP_SendFindableNPCs packet memory ([#4623](https://github.com/EQEmu/Server/pull/4623)) @Akkadius 2025-01-27
|
||||
|
||||
### Repop
|
||||
|
||||
* Make #repop instant ([#4620](https://github.com/EQEmu/Server/pull/4620)) @Akkadius 2025-01-27
|
||||
|
||||
## [22.62.0] 1/26/2025
|
||||
|
||||
### Bazaar
|
||||
|
||||
* Improve Bazaar Search Performance ([#4615](https://github.com/EQEmu/Server/pull/4615)) @neckkola 2025-01-27
|
||||
|
||||
### CLI
|
||||
|
||||
* Add --skip-backup to world database:updates ([#4605](https://github.com/EQEmu/Server/pull/4605)) @Akkadius 2025-01-22
|
||||
|
||||
### Database
|
||||
|
||||
* Change npc_types walkspeed to be of type float ([#4589](https://github.com/EQEmu/Server/pull/4589)) @Akkadius 2025-01-07
|
||||
|
||||
### Databuckets
|
||||
|
||||
* Add Account Scoped Databuckets ([#4603](https://github.com/EQEmu/Server/pull/4603)) @Akkadius 2025-01-21
|
||||
* Implement Nested Databuckets ([#4604](https://github.com/EQEmu/Server/pull/4604)) @Akkadius 2025-01-27
|
||||
|
||||
### Feature
|
||||
|
||||
* Add Alternate Bazaar Search Approach ([#4600](https://github.com/EQEmu/Server/pull/4600)) @neckkola 2025-01-20
|
||||
* Add Support for Item Previews ([#4599](https://github.com/EQEmu/Server/pull/4599)) @Kinglykrab 2025-01-20
|
||||
* Evolving Item Support for RoF2 ([#4496](https://github.com/EQEmu/Server/pull/4496)) @neckkola 2025-01-20
|
||||
* Implement Custom Pet Names ([#4594](https://github.com/EQEmu/Server/pull/4594)) @catapultam-habeo 2025-01-22
|
||||
|
||||
### Fixes
|
||||
|
||||
* Add Bazaar BulkSendTrader Limit for RoF2 ([#4590](https://github.com/EQEmu/Server/pull/4590)) @neckkola 2025-01-08
|
||||
* CLI help menu from parsing correctly in World @Akkadius 2025-01-22
|
||||
* Delete later in RemoveItem second case @Akkadius 2025-01-25
|
||||
* Fix query error in character_evolving_items @Akkadius 2025-01-21
|
||||
* Repair a memory leak in #summonitem ([#4591](https://github.com/EQEmu/Server/pull/4591)) @neckkola 2025-01-08
|
||||
* Repair an incorrect safe_delete call memory leak. ([#4588](https://github.com/EQEmu/Server/pull/4588)) @neckkola 2025-01-07
|
||||
* Repair levers opening the Evolving XP Transfer Window ([#4607](https://github.com/EQEmu/Server/pull/4607)) @neckkola 2025-01-23
|
||||
* Update a few Bazaar RoF2 routines for memory leaks ([#4592](https://github.com/EQEmu/Server/pull/4592)) @neckkola 2025-01-08
|
||||
* Update database version to match manifest @Akkadius 2025-01-21
|
||||
* Update trader add/remove packets to limits for RoF2 ([#4595](https://github.com/EQEmu/Server/pull/4595)) @neckkola 2025-01-19
|
||||
|
||||
### Linux
|
||||
|
||||
* Implement KSM Kernel Samepage Merging with Maps ([#4601](https://github.com/EQEmu/Server/pull/4601)) @Akkadius 2025-01-21
|
||||
|
||||
### Memory Leak
|
||||
|
||||
* Change raw pointer to unique_ptr to avoid potential leak in dbg stream ([#4616](https://github.com/EQEmu/Server/pull/4616)) @KimLS 2025-01-27
|
||||
* Fix leak in BuyTraderItemOutsideBazaar ([#4609](https://github.com/EQEmu/Server/pull/4609)) @Akkadius 2025-01-24
|
||||
* Fix leak in Client::RemoveDuplicateLore ([#4614](https://github.com/EQEmu/Server/pull/4614)) @Akkadius 2025-01-24
|
||||
* Fix leak in NPC::RemoveItem ([#4611](https://github.com/EQEmu/Server/pull/4611)) @Akkadius 2025-01-24
|
||||
* Fix leak in QuestManager::varlink ([#4610](https://github.com/EQEmu/Server/pull/4610)) @Akkadius 2025-01-24
|
||||
* Fix leaks in Client::Handle_OP_AugmentItem ([#4612](https://github.com/EQEmu/Server/pull/4612)) @Akkadius 2025-01-24
|
||||
* Fix memory leak in Client::Handle_OP_MoveMultipleItems ([#4613](https://github.com/EQEmu/Server/pull/4613)) @Akkadius 2025-01-24
|
||||
|
||||
### Performance
|
||||
|
||||
* Client / NPC Position Update Optimizations ([#4602](https://github.com/EQEmu/Server/pull/4602)) @Akkadius 2025-01-21
|
||||
|
||||
### Quest API
|
||||
|
||||
* Add SetAAEXPPercentage to Perl/Lua ([#4597](https://github.com/EQEmu/Server/pull/4597)) @Kinglykrab 2025-01-19
|
||||
|
||||
### Zone
|
||||
|
||||
* Implement zone player count sharding ([#4536](https://github.com/EQEmu/Server/pull/4536)) @Akkadius 2025-01-08
|
||||
|
||||
## [22.61.0] 1/6/2025
|
||||
|
||||
### Bots
|
||||
|
||||
+286
-225
@@ -6,8 +6,7 @@
|
||||
|
||||
std::vector<BazaarSearchResultsFromDB_Struct>
|
||||
Bazaar::GetSearchResults(
|
||||
Database &db,
|
||||
Database &content_db,
|
||||
SharedDatabase &db,
|
||||
BazaarSearchCriteria_Struct search,
|
||||
uint32 char_zone_id,
|
||||
int32 char_zone_instance_id
|
||||
@@ -32,132 +31,8 @@ Bazaar::GetSearchResults(
|
||||
char_zone_instance_id
|
||||
);
|
||||
|
||||
static std::map<uint8, uint32> item_slot_searches_new = {
|
||||
{EQ::invslot::slotCharm, 1},
|
||||
{EQ::invslot::slotEar1, 2},
|
||||
{EQ::invslot::slotHead, 4},
|
||||
{EQ::invslot::slotFace, 8},
|
||||
{EQ::invslot::slotEar2, 16},
|
||||
{EQ::invslot::slotNeck, 32},
|
||||
{EQ::invslot::slotShoulders, 64},
|
||||
{EQ::invslot::slotArms, 128},
|
||||
{EQ::invslot::slotBack, 256},
|
||||
{EQ::invslot::slotWrist1, 512},
|
||||
{EQ::invslot::slotWrist2, 1024},
|
||||
{EQ::invslot::slotRange, 2048},
|
||||
{EQ::invslot::slotHands, 4096},
|
||||
{EQ::invslot::slotPrimary, 8192},
|
||||
{EQ::invslot::slotSecondary, 16384},
|
||||
{EQ::invslot::slotFinger1, 32768},
|
||||
{EQ::invslot::slotFinger2, 65536},
|
||||
{EQ::invslot::slotChest, 131072},
|
||||
{EQ::invslot::slotLegs, 262144},
|
||||
{EQ::invslot::slotFeet, 524288},
|
||||
{EQ::invslot::slotWaist, 1048576},
|
||||
{EQ::invslot::slotPowerSource, 2097152},
|
||||
{EQ::invslot::slotAmmo, 4194304},
|
||||
};
|
||||
|
||||
struct ItemSearchType {
|
||||
EQ::item::ItemType type;
|
||||
std::string condition;
|
||||
};
|
||||
|
||||
std::vector<ItemSearchType> item_search_types_new = {
|
||||
{EQ::item::ItemType::ItemTypeBook, " AND (items.itemclass = 2 or items.itemclass = 31)"},
|
||||
{EQ::item::ItemType::ItemTypeContainer, " AND (items.itemclass = 1 or items.itemclass = 67)"},
|
||||
{EQ::item::ItemType::ItemTypeAllEffects, " AND (items.scrolleffect > 0 && items.scrolleffect < 65000)"},
|
||||
{EQ::item::ItemType::ItemTypeUnknown9, " AND items.worneffect = 998"},
|
||||
{EQ::item::ItemType::ItemTypeUnknown10, " AND (items.worneffect >= 1298 && items.worneffect <= 1307)"},
|
||||
{EQ::item::ItemType::ItemTypeFocusEffect, " AND items.focuseffect > 0"},
|
||||
{EQ::item::ItemType::ItemTypeArmor, " AND items.itemtype = 10"},
|
||||
{EQ::item::ItemType::ItemType1HBlunt, " AND items.itemtype = 3"},
|
||||
{EQ::item::ItemType::ItemType1HPiercing, " AND items.itemtype = 2"},
|
||||
{EQ::item::ItemType::ItemType1HSlash, " AND items.itemtype = 0"},
|
||||
{EQ::item::ItemType::ItemType2HBlunt, " AND items.itemtype = 4"},
|
||||
{EQ::item::ItemType::ItemType2HSlash, " AND items.itemtype = 1"},
|
||||
{EQ::item::ItemType::ItemTypeBow, " AND items.itemtype = 5"},
|
||||
{EQ::item::ItemType::ItemTypeShield, " AND items.itemtype = 8"},
|
||||
{EQ::item::ItemType::ItemTypeMisc, " AND items.itemtype = 11"},
|
||||
{EQ::item::ItemType::ItemTypeFood, " AND items.itemtype = 14"},
|
||||
{EQ::item::ItemType::ItemTypeDrink, " AND items.itemtype = 15"},
|
||||
{EQ::item::ItemType::ItemTypeLight, " AND items.itemtype = 16"},
|
||||
{EQ::item::ItemType::ItemTypeCombinable, " AND items.itemtype = 17"},
|
||||
{EQ::item::ItemType::ItemTypeBandage, " AND items.itemtype = 18"},
|
||||
{EQ::item::ItemType::ItemTypeSmallThrowing, " AND (items.itemtype = 19 OR items.itemtype = 7)"},
|
||||
{EQ::item::ItemType::ItemTypeSpell, " AND items.itemtype = 20"},
|
||||
{EQ::item::ItemType::ItemTypePotion, " AND items.itemtype = 21"},
|
||||
{EQ::item::ItemType::ItemTypeBrassInstrument, " AND items.itemtype = 25"},
|
||||
{EQ::item::ItemType::ItemTypeWindInstrument, " AND items.itemtype = 23"},
|
||||
{EQ::item::ItemType::ItemTypeStringedInstrument, " AND items.itemtype = 24"},
|
||||
{EQ::item::ItemType::ItemTypePercussionInstrument, " AND items.itemtype = 26"},
|
||||
{EQ::item::ItemType::ItemTypeArrow, " AND items.itemtype = 27"},
|
||||
{EQ::item::ItemType::ItemTypeJewelry, " AND items.itemtype = 29"},
|
||||
{EQ::item::ItemType::ItemTypeNote, " AND items.itemtype = 32"},
|
||||
{EQ::item::ItemType::ItemTypeKey, " AND items.itemtype = 33"},
|
||||
{EQ::item::ItemType::ItemType2HPiercing, " AND items.itemtype = 35"},
|
||||
{EQ::item::ItemType::ItemTypeAlcohol, " AND items.itemtype = 38"},
|
||||
{EQ::item::ItemType::ItemTypeMartial, " AND items.itemtype = 45"},
|
||||
{EQ::item::ItemType::ItemTypeAugmentation, " AND items.itemtype = 54"},
|
||||
{EQ::item::ItemType::ItemTypeAlternateAbility, " AND items.itemtype = 57"},
|
||||
{EQ::item::ItemType::ItemTypeCount, " AND items.itemtype = 65"},
|
||||
{EQ::item::ItemType::ItemTypeCollectible, " AND items.itemtype = 66"}
|
||||
};
|
||||
|
||||
// item stat searches
|
||||
struct ItemStatSearch {
|
||||
std::string query_string;
|
||||
EQ::skills::SkillType skill_type;
|
||||
};
|
||||
|
||||
std::map<uint32, ItemStatSearch> item_stat_searches_new = {
|
||||
{STAT_AC, {" items.ac" , static_cast<EQ::skills::SkillType>(0)} },
|
||||
{STAT_AGI, {" items.aagi", static_cast<EQ::skills::SkillType>(0)} },
|
||||
{STAT_CHA, {" items.acha", static_cast<EQ::skills::SkillType>(0)} },
|
||||
{STAT_DEX, {" items.adex", static_cast<EQ::skills::SkillType>(0)} },
|
||||
{STAT_INT, {" items.aint", static_cast<EQ::skills::SkillType>(0)} },
|
||||
{STAT_STA, {" items.asta", static_cast<EQ::skills::SkillType>(0)} },
|
||||
{STAT_STR, {" items.astr", static_cast<EQ::skills::SkillType>(0)} },
|
||||
{STAT_WIS, {" items.awis", static_cast<EQ::skills::SkillType>(0)} },
|
||||
{STAT_COLD, {" items.cr", static_cast<EQ::skills::SkillType>(0)} },
|
||||
{STAT_DISEASE, {" items.dr", static_cast<EQ::skills::SkillType>(0)} },
|
||||
{STAT_FIRE, {" items.fr", static_cast<EQ::skills::SkillType>(0)} },
|
||||
{STAT_MAGIC, {" items.mr", static_cast<EQ::skills::SkillType>(0)} },
|
||||
{STAT_POISON, {" items.pr", static_cast<EQ::skills::SkillType>(0)} },
|
||||
{STAT_HP, {" items.hp", static_cast<EQ::skills::SkillType>(0)} },
|
||||
{STAT_MANA, {" items.mana", static_cast<EQ::skills::SkillType>(0)} },
|
||||
{STAT_ENDURANCE, {" items.endur", static_cast<EQ::skills::SkillType>(0)} },
|
||||
{STAT_ATTACK, {" items.attack", static_cast<EQ::skills::SkillType>(0)} },
|
||||
{STAT_HP_REGEN, {" items.regen", static_cast<EQ::skills::SkillType>(0)} },
|
||||
{STAT_MANA_REGEN, {" items.manaregen", static_cast<EQ::skills::SkillType>(0)} },
|
||||
{STAT_HASTE, {" items.haste", static_cast<EQ::skills::SkillType>(0)} },
|
||||
{STAT_DAMAGE_SHIELD, {" items.damageshield", static_cast<EQ::skills::SkillType>(0)} },
|
||||
{STAT_DS_MITIGATION, {" items.dsmitigation", static_cast<EQ::skills::SkillType>(0)} },
|
||||
{STAT_HEAL_AMOUNT, {" items.healamt", static_cast<EQ::skills::SkillType>(0)} },
|
||||
{STAT_SPELL_DAMAGE, {" items.spelldmg", static_cast<EQ::skills::SkillType>(0)} },
|
||||
{STAT_CLAIRVOYANCE, {" items.clairvoyance", static_cast<EQ::skills::SkillType>(0)} },
|
||||
{STAT_HEROIC_AGILITY, {" items.heroic_agi", static_cast<EQ::skills::SkillType>(0)} },
|
||||
{STAT_HEROIC_CHARISMA, {" items.heroic_cha", static_cast<EQ::skills::SkillType>(0)} },
|
||||
{STAT_HEROIC_DEXTERITY, {" items.heroic_dex", static_cast<EQ::skills::SkillType>(0)} },
|
||||
{STAT_HEROIC_INTELLIGENCE, {" items.heroic_int", static_cast<EQ::skills::SkillType>(0)} },
|
||||
{STAT_HEROIC_STAMINA, {" items.heroic_sta", static_cast<EQ::skills::SkillType>(0)} },
|
||||
{STAT_HEROIC_STRENGTH, {" items.heroic_str", static_cast<EQ::skills::SkillType>(0)} },
|
||||
{STAT_HEROIC_WISDOM, {" items.heroic_wis", static_cast<EQ::skills::SkillType>(0)} },
|
||||
{STAT_BASH, {" items.skillmodvalue", EQ::skills::SkillBash} },
|
||||
{STAT_BACKSTAB, {" items.backstabdmg", EQ::skills::SkillBackstab} },
|
||||
{STAT_DRAGON_PUNCH, {" items.skillmodvalue", EQ::skills::SkillDragonPunch} },
|
||||
{STAT_EAGLE_STRIKE, {" items.skillmodvalue", EQ::skills::SkillEagleStrike} },
|
||||
{STAT_FLYING_KICK, {" items.skillmodvalue", EQ::skills::SkillFlyingKick} },
|
||||
{STAT_KICK, {" items.skillmodvalue", EQ::skills::SkillKick} },
|
||||
{STAT_ROUND_KICK, {" items.skillmodvalue", EQ::skills::SkillRoundKick} },
|
||||
{STAT_TIGER_CLAW, {" items.skillmodvalue", EQ::skills::SkillTigerClaw} },
|
||||
{STAT_FRENZY, {" items.skillmodvalue", EQ::skills::SkillFrenzy} },
|
||||
};
|
||||
|
||||
bool convert = false;
|
||||
std::string search_criteria_trader("TRUE");
|
||||
std::string field_criteria_items("FALSE");
|
||||
std::string where_criteria_items(" TRUE ");
|
||||
std::string search_criteria_trader("TRUE ");
|
||||
|
||||
if (search.search_scope == NonRoFBazaarSearchScope) {
|
||||
search_criteria_trader.append(
|
||||
@@ -202,115 +77,301 @@ Bazaar::GetSearchResults(
|
||||
search_criteria_trader.append(fmt::format(" AND trader.item_cost <= {}", (uint64) search.max_cost * 1000));
|
||||
}
|
||||
|
||||
if (search.slot != std::numeric_limits<uint32>::max()) {
|
||||
if (item_slot_searches_new.contains(search.slot)) {
|
||||
where_criteria_items.append(
|
||||
fmt::format(" AND items.slots & {0} = {0}", item_slot_searches_new[search.slot]));
|
||||
}
|
||||
}
|
||||
// not yet implemented
|
||||
// if (search.prestige != 0) {
|
||||
// 0xffffffff prestige only, 0xfffffffe non-prestige, 0 all
|
||||
// search_criteria.append(fmt::format(" AND items.type = {} ", search.prestige));
|
||||
// }
|
||||
|
||||
if (search.type != std::numeric_limits<uint32>::max()) {
|
||||
for (auto const &[type, condition]: item_search_types_new) {
|
||||
if (type == search.type) {
|
||||
where_criteria_items.append(condition);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (search.race != std::numeric_limits<uint32>::max()) {
|
||||
where_criteria_items.append(
|
||||
fmt::format(" AND items.races & {0} = {0}", GetPlayerRaceBit(GetRaceIDFromPlayerRaceValue(search.race))));
|
||||
}
|
||||
|
||||
if (search._class != std::numeric_limits<uint32>::max()) {
|
||||
where_criteria_items.append(fmt::format(" AND items.classes & {0} = {0}", GetPlayerClassBit(search._class)));
|
||||
}
|
||||
|
||||
if (search.item_stat != std::numeric_limits<uint32>::max()) {
|
||||
if (item_stat_searches_new.contains(search.item_stat)) {
|
||||
field_criteria_items = fmt::format("{}", item_stat_searches_new[search.item_stat].query_string);
|
||||
if (item_stat_searches_new[search.item_stat].skill_type) {
|
||||
where_criteria_items.append(
|
||||
fmt::format(" AND items.skillmodtype = {} ", item_stat_searches_new[search.item_stat].skill_type));
|
||||
}
|
||||
else {
|
||||
where_criteria_items.append(
|
||||
fmt::format(" AND {} > 0 ", item_stat_searches_new[search.item_stat].query_string));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (search.augment) {
|
||||
where_criteria_items.append(fmt::format(
|
||||
" AND (items.augslot1type = {0} OR "
|
||||
"items.augslot2type = {0} OR "
|
||||
"items.augslot3type = {0} OR "
|
||||
"items.augslot4type = {0} OR "
|
||||
"items.augslot5type = {0} OR "
|
||||
"items.augslot6type = {0})",
|
||||
search.augment)
|
||||
);
|
||||
}
|
||||
|
||||
if (search.min_level != 1) {
|
||||
where_criteria_items.append(fmt::format(" AND items.reclevel >= {}", search.min_level));
|
||||
}
|
||||
|
||||
if (search.max_level != 100) {
|
||||
where_criteria_items.append(fmt::format(" AND items.reclevel <= {}", search.max_level));
|
||||
}
|
||||
|
||||
std::vector<BazaarSearchResultsFromDB_Struct> all_entries;
|
||||
std::vector<std::string> trader_items_ids{};
|
||||
|
||||
auto const trader_results = TraderRepository::GetBazaarTraderDetails(db, search_criteria_trader);
|
||||
if (trader_results.empty()) {
|
||||
LogTradingDetail("Bazaar - No traders found in bazaar search.");
|
||||
return all_entries;
|
||||
}
|
||||
|
||||
for (auto const &i: trader_results) {
|
||||
trader_items_ids.push_back(std::to_string(i.trader.item_id));
|
||||
}
|
||||
|
||||
auto const item_results = ItemsRepository::GetItemsForBazaarSearch(
|
||||
content_db,
|
||||
trader_items_ids,
|
||||
std::string(search.item_name),
|
||||
field_criteria_items,
|
||||
where_criteria_items
|
||||
std::string query = fmt::format(
|
||||
"SELECT COUNT(item_id), trader.char_id, trader.item_id, trader.item_sn, trader.item_charges, trader.item_cost, "
|
||||
"trader.slot_id, SUM(trader.item_charges), trader.char_zone_id, trader.char_entity_id, character_data.name, "
|
||||
"aug_slot_1, aug_slot_2, aug_slot_3, aug_slot_4, aug_slot_5, aug_slot_6, trader.char_zone_instance_id "
|
||||
"FROM trader, character_data "
|
||||
"WHERE {} AND trader.char_id = character_data.id "
|
||||
"GROUP BY trader.item_sn, trader.item_charges, trader.char_id",
|
||||
search_criteria_trader.c_str()
|
||||
);
|
||||
|
||||
if (item_results.empty()) {
|
||||
LogError("Bazaar - No items found in bazaar search.");
|
||||
std::vector<BazaarSearchResultsFromDB_Struct> all_entries;
|
||||
|
||||
auto results = db.QueryDatabase(query);
|
||||
|
||||
if (!results.Success()) {
|
||||
return all_entries;
|
||||
}
|
||||
|
||||
all_entries.reserve(trader_results.size());
|
||||
struct ItemSearchType {
|
||||
EQ::item::ItemType type;
|
||||
bool condition;
|
||||
};
|
||||
|
||||
for (auto const& t:trader_results) {
|
||||
if (!item_results.contains(t.trader.item_id)) {
|
||||
struct AddititiveSearchCriteria {
|
||||
bool should_check;
|
||||
bool condition;
|
||||
};
|
||||
|
||||
for (auto row: results) {
|
||||
BazaarSearchResultsFromDB_Struct r{};
|
||||
|
||||
r.item_id = Strings::ToInt(row[2]);
|
||||
r.charges = Strings::ToInt(row[4]);
|
||||
|
||||
auto item = db.GetItem(r.item_id);
|
||||
if (!item) {
|
||||
continue;
|
||||
}
|
||||
|
||||
BazaarSearchResultsFromDB_Struct r{};
|
||||
r.count = 1;
|
||||
r.trader_id = t.trader.char_id;
|
||||
r.serial_number = t.trader.item_sn;
|
||||
r.cost = t.trader.item_cost;
|
||||
r.slot_id = t.trader.slot_id;
|
||||
r.sum_charges = t.trader.item_charges;
|
||||
r.stackable = item_results.at(t.trader.item_id).stackable;
|
||||
r.icon_id = item_results.at(t.trader.item_id).icon;
|
||||
r.trader_zone_id = t.trader.char_zone_id;
|
||||
r.trader_zone_instance_id = t.trader.char_zone_instance_id;
|
||||
r.trader_entity_id = t.trader.char_entity_id;
|
||||
r.serial_number_RoF = fmt::format("{:016}\0", t.trader.item_sn);
|
||||
r.item_name = fmt::format("{:.63}\0", item_results.at(t.trader.item_id).name);
|
||||
r.trader_name = fmt::format("{:.63}\0", t.trader_name);
|
||||
r.item_stat = item_results.at(t.trader.item_id).stats;
|
||||
uint32 aug_slot_1 = Strings::ToUnsignedInt(row[11]);
|
||||
uint32 aug_slot_2 = Strings::ToUnsignedInt(row[12]);
|
||||
uint32 aug_slot_3 = Strings::ToUnsignedInt(row[13]);
|
||||
uint32 aug_slot_4 = Strings::ToUnsignedInt(row[14]);
|
||||
uint32 aug_slot_5 = Strings::ToUnsignedInt(row[15]);
|
||||
uint32 aug_slot_6 = Strings::ToUnsignedInt(row[16]);
|
||||
|
||||
std::unique_ptr<EQ::ItemInstance> inst(
|
||||
db.CreateItem(
|
||||
item,
|
||||
r.charges,
|
||||
aug_slot_1,
|
||||
aug_slot_2,
|
||||
aug_slot_3,
|
||||
aug_slot_4,
|
||||
aug_slot_5,
|
||||
aug_slot_6
|
||||
)
|
||||
);
|
||||
|
||||
if (!inst->GetItem()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
r.count = Strings::ToInt(row[0]);
|
||||
r.trader_id = Strings::ToInt(row[1]);
|
||||
r.serial_number = Strings::ToInt(row[3]);
|
||||
r.cost = Strings::ToInt(row[5]);
|
||||
r.slot_id = Strings::ToInt(row[6]);
|
||||
r.sum_charges = Strings::ToInt(row[7]);
|
||||
r.stackable = item->Stackable;
|
||||
r.icon_id = item->Icon;
|
||||
r.trader_zone_id = Strings::ToInt(row[8]);
|
||||
r.trader_zone_instance_id = Strings::ToInt(row[17]);
|
||||
r.trader_entity_id = Strings::ToInt(row[9]);
|
||||
r.serial_number_RoF = fmt::format("{:016}\0", Strings::ToInt(row[3]));
|
||||
r.item_name = fmt::format("{:.63}\0", item->Name);
|
||||
r.trader_name = fmt::format("{:.63}\0", std::string(row[10]).c_str());
|
||||
|
||||
LogTradingDetail(
|
||||
"Searching against item [{}] ({}) for trader [{}]",
|
||||
item->Name,
|
||||
item->ID,
|
||||
r.trader_name
|
||||
);
|
||||
|
||||
// item stat searches
|
||||
std::map<uint32, uint32> item_stat_searches = {
|
||||
|
||||
{STAT_AC, inst->GetItemArmorClass(true)},
|
||||
{STAT_AGI, static_cast<uint32>(inst->GetItemAgi(true))},
|
||||
{STAT_CHA, static_cast<uint32>(inst->GetItemCha(true))},
|
||||
{STAT_DEX, static_cast<uint32>(inst->GetItemDex(true))},
|
||||
{STAT_INT, static_cast<uint32>(inst->GetItemInt(true))},
|
||||
{STAT_STA, static_cast<uint32>(inst->GetItemSta(true))},
|
||||
{STAT_STR, static_cast<uint32>(inst->GetItemStr(true))},
|
||||
{STAT_WIS, static_cast<uint32>(inst->GetItemWis(true))},
|
||||
{STAT_COLD, static_cast<uint32>(inst->GetItemCR(true))},
|
||||
{STAT_DISEASE, static_cast<uint32>(inst->GetItemDR(true))},
|
||||
{STAT_FIRE, static_cast<uint32>(inst->GetItemFR(true))},
|
||||
{STAT_MAGIC, static_cast<uint32>(inst->GetItemMR(true))},
|
||||
{STAT_POISON, static_cast<uint32>(inst->GetItemPR(true))},
|
||||
{STAT_HP, static_cast<uint32>(inst->GetItemHP(true))},
|
||||
{STAT_MANA, static_cast<uint32>(inst->GetItemMana(true))},
|
||||
{STAT_ENDURANCE, static_cast<uint32>(inst->GetItemEndur(true))},
|
||||
{STAT_ATTACK, static_cast<uint32>(inst->GetItemAttack(true))},
|
||||
{STAT_HP_REGEN, static_cast<uint32>(inst->GetItemRegen(true))},
|
||||
{STAT_MANA_REGEN, static_cast<uint32>(inst->GetItemManaRegen(true))},
|
||||
{STAT_HASTE, static_cast<uint32>(inst->GetItemHaste(true))},
|
||||
{STAT_DAMAGE_SHIELD, static_cast<uint32>(inst->GetItemDamageShield(true))},
|
||||
{STAT_DS_MITIGATION, static_cast<uint32>(inst->GetItemDSMitigation(true))},
|
||||
{STAT_HEAL_AMOUNT, static_cast<uint32>(inst->GetItemHealAmt(true))},
|
||||
{STAT_SPELL_DAMAGE, static_cast<uint32>(inst->GetItemSpellDamage(true))},
|
||||
{STAT_CLAIRVOYANCE, static_cast<uint32>(inst->GetItemClairvoyance(true))},
|
||||
{STAT_HEROIC_AGILITY, static_cast<uint32>(inst->GetItemHeroicAgi(true))},
|
||||
{STAT_HEROIC_CHARISMA, static_cast<uint32>(inst->GetItemHeroicCha(true))},
|
||||
{STAT_HEROIC_DEXTERITY, static_cast<uint32>(inst->GetItemHeroicDex(true))},
|
||||
{STAT_HEROIC_INTELLIGENCE, static_cast<uint32>(inst->GetItemHeroicInt(true))},
|
||||
{STAT_HEROIC_STAMINA, static_cast<uint32>(inst->GetItemHeroicSta(true))},
|
||||
{STAT_HEROIC_STRENGTH, static_cast<uint32>(inst->GetItemHeroicStr(true))},
|
||||
{STAT_HEROIC_WISDOM, static_cast<uint32>(inst->GetItemHeroicWis(true))},
|
||||
{STAT_BASH, static_cast<uint32>(inst->GetItemSkillsStat(EQ::skills::SkillBash, true))},
|
||||
{STAT_BACKSTAB, static_cast<uint32>(inst->GetItemBackstabDamage(true))},
|
||||
{STAT_DRAGON_PUNCH, static_cast<uint32>(inst->GetItemSkillsStat(EQ::skills::SkillDragonPunch, true))},
|
||||
{STAT_EAGLE_STRIKE, static_cast<uint32>(inst->GetItemSkillsStat(EQ::skills::SkillEagleStrike, true))},
|
||||
{STAT_FLYING_KICK, static_cast<uint32>(inst->GetItemSkillsStat(EQ::skills::SkillFlyingKick, true))},
|
||||
{STAT_KICK, static_cast<uint32>(inst->GetItemSkillsStat(EQ::skills::SkillKick, true))},
|
||||
{STAT_ROUND_KICK, static_cast<uint32>(inst->GetItemSkillsStat(EQ::skills::SkillRoundKick, true))},
|
||||
{STAT_TIGER_CLAW, static_cast<uint32>(inst->GetItemSkillsStat(EQ::skills::SkillTigerClaw, true))},
|
||||
{STAT_FRENZY, static_cast<uint32>(inst->GetItemSkillsStat(EQ::skills::SkillFrenzy, true))},
|
||||
};
|
||||
|
||||
r.item_stat = item_stat_searches.contains(search.item_stat) ? item_stat_searches[search.item_stat] : 0;
|
||||
if (item_stat_searches.contains(search.item_stat) && item_stat_searches[search.item_stat] <= 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
static std::map<uint8, uint32> item_slot_searches = {
|
||||
{EQ::invslot::slotCharm, 1},
|
||||
{EQ::invslot::slotEar1, 2},
|
||||
{EQ::invslot::slotHead, 4},
|
||||
{EQ::invslot::slotFace, 8},
|
||||
{EQ::invslot::slotEar2, 16},
|
||||
{EQ::invslot::slotNeck, 32},
|
||||
{EQ::invslot::slotShoulders, 64},
|
||||
{EQ::invslot::slotArms, 128},
|
||||
{EQ::invslot::slotBack, 256},
|
||||
{EQ::invslot::slotWrist1, 512},
|
||||
{EQ::invslot::slotWrist2, 1024},
|
||||
{EQ::invslot::slotRange, 2048},
|
||||
{EQ::invslot::slotHands, 4096},
|
||||
{EQ::invslot::slotPrimary, 8192},
|
||||
{EQ::invslot::slotSecondary, 16384},
|
||||
{EQ::invslot::slotFinger1, 32768},
|
||||
{EQ::invslot::slotFinger2, 65536},
|
||||
{EQ::invslot::slotChest, 131072},
|
||||
{EQ::invslot::slotLegs, 262144},
|
||||
{EQ::invslot::slotFeet, 524288},
|
||||
{EQ::invslot::slotWaist, 1048576},
|
||||
{EQ::invslot::slotPowerSource, 2097152},
|
||||
{EQ::invslot::slotAmmo, 4194304},
|
||||
};
|
||||
|
||||
auto GetEquipmentSlotBit = [&](uint32 slot) -> uint32 {
|
||||
return item_slot_searches.contains(slot) ? item_slot_searches[slot] : 0;
|
||||
};
|
||||
|
||||
auto FindItemAugSlot = [&]() -> bool {
|
||||
for (auto const &s: inst->GetItem()->AugSlotType) {
|
||||
return s == search.augment;
|
||||
}
|
||||
return false;
|
||||
};
|
||||
|
||||
// item type searches
|
||||
std::vector<ItemSearchType> item_search_types = {
|
||||
{EQ::item::ItemType::ItemTypeAll, true},
|
||||
{EQ::item::ItemType::ItemTypeBook, item->ItemClass == EQ::item::ItemType::ItemTypeBook},
|
||||
{EQ::item::ItemType::ItemTypeContainer, item->ItemClass == EQ::item::ItemType::ItemTypeContainer ||
|
||||
item->IsClassBag()},
|
||||
{EQ::item::ItemType::ItemTypeAllEffects, item->Scroll.Effect > 0 && item->Scroll.Effect < 65000},
|
||||
{EQ::item::ItemType::ItemTypeUnknown9, item->Worn.Effect == 998},
|
||||
{EQ::item::ItemType::ItemTypeUnknown10, item->Worn.Effect >= 1298 && item->Worn.Effect <= 1307},
|
||||
{EQ::item::ItemType::ItemTypeFocusEffect, item->Focus.Effect > 0},
|
||||
{EQ::item::ItemType::ItemTypeArmor, item->ItemType == EQ::item::ItemType::ItemTypeArmor},
|
||||
{EQ::item::ItemType::ItemType1HBlunt, item->ItemType == EQ::item::ItemType::ItemType1HBlunt},
|
||||
{EQ::item::ItemType::ItemType1HPiercing, item->ItemType == EQ::item::ItemType::ItemType1HPiercing},
|
||||
{EQ::item::ItemType::ItemType1HSlash, item->ItemType == EQ::item::ItemType::ItemType1HSlash},
|
||||
{EQ::item::ItemType::ItemType2HBlunt, item->ItemType == EQ::item::ItemType::ItemType2HBlunt},
|
||||
{EQ::item::ItemType::ItemType2HSlash, item->ItemType == EQ::item::ItemType::ItemType2HSlash},
|
||||
{EQ::item::ItemType::ItemTypeBow, item->ItemType == EQ::item::ItemType::ItemTypeBow},
|
||||
{EQ::item::ItemType::ItemTypeShield, item->ItemType == EQ::item::ItemType::ItemTypeShield},
|
||||
{EQ::item::ItemType::ItemTypeMisc, item->ItemType == EQ::item::ItemType::ItemTypeMisc},
|
||||
{EQ::item::ItemType::ItemTypeFood, item->ItemType == EQ::item::ItemType::ItemTypeFood},
|
||||
{EQ::item::ItemType::ItemTypeDrink, item->ItemType == EQ::item::ItemType::ItemTypeDrink},
|
||||
{EQ::item::ItemType::ItemTypeLight, item->ItemType == EQ::item::ItemType::ItemTypeLight},
|
||||
{EQ::item::ItemType::ItemTypeCombinable, item->ItemType == EQ::item::ItemType::ItemTypeCombinable},
|
||||
{EQ::item::ItemType::ItemTypeBandage, item->ItemType == EQ::item::ItemType::ItemTypeBandage},
|
||||
{EQ::item::ItemType::ItemTypeSmallThrowing, item->ItemType == EQ::item::ItemType::ItemTypeSmallThrowing ||
|
||||
item->ItemType == EQ::item::ItemType::ItemTypeLargeThrowing},
|
||||
{EQ::item::ItemType::ItemTypeSpell, item->ItemType == EQ::item::ItemType::ItemTypeSpell},
|
||||
{EQ::item::ItemType::ItemTypePotion, item->ItemType == EQ::item::ItemType::ItemTypePotion},
|
||||
{EQ::item::ItemType::ItemTypeBrassInstrument, item->ItemType == EQ::item::ItemType::ItemTypeBrassInstrument},
|
||||
{EQ::item::ItemType::ItemTypeWindInstrument, item->ItemType == EQ::item::ItemType::ItemTypeWindInstrument},
|
||||
{EQ::item::ItemType::ItemTypeStringedInstrument, item->ItemType == EQ::item::ItemType::ItemTypeStringedInstrument},
|
||||
{EQ::item::ItemType::ItemTypePercussionInstrument, item->ItemType == EQ::item::ItemType::ItemTypePercussionInstrument},
|
||||
{EQ::item::ItemType::ItemTypeArrow, item->ItemType == EQ::item::ItemType::ItemTypeArrow},
|
||||
{EQ::item::ItemType::ItemTypeJewelry, item->ItemType == EQ::item::ItemType::ItemTypeJewelry},
|
||||
{EQ::item::ItemType::ItemTypeNote, item->ItemType == EQ::item::ItemType::ItemTypeNote},
|
||||
{EQ::item::ItemType::ItemTypeKey, item->ItemType == EQ::item::ItemType::ItemTypeKey},
|
||||
{EQ::item::ItemType::ItemType2HPiercing, item->ItemType == EQ::item::ItemType::ItemType2HPiercing},
|
||||
{EQ::item::ItemType::ItemTypeAlcohol, item->ItemType == EQ::item::ItemType::ItemTypeAlcohol},
|
||||
{EQ::item::ItemType::ItemTypeMartial, item->ItemType == EQ::item::ItemType::ItemTypeMartial},
|
||||
{EQ::item::ItemType::ItemTypeAugmentation, item->ItemType == EQ::item::ItemType::ItemTypeAugmentation},
|
||||
{EQ::item::ItemType::ItemTypeAlternateAbility, item->ItemType == EQ::item::ItemType::ItemTypeAlternateAbility},
|
||||
{EQ::item::ItemType::ItemTypeCount, item->ItemType == EQ::item::ItemType::ItemTypeCount},
|
||||
{EQ::item::ItemType::ItemTypeCollectible, item->ItemType == EQ::item::ItemType::ItemTypeCollectible}
|
||||
};
|
||||
|
||||
bool met_filter = false;
|
||||
bool has_filter = false;
|
||||
|
||||
for (auto &i: item_search_types) {
|
||||
if (i.type == search.type) {
|
||||
has_filter = true;
|
||||
if (i.condition) {
|
||||
LogTradingDetail("Item [{}] met search criteria for type [{}]", item->Name, uint8(i.type));
|
||||
met_filter = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (has_filter && !met_filter) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// TODO: Add catch-all item type filter for specific item types
|
||||
|
||||
// item additive searches
|
||||
std::vector<AddititiveSearchCriteria> item_additive_searches = {
|
||||
{
|
||||
.should_check = search.min_level != 1 && inst->GetItemRequiredLevel(true) > 0,
|
||||
.condition = inst->GetItemRequiredLevel(true) >= search.min_level
|
||||
},
|
||||
{
|
||||
.should_check = search.max_level != 1 && inst->GetItemRequiredLevel(true) > 0,
|
||||
.condition = inst->GetItemRequiredLevel(true) <= search.max_level
|
||||
},
|
||||
{
|
||||
.should_check = !std::string(search.item_name).empty(),
|
||||
.condition = Strings::ContainsLower(item->Name, search.item_name)
|
||||
},
|
||||
{
|
||||
.should_check = search._class != 0xFFFFFFFF,
|
||||
.condition = static_cast<bool>(item->Classes & GetPlayerClassBit(search._class))
|
||||
},
|
||||
{
|
||||
.should_check = search.race != 0xFFFFFFFF,
|
||||
.condition = static_cast<bool>(item->Races & GetPlayerRaceBit(GetRaceIDFromPlayerRaceValue(search.race)))
|
||||
},
|
||||
{
|
||||
.should_check = search.augment != 0,
|
||||
.condition = FindItemAugSlot()
|
||||
},
|
||||
{
|
||||
.should_check = search.slot != 0xFFFFFFFF,
|
||||
.condition = static_cast<bool>(item->Slots & GetEquipmentSlotBit(search.slot))
|
||||
},
|
||||
};
|
||||
|
||||
bool should_add = true;
|
||||
|
||||
for (auto &i: item_additive_searches) {
|
||||
LogTradingDetail(
|
||||
"Checking item [{}] for search criteria - should_check [{}] condition [{}]",
|
||||
item->Name,
|
||||
i.should_check,
|
||||
i.condition
|
||||
);
|
||||
if (i.should_check && !i.condition) {
|
||||
should_add = false;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
if (!should_add) {
|
||||
continue;
|
||||
}
|
||||
|
||||
LogTradingDetail("Found item [{}] meeting search criteria.", r.item_name);
|
||||
if (RuleB(Bazaar, UseAlternateBazaarSearch)) {
|
||||
if (convert || (r.trader_zone_id == Zones::BAZAAR && r.trader_zone_instance_id != char_zone_instance_id)) {
|
||||
r.trader_id = TraderRepository::TRADER_CONVERT_ID + r.trader_zone_instance_id;
|
||||
|
||||
+1
-3
@@ -3,13 +3,11 @@
|
||||
|
||||
#include <vector>
|
||||
#include "shareddb.h"
|
||||
#include "../../common/item_instance.h"
|
||||
|
||||
class Bazaar {
|
||||
public:
|
||||
static std::vector<BazaarSearchResultsFromDB_Struct>
|
||||
GetSearchResults(Database &content_db, Database &db, BazaarSearchCriteria_Struct search, unsigned int char_zone_id, int char_zone_instance_id);
|
||||
|
||||
GetSearchResults(SharedDatabase &db, BazaarSearchCriteria_Struct search, unsigned int char_zone_id, int char_zone_instance_id);
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -6333,149 +6333,6 @@ CREATE TABLE `character_pet_name` (
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
|
||||
)",
|
||||
},
|
||||
ManifestEntry{
|
||||
.version = 9294,
|
||||
.description = "2025_01_26_items_table_bazaar_search_indexes.sql",
|
||||
.check = "SHOW CREATE TABLE `items`",
|
||||
.condition = "missing",
|
||||
.match = "idx_slots_reclevel",
|
||||
.sql = R"(
|
||||
-- indexes for the `items` table
|
||||
CREATE INDEX idx_slots_reclevel ON items (slots, reclevel);
|
||||
CREATE INDEX idx_itemclass_itemtype ON items (itemclass, itemtype);
|
||||
CREATE INDEX idx_augment_slots ON items (
|
||||
augslot1type,
|
||||
augslot2type,
|
||||
augslot3type,
|
||||
augslot4type,
|
||||
augslot5type,
|
||||
augslot6type
|
||||
);
|
||||
CREATE INDEX idx_races_classes ON items (races, classes);
|
||||
|
||||
-- common stat fields
|
||||
CREATE INDEX idx_item_ac ON items (ac);
|
||||
CREATE INDEX idx_item_hp ON items (hp);
|
||||
CREATE INDEX idx_item_mana ON items (mana);
|
||||
CREATE INDEX idx_item_reclevel ON items (reclevel);
|
||||
CREATE INDEX idx_item_type_skill ON items (itemtype, skillmodtype);
|
||||
)",
|
||||
.content_schema_update = true
|
||||
},
|
||||
ManifestEntry{
|
||||
.version = 9295,
|
||||
.description = "2025_01_26_trader_table_bazaar_search_indexes.sql",
|
||||
.check = "SHOW CREATE TABLE `trader`",
|
||||
.condition = "missing",
|
||||
.match = "idx_trader_item",
|
||||
.sql = R"(
|
||||
-- indexes for the `trader` table
|
||||
CREATE INDEX idx_trader_item ON trader (item_id, item_cost);
|
||||
CREATE INDEX idx_trader_char ON trader (char_id, char_zone_id, char_zone_instance_id);
|
||||
CREATE INDEX idx_trader_item_sn ON trader (item_sn);
|
||||
CREATE INDEX idx_trader_item_cost ON trader (item_cost);
|
||||
CREATE INDEX idx_trader_active_transaction ON trader (active_transaction);
|
||||
)",
|
||||
.content_schema_update = false
|
||||
},
|
||||
ManifestEntry{
|
||||
.version = 9296,
|
||||
.description = "2024_01_22_sharedbank_guid_primary_key.sql",
|
||||
.check = "SHOW COLUMN FROM `sharedbank` LIKE 'guid'",
|
||||
.condition = "empty",
|
||||
.match = "",
|
||||
.sql = R"(
|
||||
ALTER TABLE `sharedbank`
|
||||
CHANGE COLUMN `acctid` `account_id` int(11) UNSIGNED NOT NULL DEFAULT 0 FIRST,
|
||||
CHANGE COLUMN `slotid` `slot_id` mediumint(7) UNSIGNED NOT NULL DEFAULT 0 AFTER `account_id`,
|
||||
CHANGE COLUMN `itemid` `item_id` int(11) UNSIGNED NOT NULL DEFAULT 0 AFTER `slot_id`,
|
||||
CHANGE COLUMN `augslot1` `augment_one` mediumint(7) UNSIGNED NOT NULL DEFAULT 0 AFTER `charges`,
|
||||
CHANGE COLUMN `augslot2` `augment_two` mediumint(7) UNSIGNED NOT NULL DEFAULT 0 AFTER `augment_one`,
|
||||
CHANGE COLUMN `augslot3` `augment_three` mediumint(7) UNSIGNED NOT NULL DEFAULT 0 AFTER `augment_two`,
|
||||
CHANGE COLUMN `augslot4` `augment_four` mediumint(7) UNSIGNED NOT NULL DEFAULT 0 AFTER `augment_three`,
|
||||
CHANGE COLUMN `augslot5` `augment_five` mediumint(7) UNSIGNED NOT NULL DEFAULT 0 AFTER `augment_four`,
|
||||
CHANGE COLUMN `augslot6` `augment_six` mediumint(7) UNSIGNED NOT NULL DEFAULT 0 AFTER `augment_five`,
|
||||
MODIFY COLUMN `charges` smallint(3) UNSIGNED NOT NULL DEFAULT 0 AFTER `item_id`,
|
||||
ADD COLUMN `color` int(11) UNSIGNED NOT NULL DEFAULT 0 AFTER `charges`,
|
||||
ADD COLUMN `ornament_icon` int(11) UNSIGNED NOT NULL AFTER `custom_data`,
|
||||
ADD COLUMN `ornament_idfile` int(11) UNSIGNED NOT NULL AFTER `ornament_icon`,
|
||||
ADD COLUMN `ornament_hero_model` int(11) NOT NULL AFTER `ornament_idfile`,
|
||||
ADD COLUMN `guid` bigint(20) UNSIGNED NOT NULL DEFAULT 0 AFTER `ornament_hero_model`,
|
||||
ADD PRIMARY KEY (`account_id`, `slot_id`);
|
||||
)"
|
||||
},
|
||||
ManifestEntry{
|
||||
.version = 9297,
|
||||
.description = "2024_10_24_inventory_changes.sql",
|
||||
.check = "SHOW COLUMN FROM `inventory` LIKE 'charid'",
|
||||
.condition = "empty",
|
||||
.match = "",
|
||||
.sql = R"(
|
||||
ALTER TABLE `inventory`
|
||||
CHANGE COLUMN `charid` `character_id` int(11) UNSIGNED NOT NULL DEFAULT 0 FIRST,
|
||||
CHANGE COLUMN `slotid` `slot_id` mediumint(7) UNSIGNED NOT NULL DEFAULT 0 AFTER `character_id`,
|
||||
CHANGE COLUMN `itemid` `item_id` int(11) UNSIGNED NULL DEFAULT 0 AFTER `slot_id`,
|
||||
CHANGE COLUMN `augslot1` `augment_one` mediumint(7) UNSIGNED NOT NULL DEFAULT 0 AFTER `color`,
|
||||
CHANGE COLUMN `augslot2` `augment_two` mediumint(7) UNSIGNED NOT NULL DEFAULT 0 AFTER `augment_one`,
|
||||
CHANGE COLUMN `augslot3` `augment_three` mediumint(7) UNSIGNED NOT NULL DEFAULT 0 AFTER `augment_two`,
|
||||
CHANGE COLUMN `augslot4` `augment_four` mediumint(7) UNSIGNED NOT NULL DEFAULT 0 AFTER `augment_three`,
|
||||
CHANGE COLUMN `augslot5` `augment_five` mediumint(7) UNSIGNED NOT NULL DEFAULT 0 AFTER `augment_four`,
|
||||
CHANGE COLUMN `augslot6` `augment_six` mediumint(7) UNSIGNED NOT NULL DEFAULT 0 AFTER `augment_five`,
|
||||
CHANGE COLUMN `ornamenticon` `ornament_icon` int(11) UNSIGNED NOT NULL DEFAULT 0 AFTER `custom_data`,
|
||||
CHANGE COLUMN `ornamentidfile` `ornament_idfile` int(11) UNSIGNED NOT NULL DEFAULT 0 AFTER `ornament_icon`,
|
||||
DROP PRIMARY KEY,
|
||||
ADD PRIMARY KEY (`character_id`, `slot_id`) USING BTREE;
|
||||
UPDATE `inventory` SET `slot_id` = ((`slot_id` - 251) + 4010) WHERE `slot_id` BETWEEN 251 AND 260; -- Bag 1
|
||||
UPDATE `inventory` SET `slot_id` = ((`slot_id` - 261) + 4210) WHERE `slot_id` BETWEEN 261 AND 270; -- Bag 2
|
||||
UPDATE `inventory` SET `slot_id` = ((`slot_id` - 271) + 4410) WHERE `slot_id` BETWEEN 271 AND 280; -- Bag 3
|
||||
UPDATE `inventory` SET `slot_id` = ((`slot_id` - 281) + 4610) WHERE `slot_id` BETWEEN 281 AND 290; -- Bag 4
|
||||
UPDATE `inventory` SET `slot_id` = ((`slot_id` - 291) + 4810) WHERE `slot_id` BETWEEN 291 AND 300; -- Bag 5
|
||||
UPDATE `inventory` SET `slot_id` = ((`slot_id` - 301) + 5010) WHERE `slot_id` BETWEEN 301 AND 310; -- Bag 6
|
||||
UPDATE `inventory` SET `slot_id` = ((`slot_id` - 311) + 5210) WHERE `slot_id` BETWEEN 311 AND 320; -- Bag 7
|
||||
UPDATE `inventory` SET `slot_id` = ((`slot_id` - 321) + 5410) WHERE `slot_id` BETWEEN 321 AND 330; -- Bag 8
|
||||
UPDATE `inventory` SET `slot_id` = ((`slot_id` - 331) + 5610) WHERE `slot_id` BETWEEN 331 AND 340; -- Bag 9
|
||||
UPDATE `inventory` SET `slot_id` = ((`slot_id` - 341) + 5810) WHERE `slot_id` BETWEEN 341 AND 350; -- Bag 10
|
||||
UPDATE `inventory` SET `slot_id` = ((`slot_id` - 351) + 6010) WHERE `slot_id` BETWEEN 351 AND 360; -- Cursor Bag
|
||||
UPDATE `inventory` SET `slot_id` = ((`slot_id` - 2031) + 6210) WHERE `slot_id` BETWEEN 2031 AND 2040; -- Bank Bag 1
|
||||
UPDATE `inventory` SET `slot_id` = ((`slot_id` - 2041) + 6410) WHERE `slot_id` BETWEEN 2041 AND 2050; -- Bank Bag 2
|
||||
UPDATE `inventory` SET `slot_id` = ((`slot_id` - 2051) + 6610) WHERE `slot_id` BETWEEN 2051 AND 2060; -- Bank Bag 3
|
||||
UPDATE `inventory` SET `slot_id` = ((`slot_id` - 2061) + 6810) WHERE `slot_id` BETWEEN 2061 AND 2070; -- Bank Bag 4
|
||||
UPDATE `inventory` SET `slot_id` = ((`slot_id` - 2071) + 7010) WHERE `slot_id` BETWEEN 2071 AND 2080; -- Bank Bag 5
|
||||
UPDATE `inventory` SET `slot_id` = ((`slot_id` - 2081) + 7210) WHERE `slot_id` BETWEEN 2081 AND 2090; -- Bank Bag 6
|
||||
UPDATE `inventory` SET `slot_id` = ((`slot_id` - 2091) + 7410) WHERE `slot_id` BETWEEN 2091 AND 2100; -- Bank Bag 7
|
||||
UPDATE `inventory` SET `slot_id` = ((`slot_id` - 2101) + 7610) WHERE `slot_id` BETWEEN 2101 AND 2110; -- Bank Bag 8
|
||||
UPDATE `inventory` SET `slot_id` = ((`slot_id` - 2111) + 7810) WHERE `slot_id` BETWEEN 2111 AND 2120; -- Bank Bag 9
|
||||
UPDATE `inventory` SET `slot_id` = ((`slot_id` - 2121) + 8010) WHERE `slot_id` BETWEEN 2121 AND 2130; -- Bank Bag 10
|
||||
UPDATE `inventory` SET `slot_id` = ((`slot_id` - 2131) + 8210) WHERE `slot_id` BETWEEN 2131 AND 2140; -- Bank Bag 11
|
||||
UPDATE `inventory` SET `slot_id` = ((`slot_id` - 2141) + 8410) WHERE `slot_id` BETWEEN 2141 AND 2150; -- Bank Bag 12
|
||||
UPDATE `inventory` SET `slot_id` = ((`slot_id` - 2151) + 8610) WHERE `slot_id` BETWEEN 2151 AND 2160; -- Bank Bag 13
|
||||
UPDATE `inventory` SET `slot_id` = ((`slot_id` - 2161) + 8810) WHERE `slot_id` BETWEEN 2161 AND 2170; -- Bank Bag 14
|
||||
UPDATE `inventory` SET `slot_id` = ((`slot_id` - 2171) + 9010) WHERE `slot_id` BETWEEN 2171 AND 2180; -- Bank Bag 15
|
||||
UPDATE `inventory` SET `slot_id` = ((`slot_id` - 2181) + 9210) WHERE `slot_id` BETWEEN 2181 AND 2190; -- Bank Bag 16
|
||||
UPDATE `inventory` SET `slot_id` = ((`slot_id` - 2191) + 9410) WHERE `slot_id` BETWEEN 2191 AND 2200; -- Bank Bag 17
|
||||
UPDATE `inventory` SET `slot_id` = ((`slot_id` - 2201) + 9610) WHERE `slot_id` BETWEEN 2201 AND 2210; -- Bank Bag 18
|
||||
UPDATE `inventory` SET `slot_id` = ((`slot_id` - 2211) + 9810) WHERE `slot_id` BETWEEN 2211 AND 2220; -- Bank Bag 19
|
||||
UPDATE `inventory` SET `slot_id` = ((`slot_id` - 2221) + 10010) WHERE `slot_id` BETWEEN 2221 AND 2230; -- Bank Bag 20
|
||||
UPDATE `inventory` SET `slot_id` = ((`slot_id` - 2231) + 10210) WHERE `slot_id` BETWEEN 2231 AND 2240; -- Bank Bag 21
|
||||
UPDATE `inventory` SET `slot_id` = ((`slot_id` - 2241) + 10410) WHERE `slot_id` BETWEEN 2241 AND 2250; -- Bank Bag 22
|
||||
UPDATE `inventory` SET `slot_id` = ((`slot_id` - 2251) + 10610) WHERE `slot_id` BETWEEN 2251 AND 2260; -- Bank Bag 23
|
||||
UPDATE `inventory` SET `slot_id` = ((`slot_id` - 2261) + 10810) WHERE `slot_id` BETWEEN 2261 AND 2270; -- Bank Bag 24
|
||||
UPDATE `sharedbank` SET `slot_id` = ((`slot_id` - 2531) + 11010) WHERE `slot_id` BETWEEN 2531 AND 2540; -- Shared Bank Bag 1
|
||||
UPDATE `sharedbank` SET `slot_id` = ((`slot_id` - 2541) + 11210) WHERE `slot_id` BETWEEN 2541 AND 2550; -- Shared Bank Bag 2
|
||||
)"
|
||||
},
|
||||
ManifestEntry{
|
||||
.version = 9298,
|
||||
.description = "2024_10_24_merchantlist_temp_uncap.sql",
|
||||
.check = "SHOW CREATE TABLE `merchantlist_temp`",
|
||||
.condition = "contains",
|
||||
.match = "`slot` tinyint(3)",
|
||||
.sql = R"(
|
||||
ALTER TABLE `merchantlist_temp`
|
||||
MODIFY COLUMN `slot` int UNSIGNED NOT NULL DEFAULT 0 AFTER `npcid`;
|
||||
)"
|
||||
}
|
||||
|
||||
// -- template; copy/paste this when you need to create a new entry
|
||||
// ManifestEntry{
|
||||
// .version = 9228,
|
||||
|
||||
+33
-35
@@ -132,7 +132,7 @@ namespace EQ
|
||||
using RoF2::invtype::KRONO_SIZE;
|
||||
using RoF2::invtype::OTHER_SIZE;
|
||||
|
||||
using RoF2::invtype::TRADE_NPC_SIZE;
|
||||
using Titanium::invtype::TRADE_NPC_SIZE;
|
||||
|
||||
using RoF2::invtype::TYPE_INVALID;
|
||||
using RoF2::invtype::TYPE_BEGIN;
|
||||
@@ -159,7 +159,7 @@ namespace EQ
|
||||
using RoF2::invslot::SLOT_INVALID;
|
||||
using RoF2::invslot::SLOT_BEGIN;
|
||||
|
||||
using RoF2::invslot::SLOT_TRADESKILL_EXPERIMENT_COMBINE;
|
||||
using Titanium::invslot::SLOT_TRADESKILL_EXPERIMENT_COMBINE;
|
||||
|
||||
const int16 SLOT_AUGMENT_GENERIC_RETURN = 1001; // clients don't appear to use this method... (internal inventory return value)
|
||||
|
||||
@@ -179,28 +179,28 @@ namespace EQ
|
||||
using RoF2::invslot::BONUS_STAT_END;
|
||||
using RoF2::invslot::BONUS_SKILL_END;
|
||||
|
||||
using RoF2::invslot::BANK_BEGIN;
|
||||
using RoF2::invslot::BANK_END;
|
||||
using Titanium::invslot::BANK_BEGIN;
|
||||
using SoF::invslot::BANK_END;
|
||||
|
||||
using RoF2::invslot::SHARED_BANK_BEGIN;
|
||||
using RoF2::invslot::SHARED_BANK_END;
|
||||
using Titanium::invslot::SHARED_BANK_BEGIN;
|
||||
using Titanium::invslot::SHARED_BANK_END;
|
||||
|
||||
using RoF2::invslot::TRADE_BEGIN;
|
||||
using RoF2::invslot::TRADE_END;
|
||||
using Titanium::invslot::TRADE_BEGIN;
|
||||
using Titanium::invslot::TRADE_END;
|
||||
|
||||
using RoF2::invslot::TRADE_NPC_END;
|
||||
using Titanium::invslot::TRADE_NPC_END;
|
||||
|
||||
using RoF2::invslot::WORLD_BEGIN;
|
||||
using RoF2::invslot::WORLD_END;
|
||||
using Titanium::invslot::WORLD_BEGIN;
|
||||
using Titanium::invslot::WORLD_END;
|
||||
|
||||
using RoF2::invslot::TRIBUTE_BEGIN;
|
||||
using RoF2::invslot::TRIBUTE_END;
|
||||
using Titanium::invslot::TRIBUTE_BEGIN;
|
||||
using Titanium::invslot::TRIBUTE_END;
|
||||
|
||||
using RoF2::invslot::GUILD_TRIBUTE_BEGIN;
|
||||
using RoF2::invslot::GUILD_TRIBUTE_END;
|
||||
using Titanium::invslot::GUILD_TRIBUTE_BEGIN;
|
||||
using Titanium::invslot::GUILD_TRIBUTE_END;
|
||||
|
||||
const int16 CORPSE_BEGIN = invslot::slotGeneral1;
|
||||
const int16 CORPSE_END = CORPSE_BEGIN + invslot::slotCursor;
|
||||
const int16 CORPSE_END = CORPSE_BEGIN + invslot::slotCursor;
|
||||
|
||||
using RoF2::invslot::EQUIPMENT_BITMASK;
|
||||
using RoF2::invslot::GENERAL_BITMASK;
|
||||
@@ -214,40 +214,38 @@ namespace EQ
|
||||
} // namespace invslot
|
||||
|
||||
namespace invbag {
|
||||
using RoF2::invbag::SLOT_INVALID;
|
||||
using RoF2::invbag::SLOT_BEGIN;
|
||||
using RoF2::invbag::SLOT_END;
|
||||
using RoF2::invbag::SLOT_COUNT;
|
||||
using Titanium::invbag::SLOT_INVALID;
|
||||
using Titanium::invbag::SLOT_BEGIN;
|
||||
using Titanium::invbag::SLOT_END;
|
||||
using Titanium::invbag::SLOT_COUNT;
|
||||
|
||||
using RoF2::invslot::WORLD_END;
|
||||
|
||||
const int16 GENERAL_BAGS_BEGIN = WORLD_END + 1;
|
||||
using Titanium::invbag::GENERAL_BAGS_BEGIN;
|
||||
const int16 GENERAL_BAGS_COUNT = invslot::GENERAL_COUNT * SLOT_COUNT;
|
||||
const int16 GENERAL_BAGS_END = (GENERAL_BAGS_BEGIN + GENERAL_BAGS_COUNT) - 1;
|
||||
const int16 GENERAL_BAGS_END = (GENERAL_BAGS_BEGIN + GENERAL_BAGS_COUNT) - 1;
|
||||
|
||||
const int16 GENERAL_BAGS_8_COUNT = 8 * SLOT_COUNT;
|
||||
const int16 GENERAL_BAGS_8_END = (GENERAL_BAGS_BEGIN + GENERAL_BAGS_8_COUNT) - 1;
|
||||
const int16 GENERAL_BAGS_8_END = (GENERAL_BAGS_BEGIN + GENERAL_BAGS_8_COUNT) - 1;
|
||||
|
||||
const int16 CURSOR_BAG_BEGIN = GENERAL_BAGS_END + 1;
|
||||
const int16 CURSOR_BAG_BEGIN = 351;
|
||||
const int16 CURSOR_BAG_COUNT = SLOT_COUNT;
|
||||
const int16 CURSOR_BAG_END = (CURSOR_BAG_BEGIN + CURSOR_BAG_COUNT) - 1;
|
||||
const int16 CURSOR_BAG_END = (CURSOR_BAG_BEGIN + CURSOR_BAG_COUNT) - 1;
|
||||
|
||||
const int16 BANK_BAGS_BEGIN = CURSOR_BAG_END + 1;
|
||||
using Titanium::invbag::BANK_BAGS_BEGIN;
|
||||
const int16 BANK_BAGS_COUNT = (invtype::BANK_SIZE * SLOT_COUNT);
|
||||
const int16 BANK_BAGS_END = (BANK_BAGS_BEGIN + BANK_BAGS_COUNT) - 1;
|
||||
const int16 BANK_BAGS_END = (BANK_BAGS_BEGIN + BANK_BAGS_COUNT) - 1;
|
||||
|
||||
const int16 BANK_BAGS_16_COUNT = 16 * SLOT_COUNT;
|
||||
const int16 BANK_BAGS_16_END = (BANK_BAGS_BEGIN + BANK_BAGS_16_COUNT) - 1;
|
||||
const int16 BANK_BAGS_16_END = (BANK_BAGS_BEGIN + BANK_BAGS_16_COUNT) - 1;
|
||||
|
||||
const int16 SHARED_BANK_BAGS_BEGIN = BANK_BAGS_END + 1;
|
||||
using Titanium::invbag::SHARED_BANK_BAGS_BEGIN;
|
||||
const int16 SHARED_BANK_BAGS_COUNT = invtype::SHARED_BANK_SIZE * SLOT_COUNT;
|
||||
const int16 SHARED_BANK_BAGS_END = (SHARED_BANK_BAGS_BEGIN + SHARED_BANK_BAGS_COUNT) - 1;
|
||||
const int16 SHARED_BANK_BAGS_END = (SHARED_BANK_BAGS_BEGIN + SHARED_BANK_BAGS_COUNT) - 1;
|
||||
|
||||
const int16 TRADE_BAGS_BEGIN = SHARED_BANK_BAGS_END + 1;
|
||||
using Titanium::invbag::TRADE_BAGS_BEGIN;
|
||||
const int16 TRADE_BAGS_COUNT = invtype::TRADE_SIZE * SLOT_COUNT;
|
||||
const int16 TRADE_BAGS_END = (TRADE_BAGS_BEGIN + TRADE_BAGS_COUNT) - 1;
|
||||
const int16 TRADE_BAGS_END = (TRADE_BAGS_BEGIN + TRADE_BAGS_COUNT) - 1;
|
||||
|
||||
using RoF2::invbag::GetInvBagIndexName;
|
||||
using Titanium::invbag::GetInvBagIndexName;
|
||||
|
||||
} // namespace invbag
|
||||
|
||||
|
||||
+491
-517
File diff suppressed because it is too large
Load Diff
@@ -178,6 +178,7 @@ namespace EQ
|
||||
// Locate an available inventory slot
|
||||
int16 FindFreeSlot(bool for_bag, bool try_cursor, uint8 min_size = 0, bool is_arrow = false);
|
||||
int16 FindFreeSlotForTradeItem(const ItemInstance* inst, int16 general_start = invslot::GENERAL_BEGIN, uint8 bag_start = invbag::SLOT_BEGIN);
|
||||
std::vector<int16> FindAllFreeSlotsThatFitItem(const EQ::ItemData *inst);
|
||||
int16 FindFirstFreeSlotThatFitsItem(const EQ::ItemData *inst);
|
||||
|
||||
// Calculate slot_id for an item within a bag
|
||||
@@ -200,6 +201,12 @@ namespace EQ
|
||||
|
||||
uint8 FindBrightestLightType();
|
||||
|
||||
void dumpEntireInventory();
|
||||
void dumpWornItems();
|
||||
void dumpInventory();
|
||||
void dumpBankItems();
|
||||
void dumpSharedBankItems();
|
||||
|
||||
void SetCustomItemData(uint32 character_id, int16 slot_id, const std::string &identifier, const std::string& value);
|
||||
void SetCustomItemData(uint32 character_id, int16 slot_id, const std::string &identifier, int value);
|
||||
void SetCustomItemData(uint32 character_id, int16 slot_id, const std::string &identifier, float value);
|
||||
@@ -219,6 +226,8 @@ namespace EQ
|
||||
///////////////////////////////
|
||||
|
||||
int GetSlotByItemInstCollection(const std::map<int16, ItemInstance*> &collection, ItemInstance *inst);
|
||||
void dumpItemCollection(const std::map<int16, ItemInstance*> &collection);
|
||||
void dumpBagContents(ItemInstance *inst, std::map<int16, ItemInstance*>::const_iterator *it);
|
||||
|
||||
// Retrieves item within an inventory bucket
|
||||
ItemInstance* _GetItem(const std::map<int16, ItemInstance*>& bucket, int16 slot_id) const;
|
||||
|
||||
@@ -8,110 +8,6 @@
|
||||
#include <fmt/format.h>
|
||||
#include <sstream>
|
||||
|
||||
#include <cstring> // For memcpy
|
||||
#include <thread>
|
||||
|
||||
#define INITIAL_RING_BUFFER_CAPACITY 8192 // Initial number of buffers
|
||||
#define BUFFER_SIZE 512 // Fixed buffer size
|
||||
|
||||
class StaticRingBuffer {
|
||||
private:
|
||||
char (*m_data)[BUFFER_SIZE]; // Pointer to dynamically allocated buffer array
|
||||
bool* m_in_use; // Tracks if a buffer is currently allocated
|
||||
size_t m_capacity; // Current capacity of the ring buffer
|
||||
volatile size_t m_write_index = 0; // Next available buffer
|
||||
volatile size_t m_read_index = 0; // Next buffer to be freed
|
||||
std::atomic<size_t> m_used_space = 0; // Track used buffers
|
||||
|
||||
|
||||
public:
|
||||
StaticRingBuffer()
|
||||
: m_capacity(INITIAL_RING_BUFFER_CAPACITY) {
|
||||
m_data = new char[m_capacity][BUFFER_SIZE]; // Allocate initial buffer pool
|
||||
m_in_use = new bool[m_capacity]{false}; // Track buffer usage (initialized to false)
|
||||
}
|
||||
|
||||
~StaticRingBuffer() {
|
||||
delete[] m_data; // Free memory
|
||||
delete[] m_in_use; // Free tracking array
|
||||
}
|
||||
|
||||
// Acquire a fixed-size buffer (doubles capacity if full)
|
||||
char* Acquire() {
|
||||
for (size_t i = 0; i < m_capacity; ++i) {
|
||||
size_t index = (m_write_index + i) % m_capacity;
|
||||
if (!m_in_use[index]) {
|
||||
m_in_use[index] = true;
|
||||
m_write_index = (index + 1) % m_capacity;
|
||||
std::cout << "Acquired buffer " << index << std::endl;
|
||||
return m_data[index];
|
||||
}
|
||||
}
|
||||
|
||||
DoubleCapacity();
|
||||
return Acquire(); // Retry after resizing
|
||||
}
|
||||
|
||||
// Release a buffer back to the pool
|
||||
void Release(char* buffer) {
|
||||
size_t index = (buffer - m_data[0]) / BUFFER_SIZE; // Divide by BUFFER_SIZE, not m_capacity
|
||||
|
||||
// Prevent invalid releases (e.g., if the buffer isn't from m_data[])
|
||||
if (index >= m_capacity || m_data[index] != buffer) {
|
||||
// std::cerr << "Invalid Release: Buffer not in m_data or incorrect index!\n";
|
||||
return;
|
||||
}
|
||||
|
||||
// std::cout << "Released buffer " << index << std::endl;
|
||||
|
||||
m_in_use[index] = false; // Mark buffer as available
|
||||
}
|
||||
|
||||
private:
|
||||
// Doubles the ring buffer capacity while preserving existing data
|
||||
// TODO: Add a lock to prevent concurrent issues during resizing
|
||||
void DoubleCapacity() {
|
||||
size_t new_capacity = m_capacity * 2;
|
||||
char (*new_data)[BUFFER_SIZE] = new char[new_capacity][BUFFER_SIZE];
|
||||
bool* new_in_use = new bool[new_capacity]{false};
|
||||
|
||||
size_t current_size = (m_write_index >= m_read_index)
|
||||
? (m_write_index - m_read_index)
|
||||
: (m_capacity - m_read_index + m_write_index);
|
||||
|
||||
std::cout << "[INFO] Resizing buffer from " << m_capacity << " to " << new_capacity << std::endl;
|
||||
|
||||
// Copy data in FIFO order
|
||||
for (size_t i = 0; i < current_size; ++i) {
|
||||
size_t old_index = (m_read_index + i) % m_capacity;
|
||||
memcpy(new_data[i], m_data[old_index], BUFFER_SIZE);
|
||||
new_in_use[i] = m_in_use[old_index];
|
||||
}
|
||||
|
||||
// Store old buffer reference
|
||||
char (*old_data_ref)[BUFFER_SIZE] = m_data;
|
||||
bool* old_in_use_ref = m_in_use;
|
||||
size_t old_capacity = m_capacity;
|
||||
|
||||
// Assign new memory
|
||||
m_data = new_data;
|
||||
m_in_use = new_in_use;
|
||||
m_capacity = new_capacity;
|
||||
|
||||
m_read_index = 0;
|
||||
m_write_index = current_size;
|
||||
|
||||
// Delay deletion of old data to avoid access issues
|
||||
std::thread([old_data_ref, old_in_use_ref, old_capacity]() {
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(500)); // Ensure old packets are sent
|
||||
delete[] old_data_ref;
|
||||
delete[] old_in_use_ref;
|
||||
std::cout << "[INFO] Old buffer safely deallocated (Capacity: " << old_capacity << ")\n";
|
||||
}).detach();
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
EQ::Net::DaybreakConnectionManager::DaybreakConnectionManager()
|
||||
{
|
||||
m_attached = nullptr;
|
||||
@@ -256,6 +152,9 @@ void EQ::Net::DaybreakConnectionManager::Process()
|
||||
connection->SendKeepAlive();
|
||||
}
|
||||
}
|
||||
|
||||
connection->Process();
|
||||
break;
|
||||
}
|
||||
case StatusDisconnecting:
|
||||
connection->Process();
|
||||
@@ -539,7 +438,7 @@ void EQ::Net::DaybreakConnection::ProcessPacket(Packet &p)
|
||||
return;
|
||||
}
|
||||
|
||||
if (m_encode_passes[0] == EncodeCompression || m_encode_passes[1] == EncodeCompression)
|
||||
if (m_encode_passes[0] & EncodeCompression || m_encode_passes[1] & EncodeCompression)
|
||||
{
|
||||
EQ::Net::DynamicPacket temp;
|
||||
temp.PutPacket(0, p);
|
||||
@@ -596,8 +495,10 @@ void EQ::Net::DaybreakConnection::ProcessPacket(Packet &p)
|
||||
void EQ::Net::DaybreakConnection::ProcessQueue()
|
||||
{
|
||||
for (int i = 0; i < 4; ++i) {
|
||||
auto stream = &m_streams[i];
|
||||
auto &stream = m_streams[i];
|
||||
for (;;) {
|
||||
if (stream == nullptr)
|
||||
break;
|
||||
|
||||
auto iter = stream->packet_queue.find(stream->sequence_in);
|
||||
if (iter == stream->packet_queue.end()) {
|
||||
@@ -614,7 +515,11 @@ void EQ::Net::DaybreakConnection::ProcessQueue()
|
||||
|
||||
void EQ::Net::DaybreakConnection::RemoveFromQueue(int stream, uint16_t seq)
|
||||
{
|
||||
auto s = &m_streams[stream];
|
||||
auto &s = m_streams[stream];
|
||||
if (s == nullptr) {
|
||||
return;
|
||||
}
|
||||
|
||||
auto iter = s->packet_queue.find(seq);
|
||||
if (iter != s->packet_queue.end()) {
|
||||
auto packet = iter->second;
|
||||
@@ -625,7 +530,11 @@ void EQ::Net::DaybreakConnection::RemoveFromQueue(int stream, uint16_t seq)
|
||||
|
||||
void EQ::Net::DaybreakConnection::AddToQueue(int stream, uint16_t seq, const Packet &p)
|
||||
{
|
||||
auto s = &m_streams[stream];
|
||||
auto &s = m_streams[stream];
|
||||
if (s == nullptr) {
|
||||
return;
|
||||
}
|
||||
|
||||
auto iter = s->packet_queue.find(seq);
|
||||
if (iter == s->packet_queue.end()) {
|
||||
DynamicPacket *out = new DynamicPacket();
|
||||
@@ -780,7 +689,10 @@ void EQ::Net::DaybreakConnection::ProcessDecodedPacket(const Packet &p)
|
||||
auto header = p.GetSerialize<DaybreakReliableHeader>(0);
|
||||
auto sequence = NetworkToHost(header.sequence);
|
||||
auto stream_id = header.opcode - OP_Packet;
|
||||
auto stream = &m_streams[stream_id];
|
||||
auto &stream = m_streams[stream_id];
|
||||
if (stream == nullptr) {
|
||||
stream.reset(new DaybreakReliableStream());
|
||||
}
|
||||
|
||||
auto order = CompareSequence(stream->sequence_in, sequence);
|
||||
if (order == SequenceFuture) {
|
||||
@@ -809,7 +721,10 @@ void EQ::Net::DaybreakConnection::ProcessDecodedPacket(const Packet &p)
|
||||
auto header = p.GetSerialize<DaybreakReliableHeader>(0);
|
||||
auto sequence = NetworkToHost(header.sequence);
|
||||
auto stream_id = header.opcode - OP_Fragment;
|
||||
auto stream = &m_streams[stream_id];
|
||||
auto &stream = m_streams[stream_id];
|
||||
if (stream == nullptr) {
|
||||
stream.reset(new DaybreakReliableStream());
|
||||
}
|
||||
|
||||
auto order = CompareSequence(stream->sequence_in, sequence);
|
||||
|
||||
@@ -1195,116 +1110,85 @@ void EQ::Net::DaybreakConnection::ProcessResend()
|
||||
}
|
||||
}
|
||||
|
||||
// observed client receive window is 300 packets, 140KB
|
||||
constexpr size_t MAX_CLIENT_RECV_PACKETS_PER_WINDOW = 300;
|
||||
constexpr size_t MAX_CLIENT_RECV_BYTES_PER_WINDOW = 140 * 1024;
|
||||
|
||||
void EQ::Net::DaybreakConnection::ProcessResend(int stream)
|
||||
{
|
||||
if (m_status == DbProtocolStatus::StatusDisconnected) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (m_streams[stream].sent_packets.empty()) {
|
||||
auto resends = 0;
|
||||
auto now = Clock::now();
|
||||
auto &s = m_streams[stream];
|
||||
if (s == nullptr) {
|
||||
return;
|
||||
}
|
||||
|
||||
m_resend_packets_sent = 0;
|
||||
m_resend_bytes_sent = 0;
|
||||
for (auto &entry : s->sent_packets) {
|
||||
auto time_since_last_send = std::chrono::duration_cast<std::chrono::milliseconds>(now - entry.second.last_sent);
|
||||
if (entry.second.times_resent == 0) {
|
||||
if ((size_t)time_since_last_send.count() > entry.second.resend_delay) {
|
||||
auto &p = entry.second.packet;
|
||||
if (p.Length() >= DaybreakHeader::size()) {
|
||||
if (p.GetInt8(0) == 0 && p.GetInt8(1) >= OP_Fragment && p.GetInt8(1) <= OP_Fragment4) {
|
||||
m_stats.resent_fragments++;
|
||||
}
|
||||
else {
|
||||
m_stats.resent_full++;
|
||||
}
|
||||
}
|
||||
else {
|
||||
m_stats.resent_full++;
|
||||
}
|
||||
m_stats.resent_packets++;
|
||||
|
||||
auto now = Clock::now(); // Current time
|
||||
auto s = &m_streams[stream];
|
||||
|
||||
// Get a reference resend delay (assume first packet represents the typical case)
|
||||
if (!s->sent_packets.empty()) {
|
||||
// Check if the first packet has timed out
|
||||
auto &first_packet = s->sent_packets.begin()->second;
|
||||
auto time_since_first_sent = std::chrono::duration_cast<std::chrono::milliseconds>(now - first_packet.first_sent).count();
|
||||
|
||||
// make sure that the first_packet in the list first_sent time is within the resend_delay and now
|
||||
// if it is not, then we need to resend all packets in the list
|
||||
if (time_since_first_sent <= first_packet.resend_delay && !m_acked_since_last_resend) {
|
||||
LogNetcodeDetail(
|
||||
"Not resending packets for stream [{}] time since first sent [{}] resend delay [{}] m_acked_since_last_resend [{}]",
|
||||
stream,
|
||||
time_since_first_sent,
|
||||
first_packet.resend_delay,
|
||||
m_acked_since_last_resend
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
if (time_since_first_sent >= m_owner->m_options.resend_timeout) {
|
||||
Close();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (LogSys.IsLogEnabled(Logs::Detail, Logs::Netcode)) {
|
||||
size_t total_size = 0;
|
||||
for (auto &e: s->sent_packets) {
|
||||
total_size += e.second.packet.Length();
|
||||
}
|
||||
|
||||
LogNetcodeDetail(
|
||||
"Resending packets for stream [{}] packet count [{}] total packet size [{}] m_acked_since_last_resend [{}]",
|
||||
stream,
|
||||
s->sent_packets.size(),
|
||||
total_size,
|
||||
m_acked_since_last_resend
|
||||
);
|
||||
}
|
||||
|
||||
for (auto &e: s->sent_packets) {
|
||||
if (m_resend_packets_sent >= MAX_CLIENT_RECV_PACKETS_PER_WINDOW ||
|
||||
m_resend_bytes_sent >= MAX_CLIENT_RECV_BYTES_PER_WINDOW) {
|
||||
LogNetcodeDetail(
|
||||
"Stopping resend because we hit thresholds m_resend_packets_sent [{}] max [{}] m_resend_bytes_sent [{}] max [{}]",
|
||||
m_resend_packets_sent,
|
||||
MAX_CLIENT_RECV_PACKETS_PER_WINDOW,
|
||||
m_resend_bytes_sent,
|
||||
MAX_CLIENT_RECV_BYTES_PER_WINDOW
|
||||
);
|
||||
break;
|
||||
}
|
||||
|
||||
auto &sp = e.second;
|
||||
auto &p = sp.packet;
|
||||
if (p.Length() >= DaybreakHeader::size()) {
|
||||
if (p.GetInt8(0) == 0 && p.GetInt8(1) >= OP_Fragment && p.GetInt8(1) <= OP_Fragment4) {
|
||||
m_stats.resent_fragments++;
|
||||
}
|
||||
else {
|
||||
m_stats.resent_full++;
|
||||
InternalBufferedSend(p);
|
||||
entry.second.last_sent = now;
|
||||
entry.second.times_resent++;
|
||||
entry.second.resend_delay = EQ::Clamp(entry.second.resend_delay * 2, m_owner->m_options.resend_delay_min, m_owner->m_options.resend_delay_max);
|
||||
resends++;
|
||||
}
|
||||
}
|
||||
else {
|
||||
m_stats.resent_full++;
|
||||
auto time_since_first_sent = std::chrono::duration_cast<std::chrono::milliseconds>(now - entry.second.first_sent);
|
||||
if (time_since_first_sent.count() >= m_owner->m_options.resend_timeout) {
|
||||
Close();
|
||||
return;
|
||||
}
|
||||
|
||||
if ((size_t)time_since_last_send.count() > entry.second.resend_delay) {
|
||||
auto &p = entry.second.packet;
|
||||
if (p.Length() >= DaybreakHeader::size()) {
|
||||
if (p.GetInt8(0) == 0 && p.GetInt8(1) >= OP_Fragment && p.GetInt8(1) <= OP_Fragment4) {
|
||||
m_stats.resent_fragments++;
|
||||
}
|
||||
else {
|
||||
m_stats.resent_full++;
|
||||
}
|
||||
}
|
||||
else {
|
||||
m_stats.resent_full++;
|
||||
}
|
||||
m_stats.resent_packets++;
|
||||
|
||||
InternalBufferedSend(p);
|
||||
entry.second.last_sent = now;
|
||||
entry.second.times_resent++;
|
||||
entry.second.resend_delay = EQ::Clamp(entry.second.resend_delay * 2, m_owner->m_options.resend_delay_min, m_owner->m_options.resend_delay_max);
|
||||
resends++;
|
||||
}
|
||||
}
|
||||
m_stats.resent_packets++;
|
||||
|
||||
// Resend the packet
|
||||
InternalBufferedSend(p);
|
||||
|
||||
m_resend_packets_sent++;
|
||||
m_resend_bytes_sent += p.Length();
|
||||
sp.last_sent = now;
|
||||
sp.times_resent++;
|
||||
sp.resend_delay = EQ::Clamp(
|
||||
sp.resend_delay * 2,
|
||||
m_owner->m_options.resend_delay_min,
|
||||
m_owner->m_options.resend_delay_max
|
||||
);
|
||||
}
|
||||
|
||||
m_acked_since_last_resend = false;
|
||||
}
|
||||
|
||||
void EQ::Net::DaybreakConnection::Ack(int stream, uint16_t seq)
|
||||
{
|
||||
|
||||
auto now = Clock::now();
|
||||
auto s = &m_streams[stream];
|
||||
auto &s = m_streams[stream];
|
||||
if (s == nullptr) {
|
||||
return;
|
||||
}
|
||||
|
||||
auto iter = s->sent_packets.begin();
|
||||
while (iter != s->sent_packets.end()) {
|
||||
auto order = CompareSequence(seq, iter->first);
|
||||
@@ -1318,7 +1202,6 @@ void EQ::Net::DaybreakConnection::Ack(int stream, uint16_t seq)
|
||||
m_rolling_ping = (m_rolling_ping * 2 + round_time) / 3;
|
||||
|
||||
iter = s->sent_packets.erase(iter);
|
||||
m_acked_since_last_resend = true;
|
||||
}
|
||||
else {
|
||||
++iter;
|
||||
@@ -1329,7 +1212,11 @@ void EQ::Net::DaybreakConnection::Ack(int stream, uint16_t seq)
|
||||
void EQ::Net::DaybreakConnection::OutOfOrderAck(int stream, uint16_t seq)
|
||||
{
|
||||
auto now = Clock::now();
|
||||
auto s = &m_streams[stream];
|
||||
auto &s = m_streams[stream];
|
||||
if (s == nullptr) {
|
||||
return;
|
||||
}
|
||||
|
||||
auto iter = s->sent_packets.find(seq);
|
||||
if (iter != s->sent_packets.end()) {
|
||||
uint64_t round_time = (uint64_t)std::chrono::duration_cast<std::chrono::milliseconds>(now - iter->second.last_sent).count();
|
||||
@@ -1437,8 +1324,6 @@ void EQ::Net::DaybreakConnection::SendKeepAlive()
|
||||
InternalSend(p);
|
||||
}
|
||||
|
||||
StaticRingBuffer m_ring_buffer;
|
||||
|
||||
void EQ::Net::DaybreakConnection::InternalSend(Packet &p)
|
||||
{
|
||||
if (m_owner->m_options.outgoing_data_rate > 0.0) {
|
||||
@@ -1455,10 +1340,8 @@ void EQ::Net::DaybreakConnection::InternalSend(Packet &p)
|
||||
m_last_send = Clock::now();
|
||||
|
||||
auto send_func = [](uv_udp_send_t* req, int status) {
|
||||
if (req->data) {
|
||||
m_ring_buffer.Release((char*)req->data); // Return buffer to pool
|
||||
}
|
||||
delete req; // Return send request to pool
|
||||
delete[](char*)req->data;
|
||||
delete req;
|
||||
};
|
||||
|
||||
if (PacketCanBeEncoded(p)) {
|
||||
@@ -1495,7 +1378,7 @@ void EQ::Net::DaybreakConnection::InternalSend(Packet &p)
|
||||
uv_ip4_addr(m_endpoint.c_str(), m_port, &send_addr);
|
||||
uv_buf_t send_buffers[1];
|
||||
|
||||
char* data = m_ring_buffer.Acquire();
|
||||
char *data = new char[out.Length()];
|
||||
memcpy(data, out.Data(), out.Length());
|
||||
send_buffers[0] = uv_buf_init(data, out.Length());
|
||||
send_req->data = send_buffers[0].base;
|
||||
@@ -1503,6 +1386,7 @@ void EQ::Net::DaybreakConnection::InternalSend(Packet &p)
|
||||
m_stats.sent_bytes += out.Length();
|
||||
m_stats.sent_packets++;
|
||||
if (m_owner->m_options.simulated_out_packet_loss && m_owner->m_options.simulated_out_packet_loss >= m_owner->m_rand.Int(0, 100)) {
|
||||
delete[](char*)send_req->data;
|
||||
delete send_req;
|
||||
return;
|
||||
}
|
||||
@@ -1518,7 +1402,7 @@ void EQ::Net::DaybreakConnection::InternalSend(Packet &p)
|
||||
uv_ip4_addr(m_endpoint.c_str(), m_port, &send_addr);
|
||||
uv_buf_t send_buffers[1];
|
||||
|
||||
char* data = m_ring_buffer.Acquire();
|
||||
char *data = new char[p.Length()];
|
||||
memcpy(data, p.Data(), p.Length());
|
||||
send_buffers[0] = uv_buf_init(data, p.Length());
|
||||
send_req->data = send_buffers[0].base;
|
||||
@@ -1527,6 +1411,7 @@ void EQ::Net::DaybreakConnection::InternalSend(Packet &p)
|
||||
m_stats.sent_packets++;
|
||||
|
||||
if (m_owner->m_options.simulated_out_packet_loss && m_owner->m_options.simulated_out_packet_loss >= m_owner->m_rand.Int(0, 100)) {
|
||||
delete[](char*)send_req->data;
|
||||
delete send_req;
|
||||
return;
|
||||
}
|
||||
@@ -1547,7 +1432,11 @@ void EQ::Net::DaybreakConnection::InternalQueuePacket(Packet &p, int stream_id,
|
||||
return;
|
||||
}
|
||||
|
||||
auto stream = &m_streams[stream_id];
|
||||
auto &stream = m_streams[stream_id];
|
||||
if (stream == nullptr) {
|
||||
stream.reset(new DaybreakReliableStream());
|
||||
}
|
||||
|
||||
auto max_raw_size = m_max_packet_size - m_crc_bytes - DaybreakReliableHeader::size() - 1; // -1 for compress flag
|
||||
size_t length = p.Length();
|
||||
if (length > max_raw_size) {
|
||||
|
||||
@@ -133,6 +133,38 @@ namespace EQ
|
||||
uint64_t bytes_before_encode;
|
||||
};
|
||||
|
||||
//Refactoring this stuff
|
||||
struct DaybreakSentPacket
|
||||
{
|
||||
DynamicPacket packet;
|
||||
Timestamp last_sent;
|
||||
Timestamp first_sent;
|
||||
size_t times_resent;
|
||||
size_t resend_delay;
|
||||
};
|
||||
|
||||
class DaybreakReliableStream
|
||||
{
|
||||
public:
|
||||
DaybreakReliableStream() {
|
||||
sequence_in = 0;
|
||||
sequence_out = 0;
|
||||
fragment_current_bytes = 0;
|
||||
fragment_total_bytes = 0;
|
||||
}
|
||||
//private:
|
||||
|
||||
uint16_t sequence_in;
|
||||
uint16_t sequence_out;
|
||||
std::map<uint16_t, Packet*> packet_queue;
|
||||
|
||||
DynamicPacket fragment_packet;
|
||||
uint32_t fragment_current_bytes;
|
||||
uint32_t fragment_total_bytes;
|
||||
|
||||
std::map<uint16_t, DaybreakSentPacket> sent_packets;
|
||||
};
|
||||
|
||||
class DaybreakConnectionManager;
|
||||
class DaybreakConnection;
|
||||
class DaybreakConnection
|
||||
@@ -181,41 +213,7 @@ namespace EQ
|
||||
Timestamp m_close_time;
|
||||
double m_outgoing_budget;
|
||||
|
||||
// resend tracking
|
||||
size_t m_resend_packets_sent = 0;
|
||||
size_t m_resend_bytes_sent = 0;
|
||||
bool m_acked_since_last_resend = false;
|
||||
|
||||
struct DaybreakSentPacket
|
||||
{
|
||||
DynamicPacket packet;
|
||||
Timestamp last_sent;
|
||||
Timestamp first_sent;
|
||||
size_t times_resent;
|
||||
size_t resend_delay;
|
||||
};
|
||||
|
||||
struct DaybreakStream
|
||||
{
|
||||
DaybreakStream() {
|
||||
sequence_in = 0;
|
||||
sequence_out = 0;
|
||||
fragment_current_bytes = 0;
|
||||
fragment_total_bytes = 0;
|
||||
}
|
||||
|
||||
uint16_t sequence_in;
|
||||
uint16_t sequence_out;
|
||||
std::map<uint16_t, Packet*> packet_queue;
|
||||
|
||||
DynamicPacket fragment_packet;
|
||||
uint32_t fragment_current_bytes;
|
||||
uint32_t fragment_total_bytes;
|
||||
|
||||
std::map<uint16_t, DaybreakSentPacket> sent_packets;
|
||||
};
|
||||
|
||||
DaybreakStream m_streams[4];
|
||||
std::unique_ptr<DaybreakReliableStream> m_streams[4];
|
||||
std::weak_ptr<DaybreakConnection> m_self;
|
||||
|
||||
void Process();
|
||||
@@ -277,6 +275,14 @@ namespace EQ
|
||||
resend_timeout = 30000;
|
||||
connection_close_time = 2000;
|
||||
outgoing_data_rate = 0.0;
|
||||
//this is emperically based on what the client seems to set for theirs
|
||||
//this is the max number of packets that can be sent/recv per channel before acks come in
|
||||
//we'll use this to preallocate some buffers
|
||||
max_outgoing_packets_per_channel = 400;
|
||||
max_incoming_packets_per_channel = 400;
|
||||
|
||||
//This is the max size of a packet that can be sent or received
|
||||
max_total_packet_size = 1024 * 1024 * 16;
|
||||
}
|
||||
|
||||
size_t max_packet_size;
|
||||
@@ -300,6 +306,9 @@ namespace EQ
|
||||
DaybreakEncodeType encode_passes[2];
|
||||
int port;
|
||||
double outgoing_data_rate;
|
||||
int max_outgoing_packets_per_channel;
|
||||
int max_incoming_packets_per_channel;
|
||||
int max_total_packet_size;
|
||||
};
|
||||
|
||||
class DaybreakConnectionManager
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/* EQEMu: Everquest Server Emulator
|
||||
|
||||
|
||||
Copyright (C) 2001-2016 EQEMu Development Team (http://eqemulator.net)
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
@@ -37,7 +37,7 @@ namespace RoF2
|
||||
|
||||
const bool AllowOverLevelEquipment = true;
|
||||
|
||||
const bool AllowEmptyBagInBag = true;
|
||||
const bool AllowEmptyBagInBag = true;
|
||||
const bool AllowClickCastFromBag = true;
|
||||
|
||||
} /*inventory*/
|
||||
@@ -77,38 +77,38 @@ namespace RoF2
|
||||
} // namespace enum_
|
||||
using namespace enum_;
|
||||
|
||||
const int16 POSSESSIONS_SIZE = 34;
|
||||
const int16 BANK_SIZE = 24;
|
||||
const int16 SHARED_BANK_SIZE = 2;
|
||||
const int16 TRADE_SIZE = 8;
|
||||
const int16 WORLD_SIZE = 10;
|
||||
const int16 LIMBO_SIZE = 36;
|
||||
const int16 TRIBUTE_SIZE = 5;
|
||||
const int16 TROPHY_TRIBUTE_SIZE = 0;//unknown
|
||||
const int16 GUILD_TRIBUTE_SIZE = 2;//unverified
|
||||
const int16 MERCHANT_SIZE = 500;
|
||||
const int16 DELETED_SIZE = 0;//unknown - "Recovery Tab"
|
||||
const int16 CORPSE_SIZE = POSSESSIONS_SIZE;
|
||||
const int16 BAZAAR_SIZE = 200;
|
||||
const int16 INSPECT_SIZE = 23;
|
||||
const int16 REAL_ESTATE_SIZE = 0;//unknown
|
||||
const int16 VIEW_MOD_PC_SIZE = POSSESSIONS_SIZE;
|
||||
const int16 VIEW_MOD_BANK_SIZE = BANK_SIZE;
|
||||
const int16 POSSESSIONS_SIZE = 34;
|
||||
const int16 BANK_SIZE = 24;
|
||||
const int16 SHARED_BANK_SIZE = 2;
|
||||
const int16 TRADE_SIZE = 8;
|
||||
const int16 WORLD_SIZE = 10;
|
||||
const int16 LIMBO_SIZE = 36;
|
||||
const int16 TRIBUTE_SIZE = 5;
|
||||
const int16 TROPHY_TRIBUTE_SIZE = 0;//unknown
|
||||
const int16 GUILD_TRIBUTE_SIZE = 2;//unverified
|
||||
const int16 MERCHANT_SIZE = 200;
|
||||
const int16 DELETED_SIZE = 0;//unknown - "Recovery Tab"
|
||||
const int16 CORPSE_SIZE = POSSESSIONS_SIZE;
|
||||
const int16 BAZAAR_SIZE = 200;
|
||||
const int16 INSPECT_SIZE = 23;
|
||||
const int16 REAL_ESTATE_SIZE = 0;//unknown
|
||||
const int16 VIEW_MOD_PC_SIZE = POSSESSIONS_SIZE;
|
||||
const int16 VIEW_MOD_BANK_SIZE = BANK_SIZE;
|
||||
const int16 VIEW_MOD_SHARED_BANK_SIZE = SHARED_BANK_SIZE;
|
||||
const int16 VIEW_MOD_LIMBO_SIZE = LIMBO_SIZE;
|
||||
const int16 ALT_STORAGE_SIZE = 0;//unknown - "Shroud Bank"
|
||||
const int16 ARCHIVED_SIZE = 0;//unknown
|
||||
const int16 MAIL_SIZE = 0;//unknown
|
||||
const int16 VIEW_MOD_LIMBO_SIZE = LIMBO_SIZE;
|
||||
const int16 ALT_STORAGE_SIZE = 0;//unknown - "Shroud Bank"
|
||||
const int16 ARCHIVED_SIZE = 0;//unknown
|
||||
const int16 MAIL_SIZE = 0;//unknown
|
||||
const int16 GUILD_TROPHY_TRIBUTE_SIZE = 0;//unknown
|
||||
const int16 KRONO_SIZE = 0;//unknown
|
||||
const int16 OTHER_SIZE = 0;//unknown
|
||||
const int16 KRONO_SIZE = 0;//unknown
|
||||
const int16 OTHER_SIZE = 0;//unknown
|
||||
|
||||
const int16 TRADE_NPC_SIZE = 4; // defined by implication
|
||||
|
||||
const int16 TYPE_INVALID = IINVALID;
|
||||
const int16 TYPE_BEGIN = typePossessions;
|
||||
const int16 TYPE_END = typeOther;
|
||||
const int16 TYPE_COUNT = (TYPE_END - TYPE_BEGIN) + 1;
|
||||
const int16 TYPE_BEGIN = typePossessions;
|
||||
const int16 TYPE_END = typeOther;
|
||||
const int16 TYPE_COUNT = (TYPE_END - TYPE_BEGIN) + 1;
|
||||
|
||||
int16 GetInvTypeSize(int16 inv_type);
|
||||
const char* GetInvTypeName(int16 inv_type);
|
||||
@@ -162,54 +162,33 @@ namespace RoF2
|
||||
} // namespace enum_
|
||||
using namespace enum_;
|
||||
|
||||
const int16 SLOT_TRADESKILL_EXPERIMENT_COMBINE = 1000;
|
||||
const int16 SLOT_INVALID = IINVALID;
|
||||
const int16 SLOT_BEGIN = INULL;
|
||||
|
||||
const int16 BANK_BEGIN = 2000;
|
||||
const int16 BANK_END = (BANK_BEGIN + invtype::BANK_SIZE) - 1;
|
||||
|
||||
const int16 SHARED_BANK_BEGIN = 2500;
|
||||
const int16 SHARED_BANK_END = (SHARED_BANK_BEGIN + invtype::SHARED_BANK_SIZE) - 1;
|
||||
|
||||
const int16 TRADE_BEGIN = 3000;
|
||||
const int16 TRADE_END = (TRADE_BEGIN + invtype::TRADE_SIZE) - 1;
|
||||
|
||||
const int16 TRADE_NPC_END = (TRADE_BEGIN + invtype::TRADE_NPC_SIZE) - 1; // defined by implication
|
||||
|
||||
const int16 WORLD_BEGIN = 4000;
|
||||
const int16 WORLD_END = (WORLD_BEGIN + invtype::WORLD_SIZE) - 1;
|
||||
|
||||
const int16 TRIBUTE_BEGIN = 400;
|
||||
const int16 TRIBUTE_END = (TRIBUTE_BEGIN + invtype::TRIBUTE_SIZE) - 1;
|
||||
|
||||
const int16 GUILD_TRIBUTE_BEGIN = 450;
|
||||
const int16 GUILD_TRIBUTE_END = (GUILD_TRIBUTE_BEGIN + invtype::GUILD_TRIBUTE_SIZE) - 1;
|
||||
const int16 SLOT_INVALID = IINVALID;
|
||||
const int16 SLOT_BEGIN = INULL;
|
||||
|
||||
const int16 POSSESSIONS_BEGIN = slotCharm;
|
||||
const int16 POSSESSIONS_END = slotCursor;
|
||||
const int16 POSSESSIONS_END = slotCursor;
|
||||
const int16 POSSESSIONS_COUNT = (POSSESSIONS_END - POSSESSIONS_BEGIN) + 1;
|
||||
|
||||
const int16 EQUIPMENT_BEGIN = slotCharm;
|
||||
const int16 EQUIPMENT_END = slotAmmo;
|
||||
const int16 EQUIPMENT_END = slotAmmo;
|
||||
const int16 EQUIPMENT_COUNT = (EQUIPMENT_END - EQUIPMENT_BEGIN) + 1;
|
||||
|
||||
const int16 GENERAL_BEGIN = slotGeneral1;
|
||||
const int16 GENERAL_END = slotGeneral10;
|
||||
const int16 GENERAL_END = slotGeneral10;
|
||||
const int16 GENERAL_COUNT = (GENERAL_END - GENERAL_BEGIN) + 1;
|
||||
|
||||
const int16 BONUS_BEGIN = invslot::slotCharm;
|
||||
const int16 BONUS_STAT_END = invslot::slotPowerSource;
|
||||
const int16 BONUS_BEGIN = invslot::slotCharm;
|
||||
const int16 BONUS_STAT_END = invslot::slotPowerSource;
|
||||
const int16 BONUS_SKILL_END = invslot::slotAmmo;
|
||||
|
||||
const int16 CORPSE_BEGIN = invslot::slotGeneral1;
|
||||
const int16 CORPSE_END = invslot::slotGeneral1 + invslot::slotCursor;
|
||||
const int16 CORPSE_END = invslot::slotGeneral1 + invslot::slotCursor;
|
||||
|
||||
const uint64 EQUIPMENT_BITMASK = 0x00000000007FFFFF;
|
||||
const uint64 GENERAL_BITMASK = 0x00000001FF800000;
|
||||
const uint64 CURSOR_BITMASK = 0x0000000200000000;
|
||||
const uint64 EQUIPMENT_BITMASK = 0x00000000007FFFFF;
|
||||
const uint64 GENERAL_BITMASK = 0x00000001FF800000;
|
||||
const uint64 CURSOR_BITMASK = 0x0000000200000000;
|
||||
const uint64 POSSESSIONS_BITMASK = (EQUIPMENT_BITMASK | GENERAL_BITMASK | CURSOR_BITMASK); // based on 34-slot count (RoF+)
|
||||
const uint64 CORPSE_BITMASK = (GENERAL_BITMASK | CURSOR_BITMASK | (EQUIPMENT_BITMASK << 34)); // based on 34-slot count (RoF+)
|
||||
const uint64 CORPSE_BITMASK = (GENERAL_BITMASK | CURSOR_BITMASK | (EQUIPMENT_BITMASK << 34)); // based on 34-slot count (RoF+)
|
||||
|
||||
|
||||
const char* GetInvPossessionsSlotName(int16 inv_slot);
|
||||
@@ -220,21 +199,10 @@ namespace RoF2
|
||||
namespace invbag {
|
||||
inline EQ::versions::ClientVersion GetInvBagRef() { return EQ::versions::ClientVersion::RoF2; }
|
||||
|
||||
const int16 SLOT_TRADESKILL_EXPERIMENT_COMBINE = 1000;
|
||||
const int16 SLOT_INVALID = IINVALID;
|
||||
const int16 SLOT_BEGIN = INULL;
|
||||
const int16 SLOT_COUNT = 200;
|
||||
const int16 SLOT_END = SLOT_COUNT - 1;
|
||||
|
||||
const int16 GENERAL_BAGS_BEGIN = 251;
|
||||
|
||||
const int16 CURSOR_BAG_BEGIN = 351;
|
||||
|
||||
const int16 BANK_BAGS_BEGIN = 2031;
|
||||
|
||||
const int16 SHARED_BANK_BAGS_BEGIN = 2531;
|
||||
|
||||
const int16 TRADE_BAGS_BEGIN = 3031;
|
||||
const int16 SLOT_INVALID = IINVALID;
|
||||
const int16 SLOT_BEGIN = INULL;
|
||||
const int16 SLOT_END = 9; //254;
|
||||
const int16 SLOT_COUNT = 10; //255; // server Size will be 255..unsure what actual client is (test)
|
||||
|
||||
const char* GetInvBagIndexName(int16 bag_index);
|
||||
|
||||
@@ -244,9 +212,9 @@ namespace RoF2
|
||||
inline EQ::versions::ClientVersion GetInvAugRef() { return EQ::versions::ClientVersion::RoF2; }
|
||||
|
||||
const int16 SOCKET_INVALID = IINVALID;
|
||||
const int16 SOCKET_BEGIN = INULL;
|
||||
const int16 SOCKET_END = 5;
|
||||
const int16 SOCKET_COUNT = 6;
|
||||
const int16 SOCKET_BEGIN = INULL;
|
||||
const int16 SOCKET_END = 5;
|
||||
const int16 SOCKET_COUNT = 6;
|
||||
|
||||
const char* GetInvAugIndexName(int16 aug_index);
|
||||
|
||||
@@ -324,7 +292,7 @@ namespace RoF2
|
||||
|
||||
namespace spells {
|
||||
inline EQ::versions::ClientVersion GetSkillsRef() { return EQ::versions::ClientVersion::RoF2; }
|
||||
|
||||
|
||||
enum class CastingSlot : uint32 {
|
||||
Gem1 = 0,
|
||||
Gem2 = 1,
|
||||
@@ -347,7 +315,7 @@ namespace RoF2
|
||||
const int SPELL_ID_MAX = 45000;
|
||||
const int SPELLBOOK_SIZE = 720;
|
||||
const int SPELL_GEM_COUNT = static_cast<uint32>(CastingSlot::MaxGems);
|
||||
|
||||
|
||||
const int LONG_BUFFS = 42;
|
||||
const int SHORT_BUFFS = 20;
|
||||
const int DISC_BUFFS = 1;
|
||||
|
||||
@@ -2463,25 +2463,25 @@ struct WhoAllReturnStruct {
|
||||
struct BeginTrader_Struct {
|
||||
uint32 action;
|
||||
uint32 unknown04;
|
||||
uint64 serial_number[EQ::invtype::BAZAAR_SIZE];
|
||||
uint32 cost[EQ::invtype::BAZAAR_SIZE];
|
||||
uint64 serial_number[80];
|
||||
uint32 cost[80];
|
||||
};
|
||||
|
||||
struct Trader_Struct {
|
||||
uint32 action;
|
||||
uint32 unknown004;
|
||||
uint64 item_id[EQ::invtype::BAZAAR_SIZE];
|
||||
uint32 item_cost[EQ::invtype::BAZAAR_SIZE];
|
||||
uint64 item_id[80];
|
||||
uint32 item_cost[80];
|
||||
};
|
||||
|
||||
struct ClickTrader_Struct {
|
||||
uint32 code;
|
||||
uint32 unknown[161];//damn soe this is totally pointless :/ but at least your finally using memset! Good job :) -LE
|
||||
uint32 itemcost[EQ::invtype::BAZAAR_SIZE];
|
||||
uint32 itemcost[80];
|
||||
};
|
||||
|
||||
struct GetItems_Struct{
|
||||
uint32 items[EQ::invtype::BAZAAR_SIZE];
|
||||
uint32 items[80];
|
||||
};
|
||||
|
||||
struct BecomeTrader_Struct {
|
||||
|
||||
@@ -19,48 +19,48 @@
|
||||
class BaseInventoryRepository {
|
||||
public:
|
||||
struct Inventory {
|
||||
uint32_t character_id;
|
||||
uint32_t slot_id;
|
||||
uint32_t item_id;
|
||||
uint32_t charid;
|
||||
uint32_t slotid;
|
||||
uint32_t itemid;
|
||||
uint16_t charges;
|
||||
uint32_t color;
|
||||
uint32_t augment_one;
|
||||
uint32_t augment_two;
|
||||
uint32_t augment_three;
|
||||
uint32_t augment_four;
|
||||
uint32_t augment_five;
|
||||
uint32_t augment_six;
|
||||
uint32_t augslot1;
|
||||
uint32_t augslot2;
|
||||
uint32_t augslot3;
|
||||
uint32_t augslot4;
|
||||
uint32_t augslot5;
|
||||
int32_t augslot6;
|
||||
uint8_t instnodrop;
|
||||
std::string custom_data;
|
||||
uint32_t ornament_icon;
|
||||
uint32_t ornament_idfile;
|
||||
uint32_t ornamenticon;
|
||||
uint32_t ornamentidfile;
|
||||
int32_t ornament_hero_model;
|
||||
uint64_t guid;
|
||||
};
|
||||
|
||||
static std::string PrimaryKey()
|
||||
{
|
||||
return std::string("character_id");
|
||||
return std::string("charid");
|
||||
}
|
||||
|
||||
static std::vector<std::string> Columns()
|
||||
{
|
||||
return {
|
||||
"character_id",
|
||||
"slot_id",
|
||||
"item_id",
|
||||
"charid",
|
||||
"slotid",
|
||||
"itemid",
|
||||
"charges",
|
||||
"color",
|
||||
"augment_one",
|
||||
"augment_two",
|
||||
"augment_three",
|
||||
"augment_four",
|
||||
"augment_five",
|
||||
"augment_six",
|
||||
"augslot1",
|
||||
"augslot2",
|
||||
"augslot3",
|
||||
"augslot4",
|
||||
"augslot5",
|
||||
"augslot6",
|
||||
"instnodrop",
|
||||
"custom_data",
|
||||
"ornament_icon",
|
||||
"ornament_idfile",
|
||||
"ornamenticon",
|
||||
"ornamentidfile",
|
||||
"ornament_hero_model",
|
||||
"guid",
|
||||
};
|
||||
@@ -69,21 +69,21 @@ public:
|
||||
static std::vector<std::string> SelectColumns()
|
||||
{
|
||||
return {
|
||||
"character_id",
|
||||
"slot_id",
|
||||
"item_id",
|
||||
"charid",
|
||||
"slotid",
|
||||
"itemid",
|
||||
"charges",
|
||||
"color",
|
||||
"augment_one",
|
||||
"augment_two",
|
||||
"augment_three",
|
||||
"augment_four",
|
||||
"augment_five",
|
||||
"augment_six",
|
||||
"augslot1",
|
||||
"augslot2",
|
||||
"augslot3",
|
||||
"augslot4",
|
||||
"augslot5",
|
||||
"augslot6",
|
||||
"instnodrop",
|
||||
"custom_data",
|
||||
"ornament_icon",
|
||||
"ornament_idfile",
|
||||
"ornamenticon",
|
||||
"ornamentidfile",
|
||||
"ornament_hero_model",
|
||||
"guid",
|
||||
};
|
||||
@@ -126,21 +126,21 @@ public:
|
||||
{
|
||||
Inventory e{};
|
||||
|
||||
e.character_id = 0;
|
||||
e.slot_id = 0;
|
||||
e.item_id = 0;
|
||||
e.charid = 0;
|
||||
e.slotid = 0;
|
||||
e.itemid = 0;
|
||||
e.charges = 0;
|
||||
e.color = 0;
|
||||
e.augment_one = 0;
|
||||
e.augment_two = 0;
|
||||
e.augment_three = 0;
|
||||
e.augment_four = 0;
|
||||
e.augment_five = 0;
|
||||
e.augment_six = 0;
|
||||
e.augslot1 = 0;
|
||||
e.augslot2 = 0;
|
||||
e.augslot3 = 0;
|
||||
e.augslot4 = 0;
|
||||
e.augslot5 = 0;
|
||||
e.augslot6 = 0;
|
||||
e.instnodrop = 0;
|
||||
e.custom_data = "";
|
||||
e.ornament_icon = 0;
|
||||
e.ornament_idfile = 0;
|
||||
e.ornamenticon = 0;
|
||||
e.ornamentidfile = 0;
|
||||
e.ornament_hero_model = 0;
|
||||
e.guid = 0;
|
||||
|
||||
@@ -153,7 +153,7 @@ public:
|
||||
)
|
||||
{
|
||||
for (auto &inventory : inventorys) {
|
||||
if (inventory.character_id == inventory_id) {
|
||||
if (inventory.charid == inventory_id) {
|
||||
return inventory;
|
||||
}
|
||||
}
|
||||
@@ -179,21 +179,21 @@ public:
|
||||
if (results.RowCount() == 1) {
|
||||
Inventory e{};
|
||||
|
||||
e.character_id = row[0] ? static_cast<uint32_t>(strtoul(row[0], nullptr, 10)) : 0;
|
||||
e.slot_id = row[1] ? static_cast<uint32_t>(strtoul(row[1], nullptr, 10)) : 0;
|
||||
e.item_id = row[2] ? static_cast<uint32_t>(strtoul(row[2], nullptr, 10)) : 0;
|
||||
e.charid = row[0] ? static_cast<uint32_t>(strtoul(row[0], nullptr, 10)) : 0;
|
||||
e.slotid = row[1] ? static_cast<uint32_t>(strtoul(row[1], nullptr, 10)) : 0;
|
||||
e.itemid = row[2] ? static_cast<uint32_t>(strtoul(row[2], nullptr, 10)) : 0;
|
||||
e.charges = row[3] ? static_cast<uint16_t>(strtoul(row[3], nullptr, 10)) : 0;
|
||||
e.color = row[4] ? static_cast<uint32_t>(strtoul(row[4], nullptr, 10)) : 0;
|
||||
e.augment_one = row[5] ? static_cast<uint32_t>(strtoul(row[5], nullptr, 10)) : 0;
|
||||
e.augment_two = row[6] ? static_cast<uint32_t>(strtoul(row[6], nullptr, 10)) : 0;
|
||||
e.augment_three = row[7] ? static_cast<uint32_t>(strtoul(row[7], nullptr, 10)) : 0;
|
||||
e.augment_four = row[8] ? static_cast<uint32_t>(strtoul(row[8], nullptr, 10)) : 0;
|
||||
e.augment_five = row[9] ? static_cast<uint32_t>(strtoul(row[9], nullptr, 10)) : 0;
|
||||
e.augment_six = row[10] ? static_cast<uint32_t>(strtoul(row[10], nullptr, 10)) : 0;
|
||||
e.augslot1 = row[5] ? static_cast<uint32_t>(strtoul(row[5], nullptr, 10)) : 0;
|
||||
e.augslot2 = row[6] ? static_cast<uint32_t>(strtoul(row[6], nullptr, 10)) : 0;
|
||||
e.augslot3 = row[7] ? static_cast<uint32_t>(strtoul(row[7], nullptr, 10)) : 0;
|
||||
e.augslot4 = row[8] ? static_cast<uint32_t>(strtoul(row[8], nullptr, 10)) : 0;
|
||||
e.augslot5 = row[9] ? static_cast<uint32_t>(strtoul(row[9], nullptr, 10)) : 0;
|
||||
e.augslot6 = row[10] ? static_cast<int32_t>(atoi(row[10])) : 0;
|
||||
e.instnodrop = row[11] ? static_cast<uint8_t>(strtoul(row[11], nullptr, 10)) : 0;
|
||||
e.custom_data = row[12] ? row[12] : "";
|
||||
e.ornament_icon = row[13] ? static_cast<uint32_t>(strtoul(row[13], nullptr, 10)) : 0;
|
||||
e.ornament_idfile = row[14] ? static_cast<uint32_t>(strtoul(row[14], nullptr, 10)) : 0;
|
||||
e.ornamenticon = row[13] ? static_cast<uint32_t>(strtoul(row[13], nullptr, 10)) : 0;
|
||||
e.ornamentidfile = row[14] ? static_cast<uint32_t>(strtoul(row[14], nullptr, 10)) : 0;
|
||||
e.ornament_hero_model = row[15] ? static_cast<int32_t>(atoi(row[15])) : 0;
|
||||
e.guid = row[16] ? strtoull(row[16], nullptr, 10) : 0;
|
||||
|
||||
@@ -229,21 +229,21 @@ public:
|
||||
|
||||
auto columns = Columns();
|
||||
|
||||
v.push_back(columns[0] + " = " + std::to_string(e.character_id));
|
||||
v.push_back(columns[1] + " = " + std::to_string(e.slot_id));
|
||||
v.push_back(columns[2] + " = " + std::to_string(e.item_id));
|
||||
v.push_back(columns[0] + " = " + std::to_string(e.charid));
|
||||
v.push_back(columns[1] + " = " + std::to_string(e.slotid));
|
||||
v.push_back(columns[2] + " = " + std::to_string(e.itemid));
|
||||
v.push_back(columns[3] + " = " + std::to_string(e.charges));
|
||||
v.push_back(columns[4] + " = " + std::to_string(e.color));
|
||||
v.push_back(columns[5] + " = " + std::to_string(e.augment_one));
|
||||
v.push_back(columns[6] + " = " + std::to_string(e.augment_two));
|
||||
v.push_back(columns[7] + " = " + std::to_string(e.augment_three));
|
||||
v.push_back(columns[8] + " = " + std::to_string(e.augment_four));
|
||||
v.push_back(columns[9] + " = " + std::to_string(e.augment_five));
|
||||
v.push_back(columns[10] + " = " + std::to_string(e.augment_six));
|
||||
v.push_back(columns[5] + " = " + std::to_string(e.augslot1));
|
||||
v.push_back(columns[6] + " = " + std::to_string(e.augslot2));
|
||||
v.push_back(columns[7] + " = " + std::to_string(e.augslot3));
|
||||
v.push_back(columns[8] + " = " + std::to_string(e.augslot4));
|
||||
v.push_back(columns[9] + " = " + std::to_string(e.augslot5));
|
||||
v.push_back(columns[10] + " = " + std::to_string(e.augslot6));
|
||||
v.push_back(columns[11] + " = " + std::to_string(e.instnodrop));
|
||||
v.push_back(columns[12] + " = '" + Strings::Escape(e.custom_data) + "'");
|
||||
v.push_back(columns[13] + " = " + std::to_string(e.ornament_icon));
|
||||
v.push_back(columns[14] + " = " + std::to_string(e.ornament_idfile));
|
||||
v.push_back(columns[13] + " = " + std::to_string(e.ornamenticon));
|
||||
v.push_back(columns[14] + " = " + std::to_string(e.ornamentidfile));
|
||||
v.push_back(columns[15] + " = " + std::to_string(e.ornament_hero_model));
|
||||
v.push_back(columns[16] + " = " + std::to_string(e.guid));
|
||||
|
||||
@@ -253,7 +253,7 @@ public:
|
||||
TableName(),
|
||||
Strings::Implode(", ", v),
|
||||
PrimaryKey(),
|
||||
e.character_id
|
||||
e.charid
|
||||
)
|
||||
);
|
||||
|
||||
@@ -267,21 +267,21 @@ public:
|
||||
{
|
||||
std::vector<std::string> v;
|
||||
|
||||
v.push_back(std::to_string(e.character_id));
|
||||
v.push_back(std::to_string(e.slot_id));
|
||||
v.push_back(std::to_string(e.item_id));
|
||||
v.push_back(std::to_string(e.charid));
|
||||
v.push_back(std::to_string(e.slotid));
|
||||
v.push_back(std::to_string(e.itemid));
|
||||
v.push_back(std::to_string(e.charges));
|
||||
v.push_back(std::to_string(e.color));
|
||||
v.push_back(std::to_string(e.augment_one));
|
||||
v.push_back(std::to_string(e.augment_two));
|
||||
v.push_back(std::to_string(e.augment_three));
|
||||
v.push_back(std::to_string(e.augment_four));
|
||||
v.push_back(std::to_string(e.augment_five));
|
||||
v.push_back(std::to_string(e.augment_six));
|
||||
v.push_back(std::to_string(e.augslot1));
|
||||
v.push_back(std::to_string(e.augslot2));
|
||||
v.push_back(std::to_string(e.augslot3));
|
||||
v.push_back(std::to_string(e.augslot4));
|
||||
v.push_back(std::to_string(e.augslot5));
|
||||
v.push_back(std::to_string(e.augslot6));
|
||||
v.push_back(std::to_string(e.instnodrop));
|
||||
v.push_back("'" + Strings::Escape(e.custom_data) + "'");
|
||||
v.push_back(std::to_string(e.ornament_icon));
|
||||
v.push_back(std::to_string(e.ornament_idfile));
|
||||
v.push_back(std::to_string(e.ornamenticon));
|
||||
v.push_back(std::to_string(e.ornamentidfile));
|
||||
v.push_back(std::to_string(e.ornament_hero_model));
|
||||
v.push_back(std::to_string(e.guid));
|
||||
|
||||
@@ -294,7 +294,7 @@ public:
|
||||
);
|
||||
|
||||
if (results.Success()) {
|
||||
e.character_id = results.LastInsertedID();
|
||||
e.charid = results.LastInsertedID();
|
||||
return e;
|
||||
}
|
||||
|
||||
@@ -313,21 +313,21 @@ public:
|
||||
for (auto &e: entries) {
|
||||
std::vector<std::string> v;
|
||||
|
||||
v.push_back(std::to_string(e.character_id));
|
||||
v.push_back(std::to_string(e.slot_id));
|
||||
v.push_back(std::to_string(e.item_id));
|
||||
v.push_back(std::to_string(e.charid));
|
||||
v.push_back(std::to_string(e.slotid));
|
||||
v.push_back(std::to_string(e.itemid));
|
||||
v.push_back(std::to_string(e.charges));
|
||||
v.push_back(std::to_string(e.color));
|
||||
v.push_back(std::to_string(e.augment_one));
|
||||
v.push_back(std::to_string(e.augment_two));
|
||||
v.push_back(std::to_string(e.augment_three));
|
||||
v.push_back(std::to_string(e.augment_four));
|
||||
v.push_back(std::to_string(e.augment_five));
|
||||
v.push_back(std::to_string(e.augment_six));
|
||||
v.push_back(std::to_string(e.augslot1));
|
||||
v.push_back(std::to_string(e.augslot2));
|
||||
v.push_back(std::to_string(e.augslot3));
|
||||
v.push_back(std::to_string(e.augslot4));
|
||||
v.push_back(std::to_string(e.augslot5));
|
||||
v.push_back(std::to_string(e.augslot6));
|
||||
v.push_back(std::to_string(e.instnodrop));
|
||||
v.push_back("'" + Strings::Escape(e.custom_data) + "'");
|
||||
v.push_back(std::to_string(e.ornament_icon));
|
||||
v.push_back(std::to_string(e.ornament_idfile));
|
||||
v.push_back(std::to_string(e.ornamenticon));
|
||||
v.push_back(std::to_string(e.ornamentidfile));
|
||||
v.push_back(std::to_string(e.ornament_hero_model));
|
||||
v.push_back(std::to_string(e.guid));
|
||||
|
||||
@@ -363,21 +363,21 @@ public:
|
||||
for (auto row = results.begin(); row != results.end(); ++row) {
|
||||
Inventory e{};
|
||||
|
||||
e.character_id = row[0] ? static_cast<uint32_t>(strtoul(row[0], nullptr, 10)) : 0;
|
||||
e.slot_id = row[1] ? static_cast<uint32_t>(strtoul(row[1], nullptr, 10)) : 0;
|
||||
e.item_id = row[2] ? static_cast<uint32_t>(strtoul(row[2], nullptr, 10)) : 0;
|
||||
e.charid = row[0] ? static_cast<uint32_t>(strtoul(row[0], nullptr, 10)) : 0;
|
||||
e.slotid = row[1] ? static_cast<uint32_t>(strtoul(row[1], nullptr, 10)) : 0;
|
||||
e.itemid = row[2] ? static_cast<uint32_t>(strtoul(row[2], nullptr, 10)) : 0;
|
||||
e.charges = row[3] ? static_cast<uint16_t>(strtoul(row[3], nullptr, 10)) : 0;
|
||||
e.color = row[4] ? static_cast<uint32_t>(strtoul(row[4], nullptr, 10)) : 0;
|
||||
e.augment_one = row[5] ? static_cast<uint32_t>(strtoul(row[5], nullptr, 10)) : 0;
|
||||
e.augment_two = row[6] ? static_cast<uint32_t>(strtoul(row[6], nullptr, 10)) : 0;
|
||||
e.augment_three = row[7] ? static_cast<uint32_t>(strtoul(row[7], nullptr, 10)) : 0;
|
||||
e.augment_four = row[8] ? static_cast<uint32_t>(strtoul(row[8], nullptr, 10)) : 0;
|
||||
e.augment_five = row[9] ? static_cast<uint32_t>(strtoul(row[9], nullptr, 10)) : 0;
|
||||
e.augment_six = row[10] ? static_cast<uint32_t>(strtoul(row[10], nullptr, 10)) : 0;
|
||||
e.augslot1 = row[5] ? static_cast<uint32_t>(strtoul(row[5], nullptr, 10)) : 0;
|
||||
e.augslot2 = row[6] ? static_cast<uint32_t>(strtoul(row[6], nullptr, 10)) : 0;
|
||||
e.augslot3 = row[7] ? static_cast<uint32_t>(strtoul(row[7], nullptr, 10)) : 0;
|
||||
e.augslot4 = row[8] ? static_cast<uint32_t>(strtoul(row[8], nullptr, 10)) : 0;
|
||||
e.augslot5 = row[9] ? static_cast<uint32_t>(strtoul(row[9], nullptr, 10)) : 0;
|
||||
e.augslot6 = row[10] ? static_cast<int32_t>(atoi(row[10])) : 0;
|
||||
e.instnodrop = row[11] ? static_cast<uint8_t>(strtoul(row[11], nullptr, 10)) : 0;
|
||||
e.custom_data = row[12] ? row[12] : "";
|
||||
e.ornament_icon = row[13] ? static_cast<uint32_t>(strtoul(row[13], nullptr, 10)) : 0;
|
||||
e.ornament_idfile = row[14] ? static_cast<uint32_t>(strtoul(row[14], nullptr, 10)) : 0;
|
||||
e.ornamenticon = row[13] ? static_cast<uint32_t>(strtoul(row[13], nullptr, 10)) : 0;
|
||||
e.ornamentidfile = row[14] ? static_cast<uint32_t>(strtoul(row[14], nullptr, 10)) : 0;
|
||||
e.ornament_hero_model = row[15] ? static_cast<int32_t>(atoi(row[15])) : 0;
|
||||
e.guid = row[16] ? strtoull(row[16], nullptr, 10) : 0;
|
||||
|
||||
@@ -404,21 +404,21 @@ public:
|
||||
for (auto row = results.begin(); row != results.end(); ++row) {
|
||||
Inventory e{};
|
||||
|
||||
e.character_id = row[0] ? static_cast<uint32_t>(strtoul(row[0], nullptr, 10)) : 0;
|
||||
e.slot_id = row[1] ? static_cast<uint32_t>(strtoul(row[1], nullptr, 10)) : 0;
|
||||
e.item_id = row[2] ? static_cast<uint32_t>(strtoul(row[2], nullptr, 10)) : 0;
|
||||
e.charid = row[0] ? static_cast<uint32_t>(strtoul(row[0], nullptr, 10)) : 0;
|
||||
e.slotid = row[1] ? static_cast<uint32_t>(strtoul(row[1], nullptr, 10)) : 0;
|
||||
e.itemid = row[2] ? static_cast<uint32_t>(strtoul(row[2], nullptr, 10)) : 0;
|
||||
e.charges = row[3] ? static_cast<uint16_t>(strtoul(row[3], nullptr, 10)) : 0;
|
||||
e.color = row[4] ? static_cast<uint32_t>(strtoul(row[4], nullptr, 10)) : 0;
|
||||
e.augment_one = row[5] ? static_cast<uint32_t>(strtoul(row[5], nullptr, 10)) : 0;
|
||||
e.augment_two = row[6] ? static_cast<uint32_t>(strtoul(row[6], nullptr, 10)) : 0;
|
||||
e.augment_three = row[7] ? static_cast<uint32_t>(strtoul(row[7], nullptr, 10)) : 0;
|
||||
e.augment_four = row[8] ? static_cast<uint32_t>(strtoul(row[8], nullptr, 10)) : 0;
|
||||
e.augment_five = row[9] ? static_cast<uint32_t>(strtoul(row[9], nullptr, 10)) : 0;
|
||||
e.augment_six = row[10] ? static_cast<uint32_t>(strtoul(row[10], nullptr, 10)) : 0;
|
||||
e.augslot1 = row[5] ? static_cast<uint32_t>(strtoul(row[5], nullptr, 10)) : 0;
|
||||
e.augslot2 = row[6] ? static_cast<uint32_t>(strtoul(row[6], nullptr, 10)) : 0;
|
||||
e.augslot3 = row[7] ? static_cast<uint32_t>(strtoul(row[7], nullptr, 10)) : 0;
|
||||
e.augslot4 = row[8] ? static_cast<uint32_t>(strtoul(row[8], nullptr, 10)) : 0;
|
||||
e.augslot5 = row[9] ? static_cast<uint32_t>(strtoul(row[9], nullptr, 10)) : 0;
|
||||
e.augslot6 = row[10] ? static_cast<int32_t>(atoi(row[10])) : 0;
|
||||
e.instnodrop = row[11] ? static_cast<uint8_t>(strtoul(row[11], nullptr, 10)) : 0;
|
||||
e.custom_data = row[12] ? row[12] : "";
|
||||
e.ornament_icon = row[13] ? static_cast<uint32_t>(strtoul(row[13], nullptr, 10)) : 0;
|
||||
e.ornament_idfile = row[14] ? static_cast<uint32_t>(strtoul(row[14], nullptr, 10)) : 0;
|
||||
e.ornamenticon = row[13] ? static_cast<uint32_t>(strtoul(row[13], nullptr, 10)) : 0;
|
||||
e.ornamentidfile = row[14] ? static_cast<uint32_t>(strtoul(row[14], nullptr, 10)) : 0;
|
||||
e.ornament_hero_model = row[15] ? static_cast<int32_t>(atoi(row[15])) : 0;
|
||||
e.guid = row[16] ? strtoull(row[16], nullptr, 10) : 0;
|
||||
|
||||
@@ -495,21 +495,21 @@ public:
|
||||
{
|
||||
std::vector<std::string> v;
|
||||
|
||||
v.push_back(std::to_string(e.character_id));
|
||||
v.push_back(std::to_string(e.slot_id));
|
||||
v.push_back(std::to_string(e.item_id));
|
||||
v.push_back(std::to_string(e.charid));
|
||||
v.push_back(std::to_string(e.slotid));
|
||||
v.push_back(std::to_string(e.itemid));
|
||||
v.push_back(std::to_string(e.charges));
|
||||
v.push_back(std::to_string(e.color));
|
||||
v.push_back(std::to_string(e.augment_one));
|
||||
v.push_back(std::to_string(e.augment_two));
|
||||
v.push_back(std::to_string(e.augment_three));
|
||||
v.push_back(std::to_string(e.augment_four));
|
||||
v.push_back(std::to_string(e.augment_five));
|
||||
v.push_back(std::to_string(e.augment_six));
|
||||
v.push_back(std::to_string(e.augslot1));
|
||||
v.push_back(std::to_string(e.augslot2));
|
||||
v.push_back(std::to_string(e.augslot3));
|
||||
v.push_back(std::to_string(e.augslot4));
|
||||
v.push_back(std::to_string(e.augslot5));
|
||||
v.push_back(std::to_string(e.augslot6));
|
||||
v.push_back(std::to_string(e.instnodrop));
|
||||
v.push_back("'" + Strings::Escape(e.custom_data) + "'");
|
||||
v.push_back(std::to_string(e.ornament_icon));
|
||||
v.push_back(std::to_string(e.ornament_idfile));
|
||||
v.push_back(std::to_string(e.ornamenticon));
|
||||
v.push_back(std::to_string(e.ornamentidfile));
|
||||
v.push_back(std::to_string(e.ornament_hero_model));
|
||||
v.push_back(std::to_string(e.guid));
|
||||
|
||||
@@ -534,21 +534,21 @@ public:
|
||||
for (auto &e: entries) {
|
||||
std::vector<std::string> v;
|
||||
|
||||
v.push_back(std::to_string(e.character_id));
|
||||
v.push_back(std::to_string(e.slot_id));
|
||||
v.push_back(std::to_string(e.item_id));
|
||||
v.push_back(std::to_string(e.charid));
|
||||
v.push_back(std::to_string(e.slotid));
|
||||
v.push_back(std::to_string(e.itemid));
|
||||
v.push_back(std::to_string(e.charges));
|
||||
v.push_back(std::to_string(e.color));
|
||||
v.push_back(std::to_string(e.augment_one));
|
||||
v.push_back(std::to_string(e.augment_two));
|
||||
v.push_back(std::to_string(e.augment_three));
|
||||
v.push_back(std::to_string(e.augment_four));
|
||||
v.push_back(std::to_string(e.augment_five));
|
||||
v.push_back(std::to_string(e.augment_six));
|
||||
v.push_back(std::to_string(e.augslot1));
|
||||
v.push_back(std::to_string(e.augslot2));
|
||||
v.push_back(std::to_string(e.augslot3));
|
||||
v.push_back(std::to_string(e.augslot4));
|
||||
v.push_back(std::to_string(e.augslot5));
|
||||
v.push_back(std::to_string(e.augslot6));
|
||||
v.push_back(std::to_string(e.instnodrop));
|
||||
v.push_back("'" + Strings::Escape(e.custom_data) + "'");
|
||||
v.push_back(std::to_string(e.ornament_icon));
|
||||
v.push_back(std::to_string(e.ornament_idfile));
|
||||
v.push_back(std::to_string(e.ornamenticon));
|
||||
v.push_back(std::to_string(e.ornamentidfile));
|
||||
v.push_back(std::to_string(e.ornament_hero_model));
|
||||
v.push_back(std::to_string(e.guid));
|
||||
|
||||
|
||||
@@ -1,560 +0,0 @@
|
||||
/**
|
||||
* DO NOT MODIFY THIS FILE
|
||||
*
|
||||
* This repository was automatically generated and is NOT to be modified directly.
|
||||
* Any repository modifications are meant to be made to the repository extending the base.
|
||||
* Any modifications to base repositories are to be made by the generator only
|
||||
*
|
||||
* @generator ./utils/scripts/generators/repository-generator.pl
|
||||
* @docs https://docs.eqemu.io/developer/repositories
|
||||
*/
|
||||
|
||||
#ifndef EQEMU_BASE_SHAREDBANK_REPOSITORY_H
|
||||
#define EQEMU_BASE_SHAREDBANK_REPOSITORY_H
|
||||
|
||||
#include "../../database.h"
|
||||
#include "../../strings.h"
|
||||
#include <ctime>
|
||||
|
||||
class BaseSharedbankRepository {
|
||||
public:
|
||||
struct Sharedbank {
|
||||
uint32_t account_id;
|
||||
uint32_t slot_id;
|
||||
uint32_t item_id;
|
||||
uint16_t charges;
|
||||
uint32_t color;
|
||||
uint32_t augment_one;
|
||||
uint32_t augment_two;
|
||||
uint32_t augment_three;
|
||||
uint32_t augment_four;
|
||||
uint32_t augment_five;
|
||||
uint32_t augment_six;
|
||||
std::string custom_data;
|
||||
uint32_t ornament_icon;
|
||||
uint32_t ornament_idfile;
|
||||
int32_t ornament_hero_model;
|
||||
uint64_t guid;
|
||||
};
|
||||
|
||||
static std::string PrimaryKey()
|
||||
{
|
||||
return std::string("account_id");
|
||||
}
|
||||
|
||||
static std::vector<std::string> Columns()
|
||||
{
|
||||
return {
|
||||
"account_id",
|
||||
"slot_id",
|
||||
"item_id",
|
||||
"charges",
|
||||
"color",
|
||||
"augment_one",
|
||||
"augment_two",
|
||||
"augment_three",
|
||||
"augment_four",
|
||||
"augment_five",
|
||||
"augment_six",
|
||||
"custom_data",
|
||||
"ornament_icon",
|
||||
"ornament_idfile",
|
||||
"ornament_hero_model",
|
||||
"guid",
|
||||
};
|
||||
}
|
||||
|
||||
static std::vector<std::string> SelectColumns()
|
||||
{
|
||||
return {
|
||||
"account_id",
|
||||
"slot_id",
|
||||
"item_id",
|
||||
"charges",
|
||||
"color",
|
||||
"augment_one",
|
||||
"augment_two",
|
||||
"augment_three",
|
||||
"augment_four",
|
||||
"augment_five",
|
||||
"augment_six",
|
||||
"custom_data",
|
||||
"ornament_icon",
|
||||
"ornament_idfile",
|
||||
"ornament_hero_model",
|
||||
"guid",
|
||||
};
|
||||
}
|
||||
|
||||
static std::string ColumnsRaw()
|
||||
{
|
||||
return std::string(Strings::Implode(", ", Columns()));
|
||||
}
|
||||
|
||||
static std::string SelectColumnsRaw()
|
||||
{
|
||||
return std::string(Strings::Implode(", ", SelectColumns()));
|
||||
}
|
||||
|
||||
static std::string TableName()
|
||||
{
|
||||
return std::string("sharedbank");
|
||||
}
|
||||
|
||||
static std::string BaseSelect()
|
||||
{
|
||||
return fmt::format(
|
||||
"SELECT {} FROM {}",
|
||||
SelectColumnsRaw(),
|
||||
TableName()
|
||||
);
|
||||
}
|
||||
|
||||
static std::string BaseInsert()
|
||||
{
|
||||
return fmt::format(
|
||||
"INSERT INTO {} ({}) ",
|
||||
TableName(),
|
||||
ColumnsRaw()
|
||||
);
|
||||
}
|
||||
|
||||
static Sharedbank NewEntity()
|
||||
{
|
||||
Sharedbank e{};
|
||||
|
||||
e.account_id = 0;
|
||||
e.slot_id = 0;
|
||||
e.item_id = 0;
|
||||
e.charges = 0;
|
||||
e.color = 0;
|
||||
e.augment_one = 0;
|
||||
e.augment_two = 0;
|
||||
e.augment_three = 0;
|
||||
e.augment_four = 0;
|
||||
e.augment_five = 0;
|
||||
e.augment_six = 0;
|
||||
e.custom_data = "";
|
||||
e.ornament_icon = 0;
|
||||
e.ornament_idfile = 0;
|
||||
e.ornament_hero_model = 0;
|
||||
e.guid = 0;
|
||||
|
||||
return e;
|
||||
}
|
||||
|
||||
static Sharedbank GetSharedbank(
|
||||
const std::vector<Sharedbank> &sharedbanks,
|
||||
int sharedbank_id
|
||||
)
|
||||
{
|
||||
for (auto &sharedbank : sharedbanks) {
|
||||
if (sharedbank.account_id == sharedbank_id) {
|
||||
return sharedbank;
|
||||
}
|
||||
}
|
||||
|
||||
return NewEntity();
|
||||
}
|
||||
|
||||
static Sharedbank FindOne(
|
||||
Database& db,
|
||||
int sharedbank_id
|
||||
)
|
||||
{
|
||||
auto results = db.QueryDatabase(
|
||||
fmt::format(
|
||||
"{} WHERE {} = {} LIMIT 1",
|
||||
BaseSelect(),
|
||||
PrimaryKey(),
|
||||
sharedbank_id
|
||||
)
|
||||
);
|
||||
|
||||
auto row = results.begin();
|
||||
if (results.RowCount() == 1) {
|
||||
Sharedbank e{};
|
||||
|
||||
e.account_id = row[0] ? static_cast<uint32_t>(strtoul(row[0], nullptr, 10)) : 0;
|
||||
e.slot_id = row[1] ? static_cast<uint32_t>(strtoul(row[1], nullptr, 10)) : 0;
|
||||
e.item_id = row[2] ? static_cast<uint32_t>(strtoul(row[2], nullptr, 10)) : 0;
|
||||
e.charges = row[3] ? static_cast<uint16_t>(strtoul(row[3], nullptr, 10)) : 0;
|
||||
e.color = row[4] ? static_cast<uint32_t>(strtoul(row[4], nullptr, 10)) : 0;
|
||||
e.augment_one = row[5] ? static_cast<uint32_t>(strtoul(row[5], nullptr, 10)) : 0;
|
||||
e.augment_two = row[6] ? static_cast<uint32_t>(strtoul(row[6], nullptr, 10)) : 0;
|
||||
e.augment_three = row[7] ? static_cast<uint32_t>(strtoul(row[7], nullptr, 10)) : 0;
|
||||
e.augment_four = row[8] ? static_cast<uint32_t>(strtoul(row[8], nullptr, 10)) : 0;
|
||||
e.augment_five = row[9] ? static_cast<uint32_t>(strtoul(row[9], nullptr, 10)) : 0;
|
||||
e.augment_six = row[10] ? static_cast<uint32_t>(strtoul(row[10], nullptr, 10)) : 0;
|
||||
e.custom_data = row[11] ? row[11] : "";
|
||||
e.ornament_icon = row[12] ? static_cast<uint32_t>(strtoul(row[12], nullptr, 10)) : 0;
|
||||
e.ornament_idfile = row[13] ? static_cast<uint32_t>(strtoul(row[13], nullptr, 10)) : 0;
|
||||
e.ornament_hero_model = row[14] ? static_cast<int32_t>(atoi(row[14])) : 0;
|
||||
e.guid = row[15] ? strtoull(row[15], nullptr, 10) : 0;
|
||||
|
||||
return e;
|
||||
}
|
||||
|
||||
return NewEntity();
|
||||
}
|
||||
|
||||
static int DeleteOne(
|
||||
Database& db,
|
||||
int sharedbank_id
|
||||
)
|
||||
{
|
||||
auto results = db.QueryDatabase(
|
||||
fmt::format(
|
||||
"DELETE FROM {} WHERE {} = {}",
|
||||
TableName(),
|
||||
PrimaryKey(),
|
||||
sharedbank_id
|
||||
)
|
||||
);
|
||||
|
||||
return (results.Success() ? results.RowsAffected() : 0);
|
||||
}
|
||||
|
||||
static int UpdateOne(
|
||||
Database& db,
|
||||
const Sharedbank &e
|
||||
)
|
||||
{
|
||||
std::vector<std::string> v;
|
||||
|
||||
auto columns = Columns();
|
||||
|
||||
v.push_back(columns[0] + " = " + std::to_string(e.account_id));
|
||||
v.push_back(columns[1] + " = " + std::to_string(e.slot_id));
|
||||
v.push_back(columns[2] + " = " + std::to_string(e.item_id));
|
||||
v.push_back(columns[3] + " = " + std::to_string(e.charges));
|
||||
v.push_back(columns[4] + " = " + std::to_string(e.color));
|
||||
v.push_back(columns[5] + " = " + std::to_string(e.augment_one));
|
||||
v.push_back(columns[6] + " = " + std::to_string(e.augment_two));
|
||||
v.push_back(columns[7] + " = " + std::to_string(e.augment_three));
|
||||
v.push_back(columns[8] + " = " + std::to_string(e.augment_four));
|
||||
v.push_back(columns[9] + " = " + std::to_string(e.augment_five));
|
||||
v.push_back(columns[10] + " = " + std::to_string(e.augment_six));
|
||||
v.push_back(columns[11] + " = '" + Strings::Escape(e.custom_data) + "'");
|
||||
v.push_back(columns[12] + " = " + std::to_string(e.ornament_icon));
|
||||
v.push_back(columns[13] + " = " + std::to_string(e.ornament_idfile));
|
||||
v.push_back(columns[14] + " = " + std::to_string(e.ornament_hero_model));
|
||||
v.push_back(columns[15] + " = " + std::to_string(e.guid));
|
||||
|
||||
auto results = db.QueryDatabase(
|
||||
fmt::format(
|
||||
"UPDATE {} SET {} WHERE {} = {}",
|
||||
TableName(),
|
||||
Strings::Implode(", ", v),
|
||||
PrimaryKey(),
|
||||
e.account_id
|
||||
)
|
||||
);
|
||||
|
||||
return (results.Success() ? results.RowsAffected() : 0);
|
||||
}
|
||||
|
||||
static Sharedbank InsertOne(
|
||||
Database& db,
|
||||
Sharedbank e
|
||||
)
|
||||
{
|
||||
std::vector<std::string> v;
|
||||
|
||||
v.push_back(std::to_string(e.account_id));
|
||||
v.push_back(std::to_string(e.slot_id));
|
||||
v.push_back(std::to_string(e.item_id));
|
||||
v.push_back(std::to_string(e.charges));
|
||||
v.push_back(std::to_string(e.color));
|
||||
v.push_back(std::to_string(e.augment_one));
|
||||
v.push_back(std::to_string(e.augment_two));
|
||||
v.push_back(std::to_string(e.augment_three));
|
||||
v.push_back(std::to_string(e.augment_four));
|
||||
v.push_back(std::to_string(e.augment_five));
|
||||
v.push_back(std::to_string(e.augment_six));
|
||||
v.push_back("'" + Strings::Escape(e.custom_data) + "'");
|
||||
v.push_back(std::to_string(e.ornament_icon));
|
||||
v.push_back(std::to_string(e.ornament_idfile));
|
||||
v.push_back(std::to_string(e.ornament_hero_model));
|
||||
v.push_back(std::to_string(e.guid));
|
||||
|
||||
auto results = db.QueryDatabase(
|
||||
fmt::format(
|
||||
"{} VALUES ({})",
|
||||
BaseInsert(),
|
||||
Strings::Implode(",", v)
|
||||
)
|
||||
);
|
||||
|
||||
if (results.Success()) {
|
||||
e.account_id = results.LastInsertedID();
|
||||
return e;
|
||||
}
|
||||
|
||||
e = NewEntity();
|
||||
|
||||
return e;
|
||||
}
|
||||
|
||||
static int InsertMany(
|
||||
Database& db,
|
||||
const std::vector<Sharedbank> &entries
|
||||
)
|
||||
{
|
||||
std::vector<std::string> insert_chunks;
|
||||
|
||||
for (auto &e: entries) {
|
||||
std::vector<std::string> v;
|
||||
|
||||
v.push_back(std::to_string(e.account_id));
|
||||
v.push_back(std::to_string(e.slot_id));
|
||||
v.push_back(std::to_string(e.item_id));
|
||||
v.push_back(std::to_string(e.charges));
|
||||
v.push_back(std::to_string(e.color));
|
||||
v.push_back(std::to_string(e.augment_one));
|
||||
v.push_back(std::to_string(e.augment_two));
|
||||
v.push_back(std::to_string(e.augment_three));
|
||||
v.push_back(std::to_string(e.augment_four));
|
||||
v.push_back(std::to_string(e.augment_five));
|
||||
v.push_back(std::to_string(e.augment_six));
|
||||
v.push_back("'" + Strings::Escape(e.custom_data) + "'");
|
||||
v.push_back(std::to_string(e.ornament_icon));
|
||||
v.push_back(std::to_string(e.ornament_idfile));
|
||||
v.push_back(std::to_string(e.ornament_hero_model));
|
||||
v.push_back(std::to_string(e.guid));
|
||||
|
||||
insert_chunks.push_back("(" + Strings::Implode(",", v) + ")");
|
||||
}
|
||||
|
||||
std::vector<std::string> v;
|
||||
|
||||
auto results = db.QueryDatabase(
|
||||
fmt::format(
|
||||
"{} VALUES {}",
|
||||
BaseInsert(),
|
||||
Strings::Implode(",", insert_chunks)
|
||||
)
|
||||
);
|
||||
|
||||
return (results.Success() ? results.RowsAffected() : 0);
|
||||
}
|
||||
|
||||
static std::vector<Sharedbank> All(Database& db)
|
||||
{
|
||||
std::vector<Sharedbank> all_entries;
|
||||
|
||||
auto results = db.QueryDatabase(
|
||||
fmt::format(
|
||||
"{}",
|
||||
BaseSelect()
|
||||
)
|
||||
);
|
||||
|
||||
all_entries.reserve(results.RowCount());
|
||||
|
||||
for (auto row = results.begin(); row != results.end(); ++row) {
|
||||
Sharedbank e{};
|
||||
|
||||
e.account_id = row[0] ? static_cast<uint32_t>(strtoul(row[0], nullptr, 10)) : 0;
|
||||
e.slot_id = row[1] ? static_cast<uint32_t>(strtoul(row[1], nullptr, 10)) : 0;
|
||||
e.item_id = row[2] ? static_cast<uint32_t>(strtoul(row[2], nullptr, 10)) : 0;
|
||||
e.charges = row[3] ? static_cast<uint16_t>(strtoul(row[3], nullptr, 10)) : 0;
|
||||
e.color = row[4] ? static_cast<uint32_t>(strtoul(row[4], nullptr, 10)) : 0;
|
||||
e.augment_one = row[5] ? static_cast<uint32_t>(strtoul(row[5], nullptr, 10)) : 0;
|
||||
e.augment_two = row[6] ? static_cast<uint32_t>(strtoul(row[6], nullptr, 10)) : 0;
|
||||
e.augment_three = row[7] ? static_cast<uint32_t>(strtoul(row[7], nullptr, 10)) : 0;
|
||||
e.augment_four = row[8] ? static_cast<uint32_t>(strtoul(row[8], nullptr, 10)) : 0;
|
||||
e.augment_five = row[9] ? static_cast<uint32_t>(strtoul(row[9], nullptr, 10)) : 0;
|
||||
e.augment_six = row[10] ? static_cast<uint32_t>(strtoul(row[10], nullptr, 10)) : 0;
|
||||
e.custom_data = row[11] ? row[11] : "";
|
||||
e.ornament_icon = row[12] ? static_cast<uint32_t>(strtoul(row[12], nullptr, 10)) : 0;
|
||||
e.ornament_idfile = row[13] ? static_cast<uint32_t>(strtoul(row[13], nullptr, 10)) : 0;
|
||||
e.ornament_hero_model = row[14] ? static_cast<int32_t>(atoi(row[14])) : 0;
|
||||
e.guid = row[15] ? strtoull(row[15], nullptr, 10) : 0;
|
||||
|
||||
all_entries.push_back(e);
|
||||
}
|
||||
|
||||
return all_entries;
|
||||
}
|
||||
|
||||
static std::vector<Sharedbank> GetWhere(Database& db, const std::string &where_filter)
|
||||
{
|
||||
std::vector<Sharedbank> all_entries;
|
||||
|
||||
auto results = db.QueryDatabase(
|
||||
fmt::format(
|
||||
"{} WHERE {}",
|
||||
BaseSelect(),
|
||||
where_filter
|
||||
)
|
||||
);
|
||||
|
||||
all_entries.reserve(results.RowCount());
|
||||
|
||||
for (auto row = results.begin(); row != results.end(); ++row) {
|
||||
Sharedbank e{};
|
||||
|
||||
e.account_id = row[0] ? static_cast<uint32_t>(strtoul(row[0], nullptr, 10)) : 0;
|
||||
e.slot_id = row[1] ? static_cast<uint32_t>(strtoul(row[1], nullptr, 10)) : 0;
|
||||
e.item_id = row[2] ? static_cast<uint32_t>(strtoul(row[2], nullptr, 10)) : 0;
|
||||
e.charges = row[3] ? static_cast<uint16_t>(strtoul(row[3], nullptr, 10)) : 0;
|
||||
e.color = row[4] ? static_cast<uint32_t>(strtoul(row[4], nullptr, 10)) : 0;
|
||||
e.augment_one = row[5] ? static_cast<uint32_t>(strtoul(row[5], nullptr, 10)) : 0;
|
||||
e.augment_two = row[6] ? static_cast<uint32_t>(strtoul(row[6], nullptr, 10)) : 0;
|
||||
e.augment_three = row[7] ? static_cast<uint32_t>(strtoul(row[7], nullptr, 10)) : 0;
|
||||
e.augment_four = row[8] ? static_cast<uint32_t>(strtoul(row[8], nullptr, 10)) : 0;
|
||||
e.augment_five = row[9] ? static_cast<uint32_t>(strtoul(row[9], nullptr, 10)) : 0;
|
||||
e.augment_six = row[10] ? static_cast<uint32_t>(strtoul(row[10], nullptr, 10)) : 0;
|
||||
e.custom_data = row[11] ? row[11] : "";
|
||||
e.ornament_icon = row[12] ? static_cast<uint32_t>(strtoul(row[12], nullptr, 10)) : 0;
|
||||
e.ornament_idfile = row[13] ? static_cast<uint32_t>(strtoul(row[13], nullptr, 10)) : 0;
|
||||
e.ornament_hero_model = row[14] ? static_cast<int32_t>(atoi(row[14])) : 0;
|
||||
e.guid = row[15] ? strtoull(row[15], nullptr, 10) : 0;
|
||||
|
||||
all_entries.push_back(e);
|
||||
}
|
||||
|
||||
return all_entries;
|
||||
}
|
||||
|
||||
static int DeleteWhere(Database& db, const std::string &where_filter)
|
||||
{
|
||||
auto results = db.QueryDatabase(
|
||||
fmt::format(
|
||||
"DELETE FROM {} WHERE {}",
|
||||
TableName(),
|
||||
where_filter
|
||||
)
|
||||
);
|
||||
|
||||
return (results.Success() ? results.RowsAffected() : 0);
|
||||
}
|
||||
|
||||
static int Truncate(Database& db)
|
||||
{
|
||||
auto results = db.QueryDatabase(
|
||||
fmt::format(
|
||||
"TRUNCATE TABLE {}",
|
||||
TableName()
|
||||
)
|
||||
);
|
||||
|
||||
return (results.Success() ? results.RowsAffected() : 0);
|
||||
}
|
||||
|
||||
static int64 GetMaxId(Database& db)
|
||||
{
|
||||
auto results = db.QueryDatabase(
|
||||
fmt::format(
|
||||
"SELECT COALESCE(MAX({}), 0) FROM {}",
|
||||
PrimaryKey(),
|
||||
TableName()
|
||||
)
|
||||
);
|
||||
|
||||
return (results.Success() && results.begin()[0] ? strtoll(results.begin()[0], nullptr, 10) : 0);
|
||||
}
|
||||
|
||||
static int64 Count(Database& db, const std::string &where_filter = "")
|
||||
{
|
||||
auto results = db.QueryDatabase(
|
||||
fmt::format(
|
||||
"SELECT COUNT(*) FROM {} {}",
|
||||
TableName(),
|
||||
(where_filter.empty() ? "" : "WHERE " + where_filter)
|
||||
)
|
||||
);
|
||||
|
||||
return (results.Success() && results.begin()[0] ? strtoll(results.begin()[0], nullptr, 10) : 0);
|
||||
}
|
||||
|
||||
static std::string BaseReplace()
|
||||
{
|
||||
return fmt::format(
|
||||
"REPLACE INTO {} ({}) ",
|
||||
TableName(),
|
||||
ColumnsRaw()
|
||||
);
|
||||
}
|
||||
|
||||
static int ReplaceOne(
|
||||
Database& db,
|
||||
const Sharedbank &e
|
||||
)
|
||||
{
|
||||
std::vector<std::string> v;
|
||||
|
||||
v.push_back(std::to_string(e.account_id));
|
||||
v.push_back(std::to_string(e.slot_id));
|
||||
v.push_back(std::to_string(e.item_id));
|
||||
v.push_back(std::to_string(e.charges));
|
||||
v.push_back(std::to_string(e.color));
|
||||
v.push_back(std::to_string(e.augment_one));
|
||||
v.push_back(std::to_string(e.augment_two));
|
||||
v.push_back(std::to_string(e.augment_three));
|
||||
v.push_back(std::to_string(e.augment_four));
|
||||
v.push_back(std::to_string(e.augment_five));
|
||||
v.push_back(std::to_string(e.augment_six));
|
||||
v.push_back("'" + Strings::Escape(e.custom_data) + "'");
|
||||
v.push_back(std::to_string(e.ornament_icon));
|
||||
v.push_back(std::to_string(e.ornament_idfile));
|
||||
v.push_back(std::to_string(e.ornament_hero_model));
|
||||
v.push_back(std::to_string(e.guid));
|
||||
|
||||
auto results = db.QueryDatabase(
|
||||
fmt::format(
|
||||
"{} VALUES ({})",
|
||||
BaseReplace(),
|
||||
Strings::Implode(",", v)
|
||||
)
|
||||
);
|
||||
|
||||
return (results.Success() ? results.RowsAffected() : 0);
|
||||
}
|
||||
|
||||
static int ReplaceMany(
|
||||
Database& db,
|
||||
const std::vector<Sharedbank> &entries
|
||||
)
|
||||
{
|
||||
std::vector<std::string> insert_chunks;
|
||||
|
||||
for (auto &e: entries) {
|
||||
std::vector<std::string> v;
|
||||
|
||||
v.push_back(std::to_string(e.account_id));
|
||||
v.push_back(std::to_string(e.slot_id));
|
||||
v.push_back(std::to_string(e.item_id));
|
||||
v.push_back(std::to_string(e.charges));
|
||||
v.push_back(std::to_string(e.color));
|
||||
v.push_back(std::to_string(e.augment_one));
|
||||
v.push_back(std::to_string(e.augment_two));
|
||||
v.push_back(std::to_string(e.augment_three));
|
||||
v.push_back(std::to_string(e.augment_four));
|
||||
v.push_back(std::to_string(e.augment_five));
|
||||
v.push_back(std::to_string(e.augment_six));
|
||||
v.push_back("'" + Strings::Escape(e.custom_data) + "'");
|
||||
v.push_back(std::to_string(e.ornament_icon));
|
||||
v.push_back(std::to_string(e.ornament_idfile));
|
||||
v.push_back(std::to_string(e.ornament_hero_model));
|
||||
v.push_back(std::to_string(e.guid));
|
||||
|
||||
insert_chunks.push_back("(" + Strings::Implode(",", v) + ")");
|
||||
}
|
||||
|
||||
std::vector<std::string> v;
|
||||
|
||||
auto results = db.QueryDatabase(
|
||||
fmt::format(
|
||||
"{} VALUES {}",
|
||||
BaseReplace(),
|
||||
Strings::Implode(",", insert_chunks)
|
||||
)
|
||||
);
|
||||
|
||||
return (results.Success() ? results.RowsAffected() : 0);
|
||||
}
|
||||
};
|
||||
|
||||
#endif //EQEMU_BASE_SHAREDBANK_REPOSITORY_H
|
||||
@@ -7,14 +7,6 @@
|
||||
|
||||
class ItemsRepository: public BaseItemsRepository {
|
||||
public:
|
||||
struct Bazaar_Results {
|
||||
uint32 item_id;
|
||||
std::string name;
|
||||
bool stackable;
|
||||
uint32 icon;
|
||||
uint32 stats;
|
||||
};
|
||||
|
||||
static std::vector<int32> GetItemIDsBySearchCriteria(
|
||||
Database& db,
|
||||
std::string search_string,
|
||||
@@ -45,51 +37,6 @@ public:
|
||||
return item_id_list;
|
||||
}
|
||||
|
||||
static std::unordered_map<uint32, Bazaar_Results> GetItemsForBazaarSearch(
|
||||
Database& db,
|
||||
const std::vector<std::string> &search_ids,
|
||||
const std::string &name,
|
||||
const std::string &field_criteria_items,
|
||||
const std::string &where_criteria_items,
|
||||
const uint32 query_limit = 0
|
||||
)
|
||||
{
|
||||
auto query = fmt::format(
|
||||
"SELECT id, name, stackable, icon, {} "
|
||||
"FROM items "
|
||||
"WHERE `name` LIKE '%%{}%%' AND {} AND id IN({}) "
|
||||
"ORDER BY id ASC",
|
||||
field_criteria_items,
|
||||
Strings::Escape(name),
|
||||
where_criteria_items,
|
||||
Strings::Implode(",", search_ids)
|
||||
);
|
||||
|
||||
if (query_limit >= 1) {
|
||||
query += fmt::format(" LIMIT {}", query_limit);
|
||||
}
|
||||
|
||||
std::unordered_map<uint32, Bazaar_Results> item_list;
|
||||
|
||||
auto results = db.QueryDatabase(query);
|
||||
if (!results.Success() || !results.RowCount()) {
|
||||
return item_list;
|
||||
}
|
||||
|
||||
item_list.reserve(results.RowCount());
|
||||
for (auto row : results) {
|
||||
Bazaar_Results br{};
|
||||
br.item_id = row[0] ? static_cast<int32_t>(atoi(row[0])) : 0;
|
||||
br.name = row[1] ? row[1] : "";
|
||||
br.stackable = atoi(row[2]) ? true : false;
|
||||
br.icon = row[3] ? static_cast<int32_t>(atoi(row[3])) : 0;
|
||||
br.stats = row[4] ? static_cast<int32_t>(atoi(row[4])) : 0;
|
||||
|
||||
item_list.emplace(br.item_id, br);
|
||||
}
|
||||
|
||||
return item_list;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
|
||||
@@ -3,47 +3,310 @@
|
||||
|
||||
#include "../database.h"
|
||||
#include "../strings.h"
|
||||
#include "base/base_sharedbank_repository.h"
|
||||
|
||||
class SharedbankRepository: public BaseSharedbankRepository {
|
||||
class SharedbankRepository {
|
||||
public:
|
||||
struct Sharedbank {
|
||||
int acctid;
|
||||
int slotid;
|
||||
int itemid;
|
||||
int16 charges;
|
||||
int augslot1;
|
||||
int augslot2;
|
||||
int augslot3;
|
||||
int augslot4;
|
||||
int augslot5;
|
||||
int augslot6;
|
||||
std::string custom_data;
|
||||
};
|
||||
|
||||
/**
|
||||
* This file was auto generated and can be modified and extended upon
|
||||
*
|
||||
* Base repository methods are automatically
|
||||
* generated in the "base" version of this repository. The base repository
|
||||
* is immutable and to be left untouched, while methods in this class
|
||||
* are used as extension methods for more specific persistence-layer
|
||||
* accessors or mutators.
|
||||
*
|
||||
* Base Methods (Subject to be expanded upon in time)
|
||||
*
|
||||
* Note: Not all tables are designed appropriately to fit functionality with all base methods
|
||||
*
|
||||
* InsertOne
|
||||
* UpdateOne
|
||||
* DeleteOne
|
||||
* FindOne
|
||||
* GetWhere(std::string where_filter)
|
||||
* DeleteWhere(std::string where_filter)
|
||||
* InsertMany
|
||||
* All
|
||||
*
|
||||
* Example custom methods in a repository
|
||||
*
|
||||
* SharedbankRepository::GetByZoneAndVersion(int zone_id, int zone_version)
|
||||
* SharedbankRepository::GetWhereNeverExpires()
|
||||
* SharedbankRepository::GetWhereXAndY()
|
||||
* SharedbankRepository::DeleteWhereXAndY()
|
||||
*
|
||||
* Most of the above could be covered by base methods, but if you as a developer
|
||||
* find yourself re-using logic for other parts of the code, its best to just make a
|
||||
* method that can be re-used easily elsewhere especially if it can use a base repository
|
||||
* method and encapsulate filters there
|
||||
*/
|
||||
static std::string PrimaryKey()
|
||||
{
|
||||
return std::string("");
|
||||
}
|
||||
|
||||
// Custom extended repository methods here
|
||||
static std::vector<std::string> Columns()
|
||||
{
|
||||
return {
|
||||
"acctid",
|
||||
"slotid",
|
||||
"itemid",
|
||||
"charges",
|
||||
"augslot1",
|
||||
"augslot2",
|
||||
"augslot3",
|
||||
"augslot4",
|
||||
"augslot5",
|
||||
"augslot6",
|
||||
"custom_data",
|
||||
};
|
||||
}
|
||||
|
||||
static std::string ColumnsRaw()
|
||||
{
|
||||
return std::string(Strings::Implode(", ", Columns()));
|
||||
}
|
||||
|
||||
static std::string InsertColumnsRaw()
|
||||
{
|
||||
std::vector<std::string> insert_columns;
|
||||
|
||||
for (auto &column : Columns()) {
|
||||
if (column == PrimaryKey()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
insert_columns.push_back(column);
|
||||
}
|
||||
|
||||
return std::string(Strings::Implode(", ", insert_columns));
|
||||
}
|
||||
|
||||
static std::string TableName()
|
||||
{
|
||||
return std::string("sharedbank");
|
||||
}
|
||||
|
||||
static std::string BaseSelect()
|
||||
{
|
||||
return fmt::format(
|
||||
"SELECT {} FROM {}",
|
||||
ColumnsRaw(),
|
||||
TableName()
|
||||
);
|
||||
}
|
||||
|
||||
static std::string BaseInsert()
|
||||
{
|
||||
return fmt::format(
|
||||
"INSERT INTO {} ({}) ",
|
||||
TableName(),
|
||||
InsertColumnsRaw()
|
||||
);
|
||||
}
|
||||
|
||||
static Sharedbank NewEntity()
|
||||
{
|
||||
Sharedbank entry{};
|
||||
|
||||
entry.acctid = 0;
|
||||
entry.slotid = 0;
|
||||
entry.itemid = 0;
|
||||
entry.charges = 0;
|
||||
entry.augslot1 = 0;
|
||||
entry.augslot2 = 0;
|
||||
entry.augslot3 = 0;
|
||||
entry.augslot4 = 0;
|
||||
entry.augslot5 = 0;
|
||||
entry.augslot6 = 0;
|
||||
entry.custom_data = 0;
|
||||
|
||||
return entry;
|
||||
}
|
||||
|
||||
static Sharedbank GetSharedbankEntry(
|
||||
const std::vector<Sharedbank> &sharedbanks,
|
||||
int sharedbank_id
|
||||
)
|
||||
{
|
||||
for (auto &sharedbank : sharedbanks) {
|
||||
if (sharedbank. == sharedbank_id) {
|
||||
return sharedbank;
|
||||
}
|
||||
}
|
||||
|
||||
return NewEntity();
|
||||
}
|
||||
|
||||
static Sharedbank FindOne(
|
||||
int sharedbank_id
|
||||
)
|
||||
{
|
||||
auto results = database.QueryDatabase(
|
||||
fmt::format(
|
||||
"{} WHERE id = {} LIMIT 1",
|
||||
BaseSelect(),
|
||||
sharedbank_id
|
||||
)
|
||||
);
|
||||
|
||||
auto row = results.begin();
|
||||
if (results.RowCount() == 1) {
|
||||
Sharedbank entry{};
|
||||
|
||||
entry.acctid = atoi(row[0]);
|
||||
entry.slotid = atoi(row[1]);
|
||||
entry.itemid = atoi(row[2]);
|
||||
entry.charges = atoi(row[3]);
|
||||
entry.augslot1 = atoi(row[4]);
|
||||
entry.augslot2 = atoi(row[5]);
|
||||
entry.augslot3 = atoi(row[6]);
|
||||
entry.augslot4 = atoi(row[7]);
|
||||
entry.augslot5 = atoi(row[8]);
|
||||
entry.augslot6 = atoi(row[9]);
|
||||
entry.custom_data = row[10];
|
||||
|
||||
return entry;
|
||||
}
|
||||
|
||||
return NewEntity();
|
||||
}
|
||||
|
||||
static int DeleteOne(
|
||||
int sharedbank_id
|
||||
)
|
||||
{
|
||||
auto results = database.QueryDatabase(
|
||||
fmt::format(
|
||||
"DELETE FROM {} WHERE {} = {}",
|
||||
TableName(),
|
||||
PrimaryKey(),
|
||||
sharedbank_id
|
||||
)
|
||||
);
|
||||
|
||||
return (results.Success() ? results.RowsAffected() : 0);
|
||||
}
|
||||
|
||||
static int UpdateOne(
|
||||
Sharedbank sharedbank_entry
|
||||
)
|
||||
{
|
||||
std::vector<std::string> update_values;
|
||||
|
||||
auto columns = Columns();
|
||||
|
||||
update_values.push_back(columns[0] + " = " + std::to_string(sharedbank_entry.acctid));
|
||||
update_values.push_back(columns[1] + " = " + std::to_string(sharedbank_entry.slotid));
|
||||
update_values.push_back(columns[2] + " = " + std::to_string(sharedbank_entry.itemid));
|
||||
update_values.push_back(columns[3] + " = " + std::to_string(sharedbank_entry.charges));
|
||||
update_values.push_back(columns[4] + " = " + std::to_string(sharedbank_entry.augslot1));
|
||||
update_values.push_back(columns[5] + " = " + std::to_string(sharedbank_entry.augslot2));
|
||||
update_values.push_back(columns[6] + " = " + std::to_string(sharedbank_entry.augslot3));
|
||||
update_values.push_back(columns[7] + " = " + std::to_string(sharedbank_entry.augslot4));
|
||||
update_values.push_back(columns[8] + " = " + std::to_string(sharedbank_entry.augslot5));
|
||||
update_values.push_back(columns[9] + " = " + std::to_string(sharedbank_entry.augslot6));
|
||||
update_values.push_back(columns[10] + " = '" + Strings::Escape(sharedbank_entry.custom_data) + "'");
|
||||
|
||||
auto results = database.QueryDatabase(
|
||||
fmt::format(
|
||||
"UPDATE {} SET {} WHERE {} = {}",
|
||||
TableName(),
|
||||
Strings::Implode(", ", update_values),
|
||||
PrimaryKey(),
|
||||
sharedbank_entry.
|
||||
)
|
||||
);
|
||||
|
||||
return (results.Success() ? results.RowsAffected() : 0);
|
||||
}
|
||||
|
||||
static Sharedbank InsertOne(
|
||||
Sharedbank sharedbank_entry
|
||||
)
|
||||
{
|
||||
std::vector<std::string> insert_values;
|
||||
|
||||
insert_values.push_back(std::to_string(sharedbank_entry.acctid));
|
||||
insert_values.push_back(std::to_string(sharedbank_entry.slotid));
|
||||
insert_values.push_back(std::to_string(sharedbank_entry.itemid));
|
||||
insert_values.push_back(std::to_string(sharedbank_entry.charges));
|
||||
insert_values.push_back(std::to_string(sharedbank_entry.augslot1));
|
||||
insert_values.push_back(std::to_string(sharedbank_entry.augslot2));
|
||||
insert_values.push_back(std::to_string(sharedbank_entry.augslot3));
|
||||
insert_values.push_back(std::to_string(sharedbank_entry.augslot4));
|
||||
insert_values.push_back(std::to_string(sharedbank_entry.augslot5));
|
||||
insert_values.push_back(std::to_string(sharedbank_entry.augslot6));
|
||||
insert_values.push_back("'" + Strings::Escape(sharedbank_entry.custom_data) + "'");
|
||||
|
||||
auto results = database.QueryDatabase(
|
||||
fmt::format(
|
||||
"{} VALUES ({})",
|
||||
BaseInsert(),
|
||||
Strings::Implode(",", insert_values)
|
||||
)
|
||||
);
|
||||
|
||||
if (results.Success()) {
|
||||
sharedbank_entry.id = results.LastInsertedID();
|
||||
return sharedbank_entry;
|
||||
}
|
||||
|
||||
sharedbank_entry = InstanceListRepository::NewEntity();
|
||||
|
||||
return sharedbank_entry;
|
||||
}
|
||||
|
||||
static int InsertMany(
|
||||
std::vector<Sharedbank> sharedbank_entries
|
||||
)
|
||||
{
|
||||
std::vector<std::string> insert_chunks;
|
||||
|
||||
for (auto &sharedbank_entry: sharedbank_entries) {
|
||||
std::vector<std::string> insert_values;
|
||||
|
||||
insert_values.push_back(std::to_string(sharedbank_entry.acctid));
|
||||
insert_values.push_back(std::to_string(sharedbank_entry.slotid));
|
||||
insert_values.push_back(std::to_string(sharedbank_entry.itemid));
|
||||
insert_values.push_back(std::to_string(sharedbank_entry.charges));
|
||||
insert_values.push_back(std::to_string(sharedbank_entry.augslot1));
|
||||
insert_values.push_back(std::to_string(sharedbank_entry.augslot2));
|
||||
insert_values.push_back(std::to_string(sharedbank_entry.augslot3));
|
||||
insert_values.push_back(std::to_string(sharedbank_entry.augslot4));
|
||||
insert_values.push_back(std::to_string(sharedbank_entry.augslot5));
|
||||
insert_values.push_back(std::to_string(sharedbank_entry.augslot6));
|
||||
insert_values.push_back("'" + Strings::Escape(sharedbank_entry.custom_data) + "'");
|
||||
|
||||
insert_chunks.push_back("(" + Strings::Implode(",", insert_values) + ")");
|
||||
}
|
||||
|
||||
std::vector<std::string> insert_values;
|
||||
|
||||
auto results = database.QueryDatabase(
|
||||
fmt::format(
|
||||
"{} VALUES {}",
|
||||
BaseInsert(),
|
||||
Strings::Implode(",", insert_chunks)
|
||||
)
|
||||
);
|
||||
|
||||
return (results.Success() ? results.RowsAffected() : 0);
|
||||
}
|
||||
|
||||
static std::vector<Sharedbank> All()
|
||||
{
|
||||
std::vector<Sharedbank> all_entries;
|
||||
|
||||
auto results = database.QueryDatabase(
|
||||
fmt::format(
|
||||
"{}",
|
||||
BaseSelect()
|
||||
)
|
||||
);
|
||||
|
||||
all_entries.reserve(results.RowCount());
|
||||
|
||||
for (auto row = results.begin(); row != results.end(); ++row) {
|
||||
Sharedbank entry{};
|
||||
|
||||
entry.acctid = atoi(row[0]);
|
||||
entry.slotid = atoi(row[1]);
|
||||
entry.itemid = atoi(row[2]);
|
||||
entry.charges = atoi(row[3]);
|
||||
entry.augslot1 = atoi(row[4]);
|
||||
entry.augslot2 = atoi(row[5]);
|
||||
entry.augslot3 = atoi(row[6]);
|
||||
entry.augslot4 = atoi(row[7]);
|
||||
entry.augslot5 = atoi(row[8]);
|
||||
entry.augslot6 = atoi(row[9]);
|
||||
entry.custom_data = row[10];
|
||||
|
||||
all_entries.push_back(entry);
|
||||
}
|
||||
|
||||
return all_entries;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
|
||||
@@ -28,11 +28,6 @@ public:
|
||||
std::vector<DistinctTraders_Struct> traders{};
|
||||
};
|
||||
|
||||
struct BazaarTraderSearch_Struct {
|
||||
Trader trader;
|
||||
std::string trader_name;
|
||||
};
|
||||
|
||||
struct WelcomeData_Struct {
|
||||
uint32 count_of_traders;
|
||||
uint32 count_of_items;
|
||||
@@ -270,54 +265,6 @@ public:
|
||||
|
||||
return trader;
|
||||
}
|
||||
|
||||
static std::vector<BazaarTraderSearch_Struct> GetBazaarTraderDetails(
|
||||
Database &db,
|
||||
std::string &search_criteria_trader
|
||||
)
|
||||
{
|
||||
std::vector<BazaarTraderSearch_Struct> all_entries{};
|
||||
|
||||
auto query = fmt::format(
|
||||
"SELECT trader.*, c.`name` FROM `trader` INNER JOIN character_data AS c ON trader.char_id = c.id "
|
||||
"WHERE {} ORDER BY trader.char_id ASC",
|
||||
search_criteria_trader
|
||||
);
|
||||
|
||||
auto results = db.QueryDatabase(query);
|
||||
|
||||
if (results.RowCount() == 0) {
|
||||
return all_entries;
|
||||
}
|
||||
|
||||
all_entries.reserve(results.RowCount());
|
||||
for (auto row = results.begin(); row != results.end(); ++row) {
|
||||
BazaarTraderSearch_Struct e{};
|
||||
|
||||
e.trader.id = row[0] ? strtoull(row[0], nullptr, 10) : 0;
|
||||
e.trader.char_id = row[1] ? static_cast<uint32_t>(strtoul(row[1], nullptr, 10)) : 0;
|
||||
e.trader.item_id = row[2] ? static_cast<uint32_t>(strtoul(row[2], nullptr, 10)) : 0;
|
||||
e.trader.aug_slot_1 = row[3] ? static_cast<uint32_t>(strtoul(row[3], nullptr, 10)) : 0;
|
||||
e.trader.aug_slot_2 = row[4] ? static_cast<uint32_t>(strtoul(row[4], nullptr, 10)) : 0;
|
||||
e.trader.aug_slot_3 = row[5] ? static_cast<uint32_t>(strtoul(row[5], nullptr, 10)) : 0;
|
||||
e.trader.aug_slot_4 = row[6] ? static_cast<uint32_t>(strtoul(row[6], nullptr, 10)) : 0;
|
||||
e.trader.aug_slot_5 = row[7] ? static_cast<uint32_t>(strtoul(row[7], nullptr, 10)) : 0;
|
||||
e.trader.aug_slot_6 = row[8] ? static_cast<uint32_t>(strtoul(row[8], nullptr, 10)) : 0;
|
||||
e.trader.item_sn = row[9] ? static_cast<uint32_t>(strtoul(row[9], nullptr, 10)) : 0;
|
||||
e.trader.item_charges = row[10] ? static_cast<int32_t>(atoi(row[10])) : 0;
|
||||
e.trader.item_cost = row[11] ? static_cast<uint32_t>(strtoul(row[11], nullptr, 10)) : 0;
|
||||
e.trader.slot_id = row[12] ? static_cast<uint8_t>(strtoul(row[12], nullptr, 10)) : 0;
|
||||
e.trader.char_entity_id = row[13] ? static_cast<uint32_t>(strtoul(row[13], nullptr, 10)) : 0;
|
||||
e.trader.char_zone_id = row[14] ? static_cast<uint32_t>(strtoul(row[14], nullptr, 10)) : 0;
|
||||
e.trader.char_zone_instance_id = row[15] ? static_cast<int32_t>(atoi(row[15])) : 0;
|
||||
e.trader.active_transaction = row[16] ? static_cast<uint8_t>(strtoul(row[16], nullptr, 10)) : 0;
|
||||
e.trader_name = row[17] ? row[17] : std::string("");
|
||||
|
||||
all_entries.push_back(e);
|
||||
}
|
||||
|
||||
return all_entries;
|
||||
}
|
||||
};
|
||||
|
||||
#endif //EQEMU_TRADER_REPOSITORY_H
|
||||
|
||||
+1
-1
@@ -339,7 +339,7 @@ RULE_STRING(World, MOTD, "", "Server MOTD sent on login, change from empty to ha
|
||||
RULE_STRING(World, Rules, "", "Server Rules, change from empty to have this be used instead of variables table 'rules' value, lines are pipe (|) separated, example: A|B|C")
|
||||
RULE_BOOL(World, EnableAutoLogin, false, "Enables or disables auto login of characters, allowing people to log characters in directly from loginserver to ingame")
|
||||
RULE_BOOL(World, EnablePVPRegions, true, "Enables or disables PVP Regions automatically setting your PVP flag")
|
||||
RULE_STRING(World, SupportedClients, "RoF2", "Comma-delimited list of clients to restrict to. Supported values are Titanium | SoF | SoD | UF | RoF | RoF2. Example: Titanium,RoF2")
|
||||
RULE_STRING(World, SupportedClients, "", "Comma-delimited list of clients to restrict to. Supported values are Titanium | SoF | SoD | UF | RoF | RoF2. Example: Titanium,RoF2")
|
||||
RULE_STRING(World, CustomFilesKey, "", "Enable if the server requires custom files and sends a key to validate. Empty string to disable. Example: eqcustom_v1")
|
||||
RULE_STRING(World, CustomFilesUrl, "github.com/knervous/eqnexus/releases", "URL to display at character select if client is missing custom files")
|
||||
RULE_INT(World, CustomFilesAdminLevel, 20, "Admin level at which custom file key is not required when CustomFilesKey is specified")
|
||||
|
||||
+385
-297
@@ -50,7 +50,6 @@
|
||||
#include "repositories/skill_caps_repository.h"
|
||||
#include "repositories/inventory_repository.h"
|
||||
#include "repositories/books_repository.h"
|
||||
#include "repositories/sharedbank_repository.h"
|
||||
|
||||
namespace ItemField
|
||||
{
|
||||
@@ -193,268 +192,242 @@ SharedDatabase::MailKeys SharedDatabase::GetMailKey(int character_id)
|
||||
return MailKeys{};
|
||||
}
|
||||
|
||||
bool SharedDatabase::SaveCursor(
|
||||
uint32 char_id,
|
||||
std::list<EQ::ItemInstance*>::const_iterator& start,
|
||||
std::list<EQ::ItemInstance*>::const_iterator& end
|
||||
)
|
||||
bool SharedDatabase::SaveCursor(uint32 char_id, std::list<EQ::ItemInstance*>::const_iterator &start, std::list<EQ::ItemInstance*>::const_iterator &end)
|
||||
{
|
||||
const int deleted = InventoryRepository::DeleteWhere(
|
||||
*this,
|
||||
fmt::format(
|
||||
"`character_id` = {} AND (`slot_id` = {} OR `slot_id` BETWEEN {} AND {})",
|
||||
char_id,
|
||||
EQ::invslot::slotCursor,
|
||||
EQ::invbag::CURSOR_BAG_BEGIN,
|
||||
EQ::invbag::CURSOR_BAG_END
|
||||
)
|
||||
);
|
||||
// Delete cursor items
|
||||
const std::string query = StringFormat("DELETE FROM inventory WHERE charid = %i "
|
||||
"AND ((slotid >= 8000 AND slotid <= 8999) "
|
||||
"OR slotid = %i OR (slotid >= %i AND slotid <= %i) )",
|
||||
char_id, EQ::invslot::slotCursor,
|
||||
EQ::invbag::CURSOR_BAG_BEGIN, EQ::invbag::CURSOR_BAG_END);
|
||||
const auto results = QueryDatabase(query);
|
||||
if (!results.Success()) {
|
||||
std::cout << "Clearing cursor failed: " << results.ErrorMessage() << std::endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
int16 i = EQ::invslot::slotCursor;
|
||||
for (auto& it = start; it != end; ++it, i++) {
|
||||
// shouldn't be anything in the queue that indexes this high
|
||||
if (i > EQ::invbag::CURSOR_BAG_END) {
|
||||
break;
|
||||
}
|
||||
|
||||
const EQ::ItemInstance* inst = *it;
|
||||
const int16 use_slot = i == EQ::invslot::slotCursor ? EQ::invslot::slotCursor : i;
|
||||
int i = 8000;
|
||||
for(auto& it = start; it != end; ++it, i++) {
|
||||
if (i > 8999) { break; } // shouldn't be anything in the queue that indexes this high
|
||||
const EQ::ItemInstance *inst = *it;
|
||||
const int16 use_slot = (i == 8000) ? EQ::invslot::slotCursor : i;
|
||||
if (!SaveInventory(char_id, inst, use_slot)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool SharedDatabase::VerifyInventory(uint32 account_id, int16 slot_id, const EQ::ItemInstance* inst)
|
||||
{
|
||||
if (!inst || !inst->GetItem()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
const auto& l = SharedbankRepository::GetWhere(
|
||||
*this,
|
||||
fmt::format(
|
||||
"`account_id` = {} AND `slot_id` = {} LIMIT 1",
|
||||
account_id,
|
||||
slot_id
|
||||
)
|
||||
);
|
||||
|
||||
if (l.empty()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
const auto& e = l.front();
|
||||
|
||||
uint16 expect_charges = inst->GetCharges() >= 0 ? inst->GetCharges() : std::numeric_limits<int16>::max();
|
||||
|
||||
return e.item_id == inst->GetID() && e.charges == expect_charges;
|
||||
}
|
||||
|
||||
bool SharedDatabase::SaveInventory(uint32 char_id, const EQ::ItemInstance* inst, int16 slot_id)
|
||||
{
|
||||
// Don't save any Tribute slots
|
||||
if (
|
||||
EQ::ValueWithin(slot_id, EQ::invslot::GUILD_TRIBUTE_BEGIN, EQ::invslot::GUILD_TRIBUTE_END) ||
|
||||
EQ::ValueWithin(slot_id, EQ::invslot::TRIBUTE_BEGIN, EQ::invslot::TRIBUTE_END)
|
||||
) {
|
||||
// Delete cursor items
|
||||
const std::string query = StringFormat("SELECT itemid, charges FROM sharedbank "
|
||||
"WHERE acctid = %d AND slotid = %d",
|
||||
account_id, slot_id);
|
||||
auto results = QueryDatabase(query);
|
||||
if (!results.Success()) {
|
||||
//returning true is less harmful in the face of a query error
|
||||
return true;
|
||||
}
|
||||
|
||||
if (
|
||||
EQ::ValueWithin(slot_id, EQ::invslot::SHARED_BANK_BEGIN, EQ::invslot::SHARED_BANK_END) ||
|
||||
EQ::ValueWithin(slot_id, EQ::invbag::SHARED_BANK_BAGS_BEGIN, EQ::invbag::SHARED_BANK_BAGS_END)
|
||||
) {
|
||||
if (results.RowCount() == 0)
|
||||
return false;
|
||||
|
||||
auto& row = results.begin();
|
||||
|
||||
const uint32 id = Strings::ToUnsignedInt(row[0]);
|
||||
const uint16 charges = Strings::ToUnsignedInt(row[1]);
|
||||
|
||||
uint16 expect_charges;
|
||||
|
||||
if(inst->GetCharges() >= 0)
|
||||
expect_charges = inst->GetCharges();
|
||||
else
|
||||
expect_charges = 0x7FFF;
|
||||
|
||||
if(id != inst->GetItem()->ID || charges != expect_charges)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool SharedDatabase::SaveInventory(uint32 char_id, const EQ::ItemInstance* inst, int16 slot_id) {
|
||||
|
||||
//never save tribute slots:
|
||||
if (slot_id >= EQ::invslot::TRIBUTE_BEGIN && slot_id <= EQ::invslot::TRIBUTE_END)
|
||||
return true;
|
||||
if (slot_id >= EQ::invslot::GUILD_TRIBUTE_BEGIN && slot_id <= EQ::invslot::GUILD_TRIBUTE_END)
|
||||
return true;
|
||||
|
||||
if (slot_id >= EQ::invslot::SHARED_BANK_BEGIN && slot_id <= EQ::invbag::SHARED_BANK_BAGS_END) {
|
||||
// Shared bank inventory
|
||||
if (!inst) {
|
||||
return DeleteSharedBankSlot(char_id, slot_id);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
// Needed to clear out bag slots that 'REPLACE' in UpdateSharedBankSlot does not overwrite..otherwise, duplication occurs
|
||||
// (This requires that parent then child items be sent..which should be how they are currently passed)
|
||||
if (EQ::InventoryProfile::SupportsContainers(slot_id)) {
|
||||
if (EQ::InventoryProfile::SupportsContainers(slot_id))
|
||||
DeleteSharedBankSlot(char_id, slot_id);
|
||||
}
|
||||
|
||||
return UpdateSharedBankSlot(char_id, inst, slot_id);
|
||||
}
|
||||
} else if (!inst) { // All other inventory
|
||||
}
|
||||
else if (!inst) { // All other inventory
|
||||
return DeleteInventorySlot(char_id, slot_id);
|
||||
}
|
||||
|
||||
// Needed to clear out bag slots that 'REPLACE' in UpdateInventorySlot does not overwrite..otherwise, duplication occurs
|
||||
// (This requires that parent then child items be sent..which should be how they are currently passed)
|
||||
if (EQ::InventoryProfile::SupportsContainers(slot_id)) {
|
||||
if (EQ::InventoryProfile::SupportsContainers(slot_id))
|
||||
DeleteInventorySlot(char_id, slot_id);
|
||||
}
|
||||
|
||||
return UpdateInventorySlot(char_id, inst, slot_id);
|
||||
return UpdateInventorySlot(char_id, inst, slot_id);
|
||||
}
|
||||
|
||||
bool SharedDatabase::UpdateInventorySlot(uint32 char_id, const EQ::ItemInstance* inst, int16 slot_id)
|
||||
{
|
||||
if (!inst || !inst->GetItem()) {
|
||||
return false;
|
||||
}
|
||||
bool SharedDatabase::UpdateInventorySlot(uint32 char_id, const EQ::ItemInstance* inst, int16 slot_id) {
|
||||
// need to check 'inst' argument for valid pointer
|
||||
|
||||
std::vector<uint32> augment_ids = inst->GetAugmentIDs();
|
||||
|
||||
uint16 charges = inst->GetCharges() >= 0 ? inst->GetCharges() : std::numeric_limits<int16>::max();
|
||||
|
||||
auto e = InventoryRepository::NewEntity();
|
||||
|
||||
e.character_id = char_id;
|
||||
e.slot_id = slot_id;
|
||||
e.item_id = inst->GetID();
|
||||
e.charges = charges;
|
||||
e.color = inst->GetColor();
|
||||
e.augment_one = augment_ids[0];
|
||||
e.augment_two = augment_ids[1];
|
||||
e.augment_three = augment_ids[2];
|
||||
e.augment_four = augment_ids[3];
|
||||
e.augment_five = augment_ids[4];
|
||||
e.augment_six = augment_ids[5];
|
||||
e.instnodrop = inst->IsAttuned() ? 1 : 0;
|
||||
e.custom_data = inst->GetCustomDataString();
|
||||
e.ornament_icon = inst->GetOrnamentationIcon();
|
||||
e.ornament_idfile = inst->GetOrnamentationIDFile();
|
||||
e.ornament_hero_model = inst->GetOrnamentHeroModel();
|
||||
e.guid = inst->GetSerialNumber();
|
||||
|
||||
const int replaced = InventoryRepository::ReplaceOne(*this, e);
|
||||
|
||||
// Save bag contents, if slot supports bag contents
|
||||
if (inst->IsClassBag() && EQ::InventoryProfile::SupportsContainers(slot_id)) {
|
||||
// Limiting to bag slot count will get rid of 'hidden' duplicated items and 'Invalid Slot ID'
|
||||
// messages through attrition (and the modded code in SaveInventory)
|
||||
for (
|
||||
uint8 i = EQ::invbag::SLOT_BEGIN;
|
||||
i < inst->GetItem()->BagSlots && i <= EQ::invbag::SLOT_END;
|
||||
i++
|
||||
) {
|
||||
const EQ::ItemInstance* bag_inst = inst->GetItem(i);
|
||||
SaveInventory(char_id, bag_inst, EQ::InventoryProfile::CalcSlotId(slot_id, i));
|
||||
uint32 augslot[EQ::invaug::SOCKET_COUNT] = { 0, 0, 0, 0, 0, 0 };
|
||||
if (inst->IsClassCommon()) {
|
||||
for (int i = EQ::invaug::SOCKET_BEGIN; i <= EQ::invaug::SOCKET_END; i++) {
|
||||
const EQ::ItemInstance *auginst = inst->GetItem(i);
|
||||
augslot[i] = (auginst && auginst->GetItem()) ? auginst->GetItem()->ID : 0;
|
||||
}
|
||||
}
|
||||
|
||||
return replaced;
|
||||
uint16 charges;
|
||||
if(inst->GetCharges() >= 0)
|
||||
charges = inst->GetCharges();
|
||||
else
|
||||
charges = 0x7FFF;
|
||||
|
||||
// Update/Insert item
|
||||
const std::string query = StringFormat("REPLACE INTO inventory "
|
||||
"(charid, slotid, itemid, charges, instnodrop, custom_data, color, "
|
||||
"augslot1, augslot2, augslot3, augslot4, augslot5, augslot6, ornamenticon, ornamentidfile, ornament_hero_model, guid) "
|
||||
"VALUES( %lu, %lu, %lu, %lu, %lu, '%s', %lu, "
|
||||
"%lu, %lu, %lu, %lu, %lu, %lu, %lu, %lu, %lu, %lu)",
|
||||
static_cast<unsigned long>(char_id), static_cast<unsigned long>(slot_id), static_cast<unsigned long>(inst->GetItem()->ID),
|
||||
static_cast<unsigned long>(charges), static_cast<unsigned long>(inst->IsAttuned() ? 1 : 0),
|
||||
inst->GetCustomDataString().c_str(), static_cast<unsigned long>(inst->GetColor()),
|
||||
static_cast<unsigned long>(augslot[0]), static_cast<unsigned long>(augslot[1]), static_cast<unsigned long>(augslot[2]),
|
||||
static_cast<unsigned long>(augslot[3]), static_cast<unsigned long>(augslot[4]), static_cast<unsigned long>(augslot[5]), static_cast<unsigned long>(inst->GetOrnamentationIcon()),
|
||||
static_cast<unsigned long>(inst->GetOrnamentationIDFile()), static_cast<unsigned long>(inst->GetOrnamentHeroModel()), inst->GetSerialNumber());
|
||||
const auto results = QueryDatabase(query);
|
||||
|
||||
// Save bag contents, if slot supports bag contents
|
||||
if (inst->IsClassBag() && EQ::InventoryProfile::SupportsContainers(slot_id))
|
||||
// Limiting to bag slot count will get rid of 'hidden' duplicated items and 'Invalid Slot ID'
|
||||
// messages through attrition (and the modded code in SaveInventory)
|
||||
for (uint8 idx = EQ::invbag::SLOT_BEGIN; idx < inst->GetItem()->BagSlots && idx <= EQ::invbag::SLOT_END; idx++) {
|
||||
const EQ::ItemInstance* baginst = inst->GetItem(idx);
|
||||
SaveInventory(char_id, baginst, EQ::InventoryProfile::CalcSlotId(slot_id, idx));
|
||||
}
|
||||
|
||||
if (!results.Success()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool SharedDatabase::UpdateSharedBankSlot(uint32 char_id, const EQ::ItemInstance* inst, int16 slot_id)
|
||||
{
|
||||
if (!inst || !inst->GetItem()) {
|
||||
return false;
|
||||
bool SharedDatabase::UpdateSharedBankSlot(uint32 char_id, const EQ::ItemInstance* inst, int16 slot_id) {
|
||||
// need to check 'inst' argument for valid pointer
|
||||
|
||||
uint32 augslot[EQ::invaug::SOCKET_COUNT] = { 0, 0, 0, 0, 0, 0 };
|
||||
if (inst->IsClassCommon()) {
|
||||
for (int i = EQ::invaug::SOCKET_BEGIN; i <= EQ::invaug::SOCKET_END; i++) {
|
||||
const EQ::ItemInstance *auginst = inst->GetItem(i);
|
||||
augslot[i] = (auginst && auginst->GetItem()) ? auginst->GetItem()->ID : 0;
|
||||
}
|
||||
}
|
||||
|
||||
std::vector<uint32> augment_ids = inst->GetAugmentIDs();
|
||||
|
||||
uint16 charges = inst->GetCharges() >= 0 ? inst->GetCharges() : std::numeric_limits<int16>::max();
|
||||
|
||||
// Update/Insert item
|
||||
const uint32 account_id = GetAccountIDByChar(char_id);
|
||||
uint16 charges;
|
||||
if(inst->GetCharges() >= 0)
|
||||
charges = inst->GetCharges();
|
||||
else
|
||||
charges = 0x7FFF;
|
||||
|
||||
auto e = SharedbankRepository::NewEntity();
|
||||
const std::string query = StringFormat("REPLACE INTO sharedbank "
|
||||
"(acctid, slotid, itemid, charges, custom_data, "
|
||||
"augslot1, augslot2, augslot3, augslot4, augslot5, augslot6) "
|
||||
"VALUES( %lu, %lu, %lu, %lu, '%s', "
|
||||
"%lu, %lu, %lu, %lu, %lu, %lu)",
|
||||
static_cast<unsigned long>(account_id), static_cast<unsigned long>(slot_id), static_cast<unsigned long>(inst->GetItem()->ID),
|
||||
static_cast<unsigned long>(charges), inst->GetCustomDataString().c_str(), static_cast<unsigned long>(augslot[0]),
|
||||
static_cast<unsigned long>(augslot[1]), static_cast<unsigned long>(augslot[2]), static_cast<unsigned long>(augslot[3]), static_cast<unsigned long>(augslot[4]),
|
||||
static_cast<unsigned long>(augslot[5]));
|
||||
const auto results = QueryDatabase(query);
|
||||
|
||||
e.account_id = account_id;
|
||||
e.slot_id = slot_id;
|
||||
e.item_id = inst->GetID();
|
||||
e.charges = charges;
|
||||
e.color = inst->GetColor();
|
||||
e.augment_one = augment_ids[0];
|
||||
e.augment_two = augment_ids[1];
|
||||
e.augment_three = augment_ids[2];
|
||||
e.augment_four = augment_ids[3];
|
||||
e.augment_five = augment_ids[4];
|
||||
e.augment_six = augment_ids[5];
|
||||
e.custom_data = inst->GetCustomDataString();
|
||||
e.ornament_icon = inst->GetOrnamentationIcon();
|
||||
e.ornament_idfile = inst->GetOrnamentationIDFile();
|
||||
e.ornament_hero_model = inst->GetOrnamentHeroModel();
|
||||
e.guid = inst->GetSerialNumber();
|
||||
|
||||
const int replaced = SharedbankRepository::ReplaceOne(*this, e);
|
||||
|
||||
// Save bag contents, if slot supports bag contents
|
||||
// Save bag contents, if slot supports bag contents
|
||||
if (inst->IsClassBag() && EQ::InventoryProfile::SupportsContainers(slot_id)) {
|
||||
// Limiting to bag slot count will get rid of 'hidden' duplicated items and 'Invalid Slot ID'
|
||||
// messages through attrition (and the modded code in SaveInventory)
|
||||
for (
|
||||
uint8 i = EQ::invbag::SLOT_BEGIN;
|
||||
i < inst->GetItem()->BagSlots && i <= EQ::invbag::SLOT_END;
|
||||
i++
|
||||
) {
|
||||
const EQ::ItemInstance* bag_inst = inst->GetItem(i);
|
||||
SaveInventory(char_id, bag_inst, EQ::InventoryProfile::CalcSlotId(slot_id, i));
|
||||
for (uint8 idx = EQ::invbag::SLOT_BEGIN; idx < inst->GetItem()->BagSlots && idx <= EQ::invbag::SLOT_END; idx++) {
|
||||
const EQ::ItemInstance* baginst = inst->GetItem(idx);
|
||||
SaveInventory(char_id, baginst, EQ::InventoryProfile::CalcSlotId(slot_id, idx));
|
||||
}
|
||||
}
|
||||
|
||||
return replaced;
|
||||
if (!results.Success()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool SharedDatabase::DeleteInventorySlot(uint32 char_id, int16 slot_id)
|
||||
{
|
||||
const int deleted = InventoryRepository::DeleteWhere(
|
||||
*this,
|
||||
fmt::format(
|
||||
"`character_id` = {} AND `slot_id` = {}",
|
||||
char_id,
|
||||
slot_id
|
||||
)
|
||||
);
|
||||
bool SharedDatabase::DeleteInventorySlot(uint32 char_id, int16 slot_id) {
|
||||
|
||||
if (!deleted) {
|
||||
return false;
|
||||
}
|
||||
// Delete item
|
||||
std::string query = StringFormat("DELETE FROM inventory WHERE charid = %i AND slotid = %i", char_id, slot_id);
|
||||
auto results = QueryDatabase(query);
|
||||
if (!results.Success()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Delete bag slots, if need be
|
||||
if (!EQ::InventoryProfile::SupportsContainers(slot_id))
|
||||
return true;
|
||||
|
||||
const int16 base_slot_id = EQ::InventoryProfile::CalcSlotId(slot_id, EQ::invbag::SLOT_BEGIN);
|
||||
query = StringFormat("DELETE FROM inventory WHERE charid = %i AND slotid >= %i AND slotid < %i",
|
||||
char_id, base_slot_id, (base_slot_id+10));
|
||||
results = QueryDatabase(query);
|
||||
if (!results.Success()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// @merth: need to delete augments here
|
||||
return true;
|
||||
}
|
||||
|
||||
bool SharedDatabase::DeleteSharedBankSlot(uint32 char_id, int16 slot_id) {
|
||||
|
||||
// Delete item
|
||||
const uint32 account_id = GetAccountIDByChar(char_id);
|
||||
std::string query = StringFormat("DELETE FROM sharedbank WHERE acctid=%i AND slotid=%i", account_id, slot_id);
|
||||
auto results = QueryDatabase(query);
|
||||
if (!results.Success()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Delete bag slots, if need be
|
||||
if (!EQ::InventoryProfile::SupportsContainers(slot_id)) {
|
||||
return true;
|
||||
}
|
||||
if (!EQ::InventoryProfile::SupportsContainers(slot_id))
|
||||
return true;
|
||||
|
||||
const int16 base_slot_id = EQ::InventoryProfile::CalcSlotId(slot_id, EQ::invbag::SLOT_BEGIN);
|
||||
const int16 base_slot_id = EQ::InventoryProfile::CalcSlotId(slot_id, EQ::invbag::SLOT_BEGIN);
|
||||
query = StringFormat("DELETE FROM sharedbank WHERE acctid = %i "
|
||||
"AND slotid >= %i AND slotid < %i",
|
||||
account_id, base_slot_id, (base_slot_id+10));
|
||||
results = QueryDatabase(query);
|
||||
if (!results.Success()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return InventoryRepository::DeleteWhere(
|
||||
*this,
|
||||
fmt::format(
|
||||
"`character_id` = {} AND `slot_id` BETWEEN {} AND {}",
|
||||
char_id,
|
||||
base_slot_id,
|
||||
base_slot_id + (EQ::invbag::SLOT_COUNT - 1)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
bool SharedDatabase::DeleteSharedBankSlot(uint32 char_id, int16 slot_id)
|
||||
{
|
||||
const uint32 account_id = GetAccountIDByChar(char_id);
|
||||
|
||||
const int deleted = SharedbankRepository::DeleteWhere(
|
||||
*this,
|
||||
fmt::format(
|
||||
"`account_id` = {} AND `slot_id` = {}",
|
||||
account_id,
|
||||
slot_id
|
||||
)
|
||||
);
|
||||
|
||||
if (!deleted) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!EQ::InventoryProfile::SupportsContainers(slot_id)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
const int16 base_slot_id = EQ::InventoryProfile::CalcSlotId(slot_id, EQ::invbag::SLOT_BEGIN);
|
||||
|
||||
return SharedbankRepository::DeleteWhere(
|
||||
*this,
|
||||
fmt::format(
|
||||
"`account_id` = {} AND `slot_id` BETWEEN {} AND {}",
|
||||
account_id,
|
||||
base_slot_id,
|
||||
base_slot_id + (EQ::invbag::SLOT_COUNT - 1)
|
||||
)
|
||||
);
|
||||
// @merth: need to delete augments here
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -579,81 +552,96 @@ bool SharedDatabase::SetStartingItems(
|
||||
// Retrieve shared bank inventory based on either account or character
|
||||
bool SharedDatabase::GetSharedBank(uint32 id, EQ::InventoryProfile *inv, bool is_charid)
|
||||
{
|
||||
const uint32 account_id = is_charid ? GetAccountIDByChar(id) : id;
|
||||
std::string query;
|
||||
|
||||
if (!account_id) {
|
||||
if (is_charid) {
|
||||
query = fmt::format(
|
||||
"SELECT sb.slotid, sb.itemid, sb.charges, "
|
||||
"sb.augslot1, sb.augslot2, sb.augslot3, "
|
||||
"sb.augslot4, sb.augslot5, sb.augslot6, sb.custom_data "
|
||||
"FROM sharedbank sb INNER JOIN character_data ch "
|
||||
"ON ch.account_id = sb.acctid WHERE ch.id = {} ORDER BY sb.slotid",
|
||||
id
|
||||
);
|
||||
} else {
|
||||
query = fmt::format(
|
||||
"SELECT slotid, itemid, charges, "
|
||||
"augslot1, augslot2, augslot3, "
|
||||
"augslot4, augslot5, augslot6, custom_data "
|
||||
"FROM sharedbank WHERE acctid = {} ORDER BY slotid",
|
||||
id
|
||||
);
|
||||
}
|
||||
|
||||
auto results = QueryDatabase(query);
|
||||
// If we have no results we still need to return true
|
||||
if (!results.Success()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
const auto& l = SharedbankRepository::GetWhere(
|
||||
*this,
|
||||
fmt::format(
|
||||
"`account_id` = {}",
|
||||
account_id
|
||||
)
|
||||
);
|
||||
for (auto row : results) {
|
||||
int16 slot_id = static_cast<int16>(Strings::ToInt(row[0]));
|
||||
uint32 item_id = Strings::ToUnsignedInt(row[1]);
|
||||
const int16 charges = static_cast<int16>(Strings::ToInt(row[2]));
|
||||
|
||||
if (l.empty()) {
|
||||
return true;
|
||||
}
|
||||
uint32 aug[EQ::invaug::SOCKET_COUNT];
|
||||
aug[0] = Strings::ToUnsignedInt(row[3]);
|
||||
aug[1] = Strings::ToUnsignedInt(row[4]);
|
||||
aug[2] = Strings::ToUnsignedInt(row[5]);
|
||||
aug[3] = Strings::ToUnsignedInt(row[6]);
|
||||
aug[4] = Strings::ToUnsignedInt(row[7]);
|
||||
aug[5] = Strings::ToUnsignedInt(row[8]);
|
||||
|
||||
for (const auto& e : l) {
|
||||
uint32 augment_ids[EQ::invaug::SOCKET_COUNT] = {
|
||||
e.augment_one,
|
||||
e.augment_two,
|
||||
e.augment_three,
|
||||
e.augment_four,
|
||||
e.augment_five,
|
||||
e.augment_six
|
||||
};
|
||||
|
||||
const EQ::ItemData* item = GetItem(e.item_id);
|
||||
const EQ::ItemData *item = GetItem(item_id);
|
||||
|
||||
if (!item) {
|
||||
LogError(
|
||||
"Warning: {} [{}] has an invalid item_id [{}] in slot_id [{}]",
|
||||
is_charid ? "character_id" : "account_id",
|
||||
"Warning: [{}] [{}] has an invalid item_id [{}] in inventory slot [{}]",
|
||||
is_charid ? "charid" : "acctid",
|
||||
id,
|
||||
e.item_id,
|
||||
e.slot_id
|
||||
item_id,
|
||||
slot_id
|
||||
);
|
||||
continue;
|
||||
}
|
||||
|
||||
EQ::ItemInstance* inst = CreateBaseItem(item, e.charges);
|
||||
auto inst = CreateBaseItem(item, charges);
|
||||
if (!inst) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (item->IsClassCommon()) {
|
||||
if (inst && item->IsClassCommon()) {
|
||||
for (int i = EQ::invaug::SOCKET_BEGIN; i <= EQ::invaug::SOCKET_END; i++) {
|
||||
if (augment_ids[i]) {
|
||||
inst->PutAugment(this, i, augment_ids[i]);
|
||||
if (aug[i]) {
|
||||
inst->PutAugment(this, i, aug[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!e.custom_data.empty()) {
|
||||
inst->SetCustomDataString(e.custom_data);
|
||||
if (inst && row[9]) {
|
||||
std::string data_str(row[9]);
|
||||
inst->SetCustomDataString(data_str);
|
||||
}
|
||||
|
||||
const int16 put_slot_id = inv->PutItem(e.slot_id, *inst);
|
||||
// theoretically inst can be nullptr ... this would be very bad ...
|
||||
const int16 put_slot_id = inv->PutItem(slot_id, *inst);
|
||||
safe_delete(inst);
|
||||
|
||||
// Save ptr to item in inventory
|
||||
if (put_slot_id != INVALID_INDEX) {
|
||||
continue;
|
||||
}
|
||||
|
||||
LogError(
|
||||
"Warning: Invalid slot_id for item in shared bank inventory for {} [{}] item_id [{}] slot_id [{}]",
|
||||
is_charid ? "character_id" : "account_id",
|
||||
"Warning: Invalid slot_id for item in shared bank inventory: [{}]=[{}], item_id=[{}], slot_id=[{}]",
|
||||
is_charid ? "charid" : "acctid",
|
||||
id,
|
||||
e.item_id,
|
||||
e.slot_id
|
||||
item_id,
|
||||
slot_id
|
||||
);
|
||||
|
||||
if (is_charid) {
|
||||
SaveInventory(id, nullptr, e.slot_id);
|
||||
SaveInventory(id, nullptr, slot_id);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -671,7 +659,7 @@ bool SharedDatabase::GetInventory(Client *c)
|
||||
EQ::InventoryProfile &inv = c->GetInv();
|
||||
|
||||
// Retrieve character inventory
|
||||
auto results = InventoryRepository::GetWhere(*this, fmt::format("`character_id` = '{}' ORDER BY `slot_id`", char_id));
|
||||
auto results = InventoryRepository::GetWhere(*this, fmt::format("`charid` = '{}' ORDER BY `slotid`", char_id));
|
||||
auto e_results = CharacterEvolvingItemsRepository::GetWhere(
|
||||
*this, fmt::format("`character_id` = '{}' AND `deleted_at` IS NULL", char_id)
|
||||
);
|
||||
@@ -681,57 +669,60 @@ bool SharedDatabase::GetInventory(Client *c)
|
||||
return false;
|
||||
}
|
||||
|
||||
for (auto const& row: results) {
|
||||
for (auto const &row: results) {
|
||||
if (row.guid != 0) {
|
||||
EQ::ItemInstance::AddGUIDToMap(row.guid);
|
||||
}
|
||||
}
|
||||
|
||||
const auto timestamps = GetItemRecastTimestamps(char_id);
|
||||
auto cv_conflict = false;
|
||||
const auto pmask = inv.GetLookup()->PossessionsBitmask;
|
||||
const auto bank_size = inv.GetLookup()->InventoryTypeSize.Bank;
|
||||
const auto timestamps = GetItemRecastTimestamps(char_id);
|
||||
auto cv_conflict = false;
|
||||
const auto pmask = inv.GetLookup()->PossessionsBitmask;
|
||||
const auto bank_size = inv.GetLookup()->InventoryTypeSize.Bank;
|
||||
|
||||
std::vector<InventoryRepository::Inventory> queue{ };
|
||||
for (auto& row: results) {
|
||||
const int16 slot_id = row.slot_id;
|
||||
const uint32 item_id = row.item_id;
|
||||
std::vector<InventoryRepository::Inventory> queue{};
|
||||
for (auto &row: results) {
|
||||
const int16 slot_id = row.slotid;
|
||||
const uint32 item_id = row.itemid;
|
||||
const uint16 charges = row.charges;
|
||||
const uint32 color = row.color;
|
||||
const bool instnodrop = row.instnodrop;
|
||||
const uint32 ornament_icon = row.ornament_icon;
|
||||
const uint32 ornament_idfile = row.ornament_idfile;
|
||||
const bool instnodrop = row.instnodrop;
|
||||
const uint32 ornament_icon = row.ornamenticon;
|
||||
const uint32 ornament_idfile = row.ornamentidfile;
|
||||
const uint32 ornament_hero_model = row.ornament_hero_model;
|
||||
|
||||
uint32 augment_ids[EQ::invaug::SOCKET_COUNT] = {
|
||||
row.augment_one,
|
||||
row.augment_two,
|
||||
row.augment_three,
|
||||
row.augment_four,
|
||||
row.augment_five,
|
||||
row.augment_six
|
||||
};
|
||||
uint32 aug[EQ::invaug::SOCKET_COUNT];
|
||||
aug[0] = row.augslot1;
|
||||
aug[1] = row.augslot2;
|
||||
aug[2] = row.augslot3;
|
||||
aug[3] = row.augslot4;
|
||||
aug[4] = row.augslot5;
|
||||
aug[5] = row.augslot6;
|
||||
|
||||
if (EQ::ValueWithin(slot_id, EQ::invslot::POSSESSIONS_BEGIN, EQ::invslot::POSSESSIONS_END)) {
|
||||
if (slot_id <= EQ::invslot::POSSESSIONS_END && slot_id >= EQ::invslot::POSSESSIONS_BEGIN) {
|
||||
// Titanium thru UF check
|
||||
if (((static_cast<uint64>(1) << slot_id) & pmask) == 0) {
|
||||
cv_conflict = true;
|
||||
continue;
|
||||
}
|
||||
} else if (EQ::ValueWithin(slot_id, EQ::invbag::GENERAL_BAGS_BEGIN, EQ::invbag::GENERAL_BAGS_END)) {
|
||||
}
|
||||
else if (slot_id <= EQ::invbag::GENERAL_BAGS_END && slot_id >= EQ::invbag::GENERAL_BAGS_BEGIN) {
|
||||
// Titanium thru UF check
|
||||
const auto parent_slot = EQ::invslot::GENERAL_BEGIN + ((slot_id - EQ::invbag::GENERAL_BAGS_BEGIN) / EQ::invbag::SLOT_COUNT);
|
||||
const auto parent_slot = EQ::invslot::GENERAL_BEGIN + (
|
||||
(slot_id - EQ::invbag::GENERAL_BAGS_BEGIN) / EQ::invbag::SLOT_COUNT);
|
||||
if (((static_cast<uint64>(1) << parent_slot) & pmask) == 0) {
|
||||
cv_conflict = true;
|
||||
continue;
|
||||
}
|
||||
} else if (EQ::ValueWithin(slot_id, EQ::invslot::BANK_BEGIN, EQ::invslot::BANK_END)) {
|
||||
}
|
||||
else if (slot_id <= EQ::invslot::BANK_END && slot_id >= EQ::invslot::BANK_BEGIN) {
|
||||
// Titanium check
|
||||
if ((slot_id - EQ::invslot::BANK_BEGIN) >= bank_size) {
|
||||
cv_conflict = true;
|
||||
continue;
|
||||
}
|
||||
} else if (EQ::ValueWithin(slot_id, EQ::invbag::BANK_BAGS_BEGIN, EQ::invbag::BANK_BAGS_END)) {
|
||||
}
|
||||
else if (slot_id <= EQ::invbag::BANK_BAGS_END && slot_id >= EQ::invbag::BANK_BAGS_BEGIN) {
|
||||
// Titanium check
|
||||
const auto parent_index = ((slot_id - EQ::invbag::BANK_BAGS_BEGIN) / EQ::invbag::SLOT_COUNT);
|
||||
if (parent_index >= bank_size) {
|
||||
@@ -740,7 +731,7 @@ bool SharedDatabase::GetInventory(Client *c)
|
||||
}
|
||||
}
|
||||
|
||||
auto* item = GetItem(item_id);
|
||||
auto *item = GetItem(item_id);
|
||||
if (!item) {
|
||||
LogError(
|
||||
"Warning: charid [{}] has an invalid item_id [{}] in inventory slot [{}]",
|
||||
@@ -751,7 +742,7 @@ bool SharedDatabase::GetInventory(Client *c)
|
||||
continue;
|
||||
}
|
||||
|
||||
auto* inst = CreateBaseItem(item, charges);
|
||||
auto *inst = CreateBaseItem(item, charges);
|
||||
if (!inst) {
|
||||
continue;
|
||||
}
|
||||
@@ -764,13 +755,8 @@ bool SharedDatabase::GetInventory(Client *c)
|
||||
inst->SetOrnamentationIDFile(ornament_idfile);
|
||||
inst->SetOrnamentHeroModel(item->HerosForgeModel);
|
||||
|
||||
if (
|
||||
instnodrop ||
|
||||
(
|
||||
inst->GetItem()->Attuneable &&
|
||||
EQ::ValueWithin(slot_id, EQ::invslot::EQUIPMENT_BEGIN, EQ::invslot::EQUIPMENT_END)
|
||||
)
|
||||
) {
|
||||
if (instnodrop || (inst->GetItem()->Attuneable && slot_id >= EQ::invslot::EQUIPMENT_BEGIN && slot_id <=
|
||||
EQ::invslot::EQUIPMENT_END)) {
|
||||
inst->SetAttuned(true);
|
||||
}
|
||||
|
||||
@@ -778,29 +764,33 @@ bool SharedDatabase::GetInventory(Client *c)
|
||||
inst->SetColor(color);
|
||||
}
|
||||
|
||||
if (charges == std::numeric_limits<int16>::max()) {
|
||||
if (charges == 0x7FFF) {
|
||||
inst->SetCharges(-1);
|
||||
} else if (charges == 0 && inst->IsStackable()) {
|
||||
}
|
||||
else if (charges == 0 && inst->IsStackable()) {
|
||||
// Stackable items need a minimum charge of 1 remain moveable.
|
||||
inst->SetCharges(1);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
inst->SetCharges(charges);
|
||||
}
|
||||
|
||||
if (item->RecastDelay) {
|
||||
if (item->RecastType != RECAST_TYPE_UNLINKED_ITEM && timestamps.count(item->RecastType)) {
|
||||
inst->SetRecastTimestamp(timestamps.at(item->RecastType));
|
||||
} else if (item->RecastType == RECAST_TYPE_UNLINKED_ITEM && timestamps.count(item->ID)) {
|
||||
}
|
||||
else if (item->RecastType == RECAST_TYPE_UNLINKED_ITEM && timestamps.count(item->ID)) {
|
||||
inst->SetRecastTimestamp(timestamps.at(item->ID));
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
inst->SetRecastTimestamp(0);
|
||||
}
|
||||
}
|
||||
|
||||
if (item->IsClassCommon()) {
|
||||
for (int i = EQ::invaug::SOCKET_BEGIN; i <= EQ::invaug::SOCKET_END; i++) {
|
||||
if (augment_ids[i]) {
|
||||
inst->PutAugment(this, i, augment_ids[i]);
|
||||
if (aug[i]) {
|
||||
inst->PutAugment(this, i, aug[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -852,10 +842,20 @@ bool SharedDatabase::GetInventory(Client *c)
|
||||
}
|
||||
|
||||
int16 put_slot_id;
|
||||
// this had || slot_id == EQ::invslot::slotCursor ??s
|
||||
if (EQ::ValueWithin(slot_id, EQ::invbag::CURSOR_BAG_BEGIN, EQ::invbag::CURSOR_BAG_END)) {
|
||||
if (slot_id >= 8000 && slot_id <= 8999) {
|
||||
put_slot_id = inv.PushCursor(*inst);
|
||||
} else {
|
||||
}
|
||||
else if (slot_id >= 3111 && slot_id <= 3179) {
|
||||
// Admins: please report any occurrences of this error
|
||||
LogError(
|
||||
"Warning: Defunct location for item in inventory: charid={}, item_id={}, slot_id={} .. pushing to cursor...",
|
||||
char_id,
|
||||
item_id,
|
||||
slot_id
|
||||
);
|
||||
put_slot_id = inv.PushCursor(*inst);
|
||||
}
|
||||
else {
|
||||
put_slot_id = inv.PutItem(slot_id, *inst);
|
||||
}
|
||||
|
||||
@@ -867,7 +867,7 @@ bool SharedDatabase::GetInventory(Client *c)
|
||||
// Save ptr to item in inventory
|
||||
if (put_slot_id == INVALID_INDEX) {
|
||||
LogError(
|
||||
"Warning: Invalid slot_id for item in inventory for character_id [{}] item_id [{}] slot_id [{}]",
|
||||
"Warning: Invalid slot_id for item in inventory: charid=[{}], item_id=[{}], slot_id=[{}]",
|
||||
char_id,
|
||||
item_id,
|
||||
slot_id
|
||||
@@ -876,7 +876,7 @@ bool SharedDatabase::GetInventory(Client *c)
|
||||
}
|
||||
|
||||
if (cv_conflict) {
|
||||
const std::string& char_name = GetCharName(char_id);
|
||||
const std::string &char_name = GetCharName(char_id);
|
||||
LogError(
|
||||
"ClientVersion/Expansion conflict during inventory load at zone entry for [{}] (charid: [{}], inver: [{}], gmi: [{}])",
|
||||
char_name,
|
||||
@@ -896,6 +896,94 @@ bool SharedDatabase::GetInventory(Client *c)
|
||||
return GetSharedBank(char_id, &inv, true);
|
||||
}
|
||||
|
||||
// Overloaded: Retrieve character inventory based on account_id and character name (char select)
|
||||
bool SharedDatabase::GetInventory(uint32 account_id, char *name, EQ::InventoryProfile *inv) // deprecated
|
||||
{
|
||||
// Retrieve character inventory
|
||||
const std::string query =
|
||||
StringFormat("SELECT slotid, itemid, charges, color, augslot1, "
|
||||
"augslot2, augslot3, augslot4, augslot5, augslot6, instnodrop, custom_data, ornamenticon, "
|
||||
"ornamentidfile, ornament_hero_model "
|
||||
"FROM inventory INNER JOIN character_data ch "
|
||||
"ON ch.id = charid WHERE ch.name = '%s' AND ch.account_id = %i ORDER BY slotid",
|
||||
name, account_id);
|
||||
auto results = QueryDatabase(query);
|
||||
if (!results.Success()) {
|
||||
LogError("If you got an error related to the 'instnodrop' field, run the "
|
||||
"following SQL Queries:\nalter table inventory add instnodrop "
|
||||
"tinyint(1) unsigned default 0 not null;\n");
|
||||
return false;
|
||||
}
|
||||
|
||||
for (auto& row = results.begin(); row != results.end(); ++row) {
|
||||
int16 slot_id = Strings::ToInt(row[0]);
|
||||
uint32 item_id = Strings::ToUnsignedInt(row[1]);
|
||||
const int8 charges = Strings::ToInt(row[2]);
|
||||
const uint32 color = Strings::ToUnsignedInt(row[3]);
|
||||
|
||||
uint32 aug[EQ::invaug::SOCKET_COUNT];
|
||||
aug[0] = Strings::ToUnsignedInt(row[4]);
|
||||
aug[1] = Strings::ToUnsignedInt(row[5]);
|
||||
aug[2] = Strings::ToUnsignedInt(row[6]);
|
||||
aug[3] = Strings::ToUnsignedInt(row[7]);
|
||||
aug[4] = Strings::ToUnsignedInt(row[8]);
|
||||
aug[5] = Strings::ToUnsignedInt(row[9]);
|
||||
|
||||
const bool instnodrop = (row[10] && static_cast<uint16>(Strings::ToUnsignedInt(row[10])));
|
||||
const uint32 ornament_icon = Strings::ToUnsignedInt(row[12]);
|
||||
const uint32 ornament_idfile = Strings::ToUnsignedInt(row[13]);
|
||||
uint32 ornament_hero_model = Strings::ToUnsignedInt(row[14]);
|
||||
|
||||
const EQ::ItemData *item = GetItem(item_id);
|
||||
if (!item)
|
||||
continue;
|
||||
|
||||
EQ::ItemInstance *inst = CreateBaseItem(item, charges);
|
||||
|
||||
if (inst == nullptr)
|
||||
continue;
|
||||
|
||||
inst->SetAttuned(instnodrop);
|
||||
|
||||
if (row[11]) {
|
||||
std::string data_str(row[11]);
|
||||
inst->SetCustomDataString(data_str);
|
||||
}
|
||||
|
||||
inst->SetOrnamentIcon(ornament_icon);
|
||||
inst->SetOrnamentationIDFile(ornament_idfile);
|
||||
inst->SetOrnamentHeroModel(item->HerosForgeModel);
|
||||
|
||||
if (color > 0)
|
||||
inst->SetColor(color);
|
||||
|
||||
inst->SetCharges(charges);
|
||||
|
||||
if (item->IsClassCommon()) {
|
||||
for (int i = EQ::invaug::SOCKET_BEGIN; i <= EQ::invaug::SOCKET_END; i++) {
|
||||
if (aug[i])
|
||||
inst->PutAugment(this, i, aug[i]);
|
||||
}
|
||||
}
|
||||
|
||||
int16 put_slot_id;
|
||||
if (slot_id >= 8000 && slot_id <= 8999)
|
||||
put_slot_id = inv->PushCursor(*inst);
|
||||
else
|
||||
put_slot_id = inv->PutItem(slot_id, *inst);
|
||||
|
||||
safe_delete(inst);
|
||||
|
||||
// Save ptr to item in inventory
|
||||
if (put_slot_id == INVALID_INDEX)
|
||||
LogError("Warning: Invalid slot_id for item in inventory: name={}, acctid={}, item_id={}, slot_id={}",
|
||||
name, account_id, item_id, slot_id);
|
||||
}
|
||||
|
||||
// Retrieve shared inventory
|
||||
return GetSharedBank(account_id, inv, false);
|
||||
}
|
||||
|
||||
std::map<uint32, uint32> SharedDatabase::GetItemRecastTimestamps(uint32 char_id)
|
||||
{
|
||||
std::map<uint32, uint32> timers;
|
||||
@@ -1247,7 +1335,7 @@ void SharedDatabase::LoadItems(void *data, uint32 size, int32 items, uint32 max_
|
||||
|
||||
// Bag
|
||||
item.BagSize = static_cast<uint8>(Strings::ToUnsignedInt(row[ItemField::bagsize]));
|
||||
item.BagSlots = static_cast<uint8>(EQ::Clamp(Strings::ToInt(row[ItemField::bagslots]), 0, static_cast<int>(EQ::invbag::SLOT_COUNT)));
|
||||
item.BagSlots = static_cast<uint8>(EQ::Clamp(Strings::ToInt(row[ItemField::bagslots]), 0, 10)); // Will need to be changed from std::min to just use database value when bag slots are increased
|
||||
item.BagType = static_cast<uint8>(Strings::ToUnsignedInt(row[ItemField::bagtype]));
|
||||
item.BagWR = static_cast<uint8>(EQ::Clamp(Strings::ToInt(row[ItemField::bagwr]), 0, 100));
|
||||
|
||||
|
||||
+2
-2
@@ -25,7 +25,7 @@
|
||||
|
||||
// Build variables
|
||||
// these get injected during the build pipeline
|
||||
#define CURRENT_VERSION "22.62.1-dev" // always append -dev to the current version for custom-builds
|
||||
#define CURRENT_VERSION "22.61.0-dev" // always append -dev to the current version for custom-builds
|
||||
#define LOGIN_VERSION "0.8.0"
|
||||
#define COMPILE_DATE __DATE__
|
||||
#define COMPILE_TIME __TIME__
|
||||
@@ -42,7 +42,7 @@
|
||||
* Manifest: https://github.com/EQEmu/Server/blob/master/utils/sql/db_update_manifest.txt
|
||||
*/
|
||||
|
||||
#define CURRENT_BINARY_DATABASE_VERSION 9298
|
||||
#define CURRENT_BINARY_DATABASE_VERSION 9293
|
||||
#define CURRENT_BINARY_BOTS_DATABASE_VERSION 9045
|
||||
|
||||
#endif
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "eqemu-server",
|
||||
"version": "22.62.1",
|
||||
"version": "22.61.0",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/EQEmu/Server.git"
|
||||
|
||||
@@ -11,6 +11,6 @@ require (
|
||||
github.com/golang/protobuf v1.3.2 // indirect
|
||||
github.com/google/go-querystring v1.1.0 // indirect
|
||||
golang.org/x/crypto v0.31.0 // indirect
|
||||
golang.org/x/net v0.33.0 // indirect
|
||||
golang.org/x/net v0.23.0 // indirect
|
||||
google.golang.org/appengine v1.6.7 // indirect
|
||||
)
|
||||
|
||||
@@ -14,8 +14,8 @@ golang.org/x/crypto v0.31.0 h1:ihbySMvVjLAeSH1IbfcRTkD/iNscyz8rGzjF/E5hV6U=
|
||||
golang.org/x/crypto v0.31.0/go.mod h1:kDsLvtWBEx7MV9tJOj9bnXsPbxwJQ6csT/x4KIN4Ssk=
|
||||
golang.org/x/net v0.0.0-20190603091049-60506f45cf65/go.mod h1:HSz+uSET+XFnRR8LxR5pz3Of3rY3CfYBVs4xY44aLks=
|
||||
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
|
||||
golang.org/x/net v0.33.0 h1:74SYHlV8BIgHIFC/LrYkOGIwL19eTYXQ5wc6TBuO36I=
|
||||
golang.org/x/net v0.33.0/go.mod h1:HXLR5J+9DxmrqMwG9qjGCxZ+zKXxBru04zlTvWlWuN4=
|
||||
golang.org/x/net v0.23.0 h1:7EYJ93RZ9vYSZAIb2x3lnuvqO5zneoD6IvWjuhfxjTs=
|
||||
golang.org/x/net v0.23.0/go.mod h1:JKghWKKOSdJwpW2GEx0Ja7fmaKnMsbu+MWVZTokSYmg=
|
||||
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be h1:vEDujvNQGv4jgYKudGeI/+DAX4Jffq6hpD55MmoEvKs=
|
||||
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
|
||||
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
|
||||
@@ -142,6 +142,7 @@ foreach my $table_to_generate (@tables) {
|
||||
"guild_bank",
|
||||
"inventory_versions",
|
||||
"raid_leaders",
|
||||
"sharedbank",
|
||||
"trader_audit",
|
||||
"eqtime",
|
||||
"db_version",
|
||||
|
||||
+11
-16
@@ -2380,26 +2380,21 @@ bool Client::StoreCharacter(
|
||||
|
||||
auto e = InventoryRepository::NewEntity();
|
||||
|
||||
e.character_id = character_id;
|
||||
e.charid = character_id;
|
||||
|
||||
for (int16 slot_id = EQ::invslot::EQUIPMENT_BEGIN; slot_id <= EQ::invbag::BANK_BAGS_END;) {
|
||||
const auto inst = p_inventory_profile->GetItem(slot_id);
|
||||
if (inst) {
|
||||
e.slot_id = slot_id;
|
||||
e.item_id = inst->GetItem()->ID;
|
||||
e.charges = inst->GetCharges();
|
||||
e.color = inst->GetColor();
|
||||
e.augment_one = inst->GetAugmentItemID(EQ::invaug::SOCKET_BEGIN);
|
||||
e.augment_two = inst->GetAugmentItemID(EQ::invaug::SOCKET_BEGIN + 1);
|
||||
e.augment_three = inst->GetAugmentItemID(EQ::invaug::SOCKET_BEGIN + 2);
|
||||
e.augment_four = inst->GetAugmentItemID(EQ::invaug::SOCKET_BEGIN + 3);
|
||||
e.augment_five = inst->GetAugmentItemID(EQ::invaug::SOCKET_BEGIN + 4);
|
||||
e.augment_six = inst->GetAugmentItemID(EQ::invaug::SOCKET_END);
|
||||
e.instnodrop = inst->IsAttuned() ? 1 : 0;
|
||||
e.ornament_icon = inst->GetOrnamentationIcon();
|
||||
e.ornament_idfile = inst->GetOrnamentationIDFile();
|
||||
e.ornament_hero_model = inst->GetOrnamentHeroModel();
|
||||
e.guid = inst->GetSerialNumber();
|
||||
e.slotid = slot_id;
|
||||
e.itemid = inst->GetItem()->ID;
|
||||
e.charges = inst->GetCharges();
|
||||
e.color = inst->GetColor();
|
||||
e.augslot1 = inst->GetAugmentItemID(EQ::invaug::SOCKET_BEGIN);
|
||||
e.augslot2 = inst->GetAugmentItemID(EQ::invaug::SOCKET_BEGIN + 1);
|
||||
e.augslot3 = inst->GetAugmentItemID(EQ::invaug::SOCKET_BEGIN + 2);
|
||||
e.augslot4 = inst->GetAugmentItemID(EQ::invaug::SOCKET_BEGIN + 3);
|
||||
e.augslot5 = inst->GetAugmentItemID(EQ::invaug::SOCKET_BEGIN + 4);
|
||||
e.augslot6 = inst->GetAugmentItemID(EQ::invaug::SOCKET_END);
|
||||
|
||||
v.emplace_back(e);
|
||||
}
|
||||
|
||||
+90
-66
@@ -26,7 +26,6 @@
|
||||
#include <vector>
|
||||
#include "sof_char_create_data.h"
|
||||
#include "../common/repositories/character_instance_safereturns_repository.h"
|
||||
#include "../common/repositories/inventory_repository.h"
|
||||
#include "../common/repositories/criteria/content_filter_criteria.h"
|
||||
#include "../common/zone_store.h"
|
||||
|
||||
@@ -858,90 +857,115 @@ bool WorldDatabase::LoadCharacterCreateCombos()
|
||||
// this is a slightly modified version of SharedDatabase::GetInventory(...) for character select use-only
|
||||
bool WorldDatabase::GetCharSelInventory(uint32 account_id, char *name, EQ::InventoryProfile *inv)
|
||||
{
|
||||
if (!account_id || !name || !inv) {
|
||||
if (!account_id || !name || !inv)
|
||||
return false;
|
||||
}
|
||||
|
||||
const uint32 character_id = GetCharacterID(name);
|
||||
|
||||
if (!character_id) {
|
||||
return false;
|
||||
}
|
||||
|
||||
const auto& l = InventoryRepository::GetWhere(
|
||||
*this,
|
||||
fmt::format(
|
||||
"`character_id` = {} AND `slot_id` BETWEEN {} AND {}",
|
||||
character_id,
|
||||
EQ::invslot::slotHead,
|
||||
EQ::invslot::slotFeet
|
||||
)
|
||||
std::string query = StringFormat(
|
||||
"SELECT"
|
||||
" slotid,"
|
||||
" itemid,"
|
||||
" charges,"
|
||||
" color,"
|
||||
" augslot1,"
|
||||
" augslot2,"
|
||||
" augslot3,"
|
||||
" augslot4,"
|
||||
" augslot5,"
|
||||
" augslot6,"
|
||||
" instnodrop,"
|
||||
" custom_data,"
|
||||
" ornamenticon,"
|
||||
" ornamentidfile,"
|
||||
" ornament_hero_model "
|
||||
"FROM"
|
||||
" inventory "
|
||||
"INNER JOIN"
|
||||
" character_data ch "
|
||||
"ON"
|
||||
" ch.id = charid "
|
||||
"WHERE"
|
||||
" ch.name = '%s' "
|
||||
"AND"
|
||||
" ch.account_id = %i "
|
||||
"AND"
|
||||
" slotid >= %i "
|
||||
"AND"
|
||||
" slotid <= %i",
|
||||
name,
|
||||
account_id,
|
||||
EQ::invslot::slotHead,
|
||||
EQ::invslot::slotFeet
|
||||
);
|
||||
auto results = QueryDatabase(query);
|
||||
if (!results.Success())
|
||||
return false;
|
||||
|
||||
if (l.empty()) {
|
||||
return true;
|
||||
}
|
||||
for (auto row = results.begin(); row != results.end(); ++row) {
|
||||
int16 slot_id = Strings::ToInt(row[0]);
|
||||
|
||||
for (const auto& e : l) {
|
||||
switch (e.slot_id) {
|
||||
case EQ::invslot::slotFace:
|
||||
case EQ::invslot::slotEar2:
|
||||
case EQ::invslot::slotNeck:
|
||||
case EQ::invslot::slotShoulders:
|
||||
case EQ::invslot::slotBack:
|
||||
case EQ::invslot::slotFinger1:
|
||||
case EQ::invslot::slotFinger2:
|
||||
continue;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
uint32 augment_ids[EQ::invaug::SOCKET_COUNT] = {
|
||||
e.augment_one,
|
||||
e.augment_two,
|
||||
e.augment_three,
|
||||
e.augment_four,
|
||||
e.augment_five,
|
||||
e.augment_six
|
||||
};
|
||||
|
||||
const EQ::ItemData* item = content_db.GetItem(e.item_id);
|
||||
if (!item) {
|
||||
switch (slot_id) {
|
||||
case EQ::invslot::slotFace:
|
||||
case EQ::invslot::slotEar2:
|
||||
case EQ::invslot::slotNeck:
|
||||
case EQ::invslot::slotShoulders:
|
||||
case EQ::invslot::slotBack:
|
||||
case EQ::invslot::slotFinger1:
|
||||
case EQ::invslot::slotFinger2:
|
||||
continue;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
EQ::ItemInstance *inst = content_db.CreateBaseItem(item, e.charges);
|
||||
uint32 item_id = Strings::ToInt(row[1]);
|
||||
int8 charges = Strings::ToInt(row[2]);
|
||||
uint32 color = Strings::ToUnsignedInt(row[3]);
|
||||
|
||||
if (!inst) {
|
||||
uint32 aug[EQ::invaug::SOCKET_COUNT];
|
||||
aug[0] = (uint32)Strings::ToInt(row[4]);
|
||||
aug[1] = (uint32)Strings::ToInt(row[5]);
|
||||
aug[2] = (uint32)Strings::ToInt(row[6]);
|
||||
aug[3] = (uint32)Strings::ToInt(row[7]);
|
||||
aug[4] = (uint32)Strings::ToInt(row[8]);
|
||||
aug[5] = (uint32)Strings::ToInt(row[9]);
|
||||
|
||||
bool instnodrop = ((row[10] && (uint16)Strings::ToInt(row[10])) ? true : false);
|
||||
uint32 ornament_icon = (uint32)Strings::ToUnsignedInt(row[12]);
|
||||
uint32 ornament_idfile = (uint32)Strings::ToUnsignedInt(row[13]);
|
||||
uint32 ornament_hero_model = (uint32)Strings::ToUnsignedInt(row[14]);
|
||||
|
||||
const EQ::ItemData *item = content_db.GetItem(item_id);
|
||||
if (!item)
|
||||
continue;
|
||||
|
||||
EQ::ItemInstance *inst = content_db.CreateBaseItem(item, charges);
|
||||
|
||||
if (inst == nullptr)
|
||||
continue;
|
||||
|
||||
inst->SetAttuned(instnodrop);
|
||||
|
||||
if (row[11]) {
|
||||
std::string data_str(row[11]);
|
||||
inst->SetCustomDataString(data_str);
|
||||
}
|
||||
|
||||
inst->SetCharges(e.charges);
|
||||
inst->SetOrnamentIcon(ornament_icon);
|
||||
inst->SetOrnamentationIDFile(ornament_idfile);
|
||||
inst->SetOrnamentHeroModel(item->HerosForgeModel);
|
||||
|
||||
if (e.color > 0) {
|
||||
inst->SetColor(e.color);
|
||||
}
|
||||
if (color > 0)
|
||||
inst->SetColor(color);
|
||||
|
||||
inst->SetCharges(charges);
|
||||
|
||||
if (item->IsClassCommon()) {
|
||||
for (int i = EQ::invaug::SOCKET_BEGIN; i <= EQ::invaug::SOCKET_END; i++) {
|
||||
if (augment_ids[i]) {
|
||||
inst->PutAugment(this, i, augment_ids[i]);
|
||||
}
|
||||
if (aug[i])
|
||||
inst->PutAugment(this, i, aug[i]);
|
||||
}
|
||||
}
|
||||
|
||||
inst->SetAttuned(e.instnodrop);
|
||||
|
||||
if (!e.custom_data.empty()) {
|
||||
inst->SetCustomDataString(e.custom_data);
|
||||
}
|
||||
|
||||
inst->SetOrnamentIcon(e.ornament_icon);
|
||||
inst->SetOrnamentationIDFile(e.ornament_idfile);
|
||||
inst->SetOrnamentHeroModel(e.ornament_hero_model);
|
||||
|
||||
inv->PutItem(e.slot_id, *inst);
|
||||
inv->PutItem(slot_id, *inst);
|
||||
|
||||
safe_delete(inst);
|
||||
}
|
||||
|
||||
+26
-20
@@ -2559,12 +2559,16 @@ bool NPC::Death(Mob* killer_mob, int64 damage, uint16 spell, EQ::skills::SkillTy
|
||||
const uint8 killed_level = GetLevel();
|
||||
|
||||
if (GetClass() == Class::LDoNTreasure) { // open chest
|
||||
static EQApplicationPacket p(OP_Animation, sizeof(Animation_Struct));
|
||||
auto a = (Animation_Struct*) p.pBuffer;
|
||||
auto outapp = new EQApplicationPacket(OP_Animation, sizeof(Animation_Struct));
|
||||
|
||||
auto a = (Animation_Struct*) outapp->pBuffer;
|
||||
|
||||
a->spawnid = GetID();
|
||||
a->action = 0x0F;
|
||||
a->speed = 10;
|
||||
entity_list.QueueCloseClients(this, &p);
|
||||
|
||||
entity_list.QueueCloseClients(this, outapp);
|
||||
safe_delete(outapp);
|
||||
}
|
||||
|
||||
auto app = new EQApplicationPacket(OP_Death, sizeof(Death_Struct));
|
||||
@@ -3411,15 +3415,15 @@ void Mob::DamageShield(Mob* attacker, bool spell_ds) {
|
||||
|
||||
attacker->Damage(this, -DS, spellid, EQ::skills::SkillAbjuration/*hackish*/, false);
|
||||
//we can assume there is a spell now
|
||||
|
||||
static EQApplicationPacket p(OP_Damage, sizeof(CombatDamage_Struct));
|
||||
auto b = (CombatDamage_Struct *) p.pBuffer;
|
||||
b->target = attacker->GetID();
|
||||
b->source = GetID();
|
||||
b->type = spellbonuses.DamageShieldType;
|
||||
b->spellid = 0x0;
|
||||
b->damage = DS;
|
||||
entity_list.QueueCloseClients(this, &p);
|
||||
auto outapp = new EQApplicationPacket(OP_Damage, sizeof(CombatDamage_Struct));
|
||||
CombatDamage_Struct* cds = (CombatDamage_Struct*)outapp->pBuffer;
|
||||
cds->target = attacker->GetID();
|
||||
cds->source = GetID();
|
||||
cds->type = spellbonuses.DamageShieldType;
|
||||
cds->spellid = 0x0;
|
||||
cds->damage = DS;
|
||||
entity_list.QueueCloseClients(this, outapp);
|
||||
safe_delete(outapp);
|
||||
}
|
||||
else if (DS > 0 && !spell_ds) {
|
||||
//we are healing the attacker...
|
||||
@@ -4536,8 +4540,8 @@ void Mob::CommonDamage(Mob* attacker, int64 &damage, const uint16 spell_id, cons
|
||||
|
||||
//send damage packet...
|
||||
if (!iBuffTic) { //buff ticks do not send damage, instead they just call SendHPUpdate(), which is done above
|
||||
static EQApplicationPacket p(OP_Damage, sizeof(CombatDamage_Struct));
|
||||
auto a = (CombatDamage_Struct *) p.pBuffer;
|
||||
auto outapp = new EQApplicationPacket(OP_Damage, sizeof(CombatDamage_Struct));
|
||||
CombatDamage_Struct* a = (CombatDamage_Struct*)outapp->pBuffer;
|
||||
a->target = GetID();
|
||||
|
||||
if (!attacker) {
|
||||
@@ -4618,7 +4622,7 @@ void Mob::CommonDamage(Mob* attacker, int64 &damage, const uint16 spell_id, cons
|
||||
if (!FromDamageShield) {
|
||||
entity_list.QueueCloseClients(
|
||||
attacker, /* Sender */
|
||||
&p, /* packet */
|
||||
outapp, /* packet */
|
||||
false, /* Skip Sender */
|
||||
((IsValidSpell(spell_id)) ? RuleI(Range, SpellMessages) : RuleI(Range, DamageMessages)),
|
||||
0, /* don't skip anyone on spell */
|
||||
@@ -4692,11 +4696,11 @@ void Mob::CommonDamage(Mob* attacker, int64 &damage, const uint16 spell_id, cons
|
||||
filter = FilterMyMisses;
|
||||
|
||||
if (attacker->IsClient()) {
|
||||
attacker->CastToClient()->QueuePacket(&p, true, CLIENT_CONNECTED, filter);
|
||||
attacker->CastToClient()->QueuePacket(outapp, true, CLIENT_CONNECTED, filter);
|
||||
} else {
|
||||
entity_list.QueueCloseClients(
|
||||
attacker, /* Sender */
|
||||
&p, /* packet */
|
||||
outapp, /* packet */
|
||||
false, /* Skip Sender */
|
||||
(
|
||||
IsValidSpell(spell_id) ?
|
||||
@@ -4751,7 +4755,7 @@ void Mob::CommonDamage(Mob* attacker, int64 &damage, const uint16 spell_id, cons
|
||||
a->type = DamageTypeSpell;
|
||||
entity_list.QueueCloseClients(
|
||||
this, /* Sender */
|
||||
&p, /* packet */
|
||||
outapp, /* packet */
|
||||
false, /* Skip Sender */
|
||||
range, /* distance packet travels at the speed of sound */
|
||||
0, /* don't skip anyone on spell */
|
||||
@@ -4762,7 +4766,7 @@ void Mob::CommonDamage(Mob* attacker, int64 &damage, const uint16 spell_id, cons
|
||||
else {
|
||||
//I dont think any filters apply to damage affecting us
|
||||
if (IsClient()) {
|
||||
CastToClient()->QueuePacket(&p);
|
||||
CastToClient()->QueuePacket(outapp);
|
||||
}
|
||||
|
||||
// Send normal message to observers
|
||||
@@ -4772,7 +4776,7 @@ void Mob::CommonDamage(Mob* attacker, int64 &damage, const uint16 spell_id, cons
|
||||
if (!owner || (owner && !owner->IsClient())) {
|
||||
entity_list.QueueCloseClients(
|
||||
this, /* Sender */
|
||||
&p, /* packet */
|
||||
outapp, /* packet */
|
||||
true, /* Skip Sender */
|
||||
range, /* distance packet travels at the speed of sound */
|
||||
(IsValidSpell(spell_id) && skill_used != EQ::skills::SkillTigerClaw) ? 0 : skip,
|
||||
@@ -4782,6 +4786,8 @@ void Mob::CommonDamage(Mob* attacker, int64 &damage, const uint16 spell_id, cons
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
safe_delete(outapp);
|
||||
}
|
||||
else {
|
||||
//else, it is a buff tic...
|
||||
|
||||
+4
-5
@@ -735,22 +735,21 @@ bool Aura::Process()
|
||||
|
||||
if (movement_type == AuraMovement::Follow && GetPosition() != owner->GetPosition() && movement_timer.Check()) {
|
||||
m_Position = owner->GetPosition();
|
||||
|
||||
static EQApplicationPacket packet(OP_ClientUpdate, sizeof(PlayerPositionUpdateServer_Struct));
|
||||
auto spu = (PlayerPositionUpdateServer_Struct *) packet.pBuffer;
|
||||
|
||||
auto app = new EQApplicationPacket(OP_ClientUpdate, sizeof(PlayerPositionUpdateServer_Struct));
|
||||
auto spu = (PlayerPositionUpdateServer_Struct *) app->pBuffer;
|
||||
MakeSpawnUpdate(spu);
|
||||
auto it = spawned_for.begin();
|
||||
while (it != spawned_for.end()) {
|
||||
auto client = entity_list.GetClientByID(*it);
|
||||
if (client) {
|
||||
client->QueuePacket(&packet);
|
||||
client->QueuePacket(app);
|
||||
++it;
|
||||
}
|
||||
else {
|
||||
it = spawned_for.erase(it);
|
||||
}
|
||||
}
|
||||
safe_delete(app);
|
||||
}
|
||||
// TODO: waypoints?
|
||||
|
||||
|
||||
+4
-4
@@ -9203,7 +9203,7 @@ void Client::SetPrimaryWeaponOrnamentation(uint32 model_id)
|
||||
auto l = InventoryRepository::GetWhere(
|
||||
database,
|
||||
fmt::format(
|
||||
"`character_id` = {} AND `slot_id` = {}",
|
||||
"`charid` = {} AND `slotid` = {}",
|
||||
character_id,
|
||||
EQ::invslot::slotPrimary
|
||||
)
|
||||
@@ -9215,7 +9215,7 @@ void Client::SetPrimaryWeaponOrnamentation(uint32 model_id)
|
||||
|
||||
auto e = l.front();
|
||||
|
||||
e.ornament_idfile = model_id;
|
||||
e.ornamentidfile = model_id;
|
||||
|
||||
const int updated = InventoryRepository::UpdateOne(database, e);
|
||||
|
||||
@@ -9236,7 +9236,7 @@ void Client::SetSecondaryWeaponOrnamentation(uint32 model_id)
|
||||
auto l = InventoryRepository::GetWhere(
|
||||
database,
|
||||
fmt::format(
|
||||
"`character_id` = {} AND `slot_id` = {}",
|
||||
"`charid` = {} AND `slotid` = {}",
|
||||
character_id,
|
||||
EQ::invslot::slotSecondary
|
||||
)
|
||||
@@ -9248,7 +9248,7 @@ void Client::SetSecondaryWeaponOrnamentation(uint32 model_id)
|
||||
|
||||
auto e = l.front();
|
||||
|
||||
e.ornament_idfile = model_id;
|
||||
e.ornamentidfile = model_id;
|
||||
|
||||
const int updated = InventoryRepository::UpdateOne(database, e);
|
||||
|
||||
|
||||
@@ -339,6 +339,7 @@ public:
|
||||
const char *message9 = nullptr);
|
||||
void Tell_StringID(uint32 string_id, const char *who, const char *message);
|
||||
void SendColoredText(uint32 color, std::string message);
|
||||
void SendBazaarResults(uint32 trader_id, uint32 in_class, uint32 in_race, uint32 item_stat, uint32 item_slot, uint32 item_type, char item_name[64], uint32 min_price, uint32 max_price);
|
||||
void SendTraderItem(uint32 item_id,uint16 quantity, TraderRepository::Trader &trader);
|
||||
void DoBazaarSearch(BazaarSearchCriteria_Struct search_criteria);
|
||||
uint16 FindTraderItem(int32 SerialNumber,uint16 Quantity);
|
||||
|
||||
+58
-33
@@ -1658,6 +1658,11 @@ void Client::Handle_Connect_OP_ZoneEntry(const EQApplicationPacket *app)
|
||||
m_pp.abilitySlotRefresh = 0;
|
||||
}
|
||||
|
||||
#ifdef _EQDEBUG
|
||||
printf("Dumping inventory on load:\n");
|
||||
m_inv.dumpEntireInventory();
|
||||
#endif
|
||||
|
||||
/* Reset to max so they dont drown on zone in if its underwater */
|
||||
m_pp.air_remaining = 60;
|
||||
/* Check for PVP Zone status*/
|
||||
@@ -4837,10 +4842,11 @@ void Client::Handle_OP_ClientUpdate(const EQApplicationPacket *app) {
|
||||
auto boat_delta = glm::vec4(ppu->delta_x, ppu->delta_y, ppu->delta_z, EQ10toFloat(ppu->delta_heading));
|
||||
cmob->SetDelta(boat_delta);
|
||||
|
||||
static EQApplicationPacket outapp(OP_ClientUpdate, sizeof(PlayerPositionUpdateServer_Struct));
|
||||
auto *ppus = (PlayerPositionUpdateServer_Struct *) outapp.pBuffer;
|
||||
auto outapp = new EQApplicationPacket(OP_ClientUpdate, sizeof(PlayerPositionUpdateServer_Struct));
|
||||
PlayerPositionUpdateServer_Struct *ppus = (PlayerPositionUpdateServer_Struct *) outapp->pBuffer;
|
||||
cmob->MakeSpawnUpdate(ppus);
|
||||
entity_list.QueueCloseClients(cmob, &outapp, true, 300, this, false);
|
||||
entity_list.QueueCloseClients(cmob, outapp, true, 300, this, false);
|
||||
safe_delete(outapp);
|
||||
|
||||
/* Update the boat's position on the server, without sending an update */
|
||||
cmob->GMMove(ppu->x_pos, ppu->y_pos, ppu->z_pos, EQ12toFloat(ppu->heading));
|
||||
@@ -5014,15 +5020,15 @@ void Client::Handle_OP_ClientUpdate(const EQApplicationPacket *app) {
|
||||
m_Position.w = new_heading;
|
||||
|
||||
/* Broadcast update to other clients */
|
||||
static EQApplicationPacket outapp(OP_ClientUpdate, sizeof(PlayerPositionUpdateServer_Struct));
|
||||
PlayerPositionUpdateServer_Struct *position_update = (PlayerPositionUpdateServer_Struct *) outapp.pBuffer;
|
||||
auto outapp = new EQApplicationPacket(OP_ClientUpdate, sizeof(PlayerPositionUpdateServer_Struct));
|
||||
PlayerPositionUpdateServer_Struct *position_update = (PlayerPositionUpdateServer_Struct *) outapp->pBuffer;
|
||||
|
||||
MakeSpawnUpdate(position_update);
|
||||
|
||||
if (gm_hide_me) {
|
||||
entity_list.QueueClientsStatus(this, &outapp, true, Admin(), AccountStatus::Max);
|
||||
entity_list.QueueClientsStatus(this, outapp, true, Admin(), AccountStatus::Max);
|
||||
} else {
|
||||
entity_list.QueueCloseClients(this, &outapp, true, RuleI(Range, ClientPositionUpdates), nullptr, true);
|
||||
entity_list.QueueCloseClients(this, outapp, true, RuleI(Range, ClientPositionUpdates), nullptr, true);
|
||||
}
|
||||
|
||||
|
||||
@@ -5031,10 +5037,12 @@ void Client::Handle_OP_ClientUpdate(const EQApplicationPacket *app) {
|
||||
Raid *raid = GetRaid();
|
||||
|
||||
if (raid) {
|
||||
raid->QueueClients(this, &outapp, true, true, (RuleI(Range, ClientPositionUpdates) * -1));
|
||||
raid->QueueClients(this, outapp, true, true, (RuleI(Range, ClientPositionUpdates) * -1));
|
||||
} else if (group) {
|
||||
group->QueueClients(this, &outapp, true, true, (RuleI(Range, ClientPositionUpdates) * -1));
|
||||
group->QueueClients(this, outapp, true, true, (RuleI(Range, ClientPositionUpdates) * -1));
|
||||
}
|
||||
|
||||
safe_delete(outapp);
|
||||
}
|
||||
|
||||
if (zone->watermap) {
|
||||
@@ -10743,7 +10751,8 @@ void Client::Handle_OP_MoveCoin(const EQApplicationPacket *app)
|
||||
|
||||
void Client::Handle_OP_MoveItem(const EQApplicationPacket *app)
|
||||
{
|
||||
if (!CharacterID()) {
|
||||
if (!CharacterID())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -10752,38 +10761,57 @@ void Client::Handle_OP_MoveItem(const EQApplicationPacket *app)
|
||||
return;
|
||||
}
|
||||
|
||||
BenchTimer bench;
|
||||
|
||||
MoveItem_Struct* mi = (MoveItem_Struct*) app->pBuffer;
|
||||
if (spellend_timer.Enabled() && casting_spell_id && !IsBardSong(casting_spell_id)) {
|
||||
if (mi->from_slot != mi->to_slot && (mi->from_slot <= EQ::invslot::GENERAL_END || mi->from_slot > 39) &&
|
||||
IsValidSlot(mi->from_slot) && IsValidSlot(mi->to_slot)) {
|
||||
const EQ::ItemInstance* itm_from = GetInv().GetItem(mi->from_slot);
|
||||
const EQ::ItemInstance* itm_to = GetInv().GetItem(mi->to_slot);
|
||||
auto message = fmt::format(
|
||||
"Player issued a move item from {}(item id {}) to {}(item id {}) while casting {}.",
|
||||
MoveItem_Struct* mi = (MoveItem_Struct*)app->pBuffer;
|
||||
if (spellend_timer.Enabled() && casting_spell_id && !IsBardSong(casting_spell_id))
|
||||
{
|
||||
if (mi->from_slot != mi->to_slot && (mi->from_slot <= EQ::invslot::GENERAL_END || mi->from_slot > 39) && IsValidSlot(mi->from_slot) && IsValidSlot(mi->to_slot))
|
||||
{
|
||||
const EQ::ItemInstance *itm_from = GetInv().GetItem(mi->from_slot);
|
||||
const EQ::ItemInstance *itm_to = GetInv().GetItem(mi->to_slot);
|
||||
auto message = fmt::format("Player issued a move item from {}(item id {}) to {}(item id {}) while casting {}.",
|
||||
mi->from_slot,
|
||||
itm_from ? itm_from->GetID() : 0,
|
||||
mi->to_slot,
|
||||
itm_to ? itm_to->GetID() : 0,
|
||||
casting_spell_id
|
||||
);
|
||||
RecordPlayerEventLog(PlayerEvent::POSSIBLE_HACK, PlayerEvent::PossibleHackEvent{ .message = message });
|
||||
casting_spell_id);
|
||||
RecordPlayerEventLog(PlayerEvent::POSSIBLE_HACK, PlayerEvent::PossibleHackEvent{.message = message});
|
||||
Kick("Inventory desync"); // Kick client to prevent client and server from getting out-of-sync inventory slots
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
database.TransactionBegin();
|
||||
// Illegal bagslot usage checks. Currently, user only receives a message if this check is triggered.
|
||||
bool mi_hack = false;
|
||||
|
||||
if (mi->from_slot >= EQ::invbag::GENERAL_BAGS_BEGIN && mi->from_slot <= EQ::invbag::CURSOR_BAG_END) {
|
||||
if (mi->from_slot >= EQ::invbag::CURSOR_BAG_BEGIN) { mi_hack = true; }
|
||||
else {
|
||||
int16 from_parent = m_inv.CalcSlotId(mi->from_slot);
|
||||
if (!m_inv[from_parent]) { mi_hack = true; }
|
||||
else if (!m_inv[from_parent]->IsClassBag()) { mi_hack = true; }
|
||||
else if (m_inv.CalcBagIdx(mi->from_slot) >= m_inv[from_parent]->GetItem()->BagSlots) { mi_hack = true; }
|
||||
}
|
||||
}
|
||||
|
||||
if (mi->to_slot >= EQ::invbag::GENERAL_BAGS_BEGIN && mi->to_slot <= EQ::invbag::CURSOR_BAG_END) {
|
||||
if (mi->to_slot >= EQ::invbag::CURSOR_BAG_BEGIN) { mi_hack = true; }
|
||||
else {
|
||||
int16 to_parent = m_inv.CalcSlotId(mi->to_slot);
|
||||
if (!m_inv[to_parent]) { mi_hack = true; }
|
||||
else if (!m_inv[to_parent]->IsClassBag()) { mi_hack = true; }
|
||||
else if (m_inv.CalcBagIdx(mi->to_slot) >= m_inv[to_parent]->GetItem()->BagSlots) { mi_hack = true; }
|
||||
}
|
||||
}
|
||||
|
||||
if (mi_hack) { Message(Chat::Yellow, "Caution: Illegal use of inaccessible bag slots!"); }
|
||||
|
||||
if (!SwapItem(mi) && IsValidSlot(mi->from_slot) && IsValidSlot(mi->to_slot)) {
|
||||
SwapItemResync(mi);
|
||||
|
||||
bool error = false;
|
||||
InterrogateInventory(this, false, true, false, error, false);
|
||||
if (error) {
|
||||
if (error)
|
||||
InterrogateInventory(this, true, false, true, error);
|
||||
}
|
||||
}
|
||||
|
||||
for (int slot : {mi->to_slot, mi->from_slot}) {
|
||||
@@ -10792,10 +10820,6 @@ void Client::Handle_OP_MoveItem(const EQApplicationPacket *app)
|
||||
CharacterEvolvingItemsRepository::UpdateOne(database, item->GetEvolvingDetails());
|
||||
}
|
||||
}
|
||||
|
||||
database.TransactionCommit();
|
||||
|
||||
LogInventory("OP_MoveItem took [{}] ms", bench.elapsedMilliseconds());
|
||||
}
|
||||
|
||||
void Client::Handle_OP_MoveMultipleItems(const EQApplicationPacket *app)
|
||||
@@ -16723,12 +16747,13 @@ bool Client::CanTradeFVNoDropItem()
|
||||
|
||||
void Client::SendMobPositions()
|
||||
{
|
||||
static EQApplicationPacket p(OP_ClientUpdate, sizeof(PlayerPositionUpdateServer_Struct));
|
||||
auto *s = (PlayerPositionUpdateServer_Struct *) p.pBuffer;
|
||||
auto p = new EQApplicationPacket(OP_ClientUpdate, sizeof(PlayerPositionUpdateServer_Struct));
|
||||
auto *s = (PlayerPositionUpdateServer_Struct *) p->pBuffer;
|
||||
for (auto &m: entity_list.GetMobList()) {
|
||||
m.second->MakeSpawnUpdate(s);
|
||||
QueuePacket(&p, false);
|
||||
QueuePacket(p, false);
|
||||
}
|
||||
safe_delete(p);
|
||||
}
|
||||
|
||||
struct RecordKillCheck {
|
||||
|
||||
+53
-79
@@ -294,30 +294,24 @@ bool Client::Process() {
|
||||
}
|
||||
}
|
||||
|
||||
int lazy_load_bank_slots = 0;
|
||||
for (int i = 0; i < 5000; i++) {
|
||||
if (m_lazy_load_bank && m_lazy_load_sent_bank_slots <= EQ::invslot::SHARED_BANK_END) {
|
||||
const EQ::ItemInstance *inst = nullptr;
|
||||
if (m_lazy_load_bank && m_lazy_load_sent_bank_slots <= EQ::invslot::SHARED_BANK_END) {
|
||||
const EQ::ItemInstance *inst = nullptr;
|
||||
|
||||
// Jump the gaps
|
||||
if (m_lazy_load_sent_bank_slots < EQ::invslot::BANK_BEGIN) {
|
||||
m_lazy_load_sent_bank_slots = EQ::invslot::BANK_BEGIN;
|
||||
}
|
||||
else if (m_lazy_load_sent_bank_slots > EQ::invslot::BANK_END &&
|
||||
m_lazy_load_sent_bank_slots < EQ::invslot::SHARED_BANK_BEGIN) {
|
||||
m_lazy_load_sent_bank_slots = EQ::invslot::SHARED_BANK_BEGIN;
|
||||
}
|
||||
else {
|
||||
m_lazy_load_sent_bank_slots++;
|
||||
}
|
||||
// Jump the gaps
|
||||
if (m_lazy_load_sent_bank_slots < EQ::invslot::BANK_BEGIN) {
|
||||
m_lazy_load_sent_bank_slots = EQ::invslot::BANK_BEGIN;
|
||||
}
|
||||
else if (m_lazy_load_sent_bank_slots > EQ::invslot::BANK_END &&
|
||||
m_lazy_load_sent_bank_slots < EQ::invslot::SHARED_BANK_BEGIN) {
|
||||
m_lazy_load_sent_bank_slots = EQ::invslot::SHARED_BANK_BEGIN;
|
||||
}
|
||||
else {
|
||||
m_lazy_load_sent_bank_slots++;
|
||||
}
|
||||
|
||||
inst = m_inv[m_lazy_load_sent_bank_slots];
|
||||
if (inst) {
|
||||
SendItemPacket(m_lazy_load_sent_bank_slots, inst, ItemPacketType::ItemPacketTrade);
|
||||
lazy_load_bank_slots++;
|
||||
}
|
||||
} else {
|
||||
break;
|
||||
inst = m_inv[m_lazy_load_sent_bank_slots];
|
||||
if (inst) {
|
||||
SendItemPacket(m_lazy_load_sent_bank_slots, inst, ItemPacketType::ItemPacketTrade);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -776,83 +770,65 @@ void Client::BulkSendInventoryItems()
|
||||
EQ::OutBuffer ob;
|
||||
EQ::OutBuffer::pos_type last_pos = ob.tellp();
|
||||
|
||||
// Equipment items
|
||||
for (int16 slot_id = EQ::invslot::EQUIPMENT_BEGIN; slot_id <= EQ::invslot::EQUIPMENT_END; slot_id++) {
|
||||
// Possessions items
|
||||
for (int16 slot_id = EQ::invslot::POSSESSIONS_BEGIN; slot_id <= EQ::invslot::POSSESSIONS_END; slot_id++) {
|
||||
const EQ::ItemInstance* inst = m_inv[slot_id];
|
||||
if (!inst) {
|
||||
if (!inst)
|
||||
continue;
|
||||
}
|
||||
|
||||
inst->Serialize(ob, slot_id);
|
||||
|
||||
if (ob.tellp() == last_pos) {
|
||||
if (ob.tellp() == last_pos)
|
||||
LogInventory("Serialization failed on item slot [{}] during BulkSendInventoryItems. Item skipped", slot_id);
|
||||
}
|
||||
|
||||
last_pos = ob.tellp();
|
||||
}
|
||||
|
||||
// General items
|
||||
for (int16 slot_id = EQ::invslot::GENERAL_BEGIN; slot_id <= EQ::invslot::GENERAL_END; slot_id++) {
|
||||
const EQ::ItemInstance* inst = m_inv[slot_id];
|
||||
if (!inst) {
|
||||
continue;
|
||||
}
|
||||
if (!RuleB(Inventory, LazyLoadBank)) {
|
||||
// Bank items
|
||||
for (int16 slot_id = EQ::invslot::BANK_BEGIN; slot_id <= EQ::invslot::BANK_END; slot_id++) {
|
||||
const EQ::ItemInstance* inst = m_inv[slot_id];
|
||||
if (!inst)
|
||||
continue;
|
||||
|
||||
inst->Serialize(ob, slot_id);
|
||||
inst->Serialize(ob, slot_id);
|
||||
|
||||
if (ob.tellp() == last_pos) {
|
||||
LogInventory("Serialization failed on item slot [{}] during BulkSendInventoryItems. Item skipped", slot_id);
|
||||
}
|
||||
if (ob.tellp() == last_pos)
|
||||
LogInventory("Serialization failed on item slot [{}] during BulkSendInventoryItems. Item skipped", slot_id);
|
||||
|
||||
last_pos = ob.tellp();
|
||||
}
|
||||
last_pos = ob.tellp();
|
||||
}
|
||||
|
||||
if (!RuleB(Inventory, LazyLoadBank)) {
|
||||
// Bank items
|
||||
for (int16 slot_id = EQ::invslot::BANK_BEGIN; slot_id <= EQ::invslot::BANK_END; slot_id++) {
|
||||
const EQ::ItemInstance* inst = m_inv[slot_id];
|
||||
if (!inst) {
|
||||
continue;
|
||||
}
|
||||
// SharedBank items
|
||||
for (int16 slot_id = EQ::invslot::SHARED_BANK_BEGIN; slot_id <= EQ::invslot::SHARED_BANK_END; slot_id++) {
|
||||
const EQ::ItemInstance* inst = m_inv[slot_id];
|
||||
if (!inst)
|
||||
continue;
|
||||
|
||||
inst->Serialize(ob, slot_id);
|
||||
inst->Serialize(ob, slot_id);
|
||||
|
||||
if (ob.tellp() == last_pos) {
|
||||
LogInventory("Serialization failed on item slot [{}] during BulkSendInventoryItems. Item skipped", slot_id);
|
||||
}
|
||||
if (ob.tellp() == last_pos)
|
||||
LogInventory("Serialization failed on item slot [{}] during BulkSendInventoryItems. Item skipped", slot_id);
|
||||
|
||||
last_pos = ob.tellp();
|
||||
}
|
||||
last_pos = ob.tellp();
|
||||
}
|
||||
}
|
||||
|
||||
// SharedBank items
|
||||
for (int16 slot_id = EQ::invslot::SHARED_BANK_BEGIN; slot_id <= EQ::invslot::SHARED_BANK_END; slot_id++) {
|
||||
const EQ::ItemInstance* inst = m_inv[slot_id];
|
||||
if (!inst) {
|
||||
continue;
|
||||
}
|
||||
|
||||
inst->Serialize(ob, slot_id);
|
||||
|
||||
if (ob.tellp() == last_pos) {
|
||||
LogInventory("Serialization failed on item slot [{}] during BulkSendInventoryItems. Item skipped", slot_id);
|
||||
}
|
||||
|
||||
last_pos = ob.tellp();
|
||||
}
|
||||
}
|
||||
|
||||
auto outapp = new EQApplicationPacket(OP_CharInventory);
|
||||
|
||||
outapp->size = ob.size();
|
||||
outapp->pBuffer = ob.detach();
|
||||
|
||||
QueuePacket(outapp);
|
||||
safe_delete(outapp);
|
||||
auto outapp = new EQApplicationPacket(OP_CharInventory);
|
||||
outapp->size = ob.size();
|
||||
outapp->pBuffer = ob.detach();
|
||||
QueuePacket(outapp);
|
||||
safe_delete(outapp);
|
||||
}
|
||||
|
||||
void Client::BulkSendMerchantInventory(int merchant_id, int npcid) {
|
||||
const EQ::ItemData* handy_item = nullptr;
|
||||
|
||||
uint32 merchant_slots = 80; //The max number of items passed in the transaction.
|
||||
if (m_ClientVersionBit & EQ::versions::maskRoFAndLater) { // RoF+ can send 200 items
|
||||
merchant_slots = 200;
|
||||
}
|
||||
|
||||
const EQ::ItemData *item = nullptr;
|
||||
auto merchant_list = zone->merchanttable[merchant_id];
|
||||
auto npc = entity_list.GetMobByNpcTypeID(npcid);
|
||||
@@ -864,8 +840,6 @@ void Client::BulkSendMerchantInventory(int merchant_id, int npcid) {
|
||||
}
|
||||
}
|
||||
|
||||
const int16 merchant_slots = (m_ClientVersionBit & EQ::versions::maskRoFAndLater) ? EQ::invtype::MERCHANT_SIZE : 80;
|
||||
|
||||
auto temporary_merchant_list = zone->tmpmerchanttable[npcid];
|
||||
uint32 slot_id = 1;
|
||||
uint8 handy_chance = 0;
|
||||
|
||||
+2
-2
@@ -845,7 +845,7 @@ LootItem *Corpse::GetItem(uint16 lootslot, LootItem **bag_item_data)
|
||||
|
||||
// convert above code to for loop
|
||||
for (const auto &item: m_item_list) {
|
||||
if (item->equip_slot >= bagstart && item->equip_slot < bagstart + EQ::invbag::SLOT_COUNT) {
|
||||
if (item->equip_slot >= bagstart && item->equip_slot < bagstart + 10) {
|
||||
bag_item_data[item->equip_slot - bagstart] = item;
|
||||
}
|
||||
}
|
||||
@@ -1472,7 +1472,7 @@ void Corpse::LootCorpseItem(Client *c, const EQApplicationPacket *app)
|
||||
|
||||
const EQ::ItemData *item = nullptr;
|
||||
EQ::ItemInstance *inst = nullptr;
|
||||
LootItem *item_data = nullptr, *bag_item_data[EQ::invbag::SLOT_COUNT] = {};
|
||||
LootItem *item_data = nullptr, *bag_item_data[10] = {};
|
||||
|
||||
memset(bag_item_data, 0, sizeof(bag_item_data));
|
||||
if (GetPlayerKillItem() > 1) {
|
||||
|
||||
+27
-116
@@ -1,15 +1,12 @@
|
||||
#include "data_bucket.h"
|
||||
#include "entity.h"
|
||||
#include "zonedb.h"
|
||||
#include "mob.h"
|
||||
#include "worldserver.h"
|
||||
#include <ctime>
|
||||
#include <cctype>
|
||||
#include "../common/json/json.hpp"
|
||||
|
||||
using json = nlohmann::json;
|
||||
|
||||
extern WorldServer worldserver;
|
||||
const std::string NESTED_KEY_DELIMITER = ".";
|
||||
|
||||
std::vector<DataBucketsRepository::DataBuckets> g_data_bucket_cache = {};
|
||||
|
||||
@@ -28,13 +25,8 @@ void DataBucket::SetData(const std::string &bucket_key, const std::string &bucke
|
||||
DataBucket::SetData(k);
|
||||
}
|
||||
|
||||
void DataBucket::SetData(const DataBucketKey &k_)
|
||||
void DataBucket::SetData(const DataBucketKey &k)
|
||||
{
|
||||
DataBucketKey k = k_; // copy the key so we can modify it
|
||||
if (k.key.find(NESTED_KEY_DELIMITER) != std::string::npos) {
|
||||
k.key = Strings::Split(k.key, NESTED_KEY_DELIMITER).front();
|
||||
}
|
||||
|
||||
auto b = DataBucketsRepository::NewEntity();
|
||||
auto r = GetData(k, true);
|
||||
// if we have an entry, use it
|
||||
@@ -68,48 +60,9 @@ void DataBucket::SetData(const DataBucketKey &k_)
|
||||
|
||||
b.expires = expires_time_unix;
|
||||
b.value = k.value;
|
||||
b.key_ = k.key;
|
||||
|
||||
// Check for nested keys (keys with dots)
|
||||
if (k_.key.find(NESTED_KEY_DELIMITER) != std::string::npos) {
|
||||
// Retrieve existing JSON or create a new one
|
||||
std::string existing_value = r.id > 0 ? r.value : "{}";
|
||||
json json_value = json::object();
|
||||
|
||||
try {
|
||||
json_value = json::parse(existing_value);
|
||||
} catch (json::parse_error &e) {
|
||||
LogError("Failed to parse JSON for key [{}]: {}", k_.key, e.what());
|
||||
json_value = json::object(); // Reset to an empty object on error
|
||||
}
|
||||
|
||||
// Recursively merge new key-value pair into the JSON object
|
||||
auto nested_keys = Strings::Split(k_.key, NESTED_KEY_DELIMITER);
|
||||
json *current = &json_value;
|
||||
|
||||
for (size_t i = 0; i < nested_keys.size(); ++i) {
|
||||
const std::string &key_part = nested_keys[i];
|
||||
if (i == nested_keys.size() - 1) {
|
||||
// Set the value at the final key
|
||||
(*current)[key_part] = k_.value;
|
||||
} else {
|
||||
// Traverse or create nested objects
|
||||
if (!current->contains(key_part)) {
|
||||
(*current)[key_part] = json::object();
|
||||
} else if (!(*current)[key_part].is_object()) {
|
||||
// If key exists but is not an object, reset to object to avoid conflicts
|
||||
(*current)[key_part] = json::object();
|
||||
}
|
||||
current = &(*current)[key_part];
|
||||
}
|
||||
}
|
||||
|
||||
// Serialize JSON back to string
|
||||
b.value = json_value.dump();
|
||||
b.key_ = nested_keys.front(); // Use the top-level key
|
||||
}
|
||||
|
||||
if (bucket_id) {
|
||||
|
||||
// update the cache if it exists
|
||||
if (CanCache(k)) {
|
||||
for (auto &e: g_data_bucket_cache) {
|
||||
@@ -123,6 +76,7 @@ void DataBucket::SetData(const DataBucketKey &k_)
|
||||
DataBucketsRepository::UpdateOne(database, b);
|
||||
}
|
||||
else {
|
||||
b.key_ = k.key;
|
||||
b = DataBucketsRepository::InsertOne(database, b);
|
||||
|
||||
// add to cache if it doesn't exist
|
||||
@@ -138,56 +92,12 @@ std::string DataBucket::GetData(const std::string &bucket_key)
|
||||
return GetData(DataBucketKey{.key = bucket_key}).value;
|
||||
}
|
||||
|
||||
DataBucketsRepository::DataBuckets DataBucket::ExtractNestedValue(
|
||||
const DataBucketsRepository::DataBuckets &bucket,
|
||||
const std::string &full_key)
|
||||
{
|
||||
auto nested_keys = Strings::Split(full_key, NESTED_KEY_DELIMITER);
|
||||
json json_value;
|
||||
|
||||
try {
|
||||
json_value = json::parse(bucket.value); // Parse the JSON
|
||||
} catch (json::parse_error &ex) {
|
||||
LogError("Failed to parse JSON for key [{}]: {}", bucket.key_, ex.what());
|
||||
return DataBucketsRepository::NewEntity(); // Return empty entity on parse error
|
||||
}
|
||||
|
||||
// Start from the top-level key (e.g., "progression")
|
||||
json *current = &json_value;
|
||||
|
||||
// Traverse the JSON structure
|
||||
for (const auto &key_part: nested_keys) {
|
||||
LogDataBuckets("Looking for key part [{}] in JSON", key_part);
|
||||
|
||||
if (!current->contains(key_part)) {
|
||||
LogDataBuckets("Key part [{}] not found in JSON for [{}]", key_part, full_key);
|
||||
return DataBucketsRepository::NewEntity();
|
||||
}
|
||||
|
||||
current = &(*current)[key_part];
|
||||
}
|
||||
|
||||
// Create a new entity with the extracted value
|
||||
DataBucketsRepository::DataBuckets result = bucket; // Copy the original bucket
|
||||
result.value = current->is_string() ? current->get<std::string>() : current->dump();
|
||||
return result;
|
||||
}
|
||||
|
||||
// GetData fetches bucket data from the database or cache if it exists
|
||||
// if the bucket doesn't exist, it will be added to the cache as a miss
|
||||
// if ignore_misses_cache is true, the bucket will not be added to the cache as a miss
|
||||
// the only place we should be ignoring the misses cache is on the initial read during SetData
|
||||
DataBucketsRepository::DataBuckets DataBucket::GetData(const DataBucketKey &k_, bool ignore_misses_cache)
|
||||
DataBucketsRepository::DataBuckets DataBucket::GetData(const DataBucketKey &k, bool ignore_misses_cache)
|
||||
{
|
||||
DataBucketKey k = k_; // Copy the key so we can modify it
|
||||
|
||||
bool is_nested_key = k.key.find(NESTED_KEY_DELIMITER) != std::string::npos;
|
||||
|
||||
// Extract the top-level key for nested keys
|
||||
if (is_nested_key) {
|
||||
k.key = Strings::Split(k.key, NESTED_KEY_DELIMITER).front();
|
||||
}
|
||||
|
||||
LogDataBuckets(
|
||||
"Getting bucket key [{}] bot_id [{}] account_id [{}] character_id [{}] npc_id [{}]",
|
||||
k.key,
|
||||
@@ -199,9 +109,9 @@ DataBucketsRepository::DataBuckets DataBucket::GetData(const DataBucketKey &k_,
|
||||
|
||||
bool can_cache = CanCache(k);
|
||||
|
||||
// Attempt to retrieve the value from the cache
|
||||
// check the cache first if we can cache
|
||||
if (can_cache) {
|
||||
for (const auto &e : g_data_bucket_cache) {
|
||||
for (const auto &e: g_data_bucket_cache) {
|
||||
if (CheckBucketMatch(e, k)) {
|
||||
if (e.expires > 0 && e.expires < std::time(nullptr)) {
|
||||
LogDataBuckets("Attempted to read expired key [{}] removing from cache", e.key_);
|
||||
@@ -209,32 +119,37 @@ DataBucketsRepository::DataBuckets DataBucket::GetData(const DataBucketKey &k_,
|
||||
return DataBucketsRepository::NewEntity();
|
||||
}
|
||||
|
||||
LogDataBuckets("Returning key [{}] value [{}] from cache", e.key_, e.value);
|
||||
|
||||
if (is_nested_key) {
|
||||
return ExtractNestedValue(e, k_.key);
|
||||
// this is a bucket miss, return empty entity
|
||||
// we still cache bucket misses, so we don't have to hit the database
|
||||
if (e.id == 0) {
|
||||
return DataBucketsRepository::NewEntity();
|
||||
}
|
||||
|
||||
LogDataBuckets("Returning key [{}] value [{}] from cache", e.key_, e.value);
|
||||
return e;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Fetch the value from the database
|
||||
auto r = DataBucketsRepository::GetWhere(
|
||||
database,
|
||||
fmt::format(
|
||||
" {} `key` = '{}' LIMIT 1",
|
||||
"{} `key` = '{}' LIMIT 1",
|
||||
DataBucket::GetScopedDbFilters(k),
|
||||
k.key
|
||||
)
|
||||
);
|
||||
|
||||
if (r.empty()) {
|
||||
// Handle cache misses
|
||||
if (!ignore_misses_cache && can_cache) {
|
||||
|
||||
// if we're ignoring the misses cache, don't add to the cache
|
||||
// the only place this is ignored is during the initial read of SetData
|
||||
bool add_to_misses_cache = !ignore_misses_cache && can_cache;
|
||||
if (add_to_misses_cache) {
|
||||
size_t size_before = g_data_bucket_cache.size();
|
||||
|
||||
// cache bucket misses, so we don't have to hit the database
|
||||
// when scripts try to read a bucket that doesn't exist
|
||||
g_data_bucket_cache.emplace_back(
|
||||
DataBucketsRepository::DataBuckets{
|
||||
.id = 0,
|
||||
@@ -260,21 +175,22 @@ DataBucketsRepository::DataBuckets DataBucket::GetData(const DataBucketKey &k_,
|
||||
);
|
||||
}
|
||||
|
||||
return DataBucketsRepository::NewEntity();
|
||||
return {};
|
||||
}
|
||||
|
||||
auto bucket = r.front();
|
||||
|
||||
// If the entry has expired, delete it
|
||||
if (bucket.expires > 0 && bucket.expires < static_cast<long long>(std::time(nullptr))) {
|
||||
// if the entry has expired, delete it
|
||||
if (bucket.expires > 0 && bucket.expires < (long long) std::time(nullptr)) {
|
||||
DeleteData(k);
|
||||
return DataBucketsRepository::NewEntity();
|
||||
return {};
|
||||
}
|
||||
|
||||
// Add the value to the cache if it doesn't exist
|
||||
// add to cache if it doesn't exist
|
||||
if (can_cache) {
|
||||
bool has_cache = false;
|
||||
for (const auto &e : g_data_bucket_cache) {
|
||||
|
||||
for (auto &e: g_data_bucket_cache) {
|
||||
if (e.id == bucket.id) {
|
||||
has_cache = true;
|
||||
break;
|
||||
@@ -286,11 +202,6 @@ DataBucketsRepository::DataBuckets DataBucket::GetData(const DataBucketKey &k_,
|
||||
}
|
||||
}
|
||||
|
||||
// Handle nested key extraction
|
||||
if (is_nested_key) {
|
||||
return ExtractNestedValue(bucket, k_.key);
|
||||
}
|
||||
|
||||
return bucket;
|
||||
}
|
||||
|
||||
|
||||
+2
-4
@@ -45,9 +45,9 @@ public:
|
||||
static bool GetDataBuckets(Mob *mob);
|
||||
|
||||
// scoped bucket methods
|
||||
static void SetData(const DataBucketKey &k_);
|
||||
static void SetData(const DataBucketKey &k);
|
||||
static bool DeleteData(const DataBucketKey &k);
|
||||
static DataBucketsRepository::DataBuckets GetData(const DataBucketKey &k_, bool ignore_misses_cache = false);
|
||||
static DataBucketsRepository::DataBuckets GetData(const DataBucketKey &k, bool ignore_misses_cache = false);
|
||||
static std::string GetDataExpires(const DataBucketKey &k);
|
||||
static std::string GetDataRemaining(const DataBucketKey &k);
|
||||
static std::string GetScopedDbFilters(const DataBucketKey &k);
|
||||
@@ -63,8 +63,6 @@ public:
|
||||
static void ClearCache();
|
||||
static void DeleteFromCache(uint64 id, DataBucketLoadType::Type type);
|
||||
static bool CanCache(const DataBucketKey &key);
|
||||
static DataBucketsRepository::DataBuckets
|
||||
ExtractNestedValue(const DataBucketsRepository::DataBuckets &bucket, const std::string &full_key);
|
||||
};
|
||||
|
||||
#endif //EQEMU_DATABUCKET_H
|
||||
|
||||
+19
-19
@@ -278,25 +278,25 @@ int Perl__getinventoryslotid(std::string identifier)
|
||||
else if (identifier == "generalbags.begin") result = EQ::invbag::GENERAL_BAGS_BEGIN;
|
||||
else if (identifier == "generalbags.end") result = EQ::invbag::GENERAL_BAGS_END;
|
||||
else if (identifier == "general1bag.begin") result = EQ::invbag::GENERAL_BAGS_BEGIN;
|
||||
else if (identifier == "general1bag.end") result = EQ::invbag::GENERAL_BAGS_BEGIN + (EQ::invbag::SLOT_COUNT - 1);
|
||||
else if (identifier == "general2bag.begin") result = EQ::invbag::GENERAL_BAGS_BEGIN + EQ::invbag::SLOT_COUNT;
|
||||
else if (identifier == "general2bag.end") result = EQ::invbag::GENERAL_BAGS_BEGIN + ((EQ::invbag::SLOT_COUNT * 2) - 1);
|
||||
else if (identifier == "general3bag.begin") result = EQ::invbag::GENERAL_BAGS_BEGIN + (EQ::invbag::SLOT_COUNT * 2);
|
||||
else if (identifier == "general3bag.end") result = EQ::invbag::GENERAL_BAGS_BEGIN + ((EQ::invbag::SLOT_COUNT * 3) - 1);
|
||||
else if (identifier == "general4bag.begin") result = EQ::invbag::GENERAL_BAGS_BEGIN + (EQ::invbag::SLOT_COUNT * 3);
|
||||
else if (identifier == "general4bag.end") result = EQ::invbag::GENERAL_BAGS_BEGIN + ((EQ::invbag::SLOT_COUNT * 4) - 1);
|
||||
else if (identifier == "general5bag.begin") result = EQ::invbag::GENERAL_BAGS_BEGIN + (EQ::invbag::SLOT_COUNT * 4);
|
||||
else if (identifier == "general5bag.end") result = EQ::invbag::GENERAL_BAGS_BEGIN + ((EQ::invbag::SLOT_COUNT * 5) - 1);
|
||||
else if (identifier == "general6bag.begin") result = EQ::invbag::GENERAL_BAGS_BEGIN + (EQ::invbag::SLOT_COUNT * 5);
|
||||
else if (identifier == "general6bag.end") result = EQ::invbag::GENERAL_BAGS_BEGIN + ((EQ::invbag::SLOT_COUNT * 6) - 1);
|
||||
else if (identifier == "general7bag.begin") result = EQ::invbag::GENERAL_BAGS_BEGIN + (EQ::invbag::SLOT_COUNT * 6);
|
||||
else if (identifier == "general7bag.end") result = EQ::invbag::GENERAL_BAGS_BEGIN + ((EQ::invbag::SLOT_COUNT * 7) - 1);
|
||||
else if (identifier == "general8bag.begin") result = EQ::invbag::GENERAL_BAGS_BEGIN + (EQ::invbag::SLOT_COUNT * 7);
|
||||
else if (identifier == "general8bag.end") result = EQ::invbag::GENERAL_BAGS_BEGIN + ((EQ::invbag::SLOT_COUNT * 8) - 1);
|
||||
else if (identifier == "general9bag.begin") result = EQ::invbag::GENERAL_BAGS_BEGIN + (EQ::invbag::SLOT_COUNT * 8);
|
||||
else if (identifier == "general9bag.end") result = EQ::invbag::GENERAL_BAGS_BEGIN + ((EQ::invbag::SLOT_COUNT * 9) - 1);
|
||||
else if (identifier == "general10bag.begin") result = EQ::invbag::GENERAL_BAGS_BEGIN + (EQ::invbag::SLOT_COUNT * 9);
|
||||
else if (identifier == "general10bag.end") result = EQ::invbag::GENERAL_BAGS_BEGIN + ((EQ::invbag::SLOT_COUNT * 10) - 1);
|
||||
else if (identifier == "general1bag.end") result = EQ::invbag::GENERAL_BAGS_BEGIN + 9;
|
||||
else if (identifier == "general2bag.begin") result = EQ::invbag::GENERAL_BAGS_BEGIN + 10;
|
||||
else if (identifier == "general2bag.end") result = EQ::invbag::GENERAL_BAGS_BEGIN + 19;
|
||||
else if (identifier == "general3bag.begin") result = EQ::invbag::GENERAL_BAGS_BEGIN + 20;
|
||||
else if (identifier == "general3bag.end") result = EQ::invbag::GENERAL_BAGS_BEGIN + 29;
|
||||
else if (identifier == "general4bag.begin") result = EQ::invbag::GENERAL_BAGS_BEGIN + 30;
|
||||
else if (identifier == "general4bag.end") result = EQ::invbag::GENERAL_BAGS_BEGIN + 39;
|
||||
else if (identifier == "general5bag.begin") result = EQ::invbag::GENERAL_BAGS_BEGIN + 40;
|
||||
else if (identifier == "general5bag.end") result = EQ::invbag::GENERAL_BAGS_BEGIN + 49;
|
||||
else if (identifier == "general6bag.begin") result = EQ::invbag::GENERAL_BAGS_BEGIN + 50;
|
||||
else if (identifier == "general6bag.end") result = EQ::invbag::GENERAL_BAGS_BEGIN + 59;
|
||||
else if (identifier == "general7bag.begin") result = EQ::invbag::GENERAL_BAGS_BEGIN + 60;
|
||||
else if (identifier == "general7bag.end") result = EQ::invbag::GENERAL_BAGS_BEGIN + 69;
|
||||
else if (identifier == "general8bag.begin") result = EQ::invbag::GENERAL_BAGS_BEGIN + 70;
|
||||
else if (identifier == "general8bag.end") result = EQ::invbag::GENERAL_BAGS_BEGIN + 79;
|
||||
else if (identifier == "general9bag.begin") result = EQ::invbag::GENERAL_BAGS_BEGIN + 80;
|
||||
else if (identifier == "general9bag.end") result = EQ::invbag::GENERAL_BAGS_BEGIN + 89;
|
||||
else if (identifier == "general10bag.begin") result = EQ::invbag::GENERAL_BAGS_BEGIN + 90;
|
||||
else if (identifier == "general10bag.end") result = EQ::invbag::GENERAL_BAGS_BEGIN + 99;
|
||||
else if (identifier == "cursorbag.begin") result = EQ::invbag::CURSOR_BAG_BEGIN;
|
||||
else if (identifier == "cursorbag.end") result = EQ::invbag::CURSOR_BAG_END;
|
||||
else if (identifier == "bank.begin") result = EQ::invslot::BANK_BEGIN;
|
||||
|
||||
+34
-28
@@ -5319,12 +5319,15 @@ void EntityList::SendFindableNPCList(Client *c)
|
||||
return;
|
||||
}
|
||||
|
||||
static EQApplicationPacket p(OP_SendFindableNPCs, sizeof(FindableNPC_Struct));
|
||||
auto b = (FindableNPC_Struct*) p.pBuffer;
|
||||
b->Unknown109 = 0x16;
|
||||
b->Unknown110 = 0x06;
|
||||
b->Unknown111 = 0x24;
|
||||
b->Action = 0;
|
||||
auto outapp = new EQApplicationPacket(OP_SendFindableNPCs, sizeof(FindableNPC_Struct));
|
||||
|
||||
FindableNPC_Struct *fnpcs = (FindableNPC_Struct *)outapp->pBuffer;
|
||||
|
||||
fnpcs->Unknown109 = 0x16;
|
||||
fnpcs->Unknown110 = 0x06;
|
||||
fnpcs->Unknown111 = 0x24;
|
||||
|
||||
fnpcs->Action = 0;
|
||||
|
||||
auto it = npc_list.begin();
|
||||
while (it != npc_list.end()) {
|
||||
@@ -5332,47 +5335,50 @@ void EntityList::SendFindableNPCList(Client *c)
|
||||
NPC *n = it->second;
|
||||
|
||||
if (n->IsFindable()) {
|
||||
b->EntityID = n->GetID();
|
||||
strn0cpy(b->Name, n->GetCleanName(), sizeof(b->Name));
|
||||
strn0cpy(b->LastName, n->GetLastName(), sizeof(b->LastName));
|
||||
b->Race = n->GetRace();
|
||||
b->Class = n->GetClass();
|
||||
fnpcs->EntityID = n->GetID();
|
||||
strn0cpy(fnpcs->Name, n->GetCleanName(), sizeof(fnpcs->Name));
|
||||
strn0cpy(fnpcs->LastName, n->GetLastName(), sizeof(fnpcs->LastName));
|
||||
fnpcs->Race = n->GetRace();
|
||||
fnpcs->Class = n->GetClass();
|
||||
|
||||
c->QueuePacket(&p);
|
||||
c->QueuePacket(outapp);
|
||||
}
|
||||
}
|
||||
++it;
|
||||
}
|
||||
safe_delete(outapp);
|
||||
}
|
||||
|
||||
void EntityList::UpdateFindableNPCState(NPC *n, bool Remove)
|
||||
{
|
||||
if (!n || !n->IsFindable()) {
|
||||
if (!n || !n->IsFindable())
|
||||
return;
|
||||
}
|
||||
|
||||
static EQApplicationPacket p(OP_SendFindableNPCs, sizeof(FindableNPC_Struct));
|
||||
auto b = (FindableNPC_Struct *) p.pBuffer;
|
||||
b->Unknown109 = 0x16;
|
||||
b->Unknown110 = 0x06;
|
||||
b->Unknown111 = 0x24;
|
||||
auto outapp = new EQApplicationPacket(OP_SendFindableNPCs, sizeof(FindableNPC_Struct));
|
||||
|
||||
b->Action = Remove ? 1 : 0;
|
||||
b->EntityID = n->GetID();
|
||||
strn0cpy(b->Name, n->GetCleanName(), sizeof(b->Name));
|
||||
strn0cpy(b->LastName, n->GetLastName(), sizeof(b->LastName));
|
||||
b->Race = n->GetRace();
|
||||
b->Class = n->GetClass();
|
||||
FindableNPC_Struct *fnpcs = (FindableNPC_Struct *)outapp->pBuffer;
|
||||
|
||||
fnpcs->Unknown109 = 0x16;
|
||||
fnpcs->Unknown110 = 0x06;
|
||||
fnpcs->Unknown111 = 0x24;
|
||||
|
||||
fnpcs->Action = Remove ? 1: 0;
|
||||
fnpcs->EntityID = n->GetID();
|
||||
strn0cpy(fnpcs->Name, n->GetCleanName(), sizeof(fnpcs->Name));
|
||||
strn0cpy(fnpcs->LastName, n->GetLastName(), sizeof(fnpcs->LastName));
|
||||
fnpcs->Race = n->GetRace();
|
||||
fnpcs->Class = n->GetClass();
|
||||
|
||||
auto it = client_list.begin();
|
||||
while (it != client_list.end()) {
|
||||
Client *c = it->second;
|
||||
if (c && (c->ClientVersion() >= EQ::versions::ClientVersion::SoD)) {
|
||||
c->QueuePacket(&p);
|
||||
}
|
||||
if (c && (c->ClientVersion() >= EQ::versions::ClientVersion::SoD))
|
||||
c->QueuePacket(outapp);
|
||||
|
||||
++it;
|
||||
}
|
||||
|
||||
safe_delete(outapp);
|
||||
}
|
||||
|
||||
void EntityList::HideCorpses(Client *c, uint8 CurrentMode, uint8 NewMode)
|
||||
|
||||
@@ -310,7 +310,7 @@ void ShowInventory(Client *c, const Seperator *sep)
|
||||
Chat::White,
|
||||
fmt::format(
|
||||
"Slot {} | {} ({}){}",
|
||||
(14000 + limboIndex),
|
||||
(8000 + limboIndex),
|
||||
item_data->ID,
|
||||
linker.GenerateLink(),
|
||||
(
|
||||
@@ -339,7 +339,7 @@ void ShowInventory(Client *c, const Seperator *sep)
|
||||
Chat::White,
|
||||
fmt::format(
|
||||
"Slot {} (Augment Slot {}) | {} ({}){}",
|
||||
(14000 + limboIndex),
|
||||
(8000 + limboIndex),
|
||||
augment_index,
|
||||
linker.GenerateLink(),
|
||||
item_data->ID,
|
||||
@@ -375,7 +375,7 @@ void ShowInventory(Client *c, const Seperator *sep)
|
||||
Chat::White,
|
||||
fmt::format(
|
||||
"Slot {} Bag Slot {} | {} ({}){}",
|
||||
(14000 + limboIndex),
|
||||
(8000 + limboIndex),
|
||||
sub_index,
|
||||
linker.GenerateLink(),
|
||||
item_data->ID,
|
||||
@@ -407,7 +407,7 @@ void ShowInventory(Client *c, const Seperator *sep)
|
||||
Chat::White,
|
||||
fmt::format(
|
||||
"Slot {} Bag Slot {} (Augment Slot {}) | {} ({}){}",
|
||||
(14000 + limboIndex),
|
||||
(8000 + limboIndex),
|
||||
sub_index,
|
||||
augment_index,
|
||||
linker.GenerateLink(),
|
||||
|
||||
+14
-40
@@ -1919,20 +1919,13 @@ bool Client::SwapItem(MoveItem_Struct* move_in) {
|
||||
return false;
|
||||
}
|
||||
//verify shared bank transactions in the database
|
||||
if (
|
||||
src_inst &&
|
||||
(
|
||||
EQ::ValueWithin(src_slot_id, EQ::invslot::SHARED_BANK_BEGIN, EQ::invslot::SHARED_BANK_END) ||
|
||||
EQ::ValueWithin(src_slot_id, EQ::invbag::SHARED_BANK_BAGS_BEGIN, EQ::invbag::SHARED_BANK_BAGS_END)
|
||||
)
|
||||
) {
|
||||
if (src_inst && src_slot_id >= EQ::invslot::SHARED_BANK_BEGIN && src_slot_id <= EQ::invbag::SHARED_BANK_BAGS_END) {
|
||||
if(!database.VerifyInventory(account_id, src_slot_id, src_inst)) {
|
||||
LogError("Player [{}] on account [{}] was found exploiting the shared bank.\n", GetName(), account_name);
|
||||
DeleteItemInInventory(dst_slot_id,0,true);
|
||||
return(false);
|
||||
}
|
||||
|
||||
if (EQ::ValueWithin(src_slot_id, EQ::invslot::SHARED_BANK_BEGIN, EQ::invslot::SHARED_BANK_END) && src_inst->IsClassBag()){
|
||||
if (src_slot_id >= EQ::invslot::SHARED_BANK_BEGIN && src_slot_id <= EQ::invslot::SHARED_BANK_END && src_inst->IsClassBag()){
|
||||
for (uint8 idx = EQ::invbag::SLOT_BEGIN; idx <= EQ::invbag::SLOT_END; idx++) {
|
||||
const EQ::ItemInstance* baginst = src_inst->GetItem(idx);
|
||||
if (baginst && !database.VerifyInventory(account_id, EQ::InventoryProfile::CalcSlotId(src_slot_id, idx), baginst)){
|
||||
@@ -1941,21 +1934,13 @@ bool Client::SwapItem(MoveItem_Struct* move_in) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (
|
||||
dst_inst &&
|
||||
(
|
||||
EQ::ValueWithin(dst_slot_id, EQ::invslot::SHARED_BANK_BEGIN, EQ::invslot::SHARED_BANK_END) ||
|
||||
EQ::ValueWithin(dst_slot_id, EQ::invbag::SHARED_BANK_BAGS_BEGIN, EQ::invbag::SHARED_BANK_BAGS_END)
|
||||
)
|
||||
) {
|
||||
if (dst_inst && dst_slot_id >= EQ::invslot::SHARED_BANK_BEGIN && dst_slot_id <= EQ::invbag::SHARED_BANK_BAGS_END) {
|
||||
if(!database.VerifyInventory(account_id, dst_slot_id, dst_inst)) {
|
||||
LogError("Player [{}] on account [{}] was found exploting the shared bank.\n", GetName(), account_name);
|
||||
DeleteItemInInventory(src_slot_id,0,true);
|
||||
return(false);
|
||||
}
|
||||
|
||||
if (EQ::ValueWithin(dst_slot_id, EQ::invslot::SHARED_BANK_BEGIN, EQ::invslot::SHARED_BANK_END) && dst_inst->IsClassBag()){
|
||||
if (dst_slot_id >= EQ::invslot::SHARED_BANK_BEGIN && dst_slot_id <= EQ::invslot::SHARED_BANK_END && dst_inst->IsClassBag()){
|
||||
for (uint8 idx = EQ::invbag::SLOT_BEGIN; idx <= EQ::invbag::SLOT_END; idx++) {
|
||||
const EQ::ItemInstance* baginst = dst_inst->GetItem(idx);
|
||||
if (baginst && !database.VerifyInventory(account_id, EQ::InventoryProfile::CalcSlotId(dst_slot_id, idx), baginst)){
|
||||
@@ -1968,20 +1953,10 @@ bool Client::SwapItem(MoveItem_Struct* move_in) {
|
||||
|
||||
// Check for No Drop Hacks
|
||||
Mob* with = trade->With();
|
||||
if (
|
||||
(
|
||||
(
|
||||
with &&
|
||||
with->IsClient() &&
|
||||
!with->CastToClient()->IsBecomeNPC() &&
|
||||
EQ::ValueWithin(dst_slot_id, EQ::invslot::TRADE_BEGIN, EQ::invslot::TRADE_END)
|
||||
) ||
|
||||
EQ::ValueWithin(dst_slot_id, EQ::invslot::SHARED_BANK_BEGIN, EQ::invslot::SHARED_BANK_END) ||
|
||||
EQ::ValueWithin(dst_slot_id, EQ::invbag::SHARED_BANK_BAGS_BEGIN, EQ::invbag::SHARED_BANK_BAGS_END)
|
||||
) &&
|
||||
GetInv().CheckNoDrop(src_slot_id) &&
|
||||
!CanTradeFVNoDropItem()
|
||||
) {
|
||||
if (((with && with->IsClient() && !with->CastToClient()->IsBecomeNPC() && dst_slot_id >= EQ::invslot::TRADE_BEGIN && dst_slot_id <= EQ::invslot::TRADE_END) ||
|
||||
(dst_slot_id >= EQ::invslot::SHARED_BANK_BEGIN && dst_slot_id <= EQ::invbag::SHARED_BANK_BAGS_END))
|
||||
&& GetInv().CheckNoDrop(src_slot_id)
|
||||
&& !CanTradeFVNoDropItem()) {
|
||||
auto ndh_inst = m_inv[src_slot_id];
|
||||
std::string ndh_item_data;
|
||||
if (ndh_inst == nullptr) {
|
||||
@@ -3649,7 +3624,7 @@ bool Client::InterrogateInventory(Client* requester, bool log, bool silent, bool
|
||||
if (cursor_itr == m_inv.cursor_cbegin())
|
||||
continue;
|
||||
|
||||
instmap[EQ::invbag::CURSOR_BAG_BEGIN + limbo] = *cursor_itr;
|
||||
instmap[8000 + limbo] = *cursor_itr;
|
||||
}
|
||||
|
||||
// call InterrogateInventory_ for error check
|
||||
@@ -3752,12 +3727,11 @@ bool Client::InterrogateInventory_error(int16 head, int16 index, const EQ::ItemI
|
||||
// very basic error checking - can be elaborated upon if more in-depth testing is needed...
|
||||
|
||||
if (
|
||||
EQ::ValueWithin(head, EQ::invslot::EQUIPMENT_BEGIN, EQ::invslot::EQUIPMENT_END) ||
|
||||
EQ::ValueWithin(head, EQ::invslot::TRIBUTE_BEGIN, EQ::invslot::TRIBUTE_END) ||
|
||||
EQ::ValueWithin(head, EQ::invslot::GUILD_TRIBUTE_BEGIN, EQ::invslot::GUILD_TRIBUTE_END) ||
|
||||
EQ::ValueWithin(head, EQ::invslot::WORLD_BEGIN, EQ::invslot::WORLD_END) ||
|
||||
EQ::ValueWithin(head, EQ::invbag::CURSOR_BAG_BEGIN, EQ::invbag::CURSOR_BAG_END)
|
||||
) {
|
||||
(head >= EQ::invslot::EQUIPMENT_BEGIN && head <= EQ::invslot::EQUIPMENT_END) ||
|
||||
(head >= EQ::invslot::TRIBUTE_BEGIN && head <= EQ::invslot::TRIBUTE_END) ||
|
||||
(head >= EQ::invslot::GUILD_TRIBUTE_BEGIN && head <= EQ::invslot::GUILD_TRIBUTE_END) ||
|
||||
(head >= EQ::invslot::WORLD_BEGIN && head <= EQ::invslot::WORLD_END) ||
|
||||
(head >= 8000 && head <= 8101)) {
|
||||
switch (depth)
|
||||
{
|
||||
case 0: // requirement: inst is extant
|
||||
|
||||
+31
-22
@@ -125,7 +125,7 @@ Mob::Mob(
|
||||
tmHidden(-1),
|
||||
mitigation_ac(0),
|
||||
m_specialattacks(eSpecialAttacks::None),
|
||||
attack_anim_timer(100),
|
||||
attack_anim_timer(500),
|
||||
position_update_melee_push_timer(500),
|
||||
hate_list_cleanup_timer(6000),
|
||||
m_scan_close_mobs_timer(6000),
|
||||
@@ -1522,12 +1522,16 @@ void Mob::SendHPUpdate(bool force_update_all)
|
||||
last_hp
|
||||
);
|
||||
|
||||
static EQApplicationPacket p(OP_HPUpdate, sizeof(SpawnHPUpdate_Struct));
|
||||
auto b = (SpawnHPUpdate_Struct*) p.pBuffer;
|
||||
b->cur_hp = static_cast<uint32>(CastToClient()->GetHP() - itembonuses.HP);
|
||||
b->spawn_id = GetID();
|
||||
b->max_hp = CastToClient()->GetMaxHP() - itembonuses.HP;
|
||||
CastToClient()->QueuePacket(&p);
|
||||
auto client_packet = new EQApplicationPacket(OP_HPUpdate, sizeof(SpawnHPUpdate_Struct));
|
||||
auto *hp_packet_client = (SpawnHPUpdate_Struct *) client_packet->pBuffer;
|
||||
|
||||
hp_packet_client->cur_hp = static_cast<uint32>(CastToClient()->GetHP() - itembonuses.HP);
|
||||
hp_packet_client->spawn_id = GetID();
|
||||
hp_packet_client->max_hp = CastToClient()->GetMaxHP() - itembonuses.HP;
|
||||
|
||||
CastToClient()->QueuePacket(client_packet);
|
||||
|
||||
safe_delete(client_packet);
|
||||
|
||||
ResetHPUpdateTimer();
|
||||
|
||||
@@ -3536,21 +3540,24 @@ void Mob::DoAnim(const int animation_id, int animation_speed, bool ackreq, eqFil
|
||||
return;
|
||||
}
|
||||
|
||||
static EQApplicationPacket p(OP_Animation, sizeof(Animation_Struct));
|
||||
auto a = (Animation_Struct*) p.pBuffer;
|
||||
auto outapp = new EQApplicationPacket(OP_Animation, sizeof(Animation_Struct));
|
||||
auto *a = (Animation_Struct *) outapp->pBuffer;
|
||||
|
||||
a->spawnid = GetID();
|
||||
a->action = animation_id;
|
||||
a->speed = animation_speed ? animation_speed : 10;
|
||||
|
||||
entity_list.QueueCloseClients(
|
||||
this, /* Sender */
|
||||
&p, /* Packet */
|
||||
outapp, /* Packet */
|
||||
false, /* Ignore Sender */
|
||||
RuleI(Range, Anims),
|
||||
0, /* Skip this mob */
|
||||
ackreq, /* Packet ACK */
|
||||
filter /* eqFilterType filter */
|
||||
);
|
||||
|
||||
safe_delete(outapp);
|
||||
}
|
||||
|
||||
void Mob::ShowBuffs(Client* c) {
|
||||
@@ -7710,26 +7717,28 @@ bool Mob::CanRaceEquipItem(uint32 item_id)
|
||||
|
||||
void Mob::SendAddPlayerState(PlayerState new_state)
|
||||
{
|
||||
static EQApplicationPacket p(OP_PlayerStateAdd, sizeof(PlayerState_Struct));
|
||||
auto b = (PlayerState_Struct *) p.pBuffer;
|
||||
auto app = new EQApplicationPacket(OP_PlayerStateAdd, sizeof(PlayerState_Struct));
|
||||
auto ps = (PlayerState_Struct *)app->pBuffer;
|
||||
|
||||
b->spawn_id = GetID();
|
||||
b->state = static_cast<uint32>(new_state);
|
||||
ps->spawn_id = GetID();
|
||||
ps->state = static_cast<uint32>(new_state);
|
||||
|
||||
AddPlayerState(b->state);
|
||||
entity_list.QueueClients(nullptr, &p);
|
||||
AddPlayerState(ps->state);
|
||||
entity_list.QueueClients(nullptr, app);
|
||||
safe_delete(app);
|
||||
}
|
||||
|
||||
void Mob::SendRemovePlayerState(PlayerState old_state)
|
||||
{
|
||||
static EQApplicationPacket p(OP_PlayerStateRemove, sizeof(PlayerState_Struct));
|
||||
auto b = (PlayerState_Struct *) p.pBuffer;
|
||||
auto app = new EQApplicationPacket(OP_PlayerStateRemove, sizeof(PlayerState_Struct));
|
||||
auto ps = (PlayerState_Struct *)app->pBuffer;
|
||||
|
||||
b->spawn_id = GetID();
|
||||
b->state = static_cast<uint32>(old_state);
|
||||
ps->spawn_id = GetID();
|
||||
ps->state = static_cast<uint32>(old_state);
|
||||
|
||||
RemovePlayerState(b->state);
|
||||
entity_list.QueueClients(nullptr, &p);
|
||||
RemovePlayerState(ps->state);
|
||||
entity_list.QueueClients(nullptr, app);
|
||||
safe_delete(app);
|
||||
}
|
||||
|
||||
int32 Mob::GetMeleeMitigation() {
|
||||
|
||||
@@ -824,8 +824,8 @@ void MobMovementManager::SendCommandToClients(
|
||||
return;
|
||||
}
|
||||
|
||||
static EQApplicationPacket p(OP_ClientUpdate, sizeof(PlayerPositionUpdateServer_Struct));
|
||||
auto *spu = (PlayerPositionUpdateServer_Struct *) p.pBuffer;
|
||||
EQApplicationPacket outapp(OP_ClientUpdate, sizeof(PlayerPositionUpdateServer_Struct));
|
||||
auto *spu = (PlayerPositionUpdateServer_Struct *) outapp.pBuffer;
|
||||
|
||||
FillCommandStruct(spu, mob, delta_x, delta_y, delta_z, delta_heading, anim);
|
||||
|
||||
@@ -862,7 +862,7 @@ void MobMovementManager::SendCommandToClients(
|
||||
}
|
||||
}
|
||||
|
||||
c->QueuePacket(&p, false);
|
||||
c->QueuePacket(&outapp, false);
|
||||
c->m_last_seen_mob_position[mob->GetID()] = mob->GetPosition();
|
||||
}
|
||||
}
|
||||
@@ -924,7 +924,7 @@ void MobMovementManager::SendCommandToClients(
|
||||
}
|
||||
}
|
||||
|
||||
c->QueuePacket(&p, false);
|
||||
c->QueuePacket(&outapp, false);
|
||||
c->m_last_seen_mob_position[mob->GetID()] = mob->GetPosition();
|
||||
}
|
||||
}
|
||||
|
||||
+4
-3
@@ -3824,12 +3824,13 @@ int NPC::GetRolledItemCount(uint32 item_id)
|
||||
|
||||
void NPC::SendPositionToClients()
|
||||
{
|
||||
static EQApplicationPacket p(OP_ClientUpdate, sizeof(PlayerPositionUpdateServer_Struct));
|
||||
auto *s = (PlayerPositionUpdateServer_Struct *) p.pBuffer;
|
||||
auto p = new EQApplicationPacket(OP_ClientUpdate, sizeof(PlayerPositionUpdateServer_Struct));
|
||||
auto *s = (PlayerPositionUpdateServer_Struct *) p->pBuffer;
|
||||
for (auto &c: entity_list.GetClientList()) {
|
||||
MakeSpawnUpdate(s);
|
||||
c.second->QueuePacket(&p, false);
|
||||
c.second->QueuePacket(p, false);
|
||||
}
|
||||
safe_delete(p);
|
||||
}
|
||||
|
||||
void NPC::HandleRoambox()
|
||||
|
||||
@@ -533,7 +533,6 @@ bool ZoneDatabase::PopulateZoneSpawnList(uint32 zoneid, LinkedList<Spawn2*> &spa
|
||||
);
|
||||
|
||||
spawn2_list.Insert(new_spawn);
|
||||
new_spawn->Process();
|
||||
}
|
||||
|
||||
LogInfo("Loaded [{}] spawn2 entries", Strings::Commify(l.size()));
|
||||
|
||||
+18
-15
@@ -953,9 +953,9 @@ bool Mob::SpellEffect(Mob* caster, uint16 spell_id, float partial, int level_ove
|
||||
auto action_packet =
|
||||
new EQApplicationPacket(OP_Action, sizeof(Action_Struct));
|
||||
Action_Struct* action = (Action_Struct*) action_packet->pBuffer;
|
||||
|
||||
static EQApplicationPacket p(OP_Damage, sizeof(CombatDamage_Struct));
|
||||
auto cd = (CombatDamage_Struct *) p.pBuffer;
|
||||
auto message_packet =
|
||||
new EQApplicationPacket(OP_Damage, sizeof(CombatDamage_Struct));
|
||||
CombatDamage_Struct *cd = (CombatDamage_Struct *)message_packet->pBuffer;
|
||||
|
||||
action->target = GetID();
|
||||
action->source = caster ? caster->GetID() : GetID();
|
||||
@@ -978,15 +978,16 @@ bool Mob::SpellEffect(Mob* caster, uint16 spell_id, float partial, int level_ove
|
||||
caster->CastToClient()->QueuePacket(action_packet);
|
||||
}
|
||||
|
||||
CastToClient()->QueuePacket(&p);
|
||||
CastToClient()->QueuePacket(message_packet);
|
||||
|
||||
if (caster && caster->IsClient() && caster != this) {
|
||||
caster->CastToClient()->QueuePacket(&p);
|
||||
caster->CastToClient()->QueuePacket(message_packet);
|
||||
}
|
||||
|
||||
CastToClient()->SetBindPoint(spells[spell_id].base_value[i] - 1);
|
||||
Save();
|
||||
safe_delete(action_packet);
|
||||
safe_delete(message_packet);
|
||||
} else {
|
||||
if (!zone->CanBind()) {
|
||||
MessageString(Chat::SpellFailure, CANNOT_BIND);
|
||||
@@ -1001,9 +1002,9 @@ bool Mob::SpellEffect(Mob* caster, uint16 spell_id, float partial, int level_ove
|
||||
auto action_packet = new EQApplicationPacket(
|
||||
OP_Action, sizeof(Action_Struct));
|
||||
Action_Struct* action = (Action_Struct*) action_packet->pBuffer;
|
||||
|
||||
static EQApplicationPacket p(OP_Damage, sizeof(CombatDamage_Struct));
|
||||
auto cd = (CombatDamage_Struct *) p.pBuffer;
|
||||
auto message_packet = new EQApplicationPacket(
|
||||
OP_Damage, sizeof(CombatDamage_Struct));
|
||||
CombatDamage_Struct *cd = (CombatDamage_Struct *)message_packet->pBuffer;
|
||||
|
||||
action->target = GetID();
|
||||
action->source = caster ? caster->GetID() : GetID();
|
||||
@@ -1026,23 +1027,24 @@ bool Mob::SpellEffect(Mob* caster, uint16 spell_id, float partial, int level_ove
|
||||
caster->CastToClient()->QueuePacket(action_packet);
|
||||
}
|
||||
|
||||
CastToClient()->QueuePacket(&p);
|
||||
CastToClient()->QueuePacket(message_packet);
|
||||
|
||||
if (caster->IsClient() && caster != this) {
|
||||
caster->CastToClient()->QueuePacket(&p);
|
||||
caster->CastToClient()->QueuePacket(message_packet);
|
||||
}
|
||||
|
||||
CastToClient()->SetBindPoint(spells[spell_id].base_value[i] - 1);
|
||||
Save();
|
||||
safe_delete(action_packet);
|
||||
safe_delete(message_packet);
|
||||
}
|
||||
} else {
|
||||
auto action_packet =
|
||||
new EQApplicationPacket(OP_Action, sizeof(Action_Struct));
|
||||
Action_Struct* action = (Action_Struct*) action_packet->pBuffer;
|
||||
|
||||
static EQApplicationPacket p(OP_Damage, sizeof(CombatDamage_Struct));
|
||||
auto cd = (CombatDamage_Struct *) p.pBuffer;
|
||||
auto message_packet = new EQApplicationPacket(
|
||||
OP_Damage, sizeof(CombatDamage_Struct));
|
||||
CombatDamage_Struct *cd = (CombatDamage_Struct *)message_packet->pBuffer;
|
||||
|
||||
action->target = GetID();
|
||||
action->source = caster ? caster->GetID() : GetID();
|
||||
@@ -1065,15 +1067,16 @@ bool Mob::SpellEffect(Mob* caster, uint16 spell_id, float partial, int level_ove
|
||||
caster->CastToClient()->QueuePacket(action_packet);
|
||||
}
|
||||
|
||||
CastToClient()->QueuePacket(&p);
|
||||
CastToClient()->QueuePacket(message_packet);
|
||||
|
||||
if (caster->IsClient() && caster != this) {
|
||||
caster->CastToClient()->QueuePacket(&p);
|
||||
caster->CastToClient()->QueuePacket(message_packet);
|
||||
}
|
||||
|
||||
CastToClient()->SetBindPoint(spells[spell_id].base_value[i] - 1);
|
||||
Save();
|
||||
safe_delete(action_packet);
|
||||
safe_delete(message_packet);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+4
-3
@@ -4564,8 +4564,8 @@ bool Mob::SpellOnTarget(
|
||||
}
|
||||
}
|
||||
|
||||
static EQApplicationPacket p(OP_Damage, sizeof(CombatDamage_Struct));
|
||||
auto cd = (CombatDamage_Struct *) p.pBuffer;
|
||||
message_packet = new EQApplicationPacket(OP_Damage, sizeof(CombatDamage_Struct));
|
||||
CombatDamage_Struct *cd = (CombatDamage_Struct *)message_packet->pBuffer;
|
||||
cd->target = action->target;
|
||||
cd->source = action->source;
|
||||
cd->type = action->type;
|
||||
@@ -4583,7 +4583,7 @@ bool Mob::SpellOnTarget(
|
||||
) {
|
||||
entity_list.QueueCloseClients(
|
||||
spelltar, /* Sender */
|
||||
&p, /* Packet */
|
||||
message_packet, /* Packet */
|
||||
false, /* Ignore Sender */
|
||||
RuleI(Range, SpellMessages),
|
||||
0, /* Skip this mob */
|
||||
@@ -4593,6 +4593,7 @@ bool Mob::SpellOnTarget(
|
||||
}
|
||||
|
||||
safe_delete(action_packet);
|
||||
safe_delete(message_packet);
|
||||
|
||||
/*
|
||||
Bug: When an HP buff with a heal effect is applied for first time, the heal portion of the effect heals the client and
|
||||
|
||||
+312
-7
@@ -1800,13 +1800,7 @@ void Client::SendBarterWelcome()
|
||||
|
||||
void Client::DoBazaarSearch(BazaarSearchCriteria_Struct search_criteria)
|
||||
{
|
||||
std::vector<BazaarSearchResultsFromDB_Struct> results = Bazaar::GetSearchResults(
|
||||
database,
|
||||
content_db,
|
||||
search_criteria,
|
||||
GetZoneID(),
|
||||
GetInstanceID()
|
||||
);
|
||||
auto results = Bazaar::GetSearchResults(database, search_criteria, GetZoneID(), GetInstanceID());
|
||||
if (results.empty()) {
|
||||
SendBazaarDone(GetID());
|
||||
return;
|
||||
@@ -1828,6 +1822,317 @@ void Client::DoBazaarSearch(BazaarSearchCriteria_Struct search_criteria)
|
||||
SendBazaarDeliveryCosts();
|
||||
}
|
||||
|
||||
void Client::SendBazaarResults(
|
||||
uint32 trader_id,
|
||||
uint32 in_class,
|
||||
uint32 in_race,
|
||||
uint32 item_stat,
|
||||
uint32 item_slot,
|
||||
uint32 item_type,
|
||||
char item_name[64],
|
||||
uint32 min_price,
|
||||
uint32 max_price
|
||||
)
|
||||
{
|
||||
std::string search_values = " COUNT(item_id), trader.*, items.name ";
|
||||
std::string search_criteria = " WHERE trader.item_id = items.id ";
|
||||
|
||||
if (trader_id > 0) {
|
||||
Client *trader = entity_list.GetClientByID(trader_id);
|
||||
|
||||
if (trader) {
|
||||
search_criteria.append(StringFormat(" AND trader.char_id = %i", trader->CharacterID()));
|
||||
}
|
||||
}
|
||||
|
||||
if (min_price != 0) {
|
||||
search_criteria.append(StringFormat(" AND trader.item_cost >= %i", min_price));
|
||||
}
|
||||
|
||||
if (max_price != 0) {
|
||||
search_criteria.append(StringFormat(" AND trader.item_cost <= %i", max_price));
|
||||
}
|
||||
|
||||
if (strlen(item_name) > 0) {
|
||||
char *safeName = RemoveApostrophes(item_name);
|
||||
search_criteria.append(StringFormat(" AND items.name LIKE '%%%s%%'", safeName));
|
||||
safe_delete_array(safeName);
|
||||
}
|
||||
|
||||
if (in_class != 0xFFFFFFFF) {
|
||||
search_criteria.append(StringFormat(" AND MID(REVERSE(BIN(items.classes)), %i, 1) = 1", in_class));
|
||||
}
|
||||
|
||||
if (in_race != 0xFFFFFFFF) {
|
||||
search_criteria.append(StringFormat(" AND MID(REVERSE(BIN(items.races)), %i, 1) = 1", in_race));
|
||||
}
|
||||
|
||||
if (item_slot != 0xFFFFFFFF) {
|
||||
search_criteria.append(StringFormat(" AND MID(REVERSE(BIN(items.slots)), %i, 1) = 1", item_slot + 1));
|
||||
}
|
||||
|
||||
switch (item_type) {
|
||||
case 0xFFFFFFFF:
|
||||
break;
|
||||
case 0:
|
||||
// 1H Slashing
|
||||
search_criteria.append(" AND items.itemtype = 0 AND damage > 0");
|
||||
break;
|
||||
case 31:
|
||||
search_criteria.append(" AND items.itemclass = 2");
|
||||
break;
|
||||
case 46:
|
||||
search_criteria.append(" AND items.scrolleffect > 0 AND items.scrolleffect < 65000");
|
||||
break;
|
||||
case 47:
|
||||
search_criteria.append(" AND items.worneffect = 998");
|
||||
break;
|
||||
case 48:
|
||||
search_criteria.append(" AND items.worneffect >= 1298 AND items.worneffect <= 1307");
|
||||
break;
|
||||
case 49:
|
||||
search_criteria.append(" AND items.focuseffect > 0");
|
||||
break;
|
||||
|
||||
default:
|
||||
search_criteria.append(StringFormat(" AND items.itemtype = %i", item_type));
|
||||
}
|
||||
|
||||
switch (item_stat) {
|
||||
|
||||
case STAT_AC:
|
||||
search_criteria.append(" AND items.ac > 0");
|
||||
search_values.append(", items.ac");
|
||||
break;
|
||||
|
||||
case STAT_AGI:
|
||||
search_criteria.append(" AND items.aagi > 0");
|
||||
search_values.append(", items.aagi");
|
||||
break;
|
||||
|
||||
case STAT_CHA:
|
||||
search_criteria.append(" AND items.acha > 0");
|
||||
search_values.append(", items.acha");
|
||||
break;
|
||||
|
||||
case STAT_DEX:
|
||||
search_criteria.append(" AND items.adex > 0");
|
||||
search_values.append(", items.adex");
|
||||
break;
|
||||
|
||||
case STAT_INT:
|
||||
search_criteria.append(" AND items.aint > 0");
|
||||
search_values.append(", items.aint");
|
||||
break;
|
||||
|
||||
case STAT_STA:
|
||||
search_criteria.append(" AND items.asta > 0");
|
||||
search_values.append(", items.asta");
|
||||
break;
|
||||
|
||||
case STAT_STR:
|
||||
search_criteria.append(" AND items.astr > 0");
|
||||
search_values.append(", items.astr");
|
||||
break;
|
||||
|
||||
case STAT_WIS:
|
||||
search_criteria.append(" AND items.awis > 0");
|
||||
search_values.append(", items.awis");
|
||||
break;
|
||||
|
||||
case STAT_COLD:
|
||||
search_criteria.append(" AND items.cr > 0");
|
||||
search_values.append(", items.cr");
|
||||
break;
|
||||
|
||||
case STAT_DISEASE:
|
||||
search_criteria.append(" AND items.dr > 0");
|
||||
search_values.append(", items.dr");
|
||||
break;
|
||||
|
||||
case STAT_FIRE:
|
||||
search_criteria.append(" AND items.fr > 0");
|
||||
search_values.append(", items.fr");
|
||||
break;
|
||||
|
||||
case STAT_MAGIC:
|
||||
search_criteria.append(" AND items.mr > 0");
|
||||
search_values.append(", items.mr");
|
||||
break;
|
||||
|
||||
case STAT_POISON:
|
||||
search_criteria.append(" AND items.pr > 0");
|
||||
search_values.append(", items.pr");
|
||||
break;
|
||||
|
||||
case STAT_HP:
|
||||
search_criteria.append(" AND items.hp > 0");
|
||||
search_values.append(", items.hp");
|
||||
break;
|
||||
|
||||
case STAT_MANA:
|
||||
search_criteria.append(" AND items.mana > 0");
|
||||
search_values.append(", items.mana");
|
||||
break;
|
||||
|
||||
case STAT_ENDURANCE:
|
||||
search_criteria.append(" AND items.endur > 0");
|
||||
search_values.append(", items.endur");
|
||||
break;
|
||||
|
||||
case STAT_ATTACK:
|
||||
search_criteria.append(" AND items.attack > 0");
|
||||
search_values.append(", items.attack");
|
||||
break;
|
||||
|
||||
case STAT_HP_REGEN:
|
||||
search_criteria.append(" AND items.regen > 0");
|
||||
search_values.append(", items.regen");
|
||||
break;
|
||||
|
||||
case STAT_MANA_REGEN:
|
||||
search_criteria.append(" AND items.manaregen > 0");
|
||||
search_values.append(", items.manaregen");
|
||||
break;
|
||||
|
||||
case STAT_HASTE:
|
||||
search_criteria.append(" AND items.haste > 0");
|
||||
search_values.append(", items.haste");
|
||||
break;
|
||||
|
||||
case STAT_DAMAGE_SHIELD:
|
||||
search_criteria.append(" AND items.damageshield > 0");
|
||||
search_values.append(", items.damageshield");
|
||||
break;
|
||||
|
||||
default:
|
||||
search_values.append(", 0");
|
||||
break;
|
||||
}
|
||||
|
||||
std::string query = StringFormat(
|
||||
"SELECT %s, SUM(charges), items.stackable "
|
||||
"FROM trader, items %s GROUP BY items.id, charges, char_id LIMIT %i",
|
||||
search_values.c_str(),
|
||||
search_criteria.c_str(),
|
||||
RuleI(Bazaar, MaxSearchResults)
|
||||
);
|
||||
|
||||
auto results = database.QueryDatabase(query);
|
||||
|
||||
if (!results.Success()) {
|
||||
return;
|
||||
}
|
||||
|
||||
LogTrading("SRCH: [{}]", query.c_str());
|
||||
|
||||
int Size = 0;
|
||||
uint32 ID = 0;
|
||||
|
||||
if (results.RowCount() == static_cast<unsigned long>(RuleI(Bazaar, MaxSearchResults))) {
|
||||
Message(
|
||||
Chat::Yellow,
|
||||
"Your search reached the limit of %i results. Please narrow your search down by selecting more options.",
|
||||
RuleI(Bazaar, MaxSearchResults));
|
||||
}
|
||||
|
||||
if (results.RowCount() == 0) {
|
||||
auto outapp2 = new EQApplicationPacket(OP_BazaarSearch, sizeof(BazaarReturnDone_Struct));
|
||||
BazaarReturnDone_Struct *brds = (BazaarReturnDone_Struct *) outapp2->pBuffer;
|
||||
brds->TraderID = ID;
|
||||
brds->Type = BazaarSearchDone;
|
||||
brds->Unknown008 = 0xFFFFFFFF;
|
||||
brds->Unknown012 = 0xFFFFFFFF;
|
||||
brds->Unknown016 = 0xFFFFFFFF;
|
||||
QueuePacket(outapp2);
|
||||
safe_delete(outapp2);
|
||||
return;
|
||||
}
|
||||
|
||||
Size = results.RowCount() * sizeof(BazaarSearchResults_Struct);
|
||||
auto buffer = new uchar[Size];
|
||||
uchar *bufptr = buffer;
|
||||
memset(buffer, 0, Size);
|
||||
|
||||
int Action = BazaarSearchResults;
|
||||
uint32 Cost = 0;
|
||||
int32 SerialNumber = 0;
|
||||
char temp_buffer[64] = {0};
|
||||
int Count = 0;
|
||||
uint32 StatValue = 0;
|
||||
|
||||
for (auto &row = results.begin(); row != results.end(); ++row) {
|
||||
VARSTRUCT_ENCODE_TYPE(uint32, bufptr, Action);
|
||||
Count = Strings::ToInt(row[0]);
|
||||
VARSTRUCT_ENCODE_TYPE(uint32, bufptr, Count);
|
||||
SerialNumber = Strings::ToInt(row[3]);
|
||||
VARSTRUCT_ENCODE_TYPE(int32, bufptr, SerialNumber);
|
||||
Client *Trader2 = entity_list.GetClientByCharID(Strings::ToInt(row[1]));
|
||||
if (Trader2) {
|
||||
ID = Trader2->GetID();
|
||||
VARSTRUCT_ENCODE_TYPE(uint32, bufptr, ID);
|
||||
}
|
||||
else {
|
||||
LogTrading("Unable to find trader: [{}]\n", Strings::ToInt(row[1]));
|
||||
VARSTRUCT_ENCODE_TYPE(uint32, bufptr, 0);
|
||||
}
|
||||
Cost = Strings::ToInt(row[5]);
|
||||
VARSTRUCT_ENCODE_TYPE(uint32, bufptr, Cost);
|
||||
StatValue = Strings::ToInt(row[8]);
|
||||
VARSTRUCT_ENCODE_TYPE(uint32, bufptr, StatValue);
|
||||
bool Stackable = Strings::ToInt(row[10]);
|
||||
if (Stackable) {
|
||||
int Charges = Strings::ToInt(row[9]);
|
||||
sprintf(temp_buffer, "%s(%i)", row[7], Charges);
|
||||
}
|
||||
else {
|
||||
sprintf(temp_buffer, "%s(%i)", row[7], Count);
|
||||
}
|
||||
|
||||
memcpy(bufptr, &temp_buffer, strlen(temp_buffer));
|
||||
|
||||
bufptr += 64;
|
||||
|
||||
// Extra fields for SoD+
|
||||
//
|
||||
if (Trader2) {
|
||||
sprintf(temp_buffer, "%s", Trader2->GetName());
|
||||
}
|
||||
else {
|
||||
sprintf(temp_buffer, "Unknown");
|
||||
}
|
||||
|
||||
memcpy(bufptr, &temp_buffer, strlen(temp_buffer));
|
||||
|
||||
bufptr += 64;
|
||||
|
||||
VARSTRUCT_ENCODE_TYPE(uint32, bufptr, Strings::ToInt(row[1])); // ItemID
|
||||
}
|
||||
|
||||
auto outapp = new EQApplicationPacket(OP_BazaarSearch, Size);
|
||||
|
||||
memcpy(outapp->pBuffer, buffer, Size);
|
||||
|
||||
QueuePacket(outapp);
|
||||
|
||||
safe_delete(outapp);
|
||||
safe_delete_array(buffer);
|
||||
|
||||
auto outapp2 = new EQApplicationPacket(OP_BazaarSearch, sizeof(BazaarReturnDone_Struct));
|
||||
BazaarReturnDone_Struct *brds = (BazaarReturnDone_Struct *) outapp2->pBuffer;
|
||||
|
||||
brds->TraderID = ID;
|
||||
brds->Type = BazaarSearchDone;
|
||||
|
||||
brds->Unknown008 = 0xFFFFFFFF;
|
||||
brds->Unknown012 = 0xFFFFFFFF;
|
||||
brds->Unknown016 = 0xFFFFFFFF;
|
||||
|
||||
QueuePacket(outapp2);
|
||||
|
||||
safe_delete(outapp2);
|
||||
}
|
||||
|
||||
static void UpdateTraderCustomerItemsAdded(
|
||||
uint32 customer_id,
|
||||
std::vector<BaseTraderRepository::Trader> trader_items,
|
||||
|
||||
+4
-4
@@ -208,10 +208,10 @@ struct ZoneSpellsBlocked {
|
||||
};
|
||||
|
||||
struct TraderCharges_Struct {
|
||||
uint32 ItemID[EQ::invtype::BAZAAR_SIZE];
|
||||
int32 SerialNumber[EQ::invtype::BAZAAR_SIZE];
|
||||
uint32 ItemCost[EQ::invtype::BAZAAR_SIZE];
|
||||
int32 Charges[EQ::invtype::BAZAAR_SIZE];
|
||||
uint32 ItemID[80];
|
||||
int32 SerialNumber[80];
|
||||
uint32 ItemCost[80];
|
||||
int32 Charges[80];
|
||||
};
|
||||
|
||||
const int MaxMercStanceID = 9;
|
||||
|
||||
Reference in New Issue
Block a user