mirror of
https://github.com/EQEmu/Server.git
synced 2026-06-01 10:11:37 +00:00
Compare commits
582 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| bbc331485c | |||
| 0815aea6fd | |||
| 76f8f1fb95 | |||
| 7acff368ea | |||
| 012c54c277 | |||
| 4c7964524d | |||
| 5843ff0524 | |||
| a648d09b1b | |||
| 408bd653bc | |||
| d378f8b107 | |||
| daa9102cc6 | |||
| 04d947a40e | |||
| 1db4882cda | |||
| ccb3cef3d7 | |||
| 1f37254f1a | |||
| 32e04ea74c | |||
| 6027c56d9e | |||
| 612a248612 | |||
| aee5be9f18 | |||
| b261856917 | |||
| f64e29433e | |||
| 42a3780d80 | |||
| e544f72da0 | |||
| 587422bdc1 | |||
| f4717b8414 | |||
| 64329f3e59 | |||
| feaf907210 | |||
| 3f8746d33c | |||
| 1168d3bc37 | |||
| e81f36c0a6 | |||
| 9b3f9f356d | |||
| 47ff765ae1 | |||
| e42dc2e1d2 | |||
| 2239bba2c5 | |||
| 87076e8487 | |||
| 95b91431dd | |||
| 2d30df179c | |||
| 897512a43e | |||
| b9f8d7c3b1 | |||
| 625cfdb179 | |||
| f72474216f | |||
| af0fd14a38 | |||
| 2f78b6c2f3 | |||
| d61effbb8f | |||
| 0f7abb8c25 | |||
| 2faa3ec478 | |||
| 792bd3be96 | |||
| 97a34ded56 | |||
| c611a25385 | |||
| f74efcaa5f | |||
| eb4e7d694c | |||
| ecc0d4b5c0 | |||
| 8175ae6187 | |||
| e8f4ffd628 | |||
| 0447618f7e | |||
| e71ce001ff | |||
| 1575a2af40 | |||
| 4b69df646c | |||
| 044b9c1420 | |||
| 0bbb5b90e7 | |||
| 6506ad5b51 | |||
| dcaa0ecdaa | |||
| 9b143132be | |||
| 231bf8b4ec | |||
| dee58f9a91 | |||
| 1eb89edbbd | |||
| e015d0d67e | |||
| ba78394ce9 | |||
| 060f6e377d | |||
| 92c8b0e585 | |||
| 33df8ea665 | |||
| 9668074d94 | |||
| 822a5dcac4 | |||
| 0c65a4febe | |||
| 02f66de679 | |||
| 145111f11e | |||
| a4e47d9180 | |||
| 207ee2daa0 | |||
| 1fe5d9fa4f | |||
| ed3f6c2a40 | |||
| adb3196ca5 | |||
| e13b133ac8 | |||
| d475428157 | |||
| 00b66ce432 | |||
| 4d12dd5c43 | |||
| c4f408bffc | |||
| d876c6df2a | |||
| d142e1ca81 | |||
| d9f4d49ef4 | |||
| 0a1df5bbb6 | |||
| 41f3d7ff31 | |||
| 0afef19d26 | |||
| e9be2d76c3 | |||
| ffa813b92c | |||
| 909de47acd | |||
| 73a5f11e17 | |||
| 9544e100c3 | |||
| f3232cdc3a | |||
| b8884d6572 | |||
| 323a0c0b27 | |||
| ab45d4358d | |||
| f7775c7a75 | |||
| 659a960401 | |||
| 07d484597d | |||
| fc470d5f83 | |||
| 585ed3bd25 | |||
| 2eb291a461 | |||
| a1421af214 | |||
| 13aad6229f | |||
| 76d46ceaf0 | |||
| 389047c4e2 | |||
| 2c6d405b2c | |||
| 50ae0f8351 | |||
| dc261bb203 | |||
| 643ee56433 | |||
| c0bb32ed12 | |||
| c99bda3f47 | |||
| 967a13e692 | |||
| f304f9cc61 | |||
| 004e2ca63f | |||
| 128732e05d | |||
| 1e6a4dac78 | |||
| 654764685a | |||
| c5ab35e4af | |||
| 947795f1d1 | |||
| 1153c9ab96 | |||
| 2128b45313 | |||
| 4f7ff2d6f2 | |||
| b5f1e99d3b | |||
| 83918ce020 | |||
| f3aaeff0a9 | |||
| 98eff43346 | |||
| 46b43a990f | |||
| ea96cbf885 | |||
| de07870c99 | |||
| b3b228c26c | |||
| 27b5c80c3c | |||
| fb4d003e19 | |||
| f025e5741b | |||
| c3f2708f1b | |||
| 2e760d6397 | |||
| bac892b582 | |||
| 4005b68383 | |||
| 5ac9dd04e4 | |||
| f0c041e8b3 | |||
| 2f4a5b56dd | |||
| 940f97c9ae | |||
| f8ee664b27 | |||
| df86ad371b | |||
| e846bb86b6 | |||
| 3e6a3e2168 | |||
| 2aebf1a78a | |||
| 1be7e56b86 | |||
| a0ff9d67a1 | |||
| befee1c729 | |||
| 3d70063a68 | |||
| 4e28bcf85e | |||
| 687d10960a | |||
| 567d46c3d6 | |||
| 53cc2de459 | |||
| cb866cba31 | |||
| e2162c08da | |||
| e657953b8f | |||
| eb366e67b7 | |||
| 5b728a42f7 | |||
| a1d414d64c | |||
| 907029ed76 | |||
| 894f22fba0 | |||
| 7ec09d7e0f | |||
| c82266790a | |||
| ec31fddbae | |||
| fb49ce2404 | |||
| 276b7e238a | |||
| c7a463420b | |||
| a56bb52808 | |||
| 0bbdb58679 | |||
| f29478c105 | |||
| 888a88f966 | |||
| 3b617a6652 | |||
| c36c336bc7 | |||
| 4a9779635d | |||
| 20da490bda | |||
| 1221e88d92 | |||
| a2b28b2e16 | |||
| 3d607d352c | |||
| 83cd8119c8 | |||
| 4de8fbbd56 | |||
| 780120036d | |||
| f3697e633c | |||
| 24f8d88333 | |||
| 21bd906a4d | |||
| 138612bc88 | |||
| 5919bb4dea | |||
| 99d249fefd | |||
| c08f286817 | |||
| cd003ff0b7 | |||
| 1a539f6656 | |||
| 7e7fb7b758 | |||
| 5ae87b40e2 | |||
| 0ec07daebb | |||
| 9869da2a0a | |||
| 617eb4432b | |||
| a2b2a6a5cf | |||
| 43a5bff84a | |||
| e983d07228 | |||
| 90db12483a | |||
| ff71cfbd5b | |||
| 08bb9de437 | |||
| 16e341906d | |||
| 216b3a039f | |||
| b813cf71bb | |||
| 48ecd1222f | |||
| e758b407e9 | |||
| 758dd1875e | |||
| 8e2961dda5 | |||
| 5522eda6e4 | |||
| ac1469bac2 | |||
| c2989e019a | |||
| e16b481ba2 | |||
| 4fc0ffd173 | |||
| b883888a19 | |||
| 50ad97aa0b | |||
| dca892e258 | |||
| f9fe4ea2ec | |||
| cc30c72538 | |||
| d1fd40cd85 | |||
| f3af458cb3 | |||
| a093d04594 | |||
| 115df81400 | |||
| 5babc864b9 | |||
| 60a2dd8616 | |||
| 9be2485330 | |||
| a2bf10624a | |||
| ed58d16f1f | |||
| e9b45fb360 | |||
| 803972873a | |||
| d9e57eca79 | |||
| 6429dc80d3 | |||
| c4262b3fa6 | |||
| 92128b98fd | |||
| b9cfdea76c | |||
| c8a7066d0e | |||
| 950cc4a325 | |||
| 82b48fe6e8 | |||
| ca9c1fdd24 | |||
| fe08961d25 | |||
| 5b9f7ff4c9 | |||
| 23743a4050 | |||
| 444d688ad2 | |||
| d554eb3423 | |||
| deb298dda7 | |||
| 19e785b842 | |||
| 7b9691d486 | |||
| 30fddcc5a0 | |||
| 235e59a2d8 | |||
| bc1ffe0716 | |||
| 44497414db | |||
| 96e34fe8f7 | |||
| ceca28d2a3 | |||
| b040571427 | |||
| 49664cc1a0 | |||
| 5e4fd43920 | |||
| 937b947597 | |||
| bb70850421 | |||
| 46511365a7 | |||
| 6d69ac7a98 | |||
| 938937c271 | |||
| cd808416c8 | |||
| a05d0752f6 | |||
| 799609fb21 | |||
| 213fe6a9e9 | |||
| be6a5d5f50 | |||
| 1af29bd7b1 | |||
| ef945e6e99 | |||
| 9528c1e7fc | |||
| fd6e5f465d | |||
| d00125abe1 | |||
| 5d69235a4c | |||
| e93785f885 | |||
| 3c2545cfaf | |||
| 8d1a9efac9 | |||
| f6b18fb003 | |||
| 00e77f190c | |||
| 9cb72a6ba7 | |||
| 8203c034bf | |||
| 33ae51f56f | |||
| 30c39194a3 | |||
| 051ce3736f | |||
| 84708edccf | |||
| da4e9ab95b | |||
| a8fea95eab | |||
| 53610c2f0f | |||
| 9f10c12874 | |||
| a0634adb3c | |||
| a2ed6be1f5 | |||
| c33ac40567 | |||
| 9ee095b354 | |||
| 7ab32af4dc | |||
| 0c301419c2 | |||
| d6a21be25e | |||
| 1d4ba082ad | |||
| 94553501ba | |||
| da824d5178 | |||
| 5a1df38900 | |||
| 8cd7148b29 | |||
| 09e079a45e | |||
| 4bc881da4b | |||
| 0615864d51 | |||
| 3638d157b2 | |||
| d41725e325 | |||
| 88580b69b6 | |||
| f7a6fe595a | |||
| 07d14c2681 | |||
| eac7a73fb6 | |||
| c5715f1f14 | |||
| 3902230fa1 | |||
| 212969f5cd | |||
| de4226fdc9 | |||
| 8b13434197 | |||
| 27274397ec | |||
| 2b79a36014 | |||
| 8cf52294e9 | |||
| 0ef79903f8 | |||
| ab14458f9e | |||
| 5b94e736b3 | |||
| c3b8cc9744 | |||
| 89e3b2c72e | |||
| 23c4aa241b | |||
| acb7584e26 | |||
| a885bd9322 | |||
| 20fe1926e0 | |||
| eb7118754b | |||
| 3611b49f68 | |||
| 511d8a8bb3 | |||
| 1598d2e17b | |||
| 805757ba87 | |||
| eb6ac25540 | |||
| cb634cf57d | |||
| 2f7ca2cdc8 | |||
| 425d24c1f4 | |||
| 875df8e64a | |||
| 7a2d2a0c51 | |||
| 5296202e56 | |||
| e2db8ffea8 | |||
| fa2ab11676 | |||
| 80e8634a48 | |||
| 98c2fa5127 | |||
| 8b8b41dab3 | |||
| 63b1e6b4b4 | |||
| 21b7b6e7ab | |||
| 878a5377ae | |||
| 486c7c44be | |||
| aa4869c6e9 | |||
| 94e1b4edfa | |||
| 4d73b7d641 | |||
| ed4f9b0d30 | |||
| f8837d0926 | |||
| 753d83c499 | |||
| f0108826d3 | |||
| 6ac846c003 | |||
| 44963f3f21 | |||
| 9fd935ef10 | |||
| 6f390c81f9 | |||
| 1bd281c8f2 | |||
| 49cf97ae9c | |||
| 8315240b17 | |||
| 55155ff800 | |||
| ab4e1191ef | |||
| c09fad5a75 | |||
| 8201175c2c | |||
| e88ea24966 | |||
| 02e2f6771c | |||
| 3b399dfac5 | |||
| 9aa0f7c695 | |||
| 3ba113a91d | |||
| b0c951bd6e | |||
| 8a5f885558 | |||
| fd3f5cfd29 | |||
| 74b8cf8bd3 | |||
| 18685748f6 | |||
| da24bf467a | |||
| e948a6815c | |||
| dfb089b0c1 | |||
| d9d2d5d47c | |||
| ac4ffefa09 | |||
| c228604255 | |||
| 59292b15f6 | |||
| 843f6531a7 | |||
| 432452c5c7 | |||
| f3a2f97155 | |||
| 9e07d90664 | |||
| 4fe229c475 | |||
| 4658e7f60d | |||
| 95559b2e17 | |||
| 7ad63575c7 | |||
| bc6b21f601 | |||
| 05c7e6409d | |||
| 60ba76b39c | |||
| 41009aa19b | |||
| ed7023f336 | |||
| e0d95b4302 | |||
| 537b585791 | |||
| 1a48add20e | |||
| 1650efa787 | |||
| 0dde51f518 | |||
| 5cebc42f89 | |||
| 7021602bf4 | |||
| 752ac78c56 | |||
| e9678da311 | |||
| 51f25ed779 | |||
| 8f4f8368df | |||
| 21d27a1122 | |||
| 6519fb40c7 | |||
| ff2763785c | |||
| f1852e16b7 | |||
| 49917bfb13 | |||
| ff86cc3b8a | |||
| 91a0e14509 | |||
| 6fb919a16f | |||
| d1d6db3a09 | |||
| e3ab90695f | |||
| aa423e398a | |||
| 1cf7709c9d | |||
| f466964db8 | |||
| 4fda3c045e | |||
| 0a20100d12 | |||
| 29701d0ea7 | |||
| 4a38fd8829 | |||
| 08c8e0d81f | |||
| c966f26ac1 | |||
| fe66c24352 | |||
| bdcded7d45 | |||
| f939f25aa1 | |||
| 401f1038f3 | |||
| 95c6560e7c | |||
| 59f645b5c3 | |||
| bbfed8300c | |||
| 07c762068f | |||
| 6525051d2d | |||
| b7f94e8315 | |||
| d1f368ab7f | |||
| 1f3ac2dc4f | |||
| 7a226ca4ef | |||
| 119151c0e3 | |||
| faa8a492f7 | |||
| 2926b4df78 | |||
| 986eda44aa | |||
| b2f71f16fc | |||
| 861eac3660 | |||
| a376bc4471 | |||
| e83d0942ad | |||
| 31abaf8016 | |||
| 0acad18067 | |||
| 90c37390f1 | |||
| dba494cd8e | |||
| 37ced4b003 | |||
| d13c725a74 | |||
| 25826c6686 | |||
| 1a27127c39 | |||
| 75698a809f | |||
| 37a7b7fc41 | |||
| f21cc170df | |||
| d47bf687d0 | |||
| 035c51944f | |||
| c2ebc2540a | |||
| c82f1b9afc | |||
| 15684567cf | |||
| 533dc997fd | |||
| 03b30d5c7a | |||
| d89f9bdcc7 | |||
| 490cffb5ea | |||
| d95b64e0b8 | |||
| 1ed282f6ff | |||
| a3a498634f | |||
| c44596b38a | |||
| fe43d26dd6 | |||
| 3155b82abb | |||
| 4c6aaa6995 | |||
| c82dee575a | |||
| 33db85f2ee | |||
| b40e4ce7cd | |||
| 20ff325013 | |||
| 8a7d5e72cb | |||
| 4493ebebab | |||
| 77793f364e | |||
| e258aaa068 | |||
| 3b779ef301 | |||
| 3f3c0f2fda | |||
| 0f164c456e | |||
| 6172c49b08 | |||
| 66a7dd0143 | |||
| 5c6e7a8b09 | |||
| bd85fc96a0 | |||
| 8e40e5357c | |||
| 5f0b999ca9 | |||
| fe9df46a24 | |||
| 3d7cf4235c | |||
| 187ee10218 | |||
| 6bd758b3dd | |||
| 9938755517 | |||
| 630da0eee6 | |||
| 3158386aa3 | |||
| 12ada57ee8 | |||
| 7a841c11c5 | |||
| a49d1446b7 | |||
| b2d0fa6a2f | |||
| 62ac015fff | |||
| 4977a7c2e0 | |||
| 9967384ab8 | |||
| d3da2e5501 | |||
| 33f5c4c6a7 | |||
| e4aa6a6957 | |||
| e4d812f4b4 | |||
| bcedfe7032 | |||
| c1df3fbcb0 | |||
| 011e1d05e7 | |||
| 3f0f95976c | |||
| 77de9619b5 | |||
| 20d3ab2ac5 | |||
| 0ea47fadee | |||
| 1ce51ca3b0 | |||
| 25ef3d2cdb | |||
| 95249889a6 | |||
| 428cccfa50 | |||
| 41dd8a5754 | |||
| d02d766563 | |||
| dfd2729b28 | |||
| b92eafd21b | |||
| d6d5d992cb | |||
| d524cb6a5a | |||
| e6469878ce | |||
| 9583099ace | |||
| cf3483b402 | |||
| 311af7bbe9 | |||
| be42b73f5c | |||
| f76c798910 | |||
| ae198ae043 | |||
| 520943ebf1 | |||
| 9ac306fe67 | |||
| 7a1d69d0d4 | |||
| c873fe5a22 | |||
| e06b0c4b0c | |||
| ed2130f649 | |||
| 448a33a60c | |||
| 8f86cb353e | |||
| 178129443f | |||
| a7c3b41afc | |||
| a5a568d548 | |||
| e3198edb86 | |||
| 8568cf7d49 | |||
| 1fb7a860a1 | |||
| 7eaee2649e | |||
| a17f467b98 | |||
| 3359839a9b | |||
| 7e51e629f9 | |||
| dc6c28a52d | |||
| 78aee0780a | |||
| bcd943a964 | |||
| 56608e84bd | |||
| 8d23e710ce | |||
| 4d11077b21 | |||
| 5c0bdfdc4c | |||
| 6130e10831 | |||
| c3e1c531d2 | |||
| b52719a535 | |||
| 1af252466f | |||
| 699d22fc28 | |||
| 5d1fe68906 | |||
| 52dcf35425 | |||
| a7550fbd9e | |||
| cc0171dfe1 | |||
| 913c5da70f | |||
| 40fecbfaf5 | |||
| b1646381b0 | |||
| bb1578796b | |||
| 0e5a38f072 | |||
| 39876ab858 | |||
| ff16a76481 | |||
| ffd68eb63d | |||
| 76c1da1aad | |||
| a91e03fa43 | |||
| 453106439f |
@@ -1,6 +1,5 @@
|
|||||||
!Makefile
|
base/
|
||||||
base/*.sql
|
!base/*.json
|
||||||
base/*.zip
|
override/
|
||||||
base/db/
|
repo/
|
||||||
base/maps/
|
cache/
|
||||||
!base/expansion/Makefile
|
|
||||||
|
|||||||
+133
-189
@@ -1,196 +1,127 @@
|
|||||||
|
# Build binaries: make cmake, make build
|
||||||
|
# One time initial setup (or to reset db): make prep, make inject-mariadb, make maps
|
||||||
|
# Update custom db edits: make inject-custom
|
||||||
|
# Start up server: make shared, make login, make world, make zone
|
||||||
|
# in game, stop combat spam #logs set gmsay 79 0
|
||||||
|
# in game, stop loot spam #logs set gmsay 69 0
|
||||||
NAME := eqemu-server
|
NAME := eqemu-server
|
||||||
.ONESHELL:
|
|
||||||
|
|
||||||
DOCKER_ARGS := --rm --name ${NAME} -v $$PWD:/src -w /src ${NAME}
|
|
||||||
DOCKER_ARM64_ARGS := --rm --platform linux/arm64 --name ${NAME}-arm64 -v $$PWD:/src -w /src ${NAME}-arm64
|
|
||||||
|
|
||||||
.PHONY: build
|
|
||||||
build:
|
|
||||||
ifeq ($(findstring .devcontainer,$(CURDIR)),.devcontainer)
|
|
||||||
@make -C ../ -f .devcontainer/Makefile build --no-print-directory
|
|
||||||
exit
|
|
||||||
endif
|
|
||||||
cd build$$BUILD_SUFFIX && cmake --build . --config Release --target all --
|
|
||||||
|
|
||||||
.PHONY: cmake
|
|
||||||
cmake:
|
|
||||||
ifeq ($(findstring .devcontainer,$(CURDIR)),.devcontainer)
|
|
||||||
@make -C ../ -f .devcontainer/Makefile cmake --no-print-directory
|
|
||||||
exit
|
|
||||||
endif
|
|
||||||
@echo "working directory: $$PWD"
|
|
||||||
mkdir -p build$$BUILD_SUFFIX
|
|
||||||
@cd build$$BUILD_SUFFIX && cmake -DEQEMU_BUILD_LOGIN=ON \
|
|
||||||
-DEQEMU_BUILD_TESTS=ON \
|
|
||||||
-DCMAKE_CXX_COMPILER_LAUNCHER=ccache -G Ninja ..
|
|
||||||
|
|
||||||
clean:
|
|
||||||
ifneq (,$(findstring .devcontainer,$$PWD))
|
|
||||||
@make -C ../ -f .devcontainer/Makefile clean --no-print-directory
|
|
||||||
endif
|
|
||||||
rm -rf build
|
|
||||||
|
|
||||||
docker-cmake:
|
|
||||||
ifeq ($(findstring .devcontainer,$(CURDIR)),.devcontainer)
|
|
||||||
@make -C ../ -f .devcontainer/Makefile docker-cmake --no-print-directory
|
|
||||||
exit
|
|
||||||
endif
|
|
||||||
@echo "working directory: $$PWD"
|
|
||||||
git submodule update --init --recursive
|
|
||||||
docker run ${DOCKER_ARGS} make cmake
|
|
||||||
|
|
||||||
docker-build:
|
|
||||||
ifeq ($(findstring .devcontainer,$(CURDIR)),.devcontainer)
|
|
||||||
@make -C ../ -f .devcontainer/Makefile docker-build --no-print-directory
|
|
||||||
exit
|
|
||||||
endif
|
|
||||||
docker run ${DOCKER_ARGS} make build
|
|
||||||
|
|
||||||
# Build image if it doesn't exist
|
|
||||||
docker-image-build:
|
|
||||||
ifeq ($(findstring .devcontainer,$(CURDIR)),.devcontainer)
|
|
||||||
@make -C ../ -f .devcontainer/Makefile docker-image-build --no-print-directory
|
|
||||||
exit
|
|
||||||
endif
|
|
||||||
ifeq ($(shell docker images -q ${NAME} 2> /dev/null),)
|
|
||||||
@echo "Docker image not found. Building..."
|
|
||||||
docker build -f Dockerfile.debian.dev -t ${NAME} .
|
|
||||||
endif
|
|
||||||
|
|
||||||
docker-arm-cmake: docker-arm-image-build
|
|
||||||
ifeq ($(findstring .devcontainer,$(CURDIR)),.devcontainer)
|
|
||||||
@make -C ../ -f .devcontainer/Makefile docker-arm-cmake --no-print-directory
|
|
||||||
exit
|
|
||||||
endif
|
|
||||||
git submodule update --init --recursive
|
|
||||||
docker run ${DOCKER_ARM64_ARGS} make cmake BUILD_SUFFIX=arm64
|
|
||||||
|
|
||||||
docker-arm-build: docker-arm-image-build
|
|
||||||
ifeq ($(findstring .devcontainer,$(CURDIR)),.devcontainer)
|
|
||||||
@make -C ../ -f .devcontainer/Makefile docker-arm-build --no-print-directory
|
|
||||||
exit
|
|
||||||
endif
|
|
||||||
docker run ${DOCKER_ARM64_ARGS} make build BUILD_SUFFIX=arm64
|
|
||||||
|
|
||||||
docker-arm-image-build:
|
|
||||||
ifeq ($(shell docker images -q ${NAME}-arm64 2> /dev/null),)
|
|
||||||
@echo "Docker image not found. Building..."
|
|
||||||
docker build -f Dockerfile.debian.arm.dev -t ${NAME}-arm64 .
|
|
||||||
endif
|
|
||||||
|
|
||||||
docker-clean: clean
|
|
||||||
|
|
||||||
.PHONY: prep
|
.PHONY: prep
|
||||||
prep:
|
prep: is-vscode
|
||||||
ifeq ($(findstring .devcontainer,$(CURDIR)),.devcontainer)
|
|
||||||
@make -C ../ -f .devcontainer/Makefile prep --no-print-directory
|
|
||||||
exit
|
|
||||||
endif
|
|
||||||
@echo "Preparing build/bin for usage..."
|
@echo "Preparing build/bin for usage..."
|
||||||
mkdir -p build/bin/assets/patches
|
|
||||||
cp -R -u -p .devcontainer/base/eqemu_config.json build/bin/eqemu_config.json
|
@echo "Prepping folders..."
|
||||||
cp -R -u -p .devcontainer/base/login.json build/bin/login.json
|
@mkdir -p .devcontainer/override
|
||||||
cp -R -u -p loginserver/login_util/* build/bin/assets/patches/
|
@mkdir -p .devcontainer/repo
|
||||||
mkdir -p build/bin/assets
|
@mkdir -p .devcontainer/cache
|
||||||
cp -R -u -p utils/patches build/bin/assets/
|
@mkdir -p build/bin/logs
|
||||||
-unlink build/bin/lua_modules
|
@mkdir -p build/bin/shared
|
||||||
cd build/bin && ln -s quests/lua_modules lua_modules
|
@mkdir -p build/bin/assets
|
||||||
-unlink build/bin/mods
|
|
||||||
cd build/bin && ln -s quests/mods mods
|
@echo "Applying overrides..."
|
||||||
-unlink build/bin/maps
|
@if [ ! -f .devcontainer/override/eqemu_config.json ]; then cp .devcontainer/base/eqemu_config.json .devcontainer/override/eqemu_config.json; fi
|
||||||
cd build/bin && ln -s ../../base/maps maps
|
@if [ -f build/bin/eqemu_config.json ]; then unlink build/bin/eqemu_config.json; fi
|
||||||
mkdir -p build/bin/logs
|
cd build/bin && ln -s ../../.devcontainer/override/eqemu_config.json eqemu_config.json
|
||||||
mkdir -p build/bin/shared
|
@if [ ! -f .devcontainer/override/login.json ]; then cp .devcontainer/base/login.json .devcontainer/override/login.json; fi
|
||||||
|
@if [ -f build/bin/login.json ]; then unlink build/bin/login.json; fi
|
||||||
|
cd build/bin && ln -s ../../.devcontainer/override/login.json login.json
|
||||||
|
|
||||||
|
@echo "Cloning repositories..."
|
||||||
|
cd .devcontainer/repo && if [ ! -d "quests" ]; then cd ../../.devcontainer/repo/ && git clone https://github.com/ProjectEQ/projecteqquests.git quests; fi
|
||||||
|
cd .devcontainer/repo && if [ ! -d "eqemu-definitions" ]; then cd ../../.devcontainer/repo/ && git clone https://github.com/xackery/eqemu-definitions.git eqemu-definitions; fi
|
||||||
|
cd .devcontainer/repo && if [ ! -d "maps" ]; then cd ../../ && make maps; fi
|
||||||
|
@if [ -d build/bin/quests ]; then unlink build/bin/quests; fi
|
||||||
|
cd build/bin && ln -s ../../.devcontainer/repo/quests quests
|
||||||
|
@if [ -d build/bin/maps ]; then unlink build/bin/maps; fi
|
||||||
|
cd build/bin && ln -s ../../.devcontainer/repo/maps maps
|
||||||
|
@if [ -d build/bin/eqemu-definitions ]; then unlink build/bin/eqemu-definitions; fi
|
||||||
|
cd build/bin && ln -s ../../.devcontainer/repo/eqemu-definitions eqemu-definitions
|
||||||
|
@mkdir -p build/bin/quests/mods
|
||||||
|
|
||||||
|
@echo "Applying base links..."
|
||||||
|
cp -R -u -p utils/patches .devcontainer/base/
|
||||||
|
@if [ -d build/bin/assets/patches ]; then unlink build/bin/assets/patches; fi
|
||||||
|
cd build/bin/assets && ln -s ../../../.devcontainer/base/patches patches
|
||||||
|
@if [ -d build/bin/lua_modules ]; then unlink build/bin/lua_modules; fi
|
||||||
|
cd build/bin && ln -s ../../.devcontainer/repo/quests/lua_modules lua_modules
|
||||||
|
@if [ -d build/bin/mods ]; then unlink build/bin/mods; fi
|
||||||
|
cd build/bin && ln -s ../../.devcontainer/repo/quests/mods mods
|
||||||
|
@if [ -d build/bin/plugins ]; then unlink build/bin/plugins; fi
|
||||||
|
cd build/bin && ln -s ../../.devcontainer/repo/quests/plugins plugins
|
||||||
|
|
||||||
@echo "Eqemu is prepared. Edit build/bin/eqemu_config.json to configure."
|
@echo "Eqemu is prepared. Edit build/bin/eqemu_config.json to configure."
|
||||||
|
|
||||||
maps:
|
is-vscode:
|
||||||
@echo "Downloading maps..."
|
@if [ -z "$$REMOTE_CONTAINERS" ]; then \
|
||||||
@mkdir -p base/maps
|
echo "Not running in VS Code devcontainer"; \
|
||||||
@cd base/maps && wget -nc https://github.com/Akkadius/eqemu-maps/archive/refs/heads/master.zip
|
exit 1; \
|
||||||
@cd base/maps && unzip -o master.zip
|
fi
|
||||||
@cd base/maps && mv eqemu-maps-master/* .
|
|
||||||
@cd base/maps && rm -rf eqemu-maps-master
|
|
||||||
@echo "Maps downloaded."
|
|
||||||
|
|
||||||
quests:
|
clean: is-vscode
|
||||||
ifeq ($(findstring .devcontainer,$(CURDIR)),.devcontainer)
|
rm -rf build
|
||||||
@make -C ../ -f .devcontainer/Makefile quests --no-print-directory
|
|
||||||
exit
|
.PHONY: maps
|
||||||
endif
|
maps: is-vscode
|
||||||
@cd build/bin && git clone https://github.com/ProjectEQ/projecteqquests.git quests
|
@echo "Downloading maps..."
|
||||||
|
@mkdir -p .devcontainer/repo/maps
|
||||||
|
@cd .devcontainer/repo/maps && wget -nc https://github.com/EQEmu/maps/archive/refs/heads/master.zip
|
||||||
|
@cd .devcontainer/repo/maps && unzip -o master.zip
|
||||||
|
@cd .devcontainer/repo/maps && mv maps-master/* .
|
||||||
|
@cd .devcontainer/repo/maps && rm -rf maps-master
|
||||||
|
@echo "Maps downloaded."
|
||||||
|
|
||||||
# Runs tests
|
# Runs tests
|
||||||
.PHONY: test
|
.PHONY: test
|
||||||
test:
|
test: is-vscode
|
||||||
ifeq ($(findstring .devcontainer,$(CURDIR)),.devcontainer)
|
|
||||||
@make -C ../ -f .devcontainer/Makefile test --no-print-directory
|
|
||||||
exit
|
|
||||||
endif
|
|
||||||
cd build/bin && ./tests
|
cd build/bin && ./tests
|
||||||
|
|
||||||
# Runs login binary
|
# Runs login binary
|
||||||
.PHONY: login
|
.PHONY: login
|
||||||
login:
|
login: is-vscode check-mariadb
|
||||||
ifeq ($(findstring .devcontainer,$(CURDIR)),.devcontainer)
|
|
||||||
@make -C ../ -f .devcontainer/Makefile login --no-print-directory
|
|
||||||
exit
|
|
||||||
endif
|
|
||||||
cd build/bin && ./loginserver
|
cd build/bin && ./loginserver
|
||||||
|
|
||||||
|
.PHONY: hotfix
|
||||||
|
hotfix: shared
|
||||||
|
|
||||||
# Runs shared_memory binary
|
# Runs shared_memory binary
|
||||||
.PHONY: shared
|
.PHONY: shared
|
||||||
shared:
|
shared: is-vscode check-mariadb
|
||||||
ifeq ($(findstring .devcontainer,$(CURDIR)),.devcontainer)
|
|
||||||
@make -C ../ -f .devcontainer/Makefile shared --no-print-directory
|
|
||||||
exit
|
|
||||||
endif
|
|
||||||
cd build/bin && ./shared_memory
|
cd build/bin && ./shared_memory
|
||||||
|
|
||||||
# Runs zone binary
|
# Runs zone binary
|
||||||
.PHONY: zone
|
.PHONY: zone
|
||||||
zone:
|
zone: is-vscode check-mariadb
|
||||||
ifeq ($(findstring .devcontainer,$(CURDIR)),.devcontainer)
|
@find build/bin/logs/zone/ -type f -name 'zone*.log' -exec rm -f {} +
|
||||||
@make -C ../ -f .devcontainer/Makefile zone --no-print-directory
|
|
||||||
exit
|
|
||||||
endif
|
|
||||||
@-rm build/bin/logs/zone/zone*.log
|
|
||||||
cd build/bin && ./zone
|
cd build/bin && ./zone
|
||||||
|
|
||||||
|
check-mariadb: is-vscode
|
||||||
|
@if ! sudo service mariadb status | grep -q 'active (running)'; then \
|
||||||
|
sudo service mariadb start; \
|
||||||
|
fi
|
||||||
|
|
||||||
# Runs world binary
|
# Runs world binary
|
||||||
.PHONY: world
|
.PHONY: world
|
||||||
world:
|
world: is-vscode check-mariadb
|
||||||
ifeq ($(findstring .devcontainer,$(CURDIR)),.devcontainer)
|
@find build/bin/logs/ -type f -name 'world*.log' -exec rm -f {} +
|
||||||
@make -C ../ -f .devcontainer/Makefile world --no-print-directory
|
|
||||||
exit
|
|
||||||
endif
|
|
||||||
@-rm build/bin/logs/world*.log
|
|
||||||
cd build/bin && ./world
|
cd build/bin && ./world
|
||||||
|
|
||||||
# Runs ucs binary
|
# Runs ucs binary
|
||||||
.PHONY: ucs
|
.PHONY: ucs
|
||||||
ucs:
|
ucs: is-vscode check-mariadb
|
||||||
ifeq ($(findstring .devcontainer,$(CURDIR)),.devcontainer)
|
@find build/bin/logs/ -type f -name 'ucs*.log' -exec rm -f {} +
|
||||||
@make -C ../ -f .devcontainer/Makefile ucs --no-print-directory
|
|
||||||
exit
|
|
||||||
endif
|
|
||||||
@-rm build/bin/logs/ucs*.log
|
|
||||||
cd build/bin && ./ucs
|
cd build/bin && ./ucs
|
||||||
|
|
||||||
# Runs queryserv binary
|
# Runs queryserv binary
|
||||||
.PHONY: queryserv
|
.PHONY: queryserv
|
||||||
queryserv:
|
queryserv: is-vscode check-mariadb
|
||||||
ifeq ($(findstring .devcontainer,$(CURDIR)),.devcontainer)
|
@find build/bin/logs/ -type f -name 'query_server*.log' -exec rm -f {} +
|
||||||
@make -C ../ -f .devcontainer/Makefile queryserv --no-print-directory
|
|
||||||
exit
|
|
||||||
endif
|
|
||||||
@-rm build/bin/logs/query_server*.log
|
|
||||||
cd build/bin && ./queryserv
|
cd build/bin && ./queryserv
|
||||||
|
|
||||||
valgrind-%:
|
reset-content:
|
||||||
ifeq ($(findstring .devcontainer,$(CURDIR)),.devcontainer)
|
@echo "Resetting content tables in database peq..."
|
||||||
@make -C ../ -f .devcontainer/Makefile valgrind --no-print-directory
|
cd .devcontainer/cache/db/peq-dump && sudo mariadb --database peq -e "source create_tables_content.sql"
|
||||||
exit
|
|
||||||
endif
|
valgrind-%: is-vscode
|
||||||
cd build/bin && valgrind --leak-check=full --show-leak-kinds=all --track-origins=yes --verbose --log-file=logs/$*.valgrind.log ./$*
|
cd build/bin && valgrind --leak-check=full --show-leak-kinds=all --track-origins=yes --verbose --log-file=logs/$*.valgrind.log ./$*
|
||||||
|
|
||||||
# Start mariaDB standalone
|
# Start mariaDB standalone
|
||||||
@@ -201,30 +132,33 @@ mariadb:
|
|||||||
.PHONY: inject-mariadb
|
.PHONY: inject-mariadb
|
||||||
inject-mariadb:
|
inject-mariadb:
|
||||||
-sudo service mariadb start
|
-sudo service mariadb start
|
||||||
-mkdir -p base/db/
|
-mkdir -p .devcontainer/cache/db/
|
||||||
-sudo mariadb -e 'DROP DATABASE IF EXISTS peq;'
|
-sudo mariadb -e 'DROP DATABASE IF EXISTS peq;'
|
||||||
-sudo mariadb -e 'CREATE DATABASE peq;'
|
-sudo mariadb -e 'CREATE DATABASE peq;'
|
||||||
-sudo mariadb -e "CREATE USER 'peq'@'127.0.0.1' IDENTIFIED BY 'peqpass';"
|
-sudo mariadb -e "CREATE USER IF NOT EXISTS 'peq'@'127.0.0.1' IDENTIFIED BY 'peqpass';"
|
||||||
-sudo mariadb -e "GRANT ALL PRIVILEGES ON *.* TO 'peq'@'127.0.0.1';"
|
-sudo mariadb -e "GRANT ALL PRIVILEGES ON *.* TO 'peq'@'127.0.0.1';"
|
||||||
ifeq (,$(wildcard base/db/db.sql.zip))
|
ifeq (,$(wildcard .devcontainer/cache/db/db.sql.zip))
|
||||||
@echo "base/db.sql.zip not found. Downloading latest from https://db.projecteq.net/"
|
@echo ".devcontainer/cache/db.sql.zip not found. Downloading database from https://db.eqemu.dev/latest"
|
||||||
wget -nc https://db.projecteq.net/latest -O base/db/db.sql.zip
|
wget -nc https://db.eqemu.dev/latest -O .devcontainer/cache/db/db.sql.zip
|
||||||
-cd base/db && unzip db.sql.zip
|
-cd .devcontainer/cache/db && unzip db.sql.zip
|
||||||
endif
|
endif
|
||||||
@echo "Sourcing db may take a while, please wait..."
|
@echo "Sourcing db may take a while, please wait..."
|
||||||
@cd base/db/peq-dump && sudo mariadb --database peq -e "source create_all_tables.sql"
|
|
||||||
|
@cd .devcontainer/cache/db/peq-dump && sudo mariadb --database peq -e "source create_tables_content.sql"
|
||||||
|
@cd .devcontainer/cache/db/peq-dump && sudo mariadb --database peq -e "source create_tables_login.sql"
|
||||||
|
@cd .devcontainer/cache/db/peq-dump && sudo mariadb --database peq -e "source create_tables_player.sql"
|
||||||
|
@# deprecated cd .devcontainer/cache/db/peq-dump && sudo mariadb --database peq -e "source create_tables_queryserv.sql"
|
||||||
|
@cd .devcontainer/cache/db/peq-dump && sudo mariadb --database peq -e "source create_tables_state.sql"
|
||||||
|
@cd .devcontainer/cache/db/peq-dump && sudo mariadb --database peq -e "source create_tables_system.sql"
|
||||||
|
|
||||||
@echo "MariaDB is now injected."
|
@echo "MariaDB is now injected."
|
||||||
|
|
||||||
.PHONY: gm-%
|
.PHONY: gm-%
|
||||||
gm-%:
|
gm-%: is-vscode
|
||||||
sudo mariadb --database peq -e "UPDATE account SET status=255 WHERE name = '$*';"
|
sudo mariadb --database peq -e "UPDATE account SET status=255 WHERE name = '$*';"
|
||||||
@echo "Account $* is now a GM. /camp to have it go into effect."
|
@echo "Account $* is now a GM. /camp to have it go into effect."
|
||||||
|
|
||||||
depends:
|
depends: is-vscode
|
||||||
ifeq ($(findstring .devcontainer,$(CURDIR)),.devcontainer)
|
|
||||||
@make -C ../ -f .devcontainer/Makefile depends --no-print-directory
|
|
||||||
exit
|
|
||||||
endif
|
|
||||||
sudo apt install graphviz pip time
|
sudo apt install graphviz pip time
|
||||||
pip3 install graphviz
|
pip3 install graphviz
|
||||||
mkdir -p build/depends
|
mkdir -p build/depends
|
||||||
@@ -241,44 +175,54 @@ endif
|
|||||||
@echo "Common..."
|
@echo "Common..."
|
||||||
time python3 build/depends/dependency_graph.py -f png common build/depends/common.dot
|
time python3 build/depends/dependency_graph.py -f png common build/depends/common.dot
|
||||||
|
|
||||||
backup:
|
backup: is-vscode
|
||||||
ifeq ($(findstring .devcontainer,$(CURDIR)),.devcontainer)
|
|
||||||
@make -C ../ -f .devcontainer/Makefile backup --no-print-directory
|
|
||||||
exit
|
|
||||||
endif
|
|
||||||
@mkdir -p build/bin/backup
|
@mkdir -p build/bin/backup
|
||||||
cd build/bin && ./world database:dump --compress --player-tables --state-tables --system-tables --query-serv-tables
|
cd build/bin && ./world database:dump --compress --player-tables --state-tables --system-tables --query-serv-tables
|
||||||
|
|
||||||
cpu-zone:
|
restore-%: is-vscode
|
||||||
|
@if [ -z "$*" ]; then \
|
||||||
|
echo "Please provide a backup file to restore from. Example: make restore-backup.sql"; \
|
||||||
|
exit 1; \
|
||||||
|
fi
|
||||||
|
@echo "Restoring from backup $*"
|
||||||
|
@sudo mariadb --database peq -e "$*"
|
||||||
|
|
||||||
|
|
||||||
|
cpu-zone: is-vscode
|
||||||
ifeq ($(findstring .devcontainer,$(CURDIR)),.devcontainer)
|
ifeq ($(findstring .devcontainer,$(CURDIR)),.devcontainer)
|
||||||
@make -C ../ -f .devcontainer/Makefile cpu-zone --no-print-directory
|
@echo "This makefile is not intended to be run from the .devcontainer directory."
|
||||||
exit
|
exit
|
||||||
endif
|
endif
|
||||||
@cd build/bin && mkdir -p tmp
|
@cd build/bin && mkdir -p tmp
|
||||||
cd build/bin && CPUPROFILE=prof.out ./zone
|
cd build/bin && CPUPROFILE=prof.out ./zone
|
||||||
|
|
||||||
pprof-zone:
|
pprof-zone: is-vscode
|
||||||
ifeq ($(findstring .devcontainer,$(CURDIR)),.devcontainer)
|
ifeq ($(findstring .devcontainer,$(CURDIR)),.devcontainer)
|
||||||
@make -C ../ -f .devcontainer/Makefile pprof-zone --no-print-directory
|
@echo "This makefile is not intended to be run from the .devcontainer directory."
|
||||||
exit
|
exit
|
||||||
endif
|
endif
|
||||||
cd build/bin && google-pprof --pdf zone prof.out > prof.pdf
|
cd build/bin && google-pprof --pdf zone prof.out > prof.pdf
|
||||||
pprof-web-zone:
|
|
||||||
|
pprof-gv-zone: is-vscode
|
||||||
ifeq ($(findstring .devcontainer,$(CURDIR)),.devcontainer)
|
ifeq ($(findstring .devcontainer,$(CURDIR)),.devcontainer)
|
||||||
@make -C ../ -f .devcontainer/Makefile pprof-web-zone --no-print-directory
|
@echo "This makefile is not intended to be run from the .devcontainer directory."
|
||||||
exit
|
|
||||||
endif
|
|
||||||
cd build/bin && google-pprof --web zone prof.out
|
|
||||||
pprof-gv-zone:
|
|
||||||
ifeq ($(findstring .devcontainer,$(CURDIR)),.devcontainer)
|
|
||||||
@make -C ../ -f .devcontainer/Makefile pprof-gv-zone --no-print-directory
|
|
||||||
exit
|
exit
|
||||||
endif
|
endif
|
||||||
cd build/bin && google-pprof --gv zone prof.out > prof.gv
|
cd build/bin && google-pprof --gv zone prof.out > prof.gv
|
||||||
heap-zone:
|
|
||||||
|
heap-zone: is-vscode
|
||||||
ifeq ($(findstring .devcontainer,$(CURDIR)),.devcontainer)
|
ifeq ($(findstring .devcontainer,$(CURDIR)),.devcontainer)
|
||||||
@make -C ../ -f .devcontainer/Makefile heap-zone --no-print-directory
|
@echo "This makefile is not intended to be run from the .devcontainer directory."
|
||||||
exit
|
exit
|
||||||
endif
|
endif
|
||||||
@cd build/bin && mkdir -p tmp
|
@cd build/bin && mkdir -p tmp
|
||||||
cd build/bin && HEAPPROFILE=prof.out ./zone
|
cd build/bin && HEAPPROFILE=prof.out ./zone
|
||||||
|
|
||||||
|
|
||||||
|
.PHONY: pull
|
||||||
|
pull:
|
||||||
|
git pull
|
||||||
|
@if [ ! -d "quests" ]; then git clone https://github.com/rebuildeq/quests.git quests; fi
|
||||||
|
cd quests && git pull
|
||||||
|
@if [ ! -d "eqemu-definitions" ]; then git clone https://github.com/xackery/eqemu-definitions.git eqemu-definitions; fi
|
||||||
|
cd eqemu-definitions && git pull
|
||||||
@@ -40,10 +40,41 @@
|
|||||||
"GitHub.copilot",
|
"GitHub.copilot",
|
||||||
"xackery.make-magic",
|
"xackery.make-magic",
|
||||||
"Gruntfuggly.todo-tree",
|
"Gruntfuggly.todo-tree",
|
||||||
"ms-vscode.cmake-tools"
|
"ms-vscode.cmake-tools",
|
||||||
]
|
"sumneko.lua"
|
||||||
|
],
|
||||||
|
"settings": {
|
||||||
|
"Lua.runtime.version": "Lua 5.1",
|
||||||
|
"Lua.workspace.library": [
|
||||||
|
"/src/repo/eqemu-definitions"
|
||||||
|
],
|
||||||
|
"Lua.diagnostics.disable": [
|
||||||
|
"lowercase-global"
|
||||||
|
],
|
||||||
|
"cmake.statusbar.advanced": {
|
||||||
|
"kit": {
|
||||||
|
"visibility": "hidden"
|
||||||
|
},
|
||||||
|
"debug": {
|
||||||
|
"visibility": "hidden"
|
||||||
|
},
|
||||||
|
"buildTarget": {
|
||||||
|
"visibility": "compact"
|
||||||
|
},
|
||||||
|
"launch": {
|
||||||
|
"visibility": "hidden"
|
||||||
|
},
|
||||||
|
"ctest": {
|
||||||
|
"visibility": "icon"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"mounts": [
|
||||||
|
"source=${localWorkspaceFolder}/.devcontainer/Makefile,target=/src/Makefile,type=bind,consistency=cached"
|
||||||
|
],
|
||||||
|
|
||||||
"workspaceFolder": "/src",
|
"workspaceFolder": "/src",
|
||||||
"workspaceMount": "source=${localWorkspaceFolder},target=/src,type=bind,consistency=cached"
|
"workspaceMount": "source=${localWorkspaceFolder},target=/src,type=bind,consistency=cached"
|
||||||
}
|
}
|
||||||
-98
@@ -1,98 +0,0 @@
|
|||||||
---
|
|
||||||
|
|
||||||
kind: pipeline
|
|
||||||
type: docker
|
|
||||||
name: Build Linux
|
|
||||||
|
|
||||||
# Limits how many of these builds can run on the drone runner at a time, this isn't about cores
|
|
||||||
concurrency:
|
|
||||||
limit: 1
|
|
||||||
|
|
||||||
volumes:
|
|
||||||
- name: cache
|
|
||||||
host:
|
|
||||||
path: /var/lib/cache-release
|
|
||||||
|
|
||||||
steps:
|
|
||||||
- name: Build Linux X64
|
|
||||||
image: akkadius/eqemu-server:v14
|
|
||||||
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:
|
|
||||||
- ./utils/scripts/build/linux-build.sh
|
|
||||||
volumes:
|
|
||||||
- name: cache
|
|
||||||
path: /home/eqemu/.ccache/
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
kind: pipeline
|
|
||||||
type: exec
|
|
||||||
name: Build Windows
|
|
||||||
|
|
||||||
# Limits how many of these builds can run on the drone runner at a time, this isn't about cores
|
|
||||||
concurrency:
|
|
||||||
limit: 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"
|
|
||||||
|
|
||||||
trigger:
|
|
||||||
branch:
|
|
||||||
- master
|
|
||||||
event:
|
|
||||||
- push
|
|
||||||
|
|
||||||
depends_on:
|
|
||||||
- Build Windows
|
|
||||||
- Build Linux
|
|
||||||
|
|
||||||
|
|
||||||
@@ -0,0 +1,81 @@
|
|||||||
|
name: Build
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- master
|
||||||
|
pull_request:
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
linux:
|
||||||
|
name: Linux
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Checkout source
|
||||||
|
uses: actions/checkout@v5
|
||||||
|
with:
|
||||||
|
submodules: recursive
|
||||||
|
|
||||||
|
- name: Setup ccache
|
||||||
|
uses: hendrikmuhs/ccache-action@v1.2
|
||||||
|
with:
|
||||||
|
key: ${{ runner.os }}-ccache
|
||||||
|
|
||||||
|
- name: Install dependencies
|
||||||
|
run: |
|
||||||
|
sudo apt-get update
|
||||||
|
sudo apt-get install -y build-essential ninja-build ccache
|
||||||
|
|
||||||
|
- name: Configure
|
||||||
|
run: |
|
||||||
|
cmake -S . -B build -G Ninja \
|
||||||
|
-DCMAKE_BUILD_TYPE=RelWithDebInfo \
|
||||||
|
-DCMAKE_C_COMPILER_LAUNCHER=ccache \
|
||||||
|
-DCMAKE_CXX_COMPILER_LAUNCHER=ccache \
|
||||||
|
-DEQEMU_BUILD_TESTS=ON \
|
||||||
|
-DEQEMU_BUILD_LOGIN=ON \
|
||||||
|
-DEQEMU_BUILD_LUA=ON \
|
||||||
|
-DEQEMU_BUILD_PERL=ON \
|
||||||
|
-DEQEMU_BUILD_CLIENT_FILES=ON
|
||||||
|
|
||||||
|
- name: Build
|
||||||
|
run: cmake --build build --parallel
|
||||||
|
|
||||||
|
- name: Test
|
||||||
|
working-directory: build
|
||||||
|
run: ./bin/tests
|
||||||
|
|
||||||
|
windows:
|
||||||
|
name: Windows
|
||||||
|
runs-on: windows-latest
|
||||||
|
steps:
|
||||||
|
- name: Checkout source
|
||||||
|
uses: actions/checkout@v5
|
||||||
|
with:
|
||||||
|
submodules: recursive
|
||||||
|
|
||||||
|
- name: Enable long paths
|
||||||
|
run: git config --global core.longpaths true
|
||||||
|
|
||||||
|
- name: Setup MSVC environment
|
||||||
|
uses: ilammy/msvc-dev-cmd@v1
|
||||||
|
with:
|
||||||
|
arch: x64
|
||||||
|
|
||||||
|
- name: Configure
|
||||||
|
shell: pwsh
|
||||||
|
run: |
|
||||||
|
cmake -S . -B build -G "Visual Studio 17 2022" -A x64 `
|
||||||
|
-DCMAKE_BUILD_TYPE=RelWithDebInfo `
|
||||||
|
-DEQEMU_BUILD_TESTS=ON `
|
||||||
|
-DEQEMU_BUILD_LOGIN=ON `
|
||||||
|
-DEQEMU_BUILD_LUA=ON `
|
||||||
|
-DEQEMU_BUILD_ZLIB=ON `
|
||||||
|
-DEQEMU_BUILD_CLIENT_FILES=ON
|
||||||
|
|
||||||
|
- name: Build
|
||||||
|
shell: pwsh
|
||||||
|
run: cmake --build build --parallel --config RelWithDebInfo --target ALL_BUILD -- /m
|
||||||
|
|
||||||
|
- name: Test
|
||||||
|
working-directory: build
|
||||||
|
run: ./bin/RelWithDebInfo/tests.exe
|
||||||
@@ -68,3 +68,4 @@ compile_flags.txt
|
|||||||
|
|
||||||
# CMake Files
|
# CMake Files
|
||||||
cmake-build-relwithdebinfo/*
|
cmake-build-relwithdebinfo/*
|
||||||
|
skill-caps.diff
|
||||||
|
|||||||
+3
-15
@@ -1,18 +1,6 @@
|
|||||||
[submodule "submodules/glm"]
|
|
||||||
path = submodules/glm
|
|
||||||
url = https://github.com/g-truc/glm.git
|
|
||||||
[submodule "submodules/fmt"]
|
|
||||||
path = submodules/fmt
|
|
||||||
url = https://github.com/fmtlib/fmt.git
|
|
||||||
[submodule "submodules/libuv"]
|
|
||||||
path = submodules/libuv
|
|
||||||
url = https://github.com/libuv/libuv.git
|
|
||||||
[submodule "submodules/cereal"]
|
|
||||||
path = submodules/cereal
|
|
||||||
url = https://github.com/USCiLab/cereal.git
|
|
||||||
[submodule "submodules/websocketpp"]
|
[submodule "submodules/websocketpp"]
|
||||||
path = submodules/websocketpp
|
path = submodules/websocketpp
|
||||||
url = https://github.com/zaphoyd/websocketpp.git
|
url = https://github.com/zaphoyd/websocketpp.git
|
||||||
[submodule "submodules/recastnavigation"]
|
[submodule "submodules/vcpkg"]
|
||||||
path = submodules/recastnavigation
|
path = submodules/vcpkg
|
||||||
url = https://github.com/EQEmu/recastnavigation.git
|
url = https://github.com/microsoft/vcpkg.git
|
||||||
|
|||||||
Vendored
-25
@@ -21,14 +21,6 @@
|
|||||||
"${workspaceFolder}/dependencies/zlibng"
|
"${workspaceFolder}/dependencies/zlibng"
|
||||||
],
|
],
|
||||||
"telemetry.enableTelemetry": false,
|
"telemetry.enableTelemetry": false,
|
||||||
"cmake.buildDirectory": "${workspaceFolder}/build",
|
|
||||||
"cmake.configureArgs": [
|
|
||||||
"-DEQEMU_BUILD_LOGIN=ON",
|
|
||||||
"-DEQEMU_BUILD_TESTS=ON",
|
|
||||||
"-DCMAKE_CXX_COMPILER_LAUNCHER=ccache",
|
|
||||||
"-DEQEMU_ADD_PROFILER=ON",
|
|
||||||
"Ninja"
|
|
||||||
],
|
|
||||||
"cmake.skipConfigureIfCachePresent": true,
|
"cmake.skipConfigureIfCachePresent": true,
|
||||||
"cmake.configureOnOpen": false,
|
"cmake.configureOnOpen": false,
|
||||||
"files.associations": {
|
"files.associations": {
|
||||||
@@ -115,22 +107,5 @@
|
|||||||
"format": "cpp",
|
"format": "cpp",
|
||||||
"ranges": "cpp",
|
"ranges": "cpp",
|
||||||
"span": "cpp"
|
"span": "cpp"
|
||||||
},
|
|
||||||
"cmake.statusbar.advanced": {
|
|
||||||
"kit": {
|
|
||||||
"visibility": "hidden",
|
|
||||||
},
|
|
||||||
"debug": {
|
|
||||||
"visibility": "hidden",
|
|
||||||
},
|
|
||||||
"buildTarget": {
|
|
||||||
"visibility": "hidden",
|
|
||||||
},
|
|
||||||
"launch": {
|
|
||||||
"visibility": "hidden",
|
|
||||||
},
|
|
||||||
"ctest": {
|
|
||||||
"visibility": "icon",
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+1211
File diff suppressed because it is too large
Load Diff
+148
-453
@@ -1,484 +1,179 @@
|
|||||||
CMAKE_MINIMUM_REQUIRED(VERSION 3.12)
|
cmake_minimum_required(VERSION 3.20.0)
|
||||||
|
|
||||||
SET(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake/" ${CMAKE_MODULE_PATH})
|
set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake/" ${CMAKE_MODULE_PATH})
|
||||||
|
|
||||||
IF(POLICY CMP0074)
|
if(NOT CMAKE_TOOLCHAIN_FILE)
|
||||||
CMAKE_POLICY(SET CMP0074 NEW)
|
if(DEFINED ENV{VCPKG_ROOT})
|
||||||
ENDIF()
|
message(STATUS "Using vcpkg from VCPKG_ROOT")
|
||||||
|
set(CMAKE_TOOLCHAIN_FILE
|
||||||
|
"$ENV{VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake"
|
||||||
|
CACHE FILEPATH "Vcpkg toolchain file"
|
||||||
|
)
|
||||||
|
else()
|
||||||
|
message(STATUS "Using vcpkg submodule")
|
||||||
|
set(CMAKE_TOOLCHAIN_FILE
|
||||||
|
"${CMAKE_CURRENT_SOURCE_DIR}/submodules/vcpkg/scripts/buildsystems/vcpkg.cmake"
|
||||||
|
CACHE FILEPATH "Vcpkg toolchain file"
|
||||||
|
)
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
|
||||||
PROJECT(EQEmu)
|
project(EQEmu
|
||||||
|
VERSION 24.10.3
|
||||||
|
LANGUAGES CXX
|
||||||
|
)
|
||||||
|
|
||||||
IF(NOT CMAKE_BUILD_TYPE)
|
#explicitly set CMP0167 for Find Boost
|
||||||
SET(CMAKE_BUILD_TYPE RelWithDebInfo CACHE STRING "Choose the type of build." FORCE)
|
if(POLICY CMP0167)
|
||||||
ENDIF(NOT CMAKE_BUILD_TYPE)
|
cmake_policy(SET CMP0167 NEW)
|
||||||
|
endif()
|
||||||
|
|
||||||
SET(CMAKE_CXX_STANDARD 20)
|
if(NOT CMAKE_CONFIGURATION_TYPES AND NOT CMAKE_BUILD_TYPE)
|
||||||
SET(CMAKE_CXX_STANDARD_REQUIRED ON)
|
set(CMAKE_BUILD_TYPE "RelWithDebInfo" CACHE STRING "Build type")
|
||||||
SET(CMAKE_CXX_EXTENSIONS OFF)
|
endif()
|
||||||
|
|
||||||
OPTION(EQEMU_BUILD_STATIC "Build with static linking" OFF)
|
set(CMAKE_CXX_STANDARD 20)
|
||||||
OPTION(EQEMU_BUILD_PCH "Build with precompiled headers (Windows)" ON)
|
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||||
|
set(CMAKE_CXX_EXTENSIONS OFF)
|
||||||
|
|
||||||
IF (EQEMU_BUILD_STATIC)
|
option(EQEMU_BUILD_PCH "Build with precompiled headers (Windows)" ON)
|
||||||
SET(BUILD_SHARED_LIBS OFF)
|
|
||||||
SET(CMAKE_FIND_LIBRARY_SUFFIXES ".lib" ".a")
|
|
||||||
MESSAGE(STATUS "Building with static linking")
|
|
||||||
SET(CMAKE_EXE_LINKER_FLAGS "-static-libgcc -static-libstdc++")
|
|
||||||
IF (UNIX)
|
|
||||||
SET(PERL_LIBRARY "/opt/eqemu-perl/lib/5.32.1/x86_64-linux-thread-multi/CORE/libperl.so")
|
|
||||||
SET(PERL_INCLUDE_PATH "/opt/eqemu-perl/lib/5.32.1/x86_64-linux-thread-multi/CORE/")
|
|
||||||
SET(PERL_EXECUTABLE "/opt/eqemu-perl/bin/perl")
|
|
||||||
ENDIF ()
|
|
||||||
ENDIF (EQEMU_BUILD_STATIC)
|
|
||||||
|
|
||||||
|
if(MSVC)
|
||||||
|
add_compile_options(/bigobj)
|
||||||
|
add_compile_definitions(_CRT_SECURE_NO_WARNINGS NOMINMAX CRASH_LOGGING _HAS_AUTO_PTR_ETC)
|
||||||
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /MP")
|
||||||
|
|
||||||
# Requires libgoogle-perftools-dev google-perftools packages for linux (debian)
|
option(EQEMU_DISABLE_MSVC_WARNINGS "Disable MSVC compile warnings." ON)
|
||||||
IF(EQEMU_ADD_PROFILER)
|
if(EQEMU_DISABLE_MSVC_WARNINGS)
|
||||||
SET(CMAKE_EXE_LINKER_FLAGS "-Wl,--no-as-needed,-lprofiler,--as-needed")
|
add_compile_options(/W0 /wd4005 /wd4996 /nologo /Os)
|
||||||
ENDIF(EQEMU_ADD_PROFILER)
|
endif()
|
||||||
|
else()
|
||||||
|
add_compile_definitions(HAS_UNION_SEMUN)
|
||||||
IF(MSVC)
|
endif()
|
||||||
ADD_DEFINITIONS(-D_CRT_SECURE_NO_WARNINGS)
|
|
||||||
ADD_DEFINITIONS(-DNOMINMAX)
|
|
||||||
ADD_DEFINITIONS(-DCRASH_LOGGING)
|
|
||||||
ADD_DEFINITIONS(-D_HAS_AUTO_PTR_ETC) # for Luabind on C++17
|
|
||||||
|
|
||||||
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /MP")
|
|
||||||
|
|
||||||
OPTION(EQEMU_DISABLE_MSVC_WARNINGS "Disable MSVC compile warnings." ON)
|
|
||||||
IF(EQEMU_DISABLE_MSVC_WARNINGS)
|
|
||||||
ADD_DEFINITIONS( "/W0 /D_CRT_SECURE_NO_WARNINGS /wd4005 /wd4996 /nologo /Os")
|
|
||||||
ENDIF(EQEMU_DISABLE_MSVC_WARNINGS)
|
|
||||||
ELSE(MSVC)
|
|
||||||
ADD_DEFINITIONS(-DHAS_UNION_SEMUN)
|
|
||||||
ENDIF(MSVC)
|
|
||||||
|
|
||||||
#FreeBSD support
|
#FreeBSD support
|
||||||
IF(UNIX)
|
if(UNIX)
|
||||||
IF(CMAKE_SYSTEM_NAME MATCHES "FreeBSD")
|
if(CMAKE_SYSTEM_NAME MATCHES "FreeBSD")
|
||||||
ADD_DEFINITIONS(-DFREEBSD)
|
add_compile_definitions(FREEBSD)
|
||||||
ADD_DEFINITIONS(-D_GLIBCXX_USE_C99)
|
add_compile_definitions(_GLIBCXX_USE_C99)
|
||||||
SET(FREEBSD TRUE)
|
set(FREEBSD TRUE)
|
||||||
ENDIF(CMAKE_SYSTEM_NAME MATCHES "FreeBSD")
|
endif()
|
||||||
IF(CMAKE_SYSTEM_NAME MATCHES "Darwin")
|
if(CMAKE_SYSTEM_NAME MATCHES "Darwin")
|
||||||
ADD_DEFINITIONS(-DDARWIN)
|
add_compile_definitions(DARWIN)
|
||||||
SET(DARWIN TRUE)
|
set(DARWIN TRUE)
|
||||||
ENDIF(CMAKE_SYSTEM_NAME MATCHES "Darwin")
|
endif()
|
||||||
ENDIF(UNIX)
|
endif()
|
||||||
|
|
||||||
ADD_DEFINITIONS(-DGLM_FORCE_RADIANS)
|
find_package(Boost REQUIRED COMPONENTS dynamic_bitset foreach tuple)
|
||||||
ADD_DEFINITIONS(-DGLM_FORCE_CTOR_INIT)
|
find_package(cereal CONFIG REQUIRED)
|
||||||
ADD_DEFINITIONS(-DGLM_ENABLE_EXPERIMENTAL)
|
find_package(fmt CONFIG REQUIRED)
|
||||||
|
find_package(glm CONFIG REQUIRED)
|
||||||
|
find_package(unofficial-libmariadb CONFIG REQUIRED)
|
||||||
|
find_package(libuv CONFIG REQUIRED)
|
||||||
|
find_package(OpenSSL REQUIRED)
|
||||||
|
find_package(recastnavigation CONFIG REQUIRED)
|
||||||
|
find_package(ZLIB REQUIRED)
|
||||||
|
find_package(LuaJit REQUIRED)
|
||||||
|
find_package(PerlLibs)
|
||||||
|
|
||||||
#MSVC can fetch dependencies automatically.
|
message(STATUS "**************************************************")
|
||||||
IF(MSVC)
|
message(STATUS "* Library Detection *")
|
||||||
INCLUDE("${CMAKE_SOURCE_DIR}/cmake/DependencyHelperMSVC.cmake")
|
message(STATUS "**************************************************")
|
||||||
ENDIF()
|
|
||||||
|
|
||||||
#Find everything we need
|
if(MARIADB_FOUND)
|
||||||
FIND_PACKAGE(Boost REQUIRED)
|
message(STATUS "* MariaDB: FOUND *")
|
||||||
FIND_PACKAGE(MySQL)
|
else()
|
||||||
FIND_PACKAGE(MariaDB)
|
message(STATUS "* MariaDB: MISSING *")
|
||||||
FIND_PACKAGE(ZLIB)
|
endif()
|
||||||
FIND_PACKAGE(OpenSSL)
|
|
||||||
FIND_PACKAGE(Lua51)
|
|
||||||
FIND_PACKAGE(LuaJit)
|
|
||||||
FIND_PACKAGE(PerlLibs)
|
|
||||||
FIND_PACKAGE(Sodium)
|
|
||||||
FIND_PACKAGE(mbedTLS)
|
|
||||||
|
|
||||||
MESSAGE(STATUS "**************************************************")
|
if(ZLIB_FOUND)
|
||||||
MESSAGE(STATUS "* Library Detection *")
|
message(STATUS "* ZLIB: FOUND *")
|
||||||
MESSAGE(STATUS "**************************************************")
|
else()
|
||||||
|
message(STATUS "* ZLIB: MISSING *")
|
||||||
|
endif()
|
||||||
|
|
||||||
IF(MYSQL_FOUND)
|
if(LuaJit_FOUND)
|
||||||
MESSAGE(STATUS "* MySQL: FOUND *")
|
message(STATUS "* LuaJIT: FOUND *")
|
||||||
ELSE()
|
else()
|
||||||
MESSAGE(STATUS "* MySQL: MISSING *")
|
message(STATUS "* LuaJIT: MISSING *")
|
||||||
ENDIF()
|
endif()
|
||||||
|
|
||||||
IF(MARIADB_FOUND)
|
if(PerlLibs_FOUND)
|
||||||
MESSAGE(STATUS "* MariaDB: FOUND *")
|
message(STATUS "* Perl: FOUND *")
|
||||||
ELSE()
|
else()
|
||||||
MESSAGE(STATUS "* MariaDB: MISSING *")
|
message(STATUS "* Perl: MISSING *")
|
||||||
ENDIF()
|
endif()
|
||||||
|
|
||||||
IF(ZLIB_FOUND)
|
if(OpenSSL_FOUND)
|
||||||
MESSAGE(STATUS "* ZLIB: FOUND *")
|
message(STATUS "* OpenSSL: FOUND *")
|
||||||
ELSE()
|
else()
|
||||||
MESSAGE(STATUS "* ZLIB: MISSING *")
|
message(STATUS "* OpenSSL: MISSING *")
|
||||||
ENDIF()
|
endif()
|
||||||
|
|
||||||
IF(Lua51_FOUND)
|
message(STATUS "PERL_INCLUDE_PATH: ${PERL_INCLUDE_PATH}")
|
||||||
MESSAGE(STATUS "* Lua: FOUND *")
|
message(STATUS "PERL_LIBRARY: ${PERL_LIBRARY}")
|
||||||
ELSE()
|
message(STATUS "PERL_INCLUDE_DIR: ${PERL_INCLUDE_DIR}")
|
||||||
MESSAGE(STATUS "* Lua: MISSING *")
|
message(STATUS "PERL_INCLUDE_DIRS: ${PERL_INCLUDE_DIRS}")
|
||||||
ENDIF()
|
message(STATUS "PERL_LIBRARIES: ${PERL_LIBRARIES}")
|
||||||
|
message(STATUS "PERL_VERSION: ${PERL_VERSION}")
|
||||||
IF(LuaJit_FOUND)
|
message(STATUS "**************************************************")
|
||||||
MESSAGE(STATUS "* LuaJIT: FOUND *")
|
|
||||||
ELSE()
|
|
||||||
MESSAGE(STATUS "* LuaJIT: MISSING *")
|
|
||||||
ENDIF()
|
|
||||||
|
|
||||||
IF(PerlLibs_FOUND)
|
|
||||||
MESSAGE(STATUS "* Perl: FOUND *")
|
|
||||||
ELSE()
|
|
||||||
MESSAGE(STATUS "* Perl: MISSING *")
|
|
||||||
ENDIF()
|
|
||||||
|
|
||||||
IF(SODIUM_FOUND)
|
|
||||||
MESSAGE(STATUS "* libsodium: FOUND *")
|
|
||||||
ELSE()
|
|
||||||
MESSAGE(STATUS "* libsodium: MISSING *")
|
|
||||||
ENDIF()
|
|
||||||
|
|
||||||
IF(OpenSSL_FOUND)
|
|
||||||
MESSAGE(STATUS "* OpenSSL: FOUND *")
|
|
||||||
ELSE()
|
|
||||||
MESSAGE(STATUS "* OpenSSL: MISSING *")
|
|
||||||
ENDIF()
|
|
||||||
|
|
||||||
IF(MBEDTLS_FOUND)
|
|
||||||
MESSAGE(STATUS "* mbedTLS: FOUND *")
|
|
||||||
ELSE()
|
|
||||||
MESSAGE(STATUS "* mbedTLS: MISSING *")
|
|
||||||
ENDIF()
|
|
||||||
|
|
||||||
MESSAGE(STATUS "PERL_INCLUDE_PATH: ${PERL_INCLUDE_PATH}")
|
|
||||||
MESSAGE(STATUS "PERL_LIBRARY: ${PERL_LIBRARY}")
|
|
||||||
MESSAGE(STATUS "PERL_INCLUDE_DIR: ${PERL_INCLUDE_DIR}")
|
|
||||||
MESSAGE(STATUS "PERL_INCLUDE_DIRS: ${PERL_INCLUDE_DIRS}")
|
|
||||||
MESSAGE(STATUS "PERL_LIBRARIES: ${PERL_LIBRARIES}")
|
|
||||||
MESSAGE(STATUS "PERL_VERSION: ${PERL_VERSION}")
|
|
||||||
|
|
||||||
MESSAGE(STATUS "**************************************************")
|
|
||||||
|
|
||||||
#options
|
#options
|
||||||
OPTION(EQEMU_COMMANDS_LOGGING "Enable GM Command logs" ON)
|
option(EQEMU_BUILD_SERVER "Build the game server." ON)
|
||||||
OPTION(EQEMU_BUILD_SERVER "Build the game server." ON)
|
option(EQEMU_BUILD_LOGIN "Build the login server." ON)
|
||||||
OPTION(EQEMU_BUILD_LOGIN "Build the login server." ON)
|
option(EQEMU_BUILD_TESTS "Build utility tests." OFF)
|
||||||
OPTION(EQEMU_BUILD_HC "Build the headless client." OFF)
|
option(EQEMU_BUILD_CLIENT_FILES "Build Client Import/Export Data Programs." ON)
|
||||||
OPTION(EQEMU_BUILD_TESTS "Build utility tests." OFF)
|
|
||||||
OPTION(EQEMU_BUILD_CLIENT_FILES "Build Client Import/Export Data Programs." ON)
|
|
||||||
OPTION(EQEMU_PREFER_LUA "Build with normal Lua even if LuaJIT is found." OFF)
|
|
||||||
|
|
||||||
#PRNG options
|
if(PerlLibs_FOUND)
|
||||||
OPTION(EQEMU_ADDITIVE_LFIB_PRNG "Use Additive LFib for PRNG." OFF)
|
option(EQEMU_BUILD_PERL "Build Perl parser." ON)
|
||||||
MARK_AS_ADVANCED(EQEMU_ADDITIVE_LFIB_PRNG)
|
|
||||||
OPTION(EQEMU_BIASED_INT_DIST "Use biased int dist instead of uniform." OFF)
|
|
||||||
MARK_AS_ADVANCED(EQEMU_BIASED_INT_DIST)
|
|
||||||
SET(EQEMU_CUSTOM_PRNG_ENGINE "" CACHE STRING "Custom random engine. (ex. std::default_random_engine)")
|
|
||||||
MARK_AS_ADVANCED(EQEMU_CUSTOM_PRNG_ENGINE)
|
|
||||||
|
|
||||||
IF(CMAKE_COMPILER_IS_GNUCXX)
|
if(EQEMU_BUILD_PERL)
|
||||||
OPTION(EQEMU_SFMT19937 "Use GCC's extention for SIMD Fast MT19937." OFF)
|
set(PERL_LIBRARY_TYPE " Perl")
|
||||||
MARK_AS_ADVANCED(EQEMU_SFMT19937)
|
else()
|
||||||
ENDIF()
|
set(PERL_LIBRARY_TYPE " Missing")
|
||||||
|
endif()
|
||||||
|
else()
|
||||||
|
set(PERL_LIBRARY_TYPE "Disabled")
|
||||||
|
endif()
|
||||||
|
|
||||||
IF(EQEMU_ADDITIVE_LFIB_PRNG)
|
message(STATUS "")
|
||||||
ADD_DEFINITIONS(-DUSE_ADDITIVE_LFIB_PRNG)
|
message(STATUS "**************************************************")
|
||||||
IF(EQEMU_SFMT19937)
|
message(STATUS "* Library Usage *")
|
||||||
MESSAGE(STATUS "SFMT19937 and ADDITITVE_LFIB_PRNG both set, SFMT19937 ignored.")
|
message(STATUS "**************************************************")
|
||||||
SET(EQEMU_SFMT19937 OFF)
|
message(STATUS "* Database: MariaDB *")
|
||||||
ENDIF()
|
message(STATUS "* TLS: OpenSSL *")
|
||||||
IF(NOT EQEMU_CUSTOM_PRNG_ENGINE STREQUAL "")
|
message(STATUS "* Lua: LuaJIT *")
|
||||||
MESSAGE(STATUS "CUSTOM_PRNG_ENGINE and ADDITITVE_LFIB_PRNG both set, CUSTOM_PRNG_ENGINE ignored.")
|
message(STATUS "* Perl: ${PERL_LIBRARY_TYPE} *")
|
||||||
SET(EQEMU_CUSTOM_PRNG_ENGINE "")
|
message(STATUS "* zlib: ZLIB *")
|
||||||
ENDIF()
|
message(STATUS "**************************************************")
|
||||||
ENDIF()
|
|
||||||
|
|
||||||
IF(EQEMU_SFMT19937)
|
|
||||||
ADD_DEFINITIONS(-DUSE_SFMT19937)
|
|
||||||
IF(NOT EQEMU_CUSTOM_PRNG_ENGINE STREQUAL "")
|
|
||||||
MESSAGE(STATUS "CUSTOM_PRNG_ENGINE and SFMT19937 both set, CUSTOM_PRNG_ENGINE ignored.")
|
|
||||||
SET(EQEMU_CUSTOM_PRNG_ENGINE "")
|
|
||||||
ENDIF()
|
|
||||||
ENDIF()
|
|
||||||
|
|
||||||
IF(NOT EQEMU_CUSTOM_PRNG_ENGINE STREQUAL "")
|
option(EQEMU_BUILD_LUA "Build Lua parser." ON)
|
||||||
ADD_DEFINITIONS(-DUSE_CUSTOM_PRNG_ENGINE=${EQEMU_CUSTOM_PRNG_ENGINE})
|
|
||||||
ENDIF()
|
|
||||||
|
|
||||||
IF(EQEMU_BIASED_INT_DIST)
|
if(EQEMU_BUILD_SERVER OR EQEMU_BUILD_LOGIN OR EQEMU_BUILD_TESTS OR EQEMU_BUILD_CLIENT_FILES)
|
||||||
ADD_DEFINITIONS(-DBIASED_INT_DIST)
|
add_subdirectory(common)
|
||||||
ENDIF()
|
add_subdirectory(libs)
|
||||||
|
else()
|
||||||
|
message(FATAL_ERROR "No targets were selected to build, we must build at least one target.")
|
||||||
|
endif()
|
||||||
|
|
||||||
IF(EQEMU_COMMANDS_LOGGING)
|
if(EQEMU_BUILD_SERVER)
|
||||||
ADD_DEFINITIONS(-DCOMMANDS_LOGGING)
|
add_subdirectory(shared_memory)
|
||||||
ENDIF(EQEMU_COMMANDS_LOGGING)
|
add_subdirectory(world)
|
||||||
|
add_subdirectory(zone)
|
||||||
|
add_subdirectory(ucs)
|
||||||
|
add_subdirectory(queryserv)
|
||||||
|
add_subdirectory(eqlaunch)
|
||||||
|
endif()
|
||||||
|
|
||||||
#database
|
if(EQEMU_BUILD_LOGIN)
|
||||||
IF(MySQL_FOUND AND MariaDB_FOUND)
|
add_subdirectory(loginserver)
|
||||||
SET(DATABASE_LIBRARY_SELECTION MariaDB CACHE STRING "Database library to use:
|
endif()
|
||||||
MySQL
|
|
||||||
MariaDB"
|
|
||||||
)
|
|
||||||
|
|
||||||
IF(DATABASE_LIBRARY_SELECTION STREQUAL "MySQL")
|
if(EQEMU_BUILD_TESTS)
|
||||||
SET(DATABASE_LIBRARY_TYPE " MySQL")
|
add_subdirectory(tests)
|
||||||
SET(DATABASE_LIBRARY_LIBS ${MySQL_LIBRARIES})
|
endif()
|
||||||
SET(DATABASE_LIBRARY_INCLUDE ${MySQL_INCLUDE_DIR})
|
|
||||||
ELSEIF(DATABASE_LIBRARY_SELECTION STREQUAL "MariaDB")
|
|
||||||
SET(DATABASE_LIBRARY_TYPE "MariaDB")
|
|
||||||
SET(DATABASE_LIBRARY_LIBS ${MariaDB_LIBRARIES})
|
|
||||||
SET(DATABASE_LIBRARY_INCLUDE ${MariaDB_INCLUDE_DIR})
|
|
||||||
ELSE()
|
|
||||||
MESSAGE(FATAL_ERROR "Unknown database library set, should be one of: MySQL, MariaDB")
|
|
||||||
ENDIF()
|
|
||||||
ELSEIF(MariaDB_FOUND)
|
|
||||||
SET(DATABASE_LIBRARY_TYPE "MariaDB")
|
|
||||||
SET(DATABASE_LIBRARY_LIBS ${MariaDB_LIBRARIES})
|
|
||||||
SET(DATABASE_LIBRARY_INCLUDE ${MariaDB_INCLUDE_DIR})
|
|
||||||
ELSEIF(MySQL_FOUND)
|
|
||||||
SET(DATABASE_LIBRARY_TYPE " MySQL")
|
|
||||||
SET(DATABASE_LIBRARY_LIBS ${MySQL_LIBRARIES})
|
|
||||||
SET(DATABASE_LIBRARY_INCLUDE ${MySQL_INCLUDE_DIR})
|
|
||||||
ELSE()
|
|
||||||
MESSAGE(FATAL_ERROR "One of MySQL or MariaDB is a required dependency.")
|
|
||||||
ENDIF()
|
|
||||||
|
|
||||||
#security
|
if(EQEMU_BUILD_CLIENT_FILES)
|
||||||
#prefer openssl to mbedtls (arbitrary)
|
add_subdirectory(client_files)
|
||||||
IF(OpenSSL_FOUND AND MBEDTLS_FOUND)
|
endif()
|
||||||
SET(TLS_LIBRARY_SELECTION OpenSSL CACHE STRING "TLS library to use:
|
|
||||||
OpenSSL
|
|
||||||
mbedTLS"
|
|
||||||
)
|
|
||||||
|
|
||||||
IF(TLS_LIBRARY_SELECTION STREQUAL "OpenSSL")
|
|
||||||
SET(TLS_LIBRARY_TYPE " OpenSSL")
|
|
||||||
SET(TLS_LIBRARY_ENABLED ON)
|
|
||||||
SET(TLS_LIBRARY_LIBS ${OPENSSL_LIBRARIES})
|
|
||||||
SET(TLS_LIBRARY_INCLUDE ${OPENSSL_INCLUDE_DIR})
|
|
||||||
ADD_DEFINITIONS(-DEQEMU_USE_OPENSSL)
|
|
||||||
IF(${OPENSSL_VERSION} VERSION_GREATER_EQUAL "1.1.1")
|
|
||||||
ADD_DEFINITIONS(-DCPPHTTPLIB_OPENSSL_SUPPORT)
|
|
||||||
ENDIF()
|
|
||||||
ELSEIF(TLS_LIBRARY_SELECTION STREQUAL "mbedTLS")
|
|
||||||
SET(TLS_LIBRARY_TYPE " mbedTLS")
|
|
||||||
SET(TLS_LIBRARY_ENABLED ON)
|
|
||||||
SET(TLS_LIBRARY_LIBS ${MBEDTLS_LIBRARY} ${MBEDX509_LIBRARY} ${MBEDCRYPTO_LIBRARY})
|
|
||||||
SET(TLS_LIBRARY_INCLUDE ${MBEDTLS_INCLUDE_DIR})
|
|
||||||
ADD_DEFINITIONS(-DEQEMU_USE_MBEDTLS)
|
|
||||||
ELSE()
|
|
||||||
MESSAGE(FATAL_ERROR "Unknown TLS library set, should be one of: OpenSSL, mbedTLS")
|
|
||||||
ENDIF()
|
|
||||||
ELSEIF(OpenSSL_FOUND)
|
|
||||||
SET(TLS_LIBRARY_TYPE " OpenSSL")
|
|
||||||
SET(TLS_LIBRARY_ENABLED ON)
|
|
||||||
SET(TLS_LIBRARY_LIBS ${OPENSSL_LIBRARIES})
|
|
||||||
SET(TLS_LIBRARY_INCLUDE ${OPENSSL_INCLUDE_DIR})
|
|
||||||
ADD_DEFINITIONS(-DEQEMU_USE_OPENSSL)
|
|
||||||
IF(${OPENSSL_VERSION} VERSION_GREATER_EQUAL "1.1.1")
|
|
||||||
ADD_DEFINITIONS(-DCPPHTTPLIB_OPENSSL_SUPPORT)
|
|
||||||
ENDIF()
|
|
||||||
ELSEIF(MBEDTLS_FOUND)
|
|
||||||
SET(TLS_LIBRARY_TYPE " mbedTLS")
|
|
||||||
SET(TLS_LIBRARY_ENABLED ON)
|
|
||||||
SET(TLS_LIBRARY_LIBS ${MBEDTLS_LIBRARY} ${MBEDX509_LIBRARY} ${MBEDCRYPTO_LIBRARY})
|
|
||||||
SET(TLS_LIBRARY_INCLUDE ${MBEDTLS_INCLUDE_DIR})
|
|
||||||
ADD_DEFINITIONS(-DEQEMU_USE_MBEDTLS)
|
|
||||||
ELSE()
|
|
||||||
SET(TLS_LIBRARY_TYPE "Disabled")
|
|
||||||
SET(TLS_LIBRARY_ENABLED OFF)
|
|
||||||
ENDIF()
|
|
||||||
|
|
||||||
IF(SODIUM_FOUND)
|
|
||||||
SET(SODIUM_LIBRARY_TYPE "Libsodium")
|
|
||||||
SET(SODIUM_LIBRARY_ENABLED ON)
|
|
||||||
SET(SODIUM_LIBRARY_LIBS ${SODIUM_LIBRARIES})
|
|
||||||
SET(SODIUM_LIBRARY_INCLUDE ${SODIUM_INCLUDE_DIRS})
|
|
||||||
ADD_DEFINITIONS(-DENABLE_SECURITY)
|
|
||||||
ELSE()
|
|
||||||
SET(SODIUM_LIBRARY_TYPE " Disabled")
|
|
||||||
SET(SODIUM_LIBRARY_ENABLED OFF)
|
|
||||||
ENDIF()
|
|
||||||
|
|
||||||
IF(LUAJIT_FOUND AND NOT (EQEMU_PREFER_LUA AND Lua51_FOUND))
|
|
||||||
SET(LUA_LIBRARY_TYPE " LuaJIT")
|
|
||||||
SET(LUA_LIBRARY_ENABLED ON)
|
|
||||||
SET(LUA_LIBRARY_LIBS ${LUAJIT_LIBRARY} luabind)
|
|
||||||
SET(LUA_LIBRARY_INCLUDE ${LUAJIT_INCLUDE_DIR} "${CMAKE_CURRENT_SOURCE_DIR}/libs/luabind")
|
|
||||||
ELSEIF(Lua51_FOUND )
|
|
||||||
SET(LUA_LIBRARY_TYPE " Lua 5.1")
|
|
||||||
SET(LUA_LIBRARY_ENABLED ON)
|
|
||||||
SET(LUA_LIBRARY_LIBS ${LUA_LIBRARY} luabind)
|
|
||||||
SET(LUA_LIBRARY_INCLUDE ${LUA_INCLUDE_DIR} "${CMAKE_CURRENT_SOURCE_DIR}/libs/luabind")
|
|
||||||
ELSE()
|
|
||||||
SET(LUA_LIBRARY_TYPE "Disabled")
|
|
||||||
SET(LUA_LIBRARY_ENABLED OFF)
|
|
||||||
ENDIF()
|
|
||||||
|
|
||||||
IF(PerlLibs_FOUND)
|
|
||||||
SET(PERL_LIBRARY_TYPE " Perl")
|
|
||||||
SET(PERL_LIBRARY_ENABLED ON)
|
|
||||||
SET(PERL_LIBRARY_LIBS ${PERL_LIBRARY})
|
|
||||||
SET(PERL_LIBRARY_INCLUDE ${PERL_INCLUDE_PATH})
|
|
||||||
ELSE()
|
|
||||||
SET(PERL_LIBRARY_TYPE "Disabled")
|
|
||||||
SET(PERL_LIBRARY_ENABLED OFF)
|
|
||||||
ENDIF()
|
|
||||||
|
|
||||||
#use zlib if exists
|
|
||||||
IF(ZLIB_FOUND)
|
|
||||||
OPTION(EQEMU_BUILD_ZLIB "Build internal version of zlib." ON)
|
|
||||||
IF(EQEMU_BUILD_ZLIB)
|
|
||||||
SET(ZLIB_LIBRARY_TYPE "zlib-ng")
|
|
||||||
SET(ZLIB_LIBRARY_LIBS "zlibstatic")
|
|
||||||
SET(ZLIB_LIBRARY_INCLUDE "${CMAKE_CURRENT_SOURCE_DIR}/libs/zlibng")
|
|
||||||
INCLUDE_DIRECTORIES(SYSTEM "${CMAKE_CURRENT_BINARY_DIR}/libs/zlibng")
|
|
||||||
ELSE()
|
|
||||||
SET(ZLIB_LIBRARY_TYPE " zlib")
|
|
||||||
SET(ZLIB_LIBRARY_LIBS ${ZLIB_LIBRARY})
|
|
||||||
SET(ZLIB_LIBRARY_INCLUDE ${ZLIB_INCLUDE_DIRS})
|
|
||||||
ENDIF()
|
|
||||||
ELSE()
|
|
||||||
SET(ZLIB_LIBRARY_TYPE "zlib-ng")
|
|
||||||
SET(ZLIB_LIBRARY_LIBS "zlibstatic")
|
|
||||||
SET(ZLIB_LIBRARY_INCLUDE "${CMAKE_CURRENT_SOURCE_DIR}/libs/zlibng")
|
|
||||||
ENDIF()
|
|
||||||
|
|
||||||
IF (EQEMU_BUILD_STATIC)
|
|
||||||
SET(ZLIB_LIBRARY_LIBS libz.a)
|
|
||||||
ENDIF(EQEMU_BUILD_STATIC)
|
|
||||||
|
|
||||||
MESSAGE(STATUS "")
|
|
||||||
MESSAGE(STATUS "**************************************************")
|
|
||||||
MESSAGE(STATUS "* Library Usage *")
|
|
||||||
MESSAGE(STATUS "**************************************************")
|
|
||||||
MESSAGE(STATUS "* Database: ${DATABASE_LIBRARY_TYPE} *")
|
|
||||||
MESSAGE(STATUS "* TLS: ${TLS_LIBRARY_TYPE} *")
|
|
||||||
MESSAGE(STATUS "* Sodium: ${SODIUM_LIBRARY_TYPE} *")
|
|
||||||
MESSAGE(STATUS "* Lua: ${LUA_LIBRARY_TYPE} *")
|
|
||||||
MESSAGE(STATUS "* Perl: ${PERL_LIBRARY_TYPE} *")
|
|
||||||
MESSAGE(STATUS "* zlib: ${ZLIB_LIBRARY_TYPE} *")
|
|
||||||
MESSAGE(STATUS "**************************************************")
|
|
||||||
|
|
||||||
#setup server libs and headers
|
|
||||||
SET(SERVER_LIBS common ${DATABASE_LIBRARY_LIBS} ${ZLIB_LIBRARY_LIBS} ${Boost_LIBRARIES} uv_a fmt RecastNavigation::Detour)
|
|
||||||
|
|
||||||
INCLUDE_DIRECTORIES(SYSTEM "${DATABASE_LIBRARY_INCLUDE}")
|
|
||||||
INCLUDE_DIRECTORIES(SYSTEM "${ZLIB_LIBRARY_INCLUDE}")
|
|
||||||
INCLUDE_DIRECTORIES(SYSTEM "${Boost_INCLUDE_DIRS}")
|
|
||||||
INCLUDE_DIRECTORIES(SYSTEM "${CMAKE_CURRENT_SOURCE_DIR}/submodules/glm")
|
|
||||||
INCLUDE_DIRECTORIES(SYSTEM "${CMAKE_CURRENT_SOURCE_DIR}/submodules/cereal/include")
|
|
||||||
INCLUDE_DIRECTORIES(SYSTEM "${CMAKE_CURRENT_SOURCE_DIR}/submodules/fmt/include")
|
|
||||||
INCLUDE_DIRECTORIES(SYSTEM "${CMAKE_CURRENT_SOURCE_DIR}/submodules/libuv/include" )
|
|
||||||
INCLUDE_DIRECTORIES(SYSTEM "${CMAKE_CURRENT_SOURCE_DIR}/submodules/recastnavigation/DebugUtils/Include")
|
|
||||||
INCLUDE_DIRECTORIES(SYSTEM "${CMAKE_CURRENT_SOURCE_DIR}/submodules/recastnavigation/Detour/Include")
|
|
||||||
INCLUDE_DIRECTORIES(SYSTEM "${CMAKE_CURRENT_SOURCE_DIR}/submodules/recastnavigation/DetourCrowd/Include")
|
|
||||||
INCLUDE_DIRECTORIES(SYSTEM "${CMAKE_CURRENT_SOURCE_DIR}/submodules/recastnavigation/DetourTileCache/Include")
|
|
||||||
INCLUDE_DIRECTORIES(SYSTEM "${CMAKE_CURRENT_SOURCE_DIR}/submodules/recastnavigation/Recast/Include")
|
|
||||||
INCLUDE_DIRECTORIES(SYSTEM "${CMAKE_CURRENT_SOURCE_DIR}/submodules/websocketpp")
|
|
||||||
|
|
||||||
# silence obnoxious deprecation message
|
|
||||||
ADD_DEFINITIONS(-DBOOST_BIND_GLOBAL_PLACEHOLDERS)
|
|
||||||
|
|
||||||
IF(TLS_LIBRARY_ENABLED)
|
|
||||||
SET(SERVER_LIBS ${SERVER_LIBS} ${TLS_LIBRARY_LIBS})
|
|
||||||
INCLUDE_DIRECTORIES(SYSTEM "${TLS_LIBRARY_INCLUDE}")
|
|
||||||
ENDIF()
|
|
||||||
|
|
||||||
IF(SODIUM_LIBRARY_ENABLED)
|
|
||||||
SET(SERVER_LIBS ${SERVER_LIBS} ${SODIUM_LIBRARY_LIBS})
|
|
||||||
INCLUDE_DIRECTORIES(SYSTEM "${SODIUM_LIBRARY_INCLUDE}")
|
|
||||||
ENDIF()
|
|
||||||
|
|
||||||
IF(LUA_LIBRARY_ENABLED)
|
|
||||||
OPTION(EQEMU_BUILD_LUA "Build Lua parser." ON)
|
|
||||||
|
|
||||||
IF(EQEMU_BUILD_LUA)
|
|
||||||
ADD_DEFINITIONS(-DLUA_EQEMU)
|
|
||||||
SET(ZONE_LIBS ${LUA_LIBRARY_LIBS})
|
|
||||||
INCLUDE_DIRECTORIES(SYSTEM "${LUA_LIBRARY_INCLUDE}")
|
|
||||||
|
|
||||||
OPTION(EQEMU_SANITIZE_LUA_LIBS "Sanitize Lua Libraries (Remove OS and IO standard libraries from being able to run)." ON)
|
|
||||||
IF(EQEMU_SANITIZE_LUA_LIBS)
|
|
||||||
ADD_DEFINITIONS(-DSANITIZE_LUA_LIBS)
|
|
||||||
ENDIF()
|
|
||||||
ENDIF()
|
|
||||||
ENDIF()
|
|
||||||
|
|
||||||
IF(PERL_LIBRARY_ENABLED)
|
|
||||||
OPTION(EQEMU_BUILD_PERL "Build Perl parser." ON)
|
|
||||||
IF(EQEMU_BUILD_PERL)
|
|
||||||
SET(SERVER_LIBS ${SERVER_LIBS} ${PERL_LIBRARY_LIBS} perlbind)
|
|
||||||
INCLUDE_DIRECTORIES(SYSTEM "${PERL_LIBRARY_INCLUDE}")
|
|
||||||
ADD_DEFINITIONS(-DEMBPERL)
|
|
||||||
ADD_DEFINITIONS(-DEMBPERL_PLUGIN)
|
|
||||||
ADD_DEFINITIONS(-DPERLBIND_NO_STRICT_SCALAR_TYPES)
|
|
||||||
IF (UNIX AND EQEMU_BUILD_STATIC)
|
|
||||||
SET(SERVER_LIBS ${SERVER_LIBS} libcrypt.a)
|
|
||||||
ENDIF ()
|
|
||||||
ENDIF()
|
|
||||||
ENDIF()
|
|
||||||
|
|
||||||
IF(WIN32)
|
|
||||||
SET(SERVER_LIBS ${SERVER_LIBS} "ws2_32" "psapi" "iphlpapi" "userenv")
|
|
||||||
ENDIF()
|
|
||||||
|
|
||||||
IF(UNIX)
|
|
||||||
SET(SERVER_LIBS ${SERVER_LIBS} ${CMAKE_DL_LIBS} "z" "m" "pthread")
|
|
||||||
IF(NOT DARWIN)
|
|
||||||
SET(SERVER_LIBS ${SERVER_LIBS} "rt")
|
|
||||||
ENDIF()
|
|
||||||
# Freebsd provides uuids in the C library
|
|
||||||
IF(NOT ${CMAKE_SYSTEM_NAME} STREQUAL "FreeBSD")
|
|
||||||
SET(SERVER_LIBS ${SERVER_LIBS} "uuid")
|
|
||||||
ENDIF()
|
|
||||||
ENDIF()
|
|
||||||
|
|
||||||
SET(ZONE_LIBS ${ZONE_LIBS} ${SERVER_LIBS})
|
|
||||||
|
|
||||||
IF(EQEMU_BUILD_LOGIN AND NOT TLS_LIBRARY_ENABLED)
|
|
||||||
MESSAGE(FATAL_ERROR "Login server requires a TLS Library to build.")
|
|
||||||
ENDIF()
|
|
||||||
|
|
||||||
IF(EQEMU_BUILD_HC AND NOT TLS_LIBRARY_ENABLED)
|
|
||||||
MESSAGE(FATAL_ERROR "Headless client requires a TLS Library to build.")
|
|
||||||
ENDIF()
|
|
||||||
|
|
||||||
IF(EQEMU_BUILD_SERVER OR EQEMU_BUILD_LOGIN OR EQEMU_BUILD_TESTS OR EQEMU_BUILD_HC)
|
|
||||||
ADD_SUBDIRECTORY(common)
|
|
||||||
ADD_SUBDIRECTORY(libs)
|
|
||||||
ADD_SUBDIRECTORY(submodules/fmt)
|
|
||||||
ADD_SUBDIRECTORY(submodules/libuv)
|
|
||||||
|
|
||||||
IF(EQEMU_BUILD_ZLIB)
|
|
||||||
SET(ZLIB_COMPAT ON CACHE BOOL "Compile with zlib compatible API")
|
|
||||||
SET(ZLIB_ENABLE_TESTS OFF CACHE BOOL "Build test binaries")
|
|
||||||
ADD_SUBDIRECTORY(libs/zlibng)
|
|
||||||
ENDIF()
|
|
||||||
|
|
||||||
SET(RECASTNAVIGATION_DEMO OFF CACHE BOOL "Build demo")
|
|
||||||
SET(RECASTNAVIGATION_TESTS OFF CACHE BOOL "Build tests")
|
|
||||||
SET(RECASTNAVIGATION_EXAMPLES OFF CACHE BOOL "Build examples")
|
|
||||||
ADD_SUBDIRECTORY(submodules/recastnavigation)
|
|
||||||
ENDIF(EQEMU_BUILD_SERVER OR EQEMU_BUILD_LOGIN OR EQEMU_BUILD_TESTS OR EQEMU_BUILD_HC)
|
|
||||||
|
|
||||||
IF(EQEMU_BUILD_SERVER)
|
|
||||||
ADD_SUBDIRECTORY(shared_memory)
|
|
||||||
ADD_SUBDIRECTORY(world)
|
|
||||||
ADD_SUBDIRECTORY(zone)
|
|
||||||
ADD_SUBDIRECTORY(ucs)
|
|
||||||
ADD_SUBDIRECTORY(queryserv)
|
|
||||||
ADD_SUBDIRECTORY(eqlaunch)
|
|
||||||
ENDIF(EQEMU_BUILD_SERVER)
|
|
||||||
|
|
||||||
IF(EQEMU_BUILD_LOGIN)
|
|
||||||
ADD_SUBDIRECTORY(loginserver)
|
|
||||||
ENDIF(EQEMU_BUILD_LOGIN)
|
|
||||||
|
|
||||||
IF(EQEMU_BUILD_HC)
|
|
||||||
ADD_SUBDIRECTORY(hc)
|
|
||||||
ENDIF(EQEMU_BUILD_HC)
|
|
||||||
|
|
||||||
IF(EQEMU_BUILD_TESTS)
|
|
||||||
ADD_SUBDIRECTORY(tests)
|
|
||||||
ENDIF(EQEMU_BUILD_TESTS)
|
|
||||||
|
|
||||||
IF(EQEMU_BUILD_CLIENT_FILES)
|
|
||||||
ADD_SUBDIRECTORY(client_files)
|
|
||||||
ENDIF(EQEMU_BUILD_CLIENT_FILES)
|
|
||||||
|
|||||||
@@ -0,0 +1,49 @@
|
|||||||
|
{
|
||||||
|
"version": 3,
|
||||||
|
"cmakeMinimumRequired": {
|
||||||
|
"major": 3,
|
||||||
|
"minor": 19,
|
||||||
|
"patch": 0
|
||||||
|
},
|
||||||
|
"configurePresets": [
|
||||||
|
{
|
||||||
|
"name": "linux-debug",
|
||||||
|
"displayName": "Linux Debug",
|
||||||
|
"generator": "Ninja",
|
||||||
|
"binaryDir": "${sourceDir}/build",
|
||||||
|
"cacheVariables": {
|
||||||
|
"CMAKE_BUILD_TYPE": "Debug",
|
||||||
|
"CMAKE_EXPORT_COMPILE_COMMANDS": "ON",
|
||||||
|
"CMAKE_C_COMPILER_LAUNCHER": "ccache",
|
||||||
|
"CMAKE_CXX_COMPILER_LAUNCHER": "ccache",
|
||||||
|
"EQEMU_BUILD_LOGIN": "ON",
|
||||||
|
"EQEMU_BUILD_TESTS": "ON",
|
||||||
|
"EQEMU_ADD_PROFILER": "ON"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "linux-release",
|
||||||
|
"displayName": "Linux Release",
|
||||||
|
"generator": "Ninja",
|
||||||
|
"binaryDir": "${sourceDir}/build/release",
|
||||||
|
"cacheVariables": {
|
||||||
|
"CMAKE_BUILD_TYPE": "Release",
|
||||||
|
"CMAKE_C_COMPILER_LAUNCHER": "ccache",
|
||||||
|
"CMAKE_CXX_COMPILER_LAUNCHER": "ccache",
|
||||||
|
"EQEMU_BUILD_LOGIN": "ON"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "win-msvc",
|
||||||
|
"displayName": "Windows MSVC (VS 2022)",
|
||||||
|
"generator": "Visual Studio 17 2022",
|
||||||
|
"binaryDir": "${sourceDir}/build/{presetName}",
|
||||||
|
"architecture": { "value": "x64" },
|
||||||
|
"cacheVariables": {
|
||||||
|
"CMAKE_CONFIGURATION_TYPES": "Debug;Release",
|
||||||
|
"EQEMU_BUILD_LOGIN": "ON",
|
||||||
|
"EQEMU_BUILD_TESTS": "ON"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
@@ -1,83 +1,150 @@
|
|||||||
# EQEmulator Core Server
|
<h1 align="center">EQEmulator Server Platform</h1>
|
||||||
| Drone (Linux x64) | Drone (Windows x64) |
|
|
||||||
|:---:|:---:|
|
<p align="center">
|
||||||
|[](http://drone.akkadius.com/EQEmu/Server) |[](http://drone.akkadius.com/EQEmu/Server) |
|
<img src="https://github.com/user-attachments/assets/11942e15-b512-402d-a619-0543c7f1151e" style="border-radius: 10px">
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<p align="center">
|
||||||
|
<b>EQEmulator - A Fan-Made Project Honoring a Legendary MMORPG</b>
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<p align="center">
|
||||||
|
<a href="https://github.com/eqemu/server/graphs/contributors"><img src="https://img.shields.io/github/contributors/eqemu/server" alt="Contributors"></a>
|
||||||
|
<a href="https://discord.gg/QHsm7CD"><img src="https://img.shields.io/discord/212663220849213441?label=Discord&logo=discord&color=7289DA" alt="Discord"></a>
|
||||||
|
<a href="https://docs.eqemu.io"><img src="https://img.shields.io/badge/docs-MkDocs%20Powered-blueviolet" alt="Docs"></a>
|
||||||
|
<a href="./LICENSE"><img src="https://img.shields.io/github/license/EQEmu/Server" alt="License"></a>
|
||||||
|
<a href="https://github.com/eqemu/server/releases"><img src="https://img.shields.io/github/v/release/eqemu/server" alt="Latest Release"></a>
|
||||||
|
<a href="https://github.com/EQEmu/Server/releases"><img src="https://img.shields.io/github/release-date/EQEmu/Server" alt="Release Date"></a>
|
||||||
|
<img src="https://img.shields.io/github/downloads/eqemu/server/total.svg" alt="Github All Releases"></a>
|
||||||
|
<a href="http://drone.akkadius.com/EQEmu/Server"><img src="http://drone.akkadius.com/api/badges/EQEmu/Server/status.svg" alt="Build Status"></a>
|
||||||
|
<img src="https://img.shields.io/github/issues-pr-closed/eqemu/server" alt="GitHub Issues or Pull Requests">
|
||||||
|
<img src="https://img.shields.io/docker/pulls/akkadius/eqemu-server" alt="Docker Pulls">
|
||||||
|
<a href="http://drone.akkadius.com/EQEmu/Server"><img src="http://drone.akkadius.com/api/badges/EQEmu/Server/status.svg" alt="Build Status"></a> <img src="https://jb.gg/badges/official-plastic.svg" alt="Official">
|
||||||
|
|
||||||
|
</p>
|
||||||
|
|
||||||
***
|
***
|
||||||
|
|
||||||
**EQEmulator is a custom completely from-scratch open source server implementation for EverQuest built mostly on C++**
|
<p align="center">
|
||||||
* MySQL/MariaDB is used as the database engine (over 200+ tables)
|
EQEmulator is a <b>passion-driven</b>, <b>open source server emulator</b> project dedicated to preserving and celebrating the legacy of a groundbreaking classic MMORPG.
|
||||||
* Perl and LUA are both supported scripting languages for NPC/Player/Quest oriented events
|
</p>
|
||||||
* Open source database (Project EQ) has content up to expansion OoW (included in server installs)
|
|
||||||
* Game server environments and databases can be heavily customized to create all new experiences
|
|
||||||
* Hundreds of Quests/events created and maintained by Project EQ
|
|
||||||
|
|
||||||
## Server Installs
|
<p align="center">
|
||||||
| |Windows|Linux|
|
For over two decades and continuing, EQEmulator has served as a <strong>fan tribute</strong>, providing tools and technology that allow players to explore, customize, and experience the legendary game's iconic gameplay in new ways. This project exists solely out of <strong>deep admiration</strong> for the original developers, artists, designers, and visionaries who created one of the most influential online worlds of all time.
|
||||||
|:---:|:---:|:---:|
|
</p>
|
||||||
|**Install Count**|||
|
|
||||||
### > Windows
|
|
||||||
|
|
||||||
* [Install Guide](https://docs.eqemu.io/server/installation/server-installation-windows/)
|
<p align="center">
|
||||||
|
We do not claim ownership of the original game or its assets. <strong>All credit and respect belong to the original creators and Daybreak Game Company</strong>, whose work continues to inspire generations of players and developers alike.
|
||||||
|
</p>
|
||||||
|
|
||||||
### > Debian/Ubuntu/CentOS/Fedora
|
<p align="center">
|
||||||
|
EQEmulator has for over 20 years and always will be a <strong>fan-based, non-commercial open-source effort</strong> made by players, for players—preserving the legacy of the game while empowering community-driven creativity, learning and joy that the game and its creators has so strongly inspired in us all.
|
||||||
|
</p>
|
||||||
|
|
||||||
* [Install Guide](https://docs.eqemu.io/server/installation/server-installation-linux/)
|
***
|
||||||
|
|
||||||
* You can use curl or wget to kick off the installer (whichever your OS has)
|
<h3 align="center">
|
||||||
> curl -O https://raw.githubusercontent.com/EQEmu/Server/master/utils/scripts/linux_installer/install.sh install.sh && chmod 755 install.sh && ./install.sh
|
Technical Overview & Reverse Engineering Effort
|
||||||
|
</h1>
|
||||||
|
|
||||||
> wget --no-check-certificate https://raw.githubusercontent.com/EQEmu/Server/master/utils/scripts/linux_installer/install.sh -O install.sh && chmod 755 install.sh && ./install.sh
|
<p align="center">EQEmulator represents <strong>over two decades of collaborative reverse engineering</strong>, building the server from the ground up without access to the original source code. This effort was achieved entirely through <strong>community-driven analysis, network protocol decoding, and in-game behavioral research</strong>.</p>
|
||||||
|
|
||||||
## Supported Clients
|
<h1 align="center">
|
||||||
|
💡 How We Did It
|
||||||
|
</h1>
|
||||||
|
|
||||||
|
<p align="center">
|
||||||
|
<img src="https://github.com/user-attachments/assets/b6b48cf7-f64a-4497-9750-71f442a3d132" height="300px">
|
||||||
|
</p>
|
||||||
|
|
||||||
|
|
||||||
|
<p align="center">
|
||||||
|
<strong>Reverse Engineering</strong>
|
||||||
|
Every system, packet, opcode, and game mechanic has been reconstructed through countless hours of live packet sniffing, client disassembly, and in-game experimentation by dedicated contributors over the years.
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<p align="center">
|
||||||
|
No proprietary code or server sources were ever used.
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<p align="center">
|
||||||
|
All implementations are the result of clean-room engineering.
|
||||||
|
</p>
|
||||||
|
|
||||||
|
|
||||||
|
<h1 align="center">
|
||||||
|
🛠️ Technology Stack
|
||||||
|
</h1>
|
||||||
|
|
||||||
|
<p align="center">
|
||||||
|
<img src="https://github.com/user-attachments/assets/df5ea809-86c5-439d-a8fa-651fb04ba477" style="border-radius: 10px">
|
||||||
|
</p>
|
||||||
|
|
||||||
|
**C++ Core Engine**
|
||||||
|
|
||||||
|
* High-performance networking and gameplay logic built in C++
|
||||||
|
* Cross-platform support for Linux and Windows
|
||||||
|
|
||||||
|
**MySQL / MariaDB Backend**
|
||||||
|
|
||||||
|
* Fully structured schema with over 200+ tables
|
||||||
|
* Supports content customization, expansions, and custom worlds
|
||||||
|
|
||||||
|
**Scripting Engine**
|
||||||
|
|
||||||
|
* Native support for **Perl** and **Lua** scripting
|
||||||
|
* Powerfully extendable for quests, NPC behaviors, and custom events
|
||||||
|
|
||||||
|
**Open Source Content Database**
|
||||||
|
|
||||||
|
* Includes ProjectEQ’s world data up through *Dragons of Norrath*
|
||||||
|
* 100% customizable to create entirely new game worlds
|
||||||
|
|
||||||
|
<h1 align="center">
|
||||||
|
🚀 Why It Matters
|
||||||
|
</h1>
|
||||||
|
|
||||||
|
<p align="center">🧬 EQEmulator stands as a <strong>technical preservation project</strong>, ensuring that the magic of classic and custom servers lives on for future generations of players, tinkerers, and game designers.
|
||||||
|
</p>
|
||||||
|
|
||||||
|
> We humbly acknowledge and thank the original developers for creating one of the most influential online experiences in gaming history.
|
||||||
|
|
||||||
|
<h1 align="center">
|
||||||
|
🧑💻🖥️ Supported Clients
|
||||||
|
</h1>
|
||||||
|
|
||||||
|Titanium Edition|Secrets of Faydwer|Seeds of Destruction|Underfoot|Rain of Fear|
|
|Titanium Edition|Secrets of Faydwer|Seeds of Destruction|Underfoot|Rain of Fear|
|
||||||
|:---:|:---:|:---:|:---:|:---:|
|
|:---:|:---:|:---:|:---:|:---:|
|
||||||
|<img src="http://i.imgur.com/hrwDxoM.jpg" height="150">|<img src="http://i.imgur.com/cRDW5tn.png" height="150">|<img src="http://i.imgur.com/V48kuVn.jpg" height="150">|<img src="http://i.imgur.com/IJQ0XMa.jpg" height="150">|<img src="http://i.imgur.com/OMpHkKa.png" height="100">|
|
|<img src="http://i.imgur.com/hrwDxoM.jpg" height="150">|<img src="http://i.imgur.com/cRDW5tn.png" height="150">|<img src="http://i.imgur.com/V48kuVn.jpg" height="150">|<img src="http://i.imgur.com/IJQ0XMa.jpg" height="150">|<img src="http://i.imgur.com/OMpHkKa.png" height="100">|
|
||||||
|
|
||||||
## Bug Reports <img src="http://i.imgur.com/daf1Vjw.png" height="20">
|
## 📚 Resources
|
||||||
* Please use the [issue tracker](https://github.com/EQEmu/Server/issues) provided by GitHub to send us bug
|
|
||||||
reports or feature requests.
|
|
||||||
* The [EQEmu Forums](http://www.eqemulator.org/forums/) are also a place to submit and get help with bugs.
|
|
||||||
|
|
||||||
## Contributions <img src="http://image.flaticon.com/icons/png/512/25/25231.png" width="20">
|
| Resource | Badges | Link |
|
||||||
|
|---------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------|
|
||||||
|
| **EQEmulator Docs** | [](https://docs.eqemu.io) | [docs.eqemu.io](https://docs.eqemu.io/) |
|
||||||
|
| **Discord Community**| [](https://discord.gg/QHsm7CD) | [Join Discord](https://discord.gg/QHsm7CD) |
|
||||||
|
| **Latest Release** | [](https://github.com/eqemu/server/releases) <br> [](https://github.com/EQEmu/Server/releases) <br> [](https://github.com/eqemu/server/releases) | [View Releases](https://github.com/eqemu/server/releases) |
|
||||||
|
| **License** | [](./LICENSE) | [View License](./LICENSE) |
|
||||||
|
| **Build Status** | [](http://drone.akkadius.com/EQEmu/Server) | [View Build Status](http://drone.akkadius.com/EQEmu/Server) |
|
||||||
|
| **Docker Pulls** | [](https://hub.docker.com/r/akkadius/eqemu-server) | [Docker Hub](https://hub.docker.com/r/akkadius/eqemu-server) |
|
||||||
|
| **Contributions** | [](https://github.com/eqemu/server/pulls?q=is%3Apr+is%3Aclosed) | [Closed PRs & Issues](https://github.com/eqemu/server/pulls?q=is%3Apr+is%3Aclosed) |
|
||||||
|
|
||||||
* The preferred way to contribute is to fork the repo and submit a pull request on
|
## 🛠️ Getting Started
|
||||||
GitHub. If you need help with your changes, you can always post on the forums or
|
|
||||||
try Discord. You can also post unified diffs (`git diff` should do the trick) on the
|
|
||||||
[Server Code Submissions](http://www.eqemulator.org/forums/forumdisplay.php?f=669)
|
|
||||||
forum, although pull requests will be much quicker and easier on all parties.
|
|
||||||
|
|
||||||
## Contact <img src="http://gamerescape.com/wp-content/uploads/2015/06/discord.png" height="20">
|
If you want to set up your own EQEmulator server, please refer to the current [server installation guides](https://docs.eqemu.io/#server-installation). We've had 100,000s of players and developers use our guides to set up their own servers, and we hope you will too!
|
||||||
|
|
||||||
- Discord Channel: https://discord.gg/QHsm7CD
|
## 🗂️ Related Repositories
|
||||||
- **User Discord Channel**: `#general`
|
|
||||||
- **Developer Discord Channel**: `#eqemucoders`
|
|
||||||
|
|
||||||
## Resources
|
| Repository | Description |
|
||||||
- [EQEmulator Forums](http://www.eqemulator.org/forums)
|
|--------------------|----------------------------------------------------------------------------------|
|
||||||
- [EQEmulator Wiki](https://docs.eqemu.io/)
|
| [ProjectEQ Quests](https://github.com/ProjectEQ/projecteqquests) | Official quests and event scripts for ProjectEQ |
|
||||||
|
| [Maps](https://github.com/Akkadius/EQEmuMaps) | EQEmu-compatible zone maps |
|
||||||
|
| [Installer Resources](https://github.com/Akkadius/EQEmuInstall) | Scripts and assets for setting up EQEmu servers |
|
||||||
|
| [Zone Utilities](https://github.com/EQEmu/zone-utilities) | Utilities for parsing, rendering, and manipulating EQ zone files |
|
||||||
|
|
||||||
## Related Repositories
|
|
||||||
* [ProjectEQ Quests](https://github.com/ProjectEQ/projecteqquests)
|
|
||||||
* [Maps](https://github.com/Akkadius/EQEmuMaps)
|
|
||||||
* [Installer Resources](https://github.com/Akkadius/EQEmuInstall)
|
|
||||||
* [Zone Utilities](https://github.com/EQEmu/zone-utilities) - Various utilities and libraries for parsing, rendering and manipulating EQ Zone files.
|
|
||||||
|
|
||||||
## Other License Info
|
|
||||||
|
|
||||||
* The server code and utilities are released under **GPLv3**
|
|
||||||
* We also include some small libraries for convienence that may be under different licensing
|
|
||||||
* SocketLib - GPL LibXML
|
|
||||||
* zlib - zlib license
|
|
||||||
* MariaDB/MySQL - GPL
|
|
||||||
* GPL Perl - GPL / ActiveState (under the assumption that this is a free project)
|
|
||||||
* CPPUnit - GLP StringUtilities - Apache
|
|
||||||
* LUA - MIT
|
|
||||||
|
|
||||||
## Contributors
|
## Contributors
|
||||||
|
|
||||||
<a href="https://github.com/EQEmu/server/graphs/contributors">
|
<a href="https://github.com/EQEmu/server/graphs/contributors">
|
||||||
<img src="https://contributors-img.firebaseapp.com/image?repo=EQEmu/server" />
|
<img src="https://contributors-img.firebaseapp.com/image?repo=EQEmu/server" />
|
||||||
</a>
|
</a>
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
CMAKE_MINIMUM_REQUIRED(VERSION 3.5)
|
cmake_minimum_required(VERSION 3.20)
|
||||||
|
|
||||||
add_subdirectory(import)
|
add_subdirectory(import)
|
||||||
add_subdirectory(export)
|
add_subdirectory(export)
|
||||||
|
|||||||
@@ -1,16 +1,16 @@
|
|||||||
CMAKE_MINIMUM_REQUIRED(VERSION 3.12)
|
cmake_minimum_required(VERSION 3.20.0)
|
||||||
|
|
||||||
SET(export_sources
|
set(export_sources
|
||||||
main.cpp
|
main.cpp
|
||||||
)
|
)
|
||||||
|
|
||||||
SET(export_headers
|
set(export_headers
|
||||||
)
|
)
|
||||||
|
|
||||||
ADD_EXECUTABLE(export_client_files ${export_sources} ${export_headers})
|
add_executable(export_client_files ${export_sources} ${export_headers})
|
||||||
|
|
||||||
INSTALL(TARGETS export_client_files RUNTIME DESTINATION ${CMAKE_INSTALL_PREFIX}/bin)
|
install(TARGETS export_client_files RUNTIME DESTINATION ${CMAKE_INSTALL_PREFIX}/bin)
|
||||||
|
|
||||||
TARGET_LINK_LIBRARIES(export_client_files ${SERVER_LIBS})
|
target_link_libraries(export_client_files common)
|
||||||
|
|
||||||
SET(EXECUTABLE_OUTPUT_PATH ${PROJECT_BINARY_DIR}/bin)
|
set(EXECUTABLE_OUTPUT_PATH ${PROJECT_BINARY_DIR}/bin)
|
||||||
|
|||||||
@@ -36,12 +36,7 @@
|
|||||||
#include "../../common/file.h"
|
#include "../../common/file.h"
|
||||||
#include "../../common/events/player_event_logs.h"
|
#include "../../common/events/player_event_logs.h"
|
||||||
#include "../../common/skill_caps.h"
|
#include "../../common/skill_caps.h"
|
||||||
|
#include "../../common/evolving_items.h"
|
||||||
EQEmuLogSys LogSys;
|
|
||||||
WorldContentService content_service;
|
|
||||||
ZoneStore zone_store;
|
|
||||||
PathManager path;
|
|
||||||
PlayerEventLogs player_event_logs;
|
|
||||||
|
|
||||||
void ExportSpells(SharedDatabase *db);
|
void ExportSpells(SharedDatabase *db);
|
||||||
void ExportSkillCaps(SharedDatabase *db);
|
void ExportSkillCaps(SharedDatabase *db);
|
||||||
@@ -51,10 +46,10 @@ void ExportDBStrings(SharedDatabase *db);
|
|||||||
int main(int argc, char **argv)
|
int main(int argc, char **argv)
|
||||||
{
|
{
|
||||||
RegisterExecutablePlatform(ExePlatformClientExport);
|
RegisterExecutablePlatform(ExePlatformClientExport);
|
||||||
LogSys.LoadLogSettingsDefaults();
|
EQEmuLogSys::Instance()->LoadLogSettingsDefaults();
|
||||||
set_exception_handler();
|
set_exception_handler();
|
||||||
|
|
||||||
path.LoadPaths();
|
PathManager::Instance()->Init();
|
||||||
|
|
||||||
LogInfo("Client Files Export Utility");
|
LogInfo("Client Files Export Utility");
|
||||||
if (!EQEmuConfig::LoadConfig()) {
|
if (!EQEmuConfig::LoadConfig()) {
|
||||||
@@ -97,8 +92,8 @@ int main(int argc, char **argv)
|
|||||||
content_db.SetMySQL(database);
|
content_db.SetMySQL(database);
|
||||||
}
|
}
|
||||||
|
|
||||||
LogSys.SetDatabase(&database)
|
EQEmuLogSys::Instance()->SetDatabase(&database)
|
||||||
->SetLogPath(path.GetLogPath())
|
->SetLogPath(PathManager::Instance()->GetLogPath())
|
||||||
->LoadLogDatabaseSettings()
|
->LoadLogDatabaseSettings()
|
||||||
->StartFileLogs();
|
->StartFileLogs();
|
||||||
|
|
||||||
@@ -127,14 +122,14 @@ int main(int argc, char **argv)
|
|||||||
ExportBaseData(&content_db);
|
ExportBaseData(&content_db);
|
||||||
ExportDBStrings(&database);
|
ExportDBStrings(&database);
|
||||||
|
|
||||||
LogSys.CloseFileLogs();
|
EQEmuLogSys::Instance()->CloseFileLogs();
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ExportSpells(SharedDatabase* db)
|
void ExportSpells(SharedDatabase* db)
|
||||||
{
|
{
|
||||||
std::ofstream file(fmt::format("{}/export/spells_us.txt", path.GetServerPath()));
|
std::ofstream file(fmt::format("{}/export/spells_us.txt", PathManager::Instance()->GetServerPath()));
|
||||||
if (!file || !file.is_open()) {
|
if (!file || !file.is_open()) {
|
||||||
LogError("Unable to open export/spells_us.txt to write, skipping.");
|
LogError("Unable to open export/spells_us.txt to write, skipping.");
|
||||||
return;
|
return;
|
||||||
@@ -153,7 +148,7 @@ void ExportSpells(SharedDatabase* db)
|
|||||||
|
|
||||||
void ExportSkillCaps(SharedDatabase* db)
|
void ExportSkillCaps(SharedDatabase* db)
|
||||||
{
|
{
|
||||||
std::ofstream file(fmt::format("{}/export/SkillCaps.txt", path.GetServerPath()));
|
std::ofstream file(fmt::format("{}/export/SkillCaps.txt", PathManager::Instance()->GetServerPath()));
|
||||||
if (!file || !file.is_open()) {
|
if (!file || !file.is_open()) {
|
||||||
LogError("Unable to open export/SkillCaps.txt to write, skipping.");
|
LogError("Unable to open export/SkillCaps.txt to write, skipping.");
|
||||||
return;
|
return;
|
||||||
@@ -172,7 +167,7 @@ void ExportSkillCaps(SharedDatabase* db)
|
|||||||
|
|
||||||
void ExportBaseData(SharedDatabase *db)
|
void ExportBaseData(SharedDatabase *db)
|
||||||
{
|
{
|
||||||
std::ofstream file(fmt::format("{}/export/BaseData.txt", path.GetServerPath()));
|
std::ofstream file(fmt::format("{}/export/BaseData.txt", PathManager::Instance()->GetServerPath()));
|
||||||
if (!file || !file.is_open()) {
|
if (!file || !file.is_open()) {
|
||||||
LogError("Unable to open export/BaseData.txt to write, skipping.");
|
LogError("Unable to open export/BaseData.txt to write, skipping.");
|
||||||
return;
|
return;
|
||||||
@@ -191,7 +186,7 @@ void ExportBaseData(SharedDatabase *db)
|
|||||||
|
|
||||||
void ExportDBStrings(SharedDatabase *db)
|
void ExportDBStrings(SharedDatabase *db)
|
||||||
{
|
{
|
||||||
std::ofstream file(fmt::format("{}/export/dbstr_us.txt", path.GetServerPath()));
|
std::ofstream file(fmt::format("{}/export/dbstr_us.txt", PathManager::Instance()->GetServerPath()));
|
||||||
if (!file || !file.is_open()) {
|
if (!file || !file.is_open()) {
|
||||||
LogError("Unable to open export/dbstr_us.txt to write, skipping.");
|
LogError("Unable to open export/dbstr_us.txt to write, skipping.");
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -1,16 +1,16 @@
|
|||||||
CMAKE_MINIMUM_REQUIRED(VERSION 3.12)
|
cmake_minimum_required(VERSION 3.20.0)
|
||||||
|
|
||||||
SET(import_sources
|
set(import_sources
|
||||||
main.cpp
|
main.cpp
|
||||||
)
|
)
|
||||||
|
|
||||||
SET(import_headers
|
set(import_headers
|
||||||
)
|
)
|
||||||
|
|
||||||
ADD_EXECUTABLE(import_client_files ${import_sources} ${import_headers})
|
add_executable(import_client_files ${import_sources} ${import_headers})
|
||||||
|
|
||||||
INSTALL(TARGETS import_client_files RUNTIME DESTINATION ${CMAKE_INSTALL_PREFIX}/bin)
|
install(TARGETS import_client_files RUNTIME DESTINATION ${CMAKE_INSTALL_PREFIX}/bin)
|
||||||
|
|
||||||
TARGET_LINK_LIBRARIES(import_client_files ${SERVER_LIBS})
|
target_link_libraries(import_client_files common)
|
||||||
|
|
||||||
SET(EXECUTABLE_OUTPUT_PATH ${PROJECT_BINARY_DIR}/bin)
|
set(EXECUTABLE_OUTPUT_PATH ${PROJECT_BINARY_DIR}/bin)
|
||||||
|
|||||||
@@ -30,12 +30,7 @@
|
|||||||
#include "../../common/repositories/base_data_repository.h"
|
#include "../../common/repositories/base_data_repository.h"
|
||||||
#include "../../common/file.h"
|
#include "../../common/file.h"
|
||||||
#include "../../common/events/player_event_logs.h"
|
#include "../../common/events/player_event_logs.h"
|
||||||
|
#include "../../common/evolving_items.h"
|
||||||
EQEmuLogSys LogSys;
|
|
||||||
WorldContentService content_service;
|
|
||||||
ZoneStore zone_store;
|
|
||||||
PathManager path;
|
|
||||||
PlayerEventLogs player_event_logs;
|
|
||||||
|
|
||||||
void ImportSpells(SharedDatabase *db);
|
void ImportSpells(SharedDatabase *db);
|
||||||
void ImportSkillCaps(SharedDatabase *db);
|
void ImportSkillCaps(SharedDatabase *db);
|
||||||
@@ -44,10 +39,10 @@ void ImportDBStrings(SharedDatabase *db);
|
|||||||
|
|
||||||
int main(int argc, char **argv) {
|
int main(int argc, char **argv) {
|
||||||
RegisterExecutablePlatform(ExePlatformClientImport);
|
RegisterExecutablePlatform(ExePlatformClientImport);
|
||||||
LogSys.LoadLogSettingsDefaults();
|
EQEmuLogSys::Instance()->LoadLogSettingsDefaults();
|
||||||
set_exception_handler();
|
set_exception_handler();
|
||||||
|
|
||||||
path.LoadPaths();
|
PathManager::Instance()->Init();
|
||||||
|
|
||||||
LogInfo("Client Files Import Utility");
|
LogInfo("Client Files Import Utility");
|
||||||
if(!EQEmuConfig::LoadConfig()) {
|
if(!EQEmuConfig::LoadConfig()) {
|
||||||
@@ -90,8 +85,8 @@ int main(int argc, char **argv) {
|
|||||||
content_db.SetMySQL(database);
|
content_db.SetMySQL(database);
|
||||||
}
|
}
|
||||||
|
|
||||||
LogSys.SetDatabase(&database)
|
EQEmuLogSys::Instance()->SetDatabase(&database)
|
||||||
->SetLogPath(path.GetLogPath())
|
->SetLogPath(PathManager::Instance()->GetLogPath())
|
||||||
->LoadLogDatabaseSettings()
|
->LoadLogDatabaseSettings()
|
||||||
->StartFileLogs();
|
->StartFileLogs();
|
||||||
|
|
||||||
@@ -100,7 +95,7 @@ int main(int argc, char **argv) {
|
|||||||
ImportBaseData(&content_db);
|
ImportBaseData(&content_db);
|
||||||
ImportDBStrings(&database);
|
ImportDBStrings(&database);
|
||||||
|
|
||||||
LogSys.CloseFileLogs();
|
EQEmuLogSys::Instance()->CloseFileLogs();
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@@ -136,7 +131,7 @@ bool IsStringField(int i) {
|
|||||||
|
|
||||||
void ImportSpells(SharedDatabase *db) {
|
void ImportSpells(SharedDatabase *db) {
|
||||||
LogInfo("Importing Spells");
|
LogInfo("Importing Spells");
|
||||||
std::string file = fmt::format("{}/import/spells_us.txt", path.GetServerPath());
|
std::string file = fmt::format("{}/import/spells_us.txt", PathManager::Instance()->GetServerPath());
|
||||||
FILE *f = fopen(file.c_str(), "r");
|
FILE *f = fopen(file.c_str(), "r");
|
||||||
if(!f) {
|
if(!f) {
|
||||||
LogError("Unable to open {} to read, skipping.", file);
|
LogError("Unable to open {} to read, skipping.", file);
|
||||||
@@ -226,7 +221,7 @@ void ImportSpells(SharedDatabase *db) {
|
|||||||
void ImportSkillCaps(SharedDatabase *db) {
|
void ImportSkillCaps(SharedDatabase *db) {
|
||||||
LogInfo("Importing Skill Caps");
|
LogInfo("Importing Skill Caps");
|
||||||
|
|
||||||
std::string file = fmt::format("{}/import/SkillCaps.txt", path.GetServerPath());
|
std::string file = fmt::format("{}/import/SkillCaps.txt", PathManager::Instance()->GetServerPath());
|
||||||
FILE *f = fopen(file.c_str(), "r");
|
FILE *f = fopen(file.c_str(), "r");
|
||||||
if(!f) {
|
if(!f) {
|
||||||
LogError("Unable to open {} to read, skipping.", file);
|
LogError("Unable to open {} to read, skipping.", file);
|
||||||
@@ -263,7 +258,7 @@ void ImportBaseData(SharedDatabase *db)
|
|||||||
{
|
{
|
||||||
LogInfo("Importing Base Data");
|
LogInfo("Importing Base Data");
|
||||||
|
|
||||||
const std::string& file_name = fmt::format("{}/import/BaseData.txt", path.GetServerPath());
|
const std::string& file_name = fmt::format("{}/import/BaseData.txt", PathManager::Instance()->GetServerPath());
|
||||||
|
|
||||||
const auto& file_contents = File::GetContents(file_name);
|
const auto& file_contents = File::GetContents(file_name);
|
||||||
if (!file_contents.error.empty()) {
|
if (!file_contents.error.empty()) {
|
||||||
@@ -303,7 +298,7 @@ void ImportBaseData(SharedDatabase *db)
|
|||||||
void ImportDBStrings(SharedDatabase *db) {
|
void ImportDBStrings(SharedDatabase *db) {
|
||||||
LogInfo("Importing DB Strings");
|
LogInfo("Importing DB Strings");
|
||||||
|
|
||||||
std::string file = fmt::format("{}/import/dbstr_us.txt", path.GetServerPath());
|
std::string file = fmt::format("{}/import/dbstr_us.txt", PathManager::Instance()->GetServerPath());
|
||||||
FILE *f = fopen(file.c_str(), "r");
|
FILE *f = fopen(file.c_str(), "r");
|
||||||
if(!f) {
|
if(!f) {
|
||||||
LogError("Unable to open {} to read, skipping.", file);
|
LogError("Unable to open {} to read, skipping.", file);
|
||||||
|
|||||||
@@ -1,94 +0,0 @@
|
|||||||
OPTION(EQEMU_FETCH_MSVC_DEPENDENCIES_VCPKG "Automatically fetch vcpkg dependencies for MSCV" ON)
|
|
||||||
OPTION(EQEMU_FETCH_MSVC_DEPENDENCIES_PERL "Automatically fetch perl dependencies for MSCV" ON)
|
|
||||||
|
|
||||||
MARK_AS_ADVANCED(EQEMU_FETCH_MSVC_DEPENDENCIES_VCPKG)
|
|
||||||
MARK_AS_ADVANCED(EQEMU_FETCH_MSVC_DEPENDENCIES_PERL)
|
|
||||||
|
|
||||||
SET(EQEMU_MSVC_DEPENDENCIES_VCPKG_X86 "https://github.com/EQEmu/Server/releases/download/v1.2/vcpkg-export-x86.zip")
|
|
||||||
SET(EQEMU_MSVC_DEPENDENCIES_VCPKG_X64 "https://github.com/EQEmu/Server/releases/download/v1.2/vcpkg-export-x64.zip")
|
|
||||||
SET(EQEMU_MSVC_DEPENDENCIES_PERL_X86 "http://strawberryperl.com/download/5.24.4.1/strawberry-perl-5.24.4.1-32bit-portable.zip")
|
|
||||||
SET(EQEMU_MSVC_DEPENDENCIES_PERL_X64 "http://strawberryperl.com/download/5.24.4.1/strawberry-perl-5.24.4.1-64bit-portable.zip")
|
|
||||||
SET(EQEMU_MSVC_DEPENDENCIES_VCPKG_X86_ZIP "vcpkg-export-x86.zip")
|
|
||||||
SET(EQEMU_MSVC_DEPENDENCIES_VCPKG_X64_ZIP "vcpkg-export-x64.zip")
|
|
||||||
SET(EQEMU_MSVC_DEPENDENCIES_VCPKG_X86_DIR "vcpkg-export-x86")
|
|
||||||
SET(EQEMU_MSVC_DEPENDENCIES_VCPKG_X64_DIR "vcpkg-export-x64")
|
|
||||||
SET(EQEMU_MSVC_DEPENDENCIES_PERL_X86_ZIP "strawberry-perl-5.24.4.1-32bit-portable.zip")
|
|
||||||
SET(EQEMU_MSVC_DEPENDENCIES_PERL_X64_ZIP "strawberry-perl-5.24.4.1-64bit-portable.zip")
|
|
||||||
SET(EQEMU_MSVC_DEPENDENCIES_PERL_X86_DIR "x86")
|
|
||||||
SET(EQEMU_MSVC_DEPENDENCIES_PERL_X64_DIR "x64")
|
|
||||||
|
|
||||||
IF(CMAKE_SIZEOF_VOID_P EQUAL 8)
|
|
||||||
SET(EQEMU_VCPKG_URL ${EQEMU_MSVC_DEPENDENCIES_VCPKG_X64})
|
|
||||||
SET(EQEMU_PERL_URL ${EQEMU_MSVC_DEPENDENCIES_PERL_X64})
|
|
||||||
SET(EQEMU_VCPKG_ZIP ${EQEMU_MSVC_DEPENDENCIES_VCPKG_X64_ZIP})
|
|
||||||
SET(EQEMU_VCPKG_DIR ${EQEMU_MSVC_DEPENDENCIES_VCPKG_X64_DIR})
|
|
||||||
SET(EQEMU_PERL_ZIP ${EQEMU_MSVC_DEPENDENCIES_PERL_X64_ZIP})
|
|
||||||
SET(EQEMU_PERL_DIR ${EQEMU_MSVC_DEPENDENCIES_PERL_X64_DIR})
|
|
||||||
ELSE()
|
|
||||||
SET(EQEMU_VCPKG_URL ${EQEMU_MSVC_DEPENDENCIES_VCPKG_X86})
|
|
||||||
SET(EQEMU_PERL_URL ${EQEMU_MSVC_DEPENDENCIES_PERL_X86})
|
|
||||||
SET(EQEMU_VCPKG_ZIP ${EQEMU_MSVC_DEPENDENCIES_VCPKG_X86_ZIP})
|
|
||||||
SET(EQEMU_VCPKG_DIR ${EQEMU_MSVC_DEPENDENCIES_VCPKG_X86_DIR})
|
|
||||||
SET(EQEMU_PERL_ZIP ${EQEMU_MSVC_DEPENDENCIES_PERL_X86_ZIP})
|
|
||||||
SET(EQEMU_PERL_DIR ${EQEMU_MSVC_DEPENDENCIES_PERL_X86_DIR})
|
|
||||||
ENDIF()
|
|
||||||
|
|
||||||
IF(EQEMU_FETCH_MSVC_DEPENDENCIES_VCPKG)
|
|
||||||
MESSAGE(STATUS "Resolving vcpkg dependencies...")
|
|
||||||
|
|
||||||
IF(NOT EXISTS ${PROJECT_SOURCE_DIR}/vcpkg/${EQEMU_VCPKG_ZIP})
|
|
||||||
EXECUTE_PROCESS(COMMAND ${CMAKE_COMMAND} -E make_directory ${PROJECT_SOURCE_DIR}/vcpkg)
|
|
||||||
|
|
||||||
MESSAGE(STATUS "Downloading existing vcpkg dependencies from releases...")
|
|
||||||
FILE(DOWNLOAD ${EQEMU_VCPKG_URL} ${PROJECT_SOURCE_DIR}/vcpkg/${EQEMU_VCPKG_ZIP}
|
|
||||||
SHOW_PROGRESS
|
|
||||||
STATUS DOWNLOAD_STATUS)
|
|
||||||
|
|
||||||
LIST(GET DOWNLOAD_STATUS 0 STATUS_CODE)
|
|
||||||
IF(NOT STATUS_CODE EQUAL 0)
|
|
||||||
MESSAGE(FATAL_ERROR "Was unable to download dependencies from ${EQEMU_VCPKG_URL}")
|
|
||||||
ENDIF()
|
|
||||||
|
|
||||||
MESSAGE(STATUS "Extracting files...")
|
|
||||||
EXECUTE_PROCESS(
|
|
||||||
COMMAND ${CMAKE_COMMAND} -E tar xzf ${PROJECT_SOURCE_DIR}/vcpkg/${EQEMU_VCPKG_ZIP}
|
|
||||||
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/vcpkg
|
|
||||||
)
|
|
||||||
ENDIF()
|
|
||||||
|
|
||||||
INCLUDE(${PROJECT_SOURCE_DIR}/vcpkg/${EQEMU_VCPKG_DIR}/scripts/buildsystems/vcpkg.cmake)
|
|
||||||
ENDIF()
|
|
||||||
|
|
||||||
IF(EQEMU_FETCH_MSVC_DEPENDENCIES_PERL)
|
|
||||||
#Try to find perl first, (so you can use your active install first)
|
|
||||||
FIND_PACKAGE(PerlLibs)
|
|
||||||
|
|
||||||
IF(NOT PerlLibs_FOUND)
|
|
||||||
MESSAGE(STATUS "Resolving perl dependencies...")
|
|
||||||
|
|
||||||
IF(NOT EXISTS ${PROJECT_SOURCE_DIR}/perl/${EQEMU_PERL_ZIP})
|
|
||||||
EXECUTE_PROCESS(COMMAND ${CMAKE_COMMAND} -E make_directory ${PROJECT_SOURCE_DIR}/perl)
|
|
||||||
EXECUTE_PROCESS(COMMAND ${CMAKE_COMMAND} -E make_directory ${PROJECT_SOURCE_DIR}/perl/${EQEMU_PERL_DIR})
|
|
||||||
|
|
||||||
MESSAGE(STATUS "Downloading portable perl...")
|
|
||||||
FILE(DOWNLOAD ${EQEMU_PERL_URL} ${PROJECT_SOURCE_DIR}/perl/${EQEMU_PERL_ZIP}
|
|
||||||
SHOW_PROGRESS
|
|
||||||
STATUS DOWNLOAD_STATUS)
|
|
||||||
|
|
||||||
LIST(GET DOWNLOAD_STATUS 0 STATUS_CODE)
|
|
||||||
IF(NOT STATUS_CODE EQUAL 0)
|
|
||||||
MESSAGE(FATAL_ERROR "Was unable to download dependencies from ${EQEMU_PERL_URL}")
|
|
||||||
ENDIF()
|
|
||||||
|
|
||||||
MESSAGE(STATUS "Extracting files...")
|
|
||||||
EXECUTE_PROCESS(
|
|
||||||
COMMAND ${CMAKE_COMMAND} -E tar xzf ${PROJECT_SOURCE_DIR}/perl/${EQEMU_PERL_ZIP}
|
|
||||||
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/perl/${EQEMU_PERL_DIR}
|
|
||||||
)
|
|
||||||
ENDIF()
|
|
||||||
|
|
||||||
SET(PERL_EXECUTABLE ${PROJECT_SOURCE_DIR}/perl/${EQEMU_PERL_DIR}/perl/bin/perl.exe CACHE FILEPATH "Path to perl program" FORCE)
|
|
||||||
SET(PERL_INCLUDE_PATH ${PROJECT_SOURCE_DIR}/perl/${EQEMU_PERL_DIR}/perl/lib/CORE CACHE PATH "Path to perl include files" FORCE)
|
|
||||||
SET(PERL_LIBRARY ${PROJECT_SOURCE_DIR}/perl/${EQEMU_PERL_DIR}/perl/lib/CORE/libperl524.a CACHE FILEPATH "Path to perl library" FORCE)
|
|
||||||
ENDIF()
|
|
||||||
ENDIF()
|
|
||||||
@@ -1,91 +0,0 @@
|
|||||||
# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
|
|
||||||
# file Copyright.txt or https://cmake.org/licensing for details.
|
|
||||||
# Modified from the FindLua51 that comes with CMake
|
|
||||||
|
|
||||||
#[=======================================================================[.rst:
|
|
||||||
FindLua51
|
|
||||||
---------
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Locate Lua51 library This module defines
|
|
||||||
|
|
||||||
::
|
|
||||||
|
|
||||||
LUA51_FOUND, if false, do not try to link to Lua
|
|
||||||
LUA_LIBRARIES
|
|
||||||
LUA_INCLUDE_DIR, where to find lua.h
|
|
||||||
LUA_VERSION_STRING, the version of Lua found (since CMake 2.8.8)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Note that the expected include convention is
|
|
||||||
|
|
||||||
::
|
|
||||||
|
|
||||||
#include "lua.h"
|
|
||||||
|
|
||||||
and not
|
|
||||||
|
|
||||||
::
|
|
||||||
|
|
||||||
#include <lua/lua.h>
|
|
||||||
|
|
||||||
This is because, the lua location is not standardized and may exist in
|
|
||||||
locations other than lua/
|
|
||||||
#]=======================================================================]
|
|
||||||
|
|
||||||
find_path(LUA_INCLUDE_DIR lua.h
|
|
||||||
HINTS
|
|
||||||
ENV LUA_DIR
|
|
||||||
PATH_SUFFIXES include/lua51 include/lua5.1 include/lua-5.1 include/lua include
|
|
||||||
PATHS
|
|
||||||
~/Library/Frameworks
|
|
||||||
/Library/Frameworks
|
|
||||||
/sw # Fink
|
|
||||||
/opt/local # DarwinPorts
|
|
||||||
/opt/csw # Blastwave
|
|
||||||
/opt
|
|
||||||
)
|
|
||||||
|
|
||||||
find_library(LUA_LIBRARY
|
|
||||||
NAMES lua51 lua5.1 lua-5.1 lua
|
|
||||||
HINTS
|
|
||||||
ENV LUA_DIR
|
|
||||||
PATH_SUFFIXES lib
|
|
||||||
PATHS
|
|
||||||
~/Library/Frameworks
|
|
||||||
/Library/Frameworks
|
|
||||||
/sw
|
|
||||||
/opt/local
|
|
||||||
/opt/csw
|
|
||||||
/opt
|
|
||||||
)
|
|
||||||
|
|
||||||
if(LUA_LIBRARY)
|
|
||||||
# include the math library for Unix
|
|
||||||
if(UNIX AND NOT APPLE AND NOT BEOS AND NOT HAIKU)
|
|
||||||
find_library(LUA_MATH_LIBRARY m)
|
|
||||||
set( LUA_LIBRARIES "${LUA_LIBRARY};${LUA_MATH_LIBRARY}" CACHE STRING "Lua Libraries")
|
|
||||||
# For Windows and Mac, don't need to explicitly include the math library
|
|
||||||
else()
|
|
||||||
set( LUA_LIBRARIES "${LUA_LIBRARY}" CACHE STRING "Lua Libraries")
|
|
||||||
endif()
|
|
||||||
endif()
|
|
||||||
|
|
||||||
if(LUA_INCLUDE_DIR AND EXISTS "${LUA_INCLUDE_DIR}/lua.h")
|
|
||||||
file(STRINGS "${LUA_INCLUDE_DIR}/lua.h" lua_version_str REGEX "^#define[ \t]+LUA_RELEASE[ \t]+\"Lua .+\"")
|
|
||||||
|
|
||||||
string(REGEX REPLACE "^#define[ \t]+LUA_RELEASE[ \t]+\"Lua ([^\"]+)\".*" "\\1" LUA_VERSION_STRING "${lua_version_str}")
|
|
||||||
unset(lua_version_str)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
include(${CMAKE_ROOT}/Modules/FindPackageHandleStandardArgs.cmake)
|
|
||||||
# handle the QUIETLY and REQUIRED arguments and set LUA51_FOUND to TRUE if
|
|
||||||
# all listed variables are TRUE
|
|
||||||
FIND_PACKAGE_HANDLE_STANDARD_ARGS(Lua51
|
|
||||||
REQUIRED_VARS LUA_LIBRARIES LUA_INCLUDE_DIR
|
|
||||||
VERSION_VAR LUA_VERSION_STRING)
|
|
||||||
|
|
||||||
mark_as_advanced(LUA_INCLUDE_DIR LUA_LIBRARIES LUA_LIBRARY LUA_MATH_LIBRARY)
|
|
||||||
|
|
||||||
@@ -88,4 +88,3 @@ FIND_PACKAGE_HANDLE_STANDARD_ARGS(LuaJit
|
|||||||
VERSION_VAR LUAJIT_VERSION_STRING)
|
VERSION_VAR LUAJIT_VERSION_STRING)
|
||||||
|
|
||||||
mark_as_advanced(LUAJIT_INCLUDE_DIR LUAJIT_LIBRARIES LUAJIT_LIBRARY LUAJIT_MATH_LIBRARY)
|
mark_as_advanced(LUAJIT_INCLUDE_DIR LUAJIT_LIBRARIES LUAJIT_LIBRARY LUAJIT_MATH_LIBRARY)
|
||||||
|
|
||||||
|
|||||||
@@ -1,87 +0,0 @@
|
|||||||
# - Find mariadbclient
|
|
||||||
#
|
|
||||||
# -*- cmake -*-
|
|
||||||
#
|
|
||||||
# Find the native MariaDB includes and library
|
|
||||||
#
|
|
||||||
# MariaDB_INCLUDE_DIR - where to find mysql.h, etc.
|
|
||||||
# MariaDB_LIBRARIES - List of libraries when using MariaDB.
|
|
||||||
# MariaDB_FOUND - True if MariaDB found.
|
|
||||||
# The following can be used as a hint as to where to search:
|
|
||||||
# MARIADB_ROOT
|
|
||||||
|
|
||||||
IF (MariaDB_INCLUDE_DIR AND MariaDB_LIBRARIES)
|
|
||||||
# Already in cache, be silent
|
|
||||||
SET(MariaDB_FIND_QUIETLY TRUE)
|
|
||||||
ENDIF (MariaDB_INCLUDE_DIR AND MariaDB_LIBRARIES)
|
|
||||||
|
|
||||||
# Include dir
|
|
||||||
IF(MARIADB_ROOT)
|
|
||||||
FIND_PATH(MariaDB_INCLUDE_DIR
|
|
||||||
NAMES mariadb_version.h
|
|
||||||
PATHS ${MARIADB_ROOT}/include
|
|
||||||
PATH_SUFFIXES mysql mariadb
|
|
||||||
NO_DEFAULT_PATH
|
|
||||||
NO_SYSTEM_ENVIRONMENT_PATH
|
|
||||||
)
|
|
||||||
FIND_PATH(MariaDB_INCLUDE_DIR
|
|
||||||
NAMES mariadb_version.h
|
|
||||||
PATH_SUFFIXES mysql mariadb
|
|
||||||
)
|
|
||||||
ELSE(MARIADB_ROOT)
|
|
||||||
FIND_PATH(MariaDB_INCLUDE_DIR
|
|
||||||
NAMES mariadb_version.h
|
|
||||||
PATH_SUFFIXES mysql mariadb
|
|
||||||
)
|
|
||||||
ENDIF(MARIADB_ROOT)
|
|
||||||
|
|
||||||
# Library
|
|
||||||
SET(MariaDB_NAMES libmariadb)
|
|
||||||
IF(MARIADB_ROOT)
|
|
||||||
FIND_LIBRARY(MariaDB_LIBRARY
|
|
||||||
NAMES ${MariaDB_NAMES}
|
|
||||||
PATHS ${MARIADB_ROOT}/lib
|
|
||||||
PATH_SUFFIXES mysql mariadb
|
|
||||||
NO_DEFAULT_PATH
|
|
||||||
NO_SYSTEM_ENVIRONMENT_PATH
|
|
||||||
)
|
|
||||||
|
|
||||||
FIND_LIBRARY(MariaDB_LIBRARY
|
|
||||||
NAMES ${MariaDB_NAMES}
|
|
||||||
PATH_SUFFIXES mysql mariadb
|
|
||||||
)
|
|
||||||
ELSE(MARIADB_ROOT)
|
|
||||||
FIND_LIBRARY(MariaDB_LIBRARY
|
|
||||||
NAMES ${MariaDB_NAMES} mariadbclient_r mariadbclient
|
|
||||||
PATHS /usr/lib /usr/local/lib /usr/lib64 /usr/local/lib64
|
|
||||||
PATH_SUFFIXES mysql mariadb
|
|
||||||
)
|
|
||||||
ENDIF(MARIADB_ROOT)
|
|
||||||
|
|
||||||
IF (MariaDB_INCLUDE_DIR AND MariaDB_LIBRARY)
|
|
||||||
SET(MariaDB_FOUND TRUE)
|
|
||||||
SET(MariaDB_LIBRARIES ${MariaDB_LIBRARY})
|
|
||||||
ELSE (MariaDB_INCLUDE_DIR AND MariaDB_LIBRARY)
|
|
||||||
SET(MariaDB_FOUND FALSE)
|
|
||||||
SET(MariaDB_LIBRARIES)
|
|
||||||
ENDIF (MariaDB_INCLUDE_DIR AND MariaDB_LIBRARY)
|
|
||||||
|
|
||||||
|
|
||||||
# handle the QUIETLY and REQUIRED arguments and set MariaDB_FOUND to TRUE if
|
|
||||||
# all listed variables are TRUE
|
|
||||||
INCLUDE(FindPackageHandleStandardArgs)
|
|
||||||
FIND_PACKAGE_HANDLE_STANDARD_ARGS(MariaDB DEFAULT_MSG MariaDB_LIBRARY MariaDB_INCLUDE_DIR)
|
|
||||||
|
|
||||||
IF(MariaDB_FOUND)
|
|
||||||
SET( MariaDB_LIBRARY_RELEASE ${MariaDB_LIBRARY} )
|
|
||||||
SET( MariaDB_LIBRARY_DEBUG ${MariaDB_LIBRARY} )
|
|
||||||
SET( MariaDB_LIBRARIES ${MariaDB_LIBRARY_RELEASE} ${MariaDB_LIBRARY_DEBUG} )
|
|
||||||
ELSE(MariaDB_FOUND)
|
|
||||||
SET( MariaDB_LIBRARIES )
|
|
||||||
ENDIF(MariaDB_FOUND)
|
|
||||||
|
|
||||||
MARK_AS_ADVANCED(
|
|
||||||
MariaDB_LIBRARY_DEBUG
|
|
||||||
MariaDB_LIBRARY_RELEASE
|
|
||||||
MariaDB_INCLUDE_DIR
|
|
||||||
)
|
|
||||||
@@ -1,87 +0,0 @@
|
|||||||
# - Find mysqlclient
|
|
||||||
#
|
|
||||||
# -*- cmake -*-
|
|
||||||
#
|
|
||||||
# Find the native MySQL includes and library
|
|
||||||
#
|
|
||||||
# MySQL_INCLUDE_DIR - where to find mysql.h, etc.
|
|
||||||
# MySQL_LIBRARIES - List of libraries when using MySQL.
|
|
||||||
# MySQL_FOUND - True if MySQL found.
|
|
||||||
# The following can be used as a hint as to where to search:
|
|
||||||
# MYSQL_ROOT
|
|
||||||
|
|
||||||
IF (MySQL_INCLUDE_DIR AND MySQL_LIBRARIES)
|
|
||||||
# Already in cache, be silent
|
|
||||||
SET(MySQL_FIND_QUIETLY TRUE)
|
|
||||||
ENDIF (MySQL_INCLUDE_DIR AND MySQL_LIBRARIES)
|
|
||||||
|
|
||||||
# Include dir
|
|
||||||
IF(MYSQL_ROOT)
|
|
||||||
FIND_PATH(MySQL_INCLUDE_DIR
|
|
||||||
NAMES mysql.h
|
|
||||||
PATHS ${MYSQL_ROOT}/include
|
|
||||||
PATH_SUFFIXES mysql
|
|
||||||
NO_DEFAULT_PATH
|
|
||||||
NO_SYSTEM_ENVIRONMENT_PATH
|
|
||||||
)
|
|
||||||
FIND_PATH(MySQL_INCLUDE_DIR
|
|
||||||
NAMES mysql.h
|
|
||||||
PATH_SUFFIXES mysql
|
|
||||||
)
|
|
||||||
ELSE(MYSQL_ROOT)
|
|
||||||
FIND_PATH(MySQL_INCLUDE_DIR
|
|
||||||
NAMES mysql.h
|
|
||||||
PATH_SUFFIXES mysql
|
|
||||||
)
|
|
||||||
ENDIF(MYSQL_ROOT)
|
|
||||||
|
|
||||||
# Library
|
|
||||||
SET(MySQL_NAMES libmysql)
|
|
||||||
IF(MYSQL_ROOT)
|
|
||||||
FIND_LIBRARY(MySQL_LIBRARY
|
|
||||||
NAMES ${MySQL_NAMES}
|
|
||||||
PATHS ${MYSQL_ROOT}/lib
|
|
||||||
PATH_SUFFIXES mysql
|
|
||||||
NO_DEFAULT_PATH
|
|
||||||
NO_SYSTEM_ENVIRONMENT_PATH
|
|
||||||
)
|
|
||||||
|
|
||||||
FIND_LIBRARY(MySQL_LIBRARY
|
|
||||||
NAMES ${MySQL_NAMES}
|
|
||||||
PATH_SUFFIXES mysql
|
|
||||||
)
|
|
||||||
ELSE(MYSQL_ROOT)
|
|
||||||
FIND_LIBRARY(MySQL_LIBRARY
|
|
||||||
NAMES ${MySQL_NAMES} mysqlclient_r mysqlclient
|
|
||||||
PATHS /usr/lib /usr/local/lib /usr/lib64 /usr/local/lib64
|
|
||||||
PATH_SUFFIXES mysql
|
|
||||||
)
|
|
||||||
ENDIF(MYSQL_ROOT)
|
|
||||||
|
|
||||||
IF (MySQL_INCLUDE_DIR AND MySQL_LIBRARY)
|
|
||||||
SET(MySQL_FOUND TRUE)
|
|
||||||
SET( MySQL_LIBRARIES ${MySQL_LIBRARY} )
|
|
||||||
ELSE (MySQL_INCLUDE_DIR AND MySQL_LIBRARY)
|
|
||||||
SET(MySQL_FOUND FALSE)
|
|
||||||
SET( MySQL_LIBRARIES )
|
|
||||||
ENDIF (MySQL_INCLUDE_DIR AND MySQL_LIBRARY)
|
|
||||||
|
|
||||||
|
|
||||||
# handle the QUIETLY and REQUIRED arguments and set MySQL_FOUND to TRUE if
|
|
||||||
# all listed variables are TRUE
|
|
||||||
INCLUDE(FindPackageHandleStandardArgs)
|
|
||||||
FIND_PACKAGE_HANDLE_STANDARD_ARGS(MySQL DEFAULT_MSG MySQL_LIBRARY MySQL_INCLUDE_DIR)
|
|
||||||
|
|
||||||
IF(MySQL_FOUND)
|
|
||||||
SET( MySQL_LIBRARY_RELEASE ${MySQL_LIBRARY} )
|
|
||||||
SET( MySQL_LIBRARY_DEBUG ${MySQL_LIBRARY} )
|
|
||||||
SET( MySQL_LIBRARIES ${MySQL_LIBRARY_RELEASE} ${MySQL_LIBRARY_DEBUG} )
|
|
||||||
ELSE(MySQL_FOUND)
|
|
||||||
SET( MySQL_LIBRARIES )
|
|
||||||
ENDIF(MySQL_FOUND)
|
|
||||||
|
|
||||||
MARK_AS_ADVANCED(
|
|
||||||
MySQL_LIBRARY_DEBUG
|
|
||||||
MySQL_LIBRARY_RELEASE
|
|
||||||
MySQL_INCLUDE_DIR
|
|
||||||
)
|
|
||||||
@@ -1,30 +0,0 @@
|
|||||||
if (NOT MSVC)
|
|
||||||
include(FindPkgConfig)
|
|
||||||
pkg_check_modules(PC_SODIUM "libsodium")
|
|
||||||
if (NOT PC_SODIUM_FOUND)
|
|
||||||
pkg_check_modules(PC_SODIUM "sodium")
|
|
||||||
endif (NOT PC_SODIUM_FOUND)
|
|
||||||
if (PC_SODIUM_FOUND)
|
|
||||||
set(SODIUM_INCLUDE_HINTS ${PC_SODIUM_INCLUDE_DIRS} ${PC_SODIUM_INCLUDE_DIRS}/*)
|
|
||||||
set(SODIUM_LIBRARY_HINTS ${PC_SODIUM_LIBRARY_DIRS} ${PC_SODIUM_LIBRARY_DIRS}/*)
|
|
||||||
endif()
|
|
||||||
endif (NOT MSVC)
|
|
||||||
|
|
||||||
# some libraries install the headers is a subdirectory of the include dir
|
|
||||||
# returned by pkg-config, so use a wildcard match to improve chances of finding
|
|
||||||
# headers and libraries.
|
|
||||||
find_path(
|
|
||||||
SODIUM_INCLUDE_DIRS
|
|
||||||
NAMES sodium.h
|
|
||||||
HINTS ${SODIUM_INCLUDE_HINTS}
|
|
||||||
)
|
|
||||||
|
|
||||||
find_library(
|
|
||||||
SODIUM_LIBRARIES
|
|
||||||
NAMES libsodium sodium
|
|
||||||
HINTS ${SODIUM_LIBRARY_HINTS}
|
|
||||||
)
|
|
||||||
|
|
||||||
include(FindPackageHandleStandardArgs)
|
|
||||||
find_package_handle_standard_args(SODIUM DEFAULT_MSG SODIUM_LIBRARIES SODIUM_INCLUDE_DIRS)
|
|
||||||
mark_as_advanced(SODIUM_FOUND SODIUM_LIBRARIES SODIUM_INCLUDE_DIRS)
|
|
||||||
@@ -1,93 +0,0 @@
|
|||||||
# - Try to find mbedTLS
|
|
||||||
# Once done this will define
|
|
||||||
#
|
|
||||||
# Read-Only variables
|
|
||||||
# MBEDTLS_FOUND - system has mbedTLS
|
|
||||||
# MBEDTLS_INCLUDE_DIR - the mbedTLS include directory
|
|
||||||
# MBEDTLS_LIBRARY_DIR - the mbedTLS library directory
|
|
||||||
# MBEDTLS_LIBRARIES - Link these to use mbedTLS
|
|
||||||
# MBEDTLS_LIBRARY - path to mbedTLS library
|
|
||||||
# MBEDX509_LIBRARY - path to mbedTLS X.509 library
|
|
||||||
# MBEDCRYPTO_LIBRARY - path to mbedTLS Crypto library
|
|
||||||
#
|
|
||||||
# Hint
|
|
||||||
# MBEDTLS_ROOT_DIR can be pointed to a local mbedTLS installation.
|
|
||||||
|
|
||||||
SET(_MBEDTLS_ROOT_HINTS
|
|
||||||
${MBEDTLS_ROOT_DIR}
|
|
||||||
ENV MBEDTLS_ROOT_DIR
|
|
||||||
)
|
|
||||||
|
|
||||||
SET(_MBEDTLS_ROOT_HINTS_AND_PATHS
|
|
||||||
HINTS ${_MBEDTLS_ROOT_HINTS}
|
|
||||||
PATHS ${_MBEDTLS_ROOT_PATHS}
|
|
||||||
)
|
|
||||||
|
|
||||||
FIND_PATH(MBEDTLS_INCLUDE_DIR
|
|
||||||
NAMES mbedtls/version.h
|
|
||||||
${_MBEDTLS_ROOT_HINTS_AND_PATHS}
|
|
||||||
PATH_SUFFIXES include
|
|
||||||
)
|
|
||||||
|
|
||||||
IF(MBEDTLS_INCLUDE_DIR AND MBEDTLS_LIBRARIES)
|
|
||||||
# Already in cache, be silent
|
|
||||||
SET(MBEDTLS_FIND_QUIETLY TRUE)
|
|
||||||
ENDIF()
|
|
||||||
|
|
||||||
FIND_LIBRARY(MBEDTLS_LIBRARY
|
|
||||||
NAMES mbedtls libmbedtls
|
|
||||||
${_MBEDTLS_ROOT_HINTS_AND_PATHS}
|
|
||||||
PATH_SUFFIXES library
|
|
||||||
)
|
|
||||||
FIND_LIBRARY(MBEDX509_LIBRARY
|
|
||||||
NAMES mbedx509 libmbedx509
|
|
||||||
${_MBEDTLS_ROOT_HINTS_AND_PATHS}
|
|
||||||
PATH_SUFFIXES library
|
|
||||||
)
|
|
||||||
FIND_LIBRARY(MBEDCRYPTO_LIBRARY
|
|
||||||
NAMES mbedcrypto libmbedcrypto
|
|
||||||
${_MBEDTLS_ROOT_HINTS_AND_PATHS}
|
|
||||||
PATH_SUFFIXES library
|
|
||||||
)
|
|
||||||
|
|
||||||
IF(MBEDTLS_INCLUDE_DIR AND MBEDTLS_LIBRARY AND MBEDX509_LIBRARY AND MBEDCRYPTO_LIBRARY)
|
|
||||||
SET(MBEDTLS_FOUND TRUE)
|
|
||||||
ENDIF()
|
|
||||||
|
|
||||||
IF(MBEDTLS_FOUND)
|
|
||||||
# split mbedTLS into -L and -l linker options, so we can set them for pkg-config
|
|
||||||
GET_FILENAME_COMPONENT(MBEDTLS_LIBRARY_DIR ${MBEDTLS_LIBRARY} PATH)
|
|
||||||
GET_FILENAME_COMPONENT(MBEDTLS_LIBRARY_FILE ${MBEDTLS_LIBRARY} NAME_WE)
|
|
||||||
GET_FILENAME_COMPONENT(MBEDX509_LIBRARY_FILE ${MBEDX509_LIBRARY} NAME_WE)
|
|
||||||
GET_FILENAME_COMPONENT(MBEDCRYPTO_LIBRARY_FILE ${MBEDCRYPTO_LIBRARY} NAME_WE)
|
|
||||||
STRING(REGEX REPLACE "^lib" "" MBEDTLS_LIBRARY_FILE ${MBEDTLS_LIBRARY_FILE})
|
|
||||||
STRING(REGEX REPLACE "^lib" "" MBEDX509_LIBRARY_FILE ${MBEDX509_LIBRARY_FILE})
|
|
||||||
STRING(REGEX REPLACE "^lib" "" MBEDCRYPTO_LIBRARY_FILE ${MBEDCRYPTO_LIBRARY_FILE})
|
|
||||||
SET(MBEDTLS_LIBRARIES "-L${MBEDTLS_LIBRARY_DIR} -l${MBEDTLS_LIBRARY_FILE} -l${MBEDX509_LIBRARY_FILE} -l${MBEDCRYPTO_LIBRARY_FILE}")
|
|
||||||
|
|
||||||
IF(NOT MBEDTLS_FIND_QUIETLY)
|
|
||||||
MESSAGE(STATUS "Found mbedTLS:")
|
|
||||||
FILE(READ ${MBEDTLS_INCLUDE_DIR}/mbedtls/version.h MBEDTLSCONTENT)
|
|
||||||
STRING(REGEX MATCH "MBEDTLS_VERSION_STRING +\"[0-9|.]+\"" MBEDTLSMATCH ${MBEDTLSCONTENT})
|
|
||||||
IF (MBEDTLSMATCH)
|
|
||||||
STRING(REGEX REPLACE "MBEDTLS_VERSION_STRING +\"([0-9|.]+)\"" "\\1" MBEDTLS_VERSION ${MBEDTLSMATCH})
|
|
||||||
MESSAGE(STATUS " version ${MBEDTLS_VERSION}")
|
|
||||||
ENDIF(MBEDTLSMATCH)
|
|
||||||
MESSAGE(STATUS " TLS: ${MBEDTLS_LIBRARY}")
|
|
||||||
MESSAGE(STATUS " X509: ${MBEDX509_LIBRARY}")
|
|
||||||
MESSAGE(STATUS " Crypto: ${MBEDCRYPTO_LIBRARY}")
|
|
||||||
ENDIF(NOT MBEDTLS_FIND_QUIETLY)
|
|
||||||
ELSE(MBEDTLS_FOUND)
|
|
||||||
IF(MBEDTLS_FIND_REQUIRED)
|
|
||||||
MESSAGE(FATAL_ERROR "Could not find mbedTLS")
|
|
||||||
ENDIF(MBEDTLS_FIND_REQUIRED)
|
|
||||||
ENDIF(MBEDTLS_FOUND)
|
|
||||||
|
|
||||||
MARK_AS_ADVANCED(
|
|
||||||
MBEDTLS_INCLUDE_DIR
|
|
||||||
MBEDTLS_LIBRARY_DIR
|
|
||||||
MBEDTLS_LIBRARIES
|
|
||||||
MBEDTLS_LIBRARY
|
|
||||||
MBEDX509_LIBRARY
|
|
||||||
MBEDCRYPTO_LIBRARY
|
|
||||||
)
|
|
||||||
+538
-36
@@ -1,6 +1,6 @@
|
|||||||
CMAKE_MINIMUM_REQUIRED(VERSION 3.12)
|
cmake_minimum_required(VERSION 3.20.0)
|
||||||
|
|
||||||
SET(common_sources
|
set(common_sources
|
||||||
base_packet.cpp
|
base_packet.cpp
|
||||||
bazaar.cpp
|
bazaar.cpp
|
||||||
bodytypes.cpp
|
bodytypes.cpp
|
||||||
@@ -16,12 +16,12 @@ SET(common_sources
|
|||||||
database/database_dump_service.cpp
|
database/database_dump_service.cpp
|
||||||
database.cpp
|
database.cpp
|
||||||
database_instances.cpp
|
database_instances.cpp
|
||||||
database/database_update_manifest.cpp
|
|
||||||
database/database_update_manifest_bots.cpp
|
|
||||||
database/database_update.cpp
|
database/database_update.cpp
|
||||||
|
data_bucket.cpp
|
||||||
dbcore.cpp
|
dbcore.cpp
|
||||||
deity.cpp
|
deity.cpp
|
||||||
dynamic_zone_base.cpp
|
dynamic_zone_base.cpp
|
||||||
|
dynamic_zone_lockout.cpp
|
||||||
emu_constants.cpp
|
emu_constants.cpp
|
||||||
emu_limits.cpp
|
emu_limits.cpp
|
||||||
emu_opcodes.cpp
|
emu_opcodes.cpp
|
||||||
@@ -39,7 +39,7 @@ SET(common_sources
|
|||||||
event_sub.cpp
|
event_sub.cpp
|
||||||
events/player_event_logs.cpp
|
events/player_event_logs.cpp
|
||||||
events/player_event_discord_formatter.cpp
|
events/player_event_discord_formatter.cpp
|
||||||
expedition_lockout_timer.cpp
|
evolving_items.cpp
|
||||||
extprofile.cpp
|
extprofile.cpp
|
||||||
discord/discord_manager.cpp
|
discord/discord_manager.cpp
|
||||||
faction.cpp
|
faction.cpp
|
||||||
@@ -62,6 +62,7 @@ SET(common_sources
|
|||||||
mutex.cpp
|
mutex.cpp
|
||||||
mysql_request_result.cpp
|
mysql_request_result.cpp
|
||||||
mysql_request_row.cpp
|
mysql_request_row.cpp
|
||||||
|
mysql_stmt.cpp
|
||||||
opcode_map.cpp
|
opcode_map.cpp
|
||||||
opcodemgr.cpp
|
opcodemgr.cpp
|
||||||
packet_dump.cpp
|
packet_dump.cpp
|
||||||
@@ -87,7 +88,10 @@ SET(common_sources
|
|||||||
skills.cpp
|
skills.cpp
|
||||||
skill_caps.cpp
|
skill_caps.cpp
|
||||||
spdat.cpp
|
spdat.cpp
|
||||||
|
spdat_bot.cpp
|
||||||
strings.cpp
|
strings.cpp
|
||||||
|
strings_legacy.cpp
|
||||||
|
strings_misc.cpp
|
||||||
struct_strategy.cpp
|
struct_strategy.cpp
|
||||||
textures.cpp
|
textures.cpp
|
||||||
timer.cpp
|
timer.cpp
|
||||||
@@ -96,12 +100,13 @@ SET(common_sources
|
|||||||
json/json.hpp
|
json/json.hpp
|
||||||
json/jsoncpp.cpp
|
json/jsoncpp.cpp
|
||||||
zone_store.cpp
|
zone_store.cpp
|
||||||
|
memory/ksm.hpp
|
||||||
net/console_server.cpp
|
net/console_server.cpp
|
||||||
net/console_server_connection.cpp
|
net/console_server_connection.cpp
|
||||||
net/crc32.cpp
|
net/crc32.cpp
|
||||||
net/daybreak_connection.cpp
|
|
||||||
net/eqstream.cpp
|
net/eqstream.cpp
|
||||||
net/packet.cpp
|
net/packet.cpp
|
||||||
|
net/reliable_stream_connection.cpp
|
||||||
net/servertalk_client_connection.cpp
|
net/servertalk_client_connection.cpp
|
||||||
net/servertalk_legacy_client_connection.cpp
|
net/servertalk_legacy_client_connection.cpp
|
||||||
net/servertalk_server.cpp
|
net/servertalk_server.cpp
|
||||||
@@ -127,7 +132,7 @@ SET(common_sources
|
|||||||
util/directory.cpp
|
util/directory.cpp
|
||||||
util/uuid.cpp)
|
util/uuid.cpp)
|
||||||
|
|
||||||
SET(repositories
|
set(repositories
|
||||||
|
|
||||||
# Criteria
|
# Criteria
|
||||||
repositories/criteria/content_filter_criteria.h
|
repositories/criteria/content_filter_criteria.h
|
||||||
@@ -171,6 +176,7 @@ SET(repositories
|
|||||||
repositories/base/base_character_currency_repository.h
|
repositories/base/base_character_currency_repository.h
|
||||||
repositories/base/base_character_data_repository.h
|
repositories/base/base_character_data_repository.h
|
||||||
repositories/base/base_character_disciplines_repository.h
|
repositories/base/base_character_disciplines_repository.h
|
||||||
|
repositories/base/base_character_evolving_items_repository.h
|
||||||
repositories/base/base_character_expedition_lockouts_repository.h
|
repositories/base/base_character_expedition_lockouts_repository.h
|
||||||
repositories/base/base_character_exp_modifiers_repository.h
|
repositories/base/base_character_exp_modifiers_repository.h
|
||||||
repositories/base/base_character_inspect_messages_repository.h
|
repositories/base/base_character_inspect_messages_repository.h
|
||||||
@@ -208,10 +214,9 @@ SET(repositories
|
|||||||
repositories/base/base_discovered_items_repository.h
|
repositories/base/base_discovered_items_repository.h
|
||||||
repositories/base/base_doors_repository.h
|
repositories/base/base_doors_repository.h
|
||||||
repositories/base/base_dynamic_zones_repository.h
|
repositories/base/base_dynamic_zones_repository.h
|
||||||
|
repositories/base/base_dynamic_zone_lockouts_repository.h
|
||||||
repositories/base/base_dynamic_zone_members_repository.h
|
repositories/base/base_dynamic_zone_members_repository.h
|
||||||
repositories/base/base_dynamic_zone_templates_repository.h
|
repositories/base/base_dynamic_zone_templates_repository.h
|
||||||
repositories/base/base_expeditions_repository.h
|
|
||||||
repositories/base/base_expedition_lockouts_repository.h
|
|
||||||
repositories/base/base_faction_association_repository.h
|
repositories/base/base_faction_association_repository.h
|
||||||
repositories/base/base_faction_base_data_repository.h
|
repositories/base/base_faction_base_data_repository.h
|
||||||
repositories/base/base_faction_list_repository.h
|
repositories/base/base_faction_list_repository.h
|
||||||
@@ -239,6 +244,7 @@ SET(repositories
|
|||||||
repositories/base/base_inventory_snapshots_repository.h
|
repositories/base/base_inventory_snapshots_repository.h
|
||||||
repositories/base/base_ip_exemptions_repository.h
|
repositories/base/base_ip_exemptions_repository.h
|
||||||
repositories/base/base_items_repository.h
|
repositories/base/base_items_repository.h
|
||||||
|
repositories/base/base_items_evolving_details_repository.h
|
||||||
repositories/base/base_ldon_trap_entries_repository.h
|
repositories/base/base_ldon_trap_entries_repository.h
|
||||||
repositories/base/base_ldon_trap_templates_repository.h
|
repositories/base/base_ldon_trap_templates_repository.h
|
||||||
repositories/base/base_level_exp_mods_repository.h
|
repositories/base/base_level_exp_mods_repository.h
|
||||||
@@ -276,8 +282,20 @@ SET(repositories
|
|||||||
repositories/base/base_pets_equipmentset_repository.h
|
repositories/base/base_pets_equipmentset_repository.h
|
||||||
repositories/base/base_pets_equipmentset_entries_repository.h
|
repositories/base/base_pets_equipmentset_entries_repository.h
|
||||||
repositories/base/base_player_titlesets_repository.h
|
repositories/base/base_player_titlesets_repository.h
|
||||||
|
repositories/base/base_player_event_aa_purchase_repository.h
|
||||||
|
repositories/base/base_player_event_killed_npc_repository.h
|
||||||
|
repositories/base/base_player_event_killed_named_npc_repository.h
|
||||||
|
repositories/base/base_player_event_killed_raid_npc_repository.h
|
||||||
repositories/base/base_player_event_log_settings_repository.h
|
repositories/base/base_player_event_log_settings_repository.h
|
||||||
repositories/base/base_player_event_logs_repository.h
|
repositories/base/base_player_event_logs_repository.h
|
||||||
|
repositories/base/base_player_event_loot_items_repository.h
|
||||||
|
repositories/base/base_player_event_merchant_purchase_repository.h
|
||||||
|
repositories/base/base_player_event_merchant_sell_repository.h
|
||||||
|
repositories/base/base_player_event_npc_handin_repository.h
|
||||||
|
repositories/base/base_player_event_npc_handin_entries_repository.h
|
||||||
|
repositories/base/base_player_event_speech_repository.h
|
||||||
|
repositories/base/base_player_event_trade_repository.h
|
||||||
|
repositories/base/base_player_event_trade_entries_repository.h
|
||||||
repositories/base/base_quest_globals_repository.h
|
repositories/base/base_quest_globals_repository.h
|
||||||
repositories/base/base_raid_details_repository.h
|
repositories/base/base_raid_details_repository.h
|
||||||
repositories/base/base_raid_members_repository.h
|
repositories/base/base_raid_members_repository.h
|
||||||
@@ -354,6 +372,7 @@ SET(repositories
|
|||||||
repositories/character_currency_repository.h
|
repositories/character_currency_repository.h
|
||||||
repositories/character_data_repository.h
|
repositories/character_data_repository.h
|
||||||
repositories/character_disciplines_repository.h
|
repositories/character_disciplines_repository.h
|
||||||
|
repositories/character_evolving_items_repository.h
|
||||||
repositories/character_expedition_lockouts_repository.h
|
repositories/character_expedition_lockouts_repository.h
|
||||||
repositories/character_exp_modifiers_repository.h
|
repositories/character_exp_modifiers_repository.h
|
||||||
repositories/character_inspect_messages_repository.h
|
repositories/character_inspect_messages_repository.h
|
||||||
@@ -391,10 +410,9 @@ SET(repositories
|
|||||||
repositories/discovered_items_repository.h
|
repositories/discovered_items_repository.h
|
||||||
repositories/doors_repository.h
|
repositories/doors_repository.h
|
||||||
repositories/dynamic_zones_repository.h
|
repositories/dynamic_zones_repository.h
|
||||||
|
repositories/dynamic_zone_lockouts_repository.h
|
||||||
repositories/dynamic_zone_members_repository.h
|
repositories/dynamic_zone_members_repository.h
|
||||||
repositories/dynamic_zone_templates_repository.h
|
repositories/dynamic_zone_templates_repository.h
|
||||||
repositories/expeditions_repository.h
|
|
||||||
repositories/expedition_lockouts_repository.h
|
|
||||||
repositories/faction_association_repository.h
|
repositories/faction_association_repository.h
|
||||||
repositories/faction_base_data_repository.h
|
repositories/faction_base_data_repository.h
|
||||||
repositories/faction_list_repository.h
|
repositories/faction_list_repository.h
|
||||||
@@ -422,6 +440,7 @@ SET(repositories
|
|||||||
repositories/inventory_snapshots_repository.h
|
repositories/inventory_snapshots_repository.h
|
||||||
repositories/ip_exemptions_repository.h
|
repositories/ip_exemptions_repository.h
|
||||||
repositories/items_repository.h
|
repositories/items_repository.h
|
||||||
|
repositories/items_evolving_details_repository.h
|
||||||
repositories/ldon_trap_entries_repository.h
|
repositories/ldon_trap_entries_repository.h
|
||||||
repositories/ldon_trap_templates_repository.h
|
repositories/ldon_trap_templates_repository.h
|
||||||
repositories/level_exp_mods_repository.h
|
repositories/level_exp_mods_repository.h
|
||||||
@@ -459,8 +478,20 @@ SET(repositories
|
|||||||
repositories/pets_equipmentset_repository.h
|
repositories/pets_equipmentset_repository.h
|
||||||
repositories/pets_equipmentset_entries_repository.h
|
repositories/pets_equipmentset_entries_repository.h
|
||||||
repositories/player_titlesets_repository.h
|
repositories/player_titlesets_repository.h
|
||||||
|
repositories/player_event_aa_purchase_repository.h
|
||||||
|
repositories/player_event_killed_npc_repository.h
|
||||||
|
repositories/player_event_killed_named_npc_repository.h
|
||||||
|
repositories/player_event_killed_raid_npc_repository.h
|
||||||
repositories/player_event_log_settings_repository.h
|
repositories/player_event_log_settings_repository.h
|
||||||
repositories/player_event_logs_repository.h
|
repositories/player_event_logs_repository.h
|
||||||
|
repositories/player_event_loot_items_repository.h
|
||||||
|
repositories/player_event_merchant_purchase_repository.h
|
||||||
|
repositories/player_event_merchant_sell_repository.h
|
||||||
|
repositories/player_event_npc_handin_repository.h
|
||||||
|
repositories/player_event_npc_handin_entries_repository.h
|
||||||
|
repositories/player_event_speech_repository.h
|
||||||
|
repositories/player_event_trade_repository.h
|
||||||
|
repositories/player_event_trade_entries_repository.h
|
||||||
repositories/quest_globals_repository.h
|
repositories/quest_globals_repository.h
|
||||||
repositories/raid_details_repository.h
|
repositories/raid_details_repository.h
|
||||||
repositories/raid_members_repository.h
|
repositories/raid_members_repository.h
|
||||||
@@ -500,10 +531,9 @@ SET(repositories
|
|||||||
repositories/veteran_reward_templates_repository.h
|
repositories/veteran_reward_templates_repository.h
|
||||||
repositories/zone_repository.h
|
repositories/zone_repository.h
|
||||||
repositories/zone_points_repository.h
|
repositories/zone_points_repository.h
|
||||||
|
|
||||||
)
|
)
|
||||||
|
|
||||||
SET(common_headers
|
set(common_headers
|
||||||
additive_lagged_fibonacci_engine.h
|
additive_lagged_fibonacci_engine.h
|
||||||
bazaar.h
|
bazaar.h
|
||||||
base_packet.h
|
base_packet.h
|
||||||
@@ -524,11 +554,16 @@ SET(common_headers
|
|||||||
database.h
|
database.h
|
||||||
database_schema.h
|
database_schema.h
|
||||||
database/database_update.h
|
database/database_update.h
|
||||||
|
database/database_update_manifest.h
|
||||||
|
database/database_update_manifest_custom.h
|
||||||
|
database/database_update_manifest_bots.h
|
||||||
|
data_bucket.cpp
|
||||||
dbcore.h
|
dbcore.h
|
||||||
deity.h
|
deity.h
|
||||||
discord/discord.h
|
discord/discord.h
|
||||||
discord/discord_manager.h
|
discord/discord_manager.h
|
||||||
dynamic_zone_base.h
|
dynamic_zone_base.h
|
||||||
|
dynamic_zone_lockout.h
|
||||||
emu_constants.h
|
emu_constants.h
|
||||||
emu_limits.h
|
emu_limits.h
|
||||||
emu_opcodes.h
|
emu_opcodes.h
|
||||||
@@ -554,7 +589,7 @@ SET(common_headers
|
|||||||
events/player_event_discord_formatter.h
|
events/player_event_discord_formatter.h
|
||||||
events/player_events.h
|
events/player_events.h
|
||||||
event_sub.h
|
event_sub.h
|
||||||
expedition_lockout_timer.h
|
evolving_items.h
|
||||||
extprofile.h
|
extprofile.h
|
||||||
faction.h
|
faction.h
|
||||||
file.h
|
file.h
|
||||||
@@ -571,7 +606,6 @@ SET(common_headers
|
|||||||
ipc_mutex.h
|
ipc_mutex.h
|
||||||
ip_util.h
|
ip_util.h
|
||||||
item_data.h
|
item_data.h
|
||||||
item_fieldlist.h
|
|
||||||
item_instance.h
|
item_instance.h
|
||||||
json_config.h
|
json_config.h
|
||||||
light_source.h
|
light_source.h
|
||||||
@@ -586,6 +620,7 @@ SET(common_headers
|
|||||||
mutex.h
|
mutex.h
|
||||||
mysql_request_result.h
|
mysql_request_result.h
|
||||||
mysql_request_row.h
|
mysql_request_row.h
|
||||||
|
mysql_stmt.h
|
||||||
op_codes.h
|
op_codes.h
|
||||||
opcode_dispatch.h
|
opcode_dispatch.h
|
||||||
opcodemgr.h
|
opcodemgr.h
|
||||||
@@ -613,6 +648,7 @@ SET(common_headers
|
|||||||
server_event_scheduler.h
|
server_event_scheduler.h
|
||||||
serverinfo.h
|
serverinfo.h
|
||||||
servertalk.h
|
servertalk.h
|
||||||
|
server_reload_types.h
|
||||||
shared_tasks.h
|
shared_tasks.h
|
||||||
shareddb.h
|
shareddb.h
|
||||||
skills.h
|
skills.h
|
||||||
@@ -637,18 +673,20 @@ SET(common_headers
|
|||||||
net/console_server.h
|
net/console_server.h
|
||||||
net/console_server_connection.h
|
net/console_server_connection.h
|
||||||
net/crc32.h
|
net/crc32.h
|
||||||
net/daybreak_connection.h
|
|
||||||
net/daybreak_structs.h
|
|
||||||
net/dns.h
|
net/dns.h
|
||||||
net/endian.h
|
net/endian.h
|
||||||
net/eqstream.h
|
net/eqstream.h
|
||||||
net/packet.h
|
net/packet.h
|
||||||
|
net/reliable_stream_connection.h
|
||||||
|
net/reliable_stream_pooling.h
|
||||||
|
net/reliable_stream_structs.h
|
||||||
net/servertalk_client_connection.h
|
net/servertalk_client_connection.h
|
||||||
net/servertalk_legacy_client_connection.h
|
net/servertalk_legacy_client_connection.h
|
||||||
net/servertalk_common.h
|
net/servertalk_common.h
|
||||||
net/servertalk_server.h
|
net/servertalk_server.h
|
||||||
net/servertalk_server_connection.h
|
net/servertalk_server_connection.h
|
||||||
net/tcp_connection.h
|
net/tcp_connection.h
|
||||||
|
net/tcp_connection_pooling.h
|
||||||
net/tcp_server.h
|
net/tcp_server.h
|
||||||
net/websocket_server.h
|
net/websocket_server.h
|
||||||
net/websocket_server_connection.h
|
net/websocket_server_connection.h
|
||||||
@@ -688,28 +726,25 @@ SET(common_headers
|
|||||||
util/uuid.h
|
util/uuid.h
|
||||||
)
|
)
|
||||||
|
|
||||||
SOURCE_GROUP(Event FILES
|
source_group(Event FILES
|
||||||
event/event_loop.h
|
event/event_loop.h
|
||||||
event/timer.h
|
event/timer.h
|
||||||
event/task.h
|
event/task.h
|
||||||
)
|
)
|
||||||
|
|
||||||
SOURCE_GROUP(Json FILES
|
source_group(Json FILES
|
||||||
json/json.h
|
json/json.h
|
||||||
json/jsoncpp.cpp
|
json/jsoncpp.cpp
|
||||||
json/json-forwards.h
|
json/json-forwards.h
|
||||||
)
|
)
|
||||||
|
|
||||||
SOURCE_GROUP(Net FILES
|
source_group(Net FILES
|
||||||
net/console_server.cpp
|
net/console_server.cpp
|
||||||
net/console_server.h
|
net/console_server.h
|
||||||
net/console_server_connection.cpp
|
net/console_server_connection.cpp
|
||||||
net/console_server_connection.h
|
net/console_server_connection.h
|
||||||
net/crc32.cpp
|
net/crc32.cpp
|
||||||
net/crc32.h
|
net/crc32.h
|
||||||
net/daybreak_connection.cpp
|
|
||||||
net/daybreak_connection.h
|
|
||||||
net/daybreak_structs.h
|
|
||||||
net/dns.h
|
net/dns.h
|
||||||
net/endian.h
|
net/endian.h
|
||||||
net/eqmq.cpp
|
net/eqmq.cpp
|
||||||
@@ -718,6 +753,10 @@ SOURCE_GROUP(Net FILES
|
|||||||
net/eqstream.h
|
net/eqstream.h
|
||||||
net/packet.cpp
|
net/packet.cpp
|
||||||
net/packet.h
|
net/packet.h
|
||||||
|
net/reliable_stream_connection.cpp
|
||||||
|
net/reliable_stream_connection.h
|
||||||
|
net/reliable_stream_pooling.h
|
||||||
|
net/reliable_stream_structs.h
|
||||||
net/servertalk_client_connection.cpp
|
net/servertalk_client_connection.cpp
|
||||||
net/servertalk_client_connection.h
|
net/servertalk_client_connection.h
|
||||||
net/servertalk_legacy_client_connection.cpp
|
net/servertalk_legacy_client_connection.cpp
|
||||||
@@ -729,6 +768,7 @@ SOURCE_GROUP(Net FILES
|
|||||||
net/servertalk_server_connection.h
|
net/servertalk_server_connection.h
|
||||||
net/tcp_connection.cpp
|
net/tcp_connection.cpp
|
||||||
net/tcp_connection.h
|
net/tcp_connection.h
|
||||||
|
net/tcp_connection_pooling.h
|
||||||
net/tcp_server.cpp
|
net/tcp_server.cpp
|
||||||
net/tcp_server.h
|
net/tcp_server.h
|
||||||
net/websocket_server.cpp
|
net/websocket_server.cpp
|
||||||
@@ -737,7 +777,7 @@ SOURCE_GROUP(Net FILES
|
|||||||
net/websocket_server_connection.h
|
net/websocket_server_connection.h
|
||||||
)
|
)
|
||||||
|
|
||||||
SOURCE_GROUP(Patches FILES
|
source_group(Patches FILES
|
||||||
patches/patches.h
|
patches/patches.h
|
||||||
patches/sod.h
|
patches/sod.h
|
||||||
patches/sod_limits.h
|
patches/sod_limits.h
|
||||||
@@ -781,12 +821,413 @@ SOURCE_GROUP(Patches FILES
|
|||||||
patches/uf_limits.cpp
|
patches/uf_limits.cpp
|
||||||
)
|
)
|
||||||
|
|
||||||
SOURCE_GROUP(StackWalker FILES
|
source_group(Repositories FILES
|
||||||
|
|
||||||
|
# Criteria
|
||||||
|
repositories/criteria/content_filter_criteria.h
|
||||||
|
|
||||||
|
repositories/base/base_grid_repository.h
|
||||||
|
repositories/base/base_grid_entries_repository.h
|
||||||
|
|
||||||
|
# Base Repositories
|
||||||
|
repositories/base/base_aa_ability_repository.h
|
||||||
|
repositories/base/base_aa_ranks_repository.h
|
||||||
|
repositories/base/base_aa_rank_effects_repository.h
|
||||||
|
repositories/base/base_aa_rank_prereqs_repository.h
|
||||||
|
repositories/base/base_account_repository.h
|
||||||
|
repositories/base/base_account_flags_repository.h
|
||||||
|
repositories/base/base_account_ip_repository.h
|
||||||
|
repositories/base/base_account_rewards_repository.h
|
||||||
|
repositories/base/base_adventure_details_repository.h
|
||||||
|
repositories/base/base_adventure_members_repository.h
|
||||||
|
repositories/base/base_adventure_stats_repository.h
|
||||||
|
repositories/base/base_adventure_template_repository.h
|
||||||
|
repositories/base/base_adventure_template_entry_repository.h
|
||||||
|
repositories/base/base_adventure_template_entry_flavor_repository.h
|
||||||
|
repositories/base/base_alternate_currency_repository.h
|
||||||
|
repositories/base/base_auras_repository.h
|
||||||
|
repositories/base/base_base_data_repository.h
|
||||||
|
repositories/base/base_blocked_spells_repository.h
|
||||||
|
repositories/base/base_books_repository.h
|
||||||
|
repositories/base/base_bugs_repository.h
|
||||||
|
repositories/base/base_bug_reports_repository.h
|
||||||
|
repositories/base/base_buyer_repository.h
|
||||||
|
repositories/base/base_buyer_trade_items_repository.h
|
||||||
|
repositories/base/base_character_activities_repository.h
|
||||||
|
repositories/base/base_character_alternate_abilities_repository.h
|
||||||
|
repositories/base/base_character_alt_currency_repository.h
|
||||||
|
repositories/base/base_character_auras_repository.h
|
||||||
|
repositories/base/base_character_bandolier_repository.h
|
||||||
|
repositories/base/base_character_bind_repository.h
|
||||||
|
repositories/base/base_character_buffs_repository.h
|
||||||
|
repositories/base/base_character_corpses_repository.h
|
||||||
|
repositories/base/base_character_corpse_items_repository.h
|
||||||
|
repositories/base/base_character_currency_repository.h
|
||||||
|
repositories/base/base_character_data_repository.h
|
||||||
|
repositories/base/base_character_disciplines_repository.h
|
||||||
|
repositories/base/base_character_evolving_items_repository.h
|
||||||
|
repositories/base/base_character_expedition_lockouts_repository.h
|
||||||
|
repositories/base/base_character_exp_modifiers_repository.h
|
||||||
|
repositories/base/base_character_inspect_messages_repository.h
|
||||||
|
repositories/base/base_character_instance_safereturns_repository.h
|
||||||
|
repositories/base/base_character_item_recast_repository.h
|
||||||
|
repositories/base/base_character_languages_repository.h
|
||||||
|
repositories/base/base_character_leadership_abilities_repository.h
|
||||||
|
repositories/base/base_character_material_repository.h
|
||||||
|
repositories/base/base_character_memmed_spells_repository.h
|
||||||
|
repositories/base/base_character_parcels_repository.h
|
||||||
|
repositories/base/base_character_parcels_containers_repository.h
|
||||||
|
repositories/base/base_character_peqzone_flags_repository.h
|
||||||
|
repositories/base/base_character_pet_buffs_repository.h
|
||||||
|
repositories/base/base_character_pet_info_repository.h
|
||||||
|
repositories/base/base_character_pet_inventory_repository.h
|
||||||
|
repositories/base/base_character_potionbelt_repository.h
|
||||||
|
repositories/base/base_character_skills_repository.h
|
||||||
|
repositories/base/base_character_spells_repository.h
|
||||||
|
repositories/base/base_character_tasks_repository.h
|
||||||
|
repositories/base/base_character_task_timers_repository.h
|
||||||
|
repositories/base/base_char_create_combinations_repository.h
|
||||||
|
repositories/base/base_char_create_point_allocations_repository.h
|
||||||
|
repositories/base/base_char_recipe_list_repository.h
|
||||||
|
repositories/base/base_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
|
||||||
|
repositories/base/base_completed_tasks_repository.h
|
||||||
|
repositories/base/base_content_flags_repository.h
|
||||||
|
repositories/base/base_damageshieldtypes_repository.h
|
||||||
|
repositories/base/base_data_buckets_repository.h
|
||||||
|
repositories/base/base_db_str_repository.h
|
||||||
|
repositories/base/base_discord_webhooks_repository.h
|
||||||
|
repositories/base/base_discovered_items_repository.h
|
||||||
|
repositories/base/base_doors_repository.h
|
||||||
|
repositories/base/base_dynamic_zones_repository.h
|
||||||
|
repositories/base/base_dynamic_zone_lockouts_repository.h
|
||||||
|
repositories/base/base_dynamic_zone_members_repository.h
|
||||||
|
repositories/base/base_dynamic_zone_templates_repository.h
|
||||||
|
repositories/base/base_faction_association_repository.h
|
||||||
|
repositories/base/base_faction_base_data_repository.h
|
||||||
|
repositories/base/base_faction_list_repository.h
|
||||||
|
repositories/base/base_faction_list_mod_repository.h
|
||||||
|
repositories/base/base_faction_values_repository.h
|
||||||
|
repositories/base/base_fishing_repository.h
|
||||||
|
repositories/base/base_forage_repository.h
|
||||||
|
repositories/base/base_friends_repository.h
|
||||||
|
repositories/base/base_global_loot_repository.h
|
||||||
|
repositories/base/base_gm_ips_repository.h
|
||||||
|
repositories/base/base_graveyard_repository.h
|
||||||
|
repositories/base/base_ground_spawns_repository.h
|
||||||
|
repositories/base/base_group_id_repository.h
|
||||||
|
repositories/base/base_group_leaders_repository.h
|
||||||
|
repositories/base/base_guilds_repository.h
|
||||||
|
repositories/base/base_guild_ranks_repository.h
|
||||||
|
repositories/base/base_guild_permissions_repository.h
|
||||||
|
repositories/base/base_guild_members_repository.h
|
||||||
|
repositories/base/base_guild_bank_repository.h
|
||||||
|
repositories/base/base_guild_relations_repository.h
|
||||||
|
repositories/base/base_horses_repository.h
|
||||||
|
repositories/base/base_instance_list_repository.h
|
||||||
|
repositories/base/base_instance_list_player_repository.h
|
||||||
|
repositories/base/base_inventory_repository.h
|
||||||
|
repositories/base/base_inventory_snapshots_repository.h
|
||||||
|
repositories/base/base_ip_exemptions_repository.h
|
||||||
|
repositories/base/base_items_repository.h
|
||||||
|
repositories/base/base_items_evolving_details_repository.h
|
||||||
|
repositories/base/base_ldon_trap_entries_repository.h
|
||||||
|
repositories/base/base_ldon_trap_templates_repository.h
|
||||||
|
repositories/base/base_level_exp_mods_repository.h
|
||||||
|
repositories/base/base_lfguild_repository.h
|
||||||
|
repositories/base/base_login_accounts_repository.h
|
||||||
|
repositories/base/base_login_api_tokens_repository.h
|
||||||
|
repositories/base/base_login_server_admins_repository.h
|
||||||
|
repositories/base/base_login_server_list_types_repository.h
|
||||||
|
repositories/base/base_login_world_servers_repository.h
|
||||||
|
repositories/base/base_logsys_categories_repository.h
|
||||||
|
repositories/base/base_lootdrop_repository.h
|
||||||
|
repositories/base/base_lootdrop_entries_repository.h
|
||||||
|
repositories/base/base_loottable_repository.h
|
||||||
|
repositories/base/base_loottable_entries_repository.h
|
||||||
|
repositories/base/base_mail_repository.h
|
||||||
|
repositories/base/base_merchantlist_repository.h
|
||||||
|
repositories/base/base_merchantlist_temp_repository.h
|
||||||
|
repositories/base/base_name_filter_repository.h
|
||||||
|
repositories/base/base_npc_emotes_repository.h
|
||||||
|
repositories/base/base_npc_faction_repository.h
|
||||||
|
repositories/base/base_npc_faction_entries_repository.h
|
||||||
|
repositories/base/base_npc_scale_global_base_repository.h
|
||||||
|
repositories/base/base_npc_spells_repository.h
|
||||||
|
repositories/base/base_npc_spells_effects_repository.h
|
||||||
|
repositories/base/base_npc_spells_effects_entries_repository.h
|
||||||
|
repositories/base/base_npc_spells_entries_repository.h
|
||||||
|
repositories/base/base_npc_types_repository.h
|
||||||
|
repositories/base/base_npc_types_tint_repository.h
|
||||||
|
repositories/base/base_object_repository.h
|
||||||
|
repositories/base/base_object_contents_repository.h
|
||||||
|
repositories/base/base_perl_event_export_settings_repository.h
|
||||||
|
repositories/base/base_petitions_repository.h
|
||||||
|
repositories/base/base_pets_repository.h
|
||||||
|
repositories/base/base_pets_beastlord_data_repository.h
|
||||||
|
repositories/base/base_pets_equipmentset_repository.h
|
||||||
|
repositories/base/base_pets_equipmentset_entries_repository.h
|
||||||
|
repositories/base/base_player_titlesets_repository.h
|
||||||
|
repositories/base/base_player_event_aa_purchase_repository.h
|
||||||
|
repositories/base/base_player_event_killed_npc_repository.h
|
||||||
|
repositories/base/base_player_event_killed_named_npc_repository.h
|
||||||
|
repositories/base/base_player_event_killed_raid_npc_repository.h
|
||||||
|
repositories/base/base_player_event_log_settings_repository.h
|
||||||
|
repositories/base/base_player_event_logs_repository.h
|
||||||
|
repositories/base/base_player_event_loot_items_repository.h
|
||||||
|
repositories/base/base_player_event_merchant_purchase_repository.h
|
||||||
|
repositories/base/base_player_event_merchant_sell_repository.h
|
||||||
|
repositories/base/base_player_event_npc_handin_repository.h
|
||||||
|
repositories/base/base_player_event_npc_handin_entries_repository.h
|
||||||
|
repositories/base/base_player_event_speech_repository.h
|
||||||
|
repositories/base/base_player_event_trade_repository.h
|
||||||
|
repositories/base/base_player_event_trade_entries_repository.h
|
||||||
|
repositories/base/base_quest_globals_repository.h
|
||||||
|
repositories/base/base_raid_details_repository.h
|
||||||
|
repositories/base/base_raid_members_repository.h
|
||||||
|
repositories/base/base_reports_repository.h
|
||||||
|
repositories/base/base_respawn_times_repository.h
|
||||||
|
repositories/base/base_rule_sets_repository.h
|
||||||
|
repositories/base/base_rule_values_repository.h
|
||||||
|
repositories/base/base_saylink_repository.h
|
||||||
|
repositories/base/base_server_scheduled_events_repository.h
|
||||||
|
repositories/base/base_shared_tasks_repository.h
|
||||||
|
repositories/base/base_shared_task_activity_state_repository.h
|
||||||
|
repositories/base/base_shared_task_dynamic_zones_repository.h
|
||||||
|
repositories/base/base_shared_task_members_repository.h
|
||||||
|
repositories/base/base_skill_caps_repository.h
|
||||||
|
repositories/base/base_spawn2_repository.h
|
||||||
|
repositories/base/base_spawnentry_repository.h
|
||||||
|
repositories/base/base_spawngroup_repository.h
|
||||||
|
repositories/base/base_spawn_conditions_repository.h
|
||||||
|
repositories/base/base_spawn_condition_values_repository.h
|
||||||
|
repositories/base/base_spawn_events_repository.h
|
||||||
|
repositories/base/base_spells_new_repository.h
|
||||||
|
repositories/base/base_spell_buckets_repository.h
|
||||||
|
repositories/base/base_spell_globals_repository.h
|
||||||
|
repositories/base/base_starting_items_repository.h
|
||||||
|
repositories/base/base_start_zones_repository.h
|
||||||
|
repositories/base/base_tasks_repository.h
|
||||||
|
repositories/base/base_tasksets_repository.h
|
||||||
|
repositories/base/base_task_activities_repository.h
|
||||||
|
repositories/base/base_timers_repository.h
|
||||||
|
repositories/base/base_titles_repository.h
|
||||||
|
repositories/base/base_trader_repository.h
|
||||||
|
repositories/base/base_tradeskill_recipe_repository.h
|
||||||
|
repositories/base/base_tradeskill_recipe_entries_repository.h
|
||||||
|
repositories/base/base_traps_repository.h
|
||||||
|
repositories/base/base_tributes_repository.h
|
||||||
|
repositories/base/base_tribute_levels_repository.h
|
||||||
|
repositories/base/base_veteran_reward_templates_repository.h
|
||||||
|
repositories/base/base_zone_repository.h
|
||||||
|
repositories/base/base_zone_points_repository.h
|
||||||
|
|
||||||
|
# Extended Repositories
|
||||||
|
repositories/aa_ability_repository.h
|
||||||
|
repositories/aa_ranks_repository.h
|
||||||
|
repositories/aa_rank_effects_repository.h
|
||||||
|
repositories/aa_rank_prereqs_repository.h
|
||||||
|
repositories/account_repository.h
|
||||||
|
repositories/account_flags_repository.h
|
||||||
|
repositories/account_ip_repository.h
|
||||||
|
repositories/account_rewards_repository.h
|
||||||
|
repositories/adventure_details_repository.h
|
||||||
|
repositories/adventure_members_repository.h
|
||||||
|
repositories/adventure_stats_repository.h
|
||||||
|
repositories/adventure_template_repository.h
|
||||||
|
repositories/adventure_template_entry_repository.h
|
||||||
|
repositories/adventure_template_entry_flavor_repository.h
|
||||||
|
repositories/alternate_currency_repository.h
|
||||||
|
repositories/auras_repository.h
|
||||||
|
repositories/base_data_repository.h
|
||||||
|
repositories/blocked_spells_repository.h
|
||||||
|
repositories/books_repository.h
|
||||||
|
repositories/bugs_repository.h
|
||||||
|
repositories/bug_reports_repository.h
|
||||||
|
repositories/buyer_buy_lines_repository.h
|
||||||
|
repositories/buyer_trade_items_repository.h
|
||||||
|
repositories/character_activities_repository.h
|
||||||
|
repositories/character_alternate_abilities_repository.h
|
||||||
|
repositories/character_alt_currency_repository.h
|
||||||
|
repositories/character_auras_repository.h
|
||||||
|
repositories/character_bandolier_repository.h
|
||||||
|
repositories/character_bind_repository.h
|
||||||
|
repositories/character_buffs_repository.h
|
||||||
|
repositories/character_corpses_repository.h
|
||||||
|
repositories/character_corpse_items_repository.h
|
||||||
|
repositories/character_currency_repository.h
|
||||||
|
repositories/character_data_repository.h
|
||||||
|
repositories/character_disciplines_repository.h
|
||||||
|
repositories/character_evolving_items_repository.h
|
||||||
|
repositories/character_expedition_lockouts_repository.h
|
||||||
|
repositories/character_exp_modifiers_repository.h
|
||||||
|
repositories/character_inspect_messages_repository.h
|
||||||
|
repositories/character_instance_safereturns_repository.h
|
||||||
|
repositories/character_item_recast_repository.h
|
||||||
|
repositories/character_languages_repository.h
|
||||||
|
repositories/character_leadership_abilities_repository.h
|
||||||
|
repositories/character_material_repository.h
|
||||||
|
repositories/character_memmed_spells_repository.h
|
||||||
|
repositories/character_parcels_repository.h
|
||||||
|
repositories/character_parcels_containers_repository.h
|
||||||
|
repositories/character_peqzone_flags_repository.h
|
||||||
|
repositories/character_pet_buffs_repository.h
|
||||||
|
repositories/character_pet_info_repository.h
|
||||||
|
repositories/character_pet_inventory_repository.h
|
||||||
|
repositories/character_potionbelt_repository.h
|
||||||
|
repositories/character_skills_repository.h
|
||||||
|
repositories/character_spells_repository.h
|
||||||
|
repositories/character_tasks_repository.h
|
||||||
|
repositories/character_task_timers_repository.h
|
||||||
|
repositories/char_create_combinations_repository.h
|
||||||
|
repositories/char_create_point_allocations_repository.h
|
||||||
|
repositories/char_recipe_list_repository.h
|
||||||
|
repositories/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
|
||||||
|
repositories/completed_tasks_repository.h
|
||||||
|
repositories/content_flags_repository.h
|
||||||
|
repositories/damageshieldtypes_repository.h
|
||||||
|
repositories/data_buckets_repository.h
|
||||||
|
repositories/db_str_repository.h
|
||||||
|
repositories/discord_webhooks_repository.h
|
||||||
|
repositories/discovered_items_repository.h
|
||||||
|
repositories/doors_repository.h
|
||||||
|
repositories/dynamic_zones_repository.h
|
||||||
|
repositories/dynamic_zone_lockouts_repository.h
|
||||||
|
repositories/dynamic_zone_members_repository.h
|
||||||
|
repositories/dynamic_zone_templates_repository.h
|
||||||
|
repositories/faction_association_repository.h
|
||||||
|
repositories/faction_base_data_repository.h
|
||||||
|
repositories/faction_list_repository.h
|
||||||
|
repositories/faction_list_mod_repository.h
|
||||||
|
repositories/faction_values_repository.h
|
||||||
|
repositories/fishing_repository.h
|
||||||
|
repositories/forage_repository.h
|
||||||
|
repositories/friends_repository.h
|
||||||
|
repositories/global_loot_repository.h
|
||||||
|
repositories/gm_ips_repository.h
|
||||||
|
repositories/graveyard_repository.h
|
||||||
|
repositories/ground_spawns_repository.h
|
||||||
|
repositories/group_id_repository.h
|
||||||
|
repositories/group_leaders_repository.h
|
||||||
|
repositories/guilds_repository.h
|
||||||
|
repositories/guild_ranks_repository.h
|
||||||
|
repositories/guild_permissions_repository.h
|
||||||
|
repositories/guild_members_repository.h
|
||||||
|
repositories/guild_bank_repository.h
|
||||||
|
repositories/guild_relations_repository.h
|
||||||
|
repositories/horses_repository.h
|
||||||
|
repositories/instance_list_repository.h
|
||||||
|
repositories/instance_list_player_repository.h
|
||||||
|
repositories/inventory_repository.h
|
||||||
|
repositories/inventory_snapshots_repository.h
|
||||||
|
repositories/ip_exemptions_repository.h
|
||||||
|
repositories/items_repository.h
|
||||||
|
repositories/items_evolving_details_repository.h
|
||||||
|
repositories/ldon_trap_entries_repository.h
|
||||||
|
repositories/ldon_trap_templates_repository.h
|
||||||
|
repositories/level_exp_mods_repository.h
|
||||||
|
repositories/lfguild_repository.h
|
||||||
|
repositories/login_accounts_repository.h
|
||||||
|
repositories/login_api_tokens_repository.h
|
||||||
|
repositories/login_server_admins_repository.h
|
||||||
|
repositories/login_server_list_types_repository.h
|
||||||
|
repositories/login_world_servers_repository.h
|
||||||
|
repositories/logsys_categories_repository.h
|
||||||
|
repositories/lootdrop_repository.h
|
||||||
|
repositories/lootdrop_entries_repository.h
|
||||||
|
repositories/loottable_repository.h
|
||||||
|
repositories/loottable_entries_repository.h
|
||||||
|
repositories/mail_repository.h
|
||||||
|
repositories/merchantlist_repository.h
|
||||||
|
repositories/merchantlist_temp_repository.h
|
||||||
|
repositories/name_filter_repository.h
|
||||||
|
repositories/npc_emotes_repository.h
|
||||||
|
repositories/npc_faction_repository.h
|
||||||
|
repositories/npc_faction_entries_repository.h
|
||||||
|
repositories/npc_scale_global_base_repository.h
|
||||||
|
repositories/npc_spells_repository.h
|
||||||
|
repositories/npc_spells_effects_repository.h
|
||||||
|
repositories/npc_spells_effects_entries_repository.h
|
||||||
|
repositories/npc_spells_entries_repository.h
|
||||||
|
repositories/npc_types_repository.h
|
||||||
|
repositories/npc_types_tint_repository.h
|
||||||
|
repositories/object_repository.h
|
||||||
|
repositories/object_contents_repository.h
|
||||||
|
repositories/perl_event_export_settings_repository.h
|
||||||
|
repositories/petitions_repository.h
|
||||||
|
repositories/pets_repository.h
|
||||||
|
repositories/pets_beastlord_data_repository.h
|
||||||
|
repositories/pets_equipmentset_repository.h
|
||||||
|
repositories/pets_equipmentset_entries_repository.h
|
||||||
|
repositories/player_titlesets_repository.h
|
||||||
|
repositories/player_event_aa_purchase_repository.h
|
||||||
|
repositories/player_event_killed_npc_repository.h
|
||||||
|
repositories/player_event_killed_named_npc_repository.h
|
||||||
|
repositories/player_event_killed_raid_npc_repository.h
|
||||||
|
repositories/player_event_log_settings_repository.h
|
||||||
|
repositories/player_event_logs_repository.h
|
||||||
|
repositories/player_event_loot_items_repository.h
|
||||||
|
repositories/player_event_merchant_purchase_repository.h
|
||||||
|
repositories/player_event_merchant_sell_repository.h
|
||||||
|
repositories/player_event_npc_handin_repository.h
|
||||||
|
repositories/player_event_npc_handin_entries_repository.h
|
||||||
|
repositories/player_event_speech_repository.h
|
||||||
|
repositories/player_event_trade_repository.h
|
||||||
|
repositories/player_event_trade_entries_repository.h
|
||||||
|
repositories/quest_globals_repository.h
|
||||||
|
repositories/raid_details_repository.h
|
||||||
|
repositories/raid_members_repository.h
|
||||||
|
repositories/reports_repository.h
|
||||||
|
repositories/respawn_times_repository.h
|
||||||
|
repositories/rule_sets_repository.h
|
||||||
|
repositories/rule_values_repository.h
|
||||||
|
repositories/saylink_repository.h
|
||||||
|
repositories/server_scheduled_events_repository.h
|
||||||
|
repositories/shared_tasks_repository.h
|
||||||
|
repositories/shared_task_activity_state_repository.h
|
||||||
|
repositories/shared_task_dynamic_zones_repository.h
|
||||||
|
repositories/shared_task_members_repository.h
|
||||||
|
repositories/skill_caps_repository.h
|
||||||
|
repositories/spawn2_repository.h
|
||||||
|
repositories/spawnentry_repository.h
|
||||||
|
repositories/spawngroup_repository.h
|
||||||
|
repositories/spawn_conditions_repository.h
|
||||||
|
repositories/spawn_condition_values_repository.h
|
||||||
|
repositories/spawn_events_repository.h
|
||||||
|
repositories/spells_new_repository.h
|
||||||
|
repositories/spell_buckets_repository.h
|
||||||
|
repositories/spell_globals_repository.h
|
||||||
|
repositories/starting_items_repository.h
|
||||||
|
repositories/start_zones_repository.h
|
||||||
|
repositories/tasks_repository.h
|
||||||
|
repositories/tasksets_repository.h
|
||||||
|
repositories/task_activities_repository.h
|
||||||
|
repositories/timers_repository.h
|
||||||
|
repositories/titles_repository.h
|
||||||
|
repositories/trader_repository.h
|
||||||
|
repositories/tradeskill_recipe_repository.h
|
||||||
|
repositories/tradeskill_recipe_entries_repository.h
|
||||||
|
repositories/traps_repository.h
|
||||||
|
repositories/tributes_repository.h
|
||||||
|
repositories/tribute_levels_repository.h
|
||||||
|
repositories/veteran_reward_templates_repository.h
|
||||||
|
repositories/zone_repository.h
|
||||||
|
repositories/zone_points_repository.h
|
||||||
|
)
|
||||||
|
|
||||||
|
source_group(StackWalker FILES
|
||||||
StackWalker/StackWalker.h
|
StackWalker/StackWalker.h
|
||||||
StackWalker/StackWalker.cpp
|
StackWalker/StackWalker.cpp
|
||||||
)
|
)
|
||||||
|
|
||||||
SOURCE_GROUP(Util FILES
|
source_group(Util FILES
|
||||||
util/memory_stream.h
|
util/memory_stream.h
|
||||||
util/directory.cpp
|
util/directory.cpp
|
||||||
util/directory.h
|
util/directory.h
|
||||||
@@ -794,17 +1235,78 @@ SOURCE_GROUP(Util FILES
|
|||||||
util/uuid.h
|
util/uuid.h
|
||||||
)
|
)
|
||||||
|
|
||||||
INCLUDE_DIRECTORIES(Patches SocketLib StackWalker)
|
option(EQEMU_ADD_PROFILER "Link with Google perftools profiler" OFF)
|
||||||
|
#PRNG options
|
||||||
|
option(EQEMU_ADDITIVE_LFIB_PRNG "Use Additive LFib for PRNG." OFF)
|
||||||
|
mark_as_advanced(EQEMU_ADDITIVE_LFIB_PRNG)
|
||||||
|
option(EQEMU_BIASED_INT_DIST "Use biased int dist instead of uniform." OFF)
|
||||||
|
mark_as_advanced(EQEMU_BIASED_INT_DIST)
|
||||||
|
set(EQEMU_CUSTOM_PRNG_ENGINE "" CACHE STRING "Custom random engine. (ex. std::default_random_engine)")
|
||||||
|
mark_as_advanced(EQEMU_CUSTOM_PRNG_ENGINE)
|
||||||
|
|
||||||
ADD_LIBRARY(common ${common_sources} ${common_headers} ${repositories})
|
if(CMAKE_COMPILER_IS_GNUCXX)
|
||||||
|
option(EQEMU_SFMT19937 "Use GCC's extention for SIMD Fast MT19937." OFF)
|
||||||
|
mark_as_advanced(EQEMU_SFMT19937)
|
||||||
|
endif()
|
||||||
|
|
||||||
IF (UNIX)
|
include_directories(Patches SocketLib StackWalker)
|
||||||
SET_SOURCE_FILES_PROPERTIES("SocketLib/Mime.cpp" PROPERTY COMPILE_FLAGS -Wno-unused-result)
|
|
||||||
SET_SOURCE_FILES_PROPERTIES("patches/sod.cpp" "patches/sof.cpp" "patches/rof.cpp" "patches/rof2.cpp" "patches/uf.cpp" PROPERTIES COMPILE_FLAGS -O0)
|
|
||||||
ENDIF (UNIX)
|
|
||||||
|
|
||||||
IF (WIN32 AND EQEMU_BUILD_PCH)
|
add_library(common ${common_sources} ${common_headers} ${repositories})
|
||||||
TARGET_PRECOMPILE_HEADERS(common PRIVATE pch/pch.h)
|
|
||||||
ENDIF ()
|
|
||||||
|
|
||||||
SET(LIBRARY_OUTPUT_PATH ${PROJECT_BINARY_DIR}/bin)
|
target_compile_definitions(common PUBLIC BOOST_BIND_GLOBAL_PLACEHOLDERS GLM_FORCE_RADIANS GLM_FORCE_CTOR_INIT GLM_ENABLE_EXPERIMENTAL)
|
||||||
|
target_include_directories(common PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/../submodules/websocketpp")
|
||||||
|
target_link_libraries(common PUBLIC cereal::cereal fmt::fmt unofficial::libmariadb $<IF:$<TARGET_EXISTS:libuv::uv_a>,libuv::uv_a,libuv::uv> OpenSSL::SSL OpenSSL::Crypto ZLIB::ZLIB)
|
||||||
|
|
||||||
|
# Requires libgoogle-perftools-dev google-perftools packages for linux (debian)
|
||||||
|
if(EQEMU_ADD_PROFILER)
|
||||||
|
set(CMAKE_EXE_LINKER_FLAGS "-Wl,--no-as-needed,-lprofiler,--as-needed")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(EQEMU_ADDITIVE_LFIB_PRNG)
|
||||||
|
target_compile_definitions(common PUBLIC USE_ADDITIVE_LFIB_PRNG)
|
||||||
|
if(EQEMU_SFMT19937)
|
||||||
|
message(STATUS "SFMT19937 and ADDITITVE_LFIB_PRNG both set, SFMT19937 ignored.")
|
||||||
|
set(EQEMU_SFMT19937 OFF)
|
||||||
|
endif()
|
||||||
|
if(NOT EQEMU_CUSTOM_PRNG_ENGINE STREQUAL "")
|
||||||
|
message(STATUS "CUSTOM_PRNG_ENGINE and ADDITITVE_LFIB_PRNG both set, CUSTOM_PRNG_ENGINE ignored.")
|
||||||
|
set(EQEMU_CUSTOM_PRNG_ENGINE "")
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(EQEMU_SFMT19937)
|
||||||
|
target_compile_definitions(common PUBLIC USE_SFMT19937)
|
||||||
|
if(NOT EQEMU_CUSTOM_PRNG_ENGINE STREQUAL "")
|
||||||
|
message(STATUS "CUSTOM_PRNG_ENGINE and SFMT19937 both set, CUSTOM_PRNG_ENGINE ignored.")
|
||||||
|
set(EQEMU_CUSTOM_PRNG_ENGINE "")
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(NOT EQEMU_CUSTOM_PRNG_ENGINE STREQUAL "")
|
||||||
|
target_compile_definitions(common PUBLIC USE_CUSTOM_PRNG_ENGINE=${EQEMU_CUSTOM_PRNG_ENGINE})
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(EQEMU_BIASED_INT_DIST)
|
||||||
|
target_compile_definitions(common PUBLIC BIASED_INT_DIST)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(${OPENSSL_VERSION} VERSION_GREATER_EQUAL "1.1.1")
|
||||||
|
target_compile_definitions(common PUBLIC CPPHTTPLIB_OPENSSL_SUPPORT)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(UNIX)
|
||||||
|
target_link_libraries(common PUBLIC uuid)
|
||||||
|
set_source_files_properties("SocketLib/Mime.cpp" PROPERTY COMPILE_FLAGS -Wno-unused-result)
|
||||||
|
set_source_files_properties("patches/sod.cpp" "patches/sof.cpp" "patches/rof.cpp" "patches/rof2.cpp" "patches/uf.cpp" PROPERTIES COMPILE_FLAGS -O0)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(EQEMU_BUILD_PCH)
|
||||||
|
TARGET_PRECOMPILE_HEADERS(common PRIVATE pch/std-pch.h)
|
||||||
|
# Avoid PCH/__OPTIMIZE__ mismatch when compiling certain patch sources with -O0
|
||||||
|
# These files are compiled with -O0 on UNIX (see COMPILE_FLAGS above), which
|
||||||
|
# disables the __OPTIMIZE__ predefined macro. Disabling PCH for them prevents
|
||||||
|
# Clang from erroring due to macro state differences between the PCH and TU.
|
||||||
|
set_source_files_properties("patches/sod.cpp" "patches/sof.cpp" "patches/rof.cpp" "patches/rof2.cpp" "patches/uf.cpp" PROPERTIES SKIP_PRECOMPILE_HEADERS ON)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
set(LIBRARY_OUTPUT_PATH ${PROJECT_BINARY_DIR}/bin)
|
||||||
|
|||||||
+251
-276
@@ -6,15 +6,17 @@
|
|||||||
|
|
||||||
std::vector<BazaarSearchResultsFromDB_Struct>
|
std::vector<BazaarSearchResultsFromDB_Struct>
|
||||||
Bazaar::GetSearchResults(
|
Bazaar::GetSearchResults(
|
||||||
SharedDatabase &db,
|
Database &db,
|
||||||
|
Database &content_db,
|
||||||
BazaarSearchCriteria_Struct search,
|
BazaarSearchCriteria_Struct search,
|
||||||
uint32 char_zone_id
|
uint32 char_zone_id,
|
||||||
|
int32 char_zone_instance_id
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
LogTrading(
|
LogTrading(
|
||||||
"Searching for items with search criteria - item_name [{}] min_cost [{}] max_cost [{}] min_level [{}] "
|
"Searching for items with search criteria - item_name [{}] min_cost [{}] max_cost [{}] min_level [{}] "
|
||||||
"max_level [{}] max_results [{}] prestige [{}] augment [{}] trader_entity_id [{}] trader_id [{}] "
|
"max_level [{}] max_results [{}] prestige [{}] augment [{}] trader_entity_id [{}] trader_id [{}] "
|
||||||
"search_scope [{}] char_zone_id [{}]",
|
"search_scope [{}] char_zone_id [{}], char_zone_instance_id [{}]",
|
||||||
search.item_name,
|
search.item_name,
|
||||||
search.min_cost,
|
search.min_cost,
|
||||||
search.max_cost,
|
search.max_cost,
|
||||||
@@ -26,175 +28,11 @@ Bazaar::GetSearchResults(
|
|||||||
search.trader_entity_id,
|
search.trader_entity_id,
|
||||||
search.trader_id,
|
search.trader_id,
|
||||||
search.search_scope,
|
search.search_scope,
|
||||||
char_zone_id
|
char_zone_id,
|
||||||
|
char_zone_instance_id
|
||||||
);
|
);
|
||||||
|
|
||||||
std::string search_criteria_trader("TRUE ");
|
static std::map<uint8, uint32> item_slot_searches_new = {
|
||||||
|
|
||||||
if (search.search_scope == NonRoFBazaarSearchScope) {
|
|
||||||
search_criteria_trader.append(
|
|
||||||
fmt::format(
|
|
||||||
" AND trader.char_entity_id = {} AND trader.char_zone_id = {}",
|
|
||||||
search.trader_entity_id,
|
|
||||||
Zones::BAZAAR
|
|
||||||
)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
else if (search.search_scope == Local_Scope) {
|
|
||||||
search_criteria_trader.append(fmt::format(" AND trader.char_zone_id = {}", char_zone_id));
|
|
||||||
}
|
|
||||||
else if (search.trader_id > 0) {
|
|
||||||
search_criteria_trader.append(fmt::format(" AND trader.char_id = {}", search.trader_id));
|
|
||||||
}
|
|
||||||
if (search.min_cost != 0) {
|
|
||||||
search_criteria_trader.append(fmt::format(" AND trader.item_cost >= {}", search.min_cost * 1000));
|
|
||||||
}
|
|
||||||
if (search.max_cost != 0) {
|
|
||||||
search_criteria_trader.append(fmt::format(" AND trader.item_cost <= {}", (uint64) search.max_cost * 1000));
|
|
||||||
}
|
|
||||||
|
|
||||||
// not yet implemented
|
|
||||||
// if (search.prestige != 0) {
|
|
||||||
// 0xffffffff prestige only, 0xfffffffe non-prestige, 0 all
|
|
||||||
// search_criteria.append(fmt::format(" AND items.type = {} ", search.prestige));
|
|
||||||
// }
|
|
||||||
|
|
||||||
std::string query = fmt::format(
|
|
||||||
"SELECT COUNT(item_id), trader.char_id, trader.item_id, trader.item_sn, trader.item_charges, trader.item_cost, "
|
|
||||||
"trader.slot_id, SUM(trader.item_charges), trader.char_zone_id, trader.char_entity_id, character_data.name, "
|
|
||||||
"aug_slot_1, aug_slot_2, aug_slot_3, aug_slot_4, aug_slot_5, aug_slot_6 "
|
|
||||||
"FROM trader, character_data "
|
|
||||||
"WHERE {} AND trader.char_id = character_data.id "
|
|
||||||
"GROUP BY trader.item_sn, trader.item_charges, trader.char_id",
|
|
||||||
search_criteria_trader.c_str()
|
|
||||||
);
|
|
||||||
|
|
||||||
std::vector<BazaarSearchResultsFromDB_Struct> all_entries;
|
|
||||||
|
|
||||||
auto results = db.QueryDatabase(query);
|
|
||||||
|
|
||||||
if (!results.Success()) {
|
|
||||||
return all_entries;
|
|
||||||
}
|
|
||||||
|
|
||||||
struct ItemSearchType {
|
|
||||||
EQ::item::ItemType type;
|
|
||||||
bool condition;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct AddititiveSearchCriteria {
|
|
||||||
bool should_check;
|
|
||||||
bool condition;
|
|
||||||
};
|
|
||||||
|
|
||||||
for (auto row: results) {
|
|
||||||
BazaarSearchResultsFromDB_Struct r{};
|
|
||||||
|
|
||||||
r.item_id = Strings::ToInt(row[2]);
|
|
||||||
r.charges = Strings::ToInt(row[4]);
|
|
||||||
|
|
||||||
auto item = db.GetItem(r.item_id);
|
|
||||||
if (!item) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
uint32 aug_slot_1 = Strings::ToUnsignedInt(row[11]);
|
|
||||||
uint32 aug_slot_2 = Strings::ToUnsignedInt(row[12]);
|
|
||||||
uint32 aug_slot_3 = Strings::ToUnsignedInt(row[13]);
|
|
||||||
uint32 aug_slot_4 = Strings::ToUnsignedInt(row[14]);
|
|
||||||
uint32 aug_slot_5 = Strings::ToUnsignedInt(row[15]);
|
|
||||||
uint32 aug_slot_6 = Strings::ToUnsignedInt(row[16]);
|
|
||||||
|
|
||||||
std::unique_ptr<EQ::ItemInstance> inst(
|
|
||||||
db.CreateItem(
|
|
||||||
item,
|
|
||||||
r.charges,
|
|
||||||
aug_slot_1,
|
|
||||||
aug_slot_2,
|
|
||||||
aug_slot_3,
|
|
||||||
aug_slot_4,
|
|
||||||
aug_slot_5,
|
|
||||||
aug_slot_6
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
if (!inst->GetItem()) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
r.count = Strings::ToInt(row[0]);
|
|
||||||
r.trader_id = Strings::ToInt(row[1]);
|
|
||||||
r.serial_number = Strings::ToInt(row[3]);
|
|
||||||
r.cost = Strings::ToInt(row[5]);
|
|
||||||
r.slot_id = Strings::ToInt(row[6]);
|
|
||||||
r.sum_charges = Strings::ToInt(row[7]);
|
|
||||||
r.stackable = item->Stackable;
|
|
||||||
r.icon_id = item->Icon;
|
|
||||||
r.trader_zone_id = Strings::ToInt(row[8]);
|
|
||||||
r.trader_entity_id = Strings::ToInt(row[9]);
|
|
||||||
r.serial_number_RoF = fmt::format("{:016}\0", Strings::ToInt(row[3]));
|
|
||||||
r.item_name = fmt::format("{:.63}\0", item->Name);
|
|
||||||
r.trader_name = fmt::format("{:.63}\0", std::string(row[10]).c_str());
|
|
||||||
|
|
||||||
LogTradingDetail(
|
|
||||||
"Searching against item [{}] ({}) for trader [{}]",
|
|
||||||
item->Name,
|
|
||||||
item->ID,
|
|
||||||
r.trader_name
|
|
||||||
);
|
|
||||||
|
|
||||||
// item stat searches
|
|
||||||
std::map<uint32, uint32> item_stat_searches = {
|
|
||||||
|
|
||||||
{STAT_AC, inst->GetItemArmorClass(true)},
|
|
||||||
{STAT_AGI, static_cast<uint32>(inst->GetItemAgi(true))},
|
|
||||||
{STAT_CHA, static_cast<uint32>(inst->GetItemCha(true))},
|
|
||||||
{STAT_DEX, static_cast<uint32>(inst->GetItemDex(true))},
|
|
||||||
{STAT_INT, static_cast<uint32>(inst->GetItemInt(true))},
|
|
||||||
{STAT_STA, static_cast<uint32>(inst->GetItemSta(true))},
|
|
||||||
{STAT_STR, static_cast<uint32>(inst->GetItemStr(true))},
|
|
||||||
{STAT_WIS, static_cast<uint32>(inst->GetItemWis(true))},
|
|
||||||
{STAT_COLD, static_cast<uint32>(inst->GetItemCR(true))},
|
|
||||||
{STAT_DISEASE, static_cast<uint32>(inst->GetItemDR(true))},
|
|
||||||
{STAT_FIRE, static_cast<uint32>(inst->GetItemFR(true))},
|
|
||||||
{STAT_MAGIC, static_cast<uint32>(inst->GetItemMR(true))},
|
|
||||||
{STAT_POISON, static_cast<uint32>(inst->GetItemPR(true))},
|
|
||||||
{STAT_HP, static_cast<uint32>(inst->GetItemHP(true))},
|
|
||||||
{STAT_MANA, static_cast<uint32>(inst->GetItemMana(true))},
|
|
||||||
{STAT_ENDURANCE, static_cast<uint32>(inst->GetItemEndur(true))},
|
|
||||||
{STAT_ATTACK, static_cast<uint32>(inst->GetItemAttack(true))},
|
|
||||||
{STAT_HP_REGEN, static_cast<uint32>(inst->GetItemRegen(true))},
|
|
||||||
{STAT_MANA_REGEN, static_cast<uint32>(inst->GetItemManaRegen(true))},
|
|
||||||
{STAT_HASTE, static_cast<uint32>(inst->GetItemHaste(true))},
|
|
||||||
{STAT_DAMAGE_SHIELD, static_cast<uint32>(inst->GetItemDamageShield(true))},
|
|
||||||
{STAT_DS_MITIGATION, static_cast<uint32>(inst->GetItemDSMitigation(true))},
|
|
||||||
{STAT_HEAL_AMOUNT, static_cast<uint32>(inst->GetItemHealAmt(true))},
|
|
||||||
{STAT_SPELL_DAMAGE, static_cast<uint32>(inst->GetItemSpellDamage(true))},
|
|
||||||
{STAT_CLAIRVOYANCE, static_cast<uint32>(inst->GetItemClairvoyance(true))},
|
|
||||||
{STAT_HEROIC_AGILITY, static_cast<uint32>(inst->GetItemHeroicAgi(true))},
|
|
||||||
{STAT_HEROIC_CHARISMA, static_cast<uint32>(inst->GetItemHeroicCha(true))},
|
|
||||||
{STAT_HEROIC_DEXTERITY, static_cast<uint32>(inst->GetItemHeroicDex(true))},
|
|
||||||
{STAT_HEROIC_INTELLIGENCE, static_cast<uint32>(inst->GetItemHeroicInt(true))},
|
|
||||||
{STAT_HEROIC_STAMINA, static_cast<uint32>(inst->GetItemHeroicSta(true))},
|
|
||||||
{STAT_HEROIC_STRENGTH, static_cast<uint32>(inst->GetItemHeroicStr(true))},
|
|
||||||
{STAT_HEROIC_WISDOM, static_cast<uint32>(inst->GetItemHeroicWis(true))},
|
|
||||||
{STAT_BASH, static_cast<uint32>(inst->GetItemSkillsStat(EQ::skills::SkillBash, true))},
|
|
||||||
{STAT_BACKSTAB, static_cast<uint32>(inst->GetItemBackstabDamage(true))},
|
|
||||||
{STAT_DRAGON_PUNCH, static_cast<uint32>(inst->GetItemSkillsStat(EQ::skills::SkillDragonPunch, true))},
|
|
||||||
{STAT_EAGLE_STRIKE, static_cast<uint32>(inst->GetItemSkillsStat(EQ::skills::SkillEagleStrike, true))},
|
|
||||||
{STAT_FLYING_KICK, static_cast<uint32>(inst->GetItemSkillsStat(EQ::skills::SkillFlyingKick, true))},
|
|
||||||
{STAT_KICK, static_cast<uint32>(inst->GetItemSkillsStat(EQ::skills::SkillKick, true))},
|
|
||||||
{STAT_ROUND_KICK, static_cast<uint32>(inst->GetItemSkillsStat(EQ::skills::SkillRoundKick, true))},
|
|
||||||
{STAT_TIGER_CLAW, static_cast<uint32>(inst->GetItemSkillsStat(EQ::skills::SkillTigerClaw, true))},
|
|
||||||
{STAT_FRENZY, static_cast<uint32>(inst->GetItemSkillsStat(EQ::skills::SkillFrenzy, true))},
|
|
||||||
};
|
|
||||||
|
|
||||||
r.item_stat = item_stat_searches.contains(search.item_stat) ? item_stat_searches[search.item_stat] : 0;
|
|
||||||
if (item_stat_searches.contains(search.item_stat) && item_stat_searches[search.item_stat] <= 0) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
static std::map<uint8, uint32> item_slot_searches = {
|
|
||||||
{EQ::invslot::slotCharm, 1},
|
{EQ::invslot::slotCharm, 1},
|
||||||
{EQ::invslot::slotEar1, 2},
|
{EQ::invslot::slotEar1, 2},
|
||||||
{EQ::invslot::slotHead, 4},
|
{EQ::invslot::slotHead, 4},
|
||||||
@@ -220,132 +58,269 @@ Bazaar::GetSearchResults(
|
|||||||
{EQ::invslot::slotAmmo, 4194304},
|
{EQ::invslot::slotAmmo, 4194304},
|
||||||
};
|
};
|
||||||
|
|
||||||
auto GetEquipmentSlotBit = [&](uint32 slot) -> uint32 {
|
struct ItemSearchType {
|
||||||
return item_slot_searches.contains(slot) ? item_slot_searches[slot] : 0;
|
EQ::item::ItemType type;
|
||||||
|
std::string condition;
|
||||||
};
|
};
|
||||||
|
|
||||||
auto FindItemAugSlot = [&]() -> bool {
|
std::vector<ItemSearchType> item_search_types_new = {
|
||||||
for (auto const &s: inst->GetItem()->AugSlotType) {
|
{EQ::item::ItemType::ItemTypeBook, " AND (items.itemclass = 2 or items.itemclass = 31)"},
|
||||||
return s == search.augment;
|
{EQ::item::ItemType::ItemTypeContainer, " AND (items.itemclass = 1 or items.itemclass = 67)"},
|
||||||
|
{EQ::item::ItemType::ItemTypeAllEffects, " AND (items.scrolleffect > 0 && items.scrolleffect < 65000)"},
|
||||||
|
{EQ::item::ItemType::ItemTypeUnknown9, " AND items.worneffect = 998"},
|
||||||
|
{EQ::item::ItemType::ItemTypeUnknown10, " AND (items.worneffect >= 1298 && items.worneffect <= 1307)"},
|
||||||
|
{EQ::item::ItemType::ItemTypeFocusEffect, " AND items.focuseffect > 0"},
|
||||||
|
{EQ::item::ItemType::ItemTypeArmor, " AND items.itemtype = 10"},
|
||||||
|
{EQ::item::ItemType::ItemType1HBlunt, " AND items.itemtype = 3"},
|
||||||
|
{EQ::item::ItemType::ItemType1HPiercing, " AND items.itemtype = 2"},
|
||||||
|
{EQ::item::ItemType::ItemType1HSlash, " AND items.itemtype = 0"},
|
||||||
|
{EQ::item::ItemType::ItemType2HBlunt, " AND items.itemtype = 4"},
|
||||||
|
{EQ::item::ItemType::ItemType2HSlash, " AND items.itemtype = 1"},
|
||||||
|
{EQ::item::ItemType::ItemTypeBow, " AND items.itemtype = 5"},
|
||||||
|
{EQ::item::ItemType::ItemTypeShield, " AND items.itemtype = 8"},
|
||||||
|
{EQ::item::ItemType::ItemTypeMisc, " AND items.itemtype = 11"},
|
||||||
|
{EQ::item::ItemType::ItemTypeFood, " AND items.itemtype = 14"},
|
||||||
|
{EQ::item::ItemType::ItemTypeDrink, " AND items.itemtype = 15"},
|
||||||
|
{EQ::item::ItemType::ItemTypeLight, " AND items.itemtype = 16"},
|
||||||
|
{EQ::item::ItemType::ItemTypeCombinable, " AND items.itemtype = 17"},
|
||||||
|
{EQ::item::ItemType::ItemTypeBandage, " AND items.itemtype = 18"},
|
||||||
|
{EQ::item::ItemType::ItemTypeSmallThrowing, " AND (items.itemtype = 19 OR items.itemtype = 7)"},
|
||||||
|
{EQ::item::ItemType::ItemTypeSpell, " AND items.itemtype = 20"},
|
||||||
|
{EQ::item::ItemType::ItemTypePotion, " AND items.itemtype = 21"},
|
||||||
|
{EQ::item::ItemType::ItemTypeBrassInstrument, " AND items.itemtype = 25"},
|
||||||
|
{EQ::item::ItemType::ItemTypeWindInstrument, " AND items.itemtype = 23"},
|
||||||
|
{EQ::item::ItemType::ItemTypeStringedInstrument, " AND items.itemtype = 24"},
|
||||||
|
{EQ::item::ItemType::ItemTypePercussionInstrument, " AND items.itemtype = 26"},
|
||||||
|
{EQ::item::ItemType::ItemTypeArrow, " AND items.itemtype = 27"},
|
||||||
|
{EQ::item::ItemType::ItemTypeJewelry, " AND items.itemtype = 29"},
|
||||||
|
{EQ::item::ItemType::ItemTypeNote, " AND items.itemtype = 32"},
|
||||||
|
{EQ::item::ItemType::ItemTypeKey, " AND items.itemtype = 33"},
|
||||||
|
{EQ::item::ItemType::ItemType2HPiercing, " AND items.itemtype = 35"},
|
||||||
|
{EQ::item::ItemType::ItemTypeAlcohol, " AND items.itemtype = 38"},
|
||||||
|
{EQ::item::ItemType::ItemTypeMartial, " AND items.itemtype = 45"},
|
||||||
|
{EQ::item::ItemType::ItemTypeAugmentation, " AND items.itemtype = 54"},
|
||||||
|
{EQ::item::ItemType::ItemTypeAlternateAbility, " AND items.itemtype = 57"},
|
||||||
|
{EQ::item::ItemType::ItemTypeCount, " AND items.itemtype = 65"},
|
||||||
|
{EQ::item::ItemType::ItemTypeCollectible, " AND items.itemtype = 66"}
|
||||||
|
};
|
||||||
|
|
||||||
|
// item stat searches
|
||||||
|
struct ItemStatSearch {
|
||||||
|
std::string query_string;
|
||||||
|
EQ::skills::SkillType skill_type;
|
||||||
|
};
|
||||||
|
|
||||||
|
std::map<uint32, ItemStatSearch> item_stat_searches_new = {
|
||||||
|
{STAT_AC, {" items.ac" , static_cast<EQ::skills::SkillType>(0)} },
|
||||||
|
{STAT_AGI, {" items.aagi", static_cast<EQ::skills::SkillType>(0)} },
|
||||||
|
{STAT_CHA, {" items.acha", static_cast<EQ::skills::SkillType>(0)} },
|
||||||
|
{STAT_DEX, {" items.adex", static_cast<EQ::skills::SkillType>(0)} },
|
||||||
|
{STAT_INT, {" items.aint", static_cast<EQ::skills::SkillType>(0)} },
|
||||||
|
{STAT_STA, {" items.asta", static_cast<EQ::skills::SkillType>(0)} },
|
||||||
|
{STAT_STR, {" items.astr", static_cast<EQ::skills::SkillType>(0)} },
|
||||||
|
{STAT_WIS, {" items.awis", static_cast<EQ::skills::SkillType>(0)} },
|
||||||
|
{STAT_COLD, {" items.cr", static_cast<EQ::skills::SkillType>(0)} },
|
||||||
|
{STAT_DISEASE, {" items.dr", static_cast<EQ::skills::SkillType>(0)} },
|
||||||
|
{STAT_FIRE, {" items.fr", static_cast<EQ::skills::SkillType>(0)} },
|
||||||
|
{STAT_MAGIC, {" items.mr", static_cast<EQ::skills::SkillType>(0)} },
|
||||||
|
{STAT_POISON, {" items.pr", static_cast<EQ::skills::SkillType>(0)} },
|
||||||
|
{STAT_HP, {" items.hp", static_cast<EQ::skills::SkillType>(0)} },
|
||||||
|
{STAT_MANA, {" items.mana", static_cast<EQ::skills::SkillType>(0)} },
|
||||||
|
{STAT_ENDURANCE, {" items.endur", static_cast<EQ::skills::SkillType>(0)} },
|
||||||
|
{STAT_ATTACK, {" items.attack", static_cast<EQ::skills::SkillType>(0)} },
|
||||||
|
{STAT_HP_REGEN, {" items.regen", static_cast<EQ::skills::SkillType>(0)} },
|
||||||
|
{STAT_MANA_REGEN, {" items.manaregen", static_cast<EQ::skills::SkillType>(0)} },
|
||||||
|
{STAT_HASTE, {" items.haste", static_cast<EQ::skills::SkillType>(0)} },
|
||||||
|
{STAT_DAMAGE_SHIELD, {" items.damageshield", static_cast<EQ::skills::SkillType>(0)} },
|
||||||
|
{STAT_DS_MITIGATION, {" items.dsmitigation", static_cast<EQ::skills::SkillType>(0)} },
|
||||||
|
{STAT_HEAL_AMOUNT, {" items.healamt", static_cast<EQ::skills::SkillType>(0)} },
|
||||||
|
{STAT_SPELL_DAMAGE, {" items.spelldmg", static_cast<EQ::skills::SkillType>(0)} },
|
||||||
|
{STAT_CLAIRVOYANCE, {" items.clairvoyance", static_cast<EQ::skills::SkillType>(0)} },
|
||||||
|
{STAT_HEROIC_AGILITY, {" items.heroic_agi", static_cast<EQ::skills::SkillType>(0)} },
|
||||||
|
{STAT_HEROIC_CHARISMA, {" items.heroic_cha", static_cast<EQ::skills::SkillType>(0)} },
|
||||||
|
{STAT_HEROIC_DEXTERITY, {" items.heroic_dex", static_cast<EQ::skills::SkillType>(0)} },
|
||||||
|
{STAT_HEROIC_INTELLIGENCE, {" items.heroic_int", static_cast<EQ::skills::SkillType>(0)} },
|
||||||
|
{STAT_HEROIC_STAMINA, {" items.heroic_sta", static_cast<EQ::skills::SkillType>(0)} },
|
||||||
|
{STAT_HEROIC_STRENGTH, {" items.heroic_str", static_cast<EQ::skills::SkillType>(0)} },
|
||||||
|
{STAT_HEROIC_WISDOM, {" items.heroic_wis", static_cast<EQ::skills::SkillType>(0)} },
|
||||||
|
{STAT_BASH, {" items.skillmodvalue", EQ::skills::SkillBash} },
|
||||||
|
{STAT_BACKSTAB, {" items.backstabdmg", EQ::skills::SkillBackstab} },
|
||||||
|
{STAT_DRAGON_PUNCH, {" items.skillmodvalue", EQ::skills::SkillDragonPunch} },
|
||||||
|
{STAT_EAGLE_STRIKE, {" items.skillmodvalue", EQ::skills::SkillEagleStrike} },
|
||||||
|
{STAT_FLYING_KICK, {" items.skillmodvalue", EQ::skills::SkillFlyingKick} },
|
||||||
|
{STAT_KICK, {" items.skillmodvalue", EQ::skills::SkillKick} },
|
||||||
|
{STAT_ROUND_KICK, {" items.skillmodvalue", EQ::skills::SkillRoundKick} },
|
||||||
|
{STAT_TIGER_CLAW, {" items.skillmodvalue", EQ::skills::SkillTigerClaw} },
|
||||||
|
{STAT_FRENZY, {" items.skillmodvalue", EQ::skills::SkillFrenzy} },
|
||||||
|
};
|
||||||
|
|
||||||
|
bool convert = false;
|
||||||
|
std::string search_criteria_trader("TRUE");
|
||||||
|
std::string field_criteria_items("FALSE");
|
||||||
|
std::string where_criteria_items(" TRUE ");
|
||||||
|
|
||||||
|
if (search.search_scope == NonRoFBazaarSearchScope) {
|
||||||
|
search_criteria_trader.append(
|
||||||
|
fmt::format(
|
||||||
|
" AND trader.char_entity_id = {} AND trader.char_zone_id = {} AND trader.char_zone_instance_id = {}",
|
||||||
|
search.trader_entity_id,
|
||||||
|
Zones::BAZAAR,
|
||||||
|
char_zone_instance_id
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
else if (search.search_scope == Local_Scope) {
|
||||||
|
search_criteria_trader.append(fmt::format(
|
||||||
|
" AND trader.char_zone_id = {} AND trader.char_zone_instance_id = {}",
|
||||||
|
char_zone_id,
|
||||||
|
char_zone_instance_id)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
else if (search.trader_id > 0) {
|
||||||
|
if (RuleB(Bazaar, UseAlternateBazaarSearch)) {
|
||||||
|
if (search.trader_id >= TraderRepository::TRADER_CONVERT_ID) {
|
||||||
|
convert = true;
|
||||||
|
search_criteria_trader.append(fmt::format(
|
||||||
|
" AND trader.char_zone_id = {} AND trader.char_zone_instance_id = {}",
|
||||||
|
Zones::BAZAAR,
|
||||||
|
search.trader_id - TraderRepository::TRADER_CONVERT_ID)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
search_criteria_trader.append(fmt::format(" AND trader.char_id = {}", search.trader_id));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
search_criteria_trader.append(fmt::format(" AND trader.char_id = {}", search.trader_id));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return false;
|
|
||||||
};
|
|
||||||
|
|
||||||
// item type searches
|
if (search.min_cost != 0) {
|
||||||
std::vector<ItemSearchType> item_search_types = {
|
search_criteria_trader.append(fmt::format(" AND trader.item_cost >= {}", search.min_cost * 1000));
|
||||||
{EQ::item::ItemType::ItemTypeAll, true},
|
}
|
||||||
{EQ::item::ItemType::ItemTypeBook, item->ItemClass == EQ::item::ItemType::ItemTypeBook},
|
if (search.max_cost != 0) {
|
||||||
{EQ::item::ItemType::ItemTypeContainer, item->ItemClass == EQ::item::ItemType::ItemTypeContainer},
|
search_criteria_trader.append(fmt::format(" AND trader.item_cost <= {}", (uint64) search.max_cost * 1000));
|
||||||
{EQ::item::ItemType::ItemTypeAllEffects, item->Scroll.Effect > 0 && item->Scroll.Effect < 65000},
|
}
|
||||||
{EQ::item::ItemType::ItemTypeUnknown9, item->Worn.Effect == 998},
|
|
||||||
{EQ::item::ItemType::ItemTypeUnknown10, item->Worn.Effect >= 1298 && item->Worn.Effect <= 1307},
|
|
||||||
{EQ::item::ItemType::ItemTypeFocusEffect, item->Focus.Effect > 0},
|
|
||||||
{EQ::item::ItemType::ItemTypeArmor, item->ItemType == EQ::item::ItemType::ItemTypeArmor},
|
|
||||||
{EQ::item::ItemType::ItemType1HBlunt, item->ItemType == EQ::item::ItemType::ItemType1HBlunt},
|
|
||||||
{EQ::item::ItemType::ItemType1HPiercing, item->ItemType == EQ::item::ItemType::ItemType1HPiercing},
|
|
||||||
{EQ::item::ItemType::ItemType1HSlash, item->ItemType == EQ::item::ItemType::ItemType1HSlash},
|
|
||||||
{EQ::item::ItemType::ItemType2HBlunt, item->ItemType == EQ::item::ItemType::ItemType2HBlunt},
|
|
||||||
{EQ::item::ItemType::ItemType2HSlash, item->ItemType == EQ::item::ItemType::ItemType2HSlash},
|
|
||||||
{EQ::item::ItemType::ItemTypeBow, item->ItemType == EQ::item::ItemType::ItemTypeBow},
|
|
||||||
{EQ::item::ItemType::ItemTypeShield, item->ItemType == EQ::item::ItemType::ItemTypeShield},
|
|
||||||
{EQ::item::ItemType::ItemTypeMisc, item->ItemType == EQ::item::ItemType::ItemTypeMisc},
|
|
||||||
{EQ::item::ItemType::ItemTypeFood, item->ItemType == EQ::item::ItemType::ItemTypeFood},
|
|
||||||
{EQ::item::ItemType::ItemTypeDrink, item->ItemType == EQ::item::ItemType::ItemTypeDrink},
|
|
||||||
{EQ::item::ItemType::ItemTypeLight, item->ItemType == EQ::item::ItemType::ItemTypeLight},
|
|
||||||
{EQ::item::ItemType::ItemTypeCombinable, item->ItemType == EQ::item::ItemType::ItemTypeCombinable},
|
|
||||||
{EQ::item::ItemType::ItemTypeBandage, item->ItemType == EQ::item::ItemType::ItemTypeBandage},
|
|
||||||
{EQ::item::ItemType::ItemTypeSmallThrowing, item->ItemType == EQ::item::ItemType::ItemTypeSmallThrowing ||
|
|
||||||
item->ItemType == EQ::item::ItemType::ItemTypeLargeThrowing},
|
|
||||||
{EQ::item::ItemType::ItemTypeSpell, item->ItemType == EQ::item::ItemType::ItemTypeSpell},
|
|
||||||
{EQ::item::ItemType::ItemTypePotion, item->ItemType == EQ::item::ItemType::ItemTypePotion},
|
|
||||||
{EQ::item::ItemType::ItemTypeBrassInstrument, item->ItemType == EQ::item::ItemType::ItemTypeBrassInstrument},
|
|
||||||
{EQ::item::ItemType::ItemTypeWindInstrument, item->ItemType == EQ::item::ItemType::ItemTypeWindInstrument},
|
|
||||||
{EQ::item::ItemType::ItemTypeStringedInstrument, item->ItemType == EQ::item::ItemType::ItemTypeStringedInstrument},
|
|
||||||
{EQ::item::ItemType::ItemTypePercussionInstrument, item->ItemType == EQ::item::ItemType::ItemTypePercussionInstrument},
|
|
||||||
{EQ::item::ItemType::ItemTypeArrow, item->ItemType == EQ::item::ItemType::ItemTypeArrow},
|
|
||||||
{EQ::item::ItemType::ItemTypeJewelry, item->ItemType == EQ::item::ItemType::ItemTypeJewelry},
|
|
||||||
{EQ::item::ItemType::ItemTypeNote, item->ItemType == EQ::item::ItemType::ItemTypeNote},
|
|
||||||
{EQ::item::ItemType::ItemTypeKey, item->ItemType == EQ::item::ItemType::ItemTypeKey},
|
|
||||||
{EQ::item::ItemType::ItemType2HPiercing, item->ItemType == EQ::item::ItemType::ItemType2HPiercing},
|
|
||||||
{EQ::item::ItemType::ItemTypeAlcohol, item->ItemType == EQ::item::ItemType::ItemTypeAlcohol},
|
|
||||||
{EQ::item::ItemType::ItemTypeMartial, item->ItemType == EQ::item::ItemType::ItemTypeMartial},
|
|
||||||
{EQ::item::ItemType::ItemTypeAugmentation, item->ItemType == EQ::item::ItemType::ItemTypeAugmentation},
|
|
||||||
{EQ::item::ItemType::ItemTypeAlternateAbility, item->ItemType == EQ::item::ItemType::ItemTypeAlternateAbility},
|
|
||||||
{EQ::item::ItemType::ItemTypeCount, item->ItemType == EQ::item::ItemType::ItemTypeCount},
|
|
||||||
{EQ::item::ItemType::ItemTypeCollectible, item->ItemType == EQ::item::ItemType::ItemTypeCollectible}
|
|
||||||
};
|
|
||||||
|
|
||||||
bool met_filter = false;
|
if (search.slot != std::numeric_limits<uint32>::max()) {
|
||||||
bool has_filter = false;
|
if (item_slot_searches_new.contains(search.slot)) {
|
||||||
|
where_criteria_items.append(
|
||||||
|
fmt::format(" AND items.slots & {0} = {0}", item_slot_searches_new[search.slot]));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
for (auto &i: item_search_types) {
|
if (search.type != std::numeric_limits<uint32>::max()) {
|
||||||
if (i.type == search.type) {
|
for (auto const &[type, condition]: item_search_types_new) {
|
||||||
has_filter = true;
|
if (type == search.type) {
|
||||||
if (i.condition) {
|
where_criteria_items.append(condition);
|
||||||
LogTradingDetail("Item [{}] met search criteria for type [{}]", item->Name, uint8(i.type));
|
|
||||||
met_filter = true;
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (has_filter && !met_filter) {
|
|
||||||
continue;
|
if (search.race != std::numeric_limits<uint32>::max()) {
|
||||||
|
where_criteria_items.append(
|
||||||
|
fmt::format(" AND items.races & {0} = {0}", GetPlayerRaceBit(GetRaceIDFromPlayerRaceValue(search.race))));
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Add catch-all item type filter for specific item types
|
if (search._class != std::numeric_limits<uint32>::max()) {
|
||||||
|
where_criteria_items.append(fmt::format(" AND items.classes & {0} = {0}", GetPlayerClassBit(search._class)));
|
||||||
|
}
|
||||||
|
|
||||||
// item additive searches
|
if (search.item_stat != std::numeric_limits<uint32>::max()) {
|
||||||
std::vector<AddititiveSearchCriteria> item_additive_searches = {
|
if (item_stat_searches_new.contains(search.item_stat)) {
|
||||||
{
|
field_criteria_items = fmt::format("{}", item_stat_searches_new[search.item_stat].query_string);
|
||||||
.should_check = search.min_level != 1 && inst->GetItemRequiredLevel(true) > 0,
|
if (item_stat_searches_new[search.item_stat].skill_type) {
|
||||||
.condition = inst->GetItemRequiredLevel(true) >= search.min_level
|
where_criteria_items.append(
|
||||||
},
|
fmt::format(" AND items.skillmodtype = {} ", item_stat_searches_new[search.item_stat].skill_type));
|
||||||
{
|
}
|
||||||
.should_check = search.max_level != 1 && inst->GetItemRequiredLevel(true) > 0,
|
else {
|
||||||
.condition = inst->GetItemRequiredLevel(true) <= search.max_level
|
where_criteria_items.append(
|
||||||
},
|
fmt::format(" AND {} > 0 ", item_stat_searches_new[search.item_stat].query_string));
|
||||||
{
|
}
|
||||||
.should_check = !std::string(search.item_name).empty(),
|
}
|
||||||
.condition = Strings::ContainsLower(item->Name, search.item_name)
|
}
|
||||||
},
|
|
||||||
{
|
|
||||||
.should_check = search._class != 0xFFFFFFFF,
|
|
||||||
.condition = static_cast<bool>(item->Classes & GetPlayerClassBit(search._class))
|
|
||||||
},
|
|
||||||
{
|
|
||||||
.should_check = search.race != 0xFFFFFFFF,
|
|
||||||
.condition = static_cast<bool>(item->Races & GetPlayerRaceBit(GetRaceIDFromPlayerRaceValue(search.race)))
|
|
||||||
},
|
|
||||||
{
|
|
||||||
.should_check = search.augment != 0,
|
|
||||||
.condition = FindItemAugSlot()
|
|
||||||
},
|
|
||||||
{
|
|
||||||
.should_check = search.slot != 0xFFFFFFFF,
|
|
||||||
.condition = static_cast<bool>(item->Slots & GetEquipmentSlotBit(search.slot))
|
|
||||||
},
|
|
||||||
};
|
|
||||||
|
|
||||||
bool should_add = true;
|
if (search.augment) {
|
||||||
|
where_criteria_items.append(fmt::format(
|
||||||
for (auto &i: item_additive_searches) {
|
" AND (items.augslot1type = {0} OR "
|
||||||
LogTradingDetail(
|
"items.augslot2type = {0} OR "
|
||||||
"Checking item [{}] for search criteria - should_check [{}] condition [{}]",
|
"items.augslot3type = {0} OR "
|
||||||
item->Name,
|
"items.augslot4type = {0} OR "
|
||||||
i.should_check,
|
"items.augslot5type = {0} OR "
|
||||||
i.condition
|
"items.augslot6type = {0})",
|
||||||
|
search.augment)
|
||||||
);
|
);
|
||||||
if (i.should_check && !i.condition) {
|
|
||||||
should_add = false;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!should_add) {
|
if (search.min_level != 1) {
|
||||||
|
where_criteria_items.append(fmt::format(" AND items.reclevel >= {}", search.min_level));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (search.max_level != 100) {
|
||||||
|
where_criteria_items.append(fmt::format(" AND items.reclevel <= {}", search.max_level));
|
||||||
|
}
|
||||||
|
|
||||||
|
std::vector<BazaarSearchResultsFromDB_Struct> all_entries;
|
||||||
|
std::vector<std::string> trader_items_ids{};
|
||||||
|
|
||||||
|
auto const trader_results = TraderRepository::GetBazaarTraderDetails(db, search_criteria_trader);
|
||||||
|
if (trader_results.empty()) {
|
||||||
|
LogTradingDetail("Bazaar - No traders found in bazaar search.");
|
||||||
|
return all_entries;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (auto const &i: trader_results) {
|
||||||
|
trader_items_ids.push_back(std::to_string(i.trader.item_id));
|
||||||
|
}
|
||||||
|
|
||||||
|
auto const item_results = ItemsRepository::GetItemsForBazaarSearch(
|
||||||
|
content_db,
|
||||||
|
trader_items_ids,
|
||||||
|
std::string(search.item_name),
|
||||||
|
field_criteria_items,
|
||||||
|
where_criteria_items,
|
||||||
|
search.max_results
|
||||||
|
);
|
||||||
|
|
||||||
|
if (item_results.empty()) {
|
||||||
|
LogTradingDetail("Bazaar - No items found in bazaar search.");
|
||||||
|
return all_entries;
|
||||||
|
}
|
||||||
|
|
||||||
|
all_entries.reserve(trader_results.size());
|
||||||
|
|
||||||
|
for (auto const& t:trader_results) {
|
||||||
|
if (!item_results.contains(t.trader.item_id)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
LogTradingDetail("Found item [{}] meeting search criteria.", r.item_name);
|
BazaarSearchResultsFromDB_Struct r{};
|
||||||
|
r.count = 1;
|
||||||
|
r.trader_id = t.trader.char_id;
|
||||||
|
r.serial_number = t.trader.item_sn;
|
||||||
|
r.cost = t.trader.item_cost;
|
||||||
|
r.slot_id = t.trader.slot_id;
|
||||||
|
r.charges = t.trader.item_charges;
|
||||||
|
r.stackable = item_results.at(t.trader.item_id).stackable;
|
||||||
|
r.icon_id = item_results.at(t.trader.item_id).icon;
|
||||||
|
r.trader_zone_id = t.trader.char_zone_id;
|
||||||
|
r.trader_zone_instance_id = t.trader.char_zone_instance_id;
|
||||||
|
r.trader_entity_id = t.trader.char_entity_id;
|
||||||
|
r.serial_number_RoF = fmt::format("{:016}\0", t.trader.item_sn);
|
||||||
|
r.item_name = fmt::format("{:.63}\0", item_results.at(t.trader.item_id).name);
|
||||||
|
r.trader_name = fmt::format("{:.63}\0", t.trader_name);
|
||||||
|
r.item_stat = item_results.at(t.trader.item_id).stats;
|
||||||
|
|
||||||
|
if (RuleB(Bazaar, UseAlternateBazaarSearch)) {
|
||||||
|
if (convert ||
|
||||||
|
char_zone_id != Zones::BAZAAR ||
|
||||||
|
(char_zone_id == Zones::BAZAAR && r.trader_zone_instance_id != char_zone_instance_id)
|
||||||
|
) {
|
||||||
|
r.trader_id = TraderRepository::TRADER_CONVERT_ID + r.trader_zone_instance_id;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
all_entries.push_back(r);
|
all_entries.push_back(r);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+3
-1
@@ -3,11 +3,13 @@
|
|||||||
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include "shareddb.h"
|
#include "shareddb.h"
|
||||||
|
#include "../../common/item_instance.h"
|
||||||
|
|
||||||
class Bazaar {
|
class Bazaar {
|
||||||
public:
|
public:
|
||||||
static std::vector<BazaarSearchResultsFromDB_Struct>
|
static std::vector<BazaarSearchResultsFromDB_Struct>
|
||||||
GetSearchResults(SharedDatabase &db, BazaarSearchCriteria_Struct search, unsigned int char_zone_id);
|
GetSearchResults(Database &content_db, Database &db, BazaarSearchCriteria_Struct search, unsigned int char_zone_id, int char_zone_instance_id);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -16,6 +16,7 @@
|
|||||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
*/
|
*/
|
||||||
#include <fmt/format.h>
|
#include <fmt/format.h>
|
||||||
|
#include <fmt/ranges.h>
|
||||||
#include "../common/global_define.h"
|
#include "../common/global_define.h"
|
||||||
#include "../common/classes.h"
|
#include "../common/classes.h"
|
||||||
#include "data_verification.h"
|
#include "data_verification.h"
|
||||||
|
|||||||
@@ -131,6 +131,8 @@ static std::map<uint8, std::string> class_names = {
|
|||||||
#define ARMOR_TYPE_LAST ARMOR_TYPE_PLATE
|
#define ARMOR_TYPE_LAST ARMOR_TYPE_PLATE
|
||||||
#define ARMOR_TYPE_COUNT 5
|
#define ARMOR_TYPE_COUNT 5
|
||||||
|
|
||||||
|
#define BOT_CLASS_BASE_ID_PREFIX 3000
|
||||||
|
|
||||||
|
|
||||||
const char* GetClassIDName(uint8 class_id, uint8 level = 0);
|
const char* GetClassIDName(uint8 class_id, uint8 level = 0);
|
||||||
|
|
||||||
|
|||||||
@@ -19,6 +19,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include <fmt/format.h>
|
#include <fmt/format.h>
|
||||||
|
#include <fmt/ranges.h>
|
||||||
#include "eqemu_command_handler.h"
|
#include "eqemu_command_handler.h"
|
||||||
#include "terminal_color.hpp"
|
#include "terminal_color.hpp"
|
||||||
#include "../platform.h"
|
#include "../platform.h"
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ WorldContentService *WorldContentService::SetExpansionContext()
|
|||||||
// pull expansion from rules
|
// pull expansion from rules
|
||||||
int expansion = RuleI(Expansion, CurrentExpansion);
|
int expansion = RuleI(Expansion, CurrentExpansion);
|
||||||
if (expansion >= Expansion::Classic && expansion <= Expansion::MaxId) {
|
if (expansion >= Expansion::Classic && expansion <= Expansion::MaxId) {
|
||||||
content_service.SetCurrentExpansion(expansion);
|
WorldContentService::Instance()->SetCurrentExpansion(expansion);
|
||||||
}
|
}
|
||||||
|
|
||||||
LogInfo(
|
LogInfo(
|
||||||
@@ -41,12 +41,12 @@ WorldContentService *WorldContentService::SetExpansionContext()
|
|||||||
|
|
||||||
std::string WorldContentService::GetCurrentExpansionName()
|
std::string WorldContentService::GetCurrentExpansionName()
|
||||||
{
|
{
|
||||||
if (content_service.GetCurrentExpansion() == Expansion::EXPANSION_ALL) {
|
if (WorldContentService::Instance()->GetCurrentExpansion() == Expansion::EXPANSION_ALL) {
|
||||||
return "All Expansions";
|
return "All Expansions";
|
||||||
}
|
}
|
||||||
|
|
||||||
if (current_expansion >= Expansion::Classic && current_expansion <= Expansion::MaxId) {
|
if (current_expansion >= Expansion::Classic && current_expansion <= Expansion::MaxId) {
|
||||||
return Expansion::ExpansionName[content_service.GetCurrentExpansion()];
|
return Expansion::ExpansionName[WorldContentService::Instance()->GetCurrentExpansion()];
|
||||||
}
|
}
|
||||||
|
|
||||||
return "Unknown Expansion";
|
return "Unknown Expansion";
|
||||||
@@ -185,7 +185,7 @@ void WorldContentService::ReloadContentFlags()
|
|||||||
|
|
||||||
SetContentFlags(set_content_flags);
|
SetContentFlags(set_content_flags);
|
||||||
LoadStaticGlobalZoneInstances();
|
LoadStaticGlobalZoneInstances();
|
||||||
zone_store.LoadZones(*m_content_database);
|
ZoneStore::Instance()->LoadZones(*m_content_database);
|
||||||
}
|
}
|
||||||
|
|
||||||
Database *WorldContentService::GetDatabase() const
|
Database *WorldContentService::GetDatabase() const
|
||||||
@@ -291,7 +291,7 @@ WorldContentService *WorldContentService::LoadStaticGlobalZoneInstances()
|
|||||||
// instance_list table entry for lavastorm has version = 1, is_global = 1, never_expires = 1
|
// instance_list table entry for lavastorm has version = 1, is_global = 1, never_expires = 1
|
||||||
WorldContentService::FindZoneResult WorldContentService::FindZone(uint32 zone_id, uint32 instance_id)
|
WorldContentService::FindZoneResult WorldContentService::FindZone(uint32 zone_id, uint32 instance_id)
|
||||||
{
|
{
|
||||||
for (const auto &z: zone_store.GetZones()) {
|
for (const auto &z: ZoneStore::Instance()->GetZones()) {
|
||||||
for (auto &i: m_zone_static_instances) {
|
for (auto &i: m_zone_static_instances) {
|
||||||
if (
|
if (
|
||||||
z.zoneidnumber == zone_id &&
|
z.zoneidnumber == zone_id &&
|
||||||
|
|||||||
@@ -181,6 +181,12 @@ public:
|
|||||||
FindZoneResult FindZone(uint32 zone_id, uint32 instance_id);
|
FindZoneResult FindZone(uint32 zone_id, uint32 instance_id);
|
||||||
bool IsInPublicStaticInstance(uint32 instance_id);
|
bool IsInPublicStaticInstance(uint32 instance_id);
|
||||||
|
|
||||||
|
static WorldContentService* Instance()
|
||||||
|
{
|
||||||
|
static WorldContentService instance;
|
||||||
|
return &instance;
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
int current_expansion{};
|
int current_expansion{};
|
||||||
std::vector<ContentFlagsRepository::ContentFlags> content_flags;
|
std::vector<ContentFlagsRepository::ContentFlags> content_flags;
|
||||||
@@ -194,6 +200,4 @@ private:
|
|||||||
std::vector<InstanceListRepository::InstanceList> m_zone_static_instances;
|
std::vector<InstanceListRepository::InstanceList> m_zone_static_instances;
|
||||||
};
|
};
|
||||||
|
|
||||||
extern WorldContentService content_service;
|
|
||||||
|
|
||||||
#endif //EQEMU_WORLD_CONTENT_SERVICE_H
|
#endif //EQEMU_WORLD_CONTENT_SERVICE_H
|
||||||
|
|||||||
+9
-5
@@ -23,10 +23,12 @@ void SendCrashReport(const std::string &crash_report)
|
|||||||
{
|
{
|
||||||
// can configure multiple endpoints if need be
|
// can configure multiple endpoints if need be
|
||||||
std::vector<std::string> endpoints = {
|
std::vector<std::string> endpoints = {
|
||||||
"https://spire.akkadius.com/api/v1/analytics/server-crash-report",
|
"https://spire.eqemu.dev/api/v1/analytics/server-crash-report",
|
||||||
// "http://localhost:3010/api/v1/analytics/server-crash-report", // development
|
// "http://localhost:3010/api/v1/analytics/server-crash-report", // development
|
||||||
};
|
};
|
||||||
|
|
||||||
|
EQEmuLogSys* log = EQEmuLogSys::Instance();
|
||||||
|
|
||||||
auto config = EQEmuConfig::get();
|
auto config = EQEmuConfig::get();
|
||||||
for (auto &e: endpoints) {
|
for (auto &e: endpoints) {
|
||||||
uri u(e);
|
uri u(e);
|
||||||
@@ -68,12 +70,12 @@ void SendCrashReport(const std::string &crash_report)
|
|||||||
p["cpus"] = cpus.size();
|
p["cpus"] = cpus.size();
|
||||||
p["origination_info"] = "";
|
p["origination_info"] = "";
|
||||||
|
|
||||||
if (!LogSys.origination_info.zone_short_name.empty()) {
|
if (!log->origination_info.zone_short_name.empty()) {
|
||||||
p["origination_info"] = fmt::format(
|
p["origination_info"] = fmt::format(
|
||||||
"{} ({}) instance_id [{}]",
|
"{} ({}) instance_id [{}]",
|
||||||
LogSys.origination_info.zone_short_name,
|
log->origination_info.zone_short_name,
|
||||||
LogSys.origination_info.zone_long_name,
|
log->origination_info.zone_long_name,
|
||||||
LogSys.origination_info.instance_id
|
log->origination_info.instance_id
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -294,6 +296,8 @@ void print_trace()
|
|||||||
SendCrashReport(crash_report);
|
SendCrashReport(crash_report);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
EQEmuLogSys::Instance()->CloseFileLogs();
|
||||||
|
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,836 @@
|
|||||||
|
#include "../common/data_bucket.h"
|
||||||
|
#include "database.h"
|
||||||
|
#include <ctime>
|
||||||
|
#include <cctype>
|
||||||
|
#include "../common/json/json.hpp"
|
||||||
|
|
||||||
|
using json = nlohmann::json;
|
||||||
|
|
||||||
|
const std::string NESTED_KEY_DELIMITER = ".";
|
||||||
|
std::vector<DataBucketsRepository::DataBuckets> g_data_bucket_cache = {};
|
||||||
|
|
||||||
|
void DataBucket::SetData(SharedDatabase* database, const std::string &bucket_key, const std::string &bucket_value, std::string expires_time)
|
||||||
|
{
|
||||||
|
auto k = DataBucketKey{
|
||||||
|
.key = bucket_key,
|
||||||
|
.value = bucket_value,
|
||||||
|
.expires = expires_time,
|
||||||
|
};
|
||||||
|
|
||||||
|
DataBucket::SetData(database, k);
|
||||||
|
}
|
||||||
|
|
||||||
|
void DataBucket::SetData(SharedDatabase *database, const DataBucketKey &k_)
|
||||||
|
{
|
||||||
|
DataBucketKey k = k_; // copy the key so we can modify it
|
||||||
|
bool is_nested = k.key.find(NESTED_KEY_DELIMITER) != std::string::npos;
|
||||||
|
if (is_nested) {
|
||||||
|
k.key = Strings::Split(k.key, NESTED_KEY_DELIMITER).front();
|
||||||
|
}
|
||||||
|
|
||||||
|
auto b = DataBucketsRepository::NewEntity();
|
||||||
|
auto r = GetData(database, k, true);
|
||||||
|
// if we have an entry, use it
|
||||||
|
if (r.id > 0) {
|
||||||
|
b = r;
|
||||||
|
}
|
||||||
|
|
||||||
|
// add scoping to bucket
|
||||||
|
if (k.character_id > 0) {
|
||||||
|
b.character_id = k.character_id;
|
||||||
|
}
|
||||||
|
else if (k.account_id > 0) {
|
||||||
|
b.account_id = k.account_id;
|
||||||
|
}
|
||||||
|
else if (k.npc_id > 0) {
|
||||||
|
b.npc_id = k.npc_id;
|
||||||
|
}
|
||||||
|
else if (k.bot_id > 0) {
|
||||||
|
b.bot_id = k.bot_id;
|
||||||
|
} else if (k.zone_id > 0) {
|
||||||
|
b.zone_id = k.zone_id;
|
||||||
|
b.instance_id = k.instance_id;
|
||||||
|
}
|
||||||
|
|
||||||
|
const uint64 bucket_id = b.id;
|
||||||
|
int64 expires_time_unix = 0;
|
||||||
|
|
||||||
|
if (!k.expires.empty()) {
|
||||||
|
expires_time_unix = static_cast<int64>(std::time(nullptr)) + Strings::ToInt(k.expires);
|
||||||
|
if (isalpha(k.expires[0]) || isalpha(k.expires[k.expires.length() - 1])) {
|
||||||
|
expires_time_unix = static_cast<int64>(std::time(nullptr)) + Strings::TimeToSeconds(k.expires);
|
||||||
|
}
|
||||||
|
if (is_nested) {
|
||||||
|
LogDataBuckets("Nested keys can't expire; set expiration on the parent key");
|
||||||
|
expires_time_unix = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
b.expires = expires_time_unix;
|
||||||
|
b.value = k.value;
|
||||||
|
b.key_ = k.key;
|
||||||
|
|
||||||
|
// Check for nested keys (keys with dots)
|
||||||
|
if (k_.key.find(NESTED_KEY_DELIMITER) != std::string::npos) {
|
||||||
|
// Retrieve existing JSON or create a new one
|
||||||
|
std::string existing_value = r.id > 0 ? r.value : "{}";
|
||||||
|
json json_value = json::object();
|
||||||
|
|
||||||
|
// Check if the JSON is valid
|
||||||
|
if (Strings::IsValidJson(existing_value)) {
|
||||||
|
try {
|
||||||
|
json_value = json::parse(existing_value);
|
||||||
|
} catch (json::parse_error &e) {
|
||||||
|
LogDataBuckets("Failed to parse JSON for key [{}] [{}]", k_.key, e.what());
|
||||||
|
json_value = json::object(); // Reset to an empty object on error
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Recursively merge new key-value pair into the JSON object
|
||||||
|
auto nested_keys = Strings::Split(k_.key, NESTED_KEY_DELIMITER);
|
||||||
|
auto top_key = nested_keys.front();
|
||||||
|
// remove the top-level key
|
||||||
|
nested_keys.erase(nested_keys.begin());
|
||||||
|
|
||||||
|
json *current = &json_value;
|
||||||
|
|
||||||
|
for (size_t i = 0; i < nested_keys.size(); ++i) {
|
||||||
|
const std::string &key_part = nested_keys[i];
|
||||||
|
|
||||||
|
if (i == nested_keys.size() - 1) {
|
||||||
|
|
||||||
|
LogDataBucketsDetail("Setting key [{}] key_part [{}]", k.key, key_part);
|
||||||
|
|
||||||
|
// If the key already exists and is an object or array, prevent overwriting to avoid data loss
|
||||||
|
if (current->contains(key_part) &&
|
||||||
|
((*current)[key_part].is_object() || (*current)[key_part].is_array())) {
|
||||||
|
LogDataBuckets("Attempted to overwrite an existing object or array at key [{}] - skipping", k_.key);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Set the value at the final key
|
||||||
|
(*current)[key_part] = k_.value;
|
||||||
|
} else {
|
||||||
|
// Traverse or create nested objects
|
||||||
|
if (!current->contains(key_part)) {
|
||||||
|
(*current)[key_part] = json::object();
|
||||||
|
LogDataBucketsDetail("Creating nested root key [{}] key_part [{}]", k.key, key_part);
|
||||||
|
} else if (!(*current)[key_part].is_object()) {
|
||||||
|
// If key exists but is not an object, reset to object to avoid conflicts
|
||||||
|
(*current)[key_part] = json::object();
|
||||||
|
}
|
||||||
|
current = &(*current)[key_part];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Serialize JSON back to string
|
||||||
|
b.value = json_value.dump();
|
||||||
|
b.key_ = top_key; // Use the top-level key
|
||||||
|
}
|
||||||
|
|
||||||
|
if (bucket_id) {
|
||||||
|
// update the cache if it exists
|
||||||
|
if (CanCache(k)) {
|
||||||
|
for (auto &e: g_data_bucket_cache) {
|
||||||
|
if (CheckBucketMatch(e, k)) {
|
||||||
|
e = b;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
DataBucketsRepository::UpdateOne(*database, b);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
b = DataBucketsRepository::InsertOne(*database, b);
|
||||||
|
|
||||||
|
// add to cache if it doesn't exist
|
||||||
|
if (CanCache(k) && !ExistsInCache(b)) {
|
||||||
|
DeleteFromMissesCache(b);
|
||||||
|
g_data_bucket_cache.emplace_back(b);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string DataBucket::GetData(SharedDatabase* database, const std::string &bucket_key)
|
||||||
|
{
|
||||||
|
return GetData(database, DataBucketKey{.key = bucket_key}).value;
|
||||||
|
}
|
||||||
|
|
||||||
|
DataBucketsRepository::DataBuckets DataBucket::ExtractNestedValue(
|
||||||
|
const DataBucketsRepository::DataBuckets &bucket,
|
||||||
|
const std::string &full_key)
|
||||||
|
{
|
||||||
|
auto nested_keys = Strings::Split(full_key, NESTED_KEY_DELIMITER);
|
||||||
|
auto top_key = nested_keys.front();
|
||||||
|
nested_keys.erase(nested_keys.begin());
|
||||||
|
json json_value;
|
||||||
|
|
||||||
|
// Check if the JSON is valid
|
||||||
|
if (!Strings::IsValidJson(bucket.value)) {
|
||||||
|
LogDataBuckets("Invalid JSON for key [{}]", bucket.key_);
|
||||||
|
return DataBucketsRepository::NewEntity();
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
json_value = json::parse(bucket.value); // Parse the JSON
|
||||||
|
} catch (json::parse_error &ex) {
|
||||||
|
LogDataBuckets("Failed to parse JSON for key [{}] [{}]", bucket.key_, ex.what());
|
||||||
|
return DataBucketsRepository::NewEntity(); // Return empty entity on parse error
|
||||||
|
}
|
||||||
|
|
||||||
|
// Start from the top-level key (e.g., "progression")
|
||||||
|
json *current = &json_value;
|
||||||
|
|
||||||
|
// Traverse the JSON structure
|
||||||
|
for (const auto &key_part: nested_keys) {
|
||||||
|
LogDataBuckets("Looking for key part [{}] in JSON", key_part);
|
||||||
|
|
||||||
|
if (!current->contains(key_part)) {
|
||||||
|
LogDataBuckets("Key part [{}] not found in JSON for [{}]", key_part, full_key);
|
||||||
|
return DataBucketsRepository::NewEntity();
|
||||||
|
}
|
||||||
|
|
||||||
|
current = &(*current)[key_part];
|
||||||
|
}
|
||||||
|
|
||||||
|
// Create a new entity with the extracted value
|
||||||
|
DataBucketsRepository::DataBuckets result = bucket; // Copy the original bucket
|
||||||
|
result.value = current->is_string() ? current->get<std::string>() : current->dump();
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetData fetches bucket data from the database or cache if it exists
|
||||||
|
// if the bucket doesn't exist, it will be added to the cache as a miss
|
||||||
|
// if ignore_misses_cache is true, the bucket will not be added to the cache as a miss
|
||||||
|
// the only place we should be ignoring the misses cache is on the initial read during SetData
|
||||||
|
DataBucketsRepository::DataBuckets DataBucket::GetData(SharedDatabase* database, const DataBucketKey &k_, bool ignore_misses_cache)
|
||||||
|
{
|
||||||
|
DataBucketKey k = k_; // Copy the key so we can modify it
|
||||||
|
|
||||||
|
bool is_nested_key = k.key.find(NESTED_KEY_DELIMITER) != std::string::npos;
|
||||||
|
|
||||||
|
// Extract the top-level key for nested keys
|
||||||
|
if (is_nested_key) {
|
||||||
|
k.key = Strings::Split(k.key, NESTED_KEY_DELIMITER).front();
|
||||||
|
}
|
||||||
|
|
||||||
|
LogDataBuckets(
|
||||||
|
"Getting bucket key [{}] bot_id [{}] account_id [{}] character_id [{}] npc_id [{}] zone_id [{}] instance_id [{}]",
|
||||||
|
k.key,
|
||||||
|
k.bot_id,
|
||||||
|
k.account_id,
|
||||||
|
k.character_id,
|
||||||
|
k.npc_id,
|
||||||
|
k.zone_id,
|
||||||
|
k.instance_id
|
||||||
|
);
|
||||||
|
|
||||||
|
bool can_cache = CanCache(k);
|
||||||
|
|
||||||
|
// Attempt to retrieve the value from the cache
|
||||||
|
if (can_cache) {
|
||||||
|
for (const auto &e : g_data_bucket_cache) {
|
||||||
|
if (CheckBucketMatch(e, k)) {
|
||||||
|
if (e.expires > 0 && e.expires < std::time(nullptr)) {
|
||||||
|
LogDataBuckets("Attempted to read expired key [{}] removing from cache", e.key_);
|
||||||
|
DeleteData(database, k);
|
||||||
|
return DataBucketsRepository::NewEntity();
|
||||||
|
}
|
||||||
|
|
||||||
|
LogDataBuckets("Returning key [{}] value [{}] from cache", e.key_, e.value);
|
||||||
|
|
||||||
|
if (is_nested_key && !k_.key.empty()) {
|
||||||
|
return ExtractNestedValue(e, k_.key);
|
||||||
|
}
|
||||||
|
|
||||||
|
return e;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Fetch the value from the database
|
||||||
|
auto r = DataBucketsRepository::GetWhere(
|
||||||
|
*database,
|
||||||
|
fmt::format(
|
||||||
|
" {} `key` = '{}' LIMIT 1",
|
||||||
|
DataBucket::GetScopedDbFilters(k),
|
||||||
|
k.key
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
if (r.empty()) {
|
||||||
|
// Handle cache misses
|
||||||
|
if (!ignore_misses_cache && can_cache) {
|
||||||
|
size_t size_before = g_data_bucket_cache.size();
|
||||||
|
|
||||||
|
g_data_bucket_cache.emplace_back(
|
||||||
|
DataBucketsRepository::DataBuckets{
|
||||||
|
.id = 0,
|
||||||
|
.key_ = k.key,
|
||||||
|
.value = "",
|
||||||
|
.expires = 0,
|
||||||
|
.account_id = k.account_id,
|
||||||
|
.character_id = k.character_id,
|
||||||
|
.npc_id = k.npc_id,
|
||||||
|
.bot_id = k.bot_id,
|
||||||
|
.zone_id = k.zone_id,
|
||||||
|
.instance_id = k.instance_id
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
LogDataBuckets(
|
||||||
|
"Key [{}] not found in database, adding to cache as a miss account_id [{}] character_id [{}] npc_id [{}] bot_id [{}] zone_id [{}] instance_id [{}] cache size before [{}] after [{}]",
|
||||||
|
k.key,
|
||||||
|
k.account_id,
|
||||||
|
k.character_id,
|
||||||
|
k.npc_id,
|
||||||
|
k.bot_id,
|
||||||
|
k.zone_id,
|
||||||
|
k.instance_id,
|
||||||
|
size_before,
|
||||||
|
g_data_bucket_cache.size()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
return DataBucketsRepository::NewEntity();
|
||||||
|
}
|
||||||
|
|
||||||
|
auto bucket = r.front();
|
||||||
|
|
||||||
|
// If the entry has expired, delete it
|
||||||
|
if (bucket.expires > 0 && bucket.expires < static_cast<long long>(std::time(nullptr))) {
|
||||||
|
DeleteData(database, k);
|
||||||
|
return DataBucketsRepository::NewEntity();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Add the value to the cache if it doesn't exist
|
||||||
|
if (can_cache) {
|
||||||
|
bool has_cache = false;
|
||||||
|
for (const auto &e : g_data_bucket_cache) {
|
||||||
|
if (e.id == bucket.id) {
|
||||||
|
has_cache = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!has_cache) {
|
||||||
|
g_data_bucket_cache.emplace_back(bucket);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Handle nested key extraction
|
||||||
|
if (is_nested_key && !k_.key.empty()) {
|
||||||
|
return ExtractNestedValue(bucket, k_.key);
|
||||||
|
}
|
||||||
|
|
||||||
|
return bucket;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string DataBucket::GetDataExpires(SharedDatabase* database, const std::string &bucket_key)
|
||||||
|
{
|
||||||
|
return GetDataExpires(database, DataBucketKey{.key = bucket_key});
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string DataBucket::GetDataRemaining(SharedDatabase* database, const std::string &bucket_key)
|
||||||
|
{
|
||||||
|
return GetDataRemaining(database, DataBucketKey{.key = bucket_key});
|
||||||
|
}
|
||||||
|
|
||||||
|
bool DataBucket::DeleteData(SharedDatabase* database, const std::string &bucket_key)
|
||||||
|
{
|
||||||
|
return DeleteData(database, DataBucketKey{.key = bucket_key});
|
||||||
|
}
|
||||||
|
|
||||||
|
bool DataBucket::DeleteData(SharedDatabase* database, const DataBucketKey &k)
|
||||||
|
{
|
||||||
|
bool is_nested_key = k.key.find(NESTED_KEY_DELIMITER) != std::string::npos;
|
||||||
|
|
||||||
|
if (!is_nested_key) {
|
||||||
|
// Update cache
|
||||||
|
if (CanCache(k)) {
|
||||||
|
// delete from cache where contents match
|
||||||
|
g_data_bucket_cache.erase(
|
||||||
|
std::remove_if(
|
||||||
|
g_data_bucket_cache.begin(),
|
||||||
|
g_data_bucket_cache.end(),
|
||||||
|
[&](DataBucketsRepository::DataBuckets &e) {
|
||||||
|
return CheckBucketMatch(e, k);
|
||||||
|
}
|
||||||
|
),
|
||||||
|
g_data_bucket_cache.end()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Regular key deletion, no nesting involved
|
||||||
|
return DataBucketsRepository::DeleteWhere(
|
||||||
|
*database,
|
||||||
|
fmt::format("{} `key` = '{}'", DataBucket::GetScopedDbFilters(k), k.key)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
// If it's a nested key, retrieve the top-level JSON object
|
||||||
|
auto top_level_key = Strings::Split(k.key, NESTED_KEY_DELIMITER).front();
|
||||||
|
DataBucketKey top_level_k = k;
|
||||||
|
top_level_k.key = top_level_key;
|
||||||
|
|
||||||
|
auto r = GetData(database, top_level_k);
|
||||||
|
if (r.id == 0 || r.value.empty() || !Strings::IsValidJson(r.value)) {
|
||||||
|
LogDataBuckets("Attempted to delete nested key [{}] but parent key [{}] does not exist or is invalid JSON", k.key, top_level_key);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
json json_value;
|
||||||
|
try {
|
||||||
|
json_value = json::parse(r.value);
|
||||||
|
} catch (json::parse_error &ex) {
|
||||||
|
LogDataBuckets("Failed to parse JSON for key [{}] [{}]", top_level_key, ex.what());
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Recursively remove the nested key
|
||||||
|
auto nested_keys = Strings::Split(k.key, NESTED_KEY_DELIMITER);
|
||||||
|
auto top_key = nested_keys.front();
|
||||||
|
nested_keys.erase(nested_keys.begin());
|
||||||
|
json *current = &json_value;
|
||||||
|
|
||||||
|
for (size_t i = 0; i < nested_keys.size(); ++i) {
|
||||||
|
const std::string &key_part = nested_keys[i];
|
||||||
|
|
||||||
|
if (i == nested_keys.size() - 1) {
|
||||||
|
// Last key in the hierarchy - delete it
|
||||||
|
if (current->contains(key_part)) {
|
||||||
|
current->erase(key_part);
|
||||||
|
LogDataBuckets("Deleted nested key [{}] from [{}]", key_part, k.key);
|
||||||
|
} else {
|
||||||
|
LogDataBuckets("Key [{}] not found in JSON - nothing to delete", k.key);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (!current->contains(key_part) || !(*current)[key_part].is_object()) {
|
||||||
|
LogDataBuckets("Parent key [{}] does not exist or is not an object", key_part);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
current = &(*current)[key_part];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// If the JSON object is now empty, delete the top-level key
|
||||||
|
if (json_value.empty()) {
|
||||||
|
LogDataBuckets("Top-level key [{}] is now empty, deleting entire entry", top_level_key);
|
||||||
|
|
||||||
|
// delete cache
|
||||||
|
if (CanCache(k)) {
|
||||||
|
g_data_bucket_cache.erase(
|
||||||
|
std::remove_if(
|
||||||
|
g_data_bucket_cache.begin(),
|
||||||
|
g_data_bucket_cache.end(),
|
||||||
|
[&](DataBucketsRepository::DataBuckets &e) {
|
||||||
|
return CheckBucketMatch(e, top_level_k);
|
||||||
|
}
|
||||||
|
),
|
||||||
|
g_data_bucket_cache.end()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
return DataBucketsRepository::DeleteWhere(
|
||||||
|
*database,
|
||||||
|
fmt::format("{} `key` = '{}'", DataBucket::GetScopedDbFilters(k), top_level_key)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Otherwise, update the existing JSON without the deleted key
|
||||||
|
r.value = json_value.dump();
|
||||||
|
DataBucketsRepository::UpdateOne(*database, r);
|
||||||
|
|
||||||
|
// Update cache
|
||||||
|
if (CanCache(k)) {
|
||||||
|
for (auto &e : g_data_bucket_cache) {
|
||||||
|
if (CheckBucketMatch(e, top_level_k)) {
|
||||||
|
e.value = r.value;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string DataBucket::GetDataExpires(SharedDatabase* database, const DataBucketKey &k)
|
||||||
|
{
|
||||||
|
LogDataBuckets(
|
||||||
|
"Getting bucket expiration key [{}] bot_id [{}] account_id [{}] character_id [{}] npc_id [{}]",
|
||||||
|
k.key,
|
||||||
|
k.bot_id,
|
||||||
|
k.account_id,
|
||||||
|
k.character_id,
|
||||||
|
k.npc_id
|
||||||
|
);
|
||||||
|
|
||||||
|
auto r = GetData(database, k);
|
||||||
|
if (r.id == 0) {
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
|
||||||
|
return std::to_string(r.expires);
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string DataBucket::GetDataRemaining(SharedDatabase* database, const DataBucketKey &k)
|
||||||
|
{
|
||||||
|
LogDataBuckets(
|
||||||
|
"Getting bucket remaining key [{}] bot_id [{}] account_id [{}] character_id [{}] npc_id [{}] bot_id [{}] zone_id [{}] instance_id [{}]",
|
||||||
|
k.key,
|
||||||
|
k.bot_id,
|
||||||
|
k.account_id,
|
||||||
|
k.character_id,
|
||||||
|
k.npc_id,
|
||||||
|
k.bot_id,
|
||||||
|
k.zone_id,
|
||||||
|
k.instance_id
|
||||||
|
);
|
||||||
|
|
||||||
|
auto r = GetData(database, k);
|
||||||
|
if (r.id == 0) {
|
||||||
|
return "0";
|
||||||
|
}
|
||||||
|
|
||||||
|
return fmt::format("{}", r.expires - (long long) std::time(nullptr));
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string DataBucket::GetScopedDbFilters(const DataBucketKey &k)
|
||||||
|
{
|
||||||
|
std::vector<std::string> q = {};
|
||||||
|
if (k.character_id > 0) {
|
||||||
|
q.emplace_back(fmt::format("character_id = {}", k.character_id));
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
q.emplace_back("character_id = 0");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (k.account_id > 0) {
|
||||||
|
q.emplace_back(fmt::format("account_id = {}", k.account_id));
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
q.emplace_back("account_id = 0");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (k.npc_id > 0) {
|
||||||
|
q.emplace_back(fmt::format("npc_id = {}", k.npc_id));
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
q.emplace_back("npc_id = 0");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (k.bot_id > 0) {
|
||||||
|
q.emplace_back(fmt::format("bot_id = {}", k.bot_id));
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
q.emplace_back("bot_id = 0");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (k.zone_id > 0) {
|
||||||
|
q.emplace_back(fmt::format("zone_id = {} AND instance_id = {}", k.zone_id, k.instance_id));
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
q.emplace_back("zone_id = 0 AND instance_id = 0");
|
||||||
|
}
|
||||||
|
|
||||||
|
return fmt::format(
|
||||||
|
"{} {}",
|
||||||
|
Strings::Join(q, " AND "),
|
||||||
|
!q.empty() ? "AND" : ""
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool DataBucket::CheckBucketMatch(const DataBucketsRepository::DataBuckets &dbe, const DataBucketKey &k)
|
||||||
|
{
|
||||||
|
return (
|
||||||
|
dbe.key_ == k.key &&
|
||||||
|
dbe.bot_id == k.bot_id &&
|
||||||
|
dbe.account_id == k.account_id &&
|
||||||
|
dbe.character_id == k.character_id &&
|
||||||
|
dbe.npc_id == k.npc_id &&
|
||||||
|
dbe.zone_id == k.zone_id &&
|
||||||
|
dbe.instance_id == k.instance_id
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
void DataBucket::LoadZoneCache(SharedDatabase* database, uint16 zone_id, uint16 instance_id)
|
||||||
|
{
|
||||||
|
const auto &l = DataBucketsRepository::GetWhere(
|
||||||
|
*database,
|
||||||
|
fmt::format(
|
||||||
|
"zone_id = {} AND instance_id = {} AND (`expires` > {} OR `expires` = 0)",
|
||||||
|
zone_id,
|
||||||
|
instance_id,
|
||||||
|
(long long) std::time(nullptr)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
if (l.empty()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
LogDataBucketsDetail("cache size before [{}] l size [{}]", g_data_bucket_cache.size(), l.size());
|
||||||
|
|
||||||
|
uint32 added_count = 0;
|
||||||
|
|
||||||
|
for (const auto &e: l) {
|
||||||
|
if (!ExistsInCache(e)) {
|
||||||
|
added_count++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (const auto &e: l) {
|
||||||
|
if (!ExistsInCache(e)) {
|
||||||
|
LogDataBucketsDetail("bucket id [{}] bucket key [{}] bucket value [{}]", e.id, e.key_, e.value);
|
||||||
|
|
||||||
|
g_data_bucket_cache.emplace_back(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
LogDataBucketsDetail("cache size after [{}]", g_data_bucket_cache.size());
|
||||||
|
|
||||||
|
LogDataBuckets(
|
||||||
|
"Loaded [{}] zone keys new cache size is [{}]",
|
||||||
|
l.size(),
|
||||||
|
g_data_bucket_cache.size()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
void DataBucket::BulkLoadEntitiesToCache(SharedDatabase* database, DataBucketLoadType::Type t, std::vector<uint32> ids)
|
||||||
|
{
|
||||||
|
if (ids.empty()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ids.size() == 1) {
|
||||||
|
bool has_cache = false;
|
||||||
|
|
||||||
|
for (const auto &e: g_data_bucket_cache) {
|
||||||
|
if (t == DataBucketLoadType::Bot) {
|
||||||
|
has_cache = e.bot_id == ids[0];
|
||||||
|
}
|
||||||
|
else if (t == DataBucketLoadType::Account) {
|
||||||
|
has_cache = e.account_id == ids[0];
|
||||||
|
}
|
||||||
|
else if (t == DataBucketLoadType::Client) {
|
||||||
|
has_cache = e.character_id == ids[0];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (has_cache) {
|
||||||
|
LogDataBucketsDetail("LoadType [{}] ID [{}] has cache", DataBucketLoadType::Name[t], ids[0]);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string column;
|
||||||
|
|
||||||
|
switch (t) {
|
||||||
|
case DataBucketLoadType::Bot:
|
||||||
|
column = "bot_id";
|
||||||
|
break;
|
||||||
|
case DataBucketLoadType::Client:
|
||||||
|
column = "character_id";
|
||||||
|
break;
|
||||||
|
case DataBucketLoadType::Account:
|
||||||
|
column = "account_id";
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
LogError("Incorrect LoadType [{}]", static_cast<int>(t));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
const auto &l = DataBucketsRepository::GetWhere(
|
||||||
|
*database,
|
||||||
|
fmt::format(
|
||||||
|
"{} IN ({}) AND (`expires` > {} OR `expires` = 0)",
|
||||||
|
column,
|
||||||
|
Strings::Join(ids, ", "),
|
||||||
|
(long long) std::time(nullptr)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
if (l.empty()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
LogDataBucketsDetail("cache size before [{}] l size [{}]", g_data_bucket_cache.size(), l.size());
|
||||||
|
|
||||||
|
uint32 added_count = 0;
|
||||||
|
|
||||||
|
for (const auto &e: l) {
|
||||||
|
if (!ExistsInCache(e)) {
|
||||||
|
added_count++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (const auto &e: l) {
|
||||||
|
if (!ExistsInCache(e)) {
|
||||||
|
LogDataBucketsDetail("bucket id [{}] bucket key [{}] bucket value [{}]", e.id, e.key_, e.value);
|
||||||
|
|
||||||
|
g_data_bucket_cache.emplace_back(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
LogDataBucketsDetail("cache size after [{}]", g_data_bucket_cache.size());
|
||||||
|
|
||||||
|
LogDataBuckets(
|
||||||
|
"Bulk Loaded ids [{}] column [{}] new cache size is [{}]",
|
||||||
|
ids.size(),
|
||||||
|
column,
|
||||||
|
g_data_bucket_cache.size()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
void DataBucket::DeleteCachedBuckets(DataBucketLoadType::Type type, uint32 id, uint32 secondary_id)
|
||||||
|
{
|
||||||
|
size_t size_before = g_data_bucket_cache.size();
|
||||||
|
|
||||||
|
g_data_bucket_cache.erase(
|
||||||
|
std::remove_if(
|
||||||
|
g_data_bucket_cache.begin(),
|
||||||
|
g_data_bucket_cache.end(),
|
||||||
|
[&](DataBucketsRepository::DataBuckets &e) {
|
||||||
|
return (
|
||||||
|
(type == DataBucketLoadType::Bot && e.bot_id == id) ||
|
||||||
|
(type == DataBucketLoadType::Account && e.account_id == id) ||
|
||||||
|
(type == DataBucketLoadType::Client && e.character_id == id) ||
|
||||||
|
(type == DataBucketLoadType::Zone && e.zone_id == id && e.instance_id == secondary_id)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
),
|
||||||
|
g_data_bucket_cache.end()
|
||||||
|
);
|
||||||
|
|
||||||
|
LogDataBuckets(
|
||||||
|
"LoadType [{}] id [{}] cache size before [{}] after [{}]",
|
||||||
|
DataBucketLoadType::Name[type],
|
||||||
|
id,
|
||||||
|
size_before,
|
||||||
|
g_data_bucket_cache.size()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool DataBucket::ExistsInCache(const DataBucketsRepository::DataBuckets &entry)
|
||||||
|
{
|
||||||
|
for (const auto &e: g_data_bucket_cache) {
|
||||||
|
if (e.id == entry.id) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
void DataBucket::DeleteFromMissesCache(DataBucketsRepository::DataBuckets e)
|
||||||
|
{
|
||||||
|
// delete from cache where there might have been a written bucket miss to the cache
|
||||||
|
// this is to prevent the cache from growing too large
|
||||||
|
size_t size_before = g_data_bucket_cache.size();
|
||||||
|
|
||||||
|
g_data_bucket_cache.erase(
|
||||||
|
std::remove_if(
|
||||||
|
g_data_bucket_cache.begin(),
|
||||||
|
g_data_bucket_cache.end(),
|
||||||
|
[&](DataBucketsRepository::DataBuckets &ce) {
|
||||||
|
return ce.id == 0 && ce.key_ == e.key_ &&
|
||||||
|
ce.account_id == e.account_id &&
|
||||||
|
ce.character_id == e.character_id &&
|
||||||
|
ce.npc_id == e.npc_id &&
|
||||||
|
ce.bot_id == e.bot_id &&
|
||||||
|
ce.zone_id == e.zone_id &&
|
||||||
|
ce.instance_id == e.instance_id;
|
||||||
|
}
|
||||||
|
),
|
||||||
|
g_data_bucket_cache.end()
|
||||||
|
);
|
||||||
|
LogDataBucketsDetail(
|
||||||
|
"Deleted bucket misses from cache where key [{}] size before [{}] after [{}]",
|
||||||
|
e.key_,
|
||||||
|
size_before,
|
||||||
|
g_data_bucket_cache.size()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
void DataBucket::ClearCache()
|
||||||
|
{
|
||||||
|
g_data_bucket_cache.clear();
|
||||||
|
LogInfo("Cleared data buckets cache");
|
||||||
|
}
|
||||||
|
|
||||||
|
void DataBucket::DeleteFromCache(uint64 id, DataBucketLoadType::Type type)
|
||||||
|
{
|
||||||
|
size_t size_before = g_data_bucket_cache.size();
|
||||||
|
|
||||||
|
g_data_bucket_cache.erase(
|
||||||
|
std::remove_if(
|
||||||
|
g_data_bucket_cache.begin(),
|
||||||
|
g_data_bucket_cache.end(),
|
||||||
|
[&](DataBucketsRepository::DataBuckets &e) {
|
||||||
|
switch (type) {
|
||||||
|
case DataBucketLoadType::Bot:
|
||||||
|
return e.bot_id == id;
|
||||||
|
case DataBucketLoadType::Client:
|
||||||
|
return e.character_id == id;
|
||||||
|
case DataBucketLoadType::Account:
|
||||||
|
return e.account_id == id;
|
||||||
|
default:
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
),
|
||||||
|
g_data_bucket_cache.end()
|
||||||
|
);
|
||||||
|
|
||||||
|
LogDataBuckets(
|
||||||
|
"Deleted [{}] id [{}] from cache size before [{}] after [{}]",
|
||||||
|
DataBucketLoadType::Name[type],
|
||||||
|
id,
|
||||||
|
size_before,
|
||||||
|
g_data_bucket_cache.size()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
void DataBucket::DeleteZoneFromCache(uint16 zone_id, uint16 instance_id, DataBucketLoadType::Type type)
|
||||||
|
{
|
||||||
|
size_t size_before = g_data_bucket_cache.size();
|
||||||
|
|
||||||
|
g_data_bucket_cache.erase(
|
||||||
|
std::remove_if(
|
||||||
|
g_data_bucket_cache.begin(),
|
||||||
|
g_data_bucket_cache.end(),
|
||||||
|
[&](DataBucketsRepository::DataBuckets &e) {
|
||||||
|
switch (type) {
|
||||||
|
case DataBucketLoadType::Zone:
|
||||||
|
return e.zone_id == zone_id && e.instance_id == instance_id;
|
||||||
|
default:
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
),
|
||||||
|
g_data_bucket_cache.end()
|
||||||
|
);
|
||||||
|
|
||||||
|
LogDataBuckets(
|
||||||
|
"Deleted zone [{}] instance [{}] from cache size before [{}] after [{}]",
|
||||||
|
zone_id,
|
||||||
|
instance_id,
|
||||||
|
size_before,
|
||||||
|
g_data_bucket_cache.size()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
// CanCache returns whether a bucket can be cached or not
|
||||||
|
// characters are only in one zone at a time so we can cache locally to the zone
|
||||||
|
// bots (not implemented) are only in one zone at a time so we can cache locally to the zone
|
||||||
|
// npcs (ids) can be in multiple zones so we can't cache locally to the zone
|
||||||
|
bool DataBucket::CanCache(const DataBucketKey &key)
|
||||||
|
{
|
||||||
|
if (key.character_id > 0 || key.account_id > 0 || key.bot_id > 0 || key.zone_id > 0) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
@@ -0,0 +1,73 @@
|
|||||||
|
#ifndef EQEMU_DATABUCKET_H
|
||||||
|
#define EQEMU_DATABUCKET_H
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
#include "types.h"
|
||||||
|
#include "repositories/data_buckets_repository.h"
|
||||||
|
#include "json/json_archive_single_line.h"
|
||||||
|
#include "shareddb.h"
|
||||||
|
|
||||||
|
struct DataBucketKey {
|
||||||
|
std::string key;
|
||||||
|
std::string value;
|
||||||
|
std::string expires;
|
||||||
|
uint64_t account_id = 0;
|
||||||
|
uint64_t character_id = 0;
|
||||||
|
uint32_t npc_id = 0;
|
||||||
|
uint32_t bot_id = 0;
|
||||||
|
uint16_t zone_id = 0;
|
||||||
|
uint16_t instance_id = 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
namespace DataBucketLoadType {
|
||||||
|
enum Type : uint8 {
|
||||||
|
Bot,
|
||||||
|
Account,
|
||||||
|
Client,
|
||||||
|
Zone,
|
||||||
|
MaxType
|
||||||
|
};
|
||||||
|
|
||||||
|
static const std::string Name[Type::MaxType] = {
|
||||||
|
"Bot",
|
||||||
|
"Account",
|
||||||
|
"Client",
|
||||||
|
"Zone"
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
class DataBucket {
|
||||||
|
public:
|
||||||
|
// non-scoped bucket methods (for global buckets)
|
||||||
|
static void SetData(SharedDatabase *database, const std::string &bucket_key, const std::string &bucket_value, std::string expires_time = "");
|
||||||
|
static bool DeleteData(SharedDatabase *database, const std::string &bucket_key);
|
||||||
|
static std::string GetData(SharedDatabase *database, const std::string &bucket_key);
|
||||||
|
static std::string GetDataExpires(SharedDatabase *database, const std::string &bucket_key);
|
||||||
|
static std::string GetDataRemaining(SharedDatabase *database, const std::string &bucket_key);
|
||||||
|
|
||||||
|
// scoped bucket methods
|
||||||
|
static void SetData(SharedDatabase *database, const DataBucketKey &k_);
|
||||||
|
static bool DeleteData(SharedDatabase *database, const DataBucketKey &k);
|
||||||
|
static DataBucketsRepository::DataBuckets GetData(SharedDatabase *database, const DataBucketKey &k_, bool ignore_misses_cache = false);
|
||||||
|
static std::string GetDataExpires(SharedDatabase *database, const DataBucketKey &k);
|
||||||
|
static std::string GetDataRemaining(SharedDatabase *database, const DataBucketKey &k);
|
||||||
|
static std::string GetScopedDbFilters(const DataBucketKey &k);
|
||||||
|
|
||||||
|
// bucket repository versus key matching
|
||||||
|
static bool CheckBucketMatch(const DataBucketsRepository::DataBuckets &dbe, const DataBucketKey &k);
|
||||||
|
static bool ExistsInCache(const DataBucketsRepository::DataBuckets &entry);
|
||||||
|
|
||||||
|
static void LoadZoneCache(SharedDatabase* database, uint16 zone_id, uint16 instance_id);
|
||||||
|
static void BulkLoadEntitiesToCache(SharedDatabase* database, DataBucketLoadType::Type t, std::vector<uint32> ids);
|
||||||
|
static void DeleteCachedBuckets(DataBucketLoadType::Type type, uint32 id, uint32 secondary_id = 0);
|
||||||
|
|
||||||
|
static void DeleteFromMissesCache(DataBucketsRepository::DataBuckets e);
|
||||||
|
static void ClearCache();
|
||||||
|
static void DeleteFromCache(uint64 id, DataBucketLoadType::Type type);
|
||||||
|
static void DeleteZoneFromCache(uint16 zone_id, uint16 instance_id, DataBucketLoadType::Type type);
|
||||||
|
static bool CanCache(const DataBucketKey &key);
|
||||||
|
static DataBucketsRepository::DataBuckets
|
||||||
|
ExtractNestedValue(const DataBucketsRepository::DataBuckets &bucket, const std::string &full_key);
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif //EQEMU_DATABUCKET_H
|
||||||
+176
-20
@@ -50,6 +50,7 @@
|
|||||||
#include "../common/repositories/raid_members_repository.h"
|
#include "../common/repositories/raid_members_repository.h"
|
||||||
#include "../common/repositories/reports_repository.h"
|
#include "../common/repositories/reports_repository.h"
|
||||||
#include "../common/repositories/variables_repository.h"
|
#include "../common/repositories/variables_repository.h"
|
||||||
|
#include "../common/repositories/character_pet_name_repository.h"
|
||||||
#include "../common/events/player_event_logs.h"
|
#include "../common/events/player_event_logs.h"
|
||||||
|
|
||||||
// Disgrace: for windows compile
|
// Disgrace: for windows compile
|
||||||
@@ -244,7 +245,7 @@ uint32 Database::CreateAccount(
|
|||||||
e.password = password;
|
e.password = password;
|
||||||
}
|
}
|
||||||
|
|
||||||
LogInfo("Account Attempting to be created: [{}:{}] status: {}", loginserver, name, status);
|
LogInfo("Account attempting to be created loginserver [{}] name [{}] status [{}]", loginserver, name, status);
|
||||||
|
|
||||||
e = AccountRepository::InsertOne(*this, e);
|
e = AccountRepository::InsertOne(*this, e);
|
||||||
|
|
||||||
@@ -285,16 +286,37 @@ bool Database::SetAccountStatus(const std::string& account_name, int16 status)
|
|||||||
|
|
||||||
bool Database::ReserveName(uint32 account_id, const std::string& name)
|
bool Database::ReserveName(uint32 account_id, const std::string& name)
|
||||||
{
|
{
|
||||||
const auto& l = CharacterDataRepository::GetWhere(
|
const std::string& where_filter = fmt::format(
|
||||||
*this,
|
|
||||||
fmt::format(
|
|
||||||
"`name` = '{}'",
|
"`name` = '{}'",
|
||||||
Strings::Escape(name)
|
Strings::Escape(name)
|
||||||
)
|
|
||||||
);
|
);
|
||||||
|
|
||||||
if (!l.empty()) {
|
if (RuleB(Bots, Enabled)) {
|
||||||
LogInfo("Account: [{}] tried to request name: [{}], but it is already taken", account_id, name);
|
const auto& b = BotDataRepository::GetWhere(*this, where_filter);
|
||||||
|
|
||||||
|
if (!b.empty()) {
|
||||||
|
LogInfo("Account [{}] requested name [{}] but name is already taken by a bot", account_id, name);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const auto& c = CharacterDataRepository::GetWhere(*this, where_filter);
|
||||||
|
|
||||||
|
if (!c.empty()) {
|
||||||
|
LogInfo("Account [{}] requested name [{}] but name is already taken by a character", account_id, name);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
const auto& n = NpcTypesRepository::GetWhere(*this, where_filter);
|
||||||
|
|
||||||
|
if (!n.empty()) {
|
||||||
|
LogInfo("Account [{}] requested name [{}] but name is already taken by an NPC", account_id, name);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
const auto& p = CharacterPetNameRepository::GetWhere(*this, where_filter);
|
||||||
|
if (!p.empty()) {
|
||||||
|
LogInfo("Account [{}] requested name [{}] but name is already taken by an Pet", account_id, name);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -686,6 +708,20 @@ const std::string Database::GetNPCNameByID(uint32 npc_id)
|
|||||||
return e.id ? e.name : std::string();
|
return e.id ? e.name : std::string();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template<typename InputIterator, typename OutputIterator>
|
||||||
|
inline auto CleanMobName(InputIterator first, InputIterator last, OutputIterator result)
|
||||||
|
{
|
||||||
|
for (; first != last; ++first) {
|
||||||
|
if (*first == '_') {
|
||||||
|
*result = ' ';
|
||||||
|
}
|
||||||
|
else if (isalpha(*first) || *first == '`') {
|
||||||
|
*result = *first;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
const std::string Database::GetCleanNPCNameByID(uint32 npc_id)
|
const std::string Database::GetCleanNPCNameByID(uint32 npc_id)
|
||||||
{
|
{
|
||||||
const auto& e = NpcTypesRepository::FindOne(*this, npc_id);
|
const auto& e = NpcTypesRepository::FindOne(*this, npc_id);
|
||||||
@@ -933,6 +969,29 @@ bool Database::UpdateName(const std::string& old_name, const std::string& new_na
|
|||||||
return CharacterDataRepository::UpdateOne(*this, e);
|
return CharacterDataRepository::UpdateOne(*this, e);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool Database::UpdateNameByID(const int character_id, const std::string& new_name)
|
||||||
|
{
|
||||||
|
LogInfo("Renaming [{}] to [{}]", character_id, new_name);
|
||||||
|
|
||||||
|
auto l = CharacterDataRepository::GetWhere(
|
||||||
|
*this,
|
||||||
|
fmt::format(
|
||||||
|
"`id` = {}",
|
||||||
|
character_id
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
if (l.empty()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto& e = l.front();
|
||||||
|
|
||||||
|
e.name = new_name;
|
||||||
|
|
||||||
|
return CharacterDataRepository::UpdateOne(*this, e);
|
||||||
|
}
|
||||||
|
|
||||||
bool Database::IsNameUsed(const std::string& name)
|
bool Database::IsNameUsed(const std::string& name)
|
||||||
{
|
{
|
||||||
if (RuleB(Bots, Enabled)) {
|
if (RuleB(Bots, Enabled)) {
|
||||||
@@ -960,6 +1019,20 @@ bool Database::IsNameUsed(const std::string& name)
|
|||||||
return !character_data.empty();
|
return !character_data.empty();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Players cannot have the same name as a pet vanity name, or memory corruption occurs.
|
||||||
|
bool Database::IsPetNameUsed(const std::string& name)
|
||||||
|
{
|
||||||
|
const auto& pet_name_data = CharacterPetNameRepository::GetWhere(
|
||||||
|
*this,
|
||||||
|
fmt::format(
|
||||||
|
"`name` = '{}'",
|
||||||
|
Strings::Escape(name)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return !pet_name_data.empty();
|
||||||
|
}
|
||||||
|
|
||||||
uint32 Database::GetServerType()
|
uint32 Database::GetServerType()
|
||||||
{
|
{
|
||||||
const auto& l = VariablesRepository::GetWhere(*this, "`varname` = 'ServerType' LIMIT 1");
|
const auto& l = VariablesRepository::GetWhere(*this, "`varname` = 'ServerType' LIMIT 1");
|
||||||
@@ -1036,11 +1109,11 @@ void Database::SetLFP(uint32 character_id, bool is_lfp)
|
|||||||
CharacterDataRepository::UpdateOne(*this, e);
|
CharacterDataRepository::UpdateOne(*this, e);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Database::SetLoginFlags(uint32 character_id, bool is_lfp, bool is_lfg, uint8 first_logon)
|
void Database::SetLoginFlags(uint32 character_id, bool is_lfp, bool is_lfg, uint8 ingame)
|
||||||
{
|
{
|
||||||
auto e = CharacterDataRepository::FindOne(*this, character_id);
|
auto e = CharacterDataRepository::FindOne(*this, character_id);
|
||||||
|
|
||||||
e.firstlogon = first_logon;
|
e.ingame = ingame;
|
||||||
e.lfg = is_lfg ? 1 : 0;
|
e.lfg = is_lfg ? 1 : 0;
|
||||||
e.lfp = is_lfp ? 1 : 0;
|
e.lfp = is_lfp ? 1 : 0;
|
||||||
|
|
||||||
@@ -1056,11 +1129,11 @@ void Database::SetLFG(uint32 character_id, bool is_lfg)
|
|||||||
CharacterDataRepository::UpdateOne(*this, e);
|
CharacterDataRepository::UpdateOne(*this, e);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Database::SetFirstLogon(uint32 character_id, uint8 first_logon)
|
void Database::SetIngame(uint32 character_id, uint8 ingame)
|
||||||
{
|
{
|
||||||
auto e = CharacterDataRepository::FindOne(*this, character_id);
|
auto e = CharacterDataRepository::FindOne(*this, character_id);
|
||||||
|
|
||||||
e.firstlogon = first_logon;
|
e.ingame = ingame;
|
||||||
|
|
||||||
CharacterDataRepository::UpdateOne(*this, e);
|
CharacterDataRepository::UpdateOne(*this, e);
|
||||||
}
|
}
|
||||||
@@ -1845,7 +1918,36 @@ bool Database::CopyCharacter(
|
|||||||
|
|
||||||
const int64 new_character_id = (CharacterDataRepository::GetMaxId(*this) + 1);
|
const int64 new_character_id = (CharacterDataRepository::GetMaxId(*this) + 1);
|
||||||
|
|
||||||
std::vector<std::string> tables_to_zero_id = { "keyring", "data_buckets" };
|
// validate destination name doesn't exist already
|
||||||
|
const auto& destination_characters = CharacterDataRepository::GetWhere(
|
||||||
|
*this,
|
||||||
|
fmt::format(
|
||||||
|
"`name` = '{}' AND `deleted_at` IS NULL LIMIT 1",
|
||||||
|
Strings::Escape(destination_character_name)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
if (!destination_characters.empty()) {
|
||||||
|
LogError("Character [{}] already exists", destination_character_name);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::vector<std::string> tables_to_zero_id = {
|
||||||
|
"keyring",
|
||||||
|
"data_buckets",
|
||||||
|
"character_evolving_items",
|
||||||
|
"character_instance_safereturns",
|
||||||
|
"character_expedition_lockouts",
|
||||||
|
"character_instance_lockouts",
|
||||||
|
"character_parcels",
|
||||||
|
"character_tribute",
|
||||||
|
"player_titlesets",
|
||||||
|
};
|
||||||
|
|
||||||
|
std::vector<std::string> ignore_tables = {
|
||||||
|
"guilds",
|
||||||
|
};
|
||||||
|
|
||||||
|
size_t total_rows_copied = 0;
|
||||||
|
|
||||||
TransactionBegin();
|
TransactionBegin();
|
||||||
|
|
||||||
@@ -1853,6 +1955,10 @@ bool Database::CopyCharacter(
|
|||||||
const std::string& table_name = t.first;
|
const std::string& table_name = t.first;
|
||||||
const std::string& character_id_column_name = t.second;
|
const std::string& character_id_column_name = t.second;
|
||||||
|
|
||||||
|
if (Strings::Contains(ignore_tables, table_name)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
auto results = QueryDatabase(
|
auto results = QueryDatabase(
|
||||||
fmt::format(
|
fmt::format(
|
||||||
"SHOW COLUMNS FROM {}",
|
"SHOW COLUMNS FROM {}",
|
||||||
@@ -1860,6 +1966,12 @@ bool Database::CopyCharacter(
|
|||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
if (!results.Success()) {
|
||||||
|
LogError("Transaction failed [{}] rolling back", results.ErrorMessage());
|
||||||
|
TransactionRollback();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
std::vector<std::string> columns = {};
|
std::vector<std::string> columns = {};
|
||||||
int column_count = 0;
|
int column_count = 0;
|
||||||
|
|
||||||
@@ -1878,6 +1990,12 @@ bool Database::CopyCharacter(
|
|||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
if (!results.Success()) {
|
||||||
|
LogError("Transaction failed [{}] rolling back", results.ErrorMessage());
|
||||||
|
TransactionRollback();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
std::vector<std::vector<std::string>> new_rows;
|
std::vector<std::vector<std::string>> new_rows;
|
||||||
|
|
||||||
for (auto row : results) {
|
for (auto row : results) {
|
||||||
@@ -1903,6 +2021,10 @@ bool Database::CopyCharacter(
|
|||||||
value = std::to_string(destination_account_id);
|
value = std::to_string(destination_account_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!Strings::IsNumber(value)) {
|
||||||
|
value = Strings::Escape(value);
|
||||||
|
}
|
||||||
|
|
||||||
new_values.emplace_back(value);
|
new_values.emplace_back(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1935,14 +2057,31 @@ bool Database::CopyCharacter(
|
|||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
size_t rows_copied = insert_rows.size(); // Rows copied for this table
|
||||||
|
total_rows_copied += rows_copied; // Increment grand total
|
||||||
|
|
||||||
|
LogInfo("Copying table [{}] rows [{}]", table_name, Strings::Commify(rows_copied));
|
||||||
|
|
||||||
if (!insert.ErrorMessage().empty()) {
|
if (!insert.ErrorMessage().empty()) {
|
||||||
|
LogError("Error copying table [{}] [{}]", table_name, insert.ErrorMessage());
|
||||||
TransactionRollback();
|
TransactionRollback();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
TransactionCommit();
|
auto r = TransactionCommit();
|
||||||
|
if (!r.Success()) {
|
||||||
|
LogError("Transaction failed [{}] rolling back", r.ErrorMessage());
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
LogInfo(
|
||||||
|
"Character [{}] copied to [{}] total rows [{}]",
|
||||||
|
source_character_name,
|
||||||
|
destination_character_name,
|
||||||
|
Strings::Commify(total_rows_copied)
|
||||||
|
);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -2087,12 +2226,12 @@ void Database::PurgeCharacterParcels()
|
|||||||
for (auto const &r: results) {
|
for (auto const &r: results) {
|
||||||
pd.from_name = r.from_name;
|
pd.from_name = r.from_name;
|
||||||
pd.item_id = r.item_id;
|
pd.item_id = r.item_id;
|
||||||
pd.aug_slot_1 = r.aug_slot_1;
|
pd.augment_1_id = r.aug_slot_1;
|
||||||
pd.aug_slot_2 = r.aug_slot_2;
|
pd.augment_2_id = r.aug_slot_2;
|
||||||
pd.aug_slot_3 = r.aug_slot_3;
|
pd.augment_3_id = r.aug_slot_3;
|
||||||
pd.aug_slot_4 = r.aug_slot_4;
|
pd.augment_4_id = r.aug_slot_4;
|
||||||
pd.aug_slot_5 = r.aug_slot_5;
|
pd.augment_5_id = r.aug_slot_5;
|
||||||
pd.aug_slot_6 = r.aug_slot_6;
|
pd.augment_6_id = r.aug_slot_6;
|
||||||
pd.note = r.note;
|
pd.note = r.note;
|
||||||
pd.quantity = r.quantity;
|
pd.quantity = r.quantity;
|
||||||
pd.sent_date = r.sent_date;
|
pd.sent_date = r.sent_date;
|
||||||
@@ -2105,7 +2244,7 @@ void Database::PurgeCharacterParcels()
|
|||||||
pel.event_data = ss.str();
|
pel.event_data = ss.str();
|
||||||
pel.created_at = std::time(nullptr);
|
pel.created_at = std::time(nullptr);
|
||||||
|
|
||||||
player_event_logs.AddToQueue(pel);
|
PlayerEventLogs::Instance()->AddToQueue(pel);
|
||||||
|
|
||||||
ss.str("");
|
ss.str("");
|
||||||
ss.clear();
|
ss.clear();
|
||||||
@@ -2132,3 +2271,20 @@ void Database::ClearBuyerDetails()
|
|||||||
{
|
{
|
||||||
BuyerRepository::DeleteBuyer(*this, 0);
|
BuyerRepository::DeleteBuyer(*this, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uint64_t Database::GetNextTableId(const std::string &table_name)
|
||||||
|
{
|
||||||
|
auto results = QueryDatabase(fmt::format("SHOW TABLE STATUS LIKE '{}'", table_name));
|
||||||
|
|
||||||
|
for (auto row: results) {
|
||||||
|
for (int row_index = 0; row_index < results.ColumnCount(); row_index++) {
|
||||||
|
std::string field_name = Strings::ToLower(results.FieldName(row_index));
|
||||||
|
if (field_name == "auto_increment") {
|
||||||
|
std::string value = row[row_index] ? row[row_index] : "null";
|
||||||
|
return Strings::ToUnsignedBigInt(value, 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|||||||
+6
-1
@@ -103,6 +103,7 @@ public:
|
|||||||
bool ReserveName(uint32 account_id, const std::string& name);
|
bool ReserveName(uint32 account_id, const std::string& name);
|
||||||
bool SaveCharacterCreate(uint32 character_id, uint32 account_id, PlayerProfile_Struct* pp);
|
bool SaveCharacterCreate(uint32 character_id, uint32 account_id, PlayerProfile_Struct* pp);
|
||||||
bool UpdateName(const std::string& old_name, const std::string& new_name);
|
bool UpdateName(const std::string& old_name, const std::string& new_name);
|
||||||
|
bool UpdateNameByID(const int character_id, const std::string& new_name);
|
||||||
bool CopyCharacter(
|
bool CopyCharacter(
|
||||||
const std::string& source_character_name,
|
const std::string& source_character_name,
|
||||||
const std::string& destination_character_name,
|
const std::string& destination_character_name,
|
||||||
@@ -116,6 +117,7 @@ public:
|
|||||||
bool CheckGMIPs(const std::string& login_ip, uint32 account_id);
|
bool CheckGMIPs(const std::string& login_ip, uint32 account_id);
|
||||||
bool CheckNameFilter(const std::string& name, bool surname = false);
|
bool CheckNameFilter(const std::string& name, bool surname = false);
|
||||||
bool IsNameUsed(const std::string& name);
|
bool IsNameUsed(const std::string& name);
|
||||||
|
bool IsPetNameUsed(const std::string& name);
|
||||||
|
|
||||||
uint32 GetAccountIDByChar(const std::string& name, uint32* character_id = 0);
|
uint32 GetAccountIDByChar(const std::string& name, uint32* character_id = 0);
|
||||||
uint32 GetAccountIDByChar(uint32 character_id);
|
uint32 GetAccountIDByChar(uint32 character_id);
|
||||||
@@ -139,6 +141,7 @@ public:
|
|||||||
bool CheckInstanceExpired(uint16 instance_id);
|
bool CheckInstanceExpired(uint16 instance_id);
|
||||||
bool CreateInstance(uint16 instance_id, uint32 zone_id, uint32 version, uint32 duration);
|
bool CreateInstance(uint16 instance_id, uint32 zone_id, uint32 version, uint32 duration);
|
||||||
bool GetUnusedInstanceID(uint16& instance_id);
|
bool GetUnusedInstanceID(uint16& instance_id);
|
||||||
|
bool TryGetUnusedInstanceID(uint16& instance_id);
|
||||||
bool IsGlobalInstance(uint16 instance_id);
|
bool IsGlobalInstance(uint16 instance_id);
|
||||||
bool RemoveClientFromInstance(uint16 instance_id, uint32 char_id);
|
bool RemoveClientFromInstance(uint16 instance_id, uint32 char_id);
|
||||||
bool RemoveClientsFromInstance(uint16 instance_id);
|
bool RemoveClientsFromInstance(uint16 instance_id);
|
||||||
@@ -260,7 +263,7 @@ public:
|
|||||||
bool SaveTime(int8 minute, int8 hour, int8 day, int8 month, int16 year);
|
bool SaveTime(int8 minute, int8 hour, int8 day, int8 month, int16 year);
|
||||||
void ClearMerchantTemp();
|
void ClearMerchantTemp();
|
||||||
void ClearPTimers(uint32 character_id);
|
void ClearPTimers(uint32 character_id);
|
||||||
void SetFirstLogon(uint32 character_id, uint8 first_logon);
|
void SetIngame(uint32 character_id, uint8 ingame);
|
||||||
void SetLFG(uint32 character_id, bool is_lfg);
|
void SetLFG(uint32 character_id, bool is_lfg);
|
||||||
void SetLFP(uint32 character_id, bool is_lfp);
|
void SetLFP(uint32 character_id, bool is_lfp);
|
||||||
void SetLoginFlags(uint32 character_id, bool is_lfp, bool is_lfg, uint8 first_logon);
|
void SetLoginFlags(uint32 character_id, bool is_lfp, bool is_lfg, uint8 first_logon);
|
||||||
@@ -274,6 +277,8 @@ public:
|
|||||||
void Encode(std::string &in);
|
void Encode(std::string &in);
|
||||||
void Decode(std::string &in);
|
void Decode(std::string &in);
|
||||||
|
|
||||||
|
uint64_t GetNextTableId(const std::string& table_name);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Mutex Mvarcache;
|
Mutex Mvarcache;
|
||||||
VarCache_Struct varcache;
|
VarCache_Struct varcache;
|
||||||
|
|||||||
@@ -50,7 +50,7 @@ bool DatabaseDumpService::IsMySQLInstalled()
|
|||||||
{
|
{
|
||||||
std::string version_output = GetMySQLVersion();
|
std::string version_output = GetMySQLVersion();
|
||||||
|
|
||||||
return version_output.find("mysql") != std::string::npos && version_output.find("Ver") != std::string::npos;
|
return version_output.find("mysql") != std::string::npos && (version_output.find("Ver") != std::string::npos || version_output.find("from") != std::string::npos);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -136,11 +136,6 @@ std::string DatabaseDumpService::GetLoginTableList()
|
|||||||
return Strings::Join(DatabaseSchema::GetLoginTables(), " ");
|
return Strings::Join(DatabaseSchema::GetLoginTables(), " ");
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string DatabaseDumpService::GetQueryServTables()
|
|
||||||
{
|
|
||||||
return Strings::Join(DatabaseSchema::GetQueryServerTables(), " ");
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string DatabaseDumpService::GetSystemTablesList()
|
std::string DatabaseDumpService::GetSystemTablesList()
|
||||||
{
|
{
|
||||||
auto system_tables = DatabaseSchema::GetServerTables();
|
auto system_tables = DatabaseSchema::GetServerTables();
|
||||||
@@ -209,7 +204,7 @@ void DatabaseDumpService::DatabaseDump()
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (IsDumpOutputToConsole()) {
|
if (IsDumpOutputToConsole()) {
|
||||||
LogSys.SilenceConsoleLogging();
|
EQEmuLogSys::Instance()->SilenceConsoleLogging();
|
||||||
}
|
}
|
||||||
|
|
||||||
LogInfo("MySQL installed [{}]", GetMySQLVersion());
|
LogInfo("MySQL installed [{}]", GetMySQLVersion());
|
||||||
@@ -272,11 +267,6 @@ void DatabaseDumpService::DatabaseDump()
|
|||||||
tables_to_dump += GetLoginTableList() + " ";
|
tables_to_dump += GetLoginTableList() + " ";
|
||||||
dump_descriptor += "-login";
|
dump_descriptor += "-login";
|
||||||
}
|
}
|
||||||
|
|
||||||
if (IsDumpQueryServerTables()) {
|
|
||||||
tables_to_dump += GetQueryServTables();
|
|
||||||
dump_descriptor += "-queryserv";
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (IsDumpStaticInstanceData()) {
|
if (IsDumpStaticInstanceData()) {
|
||||||
@@ -334,7 +324,7 @@ void DatabaseDumpService::DatabaseDump()
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!IsDumpOutputToConsole()) {
|
if (!IsDumpOutputToConsole()) {
|
||||||
LogSys.LoadLogSettingsDefaults();
|
EQEmuLogSys::Instance()->LoadLogSettingsDefaults();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!pipe_file.empty()) {
|
if (!pipe_file.empty()) {
|
||||||
@@ -401,7 +391,6 @@ void DatabaseDumpService::DatabaseDump()
|
|||||||
// LogDebug("[{}] dump-to-console", IsDumpOutputToConsole());
|
// LogDebug("[{}] dump-to-console", IsDumpOutputToConsole());
|
||||||
// LogDebug("[{}] dump-path", GetSetDumpPath());
|
// LogDebug("[{}] dump-path", GetSetDumpPath());
|
||||||
// LogDebug("[{}] compression", (IsDumpWithCompression() ? "true" : "false"));
|
// LogDebug("[{}] compression", (IsDumpWithCompression() ? "true" : "false"));
|
||||||
// LogDebug("[{}] query-serv", (IsDumpQueryServerTables() ? "true" : "false"));
|
|
||||||
// LogDebug("[{}] has-compression-binary", (HasCompressionBinary() ? "true" : "false"));
|
// LogDebug("[{}] has-compression-binary", (HasCompressionBinary() ? "true" : "false"));
|
||||||
// LogDebug("[{}] content", (IsDumpContentTables() ? "true" : "false"));
|
// LogDebug("[{}] content", (IsDumpContentTables() ? "true" : "false"));
|
||||||
// LogDebug("[{}] no-data", (IsDumpWithNoData() ? "true" : "false"));
|
// LogDebug("[{}] no-data", (IsDumpWithNoData() ? "true" : "false"));
|
||||||
@@ -511,16 +500,6 @@ const std::string &DatabaseDumpService::GetDumpFileName() const
|
|||||||
return dump_file_name;
|
return dump_file_name;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool DatabaseDumpService::IsDumpQueryServerTables() const
|
|
||||||
{
|
|
||||||
return dump_query_server_tables;
|
|
||||||
}
|
|
||||||
|
|
||||||
void DatabaseDumpService::SetDumpQueryServerTables(bool dump_query_server_tables)
|
|
||||||
{
|
|
||||||
DatabaseDumpService::dump_query_server_tables = dump_query_server_tables;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool DatabaseDumpService::IsDumpOutputToConsole() const
|
bool DatabaseDumpService::IsDumpOutputToConsole() const
|
||||||
{
|
{
|
||||||
return dump_output_to_console;
|
return dump_output_to_console;
|
||||||
@@ -617,8 +596,13 @@ void DatabaseDumpService::BuildCredentialsFile()
|
|||||||
void DatabaseDumpService::RemoveCredentialsFile()
|
void DatabaseDumpService::RemoveCredentialsFile()
|
||||||
{
|
{
|
||||||
if (File::Exists(CREDENTIALS_FILE)) {
|
if (File::Exists(CREDENTIALS_FILE)) {
|
||||||
|
try {
|
||||||
std::filesystem::remove(CREDENTIALS_FILE);
|
std::filesystem::remove(CREDENTIALS_FILE);
|
||||||
}
|
}
|
||||||
|
catch (std::exception &e) {
|
||||||
|
LogError("std::filesystem::remove err [{}]", e.what());
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool DatabaseDumpService::IsDumpStaticInstanceData()
|
bool DatabaseDumpService::IsDumpStaticInstanceData()
|
||||||
|
|||||||
@@ -45,8 +45,6 @@ public:
|
|||||||
void SetDumpPath(const std::string &dump_path);
|
void SetDumpPath(const std::string &dump_path);
|
||||||
const std::string &GetDumpFileName() const;
|
const std::string &GetDumpFileName() const;
|
||||||
void SetDumpFileName(const std::string &dump_file_name);
|
void SetDumpFileName(const std::string &dump_file_name);
|
||||||
bool IsDumpQueryServerTables() const;
|
|
||||||
void SetDumpQueryServerTables(bool dump_query_server_tables);
|
|
||||||
bool IsDumpOutputToConsole() const;
|
bool IsDumpOutputToConsole() const;
|
||||||
void SetDumpOutputToConsole(bool dump_output_to_console);
|
void SetDumpOutputToConsole(bool dump_output_to_console);
|
||||||
bool IsDumpDropTableSyntaxOnly() const;
|
bool IsDumpDropTableSyntaxOnly() const;
|
||||||
@@ -67,7 +65,6 @@ private:
|
|||||||
bool dump_system_tables = false;
|
bool dump_system_tables = false;
|
||||||
bool dump_content_tables = false;
|
bool dump_content_tables = false;
|
||||||
bool dump_player_tables = false;
|
bool dump_player_tables = false;
|
||||||
bool dump_query_server_tables = false;
|
|
||||||
bool dump_login_server_tables = false;
|
bool dump_login_server_tables = false;
|
||||||
bool dump_with_no_data = false;
|
bool dump_with_no_data = false;
|
||||||
bool dump_table_lock = false;
|
bool dump_table_lock = false;
|
||||||
@@ -96,7 +93,6 @@ private:
|
|||||||
bool HasCompressionBinary();
|
bool HasCompressionBinary();
|
||||||
std::string GetDumpFileNameWithPath();
|
std::string GetDumpFileNameWithPath();
|
||||||
std::string GetSetDumpPath();
|
std::string GetSetDumpPath();
|
||||||
std::string GetQueryServTables();
|
|
||||||
void RemoveSqlBackup();
|
void RemoveSqlBackup();
|
||||||
void BuildCredentialsFile();
|
void BuildCredentialsFile();
|
||||||
void RemoveCredentialsFile();
|
void RemoveCredentialsFile();
|
||||||
|
|||||||
@@ -5,16 +5,16 @@
|
|||||||
#include "../strings.h"
|
#include "../strings.h"
|
||||||
#include "../rulesys.h"
|
#include "../rulesys.h"
|
||||||
#include "../http/httplib.h"
|
#include "../http/httplib.h"
|
||||||
|
|
||||||
#include "database_update_manifest.cpp"
|
|
||||||
#include "database_update_manifest_bots.cpp"
|
|
||||||
#include "database_dump_service.h"
|
#include "database_dump_service.h"
|
||||||
|
#include "database_update_manifest.h"
|
||||||
|
#include "database_update_manifest_custom.h"
|
||||||
|
#include "database_update_manifest_bots.h"
|
||||||
|
|
||||||
constexpr int BREAK_LENGTH = 70;
|
constexpr int BREAK_LENGTH = 70;
|
||||||
|
|
||||||
DatabaseVersion DatabaseUpdate::GetDatabaseVersions()
|
DatabaseVersion DatabaseUpdate::GetDatabaseVersions()
|
||||||
{
|
{
|
||||||
auto results = m_database->QueryDatabase("SELECT `version`, `bots_version` FROM `db_version` LIMIT 1");
|
auto results = m_database->QueryDatabase("SELECT `version`, `bots_version`, `custom_version` FROM `db_version` LIMIT 1");
|
||||||
if (!results.Success() || !results.RowCount()) {
|
if (!results.Success() || !results.RowCount()) {
|
||||||
LogError("Failed to read from [db_version] table!");
|
LogError("Failed to read from [db_version] table!");
|
||||||
return DatabaseVersion{};
|
return DatabaseVersion{};
|
||||||
@@ -25,6 +25,7 @@ DatabaseVersion DatabaseUpdate::GetDatabaseVersions()
|
|||||||
return DatabaseVersion{
|
return DatabaseVersion{
|
||||||
.server_database_version = Strings::ToInt(r[0]),
|
.server_database_version = Strings::ToInt(r[0]),
|
||||||
.bots_database_version = Strings::ToInt(r[1]),
|
.bots_database_version = Strings::ToInt(r[1]),
|
||||||
|
.custom_database_version = Strings::ToInt(r[2]),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -33,6 +34,7 @@ DatabaseVersion DatabaseUpdate::GetBinaryDatabaseVersions()
|
|||||||
return DatabaseVersion{
|
return DatabaseVersion{
|
||||||
.server_database_version = CURRENT_BINARY_DATABASE_VERSION,
|
.server_database_version = CURRENT_BINARY_DATABASE_VERSION,
|
||||||
.bots_database_version = (RuleB(Bots, Enabled) ? CURRENT_BINARY_BOTS_DATABASE_VERSION : 0),
|
.bots_database_version = (RuleB(Bots, Enabled) ? CURRENT_BINARY_BOTS_DATABASE_VERSION : 0),
|
||||||
|
.custom_database_version = CUSTOM_BINARY_DATABASE_VERSION,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -43,6 +45,7 @@ constexpr int LOOK_BACK_AMOUNT = 10;
|
|||||||
// this check will take action
|
// this check will take action
|
||||||
void DatabaseUpdate::CheckDbUpdates()
|
void DatabaseUpdate::CheckDbUpdates()
|
||||||
{
|
{
|
||||||
|
InjectCustomVersionColumn();
|
||||||
InjectBotsVersionColumn();
|
InjectBotsVersionColumn();
|
||||||
auto v = GetDatabaseVersions();
|
auto v = GetDatabaseVersions();
|
||||||
auto b = GetBinaryDatabaseVersions();
|
auto b = GetBinaryDatabaseVersions();
|
||||||
@@ -59,6 +62,15 @@ void DatabaseUpdate::CheckDbUpdates()
|
|||||||
m_database->QueryDatabase(fmt::format("UPDATE `db_version` SET `version` = {}", b.server_database_version));
|
m_database->QueryDatabase(fmt::format("UPDATE `db_version` SET `version` = {}", b.server_database_version));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (UpdateManifest(manifest_entries_custom, v.custom_database_version, b.custom_database_version)) {
|
||||||
|
LogInfo(
|
||||||
|
"Updates ran successfully, setting database version to [{}] from [{}]",
|
||||||
|
b.custom_database_version,
|
||||||
|
v.custom_database_version
|
||||||
|
);
|
||||||
|
m_database->QueryDatabase(fmt::format("UPDATE `db_version` SET `custom_version` = {}", b.custom_database_version));
|
||||||
|
}
|
||||||
|
|
||||||
if (b.bots_database_version > 0) {
|
if (b.bots_database_version > 0) {
|
||||||
if (UpdateManifest(bot_manifest_entries, v.bots_database_version, b.bots_database_version)) {
|
if (UpdateManifest(bot_manifest_entries, v.bots_database_version, b.bots_database_version)) {
|
||||||
LogInfo(
|
LogInfo(
|
||||||
@@ -141,7 +153,8 @@ bool DatabaseUpdate::UpdateManifest(
|
|||||||
std::vector<int> missing_migrations = {};
|
std::vector<int> missing_migrations = {};
|
||||||
if (version_low != version_high) {
|
if (version_low != version_high) {
|
||||||
|
|
||||||
LogSys.DisableMySQLErrorLogs();
|
EQEmuLogSys::Instance()->DisableMySQLErrorLogs();
|
||||||
|
bool force_interactive = false;
|
||||||
for (int version = version_low + 1; version <= version_high; ++version) {
|
for (int version = version_low + 1; version <= version_high; ++version) {
|
||||||
for (auto &e: entries) {
|
for (auto &e: entries) {
|
||||||
if (e.version == version) {
|
if (e.version == version) {
|
||||||
@@ -163,13 +176,20 @@ bool DatabaseUpdate::UpdateManifest(
|
|||||||
prefix,
|
prefix,
|
||||||
e.description
|
e.description
|
||||||
);
|
);
|
||||||
|
|
||||||
|
if (!has_migration && e.force_interactive) {
|
||||||
|
force_interactive = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
LogSys.EnableMySQLErrorLogs();
|
}
|
||||||
|
EQEmuLogSys::Instance()->EnableMySQLErrorLogs();
|
||||||
LogInfo("{}", Strings::Repeat("-", BREAK_LENGTH));
|
LogInfo("{}", Strings::Repeat("-", BREAK_LENGTH));
|
||||||
|
|
||||||
if (!missing_migrations.empty()) {
|
if (!missing_migrations.empty() && m_skip_backup) {
|
||||||
|
LogInfo("Skipping database backup");
|
||||||
|
}
|
||||||
|
else if (!missing_migrations.empty()) {
|
||||||
LogInfo("Automatically backing up database before applying updates");
|
LogInfo("Automatically backing up database before applying updates");
|
||||||
LogInfo("{}", Strings::Repeat("-", BREAK_LENGTH));
|
LogInfo("{}", Strings::Repeat("-", BREAK_LENGTH));
|
||||||
auto s = DatabaseDumpService();
|
auto s = DatabaseDumpService();
|
||||||
@@ -184,6 +204,42 @@ bool DatabaseUpdate::UpdateManifest(
|
|||||||
LogInfo("{}", Strings::Repeat("-", BREAK_LENGTH));
|
LogInfo("{}", Strings::Repeat("-", BREAK_LENGTH));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (force_interactive && !std::getenv("FORCE_INTERACTIVE")) {
|
||||||
|
LogInfo("{}", Strings::Repeat("-", BREAK_LENGTH));
|
||||||
|
LogInfo("Some migrations require user input. Running interactively");
|
||||||
|
LogInfo("This is usually due to a major change that could cause data loss");
|
||||||
|
LogInfo("Your server is automatically backed up before these updates are applied");
|
||||||
|
LogInfo("but you should also make sure you take a backup prior to running this update");
|
||||||
|
LogInfo("Would you like to run this update? [y/n] (Timeout 60s)");
|
||||||
|
LogInfo("{}", Strings::Repeat("-", BREAK_LENGTH));
|
||||||
|
|
||||||
|
// user input
|
||||||
|
std::string input;
|
||||||
|
bool gave_input = false;
|
||||||
|
time_t start_time = time(nullptr);
|
||||||
|
time_t wait_time_seconds = 60;
|
||||||
|
|
||||||
|
// spawn a concurrent thread that waits for input from std::cin
|
||||||
|
std::thread t1(
|
||||||
|
[&]() {
|
||||||
|
std::cin >> input;
|
||||||
|
gave_input = true;
|
||||||
|
}
|
||||||
|
);
|
||||||
|
t1.detach();
|
||||||
|
|
||||||
|
// check the inputReceived flag once every 50ms for 10 seconds
|
||||||
|
while (time(nullptr) < start_time + wait_time_seconds && !gave_input) {
|
||||||
|
std::this_thread::sleep_for(std::chrono::milliseconds(50));
|
||||||
|
}
|
||||||
|
|
||||||
|
// prompt for user skip
|
||||||
|
if (Strings::Trim(input) != "y") {
|
||||||
|
LogInfo("Exiting due to user input");
|
||||||
|
std::exit(1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
for (auto &m: missing_migrations) {
|
for (auto &m: missing_migrations) {
|
||||||
for (auto &e: entries) {
|
for (auto &e: entries) {
|
||||||
if (e.version == m) {
|
if (e.version == m) {
|
||||||
@@ -271,6 +327,13 @@ DatabaseUpdate *DatabaseUpdate::SetContentDatabase(Database *db)
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
DatabaseUpdate *DatabaseUpdate::SetSkipBackup(bool skip)
|
||||||
|
{
|
||||||
|
m_skip_backup = skip;
|
||||||
|
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
bool DatabaseUpdate::CheckVersionsUpToDate(DatabaseVersion v, DatabaseVersion b)
|
bool DatabaseUpdate::CheckVersionsUpToDate(DatabaseVersion v, DatabaseVersion b)
|
||||||
{
|
{
|
||||||
LogInfo("{}", Strings::Repeat("-", BREAK_LENGTH));
|
LogInfo("{}", Strings::Repeat("-", BREAK_LENGTH));
|
||||||
@@ -293,6 +356,16 @@ bool DatabaseUpdate::CheckVersionsUpToDate(DatabaseVersion v, DatabaseVersion b)
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (b.custom_database_version > 0) {
|
||||||
|
LogInfo(
|
||||||
|
"{:>8} | database [{}] binary [{}] {}",
|
||||||
|
"Custom",
|
||||||
|
v.custom_database_version,
|
||||||
|
b.custom_database_version,
|
||||||
|
(v.custom_database_version == b.custom_database_version) ? "up to date" : "checking updates"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
LogInfo("{:>8} | [server.auto_database_updates] [<green>true]", "Config");
|
LogInfo("{:>8} | [server.auto_database_updates] [<green>true]", "Config");
|
||||||
|
|
||||||
LogInfo("{}", Strings::Repeat("-", BREAK_LENGTH));
|
LogInfo("{}", Strings::Repeat("-", BREAK_LENGTH));
|
||||||
@@ -302,7 +375,10 @@ bool DatabaseUpdate::CheckVersionsUpToDate(DatabaseVersion v, DatabaseVersion b)
|
|||||||
// bots database version is optional, if not enabled then it is always up-to-date
|
// bots database version is optional, if not enabled then it is always up-to-date
|
||||||
bool bots_up_to_date = RuleB(Bots, Enabled) ? v.bots_database_version >= b.bots_database_version : true;
|
bool bots_up_to_date = RuleB(Bots, Enabled) ? v.bots_database_version >= b.bots_database_version : true;
|
||||||
|
|
||||||
return server_up_to_date && bots_up_to_date;
|
// custom database version is optional, if not enabled then it is always up-to-date
|
||||||
|
bool custom_up_to_date = v.custom_database_version >= b.custom_database_version;
|
||||||
|
|
||||||
|
return server_up_to_date && bots_up_to_date && custom_up_to_date;
|
||||||
}
|
}
|
||||||
|
|
||||||
// checks to see if there are pending updates
|
// checks to see if there are pending updates
|
||||||
@@ -322,3 +398,12 @@ void DatabaseUpdate::InjectBotsVersionColumn()
|
|||||||
m_database->QueryDatabase("ALTER TABLE db_version ADD bots_version int(11) DEFAULT '0' AFTER version");
|
m_database->QueryDatabase("ALTER TABLE db_version ADD bots_version int(11) DEFAULT '0' AFTER version");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void DatabaseUpdate::InjectCustomVersionColumn()
|
||||||
|
{
|
||||||
|
auto results = m_database->QueryDatabase("SHOW COLUMNS FROM `db_version` LIKE 'custom_version'");
|
||||||
|
if (!results.Success() || results.RowCount() == 0) {
|
||||||
|
LogInfo("Adding custom_version column to db_version table");
|
||||||
|
m_database->QueryDatabase("ALTER TABLE `db_version` ADD COLUMN `custom_version` INT(11) UNSIGNED NOT NULL DEFAULT 0");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -11,11 +11,13 @@ struct ManifestEntry {
|
|||||||
std::string match{}; // match field that is not always used, but works in conjunction with "condition" values [missing|match|contains]
|
std::string match{}; // match field that is not always used, but works in conjunction with "condition" values [missing|match|contains]
|
||||||
std::string sql{}; // the SQL DDL that gets ran when the condition is true
|
std::string sql{}; // the SQL DDL that gets ran when the condition is true
|
||||||
bool content_schema_update{}; // if true, this migration is a content schema update and should be ran against the content database
|
bool content_schema_update{}; // if true, this migration is a content schema update and should be ran against the content database
|
||||||
|
bool force_interactive; // if true, this migration will always be run interactively
|
||||||
};
|
};
|
||||||
|
|
||||||
struct DatabaseVersion {
|
struct DatabaseVersion {
|
||||||
int server_database_version;
|
int server_database_version;
|
||||||
int bots_database_version;
|
int bots_database_version;
|
||||||
|
int custom_database_version;
|
||||||
};
|
};
|
||||||
|
|
||||||
class DatabaseUpdate {
|
class DatabaseUpdate {
|
||||||
@@ -29,12 +31,23 @@ public:
|
|||||||
|
|
||||||
DatabaseUpdate *SetDatabase(Database *db);
|
DatabaseUpdate *SetDatabase(Database *db);
|
||||||
DatabaseUpdate *SetContentDatabase(Database *db);
|
DatabaseUpdate *SetContentDatabase(Database *db);
|
||||||
|
DatabaseUpdate *SetSkipBackup(bool skip);
|
||||||
bool HasPendingUpdates();
|
bool HasPendingUpdates();
|
||||||
|
|
||||||
|
static DatabaseUpdate* Instance()
|
||||||
|
{
|
||||||
|
static DatabaseUpdate instance;
|
||||||
|
return &instance;
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
bool m_skip_backup = false;
|
||||||
Database *m_database;
|
Database *m_database;
|
||||||
Database *m_content_database;
|
Database *m_content_database;
|
||||||
static bool CheckVersionsUpToDate(DatabaseVersion v, DatabaseVersion b);
|
static bool CheckVersionsUpToDate(DatabaseVersion v, DatabaseVersion b);
|
||||||
void InjectBotsVersionColumn();
|
void InjectBotsVersionColumn();
|
||||||
|
void InjectCustomVersionColumn();
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif //EQEMU_DATABASE_UPDATE_H
|
#endif //EQEMU_DATABASE_UPDATE_H
|
||||||
|
|||||||
+1441
-3
File diff suppressed because it is too large
Load Diff
@@ -1,186 +0,0 @@
|
|||||||
#include "database_update.h"
|
|
||||||
|
|
||||||
std::vector<ManifestEntry> bot_manifest_entries = {
|
|
||||||
ManifestEntry{
|
|
||||||
.version = 9035,
|
|
||||||
.description = "2022_12_04_bot_archery.sql",
|
|
||||||
.check = "SHOW COLUMNS FROM `bot_data` LIKE 'archery_setting'",
|
|
||||||
.condition = "empty",
|
|
||||||
.match = "",
|
|
||||||
.sql = R"(
|
|
||||||
ALTER TABLE `bot_data`
|
|
||||||
ADD COLUMN `archery_setting` TINYINT(2) UNSIGNED NOT NULL DEFAULT '0' AFTER `enforce_spell_settings`;
|
|
||||||
)",
|
|
||||||
},
|
|
||||||
ManifestEntry{
|
|
||||||
.version = 9036,
|
|
||||||
.description = "2023_01_19_drop_bot_views.sql",
|
|
||||||
.check = "SHOW TABLES LIKE 'vw_groups'",
|
|
||||||
.condition = "not_empty",
|
|
||||||
.match = "",
|
|
||||||
.sql = R"(
|
|
||||||
DROP VIEW vw_bot_groups;
|
|
||||||
DROP VIEW vw_bot_character_mobs;
|
|
||||||
DROP VIEW vw_groups;
|
|
||||||
DROP VIEW vw_guild_members;
|
|
||||||
DROP TABLE bot_guild_members;
|
|
||||||
|
|
||||||
)",
|
|
||||||
},
|
|
||||||
ManifestEntry{
|
|
||||||
.version = 9037,
|
|
||||||
.description = "2023_01_22_add_name_index.sql",
|
|
||||||
.check = "show index from bot_data WHERE key_name = 'name`",
|
|
||||||
.condition = "",
|
|
||||||
.match = "empty",
|
|
||||||
.sql = R"(
|
|
||||||
create index `name` on bot_data(`name`);
|
|
||||||
)",
|
|
||||||
},
|
|
||||||
ManifestEntry{
|
|
||||||
.version = 9038,
|
|
||||||
.description = "2023_02_16_add_caster_range.sql",
|
|
||||||
.check = "SHOW COLUMNS FROM `bot_data` LIKE 'caster_range'",
|
|
||||||
.condition = "",
|
|
||||||
.match = "empty",
|
|
||||||
.sql = R"(
|
|
||||||
ALTER TABLE `bot_data`
|
|
||||||
ADD COLUMN `caster_range` INT(11) UNSIGNED NOT NULL DEFAULT '300' AFTER `archery_setting`;
|
|
||||||
)",
|
|
||||||
},
|
|
||||||
ManifestEntry{
|
|
||||||
.version = 9039,
|
|
||||||
.description = "2023_03_31_remove_bot_groups.sql",
|
|
||||||
.check = "SHOW TABLES LIKE 'bot_groups'",
|
|
||||||
.condition = "",
|
|
||||||
.match = "not_empty",
|
|
||||||
.sql = R"(
|
|
||||||
SET FOREIGN_KEY_CHECKS = 0;
|
|
||||||
DROP TABLE IF EXISTS `bot_groups`;
|
|
||||||
DROP TABLE IF EXISTS `bot_group_members`;
|
|
||||||
SET FOREIGN_KEY_CHECKS = 1;
|
|
||||||
)",
|
|
||||||
},
|
|
||||||
ManifestEntry{
|
|
||||||
.version = 9040,
|
|
||||||
.description = "2023_11_16_bot_starting_items.sql",
|
|
||||||
.check = "SHOW TABLES LIKE 'bot_starting_items'",
|
|
||||||
.condition = "empty",
|
|
||||||
.match = "",
|
|
||||||
.sql = R"(
|
|
||||||
CREATE TABLE `bot_starting_items` (
|
|
||||||
`id` int(11) UNSIGNED NOT NULL AUTO_INCREMENT,
|
|
||||||
`races` int(11) UNSIGNED NOT NULL DEFAULT 0,
|
|
||||||
`classes` int(11) UNSIGNED NOT NULL DEFAULT 0,
|
|
||||||
`item_id` int(11) UNSIGNED NOT NULL DEFAULT 0,
|
|
||||||
`item_charges` tinyint(3) UNSIGNED NOT NULL DEFAULT 1,
|
|
||||||
`min_status` tinyint(3) UNSIGNED NOT NULL DEFAULT 0,
|
|
||||||
`slot_id` mediumint(9) NOT NULL DEFAULT -1,
|
|
||||||
`min_expansion` tinyint(4) NOT NULL DEFAULT -1,
|
|
||||||
`max_expansion` tinyint(4) NOT NULL DEFAULT -1,
|
|
||||||
`content_flags` varchar(100) CHARACTER SET latin1 COLLATE latin1_swedish_ci NULL DEFAULT NULL,
|
|
||||||
`content_flags_disabled` varchar(100) CHARACTER SET latin1 COLLATE latin1_swedish_ci NULL DEFAULT NULL,
|
|
||||||
PRIMARY KEY (`id`)
|
|
||||||
) ENGINE = InnoDB CHARACTER SET = latin1 COLLATE = latin1_swedish_ci;
|
|
||||||
)",
|
|
||||||
},
|
|
||||||
ManifestEntry{
|
|
||||||
.version = 9041,
|
|
||||||
.description = "2023_12_04_bot_timers.sql",
|
|
||||||
.check = "SHOW COLUMNS FROM `bot_timers` LIKE 'recast_time'",
|
|
||||||
.condition = "empty",
|
|
||||||
.match = "",
|
|
||||||
.sql = R"(
|
|
||||||
ALTER TABLE `bot_timers`
|
|
||||||
ADD COLUMN `recast_time` INT(11) UNSIGNED NOT NULL DEFAULT '0' AFTER `timer_value`,
|
|
||||||
ADD COLUMN `is_spell` TINYINT(2) UNSIGNED NOT NULL DEFAULT 0 AFTER `recast_time`,
|
|
||||||
ADD COLUMN `is_disc` TINYINT(2) UNSIGNED NOT NULL DEFAULT 0 AFTER `is_spell`,
|
|
||||||
ADD COLUMN `spell_id` INT(11) UNSIGNED NOT NULL DEFAULT '0' AFTER `is_disc`,
|
|
||||||
ADD COLUMN `is_item` TINYINT(2) UNSIGNED NOT NULL DEFAULT 0 AFTER `spell_id`,
|
|
||||||
ADD COLUMN `item_id` INT(11) UNSIGNED NOT NULL DEFAULT '0' AFTER `is_item`;
|
|
||||||
ALTER TABLE `bot_timers`
|
|
||||||
DROP FOREIGN KEY `FK_bot_timers_1`;
|
|
||||||
ALTER TABLE `bot_timers`
|
|
||||||
DROP PRIMARY KEY;
|
|
||||||
ALTER TABLE `bot_timers`
|
|
||||||
ADD PRIMARY KEY (`bot_id`, `timer_id`, `spell_id`, `item_id`);
|
|
||||||
)"
|
|
||||||
},
|
|
||||||
ManifestEntry{
|
|
||||||
.version = 9042,
|
|
||||||
.description = "2024_01_27_delete_bot_foreign_keys.sql",
|
|
||||||
.check = "SHOW CREATE TABLE `bot_stances`",
|
|
||||||
.condition = "contains",
|
|
||||||
.match = "FOREIGN",
|
|
||||||
.sql = R"(
|
|
||||||
ALTER TABLE `bot_buffs` DROP FOREIGN KEY `FK_bot_buffs_1`;
|
|
||||||
ALTER TABLE `bot_heal_rotations` DROP FOREIGN KEY `FK_bot_heal_rotations`;
|
|
||||||
ALTER TABLE `bot_heal_rotation_members` DROP FOREIGN KEY `FK_bot_heal_rotation_members_1`;
|
|
||||||
ALTER TABLE `bot_heal_rotation_members` DROP FOREIGN KEY `FK_bot_heal_rotation_members_2`;
|
|
||||||
ALTER TABLE `bot_heal_rotation_targets` DROP FOREIGN KEY `FK_bot_heal_rotation_targets`;
|
|
||||||
ALTER TABLE `bot_inventories` DROP FOREIGN KEY `FK_bot_inventories_1`;
|
|
||||||
ALTER TABLE `bot_pets` DROP FOREIGN KEY `FK_bot_pets_1`;
|
|
||||||
ALTER TABLE `bot_pet_buffs` DROP FOREIGN KEY `FK_bot_pet_buffs_1`;
|
|
||||||
ALTER TABLE `bot_pet_inventories` DROP FOREIGN KEY `FK_bot_pet_inventories_1`;
|
|
||||||
ALTER TABLE `bot_stances` DROP FOREIGN KEY `FK_bot_stances_1`;
|
|
||||||
)"
|
|
||||||
},
|
|
||||||
ManifestEntry{
|
|
||||||
.version = 9043,
|
|
||||||
.description = "2024_02_18_bot_starting_items_augments.sql",
|
|
||||||
.check = "SHOW COLUMNS FROM `bot_starting_items` LIKE 'augment_one'",
|
|
||||||
.condition = "empty",
|
|
||||||
.match = "",
|
|
||||||
.sql = R"(
|
|
||||||
ALTER TABLE `bot_starting_items`
|
|
||||||
ADD COLUMN `augment_one` int(11) UNSIGNED NOT NULL DEFAULT 0 AFTER `item_charges`,
|
|
||||||
ADD COLUMN `augment_two` int(11) UNSIGNED NOT NULL DEFAULT 0 AFTER `augment_one`,
|
|
||||||
ADD COLUMN `augment_three` int(11) UNSIGNED NOT NULL DEFAULT 0 AFTER `augment_two`,
|
|
||||||
ADD COLUMN `augment_four` int(11) UNSIGNED NOT NULL DEFAULT 0 AFTER `augment_three`,
|
|
||||||
ADD COLUMN `augment_five` int(11) UNSIGNED NOT NULL DEFAULT 0 AFTER `augment_four`,
|
|
||||||
ADD COLUMN `augment_six` int(11) UNSIGNED NOT NULL DEFAULT 0 AFTER `augment_five`;
|
|
||||||
)"
|
|
||||||
},
|
|
||||||
ManifestEntry{
|
|
||||||
.version = 9044,
|
|
||||||
.description = "2024_04_23_bot_extra_haste.sql",
|
|
||||||
.check = "SHOW COLUMNS FROM `bot_data` LIKE 'extra_haste'",
|
|
||||||
.condition = "empty",
|
|
||||||
.match = "",
|
|
||||||
.sql = R"(
|
|
||||||
ALTER TABLE `bot_data`
|
|
||||||
ADD COLUMN `extra_haste` mediumint(8) NOT NULL DEFAULT 0 AFTER `wis`;
|
|
||||||
)"
|
|
||||||
},
|
|
||||||
ManifestEntry{
|
|
||||||
.version = 9045,
|
|
||||||
.description = "2024_08_05_bot_spells_entries_unsigned_spell_id.sql",
|
|
||||||
.check = "SHOW COLUMNS FROM `bot_spells_entries` LIKE 'spell_id'",
|
|
||||||
.condition = "empty",
|
|
||||||
.match = "",
|
|
||||||
.sql = R"(
|
|
||||||
ALTER TABLE `bot_spells_entries`
|
|
||||||
CHANGE COLUMN `spellid` `spell_id` smallint(5) UNSIGNED NOT NULL DEFAULT 0 AFTER `npc_spells_id`;
|
|
||||||
)"
|
|
||||||
}
|
|
||||||
// -- template; copy/paste this when you need to create a new entry
|
|
||||||
// ManifestEntry{
|
|
||||||
// .version = 9228,
|
|
||||||
// .description = "some_new_migration.sql",
|
|
||||||
// .check = "SHOW COLUMNS FROM `table_name` LIKE 'column_name'",
|
|
||||||
// .condition = "empty",
|
|
||||||
// .match = "",
|
|
||||||
// .sql = R"(
|
|
||||||
//
|
|
||||||
//)"
|
|
||||||
};
|
|
||||||
|
|
||||||
// see struct definitions for what each field does
|
|
||||||
// struct ManifestEntry {
|
|
||||||
// int version{}; // database version of the migration
|
|
||||||
// std::string description{}; // description of the migration ex: "add_new_table" or "add_index_to_table"
|
|
||||||
// std::string check{}; // query that checks against the condition
|
|
||||||
// std::string condition{}; // condition or "match_type" - Possible values [contains|match|missing|empty|not_empty]
|
|
||||||
// std::string match{}; // match field that is not always used, but works in conjunction with "condition" values [missing|match|contains]
|
|
||||||
// std::string sql{}; // the SQL DDL that gets ran when the condition is true
|
|
||||||
// };
|
|
||||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,55 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
std::vector<ManifestEntry> manifest_entries_custom = {
|
||||||
|
ManifestEntry{
|
||||||
|
.version = 1,
|
||||||
|
.description = "2025_05_16_new_database_check_test",
|
||||||
|
.check = "SHOW TABLES LIKE 'new_table'",
|
||||||
|
.condition = "empty",
|
||||||
|
.match = "",
|
||||||
|
.sql = R"(
|
||||||
|
CREATE TABLE `new_table` (
|
||||||
|
`id` int NOT NULL AUTO_INCREMENT,
|
||||||
|
PRIMARY KEY (`id`)
|
||||||
|
);
|
||||||
|
)",
|
||||||
|
.content_schema_update = false,
|
||||||
|
},
|
||||||
|
// Used for testing
|
||||||
|
// ManifestEntry{
|
||||||
|
// .version = 9229,
|
||||||
|
// .description = "new_database_check_test",
|
||||||
|
// .check = "SHOW TABLES LIKE 'new_table'",
|
||||||
|
// .condition = "empty",
|
||||||
|
// .match = "",
|
||||||
|
// .sql = R"(
|
||||||
|
//CREATE TABLE `new_table` (
|
||||||
|
// `id` int NOT NULL AUTO_INCREMENT,
|
||||||
|
// PRIMARY KEY (`id`)
|
||||||
|
//);
|
||||||
|
//CREATE TABLE `new_table1` (
|
||||||
|
// `id` int NOT NULL AUTO_INCREMENT,
|
||||||
|
// PRIMARY KEY (`id`)
|
||||||
|
//);
|
||||||
|
//CREATE TABLE `new_table2` (
|
||||||
|
// `id` int NOT NULL AUTO_INCREMENT,
|
||||||
|
// PRIMARY KEY (`id`)
|
||||||
|
//);
|
||||||
|
//CREATE TABLE `new_table3` (
|
||||||
|
// `id` int NOT NULL AUTO_INCREMENT,
|
||||||
|
// PRIMARY KEY (`id`)
|
||||||
|
//);
|
||||||
|
//)",
|
||||||
|
// }
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
// see struct definitions for what each field does
|
||||||
|
// struct ManifestEntry {
|
||||||
|
// int version{}; // database version of the migration
|
||||||
|
// std::string description{}; // description of the migration ex: "add_new_table" or "add_index_to_table"
|
||||||
|
// std::string check{}; // query that checks against the condition
|
||||||
|
// std::string condition{}; // condition or "match_type" - Possible values [contains|match|missing|empty|not_empty]
|
||||||
|
// std::string match{}; // match field that is not always used, but works in conjunction with "condition" values [missing|match|contains]
|
||||||
|
// std::string sql{}; // the SQL DDL that gets ran when the condition is true
|
||||||
|
// };
|
||||||
@@ -30,8 +30,8 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|||||||
#include "../common/repositories/respawn_times_repository.h"
|
#include "../common/repositories/respawn_times_repository.h"
|
||||||
#include "../common/repositories/spawn_condition_values_repository.h"
|
#include "../common/repositories/spawn_condition_values_repository.h"
|
||||||
#include "repositories/spawn2_disabled_repository.h"
|
#include "repositories/spawn2_disabled_repository.h"
|
||||||
|
#include "repositories/data_buckets_repository.h"
|
||||||
|
#include "repositories/zone_state_spawns_repository.h"
|
||||||
#include "database.h"
|
#include "database.h"
|
||||||
|
|
||||||
#include <iomanip>
|
#include <iomanip>
|
||||||
@@ -114,7 +114,9 @@ bool Database::CheckInstanceExpired(uint16 instance_id)
|
|||||||
timeval tv{};
|
timeval tv{};
|
||||||
gettimeofday(&tv, nullptr);
|
gettimeofday(&tv, nullptr);
|
||||||
|
|
||||||
return (i.start_time + i.duration) <= tv.tv_sec;
|
// Use uint64_t for the addition to prevent overflow
|
||||||
|
uint64_t expiration_time = static_cast<uint64_t>(i.start_time) + static_cast<uint64_t>(i.duration);
|
||||||
|
return expiration_time <= tv.tv_sec;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Database::CreateInstance(uint16 instance_id, uint32 zone_id, uint32 version, uint32 duration)
|
bool Database::CreateInstance(uint16 instance_id, uint32 zone_id, uint32 version, uint32 duration)
|
||||||
@@ -126,11 +128,35 @@ bool Database::CreateInstance(uint16 instance_id, uint32 zone_id, uint32 version
|
|||||||
e.version = version;
|
e.version = version;
|
||||||
e.start_time = std::time(nullptr);
|
e.start_time = std::time(nullptr);
|
||||||
e.duration = duration;
|
e.duration = duration;
|
||||||
|
e.expire_at = e.start_time + duration;
|
||||||
|
|
||||||
return InstanceListRepository::InsertOne(*this, e).id;
|
RespawnTimesRepository::ClearInstanceTimers(*this, e.id);
|
||||||
|
InstanceListRepository::ReplaceOne(*this, e);
|
||||||
|
return instance_id > 0 && e.id;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Database::GetUnusedInstanceID(uint16 &instance_id)
|
bool Database::GetUnusedInstanceID(uint16 &instance_id)
|
||||||
|
{
|
||||||
|
// attempt to get an unused instance id
|
||||||
|
for (int a = 0; a < 10; a++) {
|
||||||
|
uint16 attempted_id = 0;
|
||||||
|
if (TryGetUnusedInstanceID(attempted_id)) {
|
||||||
|
auto i = InstanceListRepository::NewEntity();
|
||||||
|
i.id = attempted_id;
|
||||||
|
i.notes = "Prefetching";
|
||||||
|
auto n = InstanceListRepository::InsertOne(*this, i);
|
||||||
|
if (n.id > 0) {
|
||||||
|
instance_id = n.id;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
instance_id = 0;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Database::TryGetUnusedInstanceID(uint16 &instance_id)
|
||||||
{
|
{
|
||||||
uint32 max_reserved_instance_id = RuleI(Instances, ReservedInstances);
|
uint32 max_reserved_instance_id = RuleI(Instances, ReservedInstances);
|
||||||
uint32 max_instance_id = 32000;
|
uint32 max_instance_id = 32000;
|
||||||
@@ -469,16 +495,18 @@ void Database::AssignRaidToInstance(uint32 raid_id, uint32 instance_id)
|
|||||||
|
|
||||||
void Database::DeleteInstance(uint16 instance_id)
|
void Database::DeleteInstance(uint16 instance_id)
|
||||||
{
|
{
|
||||||
|
// I'm not sure why this isn't in here but we should add it in a later change and make sure it's tested
|
||||||
|
// InstanceListRepository::DeleteWhere(*this, fmt::format("id = {}", instance_id));
|
||||||
InstanceListPlayerRepository::DeleteWhere(*this, fmt::format("id = {}", instance_id));
|
InstanceListPlayerRepository::DeleteWhere(*this, fmt::format("id = {}", instance_id));
|
||||||
|
|
||||||
RespawnTimesRepository::DeleteWhere(*this, fmt::format("instance_id = {}", instance_id));
|
RespawnTimesRepository::DeleteWhere(*this, fmt::format("instance_id = {}", instance_id));
|
||||||
|
|
||||||
SpawnConditionValuesRepository::DeleteWhere(*this, fmt::format("instance_id = {}", instance_id));
|
SpawnConditionValuesRepository::DeleteWhere(*this, fmt::format("instance_id = {}", instance_id));
|
||||||
|
|
||||||
DynamicZoneMembersRepository::DeleteByInstance(*this, instance_id);
|
DynamicZoneMembersRepository::DeleteByInstance(*this, instance_id);
|
||||||
DynamicZonesRepository::DeleteWhere(*this, fmt::format("instance_id = {}", instance_id));
|
DynamicZonesRepository::DeleteWhere(*this, fmt::format("instance_id = {}", instance_id));
|
||||||
|
|
||||||
CharacterCorpsesRepository::BuryInstance(*this, instance_id);
|
CharacterCorpsesRepository::BuryInstance(*this, instance_id);
|
||||||
|
DataBucketsRepository::DeleteWhere(*this, fmt::format("instance_id = {}", instance_id));
|
||||||
|
if (RuleB(Zone, StateSavingOnShutdown)) {
|
||||||
|
ZoneStateSpawnsRepository::DeleteWhere(*this, fmt::format("`instance_id` = {}", instance_id));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Database::FlagInstanceByGroupLeader(uint32 zone_id, int16 version, uint32 character_id, uint32 group_id)
|
void Database::FlagInstanceByGroupLeader(uint32 zone_id, int16 version, uint32 character_id, uint32 group_id)
|
||||||
@@ -533,14 +561,12 @@ void Database::GetCharactersInInstance(uint16 instance_id, std::list<uint32> &ch
|
|||||||
|
|
||||||
void Database::PurgeExpiredInstances()
|
void Database::PurgeExpiredInstances()
|
||||||
{
|
{
|
||||||
/**
|
|
||||||
* Delay purging by a day so that we can continue using adjacent free instance id's
|
|
||||||
* from the table without risking the chance we immediately re-allocate a zone that freshly expired but
|
|
||||||
* has not been fully de-allocated
|
|
||||||
*/
|
|
||||||
auto l = InstanceListRepository::GetWhere(
|
auto l = InstanceListRepository::GetWhere(
|
||||||
*this,
|
*this,
|
||||||
"(start_time + duration) <= (UNIX_TIMESTAMP() - 86400) AND never_expires = 0"
|
fmt::format(
|
||||||
|
"expire_at <= (UNIX_TIMESTAMP() - {}) and expire_at != 0 AND never_expires = 0",
|
||||||
|
RuleI(Instances, ExpireOffsetTimeSeconds)
|
||||||
|
)
|
||||||
);
|
);
|
||||||
if (l.empty()) {
|
if (l.empty()) {
|
||||||
return;
|
return;
|
||||||
@@ -551,16 +577,24 @@ void Database::PurgeExpiredInstances()
|
|||||||
instance_ids.emplace_back(std::to_string(e.id));
|
instance_ids.emplace_back(std::to_string(e.id));
|
||||||
}
|
}
|
||||||
|
|
||||||
const auto imploded_instance_ids = Strings::Implode(",", instance_ids);
|
const auto ids = Strings::Implode(",", instance_ids);
|
||||||
|
|
||||||
InstanceListRepository::DeleteWhere(*this, fmt::format("id IN ({})", imploded_instance_ids));
|
TransactionBegin();
|
||||||
InstanceListPlayerRepository::DeleteWhere(*this, fmt::format("id IN ({})", imploded_instance_ids));
|
InstanceListRepository::DeleteWhere(*this, fmt::format("id IN ({})", ids));
|
||||||
RespawnTimesRepository::DeleteWhere(*this, fmt::format("instance_id IN ({})", imploded_instance_ids));
|
InstanceListPlayerRepository::DeleteWhere(*this, fmt::format("id IN ({})", ids));
|
||||||
SpawnConditionValuesRepository::DeleteWhere(*this, fmt::format("instance_id IN ({})", imploded_instance_ids));
|
RespawnTimesRepository::DeleteWhere(*this, fmt::format("instance_id IN ({})", ids));
|
||||||
CharacterCorpsesRepository::BuryInstances(*this, imploded_instance_ids);
|
SpawnConditionValuesRepository::DeleteWhere(*this, fmt::format("instance_id IN ({})", ids));
|
||||||
DynamicZoneMembersRepository::DeleteByManyInstances(*this, imploded_instance_ids);
|
CharacterCorpsesRepository::BuryInstances(*this, ids);
|
||||||
DynamicZonesRepository::DeleteWhere(*this, fmt::format("instance_id IN ({})", imploded_instance_ids));
|
DynamicZoneMembersRepository::DeleteByManyInstances(*this, ids);
|
||||||
Spawn2DisabledRepository::DeleteWhere(*this, fmt::format("instance_id IN ({})", imploded_instance_ids));
|
DynamicZonesRepository::DeleteWhere(*this, fmt::format("instance_id IN ({})", ids));
|
||||||
|
Spawn2DisabledRepository::DeleteWhere(*this, fmt::format("instance_id IN ({})", ids));
|
||||||
|
DataBucketsRepository::DeleteWhere(*this, fmt::format("instance_id != 0 and instance_id IN ({})", ids));
|
||||||
|
if (RuleB(Zone, StateSavingOnShutdown)) {
|
||||||
|
ZoneStateSpawnsRepository::DeleteWhere(*this, fmt::format("`instance_id` IN ({})", ids));
|
||||||
|
}
|
||||||
|
TransactionCommit();
|
||||||
|
|
||||||
|
LogInfo("Purged [{}] expired instances", l.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
void Database::SetInstanceDuration(uint16 instance_id, uint32 new_duration)
|
void Database::SetInstanceDuration(uint16 instance_id, uint32 new_duration)
|
||||||
@@ -572,6 +606,7 @@ void Database::SetInstanceDuration(uint16 instance_id, uint32 new_duration)
|
|||||||
|
|
||||||
i.start_time = std::time(nullptr);
|
i.start_time = std::time(nullptr);
|
||||||
i.duration = new_duration;
|
i.duration = new_duration;
|
||||||
|
i.expire_at = i.start_time + i.duration;
|
||||||
|
|
||||||
InstanceListRepository::UpdateOne(*this, i);
|
InstanceListRepository::UpdateOne(*this, i);
|
||||||
}
|
}
|
||||||
|
|||||||
+22
-29
@@ -51,6 +51,7 @@ namespace DatabaseSchema {
|
|||||||
{"character_enabledtasks", "charid"},
|
{"character_enabledtasks", "charid"},
|
||||||
{"character_expedition_lockouts", "character_id"},
|
{"character_expedition_lockouts", "character_id"},
|
||||||
{"character_exp_modifiers", "character_id"},
|
{"character_exp_modifiers", "character_id"},
|
||||||
|
{"character_evolving_items", "character_id"},
|
||||||
{"character_inspect_messages", "id"},
|
{"character_inspect_messages", "id"},
|
||||||
{"character_instance_safereturns", "character_id"},
|
{"character_instance_safereturns", "character_id"},
|
||||||
{"character_item_recast", "id"},
|
{"character_item_recast", "id"},
|
||||||
@@ -63,6 +64,7 @@ namespace DatabaseSchema {
|
|||||||
{"character_pet_buffs", "char_id"},
|
{"character_pet_buffs", "char_id"},
|
||||||
{"character_pet_info", "char_id"},
|
{"character_pet_info", "char_id"},
|
||||||
{"character_pet_inventory", "char_id"},
|
{"character_pet_inventory", "char_id"},
|
||||||
|
{"character_pet_name", "character_id"},
|
||||||
{"character_peqzone_flags", "id"},
|
{"character_peqzone_flags", "id"},
|
||||||
{"character_potionbelt", "id"},
|
{"character_potionbelt", "id"},
|
||||||
{"character_skills", "id"},
|
{"character_skills", "id"},
|
||||||
@@ -78,7 +80,7 @@ namespace DatabaseSchema {
|
|||||||
{"guild_members", "char_id"},
|
{"guild_members", "char_id"},
|
||||||
{"guilds", "id"},
|
{"guilds", "id"},
|
||||||
{"instance_list_player", "id"},
|
{"instance_list_player", "id"},
|
||||||
{"inventory", "charid"},
|
{"inventory", "character_id"},
|
||||||
{"inventory_snapshots", "charid"},
|
{"inventory_snapshots", "charid"},
|
||||||
{"keyring", "char_id"},
|
{"keyring", "char_id"},
|
||||||
{"mail", "charid"},
|
{"mail", "charid"},
|
||||||
@@ -124,6 +126,7 @@ namespace DatabaseSchema {
|
|||||||
"character_enabledtasks",
|
"character_enabledtasks",
|
||||||
"character_expedition_lockouts",
|
"character_expedition_lockouts",
|
||||||
"character_exp_modifiers",
|
"character_exp_modifiers",
|
||||||
|
"character_evolving_items",
|
||||||
"character_inspect_messages",
|
"character_inspect_messages",
|
||||||
"character_instance_safereturns",
|
"character_instance_safereturns",
|
||||||
"character_item_recast",
|
"character_item_recast",
|
||||||
@@ -136,6 +139,7 @@ namespace DatabaseSchema {
|
|||||||
"character_pet_buffs",
|
"character_pet_buffs",
|
||||||
"character_pet_info",
|
"character_pet_info",
|
||||||
"character_pet_inventory",
|
"character_pet_inventory",
|
||||||
|
"character_pet_name",
|
||||||
"character_peqzone_flags",
|
"character_peqzone_flags",
|
||||||
"character_potionbelt",
|
"character_potionbelt",
|
||||||
"character_skills",
|
"character_skills",
|
||||||
@@ -212,6 +216,7 @@ namespace DatabaseSchema {
|
|||||||
"ground_spawns",
|
"ground_spawns",
|
||||||
"horses",
|
"horses",
|
||||||
"items",
|
"items",
|
||||||
|
"items_evolving_details",
|
||||||
"ldon_trap_entries",
|
"ldon_trap_entries",
|
||||||
"ldon_trap_templates",
|
"ldon_trap_templates",
|
||||||
"lootdrop",
|
"lootdrop",
|
||||||
@@ -287,32 +292,6 @@ namespace DatabaseSchema {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets QueryServer tables
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
static std::vector<std::string> GetQueryServerTables()
|
|
||||||
{
|
|
||||||
return {
|
|
||||||
"qs_merchant_transaction_record",
|
|
||||||
"qs_merchant_transaction_record_entries",
|
|
||||||
"qs_player_aa_rate_hourly",
|
|
||||||
"qs_player_delete_record",
|
|
||||||
"qs_player_delete_record_entries",
|
|
||||||
"qs_player_events",
|
|
||||||
"qs_player_handin_record",
|
|
||||||
"qs_player_handin_record_entries",
|
|
||||||
"qs_player_move_record",
|
|
||||||
"qs_player_move_record_entries",
|
|
||||||
"qs_player_npc_kill_record",
|
|
||||||
"qs_player_npc_kill_record_entries",
|
|
||||||
"qs_player_speech",
|
|
||||||
"qs_player_trade_record",
|
|
||||||
"qs_player_trade_record_entries",
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets state tables
|
* Gets state tables
|
||||||
* Tables that keep track of server state
|
* Tables that keep track of server state
|
||||||
@@ -333,10 +312,9 @@ namespace DatabaseSchema {
|
|||||||
"completed_shared_task_members",
|
"completed_shared_task_members",
|
||||||
"completed_shared_tasks",
|
"completed_shared_tasks",
|
||||||
"discord_webhooks",
|
"discord_webhooks",
|
||||||
|
"dynamic_zone_lockouts",
|
||||||
"dynamic_zone_members",
|
"dynamic_zone_members",
|
||||||
"dynamic_zones",
|
"dynamic_zones",
|
||||||
"expedition_lockouts",
|
|
||||||
"expeditions",
|
|
||||||
"gm_ips",
|
"gm_ips",
|
||||||
"group_id",
|
"group_id",
|
||||||
"group_leaders",
|
"group_leaders",
|
||||||
@@ -355,12 +333,25 @@ namespace DatabaseSchema {
|
|||||||
"saylink",
|
"saylink",
|
||||||
"server_scheduled_events",
|
"server_scheduled_events",
|
||||||
"spawn2_disabled",
|
"spawn2_disabled",
|
||||||
|
"player_event_aa_purchase",
|
||||||
|
"player_event_killed_npc",
|
||||||
|
"player_event_killed_named_npc",
|
||||||
|
"player_event_killed_raid_npc",
|
||||||
"player_event_log_settings",
|
"player_event_log_settings",
|
||||||
"player_event_logs",
|
"player_event_logs",
|
||||||
|
"player_event_loot_items",
|
||||||
|
"player_event_merchant_purchase",
|
||||||
|
"player_event_merchant_sell",
|
||||||
|
"player_event_npc_handin",
|
||||||
|
"player_event_npc_handin_entries",
|
||||||
|
"player_event_speech",
|
||||||
|
"player_event_trade",
|
||||||
|
"player_event_trade_entries",
|
||||||
"shared_task_activity_state",
|
"shared_task_activity_state",
|
||||||
"shared_task_dynamic_zones",
|
"shared_task_dynamic_zones",
|
||||||
"shared_task_members",
|
"shared_task_members",
|
||||||
"shared_tasks",
|
"shared_tasks",
|
||||||
|
"zone_state_spawns",
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -402,6 +393,7 @@ namespace DatabaseSchema {
|
|||||||
static std::vector<std::string> GetBotTables()
|
static std::vector<std::string> GetBotTables()
|
||||||
{
|
{
|
||||||
return {
|
return {
|
||||||
|
"bot_blocked_buffs",
|
||||||
"bot_buffs",
|
"bot_buffs",
|
||||||
"bot_command_settings",
|
"bot_command_settings",
|
||||||
"bot_create_combinations",
|
"bot_create_combinations",
|
||||||
@@ -415,6 +407,7 @@ namespace DatabaseSchema {
|
|||||||
"bot_pet_buffs",
|
"bot_pet_buffs",
|
||||||
"bot_pet_inventories",
|
"bot_pet_inventories",
|
||||||
"bot_pets",
|
"bot_pets",
|
||||||
|
"bot_settings",
|
||||||
"bot_spell_casting_chances",
|
"bot_spell_casting_chances",
|
||||||
"bot_spell_settings",
|
"bot_spell_settings",
|
||||||
"bot_spells_entries",
|
"bot_spells_entries",
|
||||||
|
|||||||
+19
-3
@@ -7,6 +7,7 @@
|
|||||||
#include "timer.h"
|
#include "timer.h"
|
||||||
|
|
||||||
#include "dbcore.h"
|
#include "dbcore.h"
|
||||||
|
#include "mysql_stmt.h"
|
||||||
|
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
@@ -159,7 +160,7 @@ MySQLRequestResult DBcore::QueryDatabase(const char *query, uint32 querylen, boo
|
|||||||
(uint32) mysql_insert_id(mysql)
|
(uint32) mysql_insert_id(mysql)
|
||||||
);
|
);
|
||||||
|
|
||||||
if (LogSys.log_settings[Logs::MySQLQuery].is_category_enabled == 1) {
|
if (EQEmuLogSys::Instance()->log_settings[Logs::MySQLQuery].is_category_enabled == 1) {
|
||||||
if ((strncasecmp(query, "select", 6) == 0)) {
|
if ((strncasecmp(query, "select", 6) == 0)) {
|
||||||
LogMySQLQuery(
|
LogMySQLQuery(
|
||||||
"{0} -- ({1} row{2} returned) ({3}s)",
|
"{0} -- ({1} row{2} returned) ({3}s)",
|
||||||
@@ -188,9 +189,9 @@ void DBcore::TransactionBegin()
|
|||||||
QueryDatabase("START TRANSACTION");
|
QueryDatabase("START TRANSACTION");
|
||||||
}
|
}
|
||||||
|
|
||||||
void DBcore::TransactionCommit()
|
MySQLRequestResult DBcore::TransactionCommit()
|
||||||
{
|
{
|
||||||
QueryDatabase("COMMIT");
|
return QueryDatabase("COMMIT");
|
||||||
}
|
}
|
||||||
|
|
||||||
void DBcore::TransactionRollback()
|
void DBcore::TransactionRollback()
|
||||||
@@ -257,9 +258,17 @@ bool DBcore::Open(uint32 *errnum, char *errbuf)
|
|||||||
if (pCompress) {
|
if (pCompress) {
|
||||||
flags |= CLIENT_COMPRESS;
|
flags |= CLIENT_COMPRESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//todo: we need to revisit this ssl handling later
|
||||||
|
//the whole connect code is ancient and tls is starting to come as a default requirement for many db setups
|
||||||
if (pSSL) {
|
if (pSSL) {
|
||||||
flags |= CLIENT_SSL;
|
flags |= CLIENT_SSL;
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
int off = 0;
|
||||||
|
mysql_options(mysql, MYSQL_OPT_SSL_ENFORCE, &off);
|
||||||
|
mysql_options(mysql, MYSQL_OPT_SSL_VERIFY_SERVER_CERT, &off);
|
||||||
|
}
|
||||||
if (mysql_real_connect(mysql, pHost, pUser, pPassword, pDatabase, pPort, 0, flags)) {
|
if (mysql_real_connect(mysql, pHost, pUser, pPassword, pDatabase, pPort, 0, flags)) {
|
||||||
pStatus = Connected;
|
pStatus = Connected;
|
||||||
|
|
||||||
@@ -301,7 +310,9 @@ std::string DBcore::Escape(const std::string& s)
|
|||||||
|
|
||||||
void DBcore::SetMutex(Mutex *mutex)
|
void DBcore::SetMutex(Mutex *mutex)
|
||||||
{
|
{
|
||||||
|
if (m_mutex && m_mutex != mutex) {
|
||||||
safe_delete(m_mutex);
|
safe_delete(m_mutex);
|
||||||
|
}
|
||||||
|
|
||||||
DBcore::m_mutex = mutex;
|
DBcore::m_mutex = mutex;
|
||||||
}
|
}
|
||||||
@@ -436,3 +447,8 @@ MySQLRequestResult DBcore::QueryDatabaseMulti(const std::string &query)
|
|||||||
|
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
mysql::PreparedStmt DBcore::Prepare(std::string query)
|
||||||
|
{
|
||||||
|
return mysql::PreparedStmt(*mysql, std::move(query), m_mutex);
|
||||||
|
}
|
||||||
|
|||||||
+8
-1
@@ -17,6 +17,8 @@
|
|||||||
#define CR_SERVER_GONE_ERROR 2006
|
#define CR_SERVER_GONE_ERROR 2006
|
||||||
#define CR_SERVER_LOST 2013
|
#define CR_SERVER_LOST 2013
|
||||||
|
|
||||||
|
namespace mysql { class PreparedStmt; }
|
||||||
|
|
||||||
class DBcore {
|
class DBcore {
|
||||||
public:
|
public:
|
||||||
enum eStatus {
|
enum eStatus {
|
||||||
@@ -30,7 +32,7 @@ public:
|
|||||||
MySQLRequestResult QueryDatabase(const std::string& query, bool retryOnFailureOnce = true);
|
MySQLRequestResult QueryDatabase(const std::string& query, bool retryOnFailureOnce = true);
|
||||||
MySQLRequestResult QueryDatabaseMulti(const std::string &query);
|
MySQLRequestResult QueryDatabaseMulti(const std::string &query);
|
||||||
void TransactionBegin();
|
void TransactionBegin();
|
||||||
void TransactionCommit();
|
MySQLRequestResult TransactionCommit();
|
||||||
void TransactionRollback();
|
void TransactionRollback();
|
||||||
std::string Escape(const std::string& s);
|
std::string Escape(const std::string& s);
|
||||||
uint32 DoEscapeString(char *tobuf, const char *frombuf, uint32 fromlen);
|
uint32 DoEscapeString(char *tobuf, const char *frombuf, uint32 fromlen);
|
||||||
@@ -48,6 +50,11 @@ public:
|
|||||||
}
|
}
|
||||||
void SetMutex(Mutex *mutex);
|
void SetMutex(Mutex *mutex);
|
||||||
|
|
||||||
|
// only safe on connections shared with other threads if results buffered
|
||||||
|
// unsafe to use off main thread due to internal server logging
|
||||||
|
// throws std::runtime_error on failure
|
||||||
|
mysql::PreparedStmt Prepare(std::string query);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
bool Open(
|
bool Open(
|
||||||
const char *iHost,
|
const char *iHost,
|
||||||
|
|||||||
@@ -4,7 +4,6 @@
|
|||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
#include "../types.h"
|
#include "../types.h"
|
||||||
#include "../http/httplib.h"
|
|
||||||
#include "../repositories/player_event_logs_repository.h"
|
#include "../repositories/player_event_logs_repository.h"
|
||||||
#include "../events/player_events.h"
|
#include "../events/player_events.h"
|
||||||
|
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ void DiscordManager::ProcessMessageQueue()
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto webhook = LogSys.GetDiscordWebhooks()[q.first];
|
auto webhook = EQEmuLogSys::Instance()->GetDiscordWebhooks()[q.first];
|
||||||
std::string message;
|
std::string message;
|
||||||
|
|
||||||
for (auto &m: q.second) {
|
for (auto &m: q.second) {
|
||||||
@@ -68,7 +68,7 @@ void DiscordManager::ProcessMessageQueue()
|
|||||||
|
|
||||||
void DiscordManager::QueuePlayerEventMessage(const PlayerEvent::PlayerEventContainer& e)
|
void DiscordManager::QueuePlayerEventMessage(const PlayerEvent::PlayerEventContainer& e)
|
||||||
{
|
{
|
||||||
auto w = player_event_logs.GetDiscordWebhookUrlFromEventType(e.player_event_log.event_type_id);
|
auto w = PlayerEventLogs::Instance()->GetDiscordWebhookUrlFromEventType(e.player_event_log.event_type_id);
|
||||||
if (!w.empty()) {
|
if (!w.empty()) {
|
||||||
Discord::SendPlayerEventMessage(e, w);
|
Discord::SendPlayerEventMessage(e, w);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,6 +13,12 @@ public:
|
|||||||
void QueueWebhookMessage(uint32 webhook_id, const std::string& message);
|
void QueueWebhookMessage(uint32 webhook_id, const std::string& message);
|
||||||
void ProcessMessageQueue();
|
void ProcessMessageQueue();
|
||||||
void QueuePlayerEventMessage(const PlayerEvent::PlayerEventContainer& e);
|
void QueuePlayerEventMessage(const PlayerEvent::PlayerEventContainer& e);
|
||||||
|
|
||||||
|
static DiscordManager* Instance()
|
||||||
|
{
|
||||||
|
static DiscordManager instance;
|
||||||
|
return &instance;
|
||||||
|
}
|
||||||
private:
|
private:
|
||||||
std::mutex webhook_queue_lock{};
|
std::mutex webhook_queue_lock{};
|
||||||
std::map<uint32, std::vector<std::string>> webhook_message_queue{};
|
std::map<uint32, std::vector<std::string>> webhook_message_queue{};
|
||||||
|
|||||||
+297
-67
@@ -1,11 +1,13 @@
|
|||||||
#include "dynamic_zone_base.h"
|
#include "dynamic_zone_base.h"
|
||||||
#include "database.h"
|
#include "database.h"
|
||||||
#include "eqemu_logsys.h"
|
#include "eqemu_logsys.h"
|
||||||
#include "repositories/instance_list_repository.h"
|
|
||||||
#include "repositories/instance_list_player_repository.h"
|
|
||||||
#include "rulesys.h"
|
#include "rulesys.h"
|
||||||
#include "servertalk.h"
|
#include "servertalk.h"
|
||||||
#include "util/uuid.h"
|
#include "util/uuid.h"
|
||||||
|
#include "repositories/character_expedition_lockouts_repository.h"
|
||||||
|
#include "repositories/dynamic_zone_lockouts_repository.h"
|
||||||
|
#include "repositories/instance_list_repository.h"
|
||||||
|
#include "repositories/instance_list_player_repository.h"
|
||||||
|
|
||||||
DynamicZoneBase::DynamicZoneBase(DynamicZonesRepository::DynamicZoneInstance&& entry)
|
DynamicZoneBase::DynamicZoneBase(DynamicZonesRepository::DynamicZoneInstance&& entry)
|
||||||
{
|
{
|
||||||
@@ -56,15 +58,16 @@ uint32_t DynamicZoneBase::CreateInstance()
|
|||||||
insert_instance.start_time = static_cast<int>(std::chrono::system_clock::to_time_t(m_start_time));
|
insert_instance.start_time = static_cast<int>(std::chrono::system_clock::to_time_t(m_start_time));
|
||||||
insert_instance.duration = static_cast<int>(m_duration.count());
|
insert_instance.duration = static_cast<int>(m_duration.count());
|
||||||
insert_instance.never_expires = m_never_expires;
|
insert_instance.never_expires = m_never_expires;
|
||||||
|
insert_instance.expire_at = insert_instance.start_time + insert_instance.duration;
|
||||||
|
|
||||||
auto instance = InstanceListRepository::InsertOne(GetDatabase(), insert_instance);
|
auto instance = InstanceListRepository::ReplaceOne(GetDatabase(), insert_instance);
|
||||||
if (instance.id == 0)
|
if (!instance)
|
||||||
{
|
{
|
||||||
LogDynamicZones("Failed to create instance [{}] for zone [{}]", unused_instance_id, m_zone_id);
|
LogDynamicZones("Failed to create instance [{}] for zone [{}]", unused_instance_id, m_zone_id);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
m_instance_id = instance.id;
|
m_instance_id = unused_instance_id;
|
||||||
|
|
||||||
return m_instance_id;
|
return m_instance_id;
|
||||||
}
|
}
|
||||||
@@ -93,13 +96,15 @@ void DynamicZoneBase::LoadRepositoryResult(DynamicZonesRepository::DynamicZoneIn
|
|||||||
m_zonein.y = dz_entry.zone_in_y;
|
m_zonein.y = dz_entry.zone_in_y;
|
||||||
m_zonein.z = dz_entry.zone_in_z;
|
m_zonein.z = dz_entry.zone_in_z;
|
||||||
m_zonein.heading = dz_entry.zone_in_heading;
|
m_zonein.heading = dz_entry.zone_in_heading;
|
||||||
m_has_zonein = (dz_entry.has_zone_in != 0);
|
m_has_zonein = dz_entry.has_zone_in != 0;
|
||||||
|
m_is_locked = dz_entry.is_locked;
|
||||||
|
m_add_replay = dz_entry.add_replay;
|
||||||
// instance_list portion
|
// instance_list portion
|
||||||
m_zone_id = dz_entry.zone;
|
m_zone_id = dz_entry.zone;
|
||||||
m_zone_version = dz_entry.version;
|
m_zone_version = dz_entry.version;
|
||||||
m_start_time = std::chrono::system_clock::from_time_t(dz_entry.start_time);
|
m_start_time = std::chrono::system_clock::from_time_t(dz_entry.start_time);
|
||||||
m_duration = std::chrono::seconds(dz_entry.duration);
|
m_duration = std::chrono::seconds(dz_entry.duration);
|
||||||
m_never_expires = (dz_entry.never_expires != 0);
|
m_never_expires = dz_entry.never_expires != 0;
|
||||||
m_expire_time = m_start_time + m_duration;
|
m_expire_time = m_start_time + m_duration;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -119,37 +124,40 @@ void DynamicZoneBase::AddMemberFromRepositoryResult(
|
|||||||
uint32_t DynamicZoneBase::SaveToDatabase()
|
uint32_t DynamicZoneBase::SaveToDatabase()
|
||||||
{
|
{
|
||||||
LogDynamicZonesDetail("Saving dz instance [{}] to database", m_instance_id);
|
LogDynamicZonesDetail("Saving dz instance [{}] to database", m_instance_id);
|
||||||
|
if (m_instance_id == 0)
|
||||||
if (m_instance_id != 0)
|
|
||||||
{
|
{
|
||||||
auto insert_dz = DynamicZonesRepository::NewEntity();
|
|
||||||
insert_dz.uuid = m_uuid;
|
|
||||||
insert_dz.name = m_name;
|
|
||||||
insert_dz.leader_id = m_leader.id;
|
|
||||||
insert_dz.min_players = m_min_players;
|
|
||||||
insert_dz.max_players = m_max_players;
|
|
||||||
insert_dz.instance_id = m_instance_id,
|
|
||||||
insert_dz.type = static_cast<int>(m_type);
|
|
||||||
insert_dz.dz_switch_id = m_dz_switch_id;
|
|
||||||
insert_dz.compass_zone_id = m_compass.zone_id;
|
|
||||||
insert_dz.compass_x = m_compass.x;
|
|
||||||
insert_dz.compass_y = m_compass.y;
|
|
||||||
insert_dz.compass_z = m_compass.z;
|
|
||||||
insert_dz.safe_return_zone_id = m_safereturn.zone_id;
|
|
||||||
insert_dz.safe_return_x = m_safereturn.x;
|
|
||||||
insert_dz.safe_return_y = m_safereturn.y;
|
|
||||||
insert_dz.safe_return_z = m_safereturn.z;
|
|
||||||
insert_dz.safe_return_heading = m_safereturn.heading;
|
|
||||||
insert_dz.zone_in_x = m_zonein.x;
|
|
||||||
insert_dz.zone_in_y = m_zonein.y;
|
|
||||||
insert_dz.zone_in_z = m_zonein.z;
|
|
||||||
insert_dz.zone_in_heading = m_zonein.heading;
|
|
||||||
insert_dz.has_zone_in = m_has_zonein;
|
|
||||||
|
|
||||||
auto inserted_dz = DynamicZonesRepository::InsertOne(GetDatabase(), insert_dz);
|
|
||||||
return inserted_dz.id;
|
|
||||||
}
|
|
||||||
return 0;
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto dz = DynamicZonesRepository::NewEntity();
|
||||||
|
dz.uuid = m_uuid;
|
||||||
|
dz.name = m_name;
|
||||||
|
dz.leader_id = m_leader.id;
|
||||||
|
dz.min_players = m_min_players;
|
||||||
|
dz.max_players = m_max_players;
|
||||||
|
dz.instance_id = static_cast<int32_t>(m_instance_id),
|
||||||
|
dz.type = static_cast<uint8_t>(m_type);
|
||||||
|
dz.dz_switch_id = m_dz_switch_id;
|
||||||
|
dz.compass_zone_id = m_compass.zone_id;
|
||||||
|
dz.compass_x = m_compass.x;
|
||||||
|
dz.compass_y = m_compass.y;
|
||||||
|
dz.compass_z = m_compass.z;
|
||||||
|
dz.safe_return_zone_id = m_safereturn.zone_id;
|
||||||
|
dz.safe_return_x = m_safereturn.x;
|
||||||
|
dz.safe_return_y = m_safereturn.y;
|
||||||
|
dz.safe_return_z = m_safereturn.z;
|
||||||
|
dz.safe_return_heading = m_safereturn.heading;
|
||||||
|
dz.zone_in_x = m_zonein.x;
|
||||||
|
dz.zone_in_y = m_zonein.y;
|
||||||
|
dz.zone_in_z = m_zonein.z;
|
||||||
|
dz.zone_in_heading = m_zonein.heading;
|
||||||
|
dz.has_zone_in = static_cast<uint8_t>(m_has_zonein);
|
||||||
|
dz.is_locked = static_cast<int8_t>(m_is_locked);
|
||||||
|
dz.add_replay = static_cast<int8_t>(m_add_replay);
|
||||||
|
|
||||||
|
dz = DynamicZonesRepository::InsertOne(GetDatabase(), std::move(dz));
|
||||||
|
|
||||||
|
return dz.id;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool DynamicZoneBase::AddMember(const DynamicZoneMember& add_member)
|
bool DynamicZoneBase::AddMember(const DynamicZoneMember& add_member)
|
||||||
@@ -196,10 +204,9 @@ bool DynamicZoneBase::RemoveMember(const DynamicZoneMember& remove_member)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool DynamicZoneBase::SwapMember(
|
bool DynamicZoneBase::SwapMember(const DynamicZoneMember& add_member, const std::string& remove_name)
|
||||||
const DynamicZoneMember& add_member, const std::string& remove_char_name)
|
|
||||||
{
|
{
|
||||||
auto remove_member = GetMemberData(remove_char_name);
|
auto remove_member = GetMemberData(remove_name);
|
||||||
if (!add_member.IsValid() || !remove_member.IsValid())
|
if (!add_member.IsValid() || !remove_member.IsValid())
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
@@ -230,9 +237,18 @@ void DynamicZoneBase::RemoveAllMembers()
|
|||||||
|
|
||||||
void DynamicZoneBase::SaveMembers(const std::vector<DynamicZoneMember>& members)
|
void DynamicZoneBase::SaveMembers(const std::vector<DynamicZoneMember>& members)
|
||||||
{
|
{
|
||||||
|
if (members.empty())
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
LogDynamicZonesDetail("Saving [{}] member(s) for dz [{}]", members.size(), m_id);
|
LogDynamicZonesDetail("Saving [{}] member(s) for dz [{}]", members.size(), m_id);
|
||||||
|
|
||||||
m_members = members;
|
m_members = members;
|
||||||
|
if (m_members.size() > m_max_players)
|
||||||
|
{
|
||||||
|
m_members.resize(m_max_players);
|
||||||
|
}
|
||||||
|
|
||||||
// the lower level instance_list_players needs to be kept updated as well
|
// the lower level instance_list_players needs to be kept updated as well
|
||||||
std::vector<DynamicZoneMembersRepository::DynamicZoneMembers> insert_members;
|
std::vector<DynamicZoneMembersRepository::DynamicZoneMembers> insert_members;
|
||||||
@@ -242,12 +258,12 @@ void DynamicZoneBase::SaveMembers(const std::vector<DynamicZoneMember>& members)
|
|||||||
DynamicZoneMembersRepository::DynamicZoneMembers member_entry{};
|
DynamicZoneMembersRepository::DynamicZoneMembers member_entry{};
|
||||||
member_entry.dynamic_zone_id = m_id;
|
member_entry.dynamic_zone_id = m_id;
|
||||||
member_entry.character_id = member.id;
|
member_entry.character_id = member.id;
|
||||||
insert_members.emplace_back(member_entry);
|
insert_members.push_back(member_entry);
|
||||||
|
|
||||||
InstanceListPlayerRepository::InstanceListPlayer player_entry;
|
InstanceListPlayerRepository::InstanceListPlayer player_entry{};
|
||||||
player_entry.id = static_cast<int>(m_instance_id);
|
player_entry.id = m_instance_id;
|
||||||
player_entry.charid = static_cast<int>(member.id);
|
player_entry.charid = member.id;
|
||||||
insert_players.emplace_back(player_entry);
|
insert_players.push_back(player_entry);
|
||||||
}
|
}
|
||||||
|
|
||||||
DynamicZoneMembersRepository::InsertOrUpdateMany(GetDatabase(), insert_members);
|
DynamicZoneMembersRepository::InsertOrUpdateMany(GetDatabase(), insert_members);
|
||||||
@@ -339,6 +355,44 @@ void DynamicZoneBase::SetLeader(const DynamicZoneMember& new_leader, bool update
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void DynamicZoneBase::SetLocked(bool lock, bool update_db, DzLockMsg lock_msg, uint32_t color)
|
||||||
|
{
|
||||||
|
m_is_locked = lock;
|
||||||
|
|
||||||
|
if (update_db)
|
||||||
|
{
|
||||||
|
DynamicZonesRepository::UpdateLocked(GetDatabase(), m_id, lock);
|
||||||
|
|
||||||
|
ServerPacket pack(ServerOP_DzLock, sizeof(ServerDzLock_Struct));
|
||||||
|
auto buf = reinterpret_cast<ServerDzLock_Struct*>(pack.pBuffer);
|
||||||
|
buf->dz_id = GetID();
|
||||||
|
buf->sender_zone_id = GetCurrentZoneID();
|
||||||
|
buf->sender_instance_id = GetCurrentInstanceID();
|
||||||
|
buf->lock = m_is_locked;
|
||||||
|
buf->lock_msg = static_cast<uint8_t>(lock_msg);
|
||||||
|
buf->color = color;
|
||||||
|
SendServerPacket(&pack);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void DynamicZoneBase::SetReplayOnJoin(bool enabled, bool update_db)
|
||||||
|
{
|
||||||
|
m_add_replay = enabled;
|
||||||
|
|
||||||
|
if (update_db)
|
||||||
|
{
|
||||||
|
DynamicZonesRepository::UpdateReplayOnJoin(GetDatabase(), m_id, enabled);
|
||||||
|
|
||||||
|
ServerPacket pack(ServerOP_DzReplayOnJoin, sizeof(ServerDzBool_Struct));
|
||||||
|
auto buf = reinterpret_cast<ServerDzBool_Struct*>(pack.pBuffer);
|
||||||
|
buf->dz_id = GetID();
|
||||||
|
buf->sender_zone_id = GetCurrentZoneID();
|
||||||
|
buf->sender_instance_id = GetCurrentInstanceID();
|
||||||
|
buf->enabled = enabled;
|
||||||
|
SendServerPacket(&pack);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
uint32_t DynamicZoneBase::GetSecondsRemaining() const
|
uint32_t DynamicZoneBase::GetSecondsRemaining() const
|
||||||
{
|
{
|
||||||
auto remaining = std::chrono::duration_cast<std::chrono::seconds>(GetDurationRemaining()).count();
|
auto remaining = std::chrono::duration_cast<std::chrono::seconds>(GetDurationRemaining()).count();
|
||||||
@@ -478,13 +532,13 @@ void DynamicZoneBase::RemoveInternalMember(uint32_t character_id)
|
|||||||
), m_members.end());
|
), m_members.end());
|
||||||
}
|
}
|
||||||
|
|
||||||
bool DynamicZoneBase::HasMember(uint32_t character_id)
|
bool DynamicZoneBase::HasMember(uint32_t character_id) const
|
||||||
{
|
{
|
||||||
return std::any_of(m_members.begin(), m_members.end(),
|
return std::any_of(m_members.begin(), m_members.end(),
|
||||||
[&](const DynamicZoneMember& member) { return member.id == character_id; });
|
[&](const DynamicZoneMember& member) { return member.id == character_id; });
|
||||||
}
|
}
|
||||||
|
|
||||||
bool DynamicZoneBase::HasMember(const std::string& character_name)
|
bool DynamicZoneBase::HasMember(const std::string& character_name) const
|
||||||
{
|
{
|
||||||
return std::any_of(m_members.begin(), m_members.end(),
|
return std::any_of(m_members.begin(), m_members.end(),
|
||||||
[&](const DynamicZoneMember& member) {
|
[&](const DynamicZoneMember& member) {
|
||||||
@@ -590,35 +644,34 @@ std::string DynamicZoneBase::GetDynamicZoneTypeName(DynamicZoneType dz_type)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
EQ::Net::DynamicPacket DynamicZoneBase::GetSerializedDzPacket()
|
std::unique_ptr<ServerPacket> DynamicZoneBase::CreateServerPacket(uint16_t zone_id, uint16_t instance_id)
|
||||||
{
|
{
|
||||||
EQ::Net::DynamicPacket dyn_pack;
|
std::ostringstream ss = GetSerialized();
|
||||||
dyn_pack.PutSerialize(0, *this);
|
std::string_view sv = ss.view();
|
||||||
|
|
||||||
LogDynamicZonesDetail("Serialized server dz size [{}]", dyn_pack.Length());
|
auto pack_size = sizeof(ServerDzCreate_Struct) + sv.size();
|
||||||
return dyn_pack;
|
|
||||||
}
|
|
||||||
|
|
||||||
std::unique_ptr<ServerPacket> DynamicZoneBase::CreateServerDzCreatePacket(
|
|
||||||
uint16_t origin_zone_id, uint16_t origin_instance_id)
|
|
||||||
{
|
|
||||||
EQ::Net::DynamicPacket dyn_pack = GetSerializedDzPacket();
|
|
||||||
|
|
||||||
auto pack_size = sizeof(ServerDzCreateSerialized_Struct) + dyn_pack.Length();
|
|
||||||
auto pack = std::make_unique<ServerPacket>(ServerOP_DzCreated, static_cast<uint32_t>(pack_size));
|
auto pack = std::make_unique<ServerPacket>(ServerOP_DzCreated, static_cast<uint32_t>(pack_size));
|
||||||
auto buf = reinterpret_cast<ServerDzCreateSerialized_Struct*>(pack->pBuffer);
|
auto buf = reinterpret_cast<ServerDzCreate_Struct*>(pack->pBuffer);
|
||||||
buf->origin_zone_id = origin_zone_id;
|
buf->origin_zone_id = zone_id;
|
||||||
buf->origin_instance_id = origin_instance_id;
|
buf->origin_instance_id = instance_id;
|
||||||
buf->cereal_size = static_cast<uint32_t>(dyn_pack.Length());
|
buf->dz_id = GetID();
|
||||||
memcpy(buf->cereal_data, dyn_pack.Data(), dyn_pack.Length());
|
buf->cereal_size = static_cast<uint32_t>(sv.size());
|
||||||
|
memcpy(buf->cereal_data, sv.data(), sv.size());
|
||||||
|
|
||||||
return pack;
|
return pack;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DynamicZoneBase::LoadSerializedDzPacket(char* cereal_data, uint32_t cereal_size)
|
std::ostringstream DynamicZoneBase::GetSerialized()
|
||||||
{
|
{
|
||||||
LogDynamicZonesDetail("Deserializing server dz size [{}]", cereal_size);
|
std::ostringstream ss;
|
||||||
EQ::Util::MemoryStreamReader ss(cereal_data, cereal_size);
|
cereal::BinaryOutputArchive archive(ss);
|
||||||
|
archive(*this);
|
||||||
|
return ss;
|
||||||
|
}
|
||||||
|
|
||||||
|
void DynamicZoneBase::Unserialize(std::span<char> buf)
|
||||||
|
{
|
||||||
|
EQ::Util::MemoryStreamReader ss(buf.data(), buf.size());
|
||||||
cereal::BinaryInputArchive archive(ss);
|
cereal::BinaryInputArchive archive(ss);
|
||||||
archive(*this);
|
archive(*this);
|
||||||
}
|
}
|
||||||
@@ -647,3 +700,180 @@ void DynamicZoneBase::LoadTemplate(const DynamicZoneTemplatesRepository::Dynamic
|
|||||||
m_zonein.z = dz_template.zone_in_z;
|
m_zonein.z = dz_template.zone_in_z;
|
||||||
m_zonein.heading = dz_template.zone_in_h;
|
m_zonein.heading = dz_template.zone_in_h;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::vector<uint32_t> DynamicZoneBase::GetMemberIds()
|
||||||
|
{
|
||||||
|
std::vector<uint32_t> ids;
|
||||||
|
ids.reserve(m_members.size());
|
||||||
|
for (const auto& member : m_members)
|
||||||
|
{
|
||||||
|
ids.push_back(member.id);
|
||||||
|
}
|
||||||
|
return ids;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool DynamicZoneBase::HasLockout(const std::string& event)
|
||||||
|
{
|
||||||
|
return std::ranges::any_of(m_lockouts, [&](const auto& l) { return l.IsEvent(event); });
|
||||||
|
}
|
||||||
|
|
||||||
|
bool DynamicZoneBase::HasReplayLockout()
|
||||||
|
{
|
||||||
|
return HasLockout(DzLockout::ReplayTimer);
|
||||||
|
}
|
||||||
|
|
||||||
|
void DynamicZoneBase::AddLockout(const std::string& event, uint32_t seconds)
|
||||||
|
{
|
||||||
|
auto lockout = DzLockout::Create(m_name, event, seconds, m_uuid);
|
||||||
|
AddLockout(lockout);
|
||||||
|
}
|
||||||
|
|
||||||
|
void DynamicZoneBase::AddLockout(const DzLockout& lockout, bool members_only)
|
||||||
|
{
|
||||||
|
if (!members_only)
|
||||||
|
{
|
||||||
|
DynamicZoneLockoutsRepository::InsertLockouts(GetDatabase(), GetID(), { lockout });
|
||||||
|
}
|
||||||
|
|
||||||
|
CharacterExpeditionLockoutsRepository::InsertLockout(GetDatabase(), GetMemberIds(), lockout);
|
||||||
|
|
||||||
|
HandleLockoutUpdate(lockout, false, members_only);
|
||||||
|
SendServerPacket(CreateLockoutPacket(lockout, false, members_only).get());
|
||||||
|
}
|
||||||
|
|
||||||
|
void DynamicZoneBase::AddLockoutDuration(const std::string& event, int seconds, bool members_only)
|
||||||
|
{
|
||||||
|
auto lockout = DzLockout::Create(m_name, event, std::max(0, seconds), m_uuid);
|
||||||
|
|
||||||
|
// lockout has unsigned duration, pass original seconds to support reducing existing timers
|
||||||
|
int secs = static_cast<int>(seconds * RuleR(Expedition, LockoutDurationMultiplier));
|
||||||
|
CharacterExpeditionLockoutsRepository::AddLockoutDuration(GetDatabase(), GetMemberIds(), lockout, secs);
|
||||||
|
|
||||||
|
HandleLockoutDuration(lockout, seconds, members_only, true);
|
||||||
|
SendServerPacket(CreateLockoutDurationPacket(lockout, seconds, members_only).get());
|
||||||
|
}
|
||||||
|
|
||||||
|
void DynamicZoneBase::UpdateLockoutDuration(const std::string& event, uint32_t seconds, bool members_only)
|
||||||
|
{
|
||||||
|
// some live expeditions update existing lockout timers during progression
|
||||||
|
auto it = std::ranges::find_if(m_lockouts, [&](const auto& l) { return l.IsEvent(event); });
|
||||||
|
if (it != m_lockouts.end())
|
||||||
|
{
|
||||||
|
seconds = static_cast<uint32_t>(seconds * RuleR(Expedition, LockoutDurationMultiplier));
|
||||||
|
DzLockout lockout(m_uuid, m_name, event, it->GetStartTime() + seconds, seconds);
|
||||||
|
AddLockout(lockout, members_only);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void DynamicZoneBase::RemoveLockout(const std::string& event)
|
||||||
|
{
|
||||||
|
DynamicZoneLockoutsRepository::DeleteWhere(GetDatabase(), fmt::format(
|
||||||
|
"dynamic_zone_id = {} AND event_name = '{}'", GetID(), Strings::Escape(event)));
|
||||||
|
|
||||||
|
CharacterExpeditionLockoutsRepository::DeleteWhere(GetDatabase(), fmt::format(
|
||||||
|
"character_id IN ({}) AND expedition_name = '{}' AND event_name = '{}'",
|
||||||
|
fmt::join(GetMemberIds(), ","), Strings::Escape(m_name), Strings::Escape(event)));
|
||||||
|
|
||||||
|
DzLockout lockout{m_uuid, m_name, event, 0, 0};
|
||||||
|
HandleLockoutUpdate(lockout, true, false);
|
||||||
|
SendServerPacket(CreateLockoutPacket(lockout, true).get());
|
||||||
|
}
|
||||||
|
|
||||||
|
void DynamicZoneBase::HandleLockoutUpdate(const DzLockout& lockout, bool remove, bool members_only)
|
||||||
|
{
|
||||||
|
if (!members_only)
|
||||||
|
{
|
||||||
|
std::erase_if(m_lockouts, [&](const auto& l) { return l.IsEvent(lockout.Event()); });
|
||||||
|
if (!remove)
|
||||||
|
{
|
||||||
|
m_lockouts.push_back(lockout);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void DynamicZoneBase::HandleLockoutDuration(const DzLockout& lockout, int seconds, bool members_only, bool insert_db)
|
||||||
|
{
|
||||||
|
if (!members_only)
|
||||||
|
{
|
||||||
|
auto it = std::ranges::find_if(m_lockouts, [&](const auto& l) { return l.IsEvent(lockout.Event()); });
|
||||||
|
if (it != m_lockouts.end())
|
||||||
|
{
|
||||||
|
it->AddLockoutTime(seconds);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
it = m_lockouts.insert(m_lockouts.end(), lockout);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (insert_db)
|
||||||
|
{
|
||||||
|
DynamicZoneLockoutsRepository::InsertLockouts(GetDatabase(), GetID(), { *it });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
std::unique_ptr<ServerPacket> DynamicZoneBase::CreateLockoutPacket(const DzLockout& lockout, bool remove, bool members_only) const
|
||||||
|
{
|
||||||
|
uint32_t pack_size = sizeof(ServerDzLockout_Struct);
|
||||||
|
auto pack = std::make_unique<ServerPacket>(ServerOP_DzLockout, pack_size);
|
||||||
|
auto buf = reinterpret_cast<ServerDzLockout_Struct*>(pack->pBuffer);
|
||||||
|
buf->dz_id = GetID();
|
||||||
|
buf->expire_time = lockout.GetExpireTime();
|
||||||
|
buf->duration = lockout.GetDuration();
|
||||||
|
buf->sender_zone_id = GetCurrentZoneID();
|
||||||
|
buf->sender_instance_id = GetCurrentInstanceID();
|
||||||
|
buf->remove = remove;
|
||||||
|
buf->members_only = members_only;
|
||||||
|
strn0cpy(buf->event_name, lockout.Event().c_str(), sizeof(buf->event_name));
|
||||||
|
return pack;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::unique_ptr<ServerPacket> DynamicZoneBase::CreateLockoutDurationPacket(const DzLockout& lockout, int seconds, bool members_only) const
|
||||||
|
{
|
||||||
|
uint32_t pack_size = sizeof(ServerDzLockout_Struct);
|
||||||
|
auto pack = std::make_unique<ServerPacket>(ServerOP_DzLockoutDuration, pack_size);
|
||||||
|
auto buf = reinterpret_cast<ServerDzLockout_Struct*>(pack->pBuffer);
|
||||||
|
buf->dz_id = GetID();
|
||||||
|
buf->expire_time = lockout.GetExpireTime();
|
||||||
|
buf->duration = lockout.GetDuration();
|
||||||
|
buf->sender_zone_id = GetCurrentZoneID();
|
||||||
|
buf->sender_instance_id = GetCurrentInstanceID();
|
||||||
|
buf->members_only = members_only;
|
||||||
|
buf->seconds = seconds;
|
||||||
|
strn0cpy(buf->event_name, lockout.Event().c_str(), sizeof(buf->event_name));
|
||||||
|
return pack;
|
||||||
|
}
|
||||||
|
|
||||||
|
void DynamicZoneBase::SyncCharacterLockouts(uint32_t char_id, std::vector<DzLockout>& lockouts)
|
||||||
|
{
|
||||||
|
// adds missing event lockouts to client for this expedition and updates
|
||||||
|
// client timers that are both shorter and from another expedition
|
||||||
|
bool modified = false;
|
||||||
|
|
||||||
|
for (const auto& lockout : m_lockouts)
|
||||||
|
{
|
||||||
|
if (lockout.IsReplay() || lockout.IsExpired() || lockout.UUID() != m_uuid)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto it = std::find_if(lockouts.begin(), lockouts.end(), [&](const DzLockout& l) { return l.IsSame(lockout); });
|
||||||
|
if (it == lockouts.end())
|
||||||
|
{
|
||||||
|
modified = true;
|
||||||
|
lockouts.push_back(lockout); // insert missing
|
||||||
|
}
|
||||||
|
else if (it->GetSecondsRemaining() < lockout.GetSecondsRemaining() && it->UUID() != m_uuid)
|
||||||
|
{
|
||||||
|
// only update lockout timer not uuid so loot event apis still work
|
||||||
|
modified = true;
|
||||||
|
it->SetDuration(lockout.GetDuration());
|
||||||
|
it->SetExpireTime(lockout.GetExpireTime());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (modified)
|
||||||
|
{
|
||||||
|
CharacterExpeditionLockoutsRepository::InsertLockouts(GetDatabase(), char_id, lockouts);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
+68
-14
@@ -1,8 +1,8 @@
|
|||||||
#ifndef COMMON_DYNAMIC_ZONE_BASE_H
|
#ifndef COMMON_DYNAMIC_ZONE_BASE_H
|
||||||
#define COMMON_DYNAMIC_ZONE_BASE_H
|
#define COMMON_DYNAMIC_ZONE_BASE_H
|
||||||
|
|
||||||
|
#include "dynamic_zone_lockout.h"
|
||||||
#include "eq_constants.h"
|
#include "eq_constants.h"
|
||||||
#include "net/packet.h"
|
|
||||||
#include "repositories/dynamic_zones_repository.h"
|
#include "repositories/dynamic_zones_repository.h"
|
||||||
#include "repositories/dynamic_zone_members_repository.h"
|
#include "repositories/dynamic_zone_members_repository.h"
|
||||||
#include "repositories/dynamic_zone_templates_repository.h"
|
#include "repositories/dynamic_zone_templates_repository.h"
|
||||||
@@ -10,12 +10,40 @@
|
|||||||
#include <chrono>
|
#include <chrono>
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
#include <span>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
class Database;
|
class Database;
|
||||||
class ServerPacket;
|
class ServerPacket;
|
||||||
|
|
||||||
|
// message string 8312 added in September 08 2020 Test patch (used by both dz and shared tasks)
|
||||||
|
inline constexpr char DzNotAllAdded[] = "Not all players in your {0} were added to the {1}. The {1} can take a maximum of {2} players, and your {0} has {3}.";
|
||||||
|
|
||||||
|
enum class DzLockMsg : uint8_t
|
||||||
|
{
|
||||||
|
None = 0, Close, Begin
|
||||||
|
};
|
||||||
|
|
||||||
|
enum class DynamicZoneType
|
||||||
|
{
|
||||||
|
None = 0,
|
||||||
|
Expedition,
|
||||||
|
Tutorial,
|
||||||
|
Task,
|
||||||
|
Mission, // Shared Task
|
||||||
|
Quest
|
||||||
|
};
|
||||||
|
|
||||||
|
enum class DynamicZoneMemberStatus
|
||||||
|
{
|
||||||
|
Unknown = 0,
|
||||||
|
Online,
|
||||||
|
Offline,
|
||||||
|
InDynamicZone,
|
||||||
|
LinkDead
|
||||||
|
};
|
||||||
|
|
||||||
struct DynamicZoneMember
|
struct DynamicZoneMember
|
||||||
{
|
{
|
||||||
uint32_t id = 0;
|
uint32_t id = 0;
|
||||||
@@ -93,6 +121,7 @@ public:
|
|||||||
const std::string& GetName() const { return m_name; }
|
const std::string& GetName() const { return m_name; }
|
||||||
const std::string& GetUUID() const { return m_uuid; }
|
const std::string& GetUUID() const { return m_uuid; }
|
||||||
const DynamicZoneMember& GetLeader() const { return m_leader; }
|
const DynamicZoneMember& GetLeader() const { return m_leader; }
|
||||||
|
const std::vector<DzLockout>& GetLockouts() const { return m_lockouts; }
|
||||||
const std::vector<DynamicZoneMember>& GetMembers() const { return m_members; }
|
const std::vector<DynamicZoneMember>& GetMembers() const { return m_members; }
|
||||||
const DynamicZoneLocation& GetCompassLocation() const { return m_compass; }
|
const DynamicZoneLocation& GetCompassLocation() const { return m_compass; }
|
||||||
const DynamicZoneLocation& GetSafeReturnLocation() const { return m_safereturn; }
|
const DynamicZoneLocation& GetSafeReturnLocation() const { return m_safereturn; }
|
||||||
@@ -104,31 +133,34 @@ public:
|
|||||||
uint32_t GetDatabaseMemberCount();
|
uint32_t GetDatabaseMemberCount();
|
||||||
DynamicZoneMember GetMemberData(uint32_t character_id);
|
DynamicZoneMember GetMemberData(uint32_t character_id);
|
||||||
DynamicZoneMember GetMemberData(const std::string& character_name);
|
DynamicZoneMember GetMemberData(const std::string& character_name);
|
||||||
EQ::Net::DynamicPacket GetSerializedDzPacket();
|
std::vector<uint32_t> GetMemberIds();
|
||||||
|
std::ostringstream GetSerialized();
|
||||||
bool HasDatabaseMember(uint32_t character_id);
|
bool HasDatabaseMember(uint32_t character_id);
|
||||||
bool HasMember(uint32_t character_id);
|
bool HasMember(uint32_t character_id) const;
|
||||||
bool HasMember(const std::string& character_name);
|
bool HasMember(const std::string& character_name) const;
|
||||||
bool HasMembers() const { return !m_members.empty(); }
|
bool HasMembers() const { return !m_members.empty(); }
|
||||||
bool HasZoneInLocation() const { return m_has_zonein; }
|
bool HasZoneInLocation() const { return m_has_zonein; }
|
||||||
|
bool IsExpedition() const { return m_type == DynamicZoneType::Expedition; }
|
||||||
bool IsExpired() const { return m_expire_time < std::chrono::system_clock::now(); }
|
bool IsExpired() const { return m_expire_time < std::chrono::system_clock::now(); }
|
||||||
bool IsInstanceID(uint32_t instance_id) const { return (m_instance_id != 0 && m_instance_id == instance_id); }
|
bool IsInstanceID(uint32_t instance_id) const { return (m_instance_id != 0 && m_instance_id == instance_id); }
|
||||||
|
bool IsLocked() const { return m_is_locked; }
|
||||||
bool IsValid() const { return m_instance_id != 0; }
|
bool IsValid() const { return m_instance_id != 0; }
|
||||||
bool IsSameDz(uint32_t zone_id, uint32_t instance_id) const { return zone_id == m_zone_id && instance_id == m_instance_id; }
|
bool IsSameDz(uint32_t zone_id, uint32_t instance_id) const { return zone_id == m_zone_id && instance_id == m_instance_id; }
|
||||||
void LoadSerializedDzPacket(char* cereal_data, uint32_t cereal_size);
|
|
||||||
void LoadTemplate(const DynamicZoneTemplatesRepository::DynamicZoneTemplates& dz_template);
|
void LoadTemplate(const DynamicZoneTemplatesRepository::DynamicZoneTemplates& dz_template);
|
||||||
void RemoveAllMembers();
|
void RemoveAllMembers();
|
||||||
bool RemoveMember(uint32_t character_id);
|
bool RemoveMember(uint32_t character_id);
|
||||||
bool RemoveMember(const std::string& character_name);
|
bool RemoveMember(const std::string& character_name);
|
||||||
bool RemoveMember(const DynamicZoneMember& remove_member);
|
bool RemoveMember(const DynamicZoneMember& remove_member);
|
||||||
void SaveMembers(const std::vector<DynamicZoneMember>& members);
|
|
||||||
void SetCompass(const DynamicZoneLocation& location, bool update_db = false);
|
void SetCompass(const DynamicZoneLocation& location, bool update_db = false);
|
||||||
void SetCompass(uint32_t zone_id, float x, float y, float z, bool update_db = false);
|
void SetCompass(uint32_t zone_id, float x, float y, float z, bool update_db = false);
|
||||||
void SetDuration(uint32_t seconds) { m_duration = std::chrono::seconds(seconds); }
|
void SetDuration(uint32_t seconds) { m_duration = std::chrono::seconds(seconds); }
|
||||||
void SetLeader(const DynamicZoneMember& leader, bool update_db = false);
|
void SetLeader(const DynamicZoneMember& leader, bool update_db = false);
|
||||||
|
void SetLocked(bool lock, bool update_db = false, DzLockMsg lock_msg = DzLockMsg::None, uint32_t color = Chat::Yellow);
|
||||||
void SetMaxPlayers(uint32_t max_players) { m_max_players = max_players; }
|
void SetMaxPlayers(uint32_t max_players) { m_max_players = max_players; }
|
||||||
void SetMemberStatus(uint32_t character_id, DynamicZoneMemberStatus status);
|
void SetMemberStatus(uint32_t character_id, DynamicZoneMemberStatus status);
|
||||||
void SetMinPlayers(uint32_t min_players) { m_min_players = min_players; }
|
void SetMinPlayers(uint32_t min_players) { m_min_players = min_players; }
|
||||||
void SetName(const std::string& name) { m_name = name; }
|
void SetName(const std::string& name) { m_name = name; }
|
||||||
|
void SetReplayOnJoin(bool enabled, bool update_db = false);
|
||||||
void SetSafeReturn(const DynamicZoneLocation& location, bool update_db = false);
|
void SetSafeReturn(const DynamicZoneLocation& location, bool update_db = false);
|
||||||
void SetSafeReturn(uint32_t zone_id, float x, float y, float z, float heading, bool update_db = false);
|
void SetSafeReturn(uint32_t zone_id, float x, float y, float z, float heading, bool update_db = false);
|
||||||
void SetSwitchID(int dz_switch_id, bool update_db = false);
|
void SetSwitchID(int dz_switch_id, bool update_db = false);
|
||||||
@@ -136,34 +168,48 @@ public:
|
|||||||
void SetUUID(std::string uuid) { m_uuid = std::move(uuid); }
|
void SetUUID(std::string uuid) { m_uuid = std::move(uuid); }
|
||||||
void SetZoneInLocation(const DynamicZoneLocation& location, bool update_db = false);
|
void SetZoneInLocation(const DynamicZoneLocation& location, bool update_db = false);
|
||||||
void SetZoneInLocation(float x, float y, float z, float heading, bool update_db = false);
|
void SetZoneInLocation(float x, float y, float z, float heading, bool update_db = false);
|
||||||
bool SwapMember(const DynamicZoneMember& add_member, const std::string& remove_char_name);
|
bool SwapMember(const DynamicZoneMember& add_member, const std::string& remove_name);
|
||||||
|
|
||||||
|
void AddLockout(const std::string& event, uint32_t seconds);
|
||||||
|
void AddLockoutDuration(const std::string& event, int seconds, bool members_only = true);
|
||||||
|
bool HasLockout(const std::string& event);
|
||||||
|
bool HasReplayLockout();
|
||||||
|
void RemoveLockout(const std::string& event);
|
||||||
|
void SyncCharacterLockouts(uint32_t char_id, std::vector<DzLockout>& lockouts);
|
||||||
|
void UpdateLockoutDuration(const std::string& event, uint32_t seconds, bool members_only = true);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual uint16_t GetCurrentInstanceID() { return 0; }
|
virtual uint16_t GetCurrentInstanceID() const { return 0; }
|
||||||
virtual uint16_t GetCurrentZoneID() { return 0; }
|
virtual uint16_t GetCurrentZoneID() const { return 0; }
|
||||||
virtual Database& GetDatabase() = 0;
|
virtual Database& GetDatabase() = 0;
|
||||||
|
virtual void HandleLockoutDuration(const DzLockout& lockout, int seconds, bool members_only, bool insert_db);
|
||||||
|
virtual void HandleLockoutUpdate(const DzLockout& lockout, bool remove, bool members_only);
|
||||||
virtual void ProcessCompassChange(const DynamicZoneLocation& location) { m_compass = location; }
|
virtual void ProcessCompassChange(const DynamicZoneLocation& location) { m_compass = location; }
|
||||||
virtual void ProcessMemberAddRemove(const DynamicZoneMember& member, bool removed);
|
virtual void ProcessMemberAddRemove(const DynamicZoneMember& member, bool removed);
|
||||||
virtual bool ProcessMemberStatusChange(uint32_t member_id, DynamicZoneMemberStatus status);
|
virtual bool ProcessMemberStatusChange(uint32_t character_id, DynamicZoneMemberStatus status);
|
||||||
virtual void ProcessRemoveAllMembers(bool silent = false) { m_members.clear(); }
|
virtual void ProcessRemoveAllMembers() { m_members.clear(); }
|
||||||
virtual void ProcessSetSwitchID(int dz_switch_id) { m_dz_switch_id = dz_switch_id; }
|
virtual void ProcessSetSwitchID(int dz_switch_id) { m_dz_switch_id = dz_switch_id; }
|
||||||
virtual bool SendServerPacket(ServerPacket* packet) = 0;
|
virtual bool SendServerPacket(ServerPacket* packet) = 0;
|
||||||
|
|
||||||
|
void AddLockout(const DzLockout& lockout, bool members_only = false);
|
||||||
void AddInternalMember(const DynamicZoneMember& member);
|
void AddInternalMember(const DynamicZoneMember& member);
|
||||||
uint32_t Create();
|
uint32_t Create();
|
||||||
uint32_t CreateInstance();
|
uint32_t CreateInstance();
|
||||||
void LoadRepositoryResult(DynamicZonesRepository::DynamicZoneInstance&& dz_entry);
|
void LoadRepositoryResult(DynamicZonesRepository::DynamicZoneInstance&& dz_entry);
|
||||||
void RemoveInternalMember(uint32_t character_id);
|
void RemoveInternalMember(uint32_t character_id);
|
||||||
|
void SaveMembers(const std::vector<DynamicZoneMember>& members);
|
||||||
uint32_t SaveToDatabase();
|
uint32_t SaveToDatabase();
|
||||||
bool SetInternalMemberStatus(uint32_t character_id, DynamicZoneMemberStatus status);
|
bool SetInternalMemberStatus(uint32_t character_id, DynamicZoneMemberStatus status);
|
||||||
|
|
||||||
std::unique_ptr<ServerPacket> CreateServerDzCreatePacket(uint16_t origin_zone_id, uint16_t origin_instance_id);
|
std::unique_ptr<ServerPacket> CreateServerPacket(uint16_t zone_id, uint16_t instance_id);
|
||||||
std::unique_ptr<ServerPacket> CreateServerDzLocationPacket(uint16_t server_opcode, const DynamicZoneLocation& location);
|
std::unique_ptr<ServerPacket> CreateServerDzLocationPacket(uint16_t server_opcode, const DynamicZoneLocation& location);
|
||||||
std::unique_ptr<ServerPacket> CreateServerDzSwitchIDPacket();
|
std::unique_ptr<ServerPacket> CreateServerDzSwitchIDPacket();
|
||||||
std::unique_ptr<ServerPacket> CreateServerMemberAddRemovePacket(const DynamicZoneMember& member, bool removed);
|
std::unique_ptr<ServerPacket> CreateServerMemberAddRemovePacket(const DynamicZoneMember& member, bool removed);
|
||||||
std::unique_ptr<ServerPacket> CreateServerMemberStatusPacket(uint32_t character_id, DynamicZoneMemberStatus status);
|
std::unique_ptr<ServerPacket> CreateServerMemberStatusPacket(uint32_t character_id, DynamicZoneMemberStatus status);
|
||||||
std::unique_ptr<ServerPacket> CreateServerMemberSwapPacket(const DynamicZoneMember& remove_member, const DynamicZoneMember& add_member);
|
std::unique_ptr<ServerPacket> CreateServerMemberSwapPacket(const DynamicZoneMember& remove_member, const DynamicZoneMember& add_member);
|
||||||
std::unique_ptr<ServerPacket> CreateServerRemoveAllMembersPacket();
|
std::unique_ptr<ServerPacket> CreateServerRemoveAllMembersPacket();
|
||||||
|
std::unique_ptr<ServerPacket> CreateLockoutPacket(const DzLockout& lockout, bool remove, bool members_only = false) const;
|
||||||
|
std::unique_ptr<ServerPacket> CreateLockoutDurationPacket(const DzLockout& lockout, int seconds, bool members_only = false) const;
|
||||||
|
|
||||||
uint32_t m_id = 0;
|
uint32_t m_id = 0;
|
||||||
uint32_t m_zone_id = 0;
|
uint32_t m_zone_id = 0;
|
||||||
@@ -175,6 +221,8 @@ protected:
|
|||||||
bool m_never_expires = false;
|
bool m_never_expires = false;
|
||||||
bool m_has_zonein = false;
|
bool m_has_zonein = false;
|
||||||
bool m_has_member_statuses = false;
|
bool m_has_member_statuses = false;
|
||||||
|
bool m_is_locked = false;
|
||||||
|
bool m_add_replay = true;
|
||||||
std::string m_name;
|
std::string m_name;
|
||||||
std::string m_uuid;
|
std::string m_uuid;
|
||||||
DynamicZoneMember m_leader;
|
DynamicZoneMember m_leader;
|
||||||
@@ -182,12 +230,15 @@ protected:
|
|||||||
DynamicZoneLocation m_compass;
|
DynamicZoneLocation m_compass;
|
||||||
DynamicZoneLocation m_safereturn;
|
DynamicZoneLocation m_safereturn;
|
||||||
DynamicZoneLocation m_zonein;
|
DynamicZoneLocation m_zonein;
|
||||||
std::chrono::seconds m_duration;
|
std::chrono::seconds m_duration = {};
|
||||||
std::chrono::time_point<std::chrono::system_clock> m_start_time;
|
std::chrono::time_point<std::chrono::system_clock> m_start_time;
|
||||||
std::chrono::time_point<std::chrono::system_clock> m_expire_time;
|
std::chrono::time_point<std::chrono::system_clock> m_expire_time;
|
||||||
std::vector<DynamicZoneMember> m_members;
|
std::vector<DynamicZoneMember> m_members;
|
||||||
|
std::vector<DzLockout> m_lockouts;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
void Unserialize(std::span<char> buf);
|
||||||
|
|
||||||
template<class Archive>
|
template<class Archive>
|
||||||
void serialize(Archive& archive)
|
void serialize(Archive& archive)
|
||||||
{
|
{
|
||||||
@@ -202,6 +253,8 @@ public:
|
|||||||
m_never_expires,
|
m_never_expires,
|
||||||
m_has_zonein,
|
m_has_zonein,
|
||||||
m_has_member_statuses,
|
m_has_member_statuses,
|
||||||
|
m_is_locked,
|
||||||
|
m_add_replay,
|
||||||
m_name,
|
m_name,
|
||||||
m_uuid,
|
m_uuid,
|
||||||
m_leader,
|
m_leader,
|
||||||
@@ -212,7 +265,8 @@ public:
|
|||||||
m_duration,
|
m_duration,
|
||||||
m_start_time,
|
m_start_time,
|
||||||
m_expire_time,
|
m_expire_time,
|
||||||
m_members
|
m_members,
|
||||||
|
m_lockouts
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -0,0 +1,93 @@
|
|||||||
|
#include "dynamic_zone_lockout.h"
|
||||||
|
#include "strings.h"
|
||||||
|
#include "rulesys.h"
|
||||||
|
#include "util/uuid.h"
|
||||||
|
#include <fmt/format.h>
|
||||||
|
#include <fmt/ranges.h>
|
||||||
|
#include <cereal/types/chrono.hpp>
|
||||||
|
|
||||||
|
DzLockout::DzLockout(std::string uuid, std::string expedition, std::string event, uint64_t expire_time, uint32_t duration)
|
||||||
|
: m_uuid(std::move(uuid))
|
||||||
|
, m_name(std::move(expedition))
|
||||||
|
, m_event(std::move(event))
|
||||||
|
, m_expire_time(std::chrono::system_clock::from_time_t(expire_time))
|
||||||
|
, m_duration(duration)
|
||||||
|
{
|
||||||
|
m_is_replay = m_event == ReplayTimer;
|
||||||
|
}
|
||||||
|
|
||||||
|
DzLockout::DzLockout(std::string_view name, BaseDynamicZoneLockoutsRepository::DynamicZoneLockouts&& lockout)
|
||||||
|
: m_uuid(std::move(lockout.from_expedition_uuid))
|
||||||
|
, m_name(name)
|
||||||
|
, m_event(std::move(lockout.event_name))
|
||||||
|
, m_expire_time(std::chrono::system_clock::from_time_t(lockout.expire_time))
|
||||||
|
, m_duration(lockout.duration)
|
||||||
|
{
|
||||||
|
m_is_replay = m_event == ReplayTimer;
|
||||||
|
}
|
||||||
|
|
||||||
|
DzLockout DzLockout::Create(const std::string& expedition, const std::string& event, uint32_t seconds, std::string uuid)
|
||||||
|
{
|
||||||
|
seconds = static_cast<uint32_t>(seconds * RuleR(Expedition, LockoutDurationMultiplier));
|
||||||
|
|
||||||
|
if (uuid.empty())
|
||||||
|
{
|
||||||
|
uuid = EQ::Util::UUID::Generate().ToString();
|
||||||
|
}
|
||||||
|
|
||||||
|
DzLockout lockout{uuid, expedition, event, 0, seconds};
|
||||||
|
lockout.Reset(); // sets expire time
|
||||||
|
return lockout;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint32_t DzLockout::GetSecondsRemaining() const
|
||||||
|
{
|
||||||
|
auto now = std::chrono::system_clock::now();
|
||||||
|
if (m_expire_time > now)
|
||||||
|
{
|
||||||
|
auto remaining = m_expire_time - now;
|
||||||
|
return static_cast<uint32_t>(std::chrono::duration_cast<std::chrono::seconds>(remaining).count());
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
DzLockout::TimeStrings DzLockout::GetTimeRemainingStrs() const
|
||||||
|
{
|
||||||
|
auto seconds = GetSecondsRemaining();
|
||||||
|
return DzLockout::TimeStrings{
|
||||||
|
fmt::format_int(seconds / 86400).str(), // days
|
||||||
|
fmt::format_int(seconds / 3600 % 24).str(), // hours
|
||||||
|
fmt::format_int(seconds / 60 % 60).str(), // minutes
|
||||||
|
fmt::format_int(seconds % 60).str() // seconds
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
bool DzLockout::IsSame(const DzLockout& other) const
|
||||||
|
{
|
||||||
|
return other.IsSame(m_name, m_event);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool DzLockout::IsSame(const std::string& expedition, const std::string& event) const
|
||||||
|
{
|
||||||
|
return m_name == expedition && m_event == event;
|
||||||
|
}
|
||||||
|
|
||||||
|
void DzLockout::AddLockoutTime(int seconds)
|
||||||
|
{
|
||||||
|
seconds = static_cast<int>(seconds * RuleR(Expedition, LockoutDurationMultiplier));
|
||||||
|
|
||||||
|
auto new_duration = std::max(0, static_cast<int>(m_duration.count()) + seconds);
|
||||||
|
|
||||||
|
auto start_time = m_expire_time - m_duration;
|
||||||
|
m_duration = std::chrono::seconds(new_duration);
|
||||||
|
m_expire_time = start_time + m_duration;
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
void DzLockout::serialize(T& archive)
|
||||||
|
{
|
||||||
|
archive(m_is_replay, m_uuid, m_name, m_event, m_duration, m_expire_time);
|
||||||
|
}
|
||||||
|
|
||||||
|
template void DzLockout::serialize(cereal::BinaryOutputArchive&);
|
||||||
|
template void DzLockout::serialize(cereal::BinaryInputArchive&);
|
||||||
@@ -0,0 +1,56 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <chrono>
|
||||||
|
#include <string>
|
||||||
|
#include "repositories/base/base_dynamic_zone_lockouts_repository.h"
|
||||||
|
|
||||||
|
class DzLockout
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
DzLockout() = default;
|
||||||
|
DzLockout(std::string uuid, std::string expedition, std::string event, uint64_t expire_time, uint32_t duration);
|
||||||
|
DzLockout(std::string_view name, BaseDynamicZoneLockoutsRepository::DynamicZoneLockouts&& lockout);
|
||||||
|
|
||||||
|
static constexpr char ReplayTimer[] = "Replay Timer";
|
||||||
|
|
||||||
|
static DzLockout Create(const std::string& expedition, const std::string& event, uint32_t seconds, std::string uuid = {});
|
||||||
|
|
||||||
|
struct TimeStrings
|
||||||
|
{
|
||||||
|
std::string days;
|
||||||
|
std::string hours;
|
||||||
|
std::string mins;
|
||||||
|
std::string secs;
|
||||||
|
};
|
||||||
|
|
||||||
|
void AddLockoutTime(int seconds);
|
||||||
|
uint32_t GetDuration() const { return static_cast<uint32_t>(m_duration.count()); }
|
||||||
|
uint64_t GetExpireTime() const { return std::chrono::system_clock::to_time_t(m_expire_time); }
|
||||||
|
uint64_t GetStartTime() const { return std::chrono::system_clock::to_time_t(m_expire_time - m_duration); }
|
||||||
|
uint32_t GetSecondsRemaining() const;
|
||||||
|
TimeStrings GetTimeRemainingStrs() const;
|
||||||
|
const std::string& DzName() const { return m_name; }
|
||||||
|
const std::string& Event() const { return m_event; }
|
||||||
|
const std::string& UUID() const { return m_uuid; }
|
||||||
|
bool IsEvent(std::string_view event) const { return m_event == event; }
|
||||||
|
bool IsExpired() const { return GetSecondsRemaining() == 0; }
|
||||||
|
bool IsReplay() const { return m_is_replay; }
|
||||||
|
bool IsSame(const DzLockout& other) const;
|
||||||
|
bool IsSame(const std::string& expedition, const std::string& event) const;
|
||||||
|
bool IsUUID(const std::string& uuid) const { return uuid == m_uuid; }
|
||||||
|
void Reset() { m_expire_time = std::chrono::system_clock::now() + m_duration; }
|
||||||
|
void SetDuration(uint32_t seconds) { m_duration = std::chrono::seconds(seconds); }
|
||||||
|
void SetExpireTime(uint64_t expire_time) { m_expire_time = std::chrono::system_clock::from_time_t(expire_time); }
|
||||||
|
void SetUUID(const std::string& uuid) { m_uuid = uuid; }
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
void serialize(T& archive);
|
||||||
|
|
||||||
|
private:
|
||||||
|
bool m_is_replay = false;
|
||||||
|
std::string m_uuid; // dz received in
|
||||||
|
std::string m_name;
|
||||||
|
std::string m_event;
|
||||||
|
std::chrono::seconds m_duration = {};
|
||||||
|
std::chrono::time_point<std::chrono::system_clock> m_expire_time;
|
||||||
|
};
|
||||||
+35
-23
@@ -140,29 +140,6 @@ std::string EQ::constants::GetLanguageName(uint8 language_id)
|
|||||||
return EQ::constants::GetLanguageMap().find(language_id)->second;
|
return EQ::constants::GetLanguageMap().find(language_id)->second;
|
||||||
}
|
}
|
||||||
|
|
||||||
const std::map<uint32, std::string>& EQ::constants::GetLDoNThemeMap()
|
|
||||||
{
|
|
||||||
static const std::map<uint32, std::string> ldon_theme_map = {
|
|
||||||
{ LDoNThemes::Unused, "Unused" },
|
|
||||||
{ LDoNThemes::GUK, "Deepest Guk" },
|
|
||||||
{ LDoNThemes::MIR, "Miragul's Menagerie" },
|
|
||||||
{ LDoNThemes::MMC, "Mistmoore Catacombs" },
|
|
||||||
{ LDoNThemes::RUJ, "Rujarkian Hills" },
|
|
||||||
{ LDoNThemes::TAK, "Takish-Hiz" },
|
|
||||||
};
|
|
||||||
|
|
||||||
return ldon_theme_map;
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string EQ::constants::GetLDoNThemeName(uint32 theme_id)
|
|
||||||
{
|
|
||||||
if (!EQ::ValueWithin(theme_id, LDoNThemes::Unused, LDoNThemes::TAK)) {
|
|
||||||
return std::string();
|
|
||||||
}
|
|
||||||
|
|
||||||
return EQ::constants::GetLDoNThemeMap().find(theme_id)->second;
|
|
||||||
}
|
|
||||||
|
|
||||||
const std::map<int8, std::string>& EQ::constants::GetFlyModeMap()
|
const std::map<int8, std::string>& EQ::constants::GetFlyModeMap()
|
||||||
{
|
{
|
||||||
static const std::map<int8, std::string> flymode_map = {
|
static const std::map<int8, std::string> flymode_map = {
|
||||||
@@ -459,3 +436,38 @@ bool ComparisonType::IsValid(uint8 type)
|
|||||||
{
|
{
|
||||||
return comparison_types.find(type) != comparison_types.end();
|
return comparison_types.find(type) != comparison_types.end();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uint32 LDoNTheme::GetBitmask(uint32 theme_id)
|
||||||
|
{
|
||||||
|
return IsValid(theme_id) ? ldon_theme_names[theme_id].second : LDoNTheme::UnusedBit;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string LDoNTheme::GetName(uint32 theme_id)
|
||||||
|
{
|
||||||
|
return IsValid(theme_id) ? ldon_theme_names[theme_id].first : "UNKNOWN LDON THEME";
|
||||||
|
}
|
||||||
|
|
||||||
|
bool LDoNTheme::IsValid(uint32 theme_id)
|
||||||
|
{
|
||||||
|
return ldon_theme_names.find(theme_id) != ldon_theme_names.end();
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string PetCommand::GetName(uint8 pet_command)
|
||||||
|
{
|
||||||
|
return IsValid(pet_command) ? pet_commands[pet_command] : "UNKNOWN PET COMMAND";
|
||||||
|
}
|
||||||
|
|
||||||
|
bool PetCommand::IsValid(uint8 pet_command)
|
||||||
|
{
|
||||||
|
return pet_commands.find(pet_command) != pet_commands.end();
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string PetType::GetName(uint8 pet_type)
|
||||||
|
{
|
||||||
|
return IsValid(pet_type) ? pet_types[pet_type] : "UNKNOWN PET TYPE";
|
||||||
|
}
|
||||||
|
|
||||||
|
bool PetType::IsValid(uint8 pet_type)
|
||||||
|
{
|
||||||
|
return pet_types.find(pet_type) != pet_types.end();
|
||||||
|
}
|
||||||
|
|||||||
+191
-28
@@ -130,9 +130,11 @@ namespace EQ
|
|||||||
using RoF2::invtype::MAIL_SIZE;
|
using RoF2::invtype::MAIL_SIZE;
|
||||||
using RoF2::invtype::GUILD_TROPHY_TRIBUTE_SIZE;
|
using RoF2::invtype::GUILD_TROPHY_TRIBUTE_SIZE;
|
||||||
using RoF2::invtype::KRONO_SIZE;
|
using RoF2::invtype::KRONO_SIZE;
|
||||||
|
using RoF2::invtype::GUILD_BANK_MAIN_SIZE;
|
||||||
|
using RoF2::invtype::GUILD_BANK_DEPOSIT_SIZE;
|
||||||
using RoF2::invtype::OTHER_SIZE;
|
using RoF2::invtype::OTHER_SIZE;
|
||||||
|
|
||||||
using Titanium::invtype::TRADE_NPC_SIZE;
|
using RoF2::invtype::TRADE_NPC_SIZE;
|
||||||
|
|
||||||
using RoF2::invtype::TYPE_INVALID;
|
using RoF2::invtype::TYPE_INVALID;
|
||||||
using RoF2::invtype::TYPE_BEGIN;
|
using RoF2::invtype::TYPE_BEGIN;
|
||||||
@@ -159,7 +161,7 @@ namespace EQ
|
|||||||
using RoF2::invslot::SLOT_INVALID;
|
using RoF2::invslot::SLOT_INVALID;
|
||||||
using RoF2::invslot::SLOT_BEGIN;
|
using RoF2::invslot::SLOT_BEGIN;
|
||||||
|
|
||||||
using Titanium::invslot::SLOT_TRADESKILL_EXPERIMENT_COMBINE;
|
using RoF2::invslot::SLOT_TRADESKILL_EXPERIMENT_COMBINE;
|
||||||
|
|
||||||
const int16 SLOT_AUGMENT_GENERIC_RETURN = 1001; // clients don't appear to use this method... (internal inventory return value)
|
const int16 SLOT_AUGMENT_GENERIC_RETURN = 1001; // clients don't appear to use this method... (internal inventory return value)
|
||||||
|
|
||||||
@@ -179,25 +181,25 @@ namespace EQ
|
|||||||
using RoF2::invslot::BONUS_STAT_END;
|
using RoF2::invslot::BONUS_STAT_END;
|
||||||
using RoF2::invslot::BONUS_SKILL_END;
|
using RoF2::invslot::BONUS_SKILL_END;
|
||||||
|
|
||||||
using Titanium::invslot::BANK_BEGIN;
|
using RoF2::invslot::BANK_BEGIN;
|
||||||
using SoF::invslot::BANK_END;
|
using RoF2::invslot::BANK_END;
|
||||||
|
|
||||||
using Titanium::invslot::SHARED_BANK_BEGIN;
|
using RoF2::invslot::SHARED_BANK_BEGIN;
|
||||||
using Titanium::invslot::SHARED_BANK_END;
|
using RoF2::invslot::SHARED_BANK_END;
|
||||||
|
|
||||||
using Titanium::invslot::TRADE_BEGIN;
|
using RoF2::invslot::TRADE_BEGIN;
|
||||||
using Titanium::invslot::TRADE_END;
|
using RoF2::invslot::TRADE_END;
|
||||||
|
|
||||||
using Titanium::invslot::TRADE_NPC_END;
|
using RoF2::invslot::TRADE_NPC_END;
|
||||||
|
|
||||||
using Titanium::invslot::WORLD_BEGIN;
|
using RoF2::invslot::WORLD_BEGIN;
|
||||||
using Titanium::invslot::WORLD_END;
|
using RoF2::invslot::WORLD_END;
|
||||||
|
|
||||||
using Titanium::invslot::TRIBUTE_BEGIN;
|
using RoF2::invslot::TRIBUTE_BEGIN;
|
||||||
using Titanium::invslot::TRIBUTE_END;
|
using RoF2::invslot::TRIBUTE_END;
|
||||||
|
|
||||||
using Titanium::invslot::GUILD_TRIBUTE_BEGIN;
|
using RoF2::invslot::GUILD_TRIBUTE_BEGIN;
|
||||||
using Titanium::invslot::GUILD_TRIBUTE_END;
|
using RoF2::invslot::GUILD_TRIBUTE_END;
|
||||||
|
|
||||||
const int16 CORPSE_BEGIN = invslot::slotGeneral1;
|
const int16 CORPSE_BEGIN = invslot::slotGeneral1;
|
||||||
const int16 CORPSE_END = CORPSE_BEGIN + invslot::slotCursor;
|
const int16 CORPSE_END = CORPSE_BEGIN + invslot::slotCursor;
|
||||||
@@ -214,38 +216,40 @@ namespace EQ
|
|||||||
} // namespace invslot
|
} // namespace invslot
|
||||||
|
|
||||||
namespace invbag {
|
namespace invbag {
|
||||||
using Titanium::invbag::SLOT_INVALID;
|
using RoF2::invbag::SLOT_INVALID;
|
||||||
using Titanium::invbag::SLOT_BEGIN;
|
using RoF2::invbag::SLOT_BEGIN;
|
||||||
using Titanium::invbag::SLOT_END;
|
using RoF2::invbag::SLOT_END;
|
||||||
using Titanium::invbag::SLOT_COUNT;
|
using RoF2::invbag::SLOT_COUNT;
|
||||||
|
|
||||||
using Titanium::invbag::GENERAL_BAGS_BEGIN;
|
using RoF2::invslot::WORLD_END;
|
||||||
|
|
||||||
|
const int16 GENERAL_BAGS_BEGIN = WORLD_END + 1;
|
||||||
const int16 GENERAL_BAGS_COUNT = invslot::GENERAL_COUNT * SLOT_COUNT;
|
const int16 GENERAL_BAGS_COUNT = invslot::GENERAL_COUNT * SLOT_COUNT;
|
||||||
const int16 GENERAL_BAGS_END = (GENERAL_BAGS_BEGIN + GENERAL_BAGS_COUNT) - 1;
|
const int16 GENERAL_BAGS_END = (GENERAL_BAGS_BEGIN + GENERAL_BAGS_COUNT) - 1;
|
||||||
|
|
||||||
const int16 GENERAL_BAGS_8_COUNT = 8 * SLOT_COUNT;
|
const int16 GENERAL_BAGS_8_COUNT = 8 * SLOT_COUNT;
|
||||||
const int16 GENERAL_BAGS_8_END = (GENERAL_BAGS_BEGIN + GENERAL_BAGS_8_COUNT) - 1;
|
const int16 GENERAL_BAGS_8_END = (GENERAL_BAGS_BEGIN + GENERAL_BAGS_8_COUNT) - 1;
|
||||||
|
|
||||||
const int16 CURSOR_BAG_BEGIN = 351;
|
const int16 CURSOR_BAG_BEGIN = GENERAL_BAGS_END + 1;
|
||||||
const int16 CURSOR_BAG_COUNT = SLOT_COUNT;
|
const int16 CURSOR_BAG_COUNT = SLOT_COUNT;
|
||||||
const int16 CURSOR_BAG_END = (CURSOR_BAG_BEGIN + CURSOR_BAG_COUNT) - 1;
|
const int16 CURSOR_BAG_END = (CURSOR_BAG_BEGIN + CURSOR_BAG_COUNT) - 1;
|
||||||
|
|
||||||
using Titanium::invbag::BANK_BAGS_BEGIN;
|
const int16 BANK_BAGS_BEGIN = CURSOR_BAG_END + 1;
|
||||||
const int16 BANK_BAGS_COUNT = (invtype::BANK_SIZE * SLOT_COUNT);
|
const int16 BANK_BAGS_COUNT = (invtype::BANK_SIZE * SLOT_COUNT);
|
||||||
const int16 BANK_BAGS_END = (BANK_BAGS_BEGIN + BANK_BAGS_COUNT) - 1;
|
const int16 BANK_BAGS_END = (BANK_BAGS_BEGIN + BANK_BAGS_COUNT) - 1;
|
||||||
|
|
||||||
const int16 BANK_BAGS_16_COUNT = 16 * SLOT_COUNT;
|
const int16 BANK_BAGS_16_COUNT = 16 * SLOT_COUNT;
|
||||||
const int16 BANK_BAGS_16_END = (BANK_BAGS_BEGIN + BANK_BAGS_16_COUNT) - 1;
|
const int16 BANK_BAGS_16_END = (BANK_BAGS_BEGIN + BANK_BAGS_16_COUNT) - 1;
|
||||||
|
|
||||||
using Titanium::invbag::SHARED_BANK_BAGS_BEGIN;
|
const int16 SHARED_BANK_BAGS_BEGIN = BANK_BAGS_END + 1;
|
||||||
const int16 SHARED_BANK_BAGS_COUNT = invtype::SHARED_BANK_SIZE * SLOT_COUNT;
|
const int16 SHARED_BANK_BAGS_COUNT = invtype::SHARED_BANK_SIZE * SLOT_COUNT;
|
||||||
const int16 SHARED_BANK_BAGS_END = (SHARED_BANK_BAGS_BEGIN + SHARED_BANK_BAGS_COUNT) - 1;
|
const int16 SHARED_BANK_BAGS_END = (SHARED_BANK_BAGS_BEGIN + SHARED_BANK_BAGS_COUNT) - 1;
|
||||||
|
|
||||||
using Titanium::invbag::TRADE_BAGS_BEGIN;
|
const int16 TRADE_BAGS_BEGIN = SHARED_BANK_BAGS_END + 1;
|
||||||
const int16 TRADE_BAGS_COUNT = invtype::TRADE_SIZE * SLOT_COUNT;
|
const int16 TRADE_BAGS_COUNT = invtype::TRADE_SIZE * SLOT_COUNT;
|
||||||
const int16 TRADE_BAGS_END = (TRADE_BAGS_BEGIN + TRADE_BAGS_COUNT) - 1;
|
const int16 TRADE_BAGS_END = (TRADE_BAGS_BEGIN + TRADE_BAGS_COUNT) - 1;
|
||||||
|
|
||||||
using Titanium::invbag::GetInvBagIndexName;
|
using RoF2::invbag::GetInvBagIndexName;
|
||||||
|
|
||||||
} // namespace invbag
|
} // namespace invbag
|
||||||
|
|
||||||
@@ -352,9 +356,6 @@ namespace EQ
|
|||||||
extern const std::map<uint8, std::string>& GetLanguageMap();
|
extern const std::map<uint8, std::string>& GetLanguageMap();
|
||||||
std::string GetLanguageName(uint8 language_id);
|
std::string GetLanguageName(uint8 language_id);
|
||||||
|
|
||||||
extern const std::map<uint32, std::string>& GetLDoNThemeMap();
|
|
||||||
std::string GetLDoNThemeName(uint32 theme_id);
|
|
||||||
|
|
||||||
extern const std::map<int8, std::string>& GetFlyModeMap();
|
extern const std::map<int8, std::string>& GetFlyModeMap();
|
||||||
std::string GetFlyModeName(int8 flymode_id);
|
std::string GetFlyModeName(int8 flymode_id);
|
||||||
|
|
||||||
@@ -751,9 +752,171 @@ static std::map<uint32, std::string> stance_names = {
|
|||||||
{ Stance::AEBurn, "AE Burn" }
|
{ Stance::AEBurn, "AE Burn" }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
namespace LDoNTheme {
|
||||||
|
constexpr uint32 Unused = 0;
|
||||||
|
constexpr uint32 GUK = 1;
|
||||||
|
constexpr uint32 MIR = 2;
|
||||||
|
constexpr uint32 MMC = 3;
|
||||||
|
constexpr uint32 RUJ = 4;
|
||||||
|
constexpr uint32 TAK = 5;
|
||||||
|
|
||||||
|
constexpr uint32 UnusedBit = 0;
|
||||||
|
constexpr uint32 GUKBit = 1;
|
||||||
|
constexpr uint32 MIRBit = 2;
|
||||||
|
constexpr uint32 MMCBit = 4;
|
||||||
|
constexpr uint32 RUJBit = 8;
|
||||||
|
constexpr uint32 TAKBit = 16;
|
||||||
|
|
||||||
|
uint32 GetBitmask(uint32 theme_id);
|
||||||
|
std::string GetName(uint32 theme_id);
|
||||||
|
bool IsValid(uint32 theme_id);
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::map<uint32, std::pair<std::string, uint32>> ldon_theme_names = {
|
||||||
|
{ LDoNTheme::Unused, { "Unused", LDoNTheme::UnusedBit }, },
|
||||||
|
{ LDoNTheme::GUK, { "Deepest Guk", LDoNTheme::GUKBit }, },
|
||||||
|
{ LDoNTheme::MIR, { "Miragul's Menagerie", LDoNTheme::MIRBit }, },
|
||||||
|
{ LDoNTheme::MMC, { "Mistmoore Catacombs", LDoNTheme::MMCBit }, },
|
||||||
|
{ LDoNTheme::RUJ, { "Rujarkian Hills", LDoNTheme::RUJBit }, },
|
||||||
|
{ LDoNTheme::TAK, { "Takish-Hiz", LDoNTheme::TAKBit }, },
|
||||||
|
};
|
||||||
|
|
||||||
namespace PCNPCOnlyFlagType {
|
namespace PCNPCOnlyFlagType {
|
||||||
constexpr int PC = 1;
|
constexpr int PC = 1;
|
||||||
constexpr int NPC = 2;
|
constexpr int NPC = 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
namespace BookType {
|
||||||
|
constexpr uint8 Scroll = 0;
|
||||||
|
constexpr uint8 Book = 1;
|
||||||
|
constexpr uint8 ItemInfo = 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
namespace PetButton {
|
||||||
|
constexpr uint8 Sit = 0;
|
||||||
|
constexpr uint8 Stop = 1;
|
||||||
|
constexpr uint8 Regroup = 2;
|
||||||
|
constexpr uint8 Follow = 3;
|
||||||
|
constexpr uint8 Guard = 4;
|
||||||
|
constexpr uint8 Taunt = 5;
|
||||||
|
constexpr uint8 Hold = 6;
|
||||||
|
constexpr uint8 GreaterHold = 7;
|
||||||
|
constexpr uint8 Focus = 8;
|
||||||
|
constexpr uint8 SpellHold = 9;
|
||||||
|
}
|
||||||
|
|
||||||
|
namespace PetButtonState {
|
||||||
|
constexpr uint8 Off = 0;
|
||||||
|
constexpr uint8 On = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
namespace PetCommand {
|
||||||
|
constexpr uint8 HealthReport = 0; // /pet health or Pet Window
|
||||||
|
constexpr uint8 Leader = 1; // /pet leader or Pet Window
|
||||||
|
constexpr uint8 Attack = 2; // /pet attack or Pet Window
|
||||||
|
constexpr uint8 QAttack = 3; // /pet qattack or Pet Window
|
||||||
|
constexpr uint8 FollowMe = 4; // /pet follow or Pet Window
|
||||||
|
constexpr uint8 GuardHere = 5; // /pet guard or Pet Window
|
||||||
|
constexpr uint8 Sit = 6; // /pet sit or Pet Window
|
||||||
|
constexpr uint8 SitDown = 7; // /pet sit on
|
||||||
|
constexpr uint8 StandUp = 8; // /pet sit off
|
||||||
|
constexpr uint8 Stop = 9; // /pet stop or Pet Window - Not implemented
|
||||||
|
constexpr uint8 StopOn = 10; // /pet stop on - Not implemented
|
||||||
|
constexpr uint8 StopOff = 11; // /pet stop off - Not implemented
|
||||||
|
constexpr uint8 Taunt = 12; // /pet taunt or Pet Window
|
||||||
|
constexpr uint8 TauntOn = 13; // /pet taunt on
|
||||||
|
constexpr uint8 TauntOff = 14; // /pet taunt off
|
||||||
|
constexpr uint8 Hold = 15; // /pet hold or Pet Window, won't add to hate list unless attacking
|
||||||
|
constexpr uint8 HoldOn = 16; // /pet hold on
|
||||||
|
constexpr uint8 HoldOff = 17; // /pet hold off
|
||||||
|
constexpr uint8 GreaterHold = 18; // /pet ghold, will never add to hate list unless told to
|
||||||
|
constexpr uint8 GreaterHoldOn = 19; // /pet ghold on
|
||||||
|
constexpr uint8 GreaterHoldOff = 20; // /pet ghold off
|
||||||
|
constexpr uint8 SpellHold = 21; // /pet no cast or /pet spellhold or Pet Window
|
||||||
|
constexpr uint8 SpellHoldOn = 22; // /pet spellhold on
|
||||||
|
constexpr uint8 SpellHoldOff = 23; // /pet spellhold off
|
||||||
|
constexpr uint8 Focus = 24; // /pet focus or Pet Window
|
||||||
|
constexpr uint8 FocusOn = 25; // /pet focus on
|
||||||
|
constexpr uint8 FocusOff = 26; // /pet focus off
|
||||||
|
constexpr uint8 Feign = 27; // /pet feign
|
||||||
|
constexpr uint8 BackOff = 28; // /pet back off
|
||||||
|
constexpr uint8 GetLost = 29; // /pet get lost
|
||||||
|
constexpr uint8 GuardMe = 30; // Same as /pet follow, but different message in older clients
|
||||||
|
constexpr uint8 Regroup = 31; // /pet regroup, acts like classic hold
|
||||||
|
constexpr uint8 RegroupOn = 32; // /pet regroup on
|
||||||
|
constexpr uint8 RegroupOff = 33; // /pet regroup off
|
||||||
|
constexpr uint8 Max = 34;
|
||||||
|
|
||||||
|
static std::map<uint8, std::string> pet_commands = {
|
||||||
|
{ PetCommand::HealthReport, "Health Report" },
|
||||||
|
{ PetCommand::Leader, "Leader" },
|
||||||
|
{ PetCommand::Attack, "Attack" },
|
||||||
|
{ PetCommand::QAttack, "QAttack" },
|
||||||
|
{ PetCommand::FollowMe, "Follow Me" },
|
||||||
|
{ PetCommand::GuardHere, "Guard Here" },
|
||||||
|
{ PetCommand::Sit, "Sit" },
|
||||||
|
{ PetCommand::SitDown, "Sit Down" },
|
||||||
|
{ PetCommand::StandUp, "Stand Up" },
|
||||||
|
{ PetCommand::Stop, "Stop" },
|
||||||
|
{ PetCommand::StopOn, "Stop On" },
|
||||||
|
{ PetCommand::StopOff, "Stop Off" },
|
||||||
|
{ PetCommand::Taunt, "Taunt" },
|
||||||
|
{ PetCommand::TauntOn, "Taunt On" },
|
||||||
|
{ PetCommand::TauntOff, "Taunt Off" },
|
||||||
|
{ PetCommand::Hold, "Hold" },
|
||||||
|
{ PetCommand::HoldOn, "Hold On" },
|
||||||
|
{ PetCommand::HoldOff, "Hold Off" },
|
||||||
|
{ PetCommand::GreaterHold, "Greater Hold" },
|
||||||
|
{ PetCommand::GreaterHoldOn, "Greater Hold On" },
|
||||||
|
{ PetCommand::GreaterHoldOff, "Greater Hold Off" },
|
||||||
|
{ PetCommand::SpellHold, "Spell Hold" },
|
||||||
|
{ PetCommand::SpellHoldOn, "Spell Hold On" },
|
||||||
|
{ PetCommand::SpellHoldOff, "Spell Hold Off" },
|
||||||
|
{ PetCommand::Focus, "Focus" },
|
||||||
|
{ PetCommand::FocusOn, "Focus On" },
|
||||||
|
{ PetCommand::FocusOff, "Focus Off" },
|
||||||
|
{ PetCommand::Feign, "Feign" },
|
||||||
|
{ PetCommand::BackOff, "Back Off" },
|
||||||
|
{ PetCommand::GetLost, "Get Lost" },
|
||||||
|
{ PetCommand::GuardMe, "Guard Me" },
|
||||||
|
{ PetCommand::Regroup, "Regroup" },
|
||||||
|
{ PetCommand::RegroupOn, "Regroup On" },
|
||||||
|
{ PetCommand::RegroupOff, "Regroup Off" },
|
||||||
|
{ PetCommand::Max, "Max" }
|
||||||
|
};
|
||||||
|
|
||||||
|
std::string GetName(uint8 pet_command);
|
||||||
|
bool IsValid(uint8 pet_command);
|
||||||
|
}
|
||||||
|
|
||||||
|
namespace PetOrder {
|
||||||
|
constexpr uint8 Follow = 0;
|
||||||
|
constexpr uint8 Sit = 1;
|
||||||
|
constexpr uint8 Guard = 2;
|
||||||
|
constexpr uint8 Feign = 3;
|
||||||
|
}
|
||||||
|
|
||||||
|
namespace PetType {
|
||||||
|
constexpr uint8 Familiar = 0;
|
||||||
|
constexpr uint8 Animation = 1;
|
||||||
|
constexpr uint8 Normal = 2;
|
||||||
|
constexpr uint8 Charmed = 3;
|
||||||
|
constexpr uint8 Follow = 4;
|
||||||
|
constexpr uint8 TargetLock = 5;
|
||||||
|
constexpr uint8 None = 255;
|
||||||
|
|
||||||
|
static std::map<uint8, std::string> pet_types = {
|
||||||
|
{ PetType::Familiar, "Familiar" },
|
||||||
|
{ PetType::Animation, "Animation" },
|
||||||
|
{ PetType::Normal, "Normal" },
|
||||||
|
{ PetType::Charmed, "Charmed" },
|
||||||
|
{ PetType::Follow, "Follow" },
|
||||||
|
{ PetType::TargetLock, "Target Lock" },
|
||||||
|
{ PetType::None, "None" }
|
||||||
|
};
|
||||||
|
|
||||||
|
std::string GetName(uint8 pet_type);
|
||||||
|
bool IsValid(uint8 pet_type);
|
||||||
|
}
|
||||||
|
|
||||||
#endif /*COMMON_EMU_CONSTANTS_H*/
|
#endif /*COMMON_EMU_CONSTANTS_H*/
|
||||||
|
|||||||
@@ -77,6 +77,7 @@ N(OP_CashReward),
|
|||||||
N(OP_CastSpell),
|
N(OP_CastSpell),
|
||||||
N(OP_ChangeSize),
|
N(OP_ChangeSize),
|
||||||
N(OP_ChannelMessage),
|
N(OP_ChannelMessage),
|
||||||
|
N(OP_ChangePetName),
|
||||||
N(OP_CharacterCreate),
|
N(OP_CharacterCreate),
|
||||||
N(OP_CharacterCreateRequest),
|
N(OP_CharacterCreateRequest),
|
||||||
N(OP_CharInventory),
|
N(OP_CharInventory),
|
||||||
@@ -162,6 +163,7 @@ N(OP_EnduranceUpdate),
|
|||||||
N(OP_EnterChat),
|
N(OP_EnterChat),
|
||||||
N(OP_EnterWorld),
|
N(OP_EnterWorld),
|
||||||
N(OP_EnvDamage),
|
N(OP_EnvDamage),
|
||||||
|
N(OP_EvolveItem),
|
||||||
N(OP_ExpansionInfo),
|
N(OP_ExpansionInfo),
|
||||||
N(OP_ExpUpdate),
|
N(OP_ExpUpdate),
|
||||||
N(OP_FaceChange),
|
N(OP_FaceChange),
|
||||||
@@ -283,12 +285,17 @@ N(OP_InspectMessageUpdate),
|
|||||||
N(OP_InspectRequest),
|
N(OP_InspectRequest),
|
||||||
N(OP_InstillDoubt),
|
N(OP_InstillDoubt),
|
||||||
N(OP_InterruptCast),
|
N(OP_InterruptCast),
|
||||||
|
N(OP_InvokeChangePetName),
|
||||||
|
N(OP_InvokeChangePetNameImmediate),
|
||||||
|
N(OP_InvokeNameChangeImmediate),
|
||||||
|
N(OP_InvokeNameChangeLazy),
|
||||||
N(OP_ItemLinkClick),
|
N(OP_ItemLinkClick),
|
||||||
N(OP_ItemLinkResponse),
|
N(OP_ItemLinkResponse),
|
||||||
N(OP_ItemLinkText),
|
N(OP_ItemLinkText),
|
||||||
N(OP_ItemName),
|
N(OP_ItemName),
|
||||||
N(OP_ItemPacket),
|
N(OP_ItemPacket),
|
||||||
N(OP_ItemPreview),
|
N(OP_ItemPreview),
|
||||||
|
N(OP_ItemPreviewRequest),
|
||||||
N(OP_ItemRecastDelay),
|
N(OP_ItemRecastDelay),
|
||||||
N(OP_ItemVerifyReply),
|
N(OP_ItemVerifyReply),
|
||||||
N(OP_ItemVerifyRequest),
|
N(OP_ItemVerifyRequest),
|
||||||
@@ -400,6 +407,8 @@ N(OP_PetitionSearchText),
|
|||||||
N(OP_PetitionUnCheckout),
|
N(OP_PetitionUnCheckout),
|
||||||
N(OP_PetitionUpdate),
|
N(OP_PetitionUpdate),
|
||||||
N(OP_PickPocket),
|
N(OP_PickPocket),
|
||||||
|
N(OP_PickZone),
|
||||||
|
N(OP_PickZoneWindow),
|
||||||
N(OP_PlayerProfile),
|
N(OP_PlayerProfile),
|
||||||
N(OP_PlayerStateAdd),
|
N(OP_PlayerStateAdd),
|
||||||
N(OP_PlayerStateRemove),
|
N(OP_PlayerStateRemove),
|
||||||
@@ -534,6 +543,7 @@ N(OP_Stamina),
|
|||||||
N(OP_Stun),
|
N(OP_Stun),
|
||||||
N(OP_Surname),
|
N(OP_Surname),
|
||||||
N(OP_SwapSpell),
|
N(OP_SwapSpell),
|
||||||
|
N(OP_SystemFingerprint),
|
||||||
N(OP_TargetBuffs),
|
N(OP_TargetBuffs),
|
||||||
N(OP_TargetCommand),
|
N(OP_TargetCommand),
|
||||||
N(OP_TargetHoTT),
|
N(OP_TargetHoTT),
|
||||||
@@ -566,6 +576,7 @@ N(OP_TradeRequestAck),
|
|||||||
N(OP_TraderItemUpdate),
|
N(OP_TraderItemUpdate),
|
||||||
N(OP_TraderShop),
|
N(OP_TraderShop),
|
||||||
N(OP_TradeSkillCombine),
|
N(OP_TradeSkillCombine),
|
||||||
|
N(OP_TradeSkillRecipeInspect),
|
||||||
N(OP_Translocate),
|
N(OP_Translocate),
|
||||||
N(OP_TributeInfo),
|
N(OP_TributeInfo),
|
||||||
N(OP_TributeItem),
|
N(OP_TributeItem),
|
||||||
|
|||||||
+3
-38
@@ -974,43 +974,6 @@ namespace ZoneBlockedSpellTypes {
|
|||||||
const uint8 Region = 2;
|
const uint8 Region = 2;
|
||||||
};
|
};
|
||||||
|
|
||||||
enum class DynamicZoneType
|
|
||||||
{
|
|
||||||
None = 0,
|
|
||||||
Expedition,
|
|
||||||
Tutorial,
|
|
||||||
Task,
|
|
||||||
Mission, // Shared Task
|
|
||||||
Quest
|
|
||||||
};
|
|
||||||
|
|
||||||
enum class DynamicZoneMemberStatus : uint8_t
|
|
||||||
{
|
|
||||||
Unknown = 0,
|
|
||||||
Online,
|
|
||||||
Offline,
|
|
||||||
InDynamicZone,
|
|
||||||
LinkDead
|
|
||||||
};
|
|
||||||
|
|
||||||
enum LDoNThemes {
|
|
||||||
Unused = 0,
|
|
||||||
GUK,
|
|
||||||
MIR,
|
|
||||||
MMC,
|
|
||||||
RUJ,
|
|
||||||
TAK
|
|
||||||
};
|
|
||||||
|
|
||||||
enum LDoNThemeBits {
|
|
||||||
UnusedBit = 0,
|
|
||||||
GUKBit = 1,
|
|
||||||
MIRBit = 2,
|
|
||||||
MMCBit = 4,
|
|
||||||
RUJBit = 8,
|
|
||||||
TAKBit = 16
|
|
||||||
};
|
|
||||||
|
|
||||||
enum StartZoneIndex {
|
enum StartZoneIndex {
|
||||||
Odus = 0,
|
Odus = 0,
|
||||||
Qeynos,
|
Qeynos,
|
||||||
@@ -1025,7 +988,8 @@ enum StartZoneIndex {
|
|||||||
Felwithe,
|
Felwithe,
|
||||||
Akanon,
|
Akanon,
|
||||||
Cabilis,
|
Cabilis,
|
||||||
SharVahl
|
SharVahl,
|
||||||
|
RatheMtn
|
||||||
};
|
};
|
||||||
|
|
||||||
enum FVNoDropFlagRule
|
enum FVNoDropFlagRule
|
||||||
@@ -1132,4 +1096,5 @@ enum ExpSource
|
|||||||
namespace DoorType {
|
namespace DoorType {
|
||||||
constexpr uint32 BuyerStall = 155;
|
constexpr uint32 BuyerStall = 155;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /*COMMON_EQ_CONSTANTS_H*/
|
#endif /*COMMON_EQ_CONSTANTS_H*/
|
||||||
|
|||||||
+36
-28
@@ -47,6 +47,7 @@ static const EQ::constants::LookupEntry constants_static_lookup_entries[EQ::vers
|
|||||||
ClientUnknown::constants::EXPANSION_BIT,
|
ClientUnknown::constants::EXPANSION_BIT,
|
||||||
ClientUnknown::constants::EXPANSIONS_MASK,
|
ClientUnknown::constants::EXPANSIONS_MASK,
|
||||||
ClientUnknown::INULL,
|
ClientUnknown::INULL,
|
||||||
|
ClientUnknown::INULL,
|
||||||
ClientUnknown::INULL
|
ClientUnknown::INULL
|
||||||
),
|
),
|
||||||
/*[ClientVersion::Client62] =*/
|
/*[ClientVersion::Client62] =*/
|
||||||
@@ -55,6 +56,7 @@ static const EQ::constants::LookupEntry constants_static_lookup_entries[EQ::vers
|
|||||||
Client62::constants::EXPANSION_BIT,
|
Client62::constants::EXPANSION_BIT,
|
||||||
Client62::constants::EXPANSIONS_MASK,
|
Client62::constants::EXPANSIONS_MASK,
|
||||||
Client62::INULL,
|
Client62::INULL,
|
||||||
|
Client62::INULL,
|
||||||
Client62::INULL
|
Client62::INULL
|
||||||
),
|
),
|
||||||
/*[ClientVersion::Titanium] =*/
|
/*[ClientVersion::Titanium] =*/
|
||||||
@@ -63,7 +65,8 @@ static const EQ::constants::LookupEntry constants_static_lookup_entries[EQ::vers
|
|||||||
Titanium::constants::EXPANSION_BIT,
|
Titanium::constants::EXPANSION_BIT,
|
||||||
Titanium::constants::EXPANSIONS_MASK,
|
Titanium::constants::EXPANSIONS_MASK,
|
||||||
Titanium::constants::CHARACTER_CREATION_LIMIT,
|
Titanium::constants::CHARACTER_CREATION_LIMIT,
|
||||||
Titanium::constants::SAY_LINK_BODY_SIZE
|
Titanium::constants::SAY_LINK_BODY_SIZE,
|
||||||
|
Titanium::INULL
|
||||||
),
|
),
|
||||||
/*[ClientVersion::SoF] =*/
|
/*[ClientVersion::SoF] =*/
|
||||||
EQ::constants::LookupEntry(
|
EQ::constants::LookupEntry(
|
||||||
@@ -71,7 +74,8 @@ static const EQ::constants::LookupEntry constants_static_lookup_entries[EQ::vers
|
|||||||
SoF::constants::EXPANSION_BIT,
|
SoF::constants::EXPANSION_BIT,
|
||||||
SoF::constants::EXPANSIONS_MASK,
|
SoF::constants::EXPANSIONS_MASK,
|
||||||
SoF::constants::CHARACTER_CREATION_LIMIT,
|
SoF::constants::CHARACTER_CREATION_LIMIT,
|
||||||
SoF::constants::SAY_LINK_BODY_SIZE
|
SoF::constants::SAY_LINK_BODY_SIZE,
|
||||||
|
SoF::INULL
|
||||||
),
|
),
|
||||||
/*[ClientVersion::SoD] =*/
|
/*[ClientVersion::SoD] =*/
|
||||||
EQ::constants::LookupEntry(
|
EQ::constants::LookupEntry(
|
||||||
@@ -79,7 +83,8 @@ static const EQ::constants::LookupEntry constants_static_lookup_entries[EQ::vers
|
|||||||
SoD::constants::EXPANSION_BIT,
|
SoD::constants::EXPANSION_BIT,
|
||||||
SoD::constants::EXPANSIONS_MASK,
|
SoD::constants::EXPANSIONS_MASK,
|
||||||
SoD::constants::CHARACTER_CREATION_LIMIT,
|
SoD::constants::CHARACTER_CREATION_LIMIT,
|
||||||
SoD::constants::SAY_LINK_BODY_SIZE
|
SoD::constants::SAY_LINK_BODY_SIZE,
|
||||||
|
SoD::INULL
|
||||||
),
|
),
|
||||||
/*[ClientVersion::UF] =*/
|
/*[ClientVersion::UF] =*/
|
||||||
EQ::constants::LookupEntry(
|
EQ::constants::LookupEntry(
|
||||||
@@ -87,7 +92,8 @@ static const EQ::constants::LookupEntry constants_static_lookup_entries[EQ::vers
|
|||||||
UF::constants::EXPANSION_BIT,
|
UF::constants::EXPANSION_BIT,
|
||||||
UF::constants::EXPANSIONS_MASK,
|
UF::constants::EXPANSIONS_MASK,
|
||||||
UF::constants::CHARACTER_CREATION_LIMIT,
|
UF::constants::CHARACTER_CREATION_LIMIT,
|
||||||
UF::constants::SAY_LINK_BODY_SIZE
|
UF::constants::SAY_LINK_BODY_SIZE,
|
||||||
|
UF::INULL
|
||||||
),
|
),
|
||||||
/*[ClientVersion::RoF] =*/
|
/*[ClientVersion::RoF] =*/
|
||||||
EQ::constants::LookupEntry(
|
EQ::constants::LookupEntry(
|
||||||
@@ -95,7 +101,8 @@ static const EQ::constants::LookupEntry constants_static_lookup_entries[EQ::vers
|
|||||||
RoF::constants::EXPANSION_BIT,
|
RoF::constants::EXPANSION_BIT,
|
||||||
RoF::constants::EXPANSIONS_MASK,
|
RoF::constants::EXPANSIONS_MASK,
|
||||||
RoF::constants::CHARACTER_CREATION_LIMIT,
|
RoF::constants::CHARACTER_CREATION_LIMIT,
|
||||||
RoF::constants::SAY_LINK_BODY_SIZE
|
RoF::constants::SAY_LINK_BODY_SIZE,
|
||||||
|
RoF::INULL
|
||||||
),
|
),
|
||||||
/*[ClientVersion::RoF2] =*/
|
/*[ClientVersion::RoF2] =*/
|
||||||
EQ::constants::LookupEntry(
|
EQ::constants::LookupEntry(
|
||||||
@@ -103,7 +110,8 @@ static const EQ::constants::LookupEntry constants_static_lookup_entries[EQ::vers
|
|||||||
RoF2::constants::EXPANSION_BIT,
|
RoF2::constants::EXPANSION_BIT,
|
||||||
RoF2::constants::EXPANSIONS_MASK,
|
RoF2::constants::EXPANSIONS_MASK,
|
||||||
RoF2::constants::CHARACTER_CREATION_LIMIT,
|
RoF2::constants::CHARACTER_CREATION_LIMIT,
|
||||||
RoF2::constants::SAY_LINK_BODY_SIZE
|
RoF2::constants::SAY_LINK_BODY_SIZE,
|
||||||
|
RoF2::constants::MAX_BAZAAR_TRADERS
|
||||||
)
|
)
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -165,7 +173,7 @@ static const EQ::inventory::LookupEntry inventory_static_lookup_entries[EQ::vers
|
|||||||
ClientUnknown::INULL, ClientUnknown::INULL, ClientUnknown::INULL,
|
ClientUnknown::INULL, ClientUnknown::INULL, ClientUnknown::INULL,
|
||||||
ClientUnknown::INULL, ClientUnknown::INULL, ClientUnknown::INULL,
|
ClientUnknown::INULL, ClientUnknown::INULL, ClientUnknown::INULL,
|
||||||
ClientUnknown::INULL, ClientUnknown::INULL, ClientUnknown::INULL,
|
ClientUnknown::INULL, ClientUnknown::INULL, ClientUnknown::INULL,
|
||||||
ClientUnknown::INULL
|
ClientUnknown::INULL, ClientUnknown::INULL, ClientUnknown::INULL
|
||||||
),
|
),
|
||||||
|
|
||||||
ClientUnknown::INULL,
|
ClientUnknown::INULL,
|
||||||
@@ -192,7 +200,7 @@ static const EQ::inventory::LookupEntry inventory_static_lookup_entries[EQ::vers
|
|||||||
Client62::INULL, Client62::INULL, Client62::INULL,
|
Client62::INULL, Client62::INULL, Client62::INULL,
|
||||||
Client62::INULL, Client62::INULL, Client62::INULL,
|
Client62::INULL, Client62::INULL, Client62::INULL,
|
||||||
Client62::INULL, Client62::INULL, Client62::INULL,
|
Client62::INULL, Client62::INULL, Client62::INULL,
|
||||||
Client62::INULL
|
Client62::INULL, Client62::INULL, Client62::INULL
|
||||||
),
|
),
|
||||||
|
|
||||||
Client62::INULL,
|
Client62::INULL,
|
||||||
@@ -219,7 +227,7 @@ static const EQ::inventory::LookupEntry inventory_static_lookup_entries[EQ::vers
|
|||||||
Titanium::invtype::VIEW_MOD_PC_SIZE, Titanium::invtype::VIEW_MOD_BANK_SIZE, Titanium::invtype::VIEW_MOD_SHARED_BANK_SIZE,
|
Titanium::invtype::VIEW_MOD_PC_SIZE, Titanium::invtype::VIEW_MOD_BANK_SIZE, Titanium::invtype::VIEW_MOD_SHARED_BANK_SIZE,
|
||||||
Titanium::invtype::VIEW_MOD_LIMBO_SIZE, Titanium::invtype::ALT_STORAGE_SIZE, Titanium::invtype::ARCHIVED_SIZE,
|
Titanium::invtype::VIEW_MOD_LIMBO_SIZE, Titanium::invtype::ALT_STORAGE_SIZE, Titanium::invtype::ARCHIVED_SIZE,
|
||||||
Titanium::INULL, Titanium::INULL, Titanium::INULL,
|
Titanium::INULL, Titanium::INULL, Titanium::INULL,
|
||||||
Titanium::invtype::OTHER_SIZE
|
Titanium::INULL, Titanium::INULL, Titanium::invtype::OTHER_SIZE
|
||||||
),
|
),
|
||||||
|
|
||||||
Titanium::invslot::EQUIPMENT_BITMASK,
|
Titanium::invslot::EQUIPMENT_BITMASK,
|
||||||
@@ -246,7 +254,7 @@ static const EQ::inventory::LookupEntry inventory_static_lookup_entries[EQ::vers
|
|||||||
SoF::invtype::VIEW_MOD_PC_SIZE, SoF::invtype::VIEW_MOD_BANK_SIZE, SoF::invtype::VIEW_MOD_SHARED_BANK_SIZE,
|
SoF::invtype::VIEW_MOD_PC_SIZE, SoF::invtype::VIEW_MOD_BANK_SIZE, SoF::invtype::VIEW_MOD_SHARED_BANK_SIZE,
|
||||||
SoF::invtype::VIEW_MOD_LIMBO_SIZE, SoF::invtype::ALT_STORAGE_SIZE, SoF::invtype::ARCHIVED_SIZE,
|
SoF::invtype::VIEW_MOD_LIMBO_SIZE, SoF::invtype::ALT_STORAGE_SIZE, SoF::invtype::ARCHIVED_SIZE,
|
||||||
SoF::INULL, SoF::INULL, SoF::INULL,
|
SoF::INULL, SoF::INULL, SoF::INULL,
|
||||||
SoF::invtype::OTHER_SIZE
|
SoF::INULL, SoF::INULL, SoF::invtype::OTHER_SIZE
|
||||||
),
|
),
|
||||||
|
|
||||||
SoF::invslot::EQUIPMENT_BITMASK,
|
SoF::invslot::EQUIPMENT_BITMASK,
|
||||||
@@ -273,7 +281,7 @@ static const EQ::inventory::LookupEntry inventory_static_lookup_entries[EQ::vers
|
|||||||
SoD::invtype::VIEW_MOD_PC_SIZE, SoD::invtype::VIEW_MOD_BANK_SIZE, SoD::invtype::VIEW_MOD_SHARED_BANK_SIZE,
|
SoD::invtype::VIEW_MOD_PC_SIZE, SoD::invtype::VIEW_MOD_BANK_SIZE, SoD::invtype::VIEW_MOD_SHARED_BANK_SIZE,
|
||||||
SoD::invtype::VIEW_MOD_LIMBO_SIZE, SoD::invtype::ALT_STORAGE_SIZE, SoD::invtype::ARCHIVED_SIZE,
|
SoD::invtype::VIEW_MOD_LIMBO_SIZE, SoD::invtype::ALT_STORAGE_SIZE, SoD::invtype::ARCHIVED_SIZE,
|
||||||
SoD::INULL, SoD::INULL, SoD::INULL,
|
SoD::INULL, SoD::INULL, SoD::INULL,
|
||||||
SoD::invtype::OTHER_SIZE
|
SoD::INULL, SoD::INULL, SoD::invtype::OTHER_SIZE
|
||||||
),
|
),
|
||||||
|
|
||||||
SoD::invslot::EQUIPMENT_BITMASK,
|
SoD::invslot::EQUIPMENT_BITMASK,
|
||||||
@@ -300,7 +308,7 @@ static const EQ::inventory::LookupEntry inventory_static_lookup_entries[EQ::vers
|
|||||||
UF::invtype::VIEW_MOD_PC_SIZE, UF::invtype::VIEW_MOD_BANK_SIZE, UF::invtype::VIEW_MOD_SHARED_BANK_SIZE,
|
UF::invtype::VIEW_MOD_PC_SIZE, UF::invtype::VIEW_MOD_BANK_SIZE, UF::invtype::VIEW_MOD_SHARED_BANK_SIZE,
|
||||||
UF::invtype::VIEW_MOD_LIMBO_SIZE, UF::invtype::ALT_STORAGE_SIZE, UF::invtype::ARCHIVED_SIZE,
|
UF::invtype::VIEW_MOD_LIMBO_SIZE, UF::invtype::ALT_STORAGE_SIZE, UF::invtype::ARCHIVED_SIZE,
|
||||||
UF::INULL, UF::INULL, UF::INULL,
|
UF::INULL, UF::INULL, UF::INULL,
|
||||||
UF::invtype::OTHER_SIZE
|
UF::INULL, UF::INULL, UF::invtype::OTHER_SIZE
|
||||||
),
|
),
|
||||||
|
|
||||||
UF::invslot::EQUIPMENT_BITMASK,
|
UF::invslot::EQUIPMENT_BITMASK,
|
||||||
@@ -327,7 +335,7 @@ static const EQ::inventory::LookupEntry inventory_static_lookup_entries[EQ::vers
|
|||||||
RoF::invtype::VIEW_MOD_PC_SIZE, RoF::invtype::VIEW_MOD_BANK_SIZE, RoF::invtype::VIEW_MOD_SHARED_BANK_SIZE,
|
RoF::invtype::VIEW_MOD_PC_SIZE, RoF::invtype::VIEW_MOD_BANK_SIZE, RoF::invtype::VIEW_MOD_SHARED_BANK_SIZE,
|
||||||
RoF::invtype::VIEW_MOD_LIMBO_SIZE, RoF::invtype::ALT_STORAGE_SIZE, RoF::invtype::ARCHIVED_SIZE,
|
RoF::invtype::VIEW_MOD_LIMBO_SIZE, RoF::invtype::ALT_STORAGE_SIZE, RoF::invtype::ARCHIVED_SIZE,
|
||||||
RoF::invtype::MAIL_SIZE, RoF::invtype::GUILD_TROPHY_TRIBUTE_SIZE, RoF::INULL,
|
RoF::invtype::MAIL_SIZE, RoF::invtype::GUILD_TROPHY_TRIBUTE_SIZE, RoF::INULL,
|
||||||
RoF::invtype::OTHER_SIZE
|
RoF::INULL,RoF::INULL,RoF::invtype::OTHER_SIZE
|
||||||
),
|
),
|
||||||
|
|
||||||
RoF::invslot::EQUIPMENT_BITMASK,
|
RoF::invslot::EQUIPMENT_BITMASK,
|
||||||
@@ -354,7 +362,7 @@ static const EQ::inventory::LookupEntry inventory_static_lookup_entries[EQ::vers
|
|||||||
RoF2::invtype::VIEW_MOD_PC_SIZE, RoF2::invtype::VIEW_MOD_BANK_SIZE, RoF2::invtype::VIEW_MOD_SHARED_BANK_SIZE,
|
RoF2::invtype::VIEW_MOD_PC_SIZE, RoF2::invtype::VIEW_MOD_BANK_SIZE, RoF2::invtype::VIEW_MOD_SHARED_BANK_SIZE,
|
||||||
RoF2::invtype::VIEW_MOD_LIMBO_SIZE, RoF2::invtype::ALT_STORAGE_SIZE, RoF2::invtype::ARCHIVED_SIZE,
|
RoF2::invtype::VIEW_MOD_LIMBO_SIZE, RoF2::invtype::ALT_STORAGE_SIZE, RoF2::invtype::ARCHIVED_SIZE,
|
||||||
RoF2::invtype::MAIL_SIZE, RoF2::invtype::GUILD_TROPHY_TRIBUTE_SIZE, RoF2::invtype::KRONO_SIZE,
|
RoF2::invtype::MAIL_SIZE, RoF2::invtype::GUILD_TROPHY_TRIBUTE_SIZE, RoF2::invtype::KRONO_SIZE,
|
||||||
RoF2::invtype::OTHER_SIZE
|
RoF2::invtype::GUILD_BANK_MAIN_SIZE,RoF2::invtype::GUILD_BANK_DEPOSIT_SIZE, RoF2::invtype::OTHER_SIZE
|
||||||
),
|
),
|
||||||
|
|
||||||
RoF2::invslot::EQUIPMENT_BITMASK,
|
RoF2::invslot::EQUIPMENT_BITMASK,
|
||||||
@@ -381,7 +389,7 @@ static const EQ::inventory::LookupEntry inventory_static_lookup_entries[EQ::vers
|
|||||||
EntityLimits::NPC::INULL, EntityLimits::NPC::INULL, EntityLimits::NPC::INULL,
|
EntityLimits::NPC::INULL, EntityLimits::NPC::INULL, EntityLimits::NPC::INULL,
|
||||||
EntityLimits::NPC::INULL, EntityLimits::NPC::INULL, EntityLimits::NPC::INULL,
|
EntityLimits::NPC::INULL, EntityLimits::NPC::INULL, EntityLimits::NPC::INULL,
|
||||||
EntityLimits::NPC::INULL, EntityLimits::NPC::INULL, EntityLimits::NPC::INULL,
|
EntityLimits::NPC::INULL, EntityLimits::NPC::INULL, EntityLimits::NPC::INULL,
|
||||||
EntityLimits::NPC::INULL
|
EntityLimits::NPC::INULL, EntityLimits::NPC::INULL,EntityLimits::NPC::INULL
|
||||||
),
|
),
|
||||||
|
|
||||||
EntityLimits::NPC::INULL,
|
EntityLimits::NPC::INULL,
|
||||||
@@ -408,7 +416,7 @@ static const EQ::inventory::LookupEntry inventory_static_lookup_entries[EQ::vers
|
|||||||
EntityLimits::NPCMerchant::INULL, EntityLimits::NPCMerchant::INULL, EntityLimits::NPCMerchant::INULL,
|
EntityLimits::NPCMerchant::INULL, EntityLimits::NPCMerchant::INULL, EntityLimits::NPCMerchant::INULL,
|
||||||
EntityLimits::NPCMerchant::INULL, EntityLimits::NPCMerchant::INULL, EntityLimits::NPCMerchant::INULL,
|
EntityLimits::NPCMerchant::INULL, EntityLimits::NPCMerchant::INULL, EntityLimits::NPCMerchant::INULL,
|
||||||
EntityLimits::NPCMerchant::INULL, EntityLimits::NPCMerchant::INULL, EntityLimits::NPCMerchant::INULL,
|
EntityLimits::NPCMerchant::INULL, EntityLimits::NPCMerchant::INULL, EntityLimits::NPCMerchant::INULL,
|
||||||
EntityLimits::NPCMerchant::INULL
|
EntityLimits::NPCMerchant::INULL, EntityLimits::NPCMerchant::INULL, EntityLimits::NPCMerchant::INULL
|
||||||
),
|
),
|
||||||
|
|
||||||
EntityLimits::NPCMerchant::INULL,
|
EntityLimits::NPCMerchant::INULL,
|
||||||
@@ -435,7 +443,7 @@ static const EQ::inventory::LookupEntry inventory_static_lookup_entries[EQ::vers
|
|||||||
EntityLimits::Merc::INULL, EntityLimits::Merc::INULL, EntityLimits::Merc::INULL,
|
EntityLimits::Merc::INULL, EntityLimits::Merc::INULL, EntityLimits::Merc::INULL,
|
||||||
EntityLimits::Merc::INULL, EntityLimits::Merc::INULL, EntityLimits::Merc::INULL,
|
EntityLimits::Merc::INULL, EntityLimits::Merc::INULL, EntityLimits::Merc::INULL,
|
||||||
EntityLimits::Merc::INULL, EntityLimits::Merc::INULL, EntityLimits::Merc::INULL,
|
EntityLimits::Merc::INULL, EntityLimits::Merc::INULL, EntityLimits::Merc::INULL,
|
||||||
EntityLimits::Merc::INULL
|
EntityLimits::Merc::INULL, EntityLimits::Merc::INULL, EntityLimits::Merc::INULL
|
||||||
),
|
),
|
||||||
|
|
||||||
EntityLimits::Merc::INULL,
|
EntityLimits::Merc::INULL,
|
||||||
@@ -462,7 +470,7 @@ static const EQ::inventory::LookupEntry inventory_static_lookup_entries[EQ::vers
|
|||||||
EntityLimits::Bot::INULL, EntityLimits::Bot::INULL, EntityLimits::Bot::INULL,
|
EntityLimits::Bot::INULL, EntityLimits::Bot::INULL, EntityLimits::Bot::INULL,
|
||||||
EntityLimits::Bot::INULL, EntityLimits::Bot::INULL, EntityLimits::Bot::INULL,
|
EntityLimits::Bot::INULL, EntityLimits::Bot::INULL, EntityLimits::Bot::INULL,
|
||||||
EntityLimits::Bot::INULL, EntityLimits::Bot::INULL, EntityLimits::Bot::INULL,
|
EntityLimits::Bot::INULL, EntityLimits::Bot::INULL, EntityLimits::Bot::INULL,
|
||||||
EntityLimits::Bot::INULL
|
EntityLimits::Bot::INULL, EntityLimits::Bot::INULL, EntityLimits::Bot::INULL
|
||||||
),
|
),
|
||||||
|
|
||||||
EntityLimits::Bot::invslot::EQUIPMENT_BITMASK,
|
EntityLimits::Bot::invslot::EQUIPMENT_BITMASK,
|
||||||
@@ -489,7 +497,7 @@ static const EQ::inventory::LookupEntry inventory_static_lookup_entries[EQ::vers
|
|||||||
EntityLimits::ClientPet::INULL, EntityLimits::ClientPet::INULL, EntityLimits::ClientPet::INULL,
|
EntityLimits::ClientPet::INULL, EntityLimits::ClientPet::INULL, EntityLimits::ClientPet::INULL,
|
||||||
EntityLimits::ClientPet::INULL, EntityLimits::ClientPet::INULL, EntityLimits::ClientPet::INULL,
|
EntityLimits::ClientPet::INULL, EntityLimits::ClientPet::INULL, EntityLimits::ClientPet::INULL,
|
||||||
EntityLimits::ClientPet::INULL, EntityLimits::ClientPet::INULL, EntityLimits::ClientPet::INULL,
|
EntityLimits::ClientPet::INULL, EntityLimits::ClientPet::INULL, EntityLimits::ClientPet::INULL,
|
||||||
EntityLimits::ClientPet::INULL
|
EntityLimits::ClientPet::INULL, EntityLimits::ClientPet::INULL, EntityLimits::ClientPet::INULL
|
||||||
),
|
),
|
||||||
|
|
||||||
EntityLimits::ClientPet::INULL,
|
EntityLimits::ClientPet::INULL,
|
||||||
@@ -516,7 +524,7 @@ static const EQ::inventory::LookupEntry inventory_static_lookup_entries[EQ::vers
|
|||||||
EntityLimits::NPCPet::INULL, EntityLimits::NPCPet::INULL, EntityLimits::NPCPet::INULL,
|
EntityLimits::NPCPet::INULL, EntityLimits::NPCPet::INULL, EntityLimits::NPCPet::INULL,
|
||||||
EntityLimits::NPCPet::INULL, EntityLimits::NPCPet::INULL, EntityLimits::NPCPet::INULL,
|
EntityLimits::NPCPet::INULL, EntityLimits::NPCPet::INULL, EntityLimits::NPCPet::INULL,
|
||||||
EntityLimits::NPCPet::INULL, EntityLimits::NPCPet::INULL, EntityLimits::NPCPet::INULL,
|
EntityLimits::NPCPet::INULL, EntityLimits::NPCPet::INULL, EntityLimits::NPCPet::INULL,
|
||||||
EntityLimits::NPCPet::INULL
|
EntityLimits::NPCPet::INULL, EntityLimits::NPCPet::INULL, EntityLimits::NPCPet::INULL
|
||||||
),
|
),
|
||||||
|
|
||||||
EntityLimits::NPCPet::INULL,
|
EntityLimits::NPCPet::INULL,
|
||||||
@@ -543,7 +551,7 @@ static const EQ::inventory::LookupEntry inventory_static_lookup_entries[EQ::vers
|
|||||||
EntityLimits::MercPet::INULL, EntityLimits::MercPet::INULL, EntityLimits::MercPet::INULL,
|
EntityLimits::MercPet::INULL, EntityLimits::MercPet::INULL, EntityLimits::MercPet::INULL,
|
||||||
EntityLimits::MercPet::INULL, EntityLimits::MercPet::INULL, EntityLimits::MercPet::INULL,
|
EntityLimits::MercPet::INULL, EntityLimits::MercPet::INULL, EntityLimits::MercPet::INULL,
|
||||||
EntityLimits::MercPet::INULL, EntityLimits::MercPet::INULL, EntityLimits::MercPet::INULL,
|
EntityLimits::MercPet::INULL, EntityLimits::MercPet::INULL, EntityLimits::MercPet::INULL,
|
||||||
EntityLimits::MercPet::INULL
|
EntityLimits::MercPet::INULL, EntityLimits::MercPet::INULL, EntityLimits::MercPet::INULL
|
||||||
),
|
),
|
||||||
|
|
||||||
EntityLimits::MercPet::INULL,
|
EntityLimits::MercPet::INULL,
|
||||||
@@ -570,7 +578,7 @@ static const EQ::inventory::LookupEntry inventory_static_lookup_entries[EQ::vers
|
|||||||
EntityLimits::BotPet::INULL, EntityLimits::BotPet::INULL, EntityLimits::BotPet::INULL,
|
EntityLimits::BotPet::INULL, EntityLimits::BotPet::INULL, EntityLimits::BotPet::INULL,
|
||||||
EntityLimits::BotPet::INULL, EntityLimits::BotPet::INULL, EntityLimits::BotPet::INULL,
|
EntityLimits::BotPet::INULL, EntityLimits::BotPet::INULL, EntityLimits::BotPet::INULL,
|
||||||
EntityLimits::BotPet::INULL, EntityLimits::BotPet::INULL, EntityLimits::BotPet::INULL,
|
EntityLimits::BotPet::INULL, EntityLimits::BotPet::INULL, EntityLimits::BotPet::INULL,
|
||||||
EntityLimits::BotPet::INULL
|
EntityLimits::BotPet::INULL, EntityLimits::BotPet::INULL, EntityLimits::BotPet::INULL
|
||||||
),
|
),
|
||||||
|
|
||||||
EntityLimits::BotPet::INULL,
|
EntityLimits::BotPet::INULL,
|
||||||
@@ -597,7 +605,7 @@ static const EQ::inventory::LookupEntry inventory_static_lookup_entries[EQ::vers
|
|||||||
Titanium::invtype::VIEW_MOD_PC_SIZE, Titanium::invtype::VIEW_MOD_BANK_SIZE, Titanium::invtype::VIEW_MOD_SHARED_BANK_SIZE,
|
Titanium::invtype::VIEW_MOD_PC_SIZE, Titanium::invtype::VIEW_MOD_BANK_SIZE, Titanium::invtype::VIEW_MOD_SHARED_BANK_SIZE,
|
||||||
Titanium::invtype::VIEW_MOD_LIMBO_SIZE, Titanium::INULL, Titanium::INULL,
|
Titanium::invtype::VIEW_MOD_LIMBO_SIZE, Titanium::INULL, Titanium::INULL,
|
||||||
Titanium::INULL, Titanium::INULL, Titanium::INULL,
|
Titanium::INULL, Titanium::INULL, Titanium::INULL,
|
||||||
Titanium::INULL
|
Titanium::INULL, Titanium::INULL, Titanium::INULL
|
||||||
),
|
),
|
||||||
|
|
||||||
Titanium::INULL,
|
Titanium::INULL,
|
||||||
@@ -624,7 +632,7 @@ static const EQ::inventory::LookupEntry inventory_static_lookup_entries[EQ::vers
|
|||||||
SoF::invtype::VIEW_MOD_PC_SIZE, SoF::invtype::VIEW_MOD_BANK_SIZE, SoF::invtype::VIEW_MOD_SHARED_BANK_SIZE,
|
SoF::invtype::VIEW_MOD_PC_SIZE, SoF::invtype::VIEW_MOD_BANK_SIZE, SoF::invtype::VIEW_MOD_SHARED_BANK_SIZE,
|
||||||
SoF::invtype::VIEW_MOD_LIMBO_SIZE, SoF::INULL, SoF::INULL,
|
SoF::invtype::VIEW_MOD_LIMBO_SIZE, SoF::INULL, SoF::INULL,
|
||||||
SoF::INULL, SoF::INULL, SoF::INULL,
|
SoF::INULL, SoF::INULL, SoF::INULL,
|
||||||
SoF::INULL
|
SoF::INULL, SoF::INULL, SoF::INULL
|
||||||
),
|
),
|
||||||
|
|
||||||
SoF::INULL,
|
SoF::INULL,
|
||||||
@@ -651,7 +659,7 @@ static const EQ::inventory::LookupEntry inventory_static_lookup_entries[EQ::vers
|
|||||||
SoD::invtype::VIEW_MOD_PC_SIZE, SoD::invtype::VIEW_MOD_BANK_SIZE, SoD::invtype::VIEW_MOD_SHARED_BANK_SIZE,
|
SoD::invtype::VIEW_MOD_PC_SIZE, SoD::invtype::VIEW_MOD_BANK_SIZE, SoD::invtype::VIEW_MOD_SHARED_BANK_SIZE,
|
||||||
SoD::invtype::VIEW_MOD_LIMBO_SIZE, SoD::INULL, SoD::INULL,
|
SoD::invtype::VIEW_MOD_LIMBO_SIZE, SoD::INULL, SoD::INULL,
|
||||||
SoD::INULL, SoD::INULL, SoD::INULL,
|
SoD::INULL, SoD::INULL, SoD::INULL,
|
||||||
SoD::INULL
|
SoD::INULL, SoD::INULL, SoD::INULL
|
||||||
),
|
),
|
||||||
|
|
||||||
SoD::INULL,
|
SoD::INULL,
|
||||||
@@ -678,7 +686,7 @@ static const EQ::inventory::LookupEntry inventory_static_lookup_entries[EQ::vers
|
|||||||
UF::invtype::VIEW_MOD_PC_SIZE, UF::invtype::VIEW_MOD_BANK_SIZE, UF::invtype::VIEW_MOD_SHARED_BANK_SIZE,
|
UF::invtype::VIEW_MOD_PC_SIZE, UF::invtype::VIEW_MOD_BANK_SIZE, UF::invtype::VIEW_MOD_SHARED_BANK_SIZE,
|
||||||
UF::invtype::VIEW_MOD_LIMBO_SIZE, UF::INULL, UF::INULL,
|
UF::invtype::VIEW_MOD_LIMBO_SIZE, UF::INULL, UF::INULL,
|
||||||
UF::INULL, UF::INULL, UF::INULL,
|
UF::INULL, UF::INULL, UF::INULL,
|
||||||
UF::INULL
|
UF::INULL, UF::INULL, UF::INULL
|
||||||
),
|
),
|
||||||
|
|
||||||
UF::INULL,
|
UF::INULL,
|
||||||
@@ -705,7 +713,7 @@ static const EQ::inventory::LookupEntry inventory_static_lookup_entries[EQ::vers
|
|||||||
RoF::invtype::VIEW_MOD_PC_SIZE, RoF::invtype::VIEW_MOD_BANK_SIZE, RoF::invtype::VIEW_MOD_SHARED_BANK_SIZE,
|
RoF::invtype::VIEW_MOD_PC_SIZE, RoF::invtype::VIEW_MOD_BANK_SIZE, RoF::invtype::VIEW_MOD_SHARED_BANK_SIZE,
|
||||||
RoF::invtype::VIEW_MOD_LIMBO_SIZE, RoF::INULL, RoF::INULL,
|
RoF::invtype::VIEW_MOD_LIMBO_SIZE, RoF::INULL, RoF::INULL,
|
||||||
RoF::INULL, RoF::INULL, RoF::INULL,
|
RoF::INULL, RoF::INULL, RoF::INULL,
|
||||||
RoF::INULL
|
RoF::INULL, RoF::INULL, RoF::INULL
|
||||||
),
|
),
|
||||||
|
|
||||||
RoF::INULL,
|
RoF::INULL,
|
||||||
@@ -732,7 +740,7 @@ static const EQ::inventory::LookupEntry inventory_static_lookup_entries[EQ::vers
|
|||||||
RoF2::invtype::VIEW_MOD_PC_SIZE, RoF2::invtype::VIEW_MOD_BANK_SIZE, RoF2::invtype::VIEW_MOD_SHARED_BANK_SIZE,
|
RoF2::invtype::VIEW_MOD_PC_SIZE, RoF2::invtype::VIEW_MOD_BANK_SIZE, RoF2::invtype::VIEW_MOD_SHARED_BANK_SIZE,
|
||||||
RoF2::invtype::VIEW_MOD_LIMBO_SIZE, RoF2::INULL, RoF2::INULL,
|
RoF2::invtype::VIEW_MOD_LIMBO_SIZE, RoF2::INULL, RoF2::INULL,
|
||||||
RoF2::INULL, RoF2::INULL, RoF2::INULL,
|
RoF2::INULL, RoF2::INULL, RoF2::INULL,
|
||||||
RoF2::INULL
|
RoF2::INULL, RoF2::INULL, RoF2::INULL
|
||||||
),
|
),
|
||||||
|
|
||||||
RoF2::INULL,
|
RoF2::INULL,
|
||||||
|
|||||||
+8
-5
@@ -42,6 +42,7 @@ namespace EQ
|
|||||||
uint32 ExpansionsMask;
|
uint32 ExpansionsMask;
|
||||||
int16 CharacterCreationLimit;
|
int16 CharacterCreationLimit;
|
||||||
size_t SayLinkBodySize;
|
size_t SayLinkBodySize;
|
||||||
|
uint32 BazaarTraderLimit;
|
||||||
|
|
||||||
LookupEntry(const LookupEntry *lookup_entry) { }
|
LookupEntry(const LookupEntry *lookup_entry) { }
|
||||||
LookupEntry(
|
LookupEntry(
|
||||||
@@ -49,13 +50,15 @@ namespace EQ
|
|||||||
uint32 ExpansionBit,
|
uint32 ExpansionBit,
|
||||||
uint32 ExpansionsMask,
|
uint32 ExpansionsMask,
|
||||||
int16 CharacterCreationLimit,
|
int16 CharacterCreationLimit,
|
||||||
size_t SayLinkBodySize
|
size_t SayLinkBodySize,
|
||||||
|
uint32 BazaarTraderLimit
|
||||||
) :
|
) :
|
||||||
Expansion(Expansion),
|
Expansion(Expansion),
|
||||||
ExpansionBit(ExpansionBit),
|
ExpansionBit(ExpansionBit),
|
||||||
ExpansionsMask(ExpansionsMask),
|
ExpansionsMask(ExpansionsMask),
|
||||||
CharacterCreationLimit(CharacterCreationLimit),
|
CharacterCreationLimit(CharacterCreationLimit),
|
||||||
SayLinkBodySize(SayLinkBodySize)
|
SayLinkBodySize(SayLinkBodySize),
|
||||||
|
BazaarTraderLimit(BazaarTraderLimit)
|
||||||
{ }
|
{ }
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -84,7 +87,7 @@ namespace EQ
|
|||||||
int16 ViewMODPC, ViewMODBank, ViewMODSharedBank;
|
int16 ViewMODPC, ViewMODBank, ViewMODSharedBank;
|
||||||
int16 ViewMODLimbo, AltStorage, Archived;
|
int16 ViewMODLimbo, AltStorage, Archived;
|
||||||
int16 Mail, GuildTrophyTribute, Krono;
|
int16 Mail, GuildTrophyTribute, Krono;
|
||||||
int16 Other;
|
int16 GuildBankMain,GuildBankDeposit, Other;
|
||||||
|
|
||||||
InventoryTypeSize_Struct(
|
InventoryTypeSize_Struct(
|
||||||
int16 Possessions, int16 Bank, int16 SharedBank,
|
int16 Possessions, int16 Bank, int16 SharedBank,
|
||||||
@@ -95,7 +98,7 @@ namespace EQ
|
|||||||
int16 ViewMODPC, int16 ViewMODBank, int16 ViewMODSharedBank,
|
int16 ViewMODPC, int16 ViewMODBank, int16 ViewMODSharedBank,
|
||||||
int16 ViewMODLimbo, int16 AltStorage, int16 Archived,
|
int16 ViewMODLimbo, int16 AltStorage, int16 Archived,
|
||||||
int16 Mail, int16 GuildTrophyTribute, int16 Krono,
|
int16 Mail, int16 GuildTrophyTribute, int16 Krono,
|
||||||
int16 Other
|
int16 GuildBankMain,int16 GuildBankDeposit, int16 Other
|
||||||
) :
|
) :
|
||||||
Possessions(Possessions), Bank(Bank), SharedBank(SharedBank),
|
Possessions(Possessions), Bank(Bank), SharedBank(SharedBank),
|
||||||
Trade(Trade), World(World), Limbo(Limbo),
|
Trade(Trade), World(World), Limbo(Limbo),
|
||||||
@@ -105,7 +108,7 @@ namespace EQ
|
|||||||
ViewMODPC(ViewMODPC), ViewMODBank(ViewMODBank), ViewMODSharedBank(ViewMODSharedBank),
|
ViewMODPC(ViewMODPC), ViewMODBank(ViewMODBank), ViewMODSharedBank(ViewMODSharedBank),
|
||||||
ViewMODLimbo(ViewMODLimbo), AltStorage(AltStorage), Archived(Archived),
|
ViewMODLimbo(ViewMODLimbo), AltStorage(AltStorage), Archived(Archived),
|
||||||
Mail(Mail), GuildTrophyTribute(GuildTrophyTribute), Krono(Krono),
|
Mail(Mail), GuildTrophyTribute(GuildTrophyTribute), Krono(Krono),
|
||||||
Other(Other)
|
GuildBankMain(GuildBankMain), GuildBankDeposit(GuildBankDeposit), Other(Other)
|
||||||
{ }
|
{ }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
+166
-40
@@ -19,17 +19,17 @@
|
|||||||
#ifndef EQ_PACKET_STRUCTS_H
|
#ifndef EQ_PACKET_STRUCTS_H
|
||||||
#define EQ_PACKET_STRUCTS_H
|
#define EQ_PACKET_STRUCTS_H
|
||||||
|
|
||||||
#include "types.h"
|
#include <list>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <list>
|
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
|
#include <cereal/archives/binary.hpp>
|
||||||
|
#include <cereal/types/string.hpp>
|
||||||
|
#include <cereal/types/vector.hpp>
|
||||||
#include "../common/version.h"
|
#include "../common/version.h"
|
||||||
#include "emu_constants.h"
|
#include "emu_constants.h"
|
||||||
#include "textures.h"
|
#include "textures.h"
|
||||||
#include "../cereal/include/cereal/archives/binary.hpp"
|
#include "types.h"
|
||||||
#include "../cereal/include/cereal/types/string.hpp"
|
|
||||||
#include "../cereal/include/cereal/types/vector.hpp"
|
|
||||||
|
|
||||||
static const uint32 BUFF_COUNT = 42;
|
static const uint32 BUFF_COUNT = 42;
|
||||||
static const uint32 PET_BUFF_COUNT = 30;
|
static const uint32 PET_BUFF_COUNT = 30;
|
||||||
@@ -47,7 +47,7 @@ static const uint32 ADVANCED_LORE_LENGTH = 8192;
|
|||||||
*/
|
*/
|
||||||
#pragma pack(1)
|
#pragma pack(1)
|
||||||
|
|
||||||
struct LoginInfo_Struct {
|
struct LoginInfo {
|
||||||
/*000*/ char login_info[64];
|
/*000*/ char login_info[64];
|
||||||
/*064*/ uint8 unknown064[124];
|
/*064*/ uint8 unknown064[124];
|
||||||
/*188*/ uint8 zoning; // 01 if zoning, 00 if not
|
/*188*/ uint8 zoning; // 01 if zoning, 00 if not
|
||||||
@@ -324,6 +324,8 @@ union
|
|||||||
bool guild_show;
|
bool guild_show;
|
||||||
bool trader;
|
bool trader;
|
||||||
bool buyer;
|
bool buyer;
|
||||||
|
bool untargetable;
|
||||||
|
uint32 npc_tint_id;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct PlayerState_Struct {
|
struct PlayerState_Struct {
|
||||||
@@ -3221,6 +3223,7 @@ struct BuyerMessaging_Struct {
|
|||||||
char item_name[64];
|
char item_name[64];
|
||||||
uint32 slot;
|
uint32 slot;
|
||||||
uint32 seller_quantity;
|
uint32 seller_quantity;
|
||||||
|
uint32 purchase_method; // 0 direct merchant, 1 via /barter window
|
||||||
};
|
};
|
||||||
|
|
||||||
struct BuyerAddBuyertoBarterWindow_Struct {
|
struct BuyerAddBuyertoBarterWindow_Struct {
|
||||||
@@ -3741,7 +3744,8 @@ struct GetItems_Struct{
|
|||||||
|
|
||||||
struct BecomeTrader_Struct {
|
struct BecomeTrader_Struct {
|
||||||
uint32 action;
|
uint32 action;
|
||||||
uint32 zone_id;
|
uint16 zone_id;
|
||||||
|
uint16 zone_instance_id;
|
||||||
uint32 trader_id;
|
uint32 trader_id;
|
||||||
uint32 entity_id;
|
uint32 entity_id;
|
||||||
char trader_name[64];
|
char trader_name[64];
|
||||||
@@ -4281,6 +4285,10 @@ struct NewCombine_Struct {
|
|||||||
/*04*/
|
/*04*/
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct TradeSkillRecipeInspect_Struct {
|
||||||
|
uint32 recipe_id;
|
||||||
|
uint32 padding[17]; // unknown
|
||||||
|
};
|
||||||
|
|
||||||
//client requesting favorite recipies
|
//client requesting favorite recipies
|
||||||
struct TradeskillFavorites_Struct {
|
struct TradeskillFavorites_Struct {
|
||||||
@@ -5523,46 +5531,55 @@ struct GuildBankWithdrawItem_Struct
|
|||||||
|
|
||||||
struct GuildBankItemUpdate_Struct
|
struct GuildBankItemUpdate_Struct
|
||||||
{
|
{
|
||||||
void Init(uint32 inAction, uint32 inUnknown004, uint16 inSlotID, uint16 inArea, uint16 inUnknown012, uint32 inItemID, uint32 inIcon, uint32 inQuantity,
|
void Init(
|
||||||
uint32 inPermissions, uint32 inAllowMerge, bool inUseable)
|
uint32 inAction,
|
||||||
|
uint32 inUnknown004,
|
||||||
|
uint16 inSlotID,
|
||||||
|
uint16 inArea,
|
||||||
|
uint16 inUnknown012,
|
||||||
|
uint32 inItemID,
|
||||||
|
uint32 inIcon,
|
||||||
|
uint32 inQuantity,
|
||||||
|
uint32 inPermissions,
|
||||||
|
uint32 inAllowMerge,
|
||||||
|
bool inUseable)
|
||||||
{
|
{
|
||||||
Action = inAction;
|
action = inAction;
|
||||||
Unknown004 = inUnknown004;
|
unknown004 = inUnknown004;
|
||||||
SlotID = inSlotID;
|
slot_id = inSlotID;
|
||||||
Area = inArea;
|
area = inArea;
|
||||||
Unknown012 = inUnknown012;
|
display = inUnknown012;
|
||||||
ItemID = inItemID;
|
item_id = inItemID;
|
||||||
Icon = inIcon;
|
icon_id = inIcon;
|
||||||
Quantity = inQuantity;
|
quantity = inQuantity;
|
||||||
Permissions = inPermissions;
|
permissions = inPermissions;
|
||||||
AllowMerge = inAllowMerge;
|
allow_merge = inAllowMerge;
|
||||||
Useable = inUseable;
|
is_useable = inUseable;
|
||||||
ItemName[0] = '\0';
|
item_name[0] = '\0';
|
||||||
Donator[0] = '\0';
|
donator[0] = '\0';
|
||||||
WhoFor[0] = '\0';
|
who_for[0] = '\0';
|
||||||
};
|
};
|
||||||
|
|
||||||
/*000*/ uint32 Action;
|
/*000*/ uint32 action;
|
||||||
/*004*/ uint32 Unknown004;
|
/*004*/ uint32 unknown004;
|
||||||
/*008*/ uint16 SlotID;
|
/*008*/ uint16 slot_id;
|
||||||
/*010*/ uint16 Area;
|
/*010*/ uint16 area;
|
||||||
/*012*/ uint32 Unknown012;
|
/*012*/ uint32 display;
|
||||||
/*016*/ uint32 ItemID;
|
/*016*/ uint32 item_id;
|
||||||
/*020*/ uint32 Icon;
|
/*020*/ uint32 icon_id;
|
||||||
/*024*/ uint32 Quantity;
|
/*024*/ uint32 quantity;
|
||||||
/*028*/ uint32 Permissions;
|
/*028*/ uint32 permissions;
|
||||||
/*032*/ uint8 AllowMerge;
|
/*032*/ uint8 allow_merge;
|
||||||
/*033*/ uint8 Useable; // Used in conjunction with the Public-if-useable permission.
|
/*033*/ uint8 is_useable; // Used in conjunction with the Public-if-useable permission.
|
||||||
/*034*/ char ItemName[64];
|
/*034*/ char item_name[64];
|
||||||
/*098*/ char Donator[64];
|
/*098*/ char donator[64];
|
||||||
/*162*/ char WhoFor[64];
|
/*162*/ char who_for[64];
|
||||||
/*226*/ uint16 Unknown226;
|
/*226*/ uint16 unknown226;
|
||||||
};
|
};
|
||||||
|
|
||||||
// newer clients (RoF+) send a list that contains 240 entries
|
// newer clients (RoF+) send a list that contains 240 entries
|
||||||
// The packets don't actually use all 64 chars in the strings, but we'll just overallocate for these
|
// The packets don't actually use all 64 chars in the strings, but we'll just overallocate for these
|
||||||
struct GuildBankItemListEntry_Struct
|
struct GuildBankItemListEntry_Struct {
|
||||||
{
|
|
||||||
uint8 vaild;
|
uint8 vaild;
|
||||||
uint32 permissions;
|
uint32 permissions;
|
||||||
char whofor[64];
|
char whofor[64];
|
||||||
@@ -5817,6 +5834,28 @@ struct ChangeSize_Struct
|
|||||||
/*16*/
|
/*16*/
|
||||||
};
|
};
|
||||||
|
|
||||||
|
enum ChangeNameResponse : int {
|
||||||
|
Denied = 0, // 5167: "You have requested an invalid name or a Customer Service Representative has denied your name request. Please try another name."
|
||||||
|
Accepted = 1, // 5976: "Your request for a name change was successful."
|
||||||
|
Timeout = -1, // 5977: "Your request for a name change has timed out. Please try again later."
|
||||||
|
ServerError = -2, // 5978: "The server had an error while processing your name request. Please try again later."
|
||||||
|
RateLimited = -3, // 5979: "You must wait longer before submitting another name request. Please try again in a few minutes."
|
||||||
|
Ineligible = -4, // 5980: "Your character is not eligible for a name change."
|
||||||
|
Pending = -5 // 5193: "You already have a name change pending. Please wait until it is fully processed before attempting another name change."
|
||||||
|
};
|
||||||
|
|
||||||
|
struct AltChangeName_Struct {
|
||||||
|
/*00*/ char new_name[64];
|
||||||
|
/*40*/ char old_name[64];
|
||||||
|
/*80*/ int response_code;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct ChangePetName_Struct {
|
||||||
|
/*00*/ char new_pet_name[64];
|
||||||
|
/*40*/ char pet_owner_name[64];
|
||||||
|
/*80*/ int response_code;
|
||||||
|
};
|
||||||
|
|
||||||
// New OpCode/Struct for SoD+
|
// New OpCode/Struct for SoD+
|
||||||
struct GroupMakeLeader_Struct
|
struct GroupMakeLeader_Struct
|
||||||
{
|
{
|
||||||
@@ -6346,6 +6385,7 @@ enum BazaarTraderBarterActions {
|
|||||||
TraderAck2 = 22,
|
TraderAck2 = 22,
|
||||||
AddTraderToBazaarWindow = 24,
|
AddTraderToBazaarWindow = 24,
|
||||||
RemoveTraderFromBazaarWindow = 25,
|
RemoveTraderFromBazaarWindow = 25,
|
||||||
|
FirstOpenSearch = 26,
|
||||||
ClickTrader = 28,
|
ClickTrader = 28,
|
||||||
DeliveryCostUpdate = 29
|
DeliveryCostUpdate = 29
|
||||||
};
|
};
|
||||||
@@ -6385,6 +6425,7 @@ struct BazaarSearchResultsFromDB_Struct {
|
|||||||
uint32 icon_id;
|
uint32 icon_id;
|
||||||
uint32 sum_charges;
|
uint32 sum_charges;
|
||||||
uint32 trader_zone_id;
|
uint32 trader_zone_id;
|
||||||
|
int32 trader_zone_instance_id;
|
||||||
uint32 trader_entity_id;
|
uint32 trader_entity_id;
|
||||||
uint32 item_stat;
|
uint32 item_stat;
|
||||||
bool stackable;
|
bool stackable;
|
||||||
@@ -6406,6 +6447,7 @@ struct BazaarSearchResultsFromDB_Struct {
|
|||||||
CEREAL_NVP(icon_id),
|
CEREAL_NVP(icon_id),
|
||||||
CEREAL_NVP(sum_charges),
|
CEREAL_NVP(sum_charges),
|
||||||
CEREAL_NVP(trader_zone_id),
|
CEREAL_NVP(trader_zone_id),
|
||||||
|
CEREAL_NVP(trader_zone_instance_id),
|
||||||
CEREAL_NVP(trader_entity_id),
|
CEREAL_NVP(trader_entity_id),
|
||||||
CEREAL_NVP(item_stat),
|
CEREAL_NVP(item_stat),
|
||||||
CEREAL_NVP(stackable),
|
CEREAL_NVP(stackable),
|
||||||
@@ -6435,6 +6477,90 @@ struct BuylineItemDetails_Struct {
|
|||||||
uint32 item_quantity;
|
uint32 item_quantity;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct PickZoneEntry_Struct {
|
||||||
|
int16 zone_id;
|
||||||
|
int16 unknown;
|
||||||
|
int32 player_count;
|
||||||
|
int32 instance_id;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct PickZoneWindow_Struct {
|
||||||
|
char padding000[64];
|
||||||
|
int64 session_id;
|
||||||
|
int8 option_count;
|
||||||
|
char padding073[23];
|
||||||
|
PickZoneEntry_Struct entries[10];
|
||||||
|
};
|
||||||
|
|
||||||
|
struct PickZone_Struct {
|
||||||
|
int64 session_id;
|
||||||
|
int32 selection_id;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct EvolveItemToggle {
|
||||||
|
uint32 action;
|
||||||
|
uint32 unknown_004;
|
||||||
|
uint64 unique_id;
|
||||||
|
uint32 percentage;
|
||||||
|
uint32 activated;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct EvolveXPWindowReceive {
|
||||||
|
uint32 action;
|
||||||
|
uint32 unknown_004;
|
||||||
|
uint64 item1_unique_id;
|
||||||
|
uint64 item2_unique_id;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct EvolveItemMessaging {
|
||||||
|
uint32 action;
|
||||||
|
char serialized_data[];
|
||||||
|
};
|
||||||
|
|
||||||
|
struct EvolveXPWindowSend {
|
||||||
|
/*000*/ uint32 action;
|
||||||
|
/*004*/ uint64 item1_unique_id;
|
||||||
|
/*012*/ uint64 item2_unique_id;
|
||||||
|
/*020*/ uint32 compatibility;
|
||||||
|
/*024*/ uint32 max_transfer_level;
|
||||||
|
/*028*/ uint8 item1_present;
|
||||||
|
/*029*/ uint8 item2_present;
|
||||||
|
/*030*/ std::string serialize_item_1;
|
||||||
|
/*034*/ std::string serialize_item_2;
|
||||||
|
|
||||||
|
template<class Archive>
|
||||||
|
void serialize(Archive &archive)
|
||||||
|
{
|
||||||
|
archive(
|
||||||
|
CEREAL_NVP(action),
|
||||||
|
CEREAL_NVP(item1_unique_id),
|
||||||
|
CEREAL_NVP(item2_unique_id),
|
||||||
|
CEREAL_NVP(compatibility),
|
||||||
|
CEREAL_NVP(max_transfer_level),
|
||||||
|
CEREAL_NVP(item1_present),
|
||||||
|
CEREAL_NVP(item2_present),
|
||||||
|
CEREAL_NVP(serialize_item_1),
|
||||||
|
CEREAL_NVP(serialize_item_2)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
struct EvolveTransfer {
|
||||||
|
uint32 item_from_id;
|
||||||
|
uint32 item_from_current_amount;
|
||||||
|
uint32 item_to_id;
|
||||||
|
uint32 item_to_current_amount;
|
||||||
|
uint32 compatibility;
|
||||||
|
uint32 max_transfer_level;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct EvolveGetNextItem {
|
||||||
|
uint32 new_item_id;
|
||||||
|
uint64 new_current_amount;
|
||||||
|
uint64 from_current_amount;
|
||||||
|
uint32 max_transfer_level;
|
||||||
|
};
|
||||||
|
|
||||||
// Restore structure packing to default
|
// Restore structure packing to default
|
||||||
#pragma pack()
|
#pragma pack()
|
||||||
|
|
||||||
|
|||||||
@@ -545,13 +545,13 @@ void EQStream::SendPacket(uint16 opcode, EQApplicationPacket *p)
|
|||||||
uint32 chunksize, used;
|
uint32 chunksize, used;
|
||||||
uint32 length;
|
uint32 length;
|
||||||
|
|
||||||
if (LogSys.log_settings[Logs::Server_Client_Packet].is_category_enabled == 1){
|
if (EQEmuLogSys::Instance()->log_settings[Logs::Server_Client_Packet].is_category_enabled == 1){
|
||||||
if (p->GetOpcode() != OP_SpecialMesg){
|
if (p->GetOpcode() != OP_SpecialMesg){
|
||||||
Log(Logs::General, Logs::Server_Client_Packet, "[%s - 0x%04x] [Size: %u]", OpcodeManager::EmuToName(p->GetOpcode()), p->GetOpcode(), p->Size());
|
Log(Logs::General, Logs::Server_Client_Packet, "[%s - 0x%04x] [Size: %u]", OpcodeManager::EmuToName(p->GetOpcode()), p->GetOpcode(), p->Size());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (LogSys.log_settings[Logs::Server_Client_Packet_With_Dump].is_category_enabled == 1){
|
if (EQEmuLogSys::Instance()->log_settings[Logs::Server_Client_Packet_With_Dump].is_category_enabled == 1){
|
||||||
if (p->GetOpcode() != OP_SpecialMesg){
|
if (p->GetOpcode() != OP_SpecialMesg){
|
||||||
Log(Logs::General, Logs::Server_Client_Packet_With_Dump, "[%s - 0x%04x] [Size: %u] %s", OpcodeManager::EmuToName(p->GetOpcode()), p->GetOpcode(), p->Size(), DumpPacketToString(p).c_str());
|
Log(Logs::General, Logs::Server_Client_Packet_With_Dump, "[%s - 0x%04x] [Size: %u] %s", OpcodeManager::EmuToName(p->GetOpcode()), p->GetOpcode(), p->Size(), DumpPacketToString(p).c_str());
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
#include <string>
|
#include <string>
|
||||||
#include "emu_versions.h"
|
#include "emu_versions.h"
|
||||||
#include "eq_packet.h"
|
#include "eq_packet.h"
|
||||||
#include "net/daybreak_connection.h"
|
#include "net/reliable_stream_connection.h"
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
ESTABLISHED,
|
ESTABLISHED,
|
||||||
@@ -33,18 +33,18 @@ struct EQStreamManagerInterfaceOptions
|
|||||||
//Login I had trouble getting to recognize compression at all
|
//Login I had trouble getting to recognize compression at all
|
||||||
//but that might be because it was still a bit buggy when i was testing that.
|
//but that might be because it was still a bit buggy when i was testing that.
|
||||||
if (compressed) {
|
if (compressed) {
|
||||||
daybreak_options.encode_passes[0] = EQ::Net::EncodeCompression;
|
reliable_stream_options.encode_passes[0] = EQ::Net::EncodeCompression;
|
||||||
}
|
}
|
||||||
else if (encoded) {
|
else if (encoded) {
|
||||||
daybreak_options.encode_passes[0] = EQ::Net::EncodeXOR;
|
reliable_stream_options.encode_passes[0] = EQ::Net::EncodeXOR;
|
||||||
}
|
}
|
||||||
|
|
||||||
daybreak_options.port = port;
|
reliable_stream_options.port = port;
|
||||||
}
|
}
|
||||||
|
|
||||||
int opcode_size;
|
int opcode_size;
|
||||||
bool track_opcode_stats;
|
bool track_opcode_stats;
|
||||||
EQ::Net::DaybreakConnectionManagerOptions daybreak_options;
|
EQ::Net::ReliableStreamConnectionManagerOptions reliable_stream_options;
|
||||||
};
|
};
|
||||||
|
|
||||||
class EQStreamManagerInterface
|
class EQStreamManagerInterface
|
||||||
@@ -80,7 +80,7 @@ public:
|
|||||||
|
|
||||||
struct Stats
|
struct Stats
|
||||||
{
|
{
|
||||||
EQ::Net::DaybreakConnectionStats DaybreakStats;
|
EQ::Net::ReliableStreamConnectionStats ReliableStreamStats;
|
||||||
int RecvCount[_maxEmuOpcode];
|
int RecvCount[_maxEmuOpcode];
|
||||||
int SentCount[_maxEmuOpcode];
|
int SentCount[_maxEmuOpcode];
|
||||||
};
|
};
|
||||||
|
|||||||
+21
-3
@@ -94,7 +94,7 @@ void EQEmuConfig::parse_config()
|
|||||||
auto_database_updates = true;
|
auto_database_updates = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
WorldIP = _root["server"]["world"]["tcp"].get("host", "127.0.0.1").asString();
|
WorldIP = _root["server"]["world"]["tcp"].get("ip", "127.0.0.1").asString();
|
||||||
WorldTCPPort = Strings::ToUnsignedInt(_root["server"]["world"]["tcp"].get("port", "9000").asString());
|
WorldTCPPort = Strings::ToUnsignedInt(_root["server"]["world"]["tcp"].get("port", "9000").asString());
|
||||||
|
|
||||||
TelnetIP = _root["server"]["world"]["telnet"].get("ip", "127.0.0.1").asString();
|
TelnetIP = _root["server"]["world"]["telnet"].get("ip", "127.0.0.1").asString();
|
||||||
@@ -147,6 +147,8 @@ void EQEmuConfig::parse_config()
|
|||||||
QSDatabaseUsername = _root["server"]["qsdatabase"].get("username", "eq").asString();
|
QSDatabaseUsername = _root["server"]["qsdatabase"].get("username", "eq").asString();
|
||||||
QSDatabasePassword = _root["server"]["qsdatabase"].get("password", "eq").asString();
|
QSDatabasePassword = _root["server"]["qsdatabase"].get("password", "eq").asString();
|
||||||
QSDatabaseDB = _root["server"]["qsdatabase"].get("db", "eq").asString();
|
QSDatabaseDB = _root["server"]["qsdatabase"].get("db", "eq").asString();
|
||||||
|
QSHost = _root["server"]["queryserver"].get("host", "localhost").asString();
|
||||||
|
QSPort = Strings::ToUnsignedInt(_root["server"]["queryserver"].get("port", "9500").asString());
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Zones
|
* Zones
|
||||||
@@ -171,9 +173,25 @@ void EQEmuConfig::parse_config()
|
|||||||
PluginDir = _root["server"]["directories"].get("plugins", "plugins/").asString();
|
PluginDir = _root["server"]["directories"].get("plugins", "plugins/").asString();
|
||||||
LuaModuleDir = _root["server"]["directories"].get("lua_modules", "lua_modules/").asString();
|
LuaModuleDir = _root["server"]["directories"].get("lua_modules", "lua_modules/").asString();
|
||||||
PatchDir = _root["server"]["directories"].get("patches", "./").asString();
|
PatchDir = _root["server"]["directories"].get("patches", "./").asString();
|
||||||
|
OpcodeDir = _root["server"]["directories"].get("opcodes", "./").asString();
|
||||||
SharedMemDir = _root["server"]["directories"].get("shared_memory", "shared/").asString();
|
SharedMemDir = _root["server"]["directories"].get("shared_memory", "shared/").asString();
|
||||||
LogDir = _root["server"]["directories"].get("logs", "logs/").asString();
|
LogDir = _root["server"]["directories"].get("logs", "logs/").asString();
|
||||||
|
|
||||||
|
auto load_paths = [&](const std::string& key, std::vector<std::string>& target) {
|
||||||
|
const auto& paths = _root["server"]["directories"][key];
|
||||||
|
if (paths.isArray()) {
|
||||||
|
for (const auto& dir : paths) {
|
||||||
|
if (dir.isString()) {
|
||||||
|
target.push_back(dir.asString());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
load_paths("quest_paths", m_quest_directories);
|
||||||
|
load_paths("plugin_paths", m_plugin_directories);
|
||||||
|
load_paths("lua_module_paths", m_lua_module_directories);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Logs
|
* Logs
|
||||||
*/
|
*/
|
||||||
@@ -418,11 +436,11 @@ void EQEmuConfig::CheckUcsConfigConversion()
|
|||||||
LogInfo("Migrating old [eqemu_config] UCS configuration to new configuration");
|
LogInfo("Migrating old [eqemu_config] UCS configuration to new configuration");
|
||||||
|
|
||||||
std::string config_file_path = std::filesystem::path{
|
std::string config_file_path = std::filesystem::path{
|
||||||
path.GetServerPath() + "/eqemu_config.json"
|
PathManager::Instance()->GetServerPath() + "/eqemu_config.json"
|
||||||
}.string();
|
}.string();
|
||||||
|
|
||||||
std::string config_file_bak_path = std::filesystem::path{
|
std::string config_file_bak_path = std::filesystem::path{
|
||||||
path.GetServerPath() + "/eqemu_config.ucs-migrate-json.bak"
|
PathManager::Instance()->GetServerPath() + "/eqemu_config.ucs-migrate-json.bak"
|
||||||
}.string();
|
}.string();
|
||||||
|
|
||||||
// copy eqemu_config.json to eqemu_config.json.bak
|
// copy eqemu_config.json to eqemu_config.json.bak
|
||||||
|
|||||||
+27
-2
@@ -23,6 +23,7 @@
|
|||||||
#include "path_manager.h"
|
#include "path_manager.h"
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
#include <fmt/format.h>
|
#include <fmt/format.h>
|
||||||
|
#include <fmt/ranges.h>
|
||||||
|
|
||||||
struct LoginConfig {
|
struct LoginConfig {
|
||||||
std::string LoginHost;
|
std::string LoginHost;
|
||||||
@@ -82,6 +83,8 @@ class EQEmuConfig
|
|||||||
std::string QSDatabasePassword;
|
std::string QSDatabasePassword;
|
||||||
std::string QSDatabaseDB;
|
std::string QSDatabaseDB;
|
||||||
uint16 QSDatabasePort;
|
uint16 QSDatabasePort;
|
||||||
|
std::string QSHost;
|
||||||
|
int QSPort;
|
||||||
|
|
||||||
// From <files/>
|
// From <files/>
|
||||||
std::string SpellsFile;
|
std::string SpellsFile;
|
||||||
@@ -95,6 +98,7 @@ class EQEmuConfig
|
|||||||
std::string PluginDir;
|
std::string PluginDir;
|
||||||
std::string LuaModuleDir;
|
std::string LuaModuleDir;
|
||||||
std::string PatchDir;
|
std::string PatchDir;
|
||||||
|
std::string OpcodeDir;
|
||||||
std::string SharedMemDir;
|
std::string SharedMemDir;
|
||||||
std::string LogDir;
|
std::string LogDir;
|
||||||
|
|
||||||
@@ -117,6 +121,22 @@ class EQEmuConfig
|
|||||||
const std::string &GetUCSHost() const;
|
const std::string &GetUCSHost() const;
|
||||||
uint16 GetUCSPort() const;
|
uint16 GetUCSPort() const;
|
||||||
|
|
||||||
|
std::vector<std::string> GetQuestDirectories() const
|
||||||
|
{
|
||||||
|
return m_quest_directories;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::vector<std::string> GetPluginsDirectories() const
|
||||||
|
{
|
||||||
|
return m_plugin_directories;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::vector<std::string> GetLuaModuleDirectories() const
|
||||||
|
{
|
||||||
|
return m_lua_module_directories;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// uint16 DynamicCount;
|
// uint16 DynamicCount;
|
||||||
|
|
||||||
// map<string,uint16> StaticZones;
|
// map<string,uint16> StaticZones;
|
||||||
@@ -130,15 +150,20 @@ class EQEmuConfig
|
|||||||
Json::Value _root;
|
Json::Value _root;
|
||||||
static std::string ConfigFile;
|
static std::string ConfigFile;
|
||||||
|
|
||||||
|
std::vector<std::string> m_quest_directories = {};
|
||||||
|
std::vector<std::string> m_plugin_directories = {};
|
||||||
|
std::vector<std::string> m_lua_module_directories = {};
|
||||||
|
|
||||||
|
protected:
|
||||||
void parse_config();
|
void parse_config();
|
||||||
|
|
||||||
EQEmuConfig()
|
EQEmuConfig()
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
virtual ~EQEmuConfig() {}
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
virtual ~EQEmuConfig() {}
|
||||||
|
|
||||||
// Produce a const singleton
|
// Produce a const singleton
|
||||||
static const EQEmuConfig *get()
|
static const EQEmuConfig *get()
|
||||||
@@ -167,7 +192,7 @@ class EQEmuConfig
|
|||||||
|
|
||||||
std::string file = fmt::format(
|
std::string file = fmt::format(
|
||||||
"{}/{}",
|
"{}/{}",
|
||||||
(file_path.empty() ? path.GetServerPath() : file_path),
|
(file_path.empty() ? PathManager::Instance()->GetServerPath() : file_path),
|
||||||
EQEmuConfig::ConfigFile
|
EQEmuConfig::ConfigFile
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
+49
-10
@@ -25,6 +25,8 @@
|
|||||||
#include "repositories/discord_webhooks_repository.h"
|
#include "repositories/discord_webhooks_repository.h"
|
||||||
#include "repositories/logsys_categories_repository.h"
|
#include "repositories/logsys_categories_repository.h"
|
||||||
#include "termcolor/rang.hpp"
|
#include "termcolor/rang.hpp"
|
||||||
|
#include "path_manager.h"
|
||||||
|
#include "file.h"
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <string>
|
#include <string>
|
||||||
@@ -85,6 +87,7 @@ EQEmuLogSys *EQEmuLogSys::LoadLogSettingsDefaults()
|
|||||||
* Set Defaults
|
* Set Defaults
|
||||||
*/
|
*/
|
||||||
log_settings[Logs::Crash].log_to_console = static_cast<uint8>(Logs::General);
|
log_settings[Logs::Crash].log_to_console = static_cast<uint8>(Logs::General);
|
||||||
|
log_settings[Logs::Crash].log_to_file = static_cast<uint8>(Logs::General);
|
||||||
log_settings[Logs::MySQLError].log_to_console = static_cast<uint8>(Logs::General);
|
log_settings[Logs::MySQLError].log_to_console = static_cast<uint8>(Logs::General);
|
||||||
log_settings[Logs::NPCScaling].log_to_gmsay = 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_gmsay = static_cast<uint8>(Logs::General);
|
||||||
@@ -102,6 +105,8 @@ EQEmuLogSys *EQEmuLogSys::LoadLogSettingsDefaults()
|
|||||||
log_settings[Logs::QuestErrors].log_to_console = static_cast<uint8>(Logs::General);
|
log_settings[Logs::QuestErrors].log_to_console = static_cast<uint8>(Logs::General);
|
||||||
log_settings[Logs::EqTime].log_to_console = static_cast<uint8>(Logs::General);
|
log_settings[Logs::EqTime].log_to_console = static_cast<uint8>(Logs::General);
|
||||||
log_settings[Logs::EqTime].log_to_gmsay = static_cast<uint8>(Logs::General);
|
log_settings[Logs::EqTime].log_to_gmsay = static_cast<uint8>(Logs::General);
|
||||||
|
log_settings[Logs::NpcHandin].log_to_console = static_cast<uint8>(Logs::General);
|
||||||
|
log_settings[Logs::NpcHandin].log_to_gmsay = static_cast<uint8>(Logs::General);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* RFC 5424
|
* RFC 5424
|
||||||
@@ -532,6 +537,11 @@ void EQEmuLogSys::StartFileLogs(const std::string &log_name)
|
|||||||
{
|
{
|
||||||
EQEmuLogSys::CloseFileLogs();
|
EQEmuLogSys::CloseFileLogs();
|
||||||
|
|
||||||
|
if (!File::Exists(PathManager::Instance()->GetLogPath())) {
|
||||||
|
LogInfo("Logs directory not found, creating [{}]", PathManager::Instance()->GetLogPath());
|
||||||
|
File::Makedir(PathManager::Instance()->GetLogPath());
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* When loading settings, we must have been given a reason in category based logging to output to a file in order to even create or open one...
|
* When loading settings, we must have been given a reason in category based logging to output to a file in order to even create or open one...
|
||||||
*/
|
*/
|
||||||
@@ -591,6 +601,8 @@ void EQEmuLogSys::SilenceConsoleLogging()
|
|||||||
log_settings[log_index].is_category_enabled = 0;
|
log_settings[log_index].is_category_enabled = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
log_settings[Logs::MySQLError].log_to_console = static_cast<uint8>(Logs::MySQLError);
|
||||||
|
log_settings[Logs::Error].log_to_console = static_cast<uint8>(Logs::Error);
|
||||||
log_settings[Logs::Crash].log_to_console = static_cast<uint8>(Logs::General);
|
log_settings[Logs::Crash].log_to_console = static_cast<uint8>(Logs::General);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -602,7 +614,7 @@ void EQEmuLogSys::EnableConsoleLogging()
|
|||||||
std::copy(std::begin(pre_silence_settings), std::end(pre_silence_settings), std::begin(log_settings));
|
std::copy(std::begin(pre_silence_settings), std::end(pre_silence_settings), std::begin(log_settings));
|
||||||
}
|
}
|
||||||
|
|
||||||
EQEmuLogSys *EQEmuLogSys::LoadLogDatabaseSettings()
|
EQEmuLogSys *EQEmuLogSys::LoadLogDatabaseSettings(bool silent_load)
|
||||||
{
|
{
|
||||||
InjectTablesIfNotExist();
|
InjectTablesIfNotExist();
|
||||||
|
|
||||||
@@ -644,7 +656,7 @@ EQEmuLogSys *EQEmuLogSys::LoadLogDatabaseSettings()
|
|||||||
// If we go through this whole loop and nothing is set to any debug level, there
|
// If we go through this whole loop and nothing is set to any debug level, there
|
||||||
// is no point to create a file or keep anything open
|
// is no point to create a file or keep anything open
|
||||||
if (log_settings[c.log_category_id].log_to_file > 0) {
|
if (log_settings[c.log_category_id].log_to_file > 0) {
|
||||||
LogSys.m_file_logs_enabled = true;
|
m_file_logs_enabled = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
db_categories.emplace_back(c.log_category_id);
|
db_categories.emplace_back(c.log_category_id);
|
||||||
@@ -670,14 +682,33 @@ EQEmuLogSys *EQEmuLogSys::LoadLogDatabaseSettings()
|
|||||||
if (is_missing_in_database && !is_deprecated_category) {
|
if (is_missing_in_database && !is_deprecated_category) {
|
||||||
LogInfo("Automatically adding new log category [{}] ({})", Logs::LogCategoryName[i], i);
|
LogInfo("Automatically adding new log category [{}] ({})", Logs::LogCategoryName[i], i);
|
||||||
|
|
||||||
auto new_category = LogsysCategoriesRepository::NewEntity();
|
auto e = LogsysCategoriesRepository::NewEntity();
|
||||||
new_category.log_category_id = i;
|
e.log_category_id = i;
|
||||||
new_category.log_category_description = Strings::Escape(Logs::LogCategoryName[i]);
|
e.log_category_description = Strings::Escape(Logs::LogCategoryName[i]);
|
||||||
new_category.log_to_console = log_settings[i].log_to_console;
|
e.log_to_console = log_settings[i].log_to_console;
|
||||||
new_category.log_to_gmsay = log_settings[i].log_to_gmsay;
|
e.log_to_gmsay = log_settings[i].log_to_gmsay;
|
||||||
new_category.log_to_file = log_settings[i].log_to_file;
|
e.log_to_file = log_settings[i].log_to_file;
|
||||||
new_category.log_to_discord = log_settings[i].log_to_discord;
|
e.log_to_discord = log_settings[i].log_to_discord;
|
||||||
db_categories_to_add.emplace_back(new_category);
|
db_categories_to_add.emplace_back(e);
|
||||||
|
}
|
||||||
|
|
||||||
|
// look to see if the category name is different in the database
|
||||||
|
auto it = std::find_if(
|
||||||
|
categories.begin(),
|
||||||
|
categories.end(),
|
||||||
|
[i](const auto &c) { return c.log_category_id == i; }
|
||||||
|
);
|
||||||
|
if (it != categories.end()) {
|
||||||
|
if (it->log_category_description != Logs::LogCategoryName[i]) {
|
||||||
|
LogInfo(
|
||||||
|
"Updating log category [{}] ({}) to new name [{}]",
|
||||||
|
it->log_category_description,
|
||||||
|
i,
|
||||||
|
Logs::LogCategoryName[i]
|
||||||
|
);
|
||||||
|
it->log_category_description = Logs::LogCategoryName[i];
|
||||||
|
LogsysCategoriesRepository::ReplaceOne(*m_database, *it);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -687,6 +718,10 @@ EQEmuLogSys *EQEmuLogSys::LoadLogDatabaseSettings()
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (silent_load) {
|
||||||
|
SilenceConsoleLogging();
|
||||||
|
}
|
||||||
|
|
||||||
LogInfo("Loaded [{}] log categories", categories.size());
|
LogInfo("Loaded [{}] log categories", categories.size());
|
||||||
|
|
||||||
auto webhooks = DiscordWebhooksRepository::GetWhere(*m_database, fmt::format("id < {}", MAX_DISCORD_WEBHOOK_ID));
|
auto webhooks = DiscordWebhooksRepository::GetWhere(*m_database, fmt::format("id < {}", MAX_DISCORD_WEBHOOK_ID));
|
||||||
@@ -704,6 +739,10 @@ EQEmuLogSys *EQEmuLogSys::LoadLogDatabaseSettings()
|
|||||||
log_settings[Logs::Info].log_to_file = static_cast<uint8>(Logs::General);
|
log_settings[Logs::Info].log_to_file = static_cast<uint8>(Logs::General);
|
||||||
log_settings[Logs::Info].log_to_console = static_cast<uint8>(Logs::General);
|
log_settings[Logs::Info].log_to_console = static_cast<uint8>(Logs::General);
|
||||||
|
|
||||||
|
if (silent_load) {
|
||||||
|
SilenceConsoleLogging();
|
||||||
|
}
|
||||||
|
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+40
-15
@@ -34,6 +34,7 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <fmt/format.h>
|
#include <fmt/format.h>
|
||||||
|
#include <fmt/ranges.h>
|
||||||
#include "types.h"
|
#include "types.h"
|
||||||
|
|
||||||
namespace Logs {
|
namespace Logs {
|
||||||
@@ -74,7 +75,7 @@ namespace Logs {
|
|||||||
Spawns,
|
Spawns,
|
||||||
Spells,
|
Spells,
|
||||||
Status, // deprecated
|
Status, // deprecated
|
||||||
TCPConnection,
|
TCPConnection, // deprecated
|
||||||
Tasks,
|
Tasks,
|
||||||
Tradeskills,
|
Tradeskills,
|
||||||
Trading,
|
Trading,
|
||||||
@@ -142,6 +143,16 @@ namespace Logs {
|
|||||||
EqTime,
|
EqTime,
|
||||||
Corpses,
|
Corpses,
|
||||||
XTargets,
|
XTargets,
|
||||||
|
EvolveItem,
|
||||||
|
PositionUpdate,
|
||||||
|
KSM,
|
||||||
|
BotSettings,
|
||||||
|
BotSpellChecks,
|
||||||
|
BotSpellTypeChecks,
|
||||||
|
NpcHandin,
|
||||||
|
ZoneState,
|
||||||
|
NetClient,
|
||||||
|
NetTCP,
|
||||||
MaxCategoryID /* Don't Remove this */
|
MaxCategoryID /* Don't Remove this */
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -175,7 +186,7 @@ namespace Logs {
|
|||||||
"Spawns",
|
"Spawns",
|
||||||
"Spells",
|
"Spells",
|
||||||
"Status (Deprecated)",
|
"Status (Deprecated)",
|
||||||
"TCP Connection",
|
"TCP Connection (Deprecated)",
|
||||||
"Tasks",
|
"Tasks",
|
||||||
"Tradeskills",
|
"Tradeskills",
|
||||||
"Trading",
|
"Trading",
|
||||||
@@ -184,8 +195,8 @@ namespace Logs {
|
|||||||
"Web Interface (Deprecated)",
|
"Web Interface (Deprecated)",
|
||||||
"World Server (Deprecated)",
|
"World Server (Deprecated)",
|
||||||
"Zone Server (Deprecated)",
|
"Zone Server (Deprecated)",
|
||||||
"QueryErr",
|
"MySQL Error",
|
||||||
"Query",
|
"MySQL Query",
|
||||||
"Mercenaries",
|
"Mercenaries",
|
||||||
"Quest Debug",
|
"Quest Debug",
|
||||||
"Legacy Packet Logging (Deprecated)",
|
"Legacy Packet Logging (Deprecated)",
|
||||||
@@ -201,15 +212,15 @@ namespace Logs {
|
|||||||
"Traps",
|
"Traps",
|
||||||
"NPC Roam Box",
|
"NPC Roam Box",
|
||||||
"NPC Scaling",
|
"NPC Scaling",
|
||||||
"MobAppearance",
|
"Mob Appearance",
|
||||||
"Info",
|
"Info",
|
||||||
"Warning",
|
"Warning",
|
||||||
"Critical (Deprecated)",
|
"Critical (Deprecated)",
|
||||||
"Emergency (Deprecated)",
|
"Emergency (Deprecated)",
|
||||||
"Alert (Deprecated)",
|
"Alert (Deprecated)",
|
||||||
"Notice (Deprecated)",
|
"Notice (Deprecated)",
|
||||||
"AI Scan",
|
"AI Scan Close",
|
||||||
"AI Yell",
|
"AI Yell For Help",
|
||||||
"AI CastBeneficial",
|
"AI CastBeneficial",
|
||||||
"AOE Cast",
|
"AOE Cast",
|
||||||
"Entity Management",
|
"Entity Management",
|
||||||
@@ -227,7 +238,7 @@ namespace Logs {
|
|||||||
"DialogueWindow",
|
"DialogueWindow",
|
||||||
"HTTP",
|
"HTTP",
|
||||||
"Saylink",
|
"Saylink",
|
||||||
"ChecksumVer",
|
"Checksum Verification",
|
||||||
"CombatRecord",
|
"CombatRecord",
|
||||||
"Hate",
|
"Hate",
|
||||||
"Discord",
|
"Discord",
|
||||||
@@ -242,12 +253,20 @@ namespace Logs {
|
|||||||
"Zoning",
|
"Zoning",
|
||||||
"EqTime",
|
"EqTime",
|
||||||
"Corpses",
|
"Corpses",
|
||||||
"XTargets"
|
"XTargets",
|
||||||
|
"EvolveItem",
|
||||||
|
"PositionUpdate",
|
||||||
|
"KSM", // Kernel Samepage Merging
|
||||||
|
"Bot Settings",
|
||||||
|
"Bot Spell Checks",
|
||||||
|
"Bot Spell Type Checks",
|
||||||
|
"NpcHandin",
|
||||||
|
"ZoneState",
|
||||||
|
"Net Server <-> Client",
|
||||||
|
"Net TCP"
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
#include "eqemu_logsys_log_aliases.h"
|
|
||||||
|
|
||||||
class Database;
|
class Database;
|
||||||
|
|
||||||
constexpr uint16 MAX_DISCORD_WEBHOOK_ID = 300;
|
constexpr uint16 MAX_DISCORD_WEBHOOK_ID = 300;
|
||||||
@@ -263,7 +282,13 @@ public:
|
|||||||
*/
|
*/
|
||||||
void CloseFileLogs();
|
void CloseFileLogs();
|
||||||
EQEmuLogSys *LoadLogSettingsDefaults();
|
EQEmuLogSys *LoadLogSettingsDefaults();
|
||||||
EQEmuLogSys *LoadLogDatabaseSettings();
|
EQEmuLogSys *LoadLogDatabaseSettings(bool silent_load = false);
|
||||||
|
|
||||||
|
static EQEmuLogSys *Instance()
|
||||||
|
{
|
||||||
|
static EQEmuLogSys instance;
|
||||||
|
return &instance;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param directory_name
|
* @param directory_name
|
||||||
@@ -330,7 +355,7 @@ public:
|
|||||||
/**
|
/**
|
||||||
* Internally used memory reference for all log settings per category
|
* Internally used memory reference for all log settings per category
|
||||||
* These are loaded via DB and have defaults loaded in LoadLogSettingsDefaults
|
* These are loaded via DB and have defaults loaded in LoadLogSettingsDefaults
|
||||||
* Database loaded via LogSys.SetDatabase(&database)->LoadLogDatabaseSettings();
|
* Database loaded via EQEmuLogSys::Instance()->SetDatabase(&database)->LoadLogDatabaseSettings();
|
||||||
*/
|
*/
|
||||||
LogSettings log_settings[Logs::LogCategory::MaxCategoryID]{};
|
LogSettings log_settings[Logs::LogCategory::MaxCategoryID]{};
|
||||||
|
|
||||||
@@ -414,7 +439,7 @@ private:
|
|||||||
void InjectTablesIfNotExist();
|
void InjectTablesIfNotExist();
|
||||||
};
|
};
|
||||||
|
|
||||||
extern EQEmuLogSys LogSys;
|
#include "eqemu_logsys_log_aliases.h"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
template<typename... Args>
|
template<typename... Args>
|
||||||
@@ -436,7 +461,7 @@ void OutF(
|
|||||||
|
|
||||||
#define OutF(ls, debug_level, log_category, file, func, line, formatStr, ...) \
|
#define OutF(ls, debug_level, log_category, file, func, line, formatStr, ...) \
|
||||||
do { \
|
do { \
|
||||||
ls.Out(debug_level, log_category, file, func, line, fmt::format(formatStr, ##__VA_ARGS__).c_str()); \
|
ls->Out(debug_level, log_category, file, func, line, fmt::format(formatStr, ##__VA_ARGS__).c_str()); \
|
||||||
} while(0)
|
} while(0)
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
+426
-344
File diff suppressed because it is too large
Load Diff
@@ -3,6 +3,7 @@
|
|||||||
#include "../json/json_archive_single_line.h"
|
#include "../json/json_archive_single_line.h"
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <fmt/format.h>
|
#include <fmt/format.h>
|
||||||
|
#include <fmt/ranges.h>
|
||||||
#include <cereal/archives/json.hpp>
|
#include <cereal/archives/json.hpp>
|
||||||
#include <cereal/types/vector.hpp>
|
#include <cereal/types/vector.hpp>
|
||||||
|
|
||||||
@@ -714,6 +715,18 @@ std::string PlayerEventDiscordFormatter::FormatNPCHandinEvent(
|
|||||||
h.charges > 1 ? fmt::format(" Charges: {}", h.charges) : "",
|
h.charges > 1 ? fmt::format(" Charges: {}", h.charges) : "",
|
||||||
h.attuned ? " (Attuned)" : ""
|
h.attuned ? " (Attuned)" : ""
|
||||||
);
|
);
|
||||||
|
|
||||||
|
for (int i = 0; i < h.augment_ids.size(); i++) {
|
||||||
|
if (!h.augment_names[i].empty()) {
|
||||||
|
const uint8 slot_id = (i + 1);
|
||||||
|
handin_items_info += fmt::format(
|
||||||
|
"Augment {}: {} ({})\n",
|
||||||
|
slot_id,
|
||||||
|
h.augment_names[i],
|
||||||
|
h.augment_ids[i]
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -727,6 +740,18 @@ std::string PlayerEventDiscordFormatter::FormatNPCHandinEvent(
|
|||||||
r.charges > 1 ? fmt::format(" Charges: {}", r.charges) : "",
|
r.charges > 1 ? fmt::format(" Charges: {}", r.charges) : "",
|
||||||
r.attuned ? " (Attuned)" : ""
|
r.attuned ? " (Attuned)" : ""
|
||||||
);
|
);
|
||||||
|
|
||||||
|
for (int i = 0; i < r.augment_ids.size(); i++) {
|
||||||
|
if (!r.augment_names[i].empty()) {
|
||||||
|
const uint8 slot_id = (i + 1);
|
||||||
|
return_items_info += fmt::format(
|
||||||
|
"Augment {}: {} ({})\n",
|
||||||
|
slot_id,
|
||||||
|
r.augment_names[i],
|
||||||
|
r.augment_ids[i]
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -789,50 +814,36 @@ std::string PlayerEventDiscordFormatter::FormatNPCHandinEvent(
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::string npc_info = fmt::format(
|
||||||
|
"{} ({})\n",
|
||||||
|
e.npc_name,
|
||||||
|
e.npc_id
|
||||||
|
);
|
||||||
|
|
||||||
|
npc_info += fmt::format(
|
||||||
|
"Is Quest Handin: {}",
|
||||||
|
e.is_quest_handin ? "Yes" : "No"
|
||||||
|
);
|
||||||
|
|
||||||
std::vector<DiscordField> f = {};
|
std::vector<DiscordField> f = {};
|
||||||
|
|
||||||
|
|
||||||
|
BuildDiscordField(&f, "NPC", npc_info);
|
||||||
|
|
||||||
if (!handin_items_info.empty()) {
|
if (!handin_items_info.empty()) {
|
||||||
BuildDiscordField(
|
BuildDiscordField(&f, "Handin Items", handin_items_info);
|
||||||
&f,
|
|
||||||
"Handin Items",
|
|
||||||
fmt::format(
|
|
||||||
"{}",
|
|
||||||
handin_items_info
|
|
||||||
)
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!handin_money_info.empty()) {
|
if (!handin_money_info.empty()) {
|
||||||
BuildDiscordField(
|
BuildDiscordField(&f, "Handin Money", handin_money_info);
|
||||||
&f,
|
|
||||||
"Handin Money",
|
|
||||||
fmt::format(
|
|
||||||
"{}",
|
|
||||||
handin_money_info
|
|
||||||
)
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!return_items_info.empty()) {
|
if (!return_items_info.empty()) {
|
||||||
BuildDiscordField(
|
BuildDiscordField(&f, "Return Items", return_items_info);
|
||||||
&f,
|
|
||||||
"Return Items",
|
|
||||||
fmt::format(
|
|
||||||
"{}",
|
|
||||||
return_items_info
|
|
||||||
)
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!return_money_info.empty()) {
|
if (!return_money_info.empty()) {
|
||||||
BuildDiscordField(
|
BuildDiscordField(&f, "Return Money", return_money_info);
|
||||||
&f,
|
|
||||||
"Return Money",
|
|
||||||
fmt::format(
|
|
||||||
"{}",
|
|
||||||
return_money_info
|
|
||||||
)
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<DiscordEmbed> embeds = {};
|
std::vector<DiscordEmbed> embeds = {};
|
||||||
@@ -1071,51 +1082,51 @@ std::string PlayerEventDiscordFormatter::FormatTradeEvent(
|
|||||||
if (!e.character_1_give_items.empty()) {
|
if (!e.character_1_give_items.empty()) {
|
||||||
for (const auto &i: e.character_1_give_items) {
|
for (const auto &i: e.character_1_give_items) {
|
||||||
std::string augment_info;
|
std::string augment_info;
|
||||||
if (i.aug_1_item_id > 0) {
|
if (i.augment_1_id > 0) {
|
||||||
augment_info += fmt::format(
|
augment_info += fmt::format(
|
||||||
"Augment 1: {} ({})",
|
"Augment 1: {} ({})",
|
||||||
i.aug_1_item_name,
|
i.augment_1_name,
|
||||||
i.aug_1_item_id
|
i.augment_1_id
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (i.aug_2_item_id > 0) {
|
if (i.augment_2_id > 0) {
|
||||||
augment_info += fmt::format(
|
augment_info += fmt::format(
|
||||||
"Augment 2: {} ({})",
|
"Augment 2: {} ({})",
|
||||||
i.aug_2_item_name,
|
i.augment_2_name,
|
||||||
i.aug_2_item_id
|
i.augment_2_id
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (i.aug_3_item_id > 0) {
|
if (i.augment_3_id > 0) {
|
||||||
augment_info += fmt::format(
|
augment_info += fmt::format(
|
||||||
"Augment 3: {} ({})",
|
"Augment 3: {} ({})",
|
||||||
i.aug_3_item_name,
|
i.augment_3_name,
|
||||||
i.aug_3_item_id
|
i.augment_3_id
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (i.aug_4_item_id > 0) {
|
if (i.augment_4_id > 0) {
|
||||||
augment_info += fmt::format(
|
augment_info += fmt::format(
|
||||||
"Augment 4: {} ({})\n",
|
"Augment 4: {} ({})\n",
|
||||||
i.aug_4_item_name,
|
i.augment_4_name,
|
||||||
i.aug_4_item_id
|
i.augment_4_id
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (i.aug_5_item_id > 0) {
|
if (i.augment_5_id > 0) {
|
||||||
augment_info += fmt::format(
|
augment_info += fmt::format(
|
||||||
"Augment 5: {} ({})\n",
|
"Augment 5: {} ({})\n",
|
||||||
i.aug_5_item_name,
|
i.augment_5_name,
|
||||||
i.aug_5_item_id
|
i.augment_5_id
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (i.aug_6_item_id > 0) {
|
if (i.augment_6_id > 0) {
|
||||||
augment_info += fmt::format(
|
augment_info += fmt::format(
|
||||||
"Augment 6: {} ({})",
|
"Augment 6: {} ({})",
|
||||||
i.aug_6_item_name,
|
i.augment_6_name,
|
||||||
i.aug_6_item_id
|
i.augment_6_id
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1136,51 +1147,51 @@ std::string PlayerEventDiscordFormatter::FormatTradeEvent(
|
|||||||
if (!e.character_2_give_items.empty()) {
|
if (!e.character_2_give_items.empty()) {
|
||||||
for (const auto &i: e.character_2_give_items) {
|
for (const auto &i: e.character_2_give_items) {
|
||||||
std::string augment_info;
|
std::string augment_info;
|
||||||
if (i.aug_1_item_id > 0) {
|
if (i.augment_1_id > 0) {
|
||||||
augment_info += fmt::format(
|
augment_info += fmt::format(
|
||||||
"Augment 1: {} ({})",
|
"Augment 1: {} ({})",
|
||||||
i.aug_1_item_name,
|
i.augment_1_name,
|
||||||
i.aug_1_item_id
|
i.augment_1_id
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (i.aug_2_item_id > 0) {
|
if (i.augment_2_id > 0) {
|
||||||
augment_info += fmt::format(
|
augment_info += fmt::format(
|
||||||
"Augment 2: {} ({})",
|
"Augment 2: {} ({})",
|
||||||
i.aug_2_item_name,
|
i.augment_2_name,
|
||||||
i.aug_2_item_id
|
i.augment_2_id
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (i.aug_3_item_id > 0) {
|
if (i.augment_3_id > 0) {
|
||||||
augment_info += fmt::format(
|
augment_info += fmt::format(
|
||||||
"Augment 3: {} ({})",
|
"Augment 3: {} ({})",
|
||||||
i.aug_3_item_name,
|
i.augment_3_name,
|
||||||
i.aug_3_item_id
|
i.augment_3_id
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (i.aug_4_item_id > 0) {
|
if (i.augment_4_id > 0) {
|
||||||
augment_info += fmt::format(
|
augment_info += fmt::format(
|
||||||
"Augment 4: {} ({})\n",
|
"Augment 4: {} ({})\n",
|
||||||
i.aug_4_item_name,
|
i.augment_4_name,
|
||||||
i.aug_4_item_id
|
i.augment_4_id
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (i.aug_5_item_id > 0) {
|
if (i.augment_5_id > 0) {
|
||||||
augment_info += fmt::format(
|
augment_info += fmt::format(
|
||||||
"Augment 5: {} ({})\n",
|
"Augment 5: {} ({})\n",
|
||||||
i.aug_5_item_name,
|
i.augment_5_name,
|
||||||
i.aug_5_item_id
|
i.augment_5_id
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (i.aug_6_item_id > 0) {
|
if (i.augment_6_id > 0) {
|
||||||
augment_info += fmt::format(
|
augment_info += fmt::format(
|
||||||
"Augment 6: {} ({})",
|
"Augment 6: {} ({})",
|
||||||
i.aug_6_item_name,
|
i.augment_6_name,
|
||||||
i.aug_6_item_id
|
i.augment_6_id
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,8 +1,14 @@
|
|||||||
#include <cereal/archives/json.hpp>
|
|
||||||
#include "player_event_logs.h"
|
#include "player_event_logs.h"
|
||||||
#include "player_event_discord_formatter.h"
|
#include <cereal/archives/json.hpp>
|
||||||
|
|
||||||
#include "../platform.h"
|
#include "../platform.h"
|
||||||
#include "../rulesys.h"
|
#include "../rulesys.h"
|
||||||
|
#include "player_event_discord_formatter.h"
|
||||||
|
#include "../repositories/player_event_loot_items_repository.h"
|
||||||
|
#include "../repositories/player_event_merchant_sell_repository.h"
|
||||||
|
#include "../repositories/player_event_merchant_purchase_repository.h"
|
||||||
|
#include "../repositories/player_event_npc_handin_repository.h"
|
||||||
|
#include "../repositories/player_event_npc_handin_entries_repository.h"
|
||||||
|
|
||||||
const uint32 PROCESS_RETENTION_TRUNCATION_TIMER_INTERVAL = 60 * 60 * 1000; // 1 hour
|
const uint32 PROCESS_RETENTION_TRUNCATION_TIMER_INTERVAL = 60 * 60 * 1000; // 1 hour
|
||||||
|
|
||||||
@@ -11,6 +17,7 @@ void PlayerEventLogs::Init()
|
|||||||
{
|
{
|
||||||
m_process_batch_events_timer.SetTimer(RuleI(Logging, BatchPlayerEventProcessIntervalSeconds) * 1000);
|
m_process_batch_events_timer.SetTimer(RuleI(Logging, BatchPlayerEventProcessIntervalSeconds) * 1000);
|
||||||
m_process_retention_truncation_timer.SetTimer(PROCESS_RETENTION_TRUNCATION_TIMER_INTERVAL);
|
m_process_retention_truncation_timer.SetTimer(PROCESS_RETENTION_TRUNCATION_TIMER_INTERVAL);
|
||||||
|
m_database_ping_timer.SetTimer(10 * 1000); // 10 seconds
|
||||||
|
|
||||||
ValidateDatabaseConnection();
|
ValidateDatabaseConnection();
|
||||||
|
|
||||||
@@ -21,6 +28,7 @@ void PlayerEventLogs::Init()
|
|||||||
m_settings[i].event_enabled = 1;
|
m_settings[i].event_enabled = 1;
|
||||||
m_settings[i].retention_days = 0;
|
m_settings[i].retention_days = 0;
|
||||||
m_settings[i].discord_webhook_id = 0;
|
m_settings[i].discord_webhook_id = 0;
|
||||||
|
m_settings[i].etl_enabled = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
SetSettingsDefaults();
|
SetSettingsDefaults();
|
||||||
@@ -65,6 +73,7 @@ void PlayerEventLogs::Init()
|
|||||||
c.event_name = PlayerEvent::EventName[i];
|
c.event_name = PlayerEvent::EventName[i];
|
||||||
c.event_enabled = m_settings[i].event_enabled;
|
c.event_enabled = m_settings[i].event_enabled;
|
||||||
c.retention_days = m_settings[i].retention_days;
|
c.retention_days = m_settings[i].retention_days;
|
||||||
|
c.etl_enabled = false;
|
||||||
settings_to_insert.emplace_back(c);
|
settings_to_insert.emplace_back(c);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -78,6 +87,7 @@ void PlayerEventLogs::Init()
|
|||||||
|
|
||||||
// on initial boot process truncation
|
// on initial boot process truncation
|
||||||
if (processing_in_world || processing_in_qs) {
|
if (processing_in_world || processing_in_qs) {
|
||||||
|
LoadEtlIds();
|
||||||
ProcessRetentionTruncation();
|
ProcessRetentionTruncation();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -121,23 +131,328 @@ void PlayerEventLogs::ProcessBatchQueue()
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static std::map<uint32, uint32> counter{};
|
||||||
|
counter.clear();
|
||||||
|
for (auto const &e: m_record_batch_queue) {
|
||||||
|
counter[e.event_type_id]++;
|
||||||
|
}
|
||||||
|
|
||||||
BenchTimer benchmark;
|
BenchTimer benchmark;
|
||||||
|
|
||||||
|
EtlQueues etl_queues{};
|
||||||
|
for (const auto &[type, count]: counter) {
|
||||||
|
if (count > 0) {
|
||||||
|
switch (type) {
|
||||||
|
case PlayerEvent::TRADE:
|
||||||
|
etl_queues.trade.reserve(count);
|
||||||
|
break;
|
||||||
|
case PlayerEvent::SPEECH:
|
||||||
|
etl_queues.speech.reserve(count);
|
||||||
|
break;
|
||||||
|
case PlayerEvent::LOOT_ITEM:
|
||||||
|
etl_queues.loot_items.reserve(count);
|
||||||
|
break;
|
||||||
|
case PlayerEvent::KILLED_NPC:
|
||||||
|
etl_queues.killed_npc.reserve(count);
|
||||||
|
break;
|
||||||
|
case PlayerEvent::NPC_HANDIN:
|
||||||
|
etl_queues.npc_handin.reserve(count);
|
||||||
|
break;
|
||||||
|
case PlayerEvent::AA_PURCHASE:
|
||||||
|
etl_queues.aa_purchase.reserve(count);
|
||||||
|
break;
|
||||||
|
case PlayerEvent::MERCHANT_SELL:
|
||||||
|
etl_queues.merchant_sell.reserve(count);
|
||||||
|
break;
|
||||||
|
case PlayerEvent::KILLED_RAID_NPC:
|
||||||
|
etl_queues.killed_raid_npc.reserve(count);
|
||||||
|
break;
|
||||||
|
case PlayerEvent::KILLED_NAMED_NPC:
|
||||||
|
etl_queues.killed_named_npc.reserve(count);
|
||||||
|
break;
|
||||||
|
case PlayerEvent::MERCHANT_PURCHASE:
|
||||||
|
etl_queues.merchant_purchase.reserve(count);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Helper to deserialize event data
|
||||||
|
auto Deserialize = [](const std::string &data, auto &out) {
|
||||||
|
if (!Strings::IsValidJson(data)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// cpp exceptions are terrible, don't ever use them
|
||||||
|
try {
|
||||||
|
std::stringstream ss(data);
|
||||||
|
cereal::JSONInputArchive ar(ss);
|
||||||
|
out.serialize(ar);
|
||||||
|
}
|
||||||
|
catch (const std::exception &e) {}
|
||||||
|
};
|
||||||
|
|
||||||
|
// Helper to assign ETL table ID
|
||||||
|
|
||||||
|
auto AssignEtlId = [&](
|
||||||
|
PlayerEventLogsRepository::PlayerEventLogs& r,
|
||||||
|
PlayerEvent::EventType type
|
||||||
|
)
|
||||||
|
{
|
||||||
|
if (m_etl_settings.contains(type)) {
|
||||||
|
r.etl_table_id = m_etl_settings.at(type).next_id++;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
// Define event processors
|
||||||
|
std::unordered_map<PlayerEvent::EventType, std::function<void(PlayerEventLogsRepository::PlayerEventLogs &)>> event_processors = {
|
||||||
|
{
|
||||||
|
PlayerEvent::EventType::LOOT_ITEM, [&](PlayerEventLogsRepository::PlayerEventLogs &r) {
|
||||||
|
PlayerEvent::LootItemEvent in{};
|
||||||
|
PlayerEventLootItemsRepository::PlayerEventLootItems out{};
|
||||||
|
Deserialize(r.event_data, in);
|
||||||
|
|
||||||
|
out.charges = in.charges;
|
||||||
|
out.corpse_name = in.corpse_name;
|
||||||
|
out.item_id = in.item_id;
|
||||||
|
out.item_name = in.item_name;
|
||||||
|
out.augment_1_id = in.augment_1_id;
|
||||||
|
out.augment_2_id = in.augment_2_id;
|
||||||
|
out.augment_3_id = in.augment_3_id;
|
||||||
|
out.augment_4_id = in.augment_4_id;
|
||||||
|
out.augment_5_id = in.augment_5_id;
|
||||||
|
out.augment_6_id = in.augment_6_id;
|
||||||
|
out.npc_id = in.npc_id;
|
||||||
|
out.created_at = r.created_at;
|
||||||
|
|
||||||
|
AssignEtlId(r, PlayerEvent::EventType::LOOT_ITEM);
|
||||||
|
etl_queues.loot_items.push_back(out);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
PlayerEvent::EventType::MERCHANT_SELL, [&](PlayerEventLogsRepository::PlayerEventLogs &r) {
|
||||||
|
PlayerEvent::MerchantSellEvent in{};
|
||||||
|
PlayerEventMerchantSellRepository::PlayerEventMerchantSell out{};
|
||||||
|
Deserialize(r.event_data, in);
|
||||||
|
|
||||||
|
out.npc_id = in.npc_id;
|
||||||
|
out.merchant_name = in.merchant_name;
|
||||||
|
out.merchant_type = in.merchant_type;
|
||||||
|
out.item_id = in.item_id;
|
||||||
|
out.item_name = in.item_name;
|
||||||
|
out.charges = in.charges;
|
||||||
|
out.cost = in.cost;
|
||||||
|
out.alternate_currency_id = in.alternate_currency_id;
|
||||||
|
out.player_money_balance = in.player_money_balance;
|
||||||
|
out.player_currency_balance = in.player_currency_balance;
|
||||||
|
out.created_at = r.created_at;
|
||||||
|
|
||||||
|
AssignEtlId(r, PlayerEvent::EventType::MERCHANT_SELL);
|
||||||
|
etl_queues.merchant_sell.push_back(out);
|
||||||
|
}},
|
||||||
|
{
|
||||||
|
PlayerEvent::EventType::MERCHANT_PURCHASE, [&](PlayerEventLogsRepository::PlayerEventLogs &r) {
|
||||||
|
PlayerEvent::MerchantPurchaseEvent in{};
|
||||||
|
PlayerEventMerchantPurchaseRepository::PlayerEventMerchantPurchase out{};
|
||||||
|
Deserialize(r.event_data, in);
|
||||||
|
|
||||||
|
out.npc_id = in.npc_id;
|
||||||
|
out.merchant_name = in.merchant_name;
|
||||||
|
out.merchant_type = in.merchant_type;
|
||||||
|
out.item_id = in.item_id;
|
||||||
|
out.item_name = in.item_name;
|
||||||
|
out.charges = in.charges;
|
||||||
|
out.cost = in.cost;
|
||||||
|
out.alternate_currency_id = in.alternate_currency_id;
|
||||||
|
out.player_money_balance = in.player_money_balance;
|
||||||
|
out.player_currency_balance = in.player_currency_balance;
|
||||||
|
out.created_at = r.created_at;
|
||||||
|
|
||||||
|
AssignEtlId(r, PlayerEvent::EventType::MERCHANT_PURCHASE);
|
||||||
|
etl_queues.merchant_purchase.push_back(out);
|
||||||
|
}},
|
||||||
|
{
|
||||||
|
PlayerEvent::EventType::NPC_HANDIN, [&](PlayerEventLogsRepository::PlayerEventLogs &r) {
|
||||||
|
PlayerEvent::HandinEvent in{};
|
||||||
|
PlayerEventNpcHandinRepository::PlayerEventNpcHandin out{};
|
||||||
|
Deserialize(r.event_data, in);
|
||||||
|
|
||||||
|
out.npc_id = in.npc_id;
|
||||||
|
out.npc_name = in.npc_name;
|
||||||
|
out.handin_copper = in.handin_money.copper;
|
||||||
|
out.handin_silver = in.handin_money.silver;
|
||||||
|
out.handin_gold = in.handin_money.gold;
|
||||||
|
out.handin_platinum = in.handin_money.platinum;
|
||||||
|
out.return_copper = in.return_money.copper;
|
||||||
|
out.return_silver = in.return_money.silver;
|
||||||
|
out.return_gold = in.return_money.gold;
|
||||||
|
out.return_platinum = in.return_money.platinum;
|
||||||
|
out.is_quest_handin = in.is_quest_handin;
|
||||||
|
out.created_at = r.created_at;
|
||||||
|
|
||||||
|
AssignEtlId(r, PlayerEvent::EventType::NPC_HANDIN);
|
||||||
|
etl_queues.npc_handin.push_back(out);
|
||||||
|
|
||||||
|
for (const auto &i: in.handin_items) {
|
||||||
|
PlayerEventNpcHandinEntriesRepository::PlayerEventNpcHandinEntries entry{};
|
||||||
|
entry.player_event_npc_handin_id = r.etl_table_id;
|
||||||
|
entry.item_id = i.item_id;
|
||||||
|
entry.charges = i.charges;
|
||||||
|
entry.type = 1;
|
||||||
|
etl_queues.npc_handin_entries.push_back(entry);
|
||||||
|
}
|
||||||
|
for (const auto &i: in.return_items) {
|
||||||
|
PlayerEventNpcHandinEntriesRepository::PlayerEventNpcHandinEntries entry{};
|
||||||
|
entry.player_event_npc_handin_id = r.etl_table_id;
|
||||||
|
entry.item_id = i.item_id;
|
||||||
|
entry.charges = i.charges;
|
||||||
|
entry.type = 2;
|
||||||
|
etl_queues.npc_handin_entries.push_back(entry);
|
||||||
|
}
|
||||||
|
}},
|
||||||
|
{
|
||||||
|
PlayerEvent::EventType::TRADE, [&](PlayerEventLogsRepository::PlayerEventLogs &r) {
|
||||||
|
PlayerEvent::TradeEvent in{};
|
||||||
|
PlayerEventTradeRepository::PlayerEventTrade out{};
|
||||||
|
Deserialize(r.event_data, in);
|
||||||
|
|
||||||
|
out.char1_id = in.character_1_id;
|
||||||
|
out.char2_id = in.character_2_id;
|
||||||
|
out.char1_copper = in.character_1_give_money.copper;
|
||||||
|
out.char1_silver = in.character_1_give_money.silver;
|
||||||
|
out.char1_gold = in.character_1_give_money.gold;
|
||||||
|
out.char1_platinum = in.character_1_give_money.platinum;
|
||||||
|
out.char2_copper = in.character_2_give_money.copper;
|
||||||
|
out.char2_silver = in.character_2_give_money.silver;
|
||||||
|
out.char2_gold = in.character_2_give_money.gold;
|
||||||
|
out.char2_platinum = in.character_2_give_money.platinum;
|
||||||
|
out.created_at = r.created_at;
|
||||||
|
|
||||||
|
AssignEtlId(r, PlayerEvent::EventType::TRADE);
|
||||||
|
etl_queues.trade.push_back(out);
|
||||||
|
|
||||||
|
for (const auto &i: in.character_1_give_items) {
|
||||||
|
PlayerEventTradeEntriesRepository::PlayerEventTradeEntries entry{};
|
||||||
|
entry.player_event_trade_id = r.etl_table_id;
|
||||||
|
entry.char_id = in.character_1_id;
|
||||||
|
entry.item_id = i.item_id;
|
||||||
|
entry.charges = i.charges;
|
||||||
|
entry.slot = i.slot;
|
||||||
|
etl_queues.trade_entries.push_back(entry);
|
||||||
|
}
|
||||||
|
for (const auto &i: in.character_2_give_items) {
|
||||||
|
PlayerEventTradeEntriesRepository::PlayerEventTradeEntries entry{};
|
||||||
|
entry.player_event_trade_id = r.etl_table_id;
|
||||||
|
entry.char_id = in.character_2_id;
|
||||||
|
entry.item_id = i.item_id;
|
||||||
|
entry.charges = i.charges;
|
||||||
|
entry.slot = i.slot;
|
||||||
|
etl_queues.trade_entries.push_back(entry);
|
||||||
|
}
|
||||||
|
}},
|
||||||
|
{
|
||||||
|
PlayerEvent::EventType::SPEECH, [&](PlayerEventLogsRepository::PlayerEventLogs &r) {
|
||||||
|
PlayerEvent::PlayerSpeech in{};
|
||||||
|
PlayerEventSpeechRepository::PlayerEventSpeech out{};
|
||||||
|
Deserialize(r.event_data, in);
|
||||||
|
|
||||||
|
out.from_char_id = in.from;
|
||||||
|
out.to_char_id = in.to;
|
||||||
|
out.type = in.type;
|
||||||
|
out.min_status = in.min_status;
|
||||||
|
out.message = in.message;
|
||||||
|
out.guild_id = in.guild_id;
|
||||||
|
out.created_at = r.created_at;
|
||||||
|
|
||||||
|
AssignEtlId(r, PlayerEvent::EventType::SPEECH);
|
||||||
|
etl_queues.speech.push_back(out);
|
||||||
|
}},
|
||||||
|
{
|
||||||
|
PlayerEvent::EventType::KILLED_NPC, [&](PlayerEventLogsRepository::PlayerEventLogs &r) {
|
||||||
|
PlayerEvent::KilledNPCEvent in{};
|
||||||
|
PlayerEventKilledNpcRepository::PlayerEventKilledNpc out{};
|
||||||
|
Deserialize(r.event_data, in);
|
||||||
|
|
||||||
|
out.npc_id = in.npc_id;
|
||||||
|
out.npc_name = in.npc_name;
|
||||||
|
out.combat_time_seconds = in.combat_time_seconds;
|
||||||
|
out.total_damage_per_second_taken = in.total_damage_per_second_taken;
|
||||||
|
out.total_heal_per_second_taken = in.total_heal_per_second_taken;
|
||||||
|
out.created_at = r.created_at;
|
||||||
|
|
||||||
|
AssignEtlId(r, PlayerEvent::EventType::KILLED_NPC);
|
||||||
|
etl_queues.killed_npc.push_back(out);
|
||||||
|
}},
|
||||||
|
{
|
||||||
|
PlayerEvent::EventType::AA_PURCHASE, [&](PlayerEventLogsRepository::PlayerEventLogs &r) {
|
||||||
|
PlayerEvent::AAPurchasedEvent in{};
|
||||||
|
PlayerEventAaPurchaseRepository::PlayerEventAaPurchase out{};
|
||||||
|
Deserialize(r.event_data, in);
|
||||||
|
|
||||||
|
out.aa_ability_id = in.aa_id;
|
||||||
|
out.cost = in.aa_cost;
|
||||||
|
out.previous_id = in.aa_previous_id;
|
||||||
|
out.next_id = in.aa_next_id;
|
||||||
|
out.created_at = r.created_at;
|
||||||
|
|
||||||
|
AssignEtlId(r, PlayerEvent::EventType::AA_PURCHASE);
|
||||||
|
etl_queues.aa_purchase.push_back(out);
|
||||||
|
}},
|
||||||
|
};
|
||||||
|
|
||||||
|
// Process the batch queue
|
||||||
|
for (auto &r: m_record_batch_queue) {
|
||||||
|
if (m_settings[r.event_type_id].etl_enabled) {
|
||||||
|
auto it = event_processors.find(static_cast<PlayerEvent::EventType>(r.event_type_id));
|
||||||
|
if (it != event_processors.end()) {
|
||||||
|
it->second(r); // Call the appropriate lambda
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
LogPlayerEventsDetail("Non-Implemented ETL routing [{}]", r.event_type_id);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Helper to flush and clear queues
|
||||||
|
auto flush_queue = [&](auto insert_many, auto &queue) {
|
||||||
|
if (!queue.empty()) {
|
||||||
|
insert_many(*m_database, queue);
|
||||||
|
queue.clear();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
// flush many
|
// flush many
|
||||||
PlayerEventLogsRepository::InsertMany(*m_database, m_record_batch_queue);
|
PlayerEventLogsRepository::InsertMany(*m_database, m_record_batch_queue);
|
||||||
LogPlayerEventsDetail(
|
|
||||||
|
// flush etl queues
|
||||||
|
flush_queue(PlayerEventLootItemsRepository::InsertMany, etl_queues.loot_items);
|
||||||
|
flush_queue(PlayerEventMerchantSellRepository::InsertMany, etl_queues.merchant_sell);
|
||||||
|
flush_queue(PlayerEventMerchantPurchaseRepository::InsertMany, etl_queues.merchant_purchase);
|
||||||
|
flush_queue(PlayerEventNpcHandinRepository::InsertMany, etl_queues.npc_handin);
|
||||||
|
flush_queue(PlayerEventNpcHandinEntriesRepository::InsertMany, etl_queues.npc_handin_entries);
|
||||||
|
flush_queue(PlayerEventTradeRepository::InsertMany, etl_queues.trade);
|
||||||
|
flush_queue(PlayerEventTradeEntriesRepository::InsertMany, etl_queues.trade_entries);
|
||||||
|
flush_queue(PlayerEventSpeechRepository::InsertMany, etl_queues.speech);
|
||||||
|
flush_queue(PlayerEventKilledNpcRepository::InsertMany, etl_queues.killed_npc);
|
||||||
|
flush_queue(PlayerEventKilledNamedNpcRepository::InsertMany, etl_queues.killed_named_npc);
|
||||||
|
flush_queue(PlayerEventKilledRaidNpcRepository::InsertMany, etl_queues.killed_raid_npc);
|
||||||
|
flush_queue(PlayerEventAaPurchaseRepository::InsertMany, etl_queues.aa_purchase);
|
||||||
|
|
||||||
|
LogPlayerEvents(
|
||||||
"Processing batch player event log queue of [{}] took [{}]",
|
"Processing batch player event log queue of [{}] took [{}]",
|
||||||
m_record_batch_queue.size(),
|
m_record_batch_queue.size(),
|
||||||
benchmark.elapsed()
|
benchmark.elapsed()
|
||||||
);
|
);
|
||||||
|
|
||||||
// empty
|
// empty
|
||||||
m_record_batch_queue = {};
|
m_record_batch_queue.clear();
|
||||||
m_batch_queue_lock.unlock();
|
m_batch_queue_lock.unlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
// adds a player event to the queue
|
// adds a player event to the queue
|
||||||
void PlayerEventLogs::AddToQueue(const PlayerEventLogsRepository::PlayerEventLogs &log)
|
void PlayerEventLogs::AddToQueue(PlayerEventLogsRepository::PlayerEventLogs &log)
|
||||||
{
|
{
|
||||||
m_batch_queue_lock.lock();
|
m_batch_queue_lock.lock();
|
||||||
m_record_batch_queue.emplace_back(log);
|
m_record_batch_queue.emplace_back(log);
|
||||||
@@ -194,7 +509,7 @@ bool PlayerEventLogs::IsEventDiscordEnabled(int32_t event_type_id)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ensure there is a matching webhook to begin with
|
// ensure there is a matching webhook to begin with
|
||||||
if (!LogSys.GetDiscordWebhooks()[m_settings[event_type_id].discord_webhook_id].webhook_url.empty()) {
|
if (!EQEmuLogSys::Instance()->GetDiscordWebhooks()[m_settings[event_type_id].discord_webhook_id].webhook_url.empty()) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -214,13 +529,27 @@ std::string PlayerEventLogs::GetDiscordWebhookUrlFromEventType(int32_t event_typ
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ensure there is a matching webhook to begin with
|
// ensure there is a matching webhook to begin with
|
||||||
if (!LogSys.GetDiscordWebhooks()[m_settings[event_type_id].discord_webhook_id].webhook_url.empty()) {
|
if (!EQEmuLogSys::Instance()->GetDiscordWebhooks()[m_settings[event_type_id].discord_webhook_id].webhook_url.empty()) {
|
||||||
return LogSys.GetDiscordWebhooks()[m_settings[event_type_id].discord_webhook_id].webhook_url;
|
return EQEmuLogSys::Instance()->GetDiscordWebhooks()[m_settings[event_type_id].discord_webhook_id].webhook_url;
|
||||||
}
|
}
|
||||||
|
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void PlayerEventLogs::LoadPlayerEventSettingsFromQS(
|
||||||
|
const std::vector<PlayerEventLogSettingsRepository::PlayerEventLogSettings> &settings
|
||||||
|
)
|
||||||
|
{
|
||||||
|
for (const auto &e : settings) {
|
||||||
|
if (e.id >= PlayerEvent::MAX || e.id < 0) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
m_settings[e.id] = e;
|
||||||
|
}
|
||||||
|
|
||||||
|
LogInfo("Applied [{}] player event log settings from QS", settings.size());
|
||||||
|
}
|
||||||
|
|
||||||
// GM_COMMAND | [x] Implemented Formatter
|
// GM_COMMAND | [x] Implemented Formatter
|
||||||
// ZONING | [x] Implemented Formatter
|
// ZONING | [x] Implemented Formatter
|
||||||
// AA_GAIN | [x] Implemented Formatter
|
// AA_GAIN | [x] Implemented Formatter
|
||||||
@@ -588,7 +917,7 @@ std::string PlayerEventLogs::GetDiscordPayloadFromEvent(const PlayerEvent::Playe
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default: {
|
default: {
|
||||||
LogInfo(
|
LogPlayerEventsDetail(
|
||||||
"Player event [{}] ({}) Discord formatter not implemented",
|
"Player event [{}] ({}) Discord formatter not implemented",
|
||||||
e.player_event_log.event_type_name,
|
e.player_event_log.event_type_name,
|
||||||
e.player_event_log.event_type_id
|
e.player_event_log.event_type_id
|
||||||
@@ -602,7 +931,12 @@ std::string PlayerEventLogs::GetDiscordPayloadFromEvent(const PlayerEvent::Playe
|
|||||||
// general process function, used in world or QS depending on rule Logging:PlayerEventsQSProcess
|
// general process function, used in world or QS depending on rule Logging:PlayerEventsQSProcess
|
||||||
void PlayerEventLogs::Process()
|
void PlayerEventLogs::Process()
|
||||||
{
|
{
|
||||||
if (m_process_batch_events_timer.Check() || m_record_batch_queue.size() >= RuleI(Logging, BatchPlayerEventProcessChunkSize)) {
|
if (m_database_ping_timer.Check()) {
|
||||||
|
m_database->ping();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (m_process_batch_events_timer.Check() ||
|
||||||
|
m_record_batch_queue.size() >= RuleI(Logging, BatchPlayerEventProcessChunkSize)) {
|
||||||
ProcessBatchQueue();
|
ProcessBatchQueue();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -613,30 +947,116 @@ void PlayerEventLogs::Process()
|
|||||||
|
|
||||||
void PlayerEventLogs::ProcessRetentionTruncation()
|
void PlayerEventLogs::ProcessRetentionTruncation()
|
||||||
{
|
{
|
||||||
LogPlayerEvents("Running truncation");
|
LogPlayerEventsDetail("Running truncation");
|
||||||
|
|
||||||
|
// Map of repository-specific deletion functions
|
||||||
|
std::unordered_map<PlayerEvent::EventType, std::function<uint32(const std::string &)>> repository_deleters = {
|
||||||
|
{
|
||||||
|
PlayerEvent::LOOT_ITEM, [&](const std::string &condition) {
|
||||||
|
return PlayerEventLootItemsRepository::DeleteWhere(*m_database, condition);
|
||||||
|
}},
|
||||||
|
{
|
||||||
|
PlayerEvent::MERCHANT_SELL, [&](const std::string &condition) {
|
||||||
|
return PlayerEventMerchantSellRepository::DeleteWhere(*m_database, condition);
|
||||||
|
}},
|
||||||
|
{
|
||||||
|
PlayerEvent::MERCHANT_PURCHASE, [&](const std::string &condition) {
|
||||||
|
return PlayerEventMerchantPurchaseRepository::DeleteWhere(*m_database, condition);
|
||||||
|
}},
|
||||||
|
{
|
||||||
|
PlayerEvent::NPC_HANDIN, [&](const std::string &condition) {
|
||||||
|
uint32 deleted_count = PlayerEventNpcHandinRepository::DeleteWhere(*m_database, condition);
|
||||||
|
deleted_count += PlayerEventNpcHandinEntriesRepository::DeleteWhere(*m_database, condition);
|
||||||
|
return deleted_count;
|
||||||
|
}},
|
||||||
|
{
|
||||||
|
PlayerEvent::TRADE, [&](const std::string &condition) {
|
||||||
|
uint32 deleted_count = PlayerEventTradeRepository::DeleteWhere(*m_database, condition);
|
||||||
|
deleted_count += PlayerEventTradeEntriesRepository::DeleteWhere(*m_database, condition);
|
||||||
|
return deleted_count;
|
||||||
|
}},
|
||||||
|
{
|
||||||
|
PlayerEvent::SPEECH, [&](const std::string &condition) {
|
||||||
|
return PlayerEventSpeechRepository::DeleteWhere(*m_database, condition);
|
||||||
|
}},
|
||||||
|
{
|
||||||
|
PlayerEvent::KILLED_NPC, [&](const std::string &condition) {
|
||||||
|
return PlayerEventKilledNpcRepository::DeleteWhere(*m_database, condition);
|
||||||
|
}},
|
||||||
|
{
|
||||||
|
PlayerEvent::KILLED_NAMED_NPC, [&](const std::string &condition) {
|
||||||
|
return PlayerEventKilledNamedNpcRepository::DeleteWhere(*m_database, condition);
|
||||||
|
}},
|
||||||
|
{
|
||||||
|
PlayerEvent::KILLED_RAID_NPC, [&](const std::string &condition) {
|
||||||
|
return PlayerEventKilledRaidNpcRepository::DeleteWhere(*m_database, condition);
|
||||||
|
}},
|
||||||
|
{
|
||||||
|
PlayerEvent::AA_PURCHASE, [&](const std::string &condition) {
|
||||||
|
return PlayerEventAaPurchaseRepository::DeleteWhere(*m_database, condition);
|
||||||
|
}}
|
||||||
|
};
|
||||||
|
|
||||||
|
// Group event types by retention interval
|
||||||
|
std::unordered_map<int, std::vector<int>> retention_groups;
|
||||||
for (int i = PlayerEvent::GM_COMMAND; i != PlayerEvent::MAX; i++) {
|
for (int i = PlayerEvent::GM_COMMAND; i != PlayerEvent::MAX; i++) {
|
||||||
if (m_settings[i].retention_days > 0) {
|
if (m_settings[i].retention_days > 0) {
|
||||||
int deleted_count = PlayerEventLogsRepository::DeleteWhere(
|
retention_groups[m_settings[i].retention_days].push_back(i);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (const auto &[retention_days, event_types]: retention_groups) {
|
||||||
|
std::string condition = fmt::format(
|
||||||
|
"created_at < (NOW() - INTERVAL {} DAY)",
|
||||||
|
retention_days
|
||||||
|
);
|
||||||
|
|
||||||
|
// Handle ETL deletions for each event type in the group
|
||||||
|
uint32 total_deleted_count = 0;
|
||||||
|
for (int event_type_id: event_types) {
|
||||||
|
if (m_settings[event_type_id].etl_enabled) {
|
||||||
|
auto it = repository_deleters.find(static_cast<PlayerEvent::EventType>(m_settings[event_type_id].id));
|
||||||
|
if (it != repository_deleters.end()) {
|
||||||
|
total_deleted_count += it->second(condition);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
LogError("Non-Implemented ETL Event Type [{}]", static_cast<uint32>(m_settings[event_type_id].id));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (total_deleted_count > 0) {
|
||||||
|
LogInfo(
|
||||||
|
"Truncated [{}] ETL events older than [{}] days",
|
||||||
|
total_deleted_count,
|
||||||
|
retention_days
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Batch deletion for player_event_logs
|
||||||
|
std::string event_type_ids = fmt::format(
|
||||||
|
"({})",
|
||||||
|
fmt::join(event_types, ", ")
|
||||||
|
);
|
||||||
|
|
||||||
|
uint32 deleted_count = PlayerEventLogsRepository::DeleteWhere(
|
||||||
*m_database,
|
*m_database,
|
||||||
fmt::format(
|
fmt::format(
|
||||||
"event_type_id = {} AND created_at < (NOW() - INTERVAL {} DAY)",
|
"event_type_id IN {} AND {}",
|
||||||
i,
|
event_type_ids,
|
||||||
m_settings[i].retention_days
|
condition
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
if (deleted_count > 0) {
|
if (deleted_count > 0) {
|
||||||
LogInfo(
|
LogInfo(
|
||||||
"Truncated [{}] events of type [{}] ({}) older than [{}] days",
|
"Truncated [{}] events of types [{}] older than [{}] days",
|
||||||
deleted_count,
|
deleted_count,
|
||||||
PlayerEvent::EventName[i],
|
event_type_ids,
|
||||||
i,
|
retention_days
|
||||||
m_settings[i].retention_days
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void PlayerEventLogs::ReloadSettings()
|
void PlayerEventLogs::ReloadSettings()
|
||||||
@@ -707,8 +1127,144 @@ void PlayerEventLogs::SetSettingsDefaults()
|
|||||||
m_settings[PlayerEvent::PARCEL_RETRIEVE].event_enabled = 1;
|
m_settings[PlayerEvent::PARCEL_RETRIEVE].event_enabled = 1;
|
||||||
m_settings[PlayerEvent::PARCEL_DELETE].event_enabled = 1;
|
m_settings[PlayerEvent::PARCEL_DELETE].event_enabled = 1;
|
||||||
m_settings[PlayerEvent::BARTER_TRANSACTION].event_enabled = 1;
|
m_settings[PlayerEvent::BARTER_TRANSACTION].event_enabled = 1;
|
||||||
|
m_settings[PlayerEvent::EVOLVE_ITEM].event_enabled = 1;
|
||||||
|
m_settings[PlayerEvent::SPEECH].event_enabled = 0;
|
||||||
|
|
||||||
for (int i = PlayerEvent::GM_COMMAND; i != PlayerEvent::MAX; i++) {
|
for (int i = PlayerEvent::GM_COMMAND; i != PlayerEvent::MAX; i++) {
|
||||||
m_settings[i].retention_days = RETENTION_DAYS_DEFAULT;
|
m_settings[i].retention_days = RETENTION_DAYS_DEFAULT;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void PlayerEventLogs::LoadEtlIds()
|
||||||
|
{
|
||||||
|
auto e = [&](auto p) -> bool {
|
||||||
|
for (PlayerEventLogSettingsRepository::PlayerEventLogSettings const &c: m_settings) {
|
||||||
|
if (c.id == p) {
|
||||||
|
return c.etl_enabled ? true : false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
};
|
||||||
|
|
||||||
|
m_etl_settings.clear();
|
||||||
|
m_etl_settings = {
|
||||||
|
{
|
||||||
|
PlayerEvent::LOOT_ITEM,
|
||||||
|
{
|
||||||
|
.enabled = e(PlayerEvent::LOOT_ITEM),
|
||||||
|
.table_name = "player_event_loot_items",
|
||||||
|
.next_id = static_cast<int64>(m_database->GetNextTableId(PlayerEventLootItemsRepository::TableName()))
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
PlayerEvent::MERCHANT_SELL,
|
||||||
|
{
|
||||||
|
.enabled = e(PlayerEvent::MERCHANT_SELL),
|
||||||
|
.table_name = "player_event_merchant_sell",
|
||||||
|
.next_id = static_cast<int64>(m_database->GetNextTableId(PlayerEventMerchantSellRepository::TableName()))
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
PlayerEvent::MERCHANT_PURCHASE,
|
||||||
|
{
|
||||||
|
.enabled = e(PlayerEvent::MERCHANT_PURCHASE),
|
||||||
|
.table_name = "player_event_merchant_purchase",
|
||||||
|
.next_id = static_cast<int64>(m_database->GetNextTableId(PlayerEventMerchantPurchaseRepository::TableName()))
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
PlayerEvent::NPC_HANDIN,
|
||||||
|
{
|
||||||
|
.enabled = e(PlayerEvent::NPC_HANDIN),
|
||||||
|
.table_name = "player_event_npc_handin",
|
||||||
|
.next_id = static_cast<int64>(m_database->GetNextTableId(PlayerEventNpcHandinRepository::TableName()))
|
||||||
|
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
PlayerEvent::TRADE,
|
||||||
|
{
|
||||||
|
.enabled = e(PlayerEvent::TRADE),
|
||||||
|
.table_name = "player_event_trade",
|
||||||
|
.next_id = static_cast<int64>(m_database->GetNextTableId(PlayerEventTradeRepository::TableName()))
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
PlayerEvent::SPEECH,
|
||||||
|
{
|
||||||
|
.enabled = e(PlayerEvent::SPEECH),
|
||||||
|
.table_name = "player_event_speech",
|
||||||
|
.next_id = static_cast<int64>(m_database->GetNextTableId(PlayerEventSpeechRepository::TableName()))
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
PlayerEvent::KILLED_NPC,
|
||||||
|
{
|
||||||
|
.enabled = e(PlayerEvent::KILLED_NPC),
|
||||||
|
.table_name = "player_event_killed_npc",
|
||||||
|
.next_id = static_cast<int64>(m_database->GetNextTableId(PlayerEventKilledNpcRepository::TableName()))
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
PlayerEvent::KILLED_NAMED_NPC,
|
||||||
|
{
|
||||||
|
.enabled = e(PlayerEvent::KILLED_NAMED_NPC),
|
||||||
|
.table_name = "player_event_killed_named_npc",
|
||||||
|
.next_id = static_cast<int64>(m_database->GetNextTableId(PlayerEventKilledNamedNpcRepository::TableName()))
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
PlayerEvent::KILLED_RAID_NPC,
|
||||||
|
{
|
||||||
|
.enabled = e(PlayerEvent::KILLED_RAID_NPC),
|
||||||
|
.table_name = "player_event_killed_raid_npc",
|
||||||
|
.next_id = static_cast<int64>(m_database->GetNextTableId(PlayerEventKilledRaidNpcRepository::TableName()))
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
PlayerEvent::AA_PURCHASE,
|
||||||
|
{
|
||||||
|
.enabled = e(PlayerEvent::AA_PURCHASE),
|
||||||
|
.table_name = "player_event_aa_purchase",
|
||||||
|
.next_id = static_cast<int64>(m_database->GetNextTableId(PlayerEventAaPurchaseRepository::TableName()))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
for (auto &e: m_etl_settings) {
|
||||||
|
LogPlayerEventsDetail(
|
||||||
|
"ETL Settings [{}] Enabled [{}] Table [{}] NextId [{}]",
|
||||||
|
PlayerEvent::EventName[e.first],
|
||||||
|
e.second.enabled,
|
||||||
|
e.second.table_name,
|
||||||
|
e.second.next_id
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bool PlayerEventLogs::LoadDatabaseConnection()
|
||||||
|
{
|
||||||
|
const auto c = EQEmuConfig::get();
|
||||||
|
|
||||||
|
LogInfo(
|
||||||
|
"Connecting to MySQL for PlayerEvents [{}]@[{}]:[{}]",
|
||||||
|
c->DatabaseUsername.c_str(),
|
||||||
|
c->DatabaseHost.c_str(),
|
||||||
|
c->DatabasePort
|
||||||
|
);
|
||||||
|
|
||||||
|
if (!player_event_database.Connect(
|
||||||
|
c->DatabaseHost.c_str(),
|
||||||
|
c->DatabaseUsername.c_str(),
|
||||||
|
c->DatabasePassword.c_str(),
|
||||||
|
c->DatabaseDB.c_str(),
|
||||||
|
c->DatabasePort
|
||||||
|
)) {
|
||||||
|
LogError("Cannot continue without a database connection for player events.");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
SetDatabase(&player_event_database);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,19 +1,38 @@
|
|||||||
#ifndef EQEMU_PLAYER_EVENT_LOGS_H
|
#ifndef EQEMU_PLAYER_EVENT_LOGS_H
|
||||||
#define EQEMU_PLAYER_EVENT_LOGS_H
|
#define EQEMU_PLAYER_EVENT_LOGS_H
|
||||||
|
|
||||||
#include "../repositories/player_event_log_settings_repository.h"
|
|
||||||
#include "player_events.h"
|
|
||||||
#include "../servertalk.h"
|
|
||||||
#include "../repositories/player_event_logs_repository.h"
|
|
||||||
#include "../timer.h"
|
|
||||||
#include "../json/json_archive_single_line.h"
|
|
||||||
#include <cereal/archives/json.hpp>
|
#include <cereal/archives/json.hpp>
|
||||||
#include <mutex>
|
#include <mutex>
|
||||||
|
#include "../json/json_archive_single_line.h"
|
||||||
|
#include "../servertalk.h"
|
||||||
|
#include "../timer.h"
|
||||||
|
#include "../eqemu_config.h"
|
||||||
|
|
||||||
|
#include "../repositories/player_event_log_settings_repository.h"
|
||||||
|
#include "../repositories/player_event_logs_repository.h"
|
||||||
|
#include "../repositories/player_event_loot_items_repository.h"
|
||||||
|
#include "../repositories/player_event_merchant_purchase_repository.h"
|
||||||
|
#include "../repositories/player_event_merchant_sell_repository.h"
|
||||||
|
#include "../repositories/player_event_npc_handin_repository.h"
|
||||||
|
#include "../repositories/player_event_npc_handin_entries_repository.h"
|
||||||
|
#include "../repositories/player_event_trade_repository.h"
|
||||||
|
#include "../repositories/player_event_trade_entries_repository.h"
|
||||||
|
#include "../repositories/player_event_speech_repository.h"
|
||||||
|
#include "../repositories/player_event_killed_npc_repository.h"
|
||||||
|
#include "../repositories/player_event_killed_named_npc_repository.h"
|
||||||
|
#include "../repositories/player_event_killed_raid_npc_repository.h"
|
||||||
|
#include "../repositories/player_event_aa_purchase_repository.h"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class PlayerEventLogs {
|
class PlayerEventLogs {
|
||||||
public:
|
public:
|
||||||
|
Database player_event_database{};
|
||||||
|
|
||||||
void Init();
|
void Init();
|
||||||
|
bool LoadDatabaseConnection();
|
||||||
void ReloadSettings();
|
void ReloadSettings();
|
||||||
|
void LoadEtlIds();
|
||||||
PlayerEventLogs *SetDatabase(Database *db);
|
PlayerEventLogs *SetDatabase(Database *db);
|
||||||
bool ValidateDatabaseConnection();
|
bool ValidateDatabaseConnection();
|
||||||
bool IsEventEnabled(PlayerEvent::EventType event);
|
bool IsEventEnabled(PlayerEvent::EventType event);
|
||||||
@@ -21,7 +40,7 @@ public:
|
|||||||
void Process();
|
void Process();
|
||||||
|
|
||||||
// batch queue
|
// batch queue
|
||||||
void AddToQueue(const PlayerEventLogsRepository::PlayerEventLogs &logs);
|
void AddToQueue(PlayerEventLogsRepository::PlayerEventLogs &logs);
|
||||||
|
|
||||||
// main event record generic function
|
// main event record generic function
|
||||||
// can ingest any struct event types
|
// can ingest any struct event types
|
||||||
@@ -54,12 +73,42 @@ public:
|
|||||||
return BuildPlayerEventPacket(c);
|
return BuildPlayerEventPacket(c);
|
||||||
}
|
}
|
||||||
|
|
||||||
[[nodiscard]] const PlayerEventLogSettingsRepository::PlayerEventLogSettings *GetSettings() const;
|
[[nodiscard]] const PlayerEventLogSettingsRepository::PlayerEventLogSettings * GetSettings() const;
|
||||||
bool IsEventDiscordEnabled(int32_t event_type_id);
|
bool IsEventDiscordEnabled(int32_t event_type_id);
|
||||||
std::string GetDiscordWebhookUrlFromEventType(int32_t event_type_id);
|
std::string GetDiscordWebhookUrlFromEventType(int32_t event_type_id);
|
||||||
|
|
||||||
|
void LoadPlayerEventSettingsFromQS(const std::vector<PlayerEventLogSettingsRepository::PlayerEventLogSettings>& settings);
|
||||||
|
|
||||||
static std::string GetDiscordPayloadFromEvent(const PlayerEvent::PlayerEventContainer &e);
|
static std::string GetDiscordPayloadFromEvent(const PlayerEvent::PlayerEventContainer &e);
|
||||||
|
|
||||||
|
struct EtlQueues {
|
||||||
|
std::vector<PlayerEventLootItemsRepository::PlayerEventLootItems> loot_items;
|
||||||
|
std::vector<PlayerEventMerchantPurchaseRepository::PlayerEventMerchantPurchase> merchant_purchase;
|
||||||
|
std::vector<PlayerEventMerchantSellRepository::PlayerEventMerchantSell> merchant_sell;
|
||||||
|
std::vector<PlayerEventNpcHandinRepository::PlayerEventNpcHandin> npc_handin;
|
||||||
|
std::vector<PlayerEventNpcHandinEntriesRepository::PlayerEventNpcHandinEntries> npc_handin_entries;
|
||||||
|
std::vector<PlayerEventTradeRepository::PlayerEventTrade> trade;
|
||||||
|
std::vector<PlayerEventTradeEntriesRepository::PlayerEventTradeEntries> trade_entries;
|
||||||
|
std::vector<PlayerEventSpeechRepository::PlayerEventSpeech> speech;
|
||||||
|
std::vector<PlayerEventKilledNpcRepository::PlayerEventKilledNpc> killed_npc;
|
||||||
|
std::vector<PlayerEventKilledNamedNpcRepository::PlayerEventKilledNamedNpc> killed_named_npc;
|
||||||
|
std::vector<PlayerEventKilledRaidNpcRepository::PlayerEventKilledRaidNpc> killed_raid_npc;
|
||||||
|
std::vector<PlayerEventAaPurchaseRepository::PlayerEventAaPurchase> aa_purchase;
|
||||||
|
};
|
||||||
|
|
||||||
|
static PlayerEventLogs* Instance()
|
||||||
|
{
|
||||||
|
static PlayerEventLogs instance;
|
||||||
|
return &instance;
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
struct EtlSettings {
|
||||||
|
bool enabled;
|
||||||
|
std::string table_name;
|
||||||
|
int64 next_id;
|
||||||
|
};
|
||||||
|
|
||||||
Database *m_database; // reference to database
|
Database *m_database; // reference to database
|
||||||
PlayerEventLogSettingsRepository::PlayerEventLogSettings m_settings[PlayerEvent::EventType::MAX]{};
|
PlayerEventLogSettingsRepository::PlayerEventLogSettings m_settings[PlayerEvent::EventType::MAX]{};
|
||||||
|
|
||||||
@@ -69,7 +118,10 @@ private:
|
|||||||
static std::unique_ptr<ServerPacket>
|
static std::unique_ptr<ServerPacket>
|
||||||
BuildPlayerEventPacket(const PlayerEvent::PlayerEventContainer &e);
|
BuildPlayerEventPacket(const PlayerEvent::PlayerEventContainer &e);
|
||||||
|
|
||||||
|
std::map<PlayerEvent::EventType, EtlSettings> m_etl_settings{};
|
||||||
|
|
||||||
// timers
|
// timers
|
||||||
|
Timer m_database_ping_timer; // database ping timer
|
||||||
Timer m_process_batch_events_timer; // events processing timer
|
Timer m_process_batch_events_timer; // events processing timer
|
||||||
Timer m_process_retention_truncation_timer; // timer for truncating events based on retention settings
|
Timer m_process_retention_truncation_timer; // timer for truncating events based on retention settings
|
||||||
|
|
||||||
@@ -78,8 +130,9 @@ private:
|
|||||||
void ProcessBatchQueue();
|
void ProcessBatchQueue();
|
||||||
void ProcessRetentionTruncation();
|
void ProcessRetentionTruncation();
|
||||||
void SetSettingsDefaults();
|
void SetSettingsDefaults();
|
||||||
|
|
||||||
|
public:
|
||||||
|
std::map<PlayerEvent::EventType, EtlSettings> &GetEtlSettings() { return m_etl_settings;}
|
||||||
};
|
};
|
||||||
|
|
||||||
extern PlayerEventLogs player_event_logs;
|
|
||||||
|
|
||||||
#endif //EQEMU_PLAYER_EVENT_LOGS_H
|
#endif //EQEMU_PLAYER_EVENT_LOGS_H
|
||||||
|
|||||||
+867
-203
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,330 @@
|
|||||||
|
#include "evolving_items.h"
|
||||||
|
#include "item_instance.h"
|
||||||
|
#include "events/player_event_logs.h"
|
||||||
|
#include "repositories/character_evolving_items_repository.h"
|
||||||
|
|
||||||
|
EvolvingItemsManager::EvolvingItemsManager()
|
||||||
|
{
|
||||||
|
m_db = nullptr;
|
||||||
|
m_content_db = nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
void EvolvingItemsManager::LoadEvolvingItems() const
|
||||||
|
{
|
||||||
|
auto const &results = ItemsEvolvingDetailsRepository::All(*m_content_db);
|
||||||
|
|
||||||
|
if (results.empty()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::ranges::transform(
|
||||||
|
results.begin(),
|
||||||
|
results.end(),
|
||||||
|
std::inserter(
|
||||||
|
EvolvingItemsManager::Instance()->GetEvolvingItemsCache(),
|
||||||
|
EvolvingItemsManager::Instance()->GetEvolvingItemsCache().end()
|
||||||
|
),
|
||||||
|
[](const ItemsEvolvingDetailsRepository::ItemsEvolvingDetails &x) {
|
||||||
|
return std::make_pair(x.item_id, x);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
void EvolvingItemsManager::SetDatabase(Database *db)
|
||||||
|
{
|
||||||
|
m_db = db;
|
||||||
|
}
|
||||||
|
|
||||||
|
void EvolvingItemsManager::SetContentDatabase(Database *db)
|
||||||
|
{
|
||||||
|
m_content_db = db;
|
||||||
|
}
|
||||||
|
|
||||||
|
double EvolvingItemsManager::CalculateProgression(const uint64 current_amount, const uint32 item_id)
|
||||||
|
{
|
||||||
|
if (!EvolvingItemsManager::Instance()->GetEvolvingItemsCache().contains(item_id)) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
return EvolvingItemsManager::Instance()->GetEvolvingItemsCache().at(item_id).required_amount > 0
|
||||||
|
? static_cast<double>(current_amount)
|
||||||
|
/ static_cast<double>(EvolvingItemsManager::Instance()->GetEvolvingItemsCache().at(item_id).required_amount) * 100
|
||||||
|
: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void EvolvingItemsManager::DoLootChecks(const uint32 char_id, const uint16 slot_id, const EQ::ItemInstance &inst) const
|
||||||
|
{
|
||||||
|
if (!inst) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
inst.SetEvolveEquipped(false);
|
||||||
|
if (inst.IsEvolving() && slot_id <= EQ::invslot::EQUIPMENT_END && slot_id >= EQ::invslot::EQUIPMENT_BEGIN) {
|
||||||
|
inst.SetEvolveEquipped(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!inst.IsEvolving()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!inst.GetEvolveUniqueID()) {
|
||||||
|
auto e = CharacterEvolvingItemsRepository::NewEntity();
|
||||||
|
|
||||||
|
e.character_id = char_id;
|
||||||
|
e.item_id = inst.GetID();
|
||||||
|
e.equipped = inst.GetEvolveEquipped();
|
||||||
|
e.final_item_id = EvolvingItemsManager::Instance()->GetFinalItemID(inst);
|
||||||
|
if (inst.GetEvolveCurrentAmount() > 0) {
|
||||||
|
e.current_amount = inst.GetEvolveCurrentAmount();
|
||||||
|
inst.CalculateEvolveProgression();
|
||||||
|
}
|
||||||
|
|
||||||
|
auto r = CharacterEvolvingItemsRepository::InsertOne(*m_db, e);
|
||||||
|
e.id = r.id;
|
||||||
|
|
||||||
|
inst.SetEvolveUniqueID(e.id);
|
||||||
|
inst.SetEvolveCharID(e.character_id);
|
||||||
|
inst.SetEvolveItemID(e.item_id);
|
||||||
|
inst.SetEvolveFinalItemID(e.final_item_id);
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
CharacterEvolvingItemsRepository::SetEquipped(*m_db, inst.GetEvolveUniqueID(), inst.GetEvolveEquipped());
|
||||||
|
}
|
||||||
|
|
||||||
|
uint32 EvolvingItemsManager::GetFinalItemID(const EQ::ItemInstance &inst) const
|
||||||
|
{
|
||||||
|
if (!inst) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
const auto start_iterator = std::ranges::find_if(
|
||||||
|
EvolvingItemsManager::Instance()->GetEvolvingItemsCache().cbegin(),
|
||||||
|
EvolvingItemsManager::Instance()->GetEvolvingItemsCache().cend(),
|
||||||
|
[&](const std::pair<uint32, ItemsEvolvingDetailsRepository::ItemsEvolvingDetails> &a) {
|
||||||
|
return a.second.item_evo_id == inst.GetEvolveLoreID();
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
if (start_iterator == std::end(EvolvingItemsManager::Instance()->GetEvolvingItemsCache())) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
const auto final_id = std::ranges::max_element(
|
||||||
|
start_iterator,
|
||||||
|
EvolvingItemsManager::Instance()->GetEvolvingItemsCache().cend(),
|
||||||
|
[&](
|
||||||
|
const std::pair<uint32, ItemsEvolvingDetailsRepository::ItemsEvolvingDetails> &a,
|
||||||
|
const std::pair<uint32, ItemsEvolvingDetailsRepository::ItemsEvolvingDetails> &b
|
||||||
|
) {
|
||||||
|
return a.second.item_evo_id == b.second.item_evo_id &&
|
||||||
|
a.second.item_evolve_level < b.second.item_evolve_level;
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
return final_id->first;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint32 EvolvingItemsManager::GetNextEvolveItemID(const EQ::ItemInstance &inst) const
|
||||||
|
{
|
||||||
|
if (!inst) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int8 const current_level = inst.GetEvolveLvl();
|
||||||
|
|
||||||
|
const auto iterator = std::ranges::find_if(
|
||||||
|
EvolvingItemsManager::Instance()->GetEvolvingItemsCache().cbegin(),
|
||||||
|
EvolvingItemsManager::Instance()->GetEvolvingItemsCache().cend(),
|
||||||
|
[&](const std::pair<uint32, ItemsEvolvingDetailsRepository::ItemsEvolvingDetails> &a) {
|
||||||
|
return a.second.item_evo_id == inst.GetEvolveLoreID() &&
|
||||||
|
a.second.item_evolve_level == current_level + 1;
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
if (iterator == std::end(EvolvingItemsManager::Instance()->GetEvolvingItemsCache())) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
return iterator->first;
|
||||||
|
}
|
||||||
|
|
||||||
|
ItemsEvolvingDetailsRepository::ItemsEvolvingDetails EvolvingItemsManager::GetEvolveItemDetails(const uint64 unique_id)
|
||||||
|
{
|
||||||
|
if (GetEvolvingItemsCache().contains(unique_id)) {
|
||||||
|
return GetEvolvingItemsCache().at(unique_id);
|
||||||
|
}
|
||||||
|
|
||||||
|
return ItemsEvolvingDetailsRepository::NewEntity();
|
||||||
|
}
|
||||||
|
|
||||||
|
std::vector<ItemsEvolvingDetailsRepository::ItemsEvolvingDetails> EvolvingItemsManager::GetEvolveIDItems(
|
||||||
|
const uint32 evolve_id
|
||||||
|
)
|
||||||
|
{
|
||||||
|
std::vector<ItemsEvolvingDetailsRepository::ItemsEvolvingDetails> e{};
|
||||||
|
|
||||||
|
for (auto const &[key, value]: GetEvolvingItemsCache()) {
|
||||||
|
if (value.item_evo_id == evolve_id) {
|
||||||
|
e.push_back(value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
std::ranges::sort(
|
||||||
|
e.begin(),
|
||||||
|
e.end(),
|
||||||
|
[&](
|
||||||
|
ItemsEvolvingDetailsRepository::ItemsEvolvingDetails const &a,
|
||||||
|
ItemsEvolvingDetailsRepository::ItemsEvolvingDetails const &b
|
||||||
|
) {
|
||||||
|
return a.item_evolve_level < b.item_evolve_level;
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
return e;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint64 EvolvingItemsManager::GetTotalEarnedXP(const EQ::ItemInstance &inst)
|
||||||
|
{
|
||||||
|
if (!inst) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint64 xp = inst.GetEvolveCurrentAmount();
|
||||||
|
auto evolve_id_item_cache = GetEvolveIDItems(inst.GetEvolveLoreID());
|
||||||
|
auto current_level = inst.GetEvolveLvl();
|
||||||
|
|
||||||
|
for (auto const &i: evolve_id_item_cache) {
|
||||||
|
if (i.item_evolve_level < current_level) {
|
||||||
|
xp += i.required_amount;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return xp;
|
||||||
|
}
|
||||||
|
|
||||||
|
EvolveGetNextItem EvolvingItemsManager::GetNextItemByXP(const EQ::ItemInstance &inst_in, const int64 in_xp)
|
||||||
|
{
|
||||||
|
EvolveGetNextItem ets{};
|
||||||
|
if (!inst_in) {
|
||||||
|
return ets;
|
||||||
|
}
|
||||||
|
|
||||||
|
const auto evolve_items = GetEvolveIDItems(inst_in.GetEvolveLoreID());
|
||||||
|
uint32 max_transfer_level = 0;
|
||||||
|
int64 xp = in_xp;
|
||||||
|
|
||||||
|
for (auto const &e: evolve_items) {
|
||||||
|
if (e.item_evolve_level < inst_in.GetEvolveLvl()) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
int64 have = 0;
|
||||||
|
if (e.item_evolve_level == inst_in.GetEvolveLvl()) {
|
||||||
|
have = inst_in.GetEvolveCurrentAmount();
|
||||||
|
}
|
||||||
|
|
||||||
|
const auto required = e.required_amount;
|
||||||
|
const int64 need = required - have;
|
||||||
|
const int64 balance = xp - need;
|
||||||
|
|
||||||
|
if (balance <= 0) {
|
||||||
|
ets.new_current_amount = have + xp;
|
||||||
|
ets.new_item_id = e.item_id;
|
||||||
|
ets.from_current_amount = 0;
|
||||||
|
ets.max_transfer_level = max_transfer_level;
|
||||||
|
return ets;
|
||||||
|
}
|
||||||
|
|
||||||
|
xp = balance;
|
||||||
|
max_transfer_level += 1;
|
||||||
|
|
||||||
|
ets.new_current_amount = required;
|
||||||
|
ets.new_item_id = e.item_id;
|
||||||
|
ets.from_current_amount = balance - required;
|
||||||
|
ets.max_transfer_level = max_transfer_level;
|
||||||
|
}
|
||||||
|
|
||||||
|
return ets;
|
||||||
|
}
|
||||||
|
|
||||||
|
EvolveTransfer EvolvingItemsManager::DetermineTransferResults(
|
||||||
|
const EQ::ItemInstance &inst_from,
|
||||||
|
const EQ::ItemInstance &inst_to
|
||||||
|
)
|
||||||
|
{
|
||||||
|
EvolveTransfer ets{};
|
||||||
|
if (!inst_from || !inst_to) {
|
||||||
|
return ets;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto evolving_details_inst_from = EvolvingItemsManager::Instance()->GetEvolveItemDetails(inst_from.GetID());
|
||||||
|
auto evolving_details_inst_to = EvolvingItemsManager::Instance()->GetEvolveItemDetails(inst_to.GetID());
|
||||||
|
|
||||||
|
if (!evolving_details_inst_from.id || !evolving_details_inst_to.id) {
|
||||||
|
return ets;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (evolving_details_inst_from.type == evolving_details_inst_to.type) {
|
||||||
|
uint32 compatibility = 0;
|
||||||
|
uint64 xp = 0;
|
||||||
|
if (evolving_details_inst_from.sub_type == evolving_details_inst_to.sub_type) {
|
||||||
|
compatibility = 100;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
compatibility = 30;
|
||||||
|
}
|
||||||
|
|
||||||
|
xp = EvolvingItemsManager::Instance()->GetTotalEarnedXP(inst_from) * compatibility / 100;
|
||||||
|
auto results = EvolvingItemsManager::Instance()->GetNextItemByXP(inst_to, xp);
|
||||||
|
|
||||||
|
ets.item_from_id = EvolvingItemsManager::Instance()->GetFirstItemInLoreGroup(inst_from.GetEvolveLoreID());
|
||||||
|
ets.item_from_current_amount = results.from_current_amount;
|
||||||
|
ets.item_to_id = results.new_item_id;
|
||||||
|
ets.item_to_current_amount = results.new_current_amount;
|
||||||
|
ets.compatibility = compatibility;
|
||||||
|
ets.max_transfer_level = results.max_transfer_level;
|
||||||
|
}
|
||||||
|
|
||||||
|
return ets;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint32 EvolvingItemsManager::GetFirstItemInLoreGroup(const uint32 lore_id)
|
||||||
|
{
|
||||||
|
for (auto const &[key, value]: GetEvolvingItemsCache()) {
|
||||||
|
if (value.item_evo_id == lore_id && value.item_evolve_level == 1) {
|
||||||
|
return key;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint32 EvolvingItemsManager::GetFirstItemInLoreGroupByItemID(const uint32 item_id)
|
||||||
|
{
|
||||||
|
for (auto const &[key, value]: GetEvolvingItemsCache()) {
|
||||||
|
if (value.item_id == item_id) {
|
||||||
|
for (auto const &[key2, value2]: GetEvolvingItemsCache()) {
|
||||||
|
if (value2.item_evo_id == value.item_evo_id && value2.item_evolve_level == 1) {
|
||||||
|
return key;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void EvolvingItemsManager::LoadPlayerEvent(const EQ::ItemInstance &inst, PlayerEvent::EvolveItem &e)
|
||||||
|
{
|
||||||
|
if (!inst) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
e.item_id = inst.GetID();
|
||||||
|
e.item_name = inst.GetItem() ? inst.GetItem()->Name : std::string();
|
||||||
|
e.level = inst.GetEvolveLvl();
|
||||||
|
e.progression = inst.GetEvolveProgression();
|
||||||
|
e.unique_id = inst.GetEvolveUniqueID();
|
||||||
|
}
|
||||||
@@ -0,0 +1,70 @@
|
|||||||
|
#ifndef EVOLVING_H
|
||||||
|
#define EVOLVING_H
|
||||||
|
|
||||||
|
#include "shareddb.h"
|
||||||
|
#include "events/player_events.h"
|
||||||
|
#include "repositories/items_evolving_details_repository.h"
|
||||||
|
|
||||||
|
namespace EQ {
|
||||||
|
class ItemInstance;
|
||||||
|
}
|
||||||
|
|
||||||
|
namespace EvolvingItems {
|
||||||
|
namespace Actions {
|
||||||
|
constexpr int8 UPDATE_ITEMS = 0;
|
||||||
|
constexpr int8 TRANSFER_WINDOW_OPEN = 1;
|
||||||
|
constexpr int8 TRANSFER_WINDOW_DETAILS = 2;
|
||||||
|
constexpr int8 TRANSFER_XP = 3;
|
||||||
|
constexpr int8 FINAL_RESULT = 4;
|
||||||
|
}
|
||||||
|
|
||||||
|
namespace Types {
|
||||||
|
constexpr int8 AMOUNT_OF_EXP = 1;
|
||||||
|
constexpr int8 NUMBER_OF_KILLS = 2;
|
||||||
|
constexpr int8 SPECIFIC_MOB_RACE = 3;
|
||||||
|
constexpr int8 SPECIFIC_ZONE_ID = 4;
|
||||||
|
}
|
||||||
|
|
||||||
|
namespace SubTypes {
|
||||||
|
constexpr int8 ALL_EXP = 0;
|
||||||
|
constexpr int8 SOLO_EXP = 1;
|
||||||
|
constexpr int8 GROUP_EXP = 2;
|
||||||
|
constexpr int8 RAID_EXP = 3;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class EvolvingItemsManager
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
EvolvingItemsManager();
|
||||||
|
void SetDatabase(Database *db);
|
||||||
|
void SetContentDatabase(Database *db);
|
||||||
|
|
||||||
|
void LoadEvolvingItems() const;
|
||||||
|
void DoLootChecks(uint32 char_id, uint16 slot_id, const EQ::ItemInstance &inst) const;
|
||||||
|
uint32 GetFinalItemID(const EQ::ItemInstance &inst) const;
|
||||||
|
uint32 GetNextEvolveItemID(const EQ::ItemInstance &inst) const;
|
||||||
|
uint32 GetFirstItemInLoreGroup(uint32 lore_id);
|
||||||
|
uint32 GetFirstItemInLoreGroupByItemID(uint32 item_id);
|
||||||
|
uint64 GetTotalEarnedXP(const EQ::ItemInstance &inst);
|
||||||
|
static double CalculateProgression(uint64 current_amount, uint32 item_id);
|
||||||
|
static void LoadPlayerEvent(const EQ::ItemInstance &inst, PlayerEvent::EvolveItem &e);
|
||||||
|
|
||||||
|
ItemsEvolvingDetailsRepository::ItemsEvolvingDetails GetEvolveItemDetails(uint64 id);
|
||||||
|
EvolveTransfer DetermineTransferResults(const EQ::ItemInstance& inst_from, const EQ::ItemInstance& inst_to);
|
||||||
|
EvolveGetNextItem GetNextItemByXP(const EQ::ItemInstance &inst_in, int64 in_xp);
|
||||||
|
std::map<uint32, ItemsEvolvingDetailsRepository::ItemsEvolvingDetails>& GetEvolvingItemsCache() { return m_evolving_items_cache; }
|
||||||
|
std::vector<ItemsEvolvingDetailsRepository::ItemsEvolvingDetails> GetEvolveIDItems(uint32 evolve_id);
|
||||||
|
|
||||||
|
static EvolvingItemsManager* Instance()
|
||||||
|
{
|
||||||
|
static EvolvingItemsManager instance;
|
||||||
|
return &instance;
|
||||||
|
}
|
||||||
|
private:
|
||||||
|
std::map<uint32, ItemsEvolvingDetailsRepository::ItemsEvolvingDetails> m_evolving_items_cache;
|
||||||
|
Database * m_db;
|
||||||
|
Database * m_content_db;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif //EVOLVING_H
|
||||||
@@ -1,101 +0,0 @@
|
|||||||
/**
|
|
||||||
* EQEmulator: Everquest Server Emulator
|
|
||||||
* Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server)
|
|
||||||
*
|
|
||||||
* This program is free software; you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation; version 2 of the License.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY except by those people which sell it, which
|
|
||||||
* are required to give you total support for your newly bought product;
|
|
||||||
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
|
||||||
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program; if not, write to the Free Software
|
|
||||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "expedition_lockout_timer.h"
|
|
||||||
#include "../common/strings.h"
|
|
||||||
#include "../common/rulesys.h"
|
|
||||||
#include "../common/util/uuid.h"
|
|
||||||
#include <fmt/format.h>
|
|
||||||
|
|
||||||
const char* const DZ_REPLAY_TIMER_NAME = "Replay Timer"; // see December 14, 2016 patch notes
|
|
||||||
|
|
||||||
ExpeditionLockoutTimer::ExpeditionLockoutTimer(
|
|
||||||
std::string expedition_uuid, std::string expedition_name,
|
|
||||||
std::string event_name, uint64_t expire_time, uint32_t duration
|
|
||||||
) :
|
|
||||||
m_expedition_uuid{std::move(expedition_uuid)},
|
|
||||||
m_expedition_name{std::move(expedition_name)},
|
|
||||||
m_event_name{std::move(event_name)},
|
|
||||||
m_expire_time(std::chrono::system_clock::from_time_t(expire_time)),
|
|
||||||
m_duration(duration)
|
|
||||||
{
|
|
||||||
if (m_event_name == DZ_REPLAY_TIMER_NAME)
|
|
||||||
{
|
|
||||||
m_is_replay_timer = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
ExpeditionLockoutTimer ExpeditionLockoutTimer::CreateLockout(
|
|
||||||
const std::string& expedition_name, const std::string& event_name, uint32_t seconds, std::string uuid)
|
|
||||||
{
|
|
||||||
seconds = static_cast<uint32_t>(seconds * RuleR(Expedition, LockoutDurationMultiplier));
|
|
||||||
|
|
||||||
if (uuid.empty())
|
|
||||||
{
|
|
||||||
uuid = EQ::Util::UUID::Generate().ToString();
|
|
||||||
}
|
|
||||||
|
|
||||||
ExpeditionLockoutTimer lockout{uuid, expedition_name, event_name, 0, seconds};
|
|
||||||
lockout.Reset(); // sets expire time
|
|
||||||
return lockout;
|
|
||||||
}
|
|
||||||
|
|
||||||
uint32_t ExpeditionLockoutTimer::GetSecondsRemaining() const
|
|
||||||
{
|
|
||||||
auto now = std::chrono::system_clock::now();
|
|
||||||
if (m_expire_time > now)
|
|
||||||
{
|
|
||||||
auto remaining = m_expire_time - now;
|
|
||||||
return static_cast<uint32_t>(std::chrono::duration_cast<std::chrono::seconds>(remaining).count());
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
ExpeditionLockoutTimer::DaysHoursMinutes ExpeditionLockoutTimer::GetDaysHoursMinutesRemaining() const
|
|
||||||
{
|
|
||||||
auto seconds = GetSecondsRemaining();
|
|
||||||
return ExpeditionLockoutTimer::DaysHoursMinutes{
|
|
||||||
fmt::format_int(seconds / 86400).str(), // days
|
|
||||||
fmt::format_int((seconds / 3600) % 24).str(), // hours
|
|
||||||
fmt::format_int((seconds / 60) % 60).str() // minutes
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
bool ExpeditionLockoutTimer::IsSameLockout(const ExpeditionLockoutTimer& compare_lockout) const
|
|
||||||
{
|
|
||||||
return compare_lockout.IsSameLockout(GetExpeditionName(), GetEventName());
|
|
||||||
}
|
|
||||||
|
|
||||||
bool ExpeditionLockoutTimer::IsSameLockout(
|
|
||||||
const std::string& expedition_name, const std::string& event_name) const
|
|
||||||
{
|
|
||||||
return GetExpeditionName() == expedition_name && GetEventName() == event_name;
|
|
||||||
}
|
|
||||||
|
|
||||||
void ExpeditionLockoutTimer::AddLockoutTime(int seconds)
|
|
||||||
{
|
|
||||||
seconds = static_cast<uint32_t>(seconds * RuleR(Expedition, LockoutDurationMultiplier));
|
|
||||||
|
|
||||||
auto new_duration = std::max(0, static_cast<int>(m_duration.count()) + seconds);
|
|
||||||
|
|
||||||
auto start_time = m_expire_time - m_duration;
|
|
||||||
m_duration = std::chrono::seconds(new_duration);
|
|
||||||
m_expire_time = start_time + m_duration;
|
|
||||||
}
|
|
||||||
@@ -1,76 +0,0 @@
|
|||||||
/**
|
|
||||||
* EQEmulator: Everquest Server Emulator
|
|
||||||
* Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server)
|
|
||||||
*
|
|
||||||
* This program is free software; you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation; version 2 of the License.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY except by those people which sell it, which
|
|
||||||
* are required to give you total support for your newly bought product;
|
|
||||||
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
|
||||||
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program; if not, write to the Free Software
|
|
||||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef EXPEDITION_LOCKOUT_TIMER_H
|
|
||||||
#define EXPEDITION_LOCKOUT_TIMER_H
|
|
||||||
|
|
||||||
#include <chrono>
|
|
||||||
#include <string>
|
|
||||||
|
|
||||||
extern const char* const DZ_REPLAY_TIMER_NAME;
|
|
||||||
|
|
||||||
class ExpeditionLockoutTimer
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
ExpeditionLockoutTimer() = default;
|
|
||||||
ExpeditionLockoutTimer(
|
|
||||||
std::string expedition_uuid, std::string expedition_name,
|
|
||||||
std::string event_name, uint64_t expire_time, uint32_t duration);
|
|
||||||
|
|
||||||
static ExpeditionLockoutTimer CreateLockout(
|
|
||||||
const std::string& expedition_name, const std::string& event_name,
|
|
||||||
uint32_t seconds, std::string uuid = {});
|
|
||||||
|
|
||||||
struct DaysHoursMinutes
|
|
||||||
{
|
|
||||||
std::string days;
|
|
||||||
std::string hours;
|
|
||||||
std::string mins;
|
|
||||||
};
|
|
||||||
|
|
||||||
void AddLockoutTime(int seconds);
|
|
||||||
uint32_t GetDuration() const { return static_cast<uint32_t>(m_duration.count()); }
|
|
||||||
uint64_t GetExpireTime() const { return std::chrono::system_clock::to_time_t(m_expire_time); }
|
|
||||||
uint64_t GetStartTime() const { return std::chrono::system_clock::to_time_t(m_expire_time - m_duration); }
|
|
||||||
uint32_t GetSecondsRemaining() const;
|
|
||||||
DaysHoursMinutes GetDaysHoursMinutesRemaining() const;
|
|
||||||
const std::string& GetExpeditionName() const { return m_expedition_name; }
|
|
||||||
const std::string& GetExpeditionUUID() const { return m_expedition_uuid; }
|
|
||||||
const std::string& GetEventName() const { return m_event_name; }
|
|
||||||
bool IsExpired() const { return GetSecondsRemaining() == 0; }
|
|
||||||
bool IsFromExpedition(const std::string& uuid) const { return uuid == m_expedition_uuid; }
|
|
||||||
bool IsReplayTimer() const { return m_is_replay_timer; }
|
|
||||||
bool IsSameLockout(const ExpeditionLockoutTimer& compare_lockout) const;
|
|
||||||
bool IsSameLockout(const std::string& expedition_name, const std::string& event_name) const;
|
|
||||||
void Reset() { m_expire_time = std::chrono::system_clock::now() + m_duration; }
|
|
||||||
void SetDuration(uint32_t seconds) { m_duration = std::chrono::seconds(seconds); }
|
|
||||||
void SetExpireTime(uint64_t expire_time) { m_expire_time = std::chrono::system_clock::from_time_t(expire_time); }
|
|
||||||
void SetUUID(const std::string& uuid) { m_expedition_uuid = uuid; }
|
|
||||||
|
|
||||||
private:
|
|
||||||
bool m_is_replay_timer = false;
|
|
||||||
std::string m_expedition_uuid; // expedition received in
|
|
||||||
std::string m_expedition_name;
|
|
||||||
std::string m_event_name;
|
|
||||||
std::chrono::seconds m_duration;
|
|
||||||
std::chrono::time_point<std::chrono::system_clock> m_expire_time;
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif
|
|
||||||
+29
-29
@@ -95,12 +95,12 @@ bool IsOfEqualRace(int r1, int r2)
|
|||||||
}
|
}
|
||||||
// TODO: add more values
|
// TODO: add more values
|
||||||
switch (r1) {
|
switch (r1) {
|
||||||
case DARK_ELF:
|
case Race::DarkElf:
|
||||||
if (r2 == Race::NeriakCitizen) {
|
if (r2 == Race::NeriakCitizen) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case BARBARIAN:
|
case Race::Barbarian:
|
||||||
if (r2 == Race::HalasCitizen) {
|
if (r2 == Race::HalasCitizen) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -116,49 +116,49 @@ bool IsOfIndiffRace(int r1, int r2)
|
|||||||
}
|
}
|
||||||
// TODO: add more values
|
// TODO: add more values
|
||||||
switch (r1) {
|
switch (r1) {
|
||||||
case DARK_ELF:
|
case Race::DarkElf:
|
||||||
case OGRE:
|
case Race::Ogre:
|
||||||
case TROLL:
|
case Race::Troll:
|
||||||
if (r2 == OGRE || r2 == TROLL || r2 == DARK_ELF) {
|
if (r2 == Race::Ogre || r2 == Race::Troll || r2 == Race::DarkElf) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case HUMAN:
|
case Race::Human:
|
||||||
case BARBARIAN:
|
case Race::Barbarian:
|
||||||
case HALF_ELF:
|
case Race::HalfElf:
|
||||||
case GNOME:
|
case Race::Gnome:
|
||||||
case HALFLING:
|
case Race::Halfling:
|
||||||
case WOOD_ELF:
|
case Race::WoodElf:
|
||||||
if (r2 == HUMAN ||
|
if (r2 == Race::Human ||
|
||||||
r2 == BARBARIAN ||
|
r2 == Race::Barbarian ||
|
||||||
r2 == ERUDITE ||
|
r2 == Race::Erudite ||
|
||||||
r2 == HALF_ELF ||
|
r2 == Race::HalfElf ||
|
||||||
r2 == GNOME ||
|
r2 == Race::Gnome ||
|
||||||
r2 == HALFLING ||
|
r2 == Race::Halfling ||
|
||||||
r2 == DWARF ||
|
r2 == Race::Dwarf ||
|
||||||
r2 == HIGH_ELF ||
|
r2 == Race::HighElf ||
|
||||||
r2 == WOOD_ELF) {
|
r2 == Race::WoodElf) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case ERUDITE:
|
case Race::Erudite:
|
||||||
if (r2 == HUMAN || r2 == HALF_ELF) {
|
if (r2 == Race::Human || r2 == Race::HalfElf) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case DWARF:
|
case Race::Dwarf:
|
||||||
if (r2 == HALFLING || r2 == GNOME) {
|
if (r2 == Race::Halfling || r2 == Race::Gnome) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case HIGH_ELF:
|
case Race::HighElf:
|
||||||
if (r2 == WOOD_ELF) {
|
if (r2 == Race::WoodElf) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case VAHSHIR:
|
case Race::VahShir:
|
||||||
return true;
|
return true;
|
||||||
case IKSAR:
|
case Race::Iksar:
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
+13
-13
@@ -36,9 +36,11 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <fmt/format.h>
|
#include <fmt/format.h>
|
||||||
|
#include <fmt/ranges.h>
|
||||||
#include <filesystem>
|
#include <filesystem>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
namespace fs = std::filesystem;
|
namespace fs = std::filesystem;
|
||||||
|
|
||||||
@@ -90,23 +92,21 @@ std::string File::GetCwd()
|
|||||||
|
|
||||||
FileContentsResult File::GetContents(const std::string &file_name)
|
FileContentsResult File::GetContents(const std::string &file_name)
|
||||||
{
|
{
|
||||||
std::string error;
|
std::ifstream f(file_name, std::ios::in | std::ios::binary);
|
||||||
std::ifstream f;
|
if (!f) {
|
||||||
f.open(file_name);
|
return { .error = fmt::format("Couldn't open file [{}]", file_name) };
|
||||||
std::string line;
|
}
|
||||||
|
|
||||||
|
constexpr size_t CHUNK_SIZE = 4096; // Read 4KB chunks
|
||||||
std::string lines;
|
std::string lines;
|
||||||
if (f.is_open()) {
|
std::vector<char> buffer(CHUNK_SIZE);
|
||||||
while (f) {
|
|
||||||
std::getline(f, line);
|
while (f.read(buffer.data(), CHUNK_SIZE) || f.gcount() > 0) {
|
||||||
lines += line + "\n";
|
lines.append(buffer.data(), f.gcount());
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
error = fmt::format("Couldn't open file [{}]", file_name);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return FileContentsResult{
|
return FileContentsResult{
|
||||||
.contents = lines,
|
.contents = lines,
|
||||||
.error = error,
|
.error = {}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
+19
-17
@@ -547,52 +547,54 @@ uint32 BaseGuildManager::UpdateDbCreateGuild(std::string name, uint32 leader)
|
|||||||
|
|
||||||
bool BaseGuildManager::UpdateDbDeleteGuild(uint32 guild_id, bool local_delete, bool db_delete)
|
bool BaseGuildManager::UpdateDbDeleteGuild(uint32 guild_id, bool local_delete, bool db_delete)
|
||||||
{
|
{
|
||||||
|
auto const where_filter = fmt::format("guild_id = {}", guild_id);
|
||||||
|
auto const bank_items = GuildBankRepository::GetWhere(*m_db, where_filter);
|
||||||
|
|
||||||
if (local_delete) {
|
if (local_delete) {
|
||||||
auto where_filter = fmt::format("guildid = {}", guild_id);
|
|
||||||
auto bank_items = GuildBankRepository::GetWhere(*m_db, where_filter);
|
|
||||||
if (!bank_items.empty()) {
|
if (!bank_items.empty()) {
|
||||||
LogError(
|
LogError(
|
||||||
"Attempt to delete guild id [{}] that still has [{}] items in the bank. Please remove them and try again.",
|
"Attempt to delete guild id [{}] that still has [{}] items in the bank. Please remove them and try "
|
||||||
|
"again.",
|
||||||
guild_id,
|
guild_id,
|
||||||
bank_items.size()
|
bank_items.size()
|
||||||
);
|
);
|
||||||
LogGuilds(
|
LogGuilds(
|
||||||
"Attempt to delete guild id [{}] that still has [{}] items in the bank. Please remove them and try again.",
|
"Attempt to delete guild id [{}] that still has [{}] items in the bank. Please remove them and try "
|
||||||
|
"again.",
|
||||||
guild_id,
|
guild_id,
|
||||||
bank_items.size()
|
bank_items.size()
|
||||||
);
|
);
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
else {
|
|
||||||
std::map<uint32, GuildInfo *>::iterator res;
|
auto res = m_guilds.find(guild_id);
|
||||||
res = m_guilds.find(guild_id);
|
|
||||||
if (res != m_guilds.end()) {
|
if (res != m_guilds.end()) {
|
||||||
delete res->second;
|
safe_delete(res->second);
|
||||||
m_guilds.erase(res);
|
m_guilds.erase(res);
|
||||||
LogGuilds("Deleted guild [{}] from memory", guild_id);
|
LogGuilds("Deleted guild [{}] from memory", guild_id);
|
||||||
//Does this need to be sent to world?
|
// Does this need to be sent to world?
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (db_delete) {
|
if (db_delete) {
|
||||||
auto where_filter = fmt::format("guildid = {}", guild_id);
|
|
||||||
auto bank_items = GuildBankRepository::GetWhere(*m_db, where_filter);
|
|
||||||
if (!bank_items.empty()) {
|
if (!bank_items.empty()) {
|
||||||
LogError(
|
LogError(
|
||||||
"Attempt to delete guild id [{}] that still has [{}] items in the bank. Please remove them and try again.",
|
"Attempt to delete guild id [{}] that still has [{}] items in the bank. Please remove them and try "
|
||||||
|
"again.",
|
||||||
guild_id,
|
guild_id,
|
||||||
bank_items.size()
|
bank_items.size()
|
||||||
);
|
);
|
||||||
LogGuilds(
|
LogGuilds(
|
||||||
"Attempt to delete guild id [{}] that still has [{}] items in the bank. Please remove them and try again.",
|
"Attempt to delete guild id [{}] that still has [{}] items in the bank. Please remove them and try "
|
||||||
|
"again.",
|
||||||
guild_id,
|
guild_id,
|
||||||
bank_items.size()
|
bank_items.size()
|
||||||
);
|
);
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
else {
|
|
||||||
auto where_filter = fmt::format("guild_id = {}", guild_id);
|
|
||||||
GuildTributesRepository::DeleteOne(*m_db, guild_id);
|
GuildTributesRepository::DeleteOne(*m_db, guild_id);
|
||||||
GuildsRepository::DeleteOne(*m_db, guild_id);
|
GuildsRepository::DeleteOne(*m_db, guild_id);
|
||||||
GuildRanksRepository::DeleteWhere(*m_db, where_filter);
|
GuildRanksRepository::DeleteWhere(*m_db, where_filter);
|
||||||
@@ -600,7 +602,7 @@ bool BaseGuildManager::UpdateDbDeleteGuild(uint32 guild_id, bool local_delete, b
|
|||||||
GuildMembersRepository::DeleteWhere(*m_db, where_filter);
|
GuildMembersRepository::DeleteWhere(*m_db, where_filter);
|
||||||
LogGuilds("Deleted guild [{}] from the database", guild_id);
|
LogGuilds("Deleted guild [{}] from the database", guild_id);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+756
-482
File diff suppressed because it is too large
Load Diff
+14
-11
@@ -57,6 +57,8 @@ public:
|
|||||||
|
|
||||||
inline std::list<EQ::ItemInstance*>::const_iterator cbegin() { return m_list.cbegin(); }
|
inline std::list<EQ::ItemInstance*>::const_iterator cbegin() { return m_list.cbegin(); }
|
||||||
inline std::list<EQ::ItemInstance*>::const_iterator cend() { return m_list.cend(); }
|
inline std::list<EQ::ItemInstance*>::const_iterator cend() { return m_list.cend(); }
|
||||||
|
inline std::list<EQ::ItemInstance*>::iterator begin() { return m_list.begin(); }
|
||||||
|
inline std::list<EQ::ItemInstance*>::iterator end() { return m_list.end(); }
|
||||||
|
|
||||||
inline int size() { return static_cast<int>(m_list.size()); } // TODO: change to size_t
|
inline int size() { return static_cast<int>(m_list.size()); } // TODO: change to size_t
|
||||||
inline bool empty() { return m_list.empty(); }
|
inline bool empty() { return m_list.empty(); }
|
||||||
@@ -147,13 +149,13 @@ namespace EQ
|
|||||||
bool HasItemEquippedByID(uint32 item_id);
|
bool HasItemEquippedByID(uint32 item_id);
|
||||||
|
|
||||||
// Check how many of a specific item the player has equipped by Item ID
|
// Check how many of a specific item the player has equipped by Item ID
|
||||||
int CountItemEquippedByID(uint32 item_id);
|
uint32 CountItemEquippedByID(uint32 item_id);
|
||||||
|
|
||||||
// Check if player has a specific augment equipped by Item ID
|
// Check if player has a specific augment equipped by Item ID
|
||||||
bool HasAugmentEquippedByID(uint32 item_id);
|
bool HasAugmentEquippedByID(uint32 item_id);
|
||||||
|
|
||||||
// Check how many of a specific augment the player has equipped by Item ID
|
// Check how many of a specific augment the player has equipped by Item ID
|
||||||
int CountAugmentEquippedByID(uint32 item_id);
|
uint32 CountAugmentEquippedByID(uint32 item_id);
|
||||||
|
|
||||||
// Get a list of augments from a specific slot ID
|
// Get a list of augments from a specific slot ID
|
||||||
std::vector<uint32> GetAugmentIDsBySlotID(int16 slot_id);
|
std::vector<uint32> GetAugmentIDsBySlotID(int16 slot_id);
|
||||||
@@ -176,8 +178,8 @@ namespace EQ
|
|||||||
// Locate an available inventory slot
|
// Locate an available inventory slot
|
||||||
int16 FindFreeSlot(bool for_bag, bool try_cursor, uint8 min_size = 0, bool is_arrow = false);
|
int16 FindFreeSlot(bool for_bag, bool try_cursor, uint8 min_size = 0, bool is_arrow = false);
|
||||||
int16 FindFreeSlotForTradeItem(const ItemInstance* inst, int16 general_start = invslot::GENERAL_BEGIN, uint8 bag_start = invbag::SLOT_BEGIN);
|
int16 FindFreeSlotForTradeItem(const ItemInstance* inst, int16 general_start = invslot::GENERAL_BEGIN, uint8 bag_start = invbag::SLOT_BEGIN);
|
||||||
std::vector<int16> FindAllFreeSlotsThatFitItem(const EQ::ItemData *inst);
|
|
||||||
int16 FindFirstFreeSlotThatFitsItem(const EQ::ItemData *inst);
|
int16 FindFirstFreeSlotThatFitsItem(const EQ::ItemData *inst);
|
||||||
|
int16 FindFirstFreeSlotThatFitsItemWithStacking(ItemInstance *inst) const;
|
||||||
|
|
||||||
// Calculate slot_id for an item within a bag
|
// Calculate slot_id for an item within a bag
|
||||||
static int16 CalcSlotId(int16 slot_id); // Calc parent bag's slot_id
|
static int16 CalcSlotId(int16 slot_id); // Calc parent bag's slot_id
|
||||||
@@ -199,26 +201,25 @@ namespace EQ
|
|||||||
|
|
||||||
uint8 FindBrightestLightType();
|
uint8 FindBrightestLightType();
|
||||||
|
|
||||||
void dumpEntireInventory();
|
|
||||||
void dumpWornItems();
|
|
||||||
void dumpInventory();
|
|
||||||
void dumpBankItems();
|
|
||||||
void dumpSharedBankItems();
|
|
||||||
|
|
||||||
void SetCustomItemData(uint32 character_id, int16 slot_id, const std::string &identifier, const std::string& value);
|
void SetCustomItemData(uint32 character_id, int16 slot_id, const std::string &identifier, const std::string& value);
|
||||||
void SetCustomItemData(uint32 character_id, int16 slot_id, const std::string &identifier, int value);
|
void SetCustomItemData(uint32 character_id, int16 slot_id, const std::string &identifier, int value);
|
||||||
void SetCustomItemData(uint32 character_id, int16 slot_id, const std::string &identifier, float value);
|
void SetCustomItemData(uint32 character_id, int16 slot_id, const std::string &identifier, float value);
|
||||||
void SetCustomItemData(uint32 character_id, int16 slot_id, const std::string &identifier, bool value);
|
void SetCustomItemData(uint32 character_id, int16 slot_id, const std::string &identifier, bool value);
|
||||||
std::string GetCustomItemData(int16 slot_id, const std::string& identifier);
|
std::string GetCustomItemData(int16 slot_id, const std::string& identifier);
|
||||||
static const int GetItemStatValue(uint32 item_id, const std::string& identifier);
|
static const int GetItemStatValue(uint32 item_id, const std::string& identifier);
|
||||||
|
|
||||||
|
std::map<int16, ItemInstance*>& GetWorn() { return m_worn; }
|
||||||
|
std::map<int16, ItemInstance*>& GetPersonal() { return m_inv; }
|
||||||
|
int16 HasEvolvingItem(uint64 evolve_unique_id, uint8 quantity, uint8 where);
|
||||||
|
|
||||||
|
inline int16 PushItem(int16 slot_id, ItemInstance* inst) { return _PutItem(slot_id, inst); }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
///////////////////////////////
|
///////////////////////////////
|
||||||
// Protected Methods
|
// Protected Methods
|
||||||
///////////////////////////////
|
///////////////////////////////
|
||||||
|
|
||||||
int GetSlotByItemInstCollection(const std::map<int16, ItemInstance*> &collection, ItemInstance *inst);
|
int GetSlotByItemInstCollection(const std::map<int16, ItemInstance*> &collection, ItemInstance *inst);
|
||||||
void dumpItemCollection(const std::map<int16, ItemInstance*> &collection);
|
|
||||||
void dumpBagContents(ItemInstance *inst, std::map<int16, ItemInstance*>::const_iterator *it);
|
|
||||||
|
|
||||||
// Retrieves item within an inventory bucket
|
// Retrieves item within an inventory bucket
|
||||||
ItemInstance* _GetItem(const std::map<int16, ItemInstance*>& bucket, int16 slot_id) const;
|
ItemInstance* _GetItem(const std::map<int16, ItemInstance*>& bucket, int16 slot_id) const;
|
||||||
@@ -233,6 +234,8 @@ namespace EQ
|
|||||||
int16 _HasItemByUse(ItemInstQueue& iqueue, uint8 use, uint8 quantity);
|
int16 _HasItemByUse(ItemInstQueue& iqueue, uint8 use, uint8 quantity);
|
||||||
int16 _HasItemByLoreGroup(std::map<int16, ItemInstance*>& bucket, uint32 loregroup);
|
int16 _HasItemByLoreGroup(std::map<int16, ItemInstance*>& bucket, uint32 loregroup);
|
||||||
int16 _HasItemByLoreGroup(ItemInstQueue& iqueue, uint32 loregroup);
|
int16 _HasItemByLoreGroup(ItemInstQueue& iqueue, uint32 loregroup);
|
||||||
|
int16 _HasEvolvingItem(std::map<int16, ItemInstance*>& bucket, uint64 evolve_unique_id, uint8 quantity);
|
||||||
|
int16 _HasEvolvingItem(ItemInstQueue& iqueue, uint64 evolve_unique_id, uint8 quantity);
|
||||||
|
|
||||||
|
|
||||||
// Player inventory
|
// Player inventory
|
||||||
|
|||||||
@@ -20,6 +20,7 @@
|
|||||||
|
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
#include <fmt/format.h>
|
#include <fmt/format.h>
|
||||||
|
#include <fmt/ranges.h>
|
||||||
#include <csignal>
|
#include <csignal>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include "ip_util.h"
|
#include "ip_util.h"
|
||||||
@@ -259,3 +260,84 @@ bool IpUtil::IsIPAddress(const std::string &ip_address)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#include <iostream>
|
||||||
|
#ifdef _WIN32
|
||||||
|
#include <winsock2.h>
|
||||||
|
#pragma comment(lib, "ws2_32.lib") // Link against Winsock library
|
||||||
|
#else
|
||||||
|
#include <sys/types.h>
|
||||||
|
#include <sys/socket.h>
|
||||||
|
#include <netinet/in.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <iostream>
|
||||||
|
#include <string>
|
||||||
|
#ifdef _WIN32
|
||||||
|
#include <winsock2.h>
|
||||||
|
#include <ws2tcpip.h> // For inet_pton
|
||||||
|
#pragma comment(lib, "ws2_32.lib") // Link against Winsock library
|
||||||
|
#else
|
||||||
|
#include <sys/types.h>
|
||||||
|
#include <sys/socket.h>
|
||||||
|
#include <netinet/in.h>
|
||||||
|
#include <arpa/inet.h> // For inet_pton
|
||||||
|
#include <unistd.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
bool IpUtil::IsPortInUse(const std::string& ip, int port) {
|
||||||
|
bool in_use = false;
|
||||||
|
|
||||||
|
#ifdef _WIN32
|
||||||
|
WSADATA wsaData;
|
||||||
|
if (WSAStartup(MAKEWORD(2, 2), &wsaData) != 0) {
|
||||||
|
std::cerr << "WSAStartup failed\n";
|
||||||
|
return true; // Assume in use on failure
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
int sock = socket(AF_INET, SOCK_STREAM, 0);
|
||||||
|
if (sock < 0) {
|
||||||
|
#ifdef _WIN32
|
||||||
|
WSACleanup();
|
||||||
|
#endif
|
||||||
|
return true; // Assume in use on failure
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef _WIN32
|
||||||
|
int opt = 1;
|
||||||
|
setsockopt(sock, SOL_SOCKET, SO_EXCLUSIVEADDRUSE, (char*)&opt, sizeof(opt)); // Windows-specific
|
||||||
|
#else
|
||||||
|
int opt = 1;
|
||||||
|
setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, &opt, sizeof(opt)); // Linux/macOS
|
||||||
|
#endif
|
||||||
|
|
||||||
|
sockaddr_in addr{};
|
||||||
|
addr.sin_family = AF_INET;
|
||||||
|
addr.sin_port = htons(port);
|
||||||
|
|
||||||
|
// Convert IP address from string to binary format
|
||||||
|
if (inet_pton(AF_INET, ip.c_str(), &addr.sin_addr) <= 0) {
|
||||||
|
std::cerr << "Invalid IP address format: " << ip << std::endl;
|
||||||
|
#ifdef _WIN32
|
||||||
|
closesocket(sock);
|
||||||
|
WSACleanup();
|
||||||
|
#else
|
||||||
|
close(sock);
|
||||||
|
#endif
|
||||||
|
return true; // Assume in use on failure
|
||||||
|
}
|
||||||
|
|
||||||
|
if (bind(sock, (struct sockaddr*)&addr, sizeof(addr)) < 0) {
|
||||||
|
in_use = true; // Bind failed, port is in use
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef _WIN32
|
||||||
|
closesocket(sock);
|
||||||
|
WSACleanup();
|
||||||
|
#else
|
||||||
|
close(sock);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
return in_use;
|
||||||
|
}
|
||||||
|
|||||||
@@ -37,6 +37,7 @@ public:
|
|||||||
int port
|
int port
|
||||||
);
|
);
|
||||||
static bool IsIPAddress(const std::string &ip_address);
|
static bool IsIPAddress(const std::string &ip_address);
|
||||||
|
static bool IsPortInUse(const std::string& ip, int port);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -55,7 +55,7 @@ namespace EQ {
|
|||||||
EQ_EXCEPT("IPC Mutex", "Could not create mutex.");
|
EQ_EXCEPT("IPC Mutex", "Could not create mutex.");
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
std::string final_name = fmt::format("{}/{}.lock", path.GetSharedMemoryPath(), name);
|
std::string final_name = fmt::format("{}/{}.lock", PathManager::Instance()->GetSharedMemoryPath(), name);
|
||||||
|
|
||||||
#ifdef __DARWIN
|
#ifdef __DARWIN
|
||||||
#if __DARWIN_C_LEVEL < 200809L
|
#if __DARWIN_C_LEVEL < 200809L
|
||||||
|
|||||||
@@ -220,6 +220,34 @@ bool EQ::ItemData::IsType1HWeapon() const
|
|||||||
return ((ItemType == item::ItemType1HBlunt) || (ItemType == item::ItemType1HSlash) || (ItemType == item::ItemType1HPiercing) || (ItemType == item::ItemTypeMartial));
|
return ((ItemType == item::ItemType1HBlunt) || (ItemType == item::ItemType1HSlash) || (ItemType == item::ItemType1HPiercing) || (ItemType == item::ItemTypeMartial));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool EQ::ItemData::IsPetUsable() const
|
||||||
|
{
|
||||||
|
if (ItemClass == item::ItemClassBag) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// if it's a misc item and has slots, it's wearable
|
||||||
|
// this item type is conflated with many other item types
|
||||||
|
if (ItemClass == item::ItemTypeMisc && Slots != 0) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
switch (ItemType) {
|
||||||
|
case item::ItemType1HBlunt:
|
||||||
|
case item::ItemType1HSlash:
|
||||||
|
case item::ItemType1HPiercing:
|
||||||
|
case item::ItemType2HBlunt:
|
||||||
|
case item::ItemType2HSlash:
|
||||||
|
case item::ItemTypeMartial:
|
||||||
|
case item::ItemTypeShield:
|
||||||
|
case item::ItemTypeArmor:
|
||||||
|
case item::ItemTypeJewelry:
|
||||||
|
return true;
|
||||||
|
default:
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
bool EQ::ItemData::IsType2HWeapon() const
|
bool EQ::ItemData::IsType2HWeapon() const
|
||||||
{
|
{
|
||||||
return ((ItemType == item::ItemType2HBlunt) || (ItemType == item::ItemType2HSlash) || (ItemType == item::ItemType2HPiercing));
|
return ((ItemType == item::ItemType2HBlunt) || (ItemType == item::ItemType2HSlash) || (ItemType == item::ItemType2HPiercing));
|
||||||
|
|||||||
+2
-1
@@ -438,7 +438,7 @@ namespace EQ
|
|||||||
//uint32 Unk054 {};
|
//uint32 Unk054 {};
|
||||||
int16 MaxCharges {}; // Maximum charges items can hold: -1 if not a chargeable item
|
int16 MaxCharges {}; // Maximum charges items can hold: -1 if not a chargeable item
|
||||||
uint8 ItemType {}; // Item Type/Skill (itemClass* from above)
|
uint8 ItemType {}; // Item Type/Skill (itemClass* from above)
|
||||||
int32 SubType {}; // Some items have sub types that can be used for other things (unbreakable fishing poles, SE_FFItemClass)
|
int32 SubType {}; // Some items have sub types that can be used for other things (unbreakable fishing poles, SpellEffect::FFItemClass)
|
||||||
uint8 Material {}; // Item material type
|
uint8 Material {}; // Item material type
|
||||||
uint32 HerosForgeModel {};// Hero's Forge Armor Model Type (2-13?)
|
uint32 HerosForgeModel {};// Hero's Forge Armor Model Type (2-13?)
|
||||||
float SellRate {}; // Sell rate
|
float SellRate {}; // Sell rate
|
||||||
@@ -550,6 +550,7 @@ namespace EQ
|
|||||||
bool IsType1HWeapon() const;
|
bool IsType1HWeapon() const;
|
||||||
bool IsType2HWeapon() const;
|
bool IsType2HWeapon() const;
|
||||||
bool IsTypeShield() const;
|
bool IsTypeShield() const;
|
||||||
|
bool IsPetUsable() const;
|
||||||
bool IsQuestItem() const;
|
bool IsQuestItem() const;
|
||||||
|
|
||||||
static bool CheckLoreConflict(const ItemData* l_item, const ItemData* r_item);
|
static bool CheckLoreConflict(const ItemData* l_item, const ItemData* r_item);
|
||||||
|
|||||||
@@ -1,206 +0,0 @@
|
|||||||
/*
|
|
||||||
|
|
||||||
|
|
||||||
These fields must be in the order of how they are serialized!
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
*/
|
|
||||||
|
|
||||||
F(itemclass)
|
|
||||||
F(name)
|
|
||||||
F(lore)
|
|
||||||
F(idfile)
|
|
||||||
F(id)
|
|
||||||
F(weight)
|
|
||||||
F(norent)
|
|
||||||
F(nodrop)
|
|
||||||
F(size)
|
|
||||||
F(slots)
|
|
||||||
F(price)
|
|
||||||
F(icon)
|
|
||||||
F(UNK012)
|
|
||||||
F(UNK013)
|
|
||||||
F(benefitflag)
|
|
||||||
F(tradeskills)
|
|
||||||
F(cr)
|
|
||||||
F(dr)
|
|
||||||
F(pr)
|
|
||||||
F(mr)
|
|
||||||
F(fr)
|
|
||||||
F(astr)
|
|
||||||
F(asta)
|
|
||||||
F(aagi)
|
|
||||||
F(adex)
|
|
||||||
F(acha)
|
|
||||||
F(aint)
|
|
||||||
F(awis)
|
|
||||||
F(hp)
|
|
||||||
F(mana)
|
|
||||||
F(ac)
|
|
||||||
F(deity)
|
|
||||||
F(skillmodvalue)
|
|
||||||
F(UNK033)
|
|
||||||
F(skillmodmax)
|
|
||||||
F(skillmodtype)
|
|
||||||
F(banedmgrace)
|
|
||||||
F(banedmgamt)
|
|
||||||
F(banedmgbody)
|
|
||||||
F(magic)
|
|
||||||
F(casttime_)
|
|
||||||
F(reqlevel)
|
|
||||||
F(bardtype)
|
|
||||||
F(bardvalue)
|
|
||||||
F(light)
|
|
||||||
F(delay)
|
|
||||||
F(reclevel)
|
|
||||||
F(recskill)
|
|
||||||
F(elemdmgtype)
|
|
||||||
F(elemdmgamt)
|
|
||||||
F(range)
|
|
||||||
F(damage)
|
|
||||||
F(color)
|
|
||||||
F(classes)
|
|
||||||
F(races)
|
|
||||||
F(UNK054)
|
|
||||||
F(maxcharges)
|
|
||||||
F(itemtype)
|
|
||||||
F(material)
|
|
||||||
F(herosforgemodel)
|
|
||||||
F(sellrate)
|
|
||||||
F(UNK059)
|
|
||||||
F(casttime)
|
|
||||||
F(elitematerial)
|
|
||||||
F(procrate)
|
|
||||||
F(combateffects)
|
|
||||||
F(shielding)
|
|
||||||
F(stunresist)
|
|
||||||
F(strikethrough)
|
|
||||||
F(extradmgskill)
|
|
||||||
F(extradmgamt)
|
|
||||||
F(spellshield)
|
|
||||||
F(avoidance)
|
|
||||||
F(accuracy)
|
|
||||||
F(charmfileid)
|
|
||||||
F(factionmod1)
|
|
||||||
F(factionmod2)
|
|
||||||
F(factionmod3)
|
|
||||||
F(factionmod4)
|
|
||||||
F(factionamt1)
|
|
||||||
F(factionamt2)
|
|
||||||
F(factionamt3)
|
|
||||||
F(factionamt4)
|
|
||||||
F(charmfile)
|
|
||||||
F(augtype)
|
|
||||||
F(augslot1type)
|
|
||||||
F(augslot1visible)
|
|
||||||
F(augslot2type)
|
|
||||||
F(augslot2visible)
|
|
||||||
F(augslot3type)
|
|
||||||
F(augslot3visible)
|
|
||||||
F(augslot4type)
|
|
||||||
F(augslot4visible)
|
|
||||||
F(augslot5type)
|
|
||||||
F(augslot5visible)
|
|
||||||
F(augslot6type)
|
|
||||||
F(augslot6visible)
|
|
||||||
F(ldontheme)
|
|
||||||
F(ldonprice)
|
|
||||||
F(ldonsold)
|
|
||||||
F(bagtype)
|
|
||||||
F(bagslots)
|
|
||||||
F(bagsize)
|
|
||||||
F(bagwr)
|
|
||||||
F(book)
|
|
||||||
F(booktype)
|
|
||||||
F(filename)
|
|
||||||
F(banedmgraceamt)
|
|
||||||
F(augrestrict)
|
|
||||||
F(loregroup)
|
|
||||||
F(pendingloreflag)
|
|
||||||
F(artifactflag)
|
|
||||||
F(summonedflag)
|
|
||||||
F(favor)
|
|
||||||
F(fvnodrop)
|
|
||||||
F(endur)
|
|
||||||
F(dotshielding)
|
|
||||||
F(attack)
|
|
||||||
F(regen)
|
|
||||||
F(manaregen)
|
|
||||||
F(enduranceregen)
|
|
||||||
F(haste)
|
|
||||||
F(damageshield)
|
|
||||||
F(recastdelay)
|
|
||||||
F(recasttype)
|
|
||||||
F(guildfavor)
|
|
||||||
F(augdistiller)
|
|
||||||
F(UNK123)
|
|
||||||
F(UNK124)
|
|
||||||
F(attuneable)
|
|
||||||
F(nopet)
|
|
||||||
F(UNK127)
|
|
||||||
F(pointtype)
|
|
||||||
F(potionbelt)
|
|
||||||
F(potionbeltslots)
|
|
||||||
F(stacksize)
|
|
||||||
F(notransfer)
|
|
||||||
F(stackable)
|
|
||||||
F(UNK134)
|
|
||||||
F(clickeffect)
|
|
||||||
F(clicktype)
|
|
||||||
F(clicklevel)
|
|
||||||
F(clicklevel2)
|
|
||||||
F(proceffect)
|
|
||||||
F(proctype)
|
|
||||||
F(proclevel)
|
|
||||||
F(proclevel2)
|
|
||||||
F(worneffect)
|
|
||||||
F(worntype)
|
|
||||||
F(wornlevel)
|
|
||||||
F(wornlevel2)
|
|
||||||
F(focuseffect)
|
|
||||||
F(focustype)
|
|
||||||
F(focuslevel)
|
|
||||||
F(focuslevel2)
|
|
||||||
F(scrolleffect)
|
|
||||||
F(scrolltype)
|
|
||||||
F(scrolllevel)
|
|
||||||
F(scrolllevel2)
|
|
||||||
F(bardeffect)
|
|
||||||
F(bardeffecttype)
|
|
||||||
F(bardlevel2)
|
|
||||||
F(bardlevel)
|
|
||||||
F(questitemflag)
|
|
||||||
F(svcorruption)
|
|
||||||
F(purity)
|
|
||||||
F(evoitem)
|
|
||||||
F(evoid)
|
|
||||||
F(evolvinglevel)
|
|
||||||
F(evomax)
|
|
||||||
F(backstabdmg)
|
|
||||||
F(dsmitigation)
|
|
||||||
F(heroic_str)
|
|
||||||
F(heroic_int)
|
|
||||||
F(heroic_wis)
|
|
||||||
F(heroic_agi)
|
|
||||||
F(heroic_dex)
|
|
||||||
F(heroic_sta)
|
|
||||||
F(heroic_cha)
|
|
||||||
F(heroic_mr)
|
|
||||||
F(heroic_fr)
|
|
||||||
F(heroic_cr)
|
|
||||||
F(heroic_dr)
|
|
||||||
F(heroic_pr)
|
|
||||||
F(heroic_svcorrup)
|
|
||||||
F(healamt)
|
|
||||||
F(spelldmg)
|
|
||||||
F(ldonsellbackrate)
|
|
||||||
F(scriptfileid)
|
|
||||||
F(expendablearrow)
|
|
||||||
F(clairvoyance)
|
|
||||||
F(clickname)
|
|
||||||
F(procname)
|
|
||||||
F(wornname)
|
|
||||||
F(focusname)
|
|
||||||
F(scrollname)
|
|
||||||
F(subtype)
|
|
||||||
+85
-60
@@ -25,6 +25,7 @@
|
|||||||
#include "rulesys.h"
|
#include "rulesys.h"
|
||||||
#include "shareddb.h"
|
#include "shareddb.h"
|
||||||
#include "strings.h"
|
#include "strings.h"
|
||||||
|
#include "evolving_items.h"
|
||||||
|
|
||||||
//#include "../common/light_source.h"
|
//#include "../common/light_source.h"
|
||||||
|
|
||||||
@@ -76,6 +77,10 @@ EQ::ItemInstance::ItemInstance(const ItemData* item, int16 charges) {
|
|||||||
m_color = m_item->Color;
|
m_color = m_item->Color;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (IsEvolving()) {
|
||||||
|
SetTimer("evolve", RuleI(EvolvingItems, DelayUponEquipping));
|
||||||
|
}
|
||||||
|
|
||||||
m_SerialNumber = GetNextItemInstSerialNumber();
|
m_SerialNumber = GetNextItemInstSerialNumber();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -95,6 +100,10 @@ EQ::ItemInstance::ItemInstance(SharedDatabase *db, uint32 item_id, int16 charges
|
|||||||
m_color = 0;
|
m_color = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (IsEvolving()) {
|
||||||
|
SetTimer("evolve", RuleI(EvolvingItems, DelayUponEquipping));
|
||||||
|
}
|
||||||
|
|
||||||
m_SerialNumber = GetNextItemInstSerialNumber();
|
m_SerialNumber = GetNextItemInstSerialNumber();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -146,7 +155,6 @@ EQ::ItemInstance::ItemInstance(const ItemInstance& copy)
|
|||||||
|
|
||||||
m_exp = copy.m_exp;
|
m_exp = copy.m_exp;
|
||||||
m_evolveLvl = copy.m_evolveLvl;
|
m_evolveLvl = copy.m_evolveLvl;
|
||||||
m_activated = copy.m_activated;
|
|
||||||
|
|
||||||
if (copy.m_scaledItem) {
|
if (copy.m_scaledItem) {
|
||||||
m_scaledItem = new ItemData(*copy.m_scaledItem);
|
m_scaledItem = new ItemData(*copy.m_scaledItem);
|
||||||
@@ -154,12 +162,7 @@ EQ::ItemInstance::ItemInstance(const ItemInstance& copy)
|
|||||||
m_scaledItem = nullptr;
|
m_scaledItem = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (copy.m_evolveInfo) {
|
m_evolving_details = copy.m_evolving_details;
|
||||||
m_evolveInfo = new EvolveInfo(*copy.m_evolveInfo);
|
|
||||||
} else {
|
|
||||||
m_evolveInfo = nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
m_scaling = copy.m_scaling;
|
m_scaling = copy.m_scaling;
|
||||||
m_ornamenticon = copy.m_ornamenticon;
|
m_ornamenticon = copy.m_ornamenticon;
|
||||||
m_ornamentidfile = copy.m_ornamentidfile;
|
m_ornamentidfile = copy.m_ornamentidfile;
|
||||||
@@ -174,7 +177,6 @@ EQ::ItemInstance::~ItemInstance()
|
|||||||
Clear();
|
Clear();
|
||||||
safe_delete(m_item);
|
safe_delete(m_item);
|
||||||
safe_delete(m_scaledItem);
|
safe_delete(m_scaledItem);
|
||||||
safe_delete(m_evolveInfo);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Query item type
|
// Query item type
|
||||||
@@ -572,7 +574,7 @@ EQ::ItemInstance* EQ::ItemInstance::GetOrnamentationAugment() const
|
|||||||
uint32 EQ::ItemInstance::GetOrnamentHeroModel(int32 material_slot) const
|
uint32 EQ::ItemInstance::GetOrnamentHeroModel(int32 material_slot) const
|
||||||
{
|
{
|
||||||
// Not a Hero Forge item.
|
// Not a Hero Forge item.
|
||||||
if (m_ornament_hero_model == 0 || material_slot < 0) {
|
if (m_ornament_hero_model == 0) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -904,26 +906,34 @@ bool EQ::ItemInstance::IsSlotAllowed(int16 slot_id) const {
|
|||||||
|
|
||||||
bool EQ::ItemInstance::IsDroppable(bool recurse) const
|
bool EQ::ItemInstance::IsDroppable(bool recurse) const
|
||||||
{
|
{
|
||||||
if (!m_item)
|
if (!m_item) {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
/*if (m_ornamentidfile) // not implemented
|
/*if (m_ornamentidfile) // not implemented
|
||||||
return false;*/
|
return false;*/
|
||||||
if (m_attuned)
|
if (m_attuned) {
|
||||||
return false;
|
return false;
|
||||||
/*if (m_item->FVNoDrop != 0) // not implemented
|
}
|
||||||
return false;*/
|
|
||||||
if (m_item->NoDrop == 0)
|
if (RuleI(World, FVNoDropFlag) == FVNoDropFlagRule::Enabled && m_item->FVNoDrop == 0) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (m_item->NoDrop == 0) {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
if (recurse) {
|
if (recurse) {
|
||||||
for (auto iter : m_contents) {
|
for (auto iter: m_contents) {
|
||||||
if (!iter.second)
|
if (!iter.second) {
|
||||||
continue;
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
if (!iter.second->IsDroppable(recurse))
|
if (!iter.second->IsDroppable(recurse)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -1030,29 +1040,6 @@ void EQ::ItemInstance::ScaleItem() {
|
|||||||
m_scaledItem->CharmFileID = 0; // this stops the client from trying to scale the item itself.
|
m_scaledItem->CharmFileID = 0; // this stops the client from trying to scale the item itself.
|
||||||
}
|
}
|
||||||
|
|
||||||
bool EQ::ItemInstance::EvolveOnAllKills() const {
|
|
||||||
return (m_evolveInfo && m_evolveInfo->AllKills);
|
|
||||||
}
|
|
||||||
|
|
||||||
int8 EQ::ItemInstance::GetMaxEvolveLvl() const {
|
|
||||||
if (m_evolveInfo)
|
|
||||||
return m_evolveInfo->MaxLvl;
|
|
||||||
else
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
uint32 EQ::ItemInstance::GetKillsNeeded(uint8 currentlevel) {
|
|
||||||
uint32 kills = -1; // default to -1 (max uint32 value) because this value is usually divided by, so we don't want to ever return zero.
|
|
||||||
if (m_evolveInfo)
|
|
||||||
if (currentlevel != m_evolveInfo->MaxLvl)
|
|
||||||
kills = m_evolveInfo->LvlKills[currentlevel - 1];
|
|
||||||
|
|
||||||
if (kills == 0)
|
|
||||||
kills = -1;
|
|
||||||
|
|
||||||
return kills;
|
|
||||||
}
|
|
||||||
|
|
||||||
void EQ::ItemInstance::SetTimer(std::string name, uint32 time) {
|
void EQ::ItemInstance::SetTimer(std::string name, uint32 time) {
|
||||||
Timer t(time);
|
Timer t(time);
|
||||||
t.Start(time, false);
|
t.Start(time, false);
|
||||||
@@ -1806,6 +1793,18 @@ std::vector<uint32> EQ::ItemInstance::GetAugmentIDs() const
|
|||||||
return augments;
|
return augments;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::vector<std::string> EQ::ItemInstance::GetAugmentNames() const
|
||||||
|
{
|
||||||
|
std::vector<std::string> augment_names;
|
||||||
|
|
||||||
|
for (uint8 slot_id = invaug::SOCKET_BEGIN; slot_id <= invaug::SOCKET_END; slot_id++) {
|
||||||
|
const auto augment = GetAugment(slot_id);
|
||||||
|
augment_names.push_back(augment ? augment->GetItem()->Name : "");
|
||||||
|
}
|
||||||
|
|
||||||
|
return augment_names;
|
||||||
|
}
|
||||||
|
|
||||||
int EQ::ItemInstance::GetItemRegen(bool augments) const
|
int EQ::ItemInstance::GetItemRegen(bool augments) const
|
||||||
{
|
{
|
||||||
int stat = 0;
|
int stat = 0;
|
||||||
@@ -1951,28 +1950,54 @@ void EQ::ItemInstance::ClearGUIDMap()
|
|||||||
{
|
{
|
||||||
guids.clear();
|
guids.clear();
|
||||||
}
|
}
|
||||||
//
|
|
||||||
// class EvolveInfo
|
bool EQ::ItemInstance::TransferOwnership(Database &db, const uint32 to_char_id) const
|
||||||
//
|
{
|
||||||
EvolveInfo::EvolveInfo() {
|
if (!to_char_id || !IsEvolving()) {
|
||||||
// nothing here yet
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
SetEvolveCharID(to_char_id);
|
||||||
|
CharacterEvolvingItemsRepository::UpdateCharID(db, GetEvolveUniqueID(), to_char_id);
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
EvolveInfo::EvolveInfo(uint32 first, uint8 max, bool allkills, uint32 L2, uint32 L3, uint32 L4, uint32 L5, uint32 L6, uint32 L7, uint32 L8, uint32 L9, uint32 L10) {
|
uint32 EQ::ItemInstance::GetAugmentEvolveUniqueID(uint8 augment_index) const
|
||||||
FirstItem = first;
|
{
|
||||||
MaxLvl = max;
|
if (!m_item || !m_item->IsClassCommon()) {
|
||||||
AllKills = allkills;
|
return 0;
|
||||||
LvlKills[0] = L2;
|
}
|
||||||
LvlKills[1] = L3;
|
|
||||||
LvlKills[2] = L4;
|
const auto item = GetItem(augment_index);
|
||||||
LvlKills[3] = L5;
|
if (item) {
|
||||||
LvlKills[4] = L6;
|
return item->GetEvolveUniqueID();
|
||||||
LvlKills[5] = L7;
|
}
|
||||||
LvlKills[6] = L8;
|
|
||||||
LvlKills[7] = L9;
|
return 0;
|
||||||
LvlKills[8] = L10;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
EvolveInfo::~EvolveInfo() {
|
void EQ::ItemInstance::SetTimer(std::string name, uint32 time) const{
|
||||||
|
Timer t(time);
|
||||||
|
t.Start(time, false);
|
||||||
|
m_timers[name] = t;
|
||||||
|
}
|
||||||
|
|
||||||
|
void EQ::ItemInstance::SetEvolveEquipped(const bool in) const
|
||||||
|
{
|
||||||
|
if (!IsEvolving()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
m_evolving_details.equipped = in;
|
||||||
|
if (in && !GetTimers().contains("evolve")) {
|
||||||
|
SetTimer("evolve", RuleI(EvolvingItems, DelayUponEquipping));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (in) {
|
||||||
|
GetTimers().at("evolve").SetTimer(RuleI(EvolvingItems, DelayUponEquipping));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
GetTimers().at("evolve").Disable();
|
||||||
}
|
}
|
||||||
|
|||||||
+55
-46
@@ -23,6 +23,7 @@
|
|||||||
|
|
||||||
#ifndef COMMON_ITEM_INSTANCE_H
|
#ifndef COMMON_ITEM_INSTANCE_H
|
||||||
#define COMMON_ITEM_INSTANCE_H
|
#define COMMON_ITEM_INSTANCE_H
|
||||||
|
#include "evolving_items.h"
|
||||||
|
|
||||||
|
|
||||||
class ItemParse; // Parses item packets
|
class ItemParse; // Parses item packets
|
||||||
@@ -34,6 +35,7 @@ class EvolveInfo; // Stores information about an evolving item family
|
|||||||
#include "../common/bodytypes.h"
|
#include "../common/bodytypes.h"
|
||||||
#include "../common/deity.h"
|
#include "../common/deity.h"
|
||||||
#include "../common/memory_buffer.h"
|
#include "../common/memory_buffer.h"
|
||||||
|
#include "../common/repositories/character_evolving_items_repository.h"
|
||||||
|
|
||||||
#include <map>
|
#include <map>
|
||||||
|
|
||||||
@@ -205,13 +207,9 @@ namespace EQ
|
|||||||
bool IsDroppable(bool recurse = true) const;
|
bool IsDroppable(bool recurse = true) const;
|
||||||
|
|
||||||
bool IsScaling() const { return m_scaling; }
|
bool IsScaling() const { return m_scaling; }
|
||||||
bool IsEvolving() const { return (m_evolveLvl >= 1); }
|
|
||||||
uint32 GetExp() const { return m_exp; }
|
uint32 GetExp() const { return m_exp; }
|
||||||
void SetExp(uint32 exp) { m_exp = exp; }
|
void SetExp(uint32 exp) { m_exp = exp; }
|
||||||
void AddExp(uint32 exp) { m_exp += exp; }
|
void AddExp(uint32 exp) { m_exp += exp; }
|
||||||
bool IsActivated() { return m_activated; }
|
|
||||||
void SetActivated(bool activated) { m_activated = activated; }
|
|
||||||
int8 GetEvolveLvl() const { return m_evolveLvl; }
|
|
||||||
void SetScaling(bool v) { m_scaling = v; }
|
void SetScaling(bool v) { m_scaling = v; }
|
||||||
uint32 GetOrnamentationIcon() const { return m_ornamenticon; }
|
uint32 GetOrnamentationIcon() const { return m_ornamenticon; }
|
||||||
void SetOrnamentIcon(uint32 ornament_icon) { m_ornamenticon = ornament_icon; }
|
void SetOrnamentIcon(uint32 ornament_icon) { m_ornamenticon = ornament_icon; }
|
||||||
@@ -226,9 +224,6 @@ namespace EQ
|
|||||||
|
|
||||||
void Initialize(SharedDatabase *db = nullptr);
|
void Initialize(SharedDatabase *db = nullptr);
|
||||||
void ScaleItem();
|
void ScaleItem();
|
||||||
bool EvolveOnAllKills() const;
|
|
||||||
int8 GetMaxEvolveLvl() const;
|
|
||||||
uint32 GetKillsNeeded(uint8 currentlevel);
|
|
||||||
|
|
||||||
std::string Serialize(int16 slot_id) const { InternalSerializedItem_Struct s; s.slot_id = slot_id; s.inst = (const void*)this; std::string ser; ser.assign((char*)&s, sizeof(InternalSerializedItem_Struct)); return ser; }
|
std::string Serialize(int16 slot_id) const { InternalSerializedItem_Struct s; s.slot_id = slot_id; s.inst = (const void*)this; std::string ser; ser.assign((char*)&s, sizeof(InternalSerializedItem_Struct)); return ser; }
|
||||||
void Serialize(OutBuffer& ob, int16 slot_id) const { InternalSerializedItem_Struct isi; isi.slot_id = slot_id; isi.inst = (const void*)this; ob.write((const char*)&isi, sizeof(isi)); }
|
void Serialize(OutBuffer& ob, int16 slot_id) const { InternalSerializedItem_Struct isi; isi.slot_id = slot_id; isi.inst = (const void*)this; ob.write((const char*)&isi, sizeof(isi)); }
|
||||||
@@ -236,8 +231,9 @@ namespace EQ
|
|||||||
inline int32 GetSerialNumber() const { return m_SerialNumber; }
|
inline int32 GetSerialNumber() const { return m_SerialNumber; }
|
||||||
inline void SetSerialNumber(int32 id) { m_SerialNumber = id; }
|
inline void SetSerialNumber(int32 id) { m_SerialNumber = id; }
|
||||||
|
|
||||||
std::map<std::string, ::Timer>& GetTimers() { return m_timers; }
|
std::map<std::string, ::Timer>& GetTimers() const { return m_timers; }
|
||||||
void SetTimer(std::string name, uint32 time);
|
void SetTimer(std::string name, uint32 time);
|
||||||
|
void SetTimer(std::string name, uint32 time) const;
|
||||||
void StopTimer(std::string name);
|
void StopTimer(std::string name);
|
||||||
void ClearTimers();
|
void ClearTimers();
|
||||||
|
|
||||||
@@ -309,9 +305,38 @@ namespace EQ
|
|||||||
int GetItemSkillsStat(EQ::skills::SkillType skill, bool augments = false) const;
|
int GetItemSkillsStat(EQ::skills::SkillType skill, bool augments = false) const;
|
||||||
uint32 GetItemGuildFavor() const;
|
uint32 GetItemGuildFavor() const;
|
||||||
std::vector<uint32> GetAugmentIDs() const;
|
std::vector<uint32> GetAugmentIDs() const;
|
||||||
|
std::vector<std::string> GetAugmentNames() const;
|
||||||
static void AddGUIDToMap(uint64 existing_serial_number);
|
static void AddGUIDToMap(uint64 existing_serial_number);
|
||||||
static void ClearGUIDMap();
|
static void ClearGUIDMap();
|
||||||
|
|
||||||
|
// evolving items stuff
|
||||||
|
CharacterEvolvingItemsRepository::CharacterEvolvingItems &GetEvolvingDetails() const { return m_evolving_details; }
|
||||||
|
|
||||||
|
int8 GetEvolveLvl() const { if (GetItem()) { return GetItem()->EvolvingLevel; } return false; }
|
||||||
|
bool IsEvolving() const { if (GetItem()) { return GetItem()->EvolvingItem; } return false; }
|
||||||
|
int8 GetMaxEvolveLvl() const { if (GetItem()) { return GetItem()->EvolvingMax; } return false; }
|
||||||
|
bool GetEvolveActivated() const { return m_evolving_details.activated ? true : false; }
|
||||||
|
bool GetEvolveEquipped() const { return m_evolving_details.equipped ? true : false; }
|
||||||
|
double GetEvolveProgression() const { return m_evolving_details.progression; }
|
||||||
|
uint64 GetEvolveUniqueID() const { return m_evolving_details.id; }
|
||||||
|
uint32 GetEvolveCharID() const { return m_evolving_details.character_id; }
|
||||||
|
uint32 GetEvolveItemID() const { return m_evolving_details.item_id; }
|
||||||
|
uint32 GetEvolveLoreID() const { if (GetItem()) { return GetItem()->EvolvingID; } return false; }
|
||||||
|
uint64 GetEvolveCurrentAmount() const { return m_evolving_details.current_amount; }
|
||||||
|
uint32 GetEvolveFinalItemID() const { return m_evolving_details.final_item_id; }
|
||||||
|
uint32 GetAugmentEvolveUniqueID(uint8 augment_index) const;
|
||||||
|
void SetEvolveEquipped(const bool in) const;
|
||||||
|
void SetEvolveActivated(const bool in) const { m_evolving_details.activated = in; }
|
||||||
|
void SetEvolveProgression(const double in) const { m_evolving_details.progression = in; }
|
||||||
|
void SetEvolveUniqueID(const uint64 in) const { m_evolving_details.id = in; }
|
||||||
|
void SetEvolveCharID(const uint32 in) const { m_evolving_details.character_id = in; }
|
||||||
|
void SetEvolveItemID(const uint32 in) const { m_evolving_details.item_id = in; }
|
||||||
|
void SetEvolveCurrentAmount(const uint64 in) const { m_evolving_details.current_amount = in; }
|
||||||
|
void SetEvolveAddToCurrentAmount(const uint64 in) const { m_evolving_details.current_amount += in; }
|
||||||
|
void SetEvolveFinalItemID(const uint32 in) const { m_evolving_details.final_item_id = in; }
|
||||||
|
bool TransferOwnership(Database& db, const uint32 to_char_id) const;
|
||||||
|
void CalculateEvolveProgression() const { m_evolving_details.progression = EvolvingItemsManager::Instance()->CalculateProgression(GetEvolveCurrentAmount(), GetID()); }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
//////////////////////////
|
//////////////////////////
|
||||||
// Protected Members
|
// Protected Members
|
||||||
@@ -323,48 +348,32 @@ namespace EQ
|
|||||||
|
|
||||||
void _PutItem(uint8 index, ItemInstance* inst) { m_contents[index] = inst; }
|
void _PutItem(uint8 index, ItemInstance* inst) { m_contents[index] = inst; }
|
||||||
|
|
||||||
ItemInstTypes m_use_type {ItemInstNormal}; // Usage type for item
|
ItemInstTypes m_use_type{ItemInstNormal};// Usage type for item
|
||||||
const ItemData* m_item {nullptr}; // Ptr to item data
|
const ItemData * m_item{nullptr}; // Ptr to item data
|
||||||
int16 m_charges {0}; // # of charges for chargeable items
|
int16 m_charges{0}; // # of charges for chargeable items
|
||||||
uint32 m_price {0}; // Bazaar /trader price
|
uint32 m_price{0}; // Bazaar /trader price
|
||||||
uint32 m_color {0};
|
uint32 m_color{0};
|
||||||
uint32 m_merchantslot {0};
|
uint32 m_merchantslot{0};
|
||||||
int16 m_currentslot {0};
|
int16 m_currentslot{0};
|
||||||
bool m_attuned {false};
|
bool m_attuned{false};
|
||||||
int32 m_merchantcount {1}; //number avaliable on the merchant, -1=unlimited
|
int32 m_merchantcount{1};//number avaliable on the merchant, -1=unlimited
|
||||||
int32 m_SerialNumber {0}; // Unique identifier for this instance of an item. Needed for Bazaar.
|
int32 m_SerialNumber{0}; // Unique identifier for this instance of an item. Needed for Bazaar.
|
||||||
uint32 m_exp {0};
|
uint32 m_exp{0};
|
||||||
int8 m_evolveLvl {0};
|
int8 m_evolveLvl{0};
|
||||||
bool m_activated {false};
|
ItemData * m_scaledItem{nullptr};
|
||||||
ItemData* m_scaledItem {nullptr};
|
bool m_scaling{false};
|
||||||
::EvolveInfo* m_evolveInfo {nullptr};
|
uint32 m_ornamenticon{0};
|
||||||
bool m_scaling {false};
|
uint32 m_ornamentidfile{0};
|
||||||
uint32 m_ornamenticon {0};
|
uint32 m_new_id_file{0};
|
||||||
uint32 m_ornamentidfile {0};
|
uint32 m_ornament_hero_model{0};
|
||||||
uint32 m_new_id_file {0};
|
uint32 m_recast_timestamp{0};
|
||||||
uint32 m_ornament_hero_model {0};
|
int m_task_delivered_count{0};
|
||||||
uint32 m_recast_timestamp {0};
|
mutable CharacterEvolvingItemsRepository::CharacterEvolvingItems m_evolving_details{};
|
||||||
int m_task_delivered_count {0};
|
|
||||||
|
|
||||||
// Items inside of this item (augs or contents) {};
|
// Items inside of this item (augs or contents) {};
|
||||||
std::map<uint8, ItemInstance*> m_contents {}; // Zero-based index: min=0, max=9
|
std::map<uint8, ItemInstance*> m_contents {}; // Zero-based index: min=0, max=9
|
||||||
std::map<std::string, std::string> m_custom_data {};
|
std::map<std::string, std::string> m_custom_data {};
|
||||||
std::map<std::string, ::Timer> m_timers {};
|
mutable std::map<std::string, ::Timer> m_timers {};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
class EvolveInfo {
|
|
||||||
public:
|
|
||||||
friend class EQ::ItemInstance;
|
|
||||||
//temporary
|
|
||||||
uint16 LvlKills[9];
|
|
||||||
uint32 FirstItem;
|
|
||||||
uint8 MaxLvl;
|
|
||||||
bool AllKills;
|
|
||||||
|
|
||||||
EvolveInfo();
|
|
||||||
EvolveInfo(uint32 first, uint8 max, bool allkills, uint32 L2, uint32 L3, uint32 L4, uint32 L5, uint32 L6, uint32 L7, uint32 L8, uint32 L9, uint32 L10);
|
|
||||||
~EvolveInfo();
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif /*COMMON_ITEM_INSTANCE_H*/
|
#endif /*COMMON_ITEM_INSTANCE_H*/
|
||||||
|
|||||||
@@ -25,6 +25,7 @@ struct LootItem {
|
|||||||
uint16 trivial_max_level;
|
uint16 trivial_max_level;
|
||||||
uint16 npc_min_level;
|
uint16 npc_min_level;
|
||||||
uint16 npc_max_level;
|
uint16 npc_max_level;
|
||||||
|
uint32 lootdrop_id; // required for zone state referencing
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef std::list<LootItem*> LootItems;
|
typedef std::list<LootItem*> LootItems;
|
||||||
|
|||||||
@@ -0,0 +1,220 @@
|
|||||||
|
#ifndef EQEMU_KSM_HPP
|
||||||
|
#define EQEMU_KSM_HPP
|
||||||
|
|
||||||
|
#include "../eqemu_logsys.h"
|
||||||
|
#include <iostream>
|
||||||
|
#include <vector>
|
||||||
|
#include <cstring>
|
||||||
|
#ifdef _WIN32
|
||||||
|
#include <malloc.h> // For _aligned_malloc, _aligned_free
|
||||||
|
#include <windows.h>
|
||||||
|
#else
|
||||||
|
#include <sys/mman.h> // For madvise
|
||||||
|
#include <unistd.h> // For sysconf, sbrk
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
// Page-aligned allocator for std::vector
|
||||||
|
template <typename T>
|
||||||
|
class PageAlignedAllocator {
|
||||||
|
public:
|
||||||
|
using value_type = T;
|
||||||
|
|
||||||
|
PageAlignedAllocator() noexcept = default;
|
||||||
|
template <typename U>
|
||||||
|
PageAlignedAllocator(const PageAlignedAllocator<U>&) noexcept {}
|
||||||
|
|
||||||
|
T* allocate(std::size_t n) {
|
||||||
|
void* ptr = nullptr;
|
||||||
|
size_t size = n * sizeof(T);
|
||||||
|
|
||||||
|
#ifdef _WIN32
|
||||||
|
// Simply allocate memory without alignment
|
||||||
|
ptr = malloc(size);
|
||||||
|
if (!ptr) throw std::bad_alloc();
|
||||||
|
#else
|
||||||
|
size_t alignment = getPageSize(); // Get the system's page size
|
||||||
|
if (posix_memalign(&ptr, alignment, size) != 0) {
|
||||||
|
throw std::bad_alloc();
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
return static_cast<T*>(ptr);
|
||||||
|
}
|
||||||
|
|
||||||
|
void deallocate(T* p, std::size_t) noexcept {
|
||||||
|
free(p);
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
size_t getPageSize() const
|
||||||
|
{
|
||||||
|
#ifdef _WIN32
|
||||||
|
SYSTEM_INFO sysInfo;
|
||||||
|
GetSystemInfo(&sysInfo);
|
||||||
|
return sysInfo.dwPageSize; // Page size in bytes
|
||||||
|
#else
|
||||||
|
return static_cast<size_t>(sysconf(_SC_PAGESIZE));
|
||||||
|
#endif
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
template <typename T, typename U>
|
||||||
|
bool operator==(const PageAlignedAllocator<T>&, const PageAlignedAllocator<U>&) noexcept {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename T, typename U>
|
||||||
|
bool operator!=(const PageAlignedAllocator<T>&, const PageAlignedAllocator<U>&) noexcept {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Kernel Samepage Merging (KSM) functionality
|
||||||
|
namespace KSM {
|
||||||
|
|
||||||
|
#ifdef _WIN32
|
||||||
|
// Windows-specific placeholder functions (no-op)
|
||||||
|
inline void CheckPageAlignment(void* ptr) {
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void* AllocatePageAligned(size_t size) {
|
||||||
|
return memset(malloc(size), 0, size);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void MarkMemoryForKSM(void* start, size_t size) {
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void AlignHeapToPageBoundary() {
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void* MarkHeapStart() {
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline size_t MeasureHeapUsage(void* start) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
// Linux-specific functionality
|
||||||
|
inline void CheckPageAlignment(void* ptr) {
|
||||||
|
size_t page_size = sysconf(_SC_PAGESIZE);
|
||||||
|
if (reinterpret_cast<uintptr_t>(ptr) % page_size == 0) {
|
||||||
|
LogKSMDetail("Memory is page-aligned [{}]", ptr);
|
||||||
|
} else {
|
||||||
|
LogKSMDetail("Memory is NOT page-aligned [{}]", ptr);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void* AllocatePageAligned(size_t size) {
|
||||||
|
size_t page_size = sysconf(_SC_PAGESIZE);
|
||||||
|
void* aligned_ptr = nullptr;
|
||||||
|
if (posix_memalign(&aligned_ptr, page_size, size) != 0) {
|
||||||
|
LogKSM("Failed to allocate page-aligned memory on Linux. page_size [{}] size [{}] bytes", page_size, size);
|
||||||
|
}
|
||||||
|
std::memset(aligned_ptr, 0, size);
|
||||||
|
return aligned_ptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void MarkMemoryForKSM(void* start, size_t size) {
|
||||||
|
if (madvise(start, size, MADV_MERGEABLE) == 0) {
|
||||||
|
LogKSM("Marked memory for KSM | start [{}] size [{}] bytes", start, size);
|
||||||
|
} else {
|
||||||
|
perror("madvise failed");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void AlignHeapToPageBoundary() {
|
||||||
|
size_t page_size = sysconf(_SC_PAGESIZE);
|
||||||
|
if (page_size == 0) {
|
||||||
|
LogKSM("Failed to retrieve page size SC_PAGESIZE [{}]", page_size);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
void* current_break = sbrk(0);
|
||||||
|
if (current_break == (void*)-1) {
|
||||||
|
LogKSM("Failed to retrieve the current program break");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
uintptr_t current_address = reinterpret_cast<uintptr_t>(current_break);
|
||||||
|
size_t misalignment = current_address % page_size;
|
||||||
|
|
||||||
|
if (misalignment != 0) {
|
||||||
|
size_t adjustment = page_size - misalignment;
|
||||||
|
if (sbrk(adjustment) == (void*)-1) {
|
||||||
|
LogKSM("Failed to align heap to page boundary. adjustment [{}] bytes", adjustment);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
LogKSMDetail("Heap aligned to next page boundary. Current break [{}]", sbrk(0));
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void* MarkHeapStart() {
|
||||||
|
void* current_pos = sbrk(0);
|
||||||
|
AlignHeapToPageBoundary();
|
||||||
|
return current_pos;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline size_t MeasureHeapUsage(void* start) {
|
||||||
|
void* current_break = sbrk(0);
|
||||||
|
return static_cast<char*>(current_break) - static_cast<char*>(start);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
inline size_t getPageSize()
|
||||||
|
{
|
||||||
|
#ifdef _WIN32
|
||||||
|
SYSTEM_INFO sysInfo;
|
||||||
|
GetSystemInfo(&sysInfo);
|
||||||
|
return sysInfo.dwPageSize; // Page size in bytes
|
||||||
|
#else
|
||||||
|
return static_cast<size_t>(sysconf(_SC_PAGESIZE)); // POSIX page size
|
||||||
|
#endif
|
||||||
|
};
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
inline void PageAlignVectorAligned(std::vector<T, PageAlignedAllocator<T>>& vec) {
|
||||||
|
if (vec.empty()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
size_t page_size = getPageSize();
|
||||||
|
void* start = vec.data();
|
||||||
|
size_t size = vec.size() * sizeof(T);
|
||||||
|
|
||||||
|
// Check if the memory is page-aligned
|
||||||
|
if (reinterpret_cast<std::uintptr_t>(start) % page_size != 0) {
|
||||||
|
// Allocate a new aligned vector
|
||||||
|
std::vector<T, PageAlignedAllocator<T>> aligned_vec(vec.get_allocator());
|
||||||
|
aligned_vec.reserve(vec.capacity()); // Match capacity to avoid reallocation during copy
|
||||||
|
|
||||||
|
// Copy elements from the original vector
|
||||||
|
aligned_vec.insert(aligned_vec.end(), vec.begin(), vec.end());
|
||||||
|
|
||||||
|
// Swap the aligned vector with the original vector
|
||||||
|
vec.swap(aligned_vec);
|
||||||
|
|
||||||
|
// Clear the temporary aligned vector to free its memory
|
||||||
|
aligned_vec.clear();
|
||||||
|
|
||||||
|
// Verify the new alignment
|
||||||
|
start = vec.data();
|
||||||
|
if (reinterpret_cast<std::uintptr_t>(start) % page_size != 0) {
|
||||||
|
throw std::runtime_error("Failed to align vector memory to page boundaries.");
|
||||||
|
}
|
||||||
|
|
||||||
|
LogKSMDetail("Vector reallocated to ensure page alignment. start [{}] size [{}] bytes", start, size);
|
||||||
|
} else {
|
||||||
|
LogKSMDetail("Vector is already page-aligned. start [{}] size [{}] bytes", start, size);
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifndef _WIN32
|
||||||
|
// Mark memory for KSM (only on non-Windows systems)
|
||||||
|
MarkMemoryForKSM(start, size);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // EQEMU_KSM_HPP
|
||||||
@@ -0,0 +1,600 @@
|
|||||||
|
#include "mysql_stmt.h"
|
||||||
|
#include "eqemu_logsys.h"
|
||||||
|
#include "mutex.h"
|
||||||
|
#include "timer.h"
|
||||||
|
#include <charconv>
|
||||||
|
|
||||||
|
namespace mysql
|
||||||
|
{
|
||||||
|
|
||||||
|
void PreparedStmt::StmtDeleter::operator()(MYSQL_STMT* stmt) noexcept
|
||||||
|
{
|
||||||
|
// The connection must be locked when closing the stmt to avoid mysql errors
|
||||||
|
// in case another thread tries to use it during the close. If the mutex is
|
||||||
|
// changed to one that throws then exceptions need to be caught here.
|
||||||
|
LockMutex lock(mutex);
|
||||||
|
mysql_stmt_close(stmt);
|
||||||
|
}
|
||||||
|
|
||||||
|
PreparedStmt::PreparedStmt(MYSQL& mysql, std::string query, Mutex* mutex, StmtOptions opts)
|
||||||
|
: m_stmt(mysql_stmt_init(&mysql), { mutex }), m_query(std::move(query)), m_mutex(mutex), m_options(opts)
|
||||||
|
{
|
||||||
|
LockMutex lock(m_mutex);
|
||||||
|
if (mysql_stmt_prepare(m_stmt.get(), m_query.c_str(), static_cast<unsigned long>(m_query.size())) != 0)
|
||||||
|
{
|
||||||
|
ThrowError(fmt::format("Prepare error: {}", GetStmtError()));
|
||||||
|
}
|
||||||
|
|
||||||
|
m_params.resize(mysql_stmt_param_count(m_stmt.get()));
|
||||||
|
m_inputs.resize(m_params.size());
|
||||||
|
}
|
||||||
|
|
||||||
|
void PreparedStmt::ThrowError(const std::string& error)
|
||||||
|
{
|
||||||
|
LogMySQLError("{}", error);
|
||||||
|
throw std::runtime_error(error);
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string PreparedStmt::GetStmtError()
|
||||||
|
{
|
||||||
|
auto err = mysql_stmt_errno(m_stmt.get());
|
||||||
|
auto str = mysql_stmt_error(m_stmt.get());
|
||||||
|
return fmt::format("({}) [{}] for query [{}]", err, str, m_query);
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
void PreparedStmt::BindInput(size_t index, T value)
|
||||||
|
{
|
||||||
|
if (index >= m_inputs.size())
|
||||||
|
{
|
||||||
|
ThrowError(fmt::format("Cannot bind input, index {} out of range", index));
|
||||||
|
}
|
||||||
|
|
||||||
|
impl::Bind& arg = m_inputs[index];
|
||||||
|
arg.is_null = std::is_same_v<T, std::nullptr_t>;
|
||||||
|
|
||||||
|
MYSQL_BIND& bind = m_params[index];
|
||||||
|
bind.is_unsigned = std::is_unsigned_v<T>;
|
||||||
|
bind.is_null = &arg.is_null;
|
||||||
|
bind.length = &arg.length;
|
||||||
|
|
||||||
|
auto old_type = bind.buffer_type;
|
||||||
|
|
||||||
|
if constexpr (std::is_arithmetic_v<T>)
|
||||||
|
{
|
||||||
|
if (arg.buffer.size() < sizeof(T))
|
||||||
|
{
|
||||||
|
arg.buffer.resize(std::max(sizeof(T), sizeof(int64_t)));
|
||||||
|
bind.buffer = arg.buffer.data();
|
||||||
|
m_need_bind = true;
|
||||||
|
}
|
||||||
|
memcpy(arg.buffer.data(), &value, sizeof(T));
|
||||||
|
}
|
||||||
|
|
||||||
|
if constexpr (std::is_same_v<T, int8_t> || std::is_same_v<T, uint8_t> || std::is_same_v<T, bool>)
|
||||||
|
{
|
||||||
|
bind.buffer_type = MYSQL_TYPE_TINY;
|
||||||
|
}
|
||||||
|
else if constexpr (std::is_same_v<T, int16_t> || std::is_same_v<T, uint16_t>)
|
||||||
|
{
|
||||||
|
bind.buffer_type = MYSQL_TYPE_SHORT;
|
||||||
|
}
|
||||||
|
else if constexpr (std::is_same_v<T, int32_t> || std::is_same_v<T, uint32_t>)
|
||||||
|
{
|
||||||
|
bind.buffer_type = MYSQL_TYPE_LONG;
|
||||||
|
}
|
||||||
|
else if constexpr (std::is_same_v<T, int64_t> || std::is_same_v<T, uint64_t>)
|
||||||
|
{
|
||||||
|
bind.buffer_type = MYSQL_TYPE_LONGLONG;
|
||||||
|
}
|
||||||
|
else if constexpr (std::is_same_v<T, float>)
|
||||||
|
{
|
||||||
|
bind.buffer_type = MYSQL_TYPE_FLOAT;
|
||||||
|
}
|
||||||
|
else if constexpr (std::is_same_v<T, double>)
|
||||||
|
{
|
||||||
|
bind.buffer_type = MYSQL_TYPE_DOUBLE;
|
||||||
|
}
|
||||||
|
else if constexpr (std::is_same_v<T, std::string_view>)
|
||||||
|
{
|
||||||
|
bind.buffer_type = MYSQL_TYPE_STRING;
|
||||||
|
if (arg.buffer.empty() || arg.buffer.size() < value.size())
|
||||||
|
{
|
||||||
|
arg.buffer.resize(static_cast<size_t>((value.size() + 1) * 1.5));
|
||||||
|
bind.buffer = arg.buffer.data();
|
||||||
|
bind.buffer_length = static_cast<unsigned long>(arg.buffer.size());
|
||||||
|
m_need_bind = true;
|
||||||
|
}
|
||||||
|
std::copy(value.begin(), value.end(), arg.buffer.begin());
|
||||||
|
arg.length = static_cast<unsigned long>(value.size());
|
||||||
|
}
|
||||||
|
else if constexpr (!std::is_same_v<T, std::nullptr_t>)
|
||||||
|
{
|
||||||
|
static_assert(false_v<T>, "Cannot bind unsupported type");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (old_type != bind.buffer_type)
|
||||||
|
{
|
||||||
|
m_need_bind = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void PreparedStmt::BindInput(size_t index, const char* str)
|
||||||
|
{
|
||||||
|
BindInput(index, std::string_view(str));
|
||||||
|
}
|
||||||
|
|
||||||
|
void PreparedStmt::BindInput(size_t index, const std::string& str)
|
||||||
|
{
|
||||||
|
BindInput(index, std::string_view(str));
|
||||||
|
}
|
||||||
|
|
||||||
|
StmtResult PreparedStmt::Execute()
|
||||||
|
{
|
||||||
|
CheckArgs(0);
|
||||||
|
return DoExecute();
|
||||||
|
}
|
||||||
|
|
||||||
|
StmtResult PreparedStmt::Execute(const std::vector<param_t>& args)
|
||||||
|
{
|
||||||
|
CheckArgs(args.size());
|
||||||
|
for (size_t i = 0; i < args.size(); ++i)
|
||||||
|
{
|
||||||
|
std::visit([&](const auto& arg) { BindInput(i, arg); }, args[i]);
|
||||||
|
}
|
||||||
|
return DoExecute();
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
StmtResult PreparedStmt::Execute(const std::vector<T>& args)
|
||||||
|
{
|
||||||
|
CheckArgs(args.size());
|
||||||
|
for (size_t i = 0; i < args.size(); ++i)
|
||||||
|
{
|
||||||
|
BindInput(i, args[i]);
|
||||||
|
}
|
||||||
|
return DoExecute();
|
||||||
|
}
|
||||||
|
|
||||||
|
void PreparedStmt::CheckArgs(size_t argc)
|
||||||
|
{
|
||||||
|
if (argc != m_params.size())
|
||||||
|
{
|
||||||
|
ThrowError(fmt::format("Bad arg count (got {}, expected {}) for [{}]", argc, m_params.size(), m_query));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
StmtResult PreparedStmt::DoExecute()
|
||||||
|
{
|
||||||
|
BenchTimer timer;
|
||||||
|
LockMutex lock(m_mutex);
|
||||||
|
|
||||||
|
if (m_need_bind && mysql_stmt_bind_param(m_stmt.get(), m_params.data()) != 0)
|
||||||
|
{
|
||||||
|
ThrowError(fmt::format("Bind param error: {}", GetStmtError()));
|
||||||
|
}
|
||||||
|
|
||||||
|
m_need_bind = false;
|
||||||
|
|
||||||
|
if (mysql_stmt_execute(m_stmt.get()) != 0)
|
||||||
|
{
|
||||||
|
ThrowError(fmt::format("Execute error: {}", GetStmtError()));
|
||||||
|
}
|
||||||
|
|
||||||
|
my_bool attr = m_options.use_max_length;
|
||||||
|
mysql_stmt_attr_set(m_stmt.get(), STMT_ATTR_UPDATE_MAX_LENGTH, &attr);
|
||||||
|
|
||||||
|
if (m_options.buffer_results && mysql_stmt_store_result(m_stmt.get()) != 0)
|
||||||
|
{
|
||||||
|
ThrowError(fmt::format("Store result error: {}", GetStmtError()));
|
||||||
|
}
|
||||||
|
|
||||||
|
// Result buffers are bound on first execute and re-used if needed
|
||||||
|
if (m_results.empty())
|
||||||
|
{
|
||||||
|
BindResults();
|
||||||
|
}
|
||||||
|
|
||||||
|
StmtResult res(m_stmt.get(), m_results.size());
|
||||||
|
|
||||||
|
if (m_results.empty())
|
||||||
|
{
|
||||||
|
LogMySQLQuery("{} -- ({} row(s) affected) ({:.6f}s)", m_query, res.RowsAffected(), timer.elapsed());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
LogMySQLQuery("{} -- ({} row(s) returned) ({:.6f}s)", m_query, res.RowCount(), timer.elapsed());
|
||||||
|
}
|
||||||
|
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
void PreparedStmt::BindResults()
|
||||||
|
{
|
||||||
|
MYSQL_RES* res = mysql_stmt_result_metadata(m_stmt.get());
|
||||||
|
if (!res)
|
||||||
|
{
|
||||||
|
return; // did not produce a result set
|
||||||
|
}
|
||||||
|
|
||||||
|
MYSQL_FIELD* fields = mysql_fetch_fields(res);
|
||||||
|
m_columns.resize(mysql_num_fields(res));
|
||||||
|
m_results.resize(m_columns.size());
|
||||||
|
|
||||||
|
for (int i = 0; i < static_cast<int>(m_columns.size()); ++i)
|
||||||
|
{
|
||||||
|
impl::BindColumn& col = m_columns[i].m_col;
|
||||||
|
MYSQL_BIND& bind = m_results[i];
|
||||||
|
|
||||||
|
col.index = i;
|
||||||
|
col.name = fields[i].name;
|
||||||
|
col.buffer_type = fields[i].type;
|
||||||
|
col.is_unsigned = (fields[i].flags & UNSIGNED_FLAG) != 0;
|
||||||
|
col.buffer.resize(GetResultBufferSize(fields[i]));
|
||||||
|
|
||||||
|
bind.buffer_type = col.buffer_type;
|
||||||
|
bind.buffer = col.buffer.data();
|
||||||
|
bind.buffer_length = static_cast<unsigned long>(col.buffer.size());
|
||||||
|
bind.is_unsigned = col.is_unsigned;
|
||||||
|
bind.is_null = &col.is_null;
|
||||||
|
bind.length = &col.length;
|
||||||
|
bind.error = &col.error;
|
||||||
|
}
|
||||||
|
|
||||||
|
mysql_free_result(res);
|
||||||
|
|
||||||
|
if (!m_results.empty() && mysql_stmt_bind_result(m_stmt.get(), m_results.data()) != 0)
|
||||||
|
{
|
||||||
|
ThrowError(fmt::format("Bind result error: {}", GetStmtError()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int PreparedStmt::GetResultBufferSize(const MYSQL_FIELD& field) const
|
||||||
|
{
|
||||||
|
switch (field.type)
|
||||||
|
{
|
||||||
|
case MYSQL_TYPE_TINY:
|
||||||
|
return sizeof(int8_t);
|
||||||
|
case MYSQL_TYPE_SHORT:
|
||||||
|
return sizeof(int16_t);
|
||||||
|
case MYSQL_TYPE_INT24:
|
||||||
|
case MYSQL_TYPE_LONG:
|
||||||
|
return sizeof(int32_t);
|
||||||
|
case MYSQL_TYPE_LONGLONG:
|
||||||
|
return sizeof(int64_t);
|
||||||
|
case MYSQL_TYPE_FLOAT:
|
||||||
|
return sizeof(float);
|
||||||
|
case MYSQL_TYPE_DOUBLE:
|
||||||
|
return sizeof(double);
|
||||||
|
case MYSQL_TYPE_TIME:
|
||||||
|
case MYSQL_TYPE_DATE:
|
||||||
|
case MYSQL_TYPE_DATETIME:
|
||||||
|
case MYSQL_TYPE_TIMESTAMP:
|
||||||
|
return sizeof(MYSQL_TIME);
|
||||||
|
default: // if max_length is unavailable for strings buffers are resized on fetch
|
||||||
|
return field.max_length + 1; // ensure valid buffer created
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
StmtRow PreparedStmt::Fetch()
|
||||||
|
{
|
||||||
|
StmtRow row;
|
||||||
|
if (!m_columns.empty())
|
||||||
|
{
|
||||||
|
int rc = mysql_stmt_fetch(m_stmt.get());
|
||||||
|
if (rc == 1)
|
||||||
|
{
|
||||||
|
ThrowError(fmt::format("Fetch error: {}", GetStmtError()));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (rc != MYSQL_NO_DATA)
|
||||||
|
{
|
||||||
|
if (rc == MYSQL_DATA_TRUNCATED)
|
||||||
|
{
|
||||||
|
FetchTruncated();
|
||||||
|
}
|
||||||
|
row = StmtRow(m_columns);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return row;
|
||||||
|
}
|
||||||
|
|
||||||
|
void PreparedStmt::FetchTruncated()
|
||||||
|
{
|
||||||
|
for (int i = 0; i < static_cast<int>(m_columns.size()); ++i)
|
||||||
|
{
|
||||||
|
impl::BindColumn& col = m_columns[i].m_col;
|
||||||
|
if (col.error)
|
||||||
|
{
|
||||||
|
MYSQL_BIND& bind = m_results[i];
|
||||||
|
col.buffer.resize(static_cast<size_t>(col.length * 1.5));
|
||||||
|
bind.buffer = col.buffer.data();
|
||||||
|
bind.buffer_length = static_cast<unsigned long>(col.buffer.size());
|
||||||
|
|
||||||
|
mysql_stmt_fetch_column(m_stmt.get(), &bind, i, 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (mysql_stmt_bind_result(m_stmt.get(), m_results.data()) != 0)
|
||||||
|
{
|
||||||
|
ThrowError(fmt::format("Fetch rebind result error: {}", GetStmtError()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
StmtResult::StmtResult(MYSQL_STMT* stmt, size_t columns)
|
||||||
|
{
|
||||||
|
m_num_cols = static_cast<int>(columns);
|
||||||
|
m_num_rows = mysql_stmt_num_rows(stmt); // requires buffered results
|
||||||
|
m_affected = mysql_stmt_affected_rows(stmt);
|
||||||
|
m_insert_id = mysql_stmt_insert_id(stmt);
|
||||||
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
const StmtColumn* StmtRow::GetColumn(size_t index) const
|
||||||
|
{
|
||||||
|
return index < m_columns.size() ? &m_columns[index] : nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
const StmtColumn* StmtRow::GetColumn(std::string_view name) const
|
||||||
|
{
|
||||||
|
auto it = std::ranges::find_if(m_columns,
|
||||||
|
[name](const StmtColumn& col) { return col.Name() == name; });
|
||||||
|
|
||||||
|
return it != m_columns.end() ? &(*it) : nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::optional<std::string> StmtRow::operator[](size_t index) const
|
||||||
|
{
|
||||||
|
return GetStr(index);
|
||||||
|
}
|
||||||
|
|
||||||
|
std::optional<std::string> StmtRow::operator[](std::string_view name) const
|
||||||
|
{
|
||||||
|
return GetStr(name);
|
||||||
|
}
|
||||||
|
|
||||||
|
std::optional<std::string> StmtRow::GetStr(size_t index) const
|
||||||
|
{
|
||||||
|
const StmtColumn* col = GetColumn(index);
|
||||||
|
return col ? col->GetStr() : std::nullopt;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::optional<std::string> StmtRow::GetStr(std::string_view name) const
|
||||||
|
{
|
||||||
|
const StmtColumn* col = GetColumn(name);
|
||||||
|
return col ? col->GetStr() : std::nullopt;
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename T> requires std::is_arithmetic_v<T>
|
||||||
|
std::optional<T> StmtRow::Get(size_t index) const
|
||||||
|
{
|
||||||
|
const StmtColumn* col = GetColumn(index);
|
||||||
|
return col ? col->Get<T>() : std::nullopt;
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename T> requires std::is_arithmetic_v<T>
|
||||||
|
std::optional<T> StmtRow::Get(std::string_view name) const
|
||||||
|
{
|
||||||
|
const StmtColumn* col = GetColumn(name);
|
||||||
|
return col ? col->Get<T>() : std::nullopt;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
static time_t MakeTime(const MYSQL_TIME& mt)
|
||||||
|
{
|
||||||
|
// buffer mt given in mysql session time zone (assumes local)
|
||||||
|
std::tm tm{};
|
||||||
|
tm.tm_year = mt.year - 1900;
|
||||||
|
tm.tm_mon = mt.month - 1;
|
||||||
|
tm.tm_mday = mt.day;
|
||||||
|
tm.tm_hour = mt.hour;
|
||||||
|
tm.tm_min = mt.minute;
|
||||||
|
tm.tm_sec = mt.second;
|
||||||
|
tm.tm_isdst = -1;
|
||||||
|
return std::mktime(&tm);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int MakeSeconds(const MYSQL_TIME& mt)
|
||||||
|
{
|
||||||
|
return (mt.neg ? -1 : 1) * static_cast<int>(mt.hour * 3600 + mt.minute * 60 + mt.second);
|
||||||
|
}
|
||||||
|
|
||||||
|
static uint64_t MakeBits(std::span<const uint8_t> data)
|
||||||
|
{
|
||||||
|
// byte stream for bits is in big endian
|
||||||
|
uint64_t bits = 0;
|
||||||
|
for (size_t i = 0; i < data.size() && i < sizeof(uint64_t); ++i)
|
||||||
|
{
|
||||||
|
bits |= static_cast<uint64_t>(data[data.size() - i - 1] & 0xff) << (i * 8);
|
||||||
|
}
|
||||||
|
return bits;
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
concept has_from_chars = requires (const char* first, const char* last, T value)
|
||||||
|
{
|
||||||
|
std::from_chars(first, last, value);
|
||||||
|
};
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
static T FromString(std::string_view sv)
|
||||||
|
{
|
||||||
|
if constexpr (std::is_same_v<T, bool>)
|
||||||
|
{
|
||||||
|
// return false for empty (zero-length) strings
|
||||||
|
return !sv.empty();
|
||||||
|
}
|
||||||
|
else if constexpr (std::is_same_v<T, float> && !has_from_chars<T>)
|
||||||
|
{
|
||||||
|
return std::strtof(std::string(sv).c_str(), nullptr);
|
||||||
|
}
|
||||||
|
else if constexpr (std::is_same_v<T, double> && !has_from_chars<T>)
|
||||||
|
{
|
||||||
|
return std::strtod(std::string(sv).c_str(), nullptr);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// non numbers return a zero initialized T (could return nullopt instead)
|
||||||
|
T value = {};
|
||||||
|
std::from_chars(sv.data(), sv.data() + sv.size(), value);
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string FormatTime(enum_field_types type, const MYSQL_TIME& mt)
|
||||||
|
{
|
||||||
|
switch (type)
|
||||||
|
{
|
||||||
|
case MYSQL_TYPE_TIME: // hhh:mm:ss '-838:59:59' to '838:59:59'
|
||||||
|
return fmt::format("{}{:02d}:{:02d}:{:02d}", mt.neg ? "-" : "", mt.hour, mt.minute, mt.second);
|
||||||
|
case MYSQL_TYPE_DATE: // YYYY-MM-DD '1000-01-01' to '9999-12-31'
|
||||||
|
return fmt::format("{}-{:02d}-{:02d}", mt.year, mt.month, mt.day);
|
||||||
|
case MYSQL_TYPE_DATETIME: // YYYY-MM-DD hh:mm:ss '1000-01-01 00:00:00' to '9999-12-31 23:59:59'
|
||||||
|
case MYSQL_TYPE_TIMESTAMP: // YYYY-MM-DD hh:mm:ss '1970-01-01 00:00:01' UTC to '2038-01-19 03:14:07' UTC
|
||||||
|
return fmt::format("{}-{:02d}-{:02d} {:02d}:{:02d}:{:02d}", mt.year, mt.month, mt.day, mt.hour, mt.minute, mt.second);
|
||||||
|
default:
|
||||||
|
return std::string();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
std::optional<std::string_view> StmtColumn::GetStrView() const
|
||||||
|
{
|
||||||
|
if (m_col.is_null)
|
||||||
|
{
|
||||||
|
return std::nullopt;
|
||||||
|
}
|
||||||
|
|
||||||
|
switch (m_col.buffer_type)
|
||||||
|
{
|
||||||
|
case MYSQL_TYPE_NEWDECIMAL:
|
||||||
|
case MYSQL_TYPE_TINY_BLOB:
|
||||||
|
case MYSQL_TYPE_MEDIUM_BLOB:
|
||||||
|
case MYSQL_TYPE_LONG_BLOB:
|
||||||
|
case MYSQL_TYPE_BLOB:
|
||||||
|
case MYSQL_TYPE_VAR_STRING:
|
||||||
|
case MYSQL_TYPE_STRING:
|
||||||
|
return std::make_optional<std::string_view>(reinterpret_cast<const char*>(m_col.buffer.data()), m_col.length);
|
||||||
|
default:
|
||||||
|
return std::nullopt;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
std::optional<std::string> StmtColumn::GetStr() const
|
||||||
|
{
|
||||||
|
if (m_col.is_null)
|
||||||
|
{
|
||||||
|
return std::nullopt;
|
||||||
|
}
|
||||||
|
|
||||||
|
switch (m_col.buffer_type)
|
||||||
|
{
|
||||||
|
case MYSQL_TYPE_TINY:
|
||||||
|
return m_col.is_unsigned ? fmt::format_int(BitCast<uint8_t>()).c_str() : fmt::format_int(BitCast<int8_t>()).c_str();
|
||||||
|
case MYSQL_TYPE_SHORT:
|
||||||
|
return m_col.is_unsigned ? fmt::format_int(BitCast<uint16_t>()).c_str() : fmt::format_int(BitCast<int16_t>()).c_str();
|
||||||
|
case MYSQL_TYPE_INT24:
|
||||||
|
case MYSQL_TYPE_LONG:
|
||||||
|
return m_col.is_unsigned ? fmt::format_int(BitCast<uint32_t>()).c_str() : fmt::format_int(BitCast<int32_t>()).c_str();
|
||||||
|
case MYSQL_TYPE_LONGLONG:
|
||||||
|
return m_col.is_unsigned ? fmt::format_int(BitCast<uint64_t>()).c_str() : fmt::format_int(BitCast<int64_t>()).c_str();
|
||||||
|
case MYSQL_TYPE_FLOAT:
|
||||||
|
return fmt::format("{}", BitCast<float>());
|
||||||
|
case MYSQL_TYPE_DOUBLE:
|
||||||
|
return fmt::format("{}", BitCast<double>());
|
||||||
|
case MYSQL_TYPE_TIME:
|
||||||
|
case MYSQL_TYPE_DATE:
|
||||||
|
case MYSQL_TYPE_DATETIME:
|
||||||
|
case MYSQL_TYPE_TIMESTAMP:
|
||||||
|
return FormatTime(m_col.buffer_type, BitCast<MYSQL_TIME>());
|
||||||
|
case MYSQL_TYPE_BIT:
|
||||||
|
return fmt::format_int(*Get<uint64_t>()).c_str();
|
||||||
|
case MYSQL_TYPE_NEWDECIMAL:
|
||||||
|
case MYSQL_TYPE_TINY_BLOB:
|
||||||
|
case MYSQL_TYPE_MEDIUM_BLOB:
|
||||||
|
case MYSQL_TYPE_LONG_BLOB:
|
||||||
|
case MYSQL_TYPE_BLOB:
|
||||||
|
case MYSQL_TYPE_VAR_STRING:
|
||||||
|
case MYSQL_TYPE_STRING:
|
||||||
|
return std::make_optional<std::string>(reinterpret_cast<const char*>(m_col.buffer.data()), m_col.length);
|
||||||
|
default:
|
||||||
|
return std::nullopt;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename T> requires std::is_arithmetic_v<T>
|
||||||
|
std::optional<T> StmtColumn::Get() const
|
||||||
|
{
|
||||||
|
if (m_col.is_null)
|
||||||
|
{
|
||||||
|
return std::nullopt;
|
||||||
|
}
|
||||||
|
|
||||||
|
switch (m_col.buffer_type)
|
||||||
|
{
|
||||||
|
case MYSQL_TYPE_TINY:
|
||||||
|
return m_col.is_unsigned ? static_cast<T>(BitCast<uint8_t>()) : static_cast<T>(BitCast<int8_t>());
|
||||||
|
case MYSQL_TYPE_SHORT:
|
||||||
|
return m_col.is_unsigned ? static_cast<T>(BitCast<uint16_t>()) : static_cast<T>(BitCast<int16_t>());
|
||||||
|
case MYSQL_TYPE_INT24:
|
||||||
|
case MYSQL_TYPE_LONG:
|
||||||
|
return m_col.is_unsigned ? static_cast<T>(BitCast<uint32_t>()) : static_cast<T>(BitCast<int32_t>());
|
||||||
|
case MYSQL_TYPE_LONGLONG:
|
||||||
|
return m_col.is_unsigned ? static_cast<T>(BitCast<uint64_t>()) : static_cast<T>(BitCast<int64_t>());
|
||||||
|
case MYSQL_TYPE_FLOAT:
|
||||||
|
return static_cast<T>(BitCast<float>());
|
||||||
|
case MYSQL_TYPE_DOUBLE:
|
||||||
|
return static_cast<T>(BitCast<double>());
|
||||||
|
case MYSQL_TYPE_TIME: // return as total seconds
|
||||||
|
return static_cast<T>(MakeSeconds(BitCast<MYSQL_TIME>()));
|
||||||
|
case MYSQL_TYPE_DATE:
|
||||||
|
case MYSQL_TYPE_DATETIME:
|
||||||
|
case MYSQL_TYPE_TIMESTAMP: // return as epoch timestamp
|
||||||
|
return static_cast<T>(MakeTime(BitCast<MYSQL_TIME>()));
|
||||||
|
case MYSQL_TYPE_BIT:
|
||||||
|
return static_cast<T>(MakeBits({ m_col.buffer.data(), m_col.length }));
|
||||||
|
case MYSQL_TYPE_NEWDECIMAL:
|
||||||
|
case MYSQL_TYPE_TINY_BLOB:
|
||||||
|
case MYSQL_TYPE_MEDIUM_BLOB:
|
||||||
|
case MYSQL_TYPE_LONG_BLOB:
|
||||||
|
case MYSQL_TYPE_BLOB:
|
||||||
|
case MYSQL_TYPE_VAR_STRING:
|
||||||
|
case MYSQL_TYPE_STRING:
|
||||||
|
return FromString<T>({ reinterpret_cast<const char*>(m_col.buffer.data()), m_col.length });
|
||||||
|
default:
|
||||||
|
return std::nullopt;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
// explicit template instantiations for supported types
|
||||||
|
template void PreparedStmt::BindInput(size_t, std::string_view);
|
||||||
|
template void PreparedStmt::BindInput(size_t, std::nullptr_t);
|
||||||
|
template StmtResult PreparedStmt::Execute(const std::vector<std::string_view>&);
|
||||||
|
template StmtResult PreparedStmt::Execute(const std::vector<std::string>&);
|
||||||
|
template StmtResult PreparedStmt::Execute(const std::vector<const char*>&);
|
||||||
|
|
||||||
|
#define INSTANTIATE(T) \
|
||||||
|
template void PreparedStmt::BindInput(size_t, T); \
|
||||||
|
template StmtResult PreparedStmt::Execute(const std::vector<T>&); \
|
||||||
|
template std::optional<T> StmtRow::Get(size_t) const; \
|
||||||
|
template std::optional<T> StmtRow::Get(std::string_view) const; \
|
||||||
|
template std::optional<T> StmtColumn::Get() const;
|
||||||
|
|
||||||
|
INSTANTIATE(bool);
|
||||||
|
INSTANTIATE(int8_t);
|
||||||
|
INSTANTIATE(uint8_t);
|
||||||
|
INSTANTIATE(int16_t);
|
||||||
|
INSTANTIATE(uint16_t);
|
||||||
|
INSTANTIATE(int32_t);
|
||||||
|
INSTANTIATE(uint32_t);
|
||||||
|
INSTANTIATE(int64_t);
|
||||||
|
INSTANTIATE(uint64_t);
|
||||||
|
INSTANTIATE(float);
|
||||||
|
INSTANTIATE(double);
|
||||||
|
|
||||||
|
} // namespace mysql
|
||||||
@@ -0,0 +1,221 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "mysql.h"
|
||||||
|
#include <cassert>
|
||||||
|
#include <cstring>
|
||||||
|
#include <memory>
|
||||||
|
#include <optional>
|
||||||
|
#include <span>
|
||||||
|
#include <string>
|
||||||
|
#include <string_view>
|
||||||
|
#include <variant>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
|
class Mutex;
|
||||||
|
|
||||||
|
namespace mysql
|
||||||
|
{
|
||||||
|
|
||||||
|
// support MySQL 8.0.1+ API which removed the my_bool type
|
||||||
|
#if !defined(MARIADB_VERSION_ID) && MYSQL_VERSION_ID >= 80001
|
||||||
|
using my_bool = bool;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
template <typename>
|
||||||
|
inline constexpr bool false_v = false;
|
||||||
|
|
||||||
|
namespace impl
|
||||||
|
{
|
||||||
|
|
||||||
|
struct Bind
|
||||||
|
{
|
||||||
|
std::vector<uint8_t> buffer;
|
||||||
|
unsigned long length = 0;
|
||||||
|
my_bool is_null = false;
|
||||||
|
my_bool error = false;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct BindColumn : Bind
|
||||||
|
{
|
||||||
|
int index = 0;
|
||||||
|
std::string name;
|
||||||
|
bool is_unsigned = false;
|
||||||
|
enum_field_types buffer_type = {};
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace impl
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
struct StmtOptions
|
||||||
|
{
|
||||||
|
// Enable buffering (storing) entire result set after executing a statement
|
||||||
|
bool buffer_results = true;
|
||||||
|
|
||||||
|
// Enable MySQL to update max_length of fields in execute result set (requires buffering)
|
||||||
|
bool use_max_length = true;
|
||||||
|
};
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
// Holds ownership of bound column value buffer
|
||||||
|
class StmtColumn
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
int Index() const { return m_col.index; }
|
||||||
|
bool IsNull() const { return m_col.is_null; }
|
||||||
|
bool IsUnsigned() const { return m_col.is_unsigned; }
|
||||||
|
enum_field_types Type() const { return m_col.buffer_type; }
|
||||||
|
const std::string& Name() const { return m_col.name; }
|
||||||
|
|
||||||
|
// Get view of column value buffer
|
||||||
|
std::span<const uint8_t> GetBuf() const { return { m_col.buffer.data(), m_col.length }; }
|
||||||
|
|
||||||
|
// Get view of column string value. Returns nullopt if value is NULL or not a string
|
||||||
|
std::optional<std::string_view> GetStrView() const;
|
||||||
|
|
||||||
|
// Get column value as string. Returns nullopt if value is NULL or field type unsupported
|
||||||
|
std::optional<std::string> GetStr() const;
|
||||||
|
|
||||||
|
// Get column value as numeric T. Returns nullopt if value NULL or field type unsupported
|
||||||
|
template <typename T> requires std::is_arithmetic_v<T>
|
||||||
|
std::optional<T> Get() const;
|
||||||
|
|
||||||
|
private:
|
||||||
|
// uses memcpy for type punning buffer data to avoid UB with strict aliasing
|
||||||
|
template <typename T>
|
||||||
|
T BitCast() const
|
||||||
|
{
|
||||||
|
T val;
|
||||||
|
assert(sizeof(T) == m_col.length);
|
||||||
|
memcpy(&val, m_col.buffer.data(), sizeof(T));
|
||||||
|
return val;
|
||||||
|
}
|
||||||
|
|
||||||
|
friend class PreparedStmt; // access to allocate and bind buffers
|
||||||
|
friend class StmtResult; // access to resize truncated buffers
|
||||||
|
impl::BindColumn m_col;
|
||||||
|
};
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
// Provides a non-owning view of PreparedStmt column value buffers
|
||||||
|
// Evaluates false if it does not contain a valid row
|
||||||
|
class StmtRow
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
StmtRow() = default;
|
||||||
|
StmtRow(std::span<const StmtColumn> columns) : m_columns(columns) {};
|
||||||
|
|
||||||
|
explicit operator bool() const noexcept { return !m_columns.empty(); }
|
||||||
|
|
||||||
|
int ColumnCount() const { return static_cast<int>(m_columns.size()); }
|
||||||
|
const StmtColumn* GetColumn(size_t index) const;
|
||||||
|
const StmtColumn* GetColumn(std::string_view name) const;
|
||||||
|
|
||||||
|
// Get specified column value as string
|
||||||
|
// Returns nullopt if column invalid, value is NULL, or field type unsupported
|
||||||
|
std::optional<std::string> operator[](size_t index) const;
|
||||||
|
std::optional<std::string> operator[](std::string_view name) const;
|
||||||
|
std::optional<std::string> GetStr(size_t index) const;
|
||||||
|
std::optional<std::string> GetStr(std::string_view name) const;
|
||||||
|
|
||||||
|
// Get specified column value as numeric T
|
||||||
|
// Returns nullopt if column invalid, value is NULL, or field type unsupported
|
||||||
|
template <typename T> requires std::is_arithmetic_v<T>
|
||||||
|
std::optional<T> Get(size_t index) const;
|
||||||
|
|
||||||
|
template <typename T> requires std::is_arithmetic_v<T>
|
||||||
|
std::optional<T> Get(std::string_view name) const;
|
||||||
|
|
||||||
|
auto begin() const { return m_columns.begin(); }
|
||||||
|
auto end() const { return m_columns.end(); }
|
||||||
|
|
||||||
|
private:
|
||||||
|
std::span<const StmtColumn> m_columns;
|
||||||
|
};
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
// Result meta data for an executed prepared statement
|
||||||
|
class StmtResult
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
StmtResult() = default;
|
||||||
|
StmtResult(MYSQL_STMT* stmt, size_t columns);
|
||||||
|
|
||||||
|
int ColumnCount() const { return m_num_cols; }
|
||||||
|
uint64_t RowCount() const { return m_num_rows; }
|
||||||
|
uint64_t RowsAffected() const { return m_affected; }
|
||||||
|
uint64_t LastInsertID() const { return m_insert_id; }
|
||||||
|
|
||||||
|
private:
|
||||||
|
int m_num_cols = 0;
|
||||||
|
uint64_t m_num_rows = 0;
|
||||||
|
uint64_t m_affected = 0;
|
||||||
|
uint64_t m_insert_id = 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
class PreparedStmt
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
// Supported argument types for execute
|
||||||
|
using param_t = std::variant<int8_t, uint8_t, int16_t, uint16_t, int32_t, uint32_t,
|
||||||
|
int64_t, uint64_t, float, double, bool, std::string_view, std::nullptr_t>;
|
||||||
|
|
||||||
|
PreparedStmt() = delete;
|
||||||
|
PreparedStmt(MYSQL& mysql, std::string query, Mutex* mutex, StmtOptions opts = {});
|
||||||
|
|
||||||
|
const std::string& GetQuery() const { return m_query; }
|
||||||
|
StmtOptions GetOptions() const { return m_options; }
|
||||||
|
void SetOptions(StmtOptions options) { m_options = options; }
|
||||||
|
void FreeResult() { mysql_stmt_free_result(m_stmt.get()); }
|
||||||
|
|
||||||
|
// Execute the prepared statement with specified arguments
|
||||||
|
// Throws exception on error
|
||||||
|
template <typename T>
|
||||||
|
StmtResult Execute(const std::vector<T>& args);
|
||||||
|
StmtResult Execute(const std::vector<param_t>& args);
|
||||||
|
StmtResult Execute();
|
||||||
|
|
||||||
|
// Fetch the next row into column buffers (overwrites previous row values)
|
||||||
|
// Return value evaluates false if no more rows to fetch
|
||||||
|
// Throws exception on error
|
||||||
|
StmtRow Fetch();
|
||||||
|
|
||||||
|
private:
|
||||||
|
void CheckArgs(size_t argc);
|
||||||
|
StmtResult DoExecute();
|
||||||
|
void BindResults();
|
||||||
|
void FetchTruncated();
|
||||||
|
int GetResultBufferSize(const MYSQL_FIELD& field) const;
|
||||||
|
void ThrowError(const std::string& error);
|
||||||
|
std::string GetStmtError();
|
||||||
|
|
||||||
|
// bind an input value to a query parameter by index
|
||||||
|
template <typename T>
|
||||||
|
void BindInput(size_t index, T value);
|
||||||
|
void BindInput(size_t index, const char* str);
|
||||||
|
void BindInput(size_t index, const std::string& str);
|
||||||
|
|
||||||
|
struct StmtDeleter
|
||||||
|
{
|
||||||
|
Mutex* mutex = nullptr;
|
||||||
|
void operator()(MYSQL_STMT* stmt) noexcept;
|
||||||
|
};
|
||||||
|
|
||||||
|
private:
|
||||||
|
std::unique_ptr<MYSQL_STMT, StmtDeleter> m_stmt;
|
||||||
|
std::vector<MYSQL_BIND> m_params; // input binds
|
||||||
|
std::vector<MYSQL_BIND> m_results; // result binds
|
||||||
|
std::vector<impl::Bind> m_inputs; // execute buffers (addresses bound)
|
||||||
|
std::vector<StmtColumn> m_columns; // fetch buffers (addresses bound)
|
||||||
|
std::string m_query;
|
||||||
|
StmtOptions m_options = {};
|
||||||
|
bool m_need_bind = true;
|
||||||
|
Mutex* m_mutex = nullptr; // connection mutex
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace mysql
|
||||||
@@ -1,6 +1,7 @@
|
|||||||
#include "console_server.h"
|
#include "console_server.h"
|
||||||
#include "../strings.h"
|
#include "../strings.h"
|
||||||
#include <fmt/format.h>
|
#include <fmt/format.h>
|
||||||
|
#include <fmt/ranges.h>
|
||||||
|
|
||||||
EQ::Net::ConsoleServer::ConsoleServer(const std::string &addr, int port)
|
EQ::Net::ConsoleServer::ConsoleServer(const std::string &addr, int port)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -5,6 +5,7 @@
|
|||||||
#include "../servertalk.h"
|
#include "../servertalk.h"
|
||||||
#include "../rulesys.h"
|
#include "../rulesys.h"
|
||||||
#include <fmt/format.h>
|
#include <fmt/format.h>
|
||||||
|
#include <fmt/ranges.h>
|
||||||
|
|
||||||
EQ::Net::ConsoleServerConnection::ConsoleServerConnection(ConsoleServer *parent, std::shared_ptr<TCPConnection> connection)
|
EQ::Net::ConsoleServerConnection::ConsoleServerConnection(ConsoleServer *parent, std::shared_ptr<TCPConnection> connection)
|
||||||
{
|
{
|
||||||
|
|||||||
+12
-12
@@ -1,11 +1,11 @@
|
|||||||
#include "eqstream.h"
|
#include "eqstream.h"
|
||||||
#include "../eqemu_logsys.h"
|
#include "../eqemu_logsys.h"
|
||||||
|
|
||||||
EQ::Net::EQStreamManager::EQStreamManager(const EQStreamManagerInterfaceOptions &options) : EQStreamManagerInterface(options), m_daybreak(options.daybreak_options)
|
EQ::Net::EQStreamManager::EQStreamManager(const EQStreamManagerInterfaceOptions &options) : EQStreamManagerInterface(options), m_reliable_stream(options.reliable_stream_options)
|
||||||
{
|
{
|
||||||
m_daybreak.OnNewConnection(std::bind(&EQStreamManager::DaybreakNewConnection, this, std::placeholders::_1));
|
m_reliable_stream.OnNewConnection(std::bind(&EQStreamManager::ReliableStreamNewConnection, this, std::placeholders::_1));
|
||||||
m_daybreak.OnConnectionStateChange(std::bind(&EQStreamManager::DaybreakConnectionStateChange, this, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3));
|
m_reliable_stream.OnConnectionStateChange(std::bind(&EQStreamManager::ReliableStreamConnectionStateChange, this, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3));
|
||||||
m_daybreak.OnPacketRecv(std::bind(&EQStreamManager::DaybreakPacketRecv, this, std::placeholders::_1, std::placeholders::_2));
|
m_reliable_stream.OnPacketRecv(std::bind(&EQStreamManager::ReliableStreamPacketRecv, this, std::placeholders::_1, std::placeholders::_2));
|
||||||
}
|
}
|
||||||
|
|
||||||
EQ::Net::EQStreamManager::~EQStreamManager()
|
EQ::Net::EQStreamManager::~EQStreamManager()
|
||||||
@@ -15,11 +15,11 @@ EQ::Net::EQStreamManager::~EQStreamManager()
|
|||||||
void EQ::Net::EQStreamManager::SetOptions(const EQStreamManagerInterfaceOptions &options)
|
void EQ::Net::EQStreamManager::SetOptions(const EQStreamManagerInterfaceOptions &options)
|
||||||
{
|
{
|
||||||
m_options = options;
|
m_options = options;
|
||||||
auto &opts = m_daybreak.GetOptions();
|
auto &opts = m_reliable_stream.GetOptions();
|
||||||
opts = options.daybreak_options;
|
opts = options.reliable_stream_options;
|
||||||
}
|
}
|
||||||
|
|
||||||
void EQ::Net::EQStreamManager::DaybreakNewConnection(std::shared_ptr<DaybreakConnection> connection)
|
void EQ::Net::EQStreamManager::ReliableStreamNewConnection(std::shared_ptr<ReliableStreamConnection> connection)
|
||||||
{
|
{
|
||||||
std::shared_ptr<EQStream> stream(new EQStream(this, connection));
|
std::shared_ptr<EQStream> stream(new EQStream(this, connection));
|
||||||
m_streams.emplace(std::make_pair(connection, stream));
|
m_streams.emplace(std::make_pair(connection, stream));
|
||||||
@@ -28,7 +28,7 @@ void EQ::Net::EQStreamManager::DaybreakNewConnection(std::shared_ptr<DaybreakCon
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void EQ::Net::EQStreamManager::DaybreakConnectionStateChange(std::shared_ptr<DaybreakConnection> connection, DbProtocolStatus from, DbProtocolStatus to)
|
void EQ::Net::EQStreamManager::ReliableStreamConnectionStateChange(std::shared_ptr<ReliableStreamConnection> connection, DbProtocolStatus from, DbProtocolStatus to)
|
||||||
{
|
{
|
||||||
auto iter = m_streams.find(connection);
|
auto iter = m_streams.find(connection);
|
||||||
if (iter != m_streams.end()) {
|
if (iter != m_streams.end()) {
|
||||||
@@ -42,7 +42,7 @@ void EQ::Net::EQStreamManager::DaybreakConnectionStateChange(std::shared_ptr<Day
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void EQ::Net::EQStreamManager::DaybreakPacketRecv(std::shared_ptr<DaybreakConnection> connection, const Packet &p)
|
void EQ::Net::EQStreamManager::ReliableStreamPacketRecv(std::shared_ptr<ReliableStreamConnection> connection, const Packet &p)
|
||||||
{
|
{
|
||||||
auto iter = m_streams.find(connection);
|
auto iter = m_streams.find(connection);
|
||||||
if (iter != m_streams.end()) {
|
if (iter != m_streams.end()) {
|
||||||
@@ -53,7 +53,7 @@ void EQ::Net::EQStreamManager::DaybreakPacketRecv(std::shared_ptr<DaybreakConnec
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
EQ::Net::EQStream::EQStream(EQStreamManagerInterface *owner, std::shared_ptr<DaybreakConnection> connection)
|
EQ::Net::EQStream::EQStream(EQStreamManagerInterface *owner, std::shared_ptr<ReliableStreamConnection> connection)
|
||||||
{
|
{
|
||||||
m_owner = owner;
|
m_owner = owner;
|
||||||
m_connection = connection;
|
m_connection = connection;
|
||||||
@@ -71,7 +71,7 @@ void EQ::Net::EQStream::QueuePacket(const EQApplicationPacket *p, bool ack_req)
|
|||||||
OpcodeManager::EmuToName(p->GetOpcode()),
|
OpcodeManager::EmuToName(p->GetOpcode()),
|
||||||
(*m_opcode_manager)->EmuToEQ(p->GetOpcode()),
|
(*m_opcode_manager)->EmuToEQ(p->GetOpcode()),
|
||||||
p->Size(),
|
p->Size(),
|
||||||
(LogSys.IsLogEnabled(Logs::Detail, Logs::PacketServerClient) ? DumpPacketToString(p) : "")
|
(EQEmuLogSys::Instance()->IsLogEnabled(Logs::Detail, Logs::PacketServerClient) ? DumpPacketToString(p) : "")
|
||||||
);
|
);
|
||||||
|
|
||||||
if (m_opcode_manager && *m_opcode_manager) {
|
if (m_opcode_manager && *m_opcode_manager) {
|
||||||
@@ -235,7 +235,7 @@ EQStreamState EQ::Net::EQStream::GetState() {
|
|||||||
EQ::Net::EQStream::Stats EQ::Net::EQStream::GetStats() const
|
EQ::Net::EQStream::Stats EQ::Net::EQStream::GetStats() const
|
||||||
{
|
{
|
||||||
Stats ret;
|
Stats ret;
|
||||||
ret.DaybreakStats = m_connection->GetStats();
|
ret.ReliableStreamStats = m_connection->GetStats();
|
||||||
|
|
||||||
for (int i = 0; i < _maxEmuOpcode; ++i) {
|
for (int i = 0; i < _maxEmuOpcode; ++i) {
|
||||||
ret.RecvCount[i] = 0;
|
ret.RecvCount[i] = 0;
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
#include "../eq_packet.h"
|
#include "../eq_packet.h"
|
||||||
#include "../eq_stream_intf.h"
|
#include "../eq_stream_intf.h"
|
||||||
#include "../opcodemgr.h"
|
#include "../opcodemgr.h"
|
||||||
#include "daybreak_connection.h"
|
#include "reliable_stream_connection.h"
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <deque>
|
#include <deque>
|
||||||
#include <unordered_map>
|
#include <unordered_map>
|
||||||
@@ -23,21 +23,21 @@ namespace EQ
|
|||||||
void OnNewConnection(std::function<void(std::shared_ptr<EQStream>)> func) { m_on_new_connection = func; }
|
void OnNewConnection(std::function<void(std::shared_ptr<EQStream>)> func) { m_on_new_connection = func; }
|
||||||
void OnConnectionStateChange(std::function<void(std::shared_ptr<EQStream>, DbProtocolStatus, DbProtocolStatus)> func) { m_on_connection_state_change = func; }
|
void OnConnectionStateChange(std::function<void(std::shared_ptr<EQStream>, DbProtocolStatus, DbProtocolStatus)> func) { m_on_connection_state_change = func; }
|
||||||
private:
|
private:
|
||||||
DaybreakConnectionManager m_daybreak;
|
ReliableStreamConnectionManager m_reliable_stream;
|
||||||
std::function<void(std::shared_ptr<EQStream>)> m_on_new_connection;
|
std::function<void(std::shared_ptr<EQStream>)> m_on_new_connection;
|
||||||
std::function<void(std::shared_ptr<EQStream>, DbProtocolStatus, DbProtocolStatus)> m_on_connection_state_change;
|
std::function<void(std::shared_ptr<EQStream>, DbProtocolStatus, DbProtocolStatus)> m_on_connection_state_change;
|
||||||
std::map<std::shared_ptr<DaybreakConnection>, std::shared_ptr<EQStream>> m_streams;
|
std::map<std::shared_ptr<ReliableStreamConnection>, std::shared_ptr<EQStream>> m_streams;
|
||||||
|
|
||||||
void DaybreakNewConnection(std::shared_ptr<DaybreakConnection> connection);
|
void ReliableStreamNewConnection(std::shared_ptr<ReliableStreamConnection> connection);
|
||||||
void DaybreakConnectionStateChange(std::shared_ptr<DaybreakConnection> connection, DbProtocolStatus from, DbProtocolStatus to);
|
void ReliableStreamConnectionStateChange(std::shared_ptr<ReliableStreamConnection> connection, DbProtocolStatus from, DbProtocolStatus to);
|
||||||
void DaybreakPacketRecv(std::shared_ptr<DaybreakConnection> connection, const Packet &p);
|
void ReliableStreamPacketRecv(std::shared_ptr<ReliableStreamConnection> connection, const Packet &p);
|
||||||
friend class EQStream;
|
friend class EQStream;
|
||||||
};
|
};
|
||||||
|
|
||||||
class EQStream : public EQStreamInterface
|
class EQStream : public EQStreamInterface
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
EQStream(EQStreamManagerInterface *parent, std::shared_ptr<DaybreakConnection> connection);
|
EQStream(EQStreamManagerInterface *parent, std::shared_ptr<ReliableStreamConnection> connection);
|
||||||
~EQStream();
|
~EQStream();
|
||||||
|
|
||||||
virtual void QueuePacket(const EQApplicationPacket *p, bool ack_req = true);
|
virtual void QueuePacket(const EQApplicationPacket *p, bool ack_req = true);
|
||||||
@@ -67,7 +67,7 @@ namespace EQ
|
|||||||
virtual EQStreamManagerInterface* GetManager() const;
|
virtual EQStreamManagerInterface* GetManager() const;
|
||||||
private:
|
private:
|
||||||
EQStreamManagerInterface *m_owner;
|
EQStreamManagerInterface *m_owner;
|
||||||
std::shared_ptr<DaybreakConnection> m_connection;
|
std::shared_ptr<ReliableStreamConnection> m_connection;
|
||||||
OpcodeManager **m_opcode_manager;
|
OpcodeManager **m_opcode_manager;
|
||||||
std::deque<std::unique_ptr<EQ::Net::Packet>> m_packet_queue;
|
std::deque<std::unique_ptr<EQ::Net::Packet>> m_packet_queue;
|
||||||
std::unordered_map<int, int> m_packet_recv_count;
|
std::unordered_map<int, int> m_packet_recv_count;
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
#include "endian.h"
|
#include "endian.h"
|
||||||
#include <cctype>
|
#include <cctype>
|
||||||
#include <fmt/format.h>
|
#include <fmt/format.h>
|
||||||
|
#include <fmt/ranges.h>
|
||||||
|
|
||||||
void EQ::Net::Packet::PutInt8(size_t offset, int8_t value)
|
void EQ::Net::Packet::PutInt8(size_t offset, int8_t value)
|
||||||
{
|
{
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user