Compare commits

..

190 Commits

Author SHA1 Message Date
hg 9118d13f2f Fix item reward message 2022-09-27 20:48:42 -05:00
hg 9f1519cd94 Validate reward item instance 2022-09-27 20:48:42 -05:00
hg 494789f8d0 Fix reward item instance memory leak 2022-09-27 20:48:42 -05:00
Akkadius 462f1a2f45 Implement stack counts 2022-09-27 20:48:42 -05:00
Akkadius 1b27b43a6b Update task_client_state.cpp 2022-09-27 20:48:42 -05:00
Akkadius 512f29c0d4 Task reward stacking 2022-09-27 20:48:42 -05:00
hg 1e136c4e2f Fix reward column name in conversion script 2022-09-27 20:48:42 -05:00
Akkadius ec68e2bb99 Tweaks 2022-09-27 20:48:42 -05:00
Akkadius 3e768ad03c Update 2022_09_25_task_concat_matchlists.sql 2022-09-27 20:48:42 -05:00
Akkadius f9ca3b49af Update 2022_09_25_task_concat_matchlists.sql 2022-09-27 20:48:42 -05:00
Akkadius b596784ae3 [Tasks] Deprecate goallists table, migrate reward goal lists, simplify logic 2022-09-27 20:48:42 -05:00
hg 64c5292c69 Combine task_activity item and npc fields
This will make tooling easier.

While denormalizing goallists may not be ideal, it decouples tasks from
rewards which share the table and removes a redundant column in favor
of a using the delimited string which better matches live packet data.
2022-09-27 20:48:42 -05:00
JJ d22fca7593 [Database Updates] Typo in manifest 9207 (#2451) 2022-09-27 20:21:09 -05:00
Aeadoin 2b203c0ebe [Bug Fix] Fix Swarm Pet Flurry/Rampages Messages (#2444)
* Fix Swarm Pet Flurry/Rampages Messages

* Fixed formatting
2022-09-25 13:00:43 -04:00
Chris Miles c826d3b4e9 [eqemu_server.pl] Remove non-working fetch_latest_windows_binaries() (#2445) 2022-09-25 13:00:33 -04:00
Chris Miles 78a9de124e [Command] Fix #copycharacter command crash (#2446) 2022-09-25 13:00:25 -04:00
Aeadoin 1ce272a1c3 [Feature] Allow Focus Effects to be Filtered out. (#2447) 2022-09-25 13:00:19 -04:00
Michael Cook (mackal) 678a4e30f5 Define is _WINDOWS not WINDOWS (#2439) 2022-09-21 12:43:38 -04:00
hg dbf8440a32 [Quest API] Let HasQuestSub check encounters (#2435)
This fixes an edge case where trading would not detect the npc had a
quest handler if it was registered inside a Lua encounter.
2022-09-20 13:21:48 -04:00
Aeadoin b2a73dc572 [Feature] Add Type 49545 to Spell Resistrictions (#2436) 2022-09-20 09:06:23 -04:00
Aeadoin 406ea039d7 [Bug Fix] Fix Spellinfo Command to work with SpellIDs above int16 (#2437)
* Fix Spellinfo Command SpellIDs to work above int16

* Updated to use int32_t
2022-09-20 09:06:01 -04:00
hg b4e46c1f7e [Tasks] Let task reward find free bag slots (#2431) 2022-09-18 10:45:34 -04:00
Chris Miles 5502ab8765 [Pathing] Fix pathing z-correctness for certain models (#2430)
* [Pathing] Fix pathing z-correctness for certain models

* Update npc.cpp

* Update npc.cpp

* Update npc.cpp
2022-09-11 13:05:20 -04:00
Aeadoin 7dc9b40ee1 [Feature] Update HateMod used by SPA 114 to Int32. (#2428) 2022-09-08 07:49:13 -04:00
hg 2c9fe4f2b8 [Tasks] Add rule to update multiple task elements (#2427)
On live if a task update would affect multiple elements, only the first
one gets updated. This was added as part of the changes in 7482cfc0.

Setting `UpdateOneElementPerTask` to false will restore the old behavior
that increments all active elements matching the task update criteria.
2022-09-06 12:42:45 -04:00
hg 78223b7ebf [Commands] Make #damage require a target (#2426)
Fixes annoying issue where it affected the client if no target
2022-09-05 12:12:46 -05:00
Michael Cook (mackal) 73f310d098 I guess we'll go plural (#2425) 2022-09-05 10:54:33 -04:00
Akkadius f22d90f6e2 [Hotfix] Add Bazaar portal discs to SQL 2022-09-05 04:30:49 -05:00
Chris Miles 78d4bd464e [Zone Points] Fix zone point heading data (#2415)
* [Zone Points] Fix zone point heading data

* Update 2022_09_03_fix_zone_point_heading_data.sql

* Augment #showzonepoints with saylinks

* Add more heading fixes to zone points

* Account for 999 target_heading

* Add zone safe headings
2022-09-05 04:08:34 -05:00
Chris Miles 186c2fe2ae [Doors] Fix door target zone heading data (#2414)
* [Doors] Fix door target zone heading

* Fix even more doors that were wrong to be accurate to live

* Update version.h
2022-09-05 04:06:39 -05:00
Chris Miles 5250b819fa [Character Starting Points] Fix headings data (#2413)
* [Character Starting Points] Fix headings

* Update version.h

Co-authored-by: Michael Cook (mackal) <277429+mackal@users.noreply.github.com>
2022-09-05 04:02:47 -05:00
Akkadius da4bcbf736 [Hotfix] Faction associations file naming / lock consistency 2022-09-05 00:10:21 -05:00
Michael Cook (mackal) d8134df679 Clang was complaining about these (#2421)
Checking if first char is null should be faster than strlen
2022-09-03 17:36:45 -04:00
hg 89382d5e4a [Tasks] Only allow shared task completion once (#2422)
This prevents re-triggering completion when a shared task contains
optional elements
2022-09-03 16:25:18 -05:00
hg aa3c72c1de [Tasks] Make Task Selector Cooldown Optional (#2420)
Some live npcs ignore the request cooldown timer (tutorialb)

A separate function had to be used for perl because the apis use an
array instead of array reference which won't allow a bool overload

This also replaces the fixed array and count args with a vector
2022-09-03 13:20:03 -04:00
Michael Cook (mackal) 5e9a9e8afe [Bug Fix] Shared Memory Faction Association Typo (#2419) 2022-09-03 12:08:40 -04:00
Michael Cook (mackal) ba53b4144e [Cleanup] Rework Lua QuestReward to not use try/catch blocks (#2417)
Quest system will catch any errors and result it in being reported where
these weren't
2022-09-03 12:07:46 -04:00
Kinglykrab 5134a0e43b [NPC Scaling] Recalculate Skills and Reload Spells on Level Change (#2416)
* [NPC Scaling] Recalculate Skills and Reload Spells on Level Change

- Add $npc->ReloadSpells() to Perl.
- Add npc:ReloadSpells() to Lua.

Previously, you would you have to manually call RecalculateSkills() after you scale the NPC, now the call is built in to the scaling.

Spells did not reload when NPCs were scaled, causing them to continue to use their low/high level spells depending upon which way their level had been scaled, this has been adding to the scaling method. This will make NPCs properly use their level-based spells.

RecalculateSkills() and ReloadSpells() can still be used manually if people scale using something other than the source scaling method. Having this functionality built in to the scaling itself just makes more sense to me. Open to any  ideas or thoughts.

* Reload spell effects, too.
2022-09-03 12:06:33 -04:00
Michael Cook (mackal) 402d742def Unsure how this seding messed up (#2418) 2022-09-03 11:53:43 -04:00
Michael Cook (mackal) 2b4e555eae [Feature] Faction Association (#2408)
* Add faction logging category

Probably should use this for more things

* Add FactionAssociation struct

This is simply just a struct that contains an array of faction ids and
multiplier. This can hold a maximum of 10 entries (Seru hit is 8, so 2
extra) this can be raised if need be.

* Add database changes and other data point changes

This is all the database changes and loading changes

Included is an optional SQL that will be used as a starting point, there
is likely errors or typos, but we will fix those as they are discovered.

* Add Client::RewardFaction function

This just takes the faction ID and the magnitude of the primary faction
hit and calculates the rest.

The minimum change will be either 1 or -1. We stop processing after we
see an ID of 0 and assume there will be no later entries.

The primary faction ID will always receive a hit even if there is no
faction association entries

* Add users of RewardFaction to NPC death, tasks, and QuestRewards

This will only use the new system if the magnitude is set, otherwise we
will just use the old system still

* Add quest system calls and lua QuestReward support

* Add #factionassociation command

This just calls RewardFaction, mostly useful for debugging
2022-09-03 10:57:55 -04:00
hg efe1879115 [Tasks] Change zone task data container (#2410)
This allows removal of the task id limit (MAXTASKS)

There's some suspect places task data isn't verified but left unchanged

If memory use becomes too high once more live data is added tasks can be
stored in shared memory instead
2022-09-03 03:33:49 -05:00
Chris Miles ec857cefae [Zoning] Fix zoning logic issues (#2412)
* [Zoning] Fix various zoning issues, flag logic, #zone etc

* Enforce character restrictions later in the connection process so we don't end up in a loop race condition in world
2022-09-03 00:57:57 -05:00
hg 034667f03b [Bug Fix] Avoid erase in discord queue range loop (#2411)
Erasing from the map inside the range loop invalidated the iterator used
internally by the loop. This caused ucs access violations under msvc
debug builds when a discord logging category was enabled.
2022-09-02 21:49:14 -05:00
hg d12145c449 [Bug Fix] Fix memory leak in ucs (#2409) 2022-09-02 21:48:33 -05:00
hg ce12481021 [Tasks] Tweak task update messages (#2406)
Excludes GiveCash since it uses copper amount for increments
2022-09-01 23:10:05 -05:00
hg 7cf96ca2d8 [Tasks] Remove delivered task items from trades (#2405) 2022-09-01 23:09:13 -05:00
hg e011864ed5 [Zone] Add missing safe_heading assignment (#2407)
Regression from 89fdd842e1
2022-09-01 23:04:35 -05:00
hg 7482cfc066 [Tasks] Replace task goals with explicit fields (#2402)
The task goal system made implementing tasks a little confusing since
the goal could be ambiguous depending on type. This also didn't support
filtering on multiple goals (e.g. looting items from matching npc names
inside an area). Deliver types could specify an npc id in `delivertonpc`
but the database may have multiple npcs with the same name or a task
might want to match partial npc names.

This replaces goalids with explicit fields for npcs, items, proximity
areas, and touch switch ids. These changes make managing task data
easier without needing to update multiple tables and allows filtering
task updates by multiple criteria. To mitigate any performance impact
from merging task proximities, only clients with explore tasks in the
current zone are checked during client movement updates.

Items and npcs still support goallists but it would be possible to
denormalize entries into delimited strings to combine with the match
lists. This would also decouple task goals from reward lists.

The client task update functions were refactored to run through a single
filtering function which significantly reduces duplicated code from the
legacy task system. This will also make it easier to later implement
any unhandled types.

Since the new fields will handle filtering single entries and lists
based on having values set, `goalmethod` now only distinguishes quest
controlled from source controlled.

This is a breaking api change, `taskexploredarea` has been removed
since explore ids no longer exist.
2022-09-01 19:18:21 -05:00
Michael Cook (mackal) 8851b410d2 [Bug Fix] Resolve logic error in Raid::QueueClients (#2404)
We're checking if they're groupless here, so this should be correct now
2022-09-01 18:48:47 -05:00
Chris Miles 89fdd842e1 [Code Cleanup] Zone Data Loading Refactor (#2388)
* [Code Cleanup] Zone data loading refactor

* Update client_packet.cpp

* strcpy adjustments

* Ensure safe points get reloaded properly

* Simplify GetPEQZone and getZoneShutDownDelay

* Bring in zone_store where needed

* Update client.cpp

* Signature

* Signature

* Convert helpers to using pointers

* PR comment

* Update worlddb.cpp

* Fix loading for instances

* Fix zoning with fallback as well

* Another place for instance fallback
2022-09-01 18:48:28 -05:00
Michael Cook (mackal) c613dbb2f7 Fix issues with Client::SetHideMe (#2403)
Arg was shadowing the member variable and we weren't updating the member
variable
2022-09-01 11:48:23 -04:00
Michael Cook (mackal) 6f7fa98996 [Repositories] Add more precise types to repository generator (#2391)
* Make utils/scripts/generators/repository-generator.pl aware of more
datatypes

This adds support for unsigned and more integer types. It also avoids
using parsing functions that require casting (still needed in some
cases)

Having the data types in the Repository structs better map to the types
in the database will allow us to avoid casting when we pull data out of
them. And as a benefit, assume something is wrong if we do :)

Hopefully clean up some warnings due to casting too.

Co-authored-by: Akkadius <akkadius1@gmail.com>
2022-08-31 00:04:27 -05:00
Kinglykrab fcf01f6d87 [Commands] Add #findrecipe and #viewrecipe Commands. (#2401)
* [Commands] Add #findrecipe and #viewrecipe Commands.

- Add #findrecipe [Search Critieria] command.
- Add #viewrecipe [Recipe ID] command.
- #findrecipe will show #viewrecipe saylinks if the user has access to that command.
- #viewrecipe will show #summonitem saylinks if the user has access to that command.

* Cleanup

* Lexicon change.

* Remove unnecessary .c_str() and
2022-08-30 23:32:17 -05:00
Michael 3228d6edf6 [Bug] Loot Drop Randomization adjustment (#2368)
* [Bug] Loot Drop Randomization adjustment

Loot Table currently favors the first item in the loot drop. This should help remove that condition.

Code by Ailia.

* snake_case

Co-authored-by: Akkadius <akkadius1@gmail.com>
2022-08-30 23:31:07 -05:00
Aeadoin 149fa54cfa [Feature] Implement Heroic Strikethrough to NPCs (#2395)
* [Feature] Implement Heroic Strikethrough to NPCs

* Removed virtual from inline int32 GetHeroicStrikethrough()

* Fix formatting

* Removed unnecessary function
2022-08-30 23:29:41 -05:00
Michael Cook (mackal) edda5ef811 [Utility] Add std::string_view overloads for std::from_chars (#2392)
* Add std::string_view overloads for std::from_chars

std::from_chars floating point support is still pour, so we provide some
fall backs. These fall backs currently lack error handling.

(since GCC 11 and MSVC 2019 16.4 FP support is added, clang with libc++
still doesn't support FP)

GCC's floating point support is still rather pour (performance) and
probably shouldn't be used, but we have support to if people want to
now.

Probably need more test cases ...

* Fix issue with std::chars_format define lacking

My test case for lacking FP support was clang with libc++ which defined
this enum anyways.
2022-08-30 23:13:59 -05:00
Chris Miles 786a7e2169 [Zone] Fix and simplify zone shutdown logic (#2390)
* Fix and simplify zone shutdown logic

* Add ResetShutdownTimer
2022-08-30 23:08:24 -05:00
Michael Cook (mackal) 59584a8d94 Use macro to generate correct format specifier (#2400)
Windows and Linux use different data models on 64 bit systems so "%lld"
isn't the same on them.
2022-08-28 14:38:26 -04:00
hg 94ac04b360 [Bug Fix] Fix loading world shared task state (#2398)
The default for this field is -1 not 0, so on world restarts this was
marking all elements completed
2022-08-28 13:16:35 -04:00
Kinglykrab 3e703769a4 [Quest API] Allow CreateInstance to be used without a Client initiator. (#2399)
* [Quest API] Allow CreateInstance to be used without a Client initiator.

Currently, you have to create the instance with a client initiator, whether that's in an NPC's EVENT_SAY /EVENT_ITEM or in a player script.

This will allow you to create instances without needing a client, but if there is one and there are errors, the messages will be sent to the client.

* Update questmgr.h

* Instance version.
2022-08-28 13:10:19 -04:00
Kinglykrab 57b3255fad [Quest API] Add Recipe Methods (#2393)
- Add $client->GetRecipeMadeCount(recipe_id) to Perl.
- Add $client->HasRecipeLearned(recipe_id) to Perl.
- Add quest::getrecipemadecount(recipe_id) to Perl.
- Add quest::getrecipename(recipe_id) to Perl.
- Add quest::hasrecipelearned(recipe_id) to Perl.
- Add client:GetRecipeMadeCount(recipe_id) to Lua.
- Add client:HasRecipeLearned(recipe_id) to Lua.
- Add eq.get_recipe_made_count(recipe_id) to Lua.
- Add eq.get_recipe_name(recipe_id) to Lua.
- Add eq.has_recipe_learned(recipe_id) to Lua.
2022-08-23 13:23:33 -05:00
Michael Cook (mackal) 10fd26ebbf [Manifest] Its not_empty not notempty (#2394) 2022-08-22 22:26:24 -05:00
Kinglykrab b9d8a13c76 [Bug Fix] Fix Silent Saylinks Sending Message to Others. (#2389)
* [Bug Fix] Fix Silent Saylinks Sending Message to Others.
Silent saylinks wouldn't send to sender, but to everyone else, so they could see what your saylinks were.

Added an optional `is_silent` bool to ChannelMessageReceived to account for this where necessary.

* Nullptr fix.
2022-08-21 23:26:25 -04:00
Chris Miles c0d4dd4176 [Expansions] Zone expansion consistency changes (#2380)
* [Expansions] Zone expansion consistency changes

* Add expansion check exclusions

* Update 2022_08_19_zone_expansion_consistency.sql
2022-08-21 20:36:21 -05:00
Kinglykrab 6637e2c59f [Feature] Add Guild Chat to Console. (#2387)
Adds guild chat to console.
2022-08-21 20:55:26 -04:00
hg e65b61a95f [Tasks] Implement task activity prerequisites (#2374)
Some live tasks make new elements available without requiring all
currently active ones to be completed first.

This adds the `req_activity_id` field to task activities which will mark
an element active if its required activity id is completed. If a valid
value is set then it's used instead of checking the current step.

The `step` field may still be set on rows with a valid `req_activity_id`
to specify its logical step and prevent later steps from becoming active
until completed. It's only ignored when deciding if the current element
is active.

The legacy task logic for unlocking activities was completely refactored
for this. A common method has been added so both zone and world can make
use of it to determine which elements are currently active. The previous
step system should remain unchanged.

The world logic for locking shared tasks when an element became active
did not account for "sequential" mode (all steps 0), unordered steps, or
gaps in step numbers. This also resolves that issue.
2022-08-21 19:55:19 -05:00
Kinglykrab c954685239 [Bug Fix] Fix Duplicate Silent Saylink Messages (#2386)
Clicking silent saylinks was sending the message twice if you had an NPC targeted due to duplicate code within ChannelMessageReceived.
2022-08-21 20:54:40 -04:00
Chris Miles 893d53425a [Repository] Modernize character recipe list (#2385) 2022-08-21 19:06:57 -05:00
Chris Miles 295ec0e1b4 [Tasks] Data validation for zone_version (#2381)
* [Tasks] Data validation for zone_version

* Update task_manager.cpp

* Update task_manager.cpp

* Update task_manager.cpp

* Update task_manager.cpp
2022-08-21 14:45:06 -05:00
Aeadoin 1d8dc4c8a8 [Feature] Change Mana Costs to use Signed Int (#2384) 2022-08-21 15:38:21 -04:00
Kinglykrab b108828502 [Bug Fix] Fix Strings::Money Missing Conditions. (#2383)
Noudess pointed out we were missing CSP, CP, and SP options in these conditions.
2022-08-21 15:00:02 -04:00
Michael Cook (mackal) 3f9df40c3c Update CURRENT_BINARY_DATABASE_VERSION (#2382)
PR #2376 didn't update it
2022-08-20 17:20:37 -04:00
Kinglykrab 3e8d34825a [Quest API] Add Goto Player Teleport Methods. (#2379)
* [Quest API] Add Player Teleport Methods.

These methods will allow server operators to teleport players directly to other players via the quest API using the #goto command's functionality.
- Add $client->TeleportToPlayerByCharID(character_id) to Perl.
- Add $client->TeleportToPlayerByName(player_name) to Perl.
- Add $client->TeleportGroupToPlayerByCharID(character_id) to Perl.
- Add $client->TeleportGroupToPlayerByName(player_name) to Perl.
- Add $client->TeleportRaidToPlayerByCharID(character_id) to Perl.
- Add $client->TeleportRaidToPlayerByName(player_name) to Perl.
- Add client:TeleportToPlayerByCharID(character_id) to Lua.
- Add client:TeleportToPlayerByName(player_name) to Lua.
- Add client:TeleportGroupToPlayerByCharID(character_id) to Lua.
- Add client:TeleportGroupToPlayerByName(player_name) to Lua.
- Add client:TeleportRaidToPlayerByCharID(character_id) to Lua.
- Add client:TeleportRaidToPlayerByName(player_name) to Lua.

* Simplify by using repositories

* Simplify

Co-authored-by: Akkadius <akkadius1@gmail.com>
2022-08-20 10:23:41 -04:00
Kinglykrab 59691f39d7 [Commands] Command Status Reload and Helper Method (#2377)
* [Commands] Command Status Reloading

Currently command status changes require a server restart to take effect, this will allow them to be changed and use `#reload commands` without needing a restart.

Added a helper method called GetCommandStatus() for future reference when sending command saylinks to people and making sure if they're high enough status for the command before sending the link.

* Update client.cpp

* Update command.h

* Saylink cleanup.

* Remove unnecessary packet sending.

* Revert "Remove unnecessary packet sending."

This reverts commit e7e77b83af.
2022-08-20 10:23:26 -04:00
Kinglykrab 8e3ad529dc [Feature] Instance Version Specific Experience Modifiers (#2376)
* [Feature] Add Instance Version Support to Experience Modifiers.

Allows Operators to set experience modifiers to be instance version specific so that you can have different versions of the same zone have different modifiers. If there is not one found, it defaults to zone_id 0 for global and instance_veresion -1 for global.

* Update zonedb.cpp

* Typo.
2022-08-20 03:16:58 -05:00
Chris Miles 607871a7ac [Loot] Add #lootsim (Loot Simulator) command (#2375)
* [Loot] Add #lootsim (Loot Simulator) command

* Validation

* Add global loot
2022-08-20 03:16:09 -05:00
Kinglykrab 6232a64cdb [Bug Fix] Fix Bot Group Loading (#2366)
* [Bug Fix] Fix Bot Group Loading

There were some weird cases where this code would falsely say a bot group did not exist and this would disallow summoning this botgroup as well as deleting it.

* Typo.
2022-08-20 03:15:58 -05:00
Michael Cook (mackal) 25c6b055a4 Fix issue with trap auras casting on caster (#2378)
Unsure if something changed or I just failed to test correctly
2022-08-18 12:34:37 -04:00
Kinglykrab 216b6ef426 [Saylinks] Convert all GM Command Saylinks to Silent Saylinks. (#2373)
* [Saylinks] Convert all GM Command Saylinks to Silent Saylinks.
- This cleans up all non-silent GM Command Saylinks that we had before due to the way they worked before. All saylinks like this should be silent now.
- Add source short hand capability for say links with same link as text.

* Defaults to r anyway.

* Spacing.
2022-08-13 20:40:22 -04:00
Chris Miles 597b041d92 [Saylinks] Add Silent helper (#2372)
* [Saylinks] Add Silent helper

* Swap out usage in door manipulation for silent saylink helper
2022-08-13 19:44:53 -04:00
Michael f6889d20e9 [Bug] UINT32 EmoteID (#2369)
emoteid packet structure is UINT32 but a number of references are in UINT16.
2022-08-13 18:41:14 -05:00
Chris Miles 79285b1002 [Repositories] Add GetMaxId, Count (#2371)
* [Repositories] Add GetMaxId, Count

* Update cmake with repositories, regenerate extended repos

* Remove license from files

* Simplify receivers

* Receiver simplify remaining

* Simplify receivers final

* Pass params by const reference

* Modernize grid tables

* Remove guild members since it doesn't conform as a generatable table

* PR comment
2022-08-13 18:40:56 -05:00
Chris Miles b79e1947f1 [Doors] Improvements to door manipulation (#2370) 2022-08-13 18:16:55 -05:00
Kinglykrab aa2b7f8947 [Quest API] Add GetSkillDmgAmt() to Perl. (#2365)
- Add $mob->GetSkillDmgAmt(skill_id) to Perl.
- This already exists in Lua, but not Perl.
2022-08-10 13:39:51 -04:00
Aeadoin 1d5a3a82a8 [Feature] Change GetSkillDmgAmt to int32 (#2364) 2022-08-09 21:24:15 -04:00
Kinglykrab 8ee7759dec [Rules] Add Rule to Enable Tells with #hideme (#2358)
With the recent changes to #hideme as of #2328, tells are disabled to hidden GMs, meaning a GM must show themselves in order to receive tells.
2022-08-04 16:41:36 -04:00
Chris Miles 5ec18709a6 [Hotfix] Remove expansion field from account for those who have it (#2357) 2022-08-01 15:07:36 -05:00
hg 7c27c4350d [Tasks] Add task accept packet validation (#2354)
This makes it so clients can only accept tasks that have been offered
2022-07-31 17:54:42 -05:00
hg 6068085de4 [Quest API] Fix lua task selector count when over max (#2353)
This was leaving the task count at 0 if called with more than the max
number of tasks (40)
2022-07-31 17:52:18 -05:00
Kinglykrab e1f515ba4b [Typo] Remove CanTradeFVNoDropItem() Duplicate (#2352) 2022-07-31 13:57:48 -05:00
hg c7a3e88b81 [Tasks] Make #task reloadall not quit shared tasks (#2351)
This was causing #task reloadall to desync state for shared tasks.
Characters were removed from the shared task but remained in the
character_tasks table. This CancelTask is cosmetic only to reload
the client window.
2022-07-31 13:57:33 -05:00
Kinglykrab b0da836f5a [Quest API] Add GetBotItem() and GetBotItemIDBySlot() to Perl/Lua. (#2350)
- Add $bot->GetBotItem() to Perl.
- Add $bot->GetBotItemIDBySlot() to Perl.
- Add bot:GetBotItem() to Lua.
- Add bot:GetBotItemIDBySlot() to Lua.
2022-07-31 13:45:17 -05:00
Michael Cook (mackal) a24a6f1160 [Code Cleanup] Resolve some warnings in loginserver/world_server.cpp (#2347) 2022-07-31 13:25:09 -05:00
hg be1e558b3b [Shared Tasks] Fix shared task message target (#2349)
Small regression from refactoring
2022-07-31 13:24:36 -05:00
hg c4a99aabd0 [Shared Tasks] Avoid erasing shared tasks while iterating (#2348)
This wasn't safe since the erase would invalidate iterators used
internally by the range loops.

Shared tasks with no members are now also cleaned up

Make GetMembers return reference instead of copy (this is used a lot)

Add rule for shared task terminate time for easier debugging
2022-07-31 13:24:21 -05:00
Akkadius 0dfc6eaa15 [Hotfix] Fix potential race for crash dumps (Linux) 2022-07-31 04:10:09 -05:00
Akkadius 3cccb183a2 [Hotfix] SQL Update 2022-07-31 03:00:24 -05:00
Michael Cook (mackal) c6cfcc3ea9 [Bug Fix] Limit merchant temp item list to zone and instance (#2346)
This prevents issues with a merchant being in more than one zone as well
as guild hall merchants sharing a list of temp items
2022-07-30 22:22:09 -05:00
hg 53b599518a [Dynamic Zones] Implement dz templates (#2345)
This allows shared tasks to create dz instances automatically through
the `dz_template_id` field instead of using quest scripts. Quest apis
were also added to create expeditions from template ids.
2022-07-30 21:25:43 -05:00
hg 5e7e255d72 [Tasks] Use dz switch id for task touch events (#2344)
This changes task touch elements to use the dz_switch_id as the goal id
instead of checking if a player zoned. It will remove the need to script
door clicks or modify task element zone field since task packet data can
just be imported.
2022-07-30 21:14:22 -05:00
hg 676467cbdc [Dynamic Zones] Implement dz switch id (#2343)
This adds the `dz_switch_id` field to doors and dynamic_zones. It will
allow for compasses to be automatically added to dz entrances and will
support moving clients to the dz on use without needing to script it.
These can be imported for switches/doors from live packet dumps.

Also removes compass packet encoders (same struct in all clients)
2022-07-30 21:00:11 -05:00
hg 1351f147f4 [Shared Tasks] Enforce task reqs on player removal (#2342)
This verifies a shared task's minimum players requirement is still met
when a member is removed and schedules it for termination if not
2022-07-30 20:49:57 -05:00
hg d243cbf8a3 [Shared Tasks] Cleanup shared task request and remove (#2341)
Functionally nothing should change in this patch. This refactors a lot
of formatting and code duplication in requests and member removals.

The long SharedTaskMessage namespace and its constants were contributing
to a lot of formatting that was difficult to read. These were shortened
since they're not all shared task specific anyway (though they should
probably just be moved to string_ids.h with other eqstrs now)

Shared task requests were refactored a little to remove an unnecessary
function that filled potential members. The separate functions used for
/taskquit and /taskremove were also combined into a single function to
remove a member while preserving live message differences.
2022-07-30 20:36:04 -05:00
hg 8a962e09f6 [Shared Tasks] Implement task timer groups (#2340)
This adds task replay and request timer groups (an arbitrary id) which
allows for different tasks to share lockouts
2022-07-30 20:18:19 -05:00
hg f64d072af7 [Shared Tasks] Implement Activity Locking (#2339)
* Add shared task element locking

This adds the `lock_activity_id` field to the tasks table which will
automatically lock a shared task when that element becomes active.

A method was added to world analogous to zone's UnlockActivities to
determine when an activity is active with respect to task steps.

Also adds quest apis to manually lock or unlock a client's shared task

* Add comment
2022-07-30 19:57:57 -05:00
Michael ea878ed27f [Feature] GM State Change Persistance (#2328)
* [Feature] GM State Change Persistance

- Flymode and Invulnerable will now persist over zoning.

- Appended GMSpeed, Flymode and Invulnerable to the hideme message GMs see when they first login.

- Added #godmode [on/off] command to turn on or off hideme, flymode, gmspeed and invulnerable all in one shot.

- /becomenpc will now disable tells to the target player. It will also automatically disable GM States that interfere with its functionality.

- GM Command /toggle will not properly turn tells on/off

- GMs will now be notified if they are ignoring tells when they first zone-in, provided their GM flag is up.

- Added TellsOff variable to the output to #showstats

* [Bug] Fix tells when gmhideme is turned off.

* [Cleanup] Cleanup function and rename for consistancy.

Remove un-needed this->

* Tweaks

* Tweaks

* Update db_update_manifest.txt

* Move string building logic to a vector and use strings join

* Update client_packet.cpp

* Update 2022_07_28_gm_state_changes.sql

* PR comment tweaks

Co-authored-by: Akkadius <akkadius1@gmail.com>
2022-07-30 19:29:24 -05:00
hg 793d4bc3a4 [Quest API] Use Floating Point for CameraEffect Intensity (#2337)
This was implemented in a very odd way. The intensity is just a float.

This is a breaking api change but low-impact (intensity will be
different).

To convert old values to new values with same intensity:

  0: 0.03125
  1: 0.05625
  2: 0.1
  3: 0.175
  4: 0.3
  5: 0.5
  6: 0.9
  7: 1.6
  8: 2.8
  9: 4.8
 10: 8.0
2022-07-30 19:18:20 -05:00
hg 4592c15dd6 [Tasks] Send Client Message for All Solo Task Updates (#2336)
Live sends the task updated message for every solo quest and task
increment (not just goal completed).

Also changed color to what live uses now. There are some other color
changes with shared task messages but they correspond with colors
changed in client generated messages but probably not worth chasing
down and causing inconsistency.
2022-07-30 19:17:24 -05:00
hg 4cf6db79aa [Saylinks] Inject Saylinks in MessageClose API (#2335) 2022-07-30 19:16:25 -05:00
Kinglykrab 576e7b0f91 [Quest API] Add IsRareSpawn() to Perl/Lua. (#2338)
- Add $npc->IsRareSpawn() to Perl.
- Add npc:IsRareSpawn() to Lua.
2022-07-30 19:40:51 -04:00
Paul Coene 113846c48c [Roambox] Improve Path Finding (#2324) 2022-07-30 14:52:28 -05:00
Michael Cook (mackal) dd71420a0e [Feature] NPCs with bows and arrows do ranged attacks (#2322)
* NPCs with bows and arrows do ranged attacks

Who knew!!

* PR comments

Co-authored-by: Akkadius <akkadius1@gmail.com>
2022-07-30 14:28:06 -05:00
Michael 0f9427098d [Rules] Add adjustment for zone forage. (#2330)
* [Rules] Add adjustment for zone forage.

- Added rule to allow the adjustment of zone foraging %

* Cleanup if formating
2022-07-30 13:39:12 -05:00
Aeadoin 25705878d8 [Feature] Change mana_used to int32 (#2321)
* Changed mana_used to use int32,
to match int32 mana_cost
This will allow higher mana costs to function

* Corrected DoHPToManaCovert to Int32

* Removed unused uint16 GetMana function call from Server/zone/questmgr.h

* Change GetSkillDmgAmt from Int16 to Int32 (SkillDamageAmount2 which uses function is Int32)

* Delete mob.cpp

* Revert "Delete mob.cpp"

This reverts commit 3db8bf04d1.

* Revert "Change GetSkillDmgAmt from Int16 to Int32 (SkillDamageAmount2 which uses function is Int32)"

This reverts commit cf5dbc9ce8.

Co-authored-by: dmcintosh-BCT <dan@blackcreektechnologies.com>
2022-07-30 13:36:48 -05:00
hg 6e2d11a283 [Tasks] Support Raw NPC Names in Task Goal List (#2333) 2022-07-30 13:33:53 -05:00
hg 2ccf692167 [Tasks] Use CashReward for Tasks (#2332)
Also removes the sound which does not occur
2022-07-30 13:33:05 -05:00
Trent 5e50c4181f [Rules] Add Keep Level on Death (#2319)
* add keep level on death rule

* add keep level on death rule

* add sql rule

* add rule db update

* remove unnecessary manifest entry

* remove unnecessary sql migration

* fix casing
2022-07-30 13:32:21 -05:00
hg eaeb583048 [Tasks] Add Task Reward Points Field (#2317)
* Add task reward points field

This replaces the separate DoN crystal reward fields with points and
point_type fields. This will make it easier to import data from
packet/client captures and possibly better support any future clients
or tasks that don't reward through the newer reward window.

* Fix manifest column check
2022-07-30 13:31:34 -05:00
Quintinon c68ff9bc5a [Rules] Update logic checks everywhere for FVNoDropFlag. (#2179)
* Update logic checks everywhere for FVNoDropFlag.

FVNoDropFlag == 0 is disabled
FVNoDropFlag == 1 is enabled for everyone
FVNoDropFlag == 2 is enabled for Admin() >= Character:MinStatusForNoDropExemptions

* Adding extra parenthesis to reduce ambiquity of order of operations for FVNoDropFlag checks

* Move FVNoDropFlag checks into a helper function in emu_constants.cpp and make an enum for the possible values.
Added console warning if setting is outside of allowed values.

* Move to client scoped helper method

Co-authored-by: Akkadius <akkadius1@gmail.com>
2022-07-30 13:16:47 -05:00
Kinglykrab 3bda8251b9 [Rules] Add Rule to allow Assassinate on non-Humanoid body types. (#2331) 2022-07-29 19:23:20 -04:00
Kinglykrab cadd29e5d1 [Rules] Add Rule to allow Headshots on non-Humanoid body types. (#2329)
* [Rules] Add Rule to allow Headshots on non-Humanoid body types.

* Formatting.
2022-07-29 18:38:30 -04:00
Akkadius 4002d6a083 [Hotfix] Shared Memory Protection Fixes 2022-07-27 17:37:20 -05:00
Michael Cook (mackal) 5331f4d841 [CPP] Update C++ standard to C++17 (#2308)
* Update C++ standard to C++17

* Nuke EQ::Any in favor of std::any

* Remove std::iterator due to deprecation

* Replace result_of with invoke_result due to deprecation
2022-07-27 09:00:09 -05:00
Quintinon f4f5728195 [Memory Leak] This mem leak was missed due to merge issues in the previous PRs. (#2314)
https://github.com/EQEmu/Server/commit/b5c4357de2e14a1c97abbab26c60eee8ff308331#r77584958
2022-07-27 08:54:40 -05:00
hg ed64c82a2f [Quest API] Allow scripts to prevent door click (#2327)
Returning non-zero from EVENT_CLICK_DOOR will prevent the default
handler.

This should have been implemented when expeditions were put in to
allow scripts to prevent zoning out of vxed and tipt without flags.
Some upcoming changes may need this to allow scripts to prevent
automatic dz entry.
2022-07-27 08:53:38 -05:00
hg c847e3da86 [Netcode] Adjust first packet for compress flag (#2326)
When a packet was over max_raw_size and zlib failed to compress the
first packet chunk then the final output would be 513 bytes which
exceeded m_max_packet_size of 512.

This occured because the first packet chunk used sublen without
adjusting for the new_length + 1 compression flag added in Compress().
When the packet failed to compress then it was already at its max.
After the first packet, chunk sizes are calculated using max_raw_size
which already accounted for the compress flag. (From #979)

This should fix #2325
2022-07-27 08:52:25 -05:00
Chris Miles 7d2f88325a [Client] Fix IsMoving for Client (#2318)
* [Client] Fix IsMoving for client

* Consolidate member vars

* Update client_process.cpp
2022-07-27 08:51:51 -05:00
hg 1089f8139b [Saylinks] Refactor saylink injection (#2315)
If a message was longer than 50 characters with "00000" somewhere in the
message (such as messages with hex numbers) then the saylink injection
method was sending a blank message to the chat window.

This refactors the saylink injection method using a crude state machine
to build the output. It should function the same:

  - Inner-most brackets generate saylinks when nested
  - Saylinks are not generated in brackets that already have a saylink
  - Existing saylinks are preserved
  - Existing saylinks that contain text with brackets do not attempt to
    generate saylinks
  - Saylinks are not generated if brackets contains leading or trailing
    spaces (e.g. [ spaces ])
2022-07-27 08:50:00 -05:00
Chris Miles f07e3f4d3b [CI] Hook tests back up (#2316)
* [CI] Hook tests back up

* Pull in config file

* Delete .travis.yml
2022-07-27 08:49:04 -05:00
Chris Miles 9f8f838265 [Content Filter] Fix Runtime Filtering When Set to -1 (All) (#2313) 2022-07-27 08:48:50 -05:00
Paul Coene 5af1620e50 Fix bestz to work on client or target. (#2323) 2022-07-23 13:03:20 -04:00
hg 20c639c872 [Tasks] Reward clients on shared task completion sync (#2306)
If a member is offline (or possibly during a race while zoning?) when
the shared task is completed they will not receive the reward. On live
the character receives their reward (with an updated replay timer) if
they enter back into game while the shared task is still active. They
keep the original replay timer if the shared task is no longer active
and do not receive a reward.

This makes it so clients are issued rewards (and a task completed
event is dispatch) if the client's task state was out of sync with a
completed shared task. To prevent characters being rewarded more than
once in case of bad sync checks, a 'was_rewarded' field has been added
to the character_tasks table and updated when rewards are assigned.

This fixes a couple bugs so the character_activities table is correctly
updated with shared task states to better detect when out of sync:

- The character_activities table is now flagged to update after syncing
  shared task states. This table was not being updated if a client was
  offline or inaccessible for a shared task element update.

- The character_activities table is now updated when a task element is
  completed. This was only being updated for activity increments and on
  completing the entire task. SaveClientState is now called at the end
  of ClientTaskState::IncrementDoneCount to cover all cases.

This also has a cosmetic change to show replay timers before rewards
like live, though this will not work for shared tasks until refactoring
world code
2022-07-16 15:26:48 -05:00
Akkadius 635b7b5e86 [Hotfix] fix manifest 2022-07-16 14:58:11 -05:00
Michael Cook (mackal) 139845f971 [Feature] Implement OP_CashReward (#2307)
* Implement OP_CashReward

Tit opcode needs verifying still, I think it's correct.

Added Perl and lua client CashReward functions

* Forgot AddMoneyToPP call somehow

* Switch QuestManager::givecash to CashReward packet

* Fix extra comma
2022-07-14 21:17:44 -05:00
KimLS ce74ac9913 Merge branch 'master' of https://github.com/EQEmu/Server 2022-07-14 18:56:08 -07:00
KimLS 1db2dffa57 Fix windows build for strings.cpp 2022-07-14 18:56:00 -07:00
Chris Miles 59f8d54491 [Expansions] Expansion Deprecation Revert (#2312)
* [Expansions] Expansion Deprecation Revert

* Add blank SQL for deprecate

* Update version.h

* Adjustments
2022-07-14 20:48:26 -05:00
Michael Cook (mackal) 9488ee1e8c [Bug Fix] Remove StringUtilTest::EscapeStringMemoryTest (#2310)
This was testing the old std::string EscapeString(const char *src,
size_t sz) which was removed since it's not used anywhere else.
2022-07-14 19:47:58 -05:00
Chris Miles ffe4d528e7 [Tasks] Zone Version Matching (#2303) 2022-07-14 02:57:23 -05:00
Chris Miles ddb5794462 [Zone] Deprecate Zone expansion Field (#2297) 2022-07-14 02:49:35 -05:00
Chris Miles c8b3ca53fe [World] World Bootup Consolidation (#2294) 2022-07-14 02:39:01 -05:00
Akkadius fb2df0e570 [Hotfix] Fix merge issue 2022-07-14 02:32:35 -05:00
Paul Coene 6b5e4afd2d [DoT Messages] Add DoT messages for mob->PC casts, fixed others to use correct str. (#2289) 2022-07-14 02:23:13 -05:00
neckkola 3b409def2c [Login] Added OP_ExpansionPacketData for RoF2 and update payload for Titanium (#2186)
* Fix for GENERIC_9_STRINGS

* Update .gitignore

* OP_ExpansionPacketData for Titanium and RoF2

* Update for login_opcodes_sod.conf

* Add OP_LoginExpansionPacketData for Titanium and RoF2

* Few expansion fixes

* Update client.h

* Update client.h

* l

* Updates based on PR feedback.
Moved configuration to login.json
Set Titanium limits to constants

* Update login.json

Added the two configurations to login.json
display_expansions - true/false to display on the server select screen
max_expansions - the bitmask of expansions enabled (http://spire.akkadius.com/calculators#expansions-bitmask-calculator)

* Further cleanup based on feedback.

* Further cleanup and refactor max_expansions to max_expansions_mask to better reflect its purpose

* Missed rename of max_expansions corrected.
2022-07-14 02:22:50 -05:00
hg 1488c3685c [Tasks] Apply full duration mission replay timers (#2299)
Shared task replay timers used to be based on the task start time
(reducing the final lockout timer by elapsed task time).

Live changed this in the 2022 April 20 patch:
"Replay timers will now apply their full duration upon completion of
their associated task/quest."

Solo tasks and quests already did this

This also fixes a small bug where request timers were being
deleted when replacing replay timers for shared tasks
2022-07-14 02:19:27 -05:00
Chris Miles 71966c85ca [Logs] #logs list Improvements (#2302) 2022-07-14 02:19:00 -05:00
Chris Miles 6cbfecd5a1 [Code Cleanup] Remove Unused EQEMU_DEPOP_INVALIDATES_CACHE (#2292) 2022-07-14 02:18:13 -05:00
Chris Miles 73d4e90275 [World] Add more descriptive LS auth erroring (#2293) 2022-07-14 02:17:51 -05:00
Chris Miles f7923457fd [Crash] Linux Crash Dump Improvements (#2296)
* [Crash] Linux Crash Dump Improvements

* Change LogError  for LogCrash
2022-07-14 02:17:18 -05:00
hg f381453dbd [Tasks] Place task item rewards in free slots (#2300)
Live places item rewards into the first free inventory slot and only
places it on the cursor if inventory is full
2022-07-14 02:16:43 -05:00
hg 792ea1608a [Tasks] Fix #task command crash on bad input (#2301) 2022-07-14 02:16:31 -05:00
Chris Miles 230d115195 [Code Cleanup] Remove use of bzero since it is deprecated for memset (#2295) 2022-07-14 02:11:30 -05:00
Chris Miles dda1712bb8 [Logs] Fix GMSay Log Regression (#2298) 2022-07-14 02:11:18 -05:00
Kinglykrab 849f4e18a5 [Validation] Add Size Validation to #hotfix. (#2304)
* [Validation] Add Size Validation to #hotfix.
- Validates size of shared memory pool versus current count of database so people don't accidentally #hotfix and mess something up.

* Typo.

* Message change.
2022-07-14 02:11:04 -05:00
Chris Miles dfd8f84cac [Strings] Refactor Strings Usage (#2305)
* Initial commit checkpoint

* More functions converted

* Commify

* More functions

* Fin

* Sort declarations

* Split functions between files

* Bots

* Update strings.h

* Split

* Revert find replaces

* Repository template

* Money

* Misc function

* Update CMakeLists.txt

* Saylink

* Update strings.cpp

* Swap Strings::Saylink for Saylink::Create since saylink is coupled to zone database

* API casings
2022-07-14 02:10:52 -05:00
hg 44c85a0dd7 [Quest API] Fix missing arg in perl set_proximity (#2291) 2022-07-08 19:05:33 -05:00
Michael Cook (mackal) 8d6fcf2a84 Fix string comparison issues in Client::SendZoneFlagInfo (#2290)
clang complained about these
2022-07-08 00:07:07 -04:00
Akkadius c59ec59e85 [Hotfix] Windows compile fix take 3 (final) 2022-07-06 23:14:52 -05:00
Akkadius a2e531d7e4 [Hotfix] Possible windows compile fix take 2 2022-07-06 22:58:22 -05:00
Akkadius 8ab3ec4fb0 [Hotfix] Possible windows compile fix 2022-07-06 22:40:34 -05:00
Chris Miles 19b751257b [Server Maintenance Script] Improvements to Downloading - Empty File Detection (#2282)
* Change how the utility script gets downloaded

* Adjust timeouts and order
2022-07-06 22:13:42 -05:00
Chris Miles f4904d00d2 [Backups] Use World CLI for Database Backups (#2286)
* Use world backup utility instead of db_dumper.pl

* Delete database_dumper.pl

* Delete db_dumper.pl

* Tweak script
2022-07-06 22:02:28 -05:00
Chris Miles 67f5759e47 [Server] Configuration Issues Checker (LAN Detection) (#2283)
* LAN detect

* Add more checks, consolidate logic

* Tweaks

* Tweaks

* Update world_config.cpp

* Tweak logic

* Add DNS resolution

* Delete task runner after being used

* JSON path notation adjust
2022-07-06 22:01:58 -05:00
Chris Miles eca4eed996 [Logging] Table Injection - Member Variable Cleanup (#2281)
* Logsys member variable cleanup, table injection

* Private member adjustments, OOB checks

* continue
2022-07-06 22:01:47 -05:00
Paul Coene 5c105d7408 [Bug Fix] NPCs were getting weapon proc added twice (#2277) 2022-07-06 21:59:46 -05:00
Kinglykrab a444857b46 [Quest API] Perl Doors Fix. (#2288) 2022-07-05 16:17:55 -05:00
Kinglykrab 4025b84891 [Quest API] Add missing methods/package.adds to Perl API. (#2287) 2022-07-05 16:07:41 -05:00
Kinglykrab 6d56b5b730 [Bug Fix] Fix Spell Bucket and Spell Global Logic Checks. (#2285)
- Default to true and set to false if they fail the proper check.
2022-07-04 23:28:21 -04:00
Michael 0f13a92b73 Merge pull request #2284 from hgtw/fix/missing-overload 2022-07-04 11:29:56 -04:00
hg 44dc9967a3 Add perl SpellFinished overload 2022-07-04 11:19:44 -04:00
hg 7e8a24fcec [Quest API] Use binding library for perl apis (#2216)
* Add perlbind library

* Convert perl apis to perlbind
2022-07-03 21:33:45 -05:00
Michael 2829d21057 [Cleanup] Update to EQEmu #2253 to clean up message strings (#2279)
Added message string 1393 // You have been summoned!
2022-07-03 18:57:33 -04:00
Akkadius 66d6d523cf [Hotfix] Move discord_webhooks to state tables because we don't want webhooks being exported 2022-07-03 12:16:19 -05:00
Akkadius 1a02017737 [Hotfix] Add discord_webhooks to server tables 2022-07-03 12:08:00 -05:00
Quintinon b5c4357de2 [Bug Fix] Fix miscellaneous memory leaks related to EQApplicationPacket and it's pBuffer (#2262)
* Delete EQApplicationPacket after use

* Correct issue where Creating EQApplicationPackets in zone/mob.cpp may not free pBuffer[]

* Handle freeing pBuffer[] if exists in zone/mob.cpp Create*Packet functions

* Handle freeing pBuffer[] in zone/object.cpp Create*Packet methods

* Delete leaked outapp variables in zone/trading.cpp

* Make CreateHorseSpawnPacket() safer by freeing pBuffer[] before replacing with new[]

* Prevent initial new ServerPacket from being leaked in command_reload

* Free pack after sending in command_setlsinfo

* Delete new NPC in command_viewnpctype after printing stats

* Fix compile error

* Delete EQApplicationPacket after sending in command_kick

* Remove unneeded safe_delete(outapp) after FastQueuePacket and fix minor whitespace issue

* Delete packet after sending in WorldServer::SendReloadTasks

* Cleanup logic and free leaked NPCType in Client::Doppelganger

* Free RespawnOption in Client::HandleRespawnFromHover in 'unexpected rez from hover request' branch

* Free EQApplicationPacket after sending in Bot::ProcessBotInspectionRequest

* Free Bot when returning from failed Bot::Save() in helper_bot_create()

* Initialize variable to nullptr to prevent garbage initial value

* Undo change in other PR
2022-07-02 22:10:51 -05:00
Paul Coene 5c60913583 [Feature] Add humanoid and non-wielded restrictions to pick pocket (#2276)
* Add humanoid and non-wielded restructions to pick pocket

* Use constants for message string and char color

* Fixed more magic #s

* Fix to include valie bodytypes

* Fix incorrect scope of final else

* My extra message was not needed.  Client handles based on packet reply

* Removed string ID I added - issued by client

* Use existing pick pocket reply function / clean up
2022-07-02 22:02:43 -05:00
Quintinon 30f35a920b [Bug Fix] Handle memory leaks from return value of Client::GetTraderItems() (#2266)
* Move delete of ItemInstance to avoid edge case leaking in ZoneDatabase::LoadWorldContainer()

* Delete ItemInstance after use in Client::Handle_OP_AdventureMerchantPurchase()

* Delete ItemInstance after use in NPC::GetEquipmentMaterial()

* Delete ItemInstance after use in Bot::AddBotItem()

* Delete GetItems_Struct in edge case when !TradeItemsValid in Client::Handle_OP_Trader()

* Move delete GetItems_Struct to handle edge case when Customer is not valid in Client::Trader_EndTrader()
2022-07-02 22:01:42 -05:00
Quintinon 445c94bf4a [Cleanup] Fix unintended copies in zone/zonedb.cpp by changing auto to auto& (#2271) 2022-07-02 21:57:17 -05:00
Michael 221d173c59 [Feature] Bind Wound and Forage while mounted. (#2257)
During some point in the eras you were not able to Bind Wound or Forage when mounted. I am not sure if Live is still like this, so I added a rule with it disabled by default.
2022-07-02 21:53:15 -05:00
Michael 68d28bcd3e [Bug Fix] Add required distance to CoTH before aggro wipe (#2253)
* Add required distance to CoTH before aggro wipe

This should fix eqemu/master#2205

* Remove implied this->

* Adjustments to rules per PR discussion.
2022-07-02 21:51:57 -05:00
Kinglykrab d107226ced [Telnet] Add guildsay to console commands and Guild Channel to QueueMessage. (#2263)
* [Telnet] Add guildsay to console commands and Guild Channel to QueueMessage.
- Will allow you to send guild-specific messages from things like Discord EQ.
- Add Guild support in `EQ::Net::ConsoleServerConnection::SendChannelMessage` so guild ID can be parsed out.

* Fix auction ChannelMessage by adding to condition.

* Update console.cpp

* Update console.cpp
2022-07-02 21:51:03 -05:00
Quintinon 2c0716f654 [Cleanup] Cleanup code smells and compiler warnings in common/shareddb (#2270)
* Apply refactoring for modernize-use-default-equals

* Apply refactoring for const local variable

* Replace c-style cast with static_cast<>

* Explicit cast double to float to remove compiler warning

* Make member functions const when possible

* Correct [lnt-accidental-copy] by changing auto to auto&

* Use static_cast instead of reinterpret_cast when appropriate

* Remove unneeded initial values when assigned in all paths and joined delcaration and assignment when possible

* Remove unused include

* Make member function in header const
2022-07-02 21:49:42 -05:00
Kinglykrab 0c01872608 [Bots] Cleanup ^inventoryremove, ^inventorylist, and ^list Commands and bot groups. (#2273)
* [Bots] Cleanup ^inventoryremove, ^inventorylist, and ^list Commands.

* Bot group cleanup, bot group auto spawning.

* Compile fix.

* Require SQL.
2022-07-02 21:46:00 -05:00
Paul Coene 3936b2b882 [Fix] Boats should never get FixZ'd (#2246)
* Boats should never get FixZ'd

* Use member variable to avoid repetitive checks

* Resolve comments from review

* Fix return type
2022-07-02 13:49:45 -05:00
Kinglykrab 15113f4056 [Quest API] Add TrackNPC to Perl/Lua. (#2272)
* [Quest API] Add TrackNPC to Perl/Lua.
- Add quest::tracknpc(entity_id) to Perl.
- Add eq.track_npc(entity_id) to Lua.
- This will allow server operators to arbitrarily Track NPCs for clients with scripts.
- Modified tracking to auto turn off and tell you that you discovered your target if within 10 units, this is to allow scripted Tracking to turn off without the need for the Tracking skill.

* Remove unnecessary DoTracking() call.

* Update client.cpp
2022-06-29 15:29:02 -04:00
hg 16b31c5a3a [Bug Fix] Fix empty spawned merchants (#2275)
Regression from 763fc823
2022-06-28 09:23:08 -04:00
Kinglykrab 28b07d635a [Spells] Target's Target Combat Range Rule (#2274) 2022-06-24 19:04:52 -04:00
Quintinon 059a4b7568 [Bug Fix] Delete NpcType Struct returned by Bot::CreateDefaultNPCTypeStructForBot() when unused (#2267) 2022-06-18 16:45:38 -04:00
Quintinon b9ceba1b1c [Bug Fix] Free return value of ZoneDatabase::LoadTraderItemWithCharges() (#2264) 2022-06-18 16:44:23 -04:00
Quintinon cb95251c68 [Bug Fix] Correct type signed/unsigned int when reading item from database in shareddb (#2269)
* Correct database reads from unsigned to signed integer for item regen, manaregen, endur, and enduranceregen

* Correct item database read for Click.Effect from unsigned to signed int
2022-06-15 12:16:58 -04:00
772 changed files with 51802 additions and 40925 deletions
+3 -1
View File
@@ -19,7 +19,9 @@ steps:
commands:
- sudo chown eqemu:eqemu /drone/src/ * -R
- sudo chown eqemu:eqemu /home/eqemu/.ccache/ * -R
- git submodule init && git submodule update && mkdir -p build && cd build && cmake -DEQEMU_BUILD_LOGIN=ON -DEQEMU_ENABLE_BOTS=ON -DEQEMU_BUILD_LUA=ON -DCMAKE_CXX_COMPILER_LAUNCHER=ccache -DCMAKE_CXX_FLAGS_RELWITHDEBINFO:STRING="-O0 -g -DNDEBUG" -G 'Unix Makefiles' .. && make -j$((`nproc`-4))
- git submodule init && git submodule update && mkdir -p build && cd build && cmake -DEQEMU_BUILD_TESTS=ON -DEQEMU_BUILD_LOGIN=ON -DEQEMU_ENABLE_BOTS=ON -DEQEMU_BUILD_LUA=ON -DCMAKE_CXX_COMPILER_LAUNCHER=ccache -DCMAKE_CXX_FLAGS_RELWITHDEBINFO:STRING="-O0 -g -DNDEBUG" -G 'Unix Makefiles' .. && make -j$((`nproc`-4))
- curl https://raw.githubusercontent.com/Akkadius/eqemu-install-v2/master/eqemu_config.json --output eqemu_config.json
- ./bin/tests
volumes:
- name: cache
path: /home/eqemu/.ccache/
-19
View File
@@ -1,19 +0,0 @@
language: cpp
compiler: gcc
dist: bionic
addons:
apt:
packages:
- libmysqlclient-dev
- libperl-dev
- libboost-dev
- liblua5.1-0-dev
- zlib1g-dev
- uuid-dev
- libssl-dev
script:
- cmake -G "Unix Makefiles" -DEQEMU_BUILD_TESTS=ON -DEQEMU_ENABLE_BOTS=ON -DEQEMU_BUILD_LOGIN=ON
- make -j2
- ./bin/tests
+8 -8
View File
@@ -12,7 +12,7 @@ IF(NOT CMAKE_BUILD_TYPE)
SET(CMAKE_BUILD_TYPE RelWithDebInfo CACHE STRING "Choose the type of build." FORCE)
ENDIF(NOT CMAKE_BUILD_TYPE)
SET(CMAKE_CXX_STANDARD 14)
SET(CMAKE_CXX_STANDARD 17)
SET(CMAKE_CXX_STANDARD_REQUIRED ON)
SET(CMAKE_CXX_EXTENSIONS OFF)
@@ -20,6 +20,7 @@ IF(MSVC)
ADD_DEFINITIONS(-D_CRT_SECURE_NO_WARNINGS)
ADD_DEFINITIONS(-DNOMINMAX)
ADD_DEFINITIONS(-DCRASH_LOGGING)
ADD_DEFINITIONS(-D_HAS_AUTO_PTR_ETC) # for Luabind on C++17
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /MP")
ELSE(MSVC)
@@ -121,7 +122,6 @@ ENDIF()
MESSAGE(STATUS "**************************************************")
#options
OPTION(EQEMU_DEPOP_INVALIDATES_CACHE "#repop invalidates the npc_types cache (will cause a larger database hit on #repop but is more convienent)." ON)
OPTION(EQEMU_ENABLE_BOTS "Enable Bots" OFF)
OPTION(EQEMU_COMMANDS_LOGGING "Enable GM Command logs" ON)
OPTION(EQEMU_BUILD_SERVER "Build the game server." ON)
@@ -186,7 +186,7 @@ IF(MySQL_FOUND AND MariaDB_FOUND)
MySQL
MariaDB"
)
IF(DATABASE_LIBRARY_SELECTION STREQUAL "MySQL")
SET(DATABASE_LIBRARY_TYPE " MySQL")
SET(DATABASE_LIBRARY_LIBS ${MySQL_LIBRARIES})
@@ -217,7 +217,7 @@ IF(OpenSSL_FOUND AND MBEDTLS_FOUND)
OpenSSL
mbedTLS"
)
IF(TLS_LIBRARY_SELECTION STREQUAL "OpenSSL")
SET(TLS_LIBRARY_TYPE " OpenSSL")
SET(TLS_LIBRARY_ENABLED ON)
@@ -357,12 +357,12 @@ ENDIF()
IF(LUA_LIBRARY_ENABLED)
OPTION(EQEMU_BUILD_LUA "Build Lua parser." ON)
IF(EQEMU_BUILD_LUA)
ADD_DEFINITIONS(-DLUA_EQEMU)
SET(ZONE_LIBS ${LUA_LIBRARY_LIBS})
INCLUDE_DIRECTORIES(SYSTEM "${LUA_LIBRARY_INCLUDE}")
OPTION(EQEMU_SANITIZE_LUA_LIBS "Sanitize Lua Libraries (Remove OS and IO standard libraries from being able to run)." ON)
IF(EQEMU_SANITIZE_LUA_LIBS)
ADD_DEFINITIONS(-DSANITIZE_LUA_LIBS)
@@ -410,13 +410,13 @@ IF(EQEMU_BUILD_SERVER OR EQEMU_BUILD_LOGIN OR EQEMU_BUILD_TESTS OR EQEMU_BUILD_H
ADD_SUBDIRECTORY(libs)
ADD_SUBDIRECTORY(submodules/fmt)
ADD_SUBDIRECTORY(submodules/libuv)
IF(EQEMU_BUILD_ZLIB)
SET(ZLIB_COMPAT ON CACHE BOOL "Compile with zlib compatible API")
SET(ZLIB_ENABLE_TESTS OFF CACHE BOOL "Build test binaries")
ADD_SUBDIRECTORY(libs/zlibng)
ENDIF()
SET(RECASTNAVIGATION_DEMO OFF CACHE BOOL "Build demo")
SET(RECASTNAVIGATION_TESTS OFF CACHE BOOL "Build tests")
SET(RECASTNAVIGATION_EXAMPLES OFF CACHE BOOL "Build examples")
+3 -1
View File
@@ -25,11 +25,13 @@
#include "../../common/platform.h"
#include "../../common/crash.h"
#include "../../common/rulesys.h"
#include "../../common/string_util.h"
#include "../../common/strings.h"
#include "../../common/content/world_content_service.h"
#include "../../common/zone_store.h"
EQEmuLogSys LogSys;
WorldContentService content_service;
ZoneStore zone_store;
void ExportSpells(SharedDatabase *db);
void ExportSkillCaps(SharedDatabase *db);
+9 -7
View File
@@ -23,11 +23,13 @@
#include "../../common/platform.h"
#include "../../common/crash.h"
#include "../../common/rulesys.h"
#include "../../common/string_util.h"
#include "../../common/strings.h"
#include "../../common/content/world_content_service.h"
#include "../../common/zone_store.h"
EQEmuLogSys LogSys;
WorldContentService content_service;
ZoneStore zone_store;
void ImportSpells(SharedDatabase *db);
void ImportSkillCaps(SharedDatabase *db);
@@ -146,8 +148,8 @@ void ImportSpells(SharedDatabase *db) {
}
}
std::string escaped = ::EscapeString(buffer);
auto split = SplitString(escaped, '^');
std::string escaped = ::Strings::Escape(buffer);
auto split = Strings::Split(escaped, '^');
int line_columns = (int)split.size();
std::string sql;
@@ -225,7 +227,7 @@ void ImportSkillCaps(SharedDatabase *db) {
char buffer[2048];
while(fgets(buffer, 2048, f)) {
auto split = SplitString(buffer, '^');
auto split = Strings::Split(buffer, '^');
if(split.size() < 4) {
continue;
@@ -260,7 +262,7 @@ void ImportBaseData(SharedDatabase *db) {
char buffer[2048];
while(fgets(buffer, 2048, f)) {
auto split = SplitString(buffer, '^');
auto split = Strings::Split(buffer, '^');
if(split.size() < 10) {
continue;
@@ -318,7 +320,7 @@ void ImportDBStrings(SharedDatabase *db) {
}
}
auto split = SplitString(buffer, '^');
auto split = Strings::Split(buffer, '^');
if(split.size() < 2) {
continue;
@@ -332,7 +334,7 @@ void ImportDBStrings(SharedDatabase *db) {
type = atoi(split[1].c_str());
if(split.size() >= 3) {
value = ::EscapeString(split[2]);
value = ::Strings::Escape(split[2]);
}
sql = StringFormat("INSERT INTO db_str(id, type, value) VALUES(%u, %u, '%s')",
+742 -734
View File
File diff suppressed because it is too large Load Diff
-190
View File
@@ -1,190 +0,0 @@
/*
* Boost Software License - Version 1.0 - August 17th, 2003
*
* Permission is hereby granted, free of charge, to any person or organization
* obtaining a copy of the software and accompanying documentation covered by
* this license (the "Software") to use, reproduce, display, distribute,
* execute, and transmit the Software, and to prepare derivative works of the
* Software, and to permit third-parties to whom the Software is furnished to
* do so, all subject to the following:
*
* The copyright notices in the Software and this entire statement, including
* the above license grant, this restriction and the following disclaimer,
* must be included in all copies of the Software, in whole or in part, and
* all derivative works of the Software, unless such copies or derivative
* works are solely in the form of machine-executable object code generated by
* a source language processor.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
* SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
* FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*/
// EQ::Any is a modified version of Boost::Any and as such retains the Boost licensing.
#ifndef EQEMU_COMMON_ANY_H
#define EQEMU_COMMON_ANY_H
#include <algorithm>
#include <typeinfo>
namespace EQ
{
class Any
{
public:
Any()
: content(nullptr)
{
}
template<typename ValueType>
Any(const ValueType &value)
: content(new Holder<ValueType>(value))
{
}
Any(const Any &other)
: content(other.content ? other.content->clone() : 0)
{
}
~Any()
{
if(content)
delete content;
}
Any& swap(Any &rhs)
{
std::swap(content, rhs.content);
return *this;
}
template<typename ValueType>
Any& operator=(const ValueType &rhs)
{
Any(rhs).swap(*this);
return *this;
}
Any& operator=(Any rhs)
{
rhs.swap(*this);
return *this;
}
bool empty() const
{
return !content;
}
const std::type_info& type() const
{
return content ? content->type() : typeid(void);
}
class Placeholder
{
public:
virtual ~Placeholder()
{
}
virtual const std::type_info& type() const = 0;
virtual Placeholder* clone() const = 0;
};
template<typename ValueType>
class Holder : public Placeholder
{
public:
Holder(const ValueType &value)
: held(value)
{
}
virtual const std::type_info& type() const
{
return typeid(ValueType);
}
virtual Placeholder* clone() const
{
return new Holder(held);
}
ValueType held;
private:
Holder& operator=(const Holder&);
};
private:
template<typename ValueType>
friend ValueType* any_cast(Any*);
template<typename ValueType>
friend ValueType* unsafe_any_cast(Any*);
Placeholder* content;
};
class bad_any_cast : public std::bad_cast
{
public:
virtual const char * what() const throw()
{
return "DBI::bad_any_cast: failed conversion using DBI::any_cast";
}
};
template<typename ValueType>
ValueType* any_cast(Any* operand)
{
return operand &&
operand->type() == typeid(ValueType) ? &static_cast<Any::Holder<ValueType>*>(operand->content)->held : nullptr;
}
template<typename ValueType>
inline const ValueType* any_cast(const Any* operand)
{
return any_cast<ValueType>(const_cast<Any*>(operand));
}
template<typename ValueType>
ValueType any_cast(Any& operand)
{
typedef typename std::remove_reference<ValueType>::type nonref;
nonref* result = any_cast<nonref>(&operand);
if(!result)
throw bad_any_cast();
return *result;
}
template<typename ValueType>
inline ValueType any_cast(const Any& operand)
{
typedef typename std::remove_reference<ValueType>::type nonref;
return any_cast<const nonref&>(const_cast<Any&>(operand));
}
template<typename ValueType>
inline ValueType* unsafe_any_cast(Any* operand)
{
return &static_cast<Any::Holder<ValueType>*>(operand->content)->held;
}
template<typename ValueType>
inline const ValueType* unsafe_any_cast(const Any* operand)
{
return unsafe_any_cast<ValueType>(const_cast<Any*>(operand));
}
}
#endif
+6 -6
View File
@@ -158,25 +158,25 @@ bool WorldContentService::IsContentFlagDisabled(const std::string &content_flag)
bool WorldContentService::DoesPassContentFiltering(const ContentFlags &f)
{
// if we're not set to (-1 All) then fail when we aren't within minimum expansion
if (f.min_expansion > Expansion::EXPANSION_ALL && current_expansion < f.min_expansion) {
if (f.min_expansion > Expansion::EXPANSION_ALL && current_expansion < f.min_expansion && current_expansion != -1) {
return false;
}
// if we're not set to (-1 All) then fail when we aren't within max expansion
if (f.max_expansion > Expansion::EXPANSION_ALL && current_expansion > f.max_expansion) {
if (f.max_expansion > Expansion::EXPANSION_ALL && current_expansion > f.max_expansion && current_expansion != -1) {
return false;
}
// if we don't have any enabled flag in enabled flags, we fail
for (const auto& flag: SplitString(f.content_flags)) {
if (!contains(GetContentFlagsEnabled(), flag)) {
for (const auto& flag: Strings::Split(f.content_flags)) {
if (!Strings::Contains(GetContentFlagsEnabled(), flag)) {
return false;
}
}
// if we don't have any disabled flag in disabled flags, we fail
for (const auto& flag: SplitString(f.content_flags_disabled)) {
if (!contains(GetContentFlagsDisabled(), flag)) {
for (const auto& flag: Strings::Split(f.content_flags_disabled)) {
if (!Strings::Contains(GetContentFlagsDisabled(), flag)) {
return false;
}
}
+61 -2
View File
@@ -2,6 +2,48 @@
#include "eqemu_logsys.h"
#include "crash.h"
inline std::string random_string(size_t length)
{
auto randchar = []() -> char {
const char charset[] = "0123456789"
"ABCDEFGHIJKLMNOPQRSTUVWXYZ"
"abcdefghijklmnopqrstuvwxyz";
const size_t max_index = (sizeof(charset) - 1);
return charset[static_cast<size_t>(std::rand()) % max_index];
};
std::string str(length, 0);
std::generate_n(str.begin(), length, randchar);
return str;
}
std::string execute(const std::string &cmd, bool return_result = true)
{
std::string random = "/tmp/" + random_string(25);
const char *file_name = random.c_str();
if (return_result) {
#ifdef _WINDOWS
std::system((cmd + " > " + file_name + " 2>&1").c_str());
#else
std::system((cmd + " > " + file_name + " 2>&1").c_str());
#endif
}
else {
std::system((cmd).c_str());
}
std::string result;
if (return_result) {
std::ifstream file(file_name);
result = {std::istreambuf_iterator<char>(file), std::istreambuf_iterator<char>()};
std::remove(file_name);
}
return result;
}
#if defined(_WINDOWS) && defined(CRASH_LOGGING)
#include "StackWalker.h"
@@ -125,10 +167,28 @@ void set_exception_handler() {
void print_trace()
{
auto uid = geteuid();
bool does_gdb_exist = execute("gdb -v").find("GNU") != std::string::npos;
if (!does_gdb_exist) {
LogCrash(
"[Error] GDB is not installed, if you want crash dumps on Linux to work properly you will need GDB installed"
);
std::exit(1);
}
auto uid = geteuid();
std::string temp_output_file = "/tmp/dump-output";
// check for passwordless sudo if not root
if (uid != 0) {
bool has_passwordless_sudo = execute("sudo -n true").find("a password is required") == std::string::npos;
if (!has_passwordless_sudo) {
LogCrash(
"[Error] Current user does not have passwordless sudo installed. It is required to automatically process crash dumps with GDB as non-root."
);
std::exit(1);
}
}
char pid_buf[30];
sprintf(pid_buf, "%d", getpid());
char name_buf[512];
@@ -136,7 +196,6 @@ void print_trace()
int child_pid = fork();
if (!child_pid) {
int fd = open(temp_output_file.c_str(), O_RDWR | O_CREAT, S_IRUSR | S_IWUSR);
dup2(fd, 1); // redirect output to stderr
fprintf(stdout, "stack trace for %s pid=%s\n", name_buf, pid_buf);
if (uid == 0) {
+34 -132
View File
@@ -45,12 +45,13 @@
#include "database.h"
#include "eq_packet_structs.h"
#include "extprofile.h"
#include "string_util.h"
#include "strings.h"
#include "database_schema.h"
#include "http/httplib.h"
#include "http/uri.h"
#include "repositories/zone_repository.h"
#include "zone_store.h"
extern Client client;
@@ -107,7 +108,7 @@ uint32 Database::CheckLogin(const char* name, const char* password, const char *
"SELECT id, status FROM account WHERE `name` = '{}' AND ls_id = '{}' AND password is NOT NULL "
"AND length(password) > 0 AND (password = '{}' OR password = MD5('{}'))",
temporary_username,
EscapeString(loginserver),
Strings::Escape(loginserver),
temporary_password,
temporary_password
);
@@ -148,8 +149,8 @@ bool Database::CheckBannedIPs(std::string login_ip)
bool Database::AddBannedIP(std::string banned_ip, std::string notes) {
auto query = fmt::format(
"INSERT into banned_ips SET ip_address = '{}', notes = '{}'",
EscapeString(banned_ip),
EscapeString(notes)
Strings::Escape(banned_ip),
Strings::Escape(notes)
);
auto results = QueryDatabase(query);
@@ -280,7 +281,7 @@ bool Database::DeleteAccount(const char* name, const char *loginserver) {
}
bool Database::SetLocalPassword(uint32 accid, const char* password) {
std::string query = StringFormat("UPDATE account SET password=MD5('%s') where id=%i;", EscapeString(password).c_str(), accid);
std::string query = StringFormat("UPDATE account SET password=MD5('%s') where id=%i;", Strings::Escape(password).c_str(), accid);
auto results = QueryDatabase(query);
@@ -619,8 +620,8 @@ bool Database::SaveCharacterCreate(uint32 character_id, uint32 account_id, Playe
")",
character_id, // " id, "
account_id, // " account_id, "
EscapeString(pp->name).c_str(), // " `name`, "
EscapeString(pp->last_name).c_str(), // " last_name, "
Strings::Escape(pp->name).c_str(), // " `name`, "
Strings::Escape(pp->last_name).c_str(), // " last_name, "
pp->gender, // " gender, "
pp->race, // " race, "
pp->class_, // " class, "
@@ -644,8 +645,8 @@ bool Database::SaveCharacterCreate(uint32 character_id, uint32 account_id, Playe
pp->ability_number, // " ability_number, "
pp->ability_time_minutes, // " ability_time_minutes, "
pp->ability_time_hours, // " ability_time_hours, "
EscapeString(pp->title).c_str(), // " title, "
EscapeString(pp->suffix).c_str(), // " suffix, "
Strings::Escape(pp->title).c_str(), // " title, "
Strings::Escape(pp->suffix).c_str(), // " suffix, "
pp->exp, // " exp, "
pp->points, // " points, "
pp->mana, // " mana, "
@@ -781,7 +782,7 @@ uint32 Database::GetCharacterID(const char *name) {
Zero will also be returned if there is a database error.
*/
uint32 Database::GetAccountIDByChar(const char* charname, uint32* oCharID) {
std::string query = StringFormat("SELECT `account_id`, `id` FROM `character_data` WHERE name='%s'", EscapeString(charname).c_str());
std::string query = StringFormat("SELECT `account_id`, `id` FROM `character_data` WHERE name='%s'", Strings::Escape(charname).c_str());
auto results = QueryDatabase(query);
@@ -825,8 +826,8 @@ uint32 Database::GetAccountIDByName(std::string account_name, std::string logins
auto query = fmt::format(
"SELECT `id`, `status`, `lsaccount_id` FROM `account` WHERE `name` = '{}' AND `ls_id` = '{}' LIMIT 1",
EscapeString(account_name),
EscapeString(loginserver)
Strings::Escape(account_name),
Strings::Escape(loginserver)
);
auto results = QueryDatabase(query);
@@ -982,8 +983,8 @@ bool Database::GetVariable(std::string varname, std::string &varvalue)
bool Database::SetVariable(const std::string varname, const std::string &varvalue)
{
std::string escaped_name = EscapeString(varname);
std::string escaped_value = EscapeString(varvalue);
std::string escaped_name = Strings::Escape(varname);
std::string escaped_value = Strings::Escape(varvalue);
std::string query = StringFormat("Update variables set value='%s' WHERE varname like '%s'", escaped_value.c_str(), escaped_name.c_str());
auto results = QueryDatabase(query);
@@ -1018,97 +1019,6 @@ void Database::SetAccountCRCField(uint32 account_id, std::string field_name, uin
);
}
// Get zone starting points from DB
bool Database::GetSafePoints(const char* zone_short_name, uint32 instance_version, float* safe_x, float* safe_y, float* safe_z, float* safe_heading, int16* min_status, uint8* min_level, char *flag_needed) {
if (zone_short_name == nullptr)
return false;
std::string query = fmt::format(
SQL(
SELECT
`safe_x`, `safe_y`, `safe_z`, `safe_heading`, `min_status`, `min_level`, `flag_needed`
FROM
zone
WHERE
`short_name` = '{}'
AND
(`version` = {} OR `version` = 0)
ORDER BY `version` DESC
), zone_short_name, instance_version
);
auto results = QueryDatabase(query);
if (!results.Success())
return false;
if (results.RowCount() == 0)
return false;
auto row = results.begin();
if (safe_x != nullptr)
*safe_x = atof(row[0]);
if (safe_y != nullptr)
*safe_y = atof(row[1]);
if (safe_z != nullptr)
*safe_z = atof(row[2]);
if (safe_heading != nullptr)
*safe_heading = atof(row[3]);
if (min_status != nullptr)
*min_status = atoi(row[4]);
if (min_level != nullptr)
*min_level = atoi(row[5]);
if (flag_needed != nullptr)
strcpy(flag_needed, row[6]);
return true;
}
bool Database::GetZoneLongName(const char* short_name, char** long_name, char* file_name, float* safe_x, float* safe_y, float* safe_z, uint32* graveyard_id, uint32* maxclients) {
std::string query = StringFormat("SELECT long_name, file_name, safe_x, safe_y, safe_z, graveyard_id, maxclients FROM zone WHERE short_name='%s' AND version=0", short_name);
auto results = QueryDatabase(query);
if (!results.Success()) {
return false;
}
if (results.RowCount() == 0)
return false;
auto row = results.begin();
if (long_name != nullptr)
*long_name = strcpy(new char[strlen(row[0])+1], row[0]);
if (file_name != nullptr) {
if (row[1] == nullptr)
strcpy(file_name, short_name);
else
strcpy(file_name, row[1]);
}
if (safe_x != nullptr)
*safe_x = atof(row[2]);
if (safe_y != nullptr)
*safe_y = atof(row[3]);
if (safe_z != nullptr)
*safe_z = atof(row[4]);
if (graveyard_id != nullptr)
*graveyard_id = atoi(row[5]);
if (maxclients != nullptr)
*maxclients = atoi(row[6]);
return true;
}
bool Database::GetZoneGraveyard(const uint32 graveyard_id, uint32* graveyard_zoneid, float* graveyard_x, float* graveyard_y, float* graveyard_z, float* graveyard_heading) {
std::string query = StringFormat("SELECT zone_id, x, y, z, heading FROM graveyard WHERE id=%i", graveyard_id);
@@ -1138,25 +1048,15 @@ bool Database::GetZoneGraveyard(const uint32 graveyard_id, uint32* graveyard_zon
}
uint8 Database::GetPEQZone(uint32 zone_id, uint32 version){
std::string query = fmt::format(
"SELECT peqzone FROM zone WHERE zoneidnumber = {} AND (version = {} OR version = 0) ORDER BY version DESC LIMIT 1",
zone_id,
version
);
auto results = QueryDatabase(query);
if (!results.Success() || !results.RowCount()) {
return 0;
}
auto z = GetZoneVersionWithFallback(zone_id, version);
auto row = results.begin();
return static_cast<uint8>(std::stoi(row[0]));
return z ? z->peqzone : 0;
}
bool Database::CheckNameFilter(std::string name, bool surname)
{
name = str_tolower(name);
name = Strings::ToLower(name);
// the minimum 4 is enforced by the client too
if (name.empty() || name.size() < 4) {
@@ -1196,7 +1096,7 @@ bool Database::CheckNameFilter(std::string name, bool surname)
}
for (auto row : results) {
std::string current_row = str_tolower(row[0]);
std::string current_row = Strings::ToLower(row[0]);
if (name.find(current_row) != std::string::npos) {
return false;
}
@@ -1473,7 +1373,7 @@ uint32 Database::GetCharacterInfo(std::string character_name, uint32 *account_id
{
auto query = fmt::format(
"SELECT `id`, `account_id`, `zone_id`, `zone_instance` FROM `character_data` WHERE `name` = '{}'",
EscapeString(character_name)
Strings::Escape(character_name)
);
auto results = QueryDatabase(query);
@@ -1546,7 +1446,7 @@ void Database::AddReport(std::string who, std::string against, std::string lines
auto escape_str = new char[lines.size() * 2 + 1];
DoEscapeString(escape_str, lines.c_str(), lines.size());
std::string query = StringFormat("INSERT INTO reports (name, reported, reported_text) VALUES('%s', '%s', '%s')", EscapeString(who).c_str(), EscapeString(against).c_str(), escape_str);
std::string query = StringFormat("INSERT INTO reports (name, reported, reported_text) VALUES('%s', '%s', '%s')", Strings::Escape(who).c_str(), Strings::Escape(against).c_str(), escape_str);
QueryDatabase(query);
safe_delete_array(escape_str);
}
@@ -1644,7 +1544,7 @@ std::string Database::GetGroupLeaderForLogin(std::string character_name) {
}
void Database::SetGroupLeaderName(uint32 gid, const char* name) {
std::string query = StringFormat("UPDATE group_leaders SET leadername = '%s' WHERE gid = %u", EscapeString(name).c_str(), gid);
std::string query = StringFormat("UPDATE group_leaders SET leadername = '%s' WHERE gid = %u", Strings::Escape(name).c_str(), gid);
auto result = QueryDatabase(query);
if(result.RowsAffected() != 0) {
@@ -1652,7 +1552,7 @@ void Database::SetGroupLeaderName(uint32 gid, const char* name) {
}
query = StringFormat("REPLACE INTO group_leaders(gid, leadername, marknpc, leadershipaa, maintank, assist, puller, mentoree, mentor_percent) VALUES(%u, '%s', '', '', '', '', '', '', '0')",
gid, EscapeString(name).c_str());
gid, Strings::Escape(name).c_str());
result = QueryDatabase(query);
if(!result.Success()) {
@@ -2299,9 +2199,9 @@ int Database::GetInstanceID(uint32 char_id, uint32 zone_id) {
* @return
*/
bool Database::CopyCharacter(
std::string source_character_name,
std::string destination_character_name,
std::string destination_account_name
const std::string& source_character_name,
const std::string& destination_character_name,
const std::string& destination_account_name
)
{
auto results = QueryDatabase(
@@ -2313,6 +2213,7 @@ bool Database::CopyCharacter(
if (results.RowCount() == 0) {
LogError("No character found with name [{}]", source_character_name);
return false;
}
auto row = results.begin();
@@ -2327,6 +2228,7 @@ bool Database::CopyCharacter(
if (results.RowCount() == 0) {
LogError("No account found with name [{}]", destination_account_name);
return false;
}
row = results.begin();
@@ -2358,7 +2260,7 @@ bool Database::CopyCharacter(
results = QueryDatabase(
fmt::format(
"SELECT {} FROM {} WHERE {} = {}",
implode(",", wrap(columns, "`")),
Strings::Implode(",", Strings::Wrap(columns, "`")),
table_name,
character_id_column_name,
source_character_id
@@ -2394,7 +2296,7 @@ bool Database::CopyCharacter(
std::vector<std::string> insert_rows;
for (auto &r: new_rows) {
std::string insert_row = "(" + implode(",", wrap(r, "'")) + ")";
std::string insert_row = "(" + Strings::Implode(",", Strings::Wrap(r, "'")) + ")";
insert_rows.emplace_back(insert_row);
}
@@ -2412,8 +2314,8 @@ bool Database::CopyCharacter(
fmt::format(
"INSERT INTO {} ({}) VALUES {}",
table_name,
implode(",", wrap(columns, "`")),
implode(",", insert_rows)
Strings::Implode(",", Strings::Wrap(columns, "`")),
Strings::Implode(",", insert_rows)
)
);
@@ -2465,8 +2367,8 @@ void Database::SourceDatabaseTableFromUrl(std::string table_name, std::string ur
if (auto res = cli.Get(request_uri.get_path().c_str())) {
if (res->status == 200) {
for (auto &s: SplitString(res->body, ';')) {
if (!trim(s).empty()) {
for (auto &s: Strings::Split(res->body, ';')) {
if (!Strings::Trim(s).empty()) {
auto results = QueryDatabase(s);
if (!results.ErrorMessage().empty()) {
LogError("Error sourcing SQL [{}]", results.ErrorMessage());
+3 -5
View File
@@ -113,9 +113,9 @@ public:
bool SetMQDetectionFlag(const char *accountname, const char *charactername, const std::string &hacked, const char *zone);
bool UpdateName(const char *oldname, const char *newname);
bool CopyCharacter(
std::string source_character_name,
std::string destination_character_name,
std::string destination_account_name
const std::string& source_character_name,
const std::string& destination_character_name,
const std::string& destination_account_name
);
/* General Information Queries */
@@ -246,9 +246,7 @@ public:
/* General Queries */
bool GetSafePoints(const char* zone_short_name, uint32 instance_version, float* safe_x = 0, float* safe_y = 0, float* safe_z = 0, float* safe_heading = 0, int16* minstatus = 0, uint8* minlevel = 0, char *flag_needed = nullptr);
bool GetZoneGraveyard(const uint32 graveyard_id, uint32* graveyard_zoneid = 0, float* graveyard_x = 0, float* graveyard_y = 0, float* graveyard_z = 0, float* graveyard_heading = 0);
bool GetZoneLongName(const char* short_name, char** long_name, char* file_name = 0, float* safe_x = 0, float* safe_y = 0, float* safe_z = 0, uint32* graveyard_id = 0, uint32* maxclients = 0);
bool LoadPTimers(uint32 charid, PTimerList &into);
uint8 GetPEQZone(uint32 zone_id, uint32 version);
+11 -11
View File
@@ -23,7 +23,7 @@
#include <iterator>
#include "database_dump_service.h"
#include "../eqemu_logsys.h"
#include "../string_util.h"
#include "../strings.h"
#include "../eqemu_config.h"
#include "../database_schema.h"
#include "../file_util.h"
@@ -119,7 +119,7 @@ std::string DatabaseDumpService::GetMySQLVersion()
{
std::string version_output = execute("mysql --version");
return trim(version_output);
return Strings::Trim(version_output);
}
/**
@@ -160,7 +160,7 @@ std::string DatabaseDumpService::GetPlayerTablesList()
tables_list += table + " ";
}
return trim(tables_list);
return Strings::Trim(tables_list);
}
/**
@@ -174,7 +174,7 @@ std::string DatabaseDumpService::GetBotTablesList()
tables_list += table + " ";
}
return trim(tables_list);
return Strings::Trim(tables_list);
}
/**
@@ -188,7 +188,7 @@ std::string DatabaseDumpService::GetLoginTableList()
tables_list += table + " ";
}
return trim(tables_list);
return Strings::Trim(tables_list);
}
/**
@@ -202,7 +202,7 @@ std::string DatabaseDumpService::GetQueryServTables()
tables_list += table + " ";
}
return trim(tables_list);
return Strings::Trim(tables_list);
}
/**
@@ -222,7 +222,7 @@ std::string DatabaseDumpService::GetSystemTablesList()
tables_list += table + " ";
}
return trim(tables_list);
return Strings::Trim(tables_list);
}
/**
* @return
@@ -236,7 +236,7 @@ std::string DatabaseDumpService::GetStateTablesList()
tables_list += table + " ";
}
return trim(tables_list);
return Strings::Trim(tables_list);
}
/**
@@ -251,7 +251,7 @@ std::string DatabaseDumpService::GetContentTablesList()
tables_list += table + " ";
}
return trim(tables_list);
return Strings::Trim(tables_list);
}
/**
@@ -331,7 +331,7 @@ void DatabaseDumpService::Dump()
tables_to_dump += GetPlayerTablesList() + " ";
dump_descriptor += "-player";
}
if (IsDumpBotTables()) {
tables_to_dump += GetBotTablesList() + " ";
dump_descriptor += "-bots";
@@ -388,7 +388,7 @@ void DatabaseDumpService::Dump()
}
if (IsDumpDropTableSyntaxOnly()) {
std::vector<std::string> tables = SplitString(tables_to_dump, ' ');
std::vector<std::string> tables = Strings::Split(tables_to_dump, ' ');
for (auto &table : tables) {
std::cout << "DROP TABLE IF EXISTS `" << table << "`;" << std::endl;
+95 -95
View File
@@ -18,7 +18,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#include "../common/global_define.h"
#include "../common/rulesys.h"
#include "../common/string_util.h"
#include "../common/strings.h"
#include "../common/timer.h"
#include "database.h"
@@ -961,7 +961,7 @@ bool Database::CheckDatabaseConvertPPDeblob(){
std::string rquery = StringFormat("REPLACE INTO `character_inspect_messages` (id, inspect_message)"
"VALUES (%u, '%s')",
character_id,
EscapeString(inspectmessage).c_str()
Strings::Escape(inspectmessage).c_str()
);
auto results = QueryDatabase(rquery);
}
@@ -1097,95 +1097,95 @@ bool Database::CheckDatabaseConvertPPDeblob(){
"e_expended_aa_spent"
")"
"VALUES ("
"%u," // id
"%u," // account_id
"'%s'," // `name`
"'%s'," // last_name
"%u," // gender
"%u," // race
"%u," // class
"%u," // `level`
"%u," // deity
"%u," // birthday
"%u," // last_login
"%u," // time_played
"%u," // pvp_status
"%u," // level2
"%u," // anon
"%u," // gm
"%u," // intoxication
"%u," // hair_color
"%u," // beard_color
"%u," // eye_color_1
"%u," // eye_color_2
"%u," // hair_style
"%u," // beard
"%u," // ability_time_seconds
"%u," // ability_number
"%u," // ability_time_minutes
"%u," // ability_time_hours
"'%s'," // title
"'%s'," // suffix
"%u," // exp
"%u," // points
"%u," // mana
"%u," // cur_hp
"%u," // str
"%u," // sta
"%u," // cha
"%u," // dex
"%u," // `int`
"%u," // agi
"%u," // wis
"%u," // face
"%f," // y
"%f," // x
"%f," // z
"%f," // heading
"%u," // pvp2
"%u," // pvp_type
"%u," // autosplit_enabled
"%u," // zone_change_count
"%u," // drakkin_heritage
"%u," // drakkin_tattoo
"%u," // drakkin_details
"%i," // toxicity
"%u," // hunger_level
"%u," // thirst_level
"%u," // ability_up
"%u," // zone_id
"%u," // zone_instance
"%u," // leadership_exp_on
"%u," // ldon_points_guk
"%u," // ldon_points_mir
"%u," // ldon_points_mmc
"%u," // ldon_points_ruj
"%u," // ldon_points_tak
"%u," // ldon_points_available
"%u," // tribute_time_remaining
"%u," // show_helm
"%u," // career_tribute_points
"%u," // tribute_points
"%u," // tribute_active
"%u," // endurance
"%u," // group_leadership_exp
"%u," // raid_leadership_exp
"%u," // group_leadership_points
"%u," // raid_leadership_points
"%u," // air_remaining
"%u," // pvp_kills
"%u," // pvp_deaths
"%u," // pvp_current_points
"%u," // pvp_career_points
"%u," // pvp_best_kill_streak
"%u," // pvp_worst_death_streak
"%u," // pvp_current_kill_streak
"%u," // aa_points_spent
"%u," // aa_exp
"%u," // aa_points
"%u," // group_auto_consent
"%u," // raid_auto_consent
"%u," // guild_auto_consent
"%u," // id
"%u," // account_id
"'%s'," // `name`
"'%s'," // last_name
"%u," // gender
"%u," // race
"%u," // class
"%u," // `level`
"%u," // deity
"%u," // birthday
"%u," // last_login
"%u," // time_played
"%u," // pvp_status
"%u," // level2
"%u," // anon
"%u," // gm
"%u," // intoxication
"%u," // hair_color
"%u," // beard_color
"%u," // eye_color_1
"%u," // eye_color_2
"%u," // hair_style
"%u," // beard
"%u," // ability_time_seconds
"%u," // ability_number
"%u," // ability_time_minutes
"%u," // ability_time_hours
"'%s'," // title
"'%s'," // suffix
"%u," // exp
"%u," // points
"%u," // mana
"%u," // cur_hp
"%u," // str
"%u," // sta
"%u," // cha
"%u," // dex
"%u," // `int`
"%u," // agi
"%u," // wis
"%u," // face
"%f," // y
"%f," // x
"%f," // z
"%f," // heading
"%u," // pvp2
"%u," // pvp_type
"%u," // autosplit_enabled
"%u," // zone_change_count
"%u," // drakkin_heritage
"%u," // drakkin_tattoo
"%u," // drakkin_details
"%i," // toxicity
"%u," // hunger_level
"%u," // thirst_level
"%u," // ability_up
"%u," // zone_id
"%u," // zone_instance
"%u," // leadership_exp_on
"%u," // ldon_points_guk
"%u," // ldon_points_mir
"%u," // ldon_points_mmc
"%u," // ldon_points_ruj
"%u," // ldon_points_tak
"%u," // ldon_points_available
"%u," // tribute_time_remaining
"%u," // show_helm
"%u," // career_tribute_points
"%u," // tribute_points
"%u," // tribute_active
"%u," // endurance
"%u," // group_leadership_exp
"%u," // raid_leadership_exp
"%u," // group_leadership_points
"%u," // raid_leadership_points
"%u," // air_remaining
"%u," // pvp_kills
"%u," // pvp_deaths
"%u," // pvp_current_points
"%u," // pvp_career_points
"%u," // pvp_best_kill_streak
"%u," // pvp_worst_death_streak
"%u," // pvp_current_kill_streak
"%u," // aa_points_spent
"%u," // aa_exp
"%u," // aa_points
"%u," // group_auto_consent
"%u," // raid_auto_consent
"%u," // guild_auto_consent
"%u," // RestTimer
"%u," // First Logon - References online status for EVENT_CONNECT/EVENT_DISCONNECt
"%u," // Looking for Group
@@ -1198,8 +1198,8 @@ bool Database::CheckDatabaseConvertPPDeblob(){
")",
character_id,
account_id,
EscapeString(pp->name).c_str(),
EscapeString(pp->last_name).c_str(),
Strings::Escape(pp->name).c_str(),
Strings::Escape(pp->last_name).c_str(),
pp->gender,
pp->race,
pp->class_,
@@ -1223,8 +1223,8 @@ bool Database::CheckDatabaseConvertPPDeblob(){
pp->ability_number,
pp->ability_time_minutes,
pp->ability_time_hours,
EscapeString(pp->title).c_str(),
EscapeString(pp->suffix).c_str(),
Strings::Escape(pp->title).c_str(),
Strings::Escape(pp->suffix).c_str(),
pp->exp,
pp->points,
pp->mana,
+3 -3
View File
@@ -18,7 +18,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#include "../common/global_define.h"
#include "../common/rulesys.h"
#include "../common/string_util.h"
#include "../common/strings.h"
#include "../common/timer.h"
#include "../common/repositories/dynamic_zone_members_repository.h"
#include "../common/repositories/dynamic_zones_repository.h"
@@ -485,7 +485,7 @@ void Database::BuryCorpsesInInstance(uint16 instance_id) {
void Database::DeleteInstance(uint16 instance_id)
{
std::string query;
query = StringFormat("DELETE FROM instance_list_player WHERE id=%u", instance_id);
QueryDatabase(query);
@@ -580,7 +580,7 @@ void Database::PurgeExpiredInstances()
instance_ids.emplace_back(row[0]);
}
std::string imploded_instance_ids = implode(",", instance_ids);
std::string imploded_instance_ids = Strings::Implode(",", instance_ids);
QueryDatabase(fmt::format("DELETE FROM instance_list WHERE id IN ({})", imploded_instance_ids));
QueryDatabase(fmt::format("DELETE FROM instance_list_player WHERE id IN ({})", imploded_instance_ids));
+4 -3
View File
@@ -189,13 +189,14 @@ namespace DatabaseSchema {
"char_create_point_allocations",
"damageshieldtypes",
"doors",
"dynamic_zone_templates",
"faction_association",
"faction_base_data",
"faction_list",
"faction_list_mod",
"fishing",
"forage",
"global_loot",
"goallists",
"graveyard",
"grid",
"grid_entries",
@@ -224,7 +225,6 @@ namespace DatabaseSchema {
"pets_beastlord_data",
"pets_equipmentset",
"pets_equipmentset_entries",
"proximities",
"skill_caps",
"spawn2",
"spawn_conditions",
@@ -318,6 +318,7 @@ namespace DatabaseSchema {
"completed_shared_task_activity_state",
"completed_shared_task_members",
"completed_shared_tasks",
"discord_webhooks",
"dynamic_zone_members",
"dynamic_zones",
"eventlog",
@@ -375,7 +376,7 @@ namespace DatabaseSchema {
"inventory_versions",
};
}
/**
* @description Gets all player bot tables
* @note These tables have no content in the PEQ daily dump
+3 -3
View File
@@ -1,7 +1,7 @@
#include "discord.h"
#include "../http/httplib.h"
#include "../json/json.h"
#include "../string_util.h"
#include "../strings.h"
#include "../eqemu_logsys.h"
constexpr int MAX_RETRIES = 10;
@@ -21,11 +21,11 @@ void Discord::SendWebhookMessage(const std::string &message, const std::string &
}
// split
auto s = SplitString(webhook_url, '/');
auto s = Strings::Split(webhook_url, '/');
// url
std::string base_url = fmt::format("{}//{}", s[0], s[2]);
std::string endpoint = replace_string(webhook_url, base_url, "");
std::string endpoint = Strings::Replace(webhook_url, base_url, "");
// client
httplib::Client cli(base_url.c_str());
+8 -4
View File
@@ -1,7 +1,7 @@
#include "discord_manager.h"
#include "../common/discord/discord.h"
#include "../common/eqemu_logsys.h"
#include "../common/string_util.h"
#include "../common/strings.h"
void DiscordManager::QueueWebhookMessage(uint32 webhook_id, const std::string &message)
{
@@ -22,7 +22,12 @@ void DiscordManager::ProcessMessageQueue()
for (auto &q: webhook_message_queue) {
LogDiscord("Processing [{}] messages in queue for webhook ID [{}]...", q.second.size(), q.first);
auto webhook = LogSys.discord_webhooks[q.first];
if (q.first >= MAX_DISCORD_WEBHOOK_ID) {
LogDiscord("Out of bounds webhook ID [{}] max [{}]", q.first, MAX_DISCORD_WEBHOOK_ID);
continue;
}
auto webhook = LogSys.GetDiscordWebhooks()[q.first];
std::string message;
for (auto &m: q.second) {
@@ -58,8 +63,7 @@ void DiscordManager::ProcessMessageQueue()
webhook.webhook_url
);
}
webhook_message_queue.erase(q.first);
}
webhook_message_queue.clear();
webhook_queue_lock.unlock();
}
+49
View File
@@ -79,6 +79,7 @@ void DynamicZoneBase::LoadRepositoryResult(DynamicZonesRepository::DynamicZoneIn
m_max_players = dz_entry.max_players;
m_instance_id = dz_entry.instance_id;
m_type = static_cast<DynamicZoneType>(dz_entry.type);
m_dz_switch_id = dz_entry.dz_switch_id;
m_compass.zone_id = dz_entry.compass_zone_id;
m_compass.x = dz_entry.compass_x;
m_compass.y = dz_entry.compass_y;
@@ -129,6 +130,7 @@ uint32_t DynamicZoneBase::SaveToDatabase()
insert_dz.max_players = m_max_players;
insert_dz.instance_id = m_instance_id,
insert_dz.type = static_cast<int>(m_type);
insert_dz.dz_switch_id = m_dz_switch_id;
insert_dz.compass_zone_id = m_compass.zone_id;
insert_dz.compass_x = m_compass.x;
insert_dz.compass_y = m_compass.y;
@@ -316,6 +318,17 @@ void DynamicZoneBase::SetZoneInLocation(float x, float y, float z, float heading
SetZoneInLocation({ 0, x, y, z, heading }, update_db);
}
void DynamicZoneBase::SetSwitchID(int dz_switch_id, bool update_db)
{
m_dz_switch_id = dz_switch_id;
if (update_db)
{
DynamicZonesRepository::UpdateSwitchID(GetDatabase(), m_id, dz_switch_id);
SendServerPacket(CreateServerDzSwitchIDPacket().get());
}
}
void DynamicZoneBase::SetLeader(const DynamicZoneMember& new_leader, bool update_db)
{
m_leader = new_leader;
@@ -403,6 +416,17 @@ std::unique_ptr<ServerPacket> DynamicZoneBase::CreateServerDzLocationPacket(
return pack;
}
std::unique_ptr<ServerPacket> DynamicZoneBase::CreateServerDzSwitchIDPacket()
{
constexpr uint32_t pack_size = sizeof(ServerDzSwitchID_Struct);
auto pack = std::make_unique<ServerPacket>(ServerOP_DzSetSwitchID, pack_size);
auto buf = reinterpret_cast<ServerDzSwitchID_Struct*>(pack->pBuffer);
buf->dz_id = GetID();
buf->dz_switch_id = GetSwitchID();
return pack;
}
std::unique_ptr<ServerPacket> DynamicZoneBase::CreateServerMemberStatusPacket(
uint32_t character_id, DynamicZoneMemberStatus status)
{
@@ -598,3 +622,28 @@ void DynamicZoneBase::LoadSerializedDzPacket(char* cereal_data, uint32_t cereal_
cereal::BinaryInputArchive archive(ss);
archive(*this);
}
void DynamicZoneBase::LoadTemplate(const DynamicZoneTemplatesRepository::DynamicZoneTemplates& dz_template)
{
m_zone_id = dz_template.zone_id;
m_zone_version = dz_template.zone_version;
m_name = dz_template.name;
m_min_players = dz_template.min_players;
m_max_players = dz_template.max_players;
m_duration = std::chrono::seconds(dz_template.duration_seconds);
m_dz_switch_id = dz_template.dz_switch_id;
m_compass.zone_id = dz_template.compass_zone_id;
m_compass.x = dz_template.compass_x;
m_compass.y = dz_template.compass_y;
m_compass.z = dz_template.compass_z;
m_safereturn.zone_id = dz_template.return_zone_id;
m_safereturn.x = dz_template.return_x;
m_safereturn.y = dz_template.return_y;
m_safereturn.z = dz_template.return_z;
m_safereturn.heading = dz_template.return_h;
m_has_zonein = dz_template.override_zone_in;
m_zonein.x = dz_template.zone_in_x;
m_zonein.y = dz_template.zone_in_y;
m_zonein.z = dz_template.zone_in_z;
m_zonein.heading = dz_template.zone_in_h;
}
+9
View File
@@ -5,6 +5,7 @@
#include "net/packet.h"
#include "repositories/dynamic_zones_repository.h"
#include "repositories/dynamic_zone_members_repository.h"
#include "repositories/dynamic_zone_templates_repository.h"
#include <algorithm>
#include <chrono>
#include <cstdint>
@@ -74,6 +75,7 @@ public:
virtual void SetSecondsRemaining(uint32_t seconds_remaining) = 0;
int GetDuration() const { return static_cast<int>(m_duration.count()); }
uint64_t GetExpireTime() const { return std::chrono::system_clock::to_time_t(m_expire_time); }
uint32_t GetID() const { return m_id; }
uint16_t GetInstanceID() const { return static_cast<uint16_t>(m_instance_id); }
@@ -85,6 +87,7 @@ public:
uint16_t GetZoneID() const { return static_cast<uint16_t>(m_zone_id); }
uint32_t GetZoneIndex() const { return (m_instance_id << 16) | (m_zone_id & 0xffff); }
uint32_t GetZoneVersion() const { return m_zone_version; }
int GetSwitchID() const { return m_dz_switch_id; }
DynamicZoneType GetType() const { return m_type; }
const std::string& GetLeaderName() const { return m_leader.name; }
const std::string& GetName() const { return m_name; }
@@ -112,6 +115,7 @@ public:
bool IsValid() const { return m_instance_id != 0; }
bool IsSameDz(uint32_t zone_id, uint32_t instance_id) const { return zone_id == m_zone_id && instance_id == m_instance_id; }
void LoadSerializedDzPacket(char* cereal_data, uint32_t cereal_size);
void LoadTemplate(const DynamicZoneTemplatesRepository::DynamicZoneTemplates& dz_template);
void RemoveAllMembers();
bool RemoveMember(uint32_t character_id);
bool RemoveMember(const std::string& character_name);
@@ -127,6 +131,7 @@ public:
void SetName(const std::string& name) { m_name = name; }
void SetSafeReturn(const DynamicZoneLocation& location, bool update_db = false);
void SetSafeReturn(uint32_t zone_id, float x, float y, float z, float heading, bool update_db = false);
void SetSwitchID(int dz_switch_id, bool update_db = false);
void SetType(DynamicZoneType type) { m_type = type; }
void SetUUID(std::string uuid) { m_uuid = std::move(uuid); }
void SetZoneInLocation(const DynamicZoneLocation& location, bool update_db = false);
@@ -141,6 +146,7 @@ protected:
virtual void ProcessMemberAddRemove(const DynamicZoneMember& member, bool removed);
virtual bool ProcessMemberStatusChange(uint32_t member_id, DynamicZoneMemberStatus status);
virtual void ProcessRemoveAllMembers(bool silent = false) { m_members.clear(); }
virtual void ProcessSetSwitchID(int dz_switch_id) { m_dz_switch_id = dz_switch_id; }
virtual bool SendServerPacket(ServerPacket* packet) = 0;
void AddInternalMember(const DynamicZoneMember& member);
@@ -153,6 +159,7 @@ protected:
std::unique_ptr<ServerPacket> CreateServerDzCreatePacket(uint16_t origin_zone_id, uint16_t origin_instance_id);
std::unique_ptr<ServerPacket> CreateServerDzLocationPacket(uint16_t server_opcode, const DynamicZoneLocation& location);
std::unique_ptr<ServerPacket> CreateServerDzSwitchIDPacket();
std::unique_ptr<ServerPacket> CreateServerMemberAddRemovePacket(const DynamicZoneMember& member, bool removed);
std::unique_ptr<ServerPacket> CreateServerMemberStatusPacket(uint32_t character_id, DynamicZoneMemberStatus status);
std::unique_ptr<ServerPacket> CreateServerMemberSwapPacket(const DynamicZoneMember& remove_member, const DynamicZoneMember& add_member);
@@ -164,6 +171,7 @@ protected:
uint32_t m_zone_version = 0;
uint32_t m_min_players = 0;
uint32_t m_max_players = 0;
int m_dz_switch_id = 0;
bool m_never_expires = false;
bool m_has_zonein = false;
bool m_has_member_statuses = false;
@@ -190,6 +198,7 @@ public:
m_zone_version,
m_min_players,
m_max_players,
m_dz_switch_id,
m_never_expires,
m_has_zonein,
m_has_member_statuses,
+87 -6
View File
@@ -1,5 +1,5 @@
/* EQEMu: Everquest Server Emulator
Copyright (C) 2001-2016 EQEMu Development Team (http://eqemulator.net)
This program is free software; you can redistribute it and/or modify
@@ -18,9 +18,12 @@
*/
#include "emu_constants.h"
#include "languages.h"
#include "data_verification.h"
#include "bodytypes.h"
#include "data_verification.h"
#include "eqemu_logsys.h"
#include "eqemu_logsys_log_aliases.h"
#include "languages.h"
#include "rulesys.h"
int16 EQ::invtype::GetInvTypeSize(int16 inv_type) {
static const int16 local_array[] = {
@@ -117,7 +120,7 @@ EQ::bug::CategoryID EQ::bug::CategoryNameToCategoryID(const char* category_name)
return catLoNTCG;
if (!strcmp(category_name, "Mercenaries"))
return catMercenaries;
return catOther;
}
@@ -221,7 +224,7 @@ std::string EQ::constants::GetLDoNThemeName(uint32 theme_id)
return EQ::constants::GetLDoNThemeMap().find(theme_id)->second;
}
return std::string();
return std::string();
}
const std::map<int8, std::string>& EQ::constants::GetFlyModeMap()
@@ -321,7 +324,7 @@ const std::map<uint8, std::string>& EQ::constants::GetAccountStatusMap()
{ AccountStatus::GMAreas, "GM Areas" },
{ AccountStatus::GMCoder, "GM Coder" },
{ AccountStatus::GMMgmt, "GM Mgmt" },
{ AccountStatus::GMImpossible, "GM Impossible" },
{ AccountStatus::GMImpossible, "GM Impossible" },
{ AccountStatus::Max, "GM Max" }
};
@@ -432,3 +435,81 @@ std::string EQ::constants::GetSpawnAnimationName(uint8 animation_id)
return std::string();
}
const std::map<int, std::string>& EQ::constants::GetObjectTypeMap()
{
static const std::map<int, std::string> object_type_map = {
{ ObjectTypes::SmallBag, "Small Bag" },
{ ObjectTypes::LargeBag, "Large Bag" },
{ ObjectTypes::Quiver, "Quiver" },
{ ObjectTypes::BeltPouch, "Belt Pouch" },
{ ObjectTypes::WristPouch, "Wrist Pouch" },
{ ObjectTypes::Backpack, "Backpack" },
{ ObjectTypes::SmallChest, "Small Chest" },
{ ObjectTypes::LargeChest, "Large Chest" },
{ ObjectTypes::Bandolier, "Bandolier" },
{ ObjectTypes::Medicine, "Medicine" },
{ ObjectTypes::Tinkering, "Tinkering" },
{ ObjectTypes::Lexicon, "Lexicon" },
{ ObjectTypes::PoisonMaking, "Mortar and Pestle" },
{ ObjectTypes::Quest, "Quest" },
{ ObjectTypes::MixingBowl, "Mixing Bowl" },
{ ObjectTypes::Baking, "Baking" },
{ ObjectTypes::Tailoring, "Tailoring" },
{ ObjectTypes::Blacksmithing, "Blacksmithing" },
{ ObjectTypes::Fletching, "Fletching" },
{ ObjectTypes::Brewing, "Brewing" },
{ ObjectTypes::JewelryMaking, "Jewelry Making" },
{ ObjectTypes::Pottery, "Pottery" },
{ ObjectTypes::Kiln, "Kiln" },
{ ObjectTypes::KeyMaker, "Key Maker" },
{ ObjectTypes::ResearchWIZ, "Lexicon" },
{ ObjectTypes::ResearchMAG, "Lexicon" },
{ ObjectTypes::ResearchNEC, "Lexicon" },
{ ObjectTypes::ResearchENC, "Lexicon" },
{ ObjectTypes::Unknown, "Unknown" },
{ ObjectTypes::ResearchPractice, "Lexicon" },
{ ObjectTypes::Alchemy, "Alchemy" },
{ ObjectTypes::HighElfForge, "High Elf Forge" },
{ ObjectTypes::DarkElfForge, "Dark Elf Forge" },
{ ObjectTypes::OgreForge, "Ogre Forge" },
{ ObjectTypes::DwarfForge, "Dwarf Forge" },
{ ObjectTypes::GnomeForge, "Gnome Forge" },
{ ObjectTypes::BarbarianForge, "Barbarian Forge" },
{ ObjectTypes::IksarForge, "Iksar Forge" },
{ ObjectTypes::HumanForgeOne, "Human Forge" },
{ ObjectTypes::HumanForgeTwo, "Human Forge" },
{ ObjectTypes::HalflingTailoringOne, "Halfling Tailoring" },
{ ObjectTypes::HalflingTailoringTwo, "Halfling Tailoring" },
{ ObjectTypes::EruditeTailoring, "Erudite Tailoring" },
{ ObjectTypes::WoodElfTailoring, "Wood Elf Tailoring" },
{ ObjectTypes::WoodElfFletching, "Wood Elf Fletching" },
{ ObjectTypes::IksarPottery, "Iksar Pottery" },
{ ObjectTypes::Fishing, "Fishing" },
{ ObjectTypes::TrollForge, "Troll Forge" },
{ ObjectTypes::WoodElfForge, "Wood Elf Forge" },
{ ObjectTypes::HalflingForge, "Halfling Forge" },
{ ObjectTypes::EruditeForge, "Erudite Forge" },
{ ObjectTypes::Merchant, "Merchant" },
{ ObjectTypes::FroglokForge, "Froglok Forge" },
{ ObjectTypes::Augmenter, "Augmenter" },
{ ObjectTypes::Churn, "Churn" },
{ ObjectTypes::TransformationMold, "Transformation Mold" },
{ ObjectTypes::DetransformationMold, "Detransformation Mold" },
{ ObjectTypes::Unattuner, "Unattuner" },
{ ObjectTypes::TradeskillBag, "Tradeskill Bag" },
{ ObjectTypes::CollectibleBag, "Collectible Bag" },
{ ObjectTypes::NoDeposit, "No Deposit" }
};
return object_type_map;
}
std::string EQ::constants::GetObjectTypeName(int object_type)
{
if (EQ::ValueWithin(object_type, ObjectTypes::SmallBag, ObjectTypes::NoDeposit)) {
return EQ::constants::GetObjectTypeMap().find(object_type)->second;
}
return std::string();
}
+71 -8
View File
@@ -1,5 +1,5 @@
/* EQEMu: Everquest Server Emulator
Copyright (C) 2001-2016 EQEMu Development Team (http://eqemulator.net)
This program is free software; you can redistribute it and/or modify
@@ -32,10 +32,6 @@ namespace EQ
{
using RoF2::IINVALID;
using RoF2::INULL;
namespace inventory {
} /*inventory*/
namespace invtype {
using namespace RoF2::invtype::enum_;
@@ -201,7 +197,7 @@ namespace EQ
using RoF2::constants::EXPANSIONS_MASK;
using RoF2::constants::CHARACTER_CREATION_LIMIT;
const size_t SAY_LINK_OPENER_SIZE = 1;
using RoF2::constants::SAY_LINK_BODY_SIZE;
const size_t SAY_LINK_TEXT_SIZE = 256; // this may be varied until it breaks something (tested:374) - the others are constant
@@ -252,6 +248,70 @@ namespace EQ
Looting
};
enum ObjectTypes : int {
SmallBag,
LargeBag,
Quiver,
BeltPouch,
WristPouch,
Backpack,
SmallChest,
LargeChest,
Bandolier,
Medicine,
Tinkering,
Lexicon,
PoisonMaking,
Quest,
MixingBowl,
Baking,
Tailoring,
Blacksmithing,
Fletching,
Brewing,
JewelryMaking,
Pottery,
Kiln,
KeyMaker,
ResearchWIZ,
ResearchMAG,
ResearchNEC,
ResearchENC,
Unknown,
ResearchPractice,
Alchemy,
HighElfForge,
DarkElfForge,
OgreForge,
DwarfForge,
GnomeForge,
BarbarianForge,
IksarForge,
HumanForgeOne,
HumanForgeTwo,
HalflingTailoringOne,
HalflingTailoringTwo,
EruditeTailoring,
WoodElfTailoring,
WoodElfFletching,
IksarPottery,
Fishing,
TrollForge,
WoodElfForge,
HalflingForge,
EruditeForge,
Merchant,
FroglokForge,
Augmenter,
Churn,
TransformationMold,
DetransformationMold,
Unattuner,
TradeskillBag,
CollectibleBag,
NoDeposit
};
const char *GetStanceName(StanceType stance_type);
int ConvertStanceTypeToIndex(StanceType stance_type);
@@ -260,7 +320,7 @@ namespace EQ
extern const std::map<uint32, std::string>& GetLDoNThemeMap();
std::string GetLDoNThemeName(uint32 theme_id);
extern const std::map<int8, std::string>& GetFlyModeMap();
std::string GetFlyModeName(int8 flymode_id);
@@ -282,6 +342,9 @@ namespace EQ
extern const std::map<uint8, std::string>& GetSpawnAnimationMap();
std::string GetSpawnAnimationName(uint8 animation_id);
extern const std::map<int, std::string>& GetObjectTypeMap();
std::string GetObjectTypeName(int object_type);
const int STANCE_TYPE_FIRST = stancePassive;
const int STANCE_TYPE_LAST = stanceBurnAE;
const int STANCE_TYPE_COUNT = stanceBurnAE;
@@ -291,7 +354,7 @@ namespace EQ
namespace profile {
using RoF2::profile::BANDOLIERS_SIZE;
using RoF2::profile::BANDOLIER_ITEM_COUNT;
using RoF2::profile::POTION_BELT_SIZE;
using RoF2::profile::SKILL_ARRAY_SIZE;
+2
View File
@@ -71,6 +71,7 @@ N(OP_Camp),
N(OP_CancelSneakHide),
N(OP_CancelTask),
N(OP_CancelTrade),
N(OP_CashReward),
N(OP_CastSpell),
N(OP_ChangeSize),
N(OP_ChannelMessage),
@@ -303,6 +304,7 @@ N(OP_LockoutTimerInfo),
N(OP_Login),
N(OP_LoginAccepted),
N(OP_LoginComplete),
N(OP_LoginExpansionPacketData), //added for Rof2 client to send expansion data packet. Requires login_opcodes_sod.conf to be updated.
N(OP_LoginUnknown1),
N(OP_LoginUnknown2),
N(OP_Logout),
+7
View File
@@ -1009,4 +1009,11 @@ enum StartZoneIndex {
SharVahl
};
enum FVNoDropFlagRule
{
Disabled = 0,
Enabled = 1,
AdminOnly = 2
};
#endif /*COMMON_EQ_CONSTANTS_H*/
+16 -16
View File
@@ -1,5 +1,5 @@
/* EQEMu: Everquest Server Emulator
Copyright (C) 2001-2016 EQEMu Development Team (http://eqemulator.net)
This program is free software; you can redistribute it and/or modify
@@ -11,7 +11,7 @@
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
@@ -26,7 +26,7 @@
static bool global_dictionary_init = false;
void EQ::InitializeDynamicLookups() {
if (global_dictionary_init == true)
if (global_dictionary_init)
return;
constants::InitializeDynamicLookups();
@@ -167,7 +167,7 @@ static const EQ::inventory::LookupEntry inventory_static_lookup_entries[EQ::vers
ClientUnknown::INULL, ClientUnknown::INULL, ClientUnknown::INULL,
ClientUnknown::INULL
),
ClientUnknown::INULL,
ClientUnknown::INULL,
ClientUnknown::INULL,
@@ -175,7 +175,7 @@ static const EQ::inventory::LookupEntry inventory_static_lookup_entries[EQ::vers
ClientUnknown::INULL,
ClientUnknown::INULL,
ClientUnknown::INULL,
false,
false,
false,
@@ -194,7 +194,7 @@ static const EQ::inventory::LookupEntry inventory_static_lookup_entries[EQ::vers
Client62::INULL, Client62::INULL, Client62::INULL,
Client62::INULL
),
Client62::INULL,
Client62::INULL,
Client62::INULL,
@@ -202,7 +202,7 @@ static const EQ::inventory::LookupEntry inventory_static_lookup_entries[EQ::vers
Client62::INULL,
Client62::INULL,
Client62::INULL,
false,
false,
false,
@@ -221,7 +221,7 @@ static const EQ::inventory::LookupEntry inventory_static_lookup_entries[EQ::vers
Titanium::INULL, Titanium::INULL, Titanium::INULL,
Titanium::invtype::OTHER_SIZE
),
Titanium::invslot::EQUIPMENT_BITMASK,
Titanium::invslot::GENERAL_BITMASK,
Titanium::invslot::CURSOR_BITMASK,
@@ -229,7 +229,7 @@ static const EQ::inventory::LookupEntry inventory_static_lookup_entries[EQ::vers
Titanium::invslot::CORPSE_BITMASK,
Titanium::invbag::SLOT_COUNT,
Titanium::invaug::SOCKET_COUNT,
Titanium::inventory::AllowEmptyBagInBag,
Titanium::inventory::AllowClickCastFromBag,
Titanium::inventory::ConcatenateInvTypeLimbo,
@@ -248,7 +248,7 @@ static const EQ::inventory::LookupEntry inventory_static_lookup_entries[EQ::vers
SoF::INULL, SoF::INULL, SoF::INULL,
SoF::invtype::OTHER_SIZE
),
SoF::invslot::EQUIPMENT_BITMASK,
SoF::invslot::GENERAL_BITMASK,
SoF::invslot::CURSOR_BITMASK,
@@ -256,7 +256,7 @@ static const EQ::inventory::LookupEntry inventory_static_lookup_entries[EQ::vers
SoF::invslot::CORPSE_BITMASK,
SoF::invbag::SLOT_COUNT,
SoF::invaug::SOCKET_COUNT,
SoF::inventory::AllowEmptyBagInBag,
SoF::inventory::AllowClickCastFromBag,
SoF::inventory::ConcatenateInvTypeLimbo,
@@ -763,7 +763,7 @@ void EQ::inventory::InitializeDynamicLookups() {
// Notes:
// - Currently, there are only 3 known expansions that affect inventory-related settings in the clients..
// -- Expansion::PoR "Prophecy of Ro" - toggles between 24 (set) and 16 (clear) bank slots
// -- Expansion::TBS "The Buried Sea" - toggles slotPowerSource activated (set) and deactivated (clear)
// -- Expansion::TBS "The Buried Sea" - toggles slotPowerSource activated (set) and deactivated (clear)
// -- Expansion::HoT "House of Thule" - toggles slotGeneral9/slotGeneral10 activated (set) and deactivated (clear)
// - Corspe size does not appear to reflect loss of active possessions slots
// - Inspect size does not appear to reflect loss of active equipment slots
@@ -772,7 +772,7 @@ void EQ::inventory::InitializeDynamicLookups() {
// - General9 and General10 slots are activated by GM flag when expansion bit is (clear)
// - Obviously, the client must support the expansion to allow any (set) or override condition
const uint32 dynamic_check_mask =
const uint32 dynamic_check_mask =
(
EQ::expansions::bitPoR |
EQ::expansions::bitTBS |
@@ -1210,10 +1210,10 @@ void EQ::spells::InitializeDynamicLookups() {
if (spells_dictionary_init == true)
return;
spells_dictionary_init = true;
if (RuleB(World, UseClientBasedExpansionSettings))
return;
// use static references for now
}
@@ -1239,7 +1239,7 @@ const EQ::spells::LookupEntry* EQ::spells::DynamicGMLookup(versions::ClientVersi
client_version = versions::ValidateClientVersion(client_version);
if (spells_dynamic_gm_lookup_entries[static_cast<int>(client_version)])
return spells_dynamic_gm_lookup_entries[static_cast<int>(client_version)].get();
return &spells_static_lookup_entries[static_cast<int>(client_version)];
}
+21 -13
View File
@@ -374,18 +374,18 @@ struct NewZone_Struct {
/*0684*/ uint16 zone_id;
/*0686*/ uint16 zone_instance;
/*0688*/ uint32 unknown688;
/*0692*/ uint8 unknown692[8];
/*0692*/ uint8 unknown692[8];
// Titanium doesn't have a translator, but we can still safely add stuff under here without issues since client memcpy's only what it knows
// Just wastes some bandwidth sending to tit clients /shrug
/*0700*/ float fog_density;
/*0704*/ uint32 SuspendBuffs;
/*0708*/ uint32 FastRegenHP;
/*0712*/ uint32 FastRegenMana;
/*0716*/ uint32 FastRegenEndurance;
/*0720*/ uint32 NPCAggroMaxDist;
/*0724*/ uint32 underworld_teleport_index; // > 0 teleports w/ zone point index, invalid succors, if this value is 0, it prevents you from running off edges that would end up underworld
/*0728*/ uint32 LavaDamage; // Seen 50
/*0732*/ uint32 MinLavaDamage; // Seen 10
/*0700*/ float fog_density;
/*0704*/ uint32 suspend_buffs;
/*0708*/ uint32 fast_regen_hp;
/*0712*/ uint32 fast_regen_mana;
/*0716*/ uint32 fast_regen_endurance;
/*0720*/ uint32 npc_aggro_max_dist;
/*0724*/ uint32 underworld_teleport_index; // > 0 teleports w/ zone point index, invalid succors, if this value is 0, it prevents you from running off edges that would end up underworld
/*0728*/ uint32 lava_damage; // Seen 50
/*0732*/ uint32 min_lava_damage; // Seen 10
/*0736*/
};
@@ -2192,11 +2192,19 @@ struct QuestReward_Struct
/*068*/
};
struct CashReward_Struct
{
/*000*/ uint32 copper;
/*004*/ uint32 silver;
/*008*/ uint32 gold;
/*012*/ uint32 platinum;
};
// Size: 8
struct Camera_Struct
{
uint32 duration; // Duration in ms
uint32 intensity; // Between 1023410176 and 1090519040
float intensity;
};
struct ZonePoint_Entry {
@@ -3634,7 +3642,7 @@ struct MerchantList {
uint8 probability;
std::string bucket_name;
std::string bucket_value;
uint8 bucket_comparison;
uint8 bucket_comparison;
};
struct TempMerchantList {
@@ -4998,7 +5006,7 @@ struct DynamicZoneCompassEntry_Struct
/*000*/ uint16 dz_zone_id; // target dz id pair
/*002*/ uint16 dz_instance_id;
/*004*/ uint32 dz_type; // 1: Expedition, 2: Tutorial (purple), 3: Task, 4: Mission, 5: Quest (green)
/*008*/ uint32 unknown008;
/*008*/ uint32 dz_switch_id;
/*012*/ float y;
/*016*/ float x;
/*020*/ float z;
+7 -7
View File
@@ -23,7 +23,7 @@
#include "op_codes.h"
#include "crc16.h"
#include "platform.h"
#include "string_util.h"
#include "strings.h"
#include <string>
#include <iomanip>
@@ -406,7 +406,7 @@ void EQStream::ProcessPacket(EQProtocolPacket *p)
if(uint16(SequencedBase + SequencedQueue.size()) != NextOutSeq) {
LogNetcode(_L "Pre-OOA Invalid Sequenced queue: BS [{}] + SQ [{}] != NOS [{}]" __L, SequencedBase, SequencedQueue.size(), NextOutSeq);
}
//if the packet they got out of order is between our last acked packet and the last sent packet, then its valid.
if (CompareSequence(SequencedBase,seq) != SeqPast && CompareSequence(NextOutSeq,seq) == SeqPast) {
Log(Logs::Detail, Logs::Netcode, _L "Received OP_OutOfOrderAck for sequence %d, starting retransmit at the start of our unacked buffer (seq %d, was %d)." __L,
@@ -453,7 +453,7 @@ void EQStream::ProcessPacket(EQProtocolPacket *p)
(unsigned long)ntohl(ClientStats->packets_received), (unsigned long)ntohl(ClientStats->packets_sent), (unsigned long)ntohl(ClientStats->last_local_delta),
(unsigned long)ntohl(ClientStats->low_delta), (unsigned long)ntohl(ClientStats->average_delta),
(unsigned long)ntohl(ClientStats->high_delta), (unsigned long)ntohl(ClientStats->last_remote_delta));
AdjustRates(ntohl(ClientStats->average_delta));
if(GetExecutablePlatform() == ExePlatformWorld || GetExecutablePlatform() == ExePlatformZone) {
@@ -951,7 +951,7 @@ EQRawApplicationPacket *p=nullptr;
EmuOpcode emu_op = (*OpMgr)->EQToEmu(p->opcode);
if (emu_op == OP_Unknown) {
// Log(Logs::General, Logs::Client_Server_Packet_Unhandled, "Unknown :: [%s - 0x%04x] [Size: %u] %s", OpcodeManager::EmuToName(p->GetOpcode()), p->opcode, p->Size(), DumpPacketToString(p).c_str());
}
}
p->SetOpcode(emu_op);
}
}
@@ -1359,11 +1359,11 @@ void EQStream::AdjustRates(uint32 average_delta)
DecayRate=DECAYBASE/average_delta;
if (BytesWritten > RateThreshold)
BytesWritten = RateThreshold + DecayRate;
Log(Logs::Detail, Logs::Netcode, _L "Adjusting data rate to thresh %d, decay %d based on avg delta %d" __L,
Log(Logs::Detail, Logs::Netcode, _L "Adjusting data rate to thresh %d, decay %d based on avg delta %d" __L,
RateThreshold, DecayRate, average_delta);
MRate.unlock();
} else {
Log(Logs::Detail, Logs::Netcode, _L "Not adjusting data rate because avg delta over max (%d > %d)" __L,
Log(Logs::Detail, Logs::Netcode, _L "Not adjusting data rate because avg delta over max (%d > %d)" __L,
average_delta, AVERAGE_DELTA_MAX);
AverageDelta = AVERAGE_DELTA_MAX;
}
@@ -1374,7 +1374,7 @@ void EQStream::AdjustRates(uint32 average_delta)
BytesWritten = 0;
RateThreshold=RATEBASE/average_delta;
DecayRate=DECAYBASE/average_delta;
Log(Logs::Detail, Logs::Netcode, _L "Adjusting data rate to thresh %d, decay %d based on avg delta %d" __L,
Log(Logs::Detail, Logs::Netcode, _L "Adjusting data rate to thresh %d, decay %d based on avg delta %d" __L,
RateThreshold, DecayRate, average_delta);
MRate.unlock();
}
+4
View File
@@ -100,6 +100,10 @@ void EQEmuConfig::parse_config()
WorldHTTPEnabled = true;
}
if (_root["server"].get("disable_config_checks", "false").asString() == "true") {
DisableConfigChecks = true;
}
/**
* UCS
*/
+3 -2
View File
@@ -58,6 +58,7 @@ class EQEmuConfig
uint16 WorldHTTPPort;
std::string WorldHTTPMimeFile;
std::string SharedKey;
bool DisableConfigChecks;
// From <chatserver/>
std::string ChatHost;
@@ -130,7 +131,7 @@ class EQEmuConfig
void parse_config();
EQEmuConfig()
{
{
}
virtual ~EQEmuConfig() {}
@@ -174,7 +175,7 @@ class EQEmuConfig
}
catch (std::exception &) {
return false;
}
}
return true;
}
+94 -40
View File
@@ -21,7 +21,7 @@
#include "eqemu_logsys.h"
#include "rulesys.h"
#include "platform.h"
#include "string_util.h"
#include "strings.h"
#include "misc.h"
#include "discord/discord.h"
#include "repositories/discord_webhooks_repository.h"
@@ -91,8 +91,8 @@ namespace Console {
*/
EQEmuLogSys::EQEmuLogSys()
{
on_log_gmsay_hook = [](uint16 log_type, const std::string &) {};
on_log_console_hook = [](uint16 log_type, const std::string &) {};
m_on_log_gmsay_hook = [](uint16 log_type, const std::string &) {};
m_on_log_console_hook = [](uint16 log_type, const std::string &) {};
}
/**
@@ -105,7 +105,7 @@ EQEmuLogSys *EQEmuLogSys::LoadLogSettingsDefaults()
/**
* Get Executable platform currently running this code (Zone/World/etc)
*/
log_platform = GetExecutablePlatformInt();
m_log_platform = GetExecutablePlatformInt();
for (int log_category_id = Logs::AA; log_category_id != Logs::MaxCategoryID; log_category_id++) {
log_settings[log_category_id].log_to_console = 0;
@@ -115,7 +115,7 @@ EQEmuLogSys *EQEmuLogSys::LoadLogSettingsDefaults()
log_settings[log_category_id].is_category_enabled = 0;
}
file_logs_enabled = false;
m_file_logs_enabled = false;
/**
* Set Defaults
@@ -169,26 +169,26 @@ EQEmuLogSys *EQEmuLogSys::LoadLogSettingsDefaults()
/**
* Declare process file names for log writing=
*/
if (EQEmuLogSys::log_platform == EQEmuExePlatform::ExePlatformWorld) {
platform_file_name = "world";
if (EQEmuLogSys::m_log_platform == EQEmuExePlatform::ExePlatformWorld) {
m_platform_file_name = "world";
}
else if (EQEmuLogSys::log_platform == EQEmuExePlatform::ExePlatformQueryServ) {
platform_file_name = "query_server";
else if (EQEmuLogSys::m_log_platform == EQEmuExePlatform::ExePlatformQueryServ) {
m_platform_file_name = "query_server";
}
else if (EQEmuLogSys::log_platform == EQEmuExePlatform::ExePlatformZone) {
platform_file_name = "zone";
else if (EQEmuLogSys::m_log_platform == EQEmuExePlatform::ExePlatformZone) {
m_platform_file_name = "zone";
}
else if (EQEmuLogSys::log_platform == EQEmuExePlatform::ExePlatformUCS) {
platform_file_name = "ucs";
else if (EQEmuLogSys::m_log_platform == EQEmuExePlatform::ExePlatformUCS) {
m_platform_file_name = "ucs";
}
else if (EQEmuLogSys::log_platform == EQEmuExePlatform::ExePlatformLogin) {
platform_file_name = "login";
else if (EQEmuLogSys::m_log_platform == EQEmuExePlatform::ExePlatformLogin) {
m_platform_file_name = "login";
}
else if (EQEmuLogSys::log_platform == EQEmuExePlatform::ExePlatformLaunch) {
platform_file_name = "launcher";
else if (EQEmuLogSys::m_log_platform == EQEmuExePlatform::ExePlatformLaunch) {
m_platform_file_name = "launcher";
}
else if (EQEmuLogSys::log_platform == EQEmuExePlatform::ExePlatformHC) {
platform_file_name = "hc";
else if (EQEmuLogSys::m_log_platform == EQEmuExePlatform::ExePlatformHC) {
m_platform_file_name = "hc";
}
return this;
@@ -243,7 +243,7 @@ void EQEmuLogSys::ProcessLogWrite(
std::ofstream crash_log;
EQEmuLogSys::MakeDirectory("logs/crashes");
crash_log.open(
StringFormat("logs/crashes/crash_%s_%i.log", platform_file_name.c_str(), getpid()),
StringFormat("logs/crashes/crash_%s_%i.log", m_platform_file_name.c_str(), getpid()),
std::ios_base::app | std::ios_base::out
);
crash_log << time_stamp << " " << message << "\n";
@@ -366,7 +366,7 @@ void EQEmuLogSys::ProcessConsoleMessage(uint16 log_category, const std::string &
std::cout << EQEmuLogSys::GetLinuxConsoleColorFromCategory(log_category) << message << LC_RESET << std::endl;
#endif
on_log_console_hook(log_category, message);
m_on_log_console_hook(log_category, message);
}
/**
@@ -430,9 +430,9 @@ void EQEmuLogSys::Out(
bool log_to_gmsay = log_settings[log_category].log_to_gmsay > 0 &&
log_settings[log_category].log_to_gmsay >= debug_level &&
log_category != Logs::LogCategory::Netcode &&
(EQEmuLogSys::log_platform == EQEmuExePlatform::ExePlatformZone ||
EQEmuLogSys::log_platform == EQEmuExePlatform::ExePlatformWorld);
bool log_to_discord = EQEmuLogSys::log_platform == EQEmuExePlatform::ExePlatformZone &&
(EQEmuLogSys::m_log_platform == EQEmuExePlatform::ExePlatformZone ||
EQEmuLogSys::m_log_platform == EQEmuExePlatform::ExePlatformWorld);
bool log_to_discord = EQEmuLogSys::m_log_platform == EQEmuExePlatform::ExePlatformZone &&
log_settings[log_category].log_to_discord > 0 &&
log_settings[log_category].log_to_discord >= debug_level &&
log_settings[log_category].discord_webhook_id > 0 &&
@@ -460,13 +460,13 @@ void EQEmuLogSys::Out(
EQEmuLogSys::ProcessConsoleMessage(log_category, output_debug_message);
}
if (log_to_gmsay) {
on_log_gmsay_hook(log_category, message);
m_on_log_gmsay_hook(log_category, output_message);
}
if (log_to_file) {
EQEmuLogSys::ProcessLogWrite(log_category, output_debug_message);
}
if (log_to_discord && on_log_discord_hook) {
on_log_discord_hook(log_category, log_settings[log_category].discord_webhook_id, output_message);
if (log_to_discord && m_on_log_discord_hook) {
m_on_log_discord_hook(log_category, log_settings[log_category].discord_webhook_id, output_message);
}
}
@@ -518,23 +518,23 @@ void EQEmuLogSys::StartFileLogs(const std::string &log_name)
/**
* When loading settings, we must have been given a reason in category based logging to output to a file in order to even create or open one...
*/
if (!file_logs_enabled) {
if (!m_file_logs_enabled) {
return;
}
/**
* Zone
*/
if (EQEmuLogSys::log_platform == EQEmuExePlatform::ExePlatformZone) {
if (EQEmuLogSys::m_log_platform == EQEmuExePlatform::ExePlatformZone) {
if (!log_name.empty()) {
platform_file_name = log_name;
m_platform_file_name = log_name;
}
if (platform_file_name.empty()) {
if (m_platform_file_name.empty()) {
return;
}
LogInfo("Starting File Log [logs/{}_{}.log]", platform_file_name.c_str(), getpid());
LogInfo("Starting File Log [logs/{}_{}.log]", m_platform_file_name.c_str(), getpid());
/**
* Make directory if not exists
@@ -545,7 +545,7 @@ void EQEmuLogSys::StartFileLogs(const std::string &log_name)
* Open file pointer
*/
process_log.open(
StringFormat("logs/zone/%s_%i.log", platform_file_name.c_str(), getpid()),
StringFormat("logs/zone/%s_%i.log", m_platform_file_name.c_str(), getpid()),
std::ios_base::app | std::ios_base::out
);
}
@@ -554,17 +554,17 @@ void EQEmuLogSys::StartFileLogs(const std::string &log_name)
/**
* All other processes
*/
if (platform_file_name.empty()) {
if (m_platform_file_name.empty()) {
return;
}
LogInfo("Starting File Log [logs/{}_{}.log]", platform_file_name.c_str(), getpid());
LogInfo("Starting File Log [logs/{}_{}.log]", m_platform_file_name.c_str(), getpid());
/**
* Open file pointer
*/
process_log.open(
StringFormat("logs/%s_%i.log", platform_file_name.c_str(), getpid()),
StringFormat("logs/%s_%i.log", m_platform_file_name.c_str(), getpid()),
std::ios_base::app | std::ios_base::out
);
}
@@ -594,6 +594,8 @@ void EQEmuLogSys::EnableConsoleLogging()
EQEmuLogSys *EQEmuLogSys::LoadLogDatabaseSettings()
{
InjectTablesIfNotExist();
auto categories = LogsysCategoriesRepository::GetWhere(
*m_database,
"TRUE ORDER BY log_category_id"
@@ -632,7 +634,7 @@ EQEmuLogSys *EQEmuLogSys::LoadLogDatabaseSettings()
// If we go through this whole loop and nothing is set to any debug level, there
// is no point to create a file or keep anything open
if (log_settings[c.log_category_id].log_to_file > 0) {
LogSys.file_logs_enabled = true;
LogSys.m_file_logs_enabled = true;
}
db_categories.emplace_back(c.log_category_id);
@@ -648,7 +650,7 @@ EQEmuLogSys *EQEmuLogSys::LoadLogDatabaseSettings()
auto new_category = LogsysCategoriesRepository::NewEntity();
new_category.log_category_id = i;
new_category.log_category_description = EscapeString(Logs::LogCategoryName[i]);
new_category.log_category_description = Strings::Escape(Logs::LogCategoryName[i]);
new_category.log_to_console = log_settings[i].log_to_console;
new_category.log_to_gmsay = log_settings[i].log_to_gmsay;
new_category.log_to_file = log_settings[i].log_to_file;
@@ -660,10 +662,10 @@ EQEmuLogSys *EQEmuLogSys::LoadLogDatabaseSettings()
LogInfo("Loaded [{}] log categories", categories.size());
auto webhooks = DiscordWebhooksRepository::All(*m_database);
auto webhooks = DiscordWebhooksRepository::GetWhere(*m_database, fmt::format("id < {}", MAX_DISCORD_WEBHOOK_ID));
if (!webhooks.empty()) {
for (auto &w: webhooks) {
discord_webhooks[w.id] = {w.id, w.webhook_name, w.webhook_url};
m_discord_webhooks[w.id] = {w.id, w.webhook_name, w.webhook_url};
}
LogInfo("Loaded [{}] Discord webhooks", webhooks.size());
}
@@ -678,3 +680,55 @@ EQEmuLogSys *EQEmuLogSys::SetDatabase(Database *db)
return this;
}
void EQEmuLogSys::InjectTablesIfNotExist()
{
// do not run injections for zone as its unnecessary hits every time a zone boots
// other processes less frequently ran can pick up injection
if (m_log_platform == EQEmuExePlatform::ExePlatformZone) {
return;
}
// inject discord_webhooks
if (!m_database->DoesTableExist("discord_webhooks")) {
LogInfo("Creating table [discord_webhooks]");
m_database->QueryDatabase(
SQL(
CREATE TABLE discord_webhooks
(
id INT auto_increment primary key NULL,
webhook_name varchar(100) NULL,
webhook_url varchar(255) NULL,
created_at DATETIME NULL,
deleted_at DATETIME NULL
) ENGINE=InnoDB
DEFAULT CHARSET=utf8mb4
COLLATE=utf8mb4_general_ci;
)
);
}
// inject logsys_categories
if (!m_database->DoesTableExist("logsys_categories")) {
LogInfo("Creating table [logsys_categories]");
m_database->QueryDatabase(
SQL(
CREATE TABLE `logsys_categories` (
`log_category_id` int(11) NOT NULL,
`log_category_description` varchar(150) DEFAULT NULL,
`log_to_console` smallint(11) DEFAULT 0,
`log_to_file` smallint(11) DEFAULT 0,
`log_to_gmsay` smallint(11) DEFAULT 0,
`log_to_discord` smallint(11) DEFAULT 0,
`discord_webhook_id` int(11) DEFAULT 0,
PRIMARY KEY (`log_category_id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1
)
);
}
}
const EQEmuLogSys::DiscordWebhooks *EQEmuLogSys::GetDiscordWebhooks() const
{
return m_discord_webhooks;
}
+14 -13
View File
@@ -131,6 +131,7 @@ namespace Logs {
CombatRecord,
Hate,
Discord,
Faction,
MaxCategoryID /* Don't Remove this */
};
@@ -220,6 +221,7 @@ namespace Logs {
"CombatRecord",
"Hate",
"Discord",
"Faction",
};
}
@@ -317,26 +319,20 @@ public:
std::string webhook_url;
};
DiscordWebhooks discord_webhooks[MAX_DISCORD_WEBHOOK_ID]{};
bool file_logs_enabled = false;
int log_platform = 0;
std::string platform_file_name;
const DiscordWebhooks *GetDiscordWebhooks() const;
// gmsay
uint16 GetGMSayColorFromCategory(uint16 log_category);
EQEmuLogSys *SetGMSayHandler(std::function<void(uint16 log_type, const std::string &)> f)
{
on_log_gmsay_hook = f;
m_on_log_gmsay_hook = f;
return this;
}
EQEmuLogSys *SetDiscordHandler(std::function<void(uint16 log_category, int webhook_id, const std::string &)> f)
{
on_log_discord_hook = f;
m_on_log_discord_hook = f;
return this;
}
@@ -346,7 +342,7 @@ public:
uint16 log_type,
const std::string &
)> f
) { on_log_console_hook = f; }
) { m_on_log_console_hook = f; }
void SilenceConsoleLogging();
void EnableConsoleLogging();
@@ -357,9 +353,13 @@ private:
// reference to database
Database *m_database;
std::function<void(uint16 log_category, const std::string &)> on_log_gmsay_hook;
std::function<void(uint16 log_category, int webhook_id, const std::string &)> on_log_discord_hook;
std::function<void(uint16 log_category, const std::string &)> on_log_console_hook;
std::function<void(uint16 log_category, const std::string &)> m_on_log_gmsay_hook;
std::function<void(uint16 log_category, int webhook_id, const std::string &)> m_on_log_discord_hook;
std::function<void(uint16 log_category, const std::string &)> m_on_log_console_hook;
DiscordWebhooks m_discord_webhooks[MAX_DISCORD_WEBHOOK_ID]{};
bool m_file_logs_enabled = false;
int m_log_platform = 0;
std::string m_platform_file_name;
std::string FormatOutMessageString(uint16 log_category, const std::string &in_message);
std::string GetLinuxConsoleColorFromCategory(uint16 log_category);
@@ -368,6 +368,7 @@ private:
void ProcessConsoleMessage(uint16 log_category, const std::string &message);
void ProcessLogWrite(uint16 log_category, const std::string &message);
bool IsRfc5424LogCategory(uint16 log_category);
void InjectTablesIfNotExist();
};
extern EQEmuLogSys LogSys;
+16
View File
@@ -736,6 +736,16 @@
OutF(LogSys, Logs::Detail, Logs::Discord, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\
} while (0)
#define LogFaction(message, ...) do {\
if (LogSys.log_settings[Logs::Faction].is_category_enabled == 1)\
OutF(LogSys, Logs::General, Logs::Faction, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\
} while(0)
#define LogFactionDetail(message, ...) do {\
if (LogSys.log_settings[Logs::Faction].is_category_enabled == 1)\
OutF(LogSys, Logs::Detail, Logs::Faction, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\
} while(0)
#define Log(debug_level, log_category, message, ...) do {\
if (LogSys.log_settings[log_category].is_category_enabled == 1)\
LogSys.Out(debug_level, log_category, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\
@@ -1180,6 +1190,12 @@
#define LogHateDetail(message, ...) do {\
} while (0)
#define LogFaction(message, ...) do {\
} while (0)
#define LogFactionDetail(message, ...) do {\
} while (0)
#define Log(debug_level, log_category, message, ...) do {\
} while (0)
+4 -4
View File
@@ -1,14 +1,14 @@
#pragma once
#include <any>
#include <functional>
#include <exception>
#include "event_loop.h"
#include "../any.h"
namespace EQ {
class Task
{
public:
typedef std::function<void(const EQ::Any&)> ResolveFn;
typedef std::function<void(const std::any&)> ResolveFn;
typedef std::function<void(const std::exception&)> RejectFn;
typedef std::function<void()> FinallyFn;
typedef std::function<void(ResolveFn, RejectFn)> TaskFn;
@@ -19,7 +19,7 @@ namespace EQ {
RejectFn on_catch;
FinallyFn on_finally;
bool has_result;
EQ::Any result;
std::any result;
bool has_error;
std::exception error;
};
@@ -63,7 +63,7 @@ namespace EQ {
uv_queue_work(EventLoop::Get().Handle(), m_work, [](uv_work_t* req) {
TaskBaton *baton = (TaskBaton*)req->data;
baton->fn([baton](const EQ::Any& result) {
baton->fn([baton](const std::any& result) {
baton->has_error = false;
baton->has_result = true;
baton->result = result;
+2 -2
View File
@@ -60,8 +60,8 @@ namespace EQ
}
template<typename Fn, typename... Args>
auto Enqueue(Fn&& fn, Args&&... args) -> std::future<typename std::result_of<Fn(Args...)>::type> {
using return_type = typename std::result_of<Fn(Args...)>::type;
auto Enqueue(Fn&& fn, Args&&... args) -> std::future<typename std::invoke_result<Fn, Args...>::type> {
using return_type = typename std::invoke_result<Fn, Args...>::type;
auto task = std::make_shared<std::packaged_task<return_type()>>(
std::bind(std::forward<Fn>(fn), std::forward<Args>(args)...)
+1 -1
View File
@@ -19,7 +19,7 @@
*/
#include "expedition_lockout_timer.h"
#include "../common/string_util.h"
#include "../common/strings.h"
#include "../common/rulesys.h"
#include "../common/util/uuid.h"
#include <fmt/format.h>
+17
View File
@@ -75,6 +75,23 @@ struct NPCFaction
uint8 temp;
};
// Faction Associations give a much more live like faction system
// Basically the primary faction and magnitude of a faction hit will generate the rest of them
// Largest faction I could find quickly was Lord Inquisitor Seru with 9 total hits (8 associations) so 8 + 2 for max for now
#define MAX_FACTION_ASSOC 10
// this is the ID of a faction association and it's multiplier
struct FactionAssociationHit {
int id;
float multiplier;
};
struct FactionAssociations {
// maybe there should be more data here, fine for now
FactionAssociationHit hits[MAX_FACTION_ASSOC];
};
const char *FactionValueToString(FACTION_VALUE faction_value);
FACTION_VALUE CalculateFaction(FactionMods* fm, int32 tmpCharacter_value);
#endif
+3 -3
View File
@@ -20,7 +20,7 @@
#include "database.h"
//#include "misc_functions.h"
#include "string_util.h"
#include "strings.h"
#include <cstdlib>
#include <cstring>
@@ -1281,10 +1281,10 @@ bool BaseGuildManager::IsCharacterInGuild(uint32 character_id, uint32 guild_id)
if (current_guild_id == GUILD_NONE) {
return false;
}
if (guild_id && current_guild_id != guild_id) {
return false;
}
return true;
}
}
+11 -11
View File
@@ -25,7 +25,7 @@
//#include "races.h"
//#include "rulesys.h"
//#include "shareddb.h"
#include "string_util.h"
#include "strings.h"
#include "../common/light_source.h"
@@ -245,7 +245,7 @@ int16 EQ::InventoryProfile::PutItem(int16 slot_id, const ItemInstance& inst)
if (temp_slot >= m_lookup->InventoryTypeSize.Bank)
return EQ::invslot::SLOT_INVALID;
}
// Clean up item already in slot (if exists)
DeleteItem(slot_id);
@@ -617,7 +617,7 @@ int EQ::InventoryProfile::CountAugmentEquippedByID(uint32 item_id)
quantity += item->CountAugmentByID(item_id);
}
}
return quantity;
}
@@ -648,7 +648,7 @@ int EQ::InventoryProfile::CountItemEquippedByID(uint32 item_id)
quantity += item->IsStackable() ? item->GetCharges() : 1;
}
}
return quantity;
}
@@ -993,7 +993,7 @@ int16 EQ::InventoryProfile::CalcSlotId(int16 slot_id) {
//else if (slot_id >= EmuConstants::BANK_BEGIN && slot_id <= EmuConstants::BANK_END)
// parent_slot_id = EmuConstants::BANK_BEGIN + (slot_id - EmuConstants::BANK_BEGIN) / EmuConstants::ITEM_CONTAINER_SIZE;
//else if (slot_id >= 3100 && slot_id <= 3179) should be {3031..3110}..where did this range come from!!? (verified db save range)
if (slot_id >= invbag::GENERAL_BAGS_BEGIN && slot_id <= invbag::GENERAL_BAGS_END) {
parent_slot_id = invslot::GENERAL_BEGIN + (slot_id - invbag::GENERAL_BAGS_BEGIN) / invbag::SLOT_COUNT;
}
@@ -1231,7 +1231,7 @@ uint8 EQ::InventoryProfile::FindBrightestLightType()
for (auto iter = m_worn.begin(); iter != m_worn.end(); ++iter) {
if ((iter->first < invslot::EQUIPMENT_BEGIN || iter->first > invslot::EQUIPMENT_END))
continue;
if (iter->first == invslot::slotAmmo)
continue;
@@ -1369,7 +1369,7 @@ EQ::ItemInstance* EQ::InventoryProfile::_GetItem(const std::map<int16, ItemInsta
if (slot_id - EQ::invslot::BANK_BEGIN >= m_lookup->InventoryTypeSize.Bank)
return nullptr;
}
auto it = bucket.find(slot_id);
if (it != bucket.end()) {
return it->second;
@@ -1441,7 +1441,7 @@ int16 EQ::InventoryProfile::_PutItem(int16 slot_id, ItemInstance* inst)
result = slot_id;
}
}
if (result == INVALID_INDEX) {
LogError("InventoryProfile::_PutItem: Invalid slot_id specified ({}) with parent slot id ({})", slot_id, parentSlot);
InventoryProfile::MarkDirty(inst); // Slot not found, clean up
@@ -1478,7 +1478,7 @@ int16 EQ::InventoryProfile::_HasItem(std::map<int16, ItemInstance*>& bucket, uin
if (inst->GetAugmentItemID(index) == item_id && quantity <= 1)
return invslot::SLOT_AUGMENT_GENERIC_RETURN;
}
if (!inst->IsClassBag()) { continue; }
for (auto bag_iter = inst->_cbegin(); bag_iter != inst->_cend(); ++bag_iter) {
@@ -1509,7 +1509,7 @@ int16 EQ::InventoryProfile::_HasItem(ItemInstQueue& iqueue, uint32 item_id, uint
// is sufficient. However, in cases where referential criteria is considered, this can lead
// to unintended results. Funtionality should be observed when referencing the return value
// of this query
uint32 quantity_found = 0;
for (auto iter = iqueue.cbegin(); iter != iqueue.cend(); ++iter) {
@@ -1715,6 +1715,6 @@ int16 EQ::InventoryProfile::_HasItemByLoreGroup(ItemInstQueue& iqueue, uint32 lo
// We only check the visible cursor due to lack of queue processing ability (client allows duplicate in limbo)
break;
}
return EQ::invslot::SLOT_INVALID;
}
+5 -5
View File
@@ -19,7 +19,7 @@
#include "inventory_slot.h"
#include "textures.h"
#include "string_util.h"
#include "strings.h"
int8 EQ::inventory::ConvertEquipmentIndexToTextureIndex(int16 slot_index)
@@ -86,7 +86,7 @@ bool EQ::InventorySlot::IsValidSlot() const
{
if (_typeless)
return false;
int16 slot_count = invtype::GetInvTypeSize(_type_index);
if (!slot_count || _slot_index < invslot::SLOT_BEGIN || _slot_index >= slot_count)
return false;
@@ -136,7 +136,7 @@ bool EQ::InventorySlot::IsWeaponIndex(int16 slot_index)
{
if (slot_index == invslot::slotPrimary || slot_index == invslot::slotSecondary || slot_index == invslot::slotRange)
return true;
return false;
}
@@ -364,7 +364,7 @@ bool EQ::InventorySlot::operator<(const InventorySlot& rhs) const
{
if (Typeless() || rhs.Typeless())
return inventory_slot_typeless_lessthan(*this, rhs);
if (TypeIndex() < rhs.TypeIndex())
return true;
@@ -384,6 +384,6 @@ bool EQ::operator==(const InventorySlot& lhs, const InventorySlot& rhs)
{
if (lhs.Typeless() || rhs.Typeless())
return ((lhs.SlotIndex() == rhs.SlotIndex()) && (lhs.ContainerIndex() == rhs.ContainerIndex()) && (lhs.SocketIndex() == rhs.SocketIndex()));
return ((lhs.TypeIndex() == rhs.TypeIndex()) && (lhs.SlotIndex() == rhs.SlotIndex()) && (lhs.ContainerIndex() == rhs.ContainerIndex()) && (lhs.SocketIndex() == rhs.SocketIndex()));
}
+155
View File
@@ -18,7 +18,17 @@
*
*/
#include <cstring>
#include <fmt/format.h>
#include <csignal>
#include <vector>
#include "ip_util.h"
#include "http/httplib.h"
#include "http/uri.h"
#include "eqemu_logsys.h"
#include "event/event_loop.h"
#include "net/dns.h"
#include "event/task_scheduler.h"
/**
* @param ip
@@ -70,3 +80,148 @@ bool IpUtil::IsIpInPrivateRfc1918(const std::string &ip)
IpUtil::IsIpInRange(ip, "192.168.0.0", "255.255.0.0")
);
}
/**
* Gets local address - pings google to inspect what interface was used locally
* @return
*/
std::string IpUtil::GetLocalIPAddress()
{
char my_ip_address[16];
unsigned int my_port;
struct sockaddr_in server_address{};
struct sockaddr_in my_address{};
int sockfd;
// Connect to server
if ((sockfd = socket(AF_INET, SOCK_STREAM, 0)) < 0) {
return "";
}
// Set server_addr
memset(&server_address, 0, sizeof(server_address));
server_address.sin_family = AF_INET;
server_address.sin_addr.s_addr = inet_addr("172.217.160.99");
server_address.sin_port = htons(80);
// Connect to server
if (connect(sockfd, (struct sockaddr *) &server_address, sizeof(server_address)) < 0) {
close(sockfd);
return "";
}
// Get my ip address and port
memset(&my_address, 0, sizeof(my_address));
socklen_t len = sizeof(my_address);
getsockname(sockfd, (struct sockaddr *) &my_address, &len);
inet_ntop(AF_INET, &my_address.sin_addr, my_ip_address, sizeof(my_ip_address));
my_port = ntohs(my_address.sin_port);
return fmt::format("{}", my_ip_address);
}
/**
* Gets public address
* Uses various websites as options to return raw public IP back to the client
* @return
*/
std::string IpUtil::GetPublicIPAddress()
{
std::vector<std::string> endpoints = {
"http://ifconfig.me",
"http://api.ipify.org",
"http://ipinfo.io/ip",
"http://ipecho.net/plain",
};
for (auto &s: endpoints) {
// http get request
uri u(s);
httplib::Client r(
fmt::format(
"{}://{}",
u.get_scheme(),
u.get_host()
).c_str()
);
httplib::Headers headers = {
{"Content-type", "text/plain; charset=utf-8"},
{"User-Agent", "curl/7.81.0"}
};
r.set_connection_timeout(1, 0);
r.set_read_timeout(1, 0);
r.set_write_timeout(1, 0);
if (auto res = r.Get(fmt::format("/{}", u.get_path()).c_str(), headers)) {
if (res->status == 200) {
if (res->body.find('.') != std::string::npos) {
return res->body;
}
}
}
}
return {};
}
std::string IpUtil::DNSLookupSync(const std::string &addr, int port)
{
auto task_runner = new EQ::Event::TaskScheduler();
auto res = task_runner->Enqueue(
[&]() -> std::string {
bool running = true;
std::string ret;
EQ::Net::DNSLookup(
addr, port, false, [&](const std::string &addr) {
ret = addr;
if (addr.empty()) {
ret = "";
running = false;
}
return ret;
}
);
std::chrono::steady_clock::time_point begin = std::chrono::steady_clock::now();
auto &loop = EQ::EventLoop::Get();
while (running) {
if (!ret.empty()) {
running = false;
}
std::chrono::steady_clock::time_point end = std::chrono::steady_clock::now();
if (std::chrono::duration_cast<std::chrono::milliseconds>(end - begin).count() > 1500) {
LogInfo(
"[DNSLookupSync] Deadline exceeded [{}]",
1500
);
running = false;
}
loop.Process();
}
return ret;
}
);
std::string result = res.get();
safe_delete(task_runner);
return result;
}
bool IpUtil::IsIPAddress(const std::string &ip_address)
{
struct sockaddr_in sa{};
int result = inet_pton(AF_INET, ip_address.c_str(), &(sa.sin_addr));
return result != 0;
}
+8 -1
View File
@@ -30,7 +30,14 @@ public:
static uint32_t IPToUInt(const std::string &ip);
static bool IsIpInRange(const std::string &ip, const std::string &network, const std::string &mask);
static bool IsIpInPrivateRfc1918(const std::string &ip);
static std::string GetLocalIPAddress();
static std::string GetPublicIPAddress();
static std::string DNSLookupSync(
const std::string &addr,
int port
);
static bool IsIPAddress(const std::string &ip_address);
};
#endif //EQEMU_IP_UTIL_H
#endif //EQEMU_IP_UTIL_H
+1 -1
View File
@@ -23,7 +23,7 @@
//#include "races.h"
#include "rulesys.h"
#include "shareddb.h"
#include "string_util.h"
#include "strings.h"
//#include "../common/light_source.h"
+1 -1
View File
@@ -9,7 +9,7 @@
*/
#include <string.h> /* for memcpy() */
#include "../common/md5.h"
#include "../common/string_util.h"
#include "../common/strings.h"
#include "../common/seperator.h"
MD5::MD5() {
+7 -1
View File
@@ -10,8 +10,14 @@
#include <iterator>
#include "types.h"
class MySQLRequestRow : public std::iterator<std::input_iterator_tag, MYSQL_ROW>
class MySQLRequestRow
{
public:
using iterator_category = std::input_iterator_tag;
using value_type = MYSQL_ROW;
using difference_type = std::ptrdiff_t;
using pointer = MYSQL_ROW*;
using reference = MYSQL_ROW&;
private:
MYSQL_RES* m_Result;
+6 -6
View File
@@ -1,5 +1,5 @@
#include "console_server.h"
#include "../string_util.h"
#include "../strings.h"
#include <fmt/format.h>
EQ::Net::ConsoleServer::ConsoleServer(const std::string &addr, int port)
@@ -52,11 +52,11 @@ void EQ::Net::ConsoleServer::ConnectionDisconnected(ConsoleServerConnection *c)
void EQ::Net::ConsoleServer::ProcessCommand(ConsoleServerConnection *c, const std::string &cmd)
{
auto split = SplitString(cmd, ' ');
auto split = Strings::Split(cmd, ' ');
if (split.size() > 0) {
auto command = split[0];
ToLowerString(command);
command = Strings::ToLower(command);
if (command == "help" || command == "?") {
c->SendLine("Commands:");
@@ -70,9 +70,9 @@ void EQ::Net::ConsoleServer::ProcessCommand(ConsoleServerConnection *c, const st
c->SendPrompt();
return;
}
split.erase(split.begin(), split.begin() + 1);
auto cmd_def = m_commands.find(command);
if (cmd_def != m_commands.end()) {
if (c->Admin() >= cmd_def->second.status_required) {
+26 -27
View File
@@ -116,43 +116,42 @@ bool EQ::Net::ConsoleServerConnection::SendChannelMessage(const ServerChannelMes
}
switch (scm->chan_num) {
case 4: {
if (RuleB(Chat, ServerWideAuction)) {
QueueMessage(fmt::format("{0} auctions, '{1}'", scm->from, scm->message));
break;
} else { // I think we want default action in this case?
return false;
}
}
case 5: {
if (RuleB(Chat, ServerWideOOC)) {
QueueMessage(fmt::format("{0} says ooc, '{1}'", scm->from, scm->message));
break;
} else { // I think we want default action in this case?
return false;
}
}
case 6: {
QueueMessage(fmt::format("{0} BROADCASTS, '{1}'", scm->from, scm->message));
case ChatChannel_Guild: {
QueueMessage(fmt::format("{} tells the guild [{}], '{}'", scm->from, scm->guilddbid, scm->message));
break;
}
case 7: {
QueueMessage(fmt::format("[{0}] tells you, '{1}'", scm->from, scm->message));
case ChatChannel_Auction: {
if (RuleB(Chat, ServerWideAuction)) {
QueueMessage(fmt::format("{} auctions, '{}'", scm->from, scm->message));
break;
} else { // I think we want default action in this case?
return false;
}
}
case ChatChannel_OOC: {
if (RuleB(Chat, ServerWideOOC)) {
QueueMessage(fmt::format("{} says ooc, '{}'", scm->from, scm->message));
break;
} else { // I think we want default action in this case?
return false;
}
}
case ChatChannel_Broadcast: {
QueueMessage(fmt::format("{} BROADCASTS, '{}'", scm->from, scm->message));
break;
}
case ChatChannel_Tell: {
QueueMessage(fmt::format("[{}] tells {}, '{}'", scm->from, scm->to, scm->message));
if (onTell) {
onTell();
}
break;
}
case 11: {
QueueMessage(fmt::format("{0} GMSAYS, '{1}'", scm->from, scm->message));
case ChatChannel_GMSAY: {
QueueMessage(fmt::format("{} GMSAYS, '{}'", scm->from, scm->message));
break;
}
default: {
return false;
}
+1 -1
View File
@@ -1394,7 +1394,7 @@ void EQ::Net::DaybreakConnection::InternalQueuePacket(Packet &p, int stream_id,
first_header.total_size = (uint32_t)HostToNetwork((uint32_t)length);
size_t used = 0;
size_t sublen = m_max_packet_size - m_crc_bytes - DaybreakReliableFragmentHeader::size();
size_t sublen = m_max_packet_size - m_crc_bytes - DaybreakReliableFragmentHeader::size() - 1; // -1 for compress flag
DynamicPacket first_packet;
first_packet.PutSerialize(0, first_header);
first_packet.PutData(DaybreakReliableFragmentHeader::size(), (char*)p.Data() + used, sublen);
+18 -42
View File
@@ -11,7 +11,7 @@
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
@@ -28,7 +28,7 @@
#include "../eq_packet_structs.h"
#include "../misc_functions.h"
#include "../string_util.h"
#include "../strings.h"
#include "../inventory_profile.h"
#include "rof_structs.h"
#include "../rulesys.h"
@@ -52,13 +52,13 @@ namespace RoF
static inline structs::InventorySlot_Struct ServerToRoFCorpseSlot(uint32 server_corpse_slot);
static inline uint32 ServerToRoFCorpseMainSlot(uint32 server_corpse_slot);
static inline structs::TypelessInventorySlot_Struct ServerToRoFTypelessSlot(uint32 server_slot, int16 server_type);
// client to server inventory location converters
static inline uint32 RoFToServerSlot(structs::InventorySlot_Struct rof_slot);
static inline uint32 RoFToServerCorpseSlot(structs::InventorySlot_Struct rof_corpse_slot);
static inline uint32 RoFToServerCorpseMainSlot(uint32 rof_corpse_slot);
static inline uint32 RoFToServerTypelessSlot(structs::TypelessInventorySlot_Struct rof_slot, int16 rof_type);
// server to client say link converter
static inline void ServerToRoFSayLink(std::string& rofSayLink, const std::string& serverSayLink);
@@ -736,30 +736,6 @@ namespace RoF
FINISH_ENCODE();
}
ENCODE(OP_DzCompass)
{
SETUP_VAR_ENCODE(DynamicZoneCompass_Struct);
ALLOC_VAR_ENCODE(structs::DynamicZoneCompass_Struct,
sizeof(structs::DynamicZoneCompass_Struct) +
sizeof(structs::DynamicZoneCompassEntry_Struct) * emu->count
);
OUT(client_id);
OUT(count);
for (uint32 i = 0; i < emu->count; ++i)
{
OUT(entries[i].dz_zone_id);
OUT(entries[i].dz_instance_id);
OUT(entries[i].dz_type);
OUT(entries[i].x);
OUT(entries[i].y);
OUT(entries[i].z);
}
FINISH_ENCODE();
}
ENCODE(OP_DzExpeditionEndsWarning)
{
ENCODE_LENGTH_EXACT(ExpeditionExpireWarning);
@@ -1558,7 +1534,7 @@ namespace RoF
in->size = ob.size();
in->pBuffer = ob.detach();
delete[] __emu_buffer;
dest->FastQueuePacket(&in, ack_req);
@@ -1838,10 +1814,10 @@ namespace RoF
OUT_str(zone_short_name2);
OUT(zone_id);
OUT(zone_instance);
OUT(SuspendBuffs);
OUT(FastRegenHP);
OUT(FastRegenMana);
OUT(FastRegenEndurance);
OUT(suspend_buffs);
OUT(fast_regen_hp);
OUT(fast_regen_mana);
OUT(fast_regen_endurance);
OUT(underworld_teleport_index);
eq->FogDensity = emu->fog_density;
@@ -1849,8 +1825,8 @@ namespace RoF
/*fill in some unknowns with observed values, hopefully it will help */
eq->unknown800 = -1;
eq->unknown844 = 600;
OUT(LavaDamage);
OUT(MinLavaDamage);
OUT(lava_damage);
OUT(min_lava_damage);
eq->unknown888 = 1;
eq->unknown889 = 0;
eq->unknown890 = 1;
@@ -5188,7 +5164,7 @@ namespace RoF
void SerializeItem(EQ::OutBuffer& ob, const EQ::ItemInstance *inst, int16 slot_id_in, uint8 depth, ItemPacketType packet_type)
{
const EQ::ItemData *item = inst->GetUnscaledItem();
RoF::structs::ItemSerializationHeader hdr;
//sprintf(hdr.unknown000, "06e0002Y1W00");
@@ -5207,7 +5183,7 @@ namespace RoF
slot_id = ServerToRoFSlot(slot_id_in);
break;
}
hdr.slot_type = (inst->GetMerchantSlot() ? invtype::typeMerchant : slot_id.Type);
hdr.main_slot = (inst->GetMerchantSlot() ? inst->GetMerchantSlot() : slot_id.Slot);
hdr.sub_slot = (inst->GetMerchantSlot() ? 0xffff : slot_id.SubIndex);
@@ -5295,7 +5271,7 @@ namespace RoF
ob.write("\0", 1);
ob.write("\0", 1);
RoF::structs::ItemBodyStruct ibs;
memset(&ibs, 0, sizeof(RoF::structs::ItemBodyStruct));
@@ -5608,7 +5584,7 @@ namespace RoF
iqbs.unknown28 = 0;
iqbs.unknown30 = 0;
iqbs.unknown39 = 1;
ob.write((const char*)&iqbs, sizeof(RoF::structs::ItemQuaternaryBodyStruct));
EQ::OutBuffer::pos_type count_pos = ob.tellp();
@@ -5776,7 +5752,7 @@ namespace RoF
static inline uint32 ServerToRoFCorpseMainSlot(uint32 server_corpse_slot)
{
uint32 RoFSlot = invslot::SLOT_INVALID;
if (server_corpse_slot <= EQ::invslot::CORPSE_END && server_corpse_slot >= EQ::invslot::CORPSE_BEGIN) {
RoFSlot = server_corpse_slot;
}
@@ -6123,7 +6099,7 @@ namespace RoF
return;
}
auto segments = SplitString(serverSayLink, '\x12');
auto segments = Strings::Split(serverSayLink, '\x12');
for (size_t segment_iter = 0; segment_iter < segments.size(); ++segment_iter) {
if (segment_iter & 1) {
@@ -6162,7 +6138,7 @@ namespace RoF
return;
}
auto segments = SplitString(rofSayLink, '\x12');
auto segments = Strings::Split(rofSayLink, '\x12');
for (size_t segment_iter = 0; segment_iter < segments.size(); ++segment_iter) {
if (segment_iter & 1) {
+39 -63
View File
@@ -1,5 +1,5 @@
/* EQEMu: Everquest Server Emulator
Copyright (C) 2001-2016 EQEMu Development Team (http://eqemulator.net)
This program is free software; you can redistribute it and/or modify
@@ -28,7 +28,7 @@
#include "../eq_packet_structs.h"
#include "../misc_functions.h"
#include "../string_util.h"
#include "../strings.h"
#include "../inventory_profile.h"
#include "rof2_structs.h"
#include "../rulesys.h"
@@ -53,13 +53,13 @@ namespace RoF2
static inline structs::InventorySlot_Struct ServerToRoF2CorpseSlot(uint32 server_corpse_slot);
static inline uint32 ServerToRoF2CorpseMainSlot(uint32 server_corpse_slot);
static inline structs::TypelessInventorySlot_Struct ServerToRoF2TypelessSlot(uint32 server_slot, int16 server_type);
// client to server inventory location converters
static inline uint32 RoF2ToServerSlot(structs::InventorySlot_Struct rof2_slot);
static inline uint32 RoF2ToServerCorpseSlot(structs::InventorySlot_Struct rof2_corpse_slot);
static inline uint32 RoF2ToServerCorpseMainSlot(uint32 rof2_corpse_slot);
static inline uint32 RoF2ToServerTypelessSlot(structs::TypelessInventorySlot_Struct rof2_slot, int16 rof2_type);
// server to client say link converter
static inline void ServerToRoF2SayLink(std::string &rof2_saylink, const std::string &server_saylink);
@@ -785,30 +785,6 @@ namespace RoF2
FINISH_ENCODE();
}
ENCODE(OP_DzCompass)
{
SETUP_VAR_ENCODE(DynamicZoneCompass_Struct);
ALLOC_VAR_ENCODE(structs::DynamicZoneCompass_Struct,
sizeof(structs::DynamicZoneCompass_Struct) +
sizeof(structs::DynamicZoneCompassEntry_Struct) * emu->count
);
OUT(client_id);
OUT(count);
for (uint32 i = 0; i < emu->count; ++i)
{
OUT(entries[i].dz_zone_id);
OUT(entries[i].dz_instance_id);
OUT(entries[i].dz_type);
OUT(entries[i].x);
OUT(entries[i].y);
OUT(entries[i].z);
}
FINISH_ENCODE();
}
ENCODE(OP_DzExpeditionEndsWarning)
{
ENCODE_LENGTH_EXACT(ExpeditionExpireWarning);
@@ -1887,13 +1863,13 @@ namespace RoF2
OUT_str(zone_short_name2);
OUT(zone_id);
OUT(zone_instance);
OUT(SuspendBuffs);
OUT(FastRegenHP);
OUT(FastRegenMana);
OUT(FastRegenEndurance);
OUT(suspend_buffs);
OUT(fast_regen_hp);
OUT(fast_regen_mana);
OUT(fast_regen_endurance);
OUT(underworld_teleport_index);
eq->FogDensity = emu->fog_density;
eq->fog_density = emu->fog_density;
/*fill in some unknowns with observed values, hopefully it will help */
eq->ZoneTimeZone = 0;
@@ -1905,22 +1881,22 @@ namespace RoF2
eq->SkyRelated2 = -1;
eq->NPCAggroMaxDist = 600;
eq->FilterID = 2008; // Guild Lobby observed value
OUT(LavaDamage);
OUT(MinLavaDamage);
eq->bDisallowManaStone = 1;
eq->bNoBind = 0;
eq->bNoAttack = 0;
eq->bNoCallOfHero = 0;
eq->bNoFlux = 0;
eq->bNoFear = 0;
eq->fall_damage = 0; // 0 = Fall Damage on, 1 = Fall Damage off
eq->unknown895 = 0;
eq->CanPlaceCampsite = 2;
eq->CanPlaceGuildBanner = 2;
eq->FishingRelated = -1; // Set from PoK Example
eq->ForageRelated = -1; // Set from PoK Example
eq->bNoLevitate = 0;
eq->Blooming = 1.0; // Set from PoK Example
OUT(lava_damage);
OUT(min_lava_damage);
eq->bDisallowManaStone = 1;
eq->bNoBind = 0;
eq->bNoAttack = 0;
eq->bNoCallOfHero = 0;
eq->bNoFlux = 0;
eq->bNoFear = 0;
eq->fall_damage = 0; // 0 = Fall Damage on, 1 = Fall Damage off
eq->unknown895 = 0;
eq->can_place_campsite = 2;
eq->can_place_guild_banner = 2;
eq->fishing_related = -1; // Set from PoK Example
eq->forage_related = -1; // Set from PoK Example
eq->b_no_levitate = 0;
eq->blooming = 1.0; // Set from PoK Example
FINISH_ENCODE();
}
@@ -2894,12 +2870,12 @@ namespace RoF2
EQApplicationPacket *inapp = *p;
*p = nullptr;
AARankInfo_Struct *emu = (AARankInfo_Struct*)inapp->pBuffer;
// the structs::SendAA_Struct includes enough space for 1 prereq which is the min even if it has no prereqs
auto prereq_size = emu->total_prereqs > 1 ? (emu->total_prereqs - 1) * 8 : 0;
auto outapp = new EQApplicationPacket(OP_SendAATable, sizeof(structs::SendAA_Struct) + emu->total_effects * sizeof(structs::AA_Ability) + prereq_size);
inapp->SetReadPosition(sizeof(AARankInfo_Struct)+emu->total_effects * sizeof(AARankEffect_Struct));
std::vector<int32> skill;
std::vector<int32> points;
@@ -2962,7 +2938,7 @@ namespace RoF2
outapp->WriteUInt32(inapp->ReadUInt32()); // base2
outapp->WriteUInt32(inapp->ReadUInt32()); // slot
}
dest->FastQueuePacket(&outapp);
delete inapp;
}
@@ -5062,11 +5038,11 @@ namespace RoF2
SETUP_DIRECT_DECODE(MoveItem_Struct, structs::MoveItem_Struct);
Log(Logs::Moderate, Logs::Netcode, "RoF2::DECODE(OP_MoveItem)");
emu->from_slot = RoF2ToServerSlot(eq->from_slot);
emu->to_slot = RoF2ToServerSlot(eq->to_slot);
IN(number_in_stack);
//LogNetcode("[RoF2] MoveItem Slot from [{}] to [{}], Number [{}]", emu->from_slot, emu->to_slot, emu->number_in_stack);
FINISH_DIRECT_DECODE();
@@ -5443,7 +5419,7 @@ namespace RoF2
void SerializeItem(EQ::OutBuffer& ob, const EQ::ItemInstance *inst, int16 slot_id_in, uint8 depth, ItemPacketType packet_type)
{
const EQ::ItemData *item = inst->GetUnscaledItem();
RoF2::structs::ItemSerializationHeader hdr;
//sprintf(hdr.unknown000, "06e0002Y1W00");
@@ -5462,7 +5438,7 @@ namespace RoF2
slot_id = ServerToRoF2Slot(slot_id_in);
break;
}
hdr.slot_type = (inst->GetMerchantSlot() ? invtype::typeMerchant : slot_id.Type);
hdr.main_slot = (inst->GetMerchantSlot() ? inst->GetMerchantSlot() : slot_id.Slot);
hdr.sub_slot = (inst->GetMerchantSlot() ? 0xffff : slot_id.SubIndex);
@@ -5550,7 +5526,7 @@ namespace RoF2
ob.write("\0", 1);
ob.write("\0", 1);
RoF2::structs::ItemBodyStruct ibs;
memset(&ibs, 0, sizeof(RoF2::structs::ItemBodyStruct));
@@ -5873,7 +5849,7 @@ namespace RoF2
iqbs.unknown37a = 0; // (guessed position) New to RoF2
iqbs.unknown38 = 0;
iqbs.unknown39 = 1;
ob.write((const char*)&iqbs, sizeof(RoF2::structs::ItemQuaternaryBodyStruct));
EQ::OutBuffer::pos_type count_pos = ob.tellp();
@@ -6073,7 +6049,7 @@ namespace RoF2
uint32 server_slot = EQ::invslot::SLOT_INVALID;
uint32 temp_slot = invslot::SLOT_INVALID;
switch (rof2_slot.Type) {
case invtype::typePossessions: {
if (rof2_slot.Slot >= invslot::POSSESSIONS_BEGIN && rof2_slot.Slot <= invslot::POSSESSIONS_END) {
@@ -6188,11 +6164,11 @@ namespace RoF2
static inline uint32 RoF2ToServerCorpseSlot(structs::InventorySlot_Struct rof2_corpse_slot)
{
uint32 ServerSlot = EQ::invslot::SLOT_INVALID;
if (rof2_corpse_slot.Type != invtype::typeCorpse || rof2_corpse_slot.SubIndex != invbag::SLOT_INVALID || rof2_corpse_slot.AugIndex != invaug::SOCKET_INVALID) {
ServerSlot = EQ::invslot::SLOT_INVALID;
}
else {
ServerSlot = RoF2ToServerCorpseMainSlot(rof2_corpse_slot.Slot);
}
@@ -6346,7 +6322,7 @@ namespace RoF2
return;
}
auto segments = SplitString(server_saylink, '\x12');
auto segments = Strings::Split(server_saylink, '\x12');
for (size_t segment_iter = 0; segment_iter < segments.size(); ++segment_iter) {
if (segment_iter & 1) {
@@ -6378,7 +6354,7 @@ namespace RoF2
return;
}
auto segments = SplitString(rof2_saylink, '\x12');
auto segments = Strings::Split(rof2_saylink, '\x12');
for (size_t segment_iter = 0; segment_iter < segments.size(); ++segment_iter) {
if (segment_iter & 1) {
+2 -2
View File
@@ -1,5 +1,5 @@
/* EQEMu: Everquest Server Emulator
Copyright (C) 2001-2016 EQEMu Development Team (http://eqemulator.net)
This program is free software; you can redistribute it and/or modify
@@ -19,7 +19,7 @@
#include "rof2_limits.h"
#include "../string_util.h"
#include "../strings.h"
int16 RoF2::invtype::GetInvTypeSize(int16 inv_type)
-1
View File
@@ -59,7 +59,6 @@ E(OP_DeleteItem)
E(OP_DeleteSpawn)
E(OP_DisciplineUpdate)
E(OP_DzChooseZone)
E(OP_DzCompass)
E(OP_DzExpeditionEndsWarning)
E(OP_DzExpeditionInfo)
E(OP_DzExpeditionInvite)
+37 -37
View File
@@ -1,5 +1,5 @@
/* EQEMu: Everquest Server Emulator
Copyright (C) 2001-2016 EQEMu Development Team (http://eqemulator.net)
This program is free software; you can redistribute it and/or modify
@@ -620,40 +620,40 @@ struct NewZone_Struct {
/*0800*/ int32 SkyRelated2; //seen -1 -- maybe some default sky time?
/*0804*/ char WeatherString2[32]; //
/*0836*/ float WeatherChangeTime; // not sure :P
/*0840*/ uint32 Climate;
/*0844*/ int32 NPCAggroMaxDist; //seen 600
/*0848*/ int32 FilterID; //seen 2008 -- maybe zone guide related?
/*0852*/ uint16 zone_id; // this might just be instance ID got 1736 for time
/*0854*/ uint16 zone_instance;
/*0856*/ uint32 scriptNPCReceivedanItem;
/*0860*/ uint32 bCheck; // padded bool
/*0864*/ uint32 scriptIDSomething;
/*0868*/ uint32 underworld_teleport_index; // > 0 teleports w/ zone point index, invalid succors, -1 affects some collisions
/*0872*/ uint32 scriptIDSomething3;
/*0876*/ uint32 SuspendBuffs; // padded bool
/*0880*/ uint32 LavaDamage; // LavaDamage value
/*0884*/ uint32 MinLavaDamage; // min cap after resist calcs
/*0888*/ uint8 bDisallowManaStone; // can't use manastone in this zone
/*0889*/ uint8 bNoBind; // can't bind even if outdoor says we can!
/*0890*/ uint8 bNoAttack; // non-attack zone
/*0891*/ uint8 bNoCallOfHero; // coth line disabled
/*0892*/ uint8 bNoFlux; // gflux no worky
/*0893*/ uint8 bNoFear; // fear spells no worky
/*0894*/ uint8 fall_damage; // 0 = Fall Damage on, 1 = Fall Damage off MQ2 calls bNoEncumber
/*0895*/ uint8 unknown895; // padding
/*0896*/ uint32 FastRegenHP; // percentage I think?
/*0900*/ uint32 FastRegenMana; // percentage I think?
/*0904*/ uint32 FastRegenEndurance; // percentage I think?
/*0908*/ uint32 CanPlaceCampsite; // 0 = no, 1 = can place, 2 = place and goto
/*0912*/ uint32 CanPlaceGuildBanner; // ^
/*0916*/ float FogDensity; // Most zones have this set to 0.33 Blightfire had 0.16
/*0920*/ uint32 bAdjustGamma; // padded bool
/*0924*/ uint32 TimeStringID; // Seen 0
/*0928*/ uint32 bNoMercenaries; // padded bool
/*0932*/ int32 FishingRelated; // Seen -1 idk
/*0936*/ int32 ForageRelated; // Seen -1 idk
/*0940*/ uint32 bNoLevitate; // padded bool
/*0944*/ float Blooming; // Seen 1.0 in PoK, and 0.25 in Guild Lobby
/*0840*/ uint32 Climate;
/*0844*/ int32 NPCAggroMaxDist; //seen 600
/*0848*/ int32 FilterID; //seen 2008 -- maybe zone guide related?
/*0852*/ uint16 zone_id; // this might just be instance ID got 1736 for time
/*0854*/ uint16 zone_instance;
/*0856*/ uint32 scriptNPCReceivedanItem;
/*0860*/ uint32 bCheck; // padded bool
/*0864*/ uint32 scriptIDSomething;
/*0868*/ uint32 underworld_teleport_index; // > 0 teleports w/ zone point index, invalid succors, -1 affects some collisions
/*0872*/ uint32 scriptIDSomething3;
/*0876*/ uint32 suspend_buffs; // padded bool
/*0880*/ uint32 lava_damage; // lava_damage value
/*0884*/ uint32 min_lava_damage; // min cap after resist calcs
/*0888*/ uint8 bDisallowManaStone; // can't use manastone in this zone
/*0889*/ uint8 bNoBind; // can't bind even if outdoor says we can!
/*0890*/ uint8 bNoAttack; // non-attack zone
/*0891*/ uint8 bNoCallOfHero; // coth line disabled
/*0892*/ uint8 bNoFlux; // gflux no worky
/*0893*/ uint8 bNoFear; // fear spells no worky
/*0894*/ uint8 fall_damage; // 0 = Fall Damage on, 1 = Fall Damage off MQ2 calls bNoEncumber
/*0895*/ uint8 unknown895; // padding
/*0896*/ uint32 fast_regen_hp; // percentage I think?
/*0900*/ uint32 fast_regen_mana; // percentage I think?
/*0904*/ uint32 fast_regen_endurance; // percentage I think?
/*0908*/ uint32 can_place_campsite; // 0 = no, 1 = can place, 2 = place and goto
/*0912*/ uint32 can_place_guild_banner; // ^
/*0916*/ float fog_density; // Most zones have this set to 0.33 Blightfire had 0.16
/*0920*/ uint32 b_adjust_gamma; // padded bool
/*0924*/ uint32 time_string_id; // Seen 0
/*0928*/ uint32 b_no_mercenaries; // padded bool
/*0932*/ int32 fishing_related; // Seen -1 idk
/*0936*/ int32 forage_related; // Seen -1 idk
/*0940*/ uint32 b_no_levitate; // padded bool
/*0944*/ float blooming; // Seen 1.0 in PoK, and 0.25 in Guild Lobby
/*0948*/
};
@@ -3476,7 +3476,7 @@ struct TraderClick_Struct{
/*000*/ uint32 Code;
/*004*/ uint32 TraderID;
/*008*/ uint32 Approval;
/*012*/
/*012*/
};
struct FormattedMessage_Struct{
@@ -4989,7 +4989,7 @@ struct DynamicZoneCompassEntry_Struct
/*000*/ uint16 dz_zone_id; // target dz id pair
/*002*/ uint16 dz_instance_id;
/*004*/ uint32 dz_type; // 1: Expedition, 2: Tutorial (purple), 3: Task, 4: Mission, 5: Quest (green)
/*008*/ uint32 unknown008;
/*008*/ uint32 dz_switch_id;
/*012*/ float y;
/*016*/ float x;
/*020*/ float z;
+2 -2
View File
@@ -1,5 +1,5 @@
/* EQEMu: Everquest Server Emulator
Copyright (C) 2001-2016 EQEMu Development Team (http://eqemulator.net)
This program is free software; you can redistribute it and/or modify
@@ -19,7 +19,7 @@
#include "rof_limits.h"
#include "../string_util.h"
#include "../strings.h"
int16 RoF::invtype::GetInvTypeSize(int16 inv_type)
-1
View File
@@ -45,7 +45,6 @@ E(OP_DeleteItem)
E(OP_DeleteSpawn)
E(OP_DisciplineUpdate)
E(OP_DzChooseZone)
E(OP_DzCompass)
E(OP_DzExpeditionEndsWarning)
E(OP_DzExpeditionInfo)
E(OP_DzExpeditionInvite)
+33 -33
View File
@@ -1,5 +1,5 @@
/* EQEMu: Everquest Server Emulator
Copyright (C) 2001-2016 EQEMu Development Team (http://eqemulator.net)
This program is free software; you can redistribute it and/or modify
@@ -571,39 +571,39 @@ struct NewZone_Struct {
/*0704*/ char zone_short_name2[96]; //zone file name? excludes instance number which can be in previous version.
/*0800*/ int32 unknown800; //seen -1
/*0804*/ char unknown804[40]; //
/*0844*/ int32 unknown844; //seen 600
/*0848*/ int32 unknown848;
/*0852*/ uint16 zone_id;
/*0854*/ uint16 zone_instance;
/*0856*/ uint32 scriptNPCReceivedanItem;
/*0860*/ uint32 bCheck; // padded bool
/*0864*/ uint32 scriptIDSomething;
/*0868*/ uint32 underworld_teleport_index; // > 0 teleports w/ zone point index, invalid succors, -1 affects some collisions
/*0872*/ uint32 scriptIDSomething3;
/*0876*/ uint32 SuspendBuffs;
/*0880*/ uint32 LavaDamage; // Seen 50
/*0884*/ uint32 MinLavaDamage; // Seen 10
/*0888*/ uint8 unknown888; // Seen 1
/*0889*/ uint8 unknown889; // Seen 0 (POK) or 1 (rujj)
/*0890*/ uint8 unknown890; // Seen 1
/*0891*/ uint8 unknown891; // Seen 0
/*0892*/ uint8 unknown892; // Seen 0
/*0893*/ uint8 unknown893; // Seen 0 - 00
/*0894*/ uint8 fall_damage; // 0 = Fall Damage on, 1 = Fall Damage off
/*0895*/ uint8 unknown895; // Seen 0 - 00
/*0896*/ uint32 FastRegenHP; // Seen 180
/*0900*/ uint32 FastRegenMana; // Seen 180
/*0904*/ uint32 FastRegenEndurance; // Seen 180
/*0908*/ uint32 unknown908; // Seen 2
/*0912*/ uint32 unknown912; // Seen 2
/*0916*/ float FogDensity; // Most zones have this set to 0.33 Blightfire had 0.16
/*0920*/ uint32 unknown920; // Seen 0
/*0924*/ uint32 unknown924; // Seen 0
/*0928*/ uint32 unknown928; // Seen 0
/*0844*/ int32 unknown844; //seen 600
/*0848*/ int32 unknown848;
/*0852*/ uint16 zone_id;
/*0854*/ uint16 zone_instance;
/*0856*/ uint32 scriptNPCReceivedanItem;
/*0860*/ uint32 bCheck; // padded bool
/*0864*/ uint32 scriptIDSomething;
/*0868*/ uint32 underworld_teleport_index; // > 0 teleports w/ zone point index, invalid succors, -1 affects some collisions
/*0872*/ uint32 scriptIDSomething3;
/*0876*/ uint32 suspend_buffs;
/*0880*/ uint32 lava_damage; // Seen 50
/*0884*/ uint32 min_lava_damage; // Seen 10
/*0888*/ uint8 unknown888; // Seen 1
/*0889*/ uint8 unknown889; // Seen 0 (POK) or 1 (rujj)
/*0890*/ uint8 unknown890; // Seen 1
/*0891*/ uint8 unknown891; // Seen 0
/*0892*/ uint8 unknown892; // Seen 0
/*0893*/ uint8 unknown893; // Seen 0 - 00
/*0894*/ uint8 fall_damage; // 0 = Fall Damage on, 1 = Fall Damage off
/*0895*/ uint8 unknown895; // Seen 0 - 00
/*0896*/ uint32 fast_regen_hp; // Seen 180
/*0900*/ uint32 fast_regen_mana; // Seen 180
/*0904*/ uint32 fast_regen_endurance; // Seen 180
/*0908*/ uint32 unknown908; // Seen 2
/*0912*/ uint32 unknown912; // Seen 2
/*0916*/ float FogDensity; // Most zones have this set to 0.33 Blightfire had 0.16
/*0920*/ uint32 unknown920; // Seen 0
/*0924*/ uint32 unknown924; // Seen 0
/*0928*/ uint32 unknown928; // Seen 0
/*0932*/ int32 unknown932; // Seen -1
/*0936*/ int32 unknown936; // Seen -1
/*0940*/ uint32 unknown940; // Seen 0
/*0944*/ float unknown944; // Seen 1.0
/*0940*/ uint32 unknown940; // Seen 0
/*0944*/ float unknown944; // Seen 1.0
/*0948*/
};
@@ -4921,7 +4921,7 @@ struct DynamicZoneCompassEntry_Struct
/*000*/ uint16 dz_zone_id; // target dz id pair
/*002*/ uint16 dz_instance_id;
/*004*/ uint32 dz_type; // 1: Expedition, 2: Tutorial (purple), 3: Task, 4: Mission, 5: Quest (green)
/*008*/ uint32 unknown008;
/*008*/ uint32 dz_switch_id;
/*012*/ float y;
/*016*/ float x;
/*020*/ float z;
+17 -41
View File
@@ -1,5 +1,5 @@
/* EQEMu: Everquest Server Emulator
Copyright (C) 2001-2016 EQEMu Development Team (http://eqemulator.net)
This program is free software; you can redistribute it and/or modify
@@ -28,7 +28,7 @@
#include "../eq_packet_structs.h"
#include "../misc_functions.h"
#include "../string_util.h"
#include "../strings.h"
#include "../item_instance.h"
#include "sod_structs.h"
#include "../rulesys.h"
@@ -407,7 +407,7 @@ namespace SoD
in->size = ob.size();
in->pBuffer = ob.detach();
delete[] __emu_buffer;
dest->FastQueuePacket(&in, ack_req);
@@ -509,30 +509,6 @@ namespace SoD
FINISH_ENCODE();
}
ENCODE(OP_DzCompass)
{
SETUP_VAR_ENCODE(DynamicZoneCompass_Struct);
ALLOC_VAR_ENCODE(structs::DynamicZoneCompass_Struct,
sizeof(structs::DynamicZoneCompass_Struct) +
sizeof(structs::DynamicZoneCompassEntry_Struct) * emu->count
);
OUT(client_id);
OUT(count);
for (uint32 i = 0; i < emu->count; ++i)
{
OUT(entries[i].dz_zone_id);
OUT(entries[i].dz_instance_id);
OUT(entries[i].dz_type);
OUT(entries[i].x);
OUT(entries[i].y);
OUT(entries[i].z);
}
FINISH_ENCODE();
}
ENCODE(OP_DzExpeditionEndsWarning)
{
ENCODE_LENGTH_EXACT(ExpeditionExpireWarning);
@@ -1089,7 +1065,7 @@ namespace SoD
//store away the emu struct
uchar* __emu_buffer = in->pBuffer;
EQ::InternalSerializedItem_Struct* int_struct = (EQ::InternalSerializedItem_Struct*)(&__emu_buffer[4]);
EQ::OutBuffer ob;
@@ -1106,7 +1082,7 @@ namespace SoD
in->size = ob.size();
in->pBuffer = ob.detach();
delete[] __emu_buffer;
dest->FastQueuePacket(&in, ack_req);
@@ -1365,17 +1341,17 @@ namespace SoD
OUT_str(zone_short_name2);
OUT(zone_id);
OUT(zone_instance);
OUT(SuspendBuffs);
OUT(FastRegenHP);
OUT(FastRegenMana);
OUT(FastRegenEndurance);
OUT(suspend_buffs);
OUT(fast_regen_hp);
OUT(fast_regen_mana);
OUT(fast_regen_endurance);
OUT(underworld_teleport_index);
/*fill in some unknowns with observed values, hopefully it will help */
eq->unknown800 = -1;
eq->unknown844 = 600;
OUT(LavaDamage);
OUT(MinLavaDamage);
OUT(lava_damage);
OUT(min_lava_damage);
eq->unknown888 = 1;
eq->unknown889 = 0;
eq->unknown890 = 1;
@@ -1385,8 +1361,8 @@ namespace SoD
eq->fall_damage = 0; // 0 = Fall Damage on, 1 = Fall Damage off
eq->unknown895 = 0;
eq->unknown908 = 2;
eq->unknown912 = 2;
eq->FogDensity = emu->fog_density;
eq->unknown912 = 2;
eq->fog_density = emu->fog_density;
FINISH_ENCODE();
}
@@ -3538,7 +3514,7 @@ namespace SoD
void SerializeItem(EQ::OutBuffer& ob, const EQ::ItemInstance *inst, int16 slot_id_in, uint8 depth)
{
const EQ::ItemData *item = inst->GetUnscaledItem();
SoD::structs::ItemSerializationHeader hdr;
hdr.stacksize = (inst->IsStackable() ? ((inst->GetCharges() > 254) ? 0xFFFFFFFF : inst->GetCharges()) : 1);
@@ -3849,7 +3825,7 @@ namespace SoD
iqbs.HealAmt = item->HealAmt;
iqbs.SpellDmg = item->SpellDmg;
iqbs.Clairvoyance = item->Clairvoyance;
ob.write((const char*)&iqbs, sizeof(SoD::structs::ItemQuaternaryBodyStruct));
EQ::OutBuffer::pos_type count_pos = ob.tellp();
@@ -4061,7 +4037,7 @@ namespace SoD
return;
}
auto segments = SplitString(server_saylink, '\x12');
auto segments = Strings::Split(server_saylink, '\x12');
for (size_t segment_iter = 0; segment_iter < segments.size(); ++segment_iter) {
if (segment_iter & 1) {
@@ -4101,7 +4077,7 @@ namespace SoD
return;
}
auto segments = SplitString(sod_saylink, '\x12');
auto segments = Strings::Split(sod_saylink, '\x12');
for (size_t segment_iter = 0; segment_iter < segments.size(); ++segment_iter) {
if (segment_iter & 1) {
+2 -2
View File
@@ -1,5 +1,5 @@
/* EQEMu: Everquest Server Emulator
Copyright (C) 2001-2016 EQEMu Development Team (http://eqemulator.net)
This program is free software; you can redistribute it and/or modify
@@ -19,7 +19,7 @@
#include "sod_limits.h"
#include "../string_util.h"
#include "../strings.h"
int16 SoD::invtype::GetInvTypeSize(int16 inv_type)
-1
View File
@@ -36,7 +36,6 @@ E(OP_Damage)
E(OP_DeleteCharge)
E(OP_DeleteItem)
E(OP_DzChooseZone)
E(OP_DzCompass)
E(OP_DzExpeditionEndsWarning)
E(OP_DzExpeditionInfo)
E(OP_DzExpeditionInvite)
+31 -31
View File
@@ -1,5 +1,5 @@
/* EQEMu: Everquest Server Emulator
Copyright (C) 2001-2016 EQEMu Development Team (http://eqemulator.net)
This program is free software; you can redistribute it and/or modify
@@ -440,35 +440,35 @@ struct NewZone_Struct {
/*0704*/ char zone_short_name2[96]; //zone file name? excludes instance number which can be in previous version.
/*0800*/ int32 unknown800; //seen -1
/*0804*/ char unknown804[40]; //
/*0844*/ int32 unknown844; //seen 600
/*0848*/ int32 unknown848;
/*0852*/ uint16 zone_id;
/*0854*/ uint16 zone_instance;
/*0856*/ uint32 scriptNPCReceivedanItem;
/*0860*/ uint32 bCheck; // padded bool
/*0864*/ uint32 scriptIDSomething;
/*0868*/ uint32 underworld_teleport_index; // > 0 teleports w/ zone point index, invalid succors, -1 affects some collisions
/*0872*/ uint32 scriptIDSomething3;
/*0876*/ uint32 SuspendBuffs;
/*0880*/ uint32 LavaDamage; //seen 50
/*0884*/ uint32 MinLavaDamage; //seen 10
/*0888*/ uint8 unknown888; //seen 1
/*0889*/ uint8 unknown889; //seen 0 (POK) or 1 (rujj)
/*0890*/ uint8 unknown890; //seen 1
/*0891*/ uint8 unknown891; //seen 0
/*0892*/ uint8 unknown892; //seen 0
/*0893*/ uint8 unknown893; //seen 0 - 00
/*0894*/ uint8 fall_damage; // 0 = Fall Damage on, 1 = Fall Damage off
/*0895*/ uint8 unknown895; //seen 0 - 00
/*0896*/ uint32 FastRegenHP; //seen 180
/*0900*/ uint32 FastRegenMana; //seen 180
/*0904*/ uint32 FastRegenEndurance; //seen 180
/*0908*/ uint32 unknown908; //seen 2
/*0912*/ uint32 unknown912; //seen 2
/*0916*/ float FogDensity; //Of about 10 or so zones tested, all but one have this set to 0.33 Blightfire had 0.16
/*0920*/ uint32 unknown920; //seen 0
/*0924*/ uint32 unknown924; //seen 0
/*0928*/ uint32 unknown928; //seen 0
/*0844*/ int32 unknown844; //seen 600
/*0848*/ int32 unknown848;
/*0852*/ uint16 zone_id;
/*0854*/ uint16 zone_instance;
/*0856*/ uint32 scriptNPCReceivedanItem;
/*0860*/ uint32 bCheck; // padded bool
/*0864*/ uint32 scriptIDSomething;
/*0868*/ uint32 underworld_teleport_index; // > 0 teleports w/ zone point index, invalid succors, -1 affects some collisions
/*0872*/ uint32 scriptIDSomething3;
/*0876*/ uint32 suspend_buffs;
/*0880*/ uint32 lava_damage; //seen 50
/*0884*/ uint32 min_lava_damage; //seen 10
/*0888*/ uint8 unknown888; //seen 1
/*0889*/ uint8 unknown889; //seen 0 (POK) or 1 (rujj)
/*0890*/ uint8 unknown890; //seen 1
/*0891*/ uint8 unknown891; //seen 0
/*0892*/ uint8 unknown892; //seen 0
/*0893*/ uint8 unknown893; //seen 0 - 00
/*0894*/ uint8 fall_damage; // 0 = Fall Damage on, 1 = Fall Damage off
/*0895*/ uint8 unknown895; //seen 0 - 00
/*0896*/ uint32 fast_regen_hp; //seen 180
/*0900*/ uint32 fast_regen_mana; //seen 180
/*0904*/ uint32 fast_regen_endurance; //seen 180
/*0908*/ uint32 unknown908; //seen 2
/*0912*/ uint32 unknown912; //seen 2
/*0916*/ float fog_density; //Of about 10 or so zones tested, all but one have this set to 0.33 Blightfire had 0.16
/*0920*/ uint32 unknown920; //seen 0
/*0924*/ uint32 unknown924; //seen 0
/*0928*/ uint32 unknown928; //seen 0
/*0932*/
};
@@ -4276,7 +4276,7 @@ struct DynamicZoneCompassEntry_Struct
/*000*/ uint16 dz_zone_id; // target dz id pair
/*002*/ uint16 dz_instance_id;
/*004*/ uint32 dz_type; // 1: Expedition, 2: Tutorial (purple), 3: Task, 4: Mission, 5: Quest (green)
/*008*/ uint32 unknown008;
/*008*/ uint32 dz_switch_id;
/*012*/ float y;
/*016*/ float x;
/*020*/ float z;
+16 -40
View File
@@ -1,5 +1,5 @@
/* EQEMu: Everquest Server Emulator
Copyright (C) 2001-2016 EQEMu Development Team (http://eqemulator.net)
This program is free software; you can redistribute it and/or modify
@@ -28,7 +28,7 @@
#include "../eq_packet_structs.h"
#include "../misc_functions.h"
#include "../string_util.h"
#include "../strings.h"
#include "../item_instance.h"
#include "sof_structs.h"
#include "../rulesys.h"
@@ -387,7 +387,7 @@ namespace SoF
in->size = ob.size();
in->pBuffer = ob.detach();
delete[] __emu_buffer;
dest->FastQueuePacket(&in, ack_req);
@@ -497,30 +497,6 @@ namespace SoF
FINISH_ENCODE();
}
ENCODE(OP_DzCompass)
{
SETUP_VAR_ENCODE(DynamicZoneCompass_Struct);
ALLOC_VAR_ENCODE(structs::DynamicZoneCompass_Struct,
sizeof(structs::DynamicZoneCompass_Struct) +
sizeof(structs::DynamicZoneCompassEntry_Struct) * emu->count
);
OUT(client_id);
OUT(count);
for (uint32 i = 0; i < emu->count; ++i)
{
OUT(entries[i].dz_zone_id);
OUT(entries[i].dz_instance_id);
OUT(entries[i].dz_type);
OUT(entries[i].x);
OUT(entries[i].y);
OUT(entries[i].z);
}
FINISH_ENCODE();
}
ENCODE(OP_DzExpeditionEndsWarning)
{
ENCODE_LENGTH_EXACT(ExpeditionExpireWarning);
@@ -885,7 +861,7 @@ namespace SoF
//store away the emu struct
uchar* __emu_buffer = in->pBuffer;
EQ::InternalSerializedItem_Struct* int_struct = (EQ::InternalSerializedItem_Struct*)(&__emu_buffer[4]);
EQ::OutBuffer ob;
@@ -902,7 +878,7 @@ namespace SoF
in->size = ob.size();
in->pBuffer = ob.detach();
delete[] __emu_buffer;
dest->FastQueuePacket(&in, ack_req);
@@ -1043,17 +1019,17 @@ namespace SoF
OUT_str(zone_short_name2);
OUT(zone_id);
OUT(zone_instance);
OUT(SuspendBuffs);
OUT(FastRegenHP);
OUT(FastRegenMana);
OUT(FastRegenEndurance);
OUT(suspend_buffs);
OUT(fast_regen_hp);
OUT(fast_regen_mana);
OUT(fast_regen_endurance);
OUT(underworld_teleport_index);
/*fill in some unknowns with observed values, hopefully it will help */
eq->unknown796 = -1;
eq->unknown840 = 600;
OUT(LavaDamage);
OUT(MinLavaDamage);
OUT(lava_damage);
OUT(min_lava_damage);
eq->unknown884 = 1;
eq->unknown885 = 0;
eq->unknown886 = 1;
@@ -2936,7 +2912,7 @@ namespace SoF
void SerializeItem(EQ::OutBuffer& ob, const EQ::ItemInstance *inst, int16 slot_id_in, uint8 depth)
{
const EQ::ItemData *item = inst->GetUnscaledItem();
SoF::structs::ItemSerializationHeader hdr;
hdr.stacksize = (inst->IsStackable() ? ((inst->GetCharges() > 254) ? 0xFFFFFFFF : inst->GetCharges()) : 1);
@@ -3245,7 +3221,7 @@ namespace SoF
iqbs.HeroicSVCorrup = item->HeroicSVCorrup;
iqbs.HealAmt = item->HealAmt;
iqbs.SpellDmg = item->SpellDmg;
ob.write((const char*)&iqbs, sizeof(SoF::structs::ItemQuaternaryBodyStruct));
EQ::OutBuffer::pos_type count_pos = ob.tellp();
@@ -3354,7 +3330,7 @@ namespace SoF
static inline uint32 ServerToSoFCorpseSlot(uint32 server_corpse_slot)
{
uint32 SoFSlot = invslot::SLOT_INVALID;
if (server_corpse_slot <= EQ::invslot::slotGeneral8 && server_corpse_slot >= EQ::invslot::slotGeneral1) {
SoFSlot = server_corpse_slot;
}
@@ -3465,7 +3441,7 @@ namespace SoF
return;
}
auto segments = SplitString(server_saylink, '\x12');
auto segments = Strings::Split(server_saylink, '\x12');
for (size_t segment_iter = 0; segment_iter < segments.size(); ++segment_iter) {
if (segment_iter & 1) {
@@ -3505,7 +3481,7 @@ namespace SoF
return;
}
auto segments = SplitString(sof_saylink, '\x12');
auto segments = Strings::Split(sof_saylink, '\x12');
for (size_t segment_iter = 0; segment_iter < segments.size(); ++segment_iter) {
if (segment_iter & 1) {
+2 -2
View File
@@ -1,5 +1,5 @@
/* EQEMu: Everquest Server Emulator
Copyright (C) 2001-2016 EQEMu Development Team (http://eqemulator.net)
This program is free software; you can redistribute it and/or modify
@@ -19,7 +19,7 @@
#include "sof_limits.h"
#include "../string_util.h"
#include "../strings.h"
int16 SoF::invtype::GetInvTypeSize(int16 inv_type)
-1
View File
@@ -37,7 +37,6 @@ E(OP_DeleteCharge)
E(OP_DeleteItem)
E(OP_DeleteSpawn)
E(OP_DzChooseZone)
E(OP_DzCompass)
E(OP_DzExpeditionEndsWarning)
E(OP_DzExpeditionInfo)
E(OP_DzExpeditionInvite)
+27 -27
View File
@@ -1,5 +1,5 @@
/* EQEMu: Everquest Server Emulator
Copyright (C) 2001-2016 EQEMu Development Team (http://eqemulator.net)
This program is free software; you can redistribute it and/or modify
@@ -444,31 +444,31 @@ struct NewZone_Struct {
/*0700*/ char zone_short_name2[96]; //zone file name? excludes instance number which can be in previous version.
/*0796*/ int32 unknown796; //seen -1
/*0800*/ char unknown800[40]; //
/*0840*/ int32 unknown840; //seen 600
/*0844*/ int32 unknown844;
/*0848*/ uint16 zone_id;
/*0850*/ uint16 zone_instance;
/*0852*/ uint32 scriptNPCReceivedanItem;
/*0856*/ uint32 bCheck; // padded bool
/*0860*/ uint32 scriptIDSomething;
/*0864*/ uint32 underworld_teleport_index; // > 0 teleports w/ zone point index, invalid succors, -1 affects some collisions
/*0868*/ uint32 scriptIDSomething3;
/*0872*/ uint32 SuspendBuffs;
/*0876*/ uint32 LavaDamage; //seen 50
/*0880*/ uint32 MinLavaDamage; //seen 10
/*0884*/ uint8 unknown884; //seen 1
/*0885*/ uint8 unknown885; //seen 0 (POK) or 1 (rujj)
/*0886*/ uint8 unknown886; //seen 1
/*0887*/ uint8 unknown887; //seen 0
/*0888*/ uint8 unknown888; //seen 0
/*0893*/ uint8 unknown889; //seen 0 - 00
/*0894*/ uint8 fall_damage; // 0 = Fall Damage on, 1 = Fall Damage off
/*0895*/ uint8 unknown891; //seen 0 - 00
/*0892*/ uint32 FastRegenHP; //seen 180
/*0896*/ uint32 FastRegenMana; //seen 180
/*0900*/ uint32 FastRegenEndurance; //seen 180
/*0904*/ uint32 unknown904; //seen 2
/*0908*/ uint32 unknown908; //seen 2
/*0840*/ int32 unknown840; //seen 600
/*0844*/ int32 unknown844;
/*0848*/ uint16 zone_id;
/*0850*/ uint16 zone_instance;
/*0852*/ uint32 scriptNPCReceivedanItem;
/*0856*/ uint32 bCheck; // padded bool
/*0860*/ uint32 scriptIDSomething;
/*0864*/ uint32 underworld_teleport_index; // > 0 teleports w/ zone point index, invalid succors, -1 affects some collisions
/*0868*/ uint32 scriptIDSomething3;
/*0872*/ uint32 suspend_buffs;
/*0876*/ uint32 lava_damage; //seen 50
/*0880*/ uint32 min_lava_damage; //seen 10
/*0884*/ uint8 unknown884; //seen 1
/*0885*/ uint8 unknown885; //seen 0 (POK) or 1 (rujj)
/*0886*/ uint8 unknown886; //seen 1
/*0887*/ uint8 unknown887; //seen 0
/*0888*/ uint8 unknown888; //seen 0
/*0893*/ uint8 unknown889; //seen 0 - 00
/*0894*/ uint8 fall_damage; // 0 = Fall Damage on, 1 = Fall Damage off
/*0895*/ uint8 unknown891; //seen 0 - 00
/*0892*/ uint32 fast_regen_hp; //seen 180
/*0896*/ uint32 fast_regen_mana; //seen 180
/*0900*/ uint32 fast_regen_endurance; //seen 180
/*0904*/ uint32 unknown904; //seen 2
/*0908*/ uint32 unknown908; //seen 2
/*0912*/
};
@@ -4186,7 +4186,7 @@ struct DynamicZoneCompassEntry_Struct
/*000*/ uint16 dz_zone_id; // target dz id pair
/*002*/ uint16 dz_instance_id;
/*004*/ uint32 dz_type; // 1: Expedition, 2: Tutorial (purple), 3: Task, 4: Mission, 5: Quest (green)
/*008*/ uint32 unknown008;
/*008*/ uint32 dz_switch_id;
/*012*/ float y;
/*016*/ float x;
/*020*/ float z;
+8 -32
View File
@@ -1,5 +1,5 @@
/* EQEMu: Everquest Server Emulator
Copyright (C) 2001-2016 EQEMu Development Team (http://eqemulator.net)
This program is free software; you can redistribute it and/or modify
@@ -29,7 +29,7 @@
#include "../eq_packet_structs.h"
#include "../misc_functions.h"
#include "../string_util.h"
#include "../strings.h"
#include "../item_instance.h"
#include "titanium_structs.h"
@@ -338,13 +338,13 @@ namespace Titanium
SerializeItem(ob, (const EQ::ItemInstance*)eq->inst, ServerToTitaniumSlot(eq->slot_id), 0);
if (ob.tellp() == last_pos)
LogNetcode("Titanium::ENCODE(OP_CharInventory) Serialization failed on item slot [{}] during OP_CharInventory. Item skipped", eq->slot_id);
last_pos = ob.tellp();
}
in->size = ob.size();
in->pBuffer = ob.detach();
delete[] __emu_buffer;
dest->FastQueuePacket(&in, ack_req);
@@ -440,30 +440,6 @@ namespace Titanium
FINISH_ENCODE();
}
ENCODE(OP_DzCompass)
{
SETUP_VAR_ENCODE(DynamicZoneCompass_Struct);
ALLOC_VAR_ENCODE(structs::DynamicZoneCompass_Struct,
sizeof(structs::DynamicZoneCompass_Struct) +
sizeof(structs::DynamicZoneCompassEntry_Struct) * emu->count
);
OUT(client_id);
OUT(count);
for (uint32 i = 0; i < emu->count; ++i)
{
OUT(entries[i].dz_zone_id);
OUT(entries[i].dz_instance_id);
OUT(entries[i].dz_type);
OUT(entries[i].x);
OUT(entries[i].y);
OUT(entries[i].z);
}
FINISH_ENCODE();
}
ENCODE(OP_DzExpeditionEndsWarning)
{
ENCODE_LENGTH_EXACT(ExpeditionExpireWarning);
@@ -861,7 +837,7 @@ namespace Titanium
//store away the emu struct
uchar* __emu_buffer = in->pBuffer;
EQ::InternalSerializedItem_Struct* int_struct = (EQ::InternalSerializedItem_Struct*)(&__emu_buffer[4]);
EQ::OutBuffer ob;
@@ -878,7 +854,7 @@ namespace Titanium
in->size = ob.size();
in->pBuffer = ob.detach();
delete[] __emu_buffer;
dest->FastQueuePacket(&in, ack_req);
@@ -2845,7 +2821,7 @@ namespace Titanium
return;
}
auto segments = SplitString(server_saylink, '\x12');
auto segments = Strings::Split(server_saylink, '\x12');
for (size_t segment_iter = 0; segment_iter < segments.size(); ++segment_iter) {
if (segment_iter & 1) {
@@ -2885,7 +2861,7 @@ namespace Titanium
return;
}
auto segments = SplitString(titanium_saylink, '\x12');
auto segments = Strings::Split(titanium_saylink, '\x12');
for (size_t segment_iter = 0; segment_iter < segments.size(); ++segment_iter) {
if (segment_iter & 1) {
+2 -2
View File
@@ -1,5 +1,5 @@
/* EQEMu: Everquest Server Emulator
Copyright (C) 2001-2016 EQEMu Development Team (http://eqemulator.net)
This program is free software; you can redistribute it and/or modify
@@ -19,7 +19,7 @@
#include "titanium_limits.h"
#include "../string_util.h"
#include "../strings.h"
int16 Titanium::invtype::GetInvTypeSize(int16 inv_type)
-1
View File
@@ -33,7 +33,6 @@ E(OP_DeleteCharge)
E(OP_DeleteItem)
E(OP_DeleteSpawn)
E(OP_DzChooseZone)
E(OP_DzCompass)
E(OP_DzExpeditionEndsWarning)
E(OP_DzExpeditionInfo)
E(OP_DzExpeditionInvite)
+1 -1
View File
@@ -3396,7 +3396,7 @@ struct DynamicZoneCompassEntry_Struct
/*000*/ uint16 dz_zone_id; // target dz id pair
/*002*/ uint16 dz_instance_id;
/*004*/ uint32 dz_type; // 1: Expedition, 2: Tutorial (purple), 3: Task, 4: Mission, 5: Quest (green)
/*008*/ uint32 unknown008;
/*008*/ uint32 dz_switch_id;
/*012*/ float y;
/*016*/ float x;
/*020*/ float z;
+16 -40
View File
@@ -1,5 +1,5 @@
/* EQEMu: Everquest Server Emulator
Copyright (C) 2001-2016 EQEMu Development Team (http://eqemulator.net)
This program is free software; you can redistribute it and/or modify
@@ -28,7 +28,7 @@
#include "../eq_packet_structs.h"
#include "../misc_functions.h"
#include "../string_util.h"
#include "../strings.h"
#include "../item_instance.h"
#include "uf_structs.h"
#include "../rulesys.h"
@@ -527,7 +527,7 @@ namespace UF
in->size = ob.size();
in->pBuffer = ob.detach();
delete[] __emu_buffer;
dest->FastQueuePacket(&in, ack_req);
@@ -639,30 +639,6 @@ namespace UF
FINISH_ENCODE();
}
ENCODE(OP_DzCompass)
{
SETUP_VAR_ENCODE(DynamicZoneCompass_Struct);
ALLOC_VAR_ENCODE(structs::DynamicZoneCompass_Struct,
sizeof(structs::DynamicZoneCompass_Struct) +
sizeof(structs::DynamicZoneCompassEntry_Struct) * emu->count
);
OUT(client_id);
OUT(count);
for (uint32 i = 0; i < emu->count; ++i)
{
OUT(entries[i].dz_zone_id);
OUT(entries[i].dz_instance_id);
OUT(entries[i].dz_type);
OUT(entries[i].x);
OUT(entries[i].y);
OUT(entries[i].z);
}
FINISH_ENCODE();
}
ENCODE(OP_DzExpeditionEndsWarning)
{
ENCODE_LENGTH_EXACT(ExpeditionExpireWarning);
@@ -1314,7 +1290,7 @@ namespace UF
in->size = ob.size();
in->pBuffer = ob.detach();
delete[] __emu_buffer;
dest->FastQueuePacket(&in, ack_req);
@@ -1589,19 +1565,19 @@ namespace UF
OUT_str(zone_short_name2);
OUT(zone_id);
OUT(zone_instance);
OUT(SuspendBuffs);
OUT(FastRegenHP);
OUT(FastRegenMana);
OUT(FastRegenEndurance);
OUT(suspend_buffs);
OUT(fast_regen_hp);
OUT(fast_regen_mana);
OUT(fast_regen_endurance);
OUT(underworld_teleport_index);
eq->FogDensity = emu->fog_density;
eq->fog_density = emu->fog_density;
/*fill in some unknowns with observed values, hopefully it will help */
eq->unknown800 = -1;
eq->unknown844 = 600;
OUT(LavaDamage);
OUT(MinLavaDamage);
OUT(lava_damage);
OUT(min_lava_damage);
eq->unknown888 = 1;
eq->unknown889 = 0;
eq->unknown890 = 1;
@@ -1741,7 +1717,7 @@ namespace UF
OUT(WIS);
OUT(face);
// OUT(unknown02264[47]);
if (spells::SPELLBOOK_SIZE <= EQ::spells::SPELLBOOK_SIZE) {
for (uint32 r = 0; r < spells::SPELLBOOK_SIZE; r++) {
if (emu->spell_book[r] <= spells::SPELL_ID_MAX)
@@ -2122,7 +2098,7 @@ namespace UF
eq->aa_expansion = emu->expansion;
eq->special_category = emu->category;
eq->total_abilities = emu->total_effects;
for(auto i = 0; i < eq->total_abilities; ++i) {
eq->abilities[i].skill_id = inapp->ReadUInt32();
eq->abilities[i].base_value = inapp->ReadUInt32();
@@ -3835,7 +3811,7 @@ namespace UF
void SerializeItem(EQ::OutBuffer& ob, const EQ::ItemInstance *inst, int16 slot_id_in, uint8 depth)
{
const EQ::ItemData *item = inst->GetUnscaledItem();
UF::structs::ItemSerializationHeader hdr;
hdr.stacksize = (inst->IsStackable() ? ((inst->GetCharges() > 1000) ? 0xFFFFFFFF : inst->GetCharges()) : 1);
@@ -4420,7 +4396,7 @@ namespace UF
return;
}
auto segments = SplitString(serverSayLink, '\x12');
auto segments = Strings::Split(serverSayLink, '\x12');
for (size_t segment_iter = 0; segment_iter < segments.size(); ++segment_iter) {
if (segment_iter & 1) {
@@ -4460,7 +4436,7 @@ namespace UF
return;
}
auto segments = SplitString(ufSayLink, '\x12');
auto segments = Strings::Split(ufSayLink, '\x12');
for (size_t segment_iter = 0; segment_iter < segments.size(); ++segment_iter) {
if (segment_iter & 1) {
+2 -2
View File
@@ -1,5 +1,5 @@
/* EQEMu: Everquest Server Emulator
Copyright (C) 2001-2016 EQEMu Development Team (http://eqemulator.net)
This program is free software; you can redistribute it and/or modify
@@ -19,7 +19,7 @@
#include "uf_limits.h"
#include "../string_util.h"
#include "../strings.h"
int16 UF::invtype::GetInvTypeSize(int16 inv_type)
-1
View File
@@ -39,7 +39,6 @@ E(OP_DeleteCharge)
E(OP_DeleteItem)
E(OP_DisciplineUpdate)
E(OP_DzChooseZone)
E(OP_DzCompass)
E(OP_DzExpeditionEndsWarning)
E(OP_DzExpeditionInfo)
E(OP_DzExpeditionInvite)
+32 -32
View File
@@ -1,5 +1,5 @@
/* EQEMu: Everquest Server Emulator
Copyright (C) 2001-2016 EQEMu Development Team (http://eqemulator.net)
This program is free software; you can redistribute it and/or modify
@@ -440,35 +440,35 @@ struct NewZone_Struct {
/*0704*/ char zone_short_name2[96]; //zone file name? excludes instance number which can be in previous version.
/*0800*/ int32 unknown800; //seen -1
/*0804*/ char unknown804[40]; //
/*0844*/ int32 unknown844; //seen 600
/*0848*/ int32 unknown848;
/*0852*/ uint16 zone_id;
/*0854*/ uint16 zone_instance;
/*0856*/ uint32 scriptNPCReceivedanItem;
/*0860*/ uint32 bCheck; // padded bool
/*0864*/ uint32 scriptIDSomething;
/*0868*/ uint32 underworld_teleport_index; // > 0 teleports w/ zone point index, invalid succors, -1 affects some collisions
/*0872*/ uint32 scriptIDSomething3;
/*0876*/ uint32 SuspendBuffs;
/*0880*/ uint32 LavaDamage; //seen 50
/*0884*/ uint32 MinLavaDamage; //seen 10
/*0888*/ uint8 unknown888; //seen 1
/*0889*/ uint8 unknown889; //seen 0 (POK) or 1 (rujj)
/*0890*/ uint8 unknown890; //seen 1
/*0891*/ uint8 unknown891; //seen 0
/*0892*/ uint8 unknown892; //seen 0
/*0893*/ uint8 unknown893; //seen 0 - 00
/*0894*/ uint8 fall_damage; // 0 = Fall Damage on, 1 = Fall Damage off
/*0895*/ uint8 unknown895; //seen 0 - 00
/*0896*/ uint32 FastRegenHP; //seen 180
/*0900*/ uint32 FastRegenMana; //seen 180
/*0904*/ uint32 FastRegenEndurance; //seen 180
/*0908*/ uint32 unknown908; //seen 2
/*0912*/ uint32 unknown912; //seen 2
/*0916*/ float FogDensity; //Of about 10 or so zones tested, all but one have this set to 0.33 Blightfire had 0.16
/*0920*/ uint32 unknown920; //seen 0
/*0924*/ uint32 unknown924; //seen 0
/*0928*/ uint32 unknown928; //seen 0
/*0844*/ int32 unknown844; //seen 600
/*0848*/ int32 unknown848;
/*0852*/ uint16 zone_id;
/*0854*/ uint16 zone_instance;
/*0856*/ uint32 scriptNPCReceivedanItem;
/*0860*/ uint32 bCheck; // padded bool
/*0864*/ uint32 scriptIDSomething;
/*0868*/ uint32 underworld_teleport_index; // > 0 teleports w/ zone point index, invalid succors, -1 affects some collisions
/*0872*/ uint32 scriptIDSomething3;
/*0876*/ uint32 suspend_buffs;
/*0880*/ uint32 lava_damage; //seen 50
/*0884*/ uint32 min_lava_damage; //seen 10
/*0888*/ uint8 unknown888; //seen 1
/*0889*/ uint8 unknown889; //seen 0 (POK) or 1 (rujj)
/*0890*/ uint8 unknown890; //seen 1
/*0891*/ uint8 unknown891; //seen 0
/*0892*/ uint8 unknown892; //seen 0
/*0893*/ uint8 unknown893; //seen 0 - 00
/*0894*/ uint8 fall_damage; // 0 = Fall Damage on, 1 = Fall Damage off
/*0895*/ uint8 unknown895; //seen 0 - 00
/*0896*/ uint32 fast_regen_hp; //seen 180
/*0900*/ uint32 fast_regen_mana; //seen 180
/*0904*/ uint32 fast_regen_endurance; //seen 180
/*0908*/ uint32 unknown908; //seen 2
/*0912*/ uint32 unknown912; //seen 2
/*0916*/ float fog_density; //Of about 10 or so zones tested, all but one have this set to 0.33 Blightfire had 0.16
/*0920*/ uint32 unknown920; //seen 0
/*0924*/ uint32 unknown924; //seen 0
/*0928*/ uint32 unknown928; //seen 0
/*0932*/ uint8 unknown932[12];
};
@@ -3997,7 +3997,7 @@ struct ItemSerializationHeaderFinish
{
uint16 ornamentIcon;
/*060*/ uint8 unknown060; //0
/*061*/ uint8 unknown061; //0 -
/*061*/ uint8 unknown061; //0 -
/*062*/ uint8 isCopied; // New to Underfoot // Copied flag on item
/*063*/ uint8 ItemClass; //0, 1, or 2
};
@@ -4357,7 +4357,7 @@ struct DynamicZoneCompassEntry_Struct
/*000*/ uint16 dz_zone_id; // target dz id pair
/*002*/ uint16 dz_instance_id;
/*004*/ uint32 dz_type; // 1: Expedition, 2: Tutorial (purple), 3: Task, 4: Mission, 5: Quest (green)
/*008*/ uint32 unknown008;
/*008*/ uint32 dz_switch_id;
/*012*/ float y;
/*016*/ float x;
/*020*/ float z;
+12 -12
View File
@@ -1,5 +1,5 @@
/* EQEMu: Everquest Server Emulator
Copyright (C) 2001-2019 EQEMu Development Team (http://eqemulator.net)
This program is free software; you can redistribute it and/or modify
@@ -11,7 +11,7 @@
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
@@ -19,7 +19,7 @@
#include "profanity_manager.h"
#include "dbcore.h"
#include "string_util.h"
#include "strings.h"
#include <ctype.h>
#include <cstring>
@@ -66,7 +66,7 @@ bool EQ::ProfanityManager::AddProfanity(DBcore *db, std::string profanity) {
return false;
}
std::string entry = str_tolower(profanity);
std::string entry = Strings::ToLower(profanity);
if (check_for_existing_entry(entry)) {
return true;
@@ -98,7 +98,7 @@ bool EQ::ProfanityManager::RemoveProfanity(DBcore *db, std::string profanity) {
return false;
}
std::string entry = str_tolower(profanity);
std::string entry = Strings::ToLower(profanity);
if (!check_for_existing_entry(entry)) {
return true;
@@ -126,13 +126,13 @@ void EQ::ProfanityManager::RedactMessage(char *message) {
return;
}
std::string test_message = str_tolower(message);
std::string test_message = Strings::ToLower(message);
// hard-coded max length based on channel message buffer size (4096 bytes)..
// ..will need to change or remove if other sources are used for redaction
if (test_message.length() < REDACTION_LENGTH_MIN || test_message.length() >= 4096) {
return;
}
for (const auto &iter : profanity_list) { // consider adding textlink checks if it becomes an issue
size_t pos = 0;
size_t start_pos = 0;
@@ -162,7 +162,7 @@ void EQ::ProfanityManager::RedactMessage(std::string &message) {
return;
}
std::string test_message = str_tolower(message);
std::string test_message = Strings::ToLower(message);
for (const auto &iter : profanity_list) {
size_t pos = 0;
@@ -194,7 +194,7 @@ bool EQ::ProfanityManager::ContainsCensoredLanguage(const std::string &message)
return false;
}
std::string test_message = str_tolower(message);
std::string test_message = Strings::ToLower(message);
for (const auto &iter : profanity_list) {
if (test_message.find(iter) != std::string::npos) {
@@ -227,8 +227,8 @@ bool EQ::ProfanityManager::load_database_entries(DBcore *db) {
}
for (auto row : results) {
std::string entry = str_tolower(row[0]);
if (entry.length() >= REDACTION_LENGTH_MIN) {
std::string entry = Strings::ToLower(row[0]);
if (entry.length() >= REDACTION_LENGTH_MIN) {
if (!check_for_existing_entry(entry)) {
profanity_list.push_back(entry);
}
@@ -265,6 +265,6 @@ bool EQ::ProfanityManager::check_for_existing_entry(std::string profanity) {
return true;
}
}
return false;
}
+1 -1
View File
@@ -21,7 +21,7 @@
#include "timer.h"
#include "ptimer.h"
#include "database.h"
#include "string_util.h"
#include "strings.h"
#ifdef _WINDOWS
#include <winsock2.h>
+1 -21
View File
@@ -1,28 +1,8 @@
/**
* 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
#include "../database.h"
#include "../string_util.h"
#include "../strings.h"
#include "base/base_aa_ability_repository.h"
class AaAbilityRepository: public BaseAaAbilityRepository {
@@ -1,28 +1,8 @@
/**
* 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
#include "../database.h"
#include "../string_util.h"
#include "../strings.h"
#include "base/base_aa_rank_effects_repository.h"
class AaRankEffectsRepository: public BaseAaRankEffectsRepository {
@@ -1,28 +1,8 @@
/**
* 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
#include "../database.h"
#include "../string_util.h"
#include "../strings.h"
#include "base/base_aa_rank_prereqs_repository.h"
class AaRankPrereqsRepository: public BaseAaRankPrereqsRepository {
+1 -21
View File
@@ -1,28 +1,8 @@
/**
* 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
#include "../database.h"
#include "../string_util.h"
#include "../strings.h"
#include "base/base_aa_ranks_repository.h"
class AaRanksRepository: public BaseAaRanksRepository {
+1 -21
View File
@@ -1,28 +1,8 @@
/**
* 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
#include "../database.h"
#include "../string_util.h"
#include "../strings.h"
#include "base/base_account_flags_repository.h"
class AccountFlagsRepository: public BaseAccountFlagsRepository {
+1 -21
View File
@@ -1,28 +1,8 @@
/**
* 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
#include "../database.h"
#include "../string_util.h"
#include "../strings.h"
#include "base/base_account_ip_repository.h"
class AccountIpRepository: public BaseAccountIpRepository {
+1 -21
View File
@@ -1,28 +1,8 @@
/**
* 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
#include "../database.h"
#include "../string_util.h"
#include "../strings.h"
#include "base/base_account_repository.h"
class AccountRepository: public BaseAccountRepository {
@@ -1,28 +1,8 @@
/**
* 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
#include "../database.h"
#include "../string_util.h"
#include "../strings.h"
#include "base/base_account_rewards_repository.h"
class AccountRewardsRepository: public BaseAccountRewardsRepository {
@@ -1,28 +1,8 @@
/**
* 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
#include "../database.h"
#include "../string_util.h"
#include "../strings.h"
#include "base/base_adventure_details_repository.h"
class AdventureDetailsRepository: public BaseAdventureDetailsRepository {
@@ -1,28 +1,8 @@
/**
* 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
#include "../database.h"
#include "../string_util.h"
#include "../strings.h"
#include "base/base_adventure_members_repository.h"
class AdventureMembersRepository: public BaseAdventureMembersRepository {
@@ -1,28 +1,8 @@
/**
* 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
#include "../database.h"
#include "../string_util.h"
#include "../strings.h"
#include "base/base_adventure_stats_repository.h"
class AdventureStatsRepository: public BaseAdventureStatsRepository {
@@ -1,28 +1,8 @@
/**
* 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
#include "../database.h"
#include "../string_util.h"
#include "../strings.h"
#include "base/base_adventure_template_entry_flavor_repository.h"
class AdventureTemplateEntryFlavorRepository: public BaseAdventureTemplateEntryFlavorRepository {
@@ -1,28 +1,8 @@
/**
* 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
#include "../database.h"
#include "../string_util.h"
#include "../strings.h"
#include "base/base_adventure_template_entry_repository.h"
class AdventureTemplateEntryRepository: public BaseAdventureTemplateEntryRepository {
@@ -1,28 +1,8 @@
/**
* 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
#include "../database.h"
#include "../string_util.h"
#include "../strings.h"
#include "base/base_adventure_template_repository.h"
class AdventureTemplateRepository: public BaseAdventureTemplateRepository {
@@ -1,28 +1,8 @@
/**
* 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
#include "../database.h"
#include "../string_util.h"
#include "../strings.h"
#include "base/base_alternate_currency_repository.h"
class AlternateCurrencyRepository: public BaseAlternateCurrencyRepository {
+1 -21
View File
@@ -1,28 +1,8 @@
/**
* 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
#include "../database.h"
#include "../string_util.h"
#include "../strings.h"
#include "base/base_auras_repository.h"
class AurasRepository: public BaseAurasRepository {
@@ -13,26 +13,26 @@
#define EQEMU_BASE_AA_ABILITY_REPOSITORY_H
#include "../../database.h"
#include "../../string_util.h"
#include "../../strings.h"
#include <ctime>
class BaseAaAbilityRepository {
public:
struct AaAbility {
int id;
uint32_t id;
std::string name;
int category;
int classes;
int races;
int drakkin_heritage;
int deities;
int status;
int type;
int charges;
int grant_only;
int first_rank_id;
int enabled;
int reset_on_death;
int32_t category;
int32_t classes;
int32_t races;
int32_t drakkin_heritage;
int32_t deities;
int32_t status;
int32_t type;
int32_t charges;
int8_t grant_only;
int32_t first_rank_id;
uint8_t enabled;
int8_t reset_on_death;
};
static std::string PrimaryKey()
@@ -82,12 +82,12 @@ public:
static std::string ColumnsRaw()
{
return std::string(implode(", ", Columns()));
return std::string(Strings::Implode(", ", Columns()));
}
static std::string SelectColumnsRaw()
{
return std::string(implode(", ", SelectColumns()));
return std::string(Strings::Implode(", ", SelectColumns()));
}
static std::string TableName()
@@ -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<AaAbility> &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 = static_cast<uint32_t>(strtoul(row[0], nullptr, 10));
e.name = row[1] ? row[1] : "";
e.category = static_cast<int32_t>(atoi(row[2]));
e.classes = static_cast<int32_t>(atoi(row[3]));
e.races = static_cast<int32_t>(atoi(row[4]));
e.drakkin_heritage = static_cast<int32_t>(atoi(row[5]));
e.deities = static_cast<int32_t>(atoi(row[6]));
e.status = static_cast<int32_t>(atoi(row[7]));
e.type = static_cast<int32_t>(atoi(row[8]));
e.charges = static_cast<int32_t>(atoi(row[9]));
e.grant_only = static_cast<int8_t>(atoi(row[10]));
e.first_rank_id = static_cast<int32_t>(atoi(row[11]));
e.enabled = static_cast<uint8_t>(strtoul(row[12], nullptr, 10));
e.reset_on_death = static_cast<int8_t>(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<std::string> update_values;
std::vector<std::string> v;
auto columns = Columns();
update_values.push_back(columns[0] + " = " + std::to_string(aa_ability_entry.id));
update_values.push_back(columns[1] + " = '" + EscapeString(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(),
implode(", ", update_values),
Strings::Implode(", ", v),
PrimaryKey(),
aa_ability_entry.id
e.id
)
);
@@ -243,79 +243,79 @@ public:
static AaAbility InsertOne(
Database& db,
AaAbility aa_ability_entry
AaAbility e
)
{
std::vector<std::string> insert_values;
std::vector<std::string> v;
insert_values.push_back(std::to_string(aa_ability_entry.id));
insert_values.push_back("'" + EscapeString(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(),
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<AaAbility> aa_ability_entries
const std::vector<AaAbility> &entries
)
{
std::vector<std::string> insert_chunks;
for (auto &aa_ability_entry: aa_ability_entries) {
std::vector<std::string> insert_values;
for (auto &e: entries) {
std::vector<std::string> v;
insert_values.push_back(std::to_string(aa_ability_entry.id));
insert_values.push_back("'" + EscapeString(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("(" + implode(",", insert_values) + ")");
insert_chunks.push_back("(" + Strings::Implode(",", v) + ")");
}
std::vector<std::string> insert_values;
std::vector<std::string> v;
auto results = db.QueryDatabase(
fmt::format(
"{} VALUES {}",
BaseInsert(),
implode(",", insert_chunks)
Strings::Implode(",", insert_chunks)
)
);
@@ -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 = static_cast<uint32_t>(strtoul(row[0], nullptr, 10));
e.name = row[1] ? row[1] : "";
e.category = static_cast<int32_t>(atoi(row[2]));
e.classes = static_cast<int32_t>(atoi(row[3]));
e.races = static_cast<int32_t>(atoi(row[4]));
e.drakkin_heritage = static_cast<int32_t>(atoi(row[5]));
e.deities = static_cast<int32_t>(atoi(row[6]));
e.status = static_cast<int32_t>(atoi(row[7]));
e.type = static_cast<int32_t>(atoi(row[8]));
e.charges = static_cast<int32_t>(atoi(row[9]));
e.grant_only = static_cast<int8_t>(atoi(row[10]));
e.first_rank_id = static_cast<int32_t>(atoi(row[11]));
e.enabled = static_cast<uint8_t>(strtoul(row[12], nullptr, 10));
e.reset_on_death = static_cast<int8_t>(atoi(row[13]));
all_entries.push_back(entry);
all_entries.push_back(e);
}
return all_entries;
}
static std::vector<AaAbility> GetWhere(Database& db, std::string where_filter)
static std::vector<AaAbility> GetWhere(Database& db, const std::string &where_filter)
{
std::vector<AaAbility> 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 = static_cast<uint32_t>(strtoul(row[0], nullptr, 10));
e.name = row[1] ? row[1] : "";
e.category = static_cast<int32_t>(atoi(row[2]));
e.classes = static_cast<int32_t>(atoi(row[3]));
e.races = static_cast<int32_t>(atoi(row[4]));
e.drakkin_heritage = static_cast<int32_t>(atoi(row[5]));
e.deities = static_cast<int32_t>(atoi(row[6]));
e.status = static_cast<int32_t>(atoi(row[7]));
e.type = static_cast<int32_t>(atoi(row[8]));
e.charges = static_cast<int32_t>(atoi(row[9]));
e.grant_only = static_cast<int8_t>(atoi(row[10]));
e.first_rank_id = static_cast<int32_t>(atoi(row[11]));
e.enabled = static_cast<uint8_t>(strtoul(row[12], nullptr, 10));
e.reset_on_death = static_cast<int8_t>(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
@@ -13,17 +13,17 @@
#define EQEMU_BASE_AA_RANK_EFFECTS_REPOSITORY_H
#include "../../database.h"
#include "../../string_util.h"
#include "../../strings.h"
#include <ctime>
class BaseAaRankEffectsRepository {
public:
struct AaRankEffects {
int rank_id;
int slot;
int effect_id;
int base1;
int base2;
uint32_t rank_id;
uint32_t slot;
int32_t effect_id;
int32_t base1;
int32_t base2;
};
static std::string PrimaryKey()
@@ -55,12 +55,12 @@ public:
static std::string ColumnsRaw()
{
return std::string(implode(", ", Columns()));
return std::string(Strings::Implode(", ", Columns()));
}
static std::string SelectColumnsRaw()
{
return std::string(implode(", ", SelectColumns()));
return std::string(Strings::Implode(", ", SelectColumns()));
}
static std::string TableName()
@@ -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<AaRankEffects> &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 = static_cast<uint32_t>(strtoul(row[0], nullptr, 10));
e.slot = static_cast<uint32_t>(strtoul(row[1], nullptr, 10));
e.effect_id = static_cast<int32_t>(atoi(row[2]));
e.base1 = static_cast<int32_t>(atoi(row[3]));
e.base2 = static_cast<int32_t>(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<std::string> update_values;
std::vector<std::string> 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(),
implode(", ", update_values),
Strings::Implode(", ", v),
PrimaryKey(),
aa_rank_effects_entry.rank_id
e.rank_id
)
);
@@ -189,61 +189,61 @@ public:
static AaRankEffects InsertOne(
Database& db,
AaRankEffects aa_rank_effects_entry
AaRankEffects e
)
{
std::vector<std::string> insert_values;
std::vector<std::string> 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(),
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<AaRankEffects> aa_rank_effects_entries
const std::vector<AaRankEffects> &entries
)
{
std::vector<std::string> insert_chunks;
for (auto &aa_rank_effects_entry: aa_rank_effects_entries) {
std::vector<std::string> insert_values;
for (auto &e: entries) {
std::vector<std::string> 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("(" + implode(",", insert_values) + ")");
insert_chunks.push_back("(" + Strings::Implode(",", v) + ")");
}
std::vector<std::string> insert_values;
std::vector<std::string> v;
auto results = db.QueryDatabase(
fmt::format(
"{} VALUES {}",
BaseInsert(),
implode(",", insert_chunks)
Strings::Implode(",", insert_chunks)
)
);
@@ -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 = static_cast<uint32_t>(strtoul(row[0], nullptr, 10));
e.slot = static_cast<uint32_t>(strtoul(row[1], nullptr, 10));
e.effect_id = static_cast<int32_t>(atoi(row[2]));
e.base1 = static_cast<int32_t>(atoi(row[3]));
e.base2 = static_cast<int32_t>(atoi(row[4]));
all_entries.push_back(entry);
all_entries.push_back(e);
}
return all_entries;
}
static std::vector<AaRankEffects> GetWhere(Database& db, std::string where_filter)
static std::vector<AaRankEffects> GetWhere(Database& db, const std::string &where_filter)
{
std::vector<AaRankEffects> 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 = static_cast<uint32_t>(strtoul(row[0], nullptr, 10));
e.slot = static_cast<uint32_t>(strtoul(row[1], nullptr, 10));
e.effect_id = static_cast<int32_t>(atoi(row[2]));
e.base1 = static_cast<int32_t>(atoi(row[3]));
e.base2 = static_cast<int32_t>(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
@@ -13,15 +13,15 @@
#define EQEMU_BASE_AA_RANK_PREREQS_REPOSITORY_H
#include "../../database.h"
#include "../../string_util.h"
#include "../../strings.h"
#include <ctime>
class BaseAaRankPrereqsRepository {
public:
struct AaRankPrereqs {
int rank_id;
int aa_id;
int points;
uint32_t rank_id;
int32_t aa_id;
int32_t points;
};
static std::string PrimaryKey()
@@ -49,12 +49,12 @@ public:
static std::string ColumnsRaw()
{
return std::string(implode(", ", Columns()));
return std::string(Strings::Implode(", ", Columns()));
}
static std::string SelectColumnsRaw()
{
return std::string(implode(", ", SelectColumns()));
return std::string(Strings::Implode(", ", SelectColumns()));
}
static std::string TableName()
@@ -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<AaRankPrereqs> &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 = static_cast<uint32_t>(strtoul(row[0], nullptr, 10));
e.aa_id = static_cast<int32_t>(atoi(row[1]));
e.points = static_cast<int32_t>(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<std::string> update_values;
std::vector<std::string> 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(),
implode(", ", update_values),
Strings::Implode(", ", v),
PrimaryKey(),
aa_rank_prereqs_entry.rank_id
e.rank_id
)
);
@@ -177,57 +177,57 @@ public:
static AaRankPrereqs InsertOne(
Database& db,
AaRankPrereqs aa_rank_prereqs_entry
AaRankPrereqs e
)
{
std::vector<std::string> insert_values;
std::vector<std::string> 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(),
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<AaRankPrereqs> aa_rank_prereqs_entries
const std::vector<AaRankPrereqs> &entries
)
{
std::vector<std::string> insert_chunks;
for (auto &aa_rank_prereqs_entry: aa_rank_prereqs_entries) {
std::vector<std::string> insert_values;
for (auto &e: entries) {
std::vector<std::string> 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("(" + implode(",", insert_values) + ")");
insert_chunks.push_back("(" + Strings::Implode(",", v) + ")");
}
std::vector<std::string> insert_values;
std::vector<std::string> v;
auto results = db.QueryDatabase(
fmt::format(
"{} VALUES {}",
BaseInsert(),
implode(",", insert_chunks)
Strings::Implode(",", insert_chunks)
)
);
@@ -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 = static_cast<uint32_t>(strtoul(row[0], nullptr, 10));
e.aa_id = static_cast<int32_t>(atoi(row[1]));
e.points = static_cast<int32_t>(atoi(row[2]));
all_entries.push_back(entry);
all_entries.push_back(e);
}
return all_entries;
}
static std::vector<AaRankPrereqs> GetWhere(Database& db, std::string where_filter)
static std::vector<AaRankPrereqs> GetWhere(Database& db, const std::string &where_filter)
{
std::vector<AaRankPrereqs> 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 = static_cast<uint32_t>(strtoul(row[0], nullptr, 10));
e.aa_id = static_cast<int32_t>(atoi(row[1]));
e.points = static_cast<int32_t>(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
@@ -13,25 +13,25 @@
#define EQEMU_BASE_AA_RANKS_REPOSITORY_H
#include "../../database.h"
#include "../../string_util.h"
#include "../../strings.h"
#include <ctime>
class BaseAaRanksRepository {
public:
struct AaRanks {
int id;
int upper_hotkey_sid;
int lower_hotkey_sid;
int title_sid;
int desc_sid;
int cost;
int level_req;
int spell;
int spell_type;
int recast_time;
int expansion;
int prev_id;
int next_id;
uint32_t id;
int32_t upper_hotkey_sid;
int32_t lower_hotkey_sid;
int32_t title_sid;
int32_t desc_sid;
int32_t cost;
int32_t level_req;
int32_t spell;
int32_t spell_type;
int32_t recast_time;
int32_t expansion;
int32_t prev_id;
int32_t next_id;
};
static std::string PrimaryKey()
@@ -79,12 +79,12 @@ public:
static std::string ColumnsRaw()
{
return std::string(implode(", ", Columns()));
return std::string(Strings::Implode(", ", Columns()));
}
static std::string SelectColumnsRaw()
{
return std::string(implode(", ", SelectColumns()));
return std::string(Strings::Implode(", ", SelectColumns()));
}
static std::string TableName()
@@ -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<AaRanks> &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 = static_cast<uint32_t>(strtoul(row[0], nullptr, 10));
e.upper_hotkey_sid = static_cast<int32_t>(atoi(row[1]));
e.lower_hotkey_sid = static_cast<int32_t>(atoi(row[2]));
e.title_sid = static_cast<int32_t>(atoi(row[3]));
e.desc_sid = static_cast<int32_t>(atoi(row[4]));
e.cost = static_cast<int32_t>(atoi(row[5]));
e.level_req = static_cast<int32_t>(atoi(row[6]));
e.spell = static_cast<int32_t>(atoi(row[7]));
e.spell_type = static_cast<int32_t>(atoi(row[8]));
e.recast_time = static_cast<int32_t>(atoi(row[9]));
e.expansion = static_cast<int32_t>(atoi(row[10]));
e.prev_id = static_cast<int32_t>(atoi(row[11]));
e.next_id = static_cast<int32_t>(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<std::string> update_values;
std::vector<std::string> 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(),
implode(", ", update_values),
Strings::Implode(", ", v),
PrimaryKey(),
aa_ranks_entry.id
e.id
)
);
@@ -237,77 +237,77 @@ public:
static AaRanks InsertOne(
Database& db,
AaRanks aa_ranks_entry
AaRanks e
)
{
std::vector<std::string> insert_values;
std::vector<std::string> 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(),
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<AaRanks> aa_ranks_entries
const std::vector<AaRanks> &entries
)
{
std::vector<std::string> insert_chunks;
for (auto &aa_ranks_entry: aa_ranks_entries) {
std::vector<std::string> insert_values;
for (auto &e: entries) {
std::vector<std::string> 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("(" + implode(",", insert_values) + ")");
insert_chunks.push_back("(" + Strings::Implode(",", v) + ")");
}
std::vector<std::string> insert_values;
std::vector<std::string> v;
auto results = db.QueryDatabase(
fmt::format(
"{} VALUES {}",
BaseInsert(),
implode(",", insert_chunks)
Strings::Implode(",", insert_chunks)
)
);
@@ -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 = static_cast<uint32_t>(strtoul(row[0], nullptr, 10));
e.upper_hotkey_sid = static_cast<int32_t>(atoi(row[1]));
e.lower_hotkey_sid = static_cast<int32_t>(atoi(row[2]));
e.title_sid = static_cast<int32_t>(atoi(row[3]));
e.desc_sid = static_cast<int32_t>(atoi(row[4]));
e.cost = static_cast<int32_t>(atoi(row[5]));
e.level_req = static_cast<int32_t>(atoi(row[6]));
e.spell = static_cast<int32_t>(atoi(row[7]));
e.spell_type = static_cast<int32_t>(atoi(row[8]));
e.recast_time = static_cast<int32_t>(atoi(row[9]));
e.expansion = static_cast<int32_t>(atoi(row[10]));
e.prev_id = static_cast<int32_t>(atoi(row[11]));
e.next_id = static_cast<int32_t>(atoi(row[12]));
all_entries.push_back(entry);
all_entries.push_back(e);
}
return all_entries;
}
static std::vector<AaRanks> GetWhere(Database& db, std::string where_filter)
static std::vector<AaRanks> GetWhere(Database& db, const std::string &where_filter)
{
std::vector<AaRanks> 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 = static_cast<uint32_t>(strtoul(row[0], nullptr, 10));
e.upper_hotkey_sid = static_cast<int32_t>(atoi(row[1]));
e.lower_hotkey_sid = static_cast<int32_t>(atoi(row[2]));
e.title_sid = static_cast<int32_t>(atoi(row[3]));
e.desc_sid = static_cast<int32_t>(atoi(row[4]));
e.cost = static_cast<int32_t>(atoi(row[5]));
e.level_req = static_cast<int32_t>(atoi(row[6]));
e.spell = static_cast<int32_t>(atoi(row[7]));
e.spell_type = static_cast<int32_t>(atoi(row[8]));
e.recast_time = static_cast<int32_t>(atoi(row[9]));
e.expansion = static_cast<int32_t>(atoi(row[10]));
e.prev_id = static_cast<int32_t>(atoi(row[11]));
e.next_id = static_cast<int32_t>(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
@@ -13,13 +13,13 @@
#define EQEMU_BASE_ACCOUNT_FLAGS_REPOSITORY_H
#include "../../database.h"
#include "../../string_util.h"
#include "../../strings.h"
#include <ctime>
class BaseAccountFlagsRepository {
public:
struct AccountFlags {
int p_accid;
uint32_t p_accid;
std::string p_flag;
std::string p_value;
};
@@ -49,12 +49,12 @@ public:
static std::string ColumnsRaw()
{
return std::string(implode(", ", Columns()));
return std::string(Strings::Implode(", ", Columns()));
}
static std::string SelectColumnsRaw()
{
return std::string(implode(", ", SelectColumns()));
return std::string(Strings::Implode(", ", SelectColumns()));
}
static std::string TableName()
@@ -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<AccountFlags> &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 = static_cast<uint32_t>(strtoul(row[0], nullptr, 10));
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<std::string> update_values;
std::vector<std::string> v;
auto columns = Columns();
update_values.push_back(columns[0] + " = " + std::to_string(account_flags_entry.p_accid));
update_values.push_back(columns[1] + " = '" + EscapeString(account_flags_entry.p_flag) + "'");
update_values.push_back(columns[2] + " = '" + EscapeString(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(),
implode(", ", update_values),
Strings::Implode(", ", v),
PrimaryKey(),
account_flags_entry.p_accid
e.p_accid
)
);
@@ -177,57 +177,57 @@ public:
static AccountFlags InsertOne(
Database& db,
AccountFlags account_flags_entry
AccountFlags e
)
{
std::vector<std::string> insert_values;
std::vector<std::string> v;
insert_values.push_back(std::to_string(account_flags_entry.p_accid));
insert_values.push_back("'" + EscapeString(account_flags_entry.p_flag) + "'");
insert_values.push_back("'" + EscapeString(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(),
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<AccountFlags> account_flags_entries
const std::vector<AccountFlags> &entries
)
{
std::vector<std::string> insert_chunks;
for (auto &account_flags_entry: account_flags_entries) {
std::vector<std::string> insert_values;
for (auto &e: entries) {
std::vector<std::string> v;
insert_values.push_back(std::to_string(account_flags_entry.p_accid));
insert_values.push_back("'" + EscapeString(account_flags_entry.p_flag) + "'");
insert_values.push_back("'" + EscapeString(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("(" + implode(",", insert_values) + ")");
insert_chunks.push_back("(" + Strings::Implode(",", v) + ")");
}
std::vector<std::string> insert_values;
std::vector<std::string> v;
auto results = db.QueryDatabase(
fmt::format(
"{} VALUES {}",
BaseInsert(),
implode(",", insert_chunks)
Strings::Implode(",", insert_chunks)
)
);
@@ -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 = static_cast<uint32_t>(strtoul(row[0], nullptr, 10));
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<AccountFlags> GetWhere(Database& db, std::string where_filter)
static std::vector<AccountFlags> GetWhere(Database& db, const std::string &where_filter)
{
std::vector<AccountFlags> 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 = static_cast<uint32_t>(strtoul(row[0], nullptr, 10));
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
@@ -13,15 +13,15 @@
#define EQEMU_BASE_ACCOUNT_IP_REPOSITORY_H
#include "../../database.h"
#include "../../string_util.h"
#include "../../strings.h"
#include <ctime>
class BaseAccountIpRepository {
public:
struct AccountIp {
int accid;
int32_t accid;
std::string ip;
int count;
int32_t count;
std::string lastused;
};
@@ -52,12 +52,12 @@ public:
static std::string ColumnsRaw()
{
return std::string(implode(", ", Columns()));
return std::string(Strings::Implode(", ", Columns()));
}
static std::string SelectColumnsRaw()
{
return std::string(implode(", ", SelectColumns()));
return std::string(Strings::Implode(", ", SelectColumns()));
}
static std::string TableName()
@@ -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<AccountIp> &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 = static_cast<int32_t>(atoi(row[0]));
e.ip = row[1] ? row[1] : "";
e.count = static_cast<int32_t>(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<std::string> update_values;
std::vector<std::string> v;
auto columns = Columns();
update_values.push_back(columns[0] + " = " + std::to_string(account_ip_entry.accid));
update_values.push_back(columns[1] + " = '" + EscapeString(account_ip_entry.ip) + "'");
update_values.push_back(columns[2] + " = " + std::to_string(account_ip_entry.count));
update_values.push_back(columns[3] + " = '" + EscapeString(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(),
implode(", ", update_values),
Strings::Implode(", ", v),
PrimaryKey(),
account_ip_entry.accid
e.accid
)
);
@@ -183,59 +183,59 @@ public:
static AccountIp InsertOne(
Database& db,
AccountIp account_ip_entry
AccountIp e
)
{
std::vector<std::string> insert_values;
std::vector<std::string> v;
insert_values.push_back(std::to_string(account_ip_entry.accid));
insert_values.push_back("'" + EscapeString(account_ip_entry.ip) + "'");
insert_values.push_back(std::to_string(account_ip_entry.count));
insert_values.push_back("'" + EscapeString(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(),
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<AccountIp> account_ip_entries
const std::vector<AccountIp> &entries
)
{
std::vector<std::string> insert_chunks;
for (auto &account_ip_entry: account_ip_entries) {
std::vector<std::string> insert_values;
for (auto &e: entries) {
std::vector<std::string> v;
insert_values.push_back(std::to_string(account_ip_entry.accid));
insert_values.push_back("'" + EscapeString(account_ip_entry.ip) + "'");
insert_values.push_back(std::to_string(account_ip_entry.count));
insert_values.push_back("'" + EscapeString(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("(" + implode(",", insert_values) + ")");
insert_chunks.push_back("(" + Strings::Implode(",", v) + ")");
}
std::vector<std::string> insert_values;
std::vector<std::string> v;
auto results = db.QueryDatabase(
fmt::format(
"{} VALUES {}",
BaseInsert(),
implode(",", insert_chunks)
Strings::Implode(",", insert_chunks)
)
);
@@ -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 = static_cast<int32_t>(atoi(row[0]));
e.ip = row[1] ? row[1] : "";
e.count = static_cast<int32_t>(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<AccountIp> GetWhere(Database& db, std::string where_filter)
static std::vector<AccountIp> GetWhere(Database& db, const std::string &where_filter)
{
std::vector<AccountIp> 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 = static_cast<int32_t>(atoi(row[0]));
e.ip = row[1] ? row[1] : "";
e.count = static_cast<int32_t>(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
+243 -197
View File
@@ -13,29 +13,31 @@
#define EQEMU_BASE_ACCOUNT_REPOSITORY_H
#include "../../database.h"
#include "../../string_util.h"
#include "../../strings.h"
#include <ctime>
class BaseAccountRepository {
public:
struct Account {
int id;
int32_t id;
std::string name;
std::string charname;
int sharedplat;
uint32_t sharedplat;
std::string password;
int status;
int32_t status;
std::string ls_id;
int lsaccount_id;
int gmspeed;
int revoked;
int karma;
uint32_t lsaccount_id;
uint8_t gmspeed;
int8_t invulnerable;
int8_t flymode;
int8_t ignore_tells;
uint8_t revoked;
uint32_t karma;
std::string minilogin_ip;
int hideme;
int rulesflag;
int8_t hideme;
uint8_t rulesflag;
time_t suspendeduntil;
int time_creation;
int expansion;
uint32_t time_creation;
std::string ban_reason;
std::string suspend_reason;
std::string crc_eqgame;
@@ -60,6 +62,9 @@ public:
"ls_id",
"lsaccount_id",
"gmspeed",
"invulnerable",
"flymode",
"ignore_tells",
"revoked",
"karma",
"minilogin_ip",
@@ -67,7 +72,6 @@ public:
"rulesflag",
"suspendeduntil",
"time_creation",
"expansion",
"ban_reason",
"suspend_reason",
"crc_eqgame",
@@ -88,6 +92,9 @@ public:
"ls_id",
"lsaccount_id",
"gmspeed",
"invulnerable",
"flymode",
"ignore_tells",
"revoked",
"karma",
"minilogin_ip",
@@ -95,7 +102,6 @@ public:
"rulesflag",
"UNIX_TIMESTAMP(suspendeduntil)",
"time_creation",
"expansion",
"ban_reason",
"suspend_reason",
"crc_eqgame",
@@ -106,12 +112,12 @@ public:
static std::string ColumnsRaw()
{
return std::string(implode(", ", Columns()));
return std::string(Strings::Implode(", ", Columns()));
}
static std::string SelectColumnsRaw()
{
return std::string(implode(", ", SelectColumns()));
return std::string(Strings::Implode(", ", SelectColumns()));
}
static std::string TableName()
@@ -139,35 +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.revoked = 0;
entry.karma = 0;
entry.minilogin_ip = "";
entry.hideme = 0;
entry.rulesflag = 0;
entry.suspendeduntil = 0;
entry.time_creation = 0;
entry.expansion = 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<Account> &accounts,
int account_id
)
@@ -196,32 +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.revoked = atoi(row[9]);
entry.karma = atoi(row[10]);
entry.minilogin_ip = row[11] ? row[11] : "";
entry.hideme = atoi(row[12]);
entry.rulesflag = atoi(row[13]);
entry.suspendeduntil = strtoll(row[14] ? row[14] : "-1", nullptr, 10);
entry.time_creation = atoi(row[15]);
entry.expansion = atoi(row[16]);
entry.ban_reason = row[17] ? row[17] : "";
entry.suspend_reason = row[18] ? row[18] : "";
entry.crc_eqgame = row[19] ? row[19] : "";
entry.crc_skillcaps = row[20] ? row[20] : "";
entry.crc_basedata = row[21] ? row[21] : "";
e.id = static_cast<int32_t>(atoi(row[0]));
e.name = row[1] ? row[1] : "";
e.charname = row[2] ? row[2] : "";
e.sharedplat = static_cast<uint32_t>(strtoul(row[3], nullptr, 10));
e.password = row[4] ? row[4] : "";
e.status = static_cast<int32_t>(atoi(row[5]));
e.ls_id = row[6] ? row[6] : "";
e.lsaccount_id = static_cast<uint32_t>(strtoul(row[7], nullptr, 10));
e.gmspeed = static_cast<uint8_t>(strtoul(row[8], nullptr, 10));
e.invulnerable = static_cast<int8_t>(atoi(row[9]));
e.flymode = static_cast<int8_t>(atoi(row[10]));
e.ignore_tells = static_cast<int8_t>(atoi(row[11]));
e.revoked = static_cast<uint8_t>(strtoul(row[12], nullptr, 10));
e.karma = static_cast<uint32_t>(strtoul(row[13], nullptr, 10));
e.minilogin_ip = row[14] ? row[14] : "";
e.hideme = static_cast<int8_t>(atoi(row[15]));
e.rulesflag = static_cast<uint8_t>(strtoul(row[16], nullptr, 10));
e.suspendeduntil = strtoll(row[17] ? row[17] : "-1", nullptr, 10);
e.time_creation = static_cast<uint32_t>(strtoul(row[18], nullptr, 10));
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();
@@ -246,42 +256,44 @@ public:
static int UpdateOne(
Database& db,
Account account_entry
const Account &e
)
{
std::vector<std::string> update_values;
std::vector<std::string> v;
auto columns = Columns();
update_values.push_back(columns[1] + " = '" + EscapeString(account_entry.name) + "'");
update_values.push_back(columns[2] + " = '" + EscapeString(account_entry.charname) + "'");
update_values.push_back(columns[3] + " = " + std::to_string(account_entry.sharedplat));
update_values.push_back(columns[4] + " = '" + EscapeString(account_entry.password) + "'");
update_values.push_back(columns[5] + " = " + std::to_string(account_entry.status));
update_values.push_back(columns[6] + " = '" + EscapeString(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.revoked));
update_values.push_back(columns[10] + " = " + std::to_string(account_entry.karma));
update_values.push_back(columns[11] + " = '" + EscapeString(account_entry.minilogin_ip) + "'");
update_values.push_back(columns[12] + " = " + std::to_string(account_entry.hideme));
update_values.push_back(columns[13] + " = " + std::to_string(account_entry.rulesflag));
update_values.push_back(columns[14] + " = FROM_UNIXTIME(" + (account_entry.suspendeduntil > 0 ? std::to_string(account_entry.suspendeduntil) : "null") + ")");
update_values.push_back(columns[15] + " = " + std::to_string(account_entry.time_creation));
update_values.push_back(columns[16] + " = " + std::to_string(account_entry.expansion));
update_values.push_back(columns[17] + " = '" + EscapeString(account_entry.ban_reason) + "'");
update_values.push_back(columns[18] + " = '" + EscapeString(account_entry.suspend_reason) + "'");
update_values.push_back(columns[19] + " = '" + EscapeString(account_entry.crc_eqgame) + "'");
update_values.push_back(columns[20] + " = '" + EscapeString(account_entry.crc_skillcaps) + "'");
update_values.push_back(columns[21] + " = '" + EscapeString(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(),
implode(", ", update_values),
Strings::Implode(", ", v),
PrimaryKey(),
account_entry.id
e.id
)
);
@@ -290,95 +302,99 @@ public:
static Account InsertOne(
Database& db,
Account account_entry
Account e
)
{
std::vector<std::string> insert_values;
std::vector<std::string> v;
insert_values.push_back(std::to_string(account_entry.id));
insert_values.push_back("'" + EscapeString(account_entry.name) + "'");
insert_values.push_back("'" + EscapeString(account_entry.charname) + "'");
insert_values.push_back(std::to_string(account_entry.sharedplat));
insert_values.push_back("'" + EscapeString(account_entry.password) + "'");
insert_values.push_back(std::to_string(account_entry.status));
insert_values.push_back("'" + EscapeString(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.revoked));
insert_values.push_back(std::to_string(account_entry.karma));
insert_values.push_back("'" + EscapeString(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(std::to_string(account_entry.expansion));
insert_values.push_back("'" + EscapeString(account_entry.ban_reason) + "'");
insert_values.push_back("'" + EscapeString(account_entry.suspend_reason) + "'");
insert_values.push_back("'" + EscapeString(account_entry.crc_eqgame) + "'");
insert_values.push_back("'" + EscapeString(account_entry.crc_skillcaps) + "'");
insert_values.push_back("'" + EscapeString(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(),
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> account_entries
const std::vector<Account> &entries
)
{
std::vector<std::string> insert_chunks;
for (auto &account_entry: account_entries) {
std::vector<std::string> insert_values;
for (auto &e: entries) {
std::vector<std::string> v;
insert_values.push_back(std::to_string(account_entry.id));
insert_values.push_back("'" + EscapeString(account_entry.name) + "'");
insert_values.push_back("'" + EscapeString(account_entry.charname) + "'");
insert_values.push_back(std::to_string(account_entry.sharedplat));
insert_values.push_back("'" + EscapeString(account_entry.password) + "'");
insert_values.push_back(std::to_string(account_entry.status));
insert_values.push_back("'" + EscapeString(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.revoked));
insert_values.push_back(std::to_string(account_entry.karma));
insert_values.push_back("'" + EscapeString(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(std::to_string(account_entry.expansion));
insert_values.push_back("'" + EscapeString(account_entry.ban_reason) + "'");
insert_values.push_back("'" + EscapeString(account_entry.suspend_reason) + "'");
insert_values.push_back("'" + EscapeString(account_entry.crc_eqgame) + "'");
insert_values.push_back("'" + EscapeString(account_entry.crc_skillcaps) + "'");
insert_values.push_back("'" + EscapeString(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("(" + implode(",", insert_values) + ")");
insert_chunks.push_back("(" + Strings::Implode(",", v) + ")");
}
std::vector<std::string> insert_values;
std::vector<std::string> v;
auto results = db.QueryDatabase(
fmt::format(
"{} VALUES {}",
BaseInsert(),
implode(",", insert_chunks)
Strings::Implode(",", insert_chunks)
)
);
@@ -399,38 +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.revoked = atoi(row[9]);
entry.karma = atoi(row[10]);
entry.minilogin_ip = row[11] ? row[11] : "";
entry.hideme = atoi(row[12]);
entry.rulesflag = atoi(row[13]);
entry.suspendeduntil = strtoll(row[14] ? row[14] : "-1", nullptr, 10);
entry.time_creation = atoi(row[15]);
entry.expansion = atoi(row[16]);
entry.ban_reason = row[17] ? row[17] : "";
entry.suspend_reason = row[18] ? row[18] : "";
entry.crc_eqgame = row[19] ? row[19] : "";
entry.crc_skillcaps = row[20] ? row[20] : "";
entry.crc_basedata = row[21] ? row[21] : "";
e.id = static_cast<int32_t>(atoi(row[0]));
e.name = row[1] ? row[1] : "";
e.charname = row[2] ? row[2] : "";
e.sharedplat = static_cast<uint32_t>(strtoul(row[3], nullptr, 10));
e.password = row[4] ? row[4] : "";
e.status = static_cast<int32_t>(atoi(row[5]));
e.ls_id = row[6] ? row[6] : "";
e.lsaccount_id = static_cast<uint32_t>(strtoul(row[7], nullptr, 10));
e.gmspeed = static_cast<uint8_t>(strtoul(row[8], nullptr, 10));
e.invulnerable = static_cast<int8_t>(atoi(row[9]));
e.flymode = static_cast<int8_t>(atoi(row[10]));
e.ignore_tells = static_cast<int8_t>(atoi(row[11]));
e.revoked = static_cast<uint8_t>(strtoul(row[12], nullptr, 10));
e.karma = static_cast<uint32_t>(strtoul(row[13], nullptr, 10));
e.minilogin_ip = row[14] ? row[14] : "";
e.hideme = static_cast<int8_t>(atoi(row[15]));
e.rulesflag = static_cast<uint8_t>(strtoul(row[16], nullptr, 10));
e.suspendeduntil = strtoll(row[17] ? row[17] : "-1", nullptr, 10);
e.time_creation = static_cast<uint32_t>(strtoul(row[18], nullptr, 10));
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<Account> GetWhere(Database& db, std::string where_filter)
static std::vector<Account> GetWhere(Database& db, const std::string &where_filter)
{
std::vector<Account> all_entries;
@@ -445,38 +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.revoked = atoi(row[9]);
entry.karma = atoi(row[10]);
entry.minilogin_ip = row[11] ? row[11] : "";
entry.hideme = atoi(row[12]);
entry.rulesflag = atoi(row[13]);
entry.suspendeduntil = strtoll(row[14] ? row[14] : "-1", nullptr, 10);
entry.time_creation = atoi(row[15]);
entry.expansion = atoi(row[16]);
entry.ban_reason = row[17] ? row[17] : "";
entry.suspend_reason = row[18] ? row[18] : "";
entry.crc_eqgame = row[19] ? row[19] : "";
entry.crc_skillcaps = row[20] ? row[20] : "";
entry.crc_basedata = row[21] ? row[21] : "";
e.id = static_cast<int32_t>(atoi(row[0]));
e.name = row[1] ? row[1] : "";
e.charname = row[2] ? row[2] : "";
e.sharedplat = static_cast<uint32_t>(strtoul(row[3], nullptr, 10));
e.password = row[4] ? row[4] : "";
e.status = static_cast<int32_t>(atoi(row[5]));
e.ls_id = row[6] ? row[6] : "";
e.lsaccount_id = static_cast<uint32_t>(strtoul(row[7], nullptr, 10));
e.gmspeed = static_cast<uint8_t>(strtoul(row[8], nullptr, 10));
e.invulnerable = static_cast<int8_t>(atoi(row[9]));
e.flymode = static_cast<int8_t>(atoi(row[10]));
e.ignore_tells = static_cast<int8_t>(atoi(row[11]));
e.revoked = static_cast<uint8_t>(strtoul(row[12], nullptr, 10));
e.karma = static_cast<uint32_t>(strtoul(row[13], nullptr, 10));
e.minilogin_ip = row[14] ? row[14] : "";
e.hideme = static_cast<int8_t>(atoi(row[15]));
e.rulesflag = static_cast<uint8_t>(strtoul(row[16], nullptr, 10));
e.suspendeduntil = strtoll(row[17] ? row[17] : "-1", nullptr, 10);
e.time_creation = static_cast<uint32_t>(strtoul(row[18], nullptr, 10));
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(
@@ -501,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
@@ -13,15 +13,15 @@
#define EQEMU_BASE_ACCOUNT_REWARDS_REPOSITORY_H
#include "../../database.h"
#include "../../string_util.h"
#include "../../strings.h"
#include <ctime>
class BaseAccountRewardsRepository {
public:
struct AccountRewards {
int account_id;
int reward_id;
int amount;
uint32_t account_id;
uint32_t reward_id;
uint32_t amount;
};
static std::string PrimaryKey()
@@ -49,12 +49,12 @@ public:
static std::string ColumnsRaw()
{
return std::string(implode(", ", Columns()));
return std::string(Strings::Implode(", ", Columns()));
}
static std::string SelectColumnsRaw()
{
return std::string(implode(", ", SelectColumns()));
return std::string(Strings::Implode(", ", SelectColumns()));
}
static std::string TableName()
@@ -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<AccountRewards> &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 = static_cast<uint32_t>(strtoul(row[0], nullptr, 10));
e.reward_id = static_cast<uint32_t>(strtoul(row[1], nullptr, 10));
e.amount = static_cast<uint32_t>(strtoul(row[2], nullptr, 10));
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<std::string> update_values;
std::vector<std::string> 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(),
implode(", ", update_values),
Strings::Implode(", ", v),
PrimaryKey(),
account_rewards_entry.account_id
e.account_id
)
);
@@ -177,57 +177,57 @@ public:
static AccountRewards InsertOne(
Database& db,
AccountRewards account_rewards_entry
AccountRewards e
)
{
std::vector<std::string> insert_values;
std::vector<std::string> 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(),
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<AccountRewards> account_rewards_entries
const std::vector<AccountRewards> &entries
)
{
std::vector<std::string> insert_chunks;
for (auto &account_rewards_entry: account_rewards_entries) {
std::vector<std::string> insert_values;
for (auto &e: entries) {
std::vector<std::string> 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("(" + implode(",", insert_values) + ")");
insert_chunks.push_back("(" + Strings::Implode(",", v) + ")");
}
std::vector<std::string> insert_values;
std::vector<std::string> v;
auto results = db.QueryDatabase(
fmt::format(
"{} VALUES {}",
BaseInsert(),
implode(",", insert_chunks)
Strings::Implode(",", insert_chunks)
)
);
@@ -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 = static_cast<uint32_t>(strtoul(row[0], nullptr, 10));
e.reward_id = static_cast<uint32_t>(strtoul(row[1], nullptr, 10));
e.amount = static_cast<uint32_t>(strtoul(row[2], nullptr, 10));
all_entries.push_back(entry);
all_entries.push_back(e);
}
return all_entries;
}
static std::vector<AccountRewards> GetWhere(Database& db, std::string where_filter)
static std::vector<AccountRewards> GetWhere(Database& db, const std::string &where_filter)
{
std::vector<AccountRewards> 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 = static_cast<uint32_t>(strtoul(row[0], nullptr, 10));
e.reward_id = static_cast<uint32_t>(strtoul(row[1], nullptr, 10));
e.amount = static_cast<uint32_t>(strtoul(row[2], 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(
@@ -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
@@ -13,21 +13,21 @@
#define EQEMU_BASE_ADVENTURE_DETAILS_REPOSITORY_H
#include "../../database.h"
#include "../../string_util.h"
#include "../../strings.h"
#include <ctime>
class BaseAdventureDetailsRepository {
public:
struct AdventureDetails {
int id;
int adventure_id;
int instance_id;
int count;
int assassinate_count;
int status;
int time_created;
int time_zoned;
int time_completed;
uint32_t id;
uint16_t adventure_id;
int32_t instance_id;
uint16_t count;
uint16_t assassinate_count;
uint8_t status;
uint32_t time_created;
uint32_t time_zoned;
uint32_t time_completed;
};
static std::string PrimaryKey()
@@ -67,12 +67,12 @@ public:
static std::string ColumnsRaw()
{
return std::string(implode(", ", Columns()));
return std::string(Strings::Implode(", ", Columns()));
}
static std::string SelectColumnsRaw()
{
return std::string(implode(", ", SelectColumns()));
return std::string(Strings::Implode(", ", SelectColumns()));
}
static std::string TableName()
@@ -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<AdventureDetails> &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 = static_cast<uint32_t>(strtoul(row[0], nullptr, 10));
e.adventure_id = static_cast<uint16_t>(strtoul(row[1], nullptr, 10));
e.instance_id = static_cast<int32_t>(atoi(row[2]));
e.count = static_cast<uint16_t>(strtoul(row[3], nullptr, 10));
e.assassinate_count = static_cast<uint16_t>(strtoul(row[4], nullptr, 10));
e.status = static_cast<uint8_t>(strtoul(row[5], nullptr, 10));
e.time_created = static_cast<uint32_t>(strtoul(row[6], nullptr, 10));
e.time_zoned = static_cast<uint32_t>(strtoul(row[7], nullptr, 10));
e.time_completed = static_cast<uint32_t>(strtoul(row[8], nullptr, 10));
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<std::string> update_values;
std::vector<std::string> 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(),
implode(", ", update_values),
Strings::Implode(", ", v),
PrimaryKey(),
adventure_details_entry.id
e.id
)
);
@@ -212,69 +212,69 @@ public:
static AdventureDetails InsertOne(
Database& db,
AdventureDetails adventure_details_entry
AdventureDetails e
)
{
std::vector<std::string> insert_values;
std::vector<std::string> 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(),
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<AdventureDetails> adventure_details_entries
const std::vector<AdventureDetails> &entries
)
{
std::vector<std::string> insert_chunks;
for (auto &adventure_details_entry: adventure_details_entries) {
std::vector<std::string> insert_values;
for (auto &e: entries) {
std::vector<std::string> 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("(" + implode(",", insert_values) + ")");
insert_chunks.push_back("(" + Strings::Implode(",", v) + ")");
}
std::vector<std::string> insert_values;
std::vector<std::string> v;
auto results = db.QueryDatabase(
fmt::format(
"{} VALUES {}",
BaseInsert(),
implode(",", insert_chunks)
Strings::Implode(",", insert_chunks)
)
);
@@ -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 = static_cast<uint32_t>(strtoul(row[0], nullptr, 10));
e.adventure_id = static_cast<uint16_t>(strtoul(row[1], nullptr, 10));
e.instance_id = static_cast<int32_t>(atoi(row[2]));
e.count = static_cast<uint16_t>(strtoul(row[3], nullptr, 10));
e.assassinate_count = static_cast<uint16_t>(strtoul(row[4], nullptr, 10));
e.status = static_cast<uint8_t>(strtoul(row[5], nullptr, 10));
e.time_created = static_cast<uint32_t>(strtoul(row[6], nullptr, 10));
e.time_zoned = static_cast<uint32_t>(strtoul(row[7], nullptr, 10));
e.time_completed = static_cast<uint32_t>(strtoul(row[8], nullptr, 10));
all_entries.push_back(entry);
all_entries.push_back(e);
}
return all_entries;
}
static std::vector<AdventureDetails> GetWhere(Database& db, std::string where_filter)
static std::vector<AdventureDetails> GetWhere(Database& db, const std::string &where_filter)
{
std::vector<AdventureDetails> 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 = static_cast<uint32_t>(strtoul(row[0], nullptr, 10));
e.adventure_id = static_cast<uint16_t>(strtoul(row[1], nullptr, 10));
e.instance_id = static_cast<int32_t>(atoi(row[2]));
e.count = static_cast<uint16_t>(strtoul(row[3], nullptr, 10));
e.assassinate_count = static_cast<uint16_t>(strtoul(row[4], nullptr, 10));
e.status = static_cast<uint8_t>(strtoul(row[5], nullptr, 10));
e.time_created = static_cast<uint32_t>(strtoul(row[6], nullptr, 10));
e.time_zoned = static_cast<uint32_t>(strtoul(row[7], nullptr, 10));
e.time_completed = static_cast<uint32_t>(strtoul(row[8], 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(
@@ -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
@@ -13,14 +13,14 @@
#define EQEMU_BASE_ADVENTURE_MEMBERS_REPOSITORY_H
#include "../../database.h"
#include "../../string_util.h"
#include "../../strings.h"
#include <ctime>
class BaseAdventureMembersRepository {
public:
struct AdventureMembers {
int id;
int charid;
uint32_t id;
uint32_t charid;
};
static std::string PrimaryKey()
@@ -46,12 +46,12 @@ public:
static std::string ColumnsRaw()
{
return std::string(implode(", ", Columns()));
return std::string(Strings::Implode(", ", Columns()));
}
static std::string SelectColumnsRaw()
{
return std::string(implode(", ", SelectColumns()));
return std::string(Strings::Implode(", ", SelectColumns()));
}
static std::string TableName()
@@ -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<AdventureMembers> &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 = static_cast<uint32_t>(strtoul(row[0], nullptr, 10));
e.charid = static_cast<uint32_t>(strtoul(row[1], nullptr, 10));
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<std::string> update_values;
std::vector<std::string> 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(),
implode(", ", update_values),
Strings::Implode(", ", v),
PrimaryKey(),
adventure_members_entry.charid
e.charid
)
);
@@ -171,55 +171,55 @@ public:
static AdventureMembers InsertOne(
Database& db,
AdventureMembers adventure_members_entry
AdventureMembers e
)
{
std::vector<std::string> insert_values;
std::vector<std::string> 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(),
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<AdventureMembers> adventure_members_entries
const std::vector<AdventureMembers> &entries
)
{
std::vector<std::string> insert_chunks;
for (auto &adventure_members_entry: adventure_members_entries) {
std::vector<std::string> insert_values;
for (auto &e: entries) {
std::vector<std::string> 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("(" + implode(",", insert_values) + ")");
insert_chunks.push_back("(" + Strings::Implode(",", v) + ")");
}
std::vector<std::string> insert_values;
std::vector<std::string> v;
auto results = db.QueryDatabase(
fmt::format(
"{} VALUES {}",
BaseInsert(),
implode(",", insert_chunks)
Strings::Implode(",", insert_chunks)
)
);
@@ -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 = static_cast<uint32_t>(strtoul(row[0], nullptr, 10));
e.charid = static_cast<uint32_t>(strtoul(row[1], nullptr, 10));
all_entries.push_back(entry);
all_entries.push_back(e);
}
return all_entries;
}
static std::vector<AdventureMembers> GetWhere(Database& db, std::string where_filter)
static std::vector<AdventureMembers> GetWhere(Database& db, const std::string &where_filter)
{
std::vector<AdventureMembers> 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 = static_cast<uint32_t>(strtoul(row[0], nullptr, 10));
e.charid = static_cast<uint32_t>(strtoul(row[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(
@@ -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
@@ -13,23 +13,23 @@
#define EQEMU_BASE_ADVENTURE_STATS_REPOSITORY_H
#include "../../database.h"
#include "../../string_util.h"
#include "../../strings.h"
#include <ctime>
class BaseAdventureStatsRepository {
public:
struct AdventureStats {
int player_id;
int guk_wins;
int mir_wins;
int mmc_wins;
int ruj_wins;
int tak_wins;
int guk_losses;
int mir_losses;
int mmc_losses;
int ruj_losses;
int tak_losses;
uint32_t player_id;
uint32_t guk_wins;
uint32_t mir_wins;
uint32_t mmc_wins;
uint32_t ruj_wins;
uint32_t tak_wins;
uint32_t guk_losses;
uint32_t mir_losses;
uint32_t mmc_losses;
uint32_t ruj_losses;
uint32_t tak_losses;
};
static std::string PrimaryKey()
@@ -73,12 +73,12 @@ public:
static std::string ColumnsRaw()
{
return std::string(implode(", ", Columns()));
return std::string(Strings::Implode(", ", Columns()));
}
static std::string SelectColumnsRaw()
{
return std::string(implode(", ", SelectColumns()));
return std::string(Strings::Implode(", ", SelectColumns()));
}
static std::string TableName()
@@ -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<AdventureStats> &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 = static_cast<uint32_t>(strtoul(row[0], nullptr, 10));
e.guk_wins = static_cast<uint32_t>(strtoul(row[1], nullptr, 10));
e.mir_wins = static_cast<uint32_t>(strtoul(row[2], nullptr, 10));
e.mmc_wins = static_cast<uint32_t>(strtoul(row[3], nullptr, 10));
e.ruj_wins = static_cast<uint32_t>(strtoul(row[4], nullptr, 10));
e.tak_wins = static_cast<uint32_t>(strtoul(row[5], nullptr, 10));
e.guk_losses = static_cast<uint32_t>(strtoul(row[6], nullptr, 10));
e.mir_losses = static_cast<uint32_t>(strtoul(row[7], nullptr, 10));
e.mmc_losses = static_cast<uint32_t>(strtoul(row[8], nullptr, 10));
e.ruj_losses = static_cast<uint32_t>(strtoul(row[9], nullptr, 10));
e.tak_losses = static_cast<uint32_t>(strtoul(row[10], nullptr, 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<std::string> update_values;
std::vector<std::string> 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(),
implode(", ", update_values),
Strings::Implode(", ", v),
PrimaryKey(),
adventure_stats_entry.player_id
e.player_id
)
);
@@ -225,73 +225,73 @@ public:
static AdventureStats InsertOne(
Database& db,
AdventureStats adventure_stats_entry
AdventureStats e
)
{
std::vector<std::string> insert_values;
std::vector<std::string> 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(),
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<AdventureStats> adventure_stats_entries
const std::vector<AdventureStats> &entries
)
{
std::vector<std::string> insert_chunks;
for (auto &adventure_stats_entry: adventure_stats_entries) {
std::vector<std::string> insert_values;
for (auto &e: entries) {
std::vector<std::string> 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("(" + implode(",", insert_values) + ")");
insert_chunks.push_back("(" + Strings::Implode(",", v) + ")");
}
std::vector<std::string> insert_values;
std::vector<std::string> v;
auto results = db.QueryDatabase(
fmt::format(
"{} VALUES {}",
BaseInsert(),
implode(",", insert_chunks)
Strings::Implode(",", insert_chunks)
)
);
@@ -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 = static_cast<uint32_t>(strtoul(row[0], nullptr, 10));
e.guk_wins = static_cast<uint32_t>(strtoul(row[1], nullptr, 10));
e.mir_wins = static_cast<uint32_t>(strtoul(row[2], nullptr, 10));
e.mmc_wins = static_cast<uint32_t>(strtoul(row[3], nullptr, 10));
e.ruj_wins = static_cast<uint32_t>(strtoul(row[4], nullptr, 10));
e.tak_wins = static_cast<uint32_t>(strtoul(row[5], nullptr, 10));
e.guk_losses = static_cast<uint32_t>(strtoul(row[6], nullptr, 10));
e.mir_losses = static_cast<uint32_t>(strtoul(row[7], nullptr, 10));
e.mmc_losses = static_cast<uint32_t>(strtoul(row[8], nullptr, 10));
e.ruj_losses = static_cast<uint32_t>(strtoul(row[9], nullptr, 10));
e.tak_losses = static_cast<uint32_t>(strtoul(row[10], nullptr, 10));
all_entries.push_back(entry);
all_entries.push_back(e);
}
return all_entries;
}
static std::vector<AdventureStats> GetWhere(Database& db, std::string where_filter)
static std::vector<AdventureStats> GetWhere(Database& db, const std::string &where_filter)
{
std::vector<AdventureStats> 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 = static_cast<uint32_t>(strtoul(row[0], nullptr, 10));
e.guk_wins = static_cast<uint32_t>(strtoul(row[1], nullptr, 10));
e.mir_wins = static_cast<uint32_t>(strtoul(row[2], nullptr, 10));
e.mmc_wins = static_cast<uint32_t>(strtoul(row[3], nullptr, 10));
e.ruj_wins = static_cast<uint32_t>(strtoul(row[4], nullptr, 10));
e.tak_wins = static_cast<uint32_t>(strtoul(row[5], nullptr, 10));
e.guk_losses = static_cast<uint32_t>(strtoul(row[6], nullptr, 10));
e.mir_losses = static_cast<uint32_t>(strtoul(row[7], nullptr, 10));
e.mmc_losses = static_cast<uint32_t>(strtoul(row[8], nullptr, 10));
e.ruj_losses = static_cast<uint32_t>(strtoul(row[9], nullptr, 10));
e.tak_losses = static_cast<uint32_t>(strtoul(row[10], 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(
@@ -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
@@ -13,13 +13,13 @@
#define EQEMU_BASE_ADVENTURE_TEMPLATE_ENTRY_FLAVOR_REPOSITORY_H
#include "../../database.h"
#include "../../string_util.h"
#include "../../strings.h"
#include <ctime>
class BaseAdventureTemplateEntryFlavorRepository {
public:
struct AdventureTemplateEntryFlavor {
int id;
uint32_t id;
std::string text;
};
@@ -46,12 +46,12 @@ public:
static std::string ColumnsRaw()
{
return std::string(implode(", ", Columns()));
return std::string(Strings::Implode(", ", Columns()));
}
static std::string SelectColumnsRaw()
{
return std::string(implode(", ", SelectColumns()));
return std::string(Strings::Implode(", ", SelectColumns()));
}
static std::string TableName()
@@ -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<AdventureTemplateEntryFlavor> &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 = static_cast<uint32_t>(strtoul(row[0], nullptr, 10));
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<std::string> update_values;
std::vector<std::string> 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] + " = '" + EscapeString(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(),
implode(", ", update_values),
Strings::Implode(", ", v),
PrimaryKey(),
adventure_template_entry_flavor_entry.id
e.id
)
);
@@ -171,55 +171,55 @@ public:
static AdventureTemplateEntryFlavor InsertOne(
Database& db,
AdventureTemplateEntryFlavor adventure_template_entry_flavor_entry
AdventureTemplateEntryFlavor e
)
{
std::vector<std::string> insert_values;
std::vector<std::string> v;
insert_values.push_back(std::to_string(adventure_template_entry_flavor_entry.id));
insert_values.push_back("'" + EscapeString(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(),
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<AdventureTemplateEntryFlavor> adventure_template_entry_flavor_entries
const std::vector<AdventureTemplateEntryFlavor> &entries
)
{
std::vector<std::string> insert_chunks;
for (auto &adventure_template_entry_flavor_entry: adventure_template_entry_flavor_entries) {
std::vector<std::string> insert_values;
for (auto &e: entries) {
std::vector<std::string> v;
insert_values.push_back(std::to_string(adventure_template_entry_flavor_entry.id));
insert_values.push_back("'" + EscapeString(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("(" + implode(",", insert_values) + ")");
insert_chunks.push_back("(" + Strings::Implode(",", v) + ")");
}
std::vector<std::string> insert_values;
std::vector<std::string> v;
auto results = db.QueryDatabase(
fmt::format(
"{} VALUES {}",
BaseInsert(),
implode(",", insert_chunks)
Strings::Implode(",", insert_chunks)
)
);
@@ -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 = static_cast<uint32_t>(strtoul(row[0], nullptr, 10));
e.text = row[1] ? row[1] : "";
all_entries.push_back(entry);
all_entries.push_back(e);
}
return all_entries;
}
static std::vector<AdventureTemplateEntryFlavor> GetWhere(Database& db, std::string where_filter)
static std::vector<AdventureTemplateEntryFlavor> GetWhere(Database& db, const std::string &where_filter)
{
std::vector<AdventureTemplateEntryFlavor> 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 = static_cast<uint32_t>(strtoul(row[0], nullptr, 10));
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

Some files were not shown because too many files have changed in this diff Show More