Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Improve console output to show packet enum names (magic_enum) #1344

Merged
merged 45 commits into from
Dec 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
a9ca019
add enum stringification functionality from third party source
jadebenn Dec 17, 2023
e4d423b
squashed commit
jadebenn Dec 17, 2023
51e0deb
Merge branch 'DarkflameUniverse:main' into ImproveConsoleOutput
jadebenn Dec 17, 2023
a704d84
Macros: Add test and improve speed
EmosewaMC Dec 17, 2023
33fa5f8
moved stringify code to dCommon
jadebenn Dec 17, 2023
fbe304f
Rename #defines in stringify enum tests
jadebenn Dec 17, 2023
de2bb41
Revert "moved stringify code to dCommon"
jadebenn Dec 17, 2023
ffdc926
improve macro functionality
jadebenn Dec 17, 2023
9109eb0
typo fixes
jadebenn Dec 18, 2023
9d090f7
moved code to dCommon/dEnums and tests to dCommonTests/dEnumsTests
jadebenn Dec 18, 2023
9ce0813
initial magic_enums alternate implementation of enum stringification
jadebenn Dec 19, 2023
7d0dd94
deleted unused tests
jadebenn Dec 19, 2023
396e2af
reverted compile flag oopsy and fixed output types
jadebenn Dec 19, 2023
59b1739
fixed testing suite
jadebenn Dec 19, 2023
ae0dd3c
test formatting improvement
jadebenn Dec 19, 2023
0d36f9e
formatting again :(
jadebenn Dec 19, 2023
88c021c
added gm string to "aborting gm!" message
jadebenn Dec 19, 2023
79b4fa7
Push my suggestion for CI tests.
Jettford Dec 19, 2023
9582139
Merge remote-tracking branch 'upstream/magic-enum-demo' into ImproveC…
jadebenn Dec 20, 2023
2795711
updated magic enum test
jadebenn Dec 20, 2023
6482047
fix test variable type
jadebenn Dec 20, 2023
023a3cc
added gm test
jadebenn Dec 20, 2023
961f824
making sure magic_enum is on a release branch
jadebenn Dec 20, 2023
9eec33c
tidying up console outputs
jadebenn Dec 20, 2023
c713aff
Merge branch 'DarkflameUniverse:main' into ImproveConsoleOutputDep
jadebenn Dec 21, 2023
83ecdca
re-implemented enum array access for performance
jadebenn Dec 21, 2023
116a773
Merge branch 'ImproveConsoleOutputDep' of https://github.com/jadebenn…
jadebenn Dec 21, 2023
4906d0b
now it is bugged :(
jadebenn Dec 21, 2023
50194a1
nvm, working
jadebenn Dec 21, 2023
2fd2eb0
helping out the snowflake compilers
jadebenn Dec 21, 2023
48223d5
changed return type too
jadebenn Dec 21, 2023
0a97155
optimization too
jadebenn Dec 21, 2023
42b4a5c
formatting too I guess because why not
jadebenn Dec 21, 2023
4770bf9
being even more painfully specific
jadebenn Dec 21, 2023
d34ec46
Update WorldServer.cpp to match emo's feedback
jadebenn Dec 21, 2023
9263728
Update MagicEnumTests.cpp to use srand(time(NULL))
jadebenn Dec 21, 2023
3b4493c
Update eGameMessageType.h - formatting
jadebenn Dec 21, 2023
d044281
Trying to fix the crash but can't actually compile the code to check …
jadebenn Dec 21, 2023
05f9d42
Update WorldServer.cpp - third try at this
jadebenn Dec 21, 2023
62cadb6
Update MagicEnumTests.cpp - use better macro definitions
jadebenn Dec 21, 2023
20fe9b2
Update MagicEnumTests.cpp - c string comparison fix
jadebenn Dec 21, 2023
e76b963
addressing all but the cmake feedback
jadebenn Dec 22, 2023
5e56528
fixed cmake to the best of my very limited ability
jadebenn Dec 22, 2023
f42d1b4
added tests to verify magic enum arrays are pre-sorted
jadebenn Dec 23, 2023
231adfa
updated
jadebenn Dec 23, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,6 @@
[submodule "thirdparty/AccountManager"]
path = thirdparty/AccountManager
url = https://github.com/DarkflameUniverse/AccountManager
[submodule "thirdparty/magic_enum"]
path = thirdparty/magic_enum
url = https://github.com/Neargye/magic_enum.git
3 changes: 2 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,7 @@ set(INCLUDED_DIRECTORIES
"dScripts/zone/PROPERTY/GF"
"dScripts/zone/PROPERTY/NS"

"thirdparty/magic_enum/include/magic_enum"
jadebenn marked this conversation as resolved.
Show resolved Hide resolved
"thirdparty/raknet/Source"
"thirdparty/tinyxml2"
"thirdparty/recastnavigation"
Expand Down Expand Up @@ -373,7 +374,7 @@ add_subdirectory(dNavigation)
add_subdirectory(dPhysics)

# Create a list of common libraries shared between all binaries
set(COMMON_LIBRARIES "dCommon" "dDatabase" "dNet" "raknet" "mariadbConnCpp")
set(COMMON_LIBRARIES "dCommon" "dDatabase" "dNet" "raknet" "mariadbConnCpp" "magic_enum")

# Add platform specific common libraries
if (UNIX)
Expand Down
29 changes: 29 additions & 0 deletions dCommon/dEnums/StringifiedEnum.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#ifndef __STRINGIFIEDENUM_H__
#define __STRINGIFIEDENUM_H__

#include <string>
#include "magic_enum.hpp"

namespace StringifiedEnum {
template<typename T>
const std::string_view ToString(const T e) {
constexpr auto sv = &magic_enum::enum_entries<T>();
std::string_view output;

const auto it = std::lower_bound(
sv->begin(), sv->end(), e,
[&](const std::pair<T, std::string_view>& lhs, const T rhs)
{ return lhs.first < rhs; }
);

if (it != sv->end() && it->first == e) {
output = it->second;
}
else {
output = "UNKNOWN";
}
return output;
}
}

#endif // !__STRINGIFIEDENUM_H__
Loading
Loading