diff --git a/common/CMakeLists.txt b/common/CMakeLists.txt index 5aa76fac9..fadcea7c3 100644 --- a/common/CMakeLists.txt +++ b/common/CMakeLists.txt @@ -1,766 +1,775 @@ CMAKE_MINIMUM_REQUIRED(VERSION 3.2) SET(common_sources - base_packet.cpp - classes.cpp - cli/eqemu_command_handler.cpp - compression.cpp - condition.cpp - content/world_content_service.cpp - discord/discord.cpp - crash.cpp - crc16.cpp - crc32.cpp - database/database_dump_service.cpp - database.cpp - database_conversions.cpp - database_instances.cpp - dbcore.cpp - deity.cpp - dynamic_zone_base.cpp - emu_constants.cpp - emu_limits.cpp - emu_opcodes.cpp - emu_versions.cpp - eqdb.cpp - eqdb_res.cpp - eqemu_exception.cpp - eqemu_config.cpp - eqemu_logsys.cpp - eq_limits.cpp - eq_packet.cpp - eq_stream_ident.cpp - eq_stream_proxy.cpp - eqtime.cpp - event_sub.cpp - expedition_lockout_timer.cpp - extprofile.cpp - discord_manager.cpp - faction.cpp - file_util.cpp - guild_base.cpp - guilds.cpp - inventory_profile.cpp - inventory_slot.cpp - ipc_mutex.cpp - ip_util.cpp - item_data.cpp - item_instance.cpp - json_config.cpp - light_source.cpp - md5.cpp - memory_buffer.cpp - memory_mapped_file.cpp - misc.cpp - misc_functions.cpp - mutex.cpp - mysql_request_result.cpp - mysql_request_row.cpp - opcode_map.cpp - opcodemgr.cpp - packet_dump.cpp - packet_dump_file.cpp - packet_functions.cpp - perl_eqdb.cpp - perl_eqdb_res.cpp - proc_launcher.cpp - profanity_manager.cpp - ptimer.cpp - races.cpp - rdtsc.cpp - rulesys.cpp - say_link.cpp - serialize_buffer.cpp - server_event_scheduler.cpp - serverinfo.cpp - shared_tasks.cpp - shareddb.cpp - skills.cpp - spdat.cpp - strings.cpp - struct_strategy.cpp - textures.cpp - timer.cpp - unix.cpp - platform.cpp - json/jsoncpp.cpp - net/console_server.cpp - net/console_server_connection.cpp - net/crc32.cpp - net/daybreak_connection.cpp - net/eqstream.cpp - net/packet.cpp - net/servertalk_client_connection.cpp - net/servertalk_legacy_client_connection.cpp - net/servertalk_server.cpp - net/servertalk_server_connection.cpp - net/tcp_connection.cpp - net/tcp_server.cpp - net/websocket_server.cpp - net/websocket_server_connection.cpp - patches/patches.cpp - patches/sod.cpp - patches/sod_limits.cpp - patches/sof.cpp - patches/sof_limits.cpp - patches/rof.cpp - patches/rof_limits.cpp - patches/rof2.cpp - patches/rof2_limits.cpp - patches/titanium.cpp - patches/titanium_limits.cpp - patches/uf.cpp - patches/uf_limits.cpp - StackWalker/StackWalker.cpp - util/directory.cpp - util/uuid.cpp) + base_packet.cpp + classes.cpp + cli/eqemu_command_handler.cpp + compression.cpp + condition.cpp + content/world_content_service.cpp + discord/discord.cpp + crash.cpp + crc16.cpp + crc32.cpp + database/database_dump_service.cpp + database.cpp + database_conversions.cpp + database_instances.cpp + dbcore.cpp + deity.cpp + dynamic_zone_base.cpp + emu_constants.cpp + emu_limits.cpp + emu_opcodes.cpp + emu_versions.cpp + eqdb.cpp + eqdb_res.cpp + eqemu_exception.cpp + eqemu_config.cpp + eqemu_logsys.cpp + eq_limits.cpp + eq_packet.cpp + eq_stream_ident.cpp + eq_stream_proxy.cpp + eqtime.cpp + event_sub.cpp + expedition_lockout_timer.cpp + extprofile.cpp + discord_manager.cpp + faction.cpp + file_util.cpp + guild_base.cpp + guilds.cpp + inventory_profile.cpp + inventory_slot.cpp + ipc_mutex.cpp + ip_util.cpp + item_data.cpp + item_instance.cpp + json_config.cpp + light_source.cpp + md5.cpp + memory_buffer.cpp + memory_mapped_file.cpp + misc.cpp + misc_functions.cpp + mutex.cpp + mysql_request_result.cpp + mysql_request_row.cpp + opcode_map.cpp + opcodemgr.cpp + packet_dump.cpp + packet_dump_file.cpp + packet_functions.cpp + perl_eqdb.cpp + perl_eqdb_res.cpp + proc_launcher.cpp + profanity_manager.cpp + ptimer.cpp + races.cpp + rdtsc.cpp + rulesys.cpp + say_link.cpp + serialize_buffer.cpp + server_event_scheduler.cpp + serverinfo.cpp + shared_tasks.cpp + shareddb.cpp + skills.cpp + spdat.cpp + strings.cpp + struct_strategy.cpp + textures.cpp + timer.cpp + unix.cpp + platform.cpp + json/jsoncpp.cpp + net/console_server.cpp + net/console_server_connection.cpp + net/crc32.cpp + net/daybreak_connection.cpp + net/eqstream.cpp + net/packet.cpp + net/servertalk_client_connection.cpp + net/servertalk_legacy_client_connection.cpp + net/servertalk_server.cpp + net/servertalk_server_connection.cpp + net/tcp_connection.cpp + net/tcp_server.cpp + net/websocket_server.cpp + net/websocket_server_connection.cpp + patches/patches.cpp + patches/sod.cpp + patches/sod_limits.cpp + patches/sof.cpp + patches/sof_limits.cpp + patches/rof.cpp + patches/rof_limits.cpp + patches/rof2.cpp + patches/rof2_limits.cpp + patches/titanium.cpp + patches/titanium_limits.cpp + patches/uf.cpp + patches/uf_limits.cpp + StackWalker/StackWalker.cpp + util/directory.cpp + util/uuid.cpp) SET(repositories - # Criteria - repositories/criteria/content_filter_criteria.h + # Criteria + repositories/criteria/content_filter_criteria.h - # Base Repositories - repositories/base/base_aa_ability_repository.h - repositories/base/base_aa_ranks_repository.h - repositories/base/base_aa_rank_effects_repository.h - repositories/base/base_aa_rank_prereqs_repository.h - repositories/base/base_account_repository.h - repositories/base/base_account_flags_repository.h - repositories/base/base_account_ip_repository.h - repositories/base/base_account_rewards_repository.h - repositories/base/base_adventure_details_repository.h - repositories/base/base_adventure_members_repository.h - repositories/base/base_adventure_stats_repository.h - repositories/base/base_adventure_template_repository.h - repositories/base/base_adventure_template_entry_repository.h - repositories/base/base_adventure_template_entry_flavor_repository.h - repositories/base/base_alternate_currency_repository.h - repositories/base/base_auras_repository.h - repositories/base/base_base_data_repository.h - repositories/base/base_blocked_spells_repository.h - repositories/base/base_bugs_repository.h - repositories/base/base_bug_reports_repository.h - repositories/base/base_buyer_repository.h - repositories/base/base_character_activities_repository.h - repositories/base/base_character_alternate_abilities_repository.h - repositories/base/base_character_alt_currency_repository.h - repositories/base/base_character_auras_repository.h - repositories/base/base_character_bandolier_repository.h - repositories/base/base_character_bind_repository.h - repositories/base/base_character_buffs_repository.h - repositories/base/base_character_corpses_repository.h - repositories/base/base_character_corpse_items_repository.h - repositories/base/base_character_currency_repository.h - repositories/base/base_character_data_repository.h - repositories/base/base_character_disciplines_repository.h - repositories/base/base_character_expedition_lockouts_repository.h - repositories/base/base_character_inspect_messages_repository.h - repositories/base/base_character_instance_safereturns_repository.h - repositories/base/base_character_item_recast_repository.h - repositories/base/base_character_languages_repository.h - repositories/base/base_character_leadership_abilities_repository.h - repositories/base/base_character_material_repository.h - repositories/base/base_character_memmed_spells_repository.h - repositories/base/base_character_pet_buffs_repository.h - repositories/base/base_character_pet_info_repository.h - repositories/base/base_character_pet_inventory_repository.h - repositories/base/base_character_potionbelt_repository.h - repositories/base/base_character_skills_repository.h - repositories/base/base_character_spells_repository.h - repositories/base/base_character_task_timers_repository.h - repositories/base/base_character_tasks_repository.h - repositories/base/base_char_create_combinations_repository.h - repositories/base/base_char_create_point_allocations_repository.h - repositories/base/base_char_recipe_list_repository.h - repositories/base/base_completed_tasks_repository.h - repositories/base/base_completed_shared_tasks_repository.h - repositories/base/base_completed_shared_task_members_repository.h - repositories/base/base_completed_shared_task_activity_state_repository.h - repositories/base/base_content_flags_repository.h - repositories/base/base_damageshieldtypes_repository.h - repositories/base/base_data_buckets_repository.h - repositories/base/base_db_str_repository.h - repositories/base/base_discovered_items_repository.h - repositories/base/base_doors_repository.h - repositories/base/base_dynamic_zones_repository.h - repositories/base/base_dynamic_zone_members_repository.h - repositories/base/base_dynamic_zone_templates_repository.h - repositories/base/base_eventlog_repository.h - repositories/base/base_expeditions_repository.h - repositories/base/base_expedition_lockouts_repository.h - repositories/base/base_faction_base_data_repository.h - repositories/base/base_faction_list_repository.h - repositories/base/base_faction_list_mod_repository.h - repositories/base/base_faction_values_repository.h - repositories/base/base_fishing_repository.h - repositories/base/base_forage_repository.h - repositories/base/base_friends_repository.h - repositories/base/base_global_loot_repository.h - repositories/base/base_gm_ips_repository.h - repositories/base/base_goallists_repository.h - repositories/base/base_graveyard_repository.h - repositories/base/base_grid_repository.h - repositories/base/base_grid_entries_repository.h - repositories/base/base_ground_spawns_repository.h - repositories/base/base_group_id_repository.h - repositories/base/base_group_leaders_repository.h - repositories/base/base_guilds_repository.h - repositories/base/base_guild_members_repository.h - repositories/base/base_guild_ranks_repository.h - repositories/base/base_guild_relations_repository.h - repositories/base/base_hackers_repository.h - repositories/base/base_instance_list_repository.h - repositories/base/base_instance_list_player_repository.h - repositories/base/base_inventory_repository.h - 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 - repositories/base/base_lfguild_repository.h - repositories/base/base_login_accounts_repository.h - repositories/base/base_login_api_tokens_repository.h - repositories/base/base_login_server_admins_repository.h - repositories/base/base_login_server_list_types_repository.h - repositories/base/base_login_world_servers_repository.h - repositories/base/base_logsys_categories_repository.h - repositories/base/base_lootdrop_repository.h - repositories/base/base_lootdrop_entries_repository.h - repositories/base/base_loottable_repository.h - repositories/base/base_loottable_entries_repository.h - repositories/base/base_mail_repository.h - repositories/base/base_merchantlist_repository.h - repositories/base/base_merchantlist_temp_repository.h - repositories/base/base_name_filter_repository.h - repositories/base/base_npc_emotes_repository.h - repositories/base/base_npc_faction_repository.h - repositories/base/base_npc_faction_entries_repository.h - repositories/base/base_npc_scale_global_base_repository.h - repositories/base/base_npc_spells_repository.h - repositories/base/base_npc_spells_effects_repository.h - repositories/base/base_npc_spells_effects_entries_repository.h - repositories/base/base_npc_spells_entries_repository.h - repositories/base/base_npc_types_repository.h - repositories/base/base_npc_types_tint_repository.h - repositories/base/base_object_repository.h - repositories/base/base_object_contents_repository.h - repositories/base/base_perl_event_export_settings_repository.h - repositories/base/base_petitions_repository.h - repositories/base/base_pets_repository.h - repositories/base/base_pets_equipmentset_repository.h - repositories/base/base_pets_equipmentset_entries_repository.h - repositories/base/base_player_titlesets_repository.h - repositories/base/base_proximities_repository.h - repositories/base/base_quest_globals_repository.h - repositories/base/base_raid_details_repository.h - repositories/base/base_raid_members_repository.h - repositories/base/base_reports_repository.h - repositories/base/base_respawn_times_repository.h - repositories/base/base_rule_sets_repository.h - repositories/base/base_rule_values_repository.h - repositories/base/base_saylink_repository.h - repositories/base/base_server_scheduled_events_repository.h - repositories/base/base_shared_tasks_repository.h - repositories/base/base_shared_task_activity_state_repository.h - repositories/base/base_shared_task_dynamic_zones_repository.h - repositories/base/base_shared_task_members_repository.h - repositories/base/base_skill_caps_repository.h - repositories/base/base_spawn2_repository.h - repositories/base/base_spawnentry_repository.h - repositories/base/base_spawngroup_repository.h - repositories/base/base_spawn_conditions_repository.h - repositories/base/base_spawn_condition_values_repository.h - repositories/base/base_spawn_events_repository.h - repositories/base/base_spells_new_repository.h - repositories/base/base_spell_buckets_repository.h - repositories/base/base_spell_globals_repository.h - repositories/base/base_starting_items_repository.h - repositories/base/base_start_zones_repository.h - repositories/base/base_tasks_repository.h - repositories/base/base_tasksets_repository.h - repositories/base/base_task_activities_repository.h - repositories/base/base_timers_repository.h - repositories/base/base_titles_repository.h - repositories/base/base_trader_repository.h - repositories/base/base_tradeskill_recipe_repository.h - repositories/base/base_tradeskill_recipe_entries_repository.h - repositories/base/base_traps_repository.h - repositories/base/base_tributes_repository.h - repositories/base/base_tribute_levels_repository.h - repositories/base/base_veteran_reward_templates_repository.h - repositories/base/base_zone_repository.h - repositories/base/base_zone_points_repository.h + repositories/base/base_grid_repository.h + repositories/base/base_grid_entries_repository.h - # Extended Repositories - repositories/aa_ability_repository.h - repositories/aa_ranks_repository.h - repositories/aa_rank_effects_repository.h - repositories/aa_rank_prereqs_repository.h - repositories/account_repository.h - repositories/account_flags_repository.h - repositories/account_ip_repository.h - repositories/account_rewards_repository.h - repositories/adventure_details_repository.h - repositories/adventure_members_repository.h - repositories/adventure_stats_repository.h - repositories/adventure_template_repository.h - repositories/adventure_template_entry_repository.h - repositories/adventure_template_entry_flavor_repository.h - repositories/alternate_currency_repository.h - repositories/auras_repository.h - repositories/base_data_repository.h - repositories/blocked_spells_repository.h - repositories/bugs_repository.h - repositories/bug_reports_repository.h - repositories/buyer_repository.h - repositories/character_activities_repository.h - repositories/character_alternate_abilities_repository.h - repositories/character_alt_currency_repository.h - repositories/character_auras_repository.h - repositories/character_bandolier_repository.h - repositories/character_bind_repository.h - repositories/character_buffs_repository.h - repositories/character_corpses_repository.h - repositories/character_corpse_items_repository.h - repositories/character_currency_repository.h - repositories/character_data_repository.h - repositories/character_disciplines_repository.h - repositories/character_expedition_lockouts_repository.h - repositories/character_inspect_messages_repository.h - repositories/character_instance_safereturns_repository.h - repositories/character_item_recast_repository.h - repositories/character_languages_repository.h - repositories/character_leadership_abilities_repository.h - repositories/character_material_repository.h - repositories/character_memmed_spells_repository.h - repositories/character_pet_buffs_repository.h - repositories/character_pet_info_repository.h - repositories/character_pet_inventory_repository.h - repositories/character_potionbelt_repository.h - repositories/character_skills_repository.h - repositories/character_spells_repository.h - repositories/character_task_timers_repository.h - repositories/character_tasks_repository.h - repositories/char_create_combinations_repository.h - repositories/char_create_point_allocations_repository.h - repositories/char_recipe_list_repository.h - repositories/completed_tasks_repository.h - repositories/completed_shared_tasks_repository.h - repositories/completed_shared_task_members_repository.h - repositories/completed_shared_task_activity_state_repository.h - repositories/content_flags_repository.h - repositories/damageshieldtypes_repository.h - repositories/data_buckets_repository.h - repositories/db_str_repository.h - repositories/discovered_items_repository.h - repositories/doors_repository.h - repositories/dynamic_zones_repository.h - repositories/dynamic_zone_members_repository.h - repositories/dynamic_zone_templates_repository.h - repositories/eventlog_repository.h - repositories/expeditions_repository.h - repositories/expedition_lockouts_repository.h - repositories/faction_base_data_repository.h - repositories/faction_list_repository.h - repositories/faction_list_mod_repository.h - repositories/faction_values_repository.h - repositories/fishing_repository.h - repositories/forage_repository.h - repositories/friends_repository.h - repositories/global_loot_repository.h - repositories/gm_ips_repository.h - repositories/goallists_repository.h - repositories/graveyard_repository.h - repositories/grid_repository.h - repositories/grid_entries_repository.h - repositories/ground_spawns_repository.h - repositories/group_id_repository.h - repositories/group_leaders_repository.h - repositories/guilds_repository.h - repositories/guild_members_repository.h - repositories/guild_ranks_repository.h - repositories/guild_relations_repository.h - repositories/hackers_repository.h - repositories/instance_list_repository.h - repositories/instance_list_player_repository.h - repositories/inventory_repository.h - 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 - repositories/lfguild_repository.h - repositories/login_accounts_repository.h - repositories/login_api_tokens_repository.h - repositories/login_server_admins_repository.h - repositories/login_server_list_types_repository.h - repositories/login_world_servers_repository.h - repositories/logsys_categories_repository.h - repositories/lootdrop_repository.h - repositories/lootdrop_entries_repository.h - repositories/loottable_repository.h - repositories/loottable_entries_repository.h - repositories/mail_repository.h - repositories/merchantlist_repository.h - repositories/merchantlist_temp_repository.h - repositories/name_filter_repository.h - repositories/npc_emotes_repository.h - repositories/npc_faction_repository.h - repositories/npc_faction_entries_repository.h - repositories/npc_scale_global_base_repository.h - repositories/npc_spells_repository.h - repositories/npc_spells_effects_repository.h - repositories/npc_spells_effects_entries_repository.h - repositories/npc_spells_entries_repository.h - repositories/npc_types_repository.h - repositories/npc_types_tint_repository.h - repositories/object_repository.h - repositories/object_contents_repository.h - repositories/perl_event_export_settings_repository.h - repositories/petitions_repository.h - repositories/pets_repository.h - repositories/pets_equipmentset_repository.h - repositories/pets_equipmentset_entries_repository.h - repositories/player_titlesets_repository.h - repositories/proximities_repository.h - repositories/quest_globals_repository.h - repositories/raid_details_repository.h - repositories/raid_members_repository.h - repositories/reports_repository.h - repositories/respawn_times_repository.h - repositories/rule_sets_repository.h - repositories/rule_values_repository.h - repositories/saylink_repository.h - repositories/server_scheduled_events_repository.h - repositories/shared_tasks_repository.h - repositories/shared_task_activity_state_repository.h - repositories/shared_task_dynamic_zones_repository.h - repositories/shared_task_members_repository.h - repositories/skill_caps_repository.h - repositories/spawn2_repository.h - repositories/spawnentry_repository.h - repositories/spawngroup_repository.h - repositories/spawn_conditions_repository.h - repositories/spawn_condition_values_repository.h - repositories/spawn_events_repository.h - repositories/spells_new_repository.h - repositories/spell_buckets_repository.h - repositories/spell_globals_repository.h - repositories/starting_items_repository.h - repositories/start_zones_repository.h - repositories/tasks_repository.h - repositories/tasksets_repository.h - repositories/task_activities_repository.h - repositories/timers_repository.h - repositories/titles_repository.h - repositories/trader_repository.h - repositories/tradeskill_recipe_repository.h - repositories/tradeskill_recipe_entries_repository.h - repositories/traps_repository.h - repositories/tributes_repository.h - repositories/tribute_levels_repository.h - repositories/veteran_reward_templates_repository.h - repositories/zone_repository.h - repositories/zone_points_repository.h + # Base Repositories + repositories/base/base_aa_ability_repository.h + repositories/base/base_aa_ranks_repository.h + repositories/base/base_aa_rank_effects_repository.h + repositories/base/base_aa_rank_prereqs_repository.h + repositories/base/base_account_repository.h + repositories/base/base_account_flags_repository.h + repositories/base/base_account_ip_repository.h + repositories/base/base_account_rewards_repository.h + repositories/base/base_adventure_details_repository.h + repositories/base/base_adventure_members_repository.h + repositories/base/base_adventure_stats_repository.h + repositories/base/base_adventure_template_repository.h + repositories/base/base_adventure_template_entry_repository.h + repositories/base/base_adventure_template_entry_flavor_repository.h + repositories/base/base_alternate_currency_repository.h + repositories/base/base_auras_repository.h + repositories/base/base_base_data_repository.h + repositories/base/base_blocked_spells_repository.h + repositories/base/base_books_repository.h + repositories/base/base_bugs_repository.h + repositories/base/base_bug_reports_repository.h + repositories/base/base_buyer_repository.h + repositories/base/base_character_activities_repository.h + repositories/base/base_character_alternate_abilities_repository.h + repositories/base/base_character_alt_currency_repository.h + repositories/base/base_character_auras_repository.h + repositories/base/base_character_bandolier_repository.h + repositories/base/base_character_bind_repository.h + repositories/base/base_character_buffs_repository.h + repositories/base/base_character_corpses_repository.h + repositories/base/base_character_corpse_items_repository.h + repositories/base/base_character_currency_repository.h + repositories/base/base_character_data_repository.h + repositories/base/base_character_disciplines_repository.h + repositories/base/base_character_expedition_lockouts_repository.h + repositories/base/base_character_exp_modifiers_repository.h + repositories/base/base_character_inspect_messages_repository.h + repositories/base/base_character_instance_safereturns_repository.h + repositories/base/base_character_item_recast_repository.h + repositories/base/base_character_languages_repository.h + repositories/base/base_character_leadership_abilities_repository.h + repositories/base/base_character_material_repository.h + repositories/base/base_character_memmed_spells_repository.h + repositories/base/base_character_peqzone_flags_repository.h + repositories/base/base_character_pet_buffs_repository.h + repositories/base/base_character_pet_info_repository.h + repositories/base/base_character_pet_inventory_repository.h + repositories/base/base_character_potionbelt_repository.h + repositories/base/base_character_skills_repository.h + repositories/base/base_character_spells_repository.h + repositories/base/base_character_tasks_repository.h + repositories/base/base_character_task_timers_repository.h + repositories/base/base_char_create_combinations_repository.h + repositories/base/base_char_create_point_allocations_repository.h + repositories/base/base_char_recipe_list_repository.h + repositories/base/base_completed_shared_tasks_repository.h + repositories/base/base_completed_shared_task_activity_state_repository.h + repositories/base/base_completed_shared_task_members_repository.h + repositories/base/base_completed_tasks_repository.h + repositories/base/base_content_flags_repository.h + repositories/base/base_damageshieldtypes_repository.h + repositories/base/base_data_buckets_repository.h + repositories/base/base_db_str_repository.h + repositories/base/base_discord_webhooks_repository.h + repositories/base/base_discovered_items_repository.h + repositories/base/base_doors_repository.h + repositories/base/base_dynamic_zones_repository.h + repositories/base/base_dynamic_zone_members_repository.h + repositories/base/base_dynamic_zone_templates_repository.h + repositories/base/base_eventlog_repository.h + repositories/base/base_expeditions_repository.h + repositories/base/base_expedition_lockouts_repository.h + repositories/base/base_faction_base_data_repository.h + repositories/base/base_faction_list_repository.h + repositories/base/base_faction_list_mod_repository.h + repositories/base/base_faction_values_repository.h + repositories/base/base_fishing_repository.h + repositories/base/base_forage_repository.h + repositories/base/base_friends_repository.h + repositories/base/base_global_loot_repository.h + repositories/base/base_gm_ips_repository.h + repositories/base/base_goallists_repository.h + repositories/base/base_graveyard_repository.h + repositories/base/base_ground_spawns_repository.h + repositories/base/base_group_id_repository.h + repositories/base/base_group_leaders_repository.h + repositories/base/base_guilds_repository.h + repositories/base/base_guild_ranks_repository.h + repositories/base/base_guild_relations_repository.h + repositories/base/base_hackers_repository.h + repositories/base/base_horses_repository.h + repositories/base/base_instance_list_repository.h + repositories/base/base_instance_list_player_repository.h + repositories/base/base_inventory_repository.h + 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 + repositories/base/base_lfguild_repository.h + repositories/base/base_login_accounts_repository.h + repositories/base/base_login_api_tokens_repository.h + repositories/base/base_login_server_admins_repository.h + repositories/base/base_login_server_list_types_repository.h + repositories/base/base_login_world_servers_repository.h + repositories/base/base_logsys_categories_repository.h + repositories/base/base_lootdrop_repository.h + repositories/base/base_lootdrop_entries_repository.h + repositories/base/base_loottable_repository.h + repositories/base/base_loottable_entries_repository.h + repositories/base/base_mail_repository.h + repositories/base/base_merchantlist_repository.h + repositories/base/base_merchantlist_temp_repository.h + repositories/base/base_name_filter_repository.h + repositories/base/base_npc_emotes_repository.h + repositories/base/base_npc_faction_repository.h + repositories/base/base_npc_faction_entries_repository.h + repositories/base/base_npc_scale_global_base_repository.h + repositories/base/base_npc_spells_repository.h + repositories/base/base_npc_spells_effects_repository.h + repositories/base/base_npc_spells_effects_entries_repository.h + repositories/base/base_npc_spells_entries_repository.h + repositories/base/base_npc_types_repository.h + repositories/base/base_npc_types_tint_repository.h + repositories/base/base_object_repository.h + repositories/base/base_object_contents_repository.h + repositories/base/base_perl_event_export_settings_repository.h + repositories/base/base_petitions_repository.h + repositories/base/base_pets_repository.h + repositories/base/base_pets_beastlord_data_repository.h + repositories/base/base_pets_equipmentset_repository.h + repositories/base/base_pets_equipmentset_entries_repository.h + repositories/base/base_player_titlesets_repository.h + repositories/base/base_proximities_repository.h + repositories/base/base_quest_globals_repository.h + repositories/base/base_raid_details_repository.h + repositories/base/base_raid_members_repository.h + repositories/base/base_reports_repository.h + repositories/base/base_respawn_times_repository.h + repositories/base/base_rule_sets_repository.h + repositories/base/base_rule_values_repository.h + repositories/base/base_saylink_repository.h + repositories/base/base_server_scheduled_events_repository.h + repositories/base/base_shared_tasks_repository.h + repositories/base/base_shared_task_activity_state_repository.h + repositories/base/base_shared_task_dynamic_zones_repository.h + repositories/base/base_shared_task_members_repository.h + repositories/base/base_skill_caps_repository.h + repositories/base/base_spawn2_repository.h + repositories/base/base_spawnentry_repository.h + repositories/base/base_spawngroup_repository.h + repositories/base/base_spawn_conditions_repository.h + repositories/base/base_spawn_condition_values_repository.h + repositories/base/base_spawn_events_repository.h + repositories/base/base_spells_new_repository.h + repositories/base/base_spell_buckets_repository.h + repositories/base/base_spell_globals_repository.h + repositories/base/base_starting_items_repository.h + repositories/base/base_start_zones_repository.h + repositories/base/base_tasks_repository.h + repositories/base/base_tasksets_repository.h + repositories/base/base_task_activities_repository.h + repositories/base/base_timers_repository.h + repositories/base/base_titles_repository.h + repositories/base/base_trader_repository.h + repositories/base/base_tradeskill_recipe_repository.h + repositories/base/base_tradeskill_recipe_entries_repository.h + repositories/base/base_traps_repository.h + repositories/base/base_tributes_repository.h + repositories/base/base_tribute_levels_repository.h + repositories/base/base_veteran_reward_templates_repository.h + repositories/base/base_zone_repository.h + repositories/base/base_zone_points_repository.h - # Non-Comformative - repositories/character_recipe_list_repository.h -) + # Extended Repositories + repositories/aa_ability_repository.h + repositories/aa_ranks_repository.h + repositories/aa_rank_effects_repository.h + repositories/aa_rank_prereqs_repository.h + repositories/account_repository.h + repositories/account_flags_repository.h + repositories/account_ip_repository.h + repositories/account_rewards_repository.h + repositories/adventure_details_repository.h + repositories/adventure_members_repository.h + repositories/adventure_stats_repository.h + repositories/adventure_template_repository.h + repositories/adventure_template_entry_repository.h + repositories/adventure_template_entry_flavor_repository.h + repositories/alternate_currency_repository.h + repositories/auras_repository.h + repositories/base_data_repository.h + repositories/blocked_spells_repository.h + repositories/books_repository.h + repositories/bugs_repository.h + repositories/bug_reports_repository.h + repositories/buyer_repository.h + repositories/character_activities_repository.h + repositories/character_alternate_abilities_repository.h + repositories/character_alt_currency_repository.h + repositories/character_auras_repository.h + repositories/character_bandolier_repository.h + repositories/character_bind_repository.h + repositories/character_buffs_repository.h + repositories/character_corpses_repository.h + repositories/character_corpse_items_repository.h + repositories/character_currency_repository.h + repositories/character_data_repository.h + repositories/character_disciplines_repository.h + repositories/character_expedition_lockouts_repository.h + repositories/character_exp_modifiers_repository.h + repositories/character_inspect_messages_repository.h + repositories/character_instance_safereturns_repository.h + repositories/character_item_recast_repository.h + repositories/character_languages_repository.h + repositories/character_leadership_abilities_repository.h + repositories/character_material_repository.h + repositories/character_memmed_spells_repository.h + repositories/character_peqzone_flags_repository.h + repositories/character_pet_buffs_repository.h + repositories/character_pet_info_repository.h + repositories/character_pet_inventory_repository.h + repositories/character_potionbelt_repository.h + repositories/character_skills_repository.h + repositories/character_spells_repository.h + repositories/character_tasks_repository.h + repositories/character_task_timers_repository.h + repositories/char_create_combinations_repository.h + repositories/char_create_point_allocations_repository.h + repositories/char_recipe_list_repository.h + repositories/completed_shared_tasks_repository.h + repositories/completed_shared_task_activity_state_repository.h + repositories/completed_shared_task_members_repository.h + repositories/completed_tasks_repository.h + repositories/content_flags_repository.h + repositories/damageshieldtypes_repository.h + repositories/data_buckets_repository.h + repositories/db_str_repository.h + repositories/discord_webhooks_repository.h + repositories/discovered_items_repository.h + repositories/doors_repository.h + repositories/dynamic_zones_repository.h + repositories/dynamic_zone_members_repository.h + repositories/dynamic_zone_templates_repository.h + repositories/eventlog_repository.h + repositories/expeditions_repository.h + repositories/expedition_lockouts_repository.h + repositories/faction_base_data_repository.h + repositories/faction_list_repository.h + repositories/faction_list_mod_repository.h + repositories/faction_values_repository.h + repositories/fishing_repository.h + repositories/forage_repository.h + repositories/friends_repository.h + repositories/global_loot_repository.h + repositories/gm_ips_repository.h + repositories/goallists_repository.h + repositories/graveyard_repository.h + repositories/ground_spawns_repository.h + repositories/group_id_repository.h + repositories/group_leaders_repository.h + repositories/guilds_repository.h + repositories/guild_ranks_repository.h + repositories/guild_relations_repository.h + repositories/hackers_repository.h + repositories/horses_repository.h + repositories/instance_list_repository.h + repositories/instance_list_player_repository.h + repositories/inventory_repository.h + 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 + repositories/lfguild_repository.h + repositories/login_accounts_repository.h + repositories/login_api_tokens_repository.h + repositories/login_server_admins_repository.h + repositories/login_server_list_types_repository.h + repositories/login_world_servers_repository.h + repositories/logsys_categories_repository.h + repositories/lootdrop_repository.h + repositories/lootdrop_entries_repository.h + repositories/loottable_repository.h + repositories/loottable_entries_repository.h + repositories/mail_repository.h + repositories/merchantlist_repository.h + repositories/merchantlist_temp_repository.h + repositories/name_filter_repository.h + repositories/npc_emotes_repository.h + repositories/npc_faction_repository.h + repositories/npc_faction_entries_repository.h + repositories/npc_scale_global_base_repository.h + repositories/npc_spells_repository.h + repositories/npc_spells_effects_repository.h + repositories/npc_spells_effects_entries_repository.h + repositories/npc_spells_entries_repository.h + repositories/npc_types_repository.h + repositories/npc_types_tint_repository.h + repositories/object_repository.h + repositories/object_contents_repository.h + repositories/perl_event_export_settings_repository.h + repositories/petitions_repository.h + repositories/pets_repository.h + repositories/pets_beastlord_data_repository.h + repositories/pets_equipmentset_repository.h + repositories/pets_equipmentset_entries_repository.h + repositories/player_titlesets_repository.h + repositories/proximities_repository.h + repositories/quest_globals_repository.h + repositories/raid_details_repository.h + repositories/raid_members_repository.h + repositories/reports_repository.h + repositories/respawn_times_repository.h + repositories/rule_sets_repository.h + repositories/rule_values_repository.h + repositories/saylink_repository.h + repositories/server_scheduled_events_repository.h + repositories/shared_tasks_repository.h + repositories/shared_task_activity_state_repository.h + repositories/shared_task_dynamic_zones_repository.h + repositories/shared_task_members_repository.h + repositories/skill_caps_repository.h + repositories/spawn2_repository.h + repositories/spawnentry_repository.h + repositories/spawngroup_repository.h + repositories/spawn_conditions_repository.h + repositories/spawn_condition_values_repository.h + repositories/spawn_events_repository.h + repositories/spells_new_repository.h + repositories/spell_buckets_repository.h + repositories/spell_globals_repository.h + repositories/starting_items_repository.h + repositories/start_zones_repository.h + repositories/tasks_repository.h + repositories/tasksets_repository.h + repositories/task_activities_repository.h + repositories/timers_repository.h + repositories/titles_repository.h + repositories/trader_repository.h + repositories/tradeskill_recipe_repository.h + repositories/tradeskill_recipe_entries_repository.h + repositories/traps_repository.h + repositories/tributes_repository.h + repositories/tribute_levels_repository.h + repositories/veteran_reward_templates_repository.h + repositories/zone_repository.h + repositories/zone_points_repository.h + + # Non-Comformative + repositories/character_recipe_list_repository.h + ) SET(common_headers - additive_lagged_fibonacci_engine.h - base_packet.h - base_data.h - bodytypes.h - classes.h - compression.h - condition.h - content/world_content_service.h - crash.h - crc16.h - crc32.h - cli/argh.h - cli/eqemu_command_handler.h - cli/terminal_color.hpp - cron/croncpp.h - database/database_dump_service.h - data_verification.h - database.h - database_schema.h - dbcore.h - deity.h - discord/discord.h - discord_manager.h - dynamic_zone_base.h - emu_constants.h - emu_limits.h - emu_opcodes.h - emu_oplist.h - emu_versions.h - eq_constants.h - eq_packet_structs.h - eqdb.h - eqdb_res.h - eqemu_exception.h - eqemu_config.h - eqemu_config_elements.h - eqemu_logsys.h - eqemu_logsys_log_aliases.h - eq_limits.h - eq_packet.h - eq_stream_ident.h - eq_stream_intf.h - eq_stream_locator.h - eq_stream_proxy.h - eqtime.h - errmsg.h - event_sub.h - expedition_lockout_timer.h - extprofile.h - faction.h - file_util.h - features.h - fixed_memory_hash_set.h - fixed_memory_variable_hash_set.h - global_define.h - guild_base.h - guilds.h - http/httplib.h - http/uri.h - inventory_profile.h - inventory_slot.h - ipc_mutex.h - ip_util.h - item_data.h - item_fieldlist.h - item_instance.h - json_config.h - languages.h - light_source.h - linked_list.h - loottable.h - mail_oplist.h - md5.h - memory_buffer.h - memory_mapped_file.h - misc.h - misc_functions.h - mutex.h - mysql_request_result.h - mysql_request_row.h - op_codes.h - opcode_dispatch.h - opcodemgr.h - packet_dump.h - packet_dump_file.h - packet_functions.h - platform.h - proc_launcher.h - profanity_manager.h - profiler.h - ptimer.h - queue.h - races.h - random.h - rdtsc.h - rulesys.h - ruletypes.h - say_link.h - seperator.h - serialize_buffer.h - server_event_scheduler.h - serverinfo.h - servertalk.h - shared_tasks.h - shareddb.h - skills.h - spdat.h - strings.h - struct_strategy.h - tasks.h - textures.h - timer.h - types.h - unix.h - useperl.h - version.h - zone_numbers.h - event/event_loop.h - event/task.h - event/timer.h - json/json.h - json/json-forwards.h - net/console_server.h - net/console_server_connection.h - net/crc32.h - net/daybreak_connection.h - net/daybreak_structs.h - net/dns.h - net/endian.h - net/eqstream.h - net/packet.h - net/servertalk_client_connection.h - net/servertalk_legacy_client_connection.h - net/servertalk_common.h - net/servertalk_server.h - net/servertalk_server_connection.h - net/tcp_connection.h - net/tcp_server.h - net/websocket_server.h - net/websocket_server_connection.h - patches/patches.h - patches/sod.h - patches/sod_limits.h - patches/sod_ops.h - patches/sod_structs.h - patches/sof.h - patches/sof_limits.h - patches/sof_ops.h - patches/sof_structs.h - patches/ss_declare.h - patches/ss_define.h - patches/ss_register.h - patches/rof.h - patches/rof_limits.h - patches/rof_ops.h - patches/rof_structs.h - patches/rof2.h - patches/rof2_limits.h - patches/rof2_ops.h - patches/rof2_structs.h - patches/titanium.h - patches/titanium_limits.h - patches/titanium_ops.h - patches/titanium_structs.h - patches/uf.h - patches/uf_limits.h - patches/uf_ops.h - patches/uf_structs.h - StackWalker/StackWalker.h - util/memory_stream.h - util/directory.h - util/uuid.h -) + additive_lagged_fibonacci_engine.h + base_packet.h + base_data.h + bodytypes.h + classes.h + compression.h + condition.h + content/world_content_service.h + crash.h + crc16.h + crc32.h + cli/argh.h + cli/eqemu_command_handler.h + cli/terminal_color.hpp + cron/croncpp.h + database/database_dump_service.h + data_verification.h + database.h + database_schema.h + dbcore.h + deity.h + discord/discord.h + discord_manager.h + dynamic_zone_base.h + emu_constants.h + emu_limits.h + emu_opcodes.h + emu_oplist.h + emu_versions.h + eq_constants.h + eq_packet_structs.h + eqdb.h + eqdb_res.h + eqemu_exception.h + eqemu_config.h + eqemu_config_elements.h + eqemu_logsys.h + eqemu_logsys_log_aliases.h + eq_limits.h + eq_packet.h + eq_stream_ident.h + eq_stream_intf.h + eq_stream_locator.h + eq_stream_proxy.h + eqtime.h + errmsg.h + event_sub.h + expedition_lockout_timer.h + extprofile.h + faction.h + file_util.h + features.h + fixed_memory_hash_set.h + fixed_memory_variable_hash_set.h + global_define.h + guild_base.h + guilds.h + http/httplib.h + http/uri.h + inventory_profile.h + inventory_slot.h + ipc_mutex.h + ip_util.h + item_data.h + item_fieldlist.h + item_instance.h + json_config.h + languages.h + light_source.h + linked_list.h + loottable.h + mail_oplist.h + md5.h + memory_buffer.h + memory_mapped_file.h + misc.h + misc_functions.h + mutex.h + mysql_request_result.h + mysql_request_row.h + op_codes.h + opcode_dispatch.h + opcodemgr.h + packet_dump.h + packet_dump_file.h + packet_functions.h + platform.h + proc_launcher.h + profanity_manager.h + profiler.h + ptimer.h + queue.h + races.h + random.h + rdtsc.h + rulesys.h + ruletypes.h + say_link.h + seperator.h + serialize_buffer.h + server_event_scheduler.h + serverinfo.h + servertalk.h + shared_tasks.h + shareddb.h + skills.h + spdat.h + strings.h + struct_strategy.h + tasks.h + textures.h + timer.h + types.h + unix.h + useperl.h + version.h + zone_numbers.h + event/event_loop.h + event/task.h + event/timer.h + json/json.h + json/json-forwards.h + net/console_server.h + net/console_server_connection.h + net/crc32.h + net/daybreak_connection.h + net/daybreak_structs.h + net/dns.h + net/endian.h + net/eqstream.h + net/packet.h + net/servertalk_client_connection.h + net/servertalk_legacy_client_connection.h + net/servertalk_common.h + net/servertalk_server.h + net/servertalk_server_connection.h + net/tcp_connection.h + net/tcp_server.h + net/websocket_server.h + net/websocket_server_connection.h + patches/patches.h + patches/sod.h + patches/sod_limits.h + patches/sod_ops.h + patches/sod_structs.h + patches/sof.h + patches/sof_limits.h + patches/sof_ops.h + patches/sof_structs.h + patches/ss_declare.h + patches/ss_define.h + patches/ss_register.h + patches/rof.h + patches/rof_limits.h + patches/rof_ops.h + patches/rof_structs.h + patches/rof2.h + patches/rof2_limits.h + patches/rof2_ops.h + patches/rof2_structs.h + patches/titanium.h + patches/titanium_limits.h + patches/titanium_ops.h + patches/titanium_structs.h + patches/uf.h + patches/uf_limits.h + patches/uf_ops.h + patches/uf_structs.h + StackWalker/StackWalker.h + util/memory_stream.h + util/directory.h + util/uuid.h + ) SOURCE_GROUP(Event FILES - event/event_loop.h - event/timer.h - event/task.h -) + event/event_loop.h + event/timer.h + event/task.h + ) SOURCE_GROUP(Json FILES - json/json.h - json/jsoncpp.cpp - json/json-forwards.h -) + json/json.h + json/jsoncpp.cpp + json/json-forwards.h + ) SOURCE_GROUP(Net FILES - net/console_server.cpp - net/console_server.h - net/console_server_connection.cpp - net/console_server_connection.h - net/crc32.cpp - net/crc32.h - net/daybreak_connection.cpp - net/daybreak_connection.h - net/daybreak_structs.h - net/dns.h - net/endian.h - net/eqmq.cpp - net/eqmq.h - net/eqstream.cpp - net/eqstream.h - net/packet.cpp - net/packet.h - net/servertalk_client_connection.cpp - net/servertalk_client_connection.h - net/servertalk_legacy_client_connection.cpp - net/servertalk_legacy_client_connection.h - net/servertalk_common.h - net/servertalk_server.cpp - net/servertalk_server.h - net/servertalk_server_connection.cpp - net/servertalk_server_connection.h - net/tcp_connection.cpp - net/tcp_connection.h - net/tcp_server.cpp - net/tcp_server.h - net/websocket_server.cpp - net/websocket_server.h - net/websocket_server_connection.cpp - net/websocket_server_connection.h -) + net/console_server.cpp + net/console_server.h + net/console_server_connection.cpp + net/console_server_connection.h + net/crc32.cpp + net/crc32.h + net/daybreak_connection.cpp + net/daybreak_connection.h + net/daybreak_structs.h + net/dns.h + net/endian.h + net/eqmq.cpp + net/eqmq.h + net/eqstream.cpp + net/eqstream.h + net/packet.cpp + net/packet.h + net/servertalk_client_connection.cpp + net/servertalk_client_connection.h + net/servertalk_legacy_client_connection.cpp + net/servertalk_legacy_client_connection.h + net/servertalk_common.h + net/servertalk_server.cpp + net/servertalk_server.h + net/servertalk_server_connection.cpp + net/servertalk_server_connection.h + net/tcp_connection.cpp + net/tcp_connection.h + net/tcp_server.cpp + net/tcp_server.h + net/websocket_server.cpp + net/websocket_server.h + net/websocket_server_connection.cpp + net/websocket_server_connection.h + ) SOURCE_GROUP(Patches FILES - patches/patches.h - patches/sod.h - patches/sod_limits.h - patches/sod_ops.h - patches/sod_structs.h - patches/sof.h - patches/sof_limits.h - patches/sof_ops.h - patches/sof_structs.h - patches/ss_declare.h - patches/ss_define.h - patches/ss_register.h - patches/rof.h - patches/rof_limits.h - patches/rof_ops.h - patches/rof_structs.h - patches/rof2.h - patches/rof2_limits.h - patches/rof2_ops.h - patches/rof2_structs.h - patches/titanium.h - patches/titanium_limits.h - patches/titanium_ops.h - patches/titanium_structs.h - patches/uf.h - patches/uf_limits.h - patches/uf_ops.h - patches/uf_structs.h - patches/patches.cpp - patches/sod.cpp - patches/sod_limits.cpp - patches/sof.cpp - patches/sof_limits.cpp - patches/rof.cpp - patches/rof_limits.cpp - patches/rof2.cpp - patches/rof2_limits.cpp - patches/titanium.cpp - patches/titanium_limits.cpp - patches/uf.cpp - patches/uf_limits.cpp -) + patches/patches.h + patches/sod.h + patches/sod_limits.h + patches/sod_ops.h + patches/sod_structs.h + patches/sof.h + patches/sof_limits.h + patches/sof_ops.h + patches/sof_structs.h + patches/ss_declare.h + patches/ss_define.h + patches/ss_register.h + patches/rof.h + patches/rof_limits.h + patches/rof_ops.h + patches/rof_structs.h + patches/rof2.h + patches/rof2_limits.h + patches/rof2_ops.h + patches/rof2_structs.h + patches/titanium.h + patches/titanium_limits.h + patches/titanium_ops.h + patches/titanium_structs.h + patches/uf.h + patches/uf_limits.h + patches/uf_ops.h + patches/uf_structs.h + patches/patches.cpp + patches/sod.cpp + patches/sod_limits.cpp + patches/sof.cpp + patches/sof_limits.cpp + patches/rof.cpp + patches/rof_limits.cpp + patches/rof2.cpp + patches/rof2_limits.cpp + patches/titanium.cpp + patches/titanium_limits.cpp + patches/uf.cpp + patches/uf_limits.cpp + ) SOURCE_GROUP(StackWalker FILES - StackWalker/StackWalker.h - StackWalker/StackWalker.cpp -) + StackWalker/StackWalker.h + StackWalker/StackWalker.cpp + ) SOURCE_GROUP(Util FILES - util/memory_stream.h - util/directory.cpp - util/directory.h - util/uuid.cpp - util/uuid.h -) + util/memory_stream.h + util/directory.cpp + util/directory.h + util/uuid.cpp + util/uuid.h + ) INCLUDE_DIRECTORIES(Patches SocketLib StackWalker) ADD_LIBRARY(common ${common_sources} ${common_headers} ${repositories}) -IF(UNIX) - SET_SOURCE_FILES_PROPERTIES("SocketLib/Mime.cpp" PROPERTY COMPILE_FLAGS -Wno-unused-result) - SET_SOURCE_FILES_PROPERTIES("patches/sod.cpp" "patches/sof.cpp" "patches/rof.cpp" "patches/rof2.cpp" "patches/uf.cpp" PROPERTIES COMPILE_FLAGS -O0) -ENDIF(UNIX) +IF (UNIX) + SET_SOURCE_FILES_PROPERTIES("SocketLib/Mime.cpp" PROPERTY COMPILE_FLAGS -Wno-unused-result) + SET_SOURCE_FILES_PROPERTIES("patches/sod.cpp" "patches/sof.cpp" "patches/rof.cpp" "patches/rof2.cpp" "patches/uf.cpp" PROPERTIES COMPILE_FLAGS -O0) +ENDIF (UNIX) SET(LIBRARY_OUTPUT_PATH ${PROJECT_BINARY_DIR}/bin) diff --git a/common/repositories/aa_ability_repository.h b/common/repositories/aa_ability_repository.h index f79bd9794..59bc165e4 100644 --- a/common/repositories/aa_ability_repository.h +++ b/common/repositories/aa_ability_repository.h @@ -1,23 +1,3 @@ -/** - * EQEmulator: Everquest Server Emulator - * Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server) - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 2 of the License. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY except by those people which sell it, which - * are required to give you total support for your newly bought product; - * without even the implied warranty of MERCHANTABILITY or FITNESS FOR - * A PARTICULAR PURPOSE. See the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - #ifndef EQEMU_AA_ABILITY_REPOSITORY_H #define EQEMU_AA_ABILITY_REPOSITORY_H diff --git a/common/repositories/aa_rank_effects_repository.h b/common/repositories/aa_rank_effects_repository.h index 25f155481..ebec6814c 100644 --- a/common/repositories/aa_rank_effects_repository.h +++ b/common/repositories/aa_rank_effects_repository.h @@ -1,23 +1,3 @@ -/** - * EQEmulator: Everquest Server Emulator - * Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server) - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 2 of the License. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY except by those people which sell it, which - * are required to give you total support for your newly bought product; - * without even the implied warranty of MERCHANTABILITY or FITNESS FOR - * A PARTICULAR PURPOSE. See the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - #ifndef EQEMU_AA_RANK_EFFECTS_REPOSITORY_H #define EQEMU_AA_RANK_EFFECTS_REPOSITORY_H diff --git a/common/repositories/aa_rank_prereqs_repository.h b/common/repositories/aa_rank_prereqs_repository.h index be2096f3e..76dbeea01 100644 --- a/common/repositories/aa_rank_prereqs_repository.h +++ b/common/repositories/aa_rank_prereqs_repository.h @@ -1,23 +1,3 @@ -/** - * EQEmulator: Everquest Server Emulator - * Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server) - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 2 of the License. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY except by those people which sell it, which - * are required to give you total support for your newly bought product; - * without even the implied warranty of MERCHANTABILITY or FITNESS FOR - * A PARTICULAR PURPOSE. See the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - #ifndef EQEMU_AA_RANK_PREREQS_REPOSITORY_H #define EQEMU_AA_RANK_PREREQS_REPOSITORY_H diff --git a/common/repositories/aa_ranks_repository.h b/common/repositories/aa_ranks_repository.h index 3072371e7..170548cad 100644 --- a/common/repositories/aa_ranks_repository.h +++ b/common/repositories/aa_ranks_repository.h @@ -1,23 +1,3 @@ -/** - * EQEmulator: Everquest Server Emulator - * Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server) - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 2 of the License. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY except by those people which sell it, which - * are required to give you total support for your newly bought product; - * without even the implied warranty of MERCHANTABILITY or FITNESS FOR - * A PARTICULAR PURPOSE. See the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - #ifndef EQEMU_AA_RANKS_REPOSITORY_H #define EQEMU_AA_RANKS_REPOSITORY_H diff --git a/common/repositories/account_flags_repository.h b/common/repositories/account_flags_repository.h index c5d6f9e57..e1ebb32f4 100644 --- a/common/repositories/account_flags_repository.h +++ b/common/repositories/account_flags_repository.h @@ -1,23 +1,3 @@ -/** - * EQEmulator: Everquest Server Emulator - * Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server) - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 2 of the License. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY except by those people which sell it, which - * are required to give you total support for your newly bought product; - * without even the implied warranty of MERCHANTABILITY or FITNESS FOR - * A PARTICULAR PURPOSE. See the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - #ifndef EQEMU_ACCOUNT_FLAGS_REPOSITORY_H #define EQEMU_ACCOUNT_FLAGS_REPOSITORY_H diff --git a/common/repositories/account_ip_repository.h b/common/repositories/account_ip_repository.h index 58e1a50bd..d7278708b 100644 --- a/common/repositories/account_ip_repository.h +++ b/common/repositories/account_ip_repository.h @@ -1,23 +1,3 @@ -/** - * EQEmulator: Everquest Server Emulator - * Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server) - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 2 of the License. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY except by those people which sell it, which - * are required to give you total support for your newly bought product; - * without even the implied warranty of MERCHANTABILITY or FITNESS FOR - * A PARTICULAR PURPOSE. See the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - #ifndef EQEMU_ACCOUNT_IP_REPOSITORY_H #define EQEMU_ACCOUNT_IP_REPOSITORY_H diff --git a/common/repositories/account_repository.h b/common/repositories/account_repository.h index fa25edee9..83d221911 100644 --- a/common/repositories/account_repository.h +++ b/common/repositories/account_repository.h @@ -1,23 +1,3 @@ -/** - * EQEmulator: Everquest Server Emulator - * Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server) - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 2 of the License. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY except by those people which sell it, which - * are required to give you total support for your newly bought product; - * without even the implied warranty of MERCHANTABILITY or FITNESS FOR - * A PARTICULAR PURPOSE. See the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - #ifndef EQEMU_ACCOUNT_REPOSITORY_H #define EQEMU_ACCOUNT_REPOSITORY_H diff --git a/common/repositories/account_rewards_repository.h b/common/repositories/account_rewards_repository.h index 274cf7fcb..3db8f653a 100644 --- a/common/repositories/account_rewards_repository.h +++ b/common/repositories/account_rewards_repository.h @@ -1,23 +1,3 @@ -/** - * EQEmulator: Everquest Server Emulator - * Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server) - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 2 of the License. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY except by those people which sell it, which - * are required to give you total support for your newly bought product; - * without even the implied warranty of MERCHANTABILITY or FITNESS FOR - * A PARTICULAR PURPOSE. See the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - #ifndef EQEMU_ACCOUNT_REWARDS_REPOSITORY_H #define EQEMU_ACCOUNT_REWARDS_REPOSITORY_H diff --git a/common/repositories/adventure_details_repository.h b/common/repositories/adventure_details_repository.h index 10563938d..c81ac5cc3 100644 --- a/common/repositories/adventure_details_repository.h +++ b/common/repositories/adventure_details_repository.h @@ -1,23 +1,3 @@ -/** - * EQEmulator: Everquest Server Emulator - * Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server) - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 2 of the License. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY except by those people which sell it, which - * are required to give you total support for your newly bought product; - * without even the implied warranty of MERCHANTABILITY or FITNESS FOR - * A PARTICULAR PURPOSE. See the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - #ifndef EQEMU_ADVENTURE_DETAILS_REPOSITORY_H #define EQEMU_ADVENTURE_DETAILS_REPOSITORY_H diff --git a/common/repositories/adventure_members_repository.h b/common/repositories/adventure_members_repository.h index 619b456aa..d430d8eb2 100644 --- a/common/repositories/adventure_members_repository.h +++ b/common/repositories/adventure_members_repository.h @@ -1,23 +1,3 @@ -/** - * EQEmulator: Everquest Server Emulator - * Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server) - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 2 of the License. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY except by those people which sell it, which - * are required to give you total support for your newly bought product; - * without even the implied warranty of MERCHANTABILITY or FITNESS FOR - * A PARTICULAR PURPOSE. See the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - #ifndef EQEMU_ADVENTURE_MEMBERS_REPOSITORY_H #define EQEMU_ADVENTURE_MEMBERS_REPOSITORY_H diff --git a/common/repositories/adventure_stats_repository.h b/common/repositories/adventure_stats_repository.h index 452fea32d..6fe223e88 100644 --- a/common/repositories/adventure_stats_repository.h +++ b/common/repositories/adventure_stats_repository.h @@ -1,23 +1,3 @@ -/** - * EQEmulator: Everquest Server Emulator - * Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server) - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 2 of the License. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY except by those people which sell it, which - * are required to give you total support for your newly bought product; - * without even the implied warranty of MERCHANTABILITY or FITNESS FOR - * A PARTICULAR PURPOSE. See the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - #ifndef EQEMU_ADVENTURE_STATS_REPOSITORY_H #define EQEMU_ADVENTURE_STATS_REPOSITORY_H diff --git a/common/repositories/adventure_template_entry_flavor_repository.h b/common/repositories/adventure_template_entry_flavor_repository.h index 8e5a85a7a..c0d1d63c9 100644 --- a/common/repositories/adventure_template_entry_flavor_repository.h +++ b/common/repositories/adventure_template_entry_flavor_repository.h @@ -1,23 +1,3 @@ -/** - * EQEmulator: Everquest Server Emulator - * Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server) - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 2 of the License. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY except by those people which sell it, which - * are required to give you total support for your newly bought product; - * without even the implied warranty of MERCHANTABILITY or FITNESS FOR - * A PARTICULAR PURPOSE. See the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - #ifndef EQEMU_ADVENTURE_TEMPLATE_ENTRY_FLAVOR_REPOSITORY_H #define EQEMU_ADVENTURE_TEMPLATE_ENTRY_FLAVOR_REPOSITORY_H diff --git a/common/repositories/adventure_template_entry_repository.h b/common/repositories/adventure_template_entry_repository.h index 411325411..95db9f229 100644 --- a/common/repositories/adventure_template_entry_repository.h +++ b/common/repositories/adventure_template_entry_repository.h @@ -1,23 +1,3 @@ -/** - * EQEmulator: Everquest Server Emulator - * Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server) - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 2 of the License. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY except by those people which sell it, which - * are required to give you total support for your newly bought product; - * without even the implied warranty of MERCHANTABILITY or FITNESS FOR - * A PARTICULAR PURPOSE. See the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - #ifndef EQEMU_ADVENTURE_TEMPLATE_ENTRY_REPOSITORY_H #define EQEMU_ADVENTURE_TEMPLATE_ENTRY_REPOSITORY_H diff --git a/common/repositories/adventure_template_repository.h b/common/repositories/adventure_template_repository.h index 1931df8b1..39c8699b7 100644 --- a/common/repositories/adventure_template_repository.h +++ b/common/repositories/adventure_template_repository.h @@ -1,23 +1,3 @@ -/** - * EQEmulator: Everquest Server Emulator - * Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server) - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 2 of the License. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY except by those people which sell it, which - * are required to give you total support for your newly bought product; - * without even the implied warranty of MERCHANTABILITY or FITNESS FOR - * A PARTICULAR PURPOSE. See the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - #ifndef EQEMU_ADVENTURE_TEMPLATE_REPOSITORY_H #define EQEMU_ADVENTURE_TEMPLATE_REPOSITORY_H diff --git a/common/repositories/alternate_currency_repository.h b/common/repositories/alternate_currency_repository.h index cac9daaf5..cd2a95f52 100644 --- a/common/repositories/alternate_currency_repository.h +++ b/common/repositories/alternate_currency_repository.h @@ -1,23 +1,3 @@ -/** - * EQEmulator: Everquest Server Emulator - * Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server) - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 2 of the License. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY except by those people which sell it, which - * are required to give you total support for your newly bought product; - * without even the implied warranty of MERCHANTABILITY or FITNESS FOR - * A PARTICULAR PURPOSE. See the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - #ifndef EQEMU_ALTERNATE_CURRENCY_REPOSITORY_H #define EQEMU_ALTERNATE_CURRENCY_REPOSITORY_H diff --git a/common/repositories/auras_repository.h b/common/repositories/auras_repository.h index 80489e554..7d97503fb 100644 --- a/common/repositories/auras_repository.h +++ b/common/repositories/auras_repository.h @@ -1,23 +1,3 @@ -/** - * EQEmulator: Everquest Server Emulator - * Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server) - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 2 of the License. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY except by those people which sell it, which - * are required to give you total support for your newly bought product; - * without even the implied warranty of MERCHANTABILITY or FITNESS FOR - * A PARTICULAR PURPOSE. See the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - #ifndef EQEMU_AURAS_REPOSITORY_H #define EQEMU_AURAS_REPOSITORY_H diff --git a/common/repositories/base/base_aa_ability_repository.h b/common/repositories/base/base_aa_ability_repository.h index 9af336da8..5b451e8fd 100644 --- a/common/repositories/base/base_aa_ability_repository.h +++ b/common/repositories/base/base_aa_ability_repository.h @@ -115,27 +115,27 @@ public: static AaAbility NewEntity() { - AaAbility entry{}; + AaAbility e{}; - entry.id = 0; - entry.name = ""; - entry.category = -1; - entry.classes = 131070; - entry.races = 65535; - entry.drakkin_heritage = 127; - entry.deities = 131071; - entry.status = 0; - entry.type = 0; - entry.charges = 0; - entry.grant_only = 0; - entry.first_rank_id = -1; - entry.enabled = 1; - entry.reset_on_death = 0; + e.id = 0; + e.name = ""; + e.category = -1; + e.classes = 131070; + e.races = 65535; + e.drakkin_heritage = 127; + e.deities = 131071; + e.status = 0; + e.type = 0; + e.charges = 0; + e.grant_only = 0; + e.first_rank_id = -1; + e.enabled = 1; + e.reset_on_death = 0; - return entry; + return e; } - static AaAbility GetAaAbilityEntry( + static AaAbility GetAaAbility( const std::vector &aa_abilitys, int aa_ability_id ) @@ -164,24 +164,24 @@ public: auto row = results.begin(); if (results.RowCount() == 1) { - AaAbility entry{}; + AaAbility e{}; - entry.id = atoi(row[0]); - entry.name = row[1] ? row[1] : ""; - entry.category = atoi(row[2]); - entry.classes = atoi(row[3]); - entry.races = atoi(row[4]); - entry.drakkin_heritage = atoi(row[5]); - entry.deities = atoi(row[6]); - entry.status = atoi(row[7]); - entry.type = atoi(row[8]); - entry.charges = atoi(row[9]); - entry.grant_only = atoi(row[10]); - entry.first_rank_id = atoi(row[11]); - entry.enabled = atoi(row[12]); - entry.reset_on_death = atoi(row[13]); + e.id = atoi(row[0]); + e.name = row[1] ? row[1] : ""; + e.category = atoi(row[2]); + e.classes = atoi(row[3]); + e.races = atoi(row[4]); + e.drakkin_heritage = atoi(row[5]); + e.deities = atoi(row[6]); + e.status = atoi(row[7]); + e.type = atoi(row[8]); + e.charges = atoi(row[9]); + e.grant_only = atoi(row[10]); + e.first_rank_id = atoi(row[11]); + e.enabled = atoi(row[12]); + e.reset_on_death = atoi(row[13]); - return entry; + return e; } return NewEntity(); @@ -206,35 +206,35 @@ public: static int UpdateOne( Database& db, - AaAbility aa_ability_entry + const AaAbility &e ) { - std::vector update_values; + std::vector v; auto columns = Columns(); - update_values.push_back(columns[0] + " = " + std::to_string(aa_ability_entry.id)); - update_values.push_back(columns[1] + " = '" + Strings::Escape(aa_ability_entry.name) + "'"); - update_values.push_back(columns[2] + " = " + std::to_string(aa_ability_entry.category)); - update_values.push_back(columns[3] + " = " + std::to_string(aa_ability_entry.classes)); - update_values.push_back(columns[4] + " = " + std::to_string(aa_ability_entry.races)); - update_values.push_back(columns[5] + " = " + std::to_string(aa_ability_entry.drakkin_heritage)); - update_values.push_back(columns[6] + " = " + std::to_string(aa_ability_entry.deities)); - update_values.push_back(columns[7] + " = " + std::to_string(aa_ability_entry.status)); - update_values.push_back(columns[8] + " = " + std::to_string(aa_ability_entry.type)); - update_values.push_back(columns[9] + " = " + std::to_string(aa_ability_entry.charges)); - update_values.push_back(columns[10] + " = " + std::to_string(aa_ability_entry.grant_only)); - update_values.push_back(columns[11] + " = " + std::to_string(aa_ability_entry.first_rank_id)); - update_values.push_back(columns[12] + " = " + std::to_string(aa_ability_entry.enabled)); - update_values.push_back(columns[13] + " = " + std::to_string(aa_ability_entry.reset_on_death)); + v.push_back(columns[0] + " = " + std::to_string(e.id)); + v.push_back(columns[1] + " = '" + Strings::Escape(e.name) + "'"); + v.push_back(columns[2] + " = " + std::to_string(e.category)); + v.push_back(columns[3] + " = " + std::to_string(e.classes)); + v.push_back(columns[4] + " = " + std::to_string(e.races)); + v.push_back(columns[5] + " = " + std::to_string(e.drakkin_heritage)); + v.push_back(columns[6] + " = " + std::to_string(e.deities)); + v.push_back(columns[7] + " = " + std::to_string(e.status)); + v.push_back(columns[8] + " = " + std::to_string(e.type)); + v.push_back(columns[9] + " = " + std::to_string(e.charges)); + v.push_back(columns[10] + " = " + std::to_string(e.grant_only)); + v.push_back(columns[11] + " = " + std::to_string(e.first_rank_id)); + v.push_back(columns[12] + " = " + std::to_string(e.enabled)); + v.push_back(columns[13] + " = " + std::to_string(e.reset_on_death)); auto results = db.QueryDatabase( fmt::format( "UPDATE {} SET {} WHERE {} = {}", TableName(), - Strings::Implode(", ", update_values), + Strings::Implode(", ", v), PrimaryKey(), - aa_ability_entry.id + e.id ) ); @@ -243,73 +243,73 @@ public: static AaAbility InsertOne( Database& db, - AaAbility aa_ability_entry + AaAbility e ) { - std::vector insert_values; + std::vector v; - insert_values.push_back(std::to_string(aa_ability_entry.id)); - insert_values.push_back("'" + Strings::Escape(aa_ability_entry.name) + "'"); - insert_values.push_back(std::to_string(aa_ability_entry.category)); - insert_values.push_back(std::to_string(aa_ability_entry.classes)); - insert_values.push_back(std::to_string(aa_ability_entry.races)); - insert_values.push_back(std::to_string(aa_ability_entry.drakkin_heritage)); - insert_values.push_back(std::to_string(aa_ability_entry.deities)); - insert_values.push_back(std::to_string(aa_ability_entry.status)); - insert_values.push_back(std::to_string(aa_ability_entry.type)); - insert_values.push_back(std::to_string(aa_ability_entry.charges)); - insert_values.push_back(std::to_string(aa_ability_entry.grant_only)); - insert_values.push_back(std::to_string(aa_ability_entry.first_rank_id)); - insert_values.push_back(std::to_string(aa_ability_entry.enabled)); - insert_values.push_back(std::to_string(aa_ability_entry.reset_on_death)); + v.push_back(std::to_string(e.id)); + v.push_back("'" + Strings::Escape(e.name) + "'"); + v.push_back(std::to_string(e.category)); + v.push_back(std::to_string(e.classes)); + v.push_back(std::to_string(e.races)); + v.push_back(std::to_string(e.drakkin_heritage)); + v.push_back(std::to_string(e.deities)); + v.push_back(std::to_string(e.status)); + v.push_back(std::to_string(e.type)); + v.push_back(std::to_string(e.charges)); + v.push_back(std::to_string(e.grant_only)); + v.push_back(std::to_string(e.first_rank_id)); + v.push_back(std::to_string(e.enabled)); + v.push_back(std::to_string(e.reset_on_death)); auto results = db.QueryDatabase( fmt::format( "{} VALUES ({})", BaseInsert(), - Strings::Implode(",", insert_values) + Strings::Implode(",", v) ) ); if (results.Success()) { - aa_ability_entry.id = results.LastInsertedID(); - return aa_ability_entry; + e.id = results.LastInsertedID(); + return e; } - aa_ability_entry = NewEntity(); + e = NewEntity(); - return aa_ability_entry; + return e; } static int InsertMany( Database& db, - std::vector aa_ability_entries + const std::vector &entries ) { std::vector insert_chunks; - for (auto &aa_ability_entry: aa_ability_entries) { - std::vector insert_values; + for (auto &e: entries) { + std::vector v; - insert_values.push_back(std::to_string(aa_ability_entry.id)); - insert_values.push_back("'" + Strings::Escape(aa_ability_entry.name) + "'"); - insert_values.push_back(std::to_string(aa_ability_entry.category)); - insert_values.push_back(std::to_string(aa_ability_entry.classes)); - insert_values.push_back(std::to_string(aa_ability_entry.races)); - insert_values.push_back(std::to_string(aa_ability_entry.drakkin_heritage)); - insert_values.push_back(std::to_string(aa_ability_entry.deities)); - insert_values.push_back(std::to_string(aa_ability_entry.status)); - insert_values.push_back(std::to_string(aa_ability_entry.type)); - insert_values.push_back(std::to_string(aa_ability_entry.charges)); - insert_values.push_back(std::to_string(aa_ability_entry.grant_only)); - insert_values.push_back(std::to_string(aa_ability_entry.first_rank_id)); - insert_values.push_back(std::to_string(aa_ability_entry.enabled)); - insert_values.push_back(std::to_string(aa_ability_entry.reset_on_death)); + v.push_back(std::to_string(e.id)); + v.push_back("'" + Strings::Escape(e.name) + "'"); + v.push_back(std::to_string(e.category)); + v.push_back(std::to_string(e.classes)); + v.push_back(std::to_string(e.races)); + v.push_back(std::to_string(e.drakkin_heritage)); + v.push_back(std::to_string(e.deities)); + v.push_back(std::to_string(e.status)); + v.push_back(std::to_string(e.type)); + v.push_back(std::to_string(e.charges)); + v.push_back(std::to_string(e.grant_only)); + v.push_back(std::to_string(e.first_rank_id)); + v.push_back(std::to_string(e.enabled)); + v.push_back(std::to_string(e.reset_on_death)); - insert_chunks.push_back("(" + Strings::Implode(",", insert_values) + ")"); + insert_chunks.push_back("(" + Strings::Implode(",", v) + ")"); } - std::vector insert_values; + std::vector v; auto results = db.QueryDatabase( fmt::format( @@ -336,30 +336,30 @@ public: all_entries.reserve(results.RowCount()); for (auto row = results.begin(); row != results.end(); ++row) { - AaAbility entry{}; + AaAbility e{}; - entry.id = atoi(row[0]); - entry.name = row[1] ? row[1] : ""; - entry.category = atoi(row[2]); - entry.classes = atoi(row[3]); - entry.races = atoi(row[4]); - entry.drakkin_heritage = atoi(row[5]); - entry.deities = atoi(row[6]); - entry.status = atoi(row[7]); - entry.type = atoi(row[8]); - entry.charges = atoi(row[9]); - entry.grant_only = atoi(row[10]); - entry.first_rank_id = atoi(row[11]); - entry.enabled = atoi(row[12]); - entry.reset_on_death = atoi(row[13]); + e.id = atoi(row[0]); + e.name = row[1] ? row[1] : ""; + e.category = atoi(row[2]); + e.classes = atoi(row[3]); + e.races = atoi(row[4]); + e.drakkin_heritage = atoi(row[5]); + e.deities = atoi(row[6]); + e.status = atoi(row[7]); + e.type = atoi(row[8]); + e.charges = atoi(row[9]); + e.grant_only = atoi(row[10]); + e.first_rank_id = atoi(row[11]); + e.enabled = atoi(row[12]); + e.reset_on_death = atoi(row[13]); - all_entries.push_back(entry); + all_entries.push_back(e); } return all_entries; } - static std::vector GetWhere(Database& db, std::string where_filter) + static std::vector GetWhere(Database& db, const std::string &where_filter) { std::vector all_entries; @@ -374,30 +374,30 @@ public: all_entries.reserve(results.RowCount()); for (auto row = results.begin(); row != results.end(); ++row) { - AaAbility entry{}; + AaAbility e{}; - entry.id = atoi(row[0]); - entry.name = row[1] ? row[1] : ""; - entry.category = atoi(row[2]); - entry.classes = atoi(row[3]); - entry.races = atoi(row[4]); - entry.drakkin_heritage = atoi(row[5]); - entry.deities = atoi(row[6]); - entry.status = atoi(row[7]); - entry.type = atoi(row[8]); - entry.charges = atoi(row[9]); - entry.grant_only = atoi(row[10]); - entry.first_rank_id = atoi(row[11]); - entry.enabled = atoi(row[12]); - entry.reset_on_death = atoi(row[13]); + e.id = atoi(row[0]); + e.name = row[1] ? row[1] : ""; + e.category = atoi(row[2]); + e.classes = atoi(row[3]); + e.races = atoi(row[4]); + e.drakkin_heritage = atoi(row[5]); + e.deities = atoi(row[6]); + e.status = atoi(row[7]); + e.type = atoi(row[8]); + e.charges = atoi(row[9]); + e.grant_only = atoi(row[10]); + e.first_rank_id = atoi(row[11]); + e.enabled = atoi(row[12]); + e.reset_on_death = atoi(row[13]); - all_entries.push_back(entry); + all_entries.push_back(e); } return all_entries; } - static int DeleteWhere(Database& db, std::string where_filter) + static int DeleteWhere(Database& db, const std::string &where_filter) { auto results = db.QueryDatabase( fmt::format( @@ -422,6 +422,32 @@ public: 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); + } + }; #endif //EQEMU_BASE_AA_ABILITY_REPOSITORY_H diff --git a/common/repositories/base/base_aa_rank_effects_repository.h b/common/repositories/base/base_aa_rank_effects_repository.h index 74d915f8c..a9d90ebad 100644 --- a/common/repositories/base/base_aa_rank_effects_repository.h +++ b/common/repositories/base/base_aa_rank_effects_repository.h @@ -88,18 +88,18 @@ public: static AaRankEffects NewEntity() { - AaRankEffects entry{}; + AaRankEffects e{}; - entry.rank_id = 0; - entry.slot = 1; - entry.effect_id = 0; - entry.base1 = 0; - entry.base2 = 0; + e.rank_id = 0; + e.slot = 1; + e.effect_id = 0; + e.base1 = 0; + e.base2 = 0; - return entry; + return e; } - static AaRankEffects GetAaRankEffectsEntry( + static AaRankEffects GetAaRankEffects( const std::vector &aa_rank_effectss, int aa_rank_effects_id ) @@ -128,15 +128,15 @@ public: auto row = results.begin(); if (results.RowCount() == 1) { - AaRankEffects entry{}; + AaRankEffects e{}; - entry.rank_id = atoi(row[0]); - entry.slot = atoi(row[1]); - entry.effect_id = atoi(row[2]); - entry.base1 = atoi(row[3]); - entry.base2 = atoi(row[4]); + e.rank_id = atoi(row[0]); + e.slot = atoi(row[1]); + e.effect_id = atoi(row[2]); + e.base1 = atoi(row[3]); + e.base2 = atoi(row[4]); - return entry; + return e; } return NewEntity(); @@ -161,26 +161,26 @@ public: static int UpdateOne( Database& db, - AaRankEffects aa_rank_effects_entry + const AaRankEffects &e ) { - std::vector update_values; + std::vector v; auto columns = Columns(); - update_values.push_back(columns[0] + " = " + std::to_string(aa_rank_effects_entry.rank_id)); - update_values.push_back(columns[1] + " = " + std::to_string(aa_rank_effects_entry.slot)); - update_values.push_back(columns[2] + " = " + std::to_string(aa_rank_effects_entry.effect_id)); - update_values.push_back(columns[3] + " = " + std::to_string(aa_rank_effects_entry.base1)); - update_values.push_back(columns[4] + " = " + std::to_string(aa_rank_effects_entry.base2)); + v.push_back(columns[0] + " = " + std::to_string(e.rank_id)); + v.push_back(columns[1] + " = " + std::to_string(e.slot)); + v.push_back(columns[2] + " = " + std::to_string(e.effect_id)); + v.push_back(columns[3] + " = " + std::to_string(e.base1)); + v.push_back(columns[4] + " = " + std::to_string(e.base2)); auto results = db.QueryDatabase( fmt::format( "UPDATE {} SET {} WHERE {} = {}", TableName(), - Strings::Implode(", ", update_values), + Strings::Implode(", ", v), PrimaryKey(), - aa_rank_effects_entry.rank_id + e.rank_id ) ); @@ -189,55 +189,55 @@ public: static AaRankEffects InsertOne( Database& db, - AaRankEffects aa_rank_effects_entry + AaRankEffects e ) { - std::vector insert_values; + std::vector v; - insert_values.push_back(std::to_string(aa_rank_effects_entry.rank_id)); - insert_values.push_back(std::to_string(aa_rank_effects_entry.slot)); - insert_values.push_back(std::to_string(aa_rank_effects_entry.effect_id)); - insert_values.push_back(std::to_string(aa_rank_effects_entry.base1)); - insert_values.push_back(std::to_string(aa_rank_effects_entry.base2)); + v.push_back(std::to_string(e.rank_id)); + v.push_back(std::to_string(e.slot)); + v.push_back(std::to_string(e.effect_id)); + v.push_back(std::to_string(e.base1)); + v.push_back(std::to_string(e.base2)); auto results = db.QueryDatabase( fmt::format( "{} VALUES ({})", BaseInsert(), - Strings::Implode(",", insert_values) + Strings::Implode(",", v) ) ); if (results.Success()) { - aa_rank_effects_entry.rank_id = results.LastInsertedID(); - return aa_rank_effects_entry; + e.rank_id = results.LastInsertedID(); + return e; } - aa_rank_effects_entry = NewEntity(); + e = NewEntity(); - return aa_rank_effects_entry; + return e; } static int InsertMany( Database& db, - std::vector aa_rank_effects_entries + const std::vector &entries ) { std::vector insert_chunks; - for (auto &aa_rank_effects_entry: aa_rank_effects_entries) { - std::vector insert_values; + for (auto &e: entries) { + std::vector v; - insert_values.push_back(std::to_string(aa_rank_effects_entry.rank_id)); - insert_values.push_back(std::to_string(aa_rank_effects_entry.slot)); - insert_values.push_back(std::to_string(aa_rank_effects_entry.effect_id)); - insert_values.push_back(std::to_string(aa_rank_effects_entry.base1)); - insert_values.push_back(std::to_string(aa_rank_effects_entry.base2)); + v.push_back(std::to_string(e.rank_id)); + v.push_back(std::to_string(e.slot)); + v.push_back(std::to_string(e.effect_id)); + v.push_back(std::to_string(e.base1)); + v.push_back(std::to_string(e.base2)); - insert_chunks.push_back("(" + Strings::Implode(",", insert_values) + ")"); + insert_chunks.push_back("(" + Strings::Implode(",", v) + ")"); } - std::vector insert_values; + std::vector v; auto results = db.QueryDatabase( fmt::format( @@ -264,21 +264,21 @@ public: all_entries.reserve(results.RowCount()); for (auto row = results.begin(); row != results.end(); ++row) { - AaRankEffects entry{}; + AaRankEffects e{}; - entry.rank_id = atoi(row[0]); - entry.slot = atoi(row[1]); - entry.effect_id = atoi(row[2]); - entry.base1 = atoi(row[3]); - entry.base2 = atoi(row[4]); + e.rank_id = atoi(row[0]); + e.slot = atoi(row[1]); + e.effect_id = atoi(row[2]); + e.base1 = atoi(row[3]); + e.base2 = atoi(row[4]); - all_entries.push_back(entry); + all_entries.push_back(e); } return all_entries; } - static std::vector GetWhere(Database& db, std::string where_filter) + static std::vector GetWhere(Database& db, const std::string &where_filter) { std::vector all_entries; @@ -293,21 +293,21 @@ public: all_entries.reserve(results.RowCount()); for (auto row = results.begin(); row != results.end(); ++row) { - AaRankEffects entry{}; + AaRankEffects e{}; - entry.rank_id = atoi(row[0]); - entry.slot = atoi(row[1]); - entry.effect_id = atoi(row[2]); - entry.base1 = atoi(row[3]); - entry.base2 = atoi(row[4]); + e.rank_id = atoi(row[0]); + e.slot = atoi(row[1]); + e.effect_id = atoi(row[2]); + e.base1 = atoi(row[3]); + e.base2 = atoi(row[4]); - all_entries.push_back(entry); + all_entries.push_back(e); } return all_entries; } - static int DeleteWhere(Database& db, std::string where_filter) + static int DeleteWhere(Database& db, const std::string &where_filter) { auto results = db.QueryDatabase( fmt::format( @@ -332,6 +332,32 @@ public: 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); + } + }; #endif //EQEMU_BASE_AA_RANK_EFFECTS_REPOSITORY_H diff --git a/common/repositories/base/base_aa_rank_prereqs_repository.h b/common/repositories/base/base_aa_rank_prereqs_repository.h index 605255948..429133872 100644 --- a/common/repositories/base/base_aa_rank_prereqs_repository.h +++ b/common/repositories/base/base_aa_rank_prereqs_repository.h @@ -82,16 +82,16 @@ public: static AaRankPrereqs NewEntity() { - AaRankPrereqs entry{}; + AaRankPrereqs e{}; - entry.rank_id = 0; - entry.aa_id = 0; - entry.points = 0; + e.rank_id = 0; + e.aa_id = 0; + e.points = 0; - return entry; + return e; } - static AaRankPrereqs GetAaRankPrereqsEntry( + static AaRankPrereqs GetAaRankPrereqs( const std::vector &aa_rank_prereqss, int aa_rank_prereqs_id ) @@ -120,13 +120,13 @@ public: auto row = results.begin(); if (results.RowCount() == 1) { - AaRankPrereqs entry{}; + AaRankPrereqs e{}; - entry.rank_id = atoi(row[0]); - entry.aa_id = atoi(row[1]); - entry.points = atoi(row[2]); + e.rank_id = atoi(row[0]); + e.aa_id = atoi(row[1]); + e.points = atoi(row[2]); - return entry; + return e; } return NewEntity(); @@ -151,24 +151,24 @@ public: static int UpdateOne( Database& db, - AaRankPrereqs aa_rank_prereqs_entry + const AaRankPrereqs &e ) { - std::vector update_values; + std::vector v; auto columns = Columns(); - update_values.push_back(columns[0] + " = " + std::to_string(aa_rank_prereqs_entry.rank_id)); - update_values.push_back(columns[1] + " = " + std::to_string(aa_rank_prereqs_entry.aa_id)); - update_values.push_back(columns[2] + " = " + std::to_string(aa_rank_prereqs_entry.points)); + v.push_back(columns[0] + " = " + std::to_string(e.rank_id)); + v.push_back(columns[1] + " = " + std::to_string(e.aa_id)); + v.push_back(columns[2] + " = " + std::to_string(e.points)); auto results = db.QueryDatabase( fmt::format( "UPDATE {} SET {} WHERE {} = {}", TableName(), - Strings::Implode(", ", update_values), + Strings::Implode(", ", v), PrimaryKey(), - aa_rank_prereqs_entry.rank_id + e.rank_id ) ); @@ -177,51 +177,51 @@ public: static AaRankPrereqs InsertOne( Database& db, - AaRankPrereqs aa_rank_prereqs_entry + AaRankPrereqs e ) { - std::vector insert_values; + std::vector v; - insert_values.push_back(std::to_string(aa_rank_prereqs_entry.rank_id)); - insert_values.push_back(std::to_string(aa_rank_prereqs_entry.aa_id)); - insert_values.push_back(std::to_string(aa_rank_prereqs_entry.points)); + v.push_back(std::to_string(e.rank_id)); + v.push_back(std::to_string(e.aa_id)); + v.push_back(std::to_string(e.points)); auto results = db.QueryDatabase( fmt::format( "{} VALUES ({})", BaseInsert(), - Strings::Implode(",", insert_values) + Strings::Implode(",", v) ) ); if (results.Success()) { - aa_rank_prereqs_entry.rank_id = results.LastInsertedID(); - return aa_rank_prereqs_entry; + e.rank_id = results.LastInsertedID(); + return e; } - aa_rank_prereqs_entry = NewEntity(); + e = NewEntity(); - return aa_rank_prereqs_entry; + return e; } static int InsertMany( Database& db, - std::vector aa_rank_prereqs_entries + const std::vector &entries ) { std::vector insert_chunks; - for (auto &aa_rank_prereqs_entry: aa_rank_prereqs_entries) { - std::vector insert_values; + for (auto &e: entries) { + std::vector v; - insert_values.push_back(std::to_string(aa_rank_prereqs_entry.rank_id)); - insert_values.push_back(std::to_string(aa_rank_prereqs_entry.aa_id)); - insert_values.push_back(std::to_string(aa_rank_prereqs_entry.points)); + v.push_back(std::to_string(e.rank_id)); + v.push_back(std::to_string(e.aa_id)); + v.push_back(std::to_string(e.points)); - insert_chunks.push_back("(" + Strings::Implode(",", insert_values) + ")"); + insert_chunks.push_back("(" + Strings::Implode(",", v) + ")"); } - std::vector insert_values; + std::vector v; auto results = db.QueryDatabase( fmt::format( @@ -248,19 +248,19 @@ public: all_entries.reserve(results.RowCount()); for (auto row = results.begin(); row != results.end(); ++row) { - AaRankPrereqs entry{}; + AaRankPrereqs e{}; - entry.rank_id = atoi(row[0]); - entry.aa_id = atoi(row[1]); - entry.points = atoi(row[2]); + e.rank_id = atoi(row[0]); + e.aa_id = atoi(row[1]); + e.points = atoi(row[2]); - all_entries.push_back(entry); + all_entries.push_back(e); } return all_entries; } - static std::vector GetWhere(Database& db, std::string where_filter) + static std::vector GetWhere(Database& db, const std::string &where_filter) { std::vector all_entries; @@ -275,19 +275,19 @@ public: all_entries.reserve(results.RowCount()); for (auto row = results.begin(); row != results.end(); ++row) { - AaRankPrereqs entry{}; + AaRankPrereqs e{}; - entry.rank_id = atoi(row[0]); - entry.aa_id = atoi(row[1]); - entry.points = atoi(row[2]); + e.rank_id = atoi(row[0]); + e.aa_id = atoi(row[1]); + e.points = atoi(row[2]); - all_entries.push_back(entry); + all_entries.push_back(e); } return all_entries; } - static int DeleteWhere(Database& db, std::string where_filter) + static int DeleteWhere(Database& db, const std::string &where_filter) { auto results = db.QueryDatabase( fmt::format( @@ -312,6 +312,32 @@ public: 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); + } + }; #endif //EQEMU_BASE_AA_RANK_PREREQS_REPOSITORY_H diff --git a/common/repositories/base/base_aa_ranks_repository.h b/common/repositories/base/base_aa_ranks_repository.h index c16d86451..48ca172df 100644 --- a/common/repositories/base/base_aa_ranks_repository.h +++ b/common/repositories/base/base_aa_ranks_repository.h @@ -112,26 +112,26 @@ public: static AaRanks NewEntity() { - AaRanks entry{}; + AaRanks e{}; - entry.id = 0; - entry.upper_hotkey_sid = -1; - entry.lower_hotkey_sid = -1; - entry.title_sid = -1; - entry.desc_sid = -1; - entry.cost = 1; - entry.level_req = 51; - entry.spell = -1; - entry.spell_type = 0; - entry.recast_time = 0; - entry.expansion = 0; - entry.prev_id = -1; - entry.next_id = -1; + e.id = 0; + e.upper_hotkey_sid = -1; + e.lower_hotkey_sid = -1; + e.title_sid = -1; + e.desc_sid = -1; + e.cost = 1; + e.level_req = 51; + e.spell = -1; + e.spell_type = 0; + e.recast_time = 0; + e.expansion = 0; + e.prev_id = -1; + e.next_id = -1; - return entry; + return e; } - static AaRanks GetAaRanksEntry( + static AaRanks GetAaRanks( const std::vector &aa_rankss, int aa_ranks_id ) @@ -160,23 +160,23 @@ public: auto row = results.begin(); if (results.RowCount() == 1) { - AaRanks entry{}; + AaRanks e{}; - entry.id = atoi(row[0]); - entry.upper_hotkey_sid = atoi(row[1]); - entry.lower_hotkey_sid = atoi(row[2]); - entry.title_sid = atoi(row[3]); - entry.desc_sid = atoi(row[4]); - entry.cost = atoi(row[5]); - entry.level_req = atoi(row[6]); - entry.spell = atoi(row[7]); - entry.spell_type = atoi(row[8]); - entry.recast_time = atoi(row[9]); - entry.expansion = atoi(row[10]); - entry.prev_id = atoi(row[11]); - entry.next_id = atoi(row[12]); + e.id = atoi(row[0]); + e.upper_hotkey_sid = atoi(row[1]); + e.lower_hotkey_sid = atoi(row[2]); + e.title_sid = atoi(row[3]); + e.desc_sid = atoi(row[4]); + e.cost = atoi(row[5]); + e.level_req = atoi(row[6]); + e.spell = atoi(row[7]); + e.spell_type = atoi(row[8]); + e.recast_time = atoi(row[9]); + e.expansion = atoi(row[10]); + e.prev_id = atoi(row[11]); + e.next_id = atoi(row[12]); - return entry; + return e; } return NewEntity(); @@ -201,34 +201,34 @@ public: static int UpdateOne( Database& db, - AaRanks aa_ranks_entry + const AaRanks &e ) { - std::vector update_values; + std::vector v; auto columns = Columns(); - update_values.push_back(columns[0] + " = " + std::to_string(aa_ranks_entry.id)); - update_values.push_back(columns[1] + " = " + std::to_string(aa_ranks_entry.upper_hotkey_sid)); - update_values.push_back(columns[2] + " = " + std::to_string(aa_ranks_entry.lower_hotkey_sid)); - update_values.push_back(columns[3] + " = " + std::to_string(aa_ranks_entry.title_sid)); - update_values.push_back(columns[4] + " = " + std::to_string(aa_ranks_entry.desc_sid)); - update_values.push_back(columns[5] + " = " + std::to_string(aa_ranks_entry.cost)); - update_values.push_back(columns[6] + " = " + std::to_string(aa_ranks_entry.level_req)); - update_values.push_back(columns[7] + " = " + std::to_string(aa_ranks_entry.spell)); - update_values.push_back(columns[8] + " = " + std::to_string(aa_ranks_entry.spell_type)); - update_values.push_back(columns[9] + " = " + std::to_string(aa_ranks_entry.recast_time)); - update_values.push_back(columns[10] + " = " + std::to_string(aa_ranks_entry.expansion)); - update_values.push_back(columns[11] + " = " + std::to_string(aa_ranks_entry.prev_id)); - update_values.push_back(columns[12] + " = " + std::to_string(aa_ranks_entry.next_id)); + v.push_back(columns[0] + " = " + std::to_string(e.id)); + v.push_back(columns[1] + " = " + std::to_string(e.upper_hotkey_sid)); + v.push_back(columns[2] + " = " + std::to_string(e.lower_hotkey_sid)); + v.push_back(columns[3] + " = " + std::to_string(e.title_sid)); + v.push_back(columns[4] + " = " + std::to_string(e.desc_sid)); + v.push_back(columns[5] + " = " + std::to_string(e.cost)); + v.push_back(columns[6] + " = " + std::to_string(e.level_req)); + v.push_back(columns[7] + " = " + std::to_string(e.spell)); + v.push_back(columns[8] + " = " + std::to_string(e.spell_type)); + v.push_back(columns[9] + " = " + std::to_string(e.recast_time)); + v.push_back(columns[10] + " = " + std::to_string(e.expansion)); + v.push_back(columns[11] + " = " + std::to_string(e.prev_id)); + v.push_back(columns[12] + " = " + std::to_string(e.next_id)); auto results = db.QueryDatabase( fmt::format( "UPDATE {} SET {} WHERE {} = {}", TableName(), - Strings::Implode(", ", update_values), + Strings::Implode(", ", v), PrimaryKey(), - aa_ranks_entry.id + e.id ) ); @@ -237,71 +237,71 @@ public: static AaRanks InsertOne( Database& db, - AaRanks aa_ranks_entry + AaRanks e ) { - std::vector insert_values; + std::vector v; - insert_values.push_back(std::to_string(aa_ranks_entry.id)); - insert_values.push_back(std::to_string(aa_ranks_entry.upper_hotkey_sid)); - insert_values.push_back(std::to_string(aa_ranks_entry.lower_hotkey_sid)); - insert_values.push_back(std::to_string(aa_ranks_entry.title_sid)); - insert_values.push_back(std::to_string(aa_ranks_entry.desc_sid)); - insert_values.push_back(std::to_string(aa_ranks_entry.cost)); - insert_values.push_back(std::to_string(aa_ranks_entry.level_req)); - insert_values.push_back(std::to_string(aa_ranks_entry.spell)); - insert_values.push_back(std::to_string(aa_ranks_entry.spell_type)); - insert_values.push_back(std::to_string(aa_ranks_entry.recast_time)); - insert_values.push_back(std::to_string(aa_ranks_entry.expansion)); - insert_values.push_back(std::to_string(aa_ranks_entry.prev_id)); - insert_values.push_back(std::to_string(aa_ranks_entry.next_id)); + v.push_back(std::to_string(e.id)); + v.push_back(std::to_string(e.upper_hotkey_sid)); + v.push_back(std::to_string(e.lower_hotkey_sid)); + v.push_back(std::to_string(e.title_sid)); + v.push_back(std::to_string(e.desc_sid)); + v.push_back(std::to_string(e.cost)); + v.push_back(std::to_string(e.level_req)); + v.push_back(std::to_string(e.spell)); + v.push_back(std::to_string(e.spell_type)); + v.push_back(std::to_string(e.recast_time)); + v.push_back(std::to_string(e.expansion)); + v.push_back(std::to_string(e.prev_id)); + v.push_back(std::to_string(e.next_id)); auto results = db.QueryDatabase( fmt::format( "{} VALUES ({})", BaseInsert(), - Strings::Implode(",", insert_values) + Strings::Implode(",", v) ) ); if (results.Success()) { - aa_ranks_entry.id = results.LastInsertedID(); - return aa_ranks_entry; + e.id = results.LastInsertedID(); + return e; } - aa_ranks_entry = NewEntity(); + e = NewEntity(); - return aa_ranks_entry; + return e; } static int InsertMany( Database& db, - std::vector aa_ranks_entries + const std::vector &entries ) { std::vector insert_chunks; - for (auto &aa_ranks_entry: aa_ranks_entries) { - std::vector insert_values; + for (auto &e: entries) { + std::vector v; - insert_values.push_back(std::to_string(aa_ranks_entry.id)); - insert_values.push_back(std::to_string(aa_ranks_entry.upper_hotkey_sid)); - insert_values.push_back(std::to_string(aa_ranks_entry.lower_hotkey_sid)); - insert_values.push_back(std::to_string(aa_ranks_entry.title_sid)); - insert_values.push_back(std::to_string(aa_ranks_entry.desc_sid)); - insert_values.push_back(std::to_string(aa_ranks_entry.cost)); - insert_values.push_back(std::to_string(aa_ranks_entry.level_req)); - insert_values.push_back(std::to_string(aa_ranks_entry.spell)); - insert_values.push_back(std::to_string(aa_ranks_entry.spell_type)); - insert_values.push_back(std::to_string(aa_ranks_entry.recast_time)); - insert_values.push_back(std::to_string(aa_ranks_entry.expansion)); - insert_values.push_back(std::to_string(aa_ranks_entry.prev_id)); - insert_values.push_back(std::to_string(aa_ranks_entry.next_id)); + v.push_back(std::to_string(e.id)); + v.push_back(std::to_string(e.upper_hotkey_sid)); + v.push_back(std::to_string(e.lower_hotkey_sid)); + v.push_back(std::to_string(e.title_sid)); + v.push_back(std::to_string(e.desc_sid)); + v.push_back(std::to_string(e.cost)); + v.push_back(std::to_string(e.level_req)); + v.push_back(std::to_string(e.spell)); + v.push_back(std::to_string(e.spell_type)); + v.push_back(std::to_string(e.recast_time)); + v.push_back(std::to_string(e.expansion)); + v.push_back(std::to_string(e.prev_id)); + v.push_back(std::to_string(e.next_id)); - insert_chunks.push_back("(" + Strings::Implode(",", insert_values) + ")"); + insert_chunks.push_back("(" + Strings::Implode(",", v) + ")"); } - std::vector insert_values; + std::vector v; auto results = db.QueryDatabase( fmt::format( @@ -328,29 +328,29 @@ public: all_entries.reserve(results.RowCount()); for (auto row = results.begin(); row != results.end(); ++row) { - AaRanks entry{}; + AaRanks e{}; - entry.id = atoi(row[0]); - entry.upper_hotkey_sid = atoi(row[1]); - entry.lower_hotkey_sid = atoi(row[2]); - entry.title_sid = atoi(row[3]); - entry.desc_sid = atoi(row[4]); - entry.cost = atoi(row[5]); - entry.level_req = atoi(row[6]); - entry.spell = atoi(row[7]); - entry.spell_type = atoi(row[8]); - entry.recast_time = atoi(row[9]); - entry.expansion = atoi(row[10]); - entry.prev_id = atoi(row[11]); - entry.next_id = atoi(row[12]); + e.id = atoi(row[0]); + e.upper_hotkey_sid = atoi(row[1]); + e.lower_hotkey_sid = atoi(row[2]); + e.title_sid = atoi(row[3]); + e.desc_sid = atoi(row[4]); + e.cost = atoi(row[5]); + e.level_req = atoi(row[6]); + e.spell = atoi(row[7]); + e.spell_type = atoi(row[8]); + e.recast_time = atoi(row[9]); + e.expansion = atoi(row[10]); + e.prev_id = atoi(row[11]); + e.next_id = atoi(row[12]); - all_entries.push_back(entry); + all_entries.push_back(e); } return all_entries; } - static std::vector GetWhere(Database& db, std::string where_filter) + static std::vector GetWhere(Database& db, const std::string &where_filter) { std::vector all_entries; @@ -365,29 +365,29 @@ public: all_entries.reserve(results.RowCount()); for (auto row = results.begin(); row != results.end(); ++row) { - AaRanks entry{}; + AaRanks e{}; - entry.id = atoi(row[0]); - entry.upper_hotkey_sid = atoi(row[1]); - entry.lower_hotkey_sid = atoi(row[2]); - entry.title_sid = atoi(row[3]); - entry.desc_sid = atoi(row[4]); - entry.cost = atoi(row[5]); - entry.level_req = atoi(row[6]); - entry.spell = atoi(row[7]); - entry.spell_type = atoi(row[8]); - entry.recast_time = atoi(row[9]); - entry.expansion = atoi(row[10]); - entry.prev_id = atoi(row[11]); - entry.next_id = atoi(row[12]); + e.id = atoi(row[0]); + e.upper_hotkey_sid = atoi(row[1]); + e.lower_hotkey_sid = atoi(row[2]); + e.title_sid = atoi(row[3]); + e.desc_sid = atoi(row[4]); + e.cost = atoi(row[5]); + e.level_req = atoi(row[6]); + e.spell = atoi(row[7]); + e.spell_type = atoi(row[8]); + e.recast_time = atoi(row[9]); + e.expansion = atoi(row[10]); + e.prev_id = atoi(row[11]); + e.next_id = atoi(row[12]); - all_entries.push_back(entry); + all_entries.push_back(e); } return all_entries; } - static int DeleteWhere(Database& db, std::string where_filter) + static int DeleteWhere(Database& db, const std::string &where_filter) { auto results = db.QueryDatabase( fmt::format( @@ -412,6 +412,32 @@ public: 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); + } + }; #endif //EQEMU_BASE_AA_RANKS_REPOSITORY_H diff --git a/common/repositories/base/base_account_flags_repository.h b/common/repositories/base/base_account_flags_repository.h index 0a47fec36..47639dd5d 100644 --- a/common/repositories/base/base_account_flags_repository.h +++ b/common/repositories/base/base_account_flags_repository.h @@ -82,16 +82,16 @@ public: static AccountFlags NewEntity() { - AccountFlags entry{}; + AccountFlags e{}; - entry.p_accid = 0; - entry.p_flag = ""; - entry.p_value = ""; + e.p_accid = 0; + e.p_flag = ""; + e.p_value = ""; - return entry; + return e; } - static AccountFlags GetAccountFlagsEntry( + static AccountFlags GetAccountFlags( const std::vector &account_flagss, int account_flags_id ) @@ -120,13 +120,13 @@ public: auto row = results.begin(); if (results.RowCount() == 1) { - AccountFlags entry{}; + AccountFlags e{}; - entry.p_accid = atoi(row[0]); - entry.p_flag = row[1] ? row[1] : ""; - entry.p_value = row[2] ? row[2] : ""; + e.p_accid = atoi(row[0]); + e.p_flag = row[1] ? row[1] : ""; + e.p_value = row[2] ? row[2] : ""; - return entry; + return e; } return NewEntity(); @@ -151,24 +151,24 @@ public: static int UpdateOne( Database& db, - AccountFlags account_flags_entry + const AccountFlags &e ) { - std::vector update_values; + std::vector v; auto columns = Columns(); - update_values.push_back(columns[0] + " = " + std::to_string(account_flags_entry.p_accid)); - update_values.push_back(columns[1] + " = '" + Strings::Escape(account_flags_entry.p_flag) + "'"); - update_values.push_back(columns[2] + " = '" + Strings::Escape(account_flags_entry.p_value) + "'"); + v.push_back(columns[0] + " = " + std::to_string(e.p_accid)); + v.push_back(columns[1] + " = '" + Strings::Escape(e.p_flag) + "'"); + v.push_back(columns[2] + " = '" + Strings::Escape(e.p_value) + "'"); auto results = db.QueryDatabase( fmt::format( "UPDATE {} SET {} WHERE {} = {}", TableName(), - Strings::Implode(", ", update_values), + Strings::Implode(", ", v), PrimaryKey(), - account_flags_entry.p_accid + e.p_accid ) ); @@ -177,51 +177,51 @@ public: static AccountFlags InsertOne( Database& db, - AccountFlags account_flags_entry + AccountFlags e ) { - std::vector insert_values; + std::vector v; - insert_values.push_back(std::to_string(account_flags_entry.p_accid)); - insert_values.push_back("'" + Strings::Escape(account_flags_entry.p_flag) + "'"); - insert_values.push_back("'" + Strings::Escape(account_flags_entry.p_value) + "'"); + v.push_back(std::to_string(e.p_accid)); + v.push_back("'" + Strings::Escape(e.p_flag) + "'"); + v.push_back("'" + Strings::Escape(e.p_value) + "'"); auto results = db.QueryDatabase( fmt::format( "{} VALUES ({})", BaseInsert(), - Strings::Implode(",", insert_values) + Strings::Implode(",", v) ) ); if (results.Success()) { - account_flags_entry.p_accid = results.LastInsertedID(); - return account_flags_entry; + e.p_accid = results.LastInsertedID(); + return e; } - account_flags_entry = NewEntity(); + e = NewEntity(); - return account_flags_entry; + return e; } static int InsertMany( Database& db, - std::vector account_flags_entries + const std::vector &entries ) { std::vector insert_chunks; - for (auto &account_flags_entry: account_flags_entries) { - std::vector insert_values; + for (auto &e: entries) { + std::vector v; - insert_values.push_back(std::to_string(account_flags_entry.p_accid)); - insert_values.push_back("'" + Strings::Escape(account_flags_entry.p_flag) + "'"); - insert_values.push_back("'" + Strings::Escape(account_flags_entry.p_value) + "'"); + v.push_back(std::to_string(e.p_accid)); + v.push_back("'" + Strings::Escape(e.p_flag) + "'"); + v.push_back("'" + Strings::Escape(e.p_value) + "'"); - insert_chunks.push_back("(" + Strings::Implode(",", insert_values) + ")"); + insert_chunks.push_back("(" + Strings::Implode(",", v) + ")"); } - std::vector insert_values; + std::vector v; auto results = db.QueryDatabase( fmt::format( @@ -248,19 +248,19 @@ public: all_entries.reserve(results.RowCount()); for (auto row = results.begin(); row != results.end(); ++row) { - AccountFlags entry{}; + AccountFlags e{}; - entry.p_accid = atoi(row[0]); - entry.p_flag = row[1] ? row[1] : ""; - entry.p_value = row[2] ? row[2] : ""; + e.p_accid = atoi(row[0]); + e.p_flag = row[1] ? row[1] : ""; + e.p_value = row[2] ? row[2] : ""; - all_entries.push_back(entry); + all_entries.push_back(e); } return all_entries; } - static std::vector GetWhere(Database& db, std::string where_filter) + static std::vector GetWhere(Database& db, const std::string &where_filter) { std::vector all_entries; @@ -275,19 +275,19 @@ public: all_entries.reserve(results.RowCount()); for (auto row = results.begin(); row != results.end(); ++row) { - AccountFlags entry{}; + AccountFlags e{}; - entry.p_accid = atoi(row[0]); - entry.p_flag = row[1] ? row[1] : ""; - entry.p_value = row[2] ? row[2] : ""; + e.p_accid = atoi(row[0]); + e.p_flag = row[1] ? row[1] : ""; + e.p_value = row[2] ? row[2] : ""; - all_entries.push_back(entry); + all_entries.push_back(e); } return all_entries; } - static int DeleteWhere(Database& db, std::string where_filter) + static int DeleteWhere(Database& db, const std::string &where_filter) { auto results = db.QueryDatabase( fmt::format( @@ -312,6 +312,32 @@ public: 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); + } + }; #endif //EQEMU_BASE_ACCOUNT_FLAGS_REPOSITORY_H diff --git a/common/repositories/base/base_account_ip_repository.h b/common/repositories/base/base_account_ip_repository.h index bc889db6c..b9030f355 100644 --- a/common/repositories/base/base_account_ip_repository.h +++ b/common/repositories/base/base_account_ip_repository.h @@ -85,17 +85,17 @@ public: static AccountIp NewEntity() { - AccountIp entry{}; + AccountIp e{}; - entry.accid = 0; - entry.ip = ""; - entry.count = 1; - entry.lastused = std::time(nullptr); + e.accid = 0; + e.ip = ""; + e.count = 1; + e.lastused = std::time(nullptr); - return entry; + return e; } - static AccountIp GetAccountIpEntry( + static AccountIp GetAccountIp( const std::vector &account_ips, int account_ip_id ) @@ -124,14 +124,14 @@ public: auto row = results.begin(); if (results.RowCount() == 1) { - AccountIp entry{}; + AccountIp e{}; - entry.accid = atoi(row[0]); - entry.ip = row[1] ? row[1] : ""; - entry.count = atoi(row[2]); - entry.lastused = row[3] ? row[3] : ""; + e.accid = atoi(row[0]); + e.ip = row[1] ? row[1] : ""; + e.count = atoi(row[2]); + e.lastused = row[3] ? row[3] : ""; - return entry; + return e; } return NewEntity(); @@ -156,25 +156,25 @@ public: static int UpdateOne( Database& db, - AccountIp account_ip_entry + const AccountIp &e ) { - std::vector update_values; + std::vector v; auto columns = Columns(); - update_values.push_back(columns[0] + " = " + std::to_string(account_ip_entry.accid)); - update_values.push_back(columns[1] + " = '" + Strings::Escape(account_ip_entry.ip) + "'"); - update_values.push_back(columns[2] + " = " + std::to_string(account_ip_entry.count)); - update_values.push_back(columns[3] + " = '" + Strings::Escape(account_ip_entry.lastused) + "'"); + v.push_back(columns[0] + " = " + std::to_string(e.accid)); + v.push_back(columns[1] + " = '" + Strings::Escape(e.ip) + "'"); + v.push_back(columns[2] + " = " + std::to_string(e.count)); + v.push_back(columns[3] + " = '" + Strings::Escape(e.lastused) + "'"); auto results = db.QueryDatabase( fmt::format( "UPDATE {} SET {} WHERE {} = {}", TableName(), - Strings::Implode(", ", update_values), + Strings::Implode(", ", v), PrimaryKey(), - account_ip_entry.accid + e.accid ) ); @@ -183,53 +183,53 @@ public: static AccountIp InsertOne( Database& db, - AccountIp account_ip_entry + AccountIp e ) { - std::vector insert_values; + std::vector v; - insert_values.push_back(std::to_string(account_ip_entry.accid)); - insert_values.push_back("'" + Strings::Escape(account_ip_entry.ip) + "'"); - insert_values.push_back(std::to_string(account_ip_entry.count)); - insert_values.push_back("'" + Strings::Escape(account_ip_entry.lastused) + "'"); + v.push_back(std::to_string(e.accid)); + v.push_back("'" + Strings::Escape(e.ip) + "'"); + v.push_back(std::to_string(e.count)); + v.push_back("'" + Strings::Escape(e.lastused) + "'"); auto results = db.QueryDatabase( fmt::format( "{} VALUES ({})", BaseInsert(), - Strings::Implode(",", insert_values) + Strings::Implode(",", v) ) ); if (results.Success()) { - account_ip_entry.accid = results.LastInsertedID(); - return account_ip_entry; + e.accid = results.LastInsertedID(); + return e; } - account_ip_entry = NewEntity(); + e = NewEntity(); - return account_ip_entry; + return e; } static int InsertMany( Database& db, - std::vector account_ip_entries + const std::vector &entries ) { std::vector insert_chunks; - for (auto &account_ip_entry: account_ip_entries) { - std::vector insert_values; + for (auto &e: entries) { + std::vector v; - insert_values.push_back(std::to_string(account_ip_entry.accid)); - insert_values.push_back("'" + Strings::Escape(account_ip_entry.ip) + "'"); - insert_values.push_back(std::to_string(account_ip_entry.count)); - insert_values.push_back("'" + Strings::Escape(account_ip_entry.lastused) + "'"); + v.push_back(std::to_string(e.accid)); + v.push_back("'" + Strings::Escape(e.ip) + "'"); + v.push_back(std::to_string(e.count)); + v.push_back("'" + Strings::Escape(e.lastused) + "'"); - insert_chunks.push_back("(" + Strings::Implode(",", insert_values) + ")"); + insert_chunks.push_back("(" + Strings::Implode(",", v) + ")"); } - std::vector insert_values; + std::vector v; auto results = db.QueryDatabase( fmt::format( @@ -256,20 +256,20 @@ public: all_entries.reserve(results.RowCount()); for (auto row = results.begin(); row != results.end(); ++row) { - AccountIp entry{}; + AccountIp e{}; - entry.accid = atoi(row[0]); - entry.ip = row[1] ? row[1] : ""; - entry.count = atoi(row[2]); - entry.lastused = row[3] ? row[3] : ""; + e.accid = atoi(row[0]); + e.ip = row[1] ? row[1] : ""; + e.count = atoi(row[2]); + e.lastused = row[3] ? row[3] : ""; - all_entries.push_back(entry); + all_entries.push_back(e); } return all_entries; } - static std::vector GetWhere(Database& db, std::string where_filter) + static std::vector GetWhere(Database& db, const std::string &where_filter) { std::vector all_entries; @@ -284,20 +284,20 @@ public: all_entries.reserve(results.RowCount()); for (auto row = results.begin(); row != results.end(); ++row) { - AccountIp entry{}; + AccountIp e{}; - entry.accid = atoi(row[0]); - entry.ip = row[1] ? row[1] : ""; - entry.count = atoi(row[2]); - entry.lastused = row[3] ? row[3] : ""; + e.accid = atoi(row[0]); + e.ip = row[1] ? row[1] : ""; + e.count = atoi(row[2]); + e.lastused = row[3] ? row[3] : ""; - all_entries.push_back(entry); + all_entries.push_back(e); } return all_entries; } - static int DeleteWhere(Database& db, std::string where_filter) + static int DeleteWhere(Database& db, const std::string &where_filter) { auto results = db.QueryDatabase( fmt::format( @@ -322,6 +322,32 @@ public: 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); + } + }; #endif //EQEMU_BASE_ACCOUNT_IP_REPOSITORY_H diff --git a/common/repositories/base/base_account_repository.h b/common/repositories/base/base_account_repository.h index 2c54aa970..57a5c2ab5 100644 --- a/common/repositories/base/base_account_repository.h +++ b/common/repositories/base/base_account_repository.h @@ -145,37 +145,37 @@ public: static Account NewEntity() { - Account entry{}; + Account e{}; - entry.id = 0; - entry.name = ""; - entry.charname = ""; - entry.sharedplat = 0; - entry.password = ""; - entry.status = 0; - entry.ls_id = "eqemu"; - entry.lsaccount_id = 0; - entry.gmspeed = 0; - entry.invulnerable = 0; - entry.flymode = 0; - entry.ignore_tells = 0; - entry.revoked = 0; - entry.karma = 0; - entry.minilogin_ip = ""; - entry.hideme = 0; - entry.rulesflag = 0; - entry.suspendeduntil = 0; - entry.time_creation = 0; - entry.ban_reason = ""; - entry.suspend_reason = ""; - entry.crc_eqgame = ""; - entry.crc_skillcaps = ""; - entry.crc_basedata = ""; + e.id = 0; + e.name = ""; + e.charname = ""; + e.sharedplat = 0; + e.password = ""; + e.status = 0; + e.ls_id = "eqemu"; + e.lsaccount_id = 0; + e.gmspeed = 0; + e.invulnerable = 0; + e.flymode = 0; + e.ignore_tells = 0; + e.revoked = 0; + e.karma = 0; + e.minilogin_ip = ""; + e.hideme = 0; + e.rulesflag = 0; + e.suspendeduntil = 0; + e.time_creation = 0; + e.ban_reason = ""; + e.suspend_reason = ""; + e.crc_eqgame = ""; + e.crc_skillcaps = ""; + e.crc_basedata = ""; - return entry; + return e; } - static Account GetAccountEntry( + static Account GetAccount( const std::vector &accounts, int account_id ) @@ -204,34 +204,34 @@ public: auto row = results.begin(); if (results.RowCount() == 1) { - Account entry{}; + Account e{}; - entry.id = atoi(row[0]); - entry.name = row[1] ? row[1] : ""; - entry.charname = row[2] ? row[2] : ""; - entry.sharedplat = atoi(row[3]); - entry.password = row[4] ? row[4] : ""; - entry.status = atoi(row[5]); - entry.ls_id = row[6] ? row[6] : ""; - entry.lsaccount_id = atoi(row[7]); - entry.gmspeed = atoi(row[8]); - entry.invulnerable = atoi(row[9]); - entry.flymode = atoi(row[10]); - entry.ignore_tells = atoi(row[11]); - entry.revoked = atoi(row[12]); - entry.karma = atoi(row[13]); - entry.minilogin_ip = row[14] ? row[14] : ""; - entry.hideme = atoi(row[15]); - entry.rulesflag = atoi(row[16]); - entry.suspendeduntil = strtoll(row[17] ? row[17] : "-1", nullptr, 10); - entry.time_creation = atoi(row[18]); - entry.ban_reason = row[19] ? row[19] : ""; - entry.suspend_reason = row[20] ? row[20] : ""; - entry.crc_eqgame = row[21] ? row[21] : ""; - entry.crc_skillcaps = row[22] ? row[22] : ""; - entry.crc_basedata = row[23] ? row[23] : ""; + e.id = atoi(row[0]); + e.name = row[1] ? row[1] : ""; + e.charname = row[2] ? row[2] : ""; + e.sharedplat = atoi(row[3]); + e.password = row[4] ? row[4] : ""; + e.status = atoi(row[5]); + e.ls_id = row[6] ? row[6] : ""; + e.lsaccount_id = atoi(row[7]); + e.gmspeed = atoi(row[8]); + e.invulnerable = atoi(row[9]); + e.flymode = atoi(row[10]); + e.ignore_tells = atoi(row[11]); + e.revoked = atoi(row[12]); + e.karma = atoi(row[13]); + e.minilogin_ip = row[14] ? row[14] : ""; + e.hideme = atoi(row[15]); + e.rulesflag = atoi(row[16]); + e.suspendeduntil = strtoll(row[17] ? row[17] : "-1", nullptr, 10); + e.time_creation = atoi(row[18]); + e.ban_reason = row[19] ? row[19] : ""; + e.suspend_reason = row[20] ? row[20] : ""; + e.crc_eqgame = row[21] ? row[21] : ""; + e.crc_skillcaps = row[22] ? row[22] : ""; + e.crc_basedata = row[23] ? row[23] : ""; - return entry; + return e; } return NewEntity(); @@ -256,44 +256,44 @@ public: static int UpdateOne( Database& db, - Account account_entry + const Account &e ) { - std::vector update_values; + std::vector v; auto columns = Columns(); - update_values.push_back(columns[1] + " = '" + Strings::Escape(account_entry.name) + "'"); - update_values.push_back(columns[2] + " = '" + Strings::Escape(account_entry.charname) + "'"); - update_values.push_back(columns[3] + " = " + std::to_string(account_entry.sharedplat)); - update_values.push_back(columns[4] + " = '" + Strings::Escape(account_entry.password) + "'"); - update_values.push_back(columns[5] + " = " + std::to_string(account_entry.status)); - update_values.push_back(columns[6] + " = '" + Strings::Escape(account_entry.ls_id) + "'"); - update_values.push_back(columns[7] + " = " + std::to_string(account_entry.lsaccount_id)); - update_values.push_back(columns[8] + " = " + std::to_string(account_entry.gmspeed)); - update_values.push_back(columns[9] + " = " + std::to_string(account_entry.invulnerable)); - update_values.push_back(columns[10] + " = " + std::to_string(account_entry.flymode)); - update_values.push_back(columns[11] + " = " + std::to_string(account_entry.ignore_tells)); - update_values.push_back(columns[12] + " = " + std::to_string(account_entry.revoked)); - update_values.push_back(columns[13] + " = " + std::to_string(account_entry.karma)); - update_values.push_back(columns[14] + " = '" + Strings::Escape(account_entry.minilogin_ip) + "'"); - update_values.push_back(columns[15] + " = " + std::to_string(account_entry.hideme)); - update_values.push_back(columns[16] + " = " + std::to_string(account_entry.rulesflag)); - update_values.push_back(columns[17] + " = FROM_UNIXTIME(" + (account_entry.suspendeduntil > 0 ? std::to_string(account_entry.suspendeduntil) : "null") + ")"); - update_values.push_back(columns[18] + " = " + std::to_string(account_entry.time_creation)); - update_values.push_back(columns[19] + " = '" + Strings::Escape(account_entry.ban_reason) + "'"); - update_values.push_back(columns[20] + " = '" + Strings::Escape(account_entry.suspend_reason) + "'"); - update_values.push_back(columns[21] + " = '" + Strings::Escape(account_entry.crc_eqgame) + "'"); - update_values.push_back(columns[22] + " = '" + Strings::Escape(account_entry.crc_skillcaps) + "'"); - update_values.push_back(columns[23] + " = '" + Strings::Escape(account_entry.crc_basedata) + "'"); + v.push_back(columns[1] + " = '" + Strings::Escape(e.name) + "'"); + v.push_back(columns[2] + " = '" + Strings::Escape(e.charname) + "'"); + v.push_back(columns[3] + " = " + std::to_string(e.sharedplat)); + v.push_back(columns[4] + " = '" + Strings::Escape(e.password) + "'"); + v.push_back(columns[5] + " = " + std::to_string(e.status)); + v.push_back(columns[6] + " = '" + Strings::Escape(e.ls_id) + "'"); + v.push_back(columns[7] + " = " + std::to_string(e.lsaccount_id)); + v.push_back(columns[8] + " = " + std::to_string(e.gmspeed)); + v.push_back(columns[9] + " = " + std::to_string(e.invulnerable)); + v.push_back(columns[10] + " = " + std::to_string(e.flymode)); + v.push_back(columns[11] + " = " + std::to_string(e.ignore_tells)); + v.push_back(columns[12] + " = " + std::to_string(e.revoked)); + v.push_back(columns[13] + " = " + std::to_string(e.karma)); + v.push_back(columns[14] + " = '" + Strings::Escape(e.minilogin_ip) + "'"); + v.push_back(columns[15] + " = " + std::to_string(e.hideme)); + v.push_back(columns[16] + " = " + std::to_string(e.rulesflag)); + v.push_back(columns[17] + " = FROM_UNIXTIME(" + (e.suspendeduntil > 0 ? std::to_string(e.suspendeduntil) : "null") + ")"); + v.push_back(columns[18] + " = " + std::to_string(e.time_creation)); + v.push_back(columns[19] + " = '" + Strings::Escape(e.ban_reason) + "'"); + v.push_back(columns[20] + " = '" + Strings::Escape(e.suspend_reason) + "'"); + v.push_back(columns[21] + " = '" + Strings::Escape(e.crc_eqgame) + "'"); + v.push_back(columns[22] + " = '" + Strings::Escape(e.crc_skillcaps) + "'"); + v.push_back(columns[23] + " = '" + Strings::Escape(e.crc_basedata) + "'"); auto results = db.QueryDatabase( fmt::format( "UPDATE {} SET {} WHERE {} = {}", TableName(), - Strings::Implode(", ", update_values), + Strings::Implode(", ", v), PrimaryKey(), - account_entry.id + e.id ) ); @@ -302,93 +302,93 @@ public: static Account InsertOne( Database& db, - Account account_entry + Account e ) { - std::vector insert_values; + std::vector v; - insert_values.push_back(std::to_string(account_entry.id)); - insert_values.push_back("'" + Strings::Escape(account_entry.name) + "'"); - insert_values.push_back("'" + Strings::Escape(account_entry.charname) + "'"); - insert_values.push_back(std::to_string(account_entry.sharedplat)); - insert_values.push_back("'" + Strings::Escape(account_entry.password) + "'"); - insert_values.push_back(std::to_string(account_entry.status)); - insert_values.push_back("'" + Strings::Escape(account_entry.ls_id) + "'"); - insert_values.push_back(std::to_string(account_entry.lsaccount_id)); - insert_values.push_back(std::to_string(account_entry.gmspeed)); - insert_values.push_back(std::to_string(account_entry.invulnerable)); - insert_values.push_back(std::to_string(account_entry.flymode)); - insert_values.push_back(std::to_string(account_entry.ignore_tells)); - insert_values.push_back(std::to_string(account_entry.revoked)); - insert_values.push_back(std::to_string(account_entry.karma)); - insert_values.push_back("'" + Strings::Escape(account_entry.minilogin_ip) + "'"); - insert_values.push_back(std::to_string(account_entry.hideme)); - insert_values.push_back(std::to_string(account_entry.rulesflag)); - insert_values.push_back("FROM_UNIXTIME(" + (account_entry.suspendeduntil > 0 ? std::to_string(account_entry.suspendeduntil) : "null") + ")"); - insert_values.push_back(std::to_string(account_entry.time_creation)); - insert_values.push_back("'" + Strings::Escape(account_entry.ban_reason) + "'"); - insert_values.push_back("'" + Strings::Escape(account_entry.suspend_reason) + "'"); - insert_values.push_back("'" + Strings::Escape(account_entry.crc_eqgame) + "'"); - insert_values.push_back("'" + Strings::Escape(account_entry.crc_skillcaps) + "'"); - insert_values.push_back("'" + Strings::Escape(account_entry.crc_basedata) + "'"); + v.push_back(std::to_string(e.id)); + v.push_back("'" + Strings::Escape(e.name) + "'"); + v.push_back("'" + Strings::Escape(e.charname) + "'"); + v.push_back(std::to_string(e.sharedplat)); + v.push_back("'" + Strings::Escape(e.password) + "'"); + v.push_back(std::to_string(e.status)); + v.push_back("'" + Strings::Escape(e.ls_id) + "'"); + v.push_back(std::to_string(e.lsaccount_id)); + v.push_back(std::to_string(e.gmspeed)); + v.push_back(std::to_string(e.invulnerable)); + v.push_back(std::to_string(e.flymode)); + v.push_back(std::to_string(e.ignore_tells)); + v.push_back(std::to_string(e.revoked)); + v.push_back(std::to_string(e.karma)); + v.push_back("'" + Strings::Escape(e.minilogin_ip) + "'"); + v.push_back(std::to_string(e.hideme)); + v.push_back(std::to_string(e.rulesflag)); + v.push_back("FROM_UNIXTIME(" + (e.suspendeduntil > 0 ? std::to_string(e.suspendeduntil) : "null") + ")"); + v.push_back(std::to_string(e.time_creation)); + v.push_back("'" + Strings::Escape(e.ban_reason) + "'"); + v.push_back("'" + Strings::Escape(e.suspend_reason) + "'"); + v.push_back("'" + Strings::Escape(e.crc_eqgame) + "'"); + v.push_back("'" + Strings::Escape(e.crc_skillcaps) + "'"); + v.push_back("'" + Strings::Escape(e.crc_basedata) + "'"); auto results = db.QueryDatabase( fmt::format( "{} VALUES ({})", BaseInsert(), - Strings::Implode(",", insert_values) + Strings::Implode(",", v) ) ); if (results.Success()) { - account_entry.id = results.LastInsertedID(); - return account_entry; + e.id = results.LastInsertedID(); + return e; } - account_entry = NewEntity(); + e = NewEntity(); - return account_entry; + return e; } static int InsertMany( Database& db, - std::vector account_entries + const std::vector &entries ) { std::vector insert_chunks; - for (auto &account_entry: account_entries) { - std::vector insert_values; + for (auto &e: entries) { + std::vector v; - insert_values.push_back(std::to_string(account_entry.id)); - insert_values.push_back("'" + Strings::Escape(account_entry.name) + "'"); - insert_values.push_back("'" + Strings::Escape(account_entry.charname) + "'"); - insert_values.push_back(std::to_string(account_entry.sharedplat)); - insert_values.push_back("'" + Strings::Escape(account_entry.password) + "'"); - insert_values.push_back(std::to_string(account_entry.status)); - insert_values.push_back("'" + Strings::Escape(account_entry.ls_id) + "'"); - insert_values.push_back(std::to_string(account_entry.lsaccount_id)); - insert_values.push_back(std::to_string(account_entry.gmspeed)); - insert_values.push_back(std::to_string(account_entry.invulnerable)); - insert_values.push_back(std::to_string(account_entry.flymode)); - insert_values.push_back(std::to_string(account_entry.ignore_tells)); - insert_values.push_back(std::to_string(account_entry.revoked)); - insert_values.push_back(std::to_string(account_entry.karma)); - insert_values.push_back("'" + Strings::Escape(account_entry.minilogin_ip) + "'"); - insert_values.push_back(std::to_string(account_entry.hideme)); - insert_values.push_back(std::to_string(account_entry.rulesflag)); - insert_values.push_back("FROM_UNIXTIME(" + (account_entry.suspendeduntil > 0 ? std::to_string(account_entry.suspendeduntil) : "null") + ")"); - insert_values.push_back(std::to_string(account_entry.time_creation)); - insert_values.push_back("'" + Strings::Escape(account_entry.ban_reason) + "'"); - insert_values.push_back("'" + Strings::Escape(account_entry.suspend_reason) + "'"); - insert_values.push_back("'" + Strings::Escape(account_entry.crc_eqgame) + "'"); - insert_values.push_back("'" + Strings::Escape(account_entry.crc_skillcaps) + "'"); - insert_values.push_back("'" + Strings::Escape(account_entry.crc_basedata) + "'"); + v.push_back(std::to_string(e.id)); + v.push_back("'" + Strings::Escape(e.name) + "'"); + v.push_back("'" + Strings::Escape(e.charname) + "'"); + v.push_back(std::to_string(e.sharedplat)); + v.push_back("'" + Strings::Escape(e.password) + "'"); + v.push_back(std::to_string(e.status)); + v.push_back("'" + Strings::Escape(e.ls_id) + "'"); + v.push_back(std::to_string(e.lsaccount_id)); + v.push_back(std::to_string(e.gmspeed)); + v.push_back(std::to_string(e.invulnerable)); + v.push_back(std::to_string(e.flymode)); + v.push_back(std::to_string(e.ignore_tells)); + v.push_back(std::to_string(e.revoked)); + v.push_back(std::to_string(e.karma)); + v.push_back("'" + Strings::Escape(e.minilogin_ip) + "'"); + v.push_back(std::to_string(e.hideme)); + v.push_back(std::to_string(e.rulesflag)); + v.push_back("FROM_UNIXTIME(" + (e.suspendeduntil > 0 ? std::to_string(e.suspendeduntil) : "null") + ")"); + v.push_back(std::to_string(e.time_creation)); + v.push_back("'" + Strings::Escape(e.ban_reason) + "'"); + v.push_back("'" + Strings::Escape(e.suspend_reason) + "'"); + v.push_back("'" + Strings::Escape(e.crc_eqgame) + "'"); + v.push_back("'" + Strings::Escape(e.crc_skillcaps) + "'"); + v.push_back("'" + Strings::Escape(e.crc_basedata) + "'"); - insert_chunks.push_back("(" + Strings::Implode(",", insert_values) + ")"); + insert_chunks.push_back("(" + Strings::Implode(",", v) + ")"); } - std::vector insert_values; + std::vector v; auto results = db.QueryDatabase( fmt::format( @@ -415,40 +415,40 @@ public: all_entries.reserve(results.RowCount()); for (auto row = results.begin(); row != results.end(); ++row) { - Account entry{}; + Account e{}; - entry.id = atoi(row[0]); - entry.name = row[1] ? row[1] : ""; - entry.charname = row[2] ? row[2] : ""; - entry.sharedplat = atoi(row[3]); - entry.password = row[4] ? row[4] : ""; - entry.status = atoi(row[5]); - entry.ls_id = row[6] ? row[6] : ""; - entry.lsaccount_id = atoi(row[7]); - entry.gmspeed = atoi(row[8]); - entry.invulnerable = atoi(row[9]); - entry.flymode = atoi(row[10]); - entry.ignore_tells = atoi(row[11]); - entry.revoked = atoi(row[12]); - entry.karma = atoi(row[13]); - entry.minilogin_ip = row[14] ? row[14] : ""; - entry.hideme = atoi(row[15]); - entry.rulesflag = atoi(row[16]); - entry.suspendeduntil = strtoll(row[17] ? row[17] : "-1", nullptr, 10); - entry.time_creation = atoi(row[18]); - entry.ban_reason = row[19] ? row[19] : ""; - entry.suspend_reason = row[20] ? row[20] : ""; - entry.crc_eqgame = row[21] ? row[21] : ""; - entry.crc_skillcaps = row[22] ? row[22] : ""; - entry.crc_basedata = row[23] ? row[23] : ""; + e.id = atoi(row[0]); + e.name = row[1] ? row[1] : ""; + e.charname = row[2] ? row[2] : ""; + e.sharedplat = atoi(row[3]); + e.password = row[4] ? row[4] : ""; + e.status = atoi(row[5]); + e.ls_id = row[6] ? row[6] : ""; + e.lsaccount_id = atoi(row[7]); + e.gmspeed = atoi(row[8]); + e.invulnerable = atoi(row[9]); + e.flymode = atoi(row[10]); + e.ignore_tells = atoi(row[11]); + e.revoked = atoi(row[12]); + e.karma = atoi(row[13]); + e.minilogin_ip = row[14] ? row[14] : ""; + e.hideme = atoi(row[15]); + e.rulesflag = atoi(row[16]); + e.suspendeduntil = strtoll(row[17] ? row[17] : "-1", nullptr, 10); + e.time_creation = atoi(row[18]); + e.ban_reason = row[19] ? row[19] : ""; + e.suspend_reason = row[20] ? row[20] : ""; + e.crc_eqgame = row[21] ? row[21] : ""; + e.crc_skillcaps = row[22] ? row[22] : ""; + e.crc_basedata = row[23] ? row[23] : ""; - all_entries.push_back(entry); + all_entries.push_back(e); } return all_entries; } - static std::vector GetWhere(Database& db, std::string where_filter) + static std::vector GetWhere(Database& db, const std::string &where_filter) { std::vector all_entries; @@ -463,40 +463,40 @@ public: all_entries.reserve(results.RowCount()); for (auto row = results.begin(); row != results.end(); ++row) { - Account entry{}; + Account e{}; - entry.id = atoi(row[0]); - entry.name = row[1] ? row[1] : ""; - entry.charname = row[2] ? row[2] : ""; - entry.sharedplat = atoi(row[3]); - entry.password = row[4] ? row[4] : ""; - entry.status = atoi(row[5]); - entry.ls_id = row[6] ? row[6] : ""; - entry.lsaccount_id = atoi(row[7]); - entry.gmspeed = atoi(row[8]); - entry.invulnerable = atoi(row[9]); - entry.flymode = atoi(row[10]); - entry.ignore_tells = atoi(row[11]); - entry.revoked = atoi(row[12]); - entry.karma = atoi(row[13]); - entry.minilogin_ip = row[14] ? row[14] : ""; - entry.hideme = atoi(row[15]); - entry.rulesflag = atoi(row[16]); - entry.suspendeduntil = strtoll(row[17] ? row[17] : "-1", nullptr, 10); - entry.time_creation = atoi(row[18]); - entry.ban_reason = row[19] ? row[19] : ""; - entry.suspend_reason = row[20] ? row[20] : ""; - entry.crc_eqgame = row[21] ? row[21] : ""; - entry.crc_skillcaps = row[22] ? row[22] : ""; - entry.crc_basedata = row[23] ? row[23] : ""; + e.id = atoi(row[0]); + e.name = row[1] ? row[1] : ""; + e.charname = row[2] ? row[2] : ""; + e.sharedplat = atoi(row[3]); + e.password = row[4] ? row[4] : ""; + e.status = atoi(row[5]); + e.ls_id = row[6] ? row[6] : ""; + e.lsaccount_id = atoi(row[7]); + e.gmspeed = atoi(row[8]); + e.invulnerable = atoi(row[9]); + e.flymode = atoi(row[10]); + e.ignore_tells = atoi(row[11]); + e.revoked = atoi(row[12]); + e.karma = atoi(row[13]); + e.minilogin_ip = row[14] ? row[14] : ""; + e.hideme = atoi(row[15]); + e.rulesflag = atoi(row[16]); + e.suspendeduntil = strtoll(row[17] ? row[17] : "-1", nullptr, 10); + e.time_creation = atoi(row[18]); + e.ban_reason = row[19] ? row[19] : ""; + e.suspend_reason = row[20] ? row[20] : ""; + e.crc_eqgame = row[21] ? row[21] : ""; + e.crc_skillcaps = row[22] ? row[22] : ""; + e.crc_basedata = row[23] ? row[23] : ""; - all_entries.push_back(entry); + all_entries.push_back(e); } return all_entries; } - static int DeleteWhere(Database& db, std::string where_filter) + static int DeleteWhere(Database& db, const std::string &where_filter) { auto results = db.QueryDatabase( fmt::format( @@ -521,6 +521,32 @@ public: 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); + } + }; #endif //EQEMU_BASE_ACCOUNT_REPOSITORY_H diff --git a/common/repositories/base/base_account_rewards_repository.h b/common/repositories/base/base_account_rewards_repository.h index 56ebd8779..d6687576d 100644 --- a/common/repositories/base/base_account_rewards_repository.h +++ b/common/repositories/base/base_account_rewards_repository.h @@ -82,16 +82,16 @@ public: static AccountRewards NewEntity() { - AccountRewards entry{}; + AccountRewards e{}; - entry.account_id = 0; - entry.reward_id = 0; - entry.amount = 0; + e.account_id = 0; + e.reward_id = 0; + e.amount = 0; - return entry; + return e; } - static AccountRewards GetAccountRewardsEntry( + static AccountRewards GetAccountRewards( const std::vector &account_rewardss, int account_rewards_id ) @@ -120,13 +120,13 @@ public: auto row = results.begin(); if (results.RowCount() == 1) { - AccountRewards entry{}; + AccountRewards e{}; - entry.account_id = atoi(row[0]); - entry.reward_id = atoi(row[1]); - entry.amount = atoi(row[2]); + e.account_id = atoi(row[0]); + e.reward_id = atoi(row[1]); + e.amount = atoi(row[2]); - return entry; + return e; } return NewEntity(); @@ -151,24 +151,24 @@ public: static int UpdateOne( Database& db, - AccountRewards account_rewards_entry + const AccountRewards &e ) { - std::vector update_values; + std::vector v; auto columns = Columns(); - update_values.push_back(columns[0] + " = " + std::to_string(account_rewards_entry.account_id)); - update_values.push_back(columns[1] + " = " + std::to_string(account_rewards_entry.reward_id)); - update_values.push_back(columns[2] + " = " + std::to_string(account_rewards_entry.amount)); + v.push_back(columns[0] + " = " + std::to_string(e.account_id)); + v.push_back(columns[1] + " = " + std::to_string(e.reward_id)); + v.push_back(columns[2] + " = " + std::to_string(e.amount)); auto results = db.QueryDatabase( fmt::format( "UPDATE {} SET {} WHERE {} = {}", TableName(), - Strings::Implode(", ", update_values), + Strings::Implode(", ", v), PrimaryKey(), - account_rewards_entry.account_id + e.account_id ) ); @@ -177,51 +177,51 @@ public: static AccountRewards InsertOne( Database& db, - AccountRewards account_rewards_entry + AccountRewards e ) { - std::vector insert_values; + std::vector v; - insert_values.push_back(std::to_string(account_rewards_entry.account_id)); - insert_values.push_back(std::to_string(account_rewards_entry.reward_id)); - insert_values.push_back(std::to_string(account_rewards_entry.amount)); + v.push_back(std::to_string(e.account_id)); + v.push_back(std::to_string(e.reward_id)); + v.push_back(std::to_string(e.amount)); auto results = db.QueryDatabase( fmt::format( "{} VALUES ({})", BaseInsert(), - Strings::Implode(",", insert_values) + Strings::Implode(",", v) ) ); if (results.Success()) { - account_rewards_entry.account_id = results.LastInsertedID(); - return account_rewards_entry; + e.account_id = results.LastInsertedID(); + return e; } - account_rewards_entry = NewEntity(); + e = NewEntity(); - return account_rewards_entry; + return e; } static int InsertMany( Database& db, - std::vector account_rewards_entries + const std::vector &entries ) { std::vector insert_chunks; - for (auto &account_rewards_entry: account_rewards_entries) { - std::vector insert_values; + for (auto &e: entries) { + std::vector v; - insert_values.push_back(std::to_string(account_rewards_entry.account_id)); - insert_values.push_back(std::to_string(account_rewards_entry.reward_id)); - insert_values.push_back(std::to_string(account_rewards_entry.amount)); + v.push_back(std::to_string(e.account_id)); + v.push_back(std::to_string(e.reward_id)); + v.push_back(std::to_string(e.amount)); - insert_chunks.push_back("(" + Strings::Implode(",", insert_values) + ")"); + insert_chunks.push_back("(" + Strings::Implode(",", v) + ")"); } - std::vector insert_values; + std::vector v; auto results = db.QueryDatabase( fmt::format( @@ -248,19 +248,19 @@ public: all_entries.reserve(results.RowCount()); for (auto row = results.begin(); row != results.end(); ++row) { - AccountRewards entry{}; + AccountRewards e{}; - entry.account_id = atoi(row[0]); - entry.reward_id = atoi(row[1]); - entry.amount = atoi(row[2]); + e.account_id = atoi(row[0]); + e.reward_id = atoi(row[1]); + e.amount = atoi(row[2]); - all_entries.push_back(entry); + all_entries.push_back(e); } return all_entries; } - static std::vector GetWhere(Database& db, std::string where_filter) + static std::vector GetWhere(Database& db, const std::string &where_filter) { std::vector all_entries; @@ -275,19 +275,19 @@ public: all_entries.reserve(results.RowCount()); for (auto row = results.begin(); row != results.end(); ++row) { - AccountRewards entry{}; + AccountRewards e{}; - entry.account_id = atoi(row[0]); - entry.reward_id = atoi(row[1]); - entry.amount = atoi(row[2]); + e.account_id = atoi(row[0]); + e.reward_id = atoi(row[1]); + e.amount = atoi(row[2]); - all_entries.push_back(entry); + all_entries.push_back(e); } return all_entries; } - static int DeleteWhere(Database& db, std::string where_filter) + static int DeleteWhere(Database& db, const std::string &where_filter) { auto results = db.QueryDatabase( fmt::format( @@ -312,6 +312,32 @@ public: 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); + } + }; #endif //EQEMU_BASE_ACCOUNT_REWARDS_REPOSITORY_H diff --git a/common/repositories/base/base_adventure_details_repository.h b/common/repositories/base/base_adventure_details_repository.h index 50e76fad5..32f39761d 100644 --- a/common/repositories/base/base_adventure_details_repository.h +++ b/common/repositories/base/base_adventure_details_repository.h @@ -100,22 +100,22 @@ public: static AdventureDetails NewEntity() { - AdventureDetails entry{}; + AdventureDetails e{}; - entry.id = 0; - entry.adventure_id = 0; - entry.instance_id = -1; - entry.count = 0; - entry.assassinate_count = 0; - entry.status = 0; - entry.time_created = 0; - entry.time_zoned = 0; - entry.time_completed = 0; + e.id = 0; + e.adventure_id = 0; + e.instance_id = -1; + e.count = 0; + e.assassinate_count = 0; + e.status = 0; + e.time_created = 0; + e.time_zoned = 0; + e.time_completed = 0; - return entry; + return e; } - static AdventureDetails GetAdventureDetailsEntry( + static AdventureDetails GetAdventureDetails( const std::vector &adventure_detailss, int adventure_details_id ) @@ -144,19 +144,19 @@ public: auto row = results.begin(); if (results.RowCount() == 1) { - AdventureDetails entry{}; + AdventureDetails e{}; - entry.id = atoi(row[0]); - entry.adventure_id = atoi(row[1]); - entry.instance_id = atoi(row[2]); - entry.count = atoi(row[3]); - entry.assassinate_count = atoi(row[4]); - entry.status = atoi(row[5]); - entry.time_created = atoi(row[6]); - entry.time_zoned = atoi(row[7]); - entry.time_completed = atoi(row[8]); + e.id = atoi(row[0]); + e.adventure_id = atoi(row[1]); + e.instance_id = atoi(row[2]); + e.count = atoi(row[3]); + e.assassinate_count = atoi(row[4]); + e.status = atoi(row[5]); + e.time_created = atoi(row[6]); + e.time_zoned = atoi(row[7]); + e.time_completed = atoi(row[8]); - return entry; + return e; } return NewEntity(); @@ -181,29 +181,29 @@ public: static int UpdateOne( Database& db, - AdventureDetails adventure_details_entry + const AdventureDetails &e ) { - std::vector update_values; + std::vector v; auto columns = Columns(); - update_values.push_back(columns[1] + " = " + std::to_string(adventure_details_entry.adventure_id)); - update_values.push_back(columns[2] + " = " + std::to_string(adventure_details_entry.instance_id)); - update_values.push_back(columns[3] + " = " + std::to_string(adventure_details_entry.count)); - update_values.push_back(columns[4] + " = " + std::to_string(adventure_details_entry.assassinate_count)); - update_values.push_back(columns[5] + " = " + std::to_string(adventure_details_entry.status)); - update_values.push_back(columns[6] + " = " + std::to_string(adventure_details_entry.time_created)); - update_values.push_back(columns[7] + " = " + std::to_string(adventure_details_entry.time_zoned)); - update_values.push_back(columns[8] + " = " + std::to_string(adventure_details_entry.time_completed)); + v.push_back(columns[1] + " = " + std::to_string(e.adventure_id)); + v.push_back(columns[2] + " = " + std::to_string(e.instance_id)); + v.push_back(columns[3] + " = " + std::to_string(e.count)); + v.push_back(columns[4] + " = " + std::to_string(e.assassinate_count)); + v.push_back(columns[5] + " = " + std::to_string(e.status)); + v.push_back(columns[6] + " = " + std::to_string(e.time_created)); + v.push_back(columns[7] + " = " + std::to_string(e.time_zoned)); + v.push_back(columns[8] + " = " + std::to_string(e.time_completed)); auto results = db.QueryDatabase( fmt::format( "UPDATE {} SET {} WHERE {} = {}", TableName(), - Strings::Implode(", ", update_values), + Strings::Implode(", ", v), PrimaryKey(), - adventure_details_entry.id + e.id ) ); @@ -212,63 +212,63 @@ public: static AdventureDetails InsertOne( Database& db, - AdventureDetails adventure_details_entry + AdventureDetails e ) { - std::vector insert_values; + std::vector v; - insert_values.push_back(std::to_string(adventure_details_entry.id)); - insert_values.push_back(std::to_string(adventure_details_entry.adventure_id)); - insert_values.push_back(std::to_string(adventure_details_entry.instance_id)); - insert_values.push_back(std::to_string(adventure_details_entry.count)); - insert_values.push_back(std::to_string(adventure_details_entry.assassinate_count)); - insert_values.push_back(std::to_string(adventure_details_entry.status)); - insert_values.push_back(std::to_string(adventure_details_entry.time_created)); - insert_values.push_back(std::to_string(adventure_details_entry.time_zoned)); - insert_values.push_back(std::to_string(adventure_details_entry.time_completed)); + v.push_back(std::to_string(e.id)); + v.push_back(std::to_string(e.adventure_id)); + v.push_back(std::to_string(e.instance_id)); + v.push_back(std::to_string(e.count)); + v.push_back(std::to_string(e.assassinate_count)); + v.push_back(std::to_string(e.status)); + v.push_back(std::to_string(e.time_created)); + v.push_back(std::to_string(e.time_zoned)); + v.push_back(std::to_string(e.time_completed)); auto results = db.QueryDatabase( fmt::format( "{} VALUES ({})", BaseInsert(), - Strings::Implode(",", insert_values) + Strings::Implode(",", v) ) ); if (results.Success()) { - adventure_details_entry.id = results.LastInsertedID(); - return adventure_details_entry; + e.id = results.LastInsertedID(); + return e; } - adventure_details_entry = NewEntity(); + e = NewEntity(); - return adventure_details_entry; + return e; } static int InsertMany( Database& db, - std::vector adventure_details_entries + const std::vector &entries ) { std::vector insert_chunks; - for (auto &adventure_details_entry: adventure_details_entries) { - std::vector insert_values; + for (auto &e: entries) { + std::vector v; - insert_values.push_back(std::to_string(adventure_details_entry.id)); - insert_values.push_back(std::to_string(adventure_details_entry.adventure_id)); - insert_values.push_back(std::to_string(adventure_details_entry.instance_id)); - insert_values.push_back(std::to_string(adventure_details_entry.count)); - insert_values.push_back(std::to_string(adventure_details_entry.assassinate_count)); - insert_values.push_back(std::to_string(adventure_details_entry.status)); - insert_values.push_back(std::to_string(adventure_details_entry.time_created)); - insert_values.push_back(std::to_string(adventure_details_entry.time_zoned)); - insert_values.push_back(std::to_string(adventure_details_entry.time_completed)); + v.push_back(std::to_string(e.id)); + v.push_back(std::to_string(e.adventure_id)); + v.push_back(std::to_string(e.instance_id)); + v.push_back(std::to_string(e.count)); + v.push_back(std::to_string(e.assassinate_count)); + v.push_back(std::to_string(e.status)); + v.push_back(std::to_string(e.time_created)); + v.push_back(std::to_string(e.time_zoned)); + v.push_back(std::to_string(e.time_completed)); - insert_chunks.push_back("(" + Strings::Implode(",", insert_values) + ")"); + insert_chunks.push_back("(" + Strings::Implode(",", v) + ")"); } - std::vector insert_values; + std::vector v; auto results = db.QueryDatabase( fmt::format( @@ -295,25 +295,25 @@ public: all_entries.reserve(results.RowCount()); for (auto row = results.begin(); row != results.end(); ++row) { - AdventureDetails entry{}; + AdventureDetails e{}; - entry.id = atoi(row[0]); - entry.adventure_id = atoi(row[1]); - entry.instance_id = atoi(row[2]); - entry.count = atoi(row[3]); - entry.assassinate_count = atoi(row[4]); - entry.status = atoi(row[5]); - entry.time_created = atoi(row[6]); - entry.time_zoned = atoi(row[7]); - entry.time_completed = atoi(row[8]); + e.id = atoi(row[0]); + e.adventure_id = atoi(row[1]); + e.instance_id = atoi(row[2]); + e.count = atoi(row[3]); + e.assassinate_count = atoi(row[4]); + e.status = atoi(row[5]); + e.time_created = atoi(row[6]); + e.time_zoned = atoi(row[7]); + e.time_completed = atoi(row[8]); - all_entries.push_back(entry); + all_entries.push_back(e); } return all_entries; } - static std::vector GetWhere(Database& db, std::string where_filter) + static std::vector GetWhere(Database& db, const std::string &where_filter) { std::vector all_entries; @@ -328,25 +328,25 @@ public: all_entries.reserve(results.RowCount()); for (auto row = results.begin(); row != results.end(); ++row) { - AdventureDetails entry{}; + AdventureDetails e{}; - entry.id = atoi(row[0]); - entry.adventure_id = atoi(row[1]); - entry.instance_id = atoi(row[2]); - entry.count = atoi(row[3]); - entry.assassinate_count = atoi(row[4]); - entry.status = atoi(row[5]); - entry.time_created = atoi(row[6]); - entry.time_zoned = atoi(row[7]); - entry.time_completed = atoi(row[8]); + e.id = atoi(row[0]); + e.adventure_id = atoi(row[1]); + e.instance_id = atoi(row[2]); + e.count = atoi(row[3]); + e.assassinate_count = atoi(row[4]); + e.status = atoi(row[5]); + e.time_created = atoi(row[6]); + e.time_zoned = atoi(row[7]); + e.time_completed = atoi(row[8]); - all_entries.push_back(entry); + all_entries.push_back(e); } return all_entries; } - static int DeleteWhere(Database& db, std::string where_filter) + static int DeleteWhere(Database& db, const std::string &where_filter) { auto results = db.QueryDatabase( fmt::format( @@ -371,6 +371,32 @@ public: 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); + } + }; #endif //EQEMU_BASE_ADVENTURE_DETAILS_REPOSITORY_H diff --git a/common/repositories/base/base_adventure_members_repository.h b/common/repositories/base/base_adventure_members_repository.h index 8d940f1d0..c854583be 100644 --- a/common/repositories/base/base_adventure_members_repository.h +++ b/common/repositories/base/base_adventure_members_repository.h @@ -79,15 +79,15 @@ public: static AdventureMembers NewEntity() { - AdventureMembers entry{}; + AdventureMembers e{}; - entry.id = 0; - entry.charid = 0; + e.id = 0; + e.charid = 0; - return entry; + return e; } - static AdventureMembers GetAdventureMembersEntry( + static AdventureMembers GetAdventureMembers( const std::vector &adventure_memberss, int adventure_members_id ) @@ -116,12 +116,12 @@ public: auto row = results.begin(); if (results.RowCount() == 1) { - AdventureMembers entry{}; + AdventureMembers e{}; - entry.id = atoi(row[0]); - entry.charid = atoi(row[1]); + e.id = atoi(row[0]); + e.charid = atoi(row[1]); - return entry; + return e; } return NewEntity(); @@ -146,23 +146,23 @@ public: static int UpdateOne( Database& db, - AdventureMembers adventure_members_entry + const AdventureMembers &e ) { - std::vector update_values; + std::vector v; auto columns = Columns(); - update_values.push_back(columns[0] + " = " + std::to_string(adventure_members_entry.id)); - update_values.push_back(columns[1] + " = " + std::to_string(adventure_members_entry.charid)); + v.push_back(columns[0] + " = " + std::to_string(e.id)); + v.push_back(columns[1] + " = " + std::to_string(e.charid)); auto results = db.QueryDatabase( fmt::format( "UPDATE {} SET {} WHERE {} = {}", TableName(), - Strings::Implode(", ", update_values), + Strings::Implode(", ", v), PrimaryKey(), - adventure_members_entry.charid + e.charid ) ); @@ -171,49 +171,49 @@ public: static AdventureMembers InsertOne( Database& db, - AdventureMembers adventure_members_entry + AdventureMembers e ) { - std::vector insert_values; + std::vector v; - insert_values.push_back(std::to_string(adventure_members_entry.id)); - insert_values.push_back(std::to_string(adventure_members_entry.charid)); + v.push_back(std::to_string(e.id)); + v.push_back(std::to_string(e.charid)); auto results = db.QueryDatabase( fmt::format( "{} VALUES ({})", BaseInsert(), - Strings::Implode(",", insert_values) + Strings::Implode(",", v) ) ); if (results.Success()) { - adventure_members_entry.charid = results.LastInsertedID(); - return adventure_members_entry; + e.charid = results.LastInsertedID(); + return e; } - adventure_members_entry = NewEntity(); + e = NewEntity(); - return adventure_members_entry; + return e; } static int InsertMany( Database& db, - std::vector adventure_members_entries + const std::vector &entries ) { std::vector insert_chunks; - for (auto &adventure_members_entry: adventure_members_entries) { - std::vector insert_values; + for (auto &e: entries) { + std::vector v; - insert_values.push_back(std::to_string(adventure_members_entry.id)); - insert_values.push_back(std::to_string(adventure_members_entry.charid)); + v.push_back(std::to_string(e.id)); + v.push_back(std::to_string(e.charid)); - insert_chunks.push_back("(" + Strings::Implode(",", insert_values) + ")"); + insert_chunks.push_back("(" + Strings::Implode(",", v) + ")"); } - std::vector insert_values; + std::vector v; auto results = db.QueryDatabase( fmt::format( @@ -240,18 +240,18 @@ public: all_entries.reserve(results.RowCount()); for (auto row = results.begin(); row != results.end(); ++row) { - AdventureMembers entry{}; + AdventureMembers e{}; - entry.id = atoi(row[0]); - entry.charid = atoi(row[1]); + e.id = atoi(row[0]); + e.charid = atoi(row[1]); - all_entries.push_back(entry); + all_entries.push_back(e); } return all_entries; } - static std::vector GetWhere(Database& db, std::string where_filter) + static std::vector GetWhere(Database& db, const std::string &where_filter) { std::vector all_entries; @@ -266,18 +266,18 @@ public: all_entries.reserve(results.RowCount()); for (auto row = results.begin(); row != results.end(); ++row) { - AdventureMembers entry{}; + AdventureMembers e{}; - entry.id = atoi(row[0]); - entry.charid = atoi(row[1]); + e.id = atoi(row[0]); + e.charid = atoi(row[1]); - all_entries.push_back(entry); + all_entries.push_back(e); } return all_entries; } - static int DeleteWhere(Database& db, std::string where_filter) + static int DeleteWhere(Database& db, const std::string &where_filter) { auto results = db.QueryDatabase( fmt::format( @@ -302,6 +302,32 @@ public: 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); + } + }; #endif //EQEMU_BASE_ADVENTURE_MEMBERS_REPOSITORY_H diff --git a/common/repositories/base/base_adventure_stats_repository.h b/common/repositories/base/base_adventure_stats_repository.h index 0ed9cedb3..3a900a95c 100644 --- a/common/repositories/base/base_adventure_stats_repository.h +++ b/common/repositories/base/base_adventure_stats_repository.h @@ -106,24 +106,24 @@ public: static AdventureStats NewEntity() { - AdventureStats entry{}; + AdventureStats e{}; - entry.player_id = 0; - entry.guk_wins = 0; - entry.mir_wins = 0; - entry.mmc_wins = 0; - entry.ruj_wins = 0; - entry.tak_wins = 0; - entry.guk_losses = 0; - entry.mir_losses = 0; - entry.mmc_losses = 0; - entry.ruj_losses = 0; - entry.tak_losses = 0; + e.player_id = 0; + e.guk_wins = 0; + e.mir_wins = 0; + e.mmc_wins = 0; + e.ruj_wins = 0; + e.tak_wins = 0; + e.guk_losses = 0; + e.mir_losses = 0; + e.mmc_losses = 0; + e.ruj_losses = 0; + e.tak_losses = 0; - return entry; + return e; } - static AdventureStats GetAdventureStatsEntry( + static AdventureStats GetAdventureStats( const std::vector &adventure_statss, int adventure_stats_id ) @@ -152,21 +152,21 @@ public: auto row = results.begin(); if (results.RowCount() == 1) { - AdventureStats entry{}; + AdventureStats e{}; - entry.player_id = atoi(row[0]); - entry.guk_wins = atoi(row[1]); - entry.mir_wins = atoi(row[2]); - entry.mmc_wins = atoi(row[3]); - entry.ruj_wins = atoi(row[4]); - entry.tak_wins = atoi(row[5]); - entry.guk_losses = atoi(row[6]); - entry.mir_losses = atoi(row[7]); - entry.mmc_losses = atoi(row[8]); - entry.ruj_losses = atoi(row[9]); - entry.tak_losses = atoi(row[10]); + e.player_id = atoi(row[0]); + e.guk_wins = atoi(row[1]); + e.mir_wins = atoi(row[2]); + e.mmc_wins = atoi(row[3]); + e.ruj_wins = atoi(row[4]); + e.tak_wins = atoi(row[5]); + e.guk_losses = atoi(row[6]); + e.mir_losses = atoi(row[7]); + e.mmc_losses = atoi(row[8]); + e.ruj_losses = atoi(row[9]); + e.tak_losses = atoi(row[10]); - return entry; + return e; } return NewEntity(); @@ -191,32 +191,32 @@ public: static int UpdateOne( Database& db, - AdventureStats adventure_stats_entry + const AdventureStats &e ) { - std::vector update_values; + std::vector v; auto columns = Columns(); - update_values.push_back(columns[0] + " = " + std::to_string(adventure_stats_entry.player_id)); - update_values.push_back(columns[1] + " = " + std::to_string(adventure_stats_entry.guk_wins)); - update_values.push_back(columns[2] + " = " + std::to_string(adventure_stats_entry.mir_wins)); - update_values.push_back(columns[3] + " = " + std::to_string(adventure_stats_entry.mmc_wins)); - update_values.push_back(columns[4] + " = " + std::to_string(adventure_stats_entry.ruj_wins)); - update_values.push_back(columns[5] + " = " + std::to_string(adventure_stats_entry.tak_wins)); - update_values.push_back(columns[6] + " = " + std::to_string(adventure_stats_entry.guk_losses)); - update_values.push_back(columns[7] + " = " + std::to_string(adventure_stats_entry.mir_losses)); - update_values.push_back(columns[8] + " = " + std::to_string(adventure_stats_entry.mmc_losses)); - update_values.push_back(columns[9] + " = " + std::to_string(adventure_stats_entry.ruj_losses)); - update_values.push_back(columns[10] + " = " + std::to_string(adventure_stats_entry.tak_losses)); + v.push_back(columns[0] + " = " + std::to_string(e.player_id)); + v.push_back(columns[1] + " = " + std::to_string(e.guk_wins)); + v.push_back(columns[2] + " = " + std::to_string(e.mir_wins)); + v.push_back(columns[3] + " = " + std::to_string(e.mmc_wins)); + v.push_back(columns[4] + " = " + std::to_string(e.ruj_wins)); + v.push_back(columns[5] + " = " + std::to_string(e.tak_wins)); + v.push_back(columns[6] + " = " + std::to_string(e.guk_losses)); + v.push_back(columns[7] + " = " + std::to_string(e.mir_losses)); + v.push_back(columns[8] + " = " + std::to_string(e.mmc_losses)); + v.push_back(columns[9] + " = " + std::to_string(e.ruj_losses)); + v.push_back(columns[10] + " = " + std::to_string(e.tak_losses)); auto results = db.QueryDatabase( fmt::format( "UPDATE {} SET {} WHERE {} = {}", TableName(), - Strings::Implode(", ", update_values), + Strings::Implode(", ", v), PrimaryKey(), - adventure_stats_entry.player_id + e.player_id ) ); @@ -225,67 +225,67 @@ public: static AdventureStats InsertOne( Database& db, - AdventureStats adventure_stats_entry + AdventureStats e ) { - std::vector insert_values; + std::vector v; - insert_values.push_back(std::to_string(adventure_stats_entry.player_id)); - insert_values.push_back(std::to_string(adventure_stats_entry.guk_wins)); - insert_values.push_back(std::to_string(adventure_stats_entry.mir_wins)); - insert_values.push_back(std::to_string(adventure_stats_entry.mmc_wins)); - insert_values.push_back(std::to_string(adventure_stats_entry.ruj_wins)); - insert_values.push_back(std::to_string(adventure_stats_entry.tak_wins)); - insert_values.push_back(std::to_string(adventure_stats_entry.guk_losses)); - insert_values.push_back(std::to_string(adventure_stats_entry.mir_losses)); - insert_values.push_back(std::to_string(adventure_stats_entry.mmc_losses)); - insert_values.push_back(std::to_string(adventure_stats_entry.ruj_losses)); - insert_values.push_back(std::to_string(adventure_stats_entry.tak_losses)); + v.push_back(std::to_string(e.player_id)); + v.push_back(std::to_string(e.guk_wins)); + v.push_back(std::to_string(e.mir_wins)); + v.push_back(std::to_string(e.mmc_wins)); + v.push_back(std::to_string(e.ruj_wins)); + v.push_back(std::to_string(e.tak_wins)); + v.push_back(std::to_string(e.guk_losses)); + v.push_back(std::to_string(e.mir_losses)); + v.push_back(std::to_string(e.mmc_losses)); + v.push_back(std::to_string(e.ruj_losses)); + v.push_back(std::to_string(e.tak_losses)); auto results = db.QueryDatabase( fmt::format( "{} VALUES ({})", BaseInsert(), - Strings::Implode(",", insert_values) + Strings::Implode(",", v) ) ); if (results.Success()) { - adventure_stats_entry.player_id = results.LastInsertedID(); - return adventure_stats_entry; + e.player_id = results.LastInsertedID(); + return e; } - adventure_stats_entry = NewEntity(); + e = NewEntity(); - return adventure_stats_entry; + return e; } static int InsertMany( Database& db, - std::vector adventure_stats_entries + const std::vector &entries ) { std::vector insert_chunks; - for (auto &adventure_stats_entry: adventure_stats_entries) { - std::vector insert_values; + for (auto &e: entries) { + std::vector v; - insert_values.push_back(std::to_string(adventure_stats_entry.player_id)); - insert_values.push_back(std::to_string(adventure_stats_entry.guk_wins)); - insert_values.push_back(std::to_string(adventure_stats_entry.mir_wins)); - insert_values.push_back(std::to_string(adventure_stats_entry.mmc_wins)); - insert_values.push_back(std::to_string(adventure_stats_entry.ruj_wins)); - insert_values.push_back(std::to_string(adventure_stats_entry.tak_wins)); - insert_values.push_back(std::to_string(adventure_stats_entry.guk_losses)); - insert_values.push_back(std::to_string(adventure_stats_entry.mir_losses)); - insert_values.push_back(std::to_string(adventure_stats_entry.mmc_losses)); - insert_values.push_back(std::to_string(adventure_stats_entry.ruj_losses)); - insert_values.push_back(std::to_string(adventure_stats_entry.tak_losses)); + v.push_back(std::to_string(e.player_id)); + v.push_back(std::to_string(e.guk_wins)); + v.push_back(std::to_string(e.mir_wins)); + v.push_back(std::to_string(e.mmc_wins)); + v.push_back(std::to_string(e.ruj_wins)); + v.push_back(std::to_string(e.tak_wins)); + v.push_back(std::to_string(e.guk_losses)); + v.push_back(std::to_string(e.mir_losses)); + v.push_back(std::to_string(e.mmc_losses)); + v.push_back(std::to_string(e.ruj_losses)); + v.push_back(std::to_string(e.tak_losses)); - insert_chunks.push_back("(" + Strings::Implode(",", insert_values) + ")"); + insert_chunks.push_back("(" + Strings::Implode(",", v) + ")"); } - std::vector insert_values; + std::vector v; auto results = db.QueryDatabase( fmt::format( @@ -312,27 +312,27 @@ public: all_entries.reserve(results.RowCount()); for (auto row = results.begin(); row != results.end(); ++row) { - AdventureStats entry{}; + AdventureStats e{}; - entry.player_id = atoi(row[0]); - entry.guk_wins = atoi(row[1]); - entry.mir_wins = atoi(row[2]); - entry.mmc_wins = atoi(row[3]); - entry.ruj_wins = atoi(row[4]); - entry.tak_wins = atoi(row[5]); - entry.guk_losses = atoi(row[6]); - entry.mir_losses = atoi(row[7]); - entry.mmc_losses = atoi(row[8]); - entry.ruj_losses = atoi(row[9]); - entry.tak_losses = atoi(row[10]); + e.player_id = atoi(row[0]); + e.guk_wins = atoi(row[1]); + e.mir_wins = atoi(row[2]); + e.mmc_wins = atoi(row[3]); + e.ruj_wins = atoi(row[4]); + e.tak_wins = atoi(row[5]); + e.guk_losses = atoi(row[6]); + e.mir_losses = atoi(row[7]); + e.mmc_losses = atoi(row[8]); + e.ruj_losses = atoi(row[9]); + e.tak_losses = atoi(row[10]); - all_entries.push_back(entry); + all_entries.push_back(e); } return all_entries; } - static std::vector GetWhere(Database& db, std::string where_filter) + static std::vector GetWhere(Database& db, const std::string &where_filter) { std::vector all_entries; @@ -347,27 +347,27 @@ public: all_entries.reserve(results.RowCount()); for (auto row = results.begin(); row != results.end(); ++row) { - AdventureStats entry{}; + AdventureStats e{}; - entry.player_id = atoi(row[0]); - entry.guk_wins = atoi(row[1]); - entry.mir_wins = atoi(row[2]); - entry.mmc_wins = atoi(row[3]); - entry.ruj_wins = atoi(row[4]); - entry.tak_wins = atoi(row[5]); - entry.guk_losses = atoi(row[6]); - entry.mir_losses = atoi(row[7]); - entry.mmc_losses = atoi(row[8]); - entry.ruj_losses = atoi(row[9]); - entry.tak_losses = atoi(row[10]); + e.player_id = atoi(row[0]); + e.guk_wins = atoi(row[1]); + e.mir_wins = atoi(row[2]); + e.mmc_wins = atoi(row[3]); + e.ruj_wins = atoi(row[4]); + e.tak_wins = atoi(row[5]); + e.guk_losses = atoi(row[6]); + e.mir_losses = atoi(row[7]); + e.mmc_losses = atoi(row[8]); + e.ruj_losses = atoi(row[9]); + e.tak_losses = atoi(row[10]); - all_entries.push_back(entry); + all_entries.push_back(e); } return all_entries; } - static int DeleteWhere(Database& db, std::string where_filter) + static int DeleteWhere(Database& db, const std::string &where_filter) { auto results = db.QueryDatabase( fmt::format( @@ -392,6 +392,32 @@ public: 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); + } + }; #endif //EQEMU_BASE_ADVENTURE_STATS_REPOSITORY_H diff --git a/common/repositories/base/base_adventure_template_entry_flavor_repository.h b/common/repositories/base/base_adventure_template_entry_flavor_repository.h index 8c6c250ba..9dfdd24a1 100644 --- a/common/repositories/base/base_adventure_template_entry_flavor_repository.h +++ b/common/repositories/base/base_adventure_template_entry_flavor_repository.h @@ -79,15 +79,15 @@ public: static AdventureTemplateEntryFlavor NewEntity() { - AdventureTemplateEntryFlavor entry{}; + AdventureTemplateEntryFlavor e{}; - entry.id = 0; - entry.text = ""; + e.id = 0; + e.text = ""; - return entry; + return e; } - static AdventureTemplateEntryFlavor GetAdventureTemplateEntryFlavorEntry( + static AdventureTemplateEntryFlavor GetAdventureTemplateEntryFlavor( const std::vector &adventure_template_entry_flavors, int adventure_template_entry_flavor_id ) @@ -116,12 +116,12 @@ public: auto row = results.begin(); if (results.RowCount() == 1) { - AdventureTemplateEntryFlavor entry{}; + AdventureTemplateEntryFlavor e{}; - entry.id = atoi(row[0]); - entry.text = row[1] ? row[1] : ""; + e.id = atoi(row[0]); + e.text = row[1] ? row[1] : ""; - return entry; + return e; } return NewEntity(); @@ -146,23 +146,23 @@ public: static int UpdateOne( Database& db, - AdventureTemplateEntryFlavor adventure_template_entry_flavor_entry + const AdventureTemplateEntryFlavor &e ) { - std::vector update_values; + std::vector v; auto columns = Columns(); - update_values.push_back(columns[0] + " = " + std::to_string(adventure_template_entry_flavor_entry.id)); - update_values.push_back(columns[1] + " = '" + Strings::Escape(adventure_template_entry_flavor_entry.text) + "'"); + v.push_back(columns[0] + " = " + std::to_string(e.id)); + v.push_back(columns[1] + " = '" + Strings::Escape(e.text) + "'"); auto results = db.QueryDatabase( fmt::format( "UPDATE {} SET {} WHERE {} = {}", TableName(), - Strings::Implode(", ", update_values), + Strings::Implode(", ", v), PrimaryKey(), - adventure_template_entry_flavor_entry.id + e.id ) ); @@ -171,49 +171,49 @@ public: static AdventureTemplateEntryFlavor InsertOne( Database& db, - AdventureTemplateEntryFlavor adventure_template_entry_flavor_entry + AdventureTemplateEntryFlavor e ) { - std::vector insert_values; + std::vector v; - insert_values.push_back(std::to_string(adventure_template_entry_flavor_entry.id)); - insert_values.push_back("'" + Strings::Escape(adventure_template_entry_flavor_entry.text) + "'"); + v.push_back(std::to_string(e.id)); + v.push_back("'" + Strings::Escape(e.text) + "'"); auto results = db.QueryDatabase( fmt::format( "{} VALUES ({})", BaseInsert(), - Strings::Implode(",", insert_values) + Strings::Implode(",", v) ) ); if (results.Success()) { - adventure_template_entry_flavor_entry.id = results.LastInsertedID(); - return adventure_template_entry_flavor_entry; + e.id = results.LastInsertedID(); + return e; } - adventure_template_entry_flavor_entry = NewEntity(); + e = NewEntity(); - return adventure_template_entry_flavor_entry; + return e; } static int InsertMany( Database& db, - std::vector adventure_template_entry_flavor_entries + const std::vector &entries ) { std::vector insert_chunks; - for (auto &adventure_template_entry_flavor_entry: adventure_template_entry_flavor_entries) { - std::vector insert_values; + for (auto &e: entries) { + std::vector v; - insert_values.push_back(std::to_string(adventure_template_entry_flavor_entry.id)); - insert_values.push_back("'" + Strings::Escape(adventure_template_entry_flavor_entry.text) + "'"); + v.push_back(std::to_string(e.id)); + v.push_back("'" + Strings::Escape(e.text) + "'"); - insert_chunks.push_back("(" + Strings::Implode(",", insert_values) + ")"); + insert_chunks.push_back("(" + Strings::Implode(",", v) + ")"); } - std::vector insert_values; + std::vector v; auto results = db.QueryDatabase( fmt::format( @@ -240,18 +240,18 @@ public: all_entries.reserve(results.RowCount()); for (auto row = results.begin(); row != results.end(); ++row) { - AdventureTemplateEntryFlavor entry{}; + AdventureTemplateEntryFlavor e{}; - entry.id = atoi(row[0]); - entry.text = row[1] ? row[1] : ""; + e.id = atoi(row[0]); + e.text = row[1] ? row[1] : ""; - all_entries.push_back(entry); + all_entries.push_back(e); } return all_entries; } - static std::vector GetWhere(Database& db, std::string where_filter) + static std::vector GetWhere(Database& db, const std::string &where_filter) { std::vector all_entries; @@ -266,18 +266,18 @@ public: all_entries.reserve(results.RowCount()); for (auto row = results.begin(); row != results.end(); ++row) { - AdventureTemplateEntryFlavor entry{}; + AdventureTemplateEntryFlavor e{}; - entry.id = atoi(row[0]); - entry.text = row[1] ? row[1] : ""; + e.id = atoi(row[0]); + e.text = row[1] ? row[1] : ""; - all_entries.push_back(entry); + all_entries.push_back(e); } return all_entries; } - static int DeleteWhere(Database& db, std::string where_filter) + static int DeleteWhere(Database& db, const std::string &where_filter) { auto results = db.QueryDatabase( fmt::format( @@ -302,6 +302,32 @@ public: 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); + } + }; #endif //EQEMU_BASE_ADVENTURE_TEMPLATE_ENTRY_FLAVOR_REPOSITORY_H diff --git a/common/repositories/base/base_adventure_template_entry_repository.h b/common/repositories/base/base_adventure_template_entry_repository.h index 959fb6e31..33f4359eb 100644 --- a/common/repositories/base/base_adventure_template_entry_repository.h +++ b/common/repositories/base/base_adventure_template_entry_repository.h @@ -79,15 +79,15 @@ public: static AdventureTemplateEntry NewEntity() { - AdventureTemplateEntry entry{}; + AdventureTemplateEntry e{}; - entry.id = 0; - entry.template_id = 0; + e.id = 0; + e.template_id = 0; - return entry; + return e; } - static AdventureTemplateEntry GetAdventureTemplateEntryEntry( + static AdventureTemplateEntry GetAdventureTemplateEntry( const std::vector &adventure_template_entrys, int adventure_template_entry_id ) @@ -116,12 +116,12 @@ public: auto row = results.begin(); if (results.RowCount() == 1) { - AdventureTemplateEntry entry{}; + AdventureTemplateEntry e{}; - entry.id = atoi(row[0]); - entry.template_id = atoi(row[1]); + e.id = atoi(row[0]); + e.template_id = atoi(row[1]); - return entry; + return e; } return NewEntity(); @@ -146,23 +146,23 @@ public: static int UpdateOne( Database& db, - AdventureTemplateEntry adventure_template_entry_entry + const AdventureTemplateEntry &e ) { - std::vector update_values; + std::vector v; auto columns = Columns(); - update_values.push_back(columns[0] + " = " + std::to_string(adventure_template_entry_entry.id)); - update_values.push_back(columns[1] + " = " + std::to_string(adventure_template_entry_entry.template_id)); + v.push_back(columns[0] + " = " + std::to_string(e.id)); + v.push_back(columns[1] + " = " + std::to_string(e.template_id)); auto results = db.QueryDatabase( fmt::format( "UPDATE {} SET {} WHERE {} = {}", TableName(), - Strings::Implode(", ", update_values), + Strings::Implode(", ", v), PrimaryKey(), - adventure_template_entry_entry.id + e.id ) ); @@ -171,49 +171,49 @@ public: static AdventureTemplateEntry InsertOne( Database& db, - AdventureTemplateEntry adventure_template_entry_entry + AdventureTemplateEntry e ) { - std::vector insert_values; + std::vector v; - insert_values.push_back(std::to_string(adventure_template_entry_entry.id)); - insert_values.push_back(std::to_string(adventure_template_entry_entry.template_id)); + v.push_back(std::to_string(e.id)); + v.push_back(std::to_string(e.template_id)); auto results = db.QueryDatabase( fmt::format( "{} VALUES ({})", BaseInsert(), - Strings::Implode(",", insert_values) + Strings::Implode(",", v) ) ); if (results.Success()) { - adventure_template_entry_entry.id = results.LastInsertedID(); - return adventure_template_entry_entry; + e.id = results.LastInsertedID(); + return e; } - adventure_template_entry_entry = NewEntity(); + e = NewEntity(); - return adventure_template_entry_entry; + return e; } static int InsertMany( Database& db, - std::vector adventure_template_entry_entries + const std::vector &entries ) { std::vector insert_chunks; - for (auto &adventure_template_entry_entry: adventure_template_entry_entries) { - std::vector insert_values; + for (auto &e: entries) { + std::vector v; - insert_values.push_back(std::to_string(adventure_template_entry_entry.id)); - insert_values.push_back(std::to_string(adventure_template_entry_entry.template_id)); + v.push_back(std::to_string(e.id)); + v.push_back(std::to_string(e.template_id)); - insert_chunks.push_back("(" + Strings::Implode(",", insert_values) + ")"); + insert_chunks.push_back("(" + Strings::Implode(",", v) + ")"); } - std::vector insert_values; + std::vector v; auto results = db.QueryDatabase( fmt::format( @@ -240,18 +240,18 @@ public: all_entries.reserve(results.RowCount()); for (auto row = results.begin(); row != results.end(); ++row) { - AdventureTemplateEntry entry{}; + AdventureTemplateEntry e{}; - entry.id = atoi(row[0]); - entry.template_id = atoi(row[1]); + e.id = atoi(row[0]); + e.template_id = atoi(row[1]); - all_entries.push_back(entry); + all_entries.push_back(e); } return all_entries; } - static std::vector GetWhere(Database& db, std::string where_filter) + static std::vector GetWhere(Database& db, const std::string &where_filter) { std::vector all_entries; @@ -266,18 +266,18 @@ public: all_entries.reserve(results.RowCount()); for (auto row = results.begin(); row != results.end(); ++row) { - AdventureTemplateEntry entry{}; + AdventureTemplateEntry e{}; - entry.id = atoi(row[0]); - entry.template_id = atoi(row[1]); + e.id = atoi(row[0]); + e.template_id = atoi(row[1]); - all_entries.push_back(entry); + all_entries.push_back(e); } return all_entries; } - static int DeleteWhere(Database& db, std::string where_filter) + static int DeleteWhere(Database& db, const std::string &where_filter) { auto results = db.QueryDatabase( fmt::format( @@ -302,6 +302,32 @@ public: 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); + } + }; #endif //EQEMU_BASE_ADVENTURE_TEMPLATE_ENTRY_REPOSITORY_H diff --git a/common/repositories/base/base_adventure_template_repository.h b/common/repositories/base/base_adventure_template_repository.h index 07c988a5d..38096f4b4 100644 --- a/common/repositories/base/base_adventure_template_repository.h +++ b/common/repositories/base/base_adventure_template_repository.h @@ -172,46 +172,46 @@ public: static AdventureTemplate NewEntity() { - AdventureTemplate entry{}; + AdventureTemplate e{}; - entry.id = 0; - entry.zone = ""; - entry.zone_version = 0; - entry.is_hard = 0; - entry.is_raid = 0; - entry.min_level = 1; - entry.max_level = 65; - entry.type = 0; - entry.type_data = 0; - entry.type_count = 0; - entry.assa_x = 0; - entry.assa_y = 0; - entry.assa_z = 0; - entry.assa_h = 0; - entry.text = ""; - entry.duration = 7200; - entry.zone_in_time = 1800; - entry.win_points = 0; - entry.lose_points = 0; - entry.theme = 1; - entry.zone_in_zone_id = 0; - entry.zone_in_x = 0; - entry.zone_in_y = 0; - entry.zone_in_object_id = 0; - entry.dest_x = 0; - entry.dest_y = 0; - entry.dest_z = 0; - entry.dest_h = 0; - entry.graveyard_zone_id = 0; - entry.graveyard_x = 0; - entry.graveyard_y = 0; - entry.graveyard_z = 0; - entry.graveyard_radius = 0; + e.id = 0; + e.zone = ""; + e.zone_version = 0; + e.is_hard = 0; + e.is_raid = 0; + e.min_level = 1; + e.max_level = 65; + e.type = 0; + e.type_data = 0; + e.type_count = 0; + e.assa_x = 0; + e.assa_y = 0; + e.assa_z = 0; + e.assa_h = 0; + e.text = ""; + e.duration = 7200; + e.zone_in_time = 1800; + e.win_points = 0; + e.lose_points = 0; + e.theme = 1; + e.zone_in_zone_id = 0; + e.zone_in_x = 0; + e.zone_in_y = 0; + e.zone_in_object_id = 0; + e.dest_x = 0; + e.dest_y = 0; + e.dest_z = 0; + e.dest_h = 0; + e.graveyard_zone_id = 0; + e.graveyard_x = 0; + e.graveyard_y = 0; + e.graveyard_z = 0; + e.graveyard_radius = 0; - return entry; + return e; } - static AdventureTemplate GetAdventureTemplateEntry( + static AdventureTemplate GetAdventureTemplate( const std::vector &adventure_templates, int adventure_template_id ) @@ -240,43 +240,43 @@ public: auto row = results.begin(); if (results.RowCount() == 1) { - AdventureTemplate entry{}; + AdventureTemplate e{}; - entry.id = atoi(row[0]); - entry.zone = row[1] ? row[1] : ""; - entry.zone_version = atoi(row[2]); - entry.is_hard = atoi(row[3]); - entry.is_raid = atoi(row[4]); - entry.min_level = atoi(row[5]); - entry.max_level = atoi(row[6]); - entry.type = atoi(row[7]); - entry.type_data = atoi(row[8]); - entry.type_count = atoi(row[9]); - entry.assa_x = static_cast(atof(row[10])); - entry.assa_y = static_cast(atof(row[11])); - entry.assa_z = static_cast(atof(row[12])); - entry.assa_h = static_cast(atof(row[13])); - entry.text = row[14] ? row[14] : ""; - entry.duration = atoi(row[15]); - entry.zone_in_time = atoi(row[16]); - entry.win_points = atoi(row[17]); - entry.lose_points = atoi(row[18]); - entry.theme = atoi(row[19]); - entry.zone_in_zone_id = atoi(row[20]); - entry.zone_in_x = static_cast(atof(row[21])); - entry.zone_in_y = static_cast(atof(row[22])); - entry.zone_in_object_id = atoi(row[23]); - entry.dest_x = static_cast(atof(row[24])); - entry.dest_y = static_cast(atof(row[25])); - entry.dest_z = static_cast(atof(row[26])); - entry.dest_h = static_cast(atof(row[27])); - entry.graveyard_zone_id = atoi(row[28]); - entry.graveyard_x = static_cast(atof(row[29])); - entry.graveyard_y = static_cast(atof(row[30])); - entry.graveyard_z = static_cast(atof(row[31])); - entry.graveyard_radius = static_cast(atof(row[32])); + e.id = atoi(row[0]); + e.zone = row[1] ? row[1] : ""; + e.zone_version = atoi(row[2]); + e.is_hard = atoi(row[3]); + e.is_raid = atoi(row[4]); + e.min_level = atoi(row[5]); + e.max_level = atoi(row[6]); + e.type = atoi(row[7]); + e.type_data = atoi(row[8]); + e.type_count = atoi(row[9]); + e.assa_x = static_cast(atof(row[10])); + e.assa_y = static_cast(atof(row[11])); + e.assa_z = static_cast(atof(row[12])); + e.assa_h = static_cast(atof(row[13])); + e.text = row[14] ? row[14] : ""; + e.duration = atoi(row[15]); + e.zone_in_time = atoi(row[16]); + e.win_points = atoi(row[17]); + e.lose_points = atoi(row[18]); + e.theme = atoi(row[19]); + e.zone_in_zone_id = atoi(row[20]); + e.zone_in_x = static_cast(atof(row[21])); + e.zone_in_y = static_cast(atof(row[22])); + e.zone_in_object_id = atoi(row[23]); + e.dest_x = static_cast(atof(row[24])); + e.dest_y = static_cast(atof(row[25])); + e.dest_z = static_cast(atof(row[26])); + e.dest_h = static_cast(atof(row[27])); + e.graveyard_zone_id = atoi(row[28]); + e.graveyard_x = static_cast(atof(row[29])); + e.graveyard_y = static_cast(atof(row[30])); + e.graveyard_z = static_cast(atof(row[31])); + e.graveyard_radius = static_cast(atof(row[32])); - return entry; + return e; } return NewEntity(); @@ -301,54 +301,54 @@ public: static int UpdateOne( Database& db, - AdventureTemplate adventure_template_entry + const AdventureTemplate &e ) { - std::vector update_values; + std::vector v; auto columns = Columns(); - update_values.push_back(columns[0] + " = " + std::to_string(adventure_template_entry.id)); - update_values.push_back(columns[1] + " = '" + Strings::Escape(adventure_template_entry.zone) + "'"); - update_values.push_back(columns[2] + " = " + std::to_string(adventure_template_entry.zone_version)); - update_values.push_back(columns[3] + " = " + std::to_string(adventure_template_entry.is_hard)); - update_values.push_back(columns[4] + " = " + std::to_string(adventure_template_entry.is_raid)); - update_values.push_back(columns[5] + " = " + std::to_string(adventure_template_entry.min_level)); - update_values.push_back(columns[6] + " = " + std::to_string(adventure_template_entry.max_level)); - update_values.push_back(columns[7] + " = " + std::to_string(adventure_template_entry.type)); - update_values.push_back(columns[8] + " = " + std::to_string(adventure_template_entry.type_data)); - update_values.push_back(columns[9] + " = " + std::to_string(adventure_template_entry.type_count)); - update_values.push_back(columns[10] + " = " + std::to_string(adventure_template_entry.assa_x)); - update_values.push_back(columns[11] + " = " + std::to_string(adventure_template_entry.assa_y)); - update_values.push_back(columns[12] + " = " + std::to_string(adventure_template_entry.assa_z)); - update_values.push_back(columns[13] + " = " + std::to_string(adventure_template_entry.assa_h)); - update_values.push_back(columns[14] + " = '" + Strings::Escape(adventure_template_entry.text) + "'"); - update_values.push_back(columns[15] + " = " + std::to_string(adventure_template_entry.duration)); - update_values.push_back(columns[16] + " = " + std::to_string(adventure_template_entry.zone_in_time)); - update_values.push_back(columns[17] + " = " + std::to_string(adventure_template_entry.win_points)); - update_values.push_back(columns[18] + " = " + std::to_string(adventure_template_entry.lose_points)); - update_values.push_back(columns[19] + " = " + std::to_string(adventure_template_entry.theme)); - update_values.push_back(columns[20] + " = " + std::to_string(adventure_template_entry.zone_in_zone_id)); - update_values.push_back(columns[21] + " = " + std::to_string(adventure_template_entry.zone_in_x)); - update_values.push_back(columns[22] + " = " + std::to_string(adventure_template_entry.zone_in_y)); - update_values.push_back(columns[23] + " = " + std::to_string(adventure_template_entry.zone_in_object_id)); - update_values.push_back(columns[24] + " = " + std::to_string(adventure_template_entry.dest_x)); - update_values.push_back(columns[25] + " = " + std::to_string(adventure_template_entry.dest_y)); - update_values.push_back(columns[26] + " = " + std::to_string(adventure_template_entry.dest_z)); - update_values.push_back(columns[27] + " = " + std::to_string(adventure_template_entry.dest_h)); - update_values.push_back(columns[28] + " = " + std::to_string(adventure_template_entry.graveyard_zone_id)); - update_values.push_back(columns[29] + " = " + std::to_string(adventure_template_entry.graveyard_x)); - update_values.push_back(columns[30] + " = " + std::to_string(adventure_template_entry.graveyard_y)); - update_values.push_back(columns[31] + " = " + std::to_string(adventure_template_entry.graveyard_z)); - update_values.push_back(columns[32] + " = " + std::to_string(adventure_template_entry.graveyard_radius)); + v.push_back(columns[0] + " = " + std::to_string(e.id)); + v.push_back(columns[1] + " = '" + Strings::Escape(e.zone) + "'"); + v.push_back(columns[2] + " = " + std::to_string(e.zone_version)); + v.push_back(columns[3] + " = " + std::to_string(e.is_hard)); + v.push_back(columns[4] + " = " + std::to_string(e.is_raid)); + v.push_back(columns[5] + " = " + std::to_string(e.min_level)); + v.push_back(columns[6] + " = " + std::to_string(e.max_level)); + v.push_back(columns[7] + " = " + std::to_string(e.type)); + v.push_back(columns[8] + " = " + std::to_string(e.type_data)); + v.push_back(columns[9] + " = " + std::to_string(e.type_count)); + v.push_back(columns[10] + " = " + std::to_string(e.assa_x)); + v.push_back(columns[11] + " = " + std::to_string(e.assa_y)); + v.push_back(columns[12] + " = " + std::to_string(e.assa_z)); + v.push_back(columns[13] + " = " + std::to_string(e.assa_h)); + v.push_back(columns[14] + " = '" + Strings::Escape(e.text) + "'"); + v.push_back(columns[15] + " = " + std::to_string(e.duration)); + v.push_back(columns[16] + " = " + std::to_string(e.zone_in_time)); + v.push_back(columns[17] + " = " + std::to_string(e.win_points)); + v.push_back(columns[18] + " = " + std::to_string(e.lose_points)); + v.push_back(columns[19] + " = " + std::to_string(e.theme)); + v.push_back(columns[20] + " = " + std::to_string(e.zone_in_zone_id)); + v.push_back(columns[21] + " = " + std::to_string(e.zone_in_x)); + v.push_back(columns[22] + " = " + std::to_string(e.zone_in_y)); + v.push_back(columns[23] + " = " + std::to_string(e.zone_in_object_id)); + v.push_back(columns[24] + " = " + std::to_string(e.dest_x)); + v.push_back(columns[25] + " = " + std::to_string(e.dest_y)); + v.push_back(columns[26] + " = " + std::to_string(e.dest_z)); + v.push_back(columns[27] + " = " + std::to_string(e.dest_h)); + v.push_back(columns[28] + " = " + std::to_string(e.graveyard_zone_id)); + v.push_back(columns[29] + " = " + std::to_string(e.graveyard_x)); + v.push_back(columns[30] + " = " + std::to_string(e.graveyard_y)); + v.push_back(columns[31] + " = " + std::to_string(e.graveyard_z)); + v.push_back(columns[32] + " = " + std::to_string(e.graveyard_radius)); auto results = db.QueryDatabase( fmt::format( "UPDATE {} SET {} WHERE {} = {}", TableName(), - Strings::Implode(", ", update_values), + Strings::Implode(", ", v), PrimaryKey(), - adventure_template_entry.id + e.id ) ); @@ -357,111 +357,111 @@ public: static AdventureTemplate InsertOne( Database& db, - AdventureTemplate adventure_template_entry + AdventureTemplate e ) { - std::vector insert_values; + std::vector v; - insert_values.push_back(std::to_string(adventure_template_entry.id)); - insert_values.push_back("'" + Strings::Escape(adventure_template_entry.zone) + "'"); - insert_values.push_back(std::to_string(adventure_template_entry.zone_version)); - insert_values.push_back(std::to_string(adventure_template_entry.is_hard)); - insert_values.push_back(std::to_string(adventure_template_entry.is_raid)); - insert_values.push_back(std::to_string(adventure_template_entry.min_level)); - insert_values.push_back(std::to_string(adventure_template_entry.max_level)); - insert_values.push_back(std::to_string(adventure_template_entry.type)); - insert_values.push_back(std::to_string(adventure_template_entry.type_data)); - insert_values.push_back(std::to_string(adventure_template_entry.type_count)); - insert_values.push_back(std::to_string(adventure_template_entry.assa_x)); - insert_values.push_back(std::to_string(adventure_template_entry.assa_y)); - insert_values.push_back(std::to_string(adventure_template_entry.assa_z)); - insert_values.push_back(std::to_string(adventure_template_entry.assa_h)); - insert_values.push_back("'" + Strings::Escape(adventure_template_entry.text) + "'"); - insert_values.push_back(std::to_string(adventure_template_entry.duration)); - insert_values.push_back(std::to_string(adventure_template_entry.zone_in_time)); - insert_values.push_back(std::to_string(adventure_template_entry.win_points)); - insert_values.push_back(std::to_string(adventure_template_entry.lose_points)); - insert_values.push_back(std::to_string(adventure_template_entry.theme)); - insert_values.push_back(std::to_string(adventure_template_entry.zone_in_zone_id)); - insert_values.push_back(std::to_string(adventure_template_entry.zone_in_x)); - insert_values.push_back(std::to_string(adventure_template_entry.zone_in_y)); - insert_values.push_back(std::to_string(adventure_template_entry.zone_in_object_id)); - insert_values.push_back(std::to_string(adventure_template_entry.dest_x)); - insert_values.push_back(std::to_string(adventure_template_entry.dest_y)); - insert_values.push_back(std::to_string(adventure_template_entry.dest_z)); - insert_values.push_back(std::to_string(adventure_template_entry.dest_h)); - insert_values.push_back(std::to_string(adventure_template_entry.graveyard_zone_id)); - insert_values.push_back(std::to_string(adventure_template_entry.graveyard_x)); - insert_values.push_back(std::to_string(adventure_template_entry.graveyard_y)); - insert_values.push_back(std::to_string(adventure_template_entry.graveyard_z)); - insert_values.push_back(std::to_string(adventure_template_entry.graveyard_radius)); + v.push_back(std::to_string(e.id)); + v.push_back("'" + Strings::Escape(e.zone) + "'"); + v.push_back(std::to_string(e.zone_version)); + v.push_back(std::to_string(e.is_hard)); + v.push_back(std::to_string(e.is_raid)); + v.push_back(std::to_string(e.min_level)); + v.push_back(std::to_string(e.max_level)); + v.push_back(std::to_string(e.type)); + v.push_back(std::to_string(e.type_data)); + v.push_back(std::to_string(e.type_count)); + v.push_back(std::to_string(e.assa_x)); + v.push_back(std::to_string(e.assa_y)); + v.push_back(std::to_string(e.assa_z)); + v.push_back(std::to_string(e.assa_h)); + v.push_back("'" + Strings::Escape(e.text) + "'"); + v.push_back(std::to_string(e.duration)); + v.push_back(std::to_string(e.zone_in_time)); + v.push_back(std::to_string(e.win_points)); + v.push_back(std::to_string(e.lose_points)); + v.push_back(std::to_string(e.theme)); + v.push_back(std::to_string(e.zone_in_zone_id)); + v.push_back(std::to_string(e.zone_in_x)); + v.push_back(std::to_string(e.zone_in_y)); + v.push_back(std::to_string(e.zone_in_object_id)); + v.push_back(std::to_string(e.dest_x)); + v.push_back(std::to_string(e.dest_y)); + v.push_back(std::to_string(e.dest_z)); + v.push_back(std::to_string(e.dest_h)); + v.push_back(std::to_string(e.graveyard_zone_id)); + v.push_back(std::to_string(e.graveyard_x)); + v.push_back(std::to_string(e.graveyard_y)); + v.push_back(std::to_string(e.graveyard_z)); + v.push_back(std::to_string(e.graveyard_radius)); auto results = db.QueryDatabase( fmt::format( "{} VALUES ({})", BaseInsert(), - Strings::Implode(",", insert_values) + Strings::Implode(",", v) ) ); if (results.Success()) { - adventure_template_entry.id = results.LastInsertedID(); - return adventure_template_entry; + e.id = results.LastInsertedID(); + return e; } - adventure_template_entry = NewEntity(); + e = NewEntity(); - return adventure_template_entry; + return e; } static int InsertMany( Database& db, - std::vector adventure_template_entries + const std::vector &entries ) { std::vector insert_chunks; - for (auto &adventure_template_entry: adventure_template_entries) { - std::vector insert_values; + for (auto &e: entries) { + std::vector v; - insert_values.push_back(std::to_string(adventure_template_entry.id)); - insert_values.push_back("'" + Strings::Escape(adventure_template_entry.zone) + "'"); - insert_values.push_back(std::to_string(adventure_template_entry.zone_version)); - insert_values.push_back(std::to_string(adventure_template_entry.is_hard)); - insert_values.push_back(std::to_string(adventure_template_entry.is_raid)); - insert_values.push_back(std::to_string(adventure_template_entry.min_level)); - insert_values.push_back(std::to_string(adventure_template_entry.max_level)); - insert_values.push_back(std::to_string(adventure_template_entry.type)); - insert_values.push_back(std::to_string(adventure_template_entry.type_data)); - insert_values.push_back(std::to_string(adventure_template_entry.type_count)); - insert_values.push_back(std::to_string(adventure_template_entry.assa_x)); - insert_values.push_back(std::to_string(adventure_template_entry.assa_y)); - insert_values.push_back(std::to_string(adventure_template_entry.assa_z)); - insert_values.push_back(std::to_string(adventure_template_entry.assa_h)); - insert_values.push_back("'" + Strings::Escape(adventure_template_entry.text) + "'"); - insert_values.push_back(std::to_string(adventure_template_entry.duration)); - insert_values.push_back(std::to_string(adventure_template_entry.zone_in_time)); - insert_values.push_back(std::to_string(adventure_template_entry.win_points)); - insert_values.push_back(std::to_string(adventure_template_entry.lose_points)); - insert_values.push_back(std::to_string(adventure_template_entry.theme)); - insert_values.push_back(std::to_string(adventure_template_entry.zone_in_zone_id)); - insert_values.push_back(std::to_string(adventure_template_entry.zone_in_x)); - insert_values.push_back(std::to_string(adventure_template_entry.zone_in_y)); - insert_values.push_back(std::to_string(adventure_template_entry.zone_in_object_id)); - insert_values.push_back(std::to_string(adventure_template_entry.dest_x)); - insert_values.push_back(std::to_string(adventure_template_entry.dest_y)); - insert_values.push_back(std::to_string(adventure_template_entry.dest_z)); - insert_values.push_back(std::to_string(adventure_template_entry.dest_h)); - insert_values.push_back(std::to_string(adventure_template_entry.graveyard_zone_id)); - insert_values.push_back(std::to_string(adventure_template_entry.graveyard_x)); - insert_values.push_back(std::to_string(adventure_template_entry.graveyard_y)); - insert_values.push_back(std::to_string(adventure_template_entry.graveyard_z)); - insert_values.push_back(std::to_string(adventure_template_entry.graveyard_radius)); + v.push_back(std::to_string(e.id)); + v.push_back("'" + Strings::Escape(e.zone) + "'"); + v.push_back(std::to_string(e.zone_version)); + v.push_back(std::to_string(e.is_hard)); + v.push_back(std::to_string(e.is_raid)); + v.push_back(std::to_string(e.min_level)); + v.push_back(std::to_string(e.max_level)); + v.push_back(std::to_string(e.type)); + v.push_back(std::to_string(e.type_data)); + v.push_back(std::to_string(e.type_count)); + v.push_back(std::to_string(e.assa_x)); + v.push_back(std::to_string(e.assa_y)); + v.push_back(std::to_string(e.assa_z)); + v.push_back(std::to_string(e.assa_h)); + v.push_back("'" + Strings::Escape(e.text) + "'"); + v.push_back(std::to_string(e.duration)); + v.push_back(std::to_string(e.zone_in_time)); + v.push_back(std::to_string(e.win_points)); + v.push_back(std::to_string(e.lose_points)); + v.push_back(std::to_string(e.theme)); + v.push_back(std::to_string(e.zone_in_zone_id)); + v.push_back(std::to_string(e.zone_in_x)); + v.push_back(std::to_string(e.zone_in_y)); + v.push_back(std::to_string(e.zone_in_object_id)); + v.push_back(std::to_string(e.dest_x)); + v.push_back(std::to_string(e.dest_y)); + v.push_back(std::to_string(e.dest_z)); + v.push_back(std::to_string(e.dest_h)); + v.push_back(std::to_string(e.graveyard_zone_id)); + v.push_back(std::to_string(e.graveyard_x)); + v.push_back(std::to_string(e.graveyard_y)); + v.push_back(std::to_string(e.graveyard_z)); + v.push_back(std::to_string(e.graveyard_radius)); - insert_chunks.push_back("(" + Strings::Implode(",", insert_values) + ")"); + insert_chunks.push_back("(" + Strings::Implode(",", v) + ")"); } - std::vector insert_values; + std::vector v; auto results = db.QueryDatabase( fmt::format( @@ -488,49 +488,49 @@ public: all_entries.reserve(results.RowCount()); for (auto row = results.begin(); row != results.end(); ++row) { - AdventureTemplate entry{}; + AdventureTemplate e{}; - entry.id = atoi(row[0]); - entry.zone = row[1] ? row[1] : ""; - entry.zone_version = atoi(row[2]); - entry.is_hard = atoi(row[3]); - entry.is_raid = atoi(row[4]); - entry.min_level = atoi(row[5]); - entry.max_level = atoi(row[6]); - entry.type = atoi(row[7]); - entry.type_data = atoi(row[8]); - entry.type_count = atoi(row[9]); - entry.assa_x = static_cast(atof(row[10])); - entry.assa_y = static_cast(atof(row[11])); - entry.assa_z = static_cast(atof(row[12])); - entry.assa_h = static_cast(atof(row[13])); - entry.text = row[14] ? row[14] : ""; - entry.duration = atoi(row[15]); - entry.zone_in_time = atoi(row[16]); - entry.win_points = atoi(row[17]); - entry.lose_points = atoi(row[18]); - entry.theme = atoi(row[19]); - entry.zone_in_zone_id = atoi(row[20]); - entry.zone_in_x = static_cast(atof(row[21])); - entry.zone_in_y = static_cast(atof(row[22])); - entry.zone_in_object_id = atoi(row[23]); - entry.dest_x = static_cast(atof(row[24])); - entry.dest_y = static_cast(atof(row[25])); - entry.dest_z = static_cast(atof(row[26])); - entry.dest_h = static_cast(atof(row[27])); - entry.graveyard_zone_id = atoi(row[28]); - entry.graveyard_x = static_cast(atof(row[29])); - entry.graveyard_y = static_cast(atof(row[30])); - entry.graveyard_z = static_cast(atof(row[31])); - entry.graveyard_radius = static_cast(atof(row[32])); + e.id = atoi(row[0]); + e.zone = row[1] ? row[1] : ""; + e.zone_version = atoi(row[2]); + e.is_hard = atoi(row[3]); + e.is_raid = atoi(row[4]); + e.min_level = atoi(row[5]); + e.max_level = atoi(row[6]); + e.type = atoi(row[7]); + e.type_data = atoi(row[8]); + e.type_count = atoi(row[9]); + e.assa_x = static_cast(atof(row[10])); + e.assa_y = static_cast(atof(row[11])); + e.assa_z = static_cast(atof(row[12])); + e.assa_h = static_cast(atof(row[13])); + e.text = row[14] ? row[14] : ""; + e.duration = atoi(row[15]); + e.zone_in_time = atoi(row[16]); + e.win_points = atoi(row[17]); + e.lose_points = atoi(row[18]); + e.theme = atoi(row[19]); + e.zone_in_zone_id = atoi(row[20]); + e.zone_in_x = static_cast(atof(row[21])); + e.zone_in_y = static_cast(atof(row[22])); + e.zone_in_object_id = atoi(row[23]); + e.dest_x = static_cast(atof(row[24])); + e.dest_y = static_cast(atof(row[25])); + e.dest_z = static_cast(atof(row[26])); + e.dest_h = static_cast(atof(row[27])); + e.graveyard_zone_id = atoi(row[28]); + e.graveyard_x = static_cast(atof(row[29])); + e.graveyard_y = static_cast(atof(row[30])); + e.graveyard_z = static_cast(atof(row[31])); + e.graveyard_radius = static_cast(atof(row[32])); - all_entries.push_back(entry); + all_entries.push_back(e); } return all_entries; } - static std::vector GetWhere(Database& db, std::string where_filter) + static std::vector GetWhere(Database& db, const std::string &where_filter) { std::vector all_entries; @@ -545,49 +545,49 @@ public: all_entries.reserve(results.RowCount()); for (auto row = results.begin(); row != results.end(); ++row) { - AdventureTemplate entry{}; + AdventureTemplate e{}; - entry.id = atoi(row[0]); - entry.zone = row[1] ? row[1] : ""; - entry.zone_version = atoi(row[2]); - entry.is_hard = atoi(row[3]); - entry.is_raid = atoi(row[4]); - entry.min_level = atoi(row[5]); - entry.max_level = atoi(row[6]); - entry.type = atoi(row[7]); - entry.type_data = atoi(row[8]); - entry.type_count = atoi(row[9]); - entry.assa_x = static_cast(atof(row[10])); - entry.assa_y = static_cast(atof(row[11])); - entry.assa_z = static_cast(atof(row[12])); - entry.assa_h = static_cast(atof(row[13])); - entry.text = row[14] ? row[14] : ""; - entry.duration = atoi(row[15]); - entry.zone_in_time = atoi(row[16]); - entry.win_points = atoi(row[17]); - entry.lose_points = atoi(row[18]); - entry.theme = atoi(row[19]); - entry.zone_in_zone_id = atoi(row[20]); - entry.zone_in_x = static_cast(atof(row[21])); - entry.zone_in_y = static_cast(atof(row[22])); - entry.zone_in_object_id = atoi(row[23]); - entry.dest_x = static_cast(atof(row[24])); - entry.dest_y = static_cast(atof(row[25])); - entry.dest_z = static_cast(atof(row[26])); - entry.dest_h = static_cast(atof(row[27])); - entry.graveyard_zone_id = atoi(row[28]); - entry.graveyard_x = static_cast(atof(row[29])); - entry.graveyard_y = static_cast(atof(row[30])); - entry.graveyard_z = static_cast(atof(row[31])); - entry.graveyard_radius = static_cast(atof(row[32])); + e.id = atoi(row[0]); + e.zone = row[1] ? row[1] : ""; + e.zone_version = atoi(row[2]); + e.is_hard = atoi(row[3]); + e.is_raid = atoi(row[4]); + e.min_level = atoi(row[5]); + e.max_level = atoi(row[6]); + e.type = atoi(row[7]); + e.type_data = atoi(row[8]); + e.type_count = atoi(row[9]); + e.assa_x = static_cast(atof(row[10])); + e.assa_y = static_cast(atof(row[11])); + e.assa_z = static_cast(atof(row[12])); + e.assa_h = static_cast(atof(row[13])); + e.text = row[14] ? row[14] : ""; + e.duration = atoi(row[15]); + e.zone_in_time = atoi(row[16]); + e.win_points = atoi(row[17]); + e.lose_points = atoi(row[18]); + e.theme = atoi(row[19]); + e.zone_in_zone_id = atoi(row[20]); + e.zone_in_x = static_cast(atof(row[21])); + e.zone_in_y = static_cast(atof(row[22])); + e.zone_in_object_id = atoi(row[23]); + e.dest_x = static_cast(atof(row[24])); + e.dest_y = static_cast(atof(row[25])); + e.dest_z = static_cast(atof(row[26])); + e.dest_h = static_cast(atof(row[27])); + e.graveyard_zone_id = atoi(row[28]); + e.graveyard_x = static_cast(atof(row[29])); + e.graveyard_y = static_cast(atof(row[30])); + e.graveyard_z = static_cast(atof(row[31])); + e.graveyard_radius = static_cast(atof(row[32])); - all_entries.push_back(entry); + all_entries.push_back(e); } return all_entries; } - static int DeleteWhere(Database& db, std::string where_filter) + static int DeleteWhere(Database& db, const std::string &where_filter) { auto results = db.QueryDatabase( fmt::format( @@ -612,6 +612,32 @@ public: 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); + } + }; #endif //EQEMU_BASE_ADVENTURE_TEMPLATE_REPOSITORY_H diff --git a/common/repositories/base/base_alternate_currency_repository.h b/common/repositories/base/base_alternate_currency_repository.h index 3351b634a..2cedf8473 100644 --- a/common/repositories/base/base_alternate_currency_repository.h +++ b/common/repositories/base/base_alternate_currency_repository.h @@ -79,15 +79,15 @@ public: static AlternateCurrency NewEntity() { - AlternateCurrency entry{}; + AlternateCurrency e{}; - entry.id = 0; - entry.item_id = 0; + e.id = 0; + e.item_id = 0; - return entry; + return e; } - static AlternateCurrency GetAlternateCurrencyEntry( + static AlternateCurrency GetAlternateCurrency( const std::vector &alternate_currencys, int alternate_currency_id ) @@ -116,12 +116,12 @@ public: auto row = results.begin(); if (results.RowCount() == 1) { - AlternateCurrency entry{}; + AlternateCurrency e{}; - entry.id = atoi(row[0]); - entry.item_id = atoi(row[1]); + e.id = atoi(row[0]); + e.item_id = atoi(row[1]); - return entry; + return e; } return NewEntity(); @@ -146,23 +146,23 @@ public: static int UpdateOne( Database& db, - AlternateCurrency alternate_currency_entry + const AlternateCurrency &e ) { - std::vector update_values; + std::vector v; auto columns = Columns(); - update_values.push_back(columns[0] + " = " + std::to_string(alternate_currency_entry.id)); - update_values.push_back(columns[1] + " = " + std::to_string(alternate_currency_entry.item_id)); + v.push_back(columns[0] + " = " + std::to_string(e.id)); + v.push_back(columns[1] + " = " + std::to_string(e.item_id)); auto results = db.QueryDatabase( fmt::format( "UPDATE {} SET {} WHERE {} = {}", TableName(), - Strings::Implode(", ", update_values), + Strings::Implode(", ", v), PrimaryKey(), - alternate_currency_entry.id + e.id ) ); @@ -171,49 +171,49 @@ public: static AlternateCurrency InsertOne( Database& db, - AlternateCurrency alternate_currency_entry + AlternateCurrency e ) { - std::vector insert_values; + std::vector v; - insert_values.push_back(std::to_string(alternate_currency_entry.id)); - insert_values.push_back(std::to_string(alternate_currency_entry.item_id)); + v.push_back(std::to_string(e.id)); + v.push_back(std::to_string(e.item_id)); auto results = db.QueryDatabase( fmt::format( "{} VALUES ({})", BaseInsert(), - Strings::Implode(",", insert_values) + Strings::Implode(",", v) ) ); if (results.Success()) { - alternate_currency_entry.id = results.LastInsertedID(); - return alternate_currency_entry; + e.id = results.LastInsertedID(); + return e; } - alternate_currency_entry = NewEntity(); + e = NewEntity(); - return alternate_currency_entry; + return e; } static int InsertMany( Database& db, - std::vector alternate_currency_entries + const std::vector &entries ) { std::vector insert_chunks; - for (auto &alternate_currency_entry: alternate_currency_entries) { - std::vector insert_values; + for (auto &e: entries) { + std::vector v; - insert_values.push_back(std::to_string(alternate_currency_entry.id)); - insert_values.push_back(std::to_string(alternate_currency_entry.item_id)); + v.push_back(std::to_string(e.id)); + v.push_back(std::to_string(e.item_id)); - insert_chunks.push_back("(" + Strings::Implode(",", insert_values) + ")"); + insert_chunks.push_back("(" + Strings::Implode(",", v) + ")"); } - std::vector insert_values; + std::vector v; auto results = db.QueryDatabase( fmt::format( @@ -240,18 +240,18 @@ public: all_entries.reserve(results.RowCount()); for (auto row = results.begin(); row != results.end(); ++row) { - AlternateCurrency entry{}; + AlternateCurrency e{}; - entry.id = atoi(row[0]); - entry.item_id = atoi(row[1]); + e.id = atoi(row[0]); + e.item_id = atoi(row[1]); - all_entries.push_back(entry); + all_entries.push_back(e); } return all_entries; } - static std::vector GetWhere(Database& db, std::string where_filter) + static std::vector GetWhere(Database& db, const std::string &where_filter) { std::vector all_entries; @@ -266,18 +266,18 @@ public: all_entries.reserve(results.RowCount()); for (auto row = results.begin(); row != results.end(); ++row) { - AlternateCurrency entry{}; + AlternateCurrency e{}; - entry.id = atoi(row[0]); - entry.item_id = atoi(row[1]); + e.id = atoi(row[0]); + e.item_id = atoi(row[1]); - all_entries.push_back(entry); + all_entries.push_back(e); } return all_entries; } - static int DeleteWhere(Database& db, std::string where_filter) + static int DeleteWhere(Database& db, const std::string &where_filter) { auto results = db.QueryDatabase( fmt::format( @@ -302,6 +302,32 @@ public: 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); + } + }; #endif //EQEMU_BASE_ALTERNATE_CURRENCY_REPOSITORY_H diff --git a/common/repositories/base/base_auras_repository.h b/common/repositories/base/base_auras_repository.h index 9deb432c6..4078717ec 100644 --- a/common/repositories/base/base_auras_repository.h +++ b/common/repositories/base/base_auras_repository.h @@ -106,24 +106,24 @@ public: static Auras NewEntity() { - Auras entry{}; + Auras e{}; - entry.type = 0; - entry.npc_type = 0; - entry.name = ""; - entry.spell_id = 0; - entry.distance = 60; - entry.aura_type = 1; - entry.spawn_type = 0; - entry.movement = 0; - entry.duration = 5400; - entry.icon = -1; - entry.cast_time = 0; + e.type = 0; + e.npc_type = 0; + e.name = ""; + e.spell_id = 0; + e.distance = 60; + e.aura_type = 1; + e.spawn_type = 0; + e.movement = 0; + e.duration = 5400; + e.icon = -1; + e.cast_time = 0; - return entry; + return e; } - static Auras GetAurasEntry( + static Auras GetAuras( const std::vector &aurass, int auras_id ) @@ -152,21 +152,21 @@ public: auto row = results.begin(); if (results.RowCount() == 1) { - Auras entry{}; + Auras e{}; - entry.type = atoi(row[0]); - entry.npc_type = atoi(row[1]); - entry.name = row[2] ? row[2] : ""; - entry.spell_id = atoi(row[3]); - entry.distance = atoi(row[4]); - entry.aura_type = atoi(row[5]); - entry.spawn_type = atoi(row[6]); - entry.movement = atoi(row[7]); - entry.duration = atoi(row[8]); - entry.icon = atoi(row[9]); - entry.cast_time = atoi(row[10]); + e.type = atoi(row[0]); + e.npc_type = atoi(row[1]); + e.name = row[2] ? row[2] : ""; + e.spell_id = atoi(row[3]); + e.distance = atoi(row[4]); + e.aura_type = atoi(row[5]); + e.spawn_type = atoi(row[6]); + e.movement = atoi(row[7]); + e.duration = atoi(row[8]); + e.icon = atoi(row[9]); + e.cast_time = atoi(row[10]); - return entry; + return e; } return NewEntity(); @@ -191,32 +191,32 @@ public: static int UpdateOne( Database& db, - Auras auras_entry + const Auras &e ) { - std::vector update_values; + std::vector v; auto columns = Columns(); - update_values.push_back(columns[0] + " = " + std::to_string(auras_entry.type)); - update_values.push_back(columns[1] + " = " + std::to_string(auras_entry.npc_type)); - update_values.push_back(columns[2] + " = '" + Strings::Escape(auras_entry.name) + "'"); - update_values.push_back(columns[3] + " = " + std::to_string(auras_entry.spell_id)); - update_values.push_back(columns[4] + " = " + std::to_string(auras_entry.distance)); - update_values.push_back(columns[5] + " = " + std::to_string(auras_entry.aura_type)); - update_values.push_back(columns[6] + " = " + std::to_string(auras_entry.spawn_type)); - update_values.push_back(columns[7] + " = " + std::to_string(auras_entry.movement)); - update_values.push_back(columns[8] + " = " + std::to_string(auras_entry.duration)); - update_values.push_back(columns[9] + " = " + std::to_string(auras_entry.icon)); - update_values.push_back(columns[10] + " = " + std::to_string(auras_entry.cast_time)); + v.push_back(columns[0] + " = " + std::to_string(e.type)); + v.push_back(columns[1] + " = " + std::to_string(e.npc_type)); + v.push_back(columns[2] + " = '" + Strings::Escape(e.name) + "'"); + v.push_back(columns[3] + " = " + std::to_string(e.spell_id)); + v.push_back(columns[4] + " = " + std::to_string(e.distance)); + v.push_back(columns[5] + " = " + std::to_string(e.aura_type)); + v.push_back(columns[6] + " = " + std::to_string(e.spawn_type)); + v.push_back(columns[7] + " = " + std::to_string(e.movement)); + v.push_back(columns[8] + " = " + std::to_string(e.duration)); + v.push_back(columns[9] + " = " + std::to_string(e.icon)); + v.push_back(columns[10] + " = " + std::to_string(e.cast_time)); auto results = db.QueryDatabase( fmt::format( "UPDATE {} SET {} WHERE {} = {}", TableName(), - Strings::Implode(", ", update_values), + Strings::Implode(", ", v), PrimaryKey(), - auras_entry.type + e.type ) ); @@ -225,67 +225,67 @@ public: static Auras InsertOne( Database& db, - Auras auras_entry + Auras e ) { - std::vector insert_values; + std::vector v; - insert_values.push_back(std::to_string(auras_entry.type)); - insert_values.push_back(std::to_string(auras_entry.npc_type)); - insert_values.push_back("'" + Strings::Escape(auras_entry.name) + "'"); - insert_values.push_back(std::to_string(auras_entry.spell_id)); - insert_values.push_back(std::to_string(auras_entry.distance)); - insert_values.push_back(std::to_string(auras_entry.aura_type)); - insert_values.push_back(std::to_string(auras_entry.spawn_type)); - insert_values.push_back(std::to_string(auras_entry.movement)); - insert_values.push_back(std::to_string(auras_entry.duration)); - insert_values.push_back(std::to_string(auras_entry.icon)); - insert_values.push_back(std::to_string(auras_entry.cast_time)); + v.push_back(std::to_string(e.type)); + v.push_back(std::to_string(e.npc_type)); + v.push_back("'" + Strings::Escape(e.name) + "'"); + v.push_back(std::to_string(e.spell_id)); + v.push_back(std::to_string(e.distance)); + v.push_back(std::to_string(e.aura_type)); + v.push_back(std::to_string(e.spawn_type)); + v.push_back(std::to_string(e.movement)); + v.push_back(std::to_string(e.duration)); + v.push_back(std::to_string(e.icon)); + v.push_back(std::to_string(e.cast_time)); auto results = db.QueryDatabase( fmt::format( "{} VALUES ({})", BaseInsert(), - Strings::Implode(",", insert_values) + Strings::Implode(",", v) ) ); if (results.Success()) { - auras_entry.type = results.LastInsertedID(); - return auras_entry; + e.type = results.LastInsertedID(); + return e; } - auras_entry = NewEntity(); + e = NewEntity(); - return auras_entry; + return e; } static int InsertMany( Database& db, - std::vector auras_entries + const std::vector &entries ) { std::vector insert_chunks; - for (auto &auras_entry: auras_entries) { - std::vector insert_values; + for (auto &e: entries) { + std::vector v; - insert_values.push_back(std::to_string(auras_entry.type)); - insert_values.push_back(std::to_string(auras_entry.npc_type)); - insert_values.push_back("'" + Strings::Escape(auras_entry.name) + "'"); - insert_values.push_back(std::to_string(auras_entry.spell_id)); - insert_values.push_back(std::to_string(auras_entry.distance)); - insert_values.push_back(std::to_string(auras_entry.aura_type)); - insert_values.push_back(std::to_string(auras_entry.spawn_type)); - insert_values.push_back(std::to_string(auras_entry.movement)); - insert_values.push_back(std::to_string(auras_entry.duration)); - insert_values.push_back(std::to_string(auras_entry.icon)); - insert_values.push_back(std::to_string(auras_entry.cast_time)); + v.push_back(std::to_string(e.type)); + v.push_back(std::to_string(e.npc_type)); + v.push_back("'" + Strings::Escape(e.name) + "'"); + v.push_back(std::to_string(e.spell_id)); + v.push_back(std::to_string(e.distance)); + v.push_back(std::to_string(e.aura_type)); + v.push_back(std::to_string(e.spawn_type)); + v.push_back(std::to_string(e.movement)); + v.push_back(std::to_string(e.duration)); + v.push_back(std::to_string(e.icon)); + v.push_back(std::to_string(e.cast_time)); - insert_chunks.push_back("(" + Strings::Implode(",", insert_values) + ")"); + insert_chunks.push_back("(" + Strings::Implode(",", v) + ")"); } - std::vector insert_values; + std::vector v; auto results = db.QueryDatabase( fmt::format( @@ -312,27 +312,27 @@ public: all_entries.reserve(results.RowCount()); for (auto row = results.begin(); row != results.end(); ++row) { - Auras entry{}; + Auras e{}; - entry.type = atoi(row[0]); - entry.npc_type = atoi(row[1]); - entry.name = row[2] ? row[2] : ""; - entry.spell_id = atoi(row[3]); - entry.distance = atoi(row[4]); - entry.aura_type = atoi(row[5]); - entry.spawn_type = atoi(row[6]); - entry.movement = atoi(row[7]); - entry.duration = atoi(row[8]); - entry.icon = atoi(row[9]); - entry.cast_time = atoi(row[10]); + e.type = atoi(row[0]); + e.npc_type = atoi(row[1]); + e.name = row[2] ? row[2] : ""; + e.spell_id = atoi(row[3]); + e.distance = atoi(row[4]); + e.aura_type = atoi(row[5]); + e.spawn_type = atoi(row[6]); + e.movement = atoi(row[7]); + e.duration = atoi(row[8]); + e.icon = atoi(row[9]); + e.cast_time = atoi(row[10]); - all_entries.push_back(entry); + all_entries.push_back(e); } return all_entries; } - static std::vector GetWhere(Database& db, std::string where_filter) + static std::vector GetWhere(Database& db, const std::string &where_filter) { std::vector all_entries; @@ -347,27 +347,27 @@ public: all_entries.reserve(results.RowCount()); for (auto row = results.begin(); row != results.end(); ++row) { - Auras entry{}; + Auras e{}; - entry.type = atoi(row[0]); - entry.npc_type = atoi(row[1]); - entry.name = row[2] ? row[2] : ""; - entry.spell_id = atoi(row[3]); - entry.distance = atoi(row[4]); - entry.aura_type = atoi(row[5]); - entry.spawn_type = atoi(row[6]); - entry.movement = atoi(row[7]); - entry.duration = atoi(row[8]); - entry.icon = atoi(row[9]); - entry.cast_time = atoi(row[10]); + e.type = atoi(row[0]); + e.npc_type = atoi(row[1]); + e.name = row[2] ? row[2] : ""; + e.spell_id = atoi(row[3]); + e.distance = atoi(row[4]); + e.aura_type = atoi(row[5]); + e.spawn_type = atoi(row[6]); + e.movement = atoi(row[7]); + e.duration = atoi(row[8]); + e.icon = atoi(row[9]); + e.cast_time = atoi(row[10]); - all_entries.push_back(entry); + all_entries.push_back(e); } return all_entries; } - static int DeleteWhere(Database& db, std::string where_filter) + static int DeleteWhere(Database& db, const std::string &where_filter) { auto results = db.QueryDatabase( fmt::format( @@ -392,6 +392,32 @@ public: 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); + } + }; #endif //EQEMU_BASE_AURAS_REPOSITORY_H diff --git a/common/repositories/base/base_base_data_repository.h b/common/repositories/base/base_base_data_repository.h index c215d1014..9c4ec52b1 100644 --- a/common/repositories/base/base_base_data_repository.h +++ b/common/repositories/base/base_base_data_repository.h @@ -103,23 +103,23 @@ public: static BaseData NewEntity() { - BaseData entry{}; + BaseData e{}; - entry.level = 0; - entry.class_ = 0; - entry.hp = 0; - entry.mana = 0; - entry.end = 0; - entry.unk1 = 0; - entry.unk2 = 0; - entry.hp_fac = 0; - entry.mana_fac = 0; - entry.end_fac = 0; + e.level = 0; + e.class_ = 0; + e.hp = 0; + e.mana = 0; + e.end = 0; + e.unk1 = 0; + e.unk2 = 0; + e.hp_fac = 0; + e.mana_fac = 0; + e.end_fac = 0; - return entry; + return e; } - static BaseData GetBaseDataEntry( + static BaseData GetBaseData( const std::vector &base_datas, int base_data_id ) @@ -148,20 +148,20 @@ public: auto row = results.begin(); if (results.RowCount() == 1) { - BaseData entry{}; + BaseData e{}; - entry.level = atoi(row[0]); - entry.class_ = atoi(row[1]); - entry.hp = static_cast(atof(row[2])); - entry.mana = static_cast(atof(row[3])); - entry.end = static_cast(atof(row[4])); - entry.unk1 = static_cast(atof(row[5])); - entry.unk2 = static_cast(atof(row[6])); - entry.hp_fac = static_cast(atof(row[7])); - entry.mana_fac = static_cast(atof(row[8])); - entry.end_fac = static_cast(atof(row[9])); + e.level = atoi(row[0]); + e.class_ = atoi(row[1]); + e.hp = static_cast(atof(row[2])); + e.mana = static_cast(atof(row[3])); + e.end = static_cast(atof(row[4])); + e.unk1 = static_cast(atof(row[5])); + e.unk2 = static_cast(atof(row[6])); + e.hp_fac = static_cast(atof(row[7])); + e.mana_fac = static_cast(atof(row[8])); + e.end_fac = static_cast(atof(row[9])); - return entry; + return e; } return NewEntity(); @@ -186,31 +186,31 @@ public: static int UpdateOne( Database& db, - BaseData base_data_entry + const BaseData &e ) { - std::vector update_values; + std::vector v; auto columns = Columns(); - update_values.push_back(columns[0] + " = " + std::to_string(base_data_entry.level)); - update_values.push_back(columns[1] + " = " + std::to_string(base_data_entry.class_)); - update_values.push_back(columns[2] + " = " + std::to_string(base_data_entry.hp)); - update_values.push_back(columns[3] + " = " + std::to_string(base_data_entry.mana)); - update_values.push_back(columns[4] + " = " + std::to_string(base_data_entry.end)); - update_values.push_back(columns[5] + " = " + std::to_string(base_data_entry.unk1)); - update_values.push_back(columns[6] + " = " + std::to_string(base_data_entry.unk2)); - update_values.push_back(columns[7] + " = " + std::to_string(base_data_entry.hp_fac)); - update_values.push_back(columns[8] + " = " + std::to_string(base_data_entry.mana_fac)); - update_values.push_back(columns[9] + " = " + std::to_string(base_data_entry.end_fac)); + v.push_back(columns[0] + " = " + std::to_string(e.level)); + v.push_back(columns[1] + " = " + std::to_string(e.class_)); + v.push_back(columns[2] + " = " + std::to_string(e.hp)); + v.push_back(columns[3] + " = " + std::to_string(e.mana)); + v.push_back(columns[4] + " = " + std::to_string(e.end)); + v.push_back(columns[5] + " = " + std::to_string(e.unk1)); + v.push_back(columns[6] + " = " + std::to_string(e.unk2)); + v.push_back(columns[7] + " = " + std::to_string(e.hp_fac)); + v.push_back(columns[8] + " = " + std::to_string(e.mana_fac)); + v.push_back(columns[9] + " = " + std::to_string(e.end_fac)); auto results = db.QueryDatabase( fmt::format( "UPDATE {} SET {} WHERE {} = {}", TableName(), - Strings::Implode(", ", update_values), + Strings::Implode(", ", v), PrimaryKey(), - base_data_entry.level + e.level ) ); @@ -219,65 +219,65 @@ public: static BaseData InsertOne( Database& db, - BaseData base_data_entry + BaseData e ) { - std::vector insert_values; + std::vector v; - insert_values.push_back(std::to_string(base_data_entry.level)); - insert_values.push_back(std::to_string(base_data_entry.class_)); - insert_values.push_back(std::to_string(base_data_entry.hp)); - insert_values.push_back(std::to_string(base_data_entry.mana)); - insert_values.push_back(std::to_string(base_data_entry.end)); - insert_values.push_back(std::to_string(base_data_entry.unk1)); - insert_values.push_back(std::to_string(base_data_entry.unk2)); - insert_values.push_back(std::to_string(base_data_entry.hp_fac)); - insert_values.push_back(std::to_string(base_data_entry.mana_fac)); - insert_values.push_back(std::to_string(base_data_entry.end_fac)); + v.push_back(std::to_string(e.level)); + v.push_back(std::to_string(e.class_)); + v.push_back(std::to_string(e.hp)); + v.push_back(std::to_string(e.mana)); + v.push_back(std::to_string(e.end)); + v.push_back(std::to_string(e.unk1)); + v.push_back(std::to_string(e.unk2)); + v.push_back(std::to_string(e.hp_fac)); + v.push_back(std::to_string(e.mana_fac)); + v.push_back(std::to_string(e.end_fac)); auto results = db.QueryDatabase( fmt::format( "{} VALUES ({})", BaseInsert(), - Strings::Implode(",", insert_values) + Strings::Implode(",", v) ) ); if (results.Success()) { - base_data_entry.level = results.LastInsertedID(); - return base_data_entry; + e.level = results.LastInsertedID(); + return e; } - base_data_entry = NewEntity(); + e = NewEntity(); - return base_data_entry; + return e; } static int InsertMany( Database& db, - std::vector base_data_entries + const std::vector &entries ) { std::vector insert_chunks; - for (auto &base_data_entry: base_data_entries) { - std::vector insert_values; + for (auto &e: entries) { + std::vector v; - insert_values.push_back(std::to_string(base_data_entry.level)); - insert_values.push_back(std::to_string(base_data_entry.class_)); - insert_values.push_back(std::to_string(base_data_entry.hp)); - insert_values.push_back(std::to_string(base_data_entry.mana)); - insert_values.push_back(std::to_string(base_data_entry.end)); - insert_values.push_back(std::to_string(base_data_entry.unk1)); - insert_values.push_back(std::to_string(base_data_entry.unk2)); - insert_values.push_back(std::to_string(base_data_entry.hp_fac)); - insert_values.push_back(std::to_string(base_data_entry.mana_fac)); - insert_values.push_back(std::to_string(base_data_entry.end_fac)); + v.push_back(std::to_string(e.level)); + v.push_back(std::to_string(e.class_)); + v.push_back(std::to_string(e.hp)); + v.push_back(std::to_string(e.mana)); + v.push_back(std::to_string(e.end)); + v.push_back(std::to_string(e.unk1)); + v.push_back(std::to_string(e.unk2)); + v.push_back(std::to_string(e.hp_fac)); + v.push_back(std::to_string(e.mana_fac)); + v.push_back(std::to_string(e.end_fac)); - insert_chunks.push_back("(" + Strings::Implode(",", insert_values) + ")"); + insert_chunks.push_back("(" + Strings::Implode(",", v) + ")"); } - std::vector insert_values; + std::vector v; auto results = db.QueryDatabase( fmt::format( @@ -304,26 +304,26 @@ public: all_entries.reserve(results.RowCount()); for (auto row = results.begin(); row != results.end(); ++row) { - BaseData entry{}; + BaseData e{}; - entry.level = atoi(row[0]); - entry.class_ = atoi(row[1]); - entry.hp = static_cast(atof(row[2])); - entry.mana = static_cast(atof(row[3])); - entry.end = static_cast(atof(row[4])); - entry.unk1 = static_cast(atof(row[5])); - entry.unk2 = static_cast(atof(row[6])); - entry.hp_fac = static_cast(atof(row[7])); - entry.mana_fac = static_cast(atof(row[8])); - entry.end_fac = static_cast(atof(row[9])); + e.level = atoi(row[0]); + e.class_ = atoi(row[1]); + e.hp = static_cast(atof(row[2])); + e.mana = static_cast(atof(row[3])); + e.end = static_cast(atof(row[4])); + e.unk1 = static_cast(atof(row[5])); + e.unk2 = static_cast(atof(row[6])); + e.hp_fac = static_cast(atof(row[7])); + e.mana_fac = static_cast(atof(row[8])); + e.end_fac = static_cast(atof(row[9])); - all_entries.push_back(entry); + all_entries.push_back(e); } return all_entries; } - static std::vector GetWhere(Database& db, std::string where_filter) + static std::vector GetWhere(Database& db, const std::string &where_filter) { std::vector all_entries; @@ -338,26 +338,26 @@ public: all_entries.reserve(results.RowCount()); for (auto row = results.begin(); row != results.end(); ++row) { - BaseData entry{}; + BaseData e{}; - entry.level = atoi(row[0]); - entry.class_ = atoi(row[1]); - entry.hp = static_cast(atof(row[2])); - entry.mana = static_cast(atof(row[3])); - entry.end = static_cast(atof(row[4])); - entry.unk1 = static_cast(atof(row[5])); - entry.unk2 = static_cast(atof(row[6])); - entry.hp_fac = static_cast(atof(row[7])); - entry.mana_fac = static_cast(atof(row[8])); - entry.end_fac = static_cast(atof(row[9])); + e.level = atoi(row[0]); + e.class_ = atoi(row[1]); + e.hp = static_cast(atof(row[2])); + e.mana = static_cast(atof(row[3])); + e.end = static_cast(atof(row[4])); + e.unk1 = static_cast(atof(row[5])); + e.unk2 = static_cast(atof(row[6])); + e.hp_fac = static_cast(atof(row[7])); + e.mana_fac = static_cast(atof(row[8])); + e.end_fac = static_cast(atof(row[9])); - all_entries.push_back(entry); + all_entries.push_back(e); } return all_entries; } - static int DeleteWhere(Database& db, std::string where_filter) + static int DeleteWhere(Database& db, const std::string &where_filter) { auto results = db.QueryDatabase( fmt::format( @@ -382,6 +382,32 @@ public: 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); + } + }; #endif //EQEMU_BASE_BASE_DATA_REPOSITORY_H diff --git a/common/repositories/base/base_blocked_spells_repository.h b/common/repositories/base/base_blocked_spells_repository.h index 1b8511d2c..e2e31e8f0 100644 --- a/common/repositories/base/base_blocked_spells_repository.h +++ b/common/repositories/base/base_blocked_spells_repository.h @@ -109,25 +109,25 @@ public: static BlockedSpells NewEntity() { - BlockedSpells entry{}; + BlockedSpells e{}; - entry.id = 0; - entry.spellid = 0; - entry.type = 0; - entry.zoneid = 0; - entry.x = 0; - entry.y = 0; - entry.z = 0; - entry.x_diff = 0; - entry.y_diff = 0; - entry.z_diff = 0; - entry.message = ""; - entry.description = ""; + e.id = 0; + e.spellid = 0; + e.type = 0; + e.zoneid = 0; + e.x = 0; + e.y = 0; + e.z = 0; + e.x_diff = 0; + e.y_diff = 0; + e.z_diff = 0; + e.message = ""; + e.description = ""; - return entry; + return e; } - static BlockedSpells GetBlockedSpellsEntry( + static BlockedSpells GetBlockedSpells( const std::vector &blocked_spellss, int blocked_spells_id ) @@ -156,22 +156,22 @@ public: auto row = results.begin(); if (results.RowCount() == 1) { - BlockedSpells entry{}; + BlockedSpells e{}; - entry.id = atoi(row[0]); - entry.spellid = atoi(row[1]); - entry.type = atoi(row[2]); - entry.zoneid = atoi(row[3]); - entry.x = static_cast(atof(row[4])); - entry.y = static_cast(atof(row[5])); - entry.z = static_cast(atof(row[6])); - entry.x_diff = static_cast(atof(row[7])); - entry.y_diff = static_cast(atof(row[8])); - entry.z_diff = static_cast(atof(row[9])); - entry.message = row[10] ? row[10] : ""; - entry.description = row[11] ? row[11] : ""; + e.id = atoi(row[0]); + e.spellid = atoi(row[1]); + e.type = atoi(row[2]); + e.zoneid = atoi(row[3]); + e.x = static_cast(atof(row[4])); + e.y = static_cast(atof(row[5])); + e.z = static_cast(atof(row[6])); + e.x_diff = static_cast(atof(row[7])); + e.y_diff = static_cast(atof(row[8])); + e.z_diff = static_cast(atof(row[9])); + e.message = row[10] ? row[10] : ""; + e.description = row[11] ? row[11] : ""; - return entry; + return e; } return NewEntity(); @@ -196,32 +196,32 @@ public: static int UpdateOne( Database& db, - BlockedSpells blocked_spells_entry + const BlockedSpells &e ) { - std::vector update_values; + std::vector v; auto columns = Columns(); - update_values.push_back(columns[1] + " = " + std::to_string(blocked_spells_entry.spellid)); - update_values.push_back(columns[2] + " = " + std::to_string(blocked_spells_entry.type)); - update_values.push_back(columns[3] + " = " + std::to_string(blocked_spells_entry.zoneid)); - update_values.push_back(columns[4] + " = " + std::to_string(blocked_spells_entry.x)); - update_values.push_back(columns[5] + " = " + std::to_string(blocked_spells_entry.y)); - update_values.push_back(columns[6] + " = " + std::to_string(blocked_spells_entry.z)); - update_values.push_back(columns[7] + " = " + std::to_string(blocked_spells_entry.x_diff)); - update_values.push_back(columns[8] + " = " + std::to_string(blocked_spells_entry.y_diff)); - update_values.push_back(columns[9] + " = " + std::to_string(blocked_spells_entry.z_diff)); - update_values.push_back(columns[10] + " = '" + Strings::Escape(blocked_spells_entry.message) + "'"); - update_values.push_back(columns[11] + " = '" + Strings::Escape(blocked_spells_entry.description) + "'"); + v.push_back(columns[1] + " = " + std::to_string(e.spellid)); + v.push_back(columns[2] + " = " + std::to_string(e.type)); + v.push_back(columns[3] + " = " + std::to_string(e.zoneid)); + v.push_back(columns[4] + " = " + std::to_string(e.x)); + v.push_back(columns[5] + " = " + std::to_string(e.y)); + v.push_back(columns[6] + " = " + std::to_string(e.z)); + v.push_back(columns[7] + " = " + std::to_string(e.x_diff)); + v.push_back(columns[8] + " = " + std::to_string(e.y_diff)); + v.push_back(columns[9] + " = " + std::to_string(e.z_diff)); + v.push_back(columns[10] + " = '" + Strings::Escape(e.message) + "'"); + v.push_back(columns[11] + " = '" + Strings::Escape(e.description) + "'"); auto results = db.QueryDatabase( fmt::format( "UPDATE {} SET {} WHERE {} = {}", TableName(), - Strings::Implode(", ", update_values), + Strings::Implode(", ", v), PrimaryKey(), - blocked_spells_entry.id + e.id ) ); @@ -230,69 +230,69 @@ public: static BlockedSpells InsertOne( Database& db, - BlockedSpells blocked_spells_entry + BlockedSpells e ) { - std::vector insert_values; + std::vector v; - insert_values.push_back(std::to_string(blocked_spells_entry.id)); - insert_values.push_back(std::to_string(blocked_spells_entry.spellid)); - insert_values.push_back(std::to_string(blocked_spells_entry.type)); - insert_values.push_back(std::to_string(blocked_spells_entry.zoneid)); - insert_values.push_back(std::to_string(blocked_spells_entry.x)); - insert_values.push_back(std::to_string(blocked_spells_entry.y)); - insert_values.push_back(std::to_string(blocked_spells_entry.z)); - insert_values.push_back(std::to_string(blocked_spells_entry.x_diff)); - insert_values.push_back(std::to_string(blocked_spells_entry.y_diff)); - insert_values.push_back(std::to_string(blocked_spells_entry.z_diff)); - insert_values.push_back("'" + Strings::Escape(blocked_spells_entry.message) + "'"); - insert_values.push_back("'" + Strings::Escape(blocked_spells_entry.description) + "'"); + v.push_back(std::to_string(e.id)); + v.push_back(std::to_string(e.spellid)); + v.push_back(std::to_string(e.type)); + v.push_back(std::to_string(e.zoneid)); + v.push_back(std::to_string(e.x)); + v.push_back(std::to_string(e.y)); + v.push_back(std::to_string(e.z)); + v.push_back(std::to_string(e.x_diff)); + v.push_back(std::to_string(e.y_diff)); + v.push_back(std::to_string(e.z_diff)); + v.push_back("'" + Strings::Escape(e.message) + "'"); + v.push_back("'" + Strings::Escape(e.description) + "'"); auto results = db.QueryDatabase( fmt::format( "{} VALUES ({})", BaseInsert(), - Strings::Implode(",", insert_values) + Strings::Implode(",", v) ) ); if (results.Success()) { - blocked_spells_entry.id = results.LastInsertedID(); - return blocked_spells_entry; + e.id = results.LastInsertedID(); + return e; } - blocked_spells_entry = NewEntity(); + e = NewEntity(); - return blocked_spells_entry; + return e; } static int InsertMany( Database& db, - std::vector blocked_spells_entries + const std::vector &entries ) { std::vector insert_chunks; - for (auto &blocked_spells_entry: blocked_spells_entries) { - std::vector insert_values; + for (auto &e: entries) { + std::vector v; - insert_values.push_back(std::to_string(blocked_spells_entry.id)); - insert_values.push_back(std::to_string(blocked_spells_entry.spellid)); - insert_values.push_back(std::to_string(blocked_spells_entry.type)); - insert_values.push_back(std::to_string(blocked_spells_entry.zoneid)); - insert_values.push_back(std::to_string(blocked_spells_entry.x)); - insert_values.push_back(std::to_string(blocked_spells_entry.y)); - insert_values.push_back(std::to_string(blocked_spells_entry.z)); - insert_values.push_back(std::to_string(blocked_spells_entry.x_diff)); - insert_values.push_back(std::to_string(blocked_spells_entry.y_diff)); - insert_values.push_back(std::to_string(blocked_spells_entry.z_diff)); - insert_values.push_back("'" + Strings::Escape(blocked_spells_entry.message) + "'"); - insert_values.push_back("'" + Strings::Escape(blocked_spells_entry.description) + "'"); + v.push_back(std::to_string(e.id)); + v.push_back(std::to_string(e.spellid)); + v.push_back(std::to_string(e.type)); + v.push_back(std::to_string(e.zoneid)); + v.push_back(std::to_string(e.x)); + v.push_back(std::to_string(e.y)); + v.push_back(std::to_string(e.z)); + v.push_back(std::to_string(e.x_diff)); + v.push_back(std::to_string(e.y_diff)); + v.push_back(std::to_string(e.z_diff)); + v.push_back("'" + Strings::Escape(e.message) + "'"); + v.push_back("'" + Strings::Escape(e.description) + "'"); - insert_chunks.push_back("(" + Strings::Implode(",", insert_values) + ")"); + insert_chunks.push_back("(" + Strings::Implode(",", v) + ")"); } - std::vector insert_values; + std::vector v; auto results = db.QueryDatabase( fmt::format( @@ -319,28 +319,28 @@ public: all_entries.reserve(results.RowCount()); for (auto row = results.begin(); row != results.end(); ++row) { - BlockedSpells entry{}; + BlockedSpells e{}; - entry.id = atoi(row[0]); - entry.spellid = atoi(row[1]); - entry.type = atoi(row[2]); - entry.zoneid = atoi(row[3]); - entry.x = static_cast(atof(row[4])); - entry.y = static_cast(atof(row[5])); - entry.z = static_cast(atof(row[6])); - entry.x_diff = static_cast(atof(row[7])); - entry.y_diff = static_cast(atof(row[8])); - entry.z_diff = static_cast(atof(row[9])); - entry.message = row[10] ? row[10] : ""; - entry.description = row[11] ? row[11] : ""; + e.id = atoi(row[0]); + e.spellid = atoi(row[1]); + e.type = atoi(row[2]); + e.zoneid = atoi(row[3]); + e.x = static_cast(atof(row[4])); + e.y = static_cast(atof(row[5])); + e.z = static_cast(atof(row[6])); + e.x_diff = static_cast(atof(row[7])); + e.y_diff = static_cast(atof(row[8])); + e.z_diff = static_cast(atof(row[9])); + e.message = row[10] ? row[10] : ""; + e.description = row[11] ? row[11] : ""; - all_entries.push_back(entry); + all_entries.push_back(e); } return all_entries; } - static std::vector GetWhere(Database& db, std::string where_filter) + static std::vector GetWhere(Database& db, const std::string &where_filter) { std::vector all_entries; @@ -355,28 +355,28 @@ public: all_entries.reserve(results.RowCount()); for (auto row = results.begin(); row != results.end(); ++row) { - BlockedSpells entry{}; + BlockedSpells e{}; - entry.id = atoi(row[0]); - entry.spellid = atoi(row[1]); - entry.type = atoi(row[2]); - entry.zoneid = atoi(row[3]); - entry.x = static_cast(atof(row[4])); - entry.y = static_cast(atof(row[5])); - entry.z = static_cast(atof(row[6])); - entry.x_diff = static_cast(atof(row[7])); - entry.y_diff = static_cast(atof(row[8])); - entry.z_diff = static_cast(atof(row[9])); - entry.message = row[10] ? row[10] : ""; - entry.description = row[11] ? row[11] : ""; + e.id = atoi(row[0]); + e.spellid = atoi(row[1]); + e.type = atoi(row[2]); + e.zoneid = atoi(row[3]); + e.x = static_cast(atof(row[4])); + e.y = static_cast(atof(row[5])); + e.z = static_cast(atof(row[6])); + e.x_diff = static_cast(atof(row[7])); + e.y_diff = static_cast(atof(row[8])); + e.z_diff = static_cast(atof(row[9])); + e.message = row[10] ? row[10] : ""; + e.description = row[11] ? row[11] : ""; - all_entries.push_back(entry); + all_entries.push_back(e); } return all_entries; } - static int DeleteWhere(Database& db, std::string where_filter) + static int DeleteWhere(Database& db, const std::string &where_filter) { auto results = db.QueryDatabase( fmt::format( @@ -401,6 +401,32 @@ public: 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); + } + }; #endif //EQEMU_BASE_BLOCKED_SPELLS_REPOSITORY_H diff --git a/common/repositories/base/base_books_repository.h b/common/repositories/base/base_books_repository.h index b988d7ec8..f0ddebe0d 100644 --- a/common/repositories/base/base_books_repository.h +++ b/common/repositories/base/base_books_repository.h @@ -85,17 +85,17 @@ public: static Books NewEntity() { - Books entry{}; + Books e{}; - entry.id = 0; - entry.name = ""; - entry.txtfile = ""; - entry.language = 0; + e.id = 0; + e.name = ""; + e.txtfile = ""; + e.language = 0; - return entry; + return e; } - static Books GetBooksEntry( + static Books GetBooks( const std::vector &bookss, int books_id ) @@ -124,14 +124,14 @@ public: auto row = results.begin(); if (results.RowCount() == 1) { - Books entry{}; + Books e{}; - entry.id = atoi(row[0]); - entry.name = row[1] ? row[1] : ""; - entry.txtfile = row[2] ? row[2] : ""; - entry.language = atoi(row[3]); + e.id = atoi(row[0]); + e.name = row[1] ? row[1] : ""; + e.txtfile = row[2] ? row[2] : ""; + e.language = atoi(row[3]); - return entry; + return e; } return NewEntity(); @@ -156,24 +156,24 @@ public: static int UpdateOne( Database& db, - Books books_entry + const Books &e ) { - std::vector update_values; + std::vector v; auto columns = Columns(); - update_values.push_back(columns[1] + " = '" + Strings::Escape(books_entry.name) + "'"); - update_values.push_back(columns[2] + " = '" + Strings::Escape(books_entry.txtfile) + "'"); - update_values.push_back(columns[3] + " = " + std::to_string(books_entry.language)); + v.push_back(columns[1] + " = '" + Strings::Escape(e.name) + "'"); + v.push_back(columns[2] + " = '" + Strings::Escape(e.txtfile) + "'"); + v.push_back(columns[3] + " = " + std::to_string(e.language)); auto results = db.QueryDatabase( fmt::format( "UPDATE {} SET {} WHERE {} = {}", TableName(), - Strings::Implode(", ", update_values), + Strings::Implode(", ", v), PrimaryKey(), - books_entry.id + e.id ) ); @@ -182,53 +182,53 @@ public: static Books InsertOne( Database& db, - Books books_entry + Books e ) { - std::vector insert_values; + std::vector v; - insert_values.push_back(std::to_string(books_entry.id)); - insert_values.push_back("'" + Strings::Escape(books_entry.name) + "'"); - insert_values.push_back("'" + Strings::Escape(books_entry.txtfile) + "'"); - insert_values.push_back(std::to_string(books_entry.language)); + v.push_back(std::to_string(e.id)); + v.push_back("'" + Strings::Escape(e.name) + "'"); + v.push_back("'" + Strings::Escape(e.txtfile) + "'"); + v.push_back(std::to_string(e.language)); auto results = db.QueryDatabase( fmt::format( "{} VALUES ({})", BaseInsert(), - Strings::Implode(",", insert_values) + Strings::Implode(",", v) ) ); if (results.Success()) { - books_entry.id = results.LastInsertedID(); - return books_entry; + e.id = results.LastInsertedID(); + return e; } - books_entry = NewEntity(); + e = NewEntity(); - return books_entry; + return e; } static int InsertMany( Database& db, - std::vector books_entries + const std::vector &entries ) { std::vector insert_chunks; - for (auto &books_entry: books_entries) { - std::vector insert_values; + for (auto &e: entries) { + std::vector v; - insert_values.push_back(std::to_string(books_entry.id)); - insert_values.push_back("'" + Strings::Escape(books_entry.name) + "'"); - insert_values.push_back("'" + Strings::Escape(books_entry.txtfile) + "'"); - insert_values.push_back(std::to_string(books_entry.language)); + v.push_back(std::to_string(e.id)); + v.push_back("'" + Strings::Escape(e.name) + "'"); + v.push_back("'" + Strings::Escape(e.txtfile) + "'"); + v.push_back(std::to_string(e.language)); - insert_chunks.push_back("(" + Strings::Implode(",", insert_values) + ")"); + insert_chunks.push_back("(" + Strings::Implode(",", v) + ")"); } - std::vector insert_values; + std::vector v; auto results = db.QueryDatabase( fmt::format( @@ -255,20 +255,20 @@ public: all_entries.reserve(results.RowCount()); for (auto row = results.begin(); row != results.end(); ++row) { - Books entry{}; + Books e{}; - entry.id = atoi(row[0]); - entry.name = row[1] ? row[1] : ""; - entry.txtfile = row[2] ? row[2] : ""; - entry.language = atoi(row[3]); + e.id = atoi(row[0]); + e.name = row[1] ? row[1] : ""; + e.txtfile = row[2] ? row[2] : ""; + e.language = atoi(row[3]); - all_entries.push_back(entry); + all_entries.push_back(e); } return all_entries; } - static std::vector GetWhere(Database& db, std::string where_filter) + static std::vector GetWhere(Database& db, const std::string &where_filter) { std::vector all_entries; @@ -283,20 +283,20 @@ public: all_entries.reserve(results.RowCount()); for (auto row = results.begin(); row != results.end(); ++row) { - Books entry{}; + Books e{}; - entry.id = atoi(row[0]); - entry.name = row[1] ? row[1] : ""; - entry.txtfile = row[2] ? row[2] : ""; - entry.language = atoi(row[3]); + e.id = atoi(row[0]); + e.name = row[1] ? row[1] : ""; + e.txtfile = row[2] ? row[2] : ""; + e.language = atoi(row[3]); - all_entries.push_back(entry); + all_entries.push_back(e); } return all_entries; } - static int DeleteWhere(Database& db, std::string where_filter) + static int DeleteWhere(Database& db, const std::string &where_filter) { auto results = db.QueryDatabase( fmt::format( @@ -321,6 +321,32 @@ public: 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); + } + }; #endif //EQEMU_BASE_BOOKS_REPOSITORY_H diff --git a/common/repositories/base/base_bug_reports_repository.h b/common/repositories/base/base_bug_reports_repository.h index e284c3f53..9e068b184 100644 --- a/common/repositories/base/base_bug_reports_repository.h +++ b/common/repositories/base/base_bug_reports_repository.h @@ -169,45 +169,45 @@ public: static BugReports NewEntity() { - BugReports entry{}; + BugReports e{}; - entry.id = 0; - entry.zone = "Unknown"; - entry.client_version_id = 0; - entry.client_version_name = "Unknown"; - entry.account_id = 0; - entry.character_id = 0; - entry.character_name = "Unknown"; - entry.reporter_spoof = 1; - entry.category_id = 0; - entry.category_name = "Other"; - entry.reporter_name = "Unknown"; - entry.ui_path = "Unknown"; - entry.pos_x = 0; - entry.pos_y = 0; - entry.pos_z = 0; - entry.heading = 0; - entry.time_played = 0; - entry.target_id = 0; - entry.target_name = "Unknown"; - entry.optional_info_mask = 0; - entry._can_duplicate = 0; - entry._crash_bug = 0; - entry._target_info = 0; - entry._character_flags = 0; - entry._unknown_value = 0; - entry.bug_report = ""; - entry.system_info = ""; - entry.report_datetime = std::time(nullptr); - entry.bug_status = 0; - entry.last_review = std::time(nullptr); - entry.last_reviewer = "None"; - entry.reviewer_notes = ""; + e.id = 0; + e.zone = "Unknown"; + e.client_version_id = 0; + e.client_version_name = "Unknown"; + e.account_id = 0; + e.character_id = 0; + e.character_name = "Unknown"; + e.reporter_spoof = 1; + e.category_id = 0; + e.category_name = "Other"; + e.reporter_name = "Unknown"; + e.ui_path = "Unknown"; + e.pos_x = 0; + e.pos_y = 0; + e.pos_z = 0; + e.heading = 0; + e.time_played = 0; + e.target_id = 0; + e.target_name = "Unknown"; + e.optional_info_mask = 0; + e._can_duplicate = 0; + e._crash_bug = 0; + e._target_info = 0; + e._character_flags = 0; + e._unknown_value = 0; + e.bug_report = ""; + e.system_info = ""; + e.report_datetime = std::time(nullptr); + e.bug_status = 0; + e.last_review = std::time(nullptr); + e.last_reviewer = "None"; + e.reviewer_notes = ""; - return entry; + return e; } - static BugReports GetBugReportsEntry( + static BugReports GetBugReports( const std::vector &bug_reportss, int bug_reports_id ) @@ -236,42 +236,42 @@ public: auto row = results.begin(); if (results.RowCount() == 1) { - BugReports entry{}; + BugReports e{}; - entry.id = atoi(row[0]); - entry.zone = row[1] ? row[1] : ""; - entry.client_version_id = atoi(row[2]); - entry.client_version_name = row[3] ? row[3] : ""; - entry.account_id = atoi(row[4]); - entry.character_id = atoi(row[5]); - entry.character_name = row[6] ? row[6] : ""; - entry.reporter_spoof = atoi(row[7]); - entry.category_id = atoi(row[8]); - entry.category_name = row[9] ? row[9] : ""; - entry.reporter_name = row[10] ? row[10] : ""; - entry.ui_path = row[11] ? row[11] : ""; - entry.pos_x = static_cast(atof(row[12])); - entry.pos_y = static_cast(atof(row[13])); - entry.pos_z = static_cast(atof(row[14])); - entry.heading = atoi(row[15]); - entry.time_played = atoi(row[16]); - entry.target_id = atoi(row[17]); - entry.target_name = row[18] ? row[18] : ""; - entry.optional_info_mask = atoi(row[19]); - entry._can_duplicate = atoi(row[20]); - entry._crash_bug = atoi(row[21]); - entry._target_info = atoi(row[22]); - entry._character_flags = atoi(row[23]); - entry._unknown_value = atoi(row[24]); - entry.bug_report = row[25] ? row[25] : ""; - entry.system_info = row[26] ? row[26] : ""; - entry.report_datetime = strtoll(row[27] ? row[27] : "-1", nullptr, 10); - entry.bug_status = atoi(row[28]); - entry.last_review = strtoll(row[29] ? row[29] : "-1", nullptr, 10); - entry.last_reviewer = row[30] ? row[30] : ""; - entry.reviewer_notes = row[31] ? row[31] : ""; + e.id = atoi(row[0]); + e.zone = row[1] ? row[1] : ""; + e.client_version_id = atoi(row[2]); + e.client_version_name = row[3] ? row[3] : ""; + e.account_id = atoi(row[4]); + e.character_id = atoi(row[5]); + e.character_name = row[6] ? row[6] : ""; + e.reporter_spoof = atoi(row[7]); + e.category_id = atoi(row[8]); + e.category_name = row[9] ? row[9] : ""; + e.reporter_name = row[10] ? row[10] : ""; + e.ui_path = row[11] ? row[11] : ""; + e.pos_x = static_cast(atof(row[12])); + e.pos_y = static_cast(atof(row[13])); + e.pos_z = static_cast(atof(row[14])); + e.heading = atoi(row[15]); + e.time_played = atoi(row[16]); + e.target_id = atoi(row[17]); + e.target_name = row[18] ? row[18] : ""; + e.optional_info_mask = atoi(row[19]); + e._can_duplicate = atoi(row[20]); + e._crash_bug = atoi(row[21]); + e._target_info = atoi(row[22]); + e._character_flags = atoi(row[23]); + e._unknown_value = atoi(row[24]); + e.bug_report = row[25] ? row[25] : ""; + e.system_info = row[26] ? row[26] : ""; + e.report_datetime = strtoll(row[27] ? row[27] : "-1", nullptr, 10); + e.bug_status = atoi(row[28]); + e.last_review = strtoll(row[29] ? row[29] : "-1", nullptr, 10); + e.last_reviewer = row[30] ? row[30] : ""; + e.reviewer_notes = row[31] ? row[31] : ""; - return entry; + return e; } return NewEntity(); @@ -296,52 +296,52 @@ public: static int UpdateOne( Database& db, - BugReports bug_reports_entry + const BugReports &e ) { - std::vector update_values; + std::vector v; auto columns = Columns(); - update_values.push_back(columns[1] + " = '" + Strings::Escape(bug_reports_entry.zone) + "'"); - update_values.push_back(columns[2] + " = " + std::to_string(bug_reports_entry.client_version_id)); - update_values.push_back(columns[3] + " = '" + Strings::Escape(bug_reports_entry.client_version_name) + "'"); - update_values.push_back(columns[4] + " = " + std::to_string(bug_reports_entry.account_id)); - update_values.push_back(columns[5] + " = " + std::to_string(bug_reports_entry.character_id)); - update_values.push_back(columns[6] + " = '" + Strings::Escape(bug_reports_entry.character_name) + "'"); - update_values.push_back(columns[7] + " = " + std::to_string(bug_reports_entry.reporter_spoof)); - update_values.push_back(columns[8] + " = " + std::to_string(bug_reports_entry.category_id)); - update_values.push_back(columns[9] + " = '" + Strings::Escape(bug_reports_entry.category_name) + "'"); - update_values.push_back(columns[10] + " = '" + Strings::Escape(bug_reports_entry.reporter_name) + "'"); - update_values.push_back(columns[11] + " = '" + Strings::Escape(bug_reports_entry.ui_path) + "'"); - update_values.push_back(columns[12] + " = " + std::to_string(bug_reports_entry.pos_x)); - update_values.push_back(columns[13] + " = " + std::to_string(bug_reports_entry.pos_y)); - update_values.push_back(columns[14] + " = " + std::to_string(bug_reports_entry.pos_z)); - update_values.push_back(columns[15] + " = " + std::to_string(bug_reports_entry.heading)); - update_values.push_back(columns[16] + " = " + std::to_string(bug_reports_entry.time_played)); - update_values.push_back(columns[17] + " = " + std::to_string(bug_reports_entry.target_id)); - update_values.push_back(columns[18] + " = '" + Strings::Escape(bug_reports_entry.target_name) + "'"); - update_values.push_back(columns[19] + " = " + std::to_string(bug_reports_entry.optional_info_mask)); - update_values.push_back(columns[20] + " = " + std::to_string(bug_reports_entry._can_duplicate)); - update_values.push_back(columns[21] + " = " + std::to_string(bug_reports_entry._crash_bug)); - update_values.push_back(columns[22] + " = " + std::to_string(bug_reports_entry._target_info)); - update_values.push_back(columns[23] + " = " + std::to_string(bug_reports_entry._character_flags)); - update_values.push_back(columns[24] + " = " + std::to_string(bug_reports_entry._unknown_value)); - update_values.push_back(columns[25] + " = '" + Strings::Escape(bug_reports_entry.bug_report) + "'"); - update_values.push_back(columns[26] + " = '" + Strings::Escape(bug_reports_entry.system_info) + "'"); - update_values.push_back(columns[27] + " = FROM_UNIXTIME(" + (bug_reports_entry.report_datetime > 0 ? std::to_string(bug_reports_entry.report_datetime) : "null") + ")"); - update_values.push_back(columns[28] + " = " + std::to_string(bug_reports_entry.bug_status)); - update_values.push_back(columns[29] + " = FROM_UNIXTIME(" + (bug_reports_entry.last_review > 0 ? std::to_string(bug_reports_entry.last_review) : "null") + ")"); - update_values.push_back(columns[30] + " = '" + Strings::Escape(bug_reports_entry.last_reviewer) + "'"); - update_values.push_back(columns[31] + " = '" + Strings::Escape(bug_reports_entry.reviewer_notes) + "'"); + v.push_back(columns[1] + " = '" + Strings::Escape(e.zone) + "'"); + v.push_back(columns[2] + " = " + std::to_string(e.client_version_id)); + v.push_back(columns[3] + " = '" + Strings::Escape(e.client_version_name) + "'"); + v.push_back(columns[4] + " = " + std::to_string(e.account_id)); + v.push_back(columns[5] + " = " + std::to_string(e.character_id)); + v.push_back(columns[6] + " = '" + Strings::Escape(e.character_name) + "'"); + v.push_back(columns[7] + " = " + std::to_string(e.reporter_spoof)); + v.push_back(columns[8] + " = " + std::to_string(e.category_id)); + v.push_back(columns[9] + " = '" + Strings::Escape(e.category_name) + "'"); + v.push_back(columns[10] + " = '" + Strings::Escape(e.reporter_name) + "'"); + v.push_back(columns[11] + " = '" + Strings::Escape(e.ui_path) + "'"); + v.push_back(columns[12] + " = " + std::to_string(e.pos_x)); + v.push_back(columns[13] + " = " + std::to_string(e.pos_y)); + v.push_back(columns[14] + " = " + std::to_string(e.pos_z)); + v.push_back(columns[15] + " = " + std::to_string(e.heading)); + v.push_back(columns[16] + " = " + std::to_string(e.time_played)); + v.push_back(columns[17] + " = " + std::to_string(e.target_id)); + v.push_back(columns[18] + " = '" + Strings::Escape(e.target_name) + "'"); + v.push_back(columns[19] + " = " + std::to_string(e.optional_info_mask)); + v.push_back(columns[20] + " = " + std::to_string(e._can_duplicate)); + v.push_back(columns[21] + " = " + std::to_string(e._crash_bug)); + v.push_back(columns[22] + " = " + std::to_string(e._target_info)); + v.push_back(columns[23] + " = " + std::to_string(e._character_flags)); + v.push_back(columns[24] + " = " + std::to_string(e._unknown_value)); + v.push_back(columns[25] + " = '" + Strings::Escape(e.bug_report) + "'"); + v.push_back(columns[26] + " = '" + Strings::Escape(e.system_info) + "'"); + v.push_back(columns[27] + " = FROM_UNIXTIME(" + (e.report_datetime > 0 ? std::to_string(e.report_datetime) : "null") + ")"); + v.push_back(columns[28] + " = " + std::to_string(e.bug_status)); + v.push_back(columns[29] + " = FROM_UNIXTIME(" + (e.last_review > 0 ? std::to_string(e.last_review) : "null") + ")"); + v.push_back(columns[30] + " = '" + Strings::Escape(e.last_reviewer) + "'"); + v.push_back(columns[31] + " = '" + Strings::Escape(e.reviewer_notes) + "'"); auto results = db.QueryDatabase( fmt::format( "UPDATE {} SET {} WHERE {} = {}", TableName(), - Strings::Implode(", ", update_values), + Strings::Implode(", ", v), PrimaryKey(), - bug_reports_entry.id + e.id ) ); @@ -350,109 +350,109 @@ public: static BugReports InsertOne( Database& db, - BugReports bug_reports_entry + BugReports e ) { - std::vector insert_values; + std::vector v; - insert_values.push_back(std::to_string(bug_reports_entry.id)); - insert_values.push_back("'" + Strings::Escape(bug_reports_entry.zone) + "'"); - insert_values.push_back(std::to_string(bug_reports_entry.client_version_id)); - insert_values.push_back("'" + Strings::Escape(bug_reports_entry.client_version_name) + "'"); - insert_values.push_back(std::to_string(bug_reports_entry.account_id)); - insert_values.push_back(std::to_string(bug_reports_entry.character_id)); - insert_values.push_back("'" + Strings::Escape(bug_reports_entry.character_name) + "'"); - insert_values.push_back(std::to_string(bug_reports_entry.reporter_spoof)); - insert_values.push_back(std::to_string(bug_reports_entry.category_id)); - insert_values.push_back("'" + Strings::Escape(bug_reports_entry.category_name) + "'"); - insert_values.push_back("'" + Strings::Escape(bug_reports_entry.reporter_name) + "'"); - insert_values.push_back("'" + Strings::Escape(bug_reports_entry.ui_path) + "'"); - insert_values.push_back(std::to_string(bug_reports_entry.pos_x)); - insert_values.push_back(std::to_string(bug_reports_entry.pos_y)); - insert_values.push_back(std::to_string(bug_reports_entry.pos_z)); - insert_values.push_back(std::to_string(bug_reports_entry.heading)); - insert_values.push_back(std::to_string(bug_reports_entry.time_played)); - insert_values.push_back(std::to_string(bug_reports_entry.target_id)); - insert_values.push_back("'" + Strings::Escape(bug_reports_entry.target_name) + "'"); - insert_values.push_back(std::to_string(bug_reports_entry.optional_info_mask)); - insert_values.push_back(std::to_string(bug_reports_entry._can_duplicate)); - insert_values.push_back(std::to_string(bug_reports_entry._crash_bug)); - insert_values.push_back(std::to_string(bug_reports_entry._target_info)); - insert_values.push_back(std::to_string(bug_reports_entry._character_flags)); - insert_values.push_back(std::to_string(bug_reports_entry._unknown_value)); - insert_values.push_back("'" + Strings::Escape(bug_reports_entry.bug_report) + "'"); - insert_values.push_back("'" + Strings::Escape(bug_reports_entry.system_info) + "'"); - insert_values.push_back("FROM_UNIXTIME(" + (bug_reports_entry.report_datetime > 0 ? std::to_string(bug_reports_entry.report_datetime) : "null") + ")"); - insert_values.push_back(std::to_string(bug_reports_entry.bug_status)); - insert_values.push_back("FROM_UNIXTIME(" + (bug_reports_entry.last_review > 0 ? std::to_string(bug_reports_entry.last_review) : "null") + ")"); - insert_values.push_back("'" + Strings::Escape(bug_reports_entry.last_reviewer) + "'"); - insert_values.push_back("'" + Strings::Escape(bug_reports_entry.reviewer_notes) + "'"); + v.push_back(std::to_string(e.id)); + v.push_back("'" + Strings::Escape(e.zone) + "'"); + v.push_back(std::to_string(e.client_version_id)); + v.push_back("'" + Strings::Escape(e.client_version_name) + "'"); + v.push_back(std::to_string(e.account_id)); + v.push_back(std::to_string(e.character_id)); + v.push_back("'" + Strings::Escape(e.character_name) + "'"); + v.push_back(std::to_string(e.reporter_spoof)); + v.push_back(std::to_string(e.category_id)); + v.push_back("'" + Strings::Escape(e.category_name) + "'"); + v.push_back("'" + Strings::Escape(e.reporter_name) + "'"); + v.push_back("'" + Strings::Escape(e.ui_path) + "'"); + v.push_back(std::to_string(e.pos_x)); + v.push_back(std::to_string(e.pos_y)); + v.push_back(std::to_string(e.pos_z)); + v.push_back(std::to_string(e.heading)); + v.push_back(std::to_string(e.time_played)); + v.push_back(std::to_string(e.target_id)); + v.push_back("'" + Strings::Escape(e.target_name) + "'"); + v.push_back(std::to_string(e.optional_info_mask)); + v.push_back(std::to_string(e._can_duplicate)); + v.push_back(std::to_string(e._crash_bug)); + v.push_back(std::to_string(e._target_info)); + v.push_back(std::to_string(e._character_flags)); + v.push_back(std::to_string(e._unknown_value)); + v.push_back("'" + Strings::Escape(e.bug_report) + "'"); + v.push_back("'" + Strings::Escape(e.system_info) + "'"); + v.push_back("FROM_UNIXTIME(" + (e.report_datetime > 0 ? std::to_string(e.report_datetime) : "null") + ")"); + v.push_back(std::to_string(e.bug_status)); + v.push_back("FROM_UNIXTIME(" + (e.last_review > 0 ? std::to_string(e.last_review) : "null") + ")"); + v.push_back("'" + Strings::Escape(e.last_reviewer) + "'"); + v.push_back("'" + Strings::Escape(e.reviewer_notes) + "'"); auto results = db.QueryDatabase( fmt::format( "{} VALUES ({})", BaseInsert(), - Strings::Implode(",", insert_values) + Strings::Implode(",", v) ) ); if (results.Success()) { - bug_reports_entry.id = results.LastInsertedID(); - return bug_reports_entry; + e.id = results.LastInsertedID(); + return e; } - bug_reports_entry = NewEntity(); + e = NewEntity(); - return bug_reports_entry; + return e; } static int InsertMany( Database& db, - std::vector bug_reports_entries + const std::vector &entries ) { std::vector insert_chunks; - for (auto &bug_reports_entry: bug_reports_entries) { - std::vector insert_values; + for (auto &e: entries) { + std::vector v; - insert_values.push_back(std::to_string(bug_reports_entry.id)); - insert_values.push_back("'" + Strings::Escape(bug_reports_entry.zone) + "'"); - insert_values.push_back(std::to_string(bug_reports_entry.client_version_id)); - insert_values.push_back("'" + Strings::Escape(bug_reports_entry.client_version_name) + "'"); - insert_values.push_back(std::to_string(bug_reports_entry.account_id)); - insert_values.push_back(std::to_string(bug_reports_entry.character_id)); - insert_values.push_back("'" + Strings::Escape(bug_reports_entry.character_name) + "'"); - insert_values.push_back(std::to_string(bug_reports_entry.reporter_spoof)); - insert_values.push_back(std::to_string(bug_reports_entry.category_id)); - insert_values.push_back("'" + Strings::Escape(bug_reports_entry.category_name) + "'"); - insert_values.push_back("'" + Strings::Escape(bug_reports_entry.reporter_name) + "'"); - insert_values.push_back("'" + Strings::Escape(bug_reports_entry.ui_path) + "'"); - insert_values.push_back(std::to_string(bug_reports_entry.pos_x)); - insert_values.push_back(std::to_string(bug_reports_entry.pos_y)); - insert_values.push_back(std::to_string(bug_reports_entry.pos_z)); - insert_values.push_back(std::to_string(bug_reports_entry.heading)); - insert_values.push_back(std::to_string(bug_reports_entry.time_played)); - insert_values.push_back(std::to_string(bug_reports_entry.target_id)); - insert_values.push_back("'" + Strings::Escape(bug_reports_entry.target_name) + "'"); - insert_values.push_back(std::to_string(bug_reports_entry.optional_info_mask)); - insert_values.push_back(std::to_string(bug_reports_entry._can_duplicate)); - insert_values.push_back(std::to_string(bug_reports_entry._crash_bug)); - insert_values.push_back(std::to_string(bug_reports_entry._target_info)); - insert_values.push_back(std::to_string(bug_reports_entry._character_flags)); - insert_values.push_back(std::to_string(bug_reports_entry._unknown_value)); - insert_values.push_back("'" + Strings::Escape(bug_reports_entry.bug_report) + "'"); - insert_values.push_back("'" + Strings::Escape(bug_reports_entry.system_info) + "'"); - insert_values.push_back("FROM_UNIXTIME(" + (bug_reports_entry.report_datetime > 0 ? std::to_string(bug_reports_entry.report_datetime) : "null") + ")"); - insert_values.push_back(std::to_string(bug_reports_entry.bug_status)); - insert_values.push_back("FROM_UNIXTIME(" + (bug_reports_entry.last_review > 0 ? std::to_string(bug_reports_entry.last_review) : "null") + ")"); - insert_values.push_back("'" + Strings::Escape(bug_reports_entry.last_reviewer) + "'"); - insert_values.push_back("'" + Strings::Escape(bug_reports_entry.reviewer_notes) + "'"); + v.push_back(std::to_string(e.id)); + v.push_back("'" + Strings::Escape(e.zone) + "'"); + v.push_back(std::to_string(e.client_version_id)); + v.push_back("'" + Strings::Escape(e.client_version_name) + "'"); + v.push_back(std::to_string(e.account_id)); + v.push_back(std::to_string(e.character_id)); + v.push_back("'" + Strings::Escape(e.character_name) + "'"); + v.push_back(std::to_string(e.reporter_spoof)); + v.push_back(std::to_string(e.category_id)); + v.push_back("'" + Strings::Escape(e.category_name) + "'"); + v.push_back("'" + Strings::Escape(e.reporter_name) + "'"); + v.push_back("'" + Strings::Escape(e.ui_path) + "'"); + v.push_back(std::to_string(e.pos_x)); + v.push_back(std::to_string(e.pos_y)); + v.push_back(std::to_string(e.pos_z)); + v.push_back(std::to_string(e.heading)); + v.push_back(std::to_string(e.time_played)); + v.push_back(std::to_string(e.target_id)); + v.push_back("'" + Strings::Escape(e.target_name) + "'"); + v.push_back(std::to_string(e.optional_info_mask)); + v.push_back(std::to_string(e._can_duplicate)); + v.push_back(std::to_string(e._crash_bug)); + v.push_back(std::to_string(e._target_info)); + v.push_back(std::to_string(e._character_flags)); + v.push_back(std::to_string(e._unknown_value)); + v.push_back("'" + Strings::Escape(e.bug_report) + "'"); + v.push_back("'" + Strings::Escape(e.system_info) + "'"); + v.push_back("FROM_UNIXTIME(" + (e.report_datetime > 0 ? std::to_string(e.report_datetime) : "null") + ")"); + v.push_back(std::to_string(e.bug_status)); + v.push_back("FROM_UNIXTIME(" + (e.last_review > 0 ? std::to_string(e.last_review) : "null") + ")"); + v.push_back("'" + Strings::Escape(e.last_reviewer) + "'"); + v.push_back("'" + Strings::Escape(e.reviewer_notes) + "'"); - insert_chunks.push_back("(" + Strings::Implode(",", insert_values) + ")"); + insert_chunks.push_back("(" + Strings::Implode(",", v) + ")"); } - std::vector insert_values; + std::vector v; auto results = db.QueryDatabase( fmt::format( @@ -479,48 +479,48 @@ public: all_entries.reserve(results.RowCount()); for (auto row = results.begin(); row != results.end(); ++row) { - BugReports entry{}; + BugReports e{}; - entry.id = atoi(row[0]); - entry.zone = row[1] ? row[1] : ""; - entry.client_version_id = atoi(row[2]); - entry.client_version_name = row[3] ? row[3] : ""; - entry.account_id = atoi(row[4]); - entry.character_id = atoi(row[5]); - entry.character_name = row[6] ? row[6] : ""; - entry.reporter_spoof = atoi(row[7]); - entry.category_id = atoi(row[8]); - entry.category_name = row[9] ? row[9] : ""; - entry.reporter_name = row[10] ? row[10] : ""; - entry.ui_path = row[11] ? row[11] : ""; - entry.pos_x = static_cast(atof(row[12])); - entry.pos_y = static_cast(atof(row[13])); - entry.pos_z = static_cast(atof(row[14])); - entry.heading = atoi(row[15]); - entry.time_played = atoi(row[16]); - entry.target_id = atoi(row[17]); - entry.target_name = row[18] ? row[18] : ""; - entry.optional_info_mask = atoi(row[19]); - entry._can_duplicate = atoi(row[20]); - entry._crash_bug = atoi(row[21]); - entry._target_info = atoi(row[22]); - entry._character_flags = atoi(row[23]); - entry._unknown_value = atoi(row[24]); - entry.bug_report = row[25] ? row[25] : ""; - entry.system_info = row[26] ? row[26] : ""; - entry.report_datetime = strtoll(row[27] ? row[27] : "-1", nullptr, 10); - entry.bug_status = atoi(row[28]); - entry.last_review = strtoll(row[29] ? row[29] : "-1", nullptr, 10); - entry.last_reviewer = row[30] ? row[30] : ""; - entry.reviewer_notes = row[31] ? row[31] : ""; + e.id = atoi(row[0]); + e.zone = row[1] ? row[1] : ""; + e.client_version_id = atoi(row[2]); + e.client_version_name = row[3] ? row[3] : ""; + e.account_id = atoi(row[4]); + e.character_id = atoi(row[5]); + e.character_name = row[6] ? row[6] : ""; + e.reporter_spoof = atoi(row[7]); + e.category_id = atoi(row[8]); + e.category_name = row[9] ? row[9] : ""; + e.reporter_name = row[10] ? row[10] : ""; + e.ui_path = row[11] ? row[11] : ""; + e.pos_x = static_cast(atof(row[12])); + e.pos_y = static_cast(atof(row[13])); + e.pos_z = static_cast(atof(row[14])); + e.heading = atoi(row[15]); + e.time_played = atoi(row[16]); + e.target_id = atoi(row[17]); + e.target_name = row[18] ? row[18] : ""; + e.optional_info_mask = atoi(row[19]); + e._can_duplicate = atoi(row[20]); + e._crash_bug = atoi(row[21]); + e._target_info = atoi(row[22]); + e._character_flags = atoi(row[23]); + e._unknown_value = atoi(row[24]); + e.bug_report = row[25] ? row[25] : ""; + e.system_info = row[26] ? row[26] : ""; + e.report_datetime = strtoll(row[27] ? row[27] : "-1", nullptr, 10); + e.bug_status = atoi(row[28]); + e.last_review = strtoll(row[29] ? row[29] : "-1", nullptr, 10); + e.last_reviewer = row[30] ? row[30] : ""; + e.reviewer_notes = row[31] ? row[31] : ""; - all_entries.push_back(entry); + all_entries.push_back(e); } return all_entries; } - static std::vector GetWhere(Database& db, std::string where_filter) + static std::vector GetWhere(Database& db, const std::string &where_filter) { std::vector all_entries; @@ -535,48 +535,48 @@ public: all_entries.reserve(results.RowCount()); for (auto row = results.begin(); row != results.end(); ++row) { - BugReports entry{}; + BugReports e{}; - entry.id = atoi(row[0]); - entry.zone = row[1] ? row[1] : ""; - entry.client_version_id = atoi(row[2]); - entry.client_version_name = row[3] ? row[3] : ""; - entry.account_id = atoi(row[4]); - entry.character_id = atoi(row[5]); - entry.character_name = row[6] ? row[6] : ""; - entry.reporter_spoof = atoi(row[7]); - entry.category_id = atoi(row[8]); - entry.category_name = row[9] ? row[9] : ""; - entry.reporter_name = row[10] ? row[10] : ""; - entry.ui_path = row[11] ? row[11] : ""; - entry.pos_x = static_cast(atof(row[12])); - entry.pos_y = static_cast(atof(row[13])); - entry.pos_z = static_cast(atof(row[14])); - entry.heading = atoi(row[15]); - entry.time_played = atoi(row[16]); - entry.target_id = atoi(row[17]); - entry.target_name = row[18] ? row[18] : ""; - entry.optional_info_mask = atoi(row[19]); - entry._can_duplicate = atoi(row[20]); - entry._crash_bug = atoi(row[21]); - entry._target_info = atoi(row[22]); - entry._character_flags = atoi(row[23]); - entry._unknown_value = atoi(row[24]); - entry.bug_report = row[25] ? row[25] : ""; - entry.system_info = row[26] ? row[26] : ""; - entry.report_datetime = strtoll(row[27] ? row[27] : "-1", nullptr, 10); - entry.bug_status = atoi(row[28]); - entry.last_review = strtoll(row[29] ? row[29] : "-1", nullptr, 10); - entry.last_reviewer = row[30] ? row[30] : ""; - entry.reviewer_notes = row[31] ? row[31] : ""; + e.id = atoi(row[0]); + e.zone = row[1] ? row[1] : ""; + e.client_version_id = atoi(row[2]); + e.client_version_name = row[3] ? row[3] : ""; + e.account_id = atoi(row[4]); + e.character_id = atoi(row[5]); + e.character_name = row[6] ? row[6] : ""; + e.reporter_spoof = atoi(row[7]); + e.category_id = atoi(row[8]); + e.category_name = row[9] ? row[9] : ""; + e.reporter_name = row[10] ? row[10] : ""; + e.ui_path = row[11] ? row[11] : ""; + e.pos_x = static_cast(atof(row[12])); + e.pos_y = static_cast(atof(row[13])); + e.pos_z = static_cast(atof(row[14])); + e.heading = atoi(row[15]); + e.time_played = atoi(row[16]); + e.target_id = atoi(row[17]); + e.target_name = row[18] ? row[18] : ""; + e.optional_info_mask = atoi(row[19]); + e._can_duplicate = atoi(row[20]); + e._crash_bug = atoi(row[21]); + e._target_info = atoi(row[22]); + e._character_flags = atoi(row[23]); + e._unknown_value = atoi(row[24]); + e.bug_report = row[25] ? row[25] : ""; + e.system_info = row[26] ? row[26] : ""; + e.report_datetime = strtoll(row[27] ? row[27] : "-1", nullptr, 10); + e.bug_status = atoi(row[28]); + e.last_review = strtoll(row[29] ? row[29] : "-1", nullptr, 10); + e.last_reviewer = row[30] ? row[30] : ""; + e.reviewer_notes = row[31] ? row[31] : ""; - all_entries.push_back(entry); + all_entries.push_back(e); } return all_entries; } - static int DeleteWhere(Database& db, std::string where_filter) + static int DeleteWhere(Database& db, const std::string &where_filter) { auto results = db.QueryDatabase( fmt::format( @@ -601,6 +601,32 @@ public: 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); + } + }; #endif //EQEMU_BASE_BUG_REPORTS_REPOSITORY_H diff --git a/common/repositories/base/base_bugs_repository.h b/common/repositories/base/base_bugs_repository.h index c1000cb4a..795e368aa 100644 --- a/common/repositories/base/base_bugs_repository.h +++ b/common/repositories/base/base_bugs_repository.h @@ -112,26 +112,26 @@ public: static Bugs NewEntity() { - Bugs entry{}; + Bugs e{}; - entry.id = 0; - entry.zone = ""; - entry.name = ""; - entry.ui = ""; - entry.x = 0; - entry.y = 0; - entry.z = 0; - entry.type = ""; - entry.flag = 0; - entry.target = ""; - entry.bug = ""; - entry.date = 0; - entry.status = 0; + e.id = 0; + e.zone = ""; + e.name = ""; + e.ui = ""; + e.x = 0; + e.y = 0; + e.z = 0; + e.type = ""; + e.flag = 0; + e.target = ""; + e.bug = ""; + e.date = 0; + e.status = 0; - return entry; + return e; } - static Bugs GetBugsEntry( + static Bugs GetBugs( const std::vector &bugss, int bugs_id ) @@ -160,23 +160,23 @@ public: auto row = results.begin(); if (results.RowCount() == 1) { - Bugs entry{}; + Bugs e{}; - entry.id = atoi(row[0]); - entry.zone = row[1] ? row[1] : ""; - entry.name = row[2] ? row[2] : ""; - entry.ui = row[3] ? row[3] : ""; - entry.x = static_cast(atof(row[4])); - entry.y = static_cast(atof(row[5])); - entry.z = static_cast(atof(row[6])); - entry.type = row[7] ? row[7] : ""; - entry.flag = atoi(row[8]); - entry.target = row[9] ? row[9] : ""; - entry.bug = row[10] ? row[10] : ""; - entry.date = row[11] ? row[11] : ""; - entry.status = atoi(row[12]); + e.id = atoi(row[0]); + e.zone = row[1] ? row[1] : ""; + e.name = row[2] ? row[2] : ""; + e.ui = row[3] ? row[3] : ""; + e.x = static_cast(atof(row[4])); + e.y = static_cast(atof(row[5])); + e.z = static_cast(atof(row[6])); + e.type = row[7] ? row[7] : ""; + e.flag = atoi(row[8]); + e.target = row[9] ? row[9] : ""; + e.bug = row[10] ? row[10] : ""; + e.date = row[11] ? row[11] : ""; + e.status = atoi(row[12]); - return entry; + return e; } return NewEntity(); @@ -201,33 +201,33 @@ public: static int UpdateOne( Database& db, - Bugs bugs_entry + const Bugs &e ) { - std::vector update_values; + std::vector v; auto columns = Columns(); - update_values.push_back(columns[1] + " = '" + Strings::Escape(bugs_entry.zone) + "'"); - update_values.push_back(columns[2] + " = '" + Strings::Escape(bugs_entry.name) + "'"); - update_values.push_back(columns[3] + " = '" + Strings::Escape(bugs_entry.ui) + "'"); - update_values.push_back(columns[4] + " = " + std::to_string(bugs_entry.x)); - update_values.push_back(columns[5] + " = " + std::to_string(bugs_entry.y)); - update_values.push_back(columns[6] + " = " + std::to_string(bugs_entry.z)); - update_values.push_back(columns[7] + " = '" + Strings::Escape(bugs_entry.type) + "'"); - update_values.push_back(columns[8] + " = " + std::to_string(bugs_entry.flag)); - update_values.push_back(columns[9] + " = '" + Strings::Escape(bugs_entry.target) + "'"); - update_values.push_back(columns[10] + " = '" + Strings::Escape(bugs_entry.bug) + "'"); - update_values.push_back(columns[11] + " = '" + Strings::Escape(bugs_entry.date) + "'"); - update_values.push_back(columns[12] + " = " + std::to_string(bugs_entry.status)); + v.push_back(columns[1] + " = '" + Strings::Escape(e.zone) + "'"); + v.push_back(columns[2] + " = '" + Strings::Escape(e.name) + "'"); + v.push_back(columns[3] + " = '" + Strings::Escape(e.ui) + "'"); + v.push_back(columns[4] + " = " + std::to_string(e.x)); + v.push_back(columns[5] + " = " + std::to_string(e.y)); + v.push_back(columns[6] + " = " + std::to_string(e.z)); + v.push_back(columns[7] + " = '" + Strings::Escape(e.type) + "'"); + v.push_back(columns[8] + " = " + std::to_string(e.flag)); + v.push_back(columns[9] + " = '" + Strings::Escape(e.target) + "'"); + v.push_back(columns[10] + " = '" + Strings::Escape(e.bug) + "'"); + v.push_back(columns[11] + " = '" + Strings::Escape(e.date) + "'"); + v.push_back(columns[12] + " = " + std::to_string(e.status)); auto results = db.QueryDatabase( fmt::format( "UPDATE {} SET {} WHERE {} = {}", TableName(), - Strings::Implode(", ", update_values), + Strings::Implode(", ", v), PrimaryKey(), - bugs_entry.id + e.id ) ); @@ -236,71 +236,71 @@ public: static Bugs InsertOne( Database& db, - Bugs bugs_entry + Bugs e ) { - std::vector insert_values; + std::vector v; - insert_values.push_back(std::to_string(bugs_entry.id)); - insert_values.push_back("'" + Strings::Escape(bugs_entry.zone) + "'"); - insert_values.push_back("'" + Strings::Escape(bugs_entry.name) + "'"); - insert_values.push_back("'" + Strings::Escape(bugs_entry.ui) + "'"); - insert_values.push_back(std::to_string(bugs_entry.x)); - insert_values.push_back(std::to_string(bugs_entry.y)); - insert_values.push_back(std::to_string(bugs_entry.z)); - insert_values.push_back("'" + Strings::Escape(bugs_entry.type) + "'"); - insert_values.push_back(std::to_string(bugs_entry.flag)); - insert_values.push_back("'" + Strings::Escape(bugs_entry.target) + "'"); - insert_values.push_back("'" + Strings::Escape(bugs_entry.bug) + "'"); - insert_values.push_back("'" + Strings::Escape(bugs_entry.date) + "'"); - insert_values.push_back(std::to_string(bugs_entry.status)); + v.push_back(std::to_string(e.id)); + v.push_back("'" + Strings::Escape(e.zone) + "'"); + v.push_back("'" + Strings::Escape(e.name) + "'"); + v.push_back("'" + Strings::Escape(e.ui) + "'"); + v.push_back(std::to_string(e.x)); + v.push_back(std::to_string(e.y)); + v.push_back(std::to_string(e.z)); + v.push_back("'" + Strings::Escape(e.type) + "'"); + v.push_back(std::to_string(e.flag)); + v.push_back("'" + Strings::Escape(e.target) + "'"); + v.push_back("'" + Strings::Escape(e.bug) + "'"); + v.push_back("'" + Strings::Escape(e.date) + "'"); + v.push_back(std::to_string(e.status)); auto results = db.QueryDatabase( fmt::format( "{} VALUES ({})", BaseInsert(), - Strings::Implode(",", insert_values) + Strings::Implode(",", v) ) ); if (results.Success()) { - bugs_entry.id = results.LastInsertedID(); - return bugs_entry; + e.id = results.LastInsertedID(); + return e; } - bugs_entry = NewEntity(); + e = NewEntity(); - return bugs_entry; + return e; } static int InsertMany( Database& db, - std::vector bugs_entries + const std::vector &entries ) { std::vector insert_chunks; - for (auto &bugs_entry: bugs_entries) { - std::vector insert_values; + for (auto &e: entries) { + std::vector v; - insert_values.push_back(std::to_string(bugs_entry.id)); - insert_values.push_back("'" + Strings::Escape(bugs_entry.zone) + "'"); - insert_values.push_back("'" + Strings::Escape(bugs_entry.name) + "'"); - insert_values.push_back("'" + Strings::Escape(bugs_entry.ui) + "'"); - insert_values.push_back(std::to_string(bugs_entry.x)); - insert_values.push_back(std::to_string(bugs_entry.y)); - insert_values.push_back(std::to_string(bugs_entry.z)); - insert_values.push_back("'" + Strings::Escape(bugs_entry.type) + "'"); - insert_values.push_back(std::to_string(bugs_entry.flag)); - insert_values.push_back("'" + Strings::Escape(bugs_entry.target) + "'"); - insert_values.push_back("'" + Strings::Escape(bugs_entry.bug) + "'"); - insert_values.push_back("'" + Strings::Escape(bugs_entry.date) + "'"); - insert_values.push_back(std::to_string(bugs_entry.status)); + v.push_back(std::to_string(e.id)); + v.push_back("'" + Strings::Escape(e.zone) + "'"); + v.push_back("'" + Strings::Escape(e.name) + "'"); + v.push_back("'" + Strings::Escape(e.ui) + "'"); + v.push_back(std::to_string(e.x)); + v.push_back(std::to_string(e.y)); + v.push_back(std::to_string(e.z)); + v.push_back("'" + Strings::Escape(e.type) + "'"); + v.push_back(std::to_string(e.flag)); + v.push_back("'" + Strings::Escape(e.target) + "'"); + v.push_back("'" + Strings::Escape(e.bug) + "'"); + v.push_back("'" + Strings::Escape(e.date) + "'"); + v.push_back(std::to_string(e.status)); - insert_chunks.push_back("(" + Strings::Implode(",", insert_values) + ")"); + insert_chunks.push_back("(" + Strings::Implode(",", v) + ")"); } - std::vector insert_values; + std::vector v; auto results = db.QueryDatabase( fmt::format( @@ -327,29 +327,29 @@ public: all_entries.reserve(results.RowCount()); for (auto row = results.begin(); row != results.end(); ++row) { - Bugs entry{}; + Bugs e{}; - entry.id = atoi(row[0]); - entry.zone = row[1] ? row[1] : ""; - entry.name = row[2] ? row[2] : ""; - entry.ui = row[3] ? row[3] : ""; - entry.x = static_cast(atof(row[4])); - entry.y = static_cast(atof(row[5])); - entry.z = static_cast(atof(row[6])); - entry.type = row[7] ? row[7] : ""; - entry.flag = atoi(row[8]); - entry.target = row[9] ? row[9] : ""; - entry.bug = row[10] ? row[10] : ""; - entry.date = row[11] ? row[11] : ""; - entry.status = atoi(row[12]); + e.id = atoi(row[0]); + e.zone = row[1] ? row[1] : ""; + e.name = row[2] ? row[2] : ""; + e.ui = row[3] ? row[3] : ""; + e.x = static_cast(atof(row[4])); + e.y = static_cast(atof(row[5])); + e.z = static_cast(atof(row[6])); + e.type = row[7] ? row[7] : ""; + e.flag = atoi(row[8]); + e.target = row[9] ? row[9] : ""; + e.bug = row[10] ? row[10] : ""; + e.date = row[11] ? row[11] : ""; + e.status = atoi(row[12]); - all_entries.push_back(entry); + all_entries.push_back(e); } return all_entries; } - static std::vector GetWhere(Database& db, std::string where_filter) + static std::vector GetWhere(Database& db, const std::string &where_filter) { std::vector all_entries; @@ -364,29 +364,29 @@ public: all_entries.reserve(results.RowCount()); for (auto row = results.begin(); row != results.end(); ++row) { - Bugs entry{}; + Bugs e{}; - entry.id = atoi(row[0]); - entry.zone = row[1] ? row[1] : ""; - entry.name = row[2] ? row[2] : ""; - entry.ui = row[3] ? row[3] : ""; - entry.x = static_cast(atof(row[4])); - entry.y = static_cast(atof(row[5])); - entry.z = static_cast(atof(row[6])); - entry.type = row[7] ? row[7] : ""; - entry.flag = atoi(row[8]); - entry.target = row[9] ? row[9] : ""; - entry.bug = row[10] ? row[10] : ""; - entry.date = row[11] ? row[11] : ""; - entry.status = atoi(row[12]); + e.id = atoi(row[0]); + e.zone = row[1] ? row[1] : ""; + e.name = row[2] ? row[2] : ""; + e.ui = row[3] ? row[3] : ""; + e.x = static_cast(atof(row[4])); + e.y = static_cast(atof(row[5])); + e.z = static_cast(atof(row[6])); + e.type = row[7] ? row[7] : ""; + e.flag = atoi(row[8]); + e.target = row[9] ? row[9] : ""; + e.bug = row[10] ? row[10] : ""; + e.date = row[11] ? row[11] : ""; + e.status = atoi(row[12]); - all_entries.push_back(entry); + all_entries.push_back(e); } return all_entries; } - static int DeleteWhere(Database& db, std::string where_filter) + static int DeleteWhere(Database& db, const std::string &where_filter) { auto results = db.QueryDatabase( fmt::format( @@ -411,6 +411,32 @@ public: 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); + } + }; #endif //EQEMU_BASE_BUGS_REPOSITORY_H diff --git a/common/repositories/base/base_buyer_repository.h b/common/repositories/base/base_buyer_repository.h index d8e1b45f4..da497d910 100644 --- a/common/repositories/base/base_buyer_repository.h +++ b/common/repositories/base/base_buyer_repository.h @@ -91,19 +91,19 @@ public: static Buyer NewEntity() { - Buyer entry{}; + Buyer e{}; - entry.charid = 0; - entry.buyslot = 0; - entry.itemid = 0; - entry.itemname = ""; - entry.quantity = 0; - entry.price = 0; + e.charid = 0; + e.buyslot = 0; + e.itemid = 0; + e.itemname = ""; + e.quantity = 0; + e.price = 0; - return entry; + return e; } - static Buyer GetBuyerEntry( + static Buyer GetBuyer( const std::vector &buyers, int buyer_id ) @@ -132,16 +132,16 @@ public: auto row = results.begin(); if (results.RowCount() == 1) { - Buyer entry{}; + Buyer e{}; - entry.charid = atoi(row[0]); - entry.buyslot = atoi(row[1]); - entry.itemid = atoi(row[2]); - entry.itemname = row[3] ? row[3] : ""; - entry.quantity = atoi(row[4]); - entry.price = atoi(row[5]); + e.charid = atoi(row[0]); + e.buyslot = atoi(row[1]); + e.itemid = atoi(row[2]); + e.itemname = row[3] ? row[3] : ""; + e.quantity = atoi(row[4]); + e.price = atoi(row[5]); - return entry; + return e; } return NewEntity(); @@ -166,27 +166,27 @@ public: static int UpdateOne( Database& db, - Buyer buyer_entry + const Buyer &e ) { - std::vector update_values; + std::vector v; auto columns = Columns(); - update_values.push_back(columns[0] + " = " + std::to_string(buyer_entry.charid)); - update_values.push_back(columns[1] + " = " + std::to_string(buyer_entry.buyslot)); - update_values.push_back(columns[2] + " = " + std::to_string(buyer_entry.itemid)); - update_values.push_back(columns[3] + " = '" + Strings::Escape(buyer_entry.itemname) + "'"); - update_values.push_back(columns[4] + " = " + std::to_string(buyer_entry.quantity)); - update_values.push_back(columns[5] + " = " + std::to_string(buyer_entry.price)); + v.push_back(columns[0] + " = " + std::to_string(e.charid)); + v.push_back(columns[1] + " = " + std::to_string(e.buyslot)); + v.push_back(columns[2] + " = " + std::to_string(e.itemid)); + v.push_back(columns[3] + " = '" + Strings::Escape(e.itemname) + "'"); + v.push_back(columns[4] + " = " + std::to_string(e.quantity)); + v.push_back(columns[5] + " = " + std::to_string(e.price)); auto results = db.QueryDatabase( fmt::format( "UPDATE {} SET {} WHERE {} = {}", TableName(), - Strings::Implode(", ", update_values), + Strings::Implode(", ", v), PrimaryKey(), - buyer_entry.charid + e.charid ) ); @@ -195,57 +195,57 @@ public: static Buyer InsertOne( Database& db, - Buyer buyer_entry + Buyer e ) { - std::vector insert_values; + std::vector v; - insert_values.push_back(std::to_string(buyer_entry.charid)); - insert_values.push_back(std::to_string(buyer_entry.buyslot)); - insert_values.push_back(std::to_string(buyer_entry.itemid)); - insert_values.push_back("'" + Strings::Escape(buyer_entry.itemname) + "'"); - insert_values.push_back(std::to_string(buyer_entry.quantity)); - insert_values.push_back(std::to_string(buyer_entry.price)); + v.push_back(std::to_string(e.charid)); + v.push_back(std::to_string(e.buyslot)); + v.push_back(std::to_string(e.itemid)); + v.push_back("'" + Strings::Escape(e.itemname) + "'"); + v.push_back(std::to_string(e.quantity)); + v.push_back(std::to_string(e.price)); auto results = db.QueryDatabase( fmt::format( "{} VALUES ({})", BaseInsert(), - Strings::Implode(",", insert_values) + Strings::Implode(",", v) ) ); if (results.Success()) { - buyer_entry.charid = results.LastInsertedID(); - return buyer_entry; + e.charid = results.LastInsertedID(); + return e; } - buyer_entry = NewEntity(); + e = NewEntity(); - return buyer_entry; + return e; } static int InsertMany( Database& db, - std::vector buyer_entries + const std::vector &entries ) { std::vector insert_chunks; - for (auto &buyer_entry: buyer_entries) { - std::vector insert_values; + for (auto &e: entries) { + std::vector v; - insert_values.push_back(std::to_string(buyer_entry.charid)); - insert_values.push_back(std::to_string(buyer_entry.buyslot)); - insert_values.push_back(std::to_string(buyer_entry.itemid)); - insert_values.push_back("'" + Strings::Escape(buyer_entry.itemname) + "'"); - insert_values.push_back(std::to_string(buyer_entry.quantity)); - insert_values.push_back(std::to_string(buyer_entry.price)); + v.push_back(std::to_string(e.charid)); + v.push_back(std::to_string(e.buyslot)); + v.push_back(std::to_string(e.itemid)); + v.push_back("'" + Strings::Escape(e.itemname) + "'"); + v.push_back(std::to_string(e.quantity)); + v.push_back(std::to_string(e.price)); - insert_chunks.push_back("(" + Strings::Implode(",", insert_values) + ")"); + insert_chunks.push_back("(" + Strings::Implode(",", v) + ")"); } - std::vector insert_values; + std::vector v; auto results = db.QueryDatabase( fmt::format( @@ -272,22 +272,22 @@ public: all_entries.reserve(results.RowCount()); for (auto row = results.begin(); row != results.end(); ++row) { - Buyer entry{}; + Buyer e{}; - entry.charid = atoi(row[0]); - entry.buyslot = atoi(row[1]); - entry.itemid = atoi(row[2]); - entry.itemname = row[3] ? row[3] : ""; - entry.quantity = atoi(row[4]); - entry.price = atoi(row[5]); + e.charid = atoi(row[0]); + e.buyslot = atoi(row[1]); + e.itemid = atoi(row[2]); + e.itemname = row[3] ? row[3] : ""; + e.quantity = atoi(row[4]); + e.price = atoi(row[5]); - all_entries.push_back(entry); + all_entries.push_back(e); } return all_entries; } - static std::vector GetWhere(Database& db, std::string where_filter) + static std::vector GetWhere(Database& db, const std::string &where_filter) { std::vector all_entries; @@ -302,22 +302,22 @@ public: all_entries.reserve(results.RowCount()); for (auto row = results.begin(); row != results.end(); ++row) { - Buyer entry{}; + Buyer e{}; - entry.charid = atoi(row[0]); - entry.buyslot = atoi(row[1]); - entry.itemid = atoi(row[2]); - entry.itemname = row[3] ? row[3] : ""; - entry.quantity = atoi(row[4]); - entry.price = atoi(row[5]); + e.charid = atoi(row[0]); + e.buyslot = atoi(row[1]); + e.itemid = atoi(row[2]); + e.itemname = row[3] ? row[3] : ""; + e.quantity = atoi(row[4]); + e.price = atoi(row[5]); - all_entries.push_back(entry); + all_entries.push_back(e); } return all_entries; } - static int DeleteWhere(Database& db, std::string where_filter) + static int DeleteWhere(Database& db, const std::string &where_filter) { auto results = db.QueryDatabase( fmt::format( @@ -342,6 +342,32 @@ public: 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); + } + }; #endif //EQEMU_BASE_BUYER_REPOSITORY_H diff --git a/common/repositories/base/base_char_create_combinations_repository.h b/common/repositories/base/base_char_create_combinations_repository.h index 0af778217..f922ef4c7 100644 --- a/common/repositories/base/base_char_create_combinations_repository.h +++ b/common/repositories/base/base_char_create_combinations_repository.h @@ -91,19 +91,19 @@ public: static CharCreateCombinations NewEntity() { - CharCreateCombinations entry{}; + CharCreateCombinations e{}; - entry.allocation_id = 0; - entry.race = 0; - entry.class_ = 0; - entry.deity = 0; - entry.start_zone = 0; - entry.expansions_req = 0; + e.allocation_id = 0; + e.race = 0; + e.class_ = 0; + e.deity = 0; + e.start_zone = 0; + e.expansions_req = 0; - return entry; + return e; } - static CharCreateCombinations GetCharCreateCombinationsEntry( + static CharCreateCombinations GetCharCreateCombinations( const std::vector &char_create_combinationss, int char_create_combinations_id ) @@ -132,16 +132,16 @@ public: auto row = results.begin(); if (results.RowCount() == 1) { - CharCreateCombinations entry{}; + CharCreateCombinations e{}; - entry.allocation_id = atoi(row[0]); - entry.race = atoi(row[1]); - entry.class_ = atoi(row[2]); - entry.deity = atoi(row[3]); - entry.start_zone = atoi(row[4]); - entry.expansions_req = atoi(row[5]); + e.allocation_id = atoi(row[0]); + e.race = atoi(row[1]); + e.class_ = atoi(row[2]); + e.deity = atoi(row[3]); + e.start_zone = atoi(row[4]); + e.expansions_req = atoi(row[5]); - return entry; + return e; } return NewEntity(); @@ -166,27 +166,27 @@ public: static int UpdateOne( Database& db, - CharCreateCombinations char_create_combinations_entry + const CharCreateCombinations &e ) { - std::vector update_values; + std::vector v; auto columns = Columns(); - update_values.push_back(columns[0] + " = " + std::to_string(char_create_combinations_entry.allocation_id)); - update_values.push_back(columns[1] + " = " + std::to_string(char_create_combinations_entry.race)); - update_values.push_back(columns[2] + " = " + std::to_string(char_create_combinations_entry.class_)); - update_values.push_back(columns[3] + " = " + std::to_string(char_create_combinations_entry.deity)); - update_values.push_back(columns[4] + " = " + std::to_string(char_create_combinations_entry.start_zone)); - update_values.push_back(columns[5] + " = " + std::to_string(char_create_combinations_entry.expansions_req)); + v.push_back(columns[0] + " = " + std::to_string(e.allocation_id)); + v.push_back(columns[1] + " = " + std::to_string(e.race)); + v.push_back(columns[2] + " = " + std::to_string(e.class_)); + v.push_back(columns[3] + " = " + std::to_string(e.deity)); + v.push_back(columns[4] + " = " + std::to_string(e.start_zone)); + v.push_back(columns[5] + " = " + std::to_string(e.expansions_req)); auto results = db.QueryDatabase( fmt::format( "UPDATE {} SET {} WHERE {} = {}", TableName(), - Strings::Implode(", ", update_values), + Strings::Implode(", ", v), PrimaryKey(), - char_create_combinations_entry.race + e.race ) ); @@ -195,57 +195,57 @@ public: static CharCreateCombinations InsertOne( Database& db, - CharCreateCombinations char_create_combinations_entry + CharCreateCombinations e ) { - std::vector insert_values; + std::vector v; - insert_values.push_back(std::to_string(char_create_combinations_entry.allocation_id)); - insert_values.push_back(std::to_string(char_create_combinations_entry.race)); - insert_values.push_back(std::to_string(char_create_combinations_entry.class_)); - insert_values.push_back(std::to_string(char_create_combinations_entry.deity)); - insert_values.push_back(std::to_string(char_create_combinations_entry.start_zone)); - insert_values.push_back(std::to_string(char_create_combinations_entry.expansions_req)); + v.push_back(std::to_string(e.allocation_id)); + v.push_back(std::to_string(e.race)); + v.push_back(std::to_string(e.class_)); + v.push_back(std::to_string(e.deity)); + v.push_back(std::to_string(e.start_zone)); + v.push_back(std::to_string(e.expansions_req)); auto results = db.QueryDatabase( fmt::format( "{} VALUES ({})", BaseInsert(), - Strings::Implode(",", insert_values) + Strings::Implode(",", v) ) ); if (results.Success()) { - char_create_combinations_entry.race = results.LastInsertedID(); - return char_create_combinations_entry; + e.race = results.LastInsertedID(); + return e; } - char_create_combinations_entry = NewEntity(); + e = NewEntity(); - return char_create_combinations_entry; + return e; } static int InsertMany( Database& db, - std::vector char_create_combinations_entries + const std::vector &entries ) { std::vector insert_chunks; - for (auto &char_create_combinations_entry: char_create_combinations_entries) { - std::vector insert_values; + for (auto &e: entries) { + std::vector v; - insert_values.push_back(std::to_string(char_create_combinations_entry.allocation_id)); - insert_values.push_back(std::to_string(char_create_combinations_entry.race)); - insert_values.push_back(std::to_string(char_create_combinations_entry.class_)); - insert_values.push_back(std::to_string(char_create_combinations_entry.deity)); - insert_values.push_back(std::to_string(char_create_combinations_entry.start_zone)); - insert_values.push_back(std::to_string(char_create_combinations_entry.expansions_req)); + v.push_back(std::to_string(e.allocation_id)); + v.push_back(std::to_string(e.race)); + v.push_back(std::to_string(e.class_)); + v.push_back(std::to_string(e.deity)); + v.push_back(std::to_string(e.start_zone)); + v.push_back(std::to_string(e.expansions_req)); - insert_chunks.push_back("(" + Strings::Implode(",", insert_values) + ")"); + insert_chunks.push_back("(" + Strings::Implode(",", v) + ")"); } - std::vector insert_values; + std::vector v; auto results = db.QueryDatabase( fmt::format( @@ -272,22 +272,22 @@ public: all_entries.reserve(results.RowCount()); for (auto row = results.begin(); row != results.end(); ++row) { - CharCreateCombinations entry{}; + CharCreateCombinations e{}; - entry.allocation_id = atoi(row[0]); - entry.race = atoi(row[1]); - entry.class_ = atoi(row[2]); - entry.deity = atoi(row[3]); - entry.start_zone = atoi(row[4]); - entry.expansions_req = atoi(row[5]); + e.allocation_id = atoi(row[0]); + e.race = atoi(row[1]); + e.class_ = atoi(row[2]); + e.deity = atoi(row[3]); + e.start_zone = atoi(row[4]); + e.expansions_req = atoi(row[5]); - all_entries.push_back(entry); + all_entries.push_back(e); } return all_entries; } - static std::vector GetWhere(Database& db, std::string where_filter) + static std::vector GetWhere(Database& db, const std::string &where_filter) { std::vector all_entries; @@ -302,22 +302,22 @@ public: all_entries.reserve(results.RowCount()); for (auto row = results.begin(); row != results.end(); ++row) { - CharCreateCombinations entry{}; + CharCreateCombinations e{}; - entry.allocation_id = atoi(row[0]); - entry.race = atoi(row[1]); - entry.class_ = atoi(row[2]); - entry.deity = atoi(row[3]); - entry.start_zone = atoi(row[4]); - entry.expansions_req = atoi(row[5]); + e.allocation_id = atoi(row[0]); + e.race = atoi(row[1]); + e.class_ = atoi(row[2]); + e.deity = atoi(row[3]); + e.start_zone = atoi(row[4]); + e.expansions_req = atoi(row[5]); - all_entries.push_back(entry); + all_entries.push_back(e); } return all_entries; } - static int DeleteWhere(Database& db, std::string where_filter) + static int DeleteWhere(Database& db, const std::string &where_filter) { auto results = db.QueryDatabase( fmt::format( @@ -342,6 +342,32 @@ public: 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); + } + }; #endif //EQEMU_BASE_CHAR_CREATE_COMBINATIONS_REPOSITORY_H diff --git a/common/repositories/base/base_char_create_point_allocations_repository.h b/common/repositories/base/base_char_create_point_allocations_repository.h index d43abd3b4..80aa317f1 100644 --- a/common/repositories/base/base_char_create_point_allocations_repository.h +++ b/common/repositories/base/base_char_create_point_allocations_repository.h @@ -118,28 +118,28 @@ public: static CharCreatePointAllocations NewEntity() { - CharCreatePointAllocations entry{}; + CharCreatePointAllocations e{}; - entry.id = 0; - entry.base_str = 0; - entry.base_sta = 0; - entry.base_dex = 0; - entry.base_agi = 0; - entry.base_int = 0; - entry.base_wis = 0; - entry.base_cha = 0; - entry.alloc_str = 0; - entry.alloc_sta = 0; - entry.alloc_dex = 0; - entry.alloc_agi = 0; - entry.alloc_int = 0; - entry.alloc_wis = 0; - entry.alloc_cha = 0; + e.id = 0; + e.base_str = 0; + e.base_sta = 0; + e.base_dex = 0; + e.base_agi = 0; + e.base_int = 0; + e.base_wis = 0; + e.base_cha = 0; + e.alloc_str = 0; + e.alloc_sta = 0; + e.alloc_dex = 0; + e.alloc_agi = 0; + e.alloc_int = 0; + e.alloc_wis = 0; + e.alloc_cha = 0; - return entry; + return e; } - static CharCreatePointAllocations GetCharCreatePointAllocationsEntry( + static CharCreatePointAllocations GetCharCreatePointAllocations( const std::vector &char_create_point_allocationss, int char_create_point_allocations_id ) @@ -168,25 +168,25 @@ public: auto row = results.begin(); if (results.RowCount() == 1) { - CharCreatePointAllocations entry{}; + CharCreatePointAllocations e{}; - entry.id = atoi(row[0]); - entry.base_str = atoi(row[1]); - entry.base_sta = atoi(row[2]); - entry.base_dex = atoi(row[3]); - entry.base_agi = atoi(row[4]); - entry.base_int = atoi(row[5]); - entry.base_wis = atoi(row[6]); - entry.base_cha = atoi(row[7]); - entry.alloc_str = atoi(row[8]); - entry.alloc_sta = atoi(row[9]); - entry.alloc_dex = atoi(row[10]); - entry.alloc_agi = atoi(row[11]); - entry.alloc_int = atoi(row[12]); - entry.alloc_wis = atoi(row[13]); - entry.alloc_cha = atoi(row[14]); + e.id = atoi(row[0]); + e.base_str = atoi(row[1]); + e.base_sta = atoi(row[2]); + e.base_dex = atoi(row[3]); + e.base_agi = atoi(row[4]); + e.base_int = atoi(row[5]); + e.base_wis = atoi(row[6]); + e.base_cha = atoi(row[7]); + e.alloc_str = atoi(row[8]); + e.alloc_sta = atoi(row[9]); + e.alloc_dex = atoi(row[10]); + e.alloc_agi = atoi(row[11]); + e.alloc_int = atoi(row[12]); + e.alloc_wis = atoi(row[13]); + e.alloc_cha = atoi(row[14]); - return entry; + return e; } return NewEntity(); @@ -211,36 +211,36 @@ public: static int UpdateOne( Database& db, - CharCreatePointAllocations char_create_point_allocations_entry + const CharCreatePointAllocations &e ) { - std::vector update_values; + std::vector v; auto columns = Columns(); - update_values.push_back(columns[0] + " = " + std::to_string(char_create_point_allocations_entry.id)); - update_values.push_back(columns[1] + " = " + std::to_string(char_create_point_allocations_entry.base_str)); - update_values.push_back(columns[2] + " = " + std::to_string(char_create_point_allocations_entry.base_sta)); - update_values.push_back(columns[3] + " = " + std::to_string(char_create_point_allocations_entry.base_dex)); - update_values.push_back(columns[4] + " = " + std::to_string(char_create_point_allocations_entry.base_agi)); - update_values.push_back(columns[5] + " = " + std::to_string(char_create_point_allocations_entry.base_int)); - update_values.push_back(columns[6] + " = " + std::to_string(char_create_point_allocations_entry.base_wis)); - update_values.push_back(columns[7] + " = " + std::to_string(char_create_point_allocations_entry.base_cha)); - update_values.push_back(columns[8] + " = " + std::to_string(char_create_point_allocations_entry.alloc_str)); - update_values.push_back(columns[9] + " = " + std::to_string(char_create_point_allocations_entry.alloc_sta)); - update_values.push_back(columns[10] + " = " + std::to_string(char_create_point_allocations_entry.alloc_dex)); - update_values.push_back(columns[11] + " = " + std::to_string(char_create_point_allocations_entry.alloc_agi)); - update_values.push_back(columns[12] + " = " + std::to_string(char_create_point_allocations_entry.alloc_int)); - update_values.push_back(columns[13] + " = " + std::to_string(char_create_point_allocations_entry.alloc_wis)); - update_values.push_back(columns[14] + " = " + std::to_string(char_create_point_allocations_entry.alloc_cha)); + v.push_back(columns[0] + " = " + std::to_string(e.id)); + v.push_back(columns[1] + " = " + std::to_string(e.base_str)); + v.push_back(columns[2] + " = " + std::to_string(e.base_sta)); + v.push_back(columns[3] + " = " + std::to_string(e.base_dex)); + v.push_back(columns[4] + " = " + std::to_string(e.base_agi)); + v.push_back(columns[5] + " = " + std::to_string(e.base_int)); + v.push_back(columns[6] + " = " + std::to_string(e.base_wis)); + v.push_back(columns[7] + " = " + std::to_string(e.base_cha)); + v.push_back(columns[8] + " = " + std::to_string(e.alloc_str)); + v.push_back(columns[9] + " = " + std::to_string(e.alloc_sta)); + v.push_back(columns[10] + " = " + std::to_string(e.alloc_dex)); + v.push_back(columns[11] + " = " + std::to_string(e.alloc_agi)); + v.push_back(columns[12] + " = " + std::to_string(e.alloc_int)); + v.push_back(columns[13] + " = " + std::to_string(e.alloc_wis)); + v.push_back(columns[14] + " = " + std::to_string(e.alloc_cha)); auto results = db.QueryDatabase( fmt::format( "UPDATE {} SET {} WHERE {} = {}", TableName(), - Strings::Implode(", ", update_values), + Strings::Implode(", ", v), PrimaryKey(), - char_create_point_allocations_entry.id + e.id ) ); @@ -249,75 +249,75 @@ public: static CharCreatePointAllocations InsertOne( Database& db, - CharCreatePointAllocations char_create_point_allocations_entry + CharCreatePointAllocations e ) { - std::vector insert_values; + std::vector v; - insert_values.push_back(std::to_string(char_create_point_allocations_entry.id)); - insert_values.push_back(std::to_string(char_create_point_allocations_entry.base_str)); - insert_values.push_back(std::to_string(char_create_point_allocations_entry.base_sta)); - insert_values.push_back(std::to_string(char_create_point_allocations_entry.base_dex)); - insert_values.push_back(std::to_string(char_create_point_allocations_entry.base_agi)); - insert_values.push_back(std::to_string(char_create_point_allocations_entry.base_int)); - insert_values.push_back(std::to_string(char_create_point_allocations_entry.base_wis)); - insert_values.push_back(std::to_string(char_create_point_allocations_entry.base_cha)); - insert_values.push_back(std::to_string(char_create_point_allocations_entry.alloc_str)); - insert_values.push_back(std::to_string(char_create_point_allocations_entry.alloc_sta)); - insert_values.push_back(std::to_string(char_create_point_allocations_entry.alloc_dex)); - insert_values.push_back(std::to_string(char_create_point_allocations_entry.alloc_agi)); - insert_values.push_back(std::to_string(char_create_point_allocations_entry.alloc_int)); - insert_values.push_back(std::to_string(char_create_point_allocations_entry.alloc_wis)); - insert_values.push_back(std::to_string(char_create_point_allocations_entry.alloc_cha)); + v.push_back(std::to_string(e.id)); + v.push_back(std::to_string(e.base_str)); + v.push_back(std::to_string(e.base_sta)); + v.push_back(std::to_string(e.base_dex)); + v.push_back(std::to_string(e.base_agi)); + v.push_back(std::to_string(e.base_int)); + v.push_back(std::to_string(e.base_wis)); + v.push_back(std::to_string(e.base_cha)); + v.push_back(std::to_string(e.alloc_str)); + v.push_back(std::to_string(e.alloc_sta)); + v.push_back(std::to_string(e.alloc_dex)); + v.push_back(std::to_string(e.alloc_agi)); + v.push_back(std::to_string(e.alloc_int)); + v.push_back(std::to_string(e.alloc_wis)); + v.push_back(std::to_string(e.alloc_cha)); auto results = db.QueryDatabase( fmt::format( "{} VALUES ({})", BaseInsert(), - Strings::Implode(",", insert_values) + Strings::Implode(",", v) ) ); if (results.Success()) { - char_create_point_allocations_entry.id = results.LastInsertedID(); - return char_create_point_allocations_entry; + e.id = results.LastInsertedID(); + return e; } - char_create_point_allocations_entry = NewEntity(); + e = NewEntity(); - return char_create_point_allocations_entry; + return e; } static int InsertMany( Database& db, - std::vector char_create_point_allocations_entries + const std::vector &entries ) { std::vector insert_chunks; - for (auto &char_create_point_allocations_entry: char_create_point_allocations_entries) { - std::vector insert_values; + for (auto &e: entries) { + std::vector v; - insert_values.push_back(std::to_string(char_create_point_allocations_entry.id)); - insert_values.push_back(std::to_string(char_create_point_allocations_entry.base_str)); - insert_values.push_back(std::to_string(char_create_point_allocations_entry.base_sta)); - insert_values.push_back(std::to_string(char_create_point_allocations_entry.base_dex)); - insert_values.push_back(std::to_string(char_create_point_allocations_entry.base_agi)); - insert_values.push_back(std::to_string(char_create_point_allocations_entry.base_int)); - insert_values.push_back(std::to_string(char_create_point_allocations_entry.base_wis)); - insert_values.push_back(std::to_string(char_create_point_allocations_entry.base_cha)); - insert_values.push_back(std::to_string(char_create_point_allocations_entry.alloc_str)); - insert_values.push_back(std::to_string(char_create_point_allocations_entry.alloc_sta)); - insert_values.push_back(std::to_string(char_create_point_allocations_entry.alloc_dex)); - insert_values.push_back(std::to_string(char_create_point_allocations_entry.alloc_agi)); - insert_values.push_back(std::to_string(char_create_point_allocations_entry.alloc_int)); - insert_values.push_back(std::to_string(char_create_point_allocations_entry.alloc_wis)); - insert_values.push_back(std::to_string(char_create_point_allocations_entry.alloc_cha)); + v.push_back(std::to_string(e.id)); + v.push_back(std::to_string(e.base_str)); + v.push_back(std::to_string(e.base_sta)); + v.push_back(std::to_string(e.base_dex)); + v.push_back(std::to_string(e.base_agi)); + v.push_back(std::to_string(e.base_int)); + v.push_back(std::to_string(e.base_wis)); + v.push_back(std::to_string(e.base_cha)); + v.push_back(std::to_string(e.alloc_str)); + v.push_back(std::to_string(e.alloc_sta)); + v.push_back(std::to_string(e.alloc_dex)); + v.push_back(std::to_string(e.alloc_agi)); + v.push_back(std::to_string(e.alloc_int)); + v.push_back(std::to_string(e.alloc_wis)); + v.push_back(std::to_string(e.alloc_cha)); - insert_chunks.push_back("(" + Strings::Implode(",", insert_values) + ")"); + insert_chunks.push_back("(" + Strings::Implode(",", v) + ")"); } - std::vector insert_values; + std::vector v; auto results = db.QueryDatabase( fmt::format( @@ -344,31 +344,31 @@ public: all_entries.reserve(results.RowCount()); for (auto row = results.begin(); row != results.end(); ++row) { - CharCreatePointAllocations entry{}; + CharCreatePointAllocations e{}; - entry.id = atoi(row[0]); - entry.base_str = atoi(row[1]); - entry.base_sta = atoi(row[2]); - entry.base_dex = atoi(row[3]); - entry.base_agi = atoi(row[4]); - entry.base_int = atoi(row[5]); - entry.base_wis = atoi(row[6]); - entry.base_cha = atoi(row[7]); - entry.alloc_str = atoi(row[8]); - entry.alloc_sta = atoi(row[9]); - entry.alloc_dex = atoi(row[10]); - entry.alloc_agi = atoi(row[11]); - entry.alloc_int = atoi(row[12]); - entry.alloc_wis = atoi(row[13]); - entry.alloc_cha = atoi(row[14]); + e.id = atoi(row[0]); + e.base_str = atoi(row[1]); + e.base_sta = atoi(row[2]); + e.base_dex = atoi(row[3]); + e.base_agi = atoi(row[4]); + e.base_int = atoi(row[5]); + e.base_wis = atoi(row[6]); + e.base_cha = atoi(row[7]); + e.alloc_str = atoi(row[8]); + e.alloc_sta = atoi(row[9]); + e.alloc_dex = atoi(row[10]); + e.alloc_agi = atoi(row[11]); + e.alloc_int = atoi(row[12]); + e.alloc_wis = atoi(row[13]); + e.alloc_cha = atoi(row[14]); - all_entries.push_back(entry); + all_entries.push_back(e); } return all_entries; } - static std::vector GetWhere(Database& db, std::string where_filter) + static std::vector GetWhere(Database& db, const std::string &where_filter) { std::vector all_entries; @@ -383,31 +383,31 @@ public: all_entries.reserve(results.RowCount()); for (auto row = results.begin(); row != results.end(); ++row) { - CharCreatePointAllocations entry{}; + CharCreatePointAllocations e{}; - entry.id = atoi(row[0]); - entry.base_str = atoi(row[1]); - entry.base_sta = atoi(row[2]); - entry.base_dex = atoi(row[3]); - entry.base_agi = atoi(row[4]); - entry.base_int = atoi(row[5]); - entry.base_wis = atoi(row[6]); - entry.base_cha = atoi(row[7]); - entry.alloc_str = atoi(row[8]); - entry.alloc_sta = atoi(row[9]); - entry.alloc_dex = atoi(row[10]); - entry.alloc_agi = atoi(row[11]); - entry.alloc_int = atoi(row[12]); - entry.alloc_wis = atoi(row[13]); - entry.alloc_cha = atoi(row[14]); + e.id = atoi(row[0]); + e.base_str = atoi(row[1]); + e.base_sta = atoi(row[2]); + e.base_dex = atoi(row[3]); + e.base_agi = atoi(row[4]); + e.base_int = atoi(row[5]); + e.base_wis = atoi(row[6]); + e.base_cha = atoi(row[7]); + e.alloc_str = atoi(row[8]); + e.alloc_sta = atoi(row[9]); + e.alloc_dex = atoi(row[10]); + e.alloc_agi = atoi(row[11]); + e.alloc_int = atoi(row[12]); + e.alloc_wis = atoi(row[13]); + e.alloc_cha = atoi(row[14]); - all_entries.push_back(entry); + all_entries.push_back(e); } return all_entries; } - static int DeleteWhere(Database& db, std::string where_filter) + static int DeleteWhere(Database& db, const std::string &where_filter) { auto results = db.QueryDatabase( fmt::format( @@ -432,6 +432,32 @@ public: 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); + } + }; #endif //EQEMU_BASE_CHAR_CREATE_POINT_ALLOCATIONS_REPOSITORY_H diff --git a/common/repositories/base/base_char_recipe_list_repository.h b/common/repositories/base/base_char_recipe_list_repository.h index a77ed2e94..2d23d2101 100644 --- a/common/repositories/base/base_char_recipe_list_repository.h +++ b/common/repositories/base/base_char_recipe_list_repository.h @@ -82,16 +82,16 @@ public: static CharRecipeList NewEntity() { - CharRecipeList entry{}; + CharRecipeList e{}; - entry.char_id = 0; - entry.recipe_id = 0; - entry.madecount = 0; + e.char_id = 0; + e.recipe_id = 0; + e.madecount = 0; - return entry; + return e; } - static CharRecipeList GetCharRecipeListEntry( + static CharRecipeList GetCharRecipeList( const std::vector &char_recipe_lists, int char_recipe_list_id ) @@ -120,13 +120,13 @@ public: auto row = results.begin(); if (results.RowCount() == 1) { - CharRecipeList entry{}; + CharRecipeList e{}; - entry.char_id = atoi(row[0]); - entry.recipe_id = atoi(row[1]); - entry.madecount = atoi(row[2]); + e.char_id = atoi(row[0]); + e.recipe_id = atoi(row[1]); + e.madecount = atoi(row[2]); - return entry; + return e; } return NewEntity(); @@ -151,24 +151,24 @@ public: static int UpdateOne( Database& db, - CharRecipeList char_recipe_list_entry + const CharRecipeList &e ) { - std::vector update_values; + std::vector v; auto columns = Columns(); - update_values.push_back(columns[0] + " = " + std::to_string(char_recipe_list_entry.char_id)); - update_values.push_back(columns[1] + " = " + std::to_string(char_recipe_list_entry.recipe_id)); - update_values.push_back(columns[2] + " = " + std::to_string(char_recipe_list_entry.madecount)); + v.push_back(columns[0] + " = " + std::to_string(e.char_id)); + v.push_back(columns[1] + " = " + std::to_string(e.recipe_id)); + v.push_back(columns[2] + " = " + std::to_string(e.madecount)); auto results = db.QueryDatabase( fmt::format( "UPDATE {} SET {} WHERE {} = {}", TableName(), - Strings::Implode(", ", update_values), + Strings::Implode(", ", v), PrimaryKey(), - char_recipe_list_entry.char_id + e.char_id ) ); @@ -177,51 +177,51 @@ public: static CharRecipeList InsertOne( Database& db, - CharRecipeList char_recipe_list_entry + CharRecipeList e ) { - std::vector insert_values; + std::vector v; - insert_values.push_back(std::to_string(char_recipe_list_entry.char_id)); - insert_values.push_back(std::to_string(char_recipe_list_entry.recipe_id)); - insert_values.push_back(std::to_string(char_recipe_list_entry.madecount)); + v.push_back(std::to_string(e.char_id)); + v.push_back(std::to_string(e.recipe_id)); + v.push_back(std::to_string(e.madecount)); auto results = db.QueryDatabase( fmt::format( "{} VALUES ({})", BaseInsert(), - Strings::Implode(",", insert_values) + Strings::Implode(",", v) ) ); if (results.Success()) { - char_recipe_list_entry.char_id = results.LastInsertedID(); - return char_recipe_list_entry; + e.char_id = results.LastInsertedID(); + return e; } - char_recipe_list_entry = NewEntity(); + e = NewEntity(); - return char_recipe_list_entry; + return e; } static int InsertMany( Database& db, - std::vector char_recipe_list_entries + const std::vector &entries ) { std::vector insert_chunks; - for (auto &char_recipe_list_entry: char_recipe_list_entries) { - std::vector insert_values; + for (auto &e: entries) { + std::vector v; - insert_values.push_back(std::to_string(char_recipe_list_entry.char_id)); - insert_values.push_back(std::to_string(char_recipe_list_entry.recipe_id)); - insert_values.push_back(std::to_string(char_recipe_list_entry.madecount)); + v.push_back(std::to_string(e.char_id)); + v.push_back(std::to_string(e.recipe_id)); + v.push_back(std::to_string(e.madecount)); - insert_chunks.push_back("(" + Strings::Implode(",", insert_values) + ")"); + insert_chunks.push_back("(" + Strings::Implode(",", v) + ")"); } - std::vector insert_values; + std::vector v; auto results = db.QueryDatabase( fmt::format( @@ -248,19 +248,19 @@ public: all_entries.reserve(results.RowCount()); for (auto row = results.begin(); row != results.end(); ++row) { - CharRecipeList entry{}; + CharRecipeList e{}; - entry.char_id = atoi(row[0]); - entry.recipe_id = atoi(row[1]); - entry.madecount = atoi(row[2]); + e.char_id = atoi(row[0]); + e.recipe_id = atoi(row[1]); + e.madecount = atoi(row[2]); - all_entries.push_back(entry); + all_entries.push_back(e); } return all_entries; } - static std::vector GetWhere(Database& db, std::string where_filter) + static std::vector GetWhere(Database& db, const std::string &where_filter) { std::vector all_entries; @@ -275,19 +275,19 @@ public: all_entries.reserve(results.RowCount()); for (auto row = results.begin(); row != results.end(); ++row) { - CharRecipeList entry{}; + CharRecipeList e{}; - entry.char_id = atoi(row[0]); - entry.recipe_id = atoi(row[1]); - entry.madecount = atoi(row[2]); + e.char_id = atoi(row[0]); + e.recipe_id = atoi(row[1]); + e.madecount = atoi(row[2]); - all_entries.push_back(entry); + all_entries.push_back(e); } return all_entries; } - static int DeleteWhere(Database& db, std::string where_filter) + static int DeleteWhere(Database& db, const std::string &where_filter) { auto results = db.QueryDatabase( fmt::format( @@ -312,6 +312,32 @@ public: 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); + } + }; #endif //EQEMU_BASE_CHAR_RECIPE_LIST_REPOSITORY_H diff --git a/common/repositories/base/base_character_activities_repository.h b/common/repositories/base/base_character_activities_repository.h index 758047cfa..20733d6b5 100644 --- a/common/repositories/base/base_character_activities_repository.h +++ b/common/repositories/base/base_character_activities_repository.h @@ -88,18 +88,18 @@ public: static CharacterActivities NewEntity() { - CharacterActivities entry{}; + CharacterActivities e{}; - entry.charid = 0; - entry.taskid = 0; - entry.activityid = 0; - entry.donecount = 0; - entry.completed = 0; + e.charid = 0; + e.taskid = 0; + e.activityid = 0; + e.donecount = 0; + e.completed = 0; - return entry; + return e; } - static CharacterActivities GetCharacterActivitiesEntry( + static CharacterActivities GetCharacterActivities( const std::vector &character_activitiess, int character_activities_id ) @@ -128,15 +128,15 @@ public: auto row = results.begin(); if (results.RowCount() == 1) { - CharacterActivities entry{}; + CharacterActivities e{}; - entry.charid = atoi(row[0]); - entry.taskid = atoi(row[1]); - entry.activityid = atoi(row[2]); - entry.donecount = atoi(row[3]); - entry.completed = atoi(row[4]); + e.charid = atoi(row[0]); + e.taskid = atoi(row[1]); + e.activityid = atoi(row[2]); + e.donecount = atoi(row[3]); + e.completed = atoi(row[4]); - return entry; + return e; } return NewEntity(); @@ -161,26 +161,26 @@ public: static int UpdateOne( Database& db, - CharacterActivities character_activities_entry + const CharacterActivities &e ) { - std::vector update_values; + std::vector v; auto columns = Columns(); - update_values.push_back(columns[0] + " = " + std::to_string(character_activities_entry.charid)); - update_values.push_back(columns[1] + " = " + std::to_string(character_activities_entry.taskid)); - update_values.push_back(columns[2] + " = " + std::to_string(character_activities_entry.activityid)); - update_values.push_back(columns[3] + " = " + std::to_string(character_activities_entry.donecount)); - update_values.push_back(columns[4] + " = " + std::to_string(character_activities_entry.completed)); + v.push_back(columns[0] + " = " + std::to_string(e.charid)); + v.push_back(columns[1] + " = " + std::to_string(e.taskid)); + v.push_back(columns[2] + " = " + std::to_string(e.activityid)); + v.push_back(columns[3] + " = " + std::to_string(e.donecount)); + v.push_back(columns[4] + " = " + std::to_string(e.completed)); auto results = db.QueryDatabase( fmt::format( "UPDATE {} SET {} WHERE {} = {}", TableName(), - Strings::Implode(", ", update_values), + Strings::Implode(", ", v), PrimaryKey(), - character_activities_entry.charid + e.charid ) ); @@ -189,55 +189,55 @@ public: static CharacterActivities InsertOne( Database& db, - CharacterActivities character_activities_entry + CharacterActivities e ) { - std::vector insert_values; + std::vector v; - insert_values.push_back(std::to_string(character_activities_entry.charid)); - insert_values.push_back(std::to_string(character_activities_entry.taskid)); - insert_values.push_back(std::to_string(character_activities_entry.activityid)); - insert_values.push_back(std::to_string(character_activities_entry.donecount)); - insert_values.push_back(std::to_string(character_activities_entry.completed)); + v.push_back(std::to_string(e.charid)); + v.push_back(std::to_string(e.taskid)); + v.push_back(std::to_string(e.activityid)); + v.push_back(std::to_string(e.donecount)); + v.push_back(std::to_string(e.completed)); auto results = db.QueryDatabase( fmt::format( "{} VALUES ({})", BaseInsert(), - Strings::Implode(",", insert_values) + Strings::Implode(",", v) ) ); if (results.Success()) { - character_activities_entry.charid = results.LastInsertedID(); - return character_activities_entry; + e.charid = results.LastInsertedID(); + return e; } - character_activities_entry = NewEntity(); + e = NewEntity(); - return character_activities_entry; + return e; } static int InsertMany( Database& db, - std::vector character_activities_entries + const std::vector &entries ) { std::vector insert_chunks; - for (auto &character_activities_entry: character_activities_entries) { - std::vector insert_values; + for (auto &e: entries) { + std::vector v; - insert_values.push_back(std::to_string(character_activities_entry.charid)); - insert_values.push_back(std::to_string(character_activities_entry.taskid)); - insert_values.push_back(std::to_string(character_activities_entry.activityid)); - insert_values.push_back(std::to_string(character_activities_entry.donecount)); - insert_values.push_back(std::to_string(character_activities_entry.completed)); + v.push_back(std::to_string(e.charid)); + v.push_back(std::to_string(e.taskid)); + v.push_back(std::to_string(e.activityid)); + v.push_back(std::to_string(e.donecount)); + v.push_back(std::to_string(e.completed)); - insert_chunks.push_back("(" + Strings::Implode(",", insert_values) + ")"); + insert_chunks.push_back("(" + Strings::Implode(",", v) + ")"); } - std::vector insert_values; + std::vector v; auto results = db.QueryDatabase( fmt::format( @@ -264,21 +264,21 @@ public: all_entries.reserve(results.RowCount()); for (auto row = results.begin(); row != results.end(); ++row) { - CharacterActivities entry{}; + CharacterActivities e{}; - entry.charid = atoi(row[0]); - entry.taskid = atoi(row[1]); - entry.activityid = atoi(row[2]); - entry.donecount = atoi(row[3]); - entry.completed = atoi(row[4]); + e.charid = atoi(row[0]); + e.taskid = atoi(row[1]); + e.activityid = atoi(row[2]); + e.donecount = atoi(row[3]); + e.completed = atoi(row[4]); - all_entries.push_back(entry); + all_entries.push_back(e); } return all_entries; } - static std::vector GetWhere(Database& db, std::string where_filter) + static std::vector GetWhere(Database& db, const std::string &where_filter) { std::vector all_entries; @@ -293,21 +293,21 @@ public: all_entries.reserve(results.RowCount()); for (auto row = results.begin(); row != results.end(); ++row) { - CharacterActivities entry{}; + CharacterActivities e{}; - entry.charid = atoi(row[0]); - entry.taskid = atoi(row[1]); - entry.activityid = atoi(row[2]); - entry.donecount = atoi(row[3]); - entry.completed = atoi(row[4]); + e.charid = atoi(row[0]); + e.taskid = atoi(row[1]); + e.activityid = atoi(row[2]); + e.donecount = atoi(row[3]); + e.completed = atoi(row[4]); - all_entries.push_back(entry); + all_entries.push_back(e); } return all_entries; } - static int DeleteWhere(Database& db, std::string where_filter) + static int DeleteWhere(Database& db, const std::string &where_filter) { auto results = db.QueryDatabase( fmt::format( @@ -332,6 +332,32 @@ public: 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); + } + }; #endif //EQEMU_BASE_CHARACTER_ACTIVITIES_REPOSITORY_H diff --git a/common/repositories/base/base_character_alt_currency_repository.h b/common/repositories/base/base_character_alt_currency_repository.h index d7eef3608..f0c1f036c 100644 --- a/common/repositories/base/base_character_alt_currency_repository.h +++ b/common/repositories/base/base_character_alt_currency_repository.h @@ -82,16 +82,16 @@ public: static CharacterAltCurrency NewEntity() { - CharacterAltCurrency entry{}; + CharacterAltCurrency e{}; - entry.char_id = 0; - entry.currency_id = 0; - entry.amount = 0; + e.char_id = 0; + e.currency_id = 0; + e.amount = 0; - return entry; + return e; } - static CharacterAltCurrency GetCharacterAltCurrencyEntry( + static CharacterAltCurrency GetCharacterAltCurrency( const std::vector &character_alt_currencys, int character_alt_currency_id ) @@ -120,13 +120,13 @@ public: auto row = results.begin(); if (results.RowCount() == 1) { - CharacterAltCurrency entry{}; + CharacterAltCurrency e{}; - entry.char_id = atoi(row[0]); - entry.currency_id = atoi(row[1]); - entry.amount = atoi(row[2]); + e.char_id = atoi(row[0]); + e.currency_id = atoi(row[1]); + e.amount = atoi(row[2]); - return entry; + return e; } return NewEntity(); @@ -151,24 +151,24 @@ public: static int UpdateOne( Database& db, - CharacterAltCurrency character_alt_currency_entry + const CharacterAltCurrency &e ) { - std::vector update_values; + std::vector v; auto columns = Columns(); - update_values.push_back(columns[0] + " = " + std::to_string(character_alt_currency_entry.char_id)); - update_values.push_back(columns[1] + " = " + std::to_string(character_alt_currency_entry.currency_id)); - update_values.push_back(columns[2] + " = " + std::to_string(character_alt_currency_entry.amount)); + v.push_back(columns[0] + " = " + std::to_string(e.char_id)); + v.push_back(columns[1] + " = " + std::to_string(e.currency_id)); + v.push_back(columns[2] + " = " + std::to_string(e.amount)); auto results = db.QueryDatabase( fmt::format( "UPDATE {} SET {} WHERE {} = {}", TableName(), - Strings::Implode(", ", update_values), + Strings::Implode(", ", v), PrimaryKey(), - character_alt_currency_entry.char_id + e.char_id ) ); @@ -177,51 +177,51 @@ public: static CharacterAltCurrency InsertOne( Database& db, - CharacterAltCurrency character_alt_currency_entry + CharacterAltCurrency e ) { - std::vector insert_values; + std::vector v; - insert_values.push_back(std::to_string(character_alt_currency_entry.char_id)); - insert_values.push_back(std::to_string(character_alt_currency_entry.currency_id)); - insert_values.push_back(std::to_string(character_alt_currency_entry.amount)); + v.push_back(std::to_string(e.char_id)); + v.push_back(std::to_string(e.currency_id)); + v.push_back(std::to_string(e.amount)); auto results = db.QueryDatabase( fmt::format( "{} VALUES ({})", BaseInsert(), - Strings::Implode(",", insert_values) + Strings::Implode(",", v) ) ); if (results.Success()) { - character_alt_currency_entry.char_id = results.LastInsertedID(); - return character_alt_currency_entry; + e.char_id = results.LastInsertedID(); + return e; } - character_alt_currency_entry = NewEntity(); + e = NewEntity(); - return character_alt_currency_entry; + return e; } static int InsertMany( Database& db, - std::vector character_alt_currency_entries + const std::vector &entries ) { std::vector insert_chunks; - for (auto &character_alt_currency_entry: character_alt_currency_entries) { - std::vector insert_values; + for (auto &e: entries) { + std::vector v; - insert_values.push_back(std::to_string(character_alt_currency_entry.char_id)); - insert_values.push_back(std::to_string(character_alt_currency_entry.currency_id)); - insert_values.push_back(std::to_string(character_alt_currency_entry.amount)); + v.push_back(std::to_string(e.char_id)); + v.push_back(std::to_string(e.currency_id)); + v.push_back(std::to_string(e.amount)); - insert_chunks.push_back("(" + Strings::Implode(",", insert_values) + ")"); + insert_chunks.push_back("(" + Strings::Implode(",", v) + ")"); } - std::vector insert_values; + std::vector v; auto results = db.QueryDatabase( fmt::format( @@ -248,19 +248,19 @@ public: all_entries.reserve(results.RowCount()); for (auto row = results.begin(); row != results.end(); ++row) { - CharacterAltCurrency entry{}; + CharacterAltCurrency e{}; - entry.char_id = atoi(row[0]); - entry.currency_id = atoi(row[1]); - entry.amount = atoi(row[2]); + e.char_id = atoi(row[0]); + e.currency_id = atoi(row[1]); + e.amount = atoi(row[2]); - all_entries.push_back(entry); + all_entries.push_back(e); } return all_entries; } - static std::vector GetWhere(Database& db, std::string where_filter) + static std::vector GetWhere(Database& db, const std::string &where_filter) { std::vector all_entries; @@ -275,19 +275,19 @@ public: all_entries.reserve(results.RowCount()); for (auto row = results.begin(); row != results.end(); ++row) { - CharacterAltCurrency entry{}; + CharacterAltCurrency e{}; - entry.char_id = atoi(row[0]); - entry.currency_id = atoi(row[1]); - entry.amount = atoi(row[2]); + e.char_id = atoi(row[0]); + e.currency_id = atoi(row[1]); + e.amount = atoi(row[2]); - all_entries.push_back(entry); + all_entries.push_back(e); } return all_entries; } - static int DeleteWhere(Database& db, std::string where_filter) + static int DeleteWhere(Database& db, const std::string &where_filter) { auto results = db.QueryDatabase( fmt::format( @@ -312,6 +312,32 @@ public: 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); + } + }; #endif //EQEMU_BASE_CHARACTER_ALT_CURRENCY_REPOSITORY_H diff --git a/common/repositories/base/base_character_alternate_abilities_repository.h b/common/repositories/base/base_character_alternate_abilities_repository.h index 9e97ee405..5499c1ecf 100644 --- a/common/repositories/base/base_character_alternate_abilities_repository.h +++ b/common/repositories/base/base_character_alternate_abilities_repository.h @@ -85,17 +85,17 @@ public: static CharacterAlternateAbilities NewEntity() { - CharacterAlternateAbilities entry{}; + CharacterAlternateAbilities e{}; - entry.id = 0; - entry.aa_id = 0; - entry.aa_value = 0; - entry.charges = 0; + e.id = 0; + e.aa_id = 0; + e.aa_value = 0; + e.charges = 0; - return entry; + return e; } - static CharacterAlternateAbilities GetCharacterAlternateAbilitiesEntry( + static CharacterAlternateAbilities GetCharacterAlternateAbilities( const std::vector &character_alternate_abilitiess, int character_alternate_abilities_id ) @@ -124,14 +124,14 @@ public: auto row = results.begin(); if (results.RowCount() == 1) { - CharacterAlternateAbilities entry{}; + CharacterAlternateAbilities e{}; - entry.id = atoi(row[0]); - entry.aa_id = atoi(row[1]); - entry.aa_value = atoi(row[2]); - entry.charges = atoi(row[3]); + e.id = atoi(row[0]); + e.aa_id = atoi(row[1]); + e.aa_value = atoi(row[2]); + e.charges = atoi(row[3]); - return entry; + return e; } return NewEntity(); @@ -156,25 +156,25 @@ public: static int UpdateOne( Database& db, - CharacterAlternateAbilities character_alternate_abilities_entry + const CharacterAlternateAbilities &e ) { - std::vector update_values; + std::vector v; auto columns = Columns(); - update_values.push_back(columns[0] + " = " + std::to_string(character_alternate_abilities_entry.id)); - update_values.push_back(columns[1] + " = " + std::to_string(character_alternate_abilities_entry.aa_id)); - update_values.push_back(columns[2] + " = " + std::to_string(character_alternate_abilities_entry.aa_value)); - update_values.push_back(columns[3] + " = " + std::to_string(character_alternate_abilities_entry.charges)); + v.push_back(columns[0] + " = " + std::to_string(e.id)); + v.push_back(columns[1] + " = " + std::to_string(e.aa_id)); + v.push_back(columns[2] + " = " + std::to_string(e.aa_value)); + v.push_back(columns[3] + " = " + std::to_string(e.charges)); auto results = db.QueryDatabase( fmt::format( "UPDATE {} SET {} WHERE {} = {}", TableName(), - Strings::Implode(", ", update_values), + Strings::Implode(", ", v), PrimaryKey(), - character_alternate_abilities_entry.id + e.id ) ); @@ -183,53 +183,53 @@ public: static CharacterAlternateAbilities InsertOne( Database& db, - CharacterAlternateAbilities character_alternate_abilities_entry + CharacterAlternateAbilities e ) { - std::vector insert_values; + std::vector v; - insert_values.push_back(std::to_string(character_alternate_abilities_entry.id)); - insert_values.push_back(std::to_string(character_alternate_abilities_entry.aa_id)); - insert_values.push_back(std::to_string(character_alternate_abilities_entry.aa_value)); - insert_values.push_back(std::to_string(character_alternate_abilities_entry.charges)); + v.push_back(std::to_string(e.id)); + v.push_back(std::to_string(e.aa_id)); + v.push_back(std::to_string(e.aa_value)); + v.push_back(std::to_string(e.charges)); auto results = db.QueryDatabase( fmt::format( "{} VALUES ({})", BaseInsert(), - Strings::Implode(",", insert_values) + Strings::Implode(",", v) ) ); if (results.Success()) { - character_alternate_abilities_entry.id = results.LastInsertedID(); - return character_alternate_abilities_entry; + e.id = results.LastInsertedID(); + return e; } - character_alternate_abilities_entry = NewEntity(); + e = NewEntity(); - return character_alternate_abilities_entry; + return e; } static int InsertMany( Database& db, - std::vector character_alternate_abilities_entries + const std::vector &entries ) { std::vector insert_chunks; - for (auto &character_alternate_abilities_entry: character_alternate_abilities_entries) { - std::vector insert_values; + for (auto &e: entries) { + std::vector v; - insert_values.push_back(std::to_string(character_alternate_abilities_entry.id)); - insert_values.push_back(std::to_string(character_alternate_abilities_entry.aa_id)); - insert_values.push_back(std::to_string(character_alternate_abilities_entry.aa_value)); - insert_values.push_back(std::to_string(character_alternate_abilities_entry.charges)); + v.push_back(std::to_string(e.id)); + v.push_back(std::to_string(e.aa_id)); + v.push_back(std::to_string(e.aa_value)); + v.push_back(std::to_string(e.charges)); - insert_chunks.push_back("(" + Strings::Implode(",", insert_values) + ")"); + insert_chunks.push_back("(" + Strings::Implode(",", v) + ")"); } - std::vector insert_values; + std::vector v; auto results = db.QueryDatabase( fmt::format( @@ -256,20 +256,20 @@ public: all_entries.reserve(results.RowCount()); for (auto row = results.begin(); row != results.end(); ++row) { - CharacterAlternateAbilities entry{}; + CharacterAlternateAbilities e{}; - entry.id = atoi(row[0]); - entry.aa_id = atoi(row[1]); - entry.aa_value = atoi(row[2]); - entry.charges = atoi(row[3]); + e.id = atoi(row[0]); + e.aa_id = atoi(row[1]); + e.aa_value = atoi(row[2]); + e.charges = atoi(row[3]); - all_entries.push_back(entry); + all_entries.push_back(e); } return all_entries; } - static std::vector GetWhere(Database& db, std::string where_filter) + static std::vector GetWhere(Database& db, const std::string &where_filter) { std::vector all_entries; @@ -284,20 +284,20 @@ public: all_entries.reserve(results.RowCount()); for (auto row = results.begin(); row != results.end(); ++row) { - CharacterAlternateAbilities entry{}; + CharacterAlternateAbilities e{}; - entry.id = atoi(row[0]); - entry.aa_id = atoi(row[1]); - entry.aa_value = atoi(row[2]); - entry.charges = atoi(row[3]); + e.id = atoi(row[0]); + e.aa_id = atoi(row[1]); + e.aa_value = atoi(row[2]); + e.charges = atoi(row[3]); - all_entries.push_back(entry); + all_entries.push_back(e); } return all_entries; } - static int DeleteWhere(Database& db, std::string where_filter) + static int DeleteWhere(Database& db, const std::string &where_filter) { auto results = db.QueryDatabase( fmt::format( @@ -322,6 +322,32 @@ public: 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); + } + }; #endif //EQEMU_BASE_CHARACTER_ALTERNATE_ABILITIES_REPOSITORY_H diff --git a/common/repositories/base/base_character_auras_repository.h b/common/repositories/base/base_character_auras_repository.h index 15a48c35a..1092713e8 100644 --- a/common/repositories/base/base_character_auras_repository.h +++ b/common/repositories/base/base_character_auras_repository.h @@ -82,16 +82,16 @@ public: static CharacterAuras NewEntity() { - CharacterAuras entry{}; + CharacterAuras e{}; - entry.id = 0; - entry.slot = 0; - entry.spell_id = 0; + e.id = 0; + e.slot = 0; + e.spell_id = 0; - return entry; + return e; } - static CharacterAuras GetCharacterAurasEntry( + static CharacterAuras GetCharacterAuras( const std::vector &character_aurass, int character_auras_id ) @@ -120,13 +120,13 @@ public: auto row = results.begin(); if (results.RowCount() == 1) { - CharacterAuras entry{}; + CharacterAuras e{}; - entry.id = atoi(row[0]); - entry.slot = atoi(row[1]); - entry.spell_id = atoi(row[2]); + e.id = atoi(row[0]); + e.slot = atoi(row[1]); + e.spell_id = atoi(row[2]); - return entry; + return e; } return NewEntity(); @@ -151,24 +151,24 @@ public: static int UpdateOne( Database& db, - CharacterAuras character_auras_entry + const CharacterAuras &e ) { - std::vector update_values; + std::vector v; auto columns = Columns(); - update_values.push_back(columns[0] + " = " + std::to_string(character_auras_entry.id)); - update_values.push_back(columns[1] + " = " + std::to_string(character_auras_entry.slot)); - update_values.push_back(columns[2] + " = " + std::to_string(character_auras_entry.spell_id)); + v.push_back(columns[0] + " = " + std::to_string(e.id)); + v.push_back(columns[1] + " = " + std::to_string(e.slot)); + v.push_back(columns[2] + " = " + std::to_string(e.spell_id)); auto results = db.QueryDatabase( fmt::format( "UPDATE {} SET {} WHERE {} = {}", TableName(), - Strings::Implode(", ", update_values), + Strings::Implode(", ", v), PrimaryKey(), - character_auras_entry.id + e.id ) ); @@ -177,51 +177,51 @@ public: static CharacterAuras InsertOne( Database& db, - CharacterAuras character_auras_entry + CharacterAuras e ) { - std::vector insert_values; + std::vector v; - insert_values.push_back(std::to_string(character_auras_entry.id)); - insert_values.push_back(std::to_string(character_auras_entry.slot)); - insert_values.push_back(std::to_string(character_auras_entry.spell_id)); + v.push_back(std::to_string(e.id)); + v.push_back(std::to_string(e.slot)); + v.push_back(std::to_string(e.spell_id)); auto results = db.QueryDatabase( fmt::format( "{} VALUES ({})", BaseInsert(), - Strings::Implode(",", insert_values) + Strings::Implode(",", v) ) ); if (results.Success()) { - character_auras_entry.id = results.LastInsertedID(); - return character_auras_entry; + e.id = results.LastInsertedID(); + return e; } - character_auras_entry = NewEntity(); + e = NewEntity(); - return character_auras_entry; + return e; } static int InsertMany( Database& db, - std::vector character_auras_entries + const std::vector &entries ) { std::vector insert_chunks; - for (auto &character_auras_entry: character_auras_entries) { - std::vector insert_values; + for (auto &e: entries) { + std::vector v; - insert_values.push_back(std::to_string(character_auras_entry.id)); - insert_values.push_back(std::to_string(character_auras_entry.slot)); - insert_values.push_back(std::to_string(character_auras_entry.spell_id)); + v.push_back(std::to_string(e.id)); + v.push_back(std::to_string(e.slot)); + v.push_back(std::to_string(e.spell_id)); - insert_chunks.push_back("(" + Strings::Implode(",", insert_values) + ")"); + insert_chunks.push_back("(" + Strings::Implode(",", v) + ")"); } - std::vector insert_values; + std::vector v; auto results = db.QueryDatabase( fmt::format( @@ -248,19 +248,19 @@ public: all_entries.reserve(results.RowCount()); for (auto row = results.begin(); row != results.end(); ++row) { - CharacterAuras entry{}; + CharacterAuras e{}; - entry.id = atoi(row[0]); - entry.slot = atoi(row[1]); - entry.spell_id = atoi(row[2]); + e.id = atoi(row[0]); + e.slot = atoi(row[1]); + e.spell_id = atoi(row[2]); - all_entries.push_back(entry); + all_entries.push_back(e); } return all_entries; } - static std::vector GetWhere(Database& db, std::string where_filter) + static std::vector GetWhere(Database& db, const std::string &where_filter) { std::vector all_entries; @@ -275,19 +275,19 @@ public: all_entries.reserve(results.RowCount()); for (auto row = results.begin(); row != results.end(); ++row) { - CharacterAuras entry{}; + CharacterAuras e{}; - entry.id = atoi(row[0]); - entry.slot = atoi(row[1]); - entry.spell_id = atoi(row[2]); + e.id = atoi(row[0]); + e.slot = atoi(row[1]); + e.spell_id = atoi(row[2]); - all_entries.push_back(entry); + all_entries.push_back(e); } return all_entries; } - static int DeleteWhere(Database& db, std::string where_filter) + static int DeleteWhere(Database& db, const std::string &where_filter) { auto results = db.QueryDatabase( fmt::format( @@ -312,6 +312,32 @@ public: 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); + } + }; #endif //EQEMU_BASE_CHARACTER_AURAS_REPOSITORY_H diff --git a/common/repositories/base/base_character_bandolier_repository.h b/common/repositories/base/base_character_bandolier_repository.h index ff61d626c..fa5e2db5c 100644 --- a/common/repositories/base/base_character_bandolier_repository.h +++ b/common/repositories/base/base_character_bandolier_repository.h @@ -91,19 +91,19 @@ public: static CharacterBandolier NewEntity() { - CharacterBandolier entry{}; + CharacterBandolier e{}; - entry.id = 0; - entry.bandolier_id = 0; - entry.bandolier_slot = 0; - entry.item_id = 0; - entry.icon = 0; - entry.bandolier_name = "0"; + e.id = 0; + e.bandolier_id = 0; + e.bandolier_slot = 0; + e.item_id = 0; + e.icon = 0; + e.bandolier_name = "0"; - return entry; + return e; } - static CharacterBandolier GetCharacterBandolierEntry( + static CharacterBandolier GetCharacterBandolier( const std::vector &character_bandoliers, int character_bandolier_id ) @@ -132,16 +132,16 @@ public: auto row = results.begin(); if (results.RowCount() == 1) { - CharacterBandolier entry{}; + CharacterBandolier e{}; - entry.id = atoi(row[0]); - entry.bandolier_id = atoi(row[1]); - entry.bandolier_slot = atoi(row[2]); - entry.item_id = atoi(row[3]); - entry.icon = atoi(row[4]); - entry.bandolier_name = row[5] ? row[5] : ""; + e.id = atoi(row[0]); + e.bandolier_id = atoi(row[1]); + e.bandolier_slot = atoi(row[2]); + e.item_id = atoi(row[3]); + e.icon = atoi(row[4]); + e.bandolier_name = row[5] ? row[5] : ""; - return entry; + return e; } return NewEntity(); @@ -166,27 +166,27 @@ public: static int UpdateOne( Database& db, - CharacterBandolier character_bandolier_entry + const CharacterBandolier &e ) { - std::vector update_values; + std::vector v; auto columns = Columns(); - update_values.push_back(columns[0] + " = " + std::to_string(character_bandolier_entry.id)); - update_values.push_back(columns[1] + " = " + std::to_string(character_bandolier_entry.bandolier_id)); - update_values.push_back(columns[2] + " = " + std::to_string(character_bandolier_entry.bandolier_slot)); - update_values.push_back(columns[3] + " = " + std::to_string(character_bandolier_entry.item_id)); - update_values.push_back(columns[4] + " = " + std::to_string(character_bandolier_entry.icon)); - update_values.push_back(columns[5] + " = '" + Strings::Escape(character_bandolier_entry.bandolier_name) + "'"); + v.push_back(columns[0] + " = " + std::to_string(e.id)); + v.push_back(columns[1] + " = " + std::to_string(e.bandolier_id)); + v.push_back(columns[2] + " = " + std::to_string(e.bandolier_slot)); + v.push_back(columns[3] + " = " + std::to_string(e.item_id)); + v.push_back(columns[4] + " = " + std::to_string(e.icon)); + v.push_back(columns[5] + " = '" + Strings::Escape(e.bandolier_name) + "'"); auto results = db.QueryDatabase( fmt::format( "UPDATE {} SET {} WHERE {} = {}", TableName(), - Strings::Implode(", ", update_values), + Strings::Implode(", ", v), PrimaryKey(), - character_bandolier_entry.id + e.id ) ); @@ -195,57 +195,57 @@ public: static CharacterBandolier InsertOne( Database& db, - CharacterBandolier character_bandolier_entry + CharacterBandolier e ) { - std::vector insert_values; + std::vector v; - insert_values.push_back(std::to_string(character_bandolier_entry.id)); - insert_values.push_back(std::to_string(character_bandolier_entry.bandolier_id)); - insert_values.push_back(std::to_string(character_bandolier_entry.bandolier_slot)); - insert_values.push_back(std::to_string(character_bandolier_entry.item_id)); - insert_values.push_back(std::to_string(character_bandolier_entry.icon)); - insert_values.push_back("'" + Strings::Escape(character_bandolier_entry.bandolier_name) + "'"); + v.push_back(std::to_string(e.id)); + v.push_back(std::to_string(e.bandolier_id)); + v.push_back(std::to_string(e.bandolier_slot)); + v.push_back(std::to_string(e.item_id)); + v.push_back(std::to_string(e.icon)); + v.push_back("'" + Strings::Escape(e.bandolier_name) + "'"); auto results = db.QueryDatabase( fmt::format( "{} VALUES ({})", BaseInsert(), - Strings::Implode(",", insert_values) + Strings::Implode(",", v) ) ); if (results.Success()) { - character_bandolier_entry.id = results.LastInsertedID(); - return character_bandolier_entry; + e.id = results.LastInsertedID(); + return e; } - character_bandolier_entry = NewEntity(); + e = NewEntity(); - return character_bandolier_entry; + return e; } static int InsertMany( Database& db, - std::vector character_bandolier_entries + const std::vector &entries ) { std::vector insert_chunks; - for (auto &character_bandolier_entry: character_bandolier_entries) { - std::vector insert_values; + for (auto &e: entries) { + std::vector v; - insert_values.push_back(std::to_string(character_bandolier_entry.id)); - insert_values.push_back(std::to_string(character_bandolier_entry.bandolier_id)); - insert_values.push_back(std::to_string(character_bandolier_entry.bandolier_slot)); - insert_values.push_back(std::to_string(character_bandolier_entry.item_id)); - insert_values.push_back(std::to_string(character_bandolier_entry.icon)); - insert_values.push_back("'" + Strings::Escape(character_bandolier_entry.bandolier_name) + "'"); + v.push_back(std::to_string(e.id)); + v.push_back(std::to_string(e.bandolier_id)); + v.push_back(std::to_string(e.bandolier_slot)); + v.push_back(std::to_string(e.item_id)); + v.push_back(std::to_string(e.icon)); + v.push_back("'" + Strings::Escape(e.bandolier_name) + "'"); - insert_chunks.push_back("(" + Strings::Implode(",", insert_values) + ")"); + insert_chunks.push_back("(" + Strings::Implode(",", v) + ")"); } - std::vector insert_values; + std::vector v; auto results = db.QueryDatabase( fmt::format( @@ -272,22 +272,22 @@ public: all_entries.reserve(results.RowCount()); for (auto row = results.begin(); row != results.end(); ++row) { - CharacterBandolier entry{}; + CharacterBandolier e{}; - entry.id = atoi(row[0]); - entry.bandolier_id = atoi(row[1]); - entry.bandolier_slot = atoi(row[2]); - entry.item_id = atoi(row[3]); - entry.icon = atoi(row[4]); - entry.bandolier_name = row[5] ? row[5] : ""; + e.id = atoi(row[0]); + e.bandolier_id = atoi(row[1]); + e.bandolier_slot = atoi(row[2]); + e.item_id = atoi(row[3]); + e.icon = atoi(row[4]); + e.bandolier_name = row[5] ? row[5] : ""; - all_entries.push_back(entry); + all_entries.push_back(e); } return all_entries; } - static std::vector GetWhere(Database& db, std::string where_filter) + static std::vector GetWhere(Database& db, const std::string &where_filter) { std::vector all_entries; @@ -302,22 +302,22 @@ public: all_entries.reserve(results.RowCount()); for (auto row = results.begin(); row != results.end(); ++row) { - CharacterBandolier entry{}; + CharacterBandolier e{}; - entry.id = atoi(row[0]); - entry.bandolier_id = atoi(row[1]); - entry.bandolier_slot = atoi(row[2]); - entry.item_id = atoi(row[3]); - entry.icon = atoi(row[4]); - entry.bandolier_name = row[5] ? row[5] : ""; + e.id = atoi(row[0]); + e.bandolier_id = atoi(row[1]); + e.bandolier_slot = atoi(row[2]); + e.item_id = atoi(row[3]); + e.icon = atoi(row[4]); + e.bandolier_name = row[5] ? row[5] : ""; - all_entries.push_back(entry); + all_entries.push_back(e); } return all_entries; } - static int DeleteWhere(Database& db, std::string where_filter) + static int DeleteWhere(Database& db, const std::string &where_filter) { auto results = db.QueryDatabase( fmt::format( @@ -342,6 +342,32 @@ public: 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); + } + }; #endif //EQEMU_BASE_CHARACTER_BANDOLIER_REPOSITORY_H diff --git a/common/repositories/base/base_character_bind_repository.h b/common/repositories/base/base_character_bind_repository.h index 96dde6255..1b9f83f86 100644 --- a/common/repositories/base/base_character_bind_repository.h +++ b/common/repositories/base/base_character_bind_repository.h @@ -97,21 +97,21 @@ public: static CharacterBind NewEntity() { - CharacterBind entry{}; + CharacterBind e{}; - entry.id = 0; - entry.slot = 0; - entry.zone_id = 0; - entry.instance_id = 0; - entry.x = 0; - entry.y = 0; - entry.z = 0; - entry.heading = 0; + e.id = 0; + e.slot = 0; + e.zone_id = 0; + e.instance_id = 0; + e.x = 0; + e.y = 0; + e.z = 0; + e.heading = 0; - return entry; + return e; } - static CharacterBind GetCharacterBindEntry( + static CharacterBind GetCharacterBind( const std::vector &character_binds, int character_bind_id ) @@ -140,18 +140,18 @@ public: auto row = results.begin(); if (results.RowCount() == 1) { - CharacterBind entry{}; + CharacterBind e{}; - entry.id = atoi(row[0]); - entry.slot = atoi(row[1]); - entry.zone_id = atoi(row[2]); - entry.instance_id = atoi(row[3]); - entry.x = static_cast(atof(row[4])); - entry.y = static_cast(atof(row[5])); - entry.z = static_cast(atof(row[6])); - entry.heading = static_cast(atof(row[7])); + e.id = atoi(row[0]); + e.slot = atoi(row[1]); + e.zone_id = atoi(row[2]); + e.instance_id = atoi(row[3]); + e.x = static_cast(atof(row[4])); + e.y = static_cast(atof(row[5])); + e.z = static_cast(atof(row[6])); + e.heading = static_cast(atof(row[7])); - return entry; + return e; } return NewEntity(); @@ -176,28 +176,28 @@ public: static int UpdateOne( Database& db, - CharacterBind character_bind_entry + const CharacterBind &e ) { - std::vector update_values; + std::vector v; auto columns = Columns(); - update_values.push_back(columns[1] + " = " + std::to_string(character_bind_entry.slot)); - update_values.push_back(columns[2] + " = " + std::to_string(character_bind_entry.zone_id)); - update_values.push_back(columns[3] + " = " + std::to_string(character_bind_entry.instance_id)); - update_values.push_back(columns[4] + " = " + std::to_string(character_bind_entry.x)); - update_values.push_back(columns[5] + " = " + std::to_string(character_bind_entry.y)); - update_values.push_back(columns[6] + " = " + std::to_string(character_bind_entry.z)); - update_values.push_back(columns[7] + " = " + std::to_string(character_bind_entry.heading)); + v.push_back(columns[1] + " = " + std::to_string(e.slot)); + v.push_back(columns[2] + " = " + std::to_string(e.zone_id)); + v.push_back(columns[3] + " = " + std::to_string(e.instance_id)); + v.push_back(columns[4] + " = " + std::to_string(e.x)); + v.push_back(columns[5] + " = " + std::to_string(e.y)); + v.push_back(columns[6] + " = " + std::to_string(e.z)); + v.push_back(columns[7] + " = " + std::to_string(e.heading)); auto results = db.QueryDatabase( fmt::format( "UPDATE {} SET {} WHERE {} = {}", TableName(), - Strings::Implode(", ", update_values), + Strings::Implode(", ", v), PrimaryKey(), - character_bind_entry.id + e.id ) ); @@ -206,61 +206,61 @@ public: static CharacterBind InsertOne( Database& db, - CharacterBind character_bind_entry + CharacterBind e ) { - std::vector insert_values; + std::vector v; - insert_values.push_back(std::to_string(character_bind_entry.id)); - insert_values.push_back(std::to_string(character_bind_entry.slot)); - insert_values.push_back(std::to_string(character_bind_entry.zone_id)); - insert_values.push_back(std::to_string(character_bind_entry.instance_id)); - insert_values.push_back(std::to_string(character_bind_entry.x)); - insert_values.push_back(std::to_string(character_bind_entry.y)); - insert_values.push_back(std::to_string(character_bind_entry.z)); - insert_values.push_back(std::to_string(character_bind_entry.heading)); + v.push_back(std::to_string(e.id)); + v.push_back(std::to_string(e.slot)); + v.push_back(std::to_string(e.zone_id)); + v.push_back(std::to_string(e.instance_id)); + v.push_back(std::to_string(e.x)); + v.push_back(std::to_string(e.y)); + v.push_back(std::to_string(e.z)); + v.push_back(std::to_string(e.heading)); auto results = db.QueryDatabase( fmt::format( "{} VALUES ({})", BaseInsert(), - Strings::Implode(",", insert_values) + Strings::Implode(",", v) ) ); if (results.Success()) { - character_bind_entry.id = results.LastInsertedID(); - return character_bind_entry; + e.id = results.LastInsertedID(); + return e; } - character_bind_entry = NewEntity(); + e = NewEntity(); - return character_bind_entry; + return e; } static int InsertMany( Database& db, - std::vector character_bind_entries + const std::vector &entries ) { std::vector insert_chunks; - for (auto &character_bind_entry: character_bind_entries) { - std::vector insert_values; + for (auto &e: entries) { + std::vector v; - insert_values.push_back(std::to_string(character_bind_entry.id)); - insert_values.push_back(std::to_string(character_bind_entry.slot)); - insert_values.push_back(std::to_string(character_bind_entry.zone_id)); - insert_values.push_back(std::to_string(character_bind_entry.instance_id)); - insert_values.push_back(std::to_string(character_bind_entry.x)); - insert_values.push_back(std::to_string(character_bind_entry.y)); - insert_values.push_back(std::to_string(character_bind_entry.z)); - insert_values.push_back(std::to_string(character_bind_entry.heading)); + v.push_back(std::to_string(e.id)); + v.push_back(std::to_string(e.slot)); + v.push_back(std::to_string(e.zone_id)); + v.push_back(std::to_string(e.instance_id)); + v.push_back(std::to_string(e.x)); + v.push_back(std::to_string(e.y)); + v.push_back(std::to_string(e.z)); + v.push_back(std::to_string(e.heading)); - insert_chunks.push_back("(" + Strings::Implode(",", insert_values) + ")"); + insert_chunks.push_back("(" + Strings::Implode(",", v) + ")"); } - std::vector insert_values; + std::vector v; auto results = db.QueryDatabase( fmt::format( @@ -287,24 +287,24 @@ public: all_entries.reserve(results.RowCount()); for (auto row = results.begin(); row != results.end(); ++row) { - CharacterBind entry{}; + CharacterBind e{}; - entry.id = atoi(row[0]); - entry.slot = atoi(row[1]); - entry.zone_id = atoi(row[2]); - entry.instance_id = atoi(row[3]); - entry.x = static_cast(atof(row[4])); - entry.y = static_cast(atof(row[5])); - entry.z = static_cast(atof(row[6])); - entry.heading = static_cast(atof(row[7])); + e.id = atoi(row[0]); + e.slot = atoi(row[1]); + e.zone_id = atoi(row[2]); + e.instance_id = atoi(row[3]); + e.x = static_cast(atof(row[4])); + e.y = static_cast(atof(row[5])); + e.z = static_cast(atof(row[6])); + e.heading = static_cast(atof(row[7])); - all_entries.push_back(entry); + all_entries.push_back(e); } return all_entries; } - static std::vector GetWhere(Database& db, std::string where_filter) + static std::vector GetWhere(Database& db, const std::string &where_filter) { std::vector all_entries; @@ -319,24 +319,24 @@ public: all_entries.reserve(results.RowCount()); for (auto row = results.begin(); row != results.end(); ++row) { - CharacterBind entry{}; + CharacterBind e{}; - entry.id = atoi(row[0]); - entry.slot = atoi(row[1]); - entry.zone_id = atoi(row[2]); - entry.instance_id = atoi(row[3]); - entry.x = static_cast(atof(row[4])); - entry.y = static_cast(atof(row[5])); - entry.z = static_cast(atof(row[6])); - entry.heading = static_cast(atof(row[7])); + e.id = atoi(row[0]); + e.slot = atoi(row[1]); + e.zone_id = atoi(row[2]); + e.instance_id = atoi(row[3]); + e.x = static_cast(atof(row[4])); + e.y = static_cast(atof(row[5])); + e.z = static_cast(atof(row[6])); + e.heading = static_cast(atof(row[7])); - all_entries.push_back(entry); + all_entries.push_back(e); } return all_entries; } - static int DeleteWhere(Database& db, std::string where_filter) + static int DeleteWhere(Database& db, const std::string &where_filter) { auto results = db.QueryDatabase( fmt::format( @@ -361,6 +361,32 @@ public: 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); + } + }; #endif //EQEMU_BASE_CHARACTER_BIND_REPOSITORY_H diff --git a/common/repositories/base/base_character_buffs_repository.h b/common/repositories/base/base_character_buffs_repository.h index cc7010ced..b9f200a17 100644 --- a/common/repositories/base/base_character_buffs_repository.h +++ b/common/repositories/base/base_character_buffs_repository.h @@ -124,30 +124,30 @@ public: static CharacterBuffs NewEntity() { - CharacterBuffs entry{}; + CharacterBuffs e{}; - entry.character_id = 0; - entry.slot_id = 0; - entry.spell_id = 0; - entry.caster_level = 0; - entry.caster_name = ""; - entry.ticsremaining = 0; - entry.counters = 0; - entry.numhits = 0; - entry.melee_rune = 0; - entry.magic_rune = 0; - entry.persistent = 0; - entry.dot_rune = 0; - entry.caston_x = 0; - entry.caston_y = 0; - entry.caston_z = 0; - entry.ExtraDIChance = 0; - entry.instrument_mod = 10; + e.character_id = 0; + e.slot_id = 0; + e.spell_id = 0; + e.caster_level = 0; + e.caster_name = ""; + e.ticsremaining = 0; + e.counters = 0; + e.numhits = 0; + e.melee_rune = 0; + e.magic_rune = 0; + e.persistent = 0; + e.dot_rune = 0; + e.caston_x = 0; + e.caston_y = 0; + e.caston_z = 0; + e.ExtraDIChance = 0; + e.instrument_mod = 10; - return entry; + return e; } - static CharacterBuffs GetCharacterBuffsEntry( + static CharacterBuffs GetCharacterBuffs( const std::vector &character_buffss, int character_buffs_id ) @@ -176,27 +176,27 @@ public: auto row = results.begin(); if (results.RowCount() == 1) { - CharacterBuffs entry{}; + CharacterBuffs e{}; - entry.character_id = atoi(row[0]); - entry.slot_id = atoi(row[1]); - entry.spell_id = atoi(row[2]); - entry.caster_level = atoi(row[3]); - entry.caster_name = row[4] ? row[4] : ""; - entry.ticsremaining = atoi(row[5]); - entry.counters = atoi(row[6]); - entry.numhits = atoi(row[7]); - entry.melee_rune = atoi(row[8]); - entry.magic_rune = atoi(row[9]); - entry.persistent = atoi(row[10]); - entry.dot_rune = atoi(row[11]); - entry.caston_x = atoi(row[12]); - entry.caston_y = atoi(row[13]); - entry.caston_z = atoi(row[14]); - entry.ExtraDIChance = atoi(row[15]); - entry.instrument_mod = atoi(row[16]); + e.character_id = atoi(row[0]); + e.slot_id = atoi(row[1]); + e.spell_id = atoi(row[2]); + e.caster_level = atoi(row[3]); + e.caster_name = row[4] ? row[4] : ""; + e.ticsremaining = atoi(row[5]); + e.counters = atoi(row[6]); + e.numhits = atoi(row[7]); + e.melee_rune = atoi(row[8]); + e.magic_rune = atoi(row[9]); + e.persistent = atoi(row[10]); + e.dot_rune = atoi(row[11]); + e.caston_x = atoi(row[12]); + e.caston_y = atoi(row[13]); + e.caston_z = atoi(row[14]); + e.ExtraDIChance = atoi(row[15]); + e.instrument_mod = atoi(row[16]); - return entry; + return e; } return NewEntity(); @@ -221,38 +221,38 @@ public: static int UpdateOne( Database& db, - CharacterBuffs character_buffs_entry + const CharacterBuffs &e ) { - std::vector update_values; + std::vector v; auto columns = Columns(); - update_values.push_back(columns[0] + " = " + std::to_string(character_buffs_entry.character_id)); - update_values.push_back(columns[1] + " = " + std::to_string(character_buffs_entry.slot_id)); - update_values.push_back(columns[2] + " = " + std::to_string(character_buffs_entry.spell_id)); - update_values.push_back(columns[3] + " = " + std::to_string(character_buffs_entry.caster_level)); - update_values.push_back(columns[4] + " = '" + Strings::Escape(character_buffs_entry.caster_name) + "'"); - update_values.push_back(columns[5] + " = " + std::to_string(character_buffs_entry.ticsremaining)); - update_values.push_back(columns[6] + " = " + std::to_string(character_buffs_entry.counters)); - update_values.push_back(columns[7] + " = " + std::to_string(character_buffs_entry.numhits)); - update_values.push_back(columns[8] + " = " + std::to_string(character_buffs_entry.melee_rune)); - update_values.push_back(columns[9] + " = " + std::to_string(character_buffs_entry.magic_rune)); - update_values.push_back(columns[10] + " = " + std::to_string(character_buffs_entry.persistent)); - update_values.push_back(columns[11] + " = " + std::to_string(character_buffs_entry.dot_rune)); - update_values.push_back(columns[12] + " = " + std::to_string(character_buffs_entry.caston_x)); - update_values.push_back(columns[13] + " = " + std::to_string(character_buffs_entry.caston_y)); - update_values.push_back(columns[14] + " = " + std::to_string(character_buffs_entry.caston_z)); - update_values.push_back(columns[15] + " = " + std::to_string(character_buffs_entry.ExtraDIChance)); - update_values.push_back(columns[16] + " = " + std::to_string(character_buffs_entry.instrument_mod)); + 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.spell_id)); + v.push_back(columns[3] + " = " + std::to_string(e.caster_level)); + v.push_back(columns[4] + " = '" + Strings::Escape(e.caster_name) + "'"); + v.push_back(columns[5] + " = " + std::to_string(e.ticsremaining)); + v.push_back(columns[6] + " = " + std::to_string(e.counters)); + v.push_back(columns[7] + " = " + std::to_string(e.numhits)); + v.push_back(columns[8] + " = " + std::to_string(e.melee_rune)); + v.push_back(columns[9] + " = " + std::to_string(e.magic_rune)); + v.push_back(columns[10] + " = " + std::to_string(e.persistent)); + v.push_back(columns[11] + " = " + std::to_string(e.dot_rune)); + v.push_back(columns[12] + " = " + std::to_string(e.caston_x)); + v.push_back(columns[13] + " = " + std::to_string(e.caston_y)); + v.push_back(columns[14] + " = " + std::to_string(e.caston_z)); + v.push_back(columns[15] + " = " + std::to_string(e.ExtraDIChance)); + v.push_back(columns[16] + " = " + std::to_string(e.instrument_mod)); auto results = db.QueryDatabase( fmt::format( "UPDATE {} SET {} WHERE {} = {}", TableName(), - Strings::Implode(", ", update_values), + Strings::Implode(", ", v), PrimaryKey(), - character_buffs_entry.character_id + e.character_id ) ); @@ -261,79 +261,79 @@ public: static CharacterBuffs InsertOne( Database& db, - CharacterBuffs character_buffs_entry + CharacterBuffs e ) { - std::vector insert_values; + std::vector v; - insert_values.push_back(std::to_string(character_buffs_entry.character_id)); - insert_values.push_back(std::to_string(character_buffs_entry.slot_id)); - insert_values.push_back(std::to_string(character_buffs_entry.spell_id)); - insert_values.push_back(std::to_string(character_buffs_entry.caster_level)); - insert_values.push_back("'" + Strings::Escape(character_buffs_entry.caster_name) + "'"); - insert_values.push_back(std::to_string(character_buffs_entry.ticsremaining)); - insert_values.push_back(std::to_string(character_buffs_entry.counters)); - insert_values.push_back(std::to_string(character_buffs_entry.numhits)); - insert_values.push_back(std::to_string(character_buffs_entry.melee_rune)); - insert_values.push_back(std::to_string(character_buffs_entry.magic_rune)); - insert_values.push_back(std::to_string(character_buffs_entry.persistent)); - insert_values.push_back(std::to_string(character_buffs_entry.dot_rune)); - insert_values.push_back(std::to_string(character_buffs_entry.caston_x)); - insert_values.push_back(std::to_string(character_buffs_entry.caston_y)); - insert_values.push_back(std::to_string(character_buffs_entry.caston_z)); - insert_values.push_back(std::to_string(character_buffs_entry.ExtraDIChance)); - insert_values.push_back(std::to_string(character_buffs_entry.instrument_mod)); + 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.spell_id)); + v.push_back(std::to_string(e.caster_level)); + v.push_back("'" + Strings::Escape(e.caster_name) + "'"); + v.push_back(std::to_string(e.ticsremaining)); + v.push_back(std::to_string(e.counters)); + v.push_back(std::to_string(e.numhits)); + v.push_back(std::to_string(e.melee_rune)); + v.push_back(std::to_string(e.magic_rune)); + v.push_back(std::to_string(e.persistent)); + v.push_back(std::to_string(e.dot_rune)); + v.push_back(std::to_string(e.caston_x)); + v.push_back(std::to_string(e.caston_y)); + v.push_back(std::to_string(e.caston_z)); + v.push_back(std::to_string(e.ExtraDIChance)); + v.push_back(std::to_string(e.instrument_mod)); auto results = db.QueryDatabase( fmt::format( "{} VALUES ({})", BaseInsert(), - Strings::Implode(",", insert_values) + Strings::Implode(",", v) ) ); if (results.Success()) { - character_buffs_entry.character_id = results.LastInsertedID(); - return character_buffs_entry; + e.character_id = results.LastInsertedID(); + return e; } - character_buffs_entry = NewEntity(); + e = NewEntity(); - return character_buffs_entry; + return e; } static int InsertMany( Database& db, - std::vector character_buffs_entries + const std::vector &entries ) { std::vector insert_chunks; - for (auto &character_buffs_entry: character_buffs_entries) { - std::vector insert_values; + for (auto &e: entries) { + std::vector v; - insert_values.push_back(std::to_string(character_buffs_entry.character_id)); - insert_values.push_back(std::to_string(character_buffs_entry.slot_id)); - insert_values.push_back(std::to_string(character_buffs_entry.spell_id)); - insert_values.push_back(std::to_string(character_buffs_entry.caster_level)); - insert_values.push_back("'" + Strings::Escape(character_buffs_entry.caster_name) + "'"); - insert_values.push_back(std::to_string(character_buffs_entry.ticsremaining)); - insert_values.push_back(std::to_string(character_buffs_entry.counters)); - insert_values.push_back(std::to_string(character_buffs_entry.numhits)); - insert_values.push_back(std::to_string(character_buffs_entry.melee_rune)); - insert_values.push_back(std::to_string(character_buffs_entry.magic_rune)); - insert_values.push_back(std::to_string(character_buffs_entry.persistent)); - insert_values.push_back(std::to_string(character_buffs_entry.dot_rune)); - insert_values.push_back(std::to_string(character_buffs_entry.caston_x)); - insert_values.push_back(std::to_string(character_buffs_entry.caston_y)); - insert_values.push_back(std::to_string(character_buffs_entry.caston_z)); - insert_values.push_back(std::to_string(character_buffs_entry.ExtraDIChance)); - insert_values.push_back(std::to_string(character_buffs_entry.instrument_mod)); + 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.spell_id)); + v.push_back(std::to_string(e.caster_level)); + v.push_back("'" + Strings::Escape(e.caster_name) + "'"); + v.push_back(std::to_string(e.ticsremaining)); + v.push_back(std::to_string(e.counters)); + v.push_back(std::to_string(e.numhits)); + v.push_back(std::to_string(e.melee_rune)); + v.push_back(std::to_string(e.magic_rune)); + v.push_back(std::to_string(e.persistent)); + v.push_back(std::to_string(e.dot_rune)); + v.push_back(std::to_string(e.caston_x)); + v.push_back(std::to_string(e.caston_y)); + v.push_back(std::to_string(e.caston_z)); + v.push_back(std::to_string(e.ExtraDIChance)); + v.push_back(std::to_string(e.instrument_mod)); - insert_chunks.push_back("(" + Strings::Implode(",", insert_values) + ")"); + insert_chunks.push_back("(" + Strings::Implode(",", v) + ")"); } - std::vector insert_values; + std::vector v; auto results = db.QueryDatabase( fmt::format( @@ -360,33 +360,33 @@ public: all_entries.reserve(results.RowCount()); for (auto row = results.begin(); row != results.end(); ++row) { - CharacterBuffs entry{}; + CharacterBuffs e{}; - entry.character_id = atoi(row[0]); - entry.slot_id = atoi(row[1]); - entry.spell_id = atoi(row[2]); - entry.caster_level = atoi(row[3]); - entry.caster_name = row[4] ? row[4] : ""; - entry.ticsremaining = atoi(row[5]); - entry.counters = atoi(row[6]); - entry.numhits = atoi(row[7]); - entry.melee_rune = atoi(row[8]); - entry.magic_rune = atoi(row[9]); - entry.persistent = atoi(row[10]); - entry.dot_rune = atoi(row[11]); - entry.caston_x = atoi(row[12]); - entry.caston_y = atoi(row[13]); - entry.caston_z = atoi(row[14]); - entry.ExtraDIChance = atoi(row[15]); - entry.instrument_mod = atoi(row[16]); + e.character_id = atoi(row[0]); + e.slot_id = atoi(row[1]); + e.spell_id = atoi(row[2]); + e.caster_level = atoi(row[3]); + e.caster_name = row[4] ? row[4] : ""; + e.ticsremaining = atoi(row[5]); + e.counters = atoi(row[6]); + e.numhits = atoi(row[7]); + e.melee_rune = atoi(row[8]); + e.magic_rune = atoi(row[9]); + e.persistent = atoi(row[10]); + e.dot_rune = atoi(row[11]); + e.caston_x = atoi(row[12]); + e.caston_y = atoi(row[13]); + e.caston_z = atoi(row[14]); + e.ExtraDIChance = atoi(row[15]); + e.instrument_mod = atoi(row[16]); - all_entries.push_back(entry); + all_entries.push_back(e); } return all_entries; } - static std::vector GetWhere(Database& db, std::string where_filter) + static std::vector GetWhere(Database& db, const std::string &where_filter) { std::vector all_entries; @@ -401,33 +401,33 @@ public: all_entries.reserve(results.RowCount()); for (auto row = results.begin(); row != results.end(); ++row) { - CharacterBuffs entry{}; + CharacterBuffs e{}; - entry.character_id = atoi(row[0]); - entry.slot_id = atoi(row[1]); - entry.spell_id = atoi(row[2]); - entry.caster_level = atoi(row[3]); - entry.caster_name = row[4] ? row[4] : ""; - entry.ticsremaining = atoi(row[5]); - entry.counters = atoi(row[6]); - entry.numhits = atoi(row[7]); - entry.melee_rune = atoi(row[8]); - entry.magic_rune = atoi(row[9]); - entry.persistent = atoi(row[10]); - entry.dot_rune = atoi(row[11]); - entry.caston_x = atoi(row[12]); - entry.caston_y = atoi(row[13]); - entry.caston_z = atoi(row[14]); - entry.ExtraDIChance = atoi(row[15]); - entry.instrument_mod = atoi(row[16]); + e.character_id = atoi(row[0]); + e.slot_id = atoi(row[1]); + e.spell_id = atoi(row[2]); + e.caster_level = atoi(row[3]); + e.caster_name = row[4] ? row[4] : ""; + e.ticsremaining = atoi(row[5]); + e.counters = atoi(row[6]); + e.numhits = atoi(row[7]); + e.melee_rune = atoi(row[8]); + e.magic_rune = atoi(row[9]); + e.persistent = atoi(row[10]); + e.dot_rune = atoi(row[11]); + e.caston_x = atoi(row[12]); + e.caston_y = atoi(row[13]); + e.caston_z = atoi(row[14]); + e.ExtraDIChance = atoi(row[15]); + e.instrument_mod = atoi(row[16]); - all_entries.push_back(entry); + all_entries.push_back(e); } return all_entries; } - static int DeleteWhere(Database& db, std::string where_filter) + static int DeleteWhere(Database& db, const std::string &where_filter) { auto results = db.QueryDatabase( fmt::format( @@ -452,6 +452,32 @@ public: 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); + } + }; #endif //EQEMU_BASE_CHARACTER_BUFFS_REPOSITORY_H diff --git a/common/repositories/base/base_character_corpse_items_repository.h b/common/repositories/base/base_character_corpse_items_repository.h index da601caf1..61830ef63 100644 --- a/common/repositories/base/base_character_corpse_items_repository.h +++ b/common/repositories/base/base_character_corpse_items_repository.h @@ -106,24 +106,24 @@ public: static CharacterCorpseItems NewEntity() { - CharacterCorpseItems entry{}; + CharacterCorpseItems e{}; - entry.corpse_id = 0; - entry.equip_slot = 0; - entry.item_id = 0; - entry.charges = 0; - entry.aug_1 = 0; - entry.aug_2 = 0; - entry.aug_3 = 0; - entry.aug_4 = 0; - entry.aug_5 = 0; - entry.aug_6 = 0; - entry.attuned = 0; + e.corpse_id = 0; + e.equip_slot = 0; + e.item_id = 0; + e.charges = 0; + e.aug_1 = 0; + e.aug_2 = 0; + e.aug_3 = 0; + e.aug_4 = 0; + e.aug_5 = 0; + e.aug_6 = 0; + e.attuned = 0; - return entry; + return e; } - static CharacterCorpseItems GetCharacterCorpseItemsEntry( + static CharacterCorpseItems GetCharacterCorpseItems( const std::vector &character_corpse_itemss, int character_corpse_items_id ) @@ -152,21 +152,21 @@ public: auto row = results.begin(); if (results.RowCount() == 1) { - CharacterCorpseItems entry{}; + CharacterCorpseItems e{}; - entry.corpse_id = atoi(row[0]); - entry.equip_slot = atoi(row[1]); - entry.item_id = atoi(row[2]); - entry.charges = atoi(row[3]); - entry.aug_1 = atoi(row[4]); - entry.aug_2 = atoi(row[5]); - entry.aug_3 = atoi(row[6]); - entry.aug_4 = atoi(row[7]); - entry.aug_5 = atoi(row[8]); - entry.aug_6 = atoi(row[9]); - entry.attuned = atoi(row[10]); + e.corpse_id = atoi(row[0]); + e.equip_slot = atoi(row[1]); + e.item_id = atoi(row[2]); + e.charges = atoi(row[3]); + e.aug_1 = atoi(row[4]); + e.aug_2 = atoi(row[5]); + e.aug_3 = atoi(row[6]); + e.aug_4 = atoi(row[7]); + e.aug_5 = atoi(row[8]); + e.aug_6 = atoi(row[9]); + e.attuned = atoi(row[10]); - return entry; + return e; } return NewEntity(); @@ -191,32 +191,32 @@ public: static int UpdateOne( Database& db, - CharacterCorpseItems character_corpse_items_entry + const CharacterCorpseItems &e ) { - std::vector update_values; + std::vector v; auto columns = Columns(); - update_values.push_back(columns[0] + " = " + std::to_string(character_corpse_items_entry.corpse_id)); - update_values.push_back(columns[1] + " = " + std::to_string(character_corpse_items_entry.equip_slot)); - update_values.push_back(columns[2] + " = " + std::to_string(character_corpse_items_entry.item_id)); - update_values.push_back(columns[3] + " = " + std::to_string(character_corpse_items_entry.charges)); - update_values.push_back(columns[4] + " = " + std::to_string(character_corpse_items_entry.aug_1)); - update_values.push_back(columns[5] + " = " + std::to_string(character_corpse_items_entry.aug_2)); - update_values.push_back(columns[6] + " = " + std::to_string(character_corpse_items_entry.aug_3)); - update_values.push_back(columns[7] + " = " + std::to_string(character_corpse_items_entry.aug_4)); - update_values.push_back(columns[8] + " = " + std::to_string(character_corpse_items_entry.aug_5)); - update_values.push_back(columns[9] + " = " + std::to_string(character_corpse_items_entry.aug_6)); - update_values.push_back(columns[10] + " = " + std::to_string(character_corpse_items_entry.attuned)); + v.push_back(columns[0] + " = " + std::to_string(e.corpse_id)); + v.push_back(columns[1] + " = " + std::to_string(e.equip_slot)); + 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.aug_1)); + v.push_back(columns[5] + " = " + std::to_string(e.aug_2)); + v.push_back(columns[6] + " = " + std::to_string(e.aug_3)); + v.push_back(columns[7] + " = " + std::to_string(e.aug_4)); + v.push_back(columns[8] + " = " + std::to_string(e.aug_5)); + v.push_back(columns[9] + " = " + std::to_string(e.aug_6)); + v.push_back(columns[10] + " = " + std::to_string(e.attuned)); auto results = db.QueryDatabase( fmt::format( "UPDATE {} SET {} WHERE {} = {}", TableName(), - Strings::Implode(", ", update_values), + Strings::Implode(", ", v), PrimaryKey(), - character_corpse_items_entry.corpse_id + e.corpse_id ) ); @@ -225,67 +225,67 @@ public: static CharacterCorpseItems InsertOne( Database& db, - CharacterCorpseItems character_corpse_items_entry + CharacterCorpseItems e ) { - std::vector insert_values; + std::vector v; - insert_values.push_back(std::to_string(character_corpse_items_entry.corpse_id)); - insert_values.push_back(std::to_string(character_corpse_items_entry.equip_slot)); - insert_values.push_back(std::to_string(character_corpse_items_entry.item_id)); - insert_values.push_back(std::to_string(character_corpse_items_entry.charges)); - insert_values.push_back(std::to_string(character_corpse_items_entry.aug_1)); - insert_values.push_back(std::to_string(character_corpse_items_entry.aug_2)); - insert_values.push_back(std::to_string(character_corpse_items_entry.aug_3)); - insert_values.push_back(std::to_string(character_corpse_items_entry.aug_4)); - insert_values.push_back(std::to_string(character_corpse_items_entry.aug_5)); - insert_values.push_back(std::to_string(character_corpse_items_entry.aug_6)); - insert_values.push_back(std::to_string(character_corpse_items_entry.attuned)); + v.push_back(std::to_string(e.corpse_id)); + v.push_back(std::to_string(e.equip_slot)); + v.push_back(std::to_string(e.item_id)); + v.push_back(std::to_string(e.charges)); + v.push_back(std::to_string(e.aug_1)); + v.push_back(std::to_string(e.aug_2)); + v.push_back(std::to_string(e.aug_3)); + v.push_back(std::to_string(e.aug_4)); + v.push_back(std::to_string(e.aug_5)); + v.push_back(std::to_string(e.aug_6)); + v.push_back(std::to_string(e.attuned)); auto results = db.QueryDatabase( fmt::format( "{} VALUES ({})", BaseInsert(), - Strings::Implode(",", insert_values) + Strings::Implode(",", v) ) ); if (results.Success()) { - character_corpse_items_entry.corpse_id = results.LastInsertedID(); - return character_corpse_items_entry; + e.corpse_id = results.LastInsertedID(); + return e; } - character_corpse_items_entry = NewEntity(); + e = NewEntity(); - return character_corpse_items_entry; + return e; } static int InsertMany( Database& db, - std::vector character_corpse_items_entries + const std::vector &entries ) { std::vector insert_chunks; - for (auto &character_corpse_items_entry: character_corpse_items_entries) { - std::vector insert_values; + for (auto &e: entries) { + std::vector v; - insert_values.push_back(std::to_string(character_corpse_items_entry.corpse_id)); - insert_values.push_back(std::to_string(character_corpse_items_entry.equip_slot)); - insert_values.push_back(std::to_string(character_corpse_items_entry.item_id)); - insert_values.push_back(std::to_string(character_corpse_items_entry.charges)); - insert_values.push_back(std::to_string(character_corpse_items_entry.aug_1)); - insert_values.push_back(std::to_string(character_corpse_items_entry.aug_2)); - insert_values.push_back(std::to_string(character_corpse_items_entry.aug_3)); - insert_values.push_back(std::to_string(character_corpse_items_entry.aug_4)); - insert_values.push_back(std::to_string(character_corpse_items_entry.aug_5)); - insert_values.push_back(std::to_string(character_corpse_items_entry.aug_6)); - insert_values.push_back(std::to_string(character_corpse_items_entry.attuned)); + v.push_back(std::to_string(e.corpse_id)); + v.push_back(std::to_string(e.equip_slot)); + v.push_back(std::to_string(e.item_id)); + v.push_back(std::to_string(e.charges)); + v.push_back(std::to_string(e.aug_1)); + v.push_back(std::to_string(e.aug_2)); + v.push_back(std::to_string(e.aug_3)); + v.push_back(std::to_string(e.aug_4)); + v.push_back(std::to_string(e.aug_5)); + v.push_back(std::to_string(e.aug_6)); + v.push_back(std::to_string(e.attuned)); - insert_chunks.push_back("(" + Strings::Implode(",", insert_values) + ")"); + insert_chunks.push_back("(" + Strings::Implode(",", v) + ")"); } - std::vector insert_values; + std::vector v; auto results = db.QueryDatabase( fmt::format( @@ -312,27 +312,27 @@ public: all_entries.reserve(results.RowCount()); for (auto row = results.begin(); row != results.end(); ++row) { - CharacterCorpseItems entry{}; + CharacterCorpseItems e{}; - entry.corpse_id = atoi(row[0]); - entry.equip_slot = atoi(row[1]); - entry.item_id = atoi(row[2]); - entry.charges = atoi(row[3]); - entry.aug_1 = atoi(row[4]); - entry.aug_2 = atoi(row[5]); - entry.aug_3 = atoi(row[6]); - entry.aug_4 = atoi(row[7]); - entry.aug_5 = atoi(row[8]); - entry.aug_6 = atoi(row[9]); - entry.attuned = atoi(row[10]); + e.corpse_id = atoi(row[0]); + e.equip_slot = atoi(row[1]); + e.item_id = atoi(row[2]); + e.charges = atoi(row[3]); + e.aug_1 = atoi(row[4]); + e.aug_2 = atoi(row[5]); + e.aug_3 = atoi(row[6]); + e.aug_4 = atoi(row[7]); + e.aug_5 = atoi(row[8]); + e.aug_6 = atoi(row[9]); + e.attuned = atoi(row[10]); - all_entries.push_back(entry); + all_entries.push_back(e); } return all_entries; } - static std::vector GetWhere(Database& db, std::string where_filter) + static std::vector GetWhere(Database& db, const std::string &where_filter) { std::vector all_entries; @@ -347,27 +347,27 @@ public: all_entries.reserve(results.RowCount()); for (auto row = results.begin(); row != results.end(); ++row) { - CharacterCorpseItems entry{}; + CharacterCorpseItems e{}; - entry.corpse_id = atoi(row[0]); - entry.equip_slot = atoi(row[1]); - entry.item_id = atoi(row[2]); - entry.charges = atoi(row[3]); - entry.aug_1 = atoi(row[4]); - entry.aug_2 = atoi(row[5]); - entry.aug_3 = atoi(row[6]); - entry.aug_4 = atoi(row[7]); - entry.aug_5 = atoi(row[8]); - entry.aug_6 = atoi(row[9]); - entry.attuned = atoi(row[10]); + e.corpse_id = atoi(row[0]); + e.equip_slot = atoi(row[1]); + e.item_id = atoi(row[2]); + e.charges = atoi(row[3]); + e.aug_1 = atoi(row[4]); + e.aug_2 = atoi(row[5]); + e.aug_3 = atoi(row[6]); + e.aug_4 = atoi(row[7]); + e.aug_5 = atoi(row[8]); + e.aug_6 = atoi(row[9]); + e.attuned = atoi(row[10]); - all_entries.push_back(entry); + all_entries.push_back(e); } return all_entries; } - static int DeleteWhere(Database& db, std::string where_filter) + static int DeleteWhere(Database& db, const std::string &where_filter) { auto results = db.QueryDatabase( fmt::format( @@ -392,6 +392,32 @@ public: 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); + } + }; #endif //EQEMU_BASE_CHARACTER_CORPSE_ITEMS_REPOSITORY_H diff --git a/common/repositories/base/base_character_corpses_repository.h b/common/repositories/base/base_character_corpses_repository.h index 18a47c392..ef34a8c48 100644 --- a/common/repositories/base/base_character_corpses_repository.h +++ b/common/repositories/base/base_character_corpses_repository.h @@ -214,60 +214,60 @@ public: static CharacterCorpses NewEntity() { - CharacterCorpses entry{}; + CharacterCorpses e{}; - entry.id = 0; - entry.charid = 0; - entry.charname = ""; - entry.zone_id = 0; - entry.instance_id = 0; - entry.x = 0; - entry.y = 0; - entry.z = 0; - entry.heading = 0; - entry.time_of_death = 0; - entry.guild_consent_id = 0; - entry.is_rezzed = 0; - entry.is_buried = 0; - entry.was_at_graveyard = 0; - entry.is_locked = 0; - entry.exp = 0; - entry.size = 0; - entry.level = 0; - entry.race = 0; - entry.gender = 0; - entry.class_ = 0; - entry.deity = 0; - entry.texture = 0; - entry.helm_texture = 0; - entry.copper = 0; - entry.silver = 0; - entry.gold = 0; - entry.platinum = 0; - entry.hair_color = 0; - entry.beard_color = 0; - entry.eye_color_1 = 0; - entry.eye_color_2 = 0; - entry.hair_style = 0; - entry.face = 0; - entry.beard = 0; - entry.drakkin_heritage = 0; - entry.drakkin_tattoo = 0; - entry.drakkin_details = 0; - entry.wc_1 = 0; - entry.wc_2 = 0; - entry.wc_3 = 0; - entry.wc_4 = 0; - entry.wc_5 = 0; - entry.wc_6 = 0; - entry.wc_7 = 0; - entry.wc_8 = 0; - entry.wc_9 = 0; + e.id = 0; + e.charid = 0; + e.charname = ""; + e.zone_id = 0; + e.instance_id = 0; + e.x = 0; + e.y = 0; + e.z = 0; + e.heading = 0; + e.time_of_death = 0; + e.guild_consent_id = 0; + e.is_rezzed = 0; + e.is_buried = 0; + e.was_at_graveyard = 0; + e.is_locked = 0; + e.exp = 0; + e.size = 0; + e.level = 0; + e.race = 0; + e.gender = 0; + e.class_ = 0; + e.deity = 0; + e.texture = 0; + e.helm_texture = 0; + e.copper = 0; + e.silver = 0; + e.gold = 0; + e.platinum = 0; + e.hair_color = 0; + e.beard_color = 0; + e.eye_color_1 = 0; + e.eye_color_2 = 0; + e.hair_style = 0; + e.face = 0; + e.beard = 0; + e.drakkin_heritage = 0; + e.drakkin_tattoo = 0; + e.drakkin_details = 0; + e.wc_1 = 0; + e.wc_2 = 0; + e.wc_3 = 0; + e.wc_4 = 0; + e.wc_5 = 0; + e.wc_6 = 0; + e.wc_7 = 0; + e.wc_8 = 0; + e.wc_9 = 0; - return entry; + return e; } - static CharacterCorpses GetCharacterCorpsesEntry( + static CharacterCorpses GetCharacterCorpses( const std::vector &character_corpsess, int character_corpses_id ) @@ -296,57 +296,57 @@ public: auto row = results.begin(); if (results.RowCount() == 1) { - CharacterCorpses entry{}; + CharacterCorpses e{}; - entry.id = atoi(row[0]); - entry.charid = atoi(row[1]); - entry.charname = row[2] ? row[2] : ""; - entry.zone_id = atoi(row[3]); - entry.instance_id = atoi(row[4]); - entry.x = static_cast(atof(row[5])); - entry.y = static_cast(atof(row[6])); - entry.z = static_cast(atof(row[7])); - entry.heading = static_cast(atof(row[8])); - entry.time_of_death = strtoll(row[9] ? row[9] : "-1", nullptr, 10); - entry.guild_consent_id = atoi(row[10]); - entry.is_rezzed = atoi(row[11]); - entry.is_buried = atoi(row[12]); - entry.was_at_graveyard = atoi(row[13]); - entry.is_locked = atoi(row[14]); - entry.exp = atoi(row[15]); - entry.size = atoi(row[16]); - entry.level = atoi(row[17]); - entry.race = atoi(row[18]); - entry.gender = atoi(row[19]); - entry.class_ = atoi(row[20]); - entry.deity = atoi(row[21]); - entry.texture = atoi(row[22]); - entry.helm_texture = atoi(row[23]); - entry.copper = atoi(row[24]); - entry.silver = atoi(row[25]); - entry.gold = atoi(row[26]); - entry.platinum = atoi(row[27]); - entry.hair_color = atoi(row[28]); - entry.beard_color = atoi(row[29]); - entry.eye_color_1 = atoi(row[30]); - entry.eye_color_2 = atoi(row[31]); - entry.hair_style = atoi(row[32]); - entry.face = atoi(row[33]); - entry.beard = atoi(row[34]); - entry.drakkin_heritage = atoi(row[35]); - entry.drakkin_tattoo = atoi(row[36]); - entry.drakkin_details = atoi(row[37]); - entry.wc_1 = atoi(row[38]); - entry.wc_2 = atoi(row[39]); - entry.wc_3 = atoi(row[40]); - entry.wc_4 = atoi(row[41]); - entry.wc_5 = atoi(row[42]); - entry.wc_6 = atoi(row[43]); - entry.wc_7 = atoi(row[44]); - entry.wc_8 = atoi(row[45]); - entry.wc_9 = atoi(row[46]); + e.id = atoi(row[0]); + e.charid = atoi(row[1]); + e.charname = row[2] ? row[2] : ""; + e.zone_id = atoi(row[3]); + e.instance_id = atoi(row[4]); + e.x = static_cast(atof(row[5])); + e.y = static_cast(atof(row[6])); + e.z = static_cast(atof(row[7])); + e.heading = static_cast(atof(row[8])); + e.time_of_death = strtoll(row[9] ? row[9] : "-1", nullptr, 10); + e.guild_consent_id = atoi(row[10]); + e.is_rezzed = atoi(row[11]); + e.is_buried = atoi(row[12]); + e.was_at_graveyard = atoi(row[13]); + e.is_locked = atoi(row[14]); + e.exp = atoi(row[15]); + e.size = atoi(row[16]); + e.level = atoi(row[17]); + e.race = atoi(row[18]); + e.gender = atoi(row[19]); + e.class_ = atoi(row[20]); + e.deity = atoi(row[21]); + e.texture = atoi(row[22]); + e.helm_texture = atoi(row[23]); + e.copper = atoi(row[24]); + e.silver = atoi(row[25]); + e.gold = atoi(row[26]); + e.platinum = atoi(row[27]); + e.hair_color = atoi(row[28]); + e.beard_color = atoi(row[29]); + e.eye_color_1 = atoi(row[30]); + e.eye_color_2 = atoi(row[31]); + e.hair_style = atoi(row[32]); + e.face = atoi(row[33]); + e.beard = atoi(row[34]); + e.drakkin_heritage = atoi(row[35]); + e.drakkin_tattoo = atoi(row[36]); + e.drakkin_details = atoi(row[37]); + e.wc_1 = atoi(row[38]); + e.wc_2 = atoi(row[39]); + e.wc_3 = atoi(row[40]); + e.wc_4 = atoi(row[41]); + e.wc_5 = atoi(row[42]); + e.wc_6 = atoi(row[43]); + e.wc_7 = atoi(row[44]); + e.wc_8 = atoi(row[45]); + e.wc_9 = atoi(row[46]); - return entry; + return e; } return NewEntity(); @@ -371,67 +371,67 @@ public: static int UpdateOne( Database& db, - CharacterCorpses character_corpses_entry + const CharacterCorpses &e ) { - std::vector update_values; + std::vector v; auto columns = Columns(); - update_values.push_back(columns[1] + " = " + std::to_string(character_corpses_entry.charid)); - update_values.push_back(columns[2] + " = '" + Strings::Escape(character_corpses_entry.charname) + "'"); - update_values.push_back(columns[3] + " = " + std::to_string(character_corpses_entry.zone_id)); - update_values.push_back(columns[4] + " = " + std::to_string(character_corpses_entry.instance_id)); - update_values.push_back(columns[5] + " = " + std::to_string(character_corpses_entry.x)); - update_values.push_back(columns[6] + " = " + std::to_string(character_corpses_entry.y)); - update_values.push_back(columns[7] + " = " + std::to_string(character_corpses_entry.z)); - update_values.push_back(columns[8] + " = " + std::to_string(character_corpses_entry.heading)); - update_values.push_back(columns[9] + " = FROM_UNIXTIME(" + (character_corpses_entry.time_of_death > 0 ? std::to_string(character_corpses_entry.time_of_death) : "null") + ")"); - update_values.push_back(columns[10] + " = " + std::to_string(character_corpses_entry.guild_consent_id)); - update_values.push_back(columns[11] + " = " + std::to_string(character_corpses_entry.is_rezzed)); - update_values.push_back(columns[12] + " = " + std::to_string(character_corpses_entry.is_buried)); - update_values.push_back(columns[13] + " = " + std::to_string(character_corpses_entry.was_at_graveyard)); - update_values.push_back(columns[14] + " = " + std::to_string(character_corpses_entry.is_locked)); - update_values.push_back(columns[15] + " = " + std::to_string(character_corpses_entry.exp)); - update_values.push_back(columns[16] + " = " + std::to_string(character_corpses_entry.size)); - update_values.push_back(columns[17] + " = " + std::to_string(character_corpses_entry.level)); - update_values.push_back(columns[18] + " = " + std::to_string(character_corpses_entry.race)); - update_values.push_back(columns[19] + " = " + std::to_string(character_corpses_entry.gender)); - update_values.push_back(columns[20] + " = " + std::to_string(character_corpses_entry.class_)); - update_values.push_back(columns[21] + " = " + std::to_string(character_corpses_entry.deity)); - update_values.push_back(columns[22] + " = " + std::to_string(character_corpses_entry.texture)); - update_values.push_back(columns[23] + " = " + std::to_string(character_corpses_entry.helm_texture)); - update_values.push_back(columns[24] + " = " + std::to_string(character_corpses_entry.copper)); - update_values.push_back(columns[25] + " = " + std::to_string(character_corpses_entry.silver)); - update_values.push_back(columns[26] + " = " + std::to_string(character_corpses_entry.gold)); - update_values.push_back(columns[27] + " = " + std::to_string(character_corpses_entry.platinum)); - update_values.push_back(columns[28] + " = " + std::to_string(character_corpses_entry.hair_color)); - update_values.push_back(columns[29] + " = " + std::to_string(character_corpses_entry.beard_color)); - update_values.push_back(columns[30] + " = " + std::to_string(character_corpses_entry.eye_color_1)); - update_values.push_back(columns[31] + " = " + std::to_string(character_corpses_entry.eye_color_2)); - update_values.push_back(columns[32] + " = " + std::to_string(character_corpses_entry.hair_style)); - update_values.push_back(columns[33] + " = " + std::to_string(character_corpses_entry.face)); - update_values.push_back(columns[34] + " = " + std::to_string(character_corpses_entry.beard)); - update_values.push_back(columns[35] + " = " + std::to_string(character_corpses_entry.drakkin_heritage)); - update_values.push_back(columns[36] + " = " + std::to_string(character_corpses_entry.drakkin_tattoo)); - update_values.push_back(columns[37] + " = " + std::to_string(character_corpses_entry.drakkin_details)); - update_values.push_back(columns[38] + " = " + std::to_string(character_corpses_entry.wc_1)); - update_values.push_back(columns[39] + " = " + std::to_string(character_corpses_entry.wc_2)); - update_values.push_back(columns[40] + " = " + std::to_string(character_corpses_entry.wc_3)); - update_values.push_back(columns[41] + " = " + std::to_string(character_corpses_entry.wc_4)); - update_values.push_back(columns[42] + " = " + std::to_string(character_corpses_entry.wc_5)); - update_values.push_back(columns[43] + " = " + std::to_string(character_corpses_entry.wc_6)); - update_values.push_back(columns[44] + " = " + std::to_string(character_corpses_entry.wc_7)); - update_values.push_back(columns[45] + " = " + std::to_string(character_corpses_entry.wc_8)); - update_values.push_back(columns[46] + " = " + std::to_string(character_corpses_entry.wc_9)); + v.push_back(columns[1] + " = " + std::to_string(e.charid)); + v.push_back(columns[2] + " = '" + Strings::Escape(e.charname) + "'"); + v.push_back(columns[3] + " = " + std::to_string(e.zone_id)); + v.push_back(columns[4] + " = " + std::to_string(e.instance_id)); + v.push_back(columns[5] + " = " + std::to_string(e.x)); + v.push_back(columns[6] + " = " + std::to_string(e.y)); + v.push_back(columns[7] + " = " + std::to_string(e.z)); + v.push_back(columns[8] + " = " + std::to_string(e.heading)); + v.push_back(columns[9] + " = FROM_UNIXTIME(" + (e.time_of_death > 0 ? std::to_string(e.time_of_death) : "null") + ")"); + v.push_back(columns[10] + " = " + std::to_string(e.guild_consent_id)); + v.push_back(columns[11] + " = " + std::to_string(e.is_rezzed)); + v.push_back(columns[12] + " = " + std::to_string(e.is_buried)); + v.push_back(columns[13] + " = " + std::to_string(e.was_at_graveyard)); + v.push_back(columns[14] + " = " + std::to_string(e.is_locked)); + v.push_back(columns[15] + " = " + std::to_string(e.exp)); + v.push_back(columns[16] + " = " + std::to_string(e.size)); + v.push_back(columns[17] + " = " + std::to_string(e.level)); + v.push_back(columns[18] + " = " + std::to_string(e.race)); + v.push_back(columns[19] + " = " + std::to_string(e.gender)); + v.push_back(columns[20] + " = " + std::to_string(e.class_)); + v.push_back(columns[21] + " = " + std::to_string(e.deity)); + v.push_back(columns[22] + " = " + std::to_string(e.texture)); + v.push_back(columns[23] + " = " + std::to_string(e.helm_texture)); + v.push_back(columns[24] + " = " + std::to_string(e.copper)); + v.push_back(columns[25] + " = " + std::to_string(e.silver)); + v.push_back(columns[26] + " = " + std::to_string(e.gold)); + v.push_back(columns[27] + " = " + std::to_string(e.platinum)); + v.push_back(columns[28] + " = " + std::to_string(e.hair_color)); + v.push_back(columns[29] + " = " + std::to_string(e.beard_color)); + v.push_back(columns[30] + " = " + std::to_string(e.eye_color_1)); + v.push_back(columns[31] + " = " + std::to_string(e.eye_color_2)); + v.push_back(columns[32] + " = " + std::to_string(e.hair_style)); + v.push_back(columns[33] + " = " + std::to_string(e.face)); + v.push_back(columns[34] + " = " + std::to_string(e.beard)); + v.push_back(columns[35] + " = " + std::to_string(e.drakkin_heritage)); + v.push_back(columns[36] + " = " + std::to_string(e.drakkin_tattoo)); + v.push_back(columns[37] + " = " + std::to_string(e.drakkin_details)); + v.push_back(columns[38] + " = " + std::to_string(e.wc_1)); + v.push_back(columns[39] + " = " + std::to_string(e.wc_2)); + v.push_back(columns[40] + " = " + std::to_string(e.wc_3)); + v.push_back(columns[41] + " = " + std::to_string(e.wc_4)); + v.push_back(columns[42] + " = " + std::to_string(e.wc_5)); + v.push_back(columns[43] + " = " + std::to_string(e.wc_6)); + v.push_back(columns[44] + " = " + std::to_string(e.wc_7)); + v.push_back(columns[45] + " = " + std::to_string(e.wc_8)); + v.push_back(columns[46] + " = " + std::to_string(e.wc_9)); auto results = db.QueryDatabase( fmt::format( "UPDATE {} SET {} WHERE {} = {}", TableName(), - Strings::Implode(", ", update_values), + Strings::Implode(", ", v), PrimaryKey(), - character_corpses_entry.id + e.id ) ); @@ -440,139 +440,139 @@ public: static CharacterCorpses InsertOne( Database& db, - CharacterCorpses character_corpses_entry + CharacterCorpses e ) { - std::vector insert_values; + std::vector v; - insert_values.push_back(std::to_string(character_corpses_entry.id)); - insert_values.push_back(std::to_string(character_corpses_entry.charid)); - insert_values.push_back("'" + Strings::Escape(character_corpses_entry.charname) + "'"); - insert_values.push_back(std::to_string(character_corpses_entry.zone_id)); - insert_values.push_back(std::to_string(character_corpses_entry.instance_id)); - insert_values.push_back(std::to_string(character_corpses_entry.x)); - insert_values.push_back(std::to_string(character_corpses_entry.y)); - insert_values.push_back(std::to_string(character_corpses_entry.z)); - insert_values.push_back(std::to_string(character_corpses_entry.heading)); - insert_values.push_back("FROM_UNIXTIME(" + (character_corpses_entry.time_of_death > 0 ? std::to_string(character_corpses_entry.time_of_death) : "null") + ")"); - insert_values.push_back(std::to_string(character_corpses_entry.guild_consent_id)); - insert_values.push_back(std::to_string(character_corpses_entry.is_rezzed)); - insert_values.push_back(std::to_string(character_corpses_entry.is_buried)); - insert_values.push_back(std::to_string(character_corpses_entry.was_at_graveyard)); - insert_values.push_back(std::to_string(character_corpses_entry.is_locked)); - insert_values.push_back(std::to_string(character_corpses_entry.exp)); - insert_values.push_back(std::to_string(character_corpses_entry.size)); - insert_values.push_back(std::to_string(character_corpses_entry.level)); - insert_values.push_back(std::to_string(character_corpses_entry.race)); - insert_values.push_back(std::to_string(character_corpses_entry.gender)); - insert_values.push_back(std::to_string(character_corpses_entry.class_)); - insert_values.push_back(std::to_string(character_corpses_entry.deity)); - insert_values.push_back(std::to_string(character_corpses_entry.texture)); - insert_values.push_back(std::to_string(character_corpses_entry.helm_texture)); - insert_values.push_back(std::to_string(character_corpses_entry.copper)); - insert_values.push_back(std::to_string(character_corpses_entry.silver)); - insert_values.push_back(std::to_string(character_corpses_entry.gold)); - insert_values.push_back(std::to_string(character_corpses_entry.platinum)); - insert_values.push_back(std::to_string(character_corpses_entry.hair_color)); - insert_values.push_back(std::to_string(character_corpses_entry.beard_color)); - insert_values.push_back(std::to_string(character_corpses_entry.eye_color_1)); - insert_values.push_back(std::to_string(character_corpses_entry.eye_color_2)); - insert_values.push_back(std::to_string(character_corpses_entry.hair_style)); - insert_values.push_back(std::to_string(character_corpses_entry.face)); - insert_values.push_back(std::to_string(character_corpses_entry.beard)); - insert_values.push_back(std::to_string(character_corpses_entry.drakkin_heritage)); - insert_values.push_back(std::to_string(character_corpses_entry.drakkin_tattoo)); - insert_values.push_back(std::to_string(character_corpses_entry.drakkin_details)); - insert_values.push_back(std::to_string(character_corpses_entry.wc_1)); - insert_values.push_back(std::to_string(character_corpses_entry.wc_2)); - insert_values.push_back(std::to_string(character_corpses_entry.wc_3)); - insert_values.push_back(std::to_string(character_corpses_entry.wc_4)); - insert_values.push_back(std::to_string(character_corpses_entry.wc_5)); - insert_values.push_back(std::to_string(character_corpses_entry.wc_6)); - insert_values.push_back(std::to_string(character_corpses_entry.wc_7)); - insert_values.push_back(std::to_string(character_corpses_entry.wc_8)); - insert_values.push_back(std::to_string(character_corpses_entry.wc_9)); + v.push_back(std::to_string(e.id)); + v.push_back(std::to_string(e.charid)); + v.push_back("'" + Strings::Escape(e.charname) + "'"); + v.push_back(std::to_string(e.zone_id)); + v.push_back(std::to_string(e.instance_id)); + v.push_back(std::to_string(e.x)); + v.push_back(std::to_string(e.y)); + v.push_back(std::to_string(e.z)); + v.push_back(std::to_string(e.heading)); + v.push_back("FROM_UNIXTIME(" + (e.time_of_death > 0 ? std::to_string(e.time_of_death) : "null") + ")"); + v.push_back(std::to_string(e.guild_consent_id)); + v.push_back(std::to_string(e.is_rezzed)); + v.push_back(std::to_string(e.is_buried)); + v.push_back(std::to_string(e.was_at_graveyard)); + v.push_back(std::to_string(e.is_locked)); + v.push_back(std::to_string(e.exp)); + v.push_back(std::to_string(e.size)); + v.push_back(std::to_string(e.level)); + v.push_back(std::to_string(e.race)); + v.push_back(std::to_string(e.gender)); + v.push_back(std::to_string(e.class_)); + v.push_back(std::to_string(e.deity)); + v.push_back(std::to_string(e.texture)); + v.push_back(std::to_string(e.helm_texture)); + v.push_back(std::to_string(e.copper)); + v.push_back(std::to_string(e.silver)); + v.push_back(std::to_string(e.gold)); + v.push_back(std::to_string(e.platinum)); + v.push_back(std::to_string(e.hair_color)); + v.push_back(std::to_string(e.beard_color)); + v.push_back(std::to_string(e.eye_color_1)); + v.push_back(std::to_string(e.eye_color_2)); + v.push_back(std::to_string(e.hair_style)); + v.push_back(std::to_string(e.face)); + v.push_back(std::to_string(e.beard)); + v.push_back(std::to_string(e.drakkin_heritage)); + v.push_back(std::to_string(e.drakkin_tattoo)); + v.push_back(std::to_string(e.drakkin_details)); + v.push_back(std::to_string(e.wc_1)); + v.push_back(std::to_string(e.wc_2)); + v.push_back(std::to_string(e.wc_3)); + v.push_back(std::to_string(e.wc_4)); + v.push_back(std::to_string(e.wc_5)); + v.push_back(std::to_string(e.wc_6)); + v.push_back(std::to_string(e.wc_7)); + v.push_back(std::to_string(e.wc_8)); + v.push_back(std::to_string(e.wc_9)); auto results = db.QueryDatabase( fmt::format( "{} VALUES ({})", BaseInsert(), - Strings::Implode(",", insert_values) + Strings::Implode(",", v) ) ); if (results.Success()) { - character_corpses_entry.id = results.LastInsertedID(); - return character_corpses_entry; + e.id = results.LastInsertedID(); + return e; } - character_corpses_entry = NewEntity(); + e = NewEntity(); - return character_corpses_entry; + return e; } static int InsertMany( Database& db, - std::vector character_corpses_entries + const std::vector &entries ) { std::vector insert_chunks; - for (auto &character_corpses_entry: character_corpses_entries) { - std::vector insert_values; + for (auto &e: entries) { + std::vector v; - insert_values.push_back(std::to_string(character_corpses_entry.id)); - insert_values.push_back(std::to_string(character_corpses_entry.charid)); - insert_values.push_back("'" + Strings::Escape(character_corpses_entry.charname) + "'"); - insert_values.push_back(std::to_string(character_corpses_entry.zone_id)); - insert_values.push_back(std::to_string(character_corpses_entry.instance_id)); - insert_values.push_back(std::to_string(character_corpses_entry.x)); - insert_values.push_back(std::to_string(character_corpses_entry.y)); - insert_values.push_back(std::to_string(character_corpses_entry.z)); - insert_values.push_back(std::to_string(character_corpses_entry.heading)); - insert_values.push_back("FROM_UNIXTIME(" + (character_corpses_entry.time_of_death > 0 ? std::to_string(character_corpses_entry.time_of_death) : "null") + ")"); - insert_values.push_back(std::to_string(character_corpses_entry.guild_consent_id)); - insert_values.push_back(std::to_string(character_corpses_entry.is_rezzed)); - insert_values.push_back(std::to_string(character_corpses_entry.is_buried)); - insert_values.push_back(std::to_string(character_corpses_entry.was_at_graveyard)); - insert_values.push_back(std::to_string(character_corpses_entry.is_locked)); - insert_values.push_back(std::to_string(character_corpses_entry.exp)); - insert_values.push_back(std::to_string(character_corpses_entry.size)); - insert_values.push_back(std::to_string(character_corpses_entry.level)); - insert_values.push_back(std::to_string(character_corpses_entry.race)); - insert_values.push_back(std::to_string(character_corpses_entry.gender)); - insert_values.push_back(std::to_string(character_corpses_entry.class_)); - insert_values.push_back(std::to_string(character_corpses_entry.deity)); - insert_values.push_back(std::to_string(character_corpses_entry.texture)); - insert_values.push_back(std::to_string(character_corpses_entry.helm_texture)); - insert_values.push_back(std::to_string(character_corpses_entry.copper)); - insert_values.push_back(std::to_string(character_corpses_entry.silver)); - insert_values.push_back(std::to_string(character_corpses_entry.gold)); - insert_values.push_back(std::to_string(character_corpses_entry.platinum)); - insert_values.push_back(std::to_string(character_corpses_entry.hair_color)); - insert_values.push_back(std::to_string(character_corpses_entry.beard_color)); - insert_values.push_back(std::to_string(character_corpses_entry.eye_color_1)); - insert_values.push_back(std::to_string(character_corpses_entry.eye_color_2)); - insert_values.push_back(std::to_string(character_corpses_entry.hair_style)); - insert_values.push_back(std::to_string(character_corpses_entry.face)); - insert_values.push_back(std::to_string(character_corpses_entry.beard)); - insert_values.push_back(std::to_string(character_corpses_entry.drakkin_heritage)); - insert_values.push_back(std::to_string(character_corpses_entry.drakkin_tattoo)); - insert_values.push_back(std::to_string(character_corpses_entry.drakkin_details)); - insert_values.push_back(std::to_string(character_corpses_entry.wc_1)); - insert_values.push_back(std::to_string(character_corpses_entry.wc_2)); - insert_values.push_back(std::to_string(character_corpses_entry.wc_3)); - insert_values.push_back(std::to_string(character_corpses_entry.wc_4)); - insert_values.push_back(std::to_string(character_corpses_entry.wc_5)); - insert_values.push_back(std::to_string(character_corpses_entry.wc_6)); - insert_values.push_back(std::to_string(character_corpses_entry.wc_7)); - insert_values.push_back(std::to_string(character_corpses_entry.wc_8)); - insert_values.push_back(std::to_string(character_corpses_entry.wc_9)); + v.push_back(std::to_string(e.id)); + v.push_back(std::to_string(e.charid)); + v.push_back("'" + Strings::Escape(e.charname) + "'"); + v.push_back(std::to_string(e.zone_id)); + v.push_back(std::to_string(e.instance_id)); + v.push_back(std::to_string(e.x)); + v.push_back(std::to_string(e.y)); + v.push_back(std::to_string(e.z)); + v.push_back(std::to_string(e.heading)); + v.push_back("FROM_UNIXTIME(" + (e.time_of_death > 0 ? std::to_string(e.time_of_death) : "null") + ")"); + v.push_back(std::to_string(e.guild_consent_id)); + v.push_back(std::to_string(e.is_rezzed)); + v.push_back(std::to_string(e.is_buried)); + v.push_back(std::to_string(e.was_at_graveyard)); + v.push_back(std::to_string(e.is_locked)); + v.push_back(std::to_string(e.exp)); + v.push_back(std::to_string(e.size)); + v.push_back(std::to_string(e.level)); + v.push_back(std::to_string(e.race)); + v.push_back(std::to_string(e.gender)); + v.push_back(std::to_string(e.class_)); + v.push_back(std::to_string(e.deity)); + v.push_back(std::to_string(e.texture)); + v.push_back(std::to_string(e.helm_texture)); + v.push_back(std::to_string(e.copper)); + v.push_back(std::to_string(e.silver)); + v.push_back(std::to_string(e.gold)); + v.push_back(std::to_string(e.platinum)); + v.push_back(std::to_string(e.hair_color)); + v.push_back(std::to_string(e.beard_color)); + v.push_back(std::to_string(e.eye_color_1)); + v.push_back(std::to_string(e.eye_color_2)); + v.push_back(std::to_string(e.hair_style)); + v.push_back(std::to_string(e.face)); + v.push_back(std::to_string(e.beard)); + v.push_back(std::to_string(e.drakkin_heritage)); + v.push_back(std::to_string(e.drakkin_tattoo)); + v.push_back(std::to_string(e.drakkin_details)); + v.push_back(std::to_string(e.wc_1)); + v.push_back(std::to_string(e.wc_2)); + v.push_back(std::to_string(e.wc_3)); + v.push_back(std::to_string(e.wc_4)); + v.push_back(std::to_string(e.wc_5)); + v.push_back(std::to_string(e.wc_6)); + v.push_back(std::to_string(e.wc_7)); + v.push_back(std::to_string(e.wc_8)); + v.push_back(std::to_string(e.wc_9)); - insert_chunks.push_back("(" + Strings::Implode(",", insert_values) + ")"); + insert_chunks.push_back("(" + Strings::Implode(",", v) + ")"); } - std::vector insert_values; + std::vector v; auto results = db.QueryDatabase( fmt::format( @@ -599,63 +599,63 @@ public: all_entries.reserve(results.RowCount()); for (auto row = results.begin(); row != results.end(); ++row) { - CharacterCorpses entry{}; + CharacterCorpses e{}; - entry.id = atoi(row[0]); - entry.charid = atoi(row[1]); - entry.charname = row[2] ? row[2] : ""; - entry.zone_id = atoi(row[3]); - entry.instance_id = atoi(row[4]); - entry.x = static_cast(atof(row[5])); - entry.y = static_cast(atof(row[6])); - entry.z = static_cast(atof(row[7])); - entry.heading = static_cast(atof(row[8])); - entry.time_of_death = strtoll(row[9] ? row[9] : "-1", nullptr, 10); - entry.guild_consent_id = atoi(row[10]); - entry.is_rezzed = atoi(row[11]); - entry.is_buried = atoi(row[12]); - entry.was_at_graveyard = atoi(row[13]); - entry.is_locked = atoi(row[14]); - entry.exp = atoi(row[15]); - entry.size = atoi(row[16]); - entry.level = atoi(row[17]); - entry.race = atoi(row[18]); - entry.gender = atoi(row[19]); - entry.class_ = atoi(row[20]); - entry.deity = atoi(row[21]); - entry.texture = atoi(row[22]); - entry.helm_texture = atoi(row[23]); - entry.copper = atoi(row[24]); - entry.silver = atoi(row[25]); - entry.gold = atoi(row[26]); - entry.platinum = atoi(row[27]); - entry.hair_color = atoi(row[28]); - entry.beard_color = atoi(row[29]); - entry.eye_color_1 = atoi(row[30]); - entry.eye_color_2 = atoi(row[31]); - entry.hair_style = atoi(row[32]); - entry.face = atoi(row[33]); - entry.beard = atoi(row[34]); - entry.drakkin_heritage = atoi(row[35]); - entry.drakkin_tattoo = atoi(row[36]); - entry.drakkin_details = atoi(row[37]); - entry.wc_1 = atoi(row[38]); - entry.wc_2 = atoi(row[39]); - entry.wc_3 = atoi(row[40]); - entry.wc_4 = atoi(row[41]); - entry.wc_5 = atoi(row[42]); - entry.wc_6 = atoi(row[43]); - entry.wc_7 = atoi(row[44]); - entry.wc_8 = atoi(row[45]); - entry.wc_9 = atoi(row[46]); + e.id = atoi(row[0]); + e.charid = atoi(row[1]); + e.charname = row[2] ? row[2] : ""; + e.zone_id = atoi(row[3]); + e.instance_id = atoi(row[4]); + e.x = static_cast(atof(row[5])); + e.y = static_cast(atof(row[6])); + e.z = static_cast(atof(row[7])); + e.heading = static_cast(atof(row[8])); + e.time_of_death = strtoll(row[9] ? row[9] : "-1", nullptr, 10); + e.guild_consent_id = atoi(row[10]); + e.is_rezzed = atoi(row[11]); + e.is_buried = atoi(row[12]); + e.was_at_graveyard = atoi(row[13]); + e.is_locked = atoi(row[14]); + e.exp = atoi(row[15]); + e.size = atoi(row[16]); + e.level = atoi(row[17]); + e.race = atoi(row[18]); + e.gender = atoi(row[19]); + e.class_ = atoi(row[20]); + e.deity = atoi(row[21]); + e.texture = atoi(row[22]); + e.helm_texture = atoi(row[23]); + e.copper = atoi(row[24]); + e.silver = atoi(row[25]); + e.gold = atoi(row[26]); + e.platinum = atoi(row[27]); + e.hair_color = atoi(row[28]); + e.beard_color = atoi(row[29]); + e.eye_color_1 = atoi(row[30]); + e.eye_color_2 = atoi(row[31]); + e.hair_style = atoi(row[32]); + e.face = atoi(row[33]); + e.beard = atoi(row[34]); + e.drakkin_heritage = atoi(row[35]); + e.drakkin_tattoo = atoi(row[36]); + e.drakkin_details = atoi(row[37]); + e.wc_1 = atoi(row[38]); + e.wc_2 = atoi(row[39]); + e.wc_3 = atoi(row[40]); + e.wc_4 = atoi(row[41]); + e.wc_5 = atoi(row[42]); + e.wc_6 = atoi(row[43]); + e.wc_7 = atoi(row[44]); + e.wc_8 = atoi(row[45]); + e.wc_9 = atoi(row[46]); - all_entries.push_back(entry); + all_entries.push_back(e); } return all_entries; } - static std::vector GetWhere(Database& db, std::string where_filter) + static std::vector GetWhere(Database& db, const std::string &where_filter) { std::vector all_entries; @@ -670,63 +670,63 @@ public: all_entries.reserve(results.RowCount()); for (auto row = results.begin(); row != results.end(); ++row) { - CharacterCorpses entry{}; + CharacterCorpses e{}; - entry.id = atoi(row[0]); - entry.charid = atoi(row[1]); - entry.charname = row[2] ? row[2] : ""; - entry.zone_id = atoi(row[3]); - entry.instance_id = atoi(row[4]); - entry.x = static_cast(atof(row[5])); - entry.y = static_cast(atof(row[6])); - entry.z = static_cast(atof(row[7])); - entry.heading = static_cast(atof(row[8])); - entry.time_of_death = strtoll(row[9] ? row[9] : "-1", nullptr, 10); - entry.guild_consent_id = atoi(row[10]); - entry.is_rezzed = atoi(row[11]); - entry.is_buried = atoi(row[12]); - entry.was_at_graveyard = atoi(row[13]); - entry.is_locked = atoi(row[14]); - entry.exp = atoi(row[15]); - entry.size = atoi(row[16]); - entry.level = atoi(row[17]); - entry.race = atoi(row[18]); - entry.gender = atoi(row[19]); - entry.class_ = atoi(row[20]); - entry.deity = atoi(row[21]); - entry.texture = atoi(row[22]); - entry.helm_texture = atoi(row[23]); - entry.copper = atoi(row[24]); - entry.silver = atoi(row[25]); - entry.gold = atoi(row[26]); - entry.platinum = atoi(row[27]); - entry.hair_color = atoi(row[28]); - entry.beard_color = atoi(row[29]); - entry.eye_color_1 = atoi(row[30]); - entry.eye_color_2 = atoi(row[31]); - entry.hair_style = atoi(row[32]); - entry.face = atoi(row[33]); - entry.beard = atoi(row[34]); - entry.drakkin_heritage = atoi(row[35]); - entry.drakkin_tattoo = atoi(row[36]); - entry.drakkin_details = atoi(row[37]); - entry.wc_1 = atoi(row[38]); - entry.wc_2 = atoi(row[39]); - entry.wc_3 = atoi(row[40]); - entry.wc_4 = atoi(row[41]); - entry.wc_5 = atoi(row[42]); - entry.wc_6 = atoi(row[43]); - entry.wc_7 = atoi(row[44]); - entry.wc_8 = atoi(row[45]); - entry.wc_9 = atoi(row[46]); + e.id = atoi(row[0]); + e.charid = atoi(row[1]); + e.charname = row[2] ? row[2] : ""; + e.zone_id = atoi(row[3]); + e.instance_id = atoi(row[4]); + e.x = static_cast(atof(row[5])); + e.y = static_cast(atof(row[6])); + e.z = static_cast(atof(row[7])); + e.heading = static_cast(atof(row[8])); + e.time_of_death = strtoll(row[9] ? row[9] : "-1", nullptr, 10); + e.guild_consent_id = atoi(row[10]); + e.is_rezzed = atoi(row[11]); + e.is_buried = atoi(row[12]); + e.was_at_graveyard = atoi(row[13]); + e.is_locked = atoi(row[14]); + e.exp = atoi(row[15]); + e.size = atoi(row[16]); + e.level = atoi(row[17]); + e.race = atoi(row[18]); + e.gender = atoi(row[19]); + e.class_ = atoi(row[20]); + e.deity = atoi(row[21]); + e.texture = atoi(row[22]); + e.helm_texture = atoi(row[23]); + e.copper = atoi(row[24]); + e.silver = atoi(row[25]); + e.gold = atoi(row[26]); + e.platinum = atoi(row[27]); + e.hair_color = atoi(row[28]); + e.beard_color = atoi(row[29]); + e.eye_color_1 = atoi(row[30]); + e.eye_color_2 = atoi(row[31]); + e.hair_style = atoi(row[32]); + e.face = atoi(row[33]); + e.beard = atoi(row[34]); + e.drakkin_heritage = atoi(row[35]); + e.drakkin_tattoo = atoi(row[36]); + e.drakkin_details = atoi(row[37]); + e.wc_1 = atoi(row[38]); + e.wc_2 = atoi(row[39]); + e.wc_3 = atoi(row[40]); + e.wc_4 = atoi(row[41]); + e.wc_5 = atoi(row[42]); + e.wc_6 = atoi(row[43]); + e.wc_7 = atoi(row[44]); + e.wc_8 = atoi(row[45]); + e.wc_9 = atoi(row[46]); - all_entries.push_back(entry); + all_entries.push_back(e); } return all_entries; } - static int DeleteWhere(Database& db, std::string where_filter) + static int DeleteWhere(Database& db, const std::string &where_filter) { auto results = db.QueryDatabase( fmt::format( @@ -751,6 +751,32 @@ public: 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); + } + }; #endif //EQEMU_BASE_CHARACTER_CORPSES_REPOSITORY_H diff --git a/common/repositories/base/base_character_currency_repository.h b/common/repositories/base/base_character_currency_repository.h index aeee5fad4..bf5a9407f 100644 --- a/common/repositories/base/base_character_currency_repository.h +++ b/common/repositories/base/base_character_currency_repository.h @@ -124,30 +124,30 @@ public: static CharacterCurrency NewEntity() { - CharacterCurrency entry{}; + CharacterCurrency e{}; - entry.id = 0; - entry.platinum = 0; - entry.gold = 0; - entry.silver = 0; - entry.copper = 0; - entry.platinum_bank = 0; - entry.gold_bank = 0; - entry.silver_bank = 0; - entry.copper_bank = 0; - entry.platinum_cursor = 0; - entry.gold_cursor = 0; - entry.silver_cursor = 0; - entry.copper_cursor = 0; - entry.radiant_crystals = 0; - entry.career_radiant_crystals = 0; - entry.ebon_crystals = 0; - entry.career_ebon_crystals = 0; + e.id = 0; + e.platinum = 0; + e.gold = 0; + e.silver = 0; + e.copper = 0; + e.platinum_bank = 0; + e.gold_bank = 0; + e.silver_bank = 0; + e.copper_bank = 0; + e.platinum_cursor = 0; + e.gold_cursor = 0; + e.silver_cursor = 0; + e.copper_cursor = 0; + e.radiant_crystals = 0; + e.career_radiant_crystals = 0; + e.ebon_crystals = 0; + e.career_ebon_crystals = 0; - return entry; + return e; } - static CharacterCurrency GetCharacterCurrencyEntry( + static CharacterCurrency GetCharacterCurrency( const std::vector &character_currencys, int character_currency_id ) @@ -176,27 +176,27 @@ public: auto row = results.begin(); if (results.RowCount() == 1) { - CharacterCurrency entry{}; + CharacterCurrency e{}; - entry.id = atoi(row[0]); - entry.platinum = atoi(row[1]); - entry.gold = atoi(row[2]); - entry.silver = atoi(row[3]); - entry.copper = atoi(row[4]); - entry.platinum_bank = atoi(row[5]); - entry.gold_bank = atoi(row[6]); - entry.silver_bank = atoi(row[7]); - entry.copper_bank = atoi(row[8]); - entry.platinum_cursor = atoi(row[9]); - entry.gold_cursor = atoi(row[10]); - entry.silver_cursor = atoi(row[11]); - entry.copper_cursor = atoi(row[12]); - entry.radiant_crystals = atoi(row[13]); - entry.career_radiant_crystals = atoi(row[14]); - entry.ebon_crystals = atoi(row[15]); - entry.career_ebon_crystals = atoi(row[16]); + e.id = atoi(row[0]); + e.platinum = atoi(row[1]); + e.gold = atoi(row[2]); + e.silver = atoi(row[3]); + e.copper = atoi(row[4]); + e.platinum_bank = atoi(row[5]); + e.gold_bank = atoi(row[6]); + e.silver_bank = atoi(row[7]); + e.copper_bank = atoi(row[8]); + e.platinum_cursor = atoi(row[9]); + e.gold_cursor = atoi(row[10]); + e.silver_cursor = atoi(row[11]); + e.copper_cursor = atoi(row[12]); + e.radiant_crystals = atoi(row[13]); + e.career_radiant_crystals = atoi(row[14]); + e.ebon_crystals = atoi(row[15]); + e.career_ebon_crystals = atoi(row[16]); - return entry; + return e; } return NewEntity(); @@ -221,38 +221,38 @@ public: static int UpdateOne( Database& db, - CharacterCurrency character_currency_entry + const CharacterCurrency &e ) { - std::vector update_values; + std::vector v; auto columns = Columns(); - update_values.push_back(columns[0] + " = " + std::to_string(character_currency_entry.id)); - update_values.push_back(columns[1] + " = " + std::to_string(character_currency_entry.platinum)); - update_values.push_back(columns[2] + " = " + std::to_string(character_currency_entry.gold)); - update_values.push_back(columns[3] + " = " + std::to_string(character_currency_entry.silver)); - update_values.push_back(columns[4] + " = " + std::to_string(character_currency_entry.copper)); - update_values.push_back(columns[5] + " = " + std::to_string(character_currency_entry.platinum_bank)); - update_values.push_back(columns[6] + " = " + std::to_string(character_currency_entry.gold_bank)); - update_values.push_back(columns[7] + " = " + std::to_string(character_currency_entry.silver_bank)); - update_values.push_back(columns[8] + " = " + std::to_string(character_currency_entry.copper_bank)); - update_values.push_back(columns[9] + " = " + std::to_string(character_currency_entry.platinum_cursor)); - update_values.push_back(columns[10] + " = " + std::to_string(character_currency_entry.gold_cursor)); - update_values.push_back(columns[11] + " = " + std::to_string(character_currency_entry.silver_cursor)); - update_values.push_back(columns[12] + " = " + std::to_string(character_currency_entry.copper_cursor)); - update_values.push_back(columns[13] + " = " + std::to_string(character_currency_entry.radiant_crystals)); - update_values.push_back(columns[14] + " = " + std::to_string(character_currency_entry.career_radiant_crystals)); - update_values.push_back(columns[15] + " = " + std::to_string(character_currency_entry.ebon_crystals)); - update_values.push_back(columns[16] + " = " + std::to_string(character_currency_entry.career_ebon_crystals)); + v.push_back(columns[0] + " = " + std::to_string(e.id)); + v.push_back(columns[1] + " = " + std::to_string(e.platinum)); + v.push_back(columns[2] + " = " + std::to_string(e.gold)); + v.push_back(columns[3] + " = " + std::to_string(e.silver)); + v.push_back(columns[4] + " = " + std::to_string(e.copper)); + v.push_back(columns[5] + " = " + std::to_string(e.platinum_bank)); + v.push_back(columns[6] + " = " + std::to_string(e.gold_bank)); + v.push_back(columns[7] + " = " + std::to_string(e.silver_bank)); + v.push_back(columns[8] + " = " + std::to_string(e.copper_bank)); + v.push_back(columns[9] + " = " + std::to_string(e.platinum_cursor)); + v.push_back(columns[10] + " = " + std::to_string(e.gold_cursor)); + v.push_back(columns[11] + " = " + std::to_string(e.silver_cursor)); + v.push_back(columns[12] + " = " + std::to_string(e.copper_cursor)); + v.push_back(columns[13] + " = " + std::to_string(e.radiant_crystals)); + v.push_back(columns[14] + " = " + std::to_string(e.career_radiant_crystals)); + v.push_back(columns[15] + " = " + std::to_string(e.ebon_crystals)); + v.push_back(columns[16] + " = " + std::to_string(e.career_ebon_crystals)); auto results = db.QueryDatabase( fmt::format( "UPDATE {} SET {} WHERE {} = {}", TableName(), - Strings::Implode(", ", update_values), + Strings::Implode(", ", v), PrimaryKey(), - character_currency_entry.id + e.id ) ); @@ -261,79 +261,79 @@ public: static CharacterCurrency InsertOne( Database& db, - CharacterCurrency character_currency_entry + CharacterCurrency e ) { - std::vector insert_values; + std::vector v; - insert_values.push_back(std::to_string(character_currency_entry.id)); - insert_values.push_back(std::to_string(character_currency_entry.platinum)); - insert_values.push_back(std::to_string(character_currency_entry.gold)); - insert_values.push_back(std::to_string(character_currency_entry.silver)); - insert_values.push_back(std::to_string(character_currency_entry.copper)); - insert_values.push_back(std::to_string(character_currency_entry.platinum_bank)); - insert_values.push_back(std::to_string(character_currency_entry.gold_bank)); - insert_values.push_back(std::to_string(character_currency_entry.silver_bank)); - insert_values.push_back(std::to_string(character_currency_entry.copper_bank)); - insert_values.push_back(std::to_string(character_currency_entry.platinum_cursor)); - insert_values.push_back(std::to_string(character_currency_entry.gold_cursor)); - insert_values.push_back(std::to_string(character_currency_entry.silver_cursor)); - insert_values.push_back(std::to_string(character_currency_entry.copper_cursor)); - insert_values.push_back(std::to_string(character_currency_entry.radiant_crystals)); - insert_values.push_back(std::to_string(character_currency_entry.career_radiant_crystals)); - insert_values.push_back(std::to_string(character_currency_entry.ebon_crystals)); - insert_values.push_back(std::to_string(character_currency_entry.career_ebon_crystals)); + v.push_back(std::to_string(e.id)); + v.push_back(std::to_string(e.platinum)); + v.push_back(std::to_string(e.gold)); + v.push_back(std::to_string(e.silver)); + v.push_back(std::to_string(e.copper)); + v.push_back(std::to_string(e.platinum_bank)); + v.push_back(std::to_string(e.gold_bank)); + v.push_back(std::to_string(e.silver_bank)); + v.push_back(std::to_string(e.copper_bank)); + v.push_back(std::to_string(e.platinum_cursor)); + v.push_back(std::to_string(e.gold_cursor)); + v.push_back(std::to_string(e.silver_cursor)); + v.push_back(std::to_string(e.copper_cursor)); + v.push_back(std::to_string(e.radiant_crystals)); + v.push_back(std::to_string(e.career_radiant_crystals)); + v.push_back(std::to_string(e.ebon_crystals)); + v.push_back(std::to_string(e.career_ebon_crystals)); auto results = db.QueryDatabase( fmt::format( "{} VALUES ({})", BaseInsert(), - Strings::Implode(",", insert_values) + Strings::Implode(",", v) ) ); if (results.Success()) { - character_currency_entry.id = results.LastInsertedID(); - return character_currency_entry; + e.id = results.LastInsertedID(); + return e; } - character_currency_entry = NewEntity(); + e = NewEntity(); - return character_currency_entry; + return e; } static int InsertMany( Database& db, - std::vector character_currency_entries + const std::vector &entries ) { std::vector insert_chunks; - for (auto &character_currency_entry: character_currency_entries) { - std::vector insert_values; + for (auto &e: entries) { + std::vector v; - insert_values.push_back(std::to_string(character_currency_entry.id)); - insert_values.push_back(std::to_string(character_currency_entry.platinum)); - insert_values.push_back(std::to_string(character_currency_entry.gold)); - insert_values.push_back(std::to_string(character_currency_entry.silver)); - insert_values.push_back(std::to_string(character_currency_entry.copper)); - insert_values.push_back(std::to_string(character_currency_entry.platinum_bank)); - insert_values.push_back(std::to_string(character_currency_entry.gold_bank)); - insert_values.push_back(std::to_string(character_currency_entry.silver_bank)); - insert_values.push_back(std::to_string(character_currency_entry.copper_bank)); - insert_values.push_back(std::to_string(character_currency_entry.platinum_cursor)); - insert_values.push_back(std::to_string(character_currency_entry.gold_cursor)); - insert_values.push_back(std::to_string(character_currency_entry.silver_cursor)); - insert_values.push_back(std::to_string(character_currency_entry.copper_cursor)); - insert_values.push_back(std::to_string(character_currency_entry.radiant_crystals)); - insert_values.push_back(std::to_string(character_currency_entry.career_radiant_crystals)); - insert_values.push_back(std::to_string(character_currency_entry.ebon_crystals)); - insert_values.push_back(std::to_string(character_currency_entry.career_ebon_crystals)); + v.push_back(std::to_string(e.id)); + v.push_back(std::to_string(e.platinum)); + v.push_back(std::to_string(e.gold)); + v.push_back(std::to_string(e.silver)); + v.push_back(std::to_string(e.copper)); + v.push_back(std::to_string(e.platinum_bank)); + v.push_back(std::to_string(e.gold_bank)); + v.push_back(std::to_string(e.silver_bank)); + v.push_back(std::to_string(e.copper_bank)); + v.push_back(std::to_string(e.platinum_cursor)); + v.push_back(std::to_string(e.gold_cursor)); + v.push_back(std::to_string(e.silver_cursor)); + v.push_back(std::to_string(e.copper_cursor)); + v.push_back(std::to_string(e.radiant_crystals)); + v.push_back(std::to_string(e.career_radiant_crystals)); + v.push_back(std::to_string(e.ebon_crystals)); + v.push_back(std::to_string(e.career_ebon_crystals)); - insert_chunks.push_back("(" + Strings::Implode(",", insert_values) + ")"); + insert_chunks.push_back("(" + Strings::Implode(",", v) + ")"); } - std::vector insert_values; + std::vector v; auto results = db.QueryDatabase( fmt::format( @@ -360,33 +360,33 @@ public: all_entries.reserve(results.RowCount()); for (auto row = results.begin(); row != results.end(); ++row) { - CharacterCurrency entry{}; + CharacterCurrency e{}; - entry.id = atoi(row[0]); - entry.platinum = atoi(row[1]); - entry.gold = atoi(row[2]); - entry.silver = atoi(row[3]); - entry.copper = atoi(row[4]); - entry.platinum_bank = atoi(row[5]); - entry.gold_bank = atoi(row[6]); - entry.silver_bank = atoi(row[7]); - entry.copper_bank = atoi(row[8]); - entry.platinum_cursor = atoi(row[9]); - entry.gold_cursor = atoi(row[10]); - entry.silver_cursor = atoi(row[11]); - entry.copper_cursor = atoi(row[12]); - entry.radiant_crystals = atoi(row[13]); - entry.career_radiant_crystals = atoi(row[14]); - entry.ebon_crystals = atoi(row[15]); - entry.career_ebon_crystals = atoi(row[16]); + e.id = atoi(row[0]); + e.platinum = atoi(row[1]); + e.gold = atoi(row[2]); + e.silver = atoi(row[3]); + e.copper = atoi(row[4]); + e.platinum_bank = atoi(row[5]); + e.gold_bank = atoi(row[6]); + e.silver_bank = atoi(row[7]); + e.copper_bank = atoi(row[8]); + e.platinum_cursor = atoi(row[9]); + e.gold_cursor = atoi(row[10]); + e.silver_cursor = atoi(row[11]); + e.copper_cursor = atoi(row[12]); + e.radiant_crystals = atoi(row[13]); + e.career_radiant_crystals = atoi(row[14]); + e.ebon_crystals = atoi(row[15]); + e.career_ebon_crystals = atoi(row[16]); - all_entries.push_back(entry); + all_entries.push_back(e); } return all_entries; } - static std::vector GetWhere(Database& db, std::string where_filter) + static std::vector GetWhere(Database& db, const std::string &where_filter) { std::vector all_entries; @@ -401,33 +401,33 @@ public: all_entries.reserve(results.RowCount()); for (auto row = results.begin(); row != results.end(); ++row) { - CharacterCurrency entry{}; + CharacterCurrency e{}; - entry.id = atoi(row[0]); - entry.platinum = atoi(row[1]); - entry.gold = atoi(row[2]); - entry.silver = atoi(row[3]); - entry.copper = atoi(row[4]); - entry.platinum_bank = atoi(row[5]); - entry.gold_bank = atoi(row[6]); - entry.silver_bank = atoi(row[7]); - entry.copper_bank = atoi(row[8]); - entry.platinum_cursor = atoi(row[9]); - entry.gold_cursor = atoi(row[10]); - entry.silver_cursor = atoi(row[11]); - entry.copper_cursor = atoi(row[12]); - entry.radiant_crystals = atoi(row[13]); - entry.career_radiant_crystals = atoi(row[14]); - entry.ebon_crystals = atoi(row[15]); - entry.career_ebon_crystals = atoi(row[16]); + e.id = atoi(row[0]); + e.platinum = atoi(row[1]); + e.gold = atoi(row[2]); + e.silver = atoi(row[3]); + e.copper = atoi(row[4]); + e.platinum_bank = atoi(row[5]); + e.gold_bank = atoi(row[6]); + e.silver_bank = atoi(row[7]); + e.copper_bank = atoi(row[8]); + e.platinum_cursor = atoi(row[9]); + e.gold_cursor = atoi(row[10]); + e.silver_cursor = atoi(row[11]); + e.copper_cursor = atoi(row[12]); + e.radiant_crystals = atoi(row[13]); + e.career_radiant_crystals = atoi(row[14]); + e.ebon_crystals = atoi(row[15]); + e.career_ebon_crystals = atoi(row[16]); - all_entries.push_back(entry); + all_entries.push_back(e); } return all_entries; } - static int DeleteWhere(Database& db, std::string where_filter) + static int DeleteWhere(Database& db, const std::string &where_filter) { auto results = db.QueryDatabase( fmt::format( @@ -452,6 +452,32 @@ public: 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); + } + }; #endif //EQEMU_BASE_CHARACTER_CURRENCY_REPOSITORY_H diff --git a/common/repositories/base/base_character_data_repository.h b/common/repositories/base/base_character_data_repository.h index 29d4ae70c..1ed94e402 100644 --- a/common/repositories/base/base_character_data_repository.h +++ b/common/repositories/base/base_character_data_repository.h @@ -379,115 +379,115 @@ public: static CharacterData NewEntity() { - CharacterData entry{}; + CharacterData e{}; - entry.id = 0; - entry.account_id = 0; - entry.name = ""; - entry.last_name = ""; - entry.title = ""; - entry.suffix = ""; - entry.zone_id = 0; - entry.zone_instance = 0; - entry.y = 0; - entry.x = 0; - entry.z = 0; - entry.heading = 0; - entry.gender = 0; - entry.race = 0; - entry.class_ = 0; - entry.level = 0; - entry.deity = 0; - entry.birthday = 0; - entry.last_login = 0; - entry.time_played = 0; - entry.level2 = 0; - entry.anon = 0; - entry.gm = 0; - entry.face = 0; - entry.hair_color = 0; - entry.hair_style = 0; - entry.beard = 0; - entry.beard_color = 0; - entry.eye_color_1 = 0; - entry.eye_color_2 = 0; - entry.drakkin_heritage = 0; - entry.drakkin_tattoo = 0; - entry.drakkin_details = 0; - entry.ability_time_seconds = 0; - entry.ability_number = 0; - entry.ability_time_minutes = 0; - entry.ability_time_hours = 0; - entry.exp = 0; - entry.aa_points_spent = 0; - entry.aa_exp = 0; - entry.aa_points = 0; - entry.group_leadership_exp = 0; - entry.raid_leadership_exp = 0; - entry.group_leadership_points = 0; - entry.raid_leadership_points = 0; - entry.points = 0; - entry.cur_hp = 0; - entry.mana = 0; - entry.endurance = 0; - entry.intoxication = 0; - entry.str = 0; - entry.sta = 0; - entry.cha = 0; - entry.dex = 0; - entry.int_ = 0; - entry.agi = 0; - entry.wis = 0; - entry.zone_change_count = 0; - entry.toxicity = 0; - entry.hunger_level = 0; - entry.thirst_level = 0; - entry.ability_up = 0; - entry.ldon_points_guk = 0; - entry.ldon_points_mir = 0; - entry.ldon_points_mmc = 0; - entry.ldon_points_ruj = 0; - entry.ldon_points_tak = 0; - entry.ldon_points_available = 0; - entry.tribute_time_remaining = 0; - entry.career_tribute_points = 0; - entry.tribute_points = 0; - entry.tribute_active = 0; - entry.pvp_status = 0; - entry.pvp_kills = 0; - entry.pvp_deaths = 0; - entry.pvp_current_points = 0; - entry.pvp_career_points = 0; - entry.pvp_best_kill_streak = 0; - entry.pvp_worst_death_streak = 0; - entry.pvp_current_kill_streak = 0; - entry.pvp2 = 0; - entry.pvp_type = 0; - entry.show_helm = 0; - entry.group_auto_consent = 0; - entry.raid_auto_consent = 0; - entry.guild_auto_consent = 0; - entry.leadership_exp_on = 0; - entry.RestTimer = 0; - entry.air_remaining = 0; - entry.autosplit_enabled = 0; - entry.lfp = 0; - entry.lfg = 0; - entry.mailkey = ""; - entry.xtargets = 5; - entry.firstlogon = 0; - entry.e_aa_effects = 0; - entry.e_percent_to_aa = 0; - entry.e_expended_aa_spent = 0; - entry.aa_points_spent_old = 0; - entry.aa_points_old = 0; - entry.e_last_invsnapshot = 0; - entry.deleted_at = 0; + e.id = 0; + e.account_id = 0; + e.name = ""; + e.last_name = ""; + e.title = ""; + e.suffix = ""; + e.zone_id = 0; + e.zone_instance = 0; + e.y = 0; + e.x = 0; + e.z = 0; + e.heading = 0; + e.gender = 0; + e.race = 0; + e.class_ = 0; + e.level = 0; + e.deity = 0; + e.birthday = 0; + e.last_login = 0; + e.time_played = 0; + e.level2 = 0; + e.anon = 0; + e.gm = 0; + e.face = 0; + e.hair_color = 0; + e.hair_style = 0; + e.beard = 0; + e.beard_color = 0; + e.eye_color_1 = 0; + e.eye_color_2 = 0; + e.drakkin_heritage = 0; + e.drakkin_tattoo = 0; + e.drakkin_details = 0; + e.ability_time_seconds = 0; + e.ability_number = 0; + e.ability_time_minutes = 0; + e.ability_time_hours = 0; + e.exp = 0; + e.aa_points_spent = 0; + e.aa_exp = 0; + e.aa_points = 0; + e.group_leadership_exp = 0; + e.raid_leadership_exp = 0; + e.group_leadership_points = 0; + e.raid_leadership_points = 0; + e.points = 0; + e.cur_hp = 0; + e.mana = 0; + e.endurance = 0; + e.intoxication = 0; + e.str = 0; + e.sta = 0; + e.cha = 0; + e.dex = 0; + e.int_ = 0; + e.agi = 0; + e.wis = 0; + e.zone_change_count = 0; + e.toxicity = 0; + e.hunger_level = 0; + e.thirst_level = 0; + e.ability_up = 0; + e.ldon_points_guk = 0; + e.ldon_points_mir = 0; + e.ldon_points_mmc = 0; + e.ldon_points_ruj = 0; + e.ldon_points_tak = 0; + e.ldon_points_available = 0; + e.tribute_time_remaining = 0; + e.career_tribute_points = 0; + e.tribute_points = 0; + e.tribute_active = 0; + e.pvp_status = 0; + e.pvp_kills = 0; + e.pvp_deaths = 0; + e.pvp_current_points = 0; + e.pvp_career_points = 0; + e.pvp_best_kill_streak = 0; + e.pvp_worst_death_streak = 0; + e.pvp_current_kill_streak = 0; + e.pvp2 = 0; + e.pvp_type = 0; + e.show_helm = 0; + e.group_auto_consent = 0; + e.raid_auto_consent = 0; + e.guild_auto_consent = 0; + e.leadership_exp_on = 0; + e.RestTimer = 0; + e.air_remaining = 0; + e.autosplit_enabled = 0; + e.lfp = 0; + e.lfg = 0; + e.mailkey = ""; + e.xtargets = 5; + e.firstlogon = 0; + e.e_aa_effects = 0; + e.e_percent_to_aa = 0; + e.e_expended_aa_spent = 0; + e.aa_points_spent_old = 0; + e.aa_points_old = 0; + e.e_last_invsnapshot = 0; + e.deleted_at = 0; - return entry; + return e; } - static CharacterData GetCharacterDataEntry( + static CharacterData GetCharacterData( const std::vector &character_datas, int character_data_id ) @@ -516,112 +516,112 @@ public: auto row = results.begin(); if (results.RowCount() == 1) { - CharacterData entry{}; + CharacterData e{}; - entry.id = atoi(row[0]); - entry.account_id = atoi(row[1]); - entry.name = row[2] ? row[2] : ""; - entry.last_name = row[3] ? row[3] : ""; - entry.title = row[4] ? row[4] : ""; - entry.suffix = row[5] ? row[5] : ""; - entry.zone_id = atoi(row[6]); - entry.zone_instance = atoi(row[7]); - entry.y = static_cast(atof(row[8])); - entry.x = static_cast(atof(row[9])); - entry.z = static_cast(atof(row[10])); - entry.heading = static_cast(atof(row[11])); - entry.gender = atoi(row[12]); - entry.race = atoi(row[13]); - entry.class_ = atoi(row[14]); - entry.level = atoi(row[15]); - entry.deity = atoi(row[16]); - entry.birthday = atoi(row[17]); - entry.last_login = atoi(row[18]); - entry.time_played = atoi(row[19]); - entry.level2 = atoi(row[20]); - entry.anon = atoi(row[21]); - entry.gm = atoi(row[22]); - entry.face = atoi(row[23]); - entry.hair_color = atoi(row[24]); - entry.hair_style = atoi(row[25]); - entry.beard = atoi(row[26]); - entry.beard_color = atoi(row[27]); - entry.eye_color_1 = atoi(row[28]); - entry.eye_color_2 = atoi(row[29]); - entry.drakkin_heritage = atoi(row[30]); - entry.drakkin_tattoo = atoi(row[31]); - entry.drakkin_details = atoi(row[32]); - entry.ability_time_seconds = atoi(row[33]); - entry.ability_number = atoi(row[34]); - entry.ability_time_minutes = atoi(row[35]); - entry.ability_time_hours = atoi(row[36]); - entry.exp = atoi(row[37]); - entry.aa_points_spent = atoi(row[38]); - entry.aa_exp = atoi(row[39]); - entry.aa_points = atoi(row[40]); - entry.group_leadership_exp = atoi(row[41]); - entry.raid_leadership_exp = atoi(row[42]); - entry.group_leadership_points = atoi(row[43]); - entry.raid_leadership_points = atoi(row[44]); - entry.points = atoi(row[45]); - entry.cur_hp = atoi(row[46]); - entry.mana = atoi(row[47]); - entry.endurance = atoi(row[48]); - entry.intoxication = atoi(row[49]); - entry.str = atoi(row[50]); - entry.sta = atoi(row[51]); - entry.cha = atoi(row[52]); - entry.dex = atoi(row[53]); - entry.int_ = atoi(row[54]); - entry.agi = atoi(row[55]); - entry.wis = atoi(row[56]); - entry.zone_change_count = atoi(row[57]); - entry.toxicity = atoi(row[58]); - entry.hunger_level = atoi(row[59]); - entry.thirst_level = atoi(row[60]); - entry.ability_up = atoi(row[61]); - entry.ldon_points_guk = atoi(row[62]); - entry.ldon_points_mir = atoi(row[63]); - entry.ldon_points_mmc = atoi(row[64]); - entry.ldon_points_ruj = atoi(row[65]); - entry.ldon_points_tak = atoi(row[66]); - entry.ldon_points_available = atoi(row[67]); - entry.tribute_time_remaining = atoi(row[68]); - entry.career_tribute_points = atoi(row[69]); - entry.tribute_points = atoi(row[70]); - entry.tribute_active = atoi(row[71]); - entry.pvp_status = atoi(row[72]); - entry.pvp_kills = atoi(row[73]); - entry.pvp_deaths = atoi(row[74]); - entry.pvp_current_points = atoi(row[75]); - entry.pvp_career_points = atoi(row[76]); - entry.pvp_best_kill_streak = atoi(row[77]); - entry.pvp_worst_death_streak = atoi(row[78]); - entry.pvp_current_kill_streak = atoi(row[79]); - entry.pvp2 = atoi(row[80]); - entry.pvp_type = atoi(row[81]); - entry.show_helm = atoi(row[82]); - entry.group_auto_consent = atoi(row[83]); - entry.raid_auto_consent = atoi(row[84]); - entry.guild_auto_consent = atoi(row[85]); - entry.leadership_exp_on = atoi(row[86]); - entry.RestTimer = atoi(row[87]); - entry.air_remaining = atoi(row[88]); - entry.autosplit_enabled = atoi(row[89]); - entry.lfp = atoi(row[90]); - entry.lfg = atoi(row[91]); - entry.mailkey = row[92] ? row[92] : ""; - entry.xtargets = atoi(row[93]); - entry.firstlogon = atoi(row[94]); - entry.e_aa_effects = atoi(row[95]); - entry.e_percent_to_aa = atoi(row[96]); - entry.e_expended_aa_spent = atoi(row[97]); - entry.aa_points_spent_old = atoi(row[98]); - entry.aa_points_old = atoi(row[99]); - entry.e_last_invsnapshot = atoi(row[100]); - entry.deleted_at = strtoll(row[101] ? row[101] : "-1", nullptr, 10); + e.id = atoi(row[0]); + e.account_id = atoi(row[1]); + e.name = row[2] ? row[2] : ""; + e.last_name = row[3] ? row[3] : ""; + e.title = row[4] ? row[4] : ""; + e.suffix = row[5] ? row[5] : ""; + e.zone_id = atoi(row[6]); + e.zone_instance = atoi(row[7]); + e.y = static_cast(atof(row[8])); + e.x = static_cast(atof(row[9])); + e.z = static_cast(atof(row[10])); + e.heading = static_cast(atof(row[11])); + e.gender = atoi(row[12]); + e.race = atoi(row[13]); + e.class_ = atoi(row[14]); + e.level = atoi(row[15]); + e.deity = atoi(row[16]); + e.birthday = atoi(row[17]); + e.last_login = atoi(row[18]); + e.time_played = atoi(row[19]); + e.level2 = atoi(row[20]); + e.anon = atoi(row[21]); + e.gm = atoi(row[22]); + e.face = atoi(row[23]); + e.hair_color = atoi(row[24]); + e.hair_style = atoi(row[25]); + e.beard = atoi(row[26]); + e.beard_color = atoi(row[27]); + e.eye_color_1 = atoi(row[28]); + e.eye_color_2 = atoi(row[29]); + e.drakkin_heritage = atoi(row[30]); + e.drakkin_tattoo = atoi(row[31]); + e.drakkin_details = atoi(row[32]); + e.ability_time_seconds = atoi(row[33]); + e.ability_number = atoi(row[34]); + e.ability_time_minutes = atoi(row[35]); + e.ability_time_hours = atoi(row[36]); + e.exp = atoi(row[37]); + e.aa_points_spent = atoi(row[38]); + e.aa_exp = atoi(row[39]); + e.aa_points = atoi(row[40]); + e.group_leadership_exp = atoi(row[41]); + e.raid_leadership_exp = atoi(row[42]); + e.group_leadership_points = atoi(row[43]); + e.raid_leadership_points = atoi(row[44]); + e.points = atoi(row[45]); + e.cur_hp = atoi(row[46]); + e.mana = atoi(row[47]); + e.endurance = atoi(row[48]); + e.intoxication = atoi(row[49]); + e.str = atoi(row[50]); + e.sta = atoi(row[51]); + e.cha = atoi(row[52]); + e.dex = atoi(row[53]); + e.int_ = atoi(row[54]); + e.agi = atoi(row[55]); + e.wis = atoi(row[56]); + e.zone_change_count = atoi(row[57]); + e.toxicity = atoi(row[58]); + e.hunger_level = atoi(row[59]); + e.thirst_level = atoi(row[60]); + e.ability_up = atoi(row[61]); + e.ldon_points_guk = atoi(row[62]); + e.ldon_points_mir = atoi(row[63]); + e.ldon_points_mmc = atoi(row[64]); + e.ldon_points_ruj = atoi(row[65]); + e.ldon_points_tak = atoi(row[66]); + e.ldon_points_available = atoi(row[67]); + e.tribute_time_remaining = atoi(row[68]); + e.career_tribute_points = atoi(row[69]); + e.tribute_points = atoi(row[70]); + e.tribute_active = atoi(row[71]); + e.pvp_status = atoi(row[72]); + e.pvp_kills = atoi(row[73]); + e.pvp_deaths = atoi(row[74]); + e.pvp_current_points = atoi(row[75]); + e.pvp_career_points = atoi(row[76]); + e.pvp_best_kill_streak = atoi(row[77]); + e.pvp_worst_death_streak = atoi(row[78]); + e.pvp_current_kill_streak = atoi(row[79]); + e.pvp2 = atoi(row[80]); + e.pvp_type = atoi(row[81]); + e.show_helm = atoi(row[82]); + e.group_auto_consent = atoi(row[83]); + e.raid_auto_consent = atoi(row[84]); + e.guild_auto_consent = atoi(row[85]); + e.leadership_exp_on = atoi(row[86]); + e.RestTimer = atoi(row[87]); + e.air_remaining = atoi(row[88]); + e.autosplit_enabled = atoi(row[89]); + e.lfp = atoi(row[90]); + e.lfg = atoi(row[91]); + e.mailkey = row[92] ? row[92] : ""; + e.xtargets = atoi(row[93]); + e.firstlogon = atoi(row[94]); + e.e_aa_effects = atoi(row[95]); + e.e_percent_to_aa = atoi(row[96]); + e.e_expended_aa_spent = atoi(row[97]); + e.aa_points_spent_old = atoi(row[98]); + e.aa_points_old = atoi(row[99]); + e.e_last_invsnapshot = atoi(row[100]); + e.deleted_at = strtoll(row[101] ? row[101] : "-1", nullptr, 10); - return entry; + return e; } return NewEntity(); @@ -646,122 +646,122 @@ public: static int UpdateOne( Database& db, - CharacterData character_data_entry + const CharacterData &e ) { - std::vector update_values; + std::vector v; auto columns = Columns(); - update_values.push_back(columns[1] + " = " + std::to_string(character_data_entry.account_id)); - update_values.push_back(columns[2] + " = '" + Strings::Escape(character_data_entry.name) + "'"); - update_values.push_back(columns[3] + " = '" + Strings::Escape(character_data_entry.last_name) + "'"); - update_values.push_back(columns[4] + " = '" + Strings::Escape(character_data_entry.title) + "'"); - update_values.push_back(columns[5] + " = '" + Strings::Escape(character_data_entry.suffix) + "'"); - update_values.push_back(columns[6] + " = " + std::to_string(character_data_entry.zone_id)); - update_values.push_back(columns[7] + " = " + std::to_string(character_data_entry.zone_instance)); - update_values.push_back(columns[8] + " = " + std::to_string(character_data_entry.y)); - update_values.push_back(columns[9] + " = " + std::to_string(character_data_entry.x)); - update_values.push_back(columns[10] + " = " + std::to_string(character_data_entry.z)); - update_values.push_back(columns[11] + " = " + std::to_string(character_data_entry.heading)); - update_values.push_back(columns[12] + " = " + std::to_string(character_data_entry.gender)); - update_values.push_back(columns[13] + " = " + std::to_string(character_data_entry.race)); - update_values.push_back(columns[14] + " = " + std::to_string(character_data_entry.class_)); - update_values.push_back(columns[15] + " = " + std::to_string(character_data_entry.level)); - update_values.push_back(columns[16] + " = " + std::to_string(character_data_entry.deity)); - update_values.push_back(columns[17] + " = " + std::to_string(character_data_entry.birthday)); - update_values.push_back(columns[18] + " = " + std::to_string(character_data_entry.last_login)); - update_values.push_back(columns[19] + " = " + std::to_string(character_data_entry.time_played)); - update_values.push_back(columns[20] + " = " + std::to_string(character_data_entry.level2)); - update_values.push_back(columns[21] + " = " + std::to_string(character_data_entry.anon)); - update_values.push_back(columns[22] + " = " + std::to_string(character_data_entry.gm)); - update_values.push_back(columns[23] + " = " + std::to_string(character_data_entry.face)); - update_values.push_back(columns[24] + " = " + std::to_string(character_data_entry.hair_color)); - update_values.push_back(columns[25] + " = " + std::to_string(character_data_entry.hair_style)); - update_values.push_back(columns[26] + " = " + std::to_string(character_data_entry.beard)); - update_values.push_back(columns[27] + " = " + std::to_string(character_data_entry.beard_color)); - update_values.push_back(columns[28] + " = " + std::to_string(character_data_entry.eye_color_1)); - update_values.push_back(columns[29] + " = " + std::to_string(character_data_entry.eye_color_2)); - update_values.push_back(columns[30] + " = " + std::to_string(character_data_entry.drakkin_heritage)); - update_values.push_back(columns[31] + " = " + std::to_string(character_data_entry.drakkin_tattoo)); - update_values.push_back(columns[32] + " = " + std::to_string(character_data_entry.drakkin_details)); - update_values.push_back(columns[33] + " = " + std::to_string(character_data_entry.ability_time_seconds)); - update_values.push_back(columns[34] + " = " + std::to_string(character_data_entry.ability_number)); - update_values.push_back(columns[35] + " = " + std::to_string(character_data_entry.ability_time_minutes)); - update_values.push_back(columns[36] + " = " + std::to_string(character_data_entry.ability_time_hours)); - update_values.push_back(columns[37] + " = " + std::to_string(character_data_entry.exp)); - update_values.push_back(columns[38] + " = " + std::to_string(character_data_entry.aa_points_spent)); - update_values.push_back(columns[39] + " = " + std::to_string(character_data_entry.aa_exp)); - update_values.push_back(columns[40] + " = " + std::to_string(character_data_entry.aa_points)); - update_values.push_back(columns[41] + " = " + std::to_string(character_data_entry.group_leadership_exp)); - update_values.push_back(columns[42] + " = " + std::to_string(character_data_entry.raid_leadership_exp)); - update_values.push_back(columns[43] + " = " + std::to_string(character_data_entry.group_leadership_points)); - update_values.push_back(columns[44] + " = " + std::to_string(character_data_entry.raid_leadership_points)); - update_values.push_back(columns[45] + " = " + std::to_string(character_data_entry.points)); - update_values.push_back(columns[46] + " = " + std::to_string(character_data_entry.cur_hp)); - update_values.push_back(columns[47] + " = " + std::to_string(character_data_entry.mana)); - update_values.push_back(columns[48] + " = " + std::to_string(character_data_entry.endurance)); - update_values.push_back(columns[49] + " = " + std::to_string(character_data_entry.intoxication)); - update_values.push_back(columns[50] + " = " + std::to_string(character_data_entry.str)); - update_values.push_back(columns[51] + " = " + std::to_string(character_data_entry.sta)); - update_values.push_back(columns[52] + " = " + std::to_string(character_data_entry.cha)); - update_values.push_back(columns[53] + " = " + std::to_string(character_data_entry.dex)); - update_values.push_back(columns[54] + " = " + std::to_string(character_data_entry.int_)); - update_values.push_back(columns[55] + " = " + std::to_string(character_data_entry.agi)); - update_values.push_back(columns[56] + " = " + std::to_string(character_data_entry.wis)); - update_values.push_back(columns[57] + " = " + std::to_string(character_data_entry.zone_change_count)); - update_values.push_back(columns[58] + " = " + std::to_string(character_data_entry.toxicity)); - update_values.push_back(columns[59] + " = " + std::to_string(character_data_entry.hunger_level)); - update_values.push_back(columns[60] + " = " + std::to_string(character_data_entry.thirst_level)); - update_values.push_back(columns[61] + " = " + std::to_string(character_data_entry.ability_up)); - update_values.push_back(columns[62] + " = " + std::to_string(character_data_entry.ldon_points_guk)); - update_values.push_back(columns[63] + " = " + std::to_string(character_data_entry.ldon_points_mir)); - update_values.push_back(columns[64] + " = " + std::to_string(character_data_entry.ldon_points_mmc)); - update_values.push_back(columns[65] + " = " + std::to_string(character_data_entry.ldon_points_ruj)); - update_values.push_back(columns[66] + " = " + std::to_string(character_data_entry.ldon_points_tak)); - update_values.push_back(columns[67] + " = " + std::to_string(character_data_entry.ldon_points_available)); - update_values.push_back(columns[68] + " = " + std::to_string(character_data_entry.tribute_time_remaining)); - update_values.push_back(columns[69] + " = " + std::to_string(character_data_entry.career_tribute_points)); - update_values.push_back(columns[70] + " = " + std::to_string(character_data_entry.tribute_points)); - update_values.push_back(columns[71] + " = " + std::to_string(character_data_entry.tribute_active)); - update_values.push_back(columns[72] + " = " + std::to_string(character_data_entry.pvp_status)); - update_values.push_back(columns[73] + " = " + std::to_string(character_data_entry.pvp_kills)); - update_values.push_back(columns[74] + " = " + std::to_string(character_data_entry.pvp_deaths)); - update_values.push_back(columns[75] + " = " + std::to_string(character_data_entry.pvp_current_points)); - update_values.push_back(columns[76] + " = " + std::to_string(character_data_entry.pvp_career_points)); - update_values.push_back(columns[77] + " = " + std::to_string(character_data_entry.pvp_best_kill_streak)); - update_values.push_back(columns[78] + " = " + std::to_string(character_data_entry.pvp_worst_death_streak)); - update_values.push_back(columns[79] + " = " + std::to_string(character_data_entry.pvp_current_kill_streak)); - update_values.push_back(columns[80] + " = " + std::to_string(character_data_entry.pvp2)); - update_values.push_back(columns[81] + " = " + std::to_string(character_data_entry.pvp_type)); - update_values.push_back(columns[82] + " = " + std::to_string(character_data_entry.show_helm)); - update_values.push_back(columns[83] + " = " + std::to_string(character_data_entry.group_auto_consent)); - update_values.push_back(columns[84] + " = " + std::to_string(character_data_entry.raid_auto_consent)); - update_values.push_back(columns[85] + " = " + std::to_string(character_data_entry.guild_auto_consent)); - update_values.push_back(columns[86] + " = " + std::to_string(character_data_entry.leadership_exp_on)); - update_values.push_back(columns[87] + " = " + std::to_string(character_data_entry.RestTimer)); - update_values.push_back(columns[88] + " = " + std::to_string(character_data_entry.air_remaining)); - update_values.push_back(columns[89] + " = " + std::to_string(character_data_entry.autosplit_enabled)); - update_values.push_back(columns[90] + " = " + std::to_string(character_data_entry.lfp)); - update_values.push_back(columns[91] + " = " + std::to_string(character_data_entry.lfg)); - update_values.push_back(columns[92] + " = '" + Strings::Escape(character_data_entry.mailkey) + "'"); - update_values.push_back(columns[93] + " = " + std::to_string(character_data_entry.xtargets)); - update_values.push_back(columns[94] + " = " + std::to_string(character_data_entry.firstlogon)); - update_values.push_back(columns[95] + " = " + std::to_string(character_data_entry.e_aa_effects)); - update_values.push_back(columns[96] + " = " + std::to_string(character_data_entry.e_percent_to_aa)); - update_values.push_back(columns[97] + " = " + std::to_string(character_data_entry.e_expended_aa_spent)); - update_values.push_back(columns[98] + " = " + std::to_string(character_data_entry.aa_points_spent_old)); - update_values.push_back(columns[99] + " = " + std::to_string(character_data_entry.aa_points_old)); - update_values.push_back(columns[100] + " = " + std::to_string(character_data_entry.e_last_invsnapshot)); - update_values.push_back(columns[101] + " = FROM_UNIXTIME(" + (character_data_entry.deleted_at > 0 ? std::to_string(character_data_entry.deleted_at) : "null") + ")"); + v.push_back(columns[1] + " = " + std::to_string(e.account_id)); + v.push_back(columns[2] + " = '" + Strings::Escape(e.name) + "'"); + v.push_back(columns[3] + " = '" + Strings::Escape(e.last_name) + "'"); + v.push_back(columns[4] + " = '" + Strings::Escape(e.title) + "'"); + v.push_back(columns[5] + " = '" + Strings::Escape(e.suffix) + "'"); + v.push_back(columns[6] + " = " + std::to_string(e.zone_id)); + v.push_back(columns[7] + " = " + std::to_string(e.zone_instance)); + v.push_back(columns[8] + " = " + std::to_string(e.y)); + v.push_back(columns[9] + " = " + std::to_string(e.x)); + v.push_back(columns[10] + " = " + std::to_string(e.z)); + v.push_back(columns[11] + " = " + std::to_string(e.heading)); + v.push_back(columns[12] + " = " + std::to_string(e.gender)); + v.push_back(columns[13] + " = " + std::to_string(e.race)); + v.push_back(columns[14] + " = " + std::to_string(e.class_)); + v.push_back(columns[15] + " = " + std::to_string(e.level)); + v.push_back(columns[16] + " = " + std::to_string(e.deity)); + v.push_back(columns[17] + " = " + std::to_string(e.birthday)); + v.push_back(columns[18] + " = " + std::to_string(e.last_login)); + v.push_back(columns[19] + " = " + std::to_string(e.time_played)); + v.push_back(columns[20] + " = " + std::to_string(e.level2)); + v.push_back(columns[21] + " = " + std::to_string(e.anon)); + v.push_back(columns[22] + " = " + std::to_string(e.gm)); + v.push_back(columns[23] + " = " + std::to_string(e.face)); + v.push_back(columns[24] + " = " + std::to_string(e.hair_color)); + v.push_back(columns[25] + " = " + std::to_string(e.hair_style)); + v.push_back(columns[26] + " = " + std::to_string(e.beard)); + v.push_back(columns[27] + " = " + std::to_string(e.beard_color)); + v.push_back(columns[28] + " = " + std::to_string(e.eye_color_1)); + v.push_back(columns[29] + " = " + std::to_string(e.eye_color_2)); + v.push_back(columns[30] + " = " + std::to_string(e.drakkin_heritage)); + v.push_back(columns[31] + " = " + std::to_string(e.drakkin_tattoo)); + v.push_back(columns[32] + " = " + std::to_string(e.drakkin_details)); + v.push_back(columns[33] + " = " + std::to_string(e.ability_time_seconds)); + v.push_back(columns[34] + " = " + std::to_string(e.ability_number)); + v.push_back(columns[35] + " = " + std::to_string(e.ability_time_minutes)); + v.push_back(columns[36] + " = " + std::to_string(e.ability_time_hours)); + v.push_back(columns[37] + " = " + std::to_string(e.exp)); + v.push_back(columns[38] + " = " + std::to_string(e.aa_points_spent)); + v.push_back(columns[39] + " = " + std::to_string(e.aa_exp)); + v.push_back(columns[40] + " = " + std::to_string(e.aa_points)); + v.push_back(columns[41] + " = " + std::to_string(e.group_leadership_exp)); + v.push_back(columns[42] + " = " + std::to_string(e.raid_leadership_exp)); + v.push_back(columns[43] + " = " + std::to_string(e.group_leadership_points)); + v.push_back(columns[44] + " = " + std::to_string(e.raid_leadership_points)); + v.push_back(columns[45] + " = " + std::to_string(e.points)); + v.push_back(columns[46] + " = " + std::to_string(e.cur_hp)); + v.push_back(columns[47] + " = " + std::to_string(e.mana)); + v.push_back(columns[48] + " = " + std::to_string(e.endurance)); + v.push_back(columns[49] + " = " + std::to_string(e.intoxication)); + v.push_back(columns[50] + " = " + std::to_string(e.str)); + v.push_back(columns[51] + " = " + std::to_string(e.sta)); + v.push_back(columns[52] + " = " + std::to_string(e.cha)); + v.push_back(columns[53] + " = " + std::to_string(e.dex)); + v.push_back(columns[54] + " = " + std::to_string(e.int_)); + v.push_back(columns[55] + " = " + std::to_string(e.agi)); + v.push_back(columns[56] + " = " + std::to_string(e.wis)); + v.push_back(columns[57] + " = " + std::to_string(e.zone_change_count)); + v.push_back(columns[58] + " = " + std::to_string(e.toxicity)); + v.push_back(columns[59] + " = " + std::to_string(e.hunger_level)); + v.push_back(columns[60] + " = " + std::to_string(e.thirst_level)); + v.push_back(columns[61] + " = " + std::to_string(e.ability_up)); + v.push_back(columns[62] + " = " + std::to_string(e.ldon_points_guk)); + v.push_back(columns[63] + " = " + std::to_string(e.ldon_points_mir)); + v.push_back(columns[64] + " = " + std::to_string(e.ldon_points_mmc)); + v.push_back(columns[65] + " = " + std::to_string(e.ldon_points_ruj)); + v.push_back(columns[66] + " = " + std::to_string(e.ldon_points_tak)); + v.push_back(columns[67] + " = " + std::to_string(e.ldon_points_available)); + v.push_back(columns[68] + " = " + std::to_string(e.tribute_time_remaining)); + v.push_back(columns[69] + " = " + std::to_string(e.career_tribute_points)); + v.push_back(columns[70] + " = " + std::to_string(e.tribute_points)); + v.push_back(columns[71] + " = " + std::to_string(e.tribute_active)); + v.push_back(columns[72] + " = " + std::to_string(e.pvp_status)); + v.push_back(columns[73] + " = " + std::to_string(e.pvp_kills)); + v.push_back(columns[74] + " = " + std::to_string(e.pvp_deaths)); + v.push_back(columns[75] + " = " + std::to_string(e.pvp_current_points)); + v.push_back(columns[76] + " = " + std::to_string(e.pvp_career_points)); + v.push_back(columns[77] + " = " + std::to_string(e.pvp_best_kill_streak)); + v.push_back(columns[78] + " = " + std::to_string(e.pvp_worst_death_streak)); + v.push_back(columns[79] + " = " + std::to_string(e.pvp_current_kill_streak)); + v.push_back(columns[80] + " = " + std::to_string(e.pvp2)); + v.push_back(columns[81] + " = " + std::to_string(e.pvp_type)); + v.push_back(columns[82] + " = " + std::to_string(e.show_helm)); + v.push_back(columns[83] + " = " + std::to_string(e.group_auto_consent)); + v.push_back(columns[84] + " = " + std::to_string(e.raid_auto_consent)); + v.push_back(columns[85] + " = " + std::to_string(e.guild_auto_consent)); + v.push_back(columns[86] + " = " + std::to_string(e.leadership_exp_on)); + v.push_back(columns[87] + " = " + std::to_string(e.RestTimer)); + v.push_back(columns[88] + " = " + std::to_string(e.air_remaining)); + v.push_back(columns[89] + " = " + std::to_string(e.autosplit_enabled)); + v.push_back(columns[90] + " = " + std::to_string(e.lfp)); + v.push_back(columns[91] + " = " + std::to_string(e.lfg)); + v.push_back(columns[92] + " = '" + Strings::Escape(e.mailkey) + "'"); + v.push_back(columns[93] + " = " + std::to_string(e.xtargets)); + v.push_back(columns[94] + " = " + std::to_string(e.firstlogon)); + v.push_back(columns[95] + " = " + std::to_string(e.e_aa_effects)); + v.push_back(columns[96] + " = " + std::to_string(e.e_percent_to_aa)); + v.push_back(columns[97] + " = " + std::to_string(e.e_expended_aa_spent)); + v.push_back(columns[98] + " = " + std::to_string(e.aa_points_spent_old)); + v.push_back(columns[99] + " = " + std::to_string(e.aa_points_old)); + v.push_back(columns[100] + " = " + std::to_string(e.e_last_invsnapshot)); + v.push_back(columns[101] + " = FROM_UNIXTIME(" + (e.deleted_at > 0 ? std::to_string(e.deleted_at) : "null") + ")"); auto results = db.QueryDatabase( fmt::format( "UPDATE {} SET {} WHERE {} = {}", TableName(), - Strings::Implode(", ", update_values), + Strings::Implode(", ", v), PrimaryKey(), - character_data_entry.id + e.id ) ); @@ -770,249 +770,249 @@ public: static CharacterData InsertOne( Database& db, - CharacterData character_data_entry + CharacterData e ) { - std::vector insert_values; + std::vector v; - insert_values.push_back(std::to_string(character_data_entry.id)); - insert_values.push_back(std::to_string(character_data_entry.account_id)); - insert_values.push_back("'" + Strings::Escape(character_data_entry.name) + "'"); - insert_values.push_back("'" + Strings::Escape(character_data_entry.last_name) + "'"); - insert_values.push_back("'" + Strings::Escape(character_data_entry.title) + "'"); - insert_values.push_back("'" + Strings::Escape(character_data_entry.suffix) + "'"); - insert_values.push_back(std::to_string(character_data_entry.zone_id)); - insert_values.push_back(std::to_string(character_data_entry.zone_instance)); - insert_values.push_back(std::to_string(character_data_entry.y)); - insert_values.push_back(std::to_string(character_data_entry.x)); - insert_values.push_back(std::to_string(character_data_entry.z)); - insert_values.push_back(std::to_string(character_data_entry.heading)); - insert_values.push_back(std::to_string(character_data_entry.gender)); - insert_values.push_back(std::to_string(character_data_entry.race)); - insert_values.push_back(std::to_string(character_data_entry.class_)); - insert_values.push_back(std::to_string(character_data_entry.level)); - insert_values.push_back(std::to_string(character_data_entry.deity)); - insert_values.push_back(std::to_string(character_data_entry.birthday)); - insert_values.push_back(std::to_string(character_data_entry.last_login)); - insert_values.push_back(std::to_string(character_data_entry.time_played)); - insert_values.push_back(std::to_string(character_data_entry.level2)); - insert_values.push_back(std::to_string(character_data_entry.anon)); - insert_values.push_back(std::to_string(character_data_entry.gm)); - insert_values.push_back(std::to_string(character_data_entry.face)); - insert_values.push_back(std::to_string(character_data_entry.hair_color)); - insert_values.push_back(std::to_string(character_data_entry.hair_style)); - insert_values.push_back(std::to_string(character_data_entry.beard)); - insert_values.push_back(std::to_string(character_data_entry.beard_color)); - insert_values.push_back(std::to_string(character_data_entry.eye_color_1)); - insert_values.push_back(std::to_string(character_data_entry.eye_color_2)); - insert_values.push_back(std::to_string(character_data_entry.drakkin_heritage)); - insert_values.push_back(std::to_string(character_data_entry.drakkin_tattoo)); - insert_values.push_back(std::to_string(character_data_entry.drakkin_details)); - insert_values.push_back(std::to_string(character_data_entry.ability_time_seconds)); - insert_values.push_back(std::to_string(character_data_entry.ability_number)); - insert_values.push_back(std::to_string(character_data_entry.ability_time_minutes)); - insert_values.push_back(std::to_string(character_data_entry.ability_time_hours)); - insert_values.push_back(std::to_string(character_data_entry.exp)); - insert_values.push_back(std::to_string(character_data_entry.aa_points_spent)); - insert_values.push_back(std::to_string(character_data_entry.aa_exp)); - insert_values.push_back(std::to_string(character_data_entry.aa_points)); - insert_values.push_back(std::to_string(character_data_entry.group_leadership_exp)); - insert_values.push_back(std::to_string(character_data_entry.raid_leadership_exp)); - insert_values.push_back(std::to_string(character_data_entry.group_leadership_points)); - insert_values.push_back(std::to_string(character_data_entry.raid_leadership_points)); - insert_values.push_back(std::to_string(character_data_entry.points)); - insert_values.push_back(std::to_string(character_data_entry.cur_hp)); - insert_values.push_back(std::to_string(character_data_entry.mana)); - insert_values.push_back(std::to_string(character_data_entry.endurance)); - insert_values.push_back(std::to_string(character_data_entry.intoxication)); - insert_values.push_back(std::to_string(character_data_entry.str)); - insert_values.push_back(std::to_string(character_data_entry.sta)); - insert_values.push_back(std::to_string(character_data_entry.cha)); - insert_values.push_back(std::to_string(character_data_entry.dex)); - insert_values.push_back(std::to_string(character_data_entry.int_)); - insert_values.push_back(std::to_string(character_data_entry.agi)); - insert_values.push_back(std::to_string(character_data_entry.wis)); - insert_values.push_back(std::to_string(character_data_entry.zone_change_count)); - insert_values.push_back(std::to_string(character_data_entry.toxicity)); - insert_values.push_back(std::to_string(character_data_entry.hunger_level)); - insert_values.push_back(std::to_string(character_data_entry.thirst_level)); - insert_values.push_back(std::to_string(character_data_entry.ability_up)); - insert_values.push_back(std::to_string(character_data_entry.ldon_points_guk)); - insert_values.push_back(std::to_string(character_data_entry.ldon_points_mir)); - insert_values.push_back(std::to_string(character_data_entry.ldon_points_mmc)); - insert_values.push_back(std::to_string(character_data_entry.ldon_points_ruj)); - insert_values.push_back(std::to_string(character_data_entry.ldon_points_tak)); - insert_values.push_back(std::to_string(character_data_entry.ldon_points_available)); - insert_values.push_back(std::to_string(character_data_entry.tribute_time_remaining)); - insert_values.push_back(std::to_string(character_data_entry.career_tribute_points)); - insert_values.push_back(std::to_string(character_data_entry.tribute_points)); - insert_values.push_back(std::to_string(character_data_entry.tribute_active)); - insert_values.push_back(std::to_string(character_data_entry.pvp_status)); - insert_values.push_back(std::to_string(character_data_entry.pvp_kills)); - insert_values.push_back(std::to_string(character_data_entry.pvp_deaths)); - insert_values.push_back(std::to_string(character_data_entry.pvp_current_points)); - insert_values.push_back(std::to_string(character_data_entry.pvp_career_points)); - insert_values.push_back(std::to_string(character_data_entry.pvp_best_kill_streak)); - insert_values.push_back(std::to_string(character_data_entry.pvp_worst_death_streak)); - insert_values.push_back(std::to_string(character_data_entry.pvp_current_kill_streak)); - insert_values.push_back(std::to_string(character_data_entry.pvp2)); - insert_values.push_back(std::to_string(character_data_entry.pvp_type)); - insert_values.push_back(std::to_string(character_data_entry.show_helm)); - insert_values.push_back(std::to_string(character_data_entry.group_auto_consent)); - insert_values.push_back(std::to_string(character_data_entry.raid_auto_consent)); - insert_values.push_back(std::to_string(character_data_entry.guild_auto_consent)); - insert_values.push_back(std::to_string(character_data_entry.leadership_exp_on)); - insert_values.push_back(std::to_string(character_data_entry.RestTimer)); - insert_values.push_back(std::to_string(character_data_entry.air_remaining)); - insert_values.push_back(std::to_string(character_data_entry.autosplit_enabled)); - insert_values.push_back(std::to_string(character_data_entry.lfp)); - insert_values.push_back(std::to_string(character_data_entry.lfg)); - insert_values.push_back("'" + Strings::Escape(character_data_entry.mailkey) + "'"); - insert_values.push_back(std::to_string(character_data_entry.xtargets)); - insert_values.push_back(std::to_string(character_data_entry.firstlogon)); - insert_values.push_back(std::to_string(character_data_entry.e_aa_effects)); - insert_values.push_back(std::to_string(character_data_entry.e_percent_to_aa)); - insert_values.push_back(std::to_string(character_data_entry.e_expended_aa_spent)); - insert_values.push_back(std::to_string(character_data_entry.aa_points_spent_old)); - insert_values.push_back(std::to_string(character_data_entry.aa_points_old)); - insert_values.push_back(std::to_string(character_data_entry.e_last_invsnapshot)); - insert_values.push_back("FROM_UNIXTIME(" + (character_data_entry.deleted_at > 0 ? std::to_string(character_data_entry.deleted_at) : "null") + ")"); + v.push_back(std::to_string(e.id)); + v.push_back(std::to_string(e.account_id)); + v.push_back("'" + Strings::Escape(e.name) + "'"); + v.push_back("'" + Strings::Escape(e.last_name) + "'"); + v.push_back("'" + Strings::Escape(e.title) + "'"); + v.push_back("'" + Strings::Escape(e.suffix) + "'"); + v.push_back(std::to_string(e.zone_id)); + v.push_back(std::to_string(e.zone_instance)); + v.push_back(std::to_string(e.y)); + v.push_back(std::to_string(e.x)); + v.push_back(std::to_string(e.z)); + v.push_back(std::to_string(e.heading)); + v.push_back(std::to_string(e.gender)); + v.push_back(std::to_string(e.race)); + v.push_back(std::to_string(e.class_)); + v.push_back(std::to_string(e.level)); + v.push_back(std::to_string(e.deity)); + v.push_back(std::to_string(e.birthday)); + v.push_back(std::to_string(e.last_login)); + v.push_back(std::to_string(e.time_played)); + v.push_back(std::to_string(e.level2)); + v.push_back(std::to_string(e.anon)); + v.push_back(std::to_string(e.gm)); + v.push_back(std::to_string(e.face)); + v.push_back(std::to_string(e.hair_color)); + v.push_back(std::to_string(e.hair_style)); + v.push_back(std::to_string(e.beard)); + v.push_back(std::to_string(e.beard_color)); + v.push_back(std::to_string(e.eye_color_1)); + v.push_back(std::to_string(e.eye_color_2)); + v.push_back(std::to_string(e.drakkin_heritage)); + v.push_back(std::to_string(e.drakkin_tattoo)); + v.push_back(std::to_string(e.drakkin_details)); + v.push_back(std::to_string(e.ability_time_seconds)); + v.push_back(std::to_string(e.ability_number)); + v.push_back(std::to_string(e.ability_time_minutes)); + v.push_back(std::to_string(e.ability_time_hours)); + v.push_back(std::to_string(e.exp)); + v.push_back(std::to_string(e.aa_points_spent)); + v.push_back(std::to_string(e.aa_exp)); + v.push_back(std::to_string(e.aa_points)); + v.push_back(std::to_string(e.group_leadership_exp)); + v.push_back(std::to_string(e.raid_leadership_exp)); + v.push_back(std::to_string(e.group_leadership_points)); + v.push_back(std::to_string(e.raid_leadership_points)); + v.push_back(std::to_string(e.points)); + v.push_back(std::to_string(e.cur_hp)); + v.push_back(std::to_string(e.mana)); + v.push_back(std::to_string(e.endurance)); + v.push_back(std::to_string(e.intoxication)); + v.push_back(std::to_string(e.str)); + v.push_back(std::to_string(e.sta)); + v.push_back(std::to_string(e.cha)); + v.push_back(std::to_string(e.dex)); + v.push_back(std::to_string(e.int_)); + v.push_back(std::to_string(e.agi)); + v.push_back(std::to_string(e.wis)); + v.push_back(std::to_string(e.zone_change_count)); + v.push_back(std::to_string(e.toxicity)); + v.push_back(std::to_string(e.hunger_level)); + v.push_back(std::to_string(e.thirst_level)); + v.push_back(std::to_string(e.ability_up)); + v.push_back(std::to_string(e.ldon_points_guk)); + v.push_back(std::to_string(e.ldon_points_mir)); + v.push_back(std::to_string(e.ldon_points_mmc)); + v.push_back(std::to_string(e.ldon_points_ruj)); + v.push_back(std::to_string(e.ldon_points_tak)); + v.push_back(std::to_string(e.ldon_points_available)); + v.push_back(std::to_string(e.tribute_time_remaining)); + v.push_back(std::to_string(e.career_tribute_points)); + v.push_back(std::to_string(e.tribute_points)); + v.push_back(std::to_string(e.tribute_active)); + v.push_back(std::to_string(e.pvp_status)); + v.push_back(std::to_string(e.pvp_kills)); + v.push_back(std::to_string(e.pvp_deaths)); + v.push_back(std::to_string(e.pvp_current_points)); + v.push_back(std::to_string(e.pvp_career_points)); + v.push_back(std::to_string(e.pvp_best_kill_streak)); + v.push_back(std::to_string(e.pvp_worst_death_streak)); + v.push_back(std::to_string(e.pvp_current_kill_streak)); + v.push_back(std::to_string(e.pvp2)); + v.push_back(std::to_string(e.pvp_type)); + v.push_back(std::to_string(e.show_helm)); + v.push_back(std::to_string(e.group_auto_consent)); + v.push_back(std::to_string(e.raid_auto_consent)); + v.push_back(std::to_string(e.guild_auto_consent)); + v.push_back(std::to_string(e.leadership_exp_on)); + v.push_back(std::to_string(e.RestTimer)); + v.push_back(std::to_string(e.air_remaining)); + v.push_back(std::to_string(e.autosplit_enabled)); + v.push_back(std::to_string(e.lfp)); + v.push_back(std::to_string(e.lfg)); + v.push_back("'" + Strings::Escape(e.mailkey) + "'"); + v.push_back(std::to_string(e.xtargets)); + v.push_back(std::to_string(e.firstlogon)); + v.push_back(std::to_string(e.e_aa_effects)); + v.push_back(std::to_string(e.e_percent_to_aa)); + v.push_back(std::to_string(e.e_expended_aa_spent)); + v.push_back(std::to_string(e.aa_points_spent_old)); + v.push_back(std::to_string(e.aa_points_old)); + v.push_back(std::to_string(e.e_last_invsnapshot)); + v.push_back("FROM_UNIXTIME(" + (e.deleted_at > 0 ? std::to_string(e.deleted_at) : "null") + ")"); auto results = db.QueryDatabase( fmt::format( "{} VALUES ({})", BaseInsert(), - Strings::Implode(",", insert_values) + Strings::Implode(",", v) ) ); if (results.Success()) { - character_data_entry.id = results.LastInsertedID(); - return character_data_entry; + e.id = results.LastInsertedID(); + return e; } - character_data_entry = NewEntity(); + e = NewEntity(); - return character_data_entry; + return e; } static int InsertMany( Database& db, - std::vector character_data_entries + const std::vector &entries ) { std::vector insert_chunks; - for (auto &character_data_entry: character_data_entries) { - std::vector insert_values; + for (auto &e: entries) { + std::vector v; - insert_values.push_back(std::to_string(character_data_entry.id)); - insert_values.push_back(std::to_string(character_data_entry.account_id)); - insert_values.push_back("'" + Strings::Escape(character_data_entry.name) + "'"); - insert_values.push_back("'" + Strings::Escape(character_data_entry.last_name) + "'"); - insert_values.push_back("'" + Strings::Escape(character_data_entry.title) + "'"); - insert_values.push_back("'" + Strings::Escape(character_data_entry.suffix) + "'"); - insert_values.push_back(std::to_string(character_data_entry.zone_id)); - insert_values.push_back(std::to_string(character_data_entry.zone_instance)); - insert_values.push_back(std::to_string(character_data_entry.y)); - insert_values.push_back(std::to_string(character_data_entry.x)); - insert_values.push_back(std::to_string(character_data_entry.z)); - insert_values.push_back(std::to_string(character_data_entry.heading)); - insert_values.push_back(std::to_string(character_data_entry.gender)); - insert_values.push_back(std::to_string(character_data_entry.race)); - insert_values.push_back(std::to_string(character_data_entry.class_)); - insert_values.push_back(std::to_string(character_data_entry.level)); - insert_values.push_back(std::to_string(character_data_entry.deity)); - insert_values.push_back(std::to_string(character_data_entry.birthday)); - insert_values.push_back(std::to_string(character_data_entry.last_login)); - insert_values.push_back(std::to_string(character_data_entry.time_played)); - insert_values.push_back(std::to_string(character_data_entry.level2)); - insert_values.push_back(std::to_string(character_data_entry.anon)); - insert_values.push_back(std::to_string(character_data_entry.gm)); - insert_values.push_back(std::to_string(character_data_entry.face)); - insert_values.push_back(std::to_string(character_data_entry.hair_color)); - insert_values.push_back(std::to_string(character_data_entry.hair_style)); - insert_values.push_back(std::to_string(character_data_entry.beard)); - insert_values.push_back(std::to_string(character_data_entry.beard_color)); - insert_values.push_back(std::to_string(character_data_entry.eye_color_1)); - insert_values.push_back(std::to_string(character_data_entry.eye_color_2)); - insert_values.push_back(std::to_string(character_data_entry.drakkin_heritage)); - insert_values.push_back(std::to_string(character_data_entry.drakkin_tattoo)); - insert_values.push_back(std::to_string(character_data_entry.drakkin_details)); - insert_values.push_back(std::to_string(character_data_entry.ability_time_seconds)); - insert_values.push_back(std::to_string(character_data_entry.ability_number)); - insert_values.push_back(std::to_string(character_data_entry.ability_time_minutes)); - insert_values.push_back(std::to_string(character_data_entry.ability_time_hours)); - insert_values.push_back(std::to_string(character_data_entry.exp)); - insert_values.push_back(std::to_string(character_data_entry.aa_points_spent)); - insert_values.push_back(std::to_string(character_data_entry.aa_exp)); - insert_values.push_back(std::to_string(character_data_entry.aa_points)); - insert_values.push_back(std::to_string(character_data_entry.group_leadership_exp)); - insert_values.push_back(std::to_string(character_data_entry.raid_leadership_exp)); - insert_values.push_back(std::to_string(character_data_entry.group_leadership_points)); - insert_values.push_back(std::to_string(character_data_entry.raid_leadership_points)); - insert_values.push_back(std::to_string(character_data_entry.points)); - insert_values.push_back(std::to_string(character_data_entry.cur_hp)); - insert_values.push_back(std::to_string(character_data_entry.mana)); - insert_values.push_back(std::to_string(character_data_entry.endurance)); - insert_values.push_back(std::to_string(character_data_entry.intoxication)); - insert_values.push_back(std::to_string(character_data_entry.str)); - insert_values.push_back(std::to_string(character_data_entry.sta)); - insert_values.push_back(std::to_string(character_data_entry.cha)); - insert_values.push_back(std::to_string(character_data_entry.dex)); - insert_values.push_back(std::to_string(character_data_entry.int_)); - insert_values.push_back(std::to_string(character_data_entry.agi)); - insert_values.push_back(std::to_string(character_data_entry.wis)); - insert_values.push_back(std::to_string(character_data_entry.zone_change_count)); - insert_values.push_back(std::to_string(character_data_entry.toxicity)); - insert_values.push_back(std::to_string(character_data_entry.hunger_level)); - insert_values.push_back(std::to_string(character_data_entry.thirst_level)); - insert_values.push_back(std::to_string(character_data_entry.ability_up)); - insert_values.push_back(std::to_string(character_data_entry.ldon_points_guk)); - insert_values.push_back(std::to_string(character_data_entry.ldon_points_mir)); - insert_values.push_back(std::to_string(character_data_entry.ldon_points_mmc)); - insert_values.push_back(std::to_string(character_data_entry.ldon_points_ruj)); - insert_values.push_back(std::to_string(character_data_entry.ldon_points_tak)); - insert_values.push_back(std::to_string(character_data_entry.ldon_points_available)); - insert_values.push_back(std::to_string(character_data_entry.tribute_time_remaining)); - insert_values.push_back(std::to_string(character_data_entry.career_tribute_points)); - insert_values.push_back(std::to_string(character_data_entry.tribute_points)); - insert_values.push_back(std::to_string(character_data_entry.tribute_active)); - insert_values.push_back(std::to_string(character_data_entry.pvp_status)); - insert_values.push_back(std::to_string(character_data_entry.pvp_kills)); - insert_values.push_back(std::to_string(character_data_entry.pvp_deaths)); - insert_values.push_back(std::to_string(character_data_entry.pvp_current_points)); - insert_values.push_back(std::to_string(character_data_entry.pvp_career_points)); - insert_values.push_back(std::to_string(character_data_entry.pvp_best_kill_streak)); - insert_values.push_back(std::to_string(character_data_entry.pvp_worst_death_streak)); - insert_values.push_back(std::to_string(character_data_entry.pvp_current_kill_streak)); - insert_values.push_back(std::to_string(character_data_entry.pvp2)); - insert_values.push_back(std::to_string(character_data_entry.pvp_type)); - insert_values.push_back(std::to_string(character_data_entry.show_helm)); - insert_values.push_back(std::to_string(character_data_entry.group_auto_consent)); - insert_values.push_back(std::to_string(character_data_entry.raid_auto_consent)); - insert_values.push_back(std::to_string(character_data_entry.guild_auto_consent)); - insert_values.push_back(std::to_string(character_data_entry.leadership_exp_on)); - insert_values.push_back(std::to_string(character_data_entry.RestTimer)); - insert_values.push_back(std::to_string(character_data_entry.air_remaining)); - insert_values.push_back(std::to_string(character_data_entry.autosplit_enabled)); - insert_values.push_back(std::to_string(character_data_entry.lfp)); - insert_values.push_back(std::to_string(character_data_entry.lfg)); - insert_values.push_back("'" + Strings::Escape(character_data_entry.mailkey) + "'"); - insert_values.push_back(std::to_string(character_data_entry.xtargets)); - insert_values.push_back(std::to_string(character_data_entry.firstlogon)); - insert_values.push_back(std::to_string(character_data_entry.e_aa_effects)); - insert_values.push_back(std::to_string(character_data_entry.e_percent_to_aa)); - insert_values.push_back(std::to_string(character_data_entry.e_expended_aa_spent)); - insert_values.push_back(std::to_string(character_data_entry.aa_points_spent_old)); - insert_values.push_back(std::to_string(character_data_entry.aa_points_old)); - insert_values.push_back(std::to_string(character_data_entry.e_last_invsnapshot)); - insert_values.push_back("FROM_UNIXTIME(" + (character_data_entry.deleted_at > 0 ? std::to_string(character_data_entry.deleted_at) : "null") + ")"); + v.push_back(std::to_string(e.id)); + v.push_back(std::to_string(e.account_id)); + v.push_back("'" + Strings::Escape(e.name) + "'"); + v.push_back("'" + Strings::Escape(e.last_name) + "'"); + v.push_back("'" + Strings::Escape(e.title) + "'"); + v.push_back("'" + Strings::Escape(e.suffix) + "'"); + v.push_back(std::to_string(e.zone_id)); + v.push_back(std::to_string(e.zone_instance)); + v.push_back(std::to_string(e.y)); + v.push_back(std::to_string(e.x)); + v.push_back(std::to_string(e.z)); + v.push_back(std::to_string(e.heading)); + v.push_back(std::to_string(e.gender)); + v.push_back(std::to_string(e.race)); + v.push_back(std::to_string(e.class_)); + v.push_back(std::to_string(e.level)); + v.push_back(std::to_string(e.deity)); + v.push_back(std::to_string(e.birthday)); + v.push_back(std::to_string(e.last_login)); + v.push_back(std::to_string(e.time_played)); + v.push_back(std::to_string(e.level2)); + v.push_back(std::to_string(e.anon)); + v.push_back(std::to_string(e.gm)); + v.push_back(std::to_string(e.face)); + v.push_back(std::to_string(e.hair_color)); + v.push_back(std::to_string(e.hair_style)); + v.push_back(std::to_string(e.beard)); + v.push_back(std::to_string(e.beard_color)); + v.push_back(std::to_string(e.eye_color_1)); + v.push_back(std::to_string(e.eye_color_2)); + v.push_back(std::to_string(e.drakkin_heritage)); + v.push_back(std::to_string(e.drakkin_tattoo)); + v.push_back(std::to_string(e.drakkin_details)); + v.push_back(std::to_string(e.ability_time_seconds)); + v.push_back(std::to_string(e.ability_number)); + v.push_back(std::to_string(e.ability_time_minutes)); + v.push_back(std::to_string(e.ability_time_hours)); + v.push_back(std::to_string(e.exp)); + v.push_back(std::to_string(e.aa_points_spent)); + v.push_back(std::to_string(e.aa_exp)); + v.push_back(std::to_string(e.aa_points)); + v.push_back(std::to_string(e.group_leadership_exp)); + v.push_back(std::to_string(e.raid_leadership_exp)); + v.push_back(std::to_string(e.group_leadership_points)); + v.push_back(std::to_string(e.raid_leadership_points)); + v.push_back(std::to_string(e.points)); + v.push_back(std::to_string(e.cur_hp)); + v.push_back(std::to_string(e.mana)); + v.push_back(std::to_string(e.endurance)); + v.push_back(std::to_string(e.intoxication)); + v.push_back(std::to_string(e.str)); + v.push_back(std::to_string(e.sta)); + v.push_back(std::to_string(e.cha)); + v.push_back(std::to_string(e.dex)); + v.push_back(std::to_string(e.int_)); + v.push_back(std::to_string(e.agi)); + v.push_back(std::to_string(e.wis)); + v.push_back(std::to_string(e.zone_change_count)); + v.push_back(std::to_string(e.toxicity)); + v.push_back(std::to_string(e.hunger_level)); + v.push_back(std::to_string(e.thirst_level)); + v.push_back(std::to_string(e.ability_up)); + v.push_back(std::to_string(e.ldon_points_guk)); + v.push_back(std::to_string(e.ldon_points_mir)); + v.push_back(std::to_string(e.ldon_points_mmc)); + v.push_back(std::to_string(e.ldon_points_ruj)); + v.push_back(std::to_string(e.ldon_points_tak)); + v.push_back(std::to_string(e.ldon_points_available)); + v.push_back(std::to_string(e.tribute_time_remaining)); + v.push_back(std::to_string(e.career_tribute_points)); + v.push_back(std::to_string(e.tribute_points)); + v.push_back(std::to_string(e.tribute_active)); + v.push_back(std::to_string(e.pvp_status)); + v.push_back(std::to_string(e.pvp_kills)); + v.push_back(std::to_string(e.pvp_deaths)); + v.push_back(std::to_string(e.pvp_current_points)); + v.push_back(std::to_string(e.pvp_career_points)); + v.push_back(std::to_string(e.pvp_best_kill_streak)); + v.push_back(std::to_string(e.pvp_worst_death_streak)); + v.push_back(std::to_string(e.pvp_current_kill_streak)); + v.push_back(std::to_string(e.pvp2)); + v.push_back(std::to_string(e.pvp_type)); + v.push_back(std::to_string(e.show_helm)); + v.push_back(std::to_string(e.group_auto_consent)); + v.push_back(std::to_string(e.raid_auto_consent)); + v.push_back(std::to_string(e.guild_auto_consent)); + v.push_back(std::to_string(e.leadership_exp_on)); + v.push_back(std::to_string(e.RestTimer)); + v.push_back(std::to_string(e.air_remaining)); + v.push_back(std::to_string(e.autosplit_enabled)); + v.push_back(std::to_string(e.lfp)); + v.push_back(std::to_string(e.lfg)); + v.push_back("'" + Strings::Escape(e.mailkey) + "'"); + v.push_back(std::to_string(e.xtargets)); + v.push_back(std::to_string(e.firstlogon)); + v.push_back(std::to_string(e.e_aa_effects)); + v.push_back(std::to_string(e.e_percent_to_aa)); + v.push_back(std::to_string(e.e_expended_aa_spent)); + v.push_back(std::to_string(e.aa_points_spent_old)); + v.push_back(std::to_string(e.aa_points_old)); + v.push_back(std::to_string(e.e_last_invsnapshot)); + v.push_back("FROM_UNIXTIME(" + (e.deleted_at > 0 ? std::to_string(e.deleted_at) : "null") + ")"); - insert_chunks.push_back("(" + Strings::Implode(",", insert_values) + ")"); + insert_chunks.push_back("(" + Strings::Implode(",", v) + ")"); } - std::vector insert_values; + std::vector v; auto results = db.QueryDatabase( fmt::format( @@ -1039,118 +1039,118 @@ public: all_entries.reserve(results.RowCount()); for (auto row = results.begin(); row != results.end(); ++row) { - CharacterData entry{}; + CharacterData e{}; - entry.id = atoi(row[0]); - entry.account_id = atoi(row[1]); - entry.name = row[2] ? row[2] : ""; - entry.last_name = row[3] ? row[3] : ""; - entry.title = row[4] ? row[4] : ""; - entry.suffix = row[5] ? row[5] : ""; - entry.zone_id = atoi(row[6]); - entry.zone_instance = atoi(row[7]); - entry.y = static_cast(atof(row[8])); - entry.x = static_cast(atof(row[9])); - entry.z = static_cast(atof(row[10])); - entry.heading = static_cast(atof(row[11])); - entry.gender = atoi(row[12]); - entry.race = atoi(row[13]); - entry.class_ = atoi(row[14]); - entry.level = atoi(row[15]); - entry.deity = atoi(row[16]); - entry.birthday = atoi(row[17]); - entry.last_login = atoi(row[18]); - entry.time_played = atoi(row[19]); - entry.level2 = atoi(row[20]); - entry.anon = atoi(row[21]); - entry.gm = atoi(row[22]); - entry.face = atoi(row[23]); - entry.hair_color = atoi(row[24]); - entry.hair_style = atoi(row[25]); - entry.beard = atoi(row[26]); - entry.beard_color = atoi(row[27]); - entry.eye_color_1 = atoi(row[28]); - entry.eye_color_2 = atoi(row[29]); - entry.drakkin_heritage = atoi(row[30]); - entry.drakkin_tattoo = atoi(row[31]); - entry.drakkin_details = atoi(row[32]); - entry.ability_time_seconds = atoi(row[33]); - entry.ability_number = atoi(row[34]); - entry.ability_time_minutes = atoi(row[35]); - entry.ability_time_hours = atoi(row[36]); - entry.exp = atoi(row[37]); - entry.aa_points_spent = atoi(row[38]); - entry.aa_exp = atoi(row[39]); - entry.aa_points = atoi(row[40]); - entry.group_leadership_exp = atoi(row[41]); - entry.raid_leadership_exp = atoi(row[42]); - entry.group_leadership_points = atoi(row[43]); - entry.raid_leadership_points = atoi(row[44]); - entry.points = atoi(row[45]); - entry.cur_hp = atoi(row[46]); - entry.mana = atoi(row[47]); - entry.endurance = atoi(row[48]); - entry.intoxication = atoi(row[49]); - entry.str = atoi(row[50]); - entry.sta = atoi(row[51]); - entry.cha = atoi(row[52]); - entry.dex = atoi(row[53]); - entry.int_ = atoi(row[54]); - entry.agi = atoi(row[55]); - entry.wis = atoi(row[56]); - entry.zone_change_count = atoi(row[57]); - entry.toxicity = atoi(row[58]); - entry.hunger_level = atoi(row[59]); - entry.thirst_level = atoi(row[60]); - entry.ability_up = atoi(row[61]); - entry.ldon_points_guk = atoi(row[62]); - entry.ldon_points_mir = atoi(row[63]); - entry.ldon_points_mmc = atoi(row[64]); - entry.ldon_points_ruj = atoi(row[65]); - entry.ldon_points_tak = atoi(row[66]); - entry.ldon_points_available = atoi(row[67]); - entry.tribute_time_remaining = atoi(row[68]); - entry.career_tribute_points = atoi(row[69]); - entry.tribute_points = atoi(row[70]); - entry.tribute_active = atoi(row[71]); - entry.pvp_status = atoi(row[72]); - entry.pvp_kills = atoi(row[73]); - entry.pvp_deaths = atoi(row[74]); - entry.pvp_current_points = atoi(row[75]); - entry.pvp_career_points = atoi(row[76]); - entry.pvp_best_kill_streak = atoi(row[77]); - entry.pvp_worst_death_streak = atoi(row[78]); - entry.pvp_current_kill_streak = atoi(row[79]); - entry.pvp2 = atoi(row[80]); - entry.pvp_type = atoi(row[81]); - entry.show_helm = atoi(row[82]); - entry.group_auto_consent = atoi(row[83]); - entry.raid_auto_consent = atoi(row[84]); - entry.guild_auto_consent = atoi(row[85]); - entry.leadership_exp_on = atoi(row[86]); - entry.RestTimer = atoi(row[87]); - entry.air_remaining = atoi(row[88]); - entry.autosplit_enabled = atoi(row[89]); - entry.lfp = atoi(row[90]); - entry.lfg = atoi(row[91]); - entry.mailkey = row[92] ? row[92] : ""; - entry.xtargets = atoi(row[93]); - entry.firstlogon = atoi(row[94]); - entry.e_aa_effects = atoi(row[95]); - entry.e_percent_to_aa = atoi(row[96]); - entry.e_expended_aa_spent = atoi(row[97]); - entry.aa_points_spent_old = atoi(row[98]); - entry.aa_points_old = atoi(row[99]); - entry.e_last_invsnapshot = atoi(row[100]); - entry.deleted_at = strtoll(row[101] ? row[101] : "-1", nullptr, 10); + e.id = atoi(row[0]); + e.account_id = atoi(row[1]); + e.name = row[2] ? row[2] : ""; + e.last_name = row[3] ? row[3] : ""; + e.title = row[4] ? row[4] : ""; + e.suffix = row[5] ? row[5] : ""; + e.zone_id = atoi(row[6]); + e.zone_instance = atoi(row[7]); + e.y = static_cast(atof(row[8])); + e.x = static_cast(atof(row[9])); + e.z = static_cast(atof(row[10])); + e.heading = static_cast(atof(row[11])); + e.gender = atoi(row[12]); + e.race = atoi(row[13]); + e.class_ = atoi(row[14]); + e.level = atoi(row[15]); + e.deity = atoi(row[16]); + e.birthday = atoi(row[17]); + e.last_login = atoi(row[18]); + e.time_played = atoi(row[19]); + e.level2 = atoi(row[20]); + e.anon = atoi(row[21]); + e.gm = atoi(row[22]); + e.face = atoi(row[23]); + e.hair_color = atoi(row[24]); + e.hair_style = atoi(row[25]); + e.beard = atoi(row[26]); + e.beard_color = atoi(row[27]); + e.eye_color_1 = atoi(row[28]); + e.eye_color_2 = atoi(row[29]); + e.drakkin_heritage = atoi(row[30]); + e.drakkin_tattoo = atoi(row[31]); + e.drakkin_details = atoi(row[32]); + e.ability_time_seconds = atoi(row[33]); + e.ability_number = atoi(row[34]); + e.ability_time_minutes = atoi(row[35]); + e.ability_time_hours = atoi(row[36]); + e.exp = atoi(row[37]); + e.aa_points_spent = atoi(row[38]); + e.aa_exp = atoi(row[39]); + e.aa_points = atoi(row[40]); + e.group_leadership_exp = atoi(row[41]); + e.raid_leadership_exp = atoi(row[42]); + e.group_leadership_points = atoi(row[43]); + e.raid_leadership_points = atoi(row[44]); + e.points = atoi(row[45]); + e.cur_hp = atoi(row[46]); + e.mana = atoi(row[47]); + e.endurance = atoi(row[48]); + e.intoxication = atoi(row[49]); + e.str = atoi(row[50]); + e.sta = atoi(row[51]); + e.cha = atoi(row[52]); + e.dex = atoi(row[53]); + e.int_ = atoi(row[54]); + e.agi = atoi(row[55]); + e.wis = atoi(row[56]); + e.zone_change_count = atoi(row[57]); + e.toxicity = atoi(row[58]); + e.hunger_level = atoi(row[59]); + e.thirst_level = atoi(row[60]); + e.ability_up = atoi(row[61]); + e.ldon_points_guk = atoi(row[62]); + e.ldon_points_mir = atoi(row[63]); + e.ldon_points_mmc = atoi(row[64]); + e.ldon_points_ruj = atoi(row[65]); + e.ldon_points_tak = atoi(row[66]); + e.ldon_points_available = atoi(row[67]); + e.tribute_time_remaining = atoi(row[68]); + e.career_tribute_points = atoi(row[69]); + e.tribute_points = atoi(row[70]); + e.tribute_active = atoi(row[71]); + e.pvp_status = atoi(row[72]); + e.pvp_kills = atoi(row[73]); + e.pvp_deaths = atoi(row[74]); + e.pvp_current_points = atoi(row[75]); + e.pvp_career_points = atoi(row[76]); + e.pvp_best_kill_streak = atoi(row[77]); + e.pvp_worst_death_streak = atoi(row[78]); + e.pvp_current_kill_streak = atoi(row[79]); + e.pvp2 = atoi(row[80]); + e.pvp_type = atoi(row[81]); + e.show_helm = atoi(row[82]); + e.group_auto_consent = atoi(row[83]); + e.raid_auto_consent = atoi(row[84]); + e.guild_auto_consent = atoi(row[85]); + e.leadership_exp_on = atoi(row[86]); + e.RestTimer = atoi(row[87]); + e.air_remaining = atoi(row[88]); + e.autosplit_enabled = atoi(row[89]); + e.lfp = atoi(row[90]); + e.lfg = atoi(row[91]); + e.mailkey = row[92] ? row[92] : ""; + e.xtargets = atoi(row[93]); + e.firstlogon = atoi(row[94]); + e.e_aa_effects = atoi(row[95]); + e.e_percent_to_aa = atoi(row[96]); + e.e_expended_aa_spent = atoi(row[97]); + e.aa_points_spent_old = atoi(row[98]); + e.aa_points_old = atoi(row[99]); + e.e_last_invsnapshot = atoi(row[100]); + e.deleted_at = strtoll(row[101] ? row[101] : "-1", nullptr, 10); - all_entries.push_back(entry); + all_entries.push_back(e); } return all_entries; } - static std::vector GetWhere(Database& db, std::string where_filter) + static std::vector GetWhere(Database& db, const std::string &where_filter) { std::vector all_entries; @@ -1165,118 +1165,118 @@ public: all_entries.reserve(results.RowCount()); for (auto row = results.begin(); row != results.end(); ++row) { - CharacterData entry{}; + CharacterData e{}; - entry.id = atoi(row[0]); - entry.account_id = atoi(row[1]); - entry.name = row[2] ? row[2] : ""; - entry.last_name = row[3] ? row[3] : ""; - entry.title = row[4] ? row[4] : ""; - entry.suffix = row[5] ? row[5] : ""; - entry.zone_id = atoi(row[6]); - entry.zone_instance = atoi(row[7]); - entry.y = static_cast(atof(row[8])); - entry.x = static_cast(atof(row[9])); - entry.z = static_cast(atof(row[10])); - entry.heading = static_cast(atof(row[11])); - entry.gender = atoi(row[12]); - entry.race = atoi(row[13]); - entry.class_ = atoi(row[14]); - entry.level = atoi(row[15]); - entry.deity = atoi(row[16]); - entry.birthday = atoi(row[17]); - entry.last_login = atoi(row[18]); - entry.time_played = atoi(row[19]); - entry.level2 = atoi(row[20]); - entry.anon = atoi(row[21]); - entry.gm = atoi(row[22]); - entry.face = atoi(row[23]); - entry.hair_color = atoi(row[24]); - entry.hair_style = atoi(row[25]); - entry.beard = atoi(row[26]); - entry.beard_color = atoi(row[27]); - entry.eye_color_1 = atoi(row[28]); - entry.eye_color_2 = atoi(row[29]); - entry.drakkin_heritage = atoi(row[30]); - entry.drakkin_tattoo = atoi(row[31]); - entry.drakkin_details = atoi(row[32]); - entry.ability_time_seconds = atoi(row[33]); - entry.ability_number = atoi(row[34]); - entry.ability_time_minutes = atoi(row[35]); - entry.ability_time_hours = atoi(row[36]); - entry.exp = atoi(row[37]); - entry.aa_points_spent = atoi(row[38]); - entry.aa_exp = atoi(row[39]); - entry.aa_points = atoi(row[40]); - entry.group_leadership_exp = atoi(row[41]); - entry.raid_leadership_exp = atoi(row[42]); - entry.group_leadership_points = atoi(row[43]); - entry.raid_leadership_points = atoi(row[44]); - entry.points = atoi(row[45]); - entry.cur_hp = atoi(row[46]); - entry.mana = atoi(row[47]); - entry.endurance = atoi(row[48]); - entry.intoxication = atoi(row[49]); - entry.str = atoi(row[50]); - entry.sta = atoi(row[51]); - entry.cha = atoi(row[52]); - entry.dex = atoi(row[53]); - entry.int_ = atoi(row[54]); - entry.agi = atoi(row[55]); - entry.wis = atoi(row[56]); - entry.zone_change_count = atoi(row[57]); - entry.toxicity = atoi(row[58]); - entry.hunger_level = atoi(row[59]); - entry.thirst_level = atoi(row[60]); - entry.ability_up = atoi(row[61]); - entry.ldon_points_guk = atoi(row[62]); - entry.ldon_points_mir = atoi(row[63]); - entry.ldon_points_mmc = atoi(row[64]); - entry.ldon_points_ruj = atoi(row[65]); - entry.ldon_points_tak = atoi(row[66]); - entry.ldon_points_available = atoi(row[67]); - entry.tribute_time_remaining = atoi(row[68]); - entry.career_tribute_points = atoi(row[69]); - entry.tribute_points = atoi(row[70]); - entry.tribute_active = atoi(row[71]); - entry.pvp_status = atoi(row[72]); - entry.pvp_kills = atoi(row[73]); - entry.pvp_deaths = atoi(row[74]); - entry.pvp_current_points = atoi(row[75]); - entry.pvp_career_points = atoi(row[76]); - entry.pvp_best_kill_streak = atoi(row[77]); - entry.pvp_worst_death_streak = atoi(row[78]); - entry.pvp_current_kill_streak = atoi(row[79]); - entry.pvp2 = atoi(row[80]); - entry.pvp_type = atoi(row[81]); - entry.show_helm = atoi(row[82]); - entry.group_auto_consent = atoi(row[83]); - entry.raid_auto_consent = atoi(row[84]); - entry.guild_auto_consent = atoi(row[85]); - entry.leadership_exp_on = atoi(row[86]); - entry.RestTimer = atoi(row[87]); - entry.air_remaining = atoi(row[88]); - entry.autosplit_enabled = atoi(row[89]); - entry.lfp = atoi(row[90]); - entry.lfg = atoi(row[91]); - entry.mailkey = row[92] ? row[92] : ""; - entry.xtargets = atoi(row[93]); - entry.firstlogon = atoi(row[94]); - entry.e_aa_effects = atoi(row[95]); - entry.e_percent_to_aa = atoi(row[96]); - entry.e_expended_aa_spent = atoi(row[97]); - entry.aa_points_spent_old = atoi(row[98]); - entry.aa_points_old = atoi(row[99]); - entry.e_last_invsnapshot = atoi(row[100]); - entry.deleted_at = strtoll(row[101] ? row[101] : "-1", nullptr, 10); + e.id = atoi(row[0]); + e.account_id = atoi(row[1]); + e.name = row[2] ? row[2] : ""; + e.last_name = row[3] ? row[3] : ""; + e.title = row[4] ? row[4] : ""; + e.suffix = row[5] ? row[5] : ""; + e.zone_id = atoi(row[6]); + e.zone_instance = atoi(row[7]); + e.y = static_cast(atof(row[8])); + e.x = static_cast(atof(row[9])); + e.z = static_cast(atof(row[10])); + e.heading = static_cast(atof(row[11])); + e.gender = atoi(row[12]); + e.race = atoi(row[13]); + e.class_ = atoi(row[14]); + e.level = atoi(row[15]); + e.deity = atoi(row[16]); + e.birthday = atoi(row[17]); + e.last_login = atoi(row[18]); + e.time_played = atoi(row[19]); + e.level2 = atoi(row[20]); + e.anon = atoi(row[21]); + e.gm = atoi(row[22]); + e.face = atoi(row[23]); + e.hair_color = atoi(row[24]); + e.hair_style = atoi(row[25]); + e.beard = atoi(row[26]); + e.beard_color = atoi(row[27]); + e.eye_color_1 = atoi(row[28]); + e.eye_color_2 = atoi(row[29]); + e.drakkin_heritage = atoi(row[30]); + e.drakkin_tattoo = atoi(row[31]); + e.drakkin_details = atoi(row[32]); + e.ability_time_seconds = atoi(row[33]); + e.ability_number = atoi(row[34]); + e.ability_time_minutes = atoi(row[35]); + e.ability_time_hours = atoi(row[36]); + e.exp = atoi(row[37]); + e.aa_points_spent = atoi(row[38]); + e.aa_exp = atoi(row[39]); + e.aa_points = atoi(row[40]); + e.group_leadership_exp = atoi(row[41]); + e.raid_leadership_exp = atoi(row[42]); + e.group_leadership_points = atoi(row[43]); + e.raid_leadership_points = atoi(row[44]); + e.points = atoi(row[45]); + e.cur_hp = atoi(row[46]); + e.mana = atoi(row[47]); + e.endurance = atoi(row[48]); + e.intoxication = atoi(row[49]); + e.str = atoi(row[50]); + e.sta = atoi(row[51]); + e.cha = atoi(row[52]); + e.dex = atoi(row[53]); + e.int_ = atoi(row[54]); + e.agi = atoi(row[55]); + e.wis = atoi(row[56]); + e.zone_change_count = atoi(row[57]); + e.toxicity = atoi(row[58]); + e.hunger_level = atoi(row[59]); + e.thirst_level = atoi(row[60]); + e.ability_up = atoi(row[61]); + e.ldon_points_guk = atoi(row[62]); + e.ldon_points_mir = atoi(row[63]); + e.ldon_points_mmc = atoi(row[64]); + e.ldon_points_ruj = atoi(row[65]); + e.ldon_points_tak = atoi(row[66]); + e.ldon_points_available = atoi(row[67]); + e.tribute_time_remaining = atoi(row[68]); + e.career_tribute_points = atoi(row[69]); + e.tribute_points = atoi(row[70]); + e.tribute_active = atoi(row[71]); + e.pvp_status = atoi(row[72]); + e.pvp_kills = atoi(row[73]); + e.pvp_deaths = atoi(row[74]); + e.pvp_current_points = atoi(row[75]); + e.pvp_career_points = atoi(row[76]); + e.pvp_best_kill_streak = atoi(row[77]); + e.pvp_worst_death_streak = atoi(row[78]); + e.pvp_current_kill_streak = atoi(row[79]); + e.pvp2 = atoi(row[80]); + e.pvp_type = atoi(row[81]); + e.show_helm = atoi(row[82]); + e.group_auto_consent = atoi(row[83]); + e.raid_auto_consent = atoi(row[84]); + e.guild_auto_consent = atoi(row[85]); + e.leadership_exp_on = atoi(row[86]); + e.RestTimer = atoi(row[87]); + e.air_remaining = atoi(row[88]); + e.autosplit_enabled = atoi(row[89]); + e.lfp = atoi(row[90]); + e.lfg = atoi(row[91]); + e.mailkey = row[92] ? row[92] : ""; + e.xtargets = atoi(row[93]); + e.firstlogon = atoi(row[94]); + e.e_aa_effects = atoi(row[95]); + e.e_percent_to_aa = atoi(row[96]); + e.e_expended_aa_spent = atoi(row[97]); + e.aa_points_spent_old = atoi(row[98]); + e.aa_points_old = atoi(row[99]); + e.e_last_invsnapshot = atoi(row[100]); + e.deleted_at = strtoll(row[101] ? row[101] : "-1", nullptr, 10); - all_entries.push_back(entry); + all_entries.push_back(e); } return all_entries; } - static int DeleteWhere(Database& db, std::string where_filter) + static int DeleteWhere(Database& db, const std::string &where_filter) { auto results = db.QueryDatabase( fmt::format( @@ -1301,6 +1301,32 @@ public: 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); + } + }; #endif //EQEMU_BASE_CHARACTER_DATA_REPOSITORY_H diff --git a/common/repositories/base/base_character_disciplines_repository.h b/common/repositories/base/base_character_disciplines_repository.h index 0730e876d..7ddbe63bb 100644 --- a/common/repositories/base/base_character_disciplines_repository.h +++ b/common/repositories/base/base_character_disciplines_repository.h @@ -82,16 +82,16 @@ public: static CharacterDisciplines NewEntity() { - CharacterDisciplines entry{}; + CharacterDisciplines e{}; - entry.id = 0; - entry.slot_id = 0; - entry.disc_id = 0; + e.id = 0; + e.slot_id = 0; + e.disc_id = 0; - return entry; + return e; } - static CharacterDisciplines GetCharacterDisciplinesEntry( + static CharacterDisciplines GetCharacterDisciplines( const std::vector &character_discipliness, int character_disciplines_id ) @@ -120,13 +120,13 @@ public: auto row = results.begin(); if (results.RowCount() == 1) { - CharacterDisciplines entry{}; + CharacterDisciplines e{}; - entry.id = atoi(row[0]); - entry.slot_id = atoi(row[1]); - entry.disc_id = atoi(row[2]); + e.id = atoi(row[0]); + e.slot_id = atoi(row[1]); + e.disc_id = atoi(row[2]); - return entry; + return e; } return NewEntity(); @@ -151,24 +151,24 @@ public: static int UpdateOne( Database& db, - CharacterDisciplines character_disciplines_entry + const CharacterDisciplines &e ) { - std::vector update_values; + std::vector v; auto columns = Columns(); - update_values.push_back(columns[0] + " = " + std::to_string(character_disciplines_entry.id)); - update_values.push_back(columns[1] + " = " + std::to_string(character_disciplines_entry.slot_id)); - update_values.push_back(columns[2] + " = " + std::to_string(character_disciplines_entry.disc_id)); + v.push_back(columns[0] + " = " + std::to_string(e.id)); + v.push_back(columns[1] + " = " + std::to_string(e.slot_id)); + v.push_back(columns[2] + " = " + std::to_string(e.disc_id)); auto results = db.QueryDatabase( fmt::format( "UPDATE {} SET {} WHERE {} = {}", TableName(), - Strings::Implode(", ", update_values), + Strings::Implode(", ", v), PrimaryKey(), - character_disciplines_entry.id + e.id ) ); @@ -177,51 +177,51 @@ public: static CharacterDisciplines InsertOne( Database& db, - CharacterDisciplines character_disciplines_entry + CharacterDisciplines e ) { - std::vector insert_values; + std::vector v; - insert_values.push_back(std::to_string(character_disciplines_entry.id)); - insert_values.push_back(std::to_string(character_disciplines_entry.slot_id)); - insert_values.push_back(std::to_string(character_disciplines_entry.disc_id)); + v.push_back(std::to_string(e.id)); + v.push_back(std::to_string(e.slot_id)); + v.push_back(std::to_string(e.disc_id)); auto results = db.QueryDatabase( fmt::format( "{} VALUES ({})", BaseInsert(), - Strings::Implode(",", insert_values) + Strings::Implode(",", v) ) ); if (results.Success()) { - character_disciplines_entry.id = results.LastInsertedID(); - return character_disciplines_entry; + e.id = results.LastInsertedID(); + return e; } - character_disciplines_entry = NewEntity(); + e = NewEntity(); - return character_disciplines_entry; + return e; } static int InsertMany( Database& db, - std::vector character_disciplines_entries + const std::vector &entries ) { std::vector insert_chunks; - for (auto &character_disciplines_entry: character_disciplines_entries) { - std::vector insert_values; + for (auto &e: entries) { + std::vector v; - insert_values.push_back(std::to_string(character_disciplines_entry.id)); - insert_values.push_back(std::to_string(character_disciplines_entry.slot_id)); - insert_values.push_back(std::to_string(character_disciplines_entry.disc_id)); + v.push_back(std::to_string(e.id)); + v.push_back(std::to_string(e.slot_id)); + v.push_back(std::to_string(e.disc_id)); - insert_chunks.push_back("(" + Strings::Implode(",", insert_values) + ")"); + insert_chunks.push_back("(" + Strings::Implode(",", v) + ")"); } - std::vector insert_values; + std::vector v; auto results = db.QueryDatabase( fmt::format( @@ -248,19 +248,19 @@ public: all_entries.reserve(results.RowCount()); for (auto row = results.begin(); row != results.end(); ++row) { - CharacterDisciplines entry{}; + CharacterDisciplines e{}; - entry.id = atoi(row[0]); - entry.slot_id = atoi(row[1]); - entry.disc_id = atoi(row[2]); + e.id = atoi(row[0]); + e.slot_id = atoi(row[1]); + e.disc_id = atoi(row[2]); - all_entries.push_back(entry); + all_entries.push_back(e); } return all_entries; } - static std::vector GetWhere(Database& db, std::string where_filter) + static std::vector GetWhere(Database& db, const std::string &where_filter) { std::vector all_entries; @@ -275,19 +275,19 @@ public: all_entries.reserve(results.RowCount()); for (auto row = results.begin(); row != results.end(); ++row) { - CharacterDisciplines entry{}; + CharacterDisciplines e{}; - entry.id = atoi(row[0]); - entry.slot_id = atoi(row[1]); - entry.disc_id = atoi(row[2]); + e.id = atoi(row[0]); + e.slot_id = atoi(row[1]); + e.disc_id = atoi(row[2]); - all_entries.push_back(entry); + all_entries.push_back(e); } return all_entries; } - static int DeleteWhere(Database& db, std::string where_filter) + static int DeleteWhere(Database& db, const std::string &where_filter) { auto results = db.QueryDatabase( fmt::format( @@ -312,6 +312,32 @@ public: 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); + } + }; #endif //EQEMU_BASE_CHARACTER_DISCIPLINES_REPOSITORY_H diff --git a/common/repositories/base/base_character_exp_modifiers_repository.h b/common/repositories/base/base_character_exp_modifiers_repository.h index 2e367d703..7be708d36 100644 --- a/common/repositories/base/base_character_exp_modifiers_repository.h +++ b/common/repositories/base/base_character_exp_modifiers_repository.h @@ -85,17 +85,17 @@ public: static CharacterExpModifiers NewEntity() { - CharacterExpModifiers entry{}; + CharacterExpModifiers e{}; - entry.character_id = 0; - entry.zone_id = 0; - entry.aa_modifier = 0; - entry.exp_modifier = 0; + e.character_id = 0; + e.zone_id = 0; + e.aa_modifier = 0; + e.exp_modifier = 0; - return entry; + return e; } - static CharacterExpModifiers GetCharacterExpModifiersEntry( + static CharacterExpModifiers GetCharacterExpModifiers( const std::vector &character_exp_modifierss, int character_exp_modifiers_id ) @@ -124,14 +124,14 @@ public: auto row = results.begin(); if (results.RowCount() == 1) { - CharacterExpModifiers entry{}; + CharacterExpModifiers e{}; - entry.character_id = atoi(row[0]); - entry.zone_id = atoi(row[1]); - entry.aa_modifier = static_cast(atof(row[2])); - entry.exp_modifier = static_cast(atof(row[3])); + e.character_id = atoi(row[0]); + e.zone_id = atoi(row[1]); + e.aa_modifier = static_cast(atof(row[2])); + e.exp_modifier = static_cast(atof(row[3])); - return entry; + return e; } return NewEntity(); @@ -156,25 +156,25 @@ public: static int UpdateOne( Database& db, - CharacterExpModifiers character_exp_modifiers_entry + const CharacterExpModifiers &e ) { - std::vector update_values; + std::vector v; auto columns = Columns(); - update_values.push_back(columns[0] + " = " + std::to_string(character_exp_modifiers_entry.character_id)); - update_values.push_back(columns[1] + " = " + std::to_string(character_exp_modifiers_entry.zone_id)); - update_values.push_back(columns[2] + " = " + std::to_string(character_exp_modifiers_entry.aa_modifier)); - update_values.push_back(columns[3] + " = " + std::to_string(character_exp_modifiers_entry.exp_modifier)); + v.push_back(columns[0] + " = " + std::to_string(e.character_id)); + v.push_back(columns[1] + " = " + std::to_string(e.zone_id)); + v.push_back(columns[2] + " = " + std::to_string(e.aa_modifier)); + v.push_back(columns[3] + " = " + std::to_string(e.exp_modifier)); auto results = db.QueryDatabase( fmt::format( "UPDATE {} SET {} WHERE {} = {}", TableName(), - Strings::Implode(", ", update_values), + Strings::Implode(", ", v), PrimaryKey(), - character_exp_modifiers_entry.character_id + e.character_id ) ); @@ -183,53 +183,53 @@ public: static CharacterExpModifiers InsertOne( Database& db, - CharacterExpModifiers character_exp_modifiers_entry + CharacterExpModifiers e ) { - std::vector insert_values; + std::vector v; - insert_values.push_back(std::to_string(character_exp_modifiers_entry.character_id)); - insert_values.push_back(std::to_string(character_exp_modifiers_entry.zone_id)); - insert_values.push_back(std::to_string(character_exp_modifiers_entry.aa_modifier)); - insert_values.push_back(std::to_string(character_exp_modifiers_entry.exp_modifier)); + v.push_back(std::to_string(e.character_id)); + v.push_back(std::to_string(e.zone_id)); + v.push_back(std::to_string(e.aa_modifier)); + v.push_back(std::to_string(e.exp_modifier)); auto results = db.QueryDatabase( fmt::format( "{} VALUES ({})", BaseInsert(), - Strings::Implode(",", insert_values) + Strings::Implode(",", v) ) ); if (results.Success()) { - character_exp_modifiers_entry.character_id = results.LastInsertedID(); - return character_exp_modifiers_entry; + e.character_id = results.LastInsertedID(); + return e; } - character_exp_modifiers_entry = NewEntity(); + e = NewEntity(); - return character_exp_modifiers_entry; + return e; } static int InsertMany( Database& db, - std::vector character_exp_modifiers_entries + const std::vector &entries ) { std::vector insert_chunks; - for (auto &character_exp_modifiers_entry: character_exp_modifiers_entries) { - std::vector insert_values; + for (auto &e: entries) { + std::vector v; - insert_values.push_back(std::to_string(character_exp_modifiers_entry.character_id)); - insert_values.push_back(std::to_string(character_exp_modifiers_entry.zone_id)); - insert_values.push_back(std::to_string(character_exp_modifiers_entry.aa_modifier)); - insert_values.push_back(std::to_string(character_exp_modifiers_entry.exp_modifier)); + v.push_back(std::to_string(e.character_id)); + v.push_back(std::to_string(e.zone_id)); + v.push_back(std::to_string(e.aa_modifier)); + v.push_back(std::to_string(e.exp_modifier)); - insert_chunks.push_back("(" + Strings::Implode(",", insert_values) + ")"); + insert_chunks.push_back("(" + Strings::Implode(",", v) + ")"); } - std::vector insert_values; + std::vector v; auto results = db.QueryDatabase( fmt::format( @@ -256,20 +256,20 @@ public: all_entries.reserve(results.RowCount()); for (auto row = results.begin(); row != results.end(); ++row) { - CharacterExpModifiers entry{}; + CharacterExpModifiers e{}; - entry.character_id = atoi(row[0]); - entry.zone_id = atoi(row[1]); - entry.aa_modifier = static_cast(atof(row[2])); - entry.exp_modifier = static_cast(atof(row[3])); + e.character_id = atoi(row[0]); + e.zone_id = atoi(row[1]); + e.aa_modifier = static_cast(atof(row[2])); + e.exp_modifier = static_cast(atof(row[3])); - all_entries.push_back(entry); + all_entries.push_back(e); } return all_entries; } - static std::vector GetWhere(Database& db, std::string where_filter) + static std::vector GetWhere(Database& db, const std::string &where_filter) { std::vector all_entries; @@ -284,20 +284,20 @@ public: all_entries.reserve(results.RowCount()); for (auto row = results.begin(); row != results.end(); ++row) { - CharacterExpModifiers entry{}; + CharacterExpModifiers e{}; - entry.character_id = atoi(row[0]); - entry.zone_id = atoi(row[1]); - entry.aa_modifier = static_cast(atof(row[2])); - entry.exp_modifier = static_cast(atof(row[3])); + e.character_id = atoi(row[0]); + e.zone_id = atoi(row[1]); + e.aa_modifier = static_cast(atof(row[2])); + e.exp_modifier = static_cast(atof(row[3])); - all_entries.push_back(entry); + all_entries.push_back(e); } return all_entries; } - static int DeleteWhere(Database& db, std::string where_filter) + static int DeleteWhere(Database& db, const std::string &where_filter) { auto results = db.QueryDatabase( fmt::format( @@ -322,6 +322,32 @@ public: 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); + } + }; #endif //EQEMU_BASE_CHARACTER_EXP_MODIFIERS_REPOSITORY_H diff --git a/common/repositories/base/base_character_expedition_lockouts_repository.h b/common/repositories/base/base_character_expedition_lockouts_repository.h index b3bc5e4a1..47b619736 100644 --- a/common/repositories/base/base_character_expedition_lockouts_repository.h +++ b/common/repositories/base/base_character_expedition_lockouts_repository.h @@ -94,20 +94,20 @@ public: static CharacterExpeditionLockouts NewEntity() { - CharacterExpeditionLockouts entry{}; + CharacterExpeditionLockouts e{}; - entry.id = 0; - entry.character_id = 0; - entry.expedition_name = ""; - entry.event_name = ""; - entry.expire_time = std::time(nullptr); - entry.duration = 0; - entry.from_expedition_uuid = ""; + e.id = 0; + e.character_id = 0; + e.expedition_name = ""; + e.event_name = ""; + e.expire_time = std::time(nullptr); + e.duration = 0; + e.from_expedition_uuid = ""; - return entry; + return e; } - static CharacterExpeditionLockouts GetCharacterExpeditionLockoutsEntry( + static CharacterExpeditionLockouts GetCharacterExpeditionLockouts( const std::vector &character_expedition_lockoutss, int character_expedition_lockouts_id ) @@ -136,17 +136,17 @@ public: auto row = results.begin(); if (results.RowCount() == 1) { - CharacterExpeditionLockouts entry{}; + CharacterExpeditionLockouts e{}; - entry.id = atoi(row[0]); - entry.character_id = atoi(row[1]); - entry.expedition_name = row[2] ? row[2] : ""; - entry.event_name = row[3] ? row[3] : ""; - entry.expire_time = strtoll(row[4] ? row[4] : "-1", nullptr, 10); - entry.duration = atoi(row[5]); - entry.from_expedition_uuid = row[6] ? row[6] : ""; + e.id = atoi(row[0]); + e.character_id = atoi(row[1]); + e.expedition_name = row[2] ? row[2] : ""; + e.event_name = row[3] ? row[3] : ""; + e.expire_time = strtoll(row[4] ? row[4] : "-1", nullptr, 10); + e.duration = atoi(row[5]); + e.from_expedition_uuid = row[6] ? row[6] : ""; - return entry; + return e; } return NewEntity(); @@ -171,27 +171,27 @@ public: static int UpdateOne( Database& db, - CharacterExpeditionLockouts character_expedition_lockouts_entry + const CharacterExpeditionLockouts &e ) { - std::vector update_values; + std::vector v; auto columns = Columns(); - update_values.push_back(columns[1] + " = " + std::to_string(character_expedition_lockouts_entry.character_id)); - update_values.push_back(columns[2] + " = '" + Strings::Escape(character_expedition_lockouts_entry.expedition_name) + "'"); - update_values.push_back(columns[3] + " = '" + Strings::Escape(character_expedition_lockouts_entry.event_name) + "'"); - update_values.push_back(columns[4] + " = FROM_UNIXTIME(" + (character_expedition_lockouts_entry.expire_time > 0 ? std::to_string(character_expedition_lockouts_entry.expire_time) : "null") + ")"); - update_values.push_back(columns[5] + " = " + std::to_string(character_expedition_lockouts_entry.duration)); - update_values.push_back(columns[6] + " = '" + Strings::Escape(character_expedition_lockouts_entry.from_expedition_uuid) + "'"); + v.push_back(columns[1] + " = " + std::to_string(e.character_id)); + v.push_back(columns[2] + " = '" + Strings::Escape(e.expedition_name) + "'"); + v.push_back(columns[3] + " = '" + Strings::Escape(e.event_name) + "'"); + v.push_back(columns[4] + " = FROM_UNIXTIME(" + (e.expire_time > 0 ? std::to_string(e.expire_time) : "null") + ")"); + v.push_back(columns[5] + " = " + std::to_string(e.duration)); + v.push_back(columns[6] + " = '" + Strings::Escape(e.from_expedition_uuid) + "'"); auto results = db.QueryDatabase( fmt::format( "UPDATE {} SET {} WHERE {} = {}", TableName(), - Strings::Implode(", ", update_values), + Strings::Implode(", ", v), PrimaryKey(), - character_expedition_lockouts_entry.id + e.id ) ); @@ -200,59 +200,59 @@ public: static CharacterExpeditionLockouts InsertOne( Database& db, - CharacterExpeditionLockouts character_expedition_lockouts_entry + CharacterExpeditionLockouts e ) { - std::vector insert_values; + std::vector v; - insert_values.push_back(std::to_string(character_expedition_lockouts_entry.id)); - insert_values.push_back(std::to_string(character_expedition_lockouts_entry.character_id)); - insert_values.push_back("'" + Strings::Escape(character_expedition_lockouts_entry.expedition_name) + "'"); - insert_values.push_back("'" + Strings::Escape(character_expedition_lockouts_entry.event_name) + "'"); - insert_values.push_back("FROM_UNIXTIME(" + (character_expedition_lockouts_entry.expire_time > 0 ? std::to_string(character_expedition_lockouts_entry.expire_time) : "null") + ")"); - insert_values.push_back(std::to_string(character_expedition_lockouts_entry.duration)); - insert_values.push_back("'" + Strings::Escape(character_expedition_lockouts_entry.from_expedition_uuid) + "'"); + v.push_back(std::to_string(e.id)); + v.push_back(std::to_string(e.character_id)); + v.push_back("'" + Strings::Escape(e.expedition_name) + "'"); + v.push_back("'" + Strings::Escape(e.event_name) + "'"); + v.push_back("FROM_UNIXTIME(" + (e.expire_time > 0 ? std::to_string(e.expire_time) : "null") + ")"); + v.push_back(std::to_string(e.duration)); + v.push_back("'" + Strings::Escape(e.from_expedition_uuid) + "'"); auto results = db.QueryDatabase( fmt::format( "{} VALUES ({})", BaseInsert(), - Strings::Implode(",", insert_values) + Strings::Implode(",", v) ) ); if (results.Success()) { - character_expedition_lockouts_entry.id = results.LastInsertedID(); - return character_expedition_lockouts_entry; + e.id = results.LastInsertedID(); + return e; } - character_expedition_lockouts_entry = NewEntity(); + e = NewEntity(); - return character_expedition_lockouts_entry; + return e; } static int InsertMany( Database& db, - std::vector character_expedition_lockouts_entries + const std::vector &entries ) { std::vector insert_chunks; - for (auto &character_expedition_lockouts_entry: character_expedition_lockouts_entries) { - std::vector insert_values; + for (auto &e: entries) { + std::vector v; - insert_values.push_back(std::to_string(character_expedition_lockouts_entry.id)); - insert_values.push_back(std::to_string(character_expedition_lockouts_entry.character_id)); - insert_values.push_back("'" + Strings::Escape(character_expedition_lockouts_entry.expedition_name) + "'"); - insert_values.push_back("'" + Strings::Escape(character_expedition_lockouts_entry.event_name) + "'"); - insert_values.push_back("FROM_UNIXTIME(" + (character_expedition_lockouts_entry.expire_time > 0 ? std::to_string(character_expedition_lockouts_entry.expire_time) : "null") + ")"); - insert_values.push_back(std::to_string(character_expedition_lockouts_entry.duration)); - insert_values.push_back("'" + Strings::Escape(character_expedition_lockouts_entry.from_expedition_uuid) + "'"); + v.push_back(std::to_string(e.id)); + v.push_back(std::to_string(e.character_id)); + v.push_back("'" + Strings::Escape(e.expedition_name) + "'"); + v.push_back("'" + Strings::Escape(e.event_name) + "'"); + v.push_back("FROM_UNIXTIME(" + (e.expire_time > 0 ? std::to_string(e.expire_time) : "null") + ")"); + v.push_back(std::to_string(e.duration)); + v.push_back("'" + Strings::Escape(e.from_expedition_uuid) + "'"); - insert_chunks.push_back("(" + Strings::Implode(",", insert_values) + ")"); + insert_chunks.push_back("(" + Strings::Implode(",", v) + ")"); } - std::vector insert_values; + std::vector v; auto results = db.QueryDatabase( fmt::format( @@ -279,23 +279,23 @@ public: all_entries.reserve(results.RowCount()); for (auto row = results.begin(); row != results.end(); ++row) { - CharacterExpeditionLockouts entry{}; + CharacterExpeditionLockouts e{}; - entry.id = atoi(row[0]); - entry.character_id = atoi(row[1]); - entry.expedition_name = row[2] ? row[2] : ""; - entry.event_name = row[3] ? row[3] : ""; - entry.expire_time = strtoll(row[4] ? row[4] : "-1", nullptr, 10); - entry.duration = atoi(row[5]); - entry.from_expedition_uuid = row[6] ? row[6] : ""; + e.id = atoi(row[0]); + e.character_id = atoi(row[1]); + e.expedition_name = row[2] ? row[2] : ""; + e.event_name = row[3] ? row[3] : ""; + e.expire_time = strtoll(row[4] ? row[4] : "-1", nullptr, 10); + e.duration = atoi(row[5]); + e.from_expedition_uuid = row[6] ? row[6] : ""; - all_entries.push_back(entry); + all_entries.push_back(e); } return all_entries; } - static std::vector GetWhere(Database& db, std::string where_filter) + static std::vector GetWhere(Database& db, const std::string &where_filter) { std::vector all_entries; @@ -310,23 +310,23 @@ public: all_entries.reserve(results.RowCount()); for (auto row = results.begin(); row != results.end(); ++row) { - CharacterExpeditionLockouts entry{}; + CharacterExpeditionLockouts e{}; - entry.id = atoi(row[0]); - entry.character_id = atoi(row[1]); - entry.expedition_name = row[2] ? row[2] : ""; - entry.event_name = row[3] ? row[3] : ""; - entry.expire_time = strtoll(row[4] ? row[4] : "-1", nullptr, 10); - entry.duration = atoi(row[5]); - entry.from_expedition_uuid = row[6] ? row[6] : ""; + e.id = atoi(row[0]); + e.character_id = atoi(row[1]); + e.expedition_name = row[2] ? row[2] : ""; + e.event_name = row[3] ? row[3] : ""; + e.expire_time = strtoll(row[4] ? row[4] : "-1", nullptr, 10); + e.duration = atoi(row[5]); + e.from_expedition_uuid = row[6] ? row[6] : ""; - all_entries.push_back(entry); + all_entries.push_back(e); } return all_entries; } - static int DeleteWhere(Database& db, std::string where_filter) + static int DeleteWhere(Database& db, const std::string &where_filter) { auto results = db.QueryDatabase( fmt::format( @@ -351,6 +351,32 @@ public: 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); + } + }; #endif //EQEMU_BASE_CHARACTER_EXPEDITION_LOCKOUTS_REPOSITORY_H diff --git a/common/repositories/base/base_character_inspect_messages_repository.h b/common/repositories/base/base_character_inspect_messages_repository.h index de2789c94..94234b65b 100644 --- a/common/repositories/base/base_character_inspect_messages_repository.h +++ b/common/repositories/base/base_character_inspect_messages_repository.h @@ -79,15 +79,15 @@ public: static CharacterInspectMessages NewEntity() { - CharacterInspectMessages entry{}; + CharacterInspectMessages e{}; - entry.id = 0; - entry.inspect_message = ""; + e.id = 0; + e.inspect_message = ""; - return entry; + return e; } - static CharacterInspectMessages GetCharacterInspectMessagesEntry( + static CharacterInspectMessages GetCharacterInspectMessages( const std::vector &character_inspect_messagess, int character_inspect_messages_id ) @@ -116,12 +116,12 @@ public: auto row = results.begin(); if (results.RowCount() == 1) { - CharacterInspectMessages entry{}; + CharacterInspectMessages e{}; - entry.id = atoi(row[0]); - entry.inspect_message = row[1] ? row[1] : ""; + e.id = atoi(row[0]); + e.inspect_message = row[1] ? row[1] : ""; - return entry; + return e; } return NewEntity(); @@ -146,23 +146,23 @@ public: static int UpdateOne( Database& db, - CharacterInspectMessages character_inspect_messages_entry + const CharacterInspectMessages &e ) { - std::vector update_values; + std::vector v; auto columns = Columns(); - update_values.push_back(columns[0] + " = " + std::to_string(character_inspect_messages_entry.id)); - update_values.push_back(columns[1] + " = '" + Strings::Escape(character_inspect_messages_entry.inspect_message) + "'"); + v.push_back(columns[0] + " = " + std::to_string(e.id)); + v.push_back(columns[1] + " = '" + Strings::Escape(e.inspect_message) + "'"); auto results = db.QueryDatabase( fmt::format( "UPDATE {} SET {} WHERE {} = {}", TableName(), - Strings::Implode(", ", update_values), + Strings::Implode(", ", v), PrimaryKey(), - character_inspect_messages_entry.id + e.id ) ); @@ -171,49 +171,49 @@ public: static CharacterInspectMessages InsertOne( Database& db, - CharacterInspectMessages character_inspect_messages_entry + CharacterInspectMessages e ) { - std::vector insert_values; + std::vector v; - insert_values.push_back(std::to_string(character_inspect_messages_entry.id)); - insert_values.push_back("'" + Strings::Escape(character_inspect_messages_entry.inspect_message) + "'"); + v.push_back(std::to_string(e.id)); + v.push_back("'" + Strings::Escape(e.inspect_message) + "'"); auto results = db.QueryDatabase( fmt::format( "{} VALUES ({})", BaseInsert(), - Strings::Implode(",", insert_values) + Strings::Implode(",", v) ) ); if (results.Success()) { - character_inspect_messages_entry.id = results.LastInsertedID(); - return character_inspect_messages_entry; + e.id = results.LastInsertedID(); + return e; } - character_inspect_messages_entry = NewEntity(); + e = NewEntity(); - return character_inspect_messages_entry; + return e; } static int InsertMany( Database& db, - std::vector character_inspect_messages_entries + const std::vector &entries ) { std::vector insert_chunks; - for (auto &character_inspect_messages_entry: character_inspect_messages_entries) { - std::vector insert_values; + for (auto &e: entries) { + std::vector v; - insert_values.push_back(std::to_string(character_inspect_messages_entry.id)); - insert_values.push_back("'" + Strings::Escape(character_inspect_messages_entry.inspect_message) + "'"); + v.push_back(std::to_string(e.id)); + v.push_back("'" + Strings::Escape(e.inspect_message) + "'"); - insert_chunks.push_back("(" + Strings::Implode(",", insert_values) + ")"); + insert_chunks.push_back("(" + Strings::Implode(",", v) + ")"); } - std::vector insert_values; + std::vector v; auto results = db.QueryDatabase( fmt::format( @@ -240,18 +240,18 @@ public: all_entries.reserve(results.RowCount()); for (auto row = results.begin(); row != results.end(); ++row) { - CharacterInspectMessages entry{}; + CharacterInspectMessages e{}; - entry.id = atoi(row[0]); - entry.inspect_message = row[1] ? row[1] : ""; + e.id = atoi(row[0]); + e.inspect_message = row[1] ? row[1] : ""; - all_entries.push_back(entry); + all_entries.push_back(e); } return all_entries; } - static std::vector GetWhere(Database& db, std::string where_filter) + static std::vector GetWhere(Database& db, const std::string &where_filter) { std::vector all_entries; @@ -266,18 +266,18 @@ public: all_entries.reserve(results.RowCount()); for (auto row = results.begin(); row != results.end(); ++row) { - CharacterInspectMessages entry{}; + CharacterInspectMessages e{}; - entry.id = atoi(row[0]); - entry.inspect_message = row[1] ? row[1] : ""; + e.id = atoi(row[0]); + e.inspect_message = row[1] ? row[1] : ""; - all_entries.push_back(entry); + all_entries.push_back(e); } return all_entries; } - static int DeleteWhere(Database& db, std::string where_filter) + static int DeleteWhere(Database& db, const std::string &where_filter) { auto results = db.QueryDatabase( fmt::format( @@ -302,6 +302,32 @@ public: 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); + } + }; #endif //EQEMU_BASE_CHARACTER_INSPECT_MESSAGES_REPOSITORY_H diff --git a/common/repositories/base/base_character_instance_safereturns_repository.h b/common/repositories/base/base_character_instance_safereturns_repository.h index f751f7b0a..ba4c9249f 100644 --- a/common/repositories/base/base_character_instance_safereturns_repository.h +++ b/common/repositories/base/base_character_instance_safereturns_repository.h @@ -100,22 +100,22 @@ public: static CharacterInstanceSafereturns NewEntity() { - CharacterInstanceSafereturns entry{}; + CharacterInstanceSafereturns e{}; - entry.id = 0; - entry.character_id = 0; - entry.instance_zone_id = 0; - entry.instance_id = 0; - entry.safe_zone_id = 0; - entry.safe_x = 0; - entry.safe_y = 0; - entry.safe_z = 0; - entry.safe_heading = 0; + e.id = 0; + e.character_id = 0; + e.instance_zone_id = 0; + e.instance_id = 0; + e.safe_zone_id = 0; + e.safe_x = 0; + e.safe_y = 0; + e.safe_z = 0; + e.safe_heading = 0; - return entry; + return e; } - static CharacterInstanceSafereturns GetCharacterInstanceSafereturnsEntry( + static CharacterInstanceSafereturns GetCharacterInstanceSafereturns( const std::vector &character_instance_safereturnss, int character_instance_safereturns_id ) @@ -144,19 +144,19 @@ public: auto row = results.begin(); if (results.RowCount() == 1) { - CharacterInstanceSafereturns entry{}; + CharacterInstanceSafereturns e{}; - entry.id = atoi(row[0]); - entry.character_id = atoi(row[1]); - entry.instance_zone_id = atoi(row[2]); - entry.instance_id = atoi(row[3]); - entry.safe_zone_id = atoi(row[4]); - entry.safe_x = static_cast(atof(row[5])); - entry.safe_y = static_cast(atof(row[6])); - entry.safe_z = static_cast(atof(row[7])); - entry.safe_heading = static_cast(atof(row[8])); + e.id = atoi(row[0]); + e.character_id = atoi(row[1]); + e.instance_zone_id = atoi(row[2]); + e.instance_id = atoi(row[3]); + e.safe_zone_id = atoi(row[4]); + e.safe_x = static_cast(atof(row[5])); + e.safe_y = static_cast(atof(row[6])); + e.safe_z = static_cast(atof(row[7])); + e.safe_heading = static_cast(atof(row[8])); - return entry; + return e; } return NewEntity(); @@ -181,29 +181,29 @@ public: static int UpdateOne( Database& db, - CharacterInstanceSafereturns character_instance_safereturns_entry + const CharacterInstanceSafereturns &e ) { - std::vector update_values; + std::vector v; auto columns = Columns(); - update_values.push_back(columns[1] + " = " + std::to_string(character_instance_safereturns_entry.character_id)); - update_values.push_back(columns[2] + " = " + std::to_string(character_instance_safereturns_entry.instance_zone_id)); - update_values.push_back(columns[3] + " = " + std::to_string(character_instance_safereturns_entry.instance_id)); - update_values.push_back(columns[4] + " = " + std::to_string(character_instance_safereturns_entry.safe_zone_id)); - update_values.push_back(columns[5] + " = " + std::to_string(character_instance_safereturns_entry.safe_x)); - update_values.push_back(columns[6] + " = " + std::to_string(character_instance_safereturns_entry.safe_y)); - update_values.push_back(columns[7] + " = " + std::to_string(character_instance_safereturns_entry.safe_z)); - update_values.push_back(columns[8] + " = " + std::to_string(character_instance_safereturns_entry.safe_heading)); + v.push_back(columns[1] + " = " + std::to_string(e.character_id)); + v.push_back(columns[2] + " = " + std::to_string(e.instance_zone_id)); + v.push_back(columns[3] + " = " + std::to_string(e.instance_id)); + v.push_back(columns[4] + " = " + std::to_string(e.safe_zone_id)); + v.push_back(columns[5] + " = " + std::to_string(e.safe_x)); + v.push_back(columns[6] + " = " + std::to_string(e.safe_y)); + v.push_back(columns[7] + " = " + std::to_string(e.safe_z)); + v.push_back(columns[8] + " = " + std::to_string(e.safe_heading)); auto results = db.QueryDatabase( fmt::format( "UPDATE {} SET {} WHERE {} = {}", TableName(), - Strings::Implode(", ", update_values), + Strings::Implode(", ", v), PrimaryKey(), - character_instance_safereturns_entry.id + e.id ) ); @@ -212,63 +212,63 @@ public: static CharacterInstanceSafereturns InsertOne( Database& db, - CharacterInstanceSafereturns character_instance_safereturns_entry + CharacterInstanceSafereturns e ) { - std::vector insert_values; + std::vector v; - insert_values.push_back(std::to_string(character_instance_safereturns_entry.id)); - insert_values.push_back(std::to_string(character_instance_safereturns_entry.character_id)); - insert_values.push_back(std::to_string(character_instance_safereturns_entry.instance_zone_id)); - insert_values.push_back(std::to_string(character_instance_safereturns_entry.instance_id)); - insert_values.push_back(std::to_string(character_instance_safereturns_entry.safe_zone_id)); - insert_values.push_back(std::to_string(character_instance_safereturns_entry.safe_x)); - insert_values.push_back(std::to_string(character_instance_safereturns_entry.safe_y)); - insert_values.push_back(std::to_string(character_instance_safereturns_entry.safe_z)); - insert_values.push_back(std::to_string(character_instance_safereturns_entry.safe_heading)); + v.push_back(std::to_string(e.id)); + v.push_back(std::to_string(e.character_id)); + v.push_back(std::to_string(e.instance_zone_id)); + v.push_back(std::to_string(e.instance_id)); + v.push_back(std::to_string(e.safe_zone_id)); + v.push_back(std::to_string(e.safe_x)); + v.push_back(std::to_string(e.safe_y)); + v.push_back(std::to_string(e.safe_z)); + v.push_back(std::to_string(e.safe_heading)); auto results = db.QueryDatabase( fmt::format( "{} VALUES ({})", BaseInsert(), - Strings::Implode(",", insert_values) + Strings::Implode(",", v) ) ); if (results.Success()) { - character_instance_safereturns_entry.id = results.LastInsertedID(); - return character_instance_safereturns_entry; + e.id = results.LastInsertedID(); + return e; } - character_instance_safereturns_entry = NewEntity(); + e = NewEntity(); - return character_instance_safereturns_entry; + return e; } static int InsertMany( Database& db, - std::vector character_instance_safereturns_entries + const std::vector &entries ) { std::vector insert_chunks; - for (auto &character_instance_safereturns_entry: character_instance_safereturns_entries) { - std::vector insert_values; + for (auto &e: entries) { + std::vector v; - insert_values.push_back(std::to_string(character_instance_safereturns_entry.id)); - insert_values.push_back(std::to_string(character_instance_safereturns_entry.character_id)); - insert_values.push_back(std::to_string(character_instance_safereturns_entry.instance_zone_id)); - insert_values.push_back(std::to_string(character_instance_safereturns_entry.instance_id)); - insert_values.push_back(std::to_string(character_instance_safereturns_entry.safe_zone_id)); - insert_values.push_back(std::to_string(character_instance_safereturns_entry.safe_x)); - insert_values.push_back(std::to_string(character_instance_safereturns_entry.safe_y)); - insert_values.push_back(std::to_string(character_instance_safereturns_entry.safe_z)); - insert_values.push_back(std::to_string(character_instance_safereturns_entry.safe_heading)); + v.push_back(std::to_string(e.id)); + v.push_back(std::to_string(e.character_id)); + v.push_back(std::to_string(e.instance_zone_id)); + v.push_back(std::to_string(e.instance_id)); + v.push_back(std::to_string(e.safe_zone_id)); + v.push_back(std::to_string(e.safe_x)); + v.push_back(std::to_string(e.safe_y)); + v.push_back(std::to_string(e.safe_z)); + v.push_back(std::to_string(e.safe_heading)); - insert_chunks.push_back("(" + Strings::Implode(",", insert_values) + ")"); + insert_chunks.push_back("(" + Strings::Implode(",", v) + ")"); } - std::vector insert_values; + std::vector v; auto results = db.QueryDatabase( fmt::format( @@ -295,25 +295,25 @@ public: all_entries.reserve(results.RowCount()); for (auto row = results.begin(); row != results.end(); ++row) { - CharacterInstanceSafereturns entry{}; + CharacterInstanceSafereturns e{}; - entry.id = atoi(row[0]); - entry.character_id = atoi(row[1]); - entry.instance_zone_id = atoi(row[2]); - entry.instance_id = atoi(row[3]); - entry.safe_zone_id = atoi(row[4]); - entry.safe_x = static_cast(atof(row[5])); - entry.safe_y = static_cast(atof(row[6])); - entry.safe_z = static_cast(atof(row[7])); - entry.safe_heading = static_cast(atof(row[8])); + e.id = atoi(row[0]); + e.character_id = atoi(row[1]); + e.instance_zone_id = atoi(row[2]); + e.instance_id = atoi(row[3]); + e.safe_zone_id = atoi(row[4]); + e.safe_x = static_cast(atof(row[5])); + e.safe_y = static_cast(atof(row[6])); + e.safe_z = static_cast(atof(row[7])); + e.safe_heading = static_cast(atof(row[8])); - all_entries.push_back(entry); + all_entries.push_back(e); } return all_entries; } - static std::vector GetWhere(Database& db, std::string where_filter) + static std::vector GetWhere(Database& db, const std::string &where_filter) { std::vector all_entries; @@ -328,25 +328,25 @@ public: all_entries.reserve(results.RowCount()); for (auto row = results.begin(); row != results.end(); ++row) { - CharacterInstanceSafereturns entry{}; + CharacterInstanceSafereturns e{}; - entry.id = atoi(row[0]); - entry.character_id = atoi(row[1]); - entry.instance_zone_id = atoi(row[2]); - entry.instance_id = atoi(row[3]); - entry.safe_zone_id = atoi(row[4]); - entry.safe_x = static_cast(atof(row[5])); - entry.safe_y = static_cast(atof(row[6])); - entry.safe_z = static_cast(atof(row[7])); - entry.safe_heading = static_cast(atof(row[8])); + e.id = atoi(row[0]); + e.character_id = atoi(row[1]); + e.instance_zone_id = atoi(row[2]); + e.instance_id = atoi(row[3]); + e.safe_zone_id = atoi(row[4]); + e.safe_x = static_cast(atof(row[5])); + e.safe_y = static_cast(atof(row[6])); + e.safe_z = static_cast(atof(row[7])); + e.safe_heading = static_cast(atof(row[8])); - all_entries.push_back(entry); + all_entries.push_back(e); } return all_entries; } - static int DeleteWhere(Database& db, std::string where_filter) + static int DeleteWhere(Database& db, const std::string &where_filter) { auto results = db.QueryDatabase( fmt::format( @@ -371,6 +371,32 @@ public: 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); + } + }; #endif //EQEMU_BASE_CHARACTER_INSTANCE_SAFERETURNS_REPOSITORY_H diff --git a/common/repositories/base/base_character_item_recast_repository.h b/common/repositories/base/base_character_item_recast_repository.h index ae8ee8591..781db36aa 100644 --- a/common/repositories/base/base_character_item_recast_repository.h +++ b/common/repositories/base/base_character_item_recast_repository.h @@ -82,16 +82,16 @@ public: static CharacterItemRecast NewEntity() { - CharacterItemRecast entry{}; + CharacterItemRecast e{}; - entry.id = 0; - entry.recast_type = 0; - entry.timestamp = 0; + e.id = 0; + e.recast_type = 0; + e.timestamp = 0; - return entry; + return e; } - static CharacterItemRecast GetCharacterItemRecastEntry( + static CharacterItemRecast GetCharacterItemRecast( const std::vector &character_item_recasts, int character_item_recast_id ) @@ -120,13 +120,13 @@ public: auto row = results.begin(); if (results.RowCount() == 1) { - CharacterItemRecast entry{}; + CharacterItemRecast e{}; - entry.id = atoi(row[0]); - entry.recast_type = atoi(row[1]); - entry.timestamp = atoi(row[2]); + e.id = atoi(row[0]); + e.recast_type = atoi(row[1]); + e.timestamp = atoi(row[2]); - return entry; + return e; } return NewEntity(); @@ -151,24 +151,24 @@ public: static int UpdateOne( Database& db, - CharacterItemRecast character_item_recast_entry + const CharacterItemRecast &e ) { - std::vector update_values; + std::vector v; auto columns = Columns(); - update_values.push_back(columns[0] + " = " + std::to_string(character_item_recast_entry.id)); - update_values.push_back(columns[1] + " = " + std::to_string(character_item_recast_entry.recast_type)); - update_values.push_back(columns[2] + " = " + std::to_string(character_item_recast_entry.timestamp)); + v.push_back(columns[0] + " = " + std::to_string(e.id)); + v.push_back(columns[1] + " = " + std::to_string(e.recast_type)); + v.push_back(columns[2] + " = " + std::to_string(e.timestamp)); auto results = db.QueryDatabase( fmt::format( "UPDATE {} SET {} WHERE {} = {}", TableName(), - Strings::Implode(", ", update_values), + Strings::Implode(", ", v), PrimaryKey(), - character_item_recast_entry.id + e.id ) ); @@ -177,51 +177,51 @@ public: static CharacterItemRecast InsertOne( Database& db, - CharacterItemRecast character_item_recast_entry + CharacterItemRecast e ) { - std::vector insert_values; + std::vector v; - insert_values.push_back(std::to_string(character_item_recast_entry.id)); - insert_values.push_back(std::to_string(character_item_recast_entry.recast_type)); - insert_values.push_back(std::to_string(character_item_recast_entry.timestamp)); + v.push_back(std::to_string(e.id)); + v.push_back(std::to_string(e.recast_type)); + v.push_back(std::to_string(e.timestamp)); auto results = db.QueryDatabase( fmt::format( "{} VALUES ({})", BaseInsert(), - Strings::Implode(",", insert_values) + Strings::Implode(",", v) ) ); if (results.Success()) { - character_item_recast_entry.id = results.LastInsertedID(); - return character_item_recast_entry; + e.id = results.LastInsertedID(); + return e; } - character_item_recast_entry = NewEntity(); + e = NewEntity(); - return character_item_recast_entry; + return e; } static int InsertMany( Database& db, - std::vector character_item_recast_entries + const std::vector &entries ) { std::vector insert_chunks; - for (auto &character_item_recast_entry: character_item_recast_entries) { - std::vector insert_values; + for (auto &e: entries) { + std::vector v; - insert_values.push_back(std::to_string(character_item_recast_entry.id)); - insert_values.push_back(std::to_string(character_item_recast_entry.recast_type)); - insert_values.push_back(std::to_string(character_item_recast_entry.timestamp)); + v.push_back(std::to_string(e.id)); + v.push_back(std::to_string(e.recast_type)); + v.push_back(std::to_string(e.timestamp)); - insert_chunks.push_back("(" + Strings::Implode(",", insert_values) + ")"); + insert_chunks.push_back("(" + Strings::Implode(",", v) + ")"); } - std::vector insert_values; + std::vector v; auto results = db.QueryDatabase( fmt::format( @@ -248,19 +248,19 @@ public: all_entries.reserve(results.RowCount()); for (auto row = results.begin(); row != results.end(); ++row) { - CharacterItemRecast entry{}; + CharacterItemRecast e{}; - entry.id = atoi(row[0]); - entry.recast_type = atoi(row[1]); - entry.timestamp = atoi(row[2]); + e.id = atoi(row[0]); + e.recast_type = atoi(row[1]); + e.timestamp = atoi(row[2]); - all_entries.push_back(entry); + all_entries.push_back(e); } return all_entries; } - static std::vector GetWhere(Database& db, std::string where_filter) + static std::vector GetWhere(Database& db, const std::string &where_filter) { std::vector all_entries; @@ -275,19 +275,19 @@ public: all_entries.reserve(results.RowCount()); for (auto row = results.begin(); row != results.end(); ++row) { - CharacterItemRecast entry{}; + CharacterItemRecast e{}; - entry.id = atoi(row[0]); - entry.recast_type = atoi(row[1]); - entry.timestamp = atoi(row[2]); + e.id = atoi(row[0]); + e.recast_type = atoi(row[1]); + e.timestamp = atoi(row[2]); - all_entries.push_back(entry); + all_entries.push_back(e); } return all_entries; } - static int DeleteWhere(Database& db, std::string where_filter) + static int DeleteWhere(Database& db, const std::string &where_filter) { auto results = db.QueryDatabase( fmt::format( @@ -312,6 +312,32 @@ public: 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); + } + }; #endif //EQEMU_BASE_CHARACTER_ITEM_RECAST_REPOSITORY_H diff --git a/common/repositories/base/base_character_languages_repository.h b/common/repositories/base/base_character_languages_repository.h index a4048695a..023b6458e 100644 --- a/common/repositories/base/base_character_languages_repository.h +++ b/common/repositories/base/base_character_languages_repository.h @@ -82,16 +82,16 @@ public: static CharacterLanguages NewEntity() { - CharacterLanguages entry{}; + CharacterLanguages e{}; - entry.id = 0; - entry.lang_id = 0; - entry.value = 0; + e.id = 0; + e.lang_id = 0; + e.value = 0; - return entry; + return e; } - static CharacterLanguages GetCharacterLanguagesEntry( + static CharacterLanguages GetCharacterLanguages( const std::vector &character_languagess, int character_languages_id ) @@ -120,13 +120,13 @@ public: auto row = results.begin(); if (results.RowCount() == 1) { - CharacterLanguages entry{}; + CharacterLanguages e{}; - entry.id = atoi(row[0]); - entry.lang_id = atoi(row[1]); - entry.value = atoi(row[2]); + e.id = atoi(row[0]); + e.lang_id = atoi(row[1]); + e.value = atoi(row[2]); - return entry; + return e; } return NewEntity(); @@ -151,23 +151,23 @@ public: static int UpdateOne( Database& db, - CharacterLanguages character_languages_entry + const CharacterLanguages &e ) { - std::vector update_values; + std::vector v; auto columns = Columns(); - update_values.push_back(columns[1] + " = " + std::to_string(character_languages_entry.lang_id)); - update_values.push_back(columns[2] + " = " + std::to_string(character_languages_entry.value)); + v.push_back(columns[1] + " = " + std::to_string(e.lang_id)); + v.push_back(columns[2] + " = " + std::to_string(e.value)); auto results = db.QueryDatabase( fmt::format( "UPDATE {} SET {} WHERE {} = {}", TableName(), - Strings::Implode(", ", update_values), + Strings::Implode(", ", v), PrimaryKey(), - character_languages_entry.id + e.id ) ); @@ -176,51 +176,51 @@ public: static CharacterLanguages InsertOne( Database& db, - CharacterLanguages character_languages_entry + CharacterLanguages e ) { - std::vector insert_values; + std::vector v; - insert_values.push_back(std::to_string(character_languages_entry.id)); - insert_values.push_back(std::to_string(character_languages_entry.lang_id)); - insert_values.push_back(std::to_string(character_languages_entry.value)); + v.push_back(std::to_string(e.id)); + v.push_back(std::to_string(e.lang_id)); + v.push_back(std::to_string(e.value)); auto results = db.QueryDatabase( fmt::format( "{} VALUES ({})", BaseInsert(), - Strings::Implode(",", insert_values) + Strings::Implode(",", v) ) ); if (results.Success()) { - character_languages_entry.id = results.LastInsertedID(); - return character_languages_entry; + e.id = results.LastInsertedID(); + return e; } - character_languages_entry = NewEntity(); + e = NewEntity(); - return character_languages_entry; + return e; } static int InsertMany( Database& db, - std::vector character_languages_entries + const std::vector &entries ) { std::vector insert_chunks; - for (auto &character_languages_entry: character_languages_entries) { - std::vector insert_values; + for (auto &e: entries) { + std::vector v; - insert_values.push_back(std::to_string(character_languages_entry.id)); - insert_values.push_back(std::to_string(character_languages_entry.lang_id)); - insert_values.push_back(std::to_string(character_languages_entry.value)); + v.push_back(std::to_string(e.id)); + v.push_back(std::to_string(e.lang_id)); + v.push_back(std::to_string(e.value)); - insert_chunks.push_back("(" + Strings::Implode(",", insert_values) + ")"); + insert_chunks.push_back("(" + Strings::Implode(",", v) + ")"); } - std::vector insert_values; + std::vector v; auto results = db.QueryDatabase( fmt::format( @@ -247,19 +247,19 @@ public: all_entries.reserve(results.RowCount()); for (auto row = results.begin(); row != results.end(); ++row) { - CharacterLanguages entry{}; + CharacterLanguages e{}; - entry.id = atoi(row[0]); - entry.lang_id = atoi(row[1]); - entry.value = atoi(row[2]); + e.id = atoi(row[0]); + e.lang_id = atoi(row[1]); + e.value = atoi(row[2]); - all_entries.push_back(entry); + all_entries.push_back(e); } return all_entries; } - static std::vector GetWhere(Database& db, std::string where_filter) + static std::vector GetWhere(Database& db, const std::string &where_filter) { std::vector all_entries; @@ -274,19 +274,19 @@ public: all_entries.reserve(results.RowCount()); for (auto row = results.begin(); row != results.end(); ++row) { - CharacterLanguages entry{}; + CharacterLanguages e{}; - entry.id = atoi(row[0]); - entry.lang_id = atoi(row[1]); - entry.value = atoi(row[2]); + e.id = atoi(row[0]); + e.lang_id = atoi(row[1]); + e.value = atoi(row[2]); - all_entries.push_back(entry); + all_entries.push_back(e); } return all_entries; } - static int DeleteWhere(Database& db, std::string where_filter) + static int DeleteWhere(Database& db, const std::string &where_filter) { auto results = db.QueryDatabase( fmt::format( @@ -311,6 +311,32 @@ public: 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); + } + }; #endif //EQEMU_BASE_CHARACTER_LANGUAGES_REPOSITORY_H diff --git a/common/repositories/base/base_character_leadership_abilities_repository.h b/common/repositories/base/base_character_leadership_abilities_repository.h index af1b8f8e0..a1727323d 100644 --- a/common/repositories/base/base_character_leadership_abilities_repository.h +++ b/common/repositories/base/base_character_leadership_abilities_repository.h @@ -82,16 +82,16 @@ public: static CharacterLeadershipAbilities NewEntity() { - CharacterLeadershipAbilities entry{}; + CharacterLeadershipAbilities e{}; - entry.id = 0; - entry.slot = 0; - entry.rank = 0; + e.id = 0; + e.slot = 0; + e.rank = 0; - return entry; + return e; } - static CharacterLeadershipAbilities GetCharacterLeadershipAbilitiesEntry( + static CharacterLeadershipAbilities GetCharacterLeadershipAbilities( const std::vector &character_leadership_abilitiess, int character_leadership_abilities_id ) @@ -120,13 +120,13 @@ public: auto row = results.begin(); if (results.RowCount() == 1) { - CharacterLeadershipAbilities entry{}; + CharacterLeadershipAbilities e{}; - entry.id = atoi(row[0]); - entry.slot = atoi(row[1]); - entry.rank = atoi(row[2]); + e.id = atoi(row[0]); + e.slot = atoi(row[1]); + e.rank = atoi(row[2]); - return entry; + return e; } return NewEntity(); @@ -151,24 +151,24 @@ public: static int UpdateOne( Database& db, - CharacterLeadershipAbilities character_leadership_abilities_entry + const CharacterLeadershipAbilities &e ) { - std::vector update_values; + std::vector v; auto columns = Columns(); - update_values.push_back(columns[0] + " = " + std::to_string(character_leadership_abilities_entry.id)); - update_values.push_back(columns[1] + " = " + std::to_string(character_leadership_abilities_entry.slot)); - update_values.push_back(columns[2] + " = " + std::to_string(character_leadership_abilities_entry.rank)); + v.push_back(columns[0] + " = " + std::to_string(e.id)); + v.push_back(columns[1] + " = " + std::to_string(e.slot)); + v.push_back(columns[2] + " = " + std::to_string(e.rank)); auto results = db.QueryDatabase( fmt::format( "UPDATE {} SET {} WHERE {} = {}", TableName(), - Strings::Implode(", ", update_values), + Strings::Implode(", ", v), PrimaryKey(), - character_leadership_abilities_entry.id + e.id ) ); @@ -177,51 +177,51 @@ public: static CharacterLeadershipAbilities InsertOne( Database& db, - CharacterLeadershipAbilities character_leadership_abilities_entry + CharacterLeadershipAbilities e ) { - std::vector insert_values; + std::vector v; - insert_values.push_back(std::to_string(character_leadership_abilities_entry.id)); - insert_values.push_back(std::to_string(character_leadership_abilities_entry.slot)); - insert_values.push_back(std::to_string(character_leadership_abilities_entry.rank)); + v.push_back(std::to_string(e.id)); + v.push_back(std::to_string(e.slot)); + v.push_back(std::to_string(e.rank)); auto results = db.QueryDatabase( fmt::format( "{} VALUES ({})", BaseInsert(), - Strings::Implode(",", insert_values) + Strings::Implode(",", v) ) ); if (results.Success()) { - character_leadership_abilities_entry.id = results.LastInsertedID(); - return character_leadership_abilities_entry; + e.id = results.LastInsertedID(); + return e; } - character_leadership_abilities_entry = NewEntity(); + e = NewEntity(); - return character_leadership_abilities_entry; + return e; } static int InsertMany( Database& db, - std::vector character_leadership_abilities_entries + const std::vector &entries ) { std::vector insert_chunks; - for (auto &character_leadership_abilities_entry: character_leadership_abilities_entries) { - std::vector insert_values; + for (auto &e: entries) { + std::vector v; - insert_values.push_back(std::to_string(character_leadership_abilities_entry.id)); - insert_values.push_back(std::to_string(character_leadership_abilities_entry.slot)); - insert_values.push_back(std::to_string(character_leadership_abilities_entry.rank)); + v.push_back(std::to_string(e.id)); + v.push_back(std::to_string(e.slot)); + v.push_back(std::to_string(e.rank)); - insert_chunks.push_back("(" + Strings::Implode(",", insert_values) + ")"); + insert_chunks.push_back("(" + Strings::Implode(",", v) + ")"); } - std::vector insert_values; + std::vector v; auto results = db.QueryDatabase( fmt::format( @@ -248,19 +248,19 @@ public: all_entries.reserve(results.RowCount()); for (auto row = results.begin(); row != results.end(); ++row) { - CharacterLeadershipAbilities entry{}; + CharacterLeadershipAbilities e{}; - entry.id = atoi(row[0]); - entry.slot = atoi(row[1]); - entry.rank = atoi(row[2]); + e.id = atoi(row[0]); + e.slot = atoi(row[1]); + e.rank = atoi(row[2]); - all_entries.push_back(entry); + all_entries.push_back(e); } return all_entries; } - static std::vector GetWhere(Database& db, std::string where_filter) + static std::vector GetWhere(Database& db, const std::string &where_filter) { std::vector all_entries; @@ -275,19 +275,19 @@ public: all_entries.reserve(results.RowCount()); for (auto row = results.begin(); row != results.end(); ++row) { - CharacterLeadershipAbilities entry{}; + CharacterLeadershipAbilities e{}; - entry.id = atoi(row[0]); - entry.slot = atoi(row[1]); - entry.rank = atoi(row[2]); + e.id = atoi(row[0]); + e.slot = atoi(row[1]); + e.rank = atoi(row[2]); - all_entries.push_back(entry); + all_entries.push_back(e); } return all_entries; } - static int DeleteWhere(Database& db, std::string where_filter) + static int DeleteWhere(Database& db, const std::string &where_filter) { auto results = db.QueryDatabase( fmt::format( @@ -312,6 +312,32 @@ public: 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); + } + }; #endif //EQEMU_BASE_CHARACTER_LEADERSHIP_ABILITIES_REPOSITORY_H diff --git a/common/repositories/base/base_character_material_repository.h b/common/repositories/base/base_character_material_repository.h index a67972896..ec28a25cb 100644 --- a/common/repositories/base/base_character_material_repository.h +++ b/common/repositories/base/base_character_material_repository.h @@ -94,20 +94,20 @@ public: static CharacterMaterial NewEntity() { - CharacterMaterial entry{}; + CharacterMaterial e{}; - entry.id = 0; - entry.slot = 0; - entry.blue = 0; - entry.green = 0; - entry.red = 0; - entry.use_tint = 0; - entry.color = 0; + e.id = 0; + e.slot = 0; + e.blue = 0; + e.green = 0; + e.red = 0; + e.use_tint = 0; + e.color = 0; - return entry; + return e; } - static CharacterMaterial GetCharacterMaterialEntry( + static CharacterMaterial GetCharacterMaterial( const std::vector &character_materials, int character_material_id ) @@ -136,17 +136,17 @@ public: auto row = results.begin(); if (results.RowCount() == 1) { - CharacterMaterial entry{}; + CharacterMaterial e{}; - entry.id = atoi(row[0]); - entry.slot = atoi(row[1]); - entry.blue = atoi(row[2]); - entry.green = atoi(row[3]); - entry.red = atoi(row[4]); - entry.use_tint = atoi(row[5]); - entry.color = atoi(row[6]); + e.id = atoi(row[0]); + e.slot = atoi(row[1]); + e.blue = atoi(row[2]); + e.green = atoi(row[3]); + e.red = atoi(row[4]); + e.use_tint = atoi(row[5]); + e.color = atoi(row[6]); - return entry; + return e; } return NewEntity(); @@ -171,27 +171,27 @@ public: static int UpdateOne( Database& db, - CharacterMaterial character_material_entry + const CharacterMaterial &e ) { - std::vector update_values; + std::vector v; auto columns = Columns(); - update_values.push_back(columns[1] + " = " + std::to_string(character_material_entry.slot)); - update_values.push_back(columns[2] + " = " + std::to_string(character_material_entry.blue)); - update_values.push_back(columns[3] + " = " + std::to_string(character_material_entry.green)); - update_values.push_back(columns[4] + " = " + std::to_string(character_material_entry.red)); - update_values.push_back(columns[5] + " = " + std::to_string(character_material_entry.use_tint)); - update_values.push_back(columns[6] + " = " + std::to_string(character_material_entry.color)); + v.push_back(columns[1] + " = " + std::to_string(e.slot)); + v.push_back(columns[2] + " = " + std::to_string(e.blue)); + v.push_back(columns[3] + " = " + std::to_string(e.green)); + v.push_back(columns[4] + " = " + std::to_string(e.red)); + v.push_back(columns[5] + " = " + std::to_string(e.use_tint)); + v.push_back(columns[6] + " = " + std::to_string(e.color)); auto results = db.QueryDatabase( fmt::format( "UPDATE {} SET {} WHERE {} = {}", TableName(), - Strings::Implode(", ", update_values), + Strings::Implode(", ", v), PrimaryKey(), - character_material_entry.id + e.id ) ); @@ -200,59 +200,59 @@ public: static CharacterMaterial InsertOne( Database& db, - CharacterMaterial character_material_entry + CharacterMaterial e ) { - std::vector insert_values; + std::vector v; - insert_values.push_back(std::to_string(character_material_entry.id)); - insert_values.push_back(std::to_string(character_material_entry.slot)); - insert_values.push_back(std::to_string(character_material_entry.blue)); - insert_values.push_back(std::to_string(character_material_entry.green)); - insert_values.push_back(std::to_string(character_material_entry.red)); - insert_values.push_back(std::to_string(character_material_entry.use_tint)); - insert_values.push_back(std::to_string(character_material_entry.color)); + v.push_back(std::to_string(e.id)); + v.push_back(std::to_string(e.slot)); + v.push_back(std::to_string(e.blue)); + v.push_back(std::to_string(e.green)); + v.push_back(std::to_string(e.red)); + v.push_back(std::to_string(e.use_tint)); + v.push_back(std::to_string(e.color)); auto results = db.QueryDatabase( fmt::format( "{} VALUES ({})", BaseInsert(), - Strings::Implode(",", insert_values) + Strings::Implode(",", v) ) ); if (results.Success()) { - character_material_entry.id = results.LastInsertedID(); - return character_material_entry; + e.id = results.LastInsertedID(); + return e; } - character_material_entry = NewEntity(); + e = NewEntity(); - return character_material_entry; + return e; } static int InsertMany( Database& db, - std::vector character_material_entries + const std::vector &entries ) { std::vector insert_chunks; - for (auto &character_material_entry: character_material_entries) { - std::vector insert_values; + for (auto &e: entries) { + std::vector v; - insert_values.push_back(std::to_string(character_material_entry.id)); - insert_values.push_back(std::to_string(character_material_entry.slot)); - insert_values.push_back(std::to_string(character_material_entry.blue)); - insert_values.push_back(std::to_string(character_material_entry.green)); - insert_values.push_back(std::to_string(character_material_entry.red)); - insert_values.push_back(std::to_string(character_material_entry.use_tint)); - insert_values.push_back(std::to_string(character_material_entry.color)); + v.push_back(std::to_string(e.id)); + v.push_back(std::to_string(e.slot)); + v.push_back(std::to_string(e.blue)); + v.push_back(std::to_string(e.green)); + v.push_back(std::to_string(e.red)); + v.push_back(std::to_string(e.use_tint)); + v.push_back(std::to_string(e.color)); - insert_chunks.push_back("(" + Strings::Implode(",", insert_values) + ")"); + insert_chunks.push_back("(" + Strings::Implode(",", v) + ")"); } - std::vector insert_values; + std::vector v; auto results = db.QueryDatabase( fmt::format( @@ -279,23 +279,23 @@ public: all_entries.reserve(results.RowCount()); for (auto row = results.begin(); row != results.end(); ++row) { - CharacterMaterial entry{}; + CharacterMaterial e{}; - entry.id = atoi(row[0]); - entry.slot = atoi(row[1]); - entry.blue = atoi(row[2]); - entry.green = atoi(row[3]); - entry.red = atoi(row[4]); - entry.use_tint = atoi(row[5]); - entry.color = atoi(row[6]); + e.id = atoi(row[0]); + e.slot = atoi(row[1]); + e.blue = atoi(row[2]); + e.green = atoi(row[3]); + e.red = atoi(row[4]); + e.use_tint = atoi(row[5]); + e.color = atoi(row[6]); - all_entries.push_back(entry); + all_entries.push_back(e); } return all_entries; } - static std::vector GetWhere(Database& db, std::string where_filter) + static std::vector GetWhere(Database& db, const std::string &where_filter) { std::vector all_entries; @@ -310,23 +310,23 @@ public: all_entries.reserve(results.RowCount()); for (auto row = results.begin(); row != results.end(); ++row) { - CharacterMaterial entry{}; + CharacterMaterial e{}; - entry.id = atoi(row[0]); - entry.slot = atoi(row[1]); - entry.blue = atoi(row[2]); - entry.green = atoi(row[3]); - entry.red = atoi(row[4]); - entry.use_tint = atoi(row[5]); - entry.color = atoi(row[6]); + e.id = atoi(row[0]); + e.slot = atoi(row[1]); + e.blue = atoi(row[2]); + e.green = atoi(row[3]); + e.red = atoi(row[4]); + e.use_tint = atoi(row[5]); + e.color = atoi(row[6]); - all_entries.push_back(entry); + all_entries.push_back(e); } return all_entries; } - static int DeleteWhere(Database& db, std::string where_filter) + static int DeleteWhere(Database& db, const std::string &where_filter) { auto results = db.QueryDatabase( fmt::format( @@ -351,6 +351,32 @@ public: 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); + } + }; #endif //EQEMU_BASE_CHARACTER_MATERIAL_REPOSITORY_H diff --git a/common/repositories/base/base_character_memmed_spells_repository.h b/common/repositories/base/base_character_memmed_spells_repository.h index fd4b9de05..5875326ff 100644 --- a/common/repositories/base/base_character_memmed_spells_repository.h +++ b/common/repositories/base/base_character_memmed_spells_repository.h @@ -82,16 +82,16 @@ public: static CharacterMemmedSpells NewEntity() { - CharacterMemmedSpells entry{}; + CharacterMemmedSpells e{}; - entry.id = 0; - entry.slot_id = 0; - entry.spell_id = 0; + e.id = 0; + e.slot_id = 0; + e.spell_id = 0; - return entry; + return e; } - static CharacterMemmedSpells GetCharacterMemmedSpellsEntry( + static CharacterMemmedSpells GetCharacterMemmedSpells( const std::vector &character_memmed_spellss, int character_memmed_spells_id ) @@ -120,13 +120,13 @@ public: auto row = results.begin(); if (results.RowCount() == 1) { - CharacterMemmedSpells entry{}; + CharacterMemmedSpells e{}; - entry.id = atoi(row[0]); - entry.slot_id = atoi(row[1]); - entry.spell_id = atoi(row[2]); + e.id = atoi(row[0]); + e.slot_id = atoi(row[1]); + e.spell_id = atoi(row[2]); - return entry; + return e; } return NewEntity(); @@ -151,24 +151,24 @@ public: static int UpdateOne( Database& db, - CharacterMemmedSpells character_memmed_spells_entry + const CharacterMemmedSpells &e ) { - std::vector update_values; + std::vector v; auto columns = Columns(); - update_values.push_back(columns[0] + " = " + std::to_string(character_memmed_spells_entry.id)); - update_values.push_back(columns[1] + " = " + std::to_string(character_memmed_spells_entry.slot_id)); - update_values.push_back(columns[2] + " = " + std::to_string(character_memmed_spells_entry.spell_id)); + v.push_back(columns[0] + " = " + std::to_string(e.id)); + v.push_back(columns[1] + " = " + std::to_string(e.slot_id)); + v.push_back(columns[2] + " = " + std::to_string(e.spell_id)); auto results = db.QueryDatabase( fmt::format( "UPDATE {} SET {} WHERE {} = {}", TableName(), - Strings::Implode(", ", update_values), + Strings::Implode(", ", v), PrimaryKey(), - character_memmed_spells_entry.id + e.id ) ); @@ -177,51 +177,51 @@ public: static CharacterMemmedSpells InsertOne( Database& db, - CharacterMemmedSpells character_memmed_spells_entry + CharacterMemmedSpells e ) { - std::vector insert_values; + std::vector v; - insert_values.push_back(std::to_string(character_memmed_spells_entry.id)); - insert_values.push_back(std::to_string(character_memmed_spells_entry.slot_id)); - insert_values.push_back(std::to_string(character_memmed_spells_entry.spell_id)); + v.push_back(std::to_string(e.id)); + v.push_back(std::to_string(e.slot_id)); + v.push_back(std::to_string(e.spell_id)); auto results = db.QueryDatabase( fmt::format( "{} VALUES ({})", BaseInsert(), - Strings::Implode(",", insert_values) + Strings::Implode(",", v) ) ); if (results.Success()) { - character_memmed_spells_entry.id = results.LastInsertedID(); - return character_memmed_spells_entry; + e.id = results.LastInsertedID(); + return e; } - character_memmed_spells_entry = NewEntity(); + e = NewEntity(); - return character_memmed_spells_entry; + return e; } static int InsertMany( Database& db, - std::vector character_memmed_spells_entries + const std::vector &entries ) { std::vector insert_chunks; - for (auto &character_memmed_spells_entry: character_memmed_spells_entries) { - std::vector insert_values; + for (auto &e: entries) { + std::vector v; - insert_values.push_back(std::to_string(character_memmed_spells_entry.id)); - insert_values.push_back(std::to_string(character_memmed_spells_entry.slot_id)); - insert_values.push_back(std::to_string(character_memmed_spells_entry.spell_id)); + v.push_back(std::to_string(e.id)); + v.push_back(std::to_string(e.slot_id)); + v.push_back(std::to_string(e.spell_id)); - insert_chunks.push_back("(" + Strings::Implode(",", insert_values) + ")"); + insert_chunks.push_back("(" + Strings::Implode(",", v) + ")"); } - std::vector insert_values; + std::vector v; auto results = db.QueryDatabase( fmt::format( @@ -248,19 +248,19 @@ public: all_entries.reserve(results.RowCount()); for (auto row = results.begin(); row != results.end(); ++row) { - CharacterMemmedSpells entry{}; + CharacterMemmedSpells e{}; - entry.id = atoi(row[0]); - entry.slot_id = atoi(row[1]); - entry.spell_id = atoi(row[2]); + e.id = atoi(row[0]); + e.slot_id = atoi(row[1]); + e.spell_id = atoi(row[2]); - all_entries.push_back(entry); + all_entries.push_back(e); } return all_entries; } - static std::vector GetWhere(Database& db, std::string where_filter) + static std::vector GetWhere(Database& db, const std::string &where_filter) { std::vector all_entries; @@ -275,19 +275,19 @@ public: all_entries.reserve(results.RowCount()); for (auto row = results.begin(); row != results.end(); ++row) { - CharacterMemmedSpells entry{}; + CharacterMemmedSpells e{}; - entry.id = atoi(row[0]); - entry.slot_id = atoi(row[1]); - entry.spell_id = atoi(row[2]); + e.id = atoi(row[0]); + e.slot_id = atoi(row[1]); + e.spell_id = atoi(row[2]); - all_entries.push_back(entry); + all_entries.push_back(e); } return all_entries; } - static int DeleteWhere(Database& db, std::string where_filter) + static int DeleteWhere(Database& db, const std::string &where_filter) { auto results = db.QueryDatabase( fmt::format( @@ -312,6 +312,32 @@ public: 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); + } + }; #endif //EQEMU_BASE_CHARACTER_MEMMED_SPELLS_REPOSITORY_H diff --git a/common/repositories/base/base_character_peqzone_flags_repository.h b/common/repositories/base/base_character_peqzone_flags_repository.h new file mode 100644 index 000000000..912064fba --- /dev/null +++ b/common/repositories/base/base_character_peqzone_flags_repository.h @@ -0,0 +1,333 @@ +/** + * 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://eqemu.gitbook.io/server/in-development/developer-area/repositories + */ + +#ifndef EQEMU_BASE_CHARACTER_PEQZONE_FLAGS_REPOSITORY_H +#define EQEMU_BASE_CHARACTER_PEQZONE_FLAGS_REPOSITORY_H + +#include "../../database.h" +#include "../../strings.h" +#include + +class BaseCharacterPeqzoneFlagsRepository { +public: + struct CharacterPeqzoneFlags { + int id; + int zone_id; + }; + + static std::string PrimaryKey() + { + return std::string("id"); + } + + static std::vector Columns() + { + return { + "id", + "zone_id", + }; + } + + static std::vector SelectColumns() + { + return { + "id", + "zone_id", + }; + } + + 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("character_peqzone_flags"); + } + + static std::string BaseSelect() + { + return fmt::format( + "SELECT {} FROM {}", + SelectColumnsRaw(), + TableName() + ); + } + + static std::string BaseInsert() + { + return fmt::format( + "INSERT INTO {} ({}) ", + TableName(), + ColumnsRaw() + ); + } + + static CharacterPeqzoneFlags NewEntity() + { + CharacterPeqzoneFlags e{}; + + e.id = 0; + e.zone_id = 0; + + return e; + } + + static CharacterPeqzoneFlags GetCharacterPeqzoneFlags( + const std::vector &character_peqzone_flagss, + int character_peqzone_flags_id + ) + { + for (auto &character_peqzone_flags : character_peqzone_flagss) { + if (character_peqzone_flags.id == character_peqzone_flags_id) { + return character_peqzone_flags; + } + } + + return NewEntity(); + } + + static CharacterPeqzoneFlags FindOne( + Database& db, + int character_peqzone_flags_id + ) + { + auto results = db.QueryDatabase( + fmt::format( + "{} WHERE id = {} LIMIT 1", + BaseSelect(), + character_peqzone_flags_id + ) + ); + + auto row = results.begin(); + if (results.RowCount() == 1) { + CharacterPeqzoneFlags e{}; + + e.id = atoi(row[0]); + e.zone_id = atoi(row[1]); + + return e; + } + + return NewEntity(); + } + + static int DeleteOne( + Database& db, + int character_peqzone_flags_id + ) + { + auto results = db.QueryDatabase( + fmt::format( + "DELETE FROM {} WHERE {} = {}", + TableName(), + PrimaryKey(), + character_peqzone_flags_id + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + + static int UpdateOne( + Database& db, + const CharacterPeqzoneFlags &e + ) + { + std::vector v; + + auto columns = Columns(); + + v.push_back(columns[0] + " = " + std::to_string(e.id)); + v.push_back(columns[1] + " = " + std::to_string(e.zone_id)); + + auto results = db.QueryDatabase( + fmt::format( + "UPDATE {} SET {} WHERE {} = {}", + TableName(), + Strings::Implode(", ", v), + PrimaryKey(), + e.id + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + + static CharacterPeqzoneFlags InsertOne( + Database& db, + CharacterPeqzoneFlags e + ) + { + std::vector v; + + v.push_back(std::to_string(e.id)); + v.push_back(std::to_string(e.zone_id)); + + auto results = db.QueryDatabase( + fmt::format( + "{} VALUES ({})", + BaseInsert(), + Strings::Implode(",", v) + ) + ); + + if (results.Success()) { + e.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.id)); + v.push_back(std::to_string(e.zone_id)); + + 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) { + CharacterPeqzoneFlags e{}; + + e.id = atoi(row[0]); + e.zone_id = atoi(row[1]); + + 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) { + CharacterPeqzoneFlags e{}; + + e.id = atoi(row[0]); + e.zone_id = atoi(row[1]); + + 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); + } + +}; + +#endif //EQEMU_BASE_CHARACTER_PEQZONE_FLAGS_REPOSITORY_H diff --git a/common/repositories/base/base_character_pet_buffs_repository.h b/common/repositories/base/base_character_pet_buffs_repository.h index f06c62093..cbc441e1b 100644 --- a/common/repositories/base/base_character_pet_buffs_repository.h +++ b/common/repositories/base/base_character_pet_buffs_repository.h @@ -106,24 +106,24 @@ public: static CharacterPetBuffs NewEntity() { - CharacterPetBuffs entry{}; + CharacterPetBuffs e{}; - entry.char_id = 0; - entry.pet = 0; - entry.slot = 0; - entry.spell_id = 0; - entry.caster_level = 0; - entry.castername = ""; - entry.ticsremaining = 0; - entry.counters = 0; - entry.numhits = 0; - entry.rune = 0; - entry.instrument_mod = 10; + e.char_id = 0; + e.pet = 0; + e.slot = 0; + e.spell_id = 0; + e.caster_level = 0; + e.castername = ""; + e.ticsremaining = 0; + e.counters = 0; + e.numhits = 0; + e.rune = 0; + e.instrument_mod = 10; - return entry; + return e; } - static CharacterPetBuffs GetCharacterPetBuffsEntry( + static CharacterPetBuffs GetCharacterPetBuffs( const std::vector &character_pet_buffss, int character_pet_buffs_id ) @@ -152,21 +152,21 @@ public: auto row = results.begin(); if (results.RowCount() == 1) { - CharacterPetBuffs entry{}; + CharacterPetBuffs e{}; - entry.char_id = atoi(row[0]); - entry.pet = atoi(row[1]); - entry.slot = atoi(row[2]); - entry.spell_id = atoi(row[3]); - entry.caster_level = atoi(row[4]); - entry.castername = row[5] ? row[5] : ""; - entry.ticsremaining = atoi(row[6]); - entry.counters = atoi(row[7]); - entry.numhits = atoi(row[8]); - entry.rune = atoi(row[9]); - entry.instrument_mod = atoi(row[10]); + e.char_id = atoi(row[0]); + e.pet = atoi(row[1]); + e.slot = atoi(row[2]); + e.spell_id = atoi(row[3]); + e.caster_level = atoi(row[4]); + e.castername = row[5] ? row[5] : ""; + e.ticsremaining = atoi(row[6]); + e.counters = atoi(row[7]); + e.numhits = atoi(row[8]); + e.rune = atoi(row[9]); + e.instrument_mod = atoi(row[10]); - return entry; + return e; } return NewEntity(); @@ -191,32 +191,32 @@ public: static int UpdateOne( Database& db, - CharacterPetBuffs character_pet_buffs_entry + const CharacterPetBuffs &e ) { - std::vector update_values; + std::vector v; auto columns = Columns(); - update_values.push_back(columns[0] + " = " + std::to_string(character_pet_buffs_entry.char_id)); - update_values.push_back(columns[1] + " = " + std::to_string(character_pet_buffs_entry.pet)); - update_values.push_back(columns[2] + " = " + std::to_string(character_pet_buffs_entry.slot)); - update_values.push_back(columns[3] + " = " + std::to_string(character_pet_buffs_entry.spell_id)); - update_values.push_back(columns[4] + " = " + std::to_string(character_pet_buffs_entry.caster_level)); - update_values.push_back(columns[5] + " = '" + Strings::Escape(character_pet_buffs_entry.castername) + "'"); - update_values.push_back(columns[6] + " = " + std::to_string(character_pet_buffs_entry.ticsremaining)); - update_values.push_back(columns[7] + " = " + std::to_string(character_pet_buffs_entry.counters)); - update_values.push_back(columns[8] + " = " + std::to_string(character_pet_buffs_entry.numhits)); - update_values.push_back(columns[9] + " = " + std::to_string(character_pet_buffs_entry.rune)); - update_values.push_back(columns[10] + " = " + std::to_string(character_pet_buffs_entry.instrument_mod)); + v.push_back(columns[0] + " = " + std::to_string(e.char_id)); + v.push_back(columns[1] + " = " + std::to_string(e.pet)); + v.push_back(columns[2] + " = " + std::to_string(e.slot)); + v.push_back(columns[3] + " = " + std::to_string(e.spell_id)); + v.push_back(columns[4] + " = " + std::to_string(e.caster_level)); + v.push_back(columns[5] + " = '" + Strings::Escape(e.castername) + "'"); + v.push_back(columns[6] + " = " + std::to_string(e.ticsremaining)); + v.push_back(columns[7] + " = " + std::to_string(e.counters)); + v.push_back(columns[8] + " = " + std::to_string(e.numhits)); + v.push_back(columns[9] + " = " + std::to_string(e.rune)); + v.push_back(columns[10] + " = " + std::to_string(e.instrument_mod)); auto results = db.QueryDatabase( fmt::format( "UPDATE {} SET {} WHERE {} = {}", TableName(), - Strings::Implode(", ", update_values), + Strings::Implode(", ", v), PrimaryKey(), - character_pet_buffs_entry.char_id + e.char_id ) ); @@ -225,67 +225,67 @@ public: static CharacterPetBuffs InsertOne( Database& db, - CharacterPetBuffs character_pet_buffs_entry + CharacterPetBuffs e ) { - std::vector insert_values; + std::vector v; - insert_values.push_back(std::to_string(character_pet_buffs_entry.char_id)); - insert_values.push_back(std::to_string(character_pet_buffs_entry.pet)); - insert_values.push_back(std::to_string(character_pet_buffs_entry.slot)); - insert_values.push_back(std::to_string(character_pet_buffs_entry.spell_id)); - insert_values.push_back(std::to_string(character_pet_buffs_entry.caster_level)); - insert_values.push_back("'" + Strings::Escape(character_pet_buffs_entry.castername) + "'"); - insert_values.push_back(std::to_string(character_pet_buffs_entry.ticsremaining)); - insert_values.push_back(std::to_string(character_pet_buffs_entry.counters)); - insert_values.push_back(std::to_string(character_pet_buffs_entry.numhits)); - insert_values.push_back(std::to_string(character_pet_buffs_entry.rune)); - insert_values.push_back(std::to_string(character_pet_buffs_entry.instrument_mod)); + v.push_back(std::to_string(e.char_id)); + v.push_back(std::to_string(e.pet)); + v.push_back(std::to_string(e.slot)); + v.push_back(std::to_string(e.spell_id)); + v.push_back(std::to_string(e.caster_level)); + v.push_back("'" + Strings::Escape(e.castername) + "'"); + v.push_back(std::to_string(e.ticsremaining)); + v.push_back(std::to_string(e.counters)); + v.push_back(std::to_string(e.numhits)); + v.push_back(std::to_string(e.rune)); + v.push_back(std::to_string(e.instrument_mod)); auto results = db.QueryDatabase( fmt::format( "{} VALUES ({})", BaseInsert(), - Strings::Implode(",", insert_values) + Strings::Implode(",", v) ) ); if (results.Success()) { - character_pet_buffs_entry.char_id = results.LastInsertedID(); - return character_pet_buffs_entry; + e.char_id = results.LastInsertedID(); + return e; } - character_pet_buffs_entry = NewEntity(); + e = NewEntity(); - return character_pet_buffs_entry; + return e; } static int InsertMany( Database& db, - std::vector character_pet_buffs_entries + const std::vector &entries ) { std::vector insert_chunks; - for (auto &character_pet_buffs_entry: character_pet_buffs_entries) { - std::vector insert_values; + for (auto &e: entries) { + std::vector v; - insert_values.push_back(std::to_string(character_pet_buffs_entry.char_id)); - insert_values.push_back(std::to_string(character_pet_buffs_entry.pet)); - insert_values.push_back(std::to_string(character_pet_buffs_entry.slot)); - insert_values.push_back(std::to_string(character_pet_buffs_entry.spell_id)); - insert_values.push_back(std::to_string(character_pet_buffs_entry.caster_level)); - insert_values.push_back("'" + Strings::Escape(character_pet_buffs_entry.castername) + "'"); - insert_values.push_back(std::to_string(character_pet_buffs_entry.ticsremaining)); - insert_values.push_back(std::to_string(character_pet_buffs_entry.counters)); - insert_values.push_back(std::to_string(character_pet_buffs_entry.numhits)); - insert_values.push_back(std::to_string(character_pet_buffs_entry.rune)); - insert_values.push_back(std::to_string(character_pet_buffs_entry.instrument_mod)); + v.push_back(std::to_string(e.char_id)); + v.push_back(std::to_string(e.pet)); + v.push_back(std::to_string(e.slot)); + v.push_back(std::to_string(e.spell_id)); + v.push_back(std::to_string(e.caster_level)); + v.push_back("'" + Strings::Escape(e.castername) + "'"); + v.push_back(std::to_string(e.ticsremaining)); + v.push_back(std::to_string(e.counters)); + v.push_back(std::to_string(e.numhits)); + v.push_back(std::to_string(e.rune)); + v.push_back(std::to_string(e.instrument_mod)); - insert_chunks.push_back("(" + Strings::Implode(",", insert_values) + ")"); + insert_chunks.push_back("(" + Strings::Implode(",", v) + ")"); } - std::vector insert_values; + std::vector v; auto results = db.QueryDatabase( fmt::format( @@ -312,27 +312,27 @@ public: all_entries.reserve(results.RowCount()); for (auto row = results.begin(); row != results.end(); ++row) { - CharacterPetBuffs entry{}; + CharacterPetBuffs e{}; - entry.char_id = atoi(row[0]); - entry.pet = atoi(row[1]); - entry.slot = atoi(row[2]); - entry.spell_id = atoi(row[3]); - entry.caster_level = atoi(row[4]); - entry.castername = row[5] ? row[5] : ""; - entry.ticsremaining = atoi(row[6]); - entry.counters = atoi(row[7]); - entry.numhits = atoi(row[8]); - entry.rune = atoi(row[9]); - entry.instrument_mod = atoi(row[10]); + e.char_id = atoi(row[0]); + e.pet = atoi(row[1]); + e.slot = atoi(row[2]); + e.spell_id = atoi(row[3]); + e.caster_level = atoi(row[4]); + e.castername = row[5] ? row[5] : ""; + e.ticsremaining = atoi(row[6]); + e.counters = atoi(row[7]); + e.numhits = atoi(row[8]); + e.rune = atoi(row[9]); + e.instrument_mod = atoi(row[10]); - all_entries.push_back(entry); + all_entries.push_back(e); } return all_entries; } - static std::vector GetWhere(Database& db, std::string where_filter) + static std::vector GetWhere(Database& db, const std::string &where_filter) { std::vector all_entries; @@ -347,27 +347,27 @@ public: all_entries.reserve(results.RowCount()); for (auto row = results.begin(); row != results.end(); ++row) { - CharacterPetBuffs entry{}; + CharacterPetBuffs e{}; - entry.char_id = atoi(row[0]); - entry.pet = atoi(row[1]); - entry.slot = atoi(row[2]); - entry.spell_id = atoi(row[3]); - entry.caster_level = atoi(row[4]); - entry.castername = row[5] ? row[5] : ""; - entry.ticsremaining = atoi(row[6]); - entry.counters = atoi(row[7]); - entry.numhits = atoi(row[8]); - entry.rune = atoi(row[9]); - entry.instrument_mod = atoi(row[10]); + e.char_id = atoi(row[0]); + e.pet = atoi(row[1]); + e.slot = atoi(row[2]); + e.spell_id = atoi(row[3]); + e.caster_level = atoi(row[4]); + e.castername = row[5] ? row[5] : ""; + e.ticsremaining = atoi(row[6]); + e.counters = atoi(row[7]); + e.numhits = atoi(row[8]); + e.rune = atoi(row[9]); + e.instrument_mod = atoi(row[10]); - all_entries.push_back(entry); + all_entries.push_back(e); } return all_entries; } - static int DeleteWhere(Database& db, std::string where_filter) + static int DeleteWhere(Database& db, const std::string &where_filter) { auto results = db.QueryDatabase( fmt::format( @@ -392,6 +392,32 @@ public: 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); + } + }; #endif //EQEMU_BASE_CHARACTER_PET_BUFFS_REPOSITORY_H diff --git a/common/repositories/base/base_character_pet_info_repository.h b/common/repositories/base/base_character_pet_info_repository.h index 9268560ea..0083916ac 100644 --- a/common/repositories/base/base_character_pet_info_repository.h +++ b/common/repositories/base/base_character_pet_info_repository.h @@ -100,22 +100,22 @@ public: static CharacterPetInfo NewEntity() { - CharacterPetInfo entry{}; + CharacterPetInfo e{}; - entry.char_id = 0; - entry.pet = 0; - entry.petname = ""; - entry.petpower = 0; - entry.spell_id = 0; - entry.hp = 0; - entry.mana = 0; - entry.size = 0; - entry.taunting = 1; + e.char_id = 0; + e.pet = 0; + e.petname = ""; + e.petpower = 0; + e.spell_id = 0; + e.hp = 0; + e.mana = 0; + e.size = 0; + e.taunting = 1; - return entry; + return e; } - static CharacterPetInfo GetCharacterPetInfoEntry( + static CharacterPetInfo GetCharacterPetInfo( const std::vector &character_pet_infos, int character_pet_info_id ) @@ -144,19 +144,19 @@ public: auto row = results.begin(); if (results.RowCount() == 1) { - CharacterPetInfo entry{}; + CharacterPetInfo e{}; - entry.char_id = atoi(row[0]); - entry.pet = atoi(row[1]); - entry.petname = row[2] ? row[2] : ""; - entry.petpower = atoi(row[3]); - entry.spell_id = atoi(row[4]); - entry.hp = atoi(row[5]); - entry.mana = atoi(row[6]); - entry.size = static_cast(atof(row[7])); - entry.taunting = atoi(row[8]); + e.char_id = atoi(row[0]); + e.pet = atoi(row[1]); + e.petname = row[2] ? row[2] : ""; + e.petpower = atoi(row[3]); + e.spell_id = atoi(row[4]); + e.hp = atoi(row[5]); + e.mana = atoi(row[6]); + e.size = static_cast(atof(row[7])); + e.taunting = atoi(row[8]); - return entry; + return e; } return NewEntity(); @@ -181,30 +181,30 @@ public: static int UpdateOne( Database& db, - CharacterPetInfo character_pet_info_entry + const CharacterPetInfo &e ) { - std::vector update_values; + std::vector v; auto columns = Columns(); - update_values.push_back(columns[0] + " = " + std::to_string(character_pet_info_entry.char_id)); - update_values.push_back(columns[1] + " = " + std::to_string(character_pet_info_entry.pet)); - update_values.push_back(columns[2] + " = '" + Strings::Escape(character_pet_info_entry.petname) + "'"); - update_values.push_back(columns[3] + " = " + std::to_string(character_pet_info_entry.petpower)); - update_values.push_back(columns[4] + " = " + std::to_string(character_pet_info_entry.spell_id)); - update_values.push_back(columns[5] + " = " + std::to_string(character_pet_info_entry.hp)); - update_values.push_back(columns[6] + " = " + std::to_string(character_pet_info_entry.mana)); - update_values.push_back(columns[7] + " = " + std::to_string(character_pet_info_entry.size)); - update_values.push_back(columns[8] + " = " + std::to_string(character_pet_info_entry.taunting)); + v.push_back(columns[0] + " = " + std::to_string(e.char_id)); + v.push_back(columns[1] + " = " + std::to_string(e.pet)); + v.push_back(columns[2] + " = '" + Strings::Escape(e.petname) + "'"); + v.push_back(columns[3] + " = " + std::to_string(e.petpower)); + v.push_back(columns[4] + " = " + std::to_string(e.spell_id)); + v.push_back(columns[5] + " = " + std::to_string(e.hp)); + v.push_back(columns[6] + " = " + std::to_string(e.mana)); + v.push_back(columns[7] + " = " + std::to_string(e.size)); + v.push_back(columns[8] + " = " + std::to_string(e.taunting)); auto results = db.QueryDatabase( fmt::format( "UPDATE {} SET {} WHERE {} = {}", TableName(), - Strings::Implode(", ", update_values), + Strings::Implode(", ", v), PrimaryKey(), - character_pet_info_entry.char_id + e.char_id ) ); @@ -213,63 +213,63 @@ public: static CharacterPetInfo InsertOne( Database& db, - CharacterPetInfo character_pet_info_entry + CharacterPetInfo e ) { - std::vector insert_values; + std::vector v; - insert_values.push_back(std::to_string(character_pet_info_entry.char_id)); - insert_values.push_back(std::to_string(character_pet_info_entry.pet)); - insert_values.push_back("'" + Strings::Escape(character_pet_info_entry.petname) + "'"); - insert_values.push_back(std::to_string(character_pet_info_entry.petpower)); - insert_values.push_back(std::to_string(character_pet_info_entry.spell_id)); - insert_values.push_back(std::to_string(character_pet_info_entry.hp)); - insert_values.push_back(std::to_string(character_pet_info_entry.mana)); - insert_values.push_back(std::to_string(character_pet_info_entry.size)); - insert_values.push_back(std::to_string(character_pet_info_entry.taunting)); + v.push_back(std::to_string(e.char_id)); + v.push_back(std::to_string(e.pet)); + v.push_back("'" + Strings::Escape(e.petname) + "'"); + v.push_back(std::to_string(e.petpower)); + v.push_back(std::to_string(e.spell_id)); + v.push_back(std::to_string(e.hp)); + v.push_back(std::to_string(e.mana)); + v.push_back(std::to_string(e.size)); + v.push_back(std::to_string(e.taunting)); auto results = db.QueryDatabase( fmt::format( "{} VALUES ({})", BaseInsert(), - Strings::Implode(",", insert_values) + Strings::Implode(",", v) ) ); if (results.Success()) { - character_pet_info_entry.char_id = results.LastInsertedID(); - return character_pet_info_entry; + e.char_id = results.LastInsertedID(); + return e; } - character_pet_info_entry = NewEntity(); + e = NewEntity(); - return character_pet_info_entry; + return e; } static int InsertMany( Database& db, - std::vector character_pet_info_entries + const std::vector &entries ) { std::vector insert_chunks; - for (auto &character_pet_info_entry: character_pet_info_entries) { - std::vector insert_values; + for (auto &e: entries) { + std::vector v; - insert_values.push_back(std::to_string(character_pet_info_entry.char_id)); - insert_values.push_back(std::to_string(character_pet_info_entry.pet)); - insert_values.push_back("'" + Strings::Escape(character_pet_info_entry.petname) + "'"); - insert_values.push_back(std::to_string(character_pet_info_entry.petpower)); - insert_values.push_back(std::to_string(character_pet_info_entry.spell_id)); - insert_values.push_back(std::to_string(character_pet_info_entry.hp)); - insert_values.push_back(std::to_string(character_pet_info_entry.mana)); - insert_values.push_back(std::to_string(character_pet_info_entry.size)); - insert_values.push_back(std::to_string(character_pet_info_entry.taunting)); + v.push_back(std::to_string(e.char_id)); + v.push_back(std::to_string(e.pet)); + v.push_back("'" + Strings::Escape(e.petname) + "'"); + v.push_back(std::to_string(e.petpower)); + v.push_back(std::to_string(e.spell_id)); + v.push_back(std::to_string(e.hp)); + v.push_back(std::to_string(e.mana)); + v.push_back(std::to_string(e.size)); + v.push_back(std::to_string(e.taunting)); - insert_chunks.push_back("(" + Strings::Implode(",", insert_values) + ")"); + insert_chunks.push_back("(" + Strings::Implode(",", v) + ")"); } - std::vector insert_values; + std::vector v; auto results = db.QueryDatabase( fmt::format( @@ -296,25 +296,25 @@ public: all_entries.reserve(results.RowCount()); for (auto row = results.begin(); row != results.end(); ++row) { - CharacterPetInfo entry{}; + CharacterPetInfo e{}; - entry.char_id = atoi(row[0]); - entry.pet = atoi(row[1]); - entry.petname = row[2] ? row[2] : ""; - entry.petpower = atoi(row[3]); - entry.spell_id = atoi(row[4]); - entry.hp = atoi(row[5]); - entry.mana = atoi(row[6]); - entry.size = static_cast(atof(row[7])); - entry.taunting = atoi(row[8]); + e.char_id = atoi(row[0]); + e.pet = atoi(row[1]); + e.petname = row[2] ? row[2] : ""; + e.petpower = atoi(row[3]); + e.spell_id = atoi(row[4]); + e.hp = atoi(row[5]); + e.mana = atoi(row[6]); + e.size = static_cast(atof(row[7])); + e.taunting = atoi(row[8]); - all_entries.push_back(entry); + all_entries.push_back(e); } return all_entries; } - static std::vector GetWhere(Database& db, std::string where_filter) + static std::vector GetWhere(Database& db, const std::string &where_filter) { std::vector all_entries; @@ -329,25 +329,25 @@ public: all_entries.reserve(results.RowCount()); for (auto row = results.begin(); row != results.end(); ++row) { - CharacterPetInfo entry{}; + CharacterPetInfo e{}; - entry.char_id = atoi(row[0]); - entry.pet = atoi(row[1]); - entry.petname = row[2] ? row[2] : ""; - entry.petpower = atoi(row[3]); - entry.spell_id = atoi(row[4]); - entry.hp = atoi(row[5]); - entry.mana = atoi(row[6]); - entry.size = static_cast(atof(row[7])); - entry.taunting = atoi(row[8]); + e.char_id = atoi(row[0]); + e.pet = atoi(row[1]); + e.petname = row[2] ? row[2] : ""; + e.petpower = atoi(row[3]); + e.spell_id = atoi(row[4]); + e.hp = atoi(row[5]); + e.mana = atoi(row[6]); + e.size = static_cast(atof(row[7])); + e.taunting = atoi(row[8]); - all_entries.push_back(entry); + all_entries.push_back(e); } return all_entries; } - static int DeleteWhere(Database& db, std::string where_filter) + static int DeleteWhere(Database& db, const std::string &where_filter) { auto results = db.QueryDatabase( fmt::format( @@ -372,6 +372,32 @@ public: 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); + } + }; #endif //EQEMU_BASE_CHARACTER_PET_INFO_REPOSITORY_H diff --git a/common/repositories/base/base_character_pet_inventory_repository.h b/common/repositories/base/base_character_pet_inventory_repository.h index 2918822e6..52dcfaac3 100644 --- a/common/repositories/base/base_character_pet_inventory_repository.h +++ b/common/repositories/base/base_character_pet_inventory_repository.h @@ -85,17 +85,17 @@ public: static CharacterPetInventory NewEntity() { - CharacterPetInventory entry{}; + CharacterPetInventory e{}; - entry.char_id = 0; - entry.pet = 0; - entry.slot = 0; - entry.item_id = 0; + e.char_id = 0; + e.pet = 0; + e.slot = 0; + e.item_id = 0; - return entry; + return e; } - static CharacterPetInventory GetCharacterPetInventoryEntry( + static CharacterPetInventory GetCharacterPetInventory( const std::vector &character_pet_inventorys, int character_pet_inventory_id ) @@ -124,14 +124,14 @@ public: auto row = results.begin(); if (results.RowCount() == 1) { - CharacterPetInventory entry{}; + CharacterPetInventory e{}; - entry.char_id = atoi(row[0]); - entry.pet = atoi(row[1]); - entry.slot = atoi(row[2]); - entry.item_id = atoi(row[3]); + e.char_id = atoi(row[0]); + e.pet = atoi(row[1]); + e.slot = atoi(row[2]); + e.item_id = atoi(row[3]); - return entry; + return e; } return NewEntity(); @@ -156,25 +156,25 @@ public: static int UpdateOne( Database& db, - CharacterPetInventory character_pet_inventory_entry + const CharacterPetInventory &e ) { - std::vector update_values; + std::vector v; auto columns = Columns(); - update_values.push_back(columns[0] + " = " + std::to_string(character_pet_inventory_entry.char_id)); - update_values.push_back(columns[1] + " = " + std::to_string(character_pet_inventory_entry.pet)); - update_values.push_back(columns[2] + " = " + std::to_string(character_pet_inventory_entry.slot)); - update_values.push_back(columns[3] + " = " + std::to_string(character_pet_inventory_entry.item_id)); + v.push_back(columns[0] + " = " + std::to_string(e.char_id)); + v.push_back(columns[1] + " = " + std::to_string(e.pet)); + v.push_back(columns[2] + " = " + std::to_string(e.slot)); + v.push_back(columns[3] + " = " + std::to_string(e.item_id)); auto results = db.QueryDatabase( fmt::format( "UPDATE {} SET {} WHERE {} = {}", TableName(), - Strings::Implode(", ", update_values), + Strings::Implode(", ", v), PrimaryKey(), - character_pet_inventory_entry.char_id + e.char_id ) ); @@ -183,53 +183,53 @@ public: static CharacterPetInventory InsertOne( Database& db, - CharacterPetInventory character_pet_inventory_entry + CharacterPetInventory e ) { - std::vector insert_values; + std::vector v; - insert_values.push_back(std::to_string(character_pet_inventory_entry.char_id)); - insert_values.push_back(std::to_string(character_pet_inventory_entry.pet)); - insert_values.push_back(std::to_string(character_pet_inventory_entry.slot)); - insert_values.push_back(std::to_string(character_pet_inventory_entry.item_id)); + v.push_back(std::to_string(e.char_id)); + v.push_back(std::to_string(e.pet)); + v.push_back(std::to_string(e.slot)); + v.push_back(std::to_string(e.item_id)); auto results = db.QueryDatabase( fmt::format( "{} VALUES ({})", BaseInsert(), - Strings::Implode(",", insert_values) + Strings::Implode(",", v) ) ); if (results.Success()) { - character_pet_inventory_entry.char_id = results.LastInsertedID(); - return character_pet_inventory_entry; + e.char_id = results.LastInsertedID(); + return e; } - character_pet_inventory_entry = NewEntity(); + e = NewEntity(); - return character_pet_inventory_entry; + return e; } static int InsertMany( Database& db, - std::vector character_pet_inventory_entries + const std::vector &entries ) { std::vector insert_chunks; - for (auto &character_pet_inventory_entry: character_pet_inventory_entries) { - std::vector insert_values; + for (auto &e: entries) { + std::vector v; - insert_values.push_back(std::to_string(character_pet_inventory_entry.char_id)); - insert_values.push_back(std::to_string(character_pet_inventory_entry.pet)); - insert_values.push_back(std::to_string(character_pet_inventory_entry.slot)); - insert_values.push_back(std::to_string(character_pet_inventory_entry.item_id)); + v.push_back(std::to_string(e.char_id)); + v.push_back(std::to_string(e.pet)); + v.push_back(std::to_string(e.slot)); + v.push_back(std::to_string(e.item_id)); - insert_chunks.push_back("(" + Strings::Implode(",", insert_values) + ")"); + insert_chunks.push_back("(" + Strings::Implode(",", v) + ")"); } - std::vector insert_values; + std::vector v; auto results = db.QueryDatabase( fmt::format( @@ -256,20 +256,20 @@ public: all_entries.reserve(results.RowCount()); for (auto row = results.begin(); row != results.end(); ++row) { - CharacterPetInventory entry{}; + CharacterPetInventory e{}; - entry.char_id = atoi(row[0]); - entry.pet = atoi(row[1]); - entry.slot = atoi(row[2]); - entry.item_id = atoi(row[3]); + e.char_id = atoi(row[0]); + e.pet = atoi(row[1]); + e.slot = atoi(row[2]); + e.item_id = atoi(row[3]); - all_entries.push_back(entry); + all_entries.push_back(e); } return all_entries; } - static std::vector GetWhere(Database& db, std::string where_filter) + static std::vector GetWhere(Database& db, const std::string &where_filter) { std::vector all_entries; @@ -284,20 +284,20 @@ public: all_entries.reserve(results.RowCount()); for (auto row = results.begin(); row != results.end(); ++row) { - CharacterPetInventory entry{}; + CharacterPetInventory e{}; - entry.char_id = atoi(row[0]); - entry.pet = atoi(row[1]); - entry.slot = atoi(row[2]); - entry.item_id = atoi(row[3]); + e.char_id = atoi(row[0]); + e.pet = atoi(row[1]); + e.slot = atoi(row[2]); + e.item_id = atoi(row[3]); - all_entries.push_back(entry); + all_entries.push_back(e); } return all_entries; } - static int DeleteWhere(Database& db, std::string where_filter) + static int DeleteWhere(Database& db, const std::string &where_filter) { auto results = db.QueryDatabase( fmt::format( @@ -322,6 +322,32 @@ public: 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); + } + }; #endif //EQEMU_BASE_CHARACTER_PET_INVENTORY_REPOSITORY_H diff --git a/common/repositories/base/base_character_potionbelt_repository.h b/common/repositories/base/base_character_potionbelt_repository.h index a083e2e7a..a4882c566 100644 --- a/common/repositories/base/base_character_potionbelt_repository.h +++ b/common/repositories/base/base_character_potionbelt_repository.h @@ -85,17 +85,17 @@ public: static CharacterPotionbelt NewEntity() { - CharacterPotionbelt entry{}; + CharacterPotionbelt e{}; - entry.id = 0; - entry.potion_id = 0; - entry.item_id = 0; - entry.icon = 0; + e.id = 0; + e.potion_id = 0; + e.item_id = 0; + e.icon = 0; - return entry; + return e; } - static CharacterPotionbelt GetCharacterPotionbeltEntry( + static CharacterPotionbelt GetCharacterPotionbelt( const std::vector &character_potionbelts, int character_potionbelt_id ) @@ -124,14 +124,14 @@ public: auto row = results.begin(); if (results.RowCount() == 1) { - CharacterPotionbelt entry{}; + CharacterPotionbelt e{}; - entry.id = atoi(row[0]); - entry.potion_id = atoi(row[1]); - entry.item_id = atoi(row[2]); - entry.icon = atoi(row[3]); + e.id = atoi(row[0]); + e.potion_id = atoi(row[1]); + e.item_id = atoi(row[2]); + e.icon = atoi(row[3]); - return entry; + return e; } return NewEntity(); @@ -156,25 +156,25 @@ public: static int UpdateOne( Database& db, - CharacterPotionbelt character_potionbelt_entry + const CharacterPotionbelt &e ) { - std::vector update_values; + std::vector v; auto columns = Columns(); - update_values.push_back(columns[0] + " = " + std::to_string(character_potionbelt_entry.id)); - update_values.push_back(columns[1] + " = " + std::to_string(character_potionbelt_entry.potion_id)); - update_values.push_back(columns[2] + " = " + std::to_string(character_potionbelt_entry.item_id)); - update_values.push_back(columns[3] + " = " + std::to_string(character_potionbelt_entry.icon)); + v.push_back(columns[0] + " = " + std::to_string(e.id)); + v.push_back(columns[1] + " = " + std::to_string(e.potion_id)); + v.push_back(columns[2] + " = " + std::to_string(e.item_id)); + v.push_back(columns[3] + " = " + std::to_string(e.icon)); auto results = db.QueryDatabase( fmt::format( "UPDATE {} SET {} WHERE {} = {}", TableName(), - Strings::Implode(", ", update_values), + Strings::Implode(", ", v), PrimaryKey(), - character_potionbelt_entry.id + e.id ) ); @@ -183,53 +183,53 @@ public: static CharacterPotionbelt InsertOne( Database& db, - CharacterPotionbelt character_potionbelt_entry + CharacterPotionbelt e ) { - std::vector insert_values; + std::vector v; - insert_values.push_back(std::to_string(character_potionbelt_entry.id)); - insert_values.push_back(std::to_string(character_potionbelt_entry.potion_id)); - insert_values.push_back(std::to_string(character_potionbelt_entry.item_id)); - insert_values.push_back(std::to_string(character_potionbelt_entry.icon)); + v.push_back(std::to_string(e.id)); + v.push_back(std::to_string(e.potion_id)); + v.push_back(std::to_string(e.item_id)); + v.push_back(std::to_string(e.icon)); auto results = db.QueryDatabase( fmt::format( "{} VALUES ({})", BaseInsert(), - Strings::Implode(",", insert_values) + Strings::Implode(",", v) ) ); if (results.Success()) { - character_potionbelt_entry.id = results.LastInsertedID(); - return character_potionbelt_entry; + e.id = results.LastInsertedID(); + return e; } - character_potionbelt_entry = NewEntity(); + e = NewEntity(); - return character_potionbelt_entry; + return e; } static int InsertMany( Database& db, - std::vector character_potionbelt_entries + const std::vector &entries ) { std::vector insert_chunks; - for (auto &character_potionbelt_entry: character_potionbelt_entries) { - std::vector insert_values; + for (auto &e: entries) { + std::vector v; - insert_values.push_back(std::to_string(character_potionbelt_entry.id)); - insert_values.push_back(std::to_string(character_potionbelt_entry.potion_id)); - insert_values.push_back(std::to_string(character_potionbelt_entry.item_id)); - insert_values.push_back(std::to_string(character_potionbelt_entry.icon)); + v.push_back(std::to_string(e.id)); + v.push_back(std::to_string(e.potion_id)); + v.push_back(std::to_string(e.item_id)); + v.push_back(std::to_string(e.icon)); - insert_chunks.push_back("(" + Strings::Implode(",", insert_values) + ")"); + insert_chunks.push_back("(" + Strings::Implode(",", v) + ")"); } - std::vector insert_values; + std::vector v; auto results = db.QueryDatabase( fmt::format( @@ -256,20 +256,20 @@ public: all_entries.reserve(results.RowCount()); for (auto row = results.begin(); row != results.end(); ++row) { - CharacterPotionbelt entry{}; + CharacterPotionbelt e{}; - entry.id = atoi(row[0]); - entry.potion_id = atoi(row[1]); - entry.item_id = atoi(row[2]); - entry.icon = atoi(row[3]); + e.id = atoi(row[0]); + e.potion_id = atoi(row[1]); + e.item_id = atoi(row[2]); + e.icon = atoi(row[3]); - all_entries.push_back(entry); + all_entries.push_back(e); } return all_entries; } - static std::vector GetWhere(Database& db, std::string where_filter) + static std::vector GetWhere(Database& db, const std::string &where_filter) { std::vector all_entries; @@ -284,20 +284,20 @@ public: all_entries.reserve(results.RowCount()); for (auto row = results.begin(); row != results.end(); ++row) { - CharacterPotionbelt entry{}; + CharacterPotionbelt e{}; - entry.id = atoi(row[0]); - entry.potion_id = atoi(row[1]); - entry.item_id = atoi(row[2]); - entry.icon = atoi(row[3]); + e.id = atoi(row[0]); + e.potion_id = atoi(row[1]); + e.item_id = atoi(row[2]); + e.icon = atoi(row[3]); - all_entries.push_back(entry); + all_entries.push_back(e); } return all_entries; } - static int DeleteWhere(Database& db, std::string where_filter) + static int DeleteWhere(Database& db, const std::string &where_filter) { auto results = db.QueryDatabase( fmt::format( @@ -322,6 +322,32 @@ public: 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); + } + }; #endif //EQEMU_BASE_CHARACTER_POTIONBELT_REPOSITORY_H diff --git a/common/repositories/base/base_character_skills_repository.h b/common/repositories/base/base_character_skills_repository.h index 627c9ee3e..cb659832d 100644 --- a/common/repositories/base/base_character_skills_repository.h +++ b/common/repositories/base/base_character_skills_repository.h @@ -82,16 +82,16 @@ public: static CharacterSkills NewEntity() { - CharacterSkills entry{}; + CharacterSkills e{}; - entry.id = 0; - entry.skill_id = 0; - entry.value = 0; + e.id = 0; + e.skill_id = 0; + e.value = 0; - return entry; + return e; } - static CharacterSkills GetCharacterSkillsEntry( + static CharacterSkills GetCharacterSkills( const std::vector &character_skillss, int character_skills_id ) @@ -120,13 +120,13 @@ public: auto row = results.begin(); if (results.RowCount() == 1) { - CharacterSkills entry{}; + CharacterSkills e{}; - entry.id = atoi(row[0]); - entry.skill_id = atoi(row[1]); - entry.value = atoi(row[2]); + e.id = atoi(row[0]); + e.skill_id = atoi(row[1]); + e.value = atoi(row[2]); - return entry; + return e; } return NewEntity(); @@ -151,23 +151,23 @@ public: static int UpdateOne( Database& db, - CharacterSkills character_skills_entry + const CharacterSkills &e ) { - std::vector update_values; + std::vector v; auto columns = Columns(); - update_values.push_back(columns[1] + " = " + std::to_string(character_skills_entry.skill_id)); - update_values.push_back(columns[2] + " = " + std::to_string(character_skills_entry.value)); + v.push_back(columns[1] + " = " + std::to_string(e.skill_id)); + v.push_back(columns[2] + " = " + std::to_string(e.value)); auto results = db.QueryDatabase( fmt::format( "UPDATE {} SET {} WHERE {} = {}", TableName(), - Strings::Implode(", ", update_values), + Strings::Implode(", ", v), PrimaryKey(), - character_skills_entry.id + e.id ) ); @@ -176,51 +176,51 @@ public: static CharacterSkills InsertOne( Database& db, - CharacterSkills character_skills_entry + CharacterSkills e ) { - std::vector insert_values; + std::vector v; - insert_values.push_back(std::to_string(character_skills_entry.id)); - insert_values.push_back(std::to_string(character_skills_entry.skill_id)); - insert_values.push_back(std::to_string(character_skills_entry.value)); + v.push_back(std::to_string(e.id)); + v.push_back(std::to_string(e.skill_id)); + v.push_back(std::to_string(e.value)); auto results = db.QueryDatabase( fmt::format( "{} VALUES ({})", BaseInsert(), - Strings::Implode(",", insert_values) + Strings::Implode(",", v) ) ); if (results.Success()) { - character_skills_entry.id = results.LastInsertedID(); - return character_skills_entry; + e.id = results.LastInsertedID(); + return e; } - character_skills_entry = NewEntity(); + e = NewEntity(); - return character_skills_entry; + return e; } static int InsertMany( Database& db, - std::vector character_skills_entries + const std::vector &entries ) { std::vector insert_chunks; - for (auto &character_skills_entry: character_skills_entries) { - std::vector insert_values; + for (auto &e: entries) { + std::vector v; - insert_values.push_back(std::to_string(character_skills_entry.id)); - insert_values.push_back(std::to_string(character_skills_entry.skill_id)); - insert_values.push_back(std::to_string(character_skills_entry.value)); + v.push_back(std::to_string(e.id)); + v.push_back(std::to_string(e.skill_id)); + v.push_back(std::to_string(e.value)); - insert_chunks.push_back("(" + Strings::Implode(",", insert_values) + ")"); + insert_chunks.push_back("(" + Strings::Implode(",", v) + ")"); } - std::vector insert_values; + std::vector v; auto results = db.QueryDatabase( fmt::format( @@ -247,19 +247,19 @@ public: all_entries.reserve(results.RowCount()); for (auto row = results.begin(); row != results.end(); ++row) { - CharacterSkills entry{}; + CharacterSkills e{}; - entry.id = atoi(row[0]); - entry.skill_id = atoi(row[1]); - entry.value = atoi(row[2]); + e.id = atoi(row[0]); + e.skill_id = atoi(row[1]); + e.value = atoi(row[2]); - all_entries.push_back(entry); + all_entries.push_back(e); } return all_entries; } - static std::vector GetWhere(Database& db, std::string where_filter) + static std::vector GetWhere(Database& db, const std::string &where_filter) { std::vector all_entries; @@ -274,19 +274,19 @@ public: all_entries.reserve(results.RowCount()); for (auto row = results.begin(); row != results.end(); ++row) { - CharacterSkills entry{}; + CharacterSkills e{}; - entry.id = atoi(row[0]); - entry.skill_id = atoi(row[1]); - entry.value = atoi(row[2]); + e.id = atoi(row[0]); + e.skill_id = atoi(row[1]); + e.value = atoi(row[2]); - all_entries.push_back(entry); + all_entries.push_back(e); } return all_entries; } - static int DeleteWhere(Database& db, std::string where_filter) + static int DeleteWhere(Database& db, const std::string &where_filter) { auto results = db.QueryDatabase( fmt::format( @@ -311,6 +311,32 @@ public: 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); + } + }; #endif //EQEMU_BASE_CHARACTER_SKILLS_REPOSITORY_H diff --git a/common/repositories/base/base_character_spells_repository.h b/common/repositories/base/base_character_spells_repository.h index b5b072a56..af5d0d8ed 100644 --- a/common/repositories/base/base_character_spells_repository.h +++ b/common/repositories/base/base_character_spells_repository.h @@ -82,16 +82,16 @@ public: static CharacterSpells NewEntity() { - CharacterSpells entry{}; + CharacterSpells e{}; - entry.id = 0; - entry.slot_id = 0; - entry.spell_id = 0; + e.id = 0; + e.slot_id = 0; + e.spell_id = 0; - return entry; + return e; } - static CharacterSpells GetCharacterSpellsEntry( + static CharacterSpells GetCharacterSpells( const std::vector &character_spellss, int character_spells_id ) @@ -120,13 +120,13 @@ public: auto row = results.begin(); if (results.RowCount() == 1) { - CharacterSpells entry{}; + CharacterSpells e{}; - entry.id = atoi(row[0]); - entry.slot_id = atoi(row[1]); - entry.spell_id = atoi(row[2]); + e.id = atoi(row[0]); + e.slot_id = atoi(row[1]); + e.spell_id = atoi(row[2]); - return entry; + return e; } return NewEntity(); @@ -151,23 +151,23 @@ public: static int UpdateOne( Database& db, - CharacterSpells character_spells_entry + const CharacterSpells &e ) { - std::vector update_values; + std::vector v; auto columns = Columns(); - update_values.push_back(columns[1] + " = " + std::to_string(character_spells_entry.slot_id)); - update_values.push_back(columns[2] + " = " + std::to_string(character_spells_entry.spell_id)); + v.push_back(columns[1] + " = " + std::to_string(e.slot_id)); + v.push_back(columns[2] + " = " + std::to_string(e.spell_id)); auto results = db.QueryDatabase( fmt::format( "UPDATE {} SET {} WHERE {} = {}", TableName(), - Strings::Implode(", ", update_values), + Strings::Implode(", ", v), PrimaryKey(), - character_spells_entry.id + e.id ) ); @@ -176,51 +176,51 @@ public: static CharacterSpells InsertOne( Database& db, - CharacterSpells character_spells_entry + CharacterSpells e ) { - std::vector insert_values; + std::vector v; - insert_values.push_back(std::to_string(character_spells_entry.id)); - insert_values.push_back(std::to_string(character_spells_entry.slot_id)); - insert_values.push_back(std::to_string(character_spells_entry.spell_id)); + v.push_back(std::to_string(e.id)); + v.push_back(std::to_string(e.slot_id)); + v.push_back(std::to_string(e.spell_id)); auto results = db.QueryDatabase( fmt::format( "{} VALUES ({})", BaseInsert(), - Strings::Implode(",", insert_values) + Strings::Implode(",", v) ) ); if (results.Success()) { - character_spells_entry.id = results.LastInsertedID(); - return character_spells_entry; + e.id = results.LastInsertedID(); + return e; } - character_spells_entry = NewEntity(); + e = NewEntity(); - return character_spells_entry; + return e; } static int InsertMany( Database& db, - std::vector character_spells_entries + const std::vector &entries ) { std::vector insert_chunks; - for (auto &character_spells_entry: character_spells_entries) { - std::vector insert_values; + for (auto &e: entries) { + std::vector v; - insert_values.push_back(std::to_string(character_spells_entry.id)); - insert_values.push_back(std::to_string(character_spells_entry.slot_id)); - insert_values.push_back(std::to_string(character_spells_entry.spell_id)); + v.push_back(std::to_string(e.id)); + v.push_back(std::to_string(e.slot_id)); + v.push_back(std::to_string(e.spell_id)); - insert_chunks.push_back("(" + Strings::Implode(",", insert_values) + ")"); + insert_chunks.push_back("(" + Strings::Implode(",", v) + ")"); } - std::vector insert_values; + std::vector v; auto results = db.QueryDatabase( fmt::format( @@ -247,19 +247,19 @@ public: all_entries.reserve(results.RowCount()); for (auto row = results.begin(); row != results.end(); ++row) { - CharacterSpells entry{}; + CharacterSpells e{}; - entry.id = atoi(row[0]); - entry.slot_id = atoi(row[1]); - entry.spell_id = atoi(row[2]); + e.id = atoi(row[0]); + e.slot_id = atoi(row[1]); + e.spell_id = atoi(row[2]); - all_entries.push_back(entry); + all_entries.push_back(e); } return all_entries; } - static std::vector GetWhere(Database& db, std::string where_filter) + static std::vector GetWhere(Database& db, const std::string &where_filter) { std::vector all_entries; @@ -274,19 +274,19 @@ public: all_entries.reserve(results.RowCount()); for (auto row = results.begin(); row != results.end(); ++row) { - CharacterSpells entry{}; + CharacterSpells e{}; - entry.id = atoi(row[0]); - entry.slot_id = atoi(row[1]); - entry.spell_id = atoi(row[2]); + e.id = atoi(row[0]); + e.slot_id = atoi(row[1]); + e.spell_id = atoi(row[2]); - all_entries.push_back(entry); + all_entries.push_back(e); } return all_entries; } - static int DeleteWhere(Database& db, std::string where_filter) + static int DeleteWhere(Database& db, const std::string &where_filter) { auto results = db.QueryDatabase( fmt::format( @@ -311,6 +311,32 @@ public: 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); + } + }; #endif //EQEMU_BASE_CHARACTER_SPELLS_REPOSITORY_H diff --git a/common/repositories/base/base_character_task_timers_repository.h b/common/repositories/base/base_character_task_timers_repository.h index 0177b8fbd..5a4cee395 100644 --- a/common/repositories/base/base_character_task_timers_repository.h +++ b/common/repositories/base/base_character_task_timers_repository.h @@ -91,19 +91,19 @@ public: static CharacterTaskTimers NewEntity() { - CharacterTaskTimers entry{}; + CharacterTaskTimers e{}; - entry.id = 0; - entry.character_id = 0; - entry.task_id = 0; - entry.timer_type = 0; - entry.timer_group = 0; - entry.expire_time = std::time(nullptr); + e.id = 0; + e.character_id = 0; + e.task_id = 0; + e.timer_type = 0; + e.timer_group = 0; + e.expire_time = std::time(nullptr); - return entry; + return e; } - static CharacterTaskTimers GetCharacterTaskTimersEntry( + static CharacterTaskTimers GetCharacterTaskTimers( const std::vector &character_task_timerss, int character_task_timers_id ) @@ -132,16 +132,16 @@ public: auto row = results.begin(); if (results.RowCount() == 1) { - CharacterTaskTimers entry{}; + CharacterTaskTimers e{}; - entry.id = atoi(row[0]); - entry.character_id = atoi(row[1]); - entry.task_id = atoi(row[2]); - entry.timer_type = atoi(row[3]); - entry.timer_group = atoi(row[4]); - entry.expire_time = strtoll(row[5] ? row[5] : "-1", nullptr, 10); + e.id = atoi(row[0]); + e.character_id = atoi(row[1]); + e.task_id = atoi(row[2]); + e.timer_type = atoi(row[3]); + e.timer_group = atoi(row[4]); + e.expire_time = strtoll(row[5] ? row[5] : "-1", nullptr, 10); - return entry; + return e; } return NewEntity(); @@ -166,26 +166,26 @@ public: static int UpdateOne( Database& db, - CharacterTaskTimers character_task_timers_entry + const CharacterTaskTimers &e ) { - std::vector update_values; + std::vector v; auto columns = Columns(); - update_values.push_back(columns[1] + " = " + std::to_string(character_task_timers_entry.character_id)); - update_values.push_back(columns[2] + " = " + std::to_string(character_task_timers_entry.task_id)); - update_values.push_back(columns[3] + " = " + std::to_string(character_task_timers_entry.timer_type)); - update_values.push_back(columns[4] + " = " + std::to_string(character_task_timers_entry.timer_group)); - update_values.push_back(columns[5] + " = FROM_UNIXTIME(" + (character_task_timers_entry.expire_time > 0 ? std::to_string(character_task_timers_entry.expire_time) : "null") + ")"); + v.push_back(columns[1] + " = " + std::to_string(e.character_id)); + v.push_back(columns[2] + " = " + std::to_string(e.task_id)); + v.push_back(columns[3] + " = " + std::to_string(e.timer_type)); + v.push_back(columns[4] + " = " + std::to_string(e.timer_group)); + v.push_back(columns[5] + " = FROM_UNIXTIME(" + (e.expire_time > 0 ? std::to_string(e.expire_time) : "null") + ")"); auto results = db.QueryDatabase( fmt::format( "UPDATE {} SET {} WHERE {} = {}", TableName(), - Strings::Implode(", ", update_values), + Strings::Implode(", ", v), PrimaryKey(), - character_task_timers_entry.id + e.id ) ); @@ -194,57 +194,57 @@ public: static CharacterTaskTimers InsertOne( Database& db, - CharacterTaskTimers character_task_timers_entry + CharacterTaskTimers e ) { - std::vector insert_values; + std::vector v; - insert_values.push_back(std::to_string(character_task_timers_entry.id)); - insert_values.push_back(std::to_string(character_task_timers_entry.character_id)); - insert_values.push_back(std::to_string(character_task_timers_entry.task_id)); - insert_values.push_back(std::to_string(character_task_timers_entry.timer_type)); - insert_values.push_back(std::to_string(character_task_timers_entry.timer_group)); - insert_values.push_back("FROM_UNIXTIME(" + (character_task_timers_entry.expire_time > 0 ? std::to_string(character_task_timers_entry.expire_time) : "null") + ")"); + v.push_back(std::to_string(e.id)); + v.push_back(std::to_string(e.character_id)); + v.push_back(std::to_string(e.task_id)); + v.push_back(std::to_string(e.timer_type)); + v.push_back(std::to_string(e.timer_group)); + v.push_back("FROM_UNIXTIME(" + (e.expire_time > 0 ? std::to_string(e.expire_time) : "null") + ")"); auto results = db.QueryDatabase( fmt::format( "{} VALUES ({})", BaseInsert(), - Strings::Implode(",", insert_values) + Strings::Implode(",", v) ) ); if (results.Success()) { - character_task_timers_entry.id = results.LastInsertedID(); - return character_task_timers_entry; + e.id = results.LastInsertedID(); + return e; } - character_task_timers_entry = NewEntity(); + e = NewEntity(); - return character_task_timers_entry; + return e; } static int InsertMany( Database& db, - std::vector character_task_timers_entries + const std::vector &entries ) { std::vector insert_chunks; - for (auto &character_task_timers_entry: character_task_timers_entries) { - std::vector insert_values; + for (auto &e: entries) { + std::vector v; - insert_values.push_back(std::to_string(character_task_timers_entry.id)); - insert_values.push_back(std::to_string(character_task_timers_entry.character_id)); - insert_values.push_back(std::to_string(character_task_timers_entry.task_id)); - insert_values.push_back(std::to_string(character_task_timers_entry.timer_type)); - insert_values.push_back(std::to_string(character_task_timers_entry.timer_group)); - insert_values.push_back("FROM_UNIXTIME(" + (character_task_timers_entry.expire_time > 0 ? std::to_string(character_task_timers_entry.expire_time) : "null") + ")"); + v.push_back(std::to_string(e.id)); + v.push_back(std::to_string(e.character_id)); + v.push_back(std::to_string(e.task_id)); + v.push_back(std::to_string(e.timer_type)); + v.push_back(std::to_string(e.timer_group)); + v.push_back("FROM_UNIXTIME(" + (e.expire_time > 0 ? std::to_string(e.expire_time) : "null") + ")"); - insert_chunks.push_back("(" + Strings::Implode(",", insert_values) + ")"); + insert_chunks.push_back("(" + Strings::Implode(",", v) + ")"); } - std::vector insert_values; + std::vector v; auto results = db.QueryDatabase( fmt::format( @@ -271,22 +271,22 @@ public: all_entries.reserve(results.RowCount()); for (auto row = results.begin(); row != results.end(); ++row) { - CharacterTaskTimers entry{}; + CharacterTaskTimers e{}; - entry.id = atoi(row[0]); - entry.character_id = atoi(row[1]); - entry.task_id = atoi(row[2]); - entry.timer_type = atoi(row[3]); - entry.timer_group = atoi(row[4]); - entry.expire_time = strtoll(row[5] ? row[5] : "-1", nullptr, 10); + e.id = atoi(row[0]); + e.character_id = atoi(row[1]); + e.task_id = atoi(row[2]); + e.timer_type = atoi(row[3]); + e.timer_group = atoi(row[4]); + e.expire_time = strtoll(row[5] ? row[5] : "-1", nullptr, 10); - all_entries.push_back(entry); + all_entries.push_back(e); } return all_entries; } - static std::vector GetWhere(Database& db, std::string where_filter) + static std::vector GetWhere(Database& db, const std::string &where_filter) { std::vector all_entries; @@ -301,22 +301,22 @@ public: all_entries.reserve(results.RowCount()); for (auto row = results.begin(); row != results.end(); ++row) { - CharacterTaskTimers entry{}; + CharacterTaskTimers e{}; - entry.id = atoi(row[0]); - entry.character_id = atoi(row[1]); - entry.task_id = atoi(row[2]); - entry.timer_type = atoi(row[3]); - entry.timer_group = atoi(row[4]); - entry.expire_time = strtoll(row[5] ? row[5] : "-1", nullptr, 10); + e.id = atoi(row[0]); + e.character_id = atoi(row[1]); + e.task_id = atoi(row[2]); + e.timer_type = atoi(row[3]); + e.timer_group = atoi(row[4]); + e.expire_time = strtoll(row[5] ? row[5] : "-1", nullptr, 10); - all_entries.push_back(entry); + all_entries.push_back(e); } return all_entries; } - static int DeleteWhere(Database& db, std::string where_filter) + static int DeleteWhere(Database& db, const std::string &where_filter) { auto results = db.QueryDatabase( fmt::format( @@ -341,6 +341,32 @@ public: 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); + } + }; #endif //EQEMU_BASE_CHARACTER_TASK_TIMERS_REPOSITORY_H diff --git a/common/repositories/base/base_character_tasks_repository.h b/common/repositories/base/base_character_tasks_repository.h index 013d2091c..f18bc73f9 100644 --- a/common/repositories/base/base_character_tasks_repository.h +++ b/common/repositories/base/base_character_tasks_repository.h @@ -91,19 +91,19 @@ public: static CharacterTasks NewEntity() { - CharacterTasks entry{}; + CharacterTasks e{}; - entry.charid = 0; - entry.taskid = 0; - entry.slot = 0; - entry.type = 0; - entry.acceptedtime = 0; - entry.was_rewarded = 0; + e.charid = 0; + e.taskid = 0; + e.slot = 0; + e.type = 0; + e.acceptedtime = 0; + e.was_rewarded = 0; - return entry; + return e; } - static CharacterTasks GetCharacterTasksEntry( + static CharacterTasks GetCharacterTasks( const std::vector &character_taskss, int character_tasks_id ) @@ -132,16 +132,16 @@ public: auto row = results.begin(); if (results.RowCount() == 1) { - CharacterTasks entry{}; + CharacterTasks e{}; - entry.charid = atoi(row[0]); - entry.taskid = atoi(row[1]); - entry.slot = atoi(row[2]); - entry.type = atoi(row[3]); - entry.acceptedtime = atoi(row[4]); - entry.was_rewarded = atoi(row[5]); + e.charid = atoi(row[0]); + e.taskid = atoi(row[1]); + e.slot = atoi(row[2]); + e.type = atoi(row[3]); + e.acceptedtime = atoi(row[4]); + e.was_rewarded = atoi(row[5]); - return entry; + return e; } return NewEntity(); @@ -166,27 +166,27 @@ public: static int UpdateOne( Database& db, - CharacterTasks character_tasks_entry + const CharacterTasks &e ) { - std::vector update_values; + std::vector v; auto columns = Columns(); - update_values.push_back(columns[0] + " = " + std::to_string(character_tasks_entry.charid)); - update_values.push_back(columns[1] + " = " + std::to_string(character_tasks_entry.taskid)); - update_values.push_back(columns[2] + " = " + std::to_string(character_tasks_entry.slot)); - update_values.push_back(columns[3] + " = " + std::to_string(character_tasks_entry.type)); - update_values.push_back(columns[4] + " = " + std::to_string(character_tasks_entry.acceptedtime)); - update_values.push_back(columns[5] + " = " + std::to_string(character_tasks_entry.was_rewarded)); + v.push_back(columns[0] + " = " + std::to_string(e.charid)); + v.push_back(columns[1] + " = " + std::to_string(e.taskid)); + v.push_back(columns[2] + " = " + std::to_string(e.slot)); + v.push_back(columns[3] + " = " + std::to_string(e.type)); + v.push_back(columns[4] + " = " + std::to_string(e.acceptedtime)); + v.push_back(columns[5] + " = " + std::to_string(e.was_rewarded)); auto results = db.QueryDatabase( fmt::format( "UPDATE {} SET {} WHERE {} = {}", TableName(), - Strings::Implode(", ", update_values), + Strings::Implode(", ", v), PrimaryKey(), - character_tasks_entry.charid + e.charid ) ); @@ -195,57 +195,57 @@ public: static CharacterTasks InsertOne( Database& db, - CharacterTasks character_tasks_entry + CharacterTasks e ) { - std::vector insert_values; + std::vector v; - insert_values.push_back(std::to_string(character_tasks_entry.charid)); - insert_values.push_back(std::to_string(character_tasks_entry.taskid)); - insert_values.push_back(std::to_string(character_tasks_entry.slot)); - insert_values.push_back(std::to_string(character_tasks_entry.type)); - insert_values.push_back(std::to_string(character_tasks_entry.acceptedtime)); - insert_values.push_back(std::to_string(character_tasks_entry.was_rewarded)); + v.push_back(std::to_string(e.charid)); + v.push_back(std::to_string(e.taskid)); + v.push_back(std::to_string(e.slot)); + v.push_back(std::to_string(e.type)); + v.push_back(std::to_string(e.acceptedtime)); + v.push_back(std::to_string(e.was_rewarded)); auto results = db.QueryDatabase( fmt::format( "{} VALUES ({})", BaseInsert(), - Strings::Implode(",", insert_values) + Strings::Implode(",", v) ) ); if (results.Success()) { - character_tasks_entry.charid = results.LastInsertedID(); - return character_tasks_entry; + e.charid = results.LastInsertedID(); + return e; } - character_tasks_entry = NewEntity(); + e = NewEntity(); - return character_tasks_entry; + return e; } static int InsertMany( Database& db, - std::vector character_tasks_entries + const std::vector &entries ) { std::vector insert_chunks; - for (auto &character_tasks_entry: character_tasks_entries) { - std::vector insert_values; + for (auto &e: entries) { + std::vector v; - insert_values.push_back(std::to_string(character_tasks_entry.charid)); - insert_values.push_back(std::to_string(character_tasks_entry.taskid)); - insert_values.push_back(std::to_string(character_tasks_entry.slot)); - insert_values.push_back(std::to_string(character_tasks_entry.type)); - insert_values.push_back(std::to_string(character_tasks_entry.acceptedtime)); - insert_values.push_back(std::to_string(character_tasks_entry.was_rewarded)); + v.push_back(std::to_string(e.charid)); + v.push_back(std::to_string(e.taskid)); + v.push_back(std::to_string(e.slot)); + v.push_back(std::to_string(e.type)); + v.push_back(std::to_string(e.acceptedtime)); + v.push_back(std::to_string(e.was_rewarded)); - insert_chunks.push_back("(" + Strings::Implode(",", insert_values) + ")"); + insert_chunks.push_back("(" + Strings::Implode(",", v) + ")"); } - std::vector insert_values; + std::vector v; auto results = db.QueryDatabase( fmt::format( @@ -272,22 +272,22 @@ public: all_entries.reserve(results.RowCount()); for (auto row = results.begin(); row != results.end(); ++row) { - CharacterTasks entry{}; + CharacterTasks e{}; - entry.charid = atoi(row[0]); - entry.taskid = atoi(row[1]); - entry.slot = atoi(row[2]); - entry.type = atoi(row[3]); - entry.acceptedtime = atoi(row[4]); - entry.was_rewarded = atoi(row[5]); + e.charid = atoi(row[0]); + e.taskid = atoi(row[1]); + e.slot = atoi(row[2]); + e.type = atoi(row[3]); + e.acceptedtime = atoi(row[4]); + e.was_rewarded = atoi(row[5]); - all_entries.push_back(entry); + all_entries.push_back(e); } return all_entries; } - static std::vector GetWhere(Database& db, std::string where_filter) + static std::vector GetWhere(Database& db, const std::string &where_filter) { std::vector all_entries; @@ -302,22 +302,22 @@ public: all_entries.reserve(results.RowCount()); for (auto row = results.begin(); row != results.end(); ++row) { - CharacterTasks entry{}; + CharacterTasks e{}; - entry.charid = atoi(row[0]); - entry.taskid = atoi(row[1]); - entry.slot = atoi(row[2]); - entry.type = atoi(row[3]); - entry.acceptedtime = atoi(row[4]); - entry.was_rewarded = atoi(row[5]); + e.charid = atoi(row[0]); + e.taskid = atoi(row[1]); + e.slot = atoi(row[2]); + e.type = atoi(row[3]); + e.acceptedtime = atoi(row[4]); + e.was_rewarded = atoi(row[5]); - all_entries.push_back(entry); + all_entries.push_back(e); } return all_entries; } - static int DeleteWhere(Database& db, std::string where_filter) + static int DeleteWhere(Database& db, const std::string &where_filter) { auto results = db.QueryDatabase( fmt::format( @@ -342,6 +342,32 @@ public: 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); + } + }; #endif //EQEMU_BASE_CHARACTER_TASKS_REPOSITORY_H diff --git a/common/repositories/base/base_completed_shared_task_activity_state_repository.h b/common/repositories/base/base_completed_shared_task_activity_state_repository.h index 545b001ee..0d89bd955 100644 --- a/common/repositories/base/base_completed_shared_task_activity_state_repository.h +++ b/common/repositories/base/base_completed_shared_task_activity_state_repository.h @@ -88,18 +88,18 @@ public: static CompletedSharedTaskActivityState NewEntity() { - CompletedSharedTaskActivityState entry{}; + CompletedSharedTaskActivityState e{}; - entry.shared_task_id = 0; - entry.activity_id = 0; - entry.done_count = 0; - entry.updated_time = 0; - entry.completed_time = 0; + e.shared_task_id = 0; + e.activity_id = 0; + e.done_count = 0; + e.updated_time = 0; + e.completed_time = 0; - return entry; + return e; } - static CompletedSharedTaskActivityState GetCompletedSharedTaskActivityStateEntry( + static CompletedSharedTaskActivityState GetCompletedSharedTaskActivityState( const std::vector &completed_shared_task_activity_states, int completed_shared_task_activity_state_id ) @@ -128,15 +128,15 @@ public: auto row = results.begin(); if (results.RowCount() == 1) { - CompletedSharedTaskActivityState entry{}; + CompletedSharedTaskActivityState e{}; - entry.shared_task_id = strtoll(row[0], nullptr, 10); - entry.activity_id = atoi(row[1]); - entry.done_count = atoi(row[2]); - entry.updated_time = strtoll(row[3] ? row[3] : "-1", nullptr, 10); - entry.completed_time = strtoll(row[4] ? row[4] : "-1", nullptr, 10); + e.shared_task_id = strtoll(row[0], nullptr, 10); + e.activity_id = atoi(row[1]); + e.done_count = atoi(row[2]); + e.updated_time = strtoll(row[3] ? row[3] : "-1", nullptr, 10); + e.completed_time = strtoll(row[4] ? row[4] : "-1", nullptr, 10); - return entry; + return e; } return NewEntity(); @@ -161,26 +161,26 @@ public: static int UpdateOne( Database& db, - CompletedSharedTaskActivityState completed_shared_task_activity_state_entry + const CompletedSharedTaskActivityState &e ) { - std::vector update_values; + std::vector v; auto columns = Columns(); - update_values.push_back(columns[0] + " = " + std::to_string(completed_shared_task_activity_state_entry.shared_task_id)); - update_values.push_back(columns[1] + " = " + std::to_string(completed_shared_task_activity_state_entry.activity_id)); - update_values.push_back(columns[2] + " = " + std::to_string(completed_shared_task_activity_state_entry.done_count)); - update_values.push_back(columns[3] + " = FROM_UNIXTIME(" + (completed_shared_task_activity_state_entry.updated_time > 0 ? std::to_string(completed_shared_task_activity_state_entry.updated_time) : "null") + ")"); - update_values.push_back(columns[4] + " = FROM_UNIXTIME(" + (completed_shared_task_activity_state_entry.completed_time > 0 ? std::to_string(completed_shared_task_activity_state_entry.completed_time) : "null") + ")"); + v.push_back(columns[0] + " = " + std::to_string(e.shared_task_id)); + v.push_back(columns[1] + " = " + std::to_string(e.activity_id)); + v.push_back(columns[2] + " = " + std::to_string(e.done_count)); + v.push_back(columns[3] + " = FROM_UNIXTIME(" + (e.updated_time > 0 ? std::to_string(e.updated_time) : "null") + ")"); + v.push_back(columns[4] + " = FROM_UNIXTIME(" + (e.completed_time > 0 ? std::to_string(e.completed_time) : "null") + ")"); auto results = db.QueryDatabase( fmt::format( "UPDATE {} SET {} WHERE {} = {}", TableName(), - Strings::Implode(", ", update_values), + Strings::Implode(", ", v), PrimaryKey(), - completed_shared_task_activity_state_entry.shared_task_id + e.shared_task_id ) ); @@ -189,55 +189,55 @@ public: static CompletedSharedTaskActivityState InsertOne( Database& db, - CompletedSharedTaskActivityState completed_shared_task_activity_state_entry + CompletedSharedTaskActivityState e ) { - std::vector insert_values; + std::vector v; - insert_values.push_back(std::to_string(completed_shared_task_activity_state_entry.shared_task_id)); - insert_values.push_back(std::to_string(completed_shared_task_activity_state_entry.activity_id)); - insert_values.push_back(std::to_string(completed_shared_task_activity_state_entry.done_count)); - insert_values.push_back("FROM_UNIXTIME(" + (completed_shared_task_activity_state_entry.updated_time > 0 ? std::to_string(completed_shared_task_activity_state_entry.updated_time) : "null") + ")"); - insert_values.push_back("FROM_UNIXTIME(" + (completed_shared_task_activity_state_entry.completed_time > 0 ? std::to_string(completed_shared_task_activity_state_entry.completed_time) : "null") + ")"); + v.push_back(std::to_string(e.shared_task_id)); + v.push_back(std::to_string(e.activity_id)); + v.push_back(std::to_string(e.done_count)); + v.push_back("FROM_UNIXTIME(" + (e.updated_time > 0 ? std::to_string(e.updated_time) : "null") + ")"); + v.push_back("FROM_UNIXTIME(" + (e.completed_time > 0 ? std::to_string(e.completed_time) : "null") + ")"); auto results = db.QueryDatabase( fmt::format( "{} VALUES ({})", BaseInsert(), - Strings::Implode(",", insert_values) + Strings::Implode(",", v) ) ); if (results.Success()) { - completed_shared_task_activity_state_entry.shared_task_id = results.LastInsertedID(); - return completed_shared_task_activity_state_entry; + e.shared_task_id = results.LastInsertedID(); + return e; } - completed_shared_task_activity_state_entry = NewEntity(); + e = NewEntity(); - return completed_shared_task_activity_state_entry; + return e; } static int InsertMany( Database& db, - std::vector completed_shared_task_activity_state_entries + const std::vector &entries ) { std::vector insert_chunks; - for (auto &completed_shared_task_activity_state_entry: completed_shared_task_activity_state_entries) { - std::vector insert_values; + for (auto &e: entries) { + std::vector v; - insert_values.push_back(std::to_string(completed_shared_task_activity_state_entry.shared_task_id)); - insert_values.push_back(std::to_string(completed_shared_task_activity_state_entry.activity_id)); - insert_values.push_back(std::to_string(completed_shared_task_activity_state_entry.done_count)); - insert_values.push_back("FROM_UNIXTIME(" + (completed_shared_task_activity_state_entry.updated_time > 0 ? std::to_string(completed_shared_task_activity_state_entry.updated_time) : "null") + ")"); - insert_values.push_back("FROM_UNIXTIME(" + (completed_shared_task_activity_state_entry.completed_time > 0 ? std::to_string(completed_shared_task_activity_state_entry.completed_time) : "null") + ")"); + v.push_back(std::to_string(e.shared_task_id)); + v.push_back(std::to_string(e.activity_id)); + v.push_back(std::to_string(e.done_count)); + v.push_back("FROM_UNIXTIME(" + (e.updated_time > 0 ? std::to_string(e.updated_time) : "null") + ")"); + v.push_back("FROM_UNIXTIME(" + (e.completed_time > 0 ? std::to_string(e.completed_time) : "null") + ")"); - insert_chunks.push_back("(" + Strings::Implode(",", insert_values) + ")"); + insert_chunks.push_back("(" + Strings::Implode(",", v) + ")"); } - std::vector insert_values; + std::vector v; auto results = db.QueryDatabase( fmt::format( @@ -264,21 +264,21 @@ public: all_entries.reserve(results.RowCount()); for (auto row = results.begin(); row != results.end(); ++row) { - CompletedSharedTaskActivityState entry{}; + CompletedSharedTaskActivityState e{}; - entry.shared_task_id = strtoll(row[0], nullptr, 10); - entry.activity_id = atoi(row[1]); - entry.done_count = atoi(row[2]); - entry.updated_time = strtoll(row[3] ? row[3] : "-1", nullptr, 10); - entry.completed_time = strtoll(row[4] ? row[4] : "-1", nullptr, 10); + e.shared_task_id = strtoll(row[0], nullptr, 10); + e.activity_id = atoi(row[1]); + e.done_count = atoi(row[2]); + e.updated_time = strtoll(row[3] ? row[3] : "-1", nullptr, 10); + e.completed_time = strtoll(row[4] ? row[4] : "-1", nullptr, 10); - all_entries.push_back(entry); + all_entries.push_back(e); } return all_entries; } - static std::vector GetWhere(Database& db, std::string where_filter) + static std::vector GetWhere(Database& db, const std::string &where_filter) { std::vector all_entries; @@ -293,21 +293,21 @@ public: all_entries.reserve(results.RowCount()); for (auto row = results.begin(); row != results.end(); ++row) { - CompletedSharedTaskActivityState entry{}; + CompletedSharedTaskActivityState e{}; - entry.shared_task_id = strtoll(row[0], nullptr, 10); - entry.activity_id = atoi(row[1]); - entry.done_count = atoi(row[2]); - entry.updated_time = strtoll(row[3] ? row[3] : "-1", nullptr, 10); - entry.completed_time = strtoll(row[4] ? row[4] : "-1", nullptr, 10); + e.shared_task_id = strtoll(row[0], nullptr, 10); + e.activity_id = atoi(row[1]); + e.done_count = atoi(row[2]); + e.updated_time = strtoll(row[3] ? row[3] : "-1", nullptr, 10); + e.completed_time = strtoll(row[4] ? row[4] : "-1", nullptr, 10); - all_entries.push_back(entry); + all_entries.push_back(e); } return all_entries; } - static int DeleteWhere(Database& db, std::string where_filter) + static int DeleteWhere(Database& db, const std::string &where_filter) { auto results = db.QueryDatabase( fmt::format( @@ -332,6 +332,32 @@ public: 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); + } + }; #endif //EQEMU_BASE_COMPLETED_SHARED_TASK_ACTIVITY_STATE_REPOSITORY_H diff --git a/common/repositories/base/base_completed_shared_task_members_repository.h b/common/repositories/base/base_completed_shared_task_members_repository.h index 31a9d10f2..3054320c9 100644 --- a/common/repositories/base/base_completed_shared_task_members_repository.h +++ b/common/repositories/base/base_completed_shared_task_members_repository.h @@ -82,16 +82,16 @@ public: static CompletedSharedTaskMembers NewEntity() { - CompletedSharedTaskMembers entry{}; + CompletedSharedTaskMembers e{}; - entry.shared_task_id = 0; - entry.character_id = 0; - entry.is_leader = 0; + e.shared_task_id = 0; + e.character_id = 0; + e.is_leader = 0; - return entry; + return e; } - static CompletedSharedTaskMembers GetCompletedSharedTaskMembersEntry( + static CompletedSharedTaskMembers GetCompletedSharedTaskMembers( const std::vector &completed_shared_task_memberss, int completed_shared_task_members_id ) @@ -120,13 +120,13 @@ public: auto row = results.begin(); if (results.RowCount() == 1) { - CompletedSharedTaskMembers entry{}; + CompletedSharedTaskMembers e{}; - entry.shared_task_id = strtoll(row[0], nullptr, 10); - entry.character_id = strtoll(row[1], nullptr, 10); - entry.is_leader = atoi(row[2]); + e.shared_task_id = strtoll(row[0], nullptr, 10); + e.character_id = strtoll(row[1], nullptr, 10); + e.is_leader = atoi(row[2]); - return entry; + return e; } return NewEntity(); @@ -151,24 +151,24 @@ public: static int UpdateOne( Database& db, - CompletedSharedTaskMembers completed_shared_task_members_entry + const CompletedSharedTaskMembers &e ) { - std::vector update_values; + std::vector v; auto columns = Columns(); - update_values.push_back(columns[0] + " = " + std::to_string(completed_shared_task_members_entry.shared_task_id)); - update_values.push_back(columns[1] + " = " + std::to_string(completed_shared_task_members_entry.character_id)); - update_values.push_back(columns[2] + " = " + std::to_string(completed_shared_task_members_entry.is_leader)); + v.push_back(columns[0] + " = " + std::to_string(e.shared_task_id)); + v.push_back(columns[1] + " = " + std::to_string(e.character_id)); + v.push_back(columns[2] + " = " + std::to_string(e.is_leader)); auto results = db.QueryDatabase( fmt::format( "UPDATE {} SET {} WHERE {} = {}", TableName(), - Strings::Implode(", ", update_values), + Strings::Implode(", ", v), PrimaryKey(), - completed_shared_task_members_entry.shared_task_id + e.shared_task_id ) ); @@ -177,51 +177,51 @@ public: static CompletedSharedTaskMembers InsertOne( Database& db, - CompletedSharedTaskMembers completed_shared_task_members_entry + CompletedSharedTaskMembers e ) { - std::vector insert_values; + std::vector v; - insert_values.push_back(std::to_string(completed_shared_task_members_entry.shared_task_id)); - insert_values.push_back(std::to_string(completed_shared_task_members_entry.character_id)); - insert_values.push_back(std::to_string(completed_shared_task_members_entry.is_leader)); + v.push_back(std::to_string(e.shared_task_id)); + v.push_back(std::to_string(e.character_id)); + v.push_back(std::to_string(e.is_leader)); auto results = db.QueryDatabase( fmt::format( "{} VALUES ({})", BaseInsert(), - Strings::Implode(",", insert_values) + Strings::Implode(",", v) ) ); if (results.Success()) { - completed_shared_task_members_entry.shared_task_id = results.LastInsertedID(); - return completed_shared_task_members_entry; + e.shared_task_id = results.LastInsertedID(); + return e; } - completed_shared_task_members_entry = NewEntity(); + e = NewEntity(); - return completed_shared_task_members_entry; + return e; } static int InsertMany( Database& db, - std::vector completed_shared_task_members_entries + const std::vector &entries ) { std::vector insert_chunks; - for (auto &completed_shared_task_members_entry: completed_shared_task_members_entries) { - std::vector insert_values; + for (auto &e: entries) { + std::vector v; - insert_values.push_back(std::to_string(completed_shared_task_members_entry.shared_task_id)); - insert_values.push_back(std::to_string(completed_shared_task_members_entry.character_id)); - insert_values.push_back(std::to_string(completed_shared_task_members_entry.is_leader)); + v.push_back(std::to_string(e.shared_task_id)); + v.push_back(std::to_string(e.character_id)); + v.push_back(std::to_string(e.is_leader)); - insert_chunks.push_back("(" + Strings::Implode(",", insert_values) + ")"); + insert_chunks.push_back("(" + Strings::Implode(",", v) + ")"); } - std::vector insert_values; + std::vector v; auto results = db.QueryDatabase( fmt::format( @@ -248,19 +248,19 @@ public: all_entries.reserve(results.RowCount()); for (auto row = results.begin(); row != results.end(); ++row) { - CompletedSharedTaskMembers entry{}; + CompletedSharedTaskMembers e{}; - entry.shared_task_id = strtoll(row[0], nullptr, 10); - entry.character_id = strtoll(row[1], nullptr, 10); - entry.is_leader = atoi(row[2]); + e.shared_task_id = strtoll(row[0], nullptr, 10); + e.character_id = strtoll(row[1], nullptr, 10); + e.is_leader = atoi(row[2]); - all_entries.push_back(entry); + all_entries.push_back(e); } return all_entries; } - static std::vector GetWhere(Database& db, std::string where_filter) + static std::vector GetWhere(Database& db, const std::string &where_filter) { std::vector all_entries; @@ -275,19 +275,19 @@ public: all_entries.reserve(results.RowCount()); for (auto row = results.begin(); row != results.end(); ++row) { - CompletedSharedTaskMembers entry{}; + CompletedSharedTaskMembers e{}; - entry.shared_task_id = strtoll(row[0], nullptr, 10); - entry.character_id = strtoll(row[1], nullptr, 10); - entry.is_leader = atoi(row[2]); + e.shared_task_id = strtoll(row[0], nullptr, 10); + e.character_id = strtoll(row[1], nullptr, 10); + e.is_leader = atoi(row[2]); - all_entries.push_back(entry); + all_entries.push_back(e); } return all_entries; } - static int DeleteWhere(Database& db, std::string where_filter) + static int DeleteWhere(Database& db, const std::string &where_filter) { auto results = db.QueryDatabase( fmt::format( @@ -312,6 +312,32 @@ public: 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); + } + }; #endif //EQEMU_BASE_COMPLETED_SHARED_TASK_MEMBERS_REPOSITORY_H diff --git a/common/repositories/base/base_completed_shared_tasks_repository.h b/common/repositories/base/base_completed_shared_tasks_repository.h index eaa98328e..594ff61dd 100644 --- a/common/repositories/base/base_completed_shared_tasks_repository.h +++ b/common/repositories/base/base_completed_shared_tasks_repository.h @@ -91,19 +91,19 @@ public: static CompletedSharedTasks NewEntity() { - CompletedSharedTasks entry{}; + CompletedSharedTasks e{}; - entry.id = 0; - entry.task_id = 0; - entry.accepted_time = 0; - entry.expire_time = 0; - entry.completion_time = 0; - entry.is_locked = 0; + e.id = 0; + e.task_id = 0; + e.accepted_time = 0; + e.expire_time = 0; + e.completion_time = 0; + e.is_locked = 0; - return entry; + return e; } - static CompletedSharedTasks GetCompletedSharedTasksEntry( + static CompletedSharedTasks GetCompletedSharedTasks( const std::vector &completed_shared_taskss, int completed_shared_tasks_id ) @@ -132,16 +132,16 @@ public: auto row = results.begin(); if (results.RowCount() == 1) { - CompletedSharedTasks entry{}; + CompletedSharedTasks e{}; - entry.id = strtoll(row[0], nullptr, 10); - entry.task_id = atoi(row[1]); - entry.accepted_time = strtoll(row[2] ? row[2] : "-1", nullptr, 10); - entry.expire_time = strtoll(row[3] ? row[3] : "-1", nullptr, 10); - entry.completion_time = strtoll(row[4] ? row[4] : "-1", nullptr, 10); - entry.is_locked = atoi(row[5]); + e.id = strtoll(row[0], nullptr, 10); + e.task_id = atoi(row[1]); + e.accepted_time = strtoll(row[2] ? row[2] : "-1", nullptr, 10); + e.expire_time = strtoll(row[3] ? row[3] : "-1", nullptr, 10); + e.completion_time = strtoll(row[4] ? row[4] : "-1", nullptr, 10); + e.is_locked = atoi(row[5]); - return entry; + return e; } return NewEntity(); @@ -166,27 +166,27 @@ public: static int UpdateOne( Database& db, - CompletedSharedTasks completed_shared_tasks_entry + const CompletedSharedTasks &e ) { - std::vector update_values; + std::vector v; auto columns = Columns(); - update_values.push_back(columns[0] + " = " + std::to_string(completed_shared_tasks_entry.id)); - update_values.push_back(columns[1] + " = " + std::to_string(completed_shared_tasks_entry.task_id)); - update_values.push_back(columns[2] + " = FROM_UNIXTIME(" + (completed_shared_tasks_entry.accepted_time > 0 ? std::to_string(completed_shared_tasks_entry.accepted_time) : "null") + ")"); - update_values.push_back(columns[3] + " = FROM_UNIXTIME(" + (completed_shared_tasks_entry.expire_time > 0 ? std::to_string(completed_shared_tasks_entry.expire_time) : "null") + ")"); - update_values.push_back(columns[4] + " = FROM_UNIXTIME(" + (completed_shared_tasks_entry.completion_time > 0 ? std::to_string(completed_shared_tasks_entry.completion_time) : "null") + ")"); - update_values.push_back(columns[5] + " = " + std::to_string(completed_shared_tasks_entry.is_locked)); + v.push_back(columns[0] + " = " + std::to_string(e.id)); + v.push_back(columns[1] + " = " + std::to_string(e.task_id)); + v.push_back(columns[2] + " = FROM_UNIXTIME(" + (e.accepted_time > 0 ? std::to_string(e.accepted_time) : "null") + ")"); + v.push_back(columns[3] + " = FROM_UNIXTIME(" + (e.expire_time > 0 ? std::to_string(e.expire_time) : "null") + ")"); + v.push_back(columns[4] + " = FROM_UNIXTIME(" + (e.completion_time > 0 ? std::to_string(e.completion_time) : "null") + ")"); + v.push_back(columns[5] + " = " + std::to_string(e.is_locked)); auto results = db.QueryDatabase( fmt::format( "UPDATE {} SET {} WHERE {} = {}", TableName(), - Strings::Implode(", ", update_values), + Strings::Implode(", ", v), PrimaryKey(), - completed_shared_tasks_entry.id + e.id ) ); @@ -195,57 +195,57 @@ public: static CompletedSharedTasks InsertOne( Database& db, - CompletedSharedTasks completed_shared_tasks_entry + CompletedSharedTasks e ) { - std::vector insert_values; + std::vector v; - insert_values.push_back(std::to_string(completed_shared_tasks_entry.id)); - insert_values.push_back(std::to_string(completed_shared_tasks_entry.task_id)); - insert_values.push_back("FROM_UNIXTIME(" + (completed_shared_tasks_entry.accepted_time > 0 ? std::to_string(completed_shared_tasks_entry.accepted_time) : "null") + ")"); - insert_values.push_back("FROM_UNIXTIME(" + (completed_shared_tasks_entry.expire_time > 0 ? std::to_string(completed_shared_tasks_entry.expire_time) : "null") + ")"); - insert_values.push_back("FROM_UNIXTIME(" + (completed_shared_tasks_entry.completion_time > 0 ? std::to_string(completed_shared_tasks_entry.completion_time) : "null") + ")"); - insert_values.push_back(std::to_string(completed_shared_tasks_entry.is_locked)); + v.push_back(std::to_string(e.id)); + v.push_back(std::to_string(e.task_id)); + v.push_back("FROM_UNIXTIME(" + (e.accepted_time > 0 ? std::to_string(e.accepted_time) : "null") + ")"); + v.push_back("FROM_UNIXTIME(" + (e.expire_time > 0 ? std::to_string(e.expire_time) : "null") + ")"); + v.push_back("FROM_UNIXTIME(" + (e.completion_time > 0 ? std::to_string(e.completion_time) : "null") + ")"); + v.push_back(std::to_string(e.is_locked)); auto results = db.QueryDatabase( fmt::format( "{} VALUES ({})", BaseInsert(), - Strings::Implode(",", insert_values) + Strings::Implode(",", v) ) ); if (results.Success()) { - completed_shared_tasks_entry.id = results.LastInsertedID(); - return completed_shared_tasks_entry; + e.id = results.LastInsertedID(); + return e; } - completed_shared_tasks_entry = NewEntity(); + e = NewEntity(); - return completed_shared_tasks_entry; + return e; } static int InsertMany( Database& db, - std::vector completed_shared_tasks_entries + const std::vector &entries ) { std::vector insert_chunks; - for (auto &completed_shared_tasks_entry: completed_shared_tasks_entries) { - std::vector insert_values; + for (auto &e: entries) { + std::vector v; - insert_values.push_back(std::to_string(completed_shared_tasks_entry.id)); - insert_values.push_back(std::to_string(completed_shared_tasks_entry.task_id)); - insert_values.push_back("FROM_UNIXTIME(" + (completed_shared_tasks_entry.accepted_time > 0 ? std::to_string(completed_shared_tasks_entry.accepted_time) : "null") + ")"); - insert_values.push_back("FROM_UNIXTIME(" + (completed_shared_tasks_entry.expire_time > 0 ? std::to_string(completed_shared_tasks_entry.expire_time) : "null") + ")"); - insert_values.push_back("FROM_UNIXTIME(" + (completed_shared_tasks_entry.completion_time > 0 ? std::to_string(completed_shared_tasks_entry.completion_time) : "null") + ")"); - insert_values.push_back(std::to_string(completed_shared_tasks_entry.is_locked)); + v.push_back(std::to_string(e.id)); + v.push_back(std::to_string(e.task_id)); + v.push_back("FROM_UNIXTIME(" + (e.accepted_time > 0 ? std::to_string(e.accepted_time) : "null") + ")"); + v.push_back("FROM_UNIXTIME(" + (e.expire_time > 0 ? std::to_string(e.expire_time) : "null") + ")"); + v.push_back("FROM_UNIXTIME(" + (e.completion_time > 0 ? std::to_string(e.completion_time) : "null") + ")"); + v.push_back(std::to_string(e.is_locked)); - insert_chunks.push_back("(" + Strings::Implode(",", insert_values) + ")"); + insert_chunks.push_back("(" + Strings::Implode(",", v) + ")"); } - std::vector insert_values; + std::vector v; auto results = db.QueryDatabase( fmt::format( @@ -272,22 +272,22 @@ public: all_entries.reserve(results.RowCount()); for (auto row = results.begin(); row != results.end(); ++row) { - CompletedSharedTasks entry{}; + CompletedSharedTasks e{}; - entry.id = strtoll(row[0], nullptr, 10); - entry.task_id = atoi(row[1]); - entry.accepted_time = strtoll(row[2] ? row[2] : "-1", nullptr, 10); - entry.expire_time = strtoll(row[3] ? row[3] : "-1", nullptr, 10); - entry.completion_time = strtoll(row[4] ? row[4] : "-1", nullptr, 10); - entry.is_locked = atoi(row[5]); + e.id = strtoll(row[0], nullptr, 10); + e.task_id = atoi(row[1]); + e.accepted_time = strtoll(row[2] ? row[2] : "-1", nullptr, 10); + e.expire_time = strtoll(row[3] ? row[3] : "-1", nullptr, 10); + e.completion_time = strtoll(row[4] ? row[4] : "-1", nullptr, 10); + e.is_locked = atoi(row[5]); - all_entries.push_back(entry); + all_entries.push_back(e); } return all_entries; } - static std::vector GetWhere(Database& db, std::string where_filter) + static std::vector GetWhere(Database& db, const std::string &where_filter) { std::vector all_entries; @@ -302,22 +302,22 @@ public: all_entries.reserve(results.RowCount()); for (auto row = results.begin(); row != results.end(); ++row) { - CompletedSharedTasks entry{}; + CompletedSharedTasks e{}; - entry.id = strtoll(row[0], nullptr, 10); - entry.task_id = atoi(row[1]); - entry.accepted_time = strtoll(row[2] ? row[2] : "-1", nullptr, 10); - entry.expire_time = strtoll(row[3] ? row[3] : "-1", nullptr, 10); - entry.completion_time = strtoll(row[4] ? row[4] : "-1", nullptr, 10); - entry.is_locked = atoi(row[5]); + e.id = strtoll(row[0], nullptr, 10); + e.task_id = atoi(row[1]); + e.accepted_time = strtoll(row[2] ? row[2] : "-1", nullptr, 10); + e.expire_time = strtoll(row[3] ? row[3] : "-1", nullptr, 10); + e.completion_time = strtoll(row[4] ? row[4] : "-1", nullptr, 10); + e.is_locked = atoi(row[5]); - all_entries.push_back(entry); + all_entries.push_back(e); } return all_entries; } - static int DeleteWhere(Database& db, std::string where_filter) + static int DeleteWhere(Database& db, const std::string &where_filter) { auto results = db.QueryDatabase( fmt::format( @@ -342,6 +342,32 @@ public: 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); + } + }; #endif //EQEMU_BASE_COMPLETED_SHARED_TASKS_REPOSITORY_H diff --git a/common/repositories/base/base_completed_tasks_repository.h b/common/repositories/base/base_completed_tasks_repository.h index a5f5856e9..805e1a45e 100644 --- a/common/repositories/base/base_completed_tasks_repository.h +++ b/common/repositories/base/base_completed_tasks_repository.h @@ -85,17 +85,17 @@ public: static CompletedTasks NewEntity() { - CompletedTasks entry{}; + CompletedTasks e{}; - entry.charid = 0; - entry.completedtime = 0; - entry.taskid = 0; - entry.activityid = 0; + e.charid = 0; + e.completedtime = 0; + e.taskid = 0; + e.activityid = 0; - return entry; + return e; } - static CompletedTasks GetCompletedTasksEntry( + static CompletedTasks GetCompletedTasks( const std::vector &completed_taskss, int completed_tasks_id ) @@ -124,14 +124,14 @@ public: auto row = results.begin(); if (results.RowCount() == 1) { - CompletedTasks entry{}; + CompletedTasks e{}; - entry.charid = atoi(row[0]); - entry.completedtime = atoi(row[1]); - entry.taskid = atoi(row[2]); - entry.activityid = atoi(row[3]); + e.charid = atoi(row[0]); + e.completedtime = atoi(row[1]); + e.taskid = atoi(row[2]); + e.activityid = atoi(row[3]); - return entry; + return e; } return NewEntity(); @@ -156,25 +156,25 @@ public: static int UpdateOne( Database& db, - CompletedTasks completed_tasks_entry + const CompletedTasks &e ) { - std::vector update_values; + std::vector v; auto columns = Columns(); - update_values.push_back(columns[0] + " = " + std::to_string(completed_tasks_entry.charid)); - update_values.push_back(columns[1] + " = " + std::to_string(completed_tasks_entry.completedtime)); - update_values.push_back(columns[2] + " = " + std::to_string(completed_tasks_entry.taskid)); - update_values.push_back(columns[3] + " = " + std::to_string(completed_tasks_entry.activityid)); + v.push_back(columns[0] + " = " + std::to_string(e.charid)); + v.push_back(columns[1] + " = " + std::to_string(e.completedtime)); + v.push_back(columns[2] + " = " + std::to_string(e.taskid)); + v.push_back(columns[3] + " = " + std::to_string(e.activityid)); auto results = db.QueryDatabase( fmt::format( "UPDATE {} SET {} WHERE {} = {}", TableName(), - Strings::Implode(", ", update_values), + Strings::Implode(", ", v), PrimaryKey(), - completed_tasks_entry.charid + e.charid ) ); @@ -183,53 +183,53 @@ public: static CompletedTasks InsertOne( Database& db, - CompletedTasks completed_tasks_entry + CompletedTasks e ) { - std::vector insert_values; + std::vector v; - insert_values.push_back(std::to_string(completed_tasks_entry.charid)); - insert_values.push_back(std::to_string(completed_tasks_entry.completedtime)); - insert_values.push_back(std::to_string(completed_tasks_entry.taskid)); - insert_values.push_back(std::to_string(completed_tasks_entry.activityid)); + v.push_back(std::to_string(e.charid)); + v.push_back(std::to_string(e.completedtime)); + v.push_back(std::to_string(e.taskid)); + v.push_back(std::to_string(e.activityid)); auto results = db.QueryDatabase( fmt::format( "{} VALUES ({})", BaseInsert(), - Strings::Implode(",", insert_values) + Strings::Implode(",", v) ) ); if (results.Success()) { - completed_tasks_entry.charid = results.LastInsertedID(); - return completed_tasks_entry; + e.charid = results.LastInsertedID(); + return e; } - completed_tasks_entry = NewEntity(); + e = NewEntity(); - return completed_tasks_entry; + return e; } static int InsertMany( Database& db, - std::vector completed_tasks_entries + const std::vector &entries ) { std::vector insert_chunks; - for (auto &completed_tasks_entry: completed_tasks_entries) { - std::vector insert_values; + for (auto &e: entries) { + std::vector v; - insert_values.push_back(std::to_string(completed_tasks_entry.charid)); - insert_values.push_back(std::to_string(completed_tasks_entry.completedtime)); - insert_values.push_back(std::to_string(completed_tasks_entry.taskid)); - insert_values.push_back(std::to_string(completed_tasks_entry.activityid)); + v.push_back(std::to_string(e.charid)); + v.push_back(std::to_string(e.completedtime)); + v.push_back(std::to_string(e.taskid)); + v.push_back(std::to_string(e.activityid)); - insert_chunks.push_back("(" + Strings::Implode(",", insert_values) + ")"); + insert_chunks.push_back("(" + Strings::Implode(",", v) + ")"); } - std::vector insert_values; + std::vector v; auto results = db.QueryDatabase( fmt::format( @@ -256,20 +256,20 @@ public: all_entries.reserve(results.RowCount()); for (auto row = results.begin(); row != results.end(); ++row) { - CompletedTasks entry{}; + CompletedTasks e{}; - entry.charid = atoi(row[0]); - entry.completedtime = atoi(row[1]); - entry.taskid = atoi(row[2]); - entry.activityid = atoi(row[3]); + e.charid = atoi(row[0]); + e.completedtime = atoi(row[1]); + e.taskid = atoi(row[2]); + e.activityid = atoi(row[3]); - all_entries.push_back(entry); + all_entries.push_back(e); } return all_entries; } - static std::vector GetWhere(Database& db, std::string where_filter) + static std::vector GetWhere(Database& db, const std::string &where_filter) { std::vector all_entries; @@ -284,20 +284,20 @@ public: all_entries.reserve(results.RowCount()); for (auto row = results.begin(); row != results.end(); ++row) { - CompletedTasks entry{}; + CompletedTasks e{}; - entry.charid = atoi(row[0]); - entry.completedtime = atoi(row[1]); - entry.taskid = atoi(row[2]); - entry.activityid = atoi(row[3]); + e.charid = atoi(row[0]); + e.completedtime = atoi(row[1]); + e.taskid = atoi(row[2]); + e.activityid = atoi(row[3]); - all_entries.push_back(entry); + all_entries.push_back(e); } return all_entries; } - static int DeleteWhere(Database& db, std::string where_filter) + static int DeleteWhere(Database& db, const std::string &where_filter) { auto results = db.QueryDatabase( fmt::format( @@ -322,6 +322,32 @@ public: 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); + } + }; #endif //EQEMU_BASE_COMPLETED_TASKS_REPOSITORY_H diff --git a/common/repositories/base/base_content_flags_repository.h b/common/repositories/base/base_content_flags_repository.h index eebe55172..a567a3833 100644 --- a/common/repositories/base/base_content_flags_repository.h +++ b/common/repositories/base/base_content_flags_repository.h @@ -85,17 +85,17 @@ public: static ContentFlags NewEntity() { - ContentFlags entry{}; + ContentFlags e{}; - entry.id = 0; - entry.flag_name = ""; - entry.enabled = 0; - entry.notes = ""; + e.id = 0; + e.flag_name = ""; + e.enabled = 0; + e.notes = ""; - return entry; + return e; } - static ContentFlags GetContentFlagsEntry( + static ContentFlags GetContentFlags( const std::vector &content_flagss, int content_flags_id ) @@ -124,14 +124,14 @@ public: auto row = results.begin(); if (results.RowCount() == 1) { - ContentFlags entry{}; + ContentFlags e{}; - entry.id = atoi(row[0]); - entry.flag_name = row[1] ? row[1] : ""; - entry.enabled = atoi(row[2]); - entry.notes = row[3] ? row[3] : ""; + e.id = atoi(row[0]); + e.flag_name = row[1] ? row[1] : ""; + e.enabled = atoi(row[2]); + e.notes = row[3] ? row[3] : ""; - return entry; + return e; } return NewEntity(); @@ -156,24 +156,24 @@ public: static int UpdateOne( Database& db, - ContentFlags content_flags_entry + const ContentFlags &e ) { - std::vector update_values; + std::vector v; auto columns = Columns(); - update_values.push_back(columns[1] + " = '" + Strings::Escape(content_flags_entry.flag_name) + "'"); - update_values.push_back(columns[2] + " = " + std::to_string(content_flags_entry.enabled)); - update_values.push_back(columns[3] + " = '" + Strings::Escape(content_flags_entry.notes) + "'"); + v.push_back(columns[1] + " = '" + Strings::Escape(e.flag_name) + "'"); + v.push_back(columns[2] + " = " + std::to_string(e.enabled)); + v.push_back(columns[3] + " = '" + Strings::Escape(e.notes) + "'"); auto results = db.QueryDatabase( fmt::format( "UPDATE {} SET {} WHERE {} = {}", TableName(), - Strings::Implode(", ", update_values), + Strings::Implode(", ", v), PrimaryKey(), - content_flags_entry.id + e.id ) ); @@ -182,53 +182,53 @@ public: static ContentFlags InsertOne( Database& db, - ContentFlags content_flags_entry + ContentFlags e ) { - std::vector insert_values; + std::vector v; - insert_values.push_back(std::to_string(content_flags_entry.id)); - insert_values.push_back("'" + Strings::Escape(content_flags_entry.flag_name) + "'"); - insert_values.push_back(std::to_string(content_flags_entry.enabled)); - insert_values.push_back("'" + Strings::Escape(content_flags_entry.notes) + "'"); + v.push_back(std::to_string(e.id)); + v.push_back("'" + Strings::Escape(e.flag_name) + "'"); + v.push_back(std::to_string(e.enabled)); + v.push_back("'" + Strings::Escape(e.notes) + "'"); auto results = db.QueryDatabase( fmt::format( "{} VALUES ({})", BaseInsert(), - Strings::Implode(",", insert_values) + Strings::Implode(",", v) ) ); if (results.Success()) { - content_flags_entry.id = results.LastInsertedID(); - return content_flags_entry; + e.id = results.LastInsertedID(); + return e; } - content_flags_entry = NewEntity(); + e = NewEntity(); - return content_flags_entry; + return e; } static int InsertMany( Database& db, - std::vector content_flags_entries + const std::vector &entries ) { std::vector insert_chunks; - for (auto &content_flags_entry: content_flags_entries) { - std::vector insert_values; + for (auto &e: entries) { + std::vector v; - insert_values.push_back(std::to_string(content_flags_entry.id)); - insert_values.push_back("'" + Strings::Escape(content_flags_entry.flag_name) + "'"); - insert_values.push_back(std::to_string(content_flags_entry.enabled)); - insert_values.push_back("'" + Strings::Escape(content_flags_entry.notes) + "'"); + v.push_back(std::to_string(e.id)); + v.push_back("'" + Strings::Escape(e.flag_name) + "'"); + v.push_back(std::to_string(e.enabled)); + v.push_back("'" + Strings::Escape(e.notes) + "'"); - insert_chunks.push_back("(" + Strings::Implode(",", insert_values) + ")"); + insert_chunks.push_back("(" + Strings::Implode(",", v) + ")"); } - std::vector insert_values; + std::vector v; auto results = db.QueryDatabase( fmt::format( @@ -255,20 +255,20 @@ public: all_entries.reserve(results.RowCount()); for (auto row = results.begin(); row != results.end(); ++row) { - ContentFlags entry{}; + ContentFlags e{}; - entry.id = atoi(row[0]); - entry.flag_name = row[1] ? row[1] : ""; - entry.enabled = atoi(row[2]); - entry.notes = row[3] ? row[3] : ""; + e.id = atoi(row[0]); + e.flag_name = row[1] ? row[1] : ""; + e.enabled = atoi(row[2]); + e.notes = row[3] ? row[3] : ""; - all_entries.push_back(entry); + all_entries.push_back(e); } return all_entries; } - static std::vector GetWhere(Database& db, std::string where_filter) + static std::vector GetWhere(Database& db, const std::string &where_filter) { std::vector all_entries; @@ -283,20 +283,20 @@ public: all_entries.reserve(results.RowCount()); for (auto row = results.begin(); row != results.end(); ++row) { - ContentFlags entry{}; + ContentFlags e{}; - entry.id = atoi(row[0]); - entry.flag_name = row[1] ? row[1] : ""; - entry.enabled = atoi(row[2]); - entry.notes = row[3] ? row[3] : ""; + e.id = atoi(row[0]); + e.flag_name = row[1] ? row[1] : ""; + e.enabled = atoi(row[2]); + e.notes = row[3] ? row[3] : ""; - all_entries.push_back(entry); + all_entries.push_back(e); } return all_entries; } - static int DeleteWhere(Database& db, std::string where_filter) + static int DeleteWhere(Database& db, const std::string &where_filter) { auto results = db.QueryDatabase( fmt::format( @@ -321,6 +321,32 @@ public: 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); + } + }; #endif //EQEMU_BASE_CONTENT_FLAGS_REPOSITORY_H diff --git a/common/repositories/base/base_damageshieldtypes_repository.h b/common/repositories/base/base_damageshieldtypes_repository.h index 064ac61f4..4de879b69 100644 --- a/common/repositories/base/base_damageshieldtypes_repository.h +++ b/common/repositories/base/base_damageshieldtypes_repository.h @@ -79,15 +79,15 @@ public: static Damageshieldtypes NewEntity() { - Damageshieldtypes entry{}; + Damageshieldtypes e{}; - entry.spellid = 0; - entry.type = 0; + e.spellid = 0; + e.type = 0; - return entry; + return e; } - static Damageshieldtypes GetDamageshieldtypesEntry( + static Damageshieldtypes GetDamageshieldtypes( const std::vector &damageshieldtypess, int damageshieldtypes_id ) @@ -116,12 +116,12 @@ public: auto row = results.begin(); if (results.RowCount() == 1) { - Damageshieldtypes entry{}; + Damageshieldtypes e{}; - entry.spellid = atoi(row[0]); - entry.type = atoi(row[1]); + e.spellid = atoi(row[0]); + e.type = atoi(row[1]); - return entry; + return e; } return NewEntity(); @@ -146,23 +146,23 @@ public: static int UpdateOne( Database& db, - Damageshieldtypes damageshieldtypes_entry + const Damageshieldtypes &e ) { - std::vector update_values; + std::vector v; auto columns = Columns(); - update_values.push_back(columns[0] + " = " + std::to_string(damageshieldtypes_entry.spellid)); - update_values.push_back(columns[1] + " = " + std::to_string(damageshieldtypes_entry.type)); + v.push_back(columns[0] + " = " + std::to_string(e.spellid)); + v.push_back(columns[1] + " = " + std::to_string(e.type)); auto results = db.QueryDatabase( fmt::format( "UPDATE {} SET {} WHERE {} = {}", TableName(), - Strings::Implode(", ", update_values), + Strings::Implode(", ", v), PrimaryKey(), - damageshieldtypes_entry.spellid + e.spellid ) ); @@ -171,49 +171,49 @@ public: static Damageshieldtypes InsertOne( Database& db, - Damageshieldtypes damageshieldtypes_entry + Damageshieldtypes e ) { - std::vector insert_values; + std::vector v; - insert_values.push_back(std::to_string(damageshieldtypes_entry.spellid)); - insert_values.push_back(std::to_string(damageshieldtypes_entry.type)); + v.push_back(std::to_string(e.spellid)); + v.push_back(std::to_string(e.type)); auto results = db.QueryDatabase( fmt::format( "{} VALUES ({})", BaseInsert(), - Strings::Implode(",", insert_values) + Strings::Implode(",", v) ) ); if (results.Success()) { - damageshieldtypes_entry.spellid = results.LastInsertedID(); - return damageshieldtypes_entry; + e.spellid = results.LastInsertedID(); + return e; } - damageshieldtypes_entry = NewEntity(); + e = NewEntity(); - return damageshieldtypes_entry; + return e; } static int InsertMany( Database& db, - std::vector damageshieldtypes_entries + const std::vector &entries ) { std::vector insert_chunks; - for (auto &damageshieldtypes_entry: damageshieldtypes_entries) { - std::vector insert_values; + for (auto &e: entries) { + std::vector v; - insert_values.push_back(std::to_string(damageshieldtypes_entry.spellid)); - insert_values.push_back(std::to_string(damageshieldtypes_entry.type)); + v.push_back(std::to_string(e.spellid)); + v.push_back(std::to_string(e.type)); - insert_chunks.push_back("(" + Strings::Implode(",", insert_values) + ")"); + insert_chunks.push_back("(" + Strings::Implode(",", v) + ")"); } - std::vector insert_values; + std::vector v; auto results = db.QueryDatabase( fmt::format( @@ -240,18 +240,18 @@ public: all_entries.reserve(results.RowCount()); for (auto row = results.begin(); row != results.end(); ++row) { - Damageshieldtypes entry{}; + Damageshieldtypes e{}; - entry.spellid = atoi(row[0]); - entry.type = atoi(row[1]); + e.spellid = atoi(row[0]); + e.type = atoi(row[1]); - all_entries.push_back(entry); + all_entries.push_back(e); } return all_entries; } - static std::vector GetWhere(Database& db, std::string where_filter) + static std::vector GetWhere(Database& db, const std::string &where_filter) { std::vector all_entries; @@ -266,18 +266,18 @@ public: all_entries.reserve(results.RowCount()); for (auto row = results.begin(); row != results.end(); ++row) { - Damageshieldtypes entry{}; + Damageshieldtypes e{}; - entry.spellid = atoi(row[0]); - entry.type = atoi(row[1]); + e.spellid = atoi(row[0]); + e.type = atoi(row[1]); - all_entries.push_back(entry); + all_entries.push_back(e); } return all_entries; } - static int DeleteWhere(Database& db, std::string where_filter) + static int DeleteWhere(Database& db, const std::string &where_filter) { auto results = db.QueryDatabase( fmt::format( @@ -302,6 +302,32 @@ public: 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); + } + }; #endif //EQEMU_BASE_DAMAGESHIELDTYPES_REPOSITORY_H diff --git a/common/repositories/base/base_data_buckets_repository.h b/common/repositories/base/base_data_buckets_repository.h index f6314899e..c2cb95512 100644 --- a/common/repositories/base/base_data_buckets_repository.h +++ b/common/repositories/base/base_data_buckets_repository.h @@ -85,17 +85,17 @@ public: static DataBuckets NewEntity() { - DataBuckets entry{}; + DataBuckets e{}; - entry.id = 0; - entry.key = ""; - entry.value = ""; - entry.expires = 0; + e.id = 0; + e.key = ""; + e.value = ""; + e.expires = 0; - return entry; + return e; } - static DataBuckets GetDataBucketsEntry( + static DataBuckets GetDataBuckets( const std::vector &data_bucketss, int data_buckets_id ) @@ -124,14 +124,14 @@ public: auto row = results.begin(); if (results.RowCount() == 1) { - DataBuckets entry{}; + DataBuckets e{}; - entry.id = strtoll(row[0], nullptr, 10); - entry.key = row[1] ? row[1] : ""; - entry.value = row[2] ? row[2] : ""; - entry.expires = atoi(row[3]); + e.id = strtoll(row[0], nullptr, 10); + e.key = row[1] ? row[1] : ""; + e.value = row[2] ? row[2] : ""; + e.expires = atoi(row[3]); - return entry; + return e; } return NewEntity(); @@ -156,24 +156,24 @@ public: static int UpdateOne( Database& db, - DataBuckets data_buckets_entry + const DataBuckets &e ) { - std::vector update_values; + std::vector v; auto columns = Columns(); - update_values.push_back(columns[1] + " = '" + Strings::Escape(data_buckets_entry.key) + "'"); - update_values.push_back(columns[2] + " = '" + Strings::Escape(data_buckets_entry.value) + "'"); - update_values.push_back(columns[3] + " = " + std::to_string(data_buckets_entry.expires)); + v.push_back(columns[1] + " = '" + Strings::Escape(e.key) + "'"); + v.push_back(columns[2] + " = '" + Strings::Escape(e.value) + "'"); + v.push_back(columns[3] + " = " + std::to_string(e.expires)); auto results = db.QueryDatabase( fmt::format( "UPDATE {} SET {} WHERE {} = {}", TableName(), - Strings::Implode(", ", update_values), + Strings::Implode(", ", v), PrimaryKey(), - data_buckets_entry.id + e.id ) ); @@ -182,53 +182,53 @@ public: static DataBuckets InsertOne( Database& db, - DataBuckets data_buckets_entry + DataBuckets e ) { - std::vector insert_values; + std::vector v; - insert_values.push_back(std::to_string(data_buckets_entry.id)); - insert_values.push_back("'" + Strings::Escape(data_buckets_entry.key) + "'"); - insert_values.push_back("'" + Strings::Escape(data_buckets_entry.value) + "'"); - insert_values.push_back(std::to_string(data_buckets_entry.expires)); + v.push_back(std::to_string(e.id)); + v.push_back("'" + Strings::Escape(e.key) + "'"); + v.push_back("'" + Strings::Escape(e.value) + "'"); + v.push_back(std::to_string(e.expires)); auto results = db.QueryDatabase( fmt::format( "{} VALUES ({})", BaseInsert(), - Strings::Implode(",", insert_values) + Strings::Implode(",", v) ) ); if (results.Success()) { - data_buckets_entry.id = results.LastInsertedID(); - return data_buckets_entry; + e.id = results.LastInsertedID(); + return e; } - data_buckets_entry = NewEntity(); + e = NewEntity(); - return data_buckets_entry; + return e; } static int InsertMany( Database& db, - std::vector data_buckets_entries + const std::vector &entries ) { std::vector insert_chunks; - for (auto &data_buckets_entry: data_buckets_entries) { - std::vector insert_values; + for (auto &e: entries) { + std::vector v; - insert_values.push_back(std::to_string(data_buckets_entry.id)); - insert_values.push_back("'" + Strings::Escape(data_buckets_entry.key) + "'"); - insert_values.push_back("'" + Strings::Escape(data_buckets_entry.value) + "'"); - insert_values.push_back(std::to_string(data_buckets_entry.expires)); + v.push_back(std::to_string(e.id)); + v.push_back("'" + Strings::Escape(e.key) + "'"); + v.push_back("'" + Strings::Escape(e.value) + "'"); + v.push_back(std::to_string(e.expires)); - insert_chunks.push_back("(" + Strings::Implode(",", insert_values) + ")"); + insert_chunks.push_back("(" + Strings::Implode(",", v) + ")"); } - std::vector insert_values; + std::vector v; auto results = db.QueryDatabase( fmt::format( @@ -255,20 +255,20 @@ public: all_entries.reserve(results.RowCount()); for (auto row = results.begin(); row != results.end(); ++row) { - DataBuckets entry{}; + DataBuckets e{}; - entry.id = strtoll(row[0], nullptr, 10); - entry.key = row[1] ? row[1] : ""; - entry.value = row[2] ? row[2] : ""; - entry.expires = atoi(row[3]); + e.id = strtoll(row[0], nullptr, 10); + e.key = row[1] ? row[1] : ""; + e.value = row[2] ? row[2] : ""; + e.expires = atoi(row[3]); - all_entries.push_back(entry); + all_entries.push_back(e); } return all_entries; } - static std::vector GetWhere(Database& db, std::string where_filter) + static std::vector GetWhere(Database& db, const std::string &where_filter) { std::vector all_entries; @@ -283,20 +283,20 @@ public: all_entries.reserve(results.RowCount()); for (auto row = results.begin(); row != results.end(); ++row) { - DataBuckets entry{}; + DataBuckets e{}; - entry.id = strtoll(row[0], nullptr, 10); - entry.key = row[1] ? row[1] : ""; - entry.value = row[2] ? row[2] : ""; - entry.expires = atoi(row[3]); + e.id = strtoll(row[0], nullptr, 10); + e.key = row[1] ? row[1] : ""; + e.value = row[2] ? row[2] : ""; + e.expires = atoi(row[3]); - all_entries.push_back(entry); + all_entries.push_back(e); } return all_entries; } - static int DeleteWhere(Database& db, std::string where_filter) + static int DeleteWhere(Database& db, const std::string &where_filter) { auto results = db.QueryDatabase( fmt::format( @@ -321,6 +321,32 @@ public: 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); + } + }; #endif //EQEMU_BASE_DATA_BUCKETS_REPOSITORY_H diff --git a/common/repositories/base/base_db_str_repository.h b/common/repositories/base/base_db_str_repository.h index bc0f5d551..5e3b9a39d 100644 --- a/common/repositories/base/base_db_str_repository.h +++ b/common/repositories/base/base_db_str_repository.h @@ -82,16 +82,16 @@ public: static DbStr NewEntity() { - DbStr entry{}; + DbStr e{}; - entry.id = 0; - entry.type = 0; - entry.value = ""; + e.id = 0; + e.type = 0; + e.value = ""; - return entry; + return e; } - static DbStr GetDbStrEntry( + static DbStr GetDbStr( const std::vector &db_strs, int db_str_id ) @@ -120,13 +120,13 @@ public: auto row = results.begin(); if (results.RowCount() == 1) { - DbStr entry{}; + DbStr e{}; - entry.id = atoi(row[0]); - entry.type = atoi(row[1]); - entry.value = row[2] ? row[2] : ""; + e.id = atoi(row[0]); + e.type = atoi(row[1]); + e.value = row[2] ? row[2] : ""; - return entry; + return e; } return NewEntity(); @@ -151,24 +151,24 @@ public: static int UpdateOne( Database& db, - DbStr db_str_entry + const DbStr &e ) { - std::vector update_values; + std::vector v; auto columns = Columns(); - update_values.push_back(columns[0] + " = " + std::to_string(db_str_entry.id)); - update_values.push_back(columns[1] + " = " + std::to_string(db_str_entry.type)); - update_values.push_back(columns[2] + " = '" + Strings::Escape(db_str_entry.value) + "'"); + v.push_back(columns[0] + " = " + std::to_string(e.id)); + v.push_back(columns[1] + " = " + std::to_string(e.type)); + v.push_back(columns[2] + " = '" + Strings::Escape(e.value) + "'"); auto results = db.QueryDatabase( fmt::format( "UPDATE {} SET {} WHERE {} = {}", TableName(), - Strings::Implode(", ", update_values), + Strings::Implode(", ", v), PrimaryKey(), - db_str_entry.id + e.id ) ); @@ -177,51 +177,51 @@ public: static DbStr InsertOne( Database& db, - DbStr db_str_entry + DbStr e ) { - std::vector insert_values; + std::vector v; - insert_values.push_back(std::to_string(db_str_entry.id)); - insert_values.push_back(std::to_string(db_str_entry.type)); - insert_values.push_back("'" + Strings::Escape(db_str_entry.value) + "'"); + v.push_back(std::to_string(e.id)); + v.push_back(std::to_string(e.type)); + v.push_back("'" + Strings::Escape(e.value) + "'"); auto results = db.QueryDatabase( fmt::format( "{} VALUES ({})", BaseInsert(), - Strings::Implode(",", insert_values) + Strings::Implode(",", v) ) ); if (results.Success()) { - db_str_entry.id = results.LastInsertedID(); - return db_str_entry; + e.id = results.LastInsertedID(); + return e; } - db_str_entry = NewEntity(); + e = NewEntity(); - return db_str_entry; + return e; } static int InsertMany( Database& db, - std::vector db_str_entries + const std::vector &entries ) { std::vector insert_chunks; - for (auto &db_str_entry: db_str_entries) { - std::vector insert_values; + for (auto &e: entries) { + std::vector v; - insert_values.push_back(std::to_string(db_str_entry.id)); - insert_values.push_back(std::to_string(db_str_entry.type)); - insert_values.push_back("'" + Strings::Escape(db_str_entry.value) + "'"); + v.push_back(std::to_string(e.id)); + v.push_back(std::to_string(e.type)); + v.push_back("'" + Strings::Escape(e.value) + "'"); - insert_chunks.push_back("(" + Strings::Implode(",", insert_values) + ")"); + insert_chunks.push_back("(" + Strings::Implode(",", v) + ")"); } - std::vector insert_values; + std::vector v; auto results = db.QueryDatabase( fmt::format( @@ -248,19 +248,19 @@ public: all_entries.reserve(results.RowCount()); for (auto row = results.begin(); row != results.end(); ++row) { - DbStr entry{}; + DbStr e{}; - entry.id = atoi(row[0]); - entry.type = atoi(row[1]); - entry.value = row[2] ? row[2] : ""; + e.id = atoi(row[0]); + e.type = atoi(row[1]); + e.value = row[2] ? row[2] : ""; - all_entries.push_back(entry); + all_entries.push_back(e); } return all_entries; } - static std::vector GetWhere(Database& db, std::string where_filter) + static std::vector GetWhere(Database& db, const std::string &where_filter) { std::vector all_entries; @@ -275,19 +275,19 @@ public: all_entries.reserve(results.RowCount()); for (auto row = results.begin(); row != results.end(); ++row) { - DbStr entry{}; + DbStr e{}; - entry.id = atoi(row[0]); - entry.type = atoi(row[1]); - entry.value = row[2] ? row[2] : ""; + e.id = atoi(row[0]); + e.type = atoi(row[1]); + e.value = row[2] ? row[2] : ""; - all_entries.push_back(entry); + all_entries.push_back(e); } return all_entries; } - static int DeleteWhere(Database& db, std::string where_filter) + static int DeleteWhere(Database& db, const std::string &where_filter) { auto results = db.QueryDatabase( fmt::format( @@ -312,6 +312,32 @@ public: 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); + } + }; #endif //EQEMU_BASE_DB_STR_REPOSITORY_H diff --git a/common/repositories/base/base_discord_webhooks_repository.h b/common/repositories/base/base_discord_webhooks_repository.h index 88d6b049e..f4b78d058 100644 --- a/common/repositories/base/base_discord_webhooks_repository.h +++ b/common/repositories/base/base_discord_webhooks_repository.h @@ -88,18 +88,18 @@ public: static DiscordWebhooks NewEntity() { - DiscordWebhooks entry{}; + DiscordWebhooks e{}; - entry.id = 0; - entry.webhook_name = ""; - entry.webhook_url = ""; - entry.created_at = 0; - entry.deleted_at = 0; + e.id = 0; + e.webhook_name = ""; + e.webhook_url = ""; + e.created_at = 0; + e.deleted_at = 0; - return entry; + return e; } - static DiscordWebhooks GetDiscordWebhooksEntry( + static DiscordWebhooks GetDiscordWebhooks( const std::vector &discord_webhookss, int discord_webhooks_id ) @@ -128,15 +128,15 @@ public: auto row = results.begin(); if (results.RowCount() == 1) { - DiscordWebhooks entry{}; + DiscordWebhooks e{}; - entry.id = atoi(row[0]); - entry.webhook_name = row[1] ? row[1] : ""; - entry.webhook_url = row[2] ? row[2] : ""; - entry.created_at = strtoll(row[3] ? row[3] : "-1", nullptr, 10); - entry.deleted_at = strtoll(row[4] ? row[4] : "-1", nullptr, 10); + e.id = atoi(row[0]); + e.webhook_name = row[1] ? row[1] : ""; + e.webhook_url = row[2] ? row[2] : ""; + e.created_at = strtoll(row[3] ? row[3] : "-1", nullptr, 10); + e.deleted_at = strtoll(row[4] ? row[4] : "-1", nullptr, 10); - return entry; + return e; } return NewEntity(); @@ -161,25 +161,25 @@ public: static int UpdateOne( Database& db, - DiscordWebhooks discord_webhooks_entry + const DiscordWebhooks &e ) { - std::vector update_values; + std::vector v; auto columns = Columns(); - update_values.push_back(columns[1] + " = '" + Strings::Escape(discord_webhooks_entry.webhook_name) + "'"); - update_values.push_back(columns[2] + " = '" + Strings::Escape(discord_webhooks_entry.webhook_url) + "'"); - update_values.push_back(columns[3] + " = FROM_UNIXTIME(" + (discord_webhooks_entry.created_at > 0 ? std::to_string(discord_webhooks_entry.created_at) : "null") + ")"); - update_values.push_back(columns[4] + " = FROM_UNIXTIME(" + (discord_webhooks_entry.deleted_at > 0 ? std::to_string(discord_webhooks_entry.deleted_at) : "null") + ")"); + v.push_back(columns[1] + " = '" + Strings::Escape(e.webhook_name) + "'"); + v.push_back(columns[2] + " = '" + Strings::Escape(e.webhook_url) + "'"); + v.push_back(columns[3] + " = FROM_UNIXTIME(" + (e.created_at > 0 ? std::to_string(e.created_at) : "null") + ")"); + v.push_back(columns[4] + " = FROM_UNIXTIME(" + (e.deleted_at > 0 ? std::to_string(e.deleted_at) : "null") + ")"); auto results = db.QueryDatabase( fmt::format( "UPDATE {} SET {} WHERE {} = {}", TableName(), - Strings::Implode(", ", update_values), + Strings::Implode(", ", v), PrimaryKey(), - discord_webhooks_entry.id + e.id ) ); @@ -188,55 +188,55 @@ public: static DiscordWebhooks InsertOne( Database& db, - DiscordWebhooks discord_webhooks_entry + DiscordWebhooks e ) { - std::vector insert_values; + std::vector v; - insert_values.push_back(std::to_string(discord_webhooks_entry.id)); - insert_values.push_back("'" + Strings::Escape(discord_webhooks_entry.webhook_name) + "'"); - insert_values.push_back("'" + Strings::Escape(discord_webhooks_entry.webhook_url) + "'"); - insert_values.push_back("FROM_UNIXTIME(" + (discord_webhooks_entry.created_at > 0 ? std::to_string(discord_webhooks_entry.created_at) : "null") + ")"); - insert_values.push_back("FROM_UNIXTIME(" + (discord_webhooks_entry.deleted_at > 0 ? std::to_string(discord_webhooks_entry.deleted_at) : "null") + ")"); + v.push_back(std::to_string(e.id)); + v.push_back("'" + Strings::Escape(e.webhook_name) + "'"); + v.push_back("'" + Strings::Escape(e.webhook_url) + "'"); + v.push_back("FROM_UNIXTIME(" + (e.created_at > 0 ? std::to_string(e.created_at) : "null") + ")"); + v.push_back("FROM_UNIXTIME(" + (e.deleted_at > 0 ? std::to_string(e.deleted_at) : "null") + ")"); auto results = db.QueryDatabase( fmt::format( "{} VALUES ({})", BaseInsert(), - Strings::Implode(",", insert_values) + Strings::Implode(",", v) ) ); if (results.Success()) { - discord_webhooks_entry.id = results.LastInsertedID(); - return discord_webhooks_entry; + e.id = results.LastInsertedID(); + return e; } - discord_webhooks_entry = NewEntity(); + e = NewEntity(); - return discord_webhooks_entry; + return e; } static int InsertMany( Database& db, - std::vector discord_webhooks_entries + const std::vector &entries ) { std::vector insert_chunks; - for (auto &discord_webhooks_entry: discord_webhooks_entries) { - std::vector insert_values; + for (auto &e: entries) { + std::vector v; - insert_values.push_back(std::to_string(discord_webhooks_entry.id)); - insert_values.push_back("'" + Strings::Escape(discord_webhooks_entry.webhook_name) + "'"); - insert_values.push_back("'" + Strings::Escape(discord_webhooks_entry.webhook_url) + "'"); - insert_values.push_back("FROM_UNIXTIME(" + (discord_webhooks_entry.created_at > 0 ? std::to_string(discord_webhooks_entry.created_at) : "null") + ")"); - insert_values.push_back("FROM_UNIXTIME(" + (discord_webhooks_entry.deleted_at > 0 ? std::to_string(discord_webhooks_entry.deleted_at) : "null") + ")"); + v.push_back(std::to_string(e.id)); + v.push_back("'" + Strings::Escape(e.webhook_name) + "'"); + v.push_back("'" + Strings::Escape(e.webhook_url) + "'"); + v.push_back("FROM_UNIXTIME(" + (e.created_at > 0 ? std::to_string(e.created_at) : "null") + ")"); + v.push_back("FROM_UNIXTIME(" + (e.deleted_at > 0 ? std::to_string(e.deleted_at) : "null") + ")"); - insert_chunks.push_back("(" + Strings::Implode(",", insert_values) + ")"); + insert_chunks.push_back("(" + Strings::Implode(",", v) + ")"); } - std::vector insert_values; + std::vector v; auto results = db.QueryDatabase( fmt::format( @@ -263,21 +263,21 @@ public: all_entries.reserve(results.RowCount()); for (auto row = results.begin(); row != results.end(); ++row) { - DiscordWebhooks entry{}; + DiscordWebhooks e{}; - entry.id = atoi(row[0]); - entry.webhook_name = row[1] ? row[1] : ""; - entry.webhook_url = row[2] ? row[2] : ""; - entry.created_at = strtoll(row[3] ? row[3] : "-1", nullptr, 10); - entry.deleted_at = strtoll(row[4] ? row[4] : "-1", nullptr, 10); + e.id = atoi(row[0]); + e.webhook_name = row[1] ? row[1] : ""; + e.webhook_url = row[2] ? row[2] : ""; + e.created_at = strtoll(row[3] ? row[3] : "-1", nullptr, 10); + e.deleted_at = strtoll(row[4] ? row[4] : "-1", nullptr, 10); - all_entries.push_back(entry); + all_entries.push_back(e); } return all_entries; } - static std::vector GetWhere(Database& db, std::string where_filter) + static std::vector GetWhere(Database& db, const std::string &where_filter) { std::vector all_entries; @@ -292,21 +292,21 @@ public: all_entries.reserve(results.RowCount()); for (auto row = results.begin(); row != results.end(); ++row) { - DiscordWebhooks entry{}; + DiscordWebhooks e{}; - entry.id = atoi(row[0]); - entry.webhook_name = row[1] ? row[1] : ""; - entry.webhook_url = row[2] ? row[2] : ""; - entry.created_at = strtoll(row[3] ? row[3] : "-1", nullptr, 10); - entry.deleted_at = strtoll(row[4] ? row[4] : "-1", nullptr, 10); + e.id = atoi(row[0]); + e.webhook_name = row[1] ? row[1] : ""; + e.webhook_url = row[2] ? row[2] : ""; + e.created_at = strtoll(row[3] ? row[3] : "-1", nullptr, 10); + e.deleted_at = strtoll(row[4] ? row[4] : "-1", nullptr, 10); - all_entries.push_back(entry); + all_entries.push_back(e); } return all_entries; } - static int DeleteWhere(Database& db, std::string where_filter) + static int DeleteWhere(Database& db, const std::string &where_filter) { auto results = db.QueryDatabase( fmt::format( @@ -331,6 +331,32 @@ public: 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); + } + }; #endif //EQEMU_BASE_DISCORD_WEBHOOKS_REPOSITORY_H diff --git a/common/repositories/base/base_discovered_items_repository.h b/common/repositories/base/base_discovered_items_repository.h index 024000e13..7aaaac4da 100644 --- a/common/repositories/base/base_discovered_items_repository.h +++ b/common/repositories/base/base_discovered_items_repository.h @@ -85,17 +85,17 @@ public: static DiscoveredItems NewEntity() { - DiscoveredItems entry{}; + DiscoveredItems e{}; - entry.item_id = 0; - entry.char_name = ""; - entry.discovered_date = 0; - entry.account_status = 0; + e.item_id = 0; + e.char_name = ""; + e.discovered_date = 0; + e.account_status = 0; - return entry; + return e; } - static DiscoveredItems GetDiscoveredItemsEntry( + static DiscoveredItems GetDiscoveredItems( const std::vector &discovered_itemss, int discovered_items_id ) @@ -124,14 +124,14 @@ public: auto row = results.begin(); if (results.RowCount() == 1) { - DiscoveredItems entry{}; + DiscoveredItems e{}; - entry.item_id = atoi(row[0]); - entry.char_name = row[1] ? row[1] : ""; - entry.discovered_date = atoi(row[2]); - entry.account_status = atoi(row[3]); + e.item_id = atoi(row[0]); + e.char_name = row[1] ? row[1] : ""; + e.discovered_date = atoi(row[2]); + e.account_status = atoi(row[3]); - return entry; + return e; } return NewEntity(); @@ -156,25 +156,25 @@ public: static int UpdateOne( Database& db, - DiscoveredItems discovered_items_entry + const DiscoveredItems &e ) { - std::vector update_values; + std::vector v; auto columns = Columns(); - update_values.push_back(columns[0] + " = " + std::to_string(discovered_items_entry.item_id)); - update_values.push_back(columns[1] + " = '" + Strings::Escape(discovered_items_entry.char_name) + "'"); - update_values.push_back(columns[2] + " = " + std::to_string(discovered_items_entry.discovered_date)); - update_values.push_back(columns[3] + " = " + std::to_string(discovered_items_entry.account_status)); + v.push_back(columns[0] + " = " + std::to_string(e.item_id)); + v.push_back(columns[1] + " = '" + Strings::Escape(e.char_name) + "'"); + v.push_back(columns[2] + " = " + std::to_string(e.discovered_date)); + v.push_back(columns[3] + " = " + std::to_string(e.account_status)); auto results = db.QueryDatabase( fmt::format( "UPDATE {} SET {} WHERE {} = {}", TableName(), - Strings::Implode(", ", update_values), + Strings::Implode(", ", v), PrimaryKey(), - discovered_items_entry.item_id + e.item_id ) ); @@ -183,53 +183,53 @@ public: static DiscoveredItems InsertOne( Database& db, - DiscoveredItems discovered_items_entry + DiscoveredItems e ) { - std::vector insert_values; + std::vector v; - insert_values.push_back(std::to_string(discovered_items_entry.item_id)); - insert_values.push_back("'" + Strings::Escape(discovered_items_entry.char_name) + "'"); - insert_values.push_back(std::to_string(discovered_items_entry.discovered_date)); - insert_values.push_back(std::to_string(discovered_items_entry.account_status)); + v.push_back(std::to_string(e.item_id)); + v.push_back("'" + Strings::Escape(e.char_name) + "'"); + v.push_back(std::to_string(e.discovered_date)); + v.push_back(std::to_string(e.account_status)); auto results = db.QueryDatabase( fmt::format( "{} VALUES ({})", BaseInsert(), - Strings::Implode(",", insert_values) + Strings::Implode(",", v) ) ); if (results.Success()) { - discovered_items_entry.item_id = results.LastInsertedID(); - return discovered_items_entry; + e.item_id = results.LastInsertedID(); + return e; } - discovered_items_entry = NewEntity(); + e = NewEntity(); - return discovered_items_entry; + return e; } static int InsertMany( Database& db, - std::vector discovered_items_entries + const std::vector &entries ) { std::vector insert_chunks; - for (auto &discovered_items_entry: discovered_items_entries) { - std::vector insert_values; + for (auto &e: entries) { + std::vector v; - insert_values.push_back(std::to_string(discovered_items_entry.item_id)); - insert_values.push_back("'" + Strings::Escape(discovered_items_entry.char_name) + "'"); - insert_values.push_back(std::to_string(discovered_items_entry.discovered_date)); - insert_values.push_back(std::to_string(discovered_items_entry.account_status)); + v.push_back(std::to_string(e.item_id)); + v.push_back("'" + Strings::Escape(e.char_name) + "'"); + v.push_back(std::to_string(e.discovered_date)); + v.push_back(std::to_string(e.account_status)); - insert_chunks.push_back("(" + Strings::Implode(",", insert_values) + ")"); + insert_chunks.push_back("(" + Strings::Implode(",", v) + ")"); } - std::vector insert_values; + std::vector v; auto results = db.QueryDatabase( fmt::format( @@ -256,20 +256,20 @@ public: all_entries.reserve(results.RowCount()); for (auto row = results.begin(); row != results.end(); ++row) { - DiscoveredItems entry{}; + DiscoveredItems e{}; - entry.item_id = atoi(row[0]); - entry.char_name = row[1] ? row[1] : ""; - entry.discovered_date = atoi(row[2]); - entry.account_status = atoi(row[3]); + e.item_id = atoi(row[0]); + e.char_name = row[1] ? row[1] : ""; + e.discovered_date = atoi(row[2]); + e.account_status = atoi(row[3]); - all_entries.push_back(entry); + all_entries.push_back(e); } return all_entries; } - static std::vector GetWhere(Database& db, std::string where_filter) + static std::vector GetWhere(Database& db, const std::string &where_filter) { std::vector all_entries; @@ -284,20 +284,20 @@ public: all_entries.reserve(results.RowCount()); for (auto row = results.begin(); row != results.end(); ++row) { - DiscoveredItems entry{}; + DiscoveredItems e{}; - entry.item_id = atoi(row[0]); - entry.char_name = row[1] ? row[1] : ""; - entry.discovered_date = atoi(row[2]); - entry.account_status = atoi(row[3]); + e.item_id = atoi(row[0]); + e.char_name = row[1] ? row[1] : ""; + e.discovered_date = atoi(row[2]); + e.account_status = atoi(row[3]); - all_entries.push_back(entry); + all_entries.push_back(e); } return all_entries; } - static int DeleteWhere(Database& db, std::string where_filter) + static int DeleteWhere(Database& db, const std::string &where_filter) { auto results = db.QueryDatabase( fmt::format( @@ -322,6 +322,32 @@ public: 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); + } + }; #endif //EQEMU_BASE_DISCOVERED_ITEMS_REPOSITORY_H diff --git a/common/repositories/base/base_doors_repository.h b/common/repositories/base/base_doors_repository.h index ebb9aa3b3..fc67d2dac 100644 --- a/common/repositories/base/base_doors_repository.h +++ b/common/repositories/base/base_doors_repository.h @@ -181,49 +181,49 @@ public: static Doors NewEntity() { - Doors entry{}; + Doors e{}; - entry.id = 0; - entry.doorid = 0; - entry.zone = ""; - entry.version = 0; - entry.name = ""; - entry.pos_y = 0; - entry.pos_x = 0; - entry.pos_z = 0; - entry.heading = 0; - entry.opentype = 0; - entry.guild = 0; - entry.lockpick = 0; - entry.keyitem = 0; - entry.nokeyring = 0; - entry.triggerdoor = 0; - entry.triggertype = 0; - entry.disable_timer = 0; - entry.doorisopen = 0; - entry.door_param = 0; - entry.dest_zone = "NONE"; - entry.dest_instance = 0; - entry.dest_x = 0; - entry.dest_y = 0; - entry.dest_z = 0; - entry.dest_heading = 0; - entry.invert_state = 0; - entry.incline = 0; - entry.size = 100; - entry.buffer = 0; - entry.client_version_mask = 4294967295; - entry.is_ldon_door = 0; - entry.dz_switch_id = 0; - entry.min_expansion = -1; - entry.max_expansion = -1; - entry.content_flags = ""; - entry.content_flags_disabled = ""; + e.id = 0; + e.doorid = 0; + e.zone = ""; + e.version = 0; + e.name = ""; + e.pos_y = 0; + e.pos_x = 0; + e.pos_z = 0; + e.heading = 0; + e.opentype = 0; + e.guild = 0; + e.lockpick = 0; + e.keyitem = 0; + e.nokeyring = 0; + e.triggerdoor = 0; + e.triggertype = 0; + e.disable_timer = 0; + e.doorisopen = 0; + e.door_param = 0; + e.dest_zone = "NONE"; + e.dest_instance = 0; + e.dest_x = 0; + e.dest_y = 0; + e.dest_z = 0; + e.dest_heading = 0; + e.invert_state = 0; + e.incline = 0; + e.size = 100; + e.buffer = 0; + e.client_version_mask = 4294967295; + e.is_ldon_door = 0; + e.dz_switch_id = 0; + e.min_expansion = -1; + e.max_expansion = -1; + e.content_flags = ""; + e.content_flags_disabled = ""; - return entry; + return e; } - static Doors GetDoorsEntry( + static Doors GetDoors( const std::vector &doorss, int doors_id ) @@ -252,46 +252,46 @@ public: auto row = results.begin(); if (results.RowCount() == 1) { - Doors entry{}; + Doors e{}; - entry.id = atoi(row[0]); - entry.doorid = atoi(row[1]); - entry.zone = row[2] ? row[2] : ""; - entry.version = atoi(row[3]); - entry.name = row[4] ? row[4] : ""; - entry.pos_y = static_cast(atof(row[5])); - entry.pos_x = static_cast(atof(row[6])); - entry.pos_z = static_cast(atof(row[7])); - entry.heading = static_cast(atof(row[8])); - entry.opentype = atoi(row[9]); - entry.guild = atoi(row[10]); - entry.lockpick = atoi(row[11]); - entry.keyitem = atoi(row[12]); - entry.nokeyring = atoi(row[13]); - entry.triggerdoor = atoi(row[14]); - entry.triggertype = atoi(row[15]); - entry.disable_timer = atoi(row[16]); - entry.doorisopen = atoi(row[17]); - entry.door_param = atoi(row[18]); - entry.dest_zone = row[19] ? row[19] : ""; - entry.dest_instance = atoi(row[20]); - entry.dest_x = static_cast(atof(row[21])); - entry.dest_y = static_cast(atof(row[22])); - entry.dest_z = static_cast(atof(row[23])); - entry.dest_heading = static_cast(atof(row[24])); - entry.invert_state = atoi(row[25]); - entry.incline = atoi(row[26]); - entry.size = atoi(row[27]); - entry.buffer = static_cast(atof(row[28])); - entry.client_version_mask = atoi(row[29]); - entry.is_ldon_door = atoi(row[30]); - entry.dz_switch_id = atoi(row[31]); - entry.min_expansion = atoi(row[32]); - entry.max_expansion = atoi(row[33]); - entry.content_flags = row[34] ? row[34] : ""; - entry.content_flags_disabled = row[35] ? row[35] : ""; + e.id = atoi(row[0]); + e.doorid = atoi(row[1]); + e.zone = row[2] ? row[2] : ""; + e.version = atoi(row[3]); + e.name = row[4] ? row[4] : ""; + e.pos_y = static_cast(atof(row[5])); + e.pos_x = static_cast(atof(row[6])); + e.pos_z = static_cast(atof(row[7])); + e.heading = static_cast(atof(row[8])); + e.opentype = atoi(row[9]); + e.guild = atoi(row[10]); + e.lockpick = atoi(row[11]); + e.keyitem = atoi(row[12]); + e.nokeyring = atoi(row[13]); + e.triggerdoor = atoi(row[14]); + e.triggertype = atoi(row[15]); + e.disable_timer = atoi(row[16]); + e.doorisopen = atoi(row[17]); + e.door_param = atoi(row[18]); + e.dest_zone = row[19] ? row[19] : ""; + e.dest_instance = atoi(row[20]); + e.dest_x = static_cast(atof(row[21])); + e.dest_y = static_cast(atof(row[22])); + e.dest_z = static_cast(atof(row[23])); + e.dest_heading = static_cast(atof(row[24])); + e.invert_state = atoi(row[25]); + e.incline = atoi(row[26]); + e.size = atoi(row[27]); + e.buffer = static_cast(atof(row[28])); + e.client_version_mask = atoi(row[29]); + e.is_ldon_door = atoi(row[30]); + e.dz_switch_id = atoi(row[31]); + e.min_expansion = atoi(row[32]); + e.max_expansion = atoi(row[33]); + e.content_flags = row[34] ? row[34] : ""; + e.content_flags_disabled = row[35] ? row[35] : ""; - return entry; + return e; } return NewEntity(); @@ -316,56 +316,56 @@ public: static int UpdateOne( Database& db, - Doors doors_entry + const Doors &e ) { - std::vector update_values; + std::vector v; auto columns = Columns(); - update_values.push_back(columns[1] + " = " + std::to_string(doors_entry.doorid)); - update_values.push_back(columns[2] + " = '" + Strings::Escape(doors_entry.zone) + "'"); - update_values.push_back(columns[3] + " = " + std::to_string(doors_entry.version)); - update_values.push_back(columns[4] + " = '" + Strings::Escape(doors_entry.name) + "'"); - update_values.push_back(columns[5] + " = " + std::to_string(doors_entry.pos_y)); - update_values.push_back(columns[6] + " = " + std::to_string(doors_entry.pos_x)); - update_values.push_back(columns[7] + " = " + std::to_string(doors_entry.pos_z)); - update_values.push_back(columns[8] + " = " + std::to_string(doors_entry.heading)); - update_values.push_back(columns[9] + " = " + std::to_string(doors_entry.opentype)); - update_values.push_back(columns[10] + " = " + std::to_string(doors_entry.guild)); - update_values.push_back(columns[11] + " = " + std::to_string(doors_entry.lockpick)); - update_values.push_back(columns[12] + " = " + std::to_string(doors_entry.keyitem)); - update_values.push_back(columns[13] + " = " + std::to_string(doors_entry.nokeyring)); - update_values.push_back(columns[14] + " = " + std::to_string(doors_entry.triggerdoor)); - update_values.push_back(columns[15] + " = " + std::to_string(doors_entry.triggertype)); - update_values.push_back(columns[16] + " = " + std::to_string(doors_entry.disable_timer)); - update_values.push_back(columns[17] + " = " + std::to_string(doors_entry.doorisopen)); - update_values.push_back(columns[18] + " = " + std::to_string(doors_entry.door_param)); - update_values.push_back(columns[19] + " = '" + Strings::Escape(doors_entry.dest_zone) + "'"); - update_values.push_back(columns[20] + " = " + std::to_string(doors_entry.dest_instance)); - update_values.push_back(columns[21] + " = " + std::to_string(doors_entry.dest_x)); - update_values.push_back(columns[22] + " = " + std::to_string(doors_entry.dest_y)); - update_values.push_back(columns[23] + " = " + std::to_string(doors_entry.dest_z)); - update_values.push_back(columns[24] + " = " + std::to_string(doors_entry.dest_heading)); - update_values.push_back(columns[25] + " = " + std::to_string(doors_entry.invert_state)); - update_values.push_back(columns[26] + " = " + std::to_string(doors_entry.incline)); - update_values.push_back(columns[27] + " = " + std::to_string(doors_entry.size)); - update_values.push_back(columns[28] + " = " + std::to_string(doors_entry.buffer)); - update_values.push_back(columns[29] + " = " + std::to_string(doors_entry.client_version_mask)); - update_values.push_back(columns[30] + " = " + std::to_string(doors_entry.is_ldon_door)); - update_values.push_back(columns[31] + " = " + std::to_string(doors_entry.dz_switch_id)); - update_values.push_back(columns[32] + " = " + std::to_string(doors_entry.min_expansion)); - update_values.push_back(columns[33] + " = " + std::to_string(doors_entry.max_expansion)); - update_values.push_back(columns[34] + " = '" + Strings::Escape(doors_entry.content_flags) + "'"); - update_values.push_back(columns[35] + " = '" + Strings::Escape(doors_entry.content_flags_disabled) + "'"); + v.push_back(columns[1] + " = " + std::to_string(e.doorid)); + v.push_back(columns[2] + " = '" + Strings::Escape(e.zone) + "'"); + v.push_back(columns[3] + " = " + std::to_string(e.version)); + v.push_back(columns[4] + " = '" + Strings::Escape(e.name) + "'"); + v.push_back(columns[5] + " = " + std::to_string(e.pos_y)); + v.push_back(columns[6] + " = " + std::to_string(e.pos_x)); + v.push_back(columns[7] + " = " + std::to_string(e.pos_z)); + v.push_back(columns[8] + " = " + std::to_string(e.heading)); + v.push_back(columns[9] + " = " + std::to_string(e.opentype)); + v.push_back(columns[10] + " = " + std::to_string(e.guild)); + v.push_back(columns[11] + " = " + std::to_string(e.lockpick)); + v.push_back(columns[12] + " = " + std::to_string(e.keyitem)); + v.push_back(columns[13] + " = " + std::to_string(e.nokeyring)); + v.push_back(columns[14] + " = " + std::to_string(e.triggerdoor)); + v.push_back(columns[15] + " = " + std::to_string(e.triggertype)); + v.push_back(columns[16] + " = " + std::to_string(e.disable_timer)); + v.push_back(columns[17] + " = " + std::to_string(e.doorisopen)); + v.push_back(columns[18] + " = " + std::to_string(e.door_param)); + v.push_back(columns[19] + " = '" + Strings::Escape(e.dest_zone) + "'"); + v.push_back(columns[20] + " = " + std::to_string(e.dest_instance)); + v.push_back(columns[21] + " = " + std::to_string(e.dest_x)); + v.push_back(columns[22] + " = " + std::to_string(e.dest_y)); + v.push_back(columns[23] + " = " + std::to_string(e.dest_z)); + v.push_back(columns[24] + " = " + std::to_string(e.dest_heading)); + v.push_back(columns[25] + " = " + std::to_string(e.invert_state)); + v.push_back(columns[26] + " = " + std::to_string(e.incline)); + v.push_back(columns[27] + " = " + std::to_string(e.size)); + v.push_back(columns[28] + " = " + std::to_string(e.buffer)); + v.push_back(columns[29] + " = " + std::to_string(e.client_version_mask)); + v.push_back(columns[30] + " = " + std::to_string(e.is_ldon_door)); + v.push_back(columns[31] + " = " + std::to_string(e.dz_switch_id)); + v.push_back(columns[32] + " = " + std::to_string(e.min_expansion)); + v.push_back(columns[33] + " = " + std::to_string(e.max_expansion)); + v.push_back(columns[34] + " = '" + Strings::Escape(e.content_flags) + "'"); + v.push_back(columns[35] + " = '" + Strings::Escape(e.content_flags_disabled) + "'"); auto results = db.QueryDatabase( fmt::format( "UPDATE {} SET {} WHERE {} = {}", TableName(), - Strings::Implode(", ", update_values), + Strings::Implode(", ", v), PrimaryKey(), - doors_entry.id + e.id ) ); @@ -374,117 +374,117 @@ public: static Doors InsertOne( Database& db, - Doors doors_entry + Doors e ) { - std::vector insert_values; + std::vector v; - insert_values.push_back(std::to_string(doors_entry.id)); - insert_values.push_back(std::to_string(doors_entry.doorid)); - insert_values.push_back("'" + Strings::Escape(doors_entry.zone) + "'"); - insert_values.push_back(std::to_string(doors_entry.version)); - insert_values.push_back("'" + Strings::Escape(doors_entry.name) + "'"); - insert_values.push_back(std::to_string(doors_entry.pos_y)); - insert_values.push_back(std::to_string(doors_entry.pos_x)); - insert_values.push_back(std::to_string(doors_entry.pos_z)); - insert_values.push_back(std::to_string(doors_entry.heading)); - insert_values.push_back(std::to_string(doors_entry.opentype)); - insert_values.push_back(std::to_string(doors_entry.guild)); - insert_values.push_back(std::to_string(doors_entry.lockpick)); - insert_values.push_back(std::to_string(doors_entry.keyitem)); - insert_values.push_back(std::to_string(doors_entry.nokeyring)); - insert_values.push_back(std::to_string(doors_entry.triggerdoor)); - insert_values.push_back(std::to_string(doors_entry.triggertype)); - insert_values.push_back(std::to_string(doors_entry.disable_timer)); - insert_values.push_back(std::to_string(doors_entry.doorisopen)); - insert_values.push_back(std::to_string(doors_entry.door_param)); - insert_values.push_back("'" + Strings::Escape(doors_entry.dest_zone) + "'"); - insert_values.push_back(std::to_string(doors_entry.dest_instance)); - insert_values.push_back(std::to_string(doors_entry.dest_x)); - insert_values.push_back(std::to_string(doors_entry.dest_y)); - insert_values.push_back(std::to_string(doors_entry.dest_z)); - insert_values.push_back(std::to_string(doors_entry.dest_heading)); - insert_values.push_back(std::to_string(doors_entry.invert_state)); - insert_values.push_back(std::to_string(doors_entry.incline)); - insert_values.push_back(std::to_string(doors_entry.size)); - insert_values.push_back(std::to_string(doors_entry.buffer)); - insert_values.push_back(std::to_string(doors_entry.client_version_mask)); - insert_values.push_back(std::to_string(doors_entry.is_ldon_door)); - insert_values.push_back(std::to_string(doors_entry.dz_switch_id)); - insert_values.push_back(std::to_string(doors_entry.min_expansion)); - insert_values.push_back(std::to_string(doors_entry.max_expansion)); - insert_values.push_back("'" + Strings::Escape(doors_entry.content_flags) + "'"); - insert_values.push_back("'" + Strings::Escape(doors_entry.content_flags_disabled) + "'"); + v.push_back(std::to_string(e.id)); + v.push_back(std::to_string(e.doorid)); + v.push_back("'" + Strings::Escape(e.zone) + "'"); + v.push_back(std::to_string(e.version)); + v.push_back("'" + Strings::Escape(e.name) + "'"); + v.push_back(std::to_string(e.pos_y)); + v.push_back(std::to_string(e.pos_x)); + v.push_back(std::to_string(e.pos_z)); + v.push_back(std::to_string(e.heading)); + v.push_back(std::to_string(e.opentype)); + v.push_back(std::to_string(e.guild)); + v.push_back(std::to_string(e.lockpick)); + v.push_back(std::to_string(e.keyitem)); + v.push_back(std::to_string(e.nokeyring)); + v.push_back(std::to_string(e.triggerdoor)); + v.push_back(std::to_string(e.triggertype)); + v.push_back(std::to_string(e.disable_timer)); + v.push_back(std::to_string(e.doorisopen)); + v.push_back(std::to_string(e.door_param)); + v.push_back("'" + Strings::Escape(e.dest_zone) + "'"); + v.push_back(std::to_string(e.dest_instance)); + v.push_back(std::to_string(e.dest_x)); + v.push_back(std::to_string(e.dest_y)); + v.push_back(std::to_string(e.dest_z)); + v.push_back(std::to_string(e.dest_heading)); + v.push_back(std::to_string(e.invert_state)); + v.push_back(std::to_string(e.incline)); + v.push_back(std::to_string(e.size)); + v.push_back(std::to_string(e.buffer)); + v.push_back(std::to_string(e.client_version_mask)); + v.push_back(std::to_string(e.is_ldon_door)); + v.push_back(std::to_string(e.dz_switch_id)); + v.push_back(std::to_string(e.min_expansion)); + v.push_back(std::to_string(e.max_expansion)); + v.push_back("'" + Strings::Escape(e.content_flags) + "'"); + v.push_back("'" + Strings::Escape(e.content_flags_disabled) + "'"); auto results = db.QueryDatabase( fmt::format( "{} VALUES ({})", BaseInsert(), - Strings::Implode(",", insert_values) + Strings::Implode(",", v) ) ); if (results.Success()) { - doors_entry.id = results.LastInsertedID(); - return doors_entry; + e.id = results.LastInsertedID(); + return e; } - doors_entry = NewEntity(); + e = NewEntity(); - return doors_entry; + return e; } static int InsertMany( Database& db, - std::vector doors_entries + const std::vector &entries ) { std::vector insert_chunks; - for (auto &doors_entry: doors_entries) { - std::vector insert_values; + for (auto &e: entries) { + std::vector v; - insert_values.push_back(std::to_string(doors_entry.id)); - insert_values.push_back(std::to_string(doors_entry.doorid)); - insert_values.push_back("'" + Strings::Escape(doors_entry.zone) + "'"); - insert_values.push_back(std::to_string(doors_entry.version)); - insert_values.push_back("'" + Strings::Escape(doors_entry.name) + "'"); - insert_values.push_back(std::to_string(doors_entry.pos_y)); - insert_values.push_back(std::to_string(doors_entry.pos_x)); - insert_values.push_back(std::to_string(doors_entry.pos_z)); - insert_values.push_back(std::to_string(doors_entry.heading)); - insert_values.push_back(std::to_string(doors_entry.opentype)); - insert_values.push_back(std::to_string(doors_entry.guild)); - insert_values.push_back(std::to_string(doors_entry.lockpick)); - insert_values.push_back(std::to_string(doors_entry.keyitem)); - insert_values.push_back(std::to_string(doors_entry.nokeyring)); - insert_values.push_back(std::to_string(doors_entry.triggerdoor)); - insert_values.push_back(std::to_string(doors_entry.triggertype)); - insert_values.push_back(std::to_string(doors_entry.disable_timer)); - insert_values.push_back(std::to_string(doors_entry.doorisopen)); - insert_values.push_back(std::to_string(doors_entry.door_param)); - insert_values.push_back("'" + Strings::Escape(doors_entry.dest_zone) + "'"); - insert_values.push_back(std::to_string(doors_entry.dest_instance)); - insert_values.push_back(std::to_string(doors_entry.dest_x)); - insert_values.push_back(std::to_string(doors_entry.dest_y)); - insert_values.push_back(std::to_string(doors_entry.dest_z)); - insert_values.push_back(std::to_string(doors_entry.dest_heading)); - insert_values.push_back(std::to_string(doors_entry.invert_state)); - insert_values.push_back(std::to_string(doors_entry.incline)); - insert_values.push_back(std::to_string(doors_entry.size)); - insert_values.push_back(std::to_string(doors_entry.buffer)); - insert_values.push_back(std::to_string(doors_entry.client_version_mask)); - insert_values.push_back(std::to_string(doors_entry.is_ldon_door)); - insert_values.push_back(std::to_string(doors_entry.dz_switch_id)); - insert_values.push_back(std::to_string(doors_entry.min_expansion)); - insert_values.push_back(std::to_string(doors_entry.max_expansion)); - insert_values.push_back("'" + Strings::Escape(doors_entry.content_flags) + "'"); - insert_values.push_back("'" + Strings::Escape(doors_entry.content_flags_disabled) + "'"); + v.push_back(std::to_string(e.id)); + v.push_back(std::to_string(e.doorid)); + v.push_back("'" + Strings::Escape(e.zone) + "'"); + v.push_back(std::to_string(e.version)); + v.push_back("'" + Strings::Escape(e.name) + "'"); + v.push_back(std::to_string(e.pos_y)); + v.push_back(std::to_string(e.pos_x)); + v.push_back(std::to_string(e.pos_z)); + v.push_back(std::to_string(e.heading)); + v.push_back(std::to_string(e.opentype)); + v.push_back(std::to_string(e.guild)); + v.push_back(std::to_string(e.lockpick)); + v.push_back(std::to_string(e.keyitem)); + v.push_back(std::to_string(e.nokeyring)); + v.push_back(std::to_string(e.triggerdoor)); + v.push_back(std::to_string(e.triggertype)); + v.push_back(std::to_string(e.disable_timer)); + v.push_back(std::to_string(e.doorisopen)); + v.push_back(std::to_string(e.door_param)); + v.push_back("'" + Strings::Escape(e.dest_zone) + "'"); + v.push_back(std::to_string(e.dest_instance)); + v.push_back(std::to_string(e.dest_x)); + v.push_back(std::to_string(e.dest_y)); + v.push_back(std::to_string(e.dest_z)); + v.push_back(std::to_string(e.dest_heading)); + v.push_back(std::to_string(e.invert_state)); + v.push_back(std::to_string(e.incline)); + v.push_back(std::to_string(e.size)); + v.push_back(std::to_string(e.buffer)); + v.push_back(std::to_string(e.client_version_mask)); + v.push_back(std::to_string(e.is_ldon_door)); + v.push_back(std::to_string(e.dz_switch_id)); + v.push_back(std::to_string(e.min_expansion)); + v.push_back(std::to_string(e.max_expansion)); + v.push_back("'" + Strings::Escape(e.content_flags) + "'"); + v.push_back("'" + Strings::Escape(e.content_flags_disabled) + "'"); - insert_chunks.push_back("(" + Strings::Implode(",", insert_values) + ")"); + insert_chunks.push_back("(" + Strings::Implode(",", v) + ")"); } - std::vector insert_values; + std::vector v; auto results = db.QueryDatabase( fmt::format( @@ -511,52 +511,52 @@ public: all_entries.reserve(results.RowCount()); for (auto row = results.begin(); row != results.end(); ++row) { - Doors entry{}; + Doors e{}; - entry.id = atoi(row[0]); - entry.doorid = atoi(row[1]); - entry.zone = row[2] ? row[2] : ""; - entry.version = atoi(row[3]); - entry.name = row[4] ? row[4] : ""; - entry.pos_y = static_cast(atof(row[5])); - entry.pos_x = static_cast(atof(row[6])); - entry.pos_z = static_cast(atof(row[7])); - entry.heading = static_cast(atof(row[8])); - entry.opentype = atoi(row[9]); - entry.guild = atoi(row[10]); - entry.lockpick = atoi(row[11]); - entry.keyitem = atoi(row[12]); - entry.nokeyring = atoi(row[13]); - entry.triggerdoor = atoi(row[14]); - entry.triggertype = atoi(row[15]); - entry.disable_timer = atoi(row[16]); - entry.doorisopen = atoi(row[17]); - entry.door_param = atoi(row[18]); - entry.dest_zone = row[19] ? row[19] : ""; - entry.dest_instance = atoi(row[20]); - entry.dest_x = static_cast(atof(row[21])); - entry.dest_y = static_cast(atof(row[22])); - entry.dest_z = static_cast(atof(row[23])); - entry.dest_heading = static_cast(atof(row[24])); - entry.invert_state = atoi(row[25]); - entry.incline = atoi(row[26]); - entry.size = atoi(row[27]); - entry.buffer = static_cast(atof(row[28])); - entry.client_version_mask = atoi(row[29]); - entry.is_ldon_door = atoi(row[30]); - entry.dz_switch_id = atoi(row[31]); - entry.min_expansion = atoi(row[32]); - entry.max_expansion = atoi(row[33]); - entry.content_flags = row[34] ? row[34] : ""; - entry.content_flags_disabled = row[35] ? row[35] : ""; + e.id = atoi(row[0]); + e.doorid = atoi(row[1]); + e.zone = row[2] ? row[2] : ""; + e.version = atoi(row[3]); + e.name = row[4] ? row[4] : ""; + e.pos_y = static_cast(atof(row[5])); + e.pos_x = static_cast(atof(row[6])); + e.pos_z = static_cast(atof(row[7])); + e.heading = static_cast(atof(row[8])); + e.opentype = atoi(row[9]); + e.guild = atoi(row[10]); + e.lockpick = atoi(row[11]); + e.keyitem = atoi(row[12]); + e.nokeyring = atoi(row[13]); + e.triggerdoor = atoi(row[14]); + e.triggertype = atoi(row[15]); + e.disable_timer = atoi(row[16]); + e.doorisopen = atoi(row[17]); + e.door_param = atoi(row[18]); + e.dest_zone = row[19] ? row[19] : ""; + e.dest_instance = atoi(row[20]); + e.dest_x = static_cast(atof(row[21])); + e.dest_y = static_cast(atof(row[22])); + e.dest_z = static_cast(atof(row[23])); + e.dest_heading = static_cast(atof(row[24])); + e.invert_state = atoi(row[25]); + e.incline = atoi(row[26]); + e.size = atoi(row[27]); + e.buffer = static_cast(atof(row[28])); + e.client_version_mask = atoi(row[29]); + e.is_ldon_door = atoi(row[30]); + e.dz_switch_id = atoi(row[31]); + e.min_expansion = atoi(row[32]); + e.max_expansion = atoi(row[33]); + e.content_flags = row[34] ? row[34] : ""; + e.content_flags_disabled = row[35] ? row[35] : ""; - all_entries.push_back(entry); + all_entries.push_back(e); } return all_entries; } - static std::vector GetWhere(Database& db, std::string where_filter) + static std::vector GetWhere(Database& db, const std::string &where_filter) { std::vector all_entries; @@ -571,52 +571,52 @@ public: all_entries.reserve(results.RowCount()); for (auto row = results.begin(); row != results.end(); ++row) { - Doors entry{}; + Doors e{}; - entry.id = atoi(row[0]); - entry.doorid = atoi(row[1]); - entry.zone = row[2] ? row[2] : ""; - entry.version = atoi(row[3]); - entry.name = row[4] ? row[4] : ""; - entry.pos_y = static_cast(atof(row[5])); - entry.pos_x = static_cast(atof(row[6])); - entry.pos_z = static_cast(atof(row[7])); - entry.heading = static_cast(atof(row[8])); - entry.opentype = atoi(row[9]); - entry.guild = atoi(row[10]); - entry.lockpick = atoi(row[11]); - entry.keyitem = atoi(row[12]); - entry.nokeyring = atoi(row[13]); - entry.triggerdoor = atoi(row[14]); - entry.triggertype = atoi(row[15]); - entry.disable_timer = atoi(row[16]); - entry.doorisopen = atoi(row[17]); - entry.door_param = atoi(row[18]); - entry.dest_zone = row[19] ? row[19] : ""; - entry.dest_instance = atoi(row[20]); - entry.dest_x = static_cast(atof(row[21])); - entry.dest_y = static_cast(atof(row[22])); - entry.dest_z = static_cast(atof(row[23])); - entry.dest_heading = static_cast(atof(row[24])); - entry.invert_state = atoi(row[25]); - entry.incline = atoi(row[26]); - entry.size = atoi(row[27]); - entry.buffer = static_cast(atof(row[28])); - entry.client_version_mask = atoi(row[29]); - entry.is_ldon_door = atoi(row[30]); - entry.dz_switch_id = atoi(row[31]); - entry.min_expansion = atoi(row[32]); - entry.max_expansion = atoi(row[33]); - entry.content_flags = row[34] ? row[34] : ""; - entry.content_flags_disabled = row[35] ? row[35] : ""; + e.id = atoi(row[0]); + e.doorid = atoi(row[1]); + e.zone = row[2] ? row[2] : ""; + e.version = atoi(row[3]); + e.name = row[4] ? row[4] : ""; + e.pos_y = static_cast(atof(row[5])); + e.pos_x = static_cast(atof(row[6])); + e.pos_z = static_cast(atof(row[7])); + e.heading = static_cast(atof(row[8])); + e.opentype = atoi(row[9]); + e.guild = atoi(row[10]); + e.lockpick = atoi(row[11]); + e.keyitem = atoi(row[12]); + e.nokeyring = atoi(row[13]); + e.triggerdoor = atoi(row[14]); + e.triggertype = atoi(row[15]); + e.disable_timer = atoi(row[16]); + e.doorisopen = atoi(row[17]); + e.door_param = atoi(row[18]); + e.dest_zone = row[19] ? row[19] : ""; + e.dest_instance = atoi(row[20]); + e.dest_x = static_cast(atof(row[21])); + e.dest_y = static_cast(atof(row[22])); + e.dest_z = static_cast(atof(row[23])); + e.dest_heading = static_cast(atof(row[24])); + e.invert_state = atoi(row[25]); + e.incline = atoi(row[26]); + e.size = atoi(row[27]); + e.buffer = static_cast(atof(row[28])); + e.client_version_mask = atoi(row[29]); + e.is_ldon_door = atoi(row[30]); + e.dz_switch_id = atoi(row[31]); + e.min_expansion = atoi(row[32]); + e.max_expansion = atoi(row[33]); + e.content_flags = row[34] ? row[34] : ""; + e.content_flags_disabled = row[35] ? row[35] : ""; - all_entries.push_back(entry); + all_entries.push_back(e); } return all_entries; } - static int DeleteWhere(Database& db, std::string where_filter) + static int DeleteWhere(Database& db, const std::string &where_filter) { auto results = db.QueryDatabase( fmt::format( @@ -641,6 +641,32 @@ public: 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); + } + }; #endif //EQEMU_BASE_DOORS_REPOSITORY_H diff --git a/common/repositories/base/base_dynamic_zone_members_repository.h b/common/repositories/base/base_dynamic_zone_members_repository.h index 42c37bc53..b0846fa83 100644 --- a/common/repositories/base/base_dynamic_zone_members_repository.h +++ b/common/repositories/base/base_dynamic_zone_members_repository.h @@ -82,16 +82,16 @@ public: static DynamicZoneMembers NewEntity() { - DynamicZoneMembers entry{}; + DynamicZoneMembers e{}; - entry.id = 0; - entry.dynamic_zone_id = 0; - entry.character_id = 0; + e.id = 0; + e.dynamic_zone_id = 0; + e.character_id = 0; - return entry; + return e; } - static DynamicZoneMembers GetDynamicZoneMembersEntry( + static DynamicZoneMembers GetDynamicZoneMembers( const std::vector &dynamic_zone_memberss, int dynamic_zone_members_id ) @@ -120,13 +120,13 @@ public: auto row = results.begin(); if (results.RowCount() == 1) { - DynamicZoneMembers entry{}; + DynamicZoneMembers e{}; - entry.id = atoi(row[0]); - entry.dynamic_zone_id = atoi(row[1]); - entry.character_id = atoi(row[2]); + e.id = atoi(row[0]); + e.dynamic_zone_id = atoi(row[1]); + e.character_id = atoi(row[2]); - return entry; + return e; } return NewEntity(); @@ -151,23 +151,23 @@ public: static int UpdateOne( Database& db, - DynamicZoneMembers dynamic_zone_members_entry + const DynamicZoneMembers &e ) { - std::vector update_values; + std::vector v; auto columns = Columns(); - update_values.push_back(columns[1] + " = " + std::to_string(dynamic_zone_members_entry.dynamic_zone_id)); - update_values.push_back(columns[2] + " = " + std::to_string(dynamic_zone_members_entry.character_id)); + v.push_back(columns[1] + " = " + std::to_string(e.dynamic_zone_id)); + v.push_back(columns[2] + " = " + std::to_string(e.character_id)); auto results = db.QueryDatabase( fmt::format( "UPDATE {} SET {} WHERE {} = {}", TableName(), - Strings::Implode(", ", update_values), + Strings::Implode(", ", v), PrimaryKey(), - dynamic_zone_members_entry.id + e.id ) ); @@ -176,51 +176,51 @@ public: static DynamicZoneMembers InsertOne( Database& db, - DynamicZoneMembers dynamic_zone_members_entry + DynamicZoneMembers e ) { - std::vector insert_values; + std::vector v; - insert_values.push_back(std::to_string(dynamic_zone_members_entry.id)); - insert_values.push_back(std::to_string(dynamic_zone_members_entry.dynamic_zone_id)); - insert_values.push_back(std::to_string(dynamic_zone_members_entry.character_id)); + v.push_back(std::to_string(e.id)); + v.push_back(std::to_string(e.dynamic_zone_id)); + v.push_back(std::to_string(e.character_id)); auto results = db.QueryDatabase( fmt::format( "{} VALUES ({})", BaseInsert(), - Strings::Implode(",", insert_values) + Strings::Implode(",", v) ) ); if (results.Success()) { - dynamic_zone_members_entry.id = results.LastInsertedID(); - return dynamic_zone_members_entry; + e.id = results.LastInsertedID(); + return e; } - dynamic_zone_members_entry = NewEntity(); + e = NewEntity(); - return dynamic_zone_members_entry; + return e; } static int InsertMany( Database& db, - std::vector dynamic_zone_members_entries + const std::vector &entries ) { std::vector insert_chunks; - for (auto &dynamic_zone_members_entry: dynamic_zone_members_entries) { - std::vector insert_values; + for (auto &e: entries) { + std::vector v; - insert_values.push_back(std::to_string(dynamic_zone_members_entry.id)); - insert_values.push_back(std::to_string(dynamic_zone_members_entry.dynamic_zone_id)); - insert_values.push_back(std::to_string(dynamic_zone_members_entry.character_id)); + v.push_back(std::to_string(e.id)); + v.push_back(std::to_string(e.dynamic_zone_id)); + v.push_back(std::to_string(e.character_id)); - insert_chunks.push_back("(" + Strings::Implode(",", insert_values) + ")"); + insert_chunks.push_back("(" + Strings::Implode(",", v) + ")"); } - std::vector insert_values; + std::vector v; auto results = db.QueryDatabase( fmt::format( @@ -247,19 +247,19 @@ public: all_entries.reserve(results.RowCount()); for (auto row = results.begin(); row != results.end(); ++row) { - DynamicZoneMembers entry{}; + DynamicZoneMembers e{}; - entry.id = atoi(row[0]); - entry.dynamic_zone_id = atoi(row[1]); - entry.character_id = atoi(row[2]); + e.id = atoi(row[0]); + e.dynamic_zone_id = atoi(row[1]); + e.character_id = atoi(row[2]); - all_entries.push_back(entry); + all_entries.push_back(e); } return all_entries; } - static std::vector GetWhere(Database& db, std::string where_filter) + static std::vector GetWhere(Database& db, const std::string &where_filter) { std::vector all_entries; @@ -274,19 +274,19 @@ public: all_entries.reserve(results.RowCount()); for (auto row = results.begin(); row != results.end(); ++row) { - DynamicZoneMembers entry{}; + DynamicZoneMembers e{}; - entry.id = atoi(row[0]); - entry.dynamic_zone_id = atoi(row[1]); - entry.character_id = atoi(row[2]); + e.id = atoi(row[0]); + e.dynamic_zone_id = atoi(row[1]); + e.character_id = atoi(row[2]); - all_entries.push_back(entry); + all_entries.push_back(e); } return all_entries; } - static int DeleteWhere(Database& db, std::string where_filter) + static int DeleteWhere(Database& db, const std::string &where_filter) { auto results = db.QueryDatabase( fmt::format( @@ -311,6 +311,32 @@ public: 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); + } + }; #endif //EQEMU_BASE_DYNAMIC_ZONE_MEMBERS_REPOSITORY_H diff --git a/common/repositories/base/base_dynamic_zone_templates_repository.h b/common/repositories/base/base_dynamic_zone_templates_repository.h index 0e71e30a4..e6b5b5dce 100644 --- a/common/repositories/base/base_dynamic_zone_templates_repository.h +++ b/common/repositories/base/base_dynamic_zone_templates_repository.h @@ -139,35 +139,35 @@ public: static DynamicZoneTemplates NewEntity() { - DynamicZoneTemplates entry{}; + DynamicZoneTemplates e{}; - entry.id = 0; - entry.zone_id = 0; - entry.zone_version = 0; - entry.name = ""; - entry.min_players = 0; - entry.max_players = 0; - entry.duration_seconds = 0; - entry.dz_switch_id = 0; - entry.compass_zone_id = 0; - entry.compass_x = 0; - entry.compass_y = 0; - entry.compass_z = 0; - entry.return_zone_id = 0; - entry.return_x = 0; - entry.return_y = 0; - entry.return_z = 0; - entry.return_h = 0; - entry.override_zone_in = 0; - entry.zone_in_x = 0; - entry.zone_in_y = 0; - entry.zone_in_z = 0; - entry.zone_in_h = 0; + e.id = 0; + e.zone_id = 0; + e.zone_version = 0; + e.name = ""; + e.min_players = 0; + e.max_players = 0; + e.duration_seconds = 0; + e.dz_switch_id = 0; + e.compass_zone_id = 0; + e.compass_x = 0; + e.compass_y = 0; + e.compass_z = 0; + e.return_zone_id = 0; + e.return_x = 0; + e.return_y = 0; + e.return_z = 0; + e.return_h = 0; + e.override_zone_in = 0; + e.zone_in_x = 0; + e.zone_in_y = 0; + e.zone_in_z = 0; + e.zone_in_h = 0; - return entry; + return e; } - static DynamicZoneTemplates GetDynamicZoneTemplatesEntry( + static DynamicZoneTemplates GetDynamicZoneTemplates( const std::vector &dynamic_zone_templatess, int dynamic_zone_templates_id ) @@ -196,32 +196,32 @@ public: auto row = results.begin(); if (results.RowCount() == 1) { - DynamicZoneTemplates entry{}; + DynamicZoneTemplates e{}; - entry.id = atoi(row[0]); - entry.zone_id = atoi(row[1]); - entry.zone_version = atoi(row[2]); - entry.name = row[3] ? row[3] : ""; - entry.min_players = atoi(row[4]); - entry.max_players = atoi(row[5]); - entry.duration_seconds = atoi(row[6]); - entry.dz_switch_id = atoi(row[7]); - entry.compass_zone_id = atoi(row[8]); - entry.compass_x = static_cast(atof(row[9])); - entry.compass_y = static_cast(atof(row[10])); - entry.compass_z = static_cast(atof(row[11])); - entry.return_zone_id = atoi(row[12]); - entry.return_x = static_cast(atof(row[13])); - entry.return_y = static_cast(atof(row[14])); - entry.return_z = static_cast(atof(row[15])); - entry.return_h = static_cast(atof(row[16])); - entry.override_zone_in = atoi(row[17]); - entry.zone_in_x = static_cast(atof(row[18])); - entry.zone_in_y = static_cast(atof(row[19])); - entry.zone_in_z = static_cast(atof(row[20])); - entry.zone_in_h = static_cast(atof(row[21])); + e.id = atoi(row[0]); + e.zone_id = atoi(row[1]); + e.zone_version = atoi(row[2]); + e.name = row[3] ? row[3] : ""; + e.min_players = atoi(row[4]); + e.max_players = atoi(row[5]); + e.duration_seconds = atoi(row[6]); + e.dz_switch_id = atoi(row[7]); + e.compass_zone_id = atoi(row[8]); + e.compass_x = static_cast(atof(row[9])); + e.compass_y = static_cast(atof(row[10])); + e.compass_z = static_cast(atof(row[11])); + e.return_zone_id = atoi(row[12]); + e.return_x = static_cast(atof(row[13])); + e.return_y = static_cast(atof(row[14])); + e.return_z = static_cast(atof(row[15])); + e.return_h = static_cast(atof(row[16])); + e.override_zone_in = atoi(row[17]); + e.zone_in_x = static_cast(atof(row[18])); + e.zone_in_y = static_cast(atof(row[19])); + e.zone_in_z = static_cast(atof(row[20])); + e.zone_in_h = static_cast(atof(row[21])); - return entry; + return e; } return NewEntity(); @@ -246,42 +246,42 @@ public: static int UpdateOne( Database& db, - DynamicZoneTemplates dynamic_zone_templates_entry + const DynamicZoneTemplates &e ) { - std::vector update_values; + std::vector v; auto columns = Columns(); - update_values.push_back(columns[1] + " = " + std::to_string(dynamic_zone_templates_entry.zone_id)); - update_values.push_back(columns[2] + " = " + std::to_string(dynamic_zone_templates_entry.zone_version)); - update_values.push_back(columns[3] + " = '" + Strings::Escape(dynamic_zone_templates_entry.name) + "'"); - update_values.push_back(columns[4] + " = " + std::to_string(dynamic_zone_templates_entry.min_players)); - update_values.push_back(columns[5] + " = " + std::to_string(dynamic_zone_templates_entry.max_players)); - update_values.push_back(columns[6] + " = " + std::to_string(dynamic_zone_templates_entry.duration_seconds)); - update_values.push_back(columns[7] + " = " + std::to_string(dynamic_zone_templates_entry.dz_switch_id)); - update_values.push_back(columns[8] + " = " + std::to_string(dynamic_zone_templates_entry.compass_zone_id)); - update_values.push_back(columns[9] + " = " + std::to_string(dynamic_zone_templates_entry.compass_x)); - update_values.push_back(columns[10] + " = " + std::to_string(dynamic_zone_templates_entry.compass_y)); - update_values.push_back(columns[11] + " = " + std::to_string(dynamic_zone_templates_entry.compass_z)); - update_values.push_back(columns[12] + " = " + std::to_string(dynamic_zone_templates_entry.return_zone_id)); - update_values.push_back(columns[13] + " = " + std::to_string(dynamic_zone_templates_entry.return_x)); - update_values.push_back(columns[14] + " = " + std::to_string(dynamic_zone_templates_entry.return_y)); - update_values.push_back(columns[15] + " = " + std::to_string(dynamic_zone_templates_entry.return_z)); - update_values.push_back(columns[16] + " = " + std::to_string(dynamic_zone_templates_entry.return_h)); - update_values.push_back(columns[17] + " = " + std::to_string(dynamic_zone_templates_entry.override_zone_in)); - update_values.push_back(columns[18] + " = " + std::to_string(dynamic_zone_templates_entry.zone_in_x)); - update_values.push_back(columns[19] + " = " + std::to_string(dynamic_zone_templates_entry.zone_in_y)); - update_values.push_back(columns[20] + " = " + std::to_string(dynamic_zone_templates_entry.zone_in_z)); - update_values.push_back(columns[21] + " = " + std::to_string(dynamic_zone_templates_entry.zone_in_h)); + v.push_back(columns[1] + " = " + std::to_string(e.zone_id)); + v.push_back(columns[2] + " = " + std::to_string(e.zone_version)); + v.push_back(columns[3] + " = '" + Strings::Escape(e.name) + "'"); + v.push_back(columns[4] + " = " + std::to_string(e.min_players)); + v.push_back(columns[5] + " = " + std::to_string(e.max_players)); + v.push_back(columns[6] + " = " + std::to_string(e.duration_seconds)); + v.push_back(columns[7] + " = " + std::to_string(e.dz_switch_id)); + v.push_back(columns[8] + " = " + std::to_string(e.compass_zone_id)); + v.push_back(columns[9] + " = " + std::to_string(e.compass_x)); + v.push_back(columns[10] + " = " + std::to_string(e.compass_y)); + v.push_back(columns[11] + " = " + std::to_string(e.compass_z)); + v.push_back(columns[12] + " = " + std::to_string(e.return_zone_id)); + v.push_back(columns[13] + " = " + std::to_string(e.return_x)); + v.push_back(columns[14] + " = " + std::to_string(e.return_y)); + v.push_back(columns[15] + " = " + std::to_string(e.return_z)); + v.push_back(columns[16] + " = " + std::to_string(e.return_h)); + v.push_back(columns[17] + " = " + std::to_string(e.override_zone_in)); + v.push_back(columns[18] + " = " + std::to_string(e.zone_in_x)); + v.push_back(columns[19] + " = " + std::to_string(e.zone_in_y)); + v.push_back(columns[20] + " = " + std::to_string(e.zone_in_z)); + v.push_back(columns[21] + " = " + std::to_string(e.zone_in_h)); auto results = db.QueryDatabase( fmt::format( "UPDATE {} SET {} WHERE {} = {}", TableName(), - Strings::Implode(", ", update_values), + Strings::Implode(", ", v), PrimaryKey(), - dynamic_zone_templates_entry.id + e.id ) ); @@ -290,89 +290,89 @@ public: static DynamicZoneTemplates InsertOne( Database& db, - DynamicZoneTemplates dynamic_zone_templates_entry + DynamicZoneTemplates e ) { - std::vector insert_values; + std::vector v; - insert_values.push_back(std::to_string(dynamic_zone_templates_entry.id)); - insert_values.push_back(std::to_string(dynamic_zone_templates_entry.zone_id)); - insert_values.push_back(std::to_string(dynamic_zone_templates_entry.zone_version)); - insert_values.push_back("'" + Strings::Escape(dynamic_zone_templates_entry.name) + "'"); - insert_values.push_back(std::to_string(dynamic_zone_templates_entry.min_players)); - insert_values.push_back(std::to_string(dynamic_zone_templates_entry.max_players)); - insert_values.push_back(std::to_string(dynamic_zone_templates_entry.duration_seconds)); - insert_values.push_back(std::to_string(dynamic_zone_templates_entry.dz_switch_id)); - insert_values.push_back(std::to_string(dynamic_zone_templates_entry.compass_zone_id)); - insert_values.push_back(std::to_string(dynamic_zone_templates_entry.compass_x)); - insert_values.push_back(std::to_string(dynamic_zone_templates_entry.compass_y)); - insert_values.push_back(std::to_string(dynamic_zone_templates_entry.compass_z)); - insert_values.push_back(std::to_string(dynamic_zone_templates_entry.return_zone_id)); - insert_values.push_back(std::to_string(dynamic_zone_templates_entry.return_x)); - insert_values.push_back(std::to_string(dynamic_zone_templates_entry.return_y)); - insert_values.push_back(std::to_string(dynamic_zone_templates_entry.return_z)); - insert_values.push_back(std::to_string(dynamic_zone_templates_entry.return_h)); - insert_values.push_back(std::to_string(dynamic_zone_templates_entry.override_zone_in)); - insert_values.push_back(std::to_string(dynamic_zone_templates_entry.zone_in_x)); - insert_values.push_back(std::to_string(dynamic_zone_templates_entry.zone_in_y)); - insert_values.push_back(std::to_string(dynamic_zone_templates_entry.zone_in_z)); - insert_values.push_back(std::to_string(dynamic_zone_templates_entry.zone_in_h)); + v.push_back(std::to_string(e.id)); + v.push_back(std::to_string(e.zone_id)); + v.push_back(std::to_string(e.zone_version)); + v.push_back("'" + Strings::Escape(e.name) + "'"); + v.push_back(std::to_string(e.min_players)); + v.push_back(std::to_string(e.max_players)); + v.push_back(std::to_string(e.duration_seconds)); + v.push_back(std::to_string(e.dz_switch_id)); + v.push_back(std::to_string(e.compass_zone_id)); + v.push_back(std::to_string(e.compass_x)); + v.push_back(std::to_string(e.compass_y)); + v.push_back(std::to_string(e.compass_z)); + v.push_back(std::to_string(e.return_zone_id)); + v.push_back(std::to_string(e.return_x)); + v.push_back(std::to_string(e.return_y)); + v.push_back(std::to_string(e.return_z)); + v.push_back(std::to_string(e.return_h)); + v.push_back(std::to_string(e.override_zone_in)); + v.push_back(std::to_string(e.zone_in_x)); + v.push_back(std::to_string(e.zone_in_y)); + v.push_back(std::to_string(e.zone_in_z)); + v.push_back(std::to_string(e.zone_in_h)); auto results = db.QueryDatabase( fmt::format( "{} VALUES ({})", BaseInsert(), - Strings::Implode(",", insert_values) + Strings::Implode(",", v) ) ); if (results.Success()) { - dynamic_zone_templates_entry.id = results.LastInsertedID(); - return dynamic_zone_templates_entry; + e.id = results.LastInsertedID(); + return e; } - dynamic_zone_templates_entry = NewEntity(); + e = NewEntity(); - return dynamic_zone_templates_entry; + return e; } static int InsertMany( Database& db, - std::vector dynamic_zone_templates_entries + const std::vector &entries ) { std::vector insert_chunks; - for (auto &dynamic_zone_templates_entry: dynamic_zone_templates_entries) { - std::vector insert_values; + for (auto &e: entries) { + std::vector v; - insert_values.push_back(std::to_string(dynamic_zone_templates_entry.id)); - insert_values.push_back(std::to_string(dynamic_zone_templates_entry.zone_id)); - insert_values.push_back(std::to_string(dynamic_zone_templates_entry.zone_version)); - insert_values.push_back("'" + Strings::Escape(dynamic_zone_templates_entry.name) + "'"); - insert_values.push_back(std::to_string(dynamic_zone_templates_entry.min_players)); - insert_values.push_back(std::to_string(dynamic_zone_templates_entry.max_players)); - insert_values.push_back(std::to_string(dynamic_zone_templates_entry.duration_seconds)); - insert_values.push_back(std::to_string(dynamic_zone_templates_entry.dz_switch_id)); - insert_values.push_back(std::to_string(dynamic_zone_templates_entry.compass_zone_id)); - insert_values.push_back(std::to_string(dynamic_zone_templates_entry.compass_x)); - insert_values.push_back(std::to_string(dynamic_zone_templates_entry.compass_y)); - insert_values.push_back(std::to_string(dynamic_zone_templates_entry.compass_z)); - insert_values.push_back(std::to_string(dynamic_zone_templates_entry.return_zone_id)); - insert_values.push_back(std::to_string(dynamic_zone_templates_entry.return_x)); - insert_values.push_back(std::to_string(dynamic_zone_templates_entry.return_y)); - insert_values.push_back(std::to_string(dynamic_zone_templates_entry.return_z)); - insert_values.push_back(std::to_string(dynamic_zone_templates_entry.return_h)); - insert_values.push_back(std::to_string(dynamic_zone_templates_entry.override_zone_in)); - insert_values.push_back(std::to_string(dynamic_zone_templates_entry.zone_in_x)); - insert_values.push_back(std::to_string(dynamic_zone_templates_entry.zone_in_y)); - insert_values.push_back(std::to_string(dynamic_zone_templates_entry.zone_in_z)); - insert_values.push_back(std::to_string(dynamic_zone_templates_entry.zone_in_h)); + v.push_back(std::to_string(e.id)); + v.push_back(std::to_string(e.zone_id)); + v.push_back(std::to_string(e.zone_version)); + v.push_back("'" + Strings::Escape(e.name) + "'"); + v.push_back(std::to_string(e.min_players)); + v.push_back(std::to_string(e.max_players)); + v.push_back(std::to_string(e.duration_seconds)); + v.push_back(std::to_string(e.dz_switch_id)); + v.push_back(std::to_string(e.compass_zone_id)); + v.push_back(std::to_string(e.compass_x)); + v.push_back(std::to_string(e.compass_y)); + v.push_back(std::to_string(e.compass_z)); + v.push_back(std::to_string(e.return_zone_id)); + v.push_back(std::to_string(e.return_x)); + v.push_back(std::to_string(e.return_y)); + v.push_back(std::to_string(e.return_z)); + v.push_back(std::to_string(e.return_h)); + v.push_back(std::to_string(e.override_zone_in)); + v.push_back(std::to_string(e.zone_in_x)); + v.push_back(std::to_string(e.zone_in_y)); + v.push_back(std::to_string(e.zone_in_z)); + v.push_back(std::to_string(e.zone_in_h)); - insert_chunks.push_back("(" + Strings::Implode(",", insert_values) + ")"); + insert_chunks.push_back("(" + Strings::Implode(",", v) + ")"); } - std::vector insert_values; + std::vector v; auto results = db.QueryDatabase( fmt::format( @@ -399,38 +399,38 @@ public: all_entries.reserve(results.RowCount()); for (auto row = results.begin(); row != results.end(); ++row) { - DynamicZoneTemplates entry{}; + DynamicZoneTemplates e{}; - entry.id = atoi(row[0]); - entry.zone_id = atoi(row[1]); - entry.zone_version = atoi(row[2]); - entry.name = row[3] ? row[3] : ""; - entry.min_players = atoi(row[4]); - entry.max_players = atoi(row[5]); - entry.duration_seconds = atoi(row[6]); - entry.dz_switch_id = atoi(row[7]); - entry.compass_zone_id = atoi(row[8]); - entry.compass_x = static_cast(atof(row[9])); - entry.compass_y = static_cast(atof(row[10])); - entry.compass_z = static_cast(atof(row[11])); - entry.return_zone_id = atoi(row[12]); - entry.return_x = static_cast(atof(row[13])); - entry.return_y = static_cast(atof(row[14])); - entry.return_z = static_cast(atof(row[15])); - entry.return_h = static_cast(atof(row[16])); - entry.override_zone_in = atoi(row[17]); - entry.zone_in_x = static_cast(atof(row[18])); - entry.zone_in_y = static_cast(atof(row[19])); - entry.zone_in_z = static_cast(atof(row[20])); - entry.zone_in_h = static_cast(atof(row[21])); + e.id = atoi(row[0]); + e.zone_id = atoi(row[1]); + e.zone_version = atoi(row[2]); + e.name = row[3] ? row[3] : ""; + e.min_players = atoi(row[4]); + e.max_players = atoi(row[5]); + e.duration_seconds = atoi(row[6]); + e.dz_switch_id = atoi(row[7]); + e.compass_zone_id = atoi(row[8]); + e.compass_x = static_cast(atof(row[9])); + e.compass_y = static_cast(atof(row[10])); + e.compass_z = static_cast(atof(row[11])); + e.return_zone_id = atoi(row[12]); + e.return_x = static_cast(atof(row[13])); + e.return_y = static_cast(atof(row[14])); + e.return_z = static_cast(atof(row[15])); + e.return_h = static_cast(atof(row[16])); + e.override_zone_in = atoi(row[17]); + e.zone_in_x = static_cast(atof(row[18])); + e.zone_in_y = static_cast(atof(row[19])); + e.zone_in_z = static_cast(atof(row[20])); + e.zone_in_h = static_cast(atof(row[21])); - all_entries.push_back(entry); + all_entries.push_back(e); } return all_entries; } - static std::vector GetWhere(Database& db, std::string where_filter) + static std::vector GetWhere(Database& db, const std::string &where_filter) { std::vector all_entries; @@ -445,38 +445,38 @@ public: all_entries.reserve(results.RowCount()); for (auto row = results.begin(); row != results.end(); ++row) { - DynamicZoneTemplates entry{}; + DynamicZoneTemplates e{}; - entry.id = atoi(row[0]); - entry.zone_id = atoi(row[1]); - entry.zone_version = atoi(row[2]); - entry.name = row[3] ? row[3] : ""; - entry.min_players = atoi(row[4]); - entry.max_players = atoi(row[5]); - entry.duration_seconds = atoi(row[6]); - entry.dz_switch_id = atoi(row[7]); - entry.compass_zone_id = atoi(row[8]); - entry.compass_x = static_cast(atof(row[9])); - entry.compass_y = static_cast(atof(row[10])); - entry.compass_z = static_cast(atof(row[11])); - entry.return_zone_id = atoi(row[12]); - entry.return_x = static_cast(atof(row[13])); - entry.return_y = static_cast(atof(row[14])); - entry.return_z = static_cast(atof(row[15])); - entry.return_h = static_cast(atof(row[16])); - entry.override_zone_in = atoi(row[17]); - entry.zone_in_x = static_cast(atof(row[18])); - entry.zone_in_y = static_cast(atof(row[19])); - entry.zone_in_z = static_cast(atof(row[20])); - entry.zone_in_h = static_cast(atof(row[21])); + e.id = atoi(row[0]); + e.zone_id = atoi(row[1]); + e.zone_version = atoi(row[2]); + e.name = row[3] ? row[3] : ""; + e.min_players = atoi(row[4]); + e.max_players = atoi(row[5]); + e.duration_seconds = atoi(row[6]); + e.dz_switch_id = atoi(row[7]); + e.compass_zone_id = atoi(row[8]); + e.compass_x = static_cast(atof(row[9])); + e.compass_y = static_cast(atof(row[10])); + e.compass_z = static_cast(atof(row[11])); + e.return_zone_id = atoi(row[12]); + e.return_x = static_cast(atof(row[13])); + e.return_y = static_cast(atof(row[14])); + e.return_z = static_cast(atof(row[15])); + e.return_h = static_cast(atof(row[16])); + e.override_zone_in = atoi(row[17]); + e.zone_in_x = static_cast(atof(row[18])); + e.zone_in_y = static_cast(atof(row[19])); + e.zone_in_z = static_cast(atof(row[20])); + e.zone_in_h = static_cast(atof(row[21])); - all_entries.push_back(entry); + all_entries.push_back(e); } return all_entries; } - static int DeleteWhere(Database& db, std::string where_filter) + static int DeleteWhere(Database& db, const std::string &where_filter) { auto results = db.QueryDatabase( fmt::format( @@ -501,6 +501,32 @@ public: 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); + } + }; #endif //EQEMU_BASE_DYNAMIC_ZONE_TEMPLATES_REPOSITORY_H diff --git a/common/repositories/base/base_dynamic_zones_repository.h b/common/repositories/base/base_dynamic_zones_repository.h index 69cd8d3fa..723a84a8f 100644 --- a/common/repositories/base/base_dynamic_zones_repository.h +++ b/common/repositories/base/base_dynamic_zones_repository.h @@ -142,36 +142,36 @@ public: static DynamicZones NewEntity() { - DynamicZones entry{}; + DynamicZones e{}; - entry.id = 0; - entry.instance_id = 0; - entry.type = 0; - entry.uuid = ""; - entry.name = ""; - entry.leader_id = 0; - entry.min_players = 0; - entry.max_players = 0; - entry.dz_switch_id = 0; - entry.compass_zone_id = 0; - entry.compass_x = 0; - entry.compass_y = 0; - entry.compass_z = 0; - entry.safe_return_zone_id = 0; - entry.safe_return_x = 0; - entry.safe_return_y = 0; - entry.safe_return_z = 0; - entry.safe_return_heading = 0; - entry.zone_in_x = 0; - entry.zone_in_y = 0; - entry.zone_in_z = 0; - entry.zone_in_heading = 0; - entry.has_zone_in = 0; + e.id = 0; + e.instance_id = 0; + e.type = 0; + e.uuid = ""; + e.name = ""; + e.leader_id = 0; + e.min_players = 0; + e.max_players = 0; + e.dz_switch_id = 0; + e.compass_zone_id = 0; + e.compass_x = 0; + e.compass_y = 0; + e.compass_z = 0; + e.safe_return_zone_id = 0; + e.safe_return_x = 0; + e.safe_return_y = 0; + e.safe_return_z = 0; + e.safe_return_heading = 0; + e.zone_in_x = 0; + e.zone_in_y = 0; + e.zone_in_z = 0; + e.zone_in_heading = 0; + e.has_zone_in = 0; - return entry; + return e; } - static DynamicZones GetDynamicZonesEntry( + static DynamicZones GetDynamicZones( const std::vector &dynamic_zoness, int dynamic_zones_id ) @@ -200,33 +200,33 @@ public: auto row = results.begin(); if (results.RowCount() == 1) { - DynamicZones entry{}; + DynamicZones e{}; - entry.id = atoi(row[0]); - entry.instance_id = atoi(row[1]); - entry.type = atoi(row[2]); - entry.uuid = row[3] ? row[3] : ""; - entry.name = row[4] ? row[4] : ""; - entry.leader_id = atoi(row[5]); - entry.min_players = atoi(row[6]); - entry.max_players = atoi(row[7]); - entry.dz_switch_id = atoi(row[8]); - entry.compass_zone_id = atoi(row[9]); - entry.compass_x = static_cast(atof(row[10])); - entry.compass_y = static_cast(atof(row[11])); - entry.compass_z = static_cast(atof(row[12])); - entry.safe_return_zone_id = atoi(row[13]); - entry.safe_return_x = static_cast(atof(row[14])); - entry.safe_return_y = static_cast(atof(row[15])); - entry.safe_return_z = static_cast(atof(row[16])); - entry.safe_return_heading = static_cast(atof(row[17])); - entry.zone_in_x = static_cast(atof(row[18])); - entry.zone_in_y = static_cast(atof(row[19])); - entry.zone_in_z = static_cast(atof(row[20])); - entry.zone_in_heading = static_cast(atof(row[21])); - entry.has_zone_in = atoi(row[22]); + e.id = atoi(row[0]); + e.instance_id = atoi(row[1]); + e.type = atoi(row[2]); + e.uuid = row[3] ? row[3] : ""; + e.name = row[4] ? row[4] : ""; + e.leader_id = atoi(row[5]); + e.min_players = atoi(row[6]); + e.max_players = atoi(row[7]); + e.dz_switch_id = atoi(row[8]); + e.compass_zone_id = atoi(row[9]); + e.compass_x = static_cast(atof(row[10])); + e.compass_y = static_cast(atof(row[11])); + e.compass_z = static_cast(atof(row[12])); + e.safe_return_zone_id = atoi(row[13]); + e.safe_return_x = static_cast(atof(row[14])); + e.safe_return_y = static_cast(atof(row[15])); + e.safe_return_z = static_cast(atof(row[16])); + e.safe_return_heading = static_cast(atof(row[17])); + e.zone_in_x = static_cast(atof(row[18])); + e.zone_in_y = static_cast(atof(row[19])); + e.zone_in_z = static_cast(atof(row[20])); + e.zone_in_heading = static_cast(atof(row[21])); + e.has_zone_in = atoi(row[22]); - return entry; + return e; } return NewEntity(); @@ -251,43 +251,43 @@ public: static int UpdateOne( Database& db, - DynamicZones dynamic_zones_entry + const DynamicZones &e ) { - std::vector update_values; + std::vector v; auto columns = Columns(); - update_values.push_back(columns[1] + " = " + std::to_string(dynamic_zones_entry.instance_id)); - update_values.push_back(columns[2] + " = " + std::to_string(dynamic_zones_entry.type)); - update_values.push_back(columns[3] + " = '" + Strings::Escape(dynamic_zones_entry.uuid) + "'"); - update_values.push_back(columns[4] + " = '" + Strings::Escape(dynamic_zones_entry.name) + "'"); - update_values.push_back(columns[5] + " = " + std::to_string(dynamic_zones_entry.leader_id)); - update_values.push_back(columns[6] + " = " + std::to_string(dynamic_zones_entry.min_players)); - update_values.push_back(columns[7] + " = " + std::to_string(dynamic_zones_entry.max_players)); - update_values.push_back(columns[8] + " = " + std::to_string(dynamic_zones_entry.dz_switch_id)); - update_values.push_back(columns[9] + " = " + std::to_string(dynamic_zones_entry.compass_zone_id)); - update_values.push_back(columns[10] + " = " + std::to_string(dynamic_zones_entry.compass_x)); - update_values.push_back(columns[11] + " = " + std::to_string(dynamic_zones_entry.compass_y)); - update_values.push_back(columns[12] + " = " + std::to_string(dynamic_zones_entry.compass_z)); - update_values.push_back(columns[13] + " = " + std::to_string(dynamic_zones_entry.safe_return_zone_id)); - update_values.push_back(columns[14] + " = " + std::to_string(dynamic_zones_entry.safe_return_x)); - update_values.push_back(columns[15] + " = " + std::to_string(dynamic_zones_entry.safe_return_y)); - update_values.push_back(columns[16] + " = " + std::to_string(dynamic_zones_entry.safe_return_z)); - update_values.push_back(columns[17] + " = " + std::to_string(dynamic_zones_entry.safe_return_heading)); - update_values.push_back(columns[18] + " = " + std::to_string(dynamic_zones_entry.zone_in_x)); - update_values.push_back(columns[19] + " = " + std::to_string(dynamic_zones_entry.zone_in_y)); - update_values.push_back(columns[20] + " = " + std::to_string(dynamic_zones_entry.zone_in_z)); - update_values.push_back(columns[21] + " = " + std::to_string(dynamic_zones_entry.zone_in_heading)); - update_values.push_back(columns[22] + " = " + std::to_string(dynamic_zones_entry.has_zone_in)); + v.push_back(columns[1] + " = " + std::to_string(e.instance_id)); + v.push_back(columns[2] + " = " + std::to_string(e.type)); + v.push_back(columns[3] + " = '" + Strings::Escape(e.uuid) + "'"); + v.push_back(columns[4] + " = '" + Strings::Escape(e.name) + "'"); + v.push_back(columns[5] + " = " + std::to_string(e.leader_id)); + v.push_back(columns[6] + " = " + std::to_string(e.min_players)); + v.push_back(columns[7] + " = " + std::to_string(e.max_players)); + v.push_back(columns[8] + " = " + std::to_string(e.dz_switch_id)); + v.push_back(columns[9] + " = " + std::to_string(e.compass_zone_id)); + v.push_back(columns[10] + " = " + std::to_string(e.compass_x)); + v.push_back(columns[11] + " = " + std::to_string(e.compass_y)); + v.push_back(columns[12] + " = " + std::to_string(e.compass_z)); + v.push_back(columns[13] + " = " + std::to_string(e.safe_return_zone_id)); + v.push_back(columns[14] + " = " + std::to_string(e.safe_return_x)); + v.push_back(columns[15] + " = " + std::to_string(e.safe_return_y)); + v.push_back(columns[16] + " = " + std::to_string(e.safe_return_z)); + v.push_back(columns[17] + " = " + std::to_string(e.safe_return_heading)); + v.push_back(columns[18] + " = " + std::to_string(e.zone_in_x)); + v.push_back(columns[19] + " = " + std::to_string(e.zone_in_y)); + v.push_back(columns[20] + " = " + std::to_string(e.zone_in_z)); + v.push_back(columns[21] + " = " + std::to_string(e.zone_in_heading)); + v.push_back(columns[22] + " = " + std::to_string(e.has_zone_in)); auto results = db.QueryDatabase( fmt::format( "UPDATE {} SET {} WHERE {} = {}", TableName(), - Strings::Implode(", ", update_values), + Strings::Implode(", ", v), PrimaryKey(), - dynamic_zones_entry.id + e.id ) ); @@ -296,91 +296,91 @@ public: static DynamicZones InsertOne( Database& db, - DynamicZones dynamic_zones_entry + DynamicZones e ) { - std::vector insert_values; + std::vector v; - insert_values.push_back(std::to_string(dynamic_zones_entry.id)); - insert_values.push_back(std::to_string(dynamic_zones_entry.instance_id)); - insert_values.push_back(std::to_string(dynamic_zones_entry.type)); - insert_values.push_back("'" + Strings::Escape(dynamic_zones_entry.uuid) + "'"); - insert_values.push_back("'" + Strings::Escape(dynamic_zones_entry.name) + "'"); - insert_values.push_back(std::to_string(dynamic_zones_entry.leader_id)); - insert_values.push_back(std::to_string(dynamic_zones_entry.min_players)); - insert_values.push_back(std::to_string(dynamic_zones_entry.max_players)); - insert_values.push_back(std::to_string(dynamic_zones_entry.dz_switch_id)); - insert_values.push_back(std::to_string(dynamic_zones_entry.compass_zone_id)); - insert_values.push_back(std::to_string(dynamic_zones_entry.compass_x)); - insert_values.push_back(std::to_string(dynamic_zones_entry.compass_y)); - insert_values.push_back(std::to_string(dynamic_zones_entry.compass_z)); - insert_values.push_back(std::to_string(dynamic_zones_entry.safe_return_zone_id)); - insert_values.push_back(std::to_string(dynamic_zones_entry.safe_return_x)); - insert_values.push_back(std::to_string(dynamic_zones_entry.safe_return_y)); - insert_values.push_back(std::to_string(dynamic_zones_entry.safe_return_z)); - insert_values.push_back(std::to_string(dynamic_zones_entry.safe_return_heading)); - insert_values.push_back(std::to_string(dynamic_zones_entry.zone_in_x)); - insert_values.push_back(std::to_string(dynamic_zones_entry.zone_in_y)); - insert_values.push_back(std::to_string(dynamic_zones_entry.zone_in_z)); - insert_values.push_back(std::to_string(dynamic_zones_entry.zone_in_heading)); - insert_values.push_back(std::to_string(dynamic_zones_entry.has_zone_in)); + v.push_back(std::to_string(e.id)); + v.push_back(std::to_string(e.instance_id)); + v.push_back(std::to_string(e.type)); + v.push_back("'" + Strings::Escape(e.uuid) + "'"); + v.push_back("'" + Strings::Escape(e.name) + "'"); + v.push_back(std::to_string(e.leader_id)); + v.push_back(std::to_string(e.min_players)); + v.push_back(std::to_string(e.max_players)); + v.push_back(std::to_string(e.dz_switch_id)); + v.push_back(std::to_string(e.compass_zone_id)); + v.push_back(std::to_string(e.compass_x)); + v.push_back(std::to_string(e.compass_y)); + v.push_back(std::to_string(e.compass_z)); + v.push_back(std::to_string(e.safe_return_zone_id)); + v.push_back(std::to_string(e.safe_return_x)); + v.push_back(std::to_string(e.safe_return_y)); + v.push_back(std::to_string(e.safe_return_z)); + v.push_back(std::to_string(e.safe_return_heading)); + v.push_back(std::to_string(e.zone_in_x)); + v.push_back(std::to_string(e.zone_in_y)); + v.push_back(std::to_string(e.zone_in_z)); + v.push_back(std::to_string(e.zone_in_heading)); + v.push_back(std::to_string(e.has_zone_in)); auto results = db.QueryDatabase( fmt::format( "{} VALUES ({})", BaseInsert(), - Strings::Implode(",", insert_values) + Strings::Implode(",", v) ) ); if (results.Success()) { - dynamic_zones_entry.id = results.LastInsertedID(); - return dynamic_zones_entry; + e.id = results.LastInsertedID(); + return e; } - dynamic_zones_entry = NewEntity(); + e = NewEntity(); - return dynamic_zones_entry; + return e; } static int InsertMany( Database& db, - std::vector dynamic_zones_entries + const std::vector &entries ) { std::vector insert_chunks; - for (auto &dynamic_zones_entry: dynamic_zones_entries) { - std::vector insert_values; + for (auto &e: entries) { + std::vector v; - insert_values.push_back(std::to_string(dynamic_zones_entry.id)); - insert_values.push_back(std::to_string(dynamic_zones_entry.instance_id)); - insert_values.push_back(std::to_string(dynamic_zones_entry.type)); - insert_values.push_back("'" + Strings::Escape(dynamic_zones_entry.uuid) + "'"); - insert_values.push_back("'" + Strings::Escape(dynamic_zones_entry.name) + "'"); - insert_values.push_back(std::to_string(dynamic_zones_entry.leader_id)); - insert_values.push_back(std::to_string(dynamic_zones_entry.min_players)); - insert_values.push_back(std::to_string(dynamic_zones_entry.max_players)); - insert_values.push_back(std::to_string(dynamic_zones_entry.dz_switch_id)); - insert_values.push_back(std::to_string(dynamic_zones_entry.compass_zone_id)); - insert_values.push_back(std::to_string(dynamic_zones_entry.compass_x)); - insert_values.push_back(std::to_string(dynamic_zones_entry.compass_y)); - insert_values.push_back(std::to_string(dynamic_zones_entry.compass_z)); - insert_values.push_back(std::to_string(dynamic_zones_entry.safe_return_zone_id)); - insert_values.push_back(std::to_string(dynamic_zones_entry.safe_return_x)); - insert_values.push_back(std::to_string(dynamic_zones_entry.safe_return_y)); - insert_values.push_back(std::to_string(dynamic_zones_entry.safe_return_z)); - insert_values.push_back(std::to_string(dynamic_zones_entry.safe_return_heading)); - insert_values.push_back(std::to_string(dynamic_zones_entry.zone_in_x)); - insert_values.push_back(std::to_string(dynamic_zones_entry.zone_in_y)); - insert_values.push_back(std::to_string(dynamic_zones_entry.zone_in_z)); - insert_values.push_back(std::to_string(dynamic_zones_entry.zone_in_heading)); - insert_values.push_back(std::to_string(dynamic_zones_entry.has_zone_in)); + v.push_back(std::to_string(e.id)); + v.push_back(std::to_string(e.instance_id)); + v.push_back(std::to_string(e.type)); + v.push_back("'" + Strings::Escape(e.uuid) + "'"); + v.push_back("'" + Strings::Escape(e.name) + "'"); + v.push_back(std::to_string(e.leader_id)); + v.push_back(std::to_string(e.min_players)); + v.push_back(std::to_string(e.max_players)); + v.push_back(std::to_string(e.dz_switch_id)); + v.push_back(std::to_string(e.compass_zone_id)); + v.push_back(std::to_string(e.compass_x)); + v.push_back(std::to_string(e.compass_y)); + v.push_back(std::to_string(e.compass_z)); + v.push_back(std::to_string(e.safe_return_zone_id)); + v.push_back(std::to_string(e.safe_return_x)); + v.push_back(std::to_string(e.safe_return_y)); + v.push_back(std::to_string(e.safe_return_z)); + v.push_back(std::to_string(e.safe_return_heading)); + v.push_back(std::to_string(e.zone_in_x)); + v.push_back(std::to_string(e.zone_in_y)); + v.push_back(std::to_string(e.zone_in_z)); + v.push_back(std::to_string(e.zone_in_heading)); + v.push_back(std::to_string(e.has_zone_in)); - insert_chunks.push_back("(" + Strings::Implode(",", insert_values) + ")"); + insert_chunks.push_back("(" + Strings::Implode(",", v) + ")"); } - std::vector insert_values; + std::vector v; auto results = db.QueryDatabase( fmt::format( @@ -407,39 +407,39 @@ public: all_entries.reserve(results.RowCount()); for (auto row = results.begin(); row != results.end(); ++row) { - DynamicZones entry{}; + DynamicZones e{}; - entry.id = atoi(row[0]); - entry.instance_id = atoi(row[1]); - entry.type = atoi(row[2]); - entry.uuid = row[3] ? row[3] : ""; - entry.name = row[4] ? row[4] : ""; - entry.leader_id = atoi(row[5]); - entry.min_players = atoi(row[6]); - entry.max_players = atoi(row[7]); - entry.dz_switch_id = atoi(row[8]); - entry.compass_zone_id = atoi(row[9]); - entry.compass_x = static_cast(atof(row[10])); - entry.compass_y = static_cast(atof(row[11])); - entry.compass_z = static_cast(atof(row[12])); - entry.safe_return_zone_id = atoi(row[13]); - entry.safe_return_x = static_cast(atof(row[14])); - entry.safe_return_y = static_cast(atof(row[15])); - entry.safe_return_z = static_cast(atof(row[16])); - entry.safe_return_heading = static_cast(atof(row[17])); - entry.zone_in_x = static_cast(atof(row[18])); - entry.zone_in_y = static_cast(atof(row[19])); - entry.zone_in_z = static_cast(atof(row[20])); - entry.zone_in_heading = static_cast(atof(row[21])); - entry.has_zone_in = atoi(row[22]); + e.id = atoi(row[0]); + e.instance_id = atoi(row[1]); + e.type = atoi(row[2]); + e.uuid = row[3] ? row[3] : ""; + e.name = row[4] ? row[4] : ""; + e.leader_id = atoi(row[5]); + e.min_players = atoi(row[6]); + e.max_players = atoi(row[7]); + e.dz_switch_id = atoi(row[8]); + e.compass_zone_id = atoi(row[9]); + e.compass_x = static_cast(atof(row[10])); + e.compass_y = static_cast(atof(row[11])); + e.compass_z = static_cast(atof(row[12])); + e.safe_return_zone_id = atoi(row[13]); + e.safe_return_x = static_cast(atof(row[14])); + e.safe_return_y = static_cast(atof(row[15])); + e.safe_return_z = static_cast(atof(row[16])); + e.safe_return_heading = static_cast(atof(row[17])); + e.zone_in_x = static_cast(atof(row[18])); + e.zone_in_y = static_cast(atof(row[19])); + e.zone_in_z = static_cast(atof(row[20])); + e.zone_in_heading = static_cast(atof(row[21])); + e.has_zone_in = atoi(row[22]); - all_entries.push_back(entry); + all_entries.push_back(e); } return all_entries; } - static std::vector GetWhere(Database& db, std::string where_filter) + static std::vector GetWhere(Database& db, const std::string &where_filter) { std::vector all_entries; @@ -454,39 +454,39 @@ public: all_entries.reserve(results.RowCount()); for (auto row = results.begin(); row != results.end(); ++row) { - DynamicZones entry{}; + DynamicZones e{}; - entry.id = atoi(row[0]); - entry.instance_id = atoi(row[1]); - entry.type = atoi(row[2]); - entry.uuid = row[3] ? row[3] : ""; - entry.name = row[4] ? row[4] : ""; - entry.leader_id = atoi(row[5]); - entry.min_players = atoi(row[6]); - entry.max_players = atoi(row[7]); - entry.dz_switch_id = atoi(row[8]); - entry.compass_zone_id = atoi(row[9]); - entry.compass_x = static_cast(atof(row[10])); - entry.compass_y = static_cast(atof(row[11])); - entry.compass_z = static_cast(atof(row[12])); - entry.safe_return_zone_id = atoi(row[13]); - entry.safe_return_x = static_cast(atof(row[14])); - entry.safe_return_y = static_cast(atof(row[15])); - entry.safe_return_z = static_cast(atof(row[16])); - entry.safe_return_heading = static_cast(atof(row[17])); - entry.zone_in_x = static_cast(atof(row[18])); - entry.zone_in_y = static_cast(atof(row[19])); - entry.zone_in_z = static_cast(atof(row[20])); - entry.zone_in_heading = static_cast(atof(row[21])); - entry.has_zone_in = atoi(row[22]); + e.id = atoi(row[0]); + e.instance_id = atoi(row[1]); + e.type = atoi(row[2]); + e.uuid = row[3] ? row[3] : ""; + e.name = row[4] ? row[4] : ""; + e.leader_id = atoi(row[5]); + e.min_players = atoi(row[6]); + e.max_players = atoi(row[7]); + e.dz_switch_id = atoi(row[8]); + e.compass_zone_id = atoi(row[9]); + e.compass_x = static_cast(atof(row[10])); + e.compass_y = static_cast(atof(row[11])); + e.compass_z = static_cast(atof(row[12])); + e.safe_return_zone_id = atoi(row[13]); + e.safe_return_x = static_cast(atof(row[14])); + e.safe_return_y = static_cast(atof(row[15])); + e.safe_return_z = static_cast(atof(row[16])); + e.safe_return_heading = static_cast(atof(row[17])); + e.zone_in_x = static_cast(atof(row[18])); + e.zone_in_y = static_cast(atof(row[19])); + e.zone_in_z = static_cast(atof(row[20])); + e.zone_in_heading = static_cast(atof(row[21])); + e.has_zone_in = atoi(row[22]); - all_entries.push_back(entry); + all_entries.push_back(e); } return all_entries; } - static int DeleteWhere(Database& db, std::string where_filter) + static int DeleteWhere(Database& db, const std::string &where_filter) { auto results = db.QueryDatabase( fmt::format( @@ -511,6 +511,32 @@ public: 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); + } + }; #endif //EQEMU_BASE_DYNAMIC_ZONES_REPOSITORY_H diff --git a/common/repositories/base/base_eventlog_repository.h b/common/repositories/base/base_eventlog_repository.h index c89f34584..36d511100 100644 --- a/common/repositories/base/base_eventlog_repository.h +++ b/common/repositories/base/base_eventlog_repository.h @@ -103,23 +103,23 @@ public: static Eventlog NewEntity() { - Eventlog entry{}; + Eventlog e{}; - entry.id = 0; - entry.accountname = ""; - entry.accountid = 0; - entry.status = 0; - entry.charname = ""; - entry.target = "None"; - entry.time = std::time(nullptr); - entry.descriptiontype = ""; - entry.description = ""; - entry.event_nid = 0; + e.id = 0; + e.accountname = ""; + e.accountid = 0; + e.status = 0; + e.charname = ""; + e.target = "None"; + e.time = std::time(nullptr); + e.descriptiontype = ""; + e.description = ""; + e.event_nid = 0; - return entry; + return e; } - static Eventlog GetEventlogEntry( + static Eventlog GetEventlog( const std::vector &eventlogs, int eventlog_id ) @@ -148,20 +148,20 @@ public: auto row = results.begin(); if (results.RowCount() == 1) { - Eventlog entry{}; + Eventlog e{}; - entry.id = atoi(row[0]); - entry.accountname = row[1] ? row[1] : ""; - entry.accountid = atoi(row[2]); - entry.status = atoi(row[3]); - entry.charname = row[4] ? row[4] : ""; - entry.target = row[5] ? row[5] : ""; - entry.time = row[6] ? row[6] : ""; - entry.descriptiontype = row[7] ? row[7] : ""; - entry.description = row[8] ? row[8] : ""; - entry.event_nid = atoi(row[9]); + e.id = atoi(row[0]); + e.accountname = row[1] ? row[1] : ""; + e.accountid = atoi(row[2]); + e.status = atoi(row[3]); + e.charname = row[4] ? row[4] : ""; + e.target = row[5] ? row[5] : ""; + e.time = row[6] ? row[6] : ""; + e.descriptiontype = row[7] ? row[7] : ""; + e.description = row[8] ? row[8] : ""; + e.event_nid = atoi(row[9]); - return entry; + return e; } return NewEntity(); @@ -186,30 +186,30 @@ public: static int UpdateOne( Database& db, - Eventlog eventlog_entry + const Eventlog &e ) { - std::vector update_values; + std::vector v; auto columns = Columns(); - update_values.push_back(columns[1] + " = '" + Strings::Escape(eventlog_entry.accountname) + "'"); - update_values.push_back(columns[2] + " = " + std::to_string(eventlog_entry.accountid)); - update_values.push_back(columns[3] + " = " + std::to_string(eventlog_entry.status)); - update_values.push_back(columns[4] + " = '" + Strings::Escape(eventlog_entry.charname) + "'"); - update_values.push_back(columns[5] + " = '" + Strings::Escape(eventlog_entry.target) + "'"); - update_values.push_back(columns[6] + " = '" + Strings::Escape(eventlog_entry.time) + "'"); - update_values.push_back(columns[7] + " = '" + Strings::Escape(eventlog_entry.descriptiontype) + "'"); - update_values.push_back(columns[8] + " = '" + Strings::Escape(eventlog_entry.description) + "'"); - update_values.push_back(columns[9] + " = " + std::to_string(eventlog_entry.event_nid)); + v.push_back(columns[1] + " = '" + Strings::Escape(e.accountname) + "'"); + v.push_back(columns[2] + " = " + std::to_string(e.accountid)); + v.push_back(columns[3] + " = " + std::to_string(e.status)); + v.push_back(columns[4] + " = '" + Strings::Escape(e.charname) + "'"); + v.push_back(columns[5] + " = '" + Strings::Escape(e.target) + "'"); + v.push_back(columns[6] + " = '" + Strings::Escape(e.time) + "'"); + v.push_back(columns[7] + " = '" + Strings::Escape(e.descriptiontype) + "'"); + v.push_back(columns[8] + " = '" + Strings::Escape(e.description) + "'"); + v.push_back(columns[9] + " = " + std::to_string(e.event_nid)); auto results = db.QueryDatabase( fmt::format( "UPDATE {} SET {} WHERE {} = {}", TableName(), - Strings::Implode(", ", update_values), + Strings::Implode(", ", v), PrimaryKey(), - eventlog_entry.id + e.id ) ); @@ -218,65 +218,65 @@ public: static Eventlog InsertOne( Database& db, - Eventlog eventlog_entry + Eventlog e ) { - std::vector insert_values; + std::vector v; - insert_values.push_back(std::to_string(eventlog_entry.id)); - insert_values.push_back("'" + Strings::Escape(eventlog_entry.accountname) + "'"); - insert_values.push_back(std::to_string(eventlog_entry.accountid)); - insert_values.push_back(std::to_string(eventlog_entry.status)); - insert_values.push_back("'" + Strings::Escape(eventlog_entry.charname) + "'"); - insert_values.push_back("'" + Strings::Escape(eventlog_entry.target) + "'"); - insert_values.push_back("'" + Strings::Escape(eventlog_entry.time) + "'"); - insert_values.push_back("'" + Strings::Escape(eventlog_entry.descriptiontype) + "'"); - insert_values.push_back("'" + Strings::Escape(eventlog_entry.description) + "'"); - insert_values.push_back(std::to_string(eventlog_entry.event_nid)); + v.push_back(std::to_string(e.id)); + v.push_back("'" + Strings::Escape(e.accountname) + "'"); + v.push_back(std::to_string(e.accountid)); + v.push_back(std::to_string(e.status)); + v.push_back("'" + Strings::Escape(e.charname) + "'"); + v.push_back("'" + Strings::Escape(e.target) + "'"); + v.push_back("'" + Strings::Escape(e.time) + "'"); + v.push_back("'" + Strings::Escape(e.descriptiontype) + "'"); + v.push_back("'" + Strings::Escape(e.description) + "'"); + v.push_back(std::to_string(e.event_nid)); auto results = db.QueryDatabase( fmt::format( "{} VALUES ({})", BaseInsert(), - Strings::Implode(",", insert_values) + Strings::Implode(",", v) ) ); if (results.Success()) { - eventlog_entry.id = results.LastInsertedID(); - return eventlog_entry; + e.id = results.LastInsertedID(); + return e; } - eventlog_entry = NewEntity(); + e = NewEntity(); - return eventlog_entry; + return e; } static int InsertMany( Database& db, - std::vector eventlog_entries + const std::vector &entries ) { std::vector insert_chunks; - for (auto &eventlog_entry: eventlog_entries) { - std::vector insert_values; + for (auto &e: entries) { + std::vector v; - insert_values.push_back(std::to_string(eventlog_entry.id)); - insert_values.push_back("'" + Strings::Escape(eventlog_entry.accountname) + "'"); - insert_values.push_back(std::to_string(eventlog_entry.accountid)); - insert_values.push_back(std::to_string(eventlog_entry.status)); - insert_values.push_back("'" + Strings::Escape(eventlog_entry.charname) + "'"); - insert_values.push_back("'" + Strings::Escape(eventlog_entry.target) + "'"); - insert_values.push_back("'" + Strings::Escape(eventlog_entry.time) + "'"); - insert_values.push_back("'" + Strings::Escape(eventlog_entry.descriptiontype) + "'"); - insert_values.push_back("'" + Strings::Escape(eventlog_entry.description) + "'"); - insert_values.push_back(std::to_string(eventlog_entry.event_nid)); + v.push_back(std::to_string(e.id)); + v.push_back("'" + Strings::Escape(e.accountname) + "'"); + v.push_back(std::to_string(e.accountid)); + v.push_back(std::to_string(e.status)); + v.push_back("'" + Strings::Escape(e.charname) + "'"); + v.push_back("'" + Strings::Escape(e.target) + "'"); + v.push_back("'" + Strings::Escape(e.time) + "'"); + v.push_back("'" + Strings::Escape(e.descriptiontype) + "'"); + v.push_back("'" + Strings::Escape(e.description) + "'"); + v.push_back(std::to_string(e.event_nid)); - insert_chunks.push_back("(" + Strings::Implode(",", insert_values) + ")"); + insert_chunks.push_back("(" + Strings::Implode(",", v) + ")"); } - std::vector insert_values; + std::vector v; auto results = db.QueryDatabase( fmt::format( @@ -303,26 +303,26 @@ public: all_entries.reserve(results.RowCount()); for (auto row = results.begin(); row != results.end(); ++row) { - Eventlog entry{}; + Eventlog e{}; - entry.id = atoi(row[0]); - entry.accountname = row[1] ? row[1] : ""; - entry.accountid = atoi(row[2]); - entry.status = atoi(row[3]); - entry.charname = row[4] ? row[4] : ""; - entry.target = row[5] ? row[5] : ""; - entry.time = row[6] ? row[6] : ""; - entry.descriptiontype = row[7] ? row[7] : ""; - entry.description = row[8] ? row[8] : ""; - entry.event_nid = atoi(row[9]); + e.id = atoi(row[0]); + e.accountname = row[1] ? row[1] : ""; + e.accountid = atoi(row[2]); + e.status = atoi(row[3]); + e.charname = row[4] ? row[4] : ""; + e.target = row[5] ? row[5] : ""; + e.time = row[6] ? row[6] : ""; + e.descriptiontype = row[7] ? row[7] : ""; + e.description = row[8] ? row[8] : ""; + e.event_nid = atoi(row[9]); - all_entries.push_back(entry); + all_entries.push_back(e); } return all_entries; } - static std::vector GetWhere(Database& db, std::string where_filter) + static std::vector GetWhere(Database& db, const std::string &where_filter) { std::vector all_entries; @@ -337,26 +337,26 @@ public: all_entries.reserve(results.RowCount()); for (auto row = results.begin(); row != results.end(); ++row) { - Eventlog entry{}; + Eventlog e{}; - entry.id = atoi(row[0]); - entry.accountname = row[1] ? row[1] : ""; - entry.accountid = atoi(row[2]); - entry.status = atoi(row[3]); - entry.charname = row[4] ? row[4] : ""; - entry.target = row[5] ? row[5] : ""; - entry.time = row[6] ? row[6] : ""; - entry.descriptiontype = row[7] ? row[7] : ""; - entry.description = row[8] ? row[8] : ""; - entry.event_nid = atoi(row[9]); + e.id = atoi(row[0]); + e.accountname = row[1] ? row[1] : ""; + e.accountid = atoi(row[2]); + e.status = atoi(row[3]); + e.charname = row[4] ? row[4] : ""; + e.target = row[5] ? row[5] : ""; + e.time = row[6] ? row[6] : ""; + e.descriptiontype = row[7] ? row[7] : ""; + e.description = row[8] ? row[8] : ""; + e.event_nid = atoi(row[9]); - all_entries.push_back(entry); + all_entries.push_back(e); } return all_entries; } - static int DeleteWhere(Database& db, std::string where_filter) + static int DeleteWhere(Database& db, const std::string &where_filter) { auto results = db.QueryDatabase( fmt::format( @@ -381,6 +381,32 @@ public: 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); + } + }; #endif //EQEMU_BASE_EVENTLOG_REPOSITORY_H diff --git a/common/repositories/base/base_expedition_lockouts_repository.h b/common/repositories/base/base_expedition_lockouts_repository.h index 58d4915a6..7c884ebba 100644 --- a/common/repositories/base/base_expedition_lockouts_repository.h +++ b/common/repositories/base/base_expedition_lockouts_repository.h @@ -91,19 +91,19 @@ public: static ExpeditionLockouts NewEntity() { - ExpeditionLockouts entry{}; + ExpeditionLockouts e{}; - entry.id = 0; - entry.expedition_id = 0; - entry.event_name = ""; - entry.expire_time = std::time(nullptr); - entry.duration = 0; - entry.from_expedition_uuid = ""; + e.id = 0; + e.expedition_id = 0; + e.event_name = ""; + e.expire_time = std::time(nullptr); + e.duration = 0; + e.from_expedition_uuid = ""; - return entry; + return e; } - static ExpeditionLockouts GetExpeditionLockoutsEntry( + static ExpeditionLockouts GetExpeditionLockouts( const std::vector &expedition_lockoutss, int expedition_lockouts_id ) @@ -132,16 +132,16 @@ public: auto row = results.begin(); if (results.RowCount() == 1) { - ExpeditionLockouts entry{}; + ExpeditionLockouts e{}; - entry.id = atoi(row[0]); - entry.expedition_id = atoi(row[1]); - entry.event_name = row[2] ? row[2] : ""; - entry.expire_time = strtoll(row[3] ? row[3] : "-1", nullptr, 10); - entry.duration = atoi(row[4]); - entry.from_expedition_uuid = row[5] ? row[5] : ""; + e.id = atoi(row[0]); + e.expedition_id = atoi(row[1]); + e.event_name = row[2] ? row[2] : ""; + e.expire_time = strtoll(row[3] ? row[3] : "-1", nullptr, 10); + e.duration = atoi(row[4]); + e.from_expedition_uuid = row[5] ? row[5] : ""; - return entry; + return e; } return NewEntity(); @@ -166,26 +166,26 @@ public: static int UpdateOne( Database& db, - ExpeditionLockouts expedition_lockouts_entry + const ExpeditionLockouts &e ) { - std::vector update_values; + std::vector v; auto columns = Columns(); - update_values.push_back(columns[1] + " = " + std::to_string(expedition_lockouts_entry.expedition_id)); - update_values.push_back(columns[2] + " = '" + Strings::Escape(expedition_lockouts_entry.event_name) + "'"); - update_values.push_back(columns[3] + " = FROM_UNIXTIME(" + (expedition_lockouts_entry.expire_time > 0 ? std::to_string(expedition_lockouts_entry.expire_time) : "null") + ")"); - update_values.push_back(columns[4] + " = " + std::to_string(expedition_lockouts_entry.duration)); - update_values.push_back(columns[5] + " = '" + Strings::Escape(expedition_lockouts_entry.from_expedition_uuid) + "'"); + v.push_back(columns[1] + " = " + std::to_string(e.expedition_id)); + v.push_back(columns[2] + " = '" + Strings::Escape(e.event_name) + "'"); + v.push_back(columns[3] + " = FROM_UNIXTIME(" + (e.expire_time > 0 ? std::to_string(e.expire_time) : "null") + ")"); + v.push_back(columns[4] + " = " + std::to_string(e.duration)); + v.push_back(columns[5] + " = '" + Strings::Escape(e.from_expedition_uuid) + "'"); auto results = db.QueryDatabase( fmt::format( "UPDATE {} SET {} WHERE {} = {}", TableName(), - Strings::Implode(", ", update_values), + Strings::Implode(", ", v), PrimaryKey(), - expedition_lockouts_entry.id + e.id ) ); @@ -194,57 +194,57 @@ public: static ExpeditionLockouts InsertOne( Database& db, - ExpeditionLockouts expedition_lockouts_entry + ExpeditionLockouts e ) { - std::vector insert_values; + std::vector v; - insert_values.push_back(std::to_string(expedition_lockouts_entry.id)); - insert_values.push_back(std::to_string(expedition_lockouts_entry.expedition_id)); - insert_values.push_back("'" + Strings::Escape(expedition_lockouts_entry.event_name) + "'"); - insert_values.push_back("FROM_UNIXTIME(" + (expedition_lockouts_entry.expire_time > 0 ? std::to_string(expedition_lockouts_entry.expire_time) : "null") + ")"); - insert_values.push_back(std::to_string(expedition_lockouts_entry.duration)); - insert_values.push_back("'" + Strings::Escape(expedition_lockouts_entry.from_expedition_uuid) + "'"); + v.push_back(std::to_string(e.id)); + v.push_back(std::to_string(e.expedition_id)); + v.push_back("'" + Strings::Escape(e.event_name) + "'"); + v.push_back("FROM_UNIXTIME(" + (e.expire_time > 0 ? std::to_string(e.expire_time) : "null") + ")"); + v.push_back(std::to_string(e.duration)); + v.push_back("'" + Strings::Escape(e.from_expedition_uuid) + "'"); auto results = db.QueryDatabase( fmt::format( "{} VALUES ({})", BaseInsert(), - Strings::Implode(",", insert_values) + Strings::Implode(",", v) ) ); if (results.Success()) { - expedition_lockouts_entry.id = results.LastInsertedID(); - return expedition_lockouts_entry; + e.id = results.LastInsertedID(); + return e; } - expedition_lockouts_entry = NewEntity(); + e = NewEntity(); - return expedition_lockouts_entry; + return e; } static int InsertMany( Database& db, - std::vector expedition_lockouts_entries + const std::vector &entries ) { std::vector insert_chunks; - for (auto &expedition_lockouts_entry: expedition_lockouts_entries) { - std::vector insert_values; + for (auto &e: entries) { + std::vector v; - insert_values.push_back(std::to_string(expedition_lockouts_entry.id)); - insert_values.push_back(std::to_string(expedition_lockouts_entry.expedition_id)); - insert_values.push_back("'" + Strings::Escape(expedition_lockouts_entry.event_name) + "'"); - insert_values.push_back("FROM_UNIXTIME(" + (expedition_lockouts_entry.expire_time > 0 ? std::to_string(expedition_lockouts_entry.expire_time) : "null") + ")"); - insert_values.push_back(std::to_string(expedition_lockouts_entry.duration)); - insert_values.push_back("'" + Strings::Escape(expedition_lockouts_entry.from_expedition_uuid) + "'"); + v.push_back(std::to_string(e.id)); + v.push_back(std::to_string(e.expedition_id)); + v.push_back("'" + Strings::Escape(e.event_name) + "'"); + v.push_back("FROM_UNIXTIME(" + (e.expire_time > 0 ? std::to_string(e.expire_time) : "null") + ")"); + v.push_back(std::to_string(e.duration)); + v.push_back("'" + Strings::Escape(e.from_expedition_uuid) + "'"); - insert_chunks.push_back("(" + Strings::Implode(",", insert_values) + ")"); + insert_chunks.push_back("(" + Strings::Implode(",", v) + ")"); } - std::vector insert_values; + std::vector v; auto results = db.QueryDatabase( fmt::format( @@ -271,22 +271,22 @@ public: all_entries.reserve(results.RowCount()); for (auto row = results.begin(); row != results.end(); ++row) { - ExpeditionLockouts entry{}; + ExpeditionLockouts e{}; - entry.id = atoi(row[0]); - entry.expedition_id = atoi(row[1]); - entry.event_name = row[2] ? row[2] : ""; - entry.expire_time = strtoll(row[3] ? row[3] : "-1", nullptr, 10); - entry.duration = atoi(row[4]); - entry.from_expedition_uuid = row[5] ? row[5] : ""; + e.id = atoi(row[0]); + e.expedition_id = atoi(row[1]); + e.event_name = row[2] ? row[2] : ""; + e.expire_time = strtoll(row[3] ? row[3] : "-1", nullptr, 10); + e.duration = atoi(row[4]); + e.from_expedition_uuid = row[5] ? row[5] : ""; - all_entries.push_back(entry); + all_entries.push_back(e); } return all_entries; } - static std::vector GetWhere(Database& db, std::string where_filter) + static std::vector GetWhere(Database& db, const std::string &where_filter) { std::vector all_entries; @@ -301,22 +301,22 @@ public: all_entries.reserve(results.RowCount()); for (auto row = results.begin(); row != results.end(); ++row) { - ExpeditionLockouts entry{}; + ExpeditionLockouts e{}; - entry.id = atoi(row[0]); - entry.expedition_id = atoi(row[1]); - entry.event_name = row[2] ? row[2] : ""; - entry.expire_time = strtoll(row[3] ? row[3] : "-1", nullptr, 10); - entry.duration = atoi(row[4]); - entry.from_expedition_uuid = row[5] ? row[5] : ""; + e.id = atoi(row[0]); + e.expedition_id = atoi(row[1]); + e.event_name = row[2] ? row[2] : ""; + e.expire_time = strtoll(row[3] ? row[3] : "-1", nullptr, 10); + e.duration = atoi(row[4]); + e.from_expedition_uuid = row[5] ? row[5] : ""; - all_entries.push_back(entry); + all_entries.push_back(e); } return all_entries; } - static int DeleteWhere(Database& db, std::string where_filter) + static int DeleteWhere(Database& db, const std::string &where_filter) { auto results = db.QueryDatabase( fmt::format( @@ -341,6 +341,32 @@ public: 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); + } + }; #endif //EQEMU_BASE_EXPEDITION_LOCKOUTS_REPOSITORY_H diff --git a/common/repositories/base/base_expeditions_repository.h b/common/repositories/base/base_expeditions_repository.h index 87efe42bf..487356784 100644 --- a/common/repositories/base/base_expeditions_repository.h +++ b/common/repositories/base/base_expeditions_repository.h @@ -85,17 +85,17 @@ public: static Expeditions NewEntity() { - Expeditions entry{}; + Expeditions e{}; - entry.id = 0; - entry.dynamic_zone_id = 0; - entry.add_replay_on_join = 1; - entry.is_locked = 0; + e.id = 0; + e.dynamic_zone_id = 0; + e.add_replay_on_join = 1; + e.is_locked = 0; - return entry; + return e; } - static Expeditions GetExpeditionsEntry( + static Expeditions GetExpeditions( const std::vector &expeditionss, int expeditions_id ) @@ -124,14 +124,14 @@ public: auto row = results.begin(); if (results.RowCount() == 1) { - Expeditions entry{}; + Expeditions e{}; - entry.id = atoi(row[0]); - entry.dynamic_zone_id = atoi(row[1]); - entry.add_replay_on_join = atoi(row[2]); - entry.is_locked = atoi(row[3]); + e.id = atoi(row[0]); + e.dynamic_zone_id = atoi(row[1]); + e.add_replay_on_join = atoi(row[2]); + e.is_locked = atoi(row[3]); - return entry; + return e; } return NewEntity(); @@ -156,24 +156,24 @@ public: static int UpdateOne( Database& db, - Expeditions expeditions_entry + const Expeditions &e ) { - std::vector update_values; + std::vector v; auto columns = Columns(); - update_values.push_back(columns[1] + " = " + std::to_string(expeditions_entry.dynamic_zone_id)); - update_values.push_back(columns[2] + " = " + std::to_string(expeditions_entry.add_replay_on_join)); - update_values.push_back(columns[3] + " = " + std::to_string(expeditions_entry.is_locked)); + v.push_back(columns[1] + " = " + std::to_string(e.dynamic_zone_id)); + v.push_back(columns[2] + " = " + std::to_string(e.add_replay_on_join)); + v.push_back(columns[3] + " = " + std::to_string(e.is_locked)); auto results = db.QueryDatabase( fmt::format( "UPDATE {} SET {} WHERE {} = {}", TableName(), - Strings::Implode(", ", update_values), + Strings::Implode(", ", v), PrimaryKey(), - expeditions_entry.id + e.id ) ); @@ -182,53 +182,53 @@ public: static Expeditions InsertOne( Database& db, - Expeditions expeditions_entry + Expeditions e ) { - std::vector insert_values; + std::vector v; - insert_values.push_back(std::to_string(expeditions_entry.id)); - insert_values.push_back(std::to_string(expeditions_entry.dynamic_zone_id)); - insert_values.push_back(std::to_string(expeditions_entry.add_replay_on_join)); - insert_values.push_back(std::to_string(expeditions_entry.is_locked)); + v.push_back(std::to_string(e.id)); + v.push_back(std::to_string(e.dynamic_zone_id)); + v.push_back(std::to_string(e.add_replay_on_join)); + v.push_back(std::to_string(e.is_locked)); auto results = db.QueryDatabase( fmt::format( "{} VALUES ({})", BaseInsert(), - Strings::Implode(",", insert_values) + Strings::Implode(",", v) ) ); if (results.Success()) { - expeditions_entry.id = results.LastInsertedID(); - return expeditions_entry; + e.id = results.LastInsertedID(); + return e; } - expeditions_entry = NewEntity(); + e = NewEntity(); - return expeditions_entry; + return e; } static int InsertMany( Database& db, - std::vector expeditions_entries + const std::vector &entries ) { std::vector insert_chunks; - for (auto &expeditions_entry: expeditions_entries) { - std::vector insert_values; + for (auto &e: entries) { + std::vector v; - insert_values.push_back(std::to_string(expeditions_entry.id)); - insert_values.push_back(std::to_string(expeditions_entry.dynamic_zone_id)); - insert_values.push_back(std::to_string(expeditions_entry.add_replay_on_join)); - insert_values.push_back(std::to_string(expeditions_entry.is_locked)); + v.push_back(std::to_string(e.id)); + v.push_back(std::to_string(e.dynamic_zone_id)); + v.push_back(std::to_string(e.add_replay_on_join)); + v.push_back(std::to_string(e.is_locked)); - insert_chunks.push_back("(" + Strings::Implode(",", insert_values) + ")"); + insert_chunks.push_back("(" + Strings::Implode(",", v) + ")"); } - std::vector insert_values; + std::vector v; auto results = db.QueryDatabase( fmt::format( @@ -255,20 +255,20 @@ public: all_entries.reserve(results.RowCount()); for (auto row = results.begin(); row != results.end(); ++row) { - Expeditions entry{}; + Expeditions e{}; - entry.id = atoi(row[0]); - entry.dynamic_zone_id = atoi(row[1]); - entry.add_replay_on_join = atoi(row[2]); - entry.is_locked = atoi(row[3]); + e.id = atoi(row[0]); + e.dynamic_zone_id = atoi(row[1]); + e.add_replay_on_join = atoi(row[2]); + e.is_locked = atoi(row[3]); - all_entries.push_back(entry); + all_entries.push_back(e); } return all_entries; } - static std::vector GetWhere(Database& db, std::string where_filter) + static std::vector GetWhere(Database& db, const std::string &where_filter) { std::vector all_entries; @@ -283,20 +283,20 @@ public: all_entries.reserve(results.RowCount()); for (auto row = results.begin(); row != results.end(); ++row) { - Expeditions entry{}; + Expeditions e{}; - entry.id = atoi(row[0]); - entry.dynamic_zone_id = atoi(row[1]); - entry.add_replay_on_join = atoi(row[2]); - entry.is_locked = atoi(row[3]); + e.id = atoi(row[0]); + e.dynamic_zone_id = atoi(row[1]); + e.add_replay_on_join = atoi(row[2]); + e.is_locked = atoi(row[3]); - all_entries.push_back(entry); + all_entries.push_back(e); } return all_entries; } - static int DeleteWhere(Database& db, std::string where_filter) + static int DeleteWhere(Database& db, const std::string &where_filter) { auto results = db.QueryDatabase( fmt::format( @@ -321,6 +321,32 @@ public: 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); + } + }; #endif //EQEMU_BASE_EXPEDITIONS_REPOSITORY_H diff --git a/common/repositories/base/base_faction_base_data_repository.h b/common/repositories/base/base_faction_base_data_repository.h index 393604e06..87d65d2b4 100644 --- a/common/repositories/base/base_faction_base_data_repository.h +++ b/common/repositories/base/base_faction_base_data_repository.h @@ -91,19 +91,19 @@ public: static FactionBaseData NewEntity() { - FactionBaseData entry{}; + FactionBaseData e{}; - entry.client_faction_id = 0; - entry.min = -2000; - entry.max = 2000; - entry.unk_hero1 = 0; - entry.unk_hero2 = 0; - entry.unk_hero3 = 0; + e.client_faction_id = 0; + e.min = -2000; + e.max = 2000; + e.unk_hero1 = 0; + e.unk_hero2 = 0; + e.unk_hero3 = 0; - return entry; + return e; } - static FactionBaseData GetFactionBaseDataEntry( + static FactionBaseData GetFactionBaseData( const std::vector &faction_base_datas, int faction_base_data_id ) @@ -132,16 +132,16 @@ public: auto row = results.begin(); if (results.RowCount() == 1) { - FactionBaseData entry{}; + FactionBaseData e{}; - entry.client_faction_id = atoi(row[0]); - entry.min = atoi(row[1]); - entry.max = atoi(row[2]); - entry.unk_hero1 = atoi(row[3]); - entry.unk_hero2 = atoi(row[4]); - entry.unk_hero3 = atoi(row[5]); + e.client_faction_id = atoi(row[0]); + e.min = atoi(row[1]); + e.max = atoi(row[2]); + e.unk_hero1 = atoi(row[3]); + e.unk_hero2 = atoi(row[4]); + e.unk_hero3 = atoi(row[5]); - return entry; + return e; } return NewEntity(); @@ -166,27 +166,27 @@ public: static int UpdateOne( Database& db, - FactionBaseData faction_base_data_entry + const FactionBaseData &e ) { - std::vector update_values; + std::vector v; auto columns = Columns(); - update_values.push_back(columns[0] + " = " + std::to_string(faction_base_data_entry.client_faction_id)); - update_values.push_back(columns[1] + " = " + std::to_string(faction_base_data_entry.min)); - update_values.push_back(columns[2] + " = " + std::to_string(faction_base_data_entry.max)); - update_values.push_back(columns[3] + " = " + std::to_string(faction_base_data_entry.unk_hero1)); - update_values.push_back(columns[4] + " = " + std::to_string(faction_base_data_entry.unk_hero2)); - update_values.push_back(columns[5] + " = " + std::to_string(faction_base_data_entry.unk_hero3)); + v.push_back(columns[0] + " = " + std::to_string(e.client_faction_id)); + v.push_back(columns[1] + " = " + std::to_string(e.min)); + v.push_back(columns[2] + " = " + std::to_string(e.max)); + v.push_back(columns[3] + " = " + std::to_string(e.unk_hero1)); + v.push_back(columns[4] + " = " + std::to_string(e.unk_hero2)); + v.push_back(columns[5] + " = " + std::to_string(e.unk_hero3)); auto results = db.QueryDatabase( fmt::format( "UPDATE {} SET {} WHERE {} = {}", TableName(), - Strings::Implode(", ", update_values), + Strings::Implode(", ", v), PrimaryKey(), - faction_base_data_entry.client_faction_id + e.client_faction_id ) ); @@ -195,57 +195,57 @@ public: static FactionBaseData InsertOne( Database& db, - FactionBaseData faction_base_data_entry + FactionBaseData e ) { - std::vector insert_values; + std::vector v; - insert_values.push_back(std::to_string(faction_base_data_entry.client_faction_id)); - insert_values.push_back(std::to_string(faction_base_data_entry.min)); - insert_values.push_back(std::to_string(faction_base_data_entry.max)); - insert_values.push_back(std::to_string(faction_base_data_entry.unk_hero1)); - insert_values.push_back(std::to_string(faction_base_data_entry.unk_hero2)); - insert_values.push_back(std::to_string(faction_base_data_entry.unk_hero3)); + v.push_back(std::to_string(e.client_faction_id)); + v.push_back(std::to_string(e.min)); + v.push_back(std::to_string(e.max)); + v.push_back(std::to_string(e.unk_hero1)); + v.push_back(std::to_string(e.unk_hero2)); + v.push_back(std::to_string(e.unk_hero3)); auto results = db.QueryDatabase( fmt::format( "{} VALUES ({})", BaseInsert(), - Strings::Implode(",", insert_values) + Strings::Implode(",", v) ) ); if (results.Success()) { - faction_base_data_entry.client_faction_id = results.LastInsertedID(); - return faction_base_data_entry; + e.client_faction_id = results.LastInsertedID(); + return e; } - faction_base_data_entry = NewEntity(); + e = NewEntity(); - return faction_base_data_entry; + return e; } static int InsertMany( Database& db, - std::vector faction_base_data_entries + const std::vector &entries ) { std::vector insert_chunks; - for (auto &faction_base_data_entry: faction_base_data_entries) { - std::vector insert_values; + for (auto &e: entries) { + std::vector v; - insert_values.push_back(std::to_string(faction_base_data_entry.client_faction_id)); - insert_values.push_back(std::to_string(faction_base_data_entry.min)); - insert_values.push_back(std::to_string(faction_base_data_entry.max)); - insert_values.push_back(std::to_string(faction_base_data_entry.unk_hero1)); - insert_values.push_back(std::to_string(faction_base_data_entry.unk_hero2)); - insert_values.push_back(std::to_string(faction_base_data_entry.unk_hero3)); + v.push_back(std::to_string(e.client_faction_id)); + v.push_back(std::to_string(e.min)); + v.push_back(std::to_string(e.max)); + v.push_back(std::to_string(e.unk_hero1)); + v.push_back(std::to_string(e.unk_hero2)); + v.push_back(std::to_string(e.unk_hero3)); - insert_chunks.push_back("(" + Strings::Implode(",", insert_values) + ")"); + insert_chunks.push_back("(" + Strings::Implode(",", v) + ")"); } - std::vector insert_values; + std::vector v; auto results = db.QueryDatabase( fmt::format( @@ -272,22 +272,22 @@ public: all_entries.reserve(results.RowCount()); for (auto row = results.begin(); row != results.end(); ++row) { - FactionBaseData entry{}; + FactionBaseData e{}; - entry.client_faction_id = atoi(row[0]); - entry.min = atoi(row[1]); - entry.max = atoi(row[2]); - entry.unk_hero1 = atoi(row[3]); - entry.unk_hero2 = atoi(row[4]); - entry.unk_hero3 = atoi(row[5]); + e.client_faction_id = atoi(row[0]); + e.min = atoi(row[1]); + e.max = atoi(row[2]); + e.unk_hero1 = atoi(row[3]); + e.unk_hero2 = atoi(row[4]); + e.unk_hero3 = atoi(row[5]); - all_entries.push_back(entry); + all_entries.push_back(e); } return all_entries; } - static std::vector GetWhere(Database& db, std::string where_filter) + static std::vector GetWhere(Database& db, const std::string &where_filter) { std::vector all_entries; @@ -302,22 +302,22 @@ public: all_entries.reserve(results.RowCount()); for (auto row = results.begin(); row != results.end(); ++row) { - FactionBaseData entry{}; + FactionBaseData e{}; - entry.client_faction_id = atoi(row[0]); - entry.min = atoi(row[1]); - entry.max = atoi(row[2]); - entry.unk_hero1 = atoi(row[3]); - entry.unk_hero2 = atoi(row[4]); - entry.unk_hero3 = atoi(row[5]); + e.client_faction_id = atoi(row[0]); + e.min = atoi(row[1]); + e.max = atoi(row[2]); + e.unk_hero1 = atoi(row[3]); + e.unk_hero2 = atoi(row[4]); + e.unk_hero3 = atoi(row[5]); - all_entries.push_back(entry); + all_entries.push_back(e); } return all_entries; } - static int DeleteWhere(Database& db, std::string where_filter) + static int DeleteWhere(Database& db, const std::string &where_filter) { auto results = db.QueryDatabase( fmt::format( @@ -342,6 +342,32 @@ public: 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); + } + }; #endif //EQEMU_BASE_FACTION_BASE_DATA_REPOSITORY_H diff --git a/common/repositories/base/base_faction_list_mod_repository.h b/common/repositories/base/base_faction_list_mod_repository.h index 461393cc4..7304897a0 100644 --- a/common/repositories/base/base_faction_list_mod_repository.h +++ b/common/repositories/base/base_faction_list_mod_repository.h @@ -85,17 +85,17 @@ public: static FactionListMod NewEntity() { - FactionListMod entry{}; + FactionListMod e{}; - entry.id = 0; - entry.faction_id = 0; - entry.mod = 0; - entry.mod_name = ""; + e.id = 0; + e.faction_id = 0; + e.mod = 0; + e.mod_name = ""; - return entry; + return e; } - static FactionListMod GetFactionListModEntry( + static FactionListMod GetFactionListMod( const std::vector &faction_list_mods, int faction_list_mod_id ) @@ -124,14 +124,14 @@ public: auto row = results.begin(); if (results.RowCount() == 1) { - FactionListMod entry{}; + FactionListMod e{}; - entry.id = atoi(row[0]); - entry.faction_id = atoi(row[1]); - entry.mod = atoi(row[2]); - entry.mod_name = row[3] ? row[3] : ""; + e.id = atoi(row[0]); + e.faction_id = atoi(row[1]); + e.mod = atoi(row[2]); + e.mod_name = row[3] ? row[3] : ""; - return entry; + return e; } return NewEntity(); @@ -156,24 +156,24 @@ public: static int UpdateOne( Database& db, - FactionListMod faction_list_mod_entry + const FactionListMod &e ) { - std::vector update_values; + std::vector v; auto columns = Columns(); - update_values.push_back(columns[1] + " = " + std::to_string(faction_list_mod_entry.faction_id)); - update_values.push_back(columns[2] + " = " + std::to_string(faction_list_mod_entry.mod)); - update_values.push_back(columns[3] + " = '" + Strings::Escape(faction_list_mod_entry.mod_name) + "'"); + v.push_back(columns[1] + " = " + std::to_string(e.faction_id)); + v.push_back(columns[2] + " = " + std::to_string(e.mod)); + v.push_back(columns[3] + " = '" + Strings::Escape(e.mod_name) + "'"); auto results = db.QueryDatabase( fmt::format( "UPDATE {} SET {} WHERE {} = {}", TableName(), - Strings::Implode(", ", update_values), + Strings::Implode(", ", v), PrimaryKey(), - faction_list_mod_entry.id + e.id ) ); @@ -182,53 +182,53 @@ public: static FactionListMod InsertOne( Database& db, - FactionListMod faction_list_mod_entry + FactionListMod e ) { - std::vector insert_values; + std::vector v; - insert_values.push_back(std::to_string(faction_list_mod_entry.id)); - insert_values.push_back(std::to_string(faction_list_mod_entry.faction_id)); - insert_values.push_back(std::to_string(faction_list_mod_entry.mod)); - insert_values.push_back("'" + Strings::Escape(faction_list_mod_entry.mod_name) + "'"); + v.push_back(std::to_string(e.id)); + v.push_back(std::to_string(e.faction_id)); + v.push_back(std::to_string(e.mod)); + v.push_back("'" + Strings::Escape(e.mod_name) + "'"); auto results = db.QueryDatabase( fmt::format( "{} VALUES ({})", BaseInsert(), - Strings::Implode(",", insert_values) + Strings::Implode(",", v) ) ); if (results.Success()) { - faction_list_mod_entry.id = results.LastInsertedID(); - return faction_list_mod_entry; + e.id = results.LastInsertedID(); + return e; } - faction_list_mod_entry = NewEntity(); + e = NewEntity(); - return faction_list_mod_entry; + return e; } static int InsertMany( Database& db, - std::vector faction_list_mod_entries + const std::vector &entries ) { std::vector insert_chunks; - for (auto &faction_list_mod_entry: faction_list_mod_entries) { - std::vector insert_values; + for (auto &e: entries) { + std::vector v; - insert_values.push_back(std::to_string(faction_list_mod_entry.id)); - insert_values.push_back(std::to_string(faction_list_mod_entry.faction_id)); - insert_values.push_back(std::to_string(faction_list_mod_entry.mod)); - insert_values.push_back("'" + Strings::Escape(faction_list_mod_entry.mod_name) + "'"); + v.push_back(std::to_string(e.id)); + v.push_back(std::to_string(e.faction_id)); + v.push_back(std::to_string(e.mod)); + v.push_back("'" + Strings::Escape(e.mod_name) + "'"); - insert_chunks.push_back("(" + Strings::Implode(",", insert_values) + ")"); + insert_chunks.push_back("(" + Strings::Implode(",", v) + ")"); } - std::vector insert_values; + std::vector v; auto results = db.QueryDatabase( fmt::format( @@ -255,20 +255,20 @@ public: all_entries.reserve(results.RowCount()); for (auto row = results.begin(); row != results.end(); ++row) { - FactionListMod entry{}; + FactionListMod e{}; - entry.id = atoi(row[0]); - entry.faction_id = atoi(row[1]); - entry.mod = atoi(row[2]); - entry.mod_name = row[3] ? row[3] : ""; + e.id = atoi(row[0]); + e.faction_id = atoi(row[1]); + e.mod = atoi(row[2]); + e.mod_name = row[3] ? row[3] : ""; - all_entries.push_back(entry); + all_entries.push_back(e); } return all_entries; } - static std::vector GetWhere(Database& db, std::string where_filter) + static std::vector GetWhere(Database& db, const std::string &where_filter) { std::vector all_entries; @@ -283,20 +283,20 @@ public: all_entries.reserve(results.RowCount()); for (auto row = results.begin(); row != results.end(); ++row) { - FactionListMod entry{}; + FactionListMod e{}; - entry.id = atoi(row[0]); - entry.faction_id = atoi(row[1]); - entry.mod = atoi(row[2]); - entry.mod_name = row[3] ? row[3] : ""; + e.id = atoi(row[0]); + e.faction_id = atoi(row[1]); + e.mod = atoi(row[2]); + e.mod_name = row[3] ? row[3] : ""; - all_entries.push_back(entry); + all_entries.push_back(e); } return all_entries; } - static int DeleteWhere(Database& db, std::string where_filter) + static int DeleteWhere(Database& db, const std::string &where_filter) { auto results = db.QueryDatabase( fmt::format( @@ -321,6 +321,32 @@ public: 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); + } + }; #endif //EQEMU_BASE_FACTION_LIST_MOD_REPOSITORY_H diff --git a/common/repositories/base/base_faction_list_repository.h b/common/repositories/base/base_faction_list_repository.h index 11a8620ee..c6f8cf569 100644 --- a/common/repositories/base/base_faction_list_repository.h +++ b/common/repositories/base/base_faction_list_repository.h @@ -82,16 +82,16 @@ public: static FactionList NewEntity() { - FactionList entry{}; + FactionList e{}; - entry.id = 0; - entry.name = ""; - entry.base = 0; + e.id = 0; + e.name = ""; + e.base = 0; - return entry; + return e; } - static FactionList GetFactionListEntry( + static FactionList GetFactionList( const std::vector &faction_lists, int faction_list_id ) @@ -120,13 +120,13 @@ public: auto row = results.begin(); if (results.RowCount() == 1) { - FactionList entry{}; + FactionList e{}; - entry.id = atoi(row[0]); - entry.name = row[1] ? row[1] : ""; - entry.base = atoi(row[2]); + e.id = atoi(row[0]); + e.name = row[1] ? row[1] : ""; + e.base = atoi(row[2]); - return entry; + return e; } return NewEntity(); @@ -151,24 +151,24 @@ public: static int UpdateOne( Database& db, - FactionList faction_list_entry + const FactionList &e ) { - std::vector update_values; + std::vector v; auto columns = Columns(); - update_values.push_back(columns[0] + " = " + std::to_string(faction_list_entry.id)); - update_values.push_back(columns[1] + " = '" + Strings::Escape(faction_list_entry.name) + "'"); - update_values.push_back(columns[2] + " = " + std::to_string(faction_list_entry.base)); + v.push_back(columns[0] + " = " + std::to_string(e.id)); + v.push_back(columns[1] + " = '" + Strings::Escape(e.name) + "'"); + v.push_back(columns[2] + " = " + std::to_string(e.base)); auto results = db.QueryDatabase( fmt::format( "UPDATE {} SET {} WHERE {} = {}", TableName(), - Strings::Implode(", ", update_values), + Strings::Implode(", ", v), PrimaryKey(), - faction_list_entry.id + e.id ) ); @@ -177,51 +177,51 @@ public: static FactionList InsertOne( Database& db, - FactionList faction_list_entry + FactionList e ) { - std::vector insert_values; + std::vector v; - insert_values.push_back(std::to_string(faction_list_entry.id)); - insert_values.push_back("'" + Strings::Escape(faction_list_entry.name) + "'"); - insert_values.push_back(std::to_string(faction_list_entry.base)); + v.push_back(std::to_string(e.id)); + v.push_back("'" + Strings::Escape(e.name) + "'"); + v.push_back(std::to_string(e.base)); auto results = db.QueryDatabase( fmt::format( "{} VALUES ({})", BaseInsert(), - Strings::Implode(",", insert_values) + Strings::Implode(",", v) ) ); if (results.Success()) { - faction_list_entry.id = results.LastInsertedID(); - return faction_list_entry; + e.id = results.LastInsertedID(); + return e; } - faction_list_entry = NewEntity(); + e = NewEntity(); - return faction_list_entry; + return e; } static int InsertMany( Database& db, - std::vector faction_list_entries + const std::vector &entries ) { std::vector insert_chunks; - for (auto &faction_list_entry: faction_list_entries) { - std::vector insert_values; + for (auto &e: entries) { + std::vector v; - insert_values.push_back(std::to_string(faction_list_entry.id)); - insert_values.push_back("'" + Strings::Escape(faction_list_entry.name) + "'"); - insert_values.push_back(std::to_string(faction_list_entry.base)); + v.push_back(std::to_string(e.id)); + v.push_back("'" + Strings::Escape(e.name) + "'"); + v.push_back(std::to_string(e.base)); - insert_chunks.push_back("(" + Strings::Implode(",", insert_values) + ")"); + insert_chunks.push_back("(" + Strings::Implode(",", v) + ")"); } - std::vector insert_values; + std::vector v; auto results = db.QueryDatabase( fmt::format( @@ -248,19 +248,19 @@ public: all_entries.reserve(results.RowCount()); for (auto row = results.begin(); row != results.end(); ++row) { - FactionList entry{}; + FactionList e{}; - entry.id = atoi(row[0]); - entry.name = row[1] ? row[1] : ""; - entry.base = atoi(row[2]); + e.id = atoi(row[0]); + e.name = row[1] ? row[1] : ""; + e.base = atoi(row[2]); - all_entries.push_back(entry); + all_entries.push_back(e); } return all_entries; } - static std::vector GetWhere(Database& db, std::string where_filter) + static std::vector GetWhere(Database& db, const std::string &where_filter) { std::vector all_entries; @@ -275,19 +275,19 @@ public: all_entries.reserve(results.RowCount()); for (auto row = results.begin(); row != results.end(); ++row) { - FactionList entry{}; + FactionList e{}; - entry.id = atoi(row[0]); - entry.name = row[1] ? row[1] : ""; - entry.base = atoi(row[2]); + e.id = atoi(row[0]); + e.name = row[1] ? row[1] : ""; + e.base = atoi(row[2]); - all_entries.push_back(entry); + all_entries.push_back(e); } return all_entries; } - static int DeleteWhere(Database& db, std::string where_filter) + static int DeleteWhere(Database& db, const std::string &where_filter) { auto results = db.QueryDatabase( fmt::format( @@ -312,6 +312,32 @@ public: 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); + } + }; #endif //EQEMU_BASE_FACTION_LIST_REPOSITORY_H diff --git a/common/repositories/base/base_faction_values_repository.h b/common/repositories/base/base_faction_values_repository.h index 7868b7c88..12739bb0e 100644 --- a/common/repositories/base/base_faction_values_repository.h +++ b/common/repositories/base/base_faction_values_repository.h @@ -85,17 +85,17 @@ public: static FactionValues NewEntity() { - FactionValues entry{}; + FactionValues e{}; - entry.char_id = 0; - entry.faction_id = 0; - entry.current_value = 0; - entry.temp = 0; + e.char_id = 0; + e.faction_id = 0; + e.current_value = 0; + e.temp = 0; - return entry; + return e; } - static FactionValues GetFactionValuesEntry( + static FactionValues GetFactionValues( const std::vector &faction_valuess, int faction_values_id ) @@ -124,14 +124,14 @@ public: auto row = results.begin(); if (results.RowCount() == 1) { - FactionValues entry{}; + FactionValues e{}; - entry.char_id = atoi(row[0]); - entry.faction_id = atoi(row[1]); - entry.current_value = atoi(row[2]); - entry.temp = atoi(row[3]); + e.char_id = atoi(row[0]); + e.faction_id = atoi(row[1]); + e.current_value = atoi(row[2]); + e.temp = atoi(row[3]); - return entry; + return e; } return NewEntity(); @@ -156,25 +156,25 @@ public: static int UpdateOne( Database& db, - FactionValues faction_values_entry + const FactionValues &e ) { - std::vector update_values; + std::vector v; auto columns = Columns(); - update_values.push_back(columns[0] + " = " + std::to_string(faction_values_entry.char_id)); - update_values.push_back(columns[1] + " = " + std::to_string(faction_values_entry.faction_id)); - update_values.push_back(columns[2] + " = " + std::to_string(faction_values_entry.current_value)); - update_values.push_back(columns[3] + " = " + std::to_string(faction_values_entry.temp)); + v.push_back(columns[0] + " = " + std::to_string(e.char_id)); + v.push_back(columns[1] + " = " + std::to_string(e.faction_id)); + v.push_back(columns[2] + " = " + std::to_string(e.current_value)); + v.push_back(columns[3] + " = " + std::to_string(e.temp)); auto results = db.QueryDatabase( fmt::format( "UPDATE {} SET {} WHERE {} = {}", TableName(), - Strings::Implode(", ", update_values), + Strings::Implode(", ", v), PrimaryKey(), - faction_values_entry.char_id + e.char_id ) ); @@ -183,53 +183,53 @@ public: static FactionValues InsertOne( Database& db, - FactionValues faction_values_entry + FactionValues e ) { - std::vector insert_values; + std::vector v; - insert_values.push_back(std::to_string(faction_values_entry.char_id)); - insert_values.push_back(std::to_string(faction_values_entry.faction_id)); - insert_values.push_back(std::to_string(faction_values_entry.current_value)); - insert_values.push_back(std::to_string(faction_values_entry.temp)); + v.push_back(std::to_string(e.char_id)); + v.push_back(std::to_string(e.faction_id)); + v.push_back(std::to_string(e.current_value)); + v.push_back(std::to_string(e.temp)); auto results = db.QueryDatabase( fmt::format( "{} VALUES ({})", BaseInsert(), - Strings::Implode(",", insert_values) + Strings::Implode(",", v) ) ); if (results.Success()) { - faction_values_entry.char_id = results.LastInsertedID(); - return faction_values_entry; + e.char_id = results.LastInsertedID(); + return e; } - faction_values_entry = NewEntity(); + e = NewEntity(); - return faction_values_entry; + return e; } static int InsertMany( Database& db, - std::vector faction_values_entries + const std::vector &entries ) { std::vector insert_chunks; - for (auto &faction_values_entry: faction_values_entries) { - std::vector insert_values; + for (auto &e: entries) { + std::vector v; - insert_values.push_back(std::to_string(faction_values_entry.char_id)); - insert_values.push_back(std::to_string(faction_values_entry.faction_id)); - insert_values.push_back(std::to_string(faction_values_entry.current_value)); - insert_values.push_back(std::to_string(faction_values_entry.temp)); + v.push_back(std::to_string(e.char_id)); + v.push_back(std::to_string(e.faction_id)); + v.push_back(std::to_string(e.current_value)); + v.push_back(std::to_string(e.temp)); - insert_chunks.push_back("(" + Strings::Implode(",", insert_values) + ")"); + insert_chunks.push_back("(" + Strings::Implode(",", v) + ")"); } - std::vector insert_values; + std::vector v; auto results = db.QueryDatabase( fmt::format( @@ -256,20 +256,20 @@ public: all_entries.reserve(results.RowCount()); for (auto row = results.begin(); row != results.end(); ++row) { - FactionValues entry{}; + FactionValues e{}; - entry.char_id = atoi(row[0]); - entry.faction_id = atoi(row[1]); - entry.current_value = atoi(row[2]); - entry.temp = atoi(row[3]); + e.char_id = atoi(row[0]); + e.faction_id = atoi(row[1]); + e.current_value = atoi(row[2]); + e.temp = atoi(row[3]); - all_entries.push_back(entry); + all_entries.push_back(e); } return all_entries; } - static std::vector GetWhere(Database& db, std::string where_filter) + static std::vector GetWhere(Database& db, const std::string &where_filter) { std::vector all_entries; @@ -284,20 +284,20 @@ public: all_entries.reserve(results.RowCount()); for (auto row = results.begin(); row != results.end(); ++row) { - FactionValues entry{}; + FactionValues e{}; - entry.char_id = atoi(row[0]); - entry.faction_id = atoi(row[1]); - entry.current_value = atoi(row[2]); - entry.temp = atoi(row[3]); + e.char_id = atoi(row[0]); + e.faction_id = atoi(row[1]); + e.current_value = atoi(row[2]); + e.temp = atoi(row[3]); - all_entries.push_back(entry); + all_entries.push_back(e); } return all_entries; } - static int DeleteWhere(Database& db, std::string where_filter) + static int DeleteWhere(Database& db, const std::string &where_filter) { auto results = db.QueryDatabase( fmt::format( @@ -322,6 +322,32 @@ public: 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); + } + }; #endif //EQEMU_BASE_FACTION_VALUES_REPOSITORY_H diff --git a/common/repositories/base/base_fishing_repository.h b/common/repositories/base/base_fishing_repository.h index c6368a0f6..91a1be58d 100644 --- a/common/repositories/base/base_fishing_repository.h +++ b/common/repositories/base/base_fishing_repository.h @@ -106,24 +106,24 @@ public: static Fishing NewEntity() { - Fishing entry{}; + Fishing e{}; - entry.id = 0; - entry.zoneid = 0; - entry.Itemid = 0; - entry.skill_level = 0; - entry.chance = 0; - entry.npc_id = 0; - entry.npc_chance = 0; - entry.min_expansion = -1; - entry.max_expansion = -1; - entry.content_flags = ""; - entry.content_flags_disabled = ""; + e.id = 0; + e.zoneid = 0; + e.Itemid = 0; + e.skill_level = 0; + e.chance = 0; + e.npc_id = 0; + e.npc_chance = 0; + e.min_expansion = -1; + e.max_expansion = -1; + e.content_flags = ""; + e.content_flags_disabled = ""; - return entry; + return e; } - static Fishing GetFishingEntry( + static Fishing GetFishing( const std::vector &fishings, int fishing_id ) @@ -152,21 +152,21 @@ public: auto row = results.begin(); if (results.RowCount() == 1) { - Fishing entry{}; + Fishing e{}; - entry.id = atoi(row[0]); - entry.zoneid = atoi(row[1]); - entry.Itemid = atoi(row[2]); - entry.skill_level = atoi(row[3]); - entry.chance = atoi(row[4]); - entry.npc_id = atoi(row[5]); - entry.npc_chance = atoi(row[6]); - entry.min_expansion = atoi(row[7]); - entry.max_expansion = atoi(row[8]); - entry.content_flags = row[9] ? row[9] : ""; - entry.content_flags_disabled = row[10] ? row[10] : ""; + e.id = atoi(row[0]); + e.zoneid = atoi(row[1]); + e.Itemid = atoi(row[2]); + e.skill_level = atoi(row[3]); + e.chance = atoi(row[4]); + e.npc_id = atoi(row[5]); + e.npc_chance = atoi(row[6]); + e.min_expansion = atoi(row[7]); + e.max_expansion = atoi(row[8]); + e.content_flags = row[9] ? row[9] : ""; + e.content_flags_disabled = row[10] ? row[10] : ""; - return entry; + return e; } return NewEntity(); @@ -191,31 +191,31 @@ public: static int UpdateOne( Database& db, - Fishing fishing_entry + const Fishing &e ) { - std::vector update_values; + std::vector v; auto columns = Columns(); - update_values.push_back(columns[1] + " = " + std::to_string(fishing_entry.zoneid)); - update_values.push_back(columns[2] + " = " + std::to_string(fishing_entry.Itemid)); - update_values.push_back(columns[3] + " = " + std::to_string(fishing_entry.skill_level)); - update_values.push_back(columns[4] + " = " + std::to_string(fishing_entry.chance)); - update_values.push_back(columns[5] + " = " + std::to_string(fishing_entry.npc_id)); - update_values.push_back(columns[6] + " = " + std::to_string(fishing_entry.npc_chance)); - update_values.push_back(columns[7] + " = " + std::to_string(fishing_entry.min_expansion)); - update_values.push_back(columns[8] + " = " + std::to_string(fishing_entry.max_expansion)); - update_values.push_back(columns[9] + " = '" + Strings::Escape(fishing_entry.content_flags) + "'"); - update_values.push_back(columns[10] + " = '" + Strings::Escape(fishing_entry.content_flags_disabled) + "'"); + v.push_back(columns[1] + " = " + std::to_string(e.zoneid)); + v.push_back(columns[2] + " = " + std::to_string(e.Itemid)); + v.push_back(columns[3] + " = " + std::to_string(e.skill_level)); + v.push_back(columns[4] + " = " + std::to_string(e.chance)); + v.push_back(columns[5] + " = " + std::to_string(e.npc_id)); + v.push_back(columns[6] + " = " + std::to_string(e.npc_chance)); + v.push_back(columns[7] + " = " + std::to_string(e.min_expansion)); + v.push_back(columns[8] + " = " + std::to_string(e.max_expansion)); + v.push_back(columns[9] + " = '" + Strings::Escape(e.content_flags) + "'"); + v.push_back(columns[10] + " = '" + Strings::Escape(e.content_flags_disabled) + "'"); auto results = db.QueryDatabase( fmt::format( "UPDATE {} SET {} WHERE {} = {}", TableName(), - Strings::Implode(", ", update_values), + Strings::Implode(", ", v), PrimaryKey(), - fishing_entry.id + e.id ) ); @@ -224,67 +224,67 @@ public: static Fishing InsertOne( Database& db, - Fishing fishing_entry + Fishing e ) { - std::vector insert_values; + std::vector v; - insert_values.push_back(std::to_string(fishing_entry.id)); - insert_values.push_back(std::to_string(fishing_entry.zoneid)); - insert_values.push_back(std::to_string(fishing_entry.Itemid)); - insert_values.push_back(std::to_string(fishing_entry.skill_level)); - insert_values.push_back(std::to_string(fishing_entry.chance)); - insert_values.push_back(std::to_string(fishing_entry.npc_id)); - insert_values.push_back(std::to_string(fishing_entry.npc_chance)); - insert_values.push_back(std::to_string(fishing_entry.min_expansion)); - insert_values.push_back(std::to_string(fishing_entry.max_expansion)); - insert_values.push_back("'" + Strings::Escape(fishing_entry.content_flags) + "'"); - insert_values.push_back("'" + Strings::Escape(fishing_entry.content_flags_disabled) + "'"); + v.push_back(std::to_string(e.id)); + v.push_back(std::to_string(e.zoneid)); + v.push_back(std::to_string(e.Itemid)); + v.push_back(std::to_string(e.skill_level)); + v.push_back(std::to_string(e.chance)); + v.push_back(std::to_string(e.npc_id)); + v.push_back(std::to_string(e.npc_chance)); + v.push_back(std::to_string(e.min_expansion)); + v.push_back(std::to_string(e.max_expansion)); + v.push_back("'" + Strings::Escape(e.content_flags) + "'"); + v.push_back("'" + Strings::Escape(e.content_flags_disabled) + "'"); auto results = db.QueryDatabase( fmt::format( "{} VALUES ({})", BaseInsert(), - Strings::Implode(",", insert_values) + Strings::Implode(",", v) ) ); if (results.Success()) { - fishing_entry.id = results.LastInsertedID(); - return fishing_entry; + e.id = results.LastInsertedID(); + return e; } - fishing_entry = NewEntity(); + e = NewEntity(); - return fishing_entry; + return e; } static int InsertMany( Database& db, - std::vector fishing_entries + const std::vector &entries ) { std::vector insert_chunks; - for (auto &fishing_entry: fishing_entries) { - std::vector insert_values; + for (auto &e: entries) { + std::vector v; - insert_values.push_back(std::to_string(fishing_entry.id)); - insert_values.push_back(std::to_string(fishing_entry.zoneid)); - insert_values.push_back(std::to_string(fishing_entry.Itemid)); - insert_values.push_back(std::to_string(fishing_entry.skill_level)); - insert_values.push_back(std::to_string(fishing_entry.chance)); - insert_values.push_back(std::to_string(fishing_entry.npc_id)); - insert_values.push_back(std::to_string(fishing_entry.npc_chance)); - insert_values.push_back(std::to_string(fishing_entry.min_expansion)); - insert_values.push_back(std::to_string(fishing_entry.max_expansion)); - insert_values.push_back("'" + Strings::Escape(fishing_entry.content_flags) + "'"); - insert_values.push_back("'" + Strings::Escape(fishing_entry.content_flags_disabled) + "'"); + v.push_back(std::to_string(e.id)); + v.push_back(std::to_string(e.zoneid)); + v.push_back(std::to_string(e.Itemid)); + v.push_back(std::to_string(e.skill_level)); + v.push_back(std::to_string(e.chance)); + v.push_back(std::to_string(e.npc_id)); + v.push_back(std::to_string(e.npc_chance)); + v.push_back(std::to_string(e.min_expansion)); + v.push_back(std::to_string(e.max_expansion)); + v.push_back("'" + Strings::Escape(e.content_flags) + "'"); + v.push_back("'" + Strings::Escape(e.content_flags_disabled) + "'"); - insert_chunks.push_back("(" + Strings::Implode(",", insert_values) + ")"); + insert_chunks.push_back("(" + Strings::Implode(",", v) + ")"); } - std::vector insert_values; + std::vector v; auto results = db.QueryDatabase( fmt::format( @@ -311,27 +311,27 @@ public: all_entries.reserve(results.RowCount()); for (auto row = results.begin(); row != results.end(); ++row) { - Fishing entry{}; + Fishing e{}; - entry.id = atoi(row[0]); - entry.zoneid = atoi(row[1]); - entry.Itemid = atoi(row[2]); - entry.skill_level = atoi(row[3]); - entry.chance = atoi(row[4]); - entry.npc_id = atoi(row[5]); - entry.npc_chance = atoi(row[6]); - entry.min_expansion = atoi(row[7]); - entry.max_expansion = atoi(row[8]); - entry.content_flags = row[9] ? row[9] : ""; - entry.content_flags_disabled = row[10] ? row[10] : ""; + e.id = atoi(row[0]); + e.zoneid = atoi(row[1]); + e.Itemid = atoi(row[2]); + e.skill_level = atoi(row[3]); + e.chance = atoi(row[4]); + e.npc_id = atoi(row[5]); + e.npc_chance = atoi(row[6]); + e.min_expansion = atoi(row[7]); + e.max_expansion = atoi(row[8]); + e.content_flags = row[9] ? row[9] : ""; + e.content_flags_disabled = row[10] ? row[10] : ""; - all_entries.push_back(entry); + all_entries.push_back(e); } return all_entries; } - static std::vector GetWhere(Database& db, std::string where_filter) + static std::vector GetWhere(Database& db, const std::string &where_filter) { std::vector all_entries; @@ -346,27 +346,27 @@ public: all_entries.reserve(results.RowCount()); for (auto row = results.begin(); row != results.end(); ++row) { - Fishing entry{}; + Fishing e{}; - entry.id = atoi(row[0]); - entry.zoneid = atoi(row[1]); - entry.Itemid = atoi(row[2]); - entry.skill_level = atoi(row[3]); - entry.chance = atoi(row[4]); - entry.npc_id = atoi(row[5]); - entry.npc_chance = atoi(row[6]); - entry.min_expansion = atoi(row[7]); - entry.max_expansion = atoi(row[8]); - entry.content_flags = row[9] ? row[9] : ""; - entry.content_flags_disabled = row[10] ? row[10] : ""; + e.id = atoi(row[0]); + e.zoneid = atoi(row[1]); + e.Itemid = atoi(row[2]); + e.skill_level = atoi(row[3]); + e.chance = atoi(row[4]); + e.npc_id = atoi(row[5]); + e.npc_chance = atoi(row[6]); + e.min_expansion = atoi(row[7]); + e.max_expansion = atoi(row[8]); + e.content_flags = row[9] ? row[9] : ""; + e.content_flags_disabled = row[10] ? row[10] : ""; - all_entries.push_back(entry); + all_entries.push_back(e); } return all_entries; } - static int DeleteWhere(Database& db, std::string where_filter) + static int DeleteWhere(Database& db, const std::string &where_filter) { auto results = db.QueryDatabase( fmt::format( @@ -391,6 +391,32 @@ public: 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); + } + }; #endif //EQEMU_BASE_FISHING_REPOSITORY_H diff --git a/common/repositories/base/base_forage_repository.h b/common/repositories/base/base_forage_repository.h index 2e7a781fc..af5131689 100644 --- a/common/repositories/base/base_forage_repository.h +++ b/common/repositories/base/base_forage_repository.h @@ -100,22 +100,22 @@ public: static Forage NewEntity() { - Forage entry{}; + Forage e{}; - entry.id = 0; - entry.zoneid = 0; - entry.Itemid = 0; - entry.level = 0; - entry.chance = 0; - entry.min_expansion = -1; - entry.max_expansion = -1; - entry.content_flags = ""; - entry.content_flags_disabled = ""; + e.id = 0; + e.zoneid = 0; + e.Itemid = 0; + e.level = 0; + e.chance = 0; + e.min_expansion = -1; + e.max_expansion = -1; + e.content_flags = ""; + e.content_flags_disabled = ""; - return entry; + return e; } - static Forage GetForageEntry( + static Forage GetForage( const std::vector &forages, int forage_id ) @@ -144,19 +144,19 @@ public: auto row = results.begin(); if (results.RowCount() == 1) { - Forage entry{}; + Forage e{}; - entry.id = atoi(row[0]); - entry.zoneid = atoi(row[1]); - entry.Itemid = atoi(row[2]); - entry.level = atoi(row[3]); - entry.chance = atoi(row[4]); - entry.min_expansion = atoi(row[5]); - entry.max_expansion = atoi(row[6]); - entry.content_flags = row[7] ? row[7] : ""; - entry.content_flags_disabled = row[8] ? row[8] : ""; + e.id = atoi(row[0]); + e.zoneid = atoi(row[1]); + e.Itemid = atoi(row[2]); + e.level = atoi(row[3]); + e.chance = atoi(row[4]); + e.min_expansion = atoi(row[5]); + e.max_expansion = atoi(row[6]); + e.content_flags = row[7] ? row[7] : ""; + e.content_flags_disabled = row[8] ? row[8] : ""; - return entry; + return e; } return NewEntity(); @@ -181,29 +181,29 @@ public: static int UpdateOne( Database& db, - Forage forage_entry + const Forage &e ) { - std::vector update_values; + std::vector v; auto columns = Columns(); - update_values.push_back(columns[1] + " = " + std::to_string(forage_entry.zoneid)); - update_values.push_back(columns[2] + " = " + std::to_string(forage_entry.Itemid)); - update_values.push_back(columns[3] + " = " + std::to_string(forage_entry.level)); - update_values.push_back(columns[4] + " = " + std::to_string(forage_entry.chance)); - update_values.push_back(columns[5] + " = " + std::to_string(forage_entry.min_expansion)); - update_values.push_back(columns[6] + " = " + std::to_string(forage_entry.max_expansion)); - update_values.push_back(columns[7] + " = '" + Strings::Escape(forage_entry.content_flags) + "'"); - update_values.push_back(columns[8] + " = '" + Strings::Escape(forage_entry.content_flags_disabled) + "'"); + v.push_back(columns[1] + " = " + std::to_string(e.zoneid)); + v.push_back(columns[2] + " = " + std::to_string(e.Itemid)); + v.push_back(columns[3] + " = " + std::to_string(e.level)); + v.push_back(columns[4] + " = " + std::to_string(e.chance)); + v.push_back(columns[5] + " = " + std::to_string(e.min_expansion)); + v.push_back(columns[6] + " = " + std::to_string(e.max_expansion)); + v.push_back(columns[7] + " = '" + Strings::Escape(e.content_flags) + "'"); + v.push_back(columns[8] + " = '" + Strings::Escape(e.content_flags_disabled) + "'"); auto results = db.QueryDatabase( fmt::format( "UPDATE {} SET {} WHERE {} = {}", TableName(), - Strings::Implode(", ", update_values), + Strings::Implode(", ", v), PrimaryKey(), - forage_entry.id + e.id ) ); @@ -212,63 +212,63 @@ public: static Forage InsertOne( Database& db, - Forage forage_entry + Forage e ) { - std::vector insert_values; + std::vector v; - insert_values.push_back(std::to_string(forage_entry.id)); - insert_values.push_back(std::to_string(forage_entry.zoneid)); - insert_values.push_back(std::to_string(forage_entry.Itemid)); - insert_values.push_back(std::to_string(forage_entry.level)); - insert_values.push_back(std::to_string(forage_entry.chance)); - insert_values.push_back(std::to_string(forage_entry.min_expansion)); - insert_values.push_back(std::to_string(forage_entry.max_expansion)); - insert_values.push_back("'" + Strings::Escape(forage_entry.content_flags) + "'"); - insert_values.push_back("'" + Strings::Escape(forage_entry.content_flags_disabled) + "'"); + v.push_back(std::to_string(e.id)); + v.push_back(std::to_string(e.zoneid)); + v.push_back(std::to_string(e.Itemid)); + v.push_back(std::to_string(e.level)); + v.push_back(std::to_string(e.chance)); + v.push_back(std::to_string(e.min_expansion)); + v.push_back(std::to_string(e.max_expansion)); + v.push_back("'" + Strings::Escape(e.content_flags) + "'"); + v.push_back("'" + Strings::Escape(e.content_flags_disabled) + "'"); auto results = db.QueryDatabase( fmt::format( "{} VALUES ({})", BaseInsert(), - Strings::Implode(",", insert_values) + Strings::Implode(",", v) ) ); if (results.Success()) { - forage_entry.id = results.LastInsertedID(); - return forage_entry; + e.id = results.LastInsertedID(); + return e; } - forage_entry = NewEntity(); + e = NewEntity(); - return forage_entry; + return e; } static int InsertMany( Database& db, - std::vector forage_entries + const std::vector &entries ) { std::vector insert_chunks; - for (auto &forage_entry: forage_entries) { - std::vector insert_values; + for (auto &e: entries) { + std::vector v; - insert_values.push_back(std::to_string(forage_entry.id)); - insert_values.push_back(std::to_string(forage_entry.zoneid)); - insert_values.push_back(std::to_string(forage_entry.Itemid)); - insert_values.push_back(std::to_string(forage_entry.level)); - insert_values.push_back(std::to_string(forage_entry.chance)); - insert_values.push_back(std::to_string(forage_entry.min_expansion)); - insert_values.push_back(std::to_string(forage_entry.max_expansion)); - insert_values.push_back("'" + Strings::Escape(forage_entry.content_flags) + "'"); - insert_values.push_back("'" + Strings::Escape(forage_entry.content_flags_disabled) + "'"); + v.push_back(std::to_string(e.id)); + v.push_back(std::to_string(e.zoneid)); + v.push_back(std::to_string(e.Itemid)); + v.push_back(std::to_string(e.level)); + v.push_back(std::to_string(e.chance)); + v.push_back(std::to_string(e.min_expansion)); + v.push_back(std::to_string(e.max_expansion)); + v.push_back("'" + Strings::Escape(e.content_flags) + "'"); + v.push_back("'" + Strings::Escape(e.content_flags_disabled) + "'"); - insert_chunks.push_back("(" + Strings::Implode(",", insert_values) + ")"); + insert_chunks.push_back("(" + Strings::Implode(",", v) + ")"); } - std::vector insert_values; + std::vector v; auto results = db.QueryDatabase( fmt::format( @@ -295,25 +295,25 @@ public: all_entries.reserve(results.RowCount()); for (auto row = results.begin(); row != results.end(); ++row) { - Forage entry{}; + Forage e{}; - entry.id = atoi(row[0]); - entry.zoneid = atoi(row[1]); - entry.Itemid = atoi(row[2]); - entry.level = atoi(row[3]); - entry.chance = atoi(row[4]); - entry.min_expansion = atoi(row[5]); - entry.max_expansion = atoi(row[6]); - entry.content_flags = row[7] ? row[7] : ""; - entry.content_flags_disabled = row[8] ? row[8] : ""; + e.id = atoi(row[0]); + e.zoneid = atoi(row[1]); + e.Itemid = atoi(row[2]); + e.level = atoi(row[3]); + e.chance = atoi(row[4]); + e.min_expansion = atoi(row[5]); + e.max_expansion = atoi(row[6]); + e.content_flags = row[7] ? row[7] : ""; + e.content_flags_disabled = row[8] ? row[8] : ""; - all_entries.push_back(entry); + all_entries.push_back(e); } return all_entries; } - static std::vector GetWhere(Database& db, std::string where_filter) + static std::vector GetWhere(Database& db, const std::string &where_filter) { std::vector all_entries; @@ -328,25 +328,25 @@ public: all_entries.reserve(results.RowCount()); for (auto row = results.begin(); row != results.end(); ++row) { - Forage entry{}; + Forage e{}; - entry.id = atoi(row[0]); - entry.zoneid = atoi(row[1]); - entry.Itemid = atoi(row[2]); - entry.level = atoi(row[3]); - entry.chance = atoi(row[4]); - entry.min_expansion = atoi(row[5]); - entry.max_expansion = atoi(row[6]); - entry.content_flags = row[7] ? row[7] : ""; - entry.content_flags_disabled = row[8] ? row[8] : ""; + e.id = atoi(row[0]); + e.zoneid = atoi(row[1]); + e.Itemid = atoi(row[2]); + e.level = atoi(row[3]); + e.chance = atoi(row[4]); + e.min_expansion = atoi(row[5]); + e.max_expansion = atoi(row[6]); + e.content_flags = row[7] ? row[7] : ""; + e.content_flags_disabled = row[8] ? row[8] : ""; - all_entries.push_back(entry); + all_entries.push_back(e); } return all_entries; } - static int DeleteWhere(Database& db, std::string where_filter) + static int DeleteWhere(Database& db, const std::string &where_filter) { auto results = db.QueryDatabase( fmt::format( @@ -371,6 +371,32 @@ public: 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); + } + }; #endif //EQEMU_BASE_FORAGE_REPOSITORY_H diff --git a/common/repositories/base/base_friends_repository.h b/common/repositories/base/base_friends_repository.h index 16c7273be..b6c8a9e66 100644 --- a/common/repositories/base/base_friends_repository.h +++ b/common/repositories/base/base_friends_repository.h @@ -82,16 +82,16 @@ public: static Friends NewEntity() { - Friends entry{}; + Friends e{}; - entry.charid = 0; - entry.type = 1; - entry.name = ""; + e.charid = 0; + e.type = 1; + e.name = ""; - return entry; + return e; } - static Friends GetFriendsEntry( + static Friends GetFriends( const std::vector &friendss, int friends_id ) @@ -120,13 +120,13 @@ public: auto row = results.begin(); if (results.RowCount() == 1) { - Friends entry{}; + Friends e{}; - entry.charid = atoi(row[0]); - entry.type = atoi(row[1]); - entry.name = row[2] ? row[2] : ""; + e.charid = atoi(row[0]); + e.type = atoi(row[1]); + e.name = row[2] ? row[2] : ""; - return entry; + return e; } return NewEntity(); @@ -151,24 +151,24 @@ public: static int UpdateOne( Database& db, - Friends friends_entry + const Friends &e ) { - std::vector update_values; + std::vector v; auto columns = Columns(); - update_values.push_back(columns[0] + " = " + std::to_string(friends_entry.charid)); - update_values.push_back(columns[1] + " = " + std::to_string(friends_entry.type)); - update_values.push_back(columns[2] + " = '" + Strings::Escape(friends_entry.name) + "'"); + v.push_back(columns[0] + " = " + std::to_string(e.charid)); + v.push_back(columns[1] + " = " + std::to_string(e.type)); + v.push_back(columns[2] + " = '" + Strings::Escape(e.name) + "'"); auto results = db.QueryDatabase( fmt::format( "UPDATE {} SET {} WHERE {} = {}", TableName(), - Strings::Implode(", ", update_values), + Strings::Implode(", ", v), PrimaryKey(), - friends_entry.charid + e.charid ) ); @@ -177,51 +177,51 @@ public: static Friends InsertOne( Database& db, - Friends friends_entry + Friends e ) { - std::vector insert_values; + std::vector v; - insert_values.push_back(std::to_string(friends_entry.charid)); - insert_values.push_back(std::to_string(friends_entry.type)); - insert_values.push_back("'" + Strings::Escape(friends_entry.name) + "'"); + v.push_back(std::to_string(e.charid)); + v.push_back(std::to_string(e.type)); + v.push_back("'" + Strings::Escape(e.name) + "'"); auto results = db.QueryDatabase( fmt::format( "{} VALUES ({})", BaseInsert(), - Strings::Implode(",", insert_values) + Strings::Implode(",", v) ) ); if (results.Success()) { - friends_entry.charid = results.LastInsertedID(); - return friends_entry; + e.charid = results.LastInsertedID(); + return e; } - friends_entry = NewEntity(); + e = NewEntity(); - return friends_entry; + return e; } static int InsertMany( Database& db, - std::vector friends_entries + const std::vector &entries ) { std::vector insert_chunks; - for (auto &friends_entry: friends_entries) { - std::vector insert_values; + for (auto &e: entries) { + std::vector v; - insert_values.push_back(std::to_string(friends_entry.charid)); - insert_values.push_back(std::to_string(friends_entry.type)); - insert_values.push_back("'" + Strings::Escape(friends_entry.name) + "'"); + v.push_back(std::to_string(e.charid)); + v.push_back(std::to_string(e.type)); + v.push_back("'" + Strings::Escape(e.name) + "'"); - insert_chunks.push_back("(" + Strings::Implode(",", insert_values) + ")"); + insert_chunks.push_back("(" + Strings::Implode(",", v) + ")"); } - std::vector insert_values; + std::vector v; auto results = db.QueryDatabase( fmt::format( @@ -248,19 +248,19 @@ public: all_entries.reserve(results.RowCount()); for (auto row = results.begin(); row != results.end(); ++row) { - Friends entry{}; + Friends e{}; - entry.charid = atoi(row[0]); - entry.type = atoi(row[1]); - entry.name = row[2] ? row[2] : ""; + e.charid = atoi(row[0]); + e.type = atoi(row[1]); + e.name = row[2] ? row[2] : ""; - all_entries.push_back(entry); + all_entries.push_back(e); } return all_entries; } - static std::vector GetWhere(Database& db, std::string where_filter) + static std::vector GetWhere(Database& db, const std::string &where_filter) { std::vector all_entries; @@ -275,19 +275,19 @@ public: all_entries.reserve(results.RowCount()); for (auto row = results.begin(); row != results.end(); ++row) { - Friends entry{}; + Friends e{}; - entry.charid = atoi(row[0]); - entry.type = atoi(row[1]); - entry.name = row[2] ? row[2] : ""; + e.charid = atoi(row[0]); + e.type = atoi(row[1]); + e.name = row[2] ? row[2] : ""; - all_entries.push_back(entry); + all_entries.push_back(e); } return all_entries; } - static int DeleteWhere(Database& db, std::string where_filter) + static int DeleteWhere(Database& db, const std::string &where_filter) { auto results = db.QueryDatabase( fmt::format( @@ -312,6 +312,32 @@ public: 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); + } + }; #endif //EQEMU_BASE_FRIENDS_REPOSITORY_H diff --git a/common/repositories/base/base_global_loot_repository.h b/common/repositories/base/base_global_loot_repository.h index 5a138f1ab..e3326d672 100644 --- a/common/repositories/base/base_global_loot_repository.h +++ b/common/repositories/base/base_global_loot_repository.h @@ -124,30 +124,30 @@ public: static GlobalLoot NewEntity() { - GlobalLoot entry{}; + GlobalLoot e{}; - entry.id = 0; - entry.description = ""; - entry.loottable_id = 0; - entry.enabled = 1; - entry.min_level = 0; - entry.max_level = 0; - entry.rare = 0; - entry.raid = 0; - entry.race = ""; - entry.class_ = ""; - entry.bodytype = ""; - entry.zone = ""; - entry.hot_zone = 0; - entry.min_expansion = -1; - entry.max_expansion = -1; - entry.content_flags = ""; - entry.content_flags_disabled = ""; + e.id = 0; + e.description = ""; + e.loottable_id = 0; + e.enabled = 1; + e.min_level = 0; + e.max_level = 0; + e.rare = 0; + e.raid = 0; + e.race = ""; + e.class_ = ""; + e.bodytype = ""; + e.zone = ""; + e.hot_zone = 0; + e.min_expansion = -1; + e.max_expansion = -1; + e.content_flags = ""; + e.content_flags_disabled = ""; - return entry; + return e; } - static GlobalLoot GetGlobalLootEntry( + static GlobalLoot GetGlobalLoot( const std::vector &global_loots, int global_loot_id ) @@ -176,27 +176,27 @@ public: auto row = results.begin(); if (results.RowCount() == 1) { - GlobalLoot entry{}; + GlobalLoot e{}; - entry.id = atoi(row[0]); - entry.description = row[1] ? row[1] : ""; - entry.loottable_id = atoi(row[2]); - entry.enabled = atoi(row[3]); - entry.min_level = atoi(row[4]); - entry.max_level = atoi(row[5]); - entry.rare = atoi(row[6]); - entry.raid = atoi(row[7]); - entry.race = row[8] ? row[8] : ""; - entry.class_ = row[9] ? row[9] : ""; - entry.bodytype = row[10] ? row[10] : ""; - entry.zone = row[11] ? row[11] : ""; - entry.hot_zone = atoi(row[12]); - entry.min_expansion = atoi(row[13]); - entry.max_expansion = atoi(row[14]); - entry.content_flags = row[15] ? row[15] : ""; - entry.content_flags_disabled = row[16] ? row[16] : ""; + e.id = atoi(row[0]); + e.description = row[1] ? row[1] : ""; + e.loottable_id = atoi(row[2]); + e.enabled = atoi(row[3]); + e.min_level = atoi(row[4]); + e.max_level = atoi(row[5]); + e.rare = atoi(row[6]); + e.raid = atoi(row[7]); + e.race = row[8] ? row[8] : ""; + e.class_ = row[9] ? row[9] : ""; + e.bodytype = row[10] ? row[10] : ""; + e.zone = row[11] ? row[11] : ""; + e.hot_zone = atoi(row[12]); + e.min_expansion = atoi(row[13]); + e.max_expansion = atoi(row[14]); + e.content_flags = row[15] ? row[15] : ""; + e.content_flags_disabled = row[16] ? row[16] : ""; - return entry; + return e; } return NewEntity(); @@ -221,37 +221,37 @@ public: static int UpdateOne( Database& db, - GlobalLoot global_loot_entry + const GlobalLoot &e ) { - std::vector update_values; + std::vector v; auto columns = Columns(); - update_values.push_back(columns[1] + " = '" + Strings::Escape(global_loot_entry.description) + "'"); - update_values.push_back(columns[2] + " = " + std::to_string(global_loot_entry.loottable_id)); - update_values.push_back(columns[3] + " = " + std::to_string(global_loot_entry.enabled)); - update_values.push_back(columns[4] + " = " + std::to_string(global_loot_entry.min_level)); - update_values.push_back(columns[5] + " = " + std::to_string(global_loot_entry.max_level)); - update_values.push_back(columns[6] + " = " + std::to_string(global_loot_entry.rare)); - update_values.push_back(columns[7] + " = " + std::to_string(global_loot_entry.raid)); - update_values.push_back(columns[8] + " = '" + Strings::Escape(global_loot_entry.race) + "'"); - update_values.push_back(columns[9] + " = '" + Strings::Escape(global_loot_entry.class_) + "'"); - update_values.push_back(columns[10] + " = '" + Strings::Escape(global_loot_entry.bodytype) + "'"); - update_values.push_back(columns[11] + " = '" + Strings::Escape(global_loot_entry.zone) + "'"); - update_values.push_back(columns[12] + " = " + std::to_string(global_loot_entry.hot_zone)); - update_values.push_back(columns[13] + " = " + std::to_string(global_loot_entry.min_expansion)); - update_values.push_back(columns[14] + " = " + std::to_string(global_loot_entry.max_expansion)); - update_values.push_back(columns[15] + " = '" + Strings::Escape(global_loot_entry.content_flags) + "'"); - update_values.push_back(columns[16] + " = '" + Strings::Escape(global_loot_entry.content_flags_disabled) + "'"); + v.push_back(columns[1] + " = '" + Strings::Escape(e.description) + "'"); + v.push_back(columns[2] + " = " + std::to_string(e.loottable_id)); + v.push_back(columns[3] + " = " + std::to_string(e.enabled)); + v.push_back(columns[4] + " = " + std::to_string(e.min_level)); + v.push_back(columns[5] + " = " + std::to_string(e.max_level)); + v.push_back(columns[6] + " = " + std::to_string(e.rare)); + v.push_back(columns[7] + " = " + std::to_string(e.raid)); + v.push_back(columns[8] + " = '" + Strings::Escape(e.race) + "'"); + v.push_back(columns[9] + " = '" + Strings::Escape(e.class_) + "'"); + v.push_back(columns[10] + " = '" + Strings::Escape(e.bodytype) + "'"); + v.push_back(columns[11] + " = '" + Strings::Escape(e.zone) + "'"); + v.push_back(columns[12] + " = " + std::to_string(e.hot_zone)); + v.push_back(columns[13] + " = " + std::to_string(e.min_expansion)); + v.push_back(columns[14] + " = " + std::to_string(e.max_expansion)); + v.push_back(columns[15] + " = '" + Strings::Escape(e.content_flags) + "'"); + v.push_back(columns[16] + " = '" + Strings::Escape(e.content_flags_disabled) + "'"); auto results = db.QueryDatabase( fmt::format( "UPDATE {} SET {} WHERE {} = {}", TableName(), - Strings::Implode(", ", update_values), + Strings::Implode(", ", v), PrimaryKey(), - global_loot_entry.id + e.id ) ); @@ -260,79 +260,79 @@ public: static GlobalLoot InsertOne( Database& db, - GlobalLoot global_loot_entry + GlobalLoot e ) { - std::vector insert_values; + std::vector v; - insert_values.push_back(std::to_string(global_loot_entry.id)); - insert_values.push_back("'" + Strings::Escape(global_loot_entry.description) + "'"); - insert_values.push_back(std::to_string(global_loot_entry.loottable_id)); - insert_values.push_back(std::to_string(global_loot_entry.enabled)); - insert_values.push_back(std::to_string(global_loot_entry.min_level)); - insert_values.push_back(std::to_string(global_loot_entry.max_level)); - insert_values.push_back(std::to_string(global_loot_entry.rare)); - insert_values.push_back(std::to_string(global_loot_entry.raid)); - insert_values.push_back("'" + Strings::Escape(global_loot_entry.race) + "'"); - insert_values.push_back("'" + Strings::Escape(global_loot_entry.class_) + "'"); - insert_values.push_back("'" + Strings::Escape(global_loot_entry.bodytype) + "'"); - insert_values.push_back("'" + Strings::Escape(global_loot_entry.zone) + "'"); - insert_values.push_back(std::to_string(global_loot_entry.hot_zone)); - insert_values.push_back(std::to_string(global_loot_entry.min_expansion)); - insert_values.push_back(std::to_string(global_loot_entry.max_expansion)); - insert_values.push_back("'" + Strings::Escape(global_loot_entry.content_flags) + "'"); - insert_values.push_back("'" + Strings::Escape(global_loot_entry.content_flags_disabled) + "'"); + v.push_back(std::to_string(e.id)); + v.push_back("'" + Strings::Escape(e.description) + "'"); + v.push_back(std::to_string(e.loottable_id)); + v.push_back(std::to_string(e.enabled)); + v.push_back(std::to_string(e.min_level)); + v.push_back(std::to_string(e.max_level)); + v.push_back(std::to_string(e.rare)); + v.push_back(std::to_string(e.raid)); + v.push_back("'" + Strings::Escape(e.race) + "'"); + v.push_back("'" + Strings::Escape(e.class_) + "'"); + v.push_back("'" + Strings::Escape(e.bodytype) + "'"); + v.push_back("'" + Strings::Escape(e.zone) + "'"); + v.push_back(std::to_string(e.hot_zone)); + v.push_back(std::to_string(e.min_expansion)); + v.push_back(std::to_string(e.max_expansion)); + v.push_back("'" + Strings::Escape(e.content_flags) + "'"); + v.push_back("'" + Strings::Escape(e.content_flags_disabled) + "'"); auto results = db.QueryDatabase( fmt::format( "{} VALUES ({})", BaseInsert(), - Strings::Implode(",", insert_values) + Strings::Implode(",", v) ) ); if (results.Success()) { - global_loot_entry.id = results.LastInsertedID(); - return global_loot_entry; + e.id = results.LastInsertedID(); + return e; } - global_loot_entry = NewEntity(); + e = NewEntity(); - return global_loot_entry; + return e; } static int InsertMany( Database& db, - std::vector global_loot_entries + const std::vector &entries ) { std::vector insert_chunks; - for (auto &global_loot_entry: global_loot_entries) { - std::vector insert_values; + for (auto &e: entries) { + std::vector v; - insert_values.push_back(std::to_string(global_loot_entry.id)); - insert_values.push_back("'" + Strings::Escape(global_loot_entry.description) + "'"); - insert_values.push_back(std::to_string(global_loot_entry.loottable_id)); - insert_values.push_back(std::to_string(global_loot_entry.enabled)); - insert_values.push_back(std::to_string(global_loot_entry.min_level)); - insert_values.push_back(std::to_string(global_loot_entry.max_level)); - insert_values.push_back(std::to_string(global_loot_entry.rare)); - insert_values.push_back(std::to_string(global_loot_entry.raid)); - insert_values.push_back("'" + Strings::Escape(global_loot_entry.race) + "'"); - insert_values.push_back("'" + Strings::Escape(global_loot_entry.class_) + "'"); - insert_values.push_back("'" + Strings::Escape(global_loot_entry.bodytype) + "'"); - insert_values.push_back("'" + Strings::Escape(global_loot_entry.zone) + "'"); - insert_values.push_back(std::to_string(global_loot_entry.hot_zone)); - insert_values.push_back(std::to_string(global_loot_entry.min_expansion)); - insert_values.push_back(std::to_string(global_loot_entry.max_expansion)); - insert_values.push_back("'" + Strings::Escape(global_loot_entry.content_flags) + "'"); - insert_values.push_back("'" + Strings::Escape(global_loot_entry.content_flags_disabled) + "'"); + v.push_back(std::to_string(e.id)); + v.push_back("'" + Strings::Escape(e.description) + "'"); + v.push_back(std::to_string(e.loottable_id)); + v.push_back(std::to_string(e.enabled)); + v.push_back(std::to_string(e.min_level)); + v.push_back(std::to_string(e.max_level)); + v.push_back(std::to_string(e.rare)); + v.push_back(std::to_string(e.raid)); + v.push_back("'" + Strings::Escape(e.race) + "'"); + v.push_back("'" + Strings::Escape(e.class_) + "'"); + v.push_back("'" + Strings::Escape(e.bodytype) + "'"); + v.push_back("'" + Strings::Escape(e.zone) + "'"); + v.push_back(std::to_string(e.hot_zone)); + v.push_back(std::to_string(e.min_expansion)); + v.push_back(std::to_string(e.max_expansion)); + v.push_back("'" + Strings::Escape(e.content_flags) + "'"); + v.push_back("'" + Strings::Escape(e.content_flags_disabled) + "'"); - insert_chunks.push_back("(" + Strings::Implode(",", insert_values) + ")"); + insert_chunks.push_back("(" + Strings::Implode(",", v) + ")"); } - std::vector insert_values; + std::vector v; auto results = db.QueryDatabase( fmt::format( @@ -359,33 +359,33 @@ public: all_entries.reserve(results.RowCount()); for (auto row = results.begin(); row != results.end(); ++row) { - GlobalLoot entry{}; + GlobalLoot e{}; - entry.id = atoi(row[0]); - entry.description = row[1] ? row[1] : ""; - entry.loottable_id = atoi(row[2]); - entry.enabled = atoi(row[3]); - entry.min_level = atoi(row[4]); - entry.max_level = atoi(row[5]); - entry.rare = atoi(row[6]); - entry.raid = atoi(row[7]); - entry.race = row[8] ? row[8] : ""; - entry.class_ = row[9] ? row[9] : ""; - entry.bodytype = row[10] ? row[10] : ""; - entry.zone = row[11] ? row[11] : ""; - entry.hot_zone = atoi(row[12]); - entry.min_expansion = atoi(row[13]); - entry.max_expansion = atoi(row[14]); - entry.content_flags = row[15] ? row[15] : ""; - entry.content_flags_disabled = row[16] ? row[16] : ""; + e.id = atoi(row[0]); + e.description = row[1] ? row[1] : ""; + e.loottable_id = atoi(row[2]); + e.enabled = atoi(row[3]); + e.min_level = atoi(row[4]); + e.max_level = atoi(row[5]); + e.rare = atoi(row[6]); + e.raid = atoi(row[7]); + e.race = row[8] ? row[8] : ""; + e.class_ = row[9] ? row[9] : ""; + e.bodytype = row[10] ? row[10] : ""; + e.zone = row[11] ? row[11] : ""; + e.hot_zone = atoi(row[12]); + e.min_expansion = atoi(row[13]); + e.max_expansion = atoi(row[14]); + e.content_flags = row[15] ? row[15] : ""; + e.content_flags_disabled = row[16] ? row[16] : ""; - all_entries.push_back(entry); + all_entries.push_back(e); } return all_entries; } - static std::vector GetWhere(Database& db, std::string where_filter) + static std::vector GetWhere(Database& db, const std::string &where_filter) { std::vector all_entries; @@ -400,33 +400,33 @@ public: all_entries.reserve(results.RowCount()); for (auto row = results.begin(); row != results.end(); ++row) { - GlobalLoot entry{}; + GlobalLoot e{}; - entry.id = atoi(row[0]); - entry.description = row[1] ? row[1] : ""; - entry.loottable_id = atoi(row[2]); - entry.enabled = atoi(row[3]); - entry.min_level = atoi(row[4]); - entry.max_level = atoi(row[5]); - entry.rare = atoi(row[6]); - entry.raid = atoi(row[7]); - entry.race = row[8] ? row[8] : ""; - entry.class_ = row[9] ? row[9] : ""; - entry.bodytype = row[10] ? row[10] : ""; - entry.zone = row[11] ? row[11] : ""; - entry.hot_zone = atoi(row[12]); - entry.min_expansion = atoi(row[13]); - entry.max_expansion = atoi(row[14]); - entry.content_flags = row[15] ? row[15] : ""; - entry.content_flags_disabled = row[16] ? row[16] : ""; + e.id = atoi(row[0]); + e.description = row[1] ? row[1] : ""; + e.loottable_id = atoi(row[2]); + e.enabled = atoi(row[3]); + e.min_level = atoi(row[4]); + e.max_level = atoi(row[5]); + e.rare = atoi(row[6]); + e.raid = atoi(row[7]); + e.race = row[8] ? row[8] : ""; + e.class_ = row[9] ? row[9] : ""; + e.bodytype = row[10] ? row[10] : ""; + e.zone = row[11] ? row[11] : ""; + e.hot_zone = atoi(row[12]); + e.min_expansion = atoi(row[13]); + e.max_expansion = atoi(row[14]); + e.content_flags = row[15] ? row[15] : ""; + e.content_flags_disabled = row[16] ? row[16] : ""; - all_entries.push_back(entry); + all_entries.push_back(e); } return all_entries; } - static int DeleteWhere(Database& db, std::string where_filter) + static int DeleteWhere(Database& db, const std::string &where_filter) { auto results = db.QueryDatabase( fmt::format( @@ -451,6 +451,32 @@ public: 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); + } + }; #endif //EQEMU_BASE_GLOBAL_LOOT_REPOSITORY_H diff --git a/common/repositories/base/base_gm_ips_repository.h b/common/repositories/base/base_gm_ips_repository.h index cd09ca728..c506ffe62 100644 --- a/common/repositories/base/base_gm_ips_repository.h +++ b/common/repositories/base/base_gm_ips_repository.h @@ -82,16 +82,16 @@ public: static GmIps NewEntity() { - GmIps entry{}; + GmIps e{}; - entry.name = ""; - entry.account_id = 0; - entry.ip_address = ""; + e.name = ""; + e.account_id = 0; + e.ip_address = ""; - return entry; + return e; } - static GmIps GetGmIpsEntry( + static GmIps GetGmIps( const std::vector &gm_ipss, int gm_ips_id ) @@ -120,13 +120,13 @@ public: auto row = results.begin(); if (results.RowCount() == 1) { - GmIps entry{}; + GmIps e{}; - entry.name = row[0] ? row[0] : ""; - entry.account_id = atoi(row[1]); - entry.ip_address = row[2] ? row[2] : ""; + e.name = row[0] ? row[0] : ""; + e.account_id = atoi(row[1]); + e.ip_address = row[2] ? row[2] : ""; - return entry; + return e; } return NewEntity(); @@ -151,24 +151,24 @@ public: static int UpdateOne( Database& db, - GmIps gm_ips_entry + const GmIps &e ) { - std::vector update_values; + std::vector v; auto columns = Columns(); - update_values.push_back(columns[0] + " = '" + Strings::Escape(gm_ips_entry.name) + "'"); - update_values.push_back(columns[1] + " = " + std::to_string(gm_ips_entry.account_id)); - update_values.push_back(columns[2] + " = '" + Strings::Escape(gm_ips_entry.ip_address) + "'"); + v.push_back(columns[0] + " = '" + Strings::Escape(e.name) + "'"); + v.push_back(columns[1] + " = " + std::to_string(e.account_id)); + v.push_back(columns[2] + " = '" + Strings::Escape(e.ip_address) + "'"); auto results = db.QueryDatabase( fmt::format( "UPDATE {} SET {} WHERE {} = {}", TableName(), - Strings::Implode(", ", update_values), + Strings::Implode(", ", v), PrimaryKey(), - gm_ips_entry.account_id + e.account_id ) ); @@ -177,51 +177,51 @@ public: static GmIps InsertOne( Database& db, - GmIps gm_ips_entry + GmIps e ) { - std::vector insert_values; + std::vector v; - insert_values.push_back("'" + Strings::Escape(gm_ips_entry.name) + "'"); - insert_values.push_back(std::to_string(gm_ips_entry.account_id)); - insert_values.push_back("'" + Strings::Escape(gm_ips_entry.ip_address) + "'"); + v.push_back("'" + Strings::Escape(e.name) + "'"); + v.push_back(std::to_string(e.account_id)); + v.push_back("'" + Strings::Escape(e.ip_address) + "'"); auto results = db.QueryDatabase( fmt::format( "{} VALUES ({})", BaseInsert(), - Strings::Implode(",", insert_values) + Strings::Implode(",", v) ) ); if (results.Success()) { - gm_ips_entry.account_id = results.LastInsertedID(); - return gm_ips_entry; + e.account_id = results.LastInsertedID(); + return e; } - gm_ips_entry = NewEntity(); + e = NewEntity(); - return gm_ips_entry; + return e; } static int InsertMany( Database& db, - std::vector gm_ips_entries + const std::vector &entries ) { std::vector insert_chunks; - for (auto &gm_ips_entry: gm_ips_entries) { - std::vector insert_values; + for (auto &e: entries) { + std::vector v; - insert_values.push_back("'" + Strings::Escape(gm_ips_entry.name) + "'"); - insert_values.push_back(std::to_string(gm_ips_entry.account_id)); - insert_values.push_back("'" + Strings::Escape(gm_ips_entry.ip_address) + "'"); + v.push_back("'" + Strings::Escape(e.name) + "'"); + v.push_back(std::to_string(e.account_id)); + v.push_back("'" + Strings::Escape(e.ip_address) + "'"); - insert_chunks.push_back("(" + Strings::Implode(",", insert_values) + ")"); + insert_chunks.push_back("(" + Strings::Implode(",", v) + ")"); } - std::vector insert_values; + std::vector v; auto results = db.QueryDatabase( fmt::format( @@ -248,19 +248,19 @@ public: all_entries.reserve(results.RowCount()); for (auto row = results.begin(); row != results.end(); ++row) { - GmIps entry{}; + GmIps e{}; - entry.name = row[0] ? row[0] : ""; - entry.account_id = atoi(row[1]); - entry.ip_address = row[2] ? row[2] : ""; + e.name = row[0] ? row[0] : ""; + e.account_id = atoi(row[1]); + e.ip_address = row[2] ? row[2] : ""; - all_entries.push_back(entry); + all_entries.push_back(e); } return all_entries; } - static std::vector GetWhere(Database& db, std::string where_filter) + static std::vector GetWhere(Database& db, const std::string &where_filter) { std::vector all_entries; @@ -275,19 +275,19 @@ public: all_entries.reserve(results.RowCount()); for (auto row = results.begin(); row != results.end(); ++row) { - GmIps entry{}; + GmIps e{}; - entry.name = row[0] ? row[0] : ""; - entry.account_id = atoi(row[1]); - entry.ip_address = row[2] ? row[2] : ""; + e.name = row[0] ? row[0] : ""; + e.account_id = atoi(row[1]); + e.ip_address = row[2] ? row[2] : ""; - all_entries.push_back(entry); + all_entries.push_back(e); } return all_entries; } - static int DeleteWhere(Database& db, std::string where_filter) + static int DeleteWhere(Database& db, const std::string &where_filter) { auto results = db.QueryDatabase( fmt::format( @@ -312,6 +312,32 @@ public: 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); + } + }; #endif //EQEMU_BASE_GM_IPS_REPOSITORY_H diff --git a/common/repositories/base/base_goallists_repository.h b/common/repositories/base/base_goallists_repository.h index 2a72c5da4..1c02609f4 100644 --- a/common/repositories/base/base_goallists_repository.h +++ b/common/repositories/base/base_goallists_repository.h @@ -79,15 +79,15 @@ public: static Goallists NewEntity() { - Goallists entry{}; + Goallists e{}; - entry.listid = 0; - entry.entry = 0; + e.listid = 0; + e.entry = 0; - return entry; + return e; } - static Goallists GetGoallistsEntry( + static Goallists GetGoallists( const std::vector &goallistss, int goallists_id ) @@ -116,12 +116,12 @@ public: auto row = results.begin(); if (results.RowCount() == 1) { - Goallists entry{}; + Goallists e{}; - entry.listid = atoi(row[0]); - entry.entry = atoi(row[1]); + e.listid = atoi(row[0]); + e.entry = atoi(row[1]); - return entry; + return e; } return NewEntity(); @@ -146,23 +146,23 @@ public: static int UpdateOne( Database& db, - Goallists goallists_entry + const Goallists &e ) { - std::vector update_values; + std::vector v; auto columns = Columns(); - update_values.push_back(columns[0] + " = " + std::to_string(goallists_entry.listid)); - update_values.push_back(columns[1] + " = " + std::to_string(goallists_entry.entry)); + v.push_back(columns[0] + " = " + std::to_string(e.listid)); + v.push_back(columns[1] + " = " + std::to_string(e.entry)); auto results = db.QueryDatabase( fmt::format( "UPDATE {} SET {} WHERE {} = {}", TableName(), - Strings::Implode(", ", update_values), + Strings::Implode(", ", v), PrimaryKey(), - goallists_entry.listid + e.listid ) ); @@ -171,49 +171,49 @@ public: static Goallists InsertOne( Database& db, - Goallists goallists_entry + Goallists e ) { - std::vector insert_values; + std::vector v; - insert_values.push_back(std::to_string(goallists_entry.listid)); - insert_values.push_back(std::to_string(goallists_entry.entry)); + v.push_back(std::to_string(e.listid)); + v.push_back(std::to_string(e.entry)); auto results = db.QueryDatabase( fmt::format( "{} VALUES ({})", BaseInsert(), - Strings::Implode(",", insert_values) + Strings::Implode(",", v) ) ); if (results.Success()) { - goallists_entry.listid = results.LastInsertedID(); - return goallists_entry; + e.listid = results.LastInsertedID(); + return e; } - goallists_entry = NewEntity(); + e = NewEntity(); - return goallists_entry; + return e; } static int InsertMany( Database& db, - std::vector goallists_entries + const std::vector &entries ) { std::vector insert_chunks; - for (auto &goallists_entry: goallists_entries) { - std::vector insert_values; + for (auto &e: entries) { + std::vector v; - insert_values.push_back(std::to_string(goallists_entry.listid)); - insert_values.push_back(std::to_string(goallists_entry.entry)); + v.push_back(std::to_string(e.listid)); + v.push_back(std::to_string(e.entry)); - insert_chunks.push_back("(" + Strings::Implode(",", insert_values) + ")"); + insert_chunks.push_back("(" + Strings::Implode(",", v) + ")"); } - std::vector insert_values; + std::vector v; auto results = db.QueryDatabase( fmt::format( @@ -240,18 +240,18 @@ public: all_entries.reserve(results.RowCount()); for (auto row = results.begin(); row != results.end(); ++row) { - Goallists entry{}; + Goallists e{}; - entry.listid = atoi(row[0]); - entry.entry = atoi(row[1]); + e.listid = atoi(row[0]); + e.entry = atoi(row[1]); - all_entries.push_back(entry); + all_entries.push_back(e); } return all_entries; } - static std::vector GetWhere(Database& db, std::string where_filter) + static std::vector GetWhere(Database& db, const std::string &where_filter) { std::vector all_entries; @@ -266,18 +266,18 @@ public: all_entries.reserve(results.RowCount()); for (auto row = results.begin(); row != results.end(); ++row) { - Goallists entry{}; + Goallists e{}; - entry.listid = atoi(row[0]); - entry.entry = atoi(row[1]); + e.listid = atoi(row[0]); + e.entry = atoi(row[1]); - all_entries.push_back(entry); + all_entries.push_back(e); } return all_entries; } - static int DeleteWhere(Database& db, std::string where_filter) + static int DeleteWhere(Database& db, const std::string &where_filter) { auto results = db.QueryDatabase( fmt::format( @@ -302,6 +302,32 @@ public: 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); + } + }; #endif //EQEMU_BASE_GOALLISTS_REPOSITORY_H diff --git a/common/repositories/base/base_graveyard_repository.h b/common/repositories/base/base_graveyard_repository.h index 20b3fcd16..3fbfd5c32 100644 --- a/common/repositories/base/base_graveyard_repository.h +++ b/common/repositories/base/base_graveyard_repository.h @@ -91,19 +91,19 @@ public: static Graveyard NewEntity() { - Graveyard entry{}; + Graveyard e{}; - entry.id = 0; - entry.zone_id = 0; - entry.x = 0; - entry.y = 0; - entry.z = 0; - entry.heading = 0; + e.id = 0; + e.zone_id = 0; + e.x = 0; + e.y = 0; + e.z = 0; + e.heading = 0; - return entry; + return e; } - static Graveyard GetGraveyardEntry( + static Graveyard GetGraveyard( const std::vector &graveyards, int graveyard_id ) @@ -132,16 +132,16 @@ public: auto row = results.begin(); if (results.RowCount() == 1) { - Graveyard entry{}; + Graveyard e{}; - entry.id = atoi(row[0]); - entry.zone_id = atoi(row[1]); - entry.x = static_cast(atof(row[2])); - entry.y = static_cast(atof(row[3])); - entry.z = static_cast(atof(row[4])); - entry.heading = static_cast(atof(row[5])); + e.id = atoi(row[0]); + e.zone_id = atoi(row[1]); + e.x = static_cast(atof(row[2])); + e.y = static_cast(atof(row[3])); + e.z = static_cast(atof(row[4])); + e.heading = static_cast(atof(row[5])); - return entry; + return e; } return NewEntity(); @@ -166,26 +166,26 @@ public: static int UpdateOne( Database& db, - Graveyard graveyard_entry + const Graveyard &e ) { - std::vector update_values; + std::vector v; auto columns = Columns(); - update_values.push_back(columns[1] + " = " + std::to_string(graveyard_entry.zone_id)); - update_values.push_back(columns[2] + " = " + std::to_string(graveyard_entry.x)); - update_values.push_back(columns[3] + " = " + std::to_string(graveyard_entry.y)); - update_values.push_back(columns[4] + " = " + std::to_string(graveyard_entry.z)); - update_values.push_back(columns[5] + " = " + std::to_string(graveyard_entry.heading)); + v.push_back(columns[1] + " = " + std::to_string(e.zone_id)); + v.push_back(columns[2] + " = " + std::to_string(e.x)); + v.push_back(columns[3] + " = " + std::to_string(e.y)); + v.push_back(columns[4] + " = " + std::to_string(e.z)); + v.push_back(columns[5] + " = " + std::to_string(e.heading)); auto results = db.QueryDatabase( fmt::format( "UPDATE {} SET {} WHERE {} = {}", TableName(), - Strings::Implode(", ", update_values), + Strings::Implode(", ", v), PrimaryKey(), - graveyard_entry.id + e.id ) ); @@ -194,57 +194,57 @@ public: static Graveyard InsertOne( Database& db, - Graveyard graveyard_entry + Graveyard e ) { - std::vector insert_values; + std::vector v; - insert_values.push_back(std::to_string(graveyard_entry.id)); - insert_values.push_back(std::to_string(graveyard_entry.zone_id)); - insert_values.push_back(std::to_string(graveyard_entry.x)); - insert_values.push_back(std::to_string(graveyard_entry.y)); - insert_values.push_back(std::to_string(graveyard_entry.z)); - insert_values.push_back(std::to_string(graveyard_entry.heading)); + v.push_back(std::to_string(e.id)); + v.push_back(std::to_string(e.zone_id)); + v.push_back(std::to_string(e.x)); + v.push_back(std::to_string(e.y)); + v.push_back(std::to_string(e.z)); + v.push_back(std::to_string(e.heading)); auto results = db.QueryDatabase( fmt::format( "{} VALUES ({})", BaseInsert(), - Strings::Implode(",", insert_values) + Strings::Implode(",", v) ) ); if (results.Success()) { - graveyard_entry.id = results.LastInsertedID(); - return graveyard_entry; + e.id = results.LastInsertedID(); + return e; } - graveyard_entry = NewEntity(); + e = NewEntity(); - return graveyard_entry; + return e; } static int InsertMany( Database& db, - std::vector graveyard_entries + const std::vector &entries ) { std::vector insert_chunks; - for (auto &graveyard_entry: graveyard_entries) { - std::vector insert_values; + for (auto &e: entries) { + std::vector v; - insert_values.push_back(std::to_string(graveyard_entry.id)); - insert_values.push_back(std::to_string(graveyard_entry.zone_id)); - insert_values.push_back(std::to_string(graveyard_entry.x)); - insert_values.push_back(std::to_string(graveyard_entry.y)); - insert_values.push_back(std::to_string(graveyard_entry.z)); - insert_values.push_back(std::to_string(graveyard_entry.heading)); + v.push_back(std::to_string(e.id)); + v.push_back(std::to_string(e.zone_id)); + v.push_back(std::to_string(e.x)); + v.push_back(std::to_string(e.y)); + v.push_back(std::to_string(e.z)); + v.push_back(std::to_string(e.heading)); - insert_chunks.push_back("(" + Strings::Implode(",", insert_values) + ")"); + insert_chunks.push_back("(" + Strings::Implode(",", v) + ")"); } - std::vector insert_values; + std::vector v; auto results = db.QueryDatabase( fmt::format( @@ -271,22 +271,22 @@ public: all_entries.reserve(results.RowCount()); for (auto row = results.begin(); row != results.end(); ++row) { - Graveyard entry{}; + Graveyard e{}; - entry.id = atoi(row[0]); - entry.zone_id = atoi(row[1]); - entry.x = static_cast(atof(row[2])); - entry.y = static_cast(atof(row[3])); - entry.z = static_cast(atof(row[4])); - entry.heading = static_cast(atof(row[5])); + e.id = atoi(row[0]); + e.zone_id = atoi(row[1]); + e.x = static_cast(atof(row[2])); + e.y = static_cast(atof(row[3])); + e.z = static_cast(atof(row[4])); + e.heading = static_cast(atof(row[5])); - all_entries.push_back(entry); + all_entries.push_back(e); } return all_entries; } - static std::vector GetWhere(Database& db, std::string where_filter) + static std::vector GetWhere(Database& db, const std::string &where_filter) { std::vector all_entries; @@ -301,22 +301,22 @@ public: all_entries.reserve(results.RowCount()); for (auto row = results.begin(); row != results.end(); ++row) { - Graveyard entry{}; + Graveyard e{}; - entry.id = atoi(row[0]); - entry.zone_id = atoi(row[1]); - entry.x = static_cast(atof(row[2])); - entry.y = static_cast(atof(row[3])); - entry.z = static_cast(atof(row[4])); - entry.heading = static_cast(atof(row[5])); + e.id = atoi(row[0]); + e.zone_id = atoi(row[1]); + e.x = static_cast(atof(row[2])); + e.y = static_cast(atof(row[3])); + e.z = static_cast(atof(row[4])); + e.heading = static_cast(atof(row[5])); - all_entries.push_back(entry); + all_entries.push_back(e); } return all_entries; } - static int DeleteWhere(Database& db, std::string where_filter) + static int DeleteWhere(Database& db, const std::string &where_filter) { auto results = db.QueryDatabase( fmt::format( @@ -341,6 +341,32 @@ public: 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); + } + }; #endif //EQEMU_BASE_GRAVEYARD_REPOSITORY_H diff --git a/common/repositories/base/base_grid_entries_repository.h b/common/repositories/base/base_grid_entries_repository.h index 0c8290fd1..93129e815 100644 --- a/common/repositories/base/base_grid_entries_repository.h +++ b/common/repositories/base/base_grid_entries_repository.h @@ -1,29 +1,12 @@ /** - * EQEmulator: Everquest Server Emulator - * Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server) + * DO NOT MODIFY THIS FILE * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 2 of the License. + * 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 * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY except by those people which sell it, which - * are required to give you total support for your newly bought product; - * without even the implied warranty of MERCHANTABILITY or FITNESS FOR - * A PARTICULAR PURPOSE. See the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - * - */ - -/** - * This repository was automatically generated on Apr 5, 2020 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://eqemu.gitbook.io/server/in-development/developer-area/repositories */ #ifndef EQEMU_BASE_GRID_ENTRIES_REPOSITORY_H @@ -31,6 +14,7 @@ #include "../../database.h" #include "../../strings.h" +#include class BaseGridEntriesRepository { public: @@ -43,12 +27,12 @@ public: float z; float heading; int pause; - int8 centerpoint; + int centerpoint; }; static std::string PrimaryKey() { - return std::string("number"); + return std::string("gridid"); } static std::vector Columns() @@ -66,24 +50,29 @@ public: }; } + static std::vector SelectColumns() + { + return { + "gridid", + "zoneid", + "number", + "x", + "y", + "z", + "heading", + "pause", + "centerpoint", + }; + } + static std::string ColumnsRaw() { return std::string(Strings::Implode(", ", Columns())); } - static std::string InsertColumnsRaw() + static std::string SelectColumnsRaw() { - std::vector insert_columns; - - for (auto &column : Columns()) { - if (column == PrimaryKey()) { - continue; - } - - insert_columns.push_back(column); - } - - return std::string(Strings::Implode(", ", insert_columns)); + return std::string(Strings::Implode(", ", SelectColumns())); } static std::string TableName() @@ -95,7 +84,7 @@ public: { return fmt::format( "SELECT {} FROM {}", - ColumnsRaw(), + SelectColumnsRaw(), TableName() ); } @@ -105,34 +94,34 @@ public: return fmt::format( "INSERT INTO {} ({}) ", TableName(), - InsertColumnsRaw() + ColumnsRaw() ); } static GridEntries NewEntity() { - GridEntries entry{}; + GridEntries e{}; - entry.gridid = 0; - entry.zoneid = 0; - entry.number = 0; - entry.x = 0; - entry.y = 0; - entry.z = 0; - entry.heading = 0; - entry.pause = 0; - entry.centerpoint = 0; + e.gridid = 0; + e.zoneid = 0; + e.number = 0; + e.x = 0; + e.y = 0; + e.z = 0; + e.heading = 0; + e.pause = 0; + e.centerpoint = 0; - return entry; + return e; } - static GridEntries GetGridEntriesEntry( + static GridEntries GetGridEntries( const std::vector &grid_entriess, int grid_entries_id ) { for (auto &grid_entries : grid_entriess) { - if (grid_entries.number == grid_entries_id) { + if (grid_entries.gridid == grid_entries_id) { return grid_entries; } } @@ -141,10 +130,11 @@ public: } static GridEntries FindOne( + Database& db, int grid_entries_id ) { - auto results = content_db.QueryDatabase( + auto results = db.QueryDatabase( fmt::format( "{} WHERE id = {} LIMIT 1", BaseSelect(), @@ -154,29 +144,30 @@ public: auto row = results.begin(); if (results.RowCount() == 1) { - GridEntries entry{}; + GridEntries e{}; - entry.gridid = atoi(row[0]); - entry.zoneid = atoi(row[1]); - entry.number = atoi(row[2]); - entry.x = atof(row[3]); - entry.y = atof(row[4]); - entry.z = atof(row[5]); - entry.heading = atof(row[6]); - entry.pause = atoi(row[7]); - entry.centerpoint = atoi(row[8]); + e.gridid = atoi(row[0]); + e.zoneid = atoi(row[1]); + e.number = atoi(row[2]); + e.x = static_cast(atof(row[3])); + e.y = static_cast(atof(row[4])); + e.z = static_cast(atof(row[5])); + e.heading = static_cast(atof(row[6])); + e.pause = atoi(row[7]); + e.centerpoint = atoi(row[8]); - return entry; + return e; } return NewEntity(); } static int DeleteOne( + Database& db, int grid_entries_id ) { - auto results = content_db.QueryDatabase( + auto results = db.QueryDatabase( fmt::format( "DELETE FROM {} WHERE {} = {}", TableName(), @@ -189,27 +180,31 @@ public: } static int UpdateOne( - GridEntries grid_entries_entry + Database& db, + const GridEntries &e ) { - std::vector update_values; + std::vector v; auto columns = Columns(); - update_values.push_back(columns[3] + " = " + std::to_string(grid_entries_entry.x)); - update_values.push_back(columns[4] + " = " + std::to_string(grid_entries_entry.y)); - update_values.push_back(columns[5] + " = " + std::to_string(grid_entries_entry.z)); - update_values.push_back(columns[6] + " = " + std::to_string(grid_entries_entry.heading)); - update_values.push_back(columns[7] + " = " + std::to_string(grid_entries_entry.pause)); - update_values.push_back(columns[8] + " = " + std::to_string(grid_entries_entry.centerpoint)); + v.push_back(columns[0] + " = " + std::to_string(e.gridid)); + v.push_back(columns[1] + " = " + std::to_string(e.zoneid)); + v.push_back(columns[2] + " = " + std::to_string(e.number)); + v.push_back(columns[3] + " = " + std::to_string(e.x)); + v.push_back(columns[4] + " = " + std::to_string(e.y)); + v.push_back(columns[5] + " = " + std::to_string(e.z)); + v.push_back(columns[6] + " = " + std::to_string(e.heading)); + v.push_back(columns[7] + " = " + std::to_string(e.pause)); + v.push_back(columns[8] + " = " + std::to_string(e.centerpoint)); - auto results = content_db.QueryDatabase( + auto results = db.QueryDatabase( fmt::format( "UPDATE {} SET {} WHERE {} = {}", TableName(), - Strings::Implode(", ", update_values), + Strings::Implode(", ", v), PrimaryKey(), - grid_entries_entry.number + e.gridid ) ); @@ -217,58 +212,66 @@ public: } static GridEntries InsertOne( - GridEntries grid_entries_entry + Database& db, + GridEntries e ) { - std::vector insert_values; + std::vector v; - insert_values.push_back(std::to_string(grid_entries_entry.x)); - insert_values.push_back(std::to_string(grid_entries_entry.y)); - insert_values.push_back(std::to_string(grid_entries_entry.z)); - insert_values.push_back(std::to_string(grid_entries_entry.heading)); - insert_values.push_back(std::to_string(grid_entries_entry.pause)); - insert_values.push_back(std::to_string(grid_entries_entry.centerpoint)); + v.push_back(std::to_string(e.gridid)); + v.push_back(std::to_string(e.zoneid)); + v.push_back(std::to_string(e.number)); + v.push_back(std::to_string(e.x)); + v.push_back(std::to_string(e.y)); + v.push_back(std::to_string(e.z)); + v.push_back(std::to_string(e.heading)); + v.push_back(std::to_string(e.pause)); + v.push_back(std::to_string(e.centerpoint)); - auto results = content_db.QueryDatabase( + auto results = db.QueryDatabase( fmt::format( "{} VALUES ({})", BaseInsert(), - Strings::Implode(",", insert_values) + Strings::Implode(",", v) ) ); if (results.Success()) { - grid_entries_entry.id = results.LastInsertedID(); - return grid_entries_entry; + e.gridid = results.LastInsertedID(); + return e; } - grid_entries_entry = NewEntity(); + e = NewEntity(); - return grid_entries_entry; + return e; } static int InsertMany( - std::vector grid_entries_entries + Database& db, + const std::vector &entries ) { std::vector insert_chunks; - for (auto &grid_entries_entry: grid_entries_entries) { - std::vector insert_values; + for (auto &e: entries) { + std::vector v; - insert_values.push_back(std::to_string(grid_entries_entry.x)); - insert_values.push_back(std::to_string(grid_entries_entry.y)); - insert_values.push_back(std::to_string(grid_entries_entry.z)); - insert_values.push_back(std::to_string(grid_entries_entry.heading)); - insert_values.push_back(std::to_string(grid_entries_entry.pause)); - insert_values.push_back(std::to_string(grid_entries_entry.centerpoint)); + v.push_back(std::to_string(e.gridid)); + v.push_back(std::to_string(e.zoneid)); + v.push_back(std::to_string(e.number)); + v.push_back(std::to_string(e.x)); + v.push_back(std::to_string(e.y)); + v.push_back(std::to_string(e.z)); + v.push_back(std::to_string(e.heading)); + v.push_back(std::to_string(e.pause)); + v.push_back(std::to_string(e.centerpoint)); - insert_chunks.push_back("(" + Strings::Implode(",", insert_values) + ")"); + insert_chunks.push_back("(" + Strings::Implode(",", v) + ")"); } - std::vector insert_values; + std::vector v; - auto results = content_db.QueryDatabase( + auto results = db.QueryDatabase( fmt::format( "{} VALUES {}", BaseInsert(), @@ -279,11 +282,11 @@ public: return (results.Success() ? results.RowsAffected() : 0); } - static std::vector All() + static std::vector All(Database& db) { std::vector all_entries; - auto results = content_db.QueryDatabase( + auto results = db.QueryDatabase( fmt::format( "{}", BaseSelect() @@ -293,29 +296,29 @@ public: all_entries.reserve(results.RowCount()); for (auto row = results.begin(); row != results.end(); ++row) { - GridEntries entry{}; + GridEntries e{}; - entry.gridid = atoi(row[0]); - entry.zoneid = atoi(row[1]); - entry.number = atoi(row[2]); - entry.x = atof(row[3]); - entry.y = atof(row[4]); - entry.z = atof(row[5]); - entry.heading = atof(row[6]); - entry.pause = atoi(row[7]); - entry.centerpoint = atoi(row[8]); + e.gridid = atoi(row[0]); + e.zoneid = atoi(row[1]); + e.number = atoi(row[2]); + e.x = static_cast(atof(row[3])); + e.y = static_cast(atof(row[4])); + e.z = static_cast(atof(row[5])); + e.heading = static_cast(atof(row[6])); + e.pause = atoi(row[7]); + e.centerpoint = atoi(row[8]); - all_entries.push_back(entry); + all_entries.push_back(e); } return all_entries; } - static std::vector GetWhere(std::string where_filter) + static std::vector GetWhere(Database& db, const std::string &where_filter) { std::vector all_entries; - auto results = content_db.QueryDatabase( + auto results = db.QueryDatabase( fmt::format( "{} WHERE {}", BaseSelect(), @@ -326,31 +329,30 @@ public: all_entries.reserve(results.RowCount()); for (auto row = results.begin(); row != results.end(); ++row) { - GridEntries entry{}; + GridEntries e{}; - entry.gridid = atoi(row[0]); - entry.zoneid = atoi(row[1]); - entry.number = atoi(row[2]); - entry.x = atof(row[3]); - entry.y = atof(row[4]); - entry.z = atof(row[5]); - entry.heading = atof(row[6]); - entry.pause = atoi(row[7]); - entry.centerpoint = atoi(row[8]); + e.gridid = atoi(row[0]); + e.zoneid = atoi(row[1]); + e.number = atoi(row[2]); + e.x = static_cast(atof(row[3])); + e.y = static_cast(atof(row[4])); + e.z = static_cast(atof(row[5])); + e.heading = static_cast(atof(row[6])); + e.pause = atoi(row[7]); + e.centerpoint = atoi(row[8]); - all_entries.push_back(entry); + all_entries.push_back(e); } return all_entries; } - static int DeleteWhere(std::string where_filter) + static int DeleteWhere(Database& db, const std::string &where_filter) { - auto results = content_db.QueryDatabase( + auto results = db.QueryDatabase( fmt::format( "DELETE FROM {} WHERE {}", TableName(), - PrimaryKey(), where_filter ) ); @@ -358,6 +360,44 @@ public: 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); + } + }; #endif //EQEMU_BASE_GRID_ENTRIES_REPOSITORY_H diff --git a/common/repositories/base/base_grid_repository.h b/common/repositories/base/base_grid_repository.h index 261108b01..7a5862899 100644 --- a/common/repositories/base/base_grid_repository.h +++ b/common/repositories/base/base_grid_repository.h @@ -1,29 +1,12 @@ /** - * EQEmulator: Everquest Server Emulator - * Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server) + * DO NOT MODIFY THIS FILE * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 2 of the License. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY except by those people which sell it, which - * are required to give you total support for your newly bought product; - * without even the implied warranty of MERCHANTABILITY or FITNESS FOR - * A PARTICULAR PURPOSE. See the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - * - */ - -/** * 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 + * 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://eqemu.gitbook.io/server/in-development/developer-area/repositories */ #ifndef EQEMU_BASE_GRID_REPOSITORY_H @@ -31,6 +14,7 @@ #include "../../database.h" #include "../../strings.h" +#include class BaseGridRepository { public: @@ -56,24 +40,24 @@ public: }; } + static std::vector SelectColumns() + { + return { + "id", + "zoneid", + "type", + "type2", + }; + } + static std::string ColumnsRaw() { return std::string(Strings::Implode(", ", Columns())); } - static std::string InsertColumnsRaw() + static std::string SelectColumnsRaw() { - std::vector insert_columns; - - for (auto &column : Columns()) { - if (column == PrimaryKey()) { - continue; - } - - insert_columns.push_back(column); - } - - return std::string(Strings::Implode(", ", insert_columns)); + return std::string(Strings::Implode(", ", SelectColumns())); } static std::string TableName() @@ -85,7 +69,7 @@ public: { return fmt::format( "SELECT {} FROM {}", - ColumnsRaw(), + SelectColumnsRaw(), TableName() ); } @@ -95,23 +79,23 @@ public: return fmt::format( "INSERT INTO {} ({}) ", TableName(), - InsertColumnsRaw() + ColumnsRaw() ); } static Grid NewEntity() { - Grid entry{}; + Grid e{}; - entry.id = 0; - entry.zoneid = 0; - entry.type = 0; - entry.type2 = 0; + e.id = 0; + e.zoneid = 0; + e.type = 0; + e.type2 = 0; - return entry; + return e; } - static Grid GetGridEntry( + static Grid GetGrid( const std::vector &grids, int grid_id ) @@ -126,10 +110,11 @@ public: } static Grid FindOne( + Database& db, int grid_id ) { - auto results = content_db.QueryDatabase( + auto results = db.QueryDatabase( fmt::format( "{} WHERE id = {} LIMIT 1", BaseSelect(), @@ -139,24 +124,25 @@ public: auto row = results.begin(); if (results.RowCount() == 1) { - Grid entry{}; + Grid e{}; - entry.id = atoi(row[0]); - entry.zoneid = atoi(row[1]); - entry.type = atoi(row[2]); - entry.type2 = atoi(row[3]); + e.id = atoi(row[0]); + e.zoneid = atoi(row[1]); + e.type = atoi(row[2]); + e.type2 = atoi(row[3]); - return entry; + return e; } return NewEntity(); } static int DeleteOne( + Database& db, int grid_id ) { - auto results = content_db.QueryDatabase( + auto results = db.QueryDatabase( fmt::format( "DELETE FROM {} WHERE {} = {}", TableName(), @@ -169,25 +155,26 @@ public: } static int UpdateOne( - Grid grid_entry + Database& db, + const Grid &e ) { - std::vector update_values; + std::vector v; auto columns = Columns(); - update_values.push_back(columns[0] + " = " + std::to_string(grid_entry.id)); - update_values.push_back(columns[1] + " = " + std::to_string(grid_entry.zoneid)); - update_values.push_back(columns[2] + " = " + std::to_string(grid_entry.type)); - update_values.push_back(columns[3] + " = " + std::to_string(grid_entry.type2)); + v.push_back(columns[0] + " = " + std::to_string(e.id)); + v.push_back(columns[1] + " = " + std::to_string(e.zoneid)); + v.push_back(columns[2] + " = " + std::to_string(e.type)); + v.push_back(columns[3] + " = " + std::to_string(e.type2)); - auto results = content_db.QueryDatabase( + auto results = db.QueryDatabase( fmt::format( "UPDATE {} SET {} WHERE {} = {}", TableName(), - Strings::Implode(", ", update_values), + Strings::Implode(", ", v), PrimaryKey(), - grid_entry.id + e.id ) ); @@ -195,54 +182,56 @@ public: } static Grid InsertOne( - Grid grid_entry + Database& db, + Grid e ) { - std::vector insert_values; + std::vector v; - insert_values.push_back(std::to_string(grid_entry.id)); - insert_values.push_back(std::to_string(grid_entry.zoneid)); - insert_values.push_back(std::to_string(grid_entry.type)); - insert_values.push_back(std::to_string(grid_entry.type2)); + v.push_back(std::to_string(e.id)); + v.push_back(std::to_string(e.zoneid)); + v.push_back(std::to_string(e.type)); + v.push_back(std::to_string(e.type2)); - auto results = content_db.QueryDatabase( + auto results = db.QueryDatabase( fmt::format( "{} VALUES ({})", BaseInsert(), - Strings::Implode(",", insert_values) + Strings::Implode(",", v) ) ); if (results.Success()) { - grid_entry.id = results.LastInsertedID(); - return grid_entry; + e.id = results.LastInsertedID(); + return e; } - grid_entry = NewEntity(); + e = NewEntity(); - return grid_entry; + return e; } static int InsertMany( - std::vector grid_entries + Database& db, + const std::vector &entries ) { std::vector insert_chunks; - for (auto &grid_entry: grid_entries) { - std::vector insert_values; + for (auto &e: entries) { + std::vector v; - insert_values.push_back(std::to_string(grid_entry.id)); - insert_values.push_back(std::to_string(grid_entry.zoneid)); - insert_values.push_back(std::to_string(grid_entry.type)); - insert_values.push_back(std::to_string(grid_entry.type2)); + v.push_back(std::to_string(e.id)); + v.push_back(std::to_string(e.zoneid)); + v.push_back(std::to_string(e.type)); + v.push_back(std::to_string(e.type2)); - insert_chunks.push_back("(" + Strings::Implode(",", insert_values) + ")"); + insert_chunks.push_back("(" + Strings::Implode(",", v) + ")"); } - std::vector insert_values; + std::vector v; - auto results = content_db.QueryDatabase( + auto results = db.QueryDatabase( fmt::format( "{} VALUES {}", BaseInsert(), @@ -253,11 +242,11 @@ public: return (results.Success() ? results.RowsAffected() : 0); } - static std::vector All() + static std::vector All(Database& db) { std::vector all_entries; - auto results = content_db.QueryDatabase( + auto results = db.QueryDatabase( fmt::format( "{}", BaseSelect() @@ -267,24 +256,24 @@ public: all_entries.reserve(results.RowCount()); for (auto row = results.begin(); row != results.end(); ++row) { - Grid entry{}; + Grid e{}; - entry.id = atoi(row[0]); - entry.zoneid = atoi(row[1]); - entry.type = atoi(row[2]); - entry.type2 = atoi(row[3]); + e.id = atoi(row[0]); + e.zoneid = atoi(row[1]); + e.type = atoi(row[2]); + e.type2 = atoi(row[3]); - all_entries.push_back(entry); + all_entries.push_back(e); } return all_entries; } - static std::vector GetWhere(std::string where_filter) + static std::vector GetWhere(Database& db, const std::string &where_filter) { std::vector all_entries; - auto results = content_db.QueryDatabase( + auto results = db.QueryDatabase( fmt::format( "{} WHERE {}", BaseSelect(), @@ -295,22 +284,22 @@ public: all_entries.reserve(results.RowCount()); for (auto row = results.begin(); row != results.end(); ++row) { - Grid entry{}; + Grid e{}; - entry.id = atoi(row[0]); - entry.zoneid = atoi(row[1]); - entry.type = atoi(row[2]); - entry.type2 = atoi(row[3]); + e.id = atoi(row[0]); + e.zoneid = atoi(row[1]); + e.type = atoi(row[2]); + e.type2 = atoi(row[3]); - all_entries.push_back(entry); + all_entries.push_back(e); } return all_entries; } - static int DeleteWhere(std::string where_filter) + static int DeleteWhere(Database& db, const std::string &where_filter) { - auto results = content_db.QueryDatabase( + auto results = db.QueryDatabase( fmt::format( "DELETE FROM {} WHERE {}", TableName(), @@ -321,6 +310,44 @@ public: 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); + } + }; #endif //EQEMU_BASE_GRID_REPOSITORY_H diff --git a/common/repositories/base/base_ground_spawns_repository.h b/common/repositories/base/base_ground_spawns_repository.h index f14f50d4c..d965b5328 100644 --- a/common/repositories/base/base_ground_spawns_repository.h +++ b/common/repositories/base/base_ground_spawns_repository.h @@ -127,31 +127,31 @@ public: static GroundSpawns NewEntity() { - GroundSpawns entry{}; + GroundSpawns e{}; - entry.id = 0; - entry.zoneid = 0; - entry.version = 0; - entry.max_x = 2000; - entry.max_y = 2000; - entry.max_z = 10000; - entry.min_x = -2000; - entry.min_y = -2000; - entry.heading = 0; - entry.name = ""; - entry.item = 0; - entry.max_allowed = 1; - entry.comment = ""; - entry.respawn_timer = 300; - entry.min_expansion = -1; - entry.max_expansion = -1; - entry.content_flags = ""; - entry.content_flags_disabled = ""; + e.id = 0; + e.zoneid = 0; + e.version = 0; + e.max_x = 2000; + e.max_y = 2000; + e.max_z = 10000; + e.min_x = -2000; + e.min_y = -2000; + e.heading = 0; + e.name = ""; + e.item = 0; + e.max_allowed = 1; + e.comment = ""; + e.respawn_timer = 300; + e.min_expansion = -1; + e.max_expansion = -1; + e.content_flags = ""; + e.content_flags_disabled = ""; - return entry; + return e; } - static GroundSpawns GetGroundSpawnsEntry( + static GroundSpawns GetGroundSpawns( const std::vector &ground_spawnss, int ground_spawns_id ) @@ -180,28 +180,28 @@ public: auto row = results.begin(); if (results.RowCount() == 1) { - GroundSpawns entry{}; + GroundSpawns e{}; - entry.id = atoi(row[0]); - entry.zoneid = atoi(row[1]); - entry.version = atoi(row[2]); - entry.max_x = static_cast(atof(row[3])); - entry.max_y = static_cast(atof(row[4])); - entry.max_z = static_cast(atof(row[5])); - entry.min_x = static_cast(atof(row[6])); - entry.min_y = static_cast(atof(row[7])); - entry.heading = static_cast(atof(row[8])); - entry.name = row[9] ? row[9] : ""; - entry.item = atoi(row[10]); - entry.max_allowed = atoi(row[11]); - entry.comment = row[12] ? row[12] : ""; - entry.respawn_timer = atoi(row[13]); - entry.min_expansion = atoi(row[14]); - entry.max_expansion = atoi(row[15]); - entry.content_flags = row[16] ? row[16] : ""; - entry.content_flags_disabled = row[17] ? row[17] : ""; + e.id = atoi(row[0]); + e.zoneid = atoi(row[1]); + e.version = atoi(row[2]); + e.max_x = static_cast(atof(row[3])); + e.max_y = static_cast(atof(row[4])); + e.max_z = static_cast(atof(row[5])); + e.min_x = static_cast(atof(row[6])); + e.min_y = static_cast(atof(row[7])); + e.heading = static_cast(atof(row[8])); + e.name = row[9] ? row[9] : ""; + e.item = atoi(row[10]); + e.max_allowed = atoi(row[11]); + e.comment = row[12] ? row[12] : ""; + e.respawn_timer = atoi(row[13]); + e.min_expansion = atoi(row[14]); + e.max_expansion = atoi(row[15]); + e.content_flags = row[16] ? row[16] : ""; + e.content_flags_disabled = row[17] ? row[17] : ""; - return entry; + return e; } return NewEntity(); @@ -226,38 +226,38 @@ public: static int UpdateOne( Database& db, - GroundSpawns ground_spawns_entry + const GroundSpawns &e ) { - std::vector update_values; + std::vector v; auto columns = Columns(); - update_values.push_back(columns[1] + " = " + std::to_string(ground_spawns_entry.zoneid)); - update_values.push_back(columns[2] + " = " + std::to_string(ground_spawns_entry.version)); - update_values.push_back(columns[3] + " = " + std::to_string(ground_spawns_entry.max_x)); - update_values.push_back(columns[4] + " = " + std::to_string(ground_spawns_entry.max_y)); - update_values.push_back(columns[5] + " = " + std::to_string(ground_spawns_entry.max_z)); - update_values.push_back(columns[6] + " = " + std::to_string(ground_spawns_entry.min_x)); - update_values.push_back(columns[7] + " = " + std::to_string(ground_spawns_entry.min_y)); - update_values.push_back(columns[8] + " = " + std::to_string(ground_spawns_entry.heading)); - update_values.push_back(columns[9] + " = '" + Strings::Escape(ground_spawns_entry.name) + "'"); - update_values.push_back(columns[10] + " = " + std::to_string(ground_spawns_entry.item)); - update_values.push_back(columns[11] + " = " + std::to_string(ground_spawns_entry.max_allowed)); - update_values.push_back(columns[12] + " = '" + Strings::Escape(ground_spawns_entry.comment) + "'"); - update_values.push_back(columns[13] + " = " + std::to_string(ground_spawns_entry.respawn_timer)); - update_values.push_back(columns[14] + " = " + std::to_string(ground_spawns_entry.min_expansion)); - update_values.push_back(columns[15] + " = " + std::to_string(ground_spawns_entry.max_expansion)); - update_values.push_back(columns[16] + " = '" + Strings::Escape(ground_spawns_entry.content_flags) + "'"); - update_values.push_back(columns[17] + " = '" + Strings::Escape(ground_spawns_entry.content_flags_disabled) + "'"); + v.push_back(columns[1] + " = " + std::to_string(e.zoneid)); + v.push_back(columns[2] + " = " + std::to_string(e.version)); + v.push_back(columns[3] + " = " + std::to_string(e.max_x)); + v.push_back(columns[4] + " = " + std::to_string(e.max_y)); + v.push_back(columns[5] + " = " + std::to_string(e.max_z)); + v.push_back(columns[6] + " = " + std::to_string(e.min_x)); + v.push_back(columns[7] + " = " + std::to_string(e.min_y)); + v.push_back(columns[8] + " = " + std::to_string(e.heading)); + v.push_back(columns[9] + " = '" + Strings::Escape(e.name) + "'"); + v.push_back(columns[10] + " = " + std::to_string(e.item)); + v.push_back(columns[11] + " = " + std::to_string(e.max_allowed)); + v.push_back(columns[12] + " = '" + Strings::Escape(e.comment) + "'"); + v.push_back(columns[13] + " = " + std::to_string(e.respawn_timer)); + v.push_back(columns[14] + " = " + std::to_string(e.min_expansion)); + v.push_back(columns[15] + " = " + std::to_string(e.max_expansion)); + v.push_back(columns[16] + " = '" + Strings::Escape(e.content_flags) + "'"); + v.push_back(columns[17] + " = '" + Strings::Escape(e.content_flags_disabled) + "'"); auto results = db.QueryDatabase( fmt::format( "UPDATE {} SET {} WHERE {} = {}", TableName(), - Strings::Implode(", ", update_values), + Strings::Implode(", ", v), PrimaryKey(), - ground_spawns_entry.id + e.id ) ); @@ -266,81 +266,81 @@ public: static GroundSpawns InsertOne( Database& db, - GroundSpawns ground_spawns_entry + GroundSpawns e ) { - std::vector insert_values; + std::vector v; - insert_values.push_back(std::to_string(ground_spawns_entry.id)); - insert_values.push_back(std::to_string(ground_spawns_entry.zoneid)); - insert_values.push_back(std::to_string(ground_spawns_entry.version)); - insert_values.push_back(std::to_string(ground_spawns_entry.max_x)); - insert_values.push_back(std::to_string(ground_spawns_entry.max_y)); - insert_values.push_back(std::to_string(ground_spawns_entry.max_z)); - insert_values.push_back(std::to_string(ground_spawns_entry.min_x)); - insert_values.push_back(std::to_string(ground_spawns_entry.min_y)); - insert_values.push_back(std::to_string(ground_spawns_entry.heading)); - insert_values.push_back("'" + Strings::Escape(ground_spawns_entry.name) + "'"); - insert_values.push_back(std::to_string(ground_spawns_entry.item)); - insert_values.push_back(std::to_string(ground_spawns_entry.max_allowed)); - insert_values.push_back("'" + Strings::Escape(ground_spawns_entry.comment) + "'"); - insert_values.push_back(std::to_string(ground_spawns_entry.respawn_timer)); - insert_values.push_back(std::to_string(ground_spawns_entry.min_expansion)); - insert_values.push_back(std::to_string(ground_spawns_entry.max_expansion)); - insert_values.push_back("'" + Strings::Escape(ground_spawns_entry.content_flags) + "'"); - insert_values.push_back("'" + Strings::Escape(ground_spawns_entry.content_flags_disabled) + "'"); + v.push_back(std::to_string(e.id)); + v.push_back(std::to_string(e.zoneid)); + v.push_back(std::to_string(e.version)); + v.push_back(std::to_string(e.max_x)); + v.push_back(std::to_string(e.max_y)); + v.push_back(std::to_string(e.max_z)); + v.push_back(std::to_string(e.min_x)); + v.push_back(std::to_string(e.min_y)); + v.push_back(std::to_string(e.heading)); + v.push_back("'" + Strings::Escape(e.name) + "'"); + v.push_back(std::to_string(e.item)); + v.push_back(std::to_string(e.max_allowed)); + v.push_back("'" + Strings::Escape(e.comment) + "'"); + v.push_back(std::to_string(e.respawn_timer)); + v.push_back(std::to_string(e.min_expansion)); + v.push_back(std::to_string(e.max_expansion)); + v.push_back("'" + Strings::Escape(e.content_flags) + "'"); + v.push_back("'" + Strings::Escape(e.content_flags_disabled) + "'"); auto results = db.QueryDatabase( fmt::format( "{} VALUES ({})", BaseInsert(), - Strings::Implode(",", insert_values) + Strings::Implode(",", v) ) ); if (results.Success()) { - ground_spawns_entry.id = results.LastInsertedID(); - return ground_spawns_entry; + e.id = results.LastInsertedID(); + return e; } - ground_spawns_entry = NewEntity(); + e = NewEntity(); - return ground_spawns_entry; + return e; } static int InsertMany( Database& db, - std::vector ground_spawns_entries + const std::vector &entries ) { std::vector insert_chunks; - for (auto &ground_spawns_entry: ground_spawns_entries) { - std::vector insert_values; + for (auto &e: entries) { + std::vector v; - insert_values.push_back(std::to_string(ground_spawns_entry.id)); - insert_values.push_back(std::to_string(ground_spawns_entry.zoneid)); - insert_values.push_back(std::to_string(ground_spawns_entry.version)); - insert_values.push_back(std::to_string(ground_spawns_entry.max_x)); - insert_values.push_back(std::to_string(ground_spawns_entry.max_y)); - insert_values.push_back(std::to_string(ground_spawns_entry.max_z)); - insert_values.push_back(std::to_string(ground_spawns_entry.min_x)); - insert_values.push_back(std::to_string(ground_spawns_entry.min_y)); - insert_values.push_back(std::to_string(ground_spawns_entry.heading)); - insert_values.push_back("'" + Strings::Escape(ground_spawns_entry.name) + "'"); - insert_values.push_back(std::to_string(ground_spawns_entry.item)); - insert_values.push_back(std::to_string(ground_spawns_entry.max_allowed)); - insert_values.push_back("'" + Strings::Escape(ground_spawns_entry.comment) + "'"); - insert_values.push_back(std::to_string(ground_spawns_entry.respawn_timer)); - insert_values.push_back(std::to_string(ground_spawns_entry.min_expansion)); - insert_values.push_back(std::to_string(ground_spawns_entry.max_expansion)); - insert_values.push_back("'" + Strings::Escape(ground_spawns_entry.content_flags) + "'"); - insert_values.push_back("'" + Strings::Escape(ground_spawns_entry.content_flags_disabled) + "'"); + v.push_back(std::to_string(e.id)); + v.push_back(std::to_string(e.zoneid)); + v.push_back(std::to_string(e.version)); + v.push_back(std::to_string(e.max_x)); + v.push_back(std::to_string(e.max_y)); + v.push_back(std::to_string(e.max_z)); + v.push_back(std::to_string(e.min_x)); + v.push_back(std::to_string(e.min_y)); + v.push_back(std::to_string(e.heading)); + v.push_back("'" + Strings::Escape(e.name) + "'"); + v.push_back(std::to_string(e.item)); + v.push_back(std::to_string(e.max_allowed)); + v.push_back("'" + Strings::Escape(e.comment) + "'"); + v.push_back(std::to_string(e.respawn_timer)); + v.push_back(std::to_string(e.min_expansion)); + v.push_back(std::to_string(e.max_expansion)); + v.push_back("'" + Strings::Escape(e.content_flags) + "'"); + v.push_back("'" + Strings::Escape(e.content_flags_disabled) + "'"); - insert_chunks.push_back("(" + Strings::Implode(",", insert_values) + ")"); + insert_chunks.push_back("(" + Strings::Implode(",", v) + ")"); } - std::vector insert_values; + std::vector v; auto results = db.QueryDatabase( fmt::format( @@ -367,34 +367,34 @@ public: all_entries.reserve(results.RowCount()); for (auto row = results.begin(); row != results.end(); ++row) { - GroundSpawns entry{}; + GroundSpawns e{}; - entry.id = atoi(row[0]); - entry.zoneid = atoi(row[1]); - entry.version = atoi(row[2]); - entry.max_x = static_cast(atof(row[3])); - entry.max_y = static_cast(atof(row[4])); - entry.max_z = static_cast(atof(row[5])); - entry.min_x = static_cast(atof(row[6])); - entry.min_y = static_cast(atof(row[7])); - entry.heading = static_cast(atof(row[8])); - entry.name = row[9] ? row[9] : ""; - entry.item = atoi(row[10]); - entry.max_allowed = atoi(row[11]); - entry.comment = row[12] ? row[12] : ""; - entry.respawn_timer = atoi(row[13]); - entry.min_expansion = atoi(row[14]); - entry.max_expansion = atoi(row[15]); - entry.content_flags = row[16] ? row[16] : ""; - entry.content_flags_disabled = row[17] ? row[17] : ""; + e.id = atoi(row[0]); + e.zoneid = atoi(row[1]); + e.version = atoi(row[2]); + e.max_x = static_cast(atof(row[3])); + e.max_y = static_cast(atof(row[4])); + e.max_z = static_cast(atof(row[5])); + e.min_x = static_cast(atof(row[6])); + e.min_y = static_cast(atof(row[7])); + e.heading = static_cast(atof(row[8])); + e.name = row[9] ? row[9] : ""; + e.item = atoi(row[10]); + e.max_allowed = atoi(row[11]); + e.comment = row[12] ? row[12] : ""; + e.respawn_timer = atoi(row[13]); + e.min_expansion = atoi(row[14]); + e.max_expansion = atoi(row[15]); + e.content_flags = row[16] ? row[16] : ""; + e.content_flags_disabled = row[17] ? row[17] : ""; - all_entries.push_back(entry); + all_entries.push_back(e); } return all_entries; } - static std::vector GetWhere(Database& db, std::string where_filter) + static std::vector GetWhere(Database& db, const std::string &where_filter) { std::vector all_entries; @@ -409,34 +409,34 @@ public: all_entries.reserve(results.RowCount()); for (auto row = results.begin(); row != results.end(); ++row) { - GroundSpawns entry{}; + GroundSpawns e{}; - entry.id = atoi(row[0]); - entry.zoneid = atoi(row[1]); - entry.version = atoi(row[2]); - entry.max_x = static_cast(atof(row[3])); - entry.max_y = static_cast(atof(row[4])); - entry.max_z = static_cast(atof(row[5])); - entry.min_x = static_cast(atof(row[6])); - entry.min_y = static_cast(atof(row[7])); - entry.heading = static_cast(atof(row[8])); - entry.name = row[9] ? row[9] : ""; - entry.item = atoi(row[10]); - entry.max_allowed = atoi(row[11]); - entry.comment = row[12] ? row[12] : ""; - entry.respawn_timer = atoi(row[13]); - entry.min_expansion = atoi(row[14]); - entry.max_expansion = atoi(row[15]); - entry.content_flags = row[16] ? row[16] : ""; - entry.content_flags_disabled = row[17] ? row[17] : ""; + e.id = atoi(row[0]); + e.zoneid = atoi(row[1]); + e.version = atoi(row[2]); + e.max_x = static_cast(atof(row[3])); + e.max_y = static_cast(atof(row[4])); + e.max_z = static_cast(atof(row[5])); + e.min_x = static_cast(atof(row[6])); + e.min_y = static_cast(atof(row[7])); + e.heading = static_cast(atof(row[8])); + e.name = row[9] ? row[9] : ""; + e.item = atoi(row[10]); + e.max_allowed = atoi(row[11]); + e.comment = row[12] ? row[12] : ""; + e.respawn_timer = atoi(row[13]); + e.min_expansion = atoi(row[14]); + e.max_expansion = atoi(row[15]); + e.content_flags = row[16] ? row[16] : ""; + e.content_flags_disabled = row[17] ? row[17] : ""; - all_entries.push_back(entry); + all_entries.push_back(e); } return all_entries; } - static int DeleteWhere(Database& db, std::string where_filter) + static int DeleteWhere(Database& db, const std::string &where_filter) { auto results = db.QueryDatabase( fmt::format( @@ -461,6 +461,32 @@ public: 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); + } + }; #endif //EQEMU_BASE_GROUND_SPAWNS_REPOSITORY_H diff --git a/common/repositories/base/base_group_id_repository.h b/common/repositories/base/base_group_id_repository.h index 1ef14a1e5..7c644461c 100644 --- a/common/repositories/base/base_group_id_repository.h +++ b/common/repositories/base/base_group_id_repository.h @@ -85,17 +85,17 @@ public: static GroupId NewEntity() { - GroupId entry{}; + GroupId e{}; - entry.groupid = 0; - entry.charid = 0; - entry.name = ""; - entry.ismerc = 0; + e.groupid = 0; + e.charid = 0; + e.name = ""; + e.ismerc = 0; - return entry; + return e; } - static GroupId GetGroupIdEntry( + static GroupId GetGroupId( const std::vector &group_ids, int group_id_id ) @@ -124,14 +124,14 @@ public: auto row = results.begin(); if (results.RowCount() == 1) { - GroupId entry{}; + GroupId e{}; - entry.groupid = atoi(row[0]); - entry.charid = atoi(row[1]); - entry.name = row[2] ? row[2] : ""; - entry.ismerc = atoi(row[3]); + e.groupid = atoi(row[0]); + e.charid = atoi(row[1]); + e.name = row[2] ? row[2] : ""; + e.ismerc = atoi(row[3]); - return entry; + return e; } return NewEntity(); @@ -156,25 +156,25 @@ public: static int UpdateOne( Database& db, - GroupId group_id_entry + const GroupId &e ) { - std::vector update_values; + std::vector v; auto columns = Columns(); - update_values.push_back(columns[0] + " = " + std::to_string(group_id_entry.groupid)); - update_values.push_back(columns[1] + " = " + std::to_string(group_id_entry.charid)); - update_values.push_back(columns[2] + " = '" + Strings::Escape(group_id_entry.name) + "'"); - update_values.push_back(columns[3] + " = " + std::to_string(group_id_entry.ismerc)); + v.push_back(columns[0] + " = " + std::to_string(e.groupid)); + v.push_back(columns[1] + " = " + std::to_string(e.charid)); + v.push_back(columns[2] + " = '" + Strings::Escape(e.name) + "'"); + v.push_back(columns[3] + " = " + std::to_string(e.ismerc)); auto results = db.QueryDatabase( fmt::format( "UPDATE {} SET {} WHERE {} = {}", TableName(), - Strings::Implode(", ", update_values), + Strings::Implode(", ", v), PrimaryKey(), - group_id_entry.groupid + e.groupid ) ); @@ -183,53 +183,53 @@ public: static GroupId InsertOne( Database& db, - GroupId group_id_entry + GroupId e ) { - std::vector insert_values; + std::vector v; - insert_values.push_back(std::to_string(group_id_entry.groupid)); - insert_values.push_back(std::to_string(group_id_entry.charid)); - insert_values.push_back("'" + Strings::Escape(group_id_entry.name) + "'"); - insert_values.push_back(std::to_string(group_id_entry.ismerc)); + v.push_back(std::to_string(e.groupid)); + v.push_back(std::to_string(e.charid)); + v.push_back("'" + Strings::Escape(e.name) + "'"); + v.push_back(std::to_string(e.ismerc)); auto results = db.QueryDatabase( fmt::format( "{} VALUES ({})", BaseInsert(), - Strings::Implode(",", insert_values) + Strings::Implode(",", v) ) ); if (results.Success()) { - group_id_entry.groupid = results.LastInsertedID(); - return group_id_entry; + e.groupid = results.LastInsertedID(); + return e; } - group_id_entry = NewEntity(); + e = NewEntity(); - return group_id_entry; + return e; } static int InsertMany( Database& db, - std::vector group_id_entries + const std::vector &entries ) { std::vector insert_chunks; - for (auto &group_id_entry: group_id_entries) { - std::vector insert_values; + for (auto &e: entries) { + std::vector v; - insert_values.push_back(std::to_string(group_id_entry.groupid)); - insert_values.push_back(std::to_string(group_id_entry.charid)); - insert_values.push_back("'" + Strings::Escape(group_id_entry.name) + "'"); - insert_values.push_back(std::to_string(group_id_entry.ismerc)); + v.push_back(std::to_string(e.groupid)); + v.push_back(std::to_string(e.charid)); + v.push_back("'" + Strings::Escape(e.name) + "'"); + v.push_back(std::to_string(e.ismerc)); - insert_chunks.push_back("(" + Strings::Implode(",", insert_values) + ")"); + insert_chunks.push_back("(" + Strings::Implode(",", v) + ")"); } - std::vector insert_values; + std::vector v; auto results = db.QueryDatabase( fmt::format( @@ -256,20 +256,20 @@ public: all_entries.reserve(results.RowCount()); for (auto row = results.begin(); row != results.end(); ++row) { - GroupId entry{}; + GroupId e{}; - entry.groupid = atoi(row[0]); - entry.charid = atoi(row[1]); - entry.name = row[2] ? row[2] : ""; - entry.ismerc = atoi(row[3]); + e.groupid = atoi(row[0]); + e.charid = atoi(row[1]); + e.name = row[2] ? row[2] : ""; + e.ismerc = atoi(row[3]); - all_entries.push_back(entry); + all_entries.push_back(e); } return all_entries; } - static std::vector GetWhere(Database& db, std::string where_filter) + static std::vector GetWhere(Database& db, const std::string &where_filter) { std::vector all_entries; @@ -284,20 +284,20 @@ public: all_entries.reserve(results.RowCount()); for (auto row = results.begin(); row != results.end(); ++row) { - GroupId entry{}; + GroupId e{}; - entry.groupid = atoi(row[0]); - entry.charid = atoi(row[1]); - entry.name = row[2] ? row[2] : ""; - entry.ismerc = atoi(row[3]); + e.groupid = atoi(row[0]); + e.charid = atoi(row[1]); + e.name = row[2] ? row[2] : ""; + e.ismerc = atoi(row[3]); - all_entries.push_back(entry); + all_entries.push_back(e); } return all_entries; } - static int DeleteWhere(Database& db, std::string where_filter) + static int DeleteWhere(Database& db, const std::string &where_filter) { auto results = db.QueryDatabase( fmt::format( @@ -322,6 +322,32 @@ public: 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); + } + }; #endif //EQEMU_BASE_GROUP_ID_REPOSITORY_H diff --git a/common/repositories/base/base_group_leaders_repository.h b/common/repositories/base/base_group_leaders_repository.h index 02b226445..04521c06a 100644 --- a/common/repositories/base/base_group_leaders_repository.h +++ b/common/repositories/base/base_group_leaders_repository.h @@ -100,22 +100,22 @@ public: static GroupLeaders NewEntity() { - GroupLeaders entry{}; + GroupLeaders e{}; - entry.gid = 0; - entry.leadername = ""; - entry.marknpc = ""; - entry.leadershipaa = 0; - entry.maintank = ""; - entry.assist = ""; - entry.puller = ""; - entry.mentoree = ""; - entry.mentor_percent = 0; + e.gid = 0; + e.leadername = ""; + e.marknpc = ""; + e.leadershipaa = 0; + e.maintank = ""; + e.assist = ""; + e.puller = ""; + e.mentoree = ""; + e.mentor_percent = 0; - return entry; + return e; } - static GroupLeaders GetGroupLeadersEntry( + static GroupLeaders GetGroupLeaders( const std::vector &group_leaderss, int group_leaders_id ) @@ -144,19 +144,19 @@ public: auto row = results.begin(); if (results.RowCount() == 1) { - GroupLeaders entry{}; + GroupLeaders e{}; - entry.gid = atoi(row[0]); - entry.leadername = row[1] ? row[1] : ""; - entry.marknpc = row[2] ? row[2] : ""; - entry.leadershipaa = row[3] ? row[3] : ""; - entry.maintank = row[4] ? row[4] : ""; - entry.assist = row[5] ? row[5] : ""; - entry.puller = row[6] ? row[6] : ""; - entry.mentoree = row[7] ? row[7] : ""; - entry.mentor_percent = atoi(row[8]); + e.gid = atoi(row[0]); + e.leadername = row[1] ? row[1] : ""; + e.marknpc = row[2] ? row[2] : ""; + e.leadershipaa = row[3] ? row[3] : ""; + e.maintank = row[4] ? row[4] : ""; + e.assist = row[5] ? row[5] : ""; + e.puller = row[6] ? row[6] : ""; + e.mentoree = row[7] ? row[7] : ""; + e.mentor_percent = atoi(row[8]); - return entry; + return e; } return NewEntity(); @@ -181,30 +181,30 @@ public: static int UpdateOne( Database& db, - GroupLeaders group_leaders_entry + const GroupLeaders &e ) { - std::vector update_values; + std::vector v; auto columns = Columns(); - update_values.push_back(columns[0] + " = " + std::to_string(group_leaders_entry.gid)); - update_values.push_back(columns[1] + " = '" + Strings::Escape(group_leaders_entry.leadername) + "'"); - update_values.push_back(columns[2] + " = '" + Strings::Escape(group_leaders_entry.marknpc) + "'"); - update_values.push_back(columns[3] + " = '" + Strings::Escape(group_leaders_entry.leadershipaa) + "'"); - update_values.push_back(columns[4] + " = '" + Strings::Escape(group_leaders_entry.maintank) + "'"); - update_values.push_back(columns[5] + " = '" + Strings::Escape(group_leaders_entry.assist) + "'"); - update_values.push_back(columns[6] + " = '" + Strings::Escape(group_leaders_entry.puller) + "'"); - update_values.push_back(columns[7] + " = '" + Strings::Escape(group_leaders_entry.mentoree) + "'"); - update_values.push_back(columns[8] + " = " + std::to_string(group_leaders_entry.mentor_percent)); + v.push_back(columns[0] + " = " + std::to_string(e.gid)); + v.push_back(columns[1] + " = '" + Strings::Escape(e.leadername) + "'"); + v.push_back(columns[2] + " = '" + Strings::Escape(e.marknpc) + "'"); + v.push_back(columns[3] + " = '" + Strings::Escape(e.leadershipaa) + "'"); + v.push_back(columns[4] + " = '" + Strings::Escape(e.maintank) + "'"); + v.push_back(columns[5] + " = '" + Strings::Escape(e.assist) + "'"); + v.push_back(columns[6] + " = '" + Strings::Escape(e.puller) + "'"); + v.push_back(columns[7] + " = '" + Strings::Escape(e.mentoree) + "'"); + v.push_back(columns[8] + " = " + std::to_string(e.mentor_percent)); auto results = db.QueryDatabase( fmt::format( "UPDATE {} SET {} WHERE {} = {}", TableName(), - Strings::Implode(", ", update_values), + Strings::Implode(", ", v), PrimaryKey(), - group_leaders_entry.gid + e.gid ) ); @@ -213,63 +213,63 @@ public: static GroupLeaders InsertOne( Database& db, - GroupLeaders group_leaders_entry + GroupLeaders e ) { - std::vector insert_values; + std::vector v; - insert_values.push_back(std::to_string(group_leaders_entry.gid)); - insert_values.push_back("'" + Strings::Escape(group_leaders_entry.leadername) + "'"); - insert_values.push_back("'" + Strings::Escape(group_leaders_entry.marknpc) + "'"); - insert_values.push_back("'" + Strings::Escape(group_leaders_entry.leadershipaa) + "'"); - insert_values.push_back("'" + Strings::Escape(group_leaders_entry.maintank) + "'"); - insert_values.push_back("'" + Strings::Escape(group_leaders_entry.assist) + "'"); - insert_values.push_back("'" + Strings::Escape(group_leaders_entry.puller) + "'"); - insert_values.push_back("'" + Strings::Escape(group_leaders_entry.mentoree) + "'"); - insert_values.push_back(std::to_string(group_leaders_entry.mentor_percent)); + v.push_back(std::to_string(e.gid)); + v.push_back("'" + Strings::Escape(e.leadername) + "'"); + v.push_back("'" + Strings::Escape(e.marknpc) + "'"); + v.push_back("'" + Strings::Escape(e.leadershipaa) + "'"); + v.push_back("'" + Strings::Escape(e.maintank) + "'"); + v.push_back("'" + Strings::Escape(e.assist) + "'"); + v.push_back("'" + Strings::Escape(e.puller) + "'"); + v.push_back("'" + Strings::Escape(e.mentoree) + "'"); + v.push_back(std::to_string(e.mentor_percent)); auto results = db.QueryDatabase( fmt::format( "{} VALUES ({})", BaseInsert(), - Strings::Implode(",", insert_values) + Strings::Implode(",", v) ) ); if (results.Success()) { - group_leaders_entry.gid = results.LastInsertedID(); - return group_leaders_entry; + e.gid = results.LastInsertedID(); + return e; } - group_leaders_entry = NewEntity(); + e = NewEntity(); - return group_leaders_entry; + return e; } static int InsertMany( Database& db, - std::vector group_leaders_entries + const std::vector &entries ) { std::vector insert_chunks; - for (auto &group_leaders_entry: group_leaders_entries) { - std::vector insert_values; + for (auto &e: entries) { + std::vector v; - insert_values.push_back(std::to_string(group_leaders_entry.gid)); - insert_values.push_back("'" + Strings::Escape(group_leaders_entry.leadername) + "'"); - insert_values.push_back("'" + Strings::Escape(group_leaders_entry.marknpc) + "'"); - insert_values.push_back("'" + Strings::Escape(group_leaders_entry.leadershipaa) + "'"); - insert_values.push_back("'" + Strings::Escape(group_leaders_entry.maintank) + "'"); - insert_values.push_back("'" + Strings::Escape(group_leaders_entry.assist) + "'"); - insert_values.push_back("'" + Strings::Escape(group_leaders_entry.puller) + "'"); - insert_values.push_back("'" + Strings::Escape(group_leaders_entry.mentoree) + "'"); - insert_values.push_back(std::to_string(group_leaders_entry.mentor_percent)); + v.push_back(std::to_string(e.gid)); + v.push_back("'" + Strings::Escape(e.leadername) + "'"); + v.push_back("'" + Strings::Escape(e.marknpc) + "'"); + v.push_back("'" + Strings::Escape(e.leadershipaa) + "'"); + v.push_back("'" + Strings::Escape(e.maintank) + "'"); + v.push_back("'" + Strings::Escape(e.assist) + "'"); + v.push_back("'" + Strings::Escape(e.puller) + "'"); + v.push_back("'" + Strings::Escape(e.mentoree) + "'"); + v.push_back(std::to_string(e.mentor_percent)); - insert_chunks.push_back("(" + Strings::Implode(",", insert_values) + ")"); + insert_chunks.push_back("(" + Strings::Implode(",", v) + ")"); } - std::vector insert_values; + std::vector v; auto results = db.QueryDatabase( fmt::format( @@ -296,25 +296,25 @@ public: all_entries.reserve(results.RowCount()); for (auto row = results.begin(); row != results.end(); ++row) { - GroupLeaders entry{}; + GroupLeaders e{}; - entry.gid = atoi(row[0]); - entry.leadername = row[1] ? row[1] : ""; - entry.marknpc = row[2] ? row[2] : ""; - entry.leadershipaa = row[3] ? row[3] : ""; - entry.maintank = row[4] ? row[4] : ""; - entry.assist = row[5] ? row[5] : ""; - entry.puller = row[6] ? row[6] : ""; - entry.mentoree = row[7] ? row[7] : ""; - entry.mentor_percent = atoi(row[8]); + e.gid = atoi(row[0]); + e.leadername = row[1] ? row[1] : ""; + e.marknpc = row[2] ? row[2] : ""; + e.leadershipaa = row[3] ? row[3] : ""; + e.maintank = row[4] ? row[4] : ""; + e.assist = row[5] ? row[5] : ""; + e.puller = row[6] ? row[6] : ""; + e.mentoree = row[7] ? row[7] : ""; + e.mentor_percent = atoi(row[8]); - all_entries.push_back(entry); + all_entries.push_back(e); } return all_entries; } - static std::vector GetWhere(Database& db, std::string where_filter) + static std::vector GetWhere(Database& db, const std::string &where_filter) { std::vector all_entries; @@ -329,25 +329,25 @@ public: all_entries.reserve(results.RowCount()); for (auto row = results.begin(); row != results.end(); ++row) { - GroupLeaders entry{}; + GroupLeaders e{}; - entry.gid = atoi(row[0]); - entry.leadername = row[1] ? row[1] : ""; - entry.marknpc = row[2] ? row[2] : ""; - entry.leadershipaa = row[3] ? row[3] : ""; - entry.maintank = row[4] ? row[4] : ""; - entry.assist = row[5] ? row[5] : ""; - entry.puller = row[6] ? row[6] : ""; - entry.mentoree = row[7] ? row[7] : ""; - entry.mentor_percent = atoi(row[8]); + e.gid = atoi(row[0]); + e.leadername = row[1] ? row[1] : ""; + e.marknpc = row[2] ? row[2] : ""; + e.leadershipaa = row[3] ? row[3] : ""; + e.maintank = row[4] ? row[4] : ""; + e.assist = row[5] ? row[5] : ""; + e.puller = row[6] ? row[6] : ""; + e.mentoree = row[7] ? row[7] : ""; + e.mentor_percent = atoi(row[8]); - all_entries.push_back(entry); + all_entries.push_back(e); } return all_entries; } - static int DeleteWhere(Database& db, std::string where_filter) + static int DeleteWhere(Database& db, const std::string &where_filter) { auto results = db.QueryDatabase( fmt::format( @@ -372,6 +372,32 @@ public: 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); + } + }; #endif //EQEMU_BASE_GROUP_LEADERS_REPOSITORY_H diff --git a/common/repositories/base/base_guild_members_repository.h b/common/repositories/base/base_guild_members_repository.h deleted file mode 100644 index 83959aca4..000000000 --- a/common/repositories/base/base_guild_members_repository.h +++ /dev/null @@ -1,377 +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://eqemu.gitbook.io/server/in-development/developer-area/repositories - */ - -#ifndef EQEMU_BASE_GUILD_MEMBERS_REPOSITORY_H -#define EQEMU_BASE_GUILD_MEMBERS_REPOSITORY_H - -#include "../../database.h" -#include "../../strings.h" -#include - -class BaseGuildMembersRepository { -public: - struct GuildMembers { - int char_id; - int guild_id; - int rank; - int tribute_enable; - int total_tribute; - int last_tribute; - int banker; - std::string public_note; - int alt; - }; - - static std::string PrimaryKey() - { - return std::string("char_id"); - } - - static std::vector Columns() - { - return { - "char_id", - "guild_id", - "rank", - "tribute_enable", - "total_tribute", - "last_tribute", - "banker", - "public_note", - "alt", - }; - } - - static std::vector SelectColumns() - { - return { - "char_id", - "guild_id", - "rank", - "tribute_enable", - "total_tribute", - "last_tribute", - "banker", - "public_note", - "alt", - }; - } - - 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("guild_members"); - } - - static std::string BaseSelect() - { - return fmt::format( - "SELECT {} FROM {}", - SelectColumnsRaw(), - TableName() - ); - } - - static std::string BaseInsert() - { - return fmt::format( - "INSERT INTO {} ({}) ", - TableName(), - ColumnsRaw() - ); - } - - static GuildMembers NewEntity() - { - GuildMembers entry{}; - - entry.char_id = 0; - entry.guild_id = 0; - entry.rank = 0; - entry.tribute_enable = 0; - entry.total_tribute = 0; - entry.last_tribute = 0; - entry.banker = 0; - entry.public_note = ""; - entry.alt = 0; - - return entry; - } - - static GuildMembers GetGuildMembersEntry( - const std::vector &guild_memberss, - int guild_members_id - ) - { - for (auto &guild_members : guild_memberss) { - if (guild_members.char_id == guild_members_id) { - return guild_members; - } - } - - return NewEntity(); - } - - static GuildMembers FindOne( - Database& db, - int guild_members_id - ) - { - auto results = db.QueryDatabase( - fmt::format( - "{} WHERE id = {} LIMIT 1", - BaseSelect(), - guild_members_id - ) - ); - - auto row = results.begin(); - if (results.RowCount() == 1) { - GuildMembers entry{}; - - entry.char_id = atoi(row[0]); - entry.guild_id = atoi(row[1]); - entry.rank = atoi(row[2]); - entry.tribute_enable = atoi(row[3]); - entry.total_tribute = atoi(row[4]); - entry.last_tribute = atoi(row[5]); - entry.banker = atoi(row[6]); - entry.public_note = row[7] ? row[7] : ""; - entry.alt = atoi(row[8]); - - return entry; - } - - return NewEntity(); - } - - static int DeleteOne( - Database& db, - int guild_members_id - ) - { - auto results = db.QueryDatabase( - fmt::format( - "DELETE FROM {} WHERE {} = {}", - TableName(), - PrimaryKey(), - guild_members_id - ) - ); - - return (results.Success() ? results.RowsAffected() : 0); - } - - static int UpdateOne( - Database& db, - GuildMembers guild_members_entry - ) - { - std::vector update_values; - - auto columns = Columns(); - - update_values.push_back(columns[0] + " = " + std::to_string(guild_members_entry.char_id)); - update_values.push_back(columns[1] + " = " + std::to_string(guild_members_entry.guild_id)); - update_values.push_back(columns[2] + " = " + std::to_string(guild_members_entry.rank)); - update_values.push_back(columns[3] + " = " + std::to_string(guild_members_entry.tribute_enable)); - update_values.push_back(columns[4] + " = " + std::to_string(guild_members_entry.total_tribute)); - update_values.push_back(columns[5] + " = " + std::to_string(guild_members_entry.last_tribute)); - update_values.push_back(columns[6] + " = " + std::to_string(guild_members_entry.banker)); - update_values.push_back(columns[7] + " = '" + Strings::Escape(guild_members_entry.public_note) + "'"); - update_values.push_back(columns[8] + " = " + std::to_string(guild_members_entry.alt)); - - auto results = db.QueryDatabase( - fmt::format( - "UPDATE {} SET {} WHERE {} = {}", - TableName(), - Strings::Implode(", ", update_values), - PrimaryKey(), - guild_members_entry.char_id - ) - ); - - return (results.Success() ? results.RowsAffected() : 0); - } - - static GuildMembers InsertOne( - Database& db, - GuildMembers guild_members_entry - ) - { - std::vector insert_values; - - insert_values.push_back(std::to_string(guild_members_entry.char_id)); - insert_values.push_back(std::to_string(guild_members_entry.guild_id)); - insert_values.push_back(std::to_string(guild_members_entry.rank)); - insert_values.push_back(std::to_string(guild_members_entry.tribute_enable)); - insert_values.push_back(std::to_string(guild_members_entry.total_tribute)); - insert_values.push_back(std::to_string(guild_members_entry.last_tribute)); - insert_values.push_back(std::to_string(guild_members_entry.banker)); - insert_values.push_back("'" + Strings::Escape(guild_members_entry.public_note) + "'"); - insert_values.push_back(std::to_string(guild_members_entry.alt)); - - auto results = db.QueryDatabase( - fmt::format( - "{} VALUES ({})", - BaseInsert(), - Strings::Implode(",", insert_values) - ) - ); - - if (results.Success()) { - guild_members_entry.char_id = results.LastInsertedID(); - return guild_members_entry; - } - - guild_members_entry = NewEntity(); - - return guild_members_entry; - } - - static int InsertMany( - Database& db, - std::vector guild_members_entries - ) - { - std::vector insert_chunks; - - for (auto &guild_members_entry: guild_members_entries) { - std::vector insert_values; - - insert_values.push_back(std::to_string(guild_members_entry.char_id)); - insert_values.push_back(std::to_string(guild_members_entry.guild_id)); - insert_values.push_back(std::to_string(guild_members_entry.rank)); - insert_values.push_back(std::to_string(guild_members_entry.tribute_enable)); - insert_values.push_back(std::to_string(guild_members_entry.total_tribute)); - insert_values.push_back(std::to_string(guild_members_entry.last_tribute)); - insert_values.push_back(std::to_string(guild_members_entry.banker)); - insert_values.push_back("'" + Strings::Escape(guild_members_entry.public_note) + "'"); - insert_values.push_back(std::to_string(guild_members_entry.alt)); - - insert_chunks.push_back("(" + Strings::Implode(",", insert_values) + ")"); - } - - std::vector insert_values; - - 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) { - GuildMembers entry{}; - - entry.char_id = atoi(row[0]); - entry.guild_id = atoi(row[1]); - entry.rank = atoi(row[2]); - entry.tribute_enable = atoi(row[3]); - entry.total_tribute = atoi(row[4]); - entry.last_tribute = atoi(row[5]); - entry.banker = atoi(row[6]); - entry.public_note = row[7] ? row[7] : ""; - entry.alt = atoi(row[8]); - - all_entries.push_back(entry); - } - - return all_entries; - } - - static std::vector GetWhere(Database& db, 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) { - GuildMembers entry{}; - - entry.char_id = atoi(row[0]); - entry.guild_id = atoi(row[1]); - entry.rank = atoi(row[2]); - entry.tribute_enable = atoi(row[3]); - entry.total_tribute = atoi(row[4]); - entry.last_tribute = atoi(row[5]); - entry.banker = atoi(row[6]); - entry.public_note = row[7] ? row[7] : ""; - entry.alt = atoi(row[8]); - - all_entries.push_back(entry); - } - - return all_entries; - } - - static int DeleteWhere(Database& db, 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); - } - -}; - -#endif //EQEMU_BASE_GUILD_MEMBERS_REPOSITORY_H diff --git a/common/repositories/base/base_guild_ranks_repository.h b/common/repositories/base/base_guild_ranks_repository.h index a15768b20..9c61c8ca1 100644 --- a/common/repositories/base/base_guild_ranks_repository.h +++ b/common/repositories/base/base_guild_ranks_repository.h @@ -106,24 +106,24 @@ public: static GuildRanks NewEntity() { - GuildRanks entry{}; + GuildRanks e{}; - entry.guild_id = 0; - entry.rank = 0; - entry.title = ""; - entry.can_hear = 0; - entry.can_speak = 0; - entry.can_invite = 0; - entry.can_remove = 0; - entry.can_promote = 0; - entry.can_demote = 0; - entry.can_motd = 0; - entry.can_warpeace = 0; + e.guild_id = 0; + e.rank = 0; + e.title = ""; + e.can_hear = 0; + e.can_speak = 0; + e.can_invite = 0; + e.can_remove = 0; + e.can_promote = 0; + e.can_demote = 0; + e.can_motd = 0; + e.can_warpeace = 0; - return entry; + return e; } - static GuildRanks GetGuildRanksEntry( + static GuildRanks GetGuildRanks( const std::vector &guild_rankss, int guild_ranks_id ) @@ -152,21 +152,21 @@ public: auto row = results.begin(); if (results.RowCount() == 1) { - GuildRanks entry{}; + GuildRanks e{}; - entry.guild_id = atoi(row[0]); - entry.rank = atoi(row[1]); - entry.title = row[2] ? row[2] : ""; - entry.can_hear = atoi(row[3]); - entry.can_speak = atoi(row[4]); - entry.can_invite = atoi(row[5]); - entry.can_remove = atoi(row[6]); - entry.can_promote = atoi(row[7]); - entry.can_demote = atoi(row[8]); - entry.can_motd = atoi(row[9]); - entry.can_warpeace = atoi(row[10]); + e.guild_id = atoi(row[0]); + e.rank = atoi(row[1]); + e.title = row[2] ? row[2] : ""; + e.can_hear = atoi(row[3]); + e.can_speak = atoi(row[4]); + e.can_invite = atoi(row[5]); + e.can_remove = atoi(row[6]); + e.can_promote = atoi(row[7]); + e.can_demote = atoi(row[8]); + e.can_motd = atoi(row[9]); + e.can_warpeace = atoi(row[10]); - return entry; + return e; } return NewEntity(); @@ -191,32 +191,32 @@ public: static int UpdateOne( Database& db, - GuildRanks guild_ranks_entry + const GuildRanks &e ) { - std::vector update_values; + std::vector v; auto columns = Columns(); - update_values.push_back(columns[0] + " = " + std::to_string(guild_ranks_entry.guild_id)); - update_values.push_back(columns[1] + " = " + std::to_string(guild_ranks_entry.rank)); - update_values.push_back(columns[2] + " = '" + Strings::Escape(guild_ranks_entry.title) + "'"); - update_values.push_back(columns[3] + " = " + std::to_string(guild_ranks_entry.can_hear)); - update_values.push_back(columns[4] + " = " + std::to_string(guild_ranks_entry.can_speak)); - update_values.push_back(columns[5] + " = " + std::to_string(guild_ranks_entry.can_invite)); - update_values.push_back(columns[6] + " = " + std::to_string(guild_ranks_entry.can_remove)); - update_values.push_back(columns[7] + " = " + std::to_string(guild_ranks_entry.can_promote)); - update_values.push_back(columns[8] + " = " + std::to_string(guild_ranks_entry.can_demote)); - update_values.push_back(columns[9] + " = " + std::to_string(guild_ranks_entry.can_motd)); - update_values.push_back(columns[10] + " = " + std::to_string(guild_ranks_entry.can_warpeace)); + v.push_back(columns[0] + " = " + std::to_string(e.guild_id)); + v.push_back(columns[1] + " = " + std::to_string(e.rank)); + v.push_back(columns[2] + " = '" + Strings::Escape(e.title) + "'"); + v.push_back(columns[3] + " = " + std::to_string(e.can_hear)); + v.push_back(columns[4] + " = " + std::to_string(e.can_speak)); + v.push_back(columns[5] + " = " + std::to_string(e.can_invite)); + v.push_back(columns[6] + " = " + std::to_string(e.can_remove)); + v.push_back(columns[7] + " = " + std::to_string(e.can_promote)); + v.push_back(columns[8] + " = " + std::to_string(e.can_demote)); + v.push_back(columns[9] + " = " + std::to_string(e.can_motd)); + v.push_back(columns[10] + " = " + std::to_string(e.can_warpeace)); auto results = db.QueryDatabase( fmt::format( "UPDATE {} SET {} WHERE {} = {}", TableName(), - Strings::Implode(", ", update_values), + Strings::Implode(", ", v), PrimaryKey(), - guild_ranks_entry.guild_id + e.guild_id ) ); @@ -225,67 +225,67 @@ public: static GuildRanks InsertOne( Database& db, - GuildRanks guild_ranks_entry + GuildRanks e ) { - std::vector insert_values; + std::vector v; - insert_values.push_back(std::to_string(guild_ranks_entry.guild_id)); - insert_values.push_back(std::to_string(guild_ranks_entry.rank)); - insert_values.push_back("'" + Strings::Escape(guild_ranks_entry.title) + "'"); - insert_values.push_back(std::to_string(guild_ranks_entry.can_hear)); - insert_values.push_back(std::to_string(guild_ranks_entry.can_speak)); - insert_values.push_back(std::to_string(guild_ranks_entry.can_invite)); - insert_values.push_back(std::to_string(guild_ranks_entry.can_remove)); - insert_values.push_back(std::to_string(guild_ranks_entry.can_promote)); - insert_values.push_back(std::to_string(guild_ranks_entry.can_demote)); - insert_values.push_back(std::to_string(guild_ranks_entry.can_motd)); - insert_values.push_back(std::to_string(guild_ranks_entry.can_warpeace)); + v.push_back(std::to_string(e.guild_id)); + v.push_back(std::to_string(e.rank)); + v.push_back("'" + Strings::Escape(e.title) + "'"); + v.push_back(std::to_string(e.can_hear)); + v.push_back(std::to_string(e.can_speak)); + v.push_back(std::to_string(e.can_invite)); + v.push_back(std::to_string(e.can_remove)); + v.push_back(std::to_string(e.can_promote)); + v.push_back(std::to_string(e.can_demote)); + v.push_back(std::to_string(e.can_motd)); + v.push_back(std::to_string(e.can_warpeace)); auto results = db.QueryDatabase( fmt::format( "{} VALUES ({})", BaseInsert(), - Strings::Implode(",", insert_values) + Strings::Implode(",", v) ) ); if (results.Success()) { - guild_ranks_entry.guild_id = results.LastInsertedID(); - return guild_ranks_entry; + e.guild_id = results.LastInsertedID(); + return e; } - guild_ranks_entry = NewEntity(); + e = NewEntity(); - return guild_ranks_entry; + return e; } static int InsertMany( Database& db, - std::vector guild_ranks_entries + const std::vector &entries ) { std::vector insert_chunks; - for (auto &guild_ranks_entry: guild_ranks_entries) { - std::vector insert_values; + for (auto &e: entries) { + std::vector v; - insert_values.push_back(std::to_string(guild_ranks_entry.guild_id)); - insert_values.push_back(std::to_string(guild_ranks_entry.rank)); - insert_values.push_back("'" + Strings::Escape(guild_ranks_entry.title) + "'"); - insert_values.push_back(std::to_string(guild_ranks_entry.can_hear)); - insert_values.push_back(std::to_string(guild_ranks_entry.can_speak)); - insert_values.push_back(std::to_string(guild_ranks_entry.can_invite)); - insert_values.push_back(std::to_string(guild_ranks_entry.can_remove)); - insert_values.push_back(std::to_string(guild_ranks_entry.can_promote)); - insert_values.push_back(std::to_string(guild_ranks_entry.can_demote)); - insert_values.push_back(std::to_string(guild_ranks_entry.can_motd)); - insert_values.push_back(std::to_string(guild_ranks_entry.can_warpeace)); + v.push_back(std::to_string(e.guild_id)); + v.push_back(std::to_string(e.rank)); + v.push_back("'" + Strings::Escape(e.title) + "'"); + v.push_back(std::to_string(e.can_hear)); + v.push_back(std::to_string(e.can_speak)); + v.push_back(std::to_string(e.can_invite)); + v.push_back(std::to_string(e.can_remove)); + v.push_back(std::to_string(e.can_promote)); + v.push_back(std::to_string(e.can_demote)); + v.push_back(std::to_string(e.can_motd)); + v.push_back(std::to_string(e.can_warpeace)); - insert_chunks.push_back("(" + Strings::Implode(",", insert_values) + ")"); + insert_chunks.push_back("(" + Strings::Implode(",", v) + ")"); } - std::vector insert_values; + std::vector v; auto results = db.QueryDatabase( fmt::format( @@ -312,27 +312,27 @@ public: all_entries.reserve(results.RowCount()); for (auto row = results.begin(); row != results.end(); ++row) { - GuildRanks entry{}; + GuildRanks e{}; - entry.guild_id = atoi(row[0]); - entry.rank = atoi(row[1]); - entry.title = row[2] ? row[2] : ""; - entry.can_hear = atoi(row[3]); - entry.can_speak = atoi(row[4]); - entry.can_invite = atoi(row[5]); - entry.can_remove = atoi(row[6]); - entry.can_promote = atoi(row[7]); - entry.can_demote = atoi(row[8]); - entry.can_motd = atoi(row[9]); - entry.can_warpeace = atoi(row[10]); + e.guild_id = atoi(row[0]); + e.rank = atoi(row[1]); + e.title = row[2] ? row[2] : ""; + e.can_hear = atoi(row[3]); + e.can_speak = atoi(row[4]); + e.can_invite = atoi(row[5]); + e.can_remove = atoi(row[6]); + e.can_promote = atoi(row[7]); + e.can_demote = atoi(row[8]); + e.can_motd = atoi(row[9]); + e.can_warpeace = atoi(row[10]); - all_entries.push_back(entry); + all_entries.push_back(e); } return all_entries; } - static std::vector GetWhere(Database& db, std::string where_filter) + static std::vector GetWhere(Database& db, const std::string &where_filter) { std::vector all_entries; @@ -347,27 +347,27 @@ public: all_entries.reserve(results.RowCount()); for (auto row = results.begin(); row != results.end(); ++row) { - GuildRanks entry{}; + GuildRanks e{}; - entry.guild_id = atoi(row[0]); - entry.rank = atoi(row[1]); - entry.title = row[2] ? row[2] : ""; - entry.can_hear = atoi(row[3]); - entry.can_speak = atoi(row[4]); - entry.can_invite = atoi(row[5]); - entry.can_remove = atoi(row[6]); - entry.can_promote = atoi(row[7]); - entry.can_demote = atoi(row[8]); - entry.can_motd = atoi(row[9]); - entry.can_warpeace = atoi(row[10]); + e.guild_id = atoi(row[0]); + e.rank = atoi(row[1]); + e.title = row[2] ? row[2] : ""; + e.can_hear = atoi(row[3]); + e.can_speak = atoi(row[4]); + e.can_invite = atoi(row[5]); + e.can_remove = atoi(row[6]); + e.can_promote = atoi(row[7]); + e.can_demote = atoi(row[8]); + e.can_motd = atoi(row[9]); + e.can_warpeace = atoi(row[10]); - all_entries.push_back(entry); + all_entries.push_back(e); } return all_entries; } - static int DeleteWhere(Database& db, std::string where_filter) + static int DeleteWhere(Database& db, const std::string &where_filter) { auto results = db.QueryDatabase( fmt::format( @@ -392,6 +392,32 @@ public: 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); + } + }; #endif //EQEMU_BASE_GUILD_RANKS_REPOSITORY_H diff --git a/common/repositories/base/base_guild_relations_repository.h b/common/repositories/base/base_guild_relations_repository.h index 0901102a6..10a7da86e 100644 --- a/common/repositories/base/base_guild_relations_repository.h +++ b/common/repositories/base/base_guild_relations_repository.h @@ -82,16 +82,16 @@ public: static GuildRelations NewEntity() { - GuildRelations entry{}; + GuildRelations e{}; - entry.guild1 = 0; - entry.guild2 = 0; - entry.relation = 0; + e.guild1 = 0; + e.guild2 = 0; + e.relation = 0; - return entry; + return e; } - static GuildRelations GetGuildRelationsEntry( + static GuildRelations GetGuildRelations( const std::vector &guild_relationss, int guild_relations_id ) @@ -120,13 +120,13 @@ public: auto row = results.begin(); if (results.RowCount() == 1) { - GuildRelations entry{}; + GuildRelations e{}; - entry.guild1 = atoi(row[0]); - entry.guild2 = atoi(row[1]); - entry.relation = atoi(row[2]); + e.guild1 = atoi(row[0]); + e.guild2 = atoi(row[1]); + e.relation = atoi(row[2]); - return entry; + return e; } return NewEntity(); @@ -151,24 +151,24 @@ public: static int UpdateOne( Database& db, - GuildRelations guild_relations_entry + const GuildRelations &e ) { - std::vector update_values; + std::vector v; auto columns = Columns(); - update_values.push_back(columns[0] + " = " + std::to_string(guild_relations_entry.guild1)); - update_values.push_back(columns[1] + " = " + std::to_string(guild_relations_entry.guild2)); - update_values.push_back(columns[2] + " = " + std::to_string(guild_relations_entry.relation)); + v.push_back(columns[0] + " = " + std::to_string(e.guild1)); + v.push_back(columns[1] + " = " + std::to_string(e.guild2)); + v.push_back(columns[2] + " = " + std::to_string(e.relation)); auto results = db.QueryDatabase( fmt::format( "UPDATE {} SET {} WHERE {} = {}", TableName(), - Strings::Implode(", ", update_values), + Strings::Implode(", ", v), PrimaryKey(), - guild_relations_entry.guild1 + e.guild1 ) ); @@ -177,51 +177,51 @@ public: static GuildRelations InsertOne( Database& db, - GuildRelations guild_relations_entry + GuildRelations e ) { - std::vector insert_values; + std::vector v; - insert_values.push_back(std::to_string(guild_relations_entry.guild1)); - insert_values.push_back(std::to_string(guild_relations_entry.guild2)); - insert_values.push_back(std::to_string(guild_relations_entry.relation)); + v.push_back(std::to_string(e.guild1)); + v.push_back(std::to_string(e.guild2)); + v.push_back(std::to_string(e.relation)); auto results = db.QueryDatabase( fmt::format( "{} VALUES ({})", BaseInsert(), - Strings::Implode(",", insert_values) + Strings::Implode(",", v) ) ); if (results.Success()) { - guild_relations_entry.guild1 = results.LastInsertedID(); - return guild_relations_entry; + e.guild1 = results.LastInsertedID(); + return e; } - guild_relations_entry = NewEntity(); + e = NewEntity(); - return guild_relations_entry; + return e; } static int InsertMany( Database& db, - std::vector guild_relations_entries + const std::vector &entries ) { std::vector insert_chunks; - for (auto &guild_relations_entry: guild_relations_entries) { - std::vector insert_values; + for (auto &e: entries) { + std::vector v; - insert_values.push_back(std::to_string(guild_relations_entry.guild1)); - insert_values.push_back(std::to_string(guild_relations_entry.guild2)); - insert_values.push_back(std::to_string(guild_relations_entry.relation)); + v.push_back(std::to_string(e.guild1)); + v.push_back(std::to_string(e.guild2)); + v.push_back(std::to_string(e.relation)); - insert_chunks.push_back("(" + Strings::Implode(",", insert_values) + ")"); + insert_chunks.push_back("(" + Strings::Implode(",", v) + ")"); } - std::vector insert_values; + std::vector v; auto results = db.QueryDatabase( fmt::format( @@ -248,19 +248,19 @@ public: all_entries.reserve(results.RowCount()); for (auto row = results.begin(); row != results.end(); ++row) { - GuildRelations entry{}; + GuildRelations e{}; - entry.guild1 = atoi(row[0]); - entry.guild2 = atoi(row[1]); - entry.relation = atoi(row[2]); + e.guild1 = atoi(row[0]); + e.guild2 = atoi(row[1]); + e.relation = atoi(row[2]); - all_entries.push_back(entry); + all_entries.push_back(e); } return all_entries; } - static std::vector GetWhere(Database& db, std::string where_filter) + static std::vector GetWhere(Database& db, const std::string &where_filter) { std::vector all_entries; @@ -275,19 +275,19 @@ public: all_entries.reserve(results.RowCount()); for (auto row = results.begin(); row != results.end(); ++row) { - GuildRelations entry{}; + GuildRelations e{}; - entry.guild1 = atoi(row[0]); - entry.guild2 = atoi(row[1]); - entry.relation = atoi(row[2]); + e.guild1 = atoi(row[0]); + e.guild2 = atoi(row[1]); + e.relation = atoi(row[2]); - all_entries.push_back(entry); + all_entries.push_back(e); } return all_entries; } - static int DeleteWhere(Database& db, std::string where_filter) + static int DeleteWhere(Database& db, const std::string &where_filter) { auto results = db.QueryDatabase( fmt::format( @@ -312,6 +312,32 @@ public: 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); + } + }; #endif //EQEMU_BASE_GUILD_RELATIONS_REPOSITORY_H diff --git a/common/repositories/base/base_guilds_repository.h b/common/repositories/base/base_guilds_repository.h index 1a926a194..53558afbc 100644 --- a/common/repositories/base/base_guilds_repository.h +++ b/common/repositories/base/base_guilds_repository.h @@ -100,22 +100,22 @@ public: static Guilds NewEntity() { - Guilds entry{}; + Guilds e{}; - entry.id = 0; - entry.name = ""; - entry.leader = 0; - entry.minstatus = 0; - entry.motd = ""; - entry.tribute = 0; - entry.motd_setter = ""; - entry.channel = ""; - entry.url = ""; + e.id = 0; + e.name = ""; + e.leader = 0; + e.minstatus = 0; + e.motd = ""; + e.tribute = 0; + e.motd_setter = ""; + e.channel = ""; + e.url = ""; - return entry; + return e; } - static Guilds GetGuildsEntry( + static Guilds GetGuilds( const std::vector &guildss, int guilds_id ) @@ -144,19 +144,19 @@ public: auto row = results.begin(); if (results.RowCount() == 1) { - Guilds entry{}; + Guilds e{}; - entry.id = atoi(row[0]); - entry.name = row[1] ? row[1] : ""; - entry.leader = atoi(row[2]); - entry.minstatus = atoi(row[3]); - entry.motd = row[4] ? row[4] : ""; - entry.tribute = atoi(row[5]); - entry.motd_setter = row[6] ? row[6] : ""; - entry.channel = row[7] ? row[7] : ""; - entry.url = row[8] ? row[8] : ""; + e.id = atoi(row[0]); + e.name = row[1] ? row[1] : ""; + e.leader = atoi(row[2]); + e.minstatus = atoi(row[3]); + e.motd = row[4] ? row[4] : ""; + e.tribute = atoi(row[5]); + e.motd_setter = row[6] ? row[6] : ""; + e.channel = row[7] ? row[7] : ""; + e.url = row[8] ? row[8] : ""; - return entry; + return e; } return NewEntity(); @@ -181,29 +181,29 @@ public: static int UpdateOne( Database& db, - Guilds guilds_entry + const Guilds &e ) { - std::vector update_values; + std::vector v; auto columns = Columns(); - update_values.push_back(columns[1] + " = '" + Strings::Escape(guilds_entry.name) + "'"); - update_values.push_back(columns[2] + " = " + std::to_string(guilds_entry.leader)); - update_values.push_back(columns[3] + " = " + std::to_string(guilds_entry.minstatus)); - update_values.push_back(columns[4] + " = '" + Strings::Escape(guilds_entry.motd) + "'"); - update_values.push_back(columns[5] + " = " + std::to_string(guilds_entry.tribute)); - update_values.push_back(columns[6] + " = '" + Strings::Escape(guilds_entry.motd_setter) + "'"); - update_values.push_back(columns[7] + " = '" + Strings::Escape(guilds_entry.channel) + "'"); - update_values.push_back(columns[8] + " = '" + Strings::Escape(guilds_entry.url) + "'"); + v.push_back(columns[1] + " = '" + Strings::Escape(e.name) + "'"); + v.push_back(columns[2] + " = " + std::to_string(e.leader)); + v.push_back(columns[3] + " = " + std::to_string(e.minstatus)); + v.push_back(columns[4] + " = '" + Strings::Escape(e.motd) + "'"); + v.push_back(columns[5] + " = " + std::to_string(e.tribute)); + v.push_back(columns[6] + " = '" + Strings::Escape(e.motd_setter) + "'"); + v.push_back(columns[7] + " = '" + Strings::Escape(e.channel) + "'"); + v.push_back(columns[8] + " = '" + Strings::Escape(e.url) + "'"); auto results = db.QueryDatabase( fmt::format( "UPDATE {} SET {} WHERE {} = {}", TableName(), - Strings::Implode(", ", update_values), + Strings::Implode(", ", v), PrimaryKey(), - guilds_entry.id + e.id ) ); @@ -212,63 +212,63 @@ public: static Guilds InsertOne( Database& db, - Guilds guilds_entry + Guilds e ) { - std::vector insert_values; + std::vector v; - insert_values.push_back(std::to_string(guilds_entry.id)); - insert_values.push_back("'" + Strings::Escape(guilds_entry.name) + "'"); - insert_values.push_back(std::to_string(guilds_entry.leader)); - insert_values.push_back(std::to_string(guilds_entry.minstatus)); - insert_values.push_back("'" + Strings::Escape(guilds_entry.motd) + "'"); - insert_values.push_back(std::to_string(guilds_entry.tribute)); - insert_values.push_back("'" + Strings::Escape(guilds_entry.motd_setter) + "'"); - insert_values.push_back("'" + Strings::Escape(guilds_entry.channel) + "'"); - insert_values.push_back("'" + Strings::Escape(guilds_entry.url) + "'"); + v.push_back(std::to_string(e.id)); + v.push_back("'" + Strings::Escape(e.name) + "'"); + v.push_back(std::to_string(e.leader)); + v.push_back(std::to_string(e.minstatus)); + v.push_back("'" + Strings::Escape(e.motd) + "'"); + v.push_back(std::to_string(e.tribute)); + v.push_back("'" + Strings::Escape(e.motd_setter) + "'"); + v.push_back("'" + Strings::Escape(e.channel) + "'"); + v.push_back("'" + Strings::Escape(e.url) + "'"); auto results = db.QueryDatabase( fmt::format( "{} VALUES ({})", BaseInsert(), - Strings::Implode(",", insert_values) + Strings::Implode(",", v) ) ); if (results.Success()) { - guilds_entry.id = results.LastInsertedID(); - return guilds_entry; + e.id = results.LastInsertedID(); + return e; } - guilds_entry = NewEntity(); + e = NewEntity(); - return guilds_entry; + return e; } static int InsertMany( Database& db, - std::vector guilds_entries + const std::vector &entries ) { std::vector insert_chunks; - for (auto &guilds_entry: guilds_entries) { - std::vector insert_values; + for (auto &e: entries) { + std::vector v; - insert_values.push_back(std::to_string(guilds_entry.id)); - insert_values.push_back("'" + Strings::Escape(guilds_entry.name) + "'"); - insert_values.push_back(std::to_string(guilds_entry.leader)); - insert_values.push_back(std::to_string(guilds_entry.minstatus)); - insert_values.push_back("'" + Strings::Escape(guilds_entry.motd) + "'"); - insert_values.push_back(std::to_string(guilds_entry.tribute)); - insert_values.push_back("'" + Strings::Escape(guilds_entry.motd_setter) + "'"); - insert_values.push_back("'" + Strings::Escape(guilds_entry.channel) + "'"); - insert_values.push_back("'" + Strings::Escape(guilds_entry.url) + "'"); + v.push_back(std::to_string(e.id)); + v.push_back("'" + Strings::Escape(e.name) + "'"); + v.push_back(std::to_string(e.leader)); + v.push_back(std::to_string(e.minstatus)); + v.push_back("'" + Strings::Escape(e.motd) + "'"); + v.push_back(std::to_string(e.tribute)); + v.push_back("'" + Strings::Escape(e.motd_setter) + "'"); + v.push_back("'" + Strings::Escape(e.channel) + "'"); + v.push_back("'" + Strings::Escape(e.url) + "'"); - insert_chunks.push_back("(" + Strings::Implode(",", insert_values) + ")"); + insert_chunks.push_back("(" + Strings::Implode(",", v) + ")"); } - std::vector insert_values; + std::vector v; auto results = db.QueryDatabase( fmt::format( @@ -295,25 +295,25 @@ public: all_entries.reserve(results.RowCount()); for (auto row = results.begin(); row != results.end(); ++row) { - Guilds entry{}; + Guilds e{}; - entry.id = atoi(row[0]); - entry.name = row[1] ? row[1] : ""; - entry.leader = atoi(row[2]); - entry.minstatus = atoi(row[3]); - entry.motd = row[4] ? row[4] : ""; - entry.tribute = atoi(row[5]); - entry.motd_setter = row[6] ? row[6] : ""; - entry.channel = row[7] ? row[7] : ""; - entry.url = row[8] ? row[8] : ""; + e.id = atoi(row[0]); + e.name = row[1] ? row[1] : ""; + e.leader = atoi(row[2]); + e.minstatus = atoi(row[3]); + e.motd = row[4] ? row[4] : ""; + e.tribute = atoi(row[5]); + e.motd_setter = row[6] ? row[6] : ""; + e.channel = row[7] ? row[7] : ""; + e.url = row[8] ? row[8] : ""; - all_entries.push_back(entry); + all_entries.push_back(e); } return all_entries; } - static std::vector GetWhere(Database& db, std::string where_filter) + static std::vector GetWhere(Database& db, const std::string &where_filter) { std::vector all_entries; @@ -328,25 +328,25 @@ public: all_entries.reserve(results.RowCount()); for (auto row = results.begin(); row != results.end(); ++row) { - Guilds entry{}; + Guilds e{}; - entry.id = atoi(row[0]); - entry.name = row[1] ? row[1] : ""; - entry.leader = atoi(row[2]); - entry.minstatus = atoi(row[3]); - entry.motd = row[4] ? row[4] : ""; - entry.tribute = atoi(row[5]); - entry.motd_setter = row[6] ? row[6] : ""; - entry.channel = row[7] ? row[7] : ""; - entry.url = row[8] ? row[8] : ""; + e.id = atoi(row[0]); + e.name = row[1] ? row[1] : ""; + e.leader = atoi(row[2]); + e.minstatus = atoi(row[3]); + e.motd = row[4] ? row[4] : ""; + e.tribute = atoi(row[5]); + e.motd_setter = row[6] ? row[6] : ""; + e.channel = row[7] ? row[7] : ""; + e.url = row[8] ? row[8] : ""; - all_entries.push_back(entry); + all_entries.push_back(e); } return all_entries; } - static int DeleteWhere(Database& db, std::string where_filter) + static int DeleteWhere(Database& db, const std::string &where_filter) { auto results = db.QueryDatabase( fmt::format( @@ -371,6 +371,32 @@ public: 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); + } + }; #endif //EQEMU_BASE_GUILDS_REPOSITORY_H diff --git a/common/repositories/base/base_hackers_repository.h b/common/repositories/base/base_hackers_repository.h index 0c5e31423..f37ae9f64 100644 --- a/common/repositories/base/base_hackers_repository.h +++ b/common/repositories/base/base_hackers_repository.h @@ -91,19 +91,19 @@ public: static Hackers NewEntity() { - Hackers entry{}; + Hackers e{}; - entry.id = 0; - entry.account = ""; - entry.name = ""; - entry.hacked = ""; - entry.zone = ""; - entry.date = std::time(nullptr); + e.id = 0; + e.account = ""; + e.name = ""; + e.hacked = ""; + e.zone = ""; + e.date = std::time(nullptr); - return entry; + return e; } - static Hackers GetHackersEntry( + static Hackers GetHackers( const std::vector &hackerss, int hackers_id ) @@ -132,16 +132,16 @@ public: auto row = results.begin(); if (results.RowCount() == 1) { - Hackers entry{}; + Hackers e{}; - entry.id = atoi(row[0]); - entry.account = row[1] ? row[1] : ""; - entry.name = row[2] ? row[2] : ""; - entry.hacked = row[3] ? row[3] : ""; - entry.zone = row[4] ? row[4] : ""; - entry.date = row[5] ? row[5] : ""; + e.id = atoi(row[0]); + e.account = row[1] ? row[1] : ""; + e.name = row[2] ? row[2] : ""; + e.hacked = row[3] ? row[3] : ""; + e.zone = row[4] ? row[4] : ""; + e.date = row[5] ? row[5] : ""; - return entry; + return e; } return NewEntity(); @@ -166,26 +166,26 @@ public: static int UpdateOne( Database& db, - Hackers hackers_entry + const Hackers &e ) { - std::vector update_values; + std::vector v; auto columns = Columns(); - update_values.push_back(columns[1] + " = '" + Strings::Escape(hackers_entry.account) + "'"); - update_values.push_back(columns[2] + " = '" + Strings::Escape(hackers_entry.name) + "'"); - update_values.push_back(columns[3] + " = '" + Strings::Escape(hackers_entry.hacked) + "'"); - update_values.push_back(columns[4] + " = '" + Strings::Escape(hackers_entry.zone) + "'"); - update_values.push_back(columns[5] + " = '" + Strings::Escape(hackers_entry.date) + "'"); + v.push_back(columns[1] + " = '" + Strings::Escape(e.account) + "'"); + v.push_back(columns[2] + " = '" + Strings::Escape(e.name) + "'"); + v.push_back(columns[3] + " = '" + Strings::Escape(e.hacked) + "'"); + v.push_back(columns[4] + " = '" + Strings::Escape(e.zone) + "'"); + v.push_back(columns[5] + " = '" + Strings::Escape(e.date) + "'"); auto results = db.QueryDatabase( fmt::format( "UPDATE {} SET {} WHERE {} = {}", TableName(), - Strings::Implode(", ", update_values), + Strings::Implode(", ", v), PrimaryKey(), - hackers_entry.id + e.id ) ); @@ -194,57 +194,57 @@ public: static Hackers InsertOne( Database& db, - Hackers hackers_entry + Hackers e ) { - std::vector insert_values; + std::vector v; - insert_values.push_back(std::to_string(hackers_entry.id)); - insert_values.push_back("'" + Strings::Escape(hackers_entry.account) + "'"); - insert_values.push_back("'" + Strings::Escape(hackers_entry.name) + "'"); - insert_values.push_back("'" + Strings::Escape(hackers_entry.hacked) + "'"); - insert_values.push_back("'" + Strings::Escape(hackers_entry.zone) + "'"); - insert_values.push_back("'" + Strings::Escape(hackers_entry.date) + "'"); + v.push_back(std::to_string(e.id)); + v.push_back("'" + Strings::Escape(e.account) + "'"); + v.push_back("'" + Strings::Escape(e.name) + "'"); + v.push_back("'" + Strings::Escape(e.hacked) + "'"); + v.push_back("'" + Strings::Escape(e.zone) + "'"); + v.push_back("'" + Strings::Escape(e.date) + "'"); auto results = db.QueryDatabase( fmt::format( "{} VALUES ({})", BaseInsert(), - Strings::Implode(",", insert_values) + Strings::Implode(",", v) ) ); if (results.Success()) { - hackers_entry.id = results.LastInsertedID(); - return hackers_entry; + e.id = results.LastInsertedID(); + return e; } - hackers_entry = NewEntity(); + e = NewEntity(); - return hackers_entry; + return e; } static int InsertMany( Database& db, - std::vector hackers_entries + const std::vector &entries ) { std::vector insert_chunks; - for (auto &hackers_entry: hackers_entries) { - std::vector insert_values; + for (auto &e: entries) { + std::vector v; - insert_values.push_back(std::to_string(hackers_entry.id)); - insert_values.push_back("'" + Strings::Escape(hackers_entry.account) + "'"); - insert_values.push_back("'" + Strings::Escape(hackers_entry.name) + "'"); - insert_values.push_back("'" + Strings::Escape(hackers_entry.hacked) + "'"); - insert_values.push_back("'" + Strings::Escape(hackers_entry.zone) + "'"); - insert_values.push_back("'" + Strings::Escape(hackers_entry.date) + "'"); + v.push_back(std::to_string(e.id)); + v.push_back("'" + Strings::Escape(e.account) + "'"); + v.push_back("'" + Strings::Escape(e.name) + "'"); + v.push_back("'" + Strings::Escape(e.hacked) + "'"); + v.push_back("'" + Strings::Escape(e.zone) + "'"); + v.push_back("'" + Strings::Escape(e.date) + "'"); - insert_chunks.push_back("(" + Strings::Implode(",", insert_values) + ")"); + insert_chunks.push_back("(" + Strings::Implode(",", v) + ")"); } - std::vector insert_values; + std::vector v; auto results = db.QueryDatabase( fmt::format( @@ -271,22 +271,22 @@ public: all_entries.reserve(results.RowCount()); for (auto row = results.begin(); row != results.end(); ++row) { - Hackers entry{}; + Hackers e{}; - entry.id = atoi(row[0]); - entry.account = row[1] ? row[1] : ""; - entry.name = row[2] ? row[2] : ""; - entry.hacked = row[3] ? row[3] : ""; - entry.zone = row[4] ? row[4] : ""; - entry.date = row[5] ? row[5] : ""; + e.id = atoi(row[0]); + e.account = row[1] ? row[1] : ""; + e.name = row[2] ? row[2] : ""; + e.hacked = row[3] ? row[3] : ""; + e.zone = row[4] ? row[4] : ""; + e.date = row[5] ? row[5] : ""; - all_entries.push_back(entry); + all_entries.push_back(e); } return all_entries; } - static std::vector GetWhere(Database& db, std::string where_filter) + static std::vector GetWhere(Database& db, const std::string &where_filter) { std::vector all_entries; @@ -301,22 +301,22 @@ public: all_entries.reserve(results.RowCount()); for (auto row = results.begin(); row != results.end(); ++row) { - Hackers entry{}; + Hackers e{}; - entry.id = atoi(row[0]); - entry.account = row[1] ? row[1] : ""; - entry.name = row[2] ? row[2] : ""; - entry.hacked = row[3] ? row[3] : ""; - entry.zone = row[4] ? row[4] : ""; - entry.date = row[5] ? row[5] : ""; + e.id = atoi(row[0]); + e.account = row[1] ? row[1] : ""; + e.name = row[2] ? row[2] : ""; + e.hacked = row[3] ? row[3] : ""; + e.zone = row[4] ? row[4] : ""; + e.date = row[5] ? row[5] : ""; - all_entries.push_back(entry); + all_entries.push_back(e); } return all_entries; } - static int DeleteWhere(Database& db, std::string where_filter) + static int DeleteWhere(Database& db, const std::string &where_filter) { auto results = db.QueryDatabase( fmt::format( @@ -341,6 +341,32 @@ public: 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); + } + }; #endif //EQEMU_BASE_HACKERS_REPOSITORY_H diff --git a/common/repositories/base/base_horses_repository.h b/common/repositories/base/base_horses_repository.h index ddfc92537..c63398870 100644 --- a/common/repositories/base/base_horses_repository.h +++ b/common/repositories/base/base_horses_repository.h @@ -94,20 +94,20 @@ public: static Horses NewEntity() { - Horses entry{}; + Horses e{}; - entry.id = 0; - entry.filename = ""; - entry.race = 216; - entry.gender = 0; - entry.texture = 0; - entry.mountspeed = 0.75; - entry.notes = "Notes"; + e.id = 0; + e.filename = ""; + e.race = 216; + e.gender = 0; + e.texture = 0; + e.mountspeed = 0.75; + e.notes = "Notes"; - return entry; + return e; } - static Horses GetHorsesEntry( + static Horses GetHorses( const std::vector &horsess, int horses_id ) @@ -136,17 +136,17 @@ public: auto row = results.begin(); if (results.RowCount() == 1) { - Horses entry{}; + Horses e{}; - entry.id = atoi(row[0]); - entry.filename = row[1] ? row[1] : ""; - entry.race = atoi(row[2]); - entry.gender = atoi(row[3]); - entry.texture = atoi(row[4]); - entry.mountspeed = static_cast(atof(row[5])); - entry.notes = row[6] ? row[6] : ""; + e.id = atoi(row[0]); + e.filename = row[1] ? row[1] : ""; + e.race = atoi(row[2]); + e.gender = atoi(row[3]); + e.texture = atoi(row[4]); + e.mountspeed = static_cast(atof(row[5])); + e.notes = row[6] ? row[6] : ""; - return entry; + return e; } return NewEntity(); @@ -171,27 +171,27 @@ public: static int UpdateOne( Database& db, - Horses horses_entry + const Horses &e ) { - std::vector update_values; + std::vector v; auto columns = Columns(); - update_values.push_back(columns[1] + " = '" + Strings::Escape(horses_entry.filename) + "'"); - update_values.push_back(columns[2] + " = " + std::to_string(horses_entry.race)); - update_values.push_back(columns[3] + " = " + std::to_string(horses_entry.gender)); - update_values.push_back(columns[4] + " = " + std::to_string(horses_entry.texture)); - update_values.push_back(columns[5] + " = " + std::to_string(horses_entry.mountspeed)); - update_values.push_back(columns[6] + " = '" + Strings::Escape(horses_entry.notes) + "'"); + v.push_back(columns[1] + " = '" + Strings::Escape(e.filename) + "'"); + v.push_back(columns[2] + " = " + std::to_string(e.race)); + v.push_back(columns[3] + " = " + std::to_string(e.gender)); + v.push_back(columns[4] + " = " + std::to_string(e.texture)); + v.push_back(columns[5] + " = " + std::to_string(e.mountspeed)); + v.push_back(columns[6] + " = '" + Strings::Escape(e.notes) + "'"); auto results = db.QueryDatabase( fmt::format( "UPDATE {} SET {} WHERE {} = {}", TableName(), - Strings::Implode(", ", update_values), + Strings::Implode(", ", v), PrimaryKey(), - horses_entry.id + e.id ) ); @@ -200,59 +200,59 @@ public: static Horses InsertOne( Database& db, - Horses horses_entry + Horses e ) { - std::vector insert_values; + std::vector v; - insert_values.push_back(std::to_string(horses_entry.id)); - insert_values.push_back("'" + Strings::Escape(horses_entry.filename) + "'"); - insert_values.push_back(std::to_string(horses_entry.race)); - insert_values.push_back(std::to_string(horses_entry.gender)); - insert_values.push_back(std::to_string(horses_entry.texture)); - insert_values.push_back(std::to_string(horses_entry.mountspeed)); - insert_values.push_back("'" + Strings::Escape(horses_entry.notes) + "'"); + v.push_back(std::to_string(e.id)); + v.push_back("'" + Strings::Escape(e.filename) + "'"); + v.push_back(std::to_string(e.race)); + v.push_back(std::to_string(e.gender)); + v.push_back(std::to_string(e.texture)); + v.push_back(std::to_string(e.mountspeed)); + v.push_back("'" + Strings::Escape(e.notes) + "'"); auto results = db.QueryDatabase( fmt::format( "{} VALUES ({})", BaseInsert(), - Strings::Implode(",", insert_values) + Strings::Implode(",", v) ) ); if (results.Success()) { - horses_entry.id = results.LastInsertedID(); - return horses_entry; + e.id = results.LastInsertedID(); + return e; } - horses_entry = NewEntity(); + e = NewEntity(); - return horses_entry; + return e; } static int InsertMany( Database& db, - std::vector horses_entries + const std::vector &entries ) { std::vector insert_chunks; - for (auto &horses_entry: horses_entries) { - std::vector insert_values; + for (auto &e: entries) { + std::vector v; - insert_values.push_back(std::to_string(horses_entry.id)); - insert_values.push_back("'" + Strings::Escape(horses_entry.filename) + "'"); - insert_values.push_back(std::to_string(horses_entry.race)); - insert_values.push_back(std::to_string(horses_entry.gender)); - insert_values.push_back(std::to_string(horses_entry.texture)); - insert_values.push_back(std::to_string(horses_entry.mountspeed)); - insert_values.push_back("'" + Strings::Escape(horses_entry.notes) + "'"); + v.push_back(std::to_string(e.id)); + v.push_back("'" + Strings::Escape(e.filename) + "'"); + v.push_back(std::to_string(e.race)); + v.push_back(std::to_string(e.gender)); + v.push_back(std::to_string(e.texture)); + v.push_back(std::to_string(e.mountspeed)); + v.push_back("'" + Strings::Escape(e.notes) + "'"); - insert_chunks.push_back("(" + Strings::Implode(",", insert_values) + ")"); + insert_chunks.push_back("(" + Strings::Implode(",", v) + ")"); } - std::vector insert_values; + std::vector v; auto results = db.QueryDatabase( fmt::format( @@ -279,23 +279,23 @@ public: all_entries.reserve(results.RowCount()); for (auto row = results.begin(); row != results.end(); ++row) { - Horses entry{}; + Horses e{}; - entry.id = atoi(row[0]); - entry.filename = row[1] ? row[1] : ""; - entry.race = atoi(row[2]); - entry.gender = atoi(row[3]); - entry.texture = atoi(row[4]); - entry.mountspeed = static_cast(atof(row[5])); - entry.notes = row[6] ? row[6] : ""; + e.id = atoi(row[0]); + e.filename = row[1] ? row[1] : ""; + e.race = atoi(row[2]); + e.gender = atoi(row[3]); + e.texture = atoi(row[4]); + e.mountspeed = static_cast(atof(row[5])); + e.notes = row[6] ? row[6] : ""; - all_entries.push_back(entry); + all_entries.push_back(e); } return all_entries; } - static std::vector GetWhere(Database& db, std::string where_filter) + static std::vector GetWhere(Database& db, const std::string &where_filter) { std::vector all_entries; @@ -310,23 +310,23 @@ public: all_entries.reserve(results.RowCount()); for (auto row = results.begin(); row != results.end(); ++row) { - Horses entry{}; + Horses e{}; - entry.id = atoi(row[0]); - entry.filename = row[1] ? row[1] : ""; - entry.race = atoi(row[2]); - entry.gender = atoi(row[3]); - entry.texture = atoi(row[4]); - entry.mountspeed = static_cast(atof(row[5])); - entry.notes = row[6] ? row[6] : ""; + e.id = atoi(row[0]); + e.filename = row[1] ? row[1] : ""; + e.race = atoi(row[2]); + e.gender = atoi(row[3]); + e.texture = atoi(row[4]); + e.mountspeed = static_cast(atof(row[5])); + e.notes = row[6] ? row[6] : ""; - all_entries.push_back(entry); + all_entries.push_back(e); } return all_entries; } - static int DeleteWhere(Database& db, std::string where_filter) + static int DeleteWhere(Database& db, const std::string &where_filter) { auto results = db.QueryDatabase( fmt::format( @@ -351,6 +351,32 @@ public: 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); + } + }; #endif //EQEMU_BASE_HORSES_REPOSITORY_H diff --git a/common/repositories/base/base_instance_list_player_repository.h b/common/repositories/base/base_instance_list_player_repository.h index 25cdb4dd8..f031312c2 100644 --- a/common/repositories/base/base_instance_list_player_repository.h +++ b/common/repositories/base/base_instance_list_player_repository.h @@ -79,15 +79,15 @@ public: static InstanceListPlayer NewEntity() { - InstanceListPlayer entry{}; + InstanceListPlayer e{}; - entry.id = 0; - entry.charid = 0; + e.id = 0; + e.charid = 0; - return entry; + return e; } - static InstanceListPlayer GetInstanceListPlayerEntry( + static InstanceListPlayer GetInstanceListPlayer( const std::vector &instance_list_players, int instance_list_player_id ) @@ -116,12 +116,12 @@ public: auto row = results.begin(); if (results.RowCount() == 1) { - InstanceListPlayer entry{}; + InstanceListPlayer e{}; - entry.id = atoi(row[0]); - entry.charid = atoi(row[1]); + e.id = atoi(row[0]); + e.charid = atoi(row[1]); - return entry; + return e; } return NewEntity(); @@ -146,23 +146,23 @@ public: static int UpdateOne( Database& db, - InstanceListPlayer instance_list_player_entry + const InstanceListPlayer &e ) { - std::vector update_values; + std::vector v; auto columns = Columns(); - update_values.push_back(columns[0] + " = " + std::to_string(instance_list_player_entry.id)); - update_values.push_back(columns[1] + " = " + std::to_string(instance_list_player_entry.charid)); + v.push_back(columns[0] + " = " + std::to_string(e.id)); + v.push_back(columns[1] + " = " + std::to_string(e.charid)); auto results = db.QueryDatabase( fmt::format( "UPDATE {} SET {} WHERE {} = {}", TableName(), - Strings::Implode(", ", update_values), + Strings::Implode(", ", v), PrimaryKey(), - instance_list_player_entry.id + e.id ) ); @@ -171,49 +171,49 @@ public: static InstanceListPlayer InsertOne( Database& db, - InstanceListPlayer instance_list_player_entry + InstanceListPlayer e ) { - std::vector insert_values; + std::vector v; - insert_values.push_back(std::to_string(instance_list_player_entry.id)); - insert_values.push_back(std::to_string(instance_list_player_entry.charid)); + v.push_back(std::to_string(e.id)); + v.push_back(std::to_string(e.charid)); auto results = db.QueryDatabase( fmt::format( "{} VALUES ({})", BaseInsert(), - Strings::Implode(",", insert_values) + Strings::Implode(",", v) ) ); if (results.Success()) { - instance_list_player_entry.id = results.LastInsertedID(); - return instance_list_player_entry; + e.id = results.LastInsertedID(); + return e; } - instance_list_player_entry = NewEntity(); + e = NewEntity(); - return instance_list_player_entry; + return e; } static int InsertMany( Database& db, - std::vector instance_list_player_entries + const std::vector &entries ) { std::vector insert_chunks; - for (auto &instance_list_player_entry: instance_list_player_entries) { - std::vector insert_values; + for (auto &e: entries) { + std::vector v; - insert_values.push_back(std::to_string(instance_list_player_entry.id)); - insert_values.push_back(std::to_string(instance_list_player_entry.charid)); + v.push_back(std::to_string(e.id)); + v.push_back(std::to_string(e.charid)); - insert_chunks.push_back("(" + Strings::Implode(",", insert_values) + ")"); + insert_chunks.push_back("(" + Strings::Implode(",", v) + ")"); } - std::vector insert_values; + std::vector v; auto results = db.QueryDatabase( fmt::format( @@ -240,18 +240,18 @@ public: all_entries.reserve(results.RowCount()); for (auto row = results.begin(); row != results.end(); ++row) { - InstanceListPlayer entry{}; + InstanceListPlayer e{}; - entry.id = atoi(row[0]); - entry.charid = atoi(row[1]); + e.id = atoi(row[0]); + e.charid = atoi(row[1]); - all_entries.push_back(entry); + all_entries.push_back(e); } return all_entries; } - static std::vector GetWhere(Database& db, std::string where_filter) + static std::vector GetWhere(Database& db, const std::string &where_filter) { std::vector all_entries; @@ -266,18 +266,18 @@ public: all_entries.reserve(results.RowCount()); for (auto row = results.begin(); row != results.end(); ++row) { - InstanceListPlayer entry{}; + InstanceListPlayer e{}; - entry.id = atoi(row[0]); - entry.charid = atoi(row[1]); + e.id = atoi(row[0]); + e.charid = atoi(row[1]); - all_entries.push_back(entry); + all_entries.push_back(e); } return all_entries; } - static int DeleteWhere(Database& db, std::string where_filter) + static int DeleteWhere(Database& db, const std::string &where_filter) { auto results = db.QueryDatabase( fmt::format( @@ -302,6 +302,32 @@ public: 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); + } + }; #endif //EQEMU_BASE_INSTANCE_LIST_PLAYER_REPOSITORY_H diff --git a/common/repositories/base/base_instance_list_repository.h b/common/repositories/base/base_instance_list_repository.h index 5399d822b..609b7e187 100644 --- a/common/repositories/base/base_instance_list_repository.h +++ b/common/repositories/base/base_instance_list_repository.h @@ -94,20 +94,20 @@ public: static InstanceList NewEntity() { - InstanceList entry{}; + InstanceList e{}; - entry.id = 0; - entry.zone = 0; - entry.version = 0; - entry.is_global = 0; - entry.start_time = 0; - entry.duration = 0; - entry.never_expires = 0; + e.id = 0; + e.zone = 0; + e.version = 0; + e.is_global = 0; + e.start_time = 0; + e.duration = 0; + e.never_expires = 0; - return entry; + return e; } - static InstanceList GetInstanceListEntry( + static InstanceList GetInstanceList( const std::vector &instance_lists, int instance_list_id ) @@ -136,17 +136,17 @@ public: auto row = results.begin(); if (results.RowCount() == 1) { - InstanceList entry{}; + InstanceList e{}; - entry.id = atoi(row[0]); - entry.zone = atoi(row[1]); - entry.version = atoi(row[2]); - entry.is_global = atoi(row[3]); - entry.start_time = atoi(row[4]); - entry.duration = atoi(row[5]); - entry.never_expires = atoi(row[6]); + e.id = atoi(row[0]); + e.zone = atoi(row[1]); + e.version = atoi(row[2]); + e.is_global = atoi(row[3]); + e.start_time = atoi(row[4]); + e.duration = atoi(row[5]); + e.never_expires = atoi(row[6]); - return entry; + return e; } return NewEntity(); @@ -171,27 +171,27 @@ public: static int UpdateOne( Database& db, - InstanceList instance_list_entry + const InstanceList &e ) { - std::vector update_values; + std::vector v; auto columns = Columns(); - update_values.push_back(columns[1] + " = " + std::to_string(instance_list_entry.zone)); - update_values.push_back(columns[2] + " = " + std::to_string(instance_list_entry.version)); - update_values.push_back(columns[3] + " = " + std::to_string(instance_list_entry.is_global)); - update_values.push_back(columns[4] + " = " + std::to_string(instance_list_entry.start_time)); - update_values.push_back(columns[5] + " = " + std::to_string(instance_list_entry.duration)); - update_values.push_back(columns[6] + " = " + std::to_string(instance_list_entry.never_expires)); + v.push_back(columns[1] + " = " + std::to_string(e.zone)); + v.push_back(columns[2] + " = " + std::to_string(e.version)); + v.push_back(columns[3] + " = " + std::to_string(e.is_global)); + v.push_back(columns[4] + " = " + std::to_string(e.start_time)); + v.push_back(columns[5] + " = " + std::to_string(e.duration)); + v.push_back(columns[6] + " = " + std::to_string(e.never_expires)); auto results = db.QueryDatabase( fmt::format( "UPDATE {} SET {} WHERE {} = {}", TableName(), - Strings::Implode(", ", update_values), + Strings::Implode(", ", v), PrimaryKey(), - instance_list_entry.id + e.id ) ); @@ -200,59 +200,59 @@ public: static InstanceList InsertOne( Database& db, - InstanceList instance_list_entry + InstanceList e ) { - std::vector insert_values; + std::vector v; - insert_values.push_back(std::to_string(instance_list_entry.id)); - insert_values.push_back(std::to_string(instance_list_entry.zone)); - insert_values.push_back(std::to_string(instance_list_entry.version)); - insert_values.push_back(std::to_string(instance_list_entry.is_global)); - insert_values.push_back(std::to_string(instance_list_entry.start_time)); - insert_values.push_back(std::to_string(instance_list_entry.duration)); - insert_values.push_back(std::to_string(instance_list_entry.never_expires)); + v.push_back(std::to_string(e.id)); + v.push_back(std::to_string(e.zone)); + v.push_back(std::to_string(e.version)); + v.push_back(std::to_string(e.is_global)); + v.push_back(std::to_string(e.start_time)); + v.push_back(std::to_string(e.duration)); + v.push_back(std::to_string(e.never_expires)); auto results = db.QueryDatabase( fmt::format( "{} VALUES ({})", BaseInsert(), - Strings::Implode(",", insert_values) + Strings::Implode(",", v) ) ); if (results.Success()) { - instance_list_entry.id = results.LastInsertedID(); - return instance_list_entry; + e.id = results.LastInsertedID(); + return e; } - instance_list_entry = NewEntity(); + e = NewEntity(); - return instance_list_entry; + return e; } static int InsertMany( Database& db, - std::vector instance_list_entries + const std::vector &entries ) { std::vector insert_chunks; - for (auto &instance_list_entry: instance_list_entries) { - std::vector insert_values; + for (auto &e: entries) { + std::vector v; - insert_values.push_back(std::to_string(instance_list_entry.id)); - insert_values.push_back(std::to_string(instance_list_entry.zone)); - insert_values.push_back(std::to_string(instance_list_entry.version)); - insert_values.push_back(std::to_string(instance_list_entry.is_global)); - insert_values.push_back(std::to_string(instance_list_entry.start_time)); - insert_values.push_back(std::to_string(instance_list_entry.duration)); - insert_values.push_back(std::to_string(instance_list_entry.never_expires)); + v.push_back(std::to_string(e.id)); + v.push_back(std::to_string(e.zone)); + v.push_back(std::to_string(e.version)); + v.push_back(std::to_string(e.is_global)); + v.push_back(std::to_string(e.start_time)); + v.push_back(std::to_string(e.duration)); + v.push_back(std::to_string(e.never_expires)); - insert_chunks.push_back("(" + Strings::Implode(",", insert_values) + ")"); + insert_chunks.push_back("(" + Strings::Implode(",", v) + ")"); } - std::vector insert_values; + std::vector v; auto results = db.QueryDatabase( fmt::format( @@ -279,23 +279,23 @@ public: all_entries.reserve(results.RowCount()); for (auto row = results.begin(); row != results.end(); ++row) { - InstanceList entry{}; + InstanceList e{}; - entry.id = atoi(row[0]); - entry.zone = atoi(row[1]); - entry.version = atoi(row[2]); - entry.is_global = atoi(row[3]); - entry.start_time = atoi(row[4]); - entry.duration = atoi(row[5]); - entry.never_expires = atoi(row[6]); + e.id = atoi(row[0]); + e.zone = atoi(row[1]); + e.version = atoi(row[2]); + e.is_global = atoi(row[3]); + e.start_time = atoi(row[4]); + e.duration = atoi(row[5]); + e.never_expires = atoi(row[6]); - all_entries.push_back(entry); + all_entries.push_back(e); } return all_entries; } - static std::vector GetWhere(Database& db, std::string where_filter) + static std::vector GetWhere(Database& db, const std::string &where_filter) { std::vector all_entries; @@ -310,23 +310,23 @@ public: all_entries.reserve(results.RowCount()); for (auto row = results.begin(); row != results.end(); ++row) { - InstanceList entry{}; + InstanceList e{}; - entry.id = atoi(row[0]); - entry.zone = atoi(row[1]); - entry.version = atoi(row[2]); - entry.is_global = atoi(row[3]); - entry.start_time = atoi(row[4]); - entry.duration = atoi(row[5]); - entry.never_expires = atoi(row[6]); + e.id = atoi(row[0]); + e.zone = atoi(row[1]); + e.version = atoi(row[2]); + e.is_global = atoi(row[3]); + e.start_time = atoi(row[4]); + e.duration = atoi(row[5]); + e.never_expires = atoi(row[6]); - all_entries.push_back(entry); + all_entries.push_back(e); } return all_entries; } - static int DeleteWhere(Database& db, std::string where_filter) + static int DeleteWhere(Database& db, const std::string &where_filter) { auto results = db.QueryDatabase( fmt::format( @@ -351,6 +351,32 @@ public: 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); + } + }; #endif //EQEMU_BASE_INSTANCE_LIST_REPOSITORY_H diff --git a/common/repositories/base/base_inventory_repository.h b/common/repositories/base/base_inventory_repository.h index 122c818aa..7086e0d72 100644 --- a/common/repositories/base/base_inventory_repository.h +++ b/common/repositories/base/base_inventory_repository.h @@ -121,29 +121,29 @@ public: static Inventory NewEntity() { - Inventory entry{}; + Inventory e{}; - entry.charid = 0; - entry.slotid = 0; - entry.itemid = 0; - entry.charges = 0; - entry.color = 0; - entry.augslot1 = 0; - entry.augslot2 = 0; - entry.augslot3 = 0; - entry.augslot4 = 0; - entry.augslot5 = 0; - entry.augslot6 = 0; - entry.instnodrop = 0; - entry.custom_data = ""; - entry.ornamenticon = 0; - entry.ornamentidfile = 0; - entry.ornament_hero_model = 0; + e.charid = 0; + e.slotid = 0; + e.itemid = 0; + e.charges = 0; + e.color = 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.ornamenticon = 0; + e.ornamentidfile = 0; + e.ornament_hero_model = 0; - return entry; + return e; } - static Inventory GetInventoryEntry( + static Inventory GetInventory( const std::vector &inventorys, int inventory_id ) @@ -172,26 +172,26 @@ public: auto row = results.begin(); if (results.RowCount() == 1) { - Inventory entry{}; + Inventory e{}; - entry.charid = atoi(row[0]); - entry.slotid = atoi(row[1]); - entry.itemid = atoi(row[2]); - entry.charges = atoi(row[3]); - entry.color = atoi(row[4]); - entry.augslot1 = atoi(row[5]); - entry.augslot2 = atoi(row[6]); - entry.augslot3 = atoi(row[7]); - entry.augslot4 = atoi(row[8]); - entry.augslot5 = atoi(row[9]); - entry.augslot6 = atoi(row[10]); - entry.instnodrop = atoi(row[11]); - entry.custom_data = row[12] ? row[12] : ""; - entry.ornamenticon = atoi(row[13]); - entry.ornamentidfile = atoi(row[14]); - entry.ornament_hero_model = atoi(row[15]); + e.charid = atoi(row[0]); + e.slotid = atoi(row[1]); + e.itemid = atoi(row[2]); + e.charges = atoi(row[3]); + e.color = atoi(row[4]); + e.augslot1 = atoi(row[5]); + e.augslot2 = atoi(row[6]); + e.augslot3 = atoi(row[7]); + e.augslot4 = atoi(row[8]); + e.augslot5 = atoi(row[9]); + e.augslot6 = atoi(row[10]); + e.instnodrop = atoi(row[11]); + e.custom_data = row[12] ? row[12] : ""; + e.ornamenticon = atoi(row[13]); + e.ornamentidfile = atoi(row[14]); + e.ornament_hero_model = atoi(row[15]); - return entry; + return e; } return NewEntity(); @@ -216,37 +216,37 @@ public: static int UpdateOne( Database& db, - Inventory inventory_entry + const Inventory &e ) { - std::vector update_values; + std::vector v; auto columns = Columns(); - update_values.push_back(columns[0] + " = " + std::to_string(inventory_entry.charid)); - update_values.push_back(columns[1] + " = " + std::to_string(inventory_entry.slotid)); - update_values.push_back(columns[2] + " = " + std::to_string(inventory_entry.itemid)); - update_values.push_back(columns[3] + " = " + std::to_string(inventory_entry.charges)); - update_values.push_back(columns[4] + " = " + std::to_string(inventory_entry.color)); - update_values.push_back(columns[5] + " = " + std::to_string(inventory_entry.augslot1)); - update_values.push_back(columns[6] + " = " + std::to_string(inventory_entry.augslot2)); - update_values.push_back(columns[7] + " = " + std::to_string(inventory_entry.augslot3)); - update_values.push_back(columns[8] + " = " + std::to_string(inventory_entry.augslot4)); - update_values.push_back(columns[9] + " = " + std::to_string(inventory_entry.augslot5)); - update_values.push_back(columns[10] + " = " + std::to_string(inventory_entry.augslot6)); - update_values.push_back(columns[11] + " = " + std::to_string(inventory_entry.instnodrop)); - update_values.push_back(columns[12] + " = '" + Strings::Escape(inventory_entry.custom_data) + "'"); - update_values.push_back(columns[13] + " = " + std::to_string(inventory_entry.ornamenticon)); - update_values.push_back(columns[14] + " = " + std::to_string(inventory_entry.ornamentidfile)); - update_values.push_back(columns[15] + " = " + std::to_string(inventory_entry.ornament_hero_model)); + 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.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.ornamenticon)); + v.push_back(columns[14] + " = " + std::to_string(e.ornamentidfile)); + v.push_back(columns[15] + " = " + std::to_string(e.ornament_hero_model)); auto results = db.QueryDatabase( fmt::format( "UPDATE {} SET {} WHERE {} = {}", TableName(), - Strings::Implode(", ", update_values), + Strings::Implode(", ", v), PrimaryKey(), - inventory_entry.charid + e.charid ) ); @@ -255,77 +255,77 @@ public: static Inventory InsertOne( Database& db, - Inventory inventory_entry + Inventory e ) { - std::vector insert_values; + std::vector v; - insert_values.push_back(std::to_string(inventory_entry.charid)); - insert_values.push_back(std::to_string(inventory_entry.slotid)); - insert_values.push_back(std::to_string(inventory_entry.itemid)); - insert_values.push_back(std::to_string(inventory_entry.charges)); - insert_values.push_back(std::to_string(inventory_entry.color)); - insert_values.push_back(std::to_string(inventory_entry.augslot1)); - insert_values.push_back(std::to_string(inventory_entry.augslot2)); - insert_values.push_back(std::to_string(inventory_entry.augslot3)); - insert_values.push_back(std::to_string(inventory_entry.augslot4)); - insert_values.push_back(std::to_string(inventory_entry.augslot5)); - insert_values.push_back(std::to_string(inventory_entry.augslot6)); - insert_values.push_back(std::to_string(inventory_entry.instnodrop)); - insert_values.push_back("'" + Strings::Escape(inventory_entry.custom_data) + "'"); - insert_values.push_back(std::to_string(inventory_entry.ornamenticon)); - insert_values.push_back(std::to_string(inventory_entry.ornamentidfile)); - insert_values.push_back(std::to_string(inventory_entry.ornament_hero_model)); + 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.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.ornamenticon)); + v.push_back(std::to_string(e.ornamentidfile)); + v.push_back(std::to_string(e.ornament_hero_model)); auto results = db.QueryDatabase( fmt::format( "{} VALUES ({})", BaseInsert(), - Strings::Implode(",", insert_values) + Strings::Implode(",", v) ) ); if (results.Success()) { - inventory_entry.charid = results.LastInsertedID(); - return inventory_entry; + e.charid = results.LastInsertedID(); + return e; } - inventory_entry = NewEntity(); + e = NewEntity(); - return inventory_entry; + return e; } static int InsertMany( Database& db, - std::vector inventory_entries + const std::vector &entries ) { std::vector insert_chunks; - for (auto &inventory_entry: inventory_entries) { - std::vector insert_values; + for (auto &e: entries) { + std::vector v; - insert_values.push_back(std::to_string(inventory_entry.charid)); - insert_values.push_back(std::to_string(inventory_entry.slotid)); - insert_values.push_back(std::to_string(inventory_entry.itemid)); - insert_values.push_back(std::to_string(inventory_entry.charges)); - insert_values.push_back(std::to_string(inventory_entry.color)); - insert_values.push_back(std::to_string(inventory_entry.augslot1)); - insert_values.push_back(std::to_string(inventory_entry.augslot2)); - insert_values.push_back(std::to_string(inventory_entry.augslot3)); - insert_values.push_back(std::to_string(inventory_entry.augslot4)); - insert_values.push_back(std::to_string(inventory_entry.augslot5)); - insert_values.push_back(std::to_string(inventory_entry.augslot6)); - insert_values.push_back(std::to_string(inventory_entry.instnodrop)); - insert_values.push_back("'" + Strings::Escape(inventory_entry.custom_data) + "'"); - insert_values.push_back(std::to_string(inventory_entry.ornamenticon)); - insert_values.push_back(std::to_string(inventory_entry.ornamentidfile)); - insert_values.push_back(std::to_string(inventory_entry.ornament_hero_model)); + 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.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.ornamenticon)); + v.push_back(std::to_string(e.ornamentidfile)); + v.push_back(std::to_string(e.ornament_hero_model)); - insert_chunks.push_back("(" + Strings::Implode(",", insert_values) + ")"); + insert_chunks.push_back("(" + Strings::Implode(",", v) + ")"); } - std::vector insert_values; + std::vector v; auto results = db.QueryDatabase( fmt::format( @@ -352,32 +352,32 @@ public: all_entries.reserve(results.RowCount()); for (auto row = results.begin(); row != results.end(); ++row) { - Inventory entry{}; + Inventory e{}; - entry.charid = atoi(row[0]); - entry.slotid = atoi(row[1]); - entry.itemid = atoi(row[2]); - entry.charges = atoi(row[3]); - entry.color = atoi(row[4]); - entry.augslot1 = atoi(row[5]); - entry.augslot2 = atoi(row[6]); - entry.augslot3 = atoi(row[7]); - entry.augslot4 = atoi(row[8]); - entry.augslot5 = atoi(row[9]); - entry.augslot6 = atoi(row[10]); - entry.instnodrop = atoi(row[11]); - entry.custom_data = row[12] ? row[12] : ""; - entry.ornamenticon = atoi(row[13]); - entry.ornamentidfile = atoi(row[14]); - entry.ornament_hero_model = atoi(row[15]); + e.charid = atoi(row[0]); + e.slotid = atoi(row[1]); + e.itemid = atoi(row[2]); + e.charges = atoi(row[3]); + e.color = atoi(row[4]); + e.augslot1 = atoi(row[5]); + e.augslot2 = atoi(row[6]); + e.augslot3 = atoi(row[7]); + e.augslot4 = atoi(row[8]); + e.augslot5 = atoi(row[9]); + e.augslot6 = atoi(row[10]); + e.instnodrop = atoi(row[11]); + e.custom_data = row[12] ? row[12] : ""; + e.ornamenticon = atoi(row[13]); + e.ornamentidfile = atoi(row[14]); + e.ornament_hero_model = atoi(row[15]); - all_entries.push_back(entry); + all_entries.push_back(e); } return all_entries; } - static std::vector GetWhere(Database& db, std::string where_filter) + static std::vector GetWhere(Database& db, const std::string &where_filter) { std::vector all_entries; @@ -392,32 +392,32 @@ public: all_entries.reserve(results.RowCount()); for (auto row = results.begin(); row != results.end(); ++row) { - Inventory entry{}; + Inventory e{}; - entry.charid = atoi(row[0]); - entry.slotid = atoi(row[1]); - entry.itemid = atoi(row[2]); - entry.charges = atoi(row[3]); - entry.color = atoi(row[4]); - entry.augslot1 = atoi(row[5]); - entry.augslot2 = atoi(row[6]); - entry.augslot3 = atoi(row[7]); - entry.augslot4 = atoi(row[8]); - entry.augslot5 = atoi(row[9]); - entry.augslot6 = atoi(row[10]); - entry.instnodrop = atoi(row[11]); - entry.custom_data = row[12] ? row[12] : ""; - entry.ornamenticon = atoi(row[13]); - entry.ornamentidfile = atoi(row[14]); - entry.ornament_hero_model = atoi(row[15]); + e.charid = atoi(row[0]); + e.slotid = atoi(row[1]); + e.itemid = atoi(row[2]); + e.charges = atoi(row[3]); + e.color = atoi(row[4]); + e.augslot1 = atoi(row[5]); + e.augslot2 = atoi(row[6]); + e.augslot3 = atoi(row[7]); + e.augslot4 = atoi(row[8]); + e.augslot5 = atoi(row[9]); + e.augslot6 = atoi(row[10]); + e.instnodrop = atoi(row[11]); + e.custom_data = row[12] ? row[12] : ""; + e.ornamenticon = atoi(row[13]); + e.ornamentidfile = atoi(row[14]); + e.ornament_hero_model = atoi(row[15]); - all_entries.push_back(entry); + all_entries.push_back(e); } return all_entries; } - static int DeleteWhere(Database& db, std::string where_filter) + static int DeleteWhere(Database& db, const std::string &where_filter) { auto results = db.QueryDatabase( fmt::format( @@ -442,6 +442,32 @@ public: 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); + } + }; #endif //EQEMU_BASE_INVENTORY_REPOSITORY_H diff --git a/common/repositories/base/base_inventory_snapshots_repository.h b/common/repositories/base/base_inventory_snapshots_repository.h index 3171fda7d..66d9c6932 100644 --- a/common/repositories/base/base_inventory_snapshots_repository.h +++ b/common/repositories/base/base_inventory_snapshots_repository.h @@ -124,30 +124,30 @@ public: static InventorySnapshots NewEntity() { - InventorySnapshots entry{}; + InventorySnapshots e{}; - entry.time_index = 0; - entry.charid = 0; - entry.slotid = 0; - entry.itemid = 0; - entry.charges = 0; - entry.color = 0; - entry.augslot1 = 0; - entry.augslot2 = 0; - entry.augslot3 = 0; - entry.augslot4 = 0; - entry.augslot5 = 0; - entry.augslot6 = 0; - entry.instnodrop = 0; - entry.custom_data = ""; - entry.ornamenticon = 0; - entry.ornamentidfile = 0; - entry.ornament_hero_model = 0; + e.time_index = 0; + e.charid = 0; + e.slotid = 0; + e.itemid = 0; + e.charges = 0; + e.color = 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.ornamenticon = 0; + e.ornamentidfile = 0; + e.ornament_hero_model = 0; - return entry; + return e; } - static InventorySnapshots GetInventorySnapshotsEntry( + static InventorySnapshots GetInventorySnapshots( const std::vector &inventory_snapshotss, int inventory_snapshots_id ) @@ -176,27 +176,27 @@ public: auto row = results.begin(); if (results.RowCount() == 1) { - InventorySnapshots entry{}; + InventorySnapshots e{}; - entry.time_index = atoi(row[0]); - entry.charid = atoi(row[1]); - entry.slotid = atoi(row[2]); - entry.itemid = atoi(row[3]); - entry.charges = atoi(row[4]); - entry.color = atoi(row[5]); - entry.augslot1 = atoi(row[6]); - entry.augslot2 = atoi(row[7]); - entry.augslot3 = atoi(row[8]); - entry.augslot4 = atoi(row[9]); - entry.augslot5 = atoi(row[10]); - entry.augslot6 = atoi(row[11]); - entry.instnodrop = atoi(row[12]); - entry.custom_data = row[13] ? row[13] : ""; - entry.ornamenticon = atoi(row[14]); - entry.ornamentidfile = atoi(row[15]); - entry.ornament_hero_model = atoi(row[16]); + e.time_index = atoi(row[0]); + e.charid = atoi(row[1]); + e.slotid = atoi(row[2]); + e.itemid = atoi(row[3]); + e.charges = atoi(row[4]); + e.color = atoi(row[5]); + e.augslot1 = atoi(row[6]); + e.augslot2 = atoi(row[7]); + e.augslot3 = atoi(row[8]); + e.augslot4 = atoi(row[9]); + e.augslot5 = atoi(row[10]); + e.augslot6 = atoi(row[11]); + e.instnodrop = atoi(row[12]); + e.custom_data = row[13] ? row[13] : ""; + e.ornamenticon = atoi(row[14]); + e.ornamentidfile = atoi(row[15]); + e.ornament_hero_model = atoi(row[16]); - return entry; + return e; } return NewEntity(); @@ -221,38 +221,38 @@ public: static int UpdateOne( Database& db, - InventorySnapshots inventory_snapshots_entry + const InventorySnapshots &e ) { - std::vector update_values; + std::vector v; auto columns = Columns(); - update_values.push_back(columns[0] + " = " + std::to_string(inventory_snapshots_entry.time_index)); - update_values.push_back(columns[1] + " = " + std::to_string(inventory_snapshots_entry.charid)); - update_values.push_back(columns[2] + " = " + std::to_string(inventory_snapshots_entry.slotid)); - update_values.push_back(columns[3] + " = " + std::to_string(inventory_snapshots_entry.itemid)); - update_values.push_back(columns[4] + " = " + std::to_string(inventory_snapshots_entry.charges)); - update_values.push_back(columns[5] + " = " + std::to_string(inventory_snapshots_entry.color)); - update_values.push_back(columns[6] + " = " + std::to_string(inventory_snapshots_entry.augslot1)); - update_values.push_back(columns[7] + " = " + std::to_string(inventory_snapshots_entry.augslot2)); - update_values.push_back(columns[8] + " = " + std::to_string(inventory_snapshots_entry.augslot3)); - update_values.push_back(columns[9] + " = " + std::to_string(inventory_snapshots_entry.augslot4)); - update_values.push_back(columns[10] + " = " + std::to_string(inventory_snapshots_entry.augslot5)); - update_values.push_back(columns[11] + " = " + std::to_string(inventory_snapshots_entry.augslot6)); - update_values.push_back(columns[12] + " = " + std::to_string(inventory_snapshots_entry.instnodrop)); - update_values.push_back(columns[13] + " = '" + Strings::Escape(inventory_snapshots_entry.custom_data) + "'"); - update_values.push_back(columns[14] + " = " + std::to_string(inventory_snapshots_entry.ornamenticon)); - update_values.push_back(columns[15] + " = " + std::to_string(inventory_snapshots_entry.ornamentidfile)); - update_values.push_back(columns[16] + " = " + std::to_string(inventory_snapshots_entry.ornament_hero_model)); + v.push_back(columns[0] + " = " + std::to_string(e.time_index)); + v.push_back(columns[1] + " = " + std::to_string(e.charid)); + v.push_back(columns[2] + " = " + std::to_string(e.slotid)); + v.push_back(columns[3] + " = " + std::to_string(e.itemid)); + v.push_back(columns[4] + " = " + std::to_string(e.charges)); + v.push_back(columns[5] + " = " + std::to_string(e.color)); + v.push_back(columns[6] + " = " + std::to_string(e.augslot1)); + v.push_back(columns[7] + " = " + std::to_string(e.augslot2)); + v.push_back(columns[8] + " = " + std::to_string(e.augslot3)); + v.push_back(columns[9] + " = " + std::to_string(e.augslot4)); + v.push_back(columns[10] + " = " + std::to_string(e.augslot5)); + v.push_back(columns[11] + " = " + std::to_string(e.augslot6)); + v.push_back(columns[12] + " = " + std::to_string(e.instnodrop)); + v.push_back(columns[13] + " = '" + Strings::Escape(e.custom_data) + "'"); + v.push_back(columns[14] + " = " + std::to_string(e.ornamenticon)); + v.push_back(columns[15] + " = " + std::to_string(e.ornamentidfile)); + v.push_back(columns[16] + " = " + std::to_string(e.ornament_hero_model)); auto results = db.QueryDatabase( fmt::format( "UPDATE {} SET {} WHERE {} = {}", TableName(), - Strings::Implode(", ", update_values), + Strings::Implode(", ", v), PrimaryKey(), - inventory_snapshots_entry.time_index + e.time_index ) ); @@ -261,79 +261,79 @@ public: static InventorySnapshots InsertOne( Database& db, - InventorySnapshots inventory_snapshots_entry + InventorySnapshots e ) { - std::vector insert_values; + std::vector v; - insert_values.push_back(std::to_string(inventory_snapshots_entry.time_index)); - insert_values.push_back(std::to_string(inventory_snapshots_entry.charid)); - insert_values.push_back(std::to_string(inventory_snapshots_entry.slotid)); - insert_values.push_back(std::to_string(inventory_snapshots_entry.itemid)); - insert_values.push_back(std::to_string(inventory_snapshots_entry.charges)); - insert_values.push_back(std::to_string(inventory_snapshots_entry.color)); - insert_values.push_back(std::to_string(inventory_snapshots_entry.augslot1)); - insert_values.push_back(std::to_string(inventory_snapshots_entry.augslot2)); - insert_values.push_back(std::to_string(inventory_snapshots_entry.augslot3)); - insert_values.push_back(std::to_string(inventory_snapshots_entry.augslot4)); - insert_values.push_back(std::to_string(inventory_snapshots_entry.augslot5)); - insert_values.push_back(std::to_string(inventory_snapshots_entry.augslot6)); - insert_values.push_back(std::to_string(inventory_snapshots_entry.instnodrop)); - insert_values.push_back("'" + Strings::Escape(inventory_snapshots_entry.custom_data) + "'"); - insert_values.push_back(std::to_string(inventory_snapshots_entry.ornamenticon)); - insert_values.push_back(std::to_string(inventory_snapshots_entry.ornamentidfile)); - insert_values.push_back(std::to_string(inventory_snapshots_entry.ornament_hero_model)); + v.push_back(std::to_string(e.time_index)); + 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.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.ornamenticon)); + v.push_back(std::to_string(e.ornamentidfile)); + v.push_back(std::to_string(e.ornament_hero_model)); auto results = db.QueryDatabase( fmt::format( "{} VALUES ({})", BaseInsert(), - Strings::Implode(",", insert_values) + Strings::Implode(",", v) ) ); if (results.Success()) { - inventory_snapshots_entry.time_index = results.LastInsertedID(); - return inventory_snapshots_entry; + e.time_index = results.LastInsertedID(); + return e; } - inventory_snapshots_entry = NewEntity(); + e = NewEntity(); - return inventory_snapshots_entry; + return e; } static int InsertMany( Database& db, - std::vector inventory_snapshots_entries + const std::vector &entries ) { std::vector insert_chunks; - for (auto &inventory_snapshots_entry: inventory_snapshots_entries) { - std::vector insert_values; + for (auto &e: entries) { + std::vector v; - insert_values.push_back(std::to_string(inventory_snapshots_entry.time_index)); - insert_values.push_back(std::to_string(inventory_snapshots_entry.charid)); - insert_values.push_back(std::to_string(inventory_snapshots_entry.slotid)); - insert_values.push_back(std::to_string(inventory_snapshots_entry.itemid)); - insert_values.push_back(std::to_string(inventory_snapshots_entry.charges)); - insert_values.push_back(std::to_string(inventory_snapshots_entry.color)); - insert_values.push_back(std::to_string(inventory_snapshots_entry.augslot1)); - insert_values.push_back(std::to_string(inventory_snapshots_entry.augslot2)); - insert_values.push_back(std::to_string(inventory_snapshots_entry.augslot3)); - insert_values.push_back(std::to_string(inventory_snapshots_entry.augslot4)); - insert_values.push_back(std::to_string(inventory_snapshots_entry.augslot5)); - insert_values.push_back(std::to_string(inventory_snapshots_entry.augslot6)); - insert_values.push_back(std::to_string(inventory_snapshots_entry.instnodrop)); - insert_values.push_back("'" + Strings::Escape(inventory_snapshots_entry.custom_data) + "'"); - insert_values.push_back(std::to_string(inventory_snapshots_entry.ornamenticon)); - insert_values.push_back(std::to_string(inventory_snapshots_entry.ornamentidfile)); - insert_values.push_back(std::to_string(inventory_snapshots_entry.ornament_hero_model)); + v.push_back(std::to_string(e.time_index)); + 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.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.ornamenticon)); + v.push_back(std::to_string(e.ornamentidfile)); + v.push_back(std::to_string(e.ornament_hero_model)); - insert_chunks.push_back("(" + Strings::Implode(",", insert_values) + ")"); + insert_chunks.push_back("(" + Strings::Implode(",", v) + ")"); } - std::vector insert_values; + std::vector v; auto results = db.QueryDatabase( fmt::format( @@ -360,33 +360,33 @@ public: all_entries.reserve(results.RowCount()); for (auto row = results.begin(); row != results.end(); ++row) { - InventorySnapshots entry{}; + InventorySnapshots e{}; - entry.time_index = atoi(row[0]); - entry.charid = atoi(row[1]); - entry.slotid = atoi(row[2]); - entry.itemid = atoi(row[3]); - entry.charges = atoi(row[4]); - entry.color = atoi(row[5]); - entry.augslot1 = atoi(row[6]); - entry.augslot2 = atoi(row[7]); - entry.augslot3 = atoi(row[8]); - entry.augslot4 = atoi(row[9]); - entry.augslot5 = atoi(row[10]); - entry.augslot6 = atoi(row[11]); - entry.instnodrop = atoi(row[12]); - entry.custom_data = row[13] ? row[13] : ""; - entry.ornamenticon = atoi(row[14]); - entry.ornamentidfile = atoi(row[15]); - entry.ornament_hero_model = atoi(row[16]); + e.time_index = atoi(row[0]); + e.charid = atoi(row[1]); + e.slotid = atoi(row[2]); + e.itemid = atoi(row[3]); + e.charges = atoi(row[4]); + e.color = atoi(row[5]); + e.augslot1 = atoi(row[6]); + e.augslot2 = atoi(row[7]); + e.augslot3 = atoi(row[8]); + e.augslot4 = atoi(row[9]); + e.augslot5 = atoi(row[10]); + e.augslot6 = atoi(row[11]); + e.instnodrop = atoi(row[12]); + e.custom_data = row[13] ? row[13] : ""; + e.ornamenticon = atoi(row[14]); + e.ornamentidfile = atoi(row[15]); + e.ornament_hero_model = atoi(row[16]); - all_entries.push_back(entry); + all_entries.push_back(e); } return all_entries; } - static std::vector GetWhere(Database& db, std::string where_filter) + static std::vector GetWhere(Database& db, const std::string &where_filter) { std::vector all_entries; @@ -401,33 +401,33 @@ public: all_entries.reserve(results.RowCount()); for (auto row = results.begin(); row != results.end(); ++row) { - InventorySnapshots entry{}; + InventorySnapshots e{}; - entry.time_index = atoi(row[0]); - entry.charid = atoi(row[1]); - entry.slotid = atoi(row[2]); - entry.itemid = atoi(row[3]); - entry.charges = atoi(row[4]); - entry.color = atoi(row[5]); - entry.augslot1 = atoi(row[6]); - entry.augslot2 = atoi(row[7]); - entry.augslot3 = atoi(row[8]); - entry.augslot4 = atoi(row[9]); - entry.augslot5 = atoi(row[10]); - entry.augslot6 = atoi(row[11]); - entry.instnodrop = atoi(row[12]); - entry.custom_data = row[13] ? row[13] : ""; - entry.ornamenticon = atoi(row[14]); - entry.ornamentidfile = atoi(row[15]); - entry.ornament_hero_model = atoi(row[16]); + e.time_index = atoi(row[0]); + e.charid = atoi(row[1]); + e.slotid = atoi(row[2]); + e.itemid = atoi(row[3]); + e.charges = atoi(row[4]); + e.color = atoi(row[5]); + e.augslot1 = atoi(row[6]); + e.augslot2 = atoi(row[7]); + e.augslot3 = atoi(row[8]); + e.augslot4 = atoi(row[9]); + e.augslot5 = atoi(row[10]); + e.augslot6 = atoi(row[11]); + e.instnodrop = atoi(row[12]); + e.custom_data = row[13] ? row[13] : ""; + e.ornamenticon = atoi(row[14]); + e.ornamentidfile = atoi(row[15]); + e.ornament_hero_model = atoi(row[16]); - all_entries.push_back(entry); + all_entries.push_back(e); } return all_entries; } - static int DeleteWhere(Database& db, std::string where_filter) + static int DeleteWhere(Database& db, const std::string &where_filter) { auto results = db.QueryDatabase( fmt::format( @@ -452,6 +452,32 @@ public: 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); + } + }; #endif //EQEMU_BASE_INVENTORY_SNAPSHOTS_REPOSITORY_H diff --git a/common/repositories/base/base_ip_exemptions_repository.h b/common/repositories/base/base_ip_exemptions_repository.h index 424620b4a..e7f4f1dc7 100644 --- a/common/repositories/base/base_ip_exemptions_repository.h +++ b/common/repositories/base/base_ip_exemptions_repository.h @@ -82,16 +82,16 @@ public: static IpExemptions NewEntity() { - IpExemptions entry{}; + IpExemptions e{}; - entry.exemption_id = 0; - entry.exemption_ip = ""; - entry.exemption_amount = 0; + e.exemption_id = 0; + e.exemption_ip = ""; + e.exemption_amount = 0; - return entry; + return e; } - static IpExemptions GetIpExemptionsEntry( + static IpExemptions GetIpExemptions( const std::vector &ip_exemptionss, int ip_exemptions_id ) @@ -120,13 +120,13 @@ public: auto row = results.begin(); if (results.RowCount() == 1) { - IpExemptions entry{}; + IpExemptions e{}; - entry.exemption_id = atoi(row[0]); - entry.exemption_ip = row[1] ? row[1] : ""; - entry.exemption_amount = atoi(row[2]); + e.exemption_id = atoi(row[0]); + e.exemption_ip = row[1] ? row[1] : ""; + e.exemption_amount = atoi(row[2]); - return entry; + return e; } return NewEntity(); @@ -151,23 +151,23 @@ public: static int UpdateOne( Database& db, - IpExemptions ip_exemptions_entry + const IpExemptions &e ) { - std::vector update_values; + std::vector v; auto columns = Columns(); - update_values.push_back(columns[1] + " = '" + Strings::Escape(ip_exemptions_entry.exemption_ip) + "'"); - update_values.push_back(columns[2] + " = " + std::to_string(ip_exemptions_entry.exemption_amount)); + v.push_back(columns[1] + " = '" + Strings::Escape(e.exemption_ip) + "'"); + v.push_back(columns[2] + " = " + std::to_string(e.exemption_amount)); auto results = db.QueryDatabase( fmt::format( "UPDATE {} SET {} WHERE {} = {}", TableName(), - Strings::Implode(", ", update_values), + Strings::Implode(", ", v), PrimaryKey(), - ip_exemptions_entry.exemption_id + e.exemption_id ) ); @@ -176,51 +176,51 @@ public: static IpExemptions InsertOne( Database& db, - IpExemptions ip_exemptions_entry + IpExemptions e ) { - std::vector insert_values; + std::vector v; - insert_values.push_back(std::to_string(ip_exemptions_entry.exemption_id)); - insert_values.push_back("'" + Strings::Escape(ip_exemptions_entry.exemption_ip) + "'"); - insert_values.push_back(std::to_string(ip_exemptions_entry.exemption_amount)); + v.push_back(std::to_string(e.exemption_id)); + v.push_back("'" + Strings::Escape(e.exemption_ip) + "'"); + v.push_back(std::to_string(e.exemption_amount)); auto results = db.QueryDatabase( fmt::format( "{} VALUES ({})", BaseInsert(), - Strings::Implode(",", insert_values) + Strings::Implode(",", v) ) ); if (results.Success()) { - ip_exemptions_entry.exemption_id = results.LastInsertedID(); - return ip_exemptions_entry; + e.exemption_id = results.LastInsertedID(); + return e; } - ip_exemptions_entry = NewEntity(); + e = NewEntity(); - return ip_exemptions_entry; + return e; } static int InsertMany( Database& db, - std::vector ip_exemptions_entries + const std::vector &entries ) { std::vector insert_chunks; - for (auto &ip_exemptions_entry: ip_exemptions_entries) { - std::vector insert_values; + for (auto &e: entries) { + std::vector v; - insert_values.push_back(std::to_string(ip_exemptions_entry.exemption_id)); - insert_values.push_back("'" + Strings::Escape(ip_exemptions_entry.exemption_ip) + "'"); - insert_values.push_back(std::to_string(ip_exemptions_entry.exemption_amount)); + v.push_back(std::to_string(e.exemption_id)); + v.push_back("'" + Strings::Escape(e.exemption_ip) + "'"); + v.push_back(std::to_string(e.exemption_amount)); - insert_chunks.push_back("(" + Strings::Implode(",", insert_values) + ")"); + insert_chunks.push_back("(" + Strings::Implode(",", v) + ")"); } - std::vector insert_values; + std::vector v; auto results = db.QueryDatabase( fmt::format( @@ -247,19 +247,19 @@ public: all_entries.reserve(results.RowCount()); for (auto row = results.begin(); row != results.end(); ++row) { - IpExemptions entry{}; + IpExemptions e{}; - entry.exemption_id = atoi(row[0]); - entry.exemption_ip = row[1] ? row[1] : ""; - entry.exemption_amount = atoi(row[2]); + e.exemption_id = atoi(row[0]); + e.exemption_ip = row[1] ? row[1] : ""; + e.exemption_amount = atoi(row[2]); - all_entries.push_back(entry); + all_entries.push_back(e); } return all_entries; } - static std::vector GetWhere(Database& db, std::string where_filter) + static std::vector GetWhere(Database& db, const std::string &where_filter) { std::vector all_entries; @@ -274,19 +274,19 @@ public: all_entries.reserve(results.RowCount()); for (auto row = results.begin(); row != results.end(); ++row) { - IpExemptions entry{}; + IpExemptions e{}; - entry.exemption_id = atoi(row[0]); - entry.exemption_ip = row[1] ? row[1] : ""; - entry.exemption_amount = atoi(row[2]); + e.exemption_id = atoi(row[0]); + e.exemption_ip = row[1] ? row[1] : ""; + e.exemption_amount = atoi(row[2]); - all_entries.push_back(entry); + all_entries.push_back(e); } return all_entries; } - static int DeleteWhere(Database& db, std::string where_filter) + static int DeleteWhere(Database& db, const std::string &where_filter) { auto results = db.QueryDatabase( fmt::format( @@ -311,6 +311,32 @@ public: 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); + } + }; #endif //EQEMU_BASE_IP_EXEMPTIONS_REPOSITORY_H diff --git a/common/repositories/base/base_item_tick_repository.h b/common/repositories/base/base_item_tick_repository.h index e73df8cfb..8e7ba69a8 100644 --- a/common/repositories/base/base_item_tick_repository.h +++ b/common/repositories/base/base_item_tick_repository.h @@ -91,19 +91,19 @@ public: static ItemTick NewEntity() { - ItemTick entry{}; + ItemTick e{}; - entry.it_itemid = 0; - entry.it_chance = 0; - entry.it_level = 0; - entry.it_id = 0; - entry.it_qglobal = ""; - entry.it_bagslot = 0; + e.it_itemid = 0; + e.it_chance = 0; + e.it_level = 0; + e.it_id = 0; + e.it_qglobal = ""; + e.it_bagslot = 0; - return entry; + return e; } - static ItemTick GetItemTickEntry( + static ItemTick GetItemTick( const std::vector &item_ticks, int item_tick_id ) @@ -132,16 +132,16 @@ public: auto row = results.begin(); if (results.RowCount() == 1) { - ItemTick entry{}; + ItemTick e{}; - entry.it_itemid = atoi(row[0]); - entry.it_chance = atoi(row[1]); - entry.it_level = atoi(row[2]); - entry.it_id = atoi(row[3]); - entry.it_qglobal = row[4] ? row[4] : ""; - entry.it_bagslot = atoi(row[5]); + e.it_itemid = atoi(row[0]); + e.it_chance = atoi(row[1]); + e.it_level = atoi(row[2]); + e.it_id = atoi(row[3]); + e.it_qglobal = row[4] ? row[4] : ""; + e.it_bagslot = atoi(row[5]); - return entry; + return e; } return NewEntity(); @@ -166,26 +166,26 @@ public: static int UpdateOne( Database& db, - ItemTick item_tick_entry + const ItemTick &e ) { - std::vector update_values; + std::vector v; auto columns = Columns(); - update_values.push_back(columns[0] + " = " + std::to_string(item_tick_entry.it_itemid)); - update_values.push_back(columns[1] + " = " + std::to_string(item_tick_entry.it_chance)); - update_values.push_back(columns[2] + " = " + std::to_string(item_tick_entry.it_level)); - update_values.push_back(columns[4] + " = '" + Strings::Escape(item_tick_entry.it_qglobal) + "'"); - update_values.push_back(columns[5] + " = " + std::to_string(item_tick_entry.it_bagslot)); + 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(", ", update_values), + Strings::Implode(", ", v), PrimaryKey(), - item_tick_entry.it_id + e.it_id ) ); @@ -194,57 +194,57 @@ public: static ItemTick InsertOne( Database& db, - ItemTick item_tick_entry + ItemTick e ) { - std::vector insert_values; + std::vector v; - insert_values.push_back(std::to_string(item_tick_entry.it_itemid)); - insert_values.push_back(std::to_string(item_tick_entry.it_chance)); - insert_values.push_back(std::to_string(item_tick_entry.it_level)); - insert_values.push_back(std::to_string(item_tick_entry.it_id)); - insert_values.push_back("'" + Strings::Escape(item_tick_entry.it_qglobal) + "'"); - insert_values.push_back(std::to_string(item_tick_entry.it_bagslot)); + 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(",", insert_values) + Strings::Implode(",", v) ) ); if (results.Success()) { - item_tick_entry.it_id = results.LastInsertedID(); - return item_tick_entry; + e.it_id = results.LastInsertedID(); + return e; } - item_tick_entry = NewEntity(); + e = NewEntity(); - return item_tick_entry; + return e; } static int InsertMany( Database& db, - std::vector item_tick_entries + const std::vector &entries ) { std::vector insert_chunks; - for (auto &item_tick_entry: item_tick_entries) { - std::vector insert_values; + for (auto &e: entries) { + std::vector v; - insert_values.push_back(std::to_string(item_tick_entry.it_itemid)); - insert_values.push_back(std::to_string(item_tick_entry.it_chance)); - insert_values.push_back(std::to_string(item_tick_entry.it_level)); - insert_values.push_back(std::to_string(item_tick_entry.it_id)); - insert_values.push_back("'" + Strings::Escape(item_tick_entry.it_qglobal) + "'"); - insert_values.push_back(std::to_string(item_tick_entry.it_bagslot)); + 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(",", insert_values) + ")"); + insert_chunks.push_back("(" + Strings::Implode(",", v) + ")"); } - std::vector insert_values; + std::vector v; auto results = db.QueryDatabase( fmt::format( @@ -271,22 +271,22 @@ public: all_entries.reserve(results.RowCount()); for (auto row = results.begin(); row != results.end(); ++row) { - ItemTick entry{}; + ItemTick e{}; - entry.it_itemid = atoi(row[0]); - entry.it_chance = atoi(row[1]); - entry.it_level = atoi(row[2]); - entry.it_id = atoi(row[3]); - entry.it_qglobal = row[4] ? row[4] : ""; - entry.it_bagslot = atoi(row[5]); + e.it_itemid = atoi(row[0]); + e.it_chance = atoi(row[1]); + e.it_level = atoi(row[2]); + e.it_id = atoi(row[3]); + e.it_qglobal = row[4] ? row[4] : ""; + e.it_bagslot = atoi(row[5]); - all_entries.push_back(entry); + all_entries.push_back(e); } return all_entries; } - static std::vector GetWhere(Database& db, std::string where_filter) + static std::vector GetWhere(Database& db, const std::string &where_filter) { std::vector all_entries; @@ -301,22 +301,22 @@ public: all_entries.reserve(results.RowCount()); for (auto row = results.begin(); row != results.end(); ++row) { - ItemTick entry{}; + ItemTick e{}; - entry.it_itemid = atoi(row[0]); - entry.it_chance = atoi(row[1]); - entry.it_level = atoi(row[2]); - entry.it_id = atoi(row[3]); - entry.it_qglobal = row[4] ? row[4] : ""; - entry.it_bagslot = atoi(row[5]); + e.it_itemid = atoi(row[0]); + e.it_chance = atoi(row[1]); + e.it_level = atoi(row[2]); + e.it_id = atoi(row[3]); + e.it_qglobal = row[4] ? row[4] : ""; + e.it_bagslot = atoi(row[5]); - all_entries.push_back(entry); + all_entries.push_back(e); } return all_entries; } - static int DeleteWhere(Database& db, std::string where_filter) + static int DeleteWhere(Database& db, const std::string &where_filter) { auto results = db.QueryDatabase( fmt::format( @@ -341,6 +341,32 @@ public: 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); + } + }; #endif //EQEMU_BASE_ITEM_TICK_REPOSITORY_H diff --git a/common/repositories/base/base_items_repository.h b/common/repositories/base/base_items_repository.h index 3c4bac737..4cd9acb7c 100644 --- a/common/repositories/base/base_items_repository.h +++ b/common/repositories/base/base_items_repository.h @@ -928,298 +928,298 @@ public: static Items NewEntity() { - Items entry{}; + Items e{}; - entry.id = 0; - entry.minstatus = 0; - entry.Name = ""; - entry.aagi = 0; - entry.ac = 0; - entry.accuracy = 0; - entry.acha = 0; - entry.adex = 0; - entry.aint = 0; - entry.artifactflag = 0; - entry.asta = 0; - entry.astr = 0; - entry.attack = 0; - entry.augrestrict = 0; - entry.augslot1type = 0; - entry.augslot1visible = 0; - entry.augslot2type = 0; - entry.augslot2visible = 0; - entry.augslot3type = 0; - entry.augslot3visible = 0; - entry.augslot4type = 0; - entry.augslot4visible = 0; - entry.augslot5type = 0; - entry.augslot5visible = 0; - entry.augslot6type = 0; - entry.augslot6visible = 0; - entry.augtype = 0; - entry.avoidance = 0; - entry.awis = 0; - entry.bagsize = 0; - entry.bagslots = 0; - entry.bagtype = 0; - entry.bagwr = 0; - entry.banedmgamt = 0; - entry.banedmgraceamt = 0; - entry.banedmgbody = 0; - entry.banedmgrace = 0; - entry.bardtype = 0; - entry.bardvalue = 0; - entry.book = 0; - entry.casttime = 0; - entry.casttime_ = 0; - entry.charmfile = ""; - entry.charmfileid = ""; - entry.classes = 0; - entry.color = 0; - entry.combateffects = ""; - entry.extradmgskill = 0; - entry.extradmgamt = 0; - entry.price = 0; - entry.cr = 0; - entry.damage = 0; - entry.damageshield = 0; - entry.deity = 0; - entry.delay = 0; - entry.augdistiller = 0; - entry.dotshielding = 0; - entry.dr = 0; - entry.clicktype = 0; - entry.clicklevel2 = 0; - entry.elemdmgtype = 0; - entry.elemdmgamt = 0; - entry.endur = 0; - entry.factionamt1 = 0; - entry.factionamt2 = 0; - entry.factionamt3 = 0; - entry.factionamt4 = 0; - entry.factionmod1 = 0; - entry.factionmod2 = 0; - entry.factionmod3 = 0; - entry.factionmod4 = 0; - entry.filename = ""; - entry.focuseffect = 0; - entry.fr = 0; - entry.fvnodrop = 0; - entry.haste = 0; - entry.clicklevel = 0; - entry.hp = 0; - entry.regen = 0; - entry.icon = 0; - entry.idfile = ""; - entry.itemclass = 0; - entry.itemtype = 0; - entry.ldonprice = 0; - entry.ldontheme = 0; - entry.ldonsold = 0; - entry.light = 0; - entry.lore = ""; - entry.loregroup = 0; - entry.magic = 0; - entry.mana = 0; - entry.manaregen = 0; - entry.enduranceregen = 0; - entry.material = 0; - entry.herosforgemodel = 0; - entry.maxcharges = 0; - entry.mr = 0; - entry.nodrop = 0; - entry.norent = 0; - entry.pendingloreflag = 0; - entry.pr = 0; - entry.procrate = 0; - entry.races = 0; - entry.range = 0; - entry.reclevel = 0; - entry.recskill = 0; - entry.reqlevel = 0; - entry.sellrate = 0; - entry.shielding = 0; - entry.size = 0; - entry.skillmodtype = 0; - entry.skillmodvalue = 0; - entry.slots = 0; - entry.clickeffect = 0; - entry.spellshield = 0; - entry.strikethrough = 0; - entry.stunresist = 0; - entry.summonedflag = 0; - entry.tradeskills = 0; - entry.favor = 0; - entry.weight = 0; - entry.UNK012 = 0; - entry.UNK013 = 0; - entry.benefitflag = 0; - entry.UNK054 = 0; - entry.UNK059 = 0; - entry.booktype = 0; - entry.recastdelay = 0; - entry.recasttype = 0; - entry.guildfavor = 0; - entry.UNK123 = 0; - entry.UNK124 = 0; - entry.attuneable = 0; - entry.nopet = 0; - entry.updated = 0; - entry.comment = ""; - entry.UNK127 = 0; - entry.pointtype = 0; - entry.potionbelt = 0; - entry.potionbeltslots = 0; - entry.stacksize = 0; - entry.notransfer = 0; - entry.stackable = 0; - entry.UNK134 = ""; - entry.UNK137 = 0; - entry.proceffect = 0; - entry.proctype = 0; - entry.proclevel2 = 0; - entry.proclevel = 0; - entry.UNK142 = 0; - entry.worneffect = 0; - entry.worntype = 0; - entry.wornlevel2 = 0; - entry.wornlevel = 0; - entry.UNK147 = 0; - entry.focustype = 0; - entry.focuslevel2 = 0; - entry.focuslevel = 0; - entry.UNK152 = 0; - entry.scrolleffect = 0; - entry.scrolltype = 0; - entry.scrolllevel2 = 0; - entry.scrolllevel = 0; - entry.UNK157 = 0; - entry.serialized = 0; - entry.verified = 0; - entry.serialization = ""; - entry.source = ""; - entry.UNK033 = 0; - entry.lorefile = ""; - entry.UNK014 = 0; - entry.svcorruption = 0; - entry.skillmodmax = 0; - entry.UNK060 = 0; - entry.augslot1unk2 = 0; - entry.augslot2unk2 = 0; - entry.augslot3unk2 = 0; - entry.augslot4unk2 = 0; - entry.augslot5unk2 = 0; - entry.augslot6unk2 = 0; - entry.UNK120 = 0; - entry.UNK121 = 0; - entry.questitemflag = 0; - entry.UNK132 = ""; - entry.clickunk5 = 0; - entry.clickunk6 = ""; - entry.clickunk7 = 0; - entry.procunk1 = 0; - entry.procunk2 = 0; - entry.procunk3 = 0; - entry.procunk4 = 0; - entry.procunk6 = ""; - entry.procunk7 = 0; - entry.wornunk1 = 0; - entry.wornunk2 = 0; - entry.wornunk3 = 0; - entry.wornunk4 = 0; - entry.wornunk5 = 0; - entry.wornunk6 = ""; - entry.wornunk7 = 0; - entry.focusunk1 = 0; - entry.focusunk2 = 0; - entry.focusunk3 = 0; - entry.focusunk4 = 0; - entry.focusunk5 = 0; - entry.focusunk6 = ""; - entry.focusunk7 = 0; - entry.scrollunk1 = 0; - entry.scrollunk2 = 0; - entry.scrollunk3 = 0; - entry.scrollunk4 = 0; - entry.scrollunk5 = 0; - entry.scrollunk6 = ""; - entry.scrollunk7 = 0; - entry.UNK193 = 0; - entry.purity = 0; - entry.evoitem = 0; - entry.evoid = 0; - entry.evolvinglevel = 0; - entry.evomax = 0; - entry.clickname = ""; - entry.procname = ""; - entry.wornname = ""; - entry.focusname = ""; - entry.scrollname = ""; - entry.dsmitigation = 0; - entry.heroic_str = 0; - entry.heroic_int = 0; - entry.heroic_wis = 0; - entry.heroic_agi = 0; - entry.heroic_dex = 0; - entry.heroic_sta = 0; - entry.heroic_cha = 0; - entry.heroic_pr = 0; - entry.heroic_dr = 0; - entry.heroic_fr = 0; - entry.heroic_cr = 0; - entry.heroic_mr = 0; - entry.heroic_svcorrup = 0; - entry.healamt = 0; - entry.spelldmg = 0; - entry.clairvoyance = 0; - entry.backstabdmg = 0; - entry.created = ""; - entry.elitematerial = 0; - entry.ldonsellbackrate = 0; - entry.scriptfileid = 0; - entry.expendablearrow = 0; - entry.powersourcecapacity = 0; - entry.bardeffect = 0; - entry.bardeffecttype = 0; - entry.bardlevel2 = 0; - entry.bardlevel = 0; - entry.bardunk1 = 0; - entry.bardunk2 = 0; - entry.bardunk3 = 0; - entry.bardunk4 = 0; - entry.bardunk5 = 0; - entry.bardname = ""; - entry.bardunk7 = 0; - entry.UNK214 = 0; - entry.subtype = 0; - entry.UNK220 = 0; - entry.UNK221 = 0; - entry.heirloom = 0; - entry.UNK223 = 0; - entry.UNK224 = 0; - entry.UNK225 = 0; - entry.UNK226 = 0; - entry.UNK227 = 0; - entry.UNK228 = 0; - entry.UNK229 = 0; - entry.UNK230 = 0; - entry.UNK231 = 0; - entry.UNK232 = 0; - entry.UNK233 = 0; - entry.UNK234 = 0; - entry.placeable = 0; - entry.UNK236 = 0; - entry.UNK237 = 0; - entry.UNK238 = 0; - entry.UNK239 = 0; - entry.UNK240 = 0; - entry.UNK241 = 0; - entry.epicitem = 0; + e.id = 0; + e.minstatus = 0; + e.Name = ""; + e.aagi = 0; + e.ac = 0; + e.accuracy = 0; + e.acha = 0; + e.adex = 0; + e.aint = 0; + e.artifactflag = 0; + e.asta = 0; + e.astr = 0; + e.attack = 0; + e.augrestrict = 0; + e.augslot1type = 0; + e.augslot1visible = 0; + e.augslot2type = 0; + e.augslot2visible = 0; + e.augslot3type = 0; + e.augslot3visible = 0; + e.augslot4type = 0; + e.augslot4visible = 0; + e.augslot5type = 0; + e.augslot5visible = 0; + e.augslot6type = 0; + e.augslot6visible = 0; + e.augtype = 0; + e.avoidance = 0; + e.awis = 0; + e.bagsize = 0; + e.bagslots = 0; + e.bagtype = 0; + e.bagwr = 0; + e.banedmgamt = 0; + e.banedmgraceamt = 0; + e.banedmgbody = 0; + e.banedmgrace = 0; + e.bardtype = 0; + e.bardvalue = 0; + e.book = 0; + e.casttime = 0; + e.casttime_ = 0; + e.charmfile = ""; + e.charmfileid = ""; + e.classes = 0; + e.color = 0; + e.combateffects = ""; + e.extradmgskill = 0; + e.extradmgamt = 0; + e.price = 0; + e.cr = 0; + e.damage = 0; + e.damageshield = 0; + e.deity = 0; + e.delay = 0; + e.augdistiller = 0; + e.dotshielding = 0; + e.dr = 0; + e.clicktype = 0; + e.clicklevel2 = 0; + e.elemdmgtype = 0; + e.elemdmgamt = 0; + e.endur = 0; + e.factionamt1 = 0; + e.factionamt2 = 0; + e.factionamt3 = 0; + e.factionamt4 = 0; + e.factionmod1 = 0; + e.factionmod2 = 0; + e.factionmod3 = 0; + e.factionmod4 = 0; + e.filename = ""; + e.focuseffect = 0; + e.fr = 0; + e.fvnodrop = 0; + e.haste = 0; + e.clicklevel = 0; + e.hp = 0; + e.regen = 0; + e.icon = 0; + e.idfile = ""; + e.itemclass = 0; + e.itemtype = 0; + e.ldonprice = 0; + e.ldontheme = 0; + e.ldonsold = 0; + e.light = 0; + e.lore = ""; + e.loregroup = 0; + e.magic = 0; + e.mana = 0; + e.manaregen = 0; + e.enduranceregen = 0; + e.material = 0; + e.herosforgemodel = 0; + e.maxcharges = 0; + e.mr = 0; + e.nodrop = 0; + e.norent = 0; + e.pendingloreflag = 0; + e.pr = 0; + e.procrate = 0; + e.races = 0; + e.range = 0; + e.reclevel = 0; + e.recskill = 0; + e.reqlevel = 0; + e.sellrate = 0; + e.shielding = 0; + e.size = 0; + e.skillmodtype = 0; + e.skillmodvalue = 0; + e.slots = 0; + e.clickeffect = 0; + e.spellshield = 0; + e.strikethrough = 0; + e.stunresist = 0; + e.summonedflag = 0; + e.tradeskills = 0; + e.favor = 0; + e.weight = 0; + e.UNK012 = 0; + e.UNK013 = 0; + e.benefitflag = 0; + e.UNK054 = 0; + e.UNK059 = 0; + e.booktype = 0; + e.recastdelay = 0; + e.recasttype = 0; + e.guildfavor = 0; + e.UNK123 = 0; + e.UNK124 = 0; + e.attuneable = 0; + e.nopet = 0; + e.updated = 0; + e.comment = ""; + e.UNK127 = 0; + e.pointtype = 0; + e.potionbelt = 0; + e.potionbeltslots = 0; + e.stacksize = 0; + e.notransfer = 0; + e.stackable = 0; + e.UNK134 = ""; + e.UNK137 = 0; + e.proceffect = 0; + e.proctype = 0; + e.proclevel2 = 0; + e.proclevel = 0; + e.UNK142 = 0; + e.worneffect = 0; + e.worntype = 0; + e.wornlevel2 = 0; + e.wornlevel = 0; + e.UNK147 = 0; + e.focustype = 0; + e.focuslevel2 = 0; + e.focuslevel = 0; + e.UNK152 = 0; + e.scrolleffect = 0; + e.scrolltype = 0; + e.scrolllevel2 = 0; + e.scrolllevel = 0; + e.UNK157 = 0; + e.serialized = 0; + e.verified = 0; + e.serialization = ""; + e.source = ""; + e.UNK033 = 0; + e.lorefile = ""; + e.UNK014 = 0; + e.svcorruption = 0; + e.skillmodmax = 0; + e.UNK060 = 0; + e.augslot1unk2 = 0; + e.augslot2unk2 = 0; + e.augslot3unk2 = 0; + e.augslot4unk2 = 0; + e.augslot5unk2 = 0; + e.augslot6unk2 = 0; + e.UNK120 = 0; + e.UNK121 = 0; + e.questitemflag = 0; + e.UNK132 = ""; + e.clickunk5 = 0; + e.clickunk6 = ""; + e.clickunk7 = 0; + e.procunk1 = 0; + e.procunk2 = 0; + e.procunk3 = 0; + e.procunk4 = 0; + e.procunk6 = ""; + e.procunk7 = 0; + e.wornunk1 = 0; + e.wornunk2 = 0; + e.wornunk3 = 0; + e.wornunk4 = 0; + e.wornunk5 = 0; + e.wornunk6 = ""; + e.wornunk7 = 0; + e.focusunk1 = 0; + e.focusunk2 = 0; + e.focusunk3 = 0; + e.focusunk4 = 0; + e.focusunk5 = 0; + e.focusunk6 = ""; + e.focusunk7 = 0; + e.scrollunk1 = 0; + e.scrollunk2 = 0; + e.scrollunk3 = 0; + e.scrollunk4 = 0; + e.scrollunk5 = 0; + e.scrollunk6 = ""; + e.scrollunk7 = 0; + e.UNK193 = 0; + e.purity = 0; + e.evoitem = 0; + e.evoid = 0; + e.evolvinglevel = 0; + e.evomax = 0; + e.clickname = ""; + e.procname = ""; + e.wornname = ""; + e.focusname = ""; + e.scrollname = ""; + e.dsmitigation = 0; + e.heroic_str = 0; + e.heroic_int = 0; + e.heroic_wis = 0; + e.heroic_agi = 0; + e.heroic_dex = 0; + e.heroic_sta = 0; + e.heroic_cha = 0; + e.heroic_pr = 0; + e.heroic_dr = 0; + e.heroic_fr = 0; + e.heroic_cr = 0; + e.heroic_mr = 0; + e.heroic_svcorrup = 0; + e.healamt = 0; + e.spelldmg = 0; + e.clairvoyance = 0; + e.backstabdmg = 0; + e.created = ""; + e.elitematerial = 0; + e.ldonsellbackrate = 0; + e.scriptfileid = 0; + e.expendablearrow = 0; + e.powersourcecapacity = 0; + e.bardeffect = 0; + e.bardeffecttype = 0; + e.bardlevel2 = 0; + e.bardlevel = 0; + e.bardunk1 = 0; + e.bardunk2 = 0; + e.bardunk3 = 0; + e.bardunk4 = 0; + e.bardunk5 = 0; + e.bardname = ""; + e.bardunk7 = 0; + e.UNK214 = 0; + e.subtype = 0; + e.UNK220 = 0; + e.UNK221 = 0; + e.heirloom = 0; + e.UNK223 = 0; + e.UNK224 = 0; + e.UNK225 = 0; + e.UNK226 = 0; + e.UNK227 = 0; + e.UNK228 = 0; + e.UNK229 = 0; + e.UNK230 = 0; + e.UNK231 = 0; + e.UNK232 = 0; + e.UNK233 = 0; + e.UNK234 = 0; + e.placeable = 0; + e.UNK236 = 0; + e.UNK237 = 0; + e.UNK238 = 0; + e.UNK239 = 0; + e.UNK240 = 0; + e.UNK241 = 0; + e.epicitem = 0; - return entry; + return e; } - static Items GetItemsEntry( + static Items GetItems( const std::vector &itemss, int items_id ) @@ -1248,295 +1248,295 @@ public: auto row = results.begin(); if (results.RowCount() == 1) { - Items entry{}; + Items e{}; - entry.id = atoi(row[0]); - entry.minstatus = atoi(row[1]); - entry.Name = row[2] ? row[2] : ""; - entry.aagi = atoi(row[3]); - entry.ac = atoi(row[4]); - entry.accuracy = atoi(row[5]); - entry.acha = atoi(row[6]); - entry.adex = atoi(row[7]); - entry.aint = atoi(row[8]); - entry.artifactflag = atoi(row[9]); - entry.asta = atoi(row[10]); - entry.astr = atoi(row[11]); - entry.attack = atoi(row[12]); - entry.augrestrict = atoi(row[13]); - entry.augslot1type = atoi(row[14]); - entry.augslot1visible = atoi(row[15]); - entry.augslot2type = atoi(row[16]); - entry.augslot2visible = atoi(row[17]); - entry.augslot3type = atoi(row[18]); - entry.augslot3visible = atoi(row[19]); - entry.augslot4type = atoi(row[20]); - entry.augslot4visible = atoi(row[21]); - entry.augslot5type = atoi(row[22]); - entry.augslot5visible = atoi(row[23]); - entry.augslot6type = atoi(row[24]); - entry.augslot6visible = atoi(row[25]); - entry.augtype = atoi(row[26]); - entry.avoidance = atoi(row[27]); - entry.awis = atoi(row[28]); - entry.bagsize = atoi(row[29]); - entry.bagslots = atoi(row[30]); - entry.bagtype = atoi(row[31]); - entry.bagwr = atoi(row[32]); - entry.banedmgamt = atoi(row[33]); - entry.banedmgraceamt = atoi(row[34]); - entry.banedmgbody = atoi(row[35]); - entry.banedmgrace = atoi(row[36]); - entry.bardtype = atoi(row[37]); - entry.bardvalue = atoi(row[38]); - entry.book = atoi(row[39]); - entry.casttime = atoi(row[40]); - entry.casttime_ = atoi(row[41]); - entry.charmfile = row[42] ? row[42] : ""; - entry.charmfileid = row[43] ? row[43] : ""; - entry.classes = atoi(row[44]); - entry.color = atoi(row[45]); - entry.combateffects = row[46] ? row[46] : ""; - entry.extradmgskill = atoi(row[47]); - entry.extradmgamt = atoi(row[48]); - entry.price = atoi(row[49]); - entry.cr = atoi(row[50]); - entry.damage = atoi(row[51]); - entry.damageshield = atoi(row[52]); - entry.deity = atoi(row[53]); - entry.delay = atoi(row[54]); - entry.augdistiller = atoi(row[55]); - entry.dotshielding = atoi(row[56]); - entry.dr = atoi(row[57]); - entry.clicktype = atoi(row[58]); - entry.clicklevel2 = atoi(row[59]); - entry.elemdmgtype = atoi(row[60]); - entry.elemdmgamt = atoi(row[61]); - entry.endur = atoi(row[62]); - entry.factionamt1 = atoi(row[63]); - entry.factionamt2 = atoi(row[64]); - entry.factionamt3 = atoi(row[65]); - entry.factionamt4 = atoi(row[66]); - entry.factionmod1 = atoi(row[67]); - entry.factionmod2 = atoi(row[68]); - entry.factionmod3 = atoi(row[69]); - entry.factionmod4 = atoi(row[70]); - entry.filename = row[71] ? row[71] : ""; - entry.focuseffect = atoi(row[72]); - entry.fr = atoi(row[73]); - entry.fvnodrop = atoi(row[74]); - entry.haste = atoi(row[75]); - entry.clicklevel = atoi(row[76]); - entry.hp = atoi(row[77]); - entry.regen = atoi(row[78]); - entry.icon = atoi(row[79]); - entry.idfile = row[80] ? row[80] : ""; - entry.itemclass = atoi(row[81]); - entry.itemtype = atoi(row[82]); - entry.ldonprice = atoi(row[83]); - entry.ldontheme = atoi(row[84]); - entry.ldonsold = atoi(row[85]); - entry.light = atoi(row[86]); - entry.lore = row[87] ? row[87] : ""; - entry.loregroup = atoi(row[88]); - entry.magic = atoi(row[89]); - entry.mana = atoi(row[90]); - entry.manaregen = atoi(row[91]); - entry.enduranceregen = atoi(row[92]); - entry.material = atoi(row[93]); - entry.herosforgemodel = atoi(row[94]); - entry.maxcharges = atoi(row[95]); - entry.mr = atoi(row[96]); - entry.nodrop = atoi(row[97]); - entry.norent = atoi(row[98]); - entry.pendingloreflag = atoi(row[99]); - entry.pr = atoi(row[100]); - entry.procrate = atoi(row[101]); - entry.races = atoi(row[102]); - entry.range = atoi(row[103]); - entry.reclevel = atoi(row[104]); - entry.recskill = atoi(row[105]); - entry.reqlevel = atoi(row[106]); - entry.sellrate = static_cast(atof(row[107])); - entry.shielding = atoi(row[108]); - entry.size = atoi(row[109]); - entry.skillmodtype = atoi(row[110]); - entry.skillmodvalue = atoi(row[111]); - entry.slots = atoi(row[112]); - entry.clickeffect = atoi(row[113]); - entry.spellshield = atoi(row[114]); - entry.strikethrough = atoi(row[115]); - entry.stunresist = atoi(row[116]); - entry.summonedflag = atoi(row[117]); - entry.tradeskills = atoi(row[118]); - entry.favor = atoi(row[119]); - entry.weight = atoi(row[120]); - entry.UNK012 = atoi(row[121]); - entry.UNK013 = atoi(row[122]); - entry.benefitflag = atoi(row[123]); - entry.UNK054 = atoi(row[124]); - entry.UNK059 = atoi(row[125]); - entry.booktype = atoi(row[126]); - entry.recastdelay = atoi(row[127]); - entry.recasttype = atoi(row[128]); - entry.guildfavor = atoi(row[129]); - entry.UNK123 = atoi(row[130]); - entry.UNK124 = atoi(row[131]); - entry.attuneable = atoi(row[132]); - entry.nopet = atoi(row[133]); - entry.updated = strtoll(row[134] ? row[134] : "-1", nullptr, 10); - entry.comment = row[135] ? row[135] : ""; - entry.UNK127 = atoi(row[136]); - entry.pointtype = atoi(row[137]); - entry.potionbelt = atoi(row[138]); - entry.potionbeltslots = atoi(row[139]); - entry.stacksize = atoi(row[140]); - entry.notransfer = atoi(row[141]); - entry.stackable = atoi(row[142]); - entry.UNK134 = row[143] ? row[143] : ""; - entry.UNK137 = atoi(row[144]); - entry.proceffect = atoi(row[145]); - entry.proctype = atoi(row[146]); - entry.proclevel2 = atoi(row[147]); - entry.proclevel = atoi(row[148]); - entry.UNK142 = atoi(row[149]); - entry.worneffect = atoi(row[150]); - entry.worntype = atoi(row[151]); - entry.wornlevel2 = atoi(row[152]); - entry.wornlevel = atoi(row[153]); - entry.UNK147 = atoi(row[154]); - entry.focustype = atoi(row[155]); - entry.focuslevel2 = atoi(row[156]); - entry.focuslevel = atoi(row[157]); - entry.UNK152 = atoi(row[158]); - entry.scrolleffect = atoi(row[159]); - entry.scrolltype = atoi(row[160]); - entry.scrolllevel2 = atoi(row[161]); - entry.scrolllevel = atoi(row[162]); - entry.UNK157 = atoi(row[163]); - entry.serialized = strtoll(row[164] ? row[164] : "-1", nullptr, 10); - entry.verified = strtoll(row[165] ? row[165] : "-1", nullptr, 10); - entry.serialization = row[166] ? row[166] : ""; - entry.source = row[167] ? row[167] : ""; - entry.UNK033 = atoi(row[168]); - entry.lorefile = row[169] ? row[169] : ""; - entry.UNK014 = atoi(row[170]); - entry.svcorruption = atoi(row[171]); - entry.skillmodmax = atoi(row[172]); - entry.UNK060 = atoi(row[173]); - entry.augslot1unk2 = atoi(row[174]); - entry.augslot2unk2 = atoi(row[175]); - entry.augslot3unk2 = atoi(row[176]); - entry.augslot4unk2 = atoi(row[177]); - entry.augslot5unk2 = atoi(row[178]); - entry.augslot6unk2 = atoi(row[179]); - entry.UNK120 = atoi(row[180]); - entry.UNK121 = atoi(row[181]); - entry.questitemflag = atoi(row[182]); - entry.UNK132 = row[183] ? row[183] : ""; - entry.clickunk5 = atoi(row[184]); - entry.clickunk6 = row[185] ? row[185] : ""; - entry.clickunk7 = atoi(row[186]); - entry.procunk1 = atoi(row[187]); - entry.procunk2 = atoi(row[188]); - entry.procunk3 = atoi(row[189]); - entry.procunk4 = atoi(row[190]); - entry.procunk6 = row[191] ? row[191] : ""; - entry.procunk7 = atoi(row[192]); - entry.wornunk1 = atoi(row[193]); - entry.wornunk2 = atoi(row[194]); - entry.wornunk3 = atoi(row[195]); - entry.wornunk4 = atoi(row[196]); - entry.wornunk5 = atoi(row[197]); - entry.wornunk6 = row[198] ? row[198] : ""; - entry.wornunk7 = atoi(row[199]); - entry.focusunk1 = atoi(row[200]); - entry.focusunk2 = atoi(row[201]); - entry.focusunk3 = atoi(row[202]); - entry.focusunk4 = atoi(row[203]); - entry.focusunk5 = atoi(row[204]); - entry.focusunk6 = row[205] ? row[205] : ""; - entry.focusunk7 = atoi(row[206]); - entry.scrollunk1 = atoi(row[207]); - entry.scrollunk2 = atoi(row[208]); - entry.scrollunk3 = atoi(row[209]); - entry.scrollunk4 = atoi(row[210]); - entry.scrollunk5 = atoi(row[211]); - entry.scrollunk6 = row[212] ? row[212] : ""; - entry.scrollunk7 = atoi(row[213]); - entry.UNK193 = atoi(row[214]); - entry.purity = atoi(row[215]); - entry.evoitem = atoi(row[216]); - entry.evoid = atoi(row[217]); - entry.evolvinglevel = atoi(row[218]); - entry.evomax = atoi(row[219]); - entry.clickname = row[220] ? row[220] : ""; - entry.procname = row[221] ? row[221] : ""; - entry.wornname = row[222] ? row[222] : ""; - entry.focusname = row[223] ? row[223] : ""; - entry.scrollname = row[224] ? row[224] : ""; - entry.dsmitigation = atoi(row[225]); - entry.heroic_str = atoi(row[226]); - entry.heroic_int = atoi(row[227]); - entry.heroic_wis = atoi(row[228]); - entry.heroic_agi = atoi(row[229]); - entry.heroic_dex = atoi(row[230]); - entry.heroic_sta = atoi(row[231]); - entry.heroic_cha = atoi(row[232]); - entry.heroic_pr = atoi(row[233]); - entry.heroic_dr = atoi(row[234]); - entry.heroic_fr = atoi(row[235]); - entry.heroic_cr = atoi(row[236]); - entry.heroic_mr = atoi(row[237]); - entry.heroic_svcorrup = atoi(row[238]); - entry.healamt = atoi(row[239]); - entry.spelldmg = atoi(row[240]); - entry.clairvoyance = atoi(row[241]); - entry.backstabdmg = atoi(row[242]); - entry.created = row[243] ? row[243] : ""; - entry.elitematerial = atoi(row[244]); - entry.ldonsellbackrate = atoi(row[245]); - entry.scriptfileid = atoi(row[246]); - entry.expendablearrow = atoi(row[247]); - entry.powersourcecapacity = atoi(row[248]); - entry.bardeffect = atoi(row[249]); - entry.bardeffecttype = atoi(row[250]); - entry.bardlevel2 = atoi(row[251]); - entry.bardlevel = atoi(row[252]); - entry.bardunk1 = atoi(row[253]); - entry.bardunk2 = atoi(row[254]); - entry.bardunk3 = atoi(row[255]); - entry.bardunk4 = atoi(row[256]); - entry.bardunk5 = atoi(row[257]); - entry.bardname = row[258] ? row[258] : ""; - entry.bardunk7 = atoi(row[259]); - entry.UNK214 = atoi(row[260]); - entry.subtype = atoi(row[261]); - entry.UNK220 = atoi(row[262]); - entry.UNK221 = atoi(row[263]); - entry.heirloom = atoi(row[264]); - entry.UNK223 = atoi(row[265]); - entry.UNK224 = atoi(row[266]); - entry.UNK225 = atoi(row[267]); - entry.UNK226 = atoi(row[268]); - entry.UNK227 = atoi(row[269]); - entry.UNK228 = atoi(row[270]); - entry.UNK229 = atoi(row[271]); - entry.UNK230 = atoi(row[272]); - entry.UNK231 = atoi(row[273]); - entry.UNK232 = atoi(row[274]); - entry.UNK233 = atoi(row[275]); - entry.UNK234 = atoi(row[276]); - entry.placeable = atoi(row[277]); - entry.UNK236 = atoi(row[278]); - entry.UNK237 = atoi(row[279]); - entry.UNK238 = atoi(row[280]); - entry.UNK239 = atoi(row[281]); - entry.UNK240 = atoi(row[282]); - entry.UNK241 = atoi(row[283]); - entry.epicitem = atoi(row[284]); + e.id = atoi(row[0]); + e.minstatus = atoi(row[1]); + e.Name = row[2] ? row[2] : ""; + e.aagi = atoi(row[3]); + e.ac = atoi(row[4]); + e.accuracy = atoi(row[5]); + e.acha = atoi(row[6]); + e.adex = atoi(row[7]); + e.aint = atoi(row[8]); + e.artifactflag = atoi(row[9]); + e.asta = atoi(row[10]); + e.astr = atoi(row[11]); + e.attack = atoi(row[12]); + e.augrestrict = atoi(row[13]); + e.augslot1type = atoi(row[14]); + e.augslot1visible = atoi(row[15]); + e.augslot2type = atoi(row[16]); + e.augslot2visible = atoi(row[17]); + e.augslot3type = atoi(row[18]); + e.augslot3visible = atoi(row[19]); + e.augslot4type = atoi(row[20]); + e.augslot4visible = atoi(row[21]); + e.augslot5type = atoi(row[22]); + e.augslot5visible = atoi(row[23]); + e.augslot6type = atoi(row[24]); + e.augslot6visible = atoi(row[25]); + e.augtype = atoi(row[26]); + e.avoidance = atoi(row[27]); + e.awis = atoi(row[28]); + e.bagsize = atoi(row[29]); + e.bagslots = atoi(row[30]); + e.bagtype = atoi(row[31]); + e.bagwr = atoi(row[32]); + e.banedmgamt = atoi(row[33]); + e.banedmgraceamt = atoi(row[34]); + e.banedmgbody = atoi(row[35]); + e.banedmgrace = atoi(row[36]); + e.bardtype = atoi(row[37]); + e.bardvalue = atoi(row[38]); + e.book = atoi(row[39]); + e.casttime = atoi(row[40]); + e.casttime_ = atoi(row[41]); + e.charmfile = row[42] ? row[42] : ""; + e.charmfileid = row[43] ? row[43] : ""; + e.classes = atoi(row[44]); + e.color = atoi(row[45]); + e.combateffects = row[46] ? row[46] : ""; + e.extradmgskill = atoi(row[47]); + e.extradmgamt = atoi(row[48]); + e.price = atoi(row[49]); + e.cr = atoi(row[50]); + e.damage = atoi(row[51]); + e.damageshield = atoi(row[52]); + e.deity = atoi(row[53]); + e.delay = atoi(row[54]); + e.augdistiller = atoi(row[55]); + e.dotshielding = atoi(row[56]); + e.dr = atoi(row[57]); + e.clicktype = atoi(row[58]); + e.clicklevel2 = atoi(row[59]); + e.elemdmgtype = atoi(row[60]); + e.elemdmgamt = atoi(row[61]); + e.endur = atoi(row[62]); + e.factionamt1 = atoi(row[63]); + e.factionamt2 = atoi(row[64]); + e.factionamt3 = atoi(row[65]); + e.factionamt4 = atoi(row[66]); + e.factionmod1 = atoi(row[67]); + e.factionmod2 = atoi(row[68]); + e.factionmod3 = atoi(row[69]); + e.factionmod4 = atoi(row[70]); + e.filename = row[71] ? row[71] : ""; + e.focuseffect = atoi(row[72]); + e.fr = atoi(row[73]); + e.fvnodrop = atoi(row[74]); + e.haste = atoi(row[75]); + e.clicklevel = atoi(row[76]); + e.hp = atoi(row[77]); + e.regen = atoi(row[78]); + e.icon = atoi(row[79]); + e.idfile = row[80] ? row[80] : ""; + e.itemclass = atoi(row[81]); + e.itemtype = atoi(row[82]); + e.ldonprice = atoi(row[83]); + e.ldontheme = atoi(row[84]); + e.ldonsold = atoi(row[85]); + e.light = atoi(row[86]); + e.lore = row[87] ? row[87] : ""; + e.loregroup = atoi(row[88]); + e.magic = atoi(row[89]); + e.mana = atoi(row[90]); + e.manaregen = atoi(row[91]); + e.enduranceregen = atoi(row[92]); + e.material = atoi(row[93]); + e.herosforgemodel = atoi(row[94]); + e.maxcharges = atoi(row[95]); + e.mr = atoi(row[96]); + e.nodrop = atoi(row[97]); + e.norent = atoi(row[98]); + e.pendingloreflag = atoi(row[99]); + e.pr = atoi(row[100]); + e.procrate = atoi(row[101]); + e.races = atoi(row[102]); + e.range = atoi(row[103]); + e.reclevel = atoi(row[104]); + e.recskill = atoi(row[105]); + e.reqlevel = atoi(row[106]); + e.sellrate = static_cast(atof(row[107])); + e.shielding = atoi(row[108]); + e.size = atoi(row[109]); + e.skillmodtype = atoi(row[110]); + e.skillmodvalue = atoi(row[111]); + e.slots = atoi(row[112]); + e.clickeffect = atoi(row[113]); + e.spellshield = atoi(row[114]); + e.strikethrough = atoi(row[115]); + e.stunresist = atoi(row[116]); + e.summonedflag = atoi(row[117]); + e.tradeskills = atoi(row[118]); + e.favor = atoi(row[119]); + e.weight = atoi(row[120]); + e.UNK012 = atoi(row[121]); + e.UNK013 = atoi(row[122]); + e.benefitflag = atoi(row[123]); + e.UNK054 = atoi(row[124]); + e.UNK059 = atoi(row[125]); + e.booktype = atoi(row[126]); + e.recastdelay = atoi(row[127]); + e.recasttype = atoi(row[128]); + e.guildfavor = atoi(row[129]); + e.UNK123 = atoi(row[130]); + e.UNK124 = atoi(row[131]); + e.attuneable = atoi(row[132]); + e.nopet = atoi(row[133]); + e.updated = strtoll(row[134] ? row[134] : "-1", nullptr, 10); + e.comment = row[135] ? row[135] : ""; + e.UNK127 = atoi(row[136]); + e.pointtype = atoi(row[137]); + e.potionbelt = atoi(row[138]); + e.potionbeltslots = atoi(row[139]); + e.stacksize = atoi(row[140]); + e.notransfer = atoi(row[141]); + e.stackable = atoi(row[142]); + e.UNK134 = row[143] ? row[143] : ""; + e.UNK137 = atoi(row[144]); + e.proceffect = atoi(row[145]); + e.proctype = atoi(row[146]); + e.proclevel2 = atoi(row[147]); + e.proclevel = atoi(row[148]); + e.UNK142 = atoi(row[149]); + e.worneffect = atoi(row[150]); + e.worntype = atoi(row[151]); + e.wornlevel2 = atoi(row[152]); + e.wornlevel = atoi(row[153]); + e.UNK147 = atoi(row[154]); + e.focustype = atoi(row[155]); + e.focuslevel2 = atoi(row[156]); + e.focuslevel = atoi(row[157]); + e.UNK152 = atoi(row[158]); + e.scrolleffect = atoi(row[159]); + e.scrolltype = atoi(row[160]); + e.scrolllevel2 = atoi(row[161]); + e.scrolllevel = atoi(row[162]); + e.UNK157 = atoi(row[163]); + e.serialized = strtoll(row[164] ? row[164] : "-1", nullptr, 10); + e.verified = strtoll(row[165] ? row[165] : "-1", nullptr, 10); + e.serialization = row[166] ? row[166] : ""; + e.source = row[167] ? row[167] : ""; + e.UNK033 = atoi(row[168]); + e.lorefile = row[169] ? row[169] : ""; + e.UNK014 = atoi(row[170]); + e.svcorruption = atoi(row[171]); + e.skillmodmax = atoi(row[172]); + e.UNK060 = atoi(row[173]); + e.augslot1unk2 = atoi(row[174]); + e.augslot2unk2 = atoi(row[175]); + e.augslot3unk2 = atoi(row[176]); + e.augslot4unk2 = atoi(row[177]); + e.augslot5unk2 = atoi(row[178]); + e.augslot6unk2 = atoi(row[179]); + e.UNK120 = atoi(row[180]); + e.UNK121 = atoi(row[181]); + e.questitemflag = atoi(row[182]); + e.UNK132 = row[183] ? row[183] : ""; + e.clickunk5 = atoi(row[184]); + e.clickunk6 = row[185] ? row[185] : ""; + e.clickunk7 = atoi(row[186]); + e.procunk1 = atoi(row[187]); + e.procunk2 = atoi(row[188]); + e.procunk3 = atoi(row[189]); + e.procunk4 = atoi(row[190]); + e.procunk6 = row[191] ? row[191] : ""; + e.procunk7 = atoi(row[192]); + e.wornunk1 = atoi(row[193]); + e.wornunk2 = atoi(row[194]); + e.wornunk3 = atoi(row[195]); + e.wornunk4 = atoi(row[196]); + e.wornunk5 = atoi(row[197]); + e.wornunk6 = row[198] ? row[198] : ""; + e.wornunk7 = atoi(row[199]); + e.focusunk1 = atoi(row[200]); + e.focusunk2 = atoi(row[201]); + e.focusunk3 = atoi(row[202]); + e.focusunk4 = atoi(row[203]); + e.focusunk5 = atoi(row[204]); + e.focusunk6 = row[205] ? row[205] : ""; + e.focusunk7 = atoi(row[206]); + e.scrollunk1 = atoi(row[207]); + e.scrollunk2 = atoi(row[208]); + e.scrollunk3 = atoi(row[209]); + e.scrollunk4 = atoi(row[210]); + e.scrollunk5 = atoi(row[211]); + e.scrollunk6 = row[212] ? row[212] : ""; + e.scrollunk7 = atoi(row[213]); + e.UNK193 = atoi(row[214]); + e.purity = atoi(row[215]); + e.evoitem = atoi(row[216]); + e.evoid = atoi(row[217]); + e.evolvinglevel = atoi(row[218]); + e.evomax = atoi(row[219]); + e.clickname = row[220] ? row[220] : ""; + e.procname = row[221] ? row[221] : ""; + e.wornname = row[222] ? row[222] : ""; + e.focusname = row[223] ? row[223] : ""; + e.scrollname = row[224] ? row[224] : ""; + e.dsmitigation = atoi(row[225]); + e.heroic_str = atoi(row[226]); + e.heroic_int = atoi(row[227]); + e.heroic_wis = atoi(row[228]); + e.heroic_agi = atoi(row[229]); + e.heroic_dex = atoi(row[230]); + e.heroic_sta = atoi(row[231]); + e.heroic_cha = atoi(row[232]); + e.heroic_pr = atoi(row[233]); + e.heroic_dr = atoi(row[234]); + e.heroic_fr = atoi(row[235]); + e.heroic_cr = atoi(row[236]); + e.heroic_mr = atoi(row[237]); + e.heroic_svcorrup = atoi(row[238]); + e.healamt = atoi(row[239]); + e.spelldmg = atoi(row[240]); + e.clairvoyance = atoi(row[241]); + e.backstabdmg = atoi(row[242]); + e.created = row[243] ? row[243] : ""; + e.elitematerial = atoi(row[244]); + e.ldonsellbackrate = atoi(row[245]); + e.scriptfileid = atoi(row[246]); + e.expendablearrow = atoi(row[247]); + e.powersourcecapacity = atoi(row[248]); + e.bardeffect = atoi(row[249]); + e.bardeffecttype = atoi(row[250]); + e.bardlevel2 = atoi(row[251]); + e.bardlevel = atoi(row[252]); + e.bardunk1 = atoi(row[253]); + e.bardunk2 = atoi(row[254]); + e.bardunk3 = atoi(row[255]); + e.bardunk4 = atoi(row[256]); + e.bardunk5 = atoi(row[257]); + e.bardname = row[258] ? row[258] : ""; + e.bardunk7 = atoi(row[259]); + e.UNK214 = atoi(row[260]); + e.subtype = atoi(row[261]); + e.UNK220 = atoi(row[262]); + e.UNK221 = atoi(row[263]); + e.heirloom = atoi(row[264]); + e.UNK223 = atoi(row[265]); + e.UNK224 = atoi(row[266]); + e.UNK225 = atoi(row[267]); + e.UNK226 = atoi(row[268]); + e.UNK227 = atoi(row[269]); + e.UNK228 = atoi(row[270]); + e.UNK229 = atoi(row[271]); + e.UNK230 = atoi(row[272]); + e.UNK231 = atoi(row[273]); + e.UNK232 = atoi(row[274]); + e.UNK233 = atoi(row[275]); + e.UNK234 = atoi(row[276]); + e.placeable = atoi(row[277]); + e.UNK236 = atoi(row[278]); + e.UNK237 = atoi(row[279]); + e.UNK238 = atoi(row[280]); + e.UNK239 = atoi(row[281]); + e.UNK240 = atoi(row[282]); + e.UNK241 = atoi(row[283]); + e.epicitem = atoi(row[284]); - return entry; + return e; } return NewEntity(); @@ -1561,306 +1561,306 @@ public: static int UpdateOne( Database& db, - Items items_entry + const Items &e ) { - std::vector update_values; + std::vector v; auto columns = Columns(); - update_values.push_back(columns[0] + " = " + std::to_string(items_entry.id)); - update_values.push_back(columns[1] + " = " + std::to_string(items_entry.minstatus)); - update_values.push_back(columns[2] + " = '" + Strings::Escape(items_entry.Name) + "'"); - update_values.push_back(columns[3] + " = " + std::to_string(items_entry.aagi)); - update_values.push_back(columns[4] + " = " + std::to_string(items_entry.ac)); - update_values.push_back(columns[5] + " = " + std::to_string(items_entry.accuracy)); - update_values.push_back(columns[6] + " = " + std::to_string(items_entry.acha)); - update_values.push_back(columns[7] + " = " + std::to_string(items_entry.adex)); - update_values.push_back(columns[8] + " = " + std::to_string(items_entry.aint)); - update_values.push_back(columns[9] + " = " + std::to_string(items_entry.artifactflag)); - update_values.push_back(columns[10] + " = " + std::to_string(items_entry.asta)); - update_values.push_back(columns[11] + " = " + std::to_string(items_entry.astr)); - update_values.push_back(columns[12] + " = " + std::to_string(items_entry.attack)); - update_values.push_back(columns[13] + " = " + std::to_string(items_entry.augrestrict)); - update_values.push_back(columns[14] + " = " + std::to_string(items_entry.augslot1type)); - update_values.push_back(columns[15] + " = " + std::to_string(items_entry.augslot1visible)); - update_values.push_back(columns[16] + " = " + std::to_string(items_entry.augslot2type)); - update_values.push_back(columns[17] + " = " + std::to_string(items_entry.augslot2visible)); - update_values.push_back(columns[18] + " = " + std::to_string(items_entry.augslot3type)); - update_values.push_back(columns[19] + " = " + std::to_string(items_entry.augslot3visible)); - update_values.push_back(columns[20] + " = " + std::to_string(items_entry.augslot4type)); - update_values.push_back(columns[21] + " = " + std::to_string(items_entry.augslot4visible)); - update_values.push_back(columns[22] + " = " + std::to_string(items_entry.augslot5type)); - update_values.push_back(columns[23] + " = " + std::to_string(items_entry.augslot5visible)); - update_values.push_back(columns[24] + " = " + std::to_string(items_entry.augslot6type)); - update_values.push_back(columns[25] + " = " + std::to_string(items_entry.augslot6visible)); - update_values.push_back(columns[26] + " = " + std::to_string(items_entry.augtype)); - update_values.push_back(columns[27] + " = " + std::to_string(items_entry.avoidance)); - update_values.push_back(columns[28] + " = " + std::to_string(items_entry.awis)); - update_values.push_back(columns[29] + " = " + std::to_string(items_entry.bagsize)); - update_values.push_back(columns[30] + " = " + std::to_string(items_entry.bagslots)); - update_values.push_back(columns[31] + " = " + std::to_string(items_entry.bagtype)); - update_values.push_back(columns[32] + " = " + std::to_string(items_entry.bagwr)); - update_values.push_back(columns[33] + " = " + std::to_string(items_entry.banedmgamt)); - update_values.push_back(columns[34] + " = " + std::to_string(items_entry.banedmgraceamt)); - update_values.push_back(columns[35] + " = " + std::to_string(items_entry.banedmgbody)); - update_values.push_back(columns[36] + " = " + std::to_string(items_entry.banedmgrace)); - update_values.push_back(columns[37] + " = " + std::to_string(items_entry.bardtype)); - update_values.push_back(columns[38] + " = " + std::to_string(items_entry.bardvalue)); - update_values.push_back(columns[39] + " = " + std::to_string(items_entry.book)); - update_values.push_back(columns[40] + " = " + std::to_string(items_entry.casttime)); - update_values.push_back(columns[41] + " = " + std::to_string(items_entry.casttime_)); - update_values.push_back(columns[42] + " = '" + Strings::Escape(items_entry.charmfile) + "'"); - update_values.push_back(columns[43] + " = '" + Strings::Escape(items_entry.charmfileid) + "'"); - update_values.push_back(columns[44] + " = " + std::to_string(items_entry.classes)); - update_values.push_back(columns[45] + " = " + std::to_string(items_entry.color)); - update_values.push_back(columns[46] + " = '" + Strings::Escape(items_entry.combateffects) + "'"); - update_values.push_back(columns[47] + " = " + std::to_string(items_entry.extradmgskill)); - update_values.push_back(columns[48] + " = " + std::to_string(items_entry.extradmgamt)); - update_values.push_back(columns[49] + " = " + std::to_string(items_entry.price)); - update_values.push_back(columns[50] + " = " + std::to_string(items_entry.cr)); - update_values.push_back(columns[51] + " = " + std::to_string(items_entry.damage)); - update_values.push_back(columns[52] + " = " + std::to_string(items_entry.damageshield)); - update_values.push_back(columns[53] + " = " + std::to_string(items_entry.deity)); - update_values.push_back(columns[54] + " = " + std::to_string(items_entry.delay)); - update_values.push_back(columns[55] + " = " + std::to_string(items_entry.augdistiller)); - update_values.push_back(columns[56] + " = " + std::to_string(items_entry.dotshielding)); - update_values.push_back(columns[57] + " = " + std::to_string(items_entry.dr)); - update_values.push_back(columns[58] + " = " + std::to_string(items_entry.clicktype)); - update_values.push_back(columns[59] + " = " + std::to_string(items_entry.clicklevel2)); - update_values.push_back(columns[60] + " = " + std::to_string(items_entry.elemdmgtype)); - update_values.push_back(columns[61] + " = " + std::to_string(items_entry.elemdmgamt)); - update_values.push_back(columns[62] + " = " + std::to_string(items_entry.endur)); - update_values.push_back(columns[63] + " = " + std::to_string(items_entry.factionamt1)); - update_values.push_back(columns[64] + " = " + std::to_string(items_entry.factionamt2)); - update_values.push_back(columns[65] + " = " + std::to_string(items_entry.factionamt3)); - update_values.push_back(columns[66] + " = " + std::to_string(items_entry.factionamt4)); - update_values.push_back(columns[67] + " = " + std::to_string(items_entry.factionmod1)); - update_values.push_back(columns[68] + " = " + std::to_string(items_entry.factionmod2)); - update_values.push_back(columns[69] + " = " + std::to_string(items_entry.factionmod3)); - update_values.push_back(columns[70] + " = " + std::to_string(items_entry.factionmod4)); - update_values.push_back(columns[71] + " = '" + Strings::Escape(items_entry.filename) + "'"); - update_values.push_back(columns[72] + " = " + std::to_string(items_entry.focuseffect)); - update_values.push_back(columns[73] + " = " + std::to_string(items_entry.fr)); - update_values.push_back(columns[74] + " = " + std::to_string(items_entry.fvnodrop)); - update_values.push_back(columns[75] + " = " + std::to_string(items_entry.haste)); - update_values.push_back(columns[76] + " = " + std::to_string(items_entry.clicklevel)); - update_values.push_back(columns[77] + " = " + std::to_string(items_entry.hp)); - update_values.push_back(columns[78] + " = " + std::to_string(items_entry.regen)); - update_values.push_back(columns[79] + " = " + std::to_string(items_entry.icon)); - update_values.push_back(columns[80] + " = '" + Strings::Escape(items_entry.idfile) + "'"); - update_values.push_back(columns[81] + " = " + std::to_string(items_entry.itemclass)); - update_values.push_back(columns[82] + " = " + std::to_string(items_entry.itemtype)); - update_values.push_back(columns[83] + " = " + std::to_string(items_entry.ldonprice)); - update_values.push_back(columns[84] + " = " + std::to_string(items_entry.ldontheme)); - update_values.push_back(columns[85] + " = " + std::to_string(items_entry.ldonsold)); - update_values.push_back(columns[86] + " = " + std::to_string(items_entry.light)); - update_values.push_back(columns[87] + " = '" + Strings::Escape(items_entry.lore) + "'"); - update_values.push_back(columns[88] + " = " + std::to_string(items_entry.loregroup)); - update_values.push_back(columns[89] + " = " + std::to_string(items_entry.magic)); - update_values.push_back(columns[90] + " = " + std::to_string(items_entry.mana)); - update_values.push_back(columns[91] + " = " + std::to_string(items_entry.manaregen)); - update_values.push_back(columns[92] + " = " + std::to_string(items_entry.enduranceregen)); - update_values.push_back(columns[93] + " = " + std::to_string(items_entry.material)); - update_values.push_back(columns[94] + " = " + std::to_string(items_entry.herosforgemodel)); - update_values.push_back(columns[95] + " = " + std::to_string(items_entry.maxcharges)); - update_values.push_back(columns[96] + " = " + std::to_string(items_entry.mr)); - update_values.push_back(columns[97] + " = " + std::to_string(items_entry.nodrop)); - update_values.push_back(columns[98] + " = " + std::to_string(items_entry.norent)); - update_values.push_back(columns[99] + " = " + std::to_string(items_entry.pendingloreflag)); - update_values.push_back(columns[100] + " = " + std::to_string(items_entry.pr)); - update_values.push_back(columns[101] + " = " + std::to_string(items_entry.procrate)); - update_values.push_back(columns[102] + " = " + std::to_string(items_entry.races)); - update_values.push_back(columns[103] + " = " + std::to_string(items_entry.range)); - update_values.push_back(columns[104] + " = " + std::to_string(items_entry.reclevel)); - update_values.push_back(columns[105] + " = " + std::to_string(items_entry.recskill)); - update_values.push_back(columns[106] + " = " + std::to_string(items_entry.reqlevel)); - update_values.push_back(columns[107] + " = " + std::to_string(items_entry.sellrate)); - update_values.push_back(columns[108] + " = " + std::to_string(items_entry.shielding)); - update_values.push_back(columns[109] + " = " + std::to_string(items_entry.size)); - update_values.push_back(columns[110] + " = " + std::to_string(items_entry.skillmodtype)); - update_values.push_back(columns[111] + " = " + std::to_string(items_entry.skillmodvalue)); - update_values.push_back(columns[112] + " = " + std::to_string(items_entry.slots)); - update_values.push_back(columns[113] + " = " + std::to_string(items_entry.clickeffect)); - update_values.push_back(columns[114] + " = " + std::to_string(items_entry.spellshield)); - update_values.push_back(columns[115] + " = " + std::to_string(items_entry.strikethrough)); - update_values.push_back(columns[116] + " = " + std::to_string(items_entry.stunresist)); - update_values.push_back(columns[117] + " = " + std::to_string(items_entry.summonedflag)); - update_values.push_back(columns[118] + " = " + std::to_string(items_entry.tradeskills)); - update_values.push_back(columns[119] + " = " + std::to_string(items_entry.favor)); - update_values.push_back(columns[120] + " = " + std::to_string(items_entry.weight)); - update_values.push_back(columns[121] + " = " + std::to_string(items_entry.UNK012)); - update_values.push_back(columns[122] + " = " + std::to_string(items_entry.UNK013)); - update_values.push_back(columns[123] + " = " + std::to_string(items_entry.benefitflag)); - update_values.push_back(columns[124] + " = " + std::to_string(items_entry.UNK054)); - update_values.push_back(columns[125] + " = " + std::to_string(items_entry.UNK059)); - update_values.push_back(columns[126] + " = " + std::to_string(items_entry.booktype)); - update_values.push_back(columns[127] + " = " + std::to_string(items_entry.recastdelay)); - update_values.push_back(columns[128] + " = " + std::to_string(items_entry.recasttype)); - update_values.push_back(columns[129] + " = " + std::to_string(items_entry.guildfavor)); - update_values.push_back(columns[130] + " = " + std::to_string(items_entry.UNK123)); - update_values.push_back(columns[131] + " = " + std::to_string(items_entry.UNK124)); - update_values.push_back(columns[132] + " = " + std::to_string(items_entry.attuneable)); - update_values.push_back(columns[133] + " = " + std::to_string(items_entry.nopet)); - update_values.push_back(columns[134] + " = FROM_UNIXTIME(" + (items_entry.updated > 0 ? std::to_string(items_entry.updated) : "null") + ")"); - update_values.push_back(columns[135] + " = '" + Strings::Escape(items_entry.comment) + "'"); - update_values.push_back(columns[136] + " = " + std::to_string(items_entry.UNK127)); - update_values.push_back(columns[137] + " = " + std::to_string(items_entry.pointtype)); - update_values.push_back(columns[138] + " = " + std::to_string(items_entry.potionbelt)); - update_values.push_back(columns[139] + " = " + std::to_string(items_entry.potionbeltslots)); - update_values.push_back(columns[140] + " = " + std::to_string(items_entry.stacksize)); - update_values.push_back(columns[141] + " = " + std::to_string(items_entry.notransfer)); - update_values.push_back(columns[142] + " = " + std::to_string(items_entry.stackable)); - update_values.push_back(columns[143] + " = '" + Strings::Escape(items_entry.UNK134) + "'"); - update_values.push_back(columns[144] + " = " + std::to_string(items_entry.UNK137)); - update_values.push_back(columns[145] + " = " + std::to_string(items_entry.proceffect)); - update_values.push_back(columns[146] + " = " + std::to_string(items_entry.proctype)); - update_values.push_back(columns[147] + " = " + std::to_string(items_entry.proclevel2)); - update_values.push_back(columns[148] + " = " + std::to_string(items_entry.proclevel)); - update_values.push_back(columns[149] + " = " + std::to_string(items_entry.UNK142)); - update_values.push_back(columns[150] + " = " + std::to_string(items_entry.worneffect)); - update_values.push_back(columns[151] + " = " + std::to_string(items_entry.worntype)); - update_values.push_back(columns[152] + " = " + std::to_string(items_entry.wornlevel2)); - update_values.push_back(columns[153] + " = " + std::to_string(items_entry.wornlevel)); - update_values.push_back(columns[154] + " = " + std::to_string(items_entry.UNK147)); - update_values.push_back(columns[155] + " = " + std::to_string(items_entry.focustype)); - update_values.push_back(columns[156] + " = " + std::to_string(items_entry.focuslevel2)); - update_values.push_back(columns[157] + " = " + std::to_string(items_entry.focuslevel)); - update_values.push_back(columns[158] + " = " + std::to_string(items_entry.UNK152)); - update_values.push_back(columns[159] + " = " + std::to_string(items_entry.scrolleffect)); - update_values.push_back(columns[160] + " = " + std::to_string(items_entry.scrolltype)); - update_values.push_back(columns[161] + " = " + std::to_string(items_entry.scrolllevel2)); - update_values.push_back(columns[162] + " = " + std::to_string(items_entry.scrolllevel)); - update_values.push_back(columns[163] + " = " + std::to_string(items_entry.UNK157)); - update_values.push_back(columns[164] + " = FROM_UNIXTIME(" + (items_entry.serialized > 0 ? std::to_string(items_entry.serialized) : "null") + ")"); - update_values.push_back(columns[165] + " = FROM_UNIXTIME(" + (items_entry.verified > 0 ? std::to_string(items_entry.verified) : "null") + ")"); - update_values.push_back(columns[166] + " = '" + Strings::Escape(items_entry.serialization) + "'"); - update_values.push_back(columns[167] + " = '" + Strings::Escape(items_entry.source) + "'"); - update_values.push_back(columns[168] + " = " + std::to_string(items_entry.UNK033)); - update_values.push_back(columns[169] + " = '" + Strings::Escape(items_entry.lorefile) + "'"); - update_values.push_back(columns[170] + " = " + std::to_string(items_entry.UNK014)); - update_values.push_back(columns[171] + " = " + std::to_string(items_entry.svcorruption)); - update_values.push_back(columns[172] + " = " + std::to_string(items_entry.skillmodmax)); - update_values.push_back(columns[173] + " = " + std::to_string(items_entry.UNK060)); - update_values.push_back(columns[174] + " = " + std::to_string(items_entry.augslot1unk2)); - update_values.push_back(columns[175] + " = " + std::to_string(items_entry.augslot2unk2)); - update_values.push_back(columns[176] + " = " + std::to_string(items_entry.augslot3unk2)); - update_values.push_back(columns[177] + " = " + std::to_string(items_entry.augslot4unk2)); - update_values.push_back(columns[178] + " = " + std::to_string(items_entry.augslot5unk2)); - update_values.push_back(columns[179] + " = " + std::to_string(items_entry.augslot6unk2)); - update_values.push_back(columns[180] + " = " + std::to_string(items_entry.UNK120)); - update_values.push_back(columns[181] + " = " + std::to_string(items_entry.UNK121)); - update_values.push_back(columns[182] + " = " + std::to_string(items_entry.questitemflag)); - update_values.push_back(columns[183] + " = '" + Strings::Escape(items_entry.UNK132) + "'"); - update_values.push_back(columns[184] + " = " + std::to_string(items_entry.clickunk5)); - update_values.push_back(columns[185] + " = '" + Strings::Escape(items_entry.clickunk6) + "'"); - update_values.push_back(columns[186] + " = " + std::to_string(items_entry.clickunk7)); - update_values.push_back(columns[187] + " = " + std::to_string(items_entry.procunk1)); - update_values.push_back(columns[188] + " = " + std::to_string(items_entry.procunk2)); - update_values.push_back(columns[189] + " = " + std::to_string(items_entry.procunk3)); - update_values.push_back(columns[190] + " = " + std::to_string(items_entry.procunk4)); - update_values.push_back(columns[191] + " = '" + Strings::Escape(items_entry.procunk6) + "'"); - update_values.push_back(columns[192] + " = " + std::to_string(items_entry.procunk7)); - update_values.push_back(columns[193] + " = " + std::to_string(items_entry.wornunk1)); - update_values.push_back(columns[194] + " = " + std::to_string(items_entry.wornunk2)); - update_values.push_back(columns[195] + " = " + std::to_string(items_entry.wornunk3)); - update_values.push_back(columns[196] + " = " + std::to_string(items_entry.wornunk4)); - update_values.push_back(columns[197] + " = " + std::to_string(items_entry.wornunk5)); - update_values.push_back(columns[198] + " = '" + Strings::Escape(items_entry.wornunk6) + "'"); - update_values.push_back(columns[199] + " = " + std::to_string(items_entry.wornunk7)); - update_values.push_back(columns[200] + " = " + std::to_string(items_entry.focusunk1)); - update_values.push_back(columns[201] + " = " + std::to_string(items_entry.focusunk2)); - update_values.push_back(columns[202] + " = " + std::to_string(items_entry.focusunk3)); - update_values.push_back(columns[203] + " = " + std::to_string(items_entry.focusunk4)); - update_values.push_back(columns[204] + " = " + std::to_string(items_entry.focusunk5)); - update_values.push_back(columns[205] + " = '" + Strings::Escape(items_entry.focusunk6) + "'"); - update_values.push_back(columns[206] + " = " + std::to_string(items_entry.focusunk7)); - update_values.push_back(columns[207] + " = " + std::to_string(items_entry.scrollunk1)); - update_values.push_back(columns[208] + " = " + std::to_string(items_entry.scrollunk2)); - update_values.push_back(columns[209] + " = " + std::to_string(items_entry.scrollunk3)); - update_values.push_back(columns[210] + " = " + std::to_string(items_entry.scrollunk4)); - update_values.push_back(columns[211] + " = " + std::to_string(items_entry.scrollunk5)); - update_values.push_back(columns[212] + " = '" + Strings::Escape(items_entry.scrollunk6) + "'"); - update_values.push_back(columns[213] + " = " + std::to_string(items_entry.scrollunk7)); - update_values.push_back(columns[214] + " = " + std::to_string(items_entry.UNK193)); - update_values.push_back(columns[215] + " = " + std::to_string(items_entry.purity)); - update_values.push_back(columns[216] + " = " + std::to_string(items_entry.evoitem)); - update_values.push_back(columns[217] + " = " + std::to_string(items_entry.evoid)); - update_values.push_back(columns[218] + " = " + std::to_string(items_entry.evolvinglevel)); - update_values.push_back(columns[219] + " = " + std::to_string(items_entry.evomax)); - update_values.push_back(columns[220] + " = '" + Strings::Escape(items_entry.clickname) + "'"); - update_values.push_back(columns[221] + " = '" + Strings::Escape(items_entry.procname) + "'"); - update_values.push_back(columns[222] + " = '" + Strings::Escape(items_entry.wornname) + "'"); - update_values.push_back(columns[223] + " = '" + Strings::Escape(items_entry.focusname) + "'"); - update_values.push_back(columns[224] + " = '" + Strings::Escape(items_entry.scrollname) + "'"); - update_values.push_back(columns[225] + " = " + std::to_string(items_entry.dsmitigation)); - update_values.push_back(columns[226] + " = " + std::to_string(items_entry.heroic_str)); - update_values.push_back(columns[227] + " = " + std::to_string(items_entry.heroic_int)); - update_values.push_back(columns[228] + " = " + std::to_string(items_entry.heroic_wis)); - update_values.push_back(columns[229] + " = " + std::to_string(items_entry.heroic_agi)); - update_values.push_back(columns[230] + " = " + std::to_string(items_entry.heroic_dex)); - update_values.push_back(columns[231] + " = " + std::to_string(items_entry.heroic_sta)); - update_values.push_back(columns[232] + " = " + std::to_string(items_entry.heroic_cha)); - update_values.push_back(columns[233] + " = " + std::to_string(items_entry.heroic_pr)); - update_values.push_back(columns[234] + " = " + std::to_string(items_entry.heroic_dr)); - update_values.push_back(columns[235] + " = " + std::to_string(items_entry.heroic_fr)); - update_values.push_back(columns[236] + " = " + std::to_string(items_entry.heroic_cr)); - update_values.push_back(columns[237] + " = " + std::to_string(items_entry.heroic_mr)); - update_values.push_back(columns[238] + " = " + std::to_string(items_entry.heroic_svcorrup)); - update_values.push_back(columns[239] + " = " + std::to_string(items_entry.healamt)); - update_values.push_back(columns[240] + " = " + std::to_string(items_entry.spelldmg)); - update_values.push_back(columns[241] + " = " + std::to_string(items_entry.clairvoyance)); - update_values.push_back(columns[242] + " = " + std::to_string(items_entry.backstabdmg)); - update_values.push_back(columns[243] + " = '" + Strings::Escape(items_entry.created) + "'"); - update_values.push_back(columns[244] + " = " + std::to_string(items_entry.elitematerial)); - update_values.push_back(columns[245] + " = " + std::to_string(items_entry.ldonsellbackrate)); - update_values.push_back(columns[246] + " = " + std::to_string(items_entry.scriptfileid)); - update_values.push_back(columns[247] + " = " + std::to_string(items_entry.expendablearrow)); - update_values.push_back(columns[248] + " = " + std::to_string(items_entry.powersourcecapacity)); - update_values.push_back(columns[249] + " = " + std::to_string(items_entry.bardeffect)); - update_values.push_back(columns[250] + " = " + std::to_string(items_entry.bardeffecttype)); - update_values.push_back(columns[251] + " = " + std::to_string(items_entry.bardlevel2)); - update_values.push_back(columns[252] + " = " + std::to_string(items_entry.bardlevel)); - update_values.push_back(columns[253] + " = " + std::to_string(items_entry.bardunk1)); - update_values.push_back(columns[254] + " = " + std::to_string(items_entry.bardunk2)); - update_values.push_back(columns[255] + " = " + std::to_string(items_entry.bardunk3)); - update_values.push_back(columns[256] + " = " + std::to_string(items_entry.bardunk4)); - update_values.push_back(columns[257] + " = " + std::to_string(items_entry.bardunk5)); - update_values.push_back(columns[258] + " = '" + Strings::Escape(items_entry.bardname) + "'"); - update_values.push_back(columns[259] + " = " + std::to_string(items_entry.bardunk7)); - update_values.push_back(columns[260] + " = " + std::to_string(items_entry.UNK214)); - update_values.push_back(columns[261] + " = " + std::to_string(items_entry.subtype)); - update_values.push_back(columns[262] + " = " + std::to_string(items_entry.UNK220)); - update_values.push_back(columns[263] + " = " + std::to_string(items_entry.UNK221)); - update_values.push_back(columns[264] + " = " + std::to_string(items_entry.heirloom)); - update_values.push_back(columns[265] + " = " + std::to_string(items_entry.UNK223)); - update_values.push_back(columns[266] + " = " + std::to_string(items_entry.UNK224)); - update_values.push_back(columns[267] + " = " + std::to_string(items_entry.UNK225)); - update_values.push_back(columns[268] + " = " + std::to_string(items_entry.UNK226)); - update_values.push_back(columns[269] + " = " + std::to_string(items_entry.UNK227)); - update_values.push_back(columns[270] + " = " + std::to_string(items_entry.UNK228)); - update_values.push_back(columns[271] + " = " + std::to_string(items_entry.UNK229)); - update_values.push_back(columns[272] + " = " + std::to_string(items_entry.UNK230)); - update_values.push_back(columns[273] + " = " + std::to_string(items_entry.UNK231)); - update_values.push_back(columns[274] + " = " + std::to_string(items_entry.UNK232)); - update_values.push_back(columns[275] + " = " + std::to_string(items_entry.UNK233)); - update_values.push_back(columns[276] + " = " + std::to_string(items_entry.UNK234)); - update_values.push_back(columns[277] + " = " + std::to_string(items_entry.placeable)); - update_values.push_back(columns[278] + " = " + std::to_string(items_entry.UNK236)); - update_values.push_back(columns[279] + " = " + std::to_string(items_entry.UNK237)); - update_values.push_back(columns[280] + " = " + std::to_string(items_entry.UNK238)); - update_values.push_back(columns[281] + " = " + std::to_string(items_entry.UNK239)); - update_values.push_back(columns[282] + " = " + std::to_string(items_entry.UNK240)); - update_values.push_back(columns[283] + " = " + std::to_string(items_entry.UNK241)); - update_values.push_back(columns[284] + " = " + std::to_string(items_entry.epicitem)); + v.push_back(columns[0] + " = " + std::to_string(e.id)); + v.push_back(columns[1] + " = " + std::to_string(e.minstatus)); + v.push_back(columns[2] + " = '" + Strings::Escape(e.Name) + "'"); + v.push_back(columns[3] + " = " + std::to_string(e.aagi)); + v.push_back(columns[4] + " = " + std::to_string(e.ac)); + v.push_back(columns[5] + " = " + std::to_string(e.accuracy)); + v.push_back(columns[6] + " = " + std::to_string(e.acha)); + v.push_back(columns[7] + " = " + std::to_string(e.adex)); + v.push_back(columns[8] + " = " + std::to_string(e.aint)); + v.push_back(columns[9] + " = " + std::to_string(e.artifactflag)); + v.push_back(columns[10] + " = " + std::to_string(e.asta)); + v.push_back(columns[11] + " = " + std::to_string(e.astr)); + v.push_back(columns[12] + " = " + std::to_string(e.attack)); + v.push_back(columns[13] + " = " + std::to_string(e.augrestrict)); + v.push_back(columns[14] + " = " + std::to_string(e.augslot1type)); + v.push_back(columns[15] + " = " + std::to_string(e.augslot1visible)); + v.push_back(columns[16] + " = " + std::to_string(e.augslot2type)); + v.push_back(columns[17] + " = " + std::to_string(e.augslot2visible)); + v.push_back(columns[18] + " = " + std::to_string(e.augslot3type)); + v.push_back(columns[19] + " = " + std::to_string(e.augslot3visible)); + v.push_back(columns[20] + " = " + std::to_string(e.augslot4type)); + v.push_back(columns[21] + " = " + std::to_string(e.augslot4visible)); + v.push_back(columns[22] + " = " + std::to_string(e.augslot5type)); + v.push_back(columns[23] + " = " + std::to_string(e.augslot5visible)); + v.push_back(columns[24] + " = " + std::to_string(e.augslot6type)); + v.push_back(columns[25] + " = " + std::to_string(e.augslot6visible)); + v.push_back(columns[26] + " = " + std::to_string(e.augtype)); + v.push_back(columns[27] + " = " + std::to_string(e.avoidance)); + v.push_back(columns[28] + " = " + std::to_string(e.awis)); + v.push_back(columns[29] + " = " + std::to_string(e.bagsize)); + v.push_back(columns[30] + " = " + std::to_string(e.bagslots)); + v.push_back(columns[31] + " = " + std::to_string(e.bagtype)); + v.push_back(columns[32] + " = " + std::to_string(e.bagwr)); + v.push_back(columns[33] + " = " + std::to_string(e.banedmgamt)); + v.push_back(columns[34] + " = " + std::to_string(e.banedmgraceamt)); + v.push_back(columns[35] + " = " + std::to_string(e.banedmgbody)); + v.push_back(columns[36] + " = " + std::to_string(e.banedmgrace)); + v.push_back(columns[37] + " = " + std::to_string(e.bardtype)); + v.push_back(columns[38] + " = " + std::to_string(e.bardvalue)); + v.push_back(columns[39] + " = " + std::to_string(e.book)); + v.push_back(columns[40] + " = " + std::to_string(e.casttime)); + v.push_back(columns[41] + " = " + std::to_string(e.casttime_)); + v.push_back(columns[42] + " = '" + Strings::Escape(e.charmfile) + "'"); + v.push_back(columns[43] + " = '" + Strings::Escape(e.charmfileid) + "'"); + v.push_back(columns[44] + " = " + std::to_string(e.classes)); + v.push_back(columns[45] + " = " + std::to_string(e.color)); + v.push_back(columns[46] + " = '" + Strings::Escape(e.combateffects) + "'"); + v.push_back(columns[47] + " = " + std::to_string(e.extradmgskill)); + v.push_back(columns[48] + " = " + std::to_string(e.extradmgamt)); + v.push_back(columns[49] + " = " + std::to_string(e.price)); + v.push_back(columns[50] + " = " + std::to_string(e.cr)); + v.push_back(columns[51] + " = " + std::to_string(e.damage)); + v.push_back(columns[52] + " = " + std::to_string(e.damageshield)); + v.push_back(columns[53] + " = " + std::to_string(e.deity)); + v.push_back(columns[54] + " = " + std::to_string(e.delay)); + v.push_back(columns[55] + " = " + std::to_string(e.augdistiller)); + v.push_back(columns[56] + " = " + std::to_string(e.dotshielding)); + v.push_back(columns[57] + " = " + std::to_string(e.dr)); + v.push_back(columns[58] + " = " + std::to_string(e.clicktype)); + v.push_back(columns[59] + " = " + std::to_string(e.clicklevel2)); + v.push_back(columns[60] + " = " + std::to_string(e.elemdmgtype)); + v.push_back(columns[61] + " = " + std::to_string(e.elemdmgamt)); + v.push_back(columns[62] + " = " + std::to_string(e.endur)); + v.push_back(columns[63] + " = " + std::to_string(e.factionamt1)); + v.push_back(columns[64] + " = " + std::to_string(e.factionamt2)); + v.push_back(columns[65] + " = " + std::to_string(e.factionamt3)); + v.push_back(columns[66] + " = " + std::to_string(e.factionamt4)); + v.push_back(columns[67] + " = " + std::to_string(e.factionmod1)); + v.push_back(columns[68] + " = " + std::to_string(e.factionmod2)); + v.push_back(columns[69] + " = " + std::to_string(e.factionmod3)); + v.push_back(columns[70] + " = " + std::to_string(e.factionmod4)); + v.push_back(columns[71] + " = '" + Strings::Escape(e.filename) + "'"); + v.push_back(columns[72] + " = " + std::to_string(e.focuseffect)); + v.push_back(columns[73] + " = " + std::to_string(e.fr)); + v.push_back(columns[74] + " = " + std::to_string(e.fvnodrop)); + v.push_back(columns[75] + " = " + std::to_string(e.haste)); + v.push_back(columns[76] + " = " + std::to_string(e.clicklevel)); + v.push_back(columns[77] + " = " + std::to_string(e.hp)); + v.push_back(columns[78] + " = " + std::to_string(e.regen)); + v.push_back(columns[79] + " = " + std::to_string(e.icon)); + v.push_back(columns[80] + " = '" + Strings::Escape(e.idfile) + "'"); + v.push_back(columns[81] + " = " + std::to_string(e.itemclass)); + v.push_back(columns[82] + " = " + std::to_string(e.itemtype)); + v.push_back(columns[83] + " = " + std::to_string(e.ldonprice)); + v.push_back(columns[84] + " = " + std::to_string(e.ldontheme)); + v.push_back(columns[85] + " = " + std::to_string(e.ldonsold)); + v.push_back(columns[86] + " = " + std::to_string(e.light)); + v.push_back(columns[87] + " = '" + Strings::Escape(e.lore) + "'"); + v.push_back(columns[88] + " = " + std::to_string(e.loregroup)); + v.push_back(columns[89] + " = " + std::to_string(e.magic)); + v.push_back(columns[90] + " = " + std::to_string(e.mana)); + v.push_back(columns[91] + " = " + std::to_string(e.manaregen)); + v.push_back(columns[92] + " = " + std::to_string(e.enduranceregen)); + v.push_back(columns[93] + " = " + std::to_string(e.material)); + v.push_back(columns[94] + " = " + std::to_string(e.herosforgemodel)); + v.push_back(columns[95] + " = " + std::to_string(e.maxcharges)); + v.push_back(columns[96] + " = " + std::to_string(e.mr)); + v.push_back(columns[97] + " = " + std::to_string(e.nodrop)); + v.push_back(columns[98] + " = " + std::to_string(e.norent)); + v.push_back(columns[99] + " = " + std::to_string(e.pendingloreflag)); + v.push_back(columns[100] + " = " + std::to_string(e.pr)); + v.push_back(columns[101] + " = " + std::to_string(e.procrate)); + v.push_back(columns[102] + " = " + std::to_string(e.races)); + v.push_back(columns[103] + " = " + std::to_string(e.range)); + v.push_back(columns[104] + " = " + std::to_string(e.reclevel)); + v.push_back(columns[105] + " = " + std::to_string(e.recskill)); + v.push_back(columns[106] + " = " + std::to_string(e.reqlevel)); + v.push_back(columns[107] + " = " + std::to_string(e.sellrate)); + v.push_back(columns[108] + " = " + std::to_string(e.shielding)); + v.push_back(columns[109] + " = " + std::to_string(e.size)); + v.push_back(columns[110] + " = " + std::to_string(e.skillmodtype)); + v.push_back(columns[111] + " = " + std::to_string(e.skillmodvalue)); + v.push_back(columns[112] + " = " + std::to_string(e.slots)); + v.push_back(columns[113] + " = " + std::to_string(e.clickeffect)); + v.push_back(columns[114] + " = " + std::to_string(e.spellshield)); + v.push_back(columns[115] + " = " + std::to_string(e.strikethrough)); + v.push_back(columns[116] + " = " + std::to_string(e.stunresist)); + v.push_back(columns[117] + " = " + std::to_string(e.summonedflag)); + v.push_back(columns[118] + " = " + std::to_string(e.tradeskills)); + v.push_back(columns[119] + " = " + std::to_string(e.favor)); + v.push_back(columns[120] + " = " + std::to_string(e.weight)); + v.push_back(columns[121] + " = " + std::to_string(e.UNK012)); + v.push_back(columns[122] + " = " + std::to_string(e.UNK013)); + v.push_back(columns[123] + " = " + std::to_string(e.benefitflag)); + v.push_back(columns[124] + " = " + std::to_string(e.UNK054)); + v.push_back(columns[125] + " = " + std::to_string(e.UNK059)); + v.push_back(columns[126] + " = " + std::to_string(e.booktype)); + v.push_back(columns[127] + " = " + std::to_string(e.recastdelay)); + v.push_back(columns[128] + " = " + std::to_string(e.recasttype)); + v.push_back(columns[129] + " = " + std::to_string(e.guildfavor)); + v.push_back(columns[130] + " = " + std::to_string(e.UNK123)); + v.push_back(columns[131] + " = " + std::to_string(e.UNK124)); + v.push_back(columns[132] + " = " + std::to_string(e.attuneable)); + v.push_back(columns[133] + " = " + std::to_string(e.nopet)); + v.push_back(columns[134] + " = FROM_UNIXTIME(" + (e.updated > 0 ? std::to_string(e.updated) : "null") + ")"); + v.push_back(columns[135] + " = '" + Strings::Escape(e.comment) + "'"); + v.push_back(columns[136] + " = " + std::to_string(e.UNK127)); + v.push_back(columns[137] + " = " + std::to_string(e.pointtype)); + v.push_back(columns[138] + " = " + std::to_string(e.potionbelt)); + v.push_back(columns[139] + " = " + std::to_string(e.potionbeltslots)); + v.push_back(columns[140] + " = " + std::to_string(e.stacksize)); + v.push_back(columns[141] + " = " + std::to_string(e.notransfer)); + v.push_back(columns[142] + " = " + std::to_string(e.stackable)); + v.push_back(columns[143] + " = '" + Strings::Escape(e.UNK134) + "'"); + v.push_back(columns[144] + " = " + std::to_string(e.UNK137)); + v.push_back(columns[145] + " = " + std::to_string(e.proceffect)); + v.push_back(columns[146] + " = " + std::to_string(e.proctype)); + v.push_back(columns[147] + " = " + std::to_string(e.proclevel2)); + v.push_back(columns[148] + " = " + std::to_string(e.proclevel)); + v.push_back(columns[149] + " = " + std::to_string(e.UNK142)); + v.push_back(columns[150] + " = " + std::to_string(e.worneffect)); + v.push_back(columns[151] + " = " + std::to_string(e.worntype)); + v.push_back(columns[152] + " = " + std::to_string(e.wornlevel2)); + v.push_back(columns[153] + " = " + std::to_string(e.wornlevel)); + v.push_back(columns[154] + " = " + std::to_string(e.UNK147)); + v.push_back(columns[155] + " = " + std::to_string(e.focustype)); + v.push_back(columns[156] + " = " + std::to_string(e.focuslevel2)); + v.push_back(columns[157] + " = " + std::to_string(e.focuslevel)); + v.push_back(columns[158] + " = " + std::to_string(e.UNK152)); + v.push_back(columns[159] + " = " + std::to_string(e.scrolleffect)); + v.push_back(columns[160] + " = " + std::to_string(e.scrolltype)); + v.push_back(columns[161] + " = " + std::to_string(e.scrolllevel2)); + v.push_back(columns[162] + " = " + std::to_string(e.scrolllevel)); + v.push_back(columns[163] + " = " + std::to_string(e.UNK157)); + v.push_back(columns[164] + " = FROM_UNIXTIME(" + (e.serialized > 0 ? std::to_string(e.serialized) : "null") + ")"); + v.push_back(columns[165] + " = FROM_UNIXTIME(" + (e.verified > 0 ? std::to_string(e.verified) : "null") + ")"); + v.push_back(columns[166] + " = '" + Strings::Escape(e.serialization) + "'"); + v.push_back(columns[167] + " = '" + Strings::Escape(e.source) + "'"); + v.push_back(columns[168] + " = " + std::to_string(e.UNK033)); + v.push_back(columns[169] + " = '" + Strings::Escape(e.lorefile) + "'"); + v.push_back(columns[170] + " = " + std::to_string(e.UNK014)); + v.push_back(columns[171] + " = " + std::to_string(e.svcorruption)); + v.push_back(columns[172] + " = " + std::to_string(e.skillmodmax)); + v.push_back(columns[173] + " = " + std::to_string(e.UNK060)); + v.push_back(columns[174] + " = " + std::to_string(e.augslot1unk2)); + v.push_back(columns[175] + " = " + std::to_string(e.augslot2unk2)); + v.push_back(columns[176] + " = " + std::to_string(e.augslot3unk2)); + v.push_back(columns[177] + " = " + std::to_string(e.augslot4unk2)); + v.push_back(columns[178] + " = " + std::to_string(e.augslot5unk2)); + v.push_back(columns[179] + " = " + std::to_string(e.augslot6unk2)); + v.push_back(columns[180] + " = " + std::to_string(e.UNK120)); + v.push_back(columns[181] + " = " + std::to_string(e.UNK121)); + v.push_back(columns[182] + " = " + std::to_string(e.questitemflag)); + v.push_back(columns[183] + " = '" + Strings::Escape(e.UNK132) + "'"); + v.push_back(columns[184] + " = " + std::to_string(e.clickunk5)); + v.push_back(columns[185] + " = '" + Strings::Escape(e.clickunk6) + "'"); + v.push_back(columns[186] + " = " + std::to_string(e.clickunk7)); + v.push_back(columns[187] + " = " + std::to_string(e.procunk1)); + v.push_back(columns[188] + " = " + std::to_string(e.procunk2)); + v.push_back(columns[189] + " = " + std::to_string(e.procunk3)); + v.push_back(columns[190] + " = " + std::to_string(e.procunk4)); + v.push_back(columns[191] + " = '" + Strings::Escape(e.procunk6) + "'"); + v.push_back(columns[192] + " = " + std::to_string(e.procunk7)); + v.push_back(columns[193] + " = " + std::to_string(e.wornunk1)); + v.push_back(columns[194] + " = " + std::to_string(e.wornunk2)); + v.push_back(columns[195] + " = " + std::to_string(e.wornunk3)); + v.push_back(columns[196] + " = " + std::to_string(e.wornunk4)); + v.push_back(columns[197] + " = " + std::to_string(e.wornunk5)); + v.push_back(columns[198] + " = '" + Strings::Escape(e.wornunk6) + "'"); + v.push_back(columns[199] + " = " + std::to_string(e.wornunk7)); + v.push_back(columns[200] + " = " + std::to_string(e.focusunk1)); + v.push_back(columns[201] + " = " + std::to_string(e.focusunk2)); + v.push_back(columns[202] + " = " + std::to_string(e.focusunk3)); + v.push_back(columns[203] + " = " + std::to_string(e.focusunk4)); + v.push_back(columns[204] + " = " + std::to_string(e.focusunk5)); + v.push_back(columns[205] + " = '" + Strings::Escape(e.focusunk6) + "'"); + v.push_back(columns[206] + " = " + std::to_string(e.focusunk7)); + v.push_back(columns[207] + " = " + std::to_string(e.scrollunk1)); + v.push_back(columns[208] + " = " + std::to_string(e.scrollunk2)); + v.push_back(columns[209] + " = " + std::to_string(e.scrollunk3)); + v.push_back(columns[210] + " = " + std::to_string(e.scrollunk4)); + v.push_back(columns[211] + " = " + std::to_string(e.scrollunk5)); + v.push_back(columns[212] + " = '" + Strings::Escape(e.scrollunk6) + "'"); + v.push_back(columns[213] + " = " + std::to_string(e.scrollunk7)); + v.push_back(columns[214] + " = " + std::to_string(e.UNK193)); + v.push_back(columns[215] + " = " + std::to_string(e.purity)); + v.push_back(columns[216] + " = " + std::to_string(e.evoitem)); + v.push_back(columns[217] + " = " + std::to_string(e.evoid)); + v.push_back(columns[218] + " = " + std::to_string(e.evolvinglevel)); + v.push_back(columns[219] + " = " + std::to_string(e.evomax)); + v.push_back(columns[220] + " = '" + Strings::Escape(e.clickname) + "'"); + v.push_back(columns[221] + " = '" + Strings::Escape(e.procname) + "'"); + v.push_back(columns[222] + " = '" + Strings::Escape(e.wornname) + "'"); + v.push_back(columns[223] + " = '" + Strings::Escape(e.focusname) + "'"); + v.push_back(columns[224] + " = '" + Strings::Escape(e.scrollname) + "'"); + v.push_back(columns[225] + " = " + std::to_string(e.dsmitigation)); + v.push_back(columns[226] + " = " + std::to_string(e.heroic_str)); + v.push_back(columns[227] + " = " + std::to_string(e.heroic_int)); + v.push_back(columns[228] + " = " + std::to_string(e.heroic_wis)); + v.push_back(columns[229] + " = " + std::to_string(e.heroic_agi)); + v.push_back(columns[230] + " = " + std::to_string(e.heroic_dex)); + v.push_back(columns[231] + " = " + std::to_string(e.heroic_sta)); + v.push_back(columns[232] + " = " + std::to_string(e.heroic_cha)); + v.push_back(columns[233] + " = " + std::to_string(e.heroic_pr)); + v.push_back(columns[234] + " = " + std::to_string(e.heroic_dr)); + v.push_back(columns[235] + " = " + std::to_string(e.heroic_fr)); + v.push_back(columns[236] + " = " + std::to_string(e.heroic_cr)); + v.push_back(columns[237] + " = " + std::to_string(e.heroic_mr)); + v.push_back(columns[238] + " = " + std::to_string(e.heroic_svcorrup)); + v.push_back(columns[239] + " = " + std::to_string(e.healamt)); + v.push_back(columns[240] + " = " + std::to_string(e.spelldmg)); + v.push_back(columns[241] + " = " + std::to_string(e.clairvoyance)); + v.push_back(columns[242] + " = " + std::to_string(e.backstabdmg)); + v.push_back(columns[243] + " = '" + Strings::Escape(e.created) + "'"); + v.push_back(columns[244] + " = " + std::to_string(e.elitematerial)); + v.push_back(columns[245] + " = " + std::to_string(e.ldonsellbackrate)); + v.push_back(columns[246] + " = " + std::to_string(e.scriptfileid)); + v.push_back(columns[247] + " = " + std::to_string(e.expendablearrow)); + v.push_back(columns[248] + " = " + std::to_string(e.powersourcecapacity)); + v.push_back(columns[249] + " = " + std::to_string(e.bardeffect)); + v.push_back(columns[250] + " = " + std::to_string(e.bardeffecttype)); + v.push_back(columns[251] + " = " + std::to_string(e.bardlevel2)); + v.push_back(columns[252] + " = " + std::to_string(e.bardlevel)); + v.push_back(columns[253] + " = " + std::to_string(e.bardunk1)); + v.push_back(columns[254] + " = " + std::to_string(e.bardunk2)); + v.push_back(columns[255] + " = " + std::to_string(e.bardunk3)); + v.push_back(columns[256] + " = " + std::to_string(e.bardunk4)); + v.push_back(columns[257] + " = " + std::to_string(e.bardunk5)); + v.push_back(columns[258] + " = '" + Strings::Escape(e.bardname) + "'"); + v.push_back(columns[259] + " = " + std::to_string(e.bardunk7)); + v.push_back(columns[260] + " = " + std::to_string(e.UNK214)); + v.push_back(columns[261] + " = " + std::to_string(e.subtype)); + v.push_back(columns[262] + " = " + std::to_string(e.UNK220)); + v.push_back(columns[263] + " = " + std::to_string(e.UNK221)); + v.push_back(columns[264] + " = " + std::to_string(e.heirloom)); + v.push_back(columns[265] + " = " + std::to_string(e.UNK223)); + v.push_back(columns[266] + " = " + std::to_string(e.UNK224)); + v.push_back(columns[267] + " = " + std::to_string(e.UNK225)); + v.push_back(columns[268] + " = " + std::to_string(e.UNK226)); + v.push_back(columns[269] + " = " + std::to_string(e.UNK227)); + v.push_back(columns[270] + " = " + std::to_string(e.UNK228)); + v.push_back(columns[271] + " = " + std::to_string(e.UNK229)); + v.push_back(columns[272] + " = " + std::to_string(e.UNK230)); + v.push_back(columns[273] + " = " + std::to_string(e.UNK231)); + v.push_back(columns[274] + " = " + std::to_string(e.UNK232)); + v.push_back(columns[275] + " = " + std::to_string(e.UNK233)); + v.push_back(columns[276] + " = " + std::to_string(e.UNK234)); + v.push_back(columns[277] + " = " + std::to_string(e.placeable)); + v.push_back(columns[278] + " = " + std::to_string(e.UNK236)); + v.push_back(columns[279] + " = " + std::to_string(e.UNK237)); + v.push_back(columns[280] + " = " + std::to_string(e.UNK238)); + v.push_back(columns[281] + " = " + std::to_string(e.UNK239)); + v.push_back(columns[282] + " = " + std::to_string(e.UNK240)); + v.push_back(columns[283] + " = " + std::to_string(e.UNK241)); + v.push_back(columns[284] + " = " + std::to_string(e.epicitem)); auto results = db.QueryDatabase( fmt::format( "UPDATE {} SET {} WHERE {} = {}", TableName(), - Strings::Implode(", ", update_values), + Strings::Implode(", ", v), PrimaryKey(), - items_entry.id + e.id ) ); @@ -1869,615 +1869,615 @@ public: static Items InsertOne( Database& db, - Items items_entry + Items e ) { - std::vector insert_values; + std::vector v; - insert_values.push_back(std::to_string(items_entry.id)); - insert_values.push_back(std::to_string(items_entry.minstatus)); - insert_values.push_back("'" + Strings::Escape(items_entry.Name) + "'"); - insert_values.push_back(std::to_string(items_entry.aagi)); - insert_values.push_back(std::to_string(items_entry.ac)); - insert_values.push_back(std::to_string(items_entry.accuracy)); - insert_values.push_back(std::to_string(items_entry.acha)); - insert_values.push_back(std::to_string(items_entry.adex)); - insert_values.push_back(std::to_string(items_entry.aint)); - insert_values.push_back(std::to_string(items_entry.artifactflag)); - insert_values.push_back(std::to_string(items_entry.asta)); - insert_values.push_back(std::to_string(items_entry.astr)); - insert_values.push_back(std::to_string(items_entry.attack)); - insert_values.push_back(std::to_string(items_entry.augrestrict)); - insert_values.push_back(std::to_string(items_entry.augslot1type)); - insert_values.push_back(std::to_string(items_entry.augslot1visible)); - insert_values.push_back(std::to_string(items_entry.augslot2type)); - insert_values.push_back(std::to_string(items_entry.augslot2visible)); - insert_values.push_back(std::to_string(items_entry.augslot3type)); - insert_values.push_back(std::to_string(items_entry.augslot3visible)); - insert_values.push_back(std::to_string(items_entry.augslot4type)); - insert_values.push_back(std::to_string(items_entry.augslot4visible)); - insert_values.push_back(std::to_string(items_entry.augslot5type)); - insert_values.push_back(std::to_string(items_entry.augslot5visible)); - insert_values.push_back(std::to_string(items_entry.augslot6type)); - insert_values.push_back(std::to_string(items_entry.augslot6visible)); - insert_values.push_back(std::to_string(items_entry.augtype)); - insert_values.push_back(std::to_string(items_entry.avoidance)); - insert_values.push_back(std::to_string(items_entry.awis)); - insert_values.push_back(std::to_string(items_entry.bagsize)); - insert_values.push_back(std::to_string(items_entry.bagslots)); - insert_values.push_back(std::to_string(items_entry.bagtype)); - insert_values.push_back(std::to_string(items_entry.bagwr)); - insert_values.push_back(std::to_string(items_entry.banedmgamt)); - insert_values.push_back(std::to_string(items_entry.banedmgraceamt)); - insert_values.push_back(std::to_string(items_entry.banedmgbody)); - insert_values.push_back(std::to_string(items_entry.banedmgrace)); - insert_values.push_back(std::to_string(items_entry.bardtype)); - insert_values.push_back(std::to_string(items_entry.bardvalue)); - insert_values.push_back(std::to_string(items_entry.book)); - insert_values.push_back(std::to_string(items_entry.casttime)); - insert_values.push_back(std::to_string(items_entry.casttime_)); - insert_values.push_back("'" + Strings::Escape(items_entry.charmfile) + "'"); - insert_values.push_back("'" + Strings::Escape(items_entry.charmfileid) + "'"); - insert_values.push_back(std::to_string(items_entry.classes)); - insert_values.push_back(std::to_string(items_entry.color)); - insert_values.push_back("'" + Strings::Escape(items_entry.combateffects) + "'"); - insert_values.push_back(std::to_string(items_entry.extradmgskill)); - insert_values.push_back(std::to_string(items_entry.extradmgamt)); - insert_values.push_back(std::to_string(items_entry.price)); - insert_values.push_back(std::to_string(items_entry.cr)); - insert_values.push_back(std::to_string(items_entry.damage)); - insert_values.push_back(std::to_string(items_entry.damageshield)); - insert_values.push_back(std::to_string(items_entry.deity)); - insert_values.push_back(std::to_string(items_entry.delay)); - insert_values.push_back(std::to_string(items_entry.augdistiller)); - insert_values.push_back(std::to_string(items_entry.dotshielding)); - insert_values.push_back(std::to_string(items_entry.dr)); - insert_values.push_back(std::to_string(items_entry.clicktype)); - insert_values.push_back(std::to_string(items_entry.clicklevel2)); - insert_values.push_back(std::to_string(items_entry.elemdmgtype)); - insert_values.push_back(std::to_string(items_entry.elemdmgamt)); - insert_values.push_back(std::to_string(items_entry.endur)); - insert_values.push_back(std::to_string(items_entry.factionamt1)); - insert_values.push_back(std::to_string(items_entry.factionamt2)); - insert_values.push_back(std::to_string(items_entry.factionamt3)); - insert_values.push_back(std::to_string(items_entry.factionamt4)); - insert_values.push_back(std::to_string(items_entry.factionmod1)); - insert_values.push_back(std::to_string(items_entry.factionmod2)); - insert_values.push_back(std::to_string(items_entry.factionmod3)); - insert_values.push_back(std::to_string(items_entry.factionmod4)); - insert_values.push_back("'" + Strings::Escape(items_entry.filename) + "'"); - insert_values.push_back(std::to_string(items_entry.focuseffect)); - insert_values.push_back(std::to_string(items_entry.fr)); - insert_values.push_back(std::to_string(items_entry.fvnodrop)); - insert_values.push_back(std::to_string(items_entry.haste)); - insert_values.push_back(std::to_string(items_entry.clicklevel)); - insert_values.push_back(std::to_string(items_entry.hp)); - insert_values.push_back(std::to_string(items_entry.regen)); - insert_values.push_back(std::to_string(items_entry.icon)); - insert_values.push_back("'" + Strings::Escape(items_entry.idfile) + "'"); - insert_values.push_back(std::to_string(items_entry.itemclass)); - insert_values.push_back(std::to_string(items_entry.itemtype)); - insert_values.push_back(std::to_string(items_entry.ldonprice)); - insert_values.push_back(std::to_string(items_entry.ldontheme)); - insert_values.push_back(std::to_string(items_entry.ldonsold)); - insert_values.push_back(std::to_string(items_entry.light)); - insert_values.push_back("'" + Strings::Escape(items_entry.lore) + "'"); - insert_values.push_back(std::to_string(items_entry.loregroup)); - insert_values.push_back(std::to_string(items_entry.magic)); - insert_values.push_back(std::to_string(items_entry.mana)); - insert_values.push_back(std::to_string(items_entry.manaregen)); - insert_values.push_back(std::to_string(items_entry.enduranceregen)); - insert_values.push_back(std::to_string(items_entry.material)); - insert_values.push_back(std::to_string(items_entry.herosforgemodel)); - insert_values.push_back(std::to_string(items_entry.maxcharges)); - insert_values.push_back(std::to_string(items_entry.mr)); - insert_values.push_back(std::to_string(items_entry.nodrop)); - insert_values.push_back(std::to_string(items_entry.norent)); - insert_values.push_back(std::to_string(items_entry.pendingloreflag)); - insert_values.push_back(std::to_string(items_entry.pr)); - insert_values.push_back(std::to_string(items_entry.procrate)); - insert_values.push_back(std::to_string(items_entry.races)); - insert_values.push_back(std::to_string(items_entry.range)); - insert_values.push_back(std::to_string(items_entry.reclevel)); - insert_values.push_back(std::to_string(items_entry.recskill)); - insert_values.push_back(std::to_string(items_entry.reqlevel)); - insert_values.push_back(std::to_string(items_entry.sellrate)); - insert_values.push_back(std::to_string(items_entry.shielding)); - insert_values.push_back(std::to_string(items_entry.size)); - insert_values.push_back(std::to_string(items_entry.skillmodtype)); - insert_values.push_back(std::to_string(items_entry.skillmodvalue)); - insert_values.push_back(std::to_string(items_entry.slots)); - insert_values.push_back(std::to_string(items_entry.clickeffect)); - insert_values.push_back(std::to_string(items_entry.spellshield)); - insert_values.push_back(std::to_string(items_entry.strikethrough)); - insert_values.push_back(std::to_string(items_entry.stunresist)); - insert_values.push_back(std::to_string(items_entry.summonedflag)); - insert_values.push_back(std::to_string(items_entry.tradeskills)); - insert_values.push_back(std::to_string(items_entry.favor)); - insert_values.push_back(std::to_string(items_entry.weight)); - insert_values.push_back(std::to_string(items_entry.UNK012)); - insert_values.push_back(std::to_string(items_entry.UNK013)); - insert_values.push_back(std::to_string(items_entry.benefitflag)); - insert_values.push_back(std::to_string(items_entry.UNK054)); - insert_values.push_back(std::to_string(items_entry.UNK059)); - insert_values.push_back(std::to_string(items_entry.booktype)); - insert_values.push_back(std::to_string(items_entry.recastdelay)); - insert_values.push_back(std::to_string(items_entry.recasttype)); - insert_values.push_back(std::to_string(items_entry.guildfavor)); - insert_values.push_back(std::to_string(items_entry.UNK123)); - insert_values.push_back(std::to_string(items_entry.UNK124)); - insert_values.push_back(std::to_string(items_entry.attuneable)); - insert_values.push_back(std::to_string(items_entry.nopet)); - insert_values.push_back("FROM_UNIXTIME(" + (items_entry.updated > 0 ? std::to_string(items_entry.updated) : "null") + ")"); - insert_values.push_back("'" + Strings::Escape(items_entry.comment) + "'"); - insert_values.push_back(std::to_string(items_entry.UNK127)); - insert_values.push_back(std::to_string(items_entry.pointtype)); - insert_values.push_back(std::to_string(items_entry.potionbelt)); - insert_values.push_back(std::to_string(items_entry.potionbeltslots)); - insert_values.push_back(std::to_string(items_entry.stacksize)); - insert_values.push_back(std::to_string(items_entry.notransfer)); - insert_values.push_back(std::to_string(items_entry.stackable)); - insert_values.push_back("'" + Strings::Escape(items_entry.UNK134) + "'"); - insert_values.push_back(std::to_string(items_entry.UNK137)); - insert_values.push_back(std::to_string(items_entry.proceffect)); - insert_values.push_back(std::to_string(items_entry.proctype)); - insert_values.push_back(std::to_string(items_entry.proclevel2)); - insert_values.push_back(std::to_string(items_entry.proclevel)); - insert_values.push_back(std::to_string(items_entry.UNK142)); - insert_values.push_back(std::to_string(items_entry.worneffect)); - insert_values.push_back(std::to_string(items_entry.worntype)); - insert_values.push_back(std::to_string(items_entry.wornlevel2)); - insert_values.push_back(std::to_string(items_entry.wornlevel)); - insert_values.push_back(std::to_string(items_entry.UNK147)); - insert_values.push_back(std::to_string(items_entry.focustype)); - insert_values.push_back(std::to_string(items_entry.focuslevel2)); - insert_values.push_back(std::to_string(items_entry.focuslevel)); - insert_values.push_back(std::to_string(items_entry.UNK152)); - insert_values.push_back(std::to_string(items_entry.scrolleffect)); - insert_values.push_back(std::to_string(items_entry.scrolltype)); - insert_values.push_back(std::to_string(items_entry.scrolllevel2)); - insert_values.push_back(std::to_string(items_entry.scrolllevel)); - insert_values.push_back(std::to_string(items_entry.UNK157)); - insert_values.push_back("FROM_UNIXTIME(" + (items_entry.serialized > 0 ? std::to_string(items_entry.serialized) : "null") + ")"); - insert_values.push_back("FROM_UNIXTIME(" + (items_entry.verified > 0 ? std::to_string(items_entry.verified) : "null") + ")"); - insert_values.push_back("'" + Strings::Escape(items_entry.serialization) + "'"); - insert_values.push_back("'" + Strings::Escape(items_entry.source) + "'"); - insert_values.push_back(std::to_string(items_entry.UNK033)); - insert_values.push_back("'" + Strings::Escape(items_entry.lorefile) + "'"); - insert_values.push_back(std::to_string(items_entry.UNK014)); - insert_values.push_back(std::to_string(items_entry.svcorruption)); - insert_values.push_back(std::to_string(items_entry.skillmodmax)); - insert_values.push_back(std::to_string(items_entry.UNK060)); - insert_values.push_back(std::to_string(items_entry.augslot1unk2)); - insert_values.push_back(std::to_string(items_entry.augslot2unk2)); - insert_values.push_back(std::to_string(items_entry.augslot3unk2)); - insert_values.push_back(std::to_string(items_entry.augslot4unk2)); - insert_values.push_back(std::to_string(items_entry.augslot5unk2)); - insert_values.push_back(std::to_string(items_entry.augslot6unk2)); - insert_values.push_back(std::to_string(items_entry.UNK120)); - insert_values.push_back(std::to_string(items_entry.UNK121)); - insert_values.push_back(std::to_string(items_entry.questitemflag)); - insert_values.push_back("'" + Strings::Escape(items_entry.UNK132) + "'"); - insert_values.push_back(std::to_string(items_entry.clickunk5)); - insert_values.push_back("'" + Strings::Escape(items_entry.clickunk6) + "'"); - insert_values.push_back(std::to_string(items_entry.clickunk7)); - insert_values.push_back(std::to_string(items_entry.procunk1)); - insert_values.push_back(std::to_string(items_entry.procunk2)); - insert_values.push_back(std::to_string(items_entry.procunk3)); - insert_values.push_back(std::to_string(items_entry.procunk4)); - insert_values.push_back("'" + Strings::Escape(items_entry.procunk6) + "'"); - insert_values.push_back(std::to_string(items_entry.procunk7)); - insert_values.push_back(std::to_string(items_entry.wornunk1)); - insert_values.push_back(std::to_string(items_entry.wornunk2)); - insert_values.push_back(std::to_string(items_entry.wornunk3)); - insert_values.push_back(std::to_string(items_entry.wornunk4)); - insert_values.push_back(std::to_string(items_entry.wornunk5)); - insert_values.push_back("'" + Strings::Escape(items_entry.wornunk6) + "'"); - insert_values.push_back(std::to_string(items_entry.wornunk7)); - insert_values.push_back(std::to_string(items_entry.focusunk1)); - insert_values.push_back(std::to_string(items_entry.focusunk2)); - insert_values.push_back(std::to_string(items_entry.focusunk3)); - insert_values.push_back(std::to_string(items_entry.focusunk4)); - insert_values.push_back(std::to_string(items_entry.focusunk5)); - insert_values.push_back("'" + Strings::Escape(items_entry.focusunk6) + "'"); - insert_values.push_back(std::to_string(items_entry.focusunk7)); - insert_values.push_back(std::to_string(items_entry.scrollunk1)); - insert_values.push_back(std::to_string(items_entry.scrollunk2)); - insert_values.push_back(std::to_string(items_entry.scrollunk3)); - insert_values.push_back(std::to_string(items_entry.scrollunk4)); - insert_values.push_back(std::to_string(items_entry.scrollunk5)); - insert_values.push_back("'" + Strings::Escape(items_entry.scrollunk6) + "'"); - insert_values.push_back(std::to_string(items_entry.scrollunk7)); - insert_values.push_back(std::to_string(items_entry.UNK193)); - insert_values.push_back(std::to_string(items_entry.purity)); - insert_values.push_back(std::to_string(items_entry.evoitem)); - insert_values.push_back(std::to_string(items_entry.evoid)); - insert_values.push_back(std::to_string(items_entry.evolvinglevel)); - insert_values.push_back(std::to_string(items_entry.evomax)); - insert_values.push_back("'" + Strings::Escape(items_entry.clickname) + "'"); - insert_values.push_back("'" + Strings::Escape(items_entry.procname) + "'"); - insert_values.push_back("'" + Strings::Escape(items_entry.wornname) + "'"); - insert_values.push_back("'" + Strings::Escape(items_entry.focusname) + "'"); - insert_values.push_back("'" + Strings::Escape(items_entry.scrollname) + "'"); - insert_values.push_back(std::to_string(items_entry.dsmitigation)); - insert_values.push_back(std::to_string(items_entry.heroic_str)); - insert_values.push_back(std::to_string(items_entry.heroic_int)); - insert_values.push_back(std::to_string(items_entry.heroic_wis)); - insert_values.push_back(std::to_string(items_entry.heroic_agi)); - insert_values.push_back(std::to_string(items_entry.heroic_dex)); - insert_values.push_back(std::to_string(items_entry.heroic_sta)); - insert_values.push_back(std::to_string(items_entry.heroic_cha)); - insert_values.push_back(std::to_string(items_entry.heroic_pr)); - insert_values.push_back(std::to_string(items_entry.heroic_dr)); - insert_values.push_back(std::to_string(items_entry.heroic_fr)); - insert_values.push_back(std::to_string(items_entry.heroic_cr)); - insert_values.push_back(std::to_string(items_entry.heroic_mr)); - insert_values.push_back(std::to_string(items_entry.heroic_svcorrup)); - insert_values.push_back(std::to_string(items_entry.healamt)); - insert_values.push_back(std::to_string(items_entry.spelldmg)); - insert_values.push_back(std::to_string(items_entry.clairvoyance)); - insert_values.push_back(std::to_string(items_entry.backstabdmg)); - insert_values.push_back("'" + Strings::Escape(items_entry.created) + "'"); - insert_values.push_back(std::to_string(items_entry.elitematerial)); - insert_values.push_back(std::to_string(items_entry.ldonsellbackrate)); - insert_values.push_back(std::to_string(items_entry.scriptfileid)); - insert_values.push_back(std::to_string(items_entry.expendablearrow)); - insert_values.push_back(std::to_string(items_entry.powersourcecapacity)); - insert_values.push_back(std::to_string(items_entry.bardeffect)); - insert_values.push_back(std::to_string(items_entry.bardeffecttype)); - insert_values.push_back(std::to_string(items_entry.bardlevel2)); - insert_values.push_back(std::to_string(items_entry.bardlevel)); - insert_values.push_back(std::to_string(items_entry.bardunk1)); - insert_values.push_back(std::to_string(items_entry.bardunk2)); - insert_values.push_back(std::to_string(items_entry.bardunk3)); - insert_values.push_back(std::to_string(items_entry.bardunk4)); - insert_values.push_back(std::to_string(items_entry.bardunk5)); - insert_values.push_back("'" + Strings::Escape(items_entry.bardname) + "'"); - insert_values.push_back(std::to_string(items_entry.bardunk7)); - insert_values.push_back(std::to_string(items_entry.UNK214)); - insert_values.push_back(std::to_string(items_entry.subtype)); - insert_values.push_back(std::to_string(items_entry.UNK220)); - insert_values.push_back(std::to_string(items_entry.UNK221)); - insert_values.push_back(std::to_string(items_entry.heirloom)); - insert_values.push_back(std::to_string(items_entry.UNK223)); - insert_values.push_back(std::to_string(items_entry.UNK224)); - insert_values.push_back(std::to_string(items_entry.UNK225)); - insert_values.push_back(std::to_string(items_entry.UNK226)); - insert_values.push_back(std::to_string(items_entry.UNK227)); - insert_values.push_back(std::to_string(items_entry.UNK228)); - insert_values.push_back(std::to_string(items_entry.UNK229)); - insert_values.push_back(std::to_string(items_entry.UNK230)); - insert_values.push_back(std::to_string(items_entry.UNK231)); - insert_values.push_back(std::to_string(items_entry.UNK232)); - insert_values.push_back(std::to_string(items_entry.UNK233)); - insert_values.push_back(std::to_string(items_entry.UNK234)); - insert_values.push_back(std::to_string(items_entry.placeable)); - insert_values.push_back(std::to_string(items_entry.UNK236)); - insert_values.push_back(std::to_string(items_entry.UNK237)); - insert_values.push_back(std::to_string(items_entry.UNK238)); - insert_values.push_back(std::to_string(items_entry.UNK239)); - insert_values.push_back(std::to_string(items_entry.UNK240)); - insert_values.push_back(std::to_string(items_entry.UNK241)); - insert_values.push_back(std::to_string(items_entry.epicitem)); + v.push_back(std::to_string(e.id)); + v.push_back(std::to_string(e.minstatus)); + v.push_back("'" + Strings::Escape(e.Name) + "'"); + v.push_back(std::to_string(e.aagi)); + v.push_back(std::to_string(e.ac)); + v.push_back(std::to_string(e.accuracy)); + v.push_back(std::to_string(e.acha)); + v.push_back(std::to_string(e.adex)); + v.push_back(std::to_string(e.aint)); + v.push_back(std::to_string(e.artifactflag)); + v.push_back(std::to_string(e.asta)); + v.push_back(std::to_string(e.astr)); + v.push_back(std::to_string(e.attack)); + v.push_back(std::to_string(e.augrestrict)); + v.push_back(std::to_string(e.augslot1type)); + v.push_back(std::to_string(e.augslot1visible)); + v.push_back(std::to_string(e.augslot2type)); + v.push_back(std::to_string(e.augslot2visible)); + v.push_back(std::to_string(e.augslot3type)); + v.push_back(std::to_string(e.augslot3visible)); + v.push_back(std::to_string(e.augslot4type)); + v.push_back(std::to_string(e.augslot4visible)); + v.push_back(std::to_string(e.augslot5type)); + v.push_back(std::to_string(e.augslot5visible)); + v.push_back(std::to_string(e.augslot6type)); + v.push_back(std::to_string(e.augslot6visible)); + v.push_back(std::to_string(e.augtype)); + v.push_back(std::to_string(e.avoidance)); + v.push_back(std::to_string(e.awis)); + v.push_back(std::to_string(e.bagsize)); + v.push_back(std::to_string(e.bagslots)); + v.push_back(std::to_string(e.bagtype)); + v.push_back(std::to_string(e.bagwr)); + v.push_back(std::to_string(e.banedmgamt)); + v.push_back(std::to_string(e.banedmgraceamt)); + v.push_back(std::to_string(e.banedmgbody)); + v.push_back(std::to_string(e.banedmgrace)); + v.push_back(std::to_string(e.bardtype)); + v.push_back(std::to_string(e.bardvalue)); + v.push_back(std::to_string(e.book)); + v.push_back(std::to_string(e.casttime)); + v.push_back(std::to_string(e.casttime_)); + v.push_back("'" + Strings::Escape(e.charmfile) + "'"); + v.push_back("'" + Strings::Escape(e.charmfileid) + "'"); + v.push_back(std::to_string(e.classes)); + v.push_back(std::to_string(e.color)); + v.push_back("'" + Strings::Escape(e.combateffects) + "'"); + v.push_back(std::to_string(e.extradmgskill)); + v.push_back(std::to_string(e.extradmgamt)); + v.push_back(std::to_string(e.price)); + v.push_back(std::to_string(e.cr)); + v.push_back(std::to_string(e.damage)); + v.push_back(std::to_string(e.damageshield)); + v.push_back(std::to_string(e.deity)); + v.push_back(std::to_string(e.delay)); + v.push_back(std::to_string(e.augdistiller)); + v.push_back(std::to_string(e.dotshielding)); + v.push_back(std::to_string(e.dr)); + v.push_back(std::to_string(e.clicktype)); + v.push_back(std::to_string(e.clicklevel2)); + v.push_back(std::to_string(e.elemdmgtype)); + v.push_back(std::to_string(e.elemdmgamt)); + v.push_back(std::to_string(e.endur)); + v.push_back(std::to_string(e.factionamt1)); + v.push_back(std::to_string(e.factionamt2)); + v.push_back(std::to_string(e.factionamt3)); + v.push_back(std::to_string(e.factionamt4)); + v.push_back(std::to_string(e.factionmod1)); + v.push_back(std::to_string(e.factionmod2)); + v.push_back(std::to_string(e.factionmod3)); + v.push_back(std::to_string(e.factionmod4)); + v.push_back("'" + Strings::Escape(e.filename) + "'"); + v.push_back(std::to_string(e.focuseffect)); + v.push_back(std::to_string(e.fr)); + v.push_back(std::to_string(e.fvnodrop)); + v.push_back(std::to_string(e.haste)); + v.push_back(std::to_string(e.clicklevel)); + v.push_back(std::to_string(e.hp)); + v.push_back(std::to_string(e.regen)); + v.push_back(std::to_string(e.icon)); + v.push_back("'" + Strings::Escape(e.idfile) + "'"); + v.push_back(std::to_string(e.itemclass)); + v.push_back(std::to_string(e.itemtype)); + v.push_back(std::to_string(e.ldonprice)); + v.push_back(std::to_string(e.ldontheme)); + v.push_back(std::to_string(e.ldonsold)); + v.push_back(std::to_string(e.light)); + v.push_back("'" + Strings::Escape(e.lore) + "'"); + v.push_back(std::to_string(e.loregroup)); + v.push_back(std::to_string(e.magic)); + v.push_back(std::to_string(e.mana)); + v.push_back(std::to_string(e.manaregen)); + v.push_back(std::to_string(e.enduranceregen)); + v.push_back(std::to_string(e.material)); + v.push_back(std::to_string(e.herosforgemodel)); + v.push_back(std::to_string(e.maxcharges)); + v.push_back(std::to_string(e.mr)); + v.push_back(std::to_string(e.nodrop)); + v.push_back(std::to_string(e.norent)); + v.push_back(std::to_string(e.pendingloreflag)); + v.push_back(std::to_string(e.pr)); + v.push_back(std::to_string(e.procrate)); + v.push_back(std::to_string(e.races)); + v.push_back(std::to_string(e.range)); + v.push_back(std::to_string(e.reclevel)); + v.push_back(std::to_string(e.recskill)); + v.push_back(std::to_string(e.reqlevel)); + v.push_back(std::to_string(e.sellrate)); + v.push_back(std::to_string(e.shielding)); + v.push_back(std::to_string(e.size)); + v.push_back(std::to_string(e.skillmodtype)); + v.push_back(std::to_string(e.skillmodvalue)); + v.push_back(std::to_string(e.slots)); + v.push_back(std::to_string(e.clickeffect)); + v.push_back(std::to_string(e.spellshield)); + v.push_back(std::to_string(e.strikethrough)); + v.push_back(std::to_string(e.stunresist)); + v.push_back(std::to_string(e.summonedflag)); + v.push_back(std::to_string(e.tradeskills)); + v.push_back(std::to_string(e.favor)); + v.push_back(std::to_string(e.weight)); + v.push_back(std::to_string(e.UNK012)); + v.push_back(std::to_string(e.UNK013)); + v.push_back(std::to_string(e.benefitflag)); + v.push_back(std::to_string(e.UNK054)); + v.push_back(std::to_string(e.UNK059)); + v.push_back(std::to_string(e.booktype)); + v.push_back(std::to_string(e.recastdelay)); + v.push_back(std::to_string(e.recasttype)); + v.push_back(std::to_string(e.guildfavor)); + v.push_back(std::to_string(e.UNK123)); + v.push_back(std::to_string(e.UNK124)); + v.push_back(std::to_string(e.attuneable)); + v.push_back(std::to_string(e.nopet)); + v.push_back("FROM_UNIXTIME(" + (e.updated > 0 ? std::to_string(e.updated) : "null") + ")"); + v.push_back("'" + Strings::Escape(e.comment) + "'"); + v.push_back(std::to_string(e.UNK127)); + v.push_back(std::to_string(e.pointtype)); + v.push_back(std::to_string(e.potionbelt)); + v.push_back(std::to_string(e.potionbeltslots)); + v.push_back(std::to_string(e.stacksize)); + v.push_back(std::to_string(e.notransfer)); + v.push_back(std::to_string(e.stackable)); + v.push_back("'" + Strings::Escape(e.UNK134) + "'"); + v.push_back(std::to_string(e.UNK137)); + v.push_back(std::to_string(e.proceffect)); + v.push_back(std::to_string(e.proctype)); + v.push_back(std::to_string(e.proclevel2)); + v.push_back(std::to_string(e.proclevel)); + v.push_back(std::to_string(e.UNK142)); + v.push_back(std::to_string(e.worneffect)); + v.push_back(std::to_string(e.worntype)); + v.push_back(std::to_string(e.wornlevel2)); + v.push_back(std::to_string(e.wornlevel)); + v.push_back(std::to_string(e.UNK147)); + v.push_back(std::to_string(e.focustype)); + v.push_back(std::to_string(e.focuslevel2)); + v.push_back(std::to_string(e.focuslevel)); + v.push_back(std::to_string(e.UNK152)); + v.push_back(std::to_string(e.scrolleffect)); + v.push_back(std::to_string(e.scrolltype)); + v.push_back(std::to_string(e.scrolllevel2)); + v.push_back(std::to_string(e.scrolllevel)); + v.push_back(std::to_string(e.UNK157)); + v.push_back("FROM_UNIXTIME(" + (e.serialized > 0 ? std::to_string(e.serialized) : "null") + ")"); + v.push_back("FROM_UNIXTIME(" + (e.verified > 0 ? std::to_string(e.verified) : "null") + ")"); + v.push_back("'" + Strings::Escape(e.serialization) + "'"); + v.push_back("'" + Strings::Escape(e.source) + "'"); + v.push_back(std::to_string(e.UNK033)); + v.push_back("'" + Strings::Escape(e.lorefile) + "'"); + v.push_back(std::to_string(e.UNK014)); + v.push_back(std::to_string(e.svcorruption)); + v.push_back(std::to_string(e.skillmodmax)); + v.push_back(std::to_string(e.UNK060)); + v.push_back(std::to_string(e.augslot1unk2)); + v.push_back(std::to_string(e.augslot2unk2)); + v.push_back(std::to_string(e.augslot3unk2)); + v.push_back(std::to_string(e.augslot4unk2)); + v.push_back(std::to_string(e.augslot5unk2)); + v.push_back(std::to_string(e.augslot6unk2)); + v.push_back(std::to_string(e.UNK120)); + v.push_back(std::to_string(e.UNK121)); + v.push_back(std::to_string(e.questitemflag)); + v.push_back("'" + Strings::Escape(e.UNK132) + "'"); + v.push_back(std::to_string(e.clickunk5)); + v.push_back("'" + Strings::Escape(e.clickunk6) + "'"); + v.push_back(std::to_string(e.clickunk7)); + v.push_back(std::to_string(e.procunk1)); + v.push_back(std::to_string(e.procunk2)); + v.push_back(std::to_string(e.procunk3)); + v.push_back(std::to_string(e.procunk4)); + v.push_back("'" + Strings::Escape(e.procunk6) + "'"); + v.push_back(std::to_string(e.procunk7)); + v.push_back(std::to_string(e.wornunk1)); + v.push_back(std::to_string(e.wornunk2)); + v.push_back(std::to_string(e.wornunk3)); + v.push_back(std::to_string(e.wornunk4)); + v.push_back(std::to_string(e.wornunk5)); + v.push_back("'" + Strings::Escape(e.wornunk6) + "'"); + v.push_back(std::to_string(e.wornunk7)); + v.push_back(std::to_string(e.focusunk1)); + v.push_back(std::to_string(e.focusunk2)); + v.push_back(std::to_string(e.focusunk3)); + v.push_back(std::to_string(e.focusunk4)); + v.push_back(std::to_string(e.focusunk5)); + v.push_back("'" + Strings::Escape(e.focusunk6) + "'"); + v.push_back(std::to_string(e.focusunk7)); + v.push_back(std::to_string(e.scrollunk1)); + v.push_back(std::to_string(e.scrollunk2)); + v.push_back(std::to_string(e.scrollunk3)); + v.push_back(std::to_string(e.scrollunk4)); + v.push_back(std::to_string(e.scrollunk5)); + v.push_back("'" + Strings::Escape(e.scrollunk6) + "'"); + v.push_back(std::to_string(e.scrollunk7)); + v.push_back(std::to_string(e.UNK193)); + v.push_back(std::to_string(e.purity)); + v.push_back(std::to_string(e.evoitem)); + v.push_back(std::to_string(e.evoid)); + v.push_back(std::to_string(e.evolvinglevel)); + v.push_back(std::to_string(e.evomax)); + v.push_back("'" + Strings::Escape(e.clickname) + "'"); + v.push_back("'" + Strings::Escape(e.procname) + "'"); + v.push_back("'" + Strings::Escape(e.wornname) + "'"); + v.push_back("'" + Strings::Escape(e.focusname) + "'"); + v.push_back("'" + Strings::Escape(e.scrollname) + "'"); + v.push_back(std::to_string(e.dsmitigation)); + v.push_back(std::to_string(e.heroic_str)); + v.push_back(std::to_string(e.heroic_int)); + v.push_back(std::to_string(e.heroic_wis)); + v.push_back(std::to_string(e.heroic_agi)); + v.push_back(std::to_string(e.heroic_dex)); + v.push_back(std::to_string(e.heroic_sta)); + v.push_back(std::to_string(e.heroic_cha)); + v.push_back(std::to_string(e.heroic_pr)); + v.push_back(std::to_string(e.heroic_dr)); + v.push_back(std::to_string(e.heroic_fr)); + v.push_back(std::to_string(e.heroic_cr)); + v.push_back(std::to_string(e.heroic_mr)); + v.push_back(std::to_string(e.heroic_svcorrup)); + v.push_back(std::to_string(e.healamt)); + v.push_back(std::to_string(e.spelldmg)); + v.push_back(std::to_string(e.clairvoyance)); + v.push_back(std::to_string(e.backstabdmg)); + v.push_back("'" + Strings::Escape(e.created) + "'"); + v.push_back(std::to_string(e.elitematerial)); + v.push_back(std::to_string(e.ldonsellbackrate)); + v.push_back(std::to_string(e.scriptfileid)); + v.push_back(std::to_string(e.expendablearrow)); + v.push_back(std::to_string(e.powersourcecapacity)); + v.push_back(std::to_string(e.bardeffect)); + v.push_back(std::to_string(e.bardeffecttype)); + v.push_back(std::to_string(e.bardlevel2)); + v.push_back(std::to_string(e.bardlevel)); + v.push_back(std::to_string(e.bardunk1)); + v.push_back(std::to_string(e.bardunk2)); + v.push_back(std::to_string(e.bardunk3)); + v.push_back(std::to_string(e.bardunk4)); + v.push_back(std::to_string(e.bardunk5)); + v.push_back("'" + Strings::Escape(e.bardname) + "'"); + v.push_back(std::to_string(e.bardunk7)); + v.push_back(std::to_string(e.UNK214)); + v.push_back(std::to_string(e.subtype)); + v.push_back(std::to_string(e.UNK220)); + v.push_back(std::to_string(e.UNK221)); + v.push_back(std::to_string(e.heirloom)); + v.push_back(std::to_string(e.UNK223)); + v.push_back(std::to_string(e.UNK224)); + v.push_back(std::to_string(e.UNK225)); + v.push_back(std::to_string(e.UNK226)); + v.push_back(std::to_string(e.UNK227)); + v.push_back(std::to_string(e.UNK228)); + v.push_back(std::to_string(e.UNK229)); + v.push_back(std::to_string(e.UNK230)); + v.push_back(std::to_string(e.UNK231)); + v.push_back(std::to_string(e.UNK232)); + v.push_back(std::to_string(e.UNK233)); + v.push_back(std::to_string(e.UNK234)); + v.push_back(std::to_string(e.placeable)); + v.push_back(std::to_string(e.UNK236)); + v.push_back(std::to_string(e.UNK237)); + v.push_back(std::to_string(e.UNK238)); + v.push_back(std::to_string(e.UNK239)); + v.push_back(std::to_string(e.UNK240)); + v.push_back(std::to_string(e.UNK241)); + v.push_back(std::to_string(e.epicitem)); auto results = db.QueryDatabase( fmt::format( "{} VALUES ({})", BaseInsert(), - Strings::Implode(",", insert_values) + Strings::Implode(",", v) ) ); if (results.Success()) { - items_entry.id = results.LastInsertedID(); - return items_entry; + e.id = results.LastInsertedID(); + return e; } - items_entry = NewEntity(); + e = NewEntity(); - return items_entry; + return e; } static int InsertMany( Database& db, - std::vector items_entries + const std::vector &entries ) { std::vector insert_chunks; - for (auto &items_entry: items_entries) { - std::vector insert_values; + for (auto &e: entries) { + std::vector v; - insert_values.push_back(std::to_string(items_entry.id)); - insert_values.push_back(std::to_string(items_entry.minstatus)); - insert_values.push_back("'" + Strings::Escape(items_entry.Name) + "'"); - insert_values.push_back(std::to_string(items_entry.aagi)); - insert_values.push_back(std::to_string(items_entry.ac)); - insert_values.push_back(std::to_string(items_entry.accuracy)); - insert_values.push_back(std::to_string(items_entry.acha)); - insert_values.push_back(std::to_string(items_entry.adex)); - insert_values.push_back(std::to_string(items_entry.aint)); - insert_values.push_back(std::to_string(items_entry.artifactflag)); - insert_values.push_back(std::to_string(items_entry.asta)); - insert_values.push_back(std::to_string(items_entry.astr)); - insert_values.push_back(std::to_string(items_entry.attack)); - insert_values.push_back(std::to_string(items_entry.augrestrict)); - insert_values.push_back(std::to_string(items_entry.augslot1type)); - insert_values.push_back(std::to_string(items_entry.augslot1visible)); - insert_values.push_back(std::to_string(items_entry.augslot2type)); - insert_values.push_back(std::to_string(items_entry.augslot2visible)); - insert_values.push_back(std::to_string(items_entry.augslot3type)); - insert_values.push_back(std::to_string(items_entry.augslot3visible)); - insert_values.push_back(std::to_string(items_entry.augslot4type)); - insert_values.push_back(std::to_string(items_entry.augslot4visible)); - insert_values.push_back(std::to_string(items_entry.augslot5type)); - insert_values.push_back(std::to_string(items_entry.augslot5visible)); - insert_values.push_back(std::to_string(items_entry.augslot6type)); - insert_values.push_back(std::to_string(items_entry.augslot6visible)); - insert_values.push_back(std::to_string(items_entry.augtype)); - insert_values.push_back(std::to_string(items_entry.avoidance)); - insert_values.push_back(std::to_string(items_entry.awis)); - insert_values.push_back(std::to_string(items_entry.bagsize)); - insert_values.push_back(std::to_string(items_entry.bagslots)); - insert_values.push_back(std::to_string(items_entry.bagtype)); - insert_values.push_back(std::to_string(items_entry.bagwr)); - insert_values.push_back(std::to_string(items_entry.banedmgamt)); - insert_values.push_back(std::to_string(items_entry.banedmgraceamt)); - insert_values.push_back(std::to_string(items_entry.banedmgbody)); - insert_values.push_back(std::to_string(items_entry.banedmgrace)); - insert_values.push_back(std::to_string(items_entry.bardtype)); - insert_values.push_back(std::to_string(items_entry.bardvalue)); - insert_values.push_back(std::to_string(items_entry.book)); - insert_values.push_back(std::to_string(items_entry.casttime)); - insert_values.push_back(std::to_string(items_entry.casttime_)); - insert_values.push_back("'" + Strings::Escape(items_entry.charmfile) + "'"); - insert_values.push_back("'" + Strings::Escape(items_entry.charmfileid) + "'"); - insert_values.push_back(std::to_string(items_entry.classes)); - insert_values.push_back(std::to_string(items_entry.color)); - insert_values.push_back("'" + Strings::Escape(items_entry.combateffects) + "'"); - insert_values.push_back(std::to_string(items_entry.extradmgskill)); - insert_values.push_back(std::to_string(items_entry.extradmgamt)); - insert_values.push_back(std::to_string(items_entry.price)); - insert_values.push_back(std::to_string(items_entry.cr)); - insert_values.push_back(std::to_string(items_entry.damage)); - insert_values.push_back(std::to_string(items_entry.damageshield)); - insert_values.push_back(std::to_string(items_entry.deity)); - insert_values.push_back(std::to_string(items_entry.delay)); - insert_values.push_back(std::to_string(items_entry.augdistiller)); - insert_values.push_back(std::to_string(items_entry.dotshielding)); - insert_values.push_back(std::to_string(items_entry.dr)); - insert_values.push_back(std::to_string(items_entry.clicktype)); - insert_values.push_back(std::to_string(items_entry.clicklevel2)); - insert_values.push_back(std::to_string(items_entry.elemdmgtype)); - insert_values.push_back(std::to_string(items_entry.elemdmgamt)); - insert_values.push_back(std::to_string(items_entry.endur)); - insert_values.push_back(std::to_string(items_entry.factionamt1)); - insert_values.push_back(std::to_string(items_entry.factionamt2)); - insert_values.push_back(std::to_string(items_entry.factionamt3)); - insert_values.push_back(std::to_string(items_entry.factionamt4)); - insert_values.push_back(std::to_string(items_entry.factionmod1)); - insert_values.push_back(std::to_string(items_entry.factionmod2)); - insert_values.push_back(std::to_string(items_entry.factionmod3)); - insert_values.push_back(std::to_string(items_entry.factionmod4)); - insert_values.push_back("'" + Strings::Escape(items_entry.filename) + "'"); - insert_values.push_back(std::to_string(items_entry.focuseffect)); - insert_values.push_back(std::to_string(items_entry.fr)); - insert_values.push_back(std::to_string(items_entry.fvnodrop)); - insert_values.push_back(std::to_string(items_entry.haste)); - insert_values.push_back(std::to_string(items_entry.clicklevel)); - insert_values.push_back(std::to_string(items_entry.hp)); - insert_values.push_back(std::to_string(items_entry.regen)); - insert_values.push_back(std::to_string(items_entry.icon)); - insert_values.push_back("'" + Strings::Escape(items_entry.idfile) + "'"); - insert_values.push_back(std::to_string(items_entry.itemclass)); - insert_values.push_back(std::to_string(items_entry.itemtype)); - insert_values.push_back(std::to_string(items_entry.ldonprice)); - insert_values.push_back(std::to_string(items_entry.ldontheme)); - insert_values.push_back(std::to_string(items_entry.ldonsold)); - insert_values.push_back(std::to_string(items_entry.light)); - insert_values.push_back("'" + Strings::Escape(items_entry.lore) + "'"); - insert_values.push_back(std::to_string(items_entry.loregroup)); - insert_values.push_back(std::to_string(items_entry.magic)); - insert_values.push_back(std::to_string(items_entry.mana)); - insert_values.push_back(std::to_string(items_entry.manaregen)); - insert_values.push_back(std::to_string(items_entry.enduranceregen)); - insert_values.push_back(std::to_string(items_entry.material)); - insert_values.push_back(std::to_string(items_entry.herosforgemodel)); - insert_values.push_back(std::to_string(items_entry.maxcharges)); - insert_values.push_back(std::to_string(items_entry.mr)); - insert_values.push_back(std::to_string(items_entry.nodrop)); - insert_values.push_back(std::to_string(items_entry.norent)); - insert_values.push_back(std::to_string(items_entry.pendingloreflag)); - insert_values.push_back(std::to_string(items_entry.pr)); - insert_values.push_back(std::to_string(items_entry.procrate)); - insert_values.push_back(std::to_string(items_entry.races)); - insert_values.push_back(std::to_string(items_entry.range)); - insert_values.push_back(std::to_string(items_entry.reclevel)); - insert_values.push_back(std::to_string(items_entry.recskill)); - insert_values.push_back(std::to_string(items_entry.reqlevel)); - insert_values.push_back(std::to_string(items_entry.sellrate)); - insert_values.push_back(std::to_string(items_entry.shielding)); - insert_values.push_back(std::to_string(items_entry.size)); - insert_values.push_back(std::to_string(items_entry.skillmodtype)); - insert_values.push_back(std::to_string(items_entry.skillmodvalue)); - insert_values.push_back(std::to_string(items_entry.slots)); - insert_values.push_back(std::to_string(items_entry.clickeffect)); - insert_values.push_back(std::to_string(items_entry.spellshield)); - insert_values.push_back(std::to_string(items_entry.strikethrough)); - insert_values.push_back(std::to_string(items_entry.stunresist)); - insert_values.push_back(std::to_string(items_entry.summonedflag)); - insert_values.push_back(std::to_string(items_entry.tradeskills)); - insert_values.push_back(std::to_string(items_entry.favor)); - insert_values.push_back(std::to_string(items_entry.weight)); - insert_values.push_back(std::to_string(items_entry.UNK012)); - insert_values.push_back(std::to_string(items_entry.UNK013)); - insert_values.push_back(std::to_string(items_entry.benefitflag)); - insert_values.push_back(std::to_string(items_entry.UNK054)); - insert_values.push_back(std::to_string(items_entry.UNK059)); - insert_values.push_back(std::to_string(items_entry.booktype)); - insert_values.push_back(std::to_string(items_entry.recastdelay)); - insert_values.push_back(std::to_string(items_entry.recasttype)); - insert_values.push_back(std::to_string(items_entry.guildfavor)); - insert_values.push_back(std::to_string(items_entry.UNK123)); - insert_values.push_back(std::to_string(items_entry.UNK124)); - insert_values.push_back(std::to_string(items_entry.attuneable)); - insert_values.push_back(std::to_string(items_entry.nopet)); - insert_values.push_back("FROM_UNIXTIME(" + (items_entry.updated > 0 ? std::to_string(items_entry.updated) : "null") + ")"); - insert_values.push_back("'" + Strings::Escape(items_entry.comment) + "'"); - insert_values.push_back(std::to_string(items_entry.UNK127)); - insert_values.push_back(std::to_string(items_entry.pointtype)); - insert_values.push_back(std::to_string(items_entry.potionbelt)); - insert_values.push_back(std::to_string(items_entry.potionbeltslots)); - insert_values.push_back(std::to_string(items_entry.stacksize)); - insert_values.push_back(std::to_string(items_entry.notransfer)); - insert_values.push_back(std::to_string(items_entry.stackable)); - insert_values.push_back("'" + Strings::Escape(items_entry.UNK134) + "'"); - insert_values.push_back(std::to_string(items_entry.UNK137)); - insert_values.push_back(std::to_string(items_entry.proceffect)); - insert_values.push_back(std::to_string(items_entry.proctype)); - insert_values.push_back(std::to_string(items_entry.proclevel2)); - insert_values.push_back(std::to_string(items_entry.proclevel)); - insert_values.push_back(std::to_string(items_entry.UNK142)); - insert_values.push_back(std::to_string(items_entry.worneffect)); - insert_values.push_back(std::to_string(items_entry.worntype)); - insert_values.push_back(std::to_string(items_entry.wornlevel2)); - insert_values.push_back(std::to_string(items_entry.wornlevel)); - insert_values.push_back(std::to_string(items_entry.UNK147)); - insert_values.push_back(std::to_string(items_entry.focustype)); - insert_values.push_back(std::to_string(items_entry.focuslevel2)); - insert_values.push_back(std::to_string(items_entry.focuslevel)); - insert_values.push_back(std::to_string(items_entry.UNK152)); - insert_values.push_back(std::to_string(items_entry.scrolleffect)); - insert_values.push_back(std::to_string(items_entry.scrolltype)); - insert_values.push_back(std::to_string(items_entry.scrolllevel2)); - insert_values.push_back(std::to_string(items_entry.scrolllevel)); - insert_values.push_back(std::to_string(items_entry.UNK157)); - insert_values.push_back("FROM_UNIXTIME(" + (items_entry.serialized > 0 ? std::to_string(items_entry.serialized) : "null") + ")"); - insert_values.push_back("FROM_UNIXTIME(" + (items_entry.verified > 0 ? std::to_string(items_entry.verified) : "null") + ")"); - insert_values.push_back("'" + Strings::Escape(items_entry.serialization) + "'"); - insert_values.push_back("'" + Strings::Escape(items_entry.source) + "'"); - insert_values.push_back(std::to_string(items_entry.UNK033)); - insert_values.push_back("'" + Strings::Escape(items_entry.lorefile) + "'"); - insert_values.push_back(std::to_string(items_entry.UNK014)); - insert_values.push_back(std::to_string(items_entry.svcorruption)); - insert_values.push_back(std::to_string(items_entry.skillmodmax)); - insert_values.push_back(std::to_string(items_entry.UNK060)); - insert_values.push_back(std::to_string(items_entry.augslot1unk2)); - insert_values.push_back(std::to_string(items_entry.augslot2unk2)); - insert_values.push_back(std::to_string(items_entry.augslot3unk2)); - insert_values.push_back(std::to_string(items_entry.augslot4unk2)); - insert_values.push_back(std::to_string(items_entry.augslot5unk2)); - insert_values.push_back(std::to_string(items_entry.augslot6unk2)); - insert_values.push_back(std::to_string(items_entry.UNK120)); - insert_values.push_back(std::to_string(items_entry.UNK121)); - insert_values.push_back(std::to_string(items_entry.questitemflag)); - insert_values.push_back("'" + Strings::Escape(items_entry.UNK132) + "'"); - insert_values.push_back(std::to_string(items_entry.clickunk5)); - insert_values.push_back("'" + Strings::Escape(items_entry.clickunk6) + "'"); - insert_values.push_back(std::to_string(items_entry.clickunk7)); - insert_values.push_back(std::to_string(items_entry.procunk1)); - insert_values.push_back(std::to_string(items_entry.procunk2)); - insert_values.push_back(std::to_string(items_entry.procunk3)); - insert_values.push_back(std::to_string(items_entry.procunk4)); - insert_values.push_back("'" + Strings::Escape(items_entry.procunk6) + "'"); - insert_values.push_back(std::to_string(items_entry.procunk7)); - insert_values.push_back(std::to_string(items_entry.wornunk1)); - insert_values.push_back(std::to_string(items_entry.wornunk2)); - insert_values.push_back(std::to_string(items_entry.wornunk3)); - insert_values.push_back(std::to_string(items_entry.wornunk4)); - insert_values.push_back(std::to_string(items_entry.wornunk5)); - insert_values.push_back("'" + Strings::Escape(items_entry.wornunk6) + "'"); - insert_values.push_back(std::to_string(items_entry.wornunk7)); - insert_values.push_back(std::to_string(items_entry.focusunk1)); - insert_values.push_back(std::to_string(items_entry.focusunk2)); - insert_values.push_back(std::to_string(items_entry.focusunk3)); - insert_values.push_back(std::to_string(items_entry.focusunk4)); - insert_values.push_back(std::to_string(items_entry.focusunk5)); - insert_values.push_back("'" + Strings::Escape(items_entry.focusunk6) + "'"); - insert_values.push_back(std::to_string(items_entry.focusunk7)); - insert_values.push_back(std::to_string(items_entry.scrollunk1)); - insert_values.push_back(std::to_string(items_entry.scrollunk2)); - insert_values.push_back(std::to_string(items_entry.scrollunk3)); - insert_values.push_back(std::to_string(items_entry.scrollunk4)); - insert_values.push_back(std::to_string(items_entry.scrollunk5)); - insert_values.push_back("'" + Strings::Escape(items_entry.scrollunk6) + "'"); - insert_values.push_back(std::to_string(items_entry.scrollunk7)); - insert_values.push_back(std::to_string(items_entry.UNK193)); - insert_values.push_back(std::to_string(items_entry.purity)); - insert_values.push_back(std::to_string(items_entry.evoitem)); - insert_values.push_back(std::to_string(items_entry.evoid)); - insert_values.push_back(std::to_string(items_entry.evolvinglevel)); - insert_values.push_back(std::to_string(items_entry.evomax)); - insert_values.push_back("'" + Strings::Escape(items_entry.clickname) + "'"); - insert_values.push_back("'" + Strings::Escape(items_entry.procname) + "'"); - insert_values.push_back("'" + Strings::Escape(items_entry.wornname) + "'"); - insert_values.push_back("'" + Strings::Escape(items_entry.focusname) + "'"); - insert_values.push_back("'" + Strings::Escape(items_entry.scrollname) + "'"); - insert_values.push_back(std::to_string(items_entry.dsmitigation)); - insert_values.push_back(std::to_string(items_entry.heroic_str)); - insert_values.push_back(std::to_string(items_entry.heroic_int)); - insert_values.push_back(std::to_string(items_entry.heroic_wis)); - insert_values.push_back(std::to_string(items_entry.heroic_agi)); - insert_values.push_back(std::to_string(items_entry.heroic_dex)); - insert_values.push_back(std::to_string(items_entry.heroic_sta)); - insert_values.push_back(std::to_string(items_entry.heroic_cha)); - insert_values.push_back(std::to_string(items_entry.heroic_pr)); - insert_values.push_back(std::to_string(items_entry.heroic_dr)); - insert_values.push_back(std::to_string(items_entry.heroic_fr)); - insert_values.push_back(std::to_string(items_entry.heroic_cr)); - insert_values.push_back(std::to_string(items_entry.heroic_mr)); - insert_values.push_back(std::to_string(items_entry.heroic_svcorrup)); - insert_values.push_back(std::to_string(items_entry.healamt)); - insert_values.push_back(std::to_string(items_entry.spelldmg)); - insert_values.push_back(std::to_string(items_entry.clairvoyance)); - insert_values.push_back(std::to_string(items_entry.backstabdmg)); - insert_values.push_back("'" + Strings::Escape(items_entry.created) + "'"); - insert_values.push_back(std::to_string(items_entry.elitematerial)); - insert_values.push_back(std::to_string(items_entry.ldonsellbackrate)); - insert_values.push_back(std::to_string(items_entry.scriptfileid)); - insert_values.push_back(std::to_string(items_entry.expendablearrow)); - insert_values.push_back(std::to_string(items_entry.powersourcecapacity)); - insert_values.push_back(std::to_string(items_entry.bardeffect)); - insert_values.push_back(std::to_string(items_entry.bardeffecttype)); - insert_values.push_back(std::to_string(items_entry.bardlevel2)); - insert_values.push_back(std::to_string(items_entry.bardlevel)); - insert_values.push_back(std::to_string(items_entry.bardunk1)); - insert_values.push_back(std::to_string(items_entry.bardunk2)); - insert_values.push_back(std::to_string(items_entry.bardunk3)); - insert_values.push_back(std::to_string(items_entry.bardunk4)); - insert_values.push_back(std::to_string(items_entry.bardunk5)); - insert_values.push_back("'" + Strings::Escape(items_entry.bardname) + "'"); - insert_values.push_back(std::to_string(items_entry.bardunk7)); - insert_values.push_back(std::to_string(items_entry.UNK214)); - insert_values.push_back(std::to_string(items_entry.subtype)); - insert_values.push_back(std::to_string(items_entry.UNK220)); - insert_values.push_back(std::to_string(items_entry.UNK221)); - insert_values.push_back(std::to_string(items_entry.heirloom)); - insert_values.push_back(std::to_string(items_entry.UNK223)); - insert_values.push_back(std::to_string(items_entry.UNK224)); - insert_values.push_back(std::to_string(items_entry.UNK225)); - insert_values.push_back(std::to_string(items_entry.UNK226)); - insert_values.push_back(std::to_string(items_entry.UNK227)); - insert_values.push_back(std::to_string(items_entry.UNK228)); - insert_values.push_back(std::to_string(items_entry.UNK229)); - insert_values.push_back(std::to_string(items_entry.UNK230)); - insert_values.push_back(std::to_string(items_entry.UNK231)); - insert_values.push_back(std::to_string(items_entry.UNK232)); - insert_values.push_back(std::to_string(items_entry.UNK233)); - insert_values.push_back(std::to_string(items_entry.UNK234)); - insert_values.push_back(std::to_string(items_entry.placeable)); - insert_values.push_back(std::to_string(items_entry.UNK236)); - insert_values.push_back(std::to_string(items_entry.UNK237)); - insert_values.push_back(std::to_string(items_entry.UNK238)); - insert_values.push_back(std::to_string(items_entry.UNK239)); - insert_values.push_back(std::to_string(items_entry.UNK240)); - insert_values.push_back(std::to_string(items_entry.UNK241)); - insert_values.push_back(std::to_string(items_entry.epicitem)); + v.push_back(std::to_string(e.id)); + v.push_back(std::to_string(e.minstatus)); + v.push_back("'" + Strings::Escape(e.Name) + "'"); + v.push_back(std::to_string(e.aagi)); + v.push_back(std::to_string(e.ac)); + v.push_back(std::to_string(e.accuracy)); + v.push_back(std::to_string(e.acha)); + v.push_back(std::to_string(e.adex)); + v.push_back(std::to_string(e.aint)); + v.push_back(std::to_string(e.artifactflag)); + v.push_back(std::to_string(e.asta)); + v.push_back(std::to_string(e.astr)); + v.push_back(std::to_string(e.attack)); + v.push_back(std::to_string(e.augrestrict)); + v.push_back(std::to_string(e.augslot1type)); + v.push_back(std::to_string(e.augslot1visible)); + v.push_back(std::to_string(e.augslot2type)); + v.push_back(std::to_string(e.augslot2visible)); + v.push_back(std::to_string(e.augslot3type)); + v.push_back(std::to_string(e.augslot3visible)); + v.push_back(std::to_string(e.augslot4type)); + v.push_back(std::to_string(e.augslot4visible)); + v.push_back(std::to_string(e.augslot5type)); + v.push_back(std::to_string(e.augslot5visible)); + v.push_back(std::to_string(e.augslot6type)); + v.push_back(std::to_string(e.augslot6visible)); + v.push_back(std::to_string(e.augtype)); + v.push_back(std::to_string(e.avoidance)); + v.push_back(std::to_string(e.awis)); + v.push_back(std::to_string(e.bagsize)); + v.push_back(std::to_string(e.bagslots)); + v.push_back(std::to_string(e.bagtype)); + v.push_back(std::to_string(e.bagwr)); + v.push_back(std::to_string(e.banedmgamt)); + v.push_back(std::to_string(e.banedmgraceamt)); + v.push_back(std::to_string(e.banedmgbody)); + v.push_back(std::to_string(e.banedmgrace)); + v.push_back(std::to_string(e.bardtype)); + v.push_back(std::to_string(e.bardvalue)); + v.push_back(std::to_string(e.book)); + v.push_back(std::to_string(e.casttime)); + v.push_back(std::to_string(e.casttime_)); + v.push_back("'" + Strings::Escape(e.charmfile) + "'"); + v.push_back("'" + Strings::Escape(e.charmfileid) + "'"); + v.push_back(std::to_string(e.classes)); + v.push_back(std::to_string(e.color)); + v.push_back("'" + Strings::Escape(e.combateffects) + "'"); + v.push_back(std::to_string(e.extradmgskill)); + v.push_back(std::to_string(e.extradmgamt)); + v.push_back(std::to_string(e.price)); + v.push_back(std::to_string(e.cr)); + v.push_back(std::to_string(e.damage)); + v.push_back(std::to_string(e.damageshield)); + v.push_back(std::to_string(e.deity)); + v.push_back(std::to_string(e.delay)); + v.push_back(std::to_string(e.augdistiller)); + v.push_back(std::to_string(e.dotshielding)); + v.push_back(std::to_string(e.dr)); + v.push_back(std::to_string(e.clicktype)); + v.push_back(std::to_string(e.clicklevel2)); + v.push_back(std::to_string(e.elemdmgtype)); + v.push_back(std::to_string(e.elemdmgamt)); + v.push_back(std::to_string(e.endur)); + v.push_back(std::to_string(e.factionamt1)); + v.push_back(std::to_string(e.factionamt2)); + v.push_back(std::to_string(e.factionamt3)); + v.push_back(std::to_string(e.factionamt4)); + v.push_back(std::to_string(e.factionmod1)); + v.push_back(std::to_string(e.factionmod2)); + v.push_back(std::to_string(e.factionmod3)); + v.push_back(std::to_string(e.factionmod4)); + v.push_back("'" + Strings::Escape(e.filename) + "'"); + v.push_back(std::to_string(e.focuseffect)); + v.push_back(std::to_string(e.fr)); + v.push_back(std::to_string(e.fvnodrop)); + v.push_back(std::to_string(e.haste)); + v.push_back(std::to_string(e.clicklevel)); + v.push_back(std::to_string(e.hp)); + v.push_back(std::to_string(e.regen)); + v.push_back(std::to_string(e.icon)); + v.push_back("'" + Strings::Escape(e.idfile) + "'"); + v.push_back(std::to_string(e.itemclass)); + v.push_back(std::to_string(e.itemtype)); + v.push_back(std::to_string(e.ldonprice)); + v.push_back(std::to_string(e.ldontheme)); + v.push_back(std::to_string(e.ldonsold)); + v.push_back(std::to_string(e.light)); + v.push_back("'" + Strings::Escape(e.lore) + "'"); + v.push_back(std::to_string(e.loregroup)); + v.push_back(std::to_string(e.magic)); + v.push_back(std::to_string(e.mana)); + v.push_back(std::to_string(e.manaregen)); + v.push_back(std::to_string(e.enduranceregen)); + v.push_back(std::to_string(e.material)); + v.push_back(std::to_string(e.herosforgemodel)); + v.push_back(std::to_string(e.maxcharges)); + v.push_back(std::to_string(e.mr)); + v.push_back(std::to_string(e.nodrop)); + v.push_back(std::to_string(e.norent)); + v.push_back(std::to_string(e.pendingloreflag)); + v.push_back(std::to_string(e.pr)); + v.push_back(std::to_string(e.procrate)); + v.push_back(std::to_string(e.races)); + v.push_back(std::to_string(e.range)); + v.push_back(std::to_string(e.reclevel)); + v.push_back(std::to_string(e.recskill)); + v.push_back(std::to_string(e.reqlevel)); + v.push_back(std::to_string(e.sellrate)); + v.push_back(std::to_string(e.shielding)); + v.push_back(std::to_string(e.size)); + v.push_back(std::to_string(e.skillmodtype)); + v.push_back(std::to_string(e.skillmodvalue)); + v.push_back(std::to_string(e.slots)); + v.push_back(std::to_string(e.clickeffect)); + v.push_back(std::to_string(e.spellshield)); + v.push_back(std::to_string(e.strikethrough)); + v.push_back(std::to_string(e.stunresist)); + v.push_back(std::to_string(e.summonedflag)); + v.push_back(std::to_string(e.tradeskills)); + v.push_back(std::to_string(e.favor)); + v.push_back(std::to_string(e.weight)); + v.push_back(std::to_string(e.UNK012)); + v.push_back(std::to_string(e.UNK013)); + v.push_back(std::to_string(e.benefitflag)); + v.push_back(std::to_string(e.UNK054)); + v.push_back(std::to_string(e.UNK059)); + v.push_back(std::to_string(e.booktype)); + v.push_back(std::to_string(e.recastdelay)); + v.push_back(std::to_string(e.recasttype)); + v.push_back(std::to_string(e.guildfavor)); + v.push_back(std::to_string(e.UNK123)); + v.push_back(std::to_string(e.UNK124)); + v.push_back(std::to_string(e.attuneable)); + v.push_back(std::to_string(e.nopet)); + v.push_back("FROM_UNIXTIME(" + (e.updated > 0 ? std::to_string(e.updated) : "null") + ")"); + v.push_back("'" + Strings::Escape(e.comment) + "'"); + v.push_back(std::to_string(e.UNK127)); + v.push_back(std::to_string(e.pointtype)); + v.push_back(std::to_string(e.potionbelt)); + v.push_back(std::to_string(e.potionbeltslots)); + v.push_back(std::to_string(e.stacksize)); + v.push_back(std::to_string(e.notransfer)); + v.push_back(std::to_string(e.stackable)); + v.push_back("'" + Strings::Escape(e.UNK134) + "'"); + v.push_back(std::to_string(e.UNK137)); + v.push_back(std::to_string(e.proceffect)); + v.push_back(std::to_string(e.proctype)); + v.push_back(std::to_string(e.proclevel2)); + v.push_back(std::to_string(e.proclevel)); + v.push_back(std::to_string(e.UNK142)); + v.push_back(std::to_string(e.worneffect)); + v.push_back(std::to_string(e.worntype)); + v.push_back(std::to_string(e.wornlevel2)); + v.push_back(std::to_string(e.wornlevel)); + v.push_back(std::to_string(e.UNK147)); + v.push_back(std::to_string(e.focustype)); + v.push_back(std::to_string(e.focuslevel2)); + v.push_back(std::to_string(e.focuslevel)); + v.push_back(std::to_string(e.UNK152)); + v.push_back(std::to_string(e.scrolleffect)); + v.push_back(std::to_string(e.scrolltype)); + v.push_back(std::to_string(e.scrolllevel2)); + v.push_back(std::to_string(e.scrolllevel)); + v.push_back(std::to_string(e.UNK157)); + v.push_back("FROM_UNIXTIME(" + (e.serialized > 0 ? std::to_string(e.serialized) : "null") + ")"); + v.push_back("FROM_UNIXTIME(" + (e.verified > 0 ? std::to_string(e.verified) : "null") + ")"); + v.push_back("'" + Strings::Escape(e.serialization) + "'"); + v.push_back("'" + Strings::Escape(e.source) + "'"); + v.push_back(std::to_string(e.UNK033)); + v.push_back("'" + Strings::Escape(e.lorefile) + "'"); + v.push_back(std::to_string(e.UNK014)); + v.push_back(std::to_string(e.svcorruption)); + v.push_back(std::to_string(e.skillmodmax)); + v.push_back(std::to_string(e.UNK060)); + v.push_back(std::to_string(e.augslot1unk2)); + v.push_back(std::to_string(e.augslot2unk2)); + v.push_back(std::to_string(e.augslot3unk2)); + v.push_back(std::to_string(e.augslot4unk2)); + v.push_back(std::to_string(e.augslot5unk2)); + v.push_back(std::to_string(e.augslot6unk2)); + v.push_back(std::to_string(e.UNK120)); + v.push_back(std::to_string(e.UNK121)); + v.push_back(std::to_string(e.questitemflag)); + v.push_back("'" + Strings::Escape(e.UNK132) + "'"); + v.push_back(std::to_string(e.clickunk5)); + v.push_back("'" + Strings::Escape(e.clickunk6) + "'"); + v.push_back(std::to_string(e.clickunk7)); + v.push_back(std::to_string(e.procunk1)); + v.push_back(std::to_string(e.procunk2)); + v.push_back(std::to_string(e.procunk3)); + v.push_back(std::to_string(e.procunk4)); + v.push_back("'" + Strings::Escape(e.procunk6) + "'"); + v.push_back(std::to_string(e.procunk7)); + v.push_back(std::to_string(e.wornunk1)); + v.push_back(std::to_string(e.wornunk2)); + v.push_back(std::to_string(e.wornunk3)); + v.push_back(std::to_string(e.wornunk4)); + v.push_back(std::to_string(e.wornunk5)); + v.push_back("'" + Strings::Escape(e.wornunk6) + "'"); + v.push_back(std::to_string(e.wornunk7)); + v.push_back(std::to_string(e.focusunk1)); + v.push_back(std::to_string(e.focusunk2)); + v.push_back(std::to_string(e.focusunk3)); + v.push_back(std::to_string(e.focusunk4)); + v.push_back(std::to_string(e.focusunk5)); + v.push_back("'" + Strings::Escape(e.focusunk6) + "'"); + v.push_back(std::to_string(e.focusunk7)); + v.push_back(std::to_string(e.scrollunk1)); + v.push_back(std::to_string(e.scrollunk2)); + v.push_back(std::to_string(e.scrollunk3)); + v.push_back(std::to_string(e.scrollunk4)); + v.push_back(std::to_string(e.scrollunk5)); + v.push_back("'" + Strings::Escape(e.scrollunk6) + "'"); + v.push_back(std::to_string(e.scrollunk7)); + v.push_back(std::to_string(e.UNK193)); + v.push_back(std::to_string(e.purity)); + v.push_back(std::to_string(e.evoitem)); + v.push_back(std::to_string(e.evoid)); + v.push_back(std::to_string(e.evolvinglevel)); + v.push_back(std::to_string(e.evomax)); + v.push_back("'" + Strings::Escape(e.clickname) + "'"); + v.push_back("'" + Strings::Escape(e.procname) + "'"); + v.push_back("'" + Strings::Escape(e.wornname) + "'"); + v.push_back("'" + Strings::Escape(e.focusname) + "'"); + v.push_back("'" + Strings::Escape(e.scrollname) + "'"); + v.push_back(std::to_string(e.dsmitigation)); + v.push_back(std::to_string(e.heroic_str)); + v.push_back(std::to_string(e.heroic_int)); + v.push_back(std::to_string(e.heroic_wis)); + v.push_back(std::to_string(e.heroic_agi)); + v.push_back(std::to_string(e.heroic_dex)); + v.push_back(std::to_string(e.heroic_sta)); + v.push_back(std::to_string(e.heroic_cha)); + v.push_back(std::to_string(e.heroic_pr)); + v.push_back(std::to_string(e.heroic_dr)); + v.push_back(std::to_string(e.heroic_fr)); + v.push_back(std::to_string(e.heroic_cr)); + v.push_back(std::to_string(e.heroic_mr)); + v.push_back(std::to_string(e.heroic_svcorrup)); + v.push_back(std::to_string(e.healamt)); + v.push_back(std::to_string(e.spelldmg)); + v.push_back(std::to_string(e.clairvoyance)); + v.push_back(std::to_string(e.backstabdmg)); + v.push_back("'" + Strings::Escape(e.created) + "'"); + v.push_back(std::to_string(e.elitematerial)); + v.push_back(std::to_string(e.ldonsellbackrate)); + v.push_back(std::to_string(e.scriptfileid)); + v.push_back(std::to_string(e.expendablearrow)); + v.push_back(std::to_string(e.powersourcecapacity)); + v.push_back(std::to_string(e.bardeffect)); + v.push_back(std::to_string(e.bardeffecttype)); + v.push_back(std::to_string(e.bardlevel2)); + v.push_back(std::to_string(e.bardlevel)); + v.push_back(std::to_string(e.bardunk1)); + v.push_back(std::to_string(e.bardunk2)); + v.push_back(std::to_string(e.bardunk3)); + v.push_back(std::to_string(e.bardunk4)); + v.push_back(std::to_string(e.bardunk5)); + v.push_back("'" + Strings::Escape(e.bardname) + "'"); + v.push_back(std::to_string(e.bardunk7)); + v.push_back(std::to_string(e.UNK214)); + v.push_back(std::to_string(e.subtype)); + v.push_back(std::to_string(e.UNK220)); + v.push_back(std::to_string(e.UNK221)); + v.push_back(std::to_string(e.heirloom)); + v.push_back(std::to_string(e.UNK223)); + v.push_back(std::to_string(e.UNK224)); + v.push_back(std::to_string(e.UNK225)); + v.push_back(std::to_string(e.UNK226)); + v.push_back(std::to_string(e.UNK227)); + v.push_back(std::to_string(e.UNK228)); + v.push_back(std::to_string(e.UNK229)); + v.push_back(std::to_string(e.UNK230)); + v.push_back(std::to_string(e.UNK231)); + v.push_back(std::to_string(e.UNK232)); + v.push_back(std::to_string(e.UNK233)); + v.push_back(std::to_string(e.UNK234)); + v.push_back(std::to_string(e.placeable)); + v.push_back(std::to_string(e.UNK236)); + v.push_back(std::to_string(e.UNK237)); + v.push_back(std::to_string(e.UNK238)); + v.push_back(std::to_string(e.UNK239)); + v.push_back(std::to_string(e.UNK240)); + v.push_back(std::to_string(e.UNK241)); + v.push_back(std::to_string(e.epicitem)); - insert_chunks.push_back("(" + Strings::Implode(",", insert_values) + ")"); + insert_chunks.push_back("(" + Strings::Implode(",", v) + ")"); } - std::vector insert_values; + std::vector v; auto results = db.QueryDatabase( fmt::format( @@ -2504,301 +2504,301 @@ public: all_entries.reserve(results.RowCount()); for (auto row = results.begin(); row != results.end(); ++row) { - Items entry{}; + Items e{}; - entry.id = atoi(row[0]); - entry.minstatus = atoi(row[1]); - entry.Name = row[2] ? row[2] : ""; - entry.aagi = atoi(row[3]); - entry.ac = atoi(row[4]); - entry.accuracy = atoi(row[5]); - entry.acha = atoi(row[6]); - entry.adex = atoi(row[7]); - entry.aint = atoi(row[8]); - entry.artifactflag = atoi(row[9]); - entry.asta = atoi(row[10]); - entry.astr = atoi(row[11]); - entry.attack = atoi(row[12]); - entry.augrestrict = atoi(row[13]); - entry.augslot1type = atoi(row[14]); - entry.augslot1visible = atoi(row[15]); - entry.augslot2type = atoi(row[16]); - entry.augslot2visible = atoi(row[17]); - entry.augslot3type = atoi(row[18]); - entry.augslot3visible = atoi(row[19]); - entry.augslot4type = atoi(row[20]); - entry.augslot4visible = atoi(row[21]); - entry.augslot5type = atoi(row[22]); - entry.augslot5visible = atoi(row[23]); - entry.augslot6type = atoi(row[24]); - entry.augslot6visible = atoi(row[25]); - entry.augtype = atoi(row[26]); - entry.avoidance = atoi(row[27]); - entry.awis = atoi(row[28]); - entry.bagsize = atoi(row[29]); - entry.bagslots = atoi(row[30]); - entry.bagtype = atoi(row[31]); - entry.bagwr = atoi(row[32]); - entry.banedmgamt = atoi(row[33]); - entry.banedmgraceamt = atoi(row[34]); - entry.banedmgbody = atoi(row[35]); - entry.banedmgrace = atoi(row[36]); - entry.bardtype = atoi(row[37]); - entry.bardvalue = atoi(row[38]); - entry.book = atoi(row[39]); - entry.casttime = atoi(row[40]); - entry.casttime_ = atoi(row[41]); - entry.charmfile = row[42] ? row[42] : ""; - entry.charmfileid = row[43] ? row[43] : ""; - entry.classes = atoi(row[44]); - entry.color = atoi(row[45]); - entry.combateffects = row[46] ? row[46] : ""; - entry.extradmgskill = atoi(row[47]); - entry.extradmgamt = atoi(row[48]); - entry.price = atoi(row[49]); - entry.cr = atoi(row[50]); - entry.damage = atoi(row[51]); - entry.damageshield = atoi(row[52]); - entry.deity = atoi(row[53]); - entry.delay = atoi(row[54]); - entry.augdistiller = atoi(row[55]); - entry.dotshielding = atoi(row[56]); - entry.dr = atoi(row[57]); - entry.clicktype = atoi(row[58]); - entry.clicklevel2 = atoi(row[59]); - entry.elemdmgtype = atoi(row[60]); - entry.elemdmgamt = atoi(row[61]); - entry.endur = atoi(row[62]); - entry.factionamt1 = atoi(row[63]); - entry.factionamt2 = atoi(row[64]); - entry.factionamt3 = atoi(row[65]); - entry.factionamt4 = atoi(row[66]); - entry.factionmod1 = atoi(row[67]); - entry.factionmod2 = atoi(row[68]); - entry.factionmod3 = atoi(row[69]); - entry.factionmod4 = atoi(row[70]); - entry.filename = row[71] ? row[71] : ""; - entry.focuseffect = atoi(row[72]); - entry.fr = atoi(row[73]); - entry.fvnodrop = atoi(row[74]); - entry.haste = atoi(row[75]); - entry.clicklevel = atoi(row[76]); - entry.hp = atoi(row[77]); - entry.regen = atoi(row[78]); - entry.icon = atoi(row[79]); - entry.idfile = row[80] ? row[80] : ""; - entry.itemclass = atoi(row[81]); - entry.itemtype = atoi(row[82]); - entry.ldonprice = atoi(row[83]); - entry.ldontheme = atoi(row[84]); - entry.ldonsold = atoi(row[85]); - entry.light = atoi(row[86]); - entry.lore = row[87] ? row[87] : ""; - entry.loregroup = atoi(row[88]); - entry.magic = atoi(row[89]); - entry.mana = atoi(row[90]); - entry.manaregen = atoi(row[91]); - entry.enduranceregen = atoi(row[92]); - entry.material = atoi(row[93]); - entry.herosforgemodel = atoi(row[94]); - entry.maxcharges = atoi(row[95]); - entry.mr = atoi(row[96]); - entry.nodrop = atoi(row[97]); - entry.norent = atoi(row[98]); - entry.pendingloreflag = atoi(row[99]); - entry.pr = atoi(row[100]); - entry.procrate = atoi(row[101]); - entry.races = atoi(row[102]); - entry.range = atoi(row[103]); - entry.reclevel = atoi(row[104]); - entry.recskill = atoi(row[105]); - entry.reqlevel = atoi(row[106]); - entry.sellrate = static_cast(atof(row[107])); - entry.shielding = atoi(row[108]); - entry.size = atoi(row[109]); - entry.skillmodtype = atoi(row[110]); - entry.skillmodvalue = atoi(row[111]); - entry.slots = atoi(row[112]); - entry.clickeffect = atoi(row[113]); - entry.spellshield = atoi(row[114]); - entry.strikethrough = atoi(row[115]); - entry.stunresist = atoi(row[116]); - entry.summonedflag = atoi(row[117]); - entry.tradeskills = atoi(row[118]); - entry.favor = atoi(row[119]); - entry.weight = atoi(row[120]); - entry.UNK012 = atoi(row[121]); - entry.UNK013 = atoi(row[122]); - entry.benefitflag = atoi(row[123]); - entry.UNK054 = atoi(row[124]); - entry.UNK059 = atoi(row[125]); - entry.booktype = atoi(row[126]); - entry.recastdelay = atoi(row[127]); - entry.recasttype = atoi(row[128]); - entry.guildfavor = atoi(row[129]); - entry.UNK123 = atoi(row[130]); - entry.UNK124 = atoi(row[131]); - entry.attuneable = atoi(row[132]); - entry.nopet = atoi(row[133]); - entry.updated = strtoll(row[134] ? row[134] : "-1", nullptr, 10); - entry.comment = row[135] ? row[135] : ""; - entry.UNK127 = atoi(row[136]); - entry.pointtype = atoi(row[137]); - entry.potionbelt = atoi(row[138]); - entry.potionbeltslots = atoi(row[139]); - entry.stacksize = atoi(row[140]); - entry.notransfer = atoi(row[141]); - entry.stackable = atoi(row[142]); - entry.UNK134 = row[143] ? row[143] : ""; - entry.UNK137 = atoi(row[144]); - entry.proceffect = atoi(row[145]); - entry.proctype = atoi(row[146]); - entry.proclevel2 = atoi(row[147]); - entry.proclevel = atoi(row[148]); - entry.UNK142 = atoi(row[149]); - entry.worneffect = atoi(row[150]); - entry.worntype = atoi(row[151]); - entry.wornlevel2 = atoi(row[152]); - entry.wornlevel = atoi(row[153]); - entry.UNK147 = atoi(row[154]); - entry.focustype = atoi(row[155]); - entry.focuslevel2 = atoi(row[156]); - entry.focuslevel = atoi(row[157]); - entry.UNK152 = atoi(row[158]); - entry.scrolleffect = atoi(row[159]); - entry.scrolltype = atoi(row[160]); - entry.scrolllevel2 = atoi(row[161]); - entry.scrolllevel = atoi(row[162]); - entry.UNK157 = atoi(row[163]); - entry.serialized = strtoll(row[164] ? row[164] : "-1", nullptr, 10); - entry.verified = strtoll(row[165] ? row[165] : "-1", nullptr, 10); - entry.serialization = row[166] ? row[166] : ""; - entry.source = row[167] ? row[167] : ""; - entry.UNK033 = atoi(row[168]); - entry.lorefile = row[169] ? row[169] : ""; - entry.UNK014 = atoi(row[170]); - entry.svcorruption = atoi(row[171]); - entry.skillmodmax = atoi(row[172]); - entry.UNK060 = atoi(row[173]); - entry.augslot1unk2 = atoi(row[174]); - entry.augslot2unk2 = atoi(row[175]); - entry.augslot3unk2 = atoi(row[176]); - entry.augslot4unk2 = atoi(row[177]); - entry.augslot5unk2 = atoi(row[178]); - entry.augslot6unk2 = atoi(row[179]); - entry.UNK120 = atoi(row[180]); - entry.UNK121 = atoi(row[181]); - entry.questitemflag = atoi(row[182]); - entry.UNK132 = row[183] ? row[183] : ""; - entry.clickunk5 = atoi(row[184]); - entry.clickunk6 = row[185] ? row[185] : ""; - entry.clickunk7 = atoi(row[186]); - entry.procunk1 = atoi(row[187]); - entry.procunk2 = atoi(row[188]); - entry.procunk3 = atoi(row[189]); - entry.procunk4 = atoi(row[190]); - entry.procunk6 = row[191] ? row[191] : ""; - entry.procunk7 = atoi(row[192]); - entry.wornunk1 = atoi(row[193]); - entry.wornunk2 = atoi(row[194]); - entry.wornunk3 = atoi(row[195]); - entry.wornunk4 = atoi(row[196]); - entry.wornunk5 = atoi(row[197]); - entry.wornunk6 = row[198] ? row[198] : ""; - entry.wornunk7 = atoi(row[199]); - entry.focusunk1 = atoi(row[200]); - entry.focusunk2 = atoi(row[201]); - entry.focusunk3 = atoi(row[202]); - entry.focusunk4 = atoi(row[203]); - entry.focusunk5 = atoi(row[204]); - entry.focusunk6 = row[205] ? row[205] : ""; - entry.focusunk7 = atoi(row[206]); - entry.scrollunk1 = atoi(row[207]); - entry.scrollunk2 = atoi(row[208]); - entry.scrollunk3 = atoi(row[209]); - entry.scrollunk4 = atoi(row[210]); - entry.scrollunk5 = atoi(row[211]); - entry.scrollunk6 = row[212] ? row[212] : ""; - entry.scrollunk7 = atoi(row[213]); - entry.UNK193 = atoi(row[214]); - entry.purity = atoi(row[215]); - entry.evoitem = atoi(row[216]); - entry.evoid = atoi(row[217]); - entry.evolvinglevel = atoi(row[218]); - entry.evomax = atoi(row[219]); - entry.clickname = row[220] ? row[220] : ""; - entry.procname = row[221] ? row[221] : ""; - entry.wornname = row[222] ? row[222] : ""; - entry.focusname = row[223] ? row[223] : ""; - entry.scrollname = row[224] ? row[224] : ""; - entry.dsmitigation = atoi(row[225]); - entry.heroic_str = atoi(row[226]); - entry.heroic_int = atoi(row[227]); - entry.heroic_wis = atoi(row[228]); - entry.heroic_agi = atoi(row[229]); - entry.heroic_dex = atoi(row[230]); - entry.heroic_sta = atoi(row[231]); - entry.heroic_cha = atoi(row[232]); - entry.heroic_pr = atoi(row[233]); - entry.heroic_dr = atoi(row[234]); - entry.heroic_fr = atoi(row[235]); - entry.heroic_cr = atoi(row[236]); - entry.heroic_mr = atoi(row[237]); - entry.heroic_svcorrup = atoi(row[238]); - entry.healamt = atoi(row[239]); - entry.spelldmg = atoi(row[240]); - entry.clairvoyance = atoi(row[241]); - entry.backstabdmg = atoi(row[242]); - entry.created = row[243] ? row[243] : ""; - entry.elitematerial = atoi(row[244]); - entry.ldonsellbackrate = atoi(row[245]); - entry.scriptfileid = atoi(row[246]); - entry.expendablearrow = atoi(row[247]); - entry.powersourcecapacity = atoi(row[248]); - entry.bardeffect = atoi(row[249]); - entry.bardeffecttype = atoi(row[250]); - entry.bardlevel2 = atoi(row[251]); - entry.bardlevel = atoi(row[252]); - entry.bardunk1 = atoi(row[253]); - entry.bardunk2 = atoi(row[254]); - entry.bardunk3 = atoi(row[255]); - entry.bardunk4 = atoi(row[256]); - entry.bardunk5 = atoi(row[257]); - entry.bardname = row[258] ? row[258] : ""; - entry.bardunk7 = atoi(row[259]); - entry.UNK214 = atoi(row[260]); - entry.subtype = atoi(row[261]); - entry.UNK220 = atoi(row[262]); - entry.UNK221 = atoi(row[263]); - entry.heirloom = atoi(row[264]); - entry.UNK223 = atoi(row[265]); - entry.UNK224 = atoi(row[266]); - entry.UNK225 = atoi(row[267]); - entry.UNK226 = atoi(row[268]); - entry.UNK227 = atoi(row[269]); - entry.UNK228 = atoi(row[270]); - entry.UNK229 = atoi(row[271]); - entry.UNK230 = atoi(row[272]); - entry.UNK231 = atoi(row[273]); - entry.UNK232 = atoi(row[274]); - entry.UNK233 = atoi(row[275]); - entry.UNK234 = atoi(row[276]); - entry.placeable = atoi(row[277]); - entry.UNK236 = atoi(row[278]); - entry.UNK237 = atoi(row[279]); - entry.UNK238 = atoi(row[280]); - entry.UNK239 = atoi(row[281]); - entry.UNK240 = atoi(row[282]); - entry.UNK241 = atoi(row[283]); - entry.epicitem = atoi(row[284]); + e.id = atoi(row[0]); + e.minstatus = atoi(row[1]); + e.Name = row[2] ? row[2] : ""; + e.aagi = atoi(row[3]); + e.ac = atoi(row[4]); + e.accuracy = atoi(row[5]); + e.acha = atoi(row[6]); + e.adex = atoi(row[7]); + e.aint = atoi(row[8]); + e.artifactflag = atoi(row[9]); + e.asta = atoi(row[10]); + e.astr = atoi(row[11]); + e.attack = atoi(row[12]); + e.augrestrict = atoi(row[13]); + e.augslot1type = atoi(row[14]); + e.augslot1visible = atoi(row[15]); + e.augslot2type = atoi(row[16]); + e.augslot2visible = atoi(row[17]); + e.augslot3type = atoi(row[18]); + e.augslot3visible = atoi(row[19]); + e.augslot4type = atoi(row[20]); + e.augslot4visible = atoi(row[21]); + e.augslot5type = atoi(row[22]); + e.augslot5visible = atoi(row[23]); + e.augslot6type = atoi(row[24]); + e.augslot6visible = atoi(row[25]); + e.augtype = atoi(row[26]); + e.avoidance = atoi(row[27]); + e.awis = atoi(row[28]); + e.bagsize = atoi(row[29]); + e.bagslots = atoi(row[30]); + e.bagtype = atoi(row[31]); + e.bagwr = atoi(row[32]); + e.banedmgamt = atoi(row[33]); + e.banedmgraceamt = atoi(row[34]); + e.banedmgbody = atoi(row[35]); + e.banedmgrace = atoi(row[36]); + e.bardtype = atoi(row[37]); + e.bardvalue = atoi(row[38]); + e.book = atoi(row[39]); + e.casttime = atoi(row[40]); + e.casttime_ = atoi(row[41]); + e.charmfile = row[42] ? row[42] : ""; + e.charmfileid = row[43] ? row[43] : ""; + e.classes = atoi(row[44]); + e.color = atoi(row[45]); + e.combateffects = row[46] ? row[46] : ""; + e.extradmgskill = atoi(row[47]); + e.extradmgamt = atoi(row[48]); + e.price = atoi(row[49]); + e.cr = atoi(row[50]); + e.damage = atoi(row[51]); + e.damageshield = atoi(row[52]); + e.deity = atoi(row[53]); + e.delay = atoi(row[54]); + e.augdistiller = atoi(row[55]); + e.dotshielding = atoi(row[56]); + e.dr = atoi(row[57]); + e.clicktype = atoi(row[58]); + e.clicklevel2 = atoi(row[59]); + e.elemdmgtype = atoi(row[60]); + e.elemdmgamt = atoi(row[61]); + e.endur = atoi(row[62]); + e.factionamt1 = atoi(row[63]); + e.factionamt2 = atoi(row[64]); + e.factionamt3 = atoi(row[65]); + e.factionamt4 = atoi(row[66]); + e.factionmod1 = atoi(row[67]); + e.factionmod2 = atoi(row[68]); + e.factionmod3 = atoi(row[69]); + e.factionmod4 = atoi(row[70]); + e.filename = row[71] ? row[71] : ""; + e.focuseffect = atoi(row[72]); + e.fr = atoi(row[73]); + e.fvnodrop = atoi(row[74]); + e.haste = atoi(row[75]); + e.clicklevel = atoi(row[76]); + e.hp = atoi(row[77]); + e.regen = atoi(row[78]); + e.icon = atoi(row[79]); + e.idfile = row[80] ? row[80] : ""; + e.itemclass = atoi(row[81]); + e.itemtype = atoi(row[82]); + e.ldonprice = atoi(row[83]); + e.ldontheme = atoi(row[84]); + e.ldonsold = atoi(row[85]); + e.light = atoi(row[86]); + e.lore = row[87] ? row[87] : ""; + e.loregroup = atoi(row[88]); + e.magic = atoi(row[89]); + e.mana = atoi(row[90]); + e.manaregen = atoi(row[91]); + e.enduranceregen = atoi(row[92]); + e.material = atoi(row[93]); + e.herosforgemodel = atoi(row[94]); + e.maxcharges = atoi(row[95]); + e.mr = atoi(row[96]); + e.nodrop = atoi(row[97]); + e.norent = atoi(row[98]); + e.pendingloreflag = atoi(row[99]); + e.pr = atoi(row[100]); + e.procrate = atoi(row[101]); + e.races = atoi(row[102]); + e.range = atoi(row[103]); + e.reclevel = atoi(row[104]); + e.recskill = atoi(row[105]); + e.reqlevel = atoi(row[106]); + e.sellrate = static_cast(atof(row[107])); + e.shielding = atoi(row[108]); + e.size = atoi(row[109]); + e.skillmodtype = atoi(row[110]); + e.skillmodvalue = atoi(row[111]); + e.slots = atoi(row[112]); + e.clickeffect = atoi(row[113]); + e.spellshield = atoi(row[114]); + e.strikethrough = atoi(row[115]); + e.stunresist = atoi(row[116]); + e.summonedflag = atoi(row[117]); + e.tradeskills = atoi(row[118]); + e.favor = atoi(row[119]); + e.weight = atoi(row[120]); + e.UNK012 = atoi(row[121]); + e.UNK013 = atoi(row[122]); + e.benefitflag = atoi(row[123]); + e.UNK054 = atoi(row[124]); + e.UNK059 = atoi(row[125]); + e.booktype = atoi(row[126]); + e.recastdelay = atoi(row[127]); + e.recasttype = atoi(row[128]); + e.guildfavor = atoi(row[129]); + e.UNK123 = atoi(row[130]); + e.UNK124 = atoi(row[131]); + e.attuneable = atoi(row[132]); + e.nopet = atoi(row[133]); + e.updated = strtoll(row[134] ? row[134] : "-1", nullptr, 10); + e.comment = row[135] ? row[135] : ""; + e.UNK127 = atoi(row[136]); + e.pointtype = atoi(row[137]); + e.potionbelt = atoi(row[138]); + e.potionbeltslots = atoi(row[139]); + e.stacksize = atoi(row[140]); + e.notransfer = atoi(row[141]); + e.stackable = atoi(row[142]); + e.UNK134 = row[143] ? row[143] : ""; + e.UNK137 = atoi(row[144]); + e.proceffect = atoi(row[145]); + e.proctype = atoi(row[146]); + e.proclevel2 = atoi(row[147]); + e.proclevel = atoi(row[148]); + e.UNK142 = atoi(row[149]); + e.worneffect = atoi(row[150]); + e.worntype = atoi(row[151]); + e.wornlevel2 = atoi(row[152]); + e.wornlevel = atoi(row[153]); + e.UNK147 = atoi(row[154]); + e.focustype = atoi(row[155]); + e.focuslevel2 = atoi(row[156]); + e.focuslevel = atoi(row[157]); + e.UNK152 = atoi(row[158]); + e.scrolleffect = atoi(row[159]); + e.scrolltype = atoi(row[160]); + e.scrolllevel2 = atoi(row[161]); + e.scrolllevel = atoi(row[162]); + e.UNK157 = atoi(row[163]); + e.serialized = strtoll(row[164] ? row[164] : "-1", nullptr, 10); + e.verified = strtoll(row[165] ? row[165] : "-1", nullptr, 10); + e.serialization = row[166] ? row[166] : ""; + e.source = row[167] ? row[167] : ""; + e.UNK033 = atoi(row[168]); + e.lorefile = row[169] ? row[169] : ""; + e.UNK014 = atoi(row[170]); + e.svcorruption = atoi(row[171]); + e.skillmodmax = atoi(row[172]); + e.UNK060 = atoi(row[173]); + e.augslot1unk2 = atoi(row[174]); + e.augslot2unk2 = atoi(row[175]); + e.augslot3unk2 = atoi(row[176]); + e.augslot4unk2 = atoi(row[177]); + e.augslot5unk2 = atoi(row[178]); + e.augslot6unk2 = atoi(row[179]); + e.UNK120 = atoi(row[180]); + e.UNK121 = atoi(row[181]); + e.questitemflag = atoi(row[182]); + e.UNK132 = row[183] ? row[183] : ""; + e.clickunk5 = atoi(row[184]); + e.clickunk6 = row[185] ? row[185] : ""; + e.clickunk7 = atoi(row[186]); + e.procunk1 = atoi(row[187]); + e.procunk2 = atoi(row[188]); + e.procunk3 = atoi(row[189]); + e.procunk4 = atoi(row[190]); + e.procunk6 = row[191] ? row[191] : ""; + e.procunk7 = atoi(row[192]); + e.wornunk1 = atoi(row[193]); + e.wornunk2 = atoi(row[194]); + e.wornunk3 = atoi(row[195]); + e.wornunk4 = atoi(row[196]); + e.wornunk5 = atoi(row[197]); + e.wornunk6 = row[198] ? row[198] : ""; + e.wornunk7 = atoi(row[199]); + e.focusunk1 = atoi(row[200]); + e.focusunk2 = atoi(row[201]); + e.focusunk3 = atoi(row[202]); + e.focusunk4 = atoi(row[203]); + e.focusunk5 = atoi(row[204]); + e.focusunk6 = row[205] ? row[205] : ""; + e.focusunk7 = atoi(row[206]); + e.scrollunk1 = atoi(row[207]); + e.scrollunk2 = atoi(row[208]); + e.scrollunk3 = atoi(row[209]); + e.scrollunk4 = atoi(row[210]); + e.scrollunk5 = atoi(row[211]); + e.scrollunk6 = row[212] ? row[212] : ""; + e.scrollunk7 = atoi(row[213]); + e.UNK193 = atoi(row[214]); + e.purity = atoi(row[215]); + e.evoitem = atoi(row[216]); + e.evoid = atoi(row[217]); + e.evolvinglevel = atoi(row[218]); + e.evomax = atoi(row[219]); + e.clickname = row[220] ? row[220] : ""; + e.procname = row[221] ? row[221] : ""; + e.wornname = row[222] ? row[222] : ""; + e.focusname = row[223] ? row[223] : ""; + e.scrollname = row[224] ? row[224] : ""; + e.dsmitigation = atoi(row[225]); + e.heroic_str = atoi(row[226]); + e.heroic_int = atoi(row[227]); + e.heroic_wis = atoi(row[228]); + e.heroic_agi = atoi(row[229]); + e.heroic_dex = atoi(row[230]); + e.heroic_sta = atoi(row[231]); + e.heroic_cha = atoi(row[232]); + e.heroic_pr = atoi(row[233]); + e.heroic_dr = atoi(row[234]); + e.heroic_fr = atoi(row[235]); + e.heroic_cr = atoi(row[236]); + e.heroic_mr = atoi(row[237]); + e.heroic_svcorrup = atoi(row[238]); + e.healamt = atoi(row[239]); + e.spelldmg = atoi(row[240]); + e.clairvoyance = atoi(row[241]); + e.backstabdmg = atoi(row[242]); + e.created = row[243] ? row[243] : ""; + e.elitematerial = atoi(row[244]); + e.ldonsellbackrate = atoi(row[245]); + e.scriptfileid = atoi(row[246]); + e.expendablearrow = atoi(row[247]); + e.powersourcecapacity = atoi(row[248]); + e.bardeffect = atoi(row[249]); + e.bardeffecttype = atoi(row[250]); + e.bardlevel2 = atoi(row[251]); + e.bardlevel = atoi(row[252]); + e.bardunk1 = atoi(row[253]); + e.bardunk2 = atoi(row[254]); + e.bardunk3 = atoi(row[255]); + e.bardunk4 = atoi(row[256]); + e.bardunk5 = atoi(row[257]); + e.bardname = row[258] ? row[258] : ""; + e.bardunk7 = atoi(row[259]); + e.UNK214 = atoi(row[260]); + e.subtype = atoi(row[261]); + e.UNK220 = atoi(row[262]); + e.UNK221 = atoi(row[263]); + e.heirloom = atoi(row[264]); + e.UNK223 = atoi(row[265]); + e.UNK224 = atoi(row[266]); + e.UNK225 = atoi(row[267]); + e.UNK226 = atoi(row[268]); + e.UNK227 = atoi(row[269]); + e.UNK228 = atoi(row[270]); + e.UNK229 = atoi(row[271]); + e.UNK230 = atoi(row[272]); + e.UNK231 = atoi(row[273]); + e.UNK232 = atoi(row[274]); + e.UNK233 = atoi(row[275]); + e.UNK234 = atoi(row[276]); + e.placeable = atoi(row[277]); + e.UNK236 = atoi(row[278]); + e.UNK237 = atoi(row[279]); + e.UNK238 = atoi(row[280]); + e.UNK239 = atoi(row[281]); + e.UNK240 = atoi(row[282]); + e.UNK241 = atoi(row[283]); + e.epicitem = atoi(row[284]); - all_entries.push_back(entry); + all_entries.push_back(e); } return all_entries; } - static std::vector GetWhere(Database& db, std::string where_filter) + static std::vector GetWhere(Database& db, const std::string &where_filter) { std::vector all_entries; @@ -2813,301 +2813,301 @@ public: all_entries.reserve(results.RowCount()); for (auto row = results.begin(); row != results.end(); ++row) { - Items entry{}; + Items e{}; - entry.id = atoi(row[0]); - entry.minstatus = atoi(row[1]); - entry.Name = row[2] ? row[2] : ""; - entry.aagi = atoi(row[3]); - entry.ac = atoi(row[4]); - entry.accuracy = atoi(row[5]); - entry.acha = atoi(row[6]); - entry.adex = atoi(row[7]); - entry.aint = atoi(row[8]); - entry.artifactflag = atoi(row[9]); - entry.asta = atoi(row[10]); - entry.astr = atoi(row[11]); - entry.attack = atoi(row[12]); - entry.augrestrict = atoi(row[13]); - entry.augslot1type = atoi(row[14]); - entry.augslot1visible = atoi(row[15]); - entry.augslot2type = atoi(row[16]); - entry.augslot2visible = atoi(row[17]); - entry.augslot3type = atoi(row[18]); - entry.augslot3visible = atoi(row[19]); - entry.augslot4type = atoi(row[20]); - entry.augslot4visible = atoi(row[21]); - entry.augslot5type = atoi(row[22]); - entry.augslot5visible = atoi(row[23]); - entry.augslot6type = atoi(row[24]); - entry.augslot6visible = atoi(row[25]); - entry.augtype = atoi(row[26]); - entry.avoidance = atoi(row[27]); - entry.awis = atoi(row[28]); - entry.bagsize = atoi(row[29]); - entry.bagslots = atoi(row[30]); - entry.bagtype = atoi(row[31]); - entry.bagwr = atoi(row[32]); - entry.banedmgamt = atoi(row[33]); - entry.banedmgraceamt = atoi(row[34]); - entry.banedmgbody = atoi(row[35]); - entry.banedmgrace = atoi(row[36]); - entry.bardtype = atoi(row[37]); - entry.bardvalue = atoi(row[38]); - entry.book = atoi(row[39]); - entry.casttime = atoi(row[40]); - entry.casttime_ = atoi(row[41]); - entry.charmfile = row[42] ? row[42] : ""; - entry.charmfileid = row[43] ? row[43] : ""; - entry.classes = atoi(row[44]); - entry.color = atoi(row[45]); - entry.combateffects = row[46] ? row[46] : ""; - entry.extradmgskill = atoi(row[47]); - entry.extradmgamt = atoi(row[48]); - entry.price = atoi(row[49]); - entry.cr = atoi(row[50]); - entry.damage = atoi(row[51]); - entry.damageshield = atoi(row[52]); - entry.deity = atoi(row[53]); - entry.delay = atoi(row[54]); - entry.augdistiller = atoi(row[55]); - entry.dotshielding = atoi(row[56]); - entry.dr = atoi(row[57]); - entry.clicktype = atoi(row[58]); - entry.clicklevel2 = atoi(row[59]); - entry.elemdmgtype = atoi(row[60]); - entry.elemdmgamt = atoi(row[61]); - entry.endur = atoi(row[62]); - entry.factionamt1 = atoi(row[63]); - entry.factionamt2 = atoi(row[64]); - entry.factionamt3 = atoi(row[65]); - entry.factionamt4 = atoi(row[66]); - entry.factionmod1 = atoi(row[67]); - entry.factionmod2 = atoi(row[68]); - entry.factionmod3 = atoi(row[69]); - entry.factionmod4 = atoi(row[70]); - entry.filename = row[71] ? row[71] : ""; - entry.focuseffect = atoi(row[72]); - entry.fr = atoi(row[73]); - entry.fvnodrop = atoi(row[74]); - entry.haste = atoi(row[75]); - entry.clicklevel = atoi(row[76]); - entry.hp = atoi(row[77]); - entry.regen = atoi(row[78]); - entry.icon = atoi(row[79]); - entry.idfile = row[80] ? row[80] : ""; - entry.itemclass = atoi(row[81]); - entry.itemtype = atoi(row[82]); - entry.ldonprice = atoi(row[83]); - entry.ldontheme = atoi(row[84]); - entry.ldonsold = atoi(row[85]); - entry.light = atoi(row[86]); - entry.lore = row[87] ? row[87] : ""; - entry.loregroup = atoi(row[88]); - entry.magic = atoi(row[89]); - entry.mana = atoi(row[90]); - entry.manaregen = atoi(row[91]); - entry.enduranceregen = atoi(row[92]); - entry.material = atoi(row[93]); - entry.herosforgemodel = atoi(row[94]); - entry.maxcharges = atoi(row[95]); - entry.mr = atoi(row[96]); - entry.nodrop = atoi(row[97]); - entry.norent = atoi(row[98]); - entry.pendingloreflag = atoi(row[99]); - entry.pr = atoi(row[100]); - entry.procrate = atoi(row[101]); - entry.races = atoi(row[102]); - entry.range = atoi(row[103]); - entry.reclevel = atoi(row[104]); - entry.recskill = atoi(row[105]); - entry.reqlevel = atoi(row[106]); - entry.sellrate = static_cast(atof(row[107])); - entry.shielding = atoi(row[108]); - entry.size = atoi(row[109]); - entry.skillmodtype = atoi(row[110]); - entry.skillmodvalue = atoi(row[111]); - entry.slots = atoi(row[112]); - entry.clickeffect = atoi(row[113]); - entry.spellshield = atoi(row[114]); - entry.strikethrough = atoi(row[115]); - entry.stunresist = atoi(row[116]); - entry.summonedflag = atoi(row[117]); - entry.tradeskills = atoi(row[118]); - entry.favor = atoi(row[119]); - entry.weight = atoi(row[120]); - entry.UNK012 = atoi(row[121]); - entry.UNK013 = atoi(row[122]); - entry.benefitflag = atoi(row[123]); - entry.UNK054 = atoi(row[124]); - entry.UNK059 = atoi(row[125]); - entry.booktype = atoi(row[126]); - entry.recastdelay = atoi(row[127]); - entry.recasttype = atoi(row[128]); - entry.guildfavor = atoi(row[129]); - entry.UNK123 = atoi(row[130]); - entry.UNK124 = atoi(row[131]); - entry.attuneable = atoi(row[132]); - entry.nopet = atoi(row[133]); - entry.updated = strtoll(row[134] ? row[134] : "-1", nullptr, 10); - entry.comment = row[135] ? row[135] : ""; - entry.UNK127 = atoi(row[136]); - entry.pointtype = atoi(row[137]); - entry.potionbelt = atoi(row[138]); - entry.potionbeltslots = atoi(row[139]); - entry.stacksize = atoi(row[140]); - entry.notransfer = atoi(row[141]); - entry.stackable = atoi(row[142]); - entry.UNK134 = row[143] ? row[143] : ""; - entry.UNK137 = atoi(row[144]); - entry.proceffect = atoi(row[145]); - entry.proctype = atoi(row[146]); - entry.proclevel2 = atoi(row[147]); - entry.proclevel = atoi(row[148]); - entry.UNK142 = atoi(row[149]); - entry.worneffect = atoi(row[150]); - entry.worntype = atoi(row[151]); - entry.wornlevel2 = atoi(row[152]); - entry.wornlevel = atoi(row[153]); - entry.UNK147 = atoi(row[154]); - entry.focustype = atoi(row[155]); - entry.focuslevel2 = atoi(row[156]); - entry.focuslevel = atoi(row[157]); - entry.UNK152 = atoi(row[158]); - entry.scrolleffect = atoi(row[159]); - entry.scrolltype = atoi(row[160]); - entry.scrolllevel2 = atoi(row[161]); - entry.scrolllevel = atoi(row[162]); - entry.UNK157 = atoi(row[163]); - entry.serialized = strtoll(row[164] ? row[164] : "-1", nullptr, 10); - entry.verified = strtoll(row[165] ? row[165] : "-1", nullptr, 10); - entry.serialization = row[166] ? row[166] : ""; - entry.source = row[167] ? row[167] : ""; - entry.UNK033 = atoi(row[168]); - entry.lorefile = row[169] ? row[169] : ""; - entry.UNK014 = atoi(row[170]); - entry.svcorruption = atoi(row[171]); - entry.skillmodmax = atoi(row[172]); - entry.UNK060 = atoi(row[173]); - entry.augslot1unk2 = atoi(row[174]); - entry.augslot2unk2 = atoi(row[175]); - entry.augslot3unk2 = atoi(row[176]); - entry.augslot4unk2 = atoi(row[177]); - entry.augslot5unk2 = atoi(row[178]); - entry.augslot6unk2 = atoi(row[179]); - entry.UNK120 = atoi(row[180]); - entry.UNK121 = atoi(row[181]); - entry.questitemflag = atoi(row[182]); - entry.UNK132 = row[183] ? row[183] : ""; - entry.clickunk5 = atoi(row[184]); - entry.clickunk6 = row[185] ? row[185] : ""; - entry.clickunk7 = atoi(row[186]); - entry.procunk1 = atoi(row[187]); - entry.procunk2 = atoi(row[188]); - entry.procunk3 = atoi(row[189]); - entry.procunk4 = atoi(row[190]); - entry.procunk6 = row[191] ? row[191] : ""; - entry.procunk7 = atoi(row[192]); - entry.wornunk1 = atoi(row[193]); - entry.wornunk2 = atoi(row[194]); - entry.wornunk3 = atoi(row[195]); - entry.wornunk4 = atoi(row[196]); - entry.wornunk5 = atoi(row[197]); - entry.wornunk6 = row[198] ? row[198] : ""; - entry.wornunk7 = atoi(row[199]); - entry.focusunk1 = atoi(row[200]); - entry.focusunk2 = atoi(row[201]); - entry.focusunk3 = atoi(row[202]); - entry.focusunk4 = atoi(row[203]); - entry.focusunk5 = atoi(row[204]); - entry.focusunk6 = row[205] ? row[205] : ""; - entry.focusunk7 = atoi(row[206]); - entry.scrollunk1 = atoi(row[207]); - entry.scrollunk2 = atoi(row[208]); - entry.scrollunk3 = atoi(row[209]); - entry.scrollunk4 = atoi(row[210]); - entry.scrollunk5 = atoi(row[211]); - entry.scrollunk6 = row[212] ? row[212] : ""; - entry.scrollunk7 = atoi(row[213]); - entry.UNK193 = atoi(row[214]); - entry.purity = atoi(row[215]); - entry.evoitem = atoi(row[216]); - entry.evoid = atoi(row[217]); - entry.evolvinglevel = atoi(row[218]); - entry.evomax = atoi(row[219]); - entry.clickname = row[220] ? row[220] : ""; - entry.procname = row[221] ? row[221] : ""; - entry.wornname = row[222] ? row[222] : ""; - entry.focusname = row[223] ? row[223] : ""; - entry.scrollname = row[224] ? row[224] : ""; - entry.dsmitigation = atoi(row[225]); - entry.heroic_str = atoi(row[226]); - entry.heroic_int = atoi(row[227]); - entry.heroic_wis = atoi(row[228]); - entry.heroic_agi = atoi(row[229]); - entry.heroic_dex = atoi(row[230]); - entry.heroic_sta = atoi(row[231]); - entry.heroic_cha = atoi(row[232]); - entry.heroic_pr = atoi(row[233]); - entry.heroic_dr = atoi(row[234]); - entry.heroic_fr = atoi(row[235]); - entry.heroic_cr = atoi(row[236]); - entry.heroic_mr = atoi(row[237]); - entry.heroic_svcorrup = atoi(row[238]); - entry.healamt = atoi(row[239]); - entry.spelldmg = atoi(row[240]); - entry.clairvoyance = atoi(row[241]); - entry.backstabdmg = atoi(row[242]); - entry.created = row[243] ? row[243] : ""; - entry.elitematerial = atoi(row[244]); - entry.ldonsellbackrate = atoi(row[245]); - entry.scriptfileid = atoi(row[246]); - entry.expendablearrow = atoi(row[247]); - entry.powersourcecapacity = atoi(row[248]); - entry.bardeffect = atoi(row[249]); - entry.bardeffecttype = atoi(row[250]); - entry.bardlevel2 = atoi(row[251]); - entry.bardlevel = atoi(row[252]); - entry.bardunk1 = atoi(row[253]); - entry.bardunk2 = atoi(row[254]); - entry.bardunk3 = atoi(row[255]); - entry.bardunk4 = atoi(row[256]); - entry.bardunk5 = atoi(row[257]); - entry.bardname = row[258] ? row[258] : ""; - entry.bardunk7 = atoi(row[259]); - entry.UNK214 = atoi(row[260]); - entry.subtype = atoi(row[261]); - entry.UNK220 = atoi(row[262]); - entry.UNK221 = atoi(row[263]); - entry.heirloom = atoi(row[264]); - entry.UNK223 = atoi(row[265]); - entry.UNK224 = atoi(row[266]); - entry.UNK225 = atoi(row[267]); - entry.UNK226 = atoi(row[268]); - entry.UNK227 = atoi(row[269]); - entry.UNK228 = atoi(row[270]); - entry.UNK229 = atoi(row[271]); - entry.UNK230 = atoi(row[272]); - entry.UNK231 = atoi(row[273]); - entry.UNK232 = atoi(row[274]); - entry.UNK233 = atoi(row[275]); - entry.UNK234 = atoi(row[276]); - entry.placeable = atoi(row[277]); - entry.UNK236 = atoi(row[278]); - entry.UNK237 = atoi(row[279]); - entry.UNK238 = atoi(row[280]); - entry.UNK239 = atoi(row[281]); - entry.UNK240 = atoi(row[282]); - entry.UNK241 = atoi(row[283]); - entry.epicitem = atoi(row[284]); + e.id = atoi(row[0]); + e.minstatus = atoi(row[1]); + e.Name = row[2] ? row[2] : ""; + e.aagi = atoi(row[3]); + e.ac = atoi(row[4]); + e.accuracy = atoi(row[5]); + e.acha = atoi(row[6]); + e.adex = atoi(row[7]); + e.aint = atoi(row[8]); + e.artifactflag = atoi(row[9]); + e.asta = atoi(row[10]); + e.astr = atoi(row[11]); + e.attack = atoi(row[12]); + e.augrestrict = atoi(row[13]); + e.augslot1type = atoi(row[14]); + e.augslot1visible = atoi(row[15]); + e.augslot2type = atoi(row[16]); + e.augslot2visible = atoi(row[17]); + e.augslot3type = atoi(row[18]); + e.augslot3visible = atoi(row[19]); + e.augslot4type = atoi(row[20]); + e.augslot4visible = atoi(row[21]); + e.augslot5type = atoi(row[22]); + e.augslot5visible = atoi(row[23]); + e.augslot6type = atoi(row[24]); + e.augslot6visible = atoi(row[25]); + e.augtype = atoi(row[26]); + e.avoidance = atoi(row[27]); + e.awis = atoi(row[28]); + e.bagsize = atoi(row[29]); + e.bagslots = atoi(row[30]); + e.bagtype = atoi(row[31]); + e.bagwr = atoi(row[32]); + e.banedmgamt = atoi(row[33]); + e.banedmgraceamt = atoi(row[34]); + e.banedmgbody = atoi(row[35]); + e.banedmgrace = atoi(row[36]); + e.bardtype = atoi(row[37]); + e.bardvalue = atoi(row[38]); + e.book = atoi(row[39]); + e.casttime = atoi(row[40]); + e.casttime_ = atoi(row[41]); + e.charmfile = row[42] ? row[42] : ""; + e.charmfileid = row[43] ? row[43] : ""; + e.classes = atoi(row[44]); + e.color = atoi(row[45]); + e.combateffects = row[46] ? row[46] : ""; + e.extradmgskill = atoi(row[47]); + e.extradmgamt = atoi(row[48]); + e.price = atoi(row[49]); + e.cr = atoi(row[50]); + e.damage = atoi(row[51]); + e.damageshield = atoi(row[52]); + e.deity = atoi(row[53]); + e.delay = atoi(row[54]); + e.augdistiller = atoi(row[55]); + e.dotshielding = atoi(row[56]); + e.dr = atoi(row[57]); + e.clicktype = atoi(row[58]); + e.clicklevel2 = atoi(row[59]); + e.elemdmgtype = atoi(row[60]); + e.elemdmgamt = atoi(row[61]); + e.endur = atoi(row[62]); + e.factionamt1 = atoi(row[63]); + e.factionamt2 = atoi(row[64]); + e.factionamt3 = atoi(row[65]); + e.factionamt4 = atoi(row[66]); + e.factionmod1 = atoi(row[67]); + e.factionmod2 = atoi(row[68]); + e.factionmod3 = atoi(row[69]); + e.factionmod4 = atoi(row[70]); + e.filename = row[71] ? row[71] : ""; + e.focuseffect = atoi(row[72]); + e.fr = atoi(row[73]); + e.fvnodrop = atoi(row[74]); + e.haste = atoi(row[75]); + e.clicklevel = atoi(row[76]); + e.hp = atoi(row[77]); + e.regen = atoi(row[78]); + e.icon = atoi(row[79]); + e.idfile = row[80] ? row[80] : ""; + e.itemclass = atoi(row[81]); + e.itemtype = atoi(row[82]); + e.ldonprice = atoi(row[83]); + e.ldontheme = atoi(row[84]); + e.ldonsold = atoi(row[85]); + e.light = atoi(row[86]); + e.lore = row[87] ? row[87] : ""; + e.loregroup = atoi(row[88]); + e.magic = atoi(row[89]); + e.mana = atoi(row[90]); + e.manaregen = atoi(row[91]); + e.enduranceregen = atoi(row[92]); + e.material = atoi(row[93]); + e.herosforgemodel = atoi(row[94]); + e.maxcharges = atoi(row[95]); + e.mr = atoi(row[96]); + e.nodrop = atoi(row[97]); + e.norent = atoi(row[98]); + e.pendingloreflag = atoi(row[99]); + e.pr = atoi(row[100]); + e.procrate = atoi(row[101]); + e.races = atoi(row[102]); + e.range = atoi(row[103]); + e.reclevel = atoi(row[104]); + e.recskill = atoi(row[105]); + e.reqlevel = atoi(row[106]); + e.sellrate = static_cast(atof(row[107])); + e.shielding = atoi(row[108]); + e.size = atoi(row[109]); + e.skillmodtype = atoi(row[110]); + e.skillmodvalue = atoi(row[111]); + e.slots = atoi(row[112]); + e.clickeffect = atoi(row[113]); + e.spellshield = atoi(row[114]); + e.strikethrough = atoi(row[115]); + e.stunresist = atoi(row[116]); + e.summonedflag = atoi(row[117]); + e.tradeskills = atoi(row[118]); + e.favor = atoi(row[119]); + e.weight = atoi(row[120]); + e.UNK012 = atoi(row[121]); + e.UNK013 = atoi(row[122]); + e.benefitflag = atoi(row[123]); + e.UNK054 = atoi(row[124]); + e.UNK059 = atoi(row[125]); + e.booktype = atoi(row[126]); + e.recastdelay = atoi(row[127]); + e.recasttype = atoi(row[128]); + e.guildfavor = atoi(row[129]); + e.UNK123 = atoi(row[130]); + e.UNK124 = atoi(row[131]); + e.attuneable = atoi(row[132]); + e.nopet = atoi(row[133]); + e.updated = strtoll(row[134] ? row[134] : "-1", nullptr, 10); + e.comment = row[135] ? row[135] : ""; + e.UNK127 = atoi(row[136]); + e.pointtype = atoi(row[137]); + e.potionbelt = atoi(row[138]); + e.potionbeltslots = atoi(row[139]); + e.stacksize = atoi(row[140]); + e.notransfer = atoi(row[141]); + e.stackable = atoi(row[142]); + e.UNK134 = row[143] ? row[143] : ""; + e.UNK137 = atoi(row[144]); + e.proceffect = atoi(row[145]); + e.proctype = atoi(row[146]); + e.proclevel2 = atoi(row[147]); + e.proclevel = atoi(row[148]); + e.UNK142 = atoi(row[149]); + e.worneffect = atoi(row[150]); + e.worntype = atoi(row[151]); + e.wornlevel2 = atoi(row[152]); + e.wornlevel = atoi(row[153]); + e.UNK147 = atoi(row[154]); + e.focustype = atoi(row[155]); + e.focuslevel2 = atoi(row[156]); + e.focuslevel = atoi(row[157]); + e.UNK152 = atoi(row[158]); + e.scrolleffect = atoi(row[159]); + e.scrolltype = atoi(row[160]); + e.scrolllevel2 = atoi(row[161]); + e.scrolllevel = atoi(row[162]); + e.UNK157 = atoi(row[163]); + e.serialized = strtoll(row[164] ? row[164] : "-1", nullptr, 10); + e.verified = strtoll(row[165] ? row[165] : "-1", nullptr, 10); + e.serialization = row[166] ? row[166] : ""; + e.source = row[167] ? row[167] : ""; + e.UNK033 = atoi(row[168]); + e.lorefile = row[169] ? row[169] : ""; + e.UNK014 = atoi(row[170]); + e.svcorruption = atoi(row[171]); + e.skillmodmax = atoi(row[172]); + e.UNK060 = atoi(row[173]); + e.augslot1unk2 = atoi(row[174]); + e.augslot2unk2 = atoi(row[175]); + e.augslot3unk2 = atoi(row[176]); + e.augslot4unk2 = atoi(row[177]); + e.augslot5unk2 = atoi(row[178]); + e.augslot6unk2 = atoi(row[179]); + e.UNK120 = atoi(row[180]); + e.UNK121 = atoi(row[181]); + e.questitemflag = atoi(row[182]); + e.UNK132 = row[183] ? row[183] : ""; + e.clickunk5 = atoi(row[184]); + e.clickunk6 = row[185] ? row[185] : ""; + e.clickunk7 = atoi(row[186]); + e.procunk1 = atoi(row[187]); + e.procunk2 = atoi(row[188]); + e.procunk3 = atoi(row[189]); + e.procunk4 = atoi(row[190]); + e.procunk6 = row[191] ? row[191] : ""; + e.procunk7 = atoi(row[192]); + e.wornunk1 = atoi(row[193]); + e.wornunk2 = atoi(row[194]); + e.wornunk3 = atoi(row[195]); + e.wornunk4 = atoi(row[196]); + e.wornunk5 = atoi(row[197]); + e.wornunk6 = row[198] ? row[198] : ""; + e.wornunk7 = atoi(row[199]); + e.focusunk1 = atoi(row[200]); + e.focusunk2 = atoi(row[201]); + e.focusunk3 = atoi(row[202]); + e.focusunk4 = atoi(row[203]); + e.focusunk5 = atoi(row[204]); + e.focusunk6 = row[205] ? row[205] : ""; + e.focusunk7 = atoi(row[206]); + e.scrollunk1 = atoi(row[207]); + e.scrollunk2 = atoi(row[208]); + e.scrollunk3 = atoi(row[209]); + e.scrollunk4 = atoi(row[210]); + e.scrollunk5 = atoi(row[211]); + e.scrollunk6 = row[212] ? row[212] : ""; + e.scrollunk7 = atoi(row[213]); + e.UNK193 = atoi(row[214]); + e.purity = atoi(row[215]); + e.evoitem = atoi(row[216]); + e.evoid = atoi(row[217]); + e.evolvinglevel = atoi(row[218]); + e.evomax = atoi(row[219]); + e.clickname = row[220] ? row[220] : ""; + e.procname = row[221] ? row[221] : ""; + e.wornname = row[222] ? row[222] : ""; + e.focusname = row[223] ? row[223] : ""; + e.scrollname = row[224] ? row[224] : ""; + e.dsmitigation = atoi(row[225]); + e.heroic_str = atoi(row[226]); + e.heroic_int = atoi(row[227]); + e.heroic_wis = atoi(row[228]); + e.heroic_agi = atoi(row[229]); + e.heroic_dex = atoi(row[230]); + e.heroic_sta = atoi(row[231]); + e.heroic_cha = atoi(row[232]); + e.heroic_pr = atoi(row[233]); + e.heroic_dr = atoi(row[234]); + e.heroic_fr = atoi(row[235]); + e.heroic_cr = atoi(row[236]); + e.heroic_mr = atoi(row[237]); + e.heroic_svcorrup = atoi(row[238]); + e.healamt = atoi(row[239]); + e.spelldmg = atoi(row[240]); + e.clairvoyance = atoi(row[241]); + e.backstabdmg = atoi(row[242]); + e.created = row[243] ? row[243] : ""; + e.elitematerial = atoi(row[244]); + e.ldonsellbackrate = atoi(row[245]); + e.scriptfileid = atoi(row[246]); + e.expendablearrow = atoi(row[247]); + e.powersourcecapacity = atoi(row[248]); + e.bardeffect = atoi(row[249]); + e.bardeffecttype = atoi(row[250]); + e.bardlevel2 = atoi(row[251]); + e.bardlevel = atoi(row[252]); + e.bardunk1 = atoi(row[253]); + e.bardunk2 = atoi(row[254]); + e.bardunk3 = atoi(row[255]); + e.bardunk4 = atoi(row[256]); + e.bardunk5 = atoi(row[257]); + e.bardname = row[258] ? row[258] : ""; + e.bardunk7 = atoi(row[259]); + e.UNK214 = atoi(row[260]); + e.subtype = atoi(row[261]); + e.UNK220 = atoi(row[262]); + e.UNK221 = atoi(row[263]); + e.heirloom = atoi(row[264]); + e.UNK223 = atoi(row[265]); + e.UNK224 = atoi(row[266]); + e.UNK225 = atoi(row[267]); + e.UNK226 = atoi(row[268]); + e.UNK227 = atoi(row[269]); + e.UNK228 = atoi(row[270]); + e.UNK229 = atoi(row[271]); + e.UNK230 = atoi(row[272]); + e.UNK231 = atoi(row[273]); + e.UNK232 = atoi(row[274]); + e.UNK233 = atoi(row[275]); + e.UNK234 = atoi(row[276]); + e.placeable = atoi(row[277]); + e.UNK236 = atoi(row[278]); + e.UNK237 = atoi(row[279]); + e.UNK238 = atoi(row[280]); + e.UNK239 = atoi(row[281]); + e.UNK240 = atoi(row[282]); + e.UNK241 = atoi(row[283]); + e.epicitem = atoi(row[284]); - all_entries.push_back(entry); + all_entries.push_back(e); } return all_entries; } - static int DeleteWhere(Database& db, std::string where_filter) + static int DeleteWhere(Database& db, const std::string &where_filter) { auto results = db.QueryDatabase( fmt::format( @@ -3132,6 +3132,32 @@ public: 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); + } + }; #endif //EQEMU_BASE_ITEMS_REPOSITORY_H diff --git a/common/repositories/base/base_launcher_repository.h b/common/repositories/base/base_launcher_repository.h index 11ee44c89..15317105e 100644 --- a/common/repositories/base/base_launcher_repository.h +++ b/common/repositories/base/base_launcher_repository.h @@ -1,24 +1,3 @@ -/** - * EQEmulator: Everquest Server Emulator - * Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server) - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 2 of the License. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY except by those people which sell it, which - * are required to give you total support for your newly bought product; - * without even the implied warranty of MERCHANTABILITY or FITNESS FOR - * A PARTICULAR PURPOSE. See the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - * - */ - /** * This repository was automatically generated and is NOT to be modified directly. * Any repository modifications are meant to be made to diff --git a/common/repositories/base/base_ldon_trap_entries_repository.h b/common/repositories/base/base_ldon_trap_entries_repository.h index 95dacb130..9388018e4 100644 --- a/common/repositories/base/base_ldon_trap_entries_repository.h +++ b/common/repositories/base/base_ldon_trap_entries_repository.h @@ -79,15 +79,15 @@ public: static LdonTrapEntries NewEntity() { - LdonTrapEntries entry{}; + LdonTrapEntries e{}; - entry.id = 0; - entry.trap_id = 0; + e.id = 0; + e.trap_id = 0; - return entry; + return e; } - static LdonTrapEntries GetLdonTrapEntriesEntry( + static LdonTrapEntries GetLdonTrapEntries( const std::vector &ldon_trap_entriess, int ldon_trap_entries_id ) @@ -116,12 +116,12 @@ public: auto row = results.begin(); if (results.RowCount() == 1) { - LdonTrapEntries entry{}; + LdonTrapEntries e{}; - entry.id = atoi(row[0]); - entry.trap_id = atoi(row[1]); + e.id = atoi(row[0]); + e.trap_id = atoi(row[1]); - return entry; + return e; } return NewEntity(); @@ -146,23 +146,23 @@ public: static int UpdateOne( Database& db, - LdonTrapEntries ldon_trap_entries_entry + const LdonTrapEntries &e ) { - std::vector update_values; + std::vector v; auto columns = Columns(); - update_values.push_back(columns[0] + " = " + std::to_string(ldon_trap_entries_entry.id)); - update_values.push_back(columns[1] + " = " + std::to_string(ldon_trap_entries_entry.trap_id)); + v.push_back(columns[0] + " = " + std::to_string(e.id)); + v.push_back(columns[1] + " = " + std::to_string(e.trap_id)); auto results = db.QueryDatabase( fmt::format( "UPDATE {} SET {} WHERE {} = {}", TableName(), - Strings::Implode(", ", update_values), + Strings::Implode(", ", v), PrimaryKey(), - ldon_trap_entries_entry.id + e.id ) ); @@ -171,49 +171,49 @@ public: static LdonTrapEntries InsertOne( Database& db, - LdonTrapEntries ldon_trap_entries_entry + LdonTrapEntries e ) { - std::vector insert_values; + std::vector v; - insert_values.push_back(std::to_string(ldon_trap_entries_entry.id)); - insert_values.push_back(std::to_string(ldon_trap_entries_entry.trap_id)); + v.push_back(std::to_string(e.id)); + v.push_back(std::to_string(e.trap_id)); auto results = db.QueryDatabase( fmt::format( "{} VALUES ({})", BaseInsert(), - Strings::Implode(",", insert_values) + Strings::Implode(",", v) ) ); if (results.Success()) { - ldon_trap_entries_entry.id = results.LastInsertedID(); - return ldon_trap_entries_entry; + e.id = results.LastInsertedID(); + return e; } - ldon_trap_entries_entry = NewEntity(); + e = NewEntity(); - return ldon_trap_entries_entry; + return e; } static int InsertMany( Database& db, - std::vector ldon_trap_entries_entries + const std::vector &entries ) { std::vector insert_chunks; - for (auto &ldon_trap_entries_entry: ldon_trap_entries_entries) { - std::vector insert_values; + for (auto &e: entries) { + std::vector v; - insert_values.push_back(std::to_string(ldon_trap_entries_entry.id)); - insert_values.push_back(std::to_string(ldon_trap_entries_entry.trap_id)); + v.push_back(std::to_string(e.id)); + v.push_back(std::to_string(e.trap_id)); - insert_chunks.push_back("(" + Strings::Implode(",", insert_values) + ")"); + insert_chunks.push_back("(" + Strings::Implode(",", v) + ")"); } - std::vector insert_values; + std::vector v; auto results = db.QueryDatabase( fmt::format( @@ -240,18 +240,18 @@ public: all_entries.reserve(results.RowCount()); for (auto row = results.begin(); row != results.end(); ++row) { - LdonTrapEntries entry{}; + LdonTrapEntries e{}; - entry.id = atoi(row[0]); - entry.trap_id = atoi(row[1]); + e.id = atoi(row[0]); + e.trap_id = atoi(row[1]); - all_entries.push_back(entry); + all_entries.push_back(e); } return all_entries; } - static std::vector GetWhere(Database& db, std::string where_filter) + static std::vector GetWhere(Database& db, const std::string &where_filter) { std::vector all_entries; @@ -266,18 +266,18 @@ public: all_entries.reserve(results.RowCount()); for (auto row = results.begin(); row != results.end(); ++row) { - LdonTrapEntries entry{}; + LdonTrapEntries e{}; - entry.id = atoi(row[0]); - entry.trap_id = atoi(row[1]); + e.id = atoi(row[0]); + e.trap_id = atoi(row[1]); - all_entries.push_back(entry); + all_entries.push_back(e); } return all_entries; } - static int DeleteWhere(Database& db, std::string where_filter) + static int DeleteWhere(Database& db, const std::string &where_filter) { auto results = db.QueryDatabase( fmt::format( @@ -302,6 +302,32 @@ public: 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); + } + }; #endif //EQEMU_BASE_LDON_TRAP_ENTRIES_REPOSITORY_H diff --git a/common/repositories/base/base_ldon_trap_templates_repository.h b/common/repositories/base/base_ldon_trap_templates_repository.h index ee7a865ca..f9f22c2ac 100644 --- a/common/repositories/base/base_ldon_trap_templates_repository.h +++ b/common/repositories/base/base_ldon_trap_templates_repository.h @@ -88,18 +88,18 @@ public: static LdonTrapTemplates NewEntity() { - LdonTrapTemplates entry{}; + LdonTrapTemplates e{}; - entry.id = 0; - entry.type = 1; - entry.spell_id = 0; - entry.skill = 0; - entry.locked = 0; + e.id = 0; + e.type = 1; + e.spell_id = 0; + e.skill = 0; + e.locked = 0; - return entry; + return e; } - static LdonTrapTemplates GetLdonTrapTemplatesEntry( + static LdonTrapTemplates GetLdonTrapTemplates( const std::vector &ldon_trap_templatess, int ldon_trap_templates_id ) @@ -128,15 +128,15 @@ public: auto row = results.begin(); if (results.RowCount() == 1) { - LdonTrapTemplates entry{}; + LdonTrapTemplates e{}; - entry.id = atoi(row[0]); - entry.type = atoi(row[1]); - entry.spell_id = atoi(row[2]); - entry.skill = atoi(row[3]); - entry.locked = atoi(row[4]); + e.id = atoi(row[0]); + e.type = atoi(row[1]); + e.spell_id = atoi(row[2]); + e.skill = atoi(row[3]); + e.locked = atoi(row[4]); - return entry; + return e; } return NewEntity(); @@ -161,26 +161,26 @@ public: static int UpdateOne( Database& db, - LdonTrapTemplates ldon_trap_templates_entry + const LdonTrapTemplates &e ) { - std::vector update_values; + std::vector v; auto columns = Columns(); - update_values.push_back(columns[0] + " = " + std::to_string(ldon_trap_templates_entry.id)); - update_values.push_back(columns[1] + " = " + std::to_string(ldon_trap_templates_entry.type)); - update_values.push_back(columns[2] + " = " + std::to_string(ldon_trap_templates_entry.spell_id)); - update_values.push_back(columns[3] + " = " + std::to_string(ldon_trap_templates_entry.skill)); - update_values.push_back(columns[4] + " = " + std::to_string(ldon_trap_templates_entry.locked)); + v.push_back(columns[0] + " = " + std::to_string(e.id)); + v.push_back(columns[1] + " = " + std::to_string(e.type)); + v.push_back(columns[2] + " = " + std::to_string(e.spell_id)); + v.push_back(columns[3] + " = " + std::to_string(e.skill)); + v.push_back(columns[4] + " = " + std::to_string(e.locked)); auto results = db.QueryDatabase( fmt::format( "UPDATE {} SET {} WHERE {} = {}", TableName(), - Strings::Implode(", ", update_values), + Strings::Implode(", ", v), PrimaryKey(), - ldon_trap_templates_entry.id + e.id ) ); @@ -189,55 +189,55 @@ public: static LdonTrapTemplates InsertOne( Database& db, - LdonTrapTemplates ldon_trap_templates_entry + LdonTrapTemplates e ) { - std::vector insert_values; + std::vector v; - insert_values.push_back(std::to_string(ldon_trap_templates_entry.id)); - insert_values.push_back(std::to_string(ldon_trap_templates_entry.type)); - insert_values.push_back(std::to_string(ldon_trap_templates_entry.spell_id)); - insert_values.push_back(std::to_string(ldon_trap_templates_entry.skill)); - insert_values.push_back(std::to_string(ldon_trap_templates_entry.locked)); + v.push_back(std::to_string(e.id)); + v.push_back(std::to_string(e.type)); + v.push_back(std::to_string(e.spell_id)); + v.push_back(std::to_string(e.skill)); + v.push_back(std::to_string(e.locked)); auto results = db.QueryDatabase( fmt::format( "{} VALUES ({})", BaseInsert(), - Strings::Implode(",", insert_values) + Strings::Implode(",", v) ) ); if (results.Success()) { - ldon_trap_templates_entry.id = results.LastInsertedID(); - return ldon_trap_templates_entry; + e.id = results.LastInsertedID(); + return e; } - ldon_trap_templates_entry = NewEntity(); + e = NewEntity(); - return ldon_trap_templates_entry; + return e; } static int InsertMany( Database& db, - std::vector ldon_trap_templates_entries + const std::vector &entries ) { std::vector insert_chunks; - for (auto &ldon_trap_templates_entry: ldon_trap_templates_entries) { - std::vector insert_values; + for (auto &e: entries) { + std::vector v; - insert_values.push_back(std::to_string(ldon_trap_templates_entry.id)); - insert_values.push_back(std::to_string(ldon_trap_templates_entry.type)); - insert_values.push_back(std::to_string(ldon_trap_templates_entry.spell_id)); - insert_values.push_back(std::to_string(ldon_trap_templates_entry.skill)); - insert_values.push_back(std::to_string(ldon_trap_templates_entry.locked)); + v.push_back(std::to_string(e.id)); + v.push_back(std::to_string(e.type)); + v.push_back(std::to_string(e.spell_id)); + v.push_back(std::to_string(e.skill)); + v.push_back(std::to_string(e.locked)); - insert_chunks.push_back("(" + Strings::Implode(",", insert_values) + ")"); + insert_chunks.push_back("(" + Strings::Implode(",", v) + ")"); } - std::vector insert_values; + std::vector v; auto results = db.QueryDatabase( fmt::format( @@ -264,21 +264,21 @@ public: all_entries.reserve(results.RowCount()); for (auto row = results.begin(); row != results.end(); ++row) { - LdonTrapTemplates entry{}; + LdonTrapTemplates e{}; - entry.id = atoi(row[0]); - entry.type = atoi(row[1]); - entry.spell_id = atoi(row[2]); - entry.skill = atoi(row[3]); - entry.locked = atoi(row[4]); + e.id = atoi(row[0]); + e.type = atoi(row[1]); + e.spell_id = atoi(row[2]); + e.skill = atoi(row[3]); + e.locked = atoi(row[4]); - all_entries.push_back(entry); + all_entries.push_back(e); } return all_entries; } - static std::vector GetWhere(Database& db, std::string where_filter) + static std::vector GetWhere(Database& db, const std::string &where_filter) { std::vector all_entries; @@ -293,21 +293,21 @@ public: all_entries.reserve(results.RowCount()); for (auto row = results.begin(); row != results.end(); ++row) { - LdonTrapTemplates entry{}; + LdonTrapTemplates e{}; - entry.id = atoi(row[0]); - entry.type = atoi(row[1]); - entry.spell_id = atoi(row[2]); - entry.skill = atoi(row[3]); - entry.locked = atoi(row[4]); + e.id = atoi(row[0]); + e.type = atoi(row[1]); + e.spell_id = atoi(row[2]); + e.skill = atoi(row[3]); + e.locked = atoi(row[4]); - all_entries.push_back(entry); + all_entries.push_back(e); } return all_entries; } - static int DeleteWhere(Database& db, std::string where_filter) + static int DeleteWhere(Database& db, const std::string &where_filter) { auto results = db.QueryDatabase( fmt::format( @@ -332,6 +332,32 @@ public: 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); + } + }; #endif //EQEMU_BASE_LDON_TRAP_TEMPLATES_REPOSITORY_H diff --git a/common/repositories/base/base_level_exp_mods_repository.h b/common/repositories/base/base_level_exp_mods_repository.h index c8f636616..541b4d16e 100644 --- a/common/repositories/base/base_level_exp_mods_repository.h +++ b/common/repositories/base/base_level_exp_mods_repository.h @@ -82,16 +82,16 @@ public: static LevelExpMods NewEntity() { - LevelExpMods entry{}; + LevelExpMods e{}; - entry.level = 0; - entry.exp_mod = 0; - entry.aa_exp_mod = 0; + e.level = 0; + e.exp_mod = 0; + e.aa_exp_mod = 0; - return entry; + return e; } - static LevelExpMods GetLevelExpModsEntry( + static LevelExpMods GetLevelExpMods( const std::vector &level_exp_modss, int level_exp_mods_id ) @@ -120,13 +120,13 @@ public: auto row = results.begin(); if (results.RowCount() == 1) { - LevelExpMods entry{}; + LevelExpMods e{}; - entry.level = atoi(row[0]); - entry.exp_mod = static_cast(atof(row[1])); - entry.aa_exp_mod = static_cast(atof(row[2])); + e.level = atoi(row[0]); + e.exp_mod = static_cast(atof(row[1])); + e.aa_exp_mod = static_cast(atof(row[2])); - return entry; + return e; } return NewEntity(); @@ -151,24 +151,24 @@ public: static int UpdateOne( Database& db, - LevelExpMods level_exp_mods_entry + const LevelExpMods &e ) { - std::vector update_values; + std::vector v; auto columns = Columns(); - update_values.push_back(columns[0] + " = " + std::to_string(level_exp_mods_entry.level)); - update_values.push_back(columns[1] + " = " + std::to_string(level_exp_mods_entry.exp_mod)); - update_values.push_back(columns[2] + " = " + std::to_string(level_exp_mods_entry.aa_exp_mod)); + v.push_back(columns[0] + " = " + std::to_string(e.level)); + v.push_back(columns[1] + " = " + std::to_string(e.exp_mod)); + v.push_back(columns[2] + " = " + std::to_string(e.aa_exp_mod)); auto results = db.QueryDatabase( fmt::format( "UPDATE {} SET {} WHERE {} = {}", TableName(), - Strings::Implode(", ", update_values), + Strings::Implode(", ", v), PrimaryKey(), - level_exp_mods_entry.level + e.level ) ); @@ -177,51 +177,51 @@ public: static LevelExpMods InsertOne( Database& db, - LevelExpMods level_exp_mods_entry + LevelExpMods e ) { - std::vector insert_values; + std::vector v; - insert_values.push_back(std::to_string(level_exp_mods_entry.level)); - insert_values.push_back(std::to_string(level_exp_mods_entry.exp_mod)); - insert_values.push_back(std::to_string(level_exp_mods_entry.aa_exp_mod)); + v.push_back(std::to_string(e.level)); + v.push_back(std::to_string(e.exp_mod)); + v.push_back(std::to_string(e.aa_exp_mod)); auto results = db.QueryDatabase( fmt::format( "{} VALUES ({})", BaseInsert(), - Strings::Implode(",", insert_values) + Strings::Implode(",", v) ) ); if (results.Success()) { - level_exp_mods_entry.level = results.LastInsertedID(); - return level_exp_mods_entry; + e.level = results.LastInsertedID(); + return e; } - level_exp_mods_entry = NewEntity(); + e = NewEntity(); - return level_exp_mods_entry; + return e; } static int InsertMany( Database& db, - std::vector level_exp_mods_entries + const std::vector &entries ) { std::vector insert_chunks; - for (auto &level_exp_mods_entry: level_exp_mods_entries) { - std::vector insert_values; + for (auto &e: entries) { + std::vector v; - insert_values.push_back(std::to_string(level_exp_mods_entry.level)); - insert_values.push_back(std::to_string(level_exp_mods_entry.exp_mod)); - insert_values.push_back(std::to_string(level_exp_mods_entry.aa_exp_mod)); + v.push_back(std::to_string(e.level)); + v.push_back(std::to_string(e.exp_mod)); + v.push_back(std::to_string(e.aa_exp_mod)); - insert_chunks.push_back("(" + Strings::Implode(",", insert_values) + ")"); + insert_chunks.push_back("(" + Strings::Implode(",", v) + ")"); } - std::vector insert_values; + std::vector v; auto results = db.QueryDatabase( fmt::format( @@ -248,19 +248,19 @@ public: all_entries.reserve(results.RowCount()); for (auto row = results.begin(); row != results.end(); ++row) { - LevelExpMods entry{}; + LevelExpMods e{}; - entry.level = atoi(row[0]); - entry.exp_mod = static_cast(atof(row[1])); - entry.aa_exp_mod = static_cast(atof(row[2])); + e.level = atoi(row[0]); + e.exp_mod = static_cast(atof(row[1])); + e.aa_exp_mod = static_cast(atof(row[2])); - all_entries.push_back(entry); + all_entries.push_back(e); } return all_entries; } - static std::vector GetWhere(Database& db, std::string where_filter) + static std::vector GetWhere(Database& db, const std::string &where_filter) { std::vector all_entries; @@ -275,19 +275,19 @@ public: all_entries.reserve(results.RowCount()); for (auto row = results.begin(); row != results.end(); ++row) { - LevelExpMods entry{}; + LevelExpMods e{}; - entry.level = atoi(row[0]); - entry.exp_mod = static_cast(atof(row[1])); - entry.aa_exp_mod = static_cast(atof(row[2])); + e.level = atoi(row[0]); + e.exp_mod = static_cast(atof(row[1])); + e.aa_exp_mod = static_cast(atof(row[2])); - all_entries.push_back(entry); + all_entries.push_back(e); } return all_entries; } - static int DeleteWhere(Database& db, std::string where_filter) + static int DeleteWhere(Database& db, const std::string &where_filter) { auto results = db.QueryDatabase( fmt::format( @@ -312,6 +312,32 @@ public: 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); + } + }; #endif //EQEMU_BASE_LEVEL_EXP_MODS_REPOSITORY_H diff --git a/common/repositories/base/base_lfguild_repository.h b/common/repositories/base/base_lfguild_repository.h index 75bc6665a..7382fab9a 100644 --- a/common/repositories/base/base_lfguild_repository.h +++ b/common/repositories/base/base_lfguild_repository.h @@ -100,22 +100,22 @@ public: static Lfguild NewEntity() { - Lfguild entry{}; + Lfguild e{}; - entry.type = 0; - entry.name = ""; - entry.comment = ""; - entry.fromlevel = 0; - entry.tolevel = 0; - entry.classes = 0; - entry.aacount = 0; - entry.timezone = 0; - entry.timeposted = 0; + e.type = 0; + e.name = ""; + e.comment = ""; + e.fromlevel = 0; + e.tolevel = 0; + e.classes = 0; + e.aacount = 0; + e.timezone = 0; + e.timeposted = 0; - return entry; + return e; } - static Lfguild GetLfguildEntry( + static Lfguild GetLfguild( const std::vector &lfguilds, int lfguild_id ) @@ -144,19 +144,19 @@ public: auto row = results.begin(); if (results.RowCount() == 1) { - Lfguild entry{}; + Lfguild e{}; - entry.type = atoi(row[0]); - entry.name = row[1] ? row[1] : ""; - entry.comment = row[2] ? row[2] : ""; - entry.fromlevel = atoi(row[3]); - entry.tolevel = atoi(row[4]); - entry.classes = atoi(row[5]); - entry.aacount = atoi(row[6]); - entry.timezone = atoi(row[7]); - entry.timeposted = atoi(row[8]); + e.type = atoi(row[0]); + e.name = row[1] ? row[1] : ""; + e.comment = row[2] ? row[2] : ""; + e.fromlevel = atoi(row[3]); + e.tolevel = atoi(row[4]); + e.classes = atoi(row[5]); + e.aacount = atoi(row[6]); + e.timezone = atoi(row[7]); + e.timeposted = atoi(row[8]); - return entry; + return e; } return NewEntity(); @@ -181,30 +181,30 @@ public: static int UpdateOne( Database& db, - Lfguild lfguild_entry + const Lfguild &e ) { - std::vector update_values; + std::vector v; auto columns = Columns(); - update_values.push_back(columns[0] + " = " + std::to_string(lfguild_entry.type)); - update_values.push_back(columns[1] + " = '" + Strings::Escape(lfguild_entry.name) + "'"); - update_values.push_back(columns[2] + " = '" + Strings::Escape(lfguild_entry.comment) + "'"); - update_values.push_back(columns[3] + " = " + std::to_string(lfguild_entry.fromlevel)); - update_values.push_back(columns[4] + " = " + std::to_string(lfguild_entry.tolevel)); - update_values.push_back(columns[5] + " = " + std::to_string(lfguild_entry.classes)); - update_values.push_back(columns[6] + " = " + std::to_string(lfguild_entry.aacount)); - update_values.push_back(columns[7] + " = " + std::to_string(lfguild_entry.timezone)); - update_values.push_back(columns[8] + " = " + std::to_string(lfguild_entry.timeposted)); + v.push_back(columns[0] + " = " + std::to_string(e.type)); + v.push_back(columns[1] + " = '" + Strings::Escape(e.name) + "'"); + v.push_back(columns[2] + " = '" + Strings::Escape(e.comment) + "'"); + v.push_back(columns[3] + " = " + std::to_string(e.fromlevel)); + v.push_back(columns[4] + " = " + std::to_string(e.tolevel)); + v.push_back(columns[5] + " = " + std::to_string(e.classes)); + v.push_back(columns[6] + " = " + std::to_string(e.aacount)); + v.push_back(columns[7] + " = " + std::to_string(e.timezone)); + v.push_back(columns[8] + " = " + std::to_string(e.timeposted)); auto results = db.QueryDatabase( fmt::format( "UPDATE {} SET {} WHERE {} = {}", TableName(), - Strings::Implode(", ", update_values), + Strings::Implode(", ", v), PrimaryKey(), - lfguild_entry.type + e.type ) ); @@ -213,63 +213,63 @@ public: static Lfguild InsertOne( Database& db, - Lfguild lfguild_entry + Lfguild e ) { - std::vector insert_values; + std::vector v; - insert_values.push_back(std::to_string(lfguild_entry.type)); - insert_values.push_back("'" + Strings::Escape(lfguild_entry.name) + "'"); - insert_values.push_back("'" + Strings::Escape(lfguild_entry.comment) + "'"); - insert_values.push_back(std::to_string(lfguild_entry.fromlevel)); - insert_values.push_back(std::to_string(lfguild_entry.tolevel)); - insert_values.push_back(std::to_string(lfguild_entry.classes)); - insert_values.push_back(std::to_string(lfguild_entry.aacount)); - insert_values.push_back(std::to_string(lfguild_entry.timezone)); - insert_values.push_back(std::to_string(lfguild_entry.timeposted)); + v.push_back(std::to_string(e.type)); + v.push_back("'" + Strings::Escape(e.name) + "'"); + v.push_back("'" + Strings::Escape(e.comment) + "'"); + v.push_back(std::to_string(e.fromlevel)); + v.push_back(std::to_string(e.tolevel)); + v.push_back(std::to_string(e.classes)); + v.push_back(std::to_string(e.aacount)); + v.push_back(std::to_string(e.timezone)); + v.push_back(std::to_string(e.timeposted)); auto results = db.QueryDatabase( fmt::format( "{} VALUES ({})", BaseInsert(), - Strings::Implode(",", insert_values) + Strings::Implode(",", v) ) ); if (results.Success()) { - lfguild_entry.type = results.LastInsertedID(); - return lfguild_entry; + e.type = results.LastInsertedID(); + return e; } - lfguild_entry = NewEntity(); + e = NewEntity(); - return lfguild_entry; + return e; } static int InsertMany( Database& db, - std::vector lfguild_entries + const std::vector &entries ) { std::vector insert_chunks; - for (auto &lfguild_entry: lfguild_entries) { - std::vector insert_values; + for (auto &e: entries) { + std::vector v; - insert_values.push_back(std::to_string(lfguild_entry.type)); - insert_values.push_back("'" + Strings::Escape(lfguild_entry.name) + "'"); - insert_values.push_back("'" + Strings::Escape(lfguild_entry.comment) + "'"); - insert_values.push_back(std::to_string(lfguild_entry.fromlevel)); - insert_values.push_back(std::to_string(lfguild_entry.tolevel)); - insert_values.push_back(std::to_string(lfguild_entry.classes)); - insert_values.push_back(std::to_string(lfguild_entry.aacount)); - insert_values.push_back(std::to_string(lfguild_entry.timezone)); - insert_values.push_back(std::to_string(lfguild_entry.timeposted)); + v.push_back(std::to_string(e.type)); + v.push_back("'" + Strings::Escape(e.name) + "'"); + v.push_back("'" + Strings::Escape(e.comment) + "'"); + v.push_back(std::to_string(e.fromlevel)); + v.push_back(std::to_string(e.tolevel)); + v.push_back(std::to_string(e.classes)); + v.push_back(std::to_string(e.aacount)); + v.push_back(std::to_string(e.timezone)); + v.push_back(std::to_string(e.timeposted)); - insert_chunks.push_back("(" + Strings::Implode(",", insert_values) + ")"); + insert_chunks.push_back("(" + Strings::Implode(",", v) + ")"); } - std::vector insert_values; + std::vector v; auto results = db.QueryDatabase( fmt::format( @@ -296,25 +296,25 @@ public: all_entries.reserve(results.RowCount()); for (auto row = results.begin(); row != results.end(); ++row) { - Lfguild entry{}; + Lfguild e{}; - entry.type = atoi(row[0]); - entry.name = row[1] ? row[1] : ""; - entry.comment = row[2] ? row[2] : ""; - entry.fromlevel = atoi(row[3]); - entry.tolevel = atoi(row[4]); - entry.classes = atoi(row[5]); - entry.aacount = atoi(row[6]); - entry.timezone = atoi(row[7]); - entry.timeposted = atoi(row[8]); + e.type = atoi(row[0]); + e.name = row[1] ? row[1] : ""; + e.comment = row[2] ? row[2] : ""; + e.fromlevel = atoi(row[3]); + e.tolevel = atoi(row[4]); + e.classes = atoi(row[5]); + e.aacount = atoi(row[6]); + e.timezone = atoi(row[7]); + e.timeposted = atoi(row[8]); - all_entries.push_back(entry); + all_entries.push_back(e); } return all_entries; } - static std::vector GetWhere(Database& db, std::string where_filter) + static std::vector GetWhere(Database& db, const std::string &where_filter) { std::vector all_entries; @@ -329,25 +329,25 @@ public: all_entries.reserve(results.RowCount()); for (auto row = results.begin(); row != results.end(); ++row) { - Lfguild entry{}; + Lfguild e{}; - entry.type = atoi(row[0]); - entry.name = row[1] ? row[1] : ""; - entry.comment = row[2] ? row[2] : ""; - entry.fromlevel = atoi(row[3]); - entry.tolevel = atoi(row[4]); - entry.classes = atoi(row[5]); - entry.aacount = atoi(row[6]); - entry.timezone = atoi(row[7]); - entry.timeposted = atoi(row[8]); + e.type = atoi(row[0]); + e.name = row[1] ? row[1] : ""; + e.comment = row[2] ? row[2] : ""; + e.fromlevel = atoi(row[3]); + e.tolevel = atoi(row[4]); + e.classes = atoi(row[5]); + e.aacount = atoi(row[6]); + e.timezone = atoi(row[7]); + e.timeposted = atoi(row[8]); - all_entries.push_back(entry); + all_entries.push_back(e); } return all_entries; } - static int DeleteWhere(Database& db, std::string where_filter) + static int DeleteWhere(Database& db, const std::string &where_filter) { auto results = db.QueryDatabase( fmt::format( @@ -372,6 +372,32 @@ public: 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); + } + }; #endif //EQEMU_BASE_LFGUILD_REPOSITORY_H diff --git a/common/repositories/base/base_login_accounts_repository.h b/common/repositories/base/base_login_accounts_repository.h index ba7330184..e353a5a66 100644 --- a/common/repositories/base/base_login_accounts_repository.h +++ b/common/repositories/base/base_login_accounts_repository.h @@ -100,22 +100,22 @@ public: static LoginAccounts NewEntity() { - LoginAccounts entry{}; + LoginAccounts e{}; - entry.id = 0; - entry.account_name = ""; - entry.account_password = ""; - entry.account_email = ""; - entry.source_loginserver = ""; - entry.last_ip_address = ""; - entry.last_login_date = 0; - entry.created_at = 0; - entry.updated_at = std::time(nullptr); + e.id = 0; + e.account_name = ""; + e.account_password = ""; + e.account_email = ""; + e.source_loginserver = ""; + e.last_ip_address = ""; + e.last_login_date = 0; + e.created_at = 0; + e.updated_at = std::time(nullptr); - return entry; + return e; } - static LoginAccounts GetLoginAccountsEntry( + static LoginAccounts GetLoginAccounts( const std::vector &login_accountss, int login_accounts_id ) @@ -144,19 +144,19 @@ public: auto row = results.begin(); if (results.RowCount() == 1) { - LoginAccounts entry{}; + LoginAccounts e{}; - entry.id = atoi(row[0]); - entry.account_name = row[1] ? row[1] : ""; - entry.account_password = row[2] ? row[2] : ""; - entry.account_email = row[3] ? row[3] : ""; - entry.source_loginserver = row[4] ? row[4] : ""; - entry.last_ip_address = row[5] ? row[5] : ""; - entry.last_login_date = strtoll(row[6] ? row[6] : "-1", nullptr, 10); - entry.created_at = strtoll(row[7] ? row[7] : "-1", nullptr, 10); - entry.updated_at = strtoll(row[8] ? row[8] : "-1", nullptr, 10); + e.id = atoi(row[0]); + e.account_name = row[1] ? row[1] : ""; + e.account_password = row[2] ? row[2] : ""; + e.account_email = row[3] ? row[3] : ""; + e.source_loginserver = row[4] ? row[4] : ""; + e.last_ip_address = row[5] ? row[5] : ""; + e.last_login_date = strtoll(row[6] ? row[6] : "-1", nullptr, 10); + e.created_at = strtoll(row[7] ? row[7] : "-1", nullptr, 10); + e.updated_at = strtoll(row[8] ? row[8] : "-1", nullptr, 10); - return entry; + return e; } return NewEntity(); @@ -181,30 +181,30 @@ public: static int UpdateOne( Database& db, - LoginAccounts login_accounts_entry + const LoginAccounts &e ) { - std::vector update_values; + std::vector v; auto columns = Columns(); - update_values.push_back(columns[0] + " = " + std::to_string(login_accounts_entry.id)); - update_values.push_back(columns[1] + " = '" + Strings::Escape(login_accounts_entry.account_name) + "'"); - update_values.push_back(columns[2] + " = '" + Strings::Escape(login_accounts_entry.account_password) + "'"); - update_values.push_back(columns[3] + " = '" + Strings::Escape(login_accounts_entry.account_email) + "'"); - update_values.push_back(columns[4] + " = '" + Strings::Escape(login_accounts_entry.source_loginserver) + "'"); - update_values.push_back(columns[5] + " = '" + Strings::Escape(login_accounts_entry.last_ip_address) + "'"); - update_values.push_back(columns[6] + " = FROM_UNIXTIME(" + (login_accounts_entry.last_login_date > 0 ? std::to_string(login_accounts_entry.last_login_date) : "null") + ")"); - update_values.push_back(columns[7] + " = FROM_UNIXTIME(" + (login_accounts_entry.created_at > 0 ? std::to_string(login_accounts_entry.created_at) : "null") + ")"); - update_values.push_back(columns[8] + " = FROM_UNIXTIME(" + (login_accounts_entry.updated_at > 0 ? std::to_string(login_accounts_entry.updated_at) : "null") + ")"); + v.push_back(columns[0] + " = " + std::to_string(e.id)); + v.push_back(columns[1] + " = '" + Strings::Escape(e.account_name) + "'"); + v.push_back(columns[2] + " = '" + Strings::Escape(e.account_password) + "'"); + v.push_back(columns[3] + " = '" + Strings::Escape(e.account_email) + "'"); + v.push_back(columns[4] + " = '" + Strings::Escape(e.source_loginserver) + "'"); + v.push_back(columns[5] + " = '" + Strings::Escape(e.last_ip_address) + "'"); + v.push_back(columns[6] + " = FROM_UNIXTIME(" + (e.last_login_date > 0 ? std::to_string(e.last_login_date) : "null") + ")"); + v.push_back(columns[7] + " = FROM_UNIXTIME(" + (e.created_at > 0 ? std::to_string(e.created_at) : "null") + ")"); + v.push_back(columns[8] + " = FROM_UNIXTIME(" + (e.updated_at > 0 ? std::to_string(e.updated_at) : "null") + ")"); auto results = db.QueryDatabase( fmt::format( "UPDATE {} SET {} WHERE {} = {}", TableName(), - Strings::Implode(", ", update_values), + Strings::Implode(", ", v), PrimaryKey(), - login_accounts_entry.id + e.id ) ); @@ -213,63 +213,63 @@ public: static LoginAccounts InsertOne( Database& db, - LoginAccounts login_accounts_entry + LoginAccounts e ) { - std::vector insert_values; + std::vector v; - insert_values.push_back(std::to_string(login_accounts_entry.id)); - insert_values.push_back("'" + Strings::Escape(login_accounts_entry.account_name) + "'"); - insert_values.push_back("'" + Strings::Escape(login_accounts_entry.account_password) + "'"); - insert_values.push_back("'" + Strings::Escape(login_accounts_entry.account_email) + "'"); - insert_values.push_back("'" + Strings::Escape(login_accounts_entry.source_loginserver) + "'"); - insert_values.push_back("'" + Strings::Escape(login_accounts_entry.last_ip_address) + "'"); - insert_values.push_back("FROM_UNIXTIME(" + (login_accounts_entry.last_login_date > 0 ? std::to_string(login_accounts_entry.last_login_date) : "null") + ")"); - insert_values.push_back("FROM_UNIXTIME(" + (login_accounts_entry.created_at > 0 ? std::to_string(login_accounts_entry.created_at) : "null") + ")"); - insert_values.push_back("FROM_UNIXTIME(" + (login_accounts_entry.updated_at > 0 ? std::to_string(login_accounts_entry.updated_at) : "null") + ")"); + v.push_back(std::to_string(e.id)); + v.push_back("'" + Strings::Escape(e.account_name) + "'"); + v.push_back("'" + Strings::Escape(e.account_password) + "'"); + v.push_back("'" + Strings::Escape(e.account_email) + "'"); + v.push_back("'" + Strings::Escape(e.source_loginserver) + "'"); + v.push_back("'" + Strings::Escape(e.last_ip_address) + "'"); + v.push_back("FROM_UNIXTIME(" + (e.last_login_date > 0 ? std::to_string(e.last_login_date) : "null") + ")"); + v.push_back("FROM_UNIXTIME(" + (e.created_at > 0 ? std::to_string(e.created_at) : "null") + ")"); + v.push_back("FROM_UNIXTIME(" + (e.updated_at > 0 ? std::to_string(e.updated_at) : "null") + ")"); auto results = db.QueryDatabase( fmt::format( "{} VALUES ({})", BaseInsert(), - Strings::Implode(",", insert_values) + Strings::Implode(",", v) ) ); if (results.Success()) { - login_accounts_entry.id = results.LastInsertedID(); - return login_accounts_entry; + e.id = results.LastInsertedID(); + return e; } - login_accounts_entry = NewEntity(); + e = NewEntity(); - return login_accounts_entry; + return e; } static int InsertMany( Database& db, - std::vector login_accounts_entries + const std::vector &entries ) { std::vector insert_chunks; - for (auto &login_accounts_entry: login_accounts_entries) { - std::vector insert_values; + for (auto &e: entries) { + std::vector v; - insert_values.push_back(std::to_string(login_accounts_entry.id)); - insert_values.push_back("'" + Strings::Escape(login_accounts_entry.account_name) + "'"); - insert_values.push_back("'" + Strings::Escape(login_accounts_entry.account_password) + "'"); - insert_values.push_back("'" + Strings::Escape(login_accounts_entry.account_email) + "'"); - insert_values.push_back("'" + Strings::Escape(login_accounts_entry.source_loginserver) + "'"); - insert_values.push_back("'" + Strings::Escape(login_accounts_entry.last_ip_address) + "'"); - insert_values.push_back("FROM_UNIXTIME(" + (login_accounts_entry.last_login_date > 0 ? std::to_string(login_accounts_entry.last_login_date) : "null") + ")"); - insert_values.push_back("FROM_UNIXTIME(" + (login_accounts_entry.created_at > 0 ? std::to_string(login_accounts_entry.created_at) : "null") + ")"); - insert_values.push_back("FROM_UNIXTIME(" + (login_accounts_entry.updated_at > 0 ? std::to_string(login_accounts_entry.updated_at) : "null") + ")"); + v.push_back(std::to_string(e.id)); + v.push_back("'" + Strings::Escape(e.account_name) + "'"); + v.push_back("'" + Strings::Escape(e.account_password) + "'"); + v.push_back("'" + Strings::Escape(e.account_email) + "'"); + v.push_back("'" + Strings::Escape(e.source_loginserver) + "'"); + v.push_back("'" + Strings::Escape(e.last_ip_address) + "'"); + v.push_back("FROM_UNIXTIME(" + (e.last_login_date > 0 ? std::to_string(e.last_login_date) : "null") + ")"); + v.push_back("FROM_UNIXTIME(" + (e.created_at > 0 ? std::to_string(e.created_at) : "null") + ")"); + v.push_back("FROM_UNIXTIME(" + (e.updated_at > 0 ? std::to_string(e.updated_at) : "null") + ")"); - insert_chunks.push_back("(" + Strings::Implode(",", insert_values) + ")"); + insert_chunks.push_back("(" + Strings::Implode(",", v) + ")"); } - std::vector insert_values; + std::vector v; auto results = db.QueryDatabase( fmt::format( @@ -296,25 +296,25 @@ public: all_entries.reserve(results.RowCount()); for (auto row = results.begin(); row != results.end(); ++row) { - LoginAccounts entry{}; + LoginAccounts e{}; - entry.id = atoi(row[0]); - entry.account_name = row[1] ? row[1] : ""; - entry.account_password = row[2] ? row[2] : ""; - entry.account_email = row[3] ? row[3] : ""; - entry.source_loginserver = row[4] ? row[4] : ""; - entry.last_ip_address = row[5] ? row[5] : ""; - entry.last_login_date = strtoll(row[6] ? row[6] : "-1", nullptr, 10); - entry.created_at = strtoll(row[7] ? row[7] : "-1", nullptr, 10); - entry.updated_at = strtoll(row[8] ? row[8] : "-1", nullptr, 10); + e.id = atoi(row[0]); + e.account_name = row[1] ? row[1] : ""; + e.account_password = row[2] ? row[2] : ""; + e.account_email = row[3] ? row[3] : ""; + e.source_loginserver = row[4] ? row[4] : ""; + e.last_ip_address = row[5] ? row[5] : ""; + e.last_login_date = strtoll(row[6] ? row[6] : "-1", nullptr, 10); + e.created_at = strtoll(row[7] ? row[7] : "-1", nullptr, 10); + e.updated_at = strtoll(row[8] ? row[8] : "-1", nullptr, 10); - all_entries.push_back(entry); + all_entries.push_back(e); } return all_entries; } - static std::vector GetWhere(Database& db, std::string where_filter) + static std::vector GetWhere(Database& db, const std::string &where_filter) { std::vector all_entries; @@ -329,25 +329,25 @@ public: all_entries.reserve(results.RowCount()); for (auto row = results.begin(); row != results.end(); ++row) { - LoginAccounts entry{}; + LoginAccounts e{}; - entry.id = atoi(row[0]); - entry.account_name = row[1] ? row[1] : ""; - entry.account_password = row[2] ? row[2] : ""; - entry.account_email = row[3] ? row[3] : ""; - entry.source_loginserver = row[4] ? row[4] : ""; - entry.last_ip_address = row[5] ? row[5] : ""; - entry.last_login_date = strtoll(row[6] ? row[6] : "-1", nullptr, 10); - entry.created_at = strtoll(row[7] ? row[7] : "-1", nullptr, 10); - entry.updated_at = strtoll(row[8] ? row[8] : "-1", nullptr, 10); + e.id = atoi(row[0]); + e.account_name = row[1] ? row[1] : ""; + e.account_password = row[2] ? row[2] : ""; + e.account_email = row[3] ? row[3] : ""; + e.source_loginserver = row[4] ? row[4] : ""; + e.last_ip_address = row[5] ? row[5] : ""; + e.last_login_date = strtoll(row[6] ? row[6] : "-1", nullptr, 10); + e.created_at = strtoll(row[7] ? row[7] : "-1", nullptr, 10); + e.updated_at = strtoll(row[8] ? row[8] : "-1", nullptr, 10); - all_entries.push_back(entry); + all_entries.push_back(e); } return all_entries; } - static int DeleteWhere(Database& db, std::string where_filter) + static int DeleteWhere(Database& db, const std::string &where_filter) { auto results = db.QueryDatabase( fmt::format( @@ -372,6 +372,32 @@ public: 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); + } + }; #endif //EQEMU_BASE_LOGIN_ACCOUNTS_REPOSITORY_H diff --git a/common/repositories/base/base_login_api_tokens_repository.h b/common/repositories/base/base_login_api_tokens_repository.h index d212f618e..a56f17fc8 100644 --- a/common/repositories/base/base_login_api_tokens_repository.h +++ b/common/repositories/base/base_login_api_tokens_repository.h @@ -91,19 +91,19 @@ public: static LoginApiTokens NewEntity() { - LoginApiTokens entry{}; + LoginApiTokens e{}; - entry.id = 0; - entry.token = ""; - entry.can_write = 0; - entry.can_read = 0; - entry.created_at = 0; - entry.updated_at = std::time(nullptr); + e.id = 0; + e.token = ""; + e.can_write = 0; + e.can_read = 0; + e.created_at = 0; + e.updated_at = std::time(nullptr); - return entry; + return e; } - static LoginApiTokens GetLoginApiTokensEntry( + static LoginApiTokens GetLoginApiTokens( const std::vector &login_api_tokenss, int login_api_tokens_id ) @@ -132,16 +132,16 @@ public: auto row = results.begin(); if (results.RowCount() == 1) { - LoginApiTokens entry{}; + LoginApiTokens e{}; - entry.id = atoi(row[0]); - entry.token = row[1] ? row[1] : ""; - entry.can_write = atoi(row[2]); - entry.can_read = atoi(row[3]); - entry.created_at = strtoll(row[4] ? row[4] : "-1", nullptr, 10); - entry.updated_at = strtoll(row[5] ? row[5] : "-1", nullptr, 10); + e.id = atoi(row[0]); + e.token = row[1] ? row[1] : ""; + e.can_write = atoi(row[2]); + e.can_read = atoi(row[3]); + e.created_at = strtoll(row[4] ? row[4] : "-1", nullptr, 10); + e.updated_at = strtoll(row[5] ? row[5] : "-1", nullptr, 10); - return entry; + return e; } return NewEntity(); @@ -166,26 +166,26 @@ public: static int UpdateOne( Database& db, - LoginApiTokens login_api_tokens_entry + const LoginApiTokens &e ) { - std::vector update_values; + std::vector v; auto columns = Columns(); - update_values.push_back(columns[1] + " = '" + Strings::Escape(login_api_tokens_entry.token) + "'"); - update_values.push_back(columns[2] + " = " + std::to_string(login_api_tokens_entry.can_write)); - update_values.push_back(columns[3] + " = " + std::to_string(login_api_tokens_entry.can_read)); - update_values.push_back(columns[4] + " = FROM_UNIXTIME(" + (login_api_tokens_entry.created_at > 0 ? std::to_string(login_api_tokens_entry.created_at) : "null") + ")"); - update_values.push_back(columns[5] + " = FROM_UNIXTIME(" + (login_api_tokens_entry.updated_at > 0 ? std::to_string(login_api_tokens_entry.updated_at) : "null") + ")"); + v.push_back(columns[1] + " = '" + Strings::Escape(e.token) + "'"); + v.push_back(columns[2] + " = " + std::to_string(e.can_write)); + v.push_back(columns[3] + " = " + std::to_string(e.can_read)); + v.push_back(columns[4] + " = FROM_UNIXTIME(" + (e.created_at > 0 ? std::to_string(e.created_at) : "null") + ")"); + v.push_back(columns[5] + " = FROM_UNIXTIME(" + (e.updated_at > 0 ? std::to_string(e.updated_at) : "null") + ")"); auto results = db.QueryDatabase( fmt::format( "UPDATE {} SET {} WHERE {} = {}", TableName(), - Strings::Implode(", ", update_values), + Strings::Implode(", ", v), PrimaryKey(), - login_api_tokens_entry.id + e.id ) ); @@ -194,57 +194,57 @@ public: static LoginApiTokens InsertOne( Database& db, - LoginApiTokens login_api_tokens_entry + LoginApiTokens e ) { - std::vector insert_values; + std::vector v; - insert_values.push_back(std::to_string(login_api_tokens_entry.id)); - insert_values.push_back("'" + Strings::Escape(login_api_tokens_entry.token) + "'"); - insert_values.push_back(std::to_string(login_api_tokens_entry.can_write)); - insert_values.push_back(std::to_string(login_api_tokens_entry.can_read)); - insert_values.push_back("FROM_UNIXTIME(" + (login_api_tokens_entry.created_at > 0 ? std::to_string(login_api_tokens_entry.created_at) : "null") + ")"); - insert_values.push_back("FROM_UNIXTIME(" + (login_api_tokens_entry.updated_at > 0 ? std::to_string(login_api_tokens_entry.updated_at) : "null") + ")"); + v.push_back(std::to_string(e.id)); + v.push_back("'" + Strings::Escape(e.token) + "'"); + v.push_back(std::to_string(e.can_write)); + v.push_back(std::to_string(e.can_read)); + v.push_back("FROM_UNIXTIME(" + (e.created_at > 0 ? std::to_string(e.created_at) : "null") + ")"); + v.push_back("FROM_UNIXTIME(" + (e.updated_at > 0 ? std::to_string(e.updated_at) : "null") + ")"); auto results = db.QueryDatabase( fmt::format( "{} VALUES ({})", BaseInsert(), - Strings::Implode(",", insert_values) + Strings::Implode(",", v) ) ); if (results.Success()) { - login_api_tokens_entry.id = results.LastInsertedID(); - return login_api_tokens_entry; + e.id = results.LastInsertedID(); + return e; } - login_api_tokens_entry = NewEntity(); + e = NewEntity(); - return login_api_tokens_entry; + return e; } static int InsertMany( Database& db, - std::vector login_api_tokens_entries + const std::vector &entries ) { std::vector insert_chunks; - for (auto &login_api_tokens_entry: login_api_tokens_entries) { - std::vector insert_values; + for (auto &e: entries) { + std::vector v; - insert_values.push_back(std::to_string(login_api_tokens_entry.id)); - insert_values.push_back("'" + Strings::Escape(login_api_tokens_entry.token) + "'"); - insert_values.push_back(std::to_string(login_api_tokens_entry.can_write)); - insert_values.push_back(std::to_string(login_api_tokens_entry.can_read)); - insert_values.push_back("FROM_UNIXTIME(" + (login_api_tokens_entry.created_at > 0 ? std::to_string(login_api_tokens_entry.created_at) : "null") + ")"); - insert_values.push_back("FROM_UNIXTIME(" + (login_api_tokens_entry.updated_at > 0 ? std::to_string(login_api_tokens_entry.updated_at) : "null") + ")"); + v.push_back(std::to_string(e.id)); + v.push_back("'" + Strings::Escape(e.token) + "'"); + v.push_back(std::to_string(e.can_write)); + v.push_back(std::to_string(e.can_read)); + v.push_back("FROM_UNIXTIME(" + (e.created_at > 0 ? std::to_string(e.created_at) : "null") + ")"); + v.push_back("FROM_UNIXTIME(" + (e.updated_at > 0 ? std::to_string(e.updated_at) : "null") + ")"); - insert_chunks.push_back("(" + Strings::Implode(",", insert_values) + ")"); + insert_chunks.push_back("(" + Strings::Implode(",", v) + ")"); } - std::vector insert_values; + std::vector v; auto results = db.QueryDatabase( fmt::format( @@ -271,22 +271,22 @@ public: all_entries.reserve(results.RowCount()); for (auto row = results.begin(); row != results.end(); ++row) { - LoginApiTokens entry{}; + LoginApiTokens e{}; - entry.id = atoi(row[0]); - entry.token = row[1] ? row[1] : ""; - entry.can_write = atoi(row[2]); - entry.can_read = atoi(row[3]); - entry.created_at = strtoll(row[4] ? row[4] : "-1", nullptr, 10); - entry.updated_at = strtoll(row[5] ? row[5] : "-1", nullptr, 10); + e.id = atoi(row[0]); + e.token = row[1] ? row[1] : ""; + e.can_write = atoi(row[2]); + e.can_read = atoi(row[3]); + e.created_at = strtoll(row[4] ? row[4] : "-1", nullptr, 10); + e.updated_at = strtoll(row[5] ? row[5] : "-1", nullptr, 10); - all_entries.push_back(entry); + all_entries.push_back(e); } return all_entries; } - static std::vector GetWhere(Database& db, std::string where_filter) + static std::vector GetWhere(Database& db, const std::string &where_filter) { std::vector all_entries; @@ -301,22 +301,22 @@ public: all_entries.reserve(results.RowCount()); for (auto row = results.begin(); row != results.end(); ++row) { - LoginApiTokens entry{}; + LoginApiTokens e{}; - entry.id = atoi(row[0]); - entry.token = row[1] ? row[1] : ""; - entry.can_write = atoi(row[2]); - entry.can_read = atoi(row[3]); - entry.created_at = strtoll(row[4] ? row[4] : "-1", nullptr, 10); - entry.updated_at = strtoll(row[5] ? row[5] : "-1", nullptr, 10); + e.id = atoi(row[0]); + e.token = row[1] ? row[1] : ""; + e.can_write = atoi(row[2]); + e.can_read = atoi(row[3]); + e.created_at = strtoll(row[4] ? row[4] : "-1", nullptr, 10); + e.updated_at = strtoll(row[5] ? row[5] : "-1", nullptr, 10); - all_entries.push_back(entry); + all_entries.push_back(e); } return all_entries; } - static int DeleteWhere(Database& db, std::string where_filter) + static int DeleteWhere(Database& db, const std::string &where_filter) { auto results = db.QueryDatabase( fmt::format( @@ -341,6 +341,32 @@ public: 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); + } + }; #endif //EQEMU_BASE_LOGIN_API_TOKENS_REPOSITORY_H diff --git a/common/repositories/base/base_login_server_admins_repository.h b/common/repositories/base/base_login_server_admins_repository.h index 5e8f1e1f3..45fce3397 100644 --- a/common/repositories/base/base_login_server_admins_repository.h +++ b/common/repositories/base/base_login_server_admins_repository.h @@ -97,21 +97,21 @@ public: static LoginServerAdmins NewEntity() { - LoginServerAdmins entry{}; + LoginServerAdmins e{}; - entry.id = 0; - entry.account_name = ""; - entry.account_password = ""; - entry.first_name = ""; - entry.last_name = ""; - entry.email = ""; - entry.registration_date = 0; - entry.registration_ip_address = ""; + e.id = 0; + e.account_name = ""; + e.account_password = ""; + e.first_name = ""; + e.last_name = ""; + e.email = ""; + e.registration_date = 0; + e.registration_ip_address = ""; - return entry; + return e; } - static LoginServerAdmins GetLoginServerAdminsEntry( + static LoginServerAdmins GetLoginServerAdmins( const std::vector &login_server_adminss, int login_server_admins_id ) @@ -140,18 +140,18 @@ public: auto row = results.begin(); if (results.RowCount() == 1) { - LoginServerAdmins entry{}; + LoginServerAdmins e{}; - entry.id = atoi(row[0]); - entry.account_name = row[1] ? row[1] : ""; - entry.account_password = row[2] ? row[2] : ""; - entry.first_name = row[3] ? row[3] : ""; - entry.last_name = row[4] ? row[4] : ""; - entry.email = row[5] ? row[5] : ""; - entry.registration_date = strtoll(row[6] ? row[6] : "-1", nullptr, 10); - entry.registration_ip_address = row[7] ? row[7] : ""; + e.id = atoi(row[0]); + e.account_name = row[1] ? row[1] : ""; + e.account_password = row[2] ? row[2] : ""; + e.first_name = row[3] ? row[3] : ""; + e.last_name = row[4] ? row[4] : ""; + e.email = row[5] ? row[5] : ""; + e.registration_date = strtoll(row[6] ? row[6] : "-1", nullptr, 10); + e.registration_ip_address = row[7] ? row[7] : ""; - return entry; + return e; } return NewEntity(); @@ -176,28 +176,28 @@ public: static int UpdateOne( Database& db, - LoginServerAdmins login_server_admins_entry + const LoginServerAdmins &e ) { - std::vector update_values; + std::vector v; auto columns = Columns(); - update_values.push_back(columns[1] + " = '" + Strings::Escape(login_server_admins_entry.account_name) + "'"); - update_values.push_back(columns[2] + " = '" + Strings::Escape(login_server_admins_entry.account_password) + "'"); - update_values.push_back(columns[3] + " = '" + Strings::Escape(login_server_admins_entry.first_name) + "'"); - update_values.push_back(columns[4] + " = '" + Strings::Escape(login_server_admins_entry.last_name) + "'"); - update_values.push_back(columns[5] + " = '" + Strings::Escape(login_server_admins_entry.email) + "'"); - update_values.push_back(columns[6] + " = FROM_UNIXTIME(" + (login_server_admins_entry.registration_date > 0 ? std::to_string(login_server_admins_entry.registration_date) : "null") + ")"); - update_values.push_back(columns[7] + " = '" + Strings::Escape(login_server_admins_entry.registration_ip_address) + "'"); + v.push_back(columns[1] + " = '" + Strings::Escape(e.account_name) + "'"); + v.push_back(columns[2] + " = '" + Strings::Escape(e.account_password) + "'"); + v.push_back(columns[3] + " = '" + Strings::Escape(e.first_name) + "'"); + v.push_back(columns[4] + " = '" + Strings::Escape(e.last_name) + "'"); + v.push_back(columns[5] + " = '" + Strings::Escape(e.email) + "'"); + v.push_back(columns[6] + " = FROM_UNIXTIME(" + (e.registration_date > 0 ? std::to_string(e.registration_date) : "null") + ")"); + v.push_back(columns[7] + " = '" + Strings::Escape(e.registration_ip_address) + "'"); auto results = db.QueryDatabase( fmt::format( "UPDATE {} SET {} WHERE {} = {}", TableName(), - Strings::Implode(", ", update_values), + Strings::Implode(", ", v), PrimaryKey(), - login_server_admins_entry.id + e.id ) ); @@ -206,61 +206,61 @@ public: static LoginServerAdmins InsertOne( Database& db, - LoginServerAdmins login_server_admins_entry + LoginServerAdmins e ) { - std::vector insert_values; + std::vector v; - insert_values.push_back(std::to_string(login_server_admins_entry.id)); - insert_values.push_back("'" + Strings::Escape(login_server_admins_entry.account_name) + "'"); - insert_values.push_back("'" + Strings::Escape(login_server_admins_entry.account_password) + "'"); - insert_values.push_back("'" + Strings::Escape(login_server_admins_entry.first_name) + "'"); - insert_values.push_back("'" + Strings::Escape(login_server_admins_entry.last_name) + "'"); - insert_values.push_back("'" + Strings::Escape(login_server_admins_entry.email) + "'"); - insert_values.push_back("FROM_UNIXTIME(" + (login_server_admins_entry.registration_date > 0 ? std::to_string(login_server_admins_entry.registration_date) : "null") + ")"); - insert_values.push_back("'" + Strings::Escape(login_server_admins_entry.registration_ip_address) + "'"); + v.push_back(std::to_string(e.id)); + v.push_back("'" + Strings::Escape(e.account_name) + "'"); + v.push_back("'" + Strings::Escape(e.account_password) + "'"); + v.push_back("'" + Strings::Escape(e.first_name) + "'"); + v.push_back("'" + Strings::Escape(e.last_name) + "'"); + v.push_back("'" + Strings::Escape(e.email) + "'"); + v.push_back("FROM_UNIXTIME(" + (e.registration_date > 0 ? std::to_string(e.registration_date) : "null") + ")"); + v.push_back("'" + Strings::Escape(e.registration_ip_address) + "'"); auto results = db.QueryDatabase( fmt::format( "{} VALUES ({})", BaseInsert(), - Strings::Implode(",", insert_values) + Strings::Implode(",", v) ) ); if (results.Success()) { - login_server_admins_entry.id = results.LastInsertedID(); - return login_server_admins_entry; + e.id = results.LastInsertedID(); + return e; } - login_server_admins_entry = NewEntity(); + e = NewEntity(); - return login_server_admins_entry; + return e; } static int InsertMany( Database& db, - std::vector login_server_admins_entries + const std::vector &entries ) { std::vector insert_chunks; - for (auto &login_server_admins_entry: login_server_admins_entries) { - std::vector insert_values; + for (auto &e: entries) { + std::vector v; - insert_values.push_back(std::to_string(login_server_admins_entry.id)); - insert_values.push_back("'" + Strings::Escape(login_server_admins_entry.account_name) + "'"); - insert_values.push_back("'" + Strings::Escape(login_server_admins_entry.account_password) + "'"); - insert_values.push_back("'" + Strings::Escape(login_server_admins_entry.first_name) + "'"); - insert_values.push_back("'" + Strings::Escape(login_server_admins_entry.last_name) + "'"); - insert_values.push_back("'" + Strings::Escape(login_server_admins_entry.email) + "'"); - insert_values.push_back("FROM_UNIXTIME(" + (login_server_admins_entry.registration_date > 0 ? std::to_string(login_server_admins_entry.registration_date) : "null") + ")"); - insert_values.push_back("'" + Strings::Escape(login_server_admins_entry.registration_ip_address) + "'"); + v.push_back(std::to_string(e.id)); + v.push_back("'" + Strings::Escape(e.account_name) + "'"); + v.push_back("'" + Strings::Escape(e.account_password) + "'"); + v.push_back("'" + Strings::Escape(e.first_name) + "'"); + v.push_back("'" + Strings::Escape(e.last_name) + "'"); + v.push_back("'" + Strings::Escape(e.email) + "'"); + v.push_back("FROM_UNIXTIME(" + (e.registration_date > 0 ? std::to_string(e.registration_date) : "null") + ")"); + v.push_back("'" + Strings::Escape(e.registration_ip_address) + "'"); - insert_chunks.push_back("(" + Strings::Implode(",", insert_values) + ")"); + insert_chunks.push_back("(" + Strings::Implode(",", v) + ")"); } - std::vector insert_values; + std::vector v; auto results = db.QueryDatabase( fmt::format( @@ -287,24 +287,24 @@ public: all_entries.reserve(results.RowCount()); for (auto row = results.begin(); row != results.end(); ++row) { - LoginServerAdmins entry{}; + LoginServerAdmins e{}; - entry.id = atoi(row[0]); - entry.account_name = row[1] ? row[1] : ""; - entry.account_password = row[2] ? row[2] : ""; - entry.first_name = row[3] ? row[3] : ""; - entry.last_name = row[4] ? row[4] : ""; - entry.email = row[5] ? row[5] : ""; - entry.registration_date = strtoll(row[6] ? row[6] : "-1", nullptr, 10); - entry.registration_ip_address = row[7] ? row[7] : ""; + e.id = atoi(row[0]); + e.account_name = row[1] ? row[1] : ""; + e.account_password = row[2] ? row[2] : ""; + e.first_name = row[3] ? row[3] : ""; + e.last_name = row[4] ? row[4] : ""; + e.email = row[5] ? row[5] : ""; + e.registration_date = strtoll(row[6] ? row[6] : "-1", nullptr, 10); + e.registration_ip_address = row[7] ? row[7] : ""; - all_entries.push_back(entry); + all_entries.push_back(e); } return all_entries; } - static std::vector GetWhere(Database& db, std::string where_filter) + static std::vector GetWhere(Database& db, const std::string &where_filter) { std::vector all_entries; @@ -319,24 +319,24 @@ public: all_entries.reserve(results.RowCount()); for (auto row = results.begin(); row != results.end(); ++row) { - LoginServerAdmins entry{}; + LoginServerAdmins e{}; - entry.id = atoi(row[0]); - entry.account_name = row[1] ? row[1] : ""; - entry.account_password = row[2] ? row[2] : ""; - entry.first_name = row[3] ? row[3] : ""; - entry.last_name = row[4] ? row[4] : ""; - entry.email = row[5] ? row[5] : ""; - entry.registration_date = strtoll(row[6] ? row[6] : "-1", nullptr, 10); - entry.registration_ip_address = row[7] ? row[7] : ""; + e.id = atoi(row[0]); + e.account_name = row[1] ? row[1] : ""; + e.account_password = row[2] ? row[2] : ""; + e.first_name = row[3] ? row[3] : ""; + e.last_name = row[4] ? row[4] : ""; + e.email = row[5] ? row[5] : ""; + e.registration_date = strtoll(row[6] ? row[6] : "-1", nullptr, 10); + e.registration_ip_address = row[7] ? row[7] : ""; - all_entries.push_back(entry); + all_entries.push_back(e); } return all_entries; } - static int DeleteWhere(Database& db, std::string where_filter) + static int DeleteWhere(Database& db, const std::string &where_filter) { auto results = db.QueryDatabase( fmt::format( @@ -361,6 +361,32 @@ public: 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); + } + }; #endif //EQEMU_BASE_LOGIN_SERVER_ADMINS_REPOSITORY_H diff --git a/common/repositories/base/base_login_server_list_types_repository.h b/common/repositories/base/base_login_server_list_types_repository.h index ad14b7dcf..b03d85588 100644 --- a/common/repositories/base/base_login_server_list_types_repository.h +++ b/common/repositories/base/base_login_server_list_types_repository.h @@ -79,15 +79,15 @@ public: static LoginServerListTypes NewEntity() { - LoginServerListTypes entry{}; + LoginServerListTypes e{}; - entry.id = 0; - entry.description = ""; + e.id = 0; + e.description = ""; - return entry; + return e; } - static LoginServerListTypes GetLoginServerListTypesEntry( + static LoginServerListTypes GetLoginServerListTypes( const std::vector &login_server_list_typess, int login_server_list_types_id ) @@ -116,12 +116,12 @@ public: auto row = results.begin(); if (results.RowCount() == 1) { - LoginServerListTypes entry{}; + LoginServerListTypes e{}; - entry.id = atoi(row[0]); - entry.description = row[1] ? row[1] : ""; + e.id = atoi(row[0]); + e.description = row[1] ? row[1] : ""; - return entry; + return e; } return NewEntity(); @@ -146,23 +146,23 @@ public: static int UpdateOne( Database& db, - LoginServerListTypes login_server_list_types_entry + const LoginServerListTypes &e ) { - std::vector update_values; + std::vector v; auto columns = Columns(); - update_values.push_back(columns[0] + " = " + std::to_string(login_server_list_types_entry.id)); - update_values.push_back(columns[1] + " = '" + Strings::Escape(login_server_list_types_entry.description) + "'"); + v.push_back(columns[0] + " = " + std::to_string(e.id)); + v.push_back(columns[1] + " = '" + Strings::Escape(e.description) + "'"); auto results = db.QueryDatabase( fmt::format( "UPDATE {} SET {} WHERE {} = {}", TableName(), - Strings::Implode(", ", update_values), + Strings::Implode(", ", v), PrimaryKey(), - login_server_list_types_entry.id + e.id ) ); @@ -171,49 +171,49 @@ public: static LoginServerListTypes InsertOne( Database& db, - LoginServerListTypes login_server_list_types_entry + LoginServerListTypes e ) { - std::vector insert_values; + std::vector v; - insert_values.push_back(std::to_string(login_server_list_types_entry.id)); - insert_values.push_back("'" + Strings::Escape(login_server_list_types_entry.description) + "'"); + v.push_back(std::to_string(e.id)); + v.push_back("'" + Strings::Escape(e.description) + "'"); auto results = db.QueryDatabase( fmt::format( "{} VALUES ({})", BaseInsert(), - Strings::Implode(",", insert_values) + Strings::Implode(",", v) ) ); if (results.Success()) { - login_server_list_types_entry.id = results.LastInsertedID(); - return login_server_list_types_entry; + e.id = results.LastInsertedID(); + return e; } - login_server_list_types_entry = NewEntity(); + e = NewEntity(); - return login_server_list_types_entry; + return e; } static int InsertMany( Database& db, - std::vector login_server_list_types_entries + const std::vector &entries ) { std::vector insert_chunks; - for (auto &login_server_list_types_entry: login_server_list_types_entries) { - std::vector insert_values; + for (auto &e: entries) { + std::vector v; - insert_values.push_back(std::to_string(login_server_list_types_entry.id)); - insert_values.push_back("'" + Strings::Escape(login_server_list_types_entry.description) + "'"); + v.push_back(std::to_string(e.id)); + v.push_back("'" + Strings::Escape(e.description) + "'"); - insert_chunks.push_back("(" + Strings::Implode(",", insert_values) + ")"); + insert_chunks.push_back("(" + Strings::Implode(",", v) + ")"); } - std::vector insert_values; + std::vector v; auto results = db.QueryDatabase( fmt::format( @@ -240,18 +240,18 @@ public: all_entries.reserve(results.RowCount()); for (auto row = results.begin(); row != results.end(); ++row) { - LoginServerListTypes entry{}; + LoginServerListTypes e{}; - entry.id = atoi(row[0]); - entry.description = row[1] ? row[1] : ""; + e.id = atoi(row[0]); + e.description = row[1] ? row[1] : ""; - all_entries.push_back(entry); + all_entries.push_back(e); } return all_entries; } - static std::vector GetWhere(Database& db, std::string where_filter) + static std::vector GetWhere(Database& db, const std::string &where_filter) { std::vector all_entries; @@ -266,18 +266,18 @@ public: all_entries.reserve(results.RowCount()); for (auto row = results.begin(); row != results.end(); ++row) { - LoginServerListTypes entry{}; + LoginServerListTypes e{}; - entry.id = atoi(row[0]); - entry.description = row[1] ? row[1] : ""; + e.id = atoi(row[0]); + e.description = row[1] ? row[1] : ""; - all_entries.push_back(entry); + all_entries.push_back(e); } return all_entries; } - static int DeleteWhere(Database& db, std::string where_filter) + static int DeleteWhere(Database& db, const std::string &where_filter) { auto results = db.QueryDatabase( fmt::format( @@ -302,6 +302,32 @@ public: 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); + } + }; #endif //EQEMU_BASE_LOGIN_SERVER_LIST_TYPES_REPOSITORY_H diff --git a/common/repositories/base/base_login_world_servers_repository.h b/common/repositories/base/base_login_world_servers_repository.h index 7b74888d3..3ffb9fa6d 100644 --- a/common/repositories/base/base_login_world_servers_repository.h +++ b/common/repositories/base/base_login_world_servers_repository.h @@ -103,23 +103,23 @@ public: static LoginWorldServers NewEntity() { - LoginWorldServers entry{}; + LoginWorldServers e{}; - entry.id = 0; - entry.long_name = ""; - entry.short_name = ""; - entry.tag_description = ""; - entry.login_server_list_type_id = 0; - entry.last_login_date = 0; - entry.last_ip_address = ""; - entry.login_server_admin_id = 0; - entry.is_server_trusted = 0; - entry.note = ""; + e.id = 0; + e.long_name = ""; + e.short_name = ""; + e.tag_description = ""; + e.login_server_list_type_id = 0; + e.last_login_date = 0; + e.last_ip_address = ""; + e.login_server_admin_id = 0; + e.is_server_trusted = 0; + e.note = ""; - return entry; + return e; } - static LoginWorldServers GetLoginWorldServersEntry( + static LoginWorldServers GetLoginWorldServers( const std::vector &login_world_serverss, int login_world_servers_id ) @@ -148,20 +148,20 @@ public: auto row = results.begin(); if (results.RowCount() == 1) { - LoginWorldServers entry{}; + LoginWorldServers e{}; - entry.id = atoi(row[0]); - entry.long_name = row[1] ? row[1] : ""; - entry.short_name = row[2] ? row[2] : ""; - entry.tag_description = row[3] ? row[3] : ""; - entry.login_server_list_type_id = atoi(row[4]); - entry.last_login_date = strtoll(row[5] ? row[5] : "-1", nullptr, 10); - entry.last_ip_address = row[6] ? row[6] : ""; - entry.login_server_admin_id = atoi(row[7]); - entry.is_server_trusted = atoi(row[8]); - entry.note = row[9] ? row[9] : ""; + e.id = atoi(row[0]); + e.long_name = row[1] ? row[1] : ""; + e.short_name = row[2] ? row[2] : ""; + e.tag_description = row[3] ? row[3] : ""; + e.login_server_list_type_id = atoi(row[4]); + e.last_login_date = strtoll(row[5] ? row[5] : "-1", nullptr, 10); + e.last_ip_address = row[6] ? row[6] : ""; + e.login_server_admin_id = atoi(row[7]); + e.is_server_trusted = atoi(row[8]); + e.note = row[9] ? row[9] : ""; - return entry; + return e; } return NewEntity(); @@ -186,30 +186,30 @@ public: static int UpdateOne( Database& db, - LoginWorldServers login_world_servers_entry + const LoginWorldServers &e ) { - std::vector update_values; + std::vector v; auto columns = Columns(); - update_values.push_back(columns[1] + " = '" + Strings::Escape(login_world_servers_entry.long_name) + "'"); - update_values.push_back(columns[2] + " = '" + Strings::Escape(login_world_servers_entry.short_name) + "'"); - update_values.push_back(columns[3] + " = '" + Strings::Escape(login_world_servers_entry.tag_description) + "'"); - update_values.push_back(columns[4] + " = " + std::to_string(login_world_servers_entry.login_server_list_type_id)); - update_values.push_back(columns[5] + " = FROM_UNIXTIME(" + (login_world_servers_entry.last_login_date > 0 ? std::to_string(login_world_servers_entry.last_login_date) : "null") + ")"); - update_values.push_back(columns[6] + " = '" + Strings::Escape(login_world_servers_entry.last_ip_address) + "'"); - update_values.push_back(columns[7] + " = " + std::to_string(login_world_servers_entry.login_server_admin_id)); - update_values.push_back(columns[8] + " = " + std::to_string(login_world_servers_entry.is_server_trusted)); - update_values.push_back(columns[9] + " = '" + Strings::Escape(login_world_servers_entry.note) + "'"); + v.push_back(columns[1] + " = '" + Strings::Escape(e.long_name) + "'"); + v.push_back(columns[2] + " = '" + Strings::Escape(e.short_name) + "'"); + v.push_back(columns[3] + " = '" + Strings::Escape(e.tag_description) + "'"); + v.push_back(columns[4] + " = " + std::to_string(e.login_server_list_type_id)); + v.push_back(columns[5] + " = FROM_UNIXTIME(" + (e.last_login_date > 0 ? std::to_string(e.last_login_date) : "null") + ")"); + v.push_back(columns[6] + " = '" + Strings::Escape(e.last_ip_address) + "'"); + v.push_back(columns[7] + " = " + std::to_string(e.login_server_admin_id)); + v.push_back(columns[8] + " = " + std::to_string(e.is_server_trusted)); + v.push_back(columns[9] + " = '" + Strings::Escape(e.note) + "'"); auto results = db.QueryDatabase( fmt::format( "UPDATE {} SET {} WHERE {} = {}", TableName(), - Strings::Implode(", ", update_values), + Strings::Implode(", ", v), PrimaryKey(), - login_world_servers_entry.id + e.id ) ); @@ -218,65 +218,65 @@ public: static LoginWorldServers InsertOne( Database& db, - LoginWorldServers login_world_servers_entry + LoginWorldServers e ) { - std::vector insert_values; + std::vector v; - insert_values.push_back(std::to_string(login_world_servers_entry.id)); - insert_values.push_back("'" + Strings::Escape(login_world_servers_entry.long_name) + "'"); - insert_values.push_back("'" + Strings::Escape(login_world_servers_entry.short_name) + "'"); - insert_values.push_back("'" + Strings::Escape(login_world_servers_entry.tag_description) + "'"); - insert_values.push_back(std::to_string(login_world_servers_entry.login_server_list_type_id)); - insert_values.push_back("FROM_UNIXTIME(" + (login_world_servers_entry.last_login_date > 0 ? std::to_string(login_world_servers_entry.last_login_date) : "null") + ")"); - insert_values.push_back("'" + Strings::Escape(login_world_servers_entry.last_ip_address) + "'"); - insert_values.push_back(std::to_string(login_world_servers_entry.login_server_admin_id)); - insert_values.push_back(std::to_string(login_world_servers_entry.is_server_trusted)); - insert_values.push_back("'" + Strings::Escape(login_world_servers_entry.note) + "'"); + v.push_back(std::to_string(e.id)); + v.push_back("'" + Strings::Escape(e.long_name) + "'"); + v.push_back("'" + Strings::Escape(e.short_name) + "'"); + v.push_back("'" + Strings::Escape(e.tag_description) + "'"); + v.push_back(std::to_string(e.login_server_list_type_id)); + v.push_back("FROM_UNIXTIME(" + (e.last_login_date > 0 ? std::to_string(e.last_login_date) : "null") + ")"); + v.push_back("'" + Strings::Escape(e.last_ip_address) + "'"); + v.push_back(std::to_string(e.login_server_admin_id)); + v.push_back(std::to_string(e.is_server_trusted)); + v.push_back("'" + Strings::Escape(e.note) + "'"); auto results = db.QueryDatabase( fmt::format( "{} VALUES ({})", BaseInsert(), - Strings::Implode(",", insert_values) + Strings::Implode(",", v) ) ); if (results.Success()) { - login_world_servers_entry.id = results.LastInsertedID(); - return login_world_servers_entry; + e.id = results.LastInsertedID(); + return e; } - login_world_servers_entry = NewEntity(); + e = NewEntity(); - return login_world_servers_entry; + return e; } static int InsertMany( Database& db, - std::vector login_world_servers_entries + const std::vector &entries ) { std::vector insert_chunks; - for (auto &login_world_servers_entry: login_world_servers_entries) { - std::vector insert_values; + for (auto &e: entries) { + std::vector v; - insert_values.push_back(std::to_string(login_world_servers_entry.id)); - insert_values.push_back("'" + Strings::Escape(login_world_servers_entry.long_name) + "'"); - insert_values.push_back("'" + Strings::Escape(login_world_servers_entry.short_name) + "'"); - insert_values.push_back("'" + Strings::Escape(login_world_servers_entry.tag_description) + "'"); - insert_values.push_back(std::to_string(login_world_servers_entry.login_server_list_type_id)); - insert_values.push_back("FROM_UNIXTIME(" + (login_world_servers_entry.last_login_date > 0 ? std::to_string(login_world_servers_entry.last_login_date) : "null") + ")"); - insert_values.push_back("'" + Strings::Escape(login_world_servers_entry.last_ip_address) + "'"); - insert_values.push_back(std::to_string(login_world_servers_entry.login_server_admin_id)); - insert_values.push_back(std::to_string(login_world_servers_entry.is_server_trusted)); - insert_values.push_back("'" + Strings::Escape(login_world_servers_entry.note) + "'"); + v.push_back(std::to_string(e.id)); + v.push_back("'" + Strings::Escape(e.long_name) + "'"); + v.push_back("'" + Strings::Escape(e.short_name) + "'"); + v.push_back("'" + Strings::Escape(e.tag_description) + "'"); + v.push_back(std::to_string(e.login_server_list_type_id)); + v.push_back("FROM_UNIXTIME(" + (e.last_login_date > 0 ? std::to_string(e.last_login_date) : "null") + ")"); + v.push_back("'" + Strings::Escape(e.last_ip_address) + "'"); + v.push_back(std::to_string(e.login_server_admin_id)); + v.push_back(std::to_string(e.is_server_trusted)); + v.push_back("'" + Strings::Escape(e.note) + "'"); - insert_chunks.push_back("(" + Strings::Implode(",", insert_values) + ")"); + insert_chunks.push_back("(" + Strings::Implode(",", v) + ")"); } - std::vector insert_values; + std::vector v; auto results = db.QueryDatabase( fmt::format( @@ -303,26 +303,26 @@ public: all_entries.reserve(results.RowCount()); for (auto row = results.begin(); row != results.end(); ++row) { - LoginWorldServers entry{}; + LoginWorldServers e{}; - entry.id = atoi(row[0]); - entry.long_name = row[1] ? row[1] : ""; - entry.short_name = row[2] ? row[2] : ""; - entry.tag_description = row[3] ? row[3] : ""; - entry.login_server_list_type_id = atoi(row[4]); - entry.last_login_date = strtoll(row[5] ? row[5] : "-1", nullptr, 10); - entry.last_ip_address = row[6] ? row[6] : ""; - entry.login_server_admin_id = atoi(row[7]); - entry.is_server_trusted = atoi(row[8]); - entry.note = row[9] ? row[9] : ""; + e.id = atoi(row[0]); + e.long_name = row[1] ? row[1] : ""; + e.short_name = row[2] ? row[2] : ""; + e.tag_description = row[3] ? row[3] : ""; + e.login_server_list_type_id = atoi(row[4]); + e.last_login_date = strtoll(row[5] ? row[5] : "-1", nullptr, 10); + e.last_ip_address = row[6] ? row[6] : ""; + e.login_server_admin_id = atoi(row[7]); + e.is_server_trusted = atoi(row[8]); + e.note = row[9] ? row[9] : ""; - all_entries.push_back(entry); + all_entries.push_back(e); } return all_entries; } - static std::vector GetWhere(Database& db, std::string where_filter) + static std::vector GetWhere(Database& db, const std::string &where_filter) { std::vector all_entries; @@ -337,26 +337,26 @@ public: all_entries.reserve(results.RowCount()); for (auto row = results.begin(); row != results.end(); ++row) { - LoginWorldServers entry{}; + LoginWorldServers e{}; - entry.id = atoi(row[0]); - entry.long_name = row[1] ? row[1] : ""; - entry.short_name = row[2] ? row[2] : ""; - entry.tag_description = row[3] ? row[3] : ""; - entry.login_server_list_type_id = atoi(row[4]); - entry.last_login_date = strtoll(row[5] ? row[5] : "-1", nullptr, 10); - entry.last_ip_address = row[6] ? row[6] : ""; - entry.login_server_admin_id = atoi(row[7]); - entry.is_server_trusted = atoi(row[8]); - entry.note = row[9] ? row[9] : ""; + e.id = atoi(row[0]); + e.long_name = row[1] ? row[1] : ""; + e.short_name = row[2] ? row[2] : ""; + e.tag_description = row[3] ? row[3] : ""; + e.login_server_list_type_id = atoi(row[4]); + e.last_login_date = strtoll(row[5] ? row[5] : "-1", nullptr, 10); + e.last_ip_address = row[6] ? row[6] : ""; + e.login_server_admin_id = atoi(row[7]); + e.is_server_trusted = atoi(row[8]); + e.note = row[9] ? row[9] : ""; - all_entries.push_back(entry); + all_entries.push_back(e); } return all_entries; } - static int DeleteWhere(Database& db, std::string where_filter) + static int DeleteWhere(Database& db, const std::string &where_filter) { auto results = db.QueryDatabase( fmt::format( @@ -381,6 +381,32 @@ public: 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); + } + }; #endif //EQEMU_BASE_LOGIN_WORLD_SERVERS_REPOSITORY_H diff --git a/common/repositories/base/base_logsys_categories_repository.h b/common/repositories/base/base_logsys_categories_repository.h index f953ab490..e03374b48 100644 --- a/common/repositories/base/base_logsys_categories_repository.h +++ b/common/repositories/base/base_logsys_categories_repository.h @@ -94,20 +94,20 @@ public: static LogsysCategories NewEntity() { - LogsysCategories entry{}; + LogsysCategories e{}; - entry.log_category_id = 0; - entry.log_category_description = ""; - entry.log_to_console = 0; - entry.log_to_file = 0; - entry.log_to_gmsay = 0; - entry.log_to_discord = 0; - entry.discord_webhook_id = 0; + e.log_category_id = 0; + e.log_category_description = ""; + e.log_to_console = 0; + e.log_to_file = 0; + e.log_to_gmsay = 0; + e.log_to_discord = 0; + e.discord_webhook_id = 0; - return entry; + return e; } - static LogsysCategories GetLogsysCategoriesEntry( + static LogsysCategories GetLogsysCategories( const std::vector &logsys_categoriess, int logsys_categories_id ) @@ -136,17 +136,17 @@ public: auto row = results.begin(); if (results.RowCount() == 1) { - LogsysCategories entry{}; + LogsysCategories e{}; - entry.log_category_id = atoi(row[0]); - entry.log_category_description = row[1] ? row[1] : ""; - entry.log_to_console = atoi(row[2]); - entry.log_to_file = atoi(row[3]); - entry.log_to_gmsay = atoi(row[4]); - entry.log_to_discord = atoi(row[5]); - entry.discord_webhook_id = atoi(row[6]); + e.log_category_id = atoi(row[0]); + e.log_category_description = row[1] ? row[1] : ""; + e.log_to_console = atoi(row[2]); + e.log_to_file = atoi(row[3]); + e.log_to_gmsay = atoi(row[4]); + e.log_to_discord = atoi(row[5]); + e.discord_webhook_id = atoi(row[6]); - return entry; + return e; } return NewEntity(); @@ -171,28 +171,28 @@ public: static int UpdateOne( Database& db, - LogsysCategories logsys_categories_entry + const LogsysCategories &e ) { - std::vector update_values; + std::vector v; auto columns = Columns(); - update_values.push_back(columns[0] + " = " + std::to_string(logsys_categories_entry.log_category_id)); - update_values.push_back(columns[1] + " = '" + Strings::Escape(logsys_categories_entry.log_category_description) + "'"); - update_values.push_back(columns[2] + " = " + std::to_string(logsys_categories_entry.log_to_console)); - update_values.push_back(columns[3] + " = " + std::to_string(logsys_categories_entry.log_to_file)); - update_values.push_back(columns[4] + " = " + std::to_string(logsys_categories_entry.log_to_gmsay)); - update_values.push_back(columns[5] + " = " + std::to_string(logsys_categories_entry.log_to_discord)); - update_values.push_back(columns[6] + " = " + std::to_string(logsys_categories_entry.discord_webhook_id)); + v.push_back(columns[0] + " = " + std::to_string(e.log_category_id)); + v.push_back(columns[1] + " = '" + Strings::Escape(e.log_category_description) + "'"); + v.push_back(columns[2] + " = " + std::to_string(e.log_to_console)); + v.push_back(columns[3] + " = " + std::to_string(e.log_to_file)); + v.push_back(columns[4] + " = " + std::to_string(e.log_to_gmsay)); + v.push_back(columns[5] + " = " + std::to_string(e.log_to_discord)); + v.push_back(columns[6] + " = " + std::to_string(e.discord_webhook_id)); auto results = db.QueryDatabase( fmt::format( "UPDATE {} SET {} WHERE {} = {}", TableName(), - Strings::Implode(", ", update_values), + Strings::Implode(", ", v), PrimaryKey(), - logsys_categories_entry.log_category_id + e.log_category_id ) ); @@ -201,59 +201,59 @@ public: static LogsysCategories InsertOne( Database& db, - LogsysCategories logsys_categories_entry + LogsysCategories e ) { - std::vector insert_values; + std::vector v; - insert_values.push_back(std::to_string(logsys_categories_entry.log_category_id)); - insert_values.push_back("'" + Strings::Escape(logsys_categories_entry.log_category_description) + "'"); - insert_values.push_back(std::to_string(logsys_categories_entry.log_to_console)); - insert_values.push_back(std::to_string(logsys_categories_entry.log_to_file)); - insert_values.push_back(std::to_string(logsys_categories_entry.log_to_gmsay)); - insert_values.push_back(std::to_string(logsys_categories_entry.log_to_discord)); - insert_values.push_back(std::to_string(logsys_categories_entry.discord_webhook_id)); + v.push_back(std::to_string(e.log_category_id)); + v.push_back("'" + Strings::Escape(e.log_category_description) + "'"); + v.push_back(std::to_string(e.log_to_console)); + v.push_back(std::to_string(e.log_to_file)); + v.push_back(std::to_string(e.log_to_gmsay)); + v.push_back(std::to_string(e.log_to_discord)); + v.push_back(std::to_string(e.discord_webhook_id)); auto results = db.QueryDatabase( fmt::format( "{} VALUES ({})", BaseInsert(), - Strings::Implode(",", insert_values) + Strings::Implode(",", v) ) ); if (results.Success()) { - logsys_categories_entry.log_category_id = results.LastInsertedID(); - return logsys_categories_entry; + e.log_category_id = results.LastInsertedID(); + return e; } - logsys_categories_entry = NewEntity(); + e = NewEntity(); - return logsys_categories_entry; + return e; } static int InsertMany( Database& db, - std::vector logsys_categories_entries + const std::vector &entries ) { std::vector insert_chunks; - for (auto &logsys_categories_entry: logsys_categories_entries) { - std::vector insert_values; + for (auto &e: entries) { + std::vector v; - insert_values.push_back(std::to_string(logsys_categories_entry.log_category_id)); - insert_values.push_back("'" + Strings::Escape(logsys_categories_entry.log_category_description) + "'"); - insert_values.push_back(std::to_string(logsys_categories_entry.log_to_console)); - insert_values.push_back(std::to_string(logsys_categories_entry.log_to_file)); - insert_values.push_back(std::to_string(logsys_categories_entry.log_to_gmsay)); - insert_values.push_back(std::to_string(logsys_categories_entry.log_to_discord)); - insert_values.push_back(std::to_string(logsys_categories_entry.discord_webhook_id)); + v.push_back(std::to_string(e.log_category_id)); + v.push_back("'" + Strings::Escape(e.log_category_description) + "'"); + v.push_back(std::to_string(e.log_to_console)); + v.push_back(std::to_string(e.log_to_file)); + v.push_back(std::to_string(e.log_to_gmsay)); + v.push_back(std::to_string(e.log_to_discord)); + v.push_back(std::to_string(e.discord_webhook_id)); - insert_chunks.push_back("(" + Strings::Implode(",", insert_values) + ")"); + insert_chunks.push_back("(" + Strings::Implode(",", v) + ")"); } - std::vector insert_values; + std::vector v; auto results = db.QueryDatabase( fmt::format( @@ -280,23 +280,23 @@ public: all_entries.reserve(results.RowCount()); for (auto row = results.begin(); row != results.end(); ++row) { - LogsysCategories entry{}; + LogsysCategories e{}; - entry.log_category_id = atoi(row[0]); - entry.log_category_description = row[1] ? row[1] : ""; - entry.log_to_console = atoi(row[2]); - entry.log_to_file = atoi(row[3]); - entry.log_to_gmsay = atoi(row[4]); - entry.log_to_discord = atoi(row[5]); - entry.discord_webhook_id = atoi(row[6]); + e.log_category_id = atoi(row[0]); + e.log_category_description = row[1] ? row[1] : ""; + e.log_to_console = atoi(row[2]); + e.log_to_file = atoi(row[3]); + e.log_to_gmsay = atoi(row[4]); + e.log_to_discord = atoi(row[5]); + e.discord_webhook_id = atoi(row[6]); - all_entries.push_back(entry); + all_entries.push_back(e); } return all_entries; } - static std::vector GetWhere(Database& db, std::string where_filter) + static std::vector GetWhere(Database& db, const std::string &where_filter) { std::vector all_entries; @@ -311,23 +311,23 @@ public: all_entries.reserve(results.RowCount()); for (auto row = results.begin(); row != results.end(); ++row) { - LogsysCategories entry{}; + LogsysCategories e{}; - entry.log_category_id = atoi(row[0]); - entry.log_category_description = row[1] ? row[1] : ""; - entry.log_to_console = atoi(row[2]); - entry.log_to_file = atoi(row[3]); - entry.log_to_gmsay = atoi(row[4]); - entry.log_to_discord = atoi(row[5]); - entry.discord_webhook_id = atoi(row[6]); + e.log_category_id = atoi(row[0]); + e.log_category_description = row[1] ? row[1] : ""; + e.log_to_console = atoi(row[2]); + e.log_to_file = atoi(row[3]); + e.log_to_gmsay = atoi(row[4]); + e.log_to_discord = atoi(row[5]); + e.discord_webhook_id = atoi(row[6]); - all_entries.push_back(entry); + all_entries.push_back(e); } return all_entries; } - static int DeleteWhere(Database& db, std::string where_filter) + static int DeleteWhere(Database& db, const std::string &where_filter) { auto results = db.QueryDatabase( fmt::format( @@ -352,6 +352,32 @@ public: 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); + } + }; #endif //EQEMU_BASE_LOGSYS_CATEGORIES_REPOSITORY_H diff --git a/common/repositories/base/base_lootdrop_entries_repository.h b/common/repositories/base/base_lootdrop_entries_repository.h index 643cb103f..5988381d5 100644 --- a/common/repositories/base/base_lootdrop_entries_repository.h +++ b/common/repositories/base/base_lootdrop_entries_repository.h @@ -106,24 +106,24 @@ public: static LootdropEntries NewEntity() { - LootdropEntries entry{}; + LootdropEntries e{}; - entry.lootdrop_id = 0; - entry.item_id = 0; - entry.item_charges = 1; - entry.equip_item = 0; - entry.chance = 1; - entry.disabled_chance = 0; - entry.trivial_min_level = 0; - entry.trivial_max_level = 0; - entry.multiplier = 1; - entry.npc_min_level = 0; - entry.npc_max_level = 0; + e.lootdrop_id = 0; + e.item_id = 0; + e.item_charges = 1; + e.equip_item = 0; + e.chance = 1; + e.disabled_chance = 0; + e.trivial_min_level = 0; + e.trivial_max_level = 0; + e.multiplier = 1; + e.npc_min_level = 0; + e.npc_max_level = 0; - return entry; + return e; } - static LootdropEntries GetLootdropEntriesEntry( + static LootdropEntries GetLootdropEntries( const std::vector &lootdrop_entriess, int lootdrop_entries_id ) @@ -152,21 +152,21 @@ public: auto row = results.begin(); if (results.RowCount() == 1) { - LootdropEntries entry{}; + LootdropEntries e{}; - entry.lootdrop_id = atoi(row[0]); - entry.item_id = atoi(row[1]); - entry.item_charges = atoi(row[2]); - entry.equip_item = atoi(row[3]); - entry.chance = static_cast(atof(row[4])); - entry.disabled_chance = static_cast(atof(row[5])); - entry.trivial_min_level = atoi(row[6]); - entry.trivial_max_level = atoi(row[7]); - entry.multiplier = atoi(row[8]); - entry.npc_min_level = atoi(row[9]); - entry.npc_max_level = atoi(row[10]); + e.lootdrop_id = atoi(row[0]); + e.item_id = atoi(row[1]); + e.item_charges = atoi(row[2]); + e.equip_item = atoi(row[3]); + e.chance = static_cast(atof(row[4])); + e.disabled_chance = static_cast(atof(row[5])); + e.trivial_min_level = atoi(row[6]); + e.trivial_max_level = atoi(row[7]); + e.multiplier = atoi(row[8]); + e.npc_min_level = atoi(row[9]); + e.npc_max_level = atoi(row[10]); - return entry; + return e; } return NewEntity(); @@ -191,32 +191,32 @@ public: static int UpdateOne( Database& db, - LootdropEntries lootdrop_entries_entry + const LootdropEntries &e ) { - std::vector update_values; + std::vector v; auto columns = Columns(); - update_values.push_back(columns[0] + " = " + std::to_string(lootdrop_entries_entry.lootdrop_id)); - update_values.push_back(columns[1] + " = " + std::to_string(lootdrop_entries_entry.item_id)); - update_values.push_back(columns[2] + " = " + std::to_string(lootdrop_entries_entry.item_charges)); - update_values.push_back(columns[3] + " = " + std::to_string(lootdrop_entries_entry.equip_item)); - update_values.push_back(columns[4] + " = " + std::to_string(lootdrop_entries_entry.chance)); - update_values.push_back(columns[5] + " = " + std::to_string(lootdrop_entries_entry.disabled_chance)); - update_values.push_back(columns[6] + " = " + std::to_string(lootdrop_entries_entry.trivial_min_level)); - update_values.push_back(columns[7] + " = " + std::to_string(lootdrop_entries_entry.trivial_max_level)); - update_values.push_back(columns[8] + " = " + std::to_string(lootdrop_entries_entry.multiplier)); - update_values.push_back(columns[9] + " = " + std::to_string(lootdrop_entries_entry.npc_min_level)); - update_values.push_back(columns[10] + " = " + std::to_string(lootdrop_entries_entry.npc_max_level)); + v.push_back(columns[0] + " = " + std::to_string(e.lootdrop_id)); + v.push_back(columns[1] + " = " + std::to_string(e.item_id)); + v.push_back(columns[2] + " = " + std::to_string(e.item_charges)); + v.push_back(columns[3] + " = " + std::to_string(e.equip_item)); + v.push_back(columns[4] + " = " + std::to_string(e.chance)); + v.push_back(columns[5] + " = " + std::to_string(e.disabled_chance)); + v.push_back(columns[6] + " = " + std::to_string(e.trivial_min_level)); + v.push_back(columns[7] + " = " + std::to_string(e.trivial_max_level)); + v.push_back(columns[8] + " = " + std::to_string(e.multiplier)); + v.push_back(columns[9] + " = " + std::to_string(e.npc_min_level)); + v.push_back(columns[10] + " = " + std::to_string(e.npc_max_level)); auto results = db.QueryDatabase( fmt::format( "UPDATE {} SET {} WHERE {} = {}", TableName(), - Strings::Implode(", ", update_values), + Strings::Implode(", ", v), PrimaryKey(), - lootdrop_entries_entry.lootdrop_id + e.lootdrop_id ) ); @@ -225,67 +225,67 @@ public: static LootdropEntries InsertOne( Database& db, - LootdropEntries lootdrop_entries_entry + LootdropEntries e ) { - std::vector insert_values; + std::vector v; - insert_values.push_back(std::to_string(lootdrop_entries_entry.lootdrop_id)); - insert_values.push_back(std::to_string(lootdrop_entries_entry.item_id)); - insert_values.push_back(std::to_string(lootdrop_entries_entry.item_charges)); - insert_values.push_back(std::to_string(lootdrop_entries_entry.equip_item)); - insert_values.push_back(std::to_string(lootdrop_entries_entry.chance)); - insert_values.push_back(std::to_string(lootdrop_entries_entry.disabled_chance)); - insert_values.push_back(std::to_string(lootdrop_entries_entry.trivial_min_level)); - insert_values.push_back(std::to_string(lootdrop_entries_entry.trivial_max_level)); - insert_values.push_back(std::to_string(lootdrop_entries_entry.multiplier)); - insert_values.push_back(std::to_string(lootdrop_entries_entry.npc_min_level)); - insert_values.push_back(std::to_string(lootdrop_entries_entry.npc_max_level)); + v.push_back(std::to_string(e.lootdrop_id)); + v.push_back(std::to_string(e.item_id)); + v.push_back(std::to_string(e.item_charges)); + v.push_back(std::to_string(e.equip_item)); + v.push_back(std::to_string(e.chance)); + v.push_back(std::to_string(e.disabled_chance)); + v.push_back(std::to_string(e.trivial_min_level)); + v.push_back(std::to_string(e.trivial_max_level)); + v.push_back(std::to_string(e.multiplier)); + v.push_back(std::to_string(e.npc_min_level)); + v.push_back(std::to_string(e.npc_max_level)); auto results = db.QueryDatabase( fmt::format( "{} VALUES ({})", BaseInsert(), - Strings::Implode(",", insert_values) + Strings::Implode(",", v) ) ); if (results.Success()) { - lootdrop_entries_entry.lootdrop_id = results.LastInsertedID(); - return lootdrop_entries_entry; + e.lootdrop_id = results.LastInsertedID(); + return e; } - lootdrop_entries_entry = NewEntity(); + e = NewEntity(); - return lootdrop_entries_entry; + return e; } static int InsertMany( Database& db, - std::vector lootdrop_entries_entries + const std::vector &entries ) { std::vector insert_chunks; - for (auto &lootdrop_entries_entry: lootdrop_entries_entries) { - std::vector insert_values; + for (auto &e: entries) { + std::vector v; - insert_values.push_back(std::to_string(lootdrop_entries_entry.lootdrop_id)); - insert_values.push_back(std::to_string(lootdrop_entries_entry.item_id)); - insert_values.push_back(std::to_string(lootdrop_entries_entry.item_charges)); - insert_values.push_back(std::to_string(lootdrop_entries_entry.equip_item)); - insert_values.push_back(std::to_string(lootdrop_entries_entry.chance)); - insert_values.push_back(std::to_string(lootdrop_entries_entry.disabled_chance)); - insert_values.push_back(std::to_string(lootdrop_entries_entry.trivial_min_level)); - insert_values.push_back(std::to_string(lootdrop_entries_entry.trivial_max_level)); - insert_values.push_back(std::to_string(lootdrop_entries_entry.multiplier)); - insert_values.push_back(std::to_string(lootdrop_entries_entry.npc_min_level)); - insert_values.push_back(std::to_string(lootdrop_entries_entry.npc_max_level)); + v.push_back(std::to_string(e.lootdrop_id)); + v.push_back(std::to_string(e.item_id)); + v.push_back(std::to_string(e.item_charges)); + v.push_back(std::to_string(e.equip_item)); + v.push_back(std::to_string(e.chance)); + v.push_back(std::to_string(e.disabled_chance)); + v.push_back(std::to_string(e.trivial_min_level)); + v.push_back(std::to_string(e.trivial_max_level)); + v.push_back(std::to_string(e.multiplier)); + v.push_back(std::to_string(e.npc_min_level)); + v.push_back(std::to_string(e.npc_max_level)); - insert_chunks.push_back("(" + Strings::Implode(",", insert_values) + ")"); + insert_chunks.push_back("(" + Strings::Implode(",", v) + ")"); } - std::vector insert_values; + std::vector v; auto results = db.QueryDatabase( fmt::format( @@ -312,27 +312,27 @@ public: all_entries.reserve(results.RowCount()); for (auto row = results.begin(); row != results.end(); ++row) { - LootdropEntries entry{}; + LootdropEntries e{}; - entry.lootdrop_id = atoi(row[0]); - entry.item_id = atoi(row[1]); - entry.item_charges = atoi(row[2]); - entry.equip_item = atoi(row[3]); - entry.chance = static_cast(atof(row[4])); - entry.disabled_chance = static_cast(atof(row[5])); - entry.trivial_min_level = atoi(row[6]); - entry.trivial_max_level = atoi(row[7]); - entry.multiplier = atoi(row[8]); - entry.npc_min_level = atoi(row[9]); - entry.npc_max_level = atoi(row[10]); + e.lootdrop_id = atoi(row[0]); + e.item_id = atoi(row[1]); + e.item_charges = atoi(row[2]); + e.equip_item = atoi(row[3]); + e.chance = static_cast(atof(row[4])); + e.disabled_chance = static_cast(atof(row[5])); + e.trivial_min_level = atoi(row[6]); + e.trivial_max_level = atoi(row[7]); + e.multiplier = atoi(row[8]); + e.npc_min_level = atoi(row[9]); + e.npc_max_level = atoi(row[10]); - all_entries.push_back(entry); + all_entries.push_back(e); } return all_entries; } - static std::vector GetWhere(Database& db, std::string where_filter) + static std::vector GetWhere(Database& db, const std::string &where_filter) { std::vector all_entries; @@ -347,27 +347,27 @@ public: all_entries.reserve(results.RowCount()); for (auto row = results.begin(); row != results.end(); ++row) { - LootdropEntries entry{}; + LootdropEntries e{}; - entry.lootdrop_id = atoi(row[0]); - entry.item_id = atoi(row[1]); - entry.item_charges = atoi(row[2]); - entry.equip_item = atoi(row[3]); - entry.chance = static_cast(atof(row[4])); - entry.disabled_chance = static_cast(atof(row[5])); - entry.trivial_min_level = atoi(row[6]); - entry.trivial_max_level = atoi(row[7]); - entry.multiplier = atoi(row[8]); - entry.npc_min_level = atoi(row[9]); - entry.npc_max_level = atoi(row[10]); + e.lootdrop_id = atoi(row[0]); + e.item_id = atoi(row[1]); + e.item_charges = atoi(row[2]); + e.equip_item = atoi(row[3]); + e.chance = static_cast(atof(row[4])); + e.disabled_chance = static_cast(atof(row[5])); + e.trivial_min_level = atoi(row[6]); + e.trivial_max_level = atoi(row[7]); + e.multiplier = atoi(row[8]); + e.npc_min_level = atoi(row[9]); + e.npc_max_level = atoi(row[10]); - all_entries.push_back(entry); + all_entries.push_back(e); } return all_entries; } - static int DeleteWhere(Database& db, std::string where_filter) + static int DeleteWhere(Database& db, const std::string &where_filter) { auto results = db.QueryDatabase( fmt::format( @@ -392,6 +392,32 @@ public: 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); + } + }; #endif //EQEMU_BASE_LOOTDROP_ENTRIES_REPOSITORY_H diff --git a/common/repositories/base/base_lootdrop_repository.h b/common/repositories/base/base_lootdrop_repository.h index fe4053925..53fb883d6 100644 --- a/common/repositories/base/base_lootdrop_repository.h +++ b/common/repositories/base/base_lootdrop_repository.h @@ -91,19 +91,19 @@ public: static Lootdrop NewEntity() { - Lootdrop entry{}; + Lootdrop e{}; - entry.id = 0; - entry.name = ""; - entry.min_expansion = -1; - entry.max_expansion = -1; - entry.content_flags = ""; - entry.content_flags_disabled = ""; + e.id = 0; + e.name = ""; + e.min_expansion = -1; + e.max_expansion = -1; + e.content_flags = ""; + e.content_flags_disabled = ""; - return entry; + return e; } - static Lootdrop GetLootdropEntry( + static Lootdrop GetLootdrop( const std::vector &lootdrops, int lootdrop_id ) @@ -132,16 +132,16 @@ public: auto row = results.begin(); if (results.RowCount() == 1) { - Lootdrop entry{}; + Lootdrop e{}; - entry.id = atoi(row[0]); - entry.name = row[1] ? row[1] : ""; - entry.min_expansion = atoi(row[2]); - entry.max_expansion = atoi(row[3]); - entry.content_flags = row[4] ? row[4] : ""; - entry.content_flags_disabled = row[5] ? row[5] : ""; + e.id = atoi(row[0]); + e.name = row[1] ? row[1] : ""; + e.min_expansion = atoi(row[2]); + e.max_expansion = atoi(row[3]); + e.content_flags = row[4] ? row[4] : ""; + e.content_flags_disabled = row[5] ? row[5] : ""; - return entry; + return e; } return NewEntity(); @@ -166,26 +166,26 @@ public: static int UpdateOne( Database& db, - Lootdrop lootdrop_entry + const Lootdrop &e ) { - std::vector update_values; + std::vector v; auto columns = Columns(); - update_values.push_back(columns[1] + " = '" + Strings::Escape(lootdrop_entry.name) + "'"); - update_values.push_back(columns[2] + " = " + std::to_string(lootdrop_entry.min_expansion)); - update_values.push_back(columns[3] + " = " + std::to_string(lootdrop_entry.max_expansion)); - update_values.push_back(columns[4] + " = '" + Strings::Escape(lootdrop_entry.content_flags) + "'"); - update_values.push_back(columns[5] + " = '" + Strings::Escape(lootdrop_entry.content_flags_disabled) + "'"); + v.push_back(columns[1] + " = '" + Strings::Escape(e.name) + "'"); + v.push_back(columns[2] + " = " + std::to_string(e.min_expansion)); + v.push_back(columns[3] + " = " + std::to_string(e.max_expansion)); + v.push_back(columns[4] + " = '" + Strings::Escape(e.content_flags) + "'"); + v.push_back(columns[5] + " = '" + Strings::Escape(e.content_flags_disabled) + "'"); auto results = db.QueryDatabase( fmt::format( "UPDATE {} SET {} WHERE {} = {}", TableName(), - Strings::Implode(", ", update_values), + Strings::Implode(", ", v), PrimaryKey(), - lootdrop_entry.id + e.id ) ); @@ -194,57 +194,57 @@ public: static Lootdrop InsertOne( Database& db, - Lootdrop lootdrop_entry + Lootdrop e ) { - std::vector insert_values; + std::vector v; - insert_values.push_back(std::to_string(lootdrop_entry.id)); - insert_values.push_back("'" + Strings::Escape(lootdrop_entry.name) + "'"); - insert_values.push_back(std::to_string(lootdrop_entry.min_expansion)); - insert_values.push_back(std::to_string(lootdrop_entry.max_expansion)); - insert_values.push_back("'" + Strings::Escape(lootdrop_entry.content_flags) + "'"); - insert_values.push_back("'" + Strings::Escape(lootdrop_entry.content_flags_disabled) + "'"); + v.push_back(std::to_string(e.id)); + v.push_back("'" + Strings::Escape(e.name) + "'"); + v.push_back(std::to_string(e.min_expansion)); + v.push_back(std::to_string(e.max_expansion)); + v.push_back("'" + Strings::Escape(e.content_flags) + "'"); + v.push_back("'" + Strings::Escape(e.content_flags_disabled) + "'"); auto results = db.QueryDatabase( fmt::format( "{} VALUES ({})", BaseInsert(), - Strings::Implode(",", insert_values) + Strings::Implode(",", v) ) ); if (results.Success()) { - lootdrop_entry.id = results.LastInsertedID(); - return lootdrop_entry; + e.id = results.LastInsertedID(); + return e; } - lootdrop_entry = NewEntity(); + e = NewEntity(); - return lootdrop_entry; + return e; } static int InsertMany( Database& db, - std::vector lootdrop_entries + const std::vector &entries ) { std::vector insert_chunks; - for (auto &lootdrop_entry: lootdrop_entries) { - std::vector insert_values; + for (auto &e: entries) { + std::vector v; - insert_values.push_back(std::to_string(lootdrop_entry.id)); - insert_values.push_back("'" + Strings::Escape(lootdrop_entry.name) + "'"); - insert_values.push_back(std::to_string(lootdrop_entry.min_expansion)); - insert_values.push_back(std::to_string(lootdrop_entry.max_expansion)); - insert_values.push_back("'" + Strings::Escape(lootdrop_entry.content_flags) + "'"); - insert_values.push_back("'" + Strings::Escape(lootdrop_entry.content_flags_disabled) + "'"); + v.push_back(std::to_string(e.id)); + v.push_back("'" + Strings::Escape(e.name) + "'"); + v.push_back(std::to_string(e.min_expansion)); + v.push_back(std::to_string(e.max_expansion)); + v.push_back("'" + Strings::Escape(e.content_flags) + "'"); + v.push_back("'" + Strings::Escape(e.content_flags_disabled) + "'"); - insert_chunks.push_back("(" + Strings::Implode(",", insert_values) + ")"); + insert_chunks.push_back("(" + Strings::Implode(",", v) + ")"); } - std::vector insert_values; + std::vector v; auto results = db.QueryDatabase( fmt::format( @@ -271,22 +271,22 @@ public: all_entries.reserve(results.RowCount()); for (auto row = results.begin(); row != results.end(); ++row) { - Lootdrop entry{}; + Lootdrop e{}; - entry.id = atoi(row[0]); - entry.name = row[1] ? row[1] : ""; - entry.min_expansion = atoi(row[2]); - entry.max_expansion = atoi(row[3]); - entry.content_flags = row[4] ? row[4] : ""; - entry.content_flags_disabled = row[5] ? row[5] : ""; + e.id = atoi(row[0]); + e.name = row[1] ? row[1] : ""; + e.min_expansion = atoi(row[2]); + e.max_expansion = atoi(row[3]); + e.content_flags = row[4] ? row[4] : ""; + e.content_flags_disabled = row[5] ? row[5] : ""; - all_entries.push_back(entry); + all_entries.push_back(e); } return all_entries; } - static std::vector GetWhere(Database& db, std::string where_filter) + static std::vector GetWhere(Database& db, const std::string &where_filter) { std::vector all_entries; @@ -301,22 +301,22 @@ public: all_entries.reserve(results.RowCount()); for (auto row = results.begin(); row != results.end(); ++row) { - Lootdrop entry{}; + Lootdrop e{}; - entry.id = atoi(row[0]); - entry.name = row[1] ? row[1] : ""; - entry.min_expansion = atoi(row[2]); - entry.max_expansion = atoi(row[3]); - entry.content_flags = row[4] ? row[4] : ""; - entry.content_flags_disabled = row[5] ? row[5] : ""; + e.id = atoi(row[0]); + e.name = row[1] ? row[1] : ""; + e.min_expansion = atoi(row[2]); + e.max_expansion = atoi(row[3]); + e.content_flags = row[4] ? row[4] : ""; + e.content_flags_disabled = row[5] ? row[5] : ""; - all_entries.push_back(entry); + all_entries.push_back(e); } return all_entries; } - static int DeleteWhere(Database& db, std::string where_filter) + static int DeleteWhere(Database& db, const std::string &where_filter) { auto results = db.QueryDatabase( fmt::format( @@ -341,6 +341,32 @@ public: 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); + } + }; #endif //EQEMU_BASE_LOOTDROP_REPOSITORY_H diff --git a/common/repositories/base/base_loottable_entries_repository.h b/common/repositories/base/base_loottable_entries_repository.h index 61960d5c4..13ffc23e4 100644 --- a/common/repositories/base/base_loottable_entries_repository.h +++ b/common/repositories/base/base_loottable_entries_repository.h @@ -91,19 +91,19 @@ public: static LoottableEntries NewEntity() { - LoottableEntries entry{}; + LoottableEntries e{}; - entry.loottable_id = 0; - entry.lootdrop_id = 0; - entry.multiplier = 1; - entry.droplimit = 0; - entry.mindrop = 0; - entry.probability = 100; + e.loottable_id = 0; + e.lootdrop_id = 0; + e.multiplier = 1; + e.droplimit = 0; + e.mindrop = 0; + e.probability = 100; - return entry; + return e; } - static LoottableEntries GetLoottableEntriesEntry( + static LoottableEntries GetLoottableEntries( const std::vector &loottable_entriess, int loottable_entries_id ) @@ -132,16 +132,16 @@ public: auto row = results.begin(); if (results.RowCount() == 1) { - LoottableEntries entry{}; + LoottableEntries e{}; - entry.loottable_id = atoi(row[0]); - entry.lootdrop_id = atoi(row[1]); - entry.multiplier = atoi(row[2]); - entry.droplimit = atoi(row[3]); - entry.mindrop = atoi(row[4]); - entry.probability = static_cast(atof(row[5])); + e.loottable_id = atoi(row[0]); + e.lootdrop_id = atoi(row[1]); + e.multiplier = atoi(row[2]); + e.droplimit = atoi(row[3]); + e.mindrop = atoi(row[4]); + e.probability = static_cast(atof(row[5])); - return entry; + return e; } return NewEntity(); @@ -166,27 +166,27 @@ public: static int UpdateOne( Database& db, - LoottableEntries loottable_entries_entry + const LoottableEntries &e ) { - std::vector update_values; + std::vector v; auto columns = Columns(); - update_values.push_back(columns[0] + " = " + std::to_string(loottable_entries_entry.loottable_id)); - update_values.push_back(columns[1] + " = " + std::to_string(loottable_entries_entry.lootdrop_id)); - update_values.push_back(columns[2] + " = " + std::to_string(loottable_entries_entry.multiplier)); - update_values.push_back(columns[3] + " = " + std::to_string(loottable_entries_entry.droplimit)); - update_values.push_back(columns[4] + " = " + std::to_string(loottable_entries_entry.mindrop)); - update_values.push_back(columns[5] + " = " + std::to_string(loottable_entries_entry.probability)); + v.push_back(columns[0] + " = " + std::to_string(e.loottable_id)); + v.push_back(columns[1] + " = " + std::to_string(e.lootdrop_id)); + v.push_back(columns[2] + " = " + std::to_string(e.multiplier)); + v.push_back(columns[3] + " = " + std::to_string(e.droplimit)); + v.push_back(columns[4] + " = " + std::to_string(e.mindrop)); + v.push_back(columns[5] + " = " + std::to_string(e.probability)); auto results = db.QueryDatabase( fmt::format( "UPDATE {} SET {} WHERE {} = {}", TableName(), - Strings::Implode(", ", update_values), + Strings::Implode(", ", v), PrimaryKey(), - loottable_entries_entry.loottable_id + e.loottable_id ) ); @@ -195,57 +195,57 @@ public: static LoottableEntries InsertOne( Database& db, - LoottableEntries loottable_entries_entry + LoottableEntries e ) { - std::vector insert_values; + std::vector v; - insert_values.push_back(std::to_string(loottable_entries_entry.loottable_id)); - insert_values.push_back(std::to_string(loottable_entries_entry.lootdrop_id)); - insert_values.push_back(std::to_string(loottable_entries_entry.multiplier)); - insert_values.push_back(std::to_string(loottable_entries_entry.droplimit)); - insert_values.push_back(std::to_string(loottable_entries_entry.mindrop)); - insert_values.push_back(std::to_string(loottable_entries_entry.probability)); + v.push_back(std::to_string(e.loottable_id)); + v.push_back(std::to_string(e.lootdrop_id)); + v.push_back(std::to_string(e.multiplier)); + v.push_back(std::to_string(e.droplimit)); + v.push_back(std::to_string(e.mindrop)); + v.push_back(std::to_string(e.probability)); auto results = db.QueryDatabase( fmt::format( "{} VALUES ({})", BaseInsert(), - Strings::Implode(",", insert_values) + Strings::Implode(",", v) ) ); if (results.Success()) { - loottable_entries_entry.loottable_id = results.LastInsertedID(); - return loottable_entries_entry; + e.loottable_id = results.LastInsertedID(); + return e; } - loottable_entries_entry = NewEntity(); + e = NewEntity(); - return loottable_entries_entry; + return e; } static int InsertMany( Database& db, - std::vector loottable_entries_entries + const std::vector &entries ) { std::vector insert_chunks; - for (auto &loottable_entries_entry: loottable_entries_entries) { - std::vector insert_values; + for (auto &e: entries) { + std::vector v; - insert_values.push_back(std::to_string(loottable_entries_entry.loottable_id)); - insert_values.push_back(std::to_string(loottable_entries_entry.lootdrop_id)); - insert_values.push_back(std::to_string(loottable_entries_entry.multiplier)); - insert_values.push_back(std::to_string(loottable_entries_entry.droplimit)); - insert_values.push_back(std::to_string(loottable_entries_entry.mindrop)); - insert_values.push_back(std::to_string(loottable_entries_entry.probability)); + v.push_back(std::to_string(e.loottable_id)); + v.push_back(std::to_string(e.lootdrop_id)); + v.push_back(std::to_string(e.multiplier)); + v.push_back(std::to_string(e.droplimit)); + v.push_back(std::to_string(e.mindrop)); + v.push_back(std::to_string(e.probability)); - insert_chunks.push_back("(" + Strings::Implode(",", insert_values) + ")"); + insert_chunks.push_back("(" + Strings::Implode(",", v) + ")"); } - std::vector insert_values; + std::vector v; auto results = db.QueryDatabase( fmt::format( @@ -272,22 +272,22 @@ public: all_entries.reserve(results.RowCount()); for (auto row = results.begin(); row != results.end(); ++row) { - LoottableEntries entry{}; + LoottableEntries e{}; - entry.loottable_id = atoi(row[0]); - entry.lootdrop_id = atoi(row[1]); - entry.multiplier = atoi(row[2]); - entry.droplimit = atoi(row[3]); - entry.mindrop = atoi(row[4]); - entry.probability = static_cast(atof(row[5])); + e.loottable_id = atoi(row[0]); + e.lootdrop_id = atoi(row[1]); + e.multiplier = atoi(row[2]); + e.droplimit = atoi(row[3]); + e.mindrop = atoi(row[4]); + e.probability = static_cast(atof(row[5])); - all_entries.push_back(entry); + all_entries.push_back(e); } return all_entries; } - static std::vector GetWhere(Database& db, std::string where_filter) + static std::vector GetWhere(Database& db, const std::string &where_filter) { std::vector all_entries; @@ -302,22 +302,22 @@ public: all_entries.reserve(results.RowCount()); for (auto row = results.begin(); row != results.end(); ++row) { - LoottableEntries entry{}; + LoottableEntries e{}; - entry.loottable_id = atoi(row[0]); - entry.lootdrop_id = atoi(row[1]); - entry.multiplier = atoi(row[2]); - entry.droplimit = atoi(row[3]); - entry.mindrop = atoi(row[4]); - entry.probability = static_cast(atof(row[5])); + e.loottable_id = atoi(row[0]); + e.lootdrop_id = atoi(row[1]); + e.multiplier = atoi(row[2]); + e.droplimit = atoi(row[3]); + e.mindrop = atoi(row[4]); + e.probability = static_cast(atof(row[5])); - all_entries.push_back(entry); + all_entries.push_back(e); } return all_entries; } - static int DeleteWhere(Database& db, std::string where_filter) + static int DeleteWhere(Database& db, const std::string &where_filter) { auto results = db.QueryDatabase( fmt::format( @@ -342,6 +342,32 @@ public: 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); + } + }; #endif //EQEMU_BASE_LOOTTABLE_ENTRIES_REPOSITORY_H diff --git a/common/repositories/base/base_loottable_repository.h b/common/repositories/base/base_loottable_repository.h index 803409e4c..636e64f84 100644 --- a/common/repositories/base/base_loottable_repository.h +++ b/common/repositories/base/base_loottable_repository.h @@ -103,23 +103,23 @@ public: static Loottable NewEntity() { - Loottable entry{}; + Loottable e{}; - entry.id = 0; - entry.name = ""; - entry.mincash = 0; - entry.maxcash = 0; - entry.avgcoin = 0; - entry.done = 0; - entry.min_expansion = -1; - entry.max_expansion = -1; - entry.content_flags = ""; - entry.content_flags_disabled = ""; + e.id = 0; + e.name = ""; + e.mincash = 0; + e.maxcash = 0; + e.avgcoin = 0; + e.done = 0; + e.min_expansion = -1; + e.max_expansion = -1; + e.content_flags = ""; + e.content_flags_disabled = ""; - return entry; + return e; } - static Loottable GetLoottableEntry( + static Loottable GetLoottable( const std::vector &loottables, int loottable_id ) @@ -148,20 +148,20 @@ public: auto row = results.begin(); if (results.RowCount() == 1) { - Loottable entry{}; + Loottable e{}; - entry.id = atoi(row[0]); - entry.name = row[1] ? row[1] : ""; - entry.mincash = atoi(row[2]); - entry.maxcash = atoi(row[3]); - entry.avgcoin = atoi(row[4]); - entry.done = atoi(row[5]); - entry.min_expansion = atoi(row[6]); - entry.max_expansion = atoi(row[7]); - entry.content_flags = row[8] ? row[8] : ""; - entry.content_flags_disabled = row[9] ? row[9] : ""; + e.id = atoi(row[0]); + e.name = row[1] ? row[1] : ""; + e.mincash = atoi(row[2]); + e.maxcash = atoi(row[3]); + e.avgcoin = atoi(row[4]); + e.done = atoi(row[5]); + e.min_expansion = atoi(row[6]); + e.max_expansion = atoi(row[7]); + e.content_flags = row[8] ? row[8] : ""; + e.content_flags_disabled = row[9] ? row[9] : ""; - return entry; + return e; } return NewEntity(); @@ -186,30 +186,30 @@ public: static int UpdateOne( Database& db, - Loottable loottable_entry + const Loottable &e ) { - std::vector update_values; + std::vector v; auto columns = Columns(); - update_values.push_back(columns[1] + " = '" + Strings::Escape(loottable_entry.name) + "'"); - update_values.push_back(columns[2] + " = " + std::to_string(loottable_entry.mincash)); - update_values.push_back(columns[3] + " = " + std::to_string(loottable_entry.maxcash)); - update_values.push_back(columns[4] + " = " + std::to_string(loottable_entry.avgcoin)); - update_values.push_back(columns[5] + " = " + std::to_string(loottable_entry.done)); - update_values.push_back(columns[6] + " = " + std::to_string(loottable_entry.min_expansion)); - update_values.push_back(columns[7] + " = " + std::to_string(loottable_entry.max_expansion)); - update_values.push_back(columns[8] + " = '" + Strings::Escape(loottable_entry.content_flags) + "'"); - update_values.push_back(columns[9] + " = '" + Strings::Escape(loottable_entry.content_flags_disabled) + "'"); + v.push_back(columns[1] + " = '" + Strings::Escape(e.name) + "'"); + v.push_back(columns[2] + " = " + std::to_string(e.mincash)); + v.push_back(columns[3] + " = " + std::to_string(e.maxcash)); + v.push_back(columns[4] + " = " + std::to_string(e.avgcoin)); + v.push_back(columns[5] + " = " + std::to_string(e.done)); + v.push_back(columns[6] + " = " + std::to_string(e.min_expansion)); + v.push_back(columns[7] + " = " + std::to_string(e.max_expansion)); + v.push_back(columns[8] + " = '" + Strings::Escape(e.content_flags) + "'"); + v.push_back(columns[9] + " = '" + Strings::Escape(e.content_flags_disabled) + "'"); auto results = db.QueryDatabase( fmt::format( "UPDATE {} SET {} WHERE {} = {}", TableName(), - Strings::Implode(", ", update_values), + Strings::Implode(", ", v), PrimaryKey(), - loottable_entry.id + e.id ) ); @@ -218,65 +218,65 @@ public: static Loottable InsertOne( Database& db, - Loottable loottable_entry + Loottable e ) { - std::vector insert_values; + std::vector v; - insert_values.push_back(std::to_string(loottable_entry.id)); - insert_values.push_back("'" + Strings::Escape(loottable_entry.name) + "'"); - insert_values.push_back(std::to_string(loottable_entry.mincash)); - insert_values.push_back(std::to_string(loottable_entry.maxcash)); - insert_values.push_back(std::to_string(loottable_entry.avgcoin)); - insert_values.push_back(std::to_string(loottable_entry.done)); - insert_values.push_back(std::to_string(loottable_entry.min_expansion)); - insert_values.push_back(std::to_string(loottable_entry.max_expansion)); - insert_values.push_back("'" + Strings::Escape(loottable_entry.content_flags) + "'"); - insert_values.push_back("'" + Strings::Escape(loottable_entry.content_flags_disabled) + "'"); + v.push_back(std::to_string(e.id)); + v.push_back("'" + Strings::Escape(e.name) + "'"); + v.push_back(std::to_string(e.mincash)); + v.push_back(std::to_string(e.maxcash)); + v.push_back(std::to_string(e.avgcoin)); + v.push_back(std::to_string(e.done)); + v.push_back(std::to_string(e.min_expansion)); + v.push_back(std::to_string(e.max_expansion)); + v.push_back("'" + Strings::Escape(e.content_flags) + "'"); + v.push_back("'" + Strings::Escape(e.content_flags_disabled) + "'"); auto results = db.QueryDatabase( fmt::format( "{} VALUES ({})", BaseInsert(), - Strings::Implode(",", insert_values) + Strings::Implode(",", v) ) ); if (results.Success()) { - loottable_entry.id = results.LastInsertedID(); - return loottable_entry; + e.id = results.LastInsertedID(); + return e; } - loottable_entry = NewEntity(); + e = NewEntity(); - return loottable_entry; + return e; } static int InsertMany( Database& db, - std::vector loottable_entries + const std::vector &entries ) { std::vector insert_chunks; - for (auto &loottable_entry: loottable_entries) { - std::vector insert_values; + for (auto &e: entries) { + std::vector v; - insert_values.push_back(std::to_string(loottable_entry.id)); - insert_values.push_back("'" + Strings::Escape(loottable_entry.name) + "'"); - insert_values.push_back(std::to_string(loottable_entry.mincash)); - insert_values.push_back(std::to_string(loottable_entry.maxcash)); - insert_values.push_back(std::to_string(loottable_entry.avgcoin)); - insert_values.push_back(std::to_string(loottable_entry.done)); - insert_values.push_back(std::to_string(loottable_entry.min_expansion)); - insert_values.push_back(std::to_string(loottable_entry.max_expansion)); - insert_values.push_back("'" + Strings::Escape(loottable_entry.content_flags) + "'"); - insert_values.push_back("'" + Strings::Escape(loottable_entry.content_flags_disabled) + "'"); + v.push_back(std::to_string(e.id)); + v.push_back("'" + Strings::Escape(e.name) + "'"); + v.push_back(std::to_string(e.mincash)); + v.push_back(std::to_string(e.maxcash)); + v.push_back(std::to_string(e.avgcoin)); + v.push_back(std::to_string(e.done)); + v.push_back(std::to_string(e.min_expansion)); + v.push_back(std::to_string(e.max_expansion)); + v.push_back("'" + Strings::Escape(e.content_flags) + "'"); + v.push_back("'" + Strings::Escape(e.content_flags_disabled) + "'"); - insert_chunks.push_back("(" + Strings::Implode(",", insert_values) + ")"); + insert_chunks.push_back("(" + Strings::Implode(",", v) + ")"); } - std::vector insert_values; + std::vector v; auto results = db.QueryDatabase( fmt::format( @@ -303,26 +303,26 @@ public: all_entries.reserve(results.RowCount()); for (auto row = results.begin(); row != results.end(); ++row) { - Loottable entry{}; + Loottable e{}; - entry.id = atoi(row[0]); - entry.name = row[1] ? row[1] : ""; - entry.mincash = atoi(row[2]); - entry.maxcash = atoi(row[3]); - entry.avgcoin = atoi(row[4]); - entry.done = atoi(row[5]); - entry.min_expansion = atoi(row[6]); - entry.max_expansion = atoi(row[7]); - entry.content_flags = row[8] ? row[8] : ""; - entry.content_flags_disabled = row[9] ? row[9] : ""; + e.id = atoi(row[0]); + e.name = row[1] ? row[1] : ""; + e.mincash = atoi(row[2]); + e.maxcash = atoi(row[3]); + e.avgcoin = atoi(row[4]); + e.done = atoi(row[5]); + e.min_expansion = atoi(row[6]); + e.max_expansion = atoi(row[7]); + e.content_flags = row[8] ? row[8] : ""; + e.content_flags_disabled = row[9] ? row[9] : ""; - all_entries.push_back(entry); + all_entries.push_back(e); } return all_entries; } - static std::vector GetWhere(Database& db, std::string where_filter) + static std::vector GetWhere(Database& db, const std::string &where_filter) { std::vector all_entries; @@ -337,26 +337,26 @@ public: all_entries.reserve(results.RowCount()); for (auto row = results.begin(); row != results.end(); ++row) { - Loottable entry{}; + Loottable e{}; - entry.id = atoi(row[0]); - entry.name = row[1] ? row[1] : ""; - entry.mincash = atoi(row[2]); - entry.maxcash = atoi(row[3]); - entry.avgcoin = atoi(row[4]); - entry.done = atoi(row[5]); - entry.min_expansion = atoi(row[6]); - entry.max_expansion = atoi(row[7]); - entry.content_flags = row[8] ? row[8] : ""; - entry.content_flags_disabled = row[9] ? row[9] : ""; + e.id = atoi(row[0]); + e.name = row[1] ? row[1] : ""; + e.mincash = atoi(row[2]); + e.maxcash = atoi(row[3]); + e.avgcoin = atoi(row[4]); + e.done = atoi(row[5]); + e.min_expansion = atoi(row[6]); + e.max_expansion = atoi(row[7]); + e.content_flags = row[8] ? row[8] : ""; + e.content_flags_disabled = row[9] ? row[9] : ""; - all_entries.push_back(entry); + all_entries.push_back(e); } return all_entries; } - static int DeleteWhere(Database& db, std::string where_filter) + static int DeleteWhere(Database& db, const std::string &where_filter) { auto results = db.QueryDatabase( fmt::format( @@ -381,6 +381,32 @@ public: 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); + } + }; #endif //EQEMU_BASE_LOOTTABLE_REPOSITORY_H diff --git a/common/repositories/base/base_mail_repository.h b/common/repositories/base/base_mail_repository.h index 4e83022b8..2594cb1a7 100644 --- a/common/repositories/base/base_mail_repository.h +++ b/common/repositories/base/base_mail_repository.h @@ -97,21 +97,21 @@ public: static Mail NewEntity() { - Mail entry{}; + Mail e{}; - entry.msgid = 0; - entry.charid = 0; - entry.timestamp = 0; - entry.from = ""; - entry.subject = ""; - entry.body = ""; - entry.to = ""; - entry.status = 0; + e.msgid = 0; + e.charid = 0; + e.timestamp = 0; + e.from = ""; + e.subject = ""; + e.body = ""; + e.to = ""; + e.status = 0; - return entry; + return e; } - static Mail GetMailEntry( + static Mail GetMail( const std::vector &mails, int mail_id ) @@ -140,18 +140,18 @@ public: auto row = results.begin(); if (results.RowCount() == 1) { - Mail entry{}; + Mail e{}; - entry.msgid = atoi(row[0]); - entry.charid = atoi(row[1]); - entry.timestamp = atoi(row[2]); - entry.from = row[3] ? row[3] : ""; - entry.subject = row[4] ? row[4] : ""; - entry.body = row[5] ? row[5] : ""; - entry.to = row[6] ? row[6] : ""; - entry.status = atoi(row[7]); + e.msgid = atoi(row[0]); + e.charid = atoi(row[1]); + e.timestamp = atoi(row[2]); + e.from = row[3] ? row[3] : ""; + e.subject = row[4] ? row[4] : ""; + e.body = row[5] ? row[5] : ""; + e.to = row[6] ? row[6] : ""; + e.status = atoi(row[7]); - return entry; + return e; } return NewEntity(); @@ -176,28 +176,28 @@ public: static int UpdateOne( Database& db, - Mail mail_entry + const Mail &e ) { - std::vector update_values; + std::vector v; auto columns = Columns(); - update_values.push_back(columns[1] + " = " + std::to_string(mail_entry.charid)); - update_values.push_back(columns[2] + " = " + std::to_string(mail_entry.timestamp)); - update_values.push_back(columns[3] + " = '" + Strings::Escape(mail_entry.from) + "'"); - update_values.push_back(columns[4] + " = '" + Strings::Escape(mail_entry.subject) + "'"); - update_values.push_back(columns[5] + " = '" + Strings::Escape(mail_entry.body) + "'"); - update_values.push_back(columns[6] + " = '" + Strings::Escape(mail_entry.to) + "'"); - update_values.push_back(columns[7] + " = " + std::to_string(mail_entry.status)); + v.push_back(columns[1] + " = " + std::to_string(e.charid)); + v.push_back(columns[2] + " = " + std::to_string(e.timestamp)); + v.push_back(columns[3] + " = '" + Strings::Escape(e.from) + "'"); + v.push_back(columns[4] + " = '" + Strings::Escape(e.subject) + "'"); + v.push_back(columns[5] + " = '" + Strings::Escape(e.body) + "'"); + v.push_back(columns[6] + " = '" + Strings::Escape(e.to) + "'"); + v.push_back(columns[7] + " = " + std::to_string(e.status)); auto results = db.QueryDatabase( fmt::format( "UPDATE {} SET {} WHERE {} = {}", TableName(), - Strings::Implode(", ", update_values), + Strings::Implode(", ", v), PrimaryKey(), - mail_entry.msgid + e.msgid ) ); @@ -206,61 +206,61 @@ public: static Mail InsertOne( Database& db, - Mail mail_entry + Mail e ) { - std::vector insert_values; + std::vector v; - insert_values.push_back(std::to_string(mail_entry.msgid)); - insert_values.push_back(std::to_string(mail_entry.charid)); - insert_values.push_back(std::to_string(mail_entry.timestamp)); - insert_values.push_back("'" + Strings::Escape(mail_entry.from) + "'"); - insert_values.push_back("'" + Strings::Escape(mail_entry.subject) + "'"); - insert_values.push_back("'" + Strings::Escape(mail_entry.body) + "'"); - insert_values.push_back("'" + Strings::Escape(mail_entry.to) + "'"); - insert_values.push_back(std::to_string(mail_entry.status)); + v.push_back(std::to_string(e.msgid)); + v.push_back(std::to_string(e.charid)); + v.push_back(std::to_string(e.timestamp)); + v.push_back("'" + Strings::Escape(e.from) + "'"); + v.push_back("'" + Strings::Escape(e.subject) + "'"); + v.push_back("'" + Strings::Escape(e.body) + "'"); + v.push_back("'" + Strings::Escape(e.to) + "'"); + v.push_back(std::to_string(e.status)); auto results = db.QueryDatabase( fmt::format( "{} VALUES ({})", BaseInsert(), - Strings::Implode(",", insert_values) + Strings::Implode(",", v) ) ); if (results.Success()) { - mail_entry.msgid = results.LastInsertedID(); - return mail_entry; + e.msgid = results.LastInsertedID(); + return e; } - mail_entry = NewEntity(); + e = NewEntity(); - return mail_entry; + return e; } static int InsertMany( Database& db, - std::vector mail_entries + const std::vector &entries ) { std::vector insert_chunks; - for (auto &mail_entry: mail_entries) { - std::vector insert_values; + for (auto &e: entries) { + std::vector v; - insert_values.push_back(std::to_string(mail_entry.msgid)); - insert_values.push_back(std::to_string(mail_entry.charid)); - insert_values.push_back(std::to_string(mail_entry.timestamp)); - insert_values.push_back("'" + Strings::Escape(mail_entry.from) + "'"); - insert_values.push_back("'" + Strings::Escape(mail_entry.subject) + "'"); - insert_values.push_back("'" + Strings::Escape(mail_entry.body) + "'"); - insert_values.push_back("'" + Strings::Escape(mail_entry.to) + "'"); - insert_values.push_back(std::to_string(mail_entry.status)); + v.push_back(std::to_string(e.msgid)); + v.push_back(std::to_string(e.charid)); + v.push_back(std::to_string(e.timestamp)); + v.push_back("'" + Strings::Escape(e.from) + "'"); + v.push_back("'" + Strings::Escape(e.subject) + "'"); + v.push_back("'" + Strings::Escape(e.body) + "'"); + v.push_back("'" + Strings::Escape(e.to) + "'"); + v.push_back(std::to_string(e.status)); - insert_chunks.push_back("(" + Strings::Implode(",", insert_values) + ")"); + insert_chunks.push_back("(" + Strings::Implode(",", v) + ")"); } - std::vector insert_values; + std::vector v; auto results = db.QueryDatabase( fmt::format( @@ -287,24 +287,24 @@ public: all_entries.reserve(results.RowCount()); for (auto row = results.begin(); row != results.end(); ++row) { - Mail entry{}; + Mail e{}; - entry.msgid = atoi(row[0]); - entry.charid = atoi(row[1]); - entry.timestamp = atoi(row[2]); - entry.from = row[3] ? row[3] : ""; - entry.subject = row[4] ? row[4] : ""; - entry.body = row[5] ? row[5] : ""; - entry.to = row[6] ? row[6] : ""; - entry.status = atoi(row[7]); + e.msgid = atoi(row[0]); + e.charid = atoi(row[1]); + e.timestamp = atoi(row[2]); + e.from = row[3] ? row[3] : ""; + e.subject = row[4] ? row[4] : ""; + e.body = row[5] ? row[5] : ""; + e.to = row[6] ? row[6] : ""; + e.status = atoi(row[7]); - all_entries.push_back(entry); + all_entries.push_back(e); } return all_entries; } - static std::vector GetWhere(Database& db, std::string where_filter) + static std::vector GetWhere(Database& db, const std::string &where_filter) { std::vector all_entries; @@ -319,24 +319,24 @@ public: all_entries.reserve(results.RowCount()); for (auto row = results.begin(); row != results.end(); ++row) { - Mail entry{}; + Mail e{}; - entry.msgid = atoi(row[0]); - entry.charid = atoi(row[1]); - entry.timestamp = atoi(row[2]); - entry.from = row[3] ? row[3] : ""; - entry.subject = row[4] ? row[4] : ""; - entry.body = row[5] ? row[5] : ""; - entry.to = row[6] ? row[6] : ""; - entry.status = atoi(row[7]); + e.msgid = atoi(row[0]); + e.charid = atoi(row[1]); + e.timestamp = atoi(row[2]); + e.from = row[3] ? row[3] : ""; + e.subject = row[4] ? row[4] : ""; + e.body = row[5] ? row[5] : ""; + e.to = row[6] ? row[6] : ""; + e.status = atoi(row[7]); - all_entries.push_back(entry); + all_entries.push_back(e); } return all_entries; } - static int DeleteWhere(Database& db, std::string where_filter) + static int DeleteWhere(Database& db, const std::string &where_filter) { auto results = db.QueryDatabase( fmt::format( @@ -361,6 +361,32 @@ public: 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); + } + }; #endif //EQEMU_BASE_MAIL_REPOSITORY_H diff --git a/common/repositories/base/base_merchantlist_repository.h b/common/repositories/base/base_merchantlist_repository.h index 8805d57d0..b2ec44c32 100644 --- a/common/repositories/base/base_merchantlist_repository.h +++ b/common/repositories/base/base_merchantlist_repository.h @@ -27,6 +27,9 @@ public: int alt_currency_cost; int classes_required; int probability; + std::string bucket_name; + std::string bucket_value; + int bucket_comparison; int min_expansion; int max_expansion; std::string content_flags; @@ -49,6 +52,9 @@ public: "alt_currency_cost", "classes_required", "probability", + "bucket_name", + "bucket_value", + "bucket_comparison", "min_expansion", "max_expansion", "content_flags", @@ -67,6 +73,9 @@ public: "alt_currency_cost", "classes_required", "probability", + "bucket_name", + "bucket_value", + "bucket_comparison", "min_expansion", "max_expansion", "content_flags", @@ -109,25 +118,28 @@ public: static Merchantlist NewEntity() { - Merchantlist entry{}; + Merchantlist e{}; - entry.merchantid = 0; - entry.slot = 0; - entry.item = 0; - entry.faction_required = -100; - entry.level_required = 0; - entry.alt_currency_cost = 0; - entry.classes_required = 65535; - entry.probability = 100; - entry.min_expansion = -1; - entry.max_expansion = -1; - entry.content_flags = ""; - entry.content_flags_disabled = ""; + e.merchantid = 0; + e.slot = 0; + e.item = 0; + e.faction_required = -100; + e.level_required = 0; + e.alt_currency_cost = 0; + e.classes_required = 65535; + e.probability = 100; + e.bucket_name = ""; + e.bucket_value = ""; + e.bucket_comparison = 0; + e.min_expansion = -1; + e.max_expansion = -1; + e.content_flags = ""; + e.content_flags_disabled = ""; - return entry; + return e; } - static Merchantlist GetMerchantlistEntry( + static Merchantlist GetMerchantlist( const std::vector &merchantlists, int merchantlist_id ) @@ -156,22 +168,25 @@ public: auto row = results.begin(); if (results.RowCount() == 1) { - Merchantlist entry{}; + Merchantlist e{}; - entry.merchantid = atoi(row[0]); - entry.slot = atoi(row[1]); - entry.item = atoi(row[2]); - entry.faction_required = atoi(row[3]); - entry.level_required = atoi(row[4]); - entry.alt_currency_cost = atoi(row[5]); - entry.classes_required = atoi(row[6]); - entry.probability = atoi(row[7]); - entry.min_expansion = atoi(row[8]); - entry.max_expansion = atoi(row[9]); - entry.content_flags = row[10] ? row[10] : ""; - entry.content_flags_disabled = row[11] ? row[11] : ""; + e.merchantid = atoi(row[0]); + e.slot = atoi(row[1]); + e.item = atoi(row[2]); + e.faction_required = atoi(row[3]); + e.level_required = atoi(row[4]); + e.alt_currency_cost = atoi(row[5]); + e.classes_required = atoi(row[6]); + e.probability = atoi(row[7]); + e.bucket_name = row[8] ? row[8] : ""; + e.bucket_value = row[9] ? row[9] : ""; + e.bucket_comparison = atoi(row[10]); + e.min_expansion = atoi(row[11]); + e.max_expansion = atoi(row[12]); + e.content_flags = row[13] ? row[13] : ""; + e.content_flags_disabled = row[14] ? row[14] : ""; - return entry; + return e; } return NewEntity(); @@ -196,33 +211,36 @@ public: static int UpdateOne( Database& db, - Merchantlist merchantlist_entry + const Merchantlist &e ) { - std::vector update_values; + std::vector v; auto columns = Columns(); - update_values.push_back(columns[0] + " = " + std::to_string(merchantlist_entry.merchantid)); - update_values.push_back(columns[1] + " = " + std::to_string(merchantlist_entry.slot)); - update_values.push_back(columns[2] + " = " + std::to_string(merchantlist_entry.item)); - update_values.push_back(columns[3] + " = " + std::to_string(merchantlist_entry.faction_required)); - update_values.push_back(columns[4] + " = " + std::to_string(merchantlist_entry.level_required)); - update_values.push_back(columns[5] + " = " + std::to_string(merchantlist_entry.alt_currency_cost)); - update_values.push_back(columns[6] + " = " + std::to_string(merchantlist_entry.classes_required)); - update_values.push_back(columns[7] + " = " + std::to_string(merchantlist_entry.probability)); - update_values.push_back(columns[8] + " = " + std::to_string(merchantlist_entry.min_expansion)); - update_values.push_back(columns[9] + " = " + std::to_string(merchantlist_entry.max_expansion)); - update_values.push_back(columns[10] + " = '" + Strings::Escape(merchantlist_entry.content_flags) + "'"); - update_values.push_back(columns[11] + " = '" + Strings::Escape(merchantlist_entry.content_flags_disabled) + "'"); + v.push_back(columns[0] + " = " + std::to_string(e.merchantid)); + v.push_back(columns[1] + " = " + std::to_string(e.slot)); + v.push_back(columns[2] + " = " + std::to_string(e.item)); + v.push_back(columns[3] + " = " + std::to_string(e.faction_required)); + v.push_back(columns[4] + " = " + std::to_string(e.level_required)); + v.push_back(columns[5] + " = " + std::to_string(e.alt_currency_cost)); + v.push_back(columns[6] + " = " + std::to_string(e.classes_required)); + v.push_back(columns[7] + " = " + std::to_string(e.probability)); + v.push_back(columns[8] + " = '" + Strings::Escape(e.bucket_name) + "'"); + v.push_back(columns[9] + " = '" + Strings::Escape(e.bucket_value) + "'"); + v.push_back(columns[10] + " = " + std::to_string(e.bucket_comparison)); + v.push_back(columns[11] + " = " + std::to_string(e.min_expansion)); + v.push_back(columns[12] + " = " + std::to_string(e.max_expansion)); + v.push_back(columns[13] + " = '" + Strings::Escape(e.content_flags) + "'"); + v.push_back(columns[14] + " = '" + Strings::Escape(e.content_flags_disabled) + "'"); auto results = db.QueryDatabase( fmt::format( "UPDATE {} SET {} WHERE {} = {}", TableName(), - Strings::Implode(", ", update_values), + Strings::Implode(", ", v), PrimaryKey(), - merchantlist_entry.merchantid + e.merchantid ) ); @@ -231,69 +249,75 @@ public: static Merchantlist InsertOne( Database& db, - Merchantlist merchantlist_entry + Merchantlist e ) { - std::vector insert_values; + std::vector v; - insert_values.push_back(std::to_string(merchantlist_entry.merchantid)); - insert_values.push_back(std::to_string(merchantlist_entry.slot)); - insert_values.push_back(std::to_string(merchantlist_entry.item)); - insert_values.push_back(std::to_string(merchantlist_entry.faction_required)); - insert_values.push_back(std::to_string(merchantlist_entry.level_required)); - insert_values.push_back(std::to_string(merchantlist_entry.alt_currency_cost)); - insert_values.push_back(std::to_string(merchantlist_entry.classes_required)); - insert_values.push_back(std::to_string(merchantlist_entry.probability)); - insert_values.push_back(std::to_string(merchantlist_entry.min_expansion)); - insert_values.push_back(std::to_string(merchantlist_entry.max_expansion)); - insert_values.push_back("'" + Strings::Escape(merchantlist_entry.content_flags) + "'"); - insert_values.push_back("'" + Strings::Escape(merchantlist_entry.content_flags_disabled) + "'"); + v.push_back(std::to_string(e.merchantid)); + v.push_back(std::to_string(e.slot)); + v.push_back(std::to_string(e.item)); + v.push_back(std::to_string(e.faction_required)); + v.push_back(std::to_string(e.level_required)); + v.push_back(std::to_string(e.alt_currency_cost)); + v.push_back(std::to_string(e.classes_required)); + v.push_back(std::to_string(e.probability)); + v.push_back("'" + Strings::Escape(e.bucket_name) + "'"); + v.push_back("'" + Strings::Escape(e.bucket_value) + "'"); + v.push_back(std::to_string(e.bucket_comparison)); + v.push_back(std::to_string(e.min_expansion)); + v.push_back(std::to_string(e.max_expansion)); + v.push_back("'" + Strings::Escape(e.content_flags) + "'"); + v.push_back("'" + Strings::Escape(e.content_flags_disabled) + "'"); auto results = db.QueryDatabase( fmt::format( "{} VALUES ({})", BaseInsert(), - Strings::Implode(",", insert_values) + Strings::Implode(",", v) ) ); if (results.Success()) { - merchantlist_entry.merchantid = results.LastInsertedID(); - return merchantlist_entry; + e.merchantid = results.LastInsertedID(); + return e; } - merchantlist_entry = NewEntity(); + e = NewEntity(); - return merchantlist_entry; + return e; } static int InsertMany( Database& db, - std::vector merchantlist_entries + const std::vector &entries ) { std::vector insert_chunks; - for (auto &merchantlist_entry: merchantlist_entries) { - std::vector insert_values; + for (auto &e: entries) { + std::vector v; - insert_values.push_back(std::to_string(merchantlist_entry.merchantid)); - insert_values.push_back(std::to_string(merchantlist_entry.slot)); - insert_values.push_back(std::to_string(merchantlist_entry.item)); - insert_values.push_back(std::to_string(merchantlist_entry.faction_required)); - insert_values.push_back(std::to_string(merchantlist_entry.level_required)); - insert_values.push_back(std::to_string(merchantlist_entry.alt_currency_cost)); - insert_values.push_back(std::to_string(merchantlist_entry.classes_required)); - insert_values.push_back(std::to_string(merchantlist_entry.probability)); - insert_values.push_back(std::to_string(merchantlist_entry.min_expansion)); - insert_values.push_back(std::to_string(merchantlist_entry.max_expansion)); - insert_values.push_back("'" + Strings::Escape(merchantlist_entry.content_flags) + "'"); - insert_values.push_back("'" + Strings::Escape(merchantlist_entry.content_flags_disabled) + "'"); + v.push_back(std::to_string(e.merchantid)); + v.push_back(std::to_string(e.slot)); + v.push_back(std::to_string(e.item)); + v.push_back(std::to_string(e.faction_required)); + v.push_back(std::to_string(e.level_required)); + v.push_back(std::to_string(e.alt_currency_cost)); + v.push_back(std::to_string(e.classes_required)); + v.push_back(std::to_string(e.probability)); + v.push_back("'" + Strings::Escape(e.bucket_name) + "'"); + v.push_back("'" + Strings::Escape(e.bucket_value) + "'"); + v.push_back(std::to_string(e.bucket_comparison)); + v.push_back(std::to_string(e.min_expansion)); + v.push_back(std::to_string(e.max_expansion)); + v.push_back("'" + Strings::Escape(e.content_flags) + "'"); + v.push_back("'" + Strings::Escape(e.content_flags_disabled) + "'"); - insert_chunks.push_back("(" + Strings::Implode(",", insert_values) + ")"); + insert_chunks.push_back("(" + Strings::Implode(",", v) + ")"); } - std::vector insert_values; + std::vector v; auto results = db.QueryDatabase( fmt::format( @@ -320,28 +344,31 @@ public: all_entries.reserve(results.RowCount()); for (auto row = results.begin(); row != results.end(); ++row) { - Merchantlist entry{}; + Merchantlist e{}; - entry.merchantid = atoi(row[0]); - entry.slot = atoi(row[1]); - entry.item = atoi(row[2]); - entry.faction_required = atoi(row[3]); - entry.level_required = atoi(row[4]); - entry.alt_currency_cost = atoi(row[5]); - entry.classes_required = atoi(row[6]); - entry.probability = atoi(row[7]); - entry.min_expansion = atoi(row[8]); - entry.max_expansion = atoi(row[9]); - entry.content_flags = row[10] ? row[10] : ""; - entry.content_flags_disabled = row[11] ? row[11] : ""; + e.merchantid = atoi(row[0]); + e.slot = atoi(row[1]); + e.item = atoi(row[2]); + e.faction_required = atoi(row[3]); + e.level_required = atoi(row[4]); + e.alt_currency_cost = atoi(row[5]); + e.classes_required = atoi(row[6]); + e.probability = atoi(row[7]); + e.bucket_name = row[8] ? row[8] : ""; + e.bucket_value = row[9] ? row[9] : ""; + e.bucket_comparison = atoi(row[10]); + e.min_expansion = atoi(row[11]); + e.max_expansion = atoi(row[12]); + e.content_flags = row[13] ? row[13] : ""; + e.content_flags_disabled = row[14] ? row[14] : ""; - all_entries.push_back(entry); + all_entries.push_back(e); } return all_entries; } - static std::vector GetWhere(Database& db, std::string where_filter) + static std::vector GetWhere(Database& db, const std::string &where_filter) { std::vector all_entries; @@ -356,28 +383,31 @@ public: all_entries.reserve(results.RowCount()); for (auto row = results.begin(); row != results.end(); ++row) { - Merchantlist entry{}; + Merchantlist e{}; - entry.merchantid = atoi(row[0]); - entry.slot = atoi(row[1]); - entry.item = atoi(row[2]); - entry.faction_required = atoi(row[3]); - entry.level_required = atoi(row[4]); - entry.alt_currency_cost = atoi(row[5]); - entry.classes_required = atoi(row[6]); - entry.probability = atoi(row[7]); - entry.min_expansion = atoi(row[8]); - entry.max_expansion = atoi(row[9]); - entry.content_flags = row[10] ? row[10] : ""; - entry.content_flags_disabled = row[11] ? row[11] : ""; + e.merchantid = atoi(row[0]); + e.slot = atoi(row[1]); + e.item = atoi(row[2]); + e.faction_required = atoi(row[3]); + e.level_required = atoi(row[4]); + e.alt_currency_cost = atoi(row[5]); + e.classes_required = atoi(row[6]); + e.probability = atoi(row[7]); + e.bucket_name = row[8] ? row[8] : ""; + e.bucket_value = row[9] ? row[9] : ""; + e.bucket_comparison = atoi(row[10]); + e.min_expansion = atoi(row[11]); + e.max_expansion = atoi(row[12]); + e.content_flags = row[13] ? row[13] : ""; + e.content_flags_disabled = row[14] ? row[14] : ""; - all_entries.push_back(entry); + all_entries.push_back(e); } return all_entries; } - static int DeleteWhere(Database& db, std::string where_filter) + static int DeleteWhere(Database& db, const std::string &where_filter) { auto results = db.QueryDatabase( fmt::format( @@ -402,6 +432,32 @@ public: 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); + } + }; #endif //EQEMU_BASE_MERCHANTLIST_REPOSITORY_H diff --git a/common/repositories/base/base_merchantlist_temp_repository.h b/common/repositories/base/base_merchantlist_temp_repository.h index c7c4b3848..c6e076ecc 100644 --- a/common/repositories/base/base_merchantlist_temp_repository.h +++ b/common/repositories/base/base_merchantlist_temp_repository.h @@ -21,6 +21,8 @@ public: struct MerchantlistTemp { int npcid; int slot; + int zone_id; + int instance_id; int itemid; int charges; }; @@ -35,6 +37,8 @@ public: return { "npcid", "slot", + "zone_id", + "instance_id", "itemid", "charges", }; @@ -45,6 +49,8 @@ public: return { "npcid", "slot", + "zone_id", + "instance_id", "itemid", "charges", }; @@ -85,17 +91,19 @@ public: static MerchantlistTemp NewEntity() { - MerchantlistTemp entry{}; + MerchantlistTemp e{}; - entry.npcid = 0; - entry.slot = 0; - entry.itemid = 0; - entry.charges = 1; + e.npcid = 0; + e.slot = 0; + e.zone_id = 0; + e.instance_id = 0; + e.itemid = 0; + e.charges = 1; - return entry; + return e; } - static MerchantlistTemp GetMerchantlistTempEntry( + static MerchantlistTemp GetMerchantlistTemp( const std::vector &merchantlist_temps, int merchantlist_temp_id ) @@ -124,14 +132,16 @@ public: auto row = results.begin(); if (results.RowCount() == 1) { - MerchantlistTemp entry{}; + MerchantlistTemp e{}; - entry.npcid = atoi(row[0]); - entry.slot = atoi(row[1]); - entry.itemid = atoi(row[2]); - entry.charges = atoi(row[3]); + e.npcid = atoi(row[0]); + e.slot = atoi(row[1]); + e.zone_id = atoi(row[2]); + e.instance_id = atoi(row[3]); + e.itemid = atoi(row[4]); + e.charges = atoi(row[5]); - return entry; + return e; } return NewEntity(); @@ -156,25 +166,27 @@ public: static int UpdateOne( Database& db, - MerchantlistTemp merchantlist_temp_entry + const MerchantlistTemp &e ) { - std::vector update_values; + std::vector v; auto columns = Columns(); - update_values.push_back(columns[0] + " = " + std::to_string(merchantlist_temp_entry.npcid)); - update_values.push_back(columns[1] + " = " + std::to_string(merchantlist_temp_entry.slot)); - update_values.push_back(columns[2] + " = " + std::to_string(merchantlist_temp_entry.itemid)); - update_values.push_back(columns[3] + " = " + std::to_string(merchantlist_temp_entry.charges)); + v.push_back(columns[0] + " = " + std::to_string(e.npcid)); + v.push_back(columns[1] + " = " + std::to_string(e.slot)); + v.push_back(columns[2] + " = " + std::to_string(e.zone_id)); + v.push_back(columns[3] + " = " + std::to_string(e.instance_id)); + v.push_back(columns[4] + " = " + std::to_string(e.itemid)); + v.push_back(columns[5] + " = " + std::to_string(e.charges)); auto results = db.QueryDatabase( fmt::format( "UPDATE {} SET {} WHERE {} = {}", TableName(), - Strings::Implode(", ", update_values), + Strings::Implode(", ", v), PrimaryKey(), - merchantlist_temp_entry.npcid + e.npcid ) ); @@ -183,53 +195,57 @@ public: static MerchantlistTemp InsertOne( Database& db, - MerchantlistTemp merchantlist_temp_entry + MerchantlistTemp e ) { - std::vector insert_values; + std::vector v; - insert_values.push_back(std::to_string(merchantlist_temp_entry.npcid)); - insert_values.push_back(std::to_string(merchantlist_temp_entry.slot)); - insert_values.push_back(std::to_string(merchantlist_temp_entry.itemid)); - insert_values.push_back(std::to_string(merchantlist_temp_entry.charges)); + v.push_back(std::to_string(e.npcid)); + v.push_back(std::to_string(e.slot)); + v.push_back(std::to_string(e.zone_id)); + v.push_back(std::to_string(e.instance_id)); + v.push_back(std::to_string(e.itemid)); + v.push_back(std::to_string(e.charges)); auto results = db.QueryDatabase( fmt::format( "{} VALUES ({})", BaseInsert(), - Strings::Implode(",", insert_values) + Strings::Implode(",", v) ) ); if (results.Success()) { - merchantlist_temp_entry.npcid = results.LastInsertedID(); - return merchantlist_temp_entry; + e.npcid = results.LastInsertedID(); + return e; } - merchantlist_temp_entry = NewEntity(); + e = NewEntity(); - return merchantlist_temp_entry; + return e; } static int InsertMany( Database& db, - std::vector merchantlist_temp_entries + const std::vector &entries ) { std::vector insert_chunks; - for (auto &merchantlist_temp_entry: merchantlist_temp_entries) { - std::vector insert_values; + for (auto &e: entries) { + std::vector v; - insert_values.push_back(std::to_string(merchantlist_temp_entry.npcid)); - insert_values.push_back(std::to_string(merchantlist_temp_entry.slot)); - insert_values.push_back(std::to_string(merchantlist_temp_entry.itemid)); - insert_values.push_back(std::to_string(merchantlist_temp_entry.charges)); + v.push_back(std::to_string(e.npcid)); + v.push_back(std::to_string(e.slot)); + v.push_back(std::to_string(e.zone_id)); + v.push_back(std::to_string(e.instance_id)); + v.push_back(std::to_string(e.itemid)); + v.push_back(std::to_string(e.charges)); - insert_chunks.push_back("(" + Strings::Implode(",", insert_values) + ")"); + insert_chunks.push_back("(" + Strings::Implode(",", v) + ")"); } - std::vector insert_values; + std::vector v; auto results = db.QueryDatabase( fmt::format( @@ -256,20 +272,22 @@ public: all_entries.reserve(results.RowCount()); for (auto row = results.begin(); row != results.end(); ++row) { - MerchantlistTemp entry{}; + MerchantlistTemp e{}; - entry.npcid = atoi(row[0]); - entry.slot = atoi(row[1]); - entry.itemid = atoi(row[2]); - entry.charges = atoi(row[3]); + e.npcid = atoi(row[0]); + e.slot = atoi(row[1]); + e.zone_id = atoi(row[2]); + e.instance_id = atoi(row[3]); + e.itemid = atoi(row[4]); + e.charges = atoi(row[5]); - all_entries.push_back(entry); + all_entries.push_back(e); } return all_entries; } - static std::vector GetWhere(Database& db, std::string where_filter) + static std::vector GetWhere(Database& db, const std::string &where_filter) { std::vector all_entries; @@ -284,20 +302,22 @@ public: all_entries.reserve(results.RowCount()); for (auto row = results.begin(); row != results.end(); ++row) { - MerchantlistTemp entry{}; + MerchantlistTemp e{}; - entry.npcid = atoi(row[0]); - entry.slot = atoi(row[1]); - entry.itemid = atoi(row[2]); - entry.charges = atoi(row[3]); + e.npcid = atoi(row[0]); + e.slot = atoi(row[1]); + e.zone_id = atoi(row[2]); + e.instance_id = atoi(row[3]); + e.itemid = atoi(row[4]); + e.charges = atoi(row[5]); - all_entries.push_back(entry); + all_entries.push_back(e); } return all_entries; } - static int DeleteWhere(Database& db, std::string where_filter) + static int DeleteWhere(Database& db, const std::string &where_filter) { auto results = db.QueryDatabase( fmt::format( @@ -322,6 +342,32 @@ public: 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); + } + }; #endif //EQEMU_BASE_MERCHANTLIST_TEMP_REPOSITORY_H diff --git a/common/repositories/base/base_name_filter_repository.h b/common/repositories/base/base_name_filter_repository.h index 605c8bc75..ae4c2327f 100644 --- a/common/repositories/base/base_name_filter_repository.h +++ b/common/repositories/base/base_name_filter_repository.h @@ -79,15 +79,15 @@ public: static NameFilter NewEntity() { - NameFilter entry{}; + NameFilter e{}; - entry.id = 0; - entry.name = ""; + e.id = 0; + e.name = ""; - return entry; + return e; } - static NameFilter GetNameFilterEntry( + static NameFilter GetNameFilter( const std::vector &name_filters, int name_filter_id ) @@ -116,12 +116,12 @@ public: auto row = results.begin(); if (results.RowCount() == 1) { - NameFilter entry{}; + NameFilter e{}; - entry.id = atoi(row[0]); - entry.name = row[1] ? row[1] : ""; + e.id = atoi(row[0]); + e.name = row[1] ? row[1] : ""; - return entry; + return e; } return NewEntity(); @@ -146,22 +146,22 @@ public: static int UpdateOne( Database& db, - NameFilter name_filter_entry + const NameFilter &e ) { - std::vector update_values; + std::vector v; auto columns = Columns(); - update_values.push_back(columns[1] + " = '" + Strings::Escape(name_filter_entry.name) + "'"); + v.push_back(columns[1] + " = '" + Strings::Escape(e.name) + "'"); auto results = db.QueryDatabase( fmt::format( "UPDATE {} SET {} WHERE {} = {}", TableName(), - Strings::Implode(", ", update_values), + Strings::Implode(", ", v), PrimaryKey(), - name_filter_entry.id + e.id ) ); @@ -170,49 +170,49 @@ public: static NameFilter InsertOne( Database& db, - NameFilter name_filter_entry + NameFilter e ) { - std::vector insert_values; + std::vector v; - insert_values.push_back(std::to_string(name_filter_entry.id)); - insert_values.push_back("'" + Strings::Escape(name_filter_entry.name) + "'"); + v.push_back(std::to_string(e.id)); + v.push_back("'" + Strings::Escape(e.name) + "'"); auto results = db.QueryDatabase( fmt::format( "{} VALUES ({})", BaseInsert(), - Strings::Implode(",", insert_values) + Strings::Implode(",", v) ) ); if (results.Success()) { - name_filter_entry.id = results.LastInsertedID(); - return name_filter_entry; + e.id = results.LastInsertedID(); + return e; } - name_filter_entry = NewEntity(); + e = NewEntity(); - return name_filter_entry; + return e; } static int InsertMany( Database& db, - std::vector name_filter_entries + const std::vector &entries ) { std::vector insert_chunks; - for (auto &name_filter_entry: name_filter_entries) { - std::vector insert_values; + for (auto &e: entries) { + std::vector v; - insert_values.push_back(std::to_string(name_filter_entry.id)); - insert_values.push_back("'" + Strings::Escape(name_filter_entry.name) + "'"); + v.push_back(std::to_string(e.id)); + v.push_back("'" + Strings::Escape(e.name) + "'"); - insert_chunks.push_back("(" + Strings::Implode(",", insert_values) + ")"); + insert_chunks.push_back("(" + Strings::Implode(",", v) + ")"); } - std::vector insert_values; + std::vector v; auto results = db.QueryDatabase( fmt::format( @@ -239,18 +239,18 @@ public: all_entries.reserve(results.RowCount()); for (auto row = results.begin(); row != results.end(); ++row) { - NameFilter entry{}; + NameFilter e{}; - entry.id = atoi(row[0]); - entry.name = row[1] ? row[1] : ""; + e.id = atoi(row[0]); + e.name = row[1] ? row[1] : ""; - all_entries.push_back(entry); + all_entries.push_back(e); } return all_entries; } - static std::vector GetWhere(Database& db, std::string where_filter) + static std::vector GetWhere(Database& db, const std::string &where_filter) { std::vector all_entries; @@ -265,18 +265,18 @@ public: all_entries.reserve(results.RowCount()); for (auto row = results.begin(); row != results.end(); ++row) { - NameFilter entry{}; + NameFilter e{}; - entry.id = atoi(row[0]); - entry.name = row[1] ? row[1] : ""; + e.id = atoi(row[0]); + e.name = row[1] ? row[1] : ""; - all_entries.push_back(entry); + all_entries.push_back(e); } return all_entries; } - static int DeleteWhere(Database& db, std::string where_filter) + static int DeleteWhere(Database& db, const std::string &where_filter) { auto results = db.QueryDatabase( fmt::format( @@ -301,6 +301,32 @@ public: 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); + } + }; #endif //EQEMU_BASE_NAME_FILTER_REPOSITORY_H diff --git a/common/repositories/base/base_npc_emotes_repository.h b/common/repositories/base/base_npc_emotes_repository.h index c3e5170f8..221f9d97b 100644 --- a/common/repositories/base/base_npc_emotes_repository.h +++ b/common/repositories/base/base_npc_emotes_repository.h @@ -88,18 +88,18 @@ public: static NpcEmotes NewEntity() { - NpcEmotes entry{}; + NpcEmotes e{}; - entry.id = 0; - entry.emoteid = 0; - entry.event_ = 0; - entry.type = 0; - entry.text = ""; + e.id = 0; + e.emoteid = 0; + e.event_ = 0; + e.type = 0; + e.text = ""; - return entry; + return e; } - static NpcEmotes GetNpcEmotesEntry( + static NpcEmotes GetNpcEmotes( const std::vector &npc_emotess, int npc_emotes_id ) @@ -128,15 +128,15 @@ public: auto row = results.begin(); if (results.RowCount() == 1) { - NpcEmotes entry{}; + NpcEmotes e{}; - entry.id = atoi(row[0]); - entry.emoteid = atoi(row[1]); - entry.event_ = atoi(row[2]); - entry.type = atoi(row[3]); - entry.text = row[4] ? row[4] : ""; + e.id = atoi(row[0]); + e.emoteid = atoi(row[1]); + e.event_ = atoi(row[2]); + e.type = atoi(row[3]); + e.text = row[4] ? row[4] : ""; - return entry; + return e; } return NewEntity(); @@ -161,25 +161,25 @@ public: static int UpdateOne( Database& db, - NpcEmotes npc_emotes_entry + const NpcEmotes &e ) { - std::vector update_values; + std::vector v; auto columns = Columns(); - update_values.push_back(columns[1] + " = " + std::to_string(npc_emotes_entry.emoteid)); - update_values.push_back(columns[2] + " = " + std::to_string(npc_emotes_entry.event_)); - update_values.push_back(columns[3] + " = " + std::to_string(npc_emotes_entry.type)); - update_values.push_back(columns[4] + " = '" + Strings::Escape(npc_emotes_entry.text) + "'"); + v.push_back(columns[1] + " = " + std::to_string(e.emoteid)); + v.push_back(columns[2] + " = " + std::to_string(e.event_)); + v.push_back(columns[3] + " = " + std::to_string(e.type)); + v.push_back(columns[4] + " = '" + Strings::Escape(e.text) + "'"); auto results = db.QueryDatabase( fmt::format( "UPDATE {} SET {} WHERE {} = {}", TableName(), - Strings::Implode(", ", update_values), + Strings::Implode(", ", v), PrimaryKey(), - npc_emotes_entry.id + e.id ) ); @@ -188,55 +188,55 @@ public: static NpcEmotes InsertOne( Database& db, - NpcEmotes npc_emotes_entry + NpcEmotes e ) { - std::vector insert_values; + std::vector v; - insert_values.push_back(std::to_string(npc_emotes_entry.id)); - insert_values.push_back(std::to_string(npc_emotes_entry.emoteid)); - insert_values.push_back(std::to_string(npc_emotes_entry.event_)); - insert_values.push_back(std::to_string(npc_emotes_entry.type)); - insert_values.push_back("'" + Strings::Escape(npc_emotes_entry.text) + "'"); + v.push_back(std::to_string(e.id)); + v.push_back(std::to_string(e.emoteid)); + v.push_back(std::to_string(e.event_)); + v.push_back(std::to_string(e.type)); + v.push_back("'" + Strings::Escape(e.text) + "'"); auto results = db.QueryDatabase( fmt::format( "{} VALUES ({})", BaseInsert(), - Strings::Implode(",", insert_values) + Strings::Implode(",", v) ) ); if (results.Success()) { - npc_emotes_entry.id = results.LastInsertedID(); - return npc_emotes_entry; + e.id = results.LastInsertedID(); + return e; } - npc_emotes_entry = NewEntity(); + e = NewEntity(); - return npc_emotes_entry; + return e; } static int InsertMany( Database& db, - std::vector npc_emotes_entries + const std::vector &entries ) { std::vector insert_chunks; - for (auto &npc_emotes_entry: npc_emotes_entries) { - std::vector insert_values; + for (auto &e: entries) { + std::vector v; - insert_values.push_back(std::to_string(npc_emotes_entry.id)); - insert_values.push_back(std::to_string(npc_emotes_entry.emoteid)); - insert_values.push_back(std::to_string(npc_emotes_entry.event_)); - insert_values.push_back(std::to_string(npc_emotes_entry.type)); - insert_values.push_back("'" + Strings::Escape(npc_emotes_entry.text) + "'"); + v.push_back(std::to_string(e.id)); + v.push_back(std::to_string(e.emoteid)); + v.push_back(std::to_string(e.event_)); + v.push_back(std::to_string(e.type)); + v.push_back("'" + Strings::Escape(e.text) + "'"); - insert_chunks.push_back("(" + Strings::Implode(",", insert_values) + ")"); + insert_chunks.push_back("(" + Strings::Implode(",", v) + ")"); } - std::vector insert_values; + std::vector v; auto results = db.QueryDatabase( fmt::format( @@ -263,21 +263,21 @@ public: all_entries.reserve(results.RowCount()); for (auto row = results.begin(); row != results.end(); ++row) { - NpcEmotes entry{}; + NpcEmotes e{}; - entry.id = atoi(row[0]); - entry.emoteid = atoi(row[1]); - entry.event_ = atoi(row[2]); - entry.type = atoi(row[3]); - entry.text = row[4] ? row[4] : ""; + e.id = atoi(row[0]); + e.emoteid = atoi(row[1]); + e.event_ = atoi(row[2]); + e.type = atoi(row[3]); + e.text = row[4] ? row[4] : ""; - all_entries.push_back(entry); + all_entries.push_back(e); } return all_entries; } - static std::vector GetWhere(Database& db, std::string where_filter) + static std::vector GetWhere(Database& db, const std::string &where_filter) { std::vector all_entries; @@ -292,21 +292,21 @@ public: all_entries.reserve(results.RowCount()); for (auto row = results.begin(); row != results.end(); ++row) { - NpcEmotes entry{}; + NpcEmotes e{}; - entry.id = atoi(row[0]); - entry.emoteid = atoi(row[1]); - entry.event_ = atoi(row[2]); - entry.type = atoi(row[3]); - entry.text = row[4] ? row[4] : ""; + e.id = atoi(row[0]); + e.emoteid = atoi(row[1]); + e.event_ = atoi(row[2]); + e.type = atoi(row[3]); + e.text = row[4] ? row[4] : ""; - all_entries.push_back(entry); + all_entries.push_back(e); } return all_entries; } - static int DeleteWhere(Database& db, std::string where_filter) + static int DeleteWhere(Database& db, const std::string &where_filter) { auto results = db.QueryDatabase( fmt::format( @@ -331,6 +331,32 @@ public: 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); + } + }; #endif //EQEMU_BASE_NPC_EMOTES_REPOSITORY_H diff --git a/common/repositories/base/base_npc_faction_entries_repository.h b/common/repositories/base/base_npc_faction_entries_repository.h index a3fe60e28..a3082bbc5 100644 --- a/common/repositories/base/base_npc_faction_entries_repository.h +++ b/common/repositories/base/base_npc_faction_entries_repository.h @@ -88,18 +88,18 @@ public: static NpcFactionEntries NewEntity() { - NpcFactionEntries entry{}; + NpcFactionEntries e{}; - entry.npc_faction_id = 0; - entry.faction_id = 0; - entry.value = 0; - entry.npc_value = 0; - entry.temp = 0; + e.npc_faction_id = 0; + e.faction_id = 0; + e.value = 0; + e.npc_value = 0; + e.temp = 0; - return entry; + return e; } - static NpcFactionEntries GetNpcFactionEntriesEntry( + static NpcFactionEntries GetNpcFactionEntries( const std::vector &npc_faction_entriess, int npc_faction_entries_id ) @@ -128,15 +128,15 @@ public: auto row = results.begin(); if (results.RowCount() == 1) { - NpcFactionEntries entry{}; + NpcFactionEntries e{}; - entry.npc_faction_id = atoi(row[0]); - entry.faction_id = atoi(row[1]); - entry.value = atoi(row[2]); - entry.npc_value = atoi(row[3]); - entry.temp = atoi(row[4]); + e.npc_faction_id = atoi(row[0]); + e.faction_id = atoi(row[1]); + e.value = atoi(row[2]); + e.npc_value = atoi(row[3]); + e.temp = atoi(row[4]); - return entry; + return e; } return NewEntity(); @@ -161,26 +161,26 @@ public: static int UpdateOne( Database& db, - NpcFactionEntries npc_faction_entries_entry + const NpcFactionEntries &e ) { - std::vector update_values; + std::vector v; auto columns = Columns(); - update_values.push_back(columns[0] + " = " + std::to_string(npc_faction_entries_entry.npc_faction_id)); - update_values.push_back(columns[1] + " = " + std::to_string(npc_faction_entries_entry.faction_id)); - update_values.push_back(columns[2] + " = " + std::to_string(npc_faction_entries_entry.value)); - update_values.push_back(columns[3] + " = " + std::to_string(npc_faction_entries_entry.npc_value)); - update_values.push_back(columns[4] + " = " + std::to_string(npc_faction_entries_entry.temp)); + v.push_back(columns[0] + " = " + std::to_string(e.npc_faction_id)); + v.push_back(columns[1] + " = " + std::to_string(e.faction_id)); + v.push_back(columns[2] + " = " + std::to_string(e.value)); + v.push_back(columns[3] + " = " + std::to_string(e.npc_value)); + v.push_back(columns[4] + " = " + std::to_string(e.temp)); auto results = db.QueryDatabase( fmt::format( "UPDATE {} SET {} WHERE {} = {}", TableName(), - Strings::Implode(", ", update_values), + Strings::Implode(", ", v), PrimaryKey(), - npc_faction_entries_entry.npc_faction_id + e.npc_faction_id ) ); @@ -189,55 +189,55 @@ public: static NpcFactionEntries InsertOne( Database& db, - NpcFactionEntries npc_faction_entries_entry + NpcFactionEntries e ) { - std::vector insert_values; + std::vector v; - insert_values.push_back(std::to_string(npc_faction_entries_entry.npc_faction_id)); - insert_values.push_back(std::to_string(npc_faction_entries_entry.faction_id)); - insert_values.push_back(std::to_string(npc_faction_entries_entry.value)); - insert_values.push_back(std::to_string(npc_faction_entries_entry.npc_value)); - insert_values.push_back(std::to_string(npc_faction_entries_entry.temp)); + v.push_back(std::to_string(e.npc_faction_id)); + v.push_back(std::to_string(e.faction_id)); + v.push_back(std::to_string(e.value)); + v.push_back(std::to_string(e.npc_value)); + v.push_back(std::to_string(e.temp)); auto results = db.QueryDatabase( fmt::format( "{} VALUES ({})", BaseInsert(), - Strings::Implode(",", insert_values) + Strings::Implode(",", v) ) ); if (results.Success()) { - npc_faction_entries_entry.npc_faction_id = results.LastInsertedID(); - return npc_faction_entries_entry; + e.npc_faction_id = results.LastInsertedID(); + return e; } - npc_faction_entries_entry = NewEntity(); + e = NewEntity(); - return npc_faction_entries_entry; + return e; } static int InsertMany( Database& db, - std::vector npc_faction_entries_entries + const std::vector &entries ) { std::vector insert_chunks; - for (auto &npc_faction_entries_entry: npc_faction_entries_entries) { - std::vector insert_values; + for (auto &e: entries) { + std::vector v; - insert_values.push_back(std::to_string(npc_faction_entries_entry.npc_faction_id)); - insert_values.push_back(std::to_string(npc_faction_entries_entry.faction_id)); - insert_values.push_back(std::to_string(npc_faction_entries_entry.value)); - insert_values.push_back(std::to_string(npc_faction_entries_entry.npc_value)); - insert_values.push_back(std::to_string(npc_faction_entries_entry.temp)); + v.push_back(std::to_string(e.npc_faction_id)); + v.push_back(std::to_string(e.faction_id)); + v.push_back(std::to_string(e.value)); + v.push_back(std::to_string(e.npc_value)); + v.push_back(std::to_string(e.temp)); - insert_chunks.push_back("(" + Strings::Implode(",", insert_values) + ")"); + insert_chunks.push_back("(" + Strings::Implode(",", v) + ")"); } - std::vector insert_values; + std::vector v; auto results = db.QueryDatabase( fmt::format( @@ -264,21 +264,21 @@ public: all_entries.reserve(results.RowCount()); for (auto row = results.begin(); row != results.end(); ++row) { - NpcFactionEntries entry{}; + NpcFactionEntries e{}; - entry.npc_faction_id = atoi(row[0]); - entry.faction_id = atoi(row[1]); - entry.value = atoi(row[2]); - entry.npc_value = atoi(row[3]); - entry.temp = atoi(row[4]); + e.npc_faction_id = atoi(row[0]); + e.faction_id = atoi(row[1]); + e.value = atoi(row[2]); + e.npc_value = atoi(row[3]); + e.temp = atoi(row[4]); - all_entries.push_back(entry); + all_entries.push_back(e); } return all_entries; } - static std::vector GetWhere(Database& db, std::string where_filter) + static std::vector GetWhere(Database& db, const std::string &where_filter) { std::vector all_entries; @@ -293,21 +293,21 @@ public: all_entries.reserve(results.RowCount()); for (auto row = results.begin(); row != results.end(); ++row) { - NpcFactionEntries entry{}; + NpcFactionEntries e{}; - entry.npc_faction_id = atoi(row[0]); - entry.faction_id = atoi(row[1]); - entry.value = atoi(row[2]); - entry.npc_value = atoi(row[3]); - entry.temp = atoi(row[4]); + e.npc_faction_id = atoi(row[0]); + e.faction_id = atoi(row[1]); + e.value = atoi(row[2]); + e.npc_value = atoi(row[3]); + e.temp = atoi(row[4]); - all_entries.push_back(entry); + all_entries.push_back(e); } return all_entries; } - static int DeleteWhere(Database& db, std::string where_filter) + static int DeleteWhere(Database& db, const std::string &where_filter) { auto results = db.QueryDatabase( fmt::format( @@ -332,6 +332,32 @@ public: 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); + } + }; #endif //EQEMU_BASE_NPC_FACTION_ENTRIES_REPOSITORY_H diff --git a/common/repositories/base/base_npc_faction_repository.h b/common/repositories/base/base_npc_faction_repository.h index 1979598f3..10036103e 100644 --- a/common/repositories/base/base_npc_faction_repository.h +++ b/common/repositories/base/base_npc_faction_repository.h @@ -85,17 +85,17 @@ public: static NpcFaction NewEntity() { - NpcFaction entry{}; + NpcFaction e{}; - entry.id = 0; - entry.name = ""; - entry.primaryfaction = 0; - entry.ignore_primary_assist = 0; + e.id = 0; + e.name = ""; + e.primaryfaction = 0; + e.ignore_primary_assist = 0; - return entry; + return e; } - static NpcFaction GetNpcFactionEntry( + static NpcFaction GetNpcFaction( const std::vector &npc_factions, int npc_faction_id ) @@ -124,14 +124,14 @@ public: auto row = results.begin(); if (results.RowCount() == 1) { - NpcFaction entry{}; + NpcFaction e{}; - entry.id = atoi(row[0]); - entry.name = row[1] ? row[1] : ""; - entry.primaryfaction = atoi(row[2]); - entry.ignore_primary_assist = atoi(row[3]); + e.id = atoi(row[0]); + e.name = row[1] ? row[1] : ""; + e.primaryfaction = atoi(row[2]); + e.ignore_primary_assist = atoi(row[3]); - return entry; + return e; } return NewEntity(); @@ -156,24 +156,24 @@ public: static int UpdateOne( Database& db, - NpcFaction npc_faction_entry + const NpcFaction &e ) { - std::vector update_values; + std::vector v; auto columns = Columns(); - update_values.push_back(columns[1] + " = '" + Strings::Escape(npc_faction_entry.name) + "'"); - update_values.push_back(columns[2] + " = " + std::to_string(npc_faction_entry.primaryfaction)); - update_values.push_back(columns[3] + " = " + std::to_string(npc_faction_entry.ignore_primary_assist)); + v.push_back(columns[1] + " = '" + Strings::Escape(e.name) + "'"); + v.push_back(columns[2] + " = " + std::to_string(e.primaryfaction)); + v.push_back(columns[3] + " = " + std::to_string(e.ignore_primary_assist)); auto results = db.QueryDatabase( fmt::format( "UPDATE {} SET {} WHERE {} = {}", TableName(), - Strings::Implode(", ", update_values), + Strings::Implode(", ", v), PrimaryKey(), - npc_faction_entry.id + e.id ) ); @@ -182,53 +182,53 @@ public: static NpcFaction InsertOne( Database& db, - NpcFaction npc_faction_entry + NpcFaction e ) { - std::vector insert_values; + std::vector v; - insert_values.push_back(std::to_string(npc_faction_entry.id)); - insert_values.push_back("'" + Strings::Escape(npc_faction_entry.name) + "'"); - insert_values.push_back(std::to_string(npc_faction_entry.primaryfaction)); - insert_values.push_back(std::to_string(npc_faction_entry.ignore_primary_assist)); + v.push_back(std::to_string(e.id)); + v.push_back("'" + Strings::Escape(e.name) + "'"); + v.push_back(std::to_string(e.primaryfaction)); + v.push_back(std::to_string(e.ignore_primary_assist)); auto results = db.QueryDatabase( fmt::format( "{} VALUES ({})", BaseInsert(), - Strings::Implode(",", insert_values) + Strings::Implode(",", v) ) ); if (results.Success()) { - npc_faction_entry.id = results.LastInsertedID(); - return npc_faction_entry; + e.id = results.LastInsertedID(); + return e; } - npc_faction_entry = NewEntity(); + e = NewEntity(); - return npc_faction_entry; + return e; } static int InsertMany( Database& db, - std::vector npc_faction_entries + const std::vector &entries ) { std::vector insert_chunks; - for (auto &npc_faction_entry: npc_faction_entries) { - std::vector insert_values; + for (auto &e: entries) { + std::vector v; - insert_values.push_back(std::to_string(npc_faction_entry.id)); - insert_values.push_back("'" + Strings::Escape(npc_faction_entry.name) + "'"); - insert_values.push_back(std::to_string(npc_faction_entry.primaryfaction)); - insert_values.push_back(std::to_string(npc_faction_entry.ignore_primary_assist)); + v.push_back(std::to_string(e.id)); + v.push_back("'" + Strings::Escape(e.name) + "'"); + v.push_back(std::to_string(e.primaryfaction)); + v.push_back(std::to_string(e.ignore_primary_assist)); - insert_chunks.push_back("(" + Strings::Implode(",", insert_values) + ")"); + insert_chunks.push_back("(" + Strings::Implode(",", v) + ")"); } - std::vector insert_values; + std::vector v; auto results = db.QueryDatabase( fmt::format( @@ -255,20 +255,20 @@ public: all_entries.reserve(results.RowCount()); for (auto row = results.begin(); row != results.end(); ++row) { - NpcFaction entry{}; + NpcFaction e{}; - entry.id = atoi(row[0]); - entry.name = row[1] ? row[1] : ""; - entry.primaryfaction = atoi(row[2]); - entry.ignore_primary_assist = atoi(row[3]); + e.id = atoi(row[0]); + e.name = row[1] ? row[1] : ""; + e.primaryfaction = atoi(row[2]); + e.ignore_primary_assist = atoi(row[3]); - all_entries.push_back(entry); + all_entries.push_back(e); } return all_entries; } - static std::vector GetWhere(Database& db, std::string where_filter) + static std::vector GetWhere(Database& db, const std::string &where_filter) { std::vector all_entries; @@ -283,20 +283,20 @@ public: all_entries.reserve(results.RowCount()); for (auto row = results.begin(); row != results.end(); ++row) { - NpcFaction entry{}; + NpcFaction e{}; - entry.id = atoi(row[0]); - entry.name = row[1] ? row[1] : ""; - entry.primaryfaction = atoi(row[2]); - entry.ignore_primary_assist = atoi(row[3]); + e.id = atoi(row[0]); + e.name = row[1] ? row[1] : ""; + e.primaryfaction = atoi(row[2]); + e.ignore_primary_assist = atoi(row[3]); - all_entries.push_back(entry); + all_entries.push_back(e); } return all_entries; } - static int DeleteWhere(Database& db, std::string where_filter) + static int DeleteWhere(Database& db, const std::string &where_filter) { auto results = db.QueryDatabase( fmt::format( @@ -321,6 +321,32 @@ public: 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); + } + }; #endif //EQEMU_BASE_NPC_FACTION_REPOSITORY_H diff --git a/common/repositories/base/base_npc_scale_global_base_repository.h b/common/repositories/base/base_npc_scale_global_base_repository.h index 521d9fbff..4cbc7c76b 100644 --- a/common/repositories/base/base_npc_scale_global_base_repository.h +++ b/common/repositories/base/base_npc_scale_global_base_repository.h @@ -157,41 +157,41 @@ public: static NpcScaleGlobalBase NewEntity() { - NpcScaleGlobalBase entry{}; + NpcScaleGlobalBase e{}; - entry.type = 0; - entry.level = 0; - entry.ac = 0; - entry.hp = 0; - entry.accuracy = 0; - entry.slow_mitigation = 0; - entry.attack = 0; - entry.strength = 0; - entry.stamina = 0; - entry.dexterity = 0; - entry.agility = 0; - entry.intelligence = 0; - entry.wisdom = 0; - entry.charisma = 0; - entry.magic_resist = 0; - entry.cold_resist = 0; - entry.fire_resist = 0; - entry.poison_resist = 0; - entry.disease_resist = 0; - entry.corruption_resist = 0; - entry.physical_resist = 0; - entry.min_dmg = 0; - entry.max_dmg = 0; - entry.hp_regen_rate = 0; - entry.attack_delay = 0; - entry.spell_scale = 100; - entry.heal_scale = 100; - entry.special_abilities = ""; + e.type = 0; + e.level = 0; + e.ac = 0; + e.hp = 0; + e.accuracy = 0; + e.slow_mitigation = 0; + e.attack = 0; + e.strength = 0; + e.stamina = 0; + e.dexterity = 0; + e.agility = 0; + e.intelligence = 0; + e.wisdom = 0; + e.charisma = 0; + e.magic_resist = 0; + e.cold_resist = 0; + e.fire_resist = 0; + e.poison_resist = 0; + e.disease_resist = 0; + e.corruption_resist = 0; + e.physical_resist = 0; + e.min_dmg = 0; + e.max_dmg = 0; + e.hp_regen_rate = 0; + e.attack_delay = 0; + e.spell_scale = 100; + e.heal_scale = 100; + e.special_abilities = ""; - return entry; + return e; } - static NpcScaleGlobalBase GetNpcScaleGlobalBaseEntry( + static NpcScaleGlobalBase GetNpcScaleGlobalBase( const std::vector &npc_scale_global_bases, int npc_scale_global_base_id ) @@ -220,38 +220,38 @@ public: auto row = results.begin(); if (results.RowCount() == 1) { - NpcScaleGlobalBase entry{}; + NpcScaleGlobalBase e{}; - entry.type = atoi(row[0]); - entry.level = atoi(row[1]); - entry.ac = atoi(row[2]); - entry.hp = atoi(row[3]); - entry.accuracy = atoi(row[4]); - entry.slow_mitigation = atoi(row[5]); - entry.attack = atoi(row[6]); - entry.strength = atoi(row[7]); - entry.stamina = atoi(row[8]); - entry.dexterity = atoi(row[9]); - entry.agility = atoi(row[10]); - entry.intelligence = atoi(row[11]); - entry.wisdom = atoi(row[12]); - entry.charisma = atoi(row[13]); - entry.magic_resist = atoi(row[14]); - entry.cold_resist = atoi(row[15]); - entry.fire_resist = atoi(row[16]); - entry.poison_resist = atoi(row[17]); - entry.disease_resist = atoi(row[18]); - entry.corruption_resist = atoi(row[19]); - entry.physical_resist = atoi(row[20]); - entry.min_dmg = atoi(row[21]); - entry.max_dmg = atoi(row[22]); - entry.hp_regen_rate = atoi(row[23]); - entry.attack_delay = atoi(row[24]); - entry.spell_scale = atoi(row[25]); - entry.heal_scale = atoi(row[26]); - entry.special_abilities = row[27] ? row[27] : ""; + e.type = atoi(row[0]); + e.level = atoi(row[1]); + e.ac = atoi(row[2]); + e.hp = atoi(row[3]); + e.accuracy = atoi(row[4]); + e.slow_mitigation = atoi(row[5]); + e.attack = atoi(row[6]); + e.strength = atoi(row[7]); + e.stamina = atoi(row[8]); + e.dexterity = atoi(row[9]); + e.agility = atoi(row[10]); + e.intelligence = atoi(row[11]); + e.wisdom = atoi(row[12]); + e.charisma = atoi(row[13]); + e.magic_resist = atoi(row[14]); + e.cold_resist = atoi(row[15]); + e.fire_resist = atoi(row[16]); + e.poison_resist = atoi(row[17]); + e.disease_resist = atoi(row[18]); + e.corruption_resist = atoi(row[19]); + e.physical_resist = atoi(row[20]); + e.min_dmg = atoi(row[21]); + e.max_dmg = atoi(row[22]); + e.hp_regen_rate = atoi(row[23]); + e.attack_delay = atoi(row[24]); + e.spell_scale = atoi(row[25]); + e.heal_scale = atoi(row[26]); + e.special_abilities = row[27] ? row[27] : ""; - return entry; + return e; } return NewEntity(); @@ -276,49 +276,49 @@ public: static int UpdateOne( Database& db, - NpcScaleGlobalBase npc_scale_global_base_entry + const NpcScaleGlobalBase &e ) { - std::vector update_values; + std::vector v; auto columns = Columns(); - update_values.push_back(columns[0] + " = " + std::to_string(npc_scale_global_base_entry.type)); - update_values.push_back(columns[1] + " = " + std::to_string(npc_scale_global_base_entry.level)); - update_values.push_back(columns[2] + " = " + std::to_string(npc_scale_global_base_entry.ac)); - update_values.push_back(columns[3] + " = " + std::to_string(npc_scale_global_base_entry.hp)); - update_values.push_back(columns[4] + " = " + std::to_string(npc_scale_global_base_entry.accuracy)); - update_values.push_back(columns[5] + " = " + std::to_string(npc_scale_global_base_entry.slow_mitigation)); - update_values.push_back(columns[6] + " = " + std::to_string(npc_scale_global_base_entry.attack)); - update_values.push_back(columns[7] + " = " + std::to_string(npc_scale_global_base_entry.strength)); - update_values.push_back(columns[8] + " = " + std::to_string(npc_scale_global_base_entry.stamina)); - update_values.push_back(columns[9] + " = " + std::to_string(npc_scale_global_base_entry.dexterity)); - update_values.push_back(columns[10] + " = " + std::to_string(npc_scale_global_base_entry.agility)); - update_values.push_back(columns[11] + " = " + std::to_string(npc_scale_global_base_entry.intelligence)); - update_values.push_back(columns[12] + " = " + std::to_string(npc_scale_global_base_entry.wisdom)); - update_values.push_back(columns[13] + " = " + std::to_string(npc_scale_global_base_entry.charisma)); - update_values.push_back(columns[14] + " = " + std::to_string(npc_scale_global_base_entry.magic_resist)); - update_values.push_back(columns[15] + " = " + std::to_string(npc_scale_global_base_entry.cold_resist)); - update_values.push_back(columns[16] + " = " + std::to_string(npc_scale_global_base_entry.fire_resist)); - update_values.push_back(columns[17] + " = " + std::to_string(npc_scale_global_base_entry.poison_resist)); - update_values.push_back(columns[18] + " = " + std::to_string(npc_scale_global_base_entry.disease_resist)); - update_values.push_back(columns[19] + " = " + std::to_string(npc_scale_global_base_entry.corruption_resist)); - update_values.push_back(columns[20] + " = " + std::to_string(npc_scale_global_base_entry.physical_resist)); - update_values.push_back(columns[21] + " = " + std::to_string(npc_scale_global_base_entry.min_dmg)); - update_values.push_back(columns[22] + " = " + std::to_string(npc_scale_global_base_entry.max_dmg)); - update_values.push_back(columns[23] + " = " + std::to_string(npc_scale_global_base_entry.hp_regen_rate)); - update_values.push_back(columns[24] + " = " + std::to_string(npc_scale_global_base_entry.attack_delay)); - update_values.push_back(columns[25] + " = " + std::to_string(npc_scale_global_base_entry.spell_scale)); - update_values.push_back(columns[26] + " = " + std::to_string(npc_scale_global_base_entry.heal_scale)); - update_values.push_back(columns[27] + " = '" + Strings::Escape(npc_scale_global_base_entry.special_abilities) + "'"); + v.push_back(columns[0] + " = " + std::to_string(e.type)); + v.push_back(columns[1] + " = " + std::to_string(e.level)); + v.push_back(columns[2] + " = " + std::to_string(e.ac)); + v.push_back(columns[3] + " = " + std::to_string(e.hp)); + v.push_back(columns[4] + " = " + std::to_string(e.accuracy)); + v.push_back(columns[5] + " = " + std::to_string(e.slow_mitigation)); + v.push_back(columns[6] + " = " + std::to_string(e.attack)); + v.push_back(columns[7] + " = " + std::to_string(e.strength)); + v.push_back(columns[8] + " = " + std::to_string(e.stamina)); + v.push_back(columns[9] + " = " + std::to_string(e.dexterity)); + v.push_back(columns[10] + " = " + std::to_string(e.agility)); + v.push_back(columns[11] + " = " + std::to_string(e.intelligence)); + v.push_back(columns[12] + " = " + std::to_string(e.wisdom)); + v.push_back(columns[13] + " = " + std::to_string(e.charisma)); + v.push_back(columns[14] + " = " + std::to_string(e.magic_resist)); + v.push_back(columns[15] + " = " + std::to_string(e.cold_resist)); + v.push_back(columns[16] + " = " + std::to_string(e.fire_resist)); + v.push_back(columns[17] + " = " + std::to_string(e.poison_resist)); + v.push_back(columns[18] + " = " + std::to_string(e.disease_resist)); + v.push_back(columns[19] + " = " + std::to_string(e.corruption_resist)); + v.push_back(columns[20] + " = " + std::to_string(e.physical_resist)); + v.push_back(columns[21] + " = " + std::to_string(e.min_dmg)); + v.push_back(columns[22] + " = " + std::to_string(e.max_dmg)); + v.push_back(columns[23] + " = " + std::to_string(e.hp_regen_rate)); + v.push_back(columns[24] + " = " + std::to_string(e.attack_delay)); + v.push_back(columns[25] + " = " + std::to_string(e.spell_scale)); + v.push_back(columns[26] + " = " + std::to_string(e.heal_scale)); + v.push_back(columns[27] + " = '" + Strings::Escape(e.special_abilities) + "'"); auto results = db.QueryDatabase( fmt::format( "UPDATE {} SET {} WHERE {} = {}", TableName(), - Strings::Implode(", ", update_values), + Strings::Implode(", ", v), PrimaryKey(), - npc_scale_global_base_entry.type + e.type ) ); @@ -327,101 +327,101 @@ public: static NpcScaleGlobalBase InsertOne( Database& db, - NpcScaleGlobalBase npc_scale_global_base_entry + NpcScaleGlobalBase e ) { - std::vector insert_values; + std::vector v; - insert_values.push_back(std::to_string(npc_scale_global_base_entry.type)); - insert_values.push_back(std::to_string(npc_scale_global_base_entry.level)); - insert_values.push_back(std::to_string(npc_scale_global_base_entry.ac)); - insert_values.push_back(std::to_string(npc_scale_global_base_entry.hp)); - insert_values.push_back(std::to_string(npc_scale_global_base_entry.accuracy)); - insert_values.push_back(std::to_string(npc_scale_global_base_entry.slow_mitigation)); - insert_values.push_back(std::to_string(npc_scale_global_base_entry.attack)); - insert_values.push_back(std::to_string(npc_scale_global_base_entry.strength)); - insert_values.push_back(std::to_string(npc_scale_global_base_entry.stamina)); - insert_values.push_back(std::to_string(npc_scale_global_base_entry.dexterity)); - insert_values.push_back(std::to_string(npc_scale_global_base_entry.agility)); - insert_values.push_back(std::to_string(npc_scale_global_base_entry.intelligence)); - insert_values.push_back(std::to_string(npc_scale_global_base_entry.wisdom)); - insert_values.push_back(std::to_string(npc_scale_global_base_entry.charisma)); - insert_values.push_back(std::to_string(npc_scale_global_base_entry.magic_resist)); - insert_values.push_back(std::to_string(npc_scale_global_base_entry.cold_resist)); - insert_values.push_back(std::to_string(npc_scale_global_base_entry.fire_resist)); - insert_values.push_back(std::to_string(npc_scale_global_base_entry.poison_resist)); - insert_values.push_back(std::to_string(npc_scale_global_base_entry.disease_resist)); - insert_values.push_back(std::to_string(npc_scale_global_base_entry.corruption_resist)); - insert_values.push_back(std::to_string(npc_scale_global_base_entry.physical_resist)); - insert_values.push_back(std::to_string(npc_scale_global_base_entry.min_dmg)); - insert_values.push_back(std::to_string(npc_scale_global_base_entry.max_dmg)); - insert_values.push_back(std::to_string(npc_scale_global_base_entry.hp_regen_rate)); - insert_values.push_back(std::to_string(npc_scale_global_base_entry.attack_delay)); - insert_values.push_back(std::to_string(npc_scale_global_base_entry.spell_scale)); - insert_values.push_back(std::to_string(npc_scale_global_base_entry.heal_scale)); - insert_values.push_back("'" + Strings::Escape(npc_scale_global_base_entry.special_abilities) + "'"); + v.push_back(std::to_string(e.type)); + v.push_back(std::to_string(e.level)); + v.push_back(std::to_string(e.ac)); + v.push_back(std::to_string(e.hp)); + v.push_back(std::to_string(e.accuracy)); + v.push_back(std::to_string(e.slow_mitigation)); + v.push_back(std::to_string(e.attack)); + v.push_back(std::to_string(e.strength)); + v.push_back(std::to_string(e.stamina)); + v.push_back(std::to_string(e.dexterity)); + v.push_back(std::to_string(e.agility)); + v.push_back(std::to_string(e.intelligence)); + v.push_back(std::to_string(e.wisdom)); + v.push_back(std::to_string(e.charisma)); + v.push_back(std::to_string(e.magic_resist)); + v.push_back(std::to_string(e.cold_resist)); + v.push_back(std::to_string(e.fire_resist)); + v.push_back(std::to_string(e.poison_resist)); + v.push_back(std::to_string(e.disease_resist)); + v.push_back(std::to_string(e.corruption_resist)); + v.push_back(std::to_string(e.physical_resist)); + v.push_back(std::to_string(e.min_dmg)); + v.push_back(std::to_string(e.max_dmg)); + v.push_back(std::to_string(e.hp_regen_rate)); + v.push_back(std::to_string(e.attack_delay)); + v.push_back(std::to_string(e.spell_scale)); + v.push_back(std::to_string(e.heal_scale)); + v.push_back("'" + Strings::Escape(e.special_abilities) + "'"); auto results = db.QueryDatabase( fmt::format( "{} VALUES ({})", BaseInsert(), - Strings::Implode(",", insert_values) + Strings::Implode(",", v) ) ); if (results.Success()) { - npc_scale_global_base_entry.type = results.LastInsertedID(); - return npc_scale_global_base_entry; + e.type = results.LastInsertedID(); + return e; } - npc_scale_global_base_entry = NewEntity(); + e = NewEntity(); - return npc_scale_global_base_entry; + return e; } static int InsertMany( Database& db, - std::vector npc_scale_global_base_entries + const std::vector &entries ) { std::vector insert_chunks; - for (auto &npc_scale_global_base_entry: npc_scale_global_base_entries) { - std::vector insert_values; + for (auto &e: entries) { + std::vector v; - insert_values.push_back(std::to_string(npc_scale_global_base_entry.type)); - insert_values.push_back(std::to_string(npc_scale_global_base_entry.level)); - insert_values.push_back(std::to_string(npc_scale_global_base_entry.ac)); - insert_values.push_back(std::to_string(npc_scale_global_base_entry.hp)); - insert_values.push_back(std::to_string(npc_scale_global_base_entry.accuracy)); - insert_values.push_back(std::to_string(npc_scale_global_base_entry.slow_mitigation)); - insert_values.push_back(std::to_string(npc_scale_global_base_entry.attack)); - insert_values.push_back(std::to_string(npc_scale_global_base_entry.strength)); - insert_values.push_back(std::to_string(npc_scale_global_base_entry.stamina)); - insert_values.push_back(std::to_string(npc_scale_global_base_entry.dexterity)); - insert_values.push_back(std::to_string(npc_scale_global_base_entry.agility)); - insert_values.push_back(std::to_string(npc_scale_global_base_entry.intelligence)); - insert_values.push_back(std::to_string(npc_scale_global_base_entry.wisdom)); - insert_values.push_back(std::to_string(npc_scale_global_base_entry.charisma)); - insert_values.push_back(std::to_string(npc_scale_global_base_entry.magic_resist)); - insert_values.push_back(std::to_string(npc_scale_global_base_entry.cold_resist)); - insert_values.push_back(std::to_string(npc_scale_global_base_entry.fire_resist)); - insert_values.push_back(std::to_string(npc_scale_global_base_entry.poison_resist)); - insert_values.push_back(std::to_string(npc_scale_global_base_entry.disease_resist)); - insert_values.push_back(std::to_string(npc_scale_global_base_entry.corruption_resist)); - insert_values.push_back(std::to_string(npc_scale_global_base_entry.physical_resist)); - insert_values.push_back(std::to_string(npc_scale_global_base_entry.min_dmg)); - insert_values.push_back(std::to_string(npc_scale_global_base_entry.max_dmg)); - insert_values.push_back(std::to_string(npc_scale_global_base_entry.hp_regen_rate)); - insert_values.push_back(std::to_string(npc_scale_global_base_entry.attack_delay)); - insert_values.push_back(std::to_string(npc_scale_global_base_entry.spell_scale)); - insert_values.push_back(std::to_string(npc_scale_global_base_entry.heal_scale)); - insert_values.push_back("'" + Strings::Escape(npc_scale_global_base_entry.special_abilities) + "'"); + v.push_back(std::to_string(e.type)); + v.push_back(std::to_string(e.level)); + v.push_back(std::to_string(e.ac)); + v.push_back(std::to_string(e.hp)); + v.push_back(std::to_string(e.accuracy)); + v.push_back(std::to_string(e.slow_mitigation)); + v.push_back(std::to_string(e.attack)); + v.push_back(std::to_string(e.strength)); + v.push_back(std::to_string(e.stamina)); + v.push_back(std::to_string(e.dexterity)); + v.push_back(std::to_string(e.agility)); + v.push_back(std::to_string(e.intelligence)); + v.push_back(std::to_string(e.wisdom)); + v.push_back(std::to_string(e.charisma)); + v.push_back(std::to_string(e.magic_resist)); + v.push_back(std::to_string(e.cold_resist)); + v.push_back(std::to_string(e.fire_resist)); + v.push_back(std::to_string(e.poison_resist)); + v.push_back(std::to_string(e.disease_resist)); + v.push_back(std::to_string(e.corruption_resist)); + v.push_back(std::to_string(e.physical_resist)); + v.push_back(std::to_string(e.min_dmg)); + v.push_back(std::to_string(e.max_dmg)); + v.push_back(std::to_string(e.hp_regen_rate)); + v.push_back(std::to_string(e.attack_delay)); + v.push_back(std::to_string(e.spell_scale)); + v.push_back(std::to_string(e.heal_scale)); + v.push_back("'" + Strings::Escape(e.special_abilities) + "'"); - insert_chunks.push_back("(" + Strings::Implode(",", insert_values) + ")"); + insert_chunks.push_back("(" + Strings::Implode(",", v) + ")"); } - std::vector insert_values; + std::vector v; auto results = db.QueryDatabase( fmt::format( @@ -448,44 +448,44 @@ public: all_entries.reserve(results.RowCount()); for (auto row = results.begin(); row != results.end(); ++row) { - NpcScaleGlobalBase entry{}; + NpcScaleGlobalBase e{}; - entry.type = atoi(row[0]); - entry.level = atoi(row[1]); - entry.ac = atoi(row[2]); - entry.hp = atoi(row[3]); - entry.accuracy = atoi(row[4]); - entry.slow_mitigation = atoi(row[5]); - entry.attack = atoi(row[6]); - entry.strength = atoi(row[7]); - entry.stamina = atoi(row[8]); - entry.dexterity = atoi(row[9]); - entry.agility = atoi(row[10]); - entry.intelligence = atoi(row[11]); - entry.wisdom = atoi(row[12]); - entry.charisma = atoi(row[13]); - entry.magic_resist = atoi(row[14]); - entry.cold_resist = atoi(row[15]); - entry.fire_resist = atoi(row[16]); - entry.poison_resist = atoi(row[17]); - entry.disease_resist = atoi(row[18]); - entry.corruption_resist = atoi(row[19]); - entry.physical_resist = atoi(row[20]); - entry.min_dmg = atoi(row[21]); - entry.max_dmg = atoi(row[22]); - entry.hp_regen_rate = atoi(row[23]); - entry.attack_delay = atoi(row[24]); - entry.spell_scale = atoi(row[25]); - entry.heal_scale = atoi(row[26]); - entry.special_abilities = row[27] ? row[27] : ""; + e.type = atoi(row[0]); + e.level = atoi(row[1]); + e.ac = atoi(row[2]); + e.hp = atoi(row[3]); + e.accuracy = atoi(row[4]); + e.slow_mitigation = atoi(row[5]); + e.attack = atoi(row[6]); + e.strength = atoi(row[7]); + e.stamina = atoi(row[8]); + e.dexterity = atoi(row[9]); + e.agility = atoi(row[10]); + e.intelligence = atoi(row[11]); + e.wisdom = atoi(row[12]); + e.charisma = atoi(row[13]); + e.magic_resist = atoi(row[14]); + e.cold_resist = atoi(row[15]); + e.fire_resist = atoi(row[16]); + e.poison_resist = atoi(row[17]); + e.disease_resist = atoi(row[18]); + e.corruption_resist = atoi(row[19]); + e.physical_resist = atoi(row[20]); + e.min_dmg = atoi(row[21]); + e.max_dmg = atoi(row[22]); + e.hp_regen_rate = atoi(row[23]); + e.attack_delay = atoi(row[24]); + e.spell_scale = atoi(row[25]); + e.heal_scale = atoi(row[26]); + e.special_abilities = row[27] ? row[27] : ""; - all_entries.push_back(entry); + all_entries.push_back(e); } return all_entries; } - static std::vector GetWhere(Database& db, std::string where_filter) + static std::vector GetWhere(Database& db, const std::string &where_filter) { std::vector all_entries; @@ -500,44 +500,44 @@ public: all_entries.reserve(results.RowCount()); for (auto row = results.begin(); row != results.end(); ++row) { - NpcScaleGlobalBase entry{}; + NpcScaleGlobalBase e{}; - entry.type = atoi(row[0]); - entry.level = atoi(row[1]); - entry.ac = atoi(row[2]); - entry.hp = atoi(row[3]); - entry.accuracy = atoi(row[4]); - entry.slow_mitigation = atoi(row[5]); - entry.attack = atoi(row[6]); - entry.strength = atoi(row[7]); - entry.stamina = atoi(row[8]); - entry.dexterity = atoi(row[9]); - entry.agility = atoi(row[10]); - entry.intelligence = atoi(row[11]); - entry.wisdom = atoi(row[12]); - entry.charisma = atoi(row[13]); - entry.magic_resist = atoi(row[14]); - entry.cold_resist = atoi(row[15]); - entry.fire_resist = atoi(row[16]); - entry.poison_resist = atoi(row[17]); - entry.disease_resist = atoi(row[18]); - entry.corruption_resist = atoi(row[19]); - entry.physical_resist = atoi(row[20]); - entry.min_dmg = atoi(row[21]); - entry.max_dmg = atoi(row[22]); - entry.hp_regen_rate = atoi(row[23]); - entry.attack_delay = atoi(row[24]); - entry.spell_scale = atoi(row[25]); - entry.heal_scale = atoi(row[26]); - entry.special_abilities = row[27] ? row[27] : ""; + e.type = atoi(row[0]); + e.level = atoi(row[1]); + e.ac = atoi(row[2]); + e.hp = atoi(row[3]); + e.accuracy = atoi(row[4]); + e.slow_mitigation = atoi(row[5]); + e.attack = atoi(row[6]); + e.strength = atoi(row[7]); + e.stamina = atoi(row[8]); + e.dexterity = atoi(row[9]); + e.agility = atoi(row[10]); + e.intelligence = atoi(row[11]); + e.wisdom = atoi(row[12]); + e.charisma = atoi(row[13]); + e.magic_resist = atoi(row[14]); + e.cold_resist = atoi(row[15]); + e.fire_resist = atoi(row[16]); + e.poison_resist = atoi(row[17]); + e.disease_resist = atoi(row[18]); + e.corruption_resist = atoi(row[19]); + e.physical_resist = atoi(row[20]); + e.min_dmg = atoi(row[21]); + e.max_dmg = atoi(row[22]); + e.hp_regen_rate = atoi(row[23]); + e.attack_delay = atoi(row[24]); + e.spell_scale = atoi(row[25]); + e.heal_scale = atoi(row[26]); + e.special_abilities = row[27] ? row[27] : ""; - all_entries.push_back(entry); + all_entries.push_back(e); } return all_entries; } - static int DeleteWhere(Database& db, std::string where_filter) + static int DeleteWhere(Database& db, const std::string &where_filter) { auto results = db.QueryDatabase( fmt::format( @@ -562,6 +562,32 @@ public: 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); + } + }; #endif //EQEMU_BASE_NPC_SCALE_GLOBAL_BASE_REPOSITORY_H diff --git a/common/repositories/base/base_npc_spells_effects_entries_repository.h b/common/repositories/base/base_npc_spells_effects_entries_repository.h index e84555876..13909f0eb 100644 --- a/common/repositories/base/base_npc_spells_effects_entries_repository.h +++ b/common/repositories/base/base_npc_spells_effects_entries_repository.h @@ -97,21 +97,21 @@ public: static NpcSpellsEffectsEntries NewEntity() { - NpcSpellsEffectsEntries entry{}; + NpcSpellsEffectsEntries e{}; - entry.id = 0; - entry.npc_spells_effects_id = 0; - entry.spell_effect_id = 0; - entry.minlevel = 0; - entry.maxlevel = 255; - entry.se_base = 0; - entry.se_limit = 0; - entry.se_max = 0; + e.id = 0; + e.npc_spells_effects_id = 0; + e.spell_effect_id = 0; + e.minlevel = 0; + e.maxlevel = 255; + e.se_base = 0; + e.se_limit = 0; + e.se_max = 0; - return entry; + return e; } - static NpcSpellsEffectsEntries GetNpcSpellsEffectsEntriesEntry( + static NpcSpellsEffectsEntries GetNpcSpellsEffectsEntries( const std::vector &npc_spells_effects_entriess, int npc_spells_effects_entries_id ) @@ -140,18 +140,18 @@ public: auto row = results.begin(); if (results.RowCount() == 1) { - NpcSpellsEffectsEntries entry{}; + NpcSpellsEffectsEntries e{}; - entry.id = atoi(row[0]); - entry.npc_spells_effects_id = atoi(row[1]); - entry.spell_effect_id = atoi(row[2]); - entry.minlevel = atoi(row[3]); - entry.maxlevel = atoi(row[4]); - entry.se_base = atoi(row[5]); - entry.se_limit = atoi(row[6]); - entry.se_max = atoi(row[7]); + e.id = atoi(row[0]); + e.npc_spells_effects_id = atoi(row[1]); + e.spell_effect_id = atoi(row[2]); + e.minlevel = atoi(row[3]); + e.maxlevel = atoi(row[4]); + e.se_base = atoi(row[5]); + e.se_limit = atoi(row[6]); + e.se_max = atoi(row[7]); - return entry; + return e; } return NewEntity(); @@ -176,28 +176,28 @@ public: static int UpdateOne( Database& db, - NpcSpellsEffectsEntries npc_spells_effects_entries_entry + const NpcSpellsEffectsEntries &e ) { - std::vector update_values; + std::vector v; auto columns = Columns(); - update_values.push_back(columns[1] + " = " + std::to_string(npc_spells_effects_entries_entry.npc_spells_effects_id)); - update_values.push_back(columns[2] + " = " + std::to_string(npc_spells_effects_entries_entry.spell_effect_id)); - update_values.push_back(columns[3] + " = " + std::to_string(npc_spells_effects_entries_entry.minlevel)); - update_values.push_back(columns[4] + " = " + std::to_string(npc_spells_effects_entries_entry.maxlevel)); - update_values.push_back(columns[5] + " = " + std::to_string(npc_spells_effects_entries_entry.se_base)); - update_values.push_back(columns[6] + " = " + std::to_string(npc_spells_effects_entries_entry.se_limit)); - update_values.push_back(columns[7] + " = " + std::to_string(npc_spells_effects_entries_entry.se_max)); + v.push_back(columns[1] + " = " + std::to_string(e.npc_spells_effects_id)); + v.push_back(columns[2] + " = " + std::to_string(e.spell_effect_id)); + v.push_back(columns[3] + " = " + std::to_string(e.minlevel)); + v.push_back(columns[4] + " = " + std::to_string(e.maxlevel)); + v.push_back(columns[5] + " = " + std::to_string(e.se_base)); + v.push_back(columns[6] + " = " + std::to_string(e.se_limit)); + v.push_back(columns[7] + " = " + std::to_string(e.se_max)); auto results = db.QueryDatabase( fmt::format( "UPDATE {} SET {} WHERE {} = {}", TableName(), - Strings::Implode(", ", update_values), + Strings::Implode(", ", v), PrimaryKey(), - npc_spells_effects_entries_entry.id + e.id ) ); @@ -206,61 +206,61 @@ public: static NpcSpellsEffectsEntries InsertOne( Database& db, - NpcSpellsEffectsEntries npc_spells_effects_entries_entry + NpcSpellsEffectsEntries e ) { - std::vector insert_values; + std::vector v; - insert_values.push_back(std::to_string(npc_spells_effects_entries_entry.id)); - insert_values.push_back(std::to_string(npc_spells_effects_entries_entry.npc_spells_effects_id)); - insert_values.push_back(std::to_string(npc_spells_effects_entries_entry.spell_effect_id)); - insert_values.push_back(std::to_string(npc_spells_effects_entries_entry.minlevel)); - insert_values.push_back(std::to_string(npc_spells_effects_entries_entry.maxlevel)); - insert_values.push_back(std::to_string(npc_spells_effects_entries_entry.se_base)); - insert_values.push_back(std::to_string(npc_spells_effects_entries_entry.se_limit)); - insert_values.push_back(std::to_string(npc_spells_effects_entries_entry.se_max)); + v.push_back(std::to_string(e.id)); + v.push_back(std::to_string(e.npc_spells_effects_id)); + v.push_back(std::to_string(e.spell_effect_id)); + v.push_back(std::to_string(e.minlevel)); + v.push_back(std::to_string(e.maxlevel)); + v.push_back(std::to_string(e.se_base)); + v.push_back(std::to_string(e.se_limit)); + v.push_back(std::to_string(e.se_max)); auto results = db.QueryDatabase( fmt::format( "{} VALUES ({})", BaseInsert(), - Strings::Implode(",", insert_values) + Strings::Implode(",", v) ) ); if (results.Success()) { - npc_spells_effects_entries_entry.id = results.LastInsertedID(); - return npc_spells_effects_entries_entry; + e.id = results.LastInsertedID(); + return e; } - npc_spells_effects_entries_entry = NewEntity(); + e = NewEntity(); - return npc_spells_effects_entries_entry; + return e; } static int InsertMany( Database& db, - std::vector npc_spells_effects_entries_entries + const std::vector &entries ) { std::vector insert_chunks; - for (auto &npc_spells_effects_entries_entry: npc_spells_effects_entries_entries) { - std::vector insert_values; + for (auto &e: entries) { + std::vector v; - insert_values.push_back(std::to_string(npc_spells_effects_entries_entry.id)); - insert_values.push_back(std::to_string(npc_spells_effects_entries_entry.npc_spells_effects_id)); - insert_values.push_back(std::to_string(npc_spells_effects_entries_entry.spell_effect_id)); - insert_values.push_back(std::to_string(npc_spells_effects_entries_entry.minlevel)); - insert_values.push_back(std::to_string(npc_spells_effects_entries_entry.maxlevel)); - insert_values.push_back(std::to_string(npc_spells_effects_entries_entry.se_base)); - insert_values.push_back(std::to_string(npc_spells_effects_entries_entry.se_limit)); - insert_values.push_back(std::to_string(npc_spells_effects_entries_entry.se_max)); + v.push_back(std::to_string(e.id)); + v.push_back(std::to_string(e.npc_spells_effects_id)); + v.push_back(std::to_string(e.spell_effect_id)); + v.push_back(std::to_string(e.minlevel)); + v.push_back(std::to_string(e.maxlevel)); + v.push_back(std::to_string(e.se_base)); + v.push_back(std::to_string(e.se_limit)); + v.push_back(std::to_string(e.se_max)); - insert_chunks.push_back("(" + Strings::Implode(",", insert_values) + ")"); + insert_chunks.push_back("(" + Strings::Implode(",", v) + ")"); } - std::vector insert_values; + std::vector v; auto results = db.QueryDatabase( fmt::format( @@ -287,24 +287,24 @@ public: all_entries.reserve(results.RowCount()); for (auto row = results.begin(); row != results.end(); ++row) { - NpcSpellsEffectsEntries entry{}; + NpcSpellsEffectsEntries e{}; - entry.id = atoi(row[0]); - entry.npc_spells_effects_id = atoi(row[1]); - entry.spell_effect_id = atoi(row[2]); - entry.minlevel = atoi(row[3]); - entry.maxlevel = atoi(row[4]); - entry.se_base = atoi(row[5]); - entry.se_limit = atoi(row[6]); - entry.se_max = atoi(row[7]); + e.id = atoi(row[0]); + e.npc_spells_effects_id = atoi(row[1]); + e.spell_effect_id = atoi(row[2]); + e.minlevel = atoi(row[3]); + e.maxlevel = atoi(row[4]); + e.se_base = atoi(row[5]); + e.se_limit = atoi(row[6]); + e.se_max = atoi(row[7]); - all_entries.push_back(entry); + all_entries.push_back(e); } return all_entries; } - static std::vector GetWhere(Database& db, std::string where_filter) + static std::vector GetWhere(Database& db, const std::string &where_filter) { std::vector all_entries; @@ -319,24 +319,24 @@ public: all_entries.reserve(results.RowCount()); for (auto row = results.begin(); row != results.end(); ++row) { - NpcSpellsEffectsEntries entry{}; + NpcSpellsEffectsEntries e{}; - entry.id = atoi(row[0]); - entry.npc_spells_effects_id = atoi(row[1]); - entry.spell_effect_id = atoi(row[2]); - entry.minlevel = atoi(row[3]); - entry.maxlevel = atoi(row[4]); - entry.se_base = atoi(row[5]); - entry.se_limit = atoi(row[6]); - entry.se_max = atoi(row[7]); + e.id = atoi(row[0]); + e.npc_spells_effects_id = atoi(row[1]); + e.spell_effect_id = atoi(row[2]); + e.minlevel = atoi(row[3]); + e.maxlevel = atoi(row[4]); + e.se_base = atoi(row[5]); + e.se_limit = atoi(row[6]); + e.se_max = atoi(row[7]); - all_entries.push_back(entry); + all_entries.push_back(e); } return all_entries; } - static int DeleteWhere(Database& db, std::string where_filter) + static int DeleteWhere(Database& db, const std::string &where_filter) { auto results = db.QueryDatabase( fmt::format( @@ -361,6 +361,32 @@ public: 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); + } + }; #endif //EQEMU_BASE_NPC_SPELLS_EFFECTS_ENTRIES_REPOSITORY_H diff --git a/common/repositories/base/base_npc_spells_effects_repository.h b/common/repositories/base/base_npc_spells_effects_repository.h index afa048ab0..319835d5c 100644 --- a/common/repositories/base/base_npc_spells_effects_repository.h +++ b/common/repositories/base/base_npc_spells_effects_repository.h @@ -82,16 +82,16 @@ public: static NpcSpellsEffects NewEntity() { - NpcSpellsEffects entry{}; + NpcSpellsEffects e{}; - entry.id = 0; - entry.name = ""; - entry.parent_list = 0; + e.id = 0; + e.name = ""; + e.parent_list = 0; - return entry; + return e; } - static NpcSpellsEffects GetNpcSpellsEffectsEntry( + static NpcSpellsEffects GetNpcSpellsEffects( const std::vector &npc_spells_effectss, int npc_spells_effects_id ) @@ -120,13 +120,13 @@ public: auto row = results.begin(); if (results.RowCount() == 1) { - NpcSpellsEffects entry{}; + NpcSpellsEffects e{}; - entry.id = atoi(row[0]); - entry.name = row[1] ? row[1] : ""; - entry.parent_list = atoi(row[2]); + e.id = atoi(row[0]); + e.name = row[1] ? row[1] : ""; + e.parent_list = atoi(row[2]); - return entry; + return e; } return NewEntity(); @@ -151,23 +151,23 @@ public: static int UpdateOne( Database& db, - NpcSpellsEffects npc_spells_effects_entry + const NpcSpellsEffects &e ) { - std::vector update_values; + std::vector v; auto columns = Columns(); - update_values.push_back(columns[1] + " = '" + Strings::Escape(npc_spells_effects_entry.name) + "'"); - update_values.push_back(columns[2] + " = " + std::to_string(npc_spells_effects_entry.parent_list)); + v.push_back(columns[1] + " = '" + Strings::Escape(e.name) + "'"); + v.push_back(columns[2] + " = " + std::to_string(e.parent_list)); auto results = db.QueryDatabase( fmt::format( "UPDATE {} SET {} WHERE {} = {}", TableName(), - Strings::Implode(", ", update_values), + Strings::Implode(", ", v), PrimaryKey(), - npc_spells_effects_entry.id + e.id ) ); @@ -176,51 +176,51 @@ public: static NpcSpellsEffects InsertOne( Database& db, - NpcSpellsEffects npc_spells_effects_entry + NpcSpellsEffects e ) { - std::vector insert_values; + std::vector v; - insert_values.push_back(std::to_string(npc_spells_effects_entry.id)); - insert_values.push_back("'" + Strings::Escape(npc_spells_effects_entry.name) + "'"); - insert_values.push_back(std::to_string(npc_spells_effects_entry.parent_list)); + v.push_back(std::to_string(e.id)); + v.push_back("'" + Strings::Escape(e.name) + "'"); + v.push_back(std::to_string(e.parent_list)); auto results = db.QueryDatabase( fmt::format( "{} VALUES ({})", BaseInsert(), - Strings::Implode(",", insert_values) + Strings::Implode(",", v) ) ); if (results.Success()) { - npc_spells_effects_entry.id = results.LastInsertedID(); - return npc_spells_effects_entry; + e.id = results.LastInsertedID(); + return e; } - npc_spells_effects_entry = NewEntity(); + e = NewEntity(); - return npc_spells_effects_entry; + return e; } static int InsertMany( Database& db, - std::vector npc_spells_effects_entries + const std::vector &entries ) { std::vector insert_chunks; - for (auto &npc_spells_effects_entry: npc_spells_effects_entries) { - std::vector insert_values; + for (auto &e: entries) { + std::vector v; - insert_values.push_back(std::to_string(npc_spells_effects_entry.id)); - insert_values.push_back("'" + Strings::Escape(npc_spells_effects_entry.name) + "'"); - insert_values.push_back(std::to_string(npc_spells_effects_entry.parent_list)); + v.push_back(std::to_string(e.id)); + v.push_back("'" + Strings::Escape(e.name) + "'"); + v.push_back(std::to_string(e.parent_list)); - insert_chunks.push_back("(" + Strings::Implode(",", insert_values) + ")"); + insert_chunks.push_back("(" + Strings::Implode(",", v) + ")"); } - std::vector insert_values; + std::vector v; auto results = db.QueryDatabase( fmt::format( @@ -247,19 +247,19 @@ public: all_entries.reserve(results.RowCount()); for (auto row = results.begin(); row != results.end(); ++row) { - NpcSpellsEffects entry{}; + NpcSpellsEffects e{}; - entry.id = atoi(row[0]); - entry.name = row[1] ? row[1] : ""; - entry.parent_list = atoi(row[2]); + e.id = atoi(row[0]); + e.name = row[1] ? row[1] : ""; + e.parent_list = atoi(row[2]); - all_entries.push_back(entry); + all_entries.push_back(e); } return all_entries; } - static std::vector GetWhere(Database& db, std::string where_filter) + static std::vector GetWhere(Database& db, const std::string &where_filter) { std::vector all_entries; @@ -274,19 +274,19 @@ public: all_entries.reserve(results.RowCount()); for (auto row = results.begin(); row != results.end(); ++row) { - NpcSpellsEffects entry{}; + NpcSpellsEffects e{}; - entry.id = atoi(row[0]); - entry.name = row[1] ? row[1] : ""; - entry.parent_list = atoi(row[2]); + e.id = atoi(row[0]); + e.name = row[1] ? row[1] : ""; + e.parent_list = atoi(row[2]); - all_entries.push_back(entry); + all_entries.push_back(e); } return all_entries; } - static int DeleteWhere(Database& db, std::string where_filter) + static int DeleteWhere(Database& db, const std::string &where_filter) { auto results = db.QueryDatabase( fmt::format( @@ -311,6 +311,32 @@ public: 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); + } + }; #endif //EQEMU_BASE_NPC_SPELLS_EFFECTS_REPOSITORY_H diff --git a/common/repositories/base/base_npc_spells_entries_repository.h b/common/repositories/base/base_npc_spells_entries_repository.h index 655d69cb3..01fea395c 100644 --- a/common/repositories/base/base_npc_spells_entries_repository.h +++ b/common/repositories/base/base_npc_spells_entries_repository.h @@ -109,25 +109,25 @@ public: static NpcSpellsEntries NewEntity() { - NpcSpellsEntries entry{}; + NpcSpellsEntries e{}; - entry.id = 0; - entry.npc_spells_id = 0; - entry.spellid = 0; - entry.type = 0; - entry.minlevel = 0; - entry.maxlevel = 255; - entry.manacost = -1; - entry.recast_delay = -1; - entry.priority = 0; - entry.resist_adjust = 0; - entry.min_hp = 0; - entry.max_hp = 0; + e.id = 0; + e.npc_spells_id = 0; + e.spellid = 0; + e.type = 0; + e.minlevel = 0; + e.maxlevel = 255; + e.manacost = -1; + e.recast_delay = -1; + e.priority = 0; + e.resist_adjust = 0; + e.min_hp = 0; + e.max_hp = 0; - return entry; + return e; } - static NpcSpellsEntries GetNpcSpellsEntriesEntry( + static NpcSpellsEntries GetNpcSpellsEntries( const std::vector &npc_spells_entriess, int npc_spells_entries_id ) @@ -156,22 +156,22 @@ public: auto row = results.begin(); if (results.RowCount() == 1) { - NpcSpellsEntries entry{}; + NpcSpellsEntries e{}; - entry.id = atoi(row[0]); - entry.npc_spells_id = atoi(row[1]); - entry.spellid = atoi(row[2]); - entry.type = atoi(row[3]); - entry.minlevel = atoi(row[4]); - entry.maxlevel = atoi(row[5]); - entry.manacost = atoi(row[6]); - entry.recast_delay = atoi(row[7]); - entry.priority = atoi(row[8]); - entry.resist_adjust = atoi(row[9]); - entry.min_hp = atoi(row[10]); - entry.max_hp = atoi(row[11]); + e.id = atoi(row[0]); + e.npc_spells_id = atoi(row[1]); + e.spellid = atoi(row[2]); + e.type = atoi(row[3]); + e.minlevel = atoi(row[4]); + e.maxlevel = atoi(row[5]); + e.manacost = atoi(row[6]); + e.recast_delay = atoi(row[7]); + e.priority = atoi(row[8]); + e.resist_adjust = atoi(row[9]); + e.min_hp = atoi(row[10]); + e.max_hp = atoi(row[11]); - return entry; + return e; } return NewEntity(); @@ -196,32 +196,32 @@ public: static int UpdateOne( Database& db, - NpcSpellsEntries npc_spells_entries_entry + const NpcSpellsEntries &e ) { - std::vector update_values; + std::vector v; auto columns = Columns(); - update_values.push_back(columns[1] + " = " + std::to_string(npc_spells_entries_entry.npc_spells_id)); - update_values.push_back(columns[2] + " = " + std::to_string(npc_spells_entries_entry.spellid)); - update_values.push_back(columns[3] + " = " + std::to_string(npc_spells_entries_entry.type)); - update_values.push_back(columns[4] + " = " + std::to_string(npc_spells_entries_entry.minlevel)); - update_values.push_back(columns[5] + " = " + std::to_string(npc_spells_entries_entry.maxlevel)); - update_values.push_back(columns[6] + " = " + std::to_string(npc_spells_entries_entry.manacost)); - update_values.push_back(columns[7] + " = " + std::to_string(npc_spells_entries_entry.recast_delay)); - update_values.push_back(columns[8] + " = " + std::to_string(npc_spells_entries_entry.priority)); - update_values.push_back(columns[9] + " = " + std::to_string(npc_spells_entries_entry.resist_adjust)); - update_values.push_back(columns[10] + " = " + std::to_string(npc_spells_entries_entry.min_hp)); - update_values.push_back(columns[11] + " = " + std::to_string(npc_spells_entries_entry.max_hp)); + v.push_back(columns[1] + " = " + std::to_string(e.npc_spells_id)); + v.push_back(columns[2] + " = " + std::to_string(e.spellid)); + v.push_back(columns[3] + " = " + std::to_string(e.type)); + v.push_back(columns[4] + " = " + std::to_string(e.minlevel)); + v.push_back(columns[5] + " = " + std::to_string(e.maxlevel)); + v.push_back(columns[6] + " = " + std::to_string(e.manacost)); + v.push_back(columns[7] + " = " + std::to_string(e.recast_delay)); + v.push_back(columns[8] + " = " + std::to_string(e.priority)); + v.push_back(columns[9] + " = " + std::to_string(e.resist_adjust)); + v.push_back(columns[10] + " = " + std::to_string(e.min_hp)); + v.push_back(columns[11] + " = " + std::to_string(e.max_hp)); auto results = db.QueryDatabase( fmt::format( "UPDATE {} SET {} WHERE {} = {}", TableName(), - Strings::Implode(", ", update_values), + Strings::Implode(", ", v), PrimaryKey(), - npc_spells_entries_entry.id + e.id ) ); @@ -230,69 +230,69 @@ public: static NpcSpellsEntries InsertOne( Database& db, - NpcSpellsEntries npc_spells_entries_entry + NpcSpellsEntries e ) { - std::vector insert_values; + std::vector v; - insert_values.push_back(std::to_string(npc_spells_entries_entry.id)); - insert_values.push_back(std::to_string(npc_spells_entries_entry.npc_spells_id)); - insert_values.push_back(std::to_string(npc_spells_entries_entry.spellid)); - insert_values.push_back(std::to_string(npc_spells_entries_entry.type)); - insert_values.push_back(std::to_string(npc_spells_entries_entry.minlevel)); - insert_values.push_back(std::to_string(npc_spells_entries_entry.maxlevel)); - insert_values.push_back(std::to_string(npc_spells_entries_entry.manacost)); - insert_values.push_back(std::to_string(npc_spells_entries_entry.recast_delay)); - insert_values.push_back(std::to_string(npc_spells_entries_entry.priority)); - insert_values.push_back(std::to_string(npc_spells_entries_entry.resist_adjust)); - insert_values.push_back(std::to_string(npc_spells_entries_entry.min_hp)); - insert_values.push_back(std::to_string(npc_spells_entries_entry.max_hp)); + v.push_back(std::to_string(e.id)); + v.push_back(std::to_string(e.npc_spells_id)); + v.push_back(std::to_string(e.spellid)); + v.push_back(std::to_string(e.type)); + v.push_back(std::to_string(e.minlevel)); + v.push_back(std::to_string(e.maxlevel)); + v.push_back(std::to_string(e.manacost)); + v.push_back(std::to_string(e.recast_delay)); + v.push_back(std::to_string(e.priority)); + v.push_back(std::to_string(e.resist_adjust)); + v.push_back(std::to_string(e.min_hp)); + v.push_back(std::to_string(e.max_hp)); auto results = db.QueryDatabase( fmt::format( "{} VALUES ({})", BaseInsert(), - Strings::Implode(",", insert_values) + Strings::Implode(",", v) ) ); if (results.Success()) { - npc_spells_entries_entry.id = results.LastInsertedID(); - return npc_spells_entries_entry; + e.id = results.LastInsertedID(); + return e; } - npc_spells_entries_entry = NewEntity(); + e = NewEntity(); - return npc_spells_entries_entry; + return e; } static int InsertMany( Database& db, - std::vector npc_spells_entries_entries + const std::vector &entries ) { std::vector insert_chunks; - for (auto &npc_spells_entries_entry: npc_spells_entries_entries) { - std::vector insert_values; + for (auto &e: entries) { + std::vector v; - insert_values.push_back(std::to_string(npc_spells_entries_entry.id)); - insert_values.push_back(std::to_string(npc_spells_entries_entry.npc_spells_id)); - insert_values.push_back(std::to_string(npc_spells_entries_entry.spellid)); - insert_values.push_back(std::to_string(npc_spells_entries_entry.type)); - insert_values.push_back(std::to_string(npc_spells_entries_entry.minlevel)); - insert_values.push_back(std::to_string(npc_spells_entries_entry.maxlevel)); - insert_values.push_back(std::to_string(npc_spells_entries_entry.manacost)); - insert_values.push_back(std::to_string(npc_spells_entries_entry.recast_delay)); - insert_values.push_back(std::to_string(npc_spells_entries_entry.priority)); - insert_values.push_back(std::to_string(npc_spells_entries_entry.resist_adjust)); - insert_values.push_back(std::to_string(npc_spells_entries_entry.min_hp)); - insert_values.push_back(std::to_string(npc_spells_entries_entry.max_hp)); + v.push_back(std::to_string(e.id)); + v.push_back(std::to_string(e.npc_spells_id)); + v.push_back(std::to_string(e.spellid)); + v.push_back(std::to_string(e.type)); + v.push_back(std::to_string(e.minlevel)); + v.push_back(std::to_string(e.maxlevel)); + v.push_back(std::to_string(e.manacost)); + v.push_back(std::to_string(e.recast_delay)); + v.push_back(std::to_string(e.priority)); + v.push_back(std::to_string(e.resist_adjust)); + v.push_back(std::to_string(e.min_hp)); + v.push_back(std::to_string(e.max_hp)); - insert_chunks.push_back("(" + Strings::Implode(",", insert_values) + ")"); + insert_chunks.push_back("(" + Strings::Implode(",", v) + ")"); } - std::vector insert_values; + std::vector v; auto results = db.QueryDatabase( fmt::format( @@ -319,28 +319,28 @@ public: all_entries.reserve(results.RowCount()); for (auto row = results.begin(); row != results.end(); ++row) { - NpcSpellsEntries entry{}; + NpcSpellsEntries e{}; - entry.id = atoi(row[0]); - entry.npc_spells_id = atoi(row[1]); - entry.spellid = atoi(row[2]); - entry.type = atoi(row[3]); - entry.minlevel = atoi(row[4]); - entry.maxlevel = atoi(row[5]); - entry.manacost = atoi(row[6]); - entry.recast_delay = atoi(row[7]); - entry.priority = atoi(row[8]); - entry.resist_adjust = atoi(row[9]); - entry.min_hp = atoi(row[10]); - entry.max_hp = atoi(row[11]); + e.id = atoi(row[0]); + e.npc_spells_id = atoi(row[1]); + e.spellid = atoi(row[2]); + e.type = atoi(row[3]); + e.minlevel = atoi(row[4]); + e.maxlevel = atoi(row[5]); + e.manacost = atoi(row[6]); + e.recast_delay = atoi(row[7]); + e.priority = atoi(row[8]); + e.resist_adjust = atoi(row[9]); + e.min_hp = atoi(row[10]); + e.max_hp = atoi(row[11]); - all_entries.push_back(entry); + all_entries.push_back(e); } return all_entries; } - static std::vector GetWhere(Database& db, std::string where_filter) + static std::vector GetWhere(Database& db, const std::string &where_filter) { std::vector all_entries; @@ -355,28 +355,28 @@ public: all_entries.reserve(results.RowCount()); for (auto row = results.begin(); row != results.end(); ++row) { - NpcSpellsEntries entry{}; + NpcSpellsEntries e{}; - entry.id = atoi(row[0]); - entry.npc_spells_id = atoi(row[1]); - entry.spellid = atoi(row[2]); - entry.type = atoi(row[3]); - entry.minlevel = atoi(row[4]); - entry.maxlevel = atoi(row[5]); - entry.manacost = atoi(row[6]); - entry.recast_delay = atoi(row[7]); - entry.priority = atoi(row[8]); - entry.resist_adjust = atoi(row[9]); - entry.min_hp = atoi(row[10]); - entry.max_hp = atoi(row[11]); + e.id = atoi(row[0]); + e.npc_spells_id = atoi(row[1]); + e.spellid = atoi(row[2]); + e.type = atoi(row[3]); + e.minlevel = atoi(row[4]); + e.maxlevel = atoi(row[5]); + e.manacost = atoi(row[6]); + e.recast_delay = atoi(row[7]); + e.priority = atoi(row[8]); + e.resist_adjust = atoi(row[9]); + e.min_hp = atoi(row[10]); + e.max_hp = atoi(row[11]); - all_entries.push_back(entry); + all_entries.push_back(e); } return all_entries; } - static int DeleteWhere(Database& db, std::string where_filter) + static int DeleteWhere(Database& db, const std::string &where_filter) { auto results = db.QueryDatabase( fmt::format( @@ -401,6 +401,32 @@ public: 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); + } + }; #endif //EQEMU_BASE_NPC_SPELLS_ENTRIES_REPOSITORY_H diff --git a/common/repositories/base/base_npc_spells_repository.h b/common/repositories/base/base_npc_spells_repository.h index 9dda6c144..1b72d4bda 100644 --- a/common/repositories/base/base_npc_spells_repository.h +++ b/common/repositories/base/base_npc_spells_repository.h @@ -136,34 +136,34 @@ public: static NpcSpells NewEntity() { - NpcSpells entry{}; + NpcSpells e{}; - entry.id = 0; - entry.name = ""; - entry.parent_list = 0; - entry.attack_proc = -1; - entry.proc_chance = 3; - entry.range_proc = -1; - entry.rproc_chance = 0; - entry.defensive_proc = -1; - entry.dproc_chance = 0; - entry.fail_recast = 0; - entry.engaged_no_sp_recast_min = 0; - entry.engaged_no_sp_recast_max = 0; - entry.engaged_b_self_chance = 0; - entry.engaged_b_other_chance = 0; - entry.engaged_d_chance = 0; - entry.pursue_no_sp_recast_min = 0; - entry.pursue_no_sp_recast_max = 0; - entry.pursue_d_chance = 0; - entry.idle_no_sp_recast_min = 0; - entry.idle_no_sp_recast_max = 0; - entry.idle_b_chance = 0; + e.id = 0; + e.name = ""; + e.parent_list = 0; + e.attack_proc = -1; + e.proc_chance = 3; + e.range_proc = -1; + e.rproc_chance = 0; + e.defensive_proc = -1; + e.dproc_chance = 0; + e.fail_recast = 0; + e.engaged_no_sp_recast_min = 0; + e.engaged_no_sp_recast_max = 0; + e.engaged_b_self_chance = 0; + e.engaged_b_other_chance = 0; + e.engaged_d_chance = 0; + e.pursue_no_sp_recast_min = 0; + e.pursue_no_sp_recast_max = 0; + e.pursue_d_chance = 0; + e.idle_no_sp_recast_min = 0; + e.idle_no_sp_recast_max = 0; + e.idle_b_chance = 0; - return entry; + return e; } - static NpcSpells GetNpcSpellsEntry( + static NpcSpells GetNpcSpells( const std::vector &npc_spellss, int npc_spells_id ) @@ -192,31 +192,31 @@ public: auto row = results.begin(); if (results.RowCount() == 1) { - NpcSpells entry{}; + NpcSpells e{}; - entry.id = atoi(row[0]); - entry.name = row[1] ? row[1] : ""; - entry.parent_list = atoi(row[2]); - entry.attack_proc = atoi(row[3]); - entry.proc_chance = atoi(row[4]); - entry.range_proc = atoi(row[5]); - entry.rproc_chance = atoi(row[6]); - entry.defensive_proc = atoi(row[7]); - entry.dproc_chance = atoi(row[8]); - entry.fail_recast = atoi(row[9]); - entry.engaged_no_sp_recast_min = atoi(row[10]); - entry.engaged_no_sp_recast_max = atoi(row[11]); - entry.engaged_b_self_chance = atoi(row[12]); - entry.engaged_b_other_chance = atoi(row[13]); - entry.engaged_d_chance = atoi(row[14]); - entry.pursue_no_sp_recast_min = atoi(row[15]); - entry.pursue_no_sp_recast_max = atoi(row[16]); - entry.pursue_d_chance = atoi(row[17]); - entry.idle_no_sp_recast_min = atoi(row[18]); - entry.idle_no_sp_recast_max = atoi(row[19]); - entry.idle_b_chance = atoi(row[20]); + e.id = atoi(row[0]); + e.name = row[1] ? row[1] : ""; + e.parent_list = atoi(row[2]); + e.attack_proc = atoi(row[3]); + e.proc_chance = atoi(row[4]); + e.range_proc = atoi(row[5]); + e.rproc_chance = atoi(row[6]); + e.defensive_proc = atoi(row[7]); + e.dproc_chance = atoi(row[8]); + e.fail_recast = atoi(row[9]); + e.engaged_no_sp_recast_min = atoi(row[10]); + e.engaged_no_sp_recast_max = atoi(row[11]); + e.engaged_b_self_chance = atoi(row[12]); + e.engaged_b_other_chance = atoi(row[13]); + e.engaged_d_chance = atoi(row[14]); + e.pursue_no_sp_recast_min = atoi(row[15]); + e.pursue_no_sp_recast_max = atoi(row[16]); + e.pursue_d_chance = atoi(row[17]); + e.idle_no_sp_recast_min = atoi(row[18]); + e.idle_no_sp_recast_max = atoi(row[19]); + e.idle_b_chance = atoi(row[20]); - return entry; + return e; } return NewEntity(); @@ -241,41 +241,41 @@ public: static int UpdateOne( Database& db, - NpcSpells npc_spells_entry + const NpcSpells &e ) { - std::vector update_values; + std::vector v; auto columns = Columns(); - update_values.push_back(columns[1] + " = '" + Strings::Escape(npc_spells_entry.name) + "'"); - update_values.push_back(columns[2] + " = " + std::to_string(npc_spells_entry.parent_list)); - update_values.push_back(columns[3] + " = " + std::to_string(npc_spells_entry.attack_proc)); - update_values.push_back(columns[4] + " = " + std::to_string(npc_spells_entry.proc_chance)); - update_values.push_back(columns[5] + " = " + std::to_string(npc_spells_entry.range_proc)); - update_values.push_back(columns[6] + " = " + std::to_string(npc_spells_entry.rproc_chance)); - update_values.push_back(columns[7] + " = " + std::to_string(npc_spells_entry.defensive_proc)); - update_values.push_back(columns[8] + " = " + std::to_string(npc_spells_entry.dproc_chance)); - update_values.push_back(columns[9] + " = " + std::to_string(npc_spells_entry.fail_recast)); - update_values.push_back(columns[10] + " = " + std::to_string(npc_spells_entry.engaged_no_sp_recast_min)); - update_values.push_back(columns[11] + " = " + std::to_string(npc_spells_entry.engaged_no_sp_recast_max)); - update_values.push_back(columns[12] + " = " + std::to_string(npc_spells_entry.engaged_b_self_chance)); - update_values.push_back(columns[13] + " = " + std::to_string(npc_spells_entry.engaged_b_other_chance)); - update_values.push_back(columns[14] + " = " + std::to_string(npc_spells_entry.engaged_d_chance)); - update_values.push_back(columns[15] + " = " + std::to_string(npc_spells_entry.pursue_no_sp_recast_min)); - update_values.push_back(columns[16] + " = " + std::to_string(npc_spells_entry.pursue_no_sp_recast_max)); - update_values.push_back(columns[17] + " = " + std::to_string(npc_spells_entry.pursue_d_chance)); - update_values.push_back(columns[18] + " = " + std::to_string(npc_spells_entry.idle_no_sp_recast_min)); - update_values.push_back(columns[19] + " = " + std::to_string(npc_spells_entry.idle_no_sp_recast_max)); - update_values.push_back(columns[20] + " = " + std::to_string(npc_spells_entry.idle_b_chance)); + v.push_back(columns[1] + " = '" + Strings::Escape(e.name) + "'"); + v.push_back(columns[2] + " = " + std::to_string(e.parent_list)); + v.push_back(columns[3] + " = " + std::to_string(e.attack_proc)); + v.push_back(columns[4] + " = " + std::to_string(e.proc_chance)); + v.push_back(columns[5] + " = " + std::to_string(e.range_proc)); + v.push_back(columns[6] + " = " + std::to_string(e.rproc_chance)); + v.push_back(columns[7] + " = " + std::to_string(e.defensive_proc)); + v.push_back(columns[8] + " = " + std::to_string(e.dproc_chance)); + v.push_back(columns[9] + " = " + std::to_string(e.fail_recast)); + v.push_back(columns[10] + " = " + std::to_string(e.engaged_no_sp_recast_min)); + v.push_back(columns[11] + " = " + std::to_string(e.engaged_no_sp_recast_max)); + v.push_back(columns[12] + " = " + std::to_string(e.engaged_b_self_chance)); + v.push_back(columns[13] + " = " + std::to_string(e.engaged_b_other_chance)); + v.push_back(columns[14] + " = " + std::to_string(e.engaged_d_chance)); + v.push_back(columns[15] + " = " + std::to_string(e.pursue_no_sp_recast_min)); + v.push_back(columns[16] + " = " + std::to_string(e.pursue_no_sp_recast_max)); + v.push_back(columns[17] + " = " + std::to_string(e.pursue_d_chance)); + v.push_back(columns[18] + " = " + std::to_string(e.idle_no_sp_recast_min)); + v.push_back(columns[19] + " = " + std::to_string(e.idle_no_sp_recast_max)); + v.push_back(columns[20] + " = " + std::to_string(e.idle_b_chance)); auto results = db.QueryDatabase( fmt::format( "UPDATE {} SET {} WHERE {} = {}", TableName(), - Strings::Implode(", ", update_values), + Strings::Implode(", ", v), PrimaryKey(), - npc_spells_entry.id + e.id ) ); @@ -284,87 +284,87 @@ public: static NpcSpells InsertOne( Database& db, - NpcSpells npc_spells_entry + NpcSpells e ) { - std::vector insert_values; + std::vector v; - insert_values.push_back(std::to_string(npc_spells_entry.id)); - insert_values.push_back("'" + Strings::Escape(npc_spells_entry.name) + "'"); - insert_values.push_back(std::to_string(npc_spells_entry.parent_list)); - insert_values.push_back(std::to_string(npc_spells_entry.attack_proc)); - insert_values.push_back(std::to_string(npc_spells_entry.proc_chance)); - insert_values.push_back(std::to_string(npc_spells_entry.range_proc)); - insert_values.push_back(std::to_string(npc_spells_entry.rproc_chance)); - insert_values.push_back(std::to_string(npc_spells_entry.defensive_proc)); - insert_values.push_back(std::to_string(npc_spells_entry.dproc_chance)); - insert_values.push_back(std::to_string(npc_spells_entry.fail_recast)); - insert_values.push_back(std::to_string(npc_spells_entry.engaged_no_sp_recast_min)); - insert_values.push_back(std::to_string(npc_spells_entry.engaged_no_sp_recast_max)); - insert_values.push_back(std::to_string(npc_spells_entry.engaged_b_self_chance)); - insert_values.push_back(std::to_string(npc_spells_entry.engaged_b_other_chance)); - insert_values.push_back(std::to_string(npc_spells_entry.engaged_d_chance)); - insert_values.push_back(std::to_string(npc_spells_entry.pursue_no_sp_recast_min)); - insert_values.push_back(std::to_string(npc_spells_entry.pursue_no_sp_recast_max)); - insert_values.push_back(std::to_string(npc_spells_entry.pursue_d_chance)); - insert_values.push_back(std::to_string(npc_spells_entry.idle_no_sp_recast_min)); - insert_values.push_back(std::to_string(npc_spells_entry.idle_no_sp_recast_max)); - insert_values.push_back(std::to_string(npc_spells_entry.idle_b_chance)); + v.push_back(std::to_string(e.id)); + v.push_back("'" + Strings::Escape(e.name) + "'"); + v.push_back(std::to_string(e.parent_list)); + v.push_back(std::to_string(e.attack_proc)); + v.push_back(std::to_string(e.proc_chance)); + v.push_back(std::to_string(e.range_proc)); + v.push_back(std::to_string(e.rproc_chance)); + v.push_back(std::to_string(e.defensive_proc)); + v.push_back(std::to_string(e.dproc_chance)); + v.push_back(std::to_string(e.fail_recast)); + v.push_back(std::to_string(e.engaged_no_sp_recast_min)); + v.push_back(std::to_string(e.engaged_no_sp_recast_max)); + v.push_back(std::to_string(e.engaged_b_self_chance)); + v.push_back(std::to_string(e.engaged_b_other_chance)); + v.push_back(std::to_string(e.engaged_d_chance)); + v.push_back(std::to_string(e.pursue_no_sp_recast_min)); + v.push_back(std::to_string(e.pursue_no_sp_recast_max)); + v.push_back(std::to_string(e.pursue_d_chance)); + v.push_back(std::to_string(e.idle_no_sp_recast_min)); + v.push_back(std::to_string(e.idle_no_sp_recast_max)); + v.push_back(std::to_string(e.idle_b_chance)); auto results = db.QueryDatabase( fmt::format( "{} VALUES ({})", BaseInsert(), - Strings::Implode(",", insert_values) + Strings::Implode(",", v) ) ); if (results.Success()) { - npc_spells_entry.id = results.LastInsertedID(); - return npc_spells_entry; + e.id = results.LastInsertedID(); + return e; } - npc_spells_entry = NewEntity(); + e = NewEntity(); - return npc_spells_entry; + return e; } static int InsertMany( Database& db, - std::vector npc_spells_entries + const std::vector &entries ) { std::vector insert_chunks; - for (auto &npc_spells_entry: npc_spells_entries) { - std::vector insert_values; + for (auto &e: entries) { + std::vector v; - insert_values.push_back(std::to_string(npc_spells_entry.id)); - insert_values.push_back("'" + Strings::Escape(npc_spells_entry.name) + "'"); - insert_values.push_back(std::to_string(npc_spells_entry.parent_list)); - insert_values.push_back(std::to_string(npc_spells_entry.attack_proc)); - insert_values.push_back(std::to_string(npc_spells_entry.proc_chance)); - insert_values.push_back(std::to_string(npc_spells_entry.range_proc)); - insert_values.push_back(std::to_string(npc_spells_entry.rproc_chance)); - insert_values.push_back(std::to_string(npc_spells_entry.defensive_proc)); - insert_values.push_back(std::to_string(npc_spells_entry.dproc_chance)); - insert_values.push_back(std::to_string(npc_spells_entry.fail_recast)); - insert_values.push_back(std::to_string(npc_spells_entry.engaged_no_sp_recast_min)); - insert_values.push_back(std::to_string(npc_spells_entry.engaged_no_sp_recast_max)); - insert_values.push_back(std::to_string(npc_spells_entry.engaged_b_self_chance)); - insert_values.push_back(std::to_string(npc_spells_entry.engaged_b_other_chance)); - insert_values.push_back(std::to_string(npc_spells_entry.engaged_d_chance)); - insert_values.push_back(std::to_string(npc_spells_entry.pursue_no_sp_recast_min)); - insert_values.push_back(std::to_string(npc_spells_entry.pursue_no_sp_recast_max)); - insert_values.push_back(std::to_string(npc_spells_entry.pursue_d_chance)); - insert_values.push_back(std::to_string(npc_spells_entry.idle_no_sp_recast_min)); - insert_values.push_back(std::to_string(npc_spells_entry.idle_no_sp_recast_max)); - insert_values.push_back(std::to_string(npc_spells_entry.idle_b_chance)); + v.push_back(std::to_string(e.id)); + v.push_back("'" + Strings::Escape(e.name) + "'"); + v.push_back(std::to_string(e.parent_list)); + v.push_back(std::to_string(e.attack_proc)); + v.push_back(std::to_string(e.proc_chance)); + v.push_back(std::to_string(e.range_proc)); + v.push_back(std::to_string(e.rproc_chance)); + v.push_back(std::to_string(e.defensive_proc)); + v.push_back(std::to_string(e.dproc_chance)); + v.push_back(std::to_string(e.fail_recast)); + v.push_back(std::to_string(e.engaged_no_sp_recast_min)); + v.push_back(std::to_string(e.engaged_no_sp_recast_max)); + v.push_back(std::to_string(e.engaged_b_self_chance)); + v.push_back(std::to_string(e.engaged_b_other_chance)); + v.push_back(std::to_string(e.engaged_d_chance)); + v.push_back(std::to_string(e.pursue_no_sp_recast_min)); + v.push_back(std::to_string(e.pursue_no_sp_recast_max)); + v.push_back(std::to_string(e.pursue_d_chance)); + v.push_back(std::to_string(e.idle_no_sp_recast_min)); + v.push_back(std::to_string(e.idle_no_sp_recast_max)); + v.push_back(std::to_string(e.idle_b_chance)); - insert_chunks.push_back("(" + Strings::Implode(",", insert_values) + ")"); + insert_chunks.push_back("(" + Strings::Implode(",", v) + ")"); } - std::vector insert_values; + std::vector v; auto results = db.QueryDatabase( fmt::format( @@ -391,37 +391,37 @@ public: all_entries.reserve(results.RowCount()); for (auto row = results.begin(); row != results.end(); ++row) { - NpcSpells entry{}; + NpcSpells e{}; - entry.id = atoi(row[0]); - entry.name = row[1] ? row[1] : ""; - entry.parent_list = atoi(row[2]); - entry.attack_proc = atoi(row[3]); - entry.proc_chance = atoi(row[4]); - entry.range_proc = atoi(row[5]); - entry.rproc_chance = atoi(row[6]); - entry.defensive_proc = atoi(row[7]); - entry.dproc_chance = atoi(row[8]); - entry.fail_recast = atoi(row[9]); - entry.engaged_no_sp_recast_min = atoi(row[10]); - entry.engaged_no_sp_recast_max = atoi(row[11]); - entry.engaged_b_self_chance = atoi(row[12]); - entry.engaged_b_other_chance = atoi(row[13]); - entry.engaged_d_chance = atoi(row[14]); - entry.pursue_no_sp_recast_min = atoi(row[15]); - entry.pursue_no_sp_recast_max = atoi(row[16]); - entry.pursue_d_chance = atoi(row[17]); - entry.idle_no_sp_recast_min = atoi(row[18]); - entry.idle_no_sp_recast_max = atoi(row[19]); - entry.idle_b_chance = atoi(row[20]); + e.id = atoi(row[0]); + e.name = row[1] ? row[1] : ""; + e.parent_list = atoi(row[2]); + e.attack_proc = atoi(row[3]); + e.proc_chance = atoi(row[4]); + e.range_proc = atoi(row[5]); + e.rproc_chance = atoi(row[6]); + e.defensive_proc = atoi(row[7]); + e.dproc_chance = atoi(row[8]); + e.fail_recast = atoi(row[9]); + e.engaged_no_sp_recast_min = atoi(row[10]); + e.engaged_no_sp_recast_max = atoi(row[11]); + e.engaged_b_self_chance = atoi(row[12]); + e.engaged_b_other_chance = atoi(row[13]); + e.engaged_d_chance = atoi(row[14]); + e.pursue_no_sp_recast_min = atoi(row[15]); + e.pursue_no_sp_recast_max = atoi(row[16]); + e.pursue_d_chance = atoi(row[17]); + e.idle_no_sp_recast_min = atoi(row[18]); + e.idle_no_sp_recast_max = atoi(row[19]); + e.idle_b_chance = atoi(row[20]); - all_entries.push_back(entry); + all_entries.push_back(e); } return all_entries; } - static std::vector GetWhere(Database& db, std::string where_filter) + static std::vector GetWhere(Database& db, const std::string &where_filter) { std::vector all_entries; @@ -436,37 +436,37 @@ public: all_entries.reserve(results.RowCount()); for (auto row = results.begin(); row != results.end(); ++row) { - NpcSpells entry{}; + NpcSpells e{}; - entry.id = atoi(row[0]); - entry.name = row[1] ? row[1] : ""; - entry.parent_list = atoi(row[2]); - entry.attack_proc = atoi(row[3]); - entry.proc_chance = atoi(row[4]); - entry.range_proc = atoi(row[5]); - entry.rproc_chance = atoi(row[6]); - entry.defensive_proc = atoi(row[7]); - entry.dproc_chance = atoi(row[8]); - entry.fail_recast = atoi(row[9]); - entry.engaged_no_sp_recast_min = atoi(row[10]); - entry.engaged_no_sp_recast_max = atoi(row[11]); - entry.engaged_b_self_chance = atoi(row[12]); - entry.engaged_b_other_chance = atoi(row[13]); - entry.engaged_d_chance = atoi(row[14]); - entry.pursue_no_sp_recast_min = atoi(row[15]); - entry.pursue_no_sp_recast_max = atoi(row[16]); - entry.pursue_d_chance = atoi(row[17]); - entry.idle_no_sp_recast_min = atoi(row[18]); - entry.idle_no_sp_recast_max = atoi(row[19]); - entry.idle_b_chance = atoi(row[20]); + e.id = atoi(row[0]); + e.name = row[1] ? row[1] : ""; + e.parent_list = atoi(row[2]); + e.attack_proc = atoi(row[3]); + e.proc_chance = atoi(row[4]); + e.range_proc = atoi(row[5]); + e.rproc_chance = atoi(row[6]); + e.defensive_proc = atoi(row[7]); + e.dproc_chance = atoi(row[8]); + e.fail_recast = atoi(row[9]); + e.engaged_no_sp_recast_min = atoi(row[10]); + e.engaged_no_sp_recast_max = atoi(row[11]); + e.engaged_b_self_chance = atoi(row[12]); + e.engaged_b_other_chance = atoi(row[13]); + e.engaged_d_chance = atoi(row[14]); + e.pursue_no_sp_recast_min = atoi(row[15]); + e.pursue_no_sp_recast_max = atoi(row[16]); + e.pursue_d_chance = atoi(row[17]); + e.idle_no_sp_recast_min = atoi(row[18]); + e.idle_no_sp_recast_max = atoi(row[19]); + e.idle_b_chance = atoi(row[20]); - all_entries.push_back(entry); + all_entries.push_back(e); } return all_entries; } - static int DeleteWhere(Database& db, std::string where_filter) + static int DeleteWhere(Database& db, const std::string &where_filter) { auto results = db.QueryDatabase( fmt::format( @@ -491,6 +491,32 @@ public: 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); + } + }; #endif //EQEMU_BASE_NPC_SPELLS_REPOSITORY_H diff --git a/common/repositories/base/base_npc_types_repository.h b/common/repositories/base/base_npc_types_repository.h index 49d8cab8d..8d380d904 100644 --- a/common/repositories/base/base_npc_types_repository.h +++ b/common/repositories/base/base_npc_types_repository.h @@ -445,137 +445,137 @@ public: static NpcTypes NewEntity() { - NpcTypes entry{}; + NpcTypes e{}; - entry.id = 0; - entry.name = ""; - entry.lastname = ""; - entry.level = 0; - entry.race = 0; - entry.class_ = 0; - entry.bodytype = 1; - entry.hp = 0; - entry.mana = 0; - entry.gender = 0; - entry.texture = 0; - entry.helmtexture = 0; - entry.herosforgemodel = 0; - entry.size = 0; - entry.hp_regen_rate = 0; - entry.hp_regen_per_second = 0; - entry.mana_regen_rate = 0; - entry.loottable_id = 0; - entry.merchant_id = 0; - entry.alt_currency_id = 0; - entry.npc_spells_id = 0; - entry.npc_spells_effects_id = 0; - entry.npc_faction_id = 0; - entry.adventure_template_id = 0; - entry.trap_template = 0; - entry.mindmg = 0; - entry.maxdmg = 0; - entry.attack_count = -1; - entry.npcspecialattks = ""; - entry.special_abilities = ""; - entry.aggroradius = 0; - entry.assistradius = 0; - entry.face = 1; - entry.luclin_hairstyle = 1; - entry.luclin_haircolor = 1; - entry.luclin_eyecolor = 1; - entry.luclin_eyecolor2 = 1; - entry.luclin_beardcolor = 1; - entry.luclin_beard = 0; - entry.drakkin_heritage = 0; - entry.drakkin_tattoo = 0; - entry.drakkin_details = 0; - entry.armortint_id = 0; - entry.armortint_red = 0; - entry.armortint_green = 0; - entry.armortint_blue = 0; - entry.d_melee_texture1 = 0; - entry.d_melee_texture2 = 0; - entry.ammo_idfile = "IT10"; - entry.prim_melee_type = 28; - entry.sec_melee_type = 28; - entry.ranged_type = 7; - entry.runspeed = 0; - entry.MR = 0; - entry.CR = 0; - entry.DR = 0; - entry.FR = 0; - entry.PR = 0; - entry.Corrup = 0; - entry.PhR = 0; - entry.see_invis = 0; - entry.see_invis_undead = 0; - entry.qglobal = 0; - entry.AC = 0; - entry.npc_aggro = 0; - entry.spawn_limit = 0; - entry.attack_speed = 0; - entry.attack_delay = 30; - entry.findable = 0; - entry.STR = 75; - entry.STA = 75; - entry.DEX = 75; - entry.AGI = 75; - entry._INT = 80; - entry.WIS = 75; - entry.CHA = 75; - entry.see_hide = 0; - entry.see_improved_hide = 0; - entry.trackable = 1; - entry.isbot = 0; - entry.exclude = 1; - entry.ATK = 0; - entry.Accuracy = 0; - entry.Avoidance = 0; - entry.slow_mitigation = 0; - entry.version = 0; - entry.maxlevel = 0; - entry.scalerate = 100; - entry.private_corpse = 0; - entry.unique_spawn_by_name = 0; - entry.underwater = 0; - entry.isquest = 0; - entry.emoteid = 0; - entry.spellscale = 100; - entry.healscale = 100; - entry.no_target_hotkey = 0; - entry.raid_target = 0; - entry.armtexture = 0; - entry.bracertexture = 0; - entry.handtexture = 0; - entry.legtexture = 0; - entry.feettexture = 0; - entry.light = 0; - entry.walkspeed = 0; - entry.peqid = 0; - entry.unique_ = 0; - entry.fixed = 0; - entry.ignore_despawn = 0; - entry.show_name = 1; - entry.untargetable = 0; - entry.charm_ac = 0; - entry.charm_min_dmg = 0; - entry.charm_max_dmg = 0; - entry.charm_attack_delay = 0; - entry.charm_accuracy_rating = 0; - entry.charm_avoidance_rating = 0; - entry.charm_atk = 0; - entry.skip_global_loot = 0; - entry.rare_spawn = 0; - entry.stuck_behavior = 0; - entry.model = 0; - entry.flymode = -1; - entry.always_aggro = 0; - entry.exp_mod = 100; + e.id = 0; + e.name = ""; + e.lastname = ""; + e.level = 0; + e.race = 0; + e.class_ = 0; + e.bodytype = 1; + e.hp = 0; + e.mana = 0; + e.gender = 0; + e.texture = 0; + e.helmtexture = 0; + e.herosforgemodel = 0; + e.size = 0; + e.hp_regen_rate = 0; + e.hp_regen_per_second = 0; + e.mana_regen_rate = 0; + e.loottable_id = 0; + e.merchant_id = 0; + e.alt_currency_id = 0; + e.npc_spells_id = 0; + e.npc_spells_effects_id = 0; + e.npc_faction_id = 0; + e.adventure_template_id = 0; + e.trap_template = 0; + e.mindmg = 0; + e.maxdmg = 0; + e.attack_count = -1; + e.npcspecialattks = ""; + e.special_abilities = ""; + e.aggroradius = 0; + e.assistradius = 0; + e.face = 1; + e.luclin_hairstyle = 1; + e.luclin_haircolor = 1; + e.luclin_eyecolor = 1; + e.luclin_eyecolor2 = 1; + e.luclin_beardcolor = 1; + e.luclin_beard = 0; + e.drakkin_heritage = 0; + e.drakkin_tattoo = 0; + e.drakkin_details = 0; + e.armortint_id = 0; + e.armortint_red = 0; + e.armortint_green = 0; + e.armortint_blue = 0; + e.d_melee_texture1 = 0; + e.d_melee_texture2 = 0; + e.ammo_idfile = "IT10"; + e.prim_melee_type = 28; + e.sec_melee_type = 28; + e.ranged_type = 7; + e.runspeed = 0; + e.MR = 0; + e.CR = 0; + e.DR = 0; + e.FR = 0; + e.PR = 0; + e.Corrup = 0; + e.PhR = 0; + e.see_invis = 0; + e.see_invis_undead = 0; + e.qglobal = 0; + e.AC = 0; + e.npc_aggro = 0; + e.spawn_limit = 0; + e.attack_speed = 0; + e.attack_delay = 30; + e.findable = 0; + e.STR = 75; + e.STA = 75; + e.DEX = 75; + e.AGI = 75; + e._INT = 80; + e.WIS = 75; + e.CHA = 75; + e.see_hide = 0; + e.see_improved_hide = 0; + e.trackable = 1; + e.isbot = 0; + e.exclude = 1; + e.ATK = 0; + e.Accuracy = 0; + e.Avoidance = 0; + e.slow_mitigation = 0; + e.version = 0; + e.maxlevel = 0; + e.scalerate = 100; + e.private_corpse = 0; + e.unique_spawn_by_name = 0; + e.underwater = 0; + e.isquest = 0; + e.emoteid = 0; + e.spellscale = 100; + e.healscale = 100; + e.no_target_hotkey = 0; + e.raid_target = 0; + e.armtexture = 0; + e.bracertexture = 0; + e.handtexture = 0; + e.legtexture = 0; + e.feettexture = 0; + e.light = 0; + e.walkspeed = 0; + e.peqid = 0; + e.unique_ = 0; + e.fixed = 0; + e.ignore_despawn = 0; + e.show_name = 1; + e.untargetable = 0; + e.charm_ac = 0; + e.charm_min_dmg = 0; + e.charm_max_dmg = 0; + e.charm_attack_delay = 0; + e.charm_accuracy_rating = 0; + e.charm_avoidance_rating = 0; + e.charm_atk = 0; + e.skip_global_loot = 0; + e.rare_spawn = 0; + e.stuck_behavior = 0; + e.model = 0; + e.flymode = -1; + e.always_aggro = 0; + e.exp_mod = 100; - return entry; + return e; } - static NpcTypes GetNpcTypesEntry( + static NpcTypes GetNpcTypes( const std::vector &npc_typess, int npc_types_id ) @@ -604,134 +604,134 @@ public: auto row = results.begin(); if (results.RowCount() == 1) { - NpcTypes entry{}; + NpcTypes e{}; - entry.id = atoi(row[0]); - entry.name = row[1] ? row[1] : ""; - entry.lastname = row[2] ? row[2] : ""; - entry.level = atoi(row[3]); - entry.race = atoi(row[4]); - entry.class_ = atoi(row[5]); - entry.bodytype = atoi(row[6]); - entry.hp = strtoll(row[7], nullptr, 10); - entry.mana = strtoll(row[8], nullptr, 10); - entry.gender = atoi(row[9]); - entry.texture = atoi(row[10]); - entry.helmtexture = atoi(row[11]); - entry.herosforgemodel = atoi(row[12]); - entry.size = static_cast(atof(row[13])); - entry.hp_regen_rate = strtoll(row[14], nullptr, 10); - entry.hp_regen_per_second = strtoll(row[15], nullptr, 10); - entry.mana_regen_rate = strtoll(row[16], nullptr, 10); - entry.loottable_id = atoi(row[17]); - entry.merchant_id = atoi(row[18]); - entry.alt_currency_id = atoi(row[19]); - entry.npc_spells_id = atoi(row[20]); - entry.npc_spells_effects_id = atoi(row[21]); - entry.npc_faction_id = atoi(row[22]); - entry.adventure_template_id = atoi(row[23]); - entry.trap_template = atoi(row[24]); - entry.mindmg = atoi(row[25]); - entry.maxdmg = atoi(row[26]); - entry.attack_count = atoi(row[27]); - entry.npcspecialattks = row[28] ? row[28] : ""; - entry.special_abilities = row[29] ? row[29] : ""; - entry.aggroradius = atoi(row[30]); - entry.assistradius = atoi(row[31]); - entry.face = atoi(row[32]); - entry.luclin_hairstyle = atoi(row[33]); - entry.luclin_haircolor = atoi(row[34]); - entry.luclin_eyecolor = atoi(row[35]); - entry.luclin_eyecolor2 = atoi(row[36]); - entry.luclin_beardcolor = atoi(row[37]); - entry.luclin_beard = atoi(row[38]); - entry.drakkin_heritage = atoi(row[39]); - entry.drakkin_tattoo = atoi(row[40]); - entry.drakkin_details = atoi(row[41]); - entry.armortint_id = atoi(row[42]); - entry.armortint_red = atoi(row[43]); - entry.armortint_green = atoi(row[44]); - entry.armortint_blue = atoi(row[45]); - entry.d_melee_texture1 = atoi(row[46]); - entry.d_melee_texture2 = atoi(row[47]); - entry.ammo_idfile = row[48] ? row[48] : ""; - entry.prim_melee_type = atoi(row[49]); - entry.sec_melee_type = atoi(row[50]); - entry.ranged_type = atoi(row[51]); - entry.runspeed = static_cast(atof(row[52])); - entry.MR = atoi(row[53]); - entry.CR = atoi(row[54]); - entry.DR = atoi(row[55]); - entry.FR = atoi(row[56]); - entry.PR = atoi(row[57]); - entry.Corrup = atoi(row[58]); - entry.PhR = atoi(row[59]); - entry.see_invis = atoi(row[60]); - entry.see_invis_undead = atoi(row[61]); - entry.qglobal = atoi(row[62]); - entry.AC = atoi(row[63]); - entry.npc_aggro = atoi(row[64]); - entry.spawn_limit = atoi(row[65]); - entry.attack_speed = static_cast(atof(row[66])); - entry.attack_delay = atoi(row[67]); - entry.findable = atoi(row[68]); - entry.STR = atoi(row[69]); - entry.STA = atoi(row[70]); - entry.DEX = atoi(row[71]); - entry.AGI = atoi(row[72]); - entry._INT = atoi(row[73]); - entry.WIS = atoi(row[74]); - entry.CHA = atoi(row[75]); - entry.see_hide = atoi(row[76]); - entry.see_improved_hide = atoi(row[77]); - entry.trackable = atoi(row[78]); - entry.isbot = atoi(row[79]); - entry.exclude = atoi(row[80]); - entry.ATK = atoi(row[81]); - entry.Accuracy = atoi(row[82]); - entry.Avoidance = atoi(row[83]); - entry.slow_mitigation = atoi(row[84]); - entry.version = atoi(row[85]); - entry.maxlevel = atoi(row[86]); - entry.scalerate = atoi(row[87]); - entry.private_corpse = atoi(row[88]); - entry.unique_spawn_by_name = atoi(row[89]); - entry.underwater = atoi(row[90]); - entry.isquest = atoi(row[91]); - entry.emoteid = atoi(row[92]); - entry.spellscale = static_cast(atof(row[93])); - entry.healscale = static_cast(atof(row[94])); - entry.no_target_hotkey = atoi(row[95]); - entry.raid_target = atoi(row[96]); - entry.armtexture = atoi(row[97]); - entry.bracertexture = atoi(row[98]); - entry.handtexture = atoi(row[99]); - entry.legtexture = atoi(row[100]); - entry.feettexture = atoi(row[101]); - entry.light = atoi(row[102]); - entry.walkspeed = atoi(row[103]); - entry.peqid = atoi(row[104]); - entry.unique_ = atoi(row[105]); - entry.fixed = atoi(row[106]); - entry.ignore_despawn = atoi(row[107]); - entry.show_name = atoi(row[108]); - entry.untargetable = atoi(row[109]); - entry.charm_ac = atoi(row[110]); - entry.charm_min_dmg = atoi(row[111]); - entry.charm_max_dmg = atoi(row[112]); - entry.charm_attack_delay = atoi(row[113]); - entry.charm_accuracy_rating = atoi(row[114]); - entry.charm_avoidance_rating = atoi(row[115]); - entry.charm_atk = atoi(row[116]); - entry.skip_global_loot = atoi(row[117]); - entry.rare_spawn = atoi(row[118]); - entry.stuck_behavior = atoi(row[119]); - entry.model = atoi(row[120]); - entry.flymode = atoi(row[121]); - entry.always_aggro = atoi(row[122]); - entry.exp_mod = atoi(row[123]); + e.id = atoi(row[0]); + e.name = row[1] ? row[1] : ""; + e.lastname = row[2] ? row[2] : ""; + e.level = atoi(row[3]); + e.race = atoi(row[4]); + e.class_ = atoi(row[5]); + e.bodytype = atoi(row[6]); + e.hp = strtoll(row[7], nullptr, 10); + e.mana = strtoll(row[8], nullptr, 10); + e.gender = atoi(row[9]); + e.texture = atoi(row[10]); + e.helmtexture = atoi(row[11]); + e.herosforgemodel = atoi(row[12]); + e.size = static_cast(atof(row[13])); + e.hp_regen_rate = strtoll(row[14], nullptr, 10); + e.hp_regen_per_second = strtoll(row[15], nullptr, 10); + e.mana_regen_rate = strtoll(row[16], nullptr, 10); + e.loottable_id = atoi(row[17]); + e.merchant_id = atoi(row[18]); + e.alt_currency_id = atoi(row[19]); + e.npc_spells_id = atoi(row[20]); + e.npc_spells_effects_id = atoi(row[21]); + e.npc_faction_id = atoi(row[22]); + e.adventure_template_id = atoi(row[23]); + e.trap_template = atoi(row[24]); + e.mindmg = atoi(row[25]); + e.maxdmg = atoi(row[26]); + e.attack_count = atoi(row[27]); + e.npcspecialattks = row[28] ? row[28] : ""; + e.special_abilities = row[29] ? row[29] : ""; + e.aggroradius = atoi(row[30]); + e.assistradius = atoi(row[31]); + e.face = atoi(row[32]); + e.luclin_hairstyle = atoi(row[33]); + e.luclin_haircolor = atoi(row[34]); + e.luclin_eyecolor = atoi(row[35]); + e.luclin_eyecolor2 = atoi(row[36]); + e.luclin_beardcolor = atoi(row[37]); + e.luclin_beard = atoi(row[38]); + e.drakkin_heritage = atoi(row[39]); + e.drakkin_tattoo = atoi(row[40]); + e.drakkin_details = atoi(row[41]); + e.armortint_id = atoi(row[42]); + e.armortint_red = atoi(row[43]); + e.armortint_green = atoi(row[44]); + e.armortint_blue = atoi(row[45]); + e.d_melee_texture1 = atoi(row[46]); + e.d_melee_texture2 = atoi(row[47]); + e.ammo_idfile = row[48] ? row[48] : ""; + e.prim_melee_type = atoi(row[49]); + e.sec_melee_type = atoi(row[50]); + e.ranged_type = atoi(row[51]); + e.runspeed = static_cast(atof(row[52])); + e.MR = atoi(row[53]); + e.CR = atoi(row[54]); + e.DR = atoi(row[55]); + e.FR = atoi(row[56]); + e.PR = atoi(row[57]); + e.Corrup = atoi(row[58]); + e.PhR = atoi(row[59]); + e.see_invis = atoi(row[60]); + e.see_invis_undead = atoi(row[61]); + e.qglobal = atoi(row[62]); + e.AC = atoi(row[63]); + e.npc_aggro = atoi(row[64]); + e.spawn_limit = atoi(row[65]); + e.attack_speed = static_cast(atof(row[66])); + e.attack_delay = atoi(row[67]); + e.findable = atoi(row[68]); + e.STR = atoi(row[69]); + e.STA = atoi(row[70]); + e.DEX = atoi(row[71]); + e.AGI = atoi(row[72]); + e._INT = atoi(row[73]); + e.WIS = atoi(row[74]); + e.CHA = atoi(row[75]); + e.see_hide = atoi(row[76]); + e.see_improved_hide = atoi(row[77]); + e.trackable = atoi(row[78]); + e.isbot = atoi(row[79]); + e.exclude = atoi(row[80]); + e.ATK = atoi(row[81]); + e.Accuracy = atoi(row[82]); + e.Avoidance = atoi(row[83]); + e.slow_mitigation = atoi(row[84]); + e.version = atoi(row[85]); + e.maxlevel = atoi(row[86]); + e.scalerate = atoi(row[87]); + e.private_corpse = atoi(row[88]); + e.unique_spawn_by_name = atoi(row[89]); + e.underwater = atoi(row[90]); + e.isquest = atoi(row[91]); + e.emoteid = atoi(row[92]); + e.spellscale = static_cast(atof(row[93])); + e.healscale = static_cast(atof(row[94])); + e.no_target_hotkey = atoi(row[95]); + e.raid_target = atoi(row[96]); + e.armtexture = atoi(row[97]); + e.bracertexture = atoi(row[98]); + e.handtexture = atoi(row[99]); + e.legtexture = atoi(row[100]); + e.feettexture = atoi(row[101]); + e.light = atoi(row[102]); + e.walkspeed = atoi(row[103]); + e.peqid = atoi(row[104]); + e.unique_ = atoi(row[105]); + e.fixed = atoi(row[106]); + e.ignore_despawn = atoi(row[107]); + e.show_name = atoi(row[108]); + e.untargetable = atoi(row[109]); + e.charm_ac = atoi(row[110]); + e.charm_min_dmg = atoi(row[111]); + e.charm_max_dmg = atoi(row[112]); + e.charm_attack_delay = atoi(row[113]); + e.charm_accuracy_rating = atoi(row[114]); + e.charm_avoidance_rating = atoi(row[115]); + e.charm_atk = atoi(row[116]); + e.skip_global_loot = atoi(row[117]); + e.rare_spawn = atoi(row[118]); + e.stuck_behavior = atoi(row[119]); + e.model = atoi(row[120]); + e.flymode = atoi(row[121]); + e.always_aggro = atoi(row[122]); + e.exp_mod = atoi(row[123]); - return entry; + return e; } return NewEntity(); @@ -756,144 +756,144 @@ public: static int UpdateOne( Database& db, - NpcTypes npc_types_entry + const NpcTypes &e ) { - std::vector update_values; + std::vector v; auto columns = Columns(); - update_values.push_back(columns[1] + " = '" + Strings::Escape(npc_types_entry.name) + "'"); - update_values.push_back(columns[2] + " = '" + Strings::Escape(npc_types_entry.lastname) + "'"); - update_values.push_back(columns[3] + " = " + std::to_string(npc_types_entry.level)); - update_values.push_back(columns[4] + " = " + std::to_string(npc_types_entry.race)); - update_values.push_back(columns[5] + " = " + std::to_string(npc_types_entry.class_)); - update_values.push_back(columns[6] + " = " + std::to_string(npc_types_entry.bodytype)); - update_values.push_back(columns[7] + " = " + std::to_string(npc_types_entry.hp)); - update_values.push_back(columns[8] + " = " + std::to_string(npc_types_entry.mana)); - update_values.push_back(columns[9] + " = " + std::to_string(npc_types_entry.gender)); - update_values.push_back(columns[10] + " = " + std::to_string(npc_types_entry.texture)); - update_values.push_back(columns[11] + " = " + std::to_string(npc_types_entry.helmtexture)); - update_values.push_back(columns[12] + " = " + std::to_string(npc_types_entry.herosforgemodel)); - update_values.push_back(columns[13] + " = " + std::to_string(npc_types_entry.size)); - update_values.push_back(columns[14] + " = " + std::to_string(npc_types_entry.hp_regen_rate)); - update_values.push_back(columns[15] + " = " + std::to_string(npc_types_entry.hp_regen_per_second)); - update_values.push_back(columns[16] + " = " + std::to_string(npc_types_entry.mana_regen_rate)); - update_values.push_back(columns[17] + " = " + std::to_string(npc_types_entry.loottable_id)); - update_values.push_back(columns[18] + " = " + std::to_string(npc_types_entry.merchant_id)); - update_values.push_back(columns[19] + " = " + std::to_string(npc_types_entry.alt_currency_id)); - update_values.push_back(columns[20] + " = " + std::to_string(npc_types_entry.npc_spells_id)); - update_values.push_back(columns[21] + " = " + std::to_string(npc_types_entry.npc_spells_effects_id)); - update_values.push_back(columns[22] + " = " + std::to_string(npc_types_entry.npc_faction_id)); - update_values.push_back(columns[23] + " = " + std::to_string(npc_types_entry.adventure_template_id)); - update_values.push_back(columns[24] + " = " + std::to_string(npc_types_entry.trap_template)); - update_values.push_back(columns[25] + " = " + std::to_string(npc_types_entry.mindmg)); - update_values.push_back(columns[26] + " = " + std::to_string(npc_types_entry.maxdmg)); - update_values.push_back(columns[27] + " = " + std::to_string(npc_types_entry.attack_count)); - update_values.push_back(columns[28] + " = '" + Strings::Escape(npc_types_entry.npcspecialattks) + "'"); - update_values.push_back(columns[29] + " = '" + Strings::Escape(npc_types_entry.special_abilities) + "'"); - update_values.push_back(columns[30] + " = " + std::to_string(npc_types_entry.aggroradius)); - update_values.push_back(columns[31] + " = " + std::to_string(npc_types_entry.assistradius)); - update_values.push_back(columns[32] + " = " + std::to_string(npc_types_entry.face)); - update_values.push_back(columns[33] + " = " + std::to_string(npc_types_entry.luclin_hairstyle)); - update_values.push_back(columns[34] + " = " + std::to_string(npc_types_entry.luclin_haircolor)); - update_values.push_back(columns[35] + " = " + std::to_string(npc_types_entry.luclin_eyecolor)); - update_values.push_back(columns[36] + " = " + std::to_string(npc_types_entry.luclin_eyecolor2)); - update_values.push_back(columns[37] + " = " + std::to_string(npc_types_entry.luclin_beardcolor)); - update_values.push_back(columns[38] + " = " + std::to_string(npc_types_entry.luclin_beard)); - update_values.push_back(columns[39] + " = " + std::to_string(npc_types_entry.drakkin_heritage)); - update_values.push_back(columns[40] + " = " + std::to_string(npc_types_entry.drakkin_tattoo)); - update_values.push_back(columns[41] + " = " + std::to_string(npc_types_entry.drakkin_details)); - update_values.push_back(columns[42] + " = " + std::to_string(npc_types_entry.armortint_id)); - update_values.push_back(columns[43] + " = " + std::to_string(npc_types_entry.armortint_red)); - update_values.push_back(columns[44] + " = " + std::to_string(npc_types_entry.armortint_green)); - update_values.push_back(columns[45] + " = " + std::to_string(npc_types_entry.armortint_blue)); - update_values.push_back(columns[46] + " = " + std::to_string(npc_types_entry.d_melee_texture1)); - update_values.push_back(columns[47] + " = " + std::to_string(npc_types_entry.d_melee_texture2)); - update_values.push_back(columns[48] + " = '" + Strings::Escape(npc_types_entry.ammo_idfile) + "'"); - update_values.push_back(columns[49] + " = " + std::to_string(npc_types_entry.prim_melee_type)); - update_values.push_back(columns[50] + " = " + std::to_string(npc_types_entry.sec_melee_type)); - update_values.push_back(columns[51] + " = " + std::to_string(npc_types_entry.ranged_type)); - update_values.push_back(columns[52] + " = " + std::to_string(npc_types_entry.runspeed)); - update_values.push_back(columns[53] + " = " + std::to_string(npc_types_entry.MR)); - update_values.push_back(columns[54] + " = " + std::to_string(npc_types_entry.CR)); - update_values.push_back(columns[55] + " = " + std::to_string(npc_types_entry.DR)); - update_values.push_back(columns[56] + " = " + std::to_string(npc_types_entry.FR)); - update_values.push_back(columns[57] + " = " + std::to_string(npc_types_entry.PR)); - update_values.push_back(columns[58] + " = " + std::to_string(npc_types_entry.Corrup)); - update_values.push_back(columns[59] + " = " + std::to_string(npc_types_entry.PhR)); - update_values.push_back(columns[60] + " = " + std::to_string(npc_types_entry.see_invis)); - update_values.push_back(columns[61] + " = " + std::to_string(npc_types_entry.see_invis_undead)); - update_values.push_back(columns[62] + " = " + std::to_string(npc_types_entry.qglobal)); - update_values.push_back(columns[63] + " = " + std::to_string(npc_types_entry.AC)); - update_values.push_back(columns[64] + " = " + std::to_string(npc_types_entry.npc_aggro)); - update_values.push_back(columns[65] + " = " + std::to_string(npc_types_entry.spawn_limit)); - update_values.push_back(columns[66] + " = " + std::to_string(npc_types_entry.attack_speed)); - update_values.push_back(columns[67] + " = " + std::to_string(npc_types_entry.attack_delay)); - update_values.push_back(columns[68] + " = " + std::to_string(npc_types_entry.findable)); - update_values.push_back(columns[69] + " = " + std::to_string(npc_types_entry.STR)); - update_values.push_back(columns[70] + " = " + std::to_string(npc_types_entry.STA)); - update_values.push_back(columns[71] + " = " + std::to_string(npc_types_entry.DEX)); - update_values.push_back(columns[72] + " = " + std::to_string(npc_types_entry.AGI)); - update_values.push_back(columns[73] + " = " + std::to_string(npc_types_entry._INT)); - update_values.push_back(columns[74] + " = " + std::to_string(npc_types_entry.WIS)); - update_values.push_back(columns[75] + " = " + std::to_string(npc_types_entry.CHA)); - update_values.push_back(columns[76] + " = " + std::to_string(npc_types_entry.see_hide)); - update_values.push_back(columns[77] + " = " + std::to_string(npc_types_entry.see_improved_hide)); - update_values.push_back(columns[78] + " = " + std::to_string(npc_types_entry.trackable)); - update_values.push_back(columns[79] + " = " + std::to_string(npc_types_entry.isbot)); - update_values.push_back(columns[80] + " = " + std::to_string(npc_types_entry.exclude)); - update_values.push_back(columns[81] + " = " + std::to_string(npc_types_entry.ATK)); - update_values.push_back(columns[82] + " = " + std::to_string(npc_types_entry.Accuracy)); - update_values.push_back(columns[83] + " = " + std::to_string(npc_types_entry.Avoidance)); - update_values.push_back(columns[84] + " = " + std::to_string(npc_types_entry.slow_mitigation)); - update_values.push_back(columns[85] + " = " + std::to_string(npc_types_entry.version)); - update_values.push_back(columns[86] + " = " + std::to_string(npc_types_entry.maxlevel)); - update_values.push_back(columns[87] + " = " + std::to_string(npc_types_entry.scalerate)); - update_values.push_back(columns[88] + " = " + std::to_string(npc_types_entry.private_corpse)); - update_values.push_back(columns[89] + " = " + std::to_string(npc_types_entry.unique_spawn_by_name)); - update_values.push_back(columns[90] + " = " + std::to_string(npc_types_entry.underwater)); - update_values.push_back(columns[91] + " = " + std::to_string(npc_types_entry.isquest)); - update_values.push_back(columns[92] + " = " + std::to_string(npc_types_entry.emoteid)); - update_values.push_back(columns[93] + " = " + std::to_string(npc_types_entry.spellscale)); - update_values.push_back(columns[94] + " = " + std::to_string(npc_types_entry.healscale)); - update_values.push_back(columns[95] + " = " + std::to_string(npc_types_entry.no_target_hotkey)); - update_values.push_back(columns[96] + " = " + std::to_string(npc_types_entry.raid_target)); - update_values.push_back(columns[97] + " = " + std::to_string(npc_types_entry.armtexture)); - update_values.push_back(columns[98] + " = " + std::to_string(npc_types_entry.bracertexture)); - update_values.push_back(columns[99] + " = " + std::to_string(npc_types_entry.handtexture)); - update_values.push_back(columns[100] + " = " + std::to_string(npc_types_entry.legtexture)); - update_values.push_back(columns[101] + " = " + std::to_string(npc_types_entry.feettexture)); - update_values.push_back(columns[102] + " = " + std::to_string(npc_types_entry.light)); - update_values.push_back(columns[103] + " = " + std::to_string(npc_types_entry.walkspeed)); - update_values.push_back(columns[104] + " = " + std::to_string(npc_types_entry.peqid)); - update_values.push_back(columns[105] + " = " + std::to_string(npc_types_entry.unique_)); - update_values.push_back(columns[106] + " = " + std::to_string(npc_types_entry.fixed)); - update_values.push_back(columns[107] + " = " + std::to_string(npc_types_entry.ignore_despawn)); - update_values.push_back(columns[108] + " = " + std::to_string(npc_types_entry.show_name)); - update_values.push_back(columns[109] + " = " + std::to_string(npc_types_entry.untargetable)); - update_values.push_back(columns[110] + " = " + std::to_string(npc_types_entry.charm_ac)); - update_values.push_back(columns[111] + " = " + std::to_string(npc_types_entry.charm_min_dmg)); - update_values.push_back(columns[112] + " = " + std::to_string(npc_types_entry.charm_max_dmg)); - update_values.push_back(columns[113] + " = " + std::to_string(npc_types_entry.charm_attack_delay)); - update_values.push_back(columns[114] + " = " + std::to_string(npc_types_entry.charm_accuracy_rating)); - update_values.push_back(columns[115] + " = " + std::to_string(npc_types_entry.charm_avoidance_rating)); - update_values.push_back(columns[116] + " = " + std::to_string(npc_types_entry.charm_atk)); - update_values.push_back(columns[117] + " = " + std::to_string(npc_types_entry.skip_global_loot)); - update_values.push_back(columns[118] + " = " + std::to_string(npc_types_entry.rare_spawn)); - update_values.push_back(columns[119] + " = " + std::to_string(npc_types_entry.stuck_behavior)); - update_values.push_back(columns[120] + " = " + std::to_string(npc_types_entry.model)); - update_values.push_back(columns[121] + " = " + std::to_string(npc_types_entry.flymode)); - update_values.push_back(columns[122] + " = " + std::to_string(npc_types_entry.always_aggro)); - update_values.push_back(columns[123] + " = " + std::to_string(npc_types_entry.exp_mod)); + v.push_back(columns[1] + " = '" + Strings::Escape(e.name) + "'"); + v.push_back(columns[2] + " = '" + Strings::Escape(e.lastname) + "'"); + v.push_back(columns[3] + " = " + std::to_string(e.level)); + v.push_back(columns[4] + " = " + std::to_string(e.race)); + v.push_back(columns[5] + " = " + std::to_string(e.class_)); + v.push_back(columns[6] + " = " + std::to_string(e.bodytype)); + v.push_back(columns[7] + " = " + std::to_string(e.hp)); + v.push_back(columns[8] + " = " + std::to_string(e.mana)); + v.push_back(columns[9] + " = " + std::to_string(e.gender)); + v.push_back(columns[10] + " = " + std::to_string(e.texture)); + v.push_back(columns[11] + " = " + std::to_string(e.helmtexture)); + v.push_back(columns[12] + " = " + std::to_string(e.herosforgemodel)); + v.push_back(columns[13] + " = " + std::to_string(e.size)); + v.push_back(columns[14] + " = " + std::to_string(e.hp_regen_rate)); + v.push_back(columns[15] + " = " + std::to_string(e.hp_regen_per_second)); + v.push_back(columns[16] + " = " + std::to_string(e.mana_regen_rate)); + v.push_back(columns[17] + " = " + std::to_string(e.loottable_id)); + v.push_back(columns[18] + " = " + std::to_string(e.merchant_id)); + v.push_back(columns[19] + " = " + std::to_string(e.alt_currency_id)); + v.push_back(columns[20] + " = " + std::to_string(e.npc_spells_id)); + v.push_back(columns[21] + " = " + std::to_string(e.npc_spells_effects_id)); + v.push_back(columns[22] + " = " + std::to_string(e.npc_faction_id)); + v.push_back(columns[23] + " = " + std::to_string(e.adventure_template_id)); + v.push_back(columns[24] + " = " + std::to_string(e.trap_template)); + v.push_back(columns[25] + " = " + std::to_string(e.mindmg)); + v.push_back(columns[26] + " = " + std::to_string(e.maxdmg)); + v.push_back(columns[27] + " = " + std::to_string(e.attack_count)); + v.push_back(columns[28] + " = '" + Strings::Escape(e.npcspecialattks) + "'"); + v.push_back(columns[29] + " = '" + Strings::Escape(e.special_abilities) + "'"); + v.push_back(columns[30] + " = " + std::to_string(e.aggroradius)); + v.push_back(columns[31] + " = " + std::to_string(e.assistradius)); + v.push_back(columns[32] + " = " + std::to_string(e.face)); + v.push_back(columns[33] + " = " + std::to_string(e.luclin_hairstyle)); + v.push_back(columns[34] + " = " + std::to_string(e.luclin_haircolor)); + v.push_back(columns[35] + " = " + std::to_string(e.luclin_eyecolor)); + v.push_back(columns[36] + " = " + std::to_string(e.luclin_eyecolor2)); + v.push_back(columns[37] + " = " + std::to_string(e.luclin_beardcolor)); + v.push_back(columns[38] + " = " + std::to_string(e.luclin_beard)); + v.push_back(columns[39] + " = " + std::to_string(e.drakkin_heritage)); + v.push_back(columns[40] + " = " + std::to_string(e.drakkin_tattoo)); + v.push_back(columns[41] + " = " + std::to_string(e.drakkin_details)); + v.push_back(columns[42] + " = " + std::to_string(e.armortint_id)); + v.push_back(columns[43] + " = " + std::to_string(e.armortint_red)); + v.push_back(columns[44] + " = " + std::to_string(e.armortint_green)); + v.push_back(columns[45] + " = " + std::to_string(e.armortint_blue)); + v.push_back(columns[46] + " = " + std::to_string(e.d_melee_texture1)); + v.push_back(columns[47] + " = " + std::to_string(e.d_melee_texture2)); + v.push_back(columns[48] + " = '" + Strings::Escape(e.ammo_idfile) + "'"); + v.push_back(columns[49] + " = " + std::to_string(e.prim_melee_type)); + v.push_back(columns[50] + " = " + std::to_string(e.sec_melee_type)); + v.push_back(columns[51] + " = " + std::to_string(e.ranged_type)); + v.push_back(columns[52] + " = " + std::to_string(e.runspeed)); + v.push_back(columns[53] + " = " + std::to_string(e.MR)); + v.push_back(columns[54] + " = " + std::to_string(e.CR)); + v.push_back(columns[55] + " = " + std::to_string(e.DR)); + v.push_back(columns[56] + " = " + std::to_string(e.FR)); + v.push_back(columns[57] + " = " + std::to_string(e.PR)); + v.push_back(columns[58] + " = " + std::to_string(e.Corrup)); + v.push_back(columns[59] + " = " + std::to_string(e.PhR)); + v.push_back(columns[60] + " = " + std::to_string(e.see_invis)); + v.push_back(columns[61] + " = " + std::to_string(e.see_invis_undead)); + v.push_back(columns[62] + " = " + std::to_string(e.qglobal)); + v.push_back(columns[63] + " = " + std::to_string(e.AC)); + v.push_back(columns[64] + " = " + std::to_string(e.npc_aggro)); + v.push_back(columns[65] + " = " + std::to_string(e.spawn_limit)); + v.push_back(columns[66] + " = " + std::to_string(e.attack_speed)); + v.push_back(columns[67] + " = " + std::to_string(e.attack_delay)); + v.push_back(columns[68] + " = " + std::to_string(e.findable)); + v.push_back(columns[69] + " = " + std::to_string(e.STR)); + v.push_back(columns[70] + " = " + std::to_string(e.STA)); + v.push_back(columns[71] + " = " + std::to_string(e.DEX)); + v.push_back(columns[72] + " = " + std::to_string(e.AGI)); + v.push_back(columns[73] + " = " + std::to_string(e._INT)); + v.push_back(columns[74] + " = " + std::to_string(e.WIS)); + v.push_back(columns[75] + " = " + std::to_string(e.CHA)); + v.push_back(columns[76] + " = " + std::to_string(e.see_hide)); + v.push_back(columns[77] + " = " + std::to_string(e.see_improved_hide)); + v.push_back(columns[78] + " = " + std::to_string(e.trackable)); + v.push_back(columns[79] + " = " + std::to_string(e.isbot)); + v.push_back(columns[80] + " = " + std::to_string(e.exclude)); + v.push_back(columns[81] + " = " + std::to_string(e.ATK)); + v.push_back(columns[82] + " = " + std::to_string(e.Accuracy)); + v.push_back(columns[83] + " = " + std::to_string(e.Avoidance)); + v.push_back(columns[84] + " = " + std::to_string(e.slow_mitigation)); + v.push_back(columns[85] + " = " + std::to_string(e.version)); + v.push_back(columns[86] + " = " + std::to_string(e.maxlevel)); + v.push_back(columns[87] + " = " + std::to_string(e.scalerate)); + v.push_back(columns[88] + " = " + std::to_string(e.private_corpse)); + v.push_back(columns[89] + " = " + std::to_string(e.unique_spawn_by_name)); + v.push_back(columns[90] + " = " + std::to_string(e.underwater)); + v.push_back(columns[91] + " = " + std::to_string(e.isquest)); + v.push_back(columns[92] + " = " + std::to_string(e.emoteid)); + v.push_back(columns[93] + " = " + std::to_string(e.spellscale)); + v.push_back(columns[94] + " = " + std::to_string(e.healscale)); + v.push_back(columns[95] + " = " + std::to_string(e.no_target_hotkey)); + v.push_back(columns[96] + " = " + std::to_string(e.raid_target)); + v.push_back(columns[97] + " = " + std::to_string(e.armtexture)); + v.push_back(columns[98] + " = " + std::to_string(e.bracertexture)); + v.push_back(columns[99] + " = " + std::to_string(e.handtexture)); + v.push_back(columns[100] + " = " + std::to_string(e.legtexture)); + v.push_back(columns[101] + " = " + std::to_string(e.feettexture)); + v.push_back(columns[102] + " = " + std::to_string(e.light)); + v.push_back(columns[103] + " = " + std::to_string(e.walkspeed)); + v.push_back(columns[104] + " = " + std::to_string(e.peqid)); + v.push_back(columns[105] + " = " + std::to_string(e.unique_)); + v.push_back(columns[106] + " = " + std::to_string(e.fixed)); + v.push_back(columns[107] + " = " + std::to_string(e.ignore_despawn)); + v.push_back(columns[108] + " = " + std::to_string(e.show_name)); + v.push_back(columns[109] + " = " + std::to_string(e.untargetable)); + v.push_back(columns[110] + " = " + std::to_string(e.charm_ac)); + v.push_back(columns[111] + " = " + std::to_string(e.charm_min_dmg)); + v.push_back(columns[112] + " = " + std::to_string(e.charm_max_dmg)); + v.push_back(columns[113] + " = " + std::to_string(e.charm_attack_delay)); + v.push_back(columns[114] + " = " + std::to_string(e.charm_accuracy_rating)); + v.push_back(columns[115] + " = " + std::to_string(e.charm_avoidance_rating)); + v.push_back(columns[116] + " = " + std::to_string(e.charm_atk)); + v.push_back(columns[117] + " = " + std::to_string(e.skip_global_loot)); + v.push_back(columns[118] + " = " + std::to_string(e.rare_spawn)); + v.push_back(columns[119] + " = " + std::to_string(e.stuck_behavior)); + v.push_back(columns[120] + " = " + std::to_string(e.model)); + v.push_back(columns[121] + " = " + std::to_string(e.flymode)); + v.push_back(columns[122] + " = " + std::to_string(e.always_aggro)); + v.push_back(columns[123] + " = " + std::to_string(e.exp_mod)); auto results = db.QueryDatabase( fmt::format( "UPDATE {} SET {} WHERE {} = {}", TableName(), - Strings::Implode(", ", update_values), + Strings::Implode(", ", v), PrimaryKey(), - npc_types_entry.id + e.id ) ); @@ -902,293 +902,293 @@ public: static NpcTypes InsertOne( Database& db, - NpcTypes npc_types_entry + NpcTypes e ) { - std::vector insert_values; + std::vector v; - insert_values.push_back(std::to_string(npc_types_entry.id)); - insert_values.push_back("'" + Strings::Escape(npc_types_entry.name) + "'"); - insert_values.push_back("'" + Strings::Escape(npc_types_entry.lastname) + "'"); - insert_values.push_back(std::to_string(npc_types_entry.level)); - insert_values.push_back(std::to_string(npc_types_entry.race)); - insert_values.push_back(std::to_string(npc_types_entry.class_)); - insert_values.push_back(std::to_string(npc_types_entry.bodytype)); - insert_values.push_back(std::to_string(npc_types_entry.hp)); - insert_values.push_back(std::to_string(npc_types_entry.mana)); - insert_values.push_back(std::to_string(npc_types_entry.gender)); - insert_values.push_back(std::to_string(npc_types_entry.texture)); - insert_values.push_back(std::to_string(npc_types_entry.helmtexture)); - insert_values.push_back(std::to_string(npc_types_entry.herosforgemodel)); - insert_values.push_back(std::to_string(npc_types_entry.size)); - insert_values.push_back(std::to_string(npc_types_entry.hp_regen_rate)); - insert_values.push_back(std::to_string(npc_types_entry.hp_regen_per_second)); - insert_values.push_back(std::to_string(npc_types_entry.mana_regen_rate)); - insert_values.push_back(std::to_string(npc_types_entry.loottable_id)); - insert_values.push_back(std::to_string(npc_types_entry.merchant_id)); - insert_values.push_back(std::to_string(npc_types_entry.alt_currency_id)); - insert_values.push_back(std::to_string(npc_types_entry.npc_spells_id)); - insert_values.push_back(std::to_string(npc_types_entry.npc_spells_effects_id)); - insert_values.push_back(std::to_string(npc_types_entry.npc_faction_id)); - insert_values.push_back(std::to_string(npc_types_entry.adventure_template_id)); - insert_values.push_back(std::to_string(npc_types_entry.trap_template)); - insert_values.push_back(std::to_string(npc_types_entry.mindmg)); - insert_values.push_back(std::to_string(npc_types_entry.maxdmg)); - insert_values.push_back(std::to_string(npc_types_entry.attack_count)); - insert_values.push_back("'" + Strings::Escape(npc_types_entry.npcspecialattks) + "'"); - insert_values.push_back("'" + Strings::Escape(npc_types_entry.special_abilities) + "'"); - insert_values.push_back(std::to_string(npc_types_entry.aggroradius)); - insert_values.push_back(std::to_string(npc_types_entry.assistradius)); - insert_values.push_back(std::to_string(npc_types_entry.face)); - insert_values.push_back(std::to_string(npc_types_entry.luclin_hairstyle)); - insert_values.push_back(std::to_string(npc_types_entry.luclin_haircolor)); - insert_values.push_back(std::to_string(npc_types_entry.luclin_eyecolor)); - insert_values.push_back(std::to_string(npc_types_entry.luclin_eyecolor2)); - insert_values.push_back(std::to_string(npc_types_entry.luclin_beardcolor)); - insert_values.push_back(std::to_string(npc_types_entry.luclin_beard)); - insert_values.push_back(std::to_string(npc_types_entry.drakkin_heritage)); - insert_values.push_back(std::to_string(npc_types_entry.drakkin_tattoo)); - insert_values.push_back(std::to_string(npc_types_entry.drakkin_details)); - insert_values.push_back(std::to_string(npc_types_entry.armortint_id)); - insert_values.push_back(std::to_string(npc_types_entry.armortint_red)); - insert_values.push_back(std::to_string(npc_types_entry.armortint_green)); - insert_values.push_back(std::to_string(npc_types_entry.armortint_blue)); - insert_values.push_back(std::to_string(npc_types_entry.d_melee_texture1)); - insert_values.push_back(std::to_string(npc_types_entry.d_melee_texture2)); - insert_values.push_back("'" + Strings::Escape(npc_types_entry.ammo_idfile) + "'"); - insert_values.push_back(std::to_string(npc_types_entry.prim_melee_type)); - insert_values.push_back(std::to_string(npc_types_entry.sec_melee_type)); - insert_values.push_back(std::to_string(npc_types_entry.ranged_type)); - insert_values.push_back(std::to_string(npc_types_entry.runspeed)); - insert_values.push_back(std::to_string(npc_types_entry.MR)); - insert_values.push_back(std::to_string(npc_types_entry.CR)); - insert_values.push_back(std::to_string(npc_types_entry.DR)); - insert_values.push_back(std::to_string(npc_types_entry.FR)); - insert_values.push_back(std::to_string(npc_types_entry.PR)); - insert_values.push_back(std::to_string(npc_types_entry.Corrup)); - insert_values.push_back(std::to_string(npc_types_entry.PhR)); - insert_values.push_back(std::to_string(npc_types_entry.see_invis)); - insert_values.push_back(std::to_string(npc_types_entry.see_invis_undead)); - insert_values.push_back(std::to_string(npc_types_entry.qglobal)); - insert_values.push_back(std::to_string(npc_types_entry.AC)); - insert_values.push_back(std::to_string(npc_types_entry.npc_aggro)); - insert_values.push_back(std::to_string(npc_types_entry.spawn_limit)); - insert_values.push_back(std::to_string(npc_types_entry.attack_speed)); - insert_values.push_back(std::to_string(npc_types_entry.attack_delay)); - insert_values.push_back(std::to_string(npc_types_entry.findable)); - insert_values.push_back(std::to_string(npc_types_entry.STR)); - insert_values.push_back(std::to_string(npc_types_entry.STA)); - insert_values.push_back(std::to_string(npc_types_entry.DEX)); - insert_values.push_back(std::to_string(npc_types_entry.AGI)); - insert_values.push_back(std::to_string(npc_types_entry._INT)); - insert_values.push_back(std::to_string(npc_types_entry.WIS)); - insert_values.push_back(std::to_string(npc_types_entry.CHA)); - insert_values.push_back(std::to_string(npc_types_entry.see_hide)); - insert_values.push_back(std::to_string(npc_types_entry.see_improved_hide)); - insert_values.push_back(std::to_string(npc_types_entry.trackable)); - insert_values.push_back(std::to_string(npc_types_entry.isbot)); - insert_values.push_back(std::to_string(npc_types_entry.exclude)); - insert_values.push_back(std::to_string(npc_types_entry.ATK)); - insert_values.push_back(std::to_string(npc_types_entry.Accuracy)); - insert_values.push_back(std::to_string(npc_types_entry.Avoidance)); - insert_values.push_back(std::to_string(npc_types_entry.slow_mitigation)); - insert_values.push_back(std::to_string(npc_types_entry.version)); - insert_values.push_back(std::to_string(npc_types_entry.maxlevel)); - insert_values.push_back(std::to_string(npc_types_entry.scalerate)); - insert_values.push_back(std::to_string(npc_types_entry.private_corpse)); - insert_values.push_back(std::to_string(npc_types_entry.unique_spawn_by_name)); - insert_values.push_back(std::to_string(npc_types_entry.underwater)); - insert_values.push_back(std::to_string(npc_types_entry.isquest)); - insert_values.push_back(std::to_string(npc_types_entry.emoteid)); - insert_values.push_back(std::to_string(npc_types_entry.spellscale)); - insert_values.push_back(std::to_string(npc_types_entry.healscale)); - insert_values.push_back(std::to_string(npc_types_entry.no_target_hotkey)); - insert_values.push_back(std::to_string(npc_types_entry.raid_target)); - insert_values.push_back(std::to_string(npc_types_entry.armtexture)); - insert_values.push_back(std::to_string(npc_types_entry.bracertexture)); - insert_values.push_back(std::to_string(npc_types_entry.handtexture)); - insert_values.push_back(std::to_string(npc_types_entry.legtexture)); - insert_values.push_back(std::to_string(npc_types_entry.feettexture)); - insert_values.push_back(std::to_string(npc_types_entry.light)); - insert_values.push_back(std::to_string(npc_types_entry.walkspeed)); - insert_values.push_back(std::to_string(npc_types_entry.peqid)); - insert_values.push_back(std::to_string(npc_types_entry.unique_)); - insert_values.push_back(std::to_string(npc_types_entry.fixed)); - insert_values.push_back(std::to_string(npc_types_entry.ignore_despawn)); - insert_values.push_back(std::to_string(npc_types_entry.show_name)); - insert_values.push_back(std::to_string(npc_types_entry.untargetable)); - insert_values.push_back(std::to_string(npc_types_entry.charm_ac)); - insert_values.push_back(std::to_string(npc_types_entry.charm_min_dmg)); - insert_values.push_back(std::to_string(npc_types_entry.charm_max_dmg)); - insert_values.push_back(std::to_string(npc_types_entry.charm_attack_delay)); - insert_values.push_back(std::to_string(npc_types_entry.charm_accuracy_rating)); - insert_values.push_back(std::to_string(npc_types_entry.charm_avoidance_rating)); - insert_values.push_back(std::to_string(npc_types_entry.charm_atk)); - insert_values.push_back(std::to_string(npc_types_entry.skip_global_loot)); - insert_values.push_back(std::to_string(npc_types_entry.rare_spawn)); - insert_values.push_back(std::to_string(npc_types_entry.stuck_behavior)); - insert_values.push_back(std::to_string(npc_types_entry.model)); - insert_values.push_back(std::to_string(npc_types_entry.flymode)); - insert_values.push_back(std::to_string(npc_types_entry.always_aggro)); - insert_values.push_back(std::to_string(npc_types_entry.exp_mod)); + v.push_back(std::to_string(e.id)); + v.push_back("'" + Strings::Escape(e.name) + "'"); + v.push_back("'" + Strings::Escape(e.lastname) + "'"); + v.push_back(std::to_string(e.level)); + v.push_back(std::to_string(e.race)); + v.push_back(std::to_string(e.class_)); + v.push_back(std::to_string(e.bodytype)); + v.push_back(std::to_string(e.hp)); + v.push_back(std::to_string(e.mana)); + v.push_back(std::to_string(e.gender)); + v.push_back(std::to_string(e.texture)); + v.push_back(std::to_string(e.helmtexture)); + v.push_back(std::to_string(e.herosforgemodel)); + v.push_back(std::to_string(e.size)); + v.push_back(std::to_string(e.hp_regen_rate)); + v.push_back(std::to_string(e.hp_regen_per_second)); + v.push_back(std::to_string(e.mana_regen_rate)); + v.push_back(std::to_string(e.loottable_id)); + v.push_back(std::to_string(e.merchant_id)); + v.push_back(std::to_string(e.alt_currency_id)); + v.push_back(std::to_string(e.npc_spells_id)); + v.push_back(std::to_string(e.npc_spells_effects_id)); + v.push_back(std::to_string(e.npc_faction_id)); + v.push_back(std::to_string(e.adventure_template_id)); + v.push_back(std::to_string(e.trap_template)); + v.push_back(std::to_string(e.mindmg)); + v.push_back(std::to_string(e.maxdmg)); + v.push_back(std::to_string(e.attack_count)); + v.push_back("'" + Strings::Escape(e.npcspecialattks) + "'"); + v.push_back("'" + Strings::Escape(e.special_abilities) + "'"); + v.push_back(std::to_string(e.aggroradius)); + v.push_back(std::to_string(e.assistradius)); + v.push_back(std::to_string(e.face)); + v.push_back(std::to_string(e.luclin_hairstyle)); + v.push_back(std::to_string(e.luclin_haircolor)); + v.push_back(std::to_string(e.luclin_eyecolor)); + v.push_back(std::to_string(e.luclin_eyecolor2)); + v.push_back(std::to_string(e.luclin_beardcolor)); + v.push_back(std::to_string(e.luclin_beard)); + v.push_back(std::to_string(e.drakkin_heritage)); + v.push_back(std::to_string(e.drakkin_tattoo)); + v.push_back(std::to_string(e.drakkin_details)); + v.push_back(std::to_string(e.armortint_id)); + v.push_back(std::to_string(e.armortint_red)); + v.push_back(std::to_string(e.armortint_green)); + v.push_back(std::to_string(e.armortint_blue)); + v.push_back(std::to_string(e.d_melee_texture1)); + v.push_back(std::to_string(e.d_melee_texture2)); + v.push_back("'" + Strings::Escape(e.ammo_idfile) + "'"); + v.push_back(std::to_string(e.prim_melee_type)); + v.push_back(std::to_string(e.sec_melee_type)); + v.push_back(std::to_string(e.ranged_type)); + v.push_back(std::to_string(e.runspeed)); + v.push_back(std::to_string(e.MR)); + v.push_back(std::to_string(e.CR)); + v.push_back(std::to_string(e.DR)); + v.push_back(std::to_string(e.FR)); + v.push_back(std::to_string(e.PR)); + v.push_back(std::to_string(e.Corrup)); + v.push_back(std::to_string(e.PhR)); + v.push_back(std::to_string(e.see_invis)); + v.push_back(std::to_string(e.see_invis_undead)); + v.push_back(std::to_string(e.qglobal)); + v.push_back(std::to_string(e.AC)); + v.push_back(std::to_string(e.npc_aggro)); + v.push_back(std::to_string(e.spawn_limit)); + v.push_back(std::to_string(e.attack_speed)); + v.push_back(std::to_string(e.attack_delay)); + v.push_back(std::to_string(e.findable)); + v.push_back(std::to_string(e.STR)); + v.push_back(std::to_string(e.STA)); + v.push_back(std::to_string(e.DEX)); + v.push_back(std::to_string(e.AGI)); + v.push_back(std::to_string(e._INT)); + v.push_back(std::to_string(e.WIS)); + v.push_back(std::to_string(e.CHA)); + v.push_back(std::to_string(e.see_hide)); + v.push_back(std::to_string(e.see_improved_hide)); + v.push_back(std::to_string(e.trackable)); + v.push_back(std::to_string(e.isbot)); + v.push_back(std::to_string(e.exclude)); + v.push_back(std::to_string(e.ATK)); + v.push_back(std::to_string(e.Accuracy)); + v.push_back(std::to_string(e.Avoidance)); + v.push_back(std::to_string(e.slow_mitigation)); + v.push_back(std::to_string(e.version)); + v.push_back(std::to_string(e.maxlevel)); + v.push_back(std::to_string(e.scalerate)); + v.push_back(std::to_string(e.private_corpse)); + v.push_back(std::to_string(e.unique_spawn_by_name)); + v.push_back(std::to_string(e.underwater)); + v.push_back(std::to_string(e.isquest)); + v.push_back(std::to_string(e.emoteid)); + v.push_back(std::to_string(e.spellscale)); + v.push_back(std::to_string(e.healscale)); + v.push_back(std::to_string(e.no_target_hotkey)); + v.push_back(std::to_string(e.raid_target)); + v.push_back(std::to_string(e.armtexture)); + v.push_back(std::to_string(e.bracertexture)); + v.push_back(std::to_string(e.handtexture)); + v.push_back(std::to_string(e.legtexture)); + v.push_back(std::to_string(e.feettexture)); + v.push_back(std::to_string(e.light)); + v.push_back(std::to_string(e.walkspeed)); + v.push_back(std::to_string(e.peqid)); + v.push_back(std::to_string(e.unique_)); + v.push_back(std::to_string(e.fixed)); + v.push_back(std::to_string(e.ignore_despawn)); + v.push_back(std::to_string(e.show_name)); + v.push_back(std::to_string(e.untargetable)); + v.push_back(std::to_string(e.charm_ac)); + v.push_back(std::to_string(e.charm_min_dmg)); + v.push_back(std::to_string(e.charm_max_dmg)); + v.push_back(std::to_string(e.charm_attack_delay)); + v.push_back(std::to_string(e.charm_accuracy_rating)); + v.push_back(std::to_string(e.charm_avoidance_rating)); + v.push_back(std::to_string(e.charm_atk)); + v.push_back(std::to_string(e.skip_global_loot)); + v.push_back(std::to_string(e.rare_spawn)); + v.push_back(std::to_string(e.stuck_behavior)); + v.push_back(std::to_string(e.model)); + v.push_back(std::to_string(e.flymode)); + v.push_back(std::to_string(e.always_aggro)); + v.push_back(std::to_string(e.exp_mod)); auto results = db.QueryDatabase( fmt::format( "{} VALUES ({})", BaseInsert(), - Strings::Implode(",", insert_values) + Strings::Implode(",", v) ) ); if (results.Success()) { - npc_types_entry.id = results.LastInsertedID(); - return npc_types_entry; + e.id = results.LastInsertedID(); + return e; } - npc_types_entry = NewEntity(); + e = NewEntity(); - return npc_types_entry; + return e; } static int InsertMany( Database& db, - std::vector npc_types_entries + const std::vector &entries ) { std::vector insert_chunks; - for (auto &npc_types_entry: npc_types_entries) { - std::vector insert_values; + for (auto &e: entries) { + std::vector v; - insert_values.push_back(std::to_string(npc_types_entry.id)); - insert_values.push_back("'" + Strings::Escape(npc_types_entry.name) + "'"); - insert_values.push_back("'" + Strings::Escape(npc_types_entry.lastname) + "'"); - insert_values.push_back(std::to_string(npc_types_entry.level)); - insert_values.push_back(std::to_string(npc_types_entry.race)); - insert_values.push_back(std::to_string(npc_types_entry.class_)); - insert_values.push_back(std::to_string(npc_types_entry.bodytype)); - insert_values.push_back(std::to_string(npc_types_entry.hp)); - insert_values.push_back(std::to_string(npc_types_entry.mana)); - insert_values.push_back(std::to_string(npc_types_entry.gender)); - insert_values.push_back(std::to_string(npc_types_entry.texture)); - insert_values.push_back(std::to_string(npc_types_entry.helmtexture)); - insert_values.push_back(std::to_string(npc_types_entry.herosforgemodel)); - insert_values.push_back(std::to_string(npc_types_entry.size)); - insert_values.push_back(std::to_string(npc_types_entry.hp_regen_rate)); - insert_values.push_back(std::to_string(npc_types_entry.hp_regen_per_second)); - insert_values.push_back(std::to_string(npc_types_entry.mana_regen_rate)); - insert_values.push_back(std::to_string(npc_types_entry.loottable_id)); - insert_values.push_back(std::to_string(npc_types_entry.merchant_id)); - insert_values.push_back(std::to_string(npc_types_entry.alt_currency_id)); - insert_values.push_back(std::to_string(npc_types_entry.npc_spells_id)); - insert_values.push_back(std::to_string(npc_types_entry.npc_spells_effects_id)); - insert_values.push_back(std::to_string(npc_types_entry.npc_faction_id)); - insert_values.push_back(std::to_string(npc_types_entry.adventure_template_id)); - insert_values.push_back(std::to_string(npc_types_entry.trap_template)); - insert_values.push_back(std::to_string(npc_types_entry.mindmg)); - insert_values.push_back(std::to_string(npc_types_entry.maxdmg)); - insert_values.push_back(std::to_string(npc_types_entry.attack_count)); - insert_values.push_back("'" + Strings::Escape(npc_types_entry.npcspecialattks) + "'"); - insert_values.push_back("'" + Strings::Escape(npc_types_entry.special_abilities) + "'"); - insert_values.push_back(std::to_string(npc_types_entry.aggroradius)); - insert_values.push_back(std::to_string(npc_types_entry.assistradius)); - insert_values.push_back(std::to_string(npc_types_entry.face)); - insert_values.push_back(std::to_string(npc_types_entry.luclin_hairstyle)); - insert_values.push_back(std::to_string(npc_types_entry.luclin_haircolor)); - insert_values.push_back(std::to_string(npc_types_entry.luclin_eyecolor)); - insert_values.push_back(std::to_string(npc_types_entry.luclin_eyecolor2)); - insert_values.push_back(std::to_string(npc_types_entry.luclin_beardcolor)); - insert_values.push_back(std::to_string(npc_types_entry.luclin_beard)); - insert_values.push_back(std::to_string(npc_types_entry.drakkin_heritage)); - insert_values.push_back(std::to_string(npc_types_entry.drakkin_tattoo)); - insert_values.push_back(std::to_string(npc_types_entry.drakkin_details)); - insert_values.push_back(std::to_string(npc_types_entry.armortint_id)); - insert_values.push_back(std::to_string(npc_types_entry.armortint_red)); - insert_values.push_back(std::to_string(npc_types_entry.armortint_green)); - insert_values.push_back(std::to_string(npc_types_entry.armortint_blue)); - insert_values.push_back(std::to_string(npc_types_entry.d_melee_texture1)); - insert_values.push_back(std::to_string(npc_types_entry.d_melee_texture2)); - insert_values.push_back("'" + Strings::Escape(npc_types_entry.ammo_idfile) + "'"); - insert_values.push_back(std::to_string(npc_types_entry.prim_melee_type)); - insert_values.push_back(std::to_string(npc_types_entry.sec_melee_type)); - insert_values.push_back(std::to_string(npc_types_entry.ranged_type)); - insert_values.push_back(std::to_string(npc_types_entry.runspeed)); - insert_values.push_back(std::to_string(npc_types_entry.MR)); - insert_values.push_back(std::to_string(npc_types_entry.CR)); - insert_values.push_back(std::to_string(npc_types_entry.DR)); - insert_values.push_back(std::to_string(npc_types_entry.FR)); - insert_values.push_back(std::to_string(npc_types_entry.PR)); - insert_values.push_back(std::to_string(npc_types_entry.Corrup)); - insert_values.push_back(std::to_string(npc_types_entry.PhR)); - insert_values.push_back(std::to_string(npc_types_entry.see_invis)); - insert_values.push_back(std::to_string(npc_types_entry.see_invis_undead)); - insert_values.push_back(std::to_string(npc_types_entry.qglobal)); - insert_values.push_back(std::to_string(npc_types_entry.AC)); - insert_values.push_back(std::to_string(npc_types_entry.npc_aggro)); - insert_values.push_back(std::to_string(npc_types_entry.spawn_limit)); - insert_values.push_back(std::to_string(npc_types_entry.attack_speed)); - insert_values.push_back(std::to_string(npc_types_entry.attack_delay)); - insert_values.push_back(std::to_string(npc_types_entry.findable)); - insert_values.push_back(std::to_string(npc_types_entry.STR)); - insert_values.push_back(std::to_string(npc_types_entry.STA)); - insert_values.push_back(std::to_string(npc_types_entry.DEX)); - insert_values.push_back(std::to_string(npc_types_entry.AGI)); - insert_values.push_back(std::to_string(npc_types_entry._INT)); - insert_values.push_back(std::to_string(npc_types_entry.WIS)); - insert_values.push_back(std::to_string(npc_types_entry.CHA)); - insert_values.push_back(std::to_string(npc_types_entry.see_hide)); - insert_values.push_back(std::to_string(npc_types_entry.see_improved_hide)); - insert_values.push_back(std::to_string(npc_types_entry.trackable)); - insert_values.push_back(std::to_string(npc_types_entry.isbot)); - insert_values.push_back(std::to_string(npc_types_entry.exclude)); - insert_values.push_back(std::to_string(npc_types_entry.ATK)); - insert_values.push_back(std::to_string(npc_types_entry.Accuracy)); - insert_values.push_back(std::to_string(npc_types_entry.Avoidance)); - insert_values.push_back(std::to_string(npc_types_entry.slow_mitigation)); - insert_values.push_back(std::to_string(npc_types_entry.version)); - insert_values.push_back(std::to_string(npc_types_entry.maxlevel)); - insert_values.push_back(std::to_string(npc_types_entry.scalerate)); - insert_values.push_back(std::to_string(npc_types_entry.private_corpse)); - insert_values.push_back(std::to_string(npc_types_entry.unique_spawn_by_name)); - insert_values.push_back(std::to_string(npc_types_entry.underwater)); - insert_values.push_back(std::to_string(npc_types_entry.isquest)); - insert_values.push_back(std::to_string(npc_types_entry.emoteid)); - insert_values.push_back(std::to_string(npc_types_entry.spellscale)); - insert_values.push_back(std::to_string(npc_types_entry.healscale)); - insert_values.push_back(std::to_string(npc_types_entry.no_target_hotkey)); - insert_values.push_back(std::to_string(npc_types_entry.raid_target)); - insert_values.push_back(std::to_string(npc_types_entry.armtexture)); - insert_values.push_back(std::to_string(npc_types_entry.bracertexture)); - insert_values.push_back(std::to_string(npc_types_entry.handtexture)); - insert_values.push_back(std::to_string(npc_types_entry.legtexture)); - insert_values.push_back(std::to_string(npc_types_entry.feettexture)); - insert_values.push_back(std::to_string(npc_types_entry.light)); - insert_values.push_back(std::to_string(npc_types_entry.walkspeed)); - insert_values.push_back(std::to_string(npc_types_entry.peqid)); - insert_values.push_back(std::to_string(npc_types_entry.unique_)); - insert_values.push_back(std::to_string(npc_types_entry.fixed)); - insert_values.push_back(std::to_string(npc_types_entry.ignore_despawn)); - insert_values.push_back(std::to_string(npc_types_entry.show_name)); - insert_values.push_back(std::to_string(npc_types_entry.untargetable)); - insert_values.push_back(std::to_string(npc_types_entry.charm_ac)); - insert_values.push_back(std::to_string(npc_types_entry.charm_min_dmg)); - insert_values.push_back(std::to_string(npc_types_entry.charm_max_dmg)); - insert_values.push_back(std::to_string(npc_types_entry.charm_attack_delay)); - insert_values.push_back(std::to_string(npc_types_entry.charm_accuracy_rating)); - insert_values.push_back(std::to_string(npc_types_entry.charm_avoidance_rating)); - insert_values.push_back(std::to_string(npc_types_entry.charm_atk)); - insert_values.push_back(std::to_string(npc_types_entry.skip_global_loot)); - insert_values.push_back(std::to_string(npc_types_entry.rare_spawn)); - insert_values.push_back(std::to_string(npc_types_entry.stuck_behavior)); - insert_values.push_back(std::to_string(npc_types_entry.model)); - insert_values.push_back(std::to_string(npc_types_entry.flymode)); - insert_values.push_back(std::to_string(npc_types_entry.always_aggro)); - insert_values.push_back(std::to_string(npc_types_entry.exp_mod)); + v.push_back(std::to_string(e.id)); + v.push_back("'" + Strings::Escape(e.name) + "'"); + v.push_back("'" + Strings::Escape(e.lastname) + "'"); + v.push_back(std::to_string(e.level)); + v.push_back(std::to_string(e.race)); + v.push_back(std::to_string(e.class_)); + v.push_back(std::to_string(e.bodytype)); + v.push_back(std::to_string(e.hp)); + v.push_back(std::to_string(e.mana)); + v.push_back(std::to_string(e.gender)); + v.push_back(std::to_string(e.texture)); + v.push_back(std::to_string(e.helmtexture)); + v.push_back(std::to_string(e.herosforgemodel)); + v.push_back(std::to_string(e.size)); + v.push_back(std::to_string(e.hp_regen_rate)); + v.push_back(std::to_string(e.hp_regen_per_second)); + v.push_back(std::to_string(e.mana_regen_rate)); + v.push_back(std::to_string(e.loottable_id)); + v.push_back(std::to_string(e.merchant_id)); + v.push_back(std::to_string(e.alt_currency_id)); + v.push_back(std::to_string(e.npc_spells_id)); + v.push_back(std::to_string(e.npc_spells_effects_id)); + v.push_back(std::to_string(e.npc_faction_id)); + v.push_back(std::to_string(e.adventure_template_id)); + v.push_back(std::to_string(e.trap_template)); + v.push_back(std::to_string(e.mindmg)); + v.push_back(std::to_string(e.maxdmg)); + v.push_back(std::to_string(e.attack_count)); + v.push_back("'" + Strings::Escape(e.npcspecialattks) + "'"); + v.push_back("'" + Strings::Escape(e.special_abilities) + "'"); + v.push_back(std::to_string(e.aggroradius)); + v.push_back(std::to_string(e.assistradius)); + v.push_back(std::to_string(e.face)); + v.push_back(std::to_string(e.luclin_hairstyle)); + v.push_back(std::to_string(e.luclin_haircolor)); + v.push_back(std::to_string(e.luclin_eyecolor)); + v.push_back(std::to_string(e.luclin_eyecolor2)); + v.push_back(std::to_string(e.luclin_beardcolor)); + v.push_back(std::to_string(e.luclin_beard)); + v.push_back(std::to_string(e.drakkin_heritage)); + v.push_back(std::to_string(e.drakkin_tattoo)); + v.push_back(std::to_string(e.drakkin_details)); + v.push_back(std::to_string(e.armortint_id)); + v.push_back(std::to_string(e.armortint_red)); + v.push_back(std::to_string(e.armortint_green)); + v.push_back(std::to_string(e.armortint_blue)); + v.push_back(std::to_string(e.d_melee_texture1)); + v.push_back(std::to_string(e.d_melee_texture2)); + v.push_back("'" + Strings::Escape(e.ammo_idfile) + "'"); + v.push_back(std::to_string(e.prim_melee_type)); + v.push_back(std::to_string(e.sec_melee_type)); + v.push_back(std::to_string(e.ranged_type)); + v.push_back(std::to_string(e.runspeed)); + v.push_back(std::to_string(e.MR)); + v.push_back(std::to_string(e.CR)); + v.push_back(std::to_string(e.DR)); + v.push_back(std::to_string(e.FR)); + v.push_back(std::to_string(e.PR)); + v.push_back(std::to_string(e.Corrup)); + v.push_back(std::to_string(e.PhR)); + v.push_back(std::to_string(e.see_invis)); + v.push_back(std::to_string(e.see_invis_undead)); + v.push_back(std::to_string(e.qglobal)); + v.push_back(std::to_string(e.AC)); + v.push_back(std::to_string(e.npc_aggro)); + v.push_back(std::to_string(e.spawn_limit)); + v.push_back(std::to_string(e.attack_speed)); + v.push_back(std::to_string(e.attack_delay)); + v.push_back(std::to_string(e.findable)); + v.push_back(std::to_string(e.STR)); + v.push_back(std::to_string(e.STA)); + v.push_back(std::to_string(e.DEX)); + v.push_back(std::to_string(e.AGI)); + v.push_back(std::to_string(e._INT)); + v.push_back(std::to_string(e.WIS)); + v.push_back(std::to_string(e.CHA)); + v.push_back(std::to_string(e.see_hide)); + v.push_back(std::to_string(e.see_improved_hide)); + v.push_back(std::to_string(e.trackable)); + v.push_back(std::to_string(e.isbot)); + v.push_back(std::to_string(e.exclude)); + v.push_back(std::to_string(e.ATK)); + v.push_back(std::to_string(e.Accuracy)); + v.push_back(std::to_string(e.Avoidance)); + v.push_back(std::to_string(e.slow_mitigation)); + v.push_back(std::to_string(e.version)); + v.push_back(std::to_string(e.maxlevel)); + v.push_back(std::to_string(e.scalerate)); + v.push_back(std::to_string(e.private_corpse)); + v.push_back(std::to_string(e.unique_spawn_by_name)); + v.push_back(std::to_string(e.underwater)); + v.push_back(std::to_string(e.isquest)); + v.push_back(std::to_string(e.emoteid)); + v.push_back(std::to_string(e.spellscale)); + v.push_back(std::to_string(e.healscale)); + v.push_back(std::to_string(e.no_target_hotkey)); + v.push_back(std::to_string(e.raid_target)); + v.push_back(std::to_string(e.armtexture)); + v.push_back(std::to_string(e.bracertexture)); + v.push_back(std::to_string(e.handtexture)); + v.push_back(std::to_string(e.legtexture)); + v.push_back(std::to_string(e.feettexture)); + v.push_back(std::to_string(e.light)); + v.push_back(std::to_string(e.walkspeed)); + v.push_back(std::to_string(e.peqid)); + v.push_back(std::to_string(e.unique_)); + v.push_back(std::to_string(e.fixed)); + v.push_back(std::to_string(e.ignore_despawn)); + v.push_back(std::to_string(e.show_name)); + v.push_back(std::to_string(e.untargetable)); + v.push_back(std::to_string(e.charm_ac)); + v.push_back(std::to_string(e.charm_min_dmg)); + v.push_back(std::to_string(e.charm_max_dmg)); + v.push_back(std::to_string(e.charm_attack_delay)); + v.push_back(std::to_string(e.charm_accuracy_rating)); + v.push_back(std::to_string(e.charm_avoidance_rating)); + v.push_back(std::to_string(e.charm_atk)); + v.push_back(std::to_string(e.skip_global_loot)); + v.push_back(std::to_string(e.rare_spawn)); + v.push_back(std::to_string(e.stuck_behavior)); + v.push_back(std::to_string(e.model)); + v.push_back(std::to_string(e.flymode)); + v.push_back(std::to_string(e.always_aggro)); + v.push_back(std::to_string(e.exp_mod)); - insert_chunks.push_back("(" + Strings::Implode(",", insert_values) + ")"); + insert_chunks.push_back("(" + Strings::Implode(",", v) + ")"); } - std::vector insert_values; + std::vector v; auto results = db.QueryDatabase( fmt::format( @@ -1215,140 +1215,140 @@ public: all_entries.reserve(results.RowCount()); for (auto row = results.begin(); row != results.end(); ++row) { - NpcTypes entry{}; + NpcTypes e{}; - entry.id = atoi(row[0]); - entry.name = row[1] ? row[1] : ""; - entry.lastname = row[2] ? row[2] : ""; - entry.level = atoi(row[3]); - entry.race = atoi(row[4]); - entry.class_ = atoi(row[5]); - entry.bodytype = atoi(row[6]); - entry.hp = strtoll(row[7], nullptr, 10); - entry.mana = strtoll(row[8], nullptr, 10); - entry.gender = atoi(row[9]); - entry.texture = atoi(row[10]); - entry.helmtexture = atoi(row[11]); - entry.herosforgemodel = atoi(row[12]); - entry.size = static_cast(atof(row[13])); - entry.hp_regen_rate = strtoll(row[14], nullptr, 10); - entry.hp_regen_per_second = strtoll(row[15], nullptr, 10); - entry.mana_regen_rate = strtoll(row[16], nullptr, 10); - entry.loottable_id = atoi(row[17]); - entry.merchant_id = atoi(row[18]); - entry.alt_currency_id = atoi(row[19]); - entry.npc_spells_id = atoi(row[20]); - entry.npc_spells_effects_id = atoi(row[21]); - entry.npc_faction_id = atoi(row[22]); - entry.adventure_template_id = atoi(row[23]); - entry.trap_template = atoi(row[24]); - entry.mindmg = atoi(row[25]); - entry.maxdmg = atoi(row[26]); - entry.attack_count = atoi(row[27]); - entry.npcspecialattks = row[28] ? row[28] : ""; - entry.special_abilities = row[29] ? row[29] : ""; - entry.aggroradius = atoi(row[30]); - entry.assistradius = atoi(row[31]); - entry.face = atoi(row[32]); - entry.luclin_hairstyle = atoi(row[33]); - entry.luclin_haircolor = atoi(row[34]); - entry.luclin_eyecolor = atoi(row[35]); - entry.luclin_eyecolor2 = atoi(row[36]); - entry.luclin_beardcolor = atoi(row[37]); - entry.luclin_beard = atoi(row[38]); - entry.drakkin_heritage = atoi(row[39]); - entry.drakkin_tattoo = atoi(row[40]); - entry.drakkin_details = atoi(row[41]); - entry.armortint_id = atoi(row[42]); - entry.armortint_red = atoi(row[43]); - entry.armortint_green = atoi(row[44]); - entry.armortint_blue = atoi(row[45]); - entry.d_melee_texture1 = atoi(row[46]); - entry.d_melee_texture2 = atoi(row[47]); - entry.ammo_idfile = row[48] ? row[48] : ""; - entry.prim_melee_type = atoi(row[49]); - entry.sec_melee_type = atoi(row[50]); - entry.ranged_type = atoi(row[51]); - entry.runspeed = static_cast(atof(row[52])); - entry.MR = atoi(row[53]); - entry.CR = atoi(row[54]); - entry.DR = atoi(row[55]); - entry.FR = atoi(row[56]); - entry.PR = atoi(row[57]); - entry.Corrup = atoi(row[58]); - entry.PhR = atoi(row[59]); - entry.see_invis = atoi(row[60]); - entry.see_invis_undead = atoi(row[61]); - entry.qglobal = atoi(row[62]); - entry.AC = atoi(row[63]); - entry.npc_aggro = atoi(row[64]); - entry.spawn_limit = atoi(row[65]); - entry.attack_speed = static_cast(atof(row[66])); - entry.attack_delay = atoi(row[67]); - entry.findable = atoi(row[68]); - entry.STR = atoi(row[69]); - entry.STA = atoi(row[70]); - entry.DEX = atoi(row[71]); - entry.AGI = atoi(row[72]); - entry._INT = atoi(row[73]); - entry.WIS = atoi(row[74]); - entry.CHA = atoi(row[75]); - entry.see_hide = atoi(row[76]); - entry.see_improved_hide = atoi(row[77]); - entry.trackable = atoi(row[78]); - entry.isbot = atoi(row[79]); - entry.exclude = atoi(row[80]); - entry.ATK = atoi(row[81]); - entry.Accuracy = atoi(row[82]); - entry.Avoidance = atoi(row[83]); - entry.slow_mitigation = atoi(row[84]); - entry.version = atoi(row[85]); - entry.maxlevel = atoi(row[86]); - entry.scalerate = atoi(row[87]); - entry.private_corpse = atoi(row[88]); - entry.unique_spawn_by_name = atoi(row[89]); - entry.underwater = atoi(row[90]); - entry.isquest = atoi(row[91]); - entry.emoteid = atoi(row[92]); - entry.spellscale = static_cast(atof(row[93])); - entry.healscale = static_cast(atof(row[94])); - entry.no_target_hotkey = atoi(row[95]); - entry.raid_target = atoi(row[96]); - entry.armtexture = atoi(row[97]); - entry.bracertexture = atoi(row[98]); - entry.handtexture = atoi(row[99]); - entry.legtexture = atoi(row[100]); - entry.feettexture = atoi(row[101]); - entry.light = atoi(row[102]); - entry.walkspeed = atoi(row[103]); - entry.peqid = atoi(row[104]); - entry.unique_ = atoi(row[105]); - entry.fixed = atoi(row[106]); - entry.ignore_despawn = atoi(row[107]); - entry.show_name = atoi(row[108]); - entry.untargetable = atoi(row[109]); - entry.charm_ac = atoi(row[110]); - entry.charm_min_dmg = atoi(row[111]); - entry.charm_max_dmg = atoi(row[112]); - entry.charm_attack_delay = atoi(row[113]); - entry.charm_accuracy_rating = atoi(row[114]); - entry.charm_avoidance_rating = atoi(row[115]); - entry.charm_atk = atoi(row[116]); - entry.skip_global_loot = atoi(row[117]); - entry.rare_spawn = atoi(row[118]); - entry.stuck_behavior = atoi(row[119]); - entry.model = atoi(row[120]); - entry.flymode = atoi(row[121]); - entry.always_aggro = atoi(row[122]); - entry.exp_mod = atoi(row[123]); + e.id = atoi(row[0]); + e.name = row[1] ? row[1] : ""; + e.lastname = row[2] ? row[2] : ""; + e.level = atoi(row[3]); + e.race = atoi(row[4]); + e.class_ = atoi(row[5]); + e.bodytype = atoi(row[6]); + e.hp = strtoll(row[7], nullptr, 10); + e.mana = strtoll(row[8], nullptr, 10); + e.gender = atoi(row[9]); + e.texture = atoi(row[10]); + e.helmtexture = atoi(row[11]); + e.herosforgemodel = atoi(row[12]); + e.size = static_cast(atof(row[13])); + e.hp_regen_rate = strtoll(row[14], nullptr, 10); + e.hp_regen_per_second = strtoll(row[15], nullptr, 10); + e.mana_regen_rate = strtoll(row[16], nullptr, 10); + e.loottable_id = atoi(row[17]); + e.merchant_id = atoi(row[18]); + e.alt_currency_id = atoi(row[19]); + e.npc_spells_id = atoi(row[20]); + e.npc_spells_effects_id = atoi(row[21]); + e.npc_faction_id = atoi(row[22]); + e.adventure_template_id = atoi(row[23]); + e.trap_template = atoi(row[24]); + e.mindmg = atoi(row[25]); + e.maxdmg = atoi(row[26]); + e.attack_count = atoi(row[27]); + e.npcspecialattks = row[28] ? row[28] : ""; + e.special_abilities = row[29] ? row[29] : ""; + e.aggroradius = atoi(row[30]); + e.assistradius = atoi(row[31]); + e.face = atoi(row[32]); + e.luclin_hairstyle = atoi(row[33]); + e.luclin_haircolor = atoi(row[34]); + e.luclin_eyecolor = atoi(row[35]); + e.luclin_eyecolor2 = atoi(row[36]); + e.luclin_beardcolor = atoi(row[37]); + e.luclin_beard = atoi(row[38]); + e.drakkin_heritage = atoi(row[39]); + e.drakkin_tattoo = atoi(row[40]); + e.drakkin_details = atoi(row[41]); + e.armortint_id = atoi(row[42]); + e.armortint_red = atoi(row[43]); + e.armortint_green = atoi(row[44]); + e.armortint_blue = atoi(row[45]); + e.d_melee_texture1 = atoi(row[46]); + e.d_melee_texture2 = atoi(row[47]); + e.ammo_idfile = row[48] ? row[48] : ""; + e.prim_melee_type = atoi(row[49]); + e.sec_melee_type = atoi(row[50]); + e.ranged_type = atoi(row[51]); + e.runspeed = static_cast(atof(row[52])); + e.MR = atoi(row[53]); + e.CR = atoi(row[54]); + e.DR = atoi(row[55]); + e.FR = atoi(row[56]); + e.PR = atoi(row[57]); + e.Corrup = atoi(row[58]); + e.PhR = atoi(row[59]); + e.see_invis = atoi(row[60]); + e.see_invis_undead = atoi(row[61]); + e.qglobal = atoi(row[62]); + e.AC = atoi(row[63]); + e.npc_aggro = atoi(row[64]); + e.spawn_limit = atoi(row[65]); + e.attack_speed = static_cast(atof(row[66])); + e.attack_delay = atoi(row[67]); + e.findable = atoi(row[68]); + e.STR = atoi(row[69]); + e.STA = atoi(row[70]); + e.DEX = atoi(row[71]); + e.AGI = atoi(row[72]); + e._INT = atoi(row[73]); + e.WIS = atoi(row[74]); + e.CHA = atoi(row[75]); + e.see_hide = atoi(row[76]); + e.see_improved_hide = atoi(row[77]); + e.trackable = atoi(row[78]); + e.isbot = atoi(row[79]); + e.exclude = atoi(row[80]); + e.ATK = atoi(row[81]); + e.Accuracy = atoi(row[82]); + e.Avoidance = atoi(row[83]); + e.slow_mitigation = atoi(row[84]); + e.version = atoi(row[85]); + e.maxlevel = atoi(row[86]); + e.scalerate = atoi(row[87]); + e.private_corpse = atoi(row[88]); + e.unique_spawn_by_name = atoi(row[89]); + e.underwater = atoi(row[90]); + e.isquest = atoi(row[91]); + e.emoteid = atoi(row[92]); + e.spellscale = static_cast(atof(row[93])); + e.healscale = static_cast(atof(row[94])); + e.no_target_hotkey = atoi(row[95]); + e.raid_target = atoi(row[96]); + e.armtexture = atoi(row[97]); + e.bracertexture = atoi(row[98]); + e.handtexture = atoi(row[99]); + e.legtexture = atoi(row[100]); + e.feettexture = atoi(row[101]); + e.light = atoi(row[102]); + e.walkspeed = atoi(row[103]); + e.peqid = atoi(row[104]); + e.unique_ = atoi(row[105]); + e.fixed = atoi(row[106]); + e.ignore_despawn = atoi(row[107]); + e.show_name = atoi(row[108]); + e.untargetable = atoi(row[109]); + e.charm_ac = atoi(row[110]); + e.charm_min_dmg = atoi(row[111]); + e.charm_max_dmg = atoi(row[112]); + e.charm_attack_delay = atoi(row[113]); + e.charm_accuracy_rating = atoi(row[114]); + e.charm_avoidance_rating = atoi(row[115]); + e.charm_atk = atoi(row[116]); + e.skip_global_loot = atoi(row[117]); + e.rare_spawn = atoi(row[118]); + e.stuck_behavior = atoi(row[119]); + e.model = atoi(row[120]); + e.flymode = atoi(row[121]); + e.always_aggro = atoi(row[122]); + e.exp_mod = atoi(row[123]); - all_entries.push_back(entry); + all_entries.push_back(e); } return all_entries; } - static std::vector GetWhere(Database& db, std::string where_filter) + static std::vector GetWhere(Database& db, const std::string &where_filter) { std::vector all_entries; @@ -1363,140 +1363,140 @@ public: all_entries.reserve(results.RowCount()); for (auto row = results.begin(); row != results.end(); ++row) { - NpcTypes entry{}; + NpcTypes e{}; - entry.id = atoi(row[0]); - entry.name = row[1] ? row[1] : ""; - entry.lastname = row[2] ? row[2] : ""; - entry.level = atoi(row[3]); - entry.race = atoi(row[4]); - entry.class_ = atoi(row[5]); - entry.bodytype = atoi(row[6]); - entry.hp = strtoll(row[7], nullptr, 10); - entry.mana = strtoll(row[8], nullptr, 10); - entry.gender = atoi(row[9]); - entry.texture = atoi(row[10]); - entry.helmtexture = atoi(row[11]); - entry.herosforgemodel = atoi(row[12]); - entry.size = static_cast(atof(row[13])); - entry.hp_regen_rate = strtoll(row[14], nullptr, 10); - entry.hp_regen_per_second = strtoll(row[15], nullptr, 10); - entry.mana_regen_rate = strtoll(row[16], nullptr, 10); - entry.loottable_id = atoi(row[17]); - entry.merchant_id = atoi(row[18]); - entry.alt_currency_id = atoi(row[19]); - entry.npc_spells_id = atoi(row[20]); - entry.npc_spells_effects_id = atoi(row[21]); - entry.npc_faction_id = atoi(row[22]); - entry.adventure_template_id = atoi(row[23]); - entry.trap_template = atoi(row[24]); - entry.mindmg = atoi(row[25]); - entry.maxdmg = atoi(row[26]); - entry.attack_count = atoi(row[27]); - entry.npcspecialattks = row[28] ? row[28] : ""; - entry.special_abilities = row[29] ? row[29] : ""; - entry.aggroradius = atoi(row[30]); - entry.assistradius = atoi(row[31]); - entry.face = atoi(row[32]); - entry.luclin_hairstyle = atoi(row[33]); - entry.luclin_haircolor = atoi(row[34]); - entry.luclin_eyecolor = atoi(row[35]); - entry.luclin_eyecolor2 = atoi(row[36]); - entry.luclin_beardcolor = atoi(row[37]); - entry.luclin_beard = atoi(row[38]); - entry.drakkin_heritage = atoi(row[39]); - entry.drakkin_tattoo = atoi(row[40]); - entry.drakkin_details = atoi(row[41]); - entry.armortint_id = atoi(row[42]); - entry.armortint_red = atoi(row[43]); - entry.armortint_green = atoi(row[44]); - entry.armortint_blue = atoi(row[45]); - entry.d_melee_texture1 = atoi(row[46]); - entry.d_melee_texture2 = atoi(row[47]); - entry.ammo_idfile = row[48] ? row[48] : ""; - entry.prim_melee_type = atoi(row[49]); - entry.sec_melee_type = atoi(row[50]); - entry.ranged_type = atoi(row[51]); - entry.runspeed = static_cast(atof(row[52])); - entry.MR = atoi(row[53]); - entry.CR = atoi(row[54]); - entry.DR = atoi(row[55]); - entry.FR = atoi(row[56]); - entry.PR = atoi(row[57]); - entry.Corrup = atoi(row[58]); - entry.PhR = atoi(row[59]); - entry.see_invis = atoi(row[60]); - entry.see_invis_undead = atoi(row[61]); - entry.qglobal = atoi(row[62]); - entry.AC = atoi(row[63]); - entry.npc_aggro = atoi(row[64]); - entry.spawn_limit = atoi(row[65]); - entry.attack_speed = static_cast(atof(row[66])); - entry.attack_delay = atoi(row[67]); - entry.findable = atoi(row[68]); - entry.STR = atoi(row[69]); - entry.STA = atoi(row[70]); - entry.DEX = atoi(row[71]); - entry.AGI = atoi(row[72]); - entry._INT = atoi(row[73]); - entry.WIS = atoi(row[74]); - entry.CHA = atoi(row[75]); - entry.see_hide = atoi(row[76]); - entry.see_improved_hide = atoi(row[77]); - entry.trackable = atoi(row[78]); - entry.isbot = atoi(row[79]); - entry.exclude = atoi(row[80]); - entry.ATK = atoi(row[81]); - entry.Accuracy = atoi(row[82]); - entry.Avoidance = atoi(row[83]); - entry.slow_mitigation = atoi(row[84]); - entry.version = atoi(row[85]); - entry.maxlevel = atoi(row[86]); - entry.scalerate = atoi(row[87]); - entry.private_corpse = atoi(row[88]); - entry.unique_spawn_by_name = atoi(row[89]); - entry.underwater = atoi(row[90]); - entry.isquest = atoi(row[91]); - entry.emoteid = atoi(row[92]); - entry.spellscale = static_cast(atof(row[93])); - entry.healscale = static_cast(atof(row[94])); - entry.no_target_hotkey = atoi(row[95]); - entry.raid_target = atoi(row[96]); - entry.armtexture = atoi(row[97]); - entry.bracertexture = atoi(row[98]); - entry.handtexture = atoi(row[99]); - entry.legtexture = atoi(row[100]); - entry.feettexture = atoi(row[101]); - entry.light = atoi(row[102]); - entry.walkspeed = atoi(row[103]); - entry.peqid = atoi(row[104]); - entry.unique_ = atoi(row[105]); - entry.fixed = atoi(row[106]); - entry.ignore_despawn = atoi(row[107]); - entry.show_name = atoi(row[108]); - entry.untargetable = atoi(row[109]); - entry.charm_ac = atoi(row[110]); - entry.charm_min_dmg = atoi(row[111]); - entry.charm_max_dmg = atoi(row[112]); - entry.charm_attack_delay = atoi(row[113]); - entry.charm_accuracy_rating = atoi(row[114]); - entry.charm_avoidance_rating = atoi(row[115]); - entry.charm_atk = atoi(row[116]); - entry.skip_global_loot = atoi(row[117]); - entry.rare_spawn = atoi(row[118]); - entry.stuck_behavior = atoi(row[119]); - entry.model = atoi(row[120]); - entry.flymode = atoi(row[121]); - entry.always_aggro = atoi(row[122]); - entry.exp_mod = atoi(row[123]); + e.id = atoi(row[0]); + e.name = row[1] ? row[1] : ""; + e.lastname = row[2] ? row[2] : ""; + e.level = atoi(row[3]); + e.race = atoi(row[4]); + e.class_ = atoi(row[5]); + e.bodytype = atoi(row[6]); + e.hp = strtoll(row[7], nullptr, 10); + e.mana = strtoll(row[8], nullptr, 10); + e.gender = atoi(row[9]); + e.texture = atoi(row[10]); + e.helmtexture = atoi(row[11]); + e.herosforgemodel = atoi(row[12]); + e.size = static_cast(atof(row[13])); + e.hp_regen_rate = strtoll(row[14], nullptr, 10); + e.hp_regen_per_second = strtoll(row[15], nullptr, 10); + e.mana_regen_rate = strtoll(row[16], nullptr, 10); + e.loottable_id = atoi(row[17]); + e.merchant_id = atoi(row[18]); + e.alt_currency_id = atoi(row[19]); + e.npc_spells_id = atoi(row[20]); + e.npc_spells_effects_id = atoi(row[21]); + e.npc_faction_id = atoi(row[22]); + e.adventure_template_id = atoi(row[23]); + e.trap_template = atoi(row[24]); + e.mindmg = atoi(row[25]); + e.maxdmg = atoi(row[26]); + e.attack_count = atoi(row[27]); + e.npcspecialattks = row[28] ? row[28] : ""; + e.special_abilities = row[29] ? row[29] : ""; + e.aggroradius = atoi(row[30]); + e.assistradius = atoi(row[31]); + e.face = atoi(row[32]); + e.luclin_hairstyle = atoi(row[33]); + e.luclin_haircolor = atoi(row[34]); + e.luclin_eyecolor = atoi(row[35]); + e.luclin_eyecolor2 = atoi(row[36]); + e.luclin_beardcolor = atoi(row[37]); + e.luclin_beard = atoi(row[38]); + e.drakkin_heritage = atoi(row[39]); + e.drakkin_tattoo = atoi(row[40]); + e.drakkin_details = atoi(row[41]); + e.armortint_id = atoi(row[42]); + e.armortint_red = atoi(row[43]); + e.armortint_green = atoi(row[44]); + e.armortint_blue = atoi(row[45]); + e.d_melee_texture1 = atoi(row[46]); + e.d_melee_texture2 = atoi(row[47]); + e.ammo_idfile = row[48] ? row[48] : ""; + e.prim_melee_type = atoi(row[49]); + e.sec_melee_type = atoi(row[50]); + e.ranged_type = atoi(row[51]); + e.runspeed = static_cast(atof(row[52])); + e.MR = atoi(row[53]); + e.CR = atoi(row[54]); + e.DR = atoi(row[55]); + e.FR = atoi(row[56]); + e.PR = atoi(row[57]); + e.Corrup = atoi(row[58]); + e.PhR = atoi(row[59]); + e.see_invis = atoi(row[60]); + e.see_invis_undead = atoi(row[61]); + e.qglobal = atoi(row[62]); + e.AC = atoi(row[63]); + e.npc_aggro = atoi(row[64]); + e.spawn_limit = atoi(row[65]); + e.attack_speed = static_cast(atof(row[66])); + e.attack_delay = atoi(row[67]); + e.findable = atoi(row[68]); + e.STR = atoi(row[69]); + e.STA = atoi(row[70]); + e.DEX = atoi(row[71]); + e.AGI = atoi(row[72]); + e._INT = atoi(row[73]); + e.WIS = atoi(row[74]); + e.CHA = atoi(row[75]); + e.see_hide = atoi(row[76]); + e.see_improved_hide = atoi(row[77]); + e.trackable = atoi(row[78]); + e.isbot = atoi(row[79]); + e.exclude = atoi(row[80]); + e.ATK = atoi(row[81]); + e.Accuracy = atoi(row[82]); + e.Avoidance = atoi(row[83]); + e.slow_mitigation = atoi(row[84]); + e.version = atoi(row[85]); + e.maxlevel = atoi(row[86]); + e.scalerate = atoi(row[87]); + e.private_corpse = atoi(row[88]); + e.unique_spawn_by_name = atoi(row[89]); + e.underwater = atoi(row[90]); + e.isquest = atoi(row[91]); + e.emoteid = atoi(row[92]); + e.spellscale = static_cast(atof(row[93])); + e.healscale = static_cast(atof(row[94])); + e.no_target_hotkey = atoi(row[95]); + e.raid_target = atoi(row[96]); + e.armtexture = atoi(row[97]); + e.bracertexture = atoi(row[98]); + e.handtexture = atoi(row[99]); + e.legtexture = atoi(row[100]); + e.feettexture = atoi(row[101]); + e.light = atoi(row[102]); + e.walkspeed = atoi(row[103]); + e.peqid = atoi(row[104]); + e.unique_ = atoi(row[105]); + e.fixed = atoi(row[106]); + e.ignore_despawn = atoi(row[107]); + e.show_name = atoi(row[108]); + e.untargetable = atoi(row[109]); + e.charm_ac = atoi(row[110]); + e.charm_min_dmg = atoi(row[111]); + e.charm_max_dmg = atoi(row[112]); + e.charm_attack_delay = atoi(row[113]); + e.charm_accuracy_rating = atoi(row[114]); + e.charm_avoidance_rating = atoi(row[115]); + e.charm_atk = atoi(row[116]); + e.skip_global_loot = atoi(row[117]); + e.rare_spawn = atoi(row[118]); + e.stuck_behavior = atoi(row[119]); + e.model = atoi(row[120]); + e.flymode = atoi(row[121]); + e.always_aggro = atoi(row[122]); + e.exp_mod = atoi(row[123]); - all_entries.push_back(entry); + all_entries.push_back(e); } return all_entries; } - static int DeleteWhere(Database& db, std::string where_filter) + static int DeleteWhere(Database& db, const std::string &where_filter) { auto results = db.QueryDatabase( fmt::format( @@ -1521,6 +1521,32 @@ public: 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); + } + }; #endif //EQEMU_BASE_NPC_TYPES_REPOSITORY_H diff --git a/common/repositories/base/base_npc_types_tint_repository.h b/common/repositories/base/base_npc_types_tint_repository.h index ac9cc055e..0275d2b37 100644 --- a/common/repositories/base/base_npc_types_tint_repository.h +++ b/common/repositories/base/base_npc_types_tint_repository.h @@ -160,42 +160,42 @@ public: static NpcTypesTint NewEntity() { - NpcTypesTint entry{}; + NpcTypesTint e{}; - entry.id = 0; - entry.tint_set_name = ""; - entry.red1h = 0; - entry.grn1h = 0; - entry.blu1h = 0; - entry.red2c = 0; - entry.grn2c = 0; - entry.blu2c = 0; - entry.red3a = 0; - entry.grn3a = 0; - entry.blu3a = 0; - entry.red4b = 0; - entry.grn4b = 0; - entry.blu4b = 0; - entry.red5g = 0; - entry.grn5g = 0; - entry.blu5g = 0; - entry.red6l = 0; - entry.grn6l = 0; - entry.blu6l = 0; - entry.red7f = 0; - entry.grn7f = 0; - entry.blu7f = 0; - entry.red8x = 0; - entry.grn8x = 0; - entry.blu8x = 0; - entry.red9x = 0; - entry.grn9x = 0; - entry.blu9x = 0; + e.id = 0; + e.tint_set_name = ""; + e.red1h = 0; + e.grn1h = 0; + e.blu1h = 0; + e.red2c = 0; + e.grn2c = 0; + e.blu2c = 0; + e.red3a = 0; + e.grn3a = 0; + e.blu3a = 0; + e.red4b = 0; + e.grn4b = 0; + e.blu4b = 0; + e.red5g = 0; + e.grn5g = 0; + e.blu5g = 0; + e.red6l = 0; + e.grn6l = 0; + e.blu6l = 0; + e.red7f = 0; + e.grn7f = 0; + e.blu7f = 0; + e.red8x = 0; + e.grn8x = 0; + e.blu8x = 0; + e.red9x = 0; + e.grn9x = 0; + e.blu9x = 0; - return entry; + return e; } - static NpcTypesTint GetNpcTypesTintEntry( + static NpcTypesTint GetNpcTypesTint( const std::vector &npc_types_tints, int npc_types_tint_id ) @@ -224,39 +224,39 @@ public: auto row = results.begin(); if (results.RowCount() == 1) { - NpcTypesTint entry{}; + NpcTypesTint e{}; - entry.id = atoi(row[0]); - entry.tint_set_name = row[1] ? row[1] : ""; - entry.red1h = atoi(row[2]); - entry.grn1h = atoi(row[3]); - entry.blu1h = atoi(row[4]); - entry.red2c = atoi(row[5]); - entry.grn2c = atoi(row[6]); - entry.blu2c = atoi(row[7]); - entry.red3a = atoi(row[8]); - entry.grn3a = atoi(row[9]); - entry.blu3a = atoi(row[10]); - entry.red4b = atoi(row[11]); - entry.grn4b = atoi(row[12]); - entry.blu4b = atoi(row[13]); - entry.red5g = atoi(row[14]); - entry.grn5g = atoi(row[15]); - entry.blu5g = atoi(row[16]); - entry.red6l = atoi(row[17]); - entry.grn6l = atoi(row[18]); - entry.blu6l = atoi(row[19]); - entry.red7f = atoi(row[20]); - entry.grn7f = atoi(row[21]); - entry.blu7f = atoi(row[22]); - entry.red8x = atoi(row[23]); - entry.grn8x = atoi(row[24]); - entry.blu8x = atoi(row[25]); - entry.red9x = atoi(row[26]); - entry.grn9x = atoi(row[27]); - entry.blu9x = atoi(row[28]); + e.id = atoi(row[0]); + e.tint_set_name = row[1] ? row[1] : ""; + e.red1h = atoi(row[2]); + e.grn1h = atoi(row[3]); + e.blu1h = atoi(row[4]); + e.red2c = atoi(row[5]); + e.grn2c = atoi(row[6]); + e.blu2c = atoi(row[7]); + e.red3a = atoi(row[8]); + e.grn3a = atoi(row[9]); + e.blu3a = atoi(row[10]); + e.red4b = atoi(row[11]); + e.grn4b = atoi(row[12]); + e.blu4b = atoi(row[13]); + e.red5g = atoi(row[14]); + e.grn5g = atoi(row[15]); + e.blu5g = atoi(row[16]); + e.red6l = atoi(row[17]); + e.grn6l = atoi(row[18]); + e.blu6l = atoi(row[19]); + e.red7f = atoi(row[20]); + e.grn7f = atoi(row[21]); + e.blu7f = atoi(row[22]); + e.red8x = atoi(row[23]); + e.grn8x = atoi(row[24]); + e.blu8x = atoi(row[25]); + e.red9x = atoi(row[26]); + e.grn9x = atoi(row[27]); + e.blu9x = atoi(row[28]); - return entry; + return e; } return NewEntity(); @@ -281,50 +281,50 @@ public: static int UpdateOne( Database& db, - NpcTypesTint npc_types_tint_entry + const NpcTypesTint &e ) { - std::vector update_values; + std::vector v; auto columns = Columns(); - update_values.push_back(columns[0] + " = " + std::to_string(npc_types_tint_entry.id)); - update_values.push_back(columns[1] + " = '" + Strings::Escape(npc_types_tint_entry.tint_set_name) + "'"); - update_values.push_back(columns[2] + " = " + std::to_string(npc_types_tint_entry.red1h)); - update_values.push_back(columns[3] + " = " + std::to_string(npc_types_tint_entry.grn1h)); - update_values.push_back(columns[4] + " = " + std::to_string(npc_types_tint_entry.blu1h)); - update_values.push_back(columns[5] + " = " + std::to_string(npc_types_tint_entry.red2c)); - update_values.push_back(columns[6] + " = " + std::to_string(npc_types_tint_entry.grn2c)); - update_values.push_back(columns[7] + " = " + std::to_string(npc_types_tint_entry.blu2c)); - update_values.push_back(columns[8] + " = " + std::to_string(npc_types_tint_entry.red3a)); - update_values.push_back(columns[9] + " = " + std::to_string(npc_types_tint_entry.grn3a)); - update_values.push_back(columns[10] + " = " + std::to_string(npc_types_tint_entry.blu3a)); - update_values.push_back(columns[11] + " = " + std::to_string(npc_types_tint_entry.red4b)); - update_values.push_back(columns[12] + " = " + std::to_string(npc_types_tint_entry.grn4b)); - update_values.push_back(columns[13] + " = " + std::to_string(npc_types_tint_entry.blu4b)); - update_values.push_back(columns[14] + " = " + std::to_string(npc_types_tint_entry.red5g)); - update_values.push_back(columns[15] + " = " + std::to_string(npc_types_tint_entry.grn5g)); - update_values.push_back(columns[16] + " = " + std::to_string(npc_types_tint_entry.blu5g)); - update_values.push_back(columns[17] + " = " + std::to_string(npc_types_tint_entry.red6l)); - update_values.push_back(columns[18] + " = " + std::to_string(npc_types_tint_entry.grn6l)); - update_values.push_back(columns[19] + " = " + std::to_string(npc_types_tint_entry.blu6l)); - update_values.push_back(columns[20] + " = " + std::to_string(npc_types_tint_entry.red7f)); - update_values.push_back(columns[21] + " = " + std::to_string(npc_types_tint_entry.grn7f)); - update_values.push_back(columns[22] + " = " + std::to_string(npc_types_tint_entry.blu7f)); - update_values.push_back(columns[23] + " = " + std::to_string(npc_types_tint_entry.red8x)); - update_values.push_back(columns[24] + " = " + std::to_string(npc_types_tint_entry.grn8x)); - update_values.push_back(columns[25] + " = " + std::to_string(npc_types_tint_entry.blu8x)); - update_values.push_back(columns[26] + " = " + std::to_string(npc_types_tint_entry.red9x)); - update_values.push_back(columns[27] + " = " + std::to_string(npc_types_tint_entry.grn9x)); - update_values.push_back(columns[28] + " = " + std::to_string(npc_types_tint_entry.blu9x)); + v.push_back(columns[0] + " = " + std::to_string(e.id)); + v.push_back(columns[1] + " = '" + Strings::Escape(e.tint_set_name) + "'"); + v.push_back(columns[2] + " = " + std::to_string(e.red1h)); + v.push_back(columns[3] + " = " + std::to_string(e.grn1h)); + v.push_back(columns[4] + " = " + std::to_string(e.blu1h)); + v.push_back(columns[5] + " = " + std::to_string(e.red2c)); + v.push_back(columns[6] + " = " + std::to_string(e.grn2c)); + v.push_back(columns[7] + " = " + std::to_string(e.blu2c)); + v.push_back(columns[8] + " = " + std::to_string(e.red3a)); + v.push_back(columns[9] + " = " + std::to_string(e.grn3a)); + v.push_back(columns[10] + " = " + std::to_string(e.blu3a)); + v.push_back(columns[11] + " = " + std::to_string(e.red4b)); + v.push_back(columns[12] + " = " + std::to_string(e.grn4b)); + v.push_back(columns[13] + " = " + std::to_string(e.blu4b)); + v.push_back(columns[14] + " = " + std::to_string(e.red5g)); + v.push_back(columns[15] + " = " + std::to_string(e.grn5g)); + v.push_back(columns[16] + " = " + std::to_string(e.blu5g)); + v.push_back(columns[17] + " = " + std::to_string(e.red6l)); + v.push_back(columns[18] + " = " + std::to_string(e.grn6l)); + v.push_back(columns[19] + " = " + std::to_string(e.blu6l)); + v.push_back(columns[20] + " = " + std::to_string(e.red7f)); + v.push_back(columns[21] + " = " + std::to_string(e.grn7f)); + v.push_back(columns[22] + " = " + std::to_string(e.blu7f)); + v.push_back(columns[23] + " = " + std::to_string(e.red8x)); + v.push_back(columns[24] + " = " + std::to_string(e.grn8x)); + v.push_back(columns[25] + " = " + std::to_string(e.blu8x)); + v.push_back(columns[26] + " = " + std::to_string(e.red9x)); + v.push_back(columns[27] + " = " + std::to_string(e.grn9x)); + v.push_back(columns[28] + " = " + std::to_string(e.blu9x)); auto results = db.QueryDatabase( fmt::format( "UPDATE {} SET {} WHERE {} = {}", TableName(), - Strings::Implode(", ", update_values), + Strings::Implode(", ", v), PrimaryKey(), - npc_types_tint_entry.id + e.id ) ); @@ -333,103 +333,103 @@ public: static NpcTypesTint InsertOne( Database& db, - NpcTypesTint npc_types_tint_entry + NpcTypesTint e ) { - std::vector insert_values; + std::vector v; - insert_values.push_back(std::to_string(npc_types_tint_entry.id)); - insert_values.push_back("'" + Strings::Escape(npc_types_tint_entry.tint_set_name) + "'"); - insert_values.push_back(std::to_string(npc_types_tint_entry.red1h)); - insert_values.push_back(std::to_string(npc_types_tint_entry.grn1h)); - insert_values.push_back(std::to_string(npc_types_tint_entry.blu1h)); - insert_values.push_back(std::to_string(npc_types_tint_entry.red2c)); - insert_values.push_back(std::to_string(npc_types_tint_entry.grn2c)); - insert_values.push_back(std::to_string(npc_types_tint_entry.blu2c)); - insert_values.push_back(std::to_string(npc_types_tint_entry.red3a)); - insert_values.push_back(std::to_string(npc_types_tint_entry.grn3a)); - insert_values.push_back(std::to_string(npc_types_tint_entry.blu3a)); - insert_values.push_back(std::to_string(npc_types_tint_entry.red4b)); - insert_values.push_back(std::to_string(npc_types_tint_entry.grn4b)); - insert_values.push_back(std::to_string(npc_types_tint_entry.blu4b)); - insert_values.push_back(std::to_string(npc_types_tint_entry.red5g)); - insert_values.push_back(std::to_string(npc_types_tint_entry.grn5g)); - insert_values.push_back(std::to_string(npc_types_tint_entry.blu5g)); - insert_values.push_back(std::to_string(npc_types_tint_entry.red6l)); - insert_values.push_back(std::to_string(npc_types_tint_entry.grn6l)); - insert_values.push_back(std::to_string(npc_types_tint_entry.blu6l)); - insert_values.push_back(std::to_string(npc_types_tint_entry.red7f)); - insert_values.push_back(std::to_string(npc_types_tint_entry.grn7f)); - insert_values.push_back(std::to_string(npc_types_tint_entry.blu7f)); - insert_values.push_back(std::to_string(npc_types_tint_entry.red8x)); - insert_values.push_back(std::to_string(npc_types_tint_entry.grn8x)); - insert_values.push_back(std::to_string(npc_types_tint_entry.blu8x)); - insert_values.push_back(std::to_string(npc_types_tint_entry.red9x)); - insert_values.push_back(std::to_string(npc_types_tint_entry.grn9x)); - insert_values.push_back(std::to_string(npc_types_tint_entry.blu9x)); + v.push_back(std::to_string(e.id)); + v.push_back("'" + Strings::Escape(e.tint_set_name) + "'"); + v.push_back(std::to_string(e.red1h)); + v.push_back(std::to_string(e.grn1h)); + v.push_back(std::to_string(e.blu1h)); + v.push_back(std::to_string(e.red2c)); + v.push_back(std::to_string(e.grn2c)); + v.push_back(std::to_string(e.blu2c)); + v.push_back(std::to_string(e.red3a)); + v.push_back(std::to_string(e.grn3a)); + v.push_back(std::to_string(e.blu3a)); + v.push_back(std::to_string(e.red4b)); + v.push_back(std::to_string(e.grn4b)); + v.push_back(std::to_string(e.blu4b)); + v.push_back(std::to_string(e.red5g)); + v.push_back(std::to_string(e.grn5g)); + v.push_back(std::to_string(e.blu5g)); + v.push_back(std::to_string(e.red6l)); + v.push_back(std::to_string(e.grn6l)); + v.push_back(std::to_string(e.blu6l)); + v.push_back(std::to_string(e.red7f)); + v.push_back(std::to_string(e.grn7f)); + v.push_back(std::to_string(e.blu7f)); + v.push_back(std::to_string(e.red8x)); + v.push_back(std::to_string(e.grn8x)); + v.push_back(std::to_string(e.blu8x)); + v.push_back(std::to_string(e.red9x)); + v.push_back(std::to_string(e.grn9x)); + v.push_back(std::to_string(e.blu9x)); auto results = db.QueryDatabase( fmt::format( "{} VALUES ({})", BaseInsert(), - Strings::Implode(",", insert_values) + Strings::Implode(",", v) ) ); if (results.Success()) { - npc_types_tint_entry.id = results.LastInsertedID(); - return npc_types_tint_entry; + e.id = results.LastInsertedID(); + return e; } - npc_types_tint_entry = NewEntity(); + e = NewEntity(); - return npc_types_tint_entry; + return e; } static int InsertMany( Database& db, - std::vector npc_types_tint_entries + const std::vector &entries ) { std::vector insert_chunks; - for (auto &npc_types_tint_entry: npc_types_tint_entries) { - std::vector insert_values; + for (auto &e: entries) { + std::vector v; - insert_values.push_back(std::to_string(npc_types_tint_entry.id)); - insert_values.push_back("'" + Strings::Escape(npc_types_tint_entry.tint_set_name) + "'"); - insert_values.push_back(std::to_string(npc_types_tint_entry.red1h)); - insert_values.push_back(std::to_string(npc_types_tint_entry.grn1h)); - insert_values.push_back(std::to_string(npc_types_tint_entry.blu1h)); - insert_values.push_back(std::to_string(npc_types_tint_entry.red2c)); - insert_values.push_back(std::to_string(npc_types_tint_entry.grn2c)); - insert_values.push_back(std::to_string(npc_types_tint_entry.blu2c)); - insert_values.push_back(std::to_string(npc_types_tint_entry.red3a)); - insert_values.push_back(std::to_string(npc_types_tint_entry.grn3a)); - insert_values.push_back(std::to_string(npc_types_tint_entry.blu3a)); - insert_values.push_back(std::to_string(npc_types_tint_entry.red4b)); - insert_values.push_back(std::to_string(npc_types_tint_entry.grn4b)); - insert_values.push_back(std::to_string(npc_types_tint_entry.blu4b)); - insert_values.push_back(std::to_string(npc_types_tint_entry.red5g)); - insert_values.push_back(std::to_string(npc_types_tint_entry.grn5g)); - insert_values.push_back(std::to_string(npc_types_tint_entry.blu5g)); - insert_values.push_back(std::to_string(npc_types_tint_entry.red6l)); - insert_values.push_back(std::to_string(npc_types_tint_entry.grn6l)); - insert_values.push_back(std::to_string(npc_types_tint_entry.blu6l)); - insert_values.push_back(std::to_string(npc_types_tint_entry.red7f)); - insert_values.push_back(std::to_string(npc_types_tint_entry.grn7f)); - insert_values.push_back(std::to_string(npc_types_tint_entry.blu7f)); - insert_values.push_back(std::to_string(npc_types_tint_entry.red8x)); - insert_values.push_back(std::to_string(npc_types_tint_entry.grn8x)); - insert_values.push_back(std::to_string(npc_types_tint_entry.blu8x)); - insert_values.push_back(std::to_string(npc_types_tint_entry.red9x)); - insert_values.push_back(std::to_string(npc_types_tint_entry.grn9x)); - insert_values.push_back(std::to_string(npc_types_tint_entry.blu9x)); + v.push_back(std::to_string(e.id)); + v.push_back("'" + Strings::Escape(e.tint_set_name) + "'"); + v.push_back(std::to_string(e.red1h)); + v.push_back(std::to_string(e.grn1h)); + v.push_back(std::to_string(e.blu1h)); + v.push_back(std::to_string(e.red2c)); + v.push_back(std::to_string(e.grn2c)); + v.push_back(std::to_string(e.blu2c)); + v.push_back(std::to_string(e.red3a)); + v.push_back(std::to_string(e.grn3a)); + v.push_back(std::to_string(e.blu3a)); + v.push_back(std::to_string(e.red4b)); + v.push_back(std::to_string(e.grn4b)); + v.push_back(std::to_string(e.blu4b)); + v.push_back(std::to_string(e.red5g)); + v.push_back(std::to_string(e.grn5g)); + v.push_back(std::to_string(e.blu5g)); + v.push_back(std::to_string(e.red6l)); + v.push_back(std::to_string(e.grn6l)); + v.push_back(std::to_string(e.blu6l)); + v.push_back(std::to_string(e.red7f)); + v.push_back(std::to_string(e.grn7f)); + v.push_back(std::to_string(e.blu7f)); + v.push_back(std::to_string(e.red8x)); + v.push_back(std::to_string(e.grn8x)); + v.push_back(std::to_string(e.blu8x)); + v.push_back(std::to_string(e.red9x)); + v.push_back(std::to_string(e.grn9x)); + v.push_back(std::to_string(e.blu9x)); - insert_chunks.push_back("(" + Strings::Implode(",", insert_values) + ")"); + insert_chunks.push_back("(" + Strings::Implode(",", v) + ")"); } - std::vector insert_values; + std::vector v; auto results = db.QueryDatabase( fmt::format( @@ -456,45 +456,45 @@ public: all_entries.reserve(results.RowCount()); for (auto row = results.begin(); row != results.end(); ++row) { - NpcTypesTint entry{}; + NpcTypesTint e{}; - entry.id = atoi(row[0]); - entry.tint_set_name = row[1] ? row[1] : ""; - entry.red1h = atoi(row[2]); - entry.grn1h = atoi(row[3]); - entry.blu1h = atoi(row[4]); - entry.red2c = atoi(row[5]); - entry.grn2c = atoi(row[6]); - entry.blu2c = atoi(row[7]); - entry.red3a = atoi(row[8]); - entry.grn3a = atoi(row[9]); - entry.blu3a = atoi(row[10]); - entry.red4b = atoi(row[11]); - entry.grn4b = atoi(row[12]); - entry.blu4b = atoi(row[13]); - entry.red5g = atoi(row[14]); - entry.grn5g = atoi(row[15]); - entry.blu5g = atoi(row[16]); - entry.red6l = atoi(row[17]); - entry.grn6l = atoi(row[18]); - entry.blu6l = atoi(row[19]); - entry.red7f = atoi(row[20]); - entry.grn7f = atoi(row[21]); - entry.blu7f = atoi(row[22]); - entry.red8x = atoi(row[23]); - entry.grn8x = atoi(row[24]); - entry.blu8x = atoi(row[25]); - entry.red9x = atoi(row[26]); - entry.grn9x = atoi(row[27]); - entry.blu9x = atoi(row[28]); + e.id = atoi(row[0]); + e.tint_set_name = row[1] ? row[1] : ""; + e.red1h = atoi(row[2]); + e.grn1h = atoi(row[3]); + e.blu1h = atoi(row[4]); + e.red2c = atoi(row[5]); + e.grn2c = atoi(row[6]); + e.blu2c = atoi(row[7]); + e.red3a = atoi(row[8]); + e.grn3a = atoi(row[9]); + e.blu3a = atoi(row[10]); + e.red4b = atoi(row[11]); + e.grn4b = atoi(row[12]); + e.blu4b = atoi(row[13]); + e.red5g = atoi(row[14]); + e.grn5g = atoi(row[15]); + e.blu5g = atoi(row[16]); + e.red6l = atoi(row[17]); + e.grn6l = atoi(row[18]); + e.blu6l = atoi(row[19]); + e.red7f = atoi(row[20]); + e.grn7f = atoi(row[21]); + e.blu7f = atoi(row[22]); + e.red8x = atoi(row[23]); + e.grn8x = atoi(row[24]); + e.blu8x = atoi(row[25]); + e.red9x = atoi(row[26]); + e.grn9x = atoi(row[27]); + e.blu9x = atoi(row[28]); - all_entries.push_back(entry); + all_entries.push_back(e); } return all_entries; } - static std::vector GetWhere(Database& db, std::string where_filter) + static std::vector GetWhere(Database& db, const std::string &where_filter) { std::vector all_entries; @@ -509,45 +509,45 @@ public: all_entries.reserve(results.RowCount()); for (auto row = results.begin(); row != results.end(); ++row) { - NpcTypesTint entry{}; + NpcTypesTint e{}; - entry.id = atoi(row[0]); - entry.tint_set_name = row[1] ? row[1] : ""; - entry.red1h = atoi(row[2]); - entry.grn1h = atoi(row[3]); - entry.blu1h = atoi(row[4]); - entry.red2c = atoi(row[5]); - entry.grn2c = atoi(row[6]); - entry.blu2c = atoi(row[7]); - entry.red3a = atoi(row[8]); - entry.grn3a = atoi(row[9]); - entry.blu3a = atoi(row[10]); - entry.red4b = atoi(row[11]); - entry.grn4b = atoi(row[12]); - entry.blu4b = atoi(row[13]); - entry.red5g = atoi(row[14]); - entry.grn5g = atoi(row[15]); - entry.blu5g = atoi(row[16]); - entry.red6l = atoi(row[17]); - entry.grn6l = atoi(row[18]); - entry.blu6l = atoi(row[19]); - entry.red7f = atoi(row[20]); - entry.grn7f = atoi(row[21]); - entry.blu7f = atoi(row[22]); - entry.red8x = atoi(row[23]); - entry.grn8x = atoi(row[24]); - entry.blu8x = atoi(row[25]); - entry.red9x = atoi(row[26]); - entry.grn9x = atoi(row[27]); - entry.blu9x = atoi(row[28]); + e.id = atoi(row[0]); + e.tint_set_name = row[1] ? row[1] : ""; + e.red1h = atoi(row[2]); + e.grn1h = atoi(row[3]); + e.blu1h = atoi(row[4]); + e.red2c = atoi(row[5]); + e.grn2c = atoi(row[6]); + e.blu2c = atoi(row[7]); + e.red3a = atoi(row[8]); + e.grn3a = atoi(row[9]); + e.blu3a = atoi(row[10]); + e.red4b = atoi(row[11]); + e.grn4b = atoi(row[12]); + e.blu4b = atoi(row[13]); + e.red5g = atoi(row[14]); + e.grn5g = atoi(row[15]); + e.blu5g = atoi(row[16]); + e.red6l = atoi(row[17]); + e.grn6l = atoi(row[18]); + e.blu6l = atoi(row[19]); + e.red7f = atoi(row[20]); + e.grn7f = atoi(row[21]); + e.blu7f = atoi(row[22]); + e.red8x = atoi(row[23]); + e.grn8x = atoi(row[24]); + e.blu8x = atoi(row[25]); + e.red9x = atoi(row[26]); + e.grn9x = atoi(row[27]); + e.blu9x = atoi(row[28]); - all_entries.push_back(entry); + all_entries.push_back(e); } return all_entries; } - static int DeleteWhere(Database& db, std::string where_filter) + static int DeleteWhere(Database& db, const std::string &where_filter) { auto results = db.QueryDatabase( fmt::format( @@ -572,6 +572,32 @@ public: 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); + } + }; #endif //EQEMU_BASE_NPC_TYPES_TINT_REPOSITORY_H diff --git a/common/repositories/base/base_object_contents_repository.h b/common/repositories/base/base_object_contents_repository.h index 2eb7d0f6b..efa50c4b8 100644 --- a/common/repositories/base/base_object_contents_repository.h +++ b/common/repositories/base/base_object_contents_repository.h @@ -109,25 +109,25 @@ public: static ObjectContents NewEntity() { - ObjectContents entry{}; + ObjectContents e{}; - entry.zoneid = 0; - entry.parentid = 0; - entry.bagidx = 0; - entry.itemid = 0; - entry.charges = 0; - entry.droptime = 0; - entry.augslot1 = 0; - entry.augslot2 = 0; - entry.augslot3 = 0; - entry.augslot4 = 0; - entry.augslot5 = 0; - entry.augslot6 = 0; + e.zoneid = 0; + e.parentid = 0; + e.bagidx = 0; + e.itemid = 0; + e.charges = 0; + e.droptime = 0; + e.augslot1 = 0; + e.augslot2 = 0; + e.augslot3 = 0; + e.augslot4 = 0; + e.augslot5 = 0; + e.augslot6 = 0; - return entry; + return e; } - static ObjectContents GetObjectContentsEntry( + static ObjectContents GetObjectContents( const std::vector &object_contentss, int object_contents_id ) @@ -156,22 +156,22 @@ public: auto row = results.begin(); if (results.RowCount() == 1) { - ObjectContents entry{}; + ObjectContents e{}; - entry.zoneid = atoi(row[0]); - entry.parentid = atoi(row[1]); - entry.bagidx = atoi(row[2]); - entry.itemid = atoi(row[3]); - entry.charges = atoi(row[4]); - entry.droptime = strtoll(row[5] ? row[5] : "-1", nullptr, 10); - entry.augslot1 = atoi(row[6]); - entry.augslot2 = atoi(row[7]); - entry.augslot3 = atoi(row[8]); - entry.augslot4 = atoi(row[9]); - entry.augslot5 = atoi(row[10]); - entry.augslot6 = atoi(row[11]); + e.zoneid = atoi(row[0]); + e.parentid = atoi(row[1]); + e.bagidx = atoi(row[2]); + e.itemid = atoi(row[3]); + e.charges = atoi(row[4]); + e.droptime = strtoll(row[5] ? row[5] : "-1", nullptr, 10); + e.augslot1 = atoi(row[6]); + e.augslot2 = atoi(row[7]); + e.augslot3 = atoi(row[8]); + e.augslot4 = atoi(row[9]); + e.augslot5 = atoi(row[10]); + e.augslot6 = atoi(row[11]); - return entry; + return e; } return NewEntity(); @@ -196,33 +196,33 @@ public: static int UpdateOne( Database& db, - ObjectContents object_contents_entry + const ObjectContents &e ) { - std::vector update_values; + std::vector v; auto columns = Columns(); - update_values.push_back(columns[0] + " = " + std::to_string(object_contents_entry.zoneid)); - update_values.push_back(columns[1] + " = " + std::to_string(object_contents_entry.parentid)); - update_values.push_back(columns[2] + " = " + std::to_string(object_contents_entry.bagidx)); - update_values.push_back(columns[3] + " = " + std::to_string(object_contents_entry.itemid)); - update_values.push_back(columns[4] + " = " + std::to_string(object_contents_entry.charges)); - update_values.push_back(columns[5] + " = FROM_UNIXTIME(" + (object_contents_entry.droptime > 0 ? std::to_string(object_contents_entry.droptime) : "null") + ")"); - update_values.push_back(columns[6] + " = " + std::to_string(object_contents_entry.augslot1)); - update_values.push_back(columns[7] + " = " + std::to_string(object_contents_entry.augslot2)); - update_values.push_back(columns[8] + " = " + std::to_string(object_contents_entry.augslot3)); - update_values.push_back(columns[9] + " = " + std::to_string(object_contents_entry.augslot4)); - update_values.push_back(columns[10] + " = " + std::to_string(object_contents_entry.augslot5)); - update_values.push_back(columns[11] + " = " + std::to_string(object_contents_entry.augslot6)); + v.push_back(columns[0] + " = " + std::to_string(e.zoneid)); + v.push_back(columns[1] + " = " + std::to_string(e.parentid)); + v.push_back(columns[2] + " = " + std::to_string(e.bagidx)); + v.push_back(columns[3] + " = " + std::to_string(e.itemid)); + v.push_back(columns[4] + " = " + std::to_string(e.charges)); + v.push_back(columns[5] + " = FROM_UNIXTIME(" + (e.droptime > 0 ? std::to_string(e.droptime) : "null") + ")"); + v.push_back(columns[6] + " = " + std::to_string(e.augslot1)); + v.push_back(columns[7] + " = " + std::to_string(e.augslot2)); + v.push_back(columns[8] + " = " + std::to_string(e.augslot3)); + v.push_back(columns[9] + " = " + std::to_string(e.augslot4)); + v.push_back(columns[10] + " = " + std::to_string(e.augslot5)); + v.push_back(columns[11] + " = " + std::to_string(e.augslot6)); auto results = db.QueryDatabase( fmt::format( "UPDATE {} SET {} WHERE {} = {}", TableName(), - Strings::Implode(", ", update_values), + Strings::Implode(", ", v), PrimaryKey(), - object_contents_entry.parentid + e.parentid ) ); @@ -231,69 +231,69 @@ public: static ObjectContents InsertOne( Database& db, - ObjectContents object_contents_entry + ObjectContents e ) { - std::vector insert_values; + std::vector v; - insert_values.push_back(std::to_string(object_contents_entry.zoneid)); - insert_values.push_back(std::to_string(object_contents_entry.parentid)); - insert_values.push_back(std::to_string(object_contents_entry.bagidx)); - insert_values.push_back(std::to_string(object_contents_entry.itemid)); - insert_values.push_back(std::to_string(object_contents_entry.charges)); - insert_values.push_back("FROM_UNIXTIME(" + (object_contents_entry.droptime > 0 ? std::to_string(object_contents_entry.droptime) : "null") + ")"); - insert_values.push_back(std::to_string(object_contents_entry.augslot1)); - insert_values.push_back(std::to_string(object_contents_entry.augslot2)); - insert_values.push_back(std::to_string(object_contents_entry.augslot3)); - insert_values.push_back(std::to_string(object_contents_entry.augslot4)); - insert_values.push_back(std::to_string(object_contents_entry.augslot5)); - insert_values.push_back(std::to_string(object_contents_entry.augslot6)); + v.push_back(std::to_string(e.zoneid)); + v.push_back(std::to_string(e.parentid)); + v.push_back(std::to_string(e.bagidx)); + v.push_back(std::to_string(e.itemid)); + v.push_back(std::to_string(e.charges)); + v.push_back("FROM_UNIXTIME(" + (e.droptime > 0 ? std::to_string(e.droptime) : "null") + ")"); + 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)); auto results = db.QueryDatabase( fmt::format( "{} VALUES ({})", BaseInsert(), - Strings::Implode(",", insert_values) + Strings::Implode(",", v) ) ); if (results.Success()) { - object_contents_entry.parentid = results.LastInsertedID(); - return object_contents_entry; + e.parentid = results.LastInsertedID(); + return e; } - object_contents_entry = NewEntity(); + e = NewEntity(); - return object_contents_entry; + return e; } static int InsertMany( Database& db, - std::vector object_contents_entries + const std::vector &entries ) { std::vector insert_chunks; - for (auto &object_contents_entry: object_contents_entries) { - std::vector insert_values; + for (auto &e: entries) { + std::vector v; - insert_values.push_back(std::to_string(object_contents_entry.zoneid)); - insert_values.push_back(std::to_string(object_contents_entry.parentid)); - insert_values.push_back(std::to_string(object_contents_entry.bagidx)); - insert_values.push_back(std::to_string(object_contents_entry.itemid)); - insert_values.push_back(std::to_string(object_contents_entry.charges)); - insert_values.push_back("FROM_UNIXTIME(" + (object_contents_entry.droptime > 0 ? std::to_string(object_contents_entry.droptime) : "null") + ")"); - insert_values.push_back(std::to_string(object_contents_entry.augslot1)); - insert_values.push_back(std::to_string(object_contents_entry.augslot2)); - insert_values.push_back(std::to_string(object_contents_entry.augslot3)); - insert_values.push_back(std::to_string(object_contents_entry.augslot4)); - insert_values.push_back(std::to_string(object_contents_entry.augslot5)); - insert_values.push_back(std::to_string(object_contents_entry.augslot6)); + v.push_back(std::to_string(e.zoneid)); + v.push_back(std::to_string(e.parentid)); + v.push_back(std::to_string(e.bagidx)); + v.push_back(std::to_string(e.itemid)); + v.push_back(std::to_string(e.charges)); + v.push_back("FROM_UNIXTIME(" + (e.droptime > 0 ? std::to_string(e.droptime) : "null") + ")"); + 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)); - insert_chunks.push_back("(" + Strings::Implode(",", insert_values) + ")"); + insert_chunks.push_back("(" + Strings::Implode(",", v) + ")"); } - std::vector insert_values; + std::vector v; auto results = db.QueryDatabase( fmt::format( @@ -320,28 +320,28 @@ public: all_entries.reserve(results.RowCount()); for (auto row = results.begin(); row != results.end(); ++row) { - ObjectContents entry{}; + ObjectContents e{}; - entry.zoneid = atoi(row[0]); - entry.parentid = atoi(row[1]); - entry.bagidx = atoi(row[2]); - entry.itemid = atoi(row[3]); - entry.charges = atoi(row[4]); - entry.droptime = strtoll(row[5] ? row[5] : "-1", nullptr, 10); - entry.augslot1 = atoi(row[6]); - entry.augslot2 = atoi(row[7]); - entry.augslot3 = atoi(row[8]); - entry.augslot4 = atoi(row[9]); - entry.augslot5 = atoi(row[10]); - entry.augslot6 = atoi(row[11]); + e.zoneid = atoi(row[0]); + e.parentid = atoi(row[1]); + e.bagidx = atoi(row[2]); + e.itemid = atoi(row[3]); + e.charges = atoi(row[4]); + e.droptime = strtoll(row[5] ? row[5] : "-1", nullptr, 10); + e.augslot1 = atoi(row[6]); + e.augslot2 = atoi(row[7]); + e.augslot3 = atoi(row[8]); + e.augslot4 = atoi(row[9]); + e.augslot5 = atoi(row[10]); + e.augslot6 = atoi(row[11]); - all_entries.push_back(entry); + all_entries.push_back(e); } return all_entries; } - static std::vector GetWhere(Database& db, std::string where_filter) + static std::vector GetWhere(Database& db, const std::string &where_filter) { std::vector all_entries; @@ -356,28 +356,28 @@ public: all_entries.reserve(results.RowCount()); for (auto row = results.begin(); row != results.end(); ++row) { - ObjectContents entry{}; + ObjectContents e{}; - entry.zoneid = atoi(row[0]); - entry.parentid = atoi(row[1]); - entry.bagidx = atoi(row[2]); - entry.itemid = atoi(row[3]); - entry.charges = atoi(row[4]); - entry.droptime = strtoll(row[5] ? row[5] : "-1", nullptr, 10); - entry.augslot1 = atoi(row[6]); - entry.augslot2 = atoi(row[7]); - entry.augslot3 = atoi(row[8]); - entry.augslot4 = atoi(row[9]); - entry.augslot5 = atoi(row[10]); - entry.augslot6 = atoi(row[11]); + e.zoneid = atoi(row[0]); + e.parentid = atoi(row[1]); + e.bagidx = atoi(row[2]); + e.itemid = atoi(row[3]); + e.charges = atoi(row[4]); + e.droptime = strtoll(row[5] ? row[5] : "-1", nullptr, 10); + e.augslot1 = atoi(row[6]); + e.augslot2 = atoi(row[7]); + e.augslot3 = atoi(row[8]); + e.augslot4 = atoi(row[9]); + e.augslot5 = atoi(row[10]); + e.augslot6 = atoi(row[11]); - all_entries.push_back(entry); + all_entries.push_back(e); } return all_entries; } - static int DeleteWhere(Database& db, std::string where_filter) + static int DeleteWhere(Database& db, const std::string &where_filter) { auto results = db.QueryDatabase( fmt::format( @@ -402,6 +402,32 @@ public: 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); + } + }; #endif //EQEMU_BASE_OBJECT_CONTENTS_REPOSITORY_H diff --git a/common/repositories/base/base_object_repository.h b/common/repositories/base/base_object_repository.h index fe47f9f51..5aa04182d 100644 --- a/common/repositories/base/base_object_repository.h +++ b/common/repositories/base/base_object_repository.h @@ -163,43 +163,43 @@ public: static Object NewEntity() { - Object entry{}; + Object e{}; - entry.id = 0; - entry.zoneid = 0; - entry.version = 0; - entry.xpos = 0; - entry.ypos = 0; - entry.zpos = 0; - entry.heading = 0; - entry.itemid = 0; - entry.charges = 0; - entry.objectname = ""; - entry.type = 0; - entry.icon = 0; - entry.unknown08 = 0; - entry.unknown10 = 0; - entry.unknown20 = 0; - entry.unknown24 = 0; - entry.unknown60 = 0; - entry.unknown64 = 0; - entry.unknown68 = 0; - entry.unknown72 = 0; - entry.unknown76 = 0; - entry.unknown84 = 0; - entry.size = 100; - entry.tilt_x = 0; - entry.tilt_y = 0; - entry.display_name = ""; - entry.min_expansion = -1; - entry.max_expansion = -1; - entry.content_flags = ""; - entry.content_flags_disabled = ""; + e.id = 0; + e.zoneid = 0; + e.version = 0; + e.xpos = 0; + e.ypos = 0; + e.zpos = 0; + e.heading = 0; + e.itemid = 0; + e.charges = 0; + e.objectname = ""; + e.type = 0; + e.icon = 0; + e.unknown08 = 0; + e.unknown10 = 0; + e.unknown20 = 0; + e.unknown24 = 0; + e.unknown60 = 0; + e.unknown64 = 0; + e.unknown68 = 0; + e.unknown72 = 0; + e.unknown76 = 0; + e.unknown84 = 0; + e.size = 100; + e.tilt_x = 0; + e.tilt_y = 0; + e.display_name = ""; + e.min_expansion = -1; + e.max_expansion = -1; + e.content_flags = ""; + e.content_flags_disabled = ""; - return entry; + return e; } - static Object GetObjectEntry( + static Object GetObject( const std::vector &objects, int object_id ) @@ -228,40 +228,40 @@ public: auto row = results.begin(); if (results.RowCount() == 1) { - Object entry{}; + Object e{}; - entry.id = atoi(row[0]); - entry.zoneid = atoi(row[1]); - entry.version = atoi(row[2]); - entry.xpos = static_cast(atof(row[3])); - entry.ypos = static_cast(atof(row[4])); - entry.zpos = static_cast(atof(row[5])); - entry.heading = static_cast(atof(row[6])); - entry.itemid = atoi(row[7]); - entry.charges = atoi(row[8]); - entry.objectname = row[9] ? row[9] : ""; - entry.type = atoi(row[10]); - entry.icon = atoi(row[11]); - entry.unknown08 = atoi(row[12]); - entry.unknown10 = atoi(row[13]); - entry.unknown20 = atoi(row[14]); - entry.unknown24 = atoi(row[15]); - entry.unknown60 = atoi(row[16]); - entry.unknown64 = atoi(row[17]); - entry.unknown68 = atoi(row[18]); - entry.unknown72 = atoi(row[19]); - entry.unknown76 = atoi(row[20]); - entry.unknown84 = atoi(row[21]); - entry.size = static_cast(atof(row[22])); - entry.tilt_x = static_cast(atof(row[23])); - entry.tilt_y = static_cast(atof(row[24])); - entry.display_name = row[25] ? row[25] : ""; - entry.min_expansion = atoi(row[26]); - entry.max_expansion = atoi(row[27]); - entry.content_flags = row[28] ? row[28] : ""; - entry.content_flags_disabled = row[29] ? row[29] : ""; + e.id = atoi(row[0]); + e.zoneid = atoi(row[1]); + e.version = atoi(row[2]); + e.xpos = static_cast(atof(row[3])); + e.ypos = static_cast(atof(row[4])); + e.zpos = static_cast(atof(row[5])); + e.heading = static_cast(atof(row[6])); + e.itemid = atoi(row[7]); + e.charges = atoi(row[8]); + e.objectname = row[9] ? row[9] : ""; + e.type = atoi(row[10]); + e.icon = atoi(row[11]); + e.unknown08 = atoi(row[12]); + e.unknown10 = atoi(row[13]); + e.unknown20 = atoi(row[14]); + e.unknown24 = atoi(row[15]); + e.unknown60 = atoi(row[16]); + e.unknown64 = atoi(row[17]); + e.unknown68 = atoi(row[18]); + e.unknown72 = atoi(row[19]); + e.unknown76 = atoi(row[20]); + e.unknown84 = atoi(row[21]); + e.size = static_cast(atof(row[22])); + e.tilt_x = static_cast(atof(row[23])); + e.tilt_y = static_cast(atof(row[24])); + e.display_name = row[25] ? row[25] : ""; + e.min_expansion = atoi(row[26]); + e.max_expansion = atoi(row[27]); + e.content_flags = row[28] ? row[28] : ""; + e.content_flags_disabled = row[29] ? row[29] : ""; - return entry; + return e; } return NewEntity(); @@ -286,50 +286,50 @@ public: static int UpdateOne( Database& db, - Object object_entry + const Object &e ) { - std::vector update_values; + std::vector v; auto columns = Columns(); - update_values.push_back(columns[1] + " = " + std::to_string(object_entry.zoneid)); - update_values.push_back(columns[2] + " = " + std::to_string(object_entry.version)); - update_values.push_back(columns[3] + " = " + std::to_string(object_entry.xpos)); - update_values.push_back(columns[4] + " = " + std::to_string(object_entry.ypos)); - update_values.push_back(columns[5] + " = " + std::to_string(object_entry.zpos)); - update_values.push_back(columns[6] + " = " + std::to_string(object_entry.heading)); - update_values.push_back(columns[7] + " = " + std::to_string(object_entry.itemid)); - update_values.push_back(columns[8] + " = " + std::to_string(object_entry.charges)); - update_values.push_back(columns[9] + " = '" + Strings::Escape(object_entry.objectname) + "'"); - update_values.push_back(columns[10] + " = " + std::to_string(object_entry.type)); - update_values.push_back(columns[11] + " = " + std::to_string(object_entry.icon)); - update_values.push_back(columns[12] + " = " + std::to_string(object_entry.unknown08)); - update_values.push_back(columns[13] + " = " + std::to_string(object_entry.unknown10)); - update_values.push_back(columns[14] + " = " + std::to_string(object_entry.unknown20)); - update_values.push_back(columns[15] + " = " + std::to_string(object_entry.unknown24)); - update_values.push_back(columns[16] + " = " + std::to_string(object_entry.unknown60)); - update_values.push_back(columns[17] + " = " + std::to_string(object_entry.unknown64)); - update_values.push_back(columns[18] + " = " + std::to_string(object_entry.unknown68)); - update_values.push_back(columns[19] + " = " + std::to_string(object_entry.unknown72)); - update_values.push_back(columns[20] + " = " + std::to_string(object_entry.unknown76)); - update_values.push_back(columns[21] + " = " + std::to_string(object_entry.unknown84)); - update_values.push_back(columns[22] + " = " + std::to_string(object_entry.size)); - update_values.push_back(columns[23] + " = " + std::to_string(object_entry.tilt_x)); - update_values.push_back(columns[24] + " = " + std::to_string(object_entry.tilt_y)); - update_values.push_back(columns[25] + " = '" + Strings::Escape(object_entry.display_name) + "'"); - update_values.push_back(columns[26] + " = " + std::to_string(object_entry.min_expansion)); - update_values.push_back(columns[27] + " = " + std::to_string(object_entry.max_expansion)); - update_values.push_back(columns[28] + " = '" + Strings::Escape(object_entry.content_flags) + "'"); - update_values.push_back(columns[29] + " = '" + Strings::Escape(object_entry.content_flags_disabled) + "'"); + v.push_back(columns[1] + " = " + std::to_string(e.zoneid)); + v.push_back(columns[2] + " = " + std::to_string(e.version)); + v.push_back(columns[3] + " = " + std::to_string(e.xpos)); + v.push_back(columns[4] + " = " + std::to_string(e.ypos)); + v.push_back(columns[5] + " = " + std::to_string(e.zpos)); + v.push_back(columns[6] + " = " + std::to_string(e.heading)); + v.push_back(columns[7] + " = " + std::to_string(e.itemid)); + v.push_back(columns[8] + " = " + std::to_string(e.charges)); + v.push_back(columns[9] + " = '" + Strings::Escape(e.objectname) + "'"); + v.push_back(columns[10] + " = " + std::to_string(e.type)); + v.push_back(columns[11] + " = " + std::to_string(e.icon)); + v.push_back(columns[12] + " = " + std::to_string(e.unknown08)); + v.push_back(columns[13] + " = " + std::to_string(e.unknown10)); + v.push_back(columns[14] + " = " + std::to_string(e.unknown20)); + v.push_back(columns[15] + " = " + std::to_string(e.unknown24)); + v.push_back(columns[16] + " = " + std::to_string(e.unknown60)); + v.push_back(columns[17] + " = " + std::to_string(e.unknown64)); + v.push_back(columns[18] + " = " + std::to_string(e.unknown68)); + v.push_back(columns[19] + " = " + std::to_string(e.unknown72)); + v.push_back(columns[20] + " = " + std::to_string(e.unknown76)); + v.push_back(columns[21] + " = " + std::to_string(e.unknown84)); + v.push_back(columns[22] + " = " + std::to_string(e.size)); + v.push_back(columns[23] + " = " + std::to_string(e.tilt_x)); + v.push_back(columns[24] + " = " + std::to_string(e.tilt_y)); + v.push_back(columns[25] + " = '" + Strings::Escape(e.display_name) + "'"); + v.push_back(columns[26] + " = " + std::to_string(e.min_expansion)); + v.push_back(columns[27] + " = " + std::to_string(e.max_expansion)); + v.push_back(columns[28] + " = '" + Strings::Escape(e.content_flags) + "'"); + v.push_back(columns[29] + " = '" + Strings::Escape(e.content_flags_disabled) + "'"); auto results = db.QueryDatabase( fmt::format( "UPDATE {} SET {} WHERE {} = {}", TableName(), - Strings::Implode(", ", update_values), + Strings::Implode(", ", v), PrimaryKey(), - object_entry.id + e.id ) ); @@ -338,105 +338,105 @@ public: static Object InsertOne( Database& db, - Object object_entry + Object e ) { - std::vector insert_values; + std::vector v; - insert_values.push_back(std::to_string(object_entry.id)); - insert_values.push_back(std::to_string(object_entry.zoneid)); - insert_values.push_back(std::to_string(object_entry.version)); - insert_values.push_back(std::to_string(object_entry.xpos)); - insert_values.push_back(std::to_string(object_entry.ypos)); - insert_values.push_back(std::to_string(object_entry.zpos)); - insert_values.push_back(std::to_string(object_entry.heading)); - insert_values.push_back(std::to_string(object_entry.itemid)); - insert_values.push_back(std::to_string(object_entry.charges)); - insert_values.push_back("'" + Strings::Escape(object_entry.objectname) + "'"); - insert_values.push_back(std::to_string(object_entry.type)); - insert_values.push_back(std::to_string(object_entry.icon)); - insert_values.push_back(std::to_string(object_entry.unknown08)); - insert_values.push_back(std::to_string(object_entry.unknown10)); - insert_values.push_back(std::to_string(object_entry.unknown20)); - insert_values.push_back(std::to_string(object_entry.unknown24)); - insert_values.push_back(std::to_string(object_entry.unknown60)); - insert_values.push_back(std::to_string(object_entry.unknown64)); - insert_values.push_back(std::to_string(object_entry.unknown68)); - insert_values.push_back(std::to_string(object_entry.unknown72)); - insert_values.push_back(std::to_string(object_entry.unknown76)); - insert_values.push_back(std::to_string(object_entry.unknown84)); - insert_values.push_back(std::to_string(object_entry.size)); - insert_values.push_back(std::to_string(object_entry.tilt_x)); - insert_values.push_back(std::to_string(object_entry.tilt_y)); - insert_values.push_back("'" + Strings::Escape(object_entry.display_name) + "'"); - insert_values.push_back(std::to_string(object_entry.min_expansion)); - insert_values.push_back(std::to_string(object_entry.max_expansion)); - insert_values.push_back("'" + Strings::Escape(object_entry.content_flags) + "'"); - insert_values.push_back("'" + Strings::Escape(object_entry.content_flags_disabled) + "'"); + v.push_back(std::to_string(e.id)); + v.push_back(std::to_string(e.zoneid)); + v.push_back(std::to_string(e.version)); + v.push_back(std::to_string(e.xpos)); + v.push_back(std::to_string(e.ypos)); + v.push_back(std::to_string(e.zpos)); + v.push_back(std::to_string(e.heading)); + v.push_back(std::to_string(e.itemid)); + v.push_back(std::to_string(e.charges)); + v.push_back("'" + Strings::Escape(e.objectname) + "'"); + v.push_back(std::to_string(e.type)); + v.push_back(std::to_string(e.icon)); + v.push_back(std::to_string(e.unknown08)); + v.push_back(std::to_string(e.unknown10)); + v.push_back(std::to_string(e.unknown20)); + v.push_back(std::to_string(e.unknown24)); + v.push_back(std::to_string(e.unknown60)); + v.push_back(std::to_string(e.unknown64)); + v.push_back(std::to_string(e.unknown68)); + v.push_back(std::to_string(e.unknown72)); + v.push_back(std::to_string(e.unknown76)); + v.push_back(std::to_string(e.unknown84)); + v.push_back(std::to_string(e.size)); + v.push_back(std::to_string(e.tilt_x)); + v.push_back(std::to_string(e.tilt_y)); + v.push_back("'" + Strings::Escape(e.display_name) + "'"); + v.push_back(std::to_string(e.min_expansion)); + v.push_back(std::to_string(e.max_expansion)); + v.push_back("'" + Strings::Escape(e.content_flags) + "'"); + v.push_back("'" + Strings::Escape(e.content_flags_disabled) + "'"); auto results = db.QueryDatabase( fmt::format( "{} VALUES ({})", BaseInsert(), - Strings::Implode(",", insert_values) + Strings::Implode(",", v) ) ); if (results.Success()) { - object_entry.id = results.LastInsertedID(); - return object_entry; + e.id = results.LastInsertedID(); + return e; } - object_entry = NewEntity(); + e = NewEntity(); - return object_entry; + return e; } static int InsertMany( Database& db, - std::vector object_entries + const std::vector &entries ) { std::vector insert_chunks; - for (auto &object_entry: object_entries) { - std::vector insert_values; + for (auto &e: entries) { + std::vector v; - insert_values.push_back(std::to_string(object_entry.id)); - insert_values.push_back(std::to_string(object_entry.zoneid)); - insert_values.push_back(std::to_string(object_entry.version)); - insert_values.push_back(std::to_string(object_entry.xpos)); - insert_values.push_back(std::to_string(object_entry.ypos)); - insert_values.push_back(std::to_string(object_entry.zpos)); - insert_values.push_back(std::to_string(object_entry.heading)); - insert_values.push_back(std::to_string(object_entry.itemid)); - insert_values.push_back(std::to_string(object_entry.charges)); - insert_values.push_back("'" + Strings::Escape(object_entry.objectname) + "'"); - insert_values.push_back(std::to_string(object_entry.type)); - insert_values.push_back(std::to_string(object_entry.icon)); - insert_values.push_back(std::to_string(object_entry.unknown08)); - insert_values.push_back(std::to_string(object_entry.unknown10)); - insert_values.push_back(std::to_string(object_entry.unknown20)); - insert_values.push_back(std::to_string(object_entry.unknown24)); - insert_values.push_back(std::to_string(object_entry.unknown60)); - insert_values.push_back(std::to_string(object_entry.unknown64)); - insert_values.push_back(std::to_string(object_entry.unknown68)); - insert_values.push_back(std::to_string(object_entry.unknown72)); - insert_values.push_back(std::to_string(object_entry.unknown76)); - insert_values.push_back(std::to_string(object_entry.unknown84)); - insert_values.push_back(std::to_string(object_entry.size)); - insert_values.push_back(std::to_string(object_entry.tilt_x)); - insert_values.push_back(std::to_string(object_entry.tilt_y)); - insert_values.push_back("'" + Strings::Escape(object_entry.display_name) + "'"); - insert_values.push_back(std::to_string(object_entry.min_expansion)); - insert_values.push_back(std::to_string(object_entry.max_expansion)); - insert_values.push_back("'" + Strings::Escape(object_entry.content_flags) + "'"); - insert_values.push_back("'" + Strings::Escape(object_entry.content_flags_disabled) + "'"); + v.push_back(std::to_string(e.id)); + v.push_back(std::to_string(e.zoneid)); + v.push_back(std::to_string(e.version)); + v.push_back(std::to_string(e.xpos)); + v.push_back(std::to_string(e.ypos)); + v.push_back(std::to_string(e.zpos)); + v.push_back(std::to_string(e.heading)); + v.push_back(std::to_string(e.itemid)); + v.push_back(std::to_string(e.charges)); + v.push_back("'" + Strings::Escape(e.objectname) + "'"); + v.push_back(std::to_string(e.type)); + v.push_back(std::to_string(e.icon)); + v.push_back(std::to_string(e.unknown08)); + v.push_back(std::to_string(e.unknown10)); + v.push_back(std::to_string(e.unknown20)); + v.push_back(std::to_string(e.unknown24)); + v.push_back(std::to_string(e.unknown60)); + v.push_back(std::to_string(e.unknown64)); + v.push_back(std::to_string(e.unknown68)); + v.push_back(std::to_string(e.unknown72)); + v.push_back(std::to_string(e.unknown76)); + v.push_back(std::to_string(e.unknown84)); + v.push_back(std::to_string(e.size)); + v.push_back(std::to_string(e.tilt_x)); + v.push_back(std::to_string(e.tilt_y)); + v.push_back("'" + Strings::Escape(e.display_name) + "'"); + v.push_back(std::to_string(e.min_expansion)); + v.push_back(std::to_string(e.max_expansion)); + v.push_back("'" + Strings::Escape(e.content_flags) + "'"); + v.push_back("'" + Strings::Escape(e.content_flags_disabled) + "'"); - insert_chunks.push_back("(" + Strings::Implode(",", insert_values) + ")"); + insert_chunks.push_back("(" + Strings::Implode(",", v) + ")"); } - std::vector insert_values; + std::vector v; auto results = db.QueryDatabase( fmt::format( @@ -463,46 +463,46 @@ public: all_entries.reserve(results.RowCount()); for (auto row = results.begin(); row != results.end(); ++row) { - Object entry{}; + Object e{}; - entry.id = atoi(row[0]); - entry.zoneid = atoi(row[1]); - entry.version = atoi(row[2]); - entry.xpos = static_cast(atof(row[3])); - entry.ypos = static_cast(atof(row[4])); - entry.zpos = static_cast(atof(row[5])); - entry.heading = static_cast(atof(row[6])); - entry.itemid = atoi(row[7]); - entry.charges = atoi(row[8]); - entry.objectname = row[9] ? row[9] : ""; - entry.type = atoi(row[10]); - entry.icon = atoi(row[11]); - entry.unknown08 = atoi(row[12]); - entry.unknown10 = atoi(row[13]); - entry.unknown20 = atoi(row[14]); - entry.unknown24 = atoi(row[15]); - entry.unknown60 = atoi(row[16]); - entry.unknown64 = atoi(row[17]); - entry.unknown68 = atoi(row[18]); - entry.unknown72 = atoi(row[19]); - entry.unknown76 = atoi(row[20]); - entry.unknown84 = atoi(row[21]); - entry.size = static_cast(atof(row[22])); - entry.tilt_x = static_cast(atof(row[23])); - entry.tilt_y = static_cast(atof(row[24])); - entry.display_name = row[25] ? row[25] : ""; - entry.min_expansion = atoi(row[26]); - entry.max_expansion = atoi(row[27]); - entry.content_flags = row[28] ? row[28] : ""; - entry.content_flags_disabled = row[29] ? row[29] : ""; + e.id = atoi(row[0]); + e.zoneid = atoi(row[1]); + e.version = atoi(row[2]); + e.xpos = static_cast(atof(row[3])); + e.ypos = static_cast(atof(row[4])); + e.zpos = static_cast(atof(row[5])); + e.heading = static_cast(atof(row[6])); + e.itemid = atoi(row[7]); + e.charges = atoi(row[8]); + e.objectname = row[9] ? row[9] : ""; + e.type = atoi(row[10]); + e.icon = atoi(row[11]); + e.unknown08 = atoi(row[12]); + e.unknown10 = atoi(row[13]); + e.unknown20 = atoi(row[14]); + e.unknown24 = atoi(row[15]); + e.unknown60 = atoi(row[16]); + e.unknown64 = atoi(row[17]); + e.unknown68 = atoi(row[18]); + e.unknown72 = atoi(row[19]); + e.unknown76 = atoi(row[20]); + e.unknown84 = atoi(row[21]); + e.size = static_cast(atof(row[22])); + e.tilt_x = static_cast(atof(row[23])); + e.tilt_y = static_cast(atof(row[24])); + e.display_name = row[25] ? row[25] : ""; + e.min_expansion = atoi(row[26]); + e.max_expansion = atoi(row[27]); + e.content_flags = row[28] ? row[28] : ""; + e.content_flags_disabled = row[29] ? row[29] : ""; - all_entries.push_back(entry); + all_entries.push_back(e); } return all_entries; } - static std::vector GetWhere(Database& db, std::string where_filter) + static std::vector GetWhere(Database& db, const std::string &where_filter) { std::vector all_entries; @@ -517,46 +517,46 @@ public: all_entries.reserve(results.RowCount()); for (auto row = results.begin(); row != results.end(); ++row) { - Object entry{}; + Object e{}; - entry.id = atoi(row[0]); - entry.zoneid = atoi(row[1]); - entry.version = atoi(row[2]); - entry.xpos = static_cast(atof(row[3])); - entry.ypos = static_cast(atof(row[4])); - entry.zpos = static_cast(atof(row[5])); - entry.heading = static_cast(atof(row[6])); - entry.itemid = atoi(row[7]); - entry.charges = atoi(row[8]); - entry.objectname = row[9] ? row[9] : ""; - entry.type = atoi(row[10]); - entry.icon = atoi(row[11]); - entry.unknown08 = atoi(row[12]); - entry.unknown10 = atoi(row[13]); - entry.unknown20 = atoi(row[14]); - entry.unknown24 = atoi(row[15]); - entry.unknown60 = atoi(row[16]); - entry.unknown64 = atoi(row[17]); - entry.unknown68 = atoi(row[18]); - entry.unknown72 = atoi(row[19]); - entry.unknown76 = atoi(row[20]); - entry.unknown84 = atoi(row[21]); - entry.size = static_cast(atof(row[22])); - entry.tilt_x = static_cast(atof(row[23])); - entry.tilt_y = static_cast(atof(row[24])); - entry.display_name = row[25] ? row[25] : ""; - entry.min_expansion = atoi(row[26]); - entry.max_expansion = atoi(row[27]); - entry.content_flags = row[28] ? row[28] : ""; - entry.content_flags_disabled = row[29] ? row[29] : ""; + e.id = atoi(row[0]); + e.zoneid = atoi(row[1]); + e.version = atoi(row[2]); + e.xpos = static_cast(atof(row[3])); + e.ypos = static_cast(atof(row[4])); + e.zpos = static_cast(atof(row[5])); + e.heading = static_cast(atof(row[6])); + e.itemid = atoi(row[7]); + e.charges = atoi(row[8]); + e.objectname = row[9] ? row[9] : ""; + e.type = atoi(row[10]); + e.icon = atoi(row[11]); + e.unknown08 = atoi(row[12]); + e.unknown10 = atoi(row[13]); + e.unknown20 = atoi(row[14]); + e.unknown24 = atoi(row[15]); + e.unknown60 = atoi(row[16]); + e.unknown64 = atoi(row[17]); + e.unknown68 = atoi(row[18]); + e.unknown72 = atoi(row[19]); + e.unknown76 = atoi(row[20]); + e.unknown84 = atoi(row[21]); + e.size = static_cast(atof(row[22])); + e.tilt_x = static_cast(atof(row[23])); + e.tilt_y = static_cast(atof(row[24])); + e.display_name = row[25] ? row[25] : ""; + e.min_expansion = atoi(row[26]); + e.max_expansion = atoi(row[27]); + e.content_flags = row[28] ? row[28] : ""; + e.content_flags_disabled = row[29] ? row[29] : ""; - all_entries.push_back(entry); + all_entries.push_back(e); } return all_entries; } - static int DeleteWhere(Database& db, std::string where_filter) + static int DeleteWhere(Database& db, const std::string &where_filter) { auto results = db.QueryDatabase( fmt::format( @@ -581,6 +581,32 @@ public: 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); + } + }; #endif //EQEMU_BASE_OBJECT_REPOSITORY_H diff --git a/common/repositories/base/base_perl_event_export_settings_repository.h b/common/repositories/base/base_perl_event_export_settings_repository.h index e0e860992..3151699c2 100644 --- a/common/repositories/base/base_perl_event_export_settings_repository.h +++ b/common/repositories/base/base_perl_event_export_settings_repository.h @@ -94,20 +94,20 @@ public: static PerlEventExportSettings NewEntity() { - PerlEventExportSettings entry{}; + PerlEventExportSettings e{}; - entry.event_id = 0; - entry.event_description = ""; - entry.export_qglobals = 0; - entry.export_mob = 0; - entry.export_zone = 0; - entry.export_item = 0; - entry.export_event = 0; + e.event_id = 0; + e.event_description = ""; + e.export_qglobals = 0; + e.export_mob = 0; + e.export_zone = 0; + e.export_item = 0; + e.export_event = 0; - return entry; + return e; } - static PerlEventExportSettings GetPerlEventExportSettingsEntry( + static PerlEventExportSettings GetPerlEventExportSettings( const std::vector &perl_event_export_settingss, int perl_event_export_settings_id ) @@ -136,17 +136,17 @@ public: auto row = results.begin(); if (results.RowCount() == 1) { - PerlEventExportSettings entry{}; + PerlEventExportSettings e{}; - entry.event_id = atoi(row[0]); - entry.event_description = row[1] ? row[1] : ""; - entry.export_qglobals = atoi(row[2]); - entry.export_mob = atoi(row[3]); - entry.export_zone = atoi(row[4]); - entry.export_item = atoi(row[5]); - entry.export_event = atoi(row[6]); + e.event_id = atoi(row[0]); + e.event_description = row[1] ? row[1] : ""; + e.export_qglobals = atoi(row[2]); + e.export_mob = atoi(row[3]); + e.export_zone = atoi(row[4]); + e.export_item = atoi(row[5]); + e.export_event = atoi(row[6]); - return entry; + return e; } return NewEntity(); @@ -171,28 +171,28 @@ public: static int UpdateOne( Database& db, - PerlEventExportSettings perl_event_export_settings_entry + const PerlEventExportSettings &e ) { - std::vector update_values; + std::vector v; auto columns = Columns(); - update_values.push_back(columns[0] + " = " + std::to_string(perl_event_export_settings_entry.event_id)); - update_values.push_back(columns[1] + " = '" + Strings::Escape(perl_event_export_settings_entry.event_description) + "'"); - update_values.push_back(columns[2] + " = " + std::to_string(perl_event_export_settings_entry.export_qglobals)); - update_values.push_back(columns[3] + " = " + std::to_string(perl_event_export_settings_entry.export_mob)); - update_values.push_back(columns[4] + " = " + std::to_string(perl_event_export_settings_entry.export_zone)); - update_values.push_back(columns[5] + " = " + std::to_string(perl_event_export_settings_entry.export_item)); - update_values.push_back(columns[6] + " = " + std::to_string(perl_event_export_settings_entry.export_event)); + v.push_back(columns[0] + " = " + std::to_string(e.event_id)); + v.push_back(columns[1] + " = '" + Strings::Escape(e.event_description) + "'"); + v.push_back(columns[2] + " = " + std::to_string(e.export_qglobals)); + v.push_back(columns[3] + " = " + std::to_string(e.export_mob)); + v.push_back(columns[4] + " = " + std::to_string(e.export_zone)); + v.push_back(columns[5] + " = " + std::to_string(e.export_item)); + v.push_back(columns[6] + " = " + std::to_string(e.export_event)); auto results = db.QueryDatabase( fmt::format( "UPDATE {} SET {} WHERE {} = {}", TableName(), - Strings::Implode(", ", update_values), + Strings::Implode(", ", v), PrimaryKey(), - perl_event_export_settings_entry.event_id + e.event_id ) ); @@ -201,59 +201,59 @@ public: static PerlEventExportSettings InsertOne( Database& db, - PerlEventExportSettings perl_event_export_settings_entry + PerlEventExportSettings e ) { - std::vector insert_values; + std::vector v; - insert_values.push_back(std::to_string(perl_event_export_settings_entry.event_id)); - insert_values.push_back("'" + Strings::Escape(perl_event_export_settings_entry.event_description) + "'"); - insert_values.push_back(std::to_string(perl_event_export_settings_entry.export_qglobals)); - insert_values.push_back(std::to_string(perl_event_export_settings_entry.export_mob)); - insert_values.push_back(std::to_string(perl_event_export_settings_entry.export_zone)); - insert_values.push_back(std::to_string(perl_event_export_settings_entry.export_item)); - insert_values.push_back(std::to_string(perl_event_export_settings_entry.export_event)); + v.push_back(std::to_string(e.event_id)); + v.push_back("'" + Strings::Escape(e.event_description) + "'"); + v.push_back(std::to_string(e.export_qglobals)); + v.push_back(std::to_string(e.export_mob)); + v.push_back(std::to_string(e.export_zone)); + v.push_back(std::to_string(e.export_item)); + v.push_back(std::to_string(e.export_event)); auto results = db.QueryDatabase( fmt::format( "{} VALUES ({})", BaseInsert(), - Strings::Implode(",", insert_values) + Strings::Implode(",", v) ) ); if (results.Success()) { - perl_event_export_settings_entry.event_id = results.LastInsertedID(); - return perl_event_export_settings_entry; + e.event_id = results.LastInsertedID(); + return e; } - perl_event_export_settings_entry = NewEntity(); + e = NewEntity(); - return perl_event_export_settings_entry; + return e; } static int InsertMany( Database& db, - std::vector perl_event_export_settings_entries + const std::vector &entries ) { std::vector insert_chunks; - for (auto &perl_event_export_settings_entry: perl_event_export_settings_entries) { - std::vector insert_values; + for (auto &e: entries) { + std::vector v; - insert_values.push_back(std::to_string(perl_event_export_settings_entry.event_id)); - insert_values.push_back("'" + Strings::Escape(perl_event_export_settings_entry.event_description) + "'"); - insert_values.push_back(std::to_string(perl_event_export_settings_entry.export_qglobals)); - insert_values.push_back(std::to_string(perl_event_export_settings_entry.export_mob)); - insert_values.push_back(std::to_string(perl_event_export_settings_entry.export_zone)); - insert_values.push_back(std::to_string(perl_event_export_settings_entry.export_item)); - insert_values.push_back(std::to_string(perl_event_export_settings_entry.export_event)); + v.push_back(std::to_string(e.event_id)); + v.push_back("'" + Strings::Escape(e.event_description) + "'"); + v.push_back(std::to_string(e.export_qglobals)); + v.push_back(std::to_string(e.export_mob)); + v.push_back(std::to_string(e.export_zone)); + v.push_back(std::to_string(e.export_item)); + v.push_back(std::to_string(e.export_event)); - insert_chunks.push_back("(" + Strings::Implode(",", insert_values) + ")"); + insert_chunks.push_back("(" + Strings::Implode(",", v) + ")"); } - std::vector insert_values; + std::vector v; auto results = db.QueryDatabase( fmt::format( @@ -280,23 +280,23 @@ public: all_entries.reserve(results.RowCount()); for (auto row = results.begin(); row != results.end(); ++row) { - PerlEventExportSettings entry{}; + PerlEventExportSettings e{}; - entry.event_id = atoi(row[0]); - entry.event_description = row[1] ? row[1] : ""; - entry.export_qglobals = atoi(row[2]); - entry.export_mob = atoi(row[3]); - entry.export_zone = atoi(row[4]); - entry.export_item = atoi(row[5]); - entry.export_event = atoi(row[6]); + e.event_id = atoi(row[0]); + e.event_description = row[1] ? row[1] : ""; + e.export_qglobals = atoi(row[2]); + e.export_mob = atoi(row[3]); + e.export_zone = atoi(row[4]); + e.export_item = atoi(row[5]); + e.export_event = atoi(row[6]); - all_entries.push_back(entry); + all_entries.push_back(e); } return all_entries; } - static std::vector GetWhere(Database& db, std::string where_filter) + static std::vector GetWhere(Database& db, const std::string &where_filter) { std::vector all_entries; @@ -311,23 +311,23 @@ public: all_entries.reserve(results.RowCount()); for (auto row = results.begin(); row != results.end(); ++row) { - PerlEventExportSettings entry{}; + PerlEventExportSettings e{}; - entry.event_id = atoi(row[0]); - entry.event_description = row[1] ? row[1] : ""; - entry.export_qglobals = atoi(row[2]); - entry.export_mob = atoi(row[3]); - entry.export_zone = atoi(row[4]); - entry.export_item = atoi(row[5]); - entry.export_event = atoi(row[6]); + e.event_id = atoi(row[0]); + e.event_description = row[1] ? row[1] : ""; + e.export_qglobals = atoi(row[2]); + e.export_mob = atoi(row[3]); + e.export_zone = atoi(row[4]); + e.export_item = atoi(row[5]); + e.export_event = atoi(row[6]); - all_entries.push_back(entry); + all_entries.push_back(e); } return all_entries; } - static int DeleteWhere(Database& db, std::string where_filter) + static int DeleteWhere(Database& db, const std::string &where_filter) { auto results = db.QueryDatabase( fmt::format( @@ -352,6 +352,32 @@ public: 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); + } + }; #endif //EQEMU_BASE_PERL_EVENT_EXPORT_SETTINGS_REPOSITORY_H diff --git a/common/repositories/base/base_petitions_repository.h b/common/repositories/base/base_petitions_repository.h index 0c8ca311c..74fe0e041 100644 --- a/common/repositories/base/base_petitions_repository.h +++ b/common/repositories/base/base_petitions_repository.h @@ -121,29 +121,29 @@ public: static Petitions NewEntity() { - Petitions entry{}; + Petitions e{}; - entry.dib = 0; - entry.petid = 0; - entry.charname = ""; - entry.accountname = ""; - entry.lastgm = ""; - entry.petitiontext = ""; - entry.gmtext = ""; - entry.zone = ""; - entry.urgency = 0; - entry.charclass = 0; - entry.charrace = 0; - entry.charlevel = 0; - entry.checkouts = 0; - entry.unavailables = 0; - entry.ischeckedout = 0; - entry.senttime = 0; + e.dib = 0; + e.petid = 0; + e.charname = ""; + e.accountname = ""; + e.lastgm = ""; + e.petitiontext = ""; + e.gmtext = ""; + e.zone = ""; + e.urgency = 0; + e.charclass = 0; + e.charrace = 0; + e.charlevel = 0; + e.checkouts = 0; + e.unavailables = 0; + e.ischeckedout = 0; + e.senttime = 0; - return entry; + return e; } - static Petitions GetPetitionsEntry( + static Petitions GetPetitions( const std::vector &petitionss, int petitions_id ) @@ -172,26 +172,26 @@ public: auto row = results.begin(); if (results.RowCount() == 1) { - Petitions entry{}; + Petitions e{}; - entry.dib = atoi(row[0]); - entry.petid = atoi(row[1]); - entry.charname = row[2] ? row[2] : ""; - entry.accountname = row[3] ? row[3] : ""; - entry.lastgm = row[4] ? row[4] : ""; - entry.petitiontext = row[5] ? row[5] : ""; - entry.gmtext = row[6] ? row[6] : ""; - entry.zone = row[7] ? row[7] : ""; - entry.urgency = atoi(row[8]); - entry.charclass = atoi(row[9]); - entry.charrace = atoi(row[10]); - entry.charlevel = atoi(row[11]); - entry.checkouts = atoi(row[12]); - entry.unavailables = atoi(row[13]); - entry.ischeckedout = atoi(row[14]); - entry.senttime = strtoll(row[15], nullptr, 10); + e.dib = atoi(row[0]); + e.petid = atoi(row[1]); + e.charname = row[2] ? row[2] : ""; + e.accountname = row[3] ? row[3] : ""; + e.lastgm = row[4] ? row[4] : ""; + e.petitiontext = row[5] ? row[5] : ""; + e.gmtext = row[6] ? row[6] : ""; + e.zone = row[7] ? row[7] : ""; + e.urgency = atoi(row[8]); + e.charclass = atoi(row[9]); + e.charrace = atoi(row[10]); + e.charlevel = atoi(row[11]); + e.checkouts = atoi(row[12]); + e.unavailables = atoi(row[13]); + e.ischeckedout = atoi(row[14]); + e.senttime = strtoll(row[15], nullptr, 10); - return entry; + return e; } return NewEntity(); @@ -216,36 +216,36 @@ public: static int UpdateOne( Database& db, - Petitions petitions_entry + const Petitions &e ) { - std::vector update_values; + std::vector v; auto columns = Columns(); - update_values.push_back(columns[1] + " = " + std::to_string(petitions_entry.petid)); - update_values.push_back(columns[2] + " = '" + Strings::Escape(petitions_entry.charname) + "'"); - update_values.push_back(columns[3] + " = '" + Strings::Escape(petitions_entry.accountname) + "'"); - update_values.push_back(columns[4] + " = '" + Strings::Escape(petitions_entry.lastgm) + "'"); - update_values.push_back(columns[5] + " = '" + Strings::Escape(petitions_entry.petitiontext) + "'"); - update_values.push_back(columns[6] + " = '" + Strings::Escape(petitions_entry.gmtext) + "'"); - update_values.push_back(columns[7] + " = '" + Strings::Escape(petitions_entry.zone) + "'"); - update_values.push_back(columns[8] + " = " + std::to_string(petitions_entry.urgency)); - update_values.push_back(columns[9] + " = " + std::to_string(petitions_entry.charclass)); - update_values.push_back(columns[10] + " = " + std::to_string(petitions_entry.charrace)); - update_values.push_back(columns[11] + " = " + std::to_string(petitions_entry.charlevel)); - update_values.push_back(columns[12] + " = " + std::to_string(petitions_entry.checkouts)); - update_values.push_back(columns[13] + " = " + std::to_string(petitions_entry.unavailables)); - update_values.push_back(columns[14] + " = " + std::to_string(petitions_entry.ischeckedout)); - update_values.push_back(columns[15] + " = " + std::to_string(petitions_entry.senttime)); + v.push_back(columns[1] + " = " + std::to_string(e.petid)); + v.push_back(columns[2] + " = '" + Strings::Escape(e.charname) + "'"); + v.push_back(columns[3] + " = '" + Strings::Escape(e.accountname) + "'"); + v.push_back(columns[4] + " = '" + Strings::Escape(e.lastgm) + "'"); + v.push_back(columns[5] + " = '" + Strings::Escape(e.petitiontext) + "'"); + v.push_back(columns[6] + " = '" + Strings::Escape(e.gmtext) + "'"); + v.push_back(columns[7] + " = '" + Strings::Escape(e.zone) + "'"); + v.push_back(columns[8] + " = " + std::to_string(e.urgency)); + v.push_back(columns[9] + " = " + std::to_string(e.charclass)); + v.push_back(columns[10] + " = " + std::to_string(e.charrace)); + v.push_back(columns[11] + " = " + std::to_string(e.charlevel)); + v.push_back(columns[12] + " = " + std::to_string(e.checkouts)); + v.push_back(columns[13] + " = " + std::to_string(e.unavailables)); + v.push_back(columns[14] + " = " + std::to_string(e.ischeckedout)); + v.push_back(columns[15] + " = " + std::to_string(e.senttime)); auto results = db.QueryDatabase( fmt::format( "UPDATE {} SET {} WHERE {} = {}", TableName(), - Strings::Implode(", ", update_values), + Strings::Implode(", ", v), PrimaryKey(), - petitions_entry.dib + e.dib ) ); @@ -254,77 +254,77 @@ public: static Petitions InsertOne( Database& db, - Petitions petitions_entry + Petitions e ) { - std::vector insert_values; + std::vector v; - insert_values.push_back(std::to_string(petitions_entry.dib)); - insert_values.push_back(std::to_string(petitions_entry.petid)); - insert_values.push_back("'" + Strings::Escape(petitions_entry.charname) + "'"); - insert_values.push_back("'" + Strings::Escape(petitions_entry.accountname) + "'"); - insert_values.push_back("'" + Strings::Escape(petitions_entry.lastgm) + "'"); - insert_values.push_back("'" + Strings::Escape(petitions_entry.petitiontext) + "'"); - insert_values.push_back("'" + Strings::Escape(petitions_entry.gmtext) + "'"); - insert_values.push_back("'" + Strings::Escape(petitions_entry.zone) + "'"); - insert_values.push_back(std::to_string(petitions_entry.urgency)); - insert_values.push_back(std::to_string(petitions_entry.charclass)); - insert_values.push_back(std::to_string(petitions_entry.charrace)); - insert_values.push_back(std::to_string(petitions_entry.charlevel)); - insert_values.push_back(std::to_string(petitions_entry.checkouts)); - insert_values.push_back(std::to_string(petitions_entry.unavailables)); - insert_values.push_back(std::to_string(petitions_entry.ischeckedout)); - insert_values.push_back(std::to_string(petitions_entry.senttime)); + v.push_back(std::to_string(e.dib)); + v.push_back(std::to_string(e.petid)); + v.push_back("'" + Strings::Escape(e.charname) + "'"); + v.push_back("'" + Strings::Escape(e.accountname) + "'"); + v.push_back("'" + Strings::Escape(e.lastgm) + "'"); + v.push_back("'" + Strings::Escape(e.petitiontext) + "'"); + v.push_back("'" + Strings::Escape(e.gmtext) + "'"); + v.push_back("'" + Strings::Escape(e.zone) + "'"); + v.push_back(std::to_string(e.urgency)); + v.push_back(std::to_string(e.charclass)); + v.push_back(std::to_string(e.charrace)); + v.push_back(std::to_string(e.charlevel)); + v.push_back(std::to_string(e.checkouts)); + v.push_back(std::to_string(e.unavailables)); + v.push_back(std::to_string(e.ischeckedout)); + v.push_back(std::to_string(e.senttime)); auto results = db.QueryDatabase( fmt::format( "{} VALUES ({})", BaseInsert(), - Strings::Implode(",", insert_values) + Strings::Implode(",", v) ) ); if (results.Success()) { - petitions_entry.dib = results.LastInsertedID(); - return petitions_entry; + e.dib = results.LastInsertedID(); + return e; } - petitions_entry = NewEntity(); + e = NewEntity(); - return petitions_entry; + return e; } static int InsertMany( Database& db, - std::vector petitions_entries + const std::vector &entries ) { std::vector insert_chunks; - for (auto &petitions_entry: petitions_entries) { - std::vector insert_values; + for (auto &e: entries) { + std::vector v; - insert_values.push_back(std::to_string(petitions_entry.dib)); - insert_values.push_back(std::to_string(petitions_entry.petid)); - insert_values.push_back("'" + Strings::Escape(petitions_entry.charname) + "'"); - insert_values.push_back("'" + Strings::Escape(petitions_entry.accountname) + "'"); - insert_values.push_back("'" + Strings::Escape(petitions_entry.lastgm) + "'"); - insert_values.push_back("'" + Strings::Escape(petitions_entry.petitiontext) + "'"); - insert_values.push_back("'" + Strings::Escape(petitions_entry.gmtext) + "'"); - insert_values.push_back("'" + Strings::Escape(petitions_entry.zone) + "'"); - insert_values.push_back(std::to_string(petitions_entry.urgency)); - insert_values.push_back(std::to_string(petitions_entry.charclass)); - insert_values.push_back(std::to_string(petitions_entry.charrace)); - insert_values.push_back(std::to_string(petitions_entry.charlevel)); - insert_values.push_back(std::to_string(petitions_entry.checkouts)); - insert_values.push_back(std::to_string(petitions_entry.unavailables)); - insert_values.push_back(std::to_string(petitions_entry.ischeckedout)); - insert_values.push_back(std::to_string(petitions_entry.senttime)); + v.push_back(std::to_string(e.dib)); + v.push_back(std::to_string(e.petid)); + v.push_back("'" + Strings::Escape(e.charname) + "'"); + v.push_back("'" + Strings::Escape(e.accountname) + "'"); + v.push_back("'" + Strings::Escape(e.lastgm) + "'"); + v.push_back("'" + Strings::Escape(e.petitiontext) + "'"); + v.push_back("'" + Strings::Escape(e.gmtext) + "'"); + v.push_back("'" + Strings::Escape(e.zone) + "'"); + v.push_back(std::to_string(e.urgency)); + v.push_back(std::to_string(e.charclass)); + v.push_back(std::to_string(e.charrace)); + v.push_back(std::to_string(e.charlevel)); + v.push_back(std::to_string(e.checkouts)); + v.push_back(std::to_string(e.unavailables)); + v.push_back(std::to_string(e.ischeckedout)); + v.push_back(std::to_string(e.senttime)); - insert_chunks.push_back("(" + Strings::Implode(",", insert_values) + ")"); + insert_chunks.push_back("(" + Strings::Implode(",", v) + ")"); } - std::vector insert_values; + std::vector v; auto results = db.QueryDatabase( fmt::format( @@ -351,32 +351,32 @@ public: all_entries.reserve(results.RowCount()); for (auto row = results.begin(); row != results.end(); ++row) { - Petitions entry{}; + Petitions e{}; - entry.dib = atoi(row[0]); - entry.petid = atoi(row[1]); - entry.charname = row[2] ? row[2] : ""; - entry.accountname = row[3] ? row[3] : ""; - entry.lastgm = row[4] ? row[4] : ""; - entry.petitiontext = row[5] ? row[5] : ""; - entry.gmtext = row[6] ? row[6] : ""; - entry.zone = row[7] ? row[7] : ""; - entry.urgency = atoi(row[8]); - entry.charclass = atoi(row[9]); - entry.charrace = atoi(row[10]); - entry.charlevel = atoi(row[11]); - entry.checkouts = atoi(row[12]); - entry.unavailables = atoi(row[13]); - entry.ischeckedout = atoi(row[14]); - entry.senttime = strtoll(row[15], nullptr, 10); + e.dib = atoi(row[0]); + e.petid = atoi(row[1]); + e.charname = row[2] ? row[2] : ""; + e.accountname = row[3] ? row[3] : ""; + e.lastgm = row[4] ? row[4] : ""; + e.petitiontext = row[5] ? row[5] : ""; + e.gmtext = row[6] ? row[6] : ""; + e.zone = row[7] ? row[7] : ""; + e.urgency = atoi(row[8]); + e.charclass = atoi(row[9]); + e.charrace = atoi(row[10]); + e.charlevel = atoi(row[11]); + e.checkouts = atoi(row[12]); + e.unavailables = atoi(row[13]); + e.ischeckedout = atoi(row[14]); + e.senttime = strtoll(row[15], nullptr, 10); - all_entries.push_back(entry); + all_entries.push_back(e); } return all_entries; } - static std::vector GetWhere(Database& db, std::string where_filter) + static std::vector GetWhere(Database& db, const std::string &where_filter) { std::vector all_entries; @@ -391,32 +391,32 @@ public: all_entries.reserve(results.RowCount()); for (auto row = results.begin(); row != results.end(); ++row) { - Petitions entry{}; + Petitions e{}; - entry.dib = atoi(row[0]); - entry.petid = atoi(row[1]); - entry.charname = row[2] ? row[2] : ""; - entry.accountname = row[3] ? row[3] : ""; - entry.lastgm = row[4] ? row[4] : ""; - entry.petitiontext = row[5] ? row[5] : ""; - entry.gmtext = row[6] ? row[6] : ""; - entry.zone = row[7] ? row[7] : ""; - entry.urgency = atoi(row[8]); - entry.charclass = atoi(row[9]); - entry.charrace = atoi(row[10]); - entry.charlevel = atoi(row[11]); - entry.checkouts = atoi(row[12]); - entry.unavailables = atoi(row[13]); - entry.ischeckedout = atoi(row[14]); - entry.senttime = strtoll(row[15], nullptr, 10); + e.dib = atoi(row[0]); + e.petid = atoi(row[1]); + e.charname = row[2] ? row[2] : ""; + e.accountname = row[3] ? row[3] : ""; + e.lastgm = row[4] ? row[4] : ""; + e.petitiontext = row[5] ? row[5] : ""; + e.gmtext = row[6] ? row[6] : ""; + e.zone = row[7] ? row[7] : ""; + e.urgency = atoi(row[8]); + e.charclass = atoi(row[9]); + e.charrace = atoi(row[10]); + e.charlevel = atoi(row[11]); + e.checkouts = atoi(row[12]); + e.unavailables = atoi(row[13]); + e.ischeckedout = atoi(row[14]); + e.senttime = strtoll(row[15], nullptr, 10); - all_entries.push_back(entry); + all_entries.push_back(e); } return all_entries; } - static int DeleteWhere(Database& db, std::string where_filter) + static int DeleteWhere(Database& db, const std::string &where_filter) { auto results = db.QueryDatabase( fmt::format( @@ -441,6 +441,32 @@ public: 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); + } + }; #endif //EQEMU_BASE_PETITIONS_REPOSITORY_H diff --git a/common/repositories/base/base_pets_beastlord_data_repository.h b/common/repositories/base/base_pets_beastlord_data_repository.h index 1e0105fcc..34e2fc346 100644 --- a/common/repositories/base/base_pets_beastlord_data_repository.h +++ b/common/repositories/base/base_pets_beastlord_data_repository.h @@ -94,20 +94,20 @@ public: static PetsBeastlordData NewEntity() { - PetsBeastlordData entry{}; + PetsBeastlordData e{}; - entry.player_race = 1; - entry.pet_race = 42; - entry.texture = 0; - entry.helm_texture = 0; - entry.gender = 2; - entry.size_modifier = 1; - entry.face = 0; + e.player_race = 1; + e.pet_race = 42; + e.texture = 0; + e.helm_texture = 0; + e.gender = 2; + e.size_modifier = 1; + e.face = 0; - return entry; + return e; } - static PetsBeastlordData GetPetsBeastlordDataEntry( + static PetsBeastlordData GetPetsBeastlordData( const std::vector &pets_beastlord_datas, int pets_beastlord_data_id ) @@ -136,17 +136,17 @@ public: auto row = results.begin(); if (results.RowCount() == 1) { - PetsBeastlordData entry{}; + PetsBeastlordData e{}; - entry.player_race = atoi(row[0]); - entry.pet_race = atoi(row[1]); - entry.texture = atoi(row[2]); - entry.helm_texture = atoi(row[3]); - entry.gender = atoi(row[4]); - entry.size_modifier = static_cast(atof(row[5])); - entry.face = atoi(row[6]); + e.player_race = atoi(row[0]); + e.pet_race = atoi(row[1]); + e.texture = atoi(row[2]); + e.helm_texture = atoi(row[3]); + e.gender = atoi(row[4]); + e.size_modifier = static_cast(atof(row[5])); + e.face = atoi(row[6]); - return entry; + return e; } return NewEntity(); @@ -171,28 +171,28 @@ public: static int UpdateOne( Database& db, - PetsBeastlordData pets_beastlord_data_entry + const PetsBeastlordData &e ) { - std::vector update_values; + std::vector v; auto columns = Columns(); - update_values.push_back(columns[0] + " = " + std::to_string(pets_beastlord_data_entry.player_race)); - update_values.push_back(columns[1] + " = " + std::to_string(pets_beastlord_data_entry.pet_race)); - update_values.push_back(columns[2] + " = " + std::to_string(pets_beastlord_data_entry.texture)); - update_values.push_back(columns[3] + " = " + std::to_string(pets_beastlord_data_entry.helm_texture)); - update_values.push_back(columns[4] + " = " + std::to_string(pets_beastlord_data_entry.gender)); - update_values.push_back(columns[5] + " = " + std::to_string(pets_beastlord_data_entry.size_modifier)); - update_values.push_back(columns[6] + " = " + std::to_string(pets_beastlord_data_entry.face)); + v.push_back(columns[0] + " = " + std::to_string(e.player_race)); + v.push_back(columns[1] + " = " + std::to_string(e.pet_race)); + v.push_back(columns[2] + " = " + std::to_string(e.texture)); + v.push_back(columns[3] + " = " + std::to_string(e.helm_texture)); + v.push_back(columns[4] + " = " + std::to_string(e.gender)); + v.push_back(columns[5] + " = " + std::to_string(e.size_modifier)); + v.push_back(columns[6] + " = " + std::to_string(e.face)); auto results = db.QueryDatabase( fmt::format( "UPDATE {} SET {} WHERE {} = {}", TableName(), - Strings::Implode(", ", update_values), + Strings::Implode(", ", v), PrimaryKey(), - pets_beastlord_data_entry.player_race + e.player_race ) ); @@ -201,59 +201,59 @@ public: static PetsBeastlordData InsertOne( Database& db, - PetsBeastlordData pets_beastlord_data_entry + PetsBeastlordData e ) { - std::vector insert_values; + std::vector v; - insert_values.push_back(std::to_string(pets_beastlord_data_entry.player_race)); - insert_values.push_back(std::to_string(pets_beastlord_data_entry.pet_race)); - insert_values.push_back(std::to_string(pets_beastlord_data_entry.texture)); - insert_values.push_back(std::to_string(pets_beastlord_data_entry.helm_texture)); - insert_values.push_back(std::to_string(pets_beastlord_data_entry.gender)); - insert_values.push_back(std::to_string(pets_beastlord_data_entry.size_modifier)); - insert_values.push_back(std::to_string(pets_beastlord_data_entry.face)); + v.push_back(std::to_string(e.player_race)); + v.push_back(std::to_string(e.pet_race)); + v.push_back(std::to_string(e.texture)); + v.push_back(std::to_string(e.helm_texture)); + v.push_back(std::to_string(e.gender)); + v.push_back(std::to_string(e.size_modifier)); + v.push_back(std::to_string(e.face)); auto results = db.QueryDatabase( fmt::format( "{} VALUES ({})", BaseInsert(), - Strings::Implode(",", insert_values) + Strings::Implode(",", v) ) ); if (results.Success()) { - pets_beastlord_data_entry.player_race = results.LastInsertedID(); - return pets_beastlord_data_entry; + e.player_race = results.LastInsertedID(); + return e; } - pets_beastlord_data_entry = NewEntity(); + e = NewEntity(); - return pets_beastlord_data_entry; + return e; } static int InsertMany( Database& db, - std::vector pets_beastlord_data_entries + const std::vector &entries ) { std::vector insert_chunks; - for (auto &pets_beastlord_data_entry: pets_beastlord_data_entries) { - std::vector insert_values; + for (auto &e: entries) { + std::vector v; - insert_values.push_back(std::to_string(pets_beastlord_data_entry.player_race)); - insert_values.push_back(std::to_string(pets_beastlord_data_entry.pet_race)); - insert_values.push_back(std::to_string(pets_beastlord_data_entry.texture)); - insert_values.push_back(std::to_string(pets_beastlord_data_entry.helm_texture)); - insert_values.push_back(std::to_string(pets_beastlord_data_entry.gender)); - insert_values.push_back(std::to_string(pets_beastlord_data_entry.size_modifier)); - insert_values.push_back(std::to_string(pets_beastlord_data_entry.face)); + v.push_back(std::to_string(e.player_race)); + v.push_back(std::to_string(e.pet_race)); + v.push_back(std::to_string(e.texture)); + v.push_back(std::to_string(e.helm_texture)); + v.push_back(std::to_string(e.gender)); + v.push_back(std::to_string(e.size_modifier)); + v.push_back(std::to_string(e.face)); - insert_chunks.push_back("(" + Strings::Implode(",", insert_values) + ")"); + insert_chunks.push_back("(" + Strings::Implode(",", v) + ")"); } - std::vector insert_values; + std::vector v; auto results = db.QueryDatabase( fmt::format( @@ -280,23 +280,23 @@ public: all_entries.reserve(results.RowCount()); for (auto row = results.begin(); row != results.end(); ++row) { - PetsBeastlordData entry{}; + PetsBeastlordData e{}; - entry.player_race = atoi(row[0]); - entry.pet_race = atoi(row[1]); - entry.texture = atoi(row[2]); - entry.helm_texture = atoi(row[3]); - entry.gender = atoi(row[4]); - entry.size_modifier = static_cast(atof(row[5])); - entry.face = atoi(row[6]); + e.player_race = atoi(row[0]); + e.pet_race = atoi(row[1]); + e.texture = atoi(row[2]); + e.helm_texture = atoi(row[3]); + e.gender = atoi(row[4]); + e.size_modifier = static_cast(atof(row[5])); + e.face = atoi(row[6]); - all_entries.push_back(entry); + all_entries.push_back(e); } return all_entries; } - static std::vector GetWhere(Database& db, std::string where_filter) + static std::vector GetWhere(Database& db, const std::string &where_filter) { std::vector all_entries; @@ -311,23 +311,23 @@ public: all_entries.reserve(results.RowCount()); for (auto row = results.begin(); row != results.end(); ++row) { - PetsBeastlordData entry{}; + PetsBeastlordData e{}; - entry.player_race = atoi(row[0]); - entry.pet_race = atoi(row[1]); - entry.texture = atoi(row[2]); - entry.helm_texture = atoi(row[3]); - entry.gender = atoi(row[4]); - entry.size_modifier = static_cast(atof(row[5])); - entry.face = atoi(row[6]); + e.player_race = atoi(row[0]); + e.pet_race = atoi(row[1]); + e.texture = atoi(row[2]); + e.helm_texture = atoi(row[3]); + e.gender = atoi(row[4]); + e.size_modifier = static_cast(atof(row[5])); + e.face = atoi(row[6]); - all_entries.push_back(entry); + all_entries.push_back(e); } return all_entries; } - static int DeleteWhere(Database& db, std::string where_filter) + static int DeleteWhere(Database& db, const std::string &where_filter) { auto results = db.QueryDatabase( fmt::format( @@ -352,6 +352,32 @@ public: 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); + } + }; #endif //EQEMU_BASE_PETS_BEASTLORD_DATA_REPOSITORY_H diff --git a/common/repositories/base/base_pets_equipmentset_entries_repository.h b/common/repositories/base/base_pets_equipmentset_entries_repository.h index ddd5c63f6..c2ea4dec5 100644 --- a/common/repositories/base/base_pets_equipmentset_entries_repository.h +++ b/common/repositories/base/base_pets_equipmentset_entries_repository.h @@ -82,16 +82,16 @@ public: static PetsEquipmentsetEntries NewEntity() { - PetsEquipmentsetEntries entry{}; + PetsEquipmentsetEntries e{}; - entry.set_id = 0; - entry.slot = 0; - entry.item_id = 0; + e.set_id = 0; + e.slot = 0; + e.item_id = 0; - return entry; + return e; } - static PetsEquipmentsetEntries GetPetsEquipmentsetEntriesEntry( + static PetsEquipmentsetEntries GetPetsEquipmentsetEntries( const std::vector &pets_equipmentset_entriess, int pets_equipmentset_entries_id ) @@ -120,13 +120,13 @@ public: auto row = results.begin(); if (results.RowCount() == 1) { - PetsEquipmentsetEntries entry{}; + PetsEquipmentsetEntries e{}; - entry.set_id = atoi(row[0]); - entry.slot = atoi(row[1]); - entry.item_id = atoi(row[2]); + e.set_id = atoi(row[0]); + e.slot = atoi(row[1]); + e.item_id = atoi(row[2]); - return entry; + return e; } return NewEntity(); @@ -151,24 +151,24 @@ public: static int UpdateOne( Database& db, - PetsEquipmentsetEntries pets_equipmentset_entries_entry + const PetsEquipmentsetEntries &e ) { - std::vector update_values; + std::vector v; auto columns = Columns(); - update_values.push_back(columns[0] + " = " + std::to_string(pets_equipmentset_entries_entry.set_id)); - update_values.push_back(columns[1] + " = " + std::to_string(pets_equipmentset_entries_entry.slot)); - update_values.push_back(columns[2] + " = " + std::to_string(pets_equipmentset_entries_entry.item_id)); + v.push_back(columns[0] + " = " + std::to_string(e.set_id)); + v.push_back(columns[1] + " = " + std::to_string(e.slot)); + v.push_back(columns[2] + " = " + std::to_string(e.item_id)); auto results = db.QueryDatabase( fmt::format( "UPDATE {} SET {} WHERE {} = {}", TableName(), - Strings::Implode(", ", update_values), + Strings::Implode(", ", v), PrimaryKey(), - pets_equipmentset_entries_entry.set_id + e.set_id ) ); @@ -177,51 +177,51 @@ public: static PetsEquipmentsetEntries InsertOne( Database& db, - PetsEquipmentsetEntries pets_equipmentset_entries_entry + PetsEquipmentsetEntries e ) { - std::vector insert_values; + std::vector v; - insert_values.push_back(std::to_string(pets_equipmentset_entries_entry.set_id)); - insert_values.push_back(std::to_string(pets_equipmentset_entries_entry.slot)); - insert_values.push_back(std::to_string(pets_equipmentset_entries_entry.item_id)); + v.push_back(std::to_string(e.set_id)); + v.push_back(std::to_string(e.slot)); + v.push_back(std::to_string(e.item_id)); auto results = db.QueryDatabase( fmt::format( "{} VALUES ({})", BaseInsert(), - Strings::Implode(",", insert_values) + Strings::Implode(",", v) ) ); if (results.Success()) { - pets_equipmentset_entries_entry.set_id = results.LastInsertedID(); - return pets_equipmentset_entries_entry; + e.set_id = results.LastInsertedID(); + return e; } - pets_equipmentset_entries_entry = NewEntity(); + e = NewEntity(); - return pets_equipmentset_entries_entry; + return e; } static int InsertMany( Database& db, - std::vector pets_equipmentset_entries_entries + const std::vector &entries ) { std::vector insert_chunks; - for (auto &pets_equipmentset_entries_entry: pets_equipmentset_entries_entries) { - std::vector insert_values; + for (auto &e: entries) { + std::vector v; - insert_values.push_back(std::to_string(pets_equipmentset_entries_entry.set_id)); - insert_values.push_back(std::to_string(pets_equipmentset_entries_entry.slot)); - insert_values.push_back(std::to_string(pets_equipmentset_entries_entry.item_id)); + v.push_back(std::to_string(e.set_id)); + v.push_back(std::to_string(e.slot)); + v.push_back(std::to_string(e.item_id)); - insert_chunks.push_back("(" + Strings::Implode(",", insert_values) + ")"); + insert_chunks.push_back("(" + Strings::Implode(",", v) + ")"); } - std::vector insert_values; + std::vector v; auto results = db.QueryDatabase( fmt::format( @@ -248,19 +248,19 @@ public: all_entries.reserve(results.RowCount()); for (auto row = results.begin(); row != results.end(); ++row) { - PetsEquipmentsetEntries entry{}; + PetsEquipmentsetEntries e{}; - entry.set_id = atoi(row[0]); - entry.slot = atoi(row[1]); - entry.item_id = atoi(row[2]); + e.set_id = atoi(row[0]); + e.slot = atoi(row[1]); + e.item_id = atoi(row[2]); - all_entries.push_back(entry); + all_entries.push_back(e); } return all_entries; } - static std::vector GetWhere(Database& db, std::string where_filter) + static std::vector GetWhere(Database& db, const std::string &where_filter) { std::vector all_entries; @@ -275,19 +275,19 @@ public: all_entries.reserve(results.RowCount()); for (auto row = results.begin(); row != results.end(); ++row) { - PetsEquipmentsetEntries entry{}; + PetsEquipmentsetEntries e{}; - entry.set_id = atoi(row[0]); - entry.slot = atoi(row[1]); - entry.item_id = atoi(row[2]); + e.set_id = atoi(row[0]); + e.slot = atoi(row[1]); + e.item_id = atoi(row[2]); - all_entries.push_back(entry); + all_entries.push_back(e); } return all_entries; } - static int DeleteWhere(Database& db, std::string where_filter) + static int DeleteWhere(Database& db, const std::string &where_filter) { auto results = db.QueryDatabase( fmt::format( @@ -312,6 +312,32 @@ public: 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); + } + }; #endif //EQEMU_BASE_PETS_EQUIPMENTSET_ENTRIES_REPOSITORY_H diff --git a/common/repositories/base/base_pets_equipmentset_repository.h b/common/repositories/base/base_pets_equipmentset_repository.h index ba8241eb3..d8acbc206 100644 --- a/common/repositories/base/base_pets_equipmentset_repository.h +++ b/common/repositories/base/base_pets_equipmentset_repository.h @@ -82,16 +82,16 @@ public: static PetsEquipmentset NewEntity() { - PetsEquipmentset entry{}; + PetsEquipmentset e{}; - entry.set_id = 0; - entry.setname = ""; - entry.nested_set = -1; + e.set_id = 0; + e.setname = ""; + e.nested_set = -1; - return entry; + return e; } - static PetsEquipmentset GetPetsEquipmentsetEntry( + static PetsEquipmentset GetPetsEquipmentset( const std::vector &pets_equipmentsets, int pets_equipmentset_id ) @@ -120,13 +120,13 @@ public: auto row = results.begin(); if (results.RowCount() == 1) { - PetsEquipmentset entry{}; + PetsEquipmentset e{}; - entry.set_id = atoi(row[0]); - entry.setname = row[1] ? row[1] : ""; - entry.nested_set = atoi(row[2]); + e.set_id = atoi(row[0]); + e.setname = row[1] ? row[1] : ""; + e.nested_set = atoi(row[2]); - return entry; + return e; } return NewEntity(); @@ -151,24 +151,24 @@ public: static int UpdateOne( Database& db, - PetsEquipmentset pets_equipmentset_entry + const PetsEquipmentset &e ) { - std::vector update_values; + std::vector v; auto columns = Columns(); - update_values.push_back(columns[0] + " = " + std::to_string(pets_equipmentset_entry.set_id)); - update_values.push_back(columns[1] + " = '" + Strings::Escape(pets_equipmentset_entry.setname) + "'"); - update_values.push_back(columns[2] + " = " + std::to_string(pets_equipmentset_entry.nested_set)); + v.push_back(columns[0] + " = " + std::to_string(e.set_id)); + v.push_back(columns[1] + " = '" + Strings::Escape(e.setname) + "'"); + v.push_back(columns[2] + " = " + std::to_string(e.nested_set)); auto results = db.QueryDatabase( fmt::format( "UPDATE {} SET {} WHERE {} = {}", TableName(), - Strings::Implode(", ", update_values), + Strings::Implode(", ", v), PrimaryKey(), - pets_equipmentset_entry.set_id + e.set_id ) ); @@ -177,51 +177,51 @@ public: static PetsEquipmentset InsertOne( Database& db, - PetsEquipmentset pets_equipmentset_entry + PetsEquipmentset e ) { - std::vector insert_values; + std::vector v; - insert_values.push_back(std::to_string(pets_equipmentset_entry.set_id)); - insert_values.push_back("'" + Strings::Escape(pets_equipmentset_entry.setname) + "'"); - insert_values.push_back(std::to_string(pets_equipmentset_entry.nested_set)); + v.push_back(std::to_string(e.set_id)); + v.push_back("'" + Strings::Escape(e.setname) + "'"); + v.push_back(std::to_string(e.nested_set)); auto results = db.QueryDatabase( fmt::format( "{} VALUES ({})", BaseInsert(), - Strings::Implode(",", insert_values) + Strings::Implode(",", v) ) ); if (results.Success()) { - pets_equipmentset_entry.set_id = results.LastInsertedID(); - return pets_equipmentset_entry; + e.set_id = results.LastInsertedID(); + return e; } - pets_equipmentset_entry = NewEntity(); + e = NewEntity(); - return pets_equipmentset_entry; + return e; } static int InsertMany( Database& db, - std::vector pets_equipmentset_entries + const std::vector &entries ) { std::vector insert_chunks; - for (auto &pets_equipmentset_entry: pets_equipmentset_entries) { - std::vector insert_values; + for (auto &e: entries) { + std::vector v; - insert_values.push_back(std::to_string(pets_equipmentset_entry.set_id)); - insert_values.push_back("'" + Strings::Escape(pets_equipmentset_entry.setname) + "'"); - insert_values.push_back(std::to_string(pets_equipmentset_entry.nested_set)); + v.push_back(std::to_string(e.set_id)); + v.push_back("'" + Strings::Escape(e.setname) + "'"); + v.push_back(std::to_string(e.nested_set)); - insert_chunks.push_back("(" + Strings::Implode(",", insert_values) + ")"); + insert_chunks.push_back("(" + Strings::Implode(",", v) + ")"); } - std::vector insert_values; + std::vector v; auto results = db.QueryDatabase( fmt::format( @@ -248,19 +248,19 @@ public: all_entries.reserve(results.RowCount()); for (auto row = results.begin(); row != results.end(); ++row) { - PetsEquipmentset entry{}; + PetsEquipmentset e{}; - entry.set_id = atoi(row[0]); - entry.setname = row[1] ? row[1] : ""; - entry.nested_set = atoi(row[2]); + e.set_id = atoi(row[0]); + e.setname = row[1] ? row[1] : ""; + e.nested_set = atoi(row[2]); - all_entries.push_back(entry); + all_entries.push_back(e); } return all_entries; } - static std::vector GetWhere(Database& db, std::string where_filter) + static std::vector GetWhere(Database& db, const std::string &where_filter) { std::vector all_entries; @@ -275,19 +275,19 @@ public: all_entries.reserve(results.RowCount()); for (auto row = results.begin(); row != results.end(); ++row) { - PetsEquipmentset entry{}; + PetsEquipmentset e{}; - entry.set_id = atoi(row[0]); - entry.setname = row[1] ? row[1] : ""; - entry.nested_set = atoi(row[2]); + e.set_id = atoi(row[0]); + e.setname = row[1] ? row[1] : ""; + e.nested_set = atoi(row[2]); - all_entries.push_back(entry); + all_entries.push_back(e); } return all_entries; } - static int DeleteWhere(Database& db, std::string where_filter) + static int DeleteWhere(Database& db, const std::string &where_filter) { auto results = db.QueryDatabase( fmt::format( @@ -312,6 +312,32 @@ public: 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); + } + }; #endif //EQEMU_BASE_PETS_EQUIPMENTSET_REPOSITORY_H diff --git a/common/repositories/base/base_pets_repository.h b/common/repositories/base/base_pets_repository.h index faa13ee63..882a26e9d 100644 --- a/common/repositories/base/base_pets_repository.h +++ b/common/repositories/base/base_pets_repository.h @@ -100,22 +100,22 @@ public: static Pets NewEntity() { - Pets entry{}; + Pets e{}; - entry.id = 0; - entry.type = ""; - entry.petpower = 0; - entry.npcID = 0; - entry.temp = 0; - entry.petcontrol = 0; - entry.petnaming = 0; - entry.monsterflag = 0; - entry.equipmentset = -1; + e.id = 0; + e.type = ""; + e.petpower = 0; + e.npcID = 0; + e.temp = 0; + e.petcontrol = 0; + e.petnaming = 0; + e.monsterflag = 0; + e.equipmentset = -1; - return entry; + return e; } - static Pets GetPetsEntry( + static Pets GetPets( const std::vector &petss, int pets_id ) @@ -144,19 +144,19 @@ public: auto row = results.begin(); if (results.RowCount() == 1) { - Pets entry{}; + Pets e{}; - entry.id = atoi(row[0]); - entry.type = row[1] ? row[1] : ""; - entry.petpower = atoi(row[2]); - entry.npcID = atoi(row[3]); - entry.temp = atoi(row[4]); - entry.petcontrol = atoi(row[5]); - entry.petnaming = atoi(row[6]); - entry.monsterflag = atoi(row[7]); - entry.equipmentset = atoi(row[8]); + e.id = atoi(row[0]); + e.type = row[1] ? row[1] : ""; + e.petpower = atoi(row[2]); + e.npcID = atoi(row[3]); + e.temp = atoi(row[4]); + e.petcontrol = atoi(row[5]); + e.petnaming = atoi(row[6]); + e.monsterflag = atoi(row[7]); + e.equipmentset = atoi(row[8]); - return entry; + return e; } return NewEntity(); @@ -181,29 +181,29 @@ public: static int UpdateOne( Database& db, - Pets pets_entry + const Pets &e ) { - std::vector update_values; + std::vector v; auto columns = Columns(); - update_values.push_back(columns[1] + " = '" + Strings::Escape(pets_entry.type) + "'"); - update_values.push_back(columns[2] + " = " + std::to_string(pets_entry.petpower)); - update_values.push_back(columns[3] + " = " + std::to_string(pets_entry.npcID)); - update_values.push_back(columns[4] + " = " + std::to_string(pets_entry.temp)); - update_values.push_back(columns[5] + " = " + std::to_string(pets_entry.petcontrol)); - update_values.push_back(columns[6] + " = " + std::to_string(pets_entry.petnaming)); - update_values.push_back(columns[7] + " = " + std::to_string(pets_entry.monsterflag)); - update_values.push_back(columns[8] + " = " + std::to_string(pets_entry.equipmentset)); + v.push_back(columns[1] + " = '" + Strings::Escape(e.type) + "'"); + v.push_back(columns[2] + " = " + std::to_string(e.petpower)); + v.push_back(columns[3] + " = " + std::to_string(e.npcID)); + v.push_back(columns[4] + " = " + std::to_string(e.temp)); + v.push_back(columns[5] + " = " + std::to_string(e.petcontrol)); + v.push_back(columns[6] + " = " + std::to_string(e.petnaming)); + v.push_back(columns[7] + " = " + std::to_string(e.monsterflag)); + v.push_back(columns[8] + " = " + std::to_string(e.equipmentset)); auto results = db.QueryDatabase( fmt::format( "UPDATE {} SET {} WHERE {} = {}", TableName(), - Strings::Implode(", ", update_values), + Strings::Implode(", ", v), PrimaryKey(), - pets_entry.id + e.id ) ); @@ -212,63 +212,63 @@ public: static Pets InsertOne( Database& db, - Pets pets_entry + Pets e ) { - std::vector insert_values; + std::vector v; - insert_values.push_back(std::to_string(pets_entry.id)); - insert_values.push_back("'" + Strings::Escape(pets_entry.type) + "'"); - insert_values.push_back(std::to_string(pets_entry.petpower)); - insert_values.push_back(std::to_string(pets_entry.npcID)); - insert_values.push_back(std::to_string(pets_entry.temp)); - insert_values.push_back(std::to_string(pets_entry.petcontrol)); - insert_values.push_back(std::to_string(pets_entry.petnaming)); - insert_values.push_back(std::to_string(pets_entry.monsterflag)); - insert_values.push_back(std::to_string(pets_entry.equipmentset)); + v.push_back(std::to_string(e.id)); + v.push_back("'" + Strings::Escape(e.type) + "'"); + v.push_back(std::to_string(e.petpower)); + v.push_back(std::to_string(e.npcID)); + v.push_back(std::to_string(e.temp)); + v.push_back(std::to_string(e.petcontrol)); + v.push_back(std::to_string(e.petnaming)); + v.push_back(std::to_string(e.monsterflag)); + v.push_back(std::to_string(e.equipmentset)); auto results = db.QueryDatabase( fmt::format( "{} VALUES ({})", BaseInsert(), - Strings::Implode(",", insert_values) + Strings::Implode(",", v) ) ); if (results.Success()) { - pets_entry.id = results.LastInsertedID(); - return pets_entry; + e.id = results.LastInsertedID(); + return e; } - pets_entry = NewEntity(); + e = NewEntity(); - return pets_entry; + return e; } static int InsertMany( Database& db, - std::vector pets_entries + const std::vector &entries ) { std::vector insert_chunks; - for (auto &pets_entry: pets_entries) { - std::vector insert_values; + for (auto &e: entries) { + std::vector v; - insert_values.push_back(std::to_string(pets_entry.id)); - insert_values.push_back("'" + Strings::Escape(pets_entry.type) + "'"); - insert_values.push_back(std::to_string(pets_entry.petpower)); - insert_values.push_back(std::to_string(pets_entry.npcID)); - insert_values.push_back(std::to_string(pets_entry.temp)); - insert_values.push_back(std::to_string(pets_entry.petcontrol)); - insert_values.push_back(std::to_string(pets_entry.petnaming)); - insert_values.push_back(std::to_string(pets_entry.monsterflag)); - insert_values.push_back(std::to_string(pets_entry.equipmentset)); + v.push_back(std::to_string(e.id)); + v.push_back("'" + Strings::Escape(e.type) + "'"); + v.push_back(std::to_string(e.petpower)); + v.push_back(std::to_string(e.npcID)); + v.push_back(std::to_string(e.temp)); + v.push_back(std::to_string(e.petcontrol)); + v.push_back(std::to_string(e.petnaming)); + v.push_back(std::to_string(e.monsterflag)); + v.push_back(std::to_string(e.equipmentset)); - insert_chunks.push_back("(" + Strings::Implode(",", insert_values) + ")"); + insert_chunks.push_back("(" + Strings::Implode(",", v) + ")"); } - std::vector insert_values; + std::vector v; auto results = db.QueryDatabase( fmt::format( @@ -295,25 +295,25 @@ public: all_entries.reserve(results.RowCount()); for (auto row = results.begin(); row != results.end(); ++row) { - Pets entry{}; + Pets e{}; - entry.id = atoi(row[0]); - entry.type = row[1] ? row[1] : ""; - entry.petpower = atoi(row[2]); - entry.npcID = atoi(row[3]); - entry.temp = atoi(row[4]); - entry.petcontrol = atoi(row[5]); - entry.petnaming = atoi(row[6]); - entry.monsterflag = atoi(row[7]); - entry.equipmentset = atoi(row[8]); + e.id = atoi(row[0]); + e.type = row[1] ? row[1] : ""; + e.petpower = atoi(row[2]); + e.npcID = atoi(row[3]); + e.temp = atoi(row[4]); + e.petcontrol = atoi(row[5]); + e.petnaming = atoi(row[6]); + e.monsterflag = atoi(row[7]); + e.equipmentset = atoi(row[8]); - all_entries.push_back(entry); + all_entries.push_back(e); } return all_entries; } - static std::vector GetWhere(Database& db, std::string where_filter) + static std::vector GetWhere(Database& db, const std::string &where_filter) { std::vector all_entries; @@ -328,25 +328,25 @@ public: all_entries.reserve(results.RowCount()); for (auto row = results.begin(); row != results.end(); ++row) { - Pets entry{}; + Pets e{}; - entry.id = atoi(row[0]); - entry.type = row[1] ? row[1] : ""; - entry.petpower = atoi(row[2]); - entry.npcID = atoi(row[3]); - entry.temp = atoi(row[4]); - entry.petcontrol = atoi(row[5]); - entry.petnaming = atoi(row[6]); - entry.monsterflag = atoi(row[7]); - entry.equipmentset = atoi(row[8]); + e.id = atoi(row[0]); + e.type = row[1] ? row[1] : ""; + e.petpower = atoi(row[2]); + e.npcID = atoi(row[3]); + e.temp = atoi(row[4]); + e.petcontrol = atoi(row[5]); + e.petnaming = atoi(row[6]); + e.monsterflag = atoi(row[7]); + e.equipmentset = atoi(row[8]); - all_entries.push_back(entry); + all_entries.push_back(e); } return all_entries; } - static int DeleteWhere(Database& db, std::string where_filter) + static int DeleteWhere(Database& db, const std::string &where_filter) { auto results = db.QueryDatabase( fmt::format( @@ -371,6 +371,32 @@ public: 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); + } + }; #endif //EQEMU_BASE_PETS_REPOSITORY_H diff --git a/common/repositories/base/base_player_titlesets_repository.h b/common/repositories/base/base_player_titlesets_repository.h index 60e1bb5a5..298a66b0e 100644 --- a/common/repositories/base/base_player_titlesets_repository.h +++ b/common/repositories/base/base_player_titlesets_repository.h @@ -82,16 +82,16 @@ public: static PlayerTitlesets NewEntity() { - PlayerTitlesets entry{}; + PlayerTitlesets e{}; - entry.id = 0; - entry.char_id = 0; - entry.title_set = 0; + e.id = 0; + e.char_id = 0; + e.title_set = 0; - return entry; + return e; } - static PlayerTitlesets GetPlayerTitlesetsEntry( + static PlayerTitlesets GetPlayerTitlesets( const std::vector &player_titlesetss, int player_titlesets_id ) @@ -120,13 +120,13 @@ public: auto row = results.begin(); if (results.RowCount() == 1) { - PlayerTitlesets entry{}; + PlayerTitlesets e{}; - entry.id = atoi(row[0]); - entry.char_id = atoi(row[1]); - entry.title_set = atoi(row[2]); + e.id = atoi(row[0]); + e.char_id = atoi(row[1]); + e.title_set = atoi(row[2]); - return entry; + return e; } return NewEntity(); @@ -151,23 +151,23 @@ public: static int UpdateOne( Database& db, - PlayerTitlesets player_titlesets_entry + const PlayerTitlesets &e ) { - std::vector update_values; + std::vector v; auto columns = Columns(); - update_values.push_back(columns[1] + " = " + std::to_string(player_titlesets_entry.char_id)); - update_values.push_back(columns[2] + " = " + std::to_string(player_titlesets_entry.title_set)); + v.push_back(columns[1] + " = " + std::to_string(e.char_id)); + v.push_back(columns[2] + " = " + std::to_string(e.title_set)); auto results = db.QueryDatabase( fmt::format( "UPDATE {} SET {} WHERE {} = {}", TableName(), - Strings::Implode(", ", update_values), + Strings::Implode(", ", v), PrimaryKey(), - player_titlesets_entry.id + e.id ) ); @@ -176,51 +176,51 @@ public: static PlayerTitlesets InsertOne( Database& db, - PlayerTitlesets player_titlesets_entry + PlayerTitlesets e ) { - std::vector insert_values; + std::vector v; - insert_values.push_back(std::to_string(player_titlesets_entry.id)); - insert_values.push_back(std::to_string(player_titlesets_entry.char_id)); - insert_values.push_back(std::to_string(player_titlesets_entry.title_set)); + v.push_back(std::to_string(e.id)); + v.push_back(std::to_string(e.char_id)); + v.push_back(std::to_string(e.title_set)); auto results = db.QueryDatabase( fmt::format( "{} VALUES ({})", BaseInsert(), - Strings::Implode(",", insert_values) + Strings::Implode(",", v) ) ); if (results.Success()) { - player_titlesets_entry.id = results.LastInsertedID(); - return player_titlesets_entry; + e.id = results.LastInsertedID(); + return e; } - player_titlesets_entry = NewEntity(); + e = NewEntity(); - return player_titlesets_entry; + return e; } static int InsertMany( Database& db, - std::vector player_titlesets_entries + const std::vector &entries ) { std::vector insert_chunks; - for (auto &player_titlesets_entry: player_titlesets_entries) { - std::vector insert_values; + for (auto &e: entries) { + std::vector v; - insert_values.push_back(std::to_string(player_titlesets_entry.id)); - insert_values.push_back(std::to_string(player_titlesets_entry.char_id)); - insert_values.push_back(std::to_string(player_titlesets_entry.title_set)); + v.push_back(std::to_string(e.id)); + v.push_back(std::to_string(e.char_id)); + v.push_back(std::to_string(e.title_set)); - insert_chunks.push_back("(" + Strings::Implode(",", insert_values) + ")"); + insert_chunks.push_back("(" + Strings::Implode(",", v) + ")"); } - std::vector insert_values; + std::vector v; auto results = db.QueryDatabase( fmt::format( @@ -247,19 +247,19 @@ public: all_entries.reserve(results.RowCount()); for (auto row = results.begin(); row != results.end(); ++row) { - PlayerTitlesets entry{}; + PlayerTitlesets e{}; - entry.id = atoi(row[0]); - entry.char_id = atoi(row[1]); - entry.title_set = atoi(row[2]); + e.id = atoi(row[0]); + e.char_id = atoi(row[1]); + e.title_set = atoi(row[2]); - all_entries.push_back(entry); + all_entries.push_back(e); } return all_entries; } - static std::vector GetWhere(Database& db, std::string where_filter) + static std::vector GetWhere(Database& db, const std::string &where_filter) { std::vector all_entries; @@ -274,19 +274,19 @@ public: all_entries.reserve(results.RowCount()); for (auto row = results.begin(); row != results.end(); ++row) { - PlayerTitlesets entry{}; + PlayerTitlesets e{}; - entry.id = atoi(row[0]); - entry.char_id = atoi(row[1]); - entry.title_set = atoi(row[2]); + e.id = atoi(row[0]); + e.char_id = atoi(row[1]); + e.title_set = atoi(row[2]); - all_entries.push_back(entry); + all_entries.push_back(e); } return all_entries; } - static int DeleteWhere(Database& db, std::string where_filter) + static int DeleteWhere(Database& db, const std::string &where_filter) { auto results = db.QueryDatabase( fmt::format( @@ -311,6 +311,32 @@ public: 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); + } + }; #endif //EQEMU_BASE_PLAYER_TITLESETS_REPOSITORY_H diff --git a/common/repositories/base/base_proximities_repository.h b/common/repositories/base/base_proximities_repository.h index fa733e16c..252696745 100644 --- a/common/repositories/base/base_proximities_repository.h +++ b/common/repositories/base/base_proximities_repository.h @@ -97,21 +97,21 @@ public: static Proximities NewEntity() { - Proximities entry{}; + Proximities e{}; - entry.zoneid = 0; - entry.exploreid = 0; - entry.minx = 0.000000; - entry.maxx = 0.000000; - entry.miny = 0.000000; - entry.maxy = 0.000000; - entry.minz = 0.000000; - entry.maxz = 0.000000; + e.zoneid = 0; + e.exploreid = 0; + e.minx = 0.000000; + e.maxx = 0.000000; + e.miny = 0.000000; + e.maxy = 0.000000; + e.minz = 0.000000; + e.maxz = 0.000000; - return entry; + return e; } - static Proximities GetProximitiesEntry( + static Proximities GetProximities( const std::vector &proximitiess, int proximities_id ) @@ -140,18 +140,18 @@ public: auto row = results.begin(); if (results.RowCount() == 1) { - Proximities entry{}; + Proximities e{}; - entry.zoneid = atoi(row[0]); - entry.exploreid = atoi(row[1]); - entry.minx = static_cast(atof(row[2])); - entry.maxx = static_cast(atof(row[3])); - entry.miny = static_cast(atof(row[4])); - entry.maxy = static_cast(atof(row[5])); - entry.minz = static_cast(atof(row[6])); - entry.maxz = static_cast(atof(row[7])); + e.zoneid = atoi(row[0]); + e.exploreid = atoi(row[1]); + e.minx = static_cast(atof(row[2])); + e.maxx = static_cast(atof(row[3])); + e.miny = static_cast(atof(row[4])); + e.maxy = static_cast(atof(row[5])); + e.minz = static_cast(atof(row[6])); + e.maxz = static_cast(atof(row[7])); - return entry; + return e; } return NewEntity(); @@ -176,29 +176,29 @@ public: static int UpdateOne( Database& db, - Proximities proximities_entry + const Proximities &e ) { - std::vector update_values; + std::vector v; auto columns = Columns(); - update_values.push_back(columns[0] + " = " + std::to_string(proximities_entry.zoneid)); - update_values.push_back(columns[1] + " = " + std::to_string(proximities_entry.exploreid)); - update_values.push_back(columns[2] + " = " + std::to_string(proximities_entry.minx)); - update_values.push_back(columns[3] + " = " + std::to_string(proximities_entry.maxx)); - update_values.push_back(columns[4] + " = " + std::to_string(proximities_entry.miny)); - update_values.push_back(columns[5] + " = " + std::to_string(proximities_entry.maxy)); - update_values.push_back(columns[6] + " = " + std::to_string(proximities_entry.minz)); - update_values.push_back(columns[7] + " = " + std::to_string(proximities_entry.maxz)); + v.push_back(columns[0] + " = " + std::to_string(e.zoneid)); + v.push_back(columns[1] + " = " + std::to_string(e.exploreid)); + v.push_back(columns[2] + " = " + std::to_string(e.minx)); + v.push_back(columns[3] + " = " + std::to_string(e.maxx)); + v.push_back(columns[4] + " = " + std::to_string(e.miny)); + v.push_back(columns[5] + " = " + std::to_string(e.maxy)); + v.push_back(columns[6] + " = " + std::to_string(e.minz)); + v.push_back(columns[7] + " = " + std::to_string(e.maxz)); auto results = db.QueryDatabase( fmt::format( "UPDATE {} SET {} WHERE {} = {}", TableName(), - Strings::Implode(", ", update_values), + Strings::Implode(", ", v), PrimaryKey(), - proximities_entry.zoneid + e.zoneid ) ); @@ -207,61 +207,61 @@ public: static Proximities InsertOne( Database& db, - Proximities proximities_entry + Proximities e ) { - std::vector insert_values; + std::vector v; - insert_values.push_back(std::to_string(proximities_entry.zoneid)); - insert_values.push_back(std::to_string(proximities_entry.exploreid)); - insert_values.push_back(std::to_string(proximities_entry.minx)); - insert_values.push_back(std::to_string(proximities_entry.maxx)); - insert_values.push_back(std::to_string(proximities_entry.miny)); - insert_values.push_back(std::to_string(proximities_entry.maxy)); - insert_values.push_back(std::to_string(proximities_entry.minz)); - insert_values.push_back(std::to_string(proximities_entry.maxz)); + v.push_back(std::to_string(e.zoneid)); + v.push_back(std::to_string(e.exploreid)); + v.push_back(std::to_string(e.minx)); + v.push_back(std::to_string(e.maxx)); + v.push_back(std::to_string(e.miny)); + v.push_back(std::to_string(e.maxy)); + v.push_back(std::to_string(e.minz)); + v.push_back(std::to_string(e.maxz)); auto results = db.QueryDatabase( fmt::format( "{} VALUES ({})", BaseInsert(), - Strings::Implode(",", insert_values) + Strings::Implode(",", v) ) ); if (results.Success()) { - proximities_entry.zoneid = results.LastInsertedID(); - return proximities_entry; + e.zoneid = results.LastInsertedID(); + return e; } - proximities_entry = NewEntity(); + e = NewEntity(); - return proximities_entry; + return e; } static int InsertMany( Database& db, - std::vector proximities_entries + const std::vector &entries ) { std::vector insert_chunks; - for (auto &proximities_entry: proximities_entries) { - std::vector insert_values; + for (auto &e: entries) { + std::vector v; - insert_values.push_back(std::to_string(proximities_entry.zoneid)); - insert_values.push_back(std::to_string(proximities_entry.exploreid)); - insert_values.push_back(std::to_string(proximities_entry.minx)); - insert_values.push_back(std::to_string(proximities_entry.maxx)); - insert_values.push_back(std::to_string(proximities_entry.miny)); - insert_values.push_back(std::to_string(proximities_entry.maxy)); - insert_values.push_back(std::to_string(proximities_entry.minz)); - insert_values.push_back(std::to_string(proximities_entry.maxz)); + v.push_back(std::to_string(e.zoneid)); + v.push_back(std::to_string(e.exploreid)); + v.push_back(std::to_string(e.minx)); + v.push_back(std::to_string(e.maxx)); + v.push_back(std::to_string(e.miny)); + v.push_back(std::to_string(e.maxy)); + v.push_back(std::to_string(e.minz)); + v.push_back(std::to_string(e.maxz)); - insert_chunks.push_back("(" + Strings::Implode(",", insert_values) + ")"); + insert_chunks.push_back("(" + Strings::Implode(",", v) + ")"); } - std::vector insert_values; + std::vector v; auto results = db.QueryDatabase( fmt::format( @@ -288,24 +288,24 @@ public: all_entries.reserve(results.RowCount()); for (auto row = results.begin(); row != results.end(); ++row) { - Proximities entry{}; + Proximities e{}; - entry.zoneid = atoi(row[0]); - entry.exploreid = atoi(row[1]); - entry.minx = static_cast(atof(row[2])); - entry.maxx = static_cast(atof(row[3])); - entry.miny = static_cast(atof(row[4])); - entry.maxy = static_cast(atof(row[5])); - entry.minz = static_cast(atof(row[6])); - entry.maxz = static_cast(atof(row[7])); + e.zoneid = atoi(row[0]); + e.exploreid = atoi(row[1]); + e.minx = static_cast(atof(row[2])); + e.maxx = static_cast(atof(row[3])); + e.miny = static_cast(atof(row[4])); + e.maxy = static_cast(atof(row[5])); + e.minz = static_cast(atof(row[6])); + e.maxz = static_cast(atof(row[7])); - all_entries.push_back(entry); + all_entries.push_back(e); } return all_entries; } - static std::vector GetWhere(Database& db, std::string where_filter) + static std::vector GetWhere(Database& db, const std::string &where_filter) { std::vector all_entries; @@ -320,24 +320,24 @@ public: all_entries.reserve(results.RowCount()); for (auto row = results.begin(); row != results.end(); ++row) { - Proximities entry{}; + Proximities e{}; - entry.zoneid = atoi(row[0]); - entry.exploreid = atoi(row[1]); - entry.minx = static_cast(atof(row[2])); - entry.maxx = static_cast(atof(row[3])); - entry.miny = static_cast(atof(row[4])); - entry.maxy = static_cast(atof(row[5])); - entry.minz = static_cast(atof(row[6])); - entry.maxz = static_cast(atof(row[7])); + e.zoneid = atoi(row[0]); + e.exploreid = atoi(row[1]); + e.minx = static_cast(atof(row[2])); + e.maxx = static_cast(atof(row[3])); + e.miny = static_cast(atof(row[4])); + e.maxy = static_cast(atof(row[5])); + e.minz = static_cast(atof(row[6])); + e.maxz = static_cast(atof(row[7])); - all_entries.push_back(entry); + all_entries.push_back(e); } return all_entries; } - static int DeleteWhere(Database& db, std::string where_filter) + static int DeleteWhere(Database& db, const std::string &where_filter) { auto results = db.QueryDatabase( fmt::format( @@ -362,6 +362,32 @@ public: 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); + } + }; #endif //EQEMU_BASE_PROXIMITIES_REPOSITORY_H diff --git a/common/repositories/base/base_quest_globals_repository.h b/common/repositories/base/base_quest_globals_repository.h index 13a0b4197..64defd56d 100644 --- a/common/repositories/base/base_quest_globals_repository.h +++ b/common/repositories/base/base_quest_globals_repository.h @@ -91,19 +91,19 @@ public: static QuestGlobals NewEntity() { - QuestGlobals entry{}; + QuestGlobals e{}; - entry.charid = 0; - entry.npcid = 0; - entry.zoneid = 0; - entry.name = ""; - entry.value = "?"; - entry.expdate = 0; + e.charid = 0; + e.npcid = 0; + e.zoneid = 0; + e.name = ""; + e.value = "?"; + e.expdate = 0; - return entry; + return e; } - static QuestGlobals GetQuestGlobalsEntry( + static QuestGlobals GetQuestGlobals( const std::vector &quest_globalss, int quest_globals_id ) @@ -132,16 +132,16 @@ public: auto row = results.begin(); if (results.RowCount() == 1) { - QuestGlobals entry{}; + QuestGlobals e{}; - entry.charid = atoi(row[0]); - entry.npcid = atoi(row[1]); - entry.zoneid = atoi(row[2]); - entry.name = row[3] ? row[3] : ""; - entry.value = row[4] ? row[4] : ""; - entry.expdate = atoi(row[5]); + e.charid = atoi(row[0]); + e.npcid = atoi(row[1]); + e.zoneid = atoi(row[2]); + e.name = row[3] ? row[3] : ""; + e.value = row[4] ? row[4] : ""; + e.expdate = atoi(row[5]); - return entry; + return e; } return NewEntity(); @@ -166,27 +166,27 @@ public: static int UpdateOne( Database& db, - QuestGlobals quest_globals_entry + const QuestGlobals &e ) { - std::vector update_values; + std::vector v; auto columns = Columns(); - update_values.push_back(columns[0] + " = " + std::to_string(quest_globals_entry.charid)); - update_values.push_back(columns[1] + " = " + std::to_string(quest_globals_entry.npcid)); - update_values.push_back(columns[2] + " = " + std::to_string(quest_globals_entry.zoneid)); - update_values.push_back(columns[3] + " = '" + Strings::Escape(quest_globals_entry.name) + "'"); - update_values.push_back(columns[4] + " = '" + Strings::Escape(quest_globals_entry.value) + "'"); - update_values.push_back(columns[5] + " = " + std::to_string(quest_globals_entry.expdate)); + v.push_back(columns[0] + " = " + std::to_string(e.charid)); + v.push_back(columns[1] + " = " + std::to_string(e.npcid)); + v.push_back(columns[2] + " = " + std::to_string(e.zoneid)); + v.push_back(columns[3] + " = '" + Strings::Escape(e.name) + "'"); + v.push_back(columns[4] + " = '" + Strings::Escape(e.value) + "'"); + v.push_back(columns[5] + " = " + std::to_string(e.expdate)); auto results = db.QueryDatabase( fmt::format( "UPDATE {} SET {} WHERE {} = {}", TableName(), - Strings::Implode(", ", update_values), + Strings::Implode(", ", v), PrimaryKey(), - quest_globals_entry.charid + e.charid ) ); @@ -195,57 +195,57 @@ public: static QuestGlobals InsertOne( Database& db, - QuestGlobals quest_globals_entry + QuestGlobals e ) { - std::vector insert_values; + std::vector v; - insert_values.push_back(std::to_string(quest_globals_entry.charid)); - insert_values.push_back(std::to_string(quest_globals_entry.npcid)); - insert_values.push_back(std::to_string(quest_globals_entry.zoneid)); - insert_values.push_back("'" + Strings::Escape(quest_globals_entry.name) + "'"); - insert_values.push_back("'" + Strings::Escape(quest_globals_entry.value) + "'"); - insert_values.push_back(std::to_string(quest_globals_entry.expdate)); + v.push_back(std::to_string(e.charid)); + v.push_back(std::to_string(e.npcid)); + v.push_back(std::to_string(e.zoneid)); + v.push_back("'" + Strings::Escape(e.name) + "'"); + v.push_back("'" + Strings::Escape(e.value) + "'"); + v.push_back(std::to_string(e.expdate)); auto results = db.QueryDatabase( fmt::format( "{} VALUES ({})", BaseInsert(), - Strings::Implode(",", insert_values) + Strings::Implode(",", v) ) ); if (results.Success()) { - quest_globals_entry.charid = results.LastInsertedID(); - return quest_globals_entry; + e.charid = results.LastInsertedID(); + return e; } - quest_globals_entry = NewEntity(); + e = NewEntity(); - return quest_globals_entry; + return e; } static int InsertMany( Database& db, - std::vector quest_globals_entries + const std::vector &entries ) { std::vector insert_chunks; - for (auto &quest_globals_entry: quest_globals_entries) { - std::vector insert_values; + for (auto &e: entries) { + std::vector v; - insert_values.push_back(std::to_string(quest_globals_entry.charid)); - insert_values.push_back(std::to_string(quest_globals_entry.npcid)); - insert_values.push_back(std::to_string(quest_globals_entry.zoneid)); - insert_values.push_back("'" + Strings::Escape(quest_globals_entry.name) + "'"); - insert_values.push_back("'" + Strings::Escape(quest_globals_entry.value) + "'"); - insert_values.push_back(std::to_string(quest_globals_entry.expdate)); + v.push_back(std::to_string(e.charid)); + v.push_back(std::to_string(e.npcid)); + v.push_back(std::to_string(e.zoneid)); + v.push_back("'" + Strings::Escape(e.name) + "'"); + v.push_back("'" + Strings::Escape(e.value) + "'"); + v.push_back(std::to_string(e.expdate)); - insert_chunks.push_back("(" + Strings::Implode(",", insert_values) + ")"); + insert_chunks.push_back("(" + Strings::Implode(",", v) + ")"); } - std::vector insert_values; + std::vector v; auto results = db.QueryDatabase( fmt::format( @@ -272,22 +272,22 @@ public: all_entries.reserve(results.RowCount()); for (auto row = results.begin(); row != results.end(); ++row) { - QuestGlobals entry{}; + QuestGlobals e{}; - entry.charid = atoi(row[0]); - entry.npcid = atoi(row[1]); - entry.zoneid = atoi(row[2]); - entry.name = row[3] ? row[3] : ""; - entry.value = row[4] ? row[4] : ""; - entry.expdate = atoi(row[5]); + e.charid = atoi(row[0]); + e.npcid = atoi(row[1]); + e.zoneid = atoi(row[2]); + e.name = row[3] ? row[3] : ""; + e.value = row[4] ? row[4] : ""; + e.expdate = atoi(row[5]); - all_entries.push_back(entry); + all_entries.push_back(e); } return all_entries; } - static std::vector GetWhere(Database& db, std::string where_filter) + static std::vector GetWhere(Database& db, const std::string &where_filter) { std::vector all_entries; @@ -302,22 +302,22 @@ public: all_entries.reserve(results.RowCount()); for (auto row = results.begin(); row != results.end(); ++row) { - QuestGlobals entry{}; + QuestGlobals e{}; - entry.charid = atoi(row[0]); - entry.npcid = atoi(row[1]); - entry.zoneid = atoi(row[2]); - entry.name = row[3] ? row[3] : ""; - entry.value = row[4] ? row[4] : ""; - entry.expdate = atoi(row[5]); + e.charid = atoi(row[0]); + e.npcid = atoi(row[1]); + e.zoneid = atoi(row[2]); + e.name = row[3] ? row[3] : ""; + e.value = row[4] ? row[4] : ""; + e.expdate = atoi(row[5]); - all_entries.push_back(entry); + all_entries.push_back(e); } return all_entries; } - static int DeleteWhere(Database& db, std::string where_filter) + static int DeleteWhere(Database& db, const std::string &where_filter) { auto results = db.QueryDatabase( fmt::format( @@ -342,6 +342,32 @@ public: 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); + } + }; #endif //EQEMU_BASE_QUEST_GLOBALS_REPOSITORY_H diff --git a/common/repositories/base/base_raid_details_repository.h b/common/repositories/base/base_raid_details_repository.h index c5fdd0ed2..78f734782 100644 --- a/common/repositories/base/base_raid_details_repository.h +++ b/common/repositories/base/base_raid_details_repository.h @@ -85,17 +85,17 @@ public: static RaidDetails NewEntity() { - RaidDetails entry{}; + RaidDetails e{}; - entry.raidid = 0; - entry.loottype = 0; - entry.locked = 0; - entry.motd = ""; + e.raidid = 0; + e.loottype = 0; + e.locked = 0; + e.motd = ""; - return entry; + return e; } - static RaidDetails GetRaidDetailsEntry( + static RaidDetails GetRaidDetails( const std::vector &raid_detailss, int raid_details_id ) @@ -124,14 +124,14 @@ public: auto row = results.begin(); if (results.RowCount() == 1) { - RaidDetails entry{}; + RaidDetails e{}; - entry.raidid = atoi(row[0]); - entry.loottype = atoi(row[1]); - entry.locked = atoi(row[2]); - entry.motd = row[3] ? row[3] : ""; + e.raidid = atoi(row[0]); + e.loottype = atoi(row[1]); + e.locked = atoi(row[2]); + e.motd = row[3] ? row[3] : ""; - return entry; + return e; } return NewEntity(); @@ -156,25 +156,25 @@ public: static int UpdateOne( Database& db, - RaidDetails raid_details_entry + const RaidDetails &e ) { - std::vector update_values; + std::vector v; auto columns = Columns(); - update_values.push_back(columns[0] + " = " + std::to_string(raid_details_entry.raidid)); - update_values.push_back(columns[1] + " = " + std::to_string(raid_details_entry.loottype)); - update_values.push_back(columns[2] + " = " + std::to_string(raid_details_entry.locked)); - update_values.push_back(columns[3] + " = '" + Strings::Escape(raid_details_entry.motd) + "'"); + v.push_back(columns[0] + " = " + std::to_string(e.raidid)); + v.push_back(columns[1] + " = " + std::to_string(e.loottype)); + v.push_back(columns[2] + " = " + std::to_string(e.locked)); + v.push_back(columns[3] + " = '" + Strings::Escape(e.motd) + "'"); auto results = db.QueryDatabase( fmt::format( "UPDATE {} SET {} WHERE {} = {}", TableName(), - Strings::Implode(", ", update_values), + Strings::Implode(", ", v), PrimaryKey(), - raid_details_entry.raidid + e.raidid ) ); @@ -183,53 +183,53 @@ public: static RaidDetails InsertOne( Database& db, - RaidDetails raid_details_entry + RaidDetails e ) { - std::vector insert_values; + std::vector v; - insert_values.push_back(std::to_string(raid_details_entry.raidid)); - insert_values.push_back(std::to_string(raid_details_entry.loottype)); - insert_values.push_back(std::to_string(raid_details_entry.locked)); - insert_values.push_back("'" + Strings::Escape(raid_details_entry.motd) + "'"); + v.push_back(std::to_string(e.raidid)); + v.push_back(std::to_string(e.loottype)); + v.push_back(std::to_string(e.locked)); + v.push_back("'" + Strings::Escape(e.motd) + "'"); auto results = db.QueryDatabase( fmt::format( "{} VALUES ({})", BaseInsert(), - Strings::Implode(",", insert_values) + Strings::Implode(",", v) ) ); if (results.Success()) { - raid_details_entry.raidid = results.LastInsertedID(); - return raid_details_entry; + e.raidid = results.LastInsertedID(); + return e; } - raid_details_entry = NewEntity(); + e = NewEntity(); - return raid_details_entry; + return e; } static int InsertMany( Database& db, - std::vector raid_details_entries + const std::vector &entries ) { std::vector insert_chunks; - for (auto &raid_details_entry: raid_details_entries) { - std::vector insert_values; + for (auto &e: entries) { + std::vector v; - insert_values.push_back(std::to_string(raid_details_entry.raidid)); - insert_values.push_back(std::to_string(raid_details_entry.loottype)); - insert_values.push_back(std::to_string(raid_details_entry.locked)); - insert_values.push_back("'" + Strings::Escape(raid_details_entry.motd) + "'"); + v.push_back(std::to_string(e.raidid)); + v.push_back(std::to_string(e.loottype)); + v.push_back(std::to_string(e.locked)); + v.push_back("'" + Strings::Escape(e.motd) + "'"); - insert_chunks.push_back("(" + Strings::Implode(",", insert_values) + ")"); + insert_chunks.push_back("(" + Strings::Implode(",", v) + ")"); } - std::vector insert_values; + std::vector v; auto results = db.QueryDatabase( fmt::format( @@ -256,20 +256,20 @@ public: all_entries.reserve(results.RowCount()); for (auto row = results.begin(); row != results.end(); ++row) { - RaidDetails entry{}; + RaidDetails e{}; - entry.raidid = atoi(row[0]); - entry.loottype = atoi(row[1]); - entry.locked = atoi(row[2]); - entry.motd = row[3] ? row[3] : ""; + e.raidid = atoi(row[0]); + e.loottype = atoi(row[1]); + e.locked = atoi(row[2]); + e.motd = row[3] ? row[3] : ""; - all_entries.push_back(entry); + all_entries.push_back(e); } return all_entries; } - static std::vector GetWhere(Database& db, std::string where_filter) + static std::vector GetWhere(Database& db, const std::string &where_filter) { std::vector all_entries; @@ -284,20 +284,20 @@ public: all_entries.reserve(results.RowCount()); for (auto row = results.begin(); row != results.end(); ++row) { - RaidDetails entry{}; + RaidDetails e{}; - entry.raidid = atoi(row[0]); - entry.loottype = atoi(row[1]); - entry.locked = atoi(row[2]); - entry.motd = row[3] ? row[3] : ""; + e.raidid = atoi(row[0]); + e.loottype = atoi(row[1]); + e.locked = atoi(row[2]); + e.motd = row[3] ? row[3] : ""; - all_entries.push_back(entry); + all_entries.push_back(e); } return all_entries; } - static int DeleteWhere(Database& db, std::string where_filter) + static int DeleteWhere(Database& db, const std::string &where_filter) { auto results = db.QueryDatabase( fmt::format( @@ -322,6 +322,32 @@ public: 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); + } + }; #endif //EQEMU_BASE_RAID_DETAILS_REPOSITORY_H diff --git a/common/repositories/base/base_raid_members_repository.h b/common/repositories/base/base_raid_members_repository.h index 7daa87382..f54d4fffc 100644 --- a/common/repositories/base/base_raid_members_repository.h +++ b/common/repositories/base/base_raid_members_repository.h @@ -100,22 +100,22 @@ public: static RaidMembers NewEntity() { - RaidMembers entry{}; + RaidMembers e{}; - entry.raidid = 0; - entry.charid = 0; - entry.groupid = 0; - entry._class = 0; - entry.level = 0; - entry.name = ""; - entry.isgroupleader = 0; - entry.israidleader = 0; - entry.islooter = 0; + e.raidid = 0; + e.charid = 0; + e.groupid = 0; + e._class = 0; + e.level = 0; + e.name = ""; + e.isgroupleader = 0; + e.israidleader = 0; + e.islooter = 0; - return entry; + return e; } - static RaidMembers GetRaidMembersEntry( + static RaidMembers GetRaidMembers( const std::vector &raid_memberss, int raid_members_id ) @@ -144,19 +144,19 @@ public: auto row = results.begin(); if (results.RowCount() == 1) { - RaidMembers entry{}; + RaidMembers e{}; - entry.raidid = atoi(row[0]); - entry.charid = atoi(row[1]); - entry.groupid = atoi(row[2]); - entry._class = atoi(row[3]); - entry.level = atoi(row[4]); - entry.name = row[5] ? row[5] : ""; - entry.isgroupleader = atoi(row[6]); - entry.israidleader = atoi(row[7]); - entry.islooter = atoi(row[8]); + e.raidid = atoi(row[0]); + e.charid = atoi(row[1]); + e.groupid = atoi(row[2]); + e._class = atoi(row[3]); + e.level = atoi(row[4]); + e.name = row[5] ? row[5] : ""; + e.isgroupleader = atoi(row[6]); + e.israidleader = atoi(row[7]); + e.islooter = atoi(row[8]); - return entry; + return e; } return NewEntity(); @@ -181,30 +181,30 @@ public: static int UpdateOne( Database& db, - RaidMembers raid_members_entry + const RaidMembers &e ) { - std::vector update_values; + std::vector v; auto columns = Columns(); - update_values.push_back(columns[0] + " = " + std::to_string(raid_members_entry.raidid)); - update_values.push_back(columns[1] + " = " + std::to_string(raid_members_entry.charid)); - update_values.push_back(columns[2] + " = " + std::to_string(raid_members_entry.groupid)); - update_values.push_back(columns[3] + " = " + std::to_string(raid_members_entry._class)); - update_values.push_back(columns[4] + " = " + std::to_string(raid_members_entry.level)); - update_values.push_back(columns[5] + " = '" + Strings::Escape(raid_members_entry.name) + "'"); - update_values.push_back(columns[6] + " = " + std::to_string(raid_members_entry.isgroupleader)); - update_values.push_back(columns[7] + " = " + std::to_string(raid_members_entry.israidleader)); - update_values.push_back(columns[8] + " = " + std::to_string(raid_members_entry.islooter)); + v.push_back(columns[0] + " = " + std::to_string(e.raidid)); + v.push_back(columns[1] + " = " + std::to_string(e.charid)); + v.push_back(columns[2] + " = " + std::to_string(e.groupid)); + v.push_back(columns[3] + " = " + std::to_string(e._class)); + v.push_back(columns[4] + " = " + std::to_string(e.level)); + v.push_back(columns[5] + " = '" + Strings::Escape(e.name) + "'"); + v.push_back(columns[6] + " = " + std::to_string(e.isgroupleader)); + v.push_back(columns[7] + " = " + std::to_string(e.israidleader)); + v.push_back(columns[8] + " = " + std::to_string(e.islooter)); auto results = db.QueryDatabase( fmt::format( "UPDATE {} SET {} WHERE {} = {}", TableName(), - Strings::Implode(", ", update_values), + Strings::Implode(", ", v), PrimaryKey(), - raid_members_entry.charid + e.charid ) ); @@ -213,63 +213,63 @@ public: static RaidMembers InsertOne( Database& db, - RaidMembers raid_members_entry + RaidMembers e ) { - std::vector insert_values; + std::vector v; - insert_values.push_back(std::to_string(raid_members_entry.raidid)); - insert_values.push_back(std::to_string(raid_members_entry.charid)); - insert_values.push_back(std::to_string(raid_members_entry.groupid)); - insert_values.push_back(std::to_string(raid_members_entry._class)); - insert_values.push_back(std::to_string(raid_members_entry.level)); - insert_values.push_back("'" + Strings::Escape(raid_members_entry.name) + "'"); - insert_values.push_back(std::to_string(raid_members_entry.isgroupleader)); - insert_values.push_back(std::to_string(raid_members_entry.israidleader)); - insert_values.push_back(std::to_string(raid_members_entry.islooter)); + v.push_back(std::to_string(e.raidid)); + v.push_back(std::to_string(e.charid)); + v.push_back(std::to_string(e.groupid)); + v.push_back(std::to_string(e._class)); + v.push_back(std::to_string(e.level)); + v.push_back("'" + Strings::Escape(e.name) + "'"); + v.push_back(std::to_string(e.isgroupleader)); + v.push_back(std::to_string(e.israidleader)); + v.push_back(std::to_string(e.islooter)); auto results = db.QueryDatabase( fmt::format( "{} VALUES ({})", BaseInsert(), - Strings::Implode(",", insert_values) + Strings::Implode(",", v) ) ); if (results.Success()) { - raid_members_entry.charid = results.LastInsertedID(); - return raid_members_entry; + e.charid = results.LastInsertedID(); + return e; } - raid_members_entry = NewEntity(); + e = NewEntity(); - return raid_members_entry; + return e; } static int InsertMany( Database& db, - std::vector raid_members_entries + const std::vector &entries ) { std::vector insert_chunks; - for (auto &raid_members_entry: raid_members_entries) { - std::vector insert_values; + for (auto &e: entries) { + std::vector v; - insert_values.push_back(std::to_string(raid_members_entry.raidid)); - insert_values.push_back(std::to_string(raid_members_entry.charid)); - insert_values.push_back(std::to_string(raid_members_entry.groupid)); - insert_values.push_back(std::to_string(raid_members_entry._class)); - insert_values.push_back(std::to_string(raid_members_entry.level)); - insert_values.push_back("'" + Strings::Escape(raid_members_entry.name) + "'"); - insert_values.push_back(std::to_string(raid_members_entry.isgroupleader)); - insert_values.push_back(std::to_string(raid_members_entry.israidleader)); - insert_values.push_back(std::to_string(raid_members_entry.islooter)); + v.push_back(std::to_string(e.raidid)); + v.push_back(std::to_string(e.charid)); + v.push_back(std::to_string(e.groupid)); + v.push_back(std::to_string(e._class)); + v.push_back(std::to_string(e.level)); + v.push_back("'" + Strings::Escape(e.name) + "'"); + v.push_back(std::to_string(e.isgroupleader)); + v.push_back(std::to_string(e.israidleader)); + v.push_back(std::to_string(e.islooter)); - insert_chunks.push_back("(" + Strings::Implode(",", insert_values) + ")"); + insert_chunks.push_back("(" + Strings::Implode(",", v) + ")"); } - std::vector insert_values; + std::vector v; auto results = db.QueryDatabase( fmt::format( @@ -296,25 +296,25 @@ public: all_entries.reserve(results.RowCount()); for (auto row = results.begin(); row != results.end(); ++row) { - RaidMembers entry{}; + RaidMembers e{}; - entry.raidid = atoi(row[0]); - entry.charid = atoi(row[1]); - entry.groupid = atoi(row[2]); - entry._class = atoi(row[3]); - entry.level = atoi(row[4]); - entry.name = row[5] ? row[5] : ""; - entry.isgroupleader = atoi(row[6]); - entry.israidleader = atoi(row[7]); - entry.islooter = atoi(row[8]); + e.raidid = atoi(row[0]); + e.charid = atoi(row[1]); + e.groupid = atoi(row[2]); + e._class = atoi(row[3]); + e.level = atoi(row[4]); + e.name = row[5] ? row[5] : ""; + e.isgroupleader = atoi(row[6]); + e.israidleader = atoi(row[7]); + e.islooter = atoi(row[8]); - all_entries.push_back(entry); + all_entries.push_back(e); } return all_entries; } - static std::vector GetWhere(Database& db, std::string where_filter) + static std::vector GetWhere(Database& db, const std::string &where_filter) { std::vector all_entries; @@ -329,25 +329,25 @@ public: all_entries.reserve(results.RowCount()); for (auto row = results.begin(); row != results.end(); ++row) { - RaidMembers entry{}; + RaidMembers e{}; - entry.raidid = atoi(row[0]); - entry.charid = atoi(row[1]); - entry.groupid = atoi(row[2]); - entry._class = atoi(row[3]); - entry.level = atoi(row[4]); - entry.name = row[5] ? row[5] : ""; - entry.isgroupleader = atoi(row[6]); - entry.israidleader = atoi(row[7]); - entry.islooter = atoi(row[8]); + e.raidid = atoi(row[0]); + e.charid = atoi(row[1]); + e.groupid = atoi(row[2]); + e._class = atoi(row[3]); + e.level = atoi(row[4]); + e.name = row[5] ? row[5] : ""; + e.isgroupleader = atoi(row[6]); + e.israidleader = atoi(row[7]); + e.islooter = atoi(row[8]); - all_entries.push_back(entry); + all_entries.push_back(e); } return all_entries; } - static int DeleteWhere(Database& db, std::string where_filter) + static int DeleteWhere(Database& db, const std::string &where_filter) { auto results = db.QueryDatabase( fmt::format( @@ -372,6 +372,32 @@ public: 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); + } + }; #endif //EQEMU_BASE_RAID_MEMBERS_REPOSITORY_H diff --git a/common/repositories/base/base_reports_repository.h b/common/repositories/base/base_reports_repository.h index 7fba5c6b0..84e5d4eee 100644 --- a/common/repositories/base/base_reports_repository.h +++ b/common/repositories/base/base_reports_repository.h @@ -85,17 +85,17 @@ public: static Reports NewEntity() { - Reports entry{}; + Reports e{}; - entry.id = 0; - entry.name = ""; - entry.reported = ""; - entry.reported_text = ""; + e.id = 0; + e.name = ""; + e.reported = ""; + e.reported_text = ""; - return entry; + return e; } - static Reports GetReportsEntry( + static Reports GetReports( const std::vector &reportss, int reports_id ) @@ -124,14 +124,14 @@ public: auto row = results.begin(); if (results.RowCount() == 1) { - Reports entry{}; + Reports e{}; - entry.id = atoi(row[0]); - entry.name = row[1] ? row[1] : ""; - entry.reported = row[2] ? row[2] : ""; - entry.reported_text = row[3] ? row[3] : ""; + e.id = atoi(row[0]); + e.name = row[1] ? row[1] : ""; + e.reported = row[2] ? row[2] : ""; + e.reported_text = row[3] ? row[3] : ""; - return entry; + return e; } return NewEntity(); @@ -156,24 +156,24 @@ public: static int UpdateOne( Database& db, - Reports reports_entry + const Reports &e ) { - std::vector update_values; + std::vector v; auto columns = Columns(); - update_values.push_back(columns[1] + " = '" + Strings::Escape(reports_entry.name) + "'"); - update_values.push_back(columns[2] + " = '" + Strings::Escape(reports_entry.reported) + "'"); - update_values.push_back(columns[3] + " = '" + Strings::Escape(reports_entry.reported_text) + "'"); + v.push_back(columns[1] + " = '" + Strings::Escape(e.name) + "'"); + v.push_back(columns[2] + " = '" + Strings::Escape(e.reported) + "'"); + v.push_back(columns[3] + " = '" + Strings::Escape(e.reported_text) + "'"); auto results = db.QueryDatabase( fmt::format( "UPDATE {} SET {} WHERE {} = {}", TableName(), - Strings::Implode(", ", update_values), + Strings::Implode(", ", v), PrimaryKey(), - reports_entry.id + e.id ) ); @@ -182,53 +182,53 @@ public: static Reports InsertOne( Database& db, - Reports reports_entry + Reports e ) { - std::vector insert_values; + std::vector v; - insert_values.push_back(std::to_string(reports_entry.id)); - insert_values.push_back("'" + Strings::Escape(reports_entry.name) + "'"); - insert_values.push_back("'" + Strings::Escape(reports_entry.reported) + "'"); - insert_values.push_back("'" + Strings::Escape(reports_entry.reported_text) + "'"); + v.push_back(std::to_string(e.id)); + v.push_back("'" + Strings::Escape(e.name) + "'"); + v.push_back("'" + Strings::Escape(e.reported) + "'"); + v.push_back("'" + Strings::Escape(e.reported_text) + "'"); auto results = db.QueryDatabase( fmt::format( "{} VALUES ({})", BaseInsert(), - Strings::Implode(",", insert_values) + Strings::Implode(",", v) ) ); if (results.Success()) { - reports_entry.id = results.LastInsertedID(); - return reports_entry; + e.id = results.LastInsertedID(); + return e; } - reports_entry = NewEntity(); + e = NewEntity(); - return reports_entry; + return e; } static int InsertMany( Database& db, - std::vector reports_entries + const std::vector &entries ) { std::vector insert_chunks; - for (auto &reports_entry: reports_entries) { - std::vector insert_values; + for (auto &e: entries) { + std::vector v; - insert_values.push_back(std::to_string(reports_entry.id)); - insert_values.push_back("'" + Strings::Escape(reports_entry.name) + "'"); - insert_values.push_back("'" + Strings::Escape(reports_entry.reported) + "'"); - insert_values.push_back("'" + Strings::Escape(reports_entry.reported_text) + "'"); + v.push_back(std::to_string(e.id)); + v.push_back("'" + Strings::Escape(e.name) + "'"); + v.push_back("'" + Strings::Escape(e.reported) + "'"); + v.push_back("'" + Strings::Escape(e.reported_text) + "'"); - insert_chunks.push_back("(" + Strings::Implode(",", insert_values) + ")"); + insert_chunks.push_back("(" + Strings::Implode(",", v) + ")"); } - std::vector insert_values; + std::vector v; auto results = db.QueryDatabase( fmt::format( @@ -255,20 +255,20 @@ public: all_entries.reserve(results.RowCount()); for (auto row = results.begin(); row != results.end(); ++row) { - Reports entry{}; + Reports e{}; - entry.id = atoi(row[0]); - entry.name = row[1] ? row[1] : ""; - entry.reported = row[2] ? row[2] : ""; - entry.reported_text = row[3] ? row[3] : ""; + e.id = atoi(row[0]); + e.name = row[1] ? row[1] : ""; + e.reported = row[2] ? row[2] : ""; + e.reported_text = row[3] ? row[3] : ""; - all_entries.push_back(entry); + all_entries.push_back(e); } return all_entries; } - static std::vector GetWhere(Database& db, std::string where_filter) + static std::vector GetWhere(Database& db, const std::string &where_filter) { std::vector all_entries; @@ -283,20 +283,20 @@ public: all_entries.reserve(results.RowCount()); for (auto row = results.begin(); row != results.end(); ++row) { - Reports entry{}; + Reports e{}; - entry.id = atoi(row[0]); - entry.name = row[1] ? row[1] : ""; - entry.reported = row[2] ? row[2] : ""; - entry.reported_text = row[3] ? row[3] : ""; + e.id = atoi(row[0]); + e.name = row[1] ? row[1] : ""; + e.reported = row[2] ? row[2] : ""; + e.reported_text = row[3] ? row[3] : ""; - all_entries.push_back(entry); + all_entries.push_back(e); } return all_entries; } - static int DeleteWhere(Database& db, std::string where_filter) + static int DeleteWhere(Database& db, const std::string &where_filter) { auto results = db.QueryDatabase( fmt::format( @@ -321,6 +321,32 @@ public: 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); + } + }; #endif //EQEMU_BASE_REPORTS_REPOSITORY_H diff --git a/common/repositories/base/base_respawn_times_repository.h b/common/repositories/base/base_respawn_times_repository.h index 79505bacc..9429e3b82 100644 --- a/common/repositories/base/base_respawn_times_repository.h +++ b/common/repositories/base/base_respawn_times_repository.h @@ -85,17 +85,17 @@ public: static RespawnTimes NewEntity() { - RespawnTimes entry{}; + RespawnTimes e{}; - entry.id = 0; - entry.start = 0; - entry.duration = 0; - entry.instance_id = 0; + e.id = 0; + e.start = 0; + e.duration = 0; + e.instance_id = 0; - return entry; + return e; } - static RespawnTimes GetRespawnTimesEntry( + static RespawnTimes GetRespawnTimes( const std::vector &respawn_timess, int respawn_times_id ) @@ -124,14 +124,14 @@ public: auto row = results.begin(); if (results.RowCount() == 1) { - RespawnTimes entry{}; + RespawnTimes e{}; - entry.id = atoi(row[0]); - entry.start = atoi(row[1]); - entry.duration = atoi(row[2]); - entry.instance_id = atoi(row[3]); + e.id = atoi(row[0]); + e.start = atoi(row[1]); + e.duration = atoi(row[2]); + e.instance_id = atoi(row[3]); - return entry; + return e; } return NewEntity(); @@ -156,25 +156,25 @@ public: static int UpdateOne( Database& db, - RespawnTimes respawn_times_entry + const RespawnTimes &e ) { - std::vector update_values; + std::vector v; auto columns = Columns(); - update_values.push_back(columns[0] + " = " + std::to_string(respawn_times_entry.id)); - update_values.push_back(columns[1] + " = " + std::to_string(respawn_times_entry.start)); - update_values.push_back(columns[2] + " = " + std::to_string(respawn_times_entry.duration)); - update_values.push_back(columns[3] + " = " + std::to_string(respawn_times_entry.instance_id)); + v.push_back(columns[0] + " = " + std::to_string(e.id)); + v.push_back(columns[1] + " = " + std::to_string(e.start)); + v.push_back(columns[2] + " = " + std::to_string(e.duration)); + v.push_back(columns[3] + " = " + std::to_string(e.instance_id)); auto results = db.QueryDatabase( fmt::format( "UPDATE {} SET {} WHERE {} = {}", TableName(), - Strings::Implode(", ", update_values), + Strings::Implode(", ", v), PrimaryKey(), - respawn_times_entry.id + e.id ) ); @@ -183,53 +183,53 @@ public: static RespawnTimes InsertOne( Database& db, - RespawnTimes respawn_times_entry + RespawnTimes e ) { - std::vector insert_values; + std::vector v; - insert_values.push_back(std::to_string(respawn_times_entry.id)); - insert_values.push_back(std::to_string(respawn_times_entry.start)); - insert_values.push_back(std::to_string(respawn_times_entry.duration)); - insert_values.push_back(std::to_string(respawn_times_entry.instance_id)); + v.push_back(std::to_string(e.id)); + v.push_back(std::to_string(e.start)); + v.push_back(std::to_string(e.duration)); + v.push_back(std::to_string(e.instance_id)); auto results = db.QueryDatabase( fmt::format( "{} VALUES ({})", BaseInsert(), - Strings::Implode(",", insert_values) + Strings::Implode(",", v) ) ); if (results.Success()) { - respawn_times_entry.id = results.LastInsertedID(); - return respawn_times_entry; + e.id = results.LastInsertedID(); + return e; } - respawn_times_entry = NewEntity(); + e = NewEntity(); - return respawn_times_entry; + return e; } static int InsertMany( Database& db, - std::vector respawn_times_entries + const std::vector &entries ) { std::vector insert_chunks; - for (auto &respawn_times_entry: respawn_times_entries) { - std::vector insert_values; + for (auto &e: entries) { + std::vector v; - insert_values.push_back(std::to_string(respawn_times_entry.id)); - insert_values.push_back(std::to_string(respawn_times_entry.start)); - insert_values.push_back(std::to_string(respawn_times_entry.duration)); - insert_values.push_back(std::to_string(respawn_times_entry.instance_id)); + v.push_back(std::to_string(e.id)); + v.push_back(std::to_string(e.start)); + v.push_back(std::to_string(e.duration)); + v.push_back(std::to_string(e.instance_id)); - insert_chunks.push_back("(" + Strings::Implode(",", insert_values) + ")"); + insert_chunks.push_back("(" + Strings::Implode(",", v) + ")"); } - std::vector insert_values; + std::vector v; auto results = db.QueryDatabase( fmt::format( @@ -256,20 +256,20 @@ public: all_entries.reserve(results.RowCount()); for (auto row = results.begin(); row != results.end(); ++row) { - RespawnTimes entry{}; + RespawnTimes e{}; - entry.id = atoi(row[0]); - entry.start = atoi(row[1]); - entry.duration = atoi(row[2]); - entry.instance_id = atoi(row[3]); + e.id = atoi(row[0]); + e.start = atoi(row[1]); + e.duration = atoi(row[2]); + e.instance_id = atoi(row[3]); - all_entries.push_back(entry); + all_entries.push_back(e); } return all_entries; } - static std::vector GetWhere(Database& db, std::string where_filter) + static std::vector GetWhere(Database& db, const std::string &where_filter) { std::vector all_entries; @@ -284,20 +284,20 @@ public: all_entries.reserve(results.RowCount()); for (auto row = results.begin(); row != results.end(); ++row) { - RespawnTimes entry{}; + RespawnTimes e{}; - entry.id = atoi(row[0]); - entry.start = atoi(row[1]); - entry.duration = atoi(row[2]); - entry.instance_id = atoi(row[3]); + e.id = atoi(row[0]); + e.start = atoi(row[1]); + e.duration = atoi(row[2]); + e.instance_id = atoi(row[3]); - all_entries.push_back(entry); + all_entries.push_back(e); } return all_entries; } - static int DeleteWhere(Database& db, std::string where_filter) + static int DeleteWhere(Database& db, const std::string &where_filter) { auto results = db.QueryDatabase( fmt::format( @@ -322,6 +322,32 @@ public: 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); + } + }; #endif //EQEMU_BASE_RESPAWN_TIMES_REPOSITORY_H diff --git a/common/repositories/base/base_rule_sets_repository.h b/common/repositories/base/base_rule_sets_repository.h index 7c63e67ad..bb00caa22 100644 --- a/common/repositories/base/base_rule_sets_repository.h +++ b/common/repositories/base/base_rule_sets_repository.h @@ -79,15 +79,15 @@ public: static RuleSets NewEntity() { - RuleSets entry{}; + RuleSets e{}; - entry.ruleset_id = 0; - entry.name = ""; + e.ruleset_id = 0; + e.name = ""; - return entry; + return e; } - static RuleSets GetRuleSetsEntry( + static RuleSets GetRuleSets( const std::vector &rule_setss, int rule_sets_id ) @@ -116,12 +116,12 @@ public: auto row = results.begin(); if (results.RowCount() == 1) { - RuleSets entry{}; + RuleSets e{}; - entry.ruleset_id = atoi(row[0]); - entry.name = row[1] ? row[1] : ""; + e.ruleset_id = atoi(row[0]); + e.name = row[1] ? row[1] : ""; - return entry; + return e; } return NewEntity(); @@ -146,22 +146,22 @@ public: static int UpdateOne( Database& db, - RuleSets rule_sets_entry + const RuleSets &e ) { - std::vector update_values; + std::vector v; auto columns = Columns(); - update_values.push_back(columns[1] + " = '" + Strings::Escape(rule_sets_entry.name) + "'"); + v.push_back(columns[1] + " = '" + Strings::Escape(e.name) + "'"); auto results = db.QueryDatabase( fmt::format( "UPDATE {} SET {} WHERE {} = {}", TableName(), - Strings::Implode(", ", update_values), + Strings::Implode(", ", v), PrimaryKey(), - rule_sets_entry.ruleset_id + e.ruleset_id ) ); @@ -170,49 +170,49 @@ public: static RuleSets InsertOne( Database& db, - RuleSets rule_sets_entry + RuleSets e ) { - std::vector insert_values; + std::vector v; - insert_values.push_back(std::to_string(rule_sets_entry.ruleset_id)); - insert_values.push_back("'" + Strings::Escape(rule_sets_entry.name) + "'"); + v.push_back(std::to_string(e.ruleset_id)); + v.push_back("'" + Strings::Escape(e.name) + "'"); auto results = db.QueryDatabase( fmt::format( "{} VALUES ({})", BaseInsert(), - Strings::Implode(",", insert_values) + Strings::Implode(",", v) ) ); if (results.Success()) { - rule_sets_entry.ruleset_id = results.LastInsertedID(); - return rule_sets_entry; + e.ruleset_id = results.LastInsertedID(); + return e; } - rule_sets_entry = NewEntity(); + e = NewEntity(); - return rule_sets_entry; + return e; } static int InsertMany( Database& db, - std::vector rule_sets_entries + const std::vector &entries ) { std::vector insert_chunks; - for (auto &rule_sets_entry: rule_sets_entries) { - std::vector insert_values; + for (auto &e: entries) { + std::vector v; - insert_values.push_back(std::to_string(rule_sets_entry.ruleset_id)); - insert_values.push_back("'" + Strings::Escape(rule_sets_entry.name) + "'"); + v.push_back(std::to_string(e.ruleset_id)); + v.push_back("'" + Strings::Escape(e.name) + "'"); - insert_chunks.push_back("(" + Strings::Implode(",", insert_values) + ")"); + insert_chunks.push_back("(" + Strings::Implode(",", v) + ")"); } - std::vector insert_values; + std::vector v; auto results = db.QueryDatabase( fmt::format( @@ -239,18 +239,18 @@ public: all_entries.reserve(results.RowCount()); for (auto row = results.begin(); row != results.end(); ++row) { - RuleSets entry{}; + RuleSets e{}; - entry.ruleset_id = atoi(row[0]); - entry.name = row[1] ? row[1] : ""; + e.ruleset_id = atoi(row[0]); + e.name = row[1] ? row[1] : ""; - all_entries.push_back(entry); + all_entries.push_back(e); } return all_entries; } - static std::vector GetWhere(Database& db, std::string where_filter) + static std::vector GetWhere(Database& db, const std::string &where_filter) { std::vector all_entries; @@ -265,18 +265,18 @@ public: all_entries.reserve(results.RowCount()); for (auto row = results.begin(); row != results.end(); ++row) { - RuleSets entry{}; + RuleSets e{}; - entry.ruleset_id = atoi(row[0]); - entry.name = row[1] ? row[1] : ""; + e.ruleset_id = atoi(row[0]); + e.name = row[1] ? row[1] : ""; - all_entries.push_back(entry); + all_entries.push_back(e); } return all_entries; } - static int DeleteWhere(Database& db, std::string where_filter) + static int DeleteWhere(Database& db, const std::string &where_filter) { auto results = db.QueryDatabase( fmt::format( @@ -301,6 +301,32 @@ public: 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); + } + }; #endif //EQEMU_BASE_RULE_SETS_REPOSITORY_H diff --git a/common/repositories/base/base_rule_values_repository.h b/common/repositories/base/base_rule_values_repository.h index 6b705049a..9faccd833 100644 --- a/common/repositories/base/base_rule_values_repository.h +++ b/common/repositories/base/base_rule_values_repository.h @@ -85,17 +85,17 @@ public: static RuleValues NewEntity() { - RuleValues entry{}; + RuleValues e{}; - entry.ruleset_id = 0; - entry.rule_name = ""; - entry.rule_value = ""; - entry.notes = ""; + e.ruleset_id = 0; + e.rule_name = ""; + e.rule_value = ""; + e.notes = ""; - return entry; + return e; } - static RuleValues GetRuleValuesEntry( + static RuleValues GetRuleValues( const std::vector &rule_valuess, int rule_values_id ) @@ -124,14 +124,14 @@ public: auto row = results.begin(); if (results.RowCount() == 1) { - RuleValues entry{}; + RuleValues e{}; - entry.ruleset_id = atoi(row[0]); - entry.rule_name = row[1] ? row[1] : ""; - entry.rule_value = row[2] ? row[2] : ""; - entry.notes = row[3] ? row[3] : ""; + e.ruleset_id = atoi(row[0]); + e.rule_name = row[1] ? row[1] : ""; + e.rule_value = row[2] ? row[2] : ""; + e.notes = row[3] ? row[3] : ""; - return entry; + return e; } return NewEntity(); @@ -156,25 +156,25 @@ public: static int UpdateOne( Database& db, - RuleValues rule_values_entry + const RuleValues &e ) { - std::vector update_values; + std::vector v; auto columns = Columns(); - update_values.push_back(columns[0] + " = " + std::to_string(rule_values_entry.ruleset_id)); - update_values.push_back(columns[1] + " = '" + Strings::Escape(rule_values_entry.rule_name) + "'"); - update_values.push_back(columns[2] + " = '" + Strings::Escape(rule_values_entry.rule_value) + "'"); - update_values.push_back(columns[3] + " = '" + Strings::Escape(rule_values_entry.notes) + "'"); + v.push_back(columns[0] + " = " + std::to_string(e.ruleset_id)); + v.push_back(columns[1] + " = '" + Strings::Escape(e.rule_name) + "'"); + v.push_back(columns[2] + " = '" + Strings::Escape(e.rule_value) + "'"); + v.push_back(columns[3] + " = '" + Strings::Escape(e.notes) + "'"); auto results = db.QueryDatabase( fmt::format( "UPDATE {} SET {} WHERE {} = {}", TableName(), - Strings::Implode(", ", update_values), + Strings::Implode(", ", v), PrimaryKey(), - rule_values_entry.ruleset_id + e.ruleset_id ) ); @@ -183,53 +183,53 @@ public: static RuleValues InsertOne( Database& db, - RuleValues rule_values_entry + RuleValues e ) { - std::vector insert_values; + std::vector v; - insert_values.push_back(std::to_string(rule_values_entry.ruleset_id)); - insert_values.push_back("'" + Strings::Escape(rule_values_entry.rule_name) + "'"); - insert_values.push_back("'" + Strings::Escape(rule_values_entry.rule_value) + "'"); - insert_values.push_back("'" + Strings::Escape(rule_values_entry.notes) + "'"); + v.push_back(std::to_string(e.ruleset_id)); + v.push_back("'" + Strings::Escape(e.rule_name) + "'"); + v.push_back("'" + Strings::Escape(e.rule_value) + "'"); + v.push_back("'" + Strings::Escape(e.notes) + "'"); auto results = db.QueryDatabase( fmt::format( "{} VALUES ({})", BaseInsert(), - Strings::Implode(",", insert_values) + Strings::Implode(",", v) ) ); if (results.Success()) { - rule_values_entry.ruleset_id = results.LastInsertedID(); - return rule_values_entry; + e.ruleset_id = results.LastInsertedID(); + return e; } - rule_values_entry = NewEntity(); + e = NewEntity(); - return rule_values_entry; + return e; } static int InsertMany( Database& db, - std::vector rule_values_entries + const std::vector &entries ) { std::vector insert_chunks; - for (auto &rule_values_entry: rule_values_entries) { - std::vector insert_values; + for (auto &e: entries) { + std::vector v; - insert_values.push_back(std::to_string(rule_values_entry.ruleset_id)); - insert_values.push_back("'" + Strings::Escape(rule_values_entry.rule_name) + "'"); - insert_values.push_back("'" + Strings::Escape(rule_values_entry.rule_value) + "'"); - insert_values.push_back("'" + Strings::Escape(rule_values_entry.notes) + "'"); + v.push_back(std::to_string(e.ruleset_id)); + v.push_back("'" + Strings::Escape(e.rule_name) + "'"); + v.push_back("'" + Strings::Escape(e.rule_value) + "'"); + v.push_back("'" + Strings::Escape(e.notes) + "'"); - insert_chunks.push_back("(" + Strings::Implode(",", insert_values) + ")"); + insert_chunks.push_back("(" + Strings::Implode(",", v) + ")"); } - std::vector insert_values; + std::vector v; auto results = db.QueryDatabase( fmt::format( @@ -256,20 +256,20 @@ public: all_entries.reserve(results.RowCount()); for (auto row = results.begin(); row != results.end(); ++row) { - RuleValues entry{}; + RuleValues e{}; - entry.ruleset_id = atoi(row[0]); - entry.rule_name = row[1] ? row[1] : ""; - entry.rule_value = row[2] ? row[2] : ""; - entry.notes = row[3] ? row[3] : ""; + e.ruleset_id = atoi(row[0]); + e.rule_name = row[1] ? row[1] : ""; + e.rule_value = row[2] ? row[2] : ""; + e.notes = row[3] ? row[3] : ""; - all_entries.push_back(entry); + all_entries.push_back(e); } return all_entries; } - static std::vector GetWhere(Database& db, std::string where_filter) + static std::vector GetWhere(Database& db, const std::string &where_filter) { std::vector all_entries; @@ -284,20 +284,20 @@ public: all_entries.reserve(results.RowCount()); for (auto row = results.begin(); row != results.end(); ++row) { - RuleValues entry{}; + RuleValues e{}; - entry.ruleset_id = atoi(row[0]); - entry.rule_name = row[1] ? row[1] : ""; - entry.rule_value = row[2] ? row[2] : ""; - entry.notes = row[3] ? row[3] : ""; + e.ruleset_id = atoi(row[0]); + e.rule_name = row[1] ? row[1] : ""; + e.rule_value = row[2] ? row[2] : ""; + e.notes = row[3] ? row[3] : ""; - all_entries.push_back(entry); + all_entries.push_back(e); } return all_entries; } - static int DeleteWhere(Database& db, std::string where_filter) + static int DeleteWhere(Database& db, const std::string &where_filter) { auto results = db.QueryDatabase( fmt::format( @@ -322,6 +322,32 @@ public: 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); + } + }; #endif //EQEMU_BASE_RULE_VALUES_REPOSITORY_H diff --git a/common/repositories/base/base_saylink_repository.h b/common/repositories/base/base_saylink_repository.h index f91214e8b..903b906d5 100644 --- a/common/repositories/base/base_saylink_repository.h +++ b/common/repositories/base/base_saylink_repository.h @@ -79,15 +79,15 @@ public: static Saylink NewEntity() { - Saylink entry{}; + Saylink e{}; - entry.id = 0; - entry.phrase = ""; + e.id = 0; + e.phrase = ""; - return entry; + return e; } - static Saylink GetSaylinkEntry( + static Saylink GetSaylink( const std::vector &saylinks, int saylink_id ) @@ -116,12 +116,12 @@ public: auto row = results.begin(); if (results.RowCount() == 1) { - Saylink entry{}; + Saylink e{}; - entry.id = atoi(row[0]); - entry.phrase = row[1] ? row[1] : ""; + e.id = atoi(row[0]); + e.phrase = row[1] ? row[1] : ""; - return entry; + return e; } return NewEntity(); @@ -146,22 +146,22 @@ public: static int UpdateOne( Database& db, - Saylink saylink_entry + const Saylink &e ) { - std::vector update_values; + std::vector v; auto columns = Columns(); - update_values.push_back(columns[1] + " = '" + Strings::Escape(saylink_entry.phrase) + "'"); + v.push_back(columns[1] + " = '" + Strings::Escape(e.phrase) + "'"); auto results = db.QueryDatabase( fmt::format( "UPDATE {} SET {} WHERE {} = {}", TableName(), - Strings::Implode(", ", update_values), + Strings::Implode(", ", v), PrimaryKey(), - saylink_entry.id + e.id ) ); @@ -170,49 +170,49 @@ public: static Saylink InsertOne( Database& db, - Saylink saylink_entry + Saylink e ) { - std::vector insert_values; + std::vector v; - insert_values.push_back(std::to_string(saylink_entry.id)); - insert_values.push_back("'" + Strings::Escape(saylink_entry.phrase) + "'"); + v.push_back(std::to_string(e.id)); + v.push_back("'" + Strings::Escape(e.phrase) + "'"); auto results = db.QueryDatabase( fmt::format( "{} VALUES ({})", BaseInsert(), - Strings::Implode(",", insert_values) + Strings::Implode(",", v) ) ); if (results.Success()) { - saylink_entry.id = results.LastInsertedID(); - return saylink_entry; + e.id = results.LastInsertedID(); + return e; } - saylink_entry = NewEntity(); + e = NewEntity(); - return saylink_entry; + return e; } static int InsertMany( Database& db, - std::vector saylink_entries + const std::vector &entries ) { std::vector insert_chunks; - for (auto &saylink_entry: saylink_entries) { - std::vector insert_values; + for (auto &e: entries) { + std::vector v; - insert_values.push_back(std::to_string(saylink_entry.id)); - insert_values.push_back("'" + Strings::Escape(saylink_entry.phrase) + "'"); + v.push_back(std::to_string(e.id)); + v.push_back("'" + Strings::Escape(e.phrase) + "'"); - insert_chunks.push_back("(" + Strings::Implode(",", insert_values) + ")"); + insert_chunks.push_back("(" + Strings::Implode(",", v) + ")"); } - std::vector insert_values; + std::vector v; auto results = db.QueryDatabase( fmt::format( @@ -239,18 +239,18 @@ public: all_entries.reserve(results.RowCount()); for (auto row = results.begin(); row != results.end(); ++row) { - Saylink entry{}; + Saylink e{}; - entry.id = atoi(row[0]); - entry.phrase = row[1] ? row[1] : ""; + e.id = atoi(row[0]); + e.phrase = row[1] ? row[1] : ""; - all_entries.push_back(entry); + all_entries.push_back(e); } return all_entries; } - static std::vector GetWhere(Database& db, std::string where_filter) + static std::vector GetWhere(Database& db, const std::string &where_filter) { std::vector all_entries; @@ -265,18 +265,18 @@ public: all_entries.reserve(results.RowCount()); for (auto row = results.begin(); row != results.end(); ++row) { - Saylink entry{}; + Saylink e{}; - entry.id = atoi(row[0]); - entry.phrase = row[1] ? row[1] : ""; + e.id = atoi(row[0]); + e.phrase = row[1] ? row[1] : ""; - all_entries.push_back(entry); + all_entries.push_back(e); } return all_entries; } - static int DeleteWhere(Database& db, std::string where_filter) + static int DeleteWhere(Database& db, const std::string &where_filter) { auto results = db.QueryDatabase( fmt::format( @@ -301,6 +301,32 @@ public: 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); + } + }; #endif //EQEMU_BASE_SAYLINK_REPOSITORY_H diff --git a/common/repositories/base/base_server_scheduled_events_repository.h b/common/repositories/base/base_server_scheduled_events_repository.h index a3e676b12..a510b51fc 100644 --- a/common/repositories/base/base_server_scheduled_events_repository.h +++ b/common/repositories/base/base_server_scheduled_events_repository.h @@ -124,30 +124,30 @@ public: static ServerScheduledEvents NewEntity() { - ServerScheduledEvents entry{}; + ServerScheduledEvents e{}; - entry.id = 0; - entry.description = ""; - entry.event_type = ""; - entry.event_data = ""; - entry.minute_start = 0; - entry.hour_start = 0; - entry.day_start = 0; - entry.month_start = 0; - entry.year_start = 0; - entry.minute_end = 0; - entry.hour_end = 0; - entry.day_end = 0; - entry.month_end = 0; - entry.year_end = 0; - entry.cron_expression = ""; - entry.created_at = 0; - entry.deleted_at = 0; + e.id = 0; + e.description = ""; + e.event_type = ""; + e.event_data = ""; + e.minute_start = 0; + e.hour_start = 0; + e.day_start = 0; + e.month_start = 0; + e.year_start = 0; + e.minute_end = 0; + e.hour_end = 0; + e.day_end = 0; + e.month_end = 0; + e.year_end = 0; + e.cron_expression = ""; + e.created_at = 0; + e.deleted_at = 0; - return entry; + return e; } - static ServerScheduledEvents GetServerScheduledEventsEntry( + static ServerScheduledEvents GetServerScheduledEvents( const std::vector &server_scheduled_eventss, int server_scheduled_events_id ) @@ -176,27 +176,27 @@ public: auto row = results.begin(); if (results.RowCount() == 1) { - ServerScheduledEvents entry{}; + ServerScheduledEvents e{}; - entry.id = atoi(row[0]); - entry.description = row[1] ? row[1] : ""; - entry.event_type = row[2] ? row[2] : ""; - entry.event_data = row[3] ? row[3] : ""; - entry.minute_start = atoi(row[4]); - entry.hour_start = atoi(row[5]); - entry.day_start = atoi(row[6]); - entry.month_start = atoi(row[7]); - entry.year_start = atoi(row[8]); - entry.minute_end = atoi(row[9]); - entry.hour_end = atoi(row[10]); - entry.day_end = atoi(row[11]); - entry.month_end = atoi(row[12]); - entry.year_end = atoi(row[13]); - entry.cron_expression = row[14] ? row[14] : ""; - entry.created_at = strtoll(row[15] ? row[15] : "-1", nullptr, 10); - entry.deleted_at = strtoll(row[16] ? row[16] : "-1", nullptr, 10); + e.id = atoi(row[0]); + e.description = row[1] ? row[1] : ""; + e.event_type = row[2] ? row[2] : ""; + e.event_data = row[3] ? row[3] : ""; + e.minute_start = atoi(row[4]); + e.hour_start = atoi(row[5]); + e.day_start = atoi(row[6]); + e.month_start = atoi(row[7]); + e.year_start = atoi(row[8]); + e.minute_end = atoi(row[9]); + e.hour_end = atoi(row[10]); + e.day_end = atoi(row[11]); + e.month_end = atoi(row[12]); + e.year_end = atoi(row[13]); + e.cron_expression = row[14] ? row[14] : ""; + e.created_at = strtoll(row[15] ? row[15] : "-1", nullptr, 10); + e.deleted_at = strtoll(row[16] ? row[16] : "-1", nullptr, 10); - return entry; + return e; } return NewEntity(); @@ -221,37 +221,37 @@ public: static int UpdateOne( Database& db, - ServerScheduledEvents server_scheduled_events_entry + const ServerScheduledEvents &e ) { - std::vector update_values; + std::vector v; auto columns = Columns(); - update_values.push_back(columns[1] + " = '" + Strings::Escape(server_scheduled_events_entry.description) + "'"); - update_values.push_back(columns[2] + " = '" + Strings::Escape(server_scheduled_events_entry.event_type) + "'"); - update_values.push_back(columns[3] + " = '" + Strings::Escape(server_scheduled_events_entry.event_data) + "'"); - update_values.push_back(columns[4] + " = " + std::to_string(server_scheduled_events_entry.minute_start)); - update_values.push_back(columns[5] + " = " + std::to_string(server_scheduled_events_entry.hour_start)); - update_values.push_back(columns[6] + " = " + std::to_string(server_scheduled_events_entry.day_start)); - update_values.push_back(columns[7] + " = " + std::to_string(server_scheduled_events_entry.month_start)); - update_values.push_back(columns[8] + " = " + std::to_string(server_scheduled_events_entry.year_start)); - update_values.push_back(columns[9] + " = " + std::to_string(server_scheduled_events_entry.minute_end)); - update_values.push_back(columns[10] + " = " + std::to_string(server_scheduled_events_entry.hour_end)); - update_values.push_back(columns[11] + " = " + std::to_string(server_scheduled_events_entry.day_end)); - update_values.push_back(columns[12] + " = " + std::to_string(server_scheduled_events_entry.month_end)); - update_values.push_back(columns[13] + " = " + std::to_string(server_scheduled_events_entry.year_end)); - update_values.push_back(columns[14] + " = '" + Strings::Escape(server_scheduled_events_entry.cron_expression) + "'"); - update_values.push_back(columns[15] + " = FROM_UNIXTIME(" + (server_scheduled_events_entry.created_at > 0 ? std::to_string(server_scheduled_events_entry.created_at) : "null") + ")"); - update_values.push_back(columns[16] + " = FROM_UNIXTIME(" + (server_scheduled_events_entry.deleted_at > 0 ? std::to_string(server_scheduled_events_entry.deleted_at) : "null") + ")"); + v.push_back(columns[1] + " = '" + Strings::Escape(e.description) + "'"); + v.push_back(columns[2] + " = '" + Strings::Escape(e.event_type) + "'"); + v.push_back(columns[3] + " = '" + Strings::Escape(e.event_data) + "'"); + v.push_back(columns[4] + " = " + std::to_string(e.minute_start)); + v.push_back(columns[5] + " = " + std::to_string(e.hour_start)); + v.push_back(columns[6] + " = " + std::to_string(e.day_start)); + v.push_back(columns[7] + " = " + std::to_string(e.month_start)); + v.push_back(columns[8] + " = " + std::to_string(e.year_start)); + v.push_back(columns[9] + " = " + std::to_string(e.minute_end)); + v.push_back(columns[10] + " = " + std::to_string(e.hour_end)); + v.push_back(columns[11] + " = " + std::to_string(e.day_end)); + v.push_back(columns[12] + " = " + std::to_string(e.month_end)); + v.push_back(columns[13] + " = " + std::to_string(e.year_end)); + v.push_back(columns[14] + " = '" + Strings::Escape(e.cron_expression) + "'"); + v.push_back(columns[15] + " = FROM_UNIXTIME(" + (e.created_at > 0 ? std::to_string(e.created_at) : "null") + ")"); + v.push_back(columns[16] + " = FROM_UNIXTIME(" + (e.deleted_at > 0 ? std::to_string(e.deleted_at) : "null") + ")"); auto results = db.QueryDatabase( fmt::format( "UPDATE {} SET {} WHERE {} = {}", TableName(), - Strings::Implode(", ", update_values), + Strings::Implode(", ", v), PrimaryKey(), - server_scheduled_events_entry.id + e.id ) ); @@ -260,79 +260,79 @@ public: static ServerScheduledEvents InsertOne( Database& db, - ServerScheduledEvents server_scheduled_events_entry + ServerScheduledEvents e ) { - std::vector insert_values; + std::vector v; - insert_values.push_back(std::to_string(server_scheduled_events_entry.id)); - insert_values.push_back("'" + Strings::Escape(server_scheduled_events_entry.description) + "'"); - insert_values.push_back("'" + Strings::Escape(server_scheduled_events_entry.event_type) + "'"); - insert_values.push_back("'" + Strings::Escape(server_scheduled_events_entry.event_data) + "'"); - insert_values.push_back(std::to_string(server_scheduled_events_entry.minute_start)); - insert_values.push_back(std::to_string(server_scheduled_events_entry.hour_start)); - insert_values.push_back(std::to_string(server_scheduled_events_entry.day_start)); - insert_values.push_back(std::to_string(server_scheduled_events_entry.month_start)); - insert_values.push_back(std::to_string(server_scheduled_events_entry.year_start)); - insert_values.push_back(std::to_string(server_scheduled_events_entry.minute_end)); - insert_values.push_back(std::to_string(server_scheduled_events_entry.hour_end)); - insert_values.push_back(std::to_string(server_scheduled_events_entry.day_end)); - insert_values.push_back(std::to_string(server_scheduled_events_entry.month_end)); - insert_values.push_back(std::to_string(server_scheduled_events_entry.year_end)); - insert_values.push_back("'" + Strings::Escape(server_scheduled_events_entry.cron_expression) + "'"); - insert_values.push_back("FROM_UNIXTIME(" + (server_scheduled_events_entry.created_at > 0 ? std::to_string(server_scheduled_events_entry.created_at) : "null") + ")"); - insert_values.push_back("FROM_UNIXTIME(" + (server_scheduled_events_entry.deleted_at > 0 ? std::to_string(server_scheduled_events_entry.deleted_at) : "null") + ")"); + v.push_back(std::to_string(e.id)); + v.push_back("'" + Strings::Escape(e.description) + "'"); + v.push_back("'" + Strings::Escape(e.event_type) + "'"); + v.push_back("'" + Strings::Escape(e.event_data) + "'"); + v.push_back(std::to_string(e.minute_start)); + v.push_back(std::to_string(e.hour_start)); + v.push_back(std::to_string(e.day_start)); + v.push_back(std::to_string(e.month_start)); + v.push_back(std::to_string(e.year_start)); + v.push_back(std::to_string(e.minute_end)); + v.push_back(std::to_string(e.hour_end)); + v.push_back(std::to_string(e.day_end)); + v.push_back(std::to_string(e.month_end)); + v.push_back(std::to_string(e.year_end)); + v.push_back("'" + Strings::Escape(e.cron_expression) + "'"); + v.push_back("FROM_UNIXTIME(" + (e.created_at > 0 ? std::to_string(e.created_at) : "null") + ")"); + v.push_back("FROM_UNIXTIME(" + (e.deleted_at > 0 ? std::to_string(e.deleted_at) : "null") + ")"); auto results = db.QueryDatabase( fmt::format( "{} VALUES ({})", BaseInsert(), - Strings::Implode(",", insert_values) + Strings::Implode(",", v) ) ); if (results.Success()) { - server_scheduled_events_entry.id = results.LastInsertedID(); - return server_scheduled_events_entry; + e.id = results.LastInsertedID(); + return e; } - server_scheduled_events_entry = NewEntity(); + e = NewEntity(); - return server_scheduled_events_entry; + return e; } static int InsertMany( Database& db, - std::vector server_scheduled_events_entries + const std::vector &entries ) { std::vector insert_chunks; - for (auto &server_scheduled_events_entry: server_scheduled_events_entries) { - std::vector insert_values; + for (auto &e: entries) { + std::vector v; - insert_values.push_back(std::to_string(server_scheduled_events_entry.id)); - insert_values.push_back("'" + Strings::Escape(server_scheduled_events_entry.description) + "'"); - insert_values.push_back("'" + Strings::Escape(server_scheduled_events_entry.event_type) + "'"); - insert_values.push_back("'" + Strings::Escape(server_scheduled_events_entry.event_data) + "'"); - insert_values.push_back(std::to_string(server_scheduled_events_entry.minute_start)); - insert_values.push_back(std::to_string(server_scheduled_events_entry.hour_start)); - insert_values.push_back(std::to_string(server_scheduled_events_entry.day_start)); - insert_values.push_back(std::to_string(server_scheduled_events_entry.month_start)); - insert_values.push_back(std::to_string(server_scheduled_events_entry.year_start)); - insert_values.push_back(std::to_string(server_scheduled_events_entry.minute_end)); - insert_values.push_back(std::to_string(server_scheduled_events_entry.hour_end)); - insert_values.push_back(std::to_string(server_scheduled_events_entry.day_end)); - insert_values.push_back(std::to_string(server_scheduled_events_entry.month_end)); - insert_values.push_back(std::to_string(server_scheduled_events_entry.year_end)); - insert_values.push_back("'" + Strings::Escape(server_scheduled_events_entry.cron_expression) + "'"); - insert_values.push_back("FROM_UNIXTIME(" + (server_scheduled_events_entry.created_at > 0 ? std::to_string(server_scheduled_events_entry.created_at) : "null") + ")"); - insert_values.push_back("FROM_UNIXTIME(" + (server_scheduled_events_entry.deleted_at > 0 ? std::to_string(server_scheduled_events_entry.deleted_at) : "null") + ")"); + v.push_back(std::to_string(e.id)); + v.push_back("'" + Strings::Escape(e.description) + "'"); + v.push_back("'" + Strings::Escape(e.event_type) + "'"); + v.push_back("'" + Strings::Escape(e.event_data) + "'"); + v.push_back(std::to_string(e.minute_start)); + v.push_back(std::to_string(e.hour_start)); + v.push_back(std::to_string(e.day_start)); + v.push_back(std::to_string(e.month_start)); + v.push_back(std::to_string(e.year_start)); + v.push_back(std::to_string(e.minute_end)); + v.push_back(std::to_string(e.hour_end)); + v.push_back(std::to_string(e.day_end)); + v.push_back(std::to_string(e.month_end)); + v.push_back(std::to_string(e.year_end)); + v.push_back("'" + Strings::Escape(e.cron_expression) + "'"); + v.push_back("FROM_UNIXTIME(" + (e.created_at > 0 ? std::to_string(e.created_at) : "null") + ")"); + v.push_back("FROM_UNIXTIME(" + (e.deleted_at > 0 ? std::to_string(e.deleted_at) : "null") + ")"); - insert_chunks.push_back("(" + Strings::Implode(",", insert_values) + ")"); + insert_chunks.push_back("(" + Strings::Implode(",", v) + ")"); } - std::vector insert_values; + std::vector v; auto results = db.QueryDatabase( fmt::format( @@ -359,33 +359,33 @@ public: all_entries.reserve(results.RowCount()); for (auto row = results.begin(); row != results.end(); ++row) { - ServerScheduledEvents entry{}; + ServerScheduledEvents e{}; - entry.id = atoi(row[0]); - entry.description = row[1] ? row[1] : ""; - entry.event_type = row[2] ? row[2] : ""; - entry.event_data = row[3] ? row[3] : ""; - entry.minute_start = atoi(row[4]); - entry.hour_start = atoi(row[5]); - entry.day_start = atoi(row[6]); - entry.month_start = atoi(row[7]); - entry.year_start = atoi(row[8]); - entry.minute_end = atoi(row[9]); - entry.hour_end = atoi(row[10]); - entry.day_end = atoi(row[11]); - entry.month_end = atoi(row[12]); - entry.year_end = atoi(row[13]); - entry.cron_expression = row[14] ? row[14] : ""; - entry.created_at = strtoll(row[15] ? row[15] : "-1", nullptr, 10); - entry.deleted_at = strtoll(row[16] ? row[16] : "-1", nullptr, 10); + e.id = atoi(row[0]); + e.description = row[1] ? row[1] : ""; + e.event_type = row[2] ? row[2] : ""; + e.event_data = row[3] ? row[3] : ""; + e.minute_start = atoi(row[4]); + e.hour_start = atoi(row[5]); + e.day_start = atoi(row[6]); + e.month_start = atoi(row[7]); + e.year_start = atoi(row[8]); + e.minute_end = atoi(row[9]); + e.hour_end = atoi(row[10]); + e.day_end = atoi(row[11]); + e.month_end = atoi(row[12]); + e.year_end = atoi(row[13]); + e.cron_expression = row[14] ? row[14] : ""; + e.created_at = strtoll(row[15] ? row[15] : "-1", nullptr, 10); + e.deleted_at = strtoll(row[16] ? row[16] : "-1", nullptr, 10); - all_entries.push_back(entry); + all_entries.push_back(e); } return all_entries; } - static std::vector GetWhere(Database& db, std::string where_filter) + static std::vector GetWhere(Database& db, const std::string &where_filter) { std::vector all_entries; @@ -400,33 +400,33 @@ public: all_entries.reserve(results.RowCount()); for (auto row = results.begin(); row != results.end(); ++row) { - ServerScheduledEvents entry{}; + ServerScheduledEvents e{}; - entry.id = atoi(row[0]); - entry.description = row[1] ? row[1] : ""; - entry.event_type = row[2] ? row[2] : ""; - entry.event_data = row[3] ? row[3] : ""; - entry.minute_start = atoi(row[4]); - entry.hour_start = atoi(row[5]); - entry.day_start = atoi(row[6]); - entry.month_start = atoi(row[7]); - entry.year_start = atoi(row[8]); - entry.minute_end = atoi(row[9]); - entry.hour_end = atoi(row[10]); - entry.day_end = atoi(row[11]); - entry.month_end = atoi(row[12]); - entry.year_end = atoi(row[13]); - entry.cron_expression = row[14] ? row[14] : ""; - entry.created_at = strtoll(row[15] ? row[15] : "-1", nullptr, 10); - entry.deleted_at = strtoll(row[16] ? row[16] : "-1", nullptr, 10); + e.id = atoi(row[0]); + e.description = row[1] ? row[1] : ""; + e.event_type = row[2] ? row[2] : ""; + e.event_data = row[3] ? row[3] : ""; + e.minute_start = atoi(row[4]); + e.hour_start = atoi(row[5]); + e.day_start = atoi(row[6]); + e.month_start = atoi(row[7]); + e.year_start = atoi(row[8]); + e.minute_end = atoi(row[9]); + e.hour_end = atoi(row[10]); + e.day_end = atoi(row[11]); + e.month_end = atoi(row[12]); + e.year_end = atoi(row[13]); + e.cron_expression = row[14] ? row[14] : ""; + e.created_at = strtoll(row[15] ? row[15] : "-1", nullptr, 10); + e.deleted_at = strtoll(row[16] ? row[16] : "-1", nullptr, 10); - all_entries.push_back(entry); + all_entries.push_back(e); } return all_entries; } - static int DeleteWhere(Database& db, std::string where_filter) + static int DeleteWhere(Database& db, const std::string &where_filter) { auto results = db.QueryDatabase( fmt::format( @@ -451,6 +451,32 @@ public: 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); + } + }; #endif //EQEMU_BASE_SERVER_SCHEDULED_EVENTS_REPOSITORY_H diff --git a/common/repositories/base/base_shared_task_activity_state_repository.h b/common/repositories/base/base_shared_task_activity_state_repository.h index 1c3ef2610..09e94f49d 100644 --- a/common/repositories/base/base_shared_task_activity_state_repository.h +++ b/common/repositories/base/base_shared_task_activity_state_repository.h @@ -88,18 +88,18 @@ public: static SharedTaskActivityState NewEntity() { - SharedTaskActivityState entry{}; + SharedTaskActivityState e{}; - entry.shared_task_id = 0; - entry.activity_id = 0; - entry.done_count = 0; - entry.updated_time = 0; - entry.completed_time = 0; + e.shared_task_id = 0; + e.activity_id = 0; + e.done_count = 0; + e.updated_time = 0; + e.completed_time = 0; - return entry; + return e; } - static SharedTaskActivityState GetSharedTaskActivityStateEntry( + static SharedTaskActivityState GetSharedTaskActivityState( const std::vector &shared_task_activity_states, int shared_task_activity_state_id ) @@ -128,15 +128,15 @@ public: auto row = results.begin(); if (results.RowCount() == 1) { - SharedTaskActivityState entry{}; + SharedTaskActivityState e{}; - entry.shared_task_id = strtoll(row[0], nullptr, 10); - entry.activity_id = atoi(row[1]); - entry.done_count = atoi(row[2]); - entry.updated_time = strtoll(row[3] ? row[3] : "-1", nullptr, 10); - entry.completed_time = strtoll(row[4] ? row[4] : "-1", nullptr, 10); + e.shared_task_id = strtoll(row[0], nullptr, 10); + e.activity_id = atoi(row[1]); + e.done_count = atoi(row[2]); + e.updated_time = strtoll(row[3] ? row[3] : "-1", nullptr, 10); + e.completed_time = strtoll(row[4] ? row[4] : "-1", nullptr, 10); - return entry; + return e; } return NewEntity(); @@ -161,26 +161,26 @@ public: static int UpdateOne( Database& db, - SharedTaskActivityState shared_task_activity_state_entry + const SharedTaskActivityState &e ) { - std::vector update_values; + std::vector v; auto columns = Columns(); - update_values.push_back(columns[0] + " = " + std::to_string(shared_task_activity_state_entry.shared_task_id)); - update_values.push_back(columns[1] + " = " + std::to_string(shared_task_activity_state_entry.activity_id)); - update_values.push_back(columns[2] + " = " + std::to_string(shared_task_activity_state_entry.done_count)); - update_values.push_back(columns[3] + " = FROM_UNIXTIME(" + (shared_task_activity_state_entry.updated_time > 0 ? std::to_string(shared_task_activity_state_entry.updated_time) : "null") + ")"); - update_values.push_back(columns[4] + " = FROM_UNIXTIME(" + (shared_task_activity_state_entry.completed_time > 0 ? std::to_string(shared_task_activity_state_entry.completed_time) : "null") + ")"); + v.push_back(columns[0] + " = " + std::to_string(e.shared_task_id)); + v.push_back(columns[1] + " = " + std::to_string(e.activity_id)); + v.push_back(columns[2] + " = " + std::to_string(e.done_count)); + v.push_back(columns[3] + " = FROM_UNIXTIME(" + (e.updated_time > 0 ? std::to_string(e.updated_time) : "null") + ")"); + v.push_back(columns[4] + " = FROM_UNIXTIME(" + (e.completed_time > 0 ? std::to_string(e.completed_time) : "null") + ")"); auto results = db.QueryDatabase( fmt::format( "UPDATE {} SET {} WHERE {} = {}", TableName(), - Strings::Implode(", ", update_values), + Strings::Implode(", ", v), PrimaryKey(), - shared_task_activity_state_entry.shared_task_id + e.shared_task_id ) ); @@ -189,55 +189,55 @@ public: static SharedTaskActivityState InsertOne( Database& db, - SharedTaskActivityState shared_task_activity_state_entry + SharedTaskActivityState e ) { - std::vector insert_values; + std::vector v; - insert_values.push_back(std::to_string(shared_task_activity_state_entry.shared_task_id)); - insert_values.push_back(std::to_string(shared_task_activity_state_entry.activity_id)); - insert_values.push_back(std::to_string(shared_task_activity_state_entry.done_count)); - insert_values.push_back("FROM_UNIXTIME(" + (shared_task_activity_state_entry.updated_time > 0 ? std::to_string(shared_task_activity_state_entry.updated_time) : "null") + ")"); - insert_values.push_back("FROM_UNIXTIME(" + (shared_task_activity_state_entry.completed_time > 0 ? std::to_string(shared_task_activity_state_entry.completed_time) : "null") + ")"); + v.push_back(std::to_string(e.shared_task_id)); + v.push_back(std::to_string(e.activity_id)); + v.push_back(std::to_string(e.done_count)); + v.push_back("FROM_UNIXTIME(" + (e.updated_time > 0 ? std::to_string(e.updated_time) : "null") + ")"); + v.push_back("FROM_UNIXTIME(" + (e.completed_time > 0 ? std::to_string(e.completed_time) : "null") + ")"); auto results = db.QueryDatabase( fmt::format( "{} VALUES ({})", BaseInsert(), - Strings::Implode(",", insert_values) + Strings::Implode(",", v) ) ); if (results.Success()) { - shared_task_activity_state_entry.shared_task_id = results.LastInsertedID(); - return shared_task_activity_state_entry; + e.shared_task_id = results.LastInsertedID(); + return e; } - shared_task_activity_state_entry = NewEntity(); + e = NewEntity(); - return shared_task_activity_state_entry; + return e; } static int InsertMany( Database& db, - std::vector shared_task_activity_state_entries + const std::vector &entries ) { std::vector insert_chunks; - for (auto &shared_task_activity_state_entry: shared_task_activity_state_entries) { - std::vector insert_values; + for (auto &e: entries) { + std::vector v; - insert_values.push_back(std::to_string(shared_task_activity_state_entry.shared_task_id)); - insert_values.push_back(std::to_string(shared_task_activity_state_entry.activity_id)); - insert_values.push_back(std::to_string(shared_task_activity_state_entry.done_count)); - insert_values.push_back("FROM_UNIXTIME(" + (shared_task_activity_state_entry.updated_time > 0 ? std::to_string(shared_task_activity_state_entry.updated_time) : "null") + ")"); - insert_values.push_back("FROM_UNIXTIME(" + (shared_task_activity_state_entry.completed_time > 0 ? std::to_string(shared_task_activity_state_entry.completed_time) : "null") + ")"); + v.push_back(std::to_string(e.shared_task_id)); + v.push_back(std::to_string(e.activity_id)); + v.push_back(std::to_string(e.done_count)); + v.push_back("FROM_UNIXTIME(" + (e.updated_time > 0 ? std::to_string(e.updated_time) : "null") + ")"); + v.push_back("FROM_UNIXTIME(" + (e.completed_time > 0 ? std::to_string(e.completed_time) : "null") + ")"); - insert_chunks.push_back("(" + Strings::Implode(",", insert_values) + ")"); + insert_chunks.push_back("(" + Strings::Implode(",", v) + ")"); } - std::vector insert_values; + std::vector v; auto results = db.QueryDatabase( fmt::format( @@ -264,21 +264,21 @@ public: all_entries.reserve(results.RowCount()); for (auto row = results.begin(); row != results.end(); ++row) { - SharedTaskActivityState entry{}; + SharedTaskActivityState e{}; - entry.shared_task_id = strtoll(row[0], nullptr, 10); - entry.activity_id = atoi(row[1]); - entry.done_count = atoi(row[2]); - entry.updated_time = strtoll(row[3] ? row[3] : "-1", nullptr, 10); - entry.completed_time = strtoll(row[4] ? row[4] : "-1", nullptr, 10); + e.shared_task_id = strtoll(row[0], nullptr, 10); + e.activity_id = atoi(row[1]); + e.done_count = atoi(row[2]); + e.updated_time = strtoll(row[3] ? row[3] : "-1", nullptr, 10); + e.completed_time = strtoll(row[4] ? row[4] : "-1", nullptr, 10); - all_entries.push_back(entry); + all_entries.push_back(e); } return all_entries; } - static std::vector GetWhere(Database& db, std::string where_filter) + static std::vector GetWhere(Database& db, const std::string &where_filter) { std::vector all_entries; @@ -293,21 +293,21 @@ public: all_entries.reserve(results.RowCount()); for (auto row = results.begin(); row != results.end(); ++row) { - SharedTaskActivityState entry{}; + SharedTaskActivityState e{}; - entry.shared_task_id = strtoll(row[0], nullptr, 10); - entry.activity_id = atoi(row[1]); - entry.done_count = atoi(row[2]); - entry.updated_time = strtoll(row[3] ? row[3] : "-1", nullptr, 10); - entry.completed_time = strtoll(row[4] ? row[4] : "-1", nullptr, 10); + e.shared_task_id = strtoll(row[0], nullptr, 10); + e.activity_id = atoi(row[1]); + e.done_count = atoi(row[2]); + e.updated_time = strtoll(row[3] ? row[3] : "-1", nullptr, 10); + e.completed_time = strtoll(row[4] ? row[4] : "-1", nullptr, 10); - all_entries.push_back(entry); + all_entries.push_back(e); } return all_entries; } - static int DeleteWhere(Database& db, std::string where_filter) + static int DeleteWhere(Database& db, const std::string &where_filter) { auto results = db.QueryDatabase( fmt::format( @@ -332,6 +332,32 @@ public: 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); + } + }; #endif //EQEMU_BASE_SHARED_TASK_ACTIVITY_STATE_REPOSITORY_H diff --git a/common/repositories/base/base_shared_task_dynamic_zones_repository.h b/common/repositories/base/base_shared_task_dynamic_zones_repository.h index 00a8c8c16..919fbe15a 100644 --- a/common/repositories/base/base_shared_task_dynamic_zones_repository.h +++ b/common/repositories/base/base_shared_task_dynamic_zones_repository.h @@ -79,15 +79,15 @@ public: static SharedTaskDynamicZones NewEntity() { - SharedTaskDynamicZones entry{}; + SharedTaskDynamicZones e{}; - entry.shared_task_id = 0; - entry.dynamic_zone_id = 0; + e.shared_task_id = 0; + e.dynamic_zone_id = 0; - return entry; + return e; } - static SharedTaskDynamicZones GetSharedTaskDynamicZonesEntry( + static SharedTaskDynamicZones GetSharedTaskDynamicZones( const std::vector &shared_task_dynamic_zoness, int shared_task_dynamic_zones_id ) @@ -116,12 +116,12 @@ public: auto row = results.begin(); if (results.RowCount() == 1) { - SharedTaskDynamicZones entry{}; + SharedTaskDynamicZones e{}; - entry.shared_task_id = strtoll(row[0], nullptr, 10); - entry.dynamic_zone_id = atoi(row[1]); + e.shared_task_id = strtoll(row[0], nullptr, 10); + e.dynamic_zone_id = atoi(row[1]); - return entry; + return e; } return NewEntity(); @@ -146,23 +146,23 @@ public: static int UpdateOne( Database& db, - SharedTaskDynamicZones shared_task_dynamic_zones_entry + const SharedTaskDynamicZones &e ) { - std::vector update_values; + std::vector v; auto columns = Columns(); - update_values.push_back(columns[0] + " = " + std::to_string(shared_task_dynamic_zones_entry.shared_task_id)); - update_values.push_back(columns[1] + " = " + std::to_string(shared_task_dynamic_zones_entry.dynamic_zone_id)); + v.push_back(columns[0] + " = " + std::to_string(e.shared_task_id)); + v.push_back(columns[1] + " = " + std::to_string(e.dynamic_zone_id)); auto results = db.QueryDatabase( fmt::format( "UPDATE {} SET {} WHERE {} = {}", TableName(), - Strings::Implode(", ", update_values), + Strings::Implode(", ", v), PrimaryKey(), - shared_task_dynamic_zones_entry.shared_task_id + e.shared_task_id ) ); @@ -171,49 +171,49 @@ public: static SharedTaskDynamicZones InsertOne( Database& db, - SharedTaskDynamicZones shared_task_dynamic_zones_entry + SharedTaskDynamicZones e ) { - std::vector insert_values; + std::vector v; - insert_values.push_back(std::to_string(shared_task_dynamic_zones_entry.shared_task_id)); - insert_values.push_back(std::to_string(shared_task_dynamic_zones_entry.dynamic_zone_id)); + v.push_back(std::to_string(e.shared_task_id)); + v.push_back(std::to_string(e.dynamic_zone_id)); auto results = db.QueryDatabase( fmt::format( "{} VALUES ({})", BaseInsert(), - Strings::Implode(",", insert_values) + Strings::Implode(",", v) ) ); if (results.Success()) { - shared_task_dynamic_zones_entry.shared_task_id = results.LastInsertedID(); - return shared_task_dynamic_zones_entry; + e.shared_task_id = results.LastInsertedID(); + return e; } - shared_task_dynamic_zones_entry = NewEntity(); + e = NewEntity(); - return shared_task_dynamic_zones_entry; + return e; } static int InsertMany( Database& db, - std::vector shared_task_dynamic_zones_entries + const std::vector &entries ) { std::vector insert_chunks; - for (auto &shared_task_dynamic_zones_entry: shared_task_dynamic_zones_entries) { - std::vector insert_values; + for (auto &e: entries) { + std::vector v; - insert_values.push_back(std::to_string(shared_task_dynamic_zones_entry.shared_task_id)); - insert_values.push_back(std::to_string(shared_task_dynamic_zones_entry.dynamic_zone_id)); + v.push_back(std::to_string(e.shared_task_id)); + v.push_back(std::to_string(e.dynamic_zone_id)); - insert_chunks.push_back("(" + Strings::Implode(",", insert_values) + ")"); + insert_chunks.push_back("(" + Strings::Implode(",", v) + ")"); } - std::vector insert_values; + std::vector v; auto results = db.QueryDatabase( fmt::format( @@ -240,18 +240,18 @@ public: all_entries.reserve(results.RowCount()); for (auto row = results.begin(); row != results.end(); ++row) { - SharedTaskDynamicZones entry{}; + SharedTaskDynamicZones e{}; - entry.shared_task_id = strtoll(row[0], nullptr, 10); - entry.dynamic_zone_id = atoi(row[1]); + e.shared_task_id = strtoll(row[0], nullptr, 10); + e.dynamic_zone_id = atoi(row[1]); - all_entries.push_back(entry); + all_entries.push_back(e); } return all_entries; } - static std::vector GetWhere(Database& db, std::string where_filter) + static std::vector GetWhere(Database& db, const std::string &where_filter) { std::vector all_entries; @@ -266,18 +266,18 @@ public: all_entries.reserve(results.RowCount()); for (auto row = results.begin(); row != results.end(); ++row) { - SharedTaskDynamicZones entry{}; + SharedTaskDynamicZones e{}; - entry.shared_task_id = strtoll(row[0], nullptr, 10); - entry.dynamic_zone_id = atoi(row[1]); + e.shared_task_id = strtoll(row[0], nullptr, 10); + e.dynamic_zone_id = atoi(row[1]); - all_entries.push_back(entry); + all_entries.push_back(e); } return all_entries; } - static int DeleteWhere(Database& db, std::string where_filter) + static int DeleteWhere(Database& db, const std::string &where_filter) { auto results = db.QueryDatabase( fmt::format( @@ -302,6 +302,32 @@ public: 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); + } + }; #endif //EQEMU_BASE_SHARED_TASK_DYNAMIC_ZONES_REPOSITORY_H diff --git a/common/repositories/base/base_shared_task_members_repository.h b/common/repositories/base/base_shared_task_members_repository.h index ca883e2f0..282f36bef 100644 --- a/common/repositories/base/base_shared_task_members_repository.h +++ b/common/repositories/base/base_shared_task_members_repository.h @@ -82,16 +82,16 @@ public: static SharedTaskMembers NewEntity() { - SharedTaskMembers entry{}; + SharedTaskMembers e{}; - entry.shared_task_id = 0; - entry.character_id = 0; - entry.is_leader = 0; + e.shared_task_id = 0; + e.character_id = 0; + e.is_leader = 0; - return entry; + return e; } - static SharedTaskMembers GetSharedTaskMembersEntry( + static SharedTaskMembers GetSharedTaskMembers( const std::vector &shared_task_memberss, int shared_task_members_id ) @@ -120,13 +120,13 @@ public: auto row = results.begin(); if (results.RowCount() == 1) { - SharedTaskMembers entry{}; + SharedTaskMembers e{}; - entry.shared_task_id = strtoll(row[0], nullptr, 10); - entry.character_id = strtoll(row[1], nullptr, 10); - entry.is_leader = atoi(row[2]); + e.shared_task_id = strtoll(row[0], nullptr, 10); + e.character_id = strtoll(row[1], nullptr, 10); + e.is_leader = atoi(row[2]); - return entry; + return e; } return NewEntity(); @@ -151,24 +151,24 @@ public: static int UpdateOne( Database& db, - SharedTaskMembers shared_task_members_entry + const SharedTaskMembers &e ) { - std::vector update_values; + std::vector v; auto columns = Columns(); - update_values.push_back(columns[0] + " = " + std::to_string(shared_task_members_entry.shared_task_id)); - update_values.push_back(columns[1] + " = " + std::to_string(shared_task_members_entry.character_id)); - update_values.push_back(columns[2] + " = " + std::to_string(shared_task_members_entry.is_leader)); + v.push_back(columns[0] + " = " + std::to_string(e.shared_task_id)); + v.push_back(columns[1] + " = " + std::to_string(e.character_id)); + v.push_back(columns[2] + " = " + std::to_string(e.is_leader)); auto results = db.QueryDatabase( fmt::format( "UPDATE {} SET {} WHERE {} = {}", TableName(), - Strings::Implode(", ", update_values), + Strings::Implode(", ", v), PrimaryKey(), - shared_task_members_entry.shared_task_id + e.shared_task_id ) ); @@ -177,51 +177,51 @@ public: static SharedTaskMembers InsertOne( Database& db, - SharedTaskMembers shared_task_members_entry + SharedTaskMembers e ) { - std::vector insert_values; + std::vector v; - insert_values.push_back(std::to_string(shared_task_members_entry.shared_task_id)); - insert_values.push_back(std::to_string(shared_task_members_entry.character_id)); - insert_values.push_back(std::to_string(shared_task_members_entry.is_leader)); + v.push_back(std::to_string(e.shared_task_id)); + v.push_back(std::to_string(e.character_id)); + v.push_back(std::to_string(e.is_leader)); auto results = db.QueryDatabase( fmt::format( "{} VALUES ({})", BaseInsert(), - Strings::Implode(",", insert_values) + Strings::Implode(",", v) ) ); if (results.Success()) { - shared_task_members_entry.shared_task_id = results.LastInsertedID(); - return shared_task_members_entry; + e.shared_task_id = results.LastInsertedID(); + return e; } - shared_task_members_entry = NewEntity(); + e = NewEntity(); - return shared_task_members_entry; + return e; } static int InsertMany( Database& db, - std::vector shared_task_members_entries + const std::vector &entries ) { std::vector insert_chunks; - for (auto &shared_task_members_entry: shared_task_members_entries) { - std::vector insert_values; + for (auto &e: entries) { + std::vector v; - insert_values.push_back(std::to_string(shared_task_members_entry.shared_task_id)); - insert_values.push_back(std::to_string(shared_task_members_entry.character_id)); - insert_values.push_back(std::to_string(shared_task_members_entry.is_leader)); + v.push_back(std::to_string(e.shared_task_id)); + v.push_back(std::to_string(e.character_id)); + v.push_back(std::to_string(e.is_leader)); - insert_chunks.push_back("(" + Strings::Implode(",", insert_values) + ")"); + insert_chunks.push_back("(" + Strings::Implode(",", v) + ")"); } - std::vector insert_values; + std::vector v; auto results = db.QueryDatabase( fmt::format( @@ -248,19 +248,19 @@ public: all_entries.reserve(results.RowCount()); for (auto row = results.begin(); row != results.end(); ++row) { - SharedTaskMembers entry{}; + SharedTaskMembers e{}; - entry.shared_task_id = strtoll(row[0], nullptr, 10); - entry.character_id = strtoll(row[1], nullptr, 10); - entry.is_leader = atoi(row[2]); + e.shared_task_id = strtoll(row[0], nullptr, 10); + e.character_id = strtoll(row[1], nullptr, 10); + e.is_leader = atoi(row[2]); - all_entries.push_back(entry); + all_entries.push_back(e); } return all_entries; } - static std::vector GetWhere(Database& db, std::string where_filter) + static std::vector GetWhere(Database& db, const std::string &where_filter) { std::vector all_entries; @@ -275,19 +275,19 @@ public: all_entries.reserve(results.RowCount()); for (auto row = results.begin(); row != results.end(); ++row) { - SharedTaskMembers entry{}; + SharedTaskMembers e{}; - entry.shared_task_id = strtoll(row[0], nullptr, 10); - entry.character_id = strtoll(row[1], nullptr, 10); - entry.is_leader = atoi(row[2]); + e.shared_task_id = strtoll(row[0], nullptr, 10); + e.character_id = strtoll(row[1], nullptr, 10); + e.is_leader = atoi(row[2]); - all_entries.push_back(entry); + all_entries.push_back(e); } return all_entries; } - static int DeleteWhere(Database& db, std::string where_filter) + static int DeleteWhere(Database& db, const std::string &where_filter) { auto results = db.QueryDatabase( fmt::format( @@ -312,6 +312,32 @@ public: 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); + } + }; #endif //EQEMU_BASE_SHARED_TASK_MEMBERS_REPOSITORY_H diff --git a/common/repositories/base/base_shared_tasks_repository.h b/common/repositories/base/base_shared_tasks_repository.h index 3772240bf..e72f2d28f 100644 --- a/common/repositories/base/base_shared_tasks_repository.h +++ b/common/repositories/base/base_shared_tasks_repository.h @@ -91,19 +91,19 @@ public: static SharedTasks NewEntity() { - SharedTasks entry{}; + SharedTasks e{}; - entry.id = 0; - entry.task_id = 0; - entry.accepted_time = 0; - entry.expire_time = 0; - entry.completion_time = 0; - entry.is_locked = 0; + e.id = 0; + e.task_id = 0; + e.accepted_time = 0; + e.expire_time = 0; + e.completion_time = 0; + e.is_locked = 0; - return entry; + return e; } - static SharedTasks GetSharedTasksEntry( + static SharedTasks GetSharedTasks( const std::vector &shared_taskss, int shared_tasks_id ) @@ -132,16 +132,16 @@ public: auto row = results.begin(); if (results.RowCount() == 1) { - SharedTasks entry{}; + SharedTasks e{}; - entry.id = strtoll(row[0], nullptr, 10); - entry.task_id = atoi(row[1]); - entry.accepted_time = strtoll(row[2] ? row[2] : "-1", nullptr, 10); - entry.expire_time = strtoll(row[3] ? row[3] : "-1", nullptr, 10); - entry.completion_time = strtoll(row[4] ? row[4] : "-1", nullptr, 10); - entry.is_locked = atoi(row[5]); + e.id = strtoll(row[0], nullptr, 10); + e.task_id = atoi(row[1]); + e.accepted_time = strtoll(row[2] ? row[2] : "-1", nullptr, 10); + e.expire_time = strtoll(row[3] ? row[3] : "-1", nullptr, 10); + e.completion_time = strtoll(row[4] ? row[4] : "-1", nullptr, 10); + e.is_locked = atoi(row[5]); - return entry; + return e; } return NewEntity(); @@ -166,26 +166,26 @@ public: static int UpdateOne( Database& db, - SharedTasks shared_tasks_entry + const SharedTasks &e ) { - std::vector update_values; + std::vector v; auto columns = Columns(); - update_values.push_back(columns[1] + " = " + std::to_string(shared_tasks_entry.task_id)); - update_values.push_back(columns[2] + " = FROM_UNIXTIME(" + (shared_tasks_entry.accepted_time > 0 ? std::to_string(shared_tasks_entry.accepted_time) : "null") + ")"); - update_values.push_back(columns[3] + " = FROM_UNIXTIME(" + (shared_tasks_entry.expire_time > 0 ? std::to_string(shared_tasks_entry.expire_time) : "null") + ")"); - update_values.push_back(columns[4] + " = FROM_UNIXTIME(" + (shared_tasks_entry.completion_time > 0 ? std::to_string(shared_tasks_entry.completion_time) : "null") + ")"); - update_values.push_back(columns[5] + " = " + std::to_string(shared_tasks_entry.is_locked)); + v.push_back(columns[1] + " = " + std::to_string(e.task_id)); + v.push_back(columns[2] + " = FROM_UNIXTIME(" + (e.accepted_time > 0 ? std::to_string(e.accepted_time) : "null") + ")"); + v.push_back(columns[3] + " = FROM_UNIXTIME(" + (e.expire_time > 0 ? std::to_string(e.expire_time) : "null") + ")"); + v.push_back(columns[4] + " = FROM_UNIXTIME(" + (e.completion_time > 0 ? std::to_string(e.completion_time) : "null") + ")"); + v.push_back(columns[5] + " = " + std::to_string(e.is_locked)); auto results = db.QueryDatabase( fmt::format( "UPDATE {} SET {} WHERE {} = {}", TableName(), - Strings::Implode(", ", update_values), + Strings::Implode(", ", v), PrimaryKey(), - shared_tasks_entry.id + e.id ) ); @@ -194,57 +194,57 @@ public: static SharedTasks InsertOne( Database& db, - SharedTasks shared_tasks_entry + SharedTasks e ) { - std::vector insert_values; + std::vector v; - insert_values.push_back(std::to_string(shared_tasks_entry.id)); - insert_values.push_back(std::to_string(shared_tasks_entry.task_id)); - insert_values.push_back("FROM_UNIXTIME(" + (shared_tasks_entry.accepted_time > 0 ? std::to_string(shared_tasks_entry.accepted_time) : "null") + ")"); - insert_values.push_back("FROM_UNIXTIME(" + (shared_tasks_entry.expire_time > 0 ? std::to_string(shared_tasks_entry.expire_time) : "null") + ")"); - insert_values.push_back("FROM_UNIXTIME(" + (shared_tasks_entry.completion_time > 0 ? std::to_string(shared_tasks_entry.completion_time) : "null") + ")"); - insert_values.push_back(std::to_string(shared_tasks_entry.is_locked)); + v.push_back(std::to_string(e.id)); + v.push_back(std::to_string(e.task_id)); + v.push_back("FROM_UNIXTIME(" + (e.accepted_time > 0 ? std::to_string(e.accepted_time) : "null") + ")"); + v.push_back("FROM_UNIXTIME(" + (e.expire_time > 0 ? std::to_string(e.expire_time) : "null") + ")"); + v.push_back("FROM_UNIXTIME(" + (e.completion_time > 0 ? std::to_string(e.completion_time) : "null") + ")"); + v.push_back(std::to_string(e.is_locked)); auto results = db.QueryDatabase( fmt::format( "{} VALUES ({})", BaseInsert(), - Strings::Implode(",", insert_values) + Strings::Implode(",", v) ) ); if (results.Success()) { - shared_tasks_entry.id = results.LastInsertedID(); - return shared_tasks_entry; + e.id = results.LastInsertedID(); + return e; } - shared_tasks_entry = NewEntity(); + e = NewEntity(); - return shared_tasks_entry; + return e; } static int InsertMany( Database& db, - std::vector shared_tasks_entries + const std::vector &entries ) { std::vector insert_chunks; - for (auto &shared_tasks_entry: shared_tasks_entries) { - std::vector insert_values; + for (auto &e: entries) { + std::vector v; - insert_values.push_back(std::to_string(shared_tasks_entry.id)); - insert_values.push_back(std::to_string(shared_tasks_entry.task_id)); - insert_values.push_back("FROM_UNIXTIME(" + (shared_tasks_entry.accepted_time > 0 ? std::to_string(shared_tasks_entry.accepted_time) : "null") + ")"); - insert_values.push_back("FROM_UNIXTIME(" + (shared_tasks_entry.expire_time > 0 ? std::to_string(shared_tasks_entry.expire_time) : "null") + ")"); - insert_values.push_back("FROM_UNIXTIME(" + (shared_tasks_entry.completion_time > 0 ? std::to_string(shared_tasks_entry.completion_time) : "null") + ")"); - insert_values.push_back(std::to_string(shared_tasks_entry.is_locked)); + v.push_back(std::to_string(e.id)); + v.push_back(std::to_string(e.task_id)); + v.push_back("FROM_UNIXTIME(" + (e.accepted_time > 0 ? std::to_string(e.accepted_time) : "null") + ")"); + v.push_back("FROM_UNIXTIME(" + (e.expire_time > 0 ? std::to_string(e.expire_time) : "null") + ")"); + v.push_back("FROM_UNIXTIME(" + (e.completion_time > 0 ? std::to_string(e.completion_time) : "null") + ")"); + v.push_back(std::to_string(e.is_locked)); - insert_chunks.push_back("(" + Strings::Implode(",", insert_values) + ")"); + insert_chunks.push_back("(" + Strings::Implode(",", v) + ")"); } - std::vector insert_values; + std::vector v; auto results = db.QueryDatabase( fmt::format( @@ -271,22 +271,22 @@ public: all_entries.reserve(results.RowCount()); for (auto row = results.begin(); row != results.end(); ++row) { - SharedTasks entry{}; + SharedTasks e{}; - entry.id = strtoll(row[0], nullptr, 10); - entry.task_id = atoi(row[1]); - entry.accepted_time = strtoll(row[2] ? row[2] : "-1", nullptr, 10); - entry.expire_time = strtoll(row[3] ? row[3] : "-1", nullptr, 10); - entry.completion_time = strtoll(row[4] ? row[4] : "-1", nullptr, 10); - entry.is_locked = atoi(row[5]); + e.id = strtoll(row[0], nullptr, 10); + e.task_id = atoi(row[1]); + e.accepted_time = strtoll(row[2] ? row[2] : "-1", nullptr, 10); + e.expire_time = strtoll(row[3] ? row[3] : "-1", nullptr, 10); + e.completion_time = strtoll(row[4] ? row[4] : "-1", nullptr, 10); + e.is_locked = atoi(row[5]); - all_entries.push_back(entry); + all_entries.push_back(e); } return all_entries; } - static std::vector GetWhere(Database& db, std::string where_filter) + static std::vector GetWhere(Database& db, const std::string &where_filter) { std::vector all_entries; @@ -301,22 +301,22 @@ public: all_entries.reserve(results.RowCount()); for (auto row = results.begin(); row != results.end(); ++row) { - SharedTasks entry{}; + SharedTasks e{}; - entry.id = strtoll(row[0], nullptr, 10); - entry.task_id = atoi(row[1]); - entry.accepted_time = strtoll(row[2] ? row[2] : "-1", nullptr, 10); - entry.expire_time = strtoll(row[3] ? row[3] : "-1", nullptr, 10); - entry.completion_time = strtoll(row[4] ? row[4] : "-1", nullptr, 10); - entry.is_locked = atoi(row[5]); + e.id = strtoll(row[0], nullptr, 10); + e.task_id = atoi(row[1]); + e.accepted_time = strtoll(row[2] ? row[2] : "-1", nullptr, 10); + e.expire_time = strtoll(row[3] ? row[3] : "-1", nullptr, 10); + e.completion_time = strtoll(row[4] ? row[4] : "-1", nullptr, 10); + e.is_locked = atoi(row[5]); - all_entries.push_back(entry); + all_entries.push_back(e); } return all_entries; } - static int DeleteWhere(Database& db, std::string where_filter) + static int DeleteWhere(Database& db, const std::string &where_filter) { auto results = db.QueryDatabase( fmt::format( @@ -341,6 +341,32 @@ public: 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); + } + }; #endif //EQEMU_BASE_SHARED_TASKS_REPOSITORY_H diff --git a/common/repositories/base/base_skill_caps_repository.h b/common/repositories/base/base_skill_caps_repository.h index 2a0d59ad0..04ed2e6ff 100644 --- a/common/repositories/base/base_skill_caps_repository.h +++ b/common/repositories/base/base_skill_caps_repository.h @@ -88,18 +88,18 @@ public: static SkillCaps NewEntity() { - SkillCaps entry{}; + SkillCaps e{}; - entry.skillID = 0; - entry.class_ = 0; - entry.level = 0; - entry.cap = 0; - entry.class_ = 0; + e.skillID = 0; + e.class_ = 0; + e.level = 0; + e.cap = 0; + e.class_ = 0; - return entry; + return e; } - static SkillCaps GetSkillCapsEntry( + static SkillCaps GetSkillCaps( const std::vector &skill_capss, int skill_caps_id ) @@ -128,15 +128,15 @@ public: auto row = results.begin(); if (results.RowCount() == 1) { - SkillCaps entry{}; + SkillCaps e{}; - entry.skillID = atoi(row[0]); - entry.class_ = atoi(row[1]); - entry.level = atoi(row[2]); - entry.cap = atoi(row[3]); - entry.class_ = atoi(row[4]); + e.skillID = atoi(row[0]); + e.class_ = atoi(row[1]); + e.level = atoi(row[2]); + e.cap = atoi(row[3]); + e.class_ = atoi(row[4]); - return entry; + return e; } return NewEntity(); @@ -161,26 +161,26 @@ public: static int UpdateOne( Database& db, - SkillCaps skill_caps_entry + const SkillCaps &e ) { - std::vector update_values; + std::vector v; auto columns = Columns(); - update_values.push_back(columns[0] + " = " + std::to_string(skill_caps_entry.skillID)); - update_values.push_back(columns[1] + " = " + std::to_string(skill_caps_entry.class_)); - update_values.push_back(columns[2] + " = " + std::to_string(skill_caps_entry.level)); - update_values.push_back(columns[3] + " = " + std::to_string(skill_caps_entry.cap)); - update_values.push_back(columns[4] + " = " + std::to_string(skill_caps_entry.class_)); + v.push_back(columns[0] + " = " + std::to_string(e.skillID)); + v.push_back(columns[1] + " = " + std::to_string(e.class_)); + v.push_back(columns[2] + " = " + std::to_string(e.level)); + v.push_back(columns[3] + " = " + std::to_string(e.cap)); + v.push_back(columns[4] + " = " + std::to_string(e.class_)); auto results = db.QueryDatabase( fmt::format( "UPDATE {} SET {} WHERE {} = {}", TableName(), - Strings::Implode(", ", update_values), + Strings::Implode(", ", v), PrimaryKey(), - skill_caps_entry.skillID + e.skillID ) ); @@ -189,55 +189,55 @@ public: static SkillCaps InsertOne( Database& db, - SkillCaps skill_caps_entry + SkillCaps e ) { - std::vector insert_values; + std::vector v; - insert_values.push_back(std::to_string(skill_caps_entry.skillID)); - insert_values.push_back(std::to_string(skill_caps_entry.class_)); - insert_values.push_back(std::to_string(skill_caps_entry.level)); - insert_values.push_back(std::to_string(skill_caps_entry.cap)); - insert_values.push_back(std::to_string(skill_caps_entry.class_)); + v.push_back(std::to_string(e.skillID)); + v.push_back(std::to_string(e.class_)); + v.push_back(std::to_string(e.level)); + v.push_back(std::to_string(e.cap)); + v.push_back(std::to_string(e.class_)); auto results = db.QueryDatabase( fmt::format( "{} VALUES ({})", BaseInsert(), - Strings::Implode(",", insert_values) + Strings::Implode(",", v) ) ); if (results.Success()) { - skill_caps_entry.skillID = results.LastInsertedID(); - return skill_caps_entry; + e.skillID = results.LastInsertedID(); + return e; } - skill_caps_entry = NewEntity(); + e = NewEntity(); - return skill_caps_entry; + return e; } static int InsertMany( Database& db, - std::vector skill_caps_entries + const std::vector &entries ) { std::vector insert_chunks; - for (auto &skill_caps_entry: skill_caps_entries) { - std::vector insert_values; + for (auto &e: entries) { + std::vector v; - insert_values.push_back(std::to_string(skill_caps_entry.skillID)); - insert_values.push_back(std::to_string(skill_caps_entry.class_)); - insert_values.push_back(std::to_string(skill_caps_entry.level)); - insert_values.push_back(std::to_string(skill_caps_entry.cap)); - insert_values.push_back(std::to_string(skill_caps_entry.class_)); + v.push_back(std::to_string(e.skillID)); + v.push_back(std::to_string(e.class_)); + v.push_back(std::to_string(e.level)); + v.push_back(std::to_string(e.cap)); + v.push_back(std::to_string(e.class_)); - insert_chunks.push_back("(" + Strings::Implode(",", insert_values) + ")"); + insert_chunks.push_back("(" + Strings::Implode(",", v) + ")"); } - std::vector insert_values; + std::vector v; auto results = db.QueryDatabase( fmt::format( @@ -264,21 +264,21 @@ public: all_entries.reserve(results.RowCount()); for (auto row = results.begin(); row != results.end(); ++row) { - SkillCaps entry{}; + SkillCaps e{}; - entry.skillID = atoi(row[0]); - entry.class_ = atoi(row[1]); - entry.level = atoi(row[2]); - entry.cap = atoi(row[3]); - entry.class_ = atoi(row[4]); + e.skillID = atoi(row[0]); + e.class_ = atoi(row[1]); + e.level = atoi(row[2]); + e.cap = atoi(row[3]); + e.class_ = atoi(row[4]); - all_entries.push_back(entry); + all_entries.push_back(e); } return all_entries; } - static std::vector GetWhere(Database& db, std::string where_filter) + static std::vector GetWhere(Database& db, const std::string &where_filter) { std::vector all_entries; @@ -293,21 +293,21 @@ public: all_entries.reserve(results.RowCount()); for (auto row = results.begin(); row != results.end(); ++row) { - SkillCaps entry{}; + SkillCaps e{}; - entry.skillID = atoi(row[0]); - entry.class_ = atoi(row[1]); - entry.level = atoi(row[2]); - entry.cap = atoi(row[3]); - entry.class_ = atoi(row[4]); + e.skillID = atoi(row[0]); + e.class_ = atoi(row[1]); + e.level = atoi(row[2]); + e.cap = atoi(row[3]); + e.class_ = atoi(row[4]); - all_entries.push_back(entry); + all_entries.push_back(e); } return all_entries; } - static int DeleteWhere(Database& db, std::string where_filter) + static int DeleteWhere(Database& db, const std::string &where_filter) { auto results = db.QueryDatabase( fmt::format( @@ -332,6 +332,32 @@ public: 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); + } + }; #endif //EQEMU_BASE_SKILL_CAPS_REPOSITORY_H diff --git a/common/repositories/base/base_spawn2_repository.h b/common/repositories/base/base_spawn2_repository.h index bc9e0cf9b..8b7518653 100644 --- a/common/repositories/base/base_spawn2_repository.h +++ b/common/repositories/base/base_spawn2_repository.h @@ -133,33 +133,33 @@ public: static Spawn2 NewEntity() { - Spawn2 entry{}; + Spawn2 e{}; - entry.id = 0; - entry.spawngroupID = 0; - entry.zone = ""; - entry.version = 0; - entry.x = 0.000000; - entry.y = 0.000000; - entry.z = 0.000000; - entry.heading = 0.000000; - entry.respawntime = 0; - entry.variance = 0; - entry.pathgrid = 0; - entry.path_when_zone_idle = 0; - entry._condition = 0; - entry.cond_value = 1; - entry.enabled = 1; - entry.animation = 0; - entry.min_expansion = -1; - entry.max_expansion = -1; - entry.content_flags = ""; - entry.content_flags_disabled = ""; + e.id = 0; + e.spawngroupID = 0; + e.zone = ""; + e.version = 0; + e.x = 0.000000; + e.y = 0.000000; + e.z = 0.000000; + e.heading = 0.000000; + e.respawntime = 0; + e.variance = 0; + e.pathgrid = 0; + e.path_when_zone_idle = 0; + e._condition = 0; + e.cond_value = 1; + e.enabled = 1; + e.animation = 0; + e.min_expansion = -1; + e.max_expansion = -1; + e.content_flags = ""; + e.content_flags_disabled = ""; - return entry; + return e; } - static Spawn2 GetSpawn2Entry( + static Spawn2 GetSpawn2( const std::vector &spawn2s, int spawn2_id ) @@ -188,30 +188,30 @@ public: auto row = results.begin(); if (results.RowCount() == 1) { - Spawn2 entry{}; + Spawn2 e{}; - entry.id = atoi(row[0]); - entry.spawngroupID = atoi(row[1]); - entry.zone = row[2] ? row[2] : ""; - entry.version = atoi(row[3]); - entry.x = static_cast(atof(row[4])); - entry.y = static_cast(atof(row[5])); - entry.z = static_cast(atof(row[6])); - entry.heading = static_cast(atof(row[7])); - entry.respawntime = atoi(row[8]); - entry.variance = atoi(row[9]); - entry.pathgrid = atoi(row[10]); - entry.path_when_zone_idle = atoi(row[11]); - entry._condition = atoi(row[12]); - entry.cond_value = atoi(row[13]); - entry.enabled = atoi(row[14]); - entry.animation = atoi(row[15]); - entry.min_expansion = atoi(row[16]); - entry.max_expansion = atoi(row[17]); - entry.content_flags = row[18] ? row[18] : ""; - entry.content_flags_disabled = row[19] ? row[19] : ""; + e.id = atoi(row[0]); + e.spawngroupID = atoi(row[1]); + e.zone = row[2] ? row[2] : ""; + e.version = atoi(row[3]); + e.x = static_cast(atof(row[4])); + e.y = static_cast(atof(row[5])); + e.z = static_cast(atof(row[6])); + e.heading = static_cast(atof(row[7])); + e.respawntime = atoi(row[8]); + e.variance = atoi(row[9]); + e.pathgrid = atoi(row[10]); + e.path_when_zone_idle = atoi(row[11]); + e._condition = atoi(row[12]); + e.cond_value = atoi(row[13]); + e.enabled = atoi(row[14]); + e.animation = atoi(row[15]); + e.min_expansion = atoi(row[16]); + e.max_expansion = atoi(row[17]); + e.content_flags = row[18] ? row[18] : ""; + e.content_flags_disabled = row[19] ? row[19] : ""; - return entry; + return e; } return NewEntity(); @@ -236,40 +236,40 @@ public: static int UpdateOne( Database& db, - Spawn2 spawn2_entry + const Spawn2 &e ) { - std::vector update_values; + std::vector v; auto columns = Columns(); - update_values.push_back(columns[1] + " = " + std::to_string(spawn2_entry.spawngroupID)); - update_values.push_back(columns[2] + " = '" + Strings::Escape(spawn2_entry.zone) + "'"); - update_values.push_back(columns[3] + " = " + std::to_string(spawn2_entry.version)); - update_values.push_back(columns[4] + " = " + std::to_string(spawn2_entry.x)); - update_values.push_back(columns[5] + " = " + std::to_string(spawn2_entry.y)); - update_values.push_back(columns[6] + " = " + std::to_string(spawn2_entry.z)); - update_values.push_back(columns[7] + " = " + std::to_string(spawn2_entry.heading)); - update_values.push_back(columns[8] + " = " + std::to_string(spawn2_entry.respawntime)); - update_values.push_back(columns[9] + " = " + std::to_string(spawn2_entry.variance)); - update_values.push_back(columns[10] + " = " + std::to_string(spawn2_entry.pathgrid)); - update_values.push_back(columns[11] + " = " + std::to_string(spawn2_entry.path_when_zone_idle)); - update_values.push_back(columns[12] + " = " + std::to_string(spawn2_entry._condition)); - update_values.push_back(columns[13] + " = " + std::to_string(spawn2_entry.cond_value)); - update_values.push_back(columns[14] + " = " + std::to_string(spawn2_entry.enabled)); - update_values.push_back(columns[15] + " = " + std::to_string(spawn2_entry.animation)); - update_values.push_back(columns[16] + " = " + std::to_string(spawn2_entry.min_expansion)); - update_values.push_back(columns[17] + " = " + std::to_string(spawn2_entry.max_expansion)); - update_values.push_back(columns[18] + " = '" + Strings::Escape(spawn2_entry.content_flags) + "'"); - update_values.push_back(columns[19] + " = '" + Strings::Escape(spawn2_entry.content_flags_disabled) + "'"); + v.push_back(columns[1] + " = " + std::to_string(e.spawngroupID)); + v.push_back(columns[2] + " = '" + Strings::Escape(e.zone) + "'"); + v.push_back(columns[3] + " = " + std::to_string(e.version)); + v.push_back(columns[4] + " = " + std::to_string(e.x)); + v.push_back(columns[5] + " = " + std::to_string(e.y)); + v.push_back(columns[6] + " = " + std::to_string(e.z)); + v.push_back(columns[7] + " = " + std::to_string(e.heading)); + v.push_back(columns[8] + " = " + std::to_string(e.respawntime)); + v.push_back(columns[9] + " = " + std::to_string(e.variance)); + v.push_back(columns[10] + " = " + std::to_string(e.pathgrid)); + v.push_back(columns[11] + " = " + std::to_string(e.path_when_zone_idle)); + v.push_back(columns[12] + " = " + std::to_string(e._condition)); + v.push_back(columns[13] + " = " + std::to_string(e.cond_value)); + v.push_back(columns[14] + " = " + std::to_string(e.enabled)); + v.push_back(columns[15] + " = " + std::to_string(e.animation)); + v.push_back(columns[16] + " = " + std::to_string(e.min_expansion)); + v.push_back(columns[17] + " = " + std::to_string(e.max_expansion)); + v.push_back(columns[18] + " = '" + Strings::Escape(e.content_flags) + "'"); + v.push_back(columns[19] + " = '" + Strings::Escape(e.content_flags_disabled) + "'"); auto results = db.QueryDatabase( fmt::format( "UPDATE {} SET {} WHERE {} = {}", TableName(), - Strings::Implode(", ", update_values), + Strings::Implode(", ", v), PrimaryKey(), - spawn2_entry.id + e.id ) ); @@ -278,85 +278,85 @@ public: static Spawn2 InsertOne( Database& db, - Spawn2 spawn2_entry + Spawn2 e ) { - std::vector insert_values; + std::vector v; - insert_values.push_back(std::to_string(spawn2_entry.id)); - insert_values.push_back(std::to_string(spawn2_entry.spawngroupID)); - insert_values.push_back("'" + Strings::Escape(spawn2_entry.zone) + "'"); - insert_values.push_back(std::to_string(spawn2_entry.version)); - insert_values.push_back(std::to_string(spawn2_entry.x)); - insert_values.push_back(std::to_string(spawn2_entry.y)); - insert_values.push_back(std::to_string(spawn2_entry.z)); - insert_values.push_back(std::to_string(spawn2_entry.heading)); - insert_values.push_back(std::to_string(spawn2_entry.respawntime)); - insert_values.push_back(std::to_string(spawn2_entry.variance)); - insert_values.push_back(std::to_string(spawn2_entry.pathgrid)); - insert_values.push_back(std::to_string(spawn2_entry.path_when_zone_idle)); - insert_values.push_back(std::to_string(spawn2_entry._condition)); - insert_values.push_back(std::to_string(spawn2_entry.cond_value)); - insert_values.push_back(std::to_string(spawn2_entry.enabled)); - insert_values.push_back(std::to_string(spawn2_entry.animation)); - insert_values.push_back(std::to_string(spawn2_entry.min_expansion)); - insert_values.push_back(std::to_string(spawn2_entry.max_expansion)); - insert_values.push_back("'" + Strings::Escape(spawn2_entry.content_flags) + "'"); - insert_values.push_back("'" + Strings::Escape(spawn2_entry.content_flags_disabled) + "'"); + v.push_back(std::to_string(e.id)); + v.push_back(std::to_string(e.spawngroupID)); + v.push_back("'" + Strings::Escape(e.zone) + "'"); + v.push_back(std::to_string(e.version)); + v.push_back(std::to_string(e.x)); + v.push_back(std::to_string(e.y)); + v.push_back(std::to_string(e.z)); + v.push_back(std::to_string(e.heading)); + v.push_back(std::to_string(e.respawntime)); + v.push_back(std::to_string(e.variance)); + v.push_back(std::to_string(e.pathgrid)); + v.push_back(std::to_string(e.path_when_zone_idle)); + v.push_back(std::to_string(e._condition)); + v.push_back(std::to_string(e.cond_value)); + v.push_back(std::to_string(e.enabled)); + v.push_back(std::to_string(e.animation)); + v.push_back(std::to_string(e.min_expansion)); + v.push_back(std::to_string(e.max_expansion)); + v.push_back("'" + Strings::Escape(e.content_flags) + "'"); + v.push_back("'" + Strings::Escape(e.content_flags_disabled) + "'"); auto results = db.QueryDatabase( fmt::format( "{} VALUES ({})", BaseInsert(), - Strings::Implode(",", insert_values) + Strings::Implode(",", v) ) ); if (results.Success()) { - spawn2_entry.id = results.LastInsertedID(); - return spawn2_entry; + e.id = results.LastInsertedID(); + return e; } - spawn2_entry = NewEntity(); + e = NewEntity(); - return spawn2_entry; + return e; } static int InsertMany( Database& db, - std::vector spawn2_entries + const std::vector &entries ) { std::vector insert_chunks; - for (auto &spawn2_entry: spawn2_entries) { - std::vector insert_values; + for (auto &e: entries) { + std::vector v; - insert_values.push_back(std::to_string(spawn2_entry.id)); - insert_values.push_back(std::to_string(spawn2_entry.spawngroupID)); - insert_values.push_back("'" + Strings::Escape(spawn2_entry.zone) + "'"); - insert_values.push_back(std::to_string(spawn2_entry.version)); - insert_values.push_back(std::to_string(spawn2_entry.x)); - insert_values.push_back(std::to_string(spawn2_entry.y)); - insert_values.push_back(std::to_string(spawn2_entry.z)); - insert_values.push_back(std::to_string(spawn2_entry.heading)); - insert_values.push_back(std::to_string(spawn2_entry.respawntime)); - insert_values.push_back(std::to_string(spawn2_entry.variance)); - insert_values.push_back(std::to_string(spawn2_entry.pathgrid)); - insert_values.push_back(std::to_string(spawn2_entry.path_when_zone_idle)); - insert_values.push_back(std::to_string(spawn2_entry._condition)); - insert_values.push_back(std::to_string(spawn2_entry.cond_value)); - insert_values.push_back(std::to_string(spawn2_entry.enabled)); - insert_values.push_back(std::to_string(spawn2_entry.animation)); - insert_values.push_back(std::to_string(spawn2_entry.min_expansion)); - insert_values.push_back(std::to_string(spawn2_entry.max_expansion)); - insert_values.push_back("'" + Strings::Escape(spawn2_entry.content_flags) + "'"); - insert_values.push_back("'" + Strings::Escape(spawn2_entry.content_flags_disabled) + "'"); + v.push_back(std::to_string(e.id)); + v.push_back(std::to_string(e.spawngroupID)); + v.push_back("'" + Strings::Escape(e.zone) + "'"); + v.push_back(std::to_string(e.version)); + v.push_back(std::to_string(e.x)); + v.push_back(std::to_string(e.y)); + v.push_back(std::to_string(e.z)); + v.push_back(std::to_string(e.heading)); + v.push_back(std::to_string(e.respawntime)); + v.push_back(std::to_string(e.variance)); + v.push_back(std::to_string(e.pathgrid)); + v.push_back(std::to_string(e.path_when_zone_idle)); + v.push_back(std::to_string(e._condition)); + v.push_back(std::to_string(e.cond_value)); + v.push_back(std::to_string(e.enabled)); + v.push_back(std::to_string(e.animation)); + v.push_back(std::to_string(e.min_expansion)); + v.push_back(std::to_string(e.max_expansion)); + v.push_back("'" + Strings::Escape(e.content_flags) + "'"); + v.push_back("'" + Strings::Escape(e.content_flags_disabled) + "'"); - insert_chunks.push_back("(" + Strings::Implode(",", insert_values) + ")"); + insert_chunks.push_back("(" + Strings::Implode(",", v) + ")"); } - std::vector insert_values; + std::vector v; auto results = db.QueryDatabase( fmt::format( @@ -383,36 +383,36 @@ public: all_entries.reserve(results.RowCount()); for (auto row = results.begin(); row != results.end(); ++row) { - Spawn2 entry{}; + Spawn2 e{}; - entry.id = atoi(row[0]); - entry.spawngroupID = atoi(row[1]); - entry.zone = row[2] ? row[2] : ""; - entry.version = atoi(row[3]); - entry.x = static_cast(atof(row[4])); - entry.y = static_cast(atof(row[5])); - entry.z = static_cast(atof(row[6])); - entry.heading = static_cast(atof(row[7])); - entry.respawntime = atoi(row[8]); - entry.variance = atoi(row[9]); - entry.pathgrid = atoi(row[10]); - entry.path_when_zone_idle = atoi(row[11]); - entry._condition = atoi(row[12]); - entry.cond_value = atoi(row[13]); - entry.enabled = atoi(row[14]); - entry.animation = atoi(row[15]); - entry.min_expansion = atoi(row[16]); - entry.max_expansion = atoi(row[17]); - entry.content_flags = row[18] ? row[18] : ""; - entry.content_flags_disabled = row[19] ? row[19] : ""; + e.id = atoi(row[0]); + e.spawngroupID = atoi(row[1]); + e.zone = row[2] ? row[2] : ""; + e.version = atoi(row[3]); + e.x = static_cast(atof(row[4])); + e.y = static_cast(atof(row[5])); + e.z = static_cast(atof(row[6])); + e.heading = static_cast(atof(row[7])); + e.respawntime = atoi(row[8]); + e.variance = atoi(row[9]); + e.pathgrid = atoi(row[10]); + e.path_when_zone_idle = atoi(row[11]); + e._condition = atoi(row[12]); + e.cond_value = atoi(row[13]); + e.enabled = atoi(row[14]); + e.animation = atoi(row[15]); + e.min_expansion = atoi(row[16]); + e.max_expansion = atoi(row[17]); + e.content_flags = row[18] ? row[18] : ""; + e.content_flags_disabled = row[19] ? row[19] : ""; - all_entries.push_back(entry); + all_entries.push_back(e); } return all_entries; } - static std::vector GetWhere(Database& db, std::string where_filter) + static std::vector GetWhere(Database& db, const std::string &where_filter) { std::vector all_entries; @@ -427,36 +427,36 @@ public: all_entries.reserve(results.RowCount()); for (auto row = results.begin(); row != results.end(); ++row) { - Spawn2 entry{}; + Spawn2 e{}; - entry.id = atoi(row[0]); - entry.spawngroupID = atoi(row[1]); - entry.zone = row[2] ? row[2] : ""; - entry.version = atoi(row[3]); - entry.x = static_cast(atof(row[4])); - entry.y = static_cast(atof(row[5])); - entry.z = static_cast(atof(row[6])); - entry.heading = static_cast(atof(row[7])); - entry.respawntime = atoi(row[8]); - entry.variance = atoi(row[9]); - entry.pathgrid = atoi(row[10]); - entry.path_when_zone_idle = atoi(row[11]); - entry._condition = atoi(row[12]); - entry.cond_value = atoi(row[13]); - entry.enabled = atoi(row[14]); - entry.animation = atoi(row[15]); - entry.min_expansion = atoi(row[16]); - entry.max_expansion = atoi(row[17]); - entry.content_flags = row[18] ? row[18] : ""; - entry.content_flags_disabled = row[19] ? row[19] : ""; + e.id = atoi(row[0]); + e.spawngroupID = atoi(row[1]); + e.zone = row[2] ? row[2] : ""; + e.version = atoi(row[3]); + e.x = static_cast(atof(row[4])); + e.y = static_cast(atof(row[5])); + e.z = static_cast(atof(row[6])); + e.heading = static_cast(atof(row[7])); + e.respawntime = atoi(row[8]); + e.variance = atoi(row[9]); + e.pathgrid = atoi(row[10]); + e.path_when_zone_idle = atoi(row[11]); + e._condition = atoi(row[12]); + e.cond_value = atoi(row[13]); + e.enabled = atoi(row[14]); + e.animation = atoi(row[15]); + e.min_expansion = atoi(row[16]); + e.max_expansion = atoi(row[17]); + e.content_flags = row[18] ? row[18] : ""; + e.content_flags_disabled = row[19] ? row[19] : ""; - all_entries.push_back(entry); + all_entries.push_back(e); } return all_entries; } - static int DeleteWhere(Database& db, std::string where_filter) + static int DeleteWhere(Database& db, const std::string &where_filter) { auto results = db.QueryDatabase( fmt::format( @@ -481,6 +481,32 @@ public: 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); + } + }; #endif //EQEMU_BASE_SPAWN2_REPOSITORY_H diff --git a/common/repositories/base/base_spawn_condition_values_repository.h b/common/repositories/base/base_spawn_condition_values_repository.h index 2d310db23..ebba336fe 100644 --- a/common/repositories/base/base_spawn_condition_values_repository.h +++ b/common/repositories/base/base_spawn_condition_values_repository.h @@ -85,17 +85,17 @@ public: static SpawnConditionValues NewEntity() { - SpawnConditionValues entry{}; + SpawnConditionValues e{}; - entry.id = 0; - entry.value = 0; - entry.zone = ""; - entry.instance_id = 0; + e.id = 0; + e.value = 0; + e.zone = ""; + e.instance_id = 0; - return entry; + return e; } - static SpawnConditionValues GetSpawnConditionValuesEntry( + static SpawnConditionValues GetSpawnConditionValues( const std::vector &spawn_condition_valuess, int spawn_condition_values_id ) @@ -124,14 +124,14 @@ public: auto row = results.begin(); if (results.RowCount() == 1) { - SpawnConditionValues entry{}; + SpawnConditionValues e{}; - entry.id = atoi(row[0]); - entry.value = atoi(row[1]); - entry.zone = row[2] ? row[2] : ""; - entry.instance_id = atoi(row[3]); + e.id = atoi(row[0]); + e.value = atoi(row[1]); + e.zone = row[2] ? row[2] : ""; + e.instance_id = atoi(row[3]); - return entry; + return e; } return NewEntity(); @@ -156,25 +156,25 @@ public: static int UpdateOne( Database& db, - SpawnConditionValues spawn_condition_values_entry + const SpawnConditionValues &e ) { - std::vector update_values; + std::vector v; auto columns = Columns(); - update_values.push_back(columns[0] + " = " + std::to_string(spawn_condition_values_entry.id)); - update_values.push_back(columns[1] + " = " + std::to_string(spawn_condition_values_entry.value)); - update_values.push_back(columns[2] + " = '" + Strings::Escape(spawn_condition_values_entry.zone) + "'"); - update_values.push_back(columns[3] + " = " + std::to_string(spawn_condition_values_entry.instance_id)); + v.push_back(columns[0] + " = " + std::to_string(e.id)); + v.push_back(columns[1] + " = " + std::to_string(e.value)); + v.push_back(columns[2] + " = '" + Strings::Escape(e.zone) + "'"); + v.push_back(columns[3] + " = " + std::to_string(e.instance_id)); auto results = db.QueryDatabase( fmt::format( "UPDATE {} SET {} WHERE {} = {}", TableName(), - Strings::Implode(", ", update_values), + Strings::Implode(", ", v), PrimaryKey(), - spawn_condition_values_entry.id + e.id ) ); @@ -183,53 +183,53 @@ public: static SpawnConditionValues InsertOne( Database& db, - SpawnConditionValues spawn_condition_values_entry + SpawnConditionValues e ) { - std::vector insert_values; + std::vector v; - insert_values.push_back(std::to_string(spawn_condition_values_entry.id)); - insert_values.push_back(std::to_string(spawn_condition_values_entry.value)); - insert_values.push_back("'" + Strings::Escape(spawn_condition_values_entry.zone) + "'"); - insert_values.push_back(std::to_string(spawn_condition_values_entry.instance_id)); + v.push_back(std::to_string(e.id)); + v.push_back(std::to_string(e.value)); + v.push_back("'" + Strings::Escape(e.zone) + "'"); + v.push_back(std::to_string(e.instance_id)); auto results = db.QueryDatabase( fmt::format( "{} VALUES ({})", BaseInsert(), - Strings::Implode(",", insert_values) + Strings::Implode(",", v) ) ); if (results.Success()) { - spawn_condition_values_entry.id = results.LastInsertedID(); - return spawn_condition_values_entry; + e.id = results.LastInsertedID(); + return e; } - spawn_condition_values_entry = NewEntity(); + e = NewEntity(); - return spawn_condition_values_entry; + return e; } static int InsertMany( Database& db, - std::vector spawn_condition_values_entries + const std::vector &entries ) { std::vector insert_chunks; - for (auto &spawn_condition_values_entry: spawn_condition_values_entries) { - std::vector insert_values; + for (auto &e: entries) { + std::vector v; - insert_values.push_back(std::to_string(spawn_condition_values_entry.id)); - insert_values.push_back(std::to_string(spawn_condition_values_entry.value)); - insert_values.push_back("'" + Strings::Escape(spawn_condition_values_entry.zone) + "'"); - insert_values.push_back(std::to_string(spawn_condition_values_entry.instance_id)); + v.push_back(std::to_string(e.id)); + v.push_back(std::to_string(e.value)); + v.push_back("'" + Strings::Escape(e.zone) + "'"); + v.push_back(std::to_string(e.instance_id)); - insert_chunks.push_back("(" + Strings::Implode(",", insert_values) + ")"); + insert_chunks.push_back("(" + Strings::Implode(",", v) + ")"); } - std::vector insert_values; + std::vector v; auto results = db.QueryDatabase( fmt::format( @@ -256,20 +256,20 @@ public: all_entries.reserve(results.RowCount()); for (auto row = results.begin(); row != results.end(); ++row) { - SpawnConditionValues entry{}; + SpawnConditionValues e{}; - entry.id = atoi(row[0]); - entry.value = atoi(row[1]); - entry.zone = row[2] ? row[2] : ""; - entry.instance_id = atoi(row[3]); + e.id = atoi(row[0]); + e.value = atoi(row[1]); + e.zone = row[2] ? row[2] : ""; + e.instance_id = atoi(row[3]); - all_entries.push_back(entry); + all_entries.push_back(e); } return all_entries; } - static std::vector GetWhere(Database& db, std::string where_filter) + static std::vector GetWhere(Database& db, const std::string &where_filter) { std::vector all_entries; @@ -284,20 +284,20 @@ public: all_entries.reserve(results.RowCount()); for (auto row = results.begin(); row != results.end(); ++row) { - SpawnConditionValues entry{}; + SpawnConditionValues e{}; - entry.id = atoi(row[0]); - entry.value = atoi(row[1]); - entry.zone = row[2] ? row[2] : ""; - entry.instance_id = atoi(row[3]); + e.id = atoi(row[0]); + e.value = atoi(row[1]); + e.zone = row[2] ? row[2] : ""; + e.instance_id = atoi(row[3]); - all_entries.push_back(entry); + all_entries.push_back(e); } return all_entries; } - static int DeleteWhere(Database& db, std::string where_filter) + static int DeleteWhere(Database& db, const std::string &where_filter) { auto results = db.QueryDatabase( fmt::format( @@ -322,6 +322,32 @@ public: 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); + } + }; #endif //EQEMU_BASE_SPAWN_CONDITION_VALUES_REPOSITORY_H diff --git a/common/repositories/base/base_spawn_conditions_repository.h b/common/repositories/base/base_spawn_conditions_repository.h index 8d90a7e4c..668dec292 100644 --- a/common/repositories/base/base_spawn_conditions_repository.h +++ b/common/repositories/base/base_spawn_conditions_repository.h @@ -88,18 +88,18 @@ public: static SpawnConditions NewEntity() { - SpawnConditions entry{}; + SpawnConditions e{}; - entry.zone = ""; - entry.id = 1; - entry.value = 0; - entry.onchange = 0; - entry.name = ""; + e.zone = ""; + e.id = 1; + e.value = 0; + e.onchange = 0; + e.name = ""; - return entry; + return e; } - static SpawnConditions GetSpawnConditionsEntry( + static SpawnConditions GetSpawnConditions( const std::vector &spawn_conditionss, int spawn_conditions_id ) @@ -128,15 +128,15 @@ public: auto row = results.begin(); if (results.RowCount() == 1) { - SpawnConditions entry{}; + SpawnConditions e{}; - entry.zone = row[0] ? row[0] : ""; - entry.id = atoi(row[1]); - entry.value = atoi(row[2]); - entry.onchange = atoi(row[3]); - entry.name = row[4] ? row[4] : ""; + e.zone = row[0] ? row[0] : ""; + e.id = atoi(row[1]); + e.value = atoi(row[2]); + e.onchange = atoi(row[3]); + e.name = row[4] ? row[4] : ""; - return entry; + return e; } return NewEntity(); @@ -161,26 +161,26 @@ public: static int UpdateOne( Database& db, - SpawnConditions spawn_conditions_entry + const SpawnConditions &e ) { - std::vector update_values; + std::vector v; auto columns = Columns(); - update_values.push_back(columns[0] + " = '" + Strings::Escape(spawn_conditions_entry.zone) + "'"); - update_values.push_back(columns[1] + " = " + std::to_string(spawn_conditions_entry.id)); - update_values.push_back(columns[2] + " = " + std::to_string(spawn_conditions_entry.value)); - update_values.push_back(columns[3] + " = " + std::to_string(spawn_conditions_entry.onchange)); - update_values.push_back(columns[4] + " = '" + Strings::Escape(spawn_conditions_entry.name) + "'"); + v.push_back(columns[0] + " = '" + Strings::Escape(e.zone) + "'"); + v.push_back(columns[1] + " = " + std::to_string(e.id)); + v.push_back(columns[2] + " = " + std::to_string(e.value)); + v.push_back(columns[3] + " = " + std::to_string(e.onchange)); + v.push_back(columns[4] + " = '" + Strings::Escape(e.name) + "'"); auto results = db.QueryDatabase( fmt::format( "UPDATE {} SET {} WHERE {} = {}", TableName(), - Strings::Implode(", ", update_values), + Strings::Implode(", ", v), PrimaryKey(), - spawn_conditions_entry.id + e.id ) ); @@ -189,55 +189,55 @@ public: static SpawnConditions InsertOne( Database& db, - SpawnConditions spawn_conditions_entry + SpawnConditions e ) { - std::vector insert_values; + std::vector v; - insert_values.push_back("'" + Strings::Escape(spawn_conditions_entry.zone) + "'"); - insert_values.push_back(std::to_string(spawn_conditions_entry.id)); - insert_values.push_back(std::to_string(spawn_conditions_entry.value)); - insert_values.push_back(std::to_string(spawn_conditions_entry.onchange)); - insert_values.push_back("'" + Strings::Escape(spawn_conditions_entry.name) + "'"); + v.push_back("'" + Strings::Escape(e.zone) + "'"); + v.push_back(std::to_string(e.id)); + v.push_back(std::to_string(e.value)); + v.push_back(std::to_string(e.onchange)); + v.push_back("'" + Strings::Escape(e.name) + "'"); auto results = db.QueryDatabase( fmt::format( "{} VALUES ({})", BaseInsert(), - Strings::Implode(",", insert_values) + Strings::Implode(",", v) ) ); if (results.Success()) { - spawn_conditions_entry.id = results.LastInsertedID(); - return spawn_conditions_entry; + e.id = results.LastInsertedID(); + return e; } - spawn_conditions_entry = NewEntity(); + e = NewEntity(); - return spawn_conditions_entry; + return e; } static int InsertMany( Database& db, - std::vector spawn_conditions_entries + const std::vector &entries ) { std::vector insert_chunks; - for (auto &spawn_conditions_entry: spawn_conditions_entries) { - std::vector insert_values; + for (auto &e: entries) { + std::vector v; - insert_values.push_back("'" + Strings::Escape(spawn_conditions_entry.zone) + "'"); - insert_values.push_back(std::to_string(spawn_conditions_entry.id)); - insert_values.push_back(std::to_string(spawn_conditions_entry.value)); - insert_values.push_back(std::to_string(spawn_conditions_entry.onchange)); - insert_values.push_back("'" + Strings::Escape(spawn_conditions_entry.name) + "'"); + v.push_back("'" + Strings::Escape(e.zone) + "'"); + v.push_back(std::to_string(e.id)); + v.push_back(std::to_string(e.value)); + v.push_back(std::to_string(e.onchange)); + v.push_back("'" + Strings::Escape(e.name) + "'"); - insert_chunks.push_back("(" + Strings::Implode(",", insert_values) + ")"); + insert_chunks.push_back("(" + Strings::Implode(",", v) + ")"); } - std::vector insert_values; + std::vector v; auto results = db.QueryDatabase( fmt::format( @@ -264,21 +264,21 @@ public: all_entries.reserve(results.RowCount()); for (auto row = results.begin(); row != results.end(); ++row) { - SpawnConditions entry{}; + SpawnConditions e{}; - entry.zone = row[0] ? row[0] : ""; - entry.id = atoi(row[1]); - entry.value = atoi(row[2]); - entry.onchange = atoi(row[3]); - entry.name = row[4] ? row[4] : ""; + e.zone = row[0] ? row[0] : ""; + e.id = atoi(row[1]); + e.value = atoi(row[2]); + e.onchange = atoi(row[3]); + e.name = row[4] ? row[4] : ""; - all_entries.push_back(entry); + all_entries.push_back(e); } return all_entries; } - static std::vector GetWhere(Database& db, std::string where_filter) + static std::vector GetWhere(Database& db, const std::string &where_filter) { std::vector all_entries; @@ -293,21 +293,21 @@ public: all_entries.reserve(results.RowCount()); for (auto row = results.begin(); row != results.end(); ++row) { - SpawnConditions entry{}; + SpawnConditions e{}; - entry.zone = row[0] ? row[0] : ""; - entry.id = atoi(row[1]); - entry.value = atoi(row[2]); - entry.onchange = atoi(row[3]); - entry.name = row[4] ? row[4] : ""; + e.zone = row[0] ? row[0] : ""; + e.id = atoi(row[1]); + e.value = atoi(row[2]); + e.onchange = atoi(row[3]); + e.name = row[4] ? row[4] : ""; - all_entries.push_back(entry); + all_entries.push_back(e); } return all_entries; } - static int DeleteWhere(Database& db, std::string where_filter) + static int DeleteWhere(Database& db, const std::string &where_filter) { auto results = db.QueryDatabase( fmt::format( @@ -332,6 +332,32 @@ public: 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); + } + }; #endif //EQEMU_BASE_SPAWN_CONDITIONS_REPOSITORY_H diff --git a/common/repositories/base/base_spawn_events_repository.h b/common/repositories/base/base_spawn_events_repository.h index 4404f1008..196f98d55 100644 --- a/common/repositories/base/base_spawn_events_repository.h +++ b/common/repositories/base/base_spawn_events_repository.h @@ -115,27 +115,27 @@ public: static SpawnEvents NewEntity() { - SpawnEvents entry{}; + SpawnEvents e{}; - entry.id = 0; - entry.zone = ""; - entry.cond_id = 0; - entry.name = ""; - entry.period = 0; - entry.next_minute = 0; - entry.next_hour = 0; - entry.next_day = 0; - entry.next_month = 0; - entry.next_year = 0; - entry.enabled = 1; - entry.action = 0; - entry.argument = 0; - entry.strict = 0; + e.id = 0; + e.zone = ""; + e.cond_id = 0; + e.name = ""; + e.period = 0; + e.next_minute = 0; + e.next_hour = 0; + e.next_day = 0; + e.next_month = 0; + e.next_year = 0; + e.enabled = 1; + e.action = 0; + e.argument = 0; + e.strict = 0; - return entry; + return e; } - static SpawnEvents GetSpawnEventsEntry( + static SpawnEvents GetSpawnEvents( const std::vector &spawn_eventss, int spawn_events_id ) @@ -164,24 +164,24 @@ public: auto row = results.begin(); if (results.RowCount() == 1) { - SpawnEvents entry{}; + SpawnEvents e{}; - entry.id = atoi(row[0]); - entry.zone = row[1] ? row[1] : ""; - entry.cond_id = atoi(row[2]); - entry.name = row[3] ? row[3] : ""; - entry.period = atoi(row[4]); - entry.next_minute = atoi(row[5]); - entry.next_hour = atoi(row[6]); - entry.next_day = atoi(row[7]); - entry.next_month = atoi(row[8]); - entry.next_year = atoi(row[9]); - entry.enabled = atoi(row[10]); - entry.action = atoi(row[11]); - entry.argument = atoi(row[12]); - entry.strict = atoi(row[13]); + e.id = atoi(row[0]); + e.zone = row[1] ? row[1] : ""; + e.cond_id = atoi(row[2]); + e.name = row[3] ? row[3] : ""; + e.period = atoi(row[4]); + e.next_minute = atoi(row[5]); + e.next_hour = atoi(row[6]); + e.next_day = atoi(row[7]); + e.next_month = atoi(row[8]); + e.next_year = atoi(row[9]); + e.enabled = atoi(row[10]); + e.action = atoi(row[11]); + e.argument = atoi(row[12]); + e.strict = atoi(row[13]); - return entry; + return e; } return NewEntity(); @@ -206,34 +206,34 @@ public: static int UpdateOne( Database& db, - SpawnEvents spawn_events_entry + const SpawnEvents &e ) { - std::vector update_values; + std::vector v; auto columns = Columns(); - update_values.push_back(columns[1] + " = '" + Strings::Escape(spawn_events_entry.zone) + "'"); - update_values.push_back(columns[2] + " = " + std::to_string(spawn_events_entry.cond_id)); - update_values.push_back(columns[3] + " = '" + Strings::Escape(spawn_events_entry.name) + "'"); - update_values.push_back(columns[4] + " = " + std::to_string(spawn_events_entry.period)); - update_values.push_back(columns[5] + " = " + std::to_string(spawn_events_entry.next_minute)); - update_values.push_back(columns[6] + " = " + std::to_string(spawn_events_entry.next_hour)); - update_values.push_back(columns[7] + " = " + std::to_string(spawn_events_entry.next_day)); - update_values.push_back(columns[8] + " = " + std::to_string(spawn_events_entry.next_month)); - update_values.push_back(columns[9] + " = " + std::to_string(spawn_events_entry.next_year)); - update_values.push_back(columns[10] + " = " + std::to_string(spawn_events_entry.enabled)); - update_values.push_back(columns[11] + " = " + std::to_string(spawn_events_entry.action)); - update_values.push_back(columns[12] + " = " + std::to_string(spawn_events_entry.argument)); - update_values.push_back(columns[13] + " = " + std::to_string(spawn_events_entry.strict)); + v.push_back(columns[1] + " = '" + Strings::Escape(e.zone) + "'"); + v.push_back(columns[2] + " = " + std::to_string(e.cond_id)); + v.push_back(columns[3] + " = '" + Strings::Escape(e.name) + "'"); + v.push_back(columns[4] + " = " + std::to_string(e.period)); + v.push_back(columns[5] + " = " + std::to_string(e.next_minute)); + v.push_back(columns[6] + " = " + std::to_string(e.next_hour)); + v.push_back(columns[7] + " = " + std::to_string(e.next_day)); + v.push_back(columns[8] + " = " + std::to_string(e.next_month)); + v.push_back(columns[9] + " = " + std::to_string(e.next_year)); + v.push_back(columns[10] + " = " + std::to_string(e.enabled)); + v.push_back(columns[11] + " = " + std::to_string(e.action)); + v.push_back(columns[12] + " = " + std::to_string(e.argument)); + v.push_back(columns[13] + " = " + std::to_string(e.strict)); auto results = db.QueryDatabase( fmt::format( "UPDATE {} SET {} WHERE {} = {}", TableName(), - Strings::Implode(", ", update_values), + Strings::Implode(", ", v), PrimaryKey(), - spawn_events_entry.id + e.id ) ); @@ -242,73 +242,73 @@ public: static SpawnEvents InsertOne( Database& db, - SpawnEvents spawn_events_entry + SpawnEvents e ) { - std::vector insert_values; + std::vector v; - insert_values.push_back(std::to_string(spawn_events_entry.id)); - insert_values.push_back("'" + Strings::Escape(spawn_events_entry.zone) + "'"); - insert_values.push_back(std::to_string(spawn_events_entry.cond_id)); - insert_values.push_back("'" + Strings::Escape(spawn_events_entry.name) + "'"); - insert_values.push_back(std::to_string(spawn_events_entry.period)); - insert_values.push_back(std::to_string(spawn_events_entry.next_minute)); - insert_values.push_back(std::to_string(spawn_events_entry.next_hour)); - insert_values.push_back(std::to_string(spawn_events_entry.next_day)); - insert_values.push_back(std::to_string(spawn_events_entry.next_month)); - insert_values.push_back(std::to_string(spawn_events_entry.next_year)); - insert_values.push_back(std::to_string(spawn_events_entry.enabled)); - insert_values.push_back(std::to_string(spawn_events_entry.action)); - insert_values.push_back(std::to_string(spawn_events_entry.argument)); - insert_values.push_back(std::to_string(spawn_events_entry.strict)); + v.push_back(std::to_string(e.id)); + v.push_back("'" + Strings::Escape(e.zone) + "'"); + v.push_back(std::to_string(e.cond_id)); + v.push_back("'" + Strings::Escape(e.name) + "'"); + v.push_back(std::to_string(e.period)); + v.push_back(std::to_string(e.next_minute)); + v.push_back(std::to_string(e.next_hour)); + v.push_back(std::to_string(e.next_day)); + v.push_back(std::to_string(e.next_month)); + v.push_back(std::to_string(e.next_year)); + v.push_back(std::to_string(e.enabled)); + v.push_back(std::to_string(e.action)); + v.push_back(std::to_string(e.argument)); + v.push_back(std::to_string(e.strict)); auto results = db.QueryDatabase( fmt::format( "{} VALUES ({})", BaseInsert(), - Strings::Implode(",", insert_values) + Strings::Implode(",", v) ) ); if (results.Success()) { - spawn_events_entry.id = results.LastInsertedID(); - return spawn_events_entry; + e.id = results.LastInsertedID(); + return e; } - spawn_events_entry = NewEntity(); + e = NewEntity(); - return spawn_events_entry; + return e; } static int InsertMany( Database& db, - std::vector spawn_events_entries + const std::vector &entries ) { std::vector insert_chunks; - for (auto &spawn_events_entry: spawn_events_entries) { - std::vector insert_values; + for (auto &e: entries) { + std::vector v; - insert_values.push_back(std::to_string(spawn_events_entry.id)); - insert_values.push_back("'" + Strings::Escape(spawn_events_entry.zone) + "'"); - insert_values.push_back(std::to_string(spawn_events_entry.cond_id)); - insert_values.push_back("'" + Strings::Escape(spawn_events_entry.name) + "'"); - insert_values.push_back(std::to_string(spawn_events_entry.period)); - insert_values.push_back(std::to_string(spawn_events_entry.next_minute)); - insert_values.push_back(std::to_string(spawn_events_entry.next_hour)); - insert_values.push_back(std::to_string(spawn_events_entry.next_day)); - insert_values.push_back(std::to_string(spawn_events_entry.next_month)); - insert_values.push_back(std::to_string(spawn_events_entry.next_year)); - insert_values.push_back(std::to_string(spawn_events_entry.enabled)); - insert_values.push_back(std::to_string(spawn_events_entry.action)); - insert_values.push_back(std::to_string(spawn_events_entry.argument)); - insert_values.push_back(std::to_string(spawn_events_entry.strict)); + v.push_back(std::to_string(e.id)); + v.push_back("'" + Strings::Escape(e.zone) + "'"); + v.push_back(std::to_string(e.cond_id)); + v.push_back("'" + Strings::Escape(e.name) + "'"); + v.push_back(std::to_string(e.period)); + v.push_back(std::to_string(e.next_minute)); + v.push_back(std::to_string(e.next_hour)); + v.push_back(std::to_string(e.next_day)); + v.push_back(std::to_string(e.next_month)); + v.push_back(std::to_string(e.next_year)); + v.push_back(std::to_string(e.enabled)); + v.push_back(std::to_string(e.action)); + v.push_back(std::to_string(e.argument)); + v.push_back(std::to_string(e.strict)); - insert_chunks.push_back("(" + Strings::Implode(",", insert_values) + ")"); + insert_chunks.push_back("(" + Strings::Implode(",", v) + ")"); } - std::vector insert_values; + std::vector v; auto results = db.QueryDatabase( fmt::format( @@ -335,30 +335,30 @@ public: all_entries.reserve(results.RowCount()); for (auto row = results.begin(); row != results.end(); ++row) { - SpawnEvents entry{}; + SpawnEvents e{}; - entry.id = atoi(row[0]); - entry.zone = row[1] ? row[1] : ""; - entry.cond_id = atoi(row[2]); - entry.name = row[3] ? row[3] : ""; - entry.period = atoi(row[4]); - entry.next_minute = atoi(row[5]); - entry.next_hour = atoi(row[6]); - entry.next_day = atoi(row[7]); - entry.next_month = atoi(row[8]); - entry.next_year = atoi(row[9]); - entry.enabled = atoi(row[10]); - entry.action = atoi(row[11]); - entry.argument = atoi(row[12]); - entry.strict = atoi(row[13]); + e.id = atoi(row[0]); + e.zone = row[1] ? row[1] : ""; + e.cond_id = atoi(row[2]); + e.name = row[3] ? row[3] : ""; + e.period = atoi(row[4]); + e.next_minute = atoi(row[5]); + e.next_hour = atoi(row[6]); + e.next_day = atoi(row[7]); + e.next_month = atoi(row[8]); + e.next_year = atoi(row[9]); + e.enabled = atoi(row[10]); + e.action = atoi(row[11]); + e.argument = atoi(row[12]); + e.strict = atoi(row[13]); - all_entries.push_back(entry); + all_entries.push_back(e); } return all_entries; } - static std::vector GetWhere(Database& db, std::string where_filter) + static std::vector GetWhere(Database& db, const std::string &where_filter) { std::vector all_entries; @@ -373,30 +373,30 @@ public: all_entries.reserve(results.RowCount()); for (auto row = results.begin(); row != results.end(); ++row) { - SpawnEvents entry{}; + SpawnEvents e{}; - entry.id = atoi(row[0]); - entry.zone = row[1] ? row[1] : ""; - entry.cond_id = atoi(row[2]); - entry.name = row[3] ? row[3] : ""; - entry.period = atoi(row[4]); - entry.next_minute = atoi(row[5]); - entry.next_hour = atoi(row[6]); - entry.next_day = atoi(row[7]); - entry.next_month = atoi(row[8]); - entry.next_year = atoi(row[9]); - entry.enabled = atoi(row[10]); - entry.action = atoi(row[11]); - entry.argument = atoi(row[12]); - entry.strict = atoi(row[13]); + e.id = atoi(row[0]); + e.zone = row[1] ? row[1] : ""; + e.cond_id = atoi(row[2]); + e.name = row[3] ? row[3] : ""; + e.period = atoi(row[4]); + e.next_minute = atoi(row[5]); + e.next_hour = atoi(row[6]); + e.next_day = atoi(row[7]); + e.next_month = atoi(row[8]); + e.next_year = atoi(row[9]); + e.enabled = atoi(row[10]); + e.action = atoi(row[11]); + e.argument = atoi(row[12]); + e.strict = atoi(row[13]); - all_entries.push_back(entry); + all_entries.push_back(e); } return all_entries; } - static int DeleteWhere(Database& db, std::string where_filter) + static int DeleteWhere(Database& db, const std::string &where_filter) { auto results = db.QueryDatabase( fmt::format( @@ -421,6 +421,32 @@ public: 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); + } + }; #endif //EQEMU_BASE_SPAWN_EVENTS_REPOSITORY_H diff --git a/common/repositories/base/base_spawnentry_repository.h b/common/repositories/base/base_spawnentry_repository.h index dfa0cdadd..1fc95e4e7 100644 --- a/common/repositories/base/base_spawnentry_repository.h +++ b/common/repositories/base/base_spawnentry_repository.h @@ -97,21 +97,21 @@ public: static Spawnentry NewEntity() { - Spawnentry entry{}; + Spawnentry e{}; - entry.spawngroupID = 0; - entry.npcID = 0; - entry.chance = 0; - entry.condition_value_filter = 1; - entry.min_expansion = -1; - entry.max_expansion = -1; - entry.content_flags = ""; - entry.content_flags_disabled = ""; + e.spawngroupID = 0; + e.npcID = 0; + e.chance = 0; + e.condition_value_filter = 1; + e.min_expansion = -1; + e.max_expansion = -1; + e.content_flags = ""; + e.content_flags_disabled = ""; - return entry; + return e; } - static Spawnentry GetSpawnentryEntry( + static Spawnentry GetSpawnentry( const std::vector &spawnentrys, int spawnentry_id ) @@ -140,18 +140,18 @@ public: auto row = results.begin(); if (results.RowCount() == 1) { - Spawnentry entry{}; + Spawnentry e{}; - entry.spawngroupID = atoi(row[0]); - entry.npcID = atoi(row[1]); - entry.chance = atoi(row[2]); - entry.condition_value_filter = atoi(row[3]); - entry.min_expansion = atoi(row[4]); - entry.max_expansion = atoi(row[5]); - entry.content_flags = row[6] ? row[6] : ""; - entry.content_flags_disabled = row[7] ? row[7] : ""; + e.spawngroupID = atoi(row[0]); + e.npcID = atoi(row[1]); + e.chance = atoi(row[2]); + e.condition_value_filter = atoi(row[3]); + e.min_expansion = atoi(row[4]); + e.max_expansion = atoi(row[5]); + e.content_flags = row[6] ? row[6] : ""; + e.content_flags_disabled = row[7] ? row[7] : ""; - return entry; + return e; } return NewEntity(); @@ -176,29 +176,29 @@ public: static int UpdateOne( Database& db, - Spawnentry spawnentry_entry + const Spawnentry &e ) { - std::vector update_values; + std::vector v; auto columns = Columns(); - update_values.push_back(columns[0] + " = " + std::to_string(spawnentry_entry.spawngroupID)); - update_values.push_back(columns[1] + " = " + std::to_string(spawnentry_entry.npcID)); - update_values.push_back(columns[2] + " = " + std::to_string(spawnentry_entry.chance)); - update_values.push_back(columns[3] + " = " + std::to_string(spawnentry_entry.condition_value_filter)); - update_values.push_back(columns[4] + " = " + std::to_string(spawnentry_entry.min_expansion)); - update_values.push_back(columns[5] + " = " + std::to_string(spawnentry_entry.max_expansion)); - update_values.push_back(columns[6] + " = '" + Strings::Escape(spawnentry_entry.content_flags) + "'"); - update_values.push_back(columns[7] + " = '" + Strings::Escape(spawnentry_entry.content_flags_disabled) + "'"); + v.push_back(columns[0] + " = " + std::to_string(e.spawngroupID)); + v.push_back(columns[1] + " = " + std::to_string(e.npcID)); + v.push_back(columns[2] + " = " + std::to_string(e.chance)); + v.push_back(columns[3] + " = " + std::to_string(e.condition_value_filter)); + v.push_back(columns[4] + " = " + std::to_string(e.min_expansion)); + v.push_back(columns[5] + " = " + std::to_string(e.max_expansion)); + v.push_back(columns[6] + " = '" + Strings::Escape(e.content_flags) + "'"); + v.push_back(columns[7] + " = '" + Strings::Escape(e.content_flags_disabled) + "'"); auto results = db.QueryDatabase( fmt::format( "UPDATE {} SET {} WHERE {} = {}", TableName(), - Strings::Implode(", ", update_values), + Strings::Implode(", ", v), PrimaryKey(), - spawnentry_entry.spawngroupID + e.spawngroupID ) ); @@ -207,61 +207,61 @@ public: static Spawnentry InsertOne( Database& db, - Spawnentry spawnentry_entry + Spawnentry e ) { - std::vector insert_values; + std::vector v; - insert_values.push_back(std::to_string(spawnentry_entry.spawngroupID)); - insert_values.push_back(std::to_string(spawnentry_entry.npcID)); - insert_values.push_back(std::to_string(spawnentry_entry.chance)); - insert_values.push_back(std::to_string(spawnentry_entry.condition_value_filter)); - insert_values.push_back(std::to_string(spawnentry_entry.min_expansion)); - insert_values.push_back(std::to_string(spawnentry_entry.max_expansion)); - insert_values.push_back("'" + Strings::Escape(spawnentry_entry.content_flags) + "'"); - insert_values.push_back("'" + Strings::Escape(spawnentry_entry.content_flags_disabled) + "'"); + v.push_back(std::to_string(e.spawngroupID)); + v.push_back(std::to_string(e.npcID)); + v.push_back(std::to_string(e.chance)); + v.push_back(std::to_string(e.condition_value_filter)); + v.push_back(std::to_string(e.min_expansion)); + v.push_back(std::to_string(e.max_expansion)); + v.push_back("'" + Strings::Escape(e.content_flags) + "'"); + v.push_back("'" + Strings::Escape(e.content_flags_disabled) + "'"); auto results = db.QueryDatabase( fmt::format( "{} VALUES ({})", BaseInsert(), - Strings::Implode(",", insert_values) + Strings::Implode(",", v) ) ); if (results.Success()) { - spawnentry_entry.spawngroupID = results.LastInsertedID(); - return spawnentry_entry; + e.spawngroupID = results.LastInsertedID(); + return e; } - spawnentry_entry = NewEntity(); + e = NewEntity(); - return spawnentry_entry; + return e; } static int InsertMany( Database& db, - std::vector spawnentry_entries + const std::vector &entries ) { std::vector insert_chunks; - for (auto &spawnentry_entry: spawnentry_entries) { - std::vector insert_values; + for (auto &e: entries) { + std::vector v; - insert_values.push_back(std::to_string(spawnentry_entry.spawngroupID)); - insert_values.push_back(std::to_string(spawnentry_entry.npcID)); - insert_values.push_back(std::to_string(spawnentry_entry.chance)); - insert_values.push_back(std::to_string(spawnentry_entry.condition_value_filter)); - insert_values.push_back(std::to_string(spawnentry_entry.min_expansion)); - insert_values.push_back(std::to_string(spawnentry_entry.max_expansion)); - insert_values.push_back("'" + Strings::Escape(spawnentry_entry.content_flags) + "'"); - insert_values.push_back("'" + Strings::Escape(spawnentry_entry.content_flags_disabled) + "'"); + v.push_back(std::to_string(e.spawngroupID)); + v.push_back(std::to_string(e.npcID)); + v.push_back(std::to_string(e.chance)); + v.push_back(std::to_string(e.condition_value_filter)); + v.push_back(std::to_string(e.min_expansion)); + v.push_back(std::to_string(e.max_expansion)); + v.push_back("'" + Strings::Escape(e.content_flags) + "'"); + v.push_back("'" + Strings::Escape(e.content_flags_disabled) + "'"); - insert_chunks.push_back("(" + Strings::Implode(",", insert_values) + ")"); + insert_chunks.push_back("(" + Strings::Implode(",", v) + ")"); } - std::vector insert_values; + std::vector v; auto results = db.QueryDatabase( fmt::format( @@ -288,24 +288,24 @@ public: all_entries.reserve(results.RowCount()); for (auto row = results.begin(); row != results.end(); ++row) { - Spawnentry entry{}; + Spawnentry e{}; - entry.spawngroupID = atoi(row[0]); - entry.npcID = atoi(row[1]); - entry.chance = atoi(row[2]); - entry.condition_value_filter = atoi(row[3]); - entry.min_expansion = atoi(row[4]); - entry.max_expansion = atoi(row[5]); - entry.content_flags = row[6] ? row[6] : ""; - entry.content_flags_disabled = row[7] ? row[7] : ""; + e.spawngroupID = atoi(row[0]); + e.npcID = atoi(row[1]); + e.chance = atoi(row[2]); + e.condition_value_filter = atoi(row[3]); + e.min_expansion = atoi(row[4]); + e.max_expansion = atoi(row[5]); + e.content_flags = row[6] ? row[6] : ""; + e.content_flags_disabled = row[7] ? row[7] : ""; - all_entries.push_back(entry); + all_entries.push_back(e); } return all_entries; } - static std::vector GetWhere(Database& db, std::string where_filter) + static std::vector GetWhere(Database& db, const std::string &where_filter) { std::vector all_entries; @@ -320,24 +320,24 @@ public: all_entries.reserve(results.RowCount()); for (auto row = results.begin(); row != results.end(); ++row) { - Spawnentry entry{}; + Spawnentry e{}; - entry.spawngroupID = atoi(row[0]); - entry.npcID = atoi(row[1]); - entry.chance = atoi(row[2]); - entry.condition_value_filter = atoi(row[3]); - entry.min_expansion = atoi(row[4]); - entry.max_expansion = atoi(row[5]); - entry.content_flags = row[6] ? row[6] : ""; - entry.content_flags_disabled = row[7] ? row[7] : ""; + e.spawngroupID = atoi(row[0]); + e.npcID = atoi(row[1]); + e.chance = atoi(row[2]); + e.condition_value_filter = atoi(row[3]); + e.min_expansion = atoi(row[4]); + e.max_expansion = atoi(row[5]); + e.content_flags = row[6] ? row[6] : ""; + e.content_flags_disabled = row[7] ? row[7] : ""; - all_entries.push_back(entry); + all_entries.push_back(e); } return all_entries; } - static int DeleteWhere(Database& db, std::string where_filter) + static int DeleteWhere(Database& db, const std::string &where_filter) { auto results = db.QueryDatabase( fmt::format( @@ -362,6 +362,32 @@ public: 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); + } + }; #endif //EQEMU_BASE_SPAWNENTRY_REPOSITORY_H diff --git a/common/repositories/base/base_spawngroup_repository.h b/common/repositories/base/base_spawngroup_repository.h index 74a94f531..3194108ea 100644 --- a/common/repositories/base/base_spawngroup_repository.h +++ b/common/repositories/base/base_spawngroup_repository.h @@ -112,26 +112,26 @@ public: static Spawngroup NewEntity() { - Spawngroup entry{}; + Spawngroup e{}; - entry.id = 0; - entry.name = ""; - entry.spawn_limit = 0; - entry.dist = 0; - entry.max_x = 0; - entry.min_x = 0; - entry.max_y = 0; - entry.min_y = 0; - entry.delay = 45000; - entry.mindelay = 15000; - entry.despawn = 0; - entry.despawn_timer = 100; - entry.wp_spawns = 0; + e.id = 0; + e.name = ""; + e.spawn_limit = 0; + e.dist = 0; + e.max_x = 0; + e.min_x = 0; + e.max_y = 0; + e.min_y = 0; + e.delay = 45000; + e.mindelay = 15000; + e.despawn = 0; + e.despawn_timer = 100; + e.wp_spawns = 0; - return entry; + return e; } - static Spawngroup GetSpawngroupEntry( + static Spawngroup GetSpawngroup( const std::vector &spawngroups, int spawngroup_id ) @@ -160,23 +160,23 @@ public: auto row = results.begin(); if (results.RowCount() == 1) { - Spawngroup entry{}; + Spawngroup e{}; - entry.id = atoi(row[0]); - entry.name = row[1] ? row[1] : ""; - entry.spawn_limit = atoi(row[2]); - entry.dist = static_cast(atof(row[3])); - entry.max_x = static_cast(atof(row[4])); - entry.min_x = static_cast(atof(row[5])); - entry.max_y = static_cast(atof(row[6])); - entry.min_y = static_cast(atof(row[7])); - entry.delay = atoi(row[8]); - entry.mindelay = atoi(row[9]); - entry.despawn = atoi(row[10]); - entry.despawn_timer = atoi(row[11]); - entry.wp_spawns = atoi(row[12]); + e.id = atoi(row[0]); + e.name = row[1] ? row[1] : ""; + e.spawn_limit = atoi(row[2]); + e.dist = static_cast(atof(row[3])); + e.max_x = static_cast(atof(row[4])); + e.min_x = static_cast(atof(row[5])); + e.max_y = static_cast(atof(row[6])); + e.min_y = static_cast(atof(row[7])); + e.delay = atoi(row[8]); + e.mindelay = atoi(row[9]); + e.despawn = atoi(row[10]); + e.despawn_timer = atoi(row[11]); + e.wp_spawns = atoi(row[12]); - return entry; + return e; } return NewEntity(); @@ -201,33 +201,33 @@ public: static int UpdateOne( Database& db, - Spawngroup spawngroup_entry + const Spawngroup &e ) { - std::vector update_values; + std::vector v; auto columns = Columns(); - update_values.push_back(columns[1] + " = '" + Strings::Escape(spawngroup_entry.name) + "'"); - update_values.push_back(columns[2] + " = " + std::to_string(spawngroup_entry.spawn_limit)); - update_values.push_back(columns[3] + " = " + std::to_string(spawngroup_entry.dist)); - update_values.push_back(columns[4] + " = " + std::to_string(spawngroup_entry.max_x)); - update_values.push_back(columns[5] + " = " + std::to_string(spawngroup_entry.min_x)); - update_values.push_back(columns[6] + " = " + std::to_string(spawngroup_entry.max_y)); - update_values.push_back(columns[7] + " = " + std::to_string(spawngroup_entry.min_y)); - update_values.push_back(columns[8] + " = " + std::to_string(spawngroup_entry.delay)); - update_values.push_back(columns[9] + " = " + std::to_string(spawngroup_entry.mindelay)); - update_values.push_back(columns[10] + " = " + std::to_string(spawngroup_entry.despawn)); - update_values.push_back(columns[11] + " = " + std::to_string(spawngroup_entry.despawn_timer)); - update_values.push_back(columns[12] + " = " + std::to_string(spawngroup_entry.wp_spawns)); + v.push_back(columns[1] + " = '" + Strings::Escape(e.name) + "'"); + v.push_back(columns[2] + " = " + std::to_string(e.spawn_limit)); + v.push_back(columns[3] + " = " + std::to_string(e.dist)); + v.push_back(columns[4] + " = " + std::to_string(e.max_x)); + v.push_back(columns[5] + " = " + std::to_string(e.min_x)); + v.push_back(columns[6] + " = " + std::to_string(e.max_y)); + v.push_back(columns[7] + " = " + std::to_string(e.min_y)); + v.push_back(columns[8] + " = " + std::to_string(e.delay)); + v.push_back(columns[9] + " = " + std::to_string(e.mindelay)); + v.push_back(columns[10] + " = " + std::to_string(e.despawn)); + v.push_back(columns[11] + " = " + std::to_string(e.despawn_timer)); + v.push_back(columns[12] + " = " + std::to_string(e.wp_spawns)); auto results = db.QueryDatabase( fmt::format( "UPDATE {} SET {} WHERE {} = {}", TableName(), - Strings::Implode(", ", update_values), + Strings::Implode(", ", v), PrimaryKey(), - spawngroup_entry.id + e.id ) ); @@ -236,71 +236,71 @@ public: static Spawngroup InsertOne( Database& db, - Spawngroup spawngroup_entry + Spawngroup e ) { - std::vector insert_values; + std::vector v; - insert_values.push_back(std::to_string(spawngroup_entry.id)); - insert_values.push_back("'" + Strings::Escape(spawngroup_entry.name) + "'"); - insert_values.push_back(std::to_string(spawngroup_entry.spawn_limit)); - insert_values.push_back(std::to_string(spawngroup_entry.dist)); - insert_values.push_back(std::to_string(spawngroup_entry.max_x)); - insert_values.push_back(std::to_string(spawngroup_entry.min_x)); - insert_values.push_back(std::to_string(spawngroup_entry.max_y)); - insert_values.push_back(std::to_string(spawngroup_entry.min_y)); - insert_values.push_back(std::to_string(spawngroup_entry.delay)); - insert_values.push_back(std::to_string(spawngroup_entry.mindelay)); - insert_values.push_back(std::to_string(spawngroup_entry.despawn)); - insert_values.push_back(std::to_string(spawngroup_entry.despawn_timer)); - insert_values.push_back(std::to_string(spawngroup_entry.wp_spawns)); + v.push_back(std::to_string(e.id)); + v.push_back("'" + Strings::Escape(e.name) + "'"); + v.push_back(std::to_string(e.spawn_limit)); + v.push_back(std::to_string(e.dist)); + v.push_back(std::to_string(e.max_x)); + v.push_back(std::to_string(e.min_x)); + v.push_back(std::to_string(e.max_y)); + v.push_back(std::to_string(e.min_y)); + v.push_back(std::to_string(e.delay)); + v.push_back(std::to_string(e.mindelay)); + v.push_back(std::to_string(e.despawn)); + v.push_back(std::to_string(e.despawn_timer)); + v.push_back(std::to_string(e.wp_spawns)); auto results = db.QueryDatabase( fmt::format( "{} VALUES ({})", BaseInsert(), - Strings::Implode(",", insert_values) + Strings::Implode(",", v) ) ); if (results.Success()) { - spawngroup_entry.id = results.LastInsertedID(); - return spawngroup_entry; + e.id = results.LastInsertedID(); + return e; } - spawngroup_entry = NewEntity(); + e = NewEntity(); - return spawngroup_entry; + return e; } static int InsertMany( Database& db, - std::vector spawngroup_entries + const std::vector &entries ) { std::vector insert_chunks; - for (auto &spawngroup_entry: spawngroup_entries) { - std::vector insert_values; + for (auto &e: entries) { + std::vector v; - insert_values.push_back(std::to_string(spawngroup_entry.id)); - insert_values.push_back("'" + Strings::Escape(spawngroup_entry.name) + "'"); - insert_values.push_back(std::to_string(spawngroup_entry.spawn_limit)); - insert_values.push_back(std::to_string(spawngroup_entry.dist)); - insert_values.push_back(std::to_string(spawngroup_entry.max_x)); - insert_values.push_back(std::to_string(spawngroup_entry.min_x)); - insert_values.push_back(std::to_string(spawngroup_entry.max_y)); - insert_values.push_back(std::to_string(spawngroup_entry.min_y)); - insert_values.push_back(std::to_string(spawngroup_entry.delay)); - insert_values.push_back(std::to_string(spawngroup_entry.mindelay)); - insert_values.push_back(std::to_string(spawngroup_entry.despawn)); - insert_values.push_back(std::to_string(spawngroup_entry.despawn_timer)); - insert_values.push_back(std::to_string(spawngroup_entry.wp_spawns)); + v.push_back(std::to_string(e.id)); + v.push_back("'" + Strings::Escape(e.name) + "'"); + v.push_back(std::to_string(e.spawn_limit)); + v.push_back(std::to_string(e.dist)); + v.push_back(std::to_string(e.max_x)); + v.push_back(std::to_string(e.min_x)); + v.push_back(std::to_string(e.max_y)); + v.push_back(std::to_string(e.min_y)); + v.push_back(std::to_string(e.delay)); + v.push_back(std::to_string(e.mindelay)); + v.push_back(std::to_string(e.despawn)); + v.push_back(std::to_string(e.despawn_timer)); + v.push_back(std::to_string(e.wp_spawns)); - insert_chunks.push_back("(" + Strings::Implode(",", insert_values) + ")"); + insert_chunks.push_back("(" + Strings::Implode(",", v) + ")"); } - std::vector insert_values; + std::vector v; auto results = db.QueryDatabase( fmt::format( @@ -327,29 +327,29 @@ public: all_entries.reserve(results.RowCount()); for (auto row = results.begin(); row != results.end(); ++row) { - Spawngroup entry{}; + Spawngroup e{}; - entry.id = atoi(row[0]); - entry.name = row[1] ? row[1] : ""; - entry.spawn_limit = atoi(row[2]); - entry.dist = static_cast(atof(row[3])); - entry.max_x = static_cast(atof(row[4])); - entry.min_x = static_cast(atof(row[5])); - entry.max_y = static_cast(atof(row[6])); - entry.min_y = static_cast(atof(row[7])); - entry.delay = atoi(row[8]); - entry.mindelay = atoi(row[9]); - entry.despawn = atoi(row[10]); - entry.despawn_timer = atoi(row[11]); - entry.wp_spawns = atoi(row[12]); + e.id = atoi(row[0]); + e.name = row[1] ? row[1] : ""; + e.spawn_limit = atoi(row[2]); + e.dist = static_cast(atof(row[3])); + e.max_x = static_cast(atof(row[4])); + e.min_x = static_cast(atof(row[5])); + e.max_y = static_cast(atof(row[6])); + e.min_y = static_cast(atof(row[7])); + e.delay = atoi(row[8]); + e.mindelay = atoi(row[9]); + e.despawn = atoi(row[10]); + e.despawn_timer = atoi(row[11]); + e.wp_spawns = atoi(row[12]); - all_entries.push_back(entry); + all_entries.push_back(e); } return all_entries; } - static std::vector GetWhere(Database& db, std::string where_filter) + static std::vector GetWhere(Database& db, const std::string &where_filter) { std::vector all_entries; @@ -364,29 +364,29 @@ public: all_entries.reserve(results.RowCount()); for (auto row = results.begin(); row != results.end(); ++row) { - Spawngroup entry{}; + Spawngroup e{}; - entry.id = atoi(row[0]); - entry.name = row[1] ? row[1] : ""; - entry.spawn_limit = atoi(row[2]); - entry.dist = static_cast(atof(row[3])); - entry.max_x = static_cast(atof(row[4])); - entry.min_x = static_cast(atof(row[5])); - entry.max_y = static_cast(atof(row[6])); - entry.min_y = static_cast(atof(row[7])); - entry.delay = atoi(row[8]); - entry.mindelay = atoi(row[9]); - entry.despawn = atoi(row[10]); - entry.despawn_timer = atoi(row[11]); - entry.wp_spawns = atoi(row[12]); + e.id = atoi(row[0]); + e.name = row[1] ? row[1] : ""; + e.spawn_limit = atoi(row[2]); + e.dist = static_cast(atof(row[3])); + e.max_x = static_cast(atof(row[4])); + e.min_x = static_cast(atof(row[5])); + e.max_y = static_cast(atof(row[6])); + e.min_y = static_cast(atof(row[7])); + e.delay = atoi(row[8]); + e.mindelay = atoi(row[9]); + e.despawn = atoi(row[10]); + e.despawn_timer = atoi(row[11]); + e.wp_spawns = atoi(row[12]); - all_entries.push_back(entry); + all_entries.push_back(e); } return all_entries; } - static int DeleteWhere(Database& db, std::string where_filter) + static int DeleteWhere(Database& db, const std::string &where_filter) { auto results = db.QueryDatabase( fmt::format( @@ -411,6 +411,32 @@ public: 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); + } + }; #endif //EQEMU_BASE_SPAWNGROUP_REPOSITORY_H diff --git a/common/repositories/base/base_spell_buckets_repository.h b/common/repositories/base/base_spell_buckets_repository.h index 360b266c2..994156024 100644 --- a/common/repositories/base/base_spell_buckets_repository.h +++ b/common/repositories/base/base_spell_buckets_repository.h @@ -82,16 +82,16 @@ public: static SpellBuckets NewEntity() { - SpellBuckets entry{}; + SpellBuckets e{}; - entry.spellid = 0; - entry.key = ""; - entry.value = ""; + e.spellid = 0; + e.key = ""; + e.value = ""; - return entry; + return e; } - static SpellBuckets GetSpellBucketsEntry( + static SpellBuckets GetSpellBuckets( const std::vector &spell_bucketss, int spell_buckets_id ) @@ -120,13 +120,13 @@ public: auto row = results.begin(); if (results.RowCount() == 1) { - SpellBuckets entry{}; + SpellBuckets e{}; - entry.spellid = strtoll(row[0], nullptr, 10); - entry.key = row[1] ? row[1] : ""; - entry.value = row[2] ? row[2] : ""; + e.spellid = strtoll(row[0], nullptr, 10); + e.key = row[1] ? row[1] : ""; + e.value = row[2] ? row[2] : ""; - return entry; + return e; } return NewEntity(); @@ -151,24 +151,24 @@ public: static int UpdateOne( Database& db, - SpellBuckets spell_buckets_entry + const SpellBuckets &e ) { - std::vector update_values; + std::vector v; auto columns = Columns(); - update_values.push_back(columns[0] + " = " + std::to_string(spell_buckets_entry.spellid)); - update_values.push_back(columns[1] + " = '" + Strings::Escape(spell_buckets_entry.key) + "'"); - update_values.push_back(columns[2] + " = '" + Strings::Escape(spell_buckets_entry.value) + "'"); + v.push_back(columns[0] + " = " + std::to_string(e.spellid)); + v.push_back(columns[1] + " = '" + Strings::Escape(e.key) + "'"); + v.push_back(columns[2] + " = '" + Strings::Escape(e.value) + "'"); auto results = db.QueryDatabase( fmt::format( "UPDATE {} SET {} WHERE {} = {}", TableName(), - Strings::Implode(", ", update_values), + Strings::Implode(", ", v), PrimaryKey(), - spell_buckets_entry.spellid + e.spellid ) ); @@ -177,51 +177,51 @@ public: static SpellBuckets InsertOne( Database& db, - SpellBuckets spell_buckets_entry + SpellBuckets e ) { - std::vector insert_values; + std::vector v; - insert_values.push_back(std::to_string(spell_buckets_entry.spellid)); - insert_values.push_back("'" + Strings::Escape(spell_buckets_entry.key) + "'"); - insert_values.push_back("'" + Strings::Escape(spell_buckets_entry.value) + "'"); + v.push_back(std::to_string(e.spellid)); + v.push_back("'" + Strings::Escape(e.key) + "'"); + v.push_back("'" + Strings::Escape(e.value) + "'"); auto results = db.QueryDatabase( fmt::format( "{} VALUES ({})", BaseInsert(), - Strings::Implode(",", insert_values) + Strings::Implode(",", v) ) ); if (results.Success()) { - spell_buckets_entry.spellid = results.LastInsertedID(); - return spell_buckets_entry; + e.spellid = results.LastInsertedID(); + return e; } - spell_buckets_entry = NewEntity(); + e = NewEntity(); - return spell_buckets_entry; + return e; } static int InsertMany( Database& db, - std::vector spell_buckets_entries + const std::vector &entries ) { std::vector insert_chunks; - for (auto &spell_buckets_entry: spell_buckets_entries) { - std::vector insert_values; + for (auto &e: entries) { + std::vector v; - insert_values.push_back(std::to_string(spell_buckets_entry.spellid)); - insert_values.push_back("'" + Strings::Escape(spell_buckets_entry.key) + "'"); - insert_values.push_back("'" + Strings::Escape(spell_buckets_entry.value) + "'"); + v.push_back(std::to_string(e.spellid)); + v.push_back("'" + Strings::Escape(e.key) + "'"); + v.push_back("'" + Strings::Escape(e.value) + "'"); - insert_chunks.push_back("(" + Strings::Implode(",", insert_values) + ")"); + insert_chunks.push_back("(" + Strings::Implode(",", v) + ")"); } - std::vector insert_values; + std::vector v; auto results = db.QueryDatabase( fmt::format( @@ -248,19 +248,19 @@ public: all_entries.reserve(results.RowCount()); for (auto row = results.begin(); row != results.end(); ++row) { - SpellBuckets entry{}; + SpellBuckets e{}; - entry.spellid = strtoll(row[0], nullptr, 10); - entry.key = row[1] ? row[1] : ""; - entry.value = row[2] ? row[2] : ""; + e.spellid = strtoll(row[0], nullptr, 10); + e.key = row[1] ? row[1] : ""; + e.value = row[2] ? row[2] : ""; - all_entries.push_back(entry); + all_entries.push_back(e); } return all_entries; } - static std::vector GetWhere(Database& db, std::string where_filter) + static std::vector GetWhere(Database& db, const std::string &where_filter) { std::vector all_entries; @@ -275,19 +275,19 @@ public: all_entries.reserve(results.RowCount()); for (auto row = results.begin(); row != results.end(); ++row) { - SpellBuckets entry{}; + SpellBuckets e{}; - entry.spellid = strtoll(row[0], nullptr, 10); - entry.key = row[1] ? row[1] : ""; - entry.value = row[2] ? row[2] : ""; + e.spellid = strtoll(row[0], nullptr, 10); + e.key = row[1] ? row[1] : ""; + e.value = row[2] ? row[2] : ""; - all_entries.push_back(entry); + all_entries.push_back(e); } return all_entries; } - static int DeleteWhere(Database& db, std::string where_filter) + static int DeleteWhere(Database& db, const std::string &where_filter) { auto results = db.QueryDatabase( fmt::format( @@ -312,6 +312,32 @@ public: 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); + } + }; #endif //EQEMU_BASE_SPELL_BUCKETS_REPOSITORY_H diff --git a/common/repositories/base/base_spell_globals_repository.h b/common/repositories/base/base_spell_globals_repository.h index 1bd274bf2..5803d5bd3 100644 --- a/common/repositories/base/base_spell_globals_repository.h +++ b/common/repositories/base/base_spell_globals_repository.h @@ -85,17 +85,17 @@ public: static SpellGlobals NewEntity() { - SpellGlobals entry{}; + SpellGlobals e{}; - entry.spellid = 0; - entry.spell_name = ""; - entry.qglobal = ""; - entry.value = ""; + e.spellid = 0; + e.spell_name = ""; + e.qglobal = ""; + e.value = ""; - return entry; + return e; } - static SpellGlobals GetSpellGlobalsEntry( + static SpellGlobals GetSpellGlobals( const std::vector &spell_globalss, int spell_globals_id ) @@ -124,14 +124,14 @@ public: auto row = results.begin(); if (results.RowCount() == 1) { - SpellGlobals entry{}; + SpellGlobals e{}; - entry.spellid = atoi(row[0]); - entry.spell_name = row[1] ? row[1] : ""; - entry.qglobal = row[2] ? row[2] : ""; - entry.value = row[3] ? row[3] : ""; + e.spellid = atoi(row[0]); + e.spell_name = row[1] ? row[1] : ""; + e.qglobal = row[2] ? row[2] : ""; + e.value = row[3] ? row[3] : ""; - return entry; + return e; } return NewEntity(); @@ -156,25 +156,25 @@ public: static int UpdateOne( Database& db, - SpellGlobals spell_globals_entry + const SpellGlobals &e ) { - std::vector update_values; + std::vector v; auto columns = Columns(); - update_values.push_back(columns[0] + " = " + std::to_string(spell_globals_entry.spellid)); - update_values.push_back(columns[1] + " = '" + Strings::Escape(spell_globals_entry.spell_name) + "'"); - update_values.push_back(columns[2] + " = '" + Strings::Escape(spell_globals_entry.qglobal) + "'"); - update_values.push_back(columns[3] + " = '" + Strings::Escape(spell_globals_entry.value) + "'"); + v.push_back(columns[0] + " = " + std::to_string(e.spellid)); + v.push_back(columns[1] + " = '" + Strings::Escape(e.spell_name) + "'"); + v.push_back(columns[2] + " = '" + Strings::Escape(e.qglobal) + "'"); + v.push_back(columns[3] + " = '" + Strings::Escape(e.value) + "'"); auto results = db.QueryDatabase( fmt::format( "UPDATE {} SET {} WHERE {} = {}", TableName(), - Strings::Implode(", ", update_values), + Strings::Implode(", ", v), PrimaryKey(), - spell_globals_entry.spellid + e.spellid ) ); @@ -183,53 +183,53 @@ public: static SpellGlobals InsertOne( Database& db, - SpellGlobals spell_globals_entry + SpellGlobals e ) { - std::vector insert_values; + std::vector v; - insert_values.push_back(std::to_string(spell_globals_entry.spellid)); - insert_values.push_back("'" + Strings::Escape(spell_globals_entry.spell_name) + "'"); - insert_values.push_back("'" + Strings::Escape(spell_globals_entry.qglobal) + "'"); - insert_values.push_back("'" + Strings::Escape(spell_globals_entry.value) + "'"); + v.push_back(std::to_string(e.spellid)); + v.push_back("'" + Strings::Escape(e.spell_name) + "'"); + v.push_back("'" + Strings::Escape(e.qglobal) + "'"); + v.push_back("'" + Strings::Escape(e.value) + "'"); auto results = db.QueryDatabase( fmt::format( "{} VALUES ({})", BaseInsert(), - Strings::Implode(",", insert_values) + Strings::Implode(",", v) ) ); if (results.Success()) { - spell_globals_entry.spellid = results.LastInsertedID(); - return spell_globals_entry; + e.spellid = results.LastInsertedID(); + return e; } - spell_globals_entry = NewEntity(); + e = NewEntity(); - return spell_globals_entry; + return e; } static int InsertMany( Database& db, - std::vector spell_globals_entries + const std::vector &entries ) { std::vector insert_chunks; - for (auto &spell_globals_entry: spell_globals_entries) { - std::vector insert_values; + for (auto &e: entries) { + std::vector v; - insert_values.push_back(std::to_string(spell_globals_entry.spellid)); - insert_values.push_back("'" + Strings::Escape(spell_globals_entry.spell_name) + "'"); - insert_values.push_back("'" + Strings::Escape(spell_globals_entry.qglobal) + "'"); - insert_values.push_back("'" + Strings::Escape(spell_globals_entry.value) + "'"); + v.push_back(std::to_string(e.spellid)); + v.push_back("'" + Strings::Escape(e.spell_name) + "'"); + v.push_back("'" + Strings::Escape(e.qglobal) + "'"); + v.push_back("'" + Strings::Escape(e.value) + "'"); - insert_chunks.push_back("(" + Strings::Implode(",", insert_values) + ")"); + insert_chunks.push_back("(" + Strings::Implode(",", v) + ")"); } - std::vector insert_values; + std::vector v; auto results = db.QueryDatabase( fmt::format( @@ -256,20 +256,20 @@ public: all_entries.reserve(results.RowCount()); for (auto row = results.begin(); row != results.end(); ++row) { - SpellGlobals entry{}; + SpellGlobals e{}; - entry.spellid = atoi(row[0]); - entry.spell_name = row[1] ? row[1] : ""; - entry.qglobal = row[2] ? row[2] : ""; - entry.value = row[3] ? row[3] : ""; + e.spellid = atoi(row[0]); + e.spell_name = row[1] ? row[1] : ""; + e.qglobal = row[2] ? row[2] : ""; + e.value = row[3] ? row[3] : ""; - all_entries.push_back(entry); + all_entries.push_back(e); } return all_entries; } - static std::vector GetWhere(Database& db, std::string where_filter) + static std::vector GetWhere(Database& db, const std::string &where_filter) { std::vector all_entries; @@ -284,20 +284,20 @@ public: all_entries.reserve(results.RowCount()); for (auto row = results.begin(); row != results.end(); ++row) { - SpellGlobals entry{}; + SpellGlobals e{}; - entry.spellid = atoi(row[0]); - entry.spell_name = row[1] ? row[1] : ""; - entry.qglobal = row[2] ? row[2] : ""; - entry.value = row[3] ? row[3] : ""; + e.spellid = atoi(row[0]); + e.spell_name = row[1] ? row[1] : ""; + e.qglobal = row[2] ? row[2] : ""; + e.value = row[3] ? row[3] : ""; - all_entries.push_back(entry); + all_entries.push_back(e); } return all_entries; } - static int DeleteWhere(Database& db, std::string where_filter) + static int DeleteWhere(Database& db, const std::string &where_filter) { auto results = db.QueryDatabase( fmt::format( @@ -322,6 +322,32 @@ public: 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); + } + }; #endif //EQEMU_BASE_SPELL_GLOBALS_REPOSITORY_H diff --git a/common/repositories/base/base_spells_new_repository.h b/common/repositories/base/base_spells_new_repository.h index b2d401d10..8d523c71d 100644 --- a/common/repositories/base/base_spells_new_repository.h +++ b/common/repositories/base/base_spells_new_repository.h @@ -784,250 +784,250 @@ public: static SpellsNew NewEntity() { - SpellsNew entry{}; + SpellsNew e{}; - entry.id = 0; - entry.name = ""; - entry.player_1 = "BLUE_TRAIL"; - entry.teleport_zone = ""; - entry.you_cast = ""; - entry.other_casts = ""; - entry.cast_on_you = ""; - entry.cast_on_other = ""; - entry.spell_fades = ""; - entry.range = 100; - entry.aoerange = 0; - entry.pushback = 0; - entry.pushup = 0; - entry.cast_time = 0; - entry.recovery_time = 0; - entry.recast_time = 0; - entry.buffdurationformula = 7; - entry.buffduration = 65; - entry.AEDuration = 0; - entry.mana = 0; - entry.effect_base_value1 = 100; - entry.effect_base_value2 = 0; - entry.effect_base_value3 = 0; - entry.effect_base_value4 = 0; - entry.effect_base_value5 = 0; - entry.effect_base_value6 = 0; - entry.effect_base_value7 = 0; - entry.effect_base_value8 = 0; - entry.effect_base_value9 = 0; - entry.effect_base_value10 = 0; - entry.effect_base_value11 = 0; - entry.effect_base_value12 = 0; - entry.effect_limit_value1 = 0; - entry.effect_limit_value2 = 0; - entry.effect_limit_value3 = 0; - entry.effect_limit_value4 = 0; - entry.effect_limit_value5 = 0; - entry.effect_limit_value6 = 0; - entry.effect_limit_value7 = 0; - entry.effect_limit_value8 = 0; - entry.effect_limit_value9 = 0; - entry.effect_limit_value10 = 0; - entry.effect_limit_value11 = 0; - entry.effect_limit_value12 = 0; - entry.max1 = 0; - entry.max2 = 0; - entry.max3 = 0; - entry.max4 = 0; - entry.max5 = 0; - entry.max6 = 0; - entry.max7 = 0; - entry.max8 = 0; - entry.max9 = 0; - entry.max10 = 0; - entry.max11 = 0; - entry.max12 = 0; - entry.icon = 0; - entry.memicon = 0; - entry.components1 = -1; - entry.components2 = -1; - entry.components3 = -1; - entry.components4 = -1; - entry.component_counts1 = 1; - entry.component_counts2 = 1; - entry.component_counts3 = 1; - entry.component_counts4 = 1; - entry.NoexpendReagent1 = -1; - entry.NoexpendReagent2 = -1; - entry.NoexpendReagent3 = -1; - entry.NoexpendReagent4 = -1; - entry.formula1 = 100; - entry.formula2 = 100; - entry.formula3 = 100; - entry.formula4 = 100; - entry.formula5 = 100; - entry.formula6 = 100; - entry.formula7 = 100; - entry.formula8 = 100; - entry.formula9 = 100; - entry.formula10 = 100; - entry.formula11 = 100; - entry.formula12 = 100; - entry.LightType = 0; - entry.goodEffect = 0; - entry.Activated = 0; - entry.resisttype = 0; - entry.effectid1 = 254; - entry.effectid2 = 254; - entry.effectid3 = 254; - entry.effectid4 = 254; - entry.effectid5 = 254; - entry.effectid6 = 254; - entry.effectid7 = 254; - entry.effectid8 = 254; - entry.effectid9 = 254; - entry.effectid10 = 254; - entry.effectid11 = 254; - entry.effectid12 = 254; - entry.targettype = 2; - entry.basediff = 0; - entry.skill = 98; - entry.zonetype = -1; - entry.EnvironmentType = 0; - entry.TimeOfDay = 0; - entry.classes1 = 255; - entry.classes2 = 255; - entry.classes3 = 255; - entry.classes4 = 255; - entry.classes5 = 255; - entry.classes6 = 255; - entry.classes7 = 255; - entry.classes8 = 255; - entry.classes9 = 255; - entry.classes10 = 255; - entry.classes11 = 255; - entry.classes12 = 255; - entry.classes13 = 255; - entry.classes14 = 255; - entry.classes15 = 255; - entry.classes16 = 255; - entry.CastingAnim = 44; - entry.TargetAnim = 13; - entry.TravelType = 0; - entry.SpellAffectIndex = -1; - entry.disallow_sit = 0; - entry.deities0 = 0; - entry.deities1 = 0; - entry.deities2 = 0; - entry.deities3 = 0; - entry.deities4 = 0; - entry.deities5 = 0; - entry.deities6 = 0; - entry.deities7 = 0; - entry.deities8 = 0; - entry.deities9 = 0; - entry.deities10 = 0; - entry.deities11 = 0; - entry.deities12 = 0; - entry.deities13 = 0; - entry.deities14 = 0; - entry.deities15 = 0; - entry.deities16 = 0; - entry.field142 = 100; - entry.field143 = 0; - entry.new_icon = 161; - entry.spellanim = 0; - entry.uninterruptable = 0; - entry.ResistDiff = -150; - entry.dot_stacking_exempt = 0; - entry.deleteable = 0; - entry.RecourseLink = 0; - entry.no_partial_resist = 0; - entry.field152 = 0; - entry.field153 = 0; - entry.short_buff_box = -1; - entry.descnum = 0; - entry.typedescnum = 0; - entry.effectdescnum = 0; - entry.effectdescnum2 = 0; - entry.npc_no_los = 0; - entry.field160 = 0; - entry.reflectable = 0; - entry.bonushate = 0; - entry.field163 = 100; - entry.field164 = -150; - entry.ldon_trap = 0; - entry.EndurCost = 0; - entry.EndurTimerIndex = 0; - entry.IsDiscipline = 0; - entry.field169 = 0; - entry.field170 = 0; - entry.field171 = 0; - entry.field172 = 0; - entry.HateAdded = 0; - entry.EndurUpkeep = 0; - entry.numhitstype = 0; - entry.numhits = 0; - entry.pvpresistbase = -150; - entry.pvpresistcalc = 100; - entry.pvpresistcap = -150; - entry.spell_category = -99; - entry.pvp_duration = 0; - entry.pvp_duration_cap = 0; - entry.pcnpc_only_flag = 0; - entry.cast_not_standing = 0; - entry.can_mgb = 0; - entry.nodispell = -1; - entry.npc_category = 0; - entry.npc_usefulness = 0; - entry.MinResist = 0; - entry.MaxResist = 0; - entry.viral_targets = 0; - entry.viral_timer = 0; - entry.nimbuseffect = 0; - entry.ConeStartAngle = 0; - entry.ConeStopAngle = 0; - entry.sneaking = 0; - entry.not_extendable = 0; - entry.field198 = 0; - entry.field199 = 1; - entry.suspendable = 0; - entry.viral_range = 0; - entry.songcap = 0; - entry.field203 = 0; - entry.field204 = 0; - entry.no_block = 0; - entry.field206 = -1; - entry.spellgroup = 0; - entry.rank = 0; - entry.field209 = 0; - entry.field210 = 1; - entry.CastRestriction = 0; - entry.allowrest = 0; - entry.InCombat = 0; - entry.OutofCombat = 0; - entry.field215 = 0; - entry.field216 = 0; - entry.field217 = 0; - entry.aemaxtargets = 0; - entry.maxtargets = 0; - entry.field220 = 0; - entry.field221 = 0; - entry.field222 = 0; - entry.field223 = 0; - entry.persistdeath = 0; - entry.field225 = 0; - entry.field226 = 0; - entry.min_dist = 0; - entry.min_dist_mod = 0; - entry.max_dist = 0; - entry.max_dist_mod = 0; - entry.min_range = 0; - entry.field232 = 0; - entry.field233 = 0; - entry.field234 = 0; - entry.field235 = 0; - entry.field236 = 0; + e.id = 0; + e.name = ""; + e.player_1 = "BLUE_TRAIL"; + e.teleport_zone = ""; + e.you_cast = ""; + e.other_casts = ""; + e.cast_on_you = ""; + e.cast_on_other = ""; + e.spell_fades = ""; + e.range = 100; + e.aoerange = 0; + e.pushback = 0; + e.pushup = 0; + e.cast_time = 0; + e.recovery_time = 0; + e.recast_time = 0; + e.buffdurationformula = 7; + e.buffduration = 65; + e.AEDuration = 0; + e.mana = 0; + e.effect_base_value1 = 100; + e.effect_base_value2 = 0; + e.effect_base_value3 = 0; + e.effect_base_value4 = 0; + e.effect_base_value5 = 0; + e.effect_base_value6 = 0; + e.effect_base_value7 = 0; + e.effect_base_value8 = 0; + e.effect_base_value9 = 0; + e.effect_base_value10 = 0; + e.effect_base_value11 = 0; + e.effect_base_value12 = 0; + e.effect_limit_value1 = 0; + e.effect_limit_value2 = 0; + e.effect_limit_value3 = 0; + e.effect_limit_value4 = 0; + e.effect_limit_value5 = 0; + e.effect_limit_value6 = 0; + e.effect_limit_value7 = 0; + e.effect_limit_value8 = 0; + e.effect_limit_value9 = 0; + e.effect_limit_value10 = 0; + e.effect_limit_value11 = 0; + e.effect_limit_value12 = 0; + e.max1 = 0; + e.max2 = 0; + e.max3 = 0; + e.max4 = 0; + e.max5 = 0; + e.max6 = 0; + e.max7 = 0; + e.max8 = 0; + e.max9 = 0; + e.max10 = 0; + e.max11 = 0; + e.max12 = 0; + e.icon = 0; + e.memicon = 0; + e.components1 = -1; + e.components2 = -1; + e.components3 = -1; + e.components4 = -1; + e.component_counts1 = 1; + e.component_counts2 = 1; + e.component_counts3 = 1; + e.component_counts4 = 1; + e.NoexpendReagent1 = -1; + e.NoexpendReagent2 = -1; + e.NoexpendReagent3 = -1; + e.NoexpendReagent4 = -1; + e.formula1 = 100; + e.formula2 = 100; + e.formula3 = 100; + e.formula4 = 100; + e.formula5 = 100; + e.formula6 = 100; + e.formula7 = 100; + e.formula8 = 100; + e.formula9 = 100; + e.formula10 = 100; + e.formula11 = 100; + e.formula12 = 100; + e.LightType = 0; + e.goodEffect = 0; + e.Activated = 0; + e.resisttype = 0; + e.effectid1 = 254; + e.effectid2 = 254; + e.effectid3 = 254; + e.effectid4 = 254; + e.effectid5 = 254; + e.effectid6 = 254; + e.effectid7 = 254; + e.effectid8 = 254; + e.effectid9 = 254; + e.effectid10 = 254; + e.effectid11 = 254; + e.effectid12 = 254; + e.targettype = 2; + e.basediff = 0; + e.skill = 98; + e.zonetype = -1; + e.EnvironmentType = 0; + e.TimeOfDay = 0; + e.classes1 = 255; + e.classes2 = 255; + e.classes3 = 255; + e.classes4 = 255; + e.classes5 = 255; + e.classes6 = 255; + e.classes7 = 255; + e.classes8 = 255; + e.classes9 = 255; + e.classes10 = 255; + e.classes11 = 255; + e.classes12 = 255; + e.classes13 = 255; + e.classes14 = 255; + e.classes15 = 255; + e.classes16 = 255; + e.CastingAnim = 44; + e.TargetAnim = 13; + e.TravelType = 0; + e.SpellAffectIndex = -1; + e.disallow_sit = 0; + e.deities0 = 0; + e.deities1 = 0; + e.deities2 = 0; + e.deities3 = 0; + e.deities4 = 0; + e.deities5 = 0; + e.deities6 = 0; + e.deities7 = 0; + e.deities8 = 0; + e.deities9 = 0; + e.deities10 = 0; + e.deities11 = 0; + e.deities12 = 0; + e.deities13 = 0; + e.deities14 = 0; + e.deities15 = 0; + e.deities16 = 0; + e.field142 = 100; + e.field143 = 0; + e.new_icon = 161; + e.spellanim = 0; + e.uninterruptable = 0; + e.ResistDiff = -150; + e.dot_stacking_exempt = 0; + e.deleteable = 0; + e.RecourseLink = 0; + e.no_partial_resist = 0; + e.field152 = 0; + e.field153 = 0; + e.short_buff_box = -1; + e.descnum = 0; + e.typedescnum = 0; + e.effectdescnum = 0; + e.effectdescnum2 = 0; + e.npc_no_los = 0; + e.field160 = 0; + e.reflectable = 0; + e.bonushate = 0; + e.field163 = 100; + e.field164 = -150; + e.ldon_trap = 0; + e.EndurCost = 0; + e.EndurTimerIndex = 0; + e.IsDiscipline = 0; + e.field169 = 0; + e.field170 = 0; + e.field171 = 0; + e.field172 = 0; + e.HateAdded = 0; + e.EndurUpkeep = 0; + e.numhitstype = 0; + e.numhits = 0; + e.pvpresistbase = -150; + e.pvpresistcalc = 100; + e.pvpresistcap = -150; + e.spell_category = -99; + e.pvp_duration = 0; + e.pvp_duration_cap = 0; + e.pcnpc_only_flag = 0; + e.cast_not_standing = 0; + e.can_mgb = 0; + e.nodispell = -1; + e.npc_category = 0; + e.npc_usefulness = 0; + e.MinResist = 0; + e.MaxResist = 0; + e.viral_targets = 0; + e.viral_timer = 0; + e.nimbuseffect = 0; + e.ConeStartAngle = 0; + e.ConeStopAngle = 0; + e.sneaking = 0; + e.not_extendable = 0; + e.field198 = 0; + e.field199 = 1; + e.suspendable = 0; + e.viral_range = 0; + e.songcap = 0; + e.field203 = 0; + e.field204 = 0; + e.no_block = 0; + e.field206 = -1; + e.spellgroup = 0; + e.rank = 0; + e.field209 = 0; + e.field210 = 1; + e.CastRestriction = 0; + e.allowrest = 0; + e.InCombat = 0; + e.OutofCombat = 0; + e.field215 = 0; + e.field216 = 0; + e.field217 = 0; + e.aemaxtargets = 0; + e.maxtargets = 0; + e.field220 = 0; + e.field221 = 0; + e.field222 = 0; + e.field223 = 0; + e.persistdeath = 0; + e.field225 = 0; + e.field226 = 0; + e.min_dist = 0; + e.min_dist_mod = 0; + e.max_dist = 0; + e.max_dist_mod = 0; + e.min_range = 0; + e.field232 = 0; + e.field233 = 0; + e.field234 = 0; + e.field235 = 0; + e.field236 = 0; - return entry; + return e; } - static SpellsNew GetSpellsNewEntry( + static SpellsNew GetSpellsNew( const std::vector &spells_news, int spells_new_id ) @@ -1056,247 +1056,247 @@ public: auto row = results.begin(); if (results.RowCount() == 1) { - SpellsNew entry{}; + SpellsNew e{}; - entry.id = atoi(row[0]); - entry.name = row[1] ? row[1] : ""; - entry.player_1 = row[2] ? row[2] : ""; - entry.teleport_zone = row[3] ? row[3] : ""; - entry.you_cast = row[4] ? row[4] : ""; - entry.other_casts = row[5] ? row[5] : ""; - entry.cast_on_you = row[6] ? row[6] : ""; - entry.cast_on_other = row[7] ? row[7] : ""; - entry.spell_fades = row[8] ? row[8] : ""; - entry.range = atoi(row[9]); - entry.aoerange = atoi(row[10]); - entry.pushback = atoi(row[11]); - entry.pushup = atoi(row[12]); - entry.cast_time = atoi(row[13]); - entry.recovery_time = atoi(row[14]); - entry.recast_time = atoi(row[15]); - entry.buffdurationformula = atoi(row[16]); - entry.buffduration = atoi(row[17]); - entry.AEDuration = atoi(row[18]); - entry.mana = atoi(row[19]); - entry.effect_base_value1 = atoi(row[20]); - entry.effect_base_value2 = atoi(row[21]); - entry.effect_base_value3 = atoi(row[22]); - entry.effect_base_value4 = atoi(row[23]); - entry.effect_base_value5 = atoi(row[24]); - entry.effect_base_value6 = atoi(row[25]); - entry.effect_base_value7 = atoi(row[26]); - entry.effect_base_value8 = atoi(row[27]); - entry.effect_base_value9 = atoi(row[28]); - entry.effect_base_value10 = atoi(row[29]); - entry.effect_base_value11 = atoi(row[30]); - entry.effect_base_value12 = atoi(row[31]); - entry.effect_limit_value1 = atoi(row[32]); - entry.effect_limit_value2 = atoi(row[33]); - entry.effect_limit_value3 = atoi(row[34]); - entry.effect_limit_value4 = atoi(row[35]); - entry.effect_limit_value5 = atoi(row[36]); - entry.effect_limit_value6 = atoi(row[37]); - entry.effect_limit_value7 = atoi(row[38]); - entry.effect_limit_value8 = atoi(row[39]); - entry.effect_limit_value9 = atoi(row[40]); - entry.effect_limit_value10 = atoi(row[41]); - entry.effect_limit_value11 = atoi(row[42]); - entry.effect_limit_value12 = atoi(row[43]); - entry.max1 = atoi(row[44]); - entry.max2 = atoi(row[45]); - entry.max3 = atoi(row[46]); - entry.max4 = atoi(row[47]); - entry.max5 = atoi(row[48]); - entry.max6 = atoi(row[49]); - entry.max7 = atoi(row[50]); - entry.max8 = atoi(row[51]); - entry.max9 = atoi(row[52]); - entry.max10 = atoi(row[53]); - entry.max11 = atoi(row[54]); - entry.max12 = atoi(row[55]); - entry.icon = atoi(row[56]); - entry.memicon = atoi(row[57]); - entry.components1 = atoi(row[58]); - entry.components2 = atoi(row[59]); - entry.components3 = atoi(row[60]); - entry.components4 = atoi(row[61]); - entry.component_counts1 = atoi(row[62]); - entry.component_counts2 = atoi(row[63]); - entry.component_counts3 = atoi(row[64]); - entry.component_counts4 = atoi(row[65]); - entry.NoexpendReagent1 = atoi(row[66]); - entry.NoexpendReagent2 = atoi(row[67]); - entry.NoexpendReagent3 = atoi(row[68]); - entry.NoexpendReagent4 = atoi(row[69]); - entry.formula1 = atoi(row[70]); - entry.formula2 = atoi(row[71]); - entry.formula3 = atoi(row[72]); - entry.formula4 = atoi(row[73]); - entry.formula5 = atoi(row[74]); - entry.formula6 = atoi(row[75]); - entry.formula7 = atoi(row[76]); - entry.formula8 = atoi(row[77]); - entry.formula9 = atoi(row[78]); - entry.formula10 = atoi(row[79]); - entry.formula11 = atoi(row[80]); - entry.formula12 = atoi(row[81]); - entry.LightType = atoi(row[82]); - entry.goodEffect = atoi(row[83]); - entry.Activated = atoi(row[84]); - entry.resisttype = atoi(row[85]); - entry.effectid1 = atoi(row[86]); - entry.effectid2 = atoi(row[87]); - entry.effectid3 = atoi(row[88]); - entry.effectid4 = atoi(row[89]); - entry.effectid5 = atoi(row[90]); - entry.effectid6 = atoi(row[91]); - entry.effectid7 = atoi(row[92]); - entry.effectid8 = atoi(row[93]); - entry.effectid9 = atoi(row[94]); - entry.effectid10 = atoi(row[95]); - entry.effectid11 = atoi(row[96]); - entry.effectid12 = atoi(row[97]); - entry.targettype = atoi(row[98]); - entry.basediff = atoi(row[99]); - entry.skill = atoi(row[100]); - entry.zonetype = atoi(row[101]); - entry.EnvironmentType = atoi(row[102]); - entry.TimeOfDay = atoi(row[103]); - entry.classes1 = atoi(row[104]); - entry.classes2 = atoi(row[105]); - entry.classes3 = atoi(row[106]); - entry.classes4 = atoi(row[107]); - entry.classes5 = atoi(row[108]); - entry.classes6 = atoi(row[109]); - entry.classes7 = atoi(row[110]); - entry.classes8 = atoi(row[111]); - entry.classes9 = atoi(row[112]); - entry.classes10 = atoi(row[113]); - entry.classes11 = atoi(row[114]); - entry.classes12 = atoi(row[115]); - entry.classes13 = atoi(row[116]); - entry.classes14 = atoi(row[117]); - entry.classes15 = atoi(row[118]); - entry.classes16 = atoi(row[119]); - entry.CastingAnim = atoi(row[120]); - entry.TargetAnim = atoi(row[121]); - entry.TravelType = atoi(row[122]); - entry.SpellAffectIndex = atoi(row[123]); - entry.disallow_sit = atoi(row[124]); - entry.deities0 = atoi(row[125]); - entry.deities1 = atoi(row[126]); - entry.deities2 = atoi(row[127]); - entry.deities3 = atoi(row[128]); - entry.deities4 = atoi(row[129]); - entry.deities5 = atoi(row[130]); - entry.deities6 = atoi(row[131]); - entry.deities7 = atoi(row[132]); - entry.deities8 = atoi(row[133]); - entry.deities9 = atoi(row[134]); - entry.deities10 = atoi(row[135]); - entry.deities11 = atoi(row[136]); - entry.deities12 = atoi(row[137]); - entry.deities13 = atoi(row[138]); - entry.deities14 = atoi(row[139]); - entry.deities15 = atoi(row[140]); - entry.deities16 = atoi(row[141]); - entry.field142 = atoi(row[142]); - entry.field143 = atoi(row[143]); - entry.new_icon = atoi(row[144]); - entry.spellanim = atoi(row[145]); - entry.uninterruptable = atoi(row[146]); - entry.ResistDiff = atoi(row[147]); - entry.dot_stacking_exempt = atoi(row[148]); - entry.deleteable = atoi(row[149]); - entry.RecourseLink = atoi(row[150]); - entry.no_partial_resist = atoi(row[151]); - entry.field152 = atoi(row[152]); - entry.field153 = atoi(row[153]); - entry.short_buff_box = atoi(row[154]); - entry.descnum = atoi(row[155]); - entry.typedescnum = atoi(row[156]); - entry.effectdescnum = atoi(row[157]); - entry.effectdescnum2 = atoi(row[158]); - entry.npc_no_los = atoi(row[159]); - entry.field160 = atoi(row[160]); - entry.reflectable = atoi(row[161]); - entry.bonushate = atoi(row[162]); - entry.field163 = atoi(row[163]); - entry.field164 = atoi(row[164]); - entry.ldon_trap = atoi(row[165]); - entry.EndurCost = atoi(row[166]); - entry.EndurTimerIndex = atoi(row[167]); - entry.IsDiscipline = atoi(row[168]); - entry.field169 = atoi(row[169]); - entry.field170 = atoi(row[170]); - entry.field171 = atoi(row[171]); - entry.field172 = atoi(row[172]); - entry.HateAdded = atoi(row[173]); - entry.EndurUpkeep = atoi(row[174]); - entry.numhitstype = atoi(row[175]); - entry.numhits = atoi(row[176]); - entry.pvpresistbase = atoi(row[177]); - entry.pvpresistcalc = atoi(row[178]); - entry.pvpresistcap = atoi(row[179]); - entry.spell_category = atoi(row[180]); - entry.pvp_duration = atoi(row[181]); - entry.pvp_duration_cap = atoi(row[182]); - entry.pcnpc_only_flag = atoi(row[183]); - entry.cast_not_standing = atoi(row[184]); - entry.can_mgb = atoi(row[185]); - entry.nodispell = atoi(row[186]); - entry.npc_category = atoi(row[187]); - entry.npc_usefulness = atoi(row[188]); - entry.MinResist = atoi(row[189]); - entry.MaxResist = atoi(row[190]); - entry.viral_targets = atoi(row[191]); - entry.viral_timer = atoi(row[192]); - entry.nimbuseffect = atoi(row[193]); - entry.ConeStartAngle = atoi(row[194]); - entry.ConeStopAngle = atoi(row[195]); - entry.sneaking = atoi(row[196]); - entry.not_extendable = atoi(row[197]); - entry.field198 = atoi(row[198]); - entry.field199 = atoi(row[199]); - entry.suspendable = atoi(row[200]); - entry.viral_range = atoi(row[201]); - entry.songcap = atoi(row[202]); - entry.field203 = atoi(row[203]); - entry.field204 = atoi(row[204]); - entry.no_block = atoi(row[205]); - entry.field206 = atoi(row[206]); - entry.spellgroup = atoi(row[207]); - entry.rank = atoi(row[208]); - entry.field209 = atoi(row[209]); - entry.field210 = atoi(row[210]); - entry.CastRestriction = atoi(row[211]); - entry.allowrest = atoi(row[212]); - entry.InCombat = atoi(row[213]); - entry.OutofCombat = atoi(row[214]); - entry.field215 = atoi(row[215]); - entry.field216 = atoi(row[216]); - entry.field217 = atoi(row[217]); - entry.aemaxtargets = atoi(row[218]); - entry.maxtargets = atoi(row[219]); - entry.field220 = atoi(row[220]); - entry.field221 = atoi(row[221]); - entry.field222 = atoi(row[222]); - entry.field223 = atoi(row[223]); - entry.persistdeath = atoi(row[224]); - entry.field225 = atoi(row[225]); - entry.field226 = atoi(row[226]); - entry.min_dist = static_cast(atof(row[227])); - entry.min_dist_mod = static_cast(atof(row[228])); - entry.max_dist = static_cast(atof(row[229])); - entry.max_dist_mod = static_cast(atof(row[230])); - entry.min_range = atoi(row[231]); - entry.field232 = atoi(row[232]); - entry.field233 = atoi(row[233]); - entry.field234 = atoi(row[234]); - entry.field235 = atoi(row[235]); - entry.field236 = atoi(row[236]); + e.id = atoi(row[0]); + e.name = row[1] ? row[1] : ""; + e.player_1 = row[2] ? row[2] : ""; + e.teleport_zone = row[3] ? row[3] : ""; + e.you_cast = row[4] ? row[4] : ""; + e.other_casts = row[5] ? row[5] : ""; + e.cast_on_you = row[6] ? row[6] : ""; + e.cast_on_other = row[7] ? row[7] : ""; + e.spell_fades = row[8] ? row[8] : ""; + e.range = atoi(row[9]); + e.aoerange = atoi(row[10]); + e.pushback = atoi(row[11]); + e.pushup = atoi(row[12]); + e.cast_time = atoi(row[13]); + e.recovery_time = atoi(row[14]); + e.recast_time = atoi(row[15]); + e.buffdurationformula = atoi(row[16]); + e.buffduration = atoi(row[17]); + e.AEDuration = atoi(row[18]); + e.mana = atoi(row[19]); + e.effect_base_value1 = atoi(row[20]); + e.effect_base_value2 = atoi(row[21]); + e.effect_base_value3 = atoi(row[22]); + e.effect_base_value4 = atoi(row[23]); + e.effect_base_value5 = atoi(row[24]); + e.effect_base_value6 = atoi(row[25]); + e.effect_base_value7 = atoi(row[26]); + e.effect_base_value8 = atoi(row[27]); + e.effect_base_value9 = atoi(row[28]); + e.effect_base_value10 = atoi(row[29]); + e.effect_base_value11 = atoi(row[30]); + e.effect_base_value12 = atoi(row[31]); + e.effect_limit_value1 = atoi(row[32]); + e.effect_limit_value2 = atoi(row[33]); + e.effect_limit_value3 = atoi(row[34]); + e.effect_limit_value4 = atoi(row[35]); + e.effect_limit_value5 = atoi(row[36]); + e.effect_limit_value6 = atoi(row[37]); + e.effect_limit_value7 = atoi(row[38]); + e.effect_limit_value8 = atoi(row[39]); + e.effect_limit_value9 = atoi(row[40]); + e.effect_limit_value10 = atoi(row[41]); + e.effect_limit_value11 = atoi(row[42]); + e.effect_limit_value12 = atoi(row[43]); + e.max1 = atoi(row[44]); + e.max2 = atoi(row[45]); + e.max3 = atoi(row[46]); + e.max4 = atoi(row[47]); + e.max5 = atoi(row[48]); + e.max6 = atoi(row[49]); + e.max7 = atoi(row[50]); + e.max8 = atoi(row[51]); + e.max9 = atoi(row[52]); + e.max10 = atoi(row[53]); + e.max11 = atoi(row[54]); + e.max12 = atoi(row[55]); + e.icon = atoi(row[56]); + e.memicon = atoi(row[57]); + e.components1 = atoi(row[58]); + e.components2 = atoi(row[59]); + e.components3 = atoi(row[60]); + e.components4 = atoi(row[61]); + e.component_counts1 = atoi(row[62]); + e.component_counts2 = atoi(row[63]); + e.component_counts3 = atoi(row[64]); + e.component_counts4 = atoi(row[65]); + e.NoexpendReagent1 = atoi(row[66]); + e.NoexpendReagent2 = atoi(row[67]); + e.NoexpendReagent3 = atoi(row[68]); + e.NoexpendReagent4 = atoi(row[69]); + e.formula1 = atoi(row[70]); + e.formula2 = atoi(row[71]); + e.formula3 = atoi(row[72]); + e.formula4 = atoi(row[73]); + e.formula5 = atoi(row[74]); + e.formula6 = atoi(row[75]); + e.formula7 = atoi(row[76]); + e.formula8 = atoi(row[77]); + e.formula9 = atoi(row[78]); + e.formula10 = atoi(row[79]); + e.formula11 = atoi(row[80]); + e.formula12 = atoi(row[81]); + e.LightType = atoi(row[82]); + e.goodEffect = atoi(row[83]); + e.Activated = atoi(row[84]); + e.resisttype = atoi(row[85]); + e.effectid1 = atoi(row[86]); + e.effectid2 = atoi(row[87]); + e.effectid3 = atoi(row[88]); + e.effectid4 = atoi(row[89]); + e.effectid5 = atoi(row[90]); + e.effectid6 = atoi(row[91]); + e.effectid7 = atoi(row[92]); + e.effectid8 = atoi(row[93]); + e.effectid9 = atoi(row[94]); + e.effectid10 = atoi(row[95]); + e.effectid11 = atoi(row[96]); + e.effectid12 = atoi(row[97]); + e.targettype = atoi(row[98]); + e.basediff = atoi(row[99]); + e.skill = atoi(row[100]); + e.zonetype = atoi(row[101]); + e.EnvironmentType = atoi(row[102]); + e.TimeOfDay = atoi(row[103]); + e.classes1 = atoi(row[104]); + e.classes2 = atoi(row[105]); + e.classes3 = atoi(row[106]); + e.classes4 = atoi(row[107]); + e.classes5 = atoi(row[108]); + e.classes6 = atoi(row[109]); + e.classes7 = atoi(row[110]); + e.classes8 = atoi(row[111]); + e.classes9 = atoi(row[112]); + e.classes10 = atoi(row[113]); + e.classes11 = atoi(row[114]); + e.classes12 = atoi(row[115]); + e.classes13 = atoi(row[116]); + e.classes14 = atoi(row[117]); + e.classes15 = atoi(row[118]); + e.classes16 = atoi(row[119]); + e.CastingAnim = atoi(row[120]); + e.TargetAnim = atoi(row[121]); + e.TravelType = atoi(row[122]); + e.SpellAffectIndex = atoi(row[123]); + e.disallow_sit = atoi(row[124]); + e.deities0 = atoi(row[125]); + e.deities1 = atoi(row[126]); + e.deities2 = atoi(row[127]); + e.deities3 = atoi(row[128]); + e.deities4 = atoi(row[129]); + e.deities5 = atoi(row[130]); + e.deities6 = atoi(row[131]); + e.deities7 = atoi(row[132]); + e.deities8 = atoi(row[133]); + e.deities9 = atoi(row[134]); + e.deities10 = atoi(row[135]); + e.deities11 = atoi(row[136]); + e.deities12 = atoi(row[137]); + e.deities13 = atoi(row[138]); + e.deities14 = atoi(row[139]); + e.deities15 = atoi(row[140]); + e.deities16 = atoi(row[141]); + e.field142 = atoi(row[142]); + e.field143 = atoi(row[143]); + e.new_icon = atoi(row[144]); + e.spellanim = atoi(row[145]); + e.uninterruptable = atoi(row[146]); + e.ResistDiff = atoi(row[147]); + e.dot_stacking_exempt = atoi(row[148]); + e.deleteable = atoi(row[149]); + e.RecourseLink = atoi(row[150]); + e.no_partial_resist = atoi(row[151]); + e.field152 = atoi(row[152]); + e.field153 = atoi(row[153]); + e.short_buff_box = atoi(row[154]); + e.descnum = atoi(row[155]); + e.typedescnum = atoi(row[156]); + e.effectdescnum = atoi(row[157]); + e.effectdescnum2 = atoi(row[158]); + e.npc_no_los = atoi(row[159]); + e.field160 = atoi(row[160]); + e.reflectable = atoi(row[161]); + e.bonushate = atoi(row[162]); + e.field163 = atoi(row[163]); + e.field164 = atoi(row[164]); + e.ldon_trap = atoi(row[165]); + e.EndurCost = atoi(row[166]); + e.EndurTimerIndex = atoi(row[167]); + e.IsDiscipline = atoi(row[168]); + e.field169 = atoi(row[169]); + e.field170 = atoi(row[170]); + e.field171 = atoi(row[171]); + e.field172 = atoi(row[172]); + e.HateAdded = atoi(row[173]); + e.EndurUpkeep = atoi(row[174]); + e.numhitstype = atoi(row[175]); + e.numhits = atoi(row[176]); + e.pvpresistbase = atoi(row[177]); + e.pvpresistcalc = atoi(row[178]); + e.pvpresistcap = atoi(row[179]); + e.spell_category = atoi(row[180]); + e.pvp_duration = atoi(row[181]); + e.pvp_duration_cap = atoi(row[182]); + e.pcnpc_only_flag = atoi(row[183]); + e.cast_not_standing = atoi(row[184]); + e.can_mgb = atoi(row[185]); + e.nodispell = atoi(row[186]); + e.npc_category = atoi(row[187]); + e.npc_usefulness = atoi(row[188]); + e.MinResist = atoi(row[189]); + e.MaxResist = atoi(row[190]); + e.viral_targets = atoi(row[191]); + e.viral_timer = atoi(row[192]); + e.nimbuseffect = atoi(row[193]); + e.ConeStartAngle = atoi(row[194]); + e.ConeStopAngle = atoi(row[195]); + e.sneaking = atoi(row[196]); + e.not_extendable = atoi(row[197]); + e.field198 = atoi(row[198]); + e.field199 = atoi(row[199]); + e.suspendable = atoi(row[200]); + e.viral_range = atoi(row[201]); + e.songcap = atoi(row[202]); + e.field203 = atoi(row[203]); + e.field204 = atoi(row[204]); + e.no_block = atoi(row[205]); + e.field206 = atoi(row[206]); + e.spellgroup = atoi(row[207]); + e.rank = atoi(row[208]); + e.field209 = atoi(row[209]); + e.field210 = atoi(row[210]); + e.CastRestriction = atoi(row[211]); + e.allowrest = atoi(row[212]); + e.InCombat = atoi(row[213]); + e.OutofCombat = atoi(row[214]); + e.field215 = atoi(row[215]); + e.field216 = atoi(row[216]); + e.field217 = atoi(row[217]); + e.aemaxtargets = atoi(row[218]); + e.maxtargets = atoi(row[219]); + e.field220 = atoi(row[220]); + e.field221 = atoi(row[221]); + e.field222 = atoi(row[222]); + e.field223 = atoi(row[223]); + e.persistdeath = atoi(row[224]); + e.field225 = atoi(row[225]); + e.field226 = atoi(row[226]); + e.min_dist = static_cast(atof(row[227])); + e.min_dist_mod = static_cast(atof(row[228])); + e.max_dist = static_cast(atof(row[229])); + e.max_dist_mod = static_cast(atof(row[230])); + e.min_range = atoi(row[231]); + e.field232 = atoi(row[232]); + e.field233 = atoi(row[233]); + e.field234 = atoi(row[234]); + e.field235 = atoi(row[235]); + e.field236 = atoi(row[236]); - return entry; + return e; } return NewEntity(); @@ -1321,258 +1321,258 @@ public: static int UpdateOne( Database& db, - SpellsNew spells_new_entry + const SpellsNew &e ) { - std::vector update_values; + std::vector v; auto columns = Columns(); - update_values.push_back(columns[0] + " = " + std::to_string(spells_new_entry.id)); - update_values.push_back(columns[1] + " = '" + Strings::Escape(spells_new_entry.name) + "'"); - update_values.push_back(columns[2] + " = '" + Strings::Escape(spells_new_entry.player_1) + "'"); - update_values.push_back(columns[3] + " = '" + Strings::Escape(spells_new_entry.teleport_zone) + "'"); - update_values.push_back(columns[4] + " = '" + Strings::Escape(spells_new_entry.you_cast) + "'"); - update_values.push_back(columns[5] + " = '" + Strings::Escape(spells_new_entry.other_casts) + "'"); - update_values.push_back(columns[6] + " = '" + Strings::Escape(spells_new_entry.cast_on_you) + "'"); - update_values.push_back(columns[7] + " = '" + Strings::Escape(spells_new_entry.cast_on_other) + "'"); - update_values.push_back(columns[8] + " = '" + Strings::Escape(spells_new_entry.spell_fades) + "'"); - update_values.push_back(columns[9] + " = " + std::to_string(spells_new_entry.range)); - update_values.push_back(columns[10] + " = " + std::to_string(spells_new_entry.aoerange)); - update_values.push_back(columns[11] + " = " + std::to_string(spells_new_entry.pushback)); - update_values.push_back(columns[12] + " = " + std::to_string(spells_new_entry.pushup)); - update_values.push_back(columns[13] + " = " + std::to_string(spells_new_entry.cast_time)); - update_values.push_back(columns[14] + " = " + std::to_string(spells_new_entry.recovery_time)); - update_values.push_back(columns[15] + " = " + std::to_string(spells_new_entry.recast_time)); - update_values.push_back(columns[16] + " = " + std::to_string(spells_new_entry.buffdurationformula)); - update_values.push_back(columns[17] + " = " + std::to_string(spells_new_entry.buffduration)); - update_values.push_back(columns[18] + " = " + std::to_string(spells_new_entry.AEDuration)); - update_values.push_back(columns[19] + " = " + std::to_string(spells_new_entry.mana)); - update_values.push_back(columns[20] + " = " + std::to_string(spells_new_entry.effect_base_value1)); - update_values.push_back(columns[21] + " = " + std::to_string(spells_new_entry.effect_base_value2)); - update_values.push_back(columns[22] + " = " + std::to_string(spells_new_entry.effect_base_value3)); - update_values.push_back(columns[23] + " = " + std::to_string(spells_new_entry.effect_base_value4)); - update_values.push_back(columns[24] + " = " + std::to_string(spells_new_entry.effect_base_value5)); - update_values.push_back(columns[25] + " = " + std::to_string(spells_new_entry.effect_base_value6)); - update_values.push_back(columns[26] + " = " + std::to_string(spells_new_entry.effect_base_value7)); - update_values.push_back(columns[27] + " = " + std::to_string(spells_new_entry.effect_base_value8)); - update_values.push_back(columns[28] + " = " + std::to_string(spells_new_entry.effect_base_value9)); - update_values.push_back(columns[29] + " = " + std::to_string(spells_new_entry.effect_base_value10)); - update_values.push_back(columns[30] + " = " + std::to_string(spells_new_entry.effect_base_value11)); - update_values.push_back(columns[31] + " = " + std::to_string(spells_new_entry.effect_base_value12)); - update_values.push_back(columns[32] + " = " + std::to_string(spells_new_entry.effect_limit_value1)); - update_values.push_back(columns[33] + " = " + std::to_string(spells_new_entry.effect_limit_value2)); - update_values.push_back(columns[34] + " = " + std::to_string(spells_new_entry.effect_limit_value3)); - update_values.push_back(columns[35] + " = " + std::to_string(spells_new_entry.effect_limit_value4)); - update_values.push_back(columns[36] + " = " + std::to_string(spells_new_entry.effect_limit_value5)); - update_values.push_back(columns[37] + " = " + std::to_string(spells_new_entry.effect_limit_value6)); - update_values.push_back(columns[38] + " = " + std::to_string(spells_new_entry.effect_limit_value7)); - update_values.push_back(columns[39] + " = " + std::to_string(spells_new_entry.effect_limit_value8)); - update_values.push_back(columns[40] + " = " + std::to_string(spells_new_entry.effect_limit_value9)); - update_values.push_back(columns[41] + " = " + std::to_string(spells_new_entry.effect_limit_value10)); - update_values.push_back(columns[42] + " = " + std::to_string(spells_new_entry.effect_limit_value11)); - update_values.push_back(columns[43] + " = " + std::to_string(spells_new_entry.effect_limit_value12)); - update_values.push_back(columns[44] + " = " + std::to_string(spells_new_entry.max1)); - update_values.push_back(columns[45] + " = " + std::to_string(spells_new_entry.max2)); - update_values.push_back(columns[46] + " = " + std::to_string(spells_new_entry.max3)); - update_values.push_back(columns[47] + " = " + std::to_string(spells_new_entry.max4)); - update_values.push_back(columns[48] + " = " + std::to_string(spells_new_entry.max5)); - update_values.push_back(columns[49] + " = " + std::to_string(spells_new_entry.max6)); - update_values.push_back(columns[50] + " = " + std::to_string(spells_new_entry.max7)); - update_values.push_back(columns[51] + " = " + std::to_string(spells_new_entry.max8)); - update_values.push_back(columns[52] + " = " + std::to_string(spells_new_entry.max9)); - update_values.push_back(columns[53] + " = " + std::to_string(spells_new_entry.max10)); - update_values.push_back(columns[54] + " = " + std::to_string(spells_new_entry.max11)); - update_values.push_back(columns[55] + " = " + std::to_string(spells_new_entry.max12)); - update_values.push_back(columns[56] + " = " + std::to_string(spells_new_entry.icon)); - update_values.push_back(columns[57] + " = " + std::to_string(spells_new_entry.memicon)); - update_values.push_back(columns[58] + " = " + std::to_string(spells_new_entry.components1)); - update_values.push_back(columns[59] + " = " + std::to_string(spells_new_entry.components2)); - update_values.push_back(columns[60] + " = " + std::to_string(spells_new_entry.components3)); - update_values.push_back(columns[61] + " = " + std::to_string(spells_new_entry.components4)); - update_values.push_back(columns[62] + " = " + std::to_string(spells_new_entry.component_counts1)); - update_values.push_back(columns[63] + " = " + std::to_string(spells_new_entry.component_counts2)); - update_values.push_back(columns[64] + " = " + std::to_string(spells_new_entry.component_counts3)); - update_values.push_back(columns[65] + " = " + std::to_string(spells_new_entry.component_counts4)); - update_values.push_back(columns[66] + " = " + std::to_string(spells_new_entry.NoexpendReagent1)); - update_values.push_back(columns[67] + " = " + std::to_string(spells_new_entry.NoexpendReagent2)); - update_values.push_back(columns[68] + " = " + std::to_string(spells_new_entry.NoexpendReagent3)); - update_values.push_back(columns[69] + " = " + std::to_string(spells_new_entry.NoexpendReagent4)); - update_values.push_back(columns[70] + " = " + std::to_string(spells_new_entry.formula1)); - update_values.push_back(columns[71] + " = " + std::to_string(spells_new_entry.formula2)); - update_values.push_back(columns[72] + " = " + std::to_string(spells_new_entry.formula3)); - update_values.push_back(columns[73] + " = " + std::to_string(spells_new_entry.formula4)); - update_values.push_back(columns[74] + " = " + std::to_string(spells_new_entry.formula5)); - update_values.push_back(columns[75] + " = " + std::to_string(spells_new_entry.formula6)); - update_values.push_back(columns[76] + " = " + std::to_string(spells_new_entry.formula7)); - update_values.push_back(columns[77] + " = " + std::to_string(spells_new_entry.formula8)); - update_values.push_back(columns[78] + " = " + std::to_string(spells_new_entry.formula9)); - update_values.push_back(columns[79] + " = " + std::to_string(spells_new_entry.formula10)); - update_values.push_back(columns[80] + " = " + std::to_string(spells_new_entry.formula11)); - update_values.push_back(columns[81] + " = " + std::to_string(spells_new_entry.formula12)); - update_values.push_back(columns[82] + " = " + std::to_string(spells_new_entry.LightType)); - update_values.push_back(columns[83] + " = " + std::to_string(spells_new_entry.goodEffect)); - update_values.push_back(columns[84] + " = " + std::to_string(spells_new_entry.Activated)); - update_values.push_back(columns[85] + " = " + std::to_string(spells_new_entry.resisttype)); - update_values.push_back(columns[86] + " = " + std::to_string(spells_new_entry.effectid1)); - update_values.push_back(columns[87] + " = " + std::to_string(spells_new_entry.effectid2)); - update_values.push_back(columns[88] + " = " + std::to_string(spells_new_entry.effectid3)); - update_values.push_back(columns[89] + " = " + std::to_string(spells_new_entry.effectid4)); - update_values.push_back(columns[90] + " = " + std::to_string(spells_new_entry.effectid5)); - update_values.push_back(columns[91] + " = " + std::to_string(spells_new_entry.effectid6)); - update_values.push_back(columns[92] + " = " + std::to_string(spells_new_entry.effectid7)); - update_values.push_back(columns[93] + " = " + std::to_string(spells_new_entry.effectid8)); - update_values.push_back(columns[94] + " = " + std::to_string(spells_new_entry.effectid9)); - update_values.push_back(columns[95] + " = " + std::to_string(spells_new_entry.effectid10)); - update_values.push_back(columns[96] + " = " + std::to_string(spells_new_entry.effectid11)); - update_values.push_back(columns[97] + " = " + std::to_string(spells_new_entry.effectid12)); - update_values.push_back(columns[98] + " = " + std::to_string(spells_new_entry.targettype)); - update_values.push_back(columns[99] + " = " + std::to_string(spells_new_entry.basediff)); - update_values.push_back(columns[100] + " = " + std::to_string(spells_new_entry.skill)); - update_values.push_back(columns[101] + " = " + std::to_string(spells_new_entry.zonetype)); - update_values.push_back(columns[102] + " = " + std::to_string(spells_new_entry.EnvironmentType)); - update_values.push_back(columns[103] + " = " + std::to_string(spells_new_entry.TimeOfDay)); - update_values.push_back(columns[104] + " = " + std::to_string(spells_new_entry.classes1)); - update_values.push_back(columns[105] + " = " + std::to_string(spells_new_entry.classes2)); - update_values.push_back(columns[106] + " = " + std::to_string(spells_new_entry.classes3)); - update_values.push_back(columns[107] + " = " + std::to_string(spells_new_entry.classes4)); - update_values.push_back(columns[108] + " = " + std::to_string(spells_new_entry.classes5)); - update_values.push_back(columns[109] + " = " + std::to_string(spells_new_entry.classes6)); - update_values.push_back(columns[110] + " = " + std::to_string(spells_new_entry.classes7)); - update_values.push_back(columns[111] + " = " + std::to_string(spells_new_entry.classes8)); - update_values.push_back(columns[112] + " = " + std::to_string(spells_new_entry.classes9)); - update_values.push_back(columns[113] + " = " + std::to_string(spells_new_entry.classes10)); - update_values.push_back(columns[114] + " = " + std::to_string(spells_new_entry.classes11)); - update_values.push_back(columns[115] + " = " + std::to_string(spells_new_entry.classes12)); - update_values.push_back(columns[116] + " = " + std::to_string(spells_new_entry.classes13)); - update_values.push_back(columns[117] + " = " + std::to_string(spells_new_entry.classes14)); - update_values.push_back(columns[118] + " = " + std::to_string(spells_new_entry.classes15)); - update_values.push_back(columns[119] + " = " + std::to_string(spells_new_entry.classes16)); - update_values.push_back(columns[120] + " = " + std::to_string(spells_new_entry.CastingAnim)); - update_values.push_back(columns[121] + " = " + std::to_string(spells_new_entry.TargetAnim)); - update_values.push_back(columns[122] + " = " + std::to_string(spells_new_entry.TravelType)); - update_values.push_back(columns[123] + " = " + std::to_string(spells_new_entry.SpellAffectIndex)); - update_values.push_back(columns[124] + " = " + std::to_string(spells_new_entry.disallow_sit)); - update_values.push_back(columns[125] + " = " + std::to_string(spells_new_entry.deities0)); - update_values.push_back(columns[126] + " = " + std::to_string(spells_new_entry.deities1)); - update_values.push_back(columns[127] + " = " + std::to_string(spells_new_entry.deities2)); - update_values.push_back(columns[128] + " = " + std::to_string(spells_new_entry.deities3)); - update_values.push_back(columns[129] + " = " + std::to_string(spells_new_entry.deities4)); - update_values.push_back(columns[130] + " = " + std::to_string(spells_new_entry.deities5)); - update_values.push_back(columns[131] + " = " + std::to_string(spells_new_entry.deities6)); - update_values.push_back(columns[132] + " = " + std::to_string(spells_new_entry.deities7)); - update_values.push_back(columns[133] + " = " + std::to_string(spells_new_entry.deities8)); - update_values.push_back(columns[134] + " = " + std::to_string(spells_new_entry.deities9)); - update_values.push_back(columns[135] + " = " + std::to_string(spells_new_entry.deities10)); - update_values.push_back(columns[136] + " = " + std::to_string(spells_new_entry.deities11)); - update_values.push_back(columns[137] + " = " + std::to_string(spells_new_entry.deities12)); - update_values.push_back(columns[138] + " = " + std::to_string(spells_new_entry.deities13)); - update_values.push_back(columns[139] + " = " + std::to_string(spells_new_entry.deities14)); - update_values.push_back(columns[140] + " = " + std::to_string(spells_new_entry.deities15)); - update_values.push_back(columns[141] + " = " + std::to_string(spells_new_entry.deities16)); - update_values.push_back(columns[142] + " = " + std::to_string(spells_new_entry.field142)); - update_values.push_back(columns[143] + " = " + std::to_string(spells_new_entry.field143)); - update_values.push_back(columns[144] + " = " + std::to_string(spells_new_entry.new_icon)); - update_values.push_back(columns[145] + " = " + std::to_string(spells_new_entry.spellanim)); - update_values.push_back(columns[146] + " = " + std::to_string(spells_new_entry.uninterruptable)); - update_values.push_back(columns[147] + " = " + std::to_string(spells_new_entry.ResistDiff)); - update_values.push_back(columns[148] + " = " + std::to_string(spells_new_entry.dot_stacking_exempt)); - update_values.push_back(columns[149] + " = " + std::to_string(spells_new_entry.deleteable)); - update_values.push_back(columns[150] + " = " + std::to_string(spells_new_entry.RecourseLink)); - update_values.push_back(columns[151] + " = " + std::to_string(spells_new_entry.no_partial_resist)); - update_values.push_back(columns[152] + " = " + std::to_string(spells_new_entry.field152)); - update_values.push_back(columns[153] + " = " + std::to_string(spells_new_entry.field153)); - update_values.push_back(columns[154] + " = " + std::to_string(spells_new_entry.short_buff_box)); - update_values.push_back(columns[155] + " = " + std::to_string(spells_new_entry.descnum)); - update_values.push_back(columns[156] + " = " + std::to_string(spells_new_entry.typedescnum)); - update_values.push_back(columns[157] + " = " + std::to_string(spells_new_entry.effectdescnum)); - update_values.push_back(columns[158] + " = " + std::to_string(spells_new_entry.effectdescnum2)); - update_values.push_back(columns[159] + " = " + std::to_string(spells_new_entry.npc_no_los)); - update_values.push_back(columns[160] + " = " + std::to_string(spells_new_entry.field160)); - update_values.push_back(columns[161] + " = " + std::to_string(spells_new_entry.reflectable)); - update_values.push_back(columns[162] + " = " + std::to_string(spells_new_entry.bonushate)); - update_values.push_back(columns[163] + " = " + std::to_string(spells_new_entry.field163)); - update_values.push_back(columns[164] + " = " + std::to_string(spells_new_entry.field164)); - update_values.push_back(columns[165] + " = " + std::to_string(spells_new_entry.ldon_trap)); - update_values.push_back(columns[166] + " = " + std::to_string(spells_new_entry.EndurCost)); - update_values.push_back(columns[167] + " = " + std::to_string(spells_new_entry.EndurTimerIndex)); - update_values.push_back(columns[168] + " = " + std::to_string(spells_new_entry.IsDiscipline)); - update_values.push_back(columns[169] + " = " + std::to_string(spells_new_entry.field169)); - update_values.push_back(columns[170] + " = " + std::to_string(spells_new_entry.field170)); - update_values.push_back(columns[171] + " = " + std::to_string(spells_new_entry.field171)); - update_values.push_back(columns[172] + " = " + std::to_string(spells_new_entry.field172)); - update_values.push_back(columns[173] + " = " + std::to_string(spells_new_entry.HateAdded)); - update_values.push_back(columns[174] + " = " + std::to_string(spells_new_entry.EndurUpkeep)); - update_values.push_back(columns[175] + " = " + std::to_string(spells_new_entry.numhitstype)); - update_values.push_back(columns[176] + " = " + std::to_string(spells_new_entry.numhits)); - update_values.push_back(columns[177] + " = " + std::to_string(spells_new_entry.pvpresistbase)); - update_values.push_back(columns[178] + " = " + std::to_string(spells_new_entry.pvpresistcalc)); - update_values.push_back(columns[179] + " = " + std::to_string(spells_new_entry.pvpresistcap)); - update_values.push_back(columns[180] + " = " + std::to_string(spells_new_entry.spell_category)); - update_values.push_back(columns[181] + " = " + std::to_string(spells_new_entry.pvp_duration)); - update_values.push_back(columns[182] + " = " + std::to_string(spells_new_entry.pvp_duration_cap)); - update_values.push_back(columns[183] + " = " + std::to_string(spells_new_entry.pcnpc_only_flag)); - update_values.push_back(columns[184] + " = " + std::to_string(spells_new_entry.cast_not_standing)); - update_values.push_back(columns[185] + " = " + std::to_string(spells_new_entry.can_mgb)); - update_values.push_back(columns[186] + " = " + std::to_string(spells_new_entry.nodispell)); - update_values.push_back(columns[187] + " = " + std::to_string(spells_new_entry.npc_category)); - update_values.push_back(columns[188] + " = " + std::to_string(spells_new_entry.npc_usefulness)); - update_values.push_back(columns[189] + " = " + std::to_string(spells_new_entry.MinResist)); - update_values.push_back(columns[190] + " = " + std::to_string(spells_new_entry.MaxResist)); - update_values.push_back(columns[191] + " = " + std::to_string(spells_new_entry.viral_targets)); - update_values.push_back(columns[192] + " = " + std::to_string(spells_new_entry.viral_timer)); - update_values.push_back(columns[193] + " = " + std::to_string(spells_new_entry.nimbuseffect)); - update_values.push_back(columns[194] + " = " + std::to_string(spells_new_entry.ConeStartAngle)); - update_values.push_back(columns[195] + " = " + std::to_string(spells_new_entry.ConeStopAngle)); - update_values.push_back(columns[196] + " = " + std::to_string(spells_new_entry.sneaking)); - update_values.push_back(columns[197] + " = " + std::to_string(spells_new_entry.not_extendable)); - update_values.push_back(columns[198] + " = " + std::to_string(spells_new_entry.field198)); - update_values.push_back(columns[199] + " = " + std::to_string(spells_new_entry.field199)); - update_values.push_back(columns[200] + " = " + std::to_string(spells_new_entry.suspendable)); - update_values.push_back(columns[201] + " = " + std::to_string(spells_new_entry.viral_range)); - update_values.push_back(columns[202] + " = " + std::to_string(spells_new_entry.songcap)); - update_values.push_back(columns[203] + " = " + std::to_string(spells_new_entry.field203)); - update_values.push_back(columns[204] + " = " + std::to_string(spells_new_entry.field204)); - update_values.push_back(columns[205] + " = " + std::to_string(spells_new_entry.no_block)); - update_values.push_back(columns[206] + " = " + std::to_string(spells_new_entry.field206)); - update_values.push_back(columns[207] + " = " + std::to_string(spells_new_entry.spellgroup)); - update_values.push_back(columns[208] + " = " + std::to_string(spells_new_entry.rank)); - update_values.push_back(columns[209] + " = " + std::to_string(spells_new_entry.field209)); - update_values.push_back(columns[210] + " = " + std::to_string(spells_new_entry.field210)); - update_values.push_back(columns[211] + " = " + std::to_string(spells_new_entry.CastRestriction)); - update_values.push_back(columns[212] + " = " + std::to_string(spells_new_entry.allowrest)); - update_values.push_back(columns[213] + " = " + std::to_string(spells_new_entry.InCombat)); - update_values.push_back(columns[214] + " = " + std::to_string(spells_new_entry.OutofCombat)); - update_values.push_back(columns[215] + " = " + std::to_string(spells_new_entry.field215)); - update_values.push_back(columns[216] + " = " + std::to_string(spells_new_entry.field216)); - update_values.push_back(columns[217] + " = " + std::to_string(spells_new_entry.field217)); - update_values.push_back(columns[218] + " = " + std::to_string(spells_new_entry.aemaxtargets)); - update_values.push_back(columns[219] + " = " + std::to_string(spells_new_entry.maxtargets)); - update_values.push_back(columns[220] + " = " + std::to_string(spells_new_entry.field220)); - update_values.push_back(columns[221] + " = " + std::to_string(spells_new_entry.field221)); - update_values.push_back(columns[222] + " = " + std::to_string(spells_new_entry.field222)); - update_values.push_back(columns[223] + " = " + std::to_string(spells_new_entry.field223)); - update_values.push_back(columns[224] + " = " + std::to_string(spells_new_entry.persistdeath)); - update_values.push_back(columns[225] + " = " + std::to_string(spells_new_entry.field225)); - update_values.push_back(columns[226] + " = " + std::to_string(spells_new_entry.field226)); - update_values.push_back(columns[227] + " = " + std::to_string(spells_new_entry.min_dist)); - update_values.push_back(columns[228] + " = " + std::to_string(spells_new_entry.min_dist_mod)); - update_values.push_back(columns[229] + " = " + std::to_string(spells_new_entry.max_dist)); - update_values.push_back(columns[230] + " = " + std::to_string(spells_new_entry.max_dist_mod)); - update_values.push_back(columns[231] + " = " + std::to_string(spells_new_entry.min_range)); - update_values.push_back(columns[232] + " = " + std::to_string(spells_new_entry.field232)); - update_values.push_back(columns[233] + " = " + std::to_string(spells_new_entry.field233)); - update_values.push_back(columns[234] + " = " + std::to_string(spells_new_entry.field234)); - update_values.push_back(columns[235] + " = " + std::to_string(spells_new_entry.field235)); - update_values.push_back(columns[236] + " = " + std::to_string(spells_new_entry.field236)); + v.push_back(columns[0] + " = " + std::to_string(e.id)); + v.push_back(columns[1] + " = '" + Strings::Escape(e.name) + "'"); + v.push_back(columns[2] + " = '" + Strings::Escape(e.player_1) + "'"); + v.push_back(columns[3] + " = '" + Strings::Escape(e.teleport_zone) + "'"); + v.push_back(columns[4] + " = '" + Strings::Escape(e.you_cast) + "'"); + v.push_back(columns[5] + " = '" + Strings::Escape(e.other_casts) + "'"); + v.push_back(columns[6] + " = '" + Strings::Escape(e.cast_on_you) + "'"); + v.push_back(columns[7] + " = '" + Strings::Escape(e.cast_on_other) + "'"); + v.push_back(columns[8] + " = '" + Strings::Escape(e.spell_fades) + "'"); + v.push_back(columns[9] + " = " + std::to_string(e.range)); + v.push_back(columns[10] + " = " + std::to_string(e.aoerange)); + v.push_back(columns[11] + " = " + std::to_string(e.pushback)); + v.push_back(columns[12] + " = " + std::to_string(e.pushup)); + v.push_back(columns[13] + " = " + std::to_string(e.cast_time)); + v.push_back(columns[14] + " = " + std::to_string(e.recovery_time)); + v.push_back(columns[15] + " = " + std::to_string(e.recast_time)); + v.push_back(columns[16] + " = " + std::to_string(e.buffdurationformula)); + v.push_back(columns[17] + " = " + std::to_string(e.buffduration)); + v.push_back(columns[18] + " = " + std::to_string(e.AEDuration)); + v.push_back(columns[19] + " = " + std::to_string(e.mana)); + v.push_back(columns[20] + " = " + std::to_string(e.effect_base_value1)); + v.push_back(columns[21] + " = " + std::to_string(e.effect_base_value2)); + v.push_back(columns[22] + " = " + std::to_string(e.effect_base_value3)); + v.push_back(columns[23] + " = " + std::to_string(e.effect_base_value4)); + v.push_back(columns[24] + " = " + std::to_string(e.effect_base_value5)); + v.push_back(columns[25] + " = " + std::to_string(e.effect_base_value6)); + v.push_back(columns[26] + " = " + std::to_string(e.effect_base_value7)); + v.push_back(columns[27] + " = " + std::to_string(e.effect_base_value8)); + v.push_back(columns[28] + " = " + std::to_string(e.effect_base_value9)); + v.push_back(columns[29] + " = " + std::to_string(e.effect_base_value10)); + v.push_back(columns[30] + " = " + std::to_string(e.effect_base_value11)); + v.push_back(columns[31] + " = " + std::to_string(e.effect_base_value12)); + v.push_back(columns[32] + " = " + std::to_string(e.effect_limit_value1)); + v.push_back(columns[33] + " = " + std::to_string(e.effect_limit_value2)); + v.push_back(columns[34] + " = " + std::to_string(e.effect_limit_value3)); + v.push_back(columns[35] + " = " + std::to_string(e.effect_limit_value4)); + v.push_back(columns[36] + " = " + std::to_string(e.effect_limit_value5)); + v.push_back(columns[37] + " = " + std::to_string(e.effect_limit_value6)); + v.push_back(columns[38] + " = " + std::to_string(e.effect_limit_value7)); + v.push_back(columns[39] + " = " + std::to_string(e.effect_limit_value8)); + v.push_back(columns[40] + " = " + std::to_string(e.effect_limit_value9)); + v.push_back(columns[41] + " = " + std::to_string(e.effect_limit_value10)); + v.push_back(columns[42] + " = " + std::to_string(e.effect_limit_value11)); + v.push_back(columns[43] + " = " + std::to_string(e.effect_limit_value12)); + v.push_back(columns[44] + " = " + std::to_string(e.max1)); + v.push_back(columns[45] + " = " + std::to_string(e.max2)); + v.push_back(columns[46] + " = " + std::to_string(e.max3)); + v.push_back(columns[47] + " = " + std::to_string(e.max4)); + v.push_back(columns[48] + " = " + std::to_string(e.max5)); + v.push_back(columns[49] + " = " + std::to_string(e.max6)); + v.push_back(columns[50] + " = " + std::to_string(e.max7)); + v.push_back(columns[51] + " = " + std::to_string(e.max8)); + v.push_back(columns[52] + " = " + std::to_string(e.max9)); + v.push_back(columns[53] + " = " + std::to_string(e.max10)); + v.push_back(columns[54] + " = " + std::to_string(e.max11)); + v.push_back(columns[55] + " = " + std::to_string(e.max12)); + v.push_back(columns[56] + " = " + std::to_string(e.icon)); + v.push_back(columns[57] + " = " + std::to_string(e.memicon)); + v.push_back(columns[58] + " = " + std::to_string(e.components1)); + v.push_back(columns[59] + " = " + std::to_string(e.components2)); + v.push_back(columns[60] + " = " + std::to_string(e.components3)); + v.push_back(columns[61] + " = " + std::to_string(e.components4)); + v.push_back(columns[62] + " = " + std::to_string(e.component_counts1)); + v.push_back(columns[63] + " = " + std::to_string(e.component_counts2)); + v.push_back(columns[64] + " = " + std::to_string(e.component_counts3)); + v.push_back(columns[65] + " = " + std::to_string(e.component_counts4)); + v.push_back(columns[66] + " = " + std::to_string(e.NoexpendReagent1)); + v.push_back(columns[67] + " = " + std::to_string(e.NoexpendReagent2)); + v.push_back(columns[68] + " = " + std::to_string(e.NoexpendReagent3)); + v.push_back(columns[69] + " = " + std::to_string(e.NoexpendReagent4)); + v.push_back(columns[70] + " = " + std::to_string(e.formula1)); + v.push_back(columns[71] + " = " + std::to_string(e.formula2)); + v.push_back(columns[72] + " = " + std::to_string(e.formula3)); + v.push_back(columns[73] + " = " + std::to_string(e.formula4)); + v.push_back(columns[74] + " = " + std::to_string(e.formula5)); + v.push_back(columns[75] + " = " + std::to_string(e.formula6)); + v.push_back(columns[76] + " = " + std::to_string(e.formula7)); + v.push_back(columns[77] + " = " + std::to_string(e.formula8)); + v.push_back(columns[78] + " = " + std::to_string(e.formula9)); + v.push_back(columns[79] + " = " + std::to_string(e.formula10)); + v.push_back(columns[80] + " = " + std::to_string(e.formula11)); + v.push_back(columns[81] + " = " + std::to_string(e.formula12)); + v.push_back(columns[82] + " = " + std::to_string(e.LightType)); + v.push_back(columns[83] + " = " + std::to_string(e.goodEffect)); + v.push_back(columns[84] + " = " + std::to_string(e.Activated)); + v.push_back(columns[85] + " = " + std::to_string(e.resisttype)); + v.push_back(columns[86] + " = " + std::to_string(e.effectid1)); + v.push_back(columns[87] + " = " + std::to_string(e.effectid2)); + v.push_back(columns[88] + " = " + std::to_string(e.effectid3)); + v.push_back(columns[89] + " = " + std::to_string(e.effectid4)); + v.push_back(columns[90] + " = " + std::to_string(e.effectid5)); + v.push_back(columns[91] + " = " + std::to_string(e.effectid6)); + v.push_back(columns[92] + " = " + std::to_string(e.effectid7)); + v.push_back(columns[93] + " = " + std::to_string(e.effectid8)); + v.push_back(columns[94] + " = " + std::to_string(e.effectid9)); + v.push_back(columns[95] + " = " + std::to_string(e.effectid10)); + v.push_back(columns[96] + " = " + std::to_string(e.effectid11)); + v.push_back(columns[97] + " = " + std::to_string(e.effectid12)); + v.push_back(columns[98] + " = " + std::to_string(e.targettype)); + v.push_back(columns[99] + " = " + std::to_string(e.basediff)); + v.push_back(columns[100] + " = " + std::to_string(e.skill)); + v.push_back(columns[101] + " = " + std::to_string(e.zonetype)); + v.push_back(columns[102] + " = " + std::to_string(e.EnvironmentType)); + v.push_back(columns[103] + " = " + std::to_string(e.TimeOfDay)); + v.push_back(columns[104] + " = " + std::to_string(e.classes1)); + v.push_back(columns[105] + " = " + std::to_string(e.classes2)); + v.push_back(columns[106] + " = " + std::to_string(e.classes3)); + v.push_back(columns[107] + " = " + std::to_string(e.classes4)); + v.push_back(columns[108] + " = " + std::to_string(e.classes5)); + v.push_back(columns[109] + " = " + std::to_string(e.classes6)); + v.push_back(columns[110] + " = " + std::to_string(e.classes7)); + v.push_back(columns[111] + " = " + std::to_string(e.classes8)); + v.push_back(columns[112] + " = " + std::to_string(e.classes9)); + v.push_back(columns[113] + " = " + std::to_string(e.classes10)); + v.push_back(columns[114] + " = " + std::to_string(e.classes11)); + v.push_back(columns[115] + " = " + std::to_string(e.classes12)); + v.push_back(columns[116] + " = " + std::to_string(e.classes13)); + v.push_back(columns[117] + " = " + std::to_string(e.classes14)); + v.push_back(columns[118] + " = " + std::to_string(e.classes15)); + v.push_back(columns[119] + " = " + std::to_string(e.classes16)); + v.push_back(columns[120] + " = " + std::to_string(e.CastingAnim)); + v.push_back(columns[121] + " = " + std::to_string(e.TargetAnim)); + v.push_back(columns[122] + " = " + std::to_string(e.TravelType)); + v.push_back(columns[123] + " = " + std::to_string(e.SpellAffectIndex)); + v.push_back(columns[124] + " = " + std::to_string(e.disallow_sit)); + v.push_back(columns[125] + " = " + std::to_string(e.deities0)); + v.push_back(columns[126] + " = " + std::to_string(e.deities1)); + v.push_back(columns[127] + " = " + std::to_string(e.deities2)); + v.push_back(columns[128] + " = " + std::to_string(e.deities3)); + v.push_back(columns[129] + " = " + std::to_string(e.deities4)); + v.push_back(columns[130] + " = " + std::to_string(e.deities5)); + v.push_back(columns[131] + " = " + std::to_string(e.deities6)); + v.push_back(columns[132] + " = " + std::to_string(e.deities7)); + v.push_back(columns[133] + " = " + std::to_string(e.deities8)); + v.push_back(columns[134] + " = " + std::to_string(e.deities9)); + v.push_back(columns[135] + " = " + std::to_string(e.deities10)); + v.push_back(columns[136] + " = " + std::to_string(e.deities11)); + v.push_back(columns[137] + " = " + std::to_string(e.deities12)); + v.push_back(columns[138] + " = " + std::to_string(e.deities13)); + v.push_back(columns[139] + " = " + std::to_string(e.deities14)); + v.push_back(columns[140] + " = " + std::to_string(e.deities15)); + v.push_back(columns[141] + " = " + std::to_string(e.deities16)); + v.push_back(columns[142] + " = " + std::to_string(e.field142)); + v.push_back(columns[143] + " = " + std::to_string(e.field143)); + v.push_back(columns[144] + " = " + std::to_string(e.new_icon)); + v.push_back(columns[145] + " = " + std::to_string(e.spellanim)); + v.push_back(columns[146] + " = " + std::to_string(e.uninterruptable)); + v.push_back(columns[147] + " = " + std::to_string(e.ResistDiff)); + v.push_back(columns[148] + " = " + std::to_string(e.dot_stacking_exempt)); + v.push_back(columns[149] + " = " + std::to_string(e.deleteable)); + v.push_back(columns[150] + " = " + std::to_string(e.RecourseLink)); + v.push_back(columns[151] + " = " + std::to_string(e.no_partial_resist)); + v.push_back(columns[152] + " = " + std::to_string(e.field152)); + v.push_back(columns[153] + " = " + std::to_string(e.field153)); + v.push_back(columns[154] + " = " + std::to_string(e.short_buff_box)); + v.push_back(columns[155] + " = " + std::to_string(e.descnum)); + v.push_back(columns[156] + " = " + std::to_string(e.typedescnum)); + v.push_back(columns[157] + " = " + std::to_string(e.effectdescnum)); + v.push_back(columns[158] + " = " + std::to_string(e.effectdescnum2)); + v.push_back(columns[159] + " = " + std::to_string(e.npc_no_los)); + v.push_back(columns[160] + " = " + std::to_string(e.field160)); + v.push_back(columns[161] + " = " + std::to_string(e.reflectable)); + v.push_back(columns[162] + " = " + std::to_string(e.bonushate)); + v.push_back(columns[163] + " = " + std::to_string(e.field163)); + v.push_back(columns[164] + " = " + std::to_string(e.field164)); + v.push_back(columns[165] + " = " + std::to_string(e.ldon_trap)); + v.push_back(columns[166] + " = " + std::to_string(e.EndurCost)); + v.push_back(columns[167] + " = " + std::to_string(e.EndurTimerIndex)); + v.push_back(columns[168] + " = " + std::to_string(e.IsDiscipline)); + v.push_back(columns[169] + " = " + std::to_string(e.field169)); + v.push_back(columns[170] + " = " + std::to_string(e.field170)); + v.push_back(columns[171] + " = " + std::to_string(e.field171)); + v.push_back(columns[172] + " = " + std::to_string(e.field172)); + v.push_back(columns[173] + " = " + std::to_string(e.HateAdded)); + v.push_back(columns[174] + " = " + std::to_string(e.EndurUpkeep)); + v.push_back(columns[175] + " = " + std::to_string(e.numhitstype)); + v.push_back(columns[176] + " = " + std::to_string(e.numhits)); + v.push_back(columns[177] + " = " + std::to_string(e.pvpresistbase)); + v.push_back(columns[178] + " = " + std::to_string(e.pvpresistcalc)); + v.push_back(columns[179] + " = " + std::to_string(e.pvpresistcap)); + v.push_back(columns[180] + " = " + std::to_string(e.spell_category)); + v.push_back(columns[181] + " = " + std::to_string(e.pvp_duration)); + v.push_back(columns[182] + " = " + std::to_string(e.pvp_duration_cap)); + v.push_back(columns[183] + " = " + std::to_string(e.pcnpc_only_flag)); + v.push_back(columns[184] + " = " + std::to_string(e.cast_not_standing)); + v.push_back(columns[185] + " = " + std::to_string(e.can_mgb)); + v.push_back(columns[186] + " = " + std::to_string(e.nodispell)); + v.push_back(columns[187] + " = " + std::to_string(e.npc_category)); + v.push_back(columns[188] + " = " + std::to_string(e.npc_usefulness)); + v.push_back(columns[189] + " = " + std::to_string(e.MinResist)); + v.push_back(columns[190] + " = " + std::to_string(e.MaxResist)); + v.push_back(columns[191] + " = " + std::to_string(e.viral_targets)); + v.push_back(columns[192] + " = " + std::to_string(e.viral_timer)); + v.push_back(columns[193] + " = " + std::to_string(e.nimbuseffect)); + v.push_back(columns[194] + " = " + std::to_string(e.ConeStartAngle)); + v.push_back(columns[195] + " = " + std::to_string(e.ConeStopAngle)); + v.push_back(columns[196] + " = " + std::to_string(e.sneaking)); + v.push_back(columns[197] + " = " + std::to_string(e.not_extendable)); + v.push_back(columns[198] + " = " + std::to_string(e.field198)); + v.push_back(columns[199] + " = " + std::to_string(e.field199)); + v.push_back(columns[200] + " = " + std::to_string(e.suspendable)); + v.push_back(columns[201] + " = " + std::to_string(e.viral_range)); + v.push_back(columns[202] + " = " + std::to_string(e.songcap)); + v.push_back(columns[203] + " = " + std::to_string(e.field203)); + v.push_back(columns[204] + " = " + std::to_string(e.field204)); + v.push_back(columns[205] + " = " + std::to_string(e.no_block)); + v.push_back(columns[206] + " = " + std::to_string(e.field206)); + v.push_back(columns[207] + " = " + std::to_string(e.spellgroup)); + v.push_back(columns[208] + " = " + std::to_string(e.rank)); + v.push_back(columns[209] + " = " + std::to_string(e.field209)); + v.push_back(columns[210] + " = " + std::to_string(e.field210)); + v.push_back(columns[211] + " = " + std::to_string(e.CastRestriction)); + v.push_back(columns[212] + " = " + std::to_string(e.allowrest)); + v.push_back(columns[213] + " = " + std::to_string(e.InCombat)); + v.push_back(columns[214] + " = " + std::to_string(e.OutofCombat)); + v.push_back(columns[215] + " = " + std::to_string(e.field215)); + v.push_back(columns[216] + " = " + std::to_string(e.field216)); + v.push_back(columns[217] + " = " + std::to_string(e.field217)); + v.push_back(columns[218] + " = " + std::to_string(e.aemaxtargets)); + v.push_back(columns[219] + " = " + std::to_string(e.maxtargets)); + v.push_back(columns[220] + " = " + std::to_string(e.field220)); + v.push_back(columns[221] + " = " + std::to_string(e.field221)); + v.push_back(columns[222] + " = " + std::to_string(e.field222)); + v.push_back(columns[223] + " = " + std::to_string(e.field223)); + v.push_back(columns[224] + " = " + std::to_string(e.persistdeath)); + v.push_back(columns[225] + " = " + std::to_string(e.field225)); + v.push_back(columns[226] + " = " + std::to_string(e.field226)); + v.push_back(columns[227] + " = " + std::to_string(e.min_dist)); + v.push_back(columns[228] + " = " + std::to_string(e.min_dist_mod)); + v.push_back(columns[229] + " = " + std::to_string(e.max_dist)); + v.push_back(columns[230] + " = " + std::to_string(e.max_dist_mod)); + v.push_back(columns[231] + " = " + std::to_string(e.min_range)); + v.push_back(columns[232] + " = " + std::to_string(e.field232)); + v.push_back(columns[233] + " = " + std::to_string(e.field233)); + v.push_back(columns[234] + " = " + std::to_string(e.field234)); + v.push_back(columns[235] + " = " + std::to_string(e.field235)); + v.push_back(columns[236] + " = " + std::to_string(e.field236)); auto results = db.QueryDatabase( fmt::format( "UPDATE {} SET {} WHERE {} = {}", TableName(), - Strings::Implode(", ", update_values), + Strings::Implode(", ", v), PrimaryKey(), - spells_new_entry.id + e.id ) ); @@ -1581,519 +1581,519 @@ public: static SpellsNew InsertOne( Database& db, - SpellsNew spells_new_entry + SpellsNew e ) { - std::vector insert_values; + std::vector v; - insert_values.push_back(std::to_string(spells_new_entry.id)); - insert_values.push_back("'" + Strings::Escape(spells_new_entry.name) + "'"); - insert_values.push_back("'" + Strings::Escape(spells_new_entry.player_1) + "'"); - insert_values.push_back("'" + Strings::Escape(spells_new_entry.teleport_zone) + "'"); - insert_values.push_back("'" + Strings::Escape(spells_new_entry.you_cast) + "'"); - insert_values.push_back("'" + Strings::Escape(spells_new_entry.other_casts) + "'"); - insert_values.push_back("'" + Strings::Escape(spells_new_entry.cast_on_you) + "'"); - insert_values.push_back("'" + Strings::Escape(spells_new_entry.cast_on_other) + "'"); - insert_values.push_back("'" + Strings::Escape(spells_new_entry.spell_fades) + "'"); - insert_values.push_back(std::to_string(spells_new_entry.range)); - insert_values.push_back(std::to_string(spells_new_entry.aoerange)); - insert_values.push_back(std::to_string(spells_new_entry.pushback)); - insert_values.push_back(std::to_string(spells_new_entry.pushup)); - insert_values.push_back(std::to_string(spells_new_entry.cast_time)); - insert_values.push_back(std::to_string(spells_new_entry.recovery_time)); - insert_values.push_back(std::to_string(spells_new_entry.recast_time)); - insert_values.push_back(std::to_string(spells_new_entry.buffdurationformula)); - insert_values.push_back(std::to_string(spells_new_entry.buffduration)); - insert_values.push_back(std::to_string(spells_new_entry.AEDuration)); - insert_values.push_back(std::to_string(spells_new_entry.mana)); - insert_values.push_back(std::to_string(spells_new_entry.effect_base_value1)); - insert_values.push_back(std::to_string(spells_new_entry.effect_base_value2)); - insert_values.push_back(std::to_string(spells_new_entry.effect_base_value3)); - insert_values.push_back(std::to_string(spells_new_entry.effect_base_value4)); - insert_values.push_back(std::to_string(spells_new_entry.effect_base_value5)); - insert_values.push_back(std::to_string(spells_new_entry.effect_base_value6)); - insert_values.push_back(std::to_string(spells_new_entry.effect_base_value7)); - insert_values.push_back(std::to_string(spells_new_entry.effect_base_value8)); - insert_values.push_back(std::to_string(spells_new_entry.effect_base_value9)); - insert_values.push_back(std::to_string(spells_new_entry.effect_base_value10)); - insert_values.push_back(std::to_string(spells_new_entry.effect_base_value11)); - insert_values.push_back(std::to_string(spells_new_entry.effect_base_value12)); - insert_values.push_back(std::to_string(spells_new_entry.effect_limit_value1)); - insert_values.push_back(std::to_string(spells_new_entry.effect_limit_value2)); - insert_values.push_back(std::to_string(spells_new_entry.effect_limit_value3)); - insert_values.push_back(std::to_string(spells_new_entry.effect_limit_value4)); - insert_values.push_back(std::to_string(spells_new_entry.effect_limit_value5)); - insert_values.push_back(std::to_string(spells_new_entry.effect_limit_value6)); - insert_values.push_back(std::to_string(spells_new_entry.effect_limit_value7)); - insert_values.push_back(std::to_string(spells_new_entry.effect_limit_value8)); - insert_values.push_back(std::to_string(spells_new_entry.effect_limit_value9)); - insert_values.push_back(std::to_string(spells_new_entry.effect_limit_value10)); - insert_values.push_back(std::to_string(spells_new_entry.effect_limit_value11)); - insert_values.push_back(std::to_string(spells_new_entry.effect_limit_value12)); - insert_values.push_back(std::to_string(spells_new_entry.max1)); - insert_values.push_back(std::to_string(spells_new_entry.max2)); - insert_values.push_back(std::to_string(spells_new_entry.max3)); - insert_values.push_back(std::to_string(spells_new_entry.max4)); - insert_values.push_back(std::to_string(spells_new_entry.max5)); - insert_values.push_back(std::to_string(spells_new_entry.max6)); - insert_values.push_back(std::to_string(spells_new_entry.max7)); - insert_values.push_back(std::to_string(spells_new_entry.max8)); - insert_values.push_back(std::to_string(spells_new_entry.max9)); - insert_values.push_back(std::to_string(spells_new_entry.max10)); - insert_values.push_back(std::to_string(spells_new_entry.max11)); - insert_values.push_back(std::to_string(spells_new_entry.max12)); - insert_values.push_back(std::to_string(spells_new_entry.icon)); - insert_values.push_back(std::to_string(spells_new_entry.memicon)); - insert_values.push_back(std::to_string(spells_new_entry.components1)); - insert_values.push_back(std::to_string(spells_new_entry.components2)); - insert_values.push_back(std::to_string(spells_new_entry.components3)); - insert_values.push_back(std::to_string(spells_new_entry.components4)); - insert_values.push_back(std::to_string(spells_new_entry.component_counts1)); - insert_values.push_back(std::to_string(spells_new_entry.component_counts2)); - insert_values.push_back(std::to_string(spells_new_entry.component_counts3)); - insert_values.push_back(std::to_string(spells_new_entry.component_counts4)); - insert_values.push_back(std::to_string(spells_new_entry.NoexpendReagent1)); - insert_values.push_back(std::to_string(spells_new_entry.NoexpendReagent2)); - insert_values.push_back(std::to_string(spells_new_entry.NoexpendReagent3)); - insert_values.push_back(std::to_string(spells_new_entry.NoexpendReagent4)); - insert_values.push_back(std::to_string(spells_new_entry.formula1)); - insert_values.push_back(std::to_string(spells_new_entry.formula2)); - insert_values.push_back(std::to_string(spells_new_entry.formula3)); - insert_values.push_back(std::to_string(spells_new_entry.formula4)); - insert_values.push_back(std::to_string(spells_new_entry.formula5)); - insert_values.push_back(std::to_string(spells_new_entry.formula6)); - insert_values.push_back(std::to_string(spells_new_entry.formula7)); - insert_values.push_back(std::to_string(spells_new_entry.formula8)); - insert_values.push_back(std::to_string(spells_new_entry.formula9)); - insert_values.push_back(std::to_string(spells_new_entry.formula10)); - insert_values.push_back(std::to_string(spells_new_entry.formula11)); - insert_values.push_back(std::to_string(spells_new_entry.formula12)); - insert_values.push_back(std::to_string(spells_new_entry.LightType)); - insert_values.push_back(std::to_string(spells_new_entry.goodEffect)); - insert_values.push_back(std::to_string(spells_new_entry.Activated)); - insert_values.push_back(std::to_string(spells_new_entry.resisttype)); - insert_values.push_back(std::to_string(spells_new_entry.effectid1)); - insert_values.push_back(std::to_string(spells_new_entry.effectid2)); - insert_values.push_back(std::to_string(spells_new_entry.effectid3)); - insert_values.push_back(std::to_string(spells_new_entry.effectid4)); - insert_values.push_back(std::to_string(spells_new_entry.effectid5)); - insert_values.push_back(std::to_string(spells_new_entry.effectid6)); - insert_values.push_back(std::to_string(spells_new_entry.effectid7)); - insert_values.push_back(std::to_string(spells_new_entry.effectid8)); - insert_values.push_back(std::to_string(spells_new_entry.effectid9)); - insert_values.push_back(std::to_string(spells_new_entry.effectid10)); - insert_values.push_back(std::to_string(spells_new_entry.effectid11)); - insert_values.push_back(std::to_string(spells_new_entry.effectid12)); - insert_values.push_back(std::to_string(spells_new_entry.targettype)); - insert_values.push_back(std::to_string(spells_new_entry.basediff)); - insert_values.push_back(std::to_string(spells_new_entry.skill)); - insert_values.push_back(std::to_string(spells_new_entry.zonetype)); - insert_values.push_back(std::to_string(spells_new_entry.EnvironmentType)); - insert_values.push_back(std::to_string(spells_new_entry.TimeOfDay)); - insert_values.push_back(std::to_string(spells_new_entry.classes1)); - insert_values.push_back(std::to_string(spells_new_entry.classes2)); - insert_values.push_back(std::to_string(spells_new_entry.classes3)); - insert_values.push_back(std::to_string(spells_new_entry.classes4)); - insert_values.push_back(std::to_string(spells_new_entry.classes5)); - insert_values.push_back(std::to_string(spells_new_entry.classes6)); - insert_values.push_back(std::to_string(spells_new_entry.classes7)); - insert_values.push_back(std::to_string(spells_new_entry.classes8)); - insert_values.push_back(std::to_string(spells_new_entry.classes9)); - insert_values.push_back(std::to_string(spells_new_entry.classes10)); - insert_values.push_back(std::to_string(spells_new_entry.classes11)); - insert_values.push_back(std::to_string(spells_new_entry.classes12)); - insert_values.push_back(std::to_string(spells_new_entry.classes13)); - insert_values.push_back(std::to_string(spells_new_entry.classes14)); - insert_values.push_back(std::to_string(spells_new_entry.classes15)); - insert_values.push_back(std::to_string(spells_new_entry.classes16)); - insert_values.push_back(std::to_string(spells_new_entry.CastingAnim)); - insert_values.push_back(std::to_string(spells_new_entry.TargetAnim)); - insert_values.push_back(std::to_string(spells_new_entry.TravelType)); - insert_values.push_back(std::to_string(spells_new_entry.SpellAffectIndex)); - insert_values.push_back(std::to_string(spells_new_entry.disallow_sit)); - insert_values.push_back(std::to_string(spells_new_entry.deities0)); - insert_values.push_back(std::to_string(spells_new_entry.deities1)); - insert_values.push_back(std::to_string(spells_new_entry.deities2)); - insert_values.push_back(std::to_string(spells_new_entry.deities3)); - insert_values.push_back(std::to_string(spells_new_entry.deities4)); - insert_values.push_back(std::to_string(spells_new_entry.deities5)); - insert_values.push_back(std::to_string(spells_new_entry.deities6)); - insert_values.push_back(std::to_string(spells_new_entry.deities7)); - insert_values.push_back(std::to_string(spells_new_entry.deities8)); - insert_values.push_back(std::to_string(spells_new_entry.deities9)); - insert_values.push_back(std::to_string(spells_new_entry.deities10)); - insert_values.push_back(std::to_string(spells_new_entry.deities11)); - insert_values.push_back(std::to_string(spells_new_entry.deities12)); - insert_values.push_back(std::to_string(spells_new_entry.deities13)); - insert_values.push_back(std::to_string(spells_new_entry.deities14)); - insert_values.push_back(std::to_string(spells_new_entry.deities15)); - insert_values.push_back(std::to_string(spells_new_entry.deities16)); - insert_values.push_back(std::to_string(spells_new_entry.field142)); - insert_values.push_back(std::to_string(spells_new_entry.field143)); - insert_values.push_back(std::to_string(spells_new_entry.new_icon)); - insert_values.push_back(std::to_string(spells_new_entry.spellanim)); - insert_values.push_back(std::to_string(spells_new_entry.uninterruptable)); - insert_values.push_back(std::to_string(spells_new_entry.ResistDiff)); - insert_values.push_back(std::to_string(spells_new_entry.dot_stacking_exempt)); - insert_values.push_back(std::to_string(spells_new_entry.deleteable)); - insert_values.push_back(std::to_string(spells_new_entry.RecourseLink)); - insert_values.push_back(std::to_string(spells_new_entry.no_partial_resist)); - insert_values.push_back(std::to_string(spells_new_entry.field152)); - insert_values.push_back(std::to_string(spells_new_entry.field153)); - insert_values.push_back(std::to_string(spells_new_entry.short_buff_box)); - insert_values.push_back(std::to_string(spells_new_entry.descnum)); - insert_values.push_back(std::to_string(spells_new_entry.typedescnum)); - insert_values.push_back(std::to_string(spells_new_entry.effectdescnum)); - insert_values.push_back(std::to_string(spells_new_entry.effectdescnum2)); - insert_values.push_back(std::to_string(spells_new_entry.npc_no_los)); - insert_values.push_back(std::to_string(spells_new_entry.field160)); - insert_values.push_back(std::to_string(spells_new_entry.reflectable)); - insert_values.push_back(std::to_string(spells_new_entry.bonushate)); - insert_values.push_back(std::to_string(spells_new_entry.field163)); - insert_values.push_back(std::to_string(spells_new_entry.field164)); - insert_values.push_back(std::to_string(spells_new_entry.ldon_trap)); - insert_values.push_back(std::to_string(spells_new_entry.EndurCost)); - insert_values.push_back(std::to_string(spells_new_entry.EndurTimerIndex)); - insert_values.push_back(std::to_string(spells_new_entry.IsDiscipline)); - insert_values.push_back(std::to_string(spells_new_entry.field169)); - insert_values.push_back(std::to_string(spells_new_entry.field170)); - insert_values.push_back(std::to_string(spells_new_entry.field171)); - insert_values.push_back(std::to_string(spells_new_entry.field172)); - insert_values.push_back(std::to_string(spells_new_entry.HateAdded)); - insert_values.push_back(std::to_string(spells_new_entry.EndurUpkeep)); - insert_values.push_back(std::to_string(spells_new_entry.numhitstype)); - insert_values.push_back(std::to_string(spells_new_entry.numhits)); - insert_values.push_back(std::to_string(spells_new_entry.pvpresistbase)); - insert_values.push_back(std::to_string(spells_new_entry.pvpresistcalc)); - insert_values.push_back(std::to_string(spells_new_entry.pvpresistcap)); - insert_values.push_back(std::to_string(spells_new_entry.spell_category)); - insert_values.push_back(std::to_string(spells_new_entry.pvp_duration)); - insert_values.push_back(std::to_string(spells_new_entry.pvp_duration_cap)); - insert_values.push_back(std::to_string(spells_new_entry.pcnpc_only_flag)); - insert_values.push_back(std::to_string(spells_new_entry.cast_not_standing)); - insert_values.push_back(std::to_string(spells_new_entry.can_mgb)); - insert_values.push_back(std::to_string(spells_new_entry.nodispell)); - insert_values.push_back(std::to_string(spells_new_entry.npc_category)); - insert_values.push_back(std::to_string(spells_new_entry.npc_usefulness)); - insert_values.push_back(std::to_string(spells_new_entry.MinResist)); - insert_values.push_back(std::to_string(spells_new_entry.MaxResist)); - insert_values.push_back(std::to_string(spells_new_entry.viral_targets)); - insert_values.push_back(std::to_string(spells_new_entry.viral_timer)); - insert_values.push_back(std::to_string(spells_new_entry.nimbuseffect)); - insert_values.push_back(std::to_string(spells_new_entry.ConeStartAngle)); - insert_values.push_back(std::to_string(spells_new_entry.ConeStopAngle)); - insert_values.push_back(std::to_string(spells_new_entry.sneaking)); - insert_values.push_back(std::to_string(spells_new_entry.not_extendable)); - insert_values.push_back(std::to_string(spells_new_entry.field198)); - insert_values.push_back(std::to_string(spells_new_entry.field199)); - insert_values.push_back(std::to_string(spells_new_entry.suspendable)); - insert_values.push_back(std::to_string(spells_new_entry.viral_range)); - insert_values.push_back(std::to_string(spells_new_entry.songcap)); - insert_values.push_back(std::to_string(spells_new_entry.field203)); - insert_values.push_back(std::to_string(spells_new_entry.field204)); - insert_values.push_back(std::to_string(spells_new_entry.no_block)); - insert_values.push_back(std::to_string(spells_new_entry.field206)); - insert_values.push_back(std::to_string(spells_new_entry.spellgroup)); - insert_values.push_back(std::to_string(spells_new_entry.rank)); - insert_values.push_back(std::to_string(spells_new_entry.field209)); - insert_values.push_back(std::to_string(spells_new_entry.field210)); - insert_values.push_back(std::to_string(spells_new_entry.CastRestriction)); - insert_values.push_back(std::to_string(spells_new_entry.allowrest)); - insert_values.push_back(std::to_string(spells_new_entry.InCombat)); - insert_values.push_back(std::to_string(spells_new_entry.OutofCombat)); - insert_values.push_back(std::to_string(spells_new_entry.field215)); - insert_values.push_back(std::to_string(spells_new_entry.field216)); - insert_values.push_back(std::to_string(spells_new_entry.field217)); - insert_values.push_back(std::to_string(spells_new_entry.aemaxtargets)); - insert_values.push_back(std::to_string(spells_new_entry.maxtargets)); - insert_values.push_back(std::to_string(spells_new_entry.field220)); - insert_values.push_back(std::to_string(spells_new_entry.field221)); - insert_values.push_back(std::to_string(spells_new_entry.field222)); - insert_values.push_back(std::to_string(spells_new_entry.field223)); - insert_values.push_back(std::to_string(spells_new_entry.persistdeath)); - insert_values.push_back(std::to_string(spells_new_entry.field225)); - insert_values.push_back(std::to_string(spells_new_entry.field226)); - insert_values.push_back(std::to_string(spells_new_entry.min_dist)); - insert_values.push_back(std::to_string(spells_new_entry.min_dist_mod)); - insert_values.push_back(std::to_string(spells_new_entry.max_dist)); - insert_values.push_back(std::to_string(spells_new_entry.max_dist_mod)); - insert_values.push_back(std::to_string(spells_new_entry.min_range)); - insert_values.push_back(std::to_string(spells_new_entry.field232)); - insert_values.push_back(std::to_string(spells_new_entry.field233)); - insert_values.push_back(std::to_string(spells_new_entry.field234)); - insert_values.push_back(std::to_string(spells_new_entry.field235)); - insert_values.push_back(std::to_string(spells_new_entry.field236)); + v.push_back(std::to_string(e.id)); + v.push_back("'" + Strings::Escape(e.name) + "'"); + v.push_back("'" + Strings::Escape(e.player_1) + "'"); + v.push_back("'" + Strings::Escape(e.teleport_zone) + "'"); + v.push_back("'" + Strings::Escape(e.you_cast) + "'"); + v.push_back("'" + Strings::Escape(e.other_casts) + "'"); + v.push_back("'" + Strings::Escape(e.cast_on_you) + "'"); + v.push_back("'" + Strings::Escape(e.cast_on_other) + "'"); + v.push_back("'" + Strings::Escape(e.spell_fades) + "'"); + v.push_back(std::to_string(e.range)); + v.push_back(std::to_string(e.aoerange)); + v.push_back(std::to_string(e.pushback)); + v.push_back(std::to_string(e.pushup)); + v.push_back(std::to_string(e.cast_time)); + v.push_back(std::to_string(e.recovery_time)); + v.push_back(std::to_string(e.recast_time)); + v.push_back(std::to_string(e.buffdurationformula)); + v.push_back(std::to_string(e.buffduration)); + v.push_back(std::to_string(e.AEDuration)); + v.push_back(std::to_string(e.mana)); + v.push_back(std::to_string(e.effect_base_value1)); + v.push_back(std::to_string(e.effect_base_value2)); + v.push_back(std::to_string(e.effect_base_value3)); + v.push_back(std::to_string(e.effect_base_value4)); + v.push_back(std::to_string(e.effect_base_value5)); + v.push_back(std::to_string(e.effect_base_value6)); + v.push_back(std::to_string(e.effect_base_value7)); + v.push_back(std::to_string(e.effect_base_value8)); + v.push_back(std::to_string(e.effect_base_value9)); + v.push_back(std::to_string(e.effect_base_value10)); + v.push_back(std::to_string(e.effect_base_value11)); + v.push_back(std::to_string(e.effect_base_value12)); + v.push_back(std::to_string(e.effect_limit_value1)); + v.push_back(std::to_string(e.effect_limit_value2)); + v.push_back(std::to_string(e.effect_limit_value3)); + v.push_back(std::to_string(e.effect_limit_value4)); + v.push_back(std::to_string(e.effect_limit_value5)); + v.push_back(std::to_string(e.effect_limit_value6)); + v.push_back(std::to_string(e.effect_limit_value7)); + v.push_back(std::to_string(e.effect_limit_value8)); + v.push_back(std::to_string(e.effect_limit_value9)); + v.push_back(std::to_string(e.effect_limit_value10)); + v.push_back(std::to_string(e.effect_limit_value11)); + v.push_back(std::to_string(e.effect_limit_value12)); + v.push_back(std::to_string(e.max1)); + v.push_back(std::to_string(e.max2)); + v.push_back(std::to_string(e.max3)); + v.push_back(std::to_string(e.max4)); + v.push_back(std::to_string(e.max5)); + v.push_back(std::to_string(e.max6)); + v.push_back(std::to_string(e.max7)); + v.push_back(std::to_string(e.max8)); + v.push_back(std::to_string(e.max9)); + v.push_back(std::to_string(e.max10)); + v.push_back(std::to_string(e.max11)); + v.push_back(std::to_string(e.max12)); + v.push_back(std::to_string(e.icon)); + v.push_back(std::to_string(e.memicon)); + v.push_back(std::to_string(e.components1)); + v.push_back(std::to_string(e.components2)); + v.push_back(std::to_string(e.components3)); + v.push_back(std::to_string(e.components4)); + v.push_back(std::to_string(e.component_counts1)); + v.push_back(std::to_string(e.component_counts2)); + v.push_back(std::to_string(e.component_counts3)); + v.push_back(std::to_string(e.component_counts4)); + v.push_back(std::to_string(e.NoexpendReagent1)); + v.push_back(std::to_string(e.NoexpendReagent2)); + v.push_back(std::to_string(e.NoexpendReagent3)); + v.push_back(std::to_string(e.NoexpendReagent4)); + v.push_back(std::to_string(e.formula1)); + v.push_back(std::to_string(e.formula2)); + v.push_back(std::to_string(e.formula3)); + v.push_back(std::to_string(e.formula4)); + v.push_back(std::to_string(e.formula5)); + v.push_back(std::to_string(e.formula6)); + v.push_back(std::to_string(e.formula7)); + v.push_back(std::to_string(e.formula8)); + v.push_back(std::to_string(e.formula9)); + v.push_back(std::to_string(e.formula10)); + v.push_back(std::to_string(e.formula11)); + v.push_back(std::to_string(e.formula12)); + v.push_back(std::to_string(e.LightType)); + v.push_back(std::to_string(e.goodEffect)); + v.push_back(std::to_string(e.Activated)); + v.push_back(std::to_string(e.resisttype)); + v.push_back(std::to_string(e.effectid1)); + v.push_back(std::to_string(e.effectid2)); + v.push_back(std::to_string(e.effectid3)); + v.push_back(std::to_string(e.effectid4)); + v.push_back(std::to_string(e.effectid5)); + v.push_back(std::to_string(e.effectid6)); + v.push_back(std::to_string(e.effectid7)); + v.push_back(std::to_string(e.effectid8)); + v.push_back(std::to_string(e.effectid9)); + v.push_back(std::to_string(e.effectid10)); + v.push_back(std::to_string(e.effectid11)); + v.push_back(std::to_string(e.effectid12)); + v.push_back(std::to_string(e.targettype)); + v.push_back(std::to_string(e.basediff)); + v.push_back(std::to_string(e.skill)); + v.push_back(std::to_string(e.zonetype)); + v.push_back(std::to_string(e.EnvironmentType)); + v.push_back(std::to_string(e.TimeOfDay)); + v.push_back(std::to_string(e.classes1)); + v.push_back(std::to_string(e.classes2)); + v.push_back(std::to_string(e.classes3)); + v.push_back(std::to_string(e.classes4)); + v.push_back(std::to_string(e.classes5)); + v.push_back(std::to_string(e.classes6)); + v.push_back(std::to_string(e.classes7)); + v.push_back(std::to_string(e.classes8)); + v.push_back(std::to_string(e.classes9)); + v.push_back(std::to_string(e.classes10)); + v.push_back(std::to_string(e.classes11)); + v.push_back(std::to_string(e.classes12)); + v.push_back(std::to_string(e.classes13)); + v.push_back(std::to_string(e.classes14)); + v.push_back(std::to_string(e.classes15)); + v.push_back(std::to_string(e.classes16)); + v.push_back(std::to_string(e.CastingAnim)); + v.push_back(std::to_string(e.TargetAnim)); + v.push_back(std::to_string(e.TravelType)); + v.push_back(std::to_string(e.SpellAffectIndex)); + v.push_back(std::to_string(e.disallow_sit)); + v.push_back(std::to_string(e.deities0)); + v.push_back(std::to_string(e.deities1)); + v.push_back(std::to_string(e.deities2)); + v.push_back(std::to_string(e.deities3)); + v.push_back(std::to_string(e.deities4)); + v.push_back(std::to_string(e.deities5)); + v.push_back(std::to_string(e.deities6)); + v.push_back(std::to_string(e.deities7)); + v.push_back(std::to_string(e.deities8)); + v.push_back(std::to_string(e.deities9)); + v.push_back(std::to_string(e.deities10)); + v.push_back(std::to_string(e.deities11)); + v.push_back(std::to_string(e.deities12)); + v.push_back(std::to_string(e.deities13)); + v.push_back(std::to_string(e.deities14)); + v.push_back(std::to_string(e.deities15)); + v.push_back(std::to_string(e.deities16)); + v.push_back(std::to_string(e.field142)); + v.push_back(std::to_string(e.field143)); + v.push_back(std::to_string(e.new_icon)); + v.push_back(std::to_string(e.spellanim)); + v.push_back(std::to_string(e.uninterruptable)); + v.push_back(std::to_string(e.ResistDiff)); + v.push_back(std::to_string(e.dot_stacking_exempt)); + v.push_back(std::to_string(e.deleteable)); + v.push_back(std::to_string(e.RecourseLink)); + v.push_back(std::to_string(e.no_partial_resist)); + v.push_back(std::to_string(e.field152)); + v.push_back(std::to_string(e.field153)); + v.push_back(std::to_string(e.short_buff_box)); + v.push_back(std::to_string(e.descnum)); + v.push_back(std::to_string(e.typedescnum)); + v.push_back(std::to_string(e.effectdescnum)); + v.push_back(std::to_string(e.effectdescnum2)); + v.push_back(std::to_string(e.npc_no_los)); + v.push_back(std::to_string(e.field160)); + v.push_back(std::to_string(e.reflectable)); + v.push_back(std::to_string(e.bonushate)); + v.push_back(std::to_string(e.field163)); + v.push_back(std::to_string(e.field164)); + v.push_back(std::to_string(e.ldon_trap)); + v.push_back(std::to_string(e.EndurCost)); + v.push_back(std::to_string(e.EndurTimerIndex)); + v.push_back(std::to_string(e.IsDiscipline)); + v.push_back(std::to_string(e.field169)); + v.push_back(std::to_string(e.field170)); + v.push_back(std::to_string(e.field171)); + v.push_back(std::to_string(e.field172)); + v.push_back(std::to_string(e.HateAdded)); + v.push_back(std::to_string(e.EndurUpkeep)); + v.push_back(std::to_string(e.numhitstype)); + v.push_back(std::to_string(e.numhits)); + v.push_back(std::to_string(e.pvpresistbase)); + v.push_back(std::to_string(e.pvpresistcalc)); + v.push_back(std::to_string(e.pvpresistcap)); + v.push_back(std::to_string(e.spell_category)); + v.push_back(std::to_string(e.pvp_duration)); + v.push_back(std::to_string(e.pvp_duration_cap)); + v.push_back(std::to_string(e.pcnpc_only_flag)); + v.push_back(std::to_string(e.cast_not_standing)); + v.push_back(std::to_string(e.can_mgb)); + v.push_back(std::to_string(e.nodispell)); + v.push_back(std::to_string(e.npc_category)); + v.push_back(std::to_string(e.npc_usefulness)); + v.push_back(std::to_string(e.MinResist)); + v.push_back(std::to_string(e.MaxResist)); + v.push_back(std::to_string(e.viral_targets)); + v.push_back(std::to_string(e.viral_timer)); + v.push_back(std::to_string(e.nimbuseffect)); + v.push_back(std::to_string(e.ConeStartAngle)); + v.push_back(std::to_string(e.ConeStopAngle)); + v.push_back(std::to_string(e.sneaking)); + v.push_back(std::to_string(e.not_extendable)); + v.push_back(std::to_string(e.field198)); + v.push_back(std::to_string(e.field199)); + v.push_back(std::to_string(e.suspendable)); + v.push_back(std::to_string(e.viral_range)); + v.push_back(std::to_string(e.songcap)); + v.push_back(std::to_string(e.field203)); + v.push_back(std::to_string(e.field204)); + v.push_back(std::to_string(e.no_block)); + v.push_back(std::to_string(e.field206)); + v.push_back(std::to_string(e.spellgroup)); + v.push_back(std::to_string(e.rank)); + v.push_back(std::to_string(e.field209)); + v.push_back(std::to_string(e.field210)); + v.push_back(std::to_string(e.CastRestriction)); + v.push_back(std::to_string(e.allowrest)); + v.push_back(std::to_string(e.InCombat)); + v.push_back(std::to_string(e.OutofCombat)); + v.push_back(std::to_string(e.field215)); + v.push_back(std::to_string(e.field216)); + v.push_back(std::to_string(e.field217)); + v.push_back(std::to_string(e.aemaxtargets)); + v.push_back(std::to_string(e.maxtargets)); + v.push_back(std::to_string(e.field220)); + v.push_back(std::to_string(e.field221)); + v.push_back(std::to_string(e.field222)); + v.push_back(std::to_string(e.field223)); + v.push_back(std::to_string(e.persistdeath)); + v.push_back(std::to_string(e.field225)); + v.push_back(std::to_string(e.field226)); + v.push_back(std::to_string(e.min_dist)); + v.push_back(std::to_string(e.min_dist_mod)); + v.push_back(std::to_string(e.max_dist)); + v.push_back(std::to_string(e.max_dist_mod)); + v.push_back(std::to_string(e.min_range)); + v.push_back(std::to_string(e.field232)); + v.push_back(std::to_string(e.field233)); + v.push_back(std::to_string(e.field234)); + v.push_back(std::to_string(e.field235)); + v.push_back(std::to_string(e.field236)); auto results = db.QueryDatabase( fmt::format( "{} VALUES ({})", BaseInsert(), - Strings::Implode(",", insert_values) + Strings::Implode(",", v) ) ); if (results.Success()) { - spells_new_entry.id = results.LastInsertedID(); - return spells_new_entry; + e.id = results.LastInsertedID(); + return e; } - spells_new_entry = NewEntity(); + e = NewEntity(); - return spells_new_entry; + return e; } static int InsertMany( Database& db, - std::vector spells_new_entries + const std::vector &entries ) { std::vector insert_chunks; - for (auto &spells_new_entry: spells_new_entries) { - std::vector insert_values; + for (auto &e: entries) { + std::vector v; - insert_values.push_back(std::to_string(spells_new_entry.id)); - insert_values.push_back("'" + Strings::Escape(spells_new_entry.name) + "'"); - insert_values.push_back("'" + Strings::Escape(spells_new_entry.player_1) + "'"); - insert_values.push_back("'" + Strings::Escape(spells_new_entry.teleport_zone) + "'"); - insert_values.push_back("'" + Strings::Escape(spells_new_entry.you_cast) + "'"); - insert_values.push_back("'" + Strings::Escape(spells_new_entry.other_casts) + "'"); - insert_values.push_back("'" + Strings::Escape(spells_new_entry.cast_on_you) + "'"); - insert_values.push_back("'" + Strings::Escape(spells_new_entry.cast_on_other) + "'"); - insert_values.push_back("'" + Strings::Escape(spells_new_entry.spell_fades) + "'"); - insert_values.push_back(std::to_string(spells_new_entry.range)); - insert_values.push_back(std::to_string(spells_new_entry.aoerange)); - insert_values.push_back(std::to_string(spells_new_entry.pushback)); - insert_values.push_back(std::to_string(spells_new_entry.pushup)); - insert_values.push_back(std::to_string(spells_new_entry.cast_time)); - insert_values.push_back(std::to_string(spells_new_entry.recovery_time)); - insert_values.push_back(std::to_string(spells_new_entry.recast_time)); - insert_values.push_back(std::to_string(spells_new_entry.buffdurationformula)); - insert_values.push_back(std::to_string(spells_new_entry.buffduration)); - insert_values.push_back(std::to_string(spells_new_entry.AEDuration)); - insert_values.push_back(std::to_string(spells_new_entry.mana)); - insert_values.push_back(std::to_string(spells_new_entry.effect_base_value1)); - insert_values.push_back(std::to_string(spells_new_entry.effect_base_value2)); - insert_values.push_back(std::to_string(spells_new_entry.effect_base_value3)); - insert_values.push_back(std::to_string(spells_new_entry.effect_base_value4)); - insert_values.push_back(std::to_string(spells_new_entry.effect_base_value5)); - insert_values.push_back(std::to_string(spells_new_entry.effect_base_value6)); - insert_values.push_back(std::to_string(spells_new_entry.effect_base_value7)); - insert_values.push_back(std::to_string(spells_new_entry.effect_base_value8)); - insert_values.push_back(std::to_string(spells_new_entry.effect_base_value9)); - insert_values.push_back(std::to_string(spells_new_entry.effect_base_value10)); - insert_values.push_back(std::to_string(spells_new_entry.effect_base_value11)); - insert_values.push_back(std::to_string(spells_new_entry.effect_base_value12)); - insert_values.push_back(std::to_string(spells_new_entry.effect_limit_value1)); - insert_values.push_back(std::to_string(spells_new_entry.effect_limit_value2)); - insert_values.push_back(std::to_string(spells_new_entry.effect_limit_value3)); - insert_values.push_back(std::to_string(spells_new_entry.effect_limit_value4)); - insert_values.push_back(std::to_string(spells_new_entry.effect_limit_value5)); - insert_values.push_back(std::to_string(spells_new_entry.effect_limit_value6)); - insert_values.push_back(std::to_string(spells_new_entry.effect_limit_value7)); - insert_values.push_back(std::to_string(spells_new_entry.effect_limit_value8)); - insert_values.push_back(std::to_string(spells_new_entry.effect_limit_value9)); - insert_values.push_back(std::to_string(spells_new_entry.effect_limit_value10)); - insert_values.push_back(std::to_string(spells_new_entry.effect_limit_value11)); - insert_values.push_back(std::to_string(spells_new_entry.effect_limit_value12)); - insert_values.push_back(std::to_string(spells_new_entry.max1)); - insert_values.push_back(std::to_string(spells_new_entry.max2)); - insert_values.push_back(std::to_string(spells_new_entry.max3)); - insert_values.push_back(std::to_string(spells_new_entry.max4)); - insert_values.push_back(std::to_string(spells_new_entry.max5)); - insert_values.push_back(std::to_string(spells_new_entry.max6)); - insert_values.push_back(std::to_string(spells_new_entry.max7)); - insert_values.push_back(std::to_string(spells_new_entry.max8)); - insert_values.push_back(std::to_string(spells_new_entry.max9)); - insert_values.push_back(std::to_string(spells_new_entry.max10)); - insert_values.push_back(std::to_string(spells_new_entry.max11)); - insert_values.push_back(std::to_string(spells_new_entry.max12)); - insert_values.push_back(std::to_string(spells_new_entry.icon)); - insert_values.push_back(std::to_string(spells_new_entry.memicon)); - insert_values.push_back(std::to_string(spells_new_entry.components1)); - insert_values.push_back(std::to_string(spells_new_entry.components2)); - insert_values.push_back(std::to_string(spells_new_entry.components3)); - insert_values.push_back(std::to_string(spells_new_entry.components4)); - insert_values.push_back(std::to_string(spells_new_entry.component_counts1)); - insert_values.push_back(std::to_string(spells_new_entry.component_counts2)); - insert_values.push_back(std::to_string(spells_new_entry.component_counts3)); - insert_values.push_back(std::to_string(spells_new_entry.component_counts4)); - insert_values.push_back(std::to_string(spells_new_entry.NoexpendReagent1)); - insert_values.push_back(std::to_string(spells_new_entry.NoexpendReagent2)); - insert_values.push_back(std::to_string(spells_new_entry.NoexpendReagent3)); - insert_values.push_back(std::to_string(spells_new_entry.NoexpendReagent4)); - insert_values.push_back(std::to_string(spells_new_entry.formula1)); - insert_values.push_back(std::to_string(spells_new_entry.formula2)); - insert_values.push_back(std::to_string(spells_new_entry.formula3)); - insert_values.push_back(std::to_string(spells_new_entry.formula4)); - insert_values.push_back(std::to_string(spells_new_entry.formula5)); - insert_values.push_back(std::to_string(spells_new_entry.formula6)); - insert_values.push_back(std::to_string(spells_new_entry.formula7)); - insert_values.push_back(std::to_string(spells_new_entry.formula8)); - insert_values.push_back(std::to_string(spells_new_entry.formula9)); - insert_values.push_back(std::to_string(spells_new_entry.formula10)); - insert_values.push_back(std::to_string(spells_new_entry.formula11)); - insert_values.push_back(std::to_string(spells_new_entry.formula12)); - insert_values.push_back(std::to_string(spells_new_entry.LightType)); - insert_values.push_back(std::to_string(spells_new_entry.goodEffect)); - insert_values.push_back(std::to_string(spells_new_entry.Activated)); - insert_values.push_back(std::to_string(spells_new_entry.resisttype)); - insert_values.push_back(std::to_string(spells_new_entry.effectid1)); - insert_values.push_back(std::to_string(spells_new_entry.effectid2)); - insert_values.push_back(std::to_string(spells_new_entry.effectid3)); - insert_values.push_back(std::to_string(spells_new_entry.effectid4)); - insert_values.push_back(std::to_string(spells_new_entry.effectid5)); - insert_values.push_back(std::to_string(spells_new_entry.effectid6)); - insert_values.push_back(std::to_string(spells_new_entry.effectid7)); - insert_values.push_back(std::to_string(spells_new_entry.effectid8)); - insert_values.push_back(std::to_string(spells_new_entry.effectid9)); - insert_values.push_back(std::to_string(spells_new_entry.effectid10)); - insert_values.push_back(std::to_string(spells_new_entry.effectid11)); - insert_values.push_back(std::to_string(spells_new_entry.effectid12)); - insert_values.push_back(std::to_string(spells_new_entry.targettype)); - insert_values.push_back(std::to_string(spells_new_entry.basediff)); - insert_values.push_back(std::to_string(spells_new_entry.skill)); - insert_values.push_back(std::to_string(spells_new_entry.zonetype)); - insert_values.push_back(std::to_string(spells_new_entry.EnvironmentType)); - insert_values.push_back(std::to_string(spells_new_entry.TimeOfDay)); - insert_values.push_back(std::to_string(spells_new_entry.classes1)); - insert_values.push_back(std::to_string(spells_new_entry.classes2)); - insert_values.push_back(std::to_string(spells_new_entry.classes3)); - insert_values.push_back(std::to_string(spells_new_entry.classes4)); - insert_values.push_back(std::to_string(spells_new_entry.classes5)); - insert_values.push_back(std::to_string(spells_new_entry.classes6)); - insert_values.push_back(std::to_string(spells_new_entry.classes7)); - insert_values.push_back(std::to_string(spells_new_entry.classes8)); - insert_values.push_back(std::to_string(spells_new_entry.classes9)); - insert_values.push_back(std::to_string(spells_new_entry.classes10)); - insert_values.push_back(std::to_string(spells_new_entry.classes11)); - insert_values.push_back(std::to_string(spells_new_entry.classes12)); - insert_values.push_back(std::to_string(spells_new_entry.classes13)); - insert_values.push_back(std::to_string(spells_new_entry.classes14)); - insert_values.push_back(std::to_string(spells_new_entry.classes15)); - insert_values.push_back(std::to_string(spells_new_entry.classes16)); - insert_values.push_back(std::to_string(spells_new_entry.CastingAnim)); - insert_values.push_back(std::to_string(spells_new_entry.TargetAnim)); - insert_values.push_back(std::to_string(spells_new_entry.TravelType)); - insert_values.push_back(std::to_string(spells_new_entry.SpellAffectIndex)); - insert_values.push_back(std::to_string(spells_new_entry.disallow_sit)); - insert_values.push_back(std::to_string(spells_new_entry.deities0)); - insert_values.push_back(std::to_string(spells_new_entry.deities1)); - insert_values.push_back(std::to_string(spells_new_entry.deities2)); - insert_values.push_back(std::to_string(spells_new_entry.deities3)); - insert_values.push_back(std::to_string(spells_new_entry.deities4)); - insert_values.push_back(std::to_string(spells_new_entry.deities5)); - insert_values.push_back(std::to_string(spells_new_entry.deities6)); - insert_values.push_back(std::to_string(spells_new_entry.deities7)); - insert_values.push_back(std::to_string(spells_new_entry.deities8)); - insert_values.push_back(std::to_string(spells_new_entry.deities9)); - insert_values.push_back(std::to_string(spells_new_entry.deities10)); - insert_values.push_back(std::to_string(spells_new_entry.deities11)); - insert_values.push_back(std::to_string(spells_new_entry.deities12)); - insert_values.push_back(std::to_string(spells_new_entry.deities13)); - insert_values.push_back(std::to_string(spells_new_entry.deities14)); - insert_values.push_back(std::to_string(spells_new_entry.deities15)); - insert_values.push_back(std::to_string(spells_new_entry.deities16)); - insert_values.push_back(std::to_string(spells_new_entry.field142)); - insert_values.push_back(std::to_string(spells_new_entry.field143)); - insert_values.push_back(std::to_string(spells_new_entry.new_icon)); - insert_values.push_back(std::to_string(spells_new_entry.spellanim)); - insert_values.push_back(std::to_string(spells_new_entry.uninterruptable)); - insert_values.push_back(std::to_string(spells_new_entry.ResistDiff)); - insert_values.push_back(std::to_string(spells_new_entry.dot_stacking_exempt)); - insert_values.push_back(std::to_string(spells_new_entry.deleteable)); - insert_values.push_back(std::to_string(spells_new_entry.RecourseLink)); - insert_values.push_back(std::to_string(spells_new_entry.no_partial_resist)); - insert_values.push_back(std::to_string(spells_new_entry.field152)); - insert_values.push_back(std::to_string(spells_new_entry.field153)); - insert_values.push_back(std::to_string(spells_new_entry.short_buff_box)); - insert_values.push_back(std::to_string(spells_new_entry.descnum)); - insert_values.push_back(std::to_string(spells_new_entry.typedescnum)); - insert_values.push_back(std::to_string(spells_new_entry.effectdescnum)); - insert_values.push_back(std::to_string(spells_new_entry.effectdescnum2)); - insert_values.push_back(std::to_string(spells_new_entry.npc_no_los)); - insert_values.push_back(std::to_string(spells_new_entry.field160)); - insert_values.push_back(std::to_string(spells_new_entry.reflectable)); - insert_values.push_back(std::to_string(spells_new_entry.bonushate)); - insert_values.push_back(std::to_string(spells_new_entry.field163)); - insert_values.push_back(std::to_string(spells_new_entry.field164)); - insert_values.push_back(std::to_string(spells_new_entry.ldon_trap)); - insert_values.push_back(std::to_string(spells_new_entry.EndurCost)); - insert_values.push_back(std::to_string(spells_new_entry.EndurTimerIndex)); - insert_values.push_back(std::to_string(spells_new_entry.IsDiscipline)); - insert_values.push_back(std::to_string(spells_new_entry.field169)); - insert_values.push_back(std::to_string(spells_new_entry.field170)); - insert_values.push_back(std::to_string(spells_new_entry.field171)); - insert_values.push_back(std::to_string(spells_new_entry.field172)); - insert_values.push_back(std::to_string(spells_new_entry.HateAdded)); - insert_values.push_back(std::to_string(spells_new_entry.EndurUpkeep)); - insert_values.push_back(std::to_string(spells_new_entry.numhitstype)); - insert_values.push_back(std::to_string(spells_new_entry.numhits)); - insert_values.push_back(std::to_string(spells_new_entry.pvpresistbase)); - insert_values.push_back(std::to_string(spells_new_entry.pvpresistcalc)); - insert_values.push_back(std::to_string(spells_new_entry.pvpresistcap)); - insert_values.push_back(std::to_string(spells_new_entry.spell_category)); - insert_values.push_back(std::to_string(spells_new_entry.pvp_duration)); - insert_values.push_back(std::to_string(spells_new_entry.pvp_duration_cap)); - insert_values.push_back(std::to_string(spells_new_entry.pcnpc_only_flag)); - insert_values.push_back(std::to_string(spells_new_entry.cast_not_standing)); - insert_values.push_back(std::to_string(spells_new_entry.can_mgb)); - insert_values.push_back(std::to_string(spells_new_entry.nodispell)); - insert_values.push_back(std::to_string(spells_new_entry.npc_category)); - insert_values.push_back(std::to_string(spells_new_entry.npc_usefulness)); - insert_values.push_back(std::to_string(spells_new_entry.MinResist)); - insert_values.push_back(std::to_string(spells_new_entry.MaxResist)); - insert_values.push_back(std::to_string(spells_new_entry.viral_targets)); - insert_values.push_back(std::to_string(spells_new_entry.viral_timer)); - insert_values.push_back(std::to_string(spells_new_entry.nimbuseffect)); - insert_values.push_back(std::to_string(spells_new_entry.ConeStartAngle)); - insert_values.push_back(std::to_string(spells_new_entry.ConeStopAngle)); - insert_values.push_back(std::to_string(spells_new_entry.sneaking)); - insert_values.push_back(std::to_string(spells_new_entry.not_extendable)); - insert_values.push_back(std::to_string(spells_new_entry.field198)); - insert_values.push_back(std::to_string(spells_new_entry.field199)); - insert_values.push_back(std::to_string(spells_new_entry.suspendable)); - insert_values.push_back(std::to_string(spells_new_entry.viral_range)); - insert_values.push_back(std::to_string(spells_new_entry.songcap)); - insert_values.push_back(std::to_string(spells_new_entry.field203)); - insert_values.push_back(std::to_string(spells_new_entry.field204)); - insert_values.push_back(std::to_string(spells_new_entry.no_block)); - insert_values.push_back(std::to_string(spells_new_entry.field206)); - insert_values.push_back(std::to_string(spells_new_entry.spellgroup)); - insert_values.push_back(std::to_string(spells_new_entry.rank)); - insert_values.push_back(std::to_string(spells_new_entry.field209)); - insert_values.push_back(std::to_string(spells_new_entry.field210)); - insert_values.push_back(std::to_string(spells_new_entry.CastRestriction)); - insert_values.push_back(std::to_string(spells_new_entry.allowrest)); - insert_values.push_back(std::to_string(spells_new_entry.InCombat)); - insert_values.push_back(std::to_string(spells_new_entry.OutofCombat)); - insert_values.push_back(std::to_string(spells_new_entry.field215)); - insert_values.push_back(std::to_string(spells_new_entry.field216)); - insert_values.push_back(std::to_string(spells_new_entry.field217)); - insert_values.push_back(std::to_string(spells_new_entry.aemaxtargets)); - insert_values.push_back(std::to_string(spells_new_entry.maxtargets)); - insert_values.push_back(std::to_string(spells_new_entry.field220)); - insert_values.push_back(std::to_string(spells_new_entry.field221)); - insert_values.push_back(std::to_string(spells_new_entry.field222)); - insert_values.push_back(std::to_string(spells_new_entry.field223)); - insert_values.push_back(std::to_string(spells_new_entry.persistdeath)); - insert_values.push_back(std::to_string(spells_new_entry.field225)); - insert_values.push_back(std::to_string(spells_new_entry.field226)); - insert_values.push_back(std::to_string(spells_new_entry.min_dist)); - insert_values.push_back(std::to_string(spells_new_entry.min_dist_mod)); - insert_values.push_back(std::to_string(spells_new_entry.max_dist)); - insert_values.push_back(std::to_string(spells_new_entry.max_dist_mod)); - insert_values.push_back(std::to_string(spells_new_entry.min_range)); - insert_values.push_back(std::to_string(spells_new_entry.field232)); - insert_values.push_back(std::to_string(spells_new_entry.field233)); - insert_values.push_back(std::to_string(spells_new_entry.field234)); - insert_values.push_back(std::to_string(spells_new_entry.field235)); - insert_values.push_back(std::to_string(spells_new_entry.field236)); + v.push_back(std::to_string(e.id)); + v.push_back("'" + Strings::Escape(e.name) + "'"); + v.push_back("'" + Strings::Escape(e.player_1) + "'"); + v.push_back("'" + Strings::Escape(e.teleport_zone) + "'"); + v.push_back("'" + Strings::Escape(e.you_cast) + "'"); + v.push_back("'" + Strings::Escape(e.other_casts) + "'"); + v.push_back("'" + Strings::Escape(e.cast_on_you) + "'"); + v.push_back("'" + Strings::Escape(e.cast_on_other) + "'"); + v.push_back("'" + Strings::Escape(e.spell_fades) + "'"); + v.push_back(std::to_string(e.range)); + v.push_back(std::to_string(e.aoerange)); + v.push_back(std::to_string(e.pushback)); + v.push_back(std::to_string(e.pushup)); + v.push_back(std::to_string(e.cast_time)); + v.push_back(std::to_string(e.recovery_time)); + v.push_back(std::to_string(e.recast_time)); + v.push_back(std::to_string(e.buffdurationformula)); + v.push_back(std::to_string(e.buffduration)); + v.push_back(std::to_string(e.AEDuration)); + v.push_back(std::to_string(e.mana)); + v.push_back(std::to_string(e.effect_base_value1)); + v.push_back(std::to_string(e.effect_base_value2)); + v.push_back(std::to_string(e.effect_base_value3)); + v.push_back(std::to_string(e.effect_base_value4)); + v.push_back(std::to_string(e.effect_base_value5)); + v.push_back(std::to_string(e.effect_base_value6)); + v.push_back(std::to_string(e.effect_base_value7)); + v.push_back(std::to_string(e.effect_base_value8)); + v.push_back(std::to_string(e.effect_base_value9)); + v.push_back(std::to_string(e.effect_base_value10)); + v.push_back(std::to_string(e.effect_base_value11)); + v.push_back(std::to_string(e.effect_base_value12)); + v.push_back(std::to_string(e.effect_limit_value1)); + v.push_back(std::to_string(e.effect_limit_value2)); + v.push_back(std::to_string(e.effect_limit_value3)); + v.push_back(std::to_string(e.effect_limit_value4)); + v.push_back(std::to_string(e.effect_limit_value5)); + v.push_back(std::to_string(e.effect_limit_value6)); + v.push_back(std::to_string(e.effect_limit_value7)); + v.push_back(std::to_string(e.effect_limit_value8)); + v.push_back(std::to_string(e.effect_limit_value9)); + v.push_back(std::to_string(e.effect_limit_value10)); + v.push_back(std::to_string(e.effect_limit_value11)); + v.push_back(std::to_string(e.effect_limit_value12)); + v.push_back(std::to_string(e.max1)); + v.push_back(std::to_string(e.max2)); + v.push_back(std::to_string(e.max3)); + v.push_back(std::to_string(e.max4)); + v.push_back(std::to_string(e.max5)); + v.push_back(std::to_string(e.max6)); + v.push_back(std::to_string(e.max7)); + v.push_back(std::to_string(e.max8)); + v.push_back(std::to_string(e.max9)); + v.push_back(std::to_string(e.max10)); + v.push_back(std::to_string(e.max11)); + v.push_back(std::to_string(e.max12)); + v.push_back(std::to_string(e.icon)); + v.push_back(std::to_string(e.memicon)); + v.push_back(std::to_string(e.components1)); + v.push_back(std::to_string(e.components2)); + v.push_back(std::to_string(e.components3)); + v.push_back(std::to_string(e.components4)); + v.push_back(std::to_string(e.component_counts1)); + v.push_back(std::to_string(e.component_counts2)); + v.push_back(std::to_string(e.component_counts3)); + v.push_back(std::to_string(e.component_counts4)); + v.push_back(std::to_string(e.NoexpendReagent1)); + v.push_back(std::to_string(e.NoexpendReagent2)); + v.push_back(std::to_string(e.NoexpendReagent3)); + v.push_back(std::to_string(e.NoexpendReagent4)); + v.push_back(std::to_string(e.formula1)); + v.push_back(std::to_string(e.formula2)); + v.push_back(std::to_string(e.formula3)); + v.push_back(std::to_string(e.formula4)); + v.push_back(std::to_string(e.formula5)); + v.push_back(std::to_string(e.formula6)); + v.push_back(std::to_string(e.formula7)); + v.push_back(std::to_string(e.formula8)); + v.push_back(std::to_string(e.formula9)); + v.push_back(std::to_string(e.formula10)); + v.push_back(std::to_string(e.formula11)); + v.push_back(std::to_string(e.formula12)); + v.push_back(std::to_string(e.LightType)); + v.push_back(std::to_string(e.goodEffect)); + v.push_back(std::to_string(e.Activated)); + v.push_back(std::to_string(e.resisttype)); + v.push_back(std::to_string(e.effectid1)); + v.push_back(std::to_string(e.effectid2)); + v.push_back(std::to_string(e.effectid3)); + v.push_back(std::to_string(e.effectid4)); + v.push_back(std::to_string(e.effectid5)); + v.push_back(std::to_string(e.effectid6)); + v.push_back(std::to_string(e.effectid7)); + v.push_back(std::to_string(e.effectid8)); + v.push_back(std::to_string(e.effectid9)); + v.push_back(std::to_string(e.effectid10)); + v.push_back(std::to_string(e.effectid11)); + v.push_back(std::to_string(e.effectid12)); + v.push_back(std::to_string(e.targettype)); + v.push_back(std::to_string(e.basediff)); + v.push_back(std::to_string(e.skill)); + v.push_back(std::to_string(e.zonetype)); + v.push_back(std::to_string(e.EnvironmentType)); + v.push_back(std::to_string(e.TimeOfDay)); + v.push_back(std::to_string(e.classes1)); + v.push_back(std::to_string(e.classes2)); + v.push_back(std::to_string(e.classes3)); + v.push_back(std::to_string(e.classes4)); + v.push_back(std::to_string(e.classes5)); + v.push_back(std::to_string(e.classes6)); + v.push_back(std::to_string(e.classes7)); + v.push_back(std::to_string(e.classes8)); + v.push_back(std::to_string(e.classes9)); + v.push_back(std::to_string(e.classes10)); + v.push_back(std::to_string(e.classes11)); + v.push_back(std::to_string(e.classes12)); + v.push_back(std::to_string(e.classes13)); + v.push_back(std::to_string(e.classes14)); + v.push_back(std::to_string(e.classes15)); + v.push_back(std::to_string(e.classes16)); + v.push_back(std::to_string(e.CastingAnim)); + v.push_back(std::to_string(e.TargetAnim)); + v.push_back(std::to_string(e.TravelType)); + v.push_back(std::to_string(e.SpellAffectIndex)); + v.push_back(std::to_string(e.disallow_sit)); + v.push_back(std::to_string(e.deities0)); + v.push_back(std::to_string(e.deities1)); + v.push_back(std::to_string(e.deities2)); + v.push_back(std::to_string(e.deities3)); + v.push_back(std::to_string(e.deities4)); + v.push_back(std::to_string(e.deities5)); + v.push_back(std::to_string(e.deities6)); + v.push_back(std::to_string(e.deities7)); + v.push_back(std::to_string(e.deities8)); + v.push_back(std::to_string(e.deities9)); + v.push_back(std::to_string(e.deities10)); + v.push_back(std::to_string(e.deities11)); + v.push_back(std::to_string(e.deities12)); + v.push_back(std::to_string(e.deities13)); + v.push_back(std::to_string(e.deities14)); + v.push_back(std::to_string(e.deities15)); + v.push_back(std::to_string(e.deities16)); + v.push_back(std::to_string(e.field142)); + v.push_back(std::to_string(e.field143)); + v.push_back(std::to_string(e.new_icon)); + v.push_back(std::to_string(e.spellanim)); + v.push_back(std::to_string(e.uninterruptable)); + v.push_back(std::to_string(e.ResistDiff)); + v.push_back(std::to_string(e.dot_stacking_exempt)); + v.push_back(std::to_string(e.deleteable)); + v.push_back(std::to_string(e.RecourseLink)); + v.push_back(std::to_string(e.no_partial_resist)); + v.push_back(std::to_string(e.field152)); + v.push_back(std::to_string(e.field153)); + v.push_back(std::to_string(e.short_buff_box)); + v.push_back(std::to_string(e.descnum)); + v.push_back(std::to_string(e.typedescnum)); + v.push_back(std::to_string(e.effectdescnum)); + v.push_back(std::to_string(e.effectdescnum2)); + v.push_back(std::to_string(e.npc_no_los)); + v.push_back(std::to_string(e.field160)); + v.push_back(std::to_string(e.reflectable)); + v.push_back(std::to_string(e.bonushate)); + v.push_back(std::to_string(e.field163)); + v.push_back(std::to_string(e.field164)); + v.push_back(std::to_string(e.ldon_trap)); + v.push_back(std::to_string(e.EndurCost)); + v.push_back(std::to_string(e.EndurTimerIndex)); + v.push_back(std::to_string(e.IsDiscipline)); + v.push_back(std::to_string(e.field169)); + v.push_back(std::to_string(e.field170)); + v.push_back(std::to_string(e.field171)); + v.push_back(std::to_string(e.field172)); + v.push_back(std::to_string(e.HateAdded)); + v.push_back(std::to_string(e.EndurUpkeep)); + v.push_back(std::to_string(e.numhitstype)); + v.push_back(std::to_string(e.numhits)); + v.push_back(std::to_string(e.pvpresistbase)); + v.push_back(std::to_string(e.pvpresistcalc)); + v.push_back(std::to_string(e.pvpresistcap)); + v.push_back(std::to_string(e.spell_category)); + v.push_back(std::to_string(e.pvp_duration)); + v.push_back(std::to_string(e.pvp_duration_cap)); + v.push_back(std::to_string(e.pcnpc_only_flag)); + v.push_back(std::to_string(e.cast_not_standing)); + v.push_back(std::to_string(e.can_mgb)); + v.push_back(std::to_string(e.nodispell)); + v.push_back(std::to_string(e.npc_category)); + v.push_back(std::to_string(e.npc_usefulness)); + v.push_back(std::to_string(e.MinResist)); + v.push_back(std::to_string(e.MaxResist)); + v.push_back(std::to_string(e.viral_targets)); + v.push_back(std::to_string(e.viral_timer)); + v.push_back(std::to_string(e.nimbuseffect)); + v.push_back(std::to_string(e.ConeStartAngle)); + v.push_back(std::to_string(e.ConeStopAngle)); + v.push_back(std::to_string(e.sneaking)); + v.push_back(std::to_string(e.not_extendable)); + v.push_back(std::to_string(e.field198)); + v.push_back(std::to_string(e.field199)); + v.push_back(std::to_string(e.suspendable)); + v.push_back(std::to_string(e.viral_range)); + v.push_back(std::to_string(e.songcap)); + v.push_back(std::to_string(e.field203)); + v.push_back(std::to_string(e.field204)); + v.push_back(std::to_string(e.no_block)); + v.push_back(std::to_string(e.field206)); + v.push_back(std::to_string(e.spellgroup)); + v.push_back(std::to_string(e.rank)); + v.push_back(std::to_string(e.field209)); + v.push_back(std::to_string(e.field210)); + v.push_back(std::to_string(e.CastRestriction)); + v.push_back(std::to_string(e.allowrest)); + v.push_back(std::to_string(e.InCombat)); + v.push_back(std::to_string(e.OutofCombat)); + v.push_back(std::to_string(e.field215)); + v.push_back(std::to_string(e.field216)); + v.push_back(std::to_string(e.field217)); + v.push_back(std::to_string(e.aemaxtargets)); + v.push_back(std::to_string(e.maxtargets)); + v.push_back(std::to_string(e.field220)); + v.push_back(std::to_string(e.field221)); + v.push_back(std::to_string(e.field222)); + v.push_back(std::to_string(e.field223)); + v.push_back(std::to_string(e.persistdeath)); + v.push_back(std::to_string(e.field225)); + v.push_back(std::to_string(e.field226)); + v.push_back(std::to_string(e.min_dist)); + v.push_back(std::to_string(e.min_dist_mod)); + v.push_back(std::to_string(e.max_dist)); + v.push_back(std::to_string(e.max_dist_mod)); + v.push_back(std::to_string(e.min_range)); + v.push_back(std::to_string(e.field232)); + v.push_back(std::to_string(e.field233)); + v.push_back(std::to_string(e.field234)); + v.push_back(std::to_string(e.field235)); + v.push_back(std::to_string(e.field236)); - insert_chunks.push_back("(" + Strings::Implode(",", insert_values) + ")"); + insert_chunks.push_back("(" + Strings::Implode(",", v) + ")"); } - std::vector insert_values; + std::vector v; auto results = db.QueryDatabase( fmt::format( @@ -2120,253 +2120,253 @@ public: all_entries.reserve(results.RowCount()); for (auto row = results.begin(); row != results.end(); ++row) { - SpellsNew entry{}; + SpellsNew e{}; - entry.id = atoi(row[0]); - entry.name = row[1] ? row[1] : ""; - entry.player_1 = row[2] ? row[2] : ""; - entry.teleport_zone = row[3] ? row[3] : ""; - entry.you_cast = row[4] ? row[4] : ""; - entry.other_casts = row[5] ? row[5] : ""; - entry.cast_on_you = row[6] ? row[6] : ""; - entry.cast_on_other = row[7] ? row[7] : ""; - entry.spell_fades = row[8] ? row[8] : ""; - entry.range = atoi(row[9]); - entry.aoerange = atoi(row[10]); - entry.pushback = atoi(row[11]); - entry.pushup = atoi(row[12]); - entry.cast_time = atoi(row[13]); - entry.recovery_time = atoi(row[14]); - entry.recast_time = atoi(row[15]); - entry.buffdurationformula = atoi(row[16]); - entry.buffduration = atoi(row[17]); - entry.AEDuration = atoi(row[18]); - entry.mana = atoi(row[19]); - entry.effect_base_value1 = atoi(row[20]); - entry.effect_base_value2 = atoi(row[21]); - entry.effect_base_value3 = atoi(row[22]); - entry.effect_base_value4 = atoi(row[23]); - entry.effect_base_value5 = atoi(row[24]); - entry.effect_base_value6 = atoi(row[25]); - entry.effect_base_value7 = atoi(row[26]); - entry.effect_base_value8 = atoi(row[27]); - entry.effect_base_value9 = atoi(row[28]); - entry.effect_base_value10 = atoi(row[29]); - entry.effect_base_value11 = atoi(row[30]); - entry.effect_base_value12 = atoi(row[31]); - entry.effect_limit_value1 = atoi(row[32]); - entry.effect_limit_value2 = atoi(row[33]); - entry.effect_limit_value3 = atoi(row[34]); - entry.effect_limit_value4 = atoi(row[35]); - entry.effect_limit_value5 = atoi(row[36]); - entry.effect_limit_value6 = atoi(row[37]); - entry.effect_limit_value7 = atoi(row[38]); - entry.effect_limit_value8 = atoi(row[39]); - entry.effect_limit_value9 = atoi(row[40]); - entry.effect_limit_value10 = atoi(row[41]); - entry.effect_limit_value11 = atoi(row[42]); - entry.effect_limit_value12 = atoi(row[43]); - entry.max1 = atoi(row[44]); - entry.max2 = atoi(row[45]); - entry.max3 = atoi(row[46]); - entry.max4 = atoi(row[47]); - entry.max5 = atoi(row[48]); - entry.max6 = atoi(row[49]); - entry.max7 = atoi(row[50]); - entry.max8 = atoi(row[51]); - entry.max9 = atoi(row[52]); - entry.max10 = atoi(row[53]); - entry.max11 = atoi(row[54]); - entry.max12 = atoi(row[55]); - entry.icon = atoi(row[56]); - entry.memicon = atoi(row[57]); - entry.components1 = atoi(row[58]); - entry.components2 = atoi(row[59]); - entry.components3 = atoi(row[60]); - entry.components4 = atoi(row[61]); - entry.component_counts1 = atoi(row[62]); - entry.component_counts2 = atoi(row[63]); - entry.component_counts3 = atoi(row[64]); - entry.component_counts4 = atoi(row[65]); - entry.NoexpendReagent1 = atoi(row[66]); - entry.NoexpendReagent2 = atoi(row[67]); - entry.NoexpendReagent3 = atoi(row[68]); - entry.NoexpendReagent4 = atoi(row[69]); - entry.formula1 = atoi(row[70]); - entry.formula2 = atoi(row[71]); - entry.formula3 = atoi(row[72]); - entry.formula4 = atoi(row[73]); - entry.formula5 = atoi(row[74]); - entry.formula6 = atoi(row[75]); - entry.formula7 = atoi(row[76]); - entry.formula8 = atoi(row[77]); - entry.formula9 = atoi(row[78]); - entry.formula10 = atoi(row[79]); - entry.formula11 = atoi(row[80]); - entry.formula12 = atoi(row[81]); - entry.LightType = atoi(row[82]); - entry.goodEffect = atoi(row[83]); - entry.Activated = atoi(row[84]); - entry.resisttype = atoi(row[85]); - entry.effectid1 = atoi(row[86]); - entry.effectid2 = atoi(row[87]); - entry.effectid3 = atoi(row[88]); - entry.effectid4 = atoi(row[89]); - entry.effectid5 = atoi(row[90]); - entry.effectid6 = atoi(row[91]); - entry.effectid7 = atoi(row[92]); - entry.effectid8 = atoi(row[93]); - entry.effectid9 = atoi(row[94]); - entry.effectid10 = atoi(row[95]); - entry.effectid11 = atoi(row[96]); - entry.effectid12 = atoi(row[97]); - entry.targettype = atoi(row[98]); - entry.basediff = atoi(row[99]); - entry.skill = atoi(row[100]); - entry.zonetype = atoi(row[101]); - entry.EnvironmentType = atoi(row[102]); - entry.TimeOfDay = atoi(row[103]); - entry.classes1 = atoi(row[104]); - entry.classes2 = atoi(row[105]); - entry.classes3 = atoi(row[106]); - entry.classes4 = atoi(row[107]); - entry.classes5 = atoi(row[108]); - entry.classes6 = atoi(row[109]); - entry.classes7 = atoi(row[110]); - entry.classes8 = atoi(row[111]); - entry.classes9 = atoi(row[112]); - entry.classes10 = atoi(row[113]); - entry.classes11 = atoi(row[114]); - entry.classes12 = atoi(row[115]); - entry.classes13 = atoi(row[116]); - entry.classes14 = atoi(row[117]); - entry.classes15 = atoi(row[118]); - entry.classes16 = atoi(row[119]); - entry.CastingAnim = atoi(row[120]); - entry.TargetAnim = atoi(row[121]); - entry.TravelType = atoi(row[122]); - entry.SpellAffectIndex = atoi(row[123]); - entry.disallow_sit = atoi(row[124]); - entry.deities0 = atoi(row[125]); - entry.deities1 = atoi(row[126]); - entry.deities2 = atoi(row[127]); - entry.deities3 = atoi(row[128]); - entry.deities4 = atoi(row[129]); - entry.deities5 = atoi(row[130]); - entry.deities6 = atoi(row[131]); - entry.deities7 = atoi(row[132]); - entry.deities8 = atoi(row[133]); - entry.deities9 = atoi(row[134]); - entry.deities10 = atoi(row[135]); - entry.deities11 = atoi(row[136]); - entry.deities12 = atoi(row[137]); - entry.deities13 = atoi(row[138]); - entry.deities14 = atoi(row[139]); - entry.deities15 = atoi(row[140]); - entry.deities16 = atoi(row[141]); - entry.field142 = atoi(row[142]); - entry.field143 = atoi(row[143]); - entry.new_icon = atoi(row[144]); - entry.spellanim = atoi(row[145]); - entry.uninterruptable = atoi(row[146]); - entry.ResistDiff = atoi(row[147]); - entry.dot_stacking_exempt = atoi(row[148]); - entry.deleteable = atoi(row[149]); - entry.RecourseLink = atoi(row[150]); - entry.no_partial_resist = atoi(row[151]); - entry.field152 = atoi(row[152]); - entry.field153 = atoi(row[153]); - entry.short_buff_box = atoi(row[154]); - entry.descnum = atoi(row[155]); - entry.typedescnum = atoi(row[156]); - entry.effectdescnum = atoi(row[157]); - entry.effectdescnum2 = atoi(row[158]); - entry.npc_no_los = atoi(row[159]); - entry.field160 = atoi(row[160]); - entry.reflectable = atoi(row[161]); - entry.bonushate = atoi(row[162]); - entry.field163 = atoi(row[163]); - entry.field164 = atoi(row[164]); - entry.ldon_trap = atoi(row[165]); - entry.EndurCost = atoi(row[166]); - entry.EndurTimerIndex = atoi(row[167]); - entry.IsDiscipline = atoi(row[168]); - entry.field169 = atoi(row[169]); - entry.field170 = atoi(row[170]); - entry.field171 = atoi(row[171]); - entry.field172 = atoi(row[172]); - entry.HateAdded = atoi(row[173]); - entry.EndurUpkeep = atoi(row[174]); - entry.numhitstype = atoi(row[175]); - entry.numhits = atoi(row[176]); - entry.pvpresistbase = atoi(row[177]); - entry.pvpresistcalc = atoi(row[178]); - entry.pvpresistcap = atoi(row[179]); - entry.spell_category = atoi(row[180]); - entry.pvp_duration = atoi(row[181]); - entry.pvp_duration_cap = atoi(row[182]); - entry.pcnpc_only_flag = atoi(row[183]); - entry.cast_not_standing = atoi(row[184]); - entry.can_mgb = atoi(row[185]); - entry.nodispell = atoi(row[186]); - entry.npc_category = atoi(row[187]); - entry.npc_usefulness = atoi(row[188]); - entry.MinResist = atoi(row[189]); - entry.MaxResist = atoi(row[190]); - entry.viral_targets = atoi(row[191]); - entry.viral_timer = atoi(row[192]); - entry.nimbuseffect = atoi(row[193]); - entry.ConeStartAngle = atoi(row[194]); - entry.ConeStopAngle = atoi(row[195]); - entry.sneaking = atoi(row[196]); - entry.not_extendable = atoi(row[197]); - entry.field198 = atoi(row[198]); - entry.field199 = atoi(row[199]); - entry.suspendable = atoi(row[200]); - entry.viral_range = atoi(row[201]); - entry.songcap = atoi(row[202]); - entry.field203 = atoi(row[203]); - entry.field204 = atoi(row[204]); - entry.no_block = atoi(row[205]); - entry.field206 = atoi(row[206]); - entry.spellgroup = atoi(row[207]); - entry.rank = atoi(row[208]); - entry.field209 = atoi(row[209]); - entry.field210 = atoi(row[210]); - entry.CastRestriction = atoi(row[211]); - entry.allowrest = atoi(row[212]); - entry.InCombat = atoi(row[213]); - entry.OutofCombat = atoi(row[214]); - entry.field215 = atoi(row[215]); - entry.field216 = atoi(row[216]); - entry.field217 = atoi(row[217]); - entry.aemaxtargets = atoi(row[218]); - entry.maxtargets = atoi(row[219]); - entry.field220 = atoi(row[220]); - entry.field221 = atoi(row[221]); - entry.field222 = atoi(row[222]); - entry.field223 = atoi(row[223]); - entry.persistdeath = atoi(row[224]); - entry.field225 = atoi(row[225]); - entry.field226 = atoi(row[226]); - entry.min_dist = static_cast(atof(row[227])); - entry.min_dist_mod = static_cast(atof(row[228])); - entry.max_dist = static_cast(atof(row[229])); - entry.max_dist_mod = static_cast(atof(row[230])); - entry.min_range = atoi(row[231]); - entry.field232 = atoi(row[232]); - entry.field233 = atoi(row[233]); - entry.field234 = atoi(row[234]); - entry.field235 = atoi(row[235]); - entry.field236 = atoi(row[236]); + e.id = atoi(row[0]); + e.name = row[1] ? row[1] : ""; + e.player_1 = row[2] ? row[2] : ""; + e.teleport_zone = row[3] ? row[3] : ""; + e.you_cast = row[4] ? row[4] : ""; + e.other_casts = row[5] ? row[5] : ""; + e.cast_on_you = row[6] ? row[6] : ""; + e.cast_on_other = row[7] ? row[7] : ""; + e.spell_fades = row[8] ? row[8] : ""; + e.range = atoi(row[9]); + e.aoerange = atoi(row[10]); + e.pushback = atoi(row[11]); + e.pushup = atoi(row[12]); + e.cast_time = atoi(row[13]); + e.recovery_time = atoi(row[14]); + e.recast_time = atoi(row[15]); + e.buffdurationformula = atoi(row[16]); + e.buffduration = atoi(row[17]); + e.AEDuration = atoi(row[18]); + e.mana = atoi(row[19]); + e.effect_base_value1 = atoi(row[20]); + e.effect_base_value2 = atoi(row[21]); + e.effect_base_value3 = atoi(row[22]); + e.effect_base_value4 = atoi(row[23]); + e.effect_base_value5 = atoi(row[24]); + e.effect_base_value6 = atoi(row[25]); + e.effect_base_value7 = atoi(row[26]); + e.effect_base_value8 = atoi(row[27]); + e.effect_base_value9 = atoi(row[28]); + e.effect_base_value10 = atoi(row[29]); + e.effect_base_value11 = atoi(row[30]); + e.effect_base_value12 = atoi(row[31]); + e.effect_limit_value1 = atoi(row[32]); + e.effect_limit_value2 = atoi(row[33]); + e.effect_limit_value3 = atoi(row[34]); + e.effect_limit_value4 = atoi(row[35]); + e.effect_limit_value5 = atoi(row[36]); + e.effect_limit_value6 = atoi(row[37]); + e.effect_limit_value7 = atoi(row[38]); + e.effect_limit_value8 = atoi(row[39]); + e.effect_limit_value9 = atoi(row[40]); + e.effect_limit_value10 = atoi(row[41]); + e.effect_limit_value11 = atoi(row[42]); + e.effect_limit_value12 = atoi(row[43]); + e.max1 = atoi(row[44]); + e.max2 = atoi(row[45]); + e.max3 = atoi(row[46]); + e.max4 = atoi(row[47]); + e.max5 = atoi(row[48]); + e.max6 = atoi(row[49]); + e.max7 = atoi(row[50]); + e.max8 = atoi(row[51]); + e.max9 = atoi(row[52]); + e.max10 = atoi(row[53]); + e.max11 = atoi(row[54]); + e.max12 = atoi(row[55]); + e.icon = atoi(row[56]); + e.memicon = atoi(row[57]); + e.components1 = atoi(row[58]); + e.components2 = atoi(row[59]); + e.components3 = atoi(row[60]); + e.components4 = atoi(row[61]); + e.component_counts1 = atoi(row[62]); + e.component_counts2 = atoi(row[63]); + e.component_counts3 = atoi(row[64]); + e.component_counts4 = atoi(row[65]); + e.NoexpendReagent1 = atoi(row[66]); + e.NoexpendReagent2 = atoi(row[67]); + e.NoexpendReagent3 = atoi(row[68]); + e.NoexpendReagent4 = atoi(row[69]); + e.formula1 = atoi(row[70]); + e.formula2 = atoi(row[71]); + e.formula3 = atoi(row[72]); + e.formula4 = atoi(row[73]); + e.formula5 = atoi(row[74]); + e.formula6 = atoi(row[75]); + e.formula7 = atoi(row[76]); + e.formula8 = atoi(row[77]); + e.formula9 = atoi(row[78]); + e.formula10 = atoi(row[79]); + e.formula11 = atoi(row[80]); + e.formula12 = atoi(row[81]); + e.LightType = atoi(row[82]); + e.goodEffect = atoi(row[83]); + e.Activated = atoi(row[84]); + e.resisttype = atoi(row[85]); + e.effectid1 = atoi(row[86]); + e.effectid2 = atoi(row[87]); + e.effectid3 = atoi(row[88]); + e.effectid4 = atoi(row[89]); + e.effectid5 = atoi(row[90]); + e.effectid6 = atoi(row[91]); + e.effectid7 = atoi(row[92]); + e.effectid8 = atoi(row[93]); + e.effectid9 = atoi(row[94]); + e.effectid10 = atoi(row[95]); + e.effectid11 = atoi(row[96]); + e.effectid12 = atoi(row[97]); + e.targettype = atoi(row[98]); + e.basediff = atoi(row[99]); + e.skill = atoi(row[100]); + e.zonetype = atoi(row[101]); + e.EnvironmentType = atoi(row[102]); + e.TimeOfDay = atoi(row[103]); + e.classes1 = atoi(row[104]); + e.classes2 = atoi(row[105]); + e.classes3 = atoi(row[106]); + e.classes4 = atoi(row[107]); + e.classes5 = atoi(row[108]); + e.classes6 = atoi(row[109]); + e.classes7 = atoi(row[110]); + e.classes8 = atoi(row[111]); + e.classes9 = atoi(row[112]); + e.classes10 = atoi(row[113]); + e.classes11 = atoi(row[114]); + e.classes12 = atoi(row[115]); + e.classes13 = atoi(row[116]); + e.classes14 = atoi(row[117]); + e.classes15 = atoi(row[118]); + e.classes16 = atoi(row[119]); + e.CastingAnim = atoi(row[120]); + e.TargetAnim = atoi(row[121]); + e.TravelType = atoi(row[122]); + e.SpellAffectIndex = atoi(row[123]); + e.disallow_sit = atoi(row[124]); + e.deities0 = atoi(row[125]); + e.deities1 = atoi(row[126]); + e.deities2 = atoi(row[127]); + e.deities3 = atoi(row[128]); + e.deities4 = atoi(row[129]); + e.deities5 = atoi(row[130]); + e.deities6 = atoi(row[131]); + e.deities7 = atoi(row[132]); + e.deities8 = atoi(row[133]); + e.deities9 = atoi(row[134]); + e.deities10 = atoi(row[135]); + e.deities11 = atoi(row[136]); + e.deities12 = atoi(row[137]); + e.deities13 = atoi(row[138]); + e.deities14 = atoi(row[139]); + e.deities15 = atoi(row[140]); + e.deities16 = atoi(row[141]); + e.field142 = atoi(row[142]); + e.field143 = atoi(row[143]); + e.new_icon = atoi(row[144]); + e.spellanim = atoi(row[145]); + e.uninterruptable = atoi(row[146]); + e.ResistDiff = atoi(row[147]); + e.dot_stacking_exempt = atoi(row[148]); + e.deleteable = atoi(row[149]); + e.RecourseLink = atoi(row[150]); + e.no_partial_resist = atoi(row[151]); + e.field152 = atoi(row[152]); + e.field153 = atoi(row[153]); + e.short_buff_box = atoi(row[154]); + e.descnum = atoi(row[155]); + e.typedescnum = atoi(row[156]); + e.effectdescnum = atoi(row[157]); + e.effectdescnum2 = atoi(row[158]); + e.npc_no_los = atoi(row[159]); + e.field160 = atoi(row[160]); + e.reflectable = atoi(row[161]); + e.bonushate = atoi(row[162]); + e.field163 = atoi(row[163]); + e.field164 = atoi(row[164]); + e.ldon_trap = atoi(row[165]); + e.EndurCost = atoi(row[166]); + e.EndurTimerIndex = atoi(row[167]); + e.IsDiscipline = atoi(row[168]); + e.field169 = atoi(row[169]); + e.field170 = atoi(row[170]); + e.field171 = atoi(row[171]); + e.field172 = atoi(row[172]); + e.HateAdded = atoi(row[173]); + e.EndurUpkeep = atoi(row[174]); + e.numhitstype = atoi(row[175]); + e.numhits = atoi(row[176]); + e.pvpresistbase = atoi(row[177]); + e.pvpresistcalc = atoi(row[178]); + e.pvpresistcap = atoi(row[179]); + e.spell_category = atoi(row[180]); + e.pvp_duration = atoi(row[181]); + e.pvp_duration_cap = atoi(row[182]); + e.pcnpc_only_flag = atoi(row[183]); + e.cast_not_standing = atoi(row[184]); + e.can_mgb = atoi(row[185]); + e.nodispell = atoi(row[186]); + e.npc_category = atoi(row[187]); + e.npc_usefulness = atoi(row[188]); + e.MinResist = atoi(row[189]); + e.MaxResist = atoi(row[190]); + e.viral_targets = atoi(row[191]); + e.viral_timer = atoi(row[192]); + e.nimbuseffect = atoi(row[193]); + e.ConeStartAngle = atoi(row[194]); + e.ConeStopAngle = atoi(row[195]); + e.sneaking = atoi(row[196]); + e.not_extendable = atoi(row[197]); + e.field198 = atoi(row[198]); + e.field199 = atoi(row[199]); + e.suspendable = atoi(row[200]); + e.viral_range = atoi(row[201]); + e.songcap = atoi(row[202]); + e.field203 = atoi(row[203]); + e.field204 = atoi(row[204]); + e.no_block = atoi(row[205]); + e.field206 = atoi(row[206]); + e.spellgroup = atoi(row[207]); + e.rank = atoi(row[208]); + e.field209 = atoi(row[209]); + e.field210 = atoi(row[210]); + e.CastRestriction = atoi(row[211]); + e.allowrest = atoi(row[212]); + e.InCombat = atoi(row[213]); + e.OutofCombat = atoi(row[214]); + e.field215 = atoi(row[215]); + e.field216 = atoi(row[216]); + e.field217 = atoi(row[217]); + e.aemaxtargets = atoi(row[218]); + e.maxtargets = atoi(row[219]); + e.field220 = atoi(row[220]); + e.field221 = atoi(row[221]); + e.field222 = atoi(row[222]); + e.field223 = atoi(row[223]); + e.persistdeath = atoi(row[224]); + e.field225 = atoi(row[225]); + e.field226 = atoi(row[226]); + e.min_dist = static_cast(atof(row[227])); + e.min_dist_mod = static_cast(atof(row[228])); + e.max_dist = static_cast(atof(row[229])); + e.max_dist_mod = static_cast(atof(row[230])); + e.min_range = atoi(row[231]); + e.field232 = atoi(row[232]); + e.field233 = atoi(row[233]); + e.field234 = atoi(row[234]); + e.field235 = atoi(row[235]); + e.field236 = atoi(row[236]); - all_entries.push_back(entry); + all_entries.push_back(e); } return all_entries; } - static std::vector GetWhere(Database& db, std::string where_filter) + static std::vector GetWhere(Database& db, const std::string &where_filter) { std::vector all_entries; @@ -2381,253 +2381,253 @@ public: all_entries.reserve(results.RowCount()); for (auto row = results.begin(); row != results.end(); ++row) { - SpellsNew entry{}; + SpellsNew e{}; - entry.id = atoi(row[0]); - entry.name = row[1] ? row[1] : ""; - entry.player_1 = row[2] ? row[2] : ""; - entry.teleport_zone = row[3] ? row[3] : ""; - entry.you_cast = row[4] ? row[4] : ""; - entry.other_casts = row[5] ? row[5] : ""; - entry.cast_on_you = row[6] ? row[6] : ""; - entry.cast_on_other = row[7] ? row[7] : ""; - entry.spell_fades = row[8] ? row[8] : ""; - entry.range = atoi(row[9]); - entry.aoerange = atoi(row[10]); - entry.pushback = atoi(row[11]); - entry.pushup = atoi(row[12]); - entry.cast_time = atoi(row[13]); - entry.recovery_time = atoi(row[14]); - entry.recast_time = atoi(row[15]); - entry.buffdurationformula = atoi(row[16]); - entry.buffduration = atoi(row[17]); - entry.AEDuration = atoi(row[18]); - entry.mana = atoi(row[19]); - entry.effect_base_value1 = atoi(row[20]); - entry.effect_base_value2 = atoi(row[21]); - entry.effect_base_value3 = atoi(row[22]); - entry.effect_base_value4 = atoi(row[23]); - entry.effect_base_value5 = atoi(row[24]); - entry.effect_base_value6 = atoi(row[25]); - entry.effect_base_value7 = atoi(row[26]); - entry.effect_base_value8 = atoi(row[27]); - entry.effect_base_value9 = atoi(row[28]); - entry.effect_base_value10 = atoi(row[29]); - entry.effect_base_value11 = atoi(row[30]); - entry.effect_base_value12 = atoi(row[31]); - entry.effect_limit_value1 = atoi(row[32]); - entry.effect_limit_value2 = atoi(row[33]); - entry.effect_limit_value3 = atoi(row[34]); - entry.effect_limit_value4 = atoi(row[35]); - entry.effect_limit_value5 = atoi(row[36]); - entry.effect_limit_value6 = atoi(row[37]); - entry.effect_limit_value7 = atoi(row[38]); - entry.effect_limit_value8 = atoi(row[39]); - entry.effect_limit_value9 = atoi(row[40]); - entry.effect_limit_value10 = atoi(row[41]); - entry.effect_limit_value11 = atoi(row[42]); - entry.effect_limit_value12 = atoi(row[43]); - entry.max1 = atoi(row[44]); - entry.max2 = atoi(row[45]); - entry.max3 = atoi(row[46]); - entry.max4 = atoi(row[47]); - entry.max5 = atoi(row[48]); - entry.max6 = atoi(row[49]); - entry.max7 = atoi(row[50]); - entry.max8 = atoi(row[51]); - entry.max9 = atoi(row[52]); - entry.max10 = atoi(row[53]); - entry.max11 = atoi(row[54]); - entry.max12 = atoi(row[55]); - entry.icon = atoi(row[56]); - entry.memicon = atoi(row[57]); - entry.components1 = atoi(row[58]); - entry.components2 = atoi(row[59]); - entry.components3 = atoi(row[60]); - entry.components4 = atoi(row[61]); - entry.component_counts1 = atoi(row[62]); - entry.component_counts2 = atoi(row[63]); - entry.component_counts3 = atoi(row[64]); - entry.component_counts4 = atoi(row[65]); - entry.NoexpendReagent1 = atoi(row[66]); - entry.NoexpendReagent2 = atoi(row[67]); - entry.NoexpendReagent3 = atoi(row[68]); - entry.NoexpendReagent4 = atoi(row[69]); - entry.formula1 = atoi(row[70]); - entry.formula2 = atoi(row[71]); - entry.formula3 = atoi(row[72]); - entry.formula4 = atoi(row[73]); - entry.formula5 = atoi(row[74]); - entry.formula6 = atoi(row[75]); - entry.formula7 = atoi(row[76]); - entry.formula8 = atoi(row[77]); - entry.formula9 = atoi(row[78]); - entry.formula10 = atoi(row[79]); - entry.formula11 = atoi(row[80]); - entry.formula12 = atoi(row[81]); - entry.LightType = atoi(row[82]); - entry.goodEffect = atoi(row[83]); - entry.Activated = atoi(row[84]); - entry.resisttype = atoi(row[85]); - entry.effectid1 = atoi(row[86]); - entry.effectid2 = atoi(row[87]); - entry.effectid3 = atoi(row[88]); - entry.effectid4 = atoi(row[89]); - entry.effectid5 = atoi(row[90]); - entry.effectid6 = atoi(row[91]); - entry.effectid7 = atoi(row[92]); - entry.effectid8 = atoi(row[93]); - entry.effectid9 = atoi(row[94]); - entry.effectid10 = atoi(row[95]); - entry.effectid11 = atoi(row[96]); - entry.effectid12 = atoi(row[97]); - entry.targettype = atoi(row[98]); - entry.basediff = atoi(row[99]); - entry.skill = atoi(row[100]); - entry.zonetype = atoi(row[101]); - entry.EnvironmentType = atoi(row[102]); - entry.TimeOfDay = atoi(row[103]); - entry.classes1 = atoi(row[104]); - entry.classes2 = atoi(row[105]); - entry.classes3 = atoi(row[106]); - entry.classes4 = atoi(row[107]); - entry.classes5 = atoi(row[108]); - entry.classes6 = atoi(row[109]); - entry.classes7 = atoi(row[110]); - entry.classes8 = atoi(row[111]); - entry.classes9 = atoi(row[112]); - entry.classes10 = atoi(row[113]); - entry.classes11 = atoi(row[114]); - entry.classes12 = atoi(row[115]); - entry.classes13 = atoi(row[116]); - entry.classes14 = atoi(row[117]); - entry.classes15 = atoi(row[118]); - entry.classes16 = atoi(row[119]); - entry.CastingAnim = atoi(row[120]); - entry.TargetAnim = atoi(row[121]); - entry.TravelType = atoi(row[122]); - entry.SpellAffectIndex = atoi(row[123]); - entry.disallow_sit = atoi(row[124]); - entry.deities0 = atoi(row[125]); - entry.deities1 = atoi(row[126]); - entry.deities2 = atoi(row[127]); - entry.deities3 = atoi(row[128]); - entry.deities4 = atoi(row[129]); - entry.deities5 = atoi(row[130]); - entry.deities6 = atoi(row[131]); - entry.deities7 = atoi(row[132]); - entry.deities8 = atoi(row[133]); - entry.deities9 = atoi(row[134]); - entry.deities10 = atoi(row[135]); - entry.deities11 = atoi(row[136]); - entry.deities12 = atoi(row[137]); - entry.deities13 = atoi(row[138]); - entry.deities14 = atoi(row[139]); - entry.deities15 = atoi(row[140]); - entry.deities16 = atoi(row[141]); - entry.field142 = atoi(row[142]); - entry.field143 = atoi(row[143]); - entry.new_icon = atoi(row[144]); - entry.spellanim = atoi(row[145]); - entry.uninterruptable = atoi(row[146]); - entry.ResistDiff = atoi(row[147]); - entry.dot_stacking_exempt = atoi(row[148]); - entry.deleteable = atoi(row[149]); - entry.RecourseLink = atoi(row[150]); - entry.no_partial_resist = atoi(row[151]); - entry.field152 = atoi(row[152]); - entry.field153 = atoi(row[153]); - entry.short_buff_box = atoi(row[154]); - entry.descnum = atoi(row[155]); - entry.typedescnum = atoi(row[156]); - entry.effectdescnum = atoi(row[157]); - entry.effectdescnum2 = atoi(row[158]); - entry.npc_no_los = atoi(row[159]); - entry.field160 = atoi(row[160]); - entry.reflectable = atoi(row[161]); - entry.bonushate = atoi(row[162]); - entry.field163 = atoi(row[163]); - entry.field164 = atoi(row[164]); - entry.ldon_trap = atoi(row[165]); - entry.EndurCost = atoi(row[166]); - entry.EndurTimerIndex = atoi(row[167]); - entry.IsDiscipline = atoi(row[168]); - entry.field169 = atoi(row[169]); - entry.field170 = atoi(row[170]); - entry.field171 = atoi(row[171]); - entry.field172 = atoi(row[172]); - entry.HateAdded = atoi(row[173]); - entry.EndurUpkeep = atoi(row[174]); - entry.numhitstype = atoi(row[175]); - entry.numhits = atoi(row[176]); - entry.pvpresistbase = atoi(row[177]); - entry.pvpresistcalc = atoi(row[178]); - entry.pvpresistcap = atoi(row[179]); - entry.spell_category = atoi(row[180]); - entry.pvp_duration = atoi(row[181]); - entry.pvp_duration_cap = atoi(row[182]); - entry.pcnpc_only_flag = atoi(row[183]); - entry.cast_not_standing = atoi(row[184]); - entry.can_mgb = atoi(row[185]); - entry.nodispell = atoi(row[186]); - entry.npc_category = atoi(row[187]); - entry.npc_usefulness = atoi(row[188]); - entry.MinResist = atoi(row[189]); - entry.MaxResist = atoi(row[190]); - entry.viral_targets = atoi(row[191]); - entry.viral_timer = atoi(row[192]); - entry.nimbuseffect = atoi(row[193]); - entry.ConeStartAngle = atoi(row[194]); - entry.ConeStopAngle = atoi(row[195]); - entry.sneaking = atoi(row[196]); - entry.not_extendable = atoi(row[197]); - entry.field198 = atoi(row[198]); - entry.field199 = atoi(row[199]); - entry.suspendable = atoi(row[200]); - entry.viral_range = atoi(row[201]); - entry.songcap = atoi(row[202]); - entry.field203 = atoi(row[203]); - entry.field204 = atoi(row[204]); - entry.no_block = atoi(row[205]); - entry.field206 = atoi(row[206]); - entry.spellgroup = atoi(row[207]); - entry.rank = atoi(row[208]); - entry.field209 = atoi(row[209]); - entry.field210 = atoi(row[210]); - entry.CastRestriction = atoi(row[211]); - entry.allowrest = atoi(row[212]); - entry.InCombat = atoi(row[213]); - entry.OutofCombat = atoi(row[214]); - entry.field215 = atoi(row[215]); - entry.field216 = atoi(row[216]); - entry.field217 = atoi(row[217]); - entry.aemaxtargets = atoi(row[218]); - entry.maxtargets = atoi(row[219]); - entry.field220 = atoi(row[220]); - entry.field221 = atoi(row[221]); - entry.field222 = atoi(row[222]); - entry.field223 = atoi(row[223]); - entry.persistdeath = atoi(row[224]); - entry.field225 = atoi(row[225]); - entry.field226 = atoi(row[226]); - entry.min_dist = static_cast(atof(row[227])); - entry.min_dist_mod = static_cast(atof(row[228])); - entry.max_dist = static_cast(atof(row[229])); - entry.max_dist_mod = static_cast(atof(row[230])); - entry.min_range = atoi(row[231]); - entry.field232 = atoi(row[232]); - entry.field233 = atoi(row[233]); - entry.field234 = atoi(row[234]); - entry.field235 = atoi(row[235]); - entry.field236 = atoi(row[236]); + e.id = atoi(row[0]); + e.name = row[1] ? row[1] : ""; + e.player_1 = row[2] ? row[2] : ""; + e.teleport_zone = row[3] ? row[3] : ""; + e.you_cast = row[4] ? row[4] : ""; + e.other_casts = row[5] ? row[5] : ""; + e.cast_on_you = row[6] ? row[6] : ""; + e.cast_on_other = row[7] ? row[7] : ""; + e.spell_fades = row[8] ? row[8] : ""; + e.range = atoi(row[9]); + e.aoerange = atoi(row[10]); + e.pushback = atoi(row[11]); + e.pushup = atoi(row[12]); + e.cast_time = atoi(row[13]); + e.recovery_time = atoi(row[14]); + e.recast_time = atoi(row[15]); + e.buffdurationformula = atoi(row[16]); + e.buffduration = atoi(row[17]); + e.AEDuration = atoi(row[18]); + e.mana = atoi(row[19]); + e.effect_base_value1 = atoi(row[20]); + e.effect_base_value2 = atoi(row[21]); + e.effect_base_value3 = atoi(row[22]); + e.effect_base_value4 = atoi(row[23]); + e.effect_base_value5 = atoi(row[24]); + e.effect_base_value6 = atoi(row[25]); + e.effect_base_value7 = atoi(row[26]); + e.effect_base_value8 = atoi(row[27]); + e.effect_base_value9 = atoi(row[28]); + e.effect_base_value10 = atoi(row[29]); + e.effect_base_value11 = atoi(row[30]); + e.effect_base_value12 = atoi(row[31]); + e.effect_limit_value1 = atoi(row[32]); + e.effect_limit_value2 = atoi(row[33]); + e.effect_limit_value3 = atoi(row[34]); + e.effect_limit_value4 = atoi(row[35]); + e.effect_limit_value5 = atoi(row[36]); + e.effect_limit_value6 = atoi(row[37]); + e.effect_limit_value7 = atoi(row[38]); + e.effect_limit_value8 = atoi(row[39]); + e.effect_limit_value9 = atoi(row[40]); + e.effect_limit_value10 = atoi(row[41]); + e.effect_limit_value11 = atoi(row[42]); + e.effect_limit_value12 = atoi(row[43]); + e.max1 = atoi(row[44]); + e.max2 = atoi(row[45]); + e.max3 = atoi(row[46]); + e.max4 = atoi(row[47]); + e.max5 = atoi(row[48]); + e.max6 = atoi(row[49]); + e.max7 = atoi(row[50]); + e.max8 = atoi(row[51]); + e.max9 = atoi(row[52]); + e.max10 = atoi(row[53]); + e.max11 = atoi(row[54]); + e.max12 = atoi(row[55]); + e.icon = atoi(row[56]); + e.memicon = atoi(row[57]); + e.components1 = atoi(row[58]); + e.components2 = atoi(row[59]); + e.components3 = atoi(row[60]); + e.components4 = atoi(row[61]); + e.component_counts1 = atoi(row[62]); + e.component_counts2 = atoi(row[63]); + e.component_counts3 = atoi(row[64]); + e.component_counts4 = atoi(row[65]); + e.NoexpendReagent1 = atoi(row[66]); + e.NoexpendReagent2 = atoi(row[67]); + e.NoexpendReagent3 = atoi(row[68]); + e.NoexpendReagent4 = atoi(row[69]); + e.formula1 = atoi(row[70]); + e.formula2 = atoi(row[71]); + e.formula3 = atoi(row[72]); + e.formula4 = atoi(row[73]); + e.formula5 = atoi(row[74]); + e.formula6 = atoi(row[75]); + e.formula7 = atoi(row[76]); + e.formula8 = atoi(row[77]); + e.formula9 = atoi(row[78]); + e.formula10 = atoi(row[79]); + e.formula11 = atoi(row[80]); + e.formula12 = atoi(row[81]); + e.LightType = atoi(row[82]); + e.goodEffect = atoi(row[83]); + e.Activated = atoi(row[84]); + e.resisttype = atoi(row[85]); + e.effectid1 = atoi(row[86]); + e.effectid2 = atoi(row[87]); + e.effectid3 = atoi(row[88]); + e.effectid4 = atoi(row[89]); + e.effectid5 = atoi(row[90]); + e.effectid6 = atoi(row[91]); + e.effectid7 = atoi(row[92]); + e.effectid8 = atoi(row[93]); + e.effectid9 = atoi(row[94]); + e.effectid10 = atoi(row[95]); + e.effectid11 = atoi(row[96]); + e.effectid12 = atoi(row[97]); + e.targettype = atoi(row[98]); + e.basediff = atoi(row[99]); + e.skill = atoi(row[100]); + e.zonetype = atoi(row[101]); + e.EnvironmentType = atoi(row[102]); + e.TimeOfDay = atoi(row[103]); + e.classes1 = atoi(row[104]); + e.classes2 = atoi(row[105]); + e.classes3 = atoi(row[106]); + e.classes4 = atoi(row[107]); + e.classes5 = atoi(row[108]); + e.classes6 = atoi(row[109]); + e.classes7 = atoi(row[110]); + e.classes8 = atoi(row[111]); + e.classes9 = atoi(row[112]); + e.classes10 = atoi(row[113]); + e.classes11 = atoi(row[114]); + e.classes12 = atoi(row[115]); + e.classes13 = atoi(row[116]); + e.classes14 = atoi(row[117]); + e.classes15 = atoi(row[118]); + e.classes16 = atoi(row[119]); + e.CastingAnim = atoi(row[120]); + e.TargetAnim = atoi(row[121]); + e.TravelType = atoi(row[122]); + e.SpellAffectIndex = atoi(row[123]); + e.disallow_sit = atoi(row[124]); + e.deities0 = atoi(row[125]); + e.deities1 = atoi(row[126]); + e.deities2 = atoi(row[127]); + e.deities3 = atoi(row[128]); + e.deities4 = atoi(row[129]); + e.deities5 = atoi(row[130]); + e.deities6 = atoi(row[131]); + e.deities7 = atoi(row[132]); + e.deities8 = atoi(row[133]); + e.deities9 = atoi(row[134]); + e.deities10 = atoi(row[135]); + e.deities11 = atoi(row[136]); + e.deities12 = atoi(row[137]); + e.deities13 = atoi(row[138]); + e.deities14 = atoi(row[139]); + e.deities15 = atoi(row[140]); + e.deities16 = atoi(row[141]); + e.field142 = atoi(row[142]); + e.field143 = atoi(row[143]); + e.new_icon = atoi(row[144]); + e.spellanim = atoi(row[145]); + e.uninterruptable = atoi(row[146]); + e.ResistDiff = atoi(row[147]); + e.dot_stacking_exempt = atoi(row[148]); + e.deleteable = atoi(row[149]); + e.RecourseLink = atoi(row[150]); + e.no_partial_resist = atoi(row[151]); + e.field152 = atoi(row[152]); + e.field153 = atoi(row[153]); + e.short_buff_box = atoi(row[154]); + e.descnum = atoi(row[155]); + e.typedescnum = atoi(row[156]); + e.effectdescnum = atoi(row[157]); + e.effectdescnum2 = atoi(row[158]); + e.npc_no_los = atoi(row[159]); + e.field160 = atoi(row[160]); + e.reflectable = atoi(row[161]); + e.bonushate = atoi(row[162]); + e.field163 = atoi(row[163]); + e.field164 = atoi(row[164]); + e.ldon_trap = atoi(row[165]); + e.EndurCost = atoi(row[166]); + e.EndurTimerIndex = atoi(row[167]); + e.IsDiscipline = atoi(row[168]); + e.field169 = atoi(row[169]); + e.field170 = atoi(row[170]); + e.field171 = atoi(row[171]); + e.field172 = atoi(row[172]); + e.HateAdded = atoi(row[173]); + e.EndurUpkeep = atoi(row[174]); + e.numhitstype = atoi(row[175]); + e.numhits = atoi(row[176]); + e.pvpresistbase = atoi(row[177]); + e.pvpresistcalc = atoi(row[178]); + e.pvpresistcap = atoi(row[179]); + e.spell_category = atoi(row[180]); + e.pvp_duration = atoi(row[181]); + e.pvp_duration_cap = atoi(row[182]); + e.pcnpc_only_flag = atoi(row[183]); + e.cast_not_standing = atoi(row[184]); + e.can_mgb = atoi(row[185]); + e.nodispell = atoi(row[186]); + e.npc_category = atoi(row[187]); + e.npc_usefulness = atoi(row[188]); + e.MinResist = atoi(row[189]); + e.MaxResist = atoi(row[190]); + e.viral_targets = atoi(row[191]); + e.viral_timer = atoi(row[192]); + e.nimbuseffect = atoi(row[193]); + e.ConeStartAngle = atoi(row[194]); + e.ConeStopAngle = atoi(row[195]); + e.sneaking = atoi(row[196]); + e.not_extendable = atoi(row[197]); + e.field198 = atoi(row[198]); + e.field199 = atoi(row[199]); + e.suspendable = atoi(row[200]); + e.viral_range = atoi(row[201]); + e.songcap = atoi(row[202]); + e.field203 = atoi(row[203]); + e.field204 = atoi(row[204]); + e.no_block = atoi(row[205]); + e.field206 = atoi(row[206]); + e.spellgroup = atoi(row[207]); + e.rank = atoi(row[208]); + e.field209 = atoi(row[209]); + e.field210 = atoi(row[210]); + e.CastRestriction = atoi(row[211]); + e.allowrest = atoi(row[212]); + e.InCombat = atoi(row[213]); + e.OutofCombat = atoi(row[214]); + e.field215 = atoi(row[215]); + e.field216 = atoi(row[216]); + e.field217 = atoi(row[217]); + e.aemaxtargets = atoi(row[218]); + e.maxtargets = atoi(row[219]); + e.field220 = atoi(row[220]); + e.field221 = atoi(row[221]); + e.field222 = atoi(row[222]); + e.field223 = atoi(row[223]); + e.persistdeath = atoi(row[224]); + e.field225 = atoi(row[225]); + e.field226 = atoi(row[226]); + e.min_dist = static_cast(atof(row[227])); + e.min_dist_mod = static_cast(atof(row[228])); + e.max_dist = static_cast(atof(row[229])); + e.max_dist_mod = static_cast(atof(row[230])); + e.min_range = atoi(row[231]); + e.field232 = atoi(row[232]); + e.field233 = atoi(row[233]); + e.field234 = atoi(row[234]); + e.field235 = atoi(row[235]); + e.field236 = atoi(row[236]); - all_entries.push_back(entry); + all_entries.push_back(e); } return all_entries; } - static int DeleteWhere(Database& db, std::string where_filter) + static int DeleteWhere(Database& db, const std::string &where_filter) { auto results = db.QueryDatabase( fmt::format( @@ -2652,6 +2652,32 @@ public: 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); + } + }; #endif //EQEMU_BASE_SPELLS_NEW_REPOSITORY_H diff --git a/common/repositories/base/base_start_zones_repository.h b/common/repositories/base/base_start_zones_repository.h index e5cee8c9a..15fe05484 100644 --- a/common/repositories/base/base_start_zones_repository.h +++ b/common/repositories/base/base_start_zones_repository.h @@ -130,32 +130,32 @@ public: static StartZones NewEntity() { - StartZones entry{}; + StartZones e{}; - entry.x = 0; - entry.y = 0; - entry.z = 0; - entry.heading = 0; - entry.zone_id = 0; - entry.bind_id = 0; - entry.player_choice = 0; - entry.player_class = 0; - entry.player_deity = 0; - entry.player_race = 0; - entry.start_zone = 0; - entry.bind_x = 0; - entry.bind_y = 0; - entry.bind_z = 0; - entry.select_rank = 50; - entry.min_expansion = -1; - entry.max_expansion = -1; - entry.content_flags = ""; - entry.content_flags_disabled = ""; + e.x = 0; + e.y = 0; + e.z = 0; + e.heading = 0; + e.zone_id = 0; + e.bind_id = 0; + e.player_choice = 0; + e.player_class = 0; + e.player_deity = 0; + e.player_race = 0; + e.start_zone = 0; + e.bind_x = 0; + e.bind_y = 0; + e.bind_z = 0; + e.select_rank = 50; + e.min_expansion = -1; + e.max_expansion = -1; + e.content_flags = ""; + e.content_flags_disabled = ""; - return entry; + return e; } - static StartZones GetStartZonesEntry( + static StartZones GetStartZones( const std::vector &start_zoness, int start_zones_id ) @@ -184,29 +184,29 @@ public: auto row = results.begin(); if (results.RowCount() == 1) { - StartZones entry{}; + StartZones e{}; - entry.x = static_cast(atof(row[0])); - entry.y = static_cast(atof(row[1])); - entry.z = static_cast(atof(row[2])); - entry.heading = static_cast(atof(row[3])); - entry.zone_id = atoi(row[4]); - entry.bind_id = atoi(row[5]); - entry.player_choice = atoi(row[6]); - entry.player_class = atoi(row[7]); - entry.player_deity = atoi(row[8]); - entry.player_race = atoi(row[9]); - entry.start_zone = atoi(row[10]); - entry.bind_x = static_cast(atof(row[11])); - entry.bind_y = static_cast(atof(row[12])); - entry.bind_z = static_cast(atof(row[13])); - entry.select_rank = atoi(row[14]); - entry.min_expansion = atoi(row[15]); - entry.max_expansion = atoi(row[16]); - entry.content_flags = row[17] ? row[17] : ""; - entry.content_flags_disabled = row[18] ? row[18] : ""; + e.x = static_cast(atof(row[0])); + e.y = static_cast(atof(row[1])); + e.z = static_cast(atof(row[2])); + e.heading = static_cast(atof(row[3])); + e.zone_id = atoi(row[4]); + e.bind_id = atoi(row[5]); + e.player_choice = atoi(row[6]); + e.player_class = atoi(row[7]); + e.player_deity = atoi(row[8]); + e.player_race = atoi(row[9]); + e.start_zone = atoi(row[10]); + e.bind_x = static_cast(atof(row[11])); + e.bind_y = static_cast(atof(row[12])); + e.bind_z = static_cast(atof(row[13])); + e.select_rank = atoi(row[14]); + e.min_expansion = atoi(row[15]); + e.max_expansion = atoi(row[16]); + e.content_flags = row[17] ? row[17] : ""; + e.content_flags_disabled = row[18] ? row[18] : ""; - return entry; + return e; } return NewEntity(); @@ -231,40 +231,40 @@ public: static int UpdateOne( Database& db, - StartZones start_zones_entry + const StartZones &e ) { - std::vector update_values; + std::vector v; auto columns = Columns(); - update_values.push_back(columns[0] + " = " + std::to_string(start_zones_entry.x)); - update_values.push_back(columns[1] + " = " + std::to_string(start_zones_entry.y)); - update_values.push_back(columns[2] + " = " + std::to_string(start_zones_entry.z)); - update_values.push_back(columns[3] + " = " + std::to_string(start_zones_entry.heading)); - update_values.push_back(columns[4] + " = " + std::to_string(start_zones_entry.zone_id)); - update_values.push_back(columns[5] + " = " + std::to_string(start_zones_entry.bind_id)); - update_values.push_back(columns[6] + " = " + std::to_string(start_zones_entry.player_choice)); - update_values.push_back(columns[7] + " = " + std::to_string(start_zones_entry.player_class)); - update_values.push_back(columns[8] + " = " + std::to_string(start_zones_entry.player_deity)); - update_values.push_back(columns[9] + " = " + std::to_string(start_zones_entry.player_race)); - update_values.push_back(columns[10] + " = " + std::to_string(start_zones_entry.start_zone)); - update_values.push_back(columns[11] + " = " + std::to_string(start_zones_entry.bind_x)); - update_values.push_back(columns[12] + " = " + std::to_string(start_zones_entry.bind_y)); - update_values.push_back(columns[13] + " = " + std::to_string(start_zones_entry.bind_z)); - update_values.push_back(columns[14] + " = " + std::to_string(start_zones_entry.select_rank)); - update_values.push_back(columns[15] + " = " + std::to_string(start_zones_entry.min_expansion)); - update_values.push_back(columns[16] + " = " + std::to_string(start_zones_entry.max_expansion)); - update_values.push_back(columns[17] + " = '" + Strings::Escape(start_zones_entry.content_flags) + "'"); - update_values.push_back(columns[18] + " = '" + Strings::Escape(start_zones_entry.content_flags_disabled) + "'"); + v.push_back(columns[0] + " = " + std::to_string(e.x)); + v.push_back(columns[1] + " = " + std::to_string(e.y)); + v.push_back(columns[2] + " = " + std::to_string(e.z)); + v.push_back(columns[3] + " = " + std::to_string(e.heading)); + v.push_back(columns[4] + " = " + std::to_string(e.zone_id)); + v.push_back(columns[5] + " = " + std::to_string(e.bind_id)); + v.push_back(columns[6] + " = " + std::to_string(e.player_choice)); + v.push_back(columns[7] + " = " + std::to_string(e.player_class)); + v.push_back(columns[8] + " = " + std::to_string(e.player_deity)); + v.push_back(columns[9] + " = " + std::to_string(e.player_race)); + v.push_back(columns[10] + " = " + std::to_string(e.start_zone)); + v.push_back(columns[11] + " = " + std::to_string(e.bind_x)); + v.push_back(columns[12] + " = " + std::to_string(e.bind_y)); + v.push_back(columns[13] + " = " + std::to_string(e.bind_z)); + v.push_back(columns[14] + " = " + std::to_string(e.select_rank)); + v.push_back(columns[15] + " = " + std::to_string(e.min_expansion)); + v.push_back(columns[16] + " = " + std::to_string(e.max_expansion)); + v.push_back(columns[17] + " = '" + Strings::Escape(e.content_flags) + "'"); + v.push_back(columns[18] + " = '" + Strings::Escape(e.content_flags_disabled) + "'"); auto results = db.QueryDatabase( fmt::format( "UPDATE {} SET {} WHERE {} = {}", TableName(), - Strings::Implode(", ", update_values), + Strings::Implode(", ", v), PrimaryKey(), - start_zones_entry.player_choice + e.player_choice ) ); @@ -273,83 +273,83 @@ public: static StartZones InsertOne( Database& db, - StartZones start_zones_entry + StartZones e ) { - std::vector insert_values; + std::vector v; - insert_values.push_back(std::to_string(start_zones_entry.x)); - insert_values.push_back(std::to_string(start_zones_entry.y)); - insert_values.push_back(std::to_string(start_zones_entry.z)); - insert_values.push_back(std::to_string(start_zones_entry.heading)); - insert_values.push_back(std::to_string(start_zones_entry.zone_id)); - insert_values.push_back(std::to_string(start_zones_entry.bind_id)); - insert_values.push_back(std::to_string(start_zones_entry.player_choice)); - insert_values.push_back(std::to_string(start_zones_entry.player_class)); - insert_values.push_back(std::to_string(start_zones_entry.player_deity)); - insert_values.push_back(std::to_string(start_zones_entry.player_race)); - insert_values.push_back(std::to_string(start_zones_entry.start_zone)); - insert_values.push_back(std::to_string(start_zones_entry.bind_x)); - insert_values.push_back(std::to_string(start_zones_entry.bind_y)); - insert_values.push_back(std::to_string(start_zones_entry.bind_z)); - insert_values.push_back(std::to_string(start_zones_entry.select_rank)); - insert_values.push_back(std::to_string(start_zones_entry.min_expansion)); - insert_values.push_back(std::to_string(start_zones_entry.max_expansion)); - insert_values.push_back("'" + Strings::Escape(start_zones_entry.content_flags) + "'"); - insert_values.push_back("'" + Strings::Escape(start_zones_entry.content_flags_disabled) + "'"); + v.push_back(std::to_string(e.x)); + v.push_back(std::to_string(e.y)); + v.push_back(std::to_string(e.z)); + v.push_back(std::to_string(e.heading)); + v.push_back(std::to_string(e.zone_id)); + v.push_back(std::to_string(e.bind_id)); + v.push_back(std::to_string(e.player_choice)); + v.push_back(std::to_string(e.player_class)); + v.push_back(std::to_string(e.player_deity)); + v.push_back(std::to_string(e.player_race)); + v.push_back(std::to_string(e.start_zone)); + v.push_back(std::to_string(e.bind_x)); + v.push_back(std::to_string(e.bind_y)); + v.push_back(std::to_string(e.bind_z)); + v.push_back(std::to_string(e.select_rank)); + v.push_back(std::to_string(e.min_expansion)); + v.push_back(std::to_string(e.max_expansion)); + v.push_back("'" + Strings::Escape(e.content_flags) + "'"); + v.push_back("'" + Strings::Escape(e.content_flags_disabled) + "'"); auto results = db.QueryDatabase( fmt::format( "{} VALUES ({})", BaseInsert(), - Strings::Implode(",", insert_values) + Strings::Implode(",", v) ) ); if (results.Success()) { - start_zones_entry.player_choice = results.LastInsertedID(); - return start_zones_entry; + e.player_choice = results.LastInsertedID(); + return e; } - start_zones_entry = NewEntity(); + e = NewEntity(); - return start_zones_entry; + return e; } static int InsertMany( Database& db, - std::vector start_zones_entries + const std::vector &entries ) { std::vector insert_chunks; - for (auto &start_zones_entry: start_zones_entries) { - std::vector insert_values; + for (auto &e: entries) { + std::vector v; - insert_values.push_back(std::to_string(start_zones_entry.x)); - insert_values.push_back(std::to_string(start_zones_entry.y)); - insert_values.push_back(std::to_string(start_zones_entry.z)); - insert_values.push_back(std::to_string(start_zones_entry.heading)); - insert_values.push_back(std::to_string(start_zones_entry.zone_id)); - insert_values.push_back(std::to_string(start_zones_entry.bind_id)); - insert_values.push_back(std::to_string(start_zones_entry.player_choice)); - insert_values.push_back(std::to_string(start_zones_entry.player_class)); - insert_values.push_back(std::to_string(start_zones_entry.player_deity)); - insert_values.push_back(std::to_string(start_zones_entry.player_race)); - insert_values.push_back(std::to_string(start_zones_entry.start_zone)); - insert_values.push_back(std::to_string(start_zones_entry.bind_x)); - insert_values.push_back(std::to_string(start_zones_entry.bind_y)); - insert_values.push_back(std::to_string(start_zones_entry.bind_z)); - insert_values.push_back(std::to_string(start_zones_entry.select_rank)); - insert_values.push_back(std::to_string(start_zones_entry.min_expansion)); - insert_values.push_back(std::to_string(start_zones_entry.max_expansion)); - insert_values.push_back("'" + Strings::Escape(start_zones_entry.content_flags) + "'"); - insert_values.push_back("'" + Strings::Escape(start_zones_entry.content_flags_disabled) + "'"); + v.push_back(std::to_string(e.x)); + v.push_back(std::to_string(e.y)); + v.push_back(std::to_string(e.z)); + v.push_back(std::to_string(e.heading)); + v.push_back(std::to_string(e.zone_id)); + v.push_back(std::to_string(e.bind_id)); + v.push_back(std::to_string(e.player_choice)); + v.push_back(std::to_string(e.player_class)); + v.push_back(std::to_string(e.player_deity)); + v.push_back(std::to_string(e.player_race)); + v.push_back(std::to_string(e.start_zone)); + v.push_back(std::to_string(e.bind_x)); + v.push_back(std::to_string(e.bind_y)); + v.push_back(std::to_string(e.bind_z)); + v.push_back(std::to_string(e.select_rank)); + v.push_back(std::to_string(e.min_expansion)); + v.push_back(std::to_string(e.max_expansion)); + v.push_back("'" + Strings::Escape(e.content_flags) + "'"); + v.push_back("'" + Strings::Escape(e.content_flags_disabled) + "'"); - insert_chunks.push_back("(" + Strings::Implode(",", insert_values) + ")"); + insert_chunks.push_back("(" + Strings::Implode(",", v) + ")"); } - std::vector insert_values; + std::vector v; auto results = db.QueryDatabase( fmt::format( @@ -376,35 +376,35 @@ public: all_entries.reserve(results.RowCount()); for (auto row = results.begin(); row != results.end(); ++row) { - StartZones entry{}; + StartZones e{}; - entry.x = static_cast(atof(row[0])); - entry.y = static_cast(atof(row[1])); - entry.z = static_cast(atof(row[2])); - entry.heading = static_cast(atof(row[3])); - entry.zone_id = atoi(row[4]); - entry.bind_id = atoi(row[5]); - entry.player_choice = atoi(row[6]); - entry.player_class = atoi(row[7]); - entry.player_deity = atoi(row[8]); - entry.player_race = atoi(row[9]); - entry.start_zone = atoi(row[10]); - entry.bind_x = static_cast(atof(row[11])); - entry.bind_y = static_cast(atof(row[12])); - entry.bind_z = static_cast(atof(row[13])); - entry.select_rank = atoi(row[14]); - entry.min_expansion = atoi(row[15]); - entry.max_expansion = atoi(row[16]); - entry.content_flags = row[17] ? row[17] : ""; - entry.content_flags_disabled = row[18] ? row[18] : ""; + e.x = static_cast(atof(row[0])); + e.y = static_cast(atof(row[1])); + e.z = static_cast(atof(row[2])); + e.heading = static_cast(atof(row[3])); + e.zone_id = atoi(row[4]); + e.bind_id = atoi(row[5]); + e.player_choice = atoi(row[6]); + e.player_class = atoi(row[7]); + e.player_deity = atoi(row[8]); + e.player_race = atoi(row[9]); + e.start_zone = atoi(row[10]); + e.bind_x = static_cast(atof(row[11])); + e.bind_y = static_cast(atof(row[12])); + e.bind_z = static_cast(atof(row[13])); + e.select_rank = atoi(row[14]); + e.min_expansion = atoi(row[15]); + e.max_expansion = atoi(row[16]); + e.content_flags = row[17] ? row[17] : ""; + e.content_flags_disabled = row[18] ? row[18] : ""; - all_entries.push_back(entry); + all_entries.push_back(e); } return all_entries; } - static std::vector GetWhere(Database& db, std::string where_filter) + static std::vector GetWhere(Database& db, const std::string &where_filter) { std::vector all_entries; @@ -419,35 +419,35 @@ public: all_entries.reserve(results.RowCount()); for (auto row = results.begin(); row != results.end(); ++row) { - StartZones entry{}; + StartZones e{}; - entry.x = static_cast(atof(row[0])); - entry.y = static_cast(atof(row[1])); - entry.z = static_cast(atof(row[2])); - entry.heading = static_cast(atof(row[3])); - entry.zone_id = atoi(row[4]); - entry.bind_id = atoi(row[5]); - entry.player_choice = atoi(row[6]); - entry.player_class = atoi(row[7]); - entry.player_deity = atoi(row[8]); - entry.player_race = atoi(row[9]); - entry.start_zone = atoi(row[10]); - entry.bind_x = static_cast(atof(row[11])); - entry.bind_y = static_cast(atof(row[12])); - entry.bind_z = static_cast(atof(row[13])); - entry.select_rank = atoi(row[14]); - entry.min_expansion = atoi(row[15]); - entry.max_expansion = atoi(row[16]); - entry.content_flags = row[17] ? row[17] : ""; - entry.content_flags_disabled = row[18] ? row[18] : ""; + e.x = static_cast(atof(row[0])); + e.y = static_cast(atof(row[1])); + e.z = static_cast(atof(row[2])); + e.heading = static_cast(atof(row[3])); + e.zone_id = atoi(row[4]); + e.bind_id = atoi(row[5]); + e.player_choice = atoi(row[6]); + e.player_class = atoi(row[7]); + e.player_deity = atoi(row[8]); + e.player_race = atoi(row[9]); + e.start_zone = atoi(row[10]); + e.bind_x = static_cast(atof(row[11])); + e.bind_y = static_cast(atof(row[12])); + e.bind_z = static_cast(atof(row[13])); + e.select_rank = atoi(row[14]); + e.min_expansion = atoi(row[15]); + e.max_expansion = atoi(row[16]); + e.content_flags = row[17] ? row[17] : ""; + e.content_flags_disabled = row[18] ? row[18] : ""; - all_entries.push_back(entry); + all_entries.push_back(e); } return all_entries; } - static int DeleteWhere(Database& db, std::string where_filter) + static int DeleteWhere(Database& db, const std::string &where_filter) { auto results = db.QueryDatabase( fmt::format( @@ -472,6 +472,32 @@ public: 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); + } + }; #endif //EQEMU_BASE_START_ZONES_REPOSITORY_H diff --git a/common/repositories/base/base_starting_items_repository.h b/common/repositories/base/base_starting_items_repository.h index d2cdfb455..413fd140f 100644 --- a/common/repositories/base/base_starting_items_repository.h +++ b/common/repositories/base/base_starting_items_repository.h @@ -112,26 +112,26 @@ public: static StartingItems NewEntity() { - StartingItems entry{}; + StartingItems e{}; - entry.id = 0; - entry.race = 0; - entry.class_ = 0; - entry.deityid = 0; - entry.zoneid = 0; - entry.itemid = 0; - entry.item_charges = 1; - entry.gm = 0; - entry.slot = -1; - entry.min_expansion = -1; - entry.max_expansion = -1; - entry.content_flags = ""; - entry.content_flags_disabled = ""; + e.id = 0; + e.race = 0; + e.class_ = 0; + e.deityid = 0; + e.zoneid = 0; + e.itemid = 0; + e.item_charges = 1; + e.gm = 0; + e.slot = -1; + e.min_expansion = -1; + e.max_expansion = -1; + e.content_flags = ""; + e.content_flags_disabled = ""; - return entry; + return e; } - static StartingItems GetStartingItemsEntry( + static StartingItems GetStartingItems( const std::vector &starting_itemss, int starting_items_id ) @@ -160,23 +160,23 @@ public: auto row = results.begin(); if (results.RowCount() == 1) { - StartingItems entry{}; + StartingItems e{}; - entry.id = atoi(row[0]); - entry.race = atoi(row[1]); - entry.class_ = atoi(row[2]); - entry.deityid = atoi(row[3]); - entry.zoneid = atoi(row[4]); - entry.itemid = atoi(row[5]); - entry.item_charges = atoi(row[6]); - entry.gm = atoi(row[7]); - entry.slot = atoi(row[8]); - entry.min_expansion = atoi(row[9]); - entry.max_expansion = atoi(row[10]); - entry.content_flags = row[11] ? row[11] : ""; - entry.content_flags_disabled = row[12] ? row[12] : ""; + e.id = atoi(row[0]); + e.race = atoi(row[1]); + e.class_ = atoi(row[2]); + e.deityid = atoi(row[3]); + e.zoneid = atoi(row[4]); + e.itemid = atoi(row[5]); + e.item_charges = atoi(row[6]); + e.gm = atoi(row[7]); + e.slot = atoi(row[8]); + e.min_expansion = atoi(row[9]); + e.max_expansion = atoi(row[10]); + e.content_flags = row[11] ? row[11] : ""; + e.content_flags_disabled = row[12] ? row[12] : ""; - return entry; + return e; } return NewEntity(); @@ -201,33 +201,33 @@ public: static int UpdateOne( Database& db, - StartingItems starting_items_entry + const StartingItems &e ) { - std::vector update_values; + std::vector v; auto columns = Columns(); - update_values.push_back(columns[1] + " = " + std::to_string(starting_items_entry.race)); - update_values.push_back(columns[2] + " = " + std::to_string(starting_items_entry.class_)); - update_values.push_back(columns[3] + " = " + std::to_string(starting_items_entry.deityid)); - update_values.push_back(columns[4] + " = " + std::to_string(starting_items_entry.zoneid)); - update_values.push_back(columns[5] + " = " + std::to_string(starting_items_entry.itemid)); - update_values.push_back(columns[6] + " = " + std::to_string(starting_items_entry.item_charges)); - update_values.push_back(columns[7] + " = " + std::to_string(starting_items_entry.gm)); - update_values.push_back(columns[8] + " = " + std::to_string(starting_items_entry.slot)); - update_values.push_back(columns[9] + " = " + std::to_string(starting_items_entry.min_expansion)); - update_values.push_back(columns[10] + " = " + std::to_string(starting_items_entry.max_expansion)); - update_values.push_back(columns[11] + " = '" + Strings::Escape(starting_items_entry.content_flags) + "'"); - update_values.push_back(columns[12] + " = '" + Strings::Escape(starting_items_entry.content_flags_disabled) + "'"); + v.push_back(columns[1] + " = " + std::to_string(e.race)); + v.push_back(columns[2] + " = " + std::to_string(e.class_)); + v.push_back(columns[3] + " = " + std::to_string(e.deityid)); + v.push_back(columns[4] + " = " + std::to_string(e.zoneid)); + v.push_back(columns[5] + " = " + std::to_string(e.itemid)); + v.push_back(columns[6] + " = " + std::to_string(e.item_charges)); + v.push_back(columns[7] + " = " + std::to_string(e.gm)); + v.push_back(columns[8] + " = " + std::to_string(e.slot)); + v.push_back(columns[9] + " = " + std::to_string(e.min_expansion)); + v.push_back(columns[10] + " = " + std::to_string(e.max_expansion)); + v.push_back(columns[11] + " = '" + Strings::Escape(e.content_flags) + "'"); + v.push_back(columns[12] + " = '" + Strings::Escape(e.content_flags_disabled) + "'"); auto results = db.QueryDatabase( fmt::format( "UPDATE {} SET {} WHERE {} = {}", TableName(), - Strings::Implode(", ", update_values), + Strings::Implode(", ", v), PrimaryKey(), - starting_items_entry.id + e.id ) ); @@ -236,71 +236,71 @@ public: static StartingItems InsertOne( Database& db, - StartingItems starting_items_entry + StartingItems e ) { - std::vector insert_values; + std::vector v; - insert_values.push_back(std::to_string(starting_items_entry.id)); - insert_values.push_back(std::to_string(starting_items_entry.race)); - insert_values.push_back(std::to_string(starting_items_entry.class_)); - insert_values.push_back(std::to_string(starting_items_entry.deityid)); - insert_values.push_back(std::to_string(starting_items_entry.zoneid)); - insert_values.push_back(std::to_string(starting_items_entry.itemid)); - insert_values.push_back(std::to_string(starting_items_entry.item_charges)); - insert_values.push_back(std::to_string(starting_items_entry.gm)); - insert_values.push_back(std::to_string(starting_items_entry.slot)); - insert_values.push_back(std::to_string(starting_items_entry.min_expansion)); - insert_values.push_back(std::to_string(starting_items_entry.max_expansion)); - insert_values.push_back("'" + Strings::Escape(starting_items_entry.content_flags) + "'"); - insert_values.push_back("'" + Strings::Escape(starting_items_entry.content_flags_disabled) + "'"); + v.push_back(std::to_string(e.id)); + v.push_back(std::to_string(e.race)); + v.push_back(std::to_string(e.class_)); + v.push_back(std::to_string(e.deityid)); + v.push_back(std::to_string(e.zoneid)); + v.push_back(std::to_string(e.itemid)); + v.push_back(std::to_string(e.item_charges)); + v.push_back(std::to_string(e.gm)); + v.push_back(std::to_string(e.slot)); + v.push_back(std::to_string(e.min_expansion)); + v.push_back(std::to_string(e.max_expansion)); + v.push_back("'" + Strings::Escape(e.content_flags) + "'"); + v.push_back("'" + Strings::Escape(e.content_flags_disabled) + "'"); auto results = db.QueryDatabase( fmt::format( "{} VALUES ({})", BaseInsert(), - Strings::Implode(",", insert_values) + Strings::Implode(",", v) ) ); if (results.Success()) { - starting_items_entry.id = results.LastInsertedID(); - return starting_items_entry; + e.id = results.LastInsertedID(); + return e; } - starting_items_entry = NewEntity(); + e = NewEntity(); - return starting_items_entry; + return e; } static int InsertMany( Database& db, - std::vector starting_items_entries + const std::vector &entries ) { std::vector insert_chunks; - for (auto &starting_items_entry: starting_items_entries) { - std::vector insert_values; + for (auto &e: entries) { + std::vector v; - insert_values.push_back(std::to_string(starting_items_entry.id)); - insert_values.push_back(std::to_string(starting_items_entry.race)); - insert_values.push_back(std::to_string(starting_items_entry.class_)); - insert_values.push_back(std::to_string(starting_items_entry.deityid)); - insert_values.push_back(std::to_string(starting_items_entry.zoneid)); - insert_values.push_back(std::to_string(starting_items_entry.itemid)); - insert_values.push_back(std::to_string(starting_items_entry.item_charges)); - insert_values.push_back(std::to_string(starting_items_entry.gm)); - insert_values.push_back(std::to_string(starting_items_entry.slot)); - insert_values.push_back(std::to_string(starting_items_entry.min_expansion)); - insert_values.push_back(std::to_string(starting_items_entry.max_expansion)); - insert_values.push_back("'" + Strings::Escape(starting_items_entry.content_flags) + "'"); - insert_values.push_back("'" + Strings::Escape(starting_items_entry.content_flags_disabled) + "'"); + v.push_back(std::to_string(e.id)); + v.push_back(std::to_string(e.race)); + v.push_back(std::to_string(e.class_)); + v.push_back(std::to_string(e.deityid)); + v.push_back(std::to_string(e.zoneid)); + v.push_back(std::to_string(e.itemid)); + v.push_back(std::to_string(e.item_charges)); + v.push_back(std::to_string(e.gm)); + v.push_back(std::to_string(e.slot)); + v.push_back(std::to_string(e.min_expansion)); + v.push_back(std::to_string(e.max_expansion)); + v.push_back("'" + Strings::Escape(e.content_flags) + "'"); + v.push_back("'" + Strings::Escape(e.content_flags_disabled) + "'"); - insert_chunks.push_back("(" + Strings::Implode(",", insert_values) + ")"); + insert_chunks.push_back("(" + Strings::Implode(",", v) + ")"); } - std::vector insert_values; + std::vector v; auto results = db.QueryDatabase( fmt::format( @@ -327,29 +327,29 @@ public: all_entries.reserve(results.RowCount()); for (auto row = results.begin(); row != results.end(); ++row) { - StartingItems entry{}; + StartingItems e{}; - entry.id = atoi(row[0]); - entry.race = atoi(row[1]); - entry.class_ = atoi(row[2]); - entry.deityid = atoi(row[3]); - entry.zoneid = atoi(row[4]); - entry.itemid = atoi(row[5]); - entry.item_charges = atoi(row[6]); - entry.gm = atoi(row[7]); - entry.slot = atoi(row[8]); - entry.min_expansion = atoi(row[9]); - entry.max_expansion = atoi(row[10]); - entry.content_flags = row[11] ? row[11] : ""; - entry.content_flags_disabled = row[12] ? row[12] : ""; + e.id = atoi(row[0]); + e.race = atoi(row[1]); + e.class_ = atoi(row[2]); + e.deityid = atoi(row[3]); + e.zoneid = atoi(row[4]); + e.itemid = atoi(row[5]); + e.item_charges = atoi(row[6]); + e.gm = atoi(row[7]); + e.slot = atoi(row[8]); + e.min_expansion = atoi(row[9]); + e.max_expansion = atoi(row[10]); + e.content_flags = row[11] ? row[11] : ""; + e.content_flags_disabled = row[12] ? row[12] : ""; - all_entries.push_back(entry); + all_entries.push_back(e); } return all_entries; } - static std::vector GetWhere(Database& db, std::string where_filter) + static std::vector GetWhere(Database& db, const std::string &where_filter) { std::vector all_entries; @@ -364,29 +364,29 @@ public: all_entries.reserve(results.RowCount()); for (auto row = results.begin(); row != results.end(); ++row) { - StartingItems entry{}; + StartingItems e{}; - entry.id = atoi(row[0]); - entry.race = atoi(row[1]); - entry.class_ = atoi(row[2]); - entry.deityid = atoi(row[3]); - entry.zoneid = atoi(row[4]); - entry.itemid = atoi(row[5]); - entry.item_charges = atoi(row[6]); - entry.gm = atoi(row[7]); - entry.slot = atoi(row[8]); - entry.min_expansion = atoi(row[9]); - entry.max_expansion = atoi(row[10]); - entry.content_flags = row[11] ? row[11] : ""; - entry.content_flags_disabled = row[12] ? row[12] : ""; + e.id = atoi(row[0]); + e.race = atoi(row[1]); + e.class_ = atoi(row[2]); + e.deityid = atoi(row[3]); + e.zoneid = atoi(row[4]); + e.itemid = atoi(row[5]); + e.item_charges = atoi(row[6]); + e.gm = atoi(row[7]); + e.slot = atoi(row[8]); + e.min_expansion = atoi(row[9]); + e.max_expansion = atoi(row[10]); + e.content_flags = row[11] ? row[11] : ""; + e.content_flags_disabled = row[12] ? row[12] : ""; - all_entries.push_back(entry); + all_entries.push_back(e); } return all_entries; } - static int DeleteWhere(Database& db, std::string where_filter) + static int DeleteWhere(Database& db, const std::string &where_filter) { auto results = db.QueryDatabase( fmt::format( @@ -411,6 +411,32 @@ public: 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); + } + }; #endif //EQEMU_BASE_STARTING_ITEMS_REPOSITORY_H diff --git a/common/repositories/base/base_task_activities_repository.h b/common/repositories/base/base_task_activities_repository.h index 70a092e27..3856aae17 100644 --- a/common/repositories/base/base_task_activities_repository.h +++ b/common/repositories/base/base_task_activities_repository.h @@ -124,30 +124,30 @@ public: static TaskActivities NewEntity() { - TaskActivities entry{}; + TaskActivities e{}; - entry.taskid = 0; - entry.activityid = 0; - entry.step = 0; - entry.activitytype = 0; - entry.target_name = ""; - entry.item_list = ""; - entry.skill_list = "-1"; - entry.spell_list = "0"; - entry.description_override = ""; - entry.goalid = 0; - entry.goal_match_list = ""; - entry.goalmethod = 0; - entry.goalcount = 1; - entry.delivertonpc = 0; - entry.zones = ""; - entry.zone_version = -1; - entry.optional = 0; + e.taskid = 0; + e.activityid = 0; + e.step = 0; + e.activitytype = 0; + e.target_name = ""; + e.item_list = ""; + e.skill_list = "-1"; + e.spell_list = "0"; + e.description_override = ""; + e.goalid = 0; + e.goal_match_list = ""; + e.goalmethod = 0; + e.goalcount = 1; + e.delivertonpc = 0; + e.zones = ""; + e.zone_version = -1; + e.optional = 0; - return entry; + return e; } - static TaskActivities GetTaskActivitiesEntry( + static TaskActivities GetTaskActivities( const std::vector &task_activitiess, int task_activities_id ) @@ -176,27 +176,27 @@ public: auto row = results.begin(); if (results.RowCount() == 1) { - TaskActivities entry{}; + TaskActivities e{}; - entry.taskid = atoi(row[0]); - entry.activityid = atoi(row[1]); - entry.step = atoi(row[2]); - entry.activitytype = atoi(row[3]); - entry.target_name = row[4] ? row[4] : ""; - entry.item_list = row[5] ? row[5] : ""; - entry.skill_list = row[6] ? row[6] : ""; - entry.spell_list = row[7] ? row[7] : ""; - entry.description_override = row[8] ? row[8] : ""; - entry.goalid = atoi(row[9]); - entry.goal_match_list = row[10] ? row[10] : ""; - entry.goalmethod = atoi(row[11]); - entry.goalcount = atoi(row[12]); - entry.delivertonpc = atoi(row[13]); - entry.zones = row[14] ? row[14] : ""; - entry.zone_version = atoi(row[15]); - entry.optional = atoi(row[16]); + e.taskid = atoi(row[0]); + e.activityid = atoi(row[1]); + e.step = atoi(row[2]); + e.activitytype = atoi(row[3]); + e.target_name = row[4] ? row[4] : ""; + e.item_list = row[5] ? row[5] : ""; + e.skill_list = row[6] ? row[6] : ""; + e.spell_list = row[7] ? row[7] : ""; + e.description_override = row[8] ? row[8] : ""; + e.goalid = atoi(row[9]); + e.goal_match_list = row[10] ? row[10] : ""; + e.goalmethod = atoi(row[11]); + e.goalcount = atoi(row[12]); + e.delivertonpc = atoi(row[13]); + e.zones = row[14] ? row[14] : ""; + e.zone_version = atoi(row[15]); + e.optional = atoi(row[16]); - return entry; + return e; } return NewEntity(); @@ -221,38 +221,38 @@ public: static int UpdateOne( Database& db, - TaskActivities task_activities_entry + const TaskActivities &e ) { - std::vector update_values; + std::vector v; auto columns = Columns(); - update_values.push_back(columns[0] + " = " + std::to_string(task_activities_entry.taskid)); - update_values.push_back(columns[1] + " = " + std::to_string(task_activities_entry.activityid)); - update_values.push_back(columns[2] + " = " + std::to_string(task_activities_entry.step)); - update_values.push_back(columns[3] + " = " + std::to_string(task_activities_entry.activitytype)); - update_values.push_back(columns[4] + " = '" + Strings::Escape(task_activities_entry.target_name) + "'"); - update_values.push_back(columns[5] + " = '" + Strings::Escape(task_activities_entry.item_list) + "'"); - update_values.push_back(columns[6] + " = '" + Strings::Escape(task_activities_entry.skill_list) + "'"); - update_values.push_back(columns[7] + " = '" + Strings::Escape(task_activities_entry.spell_list) + "'"); - update_values.push_back(columns[8] + " = '" + Strings::Escape(task_activities_entry.description_override) + "'"); - update_values.push_back(columns[9] + " = " + std::to_string(task_activities_entry.goalid)); - update_values.push_back(columns[10] + " = '" + Strings::Escape(task_activities_entry.goal_match_list) + "'"); - update_values.push_back(columns[11] + " = " + std::to_string(task_activities_entry.goalmethod)); - update_values.push_back(columns[12] + " = " + std::to_string(task_activities_entry.goalcount)); - update_values.push_back(columns[13] + " = " + std::to_string(task_activities_entry.delivertonpc)); - update_values.push_back(columns[14] + " = '" + Strings::Escape(task_activities_entry.zones) + "'"); - update_values.push_back(columns[15] + " = " + std::to_string(task_activities_entry.zone_version)); - update_values.push_back(columns[16] + " = " + std::to_string(task_activities_entry.optional)); + v.push_back(columns[0] + " = " + std::to_string(e.taskid)); + v.push_back(columns[1] + " = " + std::to_string(e.activityid)); + v.push_back(columns[2] + " = " + std::to_string(e.step)); + v.push_back(columns[3] + " = " + std::to_string(e.activitytype)); + v.push_back(columns[4] + " = '" + Strings::Escape(e.target_name) + "'"); + v.push_back(columns[5] + " = '" + Strings::Escape(e.item_list) + "'"); + v.push_back(columns[6] + " = '" + Strings::Escape(e.skill_list) + "'"); + v.push_back(columns[7] + " = '" + Strings::Escape(e.spell_list) + "'"); + v.push_back(columns[8] + " = '" + Strings::Escape(e.description_override) + "'"); + v.push_back(columns[9] + " = " + std::to_string(e.goalid)); + v.push_back(columns[10] + " = '" + Strings::Escape(e.goal_match_list) + "'"); + v.push_back(columns[11] + " = " + std::to_string(e.goalmethod)); + v.push_back(columns[12] + " = " + std::to_string(e.goalcount)); + v.push_back(columns[13] + " = " + std::to_string(e.delivertonpc)); + v.push_back(columns[14] + " = '" + Strings::Escape(e.zones) + "'"); + v.push_back(columns[15] + " = " + std::to_string(e.zone_version)); + v.push_back(columns[16] + " = " + std::to_string(e.optional)); auto results = db.QueryDatabase( fmt::format( "UPDATE {} SET {} WHERE {} = {}", TableName(), - Strings::Implode(", ", update_values), + Strings::Implode(", ", v), PrimaryKey(), - task_activities_entry.taskid + e.taskid ) ); @@ -261,79 +261,79 @@ public: static TaskActivities InsertOne( Database& db, - TaskActivities task_activities_entry + TaskActivities e ) { - std::vector insert_values; + std::vector v; - insert_values.push_back(std::to_string(task_activities_entry.taskid)); - insert_values.push_back(std::to_string(task_activities_entry.activityid)); - insert_values.push_back(std::to_string(task_activities_entry.step)); - insert_values.push_back(std::to_string(task_activities_entry.activitytype)); - insert_values.push_back("'" + Strings::Escape(task_activities_entry.target_name) + "'"); - insert_values.push_back("'" + Strings::Escape(task_activities_entry.item_list) + "'"); - insert_values.push_back("'" + Strings::Escape(task_activities_entry.skill_list) + "'"); - insert_values.push_back("'" + Strings::Escape(task_activities_entry.spell_list) + "'"); - insert_values.push_back("'" + Strings::Escape(task_activities_entry.description_override) + "'"); - insert_values.push_back(std::to_string(task_activities_entry.goalid)); - insert_values.push_back("'" + Strings::Escape(task_activities_entry.goal_match_list) + "'"); - insert_values.push_back(std::to_string(task_activities_entry.goalmethod)); - insert_values.push_back(std::to_string(task_activities_entry.goalcount)); - insert_values.push_back(std::to_string(task_activities_entry.delivertonpc)); - insert_values.push_back("'" + Strings::Escape(task_activities_entry.zones) + "'"); - insert_values.push_back(std::to_string(task_activities_entry.zone_version)); - insert_values.push_back(std::to_string(task_activities_entry.optional)); + v.push_back(std::to_string(e.taskid)); + v.push_back(std::to_string(e.activityid)); + v.push_back(std::to_string(e.step)); + v.push_back(std::to_string(e.activitytype)); + v.push_back("'" + Strings::Escape(e.target_name) + "'"); + v.push_back("'" + Strings::Escape(e.item_list) + "'"); + v.push_back("'" + Strings::Escape(e.skill_list) + "'"); + v.push_back("'" + Strings::Escape(e.spell_list) + "'"); + v.push_back("'" + Strings::Escape(e.description_override) + "'"); + v.push_back(std::to_string(e.goalid)); + v.push_back("'" + Strings::Escape(e.goal_match_list) + "'"); + v.push_back(std::to_string(e.goalmethod)); + v.push_back(std::to_string(e.goalcount)); + v.push_back(std::to_string(e.delivertonpc)); + v.push_back("'" + Strings::Escape(e.zones) + "'"); + v.push_back(std::to_string(e.zone_version)); + v.push_back(std::to_string(e.optional)); auto results = db.QueryDatabase( fmt::format( "{} VALUES ({})", BaseInsert(), - Strings::Implode(",", insert_values) + Strings::Implode(",", v) ) ); if (results.Success()) { - task_activities_entry.taskid = results.LastInsertedID(); - return task_activities_entry; + e.taskid = results.LastInsertedID(); + return e; } - task_activities_entry = NewEntity(); + e = NewEntity(); - return task_activities_entry; + return e; } static int InsertMany( Database& db, - std::vector task_activities_entries + const std::vector &entries ) { std::vector insert_chunks; - for (auto &task_activities_entry: task_activities_entries) { - std::vector insert_values; + for (auto &e: entries) { + std::vector v; - insert_values.push_back(std::to_string(task_activities_entry.taskid)); - insert_values.push_back(std::to_string(task_activities_entry.activityid)); - insert_values.push_back(std::to_string(task_activities_entry.step)); - insert_values.push_back(std::to_string(task_activities_entry.activitytype)); - insert_values.push_back("'" + Strings::Escape(task_activities_entry.target_name) + "'"); - insert_values.push_back("'" + Strings::Escape(task_activities_entry.item_list) + "'"); - insert_values.push_back("'" + Strings::Escape(task_activities_entry.skill_list) + "'"); - insert_values.push_back("'" + Strings::Escape(task_activities_entry.spell_list) + "'"); - insert_values.push_back("'" + Strings::Escape(task_activities_entry.description_override) + "'"); - insert_values.push_back(std::to_string(task_activities_entry.goalid)); - insert_values.push_back("'" + Strings::Escape(task_activities_entry.goal_match_list) + "'"); - insert_values.push_back(std::to_string(task_activities_entry.goalmethod)); - insert_values.push_back(std::to_string(task_activities_entry.goalcount)); - insert_values.push_back(std::to_string(task_activities_entry.delivertonpc)); - insert_values.push_back("'" + Strings::Escape(task_activities_entry.zones) + "'"); - insert_values.push_back(std::to_string(task_activities_entry.zone_version)); - insert_values.push_back(std::to_string(task_activities_entry.optional)); + v.push_back(std::to_string(e.taskid)); + v.push_back(std::to_string(e.activityid)); + v.push_back(std::to_string(e.step)); + v.push_back(std::to_string(e.activitytype)); + v.push_back("'" + Strings::Escape(e.target_name) + "'"); + v.push_back("'" + Strings::Escape(e.item_list) + "'"); + v.push_back("'" + Strings::Escape(e.skill_list) + "'"); + v.push_back("'" + Strings::Escape(e.spell_list) + "'"); + v.push_back("'" + Strings::Escape(e.description_override) + "'"); + v.push_back(std::to_string(e.goalid)); + v.push_back("'" + Strings::Escape(e.goal_match_list) + "'"); + v.push_back(std::to_string(e.goalmethod)); + v.push_back(std::to_string(e.goalcount)); + v.push_back(std::to_string(e.delivertonpc)); + v.push_back("'" + Strings::Escape(e.zones) + "'"); + v.push_back(std::to_string(e.zone_version)); + v.push_back(std::to_string(e.optional)); - insert_chunks.push_back("(" + Strings::Implode(",", insert_values) + ")"); + insert_chunks.push_back("(" + Strings::Implode(",", v) + ")"); } - std::vector insert_values; + std::vector v; auto results = db.QueryDatabase( fmt::format( @@ -360,33 +360,33 @@ public: all_entries.reserve(results.RowCount()); for (auto row = results.begin(); row != results.end(); ++row) { - TaskActivities entry{}; + TaskActivities e{}; - entry.taskid = atoi(row[0]); - entry.activityid = atoi(row[1]); - entry.step = atoi(row[2]); - entry.activitytype = atoi(row[3]); - entry.target_name = row[4] ? row[4] : ""; - entry.item_list = row[5] ? row[5] : ""; - entry.skill_list = row[6] ? row[6] : ""; - entry.spell_list = row[7] ? row[7] : ""; - entry.description_override = row[8] ? row[8] : ""; - entry.goalid = atoi(row[9]); - entry.goal_match_list = row[10] ? row[10] : ""; - entry.goalmethod = atoi(row[11]); - entry.goalcount = atoi(row[12]); - entry.delivertonpc = atoi(row[13]); - entry.zones = row[14] ? row[14] : ""; - entry.zone_version = atoi(row[15]); - entry.optional = atoi(row[16]); + e.taskid = atoi(row[0]); + e.activityid = atoi(row[1]); + e.step = atoi(row[2]); + e.activitytype = atoi(row[3]); + e.target_name = row[4] ? row[4] : ""; + e.item_list = row[5] ? row[5] : ""; + e.skill_list = row[6] ? row[6] : ""; + e.spell_list = row[7] ? row[7] : ""; + e.description_override = row[8] ? row[8] : ""; + e.goalid = atoi(row[9]); + e.goal_match_list = row[10] ? row[10] : ""; + e.goalmethod = atoi(row[11]); + e.goalcount = atoi(row[12]); + e.delivertonpc = atoi(row[13]); + e.zones = row[14] ? row[14] : ""; + e.zone_version = atoi(row[15]); + e.optional = atoi(row[16]); - all_entries.push_back(entry); + all_entries.push_back(e); } return all_entries; } - static std::vector GetWhere(Database& db, std::string where_filter) + static std::vector GetWhere(Database& db, const std::string &where_filter) { std::vector all_entries; @@ -401,33 +401,33 @@ public: all_entries.reserve(results.RowCount()); for (auto row = results.begin(); row != results.end(); ++row) { - TaskActivities entry{}; + TaskActivities e{}; - entry.taskid = atoi(row[0]); - entry.activityid = atoi(row[1]); - entry.step = atoi(row[2]); - entry.activitytype = atoi(row[3]); - entry.target_name = row[4] ? row[4] : ""; - entry.item_list = row[5] ? row[5] : ""; - entry.skill_list = row[6] ? row[6] : ""; - entry.spell_list = row[7] ? row[7] : ""; - entry.description_override = row[8] ? row[8] : ""; - entry.goalid = atoi(row[9]); - entry.goal_match_list = row[10] ? row[10] : ""; - entry.goalmethod = atoi(row[11]); - entry.goalcount = atoi(row[12]); - entry.delivertonpc = atoi(row[13]); - entry.zones = row[14] ? row[14] : ""; - entry.zone_version = atoi(row[15]); - entry.optional = atoi(row[16]); + e.taskid = atoi(row[0]); + e.activityid = atoi(row[1]); + e.step = atoi(row[2]); + e.activitytype = atoi(row[3]); + e.target_name = row[4] ? row[4] : ""; + e.item_list = row[5] ? row[5] : ""; + e.skill_list = row[6] ? row[6] : ""; + e.spell_list = row[7] ? row[7] : ""; + e.description_override = row[8] ? row[8] : ""; + e.goalid = atoi(row[9]); + e.goal_match_list = row[10] ? row[10] : ""; + e.goalmethod = atoi(row[11]); + e.goalcount = atoi(row[12]); + e.delivertonpc = atoi(row[13]); + e.zones = row[14] ? row[14] : ""; + e.zone_version = atoi(row[15]); + e.optional = atoi(row[16]); - all_entries.push_back(entry); + all_entries.push_back(e); } return all_entries; } - static int DeleteWhere(Database& db, std::string where_filter) + static int DeleteWhere(Database& db, const std::string &where_filter) { auto results = db.QueryDatabase( fmt::format( @@ -452,6 +452,32 @@ public: 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); + } + }; #endif //EQEMU_BASE_TASK_ACTIVITIES_REPOSITORY_H diff --git a/common/repositories/base/base_tasks_repository.h b/common/repositories/base/base_tasks_repository.h index 8baf94c89..82848855f 100644 --- a/common/repositories/base/base_tasks_repository.h +++ b/common/repositories/base/base_tasks_repository.h @@ -154,40 +154,40 @@ public: static Tasks NewEntity() { - Tasks entry{}; + Tasks e{}; - entry.id = 0; - entry.type = 0; - entry.duration = 0; - entry.duration_code = 0; - entry.title = ""; - entry.description = ""; - entry.reward = ""; - entry.rewardid = 0; - entry.cashreward = 0; - entry.xpreward = 0; - entry.rewardmethod = 2; - entry.reward_points = 0; - entry.reward_point_type = 0; - entry.minlevel = 0; - entry.maxlevel = 0; - entry.level_spread = 0; - entry.min_players = 0; - entry.max_players = 0; - entry.repeatable = 1; - entry.faction_reward = 0; - entry.completion_emote = ""; - entry.replay_timer_group = 0; - entry.replay_timer_seconds = 0; - entry.request_timer_group = 0; - entry.request_timer_seconds = 0; - entry.dz_template_id = 0; - entry.lock_activity_id = -1; + e.id = 0; + e.type = 0; + e.duration = 0; + e.duration_code = 0; + e.title = ""; + e.description = ""; + e.reward = ""; + e.rewardid = 0; + e.cashreward = 0; + e.xpreward = 0; + e.rewardmethod = 2; + e.reward_points = 0; + e.reward_point_type = 0; + e.minlevel = 0; + e.maxlevel = 0; + e.level_spread = 0; + e.min_players = 0; + e.max_players = 0; + e.repeatable = 1; + e.faction_reward = 0; + e.completion_emote = ""; + e.replay_timer_group = 0; + e.replay_timer_seconds = 0; + e.request_timer_group = 0; + e.request_timer_seconds = 0; + e.dz_template_id = 0; + e.lock_activity_id = -1; - return entry; + return e; } - static Tasks GetTasksEntry( + static Tasks GetTasks( const std::vector &taskss, int tasks_id ) @@ -216,37 +216,37 @@ public: auto row = results.begin(); if (results.RowCount() == 1) { - Tasks entry{}; + Tasks e{}; - entry.id = atoi(row[0]); - entry.type = atoi(row[1]); - entry.duration = atoi(row[2]); - entry.duration_code = atoi(row[3]); - entry.title = row[4] ? row[4] : ""; - entry.description = row[5] ? row[5] : ""; - entry.reward = row[6] ? row[6] : ""; - entry.rewardid = atoi(row[7]); - entry.cashreward = atoi(row[8]); - entry.xpreward = atoi(row[9]); - entry.rewardmethod = atoi(row[10]); - entry.reward_points = atoi(row[11]); - entry.reward_point_type = atoi(row[12]); - entry.minlevel = atoi(row[13]); - entry.maxlevel = atoi(row[14]); - entry.level_spread = atoi(row[15]); - entry.min_players = atoi(row[16]); - entry.max_players = atoi(row[17]); - entry.repeatable = atoi(row[18]); - entry.faction_reward = atoi(row[19]); - entry.completion_emote = row[20] ? row[20] : ""; - entry.replay_timer_group = atoi(row[21]); - entry.replay_timer_seconds = atoi(row[22]); - entry.request_timer_group = atoi(row[23]); - entry.request_timer_seconds = atoi(row[24]); - entry.dz_template_id = atoi(row[25]); - entry.lock_activity_id = atoi(row[26]); + e.id = atoi(row[0]); + e.type = atoi(row[1]); + e.duration = atoi(row[2]); + e.duration_code = atoi(row[3]); + e.title = row[4] ? row[4] : ""; + e.description = row[5] ? row[5] : ""; + e.reward = row[6] ? row[6] : ""; + e.rewardid = atoi(row[7]); + e.cashreward = atoi(row[8]); + e.xpreward = atoi(row[9]); + e.rewardmethod = atoi(row[10]); + e.reward_points = atoi(row[11]); + e.reward_point_type = atoi(row[12]); + e.minlevel = atoi(row[13]); + e.maxlevel = atoi(row[14]); + e.level_spread = atoi(row[15]); + e.min_players = atoi(row[16]); + e.max_players = atoi(row[17]); + e.repeatable = atoi(row[18]); + e.faction_reward = atoi(row[19]); + e.completion_emote = row[20] ? row[20] : ""; + e.replay_timer_group = atoi(row[21]); + e.replay_timer_seconds = atoi(row[22]); + e.request_timer_group = atoi(row[23]); + e.request_timer_seconds = atoi(row[24]); + e.dz_template_id = atoi(row[25]); + e.lock_activity_id = atoi(row[26]); - return entry; + return e; } return NewEntity(); @@ -271,48 +271,48 @@ public: static int UpdateOne( Database& db, - Tasks tasks_entry + const Tasks &e ) { - std::vector update_values; + std::vector v; auto columns = Columns(); - update_values.push_back(columns[0] + " = " + std::to_string(tasks_entry.id)); - update_values.push_back(columns[1] + " = " + std::to_string(tasks_entry.type)); - update_values.push_back(columns[2] + " = " + std::to_string(tasks_entry.duration)); - update_values.push_back(columns[3] + " = " + std::to_string(tasks_entry.duration_code)); - update_values.push_back(columns[4] + " = '" + Strings::Escape(tasks_entry.title) + "'"); - update_values.push_back(columns[5] + " = '" + Strings::Escape(tasks_entry.description) + "'"); - update_values.push_back(columns[6] + " = '" + Strings::Escape(tasks_entry.reward) + "'"); - update_values.push_back(columns[7] + " = " + std::to_string(tasks_entry.rewardid)); - update_values.push_back(columns[8] + " = " + std::to_string(tasks_entry.cashreward)); - update_values.push_back(columns[9] + " = " + std::to_string(tasks_entry.xpreward)); - update_values.push_back(columns[10] + " = " + std::to_string(tasks_entry.rewardmethod)); - update_values.push_back(columns[11] + " = " + std::to_string(tasks_entry.reward_points)); - update_values.push_back(columns[12] + " = " + std::to_string(tasks_entry.reward_point_type)); - update_values.push_back(columns[13] + " = " + std::to_string(tasks_entry.minlevel)); - update_values.push_back(columns[14] + " = " + std::to_string(tasks_entry.maxlevel)); - update_values.push_back(columns[15] + " = " + std::to_string(tasks_entry.level_spread)); - update_values.push_back(columns[16] + " = " + std::to_string(tasks_entry.min_players)); - update_values.push_back(columns[17] + " = " + std::to_string(tasks_entry.max_players)); - update_values.push_back(columns[18] + " = " + std::to_string(tasks_entry.repeatable)); - update_values.push_back(columns[19] + " = " + std::to_string(tasks_entry.faction_reward)); - update_values.push_back(columns[20] + " = '" + Strings::Escape(tasks_entry.completion_emote) + "'"); - update_values.push_back(columns[21] + " = " + std::to_string(tasks_entry.replay_timer_group)); - update_values.push_back(columns[22] + " = " + std::to_string(tasks_entry.replay_timer_seconds)); - update_values.push_back(columns[23] + " = " + std::to_string(tasks_entry.request_timer_group)); - update_values.push_back(columns[24] + " = " + std::to_string(tasks_entry.request_timer_seconds)); - update_values.push_back(columns[25] + " = " + std::to_string(tasks_entry.dz_template_id)); - update_values.push_back(columns[26] + " = " + std::to_string(tasks_entry.lock_activity_id)); + v.push_back(columns[0] + " = " + std::to_string(e.id)); + v.push_back(columns[1] + " = " + std::to_string(e.type)); + v.push_back(columns[2] + " = " + std::to_string(e.duration)); + v.push_back(columns[3] + " = " + std::to_string(e.duration_code)); + v.push_back(columns[4] + " = '" + Strings::Escape(e.title) + "'"); + v.push_back(columns[5] + " = '" + Strings::Escape(e.description) + "'"); + v.push_back(columns[6] + " = '" + Strings::Escape(e.reward) + "'"); + v.push_back(columns[7] + " = " + std::to_string(e.rewardid)); + v.push_back(columns[8] + " = " + std::to_string(e.cashreward)); + v.push_back(columns[9] + " = " + std::to_string(e.xpreward)); + v.push_back(columns[10] + " = " + std::to_string(e.rewardmethod)); + v.push_back(columns[11] + " = " + std::to_string(e.reward_points)); + v.push_back(columns[12] + " = " + std::to_string(e.reward_point_type)); + v.push_back(columns[13] + " = " + std::to_string(e.minlevel)); + v.push_back(columns[14] + " = " + std::to_string(e.maxlevel)); + v.push_back(columns[15] + " = " + std::to_string(e.level_spread)); + v.push_back(columns[16] + " = " + std::to_string(e.min_players)); + v.push_back(columns[17] + " = " + std::to_string(e.max_players)); + v.push_back(columns[18] + " = " + std::to_string(e.repeatable)); + v.push_back(columns[19] + " = " + std::to_string(e.faction_reward)); + v.push_back(columns[20] + " = '" + Strings::Escape(e.completion_emote) + "'"); + v.push_back(columns[21] + " = " + std::to_string(e.replay_timer_group)); + v.push_back(columns[22] + " = " + std::to_string(e.replay_timer_seconds)); + v.push_back(columns[23] + " = " + std::to_string(e.request_timer_group)); + v.push_back(columns[24] + " = " + std::to_string(e.request_timer_seconds)); + v.push_back(columns[25] + " = " + std::to_string(e.dz_template_id)); + v.push_back(columns[26] + " = " + std::to_string(e.lock_activity_id)); auto results = db.QueryDatabase( fmt::format( "UPDATE {} SET {} WHERE {} = {}", TableName(), - Strings::Implode(", ", update_values), + Strings::Implode(", ", v), PrimaryKey(), - tasks_entry.id + e.id ) ); @@ -321,99 +321,99 @@ public: static Tasks InsertOne( Database& db, - Tasks tasks_entry + Tasks e ) { - std::vector insert_values; + std::vector v; - insert_values.push_back(std::to_string(tasks_entry.id)); - insert_values.push_back(std::to_string(tasks_entry.type)); - insert_values.push_back(std::to_string(tasks_entry.duration)); - insert_values.push_back(std::to_string(tasks_entry.duration_code)); - insert_values.push_back("'" + Strings::Escape(tasks_entry.title) + "'"); - insert_values.push_back("'" + Strings::Escape(tasks_entry.description) + "'"); - insert_values.push_back("'" + Strings::Escape(tasks_entry.reward) + "'"); - insert_values.push_back(std::to_string(tasks_entry.rewardid)); - insert_values.push_back(std::to_string(tasks_entry.cashreward)); - insert_values.push_back(std::to_string(tasks_entry.xpreward)); - insert_values.push_back(std::to_string(tasks_entry.rewardmethod)); - insert_values.push_back(std::to_string(tasks_entry.reward_points)); - insert_values.push_back(std::to_string(tasks_entry.reward_point_type)); - insert_values.push_back(std::to_string(tasks_entry.minlevel)); - insert_values.push_back(std::to_string(tasks_entry.maxlevel)); - insert_values.push_back(std::to_string(tasks_entry.level_spread)); - insert_values.push_back(std::to_string(tasks_entry.min_players)); - insert_values.push_back(std::to_string(tasks_entry.max_players)); - insert_values.push_back(std::to_string(tasks_entry.repeatable)); - insert_values.push_back(std::to_string(tasks_entry.faction_reward)); - insert_values.push_back("'" + Strings::Escape(tasks_entry.completion_emote) + "'"); - insert_values.push_back(std::to_string(tasks_entry.replay_timer_group)); - insert_values.push_back(std::to_string(tasks_entry.replay_timer_seconds)); - insert_values.push_back(std::to_string(tasks_entry.request_timer_group)); - insert_values.push_back(std::to_string(tasks_entry.request_timer_seconds)); - insert_values.push_back(std::to_string(tasks_entry.dz_template_id)); - insert_values.push_back(std::to_string(tasks_entry.lock_activity_id)); + v.push_back(std::to_string(e.id)); + v.push_back(std::to_string(e.type)); + v.push_back(std::to_string(e.duration)); + v.push_back(std::to_string(e.duration_code)); + v.push_back("'" + Strings::Escape(e.title) + "'"); + v.push_back("'" + Strings::Escape(e.description) + "'"); + v.push_back("'" + Strings::Escape(e.reward) + "'"); + v.push_back(std::to_string(e.rewardid)); + v.push_back(std::to_string(e.cashreward)); + v.push_back(std::to_string(e.xpreward)); + v.push_back(std::to_string(e.rewardmethod)); + v.push_back(std::to_string(e.reward_points)); + v.push_back(std::to_string(e.reward_point_type)); + v.push_back(std::to_string(e.minlevel)); + v.push_back(std::to_string(e.maxlevel)); + v.push_back(std::to_string(e.level_spread)); + v.push_back(std::to_string(e.min_players)); + v.push_back(std::to_string(e.max_players)); + v.push_back(std::to_string(e.repeatable)); + v.push_back(std::to_string(e.faction_reward)); + v.push_back("'" + Strings::Escape(e.completion_emote) + "'"); + v.push_back(std::to_string(e.replay_timer_group)); + v.push_back(std::to_string(e.replay_timer_seconds)); + v.push_back(std::to_string(e.request_timer_group)); + v.push_back(std::to_string(e.request_timer_seconds)); + v.push_back(std::to_string(e.dz_template_id)); + v.push_back(std::to_string(e.lock_activity_id)); auto results = db.QueryDatabase( fmt::format( "{} VALUES ({})", BaseInsert(), - Strings::Implode(",", insert_values) + Strings::Implode(",", v) ) ); if (results.Success()) { - tasks_entry.id = results.LastInsertedID(); - return tasks_entry; + e.id = results.LastInsertedID(); + return e; } - tasks_entry = NewEntity(); + e = NewEntity(); - return tasks_entry; + return e; } static int InsertMany( Database& db, - std::vector tasks_entries + const std::vector &entries ) { std::vector insert_chunks; - for (auto &tasks_entry: tasks_entries) { - std::vector insert_values; + for (auto &e: entries) { + std::vector v; - insert_values.push_back(std::to_string(tasks_entry.id)); - insert_values.push_back(std::to_string(tasks_entry.type)); - insert_values.push_back(std::to_string(tasks_entry.duration)); - insert_values.push_back(std::to_string(tasks_entry.duration_code)); - insert_values.push_back("'" + Strings::Escape(tasks_entry.title) + "'"); - insert_values.push_back("'" + Strings::Escape(tasks_entry.description) + "'"); - insert_values.push_back("'" + Strings::Escape(tasks_entry.reward) + "'"); - insert_values.push_back(std::to_string(tasks_entry.rewardid)); - insert_values.push_back(std::to_string(tasks_entry.cashreward)); - insert_values.push_back(std::to_string(tasks_entry.xpreward)); - insert_values.push_back(std::to_string(tasks_entry.rewardmethod)); - insert_values.push_back(std::to_string(tasks_entry.reward_points)); - insert_values.push_back(std::to_string(tasks_entry.reward_point_type)); - insert_values.push_back(std::to_string(tasks_entry.minlevel)); - insert_values.push_back(std::to_string(tasks_entry.maxlevel)); - insert_values.push_back(std::to_string(tasks_entry.level_spread)); - insert_values.push_back(std::to_string(tasks_entry.min_players)); - insert_values.push_back(std::to_string(tasks_entry.max_players)); - insert_values.push_back(std::to_string(tasks_entry.repeatable)); - insert_values.push_back(std::to_string(tasks_entry.faction_reward)); - insert_values.push_back("'" + Strings::Escape(tasks_entry.completion_emote) + "'"); - insert_values.push_back(std::to_string(tasks_entry.replay_timer_group)); - insert_values.push_back(std::to_string(tasks_entry.replay_timer_seconds)); - insert_values.push_back(std::to_string(tasks_entry.request_timer_group)); - insert_values.push_back(std::to_string(tasks_entry.request_timer_seconds)); - insert_values.push_back(std::to_string(tasks_entry.dz_template_id)); - insert_values.push_back(std::to_string(tasks_entry.lock_activity_id)); + v.push_back(std::to_string(e.id)); + v.push_back(std::to_string(e.type)); + v.push_back(std::to_string(e.duration)); + v.push_back(std::to_string(e.duration_code)); + v.push_back("'" + Strings::Escape(e.title) + "'"); + v.push_back("'" + Strings::Escape(e.description) + "'"); + v.push_back("'" + Strings::Escape(e.reward) + "'"); + v.push_back(std::to_string(e.rewardid)); + v.push_back(std::to_string(e.cashreward)); + v.push_back(std::to_string(e.xpreward)); + v.push_back(std::to_string(e.rewardmethod)); + v.push_back(std::to_string(e.reward_points)); + v.push_back(std::to_string(e.reward_point_type)); + v.push_back(std::to_string(e.minlevel)); + v.push_back(std::to_string(e.maxlevel)); + v.push_back(std::to_string(e.level_spread)); + v.push_back(std::to_string(e.min_players)); + v.push_back(std::to_string(e.max_players)); + v.push_back(std::to_string(e.repeatable)); + v.push_back(std::to_string(e.faction_reward)); + v.push_back("'" + Strings::Escape(e.completion_emote) + "'"); + v.push_back(std::to_string(e.replay_timer_group)); + v.push_back(std::to_string(e.replay_timer_seconds)); + v.push_back(std::to_string(e.request_timer_group)); + v.push_back(std::to_string(e.request_timer_seconds)); + v.push_back(std::to_string(e.dz_template_id)); + v.push_back(std::to_string(e.lock_activity_id)); - insert_chunks.push_back("(" + Strings::Implode(",", insert_values) + ")"); + insert_chunks.push_back("(" + Strings::Implode(",", v) + ")"); } - std::vector insert_values; + std::vector v; auto results = db.QueryDatabase( fmt::format( @@ -440,43 +440,43 @@ public: all_entries.reserve(results.RowCount()); for (auto row = results.begin(); row != results.end(); ++row) { - Tasks entry{}; + Tasks e{}; - entry.id = atoi(row[0]); - entry.type = atoi(row[1]); - entry.duration = atoi(row[2]); - entry.duration_code = atoi(row[3]); - entry.title = row[4] ? row[4] : ""; - entry.description = row[5] ? row[5] : ""; - entry.reward = row[6] ? row[6] : ""; - entry.rewardid = atoi(row[7]); - entry.cashreward = atoi(row[8]); - entry.xpreward = atoi(row[9]); - entry.rewardmethod = atoi(row[10]); - entry.reward_points = atoi(row[11]); - entry.reward_point_type = atoi(row[12]); - entry.minlevel = atoi(row[13]); - entry.maxlevel = atoi(row[14]); - entry.level_spread = atoi(row[15]); - entry.min_players = atoi(row[16]); - entry.max_players = atoi(row[17]); - entry.repeatable = atoi(row[18]); - entry.faction_reward = atoi(row[19]); - entry.completion_emote = row[20] ? row[20] : ""; - entry.replay_timer_group = atoi(row[21]); - entry.replay_timer_seconds = atoi(row[22]); - entry.request_timer_group = atoi(row[23]); - entry.request_timer_seconds = atoi(row[24]); - entry.dz_template_id = atoi(row[25]); - entry.lock_activity_id = atoi(row[26]); + e.id = atoi(row[0]); + e.type = atoi(row[1]); + e.duration = atoi(row[2]); + e.duration_code = atoi(row[3]); + e.title = row[4] ? row[4] : ""; + e.description = row[5] ? row[5] : ""; + e.reward = row[6] ? row[6] : ""; + e.rewardid = atoi(row[7]); + e.cashreward = atoi(row[8]); + e.xpreward = atoi(row[9]); + e.rewardmethod = atoi(row[10]); + e.reward_points = atoi(row[11]); + e.reward_point_type = atoi(row[12]); + e.minlevel = atoi(row[13]); + e.maxlevel = atoi(row[14]); + e.level_spread = atoi(row[15]); + e.min_players = atoi(row[16]); + e.max_players = atoi(row[17]); + e.repeatable = atoi(row[18]); + e.faction_reward = atoi(row[19]); + e.completion_emote = row[20] ? row[20] : ""; + e.replay_timer_group = atoi(row[21]); + e.replay_timer_seconds = atoi(row[22]); + e.request_timer_group = atoi(row[23]); + e.request_timer_seconds = atoi(row[24]); + e.dz_template_id = atoi(row[25]); + e.lock_activity_id = atoi(row[26]); - all_entries.push_back(entry); + all_entries.push_back(e); } return all_entries; } - static std::vector GetWhere(Database& db, std::string where_filter) + static std::vector GetWhere(Database& db, const std::string &where_filter) { std::vector all_entries; @@ -491,43 +491,43 @@ public: all_entries.reserve(results.RowCount()); for (auto row = results.begin(); row != results.end(); ++row) { - Tasks entry{}; + Tasks e{}; - entry.id = atoi(row[0]); - entry.type = atoi(row[1]); - entry.duration = atoi(row[2]); - entry.duration_code = atoi(row[3]); - entry.title = row[4] ? row[4] : ""; - entry.description = row[5] ? row[5] : ""; - entry.reward = row[6] ? row[6] : ""; - entry.rewardid = atoi(row[7]); - entry.cashreward = atoi(row[8]); - entry.xpreward = atoi(row[9]); - entry.rewardmethod = atoi(row[10]); - entry.reward_points = atoi(row[11]); - entry.reward_point_type = atoi(row[12]); - entry.minlevel = atoi(row[13]); - entry.maxlevel = atoi(row[14]); - entry.level_spread = atoi(row[15]); - entry.min_players = atoi(row[16]); - entry.max_players = atoi(row[17]); - entry.repeatable = atoi(row[18]); - entry.faction_reward = atoi(row[19]); - entry.completion_emote = row[20] ? row[20] : ""; - entry.replay_timer_group = atoi(row[21]); - entry.replay_timer_seconds = atoi(row[22]); - entry.request_timer_group = atoi(row[23]); - entry.request_timer_seconds = atoi(row[24]); - entry.dz_template_id = atoi(row[25]); - entry.lock_activity_id = atoi(row[26]); + e.id = atoi(row[0]); + e.type = atoi(row[1]); + e.duration = atoi(row[2]); + e.duration_code = atoi(row[3]); + e.title = row[4] ? row[4] : ""; + e.description = row[5] ? row[5] : ""; + e.reward = row[6] ? row[6] : ""; + e.rewardid = atoi(row[7]); + e.cashreward = atoi(row[8]); + e.xpreward = atoi(row[9]); + e.rewardmethod = atoi(row[10]); + e.reward_points = atoi(row[11]); + e.reward_point_type = atoi(row[12]); + e.minlevel = atoi(row[13]); + e.maxlevel = atoi(row[14]); + e.level_spread = atoi(row[15]); + e.min_players = atoi(row[16]); + e.max_players = atoi(row[17]); + e.repeatable = atoi(row[18]); + e.faction_reward = atoi(row[19]); + e.completion_emote = row[20] ? row[20] : ""; + e.replay_timer_group = atoi(row[21]); + e.replay_timer_seconds = atoi(row[22]); + e.request_timer_group = atoi(row[23]); + e.request_timer_seconds = atoi(row[24]); + e.dz_template_id = atoi(row[25]); + e.lock_activity_id = atoi(row[26]); - all_entries.push_back(entry); + all_entries.push_back(e); } return all_entries; } - static int DeleteWhere(Database& db, std::string where_filter) + static int DeleteWhere(Database& db, const std::string &where_filter) { auto results = db.QueryDatabase( fmt::format( @@ -552,6 +552,32 @@ public: 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); + } + }; #endif //EQEMU_BASE_TASKS_REPOSITORY_H diff --git a/common/repositories/base/base_tasksets_repository.h b/common/repositories/base/base_tasksets_repository.h index 2e96868ca..c771b46b2 100644 --- a/common/repositories/base/base_tasksets_repository.h +++ b/common/repositories/base/base_tasksets_repository.h @@ -79,15 +79,15 @@ public: static Tasksets NewEntity() { - Tasksets entry{}; + Tasksets e{}; - entry.id = 0; - entry.taskid = 0; + e.id = 0; + e.taskid = 0; - return entry; + return e; } - static Tasksets GetTasksetsEntry( + static Tasksets GetTasksets( const std::vector &tasksetss, int tasksets_id ) @@ -116,12 +116,12 @@ public: auto row = results.begin(); if (results.RowCount() == 1) { - Tasksets entry{}; + Tasksets e{}; - entry.id = atoi(row[0]); - entry.taskid = atoi(row[1]); + e.id = atoi(row[0]); + e.taskid = atoi(row[1]); - return entry; + return e; } return NewEntity(); @@ -146,23 +146,23 @@ public: static int UpdateOne( Database& db, - Tasksets tasksets_entry + const Tasksets &e ) { - std::vector update_values; + std::vector v; auto columns = Columns(); - update_values.push_back(columns[0] + " = " + std::to_string(tasksets_entry.id)); - update_values.push_back(columns[1] + " = " + std::to_string(tasksets_entry.taskid)); + v.push_back(columns[0] + " = " + std::to_string(e.id)); + v.push_back(columns[1] + " = " + std::to_string(e.taskid)); auto results = db.QueryDatabase( fmt::format( "UPDATE {} SET {} WHERE {} = {}", TableName(), - Strings::Implode(", ", update_values), + Strings::Implode(", ", v), PrimaryKey(), - tasksets_entry.id + e.id ) ); @@ -171,49 +171,49 @@ public: static Tasksets InsertOne( Database& db, - Tasksets tasksets_entry + Tasksets e ) { - std::vector insert_values; + std::vector v; - insert_values.push_back(std::to_string(tasksets_entry.id)); - insert_values.push_back(std::to_string(tasksets_entry.taskid)); + v.push_back(std::to_string(e.id)); + v.push_back(std::to_string(e.taskid)); auto results = db.QueryDatabase( fmt::format( "{} VALUES ({})", BaseInsert(), - Strings::Implode(",", insert_values) + Strings::Implode(",", v) ) ); if (results.Success()) { - tasksets_entry.id = results.LastInsertedID(); - return tasksets_entry; + e.id = results.LastInsertedID(); + return e; } - tasksets_entry = NewEntity(); + e = NewEntity(); - return tasksets_entry; + return e; } static int InsertMany( Database& db, - std::vector tasksets_entries + const std::vector &entries ) { std::vector insert_chunks; - for (auto &tasksets_entry: tasksets_entries) { - std::vector insert_values; + for (auto &e: entries) { + std::vector v; - insert_values.push_back(std::to_string(tasksets_entry.id)); - insert_values.push_back(std::to_string(tasksets_entry.taskid)); + v.push_back(std::to_string(e.id)); + v.push_back(std::to_string(e.taskid)); - insert_chunks.push_back("(" + Strings::Implode(",", insert_values) + ")"); + insert_chunks.push_back("(" + Strings::Implode(",", v) + ")"); } - std::vector insert_values; + std::vector v; auto results = db.QueryDatabase( fmt::format( @@ -240,18 +240,18 @@ public: all_entries.reserve(results.RowCount()); for (auto row = results.begin(); row != results.end(); ++row) { - Tasksets entry{}; + Tasksets e{}; - entry.id = atoi(row[0]); - entry.taskid = atoi(row[1]); + e.id = atoi(row[0]); + e.taskid = atoi(row[1]); - all_entries.push_back(entry); + all_entries.push_back(e); } return all_entries; } - static std::vector GetWhere(Database& db, std::string where_filter) + static std::vector GetWhere(Database& db, const std::string &where_filter) { std::vector all_entries; @@ -266,18 +266,18 @@ public: all_entries.reserve(results.RowCount()); for (auto row = results.begin(); row != results.end(); ++row) { - Tasksets entry{}; + Tasksets e{}; - entry.id = atoi(row[0]); - entry.taskid = atoi(row[1]); + e.id = atoi(row[0]); + e.taskid = atoi(row[1]); - all_entries.push_back(entry); + all_entries.push_back(e); } return all_entries; } - static int DeleteWhere(Database& db, std::string where_filter) + static int DeleteWhere(Database& db, const std::string &where_filter) { auto results = db.QueryDatabase( fmt::format( @@ -302,6 +302,32 @@ public: 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); + } + }; #endif //EQEMU_BASE_TASKSETS_REPOSITORY_H diff --git a/common/repositories/base/base_timers_repository.h b/common/repositories/base/base_timers_repository.h index f59d38103..9cf1121b3 100644 --- a/common/repositories/base/base_timers_repository.h +++ b/common/repositories/base/base_timers_repository.h @@ -88,18 +88,18 @@ public: static Timers NewEntity() { - Timers entry{}; + Timers e{}; - entry.char_id = 0; - entry.type = 0; - entry.start = 0; - entry.duration = 0; - entry.enable = 0; + e.char_id = 0; + e.type = 0; + e.start = 0; + e.duration = 0; + e.enable = 0; - return entry; + return e; } - static Timers GetTimersEntry( + static Timers GetTimers( const std::vector &timerss, int timers_id ) @@ -128,15 +128,15 @@ public: auto row = results.begin(); if (results.RowCount() == 1) { - Timers entry{}; + Timers e{}; - entry.char_id = atoi(row[0]); - entry.type = atoi(row[1]); - entry.start = atoi(row[2]); - entry.duration = atoi(row[3]); - entry.enable = atoi(row[4]); + e.char_id = atoi(row[0]); + e.type = atoi(row[1]); + e.start = atoi(row[2]); + e.duration = atoi(row[3]); + e.enable = atoi(row[4]); - return entry; + return e; } return NewEntity(); @@ -161,26 +161,26 @@ public: static int UpdateOne( Database& db, - Timers timers_entry + const Timers &e ) { - std::vector update_values; + std::vector v; auto columns = Columns(); - update_values.push_back(columns[0] + " = " + std::to_string(timers_entry.char_id)); - update_values.push_back(columns[1] + " = " + std::to_string(timers_entry.type)); - update_values.push_back(columns[2] + " = " + std::to_string(timers_entry.start)); - update_values.push_back(columns[3] + " = " + std::to_string(timers_entry.duration)); - update_values.push_back(columns[4] + " = " + std::to_string(timers_entry.enable)); + v.push_back(columns[0] + " = " + std::to_string(e.char_id)); + v.push_back(columns[1] + " = " + std::to_string(e.type)); + v.push_back(columns[2] + " = " + std::to_string(e.start)); + v.push_back(columns[3] + " = " + std::to_string(e.duration)); + v.push_back(columns[4] + " = " + std::to_string(e.enable)); auto results = db.QueryDatabase( fmt::format( "UPDATE {} SET {} WHERE {} = {}", TableName(), - Strings::Implode(", ", update_values), + Strings::Implode(", ", v), PrimaryKey(), - timers_entry.char_id + e.char_id ) ); @@ -189,55 +189,55 @@ public: static Timers InsertOne( Database& db, - Timers timers_entry + Timers e ) { - std::vector insert_values; + std::vector v; - insert_values.push_back(std::to_string(timers_entry.char_id)); - insert_values.push_back(std::to_string(timers_entry.type)); - insert_values.push_back(std::to_string(timers_entry.start)); - insert_values.push_back(std::to_string(timers_entry.duration)); - insert_values.push_back(std::to_string(timers_entry.enable)); + v.push_back(std::to_string(e.char_id)); + v.push_back(std::to_string(e.type)); + v.push_back(std::to_string(e.start)); + v.push_back(std::to_string(e.duration)); + v.push_back(std::to_string(e.enable)); auto results = db.QueryDatabase( fmt::format( "{} VALUES ({})", BaseInsert(), - Strings::Implode(",", insert_values) + Strings::Implode(",", v) ) ); if (results.Success()) { - timers_entry.char_id = results.LastInsertedID(); - return timers_entry; + e.char_id = results.LastInsertedID(); + return e; } - timers_entry = NewEntity(); + e = NewEntity(); - return timers_entry; + return e; } static int InsertMany( Database& db, - std::vector timers_entries + const std::vector &entries ) { std::vector insert_chunks; - for (auto &timers_entry: timers_entries) { - std::vector insert_values; + for (auto &e: entries) { + std::vector v; - insert_values.push_back(std::to_string(timers_entry.char_id)); - insert_values.push_back(std::to_string(timers_entry.type)); - insert_values.push_back(std::to_string(timers_entry.start)); - insert_values.push_back(std::to_string(timers_entry.duration)); - insert_values.push_back(std::to_string(timers_entry.enable)); + v.push_back(std::to_string(e.char_id)); + v.push_back(std::to_string(e.type)); + v.push_back(std::to_string(e.start)); + v.push_back(std::to_string(e.duration)); + v.push_back(std::to_string(e.enable)); - insert_chunks.push_back("(" + Strings::Implode(",", insert_values) + ")"); + insert_chunks.push_back("(" + Strings::Implode(",", v) + ")"); } - std::vector insert_values; + std::vector v; auto results = db.QueryDatabase( fmt::format( @@ -264,21 +264,21 @@ public: all_entries.reserve(results.RowCount()); for (auto row = results.begin(); row != results.end(); ++row) { - Timers entry{}; + Timers e{}; - entry.char_id = atoi(row[0]); - entry.type = atoi(row[1]); - entry.start = atoi(row[2]); - entry.duration = atoi(row[3]); - entry.enable = atoi(row[4]); + e.char_id = atoi(row[0]); + e.type = atoi(row[1]); + e.start = atoi(row[2]); + e.duration = atoi(row[3]); + e.enable = atoi(row[4]); - all_entries.push_back(entry); + all_entries.push_back(e); } return all_entries; } - static std::vector GetWhere(Database& db, std::string where_filter) + static std::vector GetWhere(Database& db, const std::string &where_filter) { std::vector all_entries; @@ -293,21 +293,21 @@ public: all_entries.reserve(results.RowCount()); for (auto row = results.begin(); row != results.end(); ++row) { - Timers entry{}; + Timers e{}; - entry.char_id = atoi(row[0]); - entry.type = atoi(row[1]); - entry.start = atoi(row[2]); - entry.duration = atoi(row[3]); - entry.enable = atoi(row[4]); + e.char_id = atoi(row[0]); + e.type = atoi(row[1]); + e.start = atoi(row[2]); + e.duration = atoi(row[3]); + e.enable = atoi(row[4]); - all_entries.push_back(entry); + all_entries.push_back(e); } return all_entries; } - static int DeleteWhere(Database& db, std::string where_filter) + static int DeleteWhere(Database& db, const std::string &where_filter) { auto results = db.QueryDatabase( fmt::format( @@ -332,6 +332,32 @@ public: 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); + } + }; #endif //EQEMU_BASE_TIMERS_REPOSITORY_H diff --git a/common/repositories/base/base_titles_repository.h b/common/repositories/base/base_titles_repository.h index 56d5d2d15..68513eb8d 100644 --- a/common/repositories/base/base_titles_repository.h +++ b/common/repositories/base/base_titles_repository.h @@ -115,27 +115,27 @@ public: static Titles NewEntity() { - Titles entry{}; + Titles e{}; - entry.id = 0; - entry.skill_id = -1; - entry.min_skill_value = -1; - entry.max_skill_value = -1; - entry.min_aa_points = -1; - entry.max_aa_points = -1; - entry.class_ = -1; - entry.gender = -1; - entry.char_id = -1; - entry.status = -1; - entry.item_id = -1; - entry.prefix = ""; - entry.suffix = ""; - entry.title_set = 0; + e.id = 0; + e.skill_id = -1; + e.min_skill_value = -1; + e.max_skill_value = -1; + e.min_aa_points = -1; + e.max_aa_points = -1; + e.class_ = -1; + e.gender = -1; + e.char_id = -1; + e.status = -1; + e.item_id = -1; + e.prefix = ""; + e.suffix = ""; + e.title_set = 0; - return entry; + return e; } - static Titles GetTitlesEntry( + static Titles GetTitles( const std::vector &titless, int titles_id ) @@ -164,24 +164,24 @@ public: auto row = results.begin(); if (results.RowCount() == 1) { - Titles entry{}; + Titles e{}; - entry.id = atoi(row[0]); - entry.skill_id = atoi(row[1]); - entry.min_skill_value = atoi(row[2]); - entry.max_skill_value = atoi(row[3]); - entry.min_aa_points = atoi(row[4]); - entry.max_aa_points = atoi(row[5]); - entry.class_ = atoi(row[6]); - entry.gender = atoi(row[7]); - entry.char_id = atoi(row[8]); - entry.status = atoi(row[9]); - entry.item_id = atoi(row[10]); - entry.prefix = row[11] ? row[11] : ""; - entry.suffix = row[12] ? row[12] : ""; - entry.title_set = atoi(row[13]); + e.id = atoi(row[0]); + e.skill_id = atoi(row[1]); + e.min_skill_value = atoi(row[2]); + e.max_skill_value = atoi(row[3]); + e.min_aa_points = atoi(row[4]); + e.max_aa_points = atoi(row[5]); + e.class_ = atoi(row[6]); + e.gender = atoi(row[7]); + e.char_id = atoi(row[8]); + e.status = atoi(row[9]); + e.item_id = atoi(row[10]); + e.prefix = row[11] ? row[11] : ""; + e.suffix = row[12] ? row[12] : ""; + e.title_set = atoi(row[13]); - return entry; + return e; } return NewEntity(); @@ -206,34 +206,34 @@ public: static int UpdateOne( Database& db, - Titles titles_entry + const Titles &e ) { - std::vector update_values; + std::vector v; auto columns = Columns(); - update_values.push_back(columns[1] + " = " + std::to_string(titles_entry.skill_id)); - update_values.push_back(columns[2] + " = " + std::to_string(titles_entry.min_skill_value)); - update_values.push_back(columns[3] + " = " + std::to_string(titles_entry.max_skill_value)); - update_values.push_back(columns[4] + " = " + std::to_string(titles_entry.min_aa_points)); - update_values.push_back(columns[5] + " = " + std::to_string(titles_entry.max_aa_points)); - update_values.push_back(columns[6] + " = " + std::to_string(titles_entry.class_)); - update_values.push_back(columns[7] + " = " + std::to_string(titles_entry.gender)); - update_values.push_back(columns[8] + " = " + std::to_string(titles_entry.char_id)); - update_values.push_back(columns[9] + " = " + std::to_string(titles_entry.status)); - update_values.push_back(columns[10] + " = " + std::to_string(titles_entry.item_id)); - update_values.push_back(columns[11] + " = '" + Strings::Escape(titles_entry.prefix) + "'"); - update_values.push_back(columns[12] + " = '" + Strings::Escape(titles_entry.suffix) + "'"); - update_values.push_back(columns[13] + " = " + std::to_string(titles_entry.title_set)); + v.push_back(columns[1] + " = " + std::to_string(e.skill_id)); + v.push_back(columns[2] + " = " + std::to_string(e.min_skill_value)); + v.push_back(columns[3] + " = " + std::to_string(e.max_skill_value)); + v.push_back(columns[4] + " = " + std::to_string(e.min_aa_points)); + v.push_back(columns[5] + " = " + std::to_string(e.max_aa_points)); + v.push_back(columns[6] + " = " + std::to_string(e.class_)); + v.push_back(columns[7] + " = " + std::to_string(e.gender)); + v.push_back(columns[8] + " = " + std::to_string(e.char_id)); + v.push_back(columns[9] + " = " + std::to_string(e.status)); + v.push_back(columns[10] + " = " + std::to_string(e.item_id)); + v.push_back(columns[11] + " = '" + Strings::Escape(e.prefix) + "'"); + v.push_back(columns[12] + " = '" + Strings::Escape(e.suffix) + "'"); + v.push_back(columns[13] + " = " + std::to_string(e.title_set)); auto results = db.QueryDatabase( fmt::format( "UPDATE {} SET {} WHERE {} = {}", TableName(), - Strings::Implode(", ", update_values), + Strings::Implode(", ", v), PrimaryKey(), - titles_entry.id + e.id ) ); @@ -242,73 +242,73 @@ public: static Titles InsertOne( Database& db, - Titles titles_entry + Titles e ) { - std::vector insert_values; + std::vector v; - insert_values.push_back(std::to_string(titles_entry.id)); - insert_values.push_back(std::to_string(titles_entry.skill_id)); - insert_values.push_back(std::to_string(titles_entry.min_skill_value)); - insert_values.push_back(std::to_string(titles_entry.max_skill_value)); - insert_values.push_back(std::to_string(titles_entry.min_aa_points)); - insert_values.push_back(std::to_string(titles_entry.max_aa_points)); - insert_values.push_back(std::to_string(titles_entry.class_)); - insert_values.push_back(std::to_string(titles_entry.gender)); - insert_values.push_back(std::to_string(titles_entry.char_id)); - insert_values.push_back(std::to_string(titles_entry.status)); - insert_values.push_back(std::to_string(titles_entry.item_id)); - insert_values.push_back("'" + Strings::Escape(titles_entry.prefix) + "'"); - insert_values.push_back("'" + Strings::Escape(titles_entry.suffix) + "'"); - insert_values.push_back(std::to_string(titles_entry.title_set)); + v.push_back(std::to_string(e.id)); + v.push_back(std::to_string(e.skill_id)); + v.push_back(std::to_string(e.min_skill_value)); + v.push_back(std::to_string(e.max_skill_value)); + v.push_back(std::to_string(e.min_aa_points)); + v.push_back(std::to_string(e.max_aa_points)); + v.push_back(std::to_string(e.class_)); + v.push_back(std::to_string(e.gender)); + v.push_back(std::to_string(e.char_id)); + v.push_back(std::to_string(e.status)); + v.push_back(std::to_string(e.item_id)); + v.push_back("'" + Strings::Escape(e.prefix) + "'"); + v.push_back("'" + Strings::Escape(e.suffix) + "'"); + v.push_back(std::to_string(e.title_set)); auto results = db.QueryDatabase( fmt::format( "{} VALUES ({})", BaseInsert(), - Strings::Implode(",", insert_values) + Strings::Implode(",", v) ) ); if (results.Success()) { - titles_entry.id = results.LastInsertedID(); - return titles_entry; + e.id = results.LastInsertedID(); + return e; } - titles_entry = NewEntity(); + e = NewEntity(); - return titles_entry; + return e; } static int InsertMany( Database& db, - std::vector titles_entries + const std::vector &entries ) { std::vector insert_chunks; - for (auto &titles_entry: titles_entries) { - std::vector insert_values; + for (auto &e: entries) { + std::vector v; - insert_values.push_back(std::to_string(titles_entry.id)); - insert_values.push_back(std::to_string(titles_entry.skill_id)); - insert_values.push_back(std::to_string(titles_entry.min_skill_value)); - insert_values.push_back(std::to_string(titles_entry.max_skill_value)); - insert_values.push_back(std::to_string(titles_entry.min_aa_points)); - insert_values.push_back(std::to_string(titles_entry.max_aa_points)); - insert_values.push_back(std::to_string(titles_entry.class_)); - insert_values.push_back(std::to_string(titles_entry.gender)); - insert_values.push_back(std::to_string(titles_entry.char_id)); - insert_values.push_back(std::to_string(titles_entry.status)); - insert_values.push_back(std::to_string(titles_entry.item_id)); - insert_values.push_back("'" + Strings::Escape(titles_entry.prefix) + "'"); - insert_values.push_back("'" + Strings::Escape(titles_entry.suffix) + "'"); - insert_values.push_back(std::to_string(titles_entry.title_set)); + v.push_back(std::to_string(e.id)); + v.push_back(std::to_string(e.skill_id)); + v.push_back(std::to_string(e.min_skill_value)); + v.push_back(std::to_string(e.max_skill_value)); + v.push_back(std::to_string(e.min_aa_points)); + v.push_back(std::to_string(e.max_aa_points)); + v.push_back(std::to_string(e.class_)); + v.push_back(std::to_string(e.gender)); + v.push_back(std::to_string(e.char_id)); + v.push_back(std::to_string(e.status)); + v.push_back(std::to_string(e.item_id)); + v.push_back("'" + Strings::Escape(e.prefix) + "'"); + v.push_back("'" + Strings::Escape(e.suffix) + "'"); + v.push_back(std::to_string(e.title_set)); - insert_chunks.push_back("(" + Strings::Implode(",", insert_values) + ")"); + insert_chunks.push_back("(" + Strings::Implode(",", v) + ")"); } - std::vector insert_values; + std::vector v; auto results = db.QueryDatabase( fmt::format( @@ -335,30 +335,30 @@ public: all_entries.reserve(results.RowCount()); for (auto row = results.begin(); row != results.end(); ++row) { - Titles entry{}; + Titles e{}; - entry.id = atoi(row[0]); - entry.skill_id = atoi(row[1]); - entry.min_skill_value = atoi(row[2]); - entry.max_skill_value = atoi(row[3]); - entry.min_aa_points = atoi(row[4]); - entry.max_aa_points = atoi(row[5]); - entry.class_ = atoi(row[6]); - entry.gender = atoi(row[7]); - entry.char_id = atoi(row[8]); - entry.status = atoi(row[9]); - entry.item_id = atoi(row[10]); - entry.prefix = row[11] ? row[11] : ""; - entry.suffix = row[12] ? row[12] : ""; - entry.title_set = atoi(row[13]); + e.id = atoi(row[0]); + e.skill_id = atoi(row[1]); + e.min_skill_value = atoi(row[2]); + e.max_skill_value = atoi(row[3]); + e.min_aa_points = atoi(row[4]); + e.max_aa_points = atoi(row[5]); + e.class_ = atoi(row[6]); + e.gender = atoi(row[7]); + e.char_id = atoi(row[8]); + e.status = atoi(row[9]); + e.item_id = atoi(row[10]); + e.prefix = row[11] ? row[11] : ""; + e.suffix = row[12] ? row[12] : ""; + e.title_set = atoi(row[13]); - all_entries.push_back(entry); + all_entries.push_back(e); } return all_entries; } - static std::vector GetWhere(Database& db, std::string where_filter) + static std::vector GetWhere(Database& db, const std::string &where_filter) { std::vector all_entries; @@ -373,30 +373,30 @@ public: all_entries.reserve(results.RowCount()); for (auto row = results.begin(); row != results.end(); ++row) { - Titles entry{}; + Titles e{}; - entry.id = atoi(row[0]); - entry.skill_id = atoi(row[1]); - entry.min_skill_value = atoi(row[2]); - entry.max_skill_value = atoi(row[3]); - entry.min_aa_points = atoi(row[4]); - entry.max_aa_points = atoi(row[5]); - entry.class_ = atoi(row[6]); - entry.gender = atoi(row[7]); - entry.char_id = atoi(row[8]); - entry.status = atoi(row[9]); - entry.item_id = atoi(row[10]); - entry.prefix = row[11] ? row[11] : ""; - entry.suffix = row[12] ? row[12] : ""; - entry.title_set = atoi(row[13]); + e.id = atoi(row[0]); + e.skill_id = atoi(row[1]); + e.min_skill_value = atoi(row[2]); + e.max_skill_value = atoi(row[3]); + e.min_aa_points = atoi(row[4]); + e.max_aa_points = atoi(row[5]); + e.class_ = atoi(row[6]); + e.gender = atoi(row[7]); + e.char_id = atoi(row[8]); + e.status = atoi(row[9]); + e.item_id = atoi(row[10]); + e.prefix = row[11] ? row[11] : ""; + e.suffix = row[12] ? row[12] : ""; + e.title_set = atoi(row[13]); - all_entries.push_back(entry); + all_entries.push_back(e); } return all_entries; } - static int DeleteWhere(Database& db, std::string where_filter) + static int DeleteWhere(Database& db, const std::string &where_filter) { auto results = db.QueryDatabase( fmt::format( @@ -421,6 +421,32 @@ public: 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); + } + }; #endif //EQEMU_BASE_TITLES_REPOSITORY_H diff --git a/common/repositories/base/base_trader_repository.h b/common/repositories/base/base_trader_repository.h index 7bb474c2a..6ad78439d 100644 --- a/common/repositories/base/base_trader_repository.h +++ b/common/repositories/base/base_trader_repository.h @@ -91,19 +91,19 @@ public: static Trader NewEntity() { - Trader entry{}; + Trader e{}; - entry.char_id = 0; - entry.item_id = 0; - entry.serialnumber = 0; - entry.charges = 0; - entry.item_cost = 0; - entry.slot_id = 0; + e.char_id = 0; + e.item_id = 0; + e.serialnumber = 0; + e.charges = 0; + e.item_cost = 0; + e.slot_id = 0; - return entry; + return e; } - static Trader GetTraderEntry( + static Trader GetTrader( const std::vector &traders, int trader_id ) @@ -132,16 +132,16 @@ public: auto row = results.begin(); if (results.RowCount() == 1) { - Trader entry{}; + Trader e{}; - entry.char_id = atoi(row[0]); - entry.item_id = atoi(row[1]); - entry.serialnumber = atoi(row[2]); - entry.charges = atoi(row[3]); - entry.item_cost = atoi(row[4]); - entry.slot_id = atoi(row[5]); + e.char_id = atoi(row[0]); + e.item_id = atoi(row[1]); + e.serialnumber = atoi(row[2]); + e.charges = atoi(row[3]); + e.item_cost = atoi(row[4]); + e.slot_id = atoi(row[5]); - return entry; + return e; } return NewEntity(); @@ -166,27 +166,27 @@ public: static int UpdateOne( Database& db, - Trader trader_entry + const Trader &e ) { - std::vector update_values; + std::vector v; auto columns = Columns(); - update_values.push_back(columns[0] + " = " + std::to_string(trader_entry.char_id)); - update_values.push_back(columns[1] + " = " + std::to_string(trader_entry.item_id)); - update_values.push_back(columns[2] + " = " + std::to_string(trader_entry.serialnumber)); - update_values.push_back(columns[3] + " = " + std::to_string(trader_entry.charges)); - update_values.push_back(columns[4] + " = " + std::to_string(trader_entry.item_cost)); - update_values.push_back(columns[5] + " = " + std::to_string(trader_entry.slot_id)); + v.push_back(columns[0] + " = " + std::to_string(e.char_id)); + v.push_back(columns[1] + " = " + std::to_string(e.item_id)); + v.push_back(columns[2] + " = " + std::to_string(e.serialnumber)); + v.push_back(columns[3] + " = " + std::to_string(e.charges)); + v.push_back(columns[4] + " = " + std::to_string(e.item_cost)); + v.push_back(columns[5] + " = " + std::to_string(e.slot_id)); auto results = db.QueryDatabase( fmt::format( "UPDATE {} SET {} WHERE {} = {}", TableName(), - Strings::Implode(", ", update_values), + Strings::Implode(", ", v), PrimaryKey(), - trader_entry.char_id + e.char_id ) ); @@ -195,57 +195,57 @@ public: static Trader InsertOne( Database& db, - Trader trader_entry + Trader e ) { - std::vector insert_values; + std::vector v; - insert_values.push_back(std::to_string(trader_entry.char_id)); - insert_values.push_back(std::to_string(trader_entry.item_id)); - insert_values.push_back(std::to_string(trader_entry.serialnumber)); - insert_values.push_back(std::to_string(trader_entry.charges)); - insert_values.push_back(std::to_string(trader_entry.item_cost)); - insert_values.push_back(std::to_string(trader_entry.slot_id)); + v.push_back(std::to_string(e.char_id)); + v.push_back(std::to_string(e.item_id)); + v.push_back(std::to_string(e.serialnumber)); + v.push_back(std::to_string(e.charges)); + v.push_back(std::to_string(e.item_cost)); + v.push_back(std::to_string(e.slot_id)); auto results = db.QueryDatabase( fmt::format( "{} VALUES ({})", BaseInsert(), - Strings::Implode(",", insert_values) + Strings::Implode(",", v) ) ); if (results.Success()) { - trader_entry.char_id = results.LastInsertedID(); - return trader_entry; + e.char_id = results.LastInsertedID(); + return e; } - trader_entry = NewEntity(); + e = NewEntity(); - return trader_entry; + return e; } static int InsertMany( Database& db, - std::vector trader_entries + const std::vector &entries ) { std::vector insert_chunks; - for (auto &trader_entry: trader_entries) { - std::vector insert_values; + for (auto &e: entries) { + std::vector v; - insert_values.push_back(std::to_string(trader_entry.char_id)); - insert_values.push_back(std::to_string(trader_entry.item_id)); - insert_values.push_back(std::to_string(trader_entry.serialnumber)); - insert_values.push_back(std::to_string(trader_entry.charges)); - insert_values.push_back(std::to_string(trader_entry.item_cost)); - insert_values.push_back(std::to_string(trader_entry.slot_id)); + v.push_back(std::to_string(e.char_id)); + v.push_back(std::to_string(e.item_id)); + v.push_back(std::to_string(e.serialnumber)); + v.push_back(std::to_string(e.charges)); + v.push_back(std::to_string(e.item_cost)); + v.push_back(std::to_string(e.slot_id)); - insert_chunks.push_back("(" + Strings::Implode(",", insert_values) + ")"); + insert_chunks.push_back("(" + Strings::Implode(",", v) + ")"); } - std::vector insert_values; + std::vector v; auto results = db.QueryDatabase( fmt::format( @@ -272,22 +272,22 @@ public: all_entries.reserve(results.RowCount()); for (auto row = results.begin(); row != results.end(); ++row) { - Trader entry{}; + Trader e{}; - entry.char_id = atoi(row[0]); - entry.item_id = atoi(row[1]); - entry.serialnumber = atoi(row[2]); - entry.charges = atoi(row[3]); - entry.item_cost = atoi(row[4]); - entry.slot_id = atoi(row[5]); + e.char_id = atoi(row[0]); + e.item_id = atoi(row[1]); + e.serialnumber = atoi(row[2]); + e.charges = atoi(row[3]); + e.item_cost = atoi(row[4]); + e.slot_id = atoi(row[5]); - all_entries.push_back(entry); + all_entries.push_back(e); } return all_entries; } - static std::vector GetWhere(Database& db, std::string where_filter) + static std::vector GetWhere(Database& db, const std::string &where_filter) { std::vector all_entries; @@ -302,22 +302,22 @@ public: all_entries.reserve(results.RowCount()); for (auto row = results.begin(); row != results.end(); ++row) { - Trader entry{}; + Trader e{}; - entry.char_id = atoi(row[0]); - entry.item_id = atoi(row[1]); - entry.serialnumber = atoi(row[2]); - entry.charges = atoi(row[3]); - entry.item_cost = atoi(row[4]); - entry.slot_id = atoi(row[5]); + e.char_id = atoi(row[0]); + e.item_id = atoi(row[1]); + e.serialnumber = atoi(row[2]); + e.charges = atoi(row[3]); + e.item_cost = atoi(row[4]); + e.slot_id = atoi(row[5]); - all_entries.push_back(entry); + all_entries.push_back(e); } return all_entries; } - static int DeleteWhere(Database& db, std::string where_filter) + static int DeleteWhere(Database& db, const std::string &where_filter) { auto results = db.QueryDatabase( fmt::format( @@ -342,6 +342,32 @@ public: 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); + } + }; #endif //EQEMU_BASE_TRADER_REPOSITORY_H diff --git a/common/repositories/base/base_tradeskill_recipe_entries_repository.h b/common/repositories/base/base_tradeskill_recipe_entries_repository.h index e9f52a105..fe275b41e 100644 --- a/common/repositories/base/base_tradeskill_recipe_entries_repository.h +++ b/common/repositories/base/base_tradeskill_recipe_entries_repository.h @@ -97,21 +97,21 @@ public: static TradeskillRecipeEntries NewEntity() { - TradeskillRecipeEntries entry{}; + TradeskillRecipeEntries e{}; - entry.id = 0; - entry.recipe_id = 0; - entry.item_id = 0; - entry.successcount = 0; - entry.failcount = 0; - entry.componentcount = 1; - entry.salvagecount = 0; - entry.iscontainer = 0; + e.id = 0; + e.recipe_id = 0; + e.item_id = 0; + e.successcount = 0; + e.failcount = 0; + e.componentcount = 1; + e.salvagecount = 0; + e.iscontainer = 0; - return entry; + return e; } - static TradeskillRecipeEntries GetTradeskillRecipeEntriesEntry( + static TradeskillRecipeEntries GetTradeskillRecipeEntries( const std::vector &tradeskill_recipe_entriess, int tradeskill_recipe_entries_id ) @@ -140,18 +140,18 @@ public: auto row = results.begin(); if (results.RowCount() == 1) { - TradeskillRecipeEntries entry{}; + TradeskillRecipeEntries e{}; - entry.id = atoi(row[0]); - entry.recipe_id = atoi(row[1]); - entry.item_id = atoi(row[2]); - entry.successcount = atoi(row[3]); - entry.failcount = atoi(row[4]); - entry.componentcount = atoi(row[5]); - entry.salvagecount = atoi(row[6]); - entry.iscontainer = atoi(row[7]); + e.id = atoi(row[0]); + e.recipe_id = atoi(row[1]); + e.item_id = atoi(row[2]); + e.successcount = atoi(row[3]); + e.failcount = atoi(row[4]); + e.componentcount = atoi(row[5]); + e.salvagecount = atoi(row[6]); + e.iscontainer = atoi(row[7]); - return entry; + return e; } return NewEntity(); @@ -176,28 +176,28 @@ public: static int UpdateOne( Database& db, - TradeskillRecipeEntries tradeskill_recipe_entries_entry + const TradeskillRecipeEntries &e ) { - std::vector update_values; + std::vector v; auto columns = Columns(); - update_values.push_back(columns[1] + " = " + std::to_string(tradeskill_recipe_entries_entry.recipe_id)); - update_values.push_back(columns[2] + " = " + std::to_string(tradeskill_recipe_entries_entry.item_id)); - update_values.push_back(columns[3] + " = " + std::to_string(tradeskill_recipe_entries_entry.successcount)); - update_values.push_back(columns[4] + " = " + std::to_string(tradeskill_recipe_entries_entry.failcount)); - update_values.push_back(columns[5] + " = " + std::to_string(tradeskill_recipe_entries_entry.componentcount)); - update_values.push_back(columns[6] + " = " + std::to_string(tradeskill_recipe_entries_entry.salvagecount)); - update_values.push_back(columns[7] + " = " + std::to_string(tradeskill_recipe_entries_entry.iscontainer)); + v.push_back(columns[1] + " = " + std::to_string(e.recipe_id)); + v.push_back(columns[2] + " = " + std::to_string(e.item_id)); + v.push_back(columns[3] + " = " + std::to_string(e.successcount)); + v.push_back(columns[4] + " = " + std::to_string(e.failcount)); + v.push_back(columns[5] + " = " + std::to_string(e.componentcount)); + v.push_back(columns[6] + " = " + std::to_string(e.salvagecount)); + v.push_back(columns[7] + " = " + std::to_string(e.iscontainer)); auto results = db.QueryDatabase( fmt::format( "UPDATE {} SET {} WHERE {} = {}", TableName(), - Strings::Implode(", ", update_values), + Strings::Implode(", ", v), PrimaryKey(), - tradeskill_recipe_entries_entry.id + e.id ) ); @@ -206,61 +206,61 @@ public: static TradeskillRecipeEntries InsertOne( Database& db, - TradeskillRecipeEntries tradeskill_recipe_entries_entry + TradeskillRecipeEntries e ) { - std::vector insert_values; + std::vector v; - insert_values.push_back(std::to_string(tradeskill_recipe_entries_entry.id)); - insert_values.push_back(std::to_string(tradeskill_recipe_entries_entry.recipe_id)); - insert_values.push_back(std::to_string(tradeskill_recipe_entries_entry.item_id)); - insert_values.push_back(std::to_string(tradeskill_recipe_entries_entry.successcount)); - insert_values.push_back(std::to_string(tradeskill_recipe_entries_entry.failcount)); - insert_values.push_back(std::to_string(tradeskill_recipe_entries_entry.componentcount)); - insert_values.push_back(std::to_string(tradeskill_recipe_entries_entry.salvagecount)); - insert_values.push_back(std::to_string(tradeskill_recipe_entries_entry.iscontainer)); + v.push_back(std::to_string(e.id)); + v.push_back(std::to_string(e.recipe_id)); + v.push_back(std::to_string(e.item_id)); + v.push_back(std::to_string(e.successcount)); + v.push_back(std::to_string(e.failcount)); + v.push_back(std::to_string(e.componentcount)); + v.push_back(std::to_string(e.salvagecount)); + v.push_back(std::to_string(e.iscontainer)); auto results = db.QueryDatabase( fmt::format( "{} VALUES ({})", BaseInsert(), - Strings::Implode(",", insert_values) + Strings::Implode(",", v) ) ); if (results.Success()) { - tradeskill_recipe_entries_entry.id = results.LastInsertedID(); - return tradeskill_recipe_entries_entry; + e.id = results.LastInsertedID(); + return e; } - tradeskill_recipe_entries_entry = NewEntity(); + e = NewEntity(); - return tradeskill_recipe_entries_entry; + return e; } static int InsertMany( Database& db, - std::vector tradeskill_recipe_entries_entries + const std::vector &entries ) { std::vector insert_chunks; - for (auto &tradeskill_recipe_entries_entry: tradeskill_recipe_entries_entries) { - std::vector insert_values; + for (auto &e: entries) { + std::vector v; - insert_values.push_back(std::to_string(tradeskill_recipe_entries_entry.id)); - insert_values.push_back(std::to_string(tradeskill_recipe_entries_entry.recipe_id)); - insert_values.push_back(std::to_string(tradeskill_recipe_entries_entry.item_id)); - insert_values.push_back(std::to_string(tradeskill_recipe_entries_entry.successcount)); - insert_values.push_back(std::to_string(tradeskill_recipe_entries_entry.failcount)); - insert_values.push_back(std::to_string(tradeskill_recipe_entries_entry.componentcount)); - insert_values.push_back(std::to_string(tradeskill_recipe_entries_entry.salvagecount)); - insert_values.push_back(std::to_string(tradeskill_recipe_entries_entry.iscontainer)); + v.push_back(std::to_string(e.id)); + v.push_back(std::to_string(e.recipe_id)); + v.push_back(std::to_string(e.item_id)); + v.push_back(std::to_string(e.successcount)); + v.push_back(std::to_string(e.failcount)); + v.push_back(std::to_string(e.componentcount)); + v.push_back(std::to_string(e.salvagecount)); + v.push_back(std::to_string(e.iscontainer)); - insert_chunks.push_back("(" + Strings::Implode(",", insert_values) + ")"); + insert_chunks.push_back("(" + Strings::Implode(",", v) + ")"); } - std::vector insert_values; + std::vector v; auto results = db.QueryDatabase( fmt::format( @@ -287,24 +287,24 @@ public: all_entries.reserve(results.RowCount()); for (auto row = results.begin(); row != results.end(); ++row) { - TradeskillRecipeEntries entry{}; + TradeskillRecipeEntries e{}; - entry.id = atoi(row[0]); - entry.recipe_id = atoi(row[1]); - entry.item_id = atoi(row[2]); - entry.successcount = atoi(row[3]); - entry.failcount = atoi(row[4]); - entry.componentcount = atoi(row[5]); - entry.salvagecount = atoi(row[6]); - entry.iscontainer = atoi(row[7]); + e.id = atoi(row[0]); + e.recipe_id = atoi(row[1]); + e.item_id = atoi(row[2]); + e.successcount = atoi(row[3]); + e.failcount = atoi(row[4]); + e.componentcount = atoi(row[5]); + e.salvagecount = atoi(row[6]); + e.iscontainer = atoi(row[7]); - all_entries.push_back(entry); + all_entries.push_back(e); } return all_entries; } - static std::vector GetWhere(Database& db, std::string where_filter) + static std::vector GetWhere(Database& db, const std::string &where_filter) { std::vector all_entries; @@ -319,24 +319,24 @@ public: all_entries.reserve(results.RowCount()); for (auto row = results.begin(); row != results.end(); ++row) { - TradeskillRecipeEntries entry{}; + TradeskillRecipeEntries e{}; - entry.id = atoi(row[0]); - entry.recipe_id = atoi(row[1]); - entry.item_id = atoi(row[2]); - entry.successcount = atoi(row[3]); - entry.failcount = atoi(row[4]); - entry.componentcount = atoi(row[5]); - entry.salvagecount = atoi(row[6]); - entry.iscontainer = atoi(row[7]); + e.id = atoi(row[0]); + e.recipe_id = atoi(row[1]); + e.item_id = atoi(row[2]); + e.successcount = atoi(row[3]); + e.failcount = atoi(row[4]); + e.componentcount = atoi(row[5]); + e.salvagecount = atoi(row[6]); + e.iscontainer = atoi(row[7]); - all_entries.push_back(entry); + all_entries.push_back(e); } return all_entries; } - static int DeleteWhere(Database& db, std::string where_filter) + static int DeleteWhere(Database& db, const std::string &where_filter) { auto results = db.QueryDatabase( fmt::format( @@ -361,6 +361,32 @@ public: 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); + } + }; #endif //EQEMU_BASE_TRADESKILL_RECIPE_ENTRIES_REPOSITORY_H diff --git a/common/repositories/base/base_tradeskill_recipe_repository.h b/common/repositories/base/base_tradeskill_recipe_repository.h index 773433a68..4d9420aa6 100644 --- a/common/repositories/base/base_tradeskill_recipe_repository.h +++ b/common/repositories/base/base_tradeskill_recipe_repository.h @@ -118,28 +118,28 @@ public: static TradeskillRecipe NewEntity() { - TradeskillRecipe entry{}; + TradeskillRecipe e{}; - entry.id = 0; - entry.name = ""; - entry.tradeskill = 0; - entry.skillneeded = 0; - entry.trivial = 0; - entry.nofail = 0; - entry.replace_container = 0; - entry.notes = ""; - entry.must_learn = 0; - entry.quest = 0; - entry.enabled = 1; - entry.min_expansion = -1; - entry.max_expansion = -1; - entry.content_flags = ""; - entry.content_flags_disabled = ""; + e.id = 0; + e.name = ""; + e.tradeskill = 0; + e.skillneeded = 0; + e.trivial = 0; + e.nofail = 0; + e.replace_container = 0; + e.notes = ""; + e.must_learn = 0; + e.quest = 0; + e.enabled = 1; + e.min_expansion = -1; + e.max_expansion = -1; + e.content_flags = ""; + e.content_flags_disabled = ""; - return entry; + return e; } - static TradeskillRecipe GetTradeskillRecipeEntry( + static TradeskillRecipe GetTradeskillRecipe( const std::vector &tradeskill_recipes, int tradeskill_recipe_id ) @@ -168,25 +168,25 @@ public: auto row = results.begin(); if (results.RowCount() == 1) { - TradeskillRecipe entry{}; + TradeskillRecipe e{}; - entry.id = atoi(row[0]); - entry.name = row[1] ? row[1] : ""; - entry.tradeskill = atoi(row[2]); - entry.skillneeded = atoi(row[3]); - entry.trivial = atoi(row[4]); - entry.nofail = atoi(row[5]); - entry.replace_container = atoi(row[6]); - entry.notes = row[7] ? row[7] : ""; - entry.must_learn = atoi(row[8]); - entry.quest = atoi(row[9]); - entry.enabled = atoi(row[10]); - entry.min_expansion = atoi(row[11]); - entry.max_expansion = atoi(row[12]); - entry.content_flags = row[13] ? row[13] : ""; - entry.content_flags_disabled = row[14] ? row[14] : ""; + e.id = atoi(row[0]); + e.name = row[1] ? row[1] : ""; + e.tradeskill = atoi(row[2]); + e.skillneeded = atoi(row[3]); + e.trivial = atoi(row[4]); + e.nofail = atoi(row[5]); + e.replace_container = atoi(row[6]); + e.notes = row[7] ? row[7] : ""; + e.must_learn = atoi(row[8]); + e.quest = atoi(row[9]); + e.enabled = atoi(row[10]); + e.min_expansion = atoi(row[11]); + e.max_expansion = atoi(row[12]); + e.content_flags = row[13] ? row[13] : ""; + e.content_flags_disabled = row[14] ? row[14] : ""; - return entry; + return e; } return NewEntity(); @@ -211,35 +211,35 @@ public: static int UpdateOne( Database& db, - TradeskillRecipe tradeskill_recipe_entry + const TradeskillRecipe &e ) { - std::vector update_values; + std::vector v; auto columns = Columns(); - update_values.push_back(columns[1] + " = '" + Strings::Escape(tradeskill_recipe_entry.name) + "'"); - update_values.push_back(columns[2] + " = " + std::to_string(tradeskill_recipe_entry.tradeskill)); - update_values.push_back(columns[3] + " = " + std::to_string(tradeskill_recipe_entry.skillneeded)); - update_values.push_back(columns[4] + " = " + std::to_string(tradeskill_recipe_entry.trivial)); - update_values.push_back(columns[5] + " = " + std::to_string(tradeskill_recipe_entry.nofail)); - update_values.push_back(columns[6] + " = " + std::to_string(tradeskill_recipe_entry.replace_container)); - update_values.push_back(columns[7] + " = '" + Strings::Escape(tradeskill_recipe_entry.notes) + "'"); - update_values.push_back(columns[8] + " = " + std::to_string(tradeskill_recipe_entry.must_learn)); - update_values.push_back(columns[9] + " = " + std::to_string(tradeskill_recipe_entry.quest)); - update_values.push_back(columns[10] + " = " + std::to_string(tradeskill_recipe_entry.enabled)); - update_values.push_back(columns[11] + " = " + std::to_string(tradeskill_recipe_entry.min_expansion)); - update_values.push_back(columns[12] + " = " + std::to_string(tradeskill_recipe_entry.max_expansion)); - update_values.push_back(columns[13] + " = '" + Strings::Escape(tradeskill_recipe_entry.content_flags) + "'"); - update_values.push_back(columns[14] + " = '" + Strings::Escape(tradeskill_recipe_entry.content_flags_disabled) + "'"); + v.push_back(columns[1] + " = '" + Strings::Escape(e.name) + "'"); + v.push_back(columns[2] + " = " + std::to_string(e.tradeskill)); + v.push_back(columns[3] + " = " + std::to_string(e.skillneeded)); + v.push_back(columns[4] + " = " + std::to_string(e.trivial)); + v.push_back(columns[5] + " = " + std::to_string(e.nofail)); + v.push_back(columns[6] + " = " + std::to_string(e.replace_container)); + v.push_back(columns[7] + " = '" + Strings::Escape(e.notes) + "'"); + v.push_back(columns[8] + " = " + std::to_string(e.must_learn)); + v.push_back(columns[9] + " = " + std::to_string(e.quest)); + v.push_back(columns[10] + " = " + std::to_string(e.enabled)); + v.push_back(columns[11] + " = " + std::to_string(e.min_expansion)); + v.push_back(columns[12] + " = " + std::to_string(e.max_expansion)); + v.push_back(columns[13] + " = '" + Strings::Escape(e.content_flags) + "'"); + v.push_back(columns[14] + " = '" + Strings::Escape(e.content_flags_disabled) + "'"); auto results = db.QueryDatabase( fmt::format( "UPDATE {} SET {} WHERE {} = {}", TableName(), - Strings::Implode(", ", update_values), + Strings::Implode(", ", v), PrimaryKey(), - tradeskill_recipe_entry.id + e.id ) ); @@ -248,75 +248,75 @@ public: static TradeskillRecipe InsertOne( Database& db, - TradeskillRecipe tradeskill_recipe_entry + TradeskillRecipe e ) { - std::vector insert_values; + std::vector v; - insert_values.push_back(std::to_string(tradeskill_recipe_entry.id)); - insert_values.push_back("'" + Strings::Escape(tradeskill_recipe_entry.name) + "'"); - insert_values.push_back(std::to_string(tradeskill_recipe_entry.tradeskill)); - insert_values.push_back(std::to_string(tradeskill_recipe_entry.skillneeded)); - insert_values.push_back(std::to_string(tradeskill_recipe_entry.trivial)); - insert_values.push_back(std::to_string(tradeskill_recipe_entry.nofail)); - insert_values.push_back(std::to_string(tradeskill_recipe_entry.replace_container)); - insert_values.push_back("'" + Strings::Escape(tradeskill_recipe_entry.notes) + "'"); - insert_values.push_back(std::to_string(tradeskill_recipe_entry.must_learn)); - insert_values.push_back(std::to_string(tradeskill_recipe_entry.quest)); - insert_values.push_back(std::to_string(tradeskill_recipe_entry.enabled)); - insert_values.push_back(std::to_string(tradeskill_recipe_entry.min_expansion)); - insert_values.push_back(std::to_string(tradeskill_recipe_entry.max_expansion)); - insert_values.push_back("'" + Strings::Escape(tradeskill_recipe_entry.content_flags) + "'"); - insert_values.push_back("'" + Strings::Escape(tradeskill_recipe_entry.content_flags_disabled) + "'"); + v.push_back(std::to_string(e.id)); + v.push_back("'" + Strings::Escape(e.name) + "'"); + v.push_back(std::to_string(e.tradeskill)); + v.push_back(std::to_string(e.skillneeded)); + v.push_back(std::to_string(e.trivial)); + v.push_back(std::to_string(e.nofail)); + v.push_back(std::to_string(e.replace_container)); + v.push_back("'" + Strings::Escape(e.notes) + "'"); + v.push_back(std::to_string(e.must_learn)); + v.push_back(std::to_string(e.quest)); + v.push_back(std::to_string(e.enabled)); + v.push_back(std::to_string(e.min_expansion)); + v.push_back(std::to_string(e.max_expansion)); + v.push_back("'" + Strings::Escape(e.content_flags) + "'"); + v.push_back("'" + Strings::Escape(e.content_flags_disabled) + "'"); auto results = db.QueryDatabase( fmt::format( "{} VALUES ({})", BaseInsert(), - Strings::Implode(",", insert_values) + Strings::Implode(",", v) ) ); if (results.Success()) { - tradeskill_recipe_entry.id = results.LastInsertedID(); - return tradeskill_recipe_entry; + e.id = results.LastInsertedID(); + return e; } - tradeskill_recipe_entry = NewEntity(); + e = NewEntity(); - return tradeskill_recipe_entry; + return e; } static int InsertMany( Database& db, - std::vector tradeskill_recipe_entries + const std::vector &entries ) { std::vector insert_chunks; - for (auto &tradeskill_recipe_entry: tradeskill_recipe_entries) { - std::vector insert_values; + for (auto &e: entries) { + std::vector v; - insert_values.push_back(std::to_string(tradeskill_recipe_entry.id)); - insert_values.push_back("'" + Strings::Escape(tradeskill_recipe_entry.name) + "'"); - insert_values.push_back(std::to_string(tradeskill_recipe_entry.tradeskill)); - insert_values.push_back(std::to_string(tradeskill_recipe_entry.skillneeded)); - insert_values.push_back(std::to_string(tradeskill_recipe_entry.trivial)); - insert_values.push_back(std::to_string(tradeskill_recipe_entry.nofail)); - insert_values.push_back(std::to_string(tradeskill_recipe_entry.replace_container)); - insert_values.push_back("'" + Strings::Escape(tradeskill_recipe_entry.notes) + "'"); - insert_values.push_back(std::to_string(tradeskill_recipe_entry.must_learn)); - insert_values.push_back(std::to_string(tradeskill_recipe_entry.quest)); - insert_values.push_back(std::to_string(tradeskill_recipe_entry.enabled)); - insert_values.push_back(std::to_string(tradeskill_recipe_entry.min_expansion)); - insert_values.push_back(std::to_string(tradeskill_recipe_entry.max_expansion)); - insert_values.push_back("'" + Strings::Escape(tradeskill_recipe_entry.content_flags) + "'"); - insert_values.push_back("'" + Strings::Escape(tradeskill_recipe_entry.content_flags_disabled) + "'"); + v.push_back(std::to_string(e.id)); + v.push_back("'" + Strings::Escape(e.name) + "'"); + v.push_back(std::to_string(e.tradeskill)); + v.push_back(std::to_string(e.skillneeded)); + v.push_back(std::to_string(e.trivial)); + v.push_back(std::to_string(e.nofail)); + v.push_back(std::to_string(e.replace_container)); + v.push_back("'" + Strings::Escape(e.notes) + "'"); + v.push_back(std::to_string(e.must_learn)); + v.push_back(std::to_string(e.quest)); + v.push_back(std::to_string(e.enabled)); + v.push_back(std::to_string(e.min_expansion)); + v.push_back(std::to_string(e.max_expansion)); + v.push_back("'" + Strings::Escape(e.content_flags) + "'"); + v.push_back("'" + Strings::Escape(e.content_flags_disabled) + "'"); - insert_chunks.push_back("(" + Strings::Implode(",", insert_values) + ")"); + insert_chunks.push_back("(" + Strings::Implode(",", v) + ")"); } - std::vector insert_values; + std::vector v; auto results = db.QueryDatabase( fmt::format( @@ -343,31 +343,31 @@ public: all_entries.reserve(results.RowCount()); for (auto row = results.begin(); row != results.end(); ++row) { - TradeskillRecipe entry{}; + TradeskillRecipe e{}; - entry.id = atoi(row[0]); - entry.name = row[1] ? row[1] : ""; - entry.tradeskill = atoi(row[2]); - entry.skillneeded = atoi(row[3]); - entry.trivial = atoi(row[4]); - entry.nofail = atoi(row[5]); - entry.replace_container = atoi(row[6]); - entry.notes = row[7] ? row[7] : ""; - entry.must_learn = atoi(row[8]); - entry.quest = atoi(row[9]); - entry.enabled = atoi(row[10]); - entry.min_expansion = atoi(row[11]); - entry.max_expansion = atoi(row[12]); - entry.content_flags = row[13] ? row[13] : ""; - entry.content_flags_disabled = row[14] ? row[14] : ""; + e.id = atoi(row[0]); + e.name = row[1] ? row[1] : ""; + e.tradeskill = atoi(row[2]); + e.skillneeded = atoi(row[3]); + e.trivial = atoi(row[4]); + e.nofail = atoi(row[5]); + e.replace_container = atoi(row[6]); + e.notes = row[7] ? row[7] : ""; + e.must_learn = atoi(row[8]); + e.quest = atoi(row[9]); + e.enabled = atoi(row[10]); + e.min_expansion = atoi(row[11]); + e.max_expansion = atoi(row[12]); + e.content_flags = row[13] ? row[13] : ""; + e.content_flags_disabled = row[14] ? row[14] : ""; - all_entries.push_back(entry); + all_entries.push_back(e); } return all_entries; } - static std::vector GetWhere(Database& db, std::string where_filter) + static std::vector GetWhere(Database& db, const std::string &where_filter) { std::vector all_entries; @@ -382,31 +382,31 @@ public: all_entries.reserve(results.RowCount()); for (auto row = results.begin(); row != results.end(); ++row) { - TradeskillRecipe entry{}; + TradeskillRecipe e{}; - entry.id = atoi(row[0]); - entry.name = row[1] ? row[1] : ""; - entry.tradeskill = atoi(row[2]); - entry.skillneeded = atoi(row[3]); - entry.trivial = atoi(row[4]); - entry.nofail = atoi(row[5]); - entry.replace_container = atoi(row[6]); - entry.notes = row[7] ? row[7] : ""; - entry.must_learn = atoi(row[8]); - entry.quest = atoi(row[9]); - entry.enabled = atoi(row[10]); - entry.min_expansion = atoi(row[11]); - entry.max_expansion = atoi(row[12]); - entry.content_flags = row[13] ? row[13] : ""; - entry.content_flags_disabled = row[14] ? row[14] : ""; + e.id = atoi(row[0]); + e.name = row[1] ? row[1] : ""; + e.tradeskill = atoi(row[2]); + e.skillneeded = atoi(row[3]); + e.trivial = atoi(row[4]); + e.nofail = atoi(row[5]); + e.replace_container = atoi(row[6]); + e.notes = row[7] ? row[7] : ""; + e.must_learn = atoi(row[8]); + e.quest = atoi(row[9]); + e.enabled = atoi(row[10]); + e.min_expansion = atoi(row[11]); + e.max_expansion = atoi(row[12]); + e.content_flags = row[13] ? row[13] : ""; + e.content_flags_disabled = row[14] ? row[14] : ""; - all_entries.push_back(entry); + all_entries.push_back(e); } return all_entries; } - static int DeleteWhere(Database& db, std::string where_filter) + static int DeleteWhere(Database& db, const std::string &where_filter) { auto results = db.QueryDatabase( fmt::format( @@ -431,6 +431,32 @@ public: 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); + } + }; #endif //EQEMU_BASE_TRADESKILL_RECIPE_REPOSITORY_H diff --git a/common/repositories/base/base_traps_repository.h b/common/repositories/base/base_traps_repository.h index f3c6ac3cf..a156fd792 100644 --- a/common/repositories/base/base_traps_repository.h +++ b/common/repositories/base/base_traps_repository.h @@ -148,38 +148,38 @@ public: static Traps NewEntity() { - Traps entry{}; + Traps e{}; - entry.id = 0; - entry.zone = ""; - entry.version = 0; - entry.x = 0; - entry.y = 0; - entry.z = 0; - entry.chance = 0; - entry.maxzdiff = 0; - entry.radius = 0; - entry.effect = 0; - entry.effectvalue = 0; - entry.effectvalue2 = 0; - entry.message = ""; - entry.skill = 0; - entry.level = 1; - entry.respawn_time = 60; - entry.respawn_var = 0; - entry.triggered_number = 0; - entry.group = 0; - entry.despawn_when_triggered = 0; - entry.undetectable = 0; - entry.min_expansion = -1; - entry.max_expansion = -1; - entry.content_flags = ""; - entry.content_flags_disabled = ""; + e.id = 0; + e.zone = ""; + e.version = 0; + e.x = 0; + e.y = 0; + e.z = 0; + e.chance = 0; + e.maxzdiff = 0; + e.radius = 0; + e.effect = 0; + e.effectvalue = 0; + e.effectvalue2 = 0; + e.message = ""; + e.skill = 0; + e.level = 1; + e.respawn_time = 60; + e.respawn_var = 0; + e.triggered_number = 0; + e.group = 0; + e.despawn_when_triggered = 0; + e.undetectable = 0; + e.min_expansion = -1; + e.max_expansion = -1; + e.content_flags = ""; + e.content_flags_disabled = ""; - return entry; + return e; } - static Traps GetTrapsEntry( + static Traps GetTraps( const std::vector &trapss, int traps_id ) @@ -208,35 +208,35 @@ public: auto row = results.begin(); if (results.RowCount() == 1) { - Traps entry{}; + Traps e{}; - entry.id = atoi(row[0]); - entry.zone = row[1] ? row[1] : ""; - entry.version = atoi(row[2]); - entry.x = atoi(row[3]); - entry.y = atoi(row[4]); - entry.z = atoi(row[5]); - entry.chance = atoi(row[6]); - entry.maxzdiff = static_cast(atof(row[7])); - entry.radius = static_cast(atof(row[8])); - entry.effect = atoi(row[9]); - entry.effectvalue = atoi(row[10]); - entry.effectvalue2 = atoi(row[11]); - entry.message = row[12] ? row[12] : ""; - entry.skill = atoi(row[13]); - entry.level = atoi(row[14]); - entry.respawn_time = atoi(row[15]); - entry.respawn_var = atoi(row[16]); - entry.triggered_number = atoi(row[17]); - entry.group = atoi(row[18]); - entry.despawn_when_triggered = atoi(row[19]); - entry.undetectable = atoi(row[20]); - entry.min_expansion = atoi(row[21]); - entry.max_expansion = atoi(row[22]); - entry.content_flags = row[23] ? row[23] : ""; - entry.content_flags_disabled = row[24] ? row[24] : ""; + e.id = atoi(row[0]); + e.zone = row[1] ? row[1] : ""; + e.version = atoi(row[2]); + e.x = atoi(row[3]); + e.y = atoi(row[4]); + e.z = atoi(row[5]); + e.chance = atoi(row[6]); + e.maxzdiff = static_cast(atof(row[7])); + e.radius = static_cast(atof(row[8])); + e.effect = atoi(row[9]); + e.effectvalue = atoi(row[10]); + e.effectvalue2 = atoi(row[11]); + e.message = row[12] ? row[12] : ""; + e.skill = atoi(row[13]); + e.level = atoi(row[14]); + e.respawn_time = atoi(row[15]); + e.respawn_var = atoi(row[16]); + e.triggered_number = atoi(row[17]); + e.group = atoi(row[18]); + e.despawn_when_triggered = atoi(row[19]); + e.undetectable = atoi(row[20]); + e.min_expansion = atoi(row[21]); + e.max_expansion = atoi(row[22]); + e.content_flags = row[23] ? row[23] : ""; + e.content_flags_disabled = row[24] ? row[24] : ""; - return entry; + return e; } return NewEntity(); @@ -261,45 +261,45 @@ public: static int UpdateOne( Database& db, - Traps traps_entry + const Traps &e ) { - std::vector update_values; + std::vector v; auto columns = Columns(); - update_values.push_back(columns[1] + " = '" + Strings::Escape(traps_entry.zone) + "'"); - update_values.push_back(columns[2] + " = " + std::to_string(traps_entry.version)); - update_values.push_back(columns[3] + " = " + std::to_string(traps_entry.x)); - update_values.push_back(columns[4] + " = " + std::to_string(traps_entry.y)); - update_values.push_back(columns[5] + " = " + std::to_string(traps_entry.z)); - update_values.push_back(columns[6] + " = " + std::to_string(traps_entry.chance)); - update_values.push_back(columns[7] + " = " + std::to_string(traps_entry.maxzdiff)); - update_values.push_back(columns[8] + " = " + std::to_string(traps_entry.radius)); - update_values.push_back(columns[9] + " = " + std::to_string(traps_entry.effect)); - update_values.push_back(columns[10] + " = " + std::to_string(traps_entry.effectvalue)); - update_values.push_back(columns[11] + " = " + std::to_string(traps_entry.effectvalue2)); - update_values.push_back(columns[12] + " = '" + Strings::Escape(traps_entry.message) + "'"); - update_values.push_back(columns[13] + " = " + std::to_string(traps_entry.skill)); - update_values.push_back(columns[14] + " = " + std::to_string(traps_entry.level)); - update_values.push_back(columns[15] + " = " + std::to_string(traps_entry.respawn_time)); - update_values.push_back(columns[16] + " = " + std::to_string(traps_entry.respawn_var)); - update_values.push_back(columns[17] + " = " + std::to_string(traps_entry.triggered_number)); - update_values.push_back(columns[18] + " = " + std::to_string(traps_entry.group)); - update_values.push_back(columns[19] + " = " + std::to_string(traps_entry.despawn_when_triggered)); - update_values.push_back(columns[20] + " = " + std::to_string(traps_entry.undetectable)); - update_values.push_back(columns[21] + " = " + std::to_string(traps_entry.min_expansion)); - update_values.push_back(columns[22] + " = " + std::to_string(traps_entry.max_expansion)); - update_values.push_back(columns[23] + " = '" + Strings::Escape(traps_entry.content_flags) + "'"); - update_values.push_back(columns[24] + " = '" + Strings::Escape(traps_entry.content_flags_disabled) + "'"); + v.push_back(columns[1] + " = '" + Strings::Escape(e.zone) + "'"); + v.push_back(columns[2] + " = " + std::to_string(e.version)); + v.push_back(columns[3] + " = " + std::to_string(e.x)); + v.push_back(columns[4] + " = " + std::to_string(e.y)); + v.push_back(columns[5] + " = " + std::to_string(e.z)); + v.push_back(columns[6] + " = " + std::to_string(e.chance)); + v.push_back(columns[7] + " = " + std::to_string(e.maxzdiff)); + v.push_back(columns[8] + " = " + std::to_string(e.radius)); + v.push_back(columns[9] + " = " + std::to_string(e.effect)); + v.push_back(columns[10] + " = " + std::to_string(e.effectvalue)); + v.push_back(columns[11] + " = " + std::to_string(e.effectvalue2)); + v.push_back(columns[12] + " = '" + Strings::Escape(e.message) + "'"); + v.push_back(columns[13] + " = " + std::to_string(e.skill)); + v.push_back(columns[14] + " = " + std::to_string(e.level)); + v.push_back(columns[15] + " = " + std::to_string(e.respawn_time)); + v.push_back(columns[16] + " = " + std::to_string(e.respawn_var)); + v.push_back(columns[17] + " = " + std::to_string(e.triggered_number)); + v.push_back(columns[18] + " = " + std::to_string(e.group)); + v.push_back(columns[19] + " = " + std::to_string(e.despawn_when_triggered)); + v.push_back(columns[20] + " = " + std::to_string(e.undetectable)); + v.push_back(columns[21] + " = " + std::to_string(e.min_expansion)); + v.push_back(columns[22] + " = " + std::to_string(e.max_expansion)); + v.push_back(columns[23] + " = '" + Strings::Escape(e.content_flags) + "'"); + v.push_back(columns[24] + " = '" + Strings::Escape(e.content_flags_disabled) + "'"); auto results = db.QueryDatabase( fmt::format( "UPDATE {} SET {} WHERE {} = {}", TableName(), - Strings::Implode(", ", update_values), + Strings::Implode(", ", v), PrimaryKey(), - traps_entry.id + e.id ) ); @@ -308,95 +308,95 @@ public: static Traps InsertOne( Database& db, - Traps traps_entry + Traps e ) { - std::vector insert_values; + std::vector v; - insert_values.push_back(std::to_string(traps_entry.id)); - insert_values.push_back("'" + Strings::Escape(traps_entry.zone) + "'"); - insert_values.push_back(std::to_string(traps_entry.version)); - insert_values.push_back(std::to_string(traps_entry.x)); - insert_values.push_back(std::to_string(traps_entry.y)); - insert_values.push_back(std::to_string(traps_entry.z)); - insert_values.push_back(std::to_string(traps_entry.chance)); - insert_values.push_back(std::to_string(traps_entry.maxzdiff)); - insert_values.push_back(std::to_string(traps_entry.radius)); - insert_values.push_back(std::to_string(traps_entry.effect)); - insert_values.push_back(std::to_string(traps_entry.effectvalue)); - insert_values.push_back(std::to_string(traps_entry.effectvalue2)); - insert_values.push_back("'" + Strings::Escape(traps_entry.message) + "'"); - insert_values.push_back(std::to_string(traps_entry.skill)); - insert_values.push_back(std::to_string(traps_entry.level)); - insert_values.push_back(std::to_string(traps_entry.respawn_time)); - insert_values.push_back(std::to_string(traps_entry.respawn_var)); - insert_values.push_back(std::to_string(traps_entry.triggered_number)); - insert_values.push_back(std::to_string(traps_entry.group)); - insert_values.push_back(std::to_string(traps_entry.despawn_when_triggered)); - insert_values.push_back(std::to_string(traps_entry.undetectable)); - insert_values.push_back(std::to_string(traps_entry.min_expansion)); - insert_values.push_back(std::to_string(traps_entry.max_expansion)); - insert_values.push_back("'" + Strings::Escape(traps_entry.content_flags) + "'"); - insert_values.push_back("'" + Strings::Escape(traps_entry.content_flags_disabled) + "'"); + v.push_back(std::to_string(e.id)); + v.push_back("'" + Strings::Escape(e.zone) + "'"); + v.push_back(std::to_string(e.version)); + v.push_back(std::to_string(e.x)); + v.push_back(std::to_string(e.y)); + v.push_back(std::to_string(e.z)); + v.push_back(std::to_string(e.chance)); + v.push_back(std::to_string(e.maxzdiff)); + v.push_back(std::to_string(e.radius)); + v.push_back(std::to_string(e.effect)); + v.push_back(std::to_string(e.effectvalue)); + v.push_back(std::to_string(e.effectvalue2)); + v.push_back("'" + Strings::Escape(e.message) + "'"); + v.push_back(std::to_string(e.skill)); + v.push_back(std::to_string(e.level)); + v.push_back(std::to_string(e.respawn_time)); + v.push_back(std::to_string(e.respawn_var)); + v.push_back(std::to_string(e.triggered_number)); + v.push_back(std::to_string(e.group)); + v.push_back(std::to_string(e.despawn_when_triggered)); + v.push_back(std::to_string(e.undetectable)); + v.push_back(std::to_string(e.min_expansion)); + v.push_back(std::to_string(e.max_expansion)); + v.push_back("'" + Strings::Escape(e.content_flags) + "'"); + v.push_back("'" + Strings::Escape(e.content_flags_disabled) + "'"); auto results = db.QueryDatabase( fmt::format( "{} VALUES ({})", BaseInsert(), - Strings::Implode(",", insert_values) + Strings::Implode(",", v) ) ); if (results.Success()) { - traps_entry.id = results.LastInsertedID(); - return traps_entry; + e.id = results.LastInsertedID(); + return e; } - traps_entry = NewEntity(); + e = NewEntity(); - return traps_entry; + return e; } static int InsertMany( Database& db, - std::vector traps_entries + const std::vector &entries ) { std::vector insert_chunks; - for (auto &traps_entry: traps_entries) { - std::vector insert_values; + for (auto &e: entries) { + std::vector v; - insert_values.push_back(std::to_string(traps_entry.id)); - insert_values.push_back("'" + Strings::Escape(traps_entry.zone) + "'"); - insert_values.push_back(std::to_string(traps_entry.version)); - insert_values.push_back(std::to_string(traps_entry.x)); - insert_values.push_back(std::to_string(traps_entry.y)); - insert_values.push_back(std::to_string(traps_entry.z)); - insert_values.push_back(std::to_string(traps_entry.chance)); - insert_values.push_back(std::to_string(traps_entry.maxzdiff)); - insert_values.push_back(std::to_string(traps_entry.radius)); - insert_values.push_back(std::to_string(traps_entry.effect)); - insert_values.push_back(std::to_string(traps_entry.effectvalue)); - insert_values.push_back(std::to_string(traps_entry.effectvalue2)); - insert_values.push_back("'" + Strings::Escape(traps_entry.message) + "'"); - insert_values.push_back(std::to_string(traps_entry.skill)); - insert_values.push_back(std::to_string(traps_entry.level)); - insert_values.push_back(std::to_string(traps_entry.respawn_time)); - insert_values.push_back(std::to_string(traps_entry.respawn_var)); - insert_values.push_back(std::to_string(traps_entry.triggered_number)); - insert_values.push_back(std::to_string(traps_entry.group)); - insert_values.push_back(std::to_string(traps_entry.despawn_when_triggered)); - insert_values.push_back(std::to_string(traps_entry.undetectable)); - insert_values.push_back(std::to_string(traps_entry.min_expansion)); - insert_values.push_back(std::to_string(traps_entry.max_expansion)); - insert_values.push_back("'" + Strings::Escape(traps_entry.content_flags) + "'"); - insert_values.push_back("'" + Strings::Escape(traps_entry.content_flags_disabled) + "'"); + v.push_back(std::to_string(e.id)); + v.push_back("'" + Strings::Escape(e.zone) + "'"); + v.push_back(std::to_string(e.version)); + v.push_back(std::to_string(e.x)); + v.push_back(std::to_string(e.y)); + v.push_back(std::to_string(e.z)); + v.push_back(std::to_string(e.chance)); + v.push_back(std::to_string(e.maxzdiff)); + v.push_back(std::to_string(e.radius)); + v.push_back(std::to_string(e.effect)); + v.push_back(std::to_string(e.effectvalue)); + v.push_back(std::to_string(e.effectvalue2)); + v.push_back("'" + Strings::Escape(e.message) + "'"); + v.push_back(std::to_string(e.skill)); + v.push_back(std::to_string(e.level)); + v.push_back(std::to_string(e.respawn_time)); + v.push_back(std::to_string(e.respawn_var)); + v.push_back(std::to_string(e.triggered_number)); + v.push_back(std::to_string(e.group)); + v.push_back(std::to_string(e.despawn_when_triggered)); + v.push_back(std::to_string(e.undetectable)); + v.push_back(std::to_string(e.min_expansion)); + v.push_back(std::to_string(e.max_expansion)); + v.push_back("'" + Strings::Escape(e.content_flags) + "'"); + v.push_back("'" + Strings::Escape(e.content_flags_disabled) + "'"); - insert_chunks.push_back("(" + Strings::Implode(",", insert_values) + ")"); + insert_chunks.push_back("(" + Strings::Implode(",", v) + ")"); } - std::vector insert_values; + std::vector v; auto results = db.QueryDatabase( fmt::format( @@ -423,41 +423,41 @@ public: all_entries.reserve(results.RowCount()); for (auto row = results.begin(); row != results.end(); ++row) { - Traps entry{}; + Traps e{}; - entry.id = atoi(row[0]); - entry.zone = row[1] ? row[1] : ""; - entry.version = atoi(row[2]); - entry.x = atoi(row[3]); - entry.y = atoi(row[4]); - entry.z = atoi(row[5]); - entry.chance = atoi(row[6]); - entry.maxzdiff = static_cast(atof(row[7])); - entry.radius = static_cast(atof(row[8])); - entry.effect = atoi(row[9]); - entry.effectvalue = atoi(row[10]); - entry.effectvalue2 = atoi(row[11]); - entry.message = row[12] ? row[12] : ""; - entry.skill = atoi(row[13]); - entry.level = atoi(row[14]); - entry.respawn_time = atoi(row[15]); - entry.respawn_var = atoi(row[16]); - entry.triggered_number = atoi(row[17]); - entry.group = atoi(row[18]); - entry.despawn_when_triggered = atoi(row[19]); - entry.undetectable = atoi(row[20]); - entry.min_expansion = atoi(row[21]); - entry.max_expansion = atoi(row[22]); - entry.content_flags = row[23] ? row[23] : ""; - entry.content_flags_disabled = row[24] ? row[24] : ""; + e.id = atoi(row[0]); + e.zone = row[1] ? row[1] : ""; + e.version = atoi(row[2]); + e.x = atoi(row[3]); + e.y = atoi(row[4]); + e.z = atoi(row[5]); + e.chance = atoi(row[6]); + e.maxzdiff = static_cast(atof(row[7])); + e.radius = static_cast(atof(row[8])); + e.effect = atoi(row[9]); + e.effectvalue = atoi(row[10]); + e.effectvalue2 = atoi(row[11]); + e.message = row[12] ? row[12] : ""; + e.skill = atoi(row[13]); + e.level = atoi(row[14]); + e.respawn_time = atoi(row[15]); + e.respawn_var = atoi(row[16]); + e.triggered_number = atoi(row[17]); + e.group = atoi(row[18]); + e.despawn_when_triggered = atoi(row[19]); + e.undetectable = atoi(row[20]); + e.min_expansion = atoi(row[21]); + e.max_expansion = atoi(row[22]); + e.content_flags = row[23] ? row[23] : ""; + e.content_flags_disabled = row[24] ? row[24] : ""; - all_entries.push_back(entry); + all_entries.push_back(e); } return all_entries; } - static std::vector GetWhere(Database& db, std::string where_filter) + static std::vector GetWhere(Database& db, const std::string &where_filter) { std::vector all_entries; @@ -472,41 +472,41 @@ public: all_entries.reserve(results.RowCount()); for (auto row = results.begin(); row != results.end(); ++row) { - Traps entry{}; + Traps e{}; - entry.id = atoi(row[0]); - entry.zone = row[1] ? row[1] : ""; - entry.version = atoi(row[2]); - entry.x = atoi(row[3]); - entry.y = atoi(row[4]); - entry.z = atoi(row[5]); - entry.chance = atoi(row[6]); - entry.maxzdiff = static_cast(atof(row[7])); - entry.radius = static_cast(atof(row[8])); - entry.effect = atoi(row[9]); - entry.effectvalue = atoi(row[10]); - entry.effectvalue2 = atoi(row[11]); - entry.message = row[12] ? row[12] : ""; - entry.skill = atoi(row[13]); - entry.level = atoi(row[14]); - entry.respawn_time = atoi(row[15]); - entry.respawn_var = atoi(row[16]); - entry.triggered_number = atoi(row[17]); - entry.group = atoi(row[18]); - entry.despawn_when_triggered = atoi(row[19]); - entry.undetectable = atoi(row[20]); - entry.min_expansion = atoi(row[21]); - entry.max_expansion = atoi(row[22]); - entry.content_flags = row[23] ? row[23] : ""; - entry.content_flags_disabled = row[24] ? row[24] : ""; + e.id = atoi(row[0]); + e.zone = row[1] ? row[1] : ""; + e.version = atoi(row[2]); + e.x = atoi(row[3]); + e.y = atoi(row[4]); + e.z = atoi(row[5]); + e.chance = atoi(row[6]); + e.maxzdiff = static_cast(atof(row[7])); + e.radius = static_cast(atof(row[8])); + e.effect = atoi(row[9]); + e.effectvalue = atoi(row[10]); + e.effectvalue2 = atoi(row[11]); + e.message = row[12] ? row[12] : ""; + e.skill = atoi(row[13]); + e.level = atoi(row[14]); + e.respawn_time = atoi(row[15]); + e.respawn_var = atoi(row[16]); + e.triggered_number = atoi(row[17]); + e.group = atoi(row[18]); + e.despawn_when_triggered = atoi(row[19]); + e.undetectable = atoi(row[20]); + e.min_expansion = atoi(row[21]); + e.max_expansion = atoi(row[22]); + e.content_flags = row[23] ? row[23] : ""; + e.content_flags_disabled = row[24] ? row[24] : ""; - all_entries.push_back(entry); + all_entries.push_back(e); } return all_entries; } - static int DeleteWhere(Database& db, std::string where_filter) + static int DeleteWhere(Database& db, const std::string &where_filter) { auto results = db.QueryDatabase( fmt::format( @@ -531,6 +531,32 @@ public: 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); + } + }; #endif //EQEMU_BASE_TRAPS_REPOSITORY_H diff --git a/common/repositories/base/base_tribute_levels_repository.h b/common/repositories/base/base_tribute_levels_repository.h index 26440680b..a115c5d84 100644 --- a/common/repositories/base/base_tribute_levels_repository.h +++ b/common/repositories/base/base_tribute_levels_repository.h @@ -85,17 +85,17 @@ public: static TributeLevels NewEntity() { - TributeLevels entry{}; + TributeLevels e{}; - entry.tribute_id = 0; - entry.level = 0; - entry.cost = 0; - entry.item_id = 0; + e.tribute_id = 0; + e.level = 0; + e.cost = 0; + e.item_id = 0; - return entry; + return e; } - static TributeLevels GetTributeLevelsEntry( + static TributeLevels GetTributeLevels( const std::vector &tribute_levelss, int tribute_levels_id ) @@ -124,14 +124,14 @@ public: auto row = results.begin(); if (results.RowCount() == 1) { - TributeLevels entry{}; + TributeLevels e{}; - entry.tribute_id = atoi(row[0]); - entry.level = atoi(row[1]); - entry.cost = atoi(row[2]); - entry.item_id = atoi(row[3]); + e.tribute_id = atoi(row[0]); + e.level = atoi(row[1]); + e.cost = atoi(row[2]); + e.item_id = atoi(row[3]); - return entry; + return e; } return NewEntity(); @@ -156,25 +156,25 @@ public: static int UpdateOne( Database& db, - TributeLevels tribute_levels_entry + const TributeLevels &e ) { - std::vector update_values; + std::vector v; auto columns = Columns(); - update_values.push_back(columns[0] + " = " + std::to_string(tribute_levels_entry.tribute_id)); - update_values.push_back(columns[1] + " = " + std::to_string(tribute_levels_entry.level)); - update_values.push_back(columns[2] + " = " + std::to_string(tribute_levels_entry.cost)); - update_values.push_back(columns[3] + " = " + std::to_string(tribute_levels_entry.item_id)); + v.push_back(columns[0] + " = " + std::to_string(e.tribute_id)); + v.push_back(columns[1] + " = " + std::to_string(e.level)); + v.push_back(columns[2] + " = " + std::to_string(e.cost)); + v.push_back(columns[3] + " = " + std::to_string(e.item_id)); auto results = db.QueryDatabase( fmt::format( "UPDATE {} SET {} WHERE {} = {}", TableName(), - Strings::Implode(", ", update_values), + Strings::Implode(", ", v), PrimaryKey(), - tribute_levels_entry.tribute_id + e.tribute_id ) ); @@ -183,53 +183,53 @@ public: static TributeLevels InsertOne( Database& db, - TributeLevels tribute_levels_entry + TributeLevels e ) { - std::vector insert_values; + std::vector v; - insert_values.push_back(std::to_string(tribute_levels_entry.tribute_id)); - insert_values.push_back(std::to_string(tribute_levels_entry.level)); - insert_values.push_back(std::to_string(tribute_levels_entry.cost)); - insert_values.push_back(std::to_string(tribute_levels_entry.item_id)); + v.push_back(std::to_string(e.tribute_id)); + v.push_back(std::to_string(e.level)); + v.push_back(std::to_string(e.cost)); + v.push_back(std::to_string(e.item_id)); auto results = db.QueryDatabase( fmt::format( "{} VALUES ({})", BaseInsert(), - Strings::Implode(",", insert_values) + Strings::Implode(",", v) ) ); if (results.Success()) { - tribute_levels_entry.tribute_id = results.LastInsertedID(); - return tribute_levels_entry; + e.tribute_id = results.LastInsertedID(); + return e; } - tribute_levels_entry = NewEntity(); + e = NewEntity(); - return tribute_levels_entry; + return e; } static int InsertMany( Database& db, - std::vector tribute_levels_entries + const std::vector &entries ) { std::vector insert_chunks; - for (auto &tribute_levels_entry: tribute_levels_entries) { - std::vector insert_values; + for (auto &e: entries) { + std::vector v; - insert_values.push_back(std::to_string(tribute_levels_entry.tribute_id)); - insert_values.push_back(std::to_string(tribute_levels_entry.level)); - insert_values.push_back(std::to_string(tribute_levels_entry.cost)); - insert_values.push_back(std::to_string(tribute_levels_entry.item_id)); + v.push_back(std::to_string(e.tribute_id)); + v.push_back(std::to_string(e.level)); + v.push_back(std::to_string(e.cost)); + v.push_back(std::to_string(e.item_id)); - insert_chunks.push_back("(" + Strings::Implode(",", insert_values) + ")"); + insert_chunks.push_back("(" + Strings::Implode(",", v) + ")"); } - std::vector insert_values; + std::vector v; auto results = db.QueryDatabase( fmt::format( @@ -256,20 +256,20 @@ public: all_entries.reserve(results.RowCount()); for (auto row = results.begin(); row != results.end(); ++row) { - TributeLevels entry{}; + TributeLevels e{}; - entry.tribute_id = atoi(row[0]); - entry.level = atoi(row[1]); - entry.cost = atoi(row[2]); - entry.item_id = atoi(row[3]); + e.tribute_id = atoi(row[0]); + e.level = atoi(row[1]); + e.cost = atoi(row[2]); + e.item_id = atoi(row[3]); - all_entries.push_back(entry); + all_entries.push_back(e); } return all_entries; } - static std::vector GetWhere(Database& db, std::string where_filter) + static std::vector GetWhere(Database& db, const std::string &where_filter) { std::vector all_entries; @@ -284,20 +284,20 @@ public: all_entries.reserve(results.RowCount()); for (auto row = results.begin(); row != results.end(); ++row) { - TributeLevels entry{}; + TributeLevels e{}; - entry.tribute_id = atoi(row[0]); - entry.level = atoi(row[1]); - entry.cost = atoi(row[2]); - entry.item_id = atoi(row[3]); + e.tribute_id = atoi(row[0]); + e.level = atoi(row[1]); + e.cost = atoi(row[2]); + e.item_id = atoi(row[3]); - all_entries.push_back(entry); + all_entries.push_back(e); } return all_entries; } - static int DeleteWhere(Database& db, std::string where_filter) + static int DeleteWhere(Database& db, const std::string &where_filter) { auto results = db.QueryDatabase( fmt::format( @@ -322,6 +322,32 @@ public: 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); + } + }; #endif //EQEMU_BASE_TRIBUTE_LEVELS_REPOSITORY_H diff --git a/common/repositories/base/base_tributes_repository.h b/common/repositories/base/base_tributes_repository.h index 57bc4dd37..bddf9c63a 100644 --- a/common/repositories/base/base_tributes_repository.h +++ b/common/repositories/base/base_tributes_repository.h @@ -88,18 +88,18 @@ public: static Tributes NewEntity() { - Tributes entry{}; + Tributes e{}; - entry.id = 0; - entry.unknown = 0; - entry.name = ""; - entry.descr = ""; - entry.isguild = 0; + e.id = 0; + e.unknown = 0; + e.name = ""; + e.descr = ""; + e.isguild = 0; - return entry; + return e; } - static Tributes GetTributesEntry( + static Tributes GetTributes( const std::vector &tributess, int tributes_id ) @@ -128,15 +128,15 @@ public: auto row = results.begin(); if (results.RowCount() == 1) { - Tributes entry{}; + Tributes e{}; - entry.id = atoi(row[0]); - entry.unknown = atoi(row[1]); - entry.name = row[2] ? row[2] : ""; - entry.descr = row[3] ? row[3] : ""; - entry.isguild = atoi(row[4]); + e.id = atoi(row[0]); + e.unknown = atoi(row[1]); + e.name = row[2] ? row[2] : ""; + e.descr = row[3] ? row[3] : ""; + e.isguild = atoi(row[4]); - return entry; + return e; } return NewEntity(); @@ -161,26 +161,26 @@ public: static int UpdateOne( Database& db, - Tributes tributes_entry + const Tributes &e ) { - std::vector update_values; + std::vector v; auto columns = Columns(); - update_values.push_back(columns[0] + " = " + std::to_string(tributes_entry.id)); - update_values.push_back(columns[1] + " = " + std::to_string(tributes_entry.unknown)); - update_values.push_back(columns[2] + " = '" + Strings::Escape(tributes_entry.name) + "'"); - update_values.push_back(columns[3] + " = '" + Strings::Escape(tributes_entry.descr) + "'"); - update_values.push_back(columns[4] + " = " + std::to_string(tributes_entry.isguild)); + v.push_back(columns[0] + " = " + std::to_string(e.id)); + v.push_back(columns[1] + " = " + std::to_string(e.unknown)); + v.push_back(columns[2] + " = '" + Strings::Escape(e.name) + "'"); + v.push_back(columns[3] + " = '" + Strings::Escape(e.descr) + "'"); + v.push_back(columns[4] + " = " + std::to_string(e.isguild)); auto results = db.QueryDatabase( fmt::format( "UPDATE {} SET {} WHERE {} = {}", TableName(), - Strings::Implode(", ", update_values), + Strings::Implode(", ", v), PrimaryKey(), - tributes_entry.id + e.id ) ); @@ -189,55 +189,55 @@ public: static Tributes InsertOne( Database& db, - Tributes tributes_entry + Tributes e ) { - std::vector insert_values; + std::vector v; - insert_values.push_back(std::to_string(tributes_entry.id)); - insert_values.push_back(std::to_string(tributes_entry.unknown)); - insert_values.push_back("'" + Strings::Escape(tributes_entry.name) + "'"); - insert_values.push_back("'" + Strings::Escape(tributes_entry.descr) + "'"); - insert_values.push_back(std::to_string(tributes_entry.isguild)); + v.push_back(std::to_string(e.id)); + v.push_back(std::to_string(e.unknown)); + v.push_back("'" + Strings::Escape(e.name) + "'"); + v.push_back("'" + Strings::Escape(e.descr) + "'"); + v.push_back(std::to_string(e.isguild)); auto results = db.QueryDatabase( fmt::format( "{} VALUES ({})", BaseInsert(), - Strings::Implode(",", insert_values) + Strings::Implode(",", v) ) ); if (results.Success()) { - tributes_entry.id = results.LastInsertedID(); - return tributes_entry; + e.id = results.LastInsertedID(); + return e; } - tributes_entry = NewEntity(); + e = NewEntity(); - return tributes_entry; + return e; } static int InsertMany( Database& db, - std::vector tributes_entries + const std::vector &entries ) { std::vector insert_chunks; - for (auto &tributes_entry: tributes_entries) { - std::vector insert_values; + for (auto &e: entries) { + std::vector v; - insert_values.push_back(std::to_string(tributes_entry.id)); - insert_values.push_back(std::to_string(tributes_entry.unknown)); - insert_values.push_back("'" + Strings::Escape(tributes_entry.name) + "'"); - insert_values.push_back("'" + Strings::Escape(tributes_entry.descr) + "'"); - insert_values.push_back(std::to_string(tributes_entry.isguild)); + v.push_back(std::to_string(e.id)); + v.push_back(std::to_string(e.unknown)); + v.push_back("'" + Strings::Escape(e.name) + "'"); + v.push_back("'" + Strings::Escape(e.descr) + "'"); + v.push_back(std::to_string(e.isguild)); - insert_chunks.push_back("(" + Strings::Implode(",", insert_values) + ")"); + insert_chunks.push_back("(" + Strings::Implode(",", v) + ")"); } - std::vector insert_values; + std::vector v; auto results = db.QueryDatabase( fmt::format( @@ -264,21 +264,21 @@ public: all_entries.reserve(results.RowCount()); for (auto row = results.begin(); row != results.end(); ++row) { - Tributes entry{}; + Tributes e{}; - entry.id = atoi(row[0]); - entry.unknown = atoi(row[1]); - entry.name = row[2] ? row[2] : ""; - entry.descr = row[3] ? row[3] : ""; - entry.isguild = atoi(row[4]); + e.id = atoi(row[0]); + e.unknown = atoi(row[1]); + e.name = row[2] ? row[2] : ""; + e.descr = row[3] ? row[3] : ""; + e.isguild = atoi(row[4]); - all_entries.push_back(entry); + all_entries.push_back(e); } return all_entries; } - static std::vector GetWhere(Database& db, std::string where_filter) + static std::vector GetWhere(Database& db, const std::string &where_filter) { std::vector all_entries; @@ -293,21 +293,21 @@ public: all_entries.reserve(results.RowCount()); for (auto row = results.begin(); row != results.end(); ++row) { - Tributes entry{}; + Tributes e{}; - entry.id = atoi(row[0]); - entry.unknown = atoi(row[1]); - entry.name = row[2] ? row[2] : ""; - entry.descr = row[3] ? row[3] : ""; - entry.isguild = atoi(row[4]); + e.id = atoi(row[0]); + e.unknown = atoi(row[1]); + e.name = row[2] ? row[2] : ""; + e.descr = row[3] ? row[3] : ""; + e.isguild = atoi(row[4]); - all_entries.push_back(entry); + all_entries.push_back(e); } return all_entries; } - static int DeleteWhere(Database& db, std::string where_filter) + static int DeleteWhere(Database& db, const std::string &where_filter) { auto results = db.QueryDatabase( fmt::format( @@ -332,6 +332,32 @@ public: 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); + } + }; #endif //EQEMU_BASE_TRIBUTES_REPOSITORY_H diff --git a/common/repositories/base/base_variables_repository.h b/common/repositories/base/base_variables_repository.h index 7bbd2bd97..09facf31e 100644 --- a/common/repositories/base/base_variables_repository.h +++ b/common/repositories/base/base_variables_repository.h @@ -1,24 +1,3 @@ -/** - * EQEmulator: Everquest Server Emulator - * Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server) - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 2 of the License. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY except by those people which sell it, which - * are required to give you total support for your newly bought product; - * without even the implied warranty of MERCHANTABILITY or FITNESS FOR - * A PARTICULAR PURPOSE. See the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - * - */ - /** * This repository was automatically generated and is NOT to be modified directly. * Any repository modifications are meant to be made to diff --git a/common/repositories/base/base_veteran_reward_templates_repository.h b/common/repositories/base/base_veteran_reward_templates_repository.h index 97219a5b9..03db670e2 100644 --- a/common/repositories/base/base_veteran_reward_templates_repository.h +++ b/common/repositories/base/base_veteran_reward_templates_repository.h @@ -88,18 +88,18 @@ public: static VeteranRewardTemplates NewEntity() { - VeteranRewardTemplates entry{}; + VeteranRewardTemplates e{}; - entry.claim_id = 0; - entry.name = ""; - entry.item_id = 0; - entry.charges = 0; - entry.reward_slot = 0; + e.claim_id = 0; + e.name = ""; + e.item_id = 0; + e.charges = 0; + e.reward_slot = 0; - return entry; + return e; } - static VeteranRewardTemplates GetVeteranRewardTemplatesEntry( + static VeteranRewardTemplates GetVeteranRewardTemplates( const std::vector &veteran_reward_templatess, int veteran_reward_templates_id ) @@ -128,15 +128,15 @@ public: auto row = results.begin(); if (results.RowCount() == 1) { - VeteranRewardTemplates entry{}; + VeteranRewardTemplates e{}; - entry.claim_id = atoi(row[0]); - entry.name = row[1] ? row[1] : ""; - entry.item_id = atoi(row[2]); - entry.charges = atoi(row[3]); - entry.reward_slot = atoi(row[4]); + e.claim_id = atoi(row[0]); + e.name = row[1] ? row[1] : ""; + e.item_id = atoi(row[2]); + e.charges = atoi(row[3]); + e.reward_slot = atoi(row[4]); - return entry; + return e; } return NewEntity(); @@ -161,26 +161,26 @@ public: static int UpdateOne( Database& db, - VeteranRewardTemplates veteran_reward_templates_entry + const VeteranRewardTemplates &e ) { - std::vector update_values; + std::vector v; auto columns = Columns(); - update_values.push_back(columns[0] + " = " + std::to_string(veteran_reward_templates_entry.claim_id)); - update_values.push_back(columns[1] + " = '" + Strings::Escape(veteran_reward_templates_entry.name) + "'"); - update_values.push_back(columns[2] + " = " + std::to_string(veteran_reward_templates_entry.item_id)); - update_values.push_back(columns[3] + " = " + std::to_string(veteran_reward_templates_entry.charges)); - update_values.push_back(columns[4] + " = " + std::to_string(veteran_reward_templates_entry.reward_slot)); + v.push_back(columns[0] + " = " + std::to_string(e.claim_id)); + v.push_back(columns[1] + " = '" + Strings::Escape(e.name) + "'"); + 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.reward_slot)); auto results = db.QueryDatabase( fmt::format( "UPDATE {} SET {} WHERE {} = {}", TableName(), - Strings::Implode(", ", update_values), + Strings::Implode(", ", v), PrimaryKey(), - veteran_reward_templates_entry.claim_id + e.claim_id ) ); @@ -189,55 +189,55 @@ public: static VeteranRewardTemplates InsertOne( Database& db, - VeteranRewardTemplates veteran_reward_templates_entry + VeteranRewardTemplates e ) { - std::vector insert_values; + std::vector v; - insert_values.push_back(std::to_string(veteran_reward_templates_entry.claim_id)); - insert_values.push_back("'" + Strings::Escape(veteran_reward_templates_entry.name) + "'"); - insert_values.push_back(std::to_string(veteran_reward_templates_entry.item_id)); - insert_values.push_back(std::to_string(veteran_reward_templates_entry.charges)); - insert_values.push_back(std::to_string(veteran_reward_templates_entry.reward_slot)); + v.push_back(std::to_string(e.claim_id)); + v.push_back("'" + Strings::Escape(e.name) + "'"); + v.push_back(std::to_string(e.item_id)); + v.push_back(std::to_string(e.charges)); + v.push_back(std::to_string(e.reward_slot)); auto results = db.QueryDatabase( fmt::format( "{} VALUES ({})", BaseInsert(), - Strings::Implode(",", insert_values) + Strings::Implode(",", v) ) ); if (results.Success()) { - veteran_reward_templates_entry.claim_id = results.LastInsertedID(); - return veteran_reward_templates_entry; + e.claim_id = results.LastInsertedID(); + return e; } - veteran_reward_templates_entry = NewEntity(); + e = NewEntity(); - return veteran_reward_templates_entry; + return e; } static int InsertMany( Database& db, - std::vector veteran_reward_templates_entries + const std::vector &entries ) { std::vector insert_chunks; - for (auto &veteran_reward_templates_entry: veteran_reward_templates_entries) { - std::vector insert_values; + for (auto &e: entries) { + std::vector v; - insert_values.push_back(std::to_string(veteran_reward_templates_entry.claim_id)); - insert_values.push_back("'" + Strings::Escape(veteran_reward_templates_entry.name) + "'"); - insert_values.push_back(std::to_string(veteran_reward_templates_entry.item_id)); - insert_values.push_back(std::to_string(veteran_reward_templates_entry.charges)); - insert_values.push_back(std::to_string(veteran_reward_templates_entry.reward_slot)); + v.push_back(std::to_string(e.claim_id)); + v.push_back("'" + Strings::Escape(e.name) + "'"); + v.push_back(std::to_string(e.item_id)); + v.push_back(std::to_string(e.charges)); + v.push_back(std::to_string(e.reward_slot)); - insert_chunks.push_back("(" + Strings::Implode(",", insert_values) + ")"); + insert_chunks.push_back("(" + Strings::Implode(",", v) + ")"); } - std::vector insert_values; + std::vector v; auto results = db.QueryDatabase( fmt::format( @@ -264,21 +264,21 @@ public: all_entries.reserve(results.RowCount()); for (auto row = results.begin(); row != results.end(); ++row) { - VeteranRewardTemplates entry{}; + VeteranRewardTemplates e{}; - entry.claim_id = atoi(row[0]); - entry.name = row[1] ? row[1] : ""; - entry.item_id = atoi(row[2]); - entry.charges = atoi(row[3]); - entry.reward_slot = atoi(row[4]); + e.claim_id = atoi(row[0]); + e.name = row[1] ? row[1] : ""; + e.item_id = atoi(row[2]); + e.charges = atoi(row[3]); + e.reward_slot = atoi(row[4]); - all_entries.push_back(entry); + all_entries.push_back(e); } return all_entries; } - static std::vector GetWhere(Database& db, std::string where_filter) + static std::vector GetWhere(Database& db, const std::string &where_filter) { std::vector all_entries; @@ -293,21 +293,21 @@ public: all_entries.reserve(results.RowCount()); for (auto row = results.begin(); row != results.end(); ++row) { - VeteranRewardTemplates entry{}; + VeteranRewardTemplates e{}; - entry.claim_id = atoi(row[0]); - entry.name = row[1] ? row[1] : ""; - entry.item_id = atoi(row[2]); - entry.charges = atoi(row[3]); - entry.reward_slot = atoi(row[4]); + e.claim_id = atoi(row[0]); + e.name = row[1] ? row[1] : ""; + e.item_id = atoi(row[2]); + e.charges = atoi(row[3]); + e.reward_slot = atoi(row[4]); - all_entries.push_back(entry); + all_entries.push_back(e); } return all_entries; } - static int DeleteWhere(Database& db, std::string where_filter) + static int DeleteWhere(Database& db, const std::string &where_filter) { auto results = db.QueryDatabase( fmt::format( @@ -332,6 +332,32 @@ public: 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); + } + }; #endif //EQEMU_BASE_VETERAN_REWARD_TEMPLATES_REPOSITORY_H diff --git a/common/repositories/base/base_zone_points_repository.h b/common/repositories/base/base_zone_points_repository.h index a8d35b647..b227ce562 100644 --- a/common/repositories/base/base_zone_points_repository.h +++ b/common/repositories/base/base_zone_points_repository.h @@ -145,37 +145,37 @@ public: static ZonePoints NewEntity() { - ZonePoints entry{}; + ZonePoints e{}; - entry.id = 0; - entry.zone = ""; - entry.version = 0; - entry.number = 1; - entry.y = 0; - entry.x = 0; - entry.z = 0; - entry.heading = 0; - entry.target_y = 0; - entry.target_x = 0; - entry.target_z = 0; - entry.target_heading = 0; - entry.zoneinst = 0; - entry.target_zone_id = 0; - entry.target_instance = 0; - entry.buffer = 0; - entry.client_version_mask = 4294967295; - entry.min_expansion = -1; - entry.max_expansion = -1; - entry.content_flags = ""; - entry.content_flags_disabled = ""; - entry.is_virtual = 0; - entry.height = 0; - entry.width = 0; + e.id = 0; + e.zone = ""; + e.version = 0; + e.number = 1; + e.y = 0; + e.x = 0; + e.z = 0; + e.heading = 0; + e.target_y = 0; + e.target_x = 0; + e.target_z = 0; + e.target_heading = 0; + e.zoneinst = 0; + e.target_zone_id = 0; + e.target_instance = 0; + e.buffer = 0; + e.client_version_mask = 4294967295; + e.min_expansion = -1; + e.max_expansion = -1; + e.content_flags = ""; + e.content_flags_disabled = ""; + e.is_virtual = 0; + e.height = 0; + e.width = 0; - return entry; + return e; } - static ZonePoints GetZonePointsEntry( + static ZonePoints GetZonePoints( const std::vector &zone_pointss, int zone_points_id ) @@ -204,34 +204,34 @@ public: auto row = results.begin(); if (results.RowCount() == 1) { - ZonePoints entry{}; + ZonePoints e{}; - entry.id = atoi(row[0]); - entry.zone = row[1] ? row[1] : ""; - entry.version = atoi(row[2]); - entry.number = atoi(row[3]); - entry.y = static_cast(atof(row[4])); - entry.x = static_cast(atof(row[5])); - entry.z = static_cast(atof(row[6])); - entry.heading = static_cast(atof(row[7])); - entry.target_y = static_cast(atof(row[8])); - entry.target_x = static_cast(atof(row[9])); - entry.target_z = static_cast(atof(row[10])); - entry.target_heading = static_cast(atof(row[11])); - entry.zoneinst = atoi(row[12]); - entry.target_zone_id = atoi(row[13]); - entry.target_instance = atoi(row[14]); - entry.buffer = static_cast(atof(row[15])); - entry.client_version_mask = atoi(row[16]); - entry.min_expansion = atoi(row[17]); - entry.max_expansion = atoi(row[18]); - entry.content_flags = row[19] ? row[19] : ""; - entry.content_flags_disabled = row[20] ? row[20] : ""; - entry.is_virtual = atoi(row[21]); - entry.height = atoi(row[22]); - entry.width = atoi(row[23]); + e.id = atoi(row[0]); + e.zone = row[1] ? row[1] : ""; + e.version = atoi(row[2]); + e.number = atoi(row[3]); + e.y = static_cast(atof(row[4])); + e.x = static_cast(atof(row[5])); + e.z = static_cast(atof(row[6])); + e.heading = static_cast(atof(row[7])); + e.target_y = static_cast(atof(row[8])); + e.target_x = static_cast(atof(row[9])); + e.target_z = static_cast(atof(row[10])); + e.target_heading = static_cast(atof(row[11])); + e.zoneinst = atoi(row[12]); + e.target_zone_id = atoi(row[13]); + e.target_instance = atoi(row[14]); + e.buffer = static_cast(atof(row[15])); + e.client_version_mask = atoi(row[16]); + e.min_expansion = atoi(row[17]); + e.max_expansion = atoi(row[18]); + e.content_flags = row[19] ? row[19] : ""; + e.content_flags_disabled = row[20] ? row[20] : ""; + e.is_virtual = atoi(row[21]); + e.height = atoi(row[22]); + e.width = atoi(row[23]); - return entry; + return e; } return NewEntity(); @@ -256,44 +256,44 @@ public: static int UpdateOne( Database& db, - ZonePoints zone_points_entry + const ZonePoints &e ) { - std::vector update_values; + std::vector v; auto columns = Columns(); - update_values.push_back(columns[1] + " = '" + Strings::Escape(zone_points_entry.zone) + "'"); - update_values.push_back(columns[2] + " = " + std::to_string(zone_points_entry.version)); - update_values.push_back(columns[3] + " = " + std::to_string(zone_points_entry.number)); - update_values.push_back(columns[4] + " = " + std::to_string(zone_points_entry.y)); - update_values.push_back(columns[5] + " = " + std::to_string(zone_points_entry.x)); - update_values.push_back(columns[6] + " = " + std::to_string(zone_points_entry.z)); - update_values.push_back(columns[7] + " = " + std::to_string(zone_points_entry.heading)); - update_values.push_back(columns[8] + " = " + std::to_string(zone_points_entry.target_y)); - update_values.push_back(columns[9] + " = " + std::to_string(zone_points_entry.target_x)); - update_values.push_back(columns[10] + " = " + std::to_string(zone_points_entry.target_z)); - update_values.push_back(columns[11] + " = " + std::to_string(zone_points_entry.target_heading)); - update_values.push_back(columns[12] + " = " + std::to_string(zone_points_entry.zoneinst)); - update_values.push_back(columns[13] + " = " + std::to_string(zone_points_entry.target_zone_id)); - update_values.push_back(columns[14] + " = " + std::to_string(zone_points_entry.target_instance)); - update_values.push_back(columns[15] + " = " + std::to_string(zone_points_entry.buffer)); - update_values.push_back(columns[16] + " = " + std::to_string(zone_points_entry.client_version_mask)); - update_values.push_back(columns[17] + " = " + std::to_string(zone_points_entry.min_expansion)); - update_values.push_back(columns[18] + " = " + std::to_string(zone_points_entry.max_expansion)); - update_values.push_back(columns[19] + " = '" + Strings::Escape(zone_points_entry.content_flags) + "'"); - update_values.push_back(columns[20] + " = '" + Strings::Escape(zone_points_entry.content_flags_disabled) + "'"); - update_values.push_back(columns[21] + " = " + std::to_string(zone_points_entry.is_virtual)); - update_values.push_back(columns[22] + " = " + std::to_string(zone_points_entry.height)); - update_values.push_back(columns[23] + " = " + std::to_string(zone_points_entry.width)); + v.push_back(columns[1] + " = '" + Strings::Escape(e.zone) + "'"); + v.push_back(columns[2] + " = " + std::to_string(e.version)); + v.push_back(columns[3] + " = " + std::to_string(e.number)); + v.push_back(columns[4] + " = " + std::to_string(e.y)); + v.push_back(columns[5] + " = " + std::to_string(e.x)); + v.push_back(columns[6] + " = " + std::to_string(e.z)); + v.push_back(columns[7] + " = " + std::to_string(e.heading)); + v.push_back(columns[8] + " = " + std::to_string(e.target_y)); + v.push_back(columns[9] + " = " + std::to_string(e.target_x)); + v.push_back(columns[10] + " = " + std::to_string(e.target_z)); + v.push_back(columns[11] + " = " + std::to_string(e.target_heading)); + v.push_back(columns[12] + " = " + std::to_string(e.zoneinst)); + v.push_back(columns[13] + " = " + std::to_string(e.target_zone_id)); + v.push_back(columns[14] + " = " + std::to_string(e.target_instance)); + v.push_back(columns[15] + " = " + std::to_string(e.buffer)); + v.push_back(columns[16] + " = " + std::to_string(e.client_version_mask)); + v.push_back(columns[17] + " = " + std::to_string(e.min_expansion)); + v.push_back(columns[18] + " = " + std::to_string(e.max_expansion)); + v.push_back(columns[19] + " = '" + Strings::Escape(e.content_flags) + "'"); + v.push_back(columns[20] + " = '" + Strings::Escape(e.content_flags_disabled) + "'"); + v.push_back(columns[21] + " = " + std::to_string(e.is_virtual)); + v.push_back(columns[22] + " = " + std::to_string(e.height)); + v.push_back(columns[23] + " = " + std::to_string(e.width)); auto results = db.QueryDatabase( fmt::format( "UPDATE {} SET {} WHERE {} = {}", TableName(), - Strings::Implode(", ", update_values), + Strings::Implode(", ", v), PrimaryKey(), - zone_points_entry.id + e.id ) ); @@ -302,93 +302,93 @@ public: static ZonePoints InsertOne( Database& db, - ZonePoints zone_points_entry + ZonePoints e ) { - std::vector insert_values; + std::vector v; - insert_values.push_back(std::to_string(zone_points_entry.id)); - insert_values.push_back("'" + Strings::Escape(zone_points_entry.zone) + "'"); - insert_values.push_back(std::to_string(zone_points_entry.version)); - insert_values.push_back(std::to_string(zone_points_entry.number)); - insert_values.push_back(std::to_string(zone_points_entry.y)); - insert_values.push_back(std::to_string(zone_points_entry.x)); - insert_values.push_back(std::to_string(zone_points_entry.z)); - insert_values.push_back(std::to_string(zone_points_entry.heading)); - insert_values.push_back(std::to_string(zone_points_entry.target_y)); - insert_values.push_back(std::to_string(zone_points_entry.target_x)); - insert_values.push_back(std::to_string(zone_points_entry.target_z)); - insert_values.push_back(std::to_string(zone_points_entry.target_heading)); - insert_values.push_back(std::to_string(zone_points_entry.zoneinst)); - insert_values.push_back(std::to_string(zone_points_entry.target_zone_id)); - insert_values.push_back(std::to_string(zone_points_entry.target_instance)); - insert_values.push_back(std::to_string(zone_points_entry.buffer)); - insert_values.push_back(std::to_string(zone_points_entry.client_version_mask)); - insert_values.push_back(std::to_string(zone_points_entry.min_expansion)); - insert_values.push_back(std::to_string(zone_points_entry.max_expansion)); - insert_values.push_back("'" + Strings::Escape(zone_points_entry.content_flags) + "'"); - insert_values.push_back("'" + Strings::Escape(zone_points_entry.content_flags_disabled) + "'"); - insert_values.push_back(std::to_string(zone_points_entry.is_virtual)); - insert_values.push_back(std::to_string(zone_points_entry.height)); - insert_values.push_back(std::to_string(zone_points_entry.width)); + v.push_back(std::to_string(e.id)); + v.push_back("'" + Strings::Escape(e.zone) + "'"); + v.push_back(std::to_string(e.version)); + v.push_back(std::to_string(e.number)); + v.push_back(std::to_string(e.y)); + v.push_back(std::to_string(e.x)); + v.push_back(std::to_string(e.z)); + v.push_back(std::to_string(e.heading)); + v.push_back(std::to_string(e.target_y)); + v.push_back(std::to_string(e.target_x)); + v.push_back(std::to_string(e.target_z)); + v.push_back(std::to_string(e.target_heading)); + v.push_back(std::to_string(e.zoneinst)); + v.push_back(std::to_string(e.target_zone_id)); + v.push_back(std::to_string(e.target_instance)); + v.push_back(std::to_string(e.buffer)); + v.push_back(std::to_string(e.client_version_mask)); + v.push_back(std::to_string(e.min_expansion)); + v.push_back(std::to_string(e.max_expansion)); + v.push_back("'" + Strings::Escape(e.content_flags) + "'"); + v.push_back("'" + Strings::Escape(e.content_flags_disabled) + "'"); + v.push_back(std::to_string(e.is_virtual)); + v.push_back(std::to_string(e.height)); + v.push_back(std::to_string(e.width)); auto results = db.QueryDatabase( fmt::format( "{} VALUES ({})", BaseInsert(), - Strings::Implode(",", insert_values) + Strings::Implode(",", v) ) ); if (results.Success()) { - zone_points_entry.id = results.LastInsertedID(); - return zone_points_entry; + e.id = results.LastInsertedID(); + return e; } - zone_points_entry = NewEntity(); + e = NewEntity(); - return zone_points_entry; + return e; } static int InsertMany( Database& db, - std::vector zone_points_entries + const std::vector &entries ) { std::vector insert_chunks; - for (auto &zone_points_entry: zone_points_entries) { - std::vector insert_values; + for (auto &e: entries) { + std::vector v; - insert_values.push_back(std::to_string(zone_points_entry.id)); - insert_values.push_back("'" + Strings::Escape(zone_points_entry.zone) + "'"); - insert_values.push_back(std::to_string(zone_points_entry.version)); - insert_values.push_back(std::to_string(zone_points_entry.number)); - insert_values.push_back(std::to_string(zone_points_entry.y)); - insert_values.push_back(std::to_string(zone_points_entry.x)); - insert_values.push_back(std::to_string(zone_points_entry.z)); - insert_values.push_back(std::to_string(zone_points_entry.heading)); - insert_values.push_back(std::to_string(zone_points_entry.target_y)); - insert_values.push_back(std::to_string(zone_points_entry.target_x)); - insert_values.push_back(std::to_string(zone_points_entry.target_z)); - insert_values.push_back(std::to_string(zone_points_entry.target_heading)); - insert_values.push_back(std::to_string(zone_points_entry.zoneinst)); - insert_values.push_back(std::to_string(zone_points_entry.target_zone_id)); - insert_values.push_back(std::to_string(zone_points_entry.target_instance)); - insert_values.push_back(std::to_string(zone_points_entry.buffer)); - insert_values.push_back(std::to_string(zone_points_entry.client_version_mask)); - insert_values.push_back(std::to_string(zone_points_entry.min_expansion)); - insert_values.push_back(std::to_string(zone_points_entry.max_expansion)); - insert_values.push_back("'" + Strings::Escape(zone_points_entry.content_flags) + "'"); - insert_values.push_back("'" + Strings::Escape(zone_points_entry.content_flags_disabled) + "'"); - insert_values.push_back(std::to_string(zone_points_entry.is_virtual)); - insert_values.push_back(std::to_string(zone_points_entry.height)); - insert_values.push_back(std::to_string(zone_points_entry.width)); + v.push_back(std::to_string(e.id)); + v.push_back("'" + Strings::Escape(e.zone) + "'"); + v.push_back(std::to_string(e.version)); + v.push_back(std::to_string(e.number)); + v.push_back(std::to_string(e.y)); + v.push_back(std::to_string(e.x)); + v.push_back(std::to_string(e.z)); + v.push_back(std::to_string(e.heading)); + v.push_back(std::to_string(e.target_y)); + v.push_back(std::to_string(e.target_x)); + v.push_back(std::to_string(e.target_z)); + v.push_back(std::to_string(e.target_heading)); + v.push_back(std::to_string(e.zoneinst)); + v.push_back(std::to_string(e.target_zone_id)); + v.push_back(std::to_string(e.target_instance)); + v.push_back(std::to_string(e.buffer)); + v.push_back(std::to_string(e.client_version_mask)); + v.push_back(std::to_string(e.min_expansion)); + v.push_back(std::to_string(e.max_expansion)); + v.push_back("'" + Strings::Escape(e.content_flags) + "'"); + v.push_back("'" + Strings::Escape(e.content_flags_disabled) + "'"); + v.push_back(std::to_string(e.is_virtual)); + v.push_back(std::to_string(e.height)); + v.push_back(std::to_string(e.width)); - insert_chunks.push_back("(" + Strings::Implode(",", insert_values) + ")"); + insert_chunks.push_back("(" + Strings::Implode(",", v) + ")"); } - std::vector insert_values; + std::vector v; auto results = db.QueryDatabase( fmt::format( @@ -415,40 +415,40 @@ public: all_entries.reserve(results.RowCount()); for (auto row = results.begin(); row != results.end(); ++row) { - ZonePoints entry{}; + ZonePoints e{}; - entry.id = atoi(row[0]); - entry.zone = row[1] ? row[1] : ""; - entry.version = atoi(row[2]); - entry.number = atoi(row[3]); - entry.y = static_cast(atof(row[4])); - entry.x = static_cast(atof(row[5])); - entry.z = static_cast(atof(row[6])); - entry.heading = static_cast(atof(row[7])); - entry.target_y = static_cast(atof(row[8])); - entry.target_x = static_cast(atof(row[9])); - entry.target_z = static_cast(atof(row[10])); - entry.target_heading = static_cast(atof(row[11])); - entry.zoneinst = atoi(row[12]); - entry.target_zone_id = atoi(row[13]); - entry.target_instance = atoi(row[14]); - entry.buffer = static_cast(atof(row[15])); - entry.client_version_mask = atoi(row[16]); - entry.min_expansion = atoi(row[17]); - entry.max_expansion = atoi(row[18]); - entry.content_flags = row[19] ? row[19] : ""; - entry.content_flags_disabled = row[20] ? row[20] : ""; - entry.is_virtual = atoi(row[21]); - entry.height = atoi(row[22]); - entry.width = atoi(row[23]); + e.id = atoi(row[0]); + e.zone = row[1] ? row[1] : ""; + e.version = atoi(row[2]); + e.number = atoi(row[3]); + e.y = static_cast(atof(row[4])); + e.x = static_cast(atof(row[5])); + e.z = static_cast(atof(row[6])); + e.heading = static_cast(atof(row[7])); + e.target_y = static_cast(atof(row[8])); + e.target_x = static_cast(atof(row[9])); + e.target_z = static_cast(atof(row[10])); + e.target_heading = static_cast(atof(row[11])); + e.zoneinst = atoi(row[12]); + e.target_zone_id = atoi(row[13]); + e.target_instance = atoi(row[14]); + e.buffer = static_cast(atof(row[15])); + e.client_version_mask = atoi(row[16]); + e.min_expansion = atoi(row[17]); + e.max_expansion = atoi(row[18]); + e.content_flags = row[19] ? row[19] : ""; + e.content_flags_disabled = row[20] ? row[20] : ""; + e.is_virtual = atoi(row[21]); + e.height = atoi(row[22]); + e.width = atoi(row[23]); - all_entries.push_back(entry); + all_entries.push_back(e); } return all_entries; } - static std::vector GetWhere(Database& db, std::string where_filter) + static std::vector GetWhere(Database& db, const std::string &where_filter) { std::vector all_entries; @@ -463,40 +463,40 @@ public: all_entries.reserve(results.RowCount()); for (auto row = results.begin(); row != results.end(); ++row) { - ZonePoints entry{}; + ZonePoints e{}; - entry.id = atoi(row[0]); - entry.zone = row[1] ? row[1] : ""; - entry.version = atoi(row[2]); - entry.number = atoi(row[3]); - entry.y = static_cast(atof(row[4])); - entry.x = static_cast(atof(row[5])); - entry.z = static_cast(atof(row[6])); - entry.heading = static_cast(atof(row[7])); - entry.target_y = static_cast(atof(row[8])); - entry.target_x = static_cast(atof(row[9])); - entry.target_z = static_cast(atof(row[10])); - entry.target_heading = static_cast(atof(row[11])); - entry.zoneinst = atoi(row[12]); - entry.target_zone_id = atoi(row[13]); - entry.target_instance = atoi(row[14]); - entry.buffer = static_cast(atof(row[15])); - entry.client_version_mask = atoi(row[16]); - entry.min_expansion = atoi(row[17]); - entry.max_expansion = atoi(row[18]); - entry.content_flags = row[19] ? row[19] : ""; - entry.content_flags_disabled = row[20] ? row[20] : ""; - entry.is_virtual = atoi(row[21]); - entry.height = atoi(row[22]); - entry.width = atoi(row[23]); + e.id = atoi(row[0]); + e.zone = row[1] ? row[1] : ""; + e.version = atoi(row[2]); + e.number = atoi(row[3]); + e.y = static_cast(atof(row[4])); + e.x = static_cast(atof(row[5])); + e.z = static_cast(atof(row[6])); + e.heading = static_cast(atof(row[7])); + e.target_y = static_cast(atof(row[8])); + e.target_x = static_cast(atof(row[9])); + e.target_z = static_cast(atof(row[10])); + e.target_heading = static_cast(atof(row[11])); + e.zoneinst = atoi(row[12]); + e.target_zone_id = atoi(row[13]); + e.target_instance = atoi(row[14]); + e.buffer = static_cast(atof(row[15])); + e.client_version_mask = atoi(row[16]); + e.min_expansion = atoi(row[17]); + e.max_expansion = atoi(row[18]); + e.content_flags = row[19] ? row[19] : ""; + e.content_flags_disabled = row[20] ? row[20] : ""; + e.is_virtual = atoi(row[21]); + e.height = atoi(row[22]); + e.width = atoi(row[23]); - all_entries.push_back(entry); + all_entries.push_back(e); } return all_entries; } - static int DeleteWhere(Database& db, std::string where_filter) + static int DeleteWhere(Database& db, const std::string &where_filter) { auto results = db.QueryDatabase( fmt::format( @@ -521,6 +521,32 @@ public: 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); + } + }; #endif //EQEMU_BASE_ZONE_POINTS_REPOSITORY_H diff --git a/common/repositories/base/base_zone_repository.h b/common/repositories/base/base_zone_repository.h index 66fb1a01e..9ed28002f 100644 --- a/common/repositories/base/base_zone_repository.h +++ b/common/repositories/base/base_zone_repository.h @@ -355,107 +355,107 @@ public: static Zone NewEntity() { - Zone entry{}; + Zone e{}; - entry.short_name = ""; - entry.id = 0; - entry.file_name = ""; - entry.long_name = ""; - entry.map_file_name = ""; - entry.safe_x = 0; - entry.safe_y = 0; - entry.safe_z = 0; - entry.safe_heading = 0; - entry.graveyard_id = 0; - entry.min_level = 0; - entry.min_status = 0; - entry.zoneidnumber = 0; - entry.version = 0; - entry.timezone = 0; - entry.maxclients = 0; - entry.ruleset = 0; - entry.note = ""; - entry.underworld = 0; - entry.minclip = 450; - entry.maxclip = 450; - entry.fog_minclip = 450; - entry.fog_maxclip = 450; - entry.fog_blue = 0; - entry.fog_red = 0; - entry.fog_green = 0; - entry.sky = 1; - entry.ztype = 1; - entry.zone_exp_multiplier = 0.00; - entry.walkspeed = 0.4; - entry.time_type = 2; - entry.fog_red1 = 0; - entry.fog_green1 = 0; - entry.fog_blue1 = 0; - entry.fog_minclip1 = 450; - entry.fog_maxclip1 = 450; - entry.fog_red2 = 0; - entry.fog_green2 = 0; - entry.fog_blue2 = 0; - entry.fog_minclip2 = 450; - entry.fog_maxclip2 = 450; - entry.fog_red3 = 0; - entry.fog_green3 = 0; - entry.fog_blue3 = 0; - entry.fog_minclip3 = 450; - entry.fog_maxclip3 = 450; - entry.fog_red4 = 0; - entry.fog_green4 = 0; - entry.fog_blue4 = 0; - entry.fog_minclip4 = 450; - entry.fog_maxclip4 = 450; - entry.fog_density = 0; - entry.flag_needed = ""; - entry.canbind = 1; - entry.cancombat = 1; - entry.canlevitate = 1; - entry.castoutdoor = 1; - entry.hotzone = 0; - entry.insttype = 0; - entry.shutdowndelay = 5000; - entry.peqzone = 1; - entry.suspendbuffs = 0; - entry.rain_chance1 = 0; - entry.rain_chance2 = 0; - entry.rain_chance3 = 0; - entry.rain_chance4 = 0; - entry.rain_duration1 = 0; - entry.rain_duration2 = 0; - entry.rain_duration3 = 0; - entry.rain_duration4 = 0; - entry.snow_chance1 = 0; - entry.snow_chance2 = 0; - entry.snow_chance3 = 0; - entry.snow_chance4 = 0; - entry.snow_duration1 = 0; - entry.snow_duration2 = 0; - entry.snow_duration3 = 0; - entry.snow_duration4 = 0; - entry.gravity = 0.4; - entry.type = 0; - entry.skylock = 0; - entry.fast_regen_hp = 180; - entry.fast_regen_mana = 180; - entry.fast_regen_endurance = 180; - entry.npc_max_aggro_dist = 600; - entry.max_movement_update_range = 600; - entry.min_expansion = -1; - entry.max_expansion = -1; - entry.content_flags = ""; - entry.content_flags_disabled = ""; - entry.underworld_teleport_index = 0; - entry.lava_damage = 50; - entry.min_lava_damage = 10; - entry.expansion = 0; + e.short_name = ""; + e.id = 0; + e.file_name = ""; + e.long_name = ""; + e.map_file_name = ""; + e.safe_x = 0; + e.safe_y = 0; + e.safe_z = 0; + e.safe_heading = 0; + e.graveyard_id = 0; + e.min_level = 0; + e.min_status = 0; + e.zoneidnumber = 0; + e.version = 0; + e.timezone = 0; + e.maxclients = 0; + e.ruleset = 0; + e.note = ""; + e.underworld = 0; + e.minclip = 450; + e.maxclip = 450; + e.fog_minclip = 450; + e.fog_maxclip = 450; + e.fog_blue = 0; + e.fog_red = 0; + e.fog_green = 0; + e.sky = 1; + e.ztype = 1; + e.zone_exp_multiplier = 0.00; + e.walkspeed = 0.4; + e.time_type = 2; + e.fog_red1 = 0; + e.fog_green1 = 0; + e.fog_blue1 = 0; + e.fog_minclip1 = 450; + e.fog_maxclip1 = 450; + e.fog_red2 = 0; + e.fog_green2 = 0; + e.fog_blue2 = 0; + e.fog_minclip2 = 450; + e.fog_maxclip2 = 450; + e.fog_red3 = 0; + e.fog_green3 = 0; + e.fog_blue3 = 0; + e.fog_minclip3 = 450; + e.fog_maxclip3 = 450; + e.fog_red4 = 0; + e.fog_green4 = 0; + e.fog_blue4 = 0; + e.fog_minclip4 = 450; + e.fog_maxclip4 = 450; + e.fog_density = 0; + e.flag_needed = ""; + e.canbind = 1; + e.cancombat = 1; + e.canlevitate = 1; + e.castoutdoor = 1; + e.hotzone = 0; + e.insttype = 0; + e.shutdowndelay = 5000; + e.peqzone = 1; + e.suspendbuffs = 0; + e.rain_chance1 = 0; + e.rain_chance2 = 0; + e.rain_chance3 = 0; + e.rain_chance4 = 0; + e.rain_duration1 = 0; + e.rain_duration2 = 0; + e.rain_duration3 = 0; + e.rain_duration4 = 0; + e.snow_chance1 = 0; + e.snow_chance2 = 0; + e.snow_chance3 = 0; + e.snow_chance4 = 0; + e.snow_duration1 = 0; + e.snow_duration2 = 0; + e.snow_duration3 = 0; + e.snow_duration4 = 0; + e.gravity = 0.4; + e.type = 0; + e.skylock = 0; + e.fast_regen_hp = 180; + e.fast_regen_mana = 180; + e.fast_regen_endurance = 180; + e.npc_max_aggro_dist = 600; + e.max_movement_update_range = 600; + e.min_expansion = -1; + e.max_expansion = -1; + e.content_flags = ""; + e.content_flags_disabled = ""; + e.underworld_teleport_index = 0; + e.lava_damage = 50; + e.min_lava_damage = 10; + e.expansion = 0; - return entry; + return e; } - static Zone GetZoneEntry( + static Zone GetZone( const std::vector &zones, int zone_id ) @@ -484,104 +484,104 @@ public: auto row = results.begin(); if (results.RowCount() == 1) { - Zone entry{}; + Zone e{}; - entry.short_name = row[0] ? row[0] : ""; - entry.id = atoi(row[1]); - entry.file_name = row[2] ? row[2] : ""; - entry.long_name = row[3] ? row[3] : ""; - entry.map_file_name = row[4] ? row[4] : ""; - entry.safe_x = static_cast(atof(row[5])); - entry.safe_y = static_cast(atof(row[6])); - entry.safe_z = static_cast(atof(row[7])); - entry.safe_heading = static_cast(atof(row[8])); - entry.graveyard_id = static_cast(atof(row[9])); - entry.min_level = atoi(row[10]); - entry.min_status = atoi(row[11]); - entry.zoneidnumber = atoi(row[12]); - entry.version = atoi(row[13]); - entry.timezone = atoi(row[14]); - entry.maxclients = atoi(row[15]); - entry.ruleset = atoi(row[16]); - entry.note = row[17] ? row[17] : ""; - entry.underworld = static_cast(atof(row[18])); - entry.minclip = static_cast(atof(row[19])); - entry.maxclip = static_cast(atof(row[20])); - entry.fog_minclip = static_cast(atof(row[21])); - entry.fog_maxclip = static_cast(atof(row[22])); - entry.fog_blue = atoi(row[23]); - entry.fog_red = atoi(row[24]); - entry.fog_green = atoi(row[25]); - entry.sky = atoi(row[26]); - entry.ztype = atoi(row[27]); - entry.zone_exp_multiplier = static_cast(atof(row[28])); - entry.walkspeed = static_cast(atof(row[29])); - entry.time_type = atoi(row[30]); - entry.fog_red1 = atoi(row[31]); - entry.fog_green1 = atoi(row[32]); - entry.fog_blue1 = atoi(row[33]); - entry.fog_minclip1 = static_cast(atof(row[34])); - entry.fog_maxclip1 = static_cast(atof(row[35])); - entry.fog_red2 = atoi(row[36]); - entry.fog_green2 = atoi(row[37]); - entry.fog_blue2 = atoi(row[38]); - entry.fog_minclip2 = static_cast(atof(row[39])); - entry.fog_maxclip2 = static_cast(atof(row[40])); - entry.fog_red3 = atoi(row[41]); - entry.fog_green3 = atoi(row[42]); - entry.fog_blue3 = atoi(row[43]); - entry.fog_minclip3 = static_cast(atof(row[44])); - entry.fog_maxclip3 = static_cast(atof(row[45])); - entry.fog_red4 = atoi(row[46]); - entry.fog_green4 = atoi(row[47]); - entry.fog_blue4 = atoi(row[48]); - entry.fog_minclip4 = static_cast(atof(row[49])); - entry.fog_maxclip4 = static_cast(atof(row[50])); - entry.fog_density = static_cast(atof(row[51])); - entry.flag_needed = row[52] ? row[52] : ""; - entry.canbind = atoi(row[53]); - entry.cancombat = atoi(row[54]); - entry.canlevitate = atoi(row[55]); - entry.castoutdoor = atoi(row[56]); - entry.hotzone = atoi(row[57]); - entry.insttype = atoi(row[58]); - entry.shutdowndelay = strtoll(row[59], nullptr, 10); - entry.peqzone = atoi(row[60]); - entry.suspendbuffs = atoi(row[61]); - entry.rain_chance1 = atoi(row[62]); - entry.rain_chance2 = atoi(row[63]); - entry.rain_chance3 = atoi(row[64]); - entry.rain_chance4 = atoi(row[65]); - entry.rain_duration1 = atoi(row[66]); - entry.rain_duration2 = atoi(row[67]); - entry.rain_duration3 = atoi(row[68]); - entry.rain_duration4 = atoi(row[69]); - entry.snow_chance1 = atoi(row[70]); - entry.snow_chance2 = atoi(row[71]); - entry.snow_chance3 = atoi(row[72]); - entry.snow_chance4 = atoi(row[73]); - entry.snow_duration1 = atoi(row[74]); - entry.snow_duration2 = atoi(row[75]); - entry.snow_duration3 = atoi(row[76]); - entry.snow_duration4 = atoi(row[77]); - entry.gravity = static_cast(atof(row[78])); - entry.type = atoi(row[79]); - entry.skylock = atoi(row[80]); - entry.fast_regen_hp = atoi(row[81]); - entry.fast_regen_mana = atoi(row[82]); - entry.fast_regen_endurance = atoi(row[83]); - entry.npc_max_aggro_dist = atoi(row[84]); - entry.max_movement_update_range = atoi(row[85]); - entry.min_expansion = atoi(row[86]); - entry.max_expansion = atoi(row[87]); - entry.content_flags = row[88] ? row[88] : ""; - entry.content_flags_disabled = row[89] ? row[89] : ""; - entry.underworld_teleport_index = atoi(row[90]); - entry.lava_damage = atoi(row[91]); - entry.min_lava_damage = atoi(row[92]); - entry.expansion = atoi(row[93]); + e.short_name = row[0] ? row[0] : ""; + e.id = atoi(row[1]); + e.file_name = row[2] ? row[2] : ""; + e.long_name = row[3] ? row[3] : ""; + e.map_file_name = row[4] ? row[4] : ""; + e.safe_x = static_cast(atof(row[5])); + e.safe_y = static_cast(atof(row[6])); + e.safe_z = static_cast(atof(row[7])); + e.safe_heading = static_cast(atof(row[8])); + e.graveyard_id = static_cast(atof(row[9])); + e.min_level = atoi(row[10]); + e.min_status = atoi(row[11]); + e.zoneidnumber = atoi(row[12]); + e.version = atoi(row[13]); + e.timezone = atoi(row[14]); + e.maxclients = atoi(row[15]); + e.ruleset = atoi(row[16]); + e.note = row[17] ? row[17] : ""; + e.underworld = static_cast(atof(row[18])); + e.minclip = static_cast(atof(row[19])); + e.maxclip = static_cast(atof(row[20])); + e.fog_minclip = static_cast(atof(row[21])); + e.fog_maxclip = static_cast(atof(row[22])); + e.fog_blue = atoi(row[23]); + e.fog_red = atoi(row[24]); + e.fog_green = atoi(row[25]); + e.sky = atoi(row[26]); + e.ztype = atoi(row[27]); + e.zone_exp_multiplier = static_cast(atof(row[28])); + e.walkspeed = static_cast(atof(row[29])); + e.time_type = atoi(row[30]); + e.fog_red1 = atoi(row[31]); + e.fog_green1 = atoi(row[32]); + e.fog_blue1 = atoi(row[33]); + e.fog_minclip1 = static_cast(atof(row[34])); + e.fog_maxclip1 = static_cast(atof(row[35])); + e.fog_red2 = atoi(row[36]); + e.fog_green2 = atoi(row[37]); + e.fog_blue2 = atoi(row[38]); + e.fog_minclip2 = static_cast(atof(row[39])); + e.fog_maxclip2 = static_cast(atof(row[40])); + e.fog_red3 = atoi(row[41]); + e.fog_green3 = atoi(row[42]); + e.fog_blue3 = atoi(row[43]); + e.fog_minclip3 = static_cast(atof(row[44])); + e.fog_maxclip3 = static_cast(atof(row[45])); + e.fog_red4 = atoi(row[46]); + e.fog_green4 = atoi(row[47]); + e.fog_blue4 = atoi(row[48]); + e.fog_minclip4 = static_cast(atof(row[49])); + e.fog_maxclip4 = static_cast(atof(row[50])); + e.fog_density = static_cast(atof(row[51])); + e.flag_needed = row[52] ? row[52] : ""; + e.canbind = atoi(row[53]); + e.cancombat = atoi(row[54]); + e.canlevitate = atoi(row[55]); + e.castoutdoor = atoi(row[56]); + e.hotzone = atoi(row[57]); + e.insttype = atoi(row[58]); + e.shutdowndelay = strtoll(row[59], nullptr, 10); + e.peqzone = atoi(row[60]); + e.suspendbuffs = atoi(row[61]); + e.rain_chance1 = atoi(row[62]); + e.rain_chance2 = atoi(row[63]); + e.rain_chance3 = atoi(row[64]); + e.rain_chance4 = atoi(row[65]); + e.rain_duration1 = atoi(row[66]); + e.rain_duration2 = atoi(row[67]); + e.rain_duration3 = atoi(row[68]); + e.rain_duration4 = atoi(row[69]); + e.snow_chance1 = atoi(row[70]); + e.snow_chance2 = atoi(row[71]); + e.snow_chance3 = atoi(row[72]); + e.snow_chance4 = atoi(row[73]); + e.snow_duration1 = atoi(row[74]); + e.snow_duration2 = atoi(row[75]); + e.snow_duration3 = atoi(row[76]); + e.snow_duration4 = atoi(row[77]); + e.gravity = static_cast(atof(row[78])); + e.type = atoi(row[79]); + e.skylock = atoi(row[80]); + e.fast_regen_hp = atoi(row[81]); + e.fast_regen_mana = atoi(row[82]); + e.fast_regen_endurance = atoi(row[83]); + e.npc_max_aggro_dist = atoi(row[84]); + e.max_movement_update_range = atoi(row[85]); + e.min_expansion = atoi(row[86]); + e.max_expansion = atoi(row[87]); + e.content_flags = row[88] ? row[88] : ""; + e.content_flags_disabled = row[89] ? row[89] : ""; + e.underworld_teleport_index = atoi(row[90]); + e.lava_damage = atoi(row[91]); + e.min_lava_damage = atoi(row[92]); + e.expansion = atoi(row[93]); - return entry; + return e; } return NewEntity(); @@ -606,114 +606,114 @@ public: static int UpdateOne( Database& db, - Zone zone_entry + const Zone &e ) { - std::vector update_values; + std::vector v; auto columns = Columns(); - update_values.push_back(columns[0] + " = '" + Strings::Escape(zone_entry.short_name) + "'"); - update_values.push_back(columns[2] + " = '" + Strings::Escape(zone_entry.file_name) + "'"); - update_values.push_back(columns[3] + " = '" + Strings::Escape(zone_entry.long_name) + "'"); - update_values.push_back(columns[4] + " = '" + Strings::Escape(zone_entry.map_file_name) + "'"); - update_values.push_back(columns[5] + " = " + std::to_string(zone_entry.safe_x)); - update_values.push_back(columns[6] + " = " + std::to_string(zone_entry.safe_y)); - update_values.push_back(columns[7] + " = " + std::to_string(zone_entry.safe_z)); - update_values.push_back(columns[8] + " = " + std::to_string(zone_entry.safe_heading)); - update_values.push_back(columns[9] + " = " + std::to_string(zone_entry.graveyard_id)); - update_values.push_back(columns[10] + " = " + std::to_string(zone_entry.min_level)); - update_values.push_back(columns[11] + " = " + std::to_string(zone_entry.min_status)); - update_values.push_back(columns[12] + " = " + std::to_string(zone_entry.zoneidnumber)); - update_values.push_back(columns[13] + " = " + std::to_string(zone_entry.version)); - update_values.push_back(columns[14] + " = " + std::to_string(zone_entry.timezone)); - update_values.push_back(columns[15] + " = " + std::to_string(zone_entry.maxclients)); - update_values.push_back(columns[16] + " = " + std::to_string(zone_entry.ruleset)); - update_values.push_back(columns[17] + " = '" + Strings::Escape(zone_entry.note) + "'"); - update_values.push_back(columns[18] + " = " + std::to_string(zone_entry.underworld)); - update_values.push_back(columns[19] + " = " + std::to_string(zone_entry.minclip)); - update_values.push_back(columns[20] + " = " + std::to_string(zone_entry.maxclip)); - update_values.push_back(columns[21] + " = " + std::to_string(zone_entry.fog_minclip)); - update_values.push_back(columns[22] + " = " + std::to_string(zone_entry.fog_maxclip)); - update_values.push_back(columns[23] + " = " + std::to_string(zone_entry.fog_blue)); - update_values.push_back(columns[24] + " = " + std::to_string(zone_entry.fog_red)); - update_values.push_back(columns[25] + " = " + std::to_string(zone_entry.fog_green)); - update_values.push_back(columns[26] + " = " + std::to_string(zone_entry.sky)); - update_values.push_back(columns[27] + " = " + std::to_string(zone_entry.ztype)); - update_values.push_back(columns[28] + " = " + std::to_string(zone_entry.zone_exp_multiplier)); - update_values.push_back(columns[29] + " = " + std::to_string(zone_entry.walkspeed)); - update_values.push_back(columns[30] + " = " + std::to_string(zone_entry.time_type)); - update_values.push_back(columns[31] + " = " + std::to_string(zone_entry.fog_red1)); - update_values.push_back(columns[32] + " = " + std::to_string(zone_entry.fog_green1)); - update_values.push_back(columns[33] + " = " + std::to_string(zone_entry.fog_blue1)); - update_values.push_back(columns[34] + " = " + std::to_string(zone_entry.fog_minclip1)); - update_values.push_back(columns[35] + " = " + std::to_string(zone_entry.fog_maxclip1)); - update_values.push_back(columns[36] + " = " + std::to_string(zone_entry.fog_red2)); - update_values.push_back(columns[37] + " = " + std::to_string(zone_entry.fog_green2)); - update_values.push_back(columns[38] + " = " + std::to_string(zone_entry.fog_blue2)); - update_values.push_back(columns[39] + " = " + std::to_string(zone_entry.fog_minclip2)); - update_values.push_back(columns[40] + " = " + std::to_string(zone_entry.fog_maxclip2)); - update_values.push_back(columns[41] + " = " + std::to_string(zone_entry.fog_red3)); - update_values.push_back(columns[42] + " = " + std::to_string(zone_entry.fog_green3)); - update_values.push_back(columns[43] + " = " + std::to_string(zone_entry.fog_blue3)); - update_values.push_back(columns[44] + " = " + std::to_string(zone_entry.fog_minclip3)); - update_values.push_back(columns[45] + " = " + std::to_string(zone_entry.fog_maxclip3)); - update_values.push_back(columns[46] + " = " + std::to_string(zone_entry.fog_red4)); - update_values.push_back(columns[47] + " = " + std::to_string(zone_entry.fog_green4)); - update_values.push_back(columns[48] + " = " + std::to_string(zone_entry.fog_blue4)); - update_values.push_back(columns[49] + " = " + std::to_string(zone_entry.fog_minclip4)); - update_values.push_back(columns[50] + " = " + std::to_string(zone_entry.fog_maxclip4)); - update_values.push_back(columns[51] + " = " + std::to_string(zone_entry.fog_density)); - update_values.push_back(columns[52] + " = '" + Strings::Escape(zone_entry.flag_needed) + "'"); - update_values.push_back(columns[53] + " = " + std::to_string(zone_entry.canbind)); - update_values.push_back(columns[54] + " = " + std::to_string(zone_entry.cancombat)); - update_values.push_back(columns[55] + " = " + std::to_string(zone_entry.canlevitate)); - update_values.push_back(columns[56] + " = " + std::to_string(zone_entry.castoutdoor)); - update_values.push_back(columns[57] + " = " + std::to_string(zone_entry.hotzone)); - update_values.push_back(columns[58] + " = " + std::to_string(zone_entry.insttype)); - update_values.push_back(columns[59] + " = " + std::to_string(zone_entry.shutdowndelay)); - update_values.push_back(columns[60] + " = " + std::to_string(zone_entry.peqzone)); - update_values.push_back(columns[61] + " = " + std::to_string(zone_entry.suspendbuffs)); - update_values.push_back(columns[62] + " = " + std::to_string(zone_entry.rain_chance1)); - update_values.push_back(columns[63] + " = " + std::to_string(zone_entry.rain_chance2)); - update_values.push_back(columns[64] + " = " + std::to_string(zone_entry.rain_chance3)); - update_values.push_back(columns[65] + " = " + std::to_string(zone_entry.rain_chance4)); - update_values.push_back(columns[66] + " = " + std::to_string(zone_entry.rain_duration1)); - update_values.push_back(columns[67] + " = " + std::to_string(zone_entry.rain_duration2)); - update_values.push_back(columns[68] + " = " + std::to_string(zone_entry.rain_duration3)); - update_values.push_back(columns[69] + " = " + std::to_string(zone_entry.rain_duration4)); - update_values.push_back(columns[70] + " = " + std::to_string(zone_entry.snow_chance1)); - update_values.push_back(columns[71] + " = " + std::to_string(zone_entry.snow_chance2)); - update_values.push_back(columns[72] + " = " + std::to_string(zone_entry.snow_chance3)); - update_values.push_back(columns[73] + " = " + std::to_string(zone_entry.snow_chance4)); - update_values.push_back(columns[74] + " = " + std::to_string(zone_entry.snow_duration1)); - update_values.push_back(columns[75] + " = " + std::to_string(zone_entry.snow_duration2)); - update_values.push_back(columns[76] + " = " + std::to_string(zone_entry.snow_duration3)); - update_values.push_back(columns[77] + " = " + std::to_string(zone_entry.snow_duration4)); - update_values.push_back(columns[78] + " = " + std::to_string(zone_entry.gravity)); - update_values.push_back(columns[79] + " = " + std::to_string(zone_entry.type)); - update_values.push_back(columns[80] + " = " + std::to_string(zone_entry.skylock)); - update_values.push_back(columns[81] + " = " + std::to_string(zone_entry.fast_regen_hp)); - update_values.push_back(columns[82] + " = " + std::to_string(zone_entry.fast_regen_mana)); - update_values.push_back(columns[83] + " = " + std::to_string(zone_entry.fast_regen_endurance)); - update_values.push_back(columns[84] + " = " + std::to_string(zone_entry.npc_max_aggro_dist)); - update_values.push_back(columns[85] + " = " + std::to_string(zone_entry.max_movement_update_range)); - update_values.push_back(columns[86] + " = " + std::to_string(zone_entry.min_expansion)); - update_values.push_back(columns[87] + " = " + std::to_string(zone_entry.max_expansion)); - update_values.push_back(columns[88] + " = '" + Strings::Escape(zone_entry.content_flags) + "'"); - update_values.push_back(columns[89] + " = '" + Strings::Escape(zone_entry.content_flags_disabled) + "'"); - update_values.push_back(columns[90] + " = " + std::to_string(zone_entry.underworld_teleport_index)); - update_values.push_back(columns[91] + " = " + std::to_string(zone_entry.lava_damage)); - update_values.push_back(columns[92] + " = " + std::to_string(zone_entry.min_lava_damage)); - update_values.push_back(columns[93] + " = " + std::to_string(zone_entry.expansion)); + v.push_back(columns[0] + " = '" + Strings::Escape(e.short_name) + "'"); + v.push_back(columns[2] + " = '" + Strings::Escape(e.file_name) + "'"); + v.push_back(columns[3] + " = '" + Strings::Escape(e.long_name) + "'"); + v.push_back(columns[4] + " = '" + Strings::Escape(e.map_file_name) + "'"); + v.push_back(columns[5] + " = " + std::to_string(e.safe_x)); + v.push_back(columns[6] + " = " + std::to_string(e.safe_y)); + v.push_back(columns[7] + " = " + std::to_string(e.safe_z)); + v.push_back(columns[8] + " = " + std::to_string(e.safe_heading)); + v.push_back(columns[9] + " = " + std::to_string(e.graveyard_id)); + v.push_back(columns[10] + " = " + std::to_string(e.min_level)); + v.push_back(columns[11] + " = " + std::to_string(e.min_status)); + v.push_back(columns[12] + " = " + std::to_string(e.zoneidnumber)); + v.push_back(columns[13] + " = " + std::to_string(e.version)); + v.push_back(columns[14] + " = " + std::to_string(e.timezone)); + v.push_back(columns[15] + " = " + std::to_string(e.maxclients)); + v.push_back(columns[16] + " = " + std::to_string(e.ruleset)); + v.push_back(columns[17] + " = '" + Strings::Escape(e.note) + "'"); + v.push_back(columns[18] + " = " + std::to_string(e.underworld)); + v.push_back(columns[19] + " = " + std::to_string(e.minclip)); + v.push_back(columns[20] + " = " + std::to_string(e.maxclip)); + v.push_back(columns[21] + " = " + std::to_string(e.fog_minclip)); + v.push_back(columns[22] + " = " + std::to_string(e.fog_maxclip)); + v.push_back(columns[23] + " = " + std::to_string(e.fog_blue)); + v.push_back(columns[24] + " = " + std::to_string(e.fog_red)); + v.push_back(columns[25] + " = " + std::to_string(e.fog_green)); + v.push_back(columns[26] + " = " + std::to_string(e.sky)); + v.push_back(columns[27] + " = " + std::to_string(e.ztype)); + v.push_back(columns[28] + " = " + std::to_string(e.zone_exp_multiplier)); + v.push_back(columns[29] + " = " + std::to_string(e.walkspeed)); + v.push_back(columns[30] + " = " + std::to_string(e.time_type)); + v.push_back(columns[31] + " = " + std::to_string(e.fog_red1)); + v.push_back(columns[32] + " = " + std::to_string(e.fog_green1)); + v.push_back(columns[33] + " = " + std::to_string(e.fog_blue1)); + v.push_back(columns[34] + " = " + std::to_string(e.fog_minclip1)); + v.push_back(columns[35] + " = " + std::to_string(e.fog_maxclip1)); + v.push_back(columns[36] + " = " + std::to_string(e.fog_red2)); + v.push_back(columns[37] + " = " + std::to_string(e.fog_green2)); + v.push_back(columns[38] + " = " + std::to_string(e.fog_blue2)); + v.push_back(columns[39] + " = " + std::to_string(e.fog_minclip2)); + v.push_back(columns[40] + " = " + std::to_string(e.fog_maxclip2)); + v.push_back(columns[41] + " = " + std::to_string(e.fog_red3)); + v.push_back(columns[42] + " = " + std::to_string(e.fog_green3)); + v.push_back(columns[43] + " = " + std::to_string(e.fog_blue3)); + v.push_back(columns[44] + " = " + std::to_string(e.fog_minclip3)); + v.push_back(columns[45] + " = " + std::to_string(e.fog_maxclip3)); + v.push_back(columns[46] + " = " + std::to_string(e.fog_red4)); + v.push_back(columns[47] + " = " + std::to_string(e.fog_green4)); + v.push_back(columns[48] + " = " + std::to_string(e.fog_blue4)); + v.push_back(columns[49] + " = " + std::to_string(e.fog_minclip4)); + v.push_back(columns[50] + " = " + std::to_string(e.fog_maxclip4)); + v.push_back(columns[51] + " = " + std::to_string(e.fog_density)); + v.push_back(columns[52] + " = '" + Strings::Escape(e.flag_needed) + "'"); + v.push_back(columns[53] + " = " + std::to_string(e.canbind)); + v.push_back(columns[54] + " = " + std::to_string(e.cancombat)); + v.push_back(columns[55] + " = " + std::to_string(e.canlevitate)); + v.push_back(columns[56] + " = " + std::to_string(e.castoutdoor)); + v.push_back(columns[57] + " = " + std::to_string(e.hotzone)); + v.push_back(columns[58] + " = " + std::to_string(e.insttype)); + v.push_back(columns[59] + " = " + std::to_string(e.shutdowndelay)); + v.push_back(columns[60] + " = " + std::to_string(e.peqzone)); + v.push_back(columns[61] + " = " + std::to_string(e.suspendbuffs)); + v.push_back(columns[62] + " = " + std::to_string(e.rain_chance1)); + v.push_back(columns[63] + " = " + std::to_string(e.rain_chance2)); + v.push_back(columns[64] + " = " + std::to_string(e.rain_chance3)); + v.push_back(columns[65] + " = " + std::to_string(e.rain_chance4)); + v.push_back(columns[66] + " = " + std::to_string(e.rain_duration1)); + v.push_back(columns[67] + " = " + std::to_string(e.rain_duration2)); + v.push_back(columns[68] + " = " + std::to_string(e.rain_duration3)); + v.push_back(columns[69] + " = " + std::to_string(e.rain_duration4)); + v.push_back(columns[70] + " = " + std::to_string(e.snow_chance1)); + v.push_back(columns[71] + " = " + std::to_string(e.snow_chance2)); + v.push_back(columns[72] + " = " + std::to_string(e.snow_chance3)); + v.push_back(columns[73] + " = " + std::to_string(e.snow_chance4)); + v.push_back(columns[74] + " = " + std::to_string(e.snow_duration1)); + v.push_back(columns[75] + " = " + std::to_string(e.snow_duration2)); + v.push_back(columns[76] + " = " + std::to_string(e.snow_duration3)); + v.push_back(columns[77] + " = " + std::to_string(e.snow_duration4)); + v.push_back(columns[78] + " = " + std::to_string(e.gravity)); + v.push_back(columns[79] + " = " + std::to_string(e.type)); + v.push_back(columns[80] + " = " + std::to_string(e.skylock)); + v.push_back(columns[81] + " = " + std::to_string(e.fast_regen_hp)); + v.push_back(columns[82] + " = " + std::to_string(e.fast_regen_mana)); + v.push_back(columns[83] + " = " + std::to_string(e.fast_regen_endurance)); + v.push_back(columns[84] + " = " + std::to_string(e.npc_max_aggro_dist)); + v.push_back(columns[85] + " = " + std::to_string(e.max_movement_update_range)); + v.push_back(columns[86] + " = " + std::to_string(e.min_expansion)); + v.push_back(columns[87] + " = " + std::to_string(e.max_expansion)); + v.push_back(columns[88] + " = '" + Strings::Escape(e.content_flags) + "'"); + v.push_back(columns[89] + " = '" + Strings::Escape(e.content_flags_disabled) + "'"); + v.push_back(columns[90] + " = " + std::to_string(e.underworld_teleport_index)); + v.push_back(columns[91] + " = " + std::to_string(e.lava_damage)); + v.push_back(columns[92] + " = " + std::to_string(e.min_lava_damage)); + v.push_back(columns[93] + " = " + std::to_string(e.expansion)); auto results = db.QueryDatabase( fmt::format( "UPDATE {} SET {} WHERE {} = {}", TableName(), - Strings::Implode(", ", update_values), + Strings::Implode(", ", v), PrimaryKey(), - zone_entry.id + e.id ) ); @@ -722,233 +722,233 @@ public: static Zone InsertOne( Database& db, - Zone zone_entry + Zone e ) { - std::vector insert_values; + std::vector v; - insert_values.push_back("'" + Strings::Escape(zone_entry.short_name) + "'"); - insert_values.push_back(std::to_string(zone_entry.id)); - insert_values.push_back("'" + Strings::Escape(zone_entry.file_name) + "'"); - insert_values.push_back("'" + Strings::Escape(zone_entry.long_name) + "'"); - insert_values.push_back("'" + Strings::Escape(zone_entry.map_file_name) + "'"); - insert_values.push_back(std::to_string(zone_entry.safe_x)); - insert_values.push_back(std::to_string(zone_entry.safe_y)); - insert_values.push_back(std::to_string(zone_entry.safe_z)); - insert_values.push_back(std::to_string(zone_entry.safe_heading)); - insert_values.push_back(std::to_string(zone_entry.graveyard_id)); - insert_values.push_back(std::to_string(zone_entry.min_level)); - insert_values.push_back(std::to_string(zone_entry.min_status)); - insert_values.push_back(std::to_string(zone_entry.zoneidnumber)); - insert_values.push_back(std::to_string(zone_entry.version)); - insert_values.push_back(std::to_string(zone_entry.timezone)); - insert_values.push_back(std::to_string(zone_entry.maxclients)); - insert_values.push_back(std::to_string(zone_entry.ruleset)); - insert_values.push_back("'" + Strings::Escape(zone_entry.note) + "'"); - insert_values.push_back(std::to_string(zone_entry.underworld)); - insert_values.push_back(std::to_string(zone_entry.minclip)); - insert_values.push_back(std::to_string(zone_entry.maxclip)); - insert_values.push_back(std::to_string(zone_entry.fog_minclip)); - insert_values.push_back(std::to_string(zone_entry.fog_maxclip)); - insert_values.push_back(std::to_string(zone_entry.fog_blue)); - insert_values.push_back(std::to_string(zone_entry.fog_red)); - insert_values.push_back(std::to_string(zone_entry.fog_green)); - insert_values.push_back(std::to_string(zone_entry.sky)); - insert_values.push_back(std::to_string(zone_entry.ztype)); - insert_values.push_back(std::to_string(zone_entry.zone_exp_multiplier)); - insert_values.push_back(std::to_string(zone_entry.walkspeed)); - insert_values.push_back(std::to_string(zone_entry.time_type)); - insert_values.push_back(std::to_string(zone_entry.fog_red1)); - insert_values.push_back(std::to_string(zone_entry.fog_green1)); - insert_values.push_back(std::to_string(zone_entry.fog_blue1)); - insert_values.push_back(std::to_string(zone_entry.fog_minclip1)); - insert_values.push_back(std::to_string(zone_entry.fog_maxclip1)); - insert_values.push_back(std::to_string(zone_entry.fog_red2)); - insert_values.push_back(std::to_string(zone_entry.fog_green2)); - insert_values.push_back(std::to_string(zone_entry.fog_blue2)); - insert_values.push_back(std::to_string(zone_entry.fog_minclip2)); - insert_values.push_back(std::to_string(zone_entry.fog_maxclip2)); - insert_values.push_back(std::to_string(zone_entry.fog_red3)); - insert_values.push_back(std::to_string(zone_entry.fog_green3)); - insert_values.push_back(std::to_string(zone_entry.fog_blue3)); - insert_values.push_back(std::to_string(zone_entry.fog_minclip3)); - insert_values.push_back(std::to_string(zone_entry.fog_maxclip3)); - insert_values.push_back(std::to_string(zone_entry.fog_red4)); - insert_values.push_back(std::to_string(zone_entry.fog_green4)); - insert_values.push_back(std::to_string(zone_entry.fog_blue4)); - insert_values.push_back(std::to_string(zone_entry.fog_minclip4)); - insert_values.push_back(std::to_string(zone_entry.fog_maxclip4)); - insert_values.push_back(std::to_string(zone_entry.fog_density)); - insert_values.push_back("'" + Strings::Escape(zone_entry.flag_needed) + "'"); - insert_values.push_back(std::to_string(zone_entry.canbind)); - insert_values.push_back(std::to_string(zone_entry.cancombat)); - insert_values.push_back(std::to_string(zone_entry.canlevitate)); - insert_values.push_back(std::to_string(zone_entry.castoutdoor)); - insert_values.push_back(std::to_string(zone_entry.hotzone)); - insert_values.push_back(std::to_string(zone_entry.insttype)); - insert_values.push_back(std::to_string(zone_entry.shutdowndelay)); - insert_values.push_back(std::to_string(zone_entry.peqzone)); - insert_values.push_back(std::to_string(zone_entry.suspendbuffs)); - insert_values.push_back(std::to_string(zone_entry.rain_chance1)); - insert_values.push_back(std::to_string(zone_entry.rain_chance2)); - insert_values.push_back(std::to_string(zone_entry.rain_chance3)); - insert_values.push_back(std::to_string(zone_entry.rain_chance4)); - insert_values.push_back(std::to_string(zone_entry.rain_duration1)); - insert_values.push_back(std::to_string(zone_entry.rain_duration2)); - insert_values.push_back(std::to_string(zone_entry.rain_duration3)); - insert_values.push_back(std::to_string(zone_entry.rain_duration4)); - insert_values.push_back(std::to_string(zone_entry.snow_chance1)); - insert_values.push_back(std::to_string(zone_entry.snow_chance2)); - insert_values.push_back(std::to_string(zone_entry.snow_chance3)); - insert_values.push_back(std::to_string(zone_entry.snow_chance4)); - insert_values.push_back(std::to_string(zone_entry.snow_duration1)); - insert_values.push_back(std::to_string(zone_entry.snow_duration2)); - insert_values.push_back(std::to_string(zone_entry.snow_duration3)); - insert_values.push_back(std::to_string(zone_entry.snow_duration4)); - insert_values.push_back(std::to_string(zone_entry.gravity)); - insert_values.push_back(std::to_string(zone_entry.type)); - insert_values.push_back(std::to_string(zone_entry.skylock)); - insert_values.push_back(std::to_string(zone_entry.fast_regen_hp)); - insert_values.push_back(std::to_string(zone_entry.fast_regen_mana)); - insert_values.push_back(std::to_string(zone_entry.fast_regen_endurance)); - insert_values.push_back(std::to_string(zone_entry.npc_max_aggro_dist)); - insert_values.push_back(std::to_string(zone_entry.max_movement_update_range)); - insert_values.push_back(std::to_string(zone_entry.min_expansion)); - insert_values.push_back(std::to_string(zone_entry.max_expansion)); - insert_values.push_back("'" + Strings::Escape(zone_entry.content_flags) + "'"); - insert_values.push_back("'" + Strings::Escape(zone_entry.content_flags_disabled) + "'"); - insert_values.push_back(std::to_string(zone_entry.underworld_teleport_index)); - insert_values.push_back(std::to_string(zone_entry.lava_damage)); - insert_values.push_back(std::to_string(zone_entry.min_lava_damage)); - insert_values.push_back(std::to_string(zone_entry.expansion)); + v.push_back("'" + Strings::Escape(e.short_name) + "'"); + v.push_back(std::to_string(e.id)); + v.push_back("'" + Strings::Escape(e.file_name) + "'"); + v.push_back("'" + Strings::Escape(e.long_name) + "'"); + v.push_back("'" + Strings::Escape(e.map_file_name) + "'"); + v.push_back(std::to_string(e.safe_x)); + v.push_back(std::to_string(e.safe_y)); + v.push_back(std::to_string(e.safe_z)); + v.push_back(std::to_string(e.safe_heading)); + v.push_back(std::to_string(e.graveyard_id)); + v.push_back(std::to_string(e.min_level)); + v.push_back(std::to_string(e.min_status)); + v.push_back(std::to_string(e.zoneidnumber)); + v.push_back(std::to_string(e.version)); + v.push_back(std::to_string(e.timezone)); + v.push_back(std::to_string(e.maxclients)); + v.push_back(std::to_string(e.ruleset)); + v.push_back("'" + Strings::Escape(e.note) + "'"); + v.push_back(std::to_string(e.underworld)); + v.push_back(std::to_string(e.minclip)); + v.push_back(std::to_string(e.maxclip)); + v.push_back(std::to_string(e.fog_minclip)); + v.push_back(std::to_string(e.fog_maxclip)); + v.push_back(std::to_string(e.fog_blue)); + v.push_back(std::to_string(e.fog_red)); + v.push_back(std::to_string(e.fog_green)); + v.push_back(std::to_string(e.sky)); + v.push_back(std::to_string(e.ztype)); + v.push_back(std::to_string(e.zone_exp_multiplier)); + v.push_back(std::to_string(e.walkspeed)); + v.push_back(std::to_string(e.time_type)); + v.push_back(std::to_string(e.fog_red1)); + v.push_back(std::to_string(e.fog_green1)); + v.push_back(std::to_string(e.fog_blue1)); + v.push_back(std::to_string(e.fog_minclip1)); + v.push_back(std::to_string(e.fog_maxclip1)); + v.push_back(std::to_string(e.fog_red2)); + v.push_back(std::to_string(e.fog_green2)); + v.push_back(std::to_string(e.fog_blue2)); + v.push_back(std::to_string(e.fog_minclip2)); + v.push_back(std::to_string(e.fog_maxclip2)); + v.push_back(std::to_string(e.fog_red3)); + v.push_back(std::to_string(e.fog_green3)); + v.push_back(std::to_string(e.fog_blue3)); + v.push_back(std::to_string(e.fog_minclip3)); + v.push_back(std::to_string(e.fog_maxclip3)); + v.push_back(std::to_string(e.fog_red4)); + v.push_back(std::to_string(e.fog_green4)); + v.push_back(std::to_string(e.fog_blue4)); + v.push_back(std::to_string(e.fog_minclip4)); + v.push_back(std::to_string(e.fog_maxclip4)); + v.push_back(std::to_string(e.fog_density)); + v.push_back("'" + Strings::Escape(e.flag_needed) + "'"); + v.push_back(std::to_string(e.canbind)); + v.push_back(std::to_string(e.cancombat)); + v.push_back(std::to_string(e.canlevitate)); + v.push_back(std::to_string(e.castoutdoor)); + v.push_back(std::to_string(e.hotzone)); + v.push_back(std::to_string(e.insttype)); + v.push_back(std::to_string(e.shutdowndelay)); + v.push_back(std::to_string(e.peqzone)); + v.push_back(std::to_string(e.suspendbuffs)); + v.push_back(std::to_string(e.rain_chance1)); + v.push_back(std::to_string(e.rain_chance2)); + v.push_back(std::to_string(e.rain_chance3)); + v.push_back(std::to_string(e.rain_chance4)); + v.push_back(std::to_string(e.rain_duration1)); + v.push_back(std::to_string(e.rain_duration2)); + v.push_back(std::to_string(e.rain_duration3)); + v.push_back(std::to_string(e.rain_duration4)); + v.push_back(std::to_string(e.snow_chance1)); + v.push_back(std::to_string(e.snow_chance2)); + v.push_back(std::to_string(e.snow_chance3)); + v.push_back(std::to_string(e.snow_chance4)); + v.push_back(std::to_string(e.snow_duration1)); + v.push_back(std::to_string(e.snow_duration2)); + v.push_back(std::to_string(e.snow_duration3)); + v.push_back(std::to_string(e.snow_duration4)); + v.push_back(std::to_string(e.gravity)); + v.push_back(std::to_string(e.type)); + v.push_back(std::to_string(e.skylock)); + v.push_back(std::to_string(e.fast_regen_hp)); + v.push_back(std::to_string(e.fast_regen_mana)); + v.push_back(std::to_string(e.fast_regen_endurance)); + v.push_back(std::to_string(e.npc_max_aggro_dist)); + v.push_back(std::to_string(e.max_movement_update_range)); + v.push_back(std::to_string(e.min_expansion)); + v.push_back(std::to_string(e.max_expansion)); + v.push_back("'" + Strings::Escape(e.content_flags) + "'"); + v.push_back("'" + Strings::Escape(e.content_flags_disabled) + "'"); + v.push_back(std::to_string(e.underworld_teleport_index)); + v.push_back(std::to_string(e.lava_damage)); + v.push_back(std::to_string(e.min_lava_damage)); + v.push_back(std::to_string(e.expansion)); auto results = db.QueryDatabase( fmt::format( "{} VALUES ({})", BaseInsert(), - Strings::Implode(",", insert_values) + Strings::Implode(",", v) ) ); if (results.Success()) { - zone_entry.id = results.LastInsertedID(); - return zone_entry; + e.id = results.LastInsertedID(); + return e; } - zone_entry = NewEntity(); + e = NewEntity(); - return zone_entry; + return e; } static int InsertMany( Database& db, - std::vector zone_entries + const std::vector &entries ) { std::vector insert_chunks; - for (auto &zone_entry: zone_entries) { - std::vector insert_values; + for (auto &e: entries) { + std::vector v; - insert_values.push_back("'" + Strings::Escape(zone_entry.short_name) + "'"); - insert_values.push_back(std::to_string(zone_entry.id)); - insert_values.push_back("'" + Strings::Escape(zone_entry.file_name) + "'"); - insert_values.push_back("'" + Strings::Escape(zone_entry.long_name) + "'"); - insert_values.push_back("'" + Strings::Escape(zone_entry.map_file_name) + "'"); - insert_values.push_back(std::to_string(zone_entry.safe_x)); - insert_values.push_back(std::to_string(zone_entry.safe_y)); - insert_values.push_back(std::to_string(zone_entry.safe_z)); - insert_values.push_back(std::to_string(zone_entry.safe_heading)); - insert_values.push_back(std::to_string(zone_entry.graveyard_id)); - insert_values.push_back(std::to_string(zone_entry.min_level)); - insert_values.push_back(std::to_string(zone_entry.min_status)); - insert_values.push_back(std::to_string(zone_entry.zoneidnumber)); - insert_values.push_back(std::to_string(zone_entry.version)); - insert_values.push_back(std::to_string(zone_entry.timezone)); - insert_values.push_back(std::to_string(zone_entry.maxclients)); - insert_values.push_back(std::to_string(zone_entry.ruleset)); - insert_values.push_back("'" + Strings::Escape(zone_entry.note) + "'"); - insert_values.push_back(std::to_string(zone_entry.underworld)); - insert_values.push_back(std::to_string(zone_entry.minclip)); - insert_values.push_back(std::to_string(zone_entry.maxclip)); - insert_values.push_back(std::to_string(zone_entry.fog_minclip)); - insert_values.push_back(std::to_string(zone_entry.fog_maxclip)); - insert_values.push_back(std::to_string(zone_entry.fog_blue)); - insert_values.push_back(std::to_string(zone_entry.fog_red)); - insert_values.push_back(std::to_string(zone_entry.fog_green)); - insert_values.push_back(std::to_string(zone_entry.sky)); - insert_values.push_back(std::to_string(zone_entry.ztype)); - insert_values.push_back(std::to_string(zone_entry.zone_exp_multiplier)); - insert_values.push_back(std::to_string(zone_entry.walkspeed)); - insert_values.push_back(std::to_string(zone_entry.time_type)); - insert_values.push_back(std::to_string(zone_entry.fog_red1)); - insert_values.push_back(std::to_string(zone_entry.fog_green1)); - insert_values.push_back(std::to_string(zone_entry.fog_blue1)); - insert_values.push_back(std::to_string(zone_entry.fog_minclip1)); - insert_values.push_back(std::to_string(zone_entry.fog_maxclip1)); - insert_values.push_back(std::to_string(zone_entry.fog_red2)); - insert_values.push_back(std::to_string(zone_entry.fog_green2)); - insert_values.push_back(std::to_string(zone_entry.fog_blue2)); - insert_values.push_back(std::to_string(zone_entry.fog_minclip2)); - insert_values.push_back(std::to_string(zone_entry.fog_maxclip2)); - insert_values.push_back(std::to_string(zone_entry.fog_red3)); - insert_values.push_back(std::to_string(zone_entry.fog_green3)); - insert_values.push_back(std::to_string(zone_entry.fog_blue3)); - insert_values.push_back(std::to_string(zone_entry.fog_minclip3)); - insert_values.push_back(std::to_string(zone_entry.fog_maxclip3)); - insert_values.push_back(std::to_string(zone_entry.fog_red4)); - insert_values.push_back(std::to_string(zone_entry.fog_green4)); - insert_values.push_back(std::to_string(zone_entry.fog_blue4)); - insert_values.push_back(std::to_string(zone_entry.fog_minclip4)); - insert_values.push_back(std::to_string(zone_entry.fog_maxclip4)); - insert_values.push_back(std::to_string(zone_entry.fog_density)); - insert_values.push_back("'" + Strings::Escape(zone_entry.flag_needed) + "'"); - insert_values.push_back(std::to_string(zone_entry.canbind)); - insert_values.push_back(std::to_string(zone_entry.cancombat)); - insert_values.push_back(std::to_string(zone_entry.canlevitate)); - insert_values.push_back(std::to_string(zone_entry.castoutdoor)); - insert_values.push_back(std::to_string(zone_entry.hotzone)); - insert_values.push_back(std::to_string(zone_entry.insttype)); - insert_values.push_back(std::to_string(zone_entry.shutdowndelay)); - insert_values.push_back(std::to_string(zone_entry.peqzone)); - insert_values.push_back(std::to_string(zone_entry.suspendbuffs)); - insert_values.push_back(std::to_string(zone_entry.rain_chance1)); - insert_values.push_back(std::to_string(zone_entry.rain_chance2)); - insert_values.push_back(std::to_string(zone_entry.rain_chance3)); - insert_values.push_back(std::to_string(zone_entry.rain_chance4)); - insert_values.push_back(std::to_string(zone_entry.rain_duration1)); - insert_values.push_back(std::to_string(zone_entry.rain_duration2)); - insert_values.push_back(std::to_string(zone_entry.rain_duration3)); - insert_values.push_back(std::to_string(zone_entry.rain_duration4)); - insert_values.push_back(std::to_string(zone_entry.snow_chance1)); - insert_values.push_back(std::to_string(zone_entry.snow_chance2)); - insert_values.push_back(std::to_string(zone_entry.snow_chance3)); - insert_values.push_back(std::to_string(zone_entry.snow_chance4)); - insert_values.push_back(std::to_string(zone_entry.snow_duration1)); - insert_values.push_back(std::to_string(zone_entry.snow_duration2)); - insert_values.push_back(std::to_string(zone_entry.snow_duration3)); - insert_values.push_back(std::to_string(zone_entry.snow_duration4)); - insert_values.push_back(std::to_string(zone_entry.gravity)); - insert_values.push_back(std::to_string(zone_entry.type)); - insert_values.push_back(std::to_string(zone_entry.skylock)); - insert_values.push_back(std::to_string(zone_entry.fast_regen_hp)); - insert_values.push_back(std::to_string(zone_entry.fast_regen_mana)); - insert_values.push_back(std::to_string(zone_entry.fast_regen_endurance)); - insert_values.push_back(std::to_string(zone_entry.npc_max_aggro_dist)); - insert_values.push_back(std::to_string(zone_entry.max_movement_update_range)); - insert_values.push_back(std::to_string(zone_entry.min_expansion)); - insert_values.push_back(std::to_string(zone_entry.max_expansion)); - insert_values.push_back("'" + Strings::Escape(zone_entry.content_flags) + "'"); - insert_values.push_back("'" + Strings::Escape(zone_entry.content_flags_disabled) + "'"); - insert_values.push_back(std::to_string(zone_entry.underworld_teleport_index)); - insert_values.push_back(std::to_string(zone_entry.lava_damage)); - insert_values.push_back(std::to_string(zone_entry.min_lava_damage)); - insert_values.push_back(std::to_string(zone_entry.expansion)); + v.push_back("'" + Strings::Escape(e.short_name) + "'"); + v.push_back(std::to_string(e.id)); + v.push_back("'" + Strings::Escape(e.file_name) + "'"); + v.push_back("'" + Strings::Escape(e.long_name) + "'"); + v.push_back("'" + Strings::Escape(e.map_file_name) + "'"); + v.push_back(std::to_string(e.safe_x)); + v.push_back(std::to_string(e.safe_y)); + v.push_back(std::to_string(e.safe_z)); + v.push_back(std::to_string(e.safe_heading)); + v.push_back(std::to_string(e.graveyard_id)); + v.push_back(std::to_string(e.min_level)); + v.push_back(std::to_string(e.min_status)); + v.push_back(std::to_string(e.zoneidnumber)); + v.push_back(std::to_string(e.version)); + v.push_back(std::to_string(e.timezone)); + v.push_back(std::to_string(e.maxclients)); + v.push_back(std::to_string(e.ruleset)); + v.push_back("'" + Strings::Escape(e.note) + "'"); + v.push_back(std::to_string(e.underworld)); + v.push_back(std::to_string(e.minclip)); + v.push_back(std::to_string(e.maxclip)); + v.push_back(std::to_string(e.fog_minclip)); + v.push_back(std::to_string(e.fog_maxclip)); + v.push_back(std::to_string(e.fog_blue)); + v.push_back(std::to_string(e.fog_red)); + v.push_back(std::to_string(e.fog_green)); + v.push_back(std::to_string(e.sky)); + v.push_back(std::to_string(e.ztype)); + v.push_back(std::to_string(e.zone_exp_multiplier)); + v.push_back(std::to_string(e.walkspeed)); + v.push_back(std::to_string(e.time_type)); + v.push_back(std::to_string(e.fog_red1)); + v.push_back(std::to_string(e.fog_green1)); + v.push_back(std::to_string(e.fog_blue1)); + v.push_back(std::to_string(e.fog_minclip1)); + v.push_back(std::to_string(e.fog_maxclip1)); + v.push_back(std::to_string(e.fog_red2)); + v.push_back(std::to_string(e.fog_green2)); + v.push_back(std::to_string(e.fog_blue2)); + v.push_back(std::to_string(e.fog_minclip2)); + v.push_back(std::to_string(e.fog_maxclip2)); + v.push_back(std::to_string(e.fog_red3)); + v.push_back(std::to_string(e.fog_green3)); + v.push_back(std::to_string(e.fog_blue3)); + v.push_back(std::to_string(e.fog_minclip3)); + v.push_back(std::to_string(e.fog_maxclip3)); + v.push_back(std::to_string(e.fog_red4)); + v.push_back(std::to_string(e.fog_green4)); + v.push_back(std::to_string(e.fog_blue4)); + v.push_back(std::to_string(e.fog_minclip4)); + v.push_back(std::to_string(e.fog_maxclip4)); + v.push_back(std::to_string(e.fog_density)); + v.push_back("'" + Strings::Escape(e.flag_needed) + "'"); + v.push_back(std::to_string(e.canbind)); + v.push_back(std::to_string(e.cancombat)); + v.push_back(std::to_string(e.canlevitate)); + v.push_back(std::to_string(e.castoutdoor)); + v.push_back(std::to_string(e.hotzone)); + v.push_back(std::to_string(e.insttype)); + v.push_back(std::to_string(e.shutdowndelay)); + v.push_back(std::to_string(e.peqzone)); + v.push_back(std::to_string(e.suspendbuffs)); + v.push_back(std::to_string(e.rain_chance1)); + v.push_back(std::to_string(e.rain_chance2)); + v.push_back(std::to_string(e.rain_chance3)); + v.push_back(std::to_string(e.rain_chance4)); + v.push_back(std::to_string(e.rain_duration1)); + v.push_back(std::to_string(e.rain_duration2)); + v.push_back(std::to_string(e.rain_duration3)); + v.push_back(std::to_string(e.rain_duration4)); + v.push_back(std::to_string(e.snow_chance1)); + v.push_back(std::to_string(e.snow_chance2)); + v.push_back(std::to_string(e.snow_chance3)); + v.push_back(std::to_string(e.snow_chance4)); + v.push_back(std::to_string(e.snow_duration1)); + v.push_back(std::to_string(e.snow_duration2)); + v.push_back(std::to_string(e.snow_duration3)); + v.push_back(std::to_string(e.snow_duration4)); + v.push_back(std::to_string(e.gravity)); + v.push_back(std::to_string(e.type)); + v.push_back(std::to_string(e.skylock)); + v.push_back(std::to_string(e.fast_regen_hp)); + v.push_back(std::to_string(e.fast_regen_mana)); + v.push_back(std::to_string(e.fast_regen_endurance)); + v.push_back(std::to_string(e.npc_max_aggro_dist)); + v.push_back(std::to_string(e.max_movement_update_range)); + v.push_back(std::to_string(e.min_expansion)); + v.push_back(std::to_string(e.max_expansion)); + v.push_back("'" + Strings::Escape(e.content_flags) + "'"); + v.push_back("'" + Strings::Escape(e.content_flags_disabled) + "'"); + v.push_back(std::to_string(e.underworld_teleport_index)); + v.push_back(std::to_string(e.lava_damage)); + v.push_back(std::to_string(e.min_lava_damage)); + v.push_back(std::to_string(e.expansion)); - insert_chunks.push_back("(" + Strings::Implode(",", insert_values) + ")"); + insert_chunks.push_back("(" + Strings::Implode(",", v) + ")"); } - std::vector insert_values; + std::vector v; auto results = db.QueryDatabase( fmt::format( @@ -975,110 +975,110 @@ public: all_entries.reserve(results.RowCount()); for (auto row = results.begin(); row != results.end(); ++row) { - Zone entry{}; + Zone e{}; - entry.short_name = row[0] ? row[0] : ""; - entry.id = atoi(row[1]); - entry.file_name = row[2] ? row[2] : ""; - entry.long_name = row[3] ? row[3] : ""; - entry.map_file_name = row[4] ? row[4] : ""; - entry.safe_x = static_cast(atof(row[5])); - entry.safe_y = static_cast(atof(row[6])); - entry.safe_z = static_cast(atof(row[7])); - entry.safe_heading = static_cast(atof(row[8])); - entry.graveyard_id = static_cast(atof(row[9])); - entry.min_level = atoi(row[10]); - entry.min_status = atoi(row[11]); - entry.zoneidnumber = atoi(row[12]); - entry.version = atoi(row[13]); - entry.timezone = atoi(row[14]); - entry.maxclients = atoi(row[15]); - entry.ruleset = atoi(row[16]); - entry.note = row[17] ? row[17] : ""; - entry.underworld = static_cast(atof(row[18])); - entry.minclip = static_cast(atof(row[19])); - entry.maxclip = static_cast(atof(row[20])); - entry.fog_minclip = static_cast(atof(row[21])); - entry.fog_maxclip = static_cast(atof(row[22])); - entry.fog_blue = atoi(row[23]); - entry.fog_red = atoi(row[24]); - entry.fog_green = atoi(row[25]); - entry.sky = atoi(row[26]); - entry.ztype = atoi(row[27]); - entry.zone_exp_multiplier = static_cast(atof(row[28])); - entry.walkspeed = static_cast(atof(row[29])); - entry.time_type = atoi(row[30]); - entry.fog_red1 = atoi(row[31]); - entry.fog_green1 = atoi(row[32]); - entry.fog_blue1 = atoi(row[33]); - entry.fog_minclip1 = static_cast(atof(row[34])); - entry.fog_maxclip1 = static_cast(atof(row[35])); - entry.fog_red2 = atoi(row[36]); - entry.fog_green2 = atoi(row[37]); - entry.fog_blue2 = atoi(row[38]); - entry.fog_minclip2 = static_cast(atof(row[39])); - entry.fog_maxclip2 = static_cast(atof(row[40])); - entry.fog_red3 = atoi(row[41]); - entry.fog_green3 = atoi(row[42]); - entry.fog_blue3 = atoi(row[43]); - entry.fog_minclip3 = static_cast(atof(row[44])); - entry.fog_maxclip3 = static_cast(atof(row[45])); - entry.fog_red4 = atoi(row[46]); - entry.fog_green4 = atoi(row[47]); - entry.fog_blue4 = atoi(row[48]); - entry.fog_minclip4 = static_cast(atof(row[49])); - entry.fog_maxclip4 = static_cast(atof(row[50])); - entry.fog_density = static_cast(atof(row[51])); - entry.flag_needed = row[52] ? row[52] : ""; - entry.canbind = atoi(row[53]); - entry.cancombat = atoi(row[54]); - entry.canlevitate = atoi(row[55]); - entry.castoutdoor = atoi(row[56]); - entry.hotzone = atoi(row[57]); - entry.insttype = atoi(row[58]); - entry.shutdowndelay = strtoll(row[59], nullptr, 10); - entry.peqzone = atoi(row[60]); - entry.suspendbuffs = atoi(row[61]); - entry.rain_chance1 = atoi(row[62]); - entry.rain_chance2 = atoi(row[63]); - entry.rain_chance3 = atoi(row[64]); - entry.rain_chance4 = atoi(row[65]); - entry.rain_duration1 = atoi(row[66]); - entry.rain_duration2 = atoi(row[67]); - entry.rain_duration3 = atoi(row[68]); - entry.rain_duration4 = atoi(row[69]); - entry.snow_chance1 = atoi(row[70]); - entry.snow_chance2 = atoi(row[71]); - entry.snow_chance3 = atoi(row[72]); - entry.snow_chance4 = atoi(row[73]); - entry.snow_duration1 = atoi(row[74]); - entry.snow_duration2 = atoi(row[75]); - entry.snow_duration3 = atoi(row[76]); - entry.snow_duration4 = atoi(row[77]); - entry.gravity = static_cast(atof(row[78])); - entry.type = atoi(row[79]); - entry.skylock = atoi(row[80]); - entry.fast_regen_hp = atoi(row[81]); - entry.fast_regen_mana = atoi(row[82]); - entry.fast_regen_endurance = atoi(row[83]); - entry.npc_max_aggro_dist = atoi(row[84]); - entry.max_movement_update_range = atoi(row[85]); - entry.min_expansion = atoi(row[86]); - entry.max_expansion = atoi(row[87]); - entry.content_flags = row[88] ? row[88] : ""; - entry.content_flags_disabled = row[89] ? row[89] : ""; - entry.underworld_teleport_index = atoi(row[90]); - entry.lava_damage = atoi(row[91]); - entry.min_lava_damage = atoi(row[92]); - entry.expansion = atoi(row[93]); + e.short_name = row[0] ? row[0] : ""; + e.id = atoi(row[1]); + e.file_name = row[2] ? row[2] : ""; + e.long_name = row[3] ? row[3] : ""; + e.map_file_name = row[4] ? row[4] : ""; + e.safe_x = static_cast(atof(row[5])); + e.safe_y = static_cast(atof(row[6])); + e.safe_z = static_cast(atof(row[7])); + e.safe_heading = static_cast(atof(row[8])); + e.graveyard_id = static_cast(atof(row[9])); + e.min_level = atoi(row[10]); + e.min_status = atoi(row[11]); + e.zoneidnumber = atoi(row[12]); + e.version = atoi(row[13]); + e.timezone = atoi(row[14]); + e.maxclients = atoi(row[15]); + e.ruleset = atoi(row[16]); + e.note = row[17] ? row[17] : ""; + e.underworld = static_cast(atof(row[18])); + e.minclip = static_cast(atof(row[19])); + e.maxclip = static_cast(atof(row[20])); + e.fog_minclip = static_cast(atof(row[21])); + e.fog_maxclip = static_cast(atof(row[22])); + e.fog_blue = atoi(row[23]); + e.fog_red = atoi(row[24]); + e.fog_green = atoi(row[25]); + e.sky = atoi(row[26]); + e.ztype = atoi(row[27]); + e.zone_exp_multiplier = static_cast(atof(row[28])); + e.walkspeed = static_cast(atof(row[29])); + e.time_type = atoi(row[30]); + e.fog_red1 = atoi(row[31]); + e.fog_green1 = atoi(row[32]); + e.fog_blue1 = atoi(row[33]); + e.fog_minclip1 = static_cast(atof(row[34])); + e.fog_maxclip1 = static_cast(atof(row[35])); + e.fog_red2 = atoi(row[36]); + e.fog_green2 = atoi(row[37]); + e.fog_blue2 = atoi(row[38]); + e.fog_minclip2 = static_cast(atof(row[39])); + e.fog_maxclip2 = static_cast(atof(row[40])); + e.fog_red3 = atoi(row[41]); + e.fog_green3 = atoi(row[42]); + e.fog_blue3 = atoi(row[43]); + e.fog_minclip3 = static_cast(atof(row[44])); + e.fog_maxclip3 = static_cast(atof(row[45])); + e.fog_red4 = atoi(row[46]); + e.fog_green4 = atoi(row[47]); + e.fog_blue4 = atoi(row[48]); + e.fog_minclip4 = static_cast(atof(row[49])); + e.fog_maxclip4 = static_cast(atof(row[50])); + e.fog_density = static_cast(atof(row[51])); + e.flag_needed = row[52] ? row[52] : ""; + e.canbind = atoi(row[53]); + e.cancombat = atoi(row[54]); + e.canlevitate = atoi(row[55]); + e.castoutdoor = atoi(row[56]); + e.hotzone = atoi(row[57]); + e.insttype = atoi(row[58]); + e.shutdowndelay = strtoll(row[59], nullptr, 10); + e.peqzone = atoi(row[60]); + e.suspendbuffs = atoi(row[61]); + e.rain_chance1 = atoi(row[62]); + e.rain_chance2 = atoi(row[63]); + e.rain_chance3 = atoi(row[64]); + e.rain_chance4 = atoi(row[65]); + e.rain_duration1 = atoi(row[66]); + e.rain_duration2 = atoi(row[67]); + e.rain_duration3 = atoi(row[68]); + e.rain_duration4 = atoi(row[69]); + e.snow_chance1 = atoi(row[70]); + e.snow_chance2 = atoi(row[71]); + e.snow_chance3 = atoi(row[72]); + e.snow_chance4 = atoi(row[73]); + e.snow_duration1 = atoi(row[74]); + e.snow_duration2 = atoi(row[75]); + e.snow_duration3 = atoi(row[76]); + e.snow_duration4 = atoi(row[77]); + e.gravity = static_cast(atof(row[78])); + e.type = atoi(row[79]); + e.skylock = atoi(row[80]); + e.fast_regen_hp = atoi(row[81]); + e.fast_regen_mana = atoi(row[82]); + e.fast_regen_endurance = atoi(row[83]); + e.npc_max_aggro_dist = atoi(row[84]); + e.max_movement_update_range = atoi(row[85]); + e.min_expansion = atoi(row[86]); + e.max_expansion = atoi(row[87]); + e.content_flags = row[88] ? row[88] : ""; + e.content_flags_disabled = row[89] ? row[89] : ""; + e.underworld_teleport_index = atoi(row[90]); + e.lava_damage = atoi(row[91]); + e.min_lava_damage = atoi(row[92]); + e.expansion = atoi(row[93]); - all_entries.push_back(entry); + all_entries.push_back(e); } return all_entries; } - static std::vector GetWhere(Database& db, std::string where_filter) + static std::vector GetWhere(Database& db, const std::string &where_filter) { std::vector all_entries; @@ -1093,110 +1093,110 @@ public: all_entries.reserve(results.RowCount()); for (auto row = results.begin(); row != results.end(); ++row) { - Zone entry{}; + Zone e{}; - entry.short_name = row[0] ? row[0] : ""; - entry.id = atoi(row[1]); - entry.file_name = row[2] ? row[2] : ""; - entry.long_name = row[3] ? row[3] : ""; - entry.map_file_name = row[4] ? row[4] : ""; - entry.safe_x = static_cast(atof(row[5])); - entry.safe_y = static_cast(atof(row[6])); - entry.safe_z = static_cast(atof(row[7])); - entry.safe_heading = static_cast(atof(row[8])); - entry.graveyard_id = static_cast(atof(row[9])); - entry.min_level = atoi(row[10]); - entry.min_status = atoi(row[11]); - entry.zoneidnumber = atoi(row[12]); - entry.version = atoi(row[13]); - entry.timezone = atoi(row[14]); - entry.maxclients = atoi(row[15]); - entry.ruleset = atoi(row[16]); - entry.note = row[17] ? row[17] : ""; - entry.underworld = static_cast(atof(row[18])); - entry.minclip = static_cast(atof(row[19])); - entry.maxclip = static_cast(atof(row[20])); - entry.fog_minclip = static_cast(atof(row[21])); - entry.fog_maxclip = static_cast(atof(row[22])); - entry.fog_blue = atoi(row[23]); - entry.fog_red = atoi(row[24]); - entry.fog_green = atoi(row[25]); - entry.sky = atoi(row[26]); - entry.ztype = atoi(row[27]); - entry.zone_exp_multiplier = static_cast(atof(row[28])); - entry.walkspeed = static_cast(atof(row[29])); - entry.time_type = atoi(row[30]); - entry.fog_red1 = atoi(row[31]); - entry.fog_green1 = atoi(row[32]); - entry.fog_blue1 = atoi(row[33]); - entry.fog_minclip1 = static_cast(atof(row[34])); - entry.fog_maxclip1 = static_cast(atof(row[35])); - entry.fog_red2 = atoi(row[36]); - entry.fog_green2 = atoi(row[37]); - entry.fog_blue2 = atoi(row[38]); - entry.fog_minclip2 = static_cast(atof(row[39])); - entry.fog_maxclip2 = static_cast(atof(row[40])); - entry.fog_red3 = atoi(row[41]); - entry.fog_green3 = atoi(row[42]); - entry.fog_blue3 = atoi(row[43]); - entry.fog_minclip3 = static_cast(atof(row[44])); - entry.fog_maxclip3 = static_cast(atof(row[45])); - entry.fog_red4 = atoi(row[46]); - entry.fog_green4 = atoi(row[47]); - entry.fog_blue4 = atoi(row[48]); - entry.fog_minclip4 = static_cast(atof(row[49])); - entry.fog_maxclip4 = static_cast(atof(row[50])); - entry.fog_density = static_cast(atof(row[51])); - entry.flag_needed = row[52] ? row[52] : ""; - entry.canbind = atoi(row[53]); - entry.cancombat = atoi(row[54]); - entry.canlevitate = atoi(row[55]); - entry.castoutdoor = atoi(row[56]); - entry.hotzone = atoi(row[57]); - entry.insttype = atoi(row[58]); - entry.shutdowndelay = strtoll(row[59], nullptr, 10); - entry.peqzone = atoi(row[60]); - entry.suspendbuffs = atoi(row[61]); - entry.rain_chance1 = atoi(row[62]); - entry.rain_chance2 = atoi(row[63]); - entry.rain_chance3 = atoi(row[64]); - entry.rain_chance4 = atoi(row[65]); - entry.rain_duration1 = atoi(row[66]); - entry.rain_duration2 = atoi(row[67]); - entry.rain_duration3 = atoi(row[68]); - entry.rain_duration4 = atoi(row[69]); - entry.snow_chance1 = atoi(row[70]); - entry.snow_chance2 = atoi(row[71]); - entry.snow_chance3 = atoi(row[72]); - entry.snow_chance4 = atoi(row[73]); - entry.snow_duration1 = atoi(row[74]); - entry.snow_duration2 = atoi(row[75]); - entry.snow_duration3 = atoi(row[76]); - entry.snow_duration4 = atoi(row[77]); - entry.gravity = static_cast(atof(row[78])); - entry.type = atoi(row[79]); - entry.skylock = atoi(row[80]); - entry.fast_regen_hp = atoi(row[81]); - entry.fast_regen_mana = atoi(row[82]); - entry.fast_regen_endurance = atoi(row[83]); - entry.npc_max_aggro_dist = atoi(row[84]); - entry.max_movement_update_range = atoi(row[85]); - entry.min_expansion = atoi(row[86]); - entry.max_expansion = atoi(row[87]); - entry.content_flags = row[88] ? row[88] : ""; - entry.content_flags_disabled = row[89] ? row[89] : ""; - entry.underworld_teleport_index = atoi(row[90]); - entry.lava_damage = atoi(row[91]); - entry.min_lava_damage = atoi(row[92]); - entry.expansion = atoi(row[93]); + e.short_name = row[0] ? row[0] : ""; + e.id = atoi(row[1]); + e.file_name = row[2] ? row[2] : ""; + e.long_name = row[3] ? row[3] : ""; + e.map_file_name = row[4] ? row[4] : ""; + e.safe_x = static_cast(atof(row[5])); + e.safe_y = static_cast(atof(row[6])); + e.safe_z = static_cast(atof(row[7])); + e.safe_heading = static_cast(atof(row[8])); + e.graveyard_id = static_cast(atof(row[9])); + e.min_level = atoi(row[10]); + e.min_status = atoi(row[11]); + e.zoneidnumber = atoi(row[12]); + e.version = atoi(row[13]); + e.timezone = atoi(row[14]); + e.maxclients = atoi(row[15]); + e.ruleset = atoi(row[16]); + e.note = row[17] ? row[17] : ""; + e.underworld = static_cast(atof(row[18])); + e.minclip = static_cast(atof(row[19])); + e.maxclip = static_cast(atof(row[20])); + e.fog_minclip = static_cast(atof(row[21])); + e.fog_maxclip = static_cast(atof(row[22])); + e.fog_blue = atoi(row[23]); + e.fog_red = atoi(row[24]); + e.fog_green = atoi(row[25]); + e.sky = atoi(row[26]); + e.ztype = atoi(row[27]); + e.zone_exp_multiplier = static_cast(atof(row[28])); + e.walkspeed = static_cast(atof(row[29])); + e.time_type = atoi(row[30]); + e.fog_red1 = atoi(row[31]); + e.fog_green1 = atoi(row[32]); + e.fog_blue1 = atoi(row[33]); + e.fog_minclip1 = static_cast(atof(row[34])); + e.fog_maxclip1 = static_cast(atof(row[35])); + e.fog_red2 = atoi(row[36]); + e.fog_green2 = atoi(row[37]); + e.fog_blue2 = atoi(row[38]); + e.fog_minclip2 = static_cast(atof(row[39])); + e.fog_maxclip2 = static_cast(atof(row[40])); + e.fog_red3 = atoi(row[41]); + e.fog_green3 = atoi(row[42]); + e.fog_blue3 = atoi(row[43]); + e.fog_minclip3 = static_cast(atof(row[44])); + e.fog_maxclip3 = static_cast(atof(row[45])); + e.fog_red4 = atoi(row[46]); + e.fog_green4 = atoi(row[47]); + e.fog_blue4 = atoi(row[48]); + e.fog_minclip4 = static_cast(atof(row[49])); + e.fog_maxclip4 = static_cast(atof(row[50])); + e.fog_density = static_cast(atof(row[51])); + e.flag_needed = row[52] ? row[52] : ""; + e.canbind = atoi(row[53]); + e.cancombat = atoi(row[54]); + e.canlevitate = atoi(row[55]); + e.castoutdoor = atoi(row[56]); + e.hotzone = atoi(row[57]); + e.insttype = atoi(row[58]); + e.shutdowndelay = strtoll(row[59], nullptr, 10); + e.peqzone = atoi(row[60]); + e.suspendbuffs = atoi(row[61]); + e.rain_chance1 = atoi(row[62]); + e.rain_chance2 = atoi(row[63]); + e.rain_chance3 = atoi(row[64]); + e.rain_chance4 = atoi(row[65]); + e.rain_duration1 = atoi(row[66]); + e.rain_duration2 = atoi(row[67]); + e.rain_duration3 = atoi(row[68]); + e.rain_duration4 = atoi(row[69]); + e.snow_chance1 = atoi(row[70]); + e.snow_chance2 = atoi(row[71]); + e.snow_chance3 = atoi(row[72]); + e.snow_chance4 = atoi(row[73]); + e.snow_duration1 = atoi(row[74]); + e.snow_duration2 = atoi(row[75]); + e.snow_duration3 = atoi(row[76]); + e.snow_duration4 = atoi(row[77]); + e.gravity = static_cast(atof(row[78])); + e.type = atoi(row[79]); + e.skylock = atoi(row[80]); + e.fast_regen_hp = atoi(row[81]); + e.fast_regen_mana = atoi(row[82]); + e.fast_regen_endurance = atoi(row[83]); + e.npc_max_aggro_dist = atoi(row[84]); + e.max_movement_update_range = atoi(row[85]); + e.min_expansion = atoi(row[86]); + e.max_expansion = atoi(row[87]); + e.content_flags = row[88] ? row[88] : ""; + e.content_flags_disabled = row[89] ? row[89] : ""; + e.underworld_teleport_index = atoi(row[90]); + e.lava_damage = atoi(row[91]); + e.min_lava_damage = atoi(row[92]); + e.expansion = atoi(row[93]); - all_entries.push_back(entry); + all_entries.push_back(e); } return all_entries; } - static int DeleteWhere(Database& db, std::string where_filter) + static int DeleteWhere(Database& db, const std::string &where_filter) { auto results = db.QueryDatabase( fmt::format( @@ -1221,6 +1221,32 @@ public: 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); + } + }; #endif //EQEMU_BASE_ZONE_REPOSITORY_H diff --git a/common/repositories/base_data_repository.h b/common/repositories/base_data_repository.h index e9958a1d6..85e696b04 100644 --- a/common/repositories/base_data_repository.h +++ b/common/repositories/base_data_repository.h @@ -1,23 +1,3 @@ -/** - * EQEmulator: Everquest Server Emulator - * Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server) - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 2 of the License. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY except by those people which sell it, which - * are required to give you total support for your newly bought product; - * without even the implied warranty of MERCHANTABILITY or FITNESS FOR - * A PARTICULAR PURPOSE. See the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - #ifndef EQEMU_BASE_DATA_REPOSITORY_H #define EQEMU_BASE_DATA_REPOSITORY_H diff --git a/common/repositories/blocked_spells_repository.h b/common/repositories/blocked_spells_repository.h index bb6494bd0..b5d669df2 100644 --- a/common/repositories/blocked_spells_repository.h +++ b/common/repositories/blocked_spells_repository.h @@ -1,23 +1,3 @@ -/** - * EQEmulator: Everquest Server Emulator - * Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server) - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 2 of the License. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY except by those people which sell it, which - * are required to give you total support for your newly bought product; - * without even the implied warranty of MERCHANTABILITY or FITNESS FOR - * A PARTICULAR PURPOSE. See the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - #ifndef EQEMU_BLOCKED_SPELLS_REPOSITORY_H #define EQEMU_BLOCKED_SPELLS_REPOSITORY_H diff --git a/common/repositories/books_repository.h b/common/repositories/books_repository.h index 8a3b70162..d174e9194 100644 --- a/common/repositories/books_repository.h +++ b/common/repositories/books_repository.h @@ -1,23 +1,3 @@ -/** - * EQEmulator: Everquest Server Emulator - * Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server) - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 2 of the License. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY except by those people which sell it, which - * are required to give you total support for your newly bought product; - * without even the implied warranty of MERCHANTABILITY or FITNESS FOR - * A PARTICULAR PURPOSE. See the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - #ifndef EQEMU_BOOKS_REPOSITORY_H #define EQEMU_BOOKS_REPOSITORY_H diff --git a/common/repositories/bug_reports_repository.h b/common/repositories/bug_reports_repository.h index cc35f11be..a6f622d28 100644 --- a/common/repositories/bug_reports_repository.h +++ b/common/repositories/bug_reports_repository.h @@ -1,23 +1,3 @@ -/** - * EQEmulator: Everquest Server Emulator - * Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server) - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 2 of the License. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY except by those people which sell it, which - * are required to give you total support for your newly bought product; - * without even the implied warranty of MERCHANTABILITY or FITNESS FOR - * A PARTICULAR PURPOSE. See the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - #ifndef EQEMU_BUG_REPORTS_REPOSITORY_H #define EQEMU_BUG_REPORTS_REPOSITORY_H diff --git a/common/repositories/bugs_repository.h b/common/repositories/bugs_repository.h index 62332a462..f55d88658 100644 --- a/common/repositories/bugs_repository.h +++ b/common/repositories/bugs_repository.h @@ -1,23 +1,3 @@ -/** - * EQEmulator: Everquest Server Emulator - * Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server) - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 2 of the License. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY except by those people which sell it, which - * are required to give you total support for your newly bought product; - * without even the implied warranty of MERCHANTABILITY or FITNESS FOR - * A PARTICULAR PURPOSE. See the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - #ifndef EQEMU_BUGS_REPOSITORY_H #define EQEMU_BUGS_REPOSITORY_H diff --git a/common/repositories/buyer_repository.h b/common/repositories/buyer_repository.h index e2685deef..7c3b39840 100644 --- a/common/repositories/buyer_repository.h +++ b/common/repositories/buyer_repository.h @@ -1,23 +1,3 @@ -/** - * EQEmulator: Everquest Server Emulator - * Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server) - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 2 of the License. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY except by those people which sell it, which - * are required to give you total support for your newly bought product; - * without even the implied warranty of MERCHANTABILITY or FITNESS FOR - * A PARTICULAR PURPOSE. See the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - #ifndef EQEMU_BUYER_REPOSITORY_H #define EQEMU_BUYER_REPOSITORY_H diff --git a/common/repositories/char_create_combinations_repository.h b/common/repositories/char_create_combinations_repository.h index 6257f5d8c..42baebb02 100644 --- a/common/repositories/char_create_combinations_repository.h +++ b/common/repositories/char_create_combinations_repository.h @@ -1,23 +1,3 @@ -/** - * EQEmulator: Everquest Server Emulator - * Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server) - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 2 of the License. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY except by those people which sell it, which - * are required to give you total support for your newly bought product; - * without even the implied warranty of MERCHANTABILITY or FITNESS FOR - * A PARTICULAR PURPOSE. See the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - #ifndef EQEMU_CHAR_CREATE_COMBINATIONS_REPOSITORY_H #define EQEMU_CHAR_CREATE_COMBINATIONS_REPOSITORY_H diff --git a/common/repositories/char_create_point_allocations_repository.h b/common/repositories/char_create_point_allocations_repository.h index 9b8da7603..8828d2521 100644 --- a/common/repositories/char_create_point_allocations_repository.h +++ b/common/repositories/char_create_point_allocations_repository.h @@ -1,23 +1,3 @@ -/** - * EQEmulator: Everquest Server Emulator - * Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server) - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 2 of the License. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY except by those people which sell it, which - * are required to give you total support for your newly bought product; - * without even the implied warranty of MERCHANTABILITY or FITNESS FOR - * A PARTICULAR PURPOSE. See the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - #ifndef EQEMU_CHAR_CREATE_POINT_ALLOCATIONS_REPOSITORY_H #define EQEMU_CHAR_CREATE_POINT_ALLOCATIONS_REPOSITORY_H diff --git a/common/repositories/char_recipe_list_repository.h b/common/repositories/char_recipe_list_repository.h index c800e36e0..82e5f78f7 100644 --- a/common/repositories/char_recipe_list_repository.h +++ b/common/repositories/char_recipe_list_repository.h @@ -1,23 +1,3 @@ -/** - * EQEmulator: Everquest Server Emulator - * Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server) - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 2 of the License. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY except by those people which sell it, which - * are required to give you total support for your newly bought product; - * without even the implied warranty of MERCHANTABILITY or FITNESS FOR - * A PARTICULAR PURPOSE. See the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - #ifndef EQEMU_CHAR_RECIPE_LIST_REPOSITORY_H #define EQEMU_CHAR_RECIPE_LIST_REPOSITORY_H diff --git a/common/repositories/character_activities_repository.h b/common/repositories/character_activities_repository.h index 3bc20c040..420548887 100644 --- a/common/repositories/character_activities_repository.h +++ b/common/repositories/character_activities_repository.h @@ -1,23 +1,3 @@ -/** - * EQEmulator: Everquest Server Emulator - * Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server) - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 2 of the License. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY except by those people which sell it, which - * are required to give you total support for your newly bought product; - * without even the implied warranty of MERCHANTABILITY or FITNESS FOR - * A PARTICULAR PURPOSE. See the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - #ifndef EQEMU_CHARACTER_ACTIVITIES_REPOSITORY_H #define EQEMU_CHARACTER_ACTIVITIES_REPOSITORY_H diff --git a/common/repositories/character_alt_currency_repository.h b/common/repositories/character_alt_currency_repository.h index 2f15074f5..1ef74dd58 100644 --- a/common/repositories/character_alt_currency_repository.h +++ b/common/repositories/character_alt_currency_repository.h @@ -1,23 +1,3 @@ -/** - * EQEmulator: Everquest Server Emulator - * Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server) - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 2 of the License. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY except by those people which sell it, which - * are required to give you total support for your newly bought product; - * without even the implied warranty of MERCHANTABILITY or FITNESS FOR - * A PARTICULAR PURPOSE. See the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - #ifndef EQEMU_CHARACTER_ALT_CURRENCY_REPOSITORY_H #define EQEMU_CHARACTER_ALT_CURRENCY_REPOSITORY_H diff --git a/common/repositories/character_alternate_abilities_repository.h b/common/repositories/character_alternate_abilities_repository.h index d14946a21..d3514c91f 100644 --- a/common/repositories/character_alternate_abilities_repository.h +++ b/common/repositories/character_alternate_abilities_repository.h @@ -1,23 +1,3 @@ -/** - * EQEmulator: Everquest Server Emulator - * Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server) - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 2 of the License. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY except by those people which sell it, which - * are required to give you total support for your newly bought product; - * without even the implied warranty of MERCHANTABILITY or FITNESS FOR - * A PARTICULAR PURPOSE. See the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - #ifndef EQEMU_CHARACTER_ALTERNATE_ABILITIES_REPOSITORY_H #define EQEMU_CHARACTER_ALTERNATE_ABILITIES_REPOSITORY_H diff --git a/common/repositories/character_auras_repository.h b/common/repositories/character_auras_repository.h index 5853f91d0..f03154a3b 100644 --- a/common/repositories/character_auras_repository.h +++ b/common/repositories/character_auras_repository.h @@ -1,23 +1,3 @@ -/** - * EQEmulator: Everquest Server Emulator - * Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server) - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 2 of the License. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY except by those people which sell it, which - * are required to give you total support for your newly bought product; - * without even the implied warranty of MERCHANTABILITY or FITNESS FOR - * A PARTICULAR PURPOSE. See the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - #ifndef EQEMU_CHARACTER_AURAS_REPOSITORY_H #define EQEMU_CHARACTER_AURAS_REPOSITORY_H diff --git a/common/repositories/character_bandolier_repository.h b/common/repositories/character_bandolier_repository.h index e7ca1d8e5..ff2a6dcc0 100644 --- a/common/repositories/character_bandolier_repository.h +++ b/common/repositories/character_bandolier_repository.h @@ -1,23 +1,3 @@ -/** - * EQEmulator: Everquest Server Emulator - * Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server) - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 2 of the License. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY except by those people which sell it, which - * are required to give you total support for your newly bought product; - * without even the implied warranty of MERCHANTABILITY or FITNESS FOR - * A PARTICULAR PURPOSE. See the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - #ifndef EQEMU_CHARACTER_BANDOLIER_REPOSITORY_H #define EQEMU_CHARACTER_BANDOLIER_REPOSITORY_H diff --git a/common/repositories/character_bind_repository.h b/common/repositories/character_bind_repository.h index 7e5834073..a78bef415 100644 --- a/common/repositories/character_bind_repository.h +++ b/common/repositories/character_bind_repository.h @@ -1,23 +1,3 @@ -/** - * EQEmulator: Everquest Server Emulator - * Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server) - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 2 of the License. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY except by those people which sell it, which - * are required to give you total support for your newly bought product; - * without even the implied warranty of MERCHANTABILITY or FITNESS FOR - * A PARTICULAR PURPOSE. See the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - #ifndef EQEMU_CHARACTER_BIND_REPOSITORY_H #define EQEMU_CHARACTER_BIND_REPOSITORY_H diff --git a/common/repositories/character_buffs_repository.h b/common/repositories/character_buffs_repository.h index f438cc399..92a81fe05 100644 --- a/common/repositories/character_buffs_repository.h +++ b/common/repositories/character_buffs_repository.h @@ -1,23 +1,3 @@ -/** - * EQEmulator: Everquest Server Emulator - * Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server) - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 2 of the License. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY except by those people which sell it, which - * are required to give you total support for your newly bought product; - * without even the implied warranty of MERCHANTABILITY or FITNESS FOR - * A PARTICULAR PURPOSE. See the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - #ifndef EQEMU_CHARACTER_BUFFS_REPOSITORY_H #define EQEMU_CHARACTER_BUFFS_REPOSITORY_H diff --git a/common/repositories/character_corpse_items_repository.h b/common/repositories/character_corpse_items_repository.h index 45f22beab..1a0352d8f 100644 --- a/common/repositories/character_corpse_items_repository.h +++ b/common/repositories/character_corpse_items_repository.h @@ -1,23 +1,3 @@ -/** - * EQEmulator: Everquest Server Emulator - * Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server) - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 2 of the License. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY except by those people which sell it, which - * are required to give you total support for your newly bought product; - * without even the implied warranty of MERCHANTABILITY or FITNESS FOR - * A PARTICULAR PURPOSE. See the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - #ifndef EQEMU_CHARACTER_CORPSE_ITEMS_REPOSITORY_H #define EQEMU_CHARACTER_CORPSE_ITEMS_REPOSITORY_H diff --git a/common/repositories/character_corpses_repository.h b/common/repositories/character_corpses_repository.h index 846b58a6a..23ce382c8 100644 --- a/common/repositories/character_corpses_repository.h +++ b/common/repositories/character_corpses_repository.h @@ -1,23 +1,3 @@ -/** - * EQEmulator: Everquest Server Emulator - * Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server) - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 2 of the License. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY except by those people which sell it, which - * are required to give you total support for your newly bought product; - * without even the implied warranty of MERCHANTABILITY or FITNESS FOR - * A PARTICULAR PURPOSE. See the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - #ifndef EQEMU_CHARACTER_CORPSES_REPOSITORY_H #define EQEMU_CHARACTER_CORPSES_REPOSITORY_H diff --git a/common/repositories/character_currency_repository.h b/common/repositories/character_currency_repository.h index 26bb90402..833e6cbf2 100644 --- a/common/repositories/character_currency_repository.h +++ b/common/repositories/character_currency_repository.h @@ -1,23 +1,3 @@ -/** - * EQEmulator: Everquest Server Emulator - * Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server) - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 2 of the License. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY except by those people which sell it, which - * are required to give you total support for your newly bought product; - * without even the implied warranty of MERCHANTABILITY or FITNESS FOR - * A PARTICULAR PURPOSE. See the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - #ifndef EQEMU_CHARACTER_CURRENCY_REPOSITORY_H #define EQEMU_CHARACTER_CURRENCY_REPOSITORY_H diff --git a/common/repositories/character_data_repository.h b/common/repositories/character_data_repository.h index c6c4708ab..f527e5537 100644 --- a/common/repositories/character_data_repository.h +++ b/common/repositories/character_data_repository.h @@ -1,23 +1,3 @@ -/** - * EQEmulator: Everquest Server Emulator - * Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server) - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 2 of the License. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY except by those people which sell it, which - * are required to give you total support for your newly bought product; - * without even the implied warranty of MERCHANTABILITY or FITNESS FOR - * A PARTICULAR PURPOSE. See the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - #ifndef EQEMU_CHARACTER_DATA_REPOSITORY_H #define EQEMU_CHARACTER_DATA_REPOSITORY_H diff --git a/common/repositories/character_disciplines_repository.h b/common/repositories/character_disciplines_repository.h index 686b287de..a6a0ff225 100644 --- a/common/repositories/character_disciplines_repository.h +++ b/common/repositories/character_disciplines_repository.h @@ -1,23 +1,3 @@ -/** - * EQEmulator: Everquest Server Emulator - * Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server) - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 2 of the License. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY except by those people which sell it, which - * are required to give you total support for your newly bought product; - * without even the implied warranty of MERCHANTABILITY or FITNESS FOR - * A PARTICULAR PURPOSE. See the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - #ifndef EQEMU_CHARACTER_DISCIPLINES_REPOSITORY_H #define EQEMU_CHARACTER_DISCIPLINES_REPOSITORY_H diff --git a/common/repositories/character_exp_modifiers_repository.h b/common/repositories/character_exp_modifiers_repository.h index 7de006fa6..d94fe79ff 100644 --- a/common/repositories/character_exp_modifiers_repository.h +++ b/common/repositories/character_exp_modifiers_repository.h @@ -1,23 +1,3 @@ -/** - * EQEmulator: Everquest Server Emulator - * Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server) - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 2 of the License. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY except by those people which sell it, which - * are required to give you total support for your newly bought product; - * without even the implied warranty of MERCHANTABILITY or FITNESS FOR - * A PARTICULAR PURPOSE. See the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - #ifndef EQEMU_CHARACTER_EXP_MODIFIERS_REPOSITORY_H #define EQEMU_CHARACTER_EXP_MODIFIERS_REPOSITORY_H diff --git a/common/repositories/character_expedition_lockouts_repository.h b/common/repositories/character_expedition_lockouts_repository.h index e4caa277d..af5040c43 100644 --- a/common/repositories/character_expedition_lockouts_repository.h +++ b/common/repositories/character_expedition_lockouts_repository.h @@ -1,23 +1,3 @@ -/** - * EQEmulator: Everquest Server Emulator - * Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server) - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 2 of the License. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY except by those people which sell it, which - * are required to give you total support for your newly bought product; - * without even the implied warranty of MERCHANTABILITY or FITNESS FOR - * A PARTICULAR PURPOSE. See the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - #ifndef EQEMU_CHARACTER_EXPEDITION_LOCKOUTS_REPOSITORY_H #define EQEMU_CHARACTER_EXPEDITION_LOCKOUTS_REPOSITORY_H diff --git a/common/repositories/character_inspect_messages_repository.h b/common/repositories/character_inspect_messages_repository.h index f9c00cadf..b3c8b5cbc 100644 --- a/common/repositories/character_inspect_messages_repository.h +++ b/common/repositories/character_inspect_messages_repository.h @@ -1,23 +1,3 @@ -/** - * EQEmulator: Everquest Server Emulator - * Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server) - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 2 of the License. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY except by those people which sell it, which - * are required to give you total support for your newly bought product; - * without even the implied warranty of MERCHANTABILITY or FITNESS FOR - * A PARTICULAR PURPOSE. See the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - #ifndef EQEMU_CHARACTER_INSPECT_MESSAGES_REPOSITORY_H #define EQEMU_CHARACTER_INSPECT_MESSAGES_REPOSITORY_H diff --git a/common/repositories/character_instance_safereturns_repository.h b/common/repositories/character_instance_safereturns_repository.h index 1b03986b1..681f4f6ad 100644 --- a/common/repositories/character_instance_safereturns_repository.h +++ b/common/repositories/character_instance_safereturns_repository.h @@ -1,23 +1,3 @@ -/** - * EQEmulator: Everquest Server Emulator - * Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server) - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 2 of the License. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY except by those people which sell it, which - * are required to give you total support for your newly bought product; - * without even the implied warranty of MERCHANTABILITY or FITNESS FOR - * A PARTICULAR PURPOSE. See the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - #ifndef EQEMU_CHARACTER_INSTANCE_SAFERETURNS_REPOSITORY_H #define EQEMU_CHARACTER_INSTANCE_SAFERETURNS_REPOSITORY_H diff --git a/common/repositories/character_item_recast_repository.h b/common/repositories/character_item_recast_repository.h index b41848689..35a36559d 100644 --- a/common/repositories/character_item_recast_repository.h +++ b/common/repositories/character_item_recast_repository.h @@ -1,23 +1,3 @@ -/** - * EQEmulator: Everquest Server Emulator - * Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server) - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 2 of the License. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY except by those people which sell it, which - * are required to give you total support for your newly bought product; - * without even the implied warranty of MERCHANTABILITY or FITNESS FOR - * A PARTICULAR PURPOSE. See the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - #ifndef EQEMU_CHARACTER_ITEM_RECAST_REPOSITORY_H #define EQEMU_CHARACTER_ITEM_RECAST_REPOSITORY_H diff --git a/common/repositories/character_languages_repository.h b/common/repositories/character_languages_repository.h index 28196e950..b4b866666 100644 --- a/common/repositories/character_languages_repository.h +++ b/common/repositories/character_languages_repository.h @@ -1,23 +1,3 @@ -/** - * EQEmulator: Everquest Server Emulator - * Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server) - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 2 of the License. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY except by those people which sell it, which - * are required to give you total support for your newly bought product; - * without even the implied warranty of MERCHANTABILITY or FITNESS FOR - * A PARTICULAR PURPOSE. See the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - #ifndef EQEMU_CHARACTER_LANGUAGES_REPOSITORY_H #define EQEMU_CHARACTER_LANGUAGES_REPOSITORY_H diff --git a/common/repositories/character_leadership_abilities_repository.h b/common/repositories/character_leadership_abilities_repository.h index 44b2c0da0..5f688d9d5 100644 --- a/common/repositories/character_leadership_abilities_repository.h +++ b/common/repositories/character_leadership_abilities_repository.h @@ -1,23 +1,3 @@ -/** - * EQEmulator: Everquest Server Emulator - * Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server) - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 2 of the License. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY except by those people which sell it, which - * are required to give you total support for your newly bought product; - * without even the implied warranty of MERCHANTABILITY or FITNESS FOR - * A PARTICULAR PURPOSE. See the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - #ifndef EQEMU_CHARACTER_LEADERSHIP_ABILITIES_REPOSITORY_H #define EQEMU_CHARACTER_LEADERSHIP_ABILITIES_REPOSITORY_H diff --git a/common/repositories/character_material_repository.h b/common/repositories/character_material_repository.h index 08f445d0a..eb5989025 100644 --- a/common/repositories/character_material_repository.h +++ b/common/repositories/character_material_repository.h @@ -1,23 +1,3 @@ -/** - * EQEmulator: Everquest Server Emulator - * Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server) - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 2 of the License. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY except by those people which sell it, which - * are required to give you total support for your newly bought product; - * without even the implied warranty of MERCHANTABILITY or FITNESS FOR - * A PARTICULAR PURPOSE. See the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - #ifndef EQEMU_CHARACTER_MATERIAL_REPOSITORY_H #define EQEMU_CHARACTER_MATERIAL_REPOSITORY_H diff --git a/common/repositories/character_memmed_spells_repository.h b/common/repositories/character_memmed_spells_repository.h index 373ea27f2..cdf5cc5f0 100644 --- a/common/repositories/character_memmed_spells_repository.h +++ b/common/repositories/character_memmed_spells_repository.h @@ -1,23 +1,3 @@ -/** - * EQEmulator: Everquest Server Emulator - * Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server) - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 2 of the License. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY except by those people which sell it, which - * are required to give you total support for your newly bought product; - * without even the implied warranty of MERCHANTABILITY or FITNESS FOR - * A PARTICULAR PURPOSE. See the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - #ifndef EQEMU_CHARACTER_MEMMED_SPELLS_REPOSITORY_H #define EQEMU_CHARACTER_MEMMED_SPELLS_REPOSITORY_H diff --git a/common/repositories/character_peqzone_flags_repository.h b/common/repositories/character_peqzone_flags_repository.h new file mode 100644 index 000000000..9cd3cf80c --- /dev/null +++ b/common/repositories/character_peqzone_flags_repository.h @@ -0,0 +1,50 @@ +#ifndef EQEMU_CHARACTER_PEQZONE_FLAGS_REPOSITORY_H +#define EQEMU_CHARACTER_PEQZONE_FLAGS_REPOSITORY_H + +#include "../database.h" +#include "../strings.h" +#include "base/base_character_peqzone_flags_repository.h" + +class CharacterPeqzoneFlagsRepository: public BaseCharacterPeqzoneFlagsRepository { +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 + * + * CharacterPeqzoneFlagsRepository::GetByZoneAndVersion(int zone_id, int zone_version) + * CharacterPeqzoneFlagsRepository::GetWhereNeverExpires() + * CharacterPeqzoneFlagsRepository::GetWhereXAndY() + * CharacterPeqzoneFlagsRepository::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_CHARACTER_PEQZONE_FLAGS_REPOSITORY_H diff --git a/common/repositories/character_pet_buffs_repository.h b/common/repositories/character_pet_buffs_repository.h index c65023532..b5ed82c63 100644 --- a/common/repositories/character_pet_buffs_repository.h +++ b/common/repositories/character_pet_buffs_repository.h @@ -1,23 +1,3 @@ -/** - * EQEmulator: Everquest Server Emulator - * Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server) - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 2 of the License. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY except by those people which sell it, which - * are required to give you total support for your newly bought product; - * without even the implied warranty of MERCHANTABILITY or FITNESS FOR - * A PARTICULAR PURPOSE. See the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - #ifndef EQEMU_CHARACTER_PET_BUFFS_REPOSITORY_H #define EQEMU_CHARACTER_PET_BUFFS_REPOSITORY_H diff --git a/common/repositories/character_pet_info_repository.h b/common/repositories/character_pet_info_repository.h index 046e4a4fd..45c4f2854 100644 --- a/common/repositories/character_pet_info_repository.h +++ b/common/repositories/character_pet_info_repository.h @@ -1,23 +1,3 @@ -/** - * EQEmulator: Everquest Server Emulator - * Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server) - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 2 of the License. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY except by those people which sell it, which - * are required to give you total support for your newly bought product; - * without even the implied warranty of MERCHANTABILITY or FITNESS FOR - * A PARTICULAR PURPOSE. See the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - #ifndef EQEMU_CHARACTER_PET_INFO_REPOSITORY_H #define EQEMU_CHARACTER_PET_INFO_REPOSITORY_H diff --git a/common/repositories/character_pet_inventory_repository.h b/common/repositories/character_pet_inventory_repository.h index 2ebf8ee85..21fb5c362 100644 --- a/common/repositories/character_pet_inventory_repository.h +++ b/common/repositories/character_pet_inventory_repository.h @@ -1,23 +1,3 @@ -/** - * EQEmulator: Everquest Server Emulator - * Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server) - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 2 of the License. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY except by those people which sell it, which - * are required to give you total support for your newly bought product; - * without even the implied warranty of MERCHANTABILITY or FITNESS FOR - * A PARTICULAR PURPOSE. See the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - #ifndef EQEMU_CHARACTER_PET_INVENTORY_REPOSITORY_H #define EQEMU_CHARACTER_PET_INVENTORY_REPOSITORY_H diff --git a/common/repositories/character_potionbelt_repository.h b/common/repositories/character_potionbelt_repository.h index 7649086fe..1a69e6711 100644 --- a/common/repositories/character_potionbelt_repository.h +++ b/common/repositories/character_potionbelt_repository.h @@ -1,23 +1,3 @@ -/** - * EQEmulator: Everquest Server Emulator - * Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server) - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 2 of the License. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY except by those people which sell it, which - * are required to give you total support for your newly bought product; - * without even the implied warranty of MERCHANTABILITY or FITNESS FOR - * A PARTICULAR PURPOSE. See the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - #ifndef EQEMU_CHARACTER_POTIONBELT_REPOSITORY_H #define EQEMU_CHARACTER_POTIONBELT_REPOSITORY_H diff --git a/common/repositories/character_recipe_list_repository.h b/common/repositories/character_recipe_list_repository.h index 5edbfd6ea..74b607330 100644 --- a/common/repositories/character_recipe_list_repository.h +++ b/common/repositories/character_recipe_list_repository.h @@ -1,23 +1,3 @@ -/** - * EQEmulator: Everquest Server Emulator - * Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server) - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 2 of the License. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY except by those people which sell it, which - * are required to give you total support for your newly bought product; - * without even the implied warranty of MERCHANTABILITY or FITNESS FOR - * A PARTICULAR PURPOSE. See the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - #ifndef EQEMU_CHARACTER_RECIPE_LIST_REPOSITORY_H #define EQEMU_CHARACTER_RECIPE_LIST_REPOSITORY_H diff --git a/common/repositories/character_skills_repository.h b/common/repositories/character_skills_repository.h index 271a0127b..c8c60e104 100644 --- a/common/repositories/character_skills_repository.h +++ b/common/repositories/character_skills_repository.h @@ -1,23 +1,3 @@ -/** - * EQEmulator: Everquest Server Emulator - * Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server) - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 2 of the License. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY except by those people which sell it, which - * are required to give you total support for your newly bought product; - * without even the implied warranty of MERCHANTABILITY or FITNESS FOR - * A PARTICULAR PURPOSE. See the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - #ifndef EQEMU_CHARACTER_SKILLS_REPOSITORY_H #define EQEMU_CHARACTER_SKILLS_REPOSITORY_H diff --git a/common/repositories/character_spells_repository.h b/common/repositories/character_spells_repository.h index 1a00797e6..81c3f9697 100644 --- a/common/repositories/character_spells_repository.h +++ b/common/repositories/character_spells_repository.h @@ -1,23 +1,3 @@ -/** - * EQEmulator: Everquest Server Emulator - * Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server) - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 2 of the License. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY except by those people which sell it, which - * are required to give you total support for your newly bought product; - * without even the implied warranty of MERCHANTABILITY or FITNESS FOR - * A PARTICULAR PURPOSE. See the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - #ifndef EQEMU_CHARACTER_SPELLS_REPOSITORY_H #define EQEMU_CHARACTER_SPELLS_REPOSITORY_H diff --git a/common/repositories/character_task_timers_repository.h b/common/repositories/character_task_timers_repository.h index 5bd0730e2..4b153cd01 100644 --- a/common/repositories/character_task_timers_repository.h +++ b/common/repositories/character_task_timers_repository.h @@ -1,23 +1,3 @@ -/** - * EQEmulator: Everquest Server Emulator - * Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server) - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 2 of the License. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY except by those people which sell it, which - * are required to give you total support for your newly bought product; - * without even the implied warranty of MERCHANTABILITY or FITNESS FOR - * A PARTICULAR PURPOSE. See the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - #ifndef EQEMU_CHARACTER_TASK_TIMERS_REPOSITORY_H #define EQEMU_CHARACTER_TASK_TIMERS_REPOSITORY_H diff --git a/common/repositories/character_tasks_repository.h b/common/repositories/character_tasks_repository.h index 065291024..15b44ccff 100644 --- a/common/repositories/character_tasks_repository.h +++ b/common/repositories/character_tasks_repository.h @@ -1,23 +1,3 @@ -/** - * EQEmulator: Everquest Server Emulator - * Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server) - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 2 of the License. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY except by those people which sell it, which - * are required to give you total support for your newly bought product; - * without even the implied warranty of MERCHANTABILITY or FITNESS FOR - * A PARTICULAR PURPOSE. See the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - #ifndef EQEMU_CHARACTER_TASKS_REPOSITORY_H #define EQEMU_CHARACTER_TASKS_REPOSITORY_H diff --git a/common/repositories/completed_shared_task_activity_state_repository.h b/common/repositories/completed_shared_task_activity_state_repository.h index ebb1231f5..144bb124c 100644 --- a/common/repositories/completed_shared_task_activity_state_repository.h +++ b/common/repositories/completed_shared_task_activity_state_repository.h @@ -1,23 +1,3 @@ -/** - * EQEmulator: Everquest Server Emulator - * Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server) - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 2 of the License. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY except by those people which sell it, which - * are required to give you total support for your newly bought product; - * without even the implied warranty of MERCHANTABILITY or FITNESS FOR - * A PARTICULAR PURPOSE. See the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - #ifndef EQEMU_COMPLETED_SHARED_TASK_ACTIVITY_STATE_REPOSITORY_H #define EQEMU_COMPLETED_SHARED_TASK_ACTIVITY_STATE_REPOSITORY_H diff --git a/common/repositories/completed_shared_task_members_repository.h b/common/repositories/completed_shared_task_members_repository.h index a865b8ab0..5e456f3c5 100644 --- a/common/repositories/completed_shared_task_members_repository.h +++ b/common/repositories/completed_shared_task_members_repository.h @@ -1,23 +1,3 @@ -/** - * EQEmulator: Everquest Server Emulator - * Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server) - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 2 of the License. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY except by those people which sell it, which - * are required to give you total support for your newly bought product; - * without even the implied warranty of MERCHANTABILITY or FITNESS FOR - * A PARTICULAR PURPOSE. See the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - #ifndef EQEMU_COMPLETED_SHARED_TASK_MEMBERS_REPOSITORY_H #define EQEMU_COMPLETED_SHARED_TASK_MEMBERS_REPOSITORY_H diff --git a/common/repositories/completed_shared_tasks_repository.h b/common/repositories/completed_shared_tasks_repository.h index 867a8636e..555a5775a 100644 --- a/common/repositories/completed_shared_tasks_repository.h +++ b/common/repositories/completed_shared_tasks_repository.h @@ -1,23 +1,3 @@ -/** - * EQEmulator: Everquest Server Emulator - * Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server) - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 2 of the License. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY except by those people which sell it, which - * are required to give you total support for your newly bought product; - * without even the implied warranty of MERCHANTABILITY or FITNESS FOR - * A PARTICULAR PURPOSE. See the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - #ifndef EQEMU_COMPLETED_SHARED_TASKS_REPOSITORY_H #define EQEMU_COMPLETED_SHARED_TASKS_REPOSITORY_H diff --git a/common/repositories/completed_tasks_repository.h b/common/repositories/completed_tasks_repository.h index 5800df7a2..8bb00017e 100644 --- a/common/repositories/completed_tasks_repository.h +++ b/common/repositories/completed_tasks_repository.h @@ -1,23 +1,3 @@ -/** - * EQEmulator: Everquest Server Emulator - * Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server) - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 2 of the License. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY except by those people which sell it, which - * are required to give you total support for your newly bought product; - * without even the implied warranty of MERCHANTABILITY or FITNESS FOR - * A PARTICULAR PURPOSE. See the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - #ifndef EQEMU_COMPLETED_TASKS_REPOSITORY_H #define EQEMU_COMPLETED_TASKS_REPOSITORY_H diff --git a/common/repositories/content_flags_repository.h b/common/repositories/content_flags_repository.h index d3b6544ca..b777155cd 100644 --- a/common/repositories/content_flags_repository.h +++ b/common/repositories/content_flags_repository.h @@ -1,23 +1,3 @@ -/** - * EQEmulator: Everquest Server Emulator - * Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server) - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 2 of the License. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY except by those people which sell it, which - * are required to give you total support for your newly bought product; - * without even the implied warranty of MERCHANTABILITY or FITNESS FOR - * A PARTICULAR PURPOSE. See the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - #ifndef EQEMU_CONTENT_FLAGS_REPOSITORY_H #define EQEMU_CONTENT_FLAGS_REPOSITORY_H diff --git a/common/repositories/criteria/content_filter_criteria.h b/common/repositories/criteria/content_filter_criteria.h index d44637e58..0883097d4 100644 --- a/common/repositories/criteria/content_filter_criteria.h +++ b/common/repositories/criteria/content_filter_criteria.h @@ -1,23 +1,3 @@ -/** - * EQEmulator: Everquest Server Emulator - * Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server) - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 2 of the License. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY except by those people which sell it, which - * are required to give you total support for your newly bought product; - * without even the implied warranty of MERCHANTABILITY or FITNESS FOR - * A PARTICULAR PURPOSE. See the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - #ifndef EQEMU_CONTENT_FILTER_CRITERIA_H #define EQEMU_CONTENT_FILTER_CRITERIA_H diff --git a/common/repositories/damageshieldtypes_repository.h b/common/repositories/damageshieldtypes_repository.h index c882d4725..ec7c829f0 100644 --- a/common/repositories/damageshieldtypes_repository.h +++ b/common/repositories/damageshieldtypes_repository.h @@ -1,23 +1,3 @@ -/** - * EQEmulator: Everquest Server Emulator - * Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server) - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 2 of the License. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY except by those people which sell it, which - * are required to give you total support for your newly bought product; - * without even the implied warranty of MERCHANTABILITY or FITNESS FOR - * A PARTICULAR PURPOSE. See the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - #ifndef EQEMU_DAMAGESHIELDTYPES_REPOSITORY_H #define EQEMU_DAMAGESHIELDTYPES_REPOSITORY_H diff --git a/common/repositories/data_buckets_repository.h b/common/repositories/data_buckets_repository.h index 0911156ff..606dbdfaa 100644 --- a/common/repositories/data_buckets_repository.h +++ b/common/repositories/data_buckets_repository.h @@ -1,23 +1,3 @@ -/** - * EQEmulator: Everquest Server Emulator - * Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server) - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 2 of the License. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY except by those people which sell it, which - * are required to give you total support for your newly bought product; - * without even the implied warranty of MERCHANTABILITY or FITNESS FOR - * A PARTICULAR PURPOSE. See the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - #ifndef EQEMU_DATA_BUCKETS_REPOSITORY_H #define EQEMU_DATA_BUCKETS_REPOSITORY_H diff --git a/common/repositories/db_str_repository.h b/common/repositories/db_str_repository.h index 1a46a92cb..1ea5550ac 100644 --- a/common/repositories/db_str_repository.h +++ b/common/repositories/db_str_repository.h @@ -1,23 +1,3 @@ -/** - * EQEmulator: Everquest Server Emulator - * Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server) - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 2 of the License. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY except by those people which sell it, which - * are required to give you total support for your newly bought product; - * without even the implied warranty of MERCHANTABILITY or FITNESS FOR - * A PARTICULAR PURPOSE. See the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - #ifndef EQEMU_DB_STR_REPOSITORY_H #define EQEMU_DB_STR_REPOSITORY_H diff --git a/common/repositories/discord_webhooks_repository.h b/common/repositories/discord_webhooks_repository.h index 987b18481..064fadfbf 100644 --- a/common/repositories/discord_webhooks_repository.h +++ b/common/repositories/discord_webhooks_repository.h @@ -1,23 +1,3 @@ -/** - * EQEmulator: Everquest Server Emulator - * Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server) - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 2 of the License. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY except by those people which sell it, which - * are required to give you total support for your newly bought product; - * without even the implied warranty of MERCHANTABILITY or FITNESS FOR - * A PARTICULAR PURPOSE. See the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - #ifndef EQEMU_DISCORD_WEBHOOKS_REPOSITORY_H #define EQEMU_DISCORD_WEBHOOKS_REPOSITORY_H diff --git a/common/repositories/discovered_items_repository.h b/common/repositories/discovered_items_repository.h index 0019695f0..6fcd7968e 100644 --- a/common/repositories/discovered_items_repository.h +++ b/common/repositories/discovered_items_repository.h @@ -1,23 +1,3 @@ -/** - * EQEmulator: Everquest Server Emulator - * Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server) - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 2 of the License. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY except by those people which sell it, which - * are required to give you total support for your newly bought product; - * without even the implied warranty of MERCHANTABILITY or FITNESS FOR - * A PARTICULAR PURPOSE. See the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - #ifndef EQEMU_DISCOVERED_ITEMS_REPOSITORY_H #define EQEMU_DISCOVERED_ITEMS_REPOSITORY_H diff --git a/common/repositories/doors_repository.h b/common/repositories/doors_repository.h index 2eab6624c..f0e46fdee 100644 --- a/common/repositories/doors_repository.h +++ b/common/repositories/doors_repository.h @@ -1,23 +1,3 @@ -/** - * EQEmulator: Everquest Server Emulator - * Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server) - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 2 of the License. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY except by those people which sell it, which - * are required to give you total support for your newly bought product; - * without even the implied warranty of MERCHANTABILITY or FITNESS FOR - * A PARTICULAR PURPOSE. See the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - #ifndef EQEMU_DOORS_REPOSITORY_H #define EQEMU_DOORS_REPOSITORY_H diff --git a/common/repositories/dynamic_zone_members_repository.h b/common/repositories/dynamic_zone_members_repository.h index f75c5b4e5..1e25fc950 100644 --- a/common/repositories/dynamic_zone_members_repository.h +++ b/common/repositories/dynamic_zone_members_repository.h @@ -1,23 +1,3 @@ -/** - * EQEmulator: Everquest Server Emulator - * Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server) - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 2 of the License. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY except by those people which sell it, which - * are required to give you total support for your newly bought product; - * without even the implied warranty of MERCHANTABILITY or FITNESS FOR - * A PARTICULAR PURPOSE. See the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - #ifndef EQEMU_DYNAMIC_ZONE_MEMBERS_REPOSITORY_H #define EQEMU_DYNAMIC_ZONE_MEMBERS_REPOSITORY_H diff --git a/common/repositories/dynamic_zone_templates_repository.h b/common/repositories/dynamic_zone_templates_repository.h index 714762889..0dfe1183e 100644 --- a/common/repositories/dynamic_zone_templates_repository.h +++ b/common/repositories/dynamic_zone_templates_repository.h @@ -1,23 +1,3 @@ -/** - * EQEmulator: Everquest Server Emulator - * Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server) - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 2 of the License. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY except by those people which sell it, which - * are required to give you total support for your newly bought product; - * without even the implied warranty of MERCHANTABILITY or FITNESS FOR - * A PARTICULAR PURPOSE. See the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - #ifndef EQEMU_DYNAMIC_ZONE_TEMPLATES_REPOSITORY_H #define EQEMU_DYNAMIC_ZONE_TEMPLATES_REPOSITORY_H diff --git a/common/repositories/dynamic_zones_repository.h b/common/repositories/dynamic_zones_repository.h index af3f91bc1..a64aef8cc 100644 --- a/common/repositories/dynamic_zones_repository.h +++ b/common/repositories/dynamic_zones_repository.h @@ -1,23 +1,3 @@ -/** - * EQEmulator: Everquest Server Emulator - * Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server) - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 2 of the License. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY except by those people which sell it, which - * are required to give you total support for your newly bought product; - * without even the implied warranty of MERCHANTABILITY or FITNESS FOR - * A PARTICULAR PURPOSE. See the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - #ifndef EQEMU_DYNAMIC_ZONES_REPOSITORY_H #define EQEMU_DYNAMIC_ZONES_REPOSITORY_H diff --git a/common/repositories/eventlog_repository.h b/common/repositories/eventlog_repository.h index 8098c88af..83f21fb1a 100644 --- a/common/repositories/eventlog_repository.h +++ b/common/repositories/eventlog_repository.h @@ -1,23 +1,3 @@ -/** - * EQEmulator: Everquest Server Emulator - * Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server) - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 2 of the License. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY except by those people which sell it, which - * are required to give you total support for your newly bought product; - * without even the implied warranty of MERCHANTABILITY or FITNESS FOR - * A PARTICULAR PURPOSE. See the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - #ifndef EQEMU_EVENTLOG_REPOSITORY_H #define EQEMU_EVENTLOG_REPOSITORY_H diff --git a/common/repositories/expedition_lockouts_repository.h b/common/repositories/expedition_lockouts_repository.h index a8d73735d..94dbe155d 100644 --- a/common/repositories/expedition_lockouts_repository.h +++ b/common/repositories/expedition_lockouts_repository.h @@ -1,23 +1,3 @@ -/** - * EQEmulator: Everquest Server Emulator - * Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server) - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 2 of the License. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY except by those people which sell it, which - * are required to give you total support for your newly bought product; - * without even the implied warranty of MERCHANTABILITY or FITNESS FOR - * A PARTICULAR PURPOSE. See the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - #ifndef EQEMU_EXPEDITION_LOCKOUTS_REPOSITORY_H #define EQEMU_EXPEDITION_LOCKOUTS_REPOSITORY_H diff --git a/common/repositories/expeditions_repository.h b/common/repositories/expeditions_repository.h index f06aaa54d..502b9bc04 100644 --- a/common/repositories/expeditions_repository.h +++ b/common/repositories/expeditions_repository.h @@ -1,23 +1,3 @@ -/** - * EQEmulator: Everquest Server Emulator - * Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server) - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 2 of the License. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY except by those people which sell it, which - * are required to give you total support for your newly bought product; - * without even the implied warranty of MERCHANTABILITY or FITNESS FOR - * A PARTICULAR PURPOSE. See the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - #ifndef EQEMU_EXPEDITIONS_REPOSITORY_H #define EQEMU_EXPEDITIONS_REPOSITORY_H diff --git a/common/repositories/faction_base_data_repository.h b/common/repositories/faction_base_data_repository.h index 528c0644a..0cabe09cf 100644 --- a/common/repositories/faction_base_data_repository.h +++ b/common/repositories/faction_base_data_repository.h @@ -1,23 +1,3 @@ -/** - * EQEmulator: Everquest Server Emulator - * Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server) - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 2 of the License. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY except by those people which sell it, which - * are required to give you total support for your newly bought product; - * without even the implied warranty of MERCHANTABILITY or FITNESS FOR - * A PARTICULAR PURPOSE. See the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - #ifndef EQEMU_FACTION_BASE_DATA_REPOSITORY_H #define EQEMU_FACTION_BASE_DATA_REPOSITORY_H diff --git a/common/repositories/faction_list_mod_repository.h b/common/repositories/faction_list_mod_repository.h index 8132e0cb8..029abb2cb 100644 --- a/common/repositories/faction_list_mod_repository.h +++ b/common/repositories/faction_list_mod_repository.h @@ -1,23 +1,3 @@ -/** - * EQEmulator: Everquest Server Emulator - * Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server) - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 2 of the License. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY except by those people which sell it, which - * are required to give you total support for your newly bought product; - * without even the implied warranty of MERCHANTABILITY or FITNESS FOR - * A PARTICULAR PURPOSE. See the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - #ifndef EQEMU_FACTION_LIST_MOD_REPOSITORY_H #define EQEMU_FACTION_LIST_MOD_REPOSITORY_H diff --git a/common/repositories/faction_list_repository.h b/common/repositories/faction_list_repository.h index a445f89ce..f37e47a3b 100644 --- a/common/repositories/faction_list_repository.h +++ b/common/repositories/faction_list_repository.h @@ -1,23 +1,3 @@ -/** - * EQEmulator: Everquest Server Emulator - * Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server) - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 2 of the License. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY except by those people which sell it, which - * are required to give you total support for your newly bought product; - * without even the implied warranty of MERCHANTABILITY or FITNESS FOR - * A PARTICULAR PURPOSE. See the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - #ifndef EQEMU_FACTION_LIST_REPOSITORY_H #define EQEMU_FACTION_LIST_REPOSITORY_H diff --git a/common/repositories/faction_values_repository.h b/common/repositories/faction_values_repository.h index fcabbc8eb..9ab862045 100644 --- a/common/repositories/faction_values_repository.h +++ b/common/repositories/faction_values_repository.h @@ -1,23 +1,3 @@ -/** - * EQEmulator: Everquest Server Emulator - * Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server) - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 2 of the License. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY except by those people which sell it, which - * are required to give you total support for your newly bought product; - * without even the implied warranty of MERCHANTABILITY or FITNESS FOR - * A PARTICULAR PURPOSE. See the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - #ifndef EQEMU_FACTION_VALUES_REPOSITORY_H #define EQEMU_FACTION_VALUES_REPOSITORY_H diff --git a/common/repositories/fishing_repository.h b/common/repositories/fishing_repository.h index 2b585908f..90e8aa82b 100644 --- a/common/repositories/fishing_repository.h +++ b/common/repositories/fishing_repository.h @@ -1,23 +1,3 @@ -/** - * EQEmulator: Everquest Server Emulator - * Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server) - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 2 of the License. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY except by those people which sell it, which - * are required to give you total support for your newly bought product; - * without even the implied warranty of MERCHANTABILITY or FITNESS FOR - * A PARTICULAR PURPOSE. See the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - #ifndef EQEMU_FISHING_REPOSITORY_H #define EQEMU_FISHING_REPOSITORY_H diff --git a/common/repositories/forage_repository.h b/common/repositories/forage_repository.h index 4fdcc283b..5f158e69d 100644 --- a/common/repositories/forage_repository.h +++ b/common/repositories/forage_repository.h @@ -1,23 +1,3 @@ -/** - * EQEmulator: Everquest Server Emulator - * Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server) - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 2 of the License. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY except by those people which sell it, which - * are required to give you total support for your newly bought product; - * without even the implied warranty of MERCHANTABILITY or FITNESS FOR - * A PARTICULAR PURPOSE. See the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - #ifndef EQEMU_FORAGE_REPOSITORY_H #define EQEMU_FORAGE_REPOSITORY_H diff --git a/common/repositories/friends_repository.h b/common/repositories/friends_repository.h index fe858fec1..3917f9f02 100644 --- a/common/repositories/friends_repository.h +++ b/common/repositories/friends_repository.h @@ -1,23 +1,3 @@ -/** - * EQEmulator: Everquest Server Emulator - * Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server) - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 2 of the License. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY except by those people which sell it, which - * are required to give you total support for your newly bought product; - * without even the implied warranty of MERCHANTABILITY or FITNESS FOR - * A PARTICULAR PURPOSE. See the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - #ifndef EQEMU_FRIENDS_REPOSITORY_H #define EQEMU_FRIENDS_REPOSITORY_H diff --git a/common/repositories/global_loot_repository.h b/common/repositories/global_loot_repository.h index f353d6a64..ca1783d21 100644 --- a/common/repositories/global_loot_repository.h +++ b/common/repositories/global_loot_repository.h @@ -1,23 +1,3 @@ -/** - * EQEmulator: Everquest Server Emulator - * Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server) - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 2 of the License. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY except by those people which sell it, which - * are required to give you total support for your newly bought product; - * without even the implied warranty of MERCHANTABILITY or FITNESS FOR - * A PARTICULAR PURPOSE. See the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - #ifndef EQEMU_GLOBAL_LOOT_REPOSITORY_H #define EQEMU_GLOBAL_LOOT_REPOSITORY_H diff --git a/common/repositories/gm_ips_repository.h b/common/repositories/gm_ips_repository.h index 508261e50..bf62bbd1b 100644 --- a/common/repositories/gm_ips_repository.h +++ b/common/repositories/gm_ips_repository.h @@ -1,23 +1,3 @@ -/** - * EQEmulator: Everquest Server Emulator - * Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server) - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 2 of the License. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY except by those people which sell it, which - * are required to give you total support for your newly bought product; - * without even the implied warranty of MERCHANTABILITY or FITNESS FOR - * A PARTICULAR PURPOSE. See the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - #ifndef EQEMU_GM_IPS_REPOSITORY_H #define EQEMU_GM_IPS_REPOSITORY_H diff --git a/common/repositories/goallists_repository.h b/common/repositories/goallists_repository.h index 074ee1ccf..a38f5727a 100644 --- a/common/repositories/goallists_repository.h +++ b/common/repositories/goallists_repository.h @@ -1,23 +1,3 @@ -/** - * EQEmulator: Everquest Server Emulator - * Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server) - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 2 of the License. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY except by those people which sell it, which - * are required to give you total support for your newly bought product; - * without even the implied warranty of MERCHANTABILITY or FITNESS FOR - * A PARTICULAR PURPOSE. See the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - #ifndef EQEMU_GOALLISTS_REPOSITORY_H #define EQEMU_GOALLISTS_REPOSITORY_H diff --git a/common/repositories/graveyard_repository.h b/common/repositories/graveyard_repository.h index 15110298a..12bf4c565 100644 --- a/common/repositories/graveyard_repository.h +++ b/common/repositories/graveyard_repository.h @@ -1,23 +1,3 @@ -/** - * EQEmulator: Everquest Server Emulator - * Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server) - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 2 of the License. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY except by those people which sell it, which - * are required to give you total support for your newly bought product; - * without even the implied warranty of MERCHANTABILITY or FITNESS FOR - * A PARTICULAR PURPOSE. See the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - #ifndef EQEMU_GRAVEYARD_REPOSITORY_H #define EQEMU_GRAVEYARD_REPOSITORY_H diff --git a/common/repositories/grid_entries_repository.h b/common/repositories/grid_entries_repository.h index 1fcc04bdd..7a9712d64 100644 --- a/common/repositories/grid_entries_repository.h +++ b/common/repositories/grid_entries_repository.h @@ -1,101 +1,55 @@ -/** - * EQEmulator: Everquest Server Emulator - * Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server) - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 2 of the License. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY except by those people which sell it, which - * are required to give you total support for your newly bought product; - * without even the implied warranty of MERCHANTABILITY or FITNESS FOR - * A PARTICULAR PURPOSE. See the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - #ifndef EQEMU_GRID_ENTRIES_REPOSITORY_H #define EQEMU_GRID_ENTRIES_REPOSITORY_H #include "../database.h" #include "../strings.h" +#include "base/base_grid_entries_repository.h" -class GridEntriesRepository { +class GridEntriesRepository: public BaseGridEntriesRepository { public: - struct GridEntry { - int gridid; - int zoneid; - int number; - float x; - float y; - float z; - float heading; - int pause; - int8 centerpoint; - }; - static std::vector Columns() + /** + * 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 + * + * GridEntriesRepository::GetByZoneAndVersion(int zone_id, int zone_version) + * GridEntriesRepository::GetWhereNeverExpires() + * GridEntriesRepository::GetWhereXAndY() + * GridEntriesRepository::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 + + static std::vector GetZoneGridEntries(Database& db, int zone_id) { - return { - "gridid", - "zoneid", - "number", - "x", - "y", - "z", - "heading", - "pause", - "centerpoint", - }; - } + std::vector grid_entries; - static std::string ColumnsRaw() - { - return std::string(Strings::Implode(", ", Columns())); - } - - static std::string TableName() - { - return std::string("grid_entries"); - } - - static std::string BaseSelect() - { - return std::string( - fmt::format( - "SELECT {} FROM {}", - ColumnsRaw(), - TableName() - ) - ); - } - - static GridEntry NewEntity() - { - GridEntry entry{}; - - entry.gridid = 0; - entry.zoneid = 0; - entry.number = 0; - entry.x = 0; - entry.y = 0; - entry.z = 0; - entry.heading = 0; - entry.pause = 0; - entry.centerpoint = 0; - - return entry; - } - - static std::vector GetZoneGridEntries(int zone_id) - { - std::vector grid_entries; - - auto results = content_db.QueryDatabase( + auto results = db.QueryDatabase( fmt::format( "{} WHERE zoneid = {} ORDER BY gridid, number", BaseSelect(), @@ -104,7 +58,7 @@ public: ); for (auto row = results.begin(); row != results.end(); ++row) { - GridEntry entry{}; + GridEntries entry{}; entry.gridid = atoi(row[0]); entry.zoneid = atoi(row[1]); @@ -121,6 +75,7 @@ public: return grid_entries; } + }; -#endif +#endif //EQEMU_GRID_ENTRIES_REPOSITORY_H diff --git a/common/repositories/grid_repository.h b/common/repositories/grid_repository.h index 0f989e842..df6968209 100644 --- a/common/repositories/grid_repository.h +++ b/common/repositories/grid_repository.h @@ -1,23 +1,3 @@ -/** - * EQEmulator: Everquest Server Emulator - * Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server) - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 2 of the License. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY except by those people which sell it, which - * are required to give you total support for your newly bought product; - * without even the implied warranty of MERCHANTABILITY or FITNESS FOR - * A PARTICULAR PURPOSE. See the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - #ifndef EQEMU_GRID_REPOSITORY_H #define EQEMU_GRID_REPOSITORY_H @@ -25,49 +5,51 @@ #include "../strings.h" #include "base/base_grid_repository.h" -class GridRepository : public BaseGridRepository { +class GridRepository: public BaseGridRepository { public: - /** - * This file was auto generated on Apr 5, 2020 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) - * - * InsertOne - * UpdateOne - * DeleteOne - * FindOne - * GetWhere(std::string where_filter) - * DeleteWhere(std::string where_filter) - * InsertMany - * All - * - * Example custom methods in a repository - * - * GridRepository::GetByZoneAndVersion(int zone_id, int zone_version) - * GridRepository::GetWhereNeverExpires() - * GridRepository::GetWhereXAndY() - * GridRepository::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 - */ + /** + * 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 + * + * GridRepository::GetByZoneAndVersion(int zone_id, int zone_version) + * GridRepository::GetWhereNeverExpires() + * GridRepository::GetWhereXAndY() + * GridRepository::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 - static std::vector GetZoneGrids(int zone_id) + static std::vector GetZoneGrids(Database& db, int zone_id) { std::vector grids; - auto results = content_db.QueryDatabase( + auto results = db.QueryDatabase( fmt::format( "{} WHERE zoneid = {}", BaseSelect(), @@ -76,33 +58,19 @@ public: ); for (auto row = results.begin(); row != results.end(); ++row) { - Grid entry{}; + Grid e{}; - entry.id = atoi(row[0]); - entry.zoneid = atoi(row[1]); - entry.type = atoi(row[2]); - entry.type2 = atoi(row[3]); + e.id = atoi(row[0]); + e.zoneid = atoi(row[1]); + e.type = atoi(row[2]); + e.type2 = atoi(row[3]); - grids.push_back(entry); + grids.push_back(e); } return grids; } - static Grid GetGrid( - const std::vector &grids, - int grid_id - ) - { - for (auto &row : grids) { - if (row.id == grid_id) { - return row; - } - } - - return NewEntity(); - } - }; #endif //EQEMU_GRID_REPOSITORY_H diff --git a/common/repositories/ground_spawns_repository.h b/common/repositories/ground_spawns_repository.h index 9d2da57cd..800dd0b3a 100644 --- a/common/repositories/ground_spawns_repository.h +++ b/common/repositories/ground_spawns_repository.h @@ -1,23 +1,3 @@ -/** - * EQEmulator: Everquest Server Emulator - * Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server) - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 2 of the License. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY except by those people which sell it, which - * are required to give you total support for your newly bought product; - * without even the implied warranty of MERCHANTABILITY or FITNESS FOR - * A PARTICULAR PURPOSE. See the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - #ifndef EQEMU_GROUND_SPAWNS_REPOSITORY_H #define EQEMU_GROUND_SPAWNS_REPOSITORY_H diff --git a/common/repositories/group_id_repository.h b/common/repositories/group_id_repository.h index 418a08069..d2717acfc 100644 --- a/common/repositories/group_id_repository.h +++ b/common/repositories/group_id_repository.h @@ -1,23 +1,3 @@ -/** - * EQEmulator: Everquest Server Emulator - * Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server) - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 2 of the License. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY except by those people which sell it, which - * are required to give you total support for your newly bought product; - * without even the implied warranty of MERCHANTABILITY or FITNESS FOR - * A PARTICULAR PURPOSE. See the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - #ifndef EQEMU_GROUP_ID_REPOSITORY_H #define EQEMU_GROUP_ID_REPOSITORY_H diff --git a/common/repositories/group_leaders_repository.h b/common/repositories/group_leaders_repository.h index 4ad47c27d..9dcef525e 100644 --- a/common/repositories/group_leaders_repository.h +++ b/common/repositories/group_leaders_repository.h @@ -1,23 +1,3 @@ -/** - * EQEmulator: Everquest Server Emulator - * Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server) - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 2 of the License. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY except by those people which sell it, which - * are required to give you total support for your newly bought product; - * without even the implied warranty of MERCHANTABILITY or FITNESS FOR - * A PARTICULAR PURPOSE. See the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - #ifndef EQEMU_GROUP_LEADERS_REPOSITORY_H #define EQEMU_GROUP_LEADERS_REPOSITORY_H diff --git a/common/repositories/guild_bank_repository.h b/common/repositories/guild_bank_repository.h index 12e9c9f89..502844804 100644 --- a/common/repositories/guild_bank_repository.h +++ b/common/repositories/guild_bank_repository.h @@ -1,23 +1,3 @@ -/** - * EQEmulator: Everquest Server Emulator - * Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server) - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 2 of the License. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY except by those people which sell it, which - * are required to give you total support for your newly bought product; - * without even the implied warranty of MERCHANTABILITY or FITNESS FOR - * A PARTICULAR PURPOSE. See the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - #ifndef EQEMU_GUILD_BANK_REPOSITORY_H #define EQEMU_GUILD_BANK_REPOSITORY_H diff --git a/common/repositories/guild_members_repository.h b/common/repositories/guild_members_repository.h deleted file mode 100644 index ad67c30ca..000000000 --- a/common/repositories/guild_members_repository.h +++ /dev/null @@ -1,70 +0,0 @@ -/** - * EQEmulator: Everquest Server Emulator - * Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server) - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 2 of the License. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY except by those people which sell it, which - * are required to give you total support for your newly bought product; - * without even the implied warranty of MERCHANTABILITY or FITNESS FOR - * A PARTICULAR PURPOSE. See the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - -#ifndef EQEMU_GUILD_MEMBERS_REPOSITORY_H -#define EQEMU_GUILD_MEMBERS_REPOSITORY_H - -#include "../database.h" -#include "../strings.h" -#include "base/base_guild_members_repository.h" - -class GuildMembersRepository: public BaseGuildMembersRepository { -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 - * - * GuildMembersRepository::GetByZoneAndVersion(int zone_id, int zone_version) - * GuildMembersRepository::GetWhereNeverExpires() - * GuildMembersRepository::GetWhereXAndY() - * GuildMembersRepository::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_GUILD_MEMBERS_REPOSITORY_H diff --git a/common/repositories/guild_ranks_repository.h b/common/repositories/guild_ranks_repository.h index 08696a2e4..1a5a00455 100644 --- a/common/repositories/guild_ranks_repository.h +++ b/common/repositories/guild_ranks_repository.h @@ -1,23 +1,3 @@ -/** - * EQEmulator: Everquest Server Emulator - * Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server) - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 2 of the License. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY except by those people which sell it, which - * are required to give you total support for your newly bought product; - * without even the implied warranty of MERCHANTABILITY or FITNESS FOR - * A PARTICULAR PURPOSE. See the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - #ifndef EQEMU_GUILD_RANKS_REPOSITORY_H #define EQEMU_GUILD_RANKS_REPOSITORY_H diff --git a/common/repositories/guild_relations_repository.h b/common/repositories/guild_relations_repository.h index a78707771..a86c80c64 100644 --- a/common/repositories/guild_relations_repository.h +++ b/common/repositories/guild_relations_repository.h @@ -1,23 +1,3 @@ -/** - * EQEmulator: Everquest Server Emulator - * Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server) - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 2 of the License. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY except by those people which sell it, which - * are required to give you total support for your newly bought product; - * without even the implied warranty of MERCHANTABILITY or FITNESS FOR - * A PARTICULAR PURPOSE. See the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - #ifndef EQEMU_GUILD_RELATIONS_REPOSITORY_H #define EQEMU_GUILD_RELATIONS_REPOSITORY_H diff --git a/common/repositories/guilds_repository.h b/common/repositories/guilds_repository.h index ade49cfba..b55510156 100644 --- a/common/repositories/guilds_repository.h +++ b/common/repositories/guilds_repository.h @@ -1,23 +1,3 @@ -/** - * EQEmulator: Everquest Server Emulator - * Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server) - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 2 of the License. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY except by those people which sell it, which - * are required to give you total support for your newly bought product; - * without even the implied warranty of MERCHANTABILITY or FITNESS FOR - * A PARTICULAR PURPOSE. See the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - #ifndef EQEMU_GUILDS_REPOSITORY_H #define EQEMU_GUILDS_REPOSITORY_H diff --git a/common/repositories/hackers_repository.h b/common/repositories/hackers_repository.h index 32a4a0748..516ab0e6f 100644 --- a/common/repositories/hackers_repository.h +++ b/common/repositories/hackers_repository.h @@ -1,23 +1,3 @@ -/** - * EQEmulator: Everquest Server Emulator - * Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server) - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 2 of the License. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY except by those people which sell it, which - * are required to give you total support for your newly bought product; - * without even the implied warranty of MERCHANTABILITY or FITNESS FOR - * A PARTICULAR PURPOSE. See the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - #ifndef EQEMU_HACKERS_REPOSITORY_H #define EQEMU_HACKERS_REPOSITORY_H diff --git a/common/repositories/horses_repository.h b/common/repositories/horses_repository.h index 35788d00b..18c1abbfc 100644 --- a/common/repositories/horses_repository.h +++ b/common/repositories/horses_repository.h @@ -1,23 +1,3 @@ -/** - * EQEmulator: Everquest Server Emulator - * Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server) - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 2 of the License. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY except by those people which sell it, which - * are required to give you total support for your newly bought product; - * without even the implied warranty of MERCHANTABILITY or FITNESS FOR - * A PARTICULAR PURPOSE. See the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - #ifndef EQEMU_HORSES_REPOSITORY_H #define EQEMU_HORSES_REPOSITORY_H diff --git a/common/repositories/instance_list_player_repository.h b/common/repositories/instance_list_player_repository.h index 9ea7397ab..8da1be7c5 100644 --- a/common/repositories/instance_list_player_repository.h +++ b/common/repositories/instance_list_player_repository.h @@ -1,23 +1,3 @@ -/** - * EQEmulator: Everquest Server Emulator - * Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server) - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 2 of the License. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY except by those people which sell it, which - * are required to give you total support for your newly bought product; - * without even the implied warranty of MERCHANTABILITY or FITNESS FOR - * A PARTICULAR PURPOSE. See the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - #ifndef EQEMU_INSTANCE_LIST_PLAYER_REPOSITORY_H #define EQEMU_INSTANCE_LIST_PLAYER_REPOSITORY_H diff --git a/common/repositories/instance_list_repository.h b/common/repositories/instance_list_repository.h index 8bd2a1ab7..e643383e2 100644 --- a/common/repositories/instance_list_repository.h +++ b/common/repositories/instance_list_repository.h @@ -1,23 +1,3 @@ -/** - * EQEmulator: Everquest Server Emulator - * Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server) - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 2 of the License. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY except by those people which sell it, which - * are required to give you total support for your newly bought product; - * without even the implied warranty of MERCHANTABILITY or FITNESS FOR - * A PARTICULAR PURPOSE. See the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - #ifndef EQEMU_INSTANCE_LIST_REPOSITORY_H #define EQEMU_INSTANCE_LIST_REPOSITORY_H diff --git a/common/repositories/inventory_repository.h b/common/repositories/inventory_repository.h index 9c79dd88a..8b4b859ee 100644 --- a/common/repositories/inventory_repository.h +++ b/common/repositories/inventory_repository.h @@ -1,23 +1,3 @@ -/** - * EQEmulator: Everquest Server Emulator - * Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server) - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 2 of the License. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY except by those people which sell it, which - * are required to give you total support for your newly bought product; - * without even the implied warranty of MERCHANTABILITY or FITNESS FOR - * A PARTICULAR PURPOSE. See the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - #ifndef EQEMU_INVENTORY_REPOSITORY_H #define EQEMU_INVENTORY_REPOSITORY_H diff --git a/common/repositories/inventory_snapshots_repository.h b/common/repositories/inventory_snapshots_repository.h index 30e2d1a27..742810a25 100644 --- a/common/repositories/inventory_snapshots_repository.h +++ b/common/repositories/inventory_snapshots_repository.h @@ -1,23 +1,3 @@ -/** - * EQEmulator: Everquest Server Emulator - * Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server) - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 2 of the License. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY except by those people which sell it, which - * are required to give you total support for your newly bought product; - * without even the implied warranty of MERCHANTABILITY or FITNESS FOR - * A PARTICULAR PURPOSE. See the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - #ifndef EQEMU_INVENTORY_SNAPSHOTS_REPOSITORY_H #define EQEMU_INVENTORY_SNAPSHOTS_REPOSITORY_H diff --git a/common/repositories/inventory_versions_repository.h b/common/repositories/inventory_versions_repository.h index 32e048750..7b279a6fe 100644 --- a/common/repositories/inventory_versions_repository.h +++ b/common/repositories/inventory_versions_repository.h @@ -1,23 +1,3 @@ -/** - * EQEmulator: Everquest Server Emulator - * Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server) - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 2 of the License. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY except by those people which sell it, which - * are required to give you total support for your newly bought product; - * without even the implied warranty of MERCHANTABILITY or FITNESS FOR - * A PARTICULAR PURPOSE. See the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - #ifndef EQEMU_INVENTORY_VERSIONS_REPOSITORY_H #define EQEMU_INVENTORY_VERSIONS_REPOSITORY_H diff --git a/common/repositories/ip_exemptions_repository.h b/common/repositories/ip_exemptions_repository.h index 3804f69f0..64b5f7603 100644 --- a/common/repositories/ip_exemptions_repository.h +++ b/common/repositories/ip_exemptions_repository.h @@ -1,23 +1,3 @@ -/** - * EQEmulator: Everquest Server Emulator - * Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server) - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 2 of the License. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY except by those people which sell it, which - * are required to give you total support for your newly bought product; - * without even the implied warranty of MERCHANTABILITY or FITNESS FOR - * A PARTICULAR PURPOSE. See the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - #ifndef EQEMU_IP_EXEMPTIONS_REPOSITORY_H #define EQEMU_IP_EXEMPTIONS_REPOSITORY_H diff --git a/common/repositories/item_tick_repository.h b/common/repositories/item_tick_repository.h index 72ca5c074..352595ac5 100644 --- a/common/repositories/item_tick_repository.h +++ b/common/repositories/item_tick_repository.h @@ -1,23 +1,3 @@ -/** - * EQEmulator: Everquest Server Emulator - * Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server) - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 2 of the License. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY except by those people which sell it, which - * are required to give you total support for your newly bought product; - * without even the implied warranty of MERCHANTABILITY or FITNESS FOR - * A PARTICULAR PURPOSE. See the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - #ifndef EQEMU_ITEM_TICK_REPOSITORY_H #define EQEMU_ITEM_TICK_REPOSITORY_H diff --git a/common/repositories/items_repository.h b/common/repositories/items_repository.h index a87604b01..aac7d3697 100644 --- a/common/repositories/items_repository.h +++ b/common/repositories/items_repository.h @@ -1,23 +1,3 @@ -/** - * EQEmulator: Everquest Server Emulator - * Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server) - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 2 of the License. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY except by those people which sell it, which - * are required to give you total support for your newly bought product; - * without even the implied warranty of MERCHANTABILITY or FITNESS FOR - * A PARTICULAR PURPOSE. See the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - #ifndef EQEMU_ITEMS_REPOSITORY_H #define EQEMU_ITEMS_REPOSITORY_H diff --git a/common/repositories/ldon_trap_entries_repository.h b/common/repositories/ldon_trap_entries_repository.h index 063dfadf4..e2d6a882a 100644 --- a/common/repositories/ldon_trap_entries_repository.h +++ b/common/repositories/ldon_trap_entries_repository.h @@ -1,23 +1,3 @@ -/** - * EQEmulator: Everquest Server Emulator - * Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server) - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 2 of the License. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY except by those people which sell it, which - * are required to give you total support for your newly bought product; - * without even the implied warranty of MERCHANTABILITY or FITNESS FOR - * A PARTICULAR PURPOSE. See the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - #ifndef EQEMU_LDON_TRAP_ENTRIES_REPOSITORY_H #define EQEMU_LDON_TRAP_ENTRIES_REPOSITORY_H diff --git a/common/repositories/ldon_trap_templates_repository.h b/common/repositories/ldon_trap_templates_repository.h index 8d2c09adf..7d94f80b4 100644 --- a/common/repositories/ldon_trap_templates_repository.h +++ b/common/repositories/ldon_trap_templates_repository.h @@ -1,23 +1,3 @@ -/** - * EQEmulator: Everquest Server Emulator - * Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server) - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 2 of the License. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY except by those people which sell it, which - * are required to give you total support for your newly bought product; - * without even the implied warranty of MERCHANTABILITY or FITNESS FOR - * A PARTICULAR PURPOSE. See the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - #ifndef EQEMU_LDON_TRAP_TEMPLATES_REPOSITORY_H #define EQEMU_LDON_TRAP_TEMPLATES_REPOSITORY_H diff --git a/common/repositories/level_exp_mods_repository.h b/common/repositories/level_exp_mods_repository.h index db257329f..6bc893aed 100644 --- a/common/repositories/level_exp_mods_repository.h +++ b/common/repositories/level_exp_mods_repository.h @@ -1,23 +1,3 @@ -/** - * EQEmulator: Everquest Server Emulator - * Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server) - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 2 of the License. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY except by those people which sell it, which - * are required to give you total support for your newly bought product; - * without even the implied warranty of MERCHANTABILITY or FITNESS FOR - * A PARTICULAR PURPOSE. See the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - #ifndef EQEMU_LEVEL_EXP_MODS_REPOSITORY_H #define EQEMU_LEVEL_EXP_MODS_REPOSITORY_H diff --git a/common/repositories/lfguild_repository.h b/common/repositories/lfguild_repository.h index efa9af744..9f415c944 100644 --- a/common/repositories/lfguild_repository.h +++ b/common/repositories/lfguild_repository.h @@ -1,23 +1,3 @@ -/** - * EQEmulator: Everquest Server Emulator - * Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server) - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 2 of the License. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY except by those people which sell it, which - * are required to give you total support for your newly bought product; - * without even the implied warranty of MERCHANTABILITY or FITNESS FOR - * A PARTICULAR PURPOSE. See the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - #ifndef EQEMU_LFGUILD_REPOSITORY_H #define EQEMU_LFGUILD_REPOSITORY_H diff --git a/common/repositories/login_accounts_repository.h b/common/repositories/login_accounts_repository.h index 785d2f3b3..2ad6797ae 100644 --- a/common/repositories/login_accounts_repository.h +++ b/common/repositories/login_accounts_repository.h @@ -1,23 +1,3 @@ -/** - * EQEmulator: Everquest Server Emulator - * Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server) - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 2 of the License. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY except by those people which sell it, which - * are required to give you total support for your newly bought product; - * without even the implied warranty of MERCHANTABILITY or FITNESS FOR - * A PARTICULAR PURPOSE. See the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - #ifndef EQEMU_LOGIN_ACCOUNTS_REPOSITORY_H #define EQEMU_LOGIN_ACCOUNTS_REPOSITORY_H diff --git a/common/repositories/login_api_tokens_repository.h b/common/repositories/login_api_tokens_repository.h index fde27d893..46bfd3316 100644 --- a/common/repositories/login_api_tokens_repository.h +++ b/common/repositories/login_api_tokens_repository.h @@ -1,23 +1,3 @@ -/** - * EQEmulator: Everquest Server Emulator - * Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server) - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 2 of the License. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY except by those people which sell it, which - * are required to give you total support for your newly bought product; - * without even the implied warranty of MERCHANTABILITY or FITNESS FOR - * A PARTICULAR PURPOSE. See the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - #ifndef EQEMU_LOGIN_API_TOKENS_REPOSITORY_H #define EQEMU_LOGIN_API_TOKENS_REPOSITORY_H diff --git a/common/repositories/login_server_admins_repository.h b/common/repositories/login_server_admins_repository.h index 143b72ed5..8afda242c 100644 --- a/common/repositories/login_server_admins_repository.h +++ b/common/repositories/login_server_admins_repository.h @@ -1,23 +1,3 @@ -/** - * EQEmulator: Everquest Server Emulator - * Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server) - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 2 of the License. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY except by those people which sell it, which - * are required to give you total support for your newly bought product; - * without even the implied warranty of MERCHANTABILITY or FITNESS FOR - * A PARTICULAR PURPOSE. See the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - #ifndef EQEMU_LOGIN_SERVER_ADMINS_REPOSITORY_H #define EQEMU_LOGIN_SERVER_ADMINS_REPOSITORY_H diff --git a/common/repositories/login_server_list_types_repository.h b/common/repositories/login_server_list_types_repository.h index 5ce0034e0..37aef18eb 100644 --- a/common/repositories/login_server_list_types_repository.h +++ b/common/repositories/login_server_list_types_repository.h @@ -1,23 +1,3 @@ -/** - * EQEmulator: Everquest Server Emulator - * Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server) - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 2 of the License. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY except by those people which sell it, which - * are required to give you total support for your newly bought product; - * without even the implied warranty of MERCHANTABILITY or FITNESS FOR - * A PARTICULAR PURPOSE. See the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - #ifndef EQEMU_LOGIN_SERVER_LIST_TYPES_REPOSITORY_H #define EQEMU_LOGIN_SERVER_LIST_TYPES_REPOSITORY_H diff --git a/common/repositories/login_world_servers_repository.h b/common/repositories/login_world_servers_repository.h index 8b3b8119e..8cda28e32 100644 --- a/common/repositories/login_world_servers_repository.h +++ b/common/repositories/login_world_servers_repository.h @@ -1,23 +1,3 @@ -/** - * EQEmulator: Everquest Server Emulator - * Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server) - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 2 of the License. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY except by those people which sell it, which - * are required to give you total support for your newly bought product; - * without even the implied warranty of MERCHANTABILITY or FITNESS FOR - * A PARTICULAR PURPOSE. See the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - #ifndef EQEMU_LOGIN_WORLD_SERVERS_REPOSITORY_H #define EQEMU_LOGIN_WORLD_SERVERS_REPOSITORY_H diff --git a/common/repositories/logsys_categories_repository.h b/common/repositories/logsys_categories_repository.h index 33b497cfd..7d2f0898a 100644 --- a/common/repositories/logsys_categories_repository.h +++ b/common/repositories/logsys_categories_repository.h @@ -1,23 +1,3 @@ -/** - * EQEmulator: Everquest Server Emulator - * Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server) - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 2 of the License. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY except by those people which sell it, which - * are required to give you total support for your newly bought product; - * without even the implied warranty of MERCHANTABILITY or FITNESS FOR - * A PARTICULAR PURPOSE. See the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - #ifndef EQEMU_LOGSYS_CATEGORIES_REPOSITORY_H #define EQEMU_LOGSYS_CATEGORIES_REPOSITORY_H diff --git a/common/repositories/lootdrop_entries_repository.h b/common/repositories/lootdrop_entries_repository.h index 43ed1b91f..398ab46a4 100644 --- a/common/repositories/lootdrop_entries_repository.h +++ b/common/repositories/lootdrop_entries_repository.h @@ -1,23 +1,3 @@ -/** - * EQEmulator: Everquest Server Emulator - * Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server) - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 2 of the License. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY except by those people which sell it, which - * are required to give you total support for your newly bought product; - * without even the implied warranty of MERCHANTABILITY or FITNESS FOR - * A PARTICULAR PURPOSE. See the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - #ifndef EQEMU_LOOTDROP_ENTRIES_REPOSITORY_H #define EQEMU_LOOTDROP_ENTRIES_REPOSITORY_H diff --git a/common/repositories/lootdrop_repository.h b/common/repositories/lootdrop_repository.h index ded0fabc8..abd2ec844 100644 --- a/common/repositories/lootdrop_repository.h +++ b/common/repositories/lootdrop_repository.h @@ -1,23 +1,3 @@ -/** - * EQEmulator: Everquest Server Emulator - * Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server) - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 2 of the License. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY except by those people which sell it, which - * are required to give you total support for your newly bought product; - * without even the implied warranty of MERCHANTABILITY or FITNESS FOR - * A PARTICULAR PURPOSE. See the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - #ifndef EQEMU_LOOTDROP_REPOSITORY_H #define EQEMU_LOOTDROP_REPOSITORY_H diff --git a/common/repositories/loottable_entries_repository.h b/common/repositories/loottable_entries_repository.h index aa1b28d5b..9e2c9d989 100644 --- a/common/repositories/loottable_entries_repository.h +++ b/common/repositories/loottable_entries_repository.h @@ -1,23 +1,3 @@ -/** - * EQEmulator: Everquest Server Emulator - * Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server) - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 2 of the License. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY except by those people which sell it, which - * are required to give you total support for your newly bought product; - * without even the implied warranty of MERCHANTABILITY or FITNESS FOR - * A PARTICULAR PURPOSE. See the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - #ifndef EQEMU_LOOTTABLE_ENTRIES_REPOSITORY_H #define EQEMU_LOOTTABLE_ENTRIES_REPOSITORY_H diff --git a/common/repositories/loottable_repository.h b/common/repositories/loottable_repository.h index fbd61a966..ef9845c87 100644 --- a/common/repositories/loottable_repository.h +++ b/common/repositories/loottable_repository.h @@ -1,23 +1,3 @@ -/** - * EQEmulator: Everquest Server Emulator - * Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server) - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 2 of the License. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY except by those people which sell it, which - * are required to give you total support for your newly bought product; - * without even the implied warranty of MERCHANTABILITY or FITNESS FOR - * A PARTICULAR PURPOSE. See the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - #ifndef EQEMU_LOOTTABLE_REPOSITORY_H #define EQEMU_LOOTTABLE_REPOSITORY_H diff --git a/common/repositories/mail_repository.h b/common/repositories/mail_repository.h index 37993df63..c1e2934ae 100644 --- a/common/repositories/mail_repository.h +++ b/common/repositories/mail_repository.h @@ -1,23 +1,3 @@ -/** - * EQEmulator: Everquest Server Emulator - * Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server) - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 2 of the License. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY except by those people which sell it, which - * are required to give you total support for your newly bought product; - * without even the implied warranty of MERCHANTABILITY or FITNESS FOR - * A PARTICULAR PURPOSE. See the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - #ifndef EQEMU_MAIL_REPOSITORY_H #define EQEMU_MAIL_REPOSITORY_H diff --git a/common/repositories/merchantlist_repository.h b/common/repositories/merchantlist_repository.h index d8d876f4c..37f4c82ef 100644 --- a/common/repositories/merchantlist_repository.h +++ b/common/repositories/merchantlist_repository.h @@ -1,23 +1,3 @@ -/** - * EQEmulator: Everquest Server Emulator - * Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server) - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 2 of the License. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY except by those people which sell it, which - * are required to give you total support for your newly bought product; - * without even the implied warranty of MERCHANTABILITY or FITNESS FOR - * A PARTICULAR PURPOSE. See the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - #ifndef EQEMU_MERCHANTLIST_REPOSITORY_H #define EQEMU_MERCHANTLIST_REPOSITORY_H diff --git a/common/repositories/merchantlist_temp_repository.h b/common/repositories/merchantlist_temp_repository.h index 76c069d9b..0cbb7669e 100644 --- a/common/repositories/merchantlist_temp_repository.h +++ b/common/repositories/merchantlist_temp_repository.h @@ -1,23 +1,3 @@ -/** - * EQEmulator: Everquest Server Emulator - * Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server) - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 2 of the License. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY except by those people which sell it, which - * are required to give you total support for your newly bought product; - * without even the implied warranty of MERCHANTABILITY or FITNESS FOR - * A PARTICULAR PURPOSE. See the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - #ifndef EQEMU_MERCHANTLIST_TEMP_REPOSITORY_H #define EQEMU_MERCHANTLIST_TEMP_REPOSITORY_H diff --git a/common/repositories/name_filter_repository.h b/common/repositories/name_filter_repository.h index b93b62429..43dc3ecf0 100644 --- a/common/repositories/name_filter_repository.h +++ b/common/repositories/name_filter_repository.h @@ -1,23 +1,3 @@ -/** - * EQEmulator: Everquest Server Emulator - * Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server) - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 2 of the License. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY except by those people which sell it, which - * are required to give you total support for your newly bought product; - * without even the implied warranty of MERCHANTABILITY or FITNESS FOR - * A PARTICULAR PURPOSE. See the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - #ifndef EQEMU_NAME_FILTER_REPOSITORY_H #define EQEMU_NAME_FILTER_REPOSITORY_H diff --git a/common/repositories/npc_emotes_repository.h b/common/repositories/npc_emotes_repository.h index 844b64d62..438ad9be4 100644 --- a/common/repositories/npc_emotes_repository.h +++ b/common/repositories/npc_emotes_repository.h @@ -1,23 +1,3 @@ -/** - * EQEmulator: Everquest Server Emulator - * Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server) - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 2 of the License. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY except by those people which sell it, which - * are required to give you total support for your newly bought product; - * without even the implied warranty of MERCHANTABILITY or FITNESS FOR - * A PARTICULAR PURPOSE. See the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - #ifndef EQEMU_NPC_EMOTES_REPOSITORY_H #define EQEMU_NPC_EMOTES_REPOSITORY_H diff --git a/common/repositories/npc_faction_entries_repository.h b/common/repositories/npc_faction_entries_repository.h index eb1b2ae23..eb9d92b44 100644 --- a/common/repositories/npc_faction_entries_repository.h +++ b/common/repositories/npc_faction_entries_repository.h @@ -1,23 +1,3 @@ -/** - * EQEmulator: Everquest Server Emulator - * Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server) - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 2 of the License. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY except by those people which sell it, which - * are required to give you total support for your newly bought product; - * without even the implied warranty of MERCHANTABILITY or FITNESS FOR - * A PARTICULAR PURPOSE. See the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - #ifndef EQEMU_NPC_FACTION_ENTRIES_REPOSITORY_H #define EQEMU_NPC_FACTION_ENTRIES_REPOSITORY_H diff --git a/common/repositories/npc_faction_repository.h b/common/repositories/npc_faction_repository.h index 720b84db3..0e4cbbbc4 100644 --- a/common/repositories/npc_faction_repository.h +++ b/common/repositories/npc_faction_repository.h @@ -1,23 +1,3 @@ -/** - * EQEmulator: Everquest Server Emulator - * Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server) - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 2 of the License. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY except by those people which sell it, which - * are required to give you total support for your newly bought product; - * without even the implied warranty of MERCHANTABILITY or FITNESS FOR - * A PARTICULAR PURPOSE. See the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - #ifndef EQEMU_NPC_FACTION_REPOSITORY_H #define EQEMU_NPC_FACTION_REPOSITORY_H diff --git a/common/repositories/npc_scale_global_base_repository.h b/common/repositories/npc_scale_global_base_repository.h index cf1e2cc08..1ef4ffb1a 100644 --- a/common/repositories/npc_scale_global_base_repository.h +++ b/common/repositories/npc_scale_global_base_repository.h @@ -1,23 +1,3 @@ -/** - * EQEmulator: Everquest Server Emulator - * Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server) - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 2 of the License. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY except by those people which sell it, which - * are required to give you total support for your newly bought product; - * without even the implied warranty of MERCHANTABILITY or FITNESS FOR - * A PARTICULAR PURPOSE. See the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - #ifndef EQEMU_NPC_SCALE_GLOBAL_BASE_REPOSITORY_H #define EQEMU_NPC_SCALE_GLOBAL_BASE_REPOSITORY_H diff --git a/common/repositories/npc_spells_effects_entries_repository.h b/common/repositories/npc_spells_effects_entries_repository.h index 83757062b..87570ceef 100644 --- a/common/repositories/npc_spells_effects_entries_repository.h +++ b/common/repositories/npc_spells_effects_entries_repository.h @@ -1,23 +1,3 @@ -/** - * EQEmulator: Everquest Server Emulator - * Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server) - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 2 of the License. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY except by those people which sell it, which - * are required to give you total support for your newly bought product; - * without even the implied warranty of MERCHANTABILITY or FITNESS FOR - * A PARTICULAR PURPOSE. See the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - #ifndef EQEMU_NPC_SPELLS_EFFECTS_ENTRIES_REPOSITORY_H #define EQEMU_NPC_SPELLS_EFFECTS_ENTRIES_REPOSITORY_H diff --git a/common/repositories/npc_spells_effects_repository.h b/common/repositories/npc_spells_effects_repository.h index ceeb723a1..46a56819a 100644 --- a/common/repositories/npc_spells_effects_repository.h +++ b/common/repositories/npc_spells_effects_repository.h @@ -1,23 +1,3 @@ -/** - * EQEmulator: Everquest Server Emulator - * Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server) - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 2 of the License. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY except by those people which sell it, which - * are required to give you total support for your newly bought product; - * without even the implied warranty of MERCHANTABILITY or FITNESS FOR - * A PARTICULAR PURPOSE. See the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - #ifndef EQEMU_NPC_SPELLS_EFFECTS_REPOSITORY_H #define EQEMU_NPC_SPELLS_EFFECTS_REPOSITORY_H diff --git a/common/repositories/npc_spells_entries_repository.h b/common/repositories/npc_spells_entries_repository.h index 2fbfcc4b9..4b21beff4 100644 --- a/common/repositories/npc_spells_entries_repository.h +++ b/common/repositories/npc_spells_entries_repository.h @@ -1,23 +1,3 @@ -/** - * EQEmulator: Everquest Server Emulator - * Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server) - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 2 of the License. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY except by those people which sell it, which - * are required to give you total support for your newly bought product; - * without even the implied warranty of MERCHANTABILITY or FITNESS FOR - * A PARTICULAR PURPOSE. See the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - #ifndef EQEMU_NPC_SPELLS_ENTRIES_REPOSITORY_H #define EQEMU_NPC_SPELLS_ENTRIES_REPOSITORY_H diff --git a/common/repositories/npc_spells_repository.h b/common/repositories/npc_spells_repository.h index a55e5d23d..e9b017085 100644 --- a/common/repositories/npc_spells_repository.h +++ b/common/repositories/npc_spells_repository.h @@ -1,23 +1,3 @@ -/** - * EQEmulator: Everquest Server Emulator - * Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server) - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 2 of the License. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY except by those people which sell it, which - * are required to give you total support for your newly bought product; - * without even the implied warranty of MERCHANTABILITY or FITNESS FOR - * A PARTICULAR PURPOSE. See the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - #ifndef EQEMU_NPC_SPELLS_REPOSITORY_H #define EQEMU_NPC_SPELLS_REPOSITORY_H diff --git a/common/repositories/npc_types_repository.h b/common/repositories/npc_types_repository.h index e28f39af8..a8f8a53a3 100644 --- a/common/repositories/npc_types_repository.h +++ b/common/repositories/npc_types_repository.h @@ -1,23 +1,3 @@ -/** - * EQEmulator: Everquest Server Emulator - * Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server) - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 2 of the License. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY except by those people which sell it, which - * are required to give you total support for your newly bought product; - * without even the implied warranty of MERCHANTABILITY or FITNESS FOR - * A PARTICULAR PURPOSE. See the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - #ifndef EQEMU_NPC_TYPES_REPOSITORY_H #define EQEMU_NPC_TYPES_REPOSITORY_H diff --git a/common/repositories/npc_types_tint_repository.h b/common/repositories/npc_types_tint_repository.h index 3270c4517..aa501acf8 100644 --- a/common/repositories/npc_types_tint_repository.h +++ b/common/repositories/npc_types_tint_repository.h @@ -1,23 +1,3 @@ -/** - * EQEmulator: Everquest Server Emulator - * Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server) - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 2 of the License. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY except by those people which sell it, which - * are required to give you total support for your newly bought product; - * without even the implied warranty of MERCHANTABILITY or FITNESS FOR - * A PARTICULAR PURPOSE. See the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - #ifndef EQEMU_NPC_TYPES_TINT_REPOSITORY_H #define EQEMU_NPC_TYPES_TINT_REPOSITORY_H diff --git a/common/repositories/object_contents_repository.h b/common/repositories/object_contents_repository.h index d5f3780d9..6ed16bd33 100644 --- a/common/repositories/object_contents_repository.h +++ b/common/repositories/object_contents_repository.h @@ -1,23 +1,3 @@ -/** - * EQEmulator: Everquest Server Emulator - * Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server) - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 2 of the License. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY except by those people which sell it, which - * are required to give you total support for your newly bought product; - * without even the implied warranty of MERCHANTABILITY or FITNESS FOR - * A PARTICULAR PURPOSE. See the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - #ifndef EQEMU_OBJECT_CONTENTS_REPOSITORY_H #define EQEMU_OBJECT_CONTENTS_REPOSITORY_H diff --git a/common/repositories/object_repository.h b/common/repositories/object_repository.h index 6937559b2..151572b35 100644 --- a/common/repositories/object_repository.h +++ b/common/repositories/object_repository.h @@ -1,23 +1,3 @@ -/** - * EQEmulator: Everquest Server Emulator - * Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server) - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 2 of the License. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY except by those people which sell it, which - * are required to give you total support for your newly bought product; - * without even the implied warranty of MERCHANTABILITY or FITNESS FOR - * A PARTICULAR PURPOSE. See the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - #ifndef EQEMU_OBJECT_REPOSITORY_H #define EQEMU_OBJECT_REPOSITORY_H diff --git a/common/repositories/perl_event_export_settings_repository.h b/common/repositories/perl_event_export_settings_repository.h index 8d02fc2a9..a7e195f54 100644 --- a/common/repositories/perl_event_export_settings_repository.h +++ b/common/repositories/perl_event_export_settings_repository.h @@ -1,23 +1,3 @@ -/** - * EQEmulator: Everquest Server Emulator - * Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server) - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 2 of the License. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY except by those people which sell it, which - * are required to give you total support for your newly bought product; - * without even the implied warranty of MERCHANTABILITY or FITNESS FOR - * A PARTICULAR PURPOSE. See the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - #ifndef EQEMU_PERL_EVENT_EXPORT_SETTINGS_REPOSITORY_H #define EQEMU_PERL_EVENT_EXPORT_SETTINGS_REPOSITORY_H diff --git a/common/repositories/petitions_repository.h b/common/repositories/petitions_repository.h index 862b5fe3e..0625845a8 100644 --- a/common/repositories/petitions_repository.h +++ b/common/repositories/petitions_repository.h @@ -1,23 +1,3 @@ -/** - * EQEmulator: Everquest Server Emulator - * Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server) - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 2 of the License. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY except by those people which sell it, which - * are required to give you total support for your newly bought product; - * without even the implied warranty of MERCHANTABILITY or FITNESS FOR - * A PARTICULAR PURPOSE. See the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - #ifndef EQEMU_PETITIONS_REPOSITORY_H #define EQEMU_PETITIONS_REPOSITORY_H diff --git a/common/repositories/pets_beastlord_data_repository.h b/common/repositories/pets_beastlord_data_repository.h index 8d1f4c203..598c154d2 100644 --- a/common/repositories/pets_beastlord_data_repository.h +++ b/common/repositories/pets_beastlord_data_repository.h @@ -1,23 +1,3 @@ -/** - * EQEmulator: Everquest Server Emulator - * Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server) - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 2 of the License. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY except by those people which sell it, which - * are required to give you total support for your newly bought product; - * without even the implied warranty of MERCHANTABILITY or FITNESS FOR - * A PARTICULAR PURPOSE. See the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - #ifndef EQEMU_PETS_BEASTLORD_DATA_REPOSITORY_H #define EQEMU_PETS_BEASTLORD_DATA_REPOSITORY_H diff --git a/common/repositories/pets_equipmentset_entries_repository.h b/common/repositories/pets_equipmentset_entries_repository.h index cf9b8d3e0..b66f739c1 100644 --- a/common/repositories/pets_equipmentset_entries_repository.h +++ b/common/repositories/pets_equipmentset_entries_repository.h @@ -1,23 +1,3 @@ -/** - * EQEmulator: Everquest Server Emulator - * Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server) - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 2 of the License. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY except by those people which sell it, which - * are required to give you total support for your newly bought product; - * without even the implied warranty of MERCHANTABILITY or FITNESS FOR - * A PARTICULAR PURPOSE. See the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - #ifndef EQEMU_PETS_EQUIPMENTSET_ENTRIES_REPOSITORY_H #define EQEMU_PETS_EQUIPMENTSET_ENTRIES_REPOSITORY_H diff --git a/common/repositories/pets_equipmentset_repository.h b/common/repositories/pets_equipmentset_repository.h index 29f857881..e676ebe5b 100644 --- a/common/repositories/pets_equipmentset_repository.h +++ b/common/repositories/pets_equipmentset_repository.h @@ -1,23 +1,3 @@ -/** - * EQEmulator: Everquest Server Emulator - * Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server) - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 2 of the License. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY except by those people which sell it, which - * are required to give you total support for your newly bought product; - * without even the implied warranty of MERCHANTABILITY or FITNESS FOR - * A PARTICULAR PURPOSE. See the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - #ifndef EQEMU_PETS_EQUIPMENTSET_REPOSITORY_H #define EQEMU_PETS_EQUIPMENTSET_REPOSITORY_H diff --git a/common/repositories/pets_repository.h b/common/repositories/pets_repository.h index d7815d026..df8e66bc8 100644 --- a/common/repositories/pets_repository.h +++ b/common/repositories/pets_repository.h @@ -1,23 +1,3 @@ -/** - * EQEmulator: Everquest Server Emulator - * Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server) - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 2 of the License. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY except by those people which sell it, which - * are required to give you total support for your newly bought product; - * without even the implied warranty of MERCHANTABILITY or FITNESS FOR - * A PARTICULAR PURPOSE. See the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - #ifndef EQEMU_PETS_REPOSITORY_H #define EQEMU_PETS_REPOSITORY_H diff --git a/common/repositories/player_titlesets_repository.h b/common/repositories/player_titlesets_repository.h index bb7f79476..f2f679347 100644 --- a/common/repositories/player_titlesets_repository.h +++ b/common/repositories/player_titlesets_repository.h @@ -1,23 +1,3 @@ -/** - * EQEmulator: Everquest Server Emulator - * Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server) - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 2 of the License. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY except by those people which sell it, which - * are required to give you total support for your newly bought product; - * without even the implied warranty of MERCHANTABILITY or FITNESS FOR - * A PARTICULAR PURPOSE. See the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - #ifndef EQEMU_PLAYER_TITLESETS_REPOSITORY_H #define EQEMU_PLAYER_TITLESETS_REPOSITORY_H diff --git a/common/repositories/proximities_repository.h b/common/repositories/proximities_repository.h index 0f089f6f9..b0dc71b64 100644 --- a/common/repositories/proximities_repository.h +++ b/common/repositories/proximities_repository.h @@ -1,23 +1,3 @@ -/** - * EQEmulator: Everquest Server Emulator - * Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server) - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 2 of the License. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY except by those people which sell it, which - * are required to give you total support for your newly bought product; - * without even the implied warranty of MERCHANTABILITY or FITNESS FOR - * A PARTICULAR PURPOSE. See the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - #ifndef EQEMU_PROXIMITIES_REPOSITORY_H #define EQEMU_PROXIMITIES_REPOSITORY_H diff --git a/common/repositories/quest_globals_repository.h b/common/repositories/quest_globals_repository.h index 5e4f1095b..efdc6d5f0 100644 --- a/common/repositories/quest_globals_repository.h +++ b/common/repositories/quest_globals_repository.h @@ -1,23 +1,3 @@ -/** - * EQEmulator: Everquest Server Emulator - * Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server) - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 2 of the License. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY except by those people which sell it, which - * are required to give you total support for your newly bought product; - * without even the implied warranty of MERCHANTABILITY or FITNESS FOR - * A PARTICULAR PURPOSE. See the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - #ifndef EQEMU_QUEST_GLOBALS_REPOSITORY_H #define EQEMU_QUEST_GLOBALS_REPOSITORY_H diff --git a/common/repositories/raid_details_repository.h b/common/repositories/raid_details_repository.h index 58f44f0bb..524903cf2 100644 --- a/common/repositories/raid_details_repository.h +++ b/common/repositories/raid_details_repository.h @@ -1,23 +1,3 @@ -/** - * EQEmulator: Everquest Server Emulator - * Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server) - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 2 of the License. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY except by those people which sell it, which - * are required to give you total support for your newly bought product; - * without even the implied warranty of MERCHANTABILITY or FITNESS FOR - * A PARTICULAR PURPOSE. See the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - #ifndef EQEMU_RAID_DETAILS_REPOSITORY_H #define EQEMU_RAID_DETAILS_REPOSITORY_H diff --git a/common/repositories/raid_leaders_repository.h b/common/repositories/raid_leaders_repository.h index 03b258e39..0b6c344ff 100644 --- a/common/repositories/raid_leaders_repository.h +++ b/common/repositories/raid_leaders_repository.h @@ -1,23 +1,3 @@ -/** - * EQEmulator: Everquest Server Emulator - * Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server) - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 2 of the License. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY except by those people which sell it, which - * are required to give you total support for your newly bought product; - * without even the implied warranty of MERCHANTABILITY or FITNESS FOR - * A PARTICULAR PURPOSE. See the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - #ifndef EQEMU_RAID_LEADERS_REPOSITORY_H #define EQEMU_RAID_LEADERS_REPOSITORY_H diff --git a/common/repositories/raid_members_repository.h b/common/repositories/raid_members_repository.h index 76e1d0c39..e8f5ddb82 100644 --- a/common/repositories/raid_members_repository.h +++ b/common/repositories/raid_members_repository.h @@ -1,23 +1,3 @@ -/** - * EQEmulator: Everquest Server Emulator - * Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server) - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 2 of the License. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY except by those people which sell it, which - * are required to give you total support for your newly bought product; - * without even the implied warranty of MERCHANTABILITY or FITNESS FOR - * A PARTICULAR PURPOSE. See the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - #ifndef EQEMU_RAID_MEMBERS_REPOSITORY_H #define EQEMU_RAID_MEMBERS_REPOSITORY_H diff --git a/common/repositories/reports_repository.h b/common/repositories/reports_repository.h index a7b9b2512..96639f9d1 100644 --- a/common/repositories/reports_repository.h +++ b/common/repositories/reports_repository.h @@ -1,23 +1,3 @@ -/** - * EQEmulator: Everquest Server Emulator - * Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server) - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 2 of the License. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY except by those people which sell it, which - * are required to give you total support for your newly bought product; - * without even the implied warranty of MERCHANTABILITY or FITNESS FOR - * A PARTICULAR PURPOSE. See the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - #ifndef EQEMU_REPORTS_REPOSITORY_H #define EQEMU_REPORTS_REPOSITORY_H diff --git a/common/repositories/respawn_times_repository.h b/common/repositories/respawn_times_repository.h index 85d6604b8..a4d7179b6 100644 --- a/common/repositories/respawn_times_repository.h +++ b/common/repositories/respawn_times_repository.h @@ -1,23 +1,3 @@ -/** - * EQEmulator: Everquest Server Emulator - * Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server) - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 2 of the License. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY except by those people which sell it, which - * are required to give you total support for your newly bought product; - * without even the implied warranty of MERCHANTABILITY or FITNESS FOR - * A PARTICULAR PURPOSE. See the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - #ifndef EQEMU_RESPAWN_TIMES_REPOSITORY_H #define EQEMU_RESPAWN_TIMES_REPOSITORY_H diff --git a/common/repositories/rule_sets_repository.h b/common/repositories/rule_sets_repository.h index f2c1a364e..8e209435d 100644 --- a/common/repositories/rule_sets_repository.h +++ b/common/repositories/rule_sets_repository.h @@ -1,23 +1,3 @@ -/** - * EQEmulator: Everquest Server Emulator - * Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server) - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 2 of the License. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY except by those people which sell it, which - * are required to give you total support for your newly bought product; - * without even the implied warranty of MERCHANTABILITY or FITNESS FOR - * A PARTICULAR PURPOSE. See the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - #ifndef EQEMU_RULE_SETS_REPOSITORY_H #define EQEMU_RULE_SETS_REPOSITORY_H diff --git a/common/repositories/rule_values_repository.h b/common/repositories/rule_values_repository.h index 74e024734..6565893ef 100644 --- a/common/repositories/rule_values_repository.h +++ b/common/repositories/rule_values_repository.h @@ -1,23 +1,3 @@ -/** - * EQEmulator: Everquest Server Emulator - * Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server) - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 2 of the License. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY except by those people which sell it, which - * are required to give you total support for your newly bought product; - * without even the implied warranty of MERCHANTABILITY or FITNESS FOR - * A PARTICULAR PURPOSE. See the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - #ifndef EQEMU_RULE_VALUES_REPOSITORY_H #define EQEMU_RULE_VALUES_REPOSITORY_H diff --git a/common/repositories/saylink_repository.h b/common/repositories/saylink_repository.h index 902a762e5..4efc13ff1 100644 --- a/common/repositories/saylink_repository.h +++ b/common/repositories/saylink_repository.h @@ -1,23 +1,3 @@ -/** - * EQEmulator: Everquest Server Emulator - * Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server) - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 2 of the License. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY except by those people which sell it, which - * are required to give you total support for your newly bought product; - * without even the implied warranty of MERCHANTABILITY or FITNESS FOR - * A PARTICULAR PURPOSE. See the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - #ifndef EQEMU_SAYLINK_REPOSITORY_H #define EQEMU_SAYLINK_REPOSITORY_H diff --git a/common/repositories/server_scheduled_events_repository.h b/common/repositories/server_scheduled_events_repository.h index 33a683638..e42fa372d 100644 --- a/common/repositories/server_scheduled_events_repository.h +++ b/common/repositories/server_scheduled_events_repository.h @@ -1,23 +1,3 @@ -/** - * EQEmulator: Everquest Server Emulator - * Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server) - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 2 of the License. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY except by those people which sell it, which - * are required to give you total support for your newly bought product; - * without even the implied warranty of MERCHANTABILITY or FITNESS FOR - * A PARTICULAR PURPOSE. See the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - #ifndef EQEMU_SERVER_SCHEDULED_EVENTS_REPOSITORY_H #define EQEMU_SERVER_SCHEDULED_EVENTS_REPOSITORY_H diff --git a/common/repositories/shared_task_activity_state_repository.h b/common/repositories/shared_task_activity_state_repository.h index 281fd0b81..25aaa4391 100644 --- a/common/repositories/shared_task_activity_state_repository.h +++ b/common/repositories/shared_task_activity_state_repository.h @@ -1,23 +1,3 @@ -/** - * EQEmulator: Everquest Server Emulator - * Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server) - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 2 of the License. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY except by those people which sell it, which - * are required to give you total support for your newly bought product; - * without even the implied warranty of MERCHANTABILITY or FITNESS FOR - * A PARTICULAR PURPOSE. See the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - #ifndef EQEMU_SHARED_TASK_ACTIVITY_STATE_REPOSITORY_H #define EQEMU_SHARED_TASK_ACTIVITY_STATE_REPOSITORY_H diff --git a/common/repositories/shared_task_dynamic_zones_repository.h b/common/repositories/shared_task_dynamic_zones_repository.h index cc0440f0b..e3148cd9e 100644 --- a/common/repositories/shared_task_dynamic_zones_repository.h +++ b/common/repositories/shared_task_dynamic_zones_repository.h @@ -1,23 +1,3 @@ -/** - * EQEmulator: Everquest Server Emulator - * Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server) - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 2 of the License. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY except by those people which sell it, which - * are required to give you total support for your newly bought product; - * without even the implied warranty of MERCHANTABILITY or FITNESS FOR - * A PARTICULAR PURPOSE. See the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - #ifndef EQEMU_SHARED_TASK_DYNAMIC_ZONES_REPOSITORY_H #define EQEMU_SHARED_TASK_DYNAMIC_ZONES_REPOSITORY_H diff --git a/common/repositories/shared_task_members_repository.h b/common/repositories/shared_task_members_repository.h index b296f083a..d55289c17 100644 --- a/common/repositories/shared_task_members_repository.h +++ b/common/repositories/shared_task_members_repository.h @@ -1,23 +1,3 @@ -/** - * EQEmulator: Everquest Server Emulator - * Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server) - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 2 of the License. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY except by those people which sell it, which - * are required to give you total support for your newly bought product; - * without even the implied warranty of MERCHANTABILITY or FITNESS FOR - * A PARTICULAR PURPOSE. See the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - #ifndef EQEMU_SHARED_TASK_MEMBERS_REPOSITORY_H #define EQEMU_SHARED_TASK_MEMBERS_REPOSITORY_H diff --git a/common/repositories/shared_tasks_repository.h b/common/repositories/shared_tasks_repository.h index 3d14db9e1..827597b84 100644 --- a/common/repositories/shared_tasks_repository.h +++ b/common/repositories/shared_tasks_repository.h @@ -1,23 +1,3 @@ -/** - * EQEmulator: Everquest Server Emulator - * Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server) - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 2 of the License. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY except by those people which sell it, which - * are required to give you total support for your newly bought product; - * without even the implied warranty of MERCHANTABILITY or FITNESS FOR - * A PARTICULAR PURPOSE. See the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - #ifndef EQEMU_SHARED_TASKS_REPOSITORY_H #define EQEMU_SHARED_TASKS_REPOSITORY_H diff --git a/common/repositories/sharedbank_repository.h b/common/repositories/sharedbank_repository.h index 001931f6a..15243d83e 100644 --- a/common/repositories/sharedbank_repository.h +++ b/common/repositories/sharedbank_repository.h @@ -1,23 +1,3 @@ -/** - * EQEmulator: Everquest Server Emulator - * Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server) - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 2 of the License. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY except by those people which sell it, which - * are required to give you total support for your newly bought product; - * without even the implied warranty of MERCHANTABILITY or FITNESS FOR - * A PARTICULAR PURPOSE. See the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - #ifndef EQEMU_SHAREDBANK_REPOSITORY_H #define EQEMU_SHAREDBANK_REPOSITORY_H diff --git a/common/repositories/skill_caps_repository.h b/common/repositories/skill_caps_repository.h index 5798b6c89..6388bacc2 100644 --- a/common/repositories/skill_caps_repository.h +++ b/common/repositories/skill_caps_repository.h @@ -1,23 +1,3 @@ -/** - * EQEmulator: Everquest Server Emulator - * Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server) - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 2 of the License. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY except by those people which sell it, which - * are required to give you total support for your newly bought product; - * without even the implied warranty of MERCHANTABILITY or FITNESS FOR - * A PARTICULAR PURPOSE. See the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - #ifndef EQEMU_SKILL_CAPS_REPOSITORY_H #define EQEMU_SKILL_CAPS_REPOSITORY_H diff --git a/common/repositories/spawn2_repository.h b/common/repositories/spawn2_repository.h index 310e32ba6..5b2dabcaa 100644 --- a/common/repositories/spawn2_repository.h +++ b/common/repositories/spawn2_repository.h @@ -1,23 +1,3 @@ -/** - * EQEmulator: Everquest Server Emulator - * Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server) - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 2 of the License. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY except by those people which sell it, which - * are required to give you total support for your newly bought product; - * without even the implied warranty of MERCHANTABILITY or FITNESS FOR - * A PARTICULAR PURPOSE. See the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - #ifndef EQEMU_SPAWN2_REPOSITORY_H #define EQEMU_SPAWN2_REPOSITORY_H diff --git a/common/repositories/spawn_condition_values_repository.h b/common/repositories/spawn_condition_values_repository.h index a056a8fbe..14a136037 100644 --- a/common/repositories/spawn_condition_values_repository.h +++ b/common/repositories/spawn_condition_values_repository.h @@ -1,23 +1,3 @@ -/** - * EQEmulator: Everquest Server Emulator - * Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server) - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 2 of the License. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY except by those people which sell it, which - * are required to give you total support for your newly bought product; - * without even the implied warranty of MERCHANTABILITY or FITNESS FOR - * A PARTICULAR PURPOSE. See the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - #ifndef EQEMU_SPAWN_CONDITION_VALUES_REPOSITORY_H #define EQEMU_SPAWN_CONDITION_VALUES_REPOSITORY_H diff --git a/common/repositories/spawn_conditions_repository.h b/common/repositories/spawn_conditions_repository.h index 4d3e84a09..0ff130faa 100644 --- a/common/repositories/spawn_conditions_repository.h +++ b/common/repositories/spawn_conditions_repository.h @@ -1,23 +1,3 @@ -/** - * EQEmulator: Everquest Server Emulator - * Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server) - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 2 of the License. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY except by those people which sell it, which - * are required to give you total support for your newly bought product; - * without even the implied warranty of MERCHANTABILITY or FITNESS FOR - * A PARTICULAR PURPOSE. See the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - #ifndef EQEMU_SPAWN_CONDITIONS_REPOSITORY_H #define EQEMU_SPAWN_CONDITIONS_REPOSITORY_H diff --git a/common/repositories/spawn_events_repository.h b/common/repositories/spawn_events_repository.h index bbd91888f..4e008e79d 100644 --- a/common/repositories/spawn_events_repository.h +++ b/common/repositories/spawn_events_repository.h @@ -1,23 +1,3 @@ -/** - * EQEmulator: Everquest Server Emulator - * Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server) - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 2 of the License. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY except by those people which sell it, which - * are required to give you total support for your newly bought product; - * without even the implied warranty of MERCHANTABILITY or FITNESS FOR - * A PARTICULAR PURPOSE. See the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - #ifndef EQEMU_SPAWN_EVENTS_REPOSITORY_H #define EQEMU_SPAWN_EVENTS_REPOSITORY_H diff --git a/common/repositories/spawnentry_repository.h b/common/repositories/spawnentry_repository.h index f813da315..0a61a5287 100644 --- a/common/repositories/spawnentry_repository.h +++ b/common/repositories/spawnentry_repository.h @@ -1,23 +1,3 @@ -/** - * EQEmulator: Everquest Server Emulator - * Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server) - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 2 of the License. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY except by those people which sell it, which - * are required to give you total support for your newly bought product; - * without even the implied warranty of MERCHANTABILITY or FITNESS FOR - * A PARTICULAR PURPOSE. See the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - #ifndef EQEMU_SPAWNENTRY_REPOSITORY_H #define EQEMU_SPAWNENTRY_REPOSITORY_H diff --git a/common/repositories/spawngroup_repository.h b/common/repositories/spawngroup_repository.h index c741ed705..6e0a7b59b 100644 --- a/common/repositories/spawngroup_repository.h +++ b/common/repositories/spawngroup_repository.h @@ -1,23 +1,3 @@ -/** - * EQEmulator: Everquest Server Emulator - * Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server) - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 2 of the License. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY except by those people which sell it, which - * are required to give you total support for your newly bought product; - * without even the implied warranty of MERCHANTABILITY or FITNESS FOR - * A PARTICULAR PURPOSE. See the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - #ifndef EQEMU_SPAWNGROUP_REPOSITORY_H #define EQEMU_SPAWNGROUP_REPOSITORY_H diff --git a/common/repositories/spell_buckets_repository.h b/common/repositories/spell_buckets_repository.h index 55fb29e10..ddba4be0c 100644 --- a/common/repositories/spell_buckets_repository.h +++ b/common/repositories/spell_buckets_repository.h @@ -1,23 +1,3 @@ -/** - * EQEmulator: Everquest Server Emulator - * Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server) - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 2 of the License. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY except by those people which sell it, which - * are required to give you total support for your newly bought product; - * without even the implied warranty of MERCHANTABILITY or FITNESS FOR - * A PARTICULAR PURPOSE. See the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - #ifndef EQEMU_SPELL_BUCKETS_REPOSITORY_H #define EQEMU_SPELL_BUCKETS_REPOSITORY_H diff --git a/common/repositories/spell_globals_repository.h b/common/repositories/spell_globals_repository.h index 7172fa78d..91cb74caf 100644 --- a/common/repositories/spell_globals_repository.h +++ b/common/repositories/spell_globals_repository.h @@ -1,23 +1,3 @@ -/** - * EQEmulator: Everquest Server Emulator - * Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server) - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 2 of the License. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY except by those people which sell it, which - * are required to give you total support for your newly bought product; - * without even the implied warranty of MERCHANTABILITY or FITNESS FOR - * A PARTICULAR PURPOSE. See the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - #ifndef EQEMU_SPELL_GLOBALS_REPOSITORY_H #define EQEMU_SPELL_GLOBALS_REPOSITORY_H diff --git a/common/repositories/spells_new_repository.h b/common/repositories/spells_new_repository.h index bbdd7e3a5..cafbad33f 100644 --- a/common/repositories/spells_new_repository.h +++ b/common/repositories/spells_new_repository.h @@ -1,23 +1,3 @@ -/** - * EQEmulator: Everquest Server Emulator - * Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server) - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 2 of the License. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY except by those people which sell it, which - * are required to give you total support for your newly bought product; - * without even the implied warranty of MERCHANTABILITY or FITNESS FOR - * A PARTICULAR PURPOSE. See the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - #ifndef EQEMU_SPELLS_NEW_REPOSITORY_H #define EQEMU_SPELLS_NEW_REPOSITORY_H diff --git a/common/repositories/start_zones_repository.h b/common/repositories/start_zones_repository.h index ab987ad58..99f29da21 100644 --- a/common/repositories/start_zones_repository.h +++ b/common/repositories/start_zones_repository.h @@ -1,23 +1,3 @@ -/** - * EQEmulator: Everquest Server Emulator - * Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server) - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 2 of the License. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY except by those people which sell it, which - * are required to give you total support for your newly bought product; - * without even the implied warranty of MERCHANTABILITY or FITNESS FOR - * A PARTICULAR PURPOSE. See the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - #ifndef EQEMU_START_ZONES_REPOSITORY_H #define EQEMU_START_ZONES_REPOSITORY_H diff --git a/common/repositories/starting_items_repository.h b/common/repositories/starting_items_repository.h index cdacee34b..8389008ac 100644 --- a/common/repositories/starting_items_repository.h +++ b/common/repositories/starting_items_repository.h @@ -1,23 +1,3 @@ -/** - * EQEmulator: Everquest Server Emulator - * Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server) - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 2 of the License. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY except by those people which sell it, which - * are required to give you total support for your newly bought product; - * without even the implied warranty of MERCHANTABILITY or FITNESS FOR - * A PARTICULAR PURPOSE. See the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - #ifndef EQEMU_STARTING_ITEMS_REPOSITORY_H #define EQEMU_STARTING_ITEMS_REPOSITORY_H diff --git a/common/repositories/task_activities_repository.h b/common/repositories/task_activities_repository.h index b3c79340d..3a57ccdc4 100644 --- a/common/repositories/task_activities_repository.h +++ b/common/repositories/task_activities_repository.h @@ -1,23 +1,3 @@ -/** - * EQEmulator: Everquest Server Emulator - * Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server) - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 2 of the License. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY except by those people which sell it, which - * are required to give you total support for your newly bought product; - * without even the implied warranty of MERCHANTABILITY or FITNESS FOR - * A PARTICULAR PURPOSE. See the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - #ifndef EQEMU_TASK_ACTIVITIES_REPOSITORY_H #define EQEMU_TASK_ACTIVITIES_REPOSITORY_H diff --git a/common/repositories/tasks_repository.h b/common/repositories/tasks_repository.h index 26b9de229..59c2f14fa 100644 --- a/common/repositories/tasks_repository.h +++ b/common/repositories/tasks_repository.h @@ -1,23 +1,3 @@ -/** - * EQEmulator: Everquest Server Emulator - * Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server) - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 2 of the License. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY except by those people which sell it, which - * are required to give you total support for your newly bought product; - * without even the implied warranty of MERCHANTABILITY or FITNESS FOR - * A PARTICULAR PURPOSE. See the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - #ifndef EQEMU_TASKS_REPOSITORY_H #define EQEMU_TASKS_REPOSITORY_H diff --git a/common/repositories/tasksets_repository.h b/common/repositories/tasksets_repository.h index 42cf15116..44dd1fc47 100644 --- a/common/repositories/tasksets_repository.h +++ b/common/repositories/tasksets_repository.h @@ -1,23 +1,3 @@ -/** - * EQEmulator: Everquest Server Emulator - * Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server) - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 2 of the License. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY except by those people which sell it, which - * are required to give you total support for your newly bought product; - * without even the implied warranty of MERCHANTABILITY or FITNESS FOR - * A PARTICULAR PURPOSE. See the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - #ifndef EQEMU_TASKSETS_REPOSITORY_H #define EQEMU_TASKSETS_REPOSITORY_H diff --git a/common/repositories/template/base_repository.template b/common/repositories/template/base_repository.template index 128d8505a..701d41327 100644 --- a/common/repositories/template/base_repository.template +++ b/common/repositories/template/base_repository.template @@ -76,14 +76,14 @@ public: static {{TABLE_NAME_STRUCT}} NewEntity() { - {{TABLE_NAME_STRUCT}} entry{}; + {{TABLE_NAME_STRUCT}} e{}; {{DEFAULT_ENTRIES}} - return entry; + return e; } - static {{TABLE_NAME_STRUCT}} Get{{TABLE_NAME_STRUCT}}Entry( + static {{TABLE_NAME_STRUCT}} Get{{TABLE_NAME_STRUCT}}( const std::vector<{{TABLE_NAME_STRUCT}}> &{{TABLE_NAME_VAR}}s, int {{TABLE_NAME_VAR}}_id ) @@ -112,10 +112,10 @@ public: auto row = results.begin(); if (results.RowCount() == 1) { - {{TABLE_NAME_STRUCT}} entry{}; + {{TABLE_NAME_STRUCT}} e{}; {{FIND_ONE_ENTRIES}} - return entry; + return e; } return NewEntity(); @@ -140,10 +140,10 @@ public: static int UpdateOne( Database& db, - {{TABLE_NAME_STRUCT}} {{TABLE_NAME_VAR}}_entry + const {{TABLE_NAME_STRUCT}} &e ) { - std::vector update_values; + std::vector v; auto columns = Columns(); @@ -153,9 +153,9 @@ public: fmt::format( "UPDATE {} SET {} WHERE {} = {}", TableName(), - Strings::Implode(", ", update_values), + Strings::Implode(", ", v), PrimaryKey(), - {{TABLE_NAME_VAR}}_entry.{{PRIMARY_KEY_STRING}} + e.{{PRIMARY_KEY_STRING}} ) ); @@ -164,10 +164,10 @@ public: static {{TABLE_NAME_STRUCT}} InsertOne( Database& db, - {{TABLE_NAME_STRUCT}} {{TABLE_NAME_VAR}}_entry + {{TABLE_NAME_STRUCT}} e ) { - std::vector insert_values; + std::vector v; {{INSERT_ONE_ENTRIES}} @@ -175,36 +175,36 @@ public: fmt::format( "{} VALUES ({})", BaseInsert(), - Strings::Implode(",", insert_values) + Strings::Implode(",", v) ) ); if (results.Success()) { - {{TABLE_NAME_VAR}}_entry.{{PRIMARY_KEY_STRING}} = results.LastInsertedID(); - return {{TABLE_NAME_VAR}}_entry; + e.{{PRIMARY_KEY_STRING}} = results.LastInsertedID(); + return e; } - {{TABLE_NAME_VAR}}_entry = NewEntity(); + e = NewEntity(); - return {{TABLE_NAME_VAR}}_entry; + return e; } static int InsertMany( Database& db, - std::vector<{{TABLE_NAME_STRUCT}}> {{TABLE_NAME_VAR}}_entries + const std::vector<{{TABLE_NAME_STRUCT}}> &entries ) { std::vector insert_chunks; - for (auto &{{TABLE_NAME_VAR}}_entry: {{TABLE_NAME_VAR}}_entries) { - std::vector insert_values; + for (auto &e: entries) { + std::vector v; {{INSERT_MANY_ENTRIES}} - insert_chunks.push_back("(" + Strings::Implode(",", insert_values) + ")"); + insert_chunks.push_back("(" + Strings::Implode(",", v) + ")"); } - std::vector insert_values; + std::vector v; auto results = db.QueryDatabase( fmt::format( @@ -231,17 +231,17 @@ public: all_entries.reserve(results.RowCount()); for (auto row = results.begin(); row != results.end(); ++row) { - {{TABLE_NAME_STRUCT}} entry{}; + {{TABLE_NAME_STRUCT}} e{}; {{ALL_ENTRIES}} - all_entries.push_back(entry); + all_entries.push_back(e); } return all_entries; } - static std::vector<{{TABLE_NAME_STRUCT}}> GetWhere(Database& db, std::string where_filter) + static std::vector<{{TABLE_NAME_STRUCT}}> GetWhere(Database& db, const std::string &where_filter) { std::vector<{{TABLE_NAME_STRUCT}}> all_entries; @@ -256,17 +256,17 @@ public: all_entries.reserve(results.RowCount()); for (auto row = results.begin(); row != results.end(); ++row) { - {{TABLE_NAME_STRUCT}} entry{}; + {{TABLE_NAME_STRUCT}} e{}; {{ALL_ENTRIES}} - all_entries.push_back(entry); + all_entries.push_back(e); } return all_entries; } - static int DeleteWhere(Database& db, std::string where_filter) + static int DeleteWhere(Database& db, const std::string &where_filter) { auto results = db.QueryDatabase( fmt::format( @@ -291,6 +291,32 @@ public: 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); + } + }; #endif //EQEMU_BASE_{{TABLE_NAME_UPPER}}_REPOSITORY_H diff --git a/common/repositories/template/repository.template b/common/repositories/template/repository.template index 09e8f10a7..d5de51e4e 100644 --- a/common/repositories/template/repository.template +++ b/common/repositories/template/repository.template @@ -1,23 +1,3 @@ -/** - * EQEmulator: Everquest Server Emulator - * Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server) - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 2 of the License. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY except by those people which sell it, which - * are required to give you total support for your newly bought product; - * without even the implied warranty of MERCHANTABILITY or FITNESS FOR - * A PARTICULAR PURPOSE. See the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - #ifndef EQEMU_{{TABLE_NAME_UPPER}}_REPOSITORY_H #define EQEMU_{{TABLE_NAME_UPPER}}_REPOSITORY_H diff --git a/common/repositories/timers_repository.h b/common/repositories/timers_repository.h index e0490b57b..eb497f12b 100644 --- a/common/repositories/timers_repository.h +++ b/common/repositories/timers_repository.h @@ -1,23 +1,3 @@ -/** - * EQEmulator: Everquest Server Emulator - * Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server) - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 2 of the License. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY except by those people which sell it, which - * are required to give you total support for your newly bought product; - * without even the implied warranty of MERCHANTABILITY or FITNESS FOR - * A PARTICULAR PURPOSE. See the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - #ifndef EQEMU_TIMERS_REPOSITORY_H #define EQEMU_TIMERS_REPOSITORY_H diff --git a/common/repositories/titles_repository.h b/common/repositories/titles_repository.h index d74b9735d..3ff4544ae 100644 --- a/common/repositories/titles_repository.h +++ b/common/repositories/titles_repository.h @@ -1,23 +1,3 @@ -/** - * EQEmulator: Everquest Server Emulator - * Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server) - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 2 of the License. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY except by those people which sell it, which - * are required to give you total support for your newly bought product; - * without even the implied warranty of MERCHANTABILITY or FITNESS FOR - * A PARTICULAR PURPOSE. See the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - #ifndef EQEMU_TITLES_REPOSITORY_H #define EQEMU_TITLES_REPOSITORY_H diff --git a/common/repositories/tool_game_objects_repository.h b/common/repositories/tool_game_objects_repository.h index d25043305..0afbf2334 100644 --- a/common/repositories/tool_game_objects_repository.h +++ b/common/repositories/tool_game_objects_repository.h @@ -1,23 +1,3 @@ -/** - * EQEmulator: Everquest Server Emulator - * Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server) - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 2 of the License. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY except by those people which sell it, which - * are required to give you total support for your newly bought product; - * without even the implied warranty of MERCHANTABILITY or FITNESS FOR - * A PARTICULAR PURPOSE. See the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - #ifndef EQEMU_TOOL_GAME_OBJECTS_REPOSITORY_H #define EQEMU_TOOL_GAME_OBJECTS_REPOSITORY_H diff --git a/common/repositories/trader_audit_repository.h b/common/repositories/trader_audit_repository.h index d0773e506..491a4c1a6 100644 --- a/common/repositories/trader_audit_repository.h +++ b/common/repositories/trader_audit_repository.h @@ -1,23 +1,3 @@ -/** - * EQEmulator: Everquest Server Emulator - * Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server) - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 2 of the License. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY except by those people which sell it, which - * are required to give you total support for your newly bought product; - * without even the implied warranty of MERCHANTABILITY or FITNESS FOR - * A PARTICULAR PURPOSE. See the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - #ifndef EQEMU_TRADER_AUDIT_REPOSITORY_H #define EQEMU_TRADER_AUDIT_REPOSITORY_H diff --git a/common/repositories/trader_repository.h b/common/repositories/trader_repository.h index d8fc47357..31f8fae87 100644 --- a/common/repositories/trader_repository.h +++ b/common/repositories/trader_repository.h @@ -1,23 +1,3 @@ -/** - * EQEmulator: Everquest Server Emulator - * Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server) - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 2 of the License. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY except by those people which sell it, which - * are required to give you total support for your newly bought product; - * without even the implied warranty of MERCHANTABILITY or FITNESS FOR - * A PARTICULAR PURPOSE. See the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - #ifndef EQEMU_TRADER_REPOSITORY_H #define EQEMU_TRADER_REPOSITORY_H diff --git a/common/repositories/tradeskill_recipe_entries_repository.h b/common/repositories/tradeskill_recipe_entries_repository.h index 9ffa49519..cb575ed9c 100644 --- a/common/repositories/tradeskill_recipe_entries_repository.h +++ b/common/repositories/tradeskill_recipe_entries_repository.h @@ -1,23 +1,3 @@ -/** - * EQEmulator: Everquest Server Emulator - * Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server) - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 2 of the License. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY except by those people which sell it, which - * are required to give you total support for your newly bought product; - * without even the implied warranty of MERCHANTABILITY or FITNESS FOR - * A PARTICULAR PURPOSE. See the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - #ifndef EQEMU_TRADESKILL_RECIPE_ENTRIES_REPOSITORY_H #define EQEMU_TRADESKILL_RECIPE_ENTRIES_REPOSITORY_H diff --git a/common/repositories/tradeskill_recipe_repository.h b/common/repositories/tradeskill_recipe_repository.h index 9f9c3e01c..287fecd99 100644 --- a/common/repositories/tradeskill_recipe_repository.h +++ b/common/repositories/tradeskill_recipe_repository.h @@ -1,23 +1,3 @@ -/** - * EQEmulator: Everquest Server Emulator - * Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server) - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 2 of the License. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY except by those people which sell it, which - * are required to give you total support for your newly bought product; - * without even the implied warranty of MERCHANTABILITY or FITNESS FOR - * A PARTICULAR PURPOSE. See the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - #ifndef EQEMU_TRADESKILL_RECIPE_REPOSITORY_H #define EQEMU_TRADESKILL_RECIPE_REPOSITORY_H diff --git a/common/repositories/traps_repository.h b/common/repositories/traps_repository.h index 579857a9b..a32465fc5 100644 --- a/common/repositories/traps_repository.h +++ b/common/repositories/traps_repository.h @@ -1,23 +1,3 @@ -/** - * EQEmulator: Everquest Server Emulator - * Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server) - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 2 of the License. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY except by those people which sell it, which - * are required to give you total support for your newly bought product; - * without even the implied warranty of MERCHANTABILITY or FITNESS FOR - * A PARTICULAR PURPOSE. See the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - #ifndef EQEMU_TRAPS_REPOSITORY_H #define EQEMU_TRAPS_REPOSITORY_H diff --git a/common/repositories/tribute_levels_repository.h b/common/repositories/tribute_levels_repository.h index 5100d05d0..26fb01a24 100644 --- a/common/repositories/tribute_levels_repository.h +++ b/common/repositories/tribute_levels_repository.h @@ -1,23 +1,3 @@ -/** - * EQEmulator: Everquest Server Emulator - * Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server) - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 2 of the License. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY except by those people which sell it, which - * are required to give you total support for your newly bought product; - * without even the implied warranty of MERCHANTABILITY or FITNESS FOR - * A PARTICULAR PURPOSE. See the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - #ifndef EQEMU_TRIBUTE_LEVELS_REPOSITORY_H #define EQEMU_TRIBUTE_LEVELS_REPOSITORY_H diff --git a/common/repositories/tributes_repository.h b/common/repositories/tributes_repository.h index 793987301..ea0145057 100644 --- a/common/repositories/tributes_repository.h +++ b/common/repositories/tributes_repository.h @@ -1,23 +1,3 @@ -/** - * EQEmulator: Everquest Server Emulator - * Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server) - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 2 of the License. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY except by those people which sell it, which - * are required to give you total support for your newly bought product; - * without even the implied warranty of MERCHANTABILITY or FITNESS FOR - * A PARTICULAR PURPOSE. See the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - #ifndef EQEMU_TRIBUTES_REPOSITORY_H #define EQEMU_TRIBUTES_REPOSITORY_H diff --git a/common/repositories/variables_repository.h b/common/repositories/variables_repository.h index f4ffedbe9..216e234b3 100644 --- a/common/repositories/variables_repository.h +++ b/common/repositories/variables_repository.h @@ -1,23 +1,3 @@ -/** - * EQEmulator: Everquest Server Emulator - * Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server) - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 2 of the License. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY except by those people which sell it, which - * are required to give you total support for your newly bought product; - * without even the implied warranty of MERCHANTABILITY or FITNESS FOR - * A PARTICULAR PURPOSE. See the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - #ifndef EQEMU_VARIABLES_REPOSITORY_H #define EQEMU_VARIABLES_REPOSITORY_H diff --git a/common/repositories/veteran_reward_templates_repository.h b/common/repositories/veteran_reward_templates_repository.h index a4246ad53..24dfb94f3 100644 --- a/common/repositories/veteran_reward_templates_repository.h +++ b/common/repositories/veteran_reward_templates_repository.h @@ -1,23 +1,3 @@ -/** - * EQEmulator: Everquest Server Emulator - * Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server) - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 2 of the License. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY except by those people which sell it, which - * are required to give you total support for your newly bought product; - * without even the implied warranty of MERCHANTABILITY or FITNESS FOR - * A PARTICULAR PURPOSE. See the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - #ifndef EQEMU_VETERAN_REWARD_TEMPLATES_REPOSITORY_H #define EQEMU_VETERAN_REWARD_TEMPLATES_REPOSITORY_H diff --git a/common/repositories/zone_points_repository.h b/common/repositories/zone_points_repository.h index 8c404c382..bcf37abe9 100644 --- a/common/repositories/zone_points_repository.h +++ b/common/repositories/zone_points_repository.h @@ -1,23 +1,3 @@ -/** - * EQEmulator: Everquest Server Emulator - * Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server) - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 2 of the License. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY except by those people which sell it, which - * are required to give you total support for your newly bought product; - * without even the implied warranty of MERCHANTABILITY or FITNESS FOR - * A PARTICULAR PURPOSE. See the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - #ifndef EQEMU_ZONE_POINTS_REPOSITORY_H #define EQEMU_ZONE_POINTS_REPOSITORY_H diff --git a/common/repositories/zone_repository.h b/common/repositories/zone_repository.h index 95d6369be..09b91a788 100644 --- a/common/repositories/zone_repository.h +++ b/common/repositories/zone_repository.h @@ -1,23 +1,3 @@ -/** - * EQEmulator: Everquest Server Emulator - * Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server) - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 2 of the License. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY except by those people which sell it, which - * are required to give you total support for your newly bought product; - * without even the implied warranty of MERCHANTABILITY or FITNESS FOR - * A PARTICULAR PURPOSE. See the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - #ifndef EQEMU_ZONE_REPOSITORY_H #define EQEMU_ZONE_REPOSITORY_H diff --git a/utils/scripts/generators/repository-generator.pl b/utils/scripts/generators/repository-generator.pl index 2a35d9c23..09e68dd88 100644 --- a/utils/scripts/generators/repository-generator.pl +++ b/utils/scripts/generators/repository-generator.pl @@ -130,8 +130,7 @@ foreach my $table_to_generate (@tables) { # These tables don't have a typical schema my @table_ignore_list = ( "character_enabledtasks", - "grid", # Manually created - "grid_entries", # Manually created + # "grid", # Manually created # "tradeskill_recipe", # Manually created # "character_recipe_list", # Manually created "guild_bank", @@ -260,7 +259,7 @@ foreach my $table_to_generate (@tables) { $table_struct_columns .= sprintf("\t\t\%-${longest_data_type_length}s %s;\n", $struct_data_type, $column_name_formatted); # new entity - $default_entries .= sprintf("\t\tentry.%-${longest_column_length}s = %s;\n", $column_name_formatted, $default_value); + $default_entries .= sprintf("\t\te.%-${longest_column_length}s = %s;\n", $column_name_formatted, $default_value); # column names (string) $column_names_quoted .= sprintf("\t\t\t\"%s\",\n", format_column_name_for_mysql($column_name)); @@ -273,53 +272,53 @@ foreach my $table_to_generate (@tables) { # update one if ($extra ne "auto_increment") { - my $query_value = sprintf('\'" + Strings::Escape(%s_entry.%s) + "\'");', $table_name, $column_name_formatted); + my $query_value = sprintf('\'" + Strings::Escape(e.%s) + "\'");', $column_name_formatted); if ($data_type =~ /int|float|double|decimal/) { - $query_value = sprintf('" + std::to_string(%s_entry.%s));', $table_name, $column_name_formatted); + $query_value = sprintf('" + std::to_string(e.%s));', $column_name_formatted); } elsif ($data_type =~ /datetime/) { - $query_value = sprintf('FROM_UNIXTIME(" + (%s_entry.%s > 0 ? std::to_string(%s_entry.%s) : "null") + ")");', $table_name, $column_name_formatted, $table_name, $column_name_formatted); + $query_value = sprintf('FROM_UNIXTIME(" + (e.%s > 0 ? std::to_string(e.%s) : "null") + ")");', $column_name_formatted, $column_name_formatted); } $update_one_entries .= sprintf( - "\t\t" . 'update_values.push_back(columns[%s] + " = %s' . "\n", + "\t\t" . 'v.push_back(columns[%s] + " = %s' . "\n", $index, $query_value ); } # insert - my $value = sprintf("\"'\" + Strings::Escape(%s_entry.%s) + \"'\"", $table_name, $column_name_formatted); + my $value = sprintf("\"'\" + Strings::Escape(e.%s) + \"'\"", $column_name_formatted); if ($data_type =~ /int|float|double|decimal/) { - $value = sprintf('std::to_string(%s_entry.%s)', $table_name, $column_name_formatted); + $value = sprintf('std::to_string(e.%s)', $column_name_formatted); } elsif ($data_type =~ /datetime/) { - $value = sprintf('"FROM_UNIXTIME(" + (%s_entry.%s > 0 ? std::to_string(%s_entry.%s) : "null") + ")"', $table_name, $column_name_formatted, $table_name, $column_name_formatted); + $value = sprintf('"FROM_UNIXTIME(" + (e.%s > 0 ? std::to_string(e.%s) : "null") + ")"', $column_name_formatted, $column_name_formatted); } - $insert_one_entries .= sprintf("\t\tinsert_values.push_back(%s);\n", $value); - $insert_many_entries .= sprintf("\t\t\tinsert_values.push_back(%s);\n", $value); + $insert_one_entries .= sprintf("\t\tv.push_back(%s);\n", $value); + $insert_many_entries .= sprintf("\t\t\tv.push_back(%s);\n", $value); # find one / all (select) if ($data_type =~ /bigint/) { - $all_entries .= sprintf("\t\t\tentry.%-${longest_column_length}s = strtoll(row[%s], nullptr, 10);\n", $column_name_formatted, $index); - $find_one_entries .= sprintf("\t\t\tentry.%-${longest_column_length}s = strtoll(row[%s], nullptr, 10);\n", $column_name_formatted, $index); + $all_entries .= sprintf("\t\t\te.%-${longest_column_length}s = strtoll(row[%s], nullptr, 10);\n", $column_name_formatted, $index); + $find_one_entries .= sprintf("\t\t\te.%-${longest_column_length}s = strtoll(row[%s], nullptr, 10);\n", $column_name_formatted, $index); } elsif ($data_type =~ /datetime/) { - $all_entries .= sprintf("\t\t\tentry.%-${longest_column_length}s = strtoll(row[%s] ? row[%s] : \"-1\", nullptr, 10);\n", $column_name_formatted, $index, $index); - $find_one_entries .= sprintf("\t\t\tentry.%-${longest_column_length}s = strtoll(row[%s] ? row[%s] : \"-1\", nullptr, 10);\n", $column_name_formatted, $index, $index); + $all_entries .= sprintf("\t\t\te.%-${longest_column_length}s = strtoll(row[%s] ? row[%s] : \"-1\", nullptr, 10);\n", $column_name_formatted, $index, $index); + $find_one_entries .= sprintf("\t\t\te.%-${longest_column_length}s = strtoll(row[%s] ? row[%s] : \"-1\", nullptr, 10);\n", $column_name_formatted, $index, $index); } elsif ($data_type =~ /int/) { - $all_entries .= sprintf("\t\t\tentry.%-${longest_column_length}s = atoi(row[%s]);\n", $column_name_formatted, $index); - $find_one_entries .= sprintf("\t\t\tentry.%-${longest_column_length}s = atoi(row[%s]);\n", $column_name_formatted, $index); + $all_entries .= sprintf("\t\t\te.%-${longest_column_length}s = atoi(row[%s]);\n", $column_name_formatted, $index); + $find_one_entries .= sprintf("\t\t\te.%-${longest_column_length}s = atoi(row[%s]);\n", $column_name_formatted, $index); } elsif ($data_type =~ /float|double|decimal/) { - $all_entries .= sprintf("\t\t\tentry.%-${longest_column_length}s = static_cast(atof(row[%s]));\n", $column_name_formatted, $index); - $find_one_entries .= sprintf("\t\t\tentry.%-${longest_column_length}s = static_cast(atof(row[%s]));\n", $column_name_formatted, $index); + $all_entries .= sprintf("\t\t\te.%-${longest_column_length}s = static_cast(atof(row[%s]));\n", $column_name_formatted, $index); + $find_one_entries .= sprintf("\t\t\te.%-${longest_column_length}s = static_cast(atof(row[%s]));\n", $column_name_formatted, $index); } else { - $all_entries .= sprintf("\t\t\tentry.%-${longest_column_length}s = row[%s] ? row[%s] : \"\";\n", $column_name_formatted, $index, $index); - $find_one_entries .= sprintf("\t\t\tentry.%-${longest_column_length}s = row[%s] ? row[%s] : \"\";\n", $column_name_formatted, $index, $index); + $all_entries .= sprintf("\t\t\te.%-${longest_column_length}s = row[%s] ? row[%s] : \"\";\n", $column_name_formatted, $index, $index); + $find_one_entries .= sprintf("\t\t\te.%-${longest_column_length}s = row[%s] ? row[%s] : \"\";\n", $column_name_formatted, $index, $index); } # print $column_name . "\n"; diff --git a/world/world_server_command_handler.cpp b/world/world_server_command_handler.cpp index d02023e1d..dc59c6dda 100644 --- a/world/world_server_command_handler.cpp +++ b/world/world_server_command_handler.cpp @@ -200,7 +200,7 @@ namespace WorldserverCommandHandler { for (const auto &table: version_tables) { version_tables_json.append(table); } - + Json::Value bot_tables_json; std::vector bot_tables = DatabaseSchema::GetBotTables(); for (const auto &table: bot_tables) { @@ -429,7 +429,7 @@ namespace WorldserverCommandHandler { } /** - * Fetch all + * Insert Many */ int inserted_count = InstanceListRepository::InsertMany(database, instance_lists); @@ -439,6 +439,11 @@ namespace WorldserverCommandHandler { LogInfo("Iterating through entry id [{}] zone [{}]", entry.id, entry.zone); } + LogInfo("[Max ID] {}", InstanceListRepository::GetMaxId(database)); + LogInfo("[Count] {}", InstanceListRepository::Count(database)); + LogInfo("[Count Where] {}", InstanceListRepository::Count(database, "zone = 999")); + LogInfo("[Count Where] {}", InstanceListRepository::Count(database, "zone = 777")); + /** * Delete where */ diff --git a/zone/zone.cpp b/zone/zone.cpp index 705f10bac..d8b18e1e1 100755 --- a/zone/zone.cpp +++ b/zone/zone.cpp @@ -2667,8 +2667,8 @@ void Zone::SetQuestHotReloadQueued(bool in_quest_hot_reload_queued) void Zone::LoadGrids() { - zone_grids = GridRepository::GetZoneGrids(GetZoneID()); - zone_grid_entries = GridEntriesRepository::GetZoneGridEntries(GetZoneID()); + zone_grids = GridRepository::GetZoneGrids(content_db, GetZoneID()); + zone_grid_entries = GridEntriesRepository::GetZoneGridEntries(content_db, GetZoneID()); } Timer Zone::GetInitgridsTimer() diff --git a/zone/zone.h b/zone/zone.h index 11884892b..ef191d2b1 100755 --- a/zone/zone.h +++ b/zone/zone.h @@ -223,8 +223,8 @@ public: std::unordered_map> aa_abilities; std::unordered_map> aa_ranks; - std::vector zone_grids; - std::vector zone_grid_entries; + std::vector zone_grids; + std::vector zone_grid_entries; std::unordered_map> dynamic_zone_cache; std::unordered_map> expedition_cache;