diff --git a/common/CMakeLists.txt b/common/CMakeLists.txt index 364924971..199091c55 100644 --- a/common/CMakeLists.txt +++ b/common/CMakeLists.txt @@ -230,7 +230,6 @@ SET(repositories repositories/base/base_inventory_snapshots_repository.h repositories/base/base_ip_exemptions_repository.h repositories/base/base_items_repository.h - repositories/base/base_item_tick_repository.h repositories/base/base_ldon_trap_entries_repository.h repositories/base/base_ldon_trap_templates_repository.h repositories/base/base_level_exp_mods_repository.h @@ -408,7 +407,6 @@ SET(repositories repositories/inventory_snapshots_repository.h repositories/ip_exemptions_repository.h repositories/items_repository.h - repositories/item_tick_repository.h repositories/ldon_trap_entries_repository.h repositories/ldon_trap_templates_repository.h repositories/level_exp_mods_repository.h diff --git a/common/repositories/base/base_item_tick_repository.h b/common/repositories/base/base_item_tick_repository.h deleted file mode 100644 index 6f4954f04..000000000 --- a/common/repositories/base/base_item_tick_repository.h +++ /dev/null @@ -1,439 +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_ITEM_TICK_REPOSITORY_H -#define EQEMU_BASE_ITEM_TICK_REPOSITORY_H - -#include "../../database.h" -#include "../../strings.h" -#include - -class BaseItemTickRepository { -public: - struct ItemTick { - int32_t it_itemid; - int32_t it_chance; - int32_t it_level; - int32_t it_id; - std::string it_qglobal; - int8_t it_bagslot; - }; - - static std::string PrimaryKey() - { - return std::string("it_id"); - } - - static std::vector Columns() - { - return { - "it_itemid", - "it_chance", - "it_level", - "it_id", - "it_qglobal", - "it_bagslot", - }; - } - - static std::vector SelectColumns() - { - return { - "it_itemid", - "it_chance", - "it_level", - "it_id", - "it_qglobal", - "it_bagslot", - }; - } - - 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("item_tick"); - } - - static std::string BaseSelect() - { - return fmt::format( - "SELECT {} FROM {}", - SelectColumnsRaw(), - TableName() - ); - } - - static std::string BaseInsert() - { - return fmt::format( - "INSERT INTO {} ({}) ", - TableName(), - ColumnsRaw() - ); - } - - static ItemTick NewEntity() - { - ItemTick e{}; - - e.it_itemid = 0; - e.it_chance = 0; - e.it_level = 0; - e.it_id = 0; - e.it_qglobal = ""; - e.it_bagslot = 0; - - return e; - } - - static ItemTick GetItemTick( - const std::vector &item_ticks, - int item_tick_id - ) - { - for (auto &item_tick : item_ticks) { - if (item_tick.it_id == item_tick_id) { - return item_tick; - } - } - - return NewEntity(); - } - - static ItemTick FindOne( - Database& db, - int item_tick_id - ) - { - auto results = db.QueryDatabase( - fmt::format( - "{} WHERE {} = {} LIMIT 1", - BaseSelect(), - PrimaryKey(), - item_tick_id - ) - ); - - auto row = results.begin(); - if (results.RowCount() == 1) { - ItemTick e{}; - - e.it_itemid = static_cast(atoi(row[0])); - e.it_chance = static_cast(atoi(row[1])); - e.it_level = static_cast(atoi(row[2])); - e.it_id = static_cast(atoi(row[3])); - e.it_qglobal = row[4] ? row[4] : ""; - e.it_bagslot = static_cast(atoi(row[5])); - - return e; - } - - return NewEntity(); - } - - static int DeleteOne( - Database& db, - int item_tick_id - ) - { - auto results = db.QueryDatabase( - fmt::format( - "DELETE FROM {} WHERE {} = {}", - TableName(), - PrimaryKey(), - item_tick_id - ) - ); - - return (results.Success() ? results.RowsAffected() : 0); - } - - static int UpdateOne( - Database& db, - const ItemTick &e - ) - { - std::vector v; - - auto columns = Columns(); - - v.push_back(columns[0] + " = " + std::to_string(e.it_itemid)); - v.push_back(columns[1] + " = " + std::to_string(e.it_chance)); - v.push_back(columns[2] + " = " + std::to_string(e.it_level)); - v.push_back(columns[4] + " = '" + Strings::Escape(e.it_qglobal) + "'"); - v.push_back(columns[5] + " = " + std::to_string(e.it_bagslot)); - - auto results = db.QueryDatabase( - fmt::format( - "UPDATE {} SET {} WHERE {} = {}", - TableName(), - Strings::Implode(", ", v), - PrimaryKey(), - e.it_id - ) - ); - - return (results.Success() ? results.RowsAffected() : 0); - } - - static ItemTick InsertOne( - Database& db, - ItemTick e - ) - { - std::vector v; - - v.push_back(std::to_string(e.it_itemid)); - v.push_back(std::to_string(e.it_chance)); - v.push_back(std::to_string(e.it_level)); - v.push_back(std::to_string(e.it_id)); - v.push_back("'" + Strings::Escape(e.it_qglobal) + "'"); - v.push_back(std::to_string(e.it_bagslot)); - - auto results = db.QueryDatabase( - fmt::format( - "{} VALUES ({})", - BaseInsert(), - Strings::Implode(",", v) - ) - ); - - if (results.Success()) { - e.it_id = results.LastInsertedID(); - return e; - } - - e = NewEntity(); - - return e; - } - - static int InsertMany( - Database& db, - const std::vector &entries - ) - { - std::vector insert_chunks; - - for (auto &e: entries) { - std::vector v; - - v.push_back(std::to_string(e.it_itemid)); - v.push_back(std::to_string(e.it_chance)); - v.push_back(std::to_string(e.it_level)); - v.push_back(std::to_string(e.it_id)); - v.push_back("'" + Strings::Escape(e.it_qglobal) + "'"); - v.push_back(std::to_string(e.it_bagslot)); - - insert_chunks.push_back("(" + Strings::Implode(",", v) + ")"); - } - - std::vector v; - - auto results = db.QueryDatabase( - fmt::format( - "{} VALUES {}", - BaseInsert(), - Strings::Implode(",", insert_chunks) - ) - ); - - return (results.Success() ? results.RowsAffected() : 0); - } - - static std::vector All(Database& db) - { - std::vector all_entries; - - auto results = db.QueryDatabase( - fmt::format( - "{}", - BaseSelect() - ) - ); - - all_entries.reserve(results.RowCount()); - - for (auto row = results.begin(); row != results.end(); ++row) { - ItemTick e{}; - - e.it_itemid = static_cast(atoi(row[0])); - e.it_chance = static_cast(atoi(row[1])); - e.it_level = static_cast(atoi(row[2])); - e.it_id = static_cast(atoi(row[3])); - e.it_qglobal = row[4] ? row[4] : ""; - e.it_bagslot = static_cast(atoi(row[5])); - - all_entries.push_back(e); - } - - return all_entries; - } - - static std::vector GetWhere(Database& db, const std::string &where_filter) - { - std::vector 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) { - ItemTick e{}; - - e.it_itemid = static_cast(atoi(row[0])); - e.it_chance = static_cast(atoi(row[1])); - e.it_level = static_cast(atoi(row[2])); - e.it_id = static_cast(atoi(row[3])); - e.it_qglobal = row[4] ? row[4] : ""; - e.it_bagslot = static_cast(atoi(row[5])); - - 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 ItemTick &e - ) - { - std::vector v; - - v.push_back(std::to_string(e.it_itemid)); - v.push_back(std::to_string(e.it_chance)); - v.push_back(std::to_string(e.it_level)); - v.push_back(std::to_string(e.it_id)); - v.push_back("'" + Strings::Escape(e.it_qglobal) + "'"); - v.push_back(std::to_string(e.it_bagslot)); - - 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 &entries - ) - { - std::vector insert_chunks; - - for (auto &e: entries) { - std::vector v; - - v.push_back(std::to_string(e.it_itemid)); - v.push_back(std::to_string(e.it_chance)); - v.push_back(std::to_string(e.it_level)); - v.push_back(std::to_string(e.it_id)); - v.push_back("'" + Strings::Escape(e.it_qglobal) + "'"); - v.push_back(std::to_string(e.it_bagslot)); - - insert_chunks.push_back("(" + Strings::Implode(",", v) + ")"); - } - - std::vector v; - - auto results = db.QueryDatabase( - fmt::format( - "{} VALUES {}", - BaseReplace(), - Strings::Implode(",", insert_chunks) - ) - ); - - return (results.Success() ? results.RowsAffected() : 0); - } -}; - -#endif //EQEMU_BASE_ITEM_TICK_REPOSITORY_H diff --git a/common/repositories/item_tick_repository.h b/common/repositories/item_tick_repository.h deleted file mode 100644 index 352595ac5..000000000 --- a/common/repositories/item_tick_repository.h +++ /dev/null @@ -1,50 +0,0 @@ -#ifndef EQEMU_ITEM_TICK_REPOSITORY_H -#define EQEMU_ITEM_TICK_REPOSITORY_H - -#include "../database.h" -#include "../strings.h" -#include "base/base_item_tick_repository.h" - -class ItemTickRepository: public BaseItemTickRepository { -public: - - /** - * 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 - * - * ItemTickRepository::GetByZoneAndVersion(int zone_id, int zone_version) - * ItemTickRepository::GetWhereNeverExpires() - * ItemTickRepository::GetWhereXAndY() - * ItemTickRepository::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 - */ - - // Custom extended repository methods here - -}; - -#endif //EQEMU_ITEM_TICK_REPOSITORY_H diff --git a/zone/client.cpp b/zone/client.cpp index 94a1ccb81..e0ca92977 100644 --- a/zone/client.cpp +++ b/zone/client.cpp @@ -165,7 +165,6 @@ Client::Client(EQStreamInterface *ieqs) : Mob( TrackingTimer(2000), RespawnFromHoverTimer(0), merc_timer(RuleI(Mercs, UpkeepIntervalMS)), - ItemTickTimer(10000), ItemQuestTimer(500), anon_toggle_timer(250), afk_toggle_timer(250), @@ -6568,7 +6567,7 @@ void Client::SendAltCurrencies() { if (!currency_count) { return; } - + auto outapp = new EQApplicationPacket( OP_AltCurrency, sizeof(AltCurrencyPopulate_Struct) + @@ -7744,68 +7743,6 @@ std::vector Client::GetAccountFlags() return l; } -void Client::TickItemCheck() -{ - int i; - - if(zone->tick_items.empty()) { return; } - - //Scan equip, general, cursor slots for items - for (i = EQ::invslot::POSSESSIONS_BEGIN; i <= EQ::invslot::POSSESSIONS_END; i++) - { - TryItemTick(i); - } - //Scan bags - for (i = EQ::invbag::GENERAL_BAGS_BEGIN; i <= EQ::invbag::CURSOR_BAG_END; i++) - { - TryItemTick(i); - } -} - -void Client::TryItemTick(int slot) -{ - int iid = 0; - const EQ::ItemInstance* inst = m_inv[slot]; - if(inst == 0) { return; } - - iid = inst->GetID(); - - if(zone->tick_items.count(iid) > 0) - { - if (GetLevel() >= zone->tick_items[iid].level && zone->random.Int(0, 100) >= (100 - zone->tick_items[iid].chance) && (zone->tick_items[iid].bagslot || slot <= EQ::invslot::EQUIPMENT_END)) - { - EQ::ItemInstance* e_inst = (EQ::ItemInstance*)inst; - - if (parse->ItemHasQuestSub(e_inst, EVENT_ITEM_TICK)) { - parse->EventItem(EVENT_ITEM_TICK, this, e_inst, nullptr, "", slot); - } - } - } - - //Only look at augs in main inventory - if (slot > EQ::invslot::EQUIPMENT_END) { return; } - - for (int x = EQ::invaug::SOCKET_BEGIN; x <= EQ::invaug::SOCKET_END; ++x) - { - EQ::ItemInstance * a_inst = inst->GetAugment(x); - if(!a_inst) { continue; } - - iid = a_inst->GetID(); - - if(zone->tick_items.count(iid) > 0) - { - if( GetLevel() >= zone->tick_items[iid].level && zone->random.Int(0, 100) >= (100 - zone->tick_items[iid].chance) ) - { - EQ::ItemInstance* e_inst = (EQ::ItemInstance*) a_inst; - - if (parse->ItemHasQuestSub(e_inst, EVENT_ITEM_TICK)) { - parse->EventItem(EVENT_ITEM_TICK, this, e_inst, nullptr, "", slot); - } - } - } - } -} - void Client::ItemTimerCheck() { int i; diff --git a/zone/client.h b/zone/client.h index 9f168ed79..a44968ca6 100644 --- a/zone/client.h +++ b/zone/client.h @@ -1590,8 +1590,6 @@ public: void DuplicateLoreMessage(uint32 ItemID); void GarbleMessage(char *, uint8); - void TickItemCheck(); - void TryItemTick(int slot); void ItemTimerCheck(); void TryItemTimer(int slot); void SendItemScale(EQ::ItemInstance *inst); @@ -2008,7 +2006,6 @@ private: AggroMeter m_aggrometer; - Timer ItemTickTimer; Timer ItemQuestTimer; std::map accountflags; diff --git a/zone/client_process.cpp b/zone/client_process.cpp index 9510187bb..f1d4a5886 100644 --- a/zone/client_process.cpp +++ b/zone/client_process.cpp @@ -525,11 +525,6 @@ bool Client::Process() { CalcBonuses(); } - if (ItemTickTimer.Check()) - { - TickItemCheck(); - } - if (ItemQuestTimer.Check()) { ItemTimerCheck(); diff --git a/zone/event_codes.h b/zone/event_codes.h index 056a23ef1..50c5bbab4 100644 --- a/zone/event_codes.h +++ b/zone/event_codes.h @@ -61,7 +61,7 @@ typedef enum { EVENT_DISCOVER_ITEM, EVENT_DISCONNECT, EVENT_CONNECT, - EVENT_ITEM_TICK, + EVENT_ITEM_TICK, // Unused, keeping so event IDs don't get out of wack EVENT_DUEL_WIN, EVENT_DUEL_LOSE, EVENT_ENCOUNTER_LOAD, diff --git a/zone/lua_general.cpp b/zone/lua_general.cpp index bc3b23623..da3352c16 100644 --- a/zone/lua_general.cpp +++ b/zone/lua_general.cpp @@ -6547,7 +6547,6 @@ luabind::scope lua_register_events() { luabind::value("discover_item", static_cast(EVENT_DISCOVER_ITEM)), luabind::value("disconnect", static_cast(EVENT_DISCONNECT)), luabind::value("connect", static_cast(EVENT_CONNECT)), - luabind::value("item_tick", static_cast(EVENT_ITEM_TICK)), luabind::value("duel_win", static_cast(EVENT_DUEL_WIN)), luabind::value("duel_lose", static_cast(EVENT_DUEL_LOSE)), luabind::value("encounter_load", static_cast(EVENT_ENCOUNTER_LOAD)), diff --git a/zone/zone.cpp b/zone/zone.cpp index f9b078aa3..9cef7ed9d 100644 --- a/zone/zone.cpp +++ b/zone/zone.cpp @@ -1219,7 +1219,6 @@ bool Zone::Init(bool is_static) { LogInfo("Zone booted successfully zone_id [{}] time_offset [{}]", zoneid, zone_time.getEQTimeZone()); LoadGrids(); - LoadTickItems(); npc_scale_manager->LoadScaleData(); @@ -2664,34 +2663,6 @@ void Zone::ClearSpawnTimers() ); } -void Zone::LoadTickItems() -{ - tick_items.clear(); - - const std::string query = "SELECT it_itemid, it_chance, it_level, it_qglobal, it_bagslot FROM item_tick"; - auto results = database.QueryDatabase(query); - if (!results.Success()) { - return; - } - - - for (auto row = results.begin(); row != results.end(); ++row) { - if(Strings::ToInt(row[0]) == 0) - continue; - - item_tick_struct ti_tmp; - ti_tmp.itemid = Strings::ToInt(row[0]); - ti_tmp.chance = Strings::ToInt(row[1]); - ti_tmp.level = Strings::ToInt(row[2]); - ti_tmp.bagslot = (int16)Strings::ToInt(row[4]); - ti_tmp.qglobal = std::string(row[3]); - tick_items[Strings::ToInt(row[0])] = ti_tmp; - - } - - LogInfo("Loaded [{}] item_tick entries", Strings::Commify(results.RowCount())); -} - uint32 Zone::GetSpawnKillCount(uint32 in_spawnid) { LinkedListIterator iterator(spawn2_list); diff --git a/zone/zone.h b/zone/zone.h index be7a9239f..525603302 100755 --- a/zone/zone.h +++ b/zone/zone.h @@ -77,14 +77,6 @@ struct ZoneEXPModInfo { float AAExpMod; }; -struct item_tick_struct { - uint32 itemid; - uint32 chance; - uint32 level; - int16 bagslot; - std::string qglobal; -}; - class Client; class Expedition; class Map; @@ -219,7 +211,6 @@ public: std::pair GetAlternateAdvancementAbilityAndRank(int id, int points_spent); - std::unordered_map tick_items; std::unordered_map> aa_abilities; std::unordered_map> aa_ranks; @@ -285,7 +276,6 @@ public: void LoadNewMerchantData(uint32 merchantid); void LoadNPCEmotes(std::vector *NPCEmoteList); void LoadTempMerchantData(); - void LoadTickItems(); void LoadVeteranRewards(); void LoadZoneDoors(); void ReloadStaticData();