Compare commits

...

123 Commits

Author SHA1 Message Date
Akkadius 332a1dcab1 Update windows-build.ps1 2023-01-21 00:51:26 -06:00
Akkadius 8dd8caff63 Update windows-build.ps1 2023-01-21 00:41:20 -06:00
Akkadius fc24385fd6 Update windows-build.ps1 2023-01-21 00:30:52 -06:00
Akkadius c9d8c45b39 Update windows-build.ps1 2023-01-21 00:22:52 -06:00
Akkadius 191746975c Trim windows assets 2023-01-21 00:15:11 -06:00
Akkadius 965bf0e684 Update CMakeLists.txt 2023-01-21 00:00:09 -06:00
Akkadius 4ed820039c Update linux-build.sh 2023-01-20 21:16:55 -06:00
Akkadius c931b1051e Update linux-build.sh 2023-01-20 20:25:39 -06:00
Akkadius 5375603b81 Another release test 2023-01-20 19:30:16 -06:00
Akkadius 77ad1c6f9c Update linux-build.sh 2023-01-20 17:37:02 -06:00
Akkadius 3771da84c4 Pop cache back in 2023-01-20 17:26:25 -06:00
Akkadius 77cbe4b9d4 Run it 2023-01-20 17:17:41 -06:00
Akkadius c7dcf52b82 Consolidate 2023-01-20 17:06:20 -06:00
Akkadius a942b65553 Update windows-build.ps1 2023-01-20 17:01:08 -06:00
Akkadius 62546b6f2f F 2023-01-20 16:54:10 -06:00
Akkadius 4ac0bfd69e Update windows-build.ps1 2023-01-20 16:51:43 -06:00
Akkadius 9cde2f7405 Update windows-build.ps1 2023-01-20 16:50:45 -06:00
Akkadius c17ab5a848 Update windows-build.ps1 2023-01-20 16:48:05 -06:00
Akkadius 158dd3ac97 Take #45354 2023-01-20 16:32:11 -06:00
Akkadius f5de63b1d7 Shuffle 2023-01-20 16:22:41 -06:00
Akkadius bf157eab7f Update build-release.bat 2023-01-20 16:16:09 -06:00
Akkadius 11fc66c490 Update build-release.bat 2023-01-20 16:11:14 -06:00
Akkadius f654fa6f58 Bump 2023-01-20 16:07:08 -06:00
Akkadius c75f731a82 Update CHANGELOG.md 2023-01-20 16:06:18 -06:00
Akkadius f29421a7d6 Test pipeline 2023-01-20 16:04:08 -06:00
Akkadius 0a6212f9a8 Update build-release.bat 2023-01-20 16:01:46 -06:00
Akkadius 84415b146b Update build-release.bat 2023-01-20 16:01:02 -06:00
Akkadius e4fe36088b Update .drone.yml 2023-01-20 15:59:56 -06:00
Akkadius 5aea91e680 Update .drone.yml 2023-01-20 15:58:29 -06:00
Akkadius 8d7cef6237 Update .drone.yml 2023-01-20 15:57:23 -06:00
Akkadius f65ab8d372 Update build-release.bat 2023-01-20 15:56:03 -06:00
Akkadius 217ea71bd7 Test 2023-01-20 15:54:17 -06:00
Akkadius d5f2669cab Update .drone.yml 2023-01-20 15:25:25 -06:00
Akkadius c49548c090 Update .drone.yml 2023-01-20 15:23:42 -06:00
Akkadius b615b4d474 Add version checks 2023-01-20 15:23:10 -06:00
Akkadius f151e5fbe3 Update .drone.yml 2023-01-20 14:24:25 -06:00
Akkadius 2835f79a9f Update .drone.yml 2023-01-20 14:21:00 -06:00
Akkadius 9fbdf1e7c0 exit 78 2023-01-20 14:19:21 -06:00
Akkadius 1c074ec84c Update .drone.yml 2023-01-20 14:14:52 -06:00
Akkadius aa953731ad Update .drone.yml 2023-01-20 14:02:15 -06:00
Akkadius 23ef6b9c8c Check if release 2023-01-20 13:59:10 -06:00
Akkadius 3655b1a350 Release bot test #2 2023-01-20 13:29:35 -06:00
Akkadius 9ff2d03d01 Bots release 22.0.5 (Test) 2023-01-20 13:28:54 -06:00
Akkadius eedba3949d Test 2023-01-20 13:28:54 -06:00
Akkadius 241e6e6823 Update .drone.yml 2023-01-20 13:28:54 -06:00
Akkadius d00ab2233a Filter pipeline stage 2023-01-20 13:28:54 -06:00
Akkadius af03ac7df2 Update .drone.yml 2023-01-20 13:28:54 -06:00
Akkadius 45c1a60684 Remove debug 2023-01-20 13:28:54 -06:00
Akkadius f3407f5972 Test pipeline 2023-01-20 13:28:54 -06:00
Akkadius e7b43b9e2f Update .drone.yml 2023-01-20 13:28:54 -06:00
Akkadius cf6b97c745 Update .drone.yml 2023-01-20 13:28:54 -06:00
Akkadius 26116ec808 Release without bots 2023-01-20 13:28:54 -06:00
Akkadius a6438b833c Yolo 2023-01-20 13:28:54 -06:00
Akkadius e840eeb931 Copy 2023-01-20 13:28:54 -06:00
Akkadius 6cd2cb20b5 Update .drone.yml 2023-01-20 13:28:54 -06:00
Akkadius 440eb64328 Update .drone.yml 2023-01-20 13:28:54 -06:00
Akkadius af0e64cef8 Yolo 2023-01-20 13:28:54 -06:00
Akkadius 2db28a7e42 Yolo 2023-01-20 13:28:54 -06:00
Akkadius 4bbad8678c Update .drone.yml 2023-01-20 13:28:54 -06:00
Akkadius b6e5ef5521 Update .drone.yml 2023-01-20 13:28:54 -06:00
Akkadius b22b281312 Update .drone.yml 2023-01-20 13:28:54 -06:00
Akkadius b66c65fc02 Test upload 2023-01-20 13:28:54 -06:00
Akkadius 1c7dedb12d Naming 2023-01-20 13:28:54 -06:00
Akkadius e6dc06c0c6 Update .drone.yml 2023-01-20 13:28:54 -06:00
Akkadius c445f7bed6 Test 2023-01-20 13:28:54 -06:00
Akkadius 4e0b762244 Update .drone.yml 2023-01-20 13:28:53 -06:00
Akkadius 4f3c97ff24 Update .drone.yml 2023-01-20 13:28:53 -06:00
Akkadius c5d5bf6503 Update .drone.yml 2023-01-20 13:28:53 -06:00
Akkadius a76204bd38 Update .drone.yml 2023-01-20 13:28:53 -06:00
Akkadius d828c72176 Linux 2023-01-20 13:28:53 -06:00
Akkadius 60962005d1 Remove 7z from build scripts 2023-01-20 13:28:53 -06:00
Akkadius 2a81314d49 Split 2023-01-20 13:28:53 -06:00
Akkadius 9edad8fa3b Kill excessive warnings 2023-01-20 13:28:53 -06:00
Akkadius 74f8629884 Update windows-build.ps1 2023-01-20 13:28:53 -06:00
Akkadius 6f8fc85a92 Update windows-build.ps1 2023-01-20 13:28:53 -06:00
Akkadius 87af11374c Update windows-build.ps1 2023-01-20 13:28:53 -06:00
Akkadius 90366302bd Test 2023-01-20 13:28:53 -06:00
Akkadius 92df505c6e Test 2023-01-20 13:28:53 -06:00
Chris Miles 5c095ab87a [Bots] Post pre-processor fixes (#2770)
* Fixes

* Update main.cpp
2023-01-20 13:28:39 -06:00
Akkadius e8ca3f6942 [eqemu_server.pl Swap out binary source 2023-01-20 12:56:37 -06:00
Akkadius 706a06efb6 [Appveyor] Remove bots preprocessor 2023-01-20 12:42:35 -06:00
Alex King 3335cacac1 [Bots] Cleanup and remove preprocessors. (#2757)
* [Bots] Cleanup and remove preprocessors.

- Removes every `#ifdef BOTS` we have and locks bots behind `Bots:AllowBots` rule.
- Bot updates are now done by default similar to regular database updates.
- Modify `CMakeLists.txt`, `.drone.yml`, and `BUILD.md` to match the removal of `EQEMU_ENABLE_BOTS`.

* Cleanup

- Add SQL for enabling bots for servers with bots.
- Add message that tells players/operators bots are disabled.

* Suggested changes.

* Bot injection stuff

* Change SQL to bot SQL.

* Tweaks

* Remove `is_bot`

* Update version.h

* Update main.cpp

* Update database.cpp

* Fix name availability crash

* Remove bots from update script

Co-authored-by: Akkadius <akkadius1@gmail.com>
2023-01-20 12:35:33 -06:00
Akkadius 1f0b2a8991 [Hotfix] Make sure we have a proper split size before assuming we can split it 2023-01-20 12:25:49 -06:00
Aeadoin a16f21d6fe [Bots] Add Support for AA bonuses that were missing. (#2764)
* [Bots] Add Support for AA bonuses that were missing.

* Fix GetFocusEffect, add virtual override to Bot to prevent using NPC
2023-01-19 22:45:09 -06:00
Chris Miles 900837f633 [Logging] Improvements to GM Say Logging (#2765) 2023-01-19 22:24:57 -06:00
Chris Miles d3e756287e [Logging] Remove function prefixes (#2766) 2023-01-19 22:24:50 -06:00
Vayle 7d0dd13d17 [Bug Fix] Add omitted function call in UCS (#2768) 2023-01-19 22:24:39 -06:00
Vayle ba5b901c16 [Optimization] Handle channel name filter checks in memory (#2767)
* Handle channel name filter checks in memory

With this commit, name filters are loaded into memory when the server loads and new channels are compared against these memory values VS hitting the database each time.

* Minor formatting tweaks
2023-01-19 21:23:11 -06:00
Akkadius 3424ae2dde [Hotfix] Fix door click crash issue if destination zone doesn't exist 2023-01-19 19:06:58 -06:00
Chris Miles 9aad8ae54c [Logging] Force crash logs to always be on regardless of setting (#2762) 2023-01-19 18:21:44 -06:00
JJ 7cd6b4b8ab [SQL] Update 2023_01_15_merc_data.sql (#2763)
Odd spacing. Someone fell asleep on the keyboard.
2023-01-19 18:20:46 -06:00
Aeadoin 090019cf83 [Bot] Restrict Bot Groups from spawning while Feigned. (#2761) 2023-01-19 16:52:20 -06:00
Chris Miles d93ea9ed86 [Zone Flags] Use database connection, not content connection (#2759) 2023-01-19 15:11:40 -06:00
Chris Miles a7b35594f8 [Fix] Zone Flags Regression (#2760) 2023-01-19 15:11:32 -06:00
Vayle 29473aa7f5 [Rules] Add rule to allow players to permanently save chat channels to database, up to a limit. (#2706)
* Initial code

* Tweak

* Rule description tweak

* More channel work

* More adjustments

* Auto-join saved permanent player channels

* Fix UCS crash if player has no channels to load from table.

* Implemented channel blocking feature

* Update database when player channel's owner or password change

* First round of requested changes.

* Logic tweak to ensure player channels are sets to permanent when appropraite

* name_filter table integration and some refactoring

* Use new `reserved_channel_names` table to block specific channel names.

* Remove some legacy channel block code

* Setup required SQL update to create  `reserved_channel_names`  table.

* Update db_update_manifest.txt

* Update db_update_manifest.txt

* Update chatchannel.cpp

* Code review

* Database to UCSDatabase

* Repository SaveChatChannel

* CurrentPlayerChannelCount repository

* Cleanup name filter

* CreateChannel

* Update websocketpp

* Increment CURRENT_BINARY_DATABASE_VERSION

Set to 9216

* Minor tweaks to blocked channel name checks & other related areas.

- Enforce blocked channel names on channel creation.
- Also enforce blocked channel names on channel join.
- Add channel status check to Debug logging.
- Minor formatting adjustments.
- Add single quotes to column name value in query.

* Minor log change

* Increment DB Version

* Formatting Tweaks

- Made formatting adjustments consistent with KinglyKrab's recommended changes.
- This compiles successfully with these changes, but unable to test the changes until this weekend.

Co-authored-by: Akkadius <akkadius1@gmail.com>
2023-01-18 22:42:09 -06:00
Aeadoin 03a27b02ff [Hotfix] Login Server failing to compile on Windows. (#2758) 2023-01-18 21:21:36 -05:00
Akkadius f9ea7ddb62 [Logging] Reset stream so we don't bold the whole line 2023-01-17 21:39:18 -06:00
Chris Miles 40d1c33351 [Logging] Logging Improvements (#2755)
* Console logging improvements

* stderr handling

* Add origination information

* Formatting

* Update zoneserver.cpp

* Update eqemu_logsys.cpp

* Remove semicolon from MySQLQuery log output

* Remove IsRfc5424LogCategory

* Remove no longer used functions

* Remove definition BUILD_LOGGING

* Deprecate categories UCSServer & WorldServer

* Deprecate UCS / World Server / Zone Server categories

* Deprecate Status, QSServer, Normal

* Update login_server.cpp

* Deprecate Emergency, Alert, Critical, Notice

* Deprecate Alert

* Fix terminal color resetting

* Deprecate headless client

* Move LogAIModerate to Detail

* Deprecate moderate logging level for detail

* Update logs.cpp

* Logs list simplify

* Update logs.cpp

* Add discord to log command

* Remove unused headers

* Windows fix

* Error in world when zones fail to load

* Show warning color properly

* Keep loginserver thread log from colliding with other logs during startup

* Deprecate Loginserver category
2023-01-17 21:18:40 -06:00
Michael Cook (mackal) ee2079ec35 [C++20] Arithmetic on different enums is deprecated (#2752)
Just do some casts and add some constants to make life easier
2023-01-17 15:21:01 -06:00
Xackery a90c760186 [Code] Removed vscode setting (#2753) 2023-01-17 15:20:36 -06:00
Alex King fbb36a3e75 [Mercs] Add Mercenary Support (#2745)
* [Mercs] Add Mercenary Support

# Notes
- Adds `--merc-tables` support to database dumper.
- Adds Mercenary-based repositories.
- Adds required SQL `2023_01_15_merc_data.sql` to insert the tables for those who don't already have them.
- Adds optional SQL `2023_01_15_merc_liaisons.sql` to change NPCs to the Mercenary Liaison class optionally.

* Inline.

* Trim tables_to_dump output

Co-authored-by: Akkadius <akkadius1@gmail.com>
2023-01-17 16:19:55 -05:00
Aeadoin bd29f1c5bb [Bug Fix] Handle_OP_AugmentItem could cause Zone crash (#2750) 2023-01-17 14:34:28 -05:00
Natedog2012 a99e0a4b2c [Bug Fix] Move EVENT_SPAWN for adding NPCs back to original spot, also add NPCs… (#2749)
* Move EVENT_SPAWN for adding NPCs back to original spot, also add NPCs to npc/mob list before parsing

* Adjust bots EVENT_SPAWN before spawn packet
2023-01-16 22:32:19 -05:00
Aeadoin be03628aa9 [Bug Fix] Fix Group XP not working. (#2748) 2023-01-16 19:10:19 -05:00
Aeadoin f1a6006ee1 [Hotfix] Resolve Zone Crashing when grouped with Bots. (#2747)
* [Hotfix] Resolve Zone Crashing when grouped with Bots.

* Fixed SpawnBotGroupByName as well.

* rename variables
2023-01-16 16:50:38 -05:00
Aeadoin dd40f2a0e6 [Bug Fix] Fix ST_TargetsTarget Spells with Restrictions (#2746) 2023-01-15 17:55:34 -05:00
Aeadoin 7fa421d848 [Bug Fix] HasPet() Zone Crashes (#2744)
* [Bug Fixes] Fix for HasPet() Zone Crashes

* HasPets const

* Remove checking This

* formatting
2023-01-15 17:16:17 -05:00
Alex King 00658632de [Cleanup] Make use of std::abs where possible. (#2739)
# Notes
- Resolves https://github.com/EQEmu/Server/issues/338
2023-01-15 17:02:13 -05:00
Alex King eed45e5250 [Quest API] Add SendPath() to Perl/Lua. (#2740)
* [Quest API] Add SendPath() to Perl/Lua.

# Perl
- Add `$client->SendPath(target)`.

# Lua
- Add `client:SendPath(target)`.

# Notes
- Allows operators to send a path to a target arbitrarily with a script.

* Update client.cpp
2023-01-15 17:02:06 -05:00
Alex King 64c62c4f0a [Feature] Add Rule to Disable Group EXP Modifier. (#2741)
# Notes
- Adds `Character:EnableGroupEXPModifier`, defaults to `true`.
- Adds `Character:GroupMemberEXPModifier`, defaults to `0.2`.
- Adds `Character:FullGroupEXPModifier`, defaults to `2.16`.
- Allows operators to enable or disable the group experience modifier based on number of members.
- Allows operators to change the modifier per member in the group between `2` and `5`.
- Allows operators to change the full group experience modifier.
2023-01-15 17:01:59 -05:00
Paul Coene ca0ae3cb98 [Rule] Add rule for NPC Level Based Buff Restrictions. (#2708)
* [Rule] Add rule for NPC Level Based Buff Restrictions.

* Erroneous whitespace

* Change prefix on log message

* Added log message when GM casts
2023-01-15 15:30:42 -06:00
Chris Miles 9e3539295b [QS] Database class name change (#2743) 2023-01-15 14:37:39 -06:00
Chris Miles 7aa25f17f6 [UCS] Database class name change (#2742) 2023-01-15 14:16:23 -06:00
Chris Miles e1c1d55ca5 [Websocket] Fix cpp20/gcc11 compile failure (#2737) 2023-01-15 11:00:24 -06:00
Aeadoin 403c54362e [Bot/Merc] Cleanup methods, and virtual overrides. (#2734)
* [Bot] Cleanup methods, and virtual overrides.

* Remove Bot::CheckAggroAmount & Bot::CheckHealAggroAmount

* formatting
2023-01-14 23:32:19 -05:00
Alex King a422484307 [Quest API] Add Client Augment Events to Perl/Lua. (#2735)
* [Quest API] Add Client Augment Events to Perl/Lua.

# Perl
- Add `EVENT_AUGMENT_INSERT_CLIENT`.
- Add `EVENT_AUGMENT_REMOVE_CLIENT`.

# Lua
- Add `event_augment_insert_client`.
- Add `event_augment_remove_client`.

# Notes
- Allows operators to use augment insert and augment remove events outside of an item script.
2023-01-14 23:23:48 -05:00
Alex King c41f375129 [Bug Fix] Fix issue with Bot::LoadAndSpawnAllZonedBots. (#2733)
* [Bug Fix] Fix issue with Bot:;LoadAndSpawnAllZonedBots.

# Notes
- Bots could spawn beyond class/global limits due to being stuck in group limbo and spawning when you enter a zone properly.

* Debug messages.

* Remove unspawned bots from group.

* Update bot.cpp

* Update bot.cpp

* Update bot.cpp

* Update bot.cpp

* >= 0
2023-01-14 23:15:26 -05:00
Alex King bd3e8b2afc [Quest API] Add Bot Methods to Lua. (#2731)
# Perl
- Minor cleanup of variable types.

 # Lua
- Add `bot:GetAugmentAt(slot_id, augment_index)`.
- Add `bot:GetItemAt(slot_id)`.
- Add `bot:SendSpellAnim(target_id, spell_id)`.
- Properly implemented `bot:GetItemIDAt(slot_id)`.

# Notes
- `bot:GetItemIDAt` existed in Lua, but didn't have a bind definition, so was non-functional.
- This makes Perl/Lua bot methods 1:1 as Perl had 75 and Lua had 72, they now both have 75.
2023-01-14 09:16:11 -06:00
Alex King f5523b40d2 [Quest API] Add CampAllBots() to Perl/Lua. (#2732)
# Perl
- Add `$client->CampAllBots()`.
- Add `$client->CampAllBots(class_id)`.

# Lua
- Add `client:CampAllBots()`.
- Add `client:CampAllBots(class_id)`.

# Notes
- Adds constants for `NO_CLASS` which is class `0` and uses `RACE_DOUG_0` for any spots that use race ID `0`.
- Cleans up magic number usage of race/class of `0`.
2023-01-14 09:14:50 -06:00
Alex King 095f4fb56c [Quest API] Add SignalAllBotsByOwnerName() to Perl/Lua. (#2730)
# Perl
- Add `$entity_list->SignalAllBotsByOwnerName(owner_name)`.

# Lua
- Add `eq.get_entity_list():SignalAllBotsByOwnerName(owner_name)`.

# Notes
- Adds a way to signal all bots by owner name instead of only character ID.
2023-01-13 04:54:20 -06:00
Alex King f8afadf0a9 [Cleanup] Remove unused basic_functions.h (#2729)
# Notes
- This file is unused and not included in any other files.
2023-01-13 04:52:32 -06:00
Alex King 9c23882d67 [Cleanup] Remove unused maxskill.h. (#2728)
# Notes
- This file is unused, noticed it when looking through source. Nothing calls this method or includes this file.
2023-01-13 04:52:08 -06:00
Aeadoin 3510ba2493 [Bug Fix] Fix Aug Clicks where item has no click effect. (#2725) 2023-01-12 12:46:42 -05:00
247 changed files with 19563 additions and 7431 deletions
-21
View File
@@ -1,21 +0,0 @@
// For format details, see https://aka.ms/vscode-remote/devcontainer.json or this file's README at:
// https://github.com/microsoft/vscode-dev-containers/tree/v0.101.1/containers/ubuntu-18.04-git
{
"name": "Ubuntu 18.04 EQEMU",
// Moved from dockerfile to image so it builds faster
"image": "eqemu/devcontainer:0.0.2",
// Set *default* container specific settings.json values on container create.
"settings": {
"terminal.integrated.shell.linux": "/bin/bash"
},
"runArgs": [ "--cap-add=SYS_PTRACE", "--security-opt", "seccomp=unconfined" ],
// Add the IDs of extensions you want installed when the container is created.
"extensions": ["ms-vscode.cpptools", "ms-azuretools.vscode-docker"],
"mounts": ["source=/var/run/docker.sock,target=/var/run/docker.sock,type=bind"],
"remoteEnv": {
"HOST_PROJECT_PATH": "${localWorkspaceFolder}"
}
}
+74 -9
View File
@@ -1,7 +1,11 @@
---
kind: pipeline
type: docker
name: EQEmulator Server Linux CI
name: Build Linux
clone:
depth: 1
# Limits how many of these builds can run on the drone runner at a time, this isn't about cores
concurrency:
@@ -10,18 +14,79 @@ concurrency:
volumes:
- name: cache
host:
path: /var/lib/cache
path: /var/lib/cache-release
steps:
- name: server-build
# Source build script https://github.com/Akkadius/akk-stack/blob/master/containers/eqemu-server/Dockerfile#L20
- name: Build Linux X64
image: akkadius/eqemu-server:v11
environment:
GITHUB_TOKEN:
from_secret: GH_RELEASE_GITHUB_API_TOKEN
RCLONE_CONFIG_REMOTE_TYPE: ftp
RCLONE_FTP_HOST: drone.akkadius.com
RCLONE_FTP_USER: artifacts
RCLONE_FTP_PASS:
from_secret: RCLONE_FTP_PASS
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_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
- ./utils/scripts/build/linux-build.sh
volumes:
- name: cache
path: /home/eqemu/.ccache/
---
kind: pipeline
type: exec
name: Build Windows
clone:
depth: 1
platform:
os: windows
arch: amd64
steps:
- name: Build Windows X64
environment:
RCLONE_CONFIG_REMOTE_TYPE: ftp
RCLONE_FTP_HOST: drone.akkadius.com
RCLONE_FTP_USER: artifacts
RCLONE_FTP_PASS:
from_secret: RCLONE_FTP_PASS
GITHUB_TOKEN:
from_secret: GH_RELEASE_GITHUB_API_TOKEN
commands:
- .\utils\scripts\build\windows-build.ps1
---
kind: pipeline
type: docker
name: Publish Artifacts to Github
steps:
- name: Upload Artifacts
image: akkadius/eqemu-build-releaser:v3
environment:
RCLONE_CONFIG_REMOTE_TYPE: ftp
RCLONE_FTP_HOST: drone.akkadius.com
RCLONE_FTP_USER: artifacts
RCLONE_FTP_PASS:
from_secret: RCLONE_FTP_PASS
GH_RELEASE_GITHUB_API_TOKEN:
from_secret: GH_RELEASE_GITHUB_API_TOKEN
GITHUB_TOKEN:
from_secret: GH_RELEASE_GITHUB_API_TOKEN
commands:
- ./utils/scripts/build/should-release/should-release
- rclone config create remote ftp env_auth true > /dev/null
- |
rclone copy remote: --include "eqemu-server*.zip" .
- gh-release --assets=eqemu-server-linux-x64.zip,eqemu-server-windows-x64.zip -y
- |
rclone delete remote: --include "eqemu-server*.zip"
depends_on:
- Build Windows
- Build Linux
+9 -1
View File
@@ -59,4 +59,12 @@ bin/
# Clangd Generated Files.
compile_flags.txt
.cache/
.cache/
# vscode generated settings
.vscode/
# Build pipeline
!utils/scripts/build/
!utils/scripts/build/should-release/should-release
!utils/scripts/build/should-release/should-release.exe
-16
View File
@@ -1,16 +0,0 @@
{
"configurations": [
{
"name": "Linux",
"includePath": [
"${workspaceFolder}/**",
"/usr/include/mysql"
],
"defines": [],
"compilerPath": "/usr/bin/gcc",
"cStandard": "c11",
"cppStandard": "c++17"
}
],
"version": 4
}
-5
View File
@@ -1,5 +0,0 @@
{
"files.associations": {
"*.ipp": "cpp"
}
}
-164
View File
@@ -1,164 +0,0 @@
{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "2.0.0",
"tasks": [
{
"label": "make",
"type": "shell",
"command": "cd bin && make",
"group": {
"kind": "build",
"isDefault": true
},
"problemMatcher": [
"$gcc"
]
},
{
"label": "make clean",
"type": "shell",
"command": "cd bin && make clean",
"group": {
"kind": "build",
"isDefault": true
},
"problemMatcher": [
"$gcc"
]
},
{
"label": "cmake",
"type": "shell",
"command": "mkdir -p bin && cd bin && rm CMakeCache.txt && cmake -DEQEMU_BUILD_LOGIN=ON -DEQEMU_BUILD_LUA=ON -G 'Unix Makefiles' ..",
"group": {
"kind": "build",
"isDefault": true
},
"problemMatcher":{
"owner": "cpp",
"fileLocation": "relative",
"pattern":[
{
"regexp": "([\\w+|\\\\]*\\.\\w+)\\((\\d+)\\)\\: (warning|error) (.*)$",
"file": 1,
"location": 2,
"severity": 3,
"message": 4
}
]
}
},
{
"label": "download maps",
"type": "shell",
"command": "mkdir -p bin && cd bin && wget https://codeload.github.com/Akkadius/EQEmuMaps/zip/master -O maps.zip && unzip -o maps.zip && rm ./maps -rf && mv EQEmuMaps-master maps && rm maps.zip",
"group": {
"kind": "build",
"isDefault": true
},
"problemMatcher": [
"$gcc"
]
},
{
"label": "download quests",
"type": "shell",
"command": "mkdir -p bin && cd bin && cd server && git -C ./quests pull 2> /dev/null || git clone https://github.com/ProjectEQ/projecteqquests.git quests",
"group": {
"kind": "build",
"isDefault": true
},
"problemMatcher": [
"$gcc"
]
},
{
"label": "download eqemu_config",
"type": "shell",
"command": "mkdir -p bin && cd bin && wget --no-check-certificate https://raw.githubusercontent.com/Akkadius/EQEmuInstall/master/eqemu_config_docker.json -O eqemu_config.json",
"group": {
"kind": "build",
"isDefault": true
},
"problemMatcher": [
"$gcc"
]
},
{
"label": "rebuild database (mariadb must be started)",
"type": "shell",
"command": "mkdir -p bin && cd bin && docker run -i --rm --privileged -v ${HOST_PROJECT_PATH}/bin:/src --network=eqemu -it eqemu/server:0.0.3 bash -c './eqemu_server.pl source_peq_db && ./eqemu_server.pl check_db_updates && ./eqemu_server.pl linux_login_server_setup'",
"group": {
"kind": "build",
"isDefault": true
},
"problemMatcher": [
"$gcc"
]
},
{
"label": "zone 7000",
"type": "shell",
"command": "docker stop zone7000 | true && docker network create eqemu | true && docker run -i --rm --name zone7000 --cap-add=SYS_PTRACE --security-opt seccomp=unconfined --privileged -v ${HOST_PROJECT_PATH}/bin:/src --ulimit core=10000000 --network=eqemu -p 7000:7000/udp -e LD_LIBRARY_PATH=/src/ eqemu/server:0.0.3 gdb -ex run --args ./zone dynamic_zone7000:7000",
"group": {
"kind": "test",
"isDefault": true
}
},
{
"label": "zone 7001",
"type": "shell",
"command": "docker stop zone7001 | true && docker network create eqemu | true && docker run -i --rm --name zone7001 --cap-add=SYS_PTRACE --security-opt seccomp=unconfined --privileged -v ${HOST_PROJECT_PATH}/bin:/src --ulimit core=10000000 --network=eqemu -p 7001:7001/udp -e LD_LIBRARY_PATH=/src/ eqemu/server:0.0.3 gdb -ex run --args ./zone dynamic_zone7001:7001",
"group": {
"kind": "test",
"isDefault": true
}
},
{
"label": "loginserver",
"type": "shell",
"command": "docker stop loginserver | true && docker network create eqemu | true && docker run -i --rm --cap-add=SYS_PTRACE --security-opt seccomp=unconfined --privileged -v ${HOST_PROJECT_PATH}/bin:/src --ulimit core=10000000 --network=eqemu --name loginserver -p 5999:5999/udp -p 5998:5998/udp -e LD_LIBRARY_PATH=/src/ eqemu/server:0.0.3 gdb -ex run --args ./loginserver",
"group": {
"kind": "test",
"isDefault": true
}
},
{
"label": "shared_memory, world",
"type": "shell",
"command": "docker stop sharedmemory | true && docker stop world | true && docker network create eqemu | true && docker run --rm -v ${HOST_PROJECT_PATH}/bin:/src --network=eqemu --name sharedmemory eqemu/server:0.0.3 ./shared_memory && docker run --rm -v ${HOST_PROJECT_PATH}/bin:/src --ulimit core=10000000 -e LD_LIBRARY_PATH=/src/ --network=eqemu --name world -p 9000:9000 -p 9000:9000/udp -p 9001:9001 -p 9080:9080 eqemu/server:0.0.3 gdb -ex run ./world",
"group": {
"kind": "test",
"isDefault": true
}
},
{
"label": "queryserv",
"type": "shell",
"command": "docker stop queryserv | true && docker run --rm -v ${HOST_PROJECT_PATH}/bin:/src --ulimit core=10000000 -e LD_LIBRARY_PATH=/src/ --network=eqemu --name queryserv eqemu/server:0.0.3 gdb -ex run ./queryserv",
"group": {
"kind": "test",
"isDefault": true
}
},
{
"label": "mariadb",
"type": "shell",
"command": "docker stop mariadb | true && cd bin && docker network create eqemu | true && docker run --rm -v ${HOST_PROJECT_PATH}/bin/db:/bitnami/mariadb -p 3306:3306 -e MARIADB_DATABASE=peq -e MARIADB_USER=eqemu -e MARIADB_PASSWORD=eqemupass -e ALLOW_EMPTY_PASSWORD=yes --name mariadb --network=eqemu bitnami/mariadb:latest",
"group": {
"kind": "test",
"isDefault": true
}
},
{
"label": "ucs",
"type": "shell",
"command": "docker stop ucs | true && cd bin && docker network create eqemu | true && docker run --rm -v ${HOST_PROJECT_PATH}/bin:/src -p 7778:7778 --name ucs --network=eqemu eqemu/server:0.0.3 gdb -ex run ./ucs",
"group": {
"kind": "test",
"isDefault": true
}
}
]
}
+2 -2
View File
@@ -40,14 +40,14 @@ Assuming it is starting in c:/projects/eqemu and the x64 dependencies were extra
mkdir build
cd build
cmake -G "Visual Studio 15 2017 Win64" -DEQEMU_BUILD_TESTS=ON -DEQEMU_BUILD_LOGIN=ON -DEQEMU_BUILD_ZLIB=ON -DEQEMU_ENABLE_BOTS=ON -DCMAKE_TOOLCHAIN_FILE="c:/projects/eqemu/vcpkg/vcpkg-export-20180828-145455/scripts/buildsystems/vcpkg.cmake" ..
cmake -G "Visual Studio 15 2017 Win64" -DEQEMU_BUILD_TESTS=ON -DEQEMU_BUILD_LOGIN=ON -DEQEMU_BUILD_ZLIB=ON -DCMAKE_TOOLCHAIN_FILE="c:/projects/eqemu/vcpkg/vcpkg-export-20180828-145455/scripts/buildsystems/vcpkg.cmake" ..
##### Linux
Similarly to Windows running CMake on Linux is simple it just omits the toolchain file and uses a different generator.
mkdir build
cd build
cmake -G "Unix Makefiles" -DEQEMU_BUILD_TESTS=ON -DEQEMU_ENABLE_BOTS=ON -DEQEMU_BUILD_LOGIN=ON ..
cmake -G "Unix Makefiles" -DEQEMU_BUILD_TESTS=ON -DEQEMU_BUILD_LOGIN=ON ..
### Building
+47
View File
@@ -0,0 +1,47 @@
## [22.0.8]
### Release Test
Another release test (We're almost there!)
## [22.0.7]
### Release Test
Release test
## [22.0.6]
### Release Test
Release test with bots #2
## [22.0.5]
### Release Test
Release test with bots
## [22.0.4]
### Release Test
Release test with smaller Linux bins
## [22.0.3]
### Release Test
Testing Linux build in release
## [22.0.2]
### Release Without Bots
Testing release without bots
## [22.0.1]
### Stable Releases
- Testing stable releases
+1 -10
View File
@@ -23,6 +23,7 @@ IF(MSVC)
ADD_DEFINITIONS(-D_HAS_AUTO_PTR_ETC) # for Luabind on C++17
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /MP")
ADD_DEFINITIONS( "/W0 /D_CRT_SECURE_NO_WARNINGS /wd4005 /wd4996 /nologo /Os")
ELSE(MSVC)
ADD_DEFINITIONS(-DHAS_UNION_SEMUN)
ENDIF(MSVC)
@@ -122,7 +123,6 @@ ENDIF()
MESSAGE(STATUS "**************************************************")
#options
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)
OPTION(EQEMU_BUILD_LOGIN "Build the login server." ON)
@@ -176,10 +176,6 @@ IF(EQEMU_COMMANDS_LOGGING)
ADD_DEFINITIONS(-DCOMMANDS_LOGGING)
ENDIF(EQEMU_COMMANDS_LOGGING)
IF(EQEMU_ENABLE_BOTS)
ADD_DEFINITIONS(-DBOTS)
ENDIF(EQEMU_ENABLE_BOTS)
#database
IF(MySQL_FOUND AND MariaDB_FOUND)
SET(DATABASE_LIBRARY_SELECTION MariaDB CACHE STRING "Database library to use:
@@ -343,11 +339,6 @@ INCLUDE_DIRECTORIES(SYSTEM "${CMAKE_CURRENT_SOURCE_DIR}/submodules/websocketpp")
# silence obnoxious deprecation message
ADD_DEFINITIONS(-DBOOST_BIND_GLOBAL_PLACEHOLDERS)
OPTION(EQEMU_BUILD_LOGGING "Build Logging (To speed up compilation)" ON)
IF(EQEMU_BUILD_LOGGING)
ADD_DEFINITIONS(-DBUILD_LOGGING)
ENDIF()
IF(TLS_LIBRARY_ENABLED)
SET(SERVER_LIBS ${SERVER_LIBS} ${TLS_LIBRARY_LIBS})
INCLUDE_DIRECTORIES(SYSTEM "${TLS_LIBRARY_INCLUDE}")
+1 -1
View File
@@ -9,7 +9,7 @@ init:
- ps: git config --global core.autocrlf input
cache: c:\tools\vcpkg\installed\
before_build:
- ps: "$wc = New-Object System.Net.WebClient\n$wc.DownloadFile(\"http://strawberryperl.com/download/5.26.2.1/strawberry-perl-5.26.2.1-64bit-portable.zip\", \"c:\\projects\\eqemu\\strawberry-perl-5.26.2.1-64bit-portable.zip\")\ncd c:\\projects\\eqemu\n7z x c:/projects/eqemu/strawberry-perl-5.26.2.1-64bit-portable.zip -oc:/projects/eqemu/strawberry-perl-portable -y\n(Get-Content C:/projects/eqemu/strawberry-perl-portable/perl/lib/CORE/config.h).replace('#define PERL_STATIC_INLINE static __inline__', '#define PERL_STATIC_INLINE static __inline') | Set-Content C:/projects/eqemu/strawberry-perl-portable/perl/lib/CORE/config.h\nvcpkg install boost-geometry:x64-windows boost-dynamic-bitset:x64-windows luajit:x64-windows libsodium:x64-windows libmysql:x64-windows openssl:x64-windows zlib:x64-windows \nmkdir build\ncd build\ncmake -G \"Visual Studio 15 2017 Win64\" -DEQEMU_BUILD_TESTS=ON -DEQEMU_BUILD_LOGIN=ON -EQEMU_ENABLE_BOTS=ON -DPERL_EXECUTABLE=\"C:/projects/eqemu/strawberry-perl-portable/perl/bin/perl.exe\" -DPERL_INCLUDE_PATH=\"C:/projects/eqemu/strawberry-perl-portable/perl/lib/CORE\" -DPERL_LIBRARY=\"C:/projects/eqemu/strawberry-perl-portable/perl/lib/CORE/libperl526.a\" -DCMAKE_TOOLCHAIN_FILE=\"c:/tools/vcpkg/scripts/buildsystems/vcpkg.cmake\" .."
- ps: "$wc = New-Object System.Net.WebClient\n$wc.DownloadFile(\"http://strawberryperl.com/download/5.26.2.1/strawberry-perl-5.26.2.1-64bit-portable.zip\", \"c:\\projects\\eqemu\\strawberry-perl-5.26.2.1-64bit-portable.zip\")\ncd c:\\projects\\eqemu\n7z x c:/projects/eqemu/strawberry-perl-5.26.2.1-64bit-portable.zip -oc:/projects/eqemu/strawberry-perl-portable -y\n(Get-Content C:/projects/eqemu/strawberry-perl-portable/perl/lib/CORE/config.h).replace('#define PERL_STATIC_INLINE static __inline__', '#define PERL_STATIC_INLINE static __inline') | Set-Content C:/projects/eqemu/strawberry-perl-portable/perl/lib/CORE/config.h\nvcpkg install boost-geometry:x64-windows boost-dynamic-bitset:x64-windows luajit:x64-windows libsodium:x64-windows libmysql:x64-windows openssl:x64-windows zlib:x64-windows \nmkdir build\ncd build\ncmake -G \"Visual Studio 15 2017 Win64\" -DEQEMU_BUILD_TESTS=ON -DEQEMU_BUILD_LOGIN=ON -DPERL_EXECUTABLE=\"C:/projects/eqemu/strawberry-perl-portable/perl/bin/perl.exe\" -DPERL_INCLUDE_PATH=\"C:/projects/eqemu/strawberry-perl-portable/perl/lib/CORE\" -DPERL_LIBRARY=\"C:/projects/eqemu/strawberry-perl-portable/perl/lib/CORE/libperl526.a\" -DCMAKE_TOOLCHAIN_FILE=\"c:/tools/vcpkg/scripts/buildsystems/vcpkg.cmake\" .."
build:
project: C:\projects\eqemu\build\EQEmu.sln
parallel: true
+1 -1
View File
@@ -9,7 +9,7 @@ init:
- ps: git config --global core.autocrlf input
cache: c:\tools\vcpkg\installed\
before_build:
- ps: "$wc = New-Object System.Net.WebClient\n$wc.DownloadFile(\"http://strawberryperl.com/download/5.26.2.1/strawberry-perl-5.26.2.1-64bit-portable.zip\", \"c:\\projects\\eqemu\\strawberry-perl-5.26.2.1-64bit-portable.zip\")\ncd c:\\projects\\eqemu\n7z x c:/projects/eqemu/strawberry-perl-5.26.2.1-64bit-portable.zip -oc:/projects/eqemu/strawberry-perl-portable -y\n(Get-Content C:/projects/eqemu/strawberry-perl-portable/perl/lib/CORE/config.h).replace('#define PERL_STATIC_INLINE static __inline__', '#define PERL_STATIC_INLINE static __inline') | Set-Content C:/projects/eqemu/strawberry-perl-portable/perl/lib/CORE/config.h\nvcpkg install boost-geometry:x64-windows boost-dynamic-bitset:x64-windows luajit:x64-windows libsodium:x64-windows libmysql:x64-windows openssl:x64-windows zlib:x64-windows \nmkdir build\ncd build\ncmake -G \"Visual Studio 15 2017 Win64\" -DEQEMU_BUILD_TESTS=ON -DEQEMU_BUILD_LOGIN=ON -EQEMU_ENABLE_BOTS=OFF -DPERL_EXECUTABLE=\"C:/projects/eqemu/strawberry-perl-portable/perl/bin/perl.exe\" -DPERL_INCLUDE_PATH=\"C:/projects/eqemu/strawberry-perl-portable/perl/lib/CORE\" -DPERL_LIBRARY=\"C:/projects/eqemu/strawberry-perl-portable/perl/lib/CORE/libperl526.a\" -DCMAKE_TOOLCHAIN_FILE=\"c:/tools/vcpkg/scripts/buildsystems/vcpkg.cmake\" .."
- ps: "$wc = New-Object System.Net.WebClient\n$wc.DownloadFile(\"http://strawberryperl.com/download/5.26.2.1/strawberry-perl-5.26.2.1-64bit-portable.zip\", \"c:\\projects\\eqemu\\strawberry-perl-5.26.2.1-64bit-portable.zip\")\ncd c:\\projects\\eqemu\n7z x c:/projects/eqemu/strawberry-perl-5.26.2.1-64bit-portable.zip -oc:/projects/eqemu/strawberry-perl-portable -y\n(Get-Content C:/projects/eqemu/strawberry-perl-portable/perl/lib/CORE/config.h).replace('#define PERL_STATIC_INLINE static __inline__', '#define PERL_STATIC_INLINE static __inline') | Set-Content C:/projects/eqemu/strawberry-perl-portable/perl/lib/CORE/config.h\nvcpkg install boost-geometry:x64-windows boost-dynamic-bitset:x64-windows luajit:x64-windows libsodium:x64-windows libmysql:x64-windows openssl:x64-windows zlib:x64-windows \nmkdir build\ncd build\ncmake -G \"Visual Studio 15 2017 Win64\" -DEQEMU_BUILD_TESTS=ON -DEQEMU_BUILD_LOGIN=ON -DPERL_EXECUTABLE=\"C:/projects/eqemu/strawberry-perl-portable/perl/bin/perl.exe\" -DPERL_INCLUDE_PATH=\"C:/projects/eqemu/strawberry-perl-portable/perl/lib/CORE\" -DPERL_LIBRARY=\"C:/projects/eqemu/strawberry-perl-portable/perl/lib/CORE/libperl526.a\" -DCMAKE_TOOLCHAIN_FILE=\"c:/tools/vcpkg/scripts/buildsystems/vcpkg.cmake\" .."
build:
project: C:\projects\eqemu\build\EQEmu.sln
parallel: true
+5
View File
@@ -182,6 +182,8 @@ SET(repositories
repositories/base/base_char_create_combinations_repository.h
repositories/base/base_char_create_point_allocations_repository.h
repositories/base/base_char_recipe_list_repository.h
repositories/base/base_chatchannels_repository.h
repositories/base/base_chatchannel_reserved_names_repository.h
repositories/base/base_completed_shared_tasks_repository.h
repositories/base/base_completed_shared_task_activity_state_repository.h
repositories/base/base_completed_shared_task_members_repository.h
@@ -358,6 +360,8 @@ SET(repositories
repositories/char_create_combinations_repository.h
repositories/char_create_point_allocations_repository.h
repositories/char_recipe_list_repository.h
repositories/chatchannels_repository.h
repositories/chatchannel_reserved_names_repository.h
repositories/completed_shared_tasks_repository.h
repositories/completed_shared_task_activity_state_repository.h
repositories/completed_shared_task_members_repository.h
@@ -652,6 +656,7 @@ SET(common_headers
patches/uf_limits.h
patches/uf_ops.h
patches/uf_structs.h
termcolor/rang.hpp
stacktrace/backward.hpp
StackWalker/StackWalker.h
util/memory_stream.h
+1
View File
@@ -20,6 +20,7 @@
#include "../common/types.h"
#define NO_CLASS 0
#define WARRIOR 1
#define CLERIC 2
#define PALADIN 3
+28 -26
View File
@@ -71,11 +71,11 @@ bool Database::Connect(const char* host, const char* user, const char* passwd, c
uint32 errnum= 0;
char errbuf[MYSQL_ERRMSG_SIZE];
if (!Open(host, user, passwd, database, port, &errnum, errbuf)) {
LogError("[MySQL] Connection [{}] Failed to connect to database: Error [{}]", connection_label, errbuf);
LogError("Connection [{}] Failed to connect to database Error [{}]", connection_label, errbuf);
return false;
}
else {
LogInfo("[MySQL] Connection [{}] database [{}] at [{}]:[{}]", connection_label, database, host,port);
LogInfo("Connected to database [{}] [{}] @ [{}:{}]", connection_label, database, host,port);
return true;
}
}
@@ -391,15 +391,10 @@ bool Database::DeleteCharacter(char *character_name)
}
if (character_id <= 0) {
LogError("[DeleteCharacter] Invalid Character ID [{}]", character_name);
LogError("Invalid Character ID [{}]", character_name);
return false;
}
#ifdef BOTS
query = StringFormat("DELETE FROM `guild_members` WHERE `char_id` = '%d' AND GetMobTypeById(%i) = 'C'", character_id); // note: only use of GetMobTypeById()
QueryDatabase(query);
#endif
std::string delete_type = "hard-deleted";
if (RuleB(Character, SoftDeletes)) {
delete_type = "soft-deleted";
@@ -418,21 +413,26 @@ bool Database::DeleteCharacter(char *character_name)
QueryDatabase(query);
#ifdef BOTS
query = fmt::format(
SQL(
UPDATE
bot_data
SET
name = SUBSTRING(CONCAT(name, '-deleted-', UNIX_TIMESTAMP()), 1, 64)
WHERE
owner_id = '{}'
),
character_id
);
QueryDatabase(query);
LogInfo("[DeleteCharacter] character_name [{}] ({}) bots are being [{}]", character_name, character_id, delete_type);
#endif
if (RuleB(Bots, Enabled)) {
query = fmt::format(
SQL(
UPDATE
bot_data
SET
name = SUBSTRING(CONCAT(name, '-deleted-', UNIX_TIMESTAMP()), 1, 64)
WHERE
owner_id = '{}'
),
character_id
);
QueryDatabase(query);
LogInfo(
"[DeleteCharacter] character_name [{}] ({}) bots are being [{}]",
character_name,
character_id,
delete_type
);
}
return true;
}
@@ -444,7 +444,7 @@ bool Database::DeleteCharacter(char *character_name)
QueryDatabase(fmt::format("DELETE FROM {} WHERE {} = {}", table_name, character_id_column_name, character_id));
}
LogInfo("[DeleteCharacter] character_name [{}] ({}) is being [{}]", character_name, character_id, delete_type);
LogInfo("character_name [{}] ({}) is being [{}]", character_name, character_id, delete_type);
return true;
}
@@ -975,6 +975,8 @@ bool Database::LoadVariables() {
varcache.Add(key, value);
}
LogInfo("Loaded [{}] variable(s)", Strings::Commify(std::to_string(results.RowCount())));
return true;
}
@@ -2354,7 +2356,7 @@ void Database::SourceDatabaseTableFromUrl(std::string table_name, std::string ur
uri request_uri(url);
LogHTTP(
"[SourceDatabaseTableFromUrl] parsing url [{}] path [{}] host [{}] query_string [{}] protocol [{}] port [{}]",
"parsing url [{}] path [{}] host [{}] query_string [{}] protocol [{}] port [{}]",
url,
request_uri.get_path(),
request_uri.get_host(),
@@ -2408,7 +2410,7 @@ void Database::SourceDatabaseTableFromUrl(std::string table_name, std::string ur
}
catch (std::invalid_argument iae) {
LogError("[SourceDatabaseTableFromUrl] URI parser error [{}]", iae.what());
LogError("URI parser error [{}]", iae.what());
}
}
+36 -77
View File
@@ -118,109 +118,53 @@ std::string DatabaseDumpService::GetBaseMySQLDumpCommand()
);
}
/**
* @return
*/
std::string DatabaseDumpService::GetPlayerTablesList()
{
std::string tables_list;
std::vector<std::string> tables = DatabaseSchema::GetPlayerTables();
for (const auto &table : tables) {
tables_list += table + " ";
}
return Strings::Trim(tables_list);
return Strings::Join(DatabaseSchema::GetPlayerTables(), " ");
}
/**
* @return
*/
std::string DatabaseDumpService::GetBotTablesList()
{
std::string tables_list;
std::vector<std::string> tables = DatabaseSchema::GetBotTables();
for (const auto &table : tables) {
tables_list += table + " ";
}
return Strings::Trim(tables_list);
return Strings::Join(DatabaseSchema::GetBotTables(), " ");
}
std::string DatabaseDumpService::GetMercTablesList()
{
return Strings::Join(DatabaseSchema::GetMercTables(), " ");
}
/**
* @return
*/
std::string DatabaseDumpService::GetLoginTableList()
{
std::string tables_list;
std::vector<std::string> tables = DatabaseSchema::GetLoginTables();
for (const auto &table : tables) {
tables_list += table + " ";
}
return Strings::Trim(tables_list);
return Strings::Join(DatabaseSchema::GetLoginTables(), " ");
}
/**
* @return
*/
std::string DatabaseDumpService::GetQueryServTables()
{
std::string tables_list;
std::vector<std::string> tables = DatabaseSchema::GetQueryServerTables();
for (const auto &table : tables) {
tables_list += table + " ";
}
return Strings::Trim(tables_list);
return Strings::Join(DatabaseSchema::GetQueryServerTables(), " ");
}
/**
* @return
*/
std::string DatabaseDumpService::GetSystemTablesList()
{
std::string tables_list;
auto system_tables = DatabaseSchema::GetServerTables();
auto version_tables = DatabaseSchema::GetVersionTables();
std::vector<std::string> tables = DatabaseSchema::GetServerTables();
for (const auto &table : tables) {
tables_list += table + " ";
}
system_tables.insert(
std::end(system_tables),
std::begin(version_tables),
std::end(version_tables)
);
tables = DatabaseSchema::GetVersionTables();
for (const auto &table : tables) {
tables_list += table + " ";
}
return Strings::Trim(tables_list);
return Strings::Join(system_tables, " ");
}
/**
* @return
*/
std::string DatabaseDumpService::GetStateTablesList()
{
std::string tables_list;
std::vector<std::string> tables = DatabaseSchema::GetStateTables();
for (const auto &table : tables) {
tables_list += table + " ";
}
return Strings::Trim(tables_list);
return Strings::Join(DatabaseSchema::GetStateTables(), " ");
}
/**
* @return
*/
std::string DatabaseDumpService::GetContentTablesList()
{
std::string tables_list;
std::vector<std::string> tables = DatabaseSchema::GetContentTables();
for (const auto &table : tables) {
tables_list += table + " ";
}
return Strings::Trim(tables_list);
return Strings::Join(DatabaseSchema::GetContentTables(), " ");
}
/**
@@ -306,6 +250,11 @@ void DatabaseDumpService::Dump()
dump_descriptor += "-bots";
}
if (IsDumpMercTables()) {
tables_to_dump += GetMercTablesList() + " ";
dump_descriptor += "-mercs";
}
if (IsDumpSystemTables()) {
tables_to_dump += GetSystemTablesList() + " ";
dump_descriptor += "-system";
@@ -375,7 +324,7 @@ void DatabaseDumpService::Dump()
}
if (!tables_to_dump.empty()) {
LogInfo("Dumping Tables [{}]", tables_to_dump);
LogInfo("Dumping Tables [{}]", Strings::Trim(tables_to_dump));
}
LogInfo("Database dump created at [{}.sql]", GetDumpFileNameWithPath());
@@ -576,3 +525,13 @@ void DatabaseDumpService::SetDumpBotTables(bool dump_bot_tables)
{
DatabaseDumpService::dump_bot_tables = dump_bot_tables;
}
bool DatabaseDumpService::IsDumpMercTables() const
{
return dump_merc_tables;
}
void DatabaseDumpService::SetDumpMercTables(bool dump_merc_tables)
{
DatabaseDumpService::dump_merc_tables = dump_merc_tables;
}
+4
View File
@@ -55,6 +55,8 @@ public:
void SetDumpStateTables(bool dump_state_tables);
bool IsDumpBotTables() const;
void SetDumpBotTables(bool dump_bot_tables);
bool IsDumpMercTables() const;
void SetDumpMercTables(bool dump_bot_tables);
private:
bool dump_all_tables = false;
@@ -70,6 +72,7 @@ private:
bool dump_output_to_console = false;
bool dump_drop_table_syntax_only = false;
bool dump_bot_tables = false;
bool dump_merc_tables = false;
std::string dump_path;
std::string dump_file_name;
@@ -78,6 +81,7 @@ private:
std::string GetBaseMySQLDumpCommand();
std::string GetPlayerTablesList();
std::string GetBotTablesList();
std::string GetMercTablesList();
std::string GetSystemTablesList();
std::string GetStateTablesList();
std::string GetContentTablesList();
+6
View File
@@ -476,6 +476,12 @@ bool Database::CheckDatabaseConversions() {
CheckDatabaseConvertPPDeblob();
CheckDatabaseConvertCorpseDeblob();
RuleManager::Instance()->LoadRules(this, "default", false);
if (!RuleB(Bots, Enabled) && DoesTableExist("bot_data")) {
LogInfo("Bot tables found but rule not enabled, enabling");
RuleManager::Instance()->SetRule("Bots:Enabled", "true", this, true, true);
}
/* Run EQEmu Server script (Checks for database updates) */
const std::string file = fmt::format("{}/eqemu_server.pl", path.GetServerPath());
+24 -3
View File
@@ -332,7 +332,9 @@ namespace DatabaseSchema {
"ip_exemptions",
"item_tick",
"lfguild",
"merc_buffs",
"merchantlist_temp",
"mercs",
"object_contents",
"raid_details",
"raid_leaders",
@@ -406,9 +408,28 @@ namespace DatabaseSchema {
"bot_spell_settings",
"bot_spells_entries",
"bot_stances",
"bot_timers",
"vw_bot_character_mobs",
"vw_bot_groups"
"bot_timers"
};
}
static std::vector<std::string> GetMercTables()
{
return {
"merc_armorinfo",
"merc_inventory",
"merc_merchant_entries",
"merc_merchant_template_entries",
"merc_merchant_templates",
"merc_name_types",
"merc_npc_types",
"merc_spell_list_entries",
"merc_spell_lists",
"merc_stance_entries",
"merc_stats",
"merc_subtypes",
"merc_templates",
"merc_types",
"merc_weaponinfo"
};
}
+2 -2
View File
@@ -167,7 +167,7 @@ MySQLRequestResult DBcore::QueryDatabase(const char *query, uint32 querylen, boo
if (LogSys.log_settings[Logs::MySQLQuery].is_category_enabled == 1) {
if ((strncasecmp(query, "select", 6) == 0)) {
LogMySQLQuery(
"{0}; -- ({1} row{2} returned) ({3}s)",
"{0} -- ({1} row{2} returned) ({3}s)",
query,
requestResult.RowCount(),
requestResult.RowCount() == 1 ? "" : "s",
@@ -176,7 +176,7 @@ MySQLRequestResult DBcore::QueryDatabase(const char *query, uint32 querylen, boo
}
else {
LogMySQLQuery(
"{0}; -- ({1} row{2} affected) ({3}s)",
"{0} -- ({1} row{2} affected) ({3}s)",
query,
requestResult.RowsAffected(),
requestResult.RowsAffected() == 1 ? "" : "s",
+1 -1
View File
@@ -48,7 +48,7 @@ void Discord::SendWebhookMessage(const std::string &message, const std::string &
while (retry) {
if (auto res = cli.Post(endpoint.c_str(), payload.str(), "application/json")) {
if (res->status != 200 && res->status != 204) {
LogError("[Discord Client] Code [{}] Error [{}]", res->status, res->body);
LogError("Code [{}] Error [{}]", res->status, res->body);
}
if (res->status == 429) {
if (!res->body.empty()) {
+149 -177
View File
@@ -22,21 +22,19 @@
#include "rulesys.h"
#include "platform.h"
#include "strings.h"
#include "misc.h"
#include "discord/discord.h"
#include "repositories/discord_webhooks_repository.h"
#include "repositories/logsys_categories_repository.h"
#include "termcolor/rang.hpp"
#include <iostream>
#include <fstream>
#include <string>
#include <iomanip>
#include <time.h>
#include <sys/stat.h>
#include <algorithm>
std::ofstream process_log;
#include <filesystem>
#ifdef _WINDOWS
#include <direct.h>
#include <conio.h>
@@ -52,46 +50,12 @@ std::ofstream process_log;
#endif
/**
* Linux ANSI console color defines
*/
#define LC_RESET "\033[0m"
#define LC_BLACK "\033[30m" /* Black */
#define LC_RED "\033[31m" /* Red */
#define LC_GREEN "\033[32m" /* Green */
#define LC_YELLOW "\033[33m" /* Yellow */
#define LC_BLUE "\033[34m" /* Blue */
#define LC_MAGENTA "\033[35m" /* Magenta */
#define LC_CYAN "\033[36m" /* Cyan */
#define LC_WHITE "\033[37m" /* White */
namespace Console {
enum Color {
Black = 0,
Blue = 1,
Green = 2,
Cyan = 3,
Red = 4,
Magenta = 5,
Brown = 6,
LightGray = 7,
DarkGray = 8,
LightBlue = 9,
LightGreen = 10,
LightCyan = 11,
LightRed = 12,
LightMagenta = 13,
Yellow = 14,
White = 15
};
}
/**
* EQEmuLogSys Constructor
*/
EQEmuLogSys::EQEmuLogSys()
{
m_on_log_gmsay_hook = [](uint16 log_type, const std::string &) {};
m_on_log_gmsay_hook = [](uint16 log_type, const char *func, const std::string &) {};
m_on_log_console_hook = [](uint16 log_type, const std::string &) {};
}
@@ -120,14 +84,8 @@ EQEmuLogSys *EQEmuLogSys::LoadLogSettingsDefaults()
/**
* Set Defaults
*/
log_settings[Logs::WorldServer].log_to_console = static_cast<uint8>(Logs::General);
log_settings[Logs::ZoneServer].log_to_console = static_cast<uint8>(Logs::General);
log_settings[Logs::QSServer].log_to_console = static_cast<uint8>(Logs::General);
log_settings[Logs::UCSServer].log_to_console = static_cast<uint8>(Logs::General);
log_settings[Logs::Crash].log_to_console = static_cast<uint8>(Logs::General);
log_settings[Logs::MySQLError].log_to_console = static_cast<uint8>(Logs::General);
log_settings[Logs::Loginserver].log_to_console = static_cast<uint8>(Logs::General);
log_settings[Logs::HeadlessClient].log_to_console = static_cast<uint8>(Logs::General);
log_settings[Logs::NPCScaling].log_to_gmsay = static_cast<uint8>(Logs::General);
log_settings[Logs::HotReload].log_to_gmsay = static_cast<uint8>(Logs::General);
log_settings[Logs::HotReload].log_to_console = static_cast<uint8>(Logs::General);
@@ -146,12 +104,8 @@ EQEmuLogSys *EQEmuLogSys::LoadLogSettingsDefaults()
/**
* RFC 5424
*/
log_settings[Logs::Emergency].log_to_console = static_cast<uint8>(Logs::General);
log_settings[Logs::Alert].log_to_console = static_cast<uint8>(Logs::General);
log_settings[Logs::Critical].log_to_console = static_cast<uint8>(Logs::General);
log_settings[Logs::Error].log_to_console = static_cast<uint8>(Logs::General);
log_settings[Logs::Warning].log_to_console = static_cast<uint8>(Logs::General);
log_settings[Logs::Notice].log_to_console = static_cast<uint8>(Logs::General);
log_settings[Logs::Info].log_to_console = static_cast<uint8>(Logs::General);
/**
@@ -196,24 +150,6 @@ EQEmuLogSys *EQEmuLogSys::LoadLogSettingsDefaults()
return this;
}
/**
* @param log_category
* @return
*/
bool EQEmuLogSys::IsRfc5424LogCategory(uint16 log_category)
{
return (
log_category == Logs::Emergency ||
log_category == Logs::Alert ||
log_category == Logs::Critical ||
log_category == Logs::Error ||
log_category == Logs::Warning ||
log_category == Logs::Notice ||
log_category == Logs::Info ||
log_category == Logs::Debug
);
}
/**
* @param debug_level
* @param log_category
@@ -244,66 +180,6 @@ void EQEmuLogSys::ProcessLogWrite(
}
}
/**
* @param log_category
* @return
*/
uint16 EQEmuLogSys::GetWindowsConsoleColorFromCategory(uint16 log_category)
{
switch (log_category) {
case Logs::Status:
case Logs::Normal:
return Console::Color::Yellow;
case Logs::MySQLError:
case Logs::Error:
case Logs::QuestErrors:
return Console::Color::LightRed;
case Logs::MySQLQuery:
case Logs::Debug:
return Console::Color::LightGreen;
case Logs::Quests:
return Console::Color::LightCyan;
case Logs::Commands:
case Logs::Mercenaries:
return Console::Color::LightMagenta;
case Logs::Crash:
return Console::Color::LightRed;
default:
return Console::Color::Yellow;
}
}
/**
* @param log_category
* @return
*/
std::string EQEmuLogSys::GetLinuxConsoleColorFromCategory(uint16 log_category)
{
switch (log_category) {
case Logs::Status:
case Logs::Normal:
return LC_YELLOW;
case Logs::MySQLError:
case Logs::QuestErrors:
case Logs::Warning:
case Logs::Critical:
case Logs::Error:
return LC_RED;
case Logs::MySQLQuery:
case Logs::Debug:
return LC_GREEN;
case Logs::Quests:
return LC_CYAN;
case Logs::Commands:
case Logs::Mercenaries:
return LC_MAGENTA;
case Logs::Crash:
return LC_RED;
default:
return LC_YELLOW;
}
}
/**
* @param log_category
* @return
@@ -311,9 +187,6 @@ std::string EQEmuLogSys::GetLinuxConsoleColorFromCategory(uint16 log_category)
uint16 EQEmuLogSys::GetGMSayColorFromCategory(uint16 log_category)
{
switch (log_category) {
case Logs::Status:
case Logs::Normal:
return Chat::Yellow;
case Logs::MySQLError:
case Logs::QuestErrors:
case Logs::Error:
@@ -333,28 +206,144 @@ uint16 EQEmuLogSys::GetGMSayColorFromCategory(uint16 log_category)
}
}
/**
* @param debug_level
* @param log_category
* @param message
*/
void EQEmuLogSys::ProcessConsoleMessage(uint16 log_category, const std::string &message)
void EQEmuLogSys::ProcessConsoleMessage(
uint16 log_category,
const std::string &message,
const char *file,
const char *func,
int line
)
{
#ifdef _WINDOWS
HANDLE console_handle;
console_handle = GetStdHandle(STD_OUTPUT_HANDLE);
CONSOLE_FONT_INFOEX info = { 0 };
info.cbSize = sizeof(info);
info.dwFontSize.Y = 12; // leave X as zero
info.FontWeight = FW_NORMAL;
wcscpy(info.FaceName, L"Lucida Console");
SetCurrentConsoleFontEx(console_handle, NULL, &info);
SetConsoleTextAttribute(console_handle, EQEmuLogSys::GetWindowsConsoleColorFromCategory(log_category));
std::cout << message << "\n";
SetConsoleTextAttribute(console_handle, Console::Color::White);
#else
std::cout << EQEmuLogSys::GetLinuxConsoleColorFromCategory(log_category) << message << LC_RESET << std::endl;
#endif
bool is_error = (
log_category == Logs::LogCategory::Error ||
log_category == Logs::LogCategory::MySQLError ||
log_category == Logs::LogCategory::Crash ||
log_category == Logs::LogCategory::QuestErrors
);
bool is_warning = (
log_category == Logs::LogCategory::Warning
);
(!is_error ? std::cout : std::cerr)
<< ""
<< rang::fgB::black
<< rang::style::bold
<< fmt::format("{:>6}", GetPlatformName().substr(0, 6))
<< rang::style::reset
<< rang::fgB::gray
<< " | "
<< ((is_error || is_warning) ? rang::fgB::red : rang::fgB::gray)
<< rang::style::bold
<< fmt::format("{:^10}", fmt::format("{}", Logs::LogCategoryName[log_category]).substr(0, 10))
<< rang::style::reset
<< rang::fgB::gray
<< " | "
<< rang::fgB::gray
<< rang::style::bold
<< fmt::format("{}", func)
<< rang::style::reset
<< rang::fgB::gray
<< " ";
if (RuleB(Logging, PrintFileFunctionAndLine)) {
(!is_error ? std::cout : std::cerr)
<< ""
<< rang::fgB::green
<< rang::style::bold
<< fmt::format("{:}", fmt::format("{}:{}:{}", std::filesystem::path(file).filename().string(), func, line))
<< rang::style::reset
<< " | ";
}
if (log_category == Logs::LogCategory::MySQLQuery) {
auto s = Strings::Split(message, "--");
if (s.size() > 1) {
std::string query = Strings::Trim(s[0]);
std::string meta = Strings::Trim(s[1]);
std::cout <<
rang::fgB::green
<<
query
<<
rang::style::reset;
std::cout <<
rang::fgB::black
<<
" -- "
<<
meta
<<
rang::style::reset;
}
}
else if (Strings::Contains(message, "[")) {
for (auto &e: Strings::Split(message, " ")) {
if (Strings::Contains(e, "[") && Strings::Contains(e, "]")) {
e = Strings::Replace(e, "[", "");
e = Strings::Replace(e, "]", "");
bool is_upper = false;
for (int i = 0; i < strlen(e.c_str()); i++) {
if (isupper(e[i])) {
is_upper = true;
}
}
if (!is_upper) {
(!is_error ? std::cout : std::cerr)
<< rang::fgB::gray
<< "["
<< rang::style::bold
<< rang::fgB::yellow
<< e
<< rang::fgB::gray
<< "] "
;
}
else {
(!is_error ? std::cout : std::cerr) << rang::fgB::gray << "[" << e << "] ";
}
}
else {
(!is_error ? std::cout : std::cerr)
<< (is_error ? rang::fgB::red : rang::fgB::gray)
<< e
<< " ";
}
}
}
else {
(!is_error ? std::cout : std::cerr)
<< (is_error ? rang::fgB::red : rang::fgB::gray)
<< message
<< " ";
}
if (!origination_info.zone_short_name.empty()) {
(!is_error ? std::cout : std::cerr)
<<
rang::fgB::black
<<
"-- "
<<
fmt::format(
"[{}] ({}) inst_id [{}]",
origination_info.zone_short_name,
origination_info.zone_long_name,
origination_info.instance_id
);
}
(!is_error ? std::cout : std::cerr) << rang::style::reset << std::endl;
m_on_log_console_hook(log_category, message);
}
@@ -368,33 +357,6 @@ constexpr const char *str_end(const char *str)
return *str ? str_end(str + 1) : str;
}
/**
* @param str
* @return
*/
constexpr bool str_slant(const char *str)
{
return *str == '/' ? true : (*str ? str_slant(str + 1) : false);
}
/**
* @param str
* @return
*/
constexpr const char *r_slant(const char *str)
{
return *str == '/' ? (str + 1) : r_slant(str - 1);
}
/**
* @param str
* @return
*/
constexpr const char *base_file_name(const char *str)
{
return str_slant(str) ? r_slant(str_end(str)) : str;
}
/**
* Core logging function
*
@@ -422,7 +384,7 @@ void EQEmuLogSys::Out(
std::string prefix;
if (RuleB(Logging, PrintFileFunctionAndLine)) {
prefix = fmt::format("[{0}::{1}:{2}] ", base_file_name(file), func, line);
prefix = fmt::format("[{0}::{1}:{2}] ", std::filesystem::path(file).filename().string(), func, line);
}
// remove this when we remove all legacy logs
@@ -445,11 +407,14 @@ void EQEmuLogSys::Out(
if (l.log_to_console_enabled) {
EQEmuLogSys::ProcessConsoleMessage(
log_category,
fmt::format("[{}] [{}] {}", GetPlatformName(), Logs::LogCategoryName[log_category], prefix + output_message)
output_message,
file,
func,
line
);
}
if (l.log_to_gmsay_enabled) {
m_on_log_gmsay_hook(log_category, output_message);
m_on_log_gmsay_hook(log_category, func, output_message);
}
if (l.log_to_file_enabled) {
EQEmuLogSys::ProcessLogWrite(
@@ -563,6 +528,8 @@ void EQEmuLogSys::SilenceConsoleLogging()
log_settings[log_index].log_to_console = 0;
log_settings[log_index].is_category_enabled = 0;
}
log_settings[Logs::Crash].log_to_console = static_cast<uint8>(Logs::General);
}
/**
@@ -667,6 +634,11 @@ EQEmuLogSys *EQEmuLogSys::LoadLogDatabaseSettings()
LogInfo("Loaded [{}] Discord webhooks", webhooks.size());
}
// force override this setting
log_settings[Logs::Crash].log_to_console = static_cast<uint8>(Logs::General);
log_settings[Logs::Crash].log_to_gmsay = static_cast<uint8>(Logs::General);
log_settings[Logs::Crash].log_to_file = static_cast<uint8>(Logs::General);
return this;
}
+63 -62
View File
@@ -39,8 +39,7 @@
namespace Logs {
enum DebugLevel {
General = 1, // 1 - Low-Level general debugging, useful info on single line
Moderate, // 2 - Informational based, used in functions, when particular things load
Detail // 3 - Use this for extreme detail in logging, usually in extreme debugging in the stack or interprocess communication
Detail // 2 - Use this for very chatty logging you want to leave in but don't want on by default
};
/**
@@ -54,7 +53,7 @@ namespace Logs {
AI,
Aggro,
Attack,
DeprecatedCS,
DeprecatedCS, // deprecated
Combat,
Commands,
Crash,
@@ -65,36 +64,36 @@ namespace Logs {
Inventory,
Launcher,
Netcode,
Normal,
Normal, // deprecated
Object,
Pathing,
QSServer,
QSServer, // deprecated
Quests,
Rules,
Skills,
Spawns,
Spells,
Status,
Status, // deprecated
TCPConnection,
Tasks,
Tradeskills,
Trading,
Tribute,
UCSServer,
WebInterfaceServer,
WorldServer,
ZoneServer,
UCSServer, // deprecated
WebInterfaceServer, // deprecated
WorldServer, // deprecated
ZoneServer, // deprecated
MySQLError,
MySQLQuery,
Mercenaries,
QuestDebug,
DeprecatedSC,
DeprecatedCSU,
DeprecatedSCD,
DeprecatedCSD,
Loginserver,
DeprecatedSC, // deprecated
DeprecatedCSU, // deprecated
DeprecatedSCD, // deprecated
DeprecatedCSD, // deprecated
Loginserver, // deprecated
ClientLogin,
HeadlessClient,
HeadlessClient, // deprecated
HPUpdate,
FixZ,
Food,
@@ -104,10 +103,10 @@ namespace Logs {
MobAppearance,
Info,
Warning,
Critical,
Emergency,
Alert,
Notice,
Critical, // deprecated
Emergency, // deprecated
Alert, // deprecated
Notice, // deprecated
AIScanClose,
AIYellForHelp,
AICastBeneficialClose,
@@ -160,52 +159,52 @@ namespace Logs {
"Inventory",
"Launcher",
"Netcode",
"Normal",
"Normal (Deprecated)",
"Object",
"Pathing",
"QS Server",
"QS Server (Deprecated)",
"Quests",
"Rules",
"Skills",
"Spawns",
"Spells",
"Status",
"Status (Deprecated)",
"TCP Connection",
"Tasks",
"Tradeskills",
"Trading",
"Tribute",
"UCS Server",
"WebInterface Server",
"World Server",
"Zone Server",
"MySQL Error",
"MySQL Query",
"UCS Server (Deprecated)",
"Web Interface (Deprecated)",
"World Server (Deprecated)",
"Zone Server (Deprecated)",
"QueryErr",
"Query",
"Mercenaries",
"Quest Debug",
"Deprecated",
"Deprecated",
"Deprecated",
"Deprecated",
"Login Server",
"Legacy Packet Logging (Deprecated)",
"Legacy Packet Logging (Deprecated)",
"Legacy Packet Logging (Deprecated)",
"Legacy Packet Logging (Deprecated)",
"Login Server (Deprecated)",
"Client Login",
"Headless Client",
"Headless Client (Deprecated)",
"HP Update",
"FixZ",
"Food",
"Traps",
"NPC Roam Box",
"NPC Scaling",
"Mob Appearance",
"MobAppearance",
"Info",
"Warning",
"Critical",
"Emergency",
"Alert",
"Notice",
"AI Scan Close",
"AI Yell For Help",
"AI Cast Beneficial Close",
"Critical (Deprecated)",
"Emergency (Deprecated)",
"Alert (Deprecated)",
"Notice (Deprecated)",
"AI Scan",
"AI Yell",
"AI CastBeneficial",
"AOE Cast",
"Entity Management",
"Flee",
@@ -222,14 +221,14 @@ namespace Logs {
"DialogueWindow",
"HTTP",
"Saylink",
"ChecksumVerification",
"ChecksumVer",
"CombatRecord",
"Hate",
"Discord",
"Faction",
"Packet-S->C",
"Packet-C->S",
"Packet-S->S",
"Packet S->C",
"Packet C->S",
"Packet S->S",
"Bugs",
"QuestErrors"
};
@@ -345,7 +344,7 @@ public:
// gmsay
uint16 GetGMSayColorFromCategory(uint16 log_category);
EQEmuLogSys *SetGMSayHandler(std::function<void(uint16 log_type, const std::string &)> f)
EQEmuLogSys *SetGMSayHandler(const std::function<void(uint16 log_type, const char *func, const std::string &)>& f)
{
m_on_log_gmsay_hook = f;
return this;
@@ -376,22 +375,24 @@ public:
private:
// reference to database
Database *m_database;
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 m_log_path;
Database *m_database;
std::function<void(uint16 log_category, const char *func, 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 m_log_path;
std::string GetLinuxConsoleColorFromCategory(uint16 log_category);
uint16 GetWindowsConsoleColorFromCategory(uint16 log_category);
void ProcessConsoleMessage(uint16 log_category, const std::string &message);
void ProcessConsoleMessage(
uint16 log_category,
const std::string &message,
const char *file,
const char *func,
int line
);
void ProcessLogWrite(uint16 log_category, const std::string &message);
bool IsRfc5424LogCategory(uint16 log_category);
void InjectTablesIfNotExist();
};
-551
View File
@@ -21,8 +21,6 @@
#ifndef EQEMU_EQEMU_LOGSYS_LOG_ALIASES_H
#define EQEMU_EQEMU_LOGSYS_LOG_ALIASES_H
#ifdef BUILD_LOGGING
#define LogAA(message, ...) do {\
if (LogSys.IsLogEnabled(Logs::General, Logs::AA))\
OutF(LogSys, Logs::General, Logs::AA, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\
@@ -38,11 +36,6 @@
OutF(LogSys, Logs::General, Logs::AI, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\
} while (0)
#define LogAIModerate(message, ...) do {\
if (LogSys.IsLogEnabled(Logs::Moderate, Logs::AI))\
OutF(LogSys, Logs::Moderate, Logs::AI, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\
} while (0)
#define LogAIDetail(message, ...) do {\
if (LogSys.IsLogEnabled(Logs::Detail, Logs::AI))\
OutF(LogSys, Logs::Detail, Logs::AI, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\
@@ -83,11 +76,6 @@
OutF(LogSys, Logs::General, Logs::Combat, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\
} while (0)
#define LogCombatModerate(message, ...) do {\
if (LogSys.IsLogEnabled(Logs::Moderate, Logs::Combat))\
OutF(LogSys, Logs::Moderate, Logs::Combat, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\
} while (0)
#define LogCombatDetail(message, ...) do {\
if (LogSys.IsLogEnabled(Logs::Detail, Logs::Combat))\
OutF(LogSys, Logs::Detail, Logs::Combat, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\
@@ -213,16 +201,6 @@
OutF(LogSys, Logs::Detail, Logs::Pathing, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\
} while (0)
#define LogQSServer(message, ...) do {\
if (LogSys.IsLogEnabled(Logs::General, Logs::QSServer))\
OutF(LogSys, Logs::General, Logs::QSServer, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\
} while (0)
#define LogQSServerDetail(message, ...) do {\
if (LogSys.IsLogEnabled(Logs::Detail, Logs::QSServer))\
OutF(LogSys, Logs::Detail, Logs::QSServer, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\
} while (0)
#define LogQuests(message, ...) do {\
if (LogSys.IsLogEnabled(Logs::General, Logs::Quests))\
OutF(LogSys, Logs::General, Logs::Quests, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\
@@ -268,11 +246,6 @@
OutF(LogSys, Logs::General, Logs::Spells, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\
} while (0)
#define LogSpellsModerate(message, ...) do {\
if (LogSys.IsLogEnabled(Logs::Moderate, Logs::Spells))\
OutF(LogSys, Logs::Moderate, Logs::Spells, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\
} while (0)
#define LogSpellsDetail(message, ...) do {\
if (LogSys.IsLogEnabled(Logs::Detail, Logs::Spells))\
OutF(LogSys, Logs::Detail, Logs::Spells, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\
@@ -338,46 +311,6 @@
OutF(LogSys, Logs::Detail, Logs::Tribute, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\
} while (0)
#define LogUCSServer(message, ...) do {\
if (LogSys.IsLogEnabled(Logs::General, Logs::UCSServer))\
OutF(LogSys, Logs::General, Logs::UCSServer, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\
} while (0)
#define LogUCSServerDetail(message, ...) do {\
if (LogSys.IsLogEnabled(Logs::Detail, Logs::UCSServer))\
OutF(LogSys, Logs::Detail, Logs::UCSServer, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\
} while (0)
#define LogWebInterfaceServer(message, ...) do {\
if (LogSys.IsLogEnabled(Logs::General, Logs::WebInterfaceServer))\
OutF(LogSys, Logs::General, Logs::WebInterfaceServer, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\
} while (0)
#define LogWebInterfaceServerDetail(message, ...) do {\
if (LogSys.IsLogEnabled(Logs::Detail, Logs::WebInterfaceServer))\
OutF(LogSys, Logs::Detail, Logs::WebInterfaceServer, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\
} while (0)
#define LogWorldServer(message, ...) do {\
if (LogSys.IsLogEnabled(Logs::General, Logs::WorldServer))\
OutF(LogSys, Logs::General, Logs::WorldServer, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\
} while (0)
#define LogWorldServerDetail(message, ...) do {\
if (LogSys.IsLogEnabled(Logs::Detail, Logs::WorldServer))\
OutF(LogSys, Logs::Detail, Logs::WorldServer, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\
} while (0)
#define LogZoneServer(message, ...) do {\
if (LogSys.IsLogEnabled(Logs::General, Logs::ZoneServer))\
OutF(LogSys, Logs::General, Logs::ZoneServer, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\
} while (0)
#define LogZoneServerDetail(message, ...) do {\
if (LogSys.IsLogEnabled(Logs::Detail, Logs::ZoneServer))\
OutF(LogSys, Logs::Detail, Logs::ZoneServer, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\
} while (0)
#define LogMySQLError(message, ...) do {\
if (LogSys.IsLogEnabled(Logs::General, Logs::MySQLError))\
OutF(LogSys, Logs::General, Logs::MySQLError, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\
@@ -449,16 +382,6 @@
OutF(LogSys, Logs::Detail, Logs::ClientLogin, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\
} while (0)
#define LogHeadlessClient(message, ...) do {\
if (LogSys.IsLogEnabled(Logs::General, Logs::HeadlessClient))\
OutF(LogSys, Logs::General, Logs::HeadlessClient, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\
} while (0)
#define LogHeadlessClientDetail(message, ...) do {\
if (LogSys.IsLogEnabled(Logs::Detail, Logs::HeadlessClient))\
OutF(LogSys, Logs::Detail, Logs::HeadlessClient, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\
} while (0)
#define LogHPUpdate(message, ...) do {\
if (LogSys.IsLogEnabled(Logs::General, Logs::HPUpdate))\
OutF(LogSys, Logs::General, Logs::HPUpdate, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\
@@ -594,11 +517,6 @@
OutF(LogSys, Logs::General, Logs::AIScanClose, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\
} while (0)
#define LogAIScanCloseModerate(message, ...) do {\
if (LogSys.IsLogEnabled(Logs::Moderate, Logs::AIScanClose))\
OutF(LogSys, Logs::Moderate, Logs::AIScanClose, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\
} while (0)
#define LogAIScanCloseDetail(message, ...) do {\
if (LogSys.IsLogEnabled(Logs::Detail, Logs::AIScanClose))\
OutF(LogSys, Logs::Detail, Logs::AIScanClose, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\
@@ -846,11 +764,6 @@
// manually created
#define LogExpeditionsModerate(message, ...) do {\
if (LogSys.IsLogEnabled(Logs::Moderate, Logs::Expeditions))\
OutF(LogSys, Logs::Moderate, Logs::Expeditions, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\
} while (0)
#define LogBugs(message, ...) do {\
if (LogSys.IsLogEnabled(Logs::General, Logs::Bugs))\
OutF(LogSys, Logs::General, Logs::Bugs, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\
@@ -881,469 +794,5 @@
OutF(LogSys, debug_level, log_category, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\
} while (0)
#else
#define LogEmergency(message, ...) do {\
} while (0)
#define LogAlert(message, ...) do {\
} while (0)
#define LogCritical(message, ...) do {\
} while (0)
#define LogError(message, ...) do {\
} while (0)
#define LogWarning(message, ...) do {\
} while (0)
#define LogNotice(message, ...) do {\
} while (0)
#define LogInfo(message, ...) do {\
} while (0)
#define LogDebug(message, ...) do {\
} while (0)
/**
* Category
*/
#define LogAA(message, ...) do {\
} while (0)
#define LogAADetail(message, ...) do {\
} while (0)
#define LogAI(message, ...) do {\
} while (0)
#define LogAIModerate(message, ...) do {\
} while (0)
#define LogAIDetail(message, ...) do {\
} while (0)
#define LogAggro(message, ...) do {\
} while (0)
#define LogAggroDetail(message, ...) do {\
} while (0)
#define LogAttack(message, ...) do {\
} while (0)
#define LogAttackDetail(message, ...) do {\
} while (0)
#define LogPacketClientServer(message, ...) do {\
} while (0)
#define LogPacketClientServerDetail(message, ...) do {\
} while (0)
#define LogCombat(message, ...) do {\
} while (0)
#define LogCombatModerate(message, ...) do {\
} while (0)
#define LogCombatDetail(message, ...) do {\
} while (0)
#define LogCommands(message, ...) do {\
} while (0)
#define LogCommandsDetail(message, ...) do {\
} while (0)
#define LogCrash(message, ...) do {\
} while (0)
#define LogCrashDetail(message, ...) do {\
} while (0)
#define LogDoors(message, ...) do {\
} while (0)
#define LogDoorsDetail(message, ...) do {\
} while (0)
#define LogGroup(message, ...) do {\
} while (0)
#define LogGroupDetail(message, ...) do {\
} while (0)
#define LogGuilds(message, ...) do {\
} while (0)
#define LogGuildsDetail(message, ...) do {\
} while (0)
#define LogInventory(message, ...) do {\
} while (0)
#define LogInventoryDetail(message, ...) do {\
} while (0)
#define LogLauncher(message, ...) do {\
} while (0)
#define LogLauncherDetail(message, ...) do {\
} while (0)
#define LogNetcode(message, ...) do {\
} while (0)
#define LogNetcodeDetail(message, ...) do {\
} while (0)
#define LogNormal(message, ...) do {\
} while (0)
#define LogNormalDetail(message, ...) do {\
} while (0)
#define LogObject(message, ...) do {\
} while (0)
#define LogObjectDetail(message, ...) do {\
} while (0)
#define LogPathing(message, ...) do {\
} while (0)
#define LogPathingDetail(message, ...) do {\
} while (0)
#define LogQSServer(message, ...) do {\
} while (0)
#define LogQSServerDetail(message, ...) do {\
} while (0)
#define LogQuests(message, ...) do {\
} while (0)
#define LogQuestsDetail(message, ...) do {\
} while (0)
#define LogRules(message, ...) do {\
} while (0)
#define LogRulesDetail(message, ...) do {\
} while (0)
#define LogSkills(message, ...) do {\
} while (0)
#define LogSkillsDetail(message, ...) do {\
} while (0)
#define LogSpawns(message, ...) do {\
} while (0)
#define LogSpawnsDetail(message, ...) do {\
} while (0)
#define LogSpells(message, ...) do {\
} while (0)
#define LogSpellsModerate(message, ...) do {\
} while (0)
#define LogSpellsDetail(message, ...) do {\
} while (0)
#define LogTCPConnection(message, ...) do {\
} while (0)
#define LogTCPConnectionDetail(message, ...) do {\
} while (0)
#define LogTasks(message, ...) do {\
} while (0)
#define LogTasksDetail(message, ...) do {\
} while (0)
#define LogTradeskills(message, ...) do {\
} while (0)
#define LogTradeskillsDetail(message, ...) do {\
} while (0)
#define LogTrading(message, ...) do {\
} while (0)
#define LogTradingDetail(message, ...) do {\
} while (0)
#define LogTribute(message, ...) do {\
} while (0)
#define LogTributeDetail(message, ...) do {\
} while (0)
#define LogMySQLError(message, ...) do {\
} while (0)
#define LogMySQLErrorDetail(message, ...) do {\
} while (0)
#define LogMySQLQuery(message, ...) do {\
} while (0)
#define LogMySQLQueryDetail(message, ...) do {\
} while (0)
#define LogMercenaries(message, ...) do {\
} while (0)
#define LogMercenariesDetail(message, ...) do {\
} while (0)
#define LogQuestDebug(message, ...) do {\
} while (0)
#define LogQuestDebugDetail(message, ...) do {\
} while (0)
#define LogLoginserver(message, ...) do {\
} while (0)
#define LogLoginserverDetail(message, ...) do {\
} while (0)
#define LogClientLogin(message, ...) do {\
} while (0)
#define LogClientLoginDetail(message, ...) do {\
} while (0)
#define LogHeadlessClient(message, ...) do {\
} while (0)
#define LogHeadlessClientDetail(message, ...) do {\
} while (0)
#define LogHPUpdate(message, ...) do {\
} while (0)
#define LogHPUpdateDetail(message, ...) do {\
} while (0)
#define LogFixZ(message, ...) do {\
} while (0)
#define LogFixZDetail(message, ...) do {\
} while (0)
#define LogFood(message, ...) do {\
} while (0)
#define LogFoodDetail(message, ...) do {\
} while (0)
#define LogTraps(message, ...) do {\
} while (0)
#define LogTrapsDetail(message, ...) do {\
} while (0)
#define LogNPCRoamBox(message, ...) do {\
} while (0)
#define LogNPCRoamBoxDetail(message, ...) do {\
} while (0)
#define LogNPCScaling(message, ...) do {\
} while (0)
#define LogNPCScalingDetail(message, ...) do {\
} while (0)
#define LogMobAppearance(message, ...) do {\
} while (0)
#define LogMobAppearanceDetail(message, ...) do {\
} while (0)
#define LogStatus(message, ...) do {\
} while (0)
#define LogStatusDetail(message, ...) do {\
} while (0)
#define LogAIScanClose(message, ...) do {\
} while (0)
#define LogAIScanCloseModerate(message, ...) do {\
} while (0)
#define LogAIScanCloseDetail(message, ...) do {\
} while (0)
#define LogAIYellForHelp(message, ...) do {\
} while (0)
#define LogAIYellForHelpDetail(message, ...) do {\
} while (0)
#define LogAICastBeneficialClose(message, ...) do {\
} while (0)
#define LogAICastBeneficialCloseDetail(message, ...) do {\
} while (0)
#define LogAoeCast(message, ...) do {\
} while (0)
#define LogAoeCastDetail(message, ...) do {\
} while (0)
#define LogEntityManagement(message, ...) do {\
} while (0)
#define LogEntityManagementDetail(message, ...) do {\
} while (0)
#define LogFlee(message, ...) do {\
} while (0)
#define LogFleeDetail(message, ...) do {\
} while (0)
#define LogAura(message, ...) do {\
} while (0)
#define LogAuraDetail(message, ...) do {\
} while (0)
#define LogHotReload(message, ...) do {\
} while (0)
#define LogHotReloadDetail(message, ...) do {\
} while (0)
#define LogMerchants(message, ...) do {\
} while (0)
#define LogMerchantsDetail(message, ...) do {\
} while (0)
#define LogZonePoints(message, ...) do {\
} while (0)
#define LogZonePointsDetail(message, ...) do {\
} while (0)
#define LogExpeditions(message, ...) do {\
} while (0)
#define LogExpeditionsModerate(message, ...) do {\
} while (0)
#define LogExpeditionsDetail(message, ...) do {\
} while (0)
#define LogDynamicZones(message, ...) do {\
} while (0)
#define LogDynamicZonesDetail(message, ...) do {\
} while (0)
#define LogCheatList(message, ...) do {\
} while (0)
#define LogCheatDetail(message, ...) do {\
} while (0)
#define LogClientList(message, ...) do {\
} while (0)
#define LogClientListDetail(message, ...) do {\
} while (0)
#define LogDiaWind(message, ...) do {\
} while (0)
#define LogDiaWindDetail(message, ...) do {\
} while (0)
#define LogHTTP(message, ...) do {\
} while (0)
#define LogHTTPDetail(message, ...) do {\
} while (0)
#define LogSaylink(message, ...) do {\
} while (0)
#define LogSaylinkDetail(message, ...) do {\
} while (0)
#define LogScheduler(message, ...) do {\
} while (0)
#define LogSchedulerDetail(message, ...) do {\
} while (0)
#define LogCheat(message, ...) do {\
} while (0)
#define LogCheatDetail(message, ...) do {\
} while (0)
#define LogLoot(message, ...) do {\
} while (0)
#define LogLootDetail(message, ...) do {\
} while (0)
#define LogFood(message, ...) do {\
} while (0)
#define LogFoodDetail(message, ...) do {\
} while (0)
#define LogChecksumVerification(message, ...) do {\
} while (0)
#define LogChecksumVerificationDetail(message, ...) do {\
} while (0)
#define LogCombatRecord(message, ...) do {\
} while (0)
#define LogCombatRecordDetail(message, ...) do {\
} while (0)
#define LogHate(message, ...) do {\
} while (0)
#define LogHateDetail(message, ...) do {\
} while (0)
#define LogFaction(message, ...) do {\
} while (0)
#define LogFactionDetail(message, ...) do {\
} while (0)
#define LogBugs(message, ...) do {\
} while (0)
#define LogBugsDetail(message, ...) do {\
} while (0)
#define Log(debug_level, log_category, message, ...) do {\
} while (0)
#define LogF(debug_level, log_category, message, ...) do {\
} while (0)
#endif
#endif //EQEMU_EQEMU_LOGSYS_LOG_ALIASES_H
+5 -17
View File
@@ -63,7 +63,9 @@ bool BaseGuildManager::LoadGuilds() {
for (auto row=results.begin();row!=results.end();++row)
_CreateGuild(atoi(row[0]), row[1], atoi(row[2]), atoi(row[3]), row[4], row[5], row[6], row[7]);
query = "SELECT guild_id,`rank`,title,can_hear,can_speak,can_invite,can_remove,can_promote,can_demote,can_motd,can_warpeace FROM guild_ranks";
LogInfo("Loaded [{}] Guilds", Strings::Commify(std::to_string(results.RowCount())));
query = "SELECT guild_id,`rank`,title,can_hear,can_speak,can_invite,can_remove,can_promote,can_demote,can_motd,can_warpeace FROM guild_ranks";
results = m_db->QueryDatabase(query);
if (!results.Success())
@@ -864,20 +866,11 @@ bool BaseGuildManager::QueryWithLogging(std::string query, const char *errmsg) {
return(true);
}
//factored out so I dont have to copy this crap.
#ifdef BOTS
#define GuildMemberBaseQuery \
"SELECT c.`id`, c.`name`, c.`class`, c.`level`, c.`last_login`, c.`zone_id`," \
" g.`guild_id`, g.`rank`, g.`tribute_enable`, g.`total_tribute`, g.`last_tribute`," \
" g.`banker`, g.`public_note`, g.`alt`" \
" FROM `vw_bot_character_mobs` AS c LEFT JOIN `vw_guild_members` AS g ON c.`id` = g.`char_id` AND c.`mob_type` = g.`mob_type` "
#else
#define GuildMemberBaseQuery \
"SELECT c.`id`, c.`name`, c.`class`, c.`level`, c.`last_login`, c.`zone_id`," \
" g.`guild_id`, g.`rank`, g.`tribute_enable`, g.`total_tribute`, g.`last_tribute`," \
" g.`banker`, g.`public_note`, g.`alt` " \
" FROM `character_data` AS c LEFT JOIN `guild_members` AS g ON c.`id` = g.`char_id` "
#endif
static void ProcessGuildMember(MySQLRequestRow row, CharGuildInfo &into) {
//fields from `characer_`
into.char_id = atoi(row[0]);
@@ -967,13 +960,8 @@ bool BaseGuildManager::GetCharInfo(uint32 char_id, CharGuildInfo &into) {
}
//load up the rank info for each guild.
std::string query;
#ifdef BOTS
query = StringFormat(GuildMemberBaseQuery " WHERE c.id=%d AND c.mob_type = 'C' AND c.deleted_at IS NULL", char_id);
#else
query = StringFormat(GuildMemberBaseQuery " WHERE c.id=%d AND c.deleted_at IS NULL", char_id);
#endif
auto results = m_db->QueryDatabase(query);
std::string query = StringFormat(GuildMemberBaseQuery " WHERE c.id=%d AND c.deleted_at IS NULL", char_id);
auto results = m_db->QueryDatabase(query);
if (!results.Success()) {
return false;
}
+3 -1
View File
@@ -26,6 +26,8 @@
#include "item_instance.h"
#include "classes.h"
#include "races.h"
#include <list>
#include <vector>
@@ -130,7 +132,7 @@ namespace EQ
// Swap items in inventory
enum SwapItemFailState : int8 { swapInvalid = -1, swapPass = 0, swapNotAllowed, swapNullData, swapRaceClass, swapDeity, swapLevel };
bool SwapItem(int16 source_slot, int16 destination_slot, SwapItemFailState& fail_state, uint16 race_id = 0, uint8 class_id = 0, uint16 deity_id = 0, uint8 level = 0);
bool SwapItem(int16 source_slot, int16 destination_slot, SwapItemFailState& fail_state, uint16 race_id = RACE_DOUG_0, uint8 class_id = NO_CLASS, uint16 deity_id = deity::DeityType::DeityUnknown, uint8 level = 0);
// Remove item from inventory
bool DeleteItem(int16 slot_id, int16 quantity = 0);
+1 -1
View File
@@ -198,7 +198,7 @@ std::string IpUtil::DNSLookupSync(const std::string &addr, int port)
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 [{}]",
"Deadline exceeded [{}]",
1500
);
running = false;
+9 -7
View File
@@ -534,10 +534,11 @@ bool EQ::ItemInstance::IsNoneEmptyContainer()
}
// Retrieve augment inside item
EQ::ItemInstance* EQ::ItemInstance::GetAugment(uint8 slot) const
EQ::ItemInstance* EQ::ItemInstance::GetAugment(uint8 augment_index) const
{
if (m_item && m_item->IsClassCommon())
return GetItem(slot);
if (m_item && m_item->IsClassCommon()) {
return GetItem(augment_index);
}
return nullptr;
}
@@ -663,12 +664,13 @@ bool EQ::ItemInstance::CanTransform(const ItemData *ItemToTry, const ItemData *C
return false;
}
uint32 EQ::ItemInstance::GetAugmentItemID(uint8 slot) const
uint32 EQ::ItemInstance::GetAugmentItemID(uint8 augment_index) const
{
if (!m_item || !m_item->IsClassCommon())
if (!m_item || !m_item->IsClassCommon()) {
return 0;
}
return GetItemID(slot);
return GetItemID(augment_index);
}
// Add an augment to the item
@@ -1249,7 +1251,7 @@ int EQ::ItemInstance::GetItemBaneDamageBody(bool augments) const
int EQ::ItemInstance::GetItemBaneDamageRace(bool augments) const
{
int race = 0;
int race = RACE_DOUG_0;
const auto item = GetItem();
if (item) {
race = item->BaneDmgRace;
+2 -2
View File
@@ -127,8 +127,8 @@ namespace EQ
//
// Augments
//
ItemInstance* GetAugment(uint8 slot) const;
uint32 GetAugmentItemID(uint8 slot) const;
ItemInstance* GetAugment(uint8 augment_index) const;
uint32 GetAugmentItemID(uint8 augment_index) const;
void PutAugment(uint8 slot, const ItemInstance& inst);
void PutAugment(SharedDatabase *db, uint8 slot, uint32 item_id);
void DeleteAugment(uint8 slot);
+7 -7
View File
@@ -665,7 +665,7 @@ namespace RoF
ENCODE(OP_DeleteCharge)
{
Log(Logs::Moderate, Logs::Netcode, "RoF::ENCODE(OP_DeleteCharge)");
Log(Logs::Detail, Logs::Netcode, "RoF::ENCODE(OP_DeleteCharge)");
ENCODE_FORWARD(OP_MoveItem);
}
@@ -1593,7 +1593,7 @@ namespace RoF
ENCODE_LENGTH_EXACT(LootingItem_Struct);
SETUP_DIRECT_ENCODE(LootingItem_Struct, structs::LootingItem_Struct);
Log(Logs::Moderate, Logs::Netcode, "RoF::ENCODE(OP_LootItem)");
Log(Logs::Detail, Logs::Netcode, "RoF::ENCODE(OP_LootItem)");
OUT(lootee);
OUT(looter);
@@ -1751,7 +1751,7 @@ namespace RoF
ENCODE_LENGTH_EXACT(MoveItem_Struct);
SETUP_DIRECT_ENCODE(MoveItem_Struct, structs::MoveItem_Struct);
Log(Logs::Moderate, Logs::Netcode, "RoF::ENCODE(OP_MoveItem)");
Log(Logs::Detail, Logs::Netcode, "RoF::ENCODE(OP_MoveItem)");
eq->from_slot = ServerToRoFSlot(emu->from_slot);
eq->to_slot = ServerToRoFSlot(emu->to_slot);
@@ -3831,7 +3831,7 @@ namespace RoF
}
float SpawnSize = emu->size;
if (!((emu->NPC == 0) || (emu->race <= RACE_GNOME_12) || (emu->race == RACE_IKSAR_128) ||
if (!((emu->NPC == 0) || (emu->race <= RACE_GNOME_12) || (emu->race == RACE_IKSAR_128) ||
(emu->race == RACE_VAH_SHIR_130) || (emu->race == RACE_FROGLOK_330) || (emu->race == RACE_DRAKKIN_522))
)
{
@@ -3965,7 +3965,7 @@ namespace RoF
VARSTRUCT_ENCODE_TYPE(uint32, Buffer, 0xffffffff); // unknown18
VARSTRUCT_ENCODE_TYPE(uint32, Buffer, 0xffffffff); // unknown19
if ((emu->NPC == 0) || (emu->race <= RACE_GNOME_12) || (emu->race == RACE_IKSAR_128) ||
if ((emu->NPC == 0) || (emu->race <= RACE_GNOME_12) || (emu->race == RACE_IKSAR_128) ||
(emu->race == RACE_VAH_SHIR_130) || (emu->race == RACE_FROGLOK_330) || (emu->race == RACE_DRAKKIN_522)
)
{
@@ -4822,7 +4822,7 @@ namespace RoF
DECODE_LENGTH_EXACT(structs::LootingItem_Struct);
SETUP_DIRECT_DECODE(LootingItem_Struct, structs::LootingItem_Struct);
Log(Logs::Moderate, Logs::Netcode, "RoF::DECODE(OP_LootItem)");
Log(Logs::Detail, Logs::Netcode, "RoF::DECODE(OP_LootItem)");
IN(lootee);
IN(looter);
@@ -4837,7 +4837,7 @@ namespace RoF
DECODE_LENGTH_EXACT(structs::MoveItem_Struct);
SETUP_DIRECT_DECODE(MoveItem_Struct, structs::MoveItem_Struct);
Log(Logs::Moderate, Logs::Netcode, "RoF::DECODE(OP_MoveItem)");
Log(Logs::Detail, Logs::Netcode, "RoF::DECODE(OP_MoveItem)");
emu->from_slot = RoFToServerSlot(eq->from_slot);
emu->to_slot = RoFToServerSlot(eq->to_slot);
+7 -7
View File
@@ -716,7 +716,7 @@ namespace RoF2
ENCODE(OP_DeleteCharge)
{
Log(Logs::Moderate, Logs::Netcode, "RoF2::ENCODE(OP_DeleteCharge)");
Log(Logs::Detail, Logs::Netcode, "RoF2::ENCODE(OP_DeleteCharge)");
ENCODE_FORWARD(OP_MoveItem);
}
@@ -1644,7 +1644,7 @@ namespace RoF2
ENCODE_LENGTH_EXACT(LootingItem_Struct);
SETUP_DIRECT_ENCODE(LootingItem_Struct, structs::LootingItem_Struct);
Log(Logs::Moderate, Logs::Netcode, "RoF2::ENCODE(OP_LootItem)");
Log(Logs::Detail, Logs::Netcode, "RoF2::ENCODE(OP_LootItem)");
OUT(lootee);
OUT(looter);
@@ -1802,7 +1802,7 @@ namespace RoF2
ENCODE_LENGTH_EXACT(MoveItem_Struct);
SETUP_DIRECT_ENCODE(MoveItem_Struct, structs::MoveItem_Struct);
Log(Logs::Moderate, Logs::Netcode, "RoF2::ENCODE(OP_MoveItem)");
Log(Logs::Detail, Logs::Netcode, "RoF2::ENCODE(OP_MoveItem)");
eq->from_slot = ServerToRoF2Slot(emu->from_slot);
eq->to_slot = ServerToRoF2Slot(emu->to_slot);
@@ -3967,7 +3967,7 @@ namespace RoF2
}
float SpawnSize = emu->size;
if (!((emu->NPC == 0) || (emu->race <= RACE_GNOME_12) || (emu->race == RACE_IKSAR_128) ||
if (!((emu->NPC == 0) || (emu->race <= RACE_GNOME_12) || (emu->race == RACE_IKSAR_128) ||
(emu->race == RACE_VAH_SHIR_130) || (emu->race == RACE_FROGLOK_330) || (emu->race == RACE_DRAKKIN_522))
)
{
@@ -4172,7 +4172,7 @@ namespace RoF2
VARSTRUCT_ENCODE_TYPE(uint32, Buffer, 0xffffffff); // These do something with OP_WeaponEquip1
VARSTRUCT_ENCODE_TYPE(uint32, Buffer, 0xffffffff); // ^
if ((emu->NPC == 0) || (emu->race <= RACE_GNOME_12) || (emu->race == RACE_IKSAR_128) ||
if ((emu->NPC == 0) || (emu->race <= RACE_GNOME_12) || (emu->race == RACE_IKSAR_128) ||
(emu->race == RACE_VAH_SHIR_130) || (emu->race == RACE_FROGLOK_330) || (emu->race == RACE_DRAKKIN_522)
)
{
@@ -5023,7 +5023,7 @@ namespace RoF2
DECODE_LENGTH_EXACT(structs::LootingItem_Struct);
SETUP_DIRECT_DECODE(LootingItem_Struct, structs::LootingItem_Struct);
Log(Logs::Moderate, Logs::Netcode, "RoF2::DECODE(OP_LootItem)");
Log(Logs::Detail, Logs::Netcode, "RoF2::DECODE(OP_LootItem)");
IN(lootee);
IN(looter);
@@ -5038,7 +5038,7 @@ namespace RoF2
DECODE_LENGTH_EXACT(structs::MoveItem_Struct);
SETUP_DIRECT_DECODE(MoveItem_Struct, structs::MoveItem_Struct);
Log(Logs::Moderate, Logs::Netcode, "RoF2::DECODE(OP_MoveItem)");
Log(Logs::Detail, Logs::Netcode, "RoF2::DECODE(OP_MoveItem)");
emu->from_slot = RoF2ToServerSlot(eq->from_slot);
emu->to_slot = RoF2ToServerSlot(eq->to_slot);
+8 -8
View File
@@ -458,7 +458,7 @@ namespace SoD
ENCODE(OP_DeleteCharge)
{
Log(Logs::Moderate, Logs::Netcode, "SoD::ENCODE(OP_DeleteCharge)");
Log(Logs::Detail, Logs::Netcode, "SoD::ENCODE(OP_DeleteCharge)");
ENCODE_FORWARD(OP_MoveItem);
}
@@ -1128,7 +1128,7 @@ namespace SoD
ENCODE_LENGTH_EXACT(LootingItem_Struct);
SETUP_DIRECT_ENCODE(LootingItem_Struct, structs::LootingItem_Struct);
Log(Logs::Moderate, Logs::Netcode, "SoD::ENCODE(OP_LootItem)");
Log(Logs::Detail, Logs::Netcode, "SoD::ENCODE(OP_LootItem)");
OUT(lootee);
OUT(looter);
@@ -1277,7 +1277,7 @@ namespace SoD
ENCODE_LENGTH_EXACT(MoveItem_Struct);
SETUP_DIRECT_ENCODE(MoveItem_Struct, structs::MoveItem_Struct);
Log(Logs::Moderate, Logs::Netcode, "SoD::ENCODE(OP_MoveItem)");
Log(Logs::Detail, Logs::Netcode, "SoD::ENCODE(OP_MoveItem)");
eq->from_slot = ServerToSoDSlot(emu->from_slot);
eq->to_slot = ServerToSoDSlot(emu->to_slot);
@@ -2467,7 +2467,7 @@ namespace SoD
}
float SpawnSize = emu->size;
if (!((emu->NPC == 0) || (emu->race <= RACE_GNOME_12) || (emu->race == RACE_IKSAR_128) ||
if (!((emu->NPC == 0) || (emu->race <= RACE_GNOME_12) || (emu->race == RACE_IKSAR_128) ||
(emu->race == RACE_VAH_SHIR_130) || (emu->race == RACE_FROGLOK_330) || (emu->race == RACE_DRAKKIN_522))
)
{
@@ -2666,7 +2666,7 @@ namespace SoD
Buffer += sizeof(structs::Spawn_Struct_Position);
if ((emu->NPC == 0) || (emu->race <= RACE_GNOME_12) || (emu->race == RACE_IKSAR_128) ||
if ((emu->NPC == 0) || (emu->race <= RACE_GNOME_12) || (emu->race == RACE_IKSAR_128) ||
(emu->race == RACE_VAH_SHIR_130) || (emu->race == RACE_FROGLOK_330) || (emu->race == RACE_DRAKKIN_522)
)
{
@@ -2693,7 +2693,7 @@ namespace SoD
}
if ((emu->NPC == 0) || (emu->race <= RACE_GNOME_12) || (emu->race == RACE_IKSAR_128) ||
if ((emu->NPC == 0) || (emu->race <= RACE_GNOME_12) || (emu->race == RACE_IKSAR_128) ||
(emu->race == RACE_VAH_SHIR_130) || (emu->race == RACE_FROGLOK_330) || (emu->race == RACE_DRAKKIN_522)
)
{
@@ -3226,7 +3226,7 @@ namespace SoD
DECODE_LENGTH_EXACT(structs::LootingItem_Struct);
SETUP_DIRECT_DECODE(LootingItem_Struct, structs::LootingItem_Struct);
Log(Logs::Moderate, Logs::Netcode, "SoD::DECODE(OP_LootItem)");
Log(Logs::Detail, Logs::Netcode, "SoD::DECODE(OP_LootItem)");
IN(lootee);
IN(looter);
@@ -3241,7 +3241,7 @@ namespace SoD
DECODE_LENGTH_EXACT(structs::MoveItem_Struct);
SETUP_DIRECT_DECODE(MoveItem_Struct, structs::MoveItem_Struct);
Log(Logs::Moderate, Logs::Netcode, "SoD::DECODE(OP_MoveItem)");
Log(Logs::Detail, Logs::Netcode, "SoD::DECODE(OP_MoveItem)");
emu->from_slot = SoDToServerSlot(eq->from_slot);
emu->to_slot = SoDToServerSlot(eq->to_slot);
+5 -5
View File
@@ -436,7 +436,7 @@ namespace SoF
ENCODE(OP_DeleteCharge)
{
Log(Logs::Moderate, Logs::Netcode, "SoF::ENCODE(OP_DeleteCharge)");
Log(Logs::Detail, Logs::Netcode, "SoF::ENCODE(OP_DeleteCharge)");
ENCODE_FORWARD(OP_MoveItem);
}
@@ -923,7 +923,7 @@ namespace SoF
ENCODE_LENGTH_EXACT(LootingItem_Struct);
SETUP_DIRECT_ENCODE(LootingItem_Struct, structs::LootingItem_Struct);
Log(Logs::Moderate, Logs::Netcode, "SoF::ENCODE(OP_LootItem)");
Log(Logs::Detail, Logs::Netcode, "SoF::ENCODE(OP_LootItem)");
OUT(lootee);
OUT(looter);
@@ -954,7 +954,7 @@ namespace SoF
ENCODE_LENGTH_EXACT(MoveItem_Struct);
SETUP_DIRECT_ENCODE(MoveItem_Struct, structs::MoveItem_Struct);
Log(Logs::Moderate, Logs::Netcode, "SoF::ENCODE(OP_MoveItem)");
Log(Logs::Detail, Logs::Netcode, "SoF::ENCODE(OP_MoveItem)");
eq->from_slot = ServerToSoFSlot(emu->from_slot);
eq->to_slot = ServerToSoFSlot(emu->to_slot);
@@ -2631,7 +2631,7 @@ namespace SoF
DECODE_LENGTH_EXACT(structs::LootingItem_Struct);
SETUP_DIRECT_DECODE(LootingItem_Struct, structs::LootingItem_Struct);
Log(Logs::Moderate, Logs::Netcode, "SoF::DECODE(OP_LootItem)");
Log(Logs::Detail, Logs::Netcode, "SoF::DECODE(OP_LootItem)");
IN(lootee);
IN(looter);
@@ -2646,7 +2646,7 @@ namespace SoF
DECODE_LENGTH_EXACT(structs::MoveItem_Struct);
SETUP_DIRECT_DECODE(MoveItem_Struct, structs::MoveItem_Struct);
Log(Logs::Moderate, Logs::Netcode, "SoF::DECODE(OP_MoveItem)");
Log(Logs::Detail, Logs::Netcode, "SoF::DECODE(OP_MoveItem)");
emu->from_slot = SoFToServerSlot(eq->from_slot);
emu->to_slot = SoFToServerSlot(eq->to_slot);
+5 -5
View File
@@ -380,7 +380,7 @@ namespace Titanium
ENCODE(OP_DeleteCharge)
{
Log(Logs::Moderate, Logs::Netcode, "Titanium::ENCODE(OP_DeleteCharge)");
Log(Logs::Detail, Logs::Netcode, "Titanium::ENCODE(OP_DeleteCharge)");
ENCODE_FORWARD(OP_MoveItem);
}
@@ -890,7 +890,7 @@ namespace Titanium
ENCODE_LENGTH_EXACT(LootingItem_Struct);
SETUP_DIRECT_ENCODE(LootingItem_Struct, structs::LootingItem_Struct);
Log(Logs::Moderate, Logs::Netcode, "Titanium::ENCODE(OP_LootItem)");
Log(Logs::Detail, Logs::Netcode, "Titanium::ENCODE(OP_LootItem)");
OUT(lootee);
OUT(looter);
@@ -934,7 +934,7 @@ namespace Titanium
ENCODE_LENGTH_EXACT(MoveItem_Struct);
SETUP_DIRECT_ENCODE(MoveItem_Struct, structs::MoveItem_Struct);
Log(Logs::Moderate, Logs::Netcode, "Titanium::ENCODE(OP_MoveItem)");
Log(Logs::Detail, Logs::Netcode, "Titanium::ENCODE(OP_MoveItem)");
eq->from_slot = ServerToTitaniumSlot(emu->from_slot);
eq->to_slot = ServerToTitaniumSlot(emu->to_slot);
@@ -2178,7 +2178,7 @@ namespace Titanium
DECODE_LENGTH_EXACT(structs::LootingItem_Struct);
SETUP_DIRECT_DECODE(LootingItem_Struct, structs::LootingItem_Struct);
Log(Logs::Moderate, Logs::Netcode, "Titanium::DECODE(OP_LootItem)");
Log(Logs::Detail, Logs::Netcode, "Titanium::DECODE(OP_LootItem)");
IN(lootee);
IN(looter);
@@ -2193,7 +2193,7 @@ namespace Titanium
DECODE_LENGTH_EXACT(structs::MoveItem_Struct);
SETUP_DIRECT_DECODE(MoveItem_Struct, structs::MoveItem_Struct);
Log(Logs::Moderate, Logs::Netcode, "Titanium::DECODE(OP_MoveItem)");
Log(Logs::Detail, Logs::Netcode, "Titanium::DECODE(OP_MoveItem)");
emu->from_slot = TitaniumToServerSlot(eq->from_slot);
emu->to_slot = TitaniumToServerSlot(eq->to_slot);
+8 -8
View File
@@ -579,7 +579,7 @@ namespace UF
ENCODE(OP_DeleteCharge)
{
Log(Logs::Moderate, Logs::Netcode, "UF::ENCODE(OP_DeleteCharge)");
Log(Logs::Detail, Logs::Netcode, "UF::ENCODE(OP_DeleteCharge)");
ENCODE_FORWARD(OP_MoveItem);
}
@@ -1349,7 +1349,7 @@ namespace UF
ENCODE_LENGTH_EXACT(LootingItem_Struct);
SETUP_DIRECT_ENCODE(LootingItem_Struct, structs::LootingItem_Struct);
Log(Logs::Moderate, Logs::Netcode, "UF::ENCODE(OP_LootItem)");
Log(Logs::Detail, Logs::Netcode, "UF::ENCODE(OP_LootItem)");
OUT(lootee);
OUT(looter);
@@ -1502,7 +1502,7 @@ namespace UF
ENCODE_LENGTH_EXACT(MoveItem_Struct);
SETUP_DIRECT_ENCODE(MoveItem_Struct, structs::MoveItem_Struct);
Log(Logs::Moderate, Logs::Netcode, "UF::ENCODE(OP_MoveItem)");
Log(Logs::Detail, Logs::Netcode, "UF::ENCODE(OP_MoveItem)");
eq->from_slot = ServerToUFSlot(emu->from_slot);
eq->to_slot = ServerToUFSlot(emu->to_slot);
@@ -2739,7 +2739,7 @@ namespace UF
}
float SpawnSize = emu->size;
if (!((emu->NPC == 0) || (emu->race <= RACE_GNOME_12) || (emu->race == RACE_IKSAR_128) ||
if (!((emu->NPC == 0) || (emu->race <= RACE_GNOME_12) || (emu->race == RACE_IKSAR_128) ||
(emu->race == RACE_VAH_SHIR_130) || (emu->race == RACE_FROGLOK_330) || (emu->race == RACE_DRAKKIN_522))
)
{
@@ -2942,7 +2942,7 @@ namespace UF
Buffer += sizeof(structs::Spawn_Struct_Position);
if ((emu->NPC == 0) || (emu->race <= RACE_GNOME_12) || (emu->race == RACE_IKSAR_128) ||
if ((emu->NPC == 0) || (emu->race <= RACE_GNOME_12) || (emu->race == RACE_IKSAR_128) ||
(emu->race == RACE_VAH_SHIR_130) || (emu->race == RACE_FROGLOK_330) || (emu->race == RACE_DRAKKIN_522)
)
{
@@ -2978,7 +2978,7 @@ namespace UF
VARSTRUCT_ENCODE_TYPE(uint32, Buffer, 0);
}
if ((emu->NPC == 0) || (emu->race <= RACE_GNOME_12) || (emu->race == RACE_IKSAR_128) ||
if ((emu->NPC == 0) || (emu->race <= RACE_GNOME_12) || (emu->race == RACE_IKSAR_128) ||
(emu->race == RACE_VAH_SHIR_130) || (emu->race == RACE_FROGLOK_330) || (emu->race == RACE_DRAKKIN_522)
)
{
@@ -3584,7 +3584,7 @@ namespace UF
DECODE_LENGTH_EXACT(structs::LootingItem_Struct);
SETUP_DIRECT_DECODE(LootingItem_Struct, structs::LootingItem_Struct);
Log(Logs::Moderate, Logs::Netcode, "UF::DECODE(OP_LootItem)");
Log(Logs::Detail, Logs::Netcode, "UF::DECODE(OP_LootItem)");
IN(lootee);
IN(looter);
@@ -3599,7 +3599,7 @@ namespace UF
DECODE_LENGTH_EXACT(structs::MoveItem_Struct);
SETUP_DIRECT_DECODE(MoveItem_Struct, structs::MoveItem_Struct);
Log(Logs::Moderate, Logs::Netcode, "UF::DECODE(OP_MoveItem)");
Log(Logs::Detail, Logs::Netcode, "UF::DECODE(OP_MoveItem)");
emu->from_slot = UFToServerSlot(eq->from_slot);
emu->to_slot = UFToServerSlot(eq->to_slot);
+18 -11
View File
@@ -20,12 +20,19 @@ void PathManager::LoadPaths()
{
m_server_path = File::FindEqemuConfigPath();
std::filesystem::current_path(m_server_path);
if (!m_server_path.empty()) {
std::filesystem::current_path(m_server_path);
}
LogInfo("[PathManager] server [{}]", m_server_path);
if (m_server_path.empty()) {
LogInfo("Failed to load server path");
return;
}
LogInfo("server [{}]", m_server_path);
if (!EQEmuConfig::LoadConfig()) {
LogError("[PathManager] Failed to load eqemu config");
LogError("Failed to load eqemu config");
return;
}
@@ -77,14 +84,14 @@ void PathManager::LoadPaths()
m_log_path = fs::relative(fs::path{m_server_path + "/" + c->LogDir}).string();
}
LogInfo("[PathManager] logs [{}]", m_log_path);
LogInfo("[PathManager] lua mods [{}]", m_lua_mods_path);
LogInfo("[PathManager] lua_modules [{}]", m_lua_modules_path);
LogInfo("[PathManager] maps [{}]", m_maps_path);
LogInfo("[PathManager] patches [{}]", m_patch_path);
LogInfo("[PathManager] plugins [{}]", m_plugins_path);
LogInfo("[PathManager] quests [{}]", m_quests_path);
LogInfo("[PathManager] shared_memory [{}]", m_shared_memory_path);
LogInfo("logs path [{}]", m_log_path);
LogInfo("lua mods path [{}]", m_lua_mods_path);
LogInfo("lua_modules path [{}]", m_lua_modules_path);
LogInfo("maps path [{}]", m_maps_path);
LogInfo("patches path [{}]", m_patch_path);
LogInfo("plugins path [{}]", m_plugins_path);
LogInfo("quests path [{}]", m_quests_path);
LogInfo("shared_memory path [{}]", m_shared_memory_path);
}
const std::string &PathManager::GetServerPath() const
+3 -5
View File
@@ -55,14 +55,12 @@ std::string GetPlatformName()
return "UCS";
case EQEmuExePlatform::ExePlatformLogin:
return "Login";
case EQEmuExePlatform::ExePlatformSocket_Server:
return "SocketServer";
case EQEmuExePlatform::ExePlatformSharedMemory:
return "SharedMemory";
return "SharedMem";
case EQEmuExePlatform::ExePlatformClientImport:
return "ClientImport";
return "Import";
case EQEmuExePlatform::ExePlatformClientExport:
return "ClientExport";
return "Export";
case EQEmuExePlatform::ExePlatformLaunch:
return "Launch";
case EQEmuExePlatform::ExePlatformHC:
+3
View File
@@ -18,6 +18,7 @@
*/
#include "profanity_manager.h"
#include "eqemu_logsys.h"
#include "dbcore.h"
#include "strings.h"
@@ -235,6 +236,8 @@ bool EQ::ProfanityManager::load_database_entries(DBcore *db) {
}
}
LogInfo("Loaded [{}] profanity entries", Strings::Commify(profanity_list.size()));
return true;
}
@@ -0,0 +1,334 @@
/**
* DO NOT MODIFY THIS FILE
*
* This repository was automatically generated and is NOT to be modified directly.
* Any repository modifications are meant to be made to the repository extending the base.
* Any modifications to base repositories are to be made by the generator only
*
* @generator ./utils/scripts/generators/repository-generator.pl
* @docs https://eqemu.gitbook.io/server/in-development/developer-area/repositories
*/
#ifndef EQEMU_BASE_CHATCHANNEL_RESERVED_NAMES_REPOSITORY_H
#define EQEMU_BASE_CHATCHANNEL_RESERVED_NAMES_REPOSITORY_H
#include "../../database.h"
#include "../../strings.h"
#include <ctime>
class BaseChatchannelReservedNamesRepository {
public:
struct ChatchannelReservedNames {
int32_t id;
std::string name;
};
static std::string PrimaryKey()
{
return std::string("id");
}
static std::vector<std::string> Columns()
{
return {
"id",
"name",
};
}
static std::vector<std::string> SelectColumns()
{
return {
"id",
"name",
};
}
static std::string ColumnsRaw()
{
return std::string(Strings::Implode(", ", Columns()));
}
static std::string SelectColumnsRaw()
{
return std::string(Strings::Implode(", ", SelectColumns()));
}
static std::string TableName()
{
return std::string("chatchannel_reserved_names");
}
static std::string BaseSelect()
{
return fmt::format(
"SELECT {} FROM {}",
SelectColumnsRaw(),
TableName()
);
}
static std::string BaseInsert()
{
return fmt::format(
"INSERT INTO {} ({}) ",
TableName(),
ColumnsRaw()
);
}
static ChatchannelReservedNames NewEntity()
{
ChatchannelReservedNames e{};
e.id = 0;
e.name = "";
return e;
}
static ChatchannelReservedNames GetChatchannelReservedNames(
const std::vector<ChatchannelReservedNames> &chatchannel_reserved_namess,
int chatchannel_reserved_names_id
)
{
for (auto &chatchannel_reserved_names : chatchannel_reserved_namess) {
if (chatchannel_reserved_names.id == chatchannel_reserved_names_id) {
return chatchannel_reserved_names;
}
}
return NewEntity();
}
static ChatchannelReservedNames FindOne(
Database& db,
int chatchannel_reserved_names_id
)
{
auto results = db.QueryDatabase(
fmt::format(
"{} WHERE {} = {} LIMIT 1",
BaseSelect(),
PrimaryKey(),
chatchannel_reserved_names_id
)
);
auto row = results.begin();
if (results.RowCount() == 1) {
ChatchannelReservedNames e{};
e.id = static_cast<int32_t>(atoi(row[0]));
e.name = row[1] ? row[1] : "";
return e;
}
return NewEntity();
}
static int DeleteOne(
Database& db,
int chatchannel_reserved_names_id
)
{
auto results = db.QueryDatabase(
fmt::format(
"DELETE FROM {} WHERE {} = {}",
TableName(),
PrimaryKey(),
chatchannel_reserved_names_id
)
);
return (results.Success() ? results.RowsAffected() : 0);
}
static int UpdateOne(
Database& db,
const ChatchannelReservedNames &e
)
{
std::vector<std::string> v;
auto columns = Columns();
v.push_back(columns[1] + " = '" + Strings::Escape(e.name) + "'");
auto results = db.QueryDatabase(
fmt::format(
"UPDATE {} SET {} WHERE {} = {}",
TableName(),
Strings::Implode(", ", v),
PrimaryKey(),
e.id
)
);
return (results.Success() ? results.RowsAffected() : 0);
}
static ChatchannelReservedNames InsertOne(
Database& db,
ChatchannelReservedNames e
)
{
std::vector<std::string> v;
v.push_back(std::to_string(e.id));
v.push_back("'" + Strings::Escape(e.name) + "'");
auto results = db.QueryDatabase(
fmt::format(
"{} VALUES ({})",
BaseInsert(),
Strings::Implode(",", v)
)
);
if (results.Success()) {
e.id = results.LastInsertedID();
return e;
}
e = NewEntity();
return e;
}
static int InsertMany(
Database& db,
const std::vector<ChatchannelReservedNames> &entries
)
{
std::vector<std::string> insert_chunks;
for (auto &e: entries) {
std::vector<std::string> v;
v.push_back(std::to_string(e.id));
v.push_back("'" + Strings::Escape(e.name) + "'");
insert_chunks.push_back("(" + Strings::Implode(",", v) + ")");
}
std::vector<std::string> v;
auto results = db.QueryDatabase(
fmt::format(
"{} VALUES {}",
BaseInsert(),
Strings::Implode(",", insert_chunks)
)
);
return (results.Success() ? results.RowsAffected() : 0);
}
static std::vector<ChatchannelReservedNames> All(Database& db)
{
std::vector<ChatchannelReservedNames> all_entries;
auto results = db.QueryDatabase(
fmt::format(
"{}",
BaseSelect()
)
);
all_entries.reserve(results.RowCount());
for (auto row = results.begin(); row != results.end(); ++row) {
ChatchannelReservedNames e{};
e.id = static_cast<int32_t>(atoi(row[0]));
e.name = row[1] ? row[1] : "";
all_entries.push_back(e);
}
return all_entries;
}
static std::vector<ChatchannelReservedNames> GetWhere(Database& db, const std::string &where_filter)
{
std::vector<ChatchannelReservedNames> all_entries;
auto results = db.QueryDatabase(
fmt::format(
"{} WHERE {}",
BaseSelect(),
where_filter
)
);
all_entries.reserve(results.RowCount());
for (auto row = results.begin(); row != results.end(); ++row) {
ChatchannelReservedNames e{};
e.id = static_cast<int32_t>(atoi(row[0]));
e.name = row[1] ? row[1] : "";
all_entries.push_back(e);
}
return all_entries;
}
static int DeleteWhere(Database& db, const std::string &where_filter)
{
auto results = db.QueryDatabase(
fmt::format(
"DELETE FROM {} WHERE {}",
TableName(),
where_filter
)
);
return (results.Success() ? results.RowsAffected() : 0);
}
static int Truncate(Database& db)
{
auto results = db.QueryDatabase(
fmt::format(
"TRUNCATE TABLE {}",
TableName()
)
);
return (results.Success() ? results.RowsAffected() : 0);
}
static int64 GetMaxId(Database& db)
{
auto results = db.QueryDatabase(
fmt::format(
"SELECT COALESCE(MAX({}), 0) FROM {}",
PrimaryKey(),
TableName()
)
);
return (results.Success() && results.begin()[0] ? strtoll(results.begin()[0], nullptr, 10) : 0);
}
static int64 Count(Database& db, const std::string &where_filter = "")
{
auto results = db.QueryDatabase(
fmt::format(
"SELECT COUNT(*) FROM {} {}",
TableName(),
(where_filter.empty() ? "" : "WHERE " + where_filter)
)
);
return (results.Success() && results.begin()[0] ? strtoll(results.begin()[0], nullptr, 10) : 0);
}
};
#endif //EQEMU_BASE_CHATCHANNEL_RESERVED_NAMES_REPOSITORY_H
@@ -0,0 +1,364 @@
/**
* DO NOT MODIFY THIS FILE
*
* This repository was automatically generated and is NOT to be modified directly.
* Any repository modifications are meant to be made to the repository extending the base.
* Any modifications to base repositories are to be made by the generator only
*
* @generator ./utils/scripts/generators/repository-generator.pl
* @docs https://eqemu.gitbook.io/server/in-development/developer-area/repositories
*/
#ifndef EQEMU_BASE_CHATCHANNELS_REPOSITORY_H
#define EQEMU_BASE_CHATCHANNELS_REPOSITORY_H
#include "../../database.h"
#include "../../strings.h"
#include <ctime>
class BaseChatchannelsRepository {
public:
struct Chatchannels {
int32_t id;
std::string name;
std::string owner;
std::string password;
int32_t minstatus;
};
static std::string PrimaryKey()
{
return std::string("id");
}
static std::vector<std::string> Columns()
{
return {
"id",
"name",
"owner",
"password",
"minstatus",
};
}
static std::vector<std::string> SelectColumns()
{
return {
"id",
"name",
"owner",
"password",
"minstatus",
};
}
static std::string ColumnsRaw()
{
return std::string(Strings::Implode(", ", Columns()));
}
static std::string SelectColumnsRaw()
{
return std::string(Strings::Implode(", ", SelectColumns()));
}
static std::string TableName()
{
return std::string("chatchannels");
}
static std::string BaseSelect()
{
return fmt::format(
"SELECT {} FROM {}",
SelectColumnsRaw(),
TableName()
);
}
static std::string BaseInsert()
{
return fmt::format(
"INSERT INTO {} ({}) ",
TableName(),
ColumnsRaw()
);
}
static Chatchannels NewEntity()
{
Chatchannels e{};
e.id = 0;
e.name = "";
e.owner = "";
e.password = "";
e.minstatus = 0;
return e;
}
static Chatchannels GetChatchannels(
const std::vector<Chatchannels> &chatchannelss,
int chatchannels_id
)
{
for (auto &chatchannels : chatchannelss) {
if (chatchannels.id == chatchannels_id) {
return chatchannels;
}
}
return NewEntity();
}
static Chatchannels FindOne(
Database& db,
int chatchannels_id
)
{
auto results = db.QueryDatabase(
fmt::format(
"{} WHERE {} = {} LIMIT 1",
BaseSelect(),
PrimaryKey(),
chatchannels_id
)
);
auto row = results.begin();
if (results.RowCount() == 1) {
Chatchannels e{};
e.id = static_cast<int32_t>(atoi(row[0]));
e.name = row[1] ? row[1] : "";
e.owner = row[2] ? row[2] : "";
e.password = row[3] ? row[3] : "";
e.minstatus = static_cast<int32_t>(atoi(row[4]));
return e;
}
return NewEntity();
}
static int DeleteOne(
Database& db,
int chatchannels_id
)
{
auto results = db.QueryDatabase(
fmt::format(
"DELETE FROM {} WHERE {} = {}",
TableName(),
PrimaryKey(),
chatchannels_id
)
);
return (results.Success() ? results.RowsAffected() : 0);
}
static int UpdateOne(
Database& db,
const Chatchannels &e
)
{
std::vector<std::string> v;
auto columns = Columns();
v.push_back(columns[1] + " = '" + Strings::Escape(e.name) + "'");
v.push_back(columns[2] + " = '" + Strings::Escape(e.owner) + "'");
v.push_back(columns[3] + " = '" + Strings::Escape(e.password) + "'");
v.push_back(columns[4] + " = " + std::to_string(e.minstatus));
auto results = db.QueryDatabase(
fmt::format(
"UPDATE {} SET {} WHERE {} = {}",
TableName(),
Strings::Implode(", ", v),
PrimaryKey(),
e.id
)
);
return (results.Success() ? results.RowsAffected() : 0);
}
static Chatchannels InsertOne(
Database& db,
Chatchannels e
)
{
std::vector<std::string> v;
v.push_back(std::to_string(e.id));
v.push_back("'" + Strings::Escape(e.name) + "'");
v.push_back("'" + Strings::Escape(e.owner) + "'");
v.push_back("'" + Strings::Escape(e.password) + "'");
v.push_back(std::to_string(e.minstatus));
auto results = db.QueryDatabase(
fmt::format(
"{} VALUES ({})",
BaseInsert(),
Strings::Implode(",", v)
)
);
if (results.Success()) {
e.id = results.LastInsertedID();
return e;
}
e = NewEntity();
return e;
}
static int InsertMany(
Database& db,
const std::vector<Chatchannels> &entries
)
{
std::vector<std::string> insert_chunks;
for (auto &e: entries) {
std::vector<std::string> v;
v.push_back(std::to_string(e.id));
v.push_back("'" + Strings::Escape(e.name) + "'");
v.push_back("'" + Strings::Escape(e.owner) + "'");
v.push_back("'" + Strings::Escape(e.password) + "'");
v.push_back(std::to_string(e.minstatus));
insert_chunks.push_back("(" + Strings::Implode(",", v) + ")");
}
std::vector<std::string> v;
auto results = db.QueryDatabase(
fmt::format(
"{} VALUES {}",
BaseInsert(),
Strings::Implode(",", insert_chunks)
)
);
return (results.Success() ? results.RowsAffected() : 0);
}
static std::vector<Chatchannels> All(Database& db)
{
std::vector<Chatchannels> all_entries;
auto results = db.QueryDatabase(
fmt::format(
"{}",
BaseSelect()
)
);
all_entries.reserve(results.RowCount());
for (auto row = results.begin(); row != results.end(); ++row) {
Chatchannels e{};
e.id = static_cast<int32_t>(atoi(row[0]));
e.name = row[1] ? row[1] : "";
e.owner = row[2] ? row[2] : "";
e.password = row[3] ? row[3] : "";
e.minstatus = static_cast<int32_t>(atoi(row[4]));
all_entries.push_back(e);
}
return all_entries;
}
static std::vector<Chatchannels> GetWhere(Database& db, const std::string &where_filter)
{
std::vector<Chatchannels> all_entries;
auto results = db.QueryDatabase(
fmt::format(
"{} WHERE {}",
BaseSelect(),
where_filter
)
);
all_entries.reserve(results.RowCount());
for (auto row = results.begin(); row != results.end(); ++row) {
Chatchannels e{};
e.id = static_cast<int32_t>(atoi(row[0]));
e.name = row[1] ? row[1] : "";
e.owner = row[2] ? row[2] : "";
e.password = row[3] ? row[3] : "";
e.minstatus = static_cast<int32_t>(atoi(row[4]));
all_entries.push_back(e);
}
return all_entries;
}
static int DeleteWhere(Database& db, const std::string &where_filter)
{
auto results = db.QueryDatabase(
fmt::format(
"DELETE FROM {} WHERE {}",
TableName(),
where_filter
)
);
return (results.Success() ? results.RowsAffected() : 0);
}
static int Truncate(Database& db)
{
auto results = db.QueryDatabase(
fmt::format(
"TRUNCATE TABLE {}",
TableName()
)
);
return (results.Success() ? results.RowsAffected() : 0);
}
static int64 GetMaxId(Database& db)
{
auto results = db.QueryDatabase(
fmt::format(
"SELECT COALESCE(MAX({}), 0) FROM {}",
PrimaryKey(),
TableName()
)
);
return (results.Success() && results.begin()[0] ? strtoll(results.begin()[0], nullptr, 10) : 0);
}
static int64 Count(Database& db, const std::string &where_filter = "")
{
auto results = db.QueryDatabase(
fmt::format(
"SELECT COUNT(*) FROM {} {}",
TableName(),
(where_filter.empty() ? "" : "WHERE " + where_filter)
)
);
return (results.Success() && results.begin()[0] ? strtoll(results.begin()[0], nullptr, 10) : 0);
}
};
#endif //EQEMU_BASE_CHATCHANNELS_REPOSITORY_H
@@ -0,0 +1,414 @@
/**
* DO NOT MODIFY THIS FILE
*
* This repository was automatically generated and is NOT to be modified directly.
* Any repository modifications are meant to be made to the repository extending the base.
* Any modifications to base repositories are to be made by the generator only
*
* @generator ./utils/scripts/generators/repository-generator.pl
* @docs https://eqemu.gitbook.io/server/in-development/developer-area/repositories
*/
#ifndef EQEMU_BASE_MERC_ARMORINFO_REPOSITORY_H
#define EQEMU_BASE_MERC_ARMORINFO_REPOSITORY_H
#include "../../database.h"
#include "../../strings.h"
#include <ctime>
class BaseMercArmorinfoRepository {
public:
struct MercArmorinfo {
int32_t id;
uint32_t merc_npc_type_id;
uint8_t minlevel;
uint8_t maxlevel;
uint8_t texture;
uint8_t helmtexture;
uint32_t armortint_id;
uint8_t armortint_red;
uint8_t armortint_green;
uint8_t armortint_blue;
};
static std::string PrimaryKey()
{
return std::string("id");
}
static std::vector<std::string> Columns()
{
return {
"id",
"merc_npc_type_id",
"minlevel",
"maxlevel",
"texture",
"helmtexture",
"armortint_id",
"armortint_red",
"armortint_green",
"armortint_blue",
};
}
static std::vector<std::string> SelectColumns()
{
return {
"id",
"merc_npc_type_id",
"minlevel",
"maxlevel",
"texture",
"helmtexture",
"armortint_id",
"armortint_red",
"armortint_green",
"armortint_blue",
};
}
static std::string ColumnsRaw()
{
return std::string(Strings::Implode(", ", Columns()));
}
static std::string SelectColumnsRaw()
{
return std::string(Strings::Implode(", ", SelectColumns()));
}
static std::string TableName()
{
return std::string("merc_armorinfo");
}
static std::string BaseSelect()
{
return fmt::format(
"SELECT {} FROM {}",
SelectColumnsRaw(),
TableName()
);
}
static std::string BaseInsert()
{
return fmt::format(
"INSERT INTO {} ({}) ",
TableName(),
ColumnsRaw()
);
}
static MercArmorinfo NewEntity()
{
MercArmorinfo e{};
e.id = 0;
e.merc_npc_type_id = 0;
e.minlevel = 1;
e.maxlevel = 255;
e.texture = 0;
e.helmtexture = 0;
e.armortint_id = 0;
e.armortint_red = 0;
e.armortint_green = 0;
e.armortint_blue = 0;
return e;
}
static MercArmorinfo GetMercArmorinfo(
const std::vector<MercArmorinfo> &merc_armorinfos,
int merc_armorinfo_id
)
{
for (auto &merc_armorinfo : merc_armorinfos) {
if (merc_armorinfo.id == merc_armorinfo_id) {
return merc_armorinfo;
}
}
return NewEntity();
}
static MercArmorinfo FindOne(
Database& db,
int merc_armorinfo_id
)
{
auto results = db.QueryDatabase(
fmt::format(
"{} WHERE {} = {} LIMIT 1",
BaseSelect(),
PrimaryKey(),
merc_armorinfo_id
)
);
auto row = results.begin();
if (results.RowCount() == 1) {
MercArmorinfo e{};
e.id = static_cast<int32_t>(atoi(row[0]));
e.merc_npc_type_id = static_cast<uint32_t>(strtoul(row[1], nullptr, 10));
e.minlevel = static_cast<uint8_t>(strtoul(row[2], nullptr, 10));
e.maxlevel = static_cast<uint8_t>(strtoul(row[3], nullptr, 10));
e.texture = static_cast<uint8_t>(strtoul(row[4], nullptr, 10));
e.helmtexture = static_cast<uint8_t>(strtoul(row[5], nullptr, 10));
e.armortint_id = static_cast<uint32_t>(strtoul(row[6], nullptr, 10));
e.armortint_red = static_cast<uint8_t>(strtoul(row[7], nullptr, 10));
e.armortint_green = static_cast<uint8_t>(strtoul(row[8], nullptr, 10));
e.armortint_blue = static_cast<uint8_t>(strtoul(row[9], nullptr, 10));
return e;
}
return NewEntity();
}
static int DeleteOne(
Database& db,
int merc_armorinfo_id
)
{
auto results = db.QueryDatabase(
fmt::format(
"DELETE FROM {} WHERE {} = {}",
TableName(),
PrimaryKey(),
merc_armorinfo_id
)
);
return (results.Success() ? results.RowsAffected() : 0);
}
static int UpdateOne(
Database& db,
const MercArmorinfo &e
)
{
std::vector<std::string> v;
auto columns = Columns();
v.push_back(columns[1] + " = " + std::to_string(e.merc_npc_type_id));
v.push_back(columns[2] + " = " + std::to_string(e.minlevel));
v.push_back(columns[3] + " = " + std::to_string(e.maxlevel));
v.push_back(columns[4] + " = " + std::to_string(e.texture));
v.push_back(columns[5] + " = " + std::to_string(e.helmtexture));
v.push_back(columns[6] + " = " + std::to_string(e.armortint_id));
v.push_back(columns[7] + " = " + std::to_string(e.armortint_red));
v.push_back(columns[8] + " = " + std::to_string(e.armortint_green));
v.push_back(columns[9] + " = " + std::to_string(e.armortint_blue));
auto results = db.QueryDatabase(
fmt::format(
"UPDATE {} SET {} WHERE {} = {}",
TableName(),
Strings::Implode(", ", v),
PrimaryKey(),
e.id
)
);
return (results.Success() ? results.RowsAffected() : 0);
}
static MercArmorinfo InsertOne(
Database& db,
MercArmorinfo e
)
{
std::vector<std::string> v;
v.push_back(std::to_string(e.id));
v.push_back(std::to_string(e.merc_npc_type_id));
v.push_back(std::to_string(e.minlevel));
v.push_back(std::to_string(e.maxlevel));
v.push_back(std::to_string(e.texture));
v.push_back(std::to_string(e.helmtexture));
v.push_back(std::to_string(e.armortint_id));
v.push_back(std::to_string(e.armortint_red));
v.push_back(std::to_string(e.armortint_green));
v.push_back(std::to_string(e.armortint_blue));
auto results = db.QueryDatabase(
fmt::format(
"{} VALUES ({})",
BaseInsert(),
Strings::Implode(",", v)
)
);
if (results.Success()) {
e.id = results.LastInsertedID();
return e;
}
e = NewEntity();
return e;
}
static int InsertMany(
Database& db,
const std::vector<MercArmorinfo> &entries
)
{
std::vector<std::string> insert_chunks;
for (auto &e: entries) {
std::vector<std::string> v;
v.push_back(std::to_string(e.id));
v.push_back(std::to_string(e.merc_npc_type_id));
v.push_back(std::to_string(e.minlevel));
v.push_back(std::to_string(e.maxlevel));
v.push_back(std::to_string(e.texture));
v.push_back(std::to_string(e.helmtexture));
v.push_back(std::to_string(e.armortint_id));
v.push_back(std::to_string(e.armortint_red));
v.push_back(std::to_string(e.armortint_green));
v.push_back(std::to_string(e.armortint_blue));
insert_chunks.push_back("(" + Strings::Implode(",", v) + ")");
}
std::vector<std::string> v;
auto results = db.QueryDatabase(
fmt::format(
"{} VALUES {}",
BaseInsert(),
Strings::Implode(",", insert_chunks)
)
);
return (results.Success() ? results.RowsAffected() : 0);
}
static std::vector<MercArmorinfo> All(Database& db)
{
std::vector<MercArmorinfo> all_entries;
auto results = db.QueryDatabase(
fmt::format(
"{}",
BaseSelect()
)
);
all_entries.reserve(results.RowCount());
for (auto row = results.begin(); row != results.end(); ++row) {
MercArmorinfo e{};
e.id = static_cast<int32_t>(atoi(row[0]));
e.merc_npc_type_id = static_cast<uint32_t>(strtoul(row[1], nullptr, 10));
e.minlevel = static_cast<uint8_t>(strtoul(row[2], nullptr, 10));
e.maxlevel = static_cast<uint8_t>(strtoul(row[3], nullptr, 10));
e.texture = static_cast<uint8_t>(strtoul(row[4], nullptr, 10));
e.helmtexture = static_cast<uint8_t>(strtoul(row[5], nullptr, 10));
e.armortint_id = static_cast<uint32_t>(strtoul(row[6], nullptr, 10));
e.armortint_red = static_cast<uint8_t>(strtoul(row[7], nullptr, 10));
e.armortint_green = static_cast<uint8_t>(strtoul(row[8], nullptr, 10));
e.armortint_blue = static_cast<uint8_t>(strtoul(row[9], nullptr, 10));
all_entries.push_back(e);
}
return all_entries;
}
static std::vector<MercArmorinfo> GetWhere(Database& db, const std::string &where_filter)
{
std::vector<MercArmorinfo> all_entries;
auto results = db.QueryDatabase(
fmt::format(
"{} WHERE {}",
BaseSelect(),
where_filter
)
);
all_entries.reserve(results.RowCount());
for (auto row = results.begin(); row != results.end(); ++row) {
MercArmorinfo e{};
e.id = static_cast<int32_t>(atoi(row[0]));
e.merc_npc_type_id = static_cast<uint32_t>(strtoul(row[1], nullptr, 10));
e.minlevel = static_cast<uint8_t>(strtoul(row[2], nullptr, 10));
e.maxlevel = static_cast<uint8_t>(strtoul(row[3], nullptr, 10));
e.texture = static_cast<uint8_t>(strtoul(row[4], nullptr, 10));
e.helmtexture = static_cast<uint8_t>(strtoul(row[5], nullptr, 10));
e.armortint_id = static_cast<uint32_t>(strtoul(row[6], nullptr, 10));
e.armortint_red = static_cast<uint8_t>(strtoul(row[7], nullptr, 10));
e.armortint_green = static_cast<uint8_t>(strtoul(row[8], nullptr, 10));
e.armortint_blue = static_cast<uint8_t>(strtoul(row[9], nullptr, 10));
all_entries.push_back(e);
}
return all_entries;
}
static int DeleteWhere(Database& db, const std::string &where_filter)
{
auto results = db.QueryDatabase(
fmt::format(
"DELETE FROM {} WHERE {}",
TableName(),
where_filter
)
);
return (results.Success() ? results.RowsAffected() : 0);
}
static int Truncate(Database& db)
{
auto results = db.QueryDatabase(
fmt::format(
"TRUNCATE TABLE {}",
TableName()
)
);
return (results.Success() ? results.RowsAffected() : 0);
}
static int64 GetMaxId(Database& db)
{
auto results = db.QueryDatabase(
fmt::format(
"SELECT COALESCE(MAX({}), 0) FROM {}",
PrimaryKey(),
TableName()
)
);
return (results.Success() && results.begin()[0] ? strtoll(results.begin()[0], nullptr, 10) : 0);
}
static int64 Count(Database& db, const std::string &where_filter = "")
{
auto results = db.QueryDatabase(
fmt::format(
"SELECT COUNT(*) FROM {} {}",
TableName(),
(where_filter.empty() ? "" : "WHERE " + where_filter)
)
);
return (results.Success() && results.begin()[0] ? strtoll(results.begin()[0], nullptr, 10) : 0);
}
};
#endif //EQEMU_BASE_MERC_ARMORINFO_REPOSITORY_H
@@ -0,0 +1,504 @@
/**
* DO NOT MODIFY THIS FILE
*
* This repository was automatically generated and is NOT to be modified directly.
* Any repository modifications are meant to be made to the repository extending the base.
* Any modifications to base repositories are to be made by the generator only
*
* @generator ./utils/scripts/generators/repository-generator.pl
* @docs https://eqemu.gitbook.io/server/in-development/developer-area/repositories
*/
#ifndef EQEMU_BASE_MERC_BUFFS_REPOSITORY_H
#define EQEMU_BASE_MERC_BUFFS_REPOSITORY_H
#include "../../database.h"
#include "../../strings.h"
#include <ctime>
class BaseMercBuffsRepository {
public:
struct MercBuffs {
uint32_t MercBuffId;
uint32_t MercId;
uint32_t SpellId;
uint32_t CasterLevel;
uint32_t DurationFormula;
int32_t TicsRemaining;
uint32_t PoisonCounters;
uint32_t DiseaseCounters;
uint32_t CurseCounters;
uint32_t CorruptionCounters;
uint32_t HitCount;
uint32_t MeleeRune;
uint32_t MagicRune;
int32_t dot_rune;
int32_t caston_x;
int8_t Persistent;
int32_t caston_y;
int32_t caston_z;
int32_t ExtraDIChance;
};
static std::string PrimaryKey()
{
return std::string("MercBuffId");
}
static std::vector<std::string> Columns()
{
return {
"MercBuffId",
"MercId",
"SpellId",
"CasterLevel",
"DurationFormula",
"TicsRemaining",
"PoisonCounters",
"DiseaseCounters",
"CurseCounters",
"CorruptionCounters",
"HitCount",
"MeleeRune",
"MagicRune",
"dot_rune",
"caston_x",
"Persistent",
"caston_y",
"caston_z",
"ExtraDIChance",
};
}
static std::vector<std::string> SelectColumns()
{
return {
"MercBuffId",
"MercId",
"SpellId",
"CasterLevel",
"DurationFormula",
"TicsRemaining",
"PoisonCounters",
"DiseaseCounters",
"CurseCounters",
"CorruptionCounters",
"HitCount",
"MeleeRune",
"MagicRune",
"dot_rune",
"caston_x",
"Persistent",
"caston_y",
"caston_z",
"ExtraDIChance",
};
}
static std::string ColumnsRaw()
{
return std::string(Strings::Implode(", ", Columns()));
}
static std::string SelectColumnsRaw()
{
return std::string(Strings::Implode(", ", SelectColumns()));
}
static std::string TableName()
{
return std::string("merc_buffs");
}
static std::string BaseSelect()
{
return fmt::format(
"SELECT {} FROM {}",
SelectColumnsRaw(),
TableName()
);
}
static std::string BaseInsert()
{
return fmt::format(
"INSERT INTO {} ({}) ",
TableName(),
ColumnsRaw()
);
}
static MercBuffs NewEntity()
{
MercBuffs e{};
e.MercBuffId = 0;
e.MercId = 0;
e.SpellId = 0;
e.CasterLevel = 0;
e.DurationFormula = 0;
e.TicsRemaining = 0;
e.PoisonCounters = 0;
e.DiseaseCounters = 0;
e.CurseCounters = 0;
e.CorruptionCounters = 0;
e.HitCount = 0;
e.MeleeRune = 0;
e.MagicRune = 0;
e.dot_rune = 0;
e.caston_x = 0;
e.Persistent = 0;
e.caston_y = 0;
e.caston_z = 0;
e.ExtraDIChance = 0;
return e;
}
static MercBuffs GetMercBuffs(
const std::vector<MercBuffs> &merc_buffss,
int merc_buffs_id
)
{
for (auto &merc_buffs : merc_buffss) {
if (merc_buffs.MercBuffId == merc_buffs_id) {
return merc_buffs;
}
}
return NewEntity();
}
static MercBuffs FindOne(
Database& db,
int merc_buffs_id
)
{
auto results = db.QueryDatabase(
fmt::format(
"{} WHERE {} = {} LIMIT 1",
BaseSelect(),
PrimaryKey(),
merc_buffs_id
)
);
auto row = results.begin();
if (results.RowCount() == 1) {
MercBuffs e{};
e.MercBuffId = static_cast<uint32_t>(strtoul(row[0], nullptr, 10));
e.MercId = static_cast<uint32_t>(strtoul(row[1], nullptr, 10));
e.SpellId = static_cast<uint32_t>(strtoul(row[2], nullptr, 10));
e.CasterLevel = static_cast<uint32_t>(strtoul(row[3], nullptr, 10));
e.DurationFormula = static_cast<uint32_t>(strtoul(row[4], nullptr, 10));
e.TicsRemaining = static_cast<int32_t>(atoi(row[5]));
e.PoisonCounters = static_cast<uint32_t>(strtoul(row[6], nullptr, 10));
e.DiseaseCounters = static_cast<uint32_t>(strtoul(row[7], nullptr, 10));
e.CurseCounters = static_cast<uint32_t>(strtoul(row[8], nullptr, 10));
e.CorruptionCounters = static_cast<uint32_t>(strtoul(row[9], nullptr, 10));
e.HitCount = static_cast<uint32_t>(strtoul(row[10], nullptr, 10));
e.MeleeRune = static_cast<uint32_t>(strtoul(row[11], nullptr, 10));
e.MagicRune = static_cast<uint32_t>(strtoul(row[12], nullptr, 10));
e.dot_rune = static_cast<int32_t>(atoi(row[13]));
e.caston_x = static_cast<int32_t>(atoi(row[14]));
e.Persistent = static_cast<int8_t>(atoi(row[15]));
e.caston_y = static_cast<int32_t>(atoi(row[16]));
e.caston_z = static_cast<int32_t>(atoi(row[17]));
e.ExtraDIChance = static_cast<int32_t>(atoi(row[18]));
return e;
}
return NewEntity();
}
static int DeleteOne(
Database& db,
int merc_buffs_id
)
{
auto results = db.QueryDatabase(
fmt::format(
"DELETE FROM {} WHERE {} = {}",
TableName(),
PrimaryKey(),
merc_buffs_id
)
);
return (results.Success() ? results.RowsAffected() : 0);
}
static int UpdateOne(
Database& db,
const MercBuffs &e
)
{
std::vector<std::string> v;
auto columns = Columns();
v.push_back(columns[1] + " = " + std::to_string(e.MercId));
v.push_back(columns[2] + " = " + std::to_string(e.SpellId));
v.push_back(columns[3] + " = " + std::to_string(e.CasterLevel));
v.push_back(columns[4] + " = " + std::to_string(e.DurationFormula));
v.push_back(columns[5] + " = " + std::to_string(e.TicsRemaining));
v.push_back(columns[6] + " = " + std::to_string(e.PoisonCounters));
v.push_back(columns[7] + " = " + std::to_string(e.DiseaseCounters));
v.push_back(columns[8] + " = " + std::to_string(e.CurseCounters));
v.push_back(columns[9] + " = " + std::to_string(e.CorruptionCounters));
v.push_back(columns[10] + " = " + std::to_string(e.HitCount));
v.push_back(columns[11] + " = " + std::to_string(e.MeleeRune));
v.push_back(columns[12] + " = " + std::to_string(e.MagicRune));
v.push_back(columns[13] + " = " + std::to_string(e.dot_rune));
v.push_back(columns[14] + " = " + std::to_string(e.caston_x));
v.push_back(columns[15] + " = " + std::to_string(e.Persistent));
v.push_back(columns[16] + " = " + std::to_string(e.caston_y));
v.push_back(columns[17] + " = " + std::to_string(e.caston_z));
v.push_back(columns[18] + " = " + std::to_string(e.ExtraDIChance));
auto results = db.QueryDatabase(
fmt::format(
"UPDATE {} SET {} WHERE {} = {}",
TableName(),
Strings::Implode(", ", v),
PrimaryKey(),
e.MercBuffId
)
);
return (results.Success() ? results.RowsAffected() : 0);
}
static MercBuffs InsertOne(
Database& db,
MercBuffs e
)
{
std::vector<std::string> v;
v.push_back(std::to_string(e.MercBuffId));
v.push_back(std::to_string(e.MercId));
v.push_back(std::to_string(e.SpellId));
v.push_back(std::to_string(e.CasterLevel));
v.push_back(std::to_string(e.DurationFormula));
v.push_back(std::to_string(e.TicsRemaining));
v.push_back(std::to_string(e.PoisonCounters));
v.push_back(std::to_string(e.DiseaseCounters));
v.push_back(std::to_string(e.CurseCounters));
v.push_back(std::to_string(e.CorruptionCounters));
v.push_back(std::to_string(e.HitCount));
v.push_back(std::to_string(e.MeleeRune));
v.push_back(std::to_string(e.MagicRune));
v.push_back(std::to_string(e.dot_rune));
v.push_back(std::to_string(e.caston_x));
v.push_back(std::to_string(e.Persistent));
v.push_back(std::to_string(e.caston_y));
v.push_back(std::to_string(e.caston_z));
v.push_back(std::to_string(e.ExtraDIChance));
auto results = db.QueryDatabase(
fmt::format(
"{} VALUES ({})",
BaseInsert(),
Strings::Implode(",", v)
)
);
if (results.Success()) {
e.MercBuffId = results.LastInsertedID();
return e;
}
e = NewEntity();
return e;
}
static int InsertMany(
Database& db,
const std::vector<MercBuffs> &entries
)
{
std::vector<std::string> insert_chunks;
for (auto &e: entries) {
std::vector<std::string> v;
v.push_back(std::to_string(e.MercBuffId));
v.push_back(std::to_string(e.MercId));
v.push_back(std::to_string(e.SpellId));
v.push_back(std::to_string(e.CasterLevel));
v.push_back(std::to_string(e.DurationFormula));
v.push_back(std::to_string(e.TicsRemaining));
v.push_back(std::to_string(e.PoisonCounters));
v.push_back(std::to_string(e.DiseaseCounters));
v.push_back(std::to_string(e.CurseCounters));
v.push_back(std::to_string(e.CorruptionCounters));
v.push_back(std::to_string(e.HitCount));
v.push_back(std::to_string(e.MeleeRune));
v.push_back(std::to_string(e.MagicRune));
v.push_back(std::to_string(e.dot_rune));
v.push_back(std::to_string(e.caston_x));
v.push_back(std::to_string(e.Persistent));
v.push_back(std::to_string(e.caston_y));
v.push_back(std::to_string(e.caston_z));
v.push_back(std::to_string(e.ExtraDIChance));
insert_chunks.push_back("(" + Strings::Implode(",", v) + ")");
}
std::vector<std::string> v;
auto results = db.QueryDatabase(
fmt::format(
"{} VALUES {}",
BaseInsert(),
Strings::Implode(",", insert_chunks)
)
);
return (results.Success() ? results.RowsAffected() : 0);
}
static std::vector<MercBuffs> All(Database& db)
{
std::vector<MercBuffs> all_entries;
auto results = db.QueryDatabase(
fmt::format(
"{}",
BaseSelect()
)
);
all_entries.reserve(results.RowCount());
for (auto row = results.begin(); row != results.end(); ++row) {
MercBuffs e{};
e.MercBuffId = static_cast<uint32_t>(strtoul(row[0], nullptr, 10));
e.MercId = static_cast<uint32_t>(strtoul(row[1], nullptr, 10));
e.SpellId = static_cast<uint32_t>(strtoul(row[2], nullptr, 10));
e.CasterLevel = static_cast<uint32_t>(strtoul(row[3], nullptr, 10));
e.DurationFormula = static_cast<uint32_t>(strtoul(row[4], nullptr, 10));
e.TicsRemaining = static_cast<int32_t>(atoi(row[5]));
e.PoisonCounters = static_cast<uint32_t>(strtoul(row[6], nullptr, 10));
e.DiseaseCounters = static_cast<uint32_t>(strtoul(row[7], nullptr, 10));
e.CurseCounters = static_cast<uint32_t>(strtoul(row[8], nullptr, 10));
e.CorruptionCounters = static_cast<uint32_t>(strtoul(row[9], nullptr, 10));
e.HitCount = static_cast<uint32_t>(strtoul(row[10], nullptr, 10));
e.MeleeRune = static_cast<uint32_t>(strtoul(row[11], nullptr, 10));
e.MagicRune = static_cast<uint32_t>(strtoul(row[12], nullptr, 10));
e.dot_rune = static_cast<int32_t>(atoi(row[13]));
e.caston_x = static_cast<int32_t>(atoi(row[14]));
e.Persistent = static_cast<int8_t>(atoi(row[15]));
e.caston_y = static_cast<int32_t>(atoi(row[16]));
e.caston_z = static_cast<int32_t>(atoi(row[17]));
e.ExtraDIChance = static_cast<int32_t>(atoi(row[18]));
all_entries.push_back(e);
}
return all_entries;
}
static std::vector<MercBuffs> GetWhere(Database& db, const std::string &where_filter)
{
std::vector<MercBuffs> all_entries;
auto results = db.QueryDatabase(
fmt::format(
"{} WHERE {}",
BaseSelect(),
where_filter
)
);
all_entries.reserve(results.RowCount());
for (auto row = results.begin(); row != results.end(); ++row) {
MercBuffs e{};
e.MercBuffId = static_cast<uint32_t>(strtoul(row[0], nullptr, 10));
e.MercId = static_cast<uint32_t>(strtoul(row[1], nullptr, 10));
e.SpellId = static_cast<uint32_t>(strtoul(row[2], nullptr, 10));
e.CasterLevel = static_cast<uint32_t>(strtoul(row[3], nullptr, 10));
e.DurationFormula = static_cast<uint32_t>(strtoul(row[4], nullptr, 10));
e.TicsRemaining = static_cast<int32_t>(atoi(row[5]));
e.PoisonCounters = static_cast<uint32_t>(strtoul(row[6], nullptr, 10));
e.DiseaseCounters = static_cast<uint32_t>(strtoul(row[7], nullptr, 10));
e.CurseCounters = static_cast<uint32_t>(strtoul(row[8], nullptr, 10));
e.CorruptionCounters = static_cast<uint32_t>(strtoul(row[9], nullptr, 10));
e.HitCount = static_cast<uint32_t>(strtoul(row[10], nullptr, 10));
e.MeleeRune = static_cast<uint32_t>(strtoul(row[11], nullptr, 10));
e.MagicRune = static_cast<uint32_t>(strtoul(row[12], nullptr, 10));
e.dot_rune = static_cast<int32_t>(atoi(row[13]));
e.caston_x = static_cast<int32_t>(atoi(row[14]));
e.Persistent = static_cast<int8_t>(atoi(row[15]));
e.caston_y = static_cast<int32_t>(atoi(row[16]));
e.caston_z = static_cast<int32_t>(atoi(row[17]));
e.ExtraDIChance = static_cast<int32_t>(atoi(row[18]));
all_entries.push_back(e);
}
return all_entries;
}
static int DeleteWhere(Database& db, const std::string &where_filter)
{
auto results = db.QueryDatabase(
fmt::format(
"DELETE FROM {} WHERE {}",
TableName(),
where_filter
)
);
return (results.Success() ? results.RowsAffected() : 0);
}
static int Truncate(Database& db)
{
auto results = db.QueryDatabase(
fmt::format(
"TRUNCATE TABLE {}",
TableName()
)
);
return (results.Success() ? results.RowsAffected() : 0);
}
static int64 GetMaxId(Database& db)
{
auto results = db.QueryDatabase(
fmt::format(
"SELECT COALESCE(MAX({}), 0) FROM {}",
PrimaryKey(),
TableName()
)
);
return (results.Success() && results.begin()[0] ? strtoll(results.begin()[0], nullptr, 10) : 0);
}
static int64 Count(Database& db, const std::string &where_filter = "")
{
auto results = db.QueryDatabase(
fmt::format(
"SELECT COUNT(*) FROM {} {}",
TableName(),
(where_filter.empty() ? "" : "WHERE " + where_filter)
)
);
return (results.Success() && results.begin()[0] ? strtoll(results.begin()[0], nullptr, 10) : 0);
}
};
#endif //EQEMU_BASE_MERC_BUFFS_REPOSITORY_H
@@ -0,0 +1,364 @@
/**
* DO NOT MODIFY THIS FILE
*
* This repository was automatically generated and is NOT to be modified directly.
* Any repository modifications are meant to be made to the repository extending the base.
* Any modifications to base repositories are to be made by the generator only
*
* @generator ./utils/scripts/generators/repository-generator.pl
* @docs https://eqemu.gitbook.io/server/in-development/developer-area/repositories
*/
#ifndef EQEMU_BASE_MERC_INVENTORY_REPOSITORY_H
#define EQEMU_BASE_MERC_INVENTORY_REPOSITORY_H
#include "../../database.h"
#include "../../strings.h"
#include <ctime>
class BaseMercInventoryRepository {
public:
struct MercInventory {
uint32_t merc_inventory_id;
uint32_t merc_subtype_id;
uint32_t item_id;
uint32_t min_level;
uint32_t max_level;
};
static std::string PrimaryKey()
{
return std::string("merc_inventory_id");
}
static std::vector<std::string> Columns()
{
return {
"merc_inventory_id",
"merc_subtype_id",
"item_id",
"min_level",
"max_level",
};
}
static std::vector<std::string> SelectColumns()
{
return {
"merc_inventory_id",
"merc_subtype_id",
"item_id",
"min_level",
"max_level",
};
}
static std::string ColumnsRaw()
{
return std::string(Strings::Implode(", ", Columns()));
}
static std::string SelectColumnsRaw()
{
return std::string(Strings::Implode(", ", SelectColumns()));
}
static std::string TableName()
{
return std::string("merc_inventory");
}
static std::string BaseSelect()
{
return fmt::format(
"SELECT {} FROM {}",
SelectColumnsRaw(),
TableName()
);
}
static std::string BaseInsert()
{
return fmt::format(
"INSERT INTO {} ({}) ",
TableName(),
ColumnsRaw()
);
}
static MercInventory NewEntity()
{
MercInventory e{};
e.merc_inventory_id = 0;
e.merc_subtype_id = 0;
e.item_id = 0;
e.min_level = 0;
e.max_level = 0;
return e;
}
static MercInventory GetMercInventory(
const std::vector<MercInventory> &merc_inventorys,
int merc_inventory_id
)
{
for (auto &merc_inventory : merc_inventorys) {
if (merc_inventory.merc_inventory_id == merc_inventory_id) {
return merc_inventory;
}
}
return NewEntity();
}
static MercInventory FindOne(
Database& db,
int merc_inventory_id
)
{
auto results = db.QueryDatabase(
fmt::format(
"{} WHERE {} = {} LIMIT 1",
BaseSelect(),
PrimaryKey(),
merc_inventory_id
)
);
auto row = results.begin();
if (results.RowCount() == 1) {
MercInventory e{};
e.merc_inventory_id = static_cast<uint32_t>(strtoul(row[0], nullptr, 10));
e.merc_subtype_id = static_cast<uint32_t>(strtoul(row[1], nullptr, 10));
e.item_id = static_cast<uint32_t>(strtoul(row[2], nullptr, 10));
e.min_level = static_cast<uint32_t>(strtoul(row[3], nullptr, 10));
e.max_level = static_cast<uint32_t>(strtoul(row[4], nullptr, 10));
return e;
}
return NewEntity();
}
static int DeleteOne(
Database& db,
int merc_inventory_id
)
{
auto results = db.QueryDatabase(
fmt::format(
"DELETE FROM {} WHERE {} = {}",
TableName(),
PrimaryKey(),
merc_inventory_id
)
);
return (results.Success() ? results.RowsAffected() : 0);
}
static int UpdateOne(
Database& db,
const MercInventory &e
)
{
std::vector<std::string> v;
auto columns = Columns();
v.push_back(columns[1] + " = " + std::to_string(e.merc_subtype_id));
v.push_back(columns[2] + " = " + std::to_string(e.item_id));
v.push_back(columns[3] + " = " + std::to_string(e.min_level));
v.push_back(columns[4] + " = " + std::to_string(e.max_level));
auto results = db.QueryDatabase(
fmt::format(
"UPDATE {} SET {} WHERE {} = {}",
TableName(),
Strings::Implode(", ", v),
PrimaryKey(),
e.merc_inventory_id
)
);
return (results.Success() ? results.RowsAffected() : 0);
}
static MercInventory InsertOne(
Database& db,
MercInventory e
)
{
std::vector<std::string> v;
v.push_back(std::to_string(e.merc_inventory_id));
v.push_back(std::to_string(e.merc_subtype_id));
v.push_back(std::to_string(e.item_id));
v.push_back(std::to_string(e.min_level));
v.push_back(std::to_string(e.max_level));
auto results = db.QueryDatabase(
fmt::format(
"{} VALUES ({})",
BaseInsert(),
Strings::Implode(",", v)
)
);
if (results.Success()) {
e.merc_inventory_id = results.LastInsertedID();
return e;
}
e = NewEntity();
return e;
}
static int InsertMany(
Database& db,
const std::vector<MercInventory> &entries
)
{
std::vector<std::string> insert_chunks;
for (auto &e: entries) {
std::vector<std::string> v;
v.push_back(std::to_string(e.merc_inventory_id));
v.push_back(std::to_string(e.merc_subtype_id));
v.push_back(std::to_string(e.item_id));
v.push_back(std::to_string(e.min_level));
v.push_back(std::to_string(e.max_level));
insert_chunks.push_back("(" + Strings::Implode(",", v) + ")");
}
std::vector<std::string> v;
auto results = db.QueryDatabase(
fmt::format(
"{} VALUES {}",
BaseInsert(),
Strings::Implode(",", insert_chunks)
)
);
return (results.Success() ? results.RowsAffected() : 0);
}
static std::vector<MercInventory> All(Database& db)
{
std::vector<MercInventory> all_entries;
auto results = db.QueryDatabase(
fmt::format(
"{}",
BaseSelect()
)
);
all_entries.reserve(results.RowCount());
for (auto row = results.begin(); row != results.end(); ++row) {
MercInventory e{};
e.merc_inventory_id = static_cast<uint32_t>(strtoul(row[0], nullptr, 10));
e.merc_subtype_id = static_cast<uint32_t>(strtoul(row[1], nullptr, 10));
e.item_id = static_cast<uint32_t>(strtoul(row[2], nullptr, 10));
e.min_level = static_cast<uint32_t>(strtoul(row[3], nullptr, 10));
e.max_level = static_cast<uint32_t>(strtoul(row[4], nullptr, 10));
all_entries.push_back(e);
}
return all_entries;
}
static std::vector<MercInventory> GetWhere(Database& db, const std::string &where_filter)
{
std::vector<MercInventory> all_entries;
auto results = db.QueryDatabase(
fmt::format(
"{} WHERE {}",
BaseSelect(),
where_filter
)
);
all_entries.reserve(results.RowCount());
for (auto row = results.begin(); row != results.end(); ++row) {
MercInventory e{};
e.merc_inventory_id = static_cast<uint32_t>(strtoul(row[0], nullptr, 10));
e.merc_subtype_id = static_cast<uint32_t>(strtoul(row[1], nullptr, 10));
e.item_id = static_cast<uint32_t>(strtoul(row[2], nullptr, 10));
e.min_level = static_cast<uint32_t>(strtoul(row[3], nullptr, 10));
e.max_level = static_cast<uint32_t>(strtoul(row[4], nullptr, 10));
all_entries.push_back(e);
}
return all_entries;
}
static int DeleteWhere(Database& db, const std::string &where_filter)
{
auto results = db.QueryDatabase(
fmt::format(
"DELETE FROM {} WHERE {}",
TableName(),
where_filter
)
);
return (results.Success() ? results.RowsAffected() : 0);
}
static int Truncate(Database& db)
{
auto results = db.QueryDatabase(
fmt::format(
"TRUNCATE TABLE {}",
TableName()
)
);
return (results.Success() ? results.RowsAffected() : 0);
}
static int64 GetMaxId(Database& db)
{
auto results = db.QueryDatabase(
fmt::format(
"SELECT COALESCE(MAX({}), 0) FROM {}",
PrimaryKey(),
TableName()
)
);
return (results.Success() && results.begin()[0] ? strtoll(results.begin()[0], nullptr, 10) : 0);
}
static int64 Count(Database& db, const std::string &where_filter = "")
{
auto results = db.QueryDatabase(
fmt::format(
"SELECT COUNT(*) FROM {} {}",
TableName(),
(where_filter.empty() ? "" : "WHERE " + where_filter)
)
);
return (results.Success() && results.begin()[0] ? strtoll(results.begin()[0], nullptr, 10) : 0);
}
};
#endif //EQEMU_BASE_MERC_INVENTORY_REPOSITORY_H
@@ -0,0 +1,344 @@
/**
* DO NOT MODIFY THIS FILE
*
* This repository was automatically generated and is NOT to be modified directly.
* Any repository modifications are meant to be made to the repository extending the base.
* Any modifications to base repositories are to be made by the generator only
*
* @generator ./utils/scripts/generators/repository-generator.pl
* @docs https://eqemu.gitbook.io/server/in-development/developer-area/repositories
*/
#ifndef EQEMU_BASE_MERC_MERCHANT_ENTRIES_REPOSITORY_H
#define EQEMU_BASE_MERC_MERCHANT_ENTRIES_REPOSITORY_H
#include "../../database.h"
#include "../../strings.h"
#include <ctime>
class BaseMercMerchantEntriesRepository {
public:
struct MercMerchantEntries {
uint32_t merc_merchant_entry_id;
uint32_t merc_merchant_template_id;
uint32_t merchant_id;
};
static std::string PrimaryKey()
{
return std::string("merc_merchant_entry_id");
}
static std::vector<std::string> Columns()
{
return {
"merc_merchant_entry_id",
"merc_merchant_template_id",
"merchant_id",
};
}
static std::vector<std::string> SelectColumns()
{
return {
"merc_merchant_entry_id",
"merc_merchant_template_id",
"merchant_id",
};
}
static std::string ColumnsRaw()
{
return std::string(Strings::Implode(", ", Columns()));
}
static std::string SelectColumnsRaw()
{
return std::string(Strings::Implode(", ", SelectColumns()));
}
static std::string TableName()
{
return std::string("merc_merchant_entries");
}
static std::string BaseSelect()
{
return fmt::format(
"SELECT {} FROM {}",
SelectColumnsRaw(),
TableName()
);
}
static std::string BaseInsert()
{
return fmt::format(
"INSERT INTO {} ({}) ",
TableName(),
ColumnsRaw()
);
}
static MercMerchantEntries NewEntity()
{
MercMerchantEntries e{};
e.merc_merchant_entry_id = 0;
e.merc_merchant_template_id = 0;
e.merchant_id = 0;
return e;
}
static MercMerchantEntries GetMercMerchantEntries(
const std::vector<MercMerchantEntries> &merc_merchant_entriess,
int merc_merchant_entries_id
)
{
for (auto &merc_merchant_entries : merc_merchant_entriess) {
if (merc_merchant_entries.merc_merchant_entry_id == merc_merchant_entries_id) {
return merc_merchant_entries;
}
}
return NewEntity();
}
static MercMerchantEntries FindOne(
Database& db,
int merc_merchant_entries_id
)
{
auto results = db.QueryDatabase(
fmt::format(
"{} WHERE {} = {} LIMIT 1",
BaseSelect(),
PrimaryKey(),
merc_merchant_entries_id
)
);
auto row = results.begin();
if (results.RowCount() == 1) {
MercMerchantEntries e{};
e.merc_merchant_entry_id = static_cast<uint32_t>(strtoul(row[0], nullptr, 10));
e.merc_merchant_template_id = static_cast<uint32_t>(strtoul(row[1], nullptr, 10));
e.merchant_id = static_cast<uint32_t>(strtoul(row[2], nullptr, 10));
return e;
}
return NewEntity();
}
static int DeleteOne(
Database& db,
int merc_merchant_entries_id
)
{
auto results = db.QueryDatabase(
fmt::format(
"DELETE FROM {} WHERE {} = {}",
TableName(),
PrimaryKey(),
merc_merchant_entries_id
)
);
return (results.Success() ? results.RowsAffected() : 0);
}
static int UpdateOne(
Database& db,
const MercMerchantEntries &e
)
{
std::vector<std::string> v;
auto columns = Columns();
v.push_back(columns[1] + " = " + std::to_string(e.merc_merchant_template_id));
v.push_back(columns[2] + " = " + std::to_string(e.merchant_id));
auto results = db.QueryDatabase(
fmt::format(
"UPDATE {} SET {} WHERE {} = {}",
TableName(),
Strings::Implode(", ", v),
PrimaryKey(),
e.merc_merchant_entry_id
)
);
return (results.Success() ? results.RowsAffected() : 0);
}
static MercMerchantEntries InsertOne(
Database& db,
MercMerchantEntries e
)
{
std::vector<std::string> v;
v.push_back(std::to_string(e.merc_merchant_entry_id));
v.push_back(std::to_string(e.merc_merchant_template_id));
v.push_back(std::to_string(e.merchant_id));
auto results = db.QueryDatabase(
fmt::format(
"{} VALUES ({})",
BaseInsert(),
Strings::Implode(",", v)
)
);
if (results.Success()) {
e.merc_merchant_entry_id = results.LastInsertedID();
return e;
}
e = NewEntity();
return e;
}
static int InsertMany(
Database& db,
const std::vector<MercMerchantEntries> &entries
)
{
std::vector<std::string> insert_chunks;
for (auto &e: entries) {
std::vector<std::string> v;
v.push_back(std::to_string(e.merc_merchant_entry_id));
v.push_back(std::to_string(e.merc_merchant_template_id));
v.push_back(std::to_string(e.merchant_id));
insert_chunks.push_back("(" + Strings::Implode(",", v) + ")");
}
std::vector<std::string> v;
auto results = db.QueryDatabase(
fmt::format(
"{} VALUES {}",
BaseInsert(),
Strings::Implode(",", insert_chunks)
)
);
return (results.Success() ? results.RowsAffected() : 0);
}
static std::vector<MercMerchantEntries> All(Database& db)
{
std::vector<MercMerchantEntries> all_entries;
auto results = db.QueryDatabase(
fmt::format(
"{}",
BaseSelect()
)
);
all_entries.reserve(results.RowCount());
for (auto row = results.begin(); row != results.end(); ++row) {
MercMerchantEntries e{};
e.merc_merchant_entry_id = static_cast<uint32_t>(strtoul(row[0], nullptr, 10));
e.merc_merchant_template_id = static_cast<uint32_t>(strtoul(row[1], nullptr, 10));
e.merchant_id = static_cast<uint32_t>(strtoul(row[2], nullptr, 10));
all_entries.push_back(e);
}
return all_entries;
}
static std::vector<MercMerchantEntries> GetWhere(Database& db, const std::string &where_filter)
{
std::vector<MercMerchantEntries> all_entries;
auto results = db.QueryDatabase(
fmt::format(
"{} WHERE {}",
BaseSelect(),
where_filter
)
);
all_entries.reserve(results.RowCount());
for (auto row = results.begin(); row != results.end(); ++row) {
MercMerchantEntries e{};
e.merc_merchant_entry_id = static_cast<uint32_t>(strtoul(row[0], nullptr, 10));
e.merc_merchant_template_id = static_cast<uint32_t>(strtoul(row[1], nullptr, 10));
e.merchant_id = static_cast<uint32_t>(strtoul(row[2], nullptr, 10));
all_entries.push_back(e);
}
return all_entries;
}
static int DeleteWhere(Database& db, const std::string &where_filter)
{
auto results = db.QueryDatabase(
fmt::format(
"DELETE FROM {} WHERE {}",
TableName(),
where_filter
)
);
return (results.Success() ? results.RowsAffected() : 0);
}
static int Truncate(Database& db)
{
auto results = db.QueryDatabase(
fmt::format(
"TRUNCATE TABLE {}",
TableName()
)
);
return (results.Success() ? results.RowsAffected() : 0);
}
static int64 GetMaxId(Database& db)
{
auto results = db.QueryDatabase(
fmt::format(
"SELECT COALESCE(MAX({}), 0) FROM {}",
PrimaryKey(),
TableName()
)
);
return (results.Success() && results.begin()[0] ? strtoll(results.begin()[0], nullptr, 10) : 0);
}
static int64 Count(Database& db, const std::string &where_filter = "")
{
auto results = db.QueryDatabase(
fmt::format(
"SELECT COUNT(*) FROM {} {}",
TableName(),
(where_filter.empty() ? "" : "WHERE " + where_filter)
)
);
return (results.Success() && results.begin()[0] ? strtoll(results.begin()[0], nullptr, 10) : 0);
}
};
#endif //EQEMU_BASE_MERC_MERCHANT_ENTRIES_REPOSITORY_H
@@ -0,0 +1,344 @@
/**
* DO NOT MODIFY THIS FILE
*
* This repository was automatically generated and is NOT to be modified directly.
* Any repository modifications are meant to be made to the repository extending the base.
* Any modifications to base repositories are to be made by the generator only
*
* @generator ./utils/scripts/generators/repository-generator.pl
* @docs https://eqemu.gitbook.io/server/in-development/developer-area/repositories
*/
#ifndef EQEMU_BASE_MERC_MERCHANT_TEMPLATE_ENTRIES_REPOSITORY_H
#define EQEMU_BASE_MERC_MERCHANT_TEMPLATE_ENTRIES_REPOSITORY_H
#include "../../database.h"
#include "../../strings.h"
#include <ctime>
class BaseMercMerchantTemplateEntriesRepository {
public:
struct MercMerchantTemplateEntries {
uint32_t merc_merchant_template_entry_id;
uint32_t merc_merchant_template_id;
uint32_t merc_template_id;
};
static std::string PrimaryKey()
{
return std::string("merc_merchant_template_entry_id");
}
static std::vector<std::string> Columns()
{
return {
"merc_merchant_template_entry_id",
"merc_merchant_template_id",
"merc_template_id",
};
}
static std::vector<std::string> SelectColumns()
{
return {
"merc_merchant_template_entry_id",
"merc_merchant_template_id",
"merc_template_id",
};
}
static std::string ColumnsRaw()
{
return std::string(Strings::Implode(", ", Columns()));
}
static std::string SelectColumnsRaw()
{
return std::string(Strings::Implode(", ", SelectColumns()));
}
static std::string TableName()
{
return std::string("merc_merchant_template_entries");
}
static std::string BaseSelect()
{
return fmt::format(
"SELECT {} FROM {}",
SelectColumnsRaw(),
TableName()
);
}
static std::string BaseInsert()
{
return fmt::format(
"INSERT INTO {} ({}) ",
TableName(),
ColumnsRaw()
);
}
static MercMerchantTemplateEntries NewEntity()
{
MercMerchantTemplateEntries e{};
e.merc_merchant_template_entry_id = 0;
e.merc_merchant_template_id = 0;
e.merc_template_id = 0;
return e;
}
static MercMerchantTemplateEntries GetMercMerchantTemplateEntries(
const std::vector<MercMerchantTemplateEntries> &merc_merchant_template_entriess,
int merc_merchant_template_entries_id
)
{
for (auto &merc_merchant_template_entries : merc_merchant_template_entriess) {
if (merc_merchant_template_entries.merc_merchant_template_entry_id == merc_merchant_template_entries_id) {
return merc_merchant_template_entries;
}
}
return NewEntity();
}
static MercMerchantTemplateEntries FindOne(
Database& db,
int merc_merchant_template_entries_id
)
{
auto results = db.QueryDatabase(
fmt::format(
"{} WHERE {} = {} LIMIT 1",
BaseSelect(),
PrimaryKey(),
merc_merchant_template_entries_id
)
);
auto row = results.begin();
if (results.RowCount() == 1) {
MercMerchantTemplateEntries e{};
e.merc_merchant_template_entry_id = static_cast<uint32_t>(strtoul(row[0], nullptr, 10));
e.merc_merchant_template_id = static_cast<uint32_t>(strtoul(row[1], nullptr, 10));
e.merc_template_id = static_cast<uint32_t>(strtoul(row[2], nullptr, 10));
return e;
}
return NewEntity();
}
static int DeleteOne(
Database& db,
int merc_merchant_template_entries_id
)
{
auto results = db.QueryDatabase(
fmt::format(
"DELETE FROM {} WHERE {} = {}",
TableName(),
PrimaryKey(),
merc_merchant_template_entries_id
)
);
return (results.Success() ? results.RowsAffected() : 0);
}
static int UpdateOne(
Database& db,
const MercMerchantTemplateEntries &e
)
{
std::vector<std::string> v;
auto columns = Columns();
v.push_back(columns[1] + " = " + std::to_string(e.merc_merchant_template_id));
v.push_back(columns[2] + " = " + std::to_string(e.merc_template_id));
auto results = db.QueryDatabase(
fmt::format(
"UPDATE {} SET {} WHERE {} = {}",
TableName(),
Strings::Implode(", ", v),
PrimaryKey(),
e.merc_merchant_template_entry_id
)
);
return (results.Success() ? results.RowsAffected() : 0);
}
static MercMerchantTemplateEntries InsertOne(
Database& db,
MercMerchantTemplateEntries e
)
{
std::vector<std::string> v;
v.push_back(std::to_string(e.merc_merchant_template_entry_id));
v.push_back(std::to_string(e.merc_merchant_template_id));
v.push_back(std::to_string(e.merc_template_id));
auto results = db.QueryDatabase(
fmt::format(
"{} VALUES ({})",
BaseInsert(),
Strings::Implode(",", v)
)
);
if (results.Success()) {
e.merc_merchant_template_entry_id = results.LastInsertedID();
return e;
}
e = NewEntity();
return e;
}
static int InsertMany(
Database& db,
const std::vector<MercMerchantTemplateEntries> &entries
)
{
std::vector<std::string> insert_chunks;
for (auto &e: entries) {
std::vector<std::string> v;
v.push_back(std::to_string(e.merc_merchant_template_entry_id));
v.push_back(std::to_string(e.merc_merchant_template_id));
v.push_back(std::to_string(e.merc_template_id));
insert_chunks.push_back("(" + Strings::Implode(",", v) + ")");
}
std::vector<std::string> v;
auto results = db.QueryDatabase(
fmt::format(
"{} VALUES {}",
BaseInsert(),
Strings::Implode(",", insert_chunks)
)
);
return (results.Success() ? results.RowsAffected() : 0);
}
static std::vector<MercMerchantTemplateEntries> All(Database& db)
{
std::vector<MercMerchantTemplateEntries> all_entries;
auto results = db.QueryDatabase(
fmt::format(
"{}",
BaseSelect()
)
);
all_entries.reserve(results.RowCount());
for (auto row = results.begin(); row != results.end(); ++row) {
MercMerchantTemplateEntries e{};
e.merc_merchant_template_entry_id = static_cast<uint32_t>(strtoul(row[0], nullptr, 10));
e.merc_merchant_template_id = static_cast<uint32_t>(strtoul(row[1], nullptr, 10));
e.merc_template_id = static_cast<uint32_t>(strtoul(row[2], nullptr, 10));
all_entries.push_back(e);
}
return all_entries;
}
static std::vector<MercMerchantTemplateEntries> GetWhere(Database& db, const std::string &where_filter)
{
std::vector<MercMerchantTemplateEntries> all_entries;
auto results = db.QueryDatabase(
fmt::format(
"{} WHERE {}",
BaseSelect(),
where_filter
)
);
all_entries.reserve(results.RowCount());
for (auto row = results.begin(); row != results.end(); ++row) {
MercMerchantTemplateEntries e{};
e.merc_merchant_template_entry_id = static_cast<uint32_t>(strtoul(row[0], nullptr, 10));
e.merc_merchant_template_id = static_cast<uint32_t>(strtoul(row[1], nullptr, 10));
e.merc_template_id = static_cast<uint32_t>(strtoul(row[2], nullptr, 10));
all_entries.push_back(e);
}
return all_entries;
}
static int DeleteWhere(Database& db, const std::string &where_filter)
{
auto results = db.QueryDatabase(
fmt::format(
"DELETE FROM {} WHERE {}",
TableName(),
where_filter
)
);
return (results.Success() ? results.RowsAffected() : 0);
}
static int Truncate(Database& db)
{
auto results = db.QueryDatabase(
fmt::format(
"TRUNCATE TABLE {}",
TableName()
)
);
return (results.Success() ? results.RowsAffected() : 0);
}
static int64 GetMaxId(Database& db)
{
auto results = db.QueryDatabase(
fmt::format(
"SELECT COALESCE(MAX({}), 0) FROM {}",
PrimaryKey(),
TableName()
)
);
return (results.Success() && results.begin()[0] ? strtoll(results.begin()[0], nullptr, 10) : 0);
}
static int64 Count(Database& db, const std::string &where_filter = "")
{
auto results = db.QueryDatabase(
fmt::format(
"SELECT COUNT(*) FROM {} {}",
TableName(),
(where_filter.empty() ? "" : "WHERE " + where_filter)
)
);
return (results.Success() && results.begin()[0] ? strtoll(results.begin()[0], nullptr, 10) : 0);
}
};
#endif //EQEMU_BASE_MERC_MERCHANT_TEMPLATE_ENTRIES_REPOSITORY_H
@@ -0,0 +1,344 @@
/**
* DO NOT MODIFY THIS FILE
*
* This repository was automatically generated and is NOT to be modified directly.
* Any repository modifications are meant to be made to the repository extending the base.
* Any modifications to base repositories are to be made by the generator only
*
* @generator ./utils/scripts/generators/repository-generator.pl
* @docs https://eqemu.gitbook.io/server/in-development/developer-area/repositories
*/
#ifndef EQEMU_BASE_MERC_MERCHANT_TEMPLATES_REPOSITORY_H
#define EQEMU_BASE_MERC_MERCHANT_TEMPLATES_REPOSITORY_H
#include "../../database.h"
#include "../../strings.h"
#include <ctime>
class BaseMercMerchantTemplatesRepository {
public:
struct MercMerchantTemplates {
uint32_t merc_merchant_template_id;
std::string name;
std::string qglobal;
};
static std::string PrimaryKey()
{
return std::string("merc_merchant_template_id");
}
static std::vector<std::string> Columns()
{
return {
"merc_merchant_template_id",
"name",
"qglobal",
};
}
static std::vector<std::string> SelectColumns()
{
return {
"merc_merchant_template_id",
"name",
"qglobal",
};
}
static std::string ColumnsRaw()
{
return std::string(Strings::Implode(", ", Columns()));
}
static std::string SelectColumnsRaw()
{
return std::string(Strings::Implode(", ", SelectColumns()));
}
static std::string TableName()
{
return std::string("merc_merchant_templates");
}
static std::string BaseSelect()
{
return fmt::format(
"SELECT {} FROM {}",
SelectColumnsRaw(),
TableName()
);
}
static std::string BaseInsert()
{
return fmt::format(
"INSERT INTO {} ({}) ",
TableName(),
ColumnsRaw()
);
}
static MercMerchantTemplates NewEntity()
{
MercMerchantTemplates e{};
e.merc_merchant_template_id = 0;
e.name = "";
e.qglobal = "";
return e;
}
static MercMerchantTemplates GetMercMerchantTemplates(
const std::vector<MercMerchantTemplates> &merc_merchant_templatess,
int merc_merchant_templates_id
)
{
for (auto &merc_merchant_templates : merc_merchant_templatess) {
if (merc_merchant_templates.merc_merchant_template_id == merc_merchant_templates_id) {
return merc_merchant_templates;
}
}
return NewEntity();
}
static MercMerchantTemplates FindOne(
Database& db,
int merc_merchant_templates_id
)
{
auto results = db.QueryDatabase(
fmt::format(
"{} WHERE {} = {} LIMIT 1",
BaseSelect(),
PrimaryKey(),
merc_merchant_templates_id
)
);
auto row = results.begin();
if (results.RowCount() == 1) {
MercMerchantTemplates e{};
e.merc_merchant_template_id = static_cast<uint32_t>(strtoul(row[0], nullptr, 10));
e.name = row[1] ? row[1] : "";
e.qglobal = row[2] ? row[2] : "";
return e;
}
return NewEntity();
}
static int DeleteOne(
Database& db,
int merc_merchant_templates_id
)
{
auto results = db.QueryDatabase(
fmt::format(
"DELETE FROM {} WHERE {} = {}",
TableName(),
PrimaryKey(),
merc_merchant_templates_id
)
);
return (results.Success() ? results.RowsAffected() : 0);
}
static int UpdateOne(
Database& db,
const MercMerchantTemplates &e
)
{
std::vector<std::string> v;
auto columns = Columns();
v.push_back(columns[1] + " = '" + Strings::Escape(e.name) + "'");
v.push_back(columns[2] + " = '" + Strings::Escape(e.qglobal) + "'");
auto results = db.QueryDatabase(
fmt::format(
"UPDATE {} SET {} WHERE {} = {}",
TableName(),
Strings::Implode(", ", v),
PrimaryKey(),
e.merc_merchant_template_id
)
);
return (results.Success() ? results.RowsAffected() : 0);
}
static MercMerchantTemplates InsertOne(
Database& db,
MercMerchantTemplates e
)
{
std::vector<std::string> v;
v.push_back(std::to_string(e.merc_merchant_template_id));
v.push_back("'" + Strings::Escape(e.name) + "'");
v.push_back("'" + Strings::Escape(e.qglobal) + "'");
auto results = db.QueryDatabase(
fmt::format(
"{} VALUES ({})",
BaseInsert(),
Strings::Implode(",", v)
)
);
if (results.Success()) {
e.merc_merchant_template_id = results.LastInsertedID();
return e;
}
e = NewEntity();
return e;
}
static int InsertMany(
Database& db,
const std::vector<MercMerchantTemplates> &entries
)
{
std::vector<std::string> insert_chunks;
for (auto &e: entries) {
std::vector<std::string> v;
v.push_back(std::to_string(e.merc_merchant_template_id));
v.push_back("'" + Strings::Escape(e.name) + "'");
v.push_back("'" + Strings::Escape(e.qglobal) + "'");
insert_chunks.push_back("(" + Strings::Implode(",", v) + ")");
}
std::vector<std::string> v;
auto results = db.QueryDatabase(
fmt::format(
"{} VALUES {}",
BaseInsert(),
Strings::Implode(",", insert_chunks)
)
);
return (results.Success() ? results.RowsAffected() : 0);
}
static std::vector<MercMerchantTemplates> All(Database& db)
{
std::vector<MercMerchantTemplates> all_entries;
auto results = db.QueryDatabase(
fmt::format(
"{}",
BaseSelect()
)
);
all_entries.reserve(results.RowCount());
for (auto row = results.begin(); row != results.end(); ++row) {
MercMerchantTemplates e{};
e.merc_merchant_template_id = static_cast<uint32_t>(strtoul(row[0], nullptr, 10));
e.name = row[1] ? row[1] : "";
e.qglobal = row[2] ? row[2] : "";
all_entries.push_back(e);
}
return all_entries;
}
static std::vector<MercMerchantTemplates> GetWhere(Database& db, const std::string &where_filter)
{
std::vector<MercMerchantTemplates> all_entries;
auto results = db.QueryDatabase(
fmt::format(
"{} WHERE {}",
BaseSelect(),
where_filter
)
);
all_entries.reserve(results.RowCount());
for (auto row = results.begin(); row != results.end(); ++row) {
MercMerchantTemplates e{};
e.merc_merchant_template_id = static_cast<uint32_t>(strtoul(row[0], nullptr, 10));
e.name = row[1] ? row[1] : "";
e.qglobal = row[2] ? row[2] : "";
all_entries.push_back(e);
}
return all_entries;
}
static int DeleteWhere(Database& db, const std::string &where_filter)
{
auto results = db.QueryDatabase(
fmt::format(
"DELETE FROM {} WHERE {}",
TableName(),
where_filter
)
);
return (results.Success() ? results.RowsAffected() : 0);
}
static int Truncate(Database& db)
{
auto results = db.QueryDatabase(
fmt::format(
"TRUNCATE TABLE {}",
TableName()
)
);
return (results.Success() ? results.RowsAffected() : 0);
}
static int64 GetMaxId(Database& db)
{
auto results = db.QueryDatabase(
fmt::format(
"SELECT COALESCE(MAX({}), 0) FROM {}",
PrimaryKey(),
TableName()
)
);
return (results.Success() && results.begin()[0] ? strtoll(results.begin()[0], nullptr, 10) : 0);
}
static int64 Count(Database& db, const std::string &where_filter = "")
{
auto results = db.QueryDatabase(
fmt::format(
"SELECT COUNT(*) FROM {} {}",
TableName(),
(where_filter.empty() ? "" : "WHERE " + where_filter)
)
);
return (results.Success() && results.begin()[0] ? strtoll(results.begin()[0], nullptr, 10) : 0);
}
};
#endif //EQEMU_BASE_MERC_MERCHANT_TEMPLATES_REPOSITORY_H
@@ -0,0 +1,355 @@
/**
* DO NOT MODIFY THIS FILE
*
* This repository was automatically generated and is NOT to be modified directly.
* Any repository modifications are meant to be made to the repository extending the base.
* Any modifications to base repositories are to be made by the generator only
*
* @generator ./utils/scripts/generators/repository-generator.pl
* @docs https://eqemu.gitbook.io/server/in-development/developer-area/repositories
*/
#ifndef EQEMU_BASE_MERC_NAME_TYPES_REPOSITORY_H
#define EQEMU_BASE_MERC_NAME_TYPES_REPOSITORY_H
#include "../../database.h"
#include "../../strings.h"
#include <ctime>
class BaseMercNameTypesRepository {
public:
struct MercNameTypes {
uint32_t name_type_id;
uint32_t class_id;
std::string prefix;
std::string suffix;
};
static std::string PrimaryKey()
{
return std::string("name_type_id");
}
static std::vector<std::string> Columns()
{
return {
"name_type_id",
"class_id",
"prefix",
"suffix",
};
}
static std::vector<std::string> SelectColumns()
{
return {
"name_type_id",
"class_id",
"prefix",
"suffix",
};
}
static std::string ColumnsRaw()
{
return std::string(Strings::Implode(", ", Columns()));
}
static std::string SelectColumnsRaw()
{
return std::string(Strings::Implode(", ", SelectColumns()));
}
static std::string TableName()
{
return std::string("merc_name_types");
}
static std::string BaseSelect()
{
return fmt::format(
"SELECT {} FROM {}",
SelectColumnsRaw(),
TableName()
);
}
static std::string BaseInsert()
{
return fmt::format(
"INSERT INTO {} ({}) ",
TableName(),
ColumnsRaw()
);
}
static MercNameTypes NewEntity()
{
MercNameTypes e{};
e.name_type_id = 0;
e.class_id = 0;
e.prefix = "";
e.suffix = "";
return e;
}
static MercNameTypes GetMercNameTypes(
const std::vector<MercNameTypes> &merc_name_typess,
int merc_name_types_id
)
{
for (auto &merc_name_types : merc_name_typess) {
if (merc_name_types.name_type_id == merc_name_types_id) {
return merc_name_types;
}
}
return NewEntity();
}
static MercNameTypes FindOne(
Database& db,
int merc_name_types_id
)
{
auto results = db.QueryDatabase(
fmt::format(
"{} WHERE {} = {} LIMIT 1",
BaseSelect(),
PrimaryKey(),
merc_name_types_id
)
);
auto row = results.begin();
if (results.RowCount() == 1) {
MercNameTypes e{};
e.name_type_id = static_cast<uint32_t>(strtoul(row[0], nullptr, 10));
e.class_id = static_cast<uint32_t>(strtoul(row[1], nullptr, 10));
e.prefix = row[2] ? row[2] : "";
e.suffix = row[3] ? row[3] : "";
return e;
}
return NewEntity();
}
static int DeleteOne(
Database& db,
int merc_name_types_id
)
{
auto results = db.QueryDatabase(
fmt::format(
"DELETE FROM {} WHERE {} = {}",
TableName(),
PrimaryKey(),
merc_name_types_id
)
);
return (results.Success() ? results.RowsAffected() : 0);
}
static int UpdateOne(
Database& db,
const MercNameTypes &e
)
{
std::vector<std::string> v;
auto columns = Columns();
v.push_back(columns[0] + " = " + std::to_string(e.name_type_id));
v.push_back(columns[1] + " = " + std::to_string(e.class_id));
v.push_back(columns[2] + " = '" + Strings::Escape(e.prefix) + "'");
v.push_back(columns[3] + " = '" + Strings::Escape(e.suffix) + "'");
auto results = db.QueryDatabase(
fmt::format(
"UPDATE {} SET {} WHERE {} = {}",
TableName(),
Strings::Implode(", ", v),
PrimaryKey(),
e.name_type_id
)
);
return (results.Success() ? results.RowsAffected() : 0);
}
static MercNameTypes InsertOne(
Database& db,
MercNameTypes e
)
{
std::vector<std::string> v;
v.push_back(std::to_string(e.name_type_id));
v.push_back(std::to_string(e.class_id));
v.push_back("'" + Strings::Escape(e.prefix) + "'");
v.push_back("'" + Strings::Escape(e.suffix) + "'");
auto results = db.QueryDatabase(
fmt::format(
"{} VALUES ({})",
BaseInsert(),
Strings::Implode(",", v)
)
);
if (results.Success()) {
e.name_type_id = results.LastInsertedID();
return e;
}
e = NewEntity();
return e;
}
static int InsertMany(
Database& db,
const std::vector<MercNameTypes> &entries
)
{
std::vector<std::string> insert_chunks;
for (auto &e: entries) {
std::vector<std::string> v;
v.push_back(std::to_string(e.name_type_id));
v.push_back(std::to_string(e.class_id));
v.push_back("'" + Strings::Escape(e.prefix) + "'");
v.push_back("'" + Strings::Escape(e.suffix) + "'");
insert_chunks.push_back("(" + Strings::Implode(",", v) + ")");
}
std::vector<std::string> v;
auto results = db.QueryDatabase(
fmt::format(
"{} VALUES {}",
BaseInsert(),
Strings::Implode(",", insert_chunks)
)
);
return (results.Success() ? results.RowsAffected() : 0);
}
static std::vector<MercNameTypes> All(Database& db)
{
std::vector<MercNameTypes> all_entries;
auto results = db.QueryDatabase(
fmt::format(
"{}",
BaseSelect()
)
);
all_entries.reserve(results.RowCount());
for (auto row = results.begin(); row != results.end(); ++row) {
MercNameTypes e{};
e.name_type_id = static_cast<uint32_t>(strtoul(row[0], nullptr, 10));
e.class_id = static_cast<uint32_t>(strtoul(row[1], nullptr, 10));
e.prefix = row[2] ? row[2] : "";
e.suffix = row[3] ? row[3] : "";
all_entries.push_back(e);
}
return all_entries;
}
static std::vector<MercNameTypes> GetWhere(Database& db, const std::string &where_filter)
{
std::vector<MercNameTypes> all_entries;
auto results = db.QueryDatabase(
fmt::format(
"{} WHERE {}",
BaseSelect(),
where_filter
)
);
all_entries.reserve(results.RowCount());
for (auto row = results.begin(); row != results.end(); ++row) {
MercNameTypes e{};
e.name_type_id = static_cast<uint32_t>(strtoul(row[0], nullptr, 10));
e.class_id = static_cast<uint32_t>(strtoul(row[1], nullptr, 10));
e.prefix = row[2] ? row[2] : "";
e.suffix = row[3] ? row[3] : "";
all_entries.push_back(e);
}
return all_entries;
}
static int DeleteWhere(Database& db, const std::string &where_filter)
{
auto results = db.QueryDatabase(
fmt::format(
"DELETE FROM {} WHERE {}",
TableName(),
where_filter
)
);
return (results.Success() ? results.RowsAffected() : 0);
}
static int Truncate(Database& db)
{
auto results = db.QueryDatabase(
fmt::format(
"TRUNCATE TABLE {}",
TableName()
)
);
return (results.Success() ? results.RowsAffected() : 0);
}
static int64 GetMaxId(Database& db)
{
auto results = db.QueryDatabase(
fmt::format(
"SELECT COALESCE(MAX({}), 0) FROM {}",
PrimaryKey(),
TableName()
)
);
return (results.Success() && results.begin()[0] ? strtoll(results.begin()[0], nullptr, 10) : 0);
}
static int64 Count(Database& db, const std::string &where_filter = "")
{
auto results = db.QueryDatabase(
fmt::format(
"SELECT COUNT(*) FROM {} {}",
TableName(),
(where_filter.empty() ? "" : "WHERE " + where_filter)
)
);
return (results.Success() && results.begin()[0] ? strtoll(results.begin()[0], nullptr, 10) : 0);
}
};
#endif //EQEMU_BASE_MERC_NAME_TYPES_REPOSITORY_H
@@ -0,0 +1,364 @@
/**
* DO NOT MODIFY THIS FILE
*
* This repository was automatically generated and is NOT to be modified directly.
* Any repository modifications are meant to be made to the repository extending the base.
* Any modifications to base repositories are to be made by the generator only
*
* @generator ./utils/scripts/generators/repository-generator.pl
* @docs https://eqemu.gitbook.io/server/in-development/developer-area/repositories
*/
#ifndef EQEMU_BASE_MERC_NPC_TYPES_REPOSITORY_H
#define EQEMU_BASE_MERC_NPC_TYPES_REPOSITORY_H
#include "../../database.h"
#include "../../strings.h"
#include <ctime>
class BaseMercNpcTypesRepository {
public:
struct MercNpcTypes {
uint32_t merc_npc_type_id;
uint8_t proficiency_id;
uint8_t tier_id;
uint32_t class_id;
std::string name;
};
static std::string PrimaryKey()
{
return std::string("merc_npc_type_id");
}
static std::vector<std::string> Columns()
{
return {
"merc_npc_type_id",
"proficiency_id",
"tier_id",
"class_id",
"name",
};
}
static std::vector<std::string> SelectColumns()
{
return {
"merc_npc_type_id",
"proficiency_id",
"tier_id",
"class_id",
"name",
};
}
static std::string ColumnsRaw()
{
return std::string(Strings::Implode(", ", Columns()));
}
static std::string SelectColumnsRaw()
{
return std::string(Strings::Implode(", ", SelectColumns()));
}
static std::string TableName()
{
return std::string("merc_npc_types");
}
static std::string BaseSelect()
{
return fmt::format(
"SELECT {} FROM {}",
SelectColumnsRaw(),
TableName()
);
}
static std::string BaseInsert()
{
return fmt::format(
"INSERT INTO {} ({}) ",
TableName(),
ColumnsRaw()
);
}
static MercNpcTypes NewEntity()
{
MercNpcTypes e{};
e.merc_npc_type_id = 0;
e.proficiency_id = 0;
e.tier_id = 0;
e.class_id = 0;
e.name = "";
return e;
}
static MercNpcTypes GetMercNpcTypes(
const std::vector<MercNpcTypes> &merc_npc_typess,
int merc_npc_types_id
)
{
for (auto &merc_npc_types : merc_npc_typess) {
if (merc_npc_types.merc_npc_type_id == merc_npc_types_id) {
return merc_npc_types;
}
}
return NewEntity();
}
static MercNpcTypes FindOne(
Database& db,
int merc_npc_types_id
)
{
auto results = db.QueryDatabase(
fmt::format(
"{} WHERE {} = {} LIMIT 1",
BaseSelect(),
PrimaryKey(),
merc_npc_types_id
)
);
auto row = results.begin();
if (results.RowCount() == 1) {
MercNpcTypes e{};
e.merc_npc_type_id = static_cast<uint32_t>(strtoul(row[0], nullptr, 10));
e.proficiency_id = static_cast<uint8_t>(strtoul(row[1], nullptr, 10));
e.tier_id = static_cast<uint8_t>(strtoul(row[2], nullptr, 10));
e.class_id = static_cast<uint32_t>(strtoul(row[3], nullptr, 10));
e.name = row[4] ? row[4] : "";
return e;
}
return NewEntity();
}
static int DeleteOne(
Database& db,
int merc_npc_types_id
)
{
auto results = db.QueryDatabase(
fmt::format(
"DELETE FROM {} WHERE {} = {}",
TableName(),
PrimaryKey(),
merc_npc_types_id
)
);
return (results.Success() ? results.RowsAffected() : 0);
}
static int UpdateOne(
Database& db,
const MercNpcTypes &e
)
{
std::vector<std::string> v;
auto columns = Columns();
v.push_back(columns[1] + " = " + std::to_string(e.proficiency_id));
v.push_back(columns[2] + " = " + std::to_string(e.tier_id));
v.push_back(columns[3] + " = " + std::to_string(e.class_id));
v.push_back(columns[4] + " = '" + Strings::Escape(e.name) + "'");
auto results = db.QueryDatabase(
fmt::format(
"UPDATE {} SET {} WHERE {} = {}",
TableName(),
Strings::Implode(", ", v),
PrimaryKey(),
e.merc_npc_type_id
)
);
return (results.Success() ? results.RowsAffected() : 0);
}
static MercNpcTypes InsertOne(
Database& db,
MercNpcTypes e
)
{
std::vector<std::string> v;
v.push_back(std::to_string(e.merc_npc_type_id));
v.push_back(std::to_string(e.proficiency_id));
v.push_back(std::to_string(e.tier_id));
v.push_back(std::to_string(e.class_id));
v.push_back("'" + Strings::Escape(e.name) + "'");
auto results = db.QueryDatabase(
fmt::format(
"{} VALUES ({})",
BaseInsert(),
Strings::Implode(",", v)
)
);
if (results.Success()) {
e.merc_npc_type_id = results.LastInsertedID();
return e;
}
e = NewEntity();
return e;
}
static int InsertMany(
Database& db,
const std::vector<MercNpcTypes> &entries
)
{
std::vector<std::string> insert_chunks;
for (auto &e: entries) {
std::vector<std::string> v;
v.push_back(std::to_string(e.merc_npc_type_id));
v.push_back(std::to_string(e.proficiency_id));
v.push_back(std::to_string(e.tier_id));
v.push_back(std::to_string(e.class_id));
v.push_back("'" + Strings::Escape(e.name) + "'");
insert_chunks.push_back("(" + Strings::Implode(",", v) + ")");
}
std::vector<std::string> v;
auto results = db.QueryDatabase(
fmt::format(
"{} VALUES {}",
BaseInsert(),
Strings::Implode(",", insert_chunks)
)
);
return (results.Success() ? results.RowsAffected() : 0);
}
static std::vector<MercNpcTypes> All(Database& db)
{
std::vector<MercNpcTypes> all_entries;
auto results = db.QueryDatabase(
fmt::format(
"{}",
BaseSelect()
)
);
all_entries.reserve(results.RowCount());
for (auto row = results.begin(); row != results.end(); ++row) {
MercNpcTypes e{};
e.merc_npc_type_id = static_cast<uint32_t>(strtoul(row[0], nullptr, 10));
e.proficiency_id = static_cast<uint8_t>(strtoul(row[1], nullptr, 10));
e.tier_id = static_cast<uint8_t>(strtoul(row[2], nullptr, 10));
e.class_id = static_cast<uint32_t>(strtoul(row[3], nullptr, 10));
e.name = row[4] ? row[4] : "";
all_entries.push_back(e);
}
return all_entries;
}
static std::vector<MercNpcTypes> GetWhere(Database& db, const std::string &where_filter)
{
std::vector<MercNpcTypes> all_entries;
auto results = db.QueryDatabase(
fmt::format(
"{} WHERE {}",
BaseSelect(),
where_filter
)
);
all_entries.reserve(results.RowCount());
for (auto row = results.begin(); row != results.end(); ++row) {
MercNpcTypes e{};
e.merc_npc_type_id = static_cast<uint32_t>(strtoul(row[0], nullptr, 10));
e.proficiency_id = static_cast<uint8_t>(strtoul(row[1], nullptr, 10));
e.tier_id = static_cast<uint8_t>(strtoul(row[2], nullptr, 10));
e.class_id = static_cast<uint32_t>(strtoul(row[3], nullptr, 10));
e.name = row[4] ? row[4] : "";
all_entries.push_back(e);
}
return all_entries;
}
static int DeleteWhere(Database& db, const std::string &where_filter)
{
auto results = db.QueryDatabase(
fmt::format(
"DELETE FROM {} WHERE {}",
TableName(),
where_filter
)
);
return (results.Success() ? results.RowsAffected() : 0);
}
static int Truncate(Database& db)
{
auto results = db.QueryDatabase(
fmt::format(
"TRUNCATE TABLE {}",
TableName()
)
);
return (results.Success() ? results.RowsAffected() : 0);
}
static int64 GetMaxId(Database& db)
{
auto results = db.QueryDatabase(
fmt::format(
"SELECT COALESCE(MAX({}), 0) FROM {}",
PrimaryKey(),
TableName()
)
);
return (results.Success() && results.begin()[0] ? strtoll(results.begin()[0], nullptr, 10) : 0);
}
static int64 Count(Database& db, const std::string &where_filter = "")
{
auto results = db.QueryDatabase(
fmt::format(
"SELECT COUNT(*) FROM {} {}",
TableName(),
(where_filter.empty() ? "" : "WHERE " + where_filter)
)
);
return (results.Success() && results.begin()[0] ? strtoll(results.begin()[0], nullptr, 10) : 0);
}
};
#endif //EQEMU_BASE_MERC_NPC_TYPES_REPOSITORY_H
@@ -0,0 +1,404 @@
/**
* DO NOT MODIFY THIS FILE
*
* This repository was automatically generated and is NOT to be modified directly.
* Any repository modifications are meant to be made to the repository extending the base.
* Any modifications to base repositories are to be made by the generator only
*
* @generator ./utils/scripts/generators/repository-generator.pl
* @docs https://eqemu.gitbook.io/server/in-development/developer-area/repositories
*/
#ifndef EQEMU_BASE_MERC_SPELL_LIST_ENTRIES_REPOSITORY_H
#define EQEMU_BASE_MERC_SPELL_LIST_ENTRIES_REPOSITORY_H
#include "../../database.h"
#include "../../strings.h"
#include <ctime>
class BaseMercSpellListEntriesRepository {
public:
struct MercSpellListEntries {
uint32_t merc_spell_list_entry_id;
uint32_t merc_spell_list_id;
uint32_t spell_id;
uint32_t spell_type;
uint8_t stance_id;
uint8_t minlevel;
uint8_t maxlevel;
int8_t slot;
uint8_t procChance;
};
static std::string PrimaryKey()
{
return std::string("merc_spell_list_entry_id");
}
static std::vector<std::string> Columns()
{
return {
"merc_spell_list_entry_id",
"merc_spell_list_id",
"spell_id",
"spell_type",
"stance_id",
"minlevel",
"maxlevel",
"slot",
"procChance",
};
}
static std::vector<std::string> SelectColumns()
{
return {
"merc_spell_list_entry_id",
"merc_spell_list_id",
"spell_id",
"spell_type",
"stance_id",
"minlevel",
"maxlevel",
"slot",
"procChance",
};
}
static std::string ColumnsRaw()
{
return std::string(Strings::Implode(", ", Columns()));
}
static std::string SelectColumnsRaw()
{
return std::string(Strings::Implode(", ", SelectColumns()));
}
static std::string TableName()
{
return std::string("merc_spell_list_entries");
}
static std::string BaseSelect()
{
return fmt::format(
"SELECT {} FROM {}",
SelectColumnsRaw(),
TableName()
);
}
static std::string BaseInsert()
{
return fmt::format(
"INSERT INTO {} ({}) ",
TableName(),
ColumnsRaw()
);
}
static MercSpellListEntries NewEntity()
{
MercSpellListEntries e{};
e.merc_spell_list_entry_id = 0;
e.merc_spell_list_id = 0;
e.spell_id = 0;
e.spell_type = 0;
e.stance_id = 0;
e.minlevel = 1;
e.maxlevel = 255;
e.slot = -1;
e.procChance = 0;
return e;
}
static MercSpellListEntries GetMercSpellListEntries(
const std::vector<MercSpellListEntries> &merc_spell_list_entriess,
int merc_spell_list_entries_id
)
{
for (auto &merc_spell_list_entries : merc_spell_list_entriess) {
if (merc_spell_list_entries.merc_spell_list_entry_id == merc_spell_list_entries_id) {
return merc_spell_list_entries;
}
}
return NewEntity();
}
static MercSpellListEntries FindOne(
Database& db,
int merc_spell_list_entries_id
)
{
auto results = db.QueryDatabase(
fmt::format(
"{} WHERE {} = {} LIMIT 1",
BaseSelect(),
PrimaryKey(),
merc_spell_list_entries_id
)
);
auto row = results.begin();
if (results.RowCount() == 1) {
MercSpellListEntries e{};
e.merc_spell_list_entry_id = static_cast<uint32_t>(strtoul(row[0], nullptr, 10));
e.merc_spell_list_id = static_cast<uint32_t>(strtoul(row[1], nullptr, 10));
e.spell_id = static_cast<uint32_t>(strtoul(row[2], nullptr, 10));
e.spell_type = static_cast<uint32_t>(strtoul(row[3], nullptr, 10));
e.stance_id = static_cast<uint8_t>(strtoul(row[4], nullptr, 10));
e.minlevel = static_cast<uint8_t>(strtoul(row[5], nullptr, 10));
e.maxlevel = static_cast<uint8_t>(strtoul(row[6], nullptr, 10));
e.slot = static_cast<int8_t>(atoi(row[7]));
e.procChance = static_cast<uint8_t>(strtoul(row[8], nullptr, 10));
return e;
}
return NewEntity();
}
static int DeleteOne(
Database& db,
int merc_spell_list_entries_id
)
{
auto results = db.QueryDatabase(
fmt::format(
"DELETE FROM {} WHERE {} = {}",
TableName(),
PrimaryKey(),
merc_spell_list_entries_id
)
);
return (results.Success() ? results.RowsAffected() : 0);
}
static int UpdateOne(
Database& db,
const MercSpellListEntries &e
)
{
std::vector<std::string> v;
auto columns = Columns();
v.push_back(columns[1] + " = " + std::to_string(e.merc_spell_list_id));
v.push_back(columns[2] + " = " + std::to_string(e.spell_id));
v.push_back(columns[3] + " = " + std::to_string(e.spell_type));
v.push_back(columns[4] + " = " + std::to_string(e.stance_id));
v.push_back(columns[5] + " = " + std::to_string(e.minlevel));
v.push_back(columns[6] + " = " + std::to_string(e.maxlevel));
v.push_back(columns[7] + " = " + std::to_string(e.slot));
v.push_back(columns[8] + " = " + std::to_string(e.procChance));
auto results = db.QueryDatabase(
fmt::format(
"UPDATE {} SET {} WHERE {} = {}",
TableName(),
Strings::Implode(", ", v),
PrimaryKey(),
e.merc_spell_list_entry_id
)
);
return (results.Success() ? results.RowsAffected() : 0);
}
static MercSpellListEntries InsertOne(
Database& db,
MercSpellListEntries e
)
{
std::vector<std::string> v;
v.push_back(std::to_string(e.merc_spell_list_entry_id));
v.push_back(std::to_string(e.merc_spell_list_id));
v.push_back(std::to_string(e.spell_id));
v.push_back(std::to_string(e.spell_type));
v.push_back(std::to_string(e.stance_id));
v.push_back(std::to_string(e.minlevel));
v.push_back(std::to_string(e.maxlevel));
v.push_back(std::to_string(e.slot));
v.push_back(std::to_string(e.procChance));
auto results = db.QueryDatabase(
fmt::format(
"{} VALUES ({})",
BaseInsert(),
Strings::Implode(",", v)
)
);
if (results.Success()) {
e.merc_spell_list_entry_id = results.LastInsertedID();
return e;
}
e = NewEntity();
return e;
}
static int InsertMany(
Database& db,
const std::vector<MercSpellListEntries> &entries
)
{
std::vector<std::string> insert_chunks;
for (auto &e: entries) {
std::vector<std::string> v;
v.push_back(std::to_string(e.merc_spell_list_entry_id));
v.push_back(std::to_string(e.merc_spell_list_id));
v.push_back(std::to_string(e.spell_id));
v.push_back(std::to_string(e.spell_type));
v.push_back(std::to_string(e.stance_id));
v.push_back(std::to_string(e.minlevel));
v.push_back(std::to_string(e.maxlevel));
v.push_back(std::to_string(e.slot));
v.push_back(std::to_string(e.procChance));
insert_chunks.push_back("(" + Strings::Implode(",", v) + ")");
}
std::vector<std::string> v;
auto results = db.QueryDatabase(
fmt::format(
"{} VALUES {}",
BaseInsert(),
Strings::Implode(",", insert_chunks)
)
);
return (results.Success() ? results.RowsAffected() : 0);
}
static std::vector<MercSpellListEntries> All(Database& db)
{
std::vector<MercSpellListEntries> all_entries;
auto results = db.QueryDatabase(
fmt::format(
"{}",
BaseSelect()
)
);
all_entries.reserve(results.RowCount());
for (auto row = results.begin(); row != results.end(); ++row) {
MercSpellListEntries e{};
e.merc_spell_list_entry_id = static_cast<uint32_t>(strtoul(row[0], nullptr, 10));
e.merc_spell_list_id = static_cast<uint32_t>(strtoul(row[1], nullptr, 10));
e.spell_id = static_cast<uint32_t>(strtoul(row[2], nullptr, 10));
e.spell_type = static_cast<uint32_t>(strtoul(row[3], nullptr, 10));
e.stance_id = static_cast<uint8_t>(strtoul(row[4], nullptr, 10));
e.minlevel = static_cast<uint8_t>(strtoul(row[5], nullptr, 10));
e.maxlevel = static_cast<uint8_t>(strtoul(row[6], nullptr, 10));
e.slot = static_cast<int8_t>(atoi(row[7]));
e.procChance = static_cast<uint8_t>(strtoul(row[8], nullptr, 10));
all_entries.push_back(e);
}
return all_entries;
}
static std::vector<MercSpellListEntries> GetWhere(Database& db, const std::string &where_filter)
{
std::vector<MercSpellListEntries> all_entries;
auto results = db.QueryDatabase(
fmt::format(
"{} WHERE {}",
BaseSelect(),
where_filter
)
);
all_entries.reserve(results.RowCount());
for (auto row = results.begin(); row != results.end(); ++row) {
MercSpellListEntries e{};
e.merc_spell_list_entry_id = static_cast<uint32_t>(strtoul(row[0], nullptr, 10));
e.merc_spell_list_id = static_cast<uint32_t>(strtoul(row[1], nullptr, 10));
e.spell_id = static_cast<uint32_t>(strtoul(row[2], nullptr, 10));
e.spell_type = static_cast<uint32_t>(strtoul(row[3], nullptr, 10));
e.stance_id = static_cast<uint8_t>(strtoul(row[4], nullptr, 10));
e.minlevel = static_cast<uint8_t>(strtoul(row[5], nullptr, 10));
e.maxlevel = static_cast<uint8_t>(strtoul(row[6], nullptr, 10));
e.slot = static_cast<int8_t>(atoi(row[7]));
e.procChance = static_cast<uint8_t>(strtoul(row[8], nullptr, 10));
all_entries.push_back(e);
}
return all_entries;
}
static int DeleteWhere(Database& db, const std::string &where_filter)
{
auto results = db.QueryDatabase(
fmt::format(
"DELETE FROM {} WHERE {}",
TableName(),
where_filter
)
);
return (results.Success() ? results.RowsAffected() : 0);
}
static int Truncate(Database& db)
{
auto results = db.QueryDatabase(
fmt::format(
"TRUNCATE TABLE {}",
TableName()
)
);
return (results.Success() ? results.RowsAffected() : 0);
}
static int64 GetMaxId(Database& db)
{
auto results = db.QueryDatabase(
fmt::format(
"SELECT COALESCE(MAX({}), 0) FROM {}",
PrimaryKey(),
TableName()
)
);
return (results.Success() && results.begin()[0] ? strtoll(results.begin()[0], nullptr, 10) : 0);
}
static int64 Count(Database& db, const std::string &where_filter = "")
{
auto results = db.QueryDatabase(
fmt::format(
"SELECT COUNT(*) FROM {} {}",
TableName(),
(where_filter.empty() ? "" : "WHERE " + where_filter)
)
);
return (results.Success() && results.begin()[0] ? strtoll(results.begin()[0], nullptr, 10) : 0);
}
};
#endif //EQEMU_BASE_MERC_SPELL_LIST_ENTRIES_REPOSITORY_H
@@ -0,0 +1,354 @@
/**
* DO NOT MODIFY THIS FILE
*
* This repository was automatically generated and is NOT to be modified directly.
* Any repository modifications are meant to be made to the repository extending the base.
* Any modifications to base repositories are to be made by the generator only
*
* @generator ./utils/scripts/generators/repository-generator.pl
* @docs https://eqemu.gitbook.io/server/in-development/developer-area/repositories
*/
#ifndef EQEMU_BASE_MERC_SPELL_LISTS_REPOSITORY_H
#define EQEMU_BASE_MERC_SPELL_LISTS_REPOSITORY_H
#include "../../database.h"
#include "../../strings.h"
#include <ctime>
class BaseMercSpellListsRepository {
public:
struct MercSpellLists {
uint32_t merc_spell_list_id;
uint32_t class_id;
uint8_t proficiency_id;
std::string name;
};
static std::string PrimaryKey()
{
return std::string("merc_spell_list_id");
}
static std::vector<std::string> Columns()
{
return {
"merc_spell_list_id",
"class_id",
"proficiency_id",
"name",
};
}
static std::vector<std::string> SelectColumns()
{
return {
"merc_spell_list_id",
"class_id",
"proficiency_id",
"name",
};
}
static std::string ColumnsRaw()
{
return std::string(Strings::Implode(", ", Columns()));
}
static std::string SelectColumnsRaw()
{
return std::string(Strings::Implode(", ", SelectColumns()));
}
static std::string TableName()
{
return std::string("merc_spell_lists");
}
static std::string BaseSelect()
{
return fmt::format(
"SELECT {} FROM {}",
SelectColumnsRaw(),
TableName()
);
}
static std::string BaseInsert()
{
return fmt::format(
"INSERT INTO {} ({}) ",
TableName(),
ColumnsRaw()
);
}
static MercSpellLists NewEntity()
{
MercSpellLists e{};
e.merc_spell_list_id = 0;
e.class_id = 0;
e.proficiency_id = 0;
e.name = "";
return e;
}
static MercSpellLists GetMercSpellLists(
const std::vector<MercSpellLists> &merc_spell_listss,
int merc_spell_lists_id
)
{
for (auto &merc_spell_lists : merc_spell_listss) {
if (merc_spell_lists.merc_spell_list_id == merc_spell_lists_id) {
return merc_spell_lists;
}
}
return NewEntity();
}
static MercSpellLists FindOne(
Database& db,
int merc_spell_lists_id
)
{
auto results = db.QueryDatabase(
fmt::format(
"{} WHERE {} = {} LIMIT 1",
BaseSelect(),
PrimaryKey(),
merc_spell_lists_id
)
);
auto row = results.begin();
if (results.RowCount() == 1) {
MercSpellLists e{};
e.merc_spell_list_id = static_cast<uint32_t>(strtoul(row[0], nullptr, 10));
e.class_id = static_cast<uint32_t>(strtoul(row[1], nullptr, 10));
e.proficiency_id = static_cast<uint8_t>(strtoul(row[2], nullptr, 10));
e.name = row[3] ? row[3] : "";
return e;
}
return NewEntity();
}
static int DeleteOne(
Database& db,
int merc_spell_lists_id
)
{
auto results = db.QueryDatabase(
fmt::format(
"DELETE FROM {} WHERE {} = {}",
TableName(),
PrimaryKey(),
merc_spell_lists_id
)
);
return (results.Success() ? results.RowsAffected() : 0);
}
static int UpdateOne(
Database& db,
const MercSpellLists &e
)
{
std::vector<std::string> v;
auto columns = Columns();
v.push_back(columns[1] + " = " + std::to_string(e.class_id));
v.push_back(columns[2] + " = " + std::to_string(e.proficiency_id));
v.push_back(columns[3] + " = '" + Strings::Escape(e.name) + "'");
auto results = db.QueryDatabase(
fmt::format(
"UPDATE {} SET {} WHERE {} = {}",
TableName(),
Strings::Implode(", ", v),
PrimaryKey(),
e.merc_spell_list_id
)
);
return (results.Success() ? results.RowsAffected() : 0);
}
static MercSpellLists InsertOne(
Database& db,
MercSpellLists e
)
{
std::vector<std::string> v;
v.push_back(std::to_string(e.merc_spell_list_id));
v.push_back(std::to_string(e.class_id));
v.push_back(std::to_string(e.proficiency_id));
v.push_back("'" + Strings::Escape(e.name) + "'");
auto results = db.QueryDatabase(
fmt::format(
"{} VALUES ({})",
BaseInsert(),
Strings::Implode(",", v)
)
);
if (results.Success()) {
e.merc_spell_list_id = results.LastInsertedID();
return e;
}
e = NewEntity();
return e;
}
static int InsertMany(
Database& db,
const std::vector<MercSpellLists> &entries
)
{
std::vector<std::string> insert_chunks;
for (auto &e: entries) {
std::vector<std::string> v;
v.push_back(std::to_string(e.merc_spell_list_id));
v.push_back(std::to_string(e.class_id));
v.push_back(std::to_string(e.proficiency_id));
v.push_back("'" + Strings::Escape(e.name) + "'");
insert_chunks.push_back("(" + Strings::Implode(",", v) + ")");
}
std::vector<std::string> v;
auto results = db.QueryDatabase(
fmt::format(
"{} VALUES {}",
BaseInsert(),
Strings::Implode(",", insert_chunks)
)
);
return (results.Success() ? results.RowsAffected() : 0);
}
static std::vector<MercSpellLists> All(Database& db)
{
std::vector<MercSpellLists> all_entries;
auto results = db.QueryDatabase(
fmt::format(
"{}",
BaseSelect()
)
);
all_entries.reserve(results.RowCount());
for (auto row = results.begin(); row != results.end(); ++row) {
MercSpellLists e{};
e.merc_spell_list_id = static_cast<uint32_t>(strtoul(row[0], nullptr, 10));
e.class_id = static_cast<uint32_t>(strtoul(row[1], nullptr, 10));
e.proficiency_id = static_cast<uint8_t>(strtoul(row[2], nullptr, 10));
e.name = row[3] ? row[3] : "";
all_entries.push_back(e);
}
return all_entries;
}
static std::vector<MercSpellLists> GetWhere(Database& db, const std::string &where_filter)
{
std::vector<MercSpellLists> all_entries;
auto results = db.QueryDatabase(
fmt::format(
"{} WHERE {}",
BaseSelect(),
where_filter
)
);
all_entries.reserve(results.RowCount());
for (auto row = results.begin(); row != results.end(); ++row) {
MercSpellLists e{};
e.merc_spell_list_id = static_cast<uint32_t>(strtoul(row[0], nullptr, 10));
e.class_id = static_cast<uint32_t>(strtoul(row[1], nullptr, 10));
e.proficiency_id = static_cast<uint8_t>(strtoul(row[2], nullptr, 10));
e.name = row[3] ? row[3] : "";
all_entries.push_back(e);
}
return all_entries;
}
static int DeleteWhere(Database& db, const std::string &where_filter)
{
auto results = db.QueryDatabase(
fmt::format(
"DELETE FROM {} WHERE {}",
TableName(),
where_filter
)
);
return (results.Success() ? results.RowsAffected() : 0);
}
static int Truncate(Database& db)
{
auto results = db.QueryDatabase(
fmt::format(
"TRUNCATE TABLE {}",
TableName()
)
);
return (results.Success() ? results.RowsAffected() : 0);
}
static int64 GetMaxId(Database& db)
{
auto results = db.QueryDatabase(
fmt::format(
"SELECT COALESCE(MAX({}), 0) FROM {}",
PrimaryKey(),
TableName()
)
);
return (results.Success() && results.begin()[0] ? strtoll(results.begin()[0], nullptr, 10) : 0);
}
static int64 Count(Database& db, const std::string &where_filter = "")
{
auto results = db.QueryDatabase(
fmt::format(
"SELECT COUNT(*) FROM {} {}",
TableName(),
(where_filter.empty() ? "" : "WHERE " + where_filter)
)
);
return (results.Success() && results.begin()[0] ? strtoll(results.begin()[0], nullptr, 10) : 0);
}
};
#endif //EQEMU_BASE_MERC_SPELL_LISTS_REPOSITORY_H
@@ -0,0 +1,364 @@
/**
* DO NOT MODIFY THIS FILE
*
* This repository was automatically generated and is NOT to be modified directly.
* Any repository modifications are meant to be made to the repository extending the base.
* Any modifications to base repositories are to be made by the generator only
*
* @generator ./utils/scripts/generators/repository-generator.pl
* @docs https://eqemu.gitbook.io/server/in-development/developer-area/repositories
*/
#ifndef EQEMU_BASE_MERC_STANCE_ENTRIES_REPOSITORY_H
#define EQEMU_BASE_MERC_STANCE_ENTRIES_REPOSITORY_H
#include "../../database.h"
#include "../../strings.h"
#include <ctime>
class BaseMercStanceEntriesRepository {
public:
struct MercStanceEntries {
uint32_t merc_stance_entry_id;
uint32_t class_id;
uint8_t proficiency_id;
uint8_t stance_id;
int8_t isdefault;
};
static std::string PrimaryKey()
{
return std::string("merc_stance_entry_id");
}
static std::vector<std::string> Columns()
{
return {
"merc_stance_entry_id",
"class_id",
"proficiency_id",
"stance_id",
"isdefault",
};
}
static std::vector<std::string> SelectColumns()
{
return {
"merc_stance_entry_id",
"class_id",
"proficiency_id",
"stance_id",
"isdefault",
};
}
static std::string ColumnsRaw()
{
return std::string(Strings::Implode(", ", Columns()));
}
static std::string SelectColumnsRaw()
{
return std::string(Strings::Implode(", ", SelectColumns()));
}
static std::string TableName()
{
return std::string("merc_stance_entries");
}
static std::string BaseSelect()
{
return fmt::format(
"SELECT {} FROM {}",
SelectColumnsRaw(),
TableName()
);
}
static std::string BaseInsert()
{
return fmt::format(
"INSERT INTO {} ({}) ",
TableName(),
ColumnsRaw()
);
}
static MercStanceEntries NewEntity()
{
MercStanceEntries e{};
e.merc_stance_entry_id = 0;
e.class_id = 0;
e.proficiency_id = 0;
e.stance_id = 0;
e.isdefault = 0;
return e;
}
static MercStanceEntries GetMercStanceEntries(
const std::vector<MercStanceEntries> &merc_stance_entriess,
int merc_stance_entries_id
)
{
for (auto &merc_stance_entries : merc_stance_entriess) {
if (merc_stance_entries.merc_stance_entry_id == merc_stance_entries_id) {
return merc_stance_entries;
}
}
return NewEntity();
}
static MercStanceEntries FindOne(
Database& db,
int merc_stance_entries_id
)
{
auto results = db.QueryDatabase(
fmt::format(
"{} WHERE {} = {} LIMIT 1",
BaseSelect(),
PrimaryKey(),
merc_stance_entries_id
)
);
auto row = results.begin();
if (results.RowCount() == 1) {
MercStanceEntries e{};
e.merc_stance_entry_id = static_cast<uint32_t>(strtoul(row[0], nullptr, 10));
e.class_id = static_cast<uint32_t>(strtoul(row[1], nullptr, 10));
e.proficiency_id = static_cast<uint8_t>(strtoul(row[2], nullptr, 10));
e.stance_id = static_cast<uint8_t>(strtoul(row[3], nullptr, 10));
e.isdefault = static_cast<int8_t>(atoi(row[4]));
return e;
}
return NewEntity();
}
static int DeleteOne(
Database& db,
int merc_stance_entries_id
)
{
auto results = db.QueryDatabase(
fmt::format(
"DELETE FROM {} WHERE {} = {}",
TableName(),
PrimaryKey(),
merc_stance_entries_id
)
);
return (results.Success() ? results.RowsAffected() : 0);
}
static int UpdateOne(
Database& db,
const MercStanceEntries &e
)
{
std::vector<std::string> v;
auto columns = Columns();
v.push_back(columns[1] + " = " + std::to_string(e.class_id));
v.push_back(columns[2] + " = " + std::to_string(e.proficiency_id));
v.push_back(columns[3] + " = " + std::to_string(e.stance_id));
v.push_back(columns[4] + " = " + std::to_string(e.isdefault));
auto results = db.QueryDatabase(
fmt::format(
"UPDATE {} SET {} WHERE {} = {}",
TableName(),
Strings::Implode(", ", v),
PrimaryKey(),
e.merc_stance_entry_id
)
);
return (results.Success() ? results.RowsAffected() : 0);
}
static MercStanceEntries InsertOne(
Database& db,
MercStanceEntries e
)
{
std::vector<std::string> v;
v.push_back(std::to_string(e.merc_stance_entry_id));
v.push_back(std::to_string(e.class_id));
v.push_back(std::to_string(e.proficiency_id));
v.push_back(std::to_string(e.stance_id));
v.push_back(std::to_string(e.isdefault));
auto results = db.QueryDatabase(
fmt::format(
"{} VALUES ({})",
BaseInsert(),
Strings::Implode(",", v)
)
);
if (results.Success()) {
e.merc_stance_entry_id = results.LastInsertedID();
return e;
}
e = NewEntity();
return e;
}
static int InsertMany(
Database& db,
const std::vector<MercStanceEntries> &entries
)
{
std::vector<std::string> insert_chunks;
for (auto &e: entries) {
std::vector<std::string> v;
v.push_back(std::to_string(e.merc_stance_entry_id));
v.push_back(std::to_string(e.class_id));
v.push_back(std::to_string(e.proficiency_id));
v.push_back(std::to_string(e.stance_id));
v.push_back(std::to_string(e.isdefault));
insert_chunks.push_back("(" + Strings::Implode(",", v) + ")");
}
std::vector<std::string> v;
auto results = db.QueryDatabase(
fmt::format(
"{} VALUES {}",
BaseInsert(),
Strings::Implode(",", insert_chunks)
)
);
return (results.Success() ? results.RowsAffected() : 0);
}
static std::vector<MercStanceEntries> All(Database& db)
{
std::vector<MercStanceEntries> all_entries;
auto results = db.QueryDatabase(
fmt::format(
"{}",
BaseSelect()
)
);
all_entries.reserve(results.RowCount());
for (auto row = results.begin(); row != results.end(); ++row) {
MercStanceEntries e{};
e.merc_stance_entry_id = static_cast<uint32_t>(strtoul(row[0], nullptr, 10));
e.class_id = static_cast<uint32_t>(strtoul(row[1], nullptr, 10));
e.proficiency_id = static_cast<uint8_t>(strtoul(row[2], nullptr, 10));
e.stance_id = static_cast<uint8_t>(strtoul(row[3], nullptr, 10));
e.isdefault = static_cast<int8_t>(atoi(row[4]));
all_entries.push_back(e);
}
return all_entries;
}
static std::vector<MercStanceEntries> GetWhere(Database& db, const std::string &where_filter)
{
std::vector<MercStanceEntries> all_entries;
auto results = db.QueryDatabase(
fmt::format(
"{} WHERE {}",
BaseSelect(),
where_filter
)
);
all_entries.reserve(results.RowCount());
for (auto row = results.begin(); row != results.end(); ++row) {
MercStanceEntries e{};
e.merc_stance_entry_id = static_cast<uint32_t>(strtoul(row[0], nullptr, 10));
e.class_id = static_cast<uint32_t>(strtoul(row[1], nullptr, 10));
e.proficiency_id = static_cast<uint8_t>(strtoul(row[2], nullptr, 10));
e.stance_id = static_cast<uint8_t>(strtoul(row[3], nullptr, 10));
e.isdefault = static_cast<int8_t>(atoi(row[4]));
all_entries.push_back(e);
}
return all_entries;
}
static int DeleteWhere(Database& db, const std::string &where_filter)
{
auto results = db.QueryDatabase(
fmt::format(
"DELETE FROM {} WHERE {}",
TableName(),
where_filter
)
);
return (results.Success() ? results.RowsAffected() : 0);
}
static int Truncate(Database& db)
{
auto results = db.QueryDatabase(
fmt::format(
"TRUNCATE TABLE {}",
TableName()
)
);
return (results.Success() ? results.RowsAffected() : 0);
}
static int64 GetMaxId(Database& db)
{
auto results = db.QueryDatabase(
fmt::format(
"SELECT COALESCE(MAX({}), 0) FROM {}",
PrimaryKey(),
TableName()
)
);
return (results.Success() && results.begin()[0] ? strtoll(results.begin()[0], nullptr, 10) : 0);
}
static int64 Count(Database& db, const std::string &where_filter = "")
{
auto results = db.QueryDatabase(
fmt::format(
"SELECT COUNT(*) FROM {} {}",
TableName(),
(where_filter.empty() ? "" : "WHERE " + where_filter)
)
);
return (results.Success() && results.begin()[0] ? strtoll(results.begin()[0], nullptr, 10) : 0);
}
};
#endif //EQEMU_BASE_MERC_STANCE_ENTRIES_REPOSITORY_H
@@ -0,0 +1,645 @@
/**
* DO NOT MODIFY THIS FILE
*
* This repository was automatically generated and is NOT to be modified directly.
* Any repository modifications are meant to be made to the repository extending the base.
* Any modifications to base repositories are to be made by the generator only
*
* @generator ./utils/scripts/generators/repository-generator.pl
* @docs https://eqemu.gitbook.io/server/in-development/developer-area/repositories
*/
#ifndef EQEMU_BASE_MERC_STATS_REPOSITORY_H
#define EQEMU_BASE_MERC_STATS_REPOSITORY_H
#include "../../database.h"
#include "../../strings.h"
#include <ctime>
class BaseMercStatsRepository {
public:
struct MercStats {
uint32_t merc_npc_type_id;
uint8_t clientlevel;
uint8_t level;
int32_t hp;
int32_t mana;
int16_t AC;
int32_t ATK;
uint32_t STR;
uint32_t STA;
uint32_t DEX;
uint32_t AGI;
uint32_t _INT;
uint32_t WIS;
uint32_t CHA;
int16_t MR;
int16_t CR;
int16_t DR;
int16_t FR;
int16_t PR;
int16_t Corrup;
uint32_t mindmg;
uint32_t maxdmg;
int16_t attack_count;
int8_t attack_speed;
uint8_t attack_delay;
std::string special_abilities;
int32_t Accuracy;
uint32_t hp_regen_rate;
uint32_t mana_regen_rate;
float runspeed;
int32_t statscale;
float spellscale;
float healscale;
};
static std::string PrimaryKey()
{
return std::string("merc_npc_type_id");
}
static std::vector<std::string> Columns()
{
return {
"merc_npc_type_id",
"clientlevel",
"level",
"hp",
"mana",
"AC",
"ATK",
"STR",
"STA",
"DEX",
"AGI",
"_INT",
"WIS",
"CHA",
"MR",
"CR",
"DR",
"FR",
"PR",
"Corrup",
"mindmg",
"maxdmg",
"attack_count",
"attack_speed",
"attack_delay",
"special_abilities",
"Accuracy",
"hp_regen_rate",
"mana_regen_rate",
"runspeed",
"statscale",
"spellscale",
"healscale",
};
}
static std::vector<std::string> SelectColumns()
{
return {
"merc_npc_type_id",
"clientlevel",
"level",
"hp",
"mana",
"AC",
"ATK",
"STR",
"STA",
"DEX",
"AGI",
"_INT",
"WIS",
"CHA",
"MR",
"CR",
"DR",
"FR",
"PR",
"Corrup",
"mindmg",
"maxdmg",
"attack_count",
"attack_speed",
"attack_delay",
"special_abilities",
"Accuracy",
"hp_regen_rate",
"mana_regen_rate",
"runspeed",
"statscale",
"spellscale",
"healscale",
};
}
static std::string ColumnsRaw()
{
return std::string(Strings::Implode(", ", Columns()));
}
static std::string SelectColumnsRaw()
{
return std::string(Strings::Implode(", ", SelectColumns()));
}
static std::string TableName()
{
return std::string("merc_stats");
}
static std::string BaseSelect()
{
return fmt::format(
"SELECT {} FROM {}",
SelectColumnsRaw(),
TableName()
);
}
static std::string BaseInsert()
{
return fmt::format(
"INSERT INTO {} ({}) ",
TableName(),
ColumnsRaw()
);
}
static MercStats NewEntity()
{
MercStats e{};
e.merc_npc_type_id = 0;
e.clientlevel = 1;
e.level = 1;
e.hp = 1;
e.mana = 0;
e.AC = 1;
e.ATK = 1;
e.STR = 75;
e.STA = 75;
e.DEX = 75;
e.AGI = 75;
e._INT = 80;
e.WIS = 80;
e.CHA = 75;
e.MR = 15;
e.CR = 15;
e.DR = 15;
e.FR = 15;
e.PR = 15;
e.Corrup = 15;
e.mindmg = 1;
e.maxdmg = 1;
e.attack_count = 0;
e.attack_speed = 0;
e.attack_delay = 30;
e.special_abilities = "";
e.Accuracy = 0;
e.hp_regen_rate = 1;
e.mana_regen_rate = 1;
e.runspeed = 0;
e.statscale = 100;
e.spellscale = 100;
e.healscale = 100;
return e;
}
static MercStats GetMercStats(
const std::vector<MercStats> &merc_statss,
int merc_stats_id
)
{
for (auto &merc_stats : merc_statss) {
if (merc_stats.merc_npc_type_id == merc_stats_id) {
return merc_stats;
}
}
return NewEntity();
}
static MercStats FindOne(
Database& db,
int merc_stats_id
)
{
auto results = db.QueryDatabase(
fmt::format(
"{} WHERE {} = {} LIMIT 1",
BaseSelect(),
PrimaryKey(),
merc_stats_id
)
);
auto row = results.begin();
if (results.RowCount() == 1) {
MercStats e{};
e.merc_npc_type_id = static_cast<uint32_t>(strtoul(row[0], nullptr, 10));
e.clientlevel = static_cast<uint8_t>(strtoul(row[1], nullptr, 10));
e.level = static_cast<uint8_t>(strtoul(row[2], nullptr, 10));
e.hp = static_cast<int32_t>(atoi(row[3]));
e.mana = static_cast<int32_t>(atoi(row[4]));
e.AC = static_cast<int16_t>(atoi(row[5]));
e.ATK = static_cast<int32_t>(atoi(row[6]));
e.STR = static_cast<uint32_t>(strtoul(row[7], nullptr, 10));
e.STA = static_cast<uint32_t>(strtoul(row[8], nullptr, 10));
e.DEX = static_cast<uint32_t>(strtoul(row[9], nullptr, 10));
e.AGI = static_cast<uint32_t>(strtoul(row[10], nullptr, 10));
e._INT = static_cast<uint32_t>(strtoul(row[11], nullptr, 10));
e.WIS = static_cast<uint32_t>(strtoul(row[12], nullptr, 10));
e.CHA = static_cast<uint32_t>(strtoul(row[13], nullptr, 10));
e.MR = static_cast<int16_t>(atoi(row[14]));
e.CR = static_cast<int16_t>(atoi(row[15]));
e.DR = static_cast<int16_t>(atoi(row[16]));
e.FR = static_cast<int16_t>(atoi(row[17]));
e.PR = static_cast<int16_t>(atoi(row[18]));
e.Corrup = static_cast<int16_t>(atoi(row[19]));
e.mindmg = static_cast<uint32_t>(strtoul(row[20], nullptr, 10));
e.maxdmg = static_cast<uint32_t>(strtoul(row[21], nullptr, 10));
e.attack_count = static_cast<int16_t>(atoi(row[22]));
e.attack_speed = static_cast<int8_t>(atoi(row[23]));
e.attack_delay = static_cast<uint8_t>(strtoul(row[24], nullptr, 10));
e.special_abilities = row[25] ? row[25] : "";
e.Accuracy = static_cast<int32_t>(atoi(row[26]));
e.hp_regen_rate = static_cast<uint32_t>(strtoul(row[27], nullptr, 10));
e.mana_regen_rate = static_cast<uint32_t>(strtoul(row[28], nullptr, 10));
e.runspeed = strtof(row[29], nullptr);
e.statscale = static_cast<int32_t>(atoi(row[30]));
e.spellscale = strtof(row[31], nullptr);
e.healscale = strtof(row[32], nullptr);
return e;
}
return NewEntity();
}
static int DeleteOne(
Database& db,
int merc_stats_id
)
{
auto results = db.QueryDatabase(
fmt::format(
"DELETE FROM {} WHERE {} = {}",
TableName(),
PrimaryKey(),
merc_stats_id
)
);
return (results.Success() ? results.RowsAffected() : 0);
}
static int UpdateOne(
Database& db,
const MercStats &e
)
{
std::vector<std::string> v;
auto columns = Columns();
v.push_back(columns[0] + " = " + std::to_string(e.merc_npc_type_id));
v.push_back(columns[1] + " = " + std::to_string(e.clientlevel));
v.push_back(columns[2] + " = " + std::to_string(e.level));
v.push_back(columns[3] + " = " + std::to_string(e.hp));
v.push_back(columns[4] + " = " + std::to_string(e.mana));
v.push_back(columns[5] + " = " + std::to_string(e.AC));
v.push_back(columns[6] + " = " + std::to_string(e.ATK));
v.push_back(columns[7] + " = " + std::to_string(e.STR));
v.push_back(columns[8] + " = " + std::to_string(e.STA));
v.push_back(columns[9] + " = " + std::to_string(e.DEX));
v.push_back(columns[10] + " = " + std::to_string(e.AGI));
v.push_back(columns[11] + " = " + std::to_string(e._INT));
v.push_back(columns[12] + " = " + std::to_string(e.WIS));
v.push_back(columns[13] + " = " + std::to_string(e.CHA));
v.push_back(columns[14] + " = " + std::to_string(e.MR));
v.push_back(columns[15] + " = " + std::to_string(e.CR));
v.push_back(columns[16] + " = " + std::to_string(e.DR));
v.push_back(columns[17] + " = " + std::to_string(e.FR));
v.push_back(columns[18] + " = " + std::to_string(e.PR));
v.push_back(columns[19] + " = " + std::to_string(e.Corrup));
v.push_back(columns[20] + " = " + std::to_string(e.mindmg));
v.push_back(columns[21] + " = " + std::to_string(e.maxdmg));
v.push_back(columns[22] + " = " + std::to_string(e.attack_count));
v.push_back(columns[23] + " = " + std::to_string(e.attack_speed));
v.push_back(columns[24] + " = " + std::to_string(e.attack_delay));
v.push_back(columns[25] + " = '" + Strings::Escape(e.special_abilities) + "'");
v.push_back(columns[26] + " = " + std::to_string(e.Accuracy));
v.push_back(columns[27] + " = " + std::to_string(e.hp_regen_rate));
v.push_back(columns[28] + " = " + std::to_string(e.mana_regen_rate));
v.push_back(columns[29] + " = " + std::to_string(e.runspeed));
v.push_back(columns[30] + " = " + std::to_string(e.statscale));
v.push_back(columns[31] + " = " + std::to_string(e.spellscale));
v.push_back(columns[32] + " = " + std::to_string(e.healscale));
auto results = db.QueryDatabase(
fmt::format(
"UPDATE {} SET {} WHERE {} = {}",
TableName(),
Strings::Implode(", ", v),
PrimaryKey(),
e.merc_npc_type_id
)
);
return (results.Success() ? results.RowsAffected() : 0);
}
static MercStats InsertOne(
Database& db,
MercStats e
)
{
std::vector<std::string> v;
v.push_back(std::to_string(e.merc_npc_type_id));
v.push_back(std::to_string(e.clientlevel));
v.push_back(std::to_string(e.level));
v.push_back(std::to_string(e.hp));
v.push_back(std::to_string(e.mana));
v.push_back(std::to_string(e.AC));
v.push_back(std::to_string(e.ATK));
v.push_back(std::to_string(e.STR));
v.push_back(std::to_string(e.STA));
v.push_back(std::to_string(e.DEX));
v.push_back(std::to_string(e.AGI));
v.push_back(std::to_string(e._INT));
v.push_back(std::to_string(e.WIS));
v.push_back(std::to_string(e.CHA));
v.push_back(std::to_string(e.MR));
v.push_back(std::to_string(e.CR));
v.push_back(std::to_string(e.DR));
v.push_back(std::to_string(e.FR));
v.push_back(std::to_string(e.PR));
v.push_back(std::to_string(e.Corrup));
v.push_back(std::to_string(e.mindmg));
v.push_back(std::to_string(e.maxdmg));
v.push_back(std::to_string(e.attack_count));
v.push_back(std::to_string(e.attack_speed));
v.push_back(std::to_string(e.attack_delay));
v.push_back("'" + Strings::Escape(e.special_abilities) + "'");
v.push_back(std::to_string(e.Accuracy));
v.push_back(std::to_string(e.hp_regen_rate));
v.push_back(std::to_string(e.mana_regen_rate));
v.push_back(std::to_string(e.runspeed));
v.push_back(std::to_string(e.statscale));
v.push_back(std::to_string(e.spellscale));
v.push_back(std::to_string(e.healscale));
auto results = db.QueryDatabase(
fmt::format(
"{} VALUES ({})",
BaseInsert(),
Strings::Implode(",", v)
)
);
if (results.Success()) {
e.merc_npc_type_id = results.LastInsertedID();
return e;
}
e = NewEntity();
return e;
}
static int InsertMany(
Database& db,
const std::vector<MercStats> &entries
)
{
std::vector<std::string> insert_chunks;
for (auto &e: entries) {
std::vector<std::string> v;
v.push_back(std::to_string(e.merc_npc_type_id));
v.push_back(std::to_string(e.clientlevel));
v.push_back(std::to_string(e.level));
v.push_back(std::to_string(e.hp));
v.push_back(std::to_string(e.mana));
v.push_back(std::to_string(e.AC));
v.push_back(std::to_string(e.ATK));
v.push_back(std::to_string(e.STR));
v.push_back(std::to_string(e.STA));
v.push_back(std::to_string(e.DEX));
v.push_back(std::to_string(e.AGI));
v.push_back(std::to_string(e._INT));
v.push_back(std::to_string(e.WIS));
v.push_back(std::to_string(e.CHA));
v.push_back(std::to_string(e.MR));
v.push_back(std::to_string(e.CR));
v.push_back(std::to_string(e.DR));
v.push_back(std::to_string(e.FR));
v.push_back(std::to_string(e.PR));
v.push_back(std::to_string(e.Corrup));
v.push_back(std::to_string(e.mindmg));
v.push_back(std::to_string(e.maxdmg));
v.push_back(std::to_string(e.attack_count));
v.push_back(std::to_string(e.attack_speed));
v.push_back(std::to_string(e.attack_delay));
v.push_back("'" + Strings::Escape(e.special_abilities) + "'");
v.push_back(std::to_string(e.Accuracy));
v.push_back(std::to_string(e.hp_regen_rate));
v.push_back(std::to_string(e.mana_regen_rate));
v.push_back(std::to_string(e.runspeed));
v.push_back(std::to_string(e.statscale));
v.push_back(std::to_string(e.spellscale));
v.push_back(std::to_string(e.healscale));
insert_chunks.push_back("(" + Strings::Implode(",", v) + ")");
}
std::vector<std::string> v;
auto results = db.QueryDatabase(
fmt::format(
"{} VALUES {}",
BaseInsert(),
Strings::Implode(",", insert_chunks)
)
);
return (results.Success() ? results.RowsAffected() : 0);
}
static std::vector<MercStats> All(Database& db)
{
std::vector<MercStats> all_entries;
auto results = db.QueryDatabase(
fmt::format(
"{}",
BaseSelect()
)
);
all_entries.reserve(results.RowCount());
for (auto row = results.begin(); row != results.end(); ++row) {
MercStats e{};
e.merc_npc_type_id = static_cast<uint32_t>(strtoul(row[0], nullptr, 10));
e.clientlevel = static_cast<uint8_t>(strtoul(row[1], nullptr, 10));
e.level = static_cast<uint8_t>(strtoul(row[2], nullptr, 10));
e.hp = static_cast<int32_t>(atoi(row[3]));
e.mana = static_cast<int32_t>(atoi(row[4]));
e.AC = static_cast<int16_t>(atoi(row[5]));
e.ATK = static_cast<int32_t>(atoi(row[6]));
e.STR = static_cast<uint32_t>(strtoul(row[7], nullptr, 10));
e.STA = static_cast<uint32_t>(strtoul(row[8], nullptr, 10));
e.DEX = static_cast<uint32_t>(strtoul(row[9], nullptr, 10));
e.AGI = static_cast<uint32_t>(strtoul(row[10], nullptr, 10));
e._INT = static_cast<uint32_t>(strtoul(row[11], nullptr, 10));
e.WIS = static_cast<uint32_t>(strtoul(row[12], nullptr, 10));
e.CHA = static_cast<uint32_t>(strtoul(row[13], nullptr, 10));
e.MR = static_cast<int16_t>(atoi(row[14]));
e.CR = static_cast<int16_t>(atoi(row[15]));
e.DR = static_cast<int16_t>(atoi(row[16]));
e.FR = static_cast<int16_t>(atoi(row[17]));
e.PR = static_cast<int16_t>(atoi(row[18]));
e.Corrup = static_cast<int16_t>(atoi(row[19]));
e.mindmg = static_cast<uint32_t>(strtoul(row[20], nullptr, 10));
e.maxdmg = static_cast<uint32_t>(strtoul(row[21], nullptr, 10));
e.attack_count = static_cast<int16_t>(atoi(row[22]));
e.attack_speed = static_cast<int8_t>(atoi(row[23]));
e.attack_delay = static_cast<uint8_t>(strtoul(row[24], nullptr, 10));
e.special_abilities = row[25] ? row[25] : "";
e.Accuracy = static_cast<int32_t>(atoi(row[26]));
e.hp_regen_rate = static_cast<uint32_t>(strtoul(row[27], nullptr, 10));
e.mana_regen_rate = static_cast<uint32_t>(strtoul(row[28], nullptr, 10));
e.runspeed = strtof(row[29], nullptr);
e.statscale = static_cast<int32_t>(atoi(row[30]));
e.spellscale = strtof(row[31], nullptr);
e.healscale = strtof(row[32], nullptr);
all_entries.push_back(e);
}
return all_entries;
}
static std::vector<MercStats> GetWhere(Database& db, const std::string &where_filter)
{
std::vector<MercStats> all_entries;
auto results = db.QueryDatabase(
fmt::format(
"{} WHERE {}",
BaseSelect(),
where_filter
)
);
all_entries.reserve(results.RowCount());
for (auto row = results.begin(); row != results.end(); ++row) {
MercStats e{};
e.merc_npc_type_id = static_cast<uint32_t>(strtoul(row[0], nullptr, 10));
e.clientlevel = static_cast<uint8_t>(strtoul(row[1], nullptr, 10));
e.level = static_cast<uint8_t>(strtoul(row[2], nullptr, 10));
e.hp = static_cast<int32_t>(atoi(row[3]));
e.mana = static_cast<int32_t>(atoi(row[4]));
e.AC = static_cast<int16_t>(atoi(row[5]));
e.ATK = static_cast<int32_t>(atoi(row[6]));
e.STR = static_cast<uint32_t>(strtoul(row[7], nullptr, 10));
e.STA = static_cast<uint32_t>(strtoul(row[8], nullptr, 10));
e.DEX = static_cast<uint32_t>(strtoul(row[9], nullptr, 10));
e.AGI = static_cast<uint32_t>(strtoul(row[10], nullptr, 10));
e._INT = static_cast<uint32_t>(strtoul(row[11], nullptr, 10));
e.WIS = static_cast<uint32_t>(strtoul(row[12], nullptr, 10));
e.CHA = static_cast<uint32_t>(strtoul(row[13], nullptr, 10));
e.MR = static_cast<int16_t>(atoi(row[14]));
e.CR = static_cast<int16_t>(atoi(row[15]));
e.DR = static_cast<int16_t>(atoi(row[16]));
e.FR = static_cast<int16_t>(atoi(row[17]));
e.PR = static_cast<int16_t>(atoi(row[18]));
e.Corrup = static_cast<int16_t>(atoi(row[19]));
e.mindmg = static_cast<uint32_t>(strtoul(row[20], nullptr, 10));
e.maxdmg = static_cast<uint32_t>(strtoul(row[21], nullptr, 10));
e.attack_count = static_cast<int16_t>(atoi(row[22]));
e.attack_speed = static_cast<int8_t>(atoi(row[23]));
e.attack_delay = static_cast<uint8_t>(strtoul(row[24], nullptr, 10));
e.special_abilities = row[25] ? row[25] : "";
e.Accuracy = static_cast<int32_t>(atoi(row[26]));
e.hp_regen_rate = static_cast<uint32_t>(strtoul(row[27], nullptr, 10));
e.mana_regen_rate = static_cast<uint32_t>(strtoul(row[28], nullptr, 10));
e.runspeed = strtof(row[29], nullptr);
e.statscale = static_cast<int32_t>(atoi(row[30]));
e.spellscale = strtof(row[31], nullptr);
e.healscale = strtof(row[32], nullptr);
all_entries.push_back(e);
}
return all_entries;
}
static int DeleteWhere(Database& db, const std::string &where_filter)
{
auto results = db.QueryDatabase(
fmt::format(
"DELETE FROM {} WHERE {}",
TableName(),
where_filter
)
);
return (results.Success() ? results.RowsAffected() : 0);
}
static int Truncate(Database& db)
{
auto results = db.QueryDatabase(
fmt::format(
"TRUNCATE TABLE {}",
TableName()
)
);
return (results.Success() ? results.RowsAffected() : 0);
}
static int64 GetMaxId(Database& db)
{
auto results = db.QueryDatabase(
fmt::format(
"SELECT COALESCE(MAX({}), 0) FROM {}",
PrimaryKey(),
TableName()
)
);
return (results.Success() && results.begin()[0] ? strtoll(results.begin()[0], nullptr, 10) : 0);
}
static int64 Count(Database& db, const std::string &where_filter = "")
{
auto results = db.QueryDatabase(
fmt::format(
"SELECT COUNT(*) FROM {} {}",
TableName(),
(where_filter.empty() ? "" : "WHERE " + where_filter)
)
);
return (results.Success() && results.begin()[0] ? strtoll(results.begin()[0], nullptr, 10) : 0);
}
};
#endif //EQEMU_BASE_MERC_STATS_REPOSITORY_H
@@ -0,0 +1,354 @@
/**
* DO NOT MODIFY THIS FILE
*
* This repository was automatically generated and is NOT to be modified directly.
* Any repository modifications are meant to be made to the repository extending the base.
* Any modifications to base repositories are to be made by the generator only
*
* @generator ./utils/scripts/generators/repository-generator.pl
* @docs https://eqemu.gitbook.io/server/in-development/developer-area/repositories
*/
#ifndef EQEMU_BASE_MERC_SUBTYPES_REPOSITORY_H
#define EQEMU_BASE_MERC_SUBTYPES_REPOSITORY_H
#include "../../database.h"
#include "../../strings.h"
#include <ctime>
class BaseMercSubtypesRepository {
public:
struct MercSubtypes {
uint32_t merc_subtype_id;
uint32_t class_id;
uint8_t tier_id;
uint8_t confidence_id;
};
static std::string PrimaryKey()
{
return std::string("merc_subtype_id");
}
static std::vector<std::string> Columns()
{
return {
"merc_subtype_id",
"class_id",
"tier_id",
"confidence_id",
};
}
static std::vector<std::string> SelectColumns()
{
return {
"merc_subtype_id",
"class_id",
"tier_id",
"confidence_id",
};
}
static std::string ColumnsRaw()
{
return std::string(Strings::Implode(", ", Columns()));
}
static std::string SelectColumnsRaw()
{
return std::string(Strings::Implode(", ", SelectColumns()));
}
static std::string TableName()
{
return std::string("merc_subtypes");
}
static std::string BaseSelect()
{
return fmt::format(
"SELECT {} FROM {}",
SelectColumnsRaw(),
TableName()
);
}
static std::string BaseInsert()
{
return fmt::format(
"INSERT INTO {} ({}) ",
TableName(),
ColumnsRaw()
);
}
static MercSubtypes NewEntity()
{
MercSubtypes e{};
e.merc_subtype_id = 0;
e.class_id = 0;
e.tier_id = 0;
e.confidence_id = 0;
return e;
}
static MercSubtypes GetMercSubtypes(
const std::vector<MercSubtypes> &merc_subtypess,
int merc_subtypes_id
)
{
for (auto &merc_subtypes : merc_subtypess) {
if (merc_subtypes.merc_subtype_id == merc_subtypes_id) {
return merc_subtypes;
}
}
return NewEntity();
}
static MercSubtypes FindOne(
Database& db,
int merc_subtypes_id
)
{
auto results = db.QueryDatabase(
fmt::format(
"{} WHERE {} = {} LIMIT 1",
BaseSelect(),
PrimaryKey(),
merc_subtypes_id
)
);
auto row = results.begin();
if (results.RowCount() == 1) {
MercSubtypes e{};
e.merc_subtype_id = static_cast<uint32_t>(strtoul(row[0], nullptr, 10));
e.class_id = static_cast<uint32_t>(strtoul(row[1], nullptr, 10));
e.tier_id = static_cast<uint8_t>(strtoul(row[2], nullptr, 10));
e.confidence_id = static_cast<uint8_t>(strtoul(row[3], nullptr, 10));
return e;
}
return NewEntity();
}
static int DeleteOne(
Database& db,
int merc_subtypes_id
)
{
auto results = db.QueryDatabase(
fmt::format(
"DELETE FROM {} WHERE {} = {}",
TableName(),
PrimaryKey(),
merc_subtypes_id
)
);
return (results.Success() ? results.RowsAffected() : 0);
}
static int UpdateOne(
Database& db,
const MercSubtypes &e
)
{
std::vector<std::string> v;
auto columns = Columns();
v.push_back(columns[1] + " = " + std::to_string(e.class_id));
v.push_back(columns[2] + " = " + std::to_string(e.tier_id));
v.push_back(columns[3] + " = " + std::to_string(e.confidence_id));
auto results = db.QueryDatabase(
fmt::format(
"UPDATE {} SET {} WHERE {} = {}",
TableName(),
Strings::Implode(", ", v),
PrimaryKey(),
e.merc_subtype_id
)
);
return (results.Success() ? results.RowsAffected() : 0);
}
static MercSubtypes InsertOne(
Database& db,
MercSubtypes e
)
{
std::vector<std::string> v;
v.push_back(std::to_string(e.merc_subtype_id));
v.push_back(std::to_string(e.class_id));
v.push_back(std::to_string(e.tier_id));
v.push_back(std::to_string(e.confidence_id));
auto results = db.QueryDatabase(
fmt::format(
"{} VALUES ({})",
BaseInsert(),
Strings::Implode(",", v)
)
);
if (results.Success()) {
e.merc_subtype_id = results.LastInsertedID();
return e;
}
e = NewEntity();
return e;
}
static int InsertMany(
Database& db,
const std::vector<MercSubtypes> &entries
)
{
std::vector<std::string> insert_chunks;
for (auto &e: entries) {
std::vector<std::string> v;
v.push_back(std::to_string(e.merc_subtype_id));
v.push_back(std::to_string(e.class_id));
v.push_back(std::to_string(e.tier_id));
v.push_back(std::to_string(e.confidence_id));
insert_chunks.push_back("(" + Strings::Implode(",", v) + ")");
}
std::vector<std::string> v;
auto results = db.QueryDatabase(
fmt::format(
"{} VALUES {}",
BaseInsert(),
Strings::Implode(",", insert_chunks)
)
);
return (results.Success() ? results.RowsAffected() : 0);
}
static std::vector<MercSubtypes> All(Database& db)
{
std::vector<MercSubtypes> all_entries;
auto results = db.QueryDatabase(
fmt::format(
"{}",
BaseSelect()
)
);
all_entries.reserve(results.RowCount());
for (auto row = results.begin(); row != results.end(); ++row) {
MercSubtypes e{};
e.merc_subtype_id = static_cast<uint32_t>(strtoul(row[0], nullptr, 10));
e.class_id = static_cast<uint32_t>(strtoul(row[1], nullptr, 10));
e.tier_id = static_cast<uint8_t>(strtoul(row[2], nullptr, 10));
e.confidence_id = static_cast<uint8_t>(strtoul(row[3], nullptr, 10));
all_entries.push_back(e);
}
return all_entries;
}
static std::vector<MercSubtypes> GetWhere(Database& db, const std::string &where_filter)
{
std::vector<MercSubtypes> all_entries;
auto results = db.QueryDatabase(
fmt::format(
"{} WHERE {}",
BaseSelect(),
where_filter
)
);
all_entries.reserve(results.RowCount());
for (auto row = results.begin(); row != results.end(); ++row) {
MercSubtypes e{};
e.merc_subtype_id = static_cast<uint32_t>(strtoul(row[0], nullptr, 10));
e.class_id = static_cast<uint32_t>(strtoul(row[1], nullptr, 10));
e.tier_id = static_cast<uint8_t>(strtoul(row[2], nullptr, 10));
e.confidence_id = static_cast<uint8_t>(strtoul(row[3], nullptr, 10));
all_entries.push_back(e);
}
return all_entries;
}
static int DeleteWhere(Database& db, const std::string &where_filter)
{
auto results = db.QueryDatabase(
fmt::format(
"DELETE FROM {} WHERE {}",
TableName(),
where_filter
)
);
return (results.Success() ? results.RowsAffected() : 0);
}
static int Truncate(Database& db)
{
auto results = db.QueryDatabase(
fmt::format(
"TRUNCATE TABLE {}",
TableName()
)
);
return (results.Success() ? results.RowsAffected() : 0);
}
static int64 GetMaxId(Database& db)
{
auto results = db.QueryDatabase(
fmt::format(
"SELECT COALESCE(MAX({}), 0) FROM {}",
PrimaryKey(),
TableName()
)
);
return (results.Success() && results.begin()[0] ? strtoll(results.begin()[0], nullptr, 10) : 0);
}
static int64 Count(Database& db, const std::string &where_filter = "")
{
auto results = db.QueryDatabase(
fmt::format(
"SELECT COUNT(*) FROM {} {}",
TableName(),
(where_filter.empty() ? "" : "WHERE " + where_filter)
)
);
return (results.Success() && results.begin()[0] ? strtoll(results.begin()[0], nullptr, 10) : 0);
}
};
#endif //EQEMU_BASE_MERC_SUBTYPES_REPOSITORY_H
@@ -0,0 +1,384 @@
/**
* DO NOT MODIFY THIS FILE
*
* This repository was automatically generated and is NOT to be modified directly.
* Any repository modifications are meant to be made to the repository extending the base.
* Any modifications to base repositories are to be made by the generator only
*
* @generator ./utils/scripts/generators/repository-generator.pl
* @docs https://eqemu.gitbook.io/server/in-development/developer-area/repositories
*/
#ifndef EQEMU_BASE_MERC_TEMPLATES_REPOSITORY_H
#define EQEMU_BASE_MERC_TEMPLATES_REPOSITORY_H
#include "../../database.h"
#include "../../strings.h"
#include <ctime>
class BaseMercTemplatesRepository {
public:
struct MercTemplates {
uint32_t merc_template_id;
uint32_t merc_type_id;
uint32_t merc_subtype_id;
uint32_t merc_npc_type_id;
std::string dbstring;
int8_t name_type_id;
uint32_t clientversion;
};
static std::string PrimaryKey()
{
return std::string("merc_template_id");
}
static std::vector<std::string> Columns()
{
return {
"merc_template_id",
"merc_type_id",
"merc_subtype_id",
"merc_npc_type_id",
"dbstring",
"name_type_id",
"clientversion",
};
}
static std::vector<std::string> SelectColumns()
{
return {
"merc_template_id",
"merc_type_id",
"merc_subtype_id",
"merc_npc_type_id",
"dbstring",
"name_type_id",
"clientversion",
};
}
static std::string ColumnsRaw()
{
return std::string(Strings::Implode(", ", Columns()));
}
static std::string SelectColumnsRaw()
{
return std::string(Strings::Implode(", ", SelectColumns()));
}
static std::string TableName()
{
return std::string("merc_templates");
}
static std::string BaseSelect()
{
return fmt::format(
"SELECT {} FROM {}",
SelectColumnsRaw(),
TableName()
);
}
static std::string BaseInsert()
{
return fmt::format(
"INSERT INTO {} ({}) ",
TableName(),
ColumnsRaw()
);
}
static MercTemplates NewEntity()
{
MercTemplates e{};
e.merc_template_id = 0;
e.merc_type_id = 0;
e.merc_subtype_id = 0;
e.merc_npc_type_id = 0;
e.dbstring = "";
e.name_type_id = 0;
e.clientversion = 0;
return e;
}
static MercTemplates GetMercTemplates(
const std::vector<MercTemplates> &merc_templatess,
int merc_templates_id
)
{
for (auto &merc_templates : merc_templatess) {
if (merc_templates.merc_template_id == merc_templates_id) {
return merc_templates;
}
}
return NewEntity();
}
static MercTemplates FindOne(
Database& db,
int merc_templates_id
)
{
auto results = db.QueryDatabase(
fmt::format(
"{} WHERE {} = {} LIMIT 1",
BaseSelect(),
PrimaryKey(),
merc_templates_id
)
);
auto row = results.begin();
if (results.RowCount() == 1) {
MercTemplates e{};
e.merc_template_id = static_cast<uint32_t>(strtoul(row[0], nullptr, 10));
e.merc_type_id = static_cast<uint32_t>(strtoul(row[1], nullptr, 10));
e.merc_subtype_id = static_cast<uint32_t>(strtoul(row[2], nullptr, 10));
e.merc_npc_type_id = static_cast<uint32_t>(strtoul(row[3], nullptr, 10));
e.dbstring = row[4] ? row[4] : "";
e.name_type_id = static_cast<int8_t>(atoi(row[5]));
e.clientversion = static_cast<uint32_t>(strtoul(row[6], nullptr, 10));
return e;
}
return NewEntity();
}
static int DeleteOne(
Database& db,
int merc_templates_id
)
{
auto results = db.QueryDatabase(
fmt::format(
"DELETE FROM {} WHERE {} = {}",
TableName(),
PrimaryKey(),
merc_templates_id
)
);
return (results.Success() ? results.RowsAffected() : 0);
}
static int UpdateOne(
Database& db,
const MercTemplates &e
)
{
std::vector<std::string> v;
auto columns = Columns();
v.push_back(columns[1] + " = " + std::to_string(e.merc_type_id));
v.push_back(columns[2] + " = " + std::to_string(e.merc_subtype_id));
v.push_back(columns[3] + " = " + std::to_string(e.merc_npc_type_id));
v.push_back(columns[4] + " = '" + Strings::Escape(e.dbstring) + "'");
v.push_back(columns[5] + " = " + std::to_string(e.name_type_id));
v.push_back(columns[6] + " = " + std::to_string(e.clientversion));
auto results = db.QueryDatabase(
fmt::format(
"UPDATE {} SET {} WHERE {} = {}",
TableName(),
Strings::Implode(", ", v),
PrimaryKey(),
e.merc_template_id
)
);
return (results.Success() ? results.RowsAffected() : 0);
}
static MercTemplates InsertOne(
Database& db,
MercTemplates e
)
{
std::vector<std::string> v;
v.push_back(std::to_string(e.merc_template_id));
v.push_back(std::to_string(e.merc_type_id));
v.push_back(std::to_string(e.merc_subtype_id));
v.push_back(std::to_string(e.merc_npc_type_id));
v.push_back("'" + Strings::Escape(e.dbstring) + "'");
v.push_back(std::to_string(e.name_type_id));
v.push_back(std::to_string(e.clientversion));
auto results = db.QueryDatabase(
fmt::format(
"{} VALUES ({})",
BaseInsert(),
Strings::Implode(",", v)
)
);
if (results.Success()) {
e.merc_template_id = results.LastInsertedID();
return e;
}
e = NewEntity();
return e;
}
static int InsertMany(
Database& db,
const std::vector<MercTemplates> &entries
)
{
std::vector<std::string> insert_chunks;
for (auto &e: entries) {
std::vector<std::string> v;
v.push_back(std::to_string(e.merc_template_id));
v.push_back(std::to_string(e.merc_type_id));
v.push_back(std::to_string(e.merc_subtype_id));
v.push_back(std::to_string(e.merc_npc_type_id));
v.push_back("'" + Strings::Escape(e.dbstring) + "'");
v.push_back(std::to_string(e.name_type_id));
v.push_back(std::to_string(e.clientversion));
insert_chunks.push_back("(" + Strings::Implode(",", v) + ")");
}
std::vector<std::string> v;
auto results = db.QueryDatabase(
fmt::format(
"{} VALUES {}",
BaseInsert(),
Strings::Implode(",", insert_chunks)
)
);
return (results.Success() ? results.RowsAffected() : 0);
}
static std::vector<MercTemplates> All(Database& db)
{
std::vector<MercTemplates> all_entries;
auto results = db.QueryDatabase(
fmt::format(
"{}",
BaseSelect()
)
);
all_entries.reserve(results.RowCount());
for (auto row = results.begin(); row != results.end(); ++row) {
MercTemplates e{};
e.merc_template_id = static_cast<uint32_t>(strtoul(row[0], nullptr, 10));
e.merc_type_id = static_cast<uint32_t>(strtoul(row[1], nullptr, 10));
e.merc_subtype_id = static_cast<uint32_t>(strtoul(row[2], nullptr, 10));
e.merc_npc_type_id = static_cast<uint32_t>(strtoul(row[3], nullptr, 10));
e.dbstring = row[4] ? row[4] : "";
e.name_type_id = static_cast<int8_t>(atoi(row[5]));
e.clientversion = static_cast<uint32_t>(strtoul(row[6], nullptr, 10));
all_entries.push_back(e);
}
return all_entries;
}
static std::vector<MercTemplates> GetWhere(Database& db, const std::string &where_filter)
{
std::vector<MercTemplates> all_entries;
auto results = db.QueryDatabase(
fmt::format(
"{} WHERE {}",
BaseSelect(),
where_filter
)
);
all_entries.reserve(results.RowCount());
for (auto row = results.begin(); row != results.end(); ++row) {
MercTemplates e{};
e.merc_template_id = static_cast<uint32_t>(strtoul(row[0], nullptr, 10));
e.merc_type_id = static_cast<uint32_t>(strtoul(row[1], nullptr, 10));
e.merc_subtype_id = static_cast<uint32_t>(strtoul(row[2], nullptr, 10));
e.merc_npc_type_id = static_cast<uint32_t>(strtoul(row[3], nullptr, 10));
e.dbstring = row[4] ? row[4] : "";
e.name_type_id = static_cast<int8_t>(atoi(row[5]));
e.clientversion = static_cast<uint32_t>(strtoul(row[6], nullptr, 10));
all_entries.push_back(e);
}
return all_entries;
}
static int DeleteWhere(Database& db, const std::string &where_filter)
{
auto results = db.QueryDatabase(
fmt::format(
"DELETE FROM {} WHERE {}",
TableName(),
where_filter
)
);
return (results.Success() ? results.RowsAffected() : 0);
}
static int Truncate(Database& db)
{
auto results = db.QueryDatabase(
fmt::format(
"TRUNCATE TABLE {}",
TableName()
)
);
return (results.Success() ? results.RowsAffected() : 0);
}
static int64 GetMaxId(Database& db)
{
auto results = db.QueryDatabase(
fmt::format(
"SELECT COALESCE(MAX({}), 0) FROM {}",
PrimaryKey(),
TableName()
)
);
return (results.Success() && results.begin()[0] ? strtoll(results.begin()[0], nullptr, 10) : 0);
}
static int64 Count(Database& db, const std::string &where_filter = "")
{
auto results = db.QueryDatabase(
fmt::format(
"SELECT COUNT(*) FROM {} {}",
TableName(),
(where_filter.empty() ? "" : "WHERE " + where_filter)
)
);
return (results.Success() && results.begin()[0] ? strtoll(results.begin()[0], nullptr, 10) : 0);
}
};
#endif //EQEMU_BASE_MERC_TEMPLATES_REPOSITORY_H
@@ -0,0 +1,364 @@
/**
* DO NOT MODIFY THIS FILE
*
* This repository was automatically generated and is NOT to be modified directly.
* Any repository modifications are meant to be made to the repository extending the base.
* Any modifications to base repositories are to be made by the generator only
*
* @generator ./utils/scripts/generators/repository-generator.pl
* @docs https://eqemu.gitbook.io/server/in-development/developer-area/repositories
*/
#ifndef EQEMU_BASE_MERC_TYPES_REPOSITORY_H
#define EQEMU_BASE_MERC_TYPES_REPOSITORY_H
#include "../../database.h"
#include "../../strings.h"
#include <ctime>
class BaseMercTypesRepository {
public:
struct MercTypes {
uint32_t merc_type_id;
uint32_t race_id;
uint8_t proficiency_id;
std::string dbstring;
uint32_t clientversion;
};
static std::string PrimaryKey()
{
return std::string("merc_type_id");
}
static std::vector<std::string> Columns()
{
return {
"merc_type_id",
"race_id",
"proficiency_id",
"dbstring",
"clientversion",
};
}
static std::vector<std::string> SelectColumns()
{
return {
"merc_type_id",
"race_id",
"proficiency_id",
"dbstring",
"clientversion",
};
}
static std::string ColumnsRaw()
{
return std::string(Strings::Implode(", ", Columns()));
}
static std::string SelectColumnsRaw()
{
return std::string(Strings::Implode(", ", SelectColumns()));
}
static std::string TableName()
{
return std::string("merc_types");
}
static std::string BaseSelect()
{
return fmt::format(
"SELECT {} FROM {}",
SelectColumnsRaw(),
TableName()
);
}
static std::string BaseInsert()
{
return fmt::format(
"INSERT INTO {} ({}) ",
TableName(),
ColumnsRaw()
);
}
static MercTypes NewEntity()
{
MercTypes e{};
e.merc_type_id = 0;
e.race_id = 0;
e.proficiency_id = 0;
e.dbstring = "";
e.clientversion = 0;
return e;
}
static MercTypes GetMercTypes(
const std::vector<MercTypes> &merc_typess,
int merc_types_id
)
{
for (auto &merc_types : merc_typess) {
if (merc_types.merc_type_id == merc_types_id) {
return merc_types;
}
}
return NewEntity();
}
static MercTypes FindOne(
Database& db,
int merc_types_id
)
{
auto results = db.QueryDatabase(
fmt::format(
"{} WHERE {} = {} LIMIT 1",
BaseSelect(),
PrimaryKey(),
merc_types_id
)
);
auto row = results.begin();
if (results.RowCount() == 1) {
MercTypes e{};
e.merc_type_id = static_cast<uint32_t>(strtoul(row[0], nullptr, 10));
e.race_id = static_cast<uint32_t>(strtoul(row[1], nullptr, 10));
e.proficiency_id = static_cast<uint8_t>(strtoul(row[2], nullptr, 10));
e.dbstring = row[3] ? row[3] : "";
e.clientversion = static_cast<uint32_t>(strtoul(row[4], nullptr, 10));
return e;
}
return NewEntity();
}
static int DeleteOne(
Database& db,
int merc_types_id
)
{
auto results = db.QueryDatabase(
fmt::format(
"DELETE FROM {} WHERE {} = {}",
TableName(),
PrimaryKey(),
merc_types_id
)
);
return (results.Success() ? results.RowsAffected() : 0);
}
static int UpdateOne(
Database& db,
const MercTypes &e
)
{
std::vector<std::string> v;
auto columns = Columns();
v.push_back(columns[1] + " = " + std::to_string(e.race_id));
v.push_back(columns[2] + " = " + std::to_string(e.proficiency_id));
v.push_back(columns[3] + " = '" + Strings::Escape(e.dbstring) + "'");
v.push_back(columns[4] + " = " + std::to_string(e.clientversion));
auto results = db.QueryDatabase(
fmt::format(
"UPDATE {} SET {} WHERE {} = {}",
TableName(),
Strings::Implode(", ", v),
PrimaryKey(),
e.merc_type_id
)
);
return (results.Success() ? results.RowsAffected() : 0);
}
static MercTypes InsertOne(
Database& db,
MercTypes e
)
{
std::vector<std::string> v;
v.push_back(std::to_string(e.merc_type_id));
v.push_back(std::to_string(e.race_id));
v.push_back(std::to_string(e.proficiency_id));
v.push_back("'" + Strings::Escape(e.dbstring) + "'");
v.push_back(std::to_string(e.clientversion));
auto results = db.QueryDatabase(
fmt::format(
"{} VALUES ({})",
BaseInsert(),
Strings::Implode(",", v)
)
);
if (results.Success()) {
e.merc_type_id = results.LastInsertedID();
return e;
}
e = NewEntity();
return e;
}
static int InsertMany(
Database& db,
const std::vector<MercTypes> &entries
)
{
std::vector<std::string> insert_chunks;
for (auto &e: entries) {
std::vector<std::string> v;
v.push_back(std::to_string(e.merc_type_id));
v.push_back(std::to_string(e.race_id));
v.push_back(std::to_string(e.proficiency_id));
v.push_back("'" + Strings::Escape(e.dbstring) + "'");
v.push_back(std::to_string(e.clientversion));
insert_chunks.push_back("(" + Strings::Implode(",", v) + ")");
}
std::vector<std::string> v;
auto results = db.QueryDatabase(
fmt::format(
"{} VALUES {}",
BaseInsert(),
Strings::Implode(",", insert_chunks)
)
);
return (results.Success() ? results.RowsAffected() : 0);
}
static std::vector<MercTypes> All(Database& db)
{
std::vector<MercTypes> all_entries;
auto results = db.QueryDatabase(
fmt::format(
"{}",
BaseSelect()
)
);
all_entries.reserve(results.RowCount());
for (auto row = results.begin(); row != results.end(); ++row) {
MercTypes e{};
e.merc_type_id = static_cast<uint32_t>(strtoul(row[0], nullptr, 10));
e.race_id = static_cast<uint32_t>(strtoul(row[1], nullptr, 10));
e.proficiency_id = static_cast<uint8_t>(strtoul(row[2], nullptr, 10));
e.dbstring = row[3] ? row[3] : "";
e.clientversion = static_cast<uint32_t>(strtoul(row[4], nullptr, 10));
all_entries.push_back(e);
}
return all_entries;
}
static std::vector<MercTypes> GetWhere(Database& db, const std::string &where_filter)
{
std::vector<MercTypes> all_entries;
auto results = db.QueryDatabase(
fmt::format(
"{} WHERE {}",
BaseSelect(),
where_filter
)
);
all_entries.reserve(results.RowCount());
for (auto row = results.begin(); row != results.end(); ++row) {
MercTypes e{};
e.merc_type_id = static_cast<uint32_t>(strtoul(row[0], nullptr, 10));
e.race_id = static_cast<uint32_t>(strtoul(row[1], nullptr, 10));
e.proficiency_id = static_cast<uint8_t>(strtoul(row[2], nullptr, 10));
e.dbstring = row[3] ? row[3] : "";
e.clientversion = static_cast<uint32_t>(strtoul(row[4], nullptr, 10));
all_entries.push_back(e);
}
return all_entries;
}
static int DeleteWhere(Database& db, const std::string &where_filter)
{
auto results = db.QueryDatabase(
fmt::format(
"DELETE FROM {} WHERE {}",
TableName(),
where_filter
)
);
return (results.Success() ? results.RowsAffected() : 0);
}
static int Truncate(Database& db)
{
auto results = db.QueryDatabase(
fmt::format(
"TRUNCATE TABLE {}",
TableName()
)
);
return (results.Success() ? results.RowsAffected() : 0);
}
static int64 GetMaxId(Database& db)
{
auto results = db.QueryDatabase(
fmt::format(
"SELECT COALESCE(MAX({}), 0) FROM {}",
PrimaryKey(),
TableName()
)
);
return (results.Success() && results.begin()[0] ? strtoll(results.begin()[0], nullptr, 10) : 0);
}
static int64 Count(Database& db, const std::string &where_filter = "")
{
auto results = db.QueryDatabase(
fmt::format(
"SELECT COUNT(*) FROM {} {}",
TableName(),
(where_filter.empty() ? "" : "WHERE " + where_filter)
)
);
return (results.Success() && results.begin()[0] ? strtoll(results.begin()[0], nullptr, 10) : 0);
}
};
#endif //EQEMU_BASE_MERC_TYPES_REPOSITORY_H
@@ -0,0 +1,394 @@
/**
* DO NOT MODIFY THIS FILE
*
* This repository was automatically generated and is NOT to be modified directly.
* Any repository modifications are meant to be made to the repository extending the base.
* Any modifications to base repositories are to be made by the generator only
*
* @generator ./utils/scripts/generators/repository-generator.pl
* @docs https://eqemu.gitbook.io/server/in-development/developer-area/repositories
*/
#ifndef EQEMU_BASE_MERC_WEAPONINFO_REPOSITORY_H
#define EQEMU_BASE_MERC_WEAPONINFO_REPOSITORY_H
#include "../../database.h"
#include "../../strings.h"
#include <ctime>
class BaseMercWeaponinfoRepository {
public:
struct MercWeaponinfo {
int32_t id;
int32_t merc_npc_type_id;
uint8_t minlevel;
uint8_t maxlevel;
int32_t d_melee_texture1;
int32_t d_melee_texture2;
uint8_t prim_melee_type;
uint8_t sec_melee_type;
};
static std::string PrimaryKey()
{
return std::string("id");
}
static std::vector<std::string> Columns()
{
return {
"id",
"merc_npc_type_id",
"minlevel",
"maxlevel",
"d_melee_texture1",
"d_melee_texture2",
"prim_melee_type",
"sec_melee_type",
};
}
static std::vector<std::string> SelectColumns()
{
return {
"id",
"merc_npc_type_id",
"minlevel",
"maxlevel",
"d_melee_texture1",
"d_melee_texture2",
"prim_melee_type",
"sec_melee_type",
};
}
static std::string ColumnsRaw()
{
return std::string(Strings::Implode(", ", Columns()));
}
static std::string SelectColumnsRaw()
{
return std::string(Strings::Implode(", ", SelectColumns()));
}
static std::string TableName()
{
return std::string("merc_weaponinfo");
}
static std::string BaseSelect()
{
return fmt::format(
"SELECT {} FROM {}",
SelectColumnsRaw(),
TableName()
);
}
static std::string BaseInsert()
{
return fmt::format(
"INSERT INTO {} ({}) ",
TableName(),
ColumnsRaw()
);
}
static MercWeaponinfo NewEntity()
{
MercWeaponinfo e{};
e.id = 0;
e.merc_npc_type_id = 0;
e.minlevel = 0;
e.maxlevel = 0;
e.d_melee_texture1 = 0;
e.d_melee_texture2 = 0;
e.prim_melee_type = 28;
e.sec_melee_type = 28;
return e;
}
static MercWeaponinfo GetMercWeaponinfo(
const std::vector<MercWeaponinfo> &merc_weaponinfos,
int merc_weaponinfo_id
)
{
for (auto &merc_weaponinfo : merc_weaponinfos) {
if (merc_weaponinfo.id == merc_weaponinfo_id) {
return merc_weaponinfo;
}
}
return NewEntity();
}
static MercWeaponinfo FindOne(
Database& db,
int merc_weaponinfo_id
)
{
auto results = db.QueryDatabase(
fmt::format(
"{} WHERE {} = {} LIMIT 1",
BaseSelect(),
PrimaryKey(),
merc_weaponinfo_id
)
);
auto row = results.begin();
if (results.RowCount() == 1) {
MercWeaponinfo e{};
e.id = static_cast<int32_t>(atoi(row[0]));
e.merc_npc_type_id = static_cast<int32_t>(atoi(row[1]));
e.minlevel = static_cast<uint8_t>(strtoul(row[2], nullptr, 10));
e.maxlevel = static_cast<uint8_t>(strtoul(row[3], nullptr, 10));
e.d_melee_texture1 = static_cast<int32_t>(atoi(row[4]));
e.d_melee_texture2 = static_cast<int32_t>(atoi(row[5]));
e.prim_melee_type = static_cast<uint8_t>(strtoul(row[6], nullptr, 10));
e.sec_melee_type = static_cast<uint8_t>(strtoul(row[7], nullptr, 10));
return e;
}
return NewEntity();
}
static int DeleteOne(
Database& db,
int merc_weaponinfo_id
)
{
auto results = db.QueryDatabase(
fmt::format(
"DELETE FROM {} WHERE {} = {}",
TableName(),
PrimaryKey(),
merc_weaponinfo_id
)
);
return (results.Success() ? results.RowsAffected() : 0);
}
static int UpdateOne(
Database& db,
const MercWeaponinfo &e
)
{
std::vector<std::string> v;
auto columns = Columns();
v.push_back(columns[1] + " = " + std::to_string(e.merc_npc_type_id));
v.push_back(columns[2] + " = " + std::to_string(e.minlevel));
v.push_back(columns[3] + " = " + std::to_string(e.maxlevel));
v.push_back(columns[4] + " = " + std::to_string(e.d_melee_texture1));
v.push_back(columns[5] + " = " + std::to_string(e.d_melee_texture2));
v.push_back(columns[6] + " = " + std::to_string(e.prim_melee_type));
v.push_back(columns[7] + " = " + std::to_string(e.sec_melee_type));
auto results = db.QueryDatabase(
fmt::format(
"UPDATE {} SET {} WHERE {} = {}",
TableName(),
Strings::Implode(", ", v),
PrimaryKey(),
e.id
)
);
return (results.Success() ? results.RowsAffected() : 0);
}
static MercWeaponinfo InsertOne(
Database& db,
MercWeaponinfo e
)
{
std::vector<std::string> v;
v.push_back(std::to_string(e.id));
v.push_back(std::to_string(e.merc_npc_type_id));
v.push_back(std::to_string(e.minlevel));
v.push_back(std::to_string(e.maxlevel));
v.push_back(std::to_string(e.d_melee_texture1));
v.push_back(std::to_string(e.d_melee_texture2));
v.push_back(std::to_string(e.prim_melee_type));
v.push_back(std::to_string(e.sec_melee_type));
auto results = db.QueryDatabase(
fmt::format(
"{} VALUES ({})",
BaseInsert(),
Strings::Implode(",", v)
)
);
if (results.Success()) {
e.id = results.LastInsertedID();
return e;
}
e = NewEntity();
return e;
}
static int InsertMany(
Database& db,
const std::vector<MercWeaponinfo> &entries
)
{
std::vector<std::string> insert_chunks;
for (auto &e: entries) {
std::vector<std::string> v;
v.push_back(std::to_string(e.id));
v.push_back(std::to_string(e.merc_npc_type_id));
v.push_back(std::to_string(e.minlevel));
v.push_back(std::to_string(e.maxlevel));
v.push_back(std::to_string(e.d_melee_texture1));
v.push_back(std::to_string(e.d_melee_texture2));
v.push_back(std::to_string(e.prim_melee_type));
v.push_back(std::to_string(e.sec_melee_type));
insert_chunks.push_back("(" + Strings::Implode(",", v) + ")");
}
std::vector<std::string> v;
auto results = db.QueryDatabase(
fmt::format(
"{} VALUES {}",
BaseInsert(),
Strings::Implode(",", insert_chunks)
)
);
return (results.Success() ? results.RowsAffected() : 0);
}
static std::vector<MercWeaponinfo> All(Database& db)
{
std::vector<MercWeaponinfo> all_entries;
auto results = db.QueryDatabase(
fmt::format(
"{}",
BaseSelect()
)
);
all_entries.reserve(results.RowCount());
for (auto row = results.begin(); row != results.end(); ++row) {
MercWeaponinfo e{};
e.id = static_cast<int32_t>(atoi(row[0]));
e.merc_npc_type_id = static_cast<int32_t>(atoi(row[1]));
e.minlevel = static_cast<uint8_t>(strtoul(row[2], nullptr, 10));
e.maxlevel = static_cast<uint8_t>(strtoul(row[3], nullptr, 10));
e.d_melee_texture1 = static_cast<int32_t>(atoi(row[4]));
e.d_melee_texture2 = static_cast<int32_t>(atoi(row[5]));
e.prim_melee_type = static_cast<uint8_t>(strtoul(row[6], nullptr, 10));
e.sec_melee_type = static_cast<uint8_t>(strtoul(row[7], nullptr, 10));
all_entries.push_back(e);
}
return all_entries;
}
static std::vector<MercWeaponinfo> GetWhere(Database& db, const std::string &where_filter)
{
std::vector<MercWeaponinfo> all_entries;
auto results = db.QueryDatabase(
fmt::format(
"{} WHERE {}",
BaseSelect(),
where_filter
)
);
all_entries.reserve(results.RowCount());
for (auto row = results.begin(); row != results.end(); ++row) {
MercWeaponinfo e{};
e.id = static_cast<int32_t>(atoi(row[0]));
e.merc_npc_type_id = static_cast<int32_t>(atoi(row[1]));
e.minlevel = static_cast<uint8_t>(strtoul(row[2], nullptr, 10));
e.maxlevel = static_cast<uint8_t>(strtoul(row[3], nullptr, 10));
e.d_melee_texture1 = static_cast<int32_t>(atoi(row[4]));
e.d_melee_texture2 = static_cast<int32_t>(atoi(row[5]));
e.prim_melee_type = static_cast<uint8_t>(strtoul(row[6], nullptr, 10));
e.sec_melee_type = static_cast<uint8_t>(strtoul(row[7], nullptr, 10));
all_entries.push_back(e);
}
return all_entries;
}
static int DeleteWhere(Database& db, const std::string &where_filter)
{
auto results = db.QueryDatabase(
fmt::format(
"DELETE FROM {} WHERE {}",
TableName(),
where_filter
)
);
return (results.Success() ? results.RowsAffected() : 0);
}
static int Truncate(Database& db)
{
auto results = db.QueryDatabase(
fmt::format(
"TRUNCATE TABLE {}",
TableName()
)
);
return (results.Success() ? results.RowsAffected() : 0);
}
static int64 GetMaxId(Database& db)
{
auto results = db.QueryDatabase(
fmt::format(
"SELECT COALESCE(MAX({}), 0) FROM {}",
PrimaryKey(),
TableName()
)
);
return (results.Success() && results.begin()[0] ? strtoll(results.begin()[0], nullptr, 10) : 0);
}
static int64 Count(Database& db, const std::string &where_filter = "")
{
auto results = db.QueryDatabase(
fmt::format(
"SELECT COUNT(*) FROM {} {}",
TableName(),
(where_filter.empty() ? "" : "WHERE " + where_filter)
)
);
return (results.Success() && results.begin()[0] ? strtoll(results.begin()[0], nullptr, 10) : 0);
}
};
#endif //EQEMU_BASE_MERC_WEAPONINFO_REPOSITORY_H
@@ -0,0 +1,554 @@
/**
* DO NOT MODIFY THIS FILE
*
* This repository was automatically generated and is NOT to be modified directly.
* Any repository modifications are meant to be made to the repository extending the base.
* Any modifications to base repositories are to be made by the generator only
*
* @generator ./utils/scripts/generators/repository-generator.pl
* @docs https://eqemu.gitbook.io/server/in-development/developer-area/repositories
*/
#ifndef EQEMU_BASE_MERCS_REPOSITORY_H
#define EQEMU_BASE_MERCS_REPOSITORY_H
#include "../../database.h"
#include "../../strings.h"
#include <ctime>
class BaseMercsRepository {
public:
struct Mercs {
uint32_t MercID;
uint32_t OwnerCharacterID;
uint8_t Slot;
std::string Name;
uint32_t TemplateID;
uint32_t SuspendedTime;
uint8_t IsSuspended;
uint32_t TimerRemaining;
uint8_t Gender;
float MercSize;
uint8_t StanceID;
uint32_t HP;
uint32_t Mana;
uint32_t Endurance;
uint32_t Face;
uint32_t LuclinHairStyle;
uint32_t LuclinHairColor;
uint32_t LuclinEyeColor;
uint32_t LuclinEyeColor2;
uint32_t LuclinBeardColor;
uint32_t LuclinBeard;
uint32_t DrakkinHeritage;
uint32_t DrakkinTattoo;
uint32_t DrakkinDetails;
};
static std::string PrimaryKey()
{
return std::string("MercID");
}
static std::vector<std::string> Columns()
{
return {
"MercID",
"OwnerCharacterID",
"Slot",
"Name",
"TemplateID",
"SuspendedTime",
"IsSuspended",
"TimerRemaining",
"Gender",
"MercSize",
"StanceID",
"HP",
"Mana",
"Endurance",
"Face",
"LuclinHairStyle",
"LuclinHairColor",
"LuclinEyeColor",
"LuclinEyeColor2",
"LuclinBeardColor",
"LuclinBeard",
"DrakkinHeritage",
"DrakkinTattoo",
"DrakkinDetails",
};
}
static std::vector<std::string> SelectColumns()
{
return {
"MercID",
"OwnerCharacterID",
"Slot",
"Name",
"TemplateID",
"SuspendedTime",
"IsSuspended",
"TimerRemaining",
"Gender",
"MercSize",
"StanceID",
"HP",
"Mana",
"Endurance",
"Face",
"LuclinHairStyle",
"LuclinHairColor",
"LuclinEyeColor",
"LuclinEyeColor2",
"LuclinBeardColor",
"LuclinBeard",
"DrakkinHeritage",
"DrakkinTattoo",
"DrakkinDetails",
};
}
static std::string ColumnsRaw()
{
return std::string(Strings::Implode(", ", Columns()));
}
static std::string SelectColumnsRaw()
{
return std::string(Strings::Implode(", ", SelectColumns()));
}
static std::string TableName()
{
return std::string("mercs");
}
static std::string BaseSelect()
{
return fmt::format(
"SELECT {} FROM {}",
SelectColumnsRaw(),
TableName()
);
}
static std::string BaseInsert()
{
return fmt::format(
"INSERT INTO {} ({}) ",
TableName(),
ColumnsRaw()
);
}
static Mercs NewEntity()
{
Mercs e{};
e.MercID = 0;
e.OwnerCharacterID = 0;
e.Slot = 0;
e.Name = "";
e.TemplateID = 0;
e.SuspendedTime = 0;
e.IsSuspended = 0;
e.TimerRemaining = 0;
e.Gender = 0;
e.MercSize = 5;
e.StanceID = 0;
e.HP = 0;
e.Mana = 0;
e.Endurance = 0;
e.Face = 1;
e.LuclinHairStyle = 1;
e.LuclinHairColor = 1;
e.LuclinEyeColor = 1;
e.LuclinEyeColor2 = 1;
e.LuclinBeardColor = 1;
e.LuclinBeard = 0;
e.DrakkinHeritage = 0;
e.DrakkinTattoo = 0;
e.DrakkinDetails = 0;
return e;
}
static Mercs GetMercs(
const std::vector<Mercs> &mercss,
int mercs_id
)
{
for (auto &mercs : mercss) {
if (mercs.MercID == mercs_id) {
return mercs;
}
}
return NewEntity();
}
static Mercs FindOne(
Database& db,
int mercs_id
)
{
auto results = db.QueryDatabase(
fmt::format(
"{} WHERE {} = {} LIMIT 1",
BaseSelect(),
PrimaryKey(),
mercs_id
)
);
auto row = results.begin();
if (results.RowCount() == 1) {
Mercs e{};
e.MercID = static_cast<uint32_t>(strtoul(row[0], nullptr, 10));
e.OwnerCharacterID = static_cast<uint32_t>(strtoul(row[1], nullptr, 10));
e.Slot = static_cast<uint8_t>(strtoul(row[2], nullptr, 10));
e.Name = row[3] ? row[3] : "";
e.TemplateID = static_cast<uint32_t>(strtoul(row[4], nullptr, 10));
e.SuspendedTime = static_cast<uint32_t>(strtoul(row[5], nullptr, 10));
e.IsSuspended = static_cast<uint8_t>(strtoul(row[6], nullptr, 10));
e.TimerRemaining = static_cast<uint32_t>(strtoul(row[7], nullptr, 10));
e.Gender = static_cast<uint8_t>(strtoul(row[8], nullptr, 10));
e.MercSize = strtof(row[9], nullptr);
e.StanceID = static_cast<uint8_t>(strtoul(row[10], nullptr, 10));
e.HP = static_cast<uint32_t>(strtoul(row[11], nullptr, 10));
e.Mana = static_cast<uint32_t>(strtoul(row[12], nullptr, 10));
e.Endurance = static_cast<uint32_t>(strtoul(row[13], nullptr, 10));
e.Face = static_cast<uint32_t>(strtoul(row[14], nullptr, 10));
e.LuclinHairStyle = static_cast<uint32_t>(strtoul(row[15], nullptr, 10));
e.LuclinHairColor = static_cast<uint32_t>(strtoul(row[16], nullptr, 10));
e.LuclinEyeColor = static_cast<uint32_t>(strtoul(row[17], nullptr, 10));
e.LuclinEyeColor2 = static_cast<uint32_t>(strtoul(row[18], nullptr, 10));
e.LuclinBeardColor = static_cast<uint32_t>(strtoul(row[19], nullptr, 10));
e.LuclinBeard = static_cast<uint32_t>(strtoul(row[20], nullptr, 10));
e.DrakkinHeritage = static_cast<uint32_t>(strtoul(row[21], nullptr, 10));
e.DrakkinTattoo = static_cast<uint32_t>(strtoul(row[22], nullptr, 10));
e.DrakkinDetails = static_cast<uint32_t>(strtoul(row[23], nullptr, 10));
return e;
}
return NewEntity();
}
static int DeleteOne(
Database& db,
int mercs_id
)
{
auto results = db.QueryDatabase(
fmt::format(
"DELETE FROM {} WHERE {} = {}",
TableName(),
PrimaryKey(),
mercs_id
)
);
return (results.Success() ? results.RowsAffected() : 0);
}
static int UpdateOne(
Database& db,
const Mercs &e
)
{
std::vector<std::string> v;
auto columns = Columns();
v.push_back(columns[1] + " = " + std::to_string(e.OwnerCharacterID));
v.push_back(columns[2] + " = " + std::to_string(e.Slot));
v.push_back(columns[3] + " = '" + Strings::Escape(e.Name) + "'");
v.push_back(columns[4] + " = " + std::to_string(e.TemplateID));
v.push_back(columns[5] + " = " + std::to_string(e.SuspendedTime));
v.push_back(columns[6] + " = " + std::to_string(e.IsSuspended));
v.push_back(columns[7] + " = " + std::to_string(e.TimerRemaining));
v.push_back(columns[8] + " = " + std::to_string(e.Gender));
v.push_back(columns[9] + " = " + std::to_string(e.MercSize));
v.push_back(columns[10] + " = " + std::to_string(e.StanceID));
v.push_back(columns[11] + " = " + std::to_string(e.HP));
v.push_back(columns[12] + " = " + std::to_string(e.Mana));
v.push_back(columns[13] + " = " + std::to_string(e.Endurance));
v.push_back(columns[14] + " = " + std::to_string(e.Face));
v.push_back(columns[15] + " = " + std::to_string(e.LuclinHairStyle));
v.push_back(columns[16] + " = " + std::to_string(e.LuclinHairColor));
v.push_back(columns[17] + " = " + std::to_string(e.LuclinEyeColor));
v.push_back(columns[18] + " = " + std::to_string(e.LuclinEyeColor2));
v.push_back(columns[19] + " = " + std::to_string(e.LuclinBeardColor));
v.push_back(columns[20] + " = " + std::to_string(e.LuclinBeard));
v.push_back(columns[21] + " = " + std::to_string(e.DrakkinHeritage));
v.push_back(columns[22] + " = " + std::to_string(e.DrakkinTattoo));
v.push_back(columns[23] + " = " + std::to_string(e.DrakkinDetails));
auto results = db.QueryDatabase(
fmt::format(
"UPDATE {} SET {} WHERE {} = {}",
TableName(),
Strings::Implode(", ", v),
PrimaryKey(),
e.MercID
)
);
return (results.Success() ? results.RowsAffected() : 0);
}
static Mercs InsertOne(
Database& db,
Mercs e
)
{
std::vector<std::string> v;
v.push_back(std::to_string(e.MercID));
v.push_back(std::to_string(e.OwnerCharacterID));
v.push_back(std::to_string(e.Slot));
v.push_back("'" + Strings::Escape(e.Name) + "'");
v.push_back(std::to_string(e.TemplateID));
v.push_back(std::to_string(e.SuspendedTime));
v.push_back(std::to_string(e.IsSuspended));
v.push_back(std::to_string(e.TimerRemaining));
v.push_back(std::to_string(e.Gender));
v.push_back(std::to_string(e.MercSize));
v.push_back(std::to_string(e.StanceID));
v.push_back(std::to_string(e.HP));
v.push_back(std::to_string(e.Mana));
v.push_back(std::to_string(e.Endurance));
v.push_back(std::to_string(e.Face));
v.push_back(std::to_string(e.LuclinHairStyle));
v.push_back(std::to_string(e.LuclinHairColor));
v.push_back(std::to_string(e.LuclinEyeColor));
v.push_back(std::to_string(e.LuclinEyeColor2));
v.push_back(std::to_string(e.LuclinBeardColor));
v.push_back(std::to_string(e.LuclinBeard));
v.push_back(std::to_string(e.DrakkinHeritage));
v.push_back(std::to_string(e.DrakkinTattoo));
v.push_back(std::to_string(e.DrakkinDetails));
auto results = db.QueryDatabase(
fmt::format(
"{} VALUES ({})",
BaseInsert(),
Strings::Implode(",", v)
)
);
if (results.Success()) {
e.MercID = results.LastInsertedID();
return e;
}
e = NewEntity();
return e;
}
static int InsertMany(
Database& db,
const std::vector<Mercs> &entries
)
{
std::vector<std::string> insert_chunks;
for (auto &e: entries) {
std::vector<std::string> v;
v.push_back(std::to_string(e.MercID));
v.push_back(std::to_string(e.OwnerCharacterID));
v.push_back(std::to_string(e.Slot));
v.push_back("'" + Strings::Escape(e.Name) + "'");
v.push_back(std::to_string(e.TemplateID));
v.push_back(std::to_string(e.SuspendedTime));
v.push_back(std::to_string(e.IsSuspended));
v.push_back(std::to_string(e.TimerRemaining));
v.push_back(std::to_string(e.Gender));
v.push_back(std::to_string(e.MercSize));
v.push_back(std::to_string(e.StanceID));
v.push_back(std::to_string(e.HP));
v.push_back(std::to_string(e.Mana));
v.push_back(std::to_string(e.Endurance));
v.push_back(std::to_string(e.Face));
v.push_back(std::to_string(e.LuclinHairStyle));
v.push_back(std::to_string(e.LuclinHairColor));
v.push_back(std::to_string(e.LuclinEyeColor));
v.push_back(std::to_string(e.LuclinEyeColor2));
v.push_back(std::to_string(e.LuclinBeardColor));
v.push_back(std::to_string(e.LuclinBeard));
v.push_back(std::to_string(e.DrakkinHeritage));
v.push_back(std::to_string(e.DrakkinTattoo));
v.push_back(std::to_string(e.DrakkinDetails));
insert_chunks.push_back("(" + Strings::Implode(",", v) + ")");
}
std::vector<std::string> v;
auto results = db.QueryDatabase(
fmt::format(
"{} VALUES {}",
BaseInsert(),
Strings::Implode(",", insert_chunks)
)
);
return (results.Success() ? results.RowsAffected() : 0);
}
static std::vector<Mercs> All(Database& db)
{
std::vector<Mercs> all_entries;
auto results = db.QueryDatabase(
fmt::format(
"{}",
BaseSelect()
)
);
all_entries.reserve(results.RowCount());
for (auto row = results.begin(); row != results.end(); ++row) {
Mercs e{};
e.MercID = static_cast<uint32_t>(strtoul(row[0], nullptr, 10));
e.OwnerCharacterID = static_cast<uint32_t>(strtoul(row[1], nullptr, 10));
e.Slot = static_cast<uint8_t>(strtoul(row[2], nullptr, 10));
e.Name = row[3] ? row[3] : "";
e.TemplateID = static_cast<uint32_t>(strtoul(row[4], nullptr, 10));
e.SuspendedTime = static_cast<uint32_t>(strtoul(row[5], nullptr, 10));
e.IsSuspended = static_cast<uint8_t>(strtoul(row[6], nullptr, 10));
e.TimerRemaining = static_cast<uint32_t>(strtoul(row[7], nullptr, 10));
e.Gender = static_cast<uint8_t>(strtoul(row[8], nullptr, 10));
e.MercSize = strtof(row[9], nullptr);
e.StanceID = static_cast<uint8_t>(strtoul(row[10], nullptr, 10));
e.HP = static_cast<uint32_t>(strtoul(row[11], nullptr, 10));
e.Mana = static_cast<uint32_t>(strtoul(row[12], nullptr, 10));
e.Endurance = static_cast<uint32_t>(strtoul(row[13], nullptr, 10));
e.Face = static_cast<uint32_t>(strtoul(row[14], nullptr, 10));
e.LuclinHairStyle = static_cast<uint32_t>(strtoul(row[15], nullptr, 10));
e.LuclinHairColor = static_cast<uint32_t>(strtoul(row[16], nullptr, 10));
e.LuclinEyeColor = static_cast<uint32_t>(strtoul(row[17], nullptr, 10));
e.LuclinEyeColor2 = static_cast<uint32_t>(strtoul(row[18], nullptr, 10));
e.LuclinBeardColor = static_cast<uint32_t>(strtoul(row[19], nullptr, 10));
e.LuclinBeard = static_cast<uint32_t>(strtoul(row[20], nullptr, 10));
e.DrakkinHeritage = static_cast<uint32_t>(strtoul(row[21], nullptr, 10));
e.DrakkinTattoo = static_cast<uint32_t>(strtoul(row[22], nullptr, 10));
e.DrakkinDetails = static_cast<uint32_t>(strtoul(row[23], nullptr, 10));
all_entries.push_back(e);
}
return all_entries;
}
static std::vector<Mercs> GetWhere(Database& db, const std::string &where_filter)
{
std::vector<Mercs> all_entries;
auto results = db.QueryDatabase(
fmt::format(
"{} WHERE {}",
BaseSelect(),
where_filter
)
);
all_entries.reserve(results.RowCount());
for (auto row = results.begin(); row != results.end(); ++row) {
Mercs e{};
e.MercID = static_cast<uint32_t>(strtoul(row[0], nullptr, 10));
e.OwnerCharacterID = static_cast<uint32_t>(strtoul(row[1], nullptr, 10));
e.Slot = static_cast<uint8_t>(strtoul(row[2], nullptr, 10));
e.Name = row[3] ? row[3] : "";
e.TemplateID = static_cast<uint32_t>(strtoul(row[4], nullptr, 10));
e.SuspendedTime = static_cast<uint32_t>(strtoul(row[5], nullptr, 10));
e.IsSuspended = static_cast<uint8_t>(strtoul(row[6], nullptr, 10));
e.TimerRemaining = static_cast<uint32_t>(strtoul(row[7], nullptr, 10));
e.Gender = static_cast<uint8_t>(strtoul(row[8], nullptr, 10));
e.MercSize = strtof(row[9], nullptr);
e.StanceID = static_cast<uint8_t>(strtoul(row[10], nullptr, 10));
e.HP = static_cast<uint32_t>(strtoul(row[11], nullptr, 10));
e.Mana = static_cast<uint32_t>(strtoul(row[12], nullptr, 10));
e.Endurance = static_cast<uint32_t>(strtoul(row[13], nullptr, 10));
e.Face = static_cast<uint32_t>(strtoul(row[14], nullptr, 10));
e.LuclinHairStyle = static_cast<uint32_t>(strtoul(row[15], nullptr, 10));
e.LuclinHairColor = static_cast<uint32_t>(strtoul(row[16], nullptr, 10));
e.LuclinEyeColor = static_cast<uint32_t>(strtoul(row[17], nullptr, 10));
e.LuclinEyeColor2 = static_cast<uint32_t>(strtoul(row[18], nullptr, 10));
e.LuclinBeardColor = static_cast<uint32_t>(strtoul(row[19], nullptr, 10));
e.LuclinBeard = static_cast<uint32_t>(strtoul(row[20], nullptr, 10));
e.DrakkinHeritage = static_cast<uint32_t>(strtoul(row[21], nullptr, 10));
e.DrakkinTattoo = static_cast<uint32_t>(strtoul(row[22], nullptr, 10));
e.DrakkinDetails = static_cast<uint32_t>(strtoul(row[23], nullptr, 10));
all_entries.push_back(e);
}
return all_entries;
}
static int DeleteWhere(Database& db, const std::string &where_filter)
{
auto results = db.QueryDatabase(
fmt::format(
"DELETE FROM {} WHERE {}",
TableName(),
where_filter
)
);
return (results.Success() ? results.RowsAffected() : 0);
}
static int Truncate(Database& db)
{
auto results = db.QueryDatabase(
fmt::format(
"TRUNCATE TABLE {}",
TableName()
)
);
return (results.Success() ? results.RowsAffected() : 0);
}
static int64 GetMaxId(Database& db)
{
auto results = db.QueryDatabase(
fmt::format(
"SELECT COALESCE(MAX({}), 0) FROM {}",
PrimaryKey(),
TableName()
)
);
return (results.Success() && results.begin()[0] ? strtoll(results.begin()[0], nullptr, 10) : 0);
}
static int64 Count(Database& db, const std::string &where_filter = "")
{
auto results = db.QueryDatabase(
fmt::format(
"SELECT COUNT(*) FROM {} {}",
TableName(),
(where_filter.empty() ? "" : "WHERE " + where_filter)
)
);
return (results.Success() && results.begin()[0] ? strtoll(results.begin()[0], nullptr, 10) : 0);
}
};
#endif //EQEMU_BASE_MERCS_REPOSITORY_H
@@ -0,0 +1,50 @@
#ifndef EQEMU_CHATCHANNEL_RESERVED_NAMES_REPOSITORY_H
#define EQEMU_CHATCHANNEL_RESERVED_NAMES_REPOSITORY_H
#include "../database.h"
#include "../strings.h"
#include "base/base_chatchannel_reserved_names_repository.h"
class ChatchannelReservedNamesRepository: public BaseChatchannelReservedNamesRepository {
public:
/**
* This file was auto generated and can be modified and extended upon
*
* Base repository methods are automatically
* generated in the "base" version of this repository. The base repository
* is immutable and to be left untouched, while methods in this class
* are used as extension methods for more specific persistence-layer
* accessors or mutators.
*
* Base Methods (Subject to be expanded upon in time)
*
* Note: Not all tables are designed appropriately to fit functionality with all base methods
*
* InsertOne
* UpdateOne
* DeleteOne
* FindOne
* GetWhere(std::string where_filter)
* DeleteWhere(std::string where_filter)
* InsertMany
* All
*
* Example custom methods in a repository
*
* ChatchannelReservedNamesRepository::GetByZoneAndVersion(int zone_id, int zone_version)
* ChatchannelReservedNamesRepository::GetWhereNeverExpires()
* ChatchannelReservedNamesRepository::GetWhereXAndY()
* ChatchannelReservedNamesRepository::DeleteWhereXAndY()
*
* Most of the above could be covered by base methods, but if you as a developer
* find yourself re-using logic for other parts of the code, its best to just make a
* method that can be re-used easily elsewhere especially if it can use a base repository
* method and encapsulate filters there
*/
// Custom extended repository methods here
};
#endif //EQEMU_CHATCHANNEL_RESERVED_NAMES_REPOSITORY_H
@@ -0,0 +1,50 @@
#ifndef EQEMU_CHATCHANNELS_REPOSITORY_H
#define EQEMU_CHATCHANNELS_REPOSITORY_H
#include "../database.h"
#include "../strings.h"
#include "base/base_chatchannels_repository.h"
class ChatchannelsRepository: public BaseChatchannelsRepository {
public:
/**
* This file was auto generated and can be modified and extended upon
*
* Base repository methods are automatically
* generated in the "base" version of this repository. The base repository
* is immutable and to be left untouched, while methods in this class
* are used as extension methods for more specific persistence-layer
* accessors or mutators.
*
* Base Methods (Subject to be expanded upon in time)
*
* Note: Not all tables are designed appropriately to fit functionality with all base methods
*
* InsertOne
* UpdateOne
* DeleteOne
* FindOne
* GetWhere(std::string where_filter)
* DeleteWhere(std::string where_filter)
* InsertMany
* All
*
* Example custom methods in a repository
*
* ChatchannelsRepository::GetByZoneAndVersion(int zone_id, int zone_version)
* ChatchannelsRepository::GetWhereNeverExpires()
* ChatchannelsRepository::GetWhereXAndY()
* ChatchannelsRepository::DeleteWhereXAndY()
*
* Most of the above could be covered by base methods, but if you as a developer
* find yourself re-using logic for other parts of the code, its best to just make a
* method that can be re-used easily elsewhere especially if it can use a base repository
* method and encapsulate filters there
*/
// Custom extended repository methods here
};
#endif //EQEMU_CHATCHANNELS_REPOSITORY_H
@@ -0,0 +1,50 @@
#ifndef EQEMU_MERC_ARMORINFO_REPOSITORY_H
#define EQEMU_MERC_ARMORINFO_REPOSITORY_H
#include "../database.h"
#include "../strings.h"
#include "base/base_merc_armorinfo_repository.h"
class MercArmorinfoRepository: public BaseMercArmorinfoRepository {
public:
/**
* This file was auto generated and can be modified and extended upon
*
* Base repository methods are automatically
* generated in the "base" version of this repository. The base repository
* is immutable and to be left untouched, while methods in this class
* are used as extension methods for more specific persistence-layer
* accessors or mutators.
*
* Base Methods (Subject to be expanded upon in time)
*
* Note: Not all tables are designed appropriately to fit functionality with all base methods
*
* InsertOne
* UpdateOne
* DeleteOne
* FindOne
* GetWhere(std::string where_filter)
* DeleteWhere(std::string where_filter)
* InsertMany
* All
*
* Example custom methods in a repository
*
* MercArmorinfoRepository::GetByZoneAndVersion(int zone_id, int zone_version)
* MercArmorinfoRepository::GetWhereNeverExpires()
* MercArmorinfoRepository::GetWhereXAndY()
* MercArmorinfoRepository::DeleteWhereXAndY()
*
* Most of the above could be covered by base methods, but if you as a developer
* find yourself re-using logic for other parts of the code, its best to just make a
* method that can be re-used easily elsewhere especially if it can use a base repository
* method and encapsulate filters there
*/
// Custom extended repository methods here
};
#endif //EQEMU_MERC_ARMORINFO_REPOSITORY_H
@@ -0,0 +1,50 @@
#ifndef EQEMU_MERC_BUFFS_REPOSITORY_H
#define EQEMU_MERC_BUFFS_REPOSITORY_H
#include "../database.h"
#include "../strings.h"
#include "base/base_merc_buffs_repository.h"
class MercBuffsRepository: public BaseMercBuffsRepository {
public:
/**
* This file was auto generated and can be modified and extended upon
*
* Base repository methods are automatically
* generated in the "base" version of this repository. The base repository
* is immutable and to be left untouched, while methods in this class
* are used as extension methods for more specific persistence-layer
* accessors or mutators.
*
* Base Methods (Subject to be expanded upon in time)
*
* Note: Not all tables are designed appropriately to fit functionality with all base methods
*
* InsertOne
* UpdateOne
* DeleteOne
* FindOne
* GetWhere(std::string where_filter)
* DeleteWhere(std::string where_filter)
* InsertMany
* All
*
* Example custom methods in a repository
*
* MercBuffsRepository::GetByZoneAndVersion(int zone_id, int zone_version)
* MercBuffsRepository::GetWhereNeverExpires()
* MercBuffsRepository::GetWhereXAndY()
* MercBuffsRepository::DeleteWhereXAndY()
*
* Most of the above could be covered by base methods, but if you as a developer
* find yourself re-using logic for other parts of the code, its best to just make a
* method that can be re-used easily elsewhere especially if it can use a base repository
* method and encapsulate filters there
*/
// Custom extended repository methods here
};
#endif //EQEMU_MERC_BUFFS_REPOSITORY_H
@@ -0,0 +1,50 @@
#ifndef EQEMU_MERC_INVENTORY_REPOSITORY_H
#define EQEMU_MERC_INVENTORY_REPOSITORY_H
#include "../database.h"
#include "../strings.h"
#include "base/base_merc_inventory_repository.h"
class MercInventoryRepository: public BaseMercInventoryRepository {
public:
/**
* This file was auto generated and can be modified and extended upon
*
* Base repository methods are automatically
* generated in the "base" version of this repository. The base repository
* is immutable and to be left untouched, while methods in this class
* are used as extension methods for more specific persistence-layer
* accessors or mutators.
*
* Base Methods (Subject to be expanded upon in time)
*
* Note: Not all tables are designed appropriately to fit functionality with all base methods
*
* InsertOne
* UpdateOne
* DeleteOne
* FindOne
* GetWhere(std::string where_filter)
* DeleteWhere(std::string where_filter)
* InsertMany
* All
*
* Example custom methods in a repository
*
* MercInventoryRepository::GetByZoneAndVersion(int zone_id, int zone_version)
* MercInventoryRepository::GetWhereNeverExpires()
* MercInventoryRepository::GetWhereXAndY()
* MercInventoryRepository::DeleteWhereXAndY()
*
* Most of the above could be covered by base methods, but if you as a developer
* find yourself re-using logic for other parts of the code, its best to just make a
* method that can be re-used easily elsewhere especially if it can use a base repository
* method and encapsulate filters there
*/
// Custom extended repository methods here
};
#endif //EQEMU_MERC_INVENTORY_REPOSITORY_H
@@ -0,0 +1,50 @@
#ifndef EQEMU_MERC_MERCHANT_ENTRIES_REPOSITORY_H
#define EQEMU_MERC_MERCHANT_ENTRIES_REPOSITORY_H
#include "../database.h"
#include "../strings.h"
#include "base/base_merc_merchant_entries_repository.h"
class MercMerchantEntriesRepository: public BaseMercMerchantEntriesRepository {
public:
/**
* This file was auto generated and can be modified and extended upon
*
* Base repository methods are automatically
* generated in the "base" version of this repository. The base repository
* is immutable and to be left untouched, while methods in this class
* are used as extension methods for more specific persistence-layer
* accessors or mutators.
*
* Base Methods (Subject to be expanded upon in time)
*
* Note: Not all tables are designed appropriately to fit functionality with all base methods
*
* InsertOne
* UpdateOne
* DeleteOne
* FindOne
* GetWhere(std::string where_filter)
* DeleteWhere(std::string where_filter)
* InsertMany
* All
*
* Example custom methods in a repository
*
* MercMerchantEntriesRepository::GetByZoneAndVersion(int zone_id, int zone_version)
* MercMerchantEntriesRepository::GetWhereNeverExpires()
* MercMerchantEntriesRepository::GetWhereXAndY()
* MercMerchantEntriesRepository::DeleteWhereXAndY()
*
* Most of the above could be covered by base methods, but if you as a developer
* find yourself re-using logic for other parts of the code, its best to just make a
* method that can be re-used easily elsewhere especially if it can use a base repository
* method and encapsulate filters there
*/
// Custom extended repository methods here
};
#endif //EQEMU_MERC_MERCHANT_ENTRIES_REPOSITORY_H
@@ -0,0 +1,50 @@
#ifndef EQEMU_MERC_MERCHANT_TEMPLATE_ENTRIES_REPOSITORY_H
#define EQEMU_MERC_MERCHANT_TEMPLATE_ENTRIES_REPOSITORY_H
#include "../database.h"
#include "../strings.h"
#include "base/base_merc_merchant_template_entries_repository.h"
class MercMerchantTemplateEntriesRepository: public BaseMercMerchantTemplateEntriesRepository {
public:
/**
* This file was auto generated and can be modified and extended upon
*
* Base repository methods are automatically
* generated in the "base" version of this repository. The base repository
* is immutable and to be left untouched, while methods in this class
* are used as extension methods for more specific persistence-layer
* accessors or mutators.
*
* Base Methods (Subject to be expanded upon in time)
*
* Note: Not all tables are designed appropriately to fit functionality with all base methods
*
* InsertOne
* UpdateOne
* DeleteOne
* FindOne
* GetWhere(std::string where_filter)
* DeleteWhere(std::string where_filter)
* InsertMany
* All
*
* Example custom methods in a repository
*
* MercMerchantTemplateEntriesRepository::GetByZoneAndVersion(int zone_id, int zone_version)
* MercMerchantTemplateEntriesRepository::GetWhereNeverExpires()
* MercMerchantTemplateEntriesRepository::GetWhereXAndY()
* MercMerchantTemplateEntriesRepository::DeleteWhereXAndY()
*
* Most of the above could be covered by base methods, but if you as a developer
* find yourself re-using logic for other parts of the code, its best to just make a
* method that can be re-used easily elsewhere especially if it can use a base repository
* method and encapsulate filters there
*/
// Custom extended repository methods here
};
#endif //EQEMU_MERC_MERCHANT_TEMPLATE_ENTRIES_REPOSITORY_H
@@ -0,0 +1,50 @@
#ifndef EQEMU_MERC_MERCHANT_TEMPLATES_REPOSITORY_H
#define EQEMU_MERC_MERCHANT_TEMPLATES_REPOSITORY_H
#include "../database.h"
#include "../strings.h"
#include "base/base_merc_merchant_templates_repository.h"
class MercMerchantTemplatesRepository: public BaseMercMerchantTemplatesRepository {
public:
/**
* This file was auto generated and can be modified and extended upon
*
* Base repository methods are automatically
* generated in the "base" version of this repository. The base repository
* is immutable and to be left untouched, while methods in this class
* are used as extension methods for more specific persistence-layer
* accessors or mutators.
*
* Base Methods (Subject to be expanded upon in time)
*
* Note: Not all tables are designed appropriately to fit functionality with all base methods
*
* InsertOne
* UpdateOne
* DeleteOne
* FindOne
* GetWhere(std::string where_filter)
* DeleteWhere(std::string where_filter)
* InsertMany
* All
*
* Example custom methods in a repository
*
* MercMerchantTemplatesRepository::GetByZoneAndVersion(int zone_id, int zone_version)
* MercMerchantTemplatesRepository::GetWhereNeverExpires()
* MercMerchantTemplatesRepository::GetWhereXAndY()
* MercMerchantTemplatesRepository::DeleteWhereXAndY()
*
* Most of the above could be covered by base methods, but if you as a developer
* find yourself re-using logic for other parts of the code, its best to just make a
* method that can be re-used easily elsewhere especially if it can use a base repository
* method and encapsulate filters there
*/
// Custom extended repository methods here
};
#endif //EQEMU_MERC_MERCHANT_TEMPLATES_REPOSITORY_H
@@ -0,0 +1,50 @@
#ifndef EQEMU_MERC_NAME_TYPES_REPOSITORY_H
#define EQEMU_MERC_NAME_TYPES_REPOSITORY_H
#include "../database.h"
#include "../strings.h"
#include "base/base_merc_name_types_repository.h"
class MercNameTypesRepository: public BaseMercNameTypesRepository {
public:
/**
* This file was auto generated and can be modified and extended upon
*
* Base repository methods are automatically
* generated in the "base" version of this repository. The base repository
* is immutable and to be left untouched, while methods in this class
* are used as extension methods for more specific persistence-layer
* accessors or mutators.
*
* Base Methods (Subject to be expanded upon in time)
*
* Note: Not all tables are designed appropriately to fit functionality with all base methods
*
* InsertOne
* UpdateOne
* DeleteOne
* FindOne
* GetWhere(std::string where_filter)
* DeleteWhere(std::string where_filter)
* InsertMany
* All
*
* Example custom methods in a repository
*
* MercNameTypesRepository::GetByZoneAndVersion(int zone_id, int zone_version)
* MercNameTypesRepository::GetWhereNeverExpires()
* MercNameTypesRepository::GetWhereXAndY()
* MercNameTypesRepository::DeleteWhereXAndY()
*
* Most of the above could be covered by base methods, but if you as a developer
* find yourself re-using logic for other parts of the code, its best to just make a
* method that can be re-used easily elsewhere especially if it can use a base repository
* method and encapsulate filters there
*/
// Custom extended repository methods here
};
#endif //EQEMU_MERC_NAME_TYPES_REPOSITORY_H
@@ -0,0 +1,50 @@
#ifndef EQEMU_MERC_NPC_TYPES_REPOSITORY_H
#define EQEMU_MERC_NPC_TYPES_REPOSITORY_H
#include "../database.h"
#include "../strings.h"
#include "base/base_merc_npc_types_repository.h"
class MercNpcTypesRepository: public BaseMercNpcTypesRepository {
public:
/**
* This file was auto generated and can be modified and extended upon
*
* Base repository methods are automatically
* generated in the "base" version of this repository. The base repository
* is immutable and to be left untouched, while methods in this class
* are used as extension methods for more specific persistence-layer
* accessors or mutators.
*
* Base Methods (Subject to be expanded upon in time)
*
* Note: Not all tables are designed appropriately to fit functionality with all base methods
*
* InsertOne
* UpdateOne
* DeleteOne
* FindOne
* GetWhere(std::string where_filter)
* DeleteWhere(std::string where_filter)
* InsertMany
* All
*
* Example custom methods in a repository
*
* MercNpcTypesRepository::GetByZoneAndVersion(int zone_id, int zone_version)
* MercNpcTypesRepository::GetWhereNeverExpires()
* MercNpcTypesRepository::GetWhereXAndY()
* MercNpcTypesRepository::DeleteWhereXAndY()
*
* Most of the above could be covered by base methods, but if you as a developer
* find yourself re-using logic for other parts of the code, its best to just make a
* method that can be re-used easily elsewhere especially if it can use a base repository
* method and encapsulate filters there
*/
// Custom extended repository methods here
};
#endif //EQEMU_MERC_NPC_TYPES_REPOSITORY_H
@@ -0,0 +1,50 @@
#ifndef EQEMU_MERC_SPELL_LIST_ENTRIES_REPOSITORY_H
#define EQEMU_MERC_SPELL_LIST_ENTRIES_REPOSITORY_H
#include "../database.h"
#include "../strings.h"
#include "base/base_merc_spell_list_entries_repository.h"
class MercSpellListEntriesRepository: public BaseMercSpellListEntriesRepository {
public:
/**
* This file was auto generated and can be modified and extended upon
*
* Base repository methods are automatically
* generated in the "base" version of this repository. The base repository
* is immutable and to be left untouched, while methods in this class
* are used as extension methods for more specific persistence-layer
* accessors or mutators.
*
* Base Methods (Subject to be expanded upon in time)
*
* Note: Not all tables are designed appropriately to fit functionality with all base methods
*
* InsertOne
* UpdateOne
* DeleteOne
* FindOne
* GetWhere(std::string where_filter)
* DeleteWhere(std::string where_filter)
* InsertMany
* All
*
* Example custom methods in a repository
*
* MercSpellListEntriesRepository::GetByZoneAndVersion(int zone_id, int zone_version)
* MercSpellListEntriesRepository::GetWhereNeverExpires()
* MercSpellListEntriesRepository::GetWhereXAndY()
* MercSpellListEntriesRepository::DeleteWhereXAndY()
*
* Most of the above could be covered by base methods, but if you as a developer
* find yourself re-using logic for other parts of the code, its best to just make a
* method that can be re-used easily elsewhere especially if it can use a base repository
* method and encapsulate filters there
*/
// Custom extended repository methods here
};
#endif //EQEMU_MERC_SPELL_LIST_ENTRIES_REPOSITORY_H
@@ -0,0 +1,50 @@
#ifndef EQEMU_MERC_SPELL_LISTS_REPOSITORY_H
#define EQEMU_MERC_SPELL_LISTS_REPOSITORY_H
#include "../database.h"
#include "../strings.h"
#include "base/base_merc_spell_lists_repository.h"
class MercSpellListsRepository: public BaseMercSpellListsRepository {
public:
/**
* This file was auto generated and can be modified and extended upon
*
* Base repository methods are automatically
* generated in the "base" version of this repository. The base repository
* is immutable and to be left untouched, while methods in this class
* are used as extension methods for more specific persistence-layer
* accessors or mutators.
*
* Base Methods (Subject to be expanded upon in time)
*
* Note: Not all tables are designed appropriately to fit functionality with all base methods
*
* InsertOne
* UpdateOne
* DeleteOne
* FindOne
* GetWhere(std::string where_filter)
* DeleteWhere(std::string where_filter)
* InsertMany
* All
*
* Example custom methods in a repository
*
* MercSpellListsRepository::GetByZoneAndVersion(int zone_id, int zone_version)
* MercSpellListsRepository::GetWhereNeverExpires()
* MercSpellListsRepository::GetWhereXAndY()
* MercSpellListsRepository::DeleteWhereXAndY()
*
* Most of the above could be covered by base methods, but if you as a developer
* find yourself re-using logic for other parts of the code, its best to just make a
* method that can be re-used easily elsewhere especially if it can use a base repository
* method and encapsulate filters there
*/
// Custom extended repository methods here
};
#endif //EQEMU_MERC_SPELL_LISTS_REPOSITORY_H
@@ -0,0 +1,50 @@
#ifndef EQEMU_MERC_STANCE_ENTRIES_REPOSITORY_H
#define EQEMU_MERC_STANCE_ENTRIES_REPOSITORY_H
#include "../database.h"
#include "../strings.h"
#include "base/base_merc_stance_entries_repository.h"
class MercStanceEntriesRepository: public BaseMercStanceEntriesRepository {
public:
/**
* This file was auto generated and can be modified and extended upon
*
* Base repository methods are automatically
* generated in the "base" version of this repository. The base repository
* is immutable and to be left untouched, while methods in this class
* are used as extension methods for more specific persistence-layer
* accessors or mutators.
*
* Base Methods (Subject to be expanded upon in time)
*
* Note: Not all tables are designed appropriately to fit functionality with all base methods
*
* InsertOne
* UpdateOne
* DeleteOne
* FindOne
* GetWhere(std::string where_filter)
* DeleteWhere(std::string where_filter)
* InsertMany
* All
*
* Example custom methods in a repository
*
* MercStanceEntriesRepository::GetByZoneAndVersion(int zone_id, int zone_version)
* MercStanceEntriesRepository::GetWhereNeverExpires()
* MercStanceEntriesRepository::GetWhereXAndY()
* MercStanceEntriesRepository::DeleteWhereXAndY()
*
* Most of the above could be covered by base methods, but if you as a developer
* find yourself re-using logic for other parts of the code, its best to just make a
* method that can be re-used easily elsewhere especially if it can use a base repository
* method and encapsulate filters there
*/
// Custom extended repository methods here
};
#endif //EQEMU_MERC_STANCE_ENTRIES_REPOSITORY_H
@@ -0,0 +1,50 @@
#ifndef EQEMU_MERC_STATS_REPOSITORY_H
#define EQEMU_MERC_STATS_REPOSITORY_H
#include "../database.h"
#include "../strings.h"
#include "base/base_merc_stats_repository.h"
class MercStatsRepository: public BaseMercStatsRepository {
public:
/**
* This file was auto generated and can be modified and extended upon
*
* Base repository methods are automatically
* generated in the "base" version of this repository. The base repository
* is immutable and to be left untouched, while methods in this class
* are used as extension methods for more specific persistence-layer
* accessors or mutators.
*
* Base Methods (Subject to be expanded upon in time)
*
* Note: Not all tables are designed appropriately to fit functionality with all base methods
*
* InsertOne
* UpdateOne
* DeleteOne
* FindOne
* GetWhere(std::string where_filter)
* DeleteWhere(std::string where_filter)
* InsertMany
* All
*
* Example custom methods in a repository
*
* MercStatsRepository::GetByZoneAndVersion(int zone_id, int zone_version)
* MercStatsRepository::GetWhereNeverExpires()
* MercStatsRepository::GetWhereXAndY()
* MercStatsRepository::DeleteWhereXAndY()
*
* Most of the above could be covered by base methods, but if you as a developer
* find yourself re-using logic for other parts of the code, its best to just make a
* method that can be re-used easily elsewhere especially if it can use a base repository
* method and encapsulate filters there
*/
// Custom extended repository methods here
};
#endif //EQEMU_MERC_STATS_REPOSITORY_H
@@ -0,0 +1,50 @@
#ifndef EQEMU_MERC_SUBTYPES_REPOSITORY_H
#define EQEMU_MERC_SUBTYPES_REPOSITORY_H
#include "../database.h"
#include "../strings.h"
#include "base/base_merc_subtypes_repository.h"
class MercSubtypesRepository: public BaseMercSubtypesRepository {
public:
/**
* This file was auto generated and can be modified and extended upon
*
* Base repository methods are automatically
* generated in the "base" version of this repository. The base repository
* is immutable and to be left untouched, while methods in this class
* are used as extension methods for more specific persistence-layer
* accessors or mutators.
*
* Base Methods (Subject to be expanded upon in time)
*
* Note: Not all tables are designed appropriately to fit functionality with all base methods
*
* InsertOne
* UpdateOne
* DeleteOne
* FindOne
* GetWhere(std::string where_filter)
* DeleteWhere(std::string where_filter)
* InsertMany
* All
*
* Example custom methods in a repository
*
* MercSubtypesRepository::GetByZoneAndVersion(int zone_id, int zone_version)
* MercSubtypesRepository::GetWhereNeverExpires()
* MercSubtypesRepository::GetWhereXAndY()
* MercSubtypesRepository::DeleteWhereXAndY()
*
* Most of the above could be covered by base methods, but if you as a developer
* find yourself re-using logic for other parts of the code, its best to just make a
* method that can be re-used easily elsewhere especially if it can use a base repository
* method and encapsulate filters there
*/
// Custom extended repository methods here
};
#endif //EQEMU_MERC_SUBTYPES_REPOSITORY_H
@@ -0,0 +1,50 @@
#ifndef EQEMU_MERC_TEMPLATES_REPOSITORY_H
#define EQEMU_MERC_TEMPLATES_REPOSITORY_H
#include "../database.h"
#include "../strings.h"
#include "base/base_merc_templates_repository.h"
class MercTemplatesRepository: public BaseMercTemplatesRepository {
public:
/**
* This file was auto generated and can be modified and extended upon
*
* Base repository methods are automatically
* generated in the "base" version of this repository. The base repository
* is immutable and to be left untouched, while methods in this class
* are used as extension methods for more specific persistence-layer
* accessors or mutators.
*
* Base Methods (Subject to be expanded upon in time)
*
* Note: Not all tables are designed appropriately to fit functionality with all base methods
*
* InsertOne
* UpdateOne
* DeleteOne
* FindOne
* GetWhere(std::string where_filter)
* DeleteWhere(std::string where_filter)
* InsertMany
* All
*
* Example custom methods in a repository
*
* MercTemplatesRepository::GetByZoneAndVersion(int zone_id, int zone_version)
* MercTemplatesRepository::GetWhereNeverExpires()
* MercTemplatesRepository::GetWhereXAndY()
* MercTemplatesRepository::DeleteWhereXAndY()
*
* Most of the above could be covered by base methods, but if you as a developer
* find yourself re-using logic for other parts of the code, its best to just make a
* method that can be re-used easily elsewhere especially if it can use a base repository
* method and encapsulate filters there
*/
// Custom extended repository methods here
};
#endif //EQEMU_MERC_TEMPLATES_REPOSITORY_H
@@ -0,0 +1,50 @@
#ifndef EQEMU_MERC_TYPES_REPOSITORY_H
#define EQEMU_MERC_TYPES_REPOSITORY_H
#include "../database.h"
#include "../strings.h"
#include "base/base_merc_types_repository.h"
class MercTypesRepository: public BaseMercTypesRepository {
public:
/**
* This file was auto generated and can be modified and extended upon
*
* Base repository methods are automatically
* generated in the "base" version of this repository. The base repository
* is immutable and to be left untouched, while methods in this class
* are used as extension methods for more specific persistence-layer
* accessors or mutators.
*
* Base Methods (Subject to be expanded upon in time)
*
* Note: Not all tables are designed appropriately to fit functionality with all base methods
*
* InsertOne
* UpdateOne
* DeleteOne
* FindOne
* GetWhere(std::string where_filter)
* DeleteWhere(std::string where_filter)
* InsertMany
* All
*
* Example custom methods in a repository
*
* MercTypesRepository::GetByZoneAndVersion(int zone_id, int zone_version)
* MercTypesRepository::GetWhereNeverExpires()
* MercTypesRepository::GetWhereXAndY()
* MercTypesRepository::DeleteWhereXAndY()
*
* Most of the above could be covered by base methods, but if you as a developer
* find yourself re-using logic for other parts of the code, its best to just make a
* method that can be re-used easily elsewhere especially if it can use a base repository
* method and encapsulate filters there
*/
// Custom extended repository methods here
};
#endif //EQEMU_MERC_TYPES_REPOSITORY_H
@@ -0,0 +1,50 @@
#ifndef EQEMU_MERC_WEAPONINFO_REPOSITORY_H
#define EQEMU_MERC_WEAPONINFO_REPOSITORY_H
#include "../database.h"
#include "../strings.h"
#include "base/base_merc_weaponinfo_repository.h"
class MercWeaponinfoRepository: public BaseMercWeaponinfoRepository {
public:
/**
* This file was auto generated and can be modified and extended upon
*
* Base repository methods are automatically
* generated in the "base" version of this repository. The base repository
* is immutable and to be left untouched, while methods in this class
* are used as extension methods for more specific persistence-layer
* accessors or mutators.
*
* Base Methods (Subject to be expanded upon in time)
*
* Note: Not all tables are designed appropriately to fit functionality with all base methods
*
* InsertOne
* UpdateOne
* DeleteOne
* FindOne
* GetWhere(std::string where_filter)
* DeleteWhere(std::string where_filter)
* InsertMany
* All
*
* Example custom methods in a repository
*
* MercWeaponinfoRepository::GetByZoneAndVersion(int zone_id, int zone_version)
* MercWeaponinfoRepository::GetWhereNeverExpires()
* MercWeaponinfoRepository::GetWhereXAndY()
* MercWeaponinfoRepository::DeleteWhereXAndY()
*
* Most of the above could be covered by base methods, but if you as a developer
* find yourself re-using logic for other parts of the code, its best to just make a
* method that can be re-used easily elsewhere especially if it can use a base repository
* method and encapsulate filters there
*/
// Custom extended repository methods here
};
#endif //EQEMU_MERC_WEAPONINFO_REPOSITORY_H
+50
View File
@@ -0,0 +1,50 @@
#ifndef EQEMU_MERCS_REPOSITORY_H
#define EQEMU_MERCS_REPOSITORY_H
#include "../database.h"
#include "../strings.h"
#include "base/base_mercs_repository.h"
class MercsRepository: public BaseMercsRepository {
public:
/**
* This file was auto generated and can be modified and extended upon
*
* Base repository methods are automatically
* generated in the "base" version of this repository. The base repository
* is immutable and to be left untouched, while methods in this class
* are used as extension methods for more specific persistence-layer
* accessors or mutators.
*
* Base Methods (Subject to be expanded upon in time)
*
* Note: Not all tables are designed appropriately to fit functionality with all base methods
*
* InsertOne
* UpdateOne
* DeleteOne
* FindOne
* GetWhere(std::string where_filter)
* DeleteWhere(std::string where_filter)
* InsertMany
* All
*
* Example custom methods in a repository
*
* MercsRepository::GetByZoneAndVersion(int zone_id, int zone_version)
* MercsRepository::GetWhereNeverExpires()
* MercsRepository::GetWhereXAndY()
* MercsRepository::DeleteWhereXAndY()
*
* Most of the above could be covered by base methods, but if you as a developer
* find yourself re-using logic for other parts of the code, its best to just make a
* method that can be re-used easily elsewhere especially if it can use a base repository
* method and encapsulate filters there
*/
// Custom extended repository methods here
};
#endif //EQEMU_MERCS_REPOSITORY_H
+18 -11
View File
@@ -34,7 +34,7 @@ const char *RuleManager::s_categoryNames[_CatCount + 1] = {
"InvalidCategory"
};
const RuleManager::RuleInfo RuleManager::s_RuleInfo[_IntRuleCount + _RealRuleCount + _BoolRuleCount + 1] = {
const RuleManager::RuleInfo RuleManager::s_RuleInfo[IntRuleCount + RealRuleCount + BoolRuleCount + 1] = {
/* this is done in three steps so we can reliably get to them by index*/
#define RULE_INT(category_name, rule_name, default_value, notes) \
{ #category_name ":" #rule_name, Category__##category_name, IntRule, Int__##rule_name, notes },
@@ -212,14 +212,14 @@ std::string RuleManager::_GetRuleName(RuleType type, uint16 index) {
case IntRule:
return s_RuleInfo[index].name;
case RealRule:
return s_RuleInfo[index + _IntRuleCount].name;
return s_RuleInfo[index + IntRuleCount].name;
case BoolRule:
return s_RuleInfo[index + _IntRuleCount + _RealRuleCount].name;
return s_RuleInfo[index + IntRuleCount + RealRuleCount].name;
default:
break;
}
return s_RuleInfo[_IntRuleCount + _RealRuleCount + _BoolRuleCount].name;
return s_RuleInfo[IntRuleCount + RealRuleCount + BoolRuleCount].name;
}
//assumes index is valid!
@@ -228,14 +228,14 @@ const std::string &RuleManager::_GetRuleNotes(RuleType type, uint16 index) {
case IntRule:
return s_RuleInfo[index].notes;
case RealRule:
return s_RuleInfo[index + _IntRuleCount].notes;
return s_RuleInfo[index + IntRuleCount].notes;
case BoolRule:
return s_RuleInfo[index + _IntRuleCount + _RealRuleCount].notes;
return s_RuleInfo[index + IntRuleCount + RealRuleCount].notes;
default:
break;
}
return s_RuleInfo[_IntRuleCount + _RealRuleCount + _BoolRuleCount].notes;
return s_RuleInfo[IntRuleCount + RealRuleCount + BoolRuleCount].notes;
}
bool RuleManager::LoadRules(Database *db, const std::string &rule_set_name, bool reload) {
@@ -304,6 +304,13 @@ bool RuleManager::LoadRules(Database *db, const std::string &rule_set_name, bool
}
}
LogInfo(
"Loaded [{}] rules(s) in rule_set [{}] id [{}]",
Strings::Commify(std::to_string(l.size())),
rule_set_name,
rule_set_id
);
return true;
}
@@ -325,15 +332,15 @@ void RuleManager::SaveRules(Database *db, const std::string &rule_set_name) {
}
int i;
for (i = 0; i < _IntRuleCount; i++) {
for (i = 0; i < IntRuleCount; i++) {
_SaveRule(db, IntRule, i);
}
for (i = 0; i < _RealRuleCount; i++) {
for (i = 0; i < RealRuleCount; i++) {
_SaveRule(db, RealRule, i);
}
for (i = 0; i < _BoolRuleCount; i++) {
for (i = 0; i < BoolRuleCount; i++) {
_SaveRule(db, BoolRule, i);
}
}
@@ -536,7 +543,7 @@ bool RuleManager::RestoreRuleNotes(Database *db)
}
}
return s_RuleInfo[_IntRuleCount + _RealRuleCount + _BoolRuleCount];
return s_RuleInfo[IntRuleCount + RealRuleCount + BoolRuleCount];
}(e.rule_name);
if (Strings::Contains(rule.name, e.rule_name)) {
+17 -11
View File
@@ -57,6 +57,8 @@ public:
_IntRuleCount
} IntType;
static const int IntRuleCount = static_cast<int>(_IntRuleCount);
typedef enum {
#define RULE_REAL(category_name, rule_name, default_value, notes) \
Real__##rule_name,
@@ -66,6 +68,8 @@ public:
_RealRuleCount
} RealType;
static const int RealRuleCount = static_cast<int>(_RealRuleCount);
typedef enum {
#define RULE_BOOL(category_name, rule_name, default_value, notes) \
Bool__##rule_name,
@@ -75,6 +79,8 @@ public:
_BoolRuleCount
} BoolType;
static const int BoolRuleCount = static_cast<int>(_BoolRuleCount);
typedef enum {
#define RULE_CATEGORY(category_name) \
Category__##category_name,
@@ -95,7 +101,7 @@ public:
static const BoolType InvalidBool = _BoolRuleCount;
static const CategoryType InvalidCategory = _CatCount;
static const uint32 _RulesCount = _IntRuleCount + _RealRuleCount + _BoolRuleCount;
static const uint32 RulesCount = IntRuleCount + RealRuleCount + BoolRuleCount;
//fetch routines, you should generally use the Rule* macros instead of this
int GetIntRule(IntType t) const;
@@ -103,13 +109,13 @@ public:
bool GetBoolRule(BoolType t) const;
//management routines
static std::string GetRuleName(IntType t) { return s_RuleInfo[t].name; }
static std::string GetRuleName(RealType t) { return s_RuleInfo[t + _IntRuleCount].name; }
static std::string GetRuleName(BoolType t) { return s_RuleInfo[t + _IntRuleCount + _RealRuleCount].name; }
static const std::string &GetRuleNotes(IntType t) { return s_RuleInfo[t].notes; }
static const std::string &GetRuleNotes(RealType t) { return s_RuleInfo[t + _IntRuleCount].notes; }
static const std::string &GetRuleNotes(BoolType t) { return s_RuleInfo[t + _IntRuleCount + _RealRuleCount].notes; }
static uint32 CountRules() { return _RulesCount; }
static std::string GetRuleName(IntType t) { return s_RuleInfo[static_cast<int>(t)].name; }
static std::string GetRuleName(RealType t) { return s_RuleInfo[static_cast<int>(t) + IntRuleCount].name; }
static std::string GetRuleName(BoolType t) { return s_RuleInfo[static_cast<int>(t) + IntRuleCount + RealRuleCount].name; }
static const std::string &GetRuleNotes(IntType t) { return s_RuleInfo[static_cast<int>(t)].notes; }
static const std::string &GetRuleNotes(RealType t) { return s_RuleInfo[static_cast<int>(t) + IntRuleCount].notes; }
static const std::string &GetRuleNotes(BoolType t) { return s_RuleInfo[static_cast<int>(t) + IntRuleCount + RealRuleCount].notes; }
static uint32 CountRules() { return RulesCount; }
static CategoryType FindCategory(const std::string &category_name);
bool ListRules(const std::string &category_name, std::vector <std::string> &l);
bool ListCategories(std::vector <std::string> &l);
@@ -141,9 +147,9 @@ private:
int m_activeRuleset;
std::string m_activeName;
int m_RuleIntValues[_IntRuleCount];
float m_RuleRealValues[_RealRuleCount];
uint32 m_RuleBoolValues[_BoolRuleCount];
int m_RuleIntValues[IntRuleCount];
float m_RuleRealValues[RealRuleCount];
uint32 m_RuleBoolValues[BoolRuleCount];
typedef enum {
IntRule,
+6 -3
View File
@@ -197,6 +197,9 @@ RULE_BOOL(Character, PetZoneWithOwner, true, "Should Pets Zone with Owner")
RULE_BOOL(Character, FullManaOnDeath, true, "On death set mana to full")
RULE_BOOL(Character, FullEndurOnDeath, true, "On death set endurance to full")
RULE_INT(Character, ExperiencePercentCapPerKill, -1, "Caps the percentage of experience that can be gained per kill. -1 disables the cap; 0 blocks all (non-aa) xp.")
RULE_BOOL(Character, EnableGroupEXPModifier, true, "Enable or disable the group experience modifier based on number of players in group, default is true")
RULE_REAL(Character, GroupMemberEXPModifier, 0.2, "Sets the group experience modifier per members between 2 and 5, default is 0.2")
RULE_REAL(Character, FullGroupEXPModifier, 2.16, "Sets the group experience modifier for a full group, default is 2.16")
RULE_CATEGORY_END()
RULE_CATEGORY(Mercs)
@@ -426,6 +429,7 @@ RULE_BOOL(Spells, BuffsFadeOnDeath, true, "Disable to keep buffs from fading on
RULE_BOOL(Spells, IllusionsAlwaysPersist, false, "Allows Illusions to persist beyond death and zoning always.")
RULE_BOOL(Spells, UseItemCastMessage, false, "Enable to use the \"item begins to glow\" messages when casting from an item.")
RULE_BOOL(Spells, TargetsTargetRequiresCombatRange, true, "Disable to remove combat range requirement from Target's Target Spell Target Type")
RULE_BOOL(Spells, NPCBuffLevelRestrictions, false, "Impose BuffLevelRestrictions on NPCs if true")
RULE_CATEGORY_END()
RULE_CATEGORY(Combat)
@@ -581,9 +585,8 @@ RULE_INT(Range, CriticalDamage, 80, "The packet range in which critical hit mess
RULE_INT(Range, MobCloseScanDistance, 600, "Close scan distance")
RULE_CATEGORY_END()
#ifdef BOTS
RULE_CATEGORY(Bots)
RULE_BOOL(Bots, Enabled, false, "Enable of disable bot functionality, default is false")
RULE_INT(Bots, BotExpansionSettings, 16383, "Sets the expansion settings for bot use. Defaults to all expansions enabled up to TSS")
RULE_BOOL(Bots, AllowCamelCaseNames, false, "Allows the use of 'MyBot' type names")
RULE_BOOL(Bots, AllowBotEquipAnyRaceGear, false, "Allows Bots to wear Equipment even if their race is not valid")
@@ -612,7 +615,6 @@ RULE_BOOL(Bots, ResurrectionSickness, true, "Use Resurrection Sickness based on
RULE_INT(Bots, OldResurrectionSicknessSpell, 757, "757 is Default Old Resurrection Sickness Spell")
RULE_INT(Bots, ResurrectionSicknessSpell, 756, "756 is Default Resurrection Sickness Spell")
RULE_CATEGORY_END()
#endif
RULE_CATEGORY(Chat)
RULE_BOOL(Chat, ServerWideOOC, true, "Enable server wide ooc-chat")
@@ -621,6 +623,7 @@ RULE_BOOL(Chat, EnableVoiceMacros, true, "Enable voice macros")
RULE_BOOL(Chat, EnableMailKeyIPVerification, true, "Setting whether the authenticity of the client should be verified via its IP address when accessing the InGame mailbox")
RULE_BOOL(Chat, EnableAntiSpam, true, "Enable anti-spam system for chat")
RULE_BOOL(Chat, SuppressCommandErrors, false, "Do not suppress command errors by default")
RULE_INT(Chat, MaxPermanentPlayerChannels, 0, "Maximum number of permanent chat channels a player can make. Default 0.")
RULE_INT(Chat, MinStatusToBypassAntiSpam, 100, "Minimum status to bypass the anti-spam system")
RULE_INT(Chat, MinimumMessagesPerInterval, 4, "Minimum number of chat messages allowed per interval. The karma value is added to this value")
RULE_INT(Chat, MaximumMessagesPerInterval, 12, "Maximum value of chat messages allowed per interval")
+3 -3
View File
@@ -109,7 +109,7 @@ bool ServerEventScheduler::ValidateEventReadyToActivate(
if (now_time_unix >= start_time_unix && (doesnt_end || now_time_unix < end_time_unix)) {
LogSchedulerDetail(
"[ValidateEventReadyToActivate] now_time [{}] start_time [{}] doesnt_end [{}] end_time [{}]",
"now_time [{}] start_time [{}] doesnt_end [{}] end_time [{}]",
now_time_unix,
start_time_unix,
doesnt_end ? "true" : "false",
@@ -131,7 +131,7 @@ ServerEventScheduler *ServerEventScheduler::SetDatabase(Database *db)
bool ServerEventScheduler::ValidateDatabaseConnection()
{
if (!m_database) {
LogError("[ServerEventScheduler::LoadScheduledEvents] No database connection");
LogError("No database connection");
return false;
}
@@ -174,7 +174,7 @@ bool ServerEventScheduler::CheckIfEventsChanged()
dbe.created_at != e.created_at ||
dbe.deleted_at != e.deleted_at
) {
LogSchedulerDetail("[CheckIfEventsChanged] Field change detected");
LogSchedulerDetail("Field change detected");
m_events = events;
return true;
}
+24 -8
View File
@@ -42,6 +42,7 @@
#include "repositories/account_repository.h"
#include "repositories/faction_association_repository.h"
#include "path_manager.h"
#include "repositories/loottable_repository.h"
namespace ItemField
{
@@ -942,10 +943,11 @@ bool SharedDatabase::LoadItems(const std::string &prefix) {
EQ::IPCMutex mutex("items");
mutex.Lock();
std::string file_name = fmt::format("{}/{}{}", path.GetSharedMemoryPath(), prefix, std::string("items"));
LogInfo("[Shared Memory] Attempting to load file [{}]", file_name);
items_mmf = std::make_unique<EQ::MemoryMappedFile>(file_name);
items_hash = std::make_unique<EQ::FixedMemoryHashSet<EQ::ItemData>>(static_cast<uint8*>(items_mmf->Get()), items_mmf->Size());
mutex.Unlock();
LogInfo("Loaded [{}] items via shared memory", Strings::Commify(m_shared_items_count));
} catch(std::exception& ex) {
LogError("Error Loading Items: {}", ex.what());
return false;
@@ -1438,10 +1440,12 @@ bool SharedDatabase::LoadNPCFactionLists(const std::string &prefix) {
EQ::IPCMutex mutex("faction");
mutex.Lock();
std::string file_name = fmt::format("{}/{}{}", path.GetSharedMemoryPath(), prefix, std::string("faction"));
LogInfo("[Shared Memory] Attempting to load file [{}]", file_name);
LogInfo("Loading [{}]", file_name);
faction_mmf = std::make_unique<EQ::MemoryMappedFile>(file_name);
faction_hash = std::make_unique<EQ::FixedMemoryHashSet<NPCFactionList>>(static_cast<uint8*>(faction_mmf->Get()), faction_mmf->Size());
mutex.Unlock();
LogInfo("Loaded faction lists via shared memory");
} catch(std::exception& ex) {
LogError("Error Loading npc factions: {}", ex.what());
return false;
@@ -1516,6 +1520,8 @@ bool SharedDatabase::LoadFactionAssociation(const std::string &prefix)
new EQ::FixedMemoryHashSet<FactionAssociations>(reinterpret_cast<uint8 *>(faction_associations_mmf->Get()),
faction_associations_mmf->Size()));
mutex.Unlock();
LogInfo("Loaded faction associations via shared memory");
} catch (std::exception &ex) {
LogError("Error Loading faction associations: {}", ex.what());
return false;
@@ -1724,8 +1730,11 @@ bool SharedDatabase::LoadSkillCaps(const std::string &prefix) {
EQ::IPCMutex mutex("skill_caps");
mutex.Lock();
std::string file_name = fmt::format("{}/{}{}", path.GetSharedMemoryPath(), prefix, std::string("skill_caps"));
LogInfo("[Shared Memory] Attempting to load file [{}]", file_name);
LogInfo("Loading [{}]", file_name);
skill_caps_mmf = std::make_unique<EQ::MemoryMappedFile>(file_name);
LogInfo("Loaded skill caps via shared memory");
mutex.Unlock();
} catch(std::exception &ex) {
LogError("Error loading skill caps: {}", ex.what());
@@ -1884,10 +1893,12 @@ bool SharedDatabase::LoadSpells(const std::string &prefix, int32 *records, const
std::string file_name = fmt::format("{}/{}{}", path.GetSharedMemoryPath(), prefix, std::string("spells"));
spells_mmf = std::make_unique<EQ::MemoryMappedFile>(file_name);
LogInfo("[Shared Memory] Attempting to load file [{}]", file_name);
LogInfo("Loading [{}]", file_name);
*records = *static_cast<uint32*>(spells_mmf->Get());
*sp = reinterpret_cast<const SPDat_Spell_Struct*>(static_cast<char*>(spells_mmf->Get()) + 4);
mutex.Unlock();
LogInfo("Loaded [{}] spells via shared memory", Strings::Commify(m_shared_spells_count));
}
catch(std::exception& ex) {
LogError("Error Loading Spells: {}", ex.what());
@@ -1908,7 +1919,7 @@ void SharedDatabase::LoadSpells(void *data, int max_spells) {
}
if(results.ColumnCount() <= SPELL_LOAD_FIELD_COUNT) {
LogSpells("[SharedDatabase::LoadSpells] Fatal error loading spells: Spell field count < SPELL_LOAD_FIELD_COUNT([{}])", SPELL_LOAD_FIELD_COUNT);
LogSpells("Fatal error loading spells: Spell field count < SPELL_LOAD_FIELD_COUNT([{}])", SPELL_LOAD_FIELD_COUNT);
return;
}
@@ -1917,9 +1928,9 @@ void SharedDatabase::LoadSpells(void *data, int max_spells) {
for (auto& row = results.begin(); row != results.end(); ++row) {
const int tempid = atoi(row[0]);
if(tempid >= max_spells) {
LogSpells("[SharedDatabase::LoadSpells] Non fatal error: spell.id >= max_spells, ignoring");
continue;
}
LogSpells("Non fatal error: spell.id >= max_spells, ignoring");
continue;
}
++counter;
sp[tempid].id = tempid;
@@ -2099,6 +2110,8 @@ bool SharedDatabase::LoadBaseData(const std::string &prefix) {
std::string file_name = fmt::format("{}/{}{}", path.GetSharedMemoryPath(), prefix, std::string("base_data"));
base_data_mmf = std::make_unique<EQ::MemoryMappedFile>(file_name);
mutex.Unlock();
LogInfo("Loaded base data via shared memory");
} catch(std::exception& ex) {
LogError("Error Loading Base Data: {}", ex.what());
return false;
@@ -2423,6 +2436,9 @@ bool SharedDatabase::LoadLoot(const std::string &prefix) {
loot_table_hash = std::make_unique<EQ::FixedMemoryVariableHashSet<LootTable_Struct>>(
static_cast<uint8*>(loot_table_mmf->Get()),
loot_table_mmf->Size());
LogInfo("Loaded loot tables via shared memory");
std::string file_name_ld = fmt::format("{}/{}{}", path.GetSharedMemoryPath(), prefix, std::string("loot_drop"));
loot_drop_mmf = std::make_unique<EQ::MemoryMappedFile>(file_name_ld);
loot_drop_hash = std::make_unique<EQ::FixedMemoryVariableHashSet<LootDrop_Struct>>(
+6
View File
@@ -95,6 +95,12 @@ public:
static std::string &RTrim(std::string &str, const std::string &chars = "\t\n\v\f\r ");
static std::string &Trim(std::string &str, const std::string &chars = "\t\n\v\f\r ");
static std::string Commify(const std::string &number);
static std::string Commify(uint16 number) { return Strings::Commify(std::to_string(number)); };
static std::string Commify(uint32 number) { return Strings::Commify(std::to_string(number)); };
static std::string Commify(uint64 number) { return Strings::Commify(std::to_string(number)); };
static std::string Commify(int16 number) { return Strings::Commify(std::to_string(number)); };
static std::string Commify(int32 number) { return Strings::Commify(std::to_string(number)); };
static std::string Commify(int64 number) { return Strings::Commify(std::to_string(number)); };
static std::string ConvertToDigit(int n, std::string suffix);
static std::string Escape(const std::string &s);
static std::string GetBetween(const std::string &s, std::string start_delim, std::string stop_delim);
+502
View File
@@ -0,0 +1,502 @@
#ifndef RANG_DOT_HPP
#define RANG_DOT_HPP
#if defined(__unix__) || defined(__unix) || defined(__linux__)
#define OS_LINUX
#elif defined(WIN32) || defined(_WIN32) || defined(_WIN64)
#define OS_WIN
#elif defined(__APPLE__) || defined(__MACH__)
#define OS_MAC
#else
#error Unknown Platform
#endif
#if defined(OS_LINUX) || defined(OS_MAC)
#include <unistd.h>
#elif defined(OS_WIN)
#if defined(_WIN32_WINNT) && (_WIN32_WINNT < 0x0600)
#error \
"Please include rang.hpp before any windows system headers or set _WIN32_WINNT at least to _WIN32_WINNT_VISTA"
#elif !defined(_WIN32_WINNT)
#define _WIN32_WINNT _WIN32_WINNT_VISTA
#endif
#include <windows.h>
#include <io.h>
#include <memory>
// Only defined in windows 10 onwards, redefining in lower windows since it
// doesn't gets used in lower versions
// https://docs.microsoft.com/en-us/windows/console/getconsolemode
#ifndef ENABLE_VIRTUAL_TERMINAL_PROCESSING
#define ENABLE_VIRTUAL_TERMINAL_PROCESSING 0x0004
#endif
#endif
#include <algorithm>
#include <atomic>
#include <cstdlib>
#include <cstring>
#include <iostream>
namespace rang {
/* For better compability with most of terminals do not use any style settings
* except of reset, bold and reversed.
* Note that on Windows terminals bold style is same as fgB color.
*/
enum class style {
reset = 0,
bold = 1,
dim = 2,
italic = 3,
underline = 4,
blink = 5,
rblink = 6,
reversed = 7,
conceal = 8,
crossed = 9
};
enum class fg {
black = 30,
red = 31,
green = 32,
yellow = 33,
blue = 34,
magenta = 35,
cyan = 36,
gray = 37,
reset = 39
};
enum class bg {
black = 40,
red = 41,
green = 42,
yellow = 43,
blue = 44,
magenta = 45,
cyan = 46,
gray = 47,
reset = 49
};
enum class fgB {
black = 90,
red = 91,
green = 92,
yellow = 93,
blue = 94,
magenta = 95,
cyan = 96,
gray = 97
};
enum class bgB {
black = 100,
red = 101,
green = 102,
yellow = 103,
blue = 104,
magenta = 105,
cyan = 106,
gray = 107
};
enum class control { // Behaviour of rang function calls
Off = 0, // toggle off rang style/color calls
Auto = 1, // (Default) autodect terminal and colorize if needed
Force = 2 // force ansi color output to non terminal streams
};
// Use rang::setControlMode to set rang control mode
enum class winTerm { // Windows Terminal Mode
Auto = 0, // (Default) automatically detects wheter Ansi or Native API
Ansi = 1, // Force use Ansi API
Native = 2 // Force use Native API
};
// Use rang::setWinTermMode to explicitly set terminal API for Windows
// Calling rang::setWinTermMode have no effect on other OS
namespace rang_implementation {
inline std::atomic<control> &controlMode() noexcept
{
static std::atomic<control> value(control::Auto);
return value;
}
inline std::atomic<winTerm> &winTermMode() noexcept
{
static std::atomic<winTerm> termMode(winTerm::Auto);
return termMode;
}
inline bool supportsColor() noexcept
{
#if defined(OS_LINUX) || defined(OS_MAC)
static const bool result = [] {
const char *Terms[]
= { "ansi", "color", "console", "cygwin", "gnome",
"konsole", "kterm", "linux", "msys", "putty",
"rxvt", "screen", "vt100", "xterm" };
const char *env_p = std::getenv("TERM");
if (env_p == nullptr) {
return false;
}
return std::any_of(std::begin(Terms), std::end(Terms),
[&](const char *term) {
return std::strstr(env_p, term) != nullptr;
});
}();
#elif defined(OS_WIN)
// All windows versions support colors through native console methods
static constexpr bool result = true;
#endif
return result;
}
#ifdef OS_WIN
inline bool isMsysPty(int fd) noexcept
{
// Dynamic load for binary compability with old Windows
const auto ptrGetFileInformationByHandleEx
= reinterpret_cast<decltype(&GetFileInformationByHandleEx)>(
GetProcAddress(GetModuleHandle(TEXT("kernel32.dll")),
"GetFileInformationByHandleEx"));
if (!ptrGetFileInformationByHandleEx) {
return false;
}
HANDLE h = reinterpret_cast<HANDLE>(_get_osfhandle(fd));
if (h == INVALID_HANDLE_VALUE) {
return false;
}
// Check that it's a pipe:
if (GetFileType(h) != FILE_TYPE_PIPE) {
return false;
}
// POD type is binary compatible with FILE_NAME_INFO from WinBase.h
// It have the same alignment and used to avoid UB in caller code
struct MY_FILE_NAME_INFO {
DWORD FileNameLength;
WCHAR FileName[MAX_PATH];
};
auto pNameInfo = std::unique_ptr<MY_FILE_NAME_INFO>(
new (std::nothrow) MY_FILE_NAME_INFO());
if (!pNameInfo) {
return false;
}
// Check pipe name is template of
// {"cygwin-","msys-"}XXXXXXXXXXXXXXX-ptyX-XX
if (!ptrGetFileInformationByHandleEx(h, FileNameInfo, pNameInfo.get(),
sizeof(MY_FILE_NAME_INFO))) {
return false;
}
std::wstring name(pNameInfo->FileName, pNameInfo->FileNameLength / sizeof(WCHAR));
if ((name.find(L"msys-") == std::wstring::npos
&& name.find(L"cygwin-") == std::wstring::npos)
|| name.find(L"-pty") == std::wstring::npos) {
return false;
}
return true;
}
#endif
inline bool isTerminal(const std::streambuf *osbuf) noexcept
{
using std::cerr;
using std::clog;
using std::cout;
#if defined(OS_LINUX) || defined(OS_MAC)
if (osbuf == cout.rdbuf()) {
static const bool cout_term = isatty(fileno(stdout)) != 0;
return cout_term;
} else if (osbuf == cerr.rdbuf() || osbuf == clog.rdbuf()) {
static const bool cerr_term = isatty(fileno(stderr)) != 0;
return cerr_term;
}
#elif defined(OS_WIN)
if (osbuf == cout.rdbuf()) {
static const bool cout_term
= (_isatty(_fileno(stdout)) || isMsysPty(_fileno(stdout)));
return cout_term;
} else if (osbuf == cerr.rdbuf() || osbuf == clog.rdbuf()) {
static const bool cerr_term
= (_isatty(_fileno(stderr)) || isMsysPty(_fileno(stderr)));
return cerr_term;
}
#endif
return false;
}
template <typename T>
using enableStd = typename std::enable_if<
std::is_same<T, rang::style>::value || std::is_same<T, rang::fg>::value
|| std::is_same<T, rang::bg>::value || std::is_same<T, rang::fgB>::value
|| std::is_same<T, rang::bgB>::value,
std::ostream &>::type;
#ifdef OS_WIN
struct SGR { // Select Graphic Rendition parameters for Windows console
BYTE fgColor; // foreground color (0-15) lower 3 rgb bits + intense bit
BYTE bgColor; // background color (0-15) lower 3 rgb bits + intense bit
BYTE bold; // emulated as FOREGROUND_INTENSITY bit
BYTE underline; // emulated as BACKGROUND_INTENSITY bit
BOOLEAN inverse; // swap foreground/bold & background/underline
BOOLEAN conceal; // set foreground/bold to background/underline
};
enum class AttrColor : BYTE { // Color attributes for console screen buffer
black = 0,
red = 4,
green = 2,
yellow = 6,
blue = 1,
magenta = 5,
cyan = 3,
gray = 7
};
inline HANDLE getConsoleHandle(const std::streambuf *osbuf) noexcept
{
if (osbuf == std::cout.rdbuf()) {
static const HANDLE hStdout = GetStdHandle(STD_OUTPUT_HANDLE);
return hStdout;
} else if (osbuf == std::cerr.rdbuf() || osbuf == std::clog.rdbuf()) {
static const HANDLE hStderr = GetStdHandle(STD_ERROR_HANDLE);
return hStderr;
}
return INVALID_HANDLE_VALUE;
}
inline bool setWinTermAnsiColors(const std::streambuf *osbuf) noexcept
{
HANDLE h = getConsoleHandle(osbuf);
if (h == INVALID_HANDLE_VALUE) {
return false;
}
DWORD dwMode = 0;
if (!GetConsoleMode(h, &dwMode)) {
return false;
}
dwMode |= ENABLE_VIRTUAL_TERMINAL_PROCESSING;
if (!SetConsoleMode(h, dwMode)) {
return false;
}
return true;
}
inline bool supportsAnsi(const std::streambuf *osbuf) noexcept
{
using std::cerr;
using std::clog;
using std::cout;
if (osbuf == cout.rdbuf()) {
static const bool cout_ansi
= (isMsysPty(_fileno(stdout)) || setWinTermAnsiColors(osbuf));
return cout_ansi;
} else if (osbuf == cerr.rdbuf() || osbuf == clog.rdbuf()) {
static const bool cerr_ansi
= (isMsysPty(_fileno(stderr)) || setWinTermAnsiColors(osbuf));
return cerr_ansi;
}
return false;
}
inline const SGR &defaultState() noexcept
{
static const SGR defaultSgr = []() -> SGR {
CONSOLE_SCREEN_BUFFER_INFO info;
WORD attrib = FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE;
if (GetConsoleScreenBufferInfo(GetStdHandle(STD_OUTPUT_HANDLE),
&info)
|| GetConsoleScreenBufferInfo(GetStdHandle(STD_ERROR_HANDLE),
&info)) {
attrib = info.wAttributes;
}
SGR sgr = { 0, 0, 0, 0, FALSE, FALSE };
sgr.fgColor = attrib & 0x0F;
sgr.bgColor = (attrib & 0xF0) >> 4;
return sgr;
}();
return defaultSgr;
}
inline BYTE ansi2attr(BYTE rgb) noexcept
{
static const AttrColor rev[8]
= { AttrColor::black, AttrColor::red, AttrColor::green,
AttrColor::yellow, AttrColor::blue, AttrColor::magenta,
AttrColor::cyan, AttrColor::gray };
return static_cast<BYTE>(rev[rgb]);
}
inline void setWinSGR(rang::bg col, SGR &state) noexcept
{
if (col != rang::bg::reset) {
state.bgColor = ansi2attr(static_cast<BYTE>(col) - 40);
} else {
state.bgColor = defaultState().bgColor;
}
}
inline void setWinSGR(rang::fg col, SGR &state) noexcept
{
if (col != rang::fg::reset) {
state.fgColor = ansi2attr(static_cast<BYTE>(col) - 30);
} else {
state.fgColor = defaultState().fgColor;
}
}
inline void setWinSGR(rang::bgB col, SGR &state) noexcept
{
state.bgColor = (BACKGROUND_INTENSITY >> 4)
| ansi2attr(static_cast<BYTE>(col) - 100);
}
inline void setWinSGR(rang::fgB col, SGR &state) noexcept
{
state.fgColor
= FOREGROUND_INTENSITY | ansi2attr(static_cast<BYTE>(col) - 90);
}
inline void setWinSGR(rang::style style, SGR &state) noexcept
{
switch (style) {
case rang::style::reset: state = defaultState(); break;
case rang::style::bold: state.bold = FOREGROUND_INTENSITY; break;
case rang::style::underline:
case rang::style::blink:
state.underline = BACKGROUND_INTENSITY;
break;
case rang::style::reversed: state.inverse = TRUE; break;
case rang::style::conceal: state.conceal = TRUE; break;
default: break;
}
}
inline SGR &current_state() noexcept
{
static SGR state = defaultState();
return state;
}
inline WORD SGR2Attr(const SGR &state) noexcept
{
WORD attrib = 0;
if (state.conceal) {
if (state.inverse) {
attrib = (state.fgColor << 4) | state.fgColor;
if (state.bold)
attrib |= FOREGROUND_INTENSITY | BACKGROUND_INTENSITY;
} else {
attrib = (state.bgColor << 4) | state.bgColor;
if (state.underline)
attrib |= FOREGROUND_INTENSITY | BACKGROUND_INTENSITY;
}
} else if (state.inverse) {
attrib = (state.fgColor << 4) | state.bgColor;
if (state.bold) attrib |= BACKGROUND_INTENSITY;
if (state.underline) attrib |= FOREGROUND_INTENSITY;
} else {
attrib = state.fgColor | (state.bgColor << 4) | state.bold
| state.underline;
}
return attrib;
}
template <typename T>
inline void setWinColorAnsi(std::ostream &os, T const value)
{
os << "\033[" << static_cast<int>(value) << "m";
}
template <typename T>
inline void setWinColorNative(std::ostream &os, T const value)
{
const HANDLE h = getConsoleHandle(os.rdbuf());
if (h != INVALID_HANDLE_VALUE) {
setWinSGR(value, current_state());
// Out all buffered text to console with previous settings:
os.flush();
SetConsoleTextAttribute(h, SGR2Attr(current_state()));
}
}
template <typename T>
inline enableStd<T> setColor(std::ostream &os, T const value)
{
if (winTermMode() == winTerm::Auto) {
if (supportsAnsi(os.rdbuf())) {
setWinColorAnsi(os, value);
} else {
setWinColorNative(os, value);
}
} else if (winTermMode() == winTerm::Ansi) {
setWinColorAnsi(os, value);
} else {
setWinColorNative(os, value);
}
return os;
}
#else
template <typename T>
inline enableStd<T> setColor(std::ostream &os, T const value)
{
return os << "\033[" << static_cast<int>(value) << "m";
}
#endif
} // namespace rang_implementation
template <typename T>
inline rang_implementation::enableStd<T> operator<<(std::ostream &os,
const T value)
{
const control option = rang_implementation::controlMode();
switch (option) {
case control::Auto:
return rang_implementation::supportsColor()
&& rang_implementation::isTerminal(os.rdbuf())
? rang_implementation::setColor(os, value)
: os;
case control::Force: return rang_implementation::setColor(os, value);
default: return os;
}
}
inline void setWinTermMode(const rang::winTerm value) noexcept
{
rang_implementation::winTermMode() = value;
}
inline void setControlMode(const control value) noexcept
{
rang_implementation::controlMode() = value;
}
} // namespace rang
#undef OS_LINUX
#undef OS_WIN
#undef OS_MAC
#endif /* ifndef RANG_DOT_HPP */
+2 -7
View File
@@ -34,13 +34,8 @@
* Manifest: https://github.com/EQEmu/Server/blob/master/utils/sql/db_update_manifest.txt
*/
#define CURRENT_BINARY_DATABASE_VERSION 9215
#ifdef BOTS
#define CURRENT_BINARY_BOTS_DATABASE_VERSION 9035
#else
#define CURRENT_BINARY_BOTS_DATABASE_VERSION 0 // must be 0
#endif
#define CURRENT_BINARY_DATABASE_VERSION 9217
#define CURRENT_BINARY_BOTS_DATABASE_VERSION 9036
#define COMPILE_DATE __DATE__
#define COMPILE_TIME __TIME__
+7 -7
View File
@@ -30,7 +30,7 @@ void ZoneStore::LoadZones(Database &db)
{
m_zones = ZoneRepository::All(db);
LogInfo("[ZoneStore] Loaded [{}] zones", m_zones.size());
LogInfo("Loaded [{}] zones", m_zones.size());
}
/**
@@ -60,7 +60,7 @@ uint32 ZoneStore::GetZoneID(std::string zone_name)
}
}
LogInfo("[GetZoneID] Failed to get zone_name [{}]", zone_name);
LogInfo("Failed to get zone_name [{}]", zone_name);
return 0;
}
@@ -117,7 +117,7 @@ std::string ZoneStore::GetZoneName(uint32 zone_id)
}
}
LogInfo("[GetZoneName] Failed to get zone long name by zone_id [{}]", zone_id);
LogInfo("Failed to get zone long name by zone_id [{}]", zone_id);
return {};
}
@@ -134,7 +134,7 @@ std::string ZoneStore::GetZoneLongName(uint32 zone_id)
}
}
LogInfo("[GetZoneLongName] Failed to get zone long name by zone_id [{}]", zone_id);
LogInfo("Failed to get zone long name by zone_id [{}]", zone_id);
return {};
}
@@ -152,7 +152,7 @@ ZoneRepository::Zone *ZoneStore::GetZone(uint32 zone_id, int version)
}
}
LogInfo("[GetZone] Failed to get zone by zone_id [{}] version [{}]", zone_id, version);
LogInfo("Failed to get zone by zone_id [{}] version [{}]", zone_id, version);
return nullptr;
}
@@ -169,7 +169,7 @@ ZoneRepository::Zone *ZoneStore::GetZone(const char *in_zone_name)
}
}
LogInfo("[GetZone] Failed to get zone by zone_name [{}]", in_zone_name);
LogInfo("Failed to get zone by zone_name [{}]", in_zone_name);
return nullptr;
}
@@ -206,7 +206,7 @@ ZoneRepository::Zone *ZoneStore::GetZoneWithFallback(uint32 zone_id, int version
}
}
LogInfo("[GetZoneWithFallback] Failed to get zone by zone_id [{}] version [{}]", zone_id, version);
LogInfo("Failed to get zone by zone_id [{}] version [{}]", zone_id, version);
return nullptr;
}
+6 -6
View File
@@ -150,7 +150,7 @@ uint32 AccountManagement::CheckLoginserverUserCredentials(
if (!login_server_admin.loaded) {
LogError(
"CheckLoginUserCredentials account [{0}] source_loginserver [{1}] not found!",
"account [{0}] source_loginserver [{1}] not found!",
in_account_username,
source_loginserver
);
@@ -167,7 +167,7 @@ uint32 AccountManagement::CheckLoginserverUserCredentials(
if (!validated_credentials) {
LogError(
"CheckLoginUserCredentials account [{0}] source_loginserver [{1}] invalid credentials!",
"account [{0}] source_loginserver [{1}] invalid credentials!",
in_account_username,
source_loginserver
);
@@ -176,7 +176,7 @@ uint32 AccountManagement::CheckLoginserverUserCredentials(
}
LogInfo(
"CheckLoginUserCredentials account [{0}] source_loginserver [{1}] credentials validated success!",
"account [{0}] source_loginserver [{1}] credentials validated success!",
in_account_username,
source_loginserver
);
@@ -206,7 +206,7 @@ bool AccountManagement::UpdateLoginserverUserCredentials(
if (!login_server_account.loaded) {
LogError(
"ChangeLoginserverUserCredentials account [{0}] source_loginserver [{1}] not found!",
"account [{0}] source_loginserver [{1}] not found!",
in_account_username,
source_loginserver
);
@@ -225,7 +225,7 @@ bool AccountManagement::UpdateLoginserverUserCredentials(
);
LogInfo(
"ChangeLoginserverUserCredentials account [{0}] source_loginserver [{1}] credentials updated!",
"account [{0}] source_loginserver [{1}] credentials updated!",
in_account_username,
source_loginserver
);
@@ -401,7 +401,7 @@ uint32 AccountManagement::CheckExternalLoginserverUserCredentials(
while (running) {
std::chrono::steady_clock::time_point end = std::chrono::steady_clock::now();
if (std::chrono::duration_cast<std::chrono::milliseconds>(end - begin).count() > REQUEST_TIMEOUT_MS) {
LogInfo("[CheckExternalLoginserverUserCredentials] Deadline exceeded [{}]", REQUEST_TIMEOUT_MS);
LogInfo("Deadline exceeded [{}]", REQUEST_TIMEOUT_MS);
running = false;
}
+3 -3
View File
@@ -223,7 +223,7 @@ void Client::Handle_Login(const char *data, unsigned int size)
if (server.db->GetLoginDataFromAccountInfo(user, db_loginserver, db_account_password_hash, db_account_id)) {
result = VerifyLoginHash(user, db_loginserver, cred, db_account_password_hash);
LogDebug("[VerifyLoginHash] Success [{0}]", (result ? "true" : "false"));
LogDebug("Success [{0}]", (result ? "true" : "false"));
}
else {
m_client_status = cs_creating_account;
@@ -332,7 +332,7 @@ void Client::AttemptLoginAccountCreation(
const std::string &loginserver
)
{
LogInfo("[AttemptLoginAccountCreation] user [{}] loginserver [{}]", user, loginserver);
LogInfo("user [{}] loginserver [{}]", user, loginserver);
#ifdef LSPX
if (loginserver == "eqemu") {
@@ -351,7 +351,7 @@ void Client::AttemptLoginAccountCreation(
);
if (account_id > 0) {
LogInfo("[AttemptLoginAccountCreation] Found and creating eqemu account [{}]", account_id);
LogInfo("Found and creating eqemu account [{}]", account_id);
CreateEQEmuAccount(user, pass, account_id);
return;
}
+1 -1
View File
@@ -41,7 +41,7 @@ Database::Database(
exit(1);
}
else {
LogStatus("Using database [{0}] at [{1}:{2}]", name, host, port);
LogInfo("Using database [{0}] at [{1}:{2}]", name, host, port);
}
}
+4 -5
View File
@@ -148,6 +148,8 @@ void LoadServerConfig()
void start_web_server()
{
Sleep(1);
int web_api_port = server.config.GetVariableInt("web_api", "port", 6000);
LogInfo("Webserver API now listening on port [{0}]", web_api_port);
@@ -253,9 +255,6 @@ int main(int argc, char **argv)
#endif
LogInfo("Server Started");
if (LogSys.log_settings[Logs::Loginserver].log_to_console == 1) {
LogInfo("Loginserver logging set to level [1] for more debugging, enable detail [3]");
}
/**
* Web API
@@ -267,8 +266,8 @@ int main(int argc, char **argv)
}
LogInfo("[Config] [Account] CanAutoCreateAccounts [{0}]", server.options.CanAutoCreateAccounts());
LogInfo("[Config] [Client_Configuration] DisplayExpansions [{0}]", server.options.IsDisplayExpansions());
LogInfo("[Config] [Client_Configuration] MaxExpansions [{0}]", server.options.GetMaxExpansions());
LogInfo("[Config] [ClientConfiguration] DisplayExpansions [{0}]", server.options.IsDisplayExpansions());
LogInfo("[Config] [ClientConfiguration] MaxExpansions [{0}]", server.options.GetMaxExpansions());
#ifdef LSPX
LogInfo("[Config] [Account] CanAutoLinkAccounts [{0}]", server.options.CanAutoLinkAccounts());
+8 -8
View File
@@ -80,7 +80,7 @@ void WorldServer::Reset()
void WorldServer::ProcessNewLSInfo(uint16_t opcode, const EQ::Net::Packet &packet)
{
LogNetcode(
"[ProcessNewLSInfo] Application packet received from server [{:#04x}] [Size: {}]\n{}",
"Application packet received from server [{:#04x}] [Size: {}]\n{}",
opcode,
packet.Length(),
packet.ToString()
@@ -125,7 +125,7 @@ void WorldServer::ProcessNewLSInfo(uint16_t opcode, const EQ::Net::Packet &packe
void WorldServer::ProcessLSStatus(uint16_t opcode, const EQ::Net::Packet &packet)
{
LogNetcode(
"[ProcessLSStatus] Application packet received from server [{:#04x}] [Size: {}]\n{}",
"Application packet received from server [{:#04x}] [Size: {}]\n{}",
opcode,
packet.Length(),
packet.ToString()
@@ -159,7 +159,7 @@ void WorldServer::ProcessLSStatus(uint16_t opcode, const EQ::Net::Packet &packet
void WorldServer::ProcessUserToWorldResponseLegacy(uint16_t opcode, const EQ::Net::Packet &packet)
{
LogNetcode(
"[ProcessUserToWorldResponseLegacy] Application packet received from server [{:#04x}] [Size: {}]\n{}",
"Application packet received from server [{:#04x}] [Size: {}]\n{}",
opcode,
packet.Length(),
packet.ToString()
@@ -255,7 +255,7 @@ void WorldServer::ProcessUserToWorldResponseLegacy(uint16_t opcode, const EQ::Ne
void WorldServer::ProcessUserToWorldResponse(uint16_t opcode, const EQ::Net::Packet &packet)
{
LogNetcode(
"[ProcessUserToWorldResponse] Application packet received from server [{:#04x}] [Size: {}]\n{}",
"Application packet received from server [{:#04x}] [Size: {}]\n{}",
opcode,
packet.Length(),
packet.ToString()
@@ -362,7 +362,7 @@ void WorldServer::ProcessUserToWorldResponse(uint16_t opcode, const EQ::Net::Pac
void WorldServer::ProcessLSAccountUpdate(uint16_t opcode, const EQ::Net::Packet &packet)
{
LogNetcode(
"[ProcessLSAccountUpdate] Application packet received from server [{:#04x}] [Size: {}]\n{}",
"Application packet received from server [{:#04x}] [Size: {}]\n{}",
opcode,
packet.Length(),
packet.ToString()
@@ -458,7 +458,7 @@ void WorldServer::Handle_NewLSInfo(ServerNewLSInfo_Struct *new_world_server_info
if (login_server_admin.loaded) {
LogDebug(
"WorldServer::Handle_NewLSInfo | Attempting to authenticate world admin... [{0}] ({1}) against worldserver [{2}]",
"Attempting to authenticate world admin... [{0}] ({1}) against worldserver [{2}]",
GetAccountName(),
login_server_admin.id,
GetServerShortName()
@@ -471,7 +471,7 @@ void WorldServer::Handle_NewLSInfo(ServerNewLSInfo_Struct *new_world_server_info
login_server_admin.account_password
)) {
LogDebug(
"WorldServer::Handle_NewLSInfo | Authenticating world admin... [{0}] ({1}) success! World ({2})",
"Authenticating world admin... [{0}] ({1}) success! World ({2})",
GetAccountName(),
login_server_admin.id,
GetServerShortName()
@@ -600,7 +600,7 @@ void WorldServer::SendClientAuth(
m_connection->Send(ServerOP_LSClientAuth, outapp);
LogNetcode(
"[ServerOP_LSClientAuth] Sending [{:#04x}] [Size: {}]\n{}",
"Sending [{:#04x}] [Size: {}]\n{}",
ServerOP_LSClientAuth,
outapp.Length(),
outapp.ToString()
+8
View File
@@ -0,0 +1,8 @@
{
"name": "eqemu-server",
"version": "22.0.8",
"repository": {
"type": "git",
"url": "https://github.com/EQEmu/Server.git"
}
}
+9 -57
View File
@@ -50,56 +50,8 @@
#include "../common/strings.h"
#include "../common/servertalk.h"
Database::Database()
{
DBInitVars();
}
/*
Establish a connection to a mysql database with the supplied parameters
*/
Database::Database(const char *host, const char *user, const char *passwd, const char *database, uint32 port)
{
DBInitVars();
Connect(host, user, passwd, database, port);
}
bool Database::Connect(const char *host, const char *user, const char *passwd, const char *database, uint32 port)
{
uint32 errnum = 0;
char errbuf[MYSQL_ERRMSG_SIZE];
if (!Open(host, user, passwd, database, port, &errnum, errbuf)) {
LogError("Failed to connect to database: Error: {}", errbuf);
HandleMysqlError(errnum);
return false;
}
else {
LogInfo("Using database [{}] at [{}]:[{}]", database, host, port);
return true;
}
}
void Database::DBInitVars()
{
}
void Database::HandleMysqlError(uint32 errnum)
{
}
/*
Close the connection to the database
*/
Database::~Database()
{
}
void Database::AddSpeech(
void QSDatabase::AddSpeech(
const char *from,
const char *to,
const char *message,
@@ -134,7 +86,7 @@ void Database::AddSpeech(
}
void Database::LogPlayerDropItem(QSPlayerDropItem_Struct *QS)
void QSDatabase::LogPlayerDropItem(QSPlayerDropItem_Struct *QS)
{
std::string query = StringFormat(
@@ -173,7 +125,7 @@ void Database::LogPlayerDropItem(QSPlayerDropItem_Struct *QS)
}
}
void Database::LogPlayerTrade(QSPlayerLogTrade_Struct *QS, uint32 detailCount)
void QSDatabase::LogPlayerTrade(QSPlayerLogTrade_Struct *QS, uint32 detailCount)
{
std::string query = StringFormat(
@@ -220,7 +172,7 @@ void Database::LogPlayerTrade(QSPlayerLogTrade_Struct *QS, uint32 detailCount)
}
void Database::LogPlayerHandin(QSPlayerLogHandin_Struct *QS, uint32 detailCount)
void QSDatabase::LogPlayerHandin(QSPlayerLogHandin_Struct *QS, uint32 detailCount)
{
std::string query = StringFormat(
@@ -269,7 +221,7 @@ void Database::LogPlayerHandin(QSPlayerLogHandin_Struct *QS, uint32 detailCount)
}
void Database::LogPlayerNPCKill(QSPlayerLogNPCKill_Struct *QS, uint32 members)
void QSDatabase::LogPlayerNPCKill(QSPlayerLogNPCKill_Struct *QS, uint32 members)
{
std::string query = StringFormat(
@@ -306,7 +258,7 @@ void Database::LogPlayerNPCKill(QSPlayerLogNPCKill_Struct *QS, uint32 members)
}
void Database::LogPlayerDelete(QSPlayerLogDelete_Struct *QS, uint32 items)
void QSDatabase::LogPlayerDelete(QSPlayerLogDelete_Struct *QS, uint32 items)
{
std::string query = StringFormat(
@@ -345,7 +297,7 @@ void Database::LogPlayerDelete(QSPlayerLogDelete_Struct *QS, uint32 items)
}
void Database::LogPlayerMove(QSPlayerLogMove_Struct *QS, uint32 items)
void QSDatabase::LogPlayerMove(QSPlayerLogMove_Struct *QS, uint32 items)
{
/* These are item moves */
@@ -385,7 +337,7 @@ void Database::LogPlayerMove(QSPlayerLogMove_Struct *QS, uint32 items)
}
}
void Database::LogMerchantTransaction(QSMerchantLogTransaction_Struct *QS, uint32 items)
void QSDatabase::LogMerchantTransaction(QSMerchantLogTransaction_Struct *QS, uint32 items)
{
/* Merchant transactions are from the perspective of the merchant, not the player */
std::string query = StringFormat(
@@ -433,7 +385,7 @@ void Database::LogMerchantTransaction(QSMerchantLogTransaction_Struct *QS, uint3
}
// this function does not delete the ServerPacket, so it must be handled at call site
void Database::GeneralQueryReceive(ServerPacket *pack)
void QSDatabase::GeneralQueryReceive(ServerPacket *pack)
{
/*
These are general queries passed from anywhere in zone instead of packing structures and breaking them down again and again
+2 -7
View File
@@ -26,7 +26,7 @@
#include "../common/eqemu_logsys.h"
#include "../common/global_define.h"
#include "../common/types.h"
#include "../common/dbcore.h"
#include "../common/database.h"
#include "../common/linked_list.h"
#include "../common/servertalk.h"
#include <string>
@@ -36,13 +36,8 @@
//atoi is not uint32 or uint32 safe!!!!
#define atoul(str) strtoul(str, nullptr, 10)
class Database : public DBcore {
class QSDatabase : public Database {
public:
Database();
Database(const char* host, const char* user, const char* passwd, const char* database,uint32 port);
bool Connect(const char* host, const char* user, const char* passwd, const char* database,uint32 port);
~Database();
void AddSpeech(const char* from, const char* to, const char* message, uint16 minstatus, uint32 guilddbid, uint8 type);
void LogPlayerTrade(QSPlayerLogTrade_Struct* QS, uint32 DetailCount);
void LogPlayerDropItem(QSPlayerDropItem_Struct* QS);
+1 -1
View File
@@ -8,7 +8,7 @@
#include "../common/rulesys.h"
extern WorldServer *worldserver;
extern Database database;
extern QSDatabase database;
PlayerLookingForGuild::PlayerLookingForGuild(char *Name, char *Comments, uint32 Level, uint32 Class, uint32 AACount, uint32 Timezone, uint32 TimePosted)
{
+3 -1
View File
@@ -32,19 +32,21 @@
#include "lfguild.h"
#include "worldserver.h"
#include "../common/path_manager.h"
#include "../common/zone_store.h"
#include <list>
#include <signal.h>
#include <thread>
volatile bool RunLoops = true;
Database database;
QSDatabase database;
LFGuildManager lfguildmanager;
std::string WorldShortName;
const queryservconfig *Config;
WorldServer *worldserver = 0;
EQEmuLogSys LogSys;
PathManager path;
ZoneStore zone_store;
void CatchSignal(int sig_num)
{
+1 -1
View File
@@ -39,7 +39,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
extern WorldServer worldserver;
extern const queryservconfig *Config;
extern Database database;
extern QSDatabase database;
extern LFGuildManager lfguildmanager;
WorldServer::WorldServer()
-5
View File
@@ -164,13 +164,9 @@ int main(int argc, char **argv)
if (!RuleManager::Instance()->LoadRules(&database, "default", false)) {
LogInfo("No rule set configured, using default rules");
}
else {
LogInfo("Loaded default rule set 'default'");
}
}
EQ::InitializeDynamicLookups();
LogInfo("Initialized dynamic dictionary entries");
}
@@ -272,7 +268,6 @@ int main(int argc, char **argv)
}
if (load_all || load_factions) {
LogInfo("Loading factions");
try {
LoadFactions(&content_db, hotfix_name);
} catch (std::exception &ex) {
+283 -125
View File
@@ -25,7 +25,7 @@
#include <cstdlib>
#include <algorithm>
extern Database database;
extern UCSDatabase database;
extern uint32 ChatMessagesSent;
void ServerToClient45SayLink(std::string& clientSayLink, const std::string& serverSayLink);
@@ -33,33 +33,33 @@ void ServerToClient50SayLink(std::string& clientSayLink, const std::string& serv
void ServerToClient55SayLink(std::string& clientSayLink, const std::string& serverSayLink);
ChatChannel::ChatChannel(std::string inName, std::string inOwner, std::string inPassword, bool inPermanent, int inMinimumStatus) :
DeleteTimer(0) {
m_delete_timer(0) {
Name = inName;
m_name = inName;
Owner = inOwner;
m_owner = inOwner;
Password = inPassword;
m_password = inPassword;
Permanent = inPermanent;
m_permanent = inPermanent;
MinimumStatus = inMinimumStatus;
m_minimum_status = inMinimumStatus;
Moderated = false;
m_moderated = false;
LogDebug(
"New ChatChannel created: Name: [[{}]], Owner: [[{}]], Password: [[{}]], MinStatus: [{}]",
Name.c_str(),
Owner.c_str(),
Password.c_str(),
MinimumStatus
"New ChatChannel created: Name: [{}], Owner: [{}], Password: [{}], MinStatus: [{}]",
m_name.c_str(),
m_owner.c_str(),
m_password.c_str(),
m_minimum_status
);
}
ChatChannel::~ChatChannel() {
LinkedListIterator<Client*> iterator(ClientsInChannel);
LinkedListIterator<Client*> iterator(m_clients_in_channel);
iterator.Reset();
@@ -67,18 +67,79 @@ ChatChannel::~ChatChannel() {
iterator.RemoveCurrent(false);
}
ChatChannel* ChatChannelList::CreateChannel(std::string Name, std::string Owner, std::string Password, bool Permanent, int MinimumStatus) {
ChatChannel *ChatChannelList::CreateChannel(
const std::string& name,
const std::string& owner,
const std::string& password,
bool permanent,
int minimum_status,
bool save_to_db
)
{
uint8 max_perm_player_channels = RuleI(Chat, MaxPermanentPlayerChannels);
ChatChannel *NewChannel = new ChatChannel(CapitaliseName(Name), Owner, Password, Permanent, MinimumStatus);
if (!database.CheckChannelNameFilter(name)) {
if (!(owner == SYSTEM_OWNER)) {
return nullptr;
}
else {
LogDebug("Ignoring Name Filter as channel is owned by System...");
}
}
ChatChannels.Insert(NewChannel);
if (IsOnChannelBlockList(name)) {
if (!(owner == SYSTEM_OWNER)) {
LogInfo("Channel name [{}] is a reserved/blocked channel name. Channel creation canceled.", name);
return nullptr;
}
else {
LogInfo("Ignoring reserved/blocked channel name [{}] as channel is owned by System...", name);
}
}
else {
LogDebug("Channel name [{}] passed the reserved/blocked channel name check...", name);
}
return NewChannel;
auto *new_channel = new ChatChannel(CapitaliseName(name), owner, password, permanent, minimum_status);
ChatChannels.Insert(new_channel);
if (owner == SYSTEM_OWNER) {
save_to_db = false;
}
// If permanent player channels are enabled (and not a system channel)
// save channel to database if not exceeding limit.
bool can_save_channel = (max_perm_player_channels > 0) && !(owner == SYSTEM_OWNER) && save_to_db;
if (can_save_channel) {
// Ensure there is room to save another chat channel to the database.
bool player_under_channel_limit = database.CurrentPlayerChannelCount(owner) + 1 <= max_perm_player_channels;
if (player_under_channel_limit) {
database.SaveChatChannel(
CapitaliseName(name),
owner,
password,
minimum_status
);
}
else {
LogDebug(
"Maximum number of channels [{}] reached for player [{}], channel [{}] save to database aborted.",
max_perm_player_channels,
owner,
CapitaliseName(name)
);
}
}
return new_channel;
}
ChatChannel* ChatChannelList::FindChannel(std::string Name) {
std::string NormalisedName = CapitaliseName(Name);
std::string normalized_name = CapitaliseName(Name);
LinkedListIterator<ChatChannel*> iterator(ChatChannels);
@@ -86,9 +147,9 @@ ChatChannel* ChatChannelList::FindChannel(std::string Name) {
while(iterator.MoreElements()) {
ChatChannel *CurrentChannel = iterator.GetData();
auto *current_channel = iterator.GetData();
if(CurrentChannel && (CurrentChannel->Name == NormalisedName))
if(current_channel && (current_channel->m_name == normalized_name))
return iterator.GetData();
iterator.Advance();
@@ -159,7 +220,7 @@ void ChatChannelList::SendAllChannels(Client *c) {
void ChatChannelList::RemoveChannel(ChatChannel *Channel) {
LogDebug("RemoveChannel ([{}])", Channel->GetName().c_str());
LogDebug("Remove channel [{}]", Channel->GetName().c_str());
LinkedListIterator<ChatChannel*> iterator(ChatChannels);
@@ -194,7 +255,7 @@ int ChatChannel::MemberCount(int Status) {
int Count = 0;
LinkedListIterator<Client*> iterator(ClientsInChannel);
LinkedListIterator<Client*> iterator(m_clients_in_channel);
iterator.Reset();
@@ -211,30 +272,43 @@ int ChatChannel::MemberCount(int Status) {
return Count;
}
void ChatChannel::SetPassword(std::string inPassword) {
void ChatChannel::SetPassword(const std::string& in_password) {
Password = inPassword;
m_password = in_password;
if(Permanent)
if(m_permanent)
{
RemoveApostrophes(Password);
database.SetChannelPassword(Name, Password);
RemoveApostrophes(m_password);
database.SetChannelPassword(m_name, m_password);
}
}
void ChatChannel::SetOwner(std::string inOwner) {
void ChatChannel::SetOwner(std::string& in_owner) {
Owner = inOwner;
m_owner = in_owner;
if(Permanent)
database.SetChannelOwner(Name, Owner);
if(m_permanent)
database.SetChannelOwner(m_name, m_owner);
}
// Returns the owner's name in type std::string()
std::string& ChatChannel::GetOwnerName() {
return m_owner;
}
void ChatChannel::SetTemporary() {
m_permanent = false;
}
void ChatChannel::SetPermanent() {
m_permanent = true;
}
void ChatChannel::AddClient(Client *c) {
if(!c) return;
DeleteTimer.Disable();
m_delete_timer.Disable();
if(IsClientInChannel(c)) {
@@ -247,9 +321,9 @@ void ChatChannel::AddClient(Client *c) {
int AccountStatus = c->GetAccountStatus();
LogDebug("Adding [{}] to channel [{}]", c->GetName().c_str(), Name.c_str());
LogDebug("Adding [{}] to channel [{}]", c->GetName().c_str(), m_name.c_str());
LinkedListIterator<Client*> iterator(ClientsInChannel);
LinkedListIterator<Client*> iterator(m_clients_in_channel);
iterator.Reset();
@@ -264,7 +338,7 @@ void ChatChannel::AddClient(Client *c) {
iterator.Advance();
}
ClientsInChannel.Insert(c);
m_clients_in_channel.Insert(c);
}
@@ -272,46 +346,46 @@ bool ChatChannel::RemoveClient(Client *c) {
if(!c) return false;
LogDebug("RemoveClient [{}] from channel [{}]", c->GetName().c_str(), GetName().c_str());
LogDebug("Remove client [{}] from channel [{}]", c->GetName().c_str(), GetName().c_str());
bool HideMe = c->GetHideMe();
bool hide_me = c->GetHideMe();
int AccountStatus = c->GetAccountStatus();
int account_status = c->GetAccountStatus();
int PlayersInChannel = 0;
int players_in_channel = 0;
LinkedListIterator<Client*> iterator(ClientsInChannel);
LinkedListIterator<Client*> iterator(m_clients_in_channel);
iterator.Reset();
while(iterator.MoreElements()) {
Client *CurrentClient = iterator.GetData();
auto *current_client = iterator.GetData();
if(CurrentClient == c) {
if(current_client == c) {
iterator.RemoveCurrent(false);
}
else if(CurrentClient) {
else if(current_client) {
PlayersInChannel++;
players_in_channel++;
if(CurrentClient->IsAnnounceOn())
if(!HideMe || (CurrentClient->GetAccountStatus() > AccountStatus))
CurrentClient->AnnounceLeave(this, c);
if(current_client->IsAnnounceOn())
if(!hide_me || (current_client->GetAccountStatus() > account_status))
current_client->AnnounceLeave(this, c);
iterator.Advance();
}
}
if((PlayersInChannel == 0) && !Permanent) {
if((players_in_channel == 0) && !m_permanent) {
if((Password.length() == 0) || (RuleI(Channels, DeleteTimer) == 0))
if((m_password.length() == 0) || (RuleI(Channels, DeleteTimer) == 0))
return false;
LogDebug("Starting delete timer for empty password protected channel [{}]", Name.c_str());
LogDebug("Starting delete timer for empty password protected channel [{}]", m_name.c_str());
DeleteTimer.Start(RuleI(Channels, DeleteTimer) * 60000);
m_delete_timer.Start(RuleI(Channels, DeleteTimer) * 60000);
}
return true;
@@ -322,9 +396,9 @@ void ChatChannel::SendOPList(Client *c)
if (!c)
return;
c->GeneralChannelMessage("Channel " + Name + " op-list: (Owner=" + Owner + ")");
c->GeneralChannelMessage("Channel " + m_name + " op-list: (Owner=" + m_owner + ")");
for (auto &&m : Moderators)
for (auto &&m : m_moderators)
c->GeneralChannelMessage(m);
}
@@ -350,7 +424,7 @@ void ChatChannel::SendChannelMembers(Client *c) {
int MembersInLine = 0;
LinkedListIterator<Client*> iterator(ClientsInChannel);
LinkedListIterator<Client*> iterator(m_clients_in_channel);
iterator.Reset();
@@ -389,7 +463,7 @@ void ChatChannel::SendChannelMembers(Client *c) {
}
void ChatChannel::SendMessageToChannel(std::string Message, Client* Sender) {
void ChatChannel::SendMessageToChannel(const std::string& Message, Client* Sender) {
if(!Sender) return;
@@ -397,40 +471,40 @@ void ChatChannel::SendMessageToChannel(std::string Message, Client* Sender) {
ChatMessagesSent++;
LinkedListIterator<Client*> iterator(ClientsInChannel);
LinkedListIterator<Client*> iterator(m_clients_in_channel);
iterator.Reset();
while(iterator.MoreElements()) {
Client *ChannelClient = iterator.GetData();
auto *channel_client = iterator.GetData();
if(ChannelClient)
if(channel_client)
{
LogDebug("Sending message to [{}] from [{}]",
ChannelClient->GetName().c_str(), Sender->GetName().c_str());
channel_client->GetName().c_str(), Sender->GetName().c_str());
if (cv_messages[static_cast<uint32>(ChannelClient->GetClientVersion())].length() == 0) {
switch (ChannelClient->GetClientVersion()) {
if (cv_messages[static_cast<uint32>(channel_client->GetClientVersion())].length() == 0) {
switch (channel_client->GetClientVersion()) {
case EQ::versions::ClientVersion::Titanium:
ServerToClient45SayLink(cv_messages[static_cast<uint32>(ChannelClient->GetClientVersion())], Message);
ServerToClient45SayLink(cv_messages[static_cast<uint32>(channel_client->GetClientVersion())], Message);
break;
case EQ::versions::ClientVersion::SoF:
case EQ::versions::ClientVersion::SoD:
case EQ::versions::ClientVersion::UF:
ServerToClient50SayLink(cv_messages[static_cast<uint32>(ChannelClient->GetClientVersion())], Message);
ServerToClient50SayLink(cv_messages[static_cast<uint32>(channel_client->GetClientVersion())], Message);
break;
case EQ::versions::ClientVersion::RoF:
ServerToClient55SayLink(cv_messages[static_cast<uint32>(ChannelClient->GetClientVersion())], Message);
ServerToClient55SayLink(cv_messages[static_cast<uint32>(channel_client->GetClientVersion())], Message);
break;
case EQ::versions::ClientVersion::RoF2:
default:
cv_messages[static_cast<uint32>(ChannelClient->GetClientVersion())] = Message;
cv_messages[static_cast<uint32>(channel_client->GetClientVersion())] = Message;
break;
}
}
ChannelClient->SendChannelMessage(Name, cv_messages[static_cast<uint32>(ChannelClient->GetClientVersion())], Sender);
channel_client->SendChannelMessage(m_name, cv_messages[static_cast<uint32>(channel_client->GetClientVersion())], Sender);
}
iterator.Advance();
@@ -439,9 +513,9 @@ void ChatChannel::SendMessageToChannel(std::string Message, Client* Sender) {
void ChatChannel::SetModerated(bool inModerated) {
Moderated = inModerated;
m_moderated = inModerated;
LinkedListIterator<Client*> iterator(ClientsInChannel);
LinkedListIterator<Client*> iterator(m_clients_in_channel);
iterator.Reset();
@@ -451,10 +525,10 @@ void ChatChannel::SetModerated(bool inModerated) {
if(ChannelClient) {
if(Moderated)
ChannelClient->GeneralChannelMessage("Channel " + Name + " is now moderated.");
if(m_moderated)
ChannelClient->GeneralChannelMessage("Channel " + m_name + " is now moderated.");
else
ChannelClient->GeneralChannelMessage("Channel " + Name + " is no longer moderated.");
ChannelClient->GeneralChannelMessage("Channel " + m_name + " is no longer moderated.");
}
iterator.Advance();
@@ -465,7 +539,7 @@ bool ChatChannel::IsClientInChannel(Client *c) {
if(!c) return false;
LinkedListIterator<Client*> iterator(ClientsInChannel);
LinkedListIterator<Client*> iterator(m_clients_in_channel);
iterator.Reset();
@@ -480,54 +554,80 @@ bool ChatChannel::IsClientInChannel(Client *c) {
return false;
}
ChatChannel *ChatChannelList::AddClientToChannel(std::string ChannelName, Client *c) {
ChatChannel *ChatChannelList::AddClientToChannel(std::string channel_name, Client *c, bool command_directed) {
if(!c) return nullptr;
if((ChannelName.length() > 0) && (isdigit(ChannelName[0]))) {
if ((channel_name.length() > 0) && (isdigit(channel_name[0]))) { // Ensure channel name does not start with a number
c->GeneralChannelMessage("The channel name can not begin with a number.");
return nullptr;
}
else if (channel_name.empty()) { // Ensure channel name is not empty
return nullptr;
}
std::string NormalisedName, Password;
std::string normalized_name, password;
std::string::size_type Colon = ChannelName.find_first_of(":");
std::string::size_type Colon = channel_name.find_first_of(":");
if(Colon == std::string::npos)
NormalisedName = CapitaliseName(ChannelName);
normalized_name = CapitaliseName(channel_name);
else {
NormalisedName = CapitaliseName(ChannelName.substr(0, Colon));
normalized_name = CapitaliseName(channel_name.substr(0, Colon));
Password = ChannelName.substr(Colon + 1);
password = channel_name.substr(Colon + 1);
}
if((NormalisedName.length() > 64) || (Password.length() > 64)) {
if((normalized_name.length() > 64) || (password.length() > 64)) {
c->GeneralChannelMessage("The channel name or password cannot exceed 64 characters.");
return nullptr;
}
LogDebug("AddClient to channel [[{}]] with password [[{}]]", NormalisedName.c_str(), Password.c_str());
ChatChannel *RequiredChannel = FindChannel(normalized_name);
ChatChannel *RequiredChannel = FindChannel(NormalisedName);
if (RequiredChannel) {
if (IsOnChannelBlockList(channel_name)) { // Ensure channel name is not blocked
if (!(RequiredChannel->GetOwnerName() == SYSTEM_OWNER)) {
c->GeneralChannelMessage("That channel name is blocked by the server operator.");
return nullptr;
}
else {
LogDebug("Reserved/blocked channel name check for [{}] ignored due to channel being owned by System...", normalized_name);
}
}
}
if(!RequiredChannel)
RequiredChannel = CreateChannel(NormalisedName, c->GetName(), Password, false, 0);
const std::string& channel_owner = c->GetName();
if(RequiredChannel->GetMinStatus() > c->GetAccountStatus()) {
bool permanent = false;
if (command_directed && RuleI(Chat, MaxPermanentPlayerChannels) > 0) {
permanent = true;
}
std::string Message = "You do not have the required account status to join channel " + NormalisedName;
if (!RequiredChannel) {
RequiredChannel = CreateChannel(normalized_name, channel_owner, password, permanent, 0, command_directed);
if (RequiredChannel == nullptr) {
LogDebug("Failed to create new channel with name: {}. Possible blocked or reserved channel name.", normalized_name);
c->GeneralChannelMessage("Failed to create new channel with provided name. Possible blocked or reserved channel name.");
return nullptr;
}
LogDebug("Created and added Client to channel [{}] with password [{}]. Owner: {}. Command Directed: {}", normalized_name.c_str(), password.c_str(), channel_owner, command_directed);
}
LogDebug("Checking status requirement of channel: {}. Channel status required: {}, player status: {}.", normalized_name, std::to_string(RequiredChannel->GetMinStatus()), std::to_string(c->GetAccountStatus()));
if (RequiredChannel->GetMinStatus() > c->GetAccountStatus()) {
std::string Message = "You do not have the required account status to join channel " + normalized_name;
c->GeneralChannelMessage(Message);
LogInfo("Client [{}] connection to channel [{}] refused due to insufficient status.", c->GetName(), normalized_name);
return nullptr;
}
if(RequiredChannel->IsClientInChannel(c))
if (RequiredChannel->IsClientInChannel(c)) {
return nullptr;
}
if(RequiredChannel->IsInvitee(c->GetName())) {
@@ -538,7 +638,7 @@ ChatChannel *ChatChannelList::AddClientToChannel(std::string ChannelName, Client
return RequiredChannel;
}
if(RequiredChannel->CheckPassword(Password) || RequiredChannel->IsOwner(c->GetName()) || RequiredChannel->IsModerator(c->GetName()) ||
if(RequiredChannel->CheckPassword(password) || RequiredChannel->IsOwner(c->GetName()) || RequiredChannel->IsModerator(c->GetName()) ||
c->IsChannelAdmin()) {
RequiredChannel->AddClient(c);
@@ -546,32 +646,42 @@ ChatChannel *ChatChannelList::AddClientToChannel(std::string ChannelName, Client
return RequiredChannel;
}
c->GeneralChannelMessage("Incorrect password for channel " + (NormalisedName));
c->GeneralChannelMessage("Incorrect password for channel " + (normalized_name));
return nullptr;
}
ChatChannel *ChatChannelList::RemoveClientFromChannel(std::string inChannelName, Client *c) {
ChatChannel *ChatChannelList::RemoveClientFromChannel(const std::string& in_channel_name, Client *c, bool command_directed) {
if(!c) return nullptr;
std::string ChannelName = inChannelName;
std::string channel_name = in_channel_name;
if((inChannelName.length() > 0) && isdigit(ChannelName[0]))
ChannelName = c->ChannelSlotName(atoi(inChannelName.c_str()));
if (in_channel_name.length() > 0 && isdigit(channel_name[0])) {
channel_name = c->ChannelSlotName(atoi(in_channel_name.c_str()));
}
ChatChannel *RequiredChannel = FindChannel(ChannelName);
auto *required_channel = FindChannel(channel_name);
if(!RequiredChannel)
if (!required_channel) {
return nullptr;
}
LogDebug("Client [{}] removed from channel [{}]. Channel is owned by {}. Command directed: {}", c->GetName(), channel_name, required_channel->GetOwnerName(), command_directed);
if (c->GetName() == required_channel->GetOwnerName() && command_directed) { // Check if the client that is leaving is the the channel owner
LogDebug("Owner left the channel [{}], removing channel from database...", channel_name);
database.DeleteChatChannel(channel_name); // Remove the channel from the database.
LogDebug("Flagging [{}] channel as temporary...", channel_name);
required_channel->SetTemporary();
}
// RemoveClient will return false if there is no-one left in the channel, and the channel is not permanent and has
// no password.
//
if(!RequiredChannel->RemoveClient(c))
RemoveChannel(RequiredChannel);
if (!required_channel->RemoveClient(c)) {
LogDebug("Noone left in the temporary channel [{}] and no password is set; removing temporary channel.", channel_name);
RemoveChannel(required_channel);
}
return RequiredChannel;
return required_channel;
}
void ChatChannelList::Process() {
@@ -600,76 +710,76 @@ void ChatChannelList::Process() {
void ChatChannel::AddInvitee(const std::string &Invitee)
{
if (!IsInvitee(Invitee)) {
Invitees.push_back(Invitee);
m_invitees.push_back(Invitee);
LogDebug("Added [{}] as invitee to channel [{}]", Invitee.c_str(), Name.c_str());
LogDebug("Added [{}] as invitee to channel [{}]", Invitee.c_str(), m_name.c_str());
}
}
void ChatChannel::RemoveInvitee(std::string Invitee)
{
auto it = std::find(std::begin(Invitees), std::end(Invitees), Invitee);
auto it = std::find(std::begin(m_invitees), std::end(m_invitees), Invitee);
if(it != std::end(Invitees)) {
Invitees.erase(it);
LogDebug("Removed [{}] as invitee to channel [{}]", Invitee.c_str(), Name.c_str());
if(it != std::end(m_invitees)) {
m_invitees.erase(it);
LogDebug("Removed [{}] as invitee to channel [{}]", Invitee.c_str(), m_name.c_str());
}
}
bool ChatChannel::IsInvitee(std::string Invitee)
{
return std::find(std::begin(Invitees), std::end(Invitees), Invitee) != std::end(Invitees);
return std::find(std::begin(m_invitees), std::end(m_invitees), Invitee) != std::end(m_invitees);
}
void ChatChannel::AddModerator(const std::string &Moderator)
{
if (!IsModerator(Moderator)) {
Moderators.push_back(Moderator);
m_moderators.push_back(Moderator);
LogInfo("Added [{}] as moderator to channel [{}]", Moderator.c_str(), Name.c_str());
LogInfo("Added [{}] as moderator to channel [{}]", Moderator.c_str(), m_name.c_str());
}
}
void ChatChannel::RemoveModerator(const std::string &Moderator)
{
auto it = std::find(std::begin(Moderators), std::end(Moderators), Moderator);
auto it = std::find(std::begin(m_moderators), std::end(m_moderators), Moderator);
if (it != std::end(Moderators)) {
Moderators.erase(it);
LogInfo("Removed [{}] as moderator to channel [{}]", Moderator.c_str(), Name.c_str());
if (it != std::end(m_moderators)) {
m_moderators.erase(it);
LogInfo("Removed [{}] as moderator to channel [{}]", Moderator.c_str(), m_name.c_str());
}
}
bool ChatChannel::IsModerator(std::string Moderator)
{
return std::find(std::begin(Moderators), std::end(Moderators), Moderator) != std::end(Moderators);
return std::find(std::begin(m_moderators), std::end(m_moderators), Moderator) != std::end(m_moderators);
}
void ChatChannel::AddVoice(const std::string &inVoiced)
{
if (!HasVoice(inVoiced)) {
Voiced.push_back(inVoiced);
m_voiced.push_back(inVoiced);
LogInfo("Added [{}] as voiced to channel [{}]", inVoiced.c_str(), Name.c_str());
LogInfo("Added [{}] as voiced to channel [{}]", inVoiced.c_str(), m_name.c_str());
}
}
void ChatChannel::RemoveVoice(const std::string &inVoiced)
{
auto it = std::find(std::begin(Voiced), std::end(Voiced), inVoiced);
auto it = std::find(std::begin(m_voiced), std::end(m_voiced), inVoiced);
if (it != std::end(Voiced)) {
Voiced.erase(it);
if (it != std::end(m_voiced)) {
m_voiced.erase(it);
LogInfo("Removed [{}] as voiced to channel [{}]", inVoiced.c_str(), Name.c_str());
LogInfo("Removed [{}] as voiced to channel [{}]", inVoiced.c_str(), m_name.c_str());
}
}
bool ChatChannel::HasVoice(std::string inVoiced)
{
return std::find(std::begin(Voiced), std::end(Voiced), inVoiced) != std::end(Voiced);
return std::find(std::begin(m_voiced), std::end(m_voiced), inVoiced) != std::end(m_voiced);
}
std::string CapitaliseName(std::string inString) {
@@ -687,6 +797,54 @@ std::string CapitaliseName(std::string inString) {
return NormalisedName;
}
bool ChatChannelList::IsOnChannelBlockList(const std::string& channel_name) {
if (channel_name.empty()) {
return false;
}
// Check if channel_name is already in the BlockedChannelNames vector
return Strings::Contains(GetBlockedChannelNames(), channel_name);
}
bool ChatChannelList::IsOnFilteredNameList(const std::string& name) {
if (name.empty()) {
return false;
}
// Check if name is already in the filtered name vector
return Strings::Contains(GetFilteredNames(), name);
}
void ChatChannelList::AddToChannelBlockList(const std::string& channel_name) {
if (channel_name.empty()) {
return;
}
// Check if channelName is already in the BlockedChannelNames vector
bool is_found = Strings::Contains(ChatChannelList::GetBlockedChannelNames(), channel_name);
// Add channelName to the BlockedChannelNames vector if it is not already present
if (!is_found) {
auto blocked_channel_names = GetBlockedChannelNames(); // Get current blocked list
blocked_channel_names.push_back(channel_name); // Add new name to local blocked list
SetChannelBlockList(blocked_channel_names); // Set blocked list to match local blocked list
}
}
void ChatChannelList::AddToFilteredNames(const std::string& name) {
if (name.empty()) {
return;
}
// Add name to the filtered names vector if it is not already present
if (!Strings::Contains(ChatChannelList::GetFilteredNames(), name)) {
auto filtered_names = GetFilteredNames(); // Get current filter name list
filtered_names.push_back(name); // Add new name to local filtered names list
SetFilteredNameList(filtered_names); // Set filtered names list to match local filtered names list
}
}
void ServerToClient45SayLink(std::string& clientSayLink, const std::string& serverSayLink) {
if (serverSayLink.find('\x12') == std::string::npos) {
clientSayLink = serverSayLink;
+42 -26
View File
@@ -9,6 +9,8 @@
class Client;
#define SYSTEM_OWNER std::string("*System*")
class ChatChannel {
public:
@@ -21,15 +23,19 @@ public:
bool IsClientInChannel(Client *c);
int MemberCount(int Status);
const std::string &GetName() { return Name; }
void SendMessageToChannel(std::string Message, Client* Sender);
bool CheckPassword(std::string inPassword) { return Password.empty() || Password == inPassword; }
void SetPassword(std::string inPassword);
bool IsOwner(std::string Name) { return (Owner == Name); }
void SetOwner(std::string inOwner);
const std::string &GetName() { return m_name; }
void SendMessageToChannel(const std::string& Message, Client* Sender);
bool CheckPassword(const std::string& in_password) { return m_password.empty() || m_password == in_password; }
void SetPassword(const std::string& in_password);
bool IsOwner(const std::string& name) { return (m_owner == name); }
const std::string& GetPassword() { return m_password; }
void SetOwner(std::string& inOwner);
std::string& GetOwnerName();
void SetTemporary();
void SetPermanent();
void SendChannelMembers(Client *c);
int GetMinStatus() { return MinimumStatus; }
bool ReadyToDelete() { return DeleteTimer.Check(); }
int GetMinStatus() { return m_minimum_status; }
bool ReadyToDelete() { return m_delete_timer.Check(); }
void SendOPList(Client *c);
void AddInvitee(const std::string &Invitee);
void RemoveInvitee(std::string Invitee);
@@ -40,48 +46,58 @@ public:
void AddVoice(const std::string &Voiced);
void RemoveVoice(const std::string &Voiced);
bool HasVoice(std::string Voiced);
inline bool IsModerated() { return Moderated; }
inline bool IsModerated() { return m_moderated; }
void SetModerated(bool inModerated);
friend class ChatChannelList;
private:
std::string Name;
std::string Owner;
std::string Password;
std::string m_name;
std::string m_owner;
std::string m_password;
bool Permanent;
bool Moderated;
bool m_permanent;
bool m_moderated;
int MinimumStatus;
int m_minimum_status;
Timer DeleteTimer;
Timer m_delete_timer;
LinkedList<Client*> ClientsInChannel;
LinkedList<Client*> m_clients_in_channel;
std::vector<std::string> Moderators;
std::vector<std::string> Invitees;
std::vector<std::string> Voiced;
std::vector<std::string> m_moderators;
std::vector<std::string> m_invitees;
std::vector<std::string> m_voiced;
};
class ChatChannelList {
public:
ChatChannel* CreateChannel(std::string Name, std::string Owner, std::string Passwordi, bool Permanent, int MinimumStatus = 0);
ChatChannel* FindChannel(std::string Name);
ChatChannel* AddClientToChannel(std::string Channel, Client *c);
ChatChannel* RemoveClientFromChannel(std::string Channel, Client *c);
void RemoveClientFromAllChannels(Client *c);
ChatChannel* CreateChannel(const std::string& name, const std::string& owner, const std::string& password, bool permanent, int minimum_status, bool save_to_database = false);
ChatChannel* FindChannel(std::string name);
ChatChannel* AddClientToChannel(std::string channel_name, Client* c, bool command_directed = false);
ChatChannel* RemoveClientFromChannel(const std::string& in_channel_name, Client* c, bool command_directed = false);
void RemoveChannel(ChatChannel *Channel);
void RemoveAllChannels();
void SendAllChannels(Client *c);
void Process();
static inline std::vector<std::string> GetBlockedChannelNames() { return m_blocked_channel_names; }
static inline std::vector<std::string> GetFilteredNames() { return m_filtered_names; }
static inline void ClearChannelBlockList() { m_blocked_channel_names.clear(); };
static inline void ClearFilteredNameList() { m_filtered_names.clear(); };
static void AddToChannelBlockList(const std::string& channel_name);
static void AddToFilteredNames(const std::string& name);
static bool IsOnChannelBlockList(const std::string& channel_name);
static bool IsOnFilteredNameList(const std::string& channel_name);
static inline void SetChannelBlockList(std::vector<std::string> new_list) { m_blocked_channel_names = new_list; }
static inline void SetFilteredNameList(std::vector<std::string> new_list) { m_filtered_names = new_list; }
private:
LinkedList<ChatChannel*> ChatChannels;
static inline std::vector<std::string> m_blocked_channel_names;
static inline std::vector<std::string> m_filtered_names;
};
+134 -94
View File
@@ -34,7 +34,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#include <cstdlib>
#include <algorithm>
extern Database database;
extern UCSDatabase database;
extern std::string WorldShortName;
extern std::string GetMailPrefix();
extern ChatChannelList *ChannelList;
@@ -48,8 +48,10 @@ int LookupCommand(const char *ChatCommand) {
for (int i = 0; i < CommandEndOfList; i++) {
if (!strcasecmp(Commands[i].CommandString, ChatCommand))
if (!strcasecmp(Commands[i].CommandString, ChatCommand)) {
return Commands[i].CommandCode;
}
}
return -1;
@@ -487,7 +489,7 @@ Clientlist::Clientlist(int ChatPort) {
exit(1);
chatsf->OnNewConnection([this](std::shared_ptr<EQ::Net::EQStream> stream) {
LogF(Logs::General, Logs::Loginserver, "New Client UDP connection from {0}:{1}", stream->GetRemoteIP(), stream->GetRemotePort());
LogInfo("New Client UDP connection from [{0}] [{1}]", stream->GetRemoteIP(), stream->GetRemotePort());
stream->SetOpcodeManager(&ChatOpMgr);
auto c = new Client(stream);
@@ -594,6 +596,28 @@ void Clientlist::CheckForStaleConnections(Client *c) {
}
}
std::string RemoveDuplicateChannels(const std::string& in_channels) {
// Split the string by ", " and store the names in a vector
std::vector<std::string> channel_names = Strings::Split(in_channels, ", ");
// Remove duplicates by inserting the names of the channels into an unordered set
// and then copying the unique elements back into the original vector
std::unordered_set<std::string> unique_channels;
channel_names.erase(
std::remove_if(
channel_names.begin(), channel_names.end(),
[&unique_channels](const std::string &channel) {
return !unique_channels.insert(channel).second;
}
), channel_names.end()
);
// Concatenate the names of the unique channels into a single string
std::string unique_channels_string = Strings::Implode(", ", channel_names);
return unique_channels_string;
}
void Clientlist::Process()
{
auto it = ClientChatConnections.begin();
@@ -682,10 +706,18 @@ void Clientlist::Process()
CheckForStaleConnections((*it));
break;
}
case OP_Mail: {
std::string CommandString = (const char *)app->pBuffer + 1;
ProcessOPMailCommand((*it), CommandString);
std::string command_string = (const char *)app->pBuffer + 1;
bool command_directed = false;
if (command_string.empty()) {
break;
}
if (Strings::Contains(Strings::ToLower(command_string), "leave")) {
command_directed = true;
}
ProcessOPMailCommand((*it), command_string, command_directed);
break;
}
@@ -716,106 +748,112 @@ void Clientlist::Process()
}
}
void Clientlist::ProcessOPMailCommand(Client *c, std::string CommandString)
void Clientlist::ProcessOPMailCommand(Client *c, std::string command_string, bool command_directed)
{
if (CommandString.length() == 0)
if (command_string.length() == 0)
return;
if (isdigit(CommandString[0]))
if (isdigit(command_string[0]))
{
c->SendChannelMessageByNumber(CommandString);
c->SendChannelMessageByNumber(command_string);
return;
}
if (CommandString[0] == '#') {
if (command_string[0] == '#') {
c->SendChannelMessage(CommandString);
c->SendChannelMessage(command_string);
return;
}
std::string Command, Parameters;
std::string command, parameters;
std::string::size_type Space = CommandString.find_first_of(" ");
std::string::size_type Space = command_string.find_first_of(" ");
if (Space != std::string::npos) {
Command = CommandString.substr(0, Space);
command = command_string.substr(0, Space);
std::string::size_type ParametersStart = CommandString.find_first_not_of(" ", Space);
std::string::size_type parameters_start = command_string.find_first_not_of(" ", Space);
if (ParametersStart != std::string::npos)
Parameters = CommandString.substr(ParametersStart);
if (parameters_start != std::string::npos)
parameters = command_string.substr(parameters_start);
}
else {
command = command_string;
}
else
Command = CommandString;
int CommandCode = LookupCommand(Command.c_str());
switch (CommandCode) {
auto command_code = LookupCommand(command.c_str());
switch (command_code) {
case CommandJoin:
c->JoinChannels(Parameters);
if (!command_directed) {
//Append saved channels to params
parameters = parameters + ", " + database.CurrentPlayerChannels(c->GetName());
parameters = RemoveDuplicateChannels(parameters);
}
c->JoinChannels(parameters, command_directed);
break;
case CommandLeaveAll:
c->LeaveAllChannels();
c->LeaveAllChannels(true, true);
break;
case CommandLeave:
c->LeaveChannels(Parameters);
c->LeaveChannels(parameters, command_directed);
break;
case CommandListAll:
ChannelList->SendAllChannels(c);
break;
case CommandList:
c->ProcessChannelList(Parameters);
c->ProcessChannelList(parameters);
break;
case CommandSet:
c->LeaveAllChannels(false);
c->JoinChannels(Parameters);
c->JoinChannels(parameters, command_directed);
break;
case CommandAnnounce:
c->ToggleAnnounce(Parameters);
c->ToggleAnnounce(parameters);
break;
case CommandSetOwner:
c->SetChannelOwner(Parameters);
c->SetChannelOwner(parameters);
break;
case CommandOPList:
c->OPList(Parameters);
c->OPList(parameters);
break;
case CommandInvite:
c->ChannelInvite(Parameters);
c->ChannelInvite(parameters);
break;
case CommandGrant:
c->ChannelGrantModerator(Parameters);
c->ChannelGrantModerator(parameters);
break;
case CommandModerate:
c->ChannelModerate(Parameters);
c->ChannelModerate(parameters);
break;
case CommandVoice:
c->ChannelGrantVoice(Parameters);
c->ChannelGrantVoice(parameters);
break;
case CommandKick:
c->ChannelKick(Parameters);
c->ChannelKick(parameters);
break;
case CommandPassword:
c->SetChannelPassword(Parameters);
c->SetChannelPassword(parameters);
break;
case CommandToggleInvites:
@@ -834,43 +872,44 @@ void Clientlist::ProcessOPMailCommand(Client *c, std::string CommandString)
break;
case CommandGetBody:
database.SendBody(c, atoi(Parameters.c_str()));
database.SendBody(c, atoi(parameters.c_str()));
break;
case CommandMailTo:
ProcessMailTo(c, Parameters);
ProcessMailTo(c, parameters);
break;
case CommandSetMessageStatus:
LogInfo("Set Message Status, Params: [{}]", Parameters.c_str());
ProcessSetMessageStatus(Parameters);
LogInfo("Set Message Status, Params: [{}]", parameters.c_str());
ProcessSetMessageStatus(parameters);
break;
case CommandSelectMailBox:
{
std::string::size_type NumStart = Parameters.find_first_of("0123456789");
c->ChangeMailBox(atoi(Parameters.substr(NumStart).c_str()));
std::string::size_type NumStart = parameters.find_first_of("0123456789");
c->ChangeMailBox(atoi(parameters.substr(NumStart).c_str()));
break;
}
case CommandSetMailForwarding:
break;
case CommandBuddy:
RemoveApostrophes(Parameters);
ProcessCommandBuddy(c, Parameters);
RemoveApostrophes(parameters);
ProcessCommandBuddy(c, parameters);
break;
case CommandIgnorePlayer:
RemoveApostrophes(Parameters);
ProcessCommandIgnore(c, Parameters);
RemoveApostrophes(parameters);
ProcessCommandIgnore(c, parameters);
break;
default:
c->SendHelp();
LogInfo("Unhandled OP_Mail command: [{}]", CommandString.c_str());
LogInfo("Unhandled OP_Mail command: [{}]", command_string.c_str());
}
}
void Clientlist::CloseAllConnections() {
@@ -992,51 +1031,51 @@ int Client::ChannelCount() {
}
void Client::JoinChannels(std::string ChannelNameList) {
void Client::JoinChannels(std::string& channel_name_list, bool command_directed) {
for (auto &elem : ChannelNameList) {
for (auto &elem : channel_name_list) {
if (elem == '%') {
elem = '/';
}
}
LogInfo("Client: [{}] joining channels [{}]", GetName().c_str(), ChannelNameList.c_str());
LogInfo("Client: [{}] joining channels [{}]", GetName().c_str(), channel_name_list.c_str());
int NumberOfChannels = ChannelCount();
auto number_of_channels = ChannelCount();
std::string::size_type CurrentPos = ChannelNameList.find_first_not_of(" ");
auto current_pos = channel_name_list.find_first_not_of(" ");
while (CurrentPos != std::string::npos) {
while (current_pos != std::string::npos) {
if (NumberOfChannels == MAX_JOINED_CHANNELS) {
if (number_of_channels == MAX_JOINED_CHANNELS) {
GeneralChannelMessage("You have joined the maximum number of channels. /leave one before trying to join another.");
break;
}
std::string::size_type Comma = ChannelNameList.find_first_of(", ", CurrentPos);
auto comma = channel_name_list.find_first_of(", ", current_pos);
if (Comma == std::string::npos) {
if (comma == std::string::npos) {
auto* joined_channel = ChannelList->AddClientToChannel(channel_name_list.substr(current_pos), this, command_directed);
ChatChannel* JoinedChannel = ChannelList->AddClientToChannel(ChannelNameList.substr(CurrentPos), this);
if (JoinedChannel)
AddToChannelList(JoinedChannel);
if (joined_channel) {
AddToChannelList(joined_channel);
}
break;
}
ChatChannel* JoinedChannel = ChannelList->AddClientToChannel(ChannelNameList.substr(CurrentPos, Comma - CurrentPos), this);
auto* joined_channel = ChannelList->AddClientToChannel(channel_name_list.substr(current_pos, comma - current_pos), this, command_directed);
if (JoinedChannel) {
if (joined_channel) {
AddToChannelList(JoinedChannel);
AddToChannelList(joined_channel);
NumberOfChannels++;
number_of_channels++;
}
CurrentPos = ChannelNameList.find_first_not_of(", ", Comma);
current_pos = channel_name_list.find_first_not_of(", ", comma);
}
std::string JoinedChannelsList, ChannelMessage;
@@ -1097,37 +1136,36 @@ void Client::JoinChannels(std::string ChannelNameList) {
safe_delete(outapp);
}
void Client::LeaveChannels(std::string ChannelNameList) {
void Client::LeaveChannels(std::string& channel_name_list, bool command_directed) {
LogInfo("Client: [{}] leaving channels [{}]", GetName().c_str(), channel_name_list.c_str());
LogInfo("Client: [{}] leaving channels [{}]", GetName().c_str(), ChannelNameList.c_str());
auto current_pos = 0;
std::string::size_type CurrentPos = 0;
while (current_pos != std::string::npos) {
while (CurrentPos != std::string::npos) {
std::string::size_type Comma = ChannelNameList.find_first_of(", ", CurrentPos);
std::string::size_type Comma = channel_name_list.find_first_of(", ", current_pos);
if (Comma == std::string::npos) {
ChatChannel* JoinedChannel = ChannelList->RemoveClientFromChannel(ChannelNameList.substr(CurrentPos), this);
auto* joined_channel = ChannelList->RemoveClientFromChannel(channel_name_list.substr(current_pos), this, command_directed);
if (JoinedChannel)
RemoveFromChannelList(JoinedChannel);
if (joined_channel)
RemoveFromChannelList(joined_channel);
break;
}
ChatChannel* JoinedChannel = ChannelList->RemoveClientFromChannel(ChannelNameList.substr(CurrentPos, Comma - CurrentPos), this);
auto* joined_channel = ChannelList->RemoveClientFromChannel(channel_name_list.substr(current_pos, Comma - current_pos), this, command_directed);
if (JoinedChannel)
RemoveFromChannelList(JoinedChannel);
if (joined_channel)
RemoveFromChannelList(joined_channel);
CurrentPos = ChannelNameList.find_first_not_of(", ", Comma);
current_pos = channel_name_list.find_first_not_of(", ", Comma);
}
std::string JoinedChannelsList, ChannelMessage;
std::string joined_channels_list, channel_message;
ChannelMessage = "Channels: ";
channel_message = "Channels: ";
char tmp[200];
@@ -1139,26 +1177,26 @@ void Client::LeaveChannels(std::string ChannelNameList) {
if (ChannelCount) {
JoinedChannelsList = JoinedChannelsList + ",";
joined_channels_list = joined_channels_list + ",";
ChannelMessage = ChannelMessage + ",";
channel_message = channel_message + ",";
}
JoinedChannelsList = JoinedChannelsList + JoinedChannels[i]->GetName();
joined_channels_list = joined_channels_list + JoinedChannels[i]->GetName();
sprintf(tmp, "%i=%s(%i)", i + 1, JoinedChannels[i]->GetName().c_str(), JoinedChannels[i]->MemberCount(Status));
ChannelMessage += tmp;
channel_message += tmp;
ChannelCount++;
}
}
auto outapp = new EQApplicationPacket(OP_Mail, JoinedChannelsList.length() + 1);
auto outapp = new EQApplicationPacket(OP_Mail, joined_channels_list.length() + 1);
char *PacketBuffer = (char *)outapp->pBuffer;
sprintf(PacketBuffer, "%s", JoinedChannelsList.c_str());
sprintf(PacketBuffer, "%s", joined_channels_list.c_str());
QueuePacket(outapp);
@@ -1166,15 +1204,15 @@ void Client::LeaveChannels(std::string ChannelNameList) {
safe_delete(outapp);
if (ChannelCount == 0)
ChannelMessage = "You are not on any channels.";
channel_message = "You are not on any channels.";
outapp = new EQApplicationPacket(OP_ChannelMessage, ChannelMessage.length() + 3);
outapp = new EQApplicationPacket(OP_ChannelMessage, channel_message.length() + 3);
PacketBuffer = (char *)outapp->pBuffer;
VARSTRUCT_ENCODE_TYPE(uint8, PacketBuffer, 0x00);
VARSTRUCT_ENCODE_TYPE(uint8, PacketBuffer, 0x00);
VARSTRUCT_ENCODE_STRING(PacketBuffer, ChannelMessage.c_str());
VARSTRUCT_ENCODE_STRING(PacketBuffer, channel_message.c_str());
QueuePacket(outapp);
@@ -1182,19 +1220,19 @@ void Client::LeaveChannels(std::string ChannelNameList) {
safe_delete(outapp);
}
void Client::LeaveAllChannels(bool SendUpdatedChannelList) {
void Client::LeaveAllChannels(bool send_updated_channel_list, bool command_directed) {
for (auto &elem : JoinedChannels) {
if (elem) {
ChannelList->RemoveClientFromChannel(elem->GetName(), this);
ChannelList->RemoveClientFromChannel(elem->GetName(), this, command_directed);
elem = nullptr;
}
}
if (SendUpdatedChannelList)
if (send_updated_channel_list)
SendChannelList();
}
@@ -1643,6 +1681,7 @@ void Client::SetChannelPassword(std::string ChannelPassword) {
}
RequiredChannel->SetPassword(Password);
database.SaveChatChannel(RequiredChannel->GetName(), RequiredChannel->GetOwnerName(), Password, RequiredChannel->GetMinStatus()); // Update DB with new password
GeneralChannelMessage(Message);
@@ -1703,6 +1742,7 @@ void Client::SetChannelOwner(std::string CommandString) {
}
RequiredChannel->SetOwner(NewOwner);
database.SaveChatChannel(RequiredChannel->GetName(), NewOwner, RequiredChannel->GetPassword(), RequiredChannel->GetMinStatus()); // Update DB with new owner
if (RequiredChannel->IsModerator(NewOwner))
RequiredChannel->RemoveModerator(NewOwner);
@@ -2121,7 +2161,7 @@ void Client::ChannelKick(std::string CommandString) {
GeneralChannelMessage("Kicked " + Kickee + " from channel " + ChannelName);
RequiredClient->LeaveChannels(ChannelName);
RequiredClient->LeaveChannels(ChannelName, false);
}
void Client::ToggleInvites() {

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