Compare commits

...

9 Commits
master ... pg

Author SHA1 Message Date
42fd697dac fix: RESULT_SAFEBOX_LOAD. 2025-06-09 17:28:58 +01:00
74e9f0e99d change: Start updating ClientManager.
add: Callback AsyncQuery.
fix: Multiple missing `txn.commit()`.
2025-06-09 17:01:28 +01:00
d25bf59c6f fix: CItemIDRangeManager::BuildRange catch error 2025-06-07 23:00:26 +01:00
dc84d3f95f change: ItemIDRangeManager 2025-06-07 22:59:09 +01:00
3a38f8828c change: Marriage. 2025-06-07 22:42:01 +01:00
93d8f2a0be fix: __INTELLISENSE__ version import (VSC).
change: Format all /db files, db/Main, db/DBManager, db/Monarch.
add: PgConnectionPool, PgAsyncQuery.
2025-06-07 20:38:53 +01:00
4bc4a79a4b remove: Unused code. 2025-06-07 13:51:00 +01:00
c9bd9a76b1 change: Translate ClientManagerBoot.cpp 2025-06-06 20:26:23 +01:00
09b28e114e change: Start moving to PG.
remove: Auction.
2025-05-31 17:58:32 +01:00
106 changed files with 5376 additions and 9963 deletions

6
.gitignore vendored
View File

@ -406,6 +406,9 @@ FodyWeavers.xsd
# CMake # CMake
cmake-build-*/ cmake-build-*/
cmake/
CMakeFiles/
CMakeCache.txt
# Mongo Explorer plugin # Mongo Explorer plugin
.idea/**/mongoSettings.xml .idea/**/mongoSettings.xml
@ -442,3 +445,6 @@ fabric.properties
# Debug folder # Debug folder
test/ test/
# Vcpkg
vcpkg_installed/

811
.idea/editor.xml generated
View File

@ -1,580 +1,247 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<project version="4"> <project version="4">
<component name="BackendCodeEditorSettings"> <component name="BackendCodeEditorSettings">
<option name="/Default/CodeStyle/CodeFormatting/CppClangFormat/EnableClangFormatSupport/@EntryValue" value="false" type="bool" />
<option name="/Default/CodeStyle/EditorConfig/EnableClangFormatSupport/@EntryValue" value="false" type="bool" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/ALIGN_MULTILINE_BINARY_EXPRESSIONS_CHAIN/@EntryValue" value="true" type="bool" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/ALIGN_MULTILINE_CALLS_CHAIN/@EntryValue" value="false" type="bool" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/ALIGN_MULTILINE_EXPRESSION/@EntryValue" value="false" type="bool" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/ALIGN_MULTILINE_FOR_STMT/@EntryValue" value="true" type="bool" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/ALIGN_MULTIPLE_DECLARATION/@EntryValue" value="false" type="bool" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/ALIGN_TERNARY/@EntryValue" value="ALIGN_ALL" type="string" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/BLANK_LINES_AROUND_CLASS_DEFINITION/@EntryValue" value="1" type="int" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/KEEP_BLANK_LINES_IN_DECLARATIONS/@EntryValue" value="2" type="int" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/KEEP_BLANK_LINES_IN_CODE/@EntryValue" value="2" type="int" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/KEEP_USER_LINEBREAKS/@EntryValue" value="true" type="bool" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/INDENT_CASE_FROM_SWITCH/@EntryValue" value="true" type="bool" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/INDENT_COMMENT/@EntryValue" value="true" type="bool" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/INT_ALIGN_EQ/@EntryValue" value="false" type="bool" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SIMPLE_BLOCK_STYLE/@EntryValue" value="DO_NOT_CHANGE" type="string" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_AFTER_COMMA_IN_TEMPLATE_ARGS/@EntryValue" value="true" type="bool" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_AFTER_COMMA_IN_TEMPLATE_PARAMS/@EntryValue" value="true" type="bool" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_AFTER_FOR_SEMICOLON/@EntryValue" value="true" type="bool" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_BEFORE_FOR_SEMICOLON/@EntryValue" value="false" type="bool" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_AFTER_UNARY_OPERATOR/@EntryValue" value="false" type="bool" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_WITHIN_ARRAY_ACCESS_BRACKETS/@EntryValue" value="false" type="bool" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_WITHIN_CAST_EXPRESSION_PARENTHESES/@EntryValue" value="false" type="bool" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_WITHIN_EMPTY_INITIALIZER_BRACES/@EntryValue" value="false" type="bool" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_WITHIN_EMPTY_METHOD_PARENTHESES/@EntryValue" value="false" type="bool" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_WITHIN_INITIALIZER_BRACES/@EntryValue" value="false" type="bool" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPECIAL_ELSE_IF_TREATMENT/@EntryValue" value="true" type="bool" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_AFTER_CAST_EXPRESSION_PARENTHESES/@EntryValue" value="true" type="bool" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/WRAP_AFTER_BINARY_OPSIGN/@EntryValue" value="true" type="bool" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/WRAP_BEFORE_TERNARY_OPSIGNS/@EntryValue" value="true" type="bool" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/TYPE_DECLARATION_BRACES/@EntryValue" value="END_OF_LINE" type="string" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/OTHER_BRACES/@EntryValue" value="END_OF_LINE" type="string" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/CASE_BLOCK_BRACES/@EntryValue" value="END_OF_LINE" type="string" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/BLANK_LINES_AROUND_FUNCTION_DECLARATION/@EntryValue" value="1" type="int" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/BLANK_LINES_AROUND_FUNCTION_DEFINITION/@EntryValue" value="1" type="int" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/PLACE_WHILE_ON_NEW_LINE/@EntryValue" value="false" type="bool" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/PLACE_ELSE_ON_NEW_LINE/@EntryValue" value="false" type="bool" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/PLACE_CATCH_ON_NEW_LINE/@EntryValue" value="false" type="bool" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/NAMESPACE_INDENTATION/@EntryValue" value="All" type="string" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/ALIGN_MULTILINE_ARGUMENT/@EntryValue" value="true" type="bool" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/ALIGN_MULTILINE_EXTENDS_LIST/@EntryValue" value="true" type="bool" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/ALIGN_MULTILINE_PARAMETER/@EntryValue" value="true" type="bool" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/ALIGN_MULTILINE_TYPE_ARGUMENT/@EntryValue" value="false" type="bool" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/ALIGN_MULTILINE_TYPE_PARAMETER/@EntryValue" value="false" type="bool" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/BLANK_LINES_AROUND_DECLARATIONS/@EntryValue" value="0" type="int" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/INDENT_ACCESS_SPECIFIERS_FROM_CLASS/@EntryValue" value="false" type="bool" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/INDENT_CLASS_MEMBERS_FROM_ACCESS_SPECIFIERS/@EntryValue" value="true" type="bool" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/LINE_BREAK_AFTER_COLON_IN_MEMBER_INITIALIZER_LISTS/@EntryValue" value="ON_SINGLE_LINE" type="string" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/MEMBER_INITIALIZER_LIST_STYLE/@EntryValue" value="DO_NOT_CHANGE" type="string" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/PLACE_NAMESPACE_DEFINITIONS_ON_SAME_LINE/@EntryValue" value="false" type="bool" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_AFTER_COLON_IN_BITFIELD_DECLARATOR/@EntryValue" value="true" type="bool" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_BEFORE_COLON_IN_BITFIELD_DECLARATOR/@EntryValue" value="false" type="bool" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_AFTER_EXTENDS_COLON/@EntryValue" value="true" type="bool" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_BEFORE_EXTENDS_COLON/@EntryValue" value="true" type="bool" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_AFTER_FOR_COLON/@EntryValue" value="true" type="bool" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_BEFORE_FOR_COLON/@EntryValue" value="false" type="bool" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_AFTER_PTR_IN_DATA_MEMBER/@EntryValue" value="false" type="bool" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_AFTER_PTR_IN_DATA_MEMBERS/@EntryValue" value="false" type="bool" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_AFTER_PTR_IN_METHOD/@EntryValue" value="false" type="bool" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_AFTER_PTR_IN_NESTED_DECLARATOR/@EntryValue" value="false" type="bool" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_AFTER_REF_IN_DATA_MEMBER/@EntryValue" value="false" type="bool" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_AFTER_REF_IN_DATA_MEMBERS/@EntryValue" value="false" type="bool" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_AFTER_REF_IN_METHOD/@EntryValue" value="false" type="bool" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_BEFORE_PTR_IN_ABSTRACT_DECL/@EntryValue" value="true" type="bool" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_BEFORE_PTR_IN_DATA_MEMBER/@EntryValue" value="true" type="bool" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_BEFORE_PTR_IN_DATA_MEMBERS/@EntryValue" value="true" type="bool" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_BEFORE_PTR_IN_METHOD/@EntryValue" value="true" type="bool" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_BEFORE_REF_IN_ABSTRACT_DECL/@EntryValue" value="true" type="bool" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_BEFORE_REF_IN_DATA_MEMBER/@EntryValue" value="true" type="bool" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_BEFORE_REF_IN_DATA_MEMBERS/@EntryValue" value="true" type="bool" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_BEFORE_REF_IN_METHOD/@EntryValue" value="true" type="bool" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_BEFORE_TEMPLATE_ARGS/@EntryValue" value="false" type="bool" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_BEFORE_TEMPLATE_PARAMS/@EntryValue" value="false" type="bool" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_BETWEEN_CLOSING_ANGLE_BRACKETS_IN_TEMPLATE_ARGS/@EntryValue" value="true" type="bool" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_WITHIN_EMPTY_TEMPLATE_PARAMS/@EntryValue" value="false" type="bool" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_WITHIN_TEMPLATE_ARGS/@EntryValue" value="false" type="bool" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_WITHIN_TEMPLATE_PARAMS/@EntryValue" value="false" type="bool" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_WITHIN_DECLARATION_PARENTHESES/@EntryValue" value="false" type="bool" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_WITHIN_EMPTY_BLOCKS/@EntryValue" value="false" type="bool" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/WRAP_BEFORE_INVOCATION_LPAR/@EntryValue" value="false" type="bool" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/WRAP_AFTER_INVOCATION_LPAR/@EntryValue" value="false" type="bool" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/WRAP_BEFORE_INVOCATION_RPAR/@EntryValue" value="false" type="bool" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/WRAP_BEFORE_DECLARATION_LPAR/@EntryValue" value="false" type="bool" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/WRAP_AFTER_DECLARATION_LPAR/@EntryValue" value="false" type="bool" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/WRAP_BEFORE_DECLARATION_RPAR/@EntryValue" value="false" type="bool" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/WRAP_ARGUMENTS_STYLE/@EntryValue" value="WRAP_IF_LONG" type="string" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/WRAP_PARAMETERS_STYLE/@EntryValue" value="WRAP_IF_LONG" type="string" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/BREAK_TEMPLATE_DECLARATION/@EntryValue" value="LINE_BREAK" type="string" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/NAMESPACE_DECLARATION_BRACES/@EntryValue" value="END_OF_LINE" type="string" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/FREE_BLOCK_BRACES/@EntryValue" value="END_OF_LINE" type="string" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/INVOCABLE_DECLARATION_BRACES/@EntryValue" value="END_OF_LINE" type="string" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/ANONYMOUS_METHOD_DECLARATION_BRACES/@EntryValue" value="END_OF_LINE" type="string" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/INITIALIZER_BRACES/@EntryValue" value="END_OF_LINE_NO_SPACE" type="string" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/INDENT_STYLE/@EntryValue" value="Space" type="string" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/INDENT_SIZE/@EntryValue" value="4" type="int" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/CONTINUOUS_LINE_INDENT/@EntryValue" value="Double" type="string" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/TAB_WIDTH/@EntryValue" value="4" type="int" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppSmartPointerVsMakeFunction/@EntryIndexedValue" value="SUGGESTION" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppSmartPointerVsMakeFunction/@EntryIndexRemoved" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppCStyleCast/@EntryIndexedValue" value="SUGGESTION" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppCStyleCast/@EntryIndexRemoved" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppFunctionalStyleCast/@EntryIndexedValue" value="SUGGESTION" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppFunctionalStyleCast/@EntryIndexRemoved" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppReinterpretCastFromVoidPtr/@EntryIndexedValue" value="SUGGESTION" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppReinterpretCastFromVoidPtr/@EntryIndexRemoved" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppNonExplicitConvertingConstructor/@EntryIndexedValue" value="HINT" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppNonExplicitConvertingConstructor/@EntryIndexRemoved" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppNonExplicitConversionOperator/@EntryIndexedValue" value="HINT" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppNonExplicitConversionOperator/@EntryIndexRemoved" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppDiscardedPostfixOperatorResult/@EntryIndexedValue" value="SUGGESTION" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppDiscardedPostfixOperatorResult/@EntryIndexRemoved" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppConstValueFunctionReturnType/@EntryIndexedValue" value="SUGGESTION" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppConstValueFunctionReturnType/@EntryIndexRemoved" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppMemberFunctionMayBeConst/@EntryIndexedValue" value="SUGGESTION" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppMemberFunctionMayBeConst/@EntryIndexRemoved" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppMemberFunctionMayBeStatic/@EntryIndexedValue" value="SUGGESTION" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppMemberFunctionMayBeStatic/@EntryIndexRemoved" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppLocalVariableMayBeConst/@EntryIndexedValue" value="HINT" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppLocalVariableMayBeConst/@EntryIndexRemoved" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppParameterMayBeConst/@EntryIndexedValue" value="HINT" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppParameterMayBeConst/@EntryIndexRemoved" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppVariableCanBeMadeConstexpr/@EntryIndexedValue" value="SUGGESTION" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppVariableCanBeMadeConstexpr/@EntryIndexRemoved" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppParameterMayBeConstPtrOrRef/@EntryIndexedValue" value="SUGGESTION" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppParameterMayBeConstPtrOrRef/@EntryIndexRemoved" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppPassValueParameterByConstReference/@EntryIndexedValue" value="SUGGESTION" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppPassValueParameterByConstReference/@EntryIndexRemoved" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppThrowExpressionCanBeReplacedWithRethrow/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppThrowExpressionCanBeReplacedWithRethrow/@EntryIndexRemoved" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppZeroConstantCanBeReplacedWithNullptr/@EntryIndexedValue" value="SUGGESTION" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppZeroConstantCanBeReplacedWithNullptr/@EntryIndexRemoved" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppCompileTimeConstantCanBeReplacedWithBooleanConstant/@EntryIndexedValue" value="SUGGESTION" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppCompileTimeConstantCanBeReplacedWithBooleanConstant/@EntryIndexRemoved" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppIfCanBeReplacedByConstexprIf/@EntryIndexedValue" value="SUGGESTION" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppIfCanBeReplacedByConstexprIf/@EntryIndexRemoved" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=IfStdIsConstantEvaluatedCanBeReplaced/@EntryIndexedValue" value="SUGGESTION" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=IfStdIsConstantEvaluatedCanBeReplaced/@EntryIndexRemoved" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=StdIsConstantEvaluatedWillAlwaysEvaluateToConstant/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=StdIsConstantEvaluatedWillAlwaysEvaluateToConstant/@EntryIndexRemoved" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=ConstevalIfIsAlwaysConstant/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=ConstevalIfIsAlwaysConstant/@EntryIndexRemoved" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppClassCanBeFinal/@EntryIndexedValue" value="HINT" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppClassCanBeFinal/@EntryIndexRemoved" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppUseStructuredBinding/@EntryIndexedValue" value="HINT" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppUseStructuredBinding/@EntryIndexRemoved" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppUseTypeTraitAlias/@EntryIndexedValue" value="SUGGESTION" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppUseTypeTraitAlias/@EntryIndexRemoved" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppUseAlgorithmWithCount/@EntryIndexedValue" value="SUGGESTION" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppUseAlgorithmWithCount/@EntryIndexRemoved" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppUseRangeAlgorithm/@EntryIndexedValue" value="SUGGESTION" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppUseRangeAlgorithm/@EntryIndexRemoved" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppUseElementsView/@EntryIndexedValue" value="SUGGESTION" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppUseElementsView/@EntryIndexRemoved" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppUseStdSize/@EntryIndexedValue" value="SUGGESTION" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppUseStdSize/@EntryIndexRemoved" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppForLoopCanBeReplacedWithWhile/@EntryIndexedValue" value="SUGGESTION" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppForLoopCanBeReplacedWithWhile/@EntryIndexRemoved" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppJoinDeclarationAndAssignment/@EntryIndexedValue" value="SUGGESTION" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppJoinDeclarationAndAssignment/@EntryIndexRemoved" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppReplaceTieWithStructuredBinding/@EntryIndexedValue" value="SUGGESTION" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppReplaceTieWithStructuredBinding/@EntryIndexRemoved" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppReplaceMemsetWithZeroInitialization/@EntryIndexedValue" value="SUGGESTION" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppReplaceMemsetWithZeroInitialization/@EntryIndexRemoved" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppUseAssociativeContains/@EntryIndexedValue" value="SUGGESTION" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppUseAssociativeContains/@EntryIndexRemoved" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppUseEraseAlgorithm/@EntryIndexedValue" value="SUGGESTION" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppUseEraseAlgorithm/@EntryIndexRemoved" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppUseFamiliarTemplateSyntaxForGenericLambdas/@EntryIndexedValue" value="SUGGESTION" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppUseFamiliarTemplateSyntaxForGenericLambdas/@EntryIndexRemoved" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppTooWideScope/@EntryIndexedValue" value="SUGGESTION" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppTooWideScope/@EntryIndexRemoved" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppTooWideScopeInitStatement/@EntryIndexedValue" value="HINT" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppTooWideScopeInitStatement/@EntryIndexRemoved" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppRedundantNamespaceDefinition/@EntryIndexedValue" value="SUGGESTION" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppRedundantNamespaceDefinition/@EntryIndexRemoved" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppNonInlineFunctionDefinitionInHeaderFile/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppNonInlineFunctionDefinitionInHeaderFile/@EntryIndexRemoved" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppNonInlineVariableDefinitionInHeaderFile/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppNonInlineVariableDefinitionInHeaderFile/@EntryIndexRemoved" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppFunctionIsNotImplemented/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppFunctionIsNotImplemented/@EntryIndexRemoved" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppPrivateSpecialMemberFunctionIsNotImplemented/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppPrivateSpecialMemberFunctionIsNotImplemented/@EntryIndexRemoved" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppHiddenFunction/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppHiddenFunction/@EntryIndexRemoved" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppHidingFunction/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppHidingFunction/@EntryIndexRemoved" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppPolymorphicClassWithNonVirtualPublicDestructor/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppPolymorphicClassWithNonVirtualPublicDestructor/@EntryIndexRemoved" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppAbstractClassWithoutSpecifier/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppAbstractClassWithoutSpecifier/@EntryIndexRemoved" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppIncompleteSwitchStatement/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppIncompleteSwitchStatement/@EntryIndexRemoved" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppDefaultCaseNotHandledInSwitchStatement/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppDefaultCaseNotHandledInSwitchStatement/@EntryIndexRemoved" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppPossiblyErroneousEmptyStatements/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppPossiblyErroneousEmptyStatements/@EntryIndexRemoved" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppExpressionWithoutSideEffects/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppExpressionWithoutSideEffects/@EntryIndexRemoved" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppNoDiscardExpression/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppNoDiscardExpression/@EntryIndexRemoved" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppFunctionResultShouldBeUsed/@EntryIndexedValue" value="HINT" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppFunctionResultShouldBeUsed/@EntryIndexRemoved" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppMissingKeywordThrow/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppMissingKeywordThrow/@EntryIndexRemoved" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppDependentTypeWithoutTypenameKeyword/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppDependentTypeWithoutTypenameKeyword/@EntryIndexRemoved" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppDependentTemplateWithoutTemplateKeyword/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppDependentTemplateWithoutTemplateKeyword/@EntryIndexRemoved" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppImplicitDefaultConstructorNotAvailable/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppImplicitDefaultConstructorNotAvailable/@EntryIndexRemoved" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppClassNeedsConstructorBecauseOfUninitializedMember/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppClassNeedsConstructorBecauseOfUninitializedMember/@EntryIndexRemoved" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppUninitializedNonStaticDataMember/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppUninitializedNonStaticDataMember/@EntryIndexRemoved" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppRangeBasedForIncompatibleReference/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppRangeBasedForIncompatibleReference/@EntryIndexRemoved" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppZeroValuedExpressionUsedAsNullPointer/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppZeroValuedExpressionUsedAsNullPointer/@EntryIndexRemoved" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppPossiblyUnintendedObjectSlicing/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppPossiblyUnintendedObjectSlicing/@EntryIndexRemoved" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppPossiblyUninitializedMember/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppPossiblyUninitializedMember/@EntryIndexRemoved" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppDeclaratorDisambiguatedAsFunction/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppDeclaratorDisambiguatedAsFunction/@EntryIndexRemoved" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppVirtualFunctionInFinalClass/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppVirtualFunctionInFinalClass/@EntryIndexRemoved" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppMustBePublicVirtualToImplementInterface/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppMustBePublicVirtualToImplementInterface/@EntryIndexRemoved" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppDeclarationSpecifierWithoutDeclarators/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppDeclarationSpecifierWithoutDeclarators/@EntryIndexRemoved" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppEmptyDeclaration/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppEmptyDeclaration/@EntryIndexRemoved" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppDeclarationHidesLocal/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppDeclarationHidesLocal/@EntryIndexRemoved" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppDeclarationHidesUncapturedLocal/@EntryIndexedValue" value="HINT" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppDeclarationHidesUncapturedLocal/@EntryIndexRemoved" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppMismatchedClassTags/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppMismatchedClassTags/@EntryIndexRemoved" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppUsingResultOfAssignmentAsCondition/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppUsingResultOfAssignmentAsCondition/@EntryIndexRemoved" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppIntegralToPointerConversion/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppIntegralToPointerConversion/@EntryIndexRemoved" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppPointerToIntegralConversion/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppPointerToIntegralConversion/@EntryIndexRemoved" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppIncompatiblePointerConversion/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppIncompatiblePointerConversion/@EntryIndexRemoved" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppPointerConversionDropsQualifiers/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppPointerConversionDropsQualifiers/@EntryIndexRemoved" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppStringLiteralToCharPointerConversion/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppStringLiteralToCharPointerConversion/@EntryIndexRemoved" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppNonExceptionSafeResourceAcquisition/@EntryIndexedValue" value="HINT" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppNonExceptionSafeResourceAcquisition/@EntryIndexRemoved" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppVirtualFunctionCallInsideCtor/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppVirtualFunctionCallInsideCtor/@EntryIndexRemoved" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppAbstractVirtualFunctionCallInCtor/@EntryIndexedValue" value="ERROR" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppAbstractVirtualFunctionCallInCtor/@EntryIndexRemoved" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppInvalidLineContinuation/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppInvalidLineContinuation/@EntryIndexRemoved" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppPrintfBadFormat/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppPrintfBadFormat/@EntryIndexRemoved" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppPrintfRiskyFormat/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppPrintfRiskyFormat/@EntryIndexRemoved" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppPrintfMissedArg/@EntryIndexedValue" value="ERROR" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppPrintfMissedArg/@EntryIndexRemoved" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppPrintfExtraArg/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppPrintfExtraArg/@EntryIndexRemoved" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppBoostFormatBadCode/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppBoostFormatBadCode/@EntryIndexRemoved" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppBoostFormatLegacyCode/@EntryIndexedValue" value="SUGGESTION" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppBoostFormatLegacyCode/@EntryIndexRemoved" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppBoostFormatMixedArgs/@EntryIndexedValue" value="ERROR" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppBoostFormatMixedArgs/@EntryIndexRemoved" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppBoostFormatTooFewArgs/@EntryIndexedValue" value="ERROR" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppBoostFormatTooFewArgs/@EntryIndexRemoved" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppBoostFormatTooManyArgs/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppBoostFormatTooManyArgs/@EntryIndexRemoved" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppDeprecatedEntity/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppDeprecatedEntity/@EntryIndexRemoved" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppMissingIncludeGuard/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppMissingIncludeGuard/@EntryIndexRemoved" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppDoxygenSyntaxError/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppDoxygenSyntaxError/@EntryIndexRemoved" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppDoxygenUnresolvedReference/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppDoxygenUnresolvedReference/@EntryIndexRemoved" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppDoxygenUndocumentedParameter/@EntryIndexedValue" value="SUGGESTION" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppDoxygenUndocumentedParameter/@EntryIndexRemoved" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppDeletingVoidPointer/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppDeletingVoidPointer/@EntryIndexRemoved" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppBooleanIncrementExpression/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppBooleanIncrementExpression/@EntryIndexRemoved" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppDeprecatedRegisterStorageClassSpecifier/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppDeprecatedRegisterStorageClassSpecifier/@EntryIndexRemoved" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppIdenticalOperandsInBinaryExpression/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppIdenticalOperandsInBinaryExpression/@EntryIndexRemoved" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppEqualOperandsInBinaryExpression/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppEqualOperandsInBinaryExpression/@EntryIndexRemoved" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppRedefinitionOfDefaultArgumentInOverrideFunction/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppRedefinitionOfDefaultArgumentInOverrideFunction/@EntryIndexRemoved" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppUnnamedNamespaceInHeaderFile/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppUnnamedNamespaceInHeaderFile/@EntryIndexRemoved" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppParameterNamesMismatch/@EntryIndexedValue" value="HINT" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppParameterNamesMismatch/@EntryIndexRemoved" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppDefaultedSpecialMemberFunctionIsImplicitlyDeleted/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppDefaultedSpecialMemberFunctionIsImplicitlyDeleted/@EntryIndexRemoved" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppNodiscardFunctionWithoutReturnValue/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppNodiscardFunctionWithoutReturnValue/@EntryIndexRemoved" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppRedundantComplexityInComparison/@EntryIndexedValue" value="SUGGESTION" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppRedundantComplexityInComparison/@EntryIndexRemoved" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppAbstractFinalClass/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppAbstractFinalClass/@EntryIndexRemoved" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppSpecialFunctionWithoutNoexceptSpecification/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppSpecialFunctionWithoutNoexceptSpecification/@EntryIndexRemoved" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppUnsignedZeroComparison/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppUnsignedZeroComparison/@EntryIndexRemoved" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppMultiCharacterLiteral/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppMultiCharacterLiteral/@EntryIndexRemoved" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppMultiCharacterWideLiteral/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppMultiCharacterWideLiteral/@EntryIndexRemoved" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppRedundantQualifier/@EntryIndexedValue" value="HINT" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppRedundantQualifier/@EntryIndexRemoved" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppRedundantAccessSpecifier/@EntryIndexedValue" value="HINT" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppRedundantAccessSpecifier/@EntryIndexRemoved" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppAccessSpecifierWithNoDeclarations/@EntryIndexedValue" value="SUGGESTION" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppAccessSpecifierWithNoDeclarations/@EntryIndexRemoved" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppRedundantTypenameKeyword/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppRedundantTypenameKeyword/@EntryIndexRemoved" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppRedundantTemplateKeyword/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppRedundantTemplateKeyword/@EntryIndexRemoved" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppRedundantElseKeyword/@EntryIndexedValue" value="HINT" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppRedundantElseKeyword/@EntryIndexRemoved" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppRedundantElseKeywordInsideCompoundStatement/@EntryIndexedValue" value="HINT" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppRedundantElseKeywordInsideCompoundStatement/@EntryIndexRemoved" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppRedundantControlFlowJump/@EntryIndexedValue" value="HINT" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppRedundantControlFlowJump/@EntryIndexRemoved" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppRedundantEmptyStatement/@EntryIndexedValue" value="HINT" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppRedundantEmptyStatement/@EntryIndexRemoved" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppRedundantEmptyDeclaration/@EntryIndexedValue" value="HINT" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppRedundantEmptyDeclaration/@EntryIndexRemoved" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppRedundantParentheses/@EntryIndexedValue" value="HINT" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppRedundantParentheses/@EntryIndexRemoved" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppRedundantLambdaParameterList/@EntryIndexedValue" value="HINT" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppRedundantLambdaParameterList/@EntryIndexRemoved" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppRedundantCastExpression/@EntryIndexedValue" value="HINT" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppRedundantCastExpression/@EntryIndexRemoved" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppHeaderHasBeenAlreadyIncluded/@EntryIndexedValue" value="HINT" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppHeaderHasBeenAlreadyIncluded/@EntryIndexRemoved" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppTemplateArgumentsCanBeDeduced/@EntryIndexedValue" value="HINT" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppTemplateArgumentsCanBeDeduced/@EntryIndexRemoved" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppRedundantTemplateArguments/@EntryIndexedValue" value="HINT" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppRedundantTemplateArguments/@EntryIndexRemoved" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppStaticSpecifierOnAnonymousNamespaceMember/@EntryIndexedValue" value="SUGGESTION" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppStaticSpecifierOnAnonymousNamespaceMember/@EntryIndexRemoved" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppRedundantStaticSpecifierOnMemberAllocationFunction/@EntryIndexedValue" value="HINT" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppRedundantStaticSpecifierOnMemberAllocationFunction/@EntryIndexRemoved" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppRedundantStaticSpecifierOnThreadLocalLocalVariable/@EntryIndexedValue" value="HINT" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppRedundantStaticSpecifierOnThreadLocalLocalVariable/@EntryIndexRemoved" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppRedundantBaseClassAccessSpecifier/@EntryIndexedValue" value="HINT" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppRedundantBaseClassAccessSpecifier/@EntryIndexRemoved" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppRedundantInlineSpecifier/@EntryIndexedValue" value="HINT" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppRedundantInlineSpecifier/@EntryIndexRemoved" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppRedundantConstSpecifier/@EntryIndexedValue" value="HINT" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppRedundantConstSpecifier/@EntryIndexRemoved" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppRedundantBooleanExpressionArgument/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppRedundantBooleanExpressionArgument/@EntryIndexRemoved" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppRedundantVoidArgumentList/@EntryIndexedValue" value="SUGGESTION" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppRedundantVoidArgumentList/@EntryIndexRemoved" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppRedundantMemberInitializer/@EntryIndexedValue" value="SUGGESTION" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppRedundantMemberInitializer/@EntryIndexRemoved" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppRedundantBaseClassInitializer/@EntryIndexedValue" value="SUGGESTION" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppRedundantBaseClassInitializer/@EntryIndexRemoved" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppConstParameterInDeclaration/@EntryIndexedValue" value="SUGGESTION" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppConstParameterInDeclaration/@EntryIndexRemoved" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppVolatileParameterInDeclaration/@EntryIndexedValue" value="SUGGESTION" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppVolatileParameterInDeclaration/@EntryIndexRemoved" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppFinalFunctionInFinalClass/@EntryIndexedValue" value="SUGGESTION" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppFinalFunctionInFinalClass/@EntryIndexRemoved" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppFinalNonOverridingVirtualFunction/@EntryIndexedValue" value="SUGGESTION" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppFinalNonOverridingVirtualFunction/@EntryIndexRemoved" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppRedundantElaboratedTypeSpecifier/@EntryIndexedValue" value="HINT" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppRedundantElaboratedTypeSpecifier/@EntryIndexRemoved" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppRedundantDereferencingAndTakingAddress/@EntryIndexedValue" value="SUGGESTION" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppRedundantDereferencingAndTakingAddress/@EntryIndexRemoved" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppRedundantConditionalExpression/@EntryIndexedValue" value="SUGGESTION" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppRedundantConditionalExpression/@EntryIndexRemoved" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppConditionalExpressionCanBeSimplified/@EntryIndexedValue" value="SUGGESTION" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppConditionalExpressionCanBeSimplified/@EntryIndexRemoved" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppRedundantExportKeyword/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppRedundantExportKeyword/@EntryIndexRemoved" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppRedundantZeroInitializerInAggregateInitialization/@EntryIndexedValue" value="SUGGESTION" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppRedundantZeroInitializerInAggregateInitialization/@EntryIndexRemoved" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppUserDefinedLiteralSuffixDoesNotStartWithUnderscore/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppUserDefinedLiteralSuffixDoesNotStartWithUnderscore/@EntryIndexRemoved" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppClassIsIncomplete/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppClassIsIncomplete/@EntryIndexRemoved" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppTemplateParameterShadowing/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppTemplateParameterShadowing/@EntryIndexRemoved" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppMutableSpecifierOnReferenceMember/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppMutableSpecifierOnReferenceMember/@EntryIndexRemoved" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppDefaultInitializationWithNoUserConstructor/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppDefaultInitializationWithNoUserConstructor/@EntryIndexRemoved" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppExplicitSpecializationInNonNamespaceScope/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppExplicitSpecializationInNonNamespaceScope/@EntryIndexRemoved" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppUnionMemberOfReferenceType/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppUnionMemberOfReferenceType/@EntryIndexRemoved" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppUninitializedDependentBaseClass/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppUninitializedDependentBaseClass/@EntryIndexRemoved" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppPrecompiledHeaderIsNotIncluded/@EntryIndexedValue" value="ERROR" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppPrecompiledHeaderIsNotIncluded/@EntryIndexRemoved" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppPrecompiledHeaderNotFound/@EntryIndexedValue" value="ERROR" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppPrecompiledHeaderNotFound/@EntryIndexRemoved" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppCoroutineCallResolveError/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppCoroutineCallResolveError/@EntryIndexRemoved" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppAwaiterTypeIsNotClass/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppAwaiterTypeIsNotClass/@EntryIndexRemoved" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppOutParameterMustBeWritten/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppOutParameterMustBeWritten/@EntryIndexRemoved" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppWarningDirective/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppWarningDirective/@EntryIndexRemoved" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppStaticAssertFailure/@EntryIndexedValue" value="ERROR" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppStaticAssertFailure/@EntryIndexRemoved" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppEvaluationFailure/@EntryIndexedValue" value="ERROR" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppEvaluationFailure/@EntryIndexRemoved" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppDeclaratorNeverUsed/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppDeclaratorNeverUsed/@EntryIndexRemoved" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppTypeAliasNeverUsed/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppTypeAliasNeverUsed/@EntryIndexRemoved" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppConceptNeverUsed/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppConceptNeverUsed/@EntryIndexRemoved" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppClassNeverUsed/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppClassNeverUsed/@EntryIndexRemoved" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppEnumeratorNeverUsed/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppEnumeratorNeverUsed/@EntryIndexRemoved" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppLambdaCaptureNeverUsed/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppLambdaCaptureNeverUsed/@EntryIndexRemoved" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppLocalVariableWithNonTrivialDtorIsNeverUsed/@EntryIndexedValue" value="DO_NOT_SHOW" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppLocalVariableWithNonTrivialDtorIsNeverUsed/@EntryIndexRemoved" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppParameterNeverUsed/@EntryIndexedValue" value="HINT" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppParameterNeverUsed/@EntryIndexRemoved" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppTemplateParameterNeverUsed/@EntryIndexedValue" value="HINT" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppTemplateParameterNeverUsed/@EntryIndexRemoved" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppEntityAssignedButNoRead/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppEntityAssignedButNoRead/@EntryIndexRemoved" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppEntityUsedOnlyInUnevaluatedContext/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppEntityUsedOnlyInUnevaluatedContext/@EntryIndexRemoved" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppLocalVariableMightNotBeInitialized/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppLocalVariableMightNotBeInitialized/@EntryIndexRemoved" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppObjectMemberMightNotBeInitialized/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppObjectMemberMightNotBeInitialized/@EntryIndexRemoved" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppSomeObjectMembersMightNotBeInitialized/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppSomeObjectMembersMightNotBeInitialized/@EntryIndexRemoved" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppDeclaratorUsedBeforeInitialization/@EntryIndexedValue" value="ERROR" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppDeclaratorUsedBeforeInitialization/@EntryIndexRemoved" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppUnusedIncludeDirective/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppUnusedIncludeDirective/@EntryIndexRemoved" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppNotAllPathsReturnValue/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppNotAllPathsReturnValue/@EntryIndexRemoved" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CDeclarationWithImplicitIntType/@EntryIndexedValue" value="WARNING" type="string" /> <option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CDeclarationWithImplicitIntType/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CDeclarationWithImplicitIntType/@EntryIndexRemoved" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppFunctionDoesntReturnValue/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppFunctionDoesntReturnValue/@EntryIndexRemoved" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppReturnNoValueInNonVoidFunction/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppReturnNoValueInNonVoidFunction/@EntryIndexRemoved" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppCVQualifierCanNotBeAppliedToReference/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppCVQualifierCanNotBeAppliedToReference/@EntryIndexRemoved" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppDereferenceOperatorLimitExceeded/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppDereferenceOperatorLimitExceeded/@EntryIndexRemoved" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppForwardEnumDeclarationWithoutUnderlyingType/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppForwardEnumDeclarationWithoutUnderlyingType/@EntryIndexRemoved" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppUnmatchedPragmaRegionDirective/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppUnmatchedPragmaRegionDirective/@EntryIndexRemoved" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppUnmatchedPragmaEndRegionDirective/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppUnmatchedPragmaEndRegionDirective/@EntryIndexRemoved" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppStaticDataMemberInUnnamedStruct/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppStaticDataMemberInUnnamedStruct/@EntryIndexRemoved" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppDefaultIsUsedAsIdentifier/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppDefaultIsUsedAsIdentifier/@EntryIndexRemoved" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppLongFloat/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppLongFloat/@EntryIndexRemoved" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppMsExtReinterpretCastFromNullptr/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppMsExtReinterpretCastFromNullptr/@EntryIndexRemoved" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppMsExtBindingRValueToLvalueReference/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppMsExtBindingRValueToLvalueReference/@EntryIndexRemoved" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppMsExtAddressOfClassRValue/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppMsExtAddressOfClassRValue/@EntryIndexRemoved" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppMsExtDoubleUserConversionInCopyInit/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppMsExtDoubleUserConversionInCopyInit/@EntryIndexRemoved" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppMsExtCopyElisionInCopyInitDeclarator/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppMsExtCopyElisionInCopyInitDeclarator/@EntryIndexRemoved" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppMsExtNotInitializedStaticConstLocalVar/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppMsExtNotInitializedStaticConstLocalVar/@EntryIndexRemoved" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppRemoveRedundantBraces/@EntryIndexedValue" value="DO_NOT_SHOW" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppRemoveRedundantBraces/@EntryIndexRemoved" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppEnforceIfStatementBraces/@EntryIndexedValue" value="DO_NOT_SHOW" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppEnforceIfStatementBraces/@EntryIndexRemoved" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppEnforceForStatementBraces/@EntryIndexedValue" value="DO_NOT_SHOW" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppEnforceForStatementBraces/@EntryIndexRemoved" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppEnforceWhileStatementBraces/@EntryIndexedValue" value="DO_NOT_SHOW" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppEnforceWhileStatementBraces/@EntryIndexRemoved" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppEnforceDoStatementBraces/@EntryIndexedValue" value="DO_NOT_SHOW" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppEnforceDoStatementBraces/@EntryIndexRemoved" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppWrongIncludesOrder/@EntryIndexedValue" value="HINT" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppWrongIncludesOrder/@EntryIndexRemoved" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppWrongSlashesInIncludeDirective/@EntryIndexedValue" value="HINT" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppWrongSlashesInIncludeDirective/@EntryIndexRemoved" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppEnforceNestedNamespacesStyle/@EntryIndexedValue" value="HINT" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppEnforceNestedNamespacesStyle/@EntryIndexRemoved" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppEnforceTypeAliasCodeStyle/@EntryIndexedValue" value="DO_NOT_SHOW" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppEnforceTypeAliasCodeStyle/@EntryIndexRemoved" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppEnforceFunctionDeclarationStyle/@EntryIndexedValue" value="DO_NOT_SHOW" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppEnforceFunctionDeclarationStyle/@EntryIndexRemoved" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppMemberInitializersOrder/@EntryIndexedValue" value="SUGGESTION" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppMemberInitializersOrder/@EntryIndexRemoved" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppEnforceOverridingFunctionStyle/@EntryIndexedValue" value="SUGGESTION" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppEnforceOverridingFunctionStyle/@EntryIndexRemoved" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppEnforceOverridingDestructorStyle/@EntryIndexedValue" value="SUGGESTION" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppEnforceOverridingDestructorStyle/@EntryIndexRemoved" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppUseAuto/@EntryIndexedValue" value="HINT" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppUseAuto/@EntryIndexRemoved" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppUseAutoForNumeric/@EntryIndexedValue" value="HINT" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppUseAutoForNumeric/@EntryIndexRemoved" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppEnforceCVQualifiersPlacement/@EntryIndexedValue" value="DO_NOT_SHOW" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppEnforceCVQualifiersPlacement/@EntryIndexRemoved" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppEnforceCVQualifiersOrder/@EntryIndexedValue" value="DO_NOT_SHOW" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppEnforceCVQualifiersOrder/@EntryIndexRemoved" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppUnnecessaryWhitespace/@EntryIndexedValue" value="DO_NOT_SHOW" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppUnnecessaryWhitespace/@EntryIndexRemoved" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppTabsAreDisallowed/@EntryIndexedValue" value="DO_NOT_SHOW" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppTabsAreDisallowed/@EntryIndexRemoved" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppDFAConstantConditions/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppDFAConstantConditions/@EntryIndexRemoved" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppDFANullDereference/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppDFANullDereference/@EntryIndexRemoved" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppDFANotInitializedField/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppDFANotInitializedField/@EntryIndexRemoved" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppDFALoopConditionNotUpdated/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppDFALoopConditionNotUpdated/@EntryIndexRemoved" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppDFADeletedPointer/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppDFADeletedPointer/@EntryIndexRemoved" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppDFAMemoryLeak/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppDFAMemoryLeak/@EntryIndexRemoved" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppDFAInvalidatedMemory/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppDFAInvalidatedMemory/@EntryIndexRemoved" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppDFALocalValueEscapesScope/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppDFALocalValueEscapesScope/@EntryIndexRemoved" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppDFALocalValueEscapesFunction/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppDFALocalValueEscapesFunction/@EntryIndexRemoved" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppDFAConstantParameter/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppDFAConstantParameter/@EntryIndexRemoved" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppDFAConstantFunctionResult/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppDFAConstantFunctionResult/@EntryIndexRemoved" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppDFAArrayIndexOutOfBounds/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppDFAArrayIndexOutOfBounds/@EntryIndexRemoved" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppDFAUnreachableCode/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppDFAUnreachableCode/@EntryIndexRemoved" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppDFAUnreachableFunctionCall/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppDFAUnreachableFunctionCall/@EntryIndexRemoved" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppDFAEndlessLoop/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppDFAEndlessLoop/@EntryIndexRemoved" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppDFAInfiniteRecursion/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppDFAInfiniteRecursion/@EntryIndexRemoved" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppDFAUnusedValue/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppDFAUnusedValue/@EntryIndexRemoved" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppDFAUnreadVariable/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppDFAUnreadVariable/@EntryIndexRemoved" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppDFATimeOver/@EntryIndexedValue" value="HINT" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppDFATimeOver/@EntryIndexRemoved" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppInconsistentNaming/@EntryIndexedValue" value="DO_NOT_SHOW" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppInconsistentNaming/@EntryIndexRemoved" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=StringLiteralTypo/@EntryIndexedValue" value="DO_NOT_SHOW" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=StringLiteralTypo/@EntryIndexRemoved" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CommentTypo/@EntryIndexedValue" value="DO_NOT_SHOW" type="string" /> <option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CommentTypo/@EntryIndexedValue" value="DO_NOT_SHOW" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CommentTypo/@EntryIndexRemoved" /> <option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=ConstevalIfIsAlwaysConstant/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppAbstractClassWithoutSpecifier/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppAbstractFinalClass/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppAbstractVirtualFunctionCallInCtor/@EntryIndexedValue" value="ERROR" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppAccessSpecifierWithNoDeclarations/@EntryIndexedValue" value="SUGGESTION" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppAwaiterTypeIsNotClass/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppBooleanIncrementExpression/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppBoostFormatBadCode/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppBoostFormatLegacyCode/@EntryIndexedValue" value="SUGGESTION" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppBoostFormatMixedArgs/@EntryIndexedValue" value="ERROR" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppBoostFormatTooFewArgs/@EntryIndexedValue" value="ERROR" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppBoostFormatTooManyArgs/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppCStyleCast/@EntryIndexedValue" value="SUGGESTION" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppCVQualifierCanNotBeAppliedToReference/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppClassCanBeFinal/@EntryIndexedValue" value="HINT" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppClassIsIncomplete/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppClassNeedsConstructorBecauseOfUninitializedMember/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppClassNeverUsed/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppCompileTimeConstantCanBeReplacedWithBooleanConstant/@EntryIndexedValue" value="SUGGESTION" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppConceptNeverUsed/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppConditionalExpressionCanBeSimplified/@EntryIndexedValue" value="SUGGESTION" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppConstParameterInDeclaration/@EntryIndexedValue" value="SUGGESTION" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppConstValueFunctionReturnType/@EntryIndexedValue" value="SUGGESTION" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppCoroutineCallResolveError/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppDFAArrayIndexOutOfBounds/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppDFAConstantConditions/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppDFAConstantFunctionResult/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppDFAConstantParameter/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppDFADeletedPointer/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppDFAEndlessLoop/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppDFAInfiniteRecursion/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppDFAInvalidatedMemory/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppDFALocalValueEscapesFunction/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppDFALocalValueEscapesScope/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppDFALoopConditionNotUpdated/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppDFAMemoryLeak/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppDFANotInitializedField/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppDFANullDereference/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppDFATimeOver/@EntryIndexedValue" value="HINT" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppDFAUnreachableCode/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppDFAUnreachableFunctionCall/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppDFAUnreadVariable/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppDFAUnusedValue/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppDeclarationHidesLocal/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppDeclarationHidesUncapturedLocal/@EntryIndexedValue" value="HINT" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppDeclarationSpecifierWithoutDeclarators/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppDeclaratorDisambiguatedAsFunction/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppDeclaratorNeverUsed/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppDeclaratorUsedBeforeInitialization/@EntryIndexedValue" value="ERROR" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppDefaultCaseNotHandledInSwitchStatement/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppDefaultInitializationWithNoUserConstructor/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppDefaultIsUsedAsIdentifier/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppDefaultedSpecialMemberFunctionIsImplicitlyDeleted/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppDeletingVoidPointer/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppDependentTemplateWithoutTemplateKeyword/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppDependentTypeWithoutTypenameKeyword/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppDeprecatedEntity/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppDeprecatedOverridenMethod/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppDeprecatedRegisterStorageClassSpecifier/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppDereferenceOperatorLimitExceeded/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppDiscardedPostfixOperatorResult/@EntryIndexedValue" value="SUGGESTION" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppDoxygenSyntaxError/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppDoxygenUndocumentedParameter/@EntryIndexedValue" value="SUGGESTION" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppDoxygenUnresolvedReference/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppEmptyDeclaration/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppEnforceCVQualifiersOrder/@EntryIndexedValue" value="DO_NOT_SHOW" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppEnforceCVQualifiersPlacement/@EntryIndexedValue" value="DO_NOT_SHOW" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppEnforceDoStatementBraces/@EntryIndexedValue" value="DO_NOT_SHOW" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppEnforceForStatementBraces/@EntryIndexedValue" value="DO_NOT_SHOW" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppEnforceFunctionDeclarationStyle/@EntryIndexedValue" value="DO_NOT_SHOW" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppEnforceIfStatementBraces/@EntryIndexedValue" value="DO_NOT_SHOW" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppEnforceNestedNamespacesStyle/@EntryIndexedValue" value="HINT" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppEnforceOverridingDestructorStyle/@EntryIndexedValue" value="SUGGESTION" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppEnforceOverridingFunctionStyle/@EntryIndexedValue" value="SUGGESTION" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppEnforceTypeAliasCodeStyle/@EntryIndexedValue" value="DO_NOT_SHOW" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppEnforceWhileStatementBraces/@EntryIndexedValue" value="DO_NOT_SHOW" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppEntityAssignedButNoRead/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppEntityUsedOnlyInUnevaluatedContext/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppEnumeratorNeverUsed/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppEqualOperandsInBinaryExpression/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppEvaluationFailure/@EntryIndexedValue" value="ERROR" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppExplicitSpecializationInNonNamespaceScope/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppExpressionWithoutSideEffects/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppFinalFunctionInFinalClass/@EntryIndexedValue" value="SUGGESTION" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppFinalNonOverridingVirtualFunction/@EntryIndexedValue" value="SUGGESTION" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppForLoopCanBeReplacedWithWhile/@EntryIndexedValue" value="SUGGESTION" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppForwardEnumDeclarationWithoutUnderlyingType/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppFunctionDoesntReturnValue/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppFunctionIsNotImplemented/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppFunctionResultShouldBeUsed/@EntryIndexedValue" value="HINT" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppFunctionalStyleCast/@EntryIndexedValue" value="SUGGESTION" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppHeaderHasBeenAlreadyIncluded/@EntryIndexedValue" value="HINT" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppHiddenFunction/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppHidingFunction/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppIdenticalOperandsInBinaryExpression/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppIfCanBeReplacedByConstexprIf/@EntryIndexedValue" value="SUGGESTION" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppImplicitDefaultConstructorNotAvailable/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppIncompatiblePointerConversion/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppIncompleteSwitchStatement/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppInconsistentNaming/@EntryIndexedValue" value="DO_NOT_SHOW" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppIntegralToPointerConversion/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppInvalidLineContinuation/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppJoinDeclarationAndAssignment/@EntryIndexedValue" value="SUGGESTION" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppLambdaCaptureNeverUsed/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppLocalVariableMayBeConst/@EntryIndexedValue" value="HINT" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppLocalVariableMightNotBeInitialized/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppLocalVariableWithNonTrivialDtorIsNeverUsed/@EntryIndexedValue" value="DO_NOT_SHOW" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppLongFloat/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppMemberFunctionMayBeConst/@EntryIndexedValue" value="SUGGESTION" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppMemberFunctionMayBeStatic/@EntryIndexedValue" value="SUGGESTION" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppMemberInitializersOrder/@EntryIndexedValue" value="SUGGESTION" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppMismatchedClassTags/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppMissingIncludeGuard/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppMissingKeywordThrow/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppMsExtAddressOfClassRValue/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppMsExtBindingRValueToLvalueReference/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppMsExtCopyElisionInCopyInitDeclarator/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppMsExtDoubleUserConversionInCopyInit/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppMsExtNotInitializedStaticConstLocalVar/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppMsExtReinterpretCastFromNullptr/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppMultiCharacterLiteral/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppMultiCharacterWideLiteral/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppMustBePublicVirtualToImplementInterface/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppMutableSpecifierOnReferenceMember/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppNoDiscardExpression/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppNodiscardFunctionWithoutReturnValue/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppNonExceptionSafeResourceAcquisition/@EntryIndexedValue" value="HINT" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppNonExplicitConversionOperator/@EntryIndexedValue" value="HINT" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppNonExplicitConvertingConstructor/@EntryIndexedValue" value="HINT" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppNonInlineFunctionDefinitionInHeaderFile/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppNonInlineVariableDefinitionInHeaderFile/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppNotAllPathsReturnValue/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppObjectMemberMightNotBeInitialized/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppOutParameterMustBeWritten/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppParameterMayBeConst/@EntryIndexedValue" value="HINT" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppParameterMayBeConstPtrOrRef/@EntryIndexedValue" value="SUGGESTION" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppParameterNamesMismatch/@EntryIndexedValue" value="HINT" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppParameterNeverUsed/@EntryIndexedValue" value="HINT" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppPassValueParameterByConstReference/@EntryIndexedValue" value="SUGGESTION" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppPointerConversionDropsQualifiers/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppPointerToIntegralConversion/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppPolymorphicClassWithNonVirtualPublicDestructor/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppPossiblyErroneousEmptyStatements/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppPossiblyUninitializedMember/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppPossiblyUnintendedObjectSlicing/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppPrecompiledHeaderIsNotIncluded/@EntryIndexedValue" value="ERROR" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppPrecompiledHeaderNotFound/@EntryIndexedValue" value="ERROR" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppPrintfBadFormat/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppPrintfExtraArg/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppPrintfMissedArg/@EntryIndexedValue" value="ERROR" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppPrintfRiskyFormat/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppPrivateSpecialMemberFunctionIsNotImplemented/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppRangeBasedForIncompatibleReference/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppRedefinitionOfDefaultArgumentInOverrideFunction/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppRedundantAccessSpecifier/@EntryIndexedValue" value="HINT" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppRedundantBaseClassAccessSpecifier/@EntryIndexedValue" value="HINT" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppRedundantBaseClassInitializer/@EntryIndexedValue" value="SUGGESTION" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppRedundantBooleanExpressionArgument/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppRedundantCastExpression/@EntryIndexedValue" value="HINT" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppRedundantComplexityInComparison/@EntryIndexedValue" value="SUGGESTION" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppRedundantConditionalExpression/@EntryIndexedValue" value="SUGGESTION" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppRedundantConstSpecifier/@EntryIndexedValue" value="HINT" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppRedundantControlFlowJump/@EntryIndexedValue" value="HINT" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppRedundantDereferencingAndTakingAddress/@EntryIndexedValue" value="SUGGESTION" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppRedundantElaboratedTypeSpecifier/@EntryIndexedValue" value="HINT" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppRedundantElseKeyword/@EntryIndexedValue" value="HINT" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppRedundantElseKeywordInsideCompoundStatement/@EntryIndexedValue" value="HINT" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppRedundantEmptyDeclaration/@EntryIndexedValue" value="HINT" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppRedundantEmptyStatement/@EntryIndexedValue" value="HINT" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppRedundantExportKeyword/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppRedundantFwdClassOrEnumSpecifier/@EntryIndexedValue" value="SUGGESTION" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppRedundantInlineSpecifier/@EntryIndexedValue" value="HINT" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppRedundantLambdaParameterList/@EntryIndexedValue" value="HINT" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppRedundantMemberInitializer/@EntryIndexedValue" value="SUGGESTION" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppRedundantNamespaceDefinition/@EntryIndexedValue" value="SUGGESTION" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppRedundantParentheses/@EntryIndexedValue" value="HINT" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppRedundantQualifier/@EntryIndexedValue" value="HINT" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppRedundantQualifierADL/@EntryIndexedValue" value="DO_NOT_SHOW" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppRedundantStaticSpecifierOnMemberAllocationFunction/@EntryIndexedValue" value="HINT" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppRedundantStaticSpecifierOnThreadLocalLocalVariable/@EntryIndexedValue" value="HINT" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppRedundantTemplateArguments/@EntryIndexedValue" value="HINT" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppRedundantTemplateKeyword/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppRedundantTypenameKeyword/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppRedundantVoidArgumentList/@EntryIndexedValue" value="SUGGESTION" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppRedundantZeroInitializerInAggregateInitialization/@EntryIndexedValue" value="SUGGESTION" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppReinterpretCastFromVoidPtr/@EntryIndexedValue" value="SUGGESTION" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppRemoveRedundantBraces/@EntryIndexedValue" value="DO_NOT_SHOW" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppReplaceMemsetWithZeroInitialization/@EntryIndexedValue" value="SUGGESTION" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppReplaceTieWithStructuredBinding/@EntryIndexedValue" value="SUGGESTION" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppReturnNoValueInNonVoidFunction/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppSmartPointerVsMakeFunction/@EntryIndexedValue" value="SUGGESTION" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppSomeObjectMembersMightNotBeInitialized/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppSpecialFunctionWithoutNoexceptSpecification/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppStaticAssertFailure/@EntryIndexedValue" value="ERROR" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppStaticDataMemberInUnnamedStruct/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppStaticSpecifierOnAnonymousNamespaceMember/@EntryIndexedValue" value="SUGGESTION" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppStringLiteralToCharPointerConversion/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppTabsAreDisallowed/@EntryIndexedValue" value="DO_NOT_SHOW" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppTemplateArgumentsCanBeDeduced/@EntryIndexedValue" value="HINT" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppTemplateParameterNeverUsed/@EntryIndexedValue" value="HINT" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppTemplateParameterShadowing/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppThrowExpressionCanBeReplacedWithRethrow/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppTooWideScope/@EntryIndexedValue" value="SUGGESTION" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppTooWideScopeInitStatement/@EntryIndexedValue" value="HINT" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppTypeAliasNeverUsed/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppUninitializedDependentBaseClass/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppUninitializedNonStaticDataMember/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppUnionMemberOfReferenceType/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppUnmatchedPragmaEndRegionDirective/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppUnmatchedPragmaRegionDirective/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppUnnamedNamespaceInHeaderFile/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppUnnecessaryWhitespace/@EntryIndexedValue" value="DO_NOT_SHOW" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppUnsignedZeroComparison/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppUnusedIncludeDirective/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppUseAlgorithmWithCount/@EntryIndexedValue" value="SUGGESTION" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppUseAssociativeContains/@EntryIndexedValue" value="SUGGESTION" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppUseAuto/@EntryIndexedValue" value="HINT" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppUseAutoForNumeric/@EntryIndexedValue" value="HINT" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppUseElementsView/@EntryIndexedValue" value="SUGGESTION" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppUseEraseAlgorithm/@EntryIndexedValue" value="SUGGESTION" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppUseFamiliarTemplateSyntaxForGenericLambdas/@EntryIndexedValue" value="SUGGESTION" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppUseRangeAlgorithm/@EntryIndexedValue" value="SUGGESTION" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppUseStdSize/@EntryIndexedValue" value="SUGGESTION" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppUseStructuredBinding/@EntryIndexedValue" value="HINT" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppUseTypeTraitAlias/@EntryIndexedValue" value="SUGGESTION" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppUserDefinedLiteralSuffixDoesNotStartWithUnderscore/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppUsingResultOfAssignmentAsCondition/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppVariableCanBeMadeConstexpr/@EntryIndexedValue" value="SUGGESTION" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppVirtualFunctionCallInsideCtor/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppVirtualFunctionInFinalClass/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppVolatileParameterInDeclaration/@EntryIndexedValue" value="SUGGESTION" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppWarningDirective/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppWrongIncludesOrder/@EntryIndexedValue" value="HINT" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppWrongSlashesInIncludeDirective/@EntryIndexedValue" value="HINT" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppZeroConstantCanBeReplacedWithNullptr/@EntryIndexedValue" value="SUGGESTION" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppZeroValuedExpressionUsedAsNullPointer/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=IdentifierTypo/@EntryIndexedValue" value="DO_NOT_SHOW" type="string" /> <option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=IdentifierTypo/@EntryIndexedValue" value="DO_NOT_SHOW" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=IdentifierTypo/@EntryIndexRemoved" /> <option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=IfStdIsConstantEvaluatedCanBeReplaced/@EntryIndexedValue" value="SUGGESTION" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=StdIsConstantEvaluatedWillAlwaysEvaluateToConstant/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=StringLiteralTypo/@EntryIndexedValue" value="DO_NOT_SHOW" type="string" />
</component> </component>
</project> </project>

12
.vscode/launch.json vendored Normal file
View File

@ -0,0 +1,12 @@
{
"configurations": [
{
"type": "cmake",
"request": "launch",
"name": "Debug portfile(s)",
"cmakeDebugType": "external",
"pipeName": "/tmp/vcpkg_ext_portfile_dbg",
"preLaunchTask": "Debug vcpkg commands"
}
]
}

102
.vscode/settings.json vendored
View File

@ -1,3 +1,103 @@
{ {
"cmake.configureOnOpen": true "cmake.configureOnOpen": true,
"files.associations": {
"array": "cpp",
"deque": "cpp",
"initializer_list": "cpp",
"list": "cpp",
"queue": "cpp",
"stack": "cpp",
"utility": "cpp",
"vector": "cpp",
"xhash": "cpp",
"xstring": "cpp",
"xtree": "cpp",
"xutility": "cpp",
"sstream": "cpp",
"fstream": "cpp",
"atomic": "cpp",
"hash_map": "cpp",
"bit": "cpp",
"bitset": "cpp",
"cctype": "cpp",
"charconv": "cpp",
"chrono": "cpp",
"cinttypes": "cpp",
"clocale": "cpp",
"cmath": "cpp",
"codecvt": "cpp",
"compare": "cpp",
"complex": "cpp",
"concepts": "cpp",
"condition_variable": "cpp",
"cstdarg": "cpp",
"cstddef": "cpp",
"cstdint": "cpp",
"cstdio": "cpp",
"cstdlib": "cpp",
"cstring": "cpp",
"ctime": "cpp",
"cwchar": "cpp",
"cwctype": "cpp",
"map": "cpp",
"set": "cpp",
"string": "cpp",
"unordered_map": "cpp",
"unordered_set": "cpp",
"exception": "cpp",
"expected": "cpp",
"algorithm": "cpp",
"functional": "cpp",
"iterator": "cpp",
"memory": "cpp",
"memory_resource": "cpp",
"numeric": "cpp",
"optional": "cpp",
"random": "cpp",
"ratio": "cpp",
"source_location": "cpp",
"string_view": "cpp",
"system_error": "cpp",
"tuple": "cpp",
"type_traits": "cpp",
"format": "cpp",
"future": "cpp",
"iomanip": "cpp",
"iosfwd": "cpp",
"iostream": "cpp",
"istream": "cpp",
"limits": "cpp",
"mutex": "cpp",
"new": "cpp",
"numbers": "cpp",
"ostream": "cpp",
"ranges": "cpp",
"semaphore": "cpp",
"shared_mutex": "cpp",
"span": "cpp",
"stdexcept": "cpp",
"stop_token": "cpp",
"streambuf": "cpp",
"thread": "cpp",
"typeinfo": "cpp",
"variant": "cpp"
},
// "editor.formatOnSave": false,
"vcpkg.target.useManifest": false,
"C_Cpp.default.configurationProvider": "ms-vscode.cmake-tools",
"cmake.configureArgs": [
"-DVCPKG_MANIFEST_MODE=OFF",
"-DVCPKG_APPLOCAL_DEPS=ON",
"-DX_VCPKG_APPLOCAL_DEPS_INSTALL=ON",
"-DVCPKG_TARGET_TRIPLET=x64-linux"
],
"vcpkg.general.enable": true,
"vcpkg.target.hostTriplet": "x64-linux",
"vcpkg.target.defaultTriplet": "x64-linux",
"vcpkg.target.useStaticLib": false,
"cmake.configureSettings": {
"CMAKE_TOOLCHAIN_FILE": "~/.vcpkg/scripts/buildsystems/vcpkg.cmake"
},
"vcpkg.target.installDependencies": true,
"vcpkg.target.preferSystemLibs": false
} }

View File

@ -1,3 +1,4 @@
# 22.04 is used due to python
FROM ubuntu:22.04 AS build FROM ubuntu:22.04 AS build
WORKDIR /app WORKDIR /app
@ -9,7 +10,7 @@ RUN echo 'deb [signed-by=/usr/share/keyrings/kitware-archive-keyring.gpg] https:
# Update the system and install various dependencies # Update the system and install various dependencies
RUN apt-get update && \ RUN apt-get update && \
apt-get install -y git cmake ninja-build build-essential tar curl zip unzip pkg-config autoconf python3 \ apt-get install -y git cmake ninja-build build-essential tar curl zip unzip pkg-config autoconf python3 \
libdevil-dev libncurses5-dev libbsd-dev libdevil-dev libncurses5-dev libbsd-dev bison flex
# Arm specific # Arm specific
ENV VCPKG_FORCE_SYSTEM_BINARIES=1 ENV VCPKG_FORCE_SYSTEM_BINARIES=1
@ -17,7 +18,7 @@ ENV VCPKG_FORCE_SYSTEM_BINARIES=1
# Install vcpkg and the required libraries # Install vcpkg and the required libraries
RUN git clone https://github.com/Microsoft/vcpkg.git RUN git clone https://github.com/Microsoft/vcpkg.git
RUN bash ./vcpkg/bootstrap-vcpkg.sh RUN bash ./vcpkg/bootstrap-vcpkg.sh
RUN ./vcpkg/vcpkg install cryptopp effolkronium-random libmariadb libevent lzo fmt spdlog argon2 RUN ./vcpkg/vcpkg install cryptopp effolkronium-random libevent lzo fmt spdlog argon2 libpq libpqxx
COPY . . COPY . .

View File

@ -60,7 +60,7 @@ Install `vcpkg` according to the [latest instructions](https://vcpkg.io/en/getti
Build and install the required libraries: Build and install the required libraries:
```shell ```shell
vcpkg install cryptopp effolkronium-random libmariadb libevent lzo fmt spdlog argon2 vcpkg install cryptopp effolkronium-random libevent lzo fmt spdlog argon2 libpq libpqxx
``` ```
#### Building the binaries #### Building the binaries

17
TODO.md Normal file
View File

@ -0,0 +1,17 @@
# The list
- [ ] Database initialization
- [x] Main (Most important duh)
- [ ] ClientManager
- [ ] ClientManagerBoot
- [ ] ClientManagerEventFlag
- [ ] ClientManagerGuild
- [ ] ClientManagerHorseName
- [ ] ClientManagerLogin
- [ ] ClientManagerPlayer
- [x] DBManager
- [ ] GuildManager
- [ ] ItemAwardManager
- [x] ItemIDRangeManager
- [x] Marriage
- [x] Monarch

15
common/version.h Normal file
View File

@ -0,0 +1,15 @@
#ifndef __INC_METIN_II_VERSION_H__
#define __INC_METIN_II_VERSION_H__
#include <ostream>
#define __REVISION__ "c9bd9a7"
#define __COMMIT_DATE__ "2025-06-06 20:26:23 +0100"
#define __COMMIT_TAG__ "0.4.1"
#define __OS_NAME__ "Linux-5.15.167.4-microsoft-standard-WSL2"
#define __COMPILER__ "GNU 9.5.0"
#define __CPU_TARGET__ "x86_64"
void WriteVersion();
#endif

View File

@ -1,335 +0,0 @@
#ifndef __INC_AUCTION_TABLES_H__
#define __INC_AUCTION_TABLES_H__
#include "tables.h"
typedef struct _base_auction
{
public:
DWORD item_num;
TItemTable* item_proto;
int offer_price;
int price;
DWORD offer_id;
char shown_name[CHARACTER_NAME_MAX_LEN + 1];
BYTE empire;
time_t expired_time;
DWORD get_item_num () { return item_num; }
DWORD get_offer_id () { return offer_id; }
BYTE get_empire () { return empire; }
time_t get_expired_time () { return expired_time; }
bool is_expired ()
{
return (time(NULL) > expired_time);
}
int get_price () { return offer_price; }
} TAuctionSimpleItemInfo;
// 각 auction 정보들.
// primary key (item_id)
typedef struct _auction : public _base_auction
{
public:
DWORD item_id;
DWORD bidder_id;
_auction (){}
_auction (DWORD _item_num, int _offer_price, int _price, DWORD _offer_id,
char* _shown_name, time_t _expired_time, DWORD _item_id, DWORD _bidder_id, BYTE _empire)
{
item_num = _item_num;
offer_price= _offer_price;
price = _price;
offer_id = _offer_id;
memcpy(shown_name, _shown_name, strlen(_shown_name) + 1);
expired_time = _expired_time;
item_id = _item_id;
bidder_id = _bidder_id;
empire = _empire;
}
// 이 메소드들은 어떤 변수가 auction에서 어떤 역할을 하는지 까먹을 까봐
// 만들어놓았다.
// by rtsummit
DWORD get_item_id () { return item_id; }
DWORD get_bidder_id () { return bidder_id; }
int get_bid_price () { return offer_price; }
void set_bid_price (int new_price)
{
offer_price = new_price;
}
int get_impur_price () { return price; }
const char* get_bidder_name () { return shown_name; }
void set_bidder_name (const char* new_bidder_name)
{
memcpy(shown_name, new_bidder_name, strlen(new_bidder_name) + 1);
}
} TAuctionItemInfo;
// primary key (item_id)
typedef struct _sale : public _base_auction
{
_sale (){}
_sale (DWORD _item_num, int _offer_price, DWORD _offer_id,
char* _shown_name, DWORD _item_id, DWORD _wisher_id)
{
item_num = _item_num;
offer_price= _offer_price;
offer_id = _offer_id;
memcpy(shown_name, _shown_name, strlen(_shown_name) + 1);
item_id = _item_id;
wisher_id = _wisher_id;
}
DWORD item_id;
DWORD wisher_id;
} TSaleItemInfo;
// wish는 실제하는 아이템은 없다.
// primary key (item_num, wisher_id)
typedef struct _wish : public _base_auction
{
_wish (){}
_wish (DWORD _item_num, int _offer_price, DWORD _offer_id,
char* _shown_name, time_t _expired_time, BYTE _empire)
{
item_num = _item_num;
offer_price= _offer_price;
offer_id = _offer_id;
memcpy(shown_name, _shown_name, strlen(_shown_name) + 1);
expired_time = _expired_time;
empire = _empire;
}
} TWishItemInfo;
enum AuctionType {_AUCTION, _WISH_AUCTION, _MY_AUCTION, _MY_WISH_AUCTION, _AUCTION_MAX};
enum AuctionCmd {OPEN_AUCTION, OPEN_WISH_AUCTION, OPEN_MY_AUCTION, OPEN_MY_WISH_AUCTION,
AUCTION_BID, AUCTION_IMME_PUR, AUCTION_ENR_AUC, AUCTION_ENR_WISH, AUCTION_ENR_SALE,
AUCTION_GET_AUC, AUCTION_BUY_SOLD,
AUCTION_CANCEL_AUC, AUCTION_CANCEL_WISH, AUCTION_CANCEL_SALE,
AUCTION_DELETE_AUCTION_ITEM, AUCTION_DELETE_SALE_ITEM,
AUCTION_CHANGING_MONEY,
AUCTION_REBID, AUCTION_BID_CANCEL,
};
// 반드시 FAIL 앞에, 실패 류 들이 와야한다.
// 왜냐, <= AUCTION_FAIL 이런 CHECK을 할 거거든
// 반대로 SUCCESS 뒤에, 성공 류 들이 와야한다. 근데 성공류가 있긴 하려나...
enum AuctionResult { AUCTION_EXPIRED, AUCTION_NOT_EXPIRED, AUCTION_NOT_ENOUGH_MONEY,
AUCTION_SOLD, AUCTION_CANCEL, AUCTION_ALREADY_IN, AUCTION_NOT_IN, AUCTION_FAIL, AUCTION_SUCCESS };
enum AuctionSort { AUCTION_NO_ORDER,
AUCTION_ITEM_NAME_AC, AUCTION_ITEM_NAME_DC,
AUCTION_CATEGORY_AC, AUCTION_CATEGORY_DC,
AUCTION_TIME_AC, AUCTION_TIME_DC,
AUCTION_CHAR_NAME_AC, AUCTION_CHAR_NAME_DC,
AUCTION_PRICE_AC, AUCTION_PRICE_DC,
};
typedef struct command_get_auction_list
{
AuctionCmd cmd;
DWORD start_idx;
BYTE size;
} TPacketGDGetAuctionList;
typedef struct command_auction
{
void enroll_product (DWORD _item_id, BYTE _empire, int _bidPrice, int _impurPrice)
{
cmd = AUCTION_ENR_AUC;
item = _item_id;
empire = _empire;
price1 = _bidPrice;
price2 = _impurPrice;
}
void enroll_sale (DWORD _item_id, DWORD _wisher_id, int _salePrice)
{
cmd = AUCTION_ENR_SALE;
item = _item_id;
price1 = _salePrice;
player_id = _wisher_id;
}
void enroll_wish (DWORD _item_num, BYTE _empire, int _wishPrice)
{
cmd = AUCTION_ENR_WISH;
item = _item_num;
empire = _empire;
price1 = _wishPrice;
}
void bid (DWORD _item_id, int _bidPrice)
{
cmd = AUCTION_BID;
item = _item_id;
price1 = _bidPrice;
}
void impur (DWORD _item_id)
{
cmd = AUCTION_IMME_PUR;
item = _item_id;
}
void get_auctioned_item (DWORD _item_id)
{
cmd = AUCTION_GET_AUC;
item = _item_id;
}
void buy_sold_item (DWORD _item_id)
{
cmd = AUCTION_BUY_SOLD;
item = _item_id;
}
void cancel_auction (DWORD _item_id)
{
cmd = AUCTION_CANCEL_AUC;
item = _item_id;
}
void cancel_wish (DWORD _item_num)
{
cmd = AUCTION_CANCEL_WISH;
item = _item_num;
}
void cancel_sale (DWORD _item_id)
{
cmd = AUCTION_CANCEL_SALE;
item = _item_id;
}
void delete_auction_item (DWORD _item_id)
{
cmd = AUCTION_DELETE_AUCTION_ITEM;
item = _item_id;
}
void delete_sale_item (DWORD _item_id)
{
cmd = AUCTION_DELETE_SALE_ITEM;
item = _item_id;
}
void changing_money (int _money)
{
cmd = AUCTION_CHANGING_MONEY;
price1 = _money;
}
// bid랑 cmd만 다르다.
void rebid (DWORD _item_id, int _bidPrice)
{
cmd = AUCTION_REBID;
item = _item_id;
price1 = _bidPrice;
}
void bid_cancel (DWORD _item_id)
{
cmd = AUCTION_BID_CANCEL;
item = _item_id;
}
DWORD get_item () { return item; }
protected:
AuctionCmd cmd;
DWORD player_id;
DWORD item;
BYTE empire;
int price1;
int price2;
public:
AuctionCmd get_cmd() { return cmd; }
BYTE get_empire () { return empire; }
} TPacketGDCommnadAuction;
typedef struct result_auction
{
AuctionCmd cmd;
BYTE result;
DWORD target;
} TPacketDGResultAuction;
// wrapper struct
typedef struct auction_enroll_product : public command_auction
{
DWORD get_item_id() { return item; }
int get_bid_price() { return price1; }
int get_impur_price() { return price2; }
} AuctionEnrollProductInfo;
typedef struct auction_enroll_sale : public command_auction
{
DWORD get_item_id() { return item; }
DWORD get_wisher_id() { return player_id; }
int get_sale_price() { return price1; }
} AuctionEnrollSaleInfo;
typedef struct auction_enroll_wish : public command_auction
{
DWORD get_item_num() { return item; }
int get_wish_price() { return price1; }
} AuctionEnrollWishInfo;
typedef struct auction_bid : public command_auction
{
DWORD get_item_id() { return item; }
int get_bid_price() { return price1; }
} AuctionBidInfo;
typedef struct auction_impur : public command_auction
{
DWORD get_item_id() { return item; }
} AuctionImpurInfo;
//typedef struct get_auction_list
//
//bid
//{
// item_id;
// bidder_id;
// price;
//}
//impur
//{
// item_id;
// purchaser_id;
//}
//enroll_wish
//{
// item_num;
// wisher_id;
// wish_price;
//}
//enroll_sale
//{
// item_id;
// seller_id;
// sale_price;
//}
//
//return_packet
//{
// isSuccess;
//}
//
//
//get_auction_simple_item_info_list
//{
// auction_type;
// start_idx;
// size;
// conditions; 정렬은 승철님께 조언을 구해보자.ㅇㅇ
//}
//
//get_auction_detail_item_info
//{
// item_id;
//}
#endif

View File

@ -456,9 +456,6 @@ enum EWindows
MALL, MALL,
DRAGON_SOUL_INVENTORY, DRAGON_SOUL_INVENTORY,
BELT_INVENTORY, BELT_INVENTORY,
#ifdef __AUCTION__
AUCTION,
#endif
GROUND GROUND
}; };

View File

@ -1,6 +1,5 @@
#ifndef __INC_SERVICE_H__ #ifndef __INC_SERVICE_H__
#define __INC_SERVICE_H__ #define __INC_SERVICE_H__
//#define __AUCTION__
#define __PET_SYSTEM__ #define __PET_SYSTEM__
#endif #endif

View File

@ -130,12 +130,6 @@ enum
HEADER_GD_VALID_LOGOUT = 134, HEADER_GD_VALID_LOGOUT = 134,
// AUCTION
#ifdef __AUCTION__
HEADER_GD_GET_AUCTION_LIST = 135,
HEADER_GD_COMMAND_AUCTION = 136,
#endif
HEADER_GD_REQUEST_CHARGE_CASH = 137, HEADER_GD_REQUEST_CHARGE_CASH = 137,
HEADER_GD_DELETE_AWARDID = 138, // delete gift notify icon HEADER_GD_DELETE_AWARDID = 138, // delete gift notify icon
@ -262,9 +256,7 @@ enum
HEADER_DG_ACK_HORSE_NAME = 176, HEADER_DG_ACK_HORSE_NAME = 176,
HEADER_DG_NEED_LOGIN_LOG = 177, HEADER_DG_NEED_LOGIN_LOG = 177,
#ifdef __AUCTION__
HEADER_DG_AUCTION_RESULT = 178,
#endif
HEADER_DG_RESULT_CHARGE_CASH = 179, HEADER_DG_RESULT_CHARGE_CASH = 179,
HEADER_DG_ITEMAWARD_INFORMER = 180, //gift notify HEADER_DG_ITEMAWARD_INFORMER = 180, //gift notify
HEADER_DG_RESPOND_CHANNELSTATUS = 181, HEADER_DG_RESPOND_CHANNELSTATUS = 181,

View File

@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.8) cmake_minimum_required(VERSION 3.12)
project(db CXX) project(db CXX)

View File

@ -1,719 +0,0 @@
#include "stdafx.h"
#ifdef __AUCTION__
#include "DBManager.h"
#include "Peer.h"
#include "AuctionManager.h"
void MyBidBoard::Boot (CPeer* peer)
{
peer->EncodeWORD(sizeof(DWORD) + sizeof(DWORD) + sizeof(int));
peer->EncodeWORD(Size());
for (TMyBidBoard::iterator pc_it = pc_map.begin(); pc_it != pc_map.end(); pc_it++)
{
TItemMap* item_map = pc_it->second;
for (TItemMap::iterator it = item_map->begin(); it != item_map->end(); it++)
{
peer->Encode(&(pc_it->first), sizeof(DWORD));
peer->Encode(&(it->first), sizeof(DWORD));
peer->Encode(&(it->second), sizeof(int));
}
}
}
size_t MyBidBoard::Size ()
{
size_t size = 0;
for (TMyBidBoard::iterator it = pc_map.begin(); it != pc_map.end(); it++)
{
size += it->second->size();
}
return size;
}
int MyBidBoard::GetMoney (DWORD player_id, DWORD item_id)
{
TMyBidBoard::iterator pc_it = pc_map.find (player_id);
if (pc_it == pc_map.end())
{
return -1;
}
TItemMap* item_map = pc_it->second;
TItemMap::iterator it = item_map->find (item_id);
if (it == item_map->end())
return -1;
else
return it->second;
}
bool MyBidBoard::Delete (DWORD player_id, DWORD item_id)
{
TMyBidBoard::iterator pc_it = pc_map.find (player_id);
if (pc_it == pc_map.end())
{
return false;
}
TItemMap* item_map = pc_it->second;
TItemMap::iterator it = item_map->find (item_id);
if (it == item_map->end())
return false;
else
{
item_map->erase(it);
}
char szQuery[512];
snprintf(szQuery, sizeof(szQuery), "DELETE FROM my_bid WHERE player_id = %d and item_id = %d", player_id, item_id);
CDBManager::instance().AsyncQuery(szQuery);
return true;
}
void MyBidBoard::Insert (DWORD player_id, DWORD item_id, int money)
{
TMyBidBoard::iterator pc_it = pc_map.find (player_id);
TItemMap* item_map;
if (pc_it == pc_map.end())
{
item_map = new TItemMap();
pc_map.insert (TMyBidBoard::value_type (player_id, item_map));
}
else
item_map = pc_it->second;
TItemMap::iterator it = item_map->find (item_id);
if (it == item_map->end())
{
item_map->insert (TItemMap::value_type (item_id, money));
}
else
{
it->second = money;
}
char szQuery[512];
snprintf(szQuery, sizeof(szQuery), "REPLACE INTO my_bid VALUES (%d, %d, %d)", player_id, item_id, money);
CDBManager::instance().AsyncQuery(szQuery);
}
AuctionManager::AuctionManager()
{
}
AuctionManager::~AuctionManager()
{
}
void AuctionManager::Initialize()
{ auction_item_cache_map.clear();
LoadAuctionItem();
LoadAuctionInfo();
LoadSaleInfo();
LoadWishInfo();
LoadMyBidInfo();
}
void AuctionManager::LoadAuctionItem()
{
char szQuery[512];
snprintf(szQuery, sizeof(szQuery),
"SELECT id, owner_id, count, vnum, socket0, socket1, socket2, "
"attrtype0, attrvalue0, "
"attrtype1, attrvalue1, "
"attrtype2, attrvalue2, "
"attrtype3, attrvalue3, "
"attrtype4, attrvalue4, "
"attrtype5, attrvalue5, "
"attrtype6, attrvalue6 "
"FROM item WHERE window = 'AUCTION'");
SQLMsg *msg = CDBManager::instance().DirectQuery(szQuery);
MYSQL_RES *res = msg->Get()->pSQLResult;
if (!res)
{
return;
}
int rows;
if ((rows = mysql_num_rows(res)) <= 0) // 데이터 없음
{
return;
}
for (int i = 0; i < rows; ++i)
{
MYSQL_ROW row = mysql_fetch_row(res);
TPlayerItem item;
int cur = 0;
str_to_number(item.id, row[cur++]);
str_to_number(item.owner, row[cur++]);
item.window = AUCTION;
str_to_number(item.count, row[cur++]);
str_to_number(item.vnum, row[cur++]);
str_to_number(item.alSockets[0], row[cur++]);
str_to_number(item.alSockets[1], row[cur++]);
str_to_number(item.alSockets[2], row[cur++]);
for (int j = 0; j < ITEM_ATTRIBUTE_MAX_NUM; j++)
{
str_to_number(item.aAttr[j].bType, row[cur++]);
str_to_number(item.aAttr[j].sValue, row[cur++]);
}
InsertItemCache(&item, true);
}
return;
}
void AuctionManager::LoadAuctionInfo()
{
char szQuery[512];
snprintf(szQuery, sizeof(szQuery),
"select * from auction");
SQLMsg *msg = CDBManager::instance().DirectQuery(szQuery);
MYSQL_RES *res = msg->Get()->pSQLResult;
if (!res)
{
return;
}
int rows;
if ((rows = mysql_num_rows(res)) <= 0) // 데이터 없음
{
return;
}
for (int i = 0; i < rows; ++i)
{
MYSQL_ROW row = mysql_fetch_row(res);
TAuctionItemInfo auctionItemInfo;
int cur = 0;
str_to_number(auctionItemInfo.item_num, row[cur++]);
str_to_number(auctionItemInfo.offer_price, row[cur++]);
str_to_number(auctionItemInfo.price, row[cur++]);
str_to_number(auctionItemInfo.offer_id, row[cur++]);
memcpy (auctionItemInfo.shown_name, (char*)row[cur], strlen((char*)row[cur]) +1);
cur++;
str_to_number(auctionItemInfo.empire, row[cur++]);
str_to_number(auctionItemInfo.expired_time, row[cur++]);
str_to_number(auctionItemInfo.item_id, row[cur++]);
str_to_number(auctionItemInfo.bidder_id, row[cur++]);
InsertAuctionItemInfoCache(&auctionItemInfo, true);
}
return;
}
void AuctionManager::LoadSaleInfo()
{
char szQuery[512];
snprintf(szQuery, sizeof(szQuery),
"select * from sale");
SQLMsg *msg = CDBManager::instance().DirectQuery(szQuery);
MYSQL_RES *res = msg->Get()->pSQLResult;
if (!res)
{
return;
}
int rows;
if ((rows = mysql_num_rows(res)) <= 0) // 데이터 없음
{
return;
}
for (int i = 0; i < rows; ++i)
{
MYSQL_ROW row = mysql_fetch_row(res);
TSaleItemInfo saleItemInfo;
int cur = 0;
str_to_number(saleItemInfo.item_num, row[cur++]);
str_to_number(saleItemInfo.offer_price, row[cur++]);
str_to_number(saleItemInfo.price, row[cur++]);
str_to_number(saleItemInfo.offer_id, row[cur++]);
memcpy (saleItemInfo.shown_name, (char*)row[cur], strlen((char*)row[cur]) +1);
cur++;
str_to_number(saleItemInfo.empire, row[cur++]);
str_to_number(saleItemInfo.expired_time, row[cur++]);
str_to_number(saleItemInfo.item_id, row[cur++]);
str_to_number(saleItemInfo.wisher_id, row[cur++]);
InsertSaleItemInfoCache(&saleItemInfo, true);
}
return;
}
void AuctionManager::LoadWishInfo()
{
char szQuery[512];
snprintf(szQuery, sizeof(szQuery),
"select * from wish");
SQLMsg *msg = CDBManager::instance().DirectQuery(szQuery);
MYSQL_RES *res = msg->Get()->pSQLResult;
if (!res)
{
return;
}
int rows;
if ((rows = mysql_num_rows(res)) <= 0) // 데이터 없음
{
return;
}
for (int i = 0; i < rows; ++i)
{
MYSQL_ROW row = mysql_fetch_row(res);
TWishItemInfo wishItemInfo;
int cur = 0;
str_to_number(wishItemInfo.item_num, row[cur++]);
str_to_number(wishItemInfo.offer_price, row[cur++]);
str_to_number(wishItemInfo.price, row[cur++]);
str_to_number(wishItemInfo.offer_id, row[cur++]);
memcpy (wishItemInfo.shown_name, (char*)row[cur], strlen((char*)row[cur]) +1);
cur++;
str_to_number(wishItemInfo.empire, row[cur++]);
str_to_number(wishItemInfo.expired_time, row[cur++]);
InsertWishItemInfoCache(&wishItemInfo, true);
}
return;
}
void AuctionManager::LoadMyBidInfo ()
{
char szQuery[512];
snprintf(szQuery, sizeof(szQuery),
"select * from my_bid");
SQLMsg *msg = CDBManager::instance().DirectQuery(szQuery);
MYSQL_RES *res = msg->Get()->pSQLResult;
if (!res)
{
return;
}
int rows;
if ((rows = mysql_num_rows(res)) <= 0) // 데이터 없음
{
return;
}
for (int i = 0; i < rows; ++i)
{
MYSQL_ROW row = mysql_fetch_row(res);
int cur = 0;
DWORD player_id;
DWORD item_id;
int money;
str_to_number(player_id, row[cur++]);
str_to_number(item_id, row[cur++]);
str_to_number(money, row[cur++]);
InsertMyBid (player_id, item_id, money);
}
return;
}
inline CItemCache* AuctionManager::GetItemCache(DWORD item_id)
{
TItemCacheMap::iterator it = auction_item_cache_map.find (item_id);
if (it == auction_item_cache_map.end())
return NULL;
else
return it->second;
}
void AuctionManager::Boot(CPeer* peer)
{
peer->EncodeWORD(sizeof(TPlayerItem));
peer->EncodeWORD(auction_item_cache_map.size());
itertype(auction_item_cache_map) auction_item_cache_map_it = auction_item_cache_map.begin();
while (auction_item_cache_map_it != auction_item_cache_map.end())
peer->Encode((auction_item_cache_map_it++)->second->Get(), sizeof(TPlayerItem));
Auction.Boot(peer);
Sale.Boot(peer);
Wish.Boot(peer);
MyBid.Boot(peer);
}
bool AuctionManager::InsertItemCache(CItemCache *item_cache, bool bSkipQuery)
{
CItemCache* c = GetItemCache (item_cache->Get(false)->id);
if (c != NULL)
{
return false;
}
auction_item_cache_map.insert(TItemCacheMap::value_type(item_cache->Get(true)->id, item_cache));
item_cache->OnFlush();
return true;
}
bool AuctionManager::InsertItemCache(TPlayerItem * pNew, bool bSkipQuery)
{
CItemCache* c = GetItemCache (pNew->id);
if (c != NULL)
{
return false;
}
c = new CItemCache();
c->Put(pNew, bSkipQuery);
auction_item_cache_map.insert(TItemCacheMap::value_type(pNew->id, c));
c->Flush();
return true;
}
bool AuctionManager::DeleteItemCache(DWORD item_id)
{
CItemCache* c = GetItemCache (item_id);
if (c == NULL)
{
return false;
}
c->Delete();
return true;
}
AuctionResult AuctionManager::EnrollInAuction(CItemCache* item_cache, TAuctionItemInfo &item_info)
{
CItemCache* c = GetItemCache (item_info.item_id);
if (c != NULL)
{
SPDLOG_ERROR("item id : {} is already in AuctionManager", item_info.item_id);
return AUCTION_FAIL;
}
if (!Auction.InsertItemInfo (&item_info))
{
SPDLOG_ERROR("item id : {} is already in AuctionBoard", item_info.item_id);
return AUCTION_FAIL;
}
item_cache->Get()->window = AUCTION;
item_cache->Get()->pos = 9999999;
InsertItemCache (item_cache);
return AUCTION_SUCCESS;
}
AuctionResult AuctionManager::EnrollInSale(CItemCache* item_cache, TSaleItemInfo &item_info)
{
CItemCache* c = GetItemCache (item_info.item_id);
if (c != NULL)
{
SPDLOG_ERROR("item id : {} is already in AuctionManager", item_info.item_id);
return AUCTION_FAIL;
}
if (!Wish.GetItemInfoCache (WishBoard::Key (item_info.item_num, item_info.wisher_id)))
{
SPDLOG_ERROR("item_num : {}, wisher_id : {} is not in wish auction.", item_info.item_num, item_info.wisher_id);
return AUCTION_FAIL;
}
if (!Sale.InsertItemInfo (&item_info))
{
SPDLOG_ERROR("item id : {} is already in SaleBoard", item_info.item_id);
return AUCTION_FAIL;
}
item_cache->Get()->window = AUCTION;
item_cache->Get()->pos = 999999;
InsertItemCache (item_cache);
return AUCTION_SUCCESS;
}
AuctionResult AuctionManager::EnrollInWish(TWishItemInfo &item_info)
{
if (!Wish.InsertItemInfo (&item_info))
{
SPDLOG_ERROR("wisher_id : {}, item_num : {} is already in WishBoard", item_info.offer_id, item_info.item_num);
return AUCTION_FAIL;
}
return AUCTION_SUCCESS;
}
AuctionResult AuctionManager::Bid(DWORD bidder_id, const char* bidder_name, DWORD item_id, DWORD bid_price)
{
CItemCache* c = GetItemCache (item_id);
if (c == NULL)
{
SPDLOG_ERROR("item id : {} does not exist in auction.", item_id);
return AUCTION_FAIL;
}
if (MyBid.GetMoney (bidder_id, item_id) != 0)
{
return AUCTION_ALREADY_IN;
}
CAuctionItemInfoCache* item_cache = Auction.GetItemInfoCache(item_id);
TAuctionItemInfo* item_info = item_cache->Get(false);
if (item_info->is_expired())
{
return AUCTION_EXPIRED;
}
if ((double)bid_price < (double)item_info->get_bid_price() * 1.05)
{
return AUCTION_NOT_ENOUGH_MONEY;
}
item_info->set_bid_price(bid_price);
item_info->bidder_id = bidder_id;
item_info->set_bidder_name (bidder_name);
item_cache->OnFlush();
InsertMyBid (bidder_id, item_id, bid_price);
return AUCTION_SUCCESS;
}
AuctionResult AuctionManager::Impur(DWORD purchaser_id, const char* purchaser_name, DWORD item_id)
{
CItemCache* c = GetItemCache (item_id);
if (c == NULL)
{
SPDLOG_ERROR("item id : {} does not exist in auction.", item_id);
return AUCTION_FAIL;
}
CAuctionItemInfoCache* item_cache = Auction.GetItemInfoCache(item_id);
TAuctionItemInfo* item_info = item_cache->Get(false);
if (item_info->is_expired())
{
return AUCTION_EXPIRED;
}
// 즉구 해버렸으므로, 경매는 끝났다.
item_info->expired_time = 0;
item_info->bidder_id = purchaser_id;
item_info->set_bidder_name (purchaser_name);
item_info->set_bid_price (item_info->get_impur_price());
item_cache->OnFlush();
return AUCTION_SUCCESS;
}
AuctionResult AuctionManager::GetAuctionedItem (DWORD actor_id, DWORD item_id, TPlayerItem& item)
{
CItemCache* c = GetItemCache (item_id);
if (c == NULL)
{
SPDLOG_ERROR("item id : {} does not exist in auction.", item_id);
return AUCTION_FAIL;
}
CAuctionItemInfoCache* item_info_cache = Auction.GetItemInfoCache(item_id);
if (item_info_cache == NULL)
{
SPDLOG_ERROR("how can this accident happen?");
return AUCTION_FAIL;
}
TAuctionItemInfo* item_info = item_info_cache->Get(false);
if (!item_info->is_expired())
{
return AUCTION_NOT_EXPIRED;
}
memcpy(&item, c->Get(), sizeof(TPlayerItem));
return AUCTION_SUCCESS;
}
AuctionResult AuctionManager::BuySoldItem (DWORD actor_id, DWORD item_id, TPlayerItem& item)
{
CItemCache* c = GetItemCache (item_id);
if (c == NULL)
{
SPDLOG_ERROR("item id : {} does not exist in auction.", item_id);
return AUCTION_FAIL;
}
CSaleItemInfoCache* item_info_cache = Sale.GetItemInfoCache(item_id);
if (item_info_cache == NULL)
{
SPDLOG_ERROR("how can this accident happen?");
return AUCTION_FAIL;
}
TSaleItemInfo* item_info = item_info_cache->Get(false);
memcpy(&item, c->Get(), sizeof(TPlayerItem));
return AUCTION_SUCCESS;
}
AuctionResult AuctionManager::CancelAuction (DWORD actor_id, DWORD item_id, TPlayerItem& item)
{
CItemCache* c = GetItemCache (item_id);
if (c == NULL)
{
SPDLOG_ERROR("item id : {} does not exist in auction.", item_id);
return AUCTION_FAIL;
}
CAuctionItemInfoCache* item_info_cache = Auction.GetItemInfoCache(item_id);
if (item_info_cache == NULL)
{
SPDLOG_ERROR("how can this accident happen?");
return AUCTION_FAIL;
}
TAuctionItemInfo* item_info = item_info_cache->Get(false);
memcpy(&item, c->Get(), sizeof(TPlayerItem));
return AUCTION_SUCCESS;
}
AuctionResult AuctionManager::CancelWish (DWORD actor_id, DWORD item_num)
{
if (!Wish.DeleteItemInfoCache (WishBoard::Key (actor_id, item_num)))
{
return AUCTION_FAIL;
}
else
{
return AUCTION_SUCCESS;
}
}
AuctionResult AuctionManager::CancelSale (DWORD actor_id, DWORD item_id, TPlayerItem& item)
{
CItemCache* c = GetItemCache (item_id);
if (c == NULL)
{
SPDLOG_ERROR("item id : {} does not exist in auction.", item_id);
return AUCTION_FAIL;
}
CSaleItemInfoCache* item_info_cache = Sale.GetItemInfoCache(item_id);
if (item_info_cache == NULL)
{
SPDLOG_ERROR("how can this accident happen?");
return AUCTION_FAIL;
}
TSaleItemInfo* item_info = item_info_cache->Get(false);
memcpy(&item, c->Get(), sizeof(TPlayerItem));
return AUCTION_SUCCESS;
}
AuctionResult AuctionManager::DeleteAuctionItem (DWORD actor_id, DWORD item_id)
{
if (DeleteItemCache (item_id) == false)
{
SPDLOG_ERROR("item id : {} does not exist in auction.", item_id);
return AUCTION_FAIL;
}
if (Auction.DeleteItemInfoCache (item_id) == NULL)
{
SPDLOG_ERROR("how can this accident happen?");
return AUCTION_FAIL;
}
return AUCTION_SUCCESS;
}
AuctionResult AuctionManager::DeleteSaleItem (DWORD actor_id, DWORD item_id)
{
if (DeleteItemCache (item_id) == false)
{
SPDLOG_ERROR("item id : {} does not exist in auction.", item_id);
return AUCTION_FAIL;
}
if (Sale.DeleteItemInfoCache (item_id) == NULL)
{
SPDLOG_ERROR("how can this accident happen?");
return AUCTION_FAIL;
}
return AUCTION_SUCCESS;
}
AuctionResult AuctionManager::ReBid(DWORD bidder_id, const char* bidder_name, DWORD item_id, DWORD bid_price)
{
CItemCache* c = GetItemCache (item_id);
if (c == NULL)
{
SPDLOG_ERROR("item id : {} does not exist in auction.", item_id);
return AUCTION_FAIL;
}
int money = MyBid.GetMoney (bidder_id, item_id);
if (money == -1)
{
return AUCTION_NOT_IN;
}
CAuctionItemInfoCache* item_cache = Auction.GetItemInfoCache(item_id);
TAuctionItemInfo* item_info = item_cache->Get(false);
if (item_info->is_expired())
{
return AUCTION_EXPIRED;
}
if ((double)(bid_price + money) < (double)item_info->get_bid_price() * 1.05)
{
return AUCTION_NOT_ENOUGH_MONEY;
}
item_info->set_bid_price(bid_price + money);
item_info->bidder_id = bidder_id;
item_info->set_bidder_name (bidder_name);
item_cache->OnFlush();
InsertMyBid (bidder_id, item_id, money + bid_price);
return AUCTION_SUCCESS;
}
AuctionResult AuctionManager::BidCancel (DWORD bidder_id, DWORD item_id)
{
if (MyBid.Delete (bidder_id, item_id))
{
return AUCTION_SUCCESS;
}
else
{
return AUCTION_NOT_IN;
}
}
#endif

View File

@ -1,370 +0,0 @@
#ifdef __AUCTION__
#ifndef __INC_AUCTION_MANAGER_H__
#define __INC_AUCTION_MANAGER_H__
#include <unordered_map>
#include "Cache.h"
#include <common/auction_table.h>
class CItemCache;
class CAuctionItemInfoCache;
class CSaleItemInfoCache;
class CWishItemInfoCache;
template<>
class hash<std::pair <DWORD, DWORD> >
{ // hash functor
public:
typedef std::pair <DWORD, DWORD> _Kty;
size_t operator()(const _Kty& _Keyval) const
{ // hash _Keyval to size_t value by pseudorandomizing transform
ldiv_t _Qrem = ldiv((size_t)_Keyval.first + (size_t)_Keyval.second, 127773);
_Qrem.rem = 16807 * _Qrem.rem - 2836 * _Qrem.quot;
if (_Qrem.rem < 0)
_Qrem.rem += 2147483647;
return ((size_t)_Qrem.rem);
}
};
class AuctionBoard
{
public:
typedef DWORD Key;
typedef CAuctionItemInfoCache ItemInfoCache;
typedef TAuctionItemInfo ItemInfo;
public:
AuctionBoard() {}
~AuctionBoard() {}
void Boot(CPeer* peer)
{
peer->EncodeWORD(sizeof(ItemInfo));
peer->EncodeWORD(item_cache_map.size());
TItemInfoCacheMap::iterator it = item_cache_map.begin();
while (it != item_cache_map.end())
peer->Encode((it++)->second->Get(), sizeof(ItemInfo));
}
size_t Size()
{
return item_cache_map.size();
}
ItemInfoCache* GetItemInfoCache (Key key)
{
TItemInfoCacheMap::iterator it = item_cache_map.find (key);
if (it == item_cache_map.end())
return NULL;
else
return it->second;
}
bool DeleteItemInfoCache (Key key)
{
TItemInfoCacheMap::iterator it = item_cache_map.find (key);
if (it == item_cache_map.end())
return false;
else
{
it->second->Delete();
item_cache_map.erase(it);
return true;
}
}
bool InsertItemInfo (ItemInfo *pNew, bool bSkipQuery = false)
{
ItemInfoCache* c = GetItemInfoCache (Key (pNew->item_id));
if (c != NULL)
{
return false;
}
c = new ItemInfoCache();
c->Put(pNew, bSkipQuery);
item_cache_map.insert(TItemInfoCacheMap::value_type(pNew->item_id, c));
c->Flush();
return true;
}
private:
typedef std::unordered_map <Key, ItemInfoCache *> TItemInfoCacheMap;
TItemInfoCacheMap item_cache_map;
};
class SaleBoard
{
public:
typedef DWORD Key;
typedef CSaleItemInfoCache ItemInfoCache;
typedef TSaleItemInfo ItemInfo;
SaleBoard() {}
~SaleBoard() {}
void Boot(CPeer* peer)
{
peer->EncodeWORD(sizeof(ItemInfo));
peer->EncodeWORD(item_cache_map.size());
TItemInfoCacheMap::iterator it = item_cache_map.begin();
while (it != item_cache_map.end())
peer->Encode((it++)->second->Get(), sizeof(ItemInfo));
}
size_t Size()
{
return item_cache_map.size();
}
ItemInfoCache* GetItemInfoCache (Key key)
{
TItemInfoCacheMap::iterator it = item_cache_map.find (key);
if (it == item_cache_map.end())
return NULL;
else
return it->second;
}
bool DeleteItemInfoCache (Key key)
{
TItemInfoCacheMap::iterator it = item_cache_map.find (key);
if (it == item_cache_map.end())
return false;
else
{
it->second->Delete();
item_cache_map.erase(it);
return true;
}
}
bool InsertItemInfo (ItemInfo *pNew, bool bSkipQuery = false)
{
ItemInfoCache* c = GetItemInfoCache (Key (pNew->item_id));
if (c != NULL)
{
return false;
}
c = new ItemInfoCache();
c->Put(pNew, bSkipQuery);
item_cache_map.insert(TItemInfoCacheMap::value_type(pNew->item_id, c));
c->Flush();
return true;
}
private:
typedef std::unordered_map <Key, ItemInfoCache *> TItemInfoCacheMap;
TItemInfoCacheMap item_cache_map;
};
class WishBoard
{
public:
typedef std::pair <DWORD, DWORD> Key;
typedef CWishItemInfoCache ItemInfoCache;
typedef TWishItemInfo ItemInfo;
WishBoard() {}
virtual ~WishBoard() {}
void Boot(CPeer* peer)
{
peer->EncodeWORD(sizeof(ItemInfo));
peer->EncodeWORD(item_cache_map.size());
TItemInfoCacheMap::iterator it = item_cache_map.begin();
while (it != item_cache_map.end())
peer->Encode((it++)->second->Get(), sizeof(ItemInfo));
}
size_t Size()
{
return item_cache_map.size();
}
ItemInfoCache* GetItemInfoCache (Key key)
{
TItemInfoCacheMap::iterator it = item_cache_map.find (key);
if (it == item_cache_map.end())
return NULL;
else
return it->second;
}
bool DeleteItemInfoCache (Key key)
{
TItemInfoCacheMap::iterator it = item_cache_map.find (key);
if (it == item_cache_map.end())
return false;
else
{
it->second->Delete();
item_cache_map.erase(it);
return true;
}
}
bool InsertItemInfo (ItemInfo *pNew, bool bSkipQuery = false)
{
ItemInfoCache* c = GetItemInfoCache (Key (pNew->item_num, pNew->offer_id));
if (c != NULL)
{
return false;
}
c = new ItemInfoCache();
c->Put(pNew, bSkipQuery);
item_cache_map.insert(TItemInfoCacheMap::value_type(Key (pNew->item_num, pNew->offer_id), c));
c->Flush();
return true;
}
private:
typedef std::unordered_map <Key, ItemInfoCache *> TItemInfoCacheMap;
TItemInfoCacheMap item_cache_map;
};
// pc가 입찰에 참여했던 경매를 관리.
class MyBidBoard
{
public:
MyBidBoard() {}
~MyBidBoard() {}
void Boot(CPeer* peer);
size_t Size();
int GetMoney (DWORD player_id, DWORD item_id);
bool Delete (DWORD player_id, DWORD item_id);
// 이미 있으면 덮어 씌운다.
void Insert (DWORD player_id, DWORD item_id, int money);
private:
typedef std::map <DWORD, int> TItemMap;
typedef std::unordered_map <DWORD, TItemMap*> TMyBidBoard;
TMyBidBoard pc_map;
};
class AuctionManager : public singleton <AuctionManager>
{
private:
// auction에 등록된 아이템들.
typedef std::unordered_map<DWORD, CItemCache *> TItemCacheMap;
TItemCacheMap auction_item_cache_map;
// auction에 등록된 정보 중 가격, 등등 아이템 테이블에 포함되지 않는 정보들을 관리하는 것들
AuctionBoard Auction;
SaleBoard Sale;
WishBoard Wish;
MyBidBoard MyBid;
public:
AuctionManager();
~AuctionManager();
void Initialize ();
void LoadAuctionItem ();
void LoadAuctionInfo ();
void LoadSaleInfo ();
void LoadWishInfo ();
void LoadMyBidInfo ();
void Boot(CPeer* peer);
bool InsertItemCache (CItemCache *item_cache, bool bSkipQuery = false);
bool InsertItemCache (TPlayerItem * pNew, bool bSkipQuery = false);
bool DeleteItemCache (DWORD item_id);
CItemCache* GetItemCache (DWORD item_id);
size_t GetAuctionItemSize()
{
return auction_item_cache_map.size();
}
size_t GetAuctionSize()
{
return Auction.Size();
}
size_t GetSaleSize()
{
return Sale.Size();
}
size_t GetWishSize()
{
return Wish.Size();
}
size_t GetMyBidSize()
{
return MyBid.Size();
}
void InsertAuctionItemInfoCache (TAuctionItemInfo *pNew, bool bSkipQuery = false)
{
Auction.InsertItemInfo (pNew, bSkipQuery);
}
CAuctionItemInfoCache* GetAuctionItemInfoCache (DWORD item_id)
{
return Auction.GetItemInfoCache(item_id);
}
void InsertSaleItemInfoCache (TSaleItemInfo *pNew, bool bSkipQuery = false)
{
Sale.InsertItemInfo (pNew, bSkipQuery);
}
CSaleItemInfoCache* GetSaleItemInfoCache (DWORD item_id)
{
return Sale.GetItemInfoCache(item_id);
}
void InsertWishItemInfoCache (TWishItemInfo *pNew, bool bSkipQuery = false)
{
Wish.InsertItemInfo (pNew, bSkipQuery);
}
CWishItemInfoCache* GetWishItemInfoCache (DWORD item_id, DWORD wisher_id)
{
return Wish.GetItemInfoCache(WishBoard::Key (item_id, wisher_id));
}
void InsertMyBid (DWORD player_id, DWORD item_id, DWORD money)
{
MyBid.Insert (player_id, item_id, money);
}
AuctionResult EnrollInAuction(CItemCache* item_cache, TAuctionItemInfo &item_info);
AuctionResult EnrollInSale(CItemCache* item_cache, TSaleItemInfo &item_info);
AuctionResult EnrollInWish(TWishItemInfo &item_info);
AuctionResult Bid(DWORD bidder_id, const char* bidder_name, DWORD item_id, DWORD bid_price);
AuctionResult Impur(DWORD purchaser_id, const char* purchaser_name, DWORD item_id);
AuctionResult GetAuctionedItem (DWORD actor_id, DWORD item_id, TPlayerItem& item);
AuctionResult BuySoldItem (DWORD actor_id, DWORD item_id, TPlayerItem& item);
AuctionResult CancelAuction (DWORD actor_id, DWORD item_id, TPlayerItem& item);
AuctionResult CancelWish (DWORD actor_id, DWORD item_num);
AuctionResult CancelSale (DWORD actor_id, DWORD item_id, TPlayerItem& item);
AuctionResult DeleteAuctionItem (DWORD actor_id, DWORD item_id);
AuctionResult DeleteSaleItem (DWORD actor_id, DWORD item_id);
AuctionResult ReBid(DWORD bidder_id, const char* bidder_name, DWORD item_id, DWORD bid_price);
AuctionResult BidCancel (DWORD bidder_id, DWORD item_id);
};
#endif
#endif

View File

@ -4,9 +4,6 @@
#include "QID.h" #include "QID.h"
#include "ClientManager.h" #include "ClientManager.h"
#ifdef __AUCTION__
#include "AuctionManager.h"
#endif
#include "Main.h" #include "Main.h"
extern CPacketInfo g_item_info; extern CPacketInfo g_item_info;
@ -18,7 +15,6 @@ extern int g_iItemPriceListTableCacheFlushSeconds;
// END_OF_MYSHOP_PRICE_LIST // END_OF_MYSHOP_PRICE_LIST
// //
extern int g_item_count; extern int g_item_count;
const int auctionMinFlushSec = 1800;
CItemCache::CItemCache() CItemCache::CItemCache()
{ {
@ -42,17 +38,17 @@ void CItemCache::Delete()
if (m_data.vnum == 0) if (m_data.vnum == 0)
return; return;
//char szQuery[QUERY_MAX_LEN]; // char szQuery[QUERY_MAX_LEN];
//szQuery[QUERY_MAX_LEN] = '\0'; // szQuery[QUERY_MAX_LEN] = '\0';
SPDLOG_TRACE("ItemCache::Delete : DELETE {}", m_data.id); SPDLOG_TRACE("ItemCache::Delete : DELETE {}", m_data.id);
m_data.vnum = 0; m_data.vnum = 0;
m_bNeedQuery = true; m_bNeedQuery = true;
m_lastUpdateTime = time(0); m_lastUpdateTime = time(0);
OnFlush(); OnFlush();
//m_bNeedQuery = false; // m_bNeedQuery = false;
//m_lastUpdateTime = time(0) - m_expireTime; // 바로 타임아웃 되도록 하자. // m_lastUpdateTime = time(0) - m_expireTime; // 바로 타임아웃 되도록 하자.
} }
void CItemCache::OnFlush() void CItemCache::OnFlush()
@ -63,7 +59,7 @@ void CItemCache::OnFlush()
snprintf(szQuery, sizeof(szQuery), "DELETE FROM item%s WHERE id=%u", GetTablePostfix(), m_data.id); snprintf(szQuery, sizeof(szQuery), "DELETE FROM item%s WHERE id=%u", GetTablePostfix(), m_data.id);
CDBManager::instance().ReturnQuery(szQuery, QID_ITEM_DESTROY, 0, NULL); CDBManager::instance().ReturnQuery(szQuery, QID_ITEM_DESTROY, 0, NULL);
SPDLOG_TRACE("ItemCache::Flush : DELETE {} {}", m_data.id, szQuery); SPDLOG_TRACE("ItemCache::Flush : DELETE {} {}", m_data.id, szQuery);
} }
else else
{ {
@ -74,7 +70,7 @@ void CItemCache::OnFlush()
memset(&alSockets, 0, sizeof(int) * ITEM_SOCKET_MAX_NUM); memset(&alSockets, 0, sizeof(int) * ITEM_SOCKET_MAX_NUM);
memset(&aAttr, 0, sizeof(TPlayerItemAttribute) * ITEM_ATTRIBUTE_MAX_NUM); memset(&aAttr, 0, sizeof(TPlayerItemAttribute) * ITEM_ATTRIBUTE_MAX_NUM);
TPlayerItem * p = &m_data; TPlayerItem *p = &m_data;
if (memcmp(alSockets, p->alSockets, sizeof(int) * ITEM_SOCKET_MAX_NUM)) if (memcmp(alSockets, p->alSockets, sizeof(int) * ITEM_SOCKET_MAX_NUM))
isSocket = true; isSocket = true;
@ -89,51 +85,51 @@ void CItemCache::OnFlush()
int iLen = snprintf(szColumns, sizeof(szColumns), "id, owner_id, window, pos, count, vnum"); int iLen = snprintf(szColumns, sizeof(szColumns), "id, owner_id, window, pos, count, vnum");
int iValueLen = snprintf(szValues, sizeof(szValues), "%u, %u, %d, %d, %u, %u", int iValueLen = snprintf(szValues, sizeof(szValues), "%u, %u, %d, %d, %u, %u",
p->id, p->owner, p->window, p->pos, p->count, p->vnum); p->id, p->owner, p->window, p->pos, p->count, p->vnum);
int iUpdateLen = snprintf(szUpdate, sizeof(szUpdate), "owner_id=%u, window=%d, pos=%d, count=%u, vnum=%u", int iUpdateLen = snprintf(szUpdate, sizeof(szUpdate), "owner_id=%u, window=%d, pos=%d, count=%u, vnum=%u",
p->owner, p->window, p->pos, p->count, p->vnum); p->owner, p->window, p->pos, p->count, p->vnum);
if (isSocket) if (isSocket)
{ {
iLen += snprintf(szColumns + iLen, sizeof(szColumns) - iLen, ", socket0, socket1, socket2"); iLen += snprintf(szColumns + iLen, sizeof(szColumns) - iLen, ", socket0, socket1, socket2");
iValueLen += snprintf(szValues + iValueLen, sizeof(szValues) - iValueLen, iValueLen += snprintf(szValues + iValueLen, sizeof(szValues) - iValueLen,
", %d, %d, %d", p->alSockets[0], p->alSockets[1], p->alSockets[2]); ", %d, %d, %d", p->alSockets[0], p->alSockets[1], p->alSockets[2]);
iUpdateLen += snprintf(szUpdate + iUpdateLen, sizeof(szUpdate) - iUpdateLen, iUpdateLen += snprintf(szUpdate + iUpdateLen, sizeof(szUpdate) - iUpdateLen,
", socket0=%d, socket1=%d, socket2=%d", p->alSockets[0], p->alSockets[1], p->alSockets[2]); ", socket0=%d, socket1=%d, socket2=%d", p->alSockets[0], p->alSockets[1], p->alSockets[2]);
} }
if (isAttr) if (isAttr)
{ {
iLen += snprintf(szColumns + iLen, sizeof(szColumns) - iLen, iLen += snprintf(szColumns + iLen, sizeof(szColumns) - iLen,
", attrtype0, attrvalue0, attrtype1, attrvalue1, attrtype2, attrvalue2, attrtype3, attrvalue3" ", attrtype0, attrvalue0, attrtype1, attrvalue1, attrtype2, attrvalue2, attrtype3, attrvalue3"
", attrtype4, attrvalue4, attrtype5, attrvalue5, attrtype6, attrvalue6"); ", attrtype4, attrvalue4, attrtype5, attrvalue5, attrtype6, attrvalue6");
iValueLen += snprintf(szValues + iValueLen, sizeof(szValues) - iValueLen, iValueLen += snprintf(szValues + iValueLen, sizeof(szValues) - iValueLen,
", %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d", ", %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d",
p->aAttr[0].bType, p->aAttr[0].sValue, p->aAttr[0].bType, p->aAttr[0].sValue,
p->aAttr[1].bType, p->aAttr[1].sValue, p->aAttr[1].bType, p->aAttr[1].sValue,
p->aAttr[2].bType, p->aAttr[2].sValue, p->aAttr[2].bType, p->aAttr[2].sValue,
p->aAttr[3].bType, p->aAttr[3].sValue, p->aAttr[3].bType, p->aAttr[3].sValue,
p->aAttr[4].bType, p->aAttr[4].sValue, p->aAttr[4].bType, p->aAttr[4].sValue,
p->aAttr[5].bType, p->aAttr[5].sValue, p->aAttr[5].bType, p->aAttr[5].sValue,
p->aAttr[6].bType, p->aAttr[6].sValue); p->aAttr[6].bType, p->aAttr[6].sValue);
iUpdateLen += snprintf(szUpdate + iUpdateLen, sizeof(szUpdate) - iUpdateLen, iUpdateLen += snprintf(szUpdate + iUpdateLen, sizeof(szUpdate) - iUpdateLen,
", attrtype0=%d, attrvalue0=%d" ", attrtype0=%d, attrvalue0=%d"
", attrtype1=%d, attrvalue1=%d" ", attrtype1=%d, attrvalue1=%d"
", attrtype2=%d, attrvalue2=%d" ", attrtype2=%d, attrvalue2=%d"
", attrtype3=%d, attrvalue3=%d" ", attrtype3=%d, attrvalue3=%d"
", attrtype4=%d, attrvalue4=%d" ", attrtype4=%d, attrvalue4=%d"
", attrtype5=%d, attrvalue5=%d" ", attrtype5=%d, attrvalue5=%d"
", attrtype6=%d, attrvalue6=%d", ", attrtype6=%d, attrvalue6=%d",
p->aAttr[0].bType, p->aAttr[0].sValue, p->aAttr[0].bType, p->aAttr[0].sValue,
p->aAttr[1].bType, p->aAttr[1].sValue, p->aAttr[1].bType, p->aAttr[1].sValue,
p->aAttr[2].bType, p->aAttr[2].sValue, p->aAttr[2].bType, p->aAttr[2].sValue,
p->aAttr[3].bType, p->aAttr[3].sValue, p->aAttr[3].bType, p->aAttr[3].sValue,
p->aAttr[4].bType, p->aAttr[4].sValue, p->aAttr[4].bType, p->aAttr[4].sValue,
p->aAttr[5].bType, p->aAttr[5].sValue, p->aAttr[5].bType, p->aAttr[5].sValue,
p->aAttr[6].bType, p->aAttr[6].sValue); p->aAttr[6].bType, p->aAttr[6].sValue);
} }
char szItemQuery[QUERY_MAX_LEN + QUERY_MAX_LEN + 100]; char szItemQuery[QUERY_MAX_LEN + QUERY_MAX_LEN + 100];
@ -143,7 +139,7 @@ void CItemCache::OnFlush()
CDBManager::instance().ReturnQuery(szItemQuery, QID_ITEM_SAVE, 0, NULL); CDBManager::instance().ReturnQuery(szItemQuery, QID_ITEM_SAVE, 0, NULL);
//g_item_info.Add(p->vnum); // g_item_info.Add(p->vnum);
++g_item_count; ++g_item_count;
} }
@ -183,7 +179,7 @@ CItemPriceListTableCache::CItemPriceListTableCache()
m_expireTime = std::min(s_nMinFlushSec, g_iItemPriceListTableCacheFlushSeconds); m_expireTime = std::min(s_nMinFlushSec, g_iItemPriceListTableCacheFlushSeconds);
} }
void CItemPriceListTableCache::UpdateList(const TItemPriceListTable* pUpdateList) void CItemPriceListTableCache::UpdateList(const TItemPriceListTable *pUpdateList)
{ {
// //
// 이미 캐싱된 아이템과 중복된 아이템을 찾고 중복되지 않는 이전 정보는 tmpvec 에 넣는다. // 이미 캐싱된 아이템과 중복된 아이템을 찾고 중복되지 않는 이전 정보는 tmpvec 에 넣는다.
@ -193,7 +189,7 @@ void CItemPriceListTableCache::UpdateList(const TItemPriceListTable* pUpdateList
for (uint idx = 0; idx < m_data.byCount; ++idx) for (uint idx = 0; idx < m_data.byCount; ++idx)
{ {
const TItemPriceInfo* pos = pUpdateList->aPriceInfo; const TItemPriceInfo *pos = pUpdateList->aPriceInfo;
for (; pos != pUpdateList->aPriceInfo + pUpdateList->byCount && m_data.aPriceInfo[idx].dwVnum != pos->dwVnum; ++pos) for (; pos != pUpdateList->aPriceInfo + pUpdateList->byCount && m_data.aPriceInfo[idx].dwVnum != pos->dwVnum; ++pos)
; ;
@ -203,7 +199,7 @@ void CItemPriceListTableCache::UpdateList(const TItemPriceListTable* pUpdateList
// //
// pUpdateList 를 m_data 에 복사하고 남은 공간을 tmpvec 의 앞에서 부터 남은 만큼 복사한다. // pUpdateList 를 m_data 에 복사하고 남은 공간을 tmpvec 의 앞에서 부터 남은 만큼 복사한다.
// //
if (pUpdateList->byCount > SHOP_PRICELIST_MAX_NUM) if (pUpdateList->byCount > SHOP_PRICELIST_MAX_NUM)
{ {
@ -215,7 +211,7 @@ void CItemPriceListTableCache::UpdateList(const TItemPriceListTable* pUpdateList
memcpy(m_data.aPriceInfo, pUpdateList->aPriceInfo, sizeof(TItemPriceInfo) * pUpdateList->byCount); memcpy(m_data.aPriceInfo, pUpdateList->aPriceInfo, sizeof(TItemPriceInfo) * pUpdateList->byCount);
int nDeletedNum; // 삭제된 가격정보의 갯수 int nDeletedNum; // 삭제된 가격정보의 갯수
if (pUpdateList->byCount < SHOP_PRICELIST_MAX_NUM) if (pUpdateList->byCount < SHOP_PRICELIST_MAX_NUM)
{ {
@ -235,8 +231,8 @@ void CItemPriceListTableCache::UpdateList(const TItemPriceListTable* pUpdateList
m_bNeedQuery = true; m_bNeedQuery = true;
SPDLOG_DEBUG( SPDLOG_DEBUG(
"ItemPriceListTableCache::UpdateList : OwnerID[{}] Update [{}] Items, Delete [{}] Items, Total [{}] Items", "ItemPriceListTableCache::UpdateList : OwnerID[{}] Update [{}] Items, Delete [{}] Items, Total [{}] Items",
m_data.dwOwnerID, pUpdateList->byCount, nDeletedNum, m_data.byCount); m_data.dwOwnerID, pUpdateList->byCount, nDeletedNum, m_data.byCount);
} }
void CItemPriceListTableCache::OnFlush() void CItemPriceListTableCache::OnFlush()
@ -257,104 +253,13 @@ void CItemPriceListTableCache::OnFlush()
for (int idx = 0; idx < m_data.byCount; ++idx) for (int idx = 0; idx < m_data.byCount; ++idx)
{ {
snprintf(szQuery, sizeof(szQuery), snprintf(szQuery, sizeof(szQuery),
"INSERT INTO myshop_pricelist%s(owner_id, item_vnum, price) VALUES(%u, %u, %u)", "INSERT INTO myshop_pricelist%s(owner_id, item_vnum, price) VALUES(%u, %u, %u)",
GetTablePostfix(), m_data.dwOwnerID, m_data.aPriceInfo[idx].dwVnum, m_data.aPriceInfo[idx].dwPrice); GetTablePostfix(), m_data.dwOwnerID, m_data.aPriceInfo[idx].dwVnum, m_data.aPriceInfo[idx].dwPrice);
CDBManager::instance().ReturnQuery(szQuery, QID_ITEMPRICE_SAVE, 0, NULL); CDBManager::instance().ReturnQuery(szQuery, QID_ITEMPRICE_SAVE, 0, NULL);
} }
SPDLOG_DEBUG("ItemPriceListTableCache::Flush : OwnerID[{}] Update [{}]Items", m_data.dwOwnerID, m_data.byCount); SPDLOG_DEBUG("ItemPriceListTableCache::Flush : OwnerID[{}] Update [{}]Items", m_data.dwOwnerID, m_data.byCount);
m_bNeedQuery = false; m_bNeedQuery = false;
} }
// END_OF_MYSHOP_PRICE_LIST // END_OF_MYSHOP_PRICE_LIST
#ifdef __AUCTION__
CAuctionItemInfoCache::CAuctionItemInfoCache()
{
m_expireTime = MIN (auctionMinFlushSec, g_iItemCacheFlushSeconds);
}
CAuctionItemInfoCache::~CAuctionItemInfoCache()
{
}
void CAuctionItemInfoCache::Delete()
{
if (m_data.item_num == 0)
return;
SPDLOG_TRACE("CAuctionItemInfoCache::Delete : DELETE {}", m_data.item_id);
m_data.item_num = 0;
m_bNeedQuery = true;
m_lastUpdateTime = time(0);
OnFlush();
delete this;
}
void CAuctionItemInfoCache::OnFlush()
{
char szQuery[QUERY_MAX_LEN];
if (m_data.item_num == 0)
{
snprintf(szQuery, sizeof(szQuery), "DELETE FROM auction where item_id = %d", m_data.item_id);
CDBManager::instance().AsyncQuery(szQuery);
}
else
{
snprintf(szQuery, sizeof(szQuery), "REPLACE INTO auction VALUES (%u, %d, %d, %u, \"%s\", %u, %u, %u, %u)",
m_data.item_num, m_data.offer_price, m_data.price, m_data.offer_id, m_data.shown_name, (DWORD)m_data.empire, (DWORD)m_data.expired_time,
m_data.item_id, m_data.bidder_id);
CDBManager::instance().AsyncQuery(szQuery);
}
}
CSaleItemInfoCache::CSaleItemInfoCache()
{
m_expireTime = MIN (auctionMinFlushSec, g_iItemCacheFlushSeconds);
}
CSaleItemInfoCache::~CSaleItemInfoCache()
{
}
void CSaleItemInfoCache::Delete()
{
}
void CSaleItemInfoCache::OnFlush()
{
char szQuery[QUERY_MAX_LEN];
snprintf(szQuery, sizeof(szQuery), "REPLACE INTO sale VALUES (%u, %d, %d, %u, \"%s\", %u, %u, %u, %u)",
m_data.item_num, m_data.offer_price, m_data.price, m_data.offer_id, m_data.shown_name, (DWORD)m_data.empire, (DWORD)m_data.expired_time,
m_data.item_id, m_data.wisher_id);
CDBManager::instance().AsyncQuery(szQuery);
}
CWishItemInfoCache::CWishItemInfoCache()
{
m_expireTime = MIN (auctionMinFlushSec, g_iItemCacheFlushSeconds);
}
CWishItemInfoCache::~CWishItemInfoCache()
{
}
void CWishItemInfoCache::Delete()
{
}
void CWishItemInfoCache::OnFlush()
{
char szQuery[QUERY_MAX_LEN];
snprintf(szQuery, sizeof(szQuery), "REPLACE INTO wish VALUES (%u, %d, %d, %u, \"%s\", %u, %d)",
m_data.item_num, m_data.offer_price, m_data.price, m_data.offer_id, m_data.shown_name, (DWORD)m_data.empire, (DWORD)m_data.expired_time);
CDBManager::instance().AsyncQuery(szQuery);
}
#endif

View File

@ -3,11 +3,10 @@
#define __INC_DB_CACHE_H__ #define __INC_DB_CACHE_H__
#include <common/cache.h> #include <common/cache.h>
#include <common/auction_table.h>
class CItemCache : public cache<TPlayerItem> class CItemCache : public cache<TPlayerItem>
{ {
public: public:
CItemCache(); CItemCache();
virtual ~CItemCache(); virtual ~CItemCache();
@ -17,7 +16,7 @@ class CItemCache : public cache<TPlayerItem>
class CPlayerTableCache : public cache<TPlayerTable> class CPlayerTableCache : public cache<TPlayerTable>
{ {
public: public:
CPlayerTableCache(); CPlayerTableCache();
virtual ~CPlayerTableCache(); virtual ~CPlayerTableCache();
@ -32,10 +31,9 @@ class CPlayerTableCache : public cache<TPlayerTable>
* @brief class * @brief class
* @version 05/06/10 Bang2ni - First release. * @version 05/06/10 Bang2ni - First release.
*/ */
class CItemPriceListTableCache : public cache< TItemPriceListTable > class CItemPriceListTableCache : public cache<TItemPriceListTable>
{ {
public: public:
/// Constructor /// Constructor
/** /**
* . * .
@ -49,49 +47,13 @@ class CItemPriceListTableCache : public cache< TItemPriceListTable >
* . * .
* . * .
*/ */
void UpdateList(const TItemPriceListTable* pUpdateList); void UpdateList(const TItemPriceListTable *pUpdateList);
/// 가격정보를 DB 에 기록한다. /// 가격정보를 DB 에 기록한다.
virtual void OnFlush(void); virtual void OnFlush(void);
private: private:
static const int s_nMinFlushSec; ///< Minimum cache expire time
static const int s_nMinFlushSec; ///< Minimum cache expire time
}; };
// END_OF_MYSHOP_PRICE_LIST // END_OF_MYSHOP_PRICE_LIST
#ifdef __AUCTION__
class CAuctionItemInfoCache : public cache <TAuctionItemInfo>
{
public:
typedef TWishItemInfo value_type;
CAuctionItemInfoCache();
virtual ~CAuctionItemInfoCache();
void Delete();
virtual void OnFlush();
};
class CSaleItemInfoCache : public cache <TSaleItemInfo>
{
public:
typedef TWishItemInfo value_type;
CSaleItemInfoCache();
virtual ~CSaleItemInfoCache();
void Delete();
virtual void OnFlush();
};
class CWishItemInfoCache : public cache <TWishItemInfo>
{
public:
typedef TWishItemInfo value_type;
CWishItemInfoCache();
virtual ~CWishItemInfoCache();
void Delete();
virtual void OnFlush();
};
#endif
#endif #endif

File diff suppressed because it is too large Load Diff

View File

@ -9,7 +9,6 @@
#include <common/stl.h> #include <common/stl.h>
#include <common/building.h> #include <common/building.h>
#include <common/auction_table.h>
#include "Peer.h" #include "Peer.h"
#include "DBManager.h" #include "DBManager.h"
@ -21,14 +20,14 @@ class CItemPriceListTableCache;
class CPacketInfo class CPacketInfo
{ {
public: public:
void Add(int header); void Add(int header);
void Reset(); void Reset();
std::map<int, int> m_map_info; std::map<int, int> m_map_info;
}; };
size_t CreatePlayerSaveQuery(char * pszQuery, size_t querySize, TPlayerTable * pkTab); size_t CreatePlayerSaveQuery(char *pszQuery, size_t querySize, TPlayerTable *pkTab);
static void AcceptConnection(evconnlistener *listener, evutil_socket_t fd, sockaddr *address, int socklen, void *ctx); static void AcceptConnection(evconnlistener *listener, evutil_socket_t fd, sockaddr *address, int socklen, void *ctx);
static void AcceptError(evconnlistener *listener, void *ctx); static void AcceptError(evconnlistener *listener, void *ctx);
@ -38,13 +37,13 @@ static void DescEventHandler(bufferevent *bev, short events, void *ctx);
class CClientManager : public singleton<CClientManager> class CClientManager : public singleton<CClientManager>
{ {
public: public:
typedef std::list<CPeer *> TPeerList; typedef std::list<CPeer *> TPeerList;
typedef std::unordered_map<DWORD, CPlayerTableCache *> TPlayerTableCacheMap; typedef std::unordered_map<DWORD, CPlayerTableCache *> TPlayerTableCacheMap;
typedef std::unordered_map<DWORD, CItemCache *> TItemCacheMap; typedef std::unordered_map<DWORD, CItemCache *> TItemCacheMap;
typedef std::unordered_set<CItemCache *, std::hash<CItemCache*> > TItemCacheSet; typedef std::unordered_set<CItemCache *, std::hash<CItemCache *>> TItemCacheSet;
typedef std::unordered_map<DWORD, TItemCacheSet *> TItemCacheSetPtrMap; typedef std::unordered_map<DWORD, TItemCacheSet *> TItemCacheSetPtrMap;
typedef std::unordered_map<DWORD, CItemPriceListTableCache*> TItemPriceListCacheMap; typedef std::unordered_map<DWORD, CItemPriceListTableCache *> TItemPriceListCacheMap;
typedef std::unordered_map<short, BYTE> TChannelStatusMap; typedef std::unordered_map<short, BYTE> TChannelStatusMap;
// MYSHOP_PRICE_LIST // MYSHOP_PRICE_LIST
@ -53,43 +52,43 @@ class CClientManager : public singleton<CClientManager>
* first: Peer handle * first: Peer handle
* second: ID * second: ID
*/ */
typedef std::pair< DWORD, DWORD > TItemPricelistReqInfo; typedef std::pair<DWORD, DWORD> TItemPricelistReqInfo;
// END_OF_MYSHOP_PRICE_LIST // END_OF_MYSHOP_PRICE_LIST
class ClientHandleInfo class ClientHandleInfo
{ {
public: public:
DWORD dwHandle; DWORD dwHandle;
DWORD account_id; DWORD account_id;
DWORD player_id; DWORD player_id;
BYTE account_index; BYTE account_index;
char login[LOGIN_MAX_LEN + 1]; char login[LOGIN_MAX_LEN + 1];
char safebox_password[SAFEBOX_PASSWORD_MAX_LEN + 1]; char safebox_password[SAFEBOX_PASSWORD_MAX_LEN + 1];
char ip[MAX_HOST_LENGTH + 1]; char ip[MAX_HOST_LENGTH + 1];
TAccountTable * pAccountTable; TAccountTable *pAccountTable;
TSafeboxTable * pSafebox; TSafeboxTable *pSafebox;
ClientHandleInfo(DWORD argHandle, DWORD dwPID = 0) ClientHandleInfo(DWORD argHandle, DWORD dwPID = 0)
{ {
dwHandle = argHandle; dwHandle = argHandle;
pSafebox = NULL; pSafebox = NULL;
pAccountTable = NULL; pAccountTable = NULL;
player_id = dwPID; player_id = dwPID;
}; };
//독일선물기능용 생성자 // Constructor for the German gift feature
ClientHandleInfo(DWORD argHandle, DWORD dwPID, DWORD accountId) ClientHandleInfo(DWORD argHandle, DWORD dwPID, DWORD accountId)
{ {
dwHandle = argHandle; dwHandle = argHandle;
pSafebox = NULL; pSafebox = NULL;
pAccountTable = NULL; pAccountTable = NULL;
player_id = dwPID; player_id = dwPID;
account_id = accountId; account_id = accountId;
}; };
~ClientHandleInfo() ~ClientHandleInfo()
{ {
if (pSafebox) if (pSafebox)
{ {
delete pSafebox; delete pSafebox;
pSafebox = NULL; pSafebox = NULL;
@ -97,43 +96,43 @@ class CClientManager : public singleton<CClientManager>
} }
}; };
public: public:
CClientManager(); CClientManager();
~CClientManager(); ~CClientManager();
bool Initialize(); bool Initialize();
time_t GetCurrentTime(); time_t GetCurrentTime();
void MainLoop(); void MainLoop();
void Quit(); void Quit();
void SetTablePostfix(const char* c_pszTablePostfix); void SetTablePostfix(const char *c_pszTablePostfix);
void SetPlayerIDStart(int iIDStart); void SetPlayerIDStart(int iIDStart);
int GetPlayerIDStart() { return m_iPlayerIDStart; } int GetPlayerIDStart() { return m_iPlayerIDStart; }
int GetPlayerDeleteLevelLimit() { return m_iPlayerDeleteLevelLimit; } int GetPlayerDeleteLevelLimit() { return m_iPlayerDeleteLevelLimit; }
void SetChinaEventServer(bool flag) { m_bChinaEventServer = flag; } void SetChinaEventServer(bool flag) { m_bChinaEventServer = flag; }
bool IsChinaEventServer() { return m_bChinaEventServer; } bool IsChinaEventServer() { return m_bChinaEventServer; }
DWORD GetUserCount(); // 접속된 사용자 수를 리턴 한다. DWORD GetUserCount(); // 접속된 사용자 수를 리턴 한다.
void SendAllGuildSkillRechargePacket(); void SendAllGuildSkillRechargePacket();
void SendTime(); void SendTime();
CPlayerTableCache * GetPlayerCache(DWORD id); CPlayerTableCache *GetPlayerCache(DWORD id);
void PutPlayerCache(TPlayerTable * pNew); void PutPlayerCache(TPlayerTable *pNew);
void CreateItemCacheSet(DWORD dwID); void CreateItemCacheSet(DWORD dwID);
TItemCacheSet * GetItemCacheSet(DWORD dwID); TItemCacheSet *GetItemCacheSet(DWORD dwID);
void FlushItemCacheSet(DWORD dwID); void FlushItemCacheSet(DWORD dwID);
CItemCache * GetItemCache(DWORD id); CItemCache *GetItemCache(DWORD id);
void PutItemCache(TPlayerItem * pNew, bool bSkipQuery = false); void PutItemCache(TPlayerItem *pNew, bool bSkipQuery = false);
bool DeleteItemCache(DWORD id); bool DeleteItemCache(DWORD id);
void UpdatePlayerCache(); void UpdatePlayerCache();
void UpdateItemCache(); void UpdateItemCache();
// MYSHOP_PRICE_LIST // MYSHOP_PRICE_LIST
/// 가격정보 리스트 캐시를 가져온다. /// 가격정보 리스트 캐시를 가져온다.
@ -141,7 +140,7 @@ class CClientManager : public singleton<CClientManager>
* @param [in] dwID .( ID) * @param [in] dwID .( ID)
* @return * @return
*/ */
CItemPriceListTableCache* GetItemPriceListCache(DWORD dwID); CItemPriceListTableCache *GetItemPriceListCache(DWORD dwID);
/// 가격정보 리스트 캐시를 넣는다. /// 가격정보 리스트 캐시를 넣는다.
/** /**
@ -149,116 +148,114 @@ class CClientManager : public singleton<CClientManager>
* *
* Update replace . * Update replace .
*/ */
void PutItemPriceListCache(const TItemPriceListTable* pItemPriceList); void PutItemPriceListCache(const TItemPriceListTable *pItemPriceList);
/// Flush 시간이 만료된 아이템 가격정보 리스트 캐시를 Flush 해주고 캐시에서 삭제한다. /// Flush 시간이 만료된 아이템 가격정보 리스트 캐시를 Flush 해주고 캐시에서 삭제한다.
void UpdateItemPriceListCache(void); void UpdateItemPriceListCache(void);
// END_OF_MYSHOP_PRICE_LIST // END_OF_MYSHOP_PRICE_LIST
void SendGuildSkillUsable(DWORD guild_id, DWORD dwSkillVnum, bool bUsable);
void SendGuildSkillUsable(DWORD guild_id, DWORD dwSkillVnum, bool bUsable); void SetCacheFlushCountLimit(int iLimit);
void SetCacheFlushCountLimit(int iLimit);
template <class Func> template <class Func>
Func for_each_peer(Func f); Func for_each_peer(Func f);
CPeer * GetAnyPeer(); CPeer *GetAnyPeer();
void ForwardPacket(BYTE header, const void* data, int size, BYTE bChannel = 0, CPeer * except = NULL); void ForwardPacket(BYTE header, const void *data, int size, BYTE bChannel = 0, CPeer *except = NULL);
void SendNotice(const char * c_pszFormat, ...); void SendNotice(const char *c_pszFormat, ...);
std::string GetCommand(char* str); //독일선물기능에서 명령어 얻는 함수 std::string GetCommand(char *str); // 독일선물기능에서 명령어 얻는 함수
void ItemAward(CPeer * peer, char* login); //독일 선물 기능 void ItemAward(CPeer *peer, char *login); // 독일 선물 기능
CPeer * AddPeer(bufferevent* bufev, sockaddr* addr); CPeer *AddPeer(bufferevent *bufev, sockaddr *addr);
void RemovePeer(CPeer * pPeer); void RemovePeer(CPeer *pPeer);
CPeer * GetPeer(IDENT ident); CPeer *GetPeer(IDENT ident);
CPeer * GetAuthPeer(); CPeer *GetAuthPeer();
void ProcessPackets(CPeer * peer); void ProcessPackets(CPeer *peer);
protected: protected:
void Destroy(); void Destroy();
private: private:
bool InitializeTables(); bool InitializeTables();
bool InitializeShopTable(); bool InitializeShopTable();
bool InitializeMobTable(); bool InitializeMobTable();
bool InitializeItemTable(); bool InitializeItemTable();
bool InitializeQuestItemTable(); bool InitializeQuestItemTable();
bool InitializeSkillTable(); bool InitializeSkillTable();
bool InitializeRefineTable(); bool InitializeRefineTable();
bool InitializeBanwordTable(); bool InitializeBanwordTable();
bool InitializeItemAttrTable(); bool InitializeItemAttrTable();
bool InitializeItemRareTable(); bool InitializeItemRareTable();
bool InitializeLandTable(); bool InitializeLandTable();
bool InitializeObjectProto(); bool InitializeObjectProto();
bool InitializeObjectTable(); bool InitializeObjectTable();
bool InitializeMonarch(); bool InitializeMonarch();
// mob_proto.txt, item_proto.txt에서 읽은 mob_proto, item_proto를 real db에 반영. // mob_proto.txt, item_proto.txt에서 읽은 mob_proto, item_proto를 real db에 반영.
// item_proto, mob_proto를 db에 반영하지 않아도, 게임 돌아가는데는 문제가 없지만, // item_proto, mob_proto를 db에 반영하지 않아도, 게임 돌아가는데는 문제가 없지만,
// 운영툴 등에서 db의 item_proto, mob_proto를 읽어 쓰기 때문에 문제가 발생한다. // 운영툴 등에서 db의 item_proto, mob_proto를 읽어 쓰기 때문에 문제가 발생한다.
bool MirrorMobTableIntoDB(); bool MirrorMobTableIntoDB();
bool MirrorItemTableIntoDB(); bool MirrorItemTableIntoDB();
int AnalyzeQueryResult(SQLMsg * msg); int AnalyzeQueryResult(SQLMsg *msg);
int AnalyzeErrorMsg(CPeer * peer, SQLMsg * msg); int AnalyzeErrorMsg(CPeer *peer, SQLMsg *msg);
int Process(); int Process();
CLoginData * GetLoginData(DWORD dwKey); CLoginData *GetLoginData(DWORD dwKey);
CLoginData * GetLoginDataByLogin(const char * c_pszLogin); CLoginData *GetLoginDataByLogin(const char *c_pszLogin);
CLoginData * GetLoginDataByAID(DWORD dwAID); CLoginData *GetLoginDataByAID(DWORD dwAID);
void InsertLoginData(CLoginData * pkLD); void InsertLoginData(CLoginData *pkLD);
void DeleteLoginData(CLoginData * pkLD); void DeleteLoginData(CLoginData *pkLD);
bool InsertLogonAccount(const char * c_pszLogin, DWORD dwHandle, const char * c_pszIP); bool InsertLogonAccount(const char *c_pszLogin, DWORD dwHandle, const char *c_pszIP);
bool DeleteLogonAccount(const char * c_pszLogin, DWORD dwHandle); bool DeleteLogonAccount(const char *c_pszLogin, DWORD dwHandle);
bool FindLogonAccount(const char * c_pszLogin); bool FindLogonAccount(const char *c_pszLogin);
void GuildCreate(CPeer * peer, DWORD dwGuildID); void GuildCreate(CPeer *peer, DWORD dwGuildID);
void GuildSkillUpdate(CPeer * peer, TPacketGuildSkillUpdate* p); void GuildSkillUpdate(CPeer *peer, TPacketGuildSkillUpdate *p);
void GuildExpUpdate(CPeer * peer, TPacketGuildExpUpdate* p); void GuildExpUpdate(CPeer *peer, TPacketGuildExpUpdate *p);
void GuildAddMember(CPeer * peer, TPacketGDGuildAddMember* p); void GuildAddMember(CPeer *peer, TPacketGDGuildAddMember *p);
void GuildChangeGrade(CPeer * peer, TPacketGuild* p); void GuildChangeGrade(CPeer *peer, TPacketGuild *p);
void GuildRemoveMember(CPeer * peer, TPacketGuild* p); void GuildRemoveMember(CPeer *peer, TPacketGuild *p);
void GuildChangeMemberData(CPeer * peer, TPacketGuildChangeMemberData* p); void GuildChangeMemberData(CPeer *peer, TPacketGuildChangeMemberData *p);
void GuildDisband(CPeer * peer, TPacketGuild * p); void GuildDisband(CPeer *peer, TPacketGuild *p);
void GuildWar(CPeer * peer, TPacketGuildWar * p); void GuildWar(CPeer *peer, TPacketGuildWar *p);
void GuildWarScore(CPeer * peer, TPacketGuildWarScore * p); void GuildWarScore(CPeer *peer, TPacketGuildWarScore *p);
void GuildChangeLadderPoint(TPacketGuildLadderPoint* p); void GuildChangeLadderPoint(TPacketGuildLadderPoint *p);
void GuildUseSkill(TPacketGuildUseSkill* p); void GuildUseSkill(TPacketGuildUseSkill *p);
void GuildDepositMoney(TPacketGDGuildMoney* p); void GuildDepositMoney(TPacketGDGuildMoney *p);
void GuildWithdrawMoney(CPeer* peer, TPacketGDGuildMoney* p); void GuildWithdrawMoney(CPeer *peer, TPacketGDGuildMoney *p);
void GuildWithdrawMoneyGiveReply(TPacketGDGuildMoneyWithdrawGiveReply* p); void GuildWithdrawMoneyGiveReply(TPacketGDGuildMoneyWithdrawGiveReply *p);
void GuildWarBet(TPacketGDGuildWarBet * p); void GuildWarBet(TPacketGDGuildWarBet *p);
void GuildChangeMaster(TPacketChangeGuildMaster* p); void GuildChangeMaster(TPacketChangeGuildMaster *p);
void SetGuildWarEndTime(DWORD guild_id1, DWORD guild_id2, time_t tEndTime); void SetGuildWarEndTime(DWORD guild_id1, DWORD guild_id2, time_t tEndTime);
void QUERY_BOOT(CPeer * peer, TPacketGDBoot * p); void QUERY_BOOT(CPeer *peer, TPacketGDBoot *p);
void QUERY_LOGIN(CPeer * peer, DWORD dwHandle, SLoginPacket* data); void QUERY_LOGIN(CPeer *peer, DWORD dwHandle, SLoginPacket *data);
void QUERY_LOGOUT(CPeer * peer, DWORD dwHandle, const char *); void QUERY_LOGOUT(CPeer *peer, DWORD dwHandle, const char *);
void RESULT_LOGIN(CPeer * peer, SQLMsg *msg); void RESULT_LOGIN(CPeer *peer, SQLMsg *msg);
void QUERY_PLAYER_LOAD(CPeer * peer, DWORD dwHandle, TPlayerLoadPacket*); void QUERY_PLAYER_LOAD(CPeer *peer, DWORD dwHandle, TPlayerLoadPacket *);
void RESULT_COMPOSITE_PLAYER(CPeer * peer, SQLMsg * pMsg, DWORD dwQID); void RESULT_COMPOSITE_PLAYER(CPeer *peer, SQLMsg *pMsg, DWORD dwQID);
void RESULT_PLAYER_LOAD(CPeer * peer, MYSQL_RES * pRes, ClientHandleInfo * pkInfo); void RESULT_PLAYER_LOAD(CPeer *peer, pqxx::result *pRes, ClientHandleInfo *pkInfo);
void RESULT_ITEM_LOAD(CPeer * peer, MYSQL_RES * pRes, DWORD dwHandle, DWORD dwPID); void RESULT_ITEM_LOAD(CPeer *peer, pqxx::result *pRes, DWORD dwHandle, DWORD dwPID);
void RESULT_QUEST_LOAD(CPeer * pkPeer, MYSQL_RES * pRes, DWORD dwHandle, DWORD dwPID); void RESULT_QUEST_LOAD(CPeer *pkPeer, pqxx::result *pRes, DWORD dwHandle, DWORD dwPID);
void RESULT_AFFECT_LOAD(CPeer * pkPeer, MYSQL_RES * pRes, DWORD dwHandle); void RESULT_AFFECT_LOAD(CPeer *pkPeer, pqxx::result *pRes, DWORD dwHandle);
// PLAYER_INDEX_CREATE_BUG_FIX // PLAYER_INDEX_CREATE_BUG_FIX
void RESULT_PLAYER_INDEX_CREATE(CPeer *pkPeer, SQLMsg *msg); void RESULT_PLAYER_INDEX_CREATE(CPeer *pkPeer, SQLMsg *msg);
// END_PLAYER_INDEX_CREATE_BUG_FIX // END_PLAYER_INDEX_CREATE_BUG_FIX
// MYSHOP_PRICE_LIST // MYSHOP_PRICE_LIST
/// 가격정보 로드 쿼리에 대한 Result 처리 /// 가격정보 로드 쿼리에 대한 Result 처리
/** /**
@ -267,7 +264,7 @@ class CClientManager : public singleton<CClientManager>
* *
* peer . * peer .
*/ */
void RESULT_PRICELIST_LOAD(CPeer* peer, SQLMsg* pMsg); void RESULT_PRICELIST_LOAD(CPeer *peer, SQLMsg *pMsg);
/// 가격정보 업데이트를 위한 로드 쿼리에 대한 Result 처리 /// 가격정보 업데이트를 위한 로드 쿼리에 대한 Result 처리
/** /**
@ -275,82 +272,81 @@ class CClientManager : public singleton<CClientManager>
* *
* . * .
*/ */
void RESULT_PRICELIST_LOAD_FOR_UPDATE(SQLMsg* pMsg); void RESULT_PRICELIST_LOAD_FOR_UPDATE(SQLMsg *pMsg);
// END_OF_MYSHOP_PRICE_LIST // END_OF_MYSHOP_PRICE_LIST
void QUERY_PLAYER_SAVE(CPeer * peer, DWORD dwHandle, TPlayerTable*); void QUERY_PLAYER_SAVE(CPeer *peer, DWORD dwHandle, TPlayerTable *);
void __QUERY_PLAYER_CREATE(CPeer * peer, DWORD dwHandle, TPlayerCreatePacket *); void __QUERY_PLAYER_CREATE(CPeer *peer, DWORD dwHandle, TPlayerCreatePacket *);
void __QUERY_PLAYER_DELETE(CPeer * peer, DWORD dwHandle, TPlayerDeletePacket *); void __QUERY_PLAYER_DELETE(CPeer *peer, DWORD dwHandle, TPlayerDeletePacket *);
void __RESULT_PLAYER_DELETE(CPeer * peer, SQLMsg* msg); void __RESULT_PLAYER_DELETE(CPeer *peer, SQLMsg *msg);
void QUERY_PLAYER_COUNT(CPeer * pkPeer, TPlayerCountPacket *); void QUERY_PLAYER_COUNT(CPeer *pkPeer, TPlayerCountPacket *);
void QUERY_ITEM_SAVE(CPeer * pkPeer, const char * c_pData); void QUERY_ITEM_SAVE(CPeer *pkPeer, const char *c_pData);
void QUERY_ITEM_DESTROY(CPeer * pkPeer, const char * c_pData); void QUERY_ITEM_DESTROY(CPeer *pkPeer, const char *c_pData);
void QUERY_ITEM_FLUSH(CPeer * pkPeer, const char * c_pData); void QUERY_ITEM_FLUSH(CPeer *pkPeer, const char *c_pData);
void QUERY_QUEST_SAVE(CPeer *pkPeer, TQuestTable *, DWORD dwLen);
void QUERY_ADD_AFFECT(CPeer *pkPeer, TPacketGDAddAffect *p);
void QUERY_REMOVE_AFFECT(CPeer *pkPeer, TPacketGDRemoveAffect *p);
void QUERY_QUEST_SAVE(CPeer * pkPeer, TQuestTable *, DWORD dwLen); void QUERY_SAFEBOX_LOAD(CPeer *pkPeer, DWORD dwHandle, TSafeboxLoadPacket *, bool bMall);
void QUERY_ADD_AFFECT(CPeer * pkPeer, TPacketGDAddAffect * p); void QUERY_SAFEBOX_SAVE(CPeer *pkPeer, TSafeboxTable *pTable);
void QUERY_REMOVE_AFFECT(CPeer * pkPeer, TPacketGDRemoveAffect * p); void QUERY_SAFEBOX_CHANGE_SIZE(CPeer *pkPeer, DWORD dwHandle, TSafeboxChangeSizePacket *p);
void QUERY_SAFEBOX_CHANGE_PASSWORD(CPeer *pkPeer, DWORD dwHandle, TSafeboxChangePasswordPacket *p);
void QUERY_SAFEBOX_LOAD(CPeer * pkPeer, DWORD dwHandle, TSafeboxLoadPacket *, bool bMall); void RESULT_SAFEBOX_LOAD(CPeer *pkPeer, ClientHandleInfo *pi, pqxx::result msg);
void QUERY_SAFEBOX_SAVE(CPeer * pkPeer, TSafeboxTable * pTable); void RESULT_SAFEBOX_CHANGE_SIZE(CPeer *pkPeer, ClientHandleInfo *pi, pqxx::result msg);
void QUERY_SAFEBOX_CHANGE_SIZE(CPeer * pkPeer, DWORD dwHandle, TSafeboxChangeSizePacket * p); void RESULT_SAFEBOX_CHANGE_PASSWORD(CPeer *pkPeer, ClientHandleInfo *pi, pqxx::result msg);
void QUERY_SAFEBOX_CHANGE_PASSWORD(CPeer * pkPeer, DWORD dwHandle, TSafeboxChangePasswordPacket * p); void RESULT_SAFEBOX_CHANGE_PASSWORD_SECOND(CPeer *pkPeer, ClientHandleInfo *pi, pqxx::result msg);
void RESULT_SAFEBOX_LOAD(CPeer * pkPeer, SQLMsg * msg); void QUERY_EMPIRE_SELECT(CPeer *pkPeer, DWORD dwHandle, TEmpireSelectPacket *p);
void RESULT_SAFEBOX_CHANGE_SIZE(CPeer * pkPeer, SQLMsg * msg); void QUERY_SETUP(CPeer *pkPeer, DWORD dwHandle, const char *c_pData);
void RESULT_SAFEBOX_CHANGE_PASSWORD(CPeer * pkPeer, SQLMsg * msg);
void RESULT_SAFEBOX_CHANGE_PASSWORD_SECOND(CPeer * pkPeer, SQLMsg * msg);
void QUERY_EMPIRE_SELECT(CPeer * pkPeer, DWORD dwHandle, TEmpireSelectPacket * p); void SendPartyOnSetup(CPeer *peer);
void QUERY_SETUP(CPeer * pkPeer, DWORD dwHandle, const char * c_pData);
void SendPartyOnSetup(CPeer * peer); void QUERY_FLUSH_CACHE(CPeer *pkPeer, const char *c_pData);
void QUERY_FLUSH_CACHE(CPeer * pkPeer, const char * c_pData); void QUERY_PARTY_CREATE(CPeer *peer, TPacketPartyCreate *p);
void QUERY_PARTY_DELETE(CPeer *peer, TPacketPartyDelete *p);
void QUERY_PARTY_ADD(CPeer *peer, TPacketPartyAdd *p);
void QUERY_PARTY_REMOVE(CPeer *peer, TPacketPartyRemove *p);
void QUERY_PARTY_STATE_CHANGE(CPeer *peer, TPacketPartyStateChange *p);
void QUERY_PARTY_SET_MEMBER_LEVEL(CPeer *peer, TPacketPartySetMemberLevel *p);
void QUERY_PARTY_CREATE(CPeer * peer, TPacketPartyCreate* p); void QUERY_RELOAD_PROTO();
void QUERY_PARTY_DELETE(CPeer * peer, TPacketPartyDelete* p);
void QUERY_PARTY_ADD(CPeer * peer, TPacketPartyAdd* p);
void QUERY_PARTY_REMOVE(CPeer * peer, TPacketPartyRemove* p);
void QUERY_PARTY_STATE_CHANGE(CPeer * peer, TPacketPartyStateChange* p);
void QUERY_PARTY_SET_MEMBER_LEVEL(CPeer * peer, TPacketPartySetMemberLevel* p);
void QUERY_RELOAD_PROTO(); void QUERY_CHANGE_NAME(CPeer *peer, DWORD dwHandle, TPacketGDChangeName *p);
void GetPlayerFromRes(TPlayerTable *player_table, pqxx::result *res);
void QUERY_CHANGE_NAME(CPeer * peer, DWORD dwHandle, TPacketGDChangeName * p); void QUERY_LOGIN_KEY(CPeer *pkPeer, TPacketGDLoginKey *p);
void GetPlayerFromRes(TPlayerTable * player_table, MYSQL_RES* res);
void QUERY_LOGIN_KEY(CPeer * pkPeer, TPacketGDLoginKey * p); void AddGuildPriv(TPacketGiveGuildPriv *p);
void AddEmpirePriv(TPacketGiveEmpirePriv *p);
void AddCharacterPriv(TPacketGiveCharacterPriv *p);
void AddGuildPriv(TPacketGiveGuildPriv* p); void MoneyLog(TPacketMoneyLog *p);
void AddEmpirePriv(TPacketGiveEmpirePriv* p);
void AddCharacterPriv(TPacketGiveCharacterPriv* p);
void MoneyLog(TPacketMoneyLog* p); void QUERY_AUTH_LOGIN(CPeer *pkPeer, DWORD dwHandle, TPacketGDAuthLogin *p);
void QUERY_AUTH_LOGIN(CPeer * pkPeer, DWORD dwHandle, TPacketGDAuthLogin * p); void QUERY_LOGIN_BY_KEY(CPeer *pkPeer, DWORD dwHandle, TPacketGDLoginByKey *p);
void RESULT_LOGIN_BY_KEY(CPeer *peer, SQLMsg *msg);
void QUERY_LOGIN_BY_KEY(CPeer * pkPeer, DWORD dwHandle, TPacketGDLoginByKey * p); void ChargeCash(const TRequestChargeCash *p);
void RESULT_LOGIN_BY_KEY(CPeer * peer, SQLMsg * msg);
void ChargeCash(const TRequestChargeCash * p); void LoadEventFlag();
void SetEventFlag(TPacketSetEventFlag *p);
void LoadEventFlag(); void SendEventFlagsOnSetup(CPeer *peer);
void SetEventFlag(TPacketSetEventFlag* p);
void SendEventFlagsOnSetup(CPeer* peer);
// 결혼 // 결혼
void MarriageAdd(TPacketMarriageAdd * p); void MarriageAdd(TPacketMarriageAdd *p);
void MarriageUpdate(TPacketMarriageUpdate * p); void MarriageUpdate(TPacketMarriageUpdate *p);
void MarriageRemove(TPacketMarriageRemove * p); void MarriageRemove(TPacketMarriageRemove *p);
void WeddingRequest(TPacketWeddingRequest * p); void WeddingRequest(TPacketWeddingRequest *p);
void WeddingReady(TPacketWeddingReady * p); void WeddingReady(TPacketWeddingReady *p);
void WeddingEnd(TPacketWeddingEnd * p); void WeddingEnd(TPacketWeddingEnd *p);
// MYSHOP_PRICE_LIST // MYSHOP_PRICE_LIST
// 개인상점 가격정보 // 개인상점 가격정보
@ -359,7 +355,7 @@ class CClientManager : public singleton<CClientManager>
/** /**
* @param [in] pPacket * @param [in] pPacket
*/ */
void MyshopPricelistUpdate(const TPacketMyshopPricelistHeader* pPacket); void MyshopPricelistUpdate(const TPacketMyshopPricelistHeader *pPacket);
/// 아이템 가격정보 리스트 요청 패킷(HEADER_GD_MYSHOP_PRICELIST_REQ) 처리함수 /// 아이템 가격정보 리스트 요청 패킷(HEADER_GD_MYSHOP_PRICELIST_REQ) 처리함수
/** /**
@ -367,146 +363,145 @@ class CClientManager : public singleton<CClientManager>
* @param [in] dwHandle peer * @param [in] dwHandle peer
* @param [in] dwPlayerID ID * @param [in] dwPlayerID ID
*/ */
void MyshopPricelistRequest(CPeer* peer, DWORD dwHandle, DWORD dwPlayerID); void MyshopPricelistRequest(CPeer *peer, DWORD dwHandle, DWORD dwPlayerID);
// END_OF_MYSHOP_PRICE_LIST // END_OF_MYSHOP_PRICE_LIST
// Building // Building
void CreateObject(TPacketGDCreateObject * p); void CreateObject(TPacketGDCreateObject *p);
void DeleteObject(DWORD dwID); void DeleteObject(DWORD dwID);
void UpdateLand(DWORD * pdw); void UpdateLand(DWORD *pdw);
// BLOCK_CHAT // BLOCK_CHAT
void BlockChat(TPacketBlockChat * p); void BlockChat(TPacketBlockChat *p);
// END_OF_BLOCK_CHAT // END_OF_BLOCK_CHAT
private:
int m_looping;
event_base * m_base = nullptr;
evconnlistener * m_listener = nullptr;
TPeerList m_peerList;
CPeer * m_pkAuthPeer; private:
int m_looping;
event_base *m_base = nullptr;
evconnlistener *m_listener = nullptr;
TPeerList m_peerList;
CPeer *m_pkAuthPeer;
// LoginKey, LoginData pair // LoginKey, LoginData pair
typedef std::unordered_map<DWORD, CLoginData *> TLoginDataByLoginKey; typedef std::unordered_map<DWORD, CLoginData *> TLoginDataByLoginKey;
TLoginDataByLoginKey m_map_pkLoginData; TLoginDataByLoginKey m_map_pkLoginData;
// Login LoginData pair // Login LoginData pair
typedef std::unordered_map<std::string, CLoginData *> TLoginDataByLogin; typedef std::unordered_map<std::string, CLoginData *> TLoginDataByLogin;
TLoginDataByLogin m_map_pkLoginDataByLogin; TLoginDataByLogin m_map_pkLoginDataByLogin;
// AccountID LoginData pair // AccountID LoginData pair
typedef std::unordered_map<DWORD, CLoginData *> TLoginDataByAID; typedef std::unordered_map<DWORD, CLoginData *> TLoginDataByAID;
TLoginDataByAID m_map_pkLoginDataByAID; TLoginDataByAID m_map_pkLoginDataByAID;
// Login LoginData pair (실제 로그인 되어있는 계정) // Login LoginData pair (실제 로그인 되어있는 계정)
typedef std::unordered_map<std::string, CLoginData *> TLogonAccountMap; typedef std::unordered_map<std::string, CLoginData *> TLogonAccountMap;
TLogonAccountMap m_map_kLogonAccount; TLogonAccountMap m_map_kLogonAccount;
int m_iPlayerIDStart; int m_iPlayerIDStart;
int m_iPlayerDeleteLevelLimit; int m_iPlayerDeleteLevelLimit;
int m_iPlayerDeleteLevelLimitLower; int m_iPlayerDeleteLevelLimitLower;
bool m_bChinaEventServer; bool m_bChinaEventServer;
std::vector<TMobTable> m_vec_mobTable; std::vector<TMobTable> m_vec_mobTable;
std::vector<TItemTable> m_vec_itemTable; std::vector<TItemTable> m_vec_itemTable;
std::map<DWORD, TItemTable *> m_map_itemTableByVnum; std::map<DWORD, TItemTable *> m_map_itemTableByVnum;
int m_iShopTableSize; int m_iShopTableSize;
TShopTable * m_pShopTable; TShopTable *m_pShopTable;
int m_iRefineTableSize; int m_iRefineTableSize;
TRefineTable* m_pRefineTable; TRefineTable *m_pRefineTable;
std::vector<TSkillTable> m_vec_skillTable; std::vector<TSkillTable> m_vec_skillTable;
std::vector<TBanwordTable> m_vec_banwordTable; std::vector<TBanwordTable> m_vec_banwordTable;
std::vector<TItemAttrTable> m_vec_itemAttrTable; std::vector<TItemAttrTable> m_vec_itemAttrTable;
std::vector<TItemAttrTable> m_vec_itemRareTable; std::vector<TItemAttrTable> m_vec_itemRareTable;
std::vector<building::TLand> m_vec_kLandTable; std::vector<building::TLand> m_vec_kLandTable;
std::vector<building::TObjectProto> m_vec_kObjectProto; std::vector<building::TObjectProto> m_vec_kObjectProto;
std::map<DWORD, building::TObject *> m_map_pkObjectTable; std::map<DWORD, building::TObject *> m_map_pkObjectTable;
bool m_bShutdowned; bool m_bShutdowned;
TPlayerTableCacheMap m_map_playerCache; // 플레이어 id가 key TPlayerTableCacheMap m_map_playerCache; // 플레이어 id가 key
TItemCacheMap m_map_itemCache; // 아이템 id가 key TItemCacheMap m_map_itemCache; // 아이템 id가 key
TItemCacheSetPtrMap m_map_pkItemCacheSetPtr; // 플레이어 id가 key, 이 플레이어가 어떤 아이템 캐쉬를 가지고 있나? TItemCacheSetPtrMap m_map_pkItemCacheSetPtr; // 플레이어 id가 key, 이 플레이어가 어떤 아이템 캐쉬를 가지고 있나?
// MYSHOP_PRICE_LIST // MYSHOP_PRICE_LIST
/// 플레이어별 아이템 가격정보 리스트 map. key: 플레이어 ID, value: 가격정보 리스트 캐시 /// 플레이어별 아이템 가격정보 리스트 map. key: 플레이어 ID, value: 가격정보 리스트 캐시
TItemPriceListCacheMap m_mapItemPriceListCache; ///< 플레이어별 아이템 가격정보 리스트 TItemPriceListCacheMap m_mapItemPriceListCache; ///< 플레이어별 아이템 가격정보 리스트
// END_OF_MYSHOP_PRICE_LIST // END_OF_MYSHOP_PRICE_LIST
TChannelStatusMap m_mChannelStatus; TChannelStatusMap m_mChannelStatus;
struct TPartyInfo struct TPartyInfo
{ {
BYTE bRole; BYTE bRole;
BYTE bLevel; BYTE bLevel;
TPartyInfo() :bRole(0), bLevel(0) TPartyInfo() : bRole(0), bLevel(0)
{ {
} }
}; };
typedef std::map<DWORD, TPartyInfo> TPartyMember; typedef std::map<DWORD, TPartyInfo> TPartyMember;
typedef std::map<DWORD, TPartyMember> TPartyMap; typedef std::map<DWORD, TPartyMember> TPartyMap;
typedef std::map<BYTE, TPartyMap> TPartyChannelMap; typedef std::map<BYTE, TPartyMap> TPartyChannelMap;
TPartyChannelMap m_map_pkChannelParty; TPartyChannelMap m_map_pkChannelParty;
typedef std::map<std::string, int> TEventFlagMap; typedef std::map<std::string, int> TEventFlagMap;
TEventFlagMap m_map_lEventFlag; TEventFlagMap m_map_lEventFlag;
BYTE m_bLastHeader; BYTE m_bLastHeader;
int m_iCacheFlushCount; int m_iCacheFlushCount;
int m_iCacheFlushCountLimit; int m_iCacheFlushCountLimit;
private : private:
TItemIDRangeTable m_itemRange; TItemIDRangeTable m_itemRange;
public : public:
bool InitializeNowItemID(); bool InitializeNowItemID();
DWORD GetItemID(); DWORD GetItemID();
DWORD GainItemID(); DWORD GainItemID();
TItemIDRangeTable GetItemRange() { return m_itemRange; } TItemIDRangeTable GetItemRange() { return m_itemRange; }
//BOOT_LOCALIZATION // BOOT_LOCALIZATION
public: public:
/* 로컬 정보 초기화 /* 로컬 정보 초기화
**/ **/
bool InitializeLocalization(); bool InitializeLocalization();
private: private:
std::vector<tLocale> m_vec_Locale; std::vector<tLocale> m_vec_Locale;
//END_BOOT_LOCALIZATION // END_BOOT_LOCALIZATION
//ADMIN_MANAGER // ADMIN_MANAGER
bool __GetAdminInfo(const char *szIP, std::vector<tAdminInfo> & rAdminVec); bool __GetAdminInfo(const char *szIP, std::vector<tAdminInfo> &rAdminVec);
bool __GetHostInfo(std::vector<std::string> & rIPVec); bool __GetHostInfo(std::vector<std::string> &rIPVec);
//END_ADMIN_MANAGER // END_ADMIN_MANAGER
// RELOAD_ADMIN
//RELOAD_ADMIN void ReloadAdmin(CPeer *peer, TPacketReloadAdmin *p);
void ReloadAdmin(CPeer * peer, TPacketReloadAdmin * p); // END_RELOAD_ADMIN
//END_RELOAD_ADMIN void BreakMarriage(CPeer *peer, const char *data);
void BreakMarriage(CPeer * peer, const char * data);
struct TLogoutPlayer struct TLogoutPlayer
{ {
DWORD pid; DWORD pid;
time_t time; time_t time;
bool operator < (const TLogoutPlayer & r) bool operator<(const TLogoutPlayer &r)
{ {
return (pid < r.pid); return (pid < r.pid);
} }
}; };
typedef std::unordered_map<DWORD, TLogoutPlayer*> TLogoutPlayerMap; typedef std::unordered_map<DWORD, TLogoutPlayer *> TLogoutPlayerMap;
TLogoutPlayerMap m_map_logout; TLogoutPlayerMap m_map_logout;
void InsertLogoutPlayer(DWORD pid); void InsertLogoutPlayer(DWORD pid);
void DeleteLogoutPlayer(DWORD pid); void DeleteLogoutPlayer(DWORD pid);
void UpdateLogoutPlayer(); void UpdateLogoutPlayer();
@ -514,58 +509,41 @@ class CClientManager : public singleton<CClientManager>
void FlushPlayerCacheSet(DWORD pid); void FlushPlayerCacheSet(DWORD pid);
//MONARCH // MONARCH
void Election(CPeer * peer, DWORD dwHandle, const char * p); void Election(CPeer *peer, DWORD dwHandle, const char *p);
void Candidacy(CPeer * peer, DWORD dwHandle, const char * p); void Candidacy(CPeer *peer, DWORD dwHandle, const char *p);
void AddMonarchMoney(CPeer * peer, DWORD dwHandle, const char * p); void AddMonarchMoney(CPeer *peer, DWORD dwHandle, const char *p);
void TakeMonarchMoney(CPeer * peer, DWORD dwHandle, const char * p); void TakeMonarchMoney(CPeer *peer, DWORD dwHandle, const char *p);
void ComeToVote(CPeer * peer, DWORD dwHandle, const char * p); void ComeToVote(CPeer *peer, DWORD dwHandle, const char *p);
void RMCandidacy(CPeer * peer, DWORD dwHandle, const char * p); void RMCandidacy(CPeer *peer, DWORD dwHandle, const char *p);
void SetMonarch(CPeer * peer, DWORD dwHandle, const char * p); void SetMonarch(CPeer *peer, DWORD dwHandle, const char *p);
void RMMonarch(CPeer * peer, DWORD dwHandle, const char * p); void RMMonarch(CPeer *peer, DWORD dwHandle, const char *p);
void DecMonarchMoney(CPeer * peer, DWORD dwHandle, const char * p); void DecMonarchMoney(CPeer *peer, DWORD dwHandle, const char *p);
//END_MONARCH // END_MONARCH
void ChangeMonarchLord(CPeer* peer, DWORD dwHandle, TPacketChangeMonarchLord* info); void ChangeMonarchLord(CPeer *peer, DWORD dwHandle, TPacketChangeMonarchLord *info);
void SendSpareItemIDRange(CPeer* peer); void SendSpareItemIDRange(CPeer *peer);
void UpdateHorseName(TPacketUpdateHorseName* data, CPeer* peer); void UpdateHorseName(TPacketUpdateHorseName *data, CPeer *peer);
void AckHorseName(DWORD dwPID, CPeer* peer); void AckHorseName(DWORD dwPID, CPeer *peer);
void DeleteLoginKey(TPacketDC *data); void DeleteLoginKey(TPacketDC *data);
void ResetLastPlayerID(const TPacketNeedLoginLogInfo* data); void ResetLastPlayerID(const TPacketNeedLoginLogInfo *data);
//delete gift notify icon // delete gift notify icon
void DeleteAwardId(TPacketDeleteAwardID* data); void DeleteAwardId(TPacketDeleteAwardID *data);
void UpdateChannelStatus(TChannelStatus* pData); void UpdateChannelStatus(TChannelStatus *pData);
void RequestChannelStatus(CPeer* peer, DWORD dwHandle); void RequestChannelStatus(CPeer *peer, DWORD dwHandle);
#ifdef __AUCTION__
void EnrollInAuction (CPeer * peer, DWORD owner_id, AuctionEnrollProductInfo* data);
void EnrollInSale (CPeer * peer, DWORD owner_id, AuctionEnrollSaleInfo* data);
void EnrollInWish (CPeer * peer, DWORD wisher_id, AuctionEnrollWishInfo* data);
void AuctionBid (CPeer * peer, DWORD bidder_id, AuctionBidInfo* data);
void AuctionImpur (CPeer * peer, DWORD purchaser_id, AuctionImpurInfo* data);
void AuctionGetAuctionedItem (CPeer * peer, DWORD actor_id, DWORD item_id);
void AuctionBuySoldItem (CPeer * peer, DWORD actor_id, DWORD item_id);
void AuctionCancelAuction (CPeer * peer, DWORD actor_id, DWORD item_id);
void AuctionCancelWish (CPeer * peer, DWORD actor_id, DWORD item_num);
void AuctionCancelSale (CPeer * peer, DWORD actor_id, DWORD item_id);
void AuctionDeleteAuctionItem (CPeer * peer, DWORD actor_id, DWORD item_id);
void AuctionDeleteSaleItem (CPeer * peer, DWORD actor_id, DWORD item_id);
void AuctionReBid (CPeer * peer, DWORD bidder_id, AuctionBidInfo* data);
void AuctionBidCancel (CPeer * peer, DWORD bidder_id, DWORD item_id);
#endif
}; };
template<class Func> template <class Func>
Func CClientManager::for_each_peer(Func f) Func CClientManager::for_each_peer(Func f)
{ {
TPeerList::iterator it; TPeerList::iterator it;
for (it = m_peerList.begin(); it!=m_peerList.end();++it) for (it = m_peerList.begin(); it != m_peerList.end(); ++it)
{ {
f(*it); f(*it);
} }
return f; return f;
} }
#endif #endif

File diff suppressed because it is too large Load Diff

View File

@ -12,7 +12,7 @@ void CClientManager::LoadEventFlag()
snprintf(szQuery, sizeof(szQuery), "SELECT szName, lValue FROM quest%s WHERE dwPID = 0", GetTablePostfix()); snprintf(szQuery, sizeof(szQuery), "SELECT szName, lValue FROM quest%s WHERE dwPID = 0", GetTablePostfix());
std::unique_ptr<SQLMsg> pmsg(CDBManager::instance().DirectQuery(szQuery)); std::unique_ptr<SQLMsg> pmsg(CDBManager::instance().DirectQuery(szQuery));
SQLResult* pRes = pmsg->Get(); SQLResult *pRes = pmsg->Get();
if (pRes->uiNumRows) if (pRes->uiNumRows)
{ {
MYSQL_ROW row; MYSQL_ROW row;
@ -28,7 +28,7 @@ void CClientManager::LoadEventFlag()
} }
} }
void CClientManager::SetEventFlag(TPacketSetEventFlag* p) void CClientManager::SetEventFlag(TPacketSetEventFlag *p)
{ {
ForwardPacket(HEADER_DG_SET_EVENT_FLAG, p, sizeof(TPacketSetEventFlag)); ForwardPacket(HEADER_DG_SET_EVENT_FLAG, p, sizeof(TPacketSetEventFlag));
@ -50,11 +50,11 @@ void CClientManager::SetEventFlag(TPacketSetEventFlag* p)
{ {
char szQuery[1024]; char szQuery[1024];
snprintf(szQuery, sizeof(szQuery), snprintf(szQuery, sizeof(szQuery),
"REPLACE INTO quest%s (dwPID, szName, szState, lValue) VALUES(0, '%s', '', %d)", "REPLACE INTO quest%s (dwPID, szName, szState, lValue) VALUES(0, '%s', '', %d)",
GetTablePostfix(), p->szFlagName, p->lValue); GetTablePostfix(), p->szFlagName, p->lValue);
szQuery[1023] = '\0'; szQuery[1023] = '\0';
//CDBManager::instance().ReturnQuery(szQuery, QID_QUEST_SAVE, 0, NULL); // CDBManager::instance().ReturnQuery(szQuery, QID_QUEST_SAVE, 0, NULL);
CDBManager::instance().AsyncQuery(szQuery); CDBManager::instance().AsyncQuery(szQuery);
SPDLOG_DEBUG("HEADER_GD_SET_EVENT_FLAG : Changed CClientmanager::SetEventFlag({} {}) ", p->szFlagName, p->lValue); SPDLOG_DEBUG("HEADER_GD_SET_EVENT_FLAG : Changed CClientmanager::SetEventFlag({} {}) ", p->szFlagName, p->lValue);
return; return;
@ -62,7 +62,7 @@ void CClientManager::SetEventFlag(TPacketSetEventFlag* p)
SPDLOG_DEBUG("HEADER_GD_SET_EVENT_FLAG : No Changed CClientmanager::SetEventFlag({} {}) ", p->szFlagName, p->lValue); SPDLOG_DEBUG("HEADER_GD_SET_EVENT_FLAG : No Changed CClientmanager::SetEventFlag({} {}) ", p->szFlagName, p->lValue);
} }
void CClientManager::SendEventFlagsOnSetup(CPeer* peer) void CClientManager::SendEventFlagsOnSetup(CPeer *peer)
{ {
typeof(m_map_lEventFlag.begin()) it; typeof(m_map_lEventFlag.begin()) it;
for (it = m_map_lEventFlag.begin(); it != m_map_lEventFlag.end(); ++it) for (it = m_map_lEventFlag.begin(); it != m_map_lEventFlag.end(); ++it)
@ -74,4 +74,3 @@ void CClientManager::SendEventFlagsOnSetup(CPeer* peer)
peer->Encode(&p, sizeof(TPacketSetEventFlag)); peer->Encode(&p, sizeof(TPacketSetEventFlag));
} }
} }

View File

@ -7,8 +7,7 @@
#include "QID.h" #include "QID.h"
#include "GuildManager.h" #include "GuildManager.h"
void CClientManager::GuildCreate(CPeer *peer, DWORD dwGuildID)
void CClientManager::GuildCreate(CPeer * peer, DWORD dwGuildID)
{ {
SPDLOG_DEBUG("GuildCreate {}", dwGuildID); SPDLOG_DEBUG("GuildCreate {}", dwGuildID);
ForwardPacket(HEADER_DG_GUILD_LOAD, &dwGuildID, sizeof(DWORD)); ForwardPacket(HEADER_DG_GUILD_LOAD, &dwGuildID, sizeof(DWORD));
@ -16,27 +15,27 @@ void CClientManager::GuildCreate(CPeer * peer, DWORD dwGuildID)
CGuildManager::instance().Load(dwGuildID); CGuildManager::instance().Load(dwGuildID);
} }
void CClientManager::GuildChangeGrade(CPeer* peer, TPacketGuild* p) void CClientManager::GuildChangeGrade(CPeer *peer, TPacketGuild *p)
{ {
SPDLOG_DEBUG("GuildChangeGrade {} {}", p->dwGuild, p->dwInfo); SPDLOG_DEBUG("GuildChangeGrade {} {}", p->dwGuild, p->dwInfo);
ForwardPacket(HEADER_DG_GUILD_CHANGE_GRADE, p, sizeof(TPacketGuild)); ForwardPacket(HEADER_DG_GUILD_CHANGE_GRADE, p, sizeof(TPacketGuild));
} }
void CClientManager::GuildAddMember(CPeer* peer, TPacketGDGuildAddMember * p) void CClientManager::GuildAddMember(CPeer *peer, TPacketGDGuildAddMember *p)
{ {
CGuildManager::instance().TouchGuild(p->dwGuild); CGuildManager::instance().TouchGuild(p->dwGuild);
SPDLOG_DEBUG("GuildAddMember {} {}", p->dwGuild, p->dwPID); SPDLOG_DEBUG("GuildAddMember {} {}", p->dwGuild, p->dwPID);
char szQuery[512]; char szQuery[512];
snprintf(szQuery, sizeof(szQuery), snprintf(szQuery, sizeof(szQuery),
"INSERT INTO guild_member%s VALUES(%u, %u, %d, 0, 0)", "INSERT INTO guild_member%s VALUES(%u, %u, %d, 0, 0)",
GetTablePostfix(), p->dwPID, p->dwGuild, p->bGrade); GetTablePostfix(), p->dwPID, p->dwGuild, p->bGrade);
std::unique_ptr<SQLMsg> pmsg_insert(CDBManager::instance().DirectQuery(szQuery)); std::unique_ptr<SQLMsg> pmsg_insert(CDBManager::instance().DirectQuery(szQuery));
snprintf(szQuery, sizeof(szQuery), snprintf(szQuery, sizeof(szQuery),
"SELECT pid, grade, is_general, offer, level, job, name FROM guild_member%s, player%s WHERE guild_id = %u and pid = id and pid = %u", GetTablePostfix(), GetTablePostfix(), p->dwGuild, p->dwPID); "SELECT pid, grade, is_general, offer, level, job, name FROM guild_member%s, player%s WHERE guild_id = %u and pid = id and pid = %u", GetTablePostfix(), GetTablePostfix(), p->dwGuild, p->dwPID);
std::unique_ptr<SQLMsg> pmsg(CDBManager::instance().DirectQuery(szQuery)); std::unique_ptr<SQLMsg> pmsg(CDBManager::instance().DirectQuery(szQuery));
@ -65,7 +64,7 @@ void CClientManager::GuildAddMember(CPeer* peer, TPacketGDGuildAddMember * p)
ForwardPacket(HEADER_DG_GUILD_ADD_MEMBER, &dg, sizeof(TPacketDGGuildMember)); ForwardPacket(HEADER_DG_GUILD_ADD_MEMBER, &dg, sizeof(TPacketDGGuildMember));
} }
void CClientManager::GuildRemoveMember(CPeer* peer, TPacketGuild* p) void CClientManager::GuildRemoveMember(CPeer *peer, TPacketGuild *p)
{ {
SPDLOG_DEBUG("GuildRemoveMember {} {}", p->dwGuild, p->dwInfo); SPDLOG_DEBUG("GuildRemoveMember {} {}", p->dwGuild, p->dwInfo);
@ -73,31 +72,31 @@ void CClientManager::GuildRemoveMember(CPeer* peer, TPacketGuild* p)
snprintf(szQuery, sizeof(szQuery), "DELETE FROM guild_member%s WHERE pid=%u and guild_id=%u", GetTablePostfix(), p->dwInfo, p->dwGuild); snprintf(szQuery, sizeof(szQuery), "DELETE FROM guild_member%s WHERE pid=%u and guild_id=%u", GetTablePostfix(), p->dwInfo, p->dwGuild);
CDBManager::instance().AsyncQuery(szQuery); CDBManager::instance().AsyncQuery(szQuery);
snprintf(szQuery, sizeof(szQuery), "REPLACE INTO quest%s (dwPID, szName, szState, lValue) VALUES(%u, 'guild_manage', 'withdraw_time', %u)", GetTablePostfix(), p->dwInfo, (DWORD) GetCurrentTime()); snprintf(szQuery, sizeof(szQuery), "REPLACE INTO quest%s (dwPID, szName, szState, lValue) VALUES(%u, 'guild_manage', 'withdraw_time', %u)", GetTablePostfix(), p->dwInfo, (DWORD)GetCurrentTime());
CDBManager::instance().AsyncQuery(szQuery); CDBManager::instance().AsyncQuery(szQuery);
ForwardPacket(HEADER_DG_GUILD_REMOVE_MEMBER, p, sizeof(TPacketGuild)); ForwardPacket(HEADER_DG_GUILD_REMOVE_MEMBER, p, sizeof(TPacketGuild));
} }
void CClientManager::GuildSkillUpdate(CPeer* peer, TPacketGuildSkillUpdate* p) void CClientManager::GuildSkillUpdate(CPeer *peer, TPacketGuildSkillUpdate *p)
{ {
SPDLOG_DEBUG("GuildSkillUpdate {}", p->amount); SPDLOG_DEBUG("GuildSkillUpdate {}", p->amount);
ForwardPacket(HEADER_DG_GUILD_SKILL_UPDATE, p, sizeof(TPacketGuildSkillUpdate)); ForwardPacket(HEADER_DG_GUILD_SKILL_UPDATE, p, sizeof(TPacketGuildSkillUpdate));
} }
void CClientManager::GuildExpUpdate(CPeer* peer, TPacketGuildExpUpdate* p) void CClientManager::GuildExpUpdate(CPeer *peer, TPacketGuildExpUpdate *p)
{ {
SPDLOG_DEBUG("GuildExpUpdate {}", p->amount); SPDLOG_DEBUG("GuildExpUpdate {}", p->amount);
ForwardPacket(HEADER_DG_GUILD_EXP_UPDATE, p, sizeof(TPacketGuildExpUpdate), 0, peer); ForwardPacket(HEADER_DG_GUILD_EXP_UPDATE, p, sizeof(TPacketGuildExpUpdate), 0, peer);
} }
void CClientManager::GuildChangeMemberData(CPeer* peer, TPacketGuildChangeMemberData* p) void CClientManager::GuildChangeMemberData(CPeer *peer, TPacketGuildChangeMemberData *p)
{ {
SPDLOG_DEBUG("GuildChangeMemberData {} {} {} {}", p->pid, p->offer, p->level, p->grade); SPDLOG_DEBUG("GuildChangeMemberData {} {} {} {}", p->pid, p->offer, p->level, p->grade);
ForwardPacket(HEADER_DG_GUILD_CHANGE_MEMBER_DATA, p, sizeof(TPacketGuildChangeMemberData), 0, peer); ForwardPacket(HEADER_DG_GUILD_CHANGE_MEMBER_DATA, p, sizeof(TPacketGuildChangeMemberData), 0, peer);
} }
void CClientManager::GuildDisband(CPeer* peer, TPacketGuild* p) void CClientManager::GuildDisband(CPeer *peer, TPacketGuild *p)
{ {
SPDLOG_DEBUG("GuildDisband {}", p->dwGuild); SPDLOG_DEBUG("GuildDisband {}", p->dwGuild);
@ -109,107 +108,107 @@ void CClientManager::GuildDisband(CPeer* peer, TPacketGuild* p)
snprintf(szQuery, sizeof(szQuery), "DELETE FROM guild_grade%s WHERE guild_id=%u", GetTablePostfix(), p->dwGuild); snprintf(szQuery, sizeof(szQuery), "DELETE FROM guild_grade%s WHERE guild_id=%u", GetTablePostfix(), p->dwGuild);
CDBManager::instance().AsyncQuery(szQuery); CDBManager::instance().AsyncQuery(szQuery);
snprintf(szQuery, sizeof(szQuery), "REPLACE INTO quest%s (dwPID, szName, szState, lValue) SELECT pid, 'guild_manage', 'withdraw_time', %u FROM guild_member%s WHERE guild_id = %u", GetTablePostfix(), (DWORD) GetCurrentTime(), GetTablePostfix(), p->dwGuild); snprintf(szQuery, sizeof(szQuery), "REPLACE INTO quest%s (dwPID, szName, szState, lValue) SELECT pid, 'guild_manage', 'withdraw_time', %u FROM guild_member%s WHERE guild_id = %u", GetTablePostfix(), (DWORD)GetCurrentTime(), GetTablePostfix(), p->dwGuild);
CDBManager::instance().AsyncQuery(szQuery); CDBManager::instance().AsyncQuery(szQuery);
snprintf(szQuery, sizeof(szQuery), "DELETE FROM guild_member%s WHERE guild_id=%u", GetTablePostfix(), p->dwGuild); snprintf(szQuery, sizeof(szQuery), "DELETE FROM guild_member%s WHERE guild_id=%u", GetTablePostfix(), p->dwGuild);
CDBManager::instance().AsyncQuery(szQuery); CDBManager::instance().AsyncQuery(szQuery);
snprintf(szQuery, sizeof(szQuery), "DELETE FROM guild_comment%s WHERE guild_id=%u", GetTablePostfix(), p->dwGuild); snprintf(szQuery, sizeof(szQuery), "DELETE FROM guild_comment%s WHERE guild_id=%u", GetTablePostfix(), p->dwGuild);
CDBManager::instance().AsyncQuery(szQuery); CDBManager::instance().AsyncQuery(szQuery);
ForwardPacket(HEADER_DG_GUILD_DISBAND, p, sizeof(TPacketGuild)); ForwardPacket(HEADER_DG_GUILD_DISBAND, p, sizeof(TPacketGuild));
} }
const char* __GetWarType(int n) const char *__GetWarType(int n)
{ {
switch (n) switch (n)
{ {
case 0 : case 0:
return "\xEF\xBF\xBD\xD0\xBF\xEF\xBF\xBD"; // 패왕 return "\xEF\xBF\xBD\xD0\xBF\xEF\xBF\xBD"; // 패왕
case 1 : case 1:
return "\xEF\xBF\xBD\xEF\xBF\xBD\xEF\xBF\xBD\xEF\xBF\xBD"; // 맹장 return "\xEF\xBF\xBD\xEF\xBF\xBD\xEF\xBF\xBD\xEF\xBF\xBD"; // 맹장
case 2 : case 2:
return "\xEF\xBF\xBD\xEF\xBF\xBD\xC8\xA3"; // 수호 return "\xEF\xBF\xBD\xEF\xBF\xBD\xC8\xA3"; // 수호
default : default:
return "\xEF\xBF\xBD\xEF\xBF\xBD\xEF\xBF\xBD\xEF\xBF\xBD\x20\xEF\xBF\xBD\xEF\xBF\xBD\xC8\xA3"; // 없는 번호 return "\xEF\xBF\xBD\xEF\xBF\xBD\xEF\xBF\xBD\xEF\xBF\xBD\x20\xEF\xBF\xBD\xEF\xBF\xBD\xC8\xA3"; // 없는 번호
} }
} }
void CClientManager::GuildWar(CPeer* peer, TPacketGuildWar* p) void CClientManager::GuildWar(CPeer *peer, TPacketGuildWar *p)
{ {
switch (p->bWar) switch (p->bWar)
{ {
case GUILD_WAR_SEND_DECLARE: case GUILD_WAR_SEND_DECLARE:
SPDLOG_DEBUG("GuildWar: GUILD_WAR_SEND_DECLARE type({}) guild({} - {})", __GetWarType(p->bType), p->dwGuildFrom, p->dwGuildTo); SPDLOG_DEBUG("GuildWar: GUILD_WAR_SEND_DECLARE type({}) guild({} - {})", __GetWarType(p->bType), p->dwGuildFrom, p->dwGuildTo);
CGuildManager::instance().AddDeclare(p->bType, p->dwGuildFrom, p->dwGuildTo); CGuildManager::instance().AddDeclare(p->bType, p->dwGuildFrom, p->dwGuildTo);
break; break;
case GUILD_WAR_REFUSE: case GUILD_WAR_REFUSE:
SPDLOG_DEBUG("GuildWar: GUILD_WAR_REFUSE type({}) guild({} - {})", __GetWarType(p->bType), p->dwGuildFrom, p->dwGuildTo); SPDLOG_DEBUG("GuildWar: GUILD_WAR_REFUSE type({}) guild({} - {})", __GetWarType(p->bType), p->dwGuildFrom, p->dwGuildTo);
CGuildManager::instance().RemoveDeclare(p->dwGuildFrom, p->dwGuildTo); CGuildManager::instance().RemoveDeclare(p->dwGuildFrom, p->dwGuildTo);
break; break;
/* /*
case GUILD_WAR_WAIT_START: case GUILD_WAR_WAIT_START:
CGuildManager::instance().RemoveDeclare(p->dwGuildFrom, p->dwGuildTo); CGuildManager::instance().RemoveDeclare(p->dwGuildFrom, p->dwGuildTo);
if (!CGuildManager::instance().WaitStart(p)) if (!CGuildManager::instance().WaitStart(p))
p->bWar = GUILD_WAR_CANCEL; p->bWar = GUILD_WAR_CANCEL;
break; break;
*/ */
case GUILD_WAR_WAIT_START: case GUILD_WAR_WAIT_START:
SPDLOG_DEBUG("GuildWar: GUILD_WAR_WAIT_START type({}) guild({} - {})", __GetWarType(p->bType), p->dwGuildFrom, p->dwGuildTo); SPDLOG_DEBUG("GuildWar: GUILD_WAR_WAIT_START type({}) guild({} - {})", __GetWarType(p->bType), p->dwGuildFrom, p->dwGuildTo);
case GUILD_WAR_RESERVE: // 길드전 예약 case GUILD_WAR_RESERVE: // 길드전 예약
if (p->bWar != GUILD_WAR_WAIT_START) if (p->bWar != GUILD_WAR_WAIT_START)
SPDLOG_DEBUG("GuildWar: GUILD_WAR_RESERVE type({}) guild({} - {})", __GetWarType(p->bType), p->dwGuildFrom, p->dwGuildTo); SPDLOG_DEBUG("GuildWar: GUILD_WAR_RESERVE type({}) guild({} - {})", __GetWarType(p->bType), p->dwGuildFrom, p->dwGuildTo);
CGuildManager::instance().RemoveDeclare(p->dwGuildFrom, p->dwGuildTo); CGuildManager::instance().RemoveDeclare(p->dwGuildFrom, p->dwGuildTo);
if (!CGuildManager::instance().ReserveWar(p)) if (!CGuildManager::instance().ReserveWar(p))
p->bWar = GUILD_WAR_CANCEL; p->bWar = GUILD_WAR_CANCEL;
else else
p->bWar = GUILD_WAR_RESERVE; p->bWar = GUILD_WAR_RESERVE;
break; break;
case GUILD_WAR_ON_WAR: // 길드전을 시작 시킨다. (필드전은 바로 시작 됨) case GUILD_WAR_ON_WAR: // 길드전을 시작 시킨다. (필드전은 바로 시작 됨)
SPDLOG_DEBUG("GuildWar: GUILD_WAR_ON_WAR type({}) guild({} - {})", __GetWarType(p->bType), p->dwGuildFrom, p->dwGuildTo); SPDLOG_DEBUG("GuildWar: GUILD_WAR_ON_WAR type({}) guild({} - {})", __GetWarType(p->bType), p->dwGuildFrom, p->dwGuildTo);
CGuildManager::instance().RemoveDeclare(p->dwGuildFrom, p->dwGuildTo); CGuildManager::instance().RemoveDeclare(p->dwGuildFrom, p->dwGuildTo);
CGuildManager::instance().StartWar(p->bType, p->dwGuildFrom, p->dwGuildTo); CGuildManager::instance().StartWar(p->bType, p->dwGuildFrom, p->dwGuildTo);
break; break;
case GUILD_WAR_OVER: // 길드전 정상 종료 case GUILD_WAR_OVER: // 길드전 정상 종료
SPDLOG_DEBUG("GuildWar: GUILD_WAR_OVER type({}) guild({} - {})", __GetWarType(p->bType), p->dwGuildFrom, p->dwGuildTo); SPDLOG_DEBUG("GuildWar: GUILD_WAR_OVER type({}) guild({} - {})", __GetWarType(p->bType), p->dwGuildFrom, p->dwGuildTo);
CGuildManager::instance().RecvWarOver(p->dwGuildFrom, p->dwGuildTo, p->bType, p->lWarPrice); CGuildManager::instance().RecvWarOver(p->dwGuildFrom, p->dwGuildTo, p->bType, p->lWarPrice);
break; break;
case GUILD_WAR_END: // 길드전 비정상 종료 case GUILD_WAR_END: // 길드전 비정상 종료
SPDLOG_DEBUG("GuildWar: GUILD_WAR_END type({}) guild({} - {})", __GetWarType(p->bType), p->dwGuildFrom, p->dwGuildTo); SPDLOG_DEBUG("GuildWar: GUILD_WAR_END type({}) guild({} - {})", __GetWarType(p->bType), p->dwGuildFrom, p->dwGuildTo);
CGuildManager::instance().RecvWarEnd(p->dwGuildFrom, p->dwGuildTo); CGuildManager::instance().RecvWarEnd(p->dwGuildFrom, p->dwGuildTo);
return; // NOTE: RecvWarEnd에서 패킷을 보내므로 따로 브로드캐스팅 하지 않는다. return; // NOTE: RecvWarEnd에서 패킷을 보내므로 따로 브로드캐스팅 하지 않는다.
case GUILD_WAR_CANCEL : case GUILD_WAR_CANCEL:
SPDLOG_DEBUG("GuildWar: GUILD_WAR_CANCEL type({}) guild({} - {})", __GetWarType(p->bType), p->dwGuildFrom, p->dwGuildTo); SPDLOG_DEBUG("GuildWar: GUILD_WAR_CANCEL type({}) guild({} - {})", __GetWarType(p->bType), p->dwGuildFrom, p->dwGuildTo);
CGuildManager::instance().CancelWar(p->dwGuildFrom, p->dwGuildTo); CGuildManager::instance().CancelWar(p->dwGuildFrom, p->dwGuildTo);
break; break;
} }
ForwardPacket(HEADER_DG_GUILD_WAR, p, sizeof(TPacketGuildWar)); ForwardPacket(HEADER_DG_GUILD_WAR, p, sizeof(TPacketGuildWar));
} }
void CClientManager::GuildWarScore(CPeer* peer, TPacketGuildWarScore * p) void CClientManager::GuildWarScore(CPeer *peer, TPacketGuildWarScore *p)
{ {
CGuildManager::instance().UpdateScore(p->dwGuildGainPoint, p->dwGuildOpponent, p->lScore, p->lBetScore); CGuildManager::instance().UpdateScore(p->dwGuildGainPoint, p->dwGuildOpponent, p->lScore, p->lBetScore);
} }
void CClientManager::GuildChangeLadderPoint(TPacketGuildLadderPoint* p) void CClientManager::GuildChangeLadderPoint(TPacketGuildLadderPoint *p)
{ {
SPDLOG_DEBUG("GuildChangeLadderPoint Recv {} {}", p->dwGuild, p->lChange); SPDLOG_DEBUG("GuildChangeLadderPoint Recv {} {}", p->dwGuild, p->lChange);
CGuildManager::instance().ChangeLadderPoint(p->dwGuild, p->lChange); CGuildManager::instance().ChangeLadderPoint(p->dwGuild, p->lChange);
} }
void CClientManager::GuildUseSkill(TPacketGuildUseSkill* p) void CClientManager::GuildUseSkill(TPacketGuildUseSkill *p)
{ {
SPDLOG_DEBUG("GuildUseSkill Recv {} {}", p->dwGuild, p->dwSkillVnum); SPDLOG_DEBUG("GuildUseSkill Recv {} {}", p->dwGuild, p->dwSkillVnum);
CGuildManager::instance().UseSkill(p->dwGuild, p->dwSkillVnum, p->dwCooltime); CGuildManager::instance().UseSkill(p->dwGuild, p->dwSkillVnum, p->dwCooltime);
@ -218,7 +217,7 @@ void CClientManager::GuildUseSkill(TPacketGuildUseSkill* p)
void CClientManager::SendGuildSkillUsable(DWORD guild_id, DWORD dwSkillVnum, bool bUsable) void CClientManager::SendGuildSkillUsable(DWORD guild_id, DWORD dwSkillVnum, bool bUsable)
{ {
SPDLOG_DEBUG("SendGuildSkillUsable Send {} {} {}", guild_id, dwSkillVnum, bUsable?"true":"false"); SPDLOG_DEBUG("SendGuildSkillUsable Send {} {} {}", guild_id, dwSkillVnum, bUsable ? "true" : "false");
TPacketGuildSkillUsableChange p; TPacketGuildSkillUsableChange p;
@ -229,7 +228,7 @@ void CClientManager::SendGuildSkillUsable(DWORD guild_id, DWORD dwSkillVnum, boo
ForwardPacket(HEADER_DG_GUILD_SKILL_USABLE_CHANGE, &p, sizeof(TPacketGuildSkillUsableChange)); ForwardPacket(HEADER_DG_GUILD_SKILL_USABLE_CHANGE, &p, sizeof(TPacketGuildSkillUsableChange));
} }
void CClientManager::GuildChangeMaster(TPacketChangeGuildMaster* p) void CClientManager::GuildChangeMaster(TPacketChangeGuildMaster *p)
{ {
if (CGuildManager::instance().ChangeMaster(p->dwGuildID, p->idFrom, p->idTo) == true) if (CGuildManager::instance().ChangeMaster(p->dwGuildID, p->idFrom, p->idTo) == true)
{ {
@ -241,4 +240,3 @@ void CClientManager::GuildChangeMaster(TPacketChangeGuildMaster* p)
ForwardPacket(HEADER_DG_ACK_CHANGE_GUILD_MASTER, &packet, sizeof(packet)); ForwardPacket(HEADER_DG_ACK_CHANGE_GUILD_MASTER, &packet, sizeof(packet));
} }
} }

View File

@ -2,7 +2,7 @@
#include "stdafx.h" #include "stdafx.h"
#include "ClientManager.h" #include "ClientManager.h"
void CClientManager::UpdateHorseName(TPacketUpdateHorseName* data, CPeer* peer) void CClientManager::UpdateHorseName(TPacketUpdateHorseName *data, CPeer *peer)
{ {
char szQuery[512]; char szQuery[512];
@ -13,7 +13,7 @@ void CClientManager::UpdateHorseName(TPacketUpdateHorseName* data, CPeer* peer)
ForwardPacket(HEADER_DG_UPDATE_HORSE_NAME, data, sizeof(TPacketUpdateHorseName), 0, peer); ForwardPacket(HEADER_DG_UPDATE_HORSE_NAME, data, sizeof(TPacketUpdateHorseName), 0, peer);
} }
void CClientManager::AckHorseName(DWORD dwPID, CPeer* peer) void CClientManager::AckHorseName(DWORD dwPID, CPeer *peer)
{ {
char szQuery[512]; char szQuery[512];
@ -26,7 +26,7 @@ void CClientManager::AckHorseName(DWORD dwPID, CPeer* peer)
if (pmsg->Get()->uiNumRows == 0) if (pmsg->Get()->uiNumRows == 0)
{ {
memset(packet.szHorseName, 0, sizeof (packet.szHorseName)); memset(packet.szHorseName, 0, sizeof(packet.szHorseName));
} }
else else
{ {
@ -37,4 +37,3 @@ void CClientManager::AckHorseName(DWORD dwPID, CPeer* peer)
peer->EncodeHeader(HEADER_DG_ACK_HORSE_NAME, 0, sizeof(TPacketUpdateHorseName)); peer->EncodeHeader(HEADER_DG_ACK_HORSE_NAME, 0, sizeof(TPacketUpdateHorseName));
peer->Encode(&packet, sizeof(TPacketUpdateHorseName)); peer->Encode(&packet, sizeof(TPacketUpdateHorseName));
} }

View File

@ -9,10 +9,10 @@
#include "Cache.h" #include "Cache.h"
extern std::string g_stLocale; extern std::string g_stLocale;
extern bool CreatePlayerTableFromRes(MYSQL_RES * res, TPlayerTable * pkTab); extern bool CreatePlayerTableFromRes(MYSQL_RES *res, TPlayerTable *pkTab);
extern int g_test_server; extern int g_test_server;
bool CClientManager::InsertLogonAccount(const char * c_pszLogin, DWORD dwHandle, const char * c_pszIP) bool CClientManager::InsertLogonAccount(const char *c_pszLogin, DWORD dwHandle, const char *c_pszIP)
{ {
char szLogin[LOGIN_MAX_LEN + 1]; char szLogin[LOGIN_MAX_LEN + 1];
trim_and_lower(c_pszLogin, szLogin, sizeof(szLogin)); trim_and_lower(c_pszLogin, szLogin, sizeof(szLogin));
@ -22,7 +22,7 @@ bool CClientManager::InsertLogonAccount(const char * c_pszLogin, DWORD dwHandle,
if (m_map_kLogonAccount.end() != it) if (m_map_kLogonAccount.end() != it)
return false; return false;
CLoginData * pkLD = GetLoginDataByLogin(c_pszLogin); CLoginData *pkLD = GetLoginDataByLogin(c_pszLogin);
if (!pkLD) if (!pkLD)
return false; return false;
@ -34,7 +34,7 @@ bool CClientManager::InsertLogonAccount(const char * c_pszLogin, DWORD dwHandle,
return true; return true;
} }
bool CClientManager::DeleteLogonAccount(const char * c_pszLogin, DWORD dwHandle) bool CClientManager::DeleteLogonAccount(const char *c_pszLogin, DWORD dwHandle)
{ {
char szLogin[LOGIN_MAX_LEN + 1]; char szLogin[LOGIN_MAX_LEN + 1];
trim_and_lower(c_pszLogin, szLogin, sizeof(szLogin)); trim_and_lower(c_pszLogin, szLogin, sizeof(szLogin));
@ -44,7 +44,7 @@ bool CClientManager::DeleteLogonAccount(const char * c_pszLogin, DWORD dwHandle)
if (it == m_map_kLogonAccount.end()) if (it == m_map_kLogonAccount.end())
return false; return false;
CLoginData * pkLD = it->second; CLoginData *pkLD = it->second;
if (pkLD->GetConnectedPeerHandle() != dwHandle) if (pkLD->GetConnectedPeerHandle() != dwHandle)
{ {
@ -66,7 +66,7 @@ bool CClientManager::DeleteLogonAccount(const char * c_pszLogin, DWORD dwHandle)
return true; return true;
} }
bool CClientManager::FindLogonAccount(const char * c_pszLogin) bool CClientManager::FindLogonAccount(const char *c_pszLogin)
{ {
char szLogin[LOGIN_MAX_LEN + 1]; char szLogin[LOGIN_MAX_LEN + 1];
trim_and_lower(c_pszLogin, szLogin, sizeof(szLogin)); trim_and_lower(c_pszLogin, szLogin, sizeof(szLogin));
@ -77,9 +77,9 @@ bool CClientManager::FindLogonAccount(const char * c_pszLogin)
return true; return true;
} }
void CClientManager::QUERY_LOGIN_BY_KEY(CPeer * pkPeer, DWORD dwHandle, TPacketGDLoginByKey * p) void CClientManager::QUERY_LOGIN_BY_KEY(CPeer *pkPeer, DWORD dwHandle, TPacketGDLoginByKey *p)
{ {
CLoginData * pkLoginData = GetLoginData(p->dwLoginKey); CLoginData *pkLoginData = GetLoginData(p->dwLoginKey);
char szLogin[LOGIN_MAX_LEN + 1]; char szLogin[LOGIN_MAX_LEN + 1];
trim_and_lower(p->szLogin, szLogin, sizeof(szLogin)); trim_and_lower(p->szLogin, szLogin, sizeof(szLogin));
@ -90,7 +90,7 @@ void CClientManager::QUERY_LOGIN_BY_KEY(CPeer * pkPeer, DWORD dwHandle, TPacketG
return; return;
} }
TAccountTable & r = pkLoginData->GetAccountRef(); TAccountTable &r = pkLoginData->GetAccountRef();
if (FindLogonAccount(r.login)) if (FindLogonAccount(r.login))
{ {
@ -111,18 +111,18 @@ void CClientManager::QUERY_LOGIN_BY_KEY(CPeer * pkPeer, DWORD dwHandle, TPacketG
if (memcmp(pkLoginData->GetClientKey(), p->adwClientKey, sizeof(DWORD) * 4)) if (memcmp(pkLoginData->GetClientKey(), p->adwClientKey, sizeof(DWORD) * 4))
{ {
const DWORD * pdwClientKey = pkLoginData->GetClientKey(); const DWORD *pdwClientKey = pkLoginData->GetClientKey();
SPDLOG_DEBUG("LOGIN_BY_KEY client key differ {} {} {} {} {}, {} {} {} {}", SPDLOG_DEBUG("LOGIN_BY_KEY client key differ {} {} {} {} {}, {} {} {} {}",
r.login, r.login,
p->adwClientKey[0], p->adwClientKey[1], p->adwClientKey[2], p->adwClientKey[3], p->adwClientKey[0], p->adwClientKey[1], p->adwClientKey[2], p->adwClientKey[3],
pdwClientKey[0], pdwClientKey[1], pdwClientKey[2], pdwClientKey[3]); pdwClientKey[0], pdwClientKey[1], pdwClientKey[2], pdwClientKey[3]);
pkPeer->EncodeReturn(HEADER_DG_LOGIN_NOT_EXIST, dwHandle); pkPeer->EncodeReturn(HEADER_DG_LOGIN_NOT_EXIST, dwHandle);
return; return;
} }
TAccountTable * pkTab = new TAccountTable; TAccountTable *pkTab = new TAccountTable;
memset(pkTab, 0, sizeof(TAccountTable)); memset(pkTab, 0, sizeof(TAccountTable));
pkTab->id = r.id; pkTab->id = r.id;
@ -131,7 +131,7 @@ void CClientManager::QUERY_LOGIN_BY_KEY(CPeer * pkPeer, DWORD dwHandle, TPacketG
strlcpy(pkTab->social_id, r.social_id, sizeof(pkTab->social_id)); strlcpy(pkTab->social_id, r.social_id, sizeof(pkTab->social_id));
strlcpy(pkTab->status, "OK", sizeof(pkTab->status)); strlcpy(pkTab->status, "OK", sizeof(pkTab->status));
ClientHandleInfo * info = new ClientHandleInfo(dwHandle); ClientHandleInfo *info = new ClientHandleInfo(dwHandle);
info->pAccountTable = pkTab; info->pAccountTable = pkTab;
strlcpy(info->ip, p->szIP, sizeof(info->ip)); strlcpy(info->ip, p->szIP, sizeof(info->ip));
@ -141,10 +141,10 @@ void CClientManager::QUERY_LOGIN_BY_KEY(CPeer * pkPeer, DWORD dwHandle, TPacketG
CDBManager::instance().ReturnQuery(szQuery, QID_LOGIN_BY_KEY, pkPeer->GetHandle(), info); CDBManager::instance().ReturnQuery(szQuery, QID_LOGIN_BY_KEY, pkPeer->GetHandle(), info);
} }
void CClientManager::RESULT_LOGIN_BY_KEY(CPeer * peer, SQLMsg * msg) void CClientManager::RESULT_LOGIN_BY_KEY(CPeer *peer, SQLMsg *msg)
{ {
CQueryInfo * qi = (CQueryInfo *) msg->pvUserData; CQueryInfo *qi = (CQueryInfo *)msg->pvUserData;
ClientHandleInfo * info = (ClientHandleInfo *) qi->pvData; ClientHandleInfo *info = (ClientHandleInfo *)qi->pvData;
if (msg->uiSQLErrno != 0) if (msg->uiSQLErrno != 0)
{ {
@ -161,7 +161,7 @@ void CClientManager::RESULT_LOGIN_BY_KEY(CPeer * peer, SQLMsg * msg)
char szQuery[QUERY_MAX_LEN]; char szQuery[QUERY_MAX_LEN];
snprintf(szQuery, sizeof(szQuery), "SELECT pid1, pid2, pid3, pid4, empire FROM player_index%s WHERE id=%u", GetTablePostfix(), account_id); snprintf(szQuery, sizeof(szQuery), "SELECT pid1, pid2, pid3, pid4, empire FROM player_index%s WHERE id=%u", GetTablePostfix(), account_id);
std::unique_ptr<SQLMsg> pMsg(CDBManager::instance().DirectQuery(szQuery, SQL_PLAYER)); std::unique_ptr<SQLMsg> pMsg(CDBManager::instance().DirectQuery(szQuery, SQL_PLAYER));
SPDLOG_DEBUG("RESULT_LOGIN_BY_KEY FAIL player_index's NULL : ID:{}", account_id); SPDLOG_DEBUG("RESULT_LOGIN_BY_KEY FAIL player_index's NULL : ID:{}", account_id);
if (pMsg->Get()->uiNumRows == 0) if (pMsg->Get()->uiNumRows == 0)
@ -169,7 +169,7 @@ void CClientManager::RESULT_LOGIN_BY_KEY(CPeer * peer, SQLMsg * msg)
SPDLOG_DEBUG("RESULT_LOGIN_BY_KEY FAIL player_index's NULL : ID:{}", account_id); SPDLOG_DEBUG("RESULT_LOGIN_BY_KEY FAIL player_index's NULL : ID:{}", account_id);
// PLAYER_INDEX_CREATE_BUG_FIX // PLAYER_INDEX_CREATE_BUG_FIX
//snprintf(szQuery, sizeof(szQuery), "INSERT IGNORE INTO player_index%s (id) VALUES(%lu)", GetTablePostfix(), info->pAccountTable->id); // snprintf(szQuery, sizeof(szQuery), "INSERT IGNORE INTO player_index%s (id) VALUES(%lu)", GetTablePostfix(), info->pAccountTable->id);
snprintf(szQuery, sizeof(szQuery), "INSERT INTO player_index%s (id) VALUES(%u)", GetTablePostfix(), info->pAccountTable->id); snprintf(szQuery, sizeof(szQuery), "INSERT INTO player_index%s (id) VALUES(%u)", GetTablePostfix(), info->pAccountTable->id);
CDBManager::instance().ReturnQuery(szQuery, QID_PLAYER_INDEX_CREATE, peer->GetHandle(), info); CDBManager::instance().ReturnQuery(szQuery, QID_PLAYER_INDEX_CREATE, peer->GetHandle(), info);
// END_PLAYER_INDEX_CREATE_BUF_FIX // END_PLAYER_INDEX_CREATE_BUF_FIX
@ -191,33 +191,33 @@ void CClientManager::RESULT_LOGIN_BY_KEY(CPeer * peer, SQLMsg * msg)
if (g_stLocale == "gb2312") if (g_stLocale == "gb2312")
{ {
snprintf(szQuery, sizeof(szQuery), snprintf(szQuery, sizeof(szQuery),
"SELECT id, name, job, level, alignment, st, ht, dx, iq, part_main, part_hair, x, y, skill_group, change_name FROM player%s WHERE account_id=%u", "SELECT id, name, job, level, alignment, st, ht, dx, iq, part_main, part_hair, x, y, skill_group, change_name FROM player%s WHERE account_id=%u",
GetTablePostfix(), info->pAccountTable->id); GetTablePostfix(), info->pAccountTable->id);
} }
else else
{ {
snprintf(szQuery, sizeof(szQuery), snprintf(szQuery, sizeof(szQuery),
"SELECT id, name, job, level, playtime, st, ht, dx, iq, part_main, part_hair, x, y, skill_group, change_name FROM player%s WHERE account_id=%u", "SELECT id, name, job, level, playtime, st, ht, dx, iq, part_main, part_hair, x, y, skill_group, change_name FROM player%s WHERE account_id=%u",
GetTablePostfix(), info->pAccountTable->id); GetTablePostfix(), info->pAccountTable->id);
} }
CDBManager::instance().ReturnQuery(szQuery, QID_LOGIN, peer->GetHandle(), info); CDBManager::instance().ReturnQuery(szQuery, QID_LOGIN, peer->GetHandle(), info);
} }
// PLAYER_INDEX_CREATE_BUG_FIX // PLAYER_INDEX_CREATE_BUG_FIX
void CClientManager::RESULT_PLAYER_INDEX_CREATE(CPeer * pkPeer, SQLMsg * msg) void CClientManager::RESULT_PLAYER_INDEX_CREATE(CPeer *pkPeer, SQLMsg *msg)
{ {
CQueryInfo * qi = (CQueryInfo *) msg->pvUserData; CQueryInfo *qi = (CQueryInfo *)msg->pvUserData;
ClientHandleInfo * info = (ClientHandleInfo *) qi->pvData; ClientHandleInfo *info = (ClientHandleInfo *)qi->pvData;
char szQuery[QUERY_MAX_LEN]; char szQuery[QUERY_MAX_LEN];
snprintf(szQuery, sizeof(szQuery), "SELECT pid1, pid2, pid3, pid4, empire FROM player_index%s WHERE id=%u", GetTablePostfix(), snprintf(szQuery, sizeof(szQuery), "SELECT pid1, pid2, pid3, pid4, empire FROM player_index%s WHERE id=%u", GetTablePostfix(),
info->pAccountTable->id); info->pAccountTable->id);
CDBManager::instance().ReturnQuery(szQuery, QID_LOGIN_BY_KEY, pkPeer->GetHandle(), info); CDBManager::instance().ReturnQuery(szQuery, QID_LOGIN_BY_KEY, pkPeer->GetHandle(), info);
} }
// END_PLAYER_INDEX_CREATE_BUG_FIX // END_PLAYER_INDEX_CREATE_BUG_FIX
TAccountTable * CreateAccountTableFromRes(MYSQL_RES * res) TAccountTable *CreateAccountTableFromRes(MYSQL_RES *res)
{ {
char input_pwd[PASSWD_MAX_LEN + 1]; char input_pwd[PASSWD_MAX_LEN + 1];
MYSQL_ROW row = NULL; MYSQL_ROW row = NULL;
@ -226,7 +226,7 @@ TAccountTable * CreateAccountTableFromRes(MYSQL_RES * res)
row = mysql_fetch_row(res); row = mysql_fetch_row(res);
col = 0; col = 0;
TAccountTable * pkTab = new TAccountTable; TAccountTable *pkTab = new TAccountTable;
memset(pkTab, 0, sizeof(TAccountTable)); memset(pkTab, 0, sizeof(TAccountTable));
// 첫번째 컬럼 것만 참고 한다 (JOIN QUERY를 위한 것 임) // 첫번째 컬럼 것만 참고 한다 (JOIN QUERY를 위한 것 임)
@ -251,7 +251,7 @@ TAccountTable * CreateAccountTableFromRes(MYSQL_RES * res)
return pkTab; return pkTab;
} }
void CreateAccountPlayerDataFromRes(MYSQL_RES * pRes, TAccountTable * pkTab) void CreateAccountPlayerDataFromRes(MYSQL_RES *pRes, TAccountTable *pkTab)
{ {
if (!pRes) if (!pRes)
return; return;
@ -273,26 +273,26 @@ void CreateAccountPlayerDataFromRes(MYSQL_RES * pRes, TAccountTable * pkTab)
{ {
if (pkTab->players[j].dwID == player_id) if (pkTab->players[j].dwID == player_id)
{ {
CPlayerTableCache * pc = CClientManager::instance().GetPlayerCache(player_id); CPlayerTableCache *pc = CClientManager::instance().GetPlayerCache(player_id);
TPlayerTable * pt = pc ? pc->Get(false) : NULL; TPlayerTable *pt = pc ? pc->Get(false) : NULL;
if (pt) if (pt)
{ {
strlcpy(pkTab->players[j].szName, pt->name, sizeof(pkTab->players[j].szName)); strlcpy(pkTab->players[j].szName, pt->name, sizeof(pkTab->players[j].szName));
pkTab->players[j].byJob = pt->job; pkTab->players[j].byJob = pt->job;
pkTab->players[j].byLevel = pt->level; pkTab->players[j].byLevel = pt->level;
pkTab->players[j].dwPlayMinutes = pt->playtime; pkTab->players[j].dwPlayMinutes = pt->playtime;
pkTab->players[j].byST = pt->st; pkTab->players[j].byST = pt->st;
pkTab->players[j].byHT = pt->ht; pkTab->players[j].byHT = pt->ht;
pkTab->players[j].byDX = pt->dx; pkTab->players[j].byDX = pt->dx;
pkTab->players[j].byIQ = pt->iq; pkTab->players[j].byIQ = pt->iq;
pkTab->players[j].wMainPart = pt->parts[PART_MAIN]; pkTab->players[j].wMainPart = pt->parts[PART_MAIN];
pkTab->players[j].wHairPart = pt->parts[PART_HAIR]; pkTab->players[j].wHairPart = pt->parts[PART_HAIR];
pkTab->players[j].x = pt->x; pkTab->players[j].x = pt->x;
pkTab->players[j].y = pt->y; pkTab->players[j].y = pt->y;
pkTab->players[j].skill_group = pt->skill_group; pkTab->players[j].skill_group = pt->skill_group;
pkTab->players[j].bChangeName = 0; pkTab->players[j].bChangeName = 0;
} }
else else
{ {
@ -301,19 +301,19 @@ void CreateAccountPlayerDataFromRes(MYSQL_RES * pRes, TAccountTable * pkTab)
else else
strlcpy(pkTab->players[j].szName, row[col - 1], sizeof(pkTab->players[j].szName)); strlcpy(pkTab->players[j].szName, row[col - 1], sizeof(pkTab->players[j].szName));
pkTab->players[j].byJob = 0; pkTab->players[j].byJob = 0;
pkTab->players[j].byLevel = 0; pkTab->players[j].byLevel = 0;
pkTab->players[j].dwPlayMinutes = 0; pkTab->players[j].dwPlayMinutes = 0;
pkTab->players[j].byST = 0; pkTab->players[j].byST = 0;
pkTab->players[j].byHT = 0; pkTab->players[j].byHT = 0;
pkTab->players[j].byDX = 0; pkTab->players[j].byDX = 0;
pkTab->players[j].byIQ = 0; pkTab->players[j].byIQ = 0;
pkTab->players[j].wMainPart = 0; pkTab->players[j].wMainPart = 0;
pkTab->players[j].wHairPart = 0; pkTab->players[j].wHairPart = 0;
pkTab->players[j].x = 0; pkTab->players[j].x = 0;
pkTab->players[j].y = 0; pkTab->players[j].y = 0;
pkTab->players[j].skill_group = 0; pkTab->players[j].skill_group = 0;
pkTab->players[j].bChangeName = 0; pkTab->players[j].bChangeName = 0;
str_to_number(pkTab->players[j].byJob, row[col++]); str_to_number(pkTab->players[j].byJob, row[col++]);
str_to_number(pkTab->players[j].byLevel, row[col++]); str_to_number(pkTab->players[j].byLevel, row[col++]);
@ -331,7 +331,7 @@ void CreateAccountPlayerDataFromRes(MYSQL_RES * pRes, TAccountTable * pkTab)
} }
SPDLOG_DEBUG("{} {} {} hair {}", SPDLOG_DEBUG("{} {} {} hair {}",
pkTab->players[j].szName, pkTab->players[j].x, pkTab->players[j].y, pkTab->players[j].wHairPart); pkTab->players[j].szName, pkTab->players[j].x, pkTab->players[j].y, pkTab->players[j].wHairPart);
break; break;
} }
} }
@ -346,10 +346,10 @@ void CreateAccountPlayerDataFromRes(MYSQL_RES * pRes, TAccountTable * pkTab)
} }
} }
void CClientManager::RESULT_LOGIN(CPeer * peer, SQLMsg * msg) void CClientManager::RESULT_LOGIN(CPeer *peer, SQLMsg *msg)
{ {
CQueryInfo * qi = (CQueryInfo *) msg->pvUserData; CQueryInfo *qi = (CQueryInfo *)msg->pvUserData;
ClientHandleInfo * info = (ClientHandleInfo *) qi->pvData; ClientHandleInfo *info = (ClientHandleInfo *)qi->pvData;
if (info->account_index == 0) if (info->account_index == 0)
{ {
@ -379,14 +379,14 @@ void CClientManager::RESULT_LOGIN(CPeer * peer, SQLMsg * msg)
if (g_stLocale == "gb2312") if (g_stLocale == "gb2312")
{ {
snprintf(queryStr, sizeof(queryStr), snprintf(queryStr, sizeof(queryStr),
"SELECT id, name, job, level, alignment, st, ht, dx, iq, part_main, part_hair, x, y, skill_group, change_name FROM player%s WHERE account_id=%u", "SELECT id, name, job, level, alignment, st, ht, dx, iq, part_main, part_hair, x, y, skill_group, change_name FROM player%s WHERE account_id=%u",
GetTablePostfix(), info->pAccountTable->id); GetTablePostfix(), info->pAccountTable->id);
} }
else else
{ {
snprintf(queryStr, sizeof(queryStr), snprintf(queryStr, sizeof(queryStr),
"SELECT id, name, job, level, playtime, st, ht, dx, iq, part_main, part_hair, x, y, skill_group, change_name FROM player%s WHERE account_id=%u", "SELECT id, name, job, level, playtime, st, ht, dx, iq, part_main, part_hair, x, y, skill_group, change_name FROM player%s WHERE account_id=%u",
GetTablePostfix(), info->pAccountTable->id); GetTablePostfix(), info->pAccountTable->id);
} }
CDBManager::instance().ReturnQuery(queryStr, QID_LOGIN, peer->GetHandle(), info); CDBManager::instance().ReturnQuery(queryStr, QID_LOGIN, peer->GetHandle(), info);
@ -420,14 +420,13 @@ void CClientManager::RESULT_LOGIN(CPeer * peer, SQLMsg * msg)
if (msg->Get()->uiNumRows > 0) if (msg->Get()->uiNumRows > 0)
CreateAccountPlayerDataFromRes(msg->Get()->pSQLResult, info->pAccountTable); CreateAccountPlayerDataFromRes(msg->Get()->pSQLResult, info->pAccountTable);
//PREVENT_COPY_ITEM // PREVENT_COPY_ITEM
CLoginData * p = GetLoginDataByLogin(info->pAccountTable->login); CLoginData *p = GetLoginDataByLogin(info->pAccountTable->login);
memcpy(&p->GetAccountRef(), info->pAccountTable, sizeof(TAccountTable)); memcpy(&p->GetAccountRef(), info->pAccountTable, sizeof(TAccountTable));
//END_PREVENT_COPY_ITEM // END_PREVENT_COPY_ITEM
peer->EncodeHeader(HEADER_DG_LOGIN_SUCCESS, info->dwHandle, sizeof(TAccountTable)); peer->EncodeHeader(HEADER_DG_LOGIN_SUCCESS, info->dwHandle, sizeof(TAccountTable));
peer->Encode(info->pAccountTable, sizeof(TAccountTable)); peer->Encode(info->pAccountTable, sizeof(TAccountTable));
} }
delete info->pAccountTable; delete info->pAccountTable;
@ -436,14 +435,14 @@ void CClientManager::RESULT_LOGIN(CPeer * peer, SQLMsg * msg)
} }
} }
void CClientManager::QUERY_LOGOUT(CPeer * peer, DWORD dwHandle,const char * data) void CClientManager::QUERY_LOGOUT(CPeer *peer, DWORD dwHandle, const char *data)
{ {
TLogoutPacket* packet = (TLogoutPacket*)data; TLogoutPacket *packet = (TLogoutPacket *)data;
if (!*packet->login) if (!*packet->login)
return; return;
CLoginData * pLoginData = GetLoginDataByLogin(packet->login); CLoginData *pLoginData = GetLoginDataByLogin(packet->login);
if (pLoginData == NULL) if (pLoginData == NULL)
return; return;
@ -457,31 +456,31 @@ void CClientManager::QUERY_LOGOUT(CPeer * peer, DWORD dwHandle,const char * data
SPDLOG_TRACE("LOGOUT {} {}", packet->login, pLoginData->GetAccountRef().players[n].dwID); SPDLOG_TRACE("LOGOUT {} {}", packet->login, pLoginData->GetAccountRef().players[n].dwID);
continue; continue;
} }
pid[n] = pLoginData->GetAccountRef().players[n].dwID; pid[n] = pLoginData->GetAccountRef().players[n].dwID;
SPDLOG_TRACE("LOGOUT InsertLogoutPlayer {} {}", packet->login, pid[n]); SPDLOG_TRACE("LOGOUT InsertLogoutPlayer {} {}", packet->login, pid[n]);
InsertLogoutPlayer(pid[n]); InsertLogoutPlayer(pid[n]);
} }
if (DeleteLogonAccount(packet->login, peer->GetHandle())) if (DeleteLogonAccount(packet->login, peer->GetHandle()))
{ {
SPDLOG_TRACE("LOGOUT {} ", packet->login); SPDLOG_TRACE("LOGOUT {} ", packet->login);
} }
} }
void CClientManager::QUERY_CHANGE_NAME(CPeer * peer, DWORD dwHandle, TPacketGDChangeName * p) void CClientManager::QUERY_CHANGE_NAME(CPeer *peer, DWORD dwHandle, TPacketGDChangeName *p)
{ {
char queryStr[QUERY_MAX_LEN]; char queryStr[QUERY_MAX_LEN];
if (g_stLocale == "sjis") if (g_stLocale == "sjis")
snprintf(queryStr, sizeof(queryStr), snprintf(queryStr, sizeof(queryStr),
"SELECT COUNT(*) as count FROM player%s WHERE name='%s' collate sjis_japanese_ci AND id <> %u", "SELECT COUNT(*) as count FROM player%s WHERE name='%s' collate sjis_japanese_ci AND id <> %u",
GetTablePostfix(), p->name, p->pid); GetTablePostfix(), p->name, p->pid);
else else
snprintf(queryStr, sizeof(queryStr), snprintf(queryStr, sizeof(queryStr),
"SELECT COUNT(*) as count FROM player%s WHERE name='%s' AND id <> %u", GetTablePostfix(), p->name, p->pid); "SELECT COUNT(*) as count FROM player%s WHERE name='%s' AND id <> %u", GetTablePostfix(), p->name, p->pid);
std::unique_ptr<SQLMsg> pMsg(CDBManager::instance().DirectQuery(queryStr, SQL_PLAYER)); std::unique_ptr<SQLMsg> pMsg(CDBManager::instance().DirectQuery(queryStr, SQL_PLAYER));
@ -500,7 +499,7 @@ void CClientManager::QUERY_CHANGE_NAME(CPeer * peer, DWORD dwHandle, TPacketGDCh
peer->EncodeHeader(HEADER_DG_PLAYER_CREATE_ALREADY, dwHandle, 0); peer->EncodeHeader(HEADER_DG_PLAYER_CREATE_ALREADY, dwHandle, 0);
return; return;
} }
} }
else else
{ {
peer->EncodeHeader(HEADER_DG_PLAYER_CREATE_FAILED, dwHandle, 0); peer->EncodeHeader(HEADER_DG_PLAYER_CREATE_FAILED, dwHandle, 0);
@ -508,7 +507,7 @@ void CClientManager::QUERY_CHANGE_NAME(CPeer * peer, DWORD dwHandle, TPacketGDCh
} }
snprintf(queryStr, sizeof(queryStr), snprintf(queryStr, sizeof(queryStr),
"UPDATE player%s SET name='%s',change_name=0 WHERE id=%u", GetTablePostfix(), p->name, p->pid); "UPDATE player%s SET name='%s',change_name=0 WHERE id=%u", GetTablePostfix(), p->name, p->pid);
std::unique_ptr<SQLMsg> pMsg0(CDBManager::instance().DirectQuery(queryStr, SQL_PLAYER)); std::unique_ptr<SQLMsg> pMsg0(CDBManager::instance().DirectQuery(queryStr, SQL_PLAYER));
@ -518,4 +517,3 @@ void CClientManager::QUERY_CHANGE_NAME(CPeer * peer, DWORD dwHandle, TPacketGDCh
strlcpy(pdg.name, p->name, sizeof(pdg.name)); strlcpy(pdg.name, p->name, sizeof(pdg.name));
peer->Encode(&pdg, sizeof(TPacketDGChangeName)); peer->Encode(&pdg, sizeof(TPacketDGChangeName));
} }

View File

@ -5,9 +5,9 @@
#include "DBManager.h" #include "DBManager.h"
#include "QID.h" #include "QID.h"
void CClientManager::QUERY_PARTY_CREATE(CPeer* peer, TPacketPartyCreate* p) void CClientManager::QUERY_PARTY_CREATE(CPeer *peer, TPacketPartyCreate *p)
{ {
TPartyMap & pm = m_map_pkChannelParty[peer->GetChannel()]; TPartyMap &pm = m_map_pkChannelParty[peer->GetChannel()];
if (pm.find(p->dwLeaderPID) == pm.end()) if (pm.find(p->dwLeaderPID) == pm.end())
{ {
@ -21,9 +21,9 @@ void CClientManager::QUERY_PARTY_CREATE(CPeer* peer, TPacketPartyCreate* p)
} }
} }
void CClientManager::QUERY_PARTY_DELETE(CPeer* peer, TPacketPartyDelete* p) void CClientManager::QUERY_PARTY_DELETE(CPeer *peer, TPacketPartyDelete *p)
{ {
TPartyMap& pm = m_map_pkChannelParty[peer->GetChannel()]; TPartyMap &pm = m_map_pkChannelParty[peer->GetChannel()];
itertype(pm) it = pm.find(p->dwLeaderPID); itertype(pm) it = pm.find(p->dwLeaderPID);
if (it == pm.end()) if (it == pm.end())
@ -37,9 +37,9 @@ void CClientManager::QUERY_PARTY_DELETE(CPeer* peer, TPacketPartyDelete* p)
SPDLOG_DEBUG("PARTY Delete [{}]", p->dwLeaderPID); SPDLOG_DEBUG("PARTY Delete [{}]", p->dwLeaderPID);
} }
void CClientManager::QUERY_PARTY_ADD(CPeer* peer, TPacketPartyAdd* p) void CClientManager::QUERY_PARTY_ADD(CPeer *peer, TPacketPartyAdd *p)
{ {
TPartyMap & pm = m_map_pkChannelParty[peer->GetChannel()]; TPartyMap &pm = m_map_pkChannelParty[peer->GetChannel()];
itertype(pm) it = pm.find(p->dwLeaderPID); itertype(pm) it = pm.find(p->dwLeaderPID);
if (it == pm.end()) if (it == pm.end())
@ -58,14 +58,14 @@ void CClientManager::QUERY_PARTY_ADD(CPeer* peer, TPacketPartyAdd* p)
SPDLOG_ERROR("PARTY Add - Already [{}] in party [{}]", p->dwPID, p->dwLeaderPID); SPDLOG_ERROR("PARTY Add - Already [{}] in party [{}]", p->dwPID, p->dwLeaderPID);
} }
void CClientManager::QUERY_PARTY_REMOVE(CPeer* peer, TPacketPartyRemove* p) void CClientManager::QUERY_PARTY_REMOVE(CPeer *peer, TPacketPartyRemove *p)
{ {
TPartyMap & pm = m_map_pkChannelParty[peer->GetChannel()]; TPartyMap &pm = m_map_pkChannelParty[peer->GetChannel()];
itertype(pm) it = pm.find(p->dwLeaderPID); itertype(pm) it = pm.find(p->dwLeaderPID);
if (it == pm.end()) if (it == pm.end())
{ {
SPDLOG_ERROR("PARTY Remove - Non exists [{}] cannot remove [{}]",p->dwLeaderPID, p->dwPID); SPDLOG_ERROR("PARTY Remove - Non exists [{}] cannot remove [{}]", p->dwLeaderPID, p->dwPID);
return; return;
} }
@ -81,14 +81,14 @@ void CClientManager::QUERY_PARTY_REMOVE(CPeer* peer, TPacketPartyRemove* p)
SPDLOG_ERROR("PARTY Remove - Cannot find [{}] in party [{}]", p->dwPID, p->dwLeaderPID); SPDLOG_ERROR("PARTY Remove - Cannot find [{}] in party [{}]", p->dwPID, p->dwLeaderPID);
} }
void CClientManager::QUERY_PARTY_STATE_CHANGE(CPeer* peer, TPacketPartyStateChange* p) void CClientManager::QUERY_PARTY_STATE_CHANGE(CPeer *peer, TPacketPartyStateChange *p)
{ {
TPartyMap & pm = m_map_pkChannelParty[peer->GetChannel()]; TPartyMap &pm = m_map_pkChannelParty[peer->GetChannel()];
itertype(pm) it = pm.find(p->dwLeaderPID); itertype(pm) it = pm.find(p->dwLeaderPID);
if (it == pm.end()) if (it == pm.end())
{ {
SPDLOG_ERROR("PARTY StateChange - Non exists [{}] cannot state change [{}]",p->dwLeaderPID, p->dwPID); SPDLOG_ERROR("PARTY StateChange - Non exists [{}] cannot state change [{}]", p->dwLeaderPID, p->dwPID);
return; return;
} }
@ -102,21 +102,21 @@ void CClientManager::QUERY_PARTY_STATE_CHANGE(CPeer* peer, TPacketPartyStateChan
if (p->bFlag) if (p->bFlag)
pit->second.bRole = p->bRole; pit->second.bRole = p->bRole;
else else
pit->second.bRole = 0; pit->second.bRole = 0;
ForwardPacket(HEADER_DG_PARTY_STATE_CHANGE, p, sizeof(TPacketPartyStateChange), peer->GetChannel(), peer); ForwardPacket(HEADER_DG_PARTY_STATE_CHANGE, p, sizeof(TPacketPartyStateChange), peer->GetChannel(), peer);
SPDLOG_DEBUG("PARTY StateChange [{}] at [{}] from {} {}",p->dwPID, p->dwLeaderPID, p->bRole, p->bFlag); SPDLOG_DEBUG("PARTY StateChange [{}] at [{}] from {} {}", p->dwPID, p->dwLeaderPID, p->bRole, p->bFlag);
} }
void CClientManager::QUERY_PARTY_SET_MEMBER_LEVEL(CPeer* peer, TPacketPartySetMemberLevel* p) void CClientManager::QUERY_PARTY_SET_MEMBER_LEVEL(CPeer *peer, TPacketPartySetMemberLevel *p)
{ {
TPartyMap & pm = m_map_pkChannelParty[peer->GetChannel()]; TPartyMap &pm = m_map_pkChannelParty[peer->GetChannel()];
itertype(pm) it = pm.find(p->dwLeaderPID); itertype(pm) it = pm.find(p->dwLeaderPID);
if (it == pm.end()) if (it == pm.end())
{ {
SPDLOG_ERROR("PARTY SetMemberLevel - Non exists [{}] cannot level change [{}]",p->dwLeaderPID, p->dwPID); SPDLOG_ERROR("PARTY SetMemberLevel - Non exists [{}] cannot level change [{}]", p->dwLeaderPID, p->dwPID);
return; return;
} }
@ -131,5 +131,5 @@ void CClientManager::QUERY_PARTY_SET_MEMBER_LEVEL(CPeer* peer, TPacketPartySetMe
pit->second.bLevel = p->bLevel; pit->second.bLevel = p->bLevel;
ForwardPacket(HEADER_DG_PARTY_SET_MEMBER_LEVEL, p, sizeof(TPacketPartySetMemberLevel), peer->GetChannel()); ForwardPacket(HEADER_DG_PARTY_SET_MEMBER_LEVEL, p, sizeof(TPacketPartySetMemberLevel), peer->GetChannel());
SPDLOG_DEBUG("PARTY SetMemberLevel pid [{}] level {}",p->dwPID, p->bLevel); SPDLOG_DEBUG("PARTY SetMemberLevel pid [{}] level {}", p->dwPID, p->bLevel);
} }

File diff suppressed because it is too large Load Diff

View File

@ -35,7 +35,7 @@ bool CConfig::GetWord(FILE *fp, char *tar)
while ((c = fgetc(fp)) != EOF) while ((c = fgetc(fp)) != EOF)
{ {
if (c == 13) if (c == 13)
continue; continue;
if (semicolon_mode) if (semicolon_mode)
@ -80,7 +80,7 @@ bool CConfig::GetWord(FILE *fp, char *tar)
return (i != 0); return (i != 0);
} }
bool CConfig::GetLine(FILE* fp, char*dest) bool CConfig::GetLine(FILE *fp, char *dest)
{ {
int c; int c;
int i = 0; int i = 0;
@ -91,15 +91,15 @@ bool CConfig::GetLine(FILE* fp, char*dest)
dest[i] = c; dest[i] = c;
++i; ++i;
} }
return true; return true;
} }
bool CConfig::LoadFile(const char* filename) bool CConfig::LoadFile(const char *filename)
{ {
char szTmp[256]; char szTmp[256];
char comment[256]; char comment[256];
FILE * fp = fopen(filename, "rb"); FILE *fp = fopen(filename, "rb");
if (fp == NULL) if (fp == NULL)
return false; return false;
@ -116,20 +116,20 @@ bool CConfig::LoadFile(const char* filename)
switch (mode) switch (mode)
{ {
case 0: case 0:
strlcpy(comment, szTmp, sizeof(comment)); strlcpy(comment, szTmp, sizeof(comment));
++mode;
break;
case 1:
if (*szTmp == '=')
++mode; ++mode;
break; break;
case 1: case 2:
if (*szTmp == '=') mode = 0;
++mode; m_valueMap.insert(TValueMap::value_type(comment, szTmp));
break; break;
case 2:
mode = 0;
m_valueMap.insert(TValueMap::value_type(comment, szTmp));
break;
} }
// ITEM_ID_RANGE // ITEM_ID_RANGE
@ -137,21 +137,19 @@ bool CConfig::LoadFile(const char* filename)
{ {
GetLine(fp, szTmp); GetLine(fp, szTmp);
m_valueMap.insert(TValueMap::value_type(comment, szTmp)); m_valueMap.insert(TValueMap::value_type(comment, szTmp));
mode = 0; mode = 0;
} }
// ITEM_ID_RANGE_END // ITEM_ID_RANGE_END
} }
// 파일 닫는 부분. // 파일 닫는 부분.
fclose(fp); fclose(fp);
return true; return true;
} }
std::string * CConfig::Search(const char* key) std::string *CConfig::Search(const char *key)
{ {
itertype(m_valueMap) i = m_valueMap.find(key); itertype(m_valueMap) i = m_valueMap.find(key);
if (i == m_valueMap.end()) if (i == m_valueMap.end())
return NULL; return NULL;
@ -159,24 +157,24 @@ std::string * CConfig::Search(const char* key)
return (&i->second); return (&i->second);
} }
bool CConfig::GetParam(const char*key, int index, DWORD *Param) bool CConfig::GetParam(const char *key, int index, DWORD *Param)
{ {
std::string * pstStr = Search(key); std::string *pstStr = Search(key);
if (!pstStr) if (!pstStr)
return false; return false;
char szParam[5][32]; char szParam[5][32];
sscanf(pstStr->c_str(), "%s %s %s %s %s", szParam[0],szParam[1],szParam[2],szParam[3],szParam[4]); sscanf(pstStr->c_str(), "%s %s %s %s %s", szParam[0], szParam[1], szParam[2], szParam[3], szParam[4]);
str_to_number(*Param, szParam[index]); str_to_number(*Param, szParam[index]);
SPDLOG_DEBUG("GetParam {}", *Param); SPDLOG_DEBUG("GetParam {}", *Param);
return true; return true;
} }
const char * CConfig::Get(const char* key) const char *CConfig::Get(const char *key)
{ {
std::string * pstStr = Search(key); std::string *pstStr = Search(key);
if (!pstStr) if (!pstStr)
{ {
@ -187,8 +185,7 @@ const char * CConfig::Get(const char* key)
return pstStr->c_str(); return pstStr->c_str();
} }
bool CConfig::GetValue(const char *key, int *dest)
bool CConfig::GetValue(const char * key, int* dest)
{ {
if (!Search(key)) if (!Search(key))
return false; return false;
@ -197,8 +194,8 @@ bool CConfig::GetValue(const char * key, int* dest)
return true; return true;
} }
bool CConfig::GetValue(const char * key, float *dest) bool CConfig::GetValue(const char *key, float *dest)
{ {
if (!Search(key)) if (!Search(key))
return false; return false;
@ -206,8 +203,8 @@ bool CConfig::GetValue(const char * key, float *dest)
return true; return true;
} }
bool CConfig::GetValue(const char * key, DWORD *dest) bool CConfig::GetValue(const char *key, DWORD *dest)
{ {
if (!Search(key)) if (!Search(key))
return false; return false;
@ -215,17 +212,17 @@ bool CConfig::GetValue(const char * key, DWORD *dest)
return true; return true;
} }
bool CConfig::GetValue(const char * key, BYTE *dest) bool CConfig::GetValue(const char *key, BYTE *dest)
{ {
if (!Search(key)) if (!Search(key))
return false; return false;
*dest = *(BYTE *) Get(key); *dest = *(BYTE *)Get(key);
return true; return true;
} }
bool CConfig::GetValue(const char * key, char *dest, size_t destSize) bool CConfig::GetValue(const char *key, char *dest, size_t destSize)
{ {
if (!Search(key)) if (!Search(key))
return false; return false;
@ -237,7 +234,7 @@ bool CConfig::GetValue(const char * key, char *dest, size_t destSize)
return true; return true;
} }
bool CConfig::GetTwoValue(const char* key, DWORD * dest1, DWORD *dest2) bool CConfig::GetTwoValue(const char *key, DWORD *dest1, DWORD *dest2)
{ {
if (!GetParam(key, 0, dest1)) if (!GetParam(key, 0, dest1))
return false; return false;
@ -247,4 +244,3 @@ bool CConfig::GetTwoValue(const char* key, DWORD * dest1, DWORD *dest2)
return true; return true;
} }

View File

@ -5,30 +5,30 @@ typedef std::map<std::string, std::string> TValueMap;
class CConfig : public singleton<CConfig> class CConfig : public singleton<CConfig>
{ {
public: public:
CConfig(); CConfig();
~CConfig(); ~CConfig();
bool LoadFile(const char* filename); bool LoadFile(const char *filename);
bool GetValue(const char* key, int* dest); bool GetValue(const char *key, int *dest);
bool GetValue(const char* key, float* dest); bool GetValue(const char *key, float *dest);
bool GetValue(const char* key, DWORD* dest); bool GetValue(const char *key, DWORD *dest);
bool GetValue(const char* key, BYTE* dest); bool GetValue(const char *key, BYTE *dest);
bool GetValue(const char* key, char* dest, size_t destSize); bool GetValue(const char *key, char *dest, size_t destSize);
bool GetWord(FILE* fp, char* dest); bool GetWord(FILE *fp, char *dest);
bool GetLine(FILE* fp, char* dest); bool GetLine(FILE *fp, char *dest);
bool GetTwoValue(const char* key, DWORD * dest1, DWORD *dest2); bool GetTwoValue(const char *key, DWORD *dest1, DWORD *dest2);
void NextLine(FILE* fp); void NextLine(FILE *fp);
private: private:
void Destroy(); void Destroy();
bool GetParam(const char*key,int index, DWORD *Param); bool GetParam(const char *key, int index, DWORD *Param);
const char * Get(const char* key); const char *Get(const char *key);
std::string * Search(const char* key); std::string *Search(const char *key);
private: private:
TValueMap m_valueMap; TValueMap m_valueMap;
}; };
#endif #endif

View File

@ -4,9 +4,9 @@
#include <algorithm> #include <algorithm>
#ifndef Assert #ifndef Assert
#include <assert.h> #include <assert.h>
#define Assert assert #define Assert assert
#define LogToFile (void)(0); #define LogToFile (void)(0);
#endif #endif
namespace namespace
@ -39,7 +39,7 @@ namespace
/// \param name 셀 이름 /// \param name 셀 이름
/// \param index 셀 인덱스 /// \param index 셀 인덱스
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
void cCsvAlias::AddAlias(const char* name, size_t index) void cCsvAlias::AddAlias(const char *name, size_t index)
{ {
std::string converted(Lower(name)); std::string converted(Lower(name));
@ -64,7 +64,7 @@ void cCsvAlias::Destroy()
/// \param index 숫자 인덱스 /// \param index 숫자 인덱스
/// \return const char* 이름 /// \return const char* 이름
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
const char* cCsvAlias::operator [] (size_t index) const const char *cCsvAlias::operator[](size_t index) const
{ {
INDEX2NAME_MAP::const_iterator itr(m_Index2Name.find(index)); INDEX2NAME_MAP::const_iterator itr(m_Index2Name.find(index));
if (itr == m_Index2Name.end()) if (itr == m_Index2Name.end())
@ -82,7 +82,7 @@ const char* cCsvAlias::operator [] (size_t index) const
/// \param name 이름 /// \param name 이름
/// \return size_t 숫자 인덱스 /// \return size_t 숫자 인덱스
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
size_t cCsvAlias::operator [] (const char* name) const size_t cCsvAlias::operator[](const char *name) const
{ {
NAME2INDEX_MAP::const_iterator itr(m_Name2Index.find(Lower(name))); NAME2INDEX_MAP::const_iterator itr(m_Name2Index.find(Lower(name)));
if (itr == m_Name2Index.end()) if (itr == m_Name2Index.end())
@ -102,29 +102,33 @@ size_t cCsvAlias::operator [] (const char* name) const
/// \param quote 따옴표로 사용할 글자. 기본값은 '"'이다. /// \param quote 따옴표로 사용할 글자. 기본값은 '"'이다.
/// \return bool 무사히 로드했다면 true, 아니라면 false /// \return bool 무사히 로드했다면 true, 아니라면 false
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
bool cCsvFile::Load(const char* fileName, const char seperator, const char quote) bool cCsvFile::Load(const char *fileName, const char seperator, const char quote)
{ {
Assert(seperator != quote); Assert(seperator != quote);
std::ifstream file(fileName, std::ios::in); std::ifstream file(fileName, std::ios::in);
if (!file) return false; if (!file)
return false;
Destroy(); // 기존의 데이터를 삭제 Destroy(); // 기존의 데이터를 삭제
cCsvRow* row = NULL; cCsvRow *row = NULL;
ParseState state = STATE_NORMAL; ParseState state = STATE_NORMAL;
std::string token = ""; std::string token = "";
char buf[2048+1] = {0,}; char buf[2048 + 1] = {
0,
};
while (file.good()) while (file.good())
{ {
file.getline(buf, 2048); file.getline(buf, 2048);
buf[sizeof(buf)-1] = 0; buf[sizeof(buf) - 1] = 0;
std::string line(Trim(buf)); std::string line(Trim(buf));
if (line.empty() || (state == STATE_NORMAL && line[0] == '#')) continue; if (line.empty() || (state == STATE_NORMAL && line[0] == '#'))
continue;
std::string text = std::string(line) + " "; // 파싱 lookahead 때문에 붙여준다.
std::string text = std::string(line) + " "; // 파싱 lookahead 때문에 붙여준다.
size_t cur = 0; size_t cur = 0;
while (cur < text.size()) while (cur < text.size())
@ -135,21 +139,21 @@ bool cCsvFile::Load(const char* fileName, const char seperator, const char quote
// '"' 문자의 종류는 두 가지이다. // '"' 문자의 종류는 두 가지이다.
// 1. 셀 내부에 특수 문자가 있을 경우 이를 알리는 셀 좌우의 것 // 1. 셀 내부에 특수 문자가 있을 경우 이를 알리는 셀 좌우의 것
// 2. 셀 내부의 '"' 문자가 '"' 2개로 치환된 것 // 2. 셀 내부의 '"' 문자가 '"' 2개로 치환된 것
// 이 중 첫번째 경우의 좌측에 있는 것은 CSV 파일이 정상적이라면, // 이 중 첫번째 경우의 좌측에 있는 것은 CSV 파일이 정상적이라면,
// 무조건 STATE_NORMAL에 걸리게 되어있다. // 무조건 STATE_NORMAL에 걸리게 되어있다.
// 그러므로 여기서 걸리는 것은 1번의 우측 경우나, 2번 경우 뿐이다. // 그러므로 여기서 걸리는 것은 1번의 우측 경우나, 2번 경우 뿐이다.
// 2번의 경우에는 무조건 '"' 문자가 2개씩 나타난다. 하지만 1번의 // 2번의 경우에는 무조건 '"' 문자가 2개씩 나타난다. 하지만 1번의
// 우측 경우에는 아니다. 이를 바탕으로 해서 코드를 짜면... // 우측 경우에는 아니다. 이를 바탕으로 해서 코드를 짜면...
if (text[cur] == quote) if (text[cur] == quote)
{ {
// 다음 문자가 '"' 문자라면, 즉 연속된 '"' 문자라면 // 다음 문자가 '"' 문자라면, 즉 연속된 '"' 문자라면
// 이는 셀 내부의 '"' 문자가 치환된 것이다. // 이는 셀 내부의 '"' 문자가 치환된 것이다.
if (text[cur+1] == quote) if (text[cur + 1] == quote)
{ {
token += quote; token += quote;
++cur; ++cur;
} }
// 다음 문자가 '"' 문자가 아니라면 // 다음 문자가 '"' 문자가 아니라면
// 현재의 '"'문자는 셀의 끝을 알리는 문자라고 할 수 있다. // 현재의 '"'문자는 셀의 끝을 알리는 문자라고 할 수 있다.
else else
{ {
@ -194,14 +198,14 @@ bool cCsvFile::Load(const char* fileName, const char seperator, const char quote
if (state == STATE_NORMAL) if (state == STATE_NORMAL)
{ {
Assert(row != NULL); Assert(row != NULL);
row->push_back(token.substr(0, token.size()-2)); row->push_back(token.substr(0, token.size() - 2));
m_Rows.push_back(row); m_Rows.push_back(row);
token.clear(); token.clear();
row = NULL; row = NULL;
} }
else else
{ {
token = token.substr(0, token.size()-2) + "\r\n"; token = token.substr(0, token.size() - 2) + "\r\n";
} }
} }
@ -211,40 +215,47 @@ bool cCsvFile::Load(const char* fileName, const char seperator, const char quote
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
/// \brief 가지고 있는 내용을 CSV 파일에다 저장한다. /// \brief 가지고 있는 내용을 CSV 파일에다 저장한다.
/// \param fileName CSV 파일 이름 /// \param fileName CSV 파일 이름
/// \param append true일 경우, 기존의 파일에다 덧붙인다. false인 경우에는 /// \param append true일 경우, 기존의 파일에다 덧붙인다. false인 경우에는
/// 기존의 파일 내용을 삭제하고, 새로 쓴다. /// 기존의 파일 내용을 삭제하고, 새로 쓴다.
/// \param seperator 필드 분리자로 사용할 글자. 기본값은 ','이다. /// \param seperator 필드 분리자로 사용할 글자. 기본값은 ','이다.
/// \param quote 따옴표로 사용할 글자. 기본값은 '"'이다. /// \param quote 따옴표로 사용할 글자. 기본값은 '"'이다.
/// \return bool 무사히 저장했다면 true, 에러가 생긴 경우에는 false /// \return bool 무사히 저장했다면 true, 에러가 생긴 경우에는 false
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
bool cCsvFile::Save(const char* fileName, bool append, char seperator, char quote) const bool cCsvFile::Save(const char *fileName, bool append, char seperator, char quote) const
{ {
Assert(seperator != quote); Assert(seperator != quote);
// 출력 모드에 따라 파일을 적당한 플래그로 생성한다. // 출력 모드에 따라 파일을 적당한 플래그로 생성한다.
std::ofstream file; std::ofstream file;
if (append) { file.open(fileName, std::ios::out | std::ios::app); } if (append)
else { file.open(fileName, std::ios::out | std::ios::trunc); } {
file.open(fileName, std::ios::out | std::ios::app);
}
else
{
file.open(fileName, std::ios::out | std::ios::trunc);
}
// 파일을 열지 못했다면, false를 리턴한다. // 파일을 열지 못했다면, false를 리턴한다.
if (!file) return false; if (!file)
return false;
char special_chars[5] = { seperator, quote, '\r', '\n', 0 }; char special_chars[5] = {seperator, quote, '\r', '\n', 0};
char quote_escape_string[3] = { quote, quote, 0 }; char quote_escape_string[3] = {quote, quote, 0};
// 모든 행을 횡단하면서... // 모든 행을 횡단하면서...
for (size_t i=0; i<m_Rows.size(); i++) for (size_t i = 0; i < m_Rows.size(); i++)
{ {
const cCsvRow& row = *((*this)[i]); const cCsvRow &row = *((*this)[i]);
std::string line; std::string line;
// 행 안의 모든 토큰을 횡단하면서... // 행 안의 모든 토큰을 횡단하면서...
for (size_t j=0; j<row.size(); j++) for (size_t j = 0; j < row.size(); j++)
{ {
const std::string& token = row[j]; const std::string &token = row[j];
// 일반적인('"' 또는 ','를 포함하지 않은) // 일반적인('"' 또는 ','를 포함하지 않은)
// 토큰이라면 그냥 저장하면 된다. // 토큰이라면 그냥 저장하면 된다.
if (token.find_first_of(special_chars) == std::string::npos) if (token.find_first_of(special_chars) == std::string::npos)
{ {
@ -256,17 +267,22 @@ bool cCsvFile::Save(const char* fileName, bool append, char seperator, char quot
{ {
line += quote; line += quote;
for (size_t k=0; k<token.size(); k++) for (size_t k = 0; k < token.size(); k++)
{ {
if (token[k] == quote) line += quote_escape_string; if (token[k] == quote)
else line += token[k]; line += quote_escape_string;
else
line += token[k];
} }
line += quote; line += quote;
} }
// 마지막 셀이 아니라면 ','를 토큰의 뒤에다 붙여줘야한다. // 마지막 셀이 아니라면 ','를 토큰의 뒤에다 붙여줘야한다.
if (j != row.size() - 1) { line += seperator; } if (j != row.size() - 1)
{
line += seperator;
}
} }
// 라인을 출력한다. // 라인을 출력한다.
@ -292,7 +308,7 @@ void cCsvFile::Destroy()
/// \param index 인덱스 /// \param index 인덱스
/// \return cCsvRow* 해당 행 /// \return cCsvRow* 해당 행
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
cCsvRow* cCsvFile::operator [] (size_t index) cCsvRow *cCsvFile::operator[](size_t index)
{ {
Assert(index < m_Rows.size()); Assert(index < m_Rows.size());
return m_Rows[index]; return m_Rows[index];
@ -303,7 +319,7 @@ cCsvRow* cCsvFile::operator [] (size_t index)
/// \param index 인덱스 /// \param index 인덱스
/// \return const cCsvRow* 해당 행 /// \return const cCsvRow* 해당 행
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
const cCsvRow* cCsvFile::operator [] (size_t index) const const cCsvRow *cCsvFile::operator[](size_t index) const
{ {
Assert(index < m_Rows.size()); Assert(index < m_Rows.size());
return m_Rows[index]; return m_Rows[index];
@ -313,7 +329,7 @@ const cCsvRow* cCsvFile::operator [] (size_t index) const
/// \brief 생성자 /// \brief 생성자
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
cCsvTable::cCsvTable() cCsvTable::cCsvTable()
: m_CurRow(-1) : m_CurRow(-1)
{ {
} }
@ -331,7 +347,7 @@ cCsvTable::~cCsvTable()
/// \param quote 따옴표로 사용할 글자. 기본값은 '"'이다. /// \param quote 따옴표로 사용할 글자. 기본값은 '"'이다.
/// \return bool 무사히 로드했다면 true, 아니라면 false /// \return bool 무사히 로드했다면 true, 아니라면 false
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
bool cCsvTable::Load(const char* fileName, const char seperator, const char quote) bool cCsvTable::Load(const char *fileName, const char seperator, const char quote)
{ {
Destroy(); Destroy();
return m_File.Load(fileName, seperator, quote); return m_File.Load(fileName, seperator, quote);
@ -364,7 +380,7 @@ size_t cCsvTable::ColCount() const
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
int cCsvTable::AsInt(size_t index) const int cCsvTable::AsInt(size_t index) const
{ {
const cCsvRow* const row = CurRow(); const cCsvRow *const row = CurRow();
Assert(row); Assert(row);
Assert(index < row->size()); Assert(index < row->size());
return row->AsInt(index); return row->AsInt(index);
@ -377,7 +393,7 @@ int cCsvTable::AsInt(size_t index) const
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
double cCsvTable::AsDouble(size_t index) const double cCsvTable::AsDouble(size_t index) const
{ {
const cCsvRow* const row = CurRow(); const cCsvRow *const row = CurRow();
Assert(row); Assert(row);
Assert(index < row->size()); Assert(index < row->size());
return row->AsDouble(index); return row->AsDouble(index);
@ -388,9 +404,9 @@ double cCsvTable::AsDouble(size_t index) const
/// \param index 셀 인덱스 /// \param index 셀 인덱스
/// \return const char* 셀 값 /// \return const char* 셀 값
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
const char* cCsvTable::AsStringByIndex(size_t index) const const char *cCsvTable::AsStringByIndex(size_t index) const
{ {
const cCsvRow* const row = CurRow(); const cCsvRow *const row = CurRow();
Assert(row); Assert(row);
Assert(index < row->size()); Assert(index < row->size());
return row->AsString(index); return row->AsString(index);
@ -409,10 +425,10 @@ void cCsvTable::Destroy()
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
/// \brief 현재 행을 반환한다. /// \brief 현재 행을 반환한다.
/// \return const cCsvRow* 액세스가 가능한 현재 행이 존재하는 경우에는 그 행의 /// \return const cCsvRow* 액세스가 가능한 현재 행이 존재하는 경우에는 그 행의
/// 포인터를 반환하고, 더 이상 액세스 가능한 행이 없는 경우에는 NULL을 /// 포인터를 반환하고, 더 이상 액세스 가능한 행이 없는 경우에는 NULL을
/// 반환한다. /// 반환한다.
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
const cCsvRow* const cCsvTable::CurRow() const const cCsvRow *const cCsvTable::CurRow() const
{ {
if (m_CurRow < 0) if (m_CurRow < 0)
{ {
@ -427,4 +443,3 @@ const cCsvRow* const cCsvTable::CurRow() const
return m_File[m_CurRow]; return m_File[m_CurRow];
} }

View File

@ -5,17 +5,17 @@
#include <vector> #include <vector>
#if _MSC_VER #if _MSC_VER
#include <hash_map> #include <hash_map>
#else #else
#include <map> #include <map>
#endif #endif
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
/// \class cCsvAlias /// \class cCsvAlias
/// \brief CSV 파일을 수정했을 때 발생하는 인덱스 문제를 줄이기 위한 /// \brief CSV 파일을 수정했을 때 발생하는 인덱스 문제를 줄이기 위한
/// 별명 객체. /// 별명 객체.
/// ///
/// 예를 들어 0번 컬럼이 A에 관한 내용을 포함하고, 1번 컬럼이 B에 관한 내용을 /// 예를 들어 0번 컬럼이 A에 관한 내용을 포함하고, 1번 컬럼이 B에 관한 내용을
/// 포함하고 있었는데... /// 포함하고 있었는데...
/// ///
/// <pre> /// <pre>
@ -23,16 +23,16 @@
/// int b = row.AsInt(1); /// int b = row.AsInt(1);
/// </pre> /// </pre>
/// ///
/// 그 사이에 C에 관한 내용을 포함하는 컬럼이 끼어든 경우, 하드코딩되어 있는 /// 그 사이에 C에 관한 내용을 포함하는 컬럼이 끼어든 경우, 하드코딩되어 있는
/// 1번을 찾아서 고쳐야 하는데, 상당히 에러가 발생하기 쉬운 작업이다. /// 1번을 찾아서 고쳐야 하는데, 상당히 에러가 발생하기 쉬운 작업이다.
/// ///
/// <pre> /// <pre>
/// int a = row.AsInt(0); /// int a = row.AsInt(0);
/// int c = row.AsInt(1); /// int c = row.AsInt(1);
/// int b = row.AsInt(2); <-- 이 부분을 일일이 신경써야 한다. /// int b = row.AsInt(2); <-- 이 부분을 일일이 신경써야 한다.
/// </pre> /// </pre>
/// ///
/// 이 부분을 문자열로 처리하면 유지보수에 들어가는 수고를 약간이나마 줄일 수 /// 이 부분을 문자열로 처리하면 유지보수에 들어가는 수고를 약간이나마 줄일 수
/// 있다. /// 있다.
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
@ -47,49 +47,45 @@ private:
typedef std::map<size_t, std::string> INDEX2NAME_MAP; typedef std::map<size_t, std::string> INDEX2NAME_MAP;
#endif #endif
NAME2INDEX_MAP m_Name2Index; ///< 셀 인덱스 대신으로 사용하기 위한 이름들 NAME2INDEX_MAP m_Name2Index; ///< 셀 인덱스 대신으로 사용하기 위한 이름들
INDEX2NAME_MAP m_Index2Name; ///< 잘못된 alias를 검사하기 위한 추가적인 맵 INDEX2NAME_MAP m_Index2Name; ///< 잘못된 alias를 검사하기 위한 추가적인 맵
public: public:
/// \brief 생성자 /// \brief 생성자
cCsvAlias() {} cCsvAlias() {}
/// \brief 소멸자 /// \brief 소멸자
virtual ~cCsvAlias() {} virtual ~cCsvAlias() {}
public: public:
/// \brief 셀을 액세스할 때, 숫자 대신 사용할 이름을 등록한다. /// \brief 셀을 액세스할 때, 숫자 대신 사용할 이름을 등록한다.
void AddAlias(const char* name, size_t index); void AddAlias(const char *name, size_t index);
/// \brief 모든 데이터를 삭제한다. /// \brief 모든 데이터를 삭제한다.
void Destroy(); void Destroy();
/// \brief 숫자 인덱스를 이름으로 변환한다. /// \brief 숫자 인덱스를 이름으로 변환한다.
const char* operator [] (size_t index) const; const char *operator[](size_t index) const;
/// \brief 이름을 숫자 인덱스로 변환한다. /// \brief 이름을 숫자 인덱스로 변환한다.
size_t operator [] (const char* name) const; size_t operator[](const char *name) const;
private: private:
/// \brief 복사 생성자 금지 /// \brief 복사 생성자 금지
cCsvAlias(const cCsvAlias&) {} cCsvAlias(const cCsvAlias &) {}
/// \brief 대입 연산자 금지 /// \brief 대입 연산자 금지
const cCsvAlias& operator = (const cCsvAlias&) { return *this; } const cCsvAlias &operator=(const cCsvAlias &) { return *this; }
}; };
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
/// \class cCsvRow /// \class cCsvRow
/// \brief CSV 파일의 한 행을 캡슐화한 클래스 /// \brief CSV 파일의 한 행을 캡슐화한 클래스
/// ///
/// CSV의 기본 포맷은 엑셀에서 보이는 하나의 셀을 ',' 문자로 구분한 것이다. /// CSV의 기본 포맷은 엑셀에서 보이는 하나의 셀을 ',' 문자로 구분한 것이다.
/// 하지만, 셀 안에 특수 문자로 쓰이는 ',' 문자나 '"' 문자가 들어갈 경우, /// 하지만, 셀 안에 특수 문자로 쓰이는 ',' 문자나 '"' 문자가 들어갈 경우,
/// 모양이 약간 이상하게 변한다. 다음은 그 변화의 예이다. /// 모양이 약간 이상하게 변한다. 다음은 그 변화의 예이다.
/// ///
/// <pre> /// <pre>
/// 엑셀에서 보이는 모양 | 실제 CSV 파일에 들어가있는 모양 /// 엑셀에서 보이는 모양 | 실제 CSV 파일에 들어가있는 모양
/// ---------------------+---------------------------------------------------- /// ---------------------+----------------------------------------------------
@ -100,7 +96,7 @@ private:
/// "Item,Price" | """Item,Price""" /// "Item,Price" | """Item,Price"""
/// Item",Price | "Item"",Price" /// Item",Price | "Item"",Price"
/// </pre> /// </pre>
/// ///
/// 이 예로서 다음과 같은 사항을 알 수 있다. /// 이 예로서 다음과 같은 사항을 알 수 있다.
/// - 셀 내부에 ',' 또는 '"' 문자가 들어갈 경우, 셀 좌우에 '"' 문자가 생긴다. /// - 셀 내부에 ',' 또는 '"' 문자가 들어갈 경우, 셀 좌우에 '"' 문자가 생긴다.
/// - 셀 내부의 '"' 문자는 2개로 치환된다. /// - 셀 내부의 '"' 문자는 2개로 치환된다.
@ -117,7 +113,6 @@ public:
/// \brief 소멸자 /// \brief 소멸자
~cCsvRow() {} ~cCsvRow() {}
public: public:
/// \brief 해당 셀의 데이터를 int 형으로 반환한다. /// \brief 해당 셀의 데이터를 int 형으로 반환한다.
int AsInt(size_t index) const { return atoi(at(index).c_str()); } int AsInt(size_t index) const { return atoi(at(index).c_str()); }
@ -126,33 +121,34 @@ public:
double AsDouble(size_t index) const { return atof(at(index).c_str()); } double AsDouble(size_t index) const { return atof(at(index).c_str()); }
/// \brief 해당 셀의 데이터를 문자열로 반환한다. /// \brief 해당 셀의 데이터를 문자열로 반환한다.
const char* AsString(size_t index) const { return at(index).c_str(); } const char *AsString(size_t index) const { return at(index).c_str(); }
/// \brief 해당하는 이름의 셀 데이터를 int 형으로 반환한다. /// \brief 해당하는 이름의 셀 데이터를 int 형으로 반환한다.
int AsInt(const char* name, const cCsvAlias& alias) const { int AsInt(const char *name, const cCsvAlias &alias) const
return atoi( at(alias[name]).c_str() ); {
return atoi(at(alias[name]).c_str());
} }
/// \brief 해당하는 이름의 셀 데이터를 int 형으로 반환한다. /// \brief 해당하는 이름의 셀 데이터를 int 형으로 반환한다.
double AsDouble(const char* name, const cCsvAlias& alias) const { double AsDouble(const char *name, const cCsvAlias &alias) const
return atof( at(alias[name]).c_str() ); {
return atof(at(alias[name]).c_str());
} }
/// \brief 해당하는 이름의 셀 데이터를 문자열로 반환한다. /// \brief 해당하는 이름의 셀 데이터를 문자열로 반환한다.
const char* AsString(const char* name, const cCsvAlias& alias) const { const char *AsString(const char *name, const cCsvAlias &alias) const
return at(alias[name]).c_str(); {
return at(alias[name]).c_str();
} }
private: private:
/// \brief 복사 생성자 금지 /// \brief 복사 생성자 금지
cCsvRow(const cCsvRow&) {} cCsvRow(const cCsvRow &) {}
/// \brief 대입 연산자 금지 /// \brief 대입 연산자 금지
const cCsvRow& operator = (const cCsvRow&) { return *this; } const cCsvRow &operator=(const cCsvRow &) { return *this; }
}; };
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
/// \class cCsvFile /// \class cCsvFile
/// \brief CSV(Comma Seperated Values) 파일을 read/write하기 위한 클래스 /// \brief CSV(Comma Seperated Values) 파일을 read/write하기 위한 클래스
@ -179,18 +175,17 @@ private:
/// file.save("test.csv", false); /// file.save("test.csv", false);
/// </pre> /// </pre>
/// ///
/// \todo 파일에서만 읽어들일 것이 아니라, 메모리 소스로부터 읽는 함수도 /// \todo 파일에서만 읽어들일 것이 아니라, 메모리 소스로부터 읽는 함수도
/// 있어야 할 듯 하다. /// 있어야 할 듯 하다.
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
class cCsvFile class cCsvFile
{ {
private: private:
typedef std::vector<cCsvRow*> ROWS; typedef std::vector<cCsvRow *> ROWS;
ROWS m_Rows; ///< 행 컬렉션 ROWS m_Rows; ///< 행 컬렉션
public: public:
/// \brief 생성자 /// \brief 생성자
cCsvFile() {} cCsvFile() {}
@ -198,44 +193,41 @@ public:
/// \brief 소멸자 /// \brief 소멸자
virtual ~cCsvFile() { Destroy(); } virtual ~cCsvFile() { Destroy(); }
public: public:
/// \brief 지정된 이름의 CSV 파일을 로드한다. /// \brief 지정된 이름의 CSV 파일을 로드한다.
bool Load(const char* fileName, const char seperator=',', const char quote='"'); bool Load(const char *fileName, const char seperator = ',', const char quote = '"');
/// \brief 가지고 있는 내용을 CSV 파일에다 저장한다. /// \brief 가지고 있는 내용을 CSV 파일에다 저장한다.
bool Save(const char* fileName, bool append=false, char seperator=',', char quote='"') const; bool Save(const char *fileName, bool append = false, char seperator = ',', char quote = '"') const;
/// \brief 모든 데이터를 메모리에서 삭제한다. /// \brief 모든 데이터를 메모리에서 삭제한다.
void Destroy(); void Destroy();
/// \brief 해당하는 인덱스의 행을 반환한다. /// \brief 해당하는 인덱스의 행을 반환한다.
cCsvRow* operator [] (size_t index); cCsvRow *operator[](size_t index);
/// \brief 해당하는 인덱스의 행을 반환한다. /// \brief 해당하는 인덱스의 행을 반환한다.
const cCsvRow* operator [] (size_t index) const; const cCsvRow *operator[](size_t index) const;
/// \brief 행의 갯수를 반환한다. /// \brief 행의 갯수를 반환한다.
size_t GetRowCount() const { return m_Rows.size(); } size_t GetRowCount() const { return m_Rows.size(); }
private: private:
/// \brief 복사 생성자 금지 /// \brief 복사 생성자 금지
cCsvFile(const cCsvFile&) {} cCsvFile(const cCsvFile &) {}
/// \brief 대입 연산자 금지 /// \brief 대입 연산자 금지
const cCsvFile& operator = (const cCsvFile&) { return *this; } const cCsvFile &operator=(const cCsvFile &) { return *this; }
}; };
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
/// \class cCsvTable /// \class cCsvTable
/// \brief CSV 파일을 이용해 테이블 데이터를 로드하는 경우가 많은데, 이 클래스는 /// \brief CSV 파일을 이용해 테이블 데이터를 로드하는 경우가 많은데, 이 클래스는
/// 그 작업을 좀 더 쉽게 하기 위해 만든 유틸리티 클래스다. /// 그 작업을 좀 더 쉽게 하기 위해 만든 유틸리티 클래스다.
/// ///
/// CSV 파일을 로드하는 경우, 숫자를 이용해 셀을 액세스해야 하는데, CSV /// CSV 파일을 로드하는 경우, 숫자를 이용해 셀을 액세스해야 하는데, CSV
/// 파일의 포맷이 바뀌는 경우, 이 숫자들을 변경해줘야한다. 이 작업이 꽤 /// 파일의 포맷이 바뀌는 경우, 이 숫자들을 변경해줘야한다. 이 작업이 꽤
/// 신경 집중을 요구하는 데다가, 에러가 발생하기 쉽다. 그러므로 숫자로 /// 신경 집중을 요구하는 데다가, 에러가 발생하기 쉽다. 그러므로 숫자로
/// 액세스하기보다는 문자열로 액세스하는 것이 약간 느리지만 낫다고 할 수 있다. /// 액세스하기보다는 문자열로 액세스하는 것이 약간 느리지만 낫다고 할 수 있다.
/// ///
/// <b>sample</b> /// <b>sample</b>
@ -250,7 +242,7 @@ private:
/// while (table.next()) /// while (table.next())
/// { /// {
/// std::string item_class = table.AsString("ItemClass"); /// std::string item_class = table.AsString("ItemClass");
/// int item_type = table.AsInt("ItemType"); /// int item_type = table.AsInt("ItemType");
/// } /// }
/// } /// }
/// </pre> /// </pre>
@ -258,12 +250,11 @@ private:
class cCsvTable class cCsvTable
{ {
public : public:
cCsvFile m_File; ///< CSV 파일 객체 cCsvFile m_File; ///< CSV 파일 객체
private: private:
cCsvAlias m_Alias; ///< 문자열을 셀 인덱스로 변환하기 위한 객체 cCsvAlias m_Alias; ///< 문자열을 셀 인덱스로 변환하기 위한 객체
int m_CurRow; ///< 현재 횡단 중인 행 번호 int m_CurRow; ///< 현재 횡단 중인 행 번호
public: public:
/// \brief 생성자 /// \brief 생성자
@ -272,13 +263,12 @@ public:
/// \brief 소멸자 /// \brief 소멸자
virtual ~cCsvTable(); virtual ~cCsvTable();
public: public:
/// \brief 지정된 이름의 CSV 파일을 로드한다. /// \brief 지정된 이름의 CSV 파일을 로드한다.
bool Load(const char* fileName, const char seperator=',', const char quote='"'); bool Load(const char *fileName, const char seperator = ',', const char quote = '"');
/// \brief 셀을 액세스할 때, 숫자 대신 사용할 이름을 등록한다. /// \brief 셀을 액세스할 때, 숫자 대신 사용할 이름을 등록한다.
void AddAlias(const char* name, size_t index) { m_Alias.AddAlias(name, index); } void AddAlias(const char *name, size_t index) { m_Alias.AddAlias(name, index); }
/// \brief 다음 행으로 넘어간다. /// \brief 다음 행으로 넘어간다.
bool Next(); bool Next();
@ -293,30 +283,29 @@ public:
double AsDouble(size_t index) const; double AsDouble(size_t index) const;
/// \brief 인덱스를 이용해 std::string 형으로 셀값을 반환한다. /// \brief 인덱스를 이용해 std::string 형으로 셀값을 반환한다.
const char* AsStringByIndex(size_t index) const; const char *AsStringByIndex(size_t index) const;
/// \brief 셀 이름을 이용해 int 형으로 셀값을 반환한다. /// \brief 셀 이름을 이용해 int 형으로 셀값을 반환한다.
int AsInt(const char* name) const { return AsInt(m_Alias[name]); } int AsInt(const char *name) const { return AsInt(m_Alias[name]); }
/// \brief 셀 이름을 이용해 double 형으로 셀값을 반환한다. /// \brief 셀 이름을 이용해 double 형으로 셀값을 반환한다.
double AsDouble(const char* name) const { return AsDouble(m_Alias[name]); } double AsDouble(const char *name) const { return AsDouble(m_Alias[name]); }
/// \brief 셀 이름을 이용해 std::string 형으로 셀값을 반환한다. /// \brief 셀 이름을 이용해 std::string 형으로 셀값을 반환한다.
const char* AsString(const char* name) const { return AsStringByIndex(m_Alias[name]); } const char *AsString(const char *name) const { return AsStringByIndex(m_Alias[name]); }
/// \brief alias를 포함해 모든 데이터를 삭제한다. /// \brief alias를 포함해 모든 데이터를 삭제한다.
void Destroy(); void Destroy();
private: private:
/// \brief 현재 행을 반환한다. /// \brief 현재 행을 반환한다.
const cCsvRow* const CurRow() const; const cCsvRow *const CurRow() const;
/// \brief 복사 생성자 금지 /// \brief 복사 생성자 금지
cCsvTable(const cCsvTable&) {} cCsvTable(const cCsvTable &) {}
/// \brief 대입 연산자 금지 /// \brief 대입 연산자 금지
const cCsvTable& operator = (const cCsvTable&) { return *this; } const cCsvTable &operator=(const cCsvTable &) { return *this; }
}; };
#endif //__CSVFILE_H__ #endif //__CSVFILE_H__

View File

@ -6,183 +6,206 @@ extern std::string g_stLocale;
CDBManager::CDBManager() CDBManager::CDBManager()
{ {
Initialize(); StartWorkerThread();
} }
CDBManager::~CDBManager() CDBManager::~CDBManager()
{ {
Destroy(); Quit();
} }
void CDBManager::Initialize() int CDBManager::Connect(const char *db_address, int db_port, const char *db_name, const char *user, const char *pwd)
{ {
for (int i = 0; i < SQL_MAX_NUM; ++i) if (!db_address || !db_name || !user || !pwd)
return false;
try
{ {
m_mainSQL[i] = NULL; m_connPool = std::make_shared<PgConnectionPool>(
m_directSQL[i] = NULL; db_address, db_port, db_name, user, pwd,
m_asyncSQL[i] = NULL; 10, // poolSize
} 60 // idleTimeoutSeconds
} );
void CDBManager::Destroy() // Optionally, do a test connection:
{ {
Clear(); auto conn = m_connPool->acquire();
if (!conn || !conn->is_open())
{
SPDLOG_ERROR("Failed to open test connection to DB");
m_connPool.reset();
return false;
}
}
SPDLOG_INFO("Connected to PostgreSQL at {}:{}, DB: {}", db_address, db_port, db_name);
return true;
}
catch (const std::exception &ex)
{
SPDLOG_ERROR("Exception while connecting to DB: {}", ex.what());
return false;
}
} }
void CDBManager::Clear() void CDBManager::Clear()
{ {
for (int i = 0; i < SQL_MAX_NUM; ++i) std::lock_guard<std::mutex> lock(m_queueMutex);
{ std::queue<std::shared_ptr<PgAsyncQuery>> empty;
if (m_mainSQL[i]) m_queryQueue.swap(empty);
{
delete m_mainSQL[i];
m_mainSQL[i] = NULL;
}
if (m_directSQL[i])
{
delete m_directSQL[i];
m_directSQL[i] = NULL;
}
if (m_asyncSQL[i])
{
delete m_asyncSQL[i];
m_asyncSQL[i] = NULL;
}
}
Initialize();
} }
void CDBManager::Quit() void CDBManager::Quit()
{ {
for (int i = 0; i < SQL_MAX_NUM; ++i) if (m_quit.exchange(1) == 0)
{ {
if (m_mainSQL[i]) StopWorkerThread();
m_mainSQL[i]->Quit(); if (m_connPool)
{
if (m_asyncSQL[i]) m_connPool.reset();
m_asyncSQL[i]->Quit(); }
if (m_directSQL[i])
m_directSQL[i]->Quit();
} }
} }
SQLMsg * CDBManager::PopResult() std::shared_ptr<PgConnectionPool> CDBManager::GetConnectionPool()
{ {
SQLMsg * p; return m_connPool;
for (int i = 0; i < SQL_MAX_NUM; ++i)
if (m_mainSQL[i] && m_mainSQL[i]->PopResult(&p))
return p;
return NULL;
} }
SQLMsg * CDBManager::PopResult(eSQL_SLOT slot) void CDBManager::AsyncQuery(const std::string &query, const pqxx::params &params)
{ {
SQLMsg * p; auto msg = std::make_shared<PgAsyncQuery>(++m_msgCounter, query, params);
if (m_mainSQL[slot] && m_mainSQL[slot]->PopResult(&p))
return p;
return NULL;
}
int CDBManager::Connect(int iSlot, const char * db_address, const int db_port, const char * db_name, const char * user, const char * pwd)
{
if (db_address == NULL || db_name == NULL)
return false;
if (iSlot < 0 || iSlot >= SQL_MAX_NUM)
return false;
SPDLOG_INFO("CREATING DIRECT_SQL");
m_directSQL[iSlot] = new CAsyncSQL2;
if (!m_directSQL[iSlot]->Setup(db_address, user, pwd, db_name, g_stLocale.c_str(), true, db_port))
{ {
Clear(); std::lock_guard<std::mutex> lock(m_queueMutex);
return false; m_queryQueue.push(msg);
} }
m_queueCondition.notify_one();
}
void CDBManager::AsyncQuery(const std::string &query, const pqxx::params &params, AsyncQueryCallback callback)
{
auto msg = std::make_shared<PgAsyncQuery>(++m_msgCounter, query, params, std::move(callback));
SPDLOG_INFO("CREATING MAIN_SQL");
m_mainSQL[iSlot] = new CAsyncSQL2;
if (!m_mainSQL[iSlot]->Setup(db_address, user, pwd, db_name, g_stLocale.c_str(), false, db_port))
{ {
Clear(); std::lock_guard<std::mutex> lock(m_queueMutex);
return false; m_queryQueue.push(msg);
} }
SPDLOG_INFO("CREATING ASYNC_SQL"); m_queueCondition.notify_one();
m_asyncSQL[iSlot] = new CAsyncSQL2; }
if (!m_asyncSQL[iSlot]->Setup(db_address, user, pwd, db_name, g_stLocale.c_str(), false, db_port))
size_t CDBManager::GetPendingQueryCount() const
{
std::lock_guard<std::mutex> lock(m_queueMutex);
return m_queryQueue.size();
}
size_t CDBManager::GetCompletedQueryCount() const
{
return m_completedQueries.load();
}
void CDBManager::ResetQueryStats()
{
m_completedQueries = 0;
}
void CDBManager::StartWorkerThread()
{
if (!m_workerRunning.exchange(true))
{ {
Clear(); m_workerThread = std::thread(&CDBManager::WorkerLoop, this);
return false;
}
return true;
}
SQLMsg * CDBManager::DirectQuery(const char * c_pszQuery, int iSlot)
{
return m_directSQL[iSlot]->DirectQuery(c_pszQuery);
}
extern CPacketInfo g_query_info;
extern int g_query_count[2];
void CDBManager::ReturnQuery(const char * c_pszQuery, int iType, IDENT dwIdent, void * udata, int iSlot)
{
assert(iSlot < SQL_MAX_NUM);
//SPDLOG_DEBUG("ReturnQuery {}", c_pszQuery);
CQueryInfo * p = new CQueryInfo;
p->iType = iType;
p->dwIdent = dwIdent;
p->pvData = udata;
m_mainSQL[iSlot]->ReturnQuery(c_pszQuery, p);
//g_query_info.Add(iType);
++g_query_count[0];
}
void CDBManager::AsyncQuery(const char * c_pszQuery, int iSlot)
{
assert(iSlot < SQL_MAX_NUM);
m_asyncSQL[iSlot]->AsyncQuery(c_pszQuery);
++g_query_count[1];
}
unsigned int CDBManager::EscapeString(void *to, const void *from, unsigned int length, int iSlot)
{
assert(iSlot < SQL_MAX_NUM);
return mysql_real_escape_string(m_directSQL[iSlot]->GetSQLHandle(), (char *) to, (const char *) from, length);
}
void CDBManager::SetLocale(const char * szLocale)
{
const std::string stLocale(szLocale);
SPDLOG_DEBUG("SetLocale start");
for (int n = 0; n < SQL_MAX_NUM; ++n)
{
m_mainSQL[n]->SetLocale(stLocale);
m_directSQL[n]->SetLocale(stLocale);
m_asyncSQL[n]->SetLocale(stLocale);
}
SPDLOG_DEBUG("End setlocale {}", szLocale);
}
void CDBManager::QueryLocaleSet()
{
for (int n = 0; n < SQL_MAX_NUM; ++n)
{
m_mainSQL[n]->QueryLocaleSet();
m_directSQL[n]->QueryLocaleSet();
m_asyncSQL[n]->QueryLocaleSet();
} }
} }
void CDBManager::StopWorkerThread()
{
if (m_workerRunning.exchange(false))
{
m_queueCondition.notify_all();
if (m_workerThread.joinable())
{
m_workerThread.join();
}
}
}
void CDBManager::WorkerLoop()
{
SPDLOG_INFO("AsyncQuery worker thread started");
while (m_workerRunning)
{
std::shared_ptr<PgAsyncQuery> msg;
{
std::unique_lock<std::mutex> lock(m_queueMutex);
m_queueCondition.wait(lock, [this]
{ return !m_queryQueue.empty() || !m_workerRunning; });
if (!m_workerRunning && m_queryQueue.empty())
{
break;
}
if (!m_queryQueue.empty())
{
msg = m_queryQueue.front();
m_queryQueue.pop();
}
}
if (msg)
{
ProcessQuery(msg);
}
}
SPDLOG_INFO("AsyncQuery worker thread stopped");
}
void CDBManager::ProcessQuery(std::shared_ptr<PgAsyncQuery> msg)
{
pqxx::result result;
std::string error;
try
{
if (!m_connPool)
{
throw std::runtime_error("No database connection available");
}
auto conn = m_connPool->acquire();
if (!conn)
{
throw std::runtime_error("Failed to get connection from pool");
}
pqxx::work txn(*conn);
result = txn.exec_params(msg->query, msg->parameters);
txn.commit();
SPDLOG_TRACE("AsyncQuery completed: {} (ID: {})", msg->query, msg->id);
}
catch (const std::exception &e)
{
SPDLOG_ERROR("AsyncQuery failed: {} (query: {}, ID: {})", e.what(), msg->query, msg->id);
}
if (msg->hasCallback && msg->callback)
{
try
{
msg->callback(result, error);
}
catch (const std::exception &e)
{
SPDLOG_ERROR("AsyncQuery callback threw exception: {}", e.what());
}
}
++m_completedQueries;
}

View File

@ -1,97 +1,49 @@
// vim:ts=8 sw=4
#ifndef __INC_METIN2_DB_DBMANAGER_H__ #ifndef __INC_METIN2_DB_DBMANAGER_H__
#define __INC_METIN2_DB_DBMANAGER_H__ #define __INC_METIN2_DB_DBMANAGER_H__
// 디비 커넥션 클래스의 목적은... 디비에 접속해서 쿼리보내고 결과 받아오는 #include <libsql/include/PgConnectionPool.h>
// 모든 일들을 처리한다. #include <libsql/include/PgAsyncQuery.h>
// 코드 by 꼬붕 후로그래머 아노아~ = _=)b #include <memory>
#include <libsql/include/CAsyncSQL.h>
#define SQL_SAFE_LENGTH(size) (size * 2 + 1)
#define QUERY_SAFE_LENGTH(size) (1024 + SQL_SAFE_LENGTH(size))
class CQueryInfo
{
public:
int iType;
DWORD dwIdent;
void * pvData;
};
enum eSQL_SLOT
{
SQL_PLAYER,
SQL_ACCOUNT,
SQL_COMMON,
SQL_MAX_NUM,
};
class CDBManager : public singleton<CDBManager> class CDBManager : public singleton<CDBManager>
{ {
protected: public:
void Initialize();
void Destroy();
public:
CDBManager(); CDBManager();
virtual ~CDBManager(); virtual ~CDBManager();
void Clear(); int Connect(const char *host, int port, const char *dbname, const char *user, const char *pass);
void Quit(); void Clear();
void Quit();
int Connect(int iSlot, const char * host, int port, const char* dbname, const char* user, const char* pass); std::shared_ptr<PgConnectionPool> GetConnectionPool();
void ReturnQuery(const char * c_pszQuery, int iType, DWORD dwIdent, void * pvData, int iSlot = SQL_PLAYER); // Async Query
void AsyncQuery(const char * c_pszQuery, int iSlot = SQL_PLAYER);
SQLMsg * DirectQuery(const char * c_pszQuery, int iSlot = SQL_PLAYER);
SQLMsg * PopResult(); void AsyncQuery(const std::string &query, const pqxx::params &params = pqxx::params{});
SQLMsg * PopResult(eSQL_SLOT slot ); void AsyncQuery(const std::string &query, const pqxx::params &params, AsyncQueryCallback callback);
unsigned int EscapeString(void * to, const void * from, unsigned int length, int iSlot = SQL_PLAYER); size_t GetPendingQueryCount() const;
size_t GetCompletedQueryCount() const;
void ResetQueryStats();
DWORD CountReturnQuery(int i) { return m_mainSQL[i] ? m_mainSQL[i]->CountQuery() : 0; } private:
DWORD CountReturnResult(int i) { return m_mainSQL[i] ? m_mainSQL[i]->CountResult() : 0; } std::shared_ptr<PgConnectionPool> m_connPool;
DWORD CountReturnQueryFinished(int i) { return m_mainSQL[i] ? m_mainSQL[i]->CountQueryFinished() : 0; } std::atomic<int> m_quit{0};
DWORD CountReturnCopiedQuery(int i) { return m_mainSQL[i] ? m_mainSQL[i]->GetCopiedQueryCount() : 0; }
DWORD CountAsyncQuery(int i) { return m_asyncSQL[i] ? m_asyncSQL[i]->CountQuery() : 0; } // Async Query
DWORD CountAsyncResult(int i) { return m_asyncSQL[i] ? m_asyncSQL[i]->CountResult() : 0; }
DWORD CountAsyncQueryFinished(int i) { return m_asyncSQL[i] ? m_asyncSQL[i]->CountQueryFinished() : 0; }
DWORD CountAsyncCopiedQuery(int i) { return m_asyncSQL[i] ? m_asyncSQL[i]->GetCopiedQueryCount() : 0; }
void ResetCounter() void StartWorkerThread();
{ void StopWorkerThread();
for (int i = 0; i < SQL_MAX_NUM; ++i) void WorkerLoop();
{ void ProcessQuery(std::shared_ptr<PgAsyncQuery> msg);
if (m_mainSQL[i])
{
m_mainSQL[i]->ResetQueryFinished();
m_mainSQL[i]->ResetCopiedQueryCount();
}
if (m_asyncSQL[i]) std::queue<std::shared_ptr<PgAsyncQuery>> m_queryQueue;
{ mutable std::mutex m_queueMutex;
m_asyncSQL[i]->ResetQueryFinished(); std::condition_variable m_queueCondition;
m_asyncSQL[i]->ResetCopiedQueryCount(); std::thread m_workerThread;
} std::atomic<int> m_msgCounter{0};
} std::atomic<size_t> m_completedQueries{0};
} std::atomic<bool> m_workerRunning{false};
private:
CAsyncSQL2 * m_mainSQL[SQL_MAX_NUM];
CAsyncSQL2 * m_directSQL[SQL_MAX_NUM];
CAsyncSQL2 * m_asyncSQL[SQL_MAX_NUM];
int m_quit; // looping flag
//CHARSET
public:
void SetLocale(const char * szLocale );
void QueryLocaleSet();
private:
//END_CHARSET
}; };
#endif #endif

View File

@ -14,15 +14,24 @@ bool isEurope()
{ {
do do
{ {
if (g_stLocale.compare("germany") == 0) break; if (g_stLocale.compare("germany") == 0)
if (g_stLocale.compare("france") == 0) break; break;
if (g_stLocale.compare("italy") == 0) break; if (g_stLocale.compare("france") == 0)
if (g_stLocale.compare("spain") == 0) break; break;
if (g_stLocale.compare("uk") == 0) break; if (g_stLocale.compare("italy") == 0)
if (g_stLocale.compare("turkey") == 0) break; break;
if (g_stLocale.compare("poland") == 0) break; if (g_stLocale.compare("spain") == 0)
if (g_stLocale.compare("portugal") == 0) break; break;
if (g_stLocale.compare("greek") == 0) break; if (g_stLocale.compare("uk") == 0)
break;
if (g_stLocale.compare("turkey") == 0)
break;
if (g_stLocale.compare("poland") == 0)
break;
if (g_stLocale.compare("portugal") == 0)
break;
if (g_stLocale.compare("greek") == 0)
break;
return false; return false;
} while (false); } while (false);
@ -33,10 +42,12 @@ bool isEurope()
DWORD GetGuildWarWaitStartDuration() DWORD GetGuildWarWaitStartDuration()
{ {
// const int GUILD_WAR_WAIT_START_DURATION = 60; // const int GUILD_WAR_WAIT_START_DURATION = 60;
// const int GUILD_WAR_WAIT_START_DURATION = 5; // const int GUILD_WAR_WAIT_START_DURATION = 5;
if (isEurope() == true) return 60; if (isEurope() == true)
else return 5; return 60;
else
return 5;
} }
DWORD GetGuildWarReserveSeconds() DWORD GetGuildWarReserveSeconds()
@ -44,11 +55,13 @@ DWORD GetGuildWarReserveSeconds()
// const int GUILD_WAR_RESERVE_SECONDS = 180; // const int GUILD_WAR_RESERVE_SECONDS = 180;
// const int GUILD_WAR_RESERVE_SECONDS = 10; // const int GUILD_WAR_RESERVE_SECONDS = 10;
if (isEurope() == true) return 180; if (isEurope() == true)
else return 10; return 180;
else
return 10;
} }
namespace namespace
{ {
struct FSendPeerWar struct FSendPeerWar
{ {
@ -65,7 +78,7 @@ namespace
p.dwGuildTo = GID2; p.dwGuildTo = GID2;
} }
void operator() (CPeer* peer) void operator()(CPeer *peer)
{ {
if (peer->GetChannel() == 0) if (peer->GetChannel() == 0)
return; return;
@ -87,7 +100,7 @@ namespace
pck.lBetScore = iBetScore; pck.lBetScore = iBetScore;
} }
void operator() (CPeer* peer) void operator()(CPeer *peer)
{ {
if (peer->GetChannel() == 0) if (peer->GetChannel() == 0)
return; return;
@ -115,7 +128,7 @@ CGuildManager::~CGuildManager()
} }
} }
TGuild & CGuildManager::TouchGuild(DWORD GID) TGuild &CGuildManager::TouchGuild(DWORD GID)
{ {
itertype(m_map_kGuild) it = m_map_kGuild.find(GID); itertype(m_map_kGuild) it = m_map_kGuild.find(GID);
@ -127,7 +140,7 @@ TGuild & CGuildManager::TouchGuild(DWORD GID)
return m_map_kGuild[GID]; return m_map_kGuild[GID];
} }
void CGuildManager::ParseResult(SQLResult * pRes) void CGuildManager::ParseResult(SQLResult *pRes)
{ {
MYSQL_ROW row; MYSQL_ROW row;
@ -135,7 +148,7 @@ void CGuildManager::ParseResult(SQLResult * pRes)
{ {
DWORD GID = strtoul(row[0], NULL, 10); DWORD GID = strtoul(row[0], NULL, 10);
TGuild & r_info = TouchGuild(GID); TGuild &r_info = TouchGuild(GID);
strlcpy(r_info.szName, row[1], sizeof(r_info.szName)); strlcpy(r_info.szName, row[1], sizeof(r_info.szName));
str_to_number(r_info.ladder_point, row[2]); str_to_number(r_info.ladder_point, row[2]);
@ -146,12 +159,12 @@ void CGuildManager::ParseResult(SQLResult * pRes)
str_to_number(r_info.level, row[7]); str_to_number(r_info.level, row[7]);
SPDLOG_DEBUG( SPDLOG_DEBUG(
"GuildWar: {:24} ladder {:<5} win {:<3} draw {:<3} loss {:<3}", "GuildWar: {:24} ladder {:<5} win {:<3} draw {:<3} loss {:<3}",
r_info.szName, r_info.szName,
r_info.ladder_point, r_info.ladder_point,
r_info.win, r_info.win,
r_info.draw, r_info.draw,
r_info.loss); r_info.loss);
} }
} }
@ -214,7 +227,7 @@ int CGuildManager::GetRanking(DWORD dwGID)
return std::clamp(it->second, 0, GUILD_RANK_MAX_NUM); return std::clamp(it->second, 0, GUILD_RANK_MAX_NUM);
} }
void CGuildManager::ResultRanking(MYSQL_RES * pRes) void CGuildManager::ResultRanking(MYSQL_RES *pRes)
{ {
if (!pRes) if (!pRes)
return; return;
@ -228,8 +241,10 @@ void CGuildManager::ResultRanking(MYSQL_RES * pRes)
while ((row = mysql_fetch_row(pRes))) while ((row = mysql_fetch_row(pRes)))
{ {
DWORD dwGID = 0; str_to_number(dwGID, row[0]); DWORD dwGID = 0;
int iLadderPoint = 0; str_to_number(iLadderPoint, row[2]); str_to_number(dwGID, row[0]);
int iLadderPoint = 0;
str_to_number(iLadderPoint, row[2]);
if (iLadderPoint != iLastLadderPoint) if (iLadderPoint != iLastLadderPoint)
++iRank; ++iRank;
@ -263,14 +278,14 @@ void CGuildManager::Update()
while (!m_pqOnWar.empty() && (m_pqOnWar.top().first <= now || (m_pqOnWar.top().second && m_pqOnWar.top().second->bEnd))) while (!m_pqOnWar.empty() && (m_pqOnWar.top().first <= now || (m_pqOnWar.top().second && m_pqOnWar.top().second->bEnd)))
{ {
TGuildWarPQElement * e = m_pqOnWar.top().second; TGuildWarPQElement *e = m_pqOnWar.top().second;
m_pqOnWar.pop(); m_pqOnWar.pop();
if (e) if (e)
{ {
if (!e->bEnd) if (!e->bEnd)
WarEnd(e->GID[0], e->GID[1], false); WarEnd(e->GID[0], e->GID[1], false);
delete e; delete e;
} }
@ -280,7 +295,7 @@ void CGuildManager::Update()
// GUILD_SKILL_COOLTIME_BUG_FIX // GUILD_SKILL_COOLTIME_BUG_FIX
while (!m_pqSkill.empty() && m_pqSkill.top().first <= now) while (!m_pqSkill.empty() && m_pqSkill.top().first <= now)
{ {
const TGuildSkillUsed& s = m_pqSkill.top().second; const TGuildSkillUsed &s = m_pqSkill.top().second;
CClientManager::instance().SendGuildSkillUsable(s.GID, s.dwSkillVnum, true); CClientManager::instance().SendGuildSkillUsable(s.GID, s.dwSkillVnum, true);
m_pqSkill.pop(); m_pqSkill.pop();
} }
@ -288,7 +303,7 @@ void CGuildManager::Update()
while (!m_pqWaitStart.empty() && m_pqWaitStart.top().first <= now) while (!m_pqWaitStart.empty() && m_pqWaitStart.top().first <= now)
{ {
const TGuildWaitStartInfo & ws = m_pqWaitStart.top().second; const TGuildWaitStartInfo &ws = m_pqWaitStart.top().second;
m_pqWaitStart.pop(); m_pqWaitStart.pop();
StartWar(ws.bType, ws.GID[0], ws.GID[1], ws.pkReserve); // insert new element to m_WarMap and m_pqOnWar StartWar(ws.bType, ws.GID[0], ws.GID[1], ws.pkReserve); // insert new element to m_WarMap and m_pqOnWar
@ -301,10 +316,10 @@ void CGuildManager::Update()
TPacketGuildWar p; TPacketGuildWar p;
p.bType = ws.bType; p.bType = ws.bType;
p.bWar = GUILD_WAR_ON_WAR; p.bWar = GUILD_WAR_ON_WAR;
p.dwGuildFrom = ws.GID[0]; p.dwGuildFrom = ws.GID[0];
p.dwGuildTo = ws.GID[1]; p.dwGuildTo = ws.GID[1];
CClientManager::instance().ForwardPacket(HEADER_DG_GUILD_WAR, &p, sizeof(p)); CClientManager::instance().ForwardPacket(HEADER_DG_GUILD_WAR, &p, sizeof(p));
SPDLOG_DEBUG("GuildWar: GUILD sending start of wait start war {} {}", ws.GID[0], ws.GID[1]); SPDLOG_DEBUG("GuildWar: GUILD sending start of wait start war {} {}", ws.GID[0], ws.GID[1]);
@ -313,26 +328,26 @@ void CGuildManager::Update()
#define for_all(cont, it) for (typeof((cont).begin()) it = (cont).begin(); it != (cont).end(); ++it) #define for_all(cont, it) for (typeof((cont).begin()) it = (cont).begin(); it != (cont).end(); ++it)
void CGuildManager::OnSetup(CPeer* peer) void CGuildManager::OnSetup(CPeer *peer)
{ {
for_all(m_WarMap, it_cont) for_all(m_WarMap, it_cont)
for_all(it_cont->second, it) for_all(it_cont->second, it)
{ {
DWORD g1 = it_cont->first; DWORD g1 = it_cont->first;
DWORD g2 = it->first; DWORD g2 = it->first;
TGuildWarPQElement* p = it->second.pElement; TGuildWarPQElement *p = it->second.pElement;
if (!p || p->bEnd) if (!p || p->bEnd)
continue; continue;
FSendPeerWar(p->bType, GUILD_WAR_ON_WAR, g1, g2) (peer); FSendPeerWar(p->bType, GUILD_WAR_ON_WAR, g1, g2)(peer);
FSendGuildWarScore(p->GID[0], p->GID[1], p->iScore[0], p->iBetScore[0]); FSendGuildWarScore(p->GID[0], p->GID[1], p->iScore[0], p->iBetScore[0]);
FSendGuildWarScore(p->GID[1], p->GID[0], p->iScore[1], p->iBetScore[1]); FSendGuildWarScore(p->GID[1], p->GID[0], p->iScore[1], p->iBetScore[1]);
} }
for_all(m_DeclareMap, it) for_all(m_DeclareMap, it)
{ {
FSendPeerWar(it->bType, GUILD_WAR_SEND_DECLARE, it->dwGuildID[0], it->dwGuildID[1]) (peer); FSendPeerWar(it->bType, GUILD_WAR_SEND_DECLARE, it->dwGuildID[0], it->dwGuildID[1])(peer);
} }
for_all(m_map_kWarReserve, it) for_all(m_map_kWarReserve, it)
@ -393,8 +408,8 @@ bool CGuildManager::IsHalfWinLadderPoint(DWORD dwGuildWinner, DWORD dwGuildLoser
itertype(m_mapGuildWarEndTime[GID1]) it = m_mapGuildWarEndTime[GID1].find(GID2); itertype(m_mapGuildWarEndTime[GID1]) it = m_mapGuildWarEndTime[GID1].find(GID2);
if (it != m_mapGuildWarEndTime[GID1].end() && if (it != m_mapGuildWarEndTime[GID1].end() &&
it->second + GUILD_WAR_LADDER_HALF_PENALTY_TIME > CClientManager::instance().GetCurrentTime()) it->second + GUILD_WAR_LADDER_HALF_PENALTY_TIME > CClientManager::instance().GetCurrentTime())
return true; return true;
return false; return false;
@ -480,7 +495,7 @@ void CGuildManager::WarEnd(DWORD GID1, DWORD GID2, bool bForceDraw)
} }
TGuildWarInfo gwi = itWarMap->second; TGuildWarInfo gwi = itWarMap->second;
TGuildWarPQElement * pData = gwi.pElement; TGuildWarPQElement *pData = gwi.pElement;
if (!pData || pData->bEnd) if (!pData || pData->bEnd)
{ {
@ -524,7 +539,7 @@ void CGuildManager::WarEnd(DWORD GID1, DWORD GID2, bool bForceDraw)
// //
// 길드전 정상 종료 // 길드전 정상 종료
// //
void CGuildManager::RecvWarOver(DWORD dwGuildWinner, DWORD dwGuildLoser, bool bDraw, int lWarPrice) void CGuildManager::RecvWarOver(DWORD dwGuildWinner, DWORD dwGuildLoser, bool bDraw, int lWarPrice)
{ {
SPDLOG_DEBUG("GuildWar: RecvWarOver : winner {} vs {} draw? {} war_price {}", dwGuildWinner, dwGuildLoser, bDraw ? 1 : 0, lWarPrice); SPDLOG_DEBUG("GuildWar: RecvWarOver : winner {} vs {} draw? {} war_price {}", dwGuildWinner, dwGuildLoser, bDraw ? 1 : 0, lWarPrice);
@ -540,7 +555,7 @@ void CGuildManager::RecvWarOver(DWORD dwGuildWinner, DWORD dwGuildLoser, bool bD
if (it == m_WarMap[GID1].end()) if (it == m_WarMap[GID1].end())
return; return;
TGuildWarInfo & gw = it->second; TGuildWarInfo &gw = it->second;
// Award // Award
if (bDraw) if (bDraw)
@ -574,14 +589,14 @@ void CGuildManager::RecvWarEnd(DWORD GID1, DWORD GID2)
WarEnd(GID1, GID2, true); // 무조건 비정상 종료 시켜야 한다. WarEnd(GID1, GID2, true); // 무조건 비정상 종료 시켜야 한다.
} }
void CGuildManager::StartWar(BYTE bType, DWORD GID1, DWORD GID2, CGuildWarReserve * pkReserve) void CGuildManager::StartWar(BYTE bType, DWORD GID1, DWORD GID2, CGuildWarReserve *pkReserve)
{ {
SPDLOG_DEBUG("GuildWar: StartWar({},{},{})", bType, GID1, GID2); SPDLOG_DEBUG("GuildWar: StartWar({},{},{})", bType, GID1, GID2);
if (GID1 > GID2) if (GID1 > GID2)
std::swap(GID1, GID2); std::swap(GID1, GID2);
TGuildWarInfo & gw = m_WarMap[GID1][GID2]; // map insert TGuildWarInfo &gw = m_WarMap[GID1][GID2]; // map insert
if (bType == GUILD_WAR_TYPE_FIELD) if (bType == GUILD_WAR_TYPE_FIELD)
gw.tEndTime = CClientManager::instance().GetCurrentTime() + GUILD_WAR_DURATION; gw.tEndTime = CClientManager::instance().GetCurrentTime() + GUILD_WAR_DURATION;
@ -606,7 +621,7 @@ void CGuildManager::UpdateScore(DWORD dwGainGID, DWORD dwOppGID, int iScoreDelta
if (it != m_WarMap[GID1].end()) if (it != m_WarMap[GID1].end())
{ {
TGuildWarPQElement * p = it->second.pElement; TGuildWarPQElement *p = it->second.pElement;
if (!p || p->bEnd) if (!p || p->bEnd)
{ {
@ -635,7 +650,7 @@ void CGuildManager::UpdateScore(DWORD dwGainGID, DWORD dwOppGID, int iScoreDelta
} }
SPDLOG_DEBUG("GuildWar: SendGuildWarScore guild {} wartype {} score_delta {} betscore_delta {} result {}, {}", SPDLOG_DEBUG("GuildWar: SendGuildWarScore guild {} wartype {} score_delta {} betscore_delta {} result {}, {}",
dwGainGID, p->bType, iScoreDelta, iBetScoreDelta, iNewScore, iNewBetScore); dwGainGID, p->bType, iScoreDelta, iBetScoreDelta, iNewScore, iNewBetScore);
CClientManager::instance().for_each_peer(FSendGuildWarScore(dwGainGID, dwOppGID, iNewScore, iNewBetScore)); CClientManager::instance().for_each_peer(FSendGuildWarScore(dwGainGID, dwOppGID, iNewScore, iNewBetScore));
} }
@ -658,7 +673,7 @@ void CGuildManager::RemoveDeclare(DWORD guild_from, DWORD guild_to)
if (it != m_DeclareMap.end()) if (it != m_DeclareMap.end())
m_DeclareMap.erase(it); m_DeclareMap.erase(it);
it = m_DeclareMap.find(TGuildDeclareInfo(0,guild_to, guild_from)); it = m_DeclareMap.find(TGuildDeclareInfo(0, guild_to, guild_from));
if (it != m_DeclareMap.end()) if (it != m_DeclareMap.end())
m_DeclareMap.erase(it); m_DeclareMap.erase(it);
@ -674,14 +689,14 @@ bool CGuildManager::TakeBetPrice(DWORD dwGuildTo, DWORD dwGuildFrom, int lWarPri
if (it_from == m_map_kGuild.end() || it_to == m_map_kGuild.end()) if (it_from == m_map_kGuild.end() || it_to == m_map_kGuild.end())
{ {
SPDLOG_DEBUG("TakeBetPrice: guild not exist {} {}", SPDLOG_DEBUG("TakeBetPrice: guild not exist {} {}",
dwGuildFrom, dwGuildTo); dwGuildFrom, dwGuildTo);
return false; return false;
} }
if (it_from->second.gold < lWarPrice || it_to->second.gold < lWarPrice) if (it_from->second.gold < lWarPrice || it_to->second.gold < lWarPrice)
{ {
SPDLOG_DEBUG("TakeBetPrice: not enough gold {} {} to {} {}", SPDLOG_DEBUG("TakeBetPrice: not enough gold {} {} to {} {}",
dwGuildFrom, it_from->second.gold, dwGuildTo, it_to->second.gold); dwGuildFrom, it_from->second.gold, dwGuildTo, it_to->second.gold);
return false; return false;
} }
@ -693,7 +708,7 @@ bool CGuildManager::TakeBetPrice(DWORD dwGuildTo, DWORD dwGuildFrom, int lWarPri
return true; return true;
} }
bool CGuildManager::WaitStart(TPacketGuildWar * p) bool CGuildManager::WaitStart(TPacketGuildWar *p)
{ {
if (p->lWarPrice > 0) if (p->lWarPrice > 0)
if (!TakeBetPrice(p->dwGuildFrom, p->dwGuildTo, p->lWarPrice)) if (!TakeBetPrice(p->dwGuildFrom, p->dwGuildTo, p->lWarPrice))
@ -705,11 +720,11 @@ bool CGuildManager::WaitStart(TPacketGuildWar * p)
m_pqWaitStart.push(std::make_pair(dwCurTime + GetGuildWarWaitStartDuration(), info)); m_pqWaitStart.push(std::make_pair(dwCurTime + GetGuildWarWaitStartDuration(), info));
SPDLOG_DEBUG( SPDLOG_DEBUG(
"GuildWar: WaitStart g1 {} g2 {} price {} start at {}", "GuildWar: WaitStart g1 {} g2 {} price {} start at {}",
p->dwGuildFrom, p->dwGuildFrom,
p->dwGuildTo, p->dwGuildTo,
p->lWarPrice, p->lWarPrice,
dwCurTime + GetGuildWarWaitStartDuration()); dwCurTime + GetGuildWarWaitStartDuration());
return true; return true;
} }
@ -731,7 +746,7 @@ void CGuildManager::ChangeLadderPoint(DWORD GID, int change)
if (it == m_map_kGuild.end()) if (it == m_map_kGuild.end())
return; return;
TGuild & r = it->second; TGuild &r = it->second;
r.ladder_point += change; r.ladder_point += change;
@ -798,7 +813,7 @@ void CGuildManager::DepositMoney(DWORD dwGuild, INT iGold)
MoneyChange(dwGuild, it->second.gold); MoneyChange(dwGuild, it->second.gold);
} }
void CGuildManager::WithdrawMoney(CPeer* peer, DWORD dwGuild, INT iGold) void CGuildManager::WithdrawMoney(CPeer *peer, DWORD dwGuild, INT iGold)
{ {
itertype(m_map_kGuild) it = m_map_kGuild.find(dwGuild); itertype(m_map_kGuild) it = m_map_kGuild.find(dwGuild);
@ -841,63 +856,62 @@ void CGuildManager::WithdrawMoneyReply(DWORD dwGuild, BYTE bGiveSuccess, INT iGo
// //
// 예약 길드전(관전자가 배팅할 수 있다) // 예약 길드전(관전자가 배팅할 수 있다)
// //
const int c_aiScoreByLevel[GUILD_MAX_LEVEL+1] = const int c_aiScoreByLevel[GUILD_MAX_LEVEL + 1] =
{ {
500, // level 0 = 500 probably error 500, // level 0 = 500 probably error
500, // 1 500, // 1
1000, 1000,
2000, 2000,
3000, 3000,
4000, 4000,
6000, 6000,
8000, 8000,
10000, 10000,
12000, 12000,
15000, // 10 15000, // 10
18000, 18000,
21000, 21000,
24000, 24000,
28000, 28000,
32000, 32000,
36000, 36000,
40000, 40000,
45000, 45000,
50000, 50000,
55000, 55000,
}; };
const int c_aiScoreByRanking[GUILD_RANK_MAX_NUM+1] = const int c_aiScoreByRanking[GUILD_RANK_MAX_NUM + 1] =
{ {
0, 0,
55000, // 1위 55000, // 1위
50000, 50000,
45000, 45000,
40000, 40000,
36000, 36000,
32000, 32000,
28000, 28000,
24000, 24000,
21000, 21000,
18000, // 10위 18000, // 10위
15000, 15000,
12000, 12000,
10000, 10000,
8000, 8000,
6000, 6000,
4000, 4000,
3000, 3000,
2000, 2000,
1000, 1000,
500 // 20위 500 // 20위
}; };
void CGuildManager::BootReserveWar() void CGuildManager::BootReserveWar()
{ {
const char * c_apszQuery[2] = const char *c_apszQuery[2] =
{ {
"SELECT id, guild1, guild2, UNIX_TIMESTAMP(time), type, warprice, initscore, bet_from, bet_to, power1, power2, handicap FROM guild_war_reservation WHERE started=1 AND winner=-1", "SELECT id, guild1, guild2, UNIX_TIMESTAMP(time), type, warprice, initscore, bet_from, bet_to, power1, power2, handicap FROM guild_war_reservation WHERE started=1 AND winner=-1",
"SELECT id, guild1, guild2, UNIX_TIMESTAMP(time), type, warprice, initscore, bet_from, bet_to, power1, power2, handicap FROM guild_war_reservation WHERE started=0" "SELECT id, guild1, guild2, UNIX_TIMESTAMP(time), type, warprice, initscore, bet_from, bet_to, power1, power2, handicap FROM guild_war_reservation WHERE started=0"};
};
for (int i = 0; i < 2; ++i) for (int i = 0; i < 2; ++i)
{ {
@ -928,14 +942,14 @@ void CGuildManager::BootReserveWar()
str_to_number(t.lHandicap, row[col++]); str_to_number(t.lHandicap, row[col++]);
t.bStarted = 0; t.bStarted = 0;
CGuildWarReserve * pkReserve = new CGuildWarReserve(t); CGuildWarReserve *pkReserve = new CGuildWarReserve(t);
char buf[512]; char buf[512];
snprintf(buf, sizeof(buf), "GuildWar: BootReserveWar : step %d id %u GID1 %u GID2 %u", i, t.dwID, t.dwGuildFrom, t.dwGuildTo); snprintf(buf, sizeof(buf), "GuildWar: BootReserveWar : step %d id %u GID1 %u GID2 %u", i, t.dwID, t.dwGuildFrom, t.dwGuildTo);
// i == 0 이면 길드전 도중 DB가 튕긴 것이므로 무승부 처리한다. // i == 0 이면 길드전 도중 DB가 튕긴 것이므로 무승부 처리한다.
// 또는, 5분 이하 남은 예약 길드전도 무승부 처리한다. (각자의 배팅액을 돌려준다) // 또는, 5분 이하 남은 예약 길드전도 무승부 처리한다. (각자의 배팅액을 돌려준다)
//if (i == 0 || (int) t.dwTime - CClientManager::instance().GetCurrentTime() < 60 * 5) // if (i == 0 || (int) t.dwTime - CClientManager::instance().GetCurrentTime() < 60 * 5)
if (i == 0 || (int) t.dwTime - CClientManager::instance().GetCurrentTime() < 0) if (i == 0 || (int)t.dwTime - CClientManager::instance().GetCurrentTime() < 0)
{ {
if (i == 0) if (i == 0)
SPDLOG_DEBUG("{} : DB was shutdowned while war is being.", buf); SPDLOG_DEBUG("{} : DB was shutdowned while war is being.", buf);
@ -958,16 +972,17 @@ int GetAverageGuildMemberLevel(DWORD dwGID)
{ {
char szQuery[QUERY_MAX_LEN]; char szQuery[QUERY_MAX_LEN];
snprintf(szQuery, sizeof(szQuery), snprintf(szQuery, sizeof(szQuery),
"SELECT AVG(level) FROM guild_member%s, player%s AS p WHERE guild_id=%u AND guild_member%s.pid=p.id", "SELECT AVG(level) FROM guild_member%s, player%s AS p WHERE guild_id=%u AND guild_member%s.pid=p.id",
GetTablePostfix(), GetTablePostfix(), dwGID, GetTablePostfix()); GetTablePostfix(), GetTablePostfix(), dwGID, GetTablePostfix());
std::unique_ptr<SQLMsg> msg(CDBManager::instance().DirectQuery(szQuery)); std::unique_ptr<SQLMsg> msg(CDBManager::instance().DirectQuery(szQuery));
MYSQL_ROW row; MYSQL_ROW row;
row = mysql_fetch_row(msg->Get()->pSQLResult); row = mysql_fetch_row(msg->Get()->pSQLResult);
int nAverageLevel = 0; str_to_number(nAverageLevel, row[0]); int nAverageLevel = 0;
str_to_number(nAverageLevel, row[0]);
return nAverageLevel; return nAverageLevel;
} }
@ -982,11 +997,12 @@ int GetGuildMemberCount(DWORD dwGID)
MYSQL_ROW row; MYSQL_ROW row;
row = mysql_fetch_row(msg->Get()->pSQLResult); row = mysql_fetch_row(msg->Get()->pSQLResult);
DWORD dwCount = 0; str_to_number(dwCount, row[0]); DWORD dwCount = 0;
str_to_number(dwCount, row[0]);
return dwCount; return dwCount;
} }
bool CGuildManager::ReserveWar(TPacketGuildWar * p) bool CGuildManager::ReserveWar(TPacketGuildWar *p)
{ {
DWORD GID1 = p->dwGuildFrom; DWORD GID1 = p->dwGuildFrom;
DWORD GID2 = p->dwGuildTo; DWORD GID2 = p->dwGuildTo;
@ -1011,7 +1027,7 @@ bool CGuildManager::ReserveWar(TPacketGuildWar * p)
int lvp, rkp, alv, mc; int lvp, rkp, alv, mc;
// 파워 계산 // 파워 계산
TGuild & k1 = TouchGuild(GID1); TGuild &k1 = TouchGuild(GID1);
lvp = c_aiScoreByLevel[std::min<size_t>(GUILD_MAX_LEVEL, k1.level)]; lvp = c_aiScoreByLevel[std::min<size_t>(GUILD_MAX_LEVEL, k1.level)];
rkp = c_aiScoreByRanking[GetRanking(GID1)]; rkp = c_aiScoreByRanking[GetRanking(GID1)];
@ -1023,11 +1039,11 @@ bool CGuildManager::ReserveWar(TPacketGuildWar * p)
polyPower.SetVar("alv", alv); polyPower.SetVar("alv", alv);
polyPower.SetVar("mc", mc); polyPower.SetVar("mc", mc);
t.lPowerFrom = (int) polyPower.Eval(); t.lPowerFrom = (int)polyPower.Eval();
SPDLOG_DEBUG("GuildWar: {} lvp {} rkp {} alv {} mc {} power {}", GID1, lvp, rkp, alv, mc, t.lPowerFrom); SPDLOG_DEBUG("GuildWar: {} lvp {} rkp {} alv {} mc {} power {}", GID1, lvp, rkp, alv, mc, t.lPowerFrom);
// 파워 계산 // 파워 계산
TGuild & k2 = TouchGuild(GID2); TGuild &k2 = TouchGuild(GID2);
lvp = c_aiScoreByLevel[std::min<size_t>(GUILD_MAX_LEVEL, k2.level)]; lvp = c_aiScoreByLevel[std::min<size_t>(GUILD_MAX_LEVEL, k2.level)];
rkp = c_aiScoreByRanking[GetRanking(GID2)]; rkp = c_aiScoreByRanking[GetRanking(GID2)];
@ -1039,7 +1055,7 @@ bool CGuildManager::ReserveWar(TPacketGuildWar * p)
polyPower.SetVar("alv", alv); polyPower.SetVar("alv", alv);
polyPower.SetVar("mc", mc); polyPower.SetVar("mc", mc);
t.lPowerTo = (int) polyPower.Eval(); t.lPowerTo = (int)polyPower.Eval();
SPDLOG_DEBUG("GuildWar: {} lvp {} rkp {} alv {} mc {} power {}", GID2, lvp, rkp, alv, mc, t.lPowerTo); SPDLOG_DEBUG("GuildWar: {} lvp {} rkp {} alv {} mc {} power {}", GID2, lvp, rkp, alv, mc, t.lPowerTo);
// 핸디캡 계산 // 핸디캡 계산
@ -1054,16 +1070,16 @@ bool CGuildManager::ReserveWar(TPacketGuildWar * p)
polyHandicap.SetVar("pB", t.lPowerTo); polyHandicap.SetVar("pB", t.lPowerTo);
} }
t.lHandicap = (int) polyHandicap.Eval(); t.lHandicap = (int)polyHandicap.Eval();
SPDLOG_DEBUG("GuildWar: handicap {}", t.lHandicap); SPDLOG_DEBUG("GuildWar: handicap {}", t.lHandicap);
// 쿼리 // 쿼리
char szQuery[512]; char szQuery[512];
snprintf(szQuery, sizeof(szQuery), snprintf(szQuery, sizeof(szQuery),
"INSERT INTO guild_war_reservation (guild1, guild2, time, type, warprice, initscore, power1, power2, handicap) " "INSERT INTO guild_war_reservation (guild1, guild2, time, type, warprice, initscore, power1, power2, handicap) "
"VALUES(%u, %u, DATE_ADD(NOW(), INTERVAL 180 SECOND), %u, %d, %d, %d, %d, %d)", "VALUES(%u, %u, DATE_ADD(NOW(), INTERVAL 180 SECOND), %u, %d, %d, %d, %d, %d)",
GID1, GID2, p->bType, p->lWarPrice, p->lInitialScore, t.lPowerFrom, t.lPowerTo, t.lHandicap); GID1, GID2, p->bType, p->lWarPrice, p->lInitialScore, t.lPowerFrom, t.lPowerTo, t.lHandicap);
std::unique_ptr<SQLMsg> pmsg(CDBManager::instance().DirectQuery(szQuery)); std::unique_ptr<SQLMsg> pmsg(CDBManager::instance().DirectQuery(szQuery));
@ -1091,15 +1107,15 @@ void CGuildManager::ProcessReserveWar()
{ {
itertype(m_map_kWarReserve) it2 = it++; itertype(m_map_kWarReserve) it2 = it++;
CGuildWarReserve * pk = it2->second; CGuildWarReserve *pk = it2->second;
TGuildWarReserve & r = pk->GetDataRef(); TGuildWarReserve &r = pk->GetDataRef();
if (!r.bStarted && r.dwTime - 1800 <= dwCurTime) // 30분 전부터 알린다. if (!r.bStarted && r.dwTime - 1800 <= dwCurTime) // 30분 전부터 알린다.
{ {
int iMin = (int) ceil((int)(r.dwTime - dwCurTime) / 60.0); int iMin = (int)ceil((int)(r.dwTime - dwCurTime) / 60.0);
TGuild & r_1 = m_map_kGuild[r.dwGuildFrom]; TGuild &r_1 = m_map_kGuild[r.dwGuildFrom];
TGuild & r_2 = m_map_kGuild[r.dwGuildTo]; TGuild &r_2 = m_map_kGuild[r.dwGuildTo];
SPDLOG_DEBUG("GuildWar: started GID1 {} GID2 {} {} time {} min {}", r.dwGuildFrom, r.dwGuildTo, r.bStarted, dwCurTime - r.dwTime, iMin); SPDLOG_DEBUG("GuildWar: started GID1 {} GID2 {} {} time {} min {}", r.dwGuildFrom, r.dwGuildTo, r.bStarted, dwCurTime - r.dwTime, iMin);
@ -1126,7 +1142,7 @@ void CGuildManager::ProcessReserveWar()
pck.lInitialScore = r.lInitialScore; pck.lInitialScore = r.lInitialScore;
CClientManager::instance().ForwardPacket(HEADER_DG_GUILD_WAR, &pck, sizeof(TPacketGuildWar)); CClientManager::instance().ForwardPacket(HEADER_DG_GUILD_WAR, &pck, sizeof(TPacketGuildWar));
//m_map_kWarReserve.erase(it2); // m_map_kWarReserve.erase(it2);
} }
else else
{ {
@ -1144,7 +1160,7 @@ void CGuildManager::ProcessReserveWar()
} }
} }
bool CGuildManager::Bet(DWORD dwID, const char * c_pszLogin, DWORD dwGold, DWORD dwGuild) bool CGuildManager::Bet(DWORD dwID, const char *c_pszLogin, DWORD dwGold, DWORD dwGuild)
{ {
itertype(m_map_kWarReserve) it = m_map_kWarReserve.find(dwID); itertype(m_map_kWarReserve) it = m_map_kWarReserve.find(dwID);
@ -1154,7 +1170,7 @@ bool CGuildManager::Bet(DWORD dwID, const char * c_pszLogin, DWORD dwGold, DWORD
{ {
SPDLOG_DEBUG("WAR_RESERVE: Bet: cannot find reserve war by id {}", dwID); SPDLOG_DEBUG("WAR_RESERVE: Bet: cannot find reserve war by id {}", dwID);
snprintf(szQuery, sizeof(szQuery), "INSERT INTO item_award (login, vnum, socket0, given_time) VALUES('%s', %d, %u, NOW())", snprintf(szQuery, sizeof(szQuery), "INSERT INTO item_award (login, vnum, socket0, given_time) VALUES('%s', %d, %u, NOW())",
c_pszLogin, ITEM_ELK_VNUM, dwGold); c_pszLogin, ITEM_ELK_VNUM, dwGold);
CDBManager::instance().AsyncQuery(szQuery); CDBManager::instance().AsyncQuery(szQuery);
return false; return false;
} }
@ -1162,8 +1178,8 @@ bool CGuildManager::Bet(DWORD dwID, const char * c_pszLogin, DWORD dwGold, DWORD
if (!it->second->Bet(c_pszLogin, dwGold, dwGuild)) if (!it->second->Bet(c_pszLogin, dwGold, dwGuild))
{ {
SPDLOG_DEBUG("WAR_RESERVE: Bet: cannot bet id {}, login {}, gold {}, guild {}", dwID, c_pszLogin, dwGold, dwGuild); SPDLOG_DEBUG("WAR_RESERVE: Bet: cannot bet id {}, login {}, gold {}, guild {}", dwID, c_pszLogin, dwGold, dwGuild);
snprintf(szQuery, sizeof(szQuery), "INSERT INTO item_award (login, vnum, socket0, given_time) VALUES('%s', %d, %u, NOW())", snprintf(szQuery, sizeof(szQuery), "INSERT INTO item_award (login, vnum, socket0, given_time) VALUES('%s', %d, %u, NOW())",
c_pszLogin, ITEM_ELK_VNUM, dwGold); c_pszLogin, ITEM_ELK_VNUM, dwGold);
CDBManager::instance().AsyncQuery(szQuery); CDBManager::instance().AsyncQuery(szQuery);
return false; return false;
} }
@ -1201,7 +1217,7 @@ bool CGuildManager::ChangeMaster(DWORD dwGID, DWORD dwFrom, DWORD dwTo)
////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////
// Guild War Reserve Class // Guild War Reserve Class
////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////
CGuildWarReserve::CGuildWarReserve(const TGuildWarReserve & rTable) CGuildWarReserve::CGuildWarReserve(const TGuildWarReserve &rTable)
{ {
memcpy(&m_data, &rTable, sizeof(TGuildWarReserve)); memcpy(&m_data, &rTable, sizeof(TGuildWarReserve));
m_iLastNoticeMin = -1; m_iLastNoticeMin = -1;
@ -1218,10 +1234,10 @@ void CGuildWarReserve::Initialize()
if (msgbet->Get()->uiNumRows) if (msgbet->Get()->uiNumRows)
{ {
MYSQL_RES * res = msgbet->Get()->pSQLResult; MYSQL_RES *res = msgbet->Get()->pSQLResult;
MYSQL_ROW row; MYSQL_ROW row;
char szLogin[LOGIN_MAX_LEN+1]; char szLogin[LOGIN_MAX_LEN + 1];
DWORD dwGuild; DWORD dwGuild;
DWORD dwGold; DWORD dwGold;
@ -1237,12 +1253,12 @@ void CGuildWarReserve::Initialize()
} }
} }
void CGuildWarReserve::OnSetup(CPeer * peer) void CGuildWarReserve::OnSetup(CPeer *peer)
{ {
if (m_data.bStarted) // 이미 시작된 것은 보내지 않는다. if (m_data.bStarted) // 이미 시작된 것은 보내지 않는다.
return; return;
FSendPeerWar(m_data.bType, GUILD_WAR_RESERVE, m_data.dwGuildFrom, m_data.dwGuildTo) (peer); FSendPeerWar(m_data.bType, GUILD_WAR_RESERVE, m_data.dwGuildFrom, m_data.dwGuildTo)(peer);
peer->EncodeHeader(HEADER_DG_GUILD_WAR_RESERVE_ADD, 0, sizeof(TGuildWarReserve)); peer->EncodeHeader(HEADER_DG_GUILD_WAR_RESERVE_ADD, 0, sizeof(TGuildWarReserve));
peer->Encode(&m_data, sizeof(TGuildWarReserve)); peer->Encode(&m_data, sizeof(TGuildWarReserve));
@ -1265,7 +1281,7 @@ void CGuildWarReserve::OnSetup(CPeer * peer)
} }
} }
bool CGuildWarReserve::Bet(const char * pszLogin, DWORD dwGold, DWORD dwGuild) bool CGuildWarReserve::Bet(const char *pszLogin, DWORD dwGold, DWORD dwGuild)
{ {
char szQuery[1024]; char szQuery[1024];
@ -1287,9 +1303,9 @@ bool CGuildWarReserve::Bet(const char * pszLogin, DWORD dwGold, DWORD dwGuild)
return false; return false;
} }
snprintf(szQuery, sizeof(szQuery), snprintf(szQuery, sizeof(szQuery),
"INSERT INTO guild_war_bet (war_id, login, gold, guild) VALUES(%u, '%s', %u, %u)", "INSERT INTO guild_war_bet (war_id, login, gold, guild) VALUES(%u, '%s', %u, %u)",
m_data.dwID, pszLogin, dwGold, dwGuild); m_data.dwID, pszLogin, dwGold, dwGuild);
std::unique_ptr<SQLMsg> pmsg(CDBManager::instance().DirectQuery(szQuery)); std::unique_ptr<SQLMsg> pmsg(CDBManager::instance().DirectQuery(szQuery));
@ -1306,8 +1322,8 @@ bool CGuildWarReserve::Bet(const char * pszLogin, DWORD dwGold, DWORD dwGuild)
CClientManager::instance().ForwardPacket(HEADER_DG_GUILD_WAR_RESERVE_ADD, &m_data, sizeof(TGuildWarReserve)); CClientManager::instance().ForwardPacket(HEADER_DG_GUILD_WAR_RESERVE_ADD, &m_data, sizeof(TGuildWarReserve));
snprintf(szQuery, sizeof(szQuery), "UPDATE guild_war_reservation SET bet_from=%u,bet_to=%u WHERE id=%u", snprintf(szQuery, sizeof(szQuery), "UPDATE guild_war_reservation SET bet_from=%u,bet_to=%u WHERE id=%u",
m_data.dwBetFrom, m_data.dwBetTo, m_data.dwID); m_data.dwBetFrom, m_data.dwBetTo, m_data.dwID);
CDBManager::instance().AsyncQuery(szQuery); CDBManager::instance().AsyncQuery(szQuery);
@ -1328,7 +1344,7 @@ bool CGuildWarReserve::Bet(const char * pszLogin, DWORD dwGold, DWORD dwGuild)
// 무승부 처리: 대부분 승부가 나야 정상이지만, 서버 문제 등 특정 상황일 경우에는 // 무승부 처리: 대부분 승부가 나야 정상이지만, 서버 문제 등 특정 상황일 경우에는
// 무승부 처리가 있어야 한다. // 무승부 처리가 있어야 한다.
// //
void CGuildWarReserve::Draw() void CGuildWarReserve::Draw()
{ {
char szQuery[1024]; char szQuery[1024];
@ -1352,11 +1368,11 @@ void CGuildWarReserve::Draw()
while (it != mapBet.end()) while (it != mapBet.end())
{ {
if (iRow == 0) if (iRow == 0)
iLen += snprintf(szQuery + iLen, sizeof(szQuery) - iLen, "('%s', %d, %u, NOW())", iLen += snprintf(szQuery + iLen, sizeof(szQuery) - iLen, "('%s', %d, %u, NOW())",
it->first.c_str(), ITEM_ELK_VNUM, it->second.second); it->first.c_str(), ITEM_ELK_VNUM, it->second.second);
else else
iLen += snprintf(szQuery + iLen, sizeof(szQuery) - iLen, ",('%s', %d, %u, NOW())", iLen += snprintf(szQuery + iLen, sizeof(szQuery) - iLen, ",('%s', %d, %u, NOW())",
it->first.c_str(), ITEM_ELK_VNUM, it->second.second); it->first.c_str(), ITEM_ELK_VNUM, it->second.second);
it++; it++;
@ -1398,7 +1414,7 @@ void CGuildWarReserve::End(int iScoreFrom, int iScoreTo)
} }
else else
{ {
if (m_data.lHandicap > iScoreTo - iScoreFrom) if (m_data.lHandicap > iScoreTo - iScoreFrom)
{ {
SPDLOG_DEBUG("WAR_REWARD: End: failed to overcome handicap, To is strong but From won"); SPDLOG_DEBUG("WAR_REWARD: End: failed to overcome handicap, To is strong but From won");
dwWinner = m_data.dwGuildFrom; dwWinner = m_data.dwGuildFrom;
@ -1411,8 +1427,8 @@ void CGuildWarReserve::End(int iScoreFrom, int iScoreTo)
} }
char szQuery[1024]; char szQuery[1024];
snprintf(szQuery, sizeof(szQuery), "UPDATE guild_war_reservation SET started=1,winner=%u,result1=%d,result2=%d WHERE id=%u", snprintf(szQuery, sizeof(szQuery), "UPDATE guild_war_reservation SET started=1,winner=%u,result1=%d,result2=%d WHERE id=%u",
dwWinner, iScoreFrom, iScoreTo, m_data.dwID); dwWinner, iScoreFrom, iScoreTo, m_data.dwID);
CDBManager::instance().AsyncQuery(szQuery); CDBManager::instance().AsyncQuery(szQuery);
if (mapBet.empty()) if (mapBet.empty())
@ -1456,19 +1472,19 @@ void CGuildWarReserve::End(int iScoreFrom, int iScoreTo)
continue; continue;
} }
double ratio = (double) it->second.second / dwWinnerBet; double ratio = (double)it->second.second / dwWinnerBet;
// 10% 세금 공제 후 분배 // 10% 세금 공제 후 분배
SPDLOG_DEBUG("WAR_REWARD: {} {} ratio {}", it->first.c_str(), it->second.second, ratio); SPDLOG_DEBUG("WAR_REWARD: {} {} ratio {}", it->first.c_str(), it->second.second, ratio);
DWORD dwGold = (DWORD) (dwTotalBet * ratio * 0.9); DWORD dwGold = (DWORD)(dwTotalBet * ratio * 0.9);
if (iRow == 0) if (iRow == 0)
iLen += snprintf(szQuery + iLen, sizeof(szQuery) - iLen, "('%s', %d, %u, NOW())", iLen += snprintf(szQuery + iLen, sizeof(szQuery) - iLen, "('%s', %d, %u, NOW())",
it->first.c_str(), ITEM_ELK_VNUM, dwGold); it->first.c_str(), ITEM_ELK_VNUM, dwGold);
else else
iLen += snprintf(szQuery + iLen, sizeof(szQuery) - iLen, ",('%s', %d, %u, NOW())", iLen += snprintf(szQuery + iLen, sizeof(szQuery) - iLen, ",('%s', %d, %u, NOW())",
it->first.c_str(), ITEM_ELK_VNUM, dwGold); it->first.c_str(), ITEM_ELK_VNUM, dwGold);
++it; ++it;
@ -1488,4 +1504,3 @@ void CGuildWarReserve::End(int iScoreFrom, int iScoreTo)
break; break;
} }
} }

View File

@ -10,7 +10,7 @@
enum enum
{ {
GUILD_WARP_WAR_CHANNEL = 99 GUILD_WARP_WAR_CHANNEL = 99
}; };
class CGuildWarReserve; class CGuildWarReserve;
@ -27,12 +27,12 @@ struct TGuildDeclareInfo
dwGuildID[1] = _dwGuildID2; dwGuildID[1] = _dwGuildID2;
} }
bool operator < (const TGuildDeclareInfo& r) const bool operator<(const TGuildDeclareInfo &r) const
{ {
return dwGuildID[0] < r.dwGuildID[0] || dwGuildID[0] == r.dwGuildID[0] && dwGuildID[1] < r.dwGuildID[1]; return dwGuildID[0] < r.dwGuildID[0] || dwGuildID[0] == r.dwGuildID[0] && dwGuildID[1] < r.dwGuildID[1];
} }
TGuildDeclareInfo& operator = (const TGuildDeclareInfo& r) TGuildDeclareInfo &operator=(const TGuildDeclareInfo &r)
{ {
bType = r.bType; bType = r.bType;
dwGuildID[0] = r.dwGuildID[0]; dwGuildID[0] = r.dwGuildID[0];
@ -43,25 +43,25 @@ struct TGuildDeclareInfo
struct TGuildWaitStartInfo struct TGuildWaitStartInfo
{ {
BYTE bType; BYTE bType;
DWORD GID[2]; DWORD GID[2];
int lWarPrice; int lWarPrice;
int lInitialScore; int lInitialScore;
CGuildWarReserve * pkReserve; CGuildWarReserve *pkReserve;
TGuildWaitStartInfo(BYTE _bType, TGuildWaitStartInfo(BYTE _bType,
DWORD _g1, DWORD _g1,
DWORD _g2, DWORD _g2,
int _lWarPrice, int _lWarPrice,
int _lInitialScore, int _lInitialScore,
CGuildWarReserve * _pkReserve) CGuildWarReserve *_pkReserve)
: bType(_bType), lWarPrice(_lWarPrice), lInitialScore(_lInitialScore), pkReserve(_pkReserve) : bType(_bType), lWarPrice(_lWarPrice), lInitialScore(_lInitialScore), pkReserve(_pkReserve)
{ {
GID[0] = _g1; GID[0] = _g1;
GID[1] = _g2; GID[1] = _g2;
} }
bool operator < (const TGuildWaitStartInfo& r) const bool operator<(const TGuildWaitStartInfo &r) const
{ {
return GID[0] < r.GID[0] || GID[0] == r.GID[0] && GID[1] < r.GID[1]; return GID[0] < r.GID[0] || GID[0] == r.GID[0] && GID[1] < r.GID[1];
} }
@ -69,11 +69,11 @@ struct TGuildWaitStartInfo
struct TGuildWarPQElement struct TGuildWarPQElement
{ {
bool bEnd; bool bEnd;
BYTE bType; BYTE bType;
DWORD GID[2]; DWORD GID[2];
DWORD iScore[2]; DWORD iScore[2];
DWORD iBetScore[2]; DWORD iBetScore[2];
TGuildWarPQElement(BYTE _bType, DWORD GID1, DWORD GID2) : bEnd(false), bType(_bType) TGuildWarPQElement(BYTE _bType, DWORD GID1, DWORD GID2) : bEnd(false), bType(_bType)
{ {
@ -87,19 +87,19 @@ struct TGuildWarPQElement
struct TGuildSkillUsed struct TGuildSkillUsed
{ {
DWORD GID; DWORD GID;
DWORD dwSkillVnum; DWORD dwSkillVnum;
// GUILD_SKILL_COOLTIME_BUG_FIX // GUILD_SKILL_COOLTIME_BUG_FIX
TGuildSkillUsed(DWORD _GID, DWORD _dwSkillVnum) : GID(_GID), dwSkillVnum(_dwSkillVnum) TGuildSkillUsed(DWORD _GID, DWORD _dwSkillVnum) : GID(_GID), dwSkillVnum(_dwSkillVnum)
{ {
} }
// END_OF_GUILD_SKILL_COOLTIME_BUG_FIX // END_OF_GUILD_SKILL_COOLTIME_BUG_FIX
}; };
inline bool operator < (const TGuildSkillUsed& a, const TGuildSkillUsed& b) inline bool operator<(const TGuildSkillUsed &a, const TGuildSkillUsed &b)
{ {
return a.GID < b.GID || a.GID == b.GID && a.dwSkillVnum < b.dwSkillVnum; return a.GID < b.GID || a.GID == b.GID && a.dwSkillVnum < b.dwSkillVnum;
} }
typedef struct SGuild typedef struct SGuild
@ -109,115 +109,115 @@ typedef struct SGuild
memset(szName, 0, sizeof(szName)); memset(szName, 0, sizeof(szName));
} }
char szName[GUILD_NAME_MAX_LEN+1]; char szName[GUILD_NAME_MAX_LEN + 1];
int ladder_point; int ladder_point;
int win; int win;
int draw; int draw;
int loss; int loss;
int gold; int gold;
int level; int level;
} TGuild; } TGuild;
typedef struct SGuildWarInfo typedef struct SGuildWarInfo
{ {
time_t tEndTime; time_t tEndTime;
TGuildWarPQElement * pElement; TGuildWarPQElement *pElement;
CGuildWarReserve * pkReserve; CGuildWarReserve *pkReserve;
SGuildWarInfo() : pElement(NULL) SGuildWarInfo() : pElement(NULL)
{ {
} }
} TGuildWarInfo; } TGuildWarInfo;
class CGuildWarReserve class CGuildWarReserve
{ {
public: public:
CGuildWarReserve(const TGuildWarReserve& rTable); CGuildWarReserve(const TGuildWarReserve &rTable);
void Initialize(); void Initialize();
TGuildWarReserve & GetDataRef() TGuildWarReserve &GetDataRef()
{ {
return m_data; return m_data;
} }
void OnSetup(CPeer * peer); void OnSetup(CPeer *peer);
bool Bet(const char * pszLogin, DWORD dwGold, DWORD dwGuild); bool Bet(const char *pszLogin, DWORD dwGold, DWORD dwGuild);
void Draw(); void Draw();
void End(int iScoreFrom, int iScoreTo); void End(int iScoreFrom, int iScoreTo);
int GetLastNoticeMin() { return m_iLastNoticeMin; } int GetLastNoticeMin() { return m_iLastNoticeMin; }
void SetLastNoticeMin(int iMin) { m_iLastNoticeMin = iMin; } void SetLastNoticeMin(int iMin) { m_iLastNoticeMin = iMin; }
private: private:
CGuildWarReserve(); // 기본 생성자를 사용하지 못하도록 의도적으로 구현하지 않음 CGuildWarReserve(); // 기본 생성자를 사용하지 못하도록 의도적으로 구현하지 않음
TGuildWarReserve m_data; TGuildWarReserve m_data;
// <login, <guild, gold>> // <login, <guild, gold>>
std::map<std::string, std::pair<DWORD, DWORD> > mapBet; std::map<std::string, std::pair<DWORD, DWORD>> mapBet;
int m_iLastNoticeMin; int m_iLastNoticeMin;
}; };
class CGuildManager : public singleton<CGuildManager> class CGuildManager : public singleton<CGuildManager>
{ {
public: public:
CGuildManager(); CGuildManager();
virtual ~CGuildManager(); virtual ~CGuildManager();
void Initialize(); void Initialize();
void Load(DWORD dwGuildID); void Load(DWORD dwGuildID);
TGuild & TouchGuild(DWORD GID); TGuild &TouchGuild(DWORD GID);
void Update(); void Update();
void OnSetup(CPeer * peer); void OnSetup(CPeer *peer);
void StartWar(BYTE bType, DWORD GID1, DWORD GID2, CGuildWarReserve * pkReserve = NULL); void StartWar(BYTE bType, DWORD GID1, DWORD GID2, CGuildWarReserve *pkReserve = NULL);
void UpdateScore(DWORD guild_gain_point, DWORD guild_opponent, int iScore, int iBetScore); void UpdateScore(DWORD guild_gain_point, DWORD guild_opponent, int iScore, int iBetScore);
void AddDeclare(BYTE bType, DWORD guild_from, DWORD guild_to); void AddDeclare(BYTE bType, DWORD guild_from, DWORD guild_to);
void RemoveDeclare(DWORD guild_from, DWORD guild_to); void RemoveDeclare(DWORD guild_from, DWORD guild_to);
bool TakeBetPrice(DWORD dwGuildTo, DWORD dwGuildFrom, int lWarPrice); bool TakeBetPrice(DWORD dwGuildTo, DWORD dwGuildFrom, int lWarPrice);
bool WaitStart(TPacketGuildWar * p); bool WaitStart(TPacketGuildWar *p);
void RecvWarEnd(DWORD GID1, DWORD GID2); void RecvWarEnd(DWORD GID1, DWORD GID2);
void RecvWarOver(DWORD dwGuildWinner, DWORD dwGuildLoser, bool bDraw, int lWarPrice); void RecvWarOver(DWORD dwGuildWinner, DWORD dwGuildLoser, bool bDraw, int lWarPrice);
void ChangeLadderPoint(DWORD GID, int change); void ChangeLadderPoint(DWORD GID, int change);
void UseSkill(DWORD dwGuild, DWORD dwSkillVnum, DWORD dwCooltime); void UseSkill(DWORD dwGuild, DWORD dwSkillVnum, DWORD dwCooltime);
INT GetGuildGold(DWORD dwGuild); INT GetGuildGold(DWORD dwGuild);
void DepositMoney(DWORD dwGuild, INT lGold); void DepositMoney(DWORD dwGuild, INT lGold);
void WithdrawMoney(CPeer* peer, DWORD dwGuild, INT lGold); void WithdrawMoney(CPeer *peer, DWORD dwGuild, INT lGold);
void WithdrawMoneyReply(DWORD dwGuild, BYTE bGiveSuccess, INT lGold); void WithdrawMoneyReply(DWORD dwGuild, BYTE bGiveSuccess, INT lGold);
void MoneyChange(DWORD dwGuild, DWORD dwGold); void MoneyChange(DWORD dwGuild, DWORD dwGold);
void QueryRanking(); void QueryRanking();
void ResultRanking(MYSQL_RES * pRes); void ResultRanking(MYSQL_RES *pRes);
int GetRanking(DWORD dwGID); int GetRanking(DWORD dwGID);
// //
// Reserve War // Reserve War
// //
void BootReserveWar(); void BootReserveWar();
bool ReserveWar(TPacketGuildWar * p); bool ReserveWar(TPacketGuildWar *p);
void ProcessReserveWar(); void ProcessReserveWar();
bool Bet(DWORD dwID, const char * c_pszLogin, DWORD dwGold, DWORD dwGuild); bool Bet(DWORD dwID, const char *c_pszLogin, DWORD dwGold, DWORD dwGuild);
void CancelWar(DWORD GID1, DWORD GID2); void CancelWar(DWORD GID1, DWORD GID2);
bool ChangeMaster(DWORD dwGID, DWORD dwFrom, DWORD dwTo); bool ChangeMaster(DWORD dwGID, DWORD dwFrom, DWORD dwTo);
private: private:
void ParseResult(SQLResult * pRes); void ParseResult(SQLResult *pRes);
void RemoveWar(DWORD GID1, DWORD GID2); // erase war from m_WarMap and set end on priority queue void RemoveWar(DWORD GID1, DWORD GID2); // erase war from m_WarMap and set end on priority queue
void WarEnd(DWORD GID1, DWORD GID2, bool bDraw = false); void WarEnd(DWORD GID1, DWORD GID2, bool bDraw = false);
@ -232,29 +232,29 @@ class CGuildManager : public singleton<CGuildManager>
bool IsHalfWinLadderPoint(DWORD dwGuildWinner, DWORD dwGuildLoser); bool IsHalfWinLadderPoint(DWORD dwGuildWinner, DWORD dwGuildLoser);
std::map<DWORD, TGuild> m_map_kGuild; std::map<DWORD, TGuild> m_map_kGuild;
std::map<DWORD, std::map<DWORD, time_t> > m_mapGuildWarEndTime; std::map<DWORD, std::map<DWORD, time_t>> m_mapGuildWarEndTime;
std::set<TGuildDeclareInfo> m_DeclareMap; // 선전 포고 상태를 저장 std::set<TGuildDeclareInfo> m_DeclareMap; // 선전 포고 상태를 저장
std::map<DWORD, std::map<DWORD, TGuildWarInfo> > m_WarMap; std::map<DWORD, std::map<DWORD, TGuildWarInfo>> m_WarMap;
typedef std::pair<time_t, TGuildWarPQElement *> stPairGuildWar; typedef std::pair<time_t, TGuildWarPQElement *> stPairGuildWar;
typedef std::pair<time_t, TGuildSkillUsed> stPairSkillUsed; typedef std::pair<time_t, TGuildSkillUsed> stPairSkillUsed;
typedef std::pair<time_t, TGuildWaitStartInfo> stPairWaitStart; typedef std::pair<time_t, TGuildWaitStartInfo> stPairWaitStart;
std::priority_queue<stPairGuildWar, std::vector<stPairGuildWar>, std::greater<stPairGuildWar> > std::priority_queue<stPairGuildWar, std::vector<stPairGuildWar>, std::greater<stPairGuildWar>>
m_pqOnWar; m_pqOnWar;
std::priority_queue<stPairWaitStart, std::vector<stPairWaitStart>, std::greater<stPairWaitStart> > std::priority_queue<stPairWaitStart, std::vector<stPairWaitStart>, std::greater<stPairWaitStart>>
m_pqWaitStart; m_pqWaitStart;
std::priority_queue<stPairSkillUsed, std::vector<stPairSkillUsed>, std::greater<stPairSkillUsed> > std::priority_queue<stPairSkillUsed, std::vector<stPairSkillUsed>, std::greater<stPairSkillUsed>>
m_pqSkill; m_pqSkill;
std::map<DWORD, CGuildWarReserve *> m_map_kWarReserve; std::map<DWORD, CGuildWarReserve *> m_map_kWarReserve;
CPoly polyPower; CPoly polyPower;
CPoly polyHandicap; CPoly polyHandicap;
// GID Ranking // GID Ranking
std::map<DWORD, int> map_kLadderPointRankingByGID; std::map<DWORD, int> map_kLadderPointRankingByGID;
}; };
#endif #endif

View File

@ -6,8 +6,6 @@
#include "ClientManager.h" #include "ClientManager.h"
DWORD g_dwLastCachedItemAwardID = 0; DWORD g_dwLastCachedItemAwardID = 0;
ItemAwardManager::ItemAwardManager() ItemAwardManager::ItemAwardManager()
{ {
@ -24,9 +22,9 @@ void ItemAwardManager::RequestLoad()
CDBManager::instance().ReturnQuery(szQuery, QID_ITEM_AWARD_LOAD, 0, NULL); CDBManager::instance().ReturnQuery(szQuery, QID_ITEM_AWARD_LOAD, 0, NULL);
} }
void ItemAwardManager::Load(SQLMsg * pMsg) void ItemAwardManager::Load(SQLMsg *pMsg)
{ {
MYSQL_RES * pRes = pMsg->Get()->pSQLResult; MYSQL_RES *pRes = pMsg->Get()->pSQLResult;
for (uint i = 0; i < pMsg->Get()->uiNumRows; ++i) for (uint i = 0; i < pMsg->Get()->uiNumRows; ++i)
{ {
@ -39,10 +37,10 @@ void ItemAwardManager::Load(SQLMsg * pMsg)
if (m_map_award.find(dwID) != m_map_award.end()) if (m_map_award.find(dwID) != m_map_award.end())
continue; continue;
TItemAward * kData = new TItemAward; TItemAward *kData = new TItemAward;
memset(kData, 0, sizeof(TItemAward)); memset(kData, 0, sizeof(TItemAward));
kData->dwID = dwID; kData->dwID = dwID;
trim_and_lower(row[col++], kData->szLogin, sizeof(kData->szLogin)); trim_and_lower(row[col++], kData->szLogin, sizeof(kData->szLogin));
str_to_number(kData->dwVnum, row[col++]); str_to_number(kData->dwVnum, row[col++]);
str_to_number(kData->dwCount, row[col++]); str_to_number(kData->dwCount, row[col++]);
@ -54,20 +52,20 @@ void ItemAwardManager::Load(SQLMsg * pMsg)
if (row[col]) if (row[col])
{ {
strlcpy(kData->szWhy, row[col], sizeof(kData->szWhy)); strlcpy(kData->szWhy, row[col], sizeof(kData->szWhy));
//게임 중에 why콜룸에 변동이 생기면 // 게임 중에 why콜룸에 변동이 생기면
char* whyStr = kData->szWhy; //why 콜룸 읽기 char *whyStr = kData->szWhy; // why 콜룸 읽기
char cmdStr[100] = ""; //why콜룸에서 읽은 값을 임시 문자열에 복사해둠 char cmdStr[100] = ""; // why콜룸에서 읽은 값을 임시 문자열에 복사해둠
strcpy(cmdStr,whyStr); //명령어 얻는 과정에서 토큰쓰면 원본도 토큰화 되기 때문 strcpy(cmdStr, whyStr); // 명령어 얻는 과정에서 토큰쓰면 원본도 토큰화 되기 때문
char command[20] = ""; char command[20] = "";
strcpy(command,CClientManager::instance().GetCommand(cmdStr).c_str()); // command 얻기 strcpy(command, CClientManager::instance().GetCommand(cmdStr).c_str()); // command 얻기
//SPDLOG_ERROR("{}, {}",pItemAward->dwID,command); // SPDLOG_ERROR("{}, {}",pItemAward->dwID,command);
if( !(strcmp(command,"GIFT") )) // command 가 GIFT이면 if (!(strcmp(command, "GIFT"))) // command 가 GIFT이면
{ {
TPacketItemAwardInfromer giftData; TPacketItemAwardInfromer giftData;
strcpy(giftData.login, kData->szLogin); //로그인 아이디 복사 strcpy(giftData.login, kData->szLogin); // 로그인 아이디 복사
strcpy(giftData.command, command); //명령어 복사 strcpy(giftData.command, command); // 명령어 복사
giftData.vnum = kData->dwVnum; //아이템 vnum도 복사 giftData.vnum = kData->dwVnum; // 아이템 vnum도 복사
CClientManager::instance().ForwardPacket(HEADER_DG_ITEMAWARD_INFORMER,&giftData,sizeof(TPacketItemAwardInfromer)); CClientManager::instance().ForwardPacket(HEADER_DG_ITEMAWARD_INFORMER, &giftData, sizeof(TPacketItemAwardInfromer));
} }
} }
@ -75,7 +73,7 @@ void ItemAwardManager::Load(SQLMsg * pMsg)
printf("ITEM_AWARD load id %u bMall %d \n", kData->dwID, kData->bMall); printf("ITEM_AWARD load id %u bMall %d \n", kData->dwID, kData->bMall);
SPDLOG_DEBUG("ITEM_AWARD: load id {} login {} vnum {} count {} socket {}", kData->dwID, kData->szLogin, kData->dwVnum, kData->dwCount, kData->dwSocket0); SPDLOG_DEBUG("ITEM_AWARD: load id {} login {} vnum {} count {} socket {}", kData->dwID, kData->szLogin, kData->dwVnum, kData->dwCount, kData->dwSocket0);
std::set<TItemAward *> & kSet = m_map_kSetAwardByLogin[kData->szLogin]; std::set<TItemAward *> &kSet = m_map_kSetAwardByLogin[kData->szLogin];
kSet.insert(kData); kSet.insert(kData);
if (dwID > g_dwLastCachedItemAwardID) if (dwID > g_dwLastCachedItemAwardID)
@ -83,7 +81,7 @@ void ItemAwardManager::Load(SQLMsg * pMsg)
} }
} }
std::set<TItemAward *> * ItemAwardManager::GetByLogin(const char * c_pszLogin) std::set<TItemAward *> *ItemAwardManager::GetByLogin(const char *c_pszLogin)
{ {
itertype(m_map_kSetAwardByLogin) it = m_map_kSetAwardByLogin.find(c_pszLogin); itertype(m_map_kSetAwardByLogin) it = m_map_kSetAwardByLogin.find(c_pszLogin);
@ -103,27 +101,27 @@ void ItemAwardManager::Taken(DWORD dwAwardID, DWORD dwItemID)
return; return;
} }
TItemAward * k = it->second; TItemAward *k = it->second;
k->bTaken = true; k->bTaken = true;
// //
// Update taken_time in database to prevent not to give him again. // Update taken_time in database to prevent not to give him again.
// //
char szQuery[QUERY_MAX_LEN]; char szQuery[QUERY_MAX_LEN];
snprintf(szQuery, sizeof(szQuery), snprintf(szQuery, sizeof(szQuery),
"UPDATE item_award SET taken_time=NOW(),item_id=%u WHERE id=%u AND taken_time IS NULL", "UPDATE item_award SET taken_time=NOW(),item_id=%u WHERE id=%u AND taken_time IS NULL",
dwItemID, dwAwardID); dwItemID, dwAwardID);
CDBManager::instance().ReturnQuery(szQuery, QID_ITEM_AWARD_TAKEN, 0, NULL); CDBManager::instance().ReturnQuery(szQuery, QID_ITEM_AWARD_TAKEN, 0, NULL);
} }
std::map<DWORD, TItemAward *>& ItemAwardManager::GetMapAward() std::map<DWORD, TItemAward *> &ItemAwardManager::GetMapAward()
{ {
return m_map_award; return m_map_award;
} }
std::map<std::string, std::set<TItemAward *> >& ItemAwardManager::GetMapkSetAwardByLogin() std::map<std::string, std::set<TItemAward *>> &ItemAwardManager::GetMapkSetAwardByLogin()
{ {
return m_map_kSetAwardByLogin; return m_map_kSetAwardByLogin;
} }

View File

@ -7,37 +7,38 @@
typedef struct SItemAward typedef struct SItemAward
{ {
DWORD dwID; DWORD dwID;
char szLogin[LOGIN_MAX_LEN+1]; char szLogin[LOGIN_MAX_LEN + 1];
DWORD dwVnum; DWORD dwVnum;
DWORD dwCount; DWORD dwCount;
DWORD dwSocket0; DWORD dwSocket0;
DWORD dwSocket1; DWORD dwSocket1;
DWORD dwSocket2; DWORD dwSocket2;
char szWhy[ITEM_AWARD_WHY_MAX_LEN+1]; char szWhy[ITEM_AWARD_WHY_MAX_LEN + 1];
bool bTaken; bool bTaken;
bool bMall; bool bMall;
} TItemAward; } TItemAward;
class ItemAwardManager : public singleton<ItemAwardManager> class ItemAwardManager : public singleton<ItemAwardManager>
{ {
public: public:
ItemAwardManager(); ItemAwardManager();
virtual ~ItemAwardManager(); virtual ~ItemAwardManager();
void RequestLoad(); void RequestLoad();
void Load(SQLMsg * pMsg); void Load(SQLMsg *pMsg);
std::set<TItemAward *> * GetByLogin(const char * c_pszLogin); std::set<TItemAward *> *GetByLogin(const char *c_pszLogin);
void Taken(DWORD dwAwardID, DWORD dwItemID); void Taken(DWORD dwAwardID, DWORD dwItemID);
// gift notify // gift notify
std::map<DWORD, TItemAward *>& GetMapAward(); std::map<DWORD, TItemAward *> &GetMapAward();
std::map<std::string, std::set<TItemAward *> >& GetMapkSetAwardByLogin(); std::map<std::string, std::set<TItemAward *>> &GetMapkSetAwardByLogin();
private:
private:
// ID, ItemAward pair // ID, ItemAward pair
std::map<DWORD, TItemAward *> m_map_award; std::map<DWORD, TItemAward *> m_map_award;
// PID, ItemAward pair // PID, ItemAward pair
std::map<std::string, std::set<TItemAward *> > m_map_kSetAwardByLogin; std::map<std::string, std::set<TItemAward *>> m_map_kSetAwardByLogin;
}; };
#endif #endif

View File

@ -16,7 +16,7 @@ void CItemIDRangeManager::Build()
DWORD dwMax = 0; DWORD dwMax = 0;
TItemIDRangeTable range; TItemIDRangeTable range;
for (int i = 0; ; ++i) for (int i = 0;; ++i)
{ {
dwMin = cs_dwMinimumRange * (i + 1) + 1; dwMin = cs_dwMinimumRange * (i + 1) + 1;
dwMax = cs_dwMinimumRange * (i + 2); dwMax = cs_dwMinimumRange * (i + 2);
@ -48,7 +48,7 @@ struct FCheckCollision
range = data; range = data;
} }
void operator() (CPeer* peer) void operator()(CPeer *peer)
{ {
if (hasCollision == false) if (hasCollision == false)
{ {
@ -74,7 +74,8 @@ TItemIDRangeTable CItemIDRangeManager::GetRange()
FCheckCollision f(ret); FCheckCollision f(ret);
CClientManager::instance().for_each_peer(f); CClientManager::instance().for_each_peer(f);
if (f.hasCollision == false) return ret; if (f.hasCollision == false)
return ret;
} }
} }
@ -83,71 +84,59 @@ TItemIDRangeTable CItemIDRangeManager::GetRange()
return ret; return ret;
} }
#include <pqxx/pqxx>
#include <spdlog/spdlog.h>
bool CItemIDRangeManager::BuildRange(DWORD dwMin, DWORD dwMax, TItemIDRangeTable& range) bool CItemIDRangeManager::BuildRange(DWORD dwMin, DWORD dwMax, TItemIDRangeTable &range)
{ {
char szQuery[1024];
DWORD dwItemMaxID = 0; DWORD dwItemMaxID = 0;
SQLMsg* pMsg = NULL;
MYSQL_ROW row;
snprintf(szQuery, sizeof(szQuery), "SELECT MAX(id) FROM item%s WHERE id >= %u and id <= %u", GetTablePostfix(), dwMin, dwMax); auto pool = CDBManager::instance().GetConnectionPool();
auto conn = pool->acquire();
pMsg = CDBManager::instance().DirectQuery(szQuery); try
if (pMsg != NULL)
{ {
if (pMsg->Get()->uiNumRows > 0) pqxx::work txn(*conn);
auto maxRow = txn.exec_params1("SELECT MAX(id) FROM item WHERE id >= $1 AND id <= $2", dwMin, dwMax);
if (!maxRow[0].is_null())
dwItemMaxID = maxRow[0].as<DWORD>();
dwItemMaxID = (dwItemMaxID == 0) ? dwMin : dwItemMaxID + 1;
if ((dwMax < dwItemMaxID) || (dwMax - dwItemMaxID < cs_dwMinimumRemainCount))
{ {
row = mysql_fetch_row(pMsg->Get()->pSQLResult); SPDLOG_DEBUG("ItemIDRange: Build {} ~ {} start: {}\tNOT USE remain count is below {}",
str_to_number(dwItemMaxID, row[0]); dwMin, dwMax, dwItemMaxID, cs_dwMinimumRemainCount);
} }
delete pMsg; else
}
if (dwItemMaxID == 0)
dwItemMaxID = dwMin;
else
dwItemMaxID++;
if ((dwMax < dwItemMaxID) || (dwMax - dwItemMaxID < cs_dwMinimumRemainCount))
{
SPDLOG_DEBUG("ItemIDRange: Build {} ~ {} start: {}\tNOT USE remain count is below {}",
dwMin, dwMax, dwItemMaxID, cs_dwMinimumRemainCount);
}
else
{
range.dwMin = dwMin;
range.dwMax = dwMax;
range.dwUsableItemIDMin = dwItemMaxID;
snprintf(szQuery, sizeof(szQuery), "SELECT COUNT(*) FROM item%s WHERE id >= %u AND id <= %u",
GetTablePostfix(), range.dwUsableItemIDMin, range.dwMax);
pMsg = CDBManager::instance().DirectQuery(szQuery);
if (pMsg != NULL)
{ {
if (pMsg->Get()->uiNumRows > 0) range.dwMin = dwMin;
range.dwMax = dwMax;
range.dwUsableItemIDMin = dwItemMaxID;
auto countRow = txn.exec_params1("SELECT COUNT(*) FROM item WHERE id >= $1 AND id <= $2", range.dwUsableItemIDMin, range.dwMax);
DWORD count = countRow[0].as<DWORD>();
if (count > 0)
{ {
DWORD count = 0; SPDLOG_ERROR("ItemIDRange: Build: {} ~ {}\thave a item", range.dwUsableItemIDMin, range.dwMax);
row = mysql_fetch_row(pMsg->Get()->pSQLResult); return false;
str_to_number(count, row[0]); }
else
if (count > 0) {
{ SPDLOG_TRACE("ItemIDRange: Build: {} ~ {} start:{}", range.dwMin, range.dwMax, range.dwUsableItemIDMin);
SPDLOG_ERROR("ItemIDRange: Build: {} ~ {}\thave a item", range.dwUsableItemIDMin, range.dwMax); return true;
return false;
}
else
{
SPDLOG_TRACE("ItemIDRange: Build: {} ~ {} start:{}", range.dwMin, range.dwMax, range.dwUsableItemIDMin);
return true;
}
} }
delete pMsg;
} }
txn.commit();
}
catch (const std::exception &e)
{
SPDLOG_ERROR("[CItemIDRangeManager::BuildRange] Query error: {}", e.what());
} }
return false; return false;
@ -162,4 +151,3 @@ void CItemIDRangeManager::UpdateRange(DWORD dwMin, DWORD dwMax)
m_listData.push_back(range); m_listData.push_back(range);
} }
} }

View File

@ -2,25 +2,26 @@
#ifndef __INC_METIN_II_ITEM_ID_RANGE_MANAGER_H__ #ifndef __INC_METIN_II_ITEM_ID_RANGE_MANAGER_H__
#define __INC_METIN_II_ITEM_ID_RANGE_MANAGER_H__ #define __INC_METIN_II_ITEM_ID_RANGE_MANAGER_H__
namespace { namespace
static const uint32_t cs_dwMaxItemID = 4290000000UL; {
static const uint32_t cs_dwMinimumRange = 10000000UL; static const uint32_t cs_dwMaxItemID = 4290000000UL;
static const uint32_t cs_dwMinimumRemainCount = 10000UL; static const uint32_t cs_dwMinimumRange = 10000000UL;
static const uint32_t cs_dwMinimumRemainCount = 10000UL;
} }
class CItemIDRangeManager : public singleton<CItemIDRangeManager> class CItemIDRangeManager : public singleton<CItemIDRangeManager>
{ {
private: private:
std::list<TItemIDRangeTable> m_listData; std::list<TItemIDRangeTable> m_listData;
public: public:
CItemIDRangeManager(); CItemIDRangeManager();
void Build(); void Build();
bool BuildRange(DWORD dwMin, DWORD dwMax, TItemIDRangeTable& range); bool BuildRange(DWORD dwMin, DWORD dwMax, TItemIDRangeTable &range);
void UpdateRange(DWORD dwMin, DWORD dwMax); void UpdateRange(DWORD dwMin, DWORD dwMax);
TItemIDRangeTable GetRange(); TItemIDRangeTable GetRange();
}; };
#endif #endif

View File

@ -12,39 +12,23 @@ CLock::~CLock()
void CLock::Initialize() void CLock::Initialize()
{ {
m_bLocked = false; m_bLocked = false;
#ifndef __WIN32__
pthread_mutex_init(&m_lock, NULL); pthread_mutex_init(&m_lock, NULL);
#else
::InitializeCriticalSection(&m_lock);
#endif
} }
void CLock::Destroy() void CLock::Destroy()
{ {
assert(!m_bLocked && "lock didn't released"); assert(!m_bLocked && "lock didn't released");
#ifndef __WIN32__
pthread_mutex_destroy(&m_lock); pthread_mutex_destroy(&m_lock);
#else
::DeleteCriticalSection(&m_lock);
#endif
} }
int CLock::Trylock() int CLock::Trylock()
{ {
#ifndef __WIN32__
return pthread_mutex_trylock(&m_lock); return pthread_mutex_trylock(&m_lock);
#else
return ::TryEnterCriticalSection(&m_lock);
#endif
} }
void CLock::Lock() void CLock::Lock()
{ {
#ifndef __WIN32__
pthread_mutex_lock(&m_lock); pthread_mutex_lock(&m_lock);
#else
::EnterCriticalSection(&m_lock);
#endif
m_bLocked = true; m_bLocked = true;
} }
@ -52,9 +36,5 @@ void CLock::Unlock()
{ {
assert(m_bLocked && "lock didn't issued"); assert(m_bLocked && "lock didn't issued");
m_bLocked = false; m_bLocked = false;
#ifndef __WIN32__
pthread_mutex_unlock(&m_lock); pthread_mutex_unlock(&m_lock);
#else
::LeaveCriticalSection(&m_lock);
#endif
} }

View File

@ -2,26 +2,22 @@
#ifndef __INC_LOCK_H__ #ifndef __INC_LOCK_H__
#define __INC_LOCK_H__ #define __INC_LOCK_H__
#ifdef __WIN32__ typedef pthread_mutex_t lock_t;
typedef CRITICAL_SECTION lock_t;
#else
typedef pthread_mutex_t lock_t;
#endif
class CLock class CLock
{ {
public: public:
CLock(); CLock();
~CLock(); ~CLock();
void Initialize(); void Initialize();
void Destroy(); void Destroy();
int Trylock(); int Trylock();
void Lock(); void Lock();
void Unlock(); void Unlock();
private: private:
lock_t m_lock; lock_t m_lock;
bool m_bLocked; bool m_bLocked;
}; };
#endif #endif

View File

@ -17,17 +17,17 @@ CLoginData::CLoginData()
memset(&m_data, 0, sizeof(TAccountTable)); memset(&m_data, 0, sizeof(TAccountTable));
} }
TAccountTable & CLoginData::GetAccountRef() TAccountTable &CLoginData::GetAccountRef()
{ {
return m_data; return m_data;
} }
void CLoginData::SetClientKey(const DWORD * c_pdwClientKey) void CLoginData::SetClientKey(const DWORD *c_pdwClientKey)
{ {
memcpy(&m_adwClientKey, c_pdwClientKey, sizeof(DWORD) * 4); memcpy(&m_adwClientKey, c_pdwClientKey, sizeof(DWORD) * 4);
} }
const DWORD * CLoginData::GetClientKey() const DWORD *CLoginData::GetClientKey()
{ {
return &m_adwClientKey[0]; return &m_adwClientKey[0];
} }
@ -62,12 +62,12 @@ DWORD CLoginData::GetLogonTime()
return m_dwLogonTime; return m_dwLogonTime;
} }
void CLoginData::SetIP(const char * c_pszIP) void CLoginData::SetIP(const char *c_pszIP)
{ {
strlcpy(m_szIP, c_pszIP, sizeof(m_szIP)); strlcpy(m_szIP, c_pszIP, sizeof(m_szIP));
} }
const char * CLoginData::GetIP() const char *CLoginData::GetIP()
{ {
return m_szIP; return m_szIP;
} }
@ -101,7 +101,7 @@ bool CLoginData::IsDeleted()
return m_bDeleted; return m_bDeleted;
} }
void CLoginData::SetPremium(DWORD * paiPremiumTimes) void CLoginData::SetPremium(DWORD *paiPremiumTimes)
{ {
memcpy(m_aiPremiumTimes, paiPremiumTimes, sizeof(m_aiPremiumTimes)); memcpy(m_aiPremiumTimes, paiPremiumTimes, sizeof(m_aiPremiumTimes));
} }
@ -114,8 +114,7 @@ DWORD CLoginData::GetPremium(BYTE type)
return m_aiPremiumTimes[type]; return m_aiPremiumTimes[type];
} }
DWORD * CLoginData::GetPremiumPtr() DWORD *CLoginData::GetPremiumPtr()
{ {
return &m_aiPremiumTimes[0]; return &m_aiPremiumTimes[0];
} }

View File

@ -4,55 +4,55 @@
class CLoginData class CLoginData
{ {
public: public:
CLoginData(); CLoginData();
TAccountTable & GetAccountRef(); TAccountTable &GetAccountRef();
void SetClientKey(const DWORD * c_pdwClientKey); void SetClientKey(const DWORD *c_pdwClientKey);
const DWORD * GetClientKey(); const DWORD *GetClientKey();
void SetKey(DWORD dwKey); void SetKey(DWORD dwKey);
DWORD GetKey(); DWORD GetKey();
void SetConnectedPeerHandle(DWORD dwHandle); void SetConnectedPeerHandle(DWORD dwHandle);
DWORD GetConnectedPeerHandle(); DWORD GetConnectedPeerHandle();
void SetLogonTime(); void SetLogonTime();
DWORD GetLogonTime(); DWORD GetLogonTime();
void SetIP(const char * c_pszIP); void SetIP(const char *c_pszIP);
const char * GetIP(); const char *GetIP();
void SetPlay(bool bOn); void SetPlay(bool bOn);
bool IsPlay(); bool IsPlay();
void SetDeleted(bool bSet); void SetDeleted(bool bSet);
bool IsDeleted(); bool IsDeleted();
time_t GetLastPlayTime() { return m_lastPlayTime; } time_t GetLastPlayTime() { return m_lastPlayTime; }
void SetPremium(DWORD * paiPremiumTimes); void SetPremium(DWORD *paiPremiumTimes);
DWORD GetPremium(BYTE type); DWORD GetPremium(BYTE type);
DWORD * GetPremiumPtr(); DWORD *GetPremiumPtr();
DWORD GetLastPlayerID() const { return m_dwLastPlayerID; } DWORD GetLastPlayerID() const { return m_dwLastPlayerID; }
void SetLastPlayerID(DWORD id) { m_dwLastPlayerID = id; } void SetLastPlayerID(DWORD id) { m_dwLastPlayerID = id; }
private: private:
DWORD m_dwKey; DWORD m_dwKey;
DWORD m_adwClientKey[4]; DWORD m_adwClientKey[4];
DWORD m_dwConnectedPeerHandle; DWORD m_dwConnectedPeerHandle;
DWORD m_dwLogonTime; DWORD m_dwLogonTime;
char m_szIP[MAX_HOST_LENGTH+1]; char m_szIP[MAX_HOST_LENGTH + 1];
bool m_bPlay; bool m_bPlay;
bool m_bDeleted; bool m_bDeleted;
time_t m_lastPlayTime; time_t m_lastPlayTime;
DWORD m_aiPremiumTimes[PREMIUM_MAX_NUM]; DWORD m_aiPremiumTimes[PREMIUM_MAX_NUM];
DWORD m_dwLastPlayerID; DWORD m_dwLastPlayerID;
TAccountTable m_data; TAccountTable m_data;
}; };
#endif #endif

View File

@ -10,38 +10,33 @@
#include "Marriage.h" #include "Marriage.h"
#include "Monarch.h" #include "Monarch.h"
#include "ItemIDRangeManager.h" #include "ItemIDRangeManager.h"
#ifndef __INTELLISENSE__
#include <version.h> #include <version.h>
#ifdef __AUCTION__ #else
#include "AuctionManager.h" #include <../../../common/version.h>
#endif #endif
#include <signal.h> #include <signal.h>
void SetTablePostfix(const char* c_pszTablePostfix); void SetTablePostfix(const char *c_pszTablePostfix);
int Start(); int Start();
std::string g_stTablePostfix; std::string g_stTablePostfix;
std::string g_stLocaleNameColumn = "name"; std::string g_stLocaleNameColumn = "name";
std::string g_stLocale = "euckr"; std::string g_stLocale = "euckr";
BOOL g_test_server = false; BOOL g_test_server = false;
//단위 초 // 단위 초
int g_iPlayerCacheFlushSeconds = 60*7; int g_iPlayerCacheFlushSeconds = 60 * 7;
int g_iItemCacheFlushSeconds = 60*5; int g_iItemCacheFlushSeconds = 60 * 5;
//g_iLogoutSeconds 수치는 g_iPlayerCacheFlushSeconds 와 g_iItemCacheFlushSeconds 보다 길어야 한다.
int g_iLogoutSeconds = 60*10;
// g_iLogoutSeconds 수치는 g_iPlayerCacheFlushSeconds 와 g_iItemCacheFlushSeconds 보다 길어야 한다.
int g_iLogoutSeconds = 60 * 10;
// MYSHOP_PRICE_LIST // MYSHOP_PRICE_LIST
int g_iItemPriceListTableCacheFlushSeconds = 540; int g_iItemPriceListTableCacheFlushSeconds = 540;
// END_OF_MYSHOP_PRICE_LIST // END_OF_MYSHOP_PRICE_LIST
#ifdef __FreeBSD__
extern const char * _malloc_options;
#endif
void emergency_sig(int sig) void emergency_sig(int sig)
{ {
if (sig == SIGSEGV) if (sig == SIGSEGV)
@ -56,14 +51,10 @@ void emergency_sig(int sig)
int main() int main()
{ {
WriteVersion(); WriteVersion();
log_init(); log_init();
#ifdef __FreeBSD__
_malloc_options = "A";
#endif
CConfig Config; CConfig Config;
CDBManager DBManager; CDBManager DBManager;
CClientManager ClientManager; CClientManager ClientManager;
CGuildManager GuildManager; CGuildManager GuildManager;
CPrivManager PrivManager; CPrivManager PrivManager;
@ -72,18 +63,12 @@ int main()
marriage::CManager MarriageManager; marriage::CManager MarriageManager;
CMonarch Monarch; CMonarch Monarch;
CItemIDRangeManager ItemIDRangeManager; CItemIDRangeManager ItemIDRangeManager;
#ifdef __AUCTION__
AuctionManager auctionManager;
#endif
if (!Start()) if (!Start())
return 1; return 1;
GuildManager.Initialize(); GuildManager.Initialize();
MarriageManager.Initialize(); MarriageManager.Initialize();
ItemIDRangeManager.Build(); ItemIDRangeManager.Build();
#ifdef __AUCTION__
AuctionManager::instance().Initialize();
#endif
SPDLOG_DEBUG("Metin2DBCacheServer Start"); SPDLOG_DEBUG("Metin2DBCacheServer Start");
CClientManager::instance().MainLoop(); CClientManager::instance().MainLoop();
@ -91,30 +76,32 @@ int main()
signal_timer_disable(); signal_timer_disable();
DBManager.Quit(); DBManager.Quit();
int iCount;
while (true) // TODO Check if this is really needed, this should just be cleaning up queued queries
{ // int iCount;
iCount = 0;
iCount += CDBManager::instance().CountReturnQuery(SQL_PLAYER); // while (true)
iCount += CDBManager::instance().CountAsyncQuery(SQL_PLAYER); // {
// iCount = 0;
if (iCount == 0) // iCount += CDBManager::instance().CountReturnQuery(SQL_PLAYER);
break; // iCount += CDBManager::instance().CountAsyncQuery(SQL_PLAYER);
usleep(1000); // if (iCount == 0)
SPDLOG_DEBUG("WAITING_QUERY_COUNT {}", iCount); // break;
}
log_destroy(); // usleep(1000);
// SPDLOG_DEBUG("WAITING_QUERY_COUNT {}", iCount);
// }
log_destroy();
return 1; return 1;
} }
void emptybeat(LPHEART heart, int pulse) void emptybeat(LPHEART heart, int pulse)
{ {
if (!(pulse % heart->passes_per_sec)) // 1초에 한번 if (!(pulse % heart->passes_per_sec)) // 1초에 한번
{ {
} }
} }
@ -135,7 +122,7 @@ int Start()
SPDLOG_INFO("Real Server"); SPDLOG_INFO("Real Server");
} }
else else
SPDLOG_INFO("Test Server"); SPDLOG_INFO("Test Server");
int tmpValue; int tmpValue;
@ -148,7 +135,7 @@ int Start()
if (CConfig::instance().GetValue("LOG_LEVEL", &tmpValue)) if (CConfig::instance().GetValue("LOG_LEVEL", &tmpValue))
{ {
SPDLOG_INFO("Setting log level to {}", tmpValue); SPDLOG_INFO("Setting log level to {}", tmpValue);
tmpValue = std::clamp(tmpValue, SPDLOG_LEVEL_TRACE, SPDLOG_LEVEL_OFF); tmpValue = std::clamp(tmpValue, SPDLOG_LEVEL_TRACE, SPDLOG_LEVEL_OFF);
log_set_level(tmpValue); log_set_level(tmpValue);
} }
@ -156,7 +143,7 @@ int Start()
thecore_init(heart_beat, emptybeat); thecore_init(heart_beat, emptybeat);
signal_timer_enable(60); signal_timer_enable(60);
char szBuf[256+1]; char szBuf[256 + 1];
if (CConfig::instance().GetValue("LOCALE", szBuf, 256)) if (CConfig::instance().GetValue("LOCALE", szBuf, 256))
{ {
@ -181,20 +168,21 @@ int Start()
if (CConfig::instance().GetValue("ITEM_CACHE_FLUSH_SECONDS", szBuf, 256)) if (CConfig::instance().GetValue("ITEM_CACHE_FLUSH_SECONDS", szBuf, 256))
{ {
str_to_number(g_iItemCacheFlushSeconds, szBuf); str_to_number(g_iItemCacheFlushSeconds, szBuf);
SPDLOG_INFO("ITEM_CACHE_FLUSH_SECONDS: {}", g_iItemCacheFlushSeconds); SPDLOG_INFO("ITEM_CACHE_FLUSH_SECONDS: {}", g_iItemCacheFlushSeconds);
} }
// MYSHOP_PRICE_LIST // MYSHOP_PRICE_LIST
if (CConfig::instance().GetValue("ITEM_PRICELIST_CACHE_FLUSH_SECONDS", szBuf, 256)) if (CConfig::instance().GetValue("ITEM_PRICELIST_CACHE_FLUSH_SECONDS", szBuf, 256))
{ {
str_to_number(g_iItemPriceListTableCacheFlushSeconds, szBuf); str_to_number(g_iItemPriceListTableCacheFlushSeconds, szBuf);
SPDLOG_INFO("ITEM_PRICELIST_CACHE_FLUSH_SECONDS: {}", g_iItemPriceListTableCacheFlushSeconds); SPDLOG_INFO("ITEM_PRICELIST_CACHE_FLUSH_SECONDS: {}", g_iItemPriceListTableCacheFlushSeconds);
} }
// END_OF_MYSHOP_PRICE_LIST // END_OF_MYSHOP_PRICE_LIST
// //
if (CConfig::instance().GetValue("CACHE_FLUSH_LIMIT_PER_SECOND", szBuf, 256)) if (CConfig::instance().GetValue("CACHE_FLUSH_LIMIT_PER_SECOND", szBuf, 256))
{ {
DWORD dwVal = 0; str_to_number(dwVal, szBuf); DWORD dwVal = 0;
str_to_number(dwVal, szBuf);
CClientManager::instance().SetCacheFlushCountLimit(dwVal); CClientManager::instance().SetCacheFlushCountLimit(dwVal);
} }
@ -215,77 +203,33 @@ int Start()
char szAddr[64], szDB[64], szUser[64], szPassword[64]; char szAddr[64], szDB[64], szUser[64], szPassword[64];
int iPort; int iPort;
char line[256+1]; char line[256 + 1];
if (CConfig::instance().GetValue("SQL_PLAYER", line, 256)) { sscanf(line, " %s %s %s %s %d ", szAddr, szDB, szUser, szPassword, &iPort);
sscanf(line, " %s %s %s %s %d ", szAddr, szDB, szUser, szPassword, &iPort); SPDLOG_DEBUG("Connecting to PostgreSQL server");
SPDLOG_DEBUG("Connecting to MySQL server (player)");
if (!CDBManager::instance().Connect(SQL_PLAYER, szAddr, iPort, szDB, szUser, szPassword)) { if (!CDBManager::instance().Connect(szAddr, iPort, szDB, szUser, szPassword))
SPDLOG_CRITICAL("Connection to MySQL server (player) failed!"); {
return false; SPDLOG_CRITICAL("Connection to PostgreSQL server failed!");
}
SPDLOG_INFO("Connected to MySQL server (player)");
}
else {
SPDLOG_CRITICAL("SQL_PLAYER not configured");
return false; return false;
} }
if (CConfig::instance().GetValue("SQL_ACCOUNT", line, 256)) { SPDLOG_INFO("Connected to PostgreSQL server");
sscanf(line, " %s %s %s %s %d ", szAddr, szDB, szUser, szPassword, &iPort);
SPDLOG_DEBUG("Connecting to MySQL server (account)");
if (!CDBManager::instance().Connect(SQL_ACCOUNT, szAddr, iPort, szDB, szUser, szPassword)) {
SPDLOG_CRITICAL("Connection to MySQL server (account) failed!");
return false;
}
SPDLOG_INFO("Connected to MySQL server (account)");
}
else
{
SPDLOG_CRITICAL("SQL_ACCOUNT not configured");
return false;
}
if (CConfig::instance().GetValue("SQL_COMMON", line, 256))
{
sscanf(line, " %s %s %s %s %d ", szAddr, szDB, szUser, szPassword, &iPort);
SPDLOG_DEBUG("Connecting to MySQL server (common)");
if (!CDBManager::instance().Connect(SQL_COMMON, szAddr, iPort, szDB, szUser, szPassword))
{
SPDLOG_CRITICAL("Connection to MySQL server (common) failed!");
return false;
}
SPDLOG_INFO("Connected to MySQL server (common)");
}
else
{
SPDLOG_CRITICAL("SQL_COMMON not configured");
return false;
}
if (!CClientManager::instance().Initialize()) if (!CClientManager::instance().Initialize())
{ {
SPDLOG_ERROR("ClientManager initialization failed"); SPDLOG_ERROR("ClientManager initialization failed");
return false; return false;
} }
SPDLOG_INFO("ClientManager initialization OK"); SPDLOG_INFO("ClientManager initialization OK");
#ifndef __WIN32__
signal(SIGUSR1, emergency_sig); signal(SIGUSR1, emergency_sig);
#endif
signal(SIGSEGV, emergency_sig); signal(SIGSEGV, emergency_sig);
return true; return true;
} }
void SetTablePostfix(const char* c_pszTablePostfix) void SetTablePostfix(const char *c_pszTablePostfix)
{ {
if (!c_pszTablePostfix || !*c_pszTablePostfix) if (!c_pszTablePostfix || !*c_pszTablePostfix)
g_stTablePostfix = ""; g_stTablePostfix = "";
@ -293,7 +237,7 @@ void SetTablePostfix(const char* c_pszTablePostfix)
g_stTablePostfix = c_pszTablePostfix; g_stTablePostfix = c_pszTablePostfix;
} }
const char * GetTablePostfix() const char *GetTablePostfix()
{ {
return g_stTablePostfix.c_str(); return g_stTablePostfix.c_str();
} }

View File

@ -1,9 +1,7 @@
#ifndef __INC_MAIN_H__ #ifndef __INC_MAIN_H__
#define __INC_MAIN_H__ #define __INC_MAIN_H__
int Start(); int Start();
void End(); const char *GetTablePostfix();
const char * GetTablePostfix();
const char * GetPlayerDBName();
#endif #endif

View File

@ -7,17 +7,17 @@
namespace marriage namespace marriage
{ {
const DWORD WEDDING_LENGTH = 60 * 60; // sec const DWORD WEDDING_LENGTH = 60 * 60; // sec
bool operator < (const TWedding& lhs, const TWedding& rhs) bool operator<(const TWedding &lhs, const TWedding &rhs)
{ {
return lhs.dwTime < rhs.dwTime; return lhs.dwTime < rhs.dwTime;
} }
bool operator > (const TWedding& lhs, const TWedding& rhs) bool operator>(const TWedding &lhs, const TWedding &rhs)
{ {
return lhs.dwTime > rhs.dwTime; return lhs.dwTime > rhs.dwTime;
} }
bool operator > (const TWeddingInfo &lhs, const TWeddingInfo& rhs) bool operator>(const TWeddingInfo &lhs, const TWeddingInfo &rhs)
{ {
return lhs.dwTime > rhs.dwTime; return lhs.dwTime > rhs.dwTime;
} }
@ -34,44 +34,53 @@ namespace marriage
bool CManager::Initialize() bool CManager::Initialize()
{ {
char szQuery[1024]; auto pool = CDBManager::instance().GetConnectionPool();
auto conn = pool->acquire();
snprintf(szQuery, sizeof(szQuery), try
"SELECT pid1, pid2, love_point, time, is_married, p1.name, p2.name FROM marriage, player%s as p1, player%s as p2 WHERE p1.id = pid1 AND p2.id = pid2",
GetTablePostfix(), GetTablePostfix());
unique_ptr<SQLMsg> pmsg_delete(CDBManager::instance().DirectQuery("DELETE FROM marriage WHERE is_married = 0"));
unique_ptr<SQLMsg> pmsg(CDBManager::instance().DirectQuery(szQuery));
SQLResult * pRes = pmsg->Get();
SPDLOG_DEBUG("MarriageList(size={})", pRes->uiNumRows);
if (pRes->uiNumRows > 0)
{ {
for (uint uiRow = 0; uiRow != pRes->uiNumRows; ++uiRow) pqxx::work txn{*conn};
txn.exec("DELETE FROM player.marriage WHERE is_married = false");
pqxx::result result = txn.exec("SELECT player_id_1, player_id_2, love_points, created_at, is_married, p1.name, p2.name FROM player.marriage, player.player as p1, player.player as p2 WHERE p1.id = player_id_1 AND p2.id = player_id_2");
std::size_t const numRows = std::size(result);
SPDLOG_DEBUG("MarriageList(size={})", numRows);
for (auto row : result)
{ {
MYSQL_ROW row = mysql_fetch_row(pRes->pSQLResult); DWORD pid1 = 0;
str_to_number(pid1, row[0].c_str());
DWORD pid2 = 0;
str_to_number(pid2, row[1].c_str());
int love_point = 0;
str_to_number(love_point, row[2].c_str());
DWORD time = 0;
str_to_number(time, row[3].c_str());
BYTE is_married = 0;
str_to_number(is_married, row[4].c_str());
const char *name1 = row[5].c_str();
const char *name2 = row[6].c_str();
DWORD pid1 = 0; str_to_number(pid1, row[0]); TMarriage *pMarriage = new TMarriage(pid1, pid2, love_point, time, is_married, name1, name2);
DWORD pid2 = 0; str_to_number(pid2, row[1]);
int love_point = 0; str_to_number(love_point, row[2]);
DWORD time = 0; str_to_number(time, row[3]);
BYTE is_married = 0; str_to_number(is_married, row[4]);
const char* name1 = row[5];
const char* name2 = row[6];
TMarriage* pMarriage = new TMarriage(pid1, pid2, love_point, time, is_married, name1, name2);
m_Marriages.insert(pMarriage); m_Marriages.insert(pMarriage);
m_MarriageByPID.insert(make_pair(pid1, pMarriage)); m_MarriageByPID.insert(make_pair(pid1, pMarriage));
m_MarriageByPID.insert(make_pair(pid2, pMarriage)); m_MarriageByPID.insert(make_pair(pid2, pMarriage));
SPDLOG_DEBUG("Marriage {}: LP:{} TM:{} ST:{} {:10}:{:16} {:10}:{:16} ", uiRow, love_point, time, is_married, pid1, name1, pid2, name2); SPDLOG_DEBUG("Marriage {}: LP:{} TM:{} ST:{} {:10}:{:16} {:10}:{:16} ", uiRow, love_point, time, is_married, pid1, name1, pid2, name2);
} }
txn.commit();
} }
catch (const std::exception &e)
{
SPDLOG_ERROR("[CManager::Initialize] Query error: {}", e.what());
return false;
}
return true; return true;
} }
TMarriage* CManager::Get(DWORD dwPlayerID) TMarriage *CManager::Get(DWORD dwPlayerID)
{ {
itertype(m_MarriageByPID) it = m_MarriageByPID.find(dwPlayerID); itertype(m_MarriageByPID) it = m_MarriageByPID.find(dwPlayerID);
@ -81,13 +90,13 @@ namespace marriage
return NULL; return NULL;
} }
void Align(DWORD& rPID1, DWORD& rPID2) void Align(DWORD &rPID1, DWORD &rPID2)
{ {
if (rPID1 > rPID2) if (rPID1 > rPID2)
std::swap(rPID1, rPID2); std::swap(rPID1, rPID2);
} }
void CManager::Add(DWORD dwPID1, DWORD dwPID2, const char* szName1, const char* szName2) void CManager::Add(DWORD dwPID1, DWORD dwPID2, const char *szName1, const char *szName2)
{ {
DWORD now = CClientManager::instance().GetCurrentTime(); DWORD now = CClientManager::instance().GetCurrentTime();
if (IsMarried(dwPID1) || IsMarried(dwPID2)) if (IsMarried(dwPID1) || IsMarried(dwPID2))
@ -98,21 +107,32 @@ namespace marriage
Align(dwPID1, dwPID2); Align(dwPID1, dwPID2);
char szQuery[512]; auto pool = CDBManager::instance().GetConnectionPool();
snprintf(szQuery, sizeof(szQuery), "INSERT INTO marriage(pid1, pid2, love_point, time) VALUES (%u, %u, 0, %u)", dwPID1, dwPID2, now); auto conn = pool->acquire();
unique_ptr<SQLMsg> pmsg(CDBManager::instance().DirectQuery(szQuery)); try
SQLResult* res = pmsg->Get();
if (res->uiAffectedRows == 0 || res->uiAffectedRows == (uint32_t)-1)
{ {
SPDLOG_ERROR("cannot insert marriage"); pqxx::work txn{*conn};
pqxx::result result = txn.exec_params("INSERT INTO player.marriage(player_id_1, player_id_2, love_points, created_at) VALUES ($1, $2, 0, $3) RETURNING id", dwPID1, dwPID2, now);
std::size_t const numRows = std::size(result);
if (numRows == 0)
{
SPDLOG_ERROR("cannot insert marriage");
return;
}
txn.commit();
}
catch (const std::exception &e)
{
SPDLOG_ERROR("[CManager::Add] Query error: {}", e.what());
return; return;
} }
SPDLOG_DEBUG("MARRIAGE ADD {} {}", dwPID1, dwPID2); SPDLOG_DEBUG("MARRIAGE ADD {} {}", dwPID1, dwPID2);
TMarriage* pMarriage = new TMarriage(dwPID1, dwPID2, 0, now, 0, szName1, szName2); TMarriage *pMarriage = new TMarriage(dwPID1, dwPID2, 0, now, 0, szName1, szName2);
m_Marriages.insert(pMarriage); m_Marriages.insert(pMarriage);
m_MarriageByPID.insert(make_pair(dwPID1, pMarriage)); m_MarriageByPID.insert(make_pair(dwPID1, pMarriage));
m_MarriageByPID.insert(make_pair(dwPID2, pMarriage)); m_MarriageByPID.insert(make_pair(dwPID2, pMarriage));
@ -128,7 +148,7 @@ namespace marriage
void CManager::Update(DWORD dwPID1, DWORD dwPID2, INT iLovePoint, BYTE byMarried) void CManager::Update(DWORD dwPID1, DWORD dwPID2, INT iLovePoint, BYTE byMarried)
{ {
TMarriage* pMarriage = Get(dwPID1); TMarriage *pMarriage = Get(dwPID1);
if (!pMarriage || pMarriage->GetOther(dwPID1) != dwPID2) if (!pMarriage || pMarriage->GetOther(dwPID1) != dwPID2)
{ {
SPDLOG_ERROR("not under marriage : {} {}", dwPID1, dwPID2); SPDLOG_ERROR("not under marriage : {} {}", dwPID1, dwPID2);
@ -137,16 +157,26 @@ namespace marriage
Align(dwPID1, dwPID2); Align(dwPID1, dwPID2);
char szQuery[512]; auto pool = CDBManager::instance().GetConnectionPool();
snprintf(szQuery, sizeof(szQuery), "UPDATE marriage SET love_point = %d, is_married = %d WHERE pid1 = %u AND pid2 = %u", auto conn = pool->acquire();
iLovePoint, byMarried, pMarriage->pid1, pMarriage->pid2);
unique_ptr<SQLMsg> pmsg(CDBManager::instance().DirectQuery(szQuery)); try
SQLResult* res = pmsg->Get();
if (res->uiAffectedRows == 0 || res->uiAffectedRows == (uint32_t)-1)
{ {
SPDLOG_ERROR("cannot update marriage : PID:{} {}", dwPID1, dwPID2); pqxx::work txn{*conn};
pqxx::result result = txn.exec_params("UPDATE player.marriage SET love_points=$1, is_married=$2 WHERE player_id_1=$3 AND player_id_2=$4 RETURNING id", iLovePoint, byMarried, pMarriage->pid1, pMarriage->pid2);
std::size_t const numRows = std::size(result);
if (numRows == 0)
{
SPDLOG_ERROR("cannot update marriage : PID:{} {}", dwPID1, dwPID2);
return;
}
txn.commit();
}
catch (const std::exception &e)
{
SPDLOG_ERROR("[CManager::Update] Query error: {}", e.what());
return; return;
} }
@ -164,7 +194,7 @@ namespace marriage
void CManager::Remove(DWORD dwPID1, DWORD dwPID2) void CManager::Remove(DWORD dwPID1, DWORD dwPID2)
{ {
TMarriage* pMarriage = Get(dwPID1); TMarriage *pMarriage = Get(dwPID1);
if (pMarriage) if (pMarriage)
{ {
@ -184,15 +214,26 @@ namespace marriage
Align(dwPID1, dwPID2); Align(dwPID1, dwPID2);
char szQuery[512]; auto pool = CDBManager::instance().GetConnectionPool();
snprintf(szQuery, sizeof(szQuery), "DELETE FROM marriage WHERE pid1 = %u AND pid2 = %u", dwPID1, dwPID2); auto conn = pool->acquire();
unique_ptr<SQLMsg> pmsg(CDBManager::instance().DirectQuery(szQuery)); try
SQLResult* res = pmsg->Get();
if (res->uiAffectedRows == 0 || res->uiAffectedRows == (uint32_t)-1)
{ {
SPDLOG_ERROR("cannot delete marriage : PID:{} {}", dwPID1, dwPID2); pqxx::work txn{*conn};
pqxx::result result = txn.exec_params("DELETE FROM player.marriage WHERE player_id_1=$1 AND player_id_2=$2", dwPID1, dwPID2);
std::size_t const numRows = std::size(result);
if (numRows == 0)
{
SPDLOG_ERROR("cannot delete marriage : PID:{} {}", dwPID1, dwPID2);
return;
}
txn.commit();
}
catch (const std::exception &e)
{
SPDLOG_ERROR("[CManager::Remove] Query error: {}", e.what());
return; return;
} }
@ -212,7 +253,7 @@ namespace marriage
void CManager::EngageToMarriage(DWORD dwPID1, DWORD dwPID2) void CManager::EngageToMarriage(DWORD dwPID1, DWORD dwPID2)
{ {
TMarriage* pMarriage = Get(dwPID1); TMarriage *pMarriage = Get(dwPID1);
if (!pMarriage || pMarriage->GetOther(dwPID1) != dwPID2) if (!pMarriage || pMarriage->GetOther(dwPID1) != dwPID2)
{ {
SPDLOG_ERROR("not under marriage : PID:{} {}", dwPID1, dwPID2); SPDLOG_ERROR("not under marriage : PID:{} {}", dwPID1, dwPID2);
@ -227,16 +268,26 @@ namespace marriage
Align(dwPID1, dwPID2); Align(dwPID1, dwPID2);
char szQuery[512]; auto pool = CDBManager::instance().GetConnectionPool();
snprintf(szQuery, sizeof(szQuery), "UPDATE marriage SET is_married = 1 WHERE pid1 = %u AND pid2 = %u", auto conn = pool->acquire();
pMarriage->pid1, pMarriage->pid2);
unique_ptr<SQLMsg> pmsg(CDBManager::instance().DirectQuery(szQuery)); try
SQLResult* res = pmsg->Get();
if (res->uiAffectedRows == 0 || res->uiAffectedRows == (uint32_t)-1)
{ {
SPDLOG_ERROR("cannot change engage to marriage : PID:{} {}", dwPID1, dwPID2); pqxx::work txn{*conn};
pqxx::result result = txn.exec_params("UPDATE player.marriage SET is_married = 1 WHERE player_id_1=$1 AND player_id_2=$2", pMarriage->pid1, pMarriage->pid2);
std::size_t const numRows = std::size(result);
if (numRows == 0)
{
SPDLOG_ERROR("cannot change engage to marriage : PID:{} {}", dwPID1, dwPID2);
return;
}
txn.commit();
}
catch (const std::exception &e)
{
SPDLOG_ERROR("[CManager::EngageToMarriage] Query error: {}", e.what());
return; return;
} }
@ -251,12 +302,12 @@ namespace marriage
CClientManager::instance().ForwardPacket(HEADER_DG_MARRIAGE_UPDATE, &p, sizeof(p)); CClientManager::instance().ForwardPacket(HEADER_DG_MARRIAGE_UPDATE, &p, sizeof(p));
} }
void CManager::OnSetup(CPeer* peer) void CManager::OnSetup(CPeer *peer)
{ {
// 결혼한 사람들 보내기 // 결혼한 사람들 보내기
for (itertype(m_Marriages) it = m_Marriages.begin(); it != m_Marriages.end(); ++it) for (itertype(m_Marriages) it = m_Marriages.begin(); it != m_Marriages.end(); ++it)
{ {
TMarriage* pMarriage = *it; TMarriage *pMarriage = *it;
{ {
TPacketMarriageAdd p; TPacketMarriageAdd p;
@ -274,7 +325,7 @@ namespace marriage
p.dwPID1 = pMarriage->pid1; p.dwPID1 = pMarriage->pid1;
p.dwPID2 = pMarriage->pid2; p.dwPID2 = pMarriage->pid2;
p.iLovePoint = pMarriage->love_point; p.iLovePoint = pMarriage->love_point;
p.byMarried = pMarriage->is_married; p.byMarried = pMarriage->is_married;
peer->EncodeHeader(HEADER_DG_MARRIAGE_UPDATE, 0, sizeof(p)); peer->EncodeHeader(HEADER_DG_MARRIAGE_UPDATE, 0, sizeof(p));
peer->Encode(&p, sizeof(p)); peer->Encode(&p, sizeof(p));
} }
@ -283,7 +334,7 @@ namespace marriage
// 결혼식 보내기 // 결혼식 보내기
for (itertype(m_mapRunningWedding) it = m_mapRunningWedding.begin(); it != m_mapRunningWedding.end(); ++it) for (itertype(m_mapRunningWedding) it = m_mapRunningWedding.begin(); it != m_mapRunningWedding.end(); ++it)
{ {
const TWedding& t = it->second; const TWedding &t = it->second;
TPacketWeddingReady p; TPacketWeddingReady p;
p.dwPID1 = t.dwPID1; p.dwPID1 = t.dwPID1;
@ -317,7 +368,7 @@ namespace marriage
return; return;
} }
TWedding& w = it->second; TWedding &w = it->second;
TPacketWeddingEnd p; TPacketWeddingEnd p;
p.dwPID1 = w.dwPID1; p.dwPID1 = w.dwPID1;
@ -341,7 +392,7 @@ namespace marriage
if (it == m_mapRunningWedding.end()) if (it == m_mapRunningWedding.end())
continue; continue;
TWedding& w = it->second; TWedding &w = it->second;
TPacketWeddingEnd p; TPacketWeddingEnd p;
p.dwPID1 = w.dwPID1; p.dwPID1 = w.dwPID1;
@ -353,7 +404,7 @@ namespace marriage
if (it_marriage != m_MarriageByPID.end()) if (it_marriage != m_MarriageByPID.end())
{ {
TMarriage* pMarriage = it_marriage->second; TMarriage *pMarriage = it_marriage->second;
if (!pMarriage->is_married) if (!pMarriage->is_married)
{ {
Remove(pMarriage->pid1, pMarriage->pid2); Remove(pMarriage->pid1, pMarriage->pid2);

View File

@ -17,8 +17,8 @@ namespace marriage
DWORD dwPID2; DWORD dwPID2;
TWeddingInfo(DWORD time, DWORD pid1, DWORD pid2) TWeddingInfo(DWORD time, DWORD pid1, DWORD pid2)
: dwTime(time), : dwTime(time),
dwPID1(pid1), dwPID1(pid1),
dwPID2(pid2) dwPID2(pid2)
{ {
} }
}; };
@ -32,28 +32,28 @@ namespace marriage
TWedding(DWORD time, DWORD dwMapIndex, DWORD pid1, DWORD pid2) TWedding(DWORD time, DWORD dwMapIndex, DWORD pid1, DWORD pid2)
: dwTime(time), : dwTime(time),
dwMapIndex(dwMapIndex), dwMapIndex(dwMapIndex),
dwPID1(pid1), dwPID1(pid1),
dwPID2(pid2) dwPID2(pid2)
{ {
} }
}; };
extern bool operator < (const TWedding& lhs, const TWedding& rhs); extern bool operator<(const TWedding &lhs, const TWedding &rhs);
extern bool operator > (const TWedding& lhs, const TWedding& rhs); extern bool operator>(const TWedding &lhs, const TWedding &rhs);
extern bool operator > (const TWeddingInfo& lhs, const TWeddingInfo& rhs); extern bool operator>(const TWeddingInfo &lhs, const TWeddingInfo &rhs);
struct TMarriage struct TMarriage
{ {
DWORD pid1; DWORD pid1;
DWORD pid2; DWORD pid2;
int love_point; int love_point;
DWORD time; DWORD time;
BYTE is_married; // false : 약혼 상태, true : 결혼 상태 BYTE is_married; // false : 약혼 상태, true : 결혼 상태
std::string name1; std::string name1;
std::string name2; std::string name2;
TMarriage(DWORD _pid1, DWORD _pid2, int _love_point, DWORD _time, BYTE _is_married, const char* name1, const char* name2) TMarriage(DWORD _pid1, DWORD _pid2, int _love_point, DWORD _time, BYTE _is_married, const char *name1, const char *name2)
: pid1(_pid1), pid2(_pid2), love_point(_love_point), time(_time), is_married(_is_married), name1(name1), name2(name2) : pid1(_pid1), pid2(_pid2), love_point(_love_point), time(_time), is_married(_is_married), name1(name1), name2(name2)
{ {
} }
@ -72,41 +72,41 @@ namespace marriage
class CManager : public singleton<CManager> class CManager : public singleton<CManager>
{ {
public: public:
CManager(); CManager();
virtual ~CManager(); virtual ~CManager();
bool Initialize(); bool Initialize();
TMarriage* Get(DWORD dwPlayerID); TMarriage *Get(DWORD dwPlayerID);
bool IsMarried(DWORD dwPlayerID) bool IsMarried(DWORD dwPlayerID)
{ {
return Get(dwPlayerID) != NULL; return Get(dwPlayerID) != NULL;
} }
//void Reserve(DWORD dwPID1, DWORD dwPID2); // void Reserve(DWORD dwPID1, DWORD dwPID2);
void Add(DWORD dwPID1, DWORD dwPID2, const char* szName1, const char* szName2); void Add(DWORD dwPID1, DWORD dwPID2, const char *szName1, const char *szName2);
void Remove(DWORD dwPID1, DWORD dwPID2); void Remove(DWORD dwPID1, DWORD dwPID2);
void Update(DWORD dwPID1, DWORD dwPID2, INT iLovePoint, BYTE byMarried); void Update(DWORD dwPID1, DWORD dwPID2, INT iLovePoint, BYTE byMarried);
void EngageToMarriage(DWORD dwPID1, DWORD dwPID2); void EngageToMarriage(DWORD dwPID1, DWORD dwPID2);
void ReadyWedding(DWORD dwMapIndex, DWORD dwPID1, DWORD dwPID2); void ReadyWedding(DWORD dwMapIndex, DWORD dwPID1, DWORD dwPID2);
void EndWedding(DWORD dwPID1, DWORD dwPID2); void EndWedding(DWORD dwPID1, DWORD dwPID2);
void OnSetup(CPeer* peer); void OnSetup(CPeer *peer);
void Update(); void Update();
private: private:
std::set<TMarriage *> m_Marriages; std::set<TMarriage *> m_Marriages;
std::map<DWORD, TMarriage *> m_MarriageByPID; std::map<DWORD, TMarriage *> m_MarriageByPID;
std::priority_queue<TWedding, std::vector<TWedding>, std::greater<TWedding> > m_pqWeddingStart; std::priority_queue<TWedding, std::vector<TWedding>, std::greater<TWedding>> m_pqWeddingStart;
std::priority_queue<TWeddingInfo, std::vector<TWeddingInfo>, std::greater<TWeddingInfo> > m_pqWeddingEnd; std::priority_queue<TWeddingInfo, std::vector<TWeddingInfo>, std::greater<TWeddingInfo>> m_pqWeddingEnd;
std::map<std::pair<DWORD, DWORD>, TWedding> m_mapRunningWedding; std::map<std::pair<DWORD, DWORD>, TWedding> m_mapRunningWedding;
}; };
} }

View File

@ -22,17 +22,15 @@ bool CMonarch::VoteMonarch(DWORD pid, DWORD selectdpid)
if (it == m_map_MonarchElection.end()) if (it == m_map_MonarchElection.end())
{ {
MonarchElectionInfo * p = new MonarchElectionInfo; MonarchElectionInfo *p = new MonarchElectionInfo;
p->pid = pid; p->pid = pid;
p->selectedpid= selectdpid; p->selectedpid = selectdpid;
m_map_MonarchElection.insert(MAP_MONARCHELECTION::value_type(pid, p)); m_map_MonarchElection.insert(MAP_MONARCHELECTION::value_type(pid, p));
char szQuery[256]; CDBManager::instance().AsyncQuery(
snprintf(szQuery, sizeof(szQuery), "INSERT INTO player.monarch_election(player_id, selected_player_id, election_at) VALUES($1, $2, now())",
"INSERT INTO monarch_election(pid, selectedpid, electiondata) VALUES(%d, %d, now())", pid, selectdpid); pqxx::params(pid, selectdpid));
return 1;
CDBManager::instance().AsyncQuery(szQuery);
return 1;
} }
return 0; return 0;
@ -42,15 +40,15 @@ void CMonarch::ElectMonarch()
{ {
int size = GetVecMonarchCandidacy().size(); int size = GetVecMonarchCandidacy().size();
int * s = new int[size]; int *s = new int[size];
itertype(m_map_MonarchElection) it = m_map_MonarchElection.begin(); itertype(m_map_MonarchElection) it = m_map_MonarchElection.begin();
int idx = 0; int idx = 0;
for (; it != m_map_MonarchElection.end(); ++it) for (; it != m_map_MonarchElection.end(); ++it)
{ {
if ((idx = GetCandidacyIndex(it->second->pid)) < 0) if ((idx = GetCandidacyIndex(it->second->pid)) < 0)
continue; continue;
++s[idx]; ++s[idx];
@ -58,23 +56,23 @@ void CMonarch::ElectMonarch()
SPDLOG_TRACE("[MONARCH_VOTE] pid({}) come to vote candidacy pid({})", it->second->pid, m_vec_MonarchCandidacy[idx].pid); SPDLOG_TRACE("[MONARCH_VOTE] pid({}) come to vote candidacy pid({})", it->second->pid, m_vec_MonarchCandidacy[idx].pid);
} }
delete [] s; delete[] s;
} }
bool CMonarch::IsCandidacy(DWORD pid) bool CMonarch::IsCandidacy(DWORD pid)
{ {
VEC_MONARCHCANDIDACY::iterator it = m_vec_MonarchCandidacy.begin(); VEC_MONARCHCANDIDACY::iterator it = m_vec_MonarchCandidacy.begin();
for (; it != m_vec_MonarchCandidacy.end(); ++it) for (; it != m_vec_MonarchCandidacy.end(); ++it)
{ {
if (it->pid == pid) if (it->pid == pid)
return false; return false;
} }
return true; return true;
} }
bool CMonarch::AddCandidacy(DWORD pid, const char * name) bool CMonarch::AddCandidacy(DWORD pid, const char *name)
{ {
if (IsCandidacy(pid) == false) if (IsCandidacy(pid) == false)
return false; return false;
@ -83,34 +81,33 @@ bool CMonarch::AddCandidacy(DWORD pid, const char * name)
info.pid = pid; info.pid = pid;
strlcpy(info.name, name, sizeof(info.name)); strlcpy(info.name, name, sizeof(info.name));
m_vec_MonarchCandidacy.push_back(info); m_vec_MonarchCandidacy.push_back(info);
char szQuery[256]; CDBManager::instance().AsyncQuery(
snprintf(szQuery, sizeof(szQuery), "INSERT INTO player.monarch_candidacy(player_id, date) VALUES($1, now())",
"INSERT INTO monarch_candidacy(pid, date) VALUES(%d, now())", pid); pqxx::params(pid));
CDBManager::instance().AsyncQuery(szQuery);
return true; return true;
} }
bool CMonarch::DelCandidacy(const char * name) bool CMonarch::DelCandidacy(const char *name)
{ {
itertype(m_vec_MonarchCandidacy) it = m_vec_MonarchCandidacy.begin(); itertype(m_vec_MonarchCandidacy) it = m_vec_MonarchCandidacy.begin();
for (; it != m_vec_MonarchCandidacy.end(); ++it) for (; it != m_vec_MonarchCandidacy.end(); ++it)
{ {
if (0 == strncmp(it->name, name, sizeof(it->name))) if (0 == strncmp(it->name, name, sizeof(it->name)))
{ {
char szQuery[256]; CDBManager::instance().AsyncQuery(
snprintf(szQuery, sizeof(szQuery), "DELETE FROM player.monarch_candidacy WHERE player_id=$1",
"DELETE FROM monarch_candidacy WHERE pid=%d ", it->pid); pqxx::params(it->pid));
CDBManager::instance().AsyncQuery(szQuery);
m_vec_MonarchCandidacy.erase(it);
m_vec_MonarchCandidacy.erase (it);
return true; return true;
} }
} }
return false;
return false;
} }
bool CMonarch::IsMonarch(int Empire, DWORD pid) bool CMonarch::IsMonarch(int Empire, DWORD pid)
@ -129,26 +126,25 @@ bool CMonarch::AddMoney(int Empire, int64_t Money)
int64_t Money64 = m_MonarchInfo.money[Empire]; int64_t Money64 = m_MonarchInfo.money[Empire];
char szQuery[1024]; CDBManager::instance().AsyncQuery(
snprintf(szQuery, sizeof(szQuery), "UPDATE monarch set money=%ld where empire=%d", Money64, Empire); "UPDATE player.monarch SET money=$1 WHERE empire=$2",
pqxx::params(Money64, Empire));
CDBManager::instance().AsyncQuery(szQuery);
return true; return true;
} }
bool CMonarch::DecMoney(int Empire, int64_t Money) bool CMonarch::DecMoney(int Empire, int64_t Money)
{ {
if (m_MonarchInfo.money[Empire] - Money < 0) if (m_MonarchInfo.money[Empire] - Money < 0)
return false; return false;
m_MonarchInfo.money[Empire] -= Money; m_MonarchInfo.money[Empire] -= Money;
int64_t Money64 = m_MonarchInfo.money[Empire]; int64_t Money64 = m_MonarchInfo.money[Empire];
char szQuery[1024]; CDBManager::instance().AsyncQuery(
snprintf(szQuery, sizeof(szQuery), "UPDATE monarch set money=%ld where empire=%d", Money64, Empire); "UPDATE player.monarch SET money=$1 WHERE empire=$2",
pqxx::params(Money64, Empire));
CDBManager::instance().AsyncQuery(szQuery);
return true; return true;
} }
@ -159,14 +155,12 @@ bool CMonarch::TakeMoney(int Empire, DWORD pid, int64_t Money)
if (m_MonarchInfo.money[Empire] < Money) if (m_MonarchInfo.money[Empire] < Money)
return false; return false;
m_MonarchInfo.money[Empire] -= Money; m_MonarchInfo.money[Empire] -= Money;
char szQuery[1024]; CDBManager::instance().AsyncQuery(
snprintf(szQuery, sizeof(szQuery), "UPDATE player.monarch SET money=$1 WHERE empire=$2",
"UPDATE monarch set money=%ld; where empire=%d", m_MonarchInfo.money[Empire], Empire); pqxx::params(m_MonarchInfo.money[Empire], Empire));
CDBManager::instance().AsyncQuery(szQuery);
SPDLOG_TRACE("[MONARCH] Take money empire({}) money({})", Empire, m_MonarchInfo.money[Empire]); SPDLOG_TRACE("[MONARCH] Take money empire({}) money({})", Empire, m_MonarchInfo.money[Empire]);
return true; return true;
@ -174,122 +168,157 @@ bool CMonarch::TakeMoney(int Empire, DWORD pid, int64_t Money)
bool CMonarch::LoadMonarch() bool CMonarch::LoadMonarch()
{ {
MonarchInfo * p = &m_MonarchInfo; MonarchInfo *p = &m_MonarchInfo;
char szQuery[256];
snprintf(szQuery, sizeof(szQuery), "SELECT empire, pid, name, money, windate FROM monarch a, player%s b where a.pid=b.id", GetTablePostfix());
SQLMsg * pMsg = CDBManager::instance().DirectQuery(szQuery, SQL_PLAYER);
if (pMsg->Get()->uiNumRows == 0) auto pool = CDBManager::instance().GetConnectionPool();
{ auto conn = pool->acquire();
delete pMsg;
return false;
}
MYSQL_ROW row; try
for (int n = 0; (row = mysql_fetch_row(pMsg->Get()->pSQLResult)) != NULL; ++n) {
{ pqxx::work txn{*conn};
int idx = 0; pqxx::result result = txn.exec("SELECT empire, player_id, name, money, win_at FROM player.monarch m, player.player p WHERE m.player_id=p.id");
int Empire = 0; str_to_number(Empire, row[idx++]); std::size_t const numRows = std::size(result);
str_to_number(p->pid[Empire], row[idx++]); if (numRows == 0)
strlcpy(p->name[Empire], row[idx++], sizeof(p->name[Empire])); {
return false;
}
str_to_number(p->money[Empire], row[idx++]); for (auto row : result)
strlcpy(p->date[Empire], row[idx++], sizeof(p->date[Empire])); {
int Empire = row[0].as<int>();
str_to_number(p->pid[Empire], row[1].c_str());
strlcpy(p->name[Empire], row[2].c_str(), sizeof(p->name[Empire]));
SPDLOG_TRACE("[LOAD_MONARCH] Empire {} pid {} money {} windate {}", Empire, p->pid[Empire], p->money[Empire], p->date[Empire]); str_to_number(p->money[Empire], row[3].c_str());
} strlcpy(p->date[Empire], row[4].c_str(), sizeof(p->date[Empire]));
delete pMsg; SPDLOG_TRACE("[LOAD_MONARCH] Empire {} pid {} money {} windate {}", Empire, p->pid[Empire], p->money[Empire], p->date[Empire]);
return true; }
txn.commit();
}
catch (const std::exception &e)
{
SPDLOG_ERROR("[CMonarch::LoadMonarch] Query error: {}", e.what());
return false;
}
return true;
} }
bool CMonarch::SetMonarch(const char * name) bool CMonarch::SetMonarch(const char *name)
{ {
MonarchInfo * p = &m_MonarchInfo; MonarchInfo *p = &m_MonarchInfo;
char szQuery[256];
snprintf(szQuery, sizeof(szQuery), "SELECT empire, pid, name FROM player a where a.name = '%s'", name); auto pool = CDBManager::instance().GetConnectionPool();
SQLMsg * pMsg = CDBManager::instance().DirectQuery(szQuery, SQL_PLAYER); auto conn = pool->acquire();
if (pMsg->Get()->uiNumRows == 0) try
{ {
delete pMsg; pqxx::work txn{*conn};
return false; // TODO Look at this, this should probably not iterate and just get one value instead
} pqxx::result result = txn.exec_params("SELECT empire, player_id, name, money FROM player.player WHERE name=$1", name);
std::size_t const numRows = std::size(result);
MYSQL_ROW row; if (numRows == 0)
int Empire = 0; {
for (int n = 0; (row = mysql_fetch_row(pMsg->Get()->pSQLResult)) != NULL; ++n) return false;
{ }
int idx = 0;
str_to_number(Empire, row[idx++]);
str_to_number(p->pid[Empire], row[idx++]); int Empire = 0;
strlcpy(p->name[Empire], row[idx++], sizeof(p->name[Empire])); for (auto row : result)
p->money[Empire] = atoll(row[idx++]); {
Empire = row[0].as<int>();
SPDLOG_TRACE("[Set_MONARCH] Empire {} pid {} money {} windate {}", Empire, p->pid[Empire], p->money[Empire], p->date[Empire]);
}
delete pMsg;
//db에 입력 str_to_number(p->pid[Empire], row[1].c_str());
snprintf(szQuery, sizeof(szQuery), strlcpy(p->name[Empire], row[2].c_str(), sizeof(p->name[Empire]));
"REPLACE INTO monarch (empire, name, windate, money) VALUES(%d, %d, now(), %ld)", Empire, p->pid[Empire], p->money[Empire]); p->money[Empire] = atoll(row[3].c_str());
CDBManager::instance().AsyncQuery(szQuery, SQL_PLAYER); SPDLOG_TRACE("[Set_MONARCH] Empire {} pid {} money {} windate {}", Empire, p->pid[Empire], p->money[Empire], p->date[Empire]);
return true; }
txn.commit();
CDBManager::instance().AsyncQuery(
"REPLACE INTO player.monarch (empire, name, win_at, money) VALUES($1, $2, now(), $3)",
pqxx::params{Empire, p->pid[Empire], p->money[Empire]});
}
catch (const std::exception &e)
{
SPDLOG_ERROR("[CMonarch::SetMonarch] Query error: {}", e.what());
return false;
}
return true;
} }
bool CMonarch::DelMonarch(int Empire) bool CMonarch::DelMonarch(int Empire)
{ {
char szQuery[256]; auto pool = CDBManager::instance().GetConnectionPool();
auto conn = pool->acquire();
snprintf(szQuery, sizeof(szQuery), "DELETE from monarch where empire=%d", Empire); try
SQLMsg * pMsg = CDBManager::instance().DirectQuery(szQuery, SQL_PLAYER);
if (pMsg->Get()->uiNumRows == 0)
{ {
delete pMsg; pqxx::work txn{*conn};
pqxx::result result = txn.exec_params("DELETE FROM player.monarch WHERE empire=$1 RETURNING id", Empire);
std::size_t const numRows = std::size(result);
if (numRows == 0)
{
return false;
}
txn.commit();
}
catch (const std::exception &e)
{
SPDLOG_ERROR("[CMonarch::DelMonarch] Query error: {}", e.what());
return false; return false;
} }
delete pMsg;
memset(m_MonarchInfo.name[Empire], 0, sizeof(m_MonarchInfo.name[Empire])); memset(m_MonarchInfo.name[Empire], 0, sizeof(m_MonarchInfo.name[Empire]));
m_MonarchInfo.money[Empire] = 0; m_MonarchInfo.money[Empire] = 0;
m_MonarchInfo.pid[Empire] = 0; m_MonarchInfo.pid[Empire] = 0;
return true; return true;
} }
bool CMonarch::DelMonarch(const char * name) bool CMonarch::DelMonarch(const char *name)
{ {
for (int n = 1; n < 4; ++n) auto pool = CDBManager::instance().GetConnectionPool();
auto conn = pool->acquire();
try
{ {
if (0 == strncmp(m_MonarchInfo.name[n], name, sizeof(m_MonarchInfo.name[n]))) pqxx::work txn{*conn};
pqxx::result result = txn.exec_params("DELETE FROM player.monarch WHERE name=$1 RETURNING empire", name);
std::size_t const numRows = std::size(result);
if (numRows == 0)
{ {
char szQuery[256]; return false;
}
int Empire = n; for (auto row : result)
snprintf(szQuery, sizeof(szQuery), "DELETE from monarch where name=%d", Empire); {
SQLMsg * pMsg = CDBManager::instance().DirectQuery(szQuery, SQL_PLAYER); int Empire = row[0].as<int>();
if (pMsg->Get()->uiNumRows == 0) memset(m_MonarchInfo.name[Empire], 0, sizeof(m_MonarchInfo.name[Empire]));
{
SPDLOG_ERROR(" DirectQuery failed({})", szQuery);
delete pMsg;
return false;
}
delete pMsg;
memset(m_MonarchInfo.name[Empire], 0, 32);
m_MonarchInfo.money[Empire] = 0; m_MonarchInfo.money[Empire] = 0;
m_MonarchInfo.pid[Empire] = 0; m_MonarchInfo.pid[Empire] = 0;
return true; return true;
} }
txn.commit();
} }
catch (const std::exception &e)
{
SPDLOG_ERROR("[CMonarch::DelMonarch(name)] Query error: {}", e.what());
return false;
}
return false; return false;
} }
@ -300,7 +329,7 @@ int CMonarch::GetCandidacyIndex(DWORD pid)
for (int n = 0; it != m_vec_MonarchCandidacy.end(); ++it, ++n) for (int n = 0; it != m_vec_MonarchCandidacy.end(); ++it, ++n)
{ {
if (it->pid == pid) if (it->pid == pid)
return n; return n;
} }
return -1; return -1;

View File

@ -10,61 +10,61 @@
class CMonarch : public singleton<CMonarch> class CMonarch : public singleton<CMonarch>
{ {
public: public:
typedef std::map<DWORD, MonarchElectionInfo*> MAP_MONARCHELECTION; typedef std::map<DWORD, MonarchElectionInfo *> MAP_MONARCHELECTION;
typedef std::vector<MonarchCandidacy> VEC_MONARCHCANDIDACY; typedef std::vector<MonarchCandidacy> VEC_MONARCHCANDIDACY;
CMonarch(); CMonarch();
virtual ~CMonarch(); virtual ~CMonarch();
bool VoteMonarch(DWORD pid, DWORD selectedpid); bool VoteMonarch(DWORD pid, DWORD selectedpid);
void ElectMonarch(); void ElectMonarch();
bool IsCandidacy(DWORD pid); bool IsCandidacy(DWORD pid);
bool AddCandidacy(DWORD pid, const char * name); bool AddCandidacy(DWORD pid, const char *name);
bool DelCandidacy(const char * name); bool DelCandidacy(const char *name);
bool LoadMonarch(); bool LoadMonarch();
bool SetMonarch(const char * name); bool SetMonarch(const char *name);
bool DelMonarch(int Empire); bool DelMonarch(int Empire);
bool DelMonarch(const char * name); bool DelMonarch(const char *name);
bool IsMonarch(int Empire, DWORD pid); bool IsMonarch(int Empire, DWORD pid);
bool AddMoney(int Empire, int64_t Money); bool AddMoney(int Empire, int64_t Money);
bool DecMoney(int Empire, int64_t Money); bool DecMoney(int Empire, int64_t Money);
bool TakeMoney(int Empire, DWORD pid, int64_t Money); bool TakeMoney(int Empire, DWORD pid, int64_t Money);
TMonarchInfo* GetMonarch() TMonarchInfo *GetMonarch()
{ {
return &m_MonarchInfo; return &m_MonarchInfo;
} }
VEC_MONARCHCANDIDACY& GetVecMonarchCandidacy() VEC_MONARCHCANDIDACY &GetVecMonarchCandidacy()
{ {
return m_vec_MonarchCandidacy; return m_vec_MonarchCandidacy;
} }
size_t MonarchCandidacySize() size_t MonarchCandidacySize()
{ {
return m_vec_MonarchCandidacy.size(); return m_vec_MonarchCandidacy.size();
} }
private: private:
int GetCandidacyIndex(DWORD pid); int GetCandidacyIndex(DWORD pid);
MAP_MONARCHELECTION m_map_MonarchElection; MAP_MONARCHELECTION m_map_MonarchElection;
VEC_MONARCHCANDIDACY m_vec_MonarchCandidacy; VEC_MONARCHCANDIDACY m_vec_MonarchCandidacy;
TMonarchInfo m_MonarchInfo; TMonarchInfo m_MonarchInfo;
MonarchElectionInfo* GetMonarchElection(DWORD pid) MonarchElectionInfo *GetMonarchElection(DWORD pid)
{ {
MAP_MONARCHELECTION::iterator it = m_map_MonarchElection.find(pid); MAP_MONARCHELECTION::iterator it = m_map_MonarchElection.find(pid);
if (it != m_map_MonarchElection.end()) if (it != m_map_MonarchElection.end())
return it->second; return it->second;
return NULL; return NULL;
} }
}; };
#endif #endif

View File

@ -13,15 +13,15 @@ CMoneyLog::~CMoneyLog()
void CMoneyLog::Save() void CMoneyLog::Save()
{ {
CPeer* peer = CClientManager::instance().GetAnyPeer(); CPeer *peer = CClientManager::instance().GetAnyPeer();
if (!peer) if (!peer)
return; return;
for (BYTE bType = 0; bType < MONEY_LOG_TYPE_MAX_NUM; bType ++) for (BYTE bType = 0; bType < MONEY_LOG_TYPE_MAX_NUM; bType++)
{ {
typeof(m_MoneyLogContainer[bType].begin()) it; typeof(m_MoneyLogContainer[bType].begin()) it;
for (it = m_MoneyLogContainer[bType].begin(); it != m_MoneyLogContainer[bType].end(); ++it) for (it = m_MoneyLogContainer[bType].begin(); it != m_MoneyLogContainer[bType].end(); ++it)
{ {
//bType; // bType;
TPacketMoneyLog p; TPacketMoneyLog p;
p.type = bType; p.type = bType;
p.vnum = it->first; p.vnum = it->first;
@ -31,24 +31,6 @@ void CMoneyLog::Save()
} }
m_MoneyLogContainer[bType].clear(); m_MoneyLogContainer[bType].clear();
} }
/*
CPeer* peer = GetPeer();
peer->
for (BYTE bType = 0; bType < MONEY_LOG_TYPE_MAX_NUM; bType++)
{
//"INSERT INTO money_log%s VALUES('%s', %d, %d, %d)", CClientManager::instance().GetTablePostfix(),
typeof(m_MoneyLogContainer[bType].begin()) it;
for (it = m_MoneyLogContainer[bType].begin(); it != m_MoneyLogContainer[bType].end(); ++it)
{
typeof(it->second.begin())
}
}
for (BYTE bType = 0; bType < MONEY_LOG_TYPE_MAX_NUM; bType++)
m_MoneyLogContainer[bType].clear()
*/
} }
void CMoneyLog::AddLog(BYTE bType, DWORD dwVnum, int iGold) void CMoneyLog::AddLog(BYTE bType, DWORD dwVnum, int iGold)

View File

@ -6,14 +6,14 @@
class CMoneyLog : public singleton<CMoneyLog> class CMoneyLog : public singleton<CMoneyLog>
{ {
public: public:
CMoneyLog(); CMoneyLog();
virtual ~CMoneyLog(); virtual ~CMoneyLog();
void Save(); void Save();
void AddLog(BYTE bType, DWORD dwVnum, int iGold); void AddLog(BYTE bType, DWORD dwVnum, int iGold);
private: private:
std::map<DWORD, int> m_MoneyLogContainer[MONEY_LOG_TYPE_MAX_NUM]; std::map<DWORD, int> m_MoneyLogContainer[MONEY_LOG_TYPE_MAX_NUM];
}; };

View File

@ -61,48 +61,50 @@ void CPeer::SetUserCount(DWORD dwCount)
m_dwUserCount = dwCount; m_dwUserCount = dwCount;
} }
bool CPeer::PeekPacket(int & iBytesProceed, BYTE & header, DWORD & dwHandle, DWORD & dwLength, const char ** data) bool CPeer::PeekPacket(int &iBytesProceed, BYTE &header, DWORD &dwHandle, DWORD &dwLength, const char **data)
{ {
// Return if not enough data was received to read the header // Return if not enough data was received to read the header
if (GetRecvLength() < iBytesProceed + 9) if (GetRecvLength() < iBytesProceed + 9)
return false; return false;
const char * buf = (const char *) GetRecvBuffer(iBytesProceed + 9); const char *buf = (const char *)GetRecvBuffer(iBytesProceed + 9);
if (!buf) { if (!buf)
SPDLOG_ERROR("PeekPacket: Failed to get network buffer!");
return false;
}
buf += iBytesProceed;
// Read the header data
header = *(buf++);
dwHandle = *((DWORD *) buf);
buf += sizeof(DWORD);
dwLength = *((DWORD *) buf);
buf += sizeof(DWORD);
// Ensure that all the data was fully received
if (iBytesProceed + dwLength + 9 > (DWORD) GetRecvLength())
{ {
SPDLOG_DEBUG("PeekPacket: not enough buffer size: len {}, recv {}", SPDLOG_ERROR("PeekPacket: Failed to get network buffer!");
9+dwLength, GetRecvLength()-iBytesProceed);
return false; return false;
} }
// Ensure that all the required data is available in a contiguous area buf += iBytesProceed;
buf = (const char *) GetRecvBuffer(iBytesProceed + dwLength + 9);
if (!buf) {
SPDLOG_ERROR("PeekPacket: Failed to get network buffer!");
return false;
}
// Skip the header // Read the header data
buf += iBytesProceed + 9; header = *(buf++);
// Set the data pointer dwHandle = *((DWORD *)buf);
buf += sizeof(DWORD);
dwLength = *((DWORD *)buf);
buf += sizeof(DWORD);
// Ensure that all the data was fully received
if (iBytesProceed + dwLength + 9 > (DWORD)GetRecvLength())
{
SPDLOG_DEBUG("PeekPacket: not enough buffer size: len {}, recv {}",
9 + dwLength, GetRecvLength() - iBytesProceed);
return false;
}
// Ensure that all the required data is available in a contiguous area
buf = (const char *)GetRecvBuffer(iBytesProceed + dwLength + 9);
if (!buf)
{
SPDLOG_ERROR("PeekPacket: Failed to get network buffer!");
return false;
}
// Skip the header
buf += iBytesProceed + 9;
// Set the data pointer
*data = buf; *data = buf;
iBytesProceed += dwLength + 9; iBytesProceed += dwLength + 9;
return true; return true;
@ -131,7 +133,7 @@ void CPeer::SetP2PPort(WORD wPort)
m_wP2PPort = wPort; m_wP2PPort = wPort;
} }
void CPeer::SetMaps(LONG * pl) void CPeer::SetMaps(LONG *pl)
{ {
memcpy(m_alMaps, pl, sizeof(m_alMaps)); memcpy(m_alMaps, pl, sizeof(m_alMaps));
} }
@ -160,7 +162,8 @@ void CPeer::SendSpareItemIDRange()
bool CPeer::SetItemIDRange(TItemIDRangeTable itemRange) bool CPeer::SetItemIDRange(TItemIDRangeTable itemRange)
{ {
if (itemRange.dwMin == 0 || itemRange.dwMax == 0 || itemRange.dwUsableItemIDMin == 0) return false; if (itemRange.dwMin == 0 || itemRange.dwMax == 0 || itemRange.dwUsableItemIDMin == 0)
return false;
m_itemRange = itemRange; m_itemRange = itemRange;
SPDLOG_DEBUG("ItemIDRange: SET {} {} ~ {} start: {}", GetPublicIP(), m_itemRange.dwMin, m_itemRange.dwMax, m_itemRange.dwUsableItemIDMin); SPDLOG_DEBUG("ItemIDRange: SET {} {} ~ {} start: {}", GetPublicIP(), m_itemRange.dwMin, m_itemRange.dwMax, m_itemRange.dwUsableItemIDMin);
@ -170,11 +173,12 @@ bool CPeer::SetItemIDRange(TItemIDRangeTable itemRange)
bool CPeer::SetSpareItemIDRange(TItemIDRangeTable itemRange) bool CPeer::SetSpareItemIDRange(TItemIDRangeTable itemRange)
{ {
if (itemRange.dwMin == 0 || itemRange.dwMax == 0 || itemRange.dwUsableItemIDMin == 0) return false; if (itemRange.dwMin == 0 || itemRange.dwMax == 0 || itemRange.dwUsableItemIDMin == 0)
return false;
m_itemSpareRange = itemRange; m_itemSpareRange = itemRange;
SPDLOG_DEBUG("ItemIDRange: SPARE SET {} {} ~ {} start: {}", GetPublicIP(), m_itemSpareRange.dwMin, m_itemSpareRange.dwMax, SPDLOG_DEBUG("ItemIDRange: SPARE SET {} {} ~ {} start: {}", GetPublicIP(), m_itemSpareRange.dwMin, m_itemSpareRange.dwMax,
m_itemSpareRange.dwUsableItemIDMin); m_itemSpareRange.dwUsableItemIDMin);
return true; return true;
} }
@ -184,18 +188,16 @@ bool CPeer::CheckItemIDRangeCollision(TItemIDRangeTable itemRange)
if (m_itemRange.dwMin < itemRange.dwMax && m_itemRange.dwMax > itemRange.dwMin) if (m_itemRange.dwMin < itemRange.dwMax && m_itemRange.dwMax > itemRange.dwMin)
{ {
SPDLOG_ERROR("ItemIDRange: Collision!! this {} ~ {} check {} ~ {}", SPDLOG_ERROR("ItemIDRange: Collision!! this {} ~ {} check {} ~ {}",
m_itemRange.dwMin, m_itemRange.dwMax, itemRange.dwMin, itemRange.dwMax); m_itemRange.dwMin, m_itemRange.dwMax, itemRange.dwMin, itemRange.dwMax);
return false; return false;
} }
if (m_itemSpareRange.dwMin < itemRange.dwMax && m_itemSpareRange.dwMax > itemRange.dwMin) if (m_itemSpareRange.dwMin < itemRange.dwMax && m_itemSpareRange.dwMax > itemRange.dwMin)
{ {
SPDLOG_ERROR("ItemIDRange: Collision with spare range this {} ~ {} check {} ~ {}", SPDLOG_ERROR("ItemIDRange: Collision with spare range this {} ~ {} check {} ~ {}",
m_itemSpareRange.dwMin, m_itemSpareRange.dwMax, itemRange.dwMin, itemRange.dwMax); m_itemSpareRange.dwMin, m_itemSpareRange.dwMax, itemRange.dwMin, itemRange.dwMax);
return false; return false;
} }
return true; return true;
} }

View File

@ -6,70 +6,70 @@
class CPeer : public CPeerBase class CPeer : public CPeerBase
{ {
protected: protected:
virtual void OnAccept(); virtual void OnAccept();
virtual void OnClose(); virtual void OnClose();
public: public:
#pragma pack(1) #pragma pack(1)
typedef struct _header typedef struct _header
{ {
BYTE bHeader; BYTE bHeader;
DWORD dwHandle; DWORD dwHandle;
DWORD dwSize; DWORD dwSize;
} HEADER; } HEADER;
#pragma pack() #pragma pack()
enum EState enum EState
{ {
STATE_CLOSE = 0, STATE_CLOSE = 0,
STATE_PLAYING = 1 STATE_PLAYING = 1
}; };
CPeer(); CPeer();
virtual ~CPeer(); virtual ~CPeer();
void EncodeHeader(BYTE header, DWORD dwHandle, DWORD dwSize); void EncodeHeader(BYTE header, DWORD dwHandle, DWORD dwSize);
bool PeekPacket(int & iBytesProceed, BYTE & header, DWORD & dwHandle, DWORD & dwLength, const char ** data); bool PeekPacket(int &iBytesProceed, BYTE &header, DWORD &dwHandle, DWORD &dwLength, const char **data);
void EncodeReturn(BYTE header, DWORD dwHandle); void EncodeReturn(BYTE header, DWORD dwHandle);
void ProcessInput(); void ProcessInput();
DWORD GetHandle(); DWORD GetHandle();
DWORD GetUserCount(); DWORD GetUserCount();
void SetUserCount(DWORD dwCount); void SetUserCount(DWORD dwCount);
void SetChannel(BYTE bChannel) { m_bChannel = bChannel; } void SetChannel(BYTE bChannel) { m_bChannel = bChannel; }
BYTE GetChannel() { return m_bChannel; } BYTE GetChannel() { return m_bChannel; }
void SetPublicIP(const char * ip) { m_stPublicIP = ip; } void SetPublicIP(const char *ip) { m_stPublicIP = ip; }
const char * GetPublicIP() { return m_stPublicIP.c_str(); } const char *GetPublicIP() { return m_stPublicIP.c_str(); }
void SetListenPort(WORD wPort) { m_wListenPort = wPort; } void SetListenPort(WORD wPort) { m_wListenPort = wPort; }
WORD GetListenPort() { return m_wListenPort; } WORD GetListenPort() { return m_wListenPort; }
void SetInternalIP(const char * ip) { m_stInternalIP = ip; } void SetInternalIP(const char *ip) { m_stInternalIP = ip; }
const char * GetInternalIP() { return m_stInternalIP.c_str(); } const char *GetInternalIP() { return m_stInternalIP.c_str(); }
void SetP2PPort(WORD wPort); void SetP2PPort(WORD wPort);
WORD GetP2PPort() { return m_wP2PPort; } WORD GetP2PPort() { return m_wP2PPort; }
void SetMaps(LONG* pl); void SetMaps(LONG *pl);
LONG * GetMaps() { return &m_alMaps[0]; } LONG *GetMaps() { return &m_alMaps[0]; }
bool SetItemIDRange(TItemIDRangeTable itemRange); bool SetItemIDRange(TItemIDRangeTable itemRange);
bool SetSpareItemIDRange(TItemIDRangeTable itemRange); bool SetSpareItemIDRange(TItemIDRangeTable itemRange);
bool CheckItemIDRangeCollision(TItemIDRangeTable itemRange); bool CheckItemIDRangeCollision(TItemIDRangeTable itemRange);
void SendSpareItemIDRange(); void SendSpareItemIDRange();
private: private:
int m_state; int m_state;
BYTE m_bChannel; BYTE m_bChannel;
DWORD m_dwHandle; DWORD m_dwHandle;
DWORD m_dwUserCount; DWORD m_dwUserCount;
WORD m_wListenPort; // 게임서버가 클라이언트를 위해 listen 하는 포트 WORD m_wListenPort; // 게임서버가 클라이언트를 위해 listen 하는 포트
WORD m_wP2PPort; // 게임서버가 게임서버 P2P 접속을 위해 listen 하는 포트 WORD m_wP2PPort; // 게임서버가 게임서버 P2P 접속을 위해 listen 하는 포트
LONG m_alMaps[MAP_ALLOW_MAX_LEN]; // 어떤 맵을 관장하고 있는가? LONG m_alMaps[MAP_ALLOW_MAX_LEN]; // 어떤 맵을 관장하고 있는가?
TItemIDRangeTable m_itemRange; TItemIDRangeTable m_itemRange;
TItemIDRangeTable m_itemSpareRange; TItemIDRangeTable m_itemSpareRange;

View File

@ -9,25 +9,28 @@ CPeerBase::CPeerBase() : m_bufferevent(nullptr)
CPeerBase::~CPeerBase() CPeerBase::~CPeerBase()
{ {
Destroy(); Destroy();
} }
void CPeerBase::Destroy() void CPeerBase::Destroy()
{ {
if (m_bufferevent) { if (m_bufferevent)
{
bufferevent_free(m_bufferevent); bufferevent_free(m_bufferevent);
m_bufferevent = nullptr; m_bufferevent = nullptr;
} }
} }
bool CPeerBase::Accept(bufferevent* bufev, sockaddr* addr) bool CPeerBase::Accept(bufferevent *bufev, sockaddr *addr)
{ {
if (!bufev) { if (!bufev)
{
SPDLOG_ERROR("Cannot accept empty bufferevent!"); SPDLOG_ERROR("Cannot accept empty bufferevent!");
return false; return false;
} }
if (m_bufferevent != nullptr) { if (m_bufferevent != nullptr)
{
SPDLOG_ERROR("Peer is already initialized"); SPDLOG_ERROR("Peer is already initialized");
return false; return false;
} }
@ -36,40 +39,41 @@ bool CPeerBase::Accept(bufferevent* bufev, sockaddr* addr)
m_bufferevent = bufev; m_bufferevent = bufev;
// Get the address of the conected peer // Get the address of the conected peer
sockaddr_in* peer; sockaddr_in *peer;
sockaddr_in6* peer6; sockaddr_in6 *peer6;
switch (addr->sa_family) { switch (addr->sa_family)
case AF_INET: {
peer = (sockaddr_in*) addr; case AF_INET:
inet_ntop(AF_INET, &(peer->sin_addr), m_host, INET_ADDRSTRLEN); peer = (sockaddr_in *)addr;
break; inet_ntop(AF_INET, &(peer->sin_addr), m_host, INET_ADDRSTRLEN);
break;
case AF_INET6: case AF_INET6:
peer6 = (sockaddr_in6*) addr; peer6 = (sockaddr_in6 *)addr;
inet_ntop(AF_INET, &(peer6->sin6_addr), m_host, INET6_ADDRSTRLEN); inet_ntop(AF_INET, &(peer6->sin6_addr), m_host, INET6_ADDRSTRLEN);
break; break;
default: default:
break; break;
} }
// Trigger the OnAccept event // Trigger the OnAccept event
OnAccept(); OnAccept();
SPDLOG_DEBUG("ACCEPT FROM {}", m_host); SPDLOG_DEBUG("ACCEPT FROM {}", m_host);
return true; return true;
} }
void CPeerBase::Close() void CPeerBase::Close()
{ {
OnClose(); OnClose();
} }
void CPeerBase::EncodeBYTE(BYTE b) void CPeerBase::EncodeBYTE(BYTE b)
{ {
Encode(&b, sizeof(b)); Encode(&b, sizeof(b));
} }
void CPeerBase::EncodeWORD(WORD w) void CPeerBase::EncodeWORD(WORD w)
@ -82,15 +86,16 @@ void CPeerBase::EncodeDWORD(DWORD dw)
Encode(&dw, sizeof(dw)); Encode(&dw, sizeof(dw));
} }
void CPeerBase::Encode(const void* data, size_t size) void CPeerBase::Encode(const void *data, size_t size)
{ {
if (!m_bufferevent) if (!m_bufferevent)
{ {
SPDLOG_ERROR("Bufferevent not ready!"); SPDLOG_ERROR("Bufferevent not ready!");
return; return;
} }
if (bufferevent_write(m_bufferevent, data, size) != 0) { if (bufferevent_write(m_bufferevent, data, size) != 0)
{
SPDLOG_ERROR("Buffer write error!"); SPDLOG_ERROR("Buffer write error!");
return; return;
} }
@ -117,10 +122,10 @@ size_t CPeerBase::GetRecvLength()
} }
evbuffer *input = bufferevent_get_input(m_bufferevent); evbuffer *input = bufferevent_get_input(m_bufferevent);
return evbuffer_get_length(input); return evbuffer_get_length(input);
} }
const void * CPeerBase::GetRecvBuffer(ssize_t ensure_bytes) const void *CPeerBase::GetRecvBuffer(ssize_t ensure_bytes)
{ {
if (!m_bufferevent) if (!m_bufferevent)
{ {
@ -129,7 +134,7 @@ const void * CPeerBase::GetRecvBuffer(ssize_t ensure_bytes)
} }
evbuffer *input = bufferevent_get_input(m_bufferevent); evbuffer *input = bufferevent_get_input(m_bufferevent);
return evbuffer_pullup(input, ensure_bytes); return evbuffer_pullup(input, ensure_bytes);
} }
size_t CPeerBase::GetSendLength() size_t CPeerBase::GetSendLength()

View File

@ -3,38 +3,39 @@
#include <event2/bufferevent.h> #include <event2/bufferevent.h>
class CPeerBase { class CPeerBase
{
protected: protected:
virtual void OnAccept() = 0; virtual void OnAccept() = 0;
virtual void OnClose() = 0; virtual void OnClose() = 0;
public: public:
bool Accept(bufferevent* bufev, sockaddr* addr); bool Accept(bufferevent *bufev, sockaddr *addr);
void Close(); void Close();
public: public:
CPeerBase(); CPeerBase();
virtual ~CPeerBase(); virtual ~CPeerBase();
void Destroy(); void Destroy();
bufferevent * GetBufferevent() { return m_bufferevent; } bufferevent *GetBufferevent() { return m_bufferevent; }
void EncodeBYTE(BYTE b); void EncodeBYTE(BYTE b);
void EncodeWORD(WORD w); void EncodeWORD(WORD w);
void EncodeDWORD(DWORD dw); void EncodeDWORD(DWORD dw);
void Encode(const void* data, size_t size); void Encode(const void *data, size_t size);
void RecvEnd(size_t proceed_bytes); void RecvEnd(size_t proceed_bytes);
size_t GetRecvLength(); size_t GetRecvLength();
const void * GetRecvBuffer(ssize_t ensure_bytes); const void *GetRecvBuffer(ssize_t ensure_bytes);
size_t GetSendLength(); size_t GetSendLength();
const char * GetHost() { return m_host; } const char *GetHost() { return m_host; }
protected: protected:
char m_host[IP_ADDRESS_LENGTH + 1]; char m_host[IP_ADDRESS_LENGTH + 1];
bufferevent * m_bufferevent; bufferevent *m_bufferevent;
}; };
#endif #endif

View File

@ -2,9 +2,9 @@
#include "PrivManager.h" #include "PrivManager.h"
#include "ClientManager.h" #include "ClientManager.h"
const int PRIV_DURATION = 60*60*12; const int PRIV_DURATION = 60 * 60 * 12;
const int CHARACTER_GOOD_PRIV_DURATION = 2*60*60; const int CHARACTER_GOOD_PRIV_DURATION = 2 * 60 * 60;
const int CHARACTER_BAD_PRIV_DURATION = 60*60; const int CHARACTER_BAD_PRIV_DURATION = 60 * 60;
CPrivManager::CPrivManager() CPrivManager::CPrivManager()
{ {
@ -28,7 +28,7 @@ void CPrivManager::Update()
while (!m_pqPrivGuild.empty() && m_pqPrivGuild.top().first <= now) while (!m_pqPrivGuild.empty() && m_pqPrivGuild.top().first <= now)
{ {
TPrivGuildData* p = m_pqPrivGuild.top().second; TPrivGuildData *p = m_pqPrivGuild.top().second;
m_pqPrivGuild.pop(); m_pqPrivGuild.pop();
if (p->value != 0 && !p->bRemoved) if (p->value != 0 && !p->bRemoved)
@ -39,7 +39,8 @@ void CPrivManager::Update()
// ADD_GUILD_PRIV_TIME // ADD_GUILD_PRIV_TIME
// 길드에 중복적으로 보너스가 설정되었을 경우 map 의 value 가 갱신(수정) 되었으므로 // 길드에 중복적으로 보너스가 설정되었을 경우 map 의 value 가 갱신(수정) 되었으므로
// TPrivGuildData 의 포인터가 같을때 실제로 삭제해 주고 게임서버들에게 cast 해 준다. // TPrivGuildData 의 포인터가 같을때 실제로 삭제해 주고 게임서버들에게 cast 해 준다.
if (it != m_aPrivGuild[p->type].end() && it->second == p) { if (it != m_aPrivGuild[p->type].end() && it->second == p)
{
m_aPrivGuild[p->type].erase(it); m_aPrivGuild[p->type].erase(it);
SendChangeGuildPriv(p->guild_id, p->type, 0, 0); SendChangeGuildPriv(p->guild_id, p->type, 0, 0);
// END_OF_ADD_GUILD_PRIV_TIME // END_OF_ADD_GUILD_PRIV_TIME
@ -51,7 +52,7 @@ void CPrivManager::Update()
while (!m_pqPrivEmpire.empty() && m_pqPrivEmpire.top().first <= now) while (!m_pqPrivEmpire.empty() && m_pqPrivEmpire.top().first <= now)
{ {
TPrivEmpireData* p = (m_pqPrivEmpire.top().second); TPrivEmpireData *p = (m_pqPrivEmpire.top().second);
m_pqPrivEmpire.pop(); m_pqPrivEmpire.pop();
if (p->value != 0 && !p->bRemoved) if (p->value != 0 && !p->bRemoved)
@ -65,7 +66,7 @@ void CPrivManager::Update()
while (!m_pqPrivChar.empty() && m_pqPrivChar.top().first <= now) while (!m_pqPrivChar.empty() && m_pqPrivChar.top().first <= now)
{ {
TPrivCharData* p = (m_pqPrivChar.top().second); TPrivCharData *p = (m_pqPrivChar.top().second);
m_pqPrivChar.pop(); m_pqPrivChar.pop();
if (!p->bRemoved) if (!p->bRemoved)
@ -97,14 +98,14 @@ void CPrivManager::AddCharPriv(DWORD pid, BYTE type, int value)
return; return;
time_t now = CClientManager::instance().GetCurrentTime(); time_t now = CClientManager::instance().GetCurrentTime();
TPrivCharData* p = new TPrivCharData(type, value, pid); TPrivCharData *p = new TPrivCharData(type, value, pid);
int iDuration = CHARACTER_BAD_PRIV_DURATION; int iDuration = CHARACTER_BAD_PRIV_DURATION;
if (value > 0) if (value > 0)
iDuration = CHARACTER_GOOD_PRIV_DURATION; iDuration = CHARACTER_GOOD_PRIV_DURATION;
m_pqPrivChar.push(std::make_pair(now+iDuration, p)); m_pqPrivChar.push(std::make_pair(now + iDuration, p));
m_aPrivChar[type].insert(std::make_pair(pid, p)); m_aPrivChar[type].insert(std::make_pair(pid, p));
// TODO send packet // TODO send packet
@ -127,7 +128,7 @@ void CPrivManager::AddGuildPriv(DWORD guild_id, BYTE type, int value, time_t dur
time_t now = CClientManager::instance().GetCurrentTime(); time_t now = CClientManager::instance().GetCurrentTime();
time_t end = now + duration_sec; time_t end = now + duration_sec;
TPrivGuildData * p = new TPrivGuildData(type, value, guild_id, end); TPrivGuildData *p = new TPrivGuildData(type, value, guild_id, end);
m_pqPrivGuild.push(std::make_pair(end, p)); m_pqPrivGuild.push(std::make_pair(end, p));
// ADD_GUILD_PRIV_TIME // ADD_GUILD_PRIV_TIME
@ -156,7 +157,7 @@ void CPrivManager::AddEmpirePriv(BYTE empire, BYTE type, int value, time_t durat
duration_sec = 0; duration_sec = 0;
time_t now = CClientManager::instance().GetCurrentTime(); time_t now = CClientManager::instance().GetCurrentTime();
time_t end = now+duration_sec; time_t end = now + duration_sec;
// 이전 설정값 무효화 // 이전 설정값 무효화
// priority_queue에 들어있는 pointer == m_aaPrivEmpire[type][empire] // priority_queue에 들어있는 pointer == m_aaPrivEmpire[type][empire]
@ -165,7 +166,7 @@ void CPrivManager::AddEmpirePriv(BYTE empire, BYTE type, int value, time_t durat
m_aaPrivEmpire[type][empire]->bRemoved = true; m_aaPrivEmpire[type][empire]->bRemoved = true;
} }
TPrivEmpireData * p = new TPrivEmpireData(type, value, empire, end); TPrivEmpireData *p = new TPrivEmpireData(type, value, empire, end);
m_pqPrivEmpire.push(std::make_pair(end, p)); m_pqPrivEmpire.push(std::make_pair(end, p));
m_aaPrivEmpire[type][empire] = p; m_aaPrivEmpire[type][empire] = p;
@ -192,7 +193,7 @@ struct FSendChangeGuildPriv
// END_OF_ADD_GUILD_PRIV_TIME // END_OF_ADD_GUILD_PRIV_TIME
} }
void operator() (CPeer* peer) void operator()(CPeer *peer)
{ {
peer->EncodeHeader(HEADER_DG_CHANGE_GUILD_PRIV, 0, sizeof(TPacketDGChangeGuildPriv)); peer->EncodeHeader(HEADER_DG_CHANGE_GUILD_PRIV, 0, sizeof(TPacketDGChangeGuildPriv));
peer->Encode(&p, sizeof(TPacketDGChangeGuildPriv)); peer->Encode(&p, sizeof(TPacketDGChangeGuildPriv));
@ -215,7 +216,7 @@ struct FSendChangeEmpirePriv
// END_OF_ADD_EMPIRE_PRIV_TIME // END_OF_ADD_EMPIRE_PRIV_TIME
} }
void operator ()(CPeer* peer) void operator()(CPeer *peer)
{ {
peer->EncodeHeader(HEADER_DG_CHANGE_EMPIRE_PRIV, 0, sizeof(TPacketDGChangeEmpirePriv)); peer->EncodeHeader(HEADER_DG_CHANGE_EMPIRE_PRIV, 0, sizeof(TPacketDGChangeEmpirePriv));
peer->Encode(&p, sizeof(TPacketDGChangeEmpirePriv)); peer->Encode(&p, sizeof(TPacketDGChangeEmpirePriv));
@ -234,7 +235,7 @@ struct FSendChangeCharPriv
p.value = value; p.value = value;
p.bLog = 1; p.bLog = 1;
} }
void operator()(CPeer* peer) void operator()(CPeer *peer)
{ {
peer->EncodeHeader(HEADER_DG_CHANGE_CHARACTER_PRIV, 0, sizeof(TPacketDGChangeCharacterPriv)); peer->EncodeHeader(HEADER_DG_CHANGE_CHARACTER_PRIV, 0, sizeof(TPacketDGChangeCharacterPriv));
peer->Encode(&p, sizeof(TPacketDGChangeCharacterPriv)); peer->Encode(&p, sizeof(TPacketDGChangeCharacterPriv));
@ -262,14 +263,14 @@ void CPrivManager::SendChangeCharPriv(DWORD pid, BYTE type, int value)
CClientManager::instance().for_each_peer(FSendChangeCharPriv(pid, type, value)); CClientManager::instance().for_each_peer(FSendChangeCharPriv(pid, type, value));
} }
void CPrivManager::SendPrivOnSetup(CPeer* peer) void CPrivManager::SendPrivOnSetup(CPeer *peer)
{ {
for (int i = 1; i < MAX_PRIV_NUM; ++i) for (int i = 1; i < MAX_PRIV_NUM; ++i)
{ {
for (int e = 0; e < EMPIRE_MAX_NUM; ++e) for (int e = 0; e < EMPIRE_MAX_NUM; ++e)
{ {
// ADD_EMPIRE_PRIV_TIME // ADD_EMPIRE_PRIV_TIME
TPrivEmpireData* pPrivEmpireData = m_aaPrivEmpire[i][e]; TPrivEmpireData *pPrivEmpireData = m_aaPrivEmpire[i][e];
if (pPrivEmpireData) if (pPrivEmpireData)
{ {
FSendChangeEmpirePriv(e, i, pPrivEmpireData->value, pPrivEmpireData->end_time_sec)(peer); FSendChangeEmpirePriv(e, i, pPrivEmpireData->value, pPrivEmpireData->end_time_sec)(peer);
@ -277,7 +278,7 @@ void CPrivManager::SendPrivOnSetup(CPeer* peer)
// END_OF_ADD_EMPIRE_PRIV_TIME // END_OF_ADD_EMPIRE_PRIV_TIME
} }
for (typeof(m_aPrivGuild[i].begin()) it = m_aPrivGuild[i].begin(); it != m_aPrivGuild[i].end();++it) for (typeof(m_aPrivGuild[i].begin()) it = m_aPrivGuild[i].begin(); it != m_aPrivGuild[i].end(); ++it)
{ {
// ADD_GUILD_PRIV_TIME // ADD_GUILD_PRIV_TIME
FSendChangeGuildPriv(it->first, i, it->second->value, it->second->end_time_sec)(peer); FSendChangeGuildPriv(it->first, i, it->second->value, it->second->end_time_sec)(peer);

View File

@ -8,17 +8,18 @@
struct TPrivEmpireData struct TPrivEmpireData
{ {
BYTE type; BYTE type;
int value; int value;
bool bRemoved; bool bRemoved;
BYTE empire; BYTE empire;
// ADD_EMPIRE_PRIV_TIME // ADD_EMPIRE_PRIV_TIME
time_t end_time_sec; time_t end_time_sec;
TPrivEmpireData(BYTE type, int value, BYTE empire, time_t end_time_sec) TPrivEmpireData(BYTE type, int value, BYTE empire, time_t end_time_sec)
: type(type), value(value), bRemoved(false), empire(empire), end_time_sec(end_time_sec) : type(type), value(value), bRemoved(false), empire(empire), end_time_sec(end_time_sec)
{} {
}
// END_OF_ADD_EMPIRE_PRIV_TIME // END_OF_ADD_EMPIRE_PRIV_TIME
}; };
@ -27,29 +28,31 @@ struct TPrivEmpireData
*/ */
struct TPrivGuildData struct TPrivGuildData
{ {
BYTE type; BYTE type;
int value; int value;
bool bRemoved; bool bRemoved;
DWORD guild_id; DWORD guild_id;
// ADD_GUILD_PRIV_TIME // ADD_GUILD_PRIV_TIME
time_t end_time_sec; ///< 지속시간 time_t end_time_sec; ///< 지속시간
TPrivGuildData(BYTE type, int value, DWORD guild_id, time_t _end_time_sec) TPrivGuildData(BYTE type, int value, DWORD guild_id, time_t _end_time_sec)
: type(type), value(value), bRemoved(false), guild_id(guild_id), end_time_sec(_end_time_sec ) : type(type), value(value), bRemoved(false), guild_id(guild_id), end_time_sec(_end_time_sec)
{} {
}
// END_OF_ADD_GUILD_PRIV_TIME // END_OF_ADD_GUILD_PRIV_TIME
}; };
struct TPrivCharData struct TPrivCharData
{ {
BYTE type; BYTE type;
int value; int value;
bool bRemoved; bool bRemoved;
DWORD pid; DWORD pid;
TPrivCharData(BYTE type, int value, DWORD pid) TPrivCharData(BYTE type, int value, DWORD pid)
: type(type), value(value), bRemoved(false), pid(pid) : type(type), value(value), bRemoved(false), pid(pid)
{} {
}
}; };
/** /**
@ -57,7 +60,7 @@ struct TPrivCharData
*/ */
class CPrivManager : public singleton<CPrivManager> class CPrivManager : public singleton<CPrivManager>
{ {
public: public:
CPrivManager(); CPrivManager();
virtual ~CPrivManager(); virtual ~CPrivManager();
@ -65,42 +68,41 @@ class CPrivManager : public singleton<CPrivManager>
void AddGuildPriv(DWORD guild_id, BYTE type, int value, time_t time_sec); void AddGuildPriv(DWORD guild_id, BYTE type, int value, time_t time_sec);
// END_OF_ADD_GUILD_PRIV_TIME // END_OF_ADD_GUILD_PRIV_TIME
// ADD_EMPIRE_PRIV_TIME // ADD_EMPIRE_PRIV_TIME
void AddEmpirePriv(BYTE empire, BYTE type, int value, time_t time_sec); void AddEmpirePriv(BYTE empire, BYTE type, int value, time_t time_sec);
// END_OF_ADD_EMPIRE_PRIV_TIME // END_OF_ADD_EMPIRE_PRIV_TIME
void AddCharPriv(DWORD pid, BYTE type, int value); void AddCharPriv(DWORD pid, BYTE type, int value);
void Update(); void Update();
void SendPrivOnSetup(CPeer* peer); void SendPrivOnSetup(CPeer *peer);
private:
private:
// ADD_GUILD_PRIV_TIME // ADD_GUILD_PRIV_TIME
void SendChangeGuildPriv(DWORD guild_id, BYTE type, int value, time_t end_time_sec); void SendChangeGuildPriv(DWORD guild_id, BYTE type, int value, time_t end_time_sec);
// END_OF_ADD_GUILD_PRIV_TIME // END_OF_ADD_GUILD_PRIV_TIME
// ADD_EMPIRE_PRIV_TIME // ADD_EMPIRE_PRIV_TIME
void SendChangeEmpirePriv(BYTE empire, BYTE type, int value, time_t end_time_sec); void SendChangeEmpirePriv(BYTE empire, BYTE type, int value, time_t end_time_sec);
// END_OF_ADD_EMPIRE_PRIV_TIME // END_OF_ADD_EMPIRE_PRIV_TIME
void SendChangeCharPriv(DWORD pid, BYTE type, int value); void SendChangeCharPriv(DWORD pid, BYTE type, int value);
typedef std::pair<time_t, TPrivCharData *> stPairChar; typedef std::pair<time_t, TPrivCharData *> stPairChar;
typedef std::pair<time_t, TPrivGuildData*> stPairGuild; typedef std::pair<time_t, TPrivGuildData *> stPairGuild;
typedef std::pair<time_t, TPrivEmpireData*> stPairEmpire; typedef std::pair<time_t, TPrivEmpireData *> stPairEmpire;
std::priority_queue<stPairChar, std::vector<stPairChar>, std::greater<stPairChar> > std::priority_queue<stPairChar, std::vector<stPairChar>, std::greater<stPairChar>>
m_pqPrivChar; m_pqPrivChar;
std::priority_queue<stPairGuild, std::vector<stPairGuild>, std::greater<stPairGuild> > std::priority_queue<stPairGuild, std::vector<stPairGuild>, std::greater<stPairGuild>>
m_pqPrivGuild; m_pqPrivGuild;
std::priority_queue<stPairEmpire, std::vector<stPairEmpire>, std::greater<stPairEmpire> > std::priority_queue<stPairEmpire, std::vector<stPairEmpire>, std::greater<stPairEmpire>>
m_pqPrivEmpire; m_pqPrivEmpire;
TPrivEmpireData* m_aaPrivEmpire[MAX_PRIV_NUM][EMPIRE_MAX_NUM]; TPrivEmpireData *m_aaPrivEmpire[MAX_PRIV_NUM][EMPIRE_MAX_NUM];
std::map<DWORD, TPrivGuildData*> m_aPrivGuild[MAX_PRIV_NUM]; std::map<DWORD, TPrivGuildData *> m_aPrivGuild[MAX_PRIV_NUM];
std::map<DWORD, TPrivCharData*> m_aPrivChar[MAX_PRIV_NUM]; std::map<DWORD, TPrivCharData *> m_aPrivChar[MAX_PRIV_NUM];
}; };
#endif #endif

File diff suppressed because it is too large Load Diff

View File

@ -6,7 +6,7 @@
#include "CsvReader.h" #include "CsvReader.h"
//csv 파일을 읽어와서 아이템 테이블에 넣어준다. // csv 파일을 읽어와서 아이템 테이블에 넣어준다.
void putItemIntoTable(); //(테이블, 테스트여부) void putItemIntoTable(); //(테이블, 테스트여부)
int get_Item_Type_Value(std::string inputString); int get_Item_Type_Value(std::string inputString);
@ -18,8 +18,7 @@ int get_Item_Immune_Value(std::string inputString);
int get_Item_LimitType_Value(std::string inputString); int get_Item_LimitType_Value(std::string inputString);
int get_Item_ApplyType_Value(std::string inputString); int get_Item_ApplyType_Value(std::string inputString);
// 몬스터 프로토도 읽을 수 있다.
//몬스터 프로토도 읽을 수 있다.
int get_Mob_Rank_Value(std::string inputString); int get_Mob_Rank_Value(std::string inputString);
int get_Mob_Type_Value(std::string inputString); int get_Mob_Type_Value(std::string inputString);
int get_Mob_BattleType_Value(std::string inputString); int get_Mob_BattleType_Value(std::string inputString);
@ -30,7 +29,7 @@ int get_Mob_RaceFlag_Value(std::string inputString);
int get_Mob_ImmuneFlag_Value(std::string inputString); int get_Mob_ImmuneFlag_Value(std::string inputString);
// //
bool Set_Proto_Mob_Table(TMobTable *mobTable, cCsvTable &csvTable, std::map<int,const char*> &nameMap); bool Set_Proto_Mob_Table(TMobTable *mobTable, cCsvTable &csvTable, std::map<int, const char *> &nameMap);
bool Set_Proto_Item_Table(TItemTable *itemTable, cCsvTable &csvTable,std::map<int,const char*> &nameMap); bool Set_Proto_Item_Table(TItemTable *itemTable, cCsvTable &csvTable, std::map<int, const char *> &nameMap);
#endif #endif

View File

@ -6,33 +6,33 @@
*/ */
enum QID enum QID
{ {
QID_PLAYER, // 0 QID_PLAYER, // 0
QID_ITEM, // 1 QID_ITEM, // 1
QID_QUEST, // 2 QID_QUEST, // 2
QID_AFFECT, // 3 QID_AFFECT, // 3
QID_LOGIN, // 4 QID_LOGIN, // 4
QID_SAFEBOX_LOAD, // 5 QID_SAFEBOX_LOAD, // 5
QID_SAFEBOX_CHANGE_SIZE, // 6 QID_SAFEBOX_CHANGE_SIZE, // 6
QID_SAFEBOX_CHANGE_PASSWORD, // 7 QID_SAFEBOX_CHANGE_PASSWORD, // 7
QID_SAFEBOX_CHANGE_PASSWORD_SECOND, // 8 QID_SAFEBOX_CHANGE_PASSWORD_SECOND, // 8
QID_SAFEBOX_SAVE, // 9 QID_SAFEBOX_SAVE, // 9
QID_ITEM_SAVE, // 10 QID_ITEM_SAVE, // 10
QID_ITEM_DESTROY, // 11 QID_ITEM_DESTROY, // 11
QID_QUEST_SAVE, // 12 QID_QUEST_SAVE, // 12
QID_PLAYER_SAVE, // 13 QID_PLAYER_SAVE, // 13
QID_PLAYER_DELETE, // 14 QID_PLAYER_DELETE, // 14
QID_LOGIN_BY_KEY, // 15 QID_LOGIN_BY_KEY, // 15
QID_PLAYER_INDEX_CREATE, // 16 QID_PLAYER_INDEX_CREATE, // 16
QID_ITEM_AWARD_LOAD, // 17 QID_ITEM_AWARD_LOAD, // 17
QID_ITEM_AWARD_TAKEN, // 18 QID_ITEM_AWARD_TAKEN, // 18
QID_GUILD_RANKING, // 19 QID_GUILD_RANKING, // 19
// MYSHOP_PRICE_LIST // MYSHOP_PRICE_LIST
QID_ITEMPRICE_SAVE, ///< 20, 아이템 가격정보 저장 쿼리 QID_ITEMPRICE_SAVE, ///< 20, 아이템 가격정보 저장 쿼리
QID_ITEMPRICE_DESTROY, ///< 21, 아이템 가격정보 삭제 쿼리 QID_ITEMPRICE_DESTROY, ///< 21, 아이템 가격정보 삭제 쿼리
QID_ITEMPRICE_LOAD_FOR_UPDATE, ///< 22, 가격정보 업데이트를 위한 아이템 가격정보 로드 쿼리 QID_ITEMPRICE_LOAD_FOR_UPDATE, ///< 22, 가격정보 업데이트를 위한 아이템 가격정보 로드 쿼리
QID_ITEMPRICE_LOAD, ///< 22, 아이템 가격정보 로드 쿼리 QID_ITEMPRICE_LOAD, ///< 22, 아이템 가격정보 로드 쿼리
// END_OF_MYSHOP_PRICE_LIST // END_OF_MYSHOP_PRICE_LIST
}; };
#endif #endif

View File

@ -9,7 +9,7 @@ CGrid::CGrid(int w, int h) : m_iWidth(w), m_iHeight(h)
memset(m_pGrid, 0, sizeof(char) * m_iWidth * m_iHeight); memset(m_pGrid, 0, sizeof(char) * m_iWidth * m_iHeight);
} }
CGrid::CGrid(CGrid * pkGrid, int w, int h) : m_iWidth(w), m_iHeight(h) CGrid::CGrid(CGrid *pkGrid, int w, int h) : m_iWidth(w), m_iHeight(h)
{ {
m_pGrid = new char[m_iWidth * m_iHeight]; m_pGrid = new char[m_iWidth * m_iHeight];
int iSize = std::min(w * h, pkGrid->m_iWidth * pkGrid->m_iHeight); int iSize = std::min(w * h, pkGrid->m_iWidth * pkGrid->m_iHeight);
@ -18,7 +18,7 @@ CGrid::CGrid(CGrid * pkGrid, int w, int h) : m_iWidth(w), m_iHeight(h)
CGrid::~CGrid() CGrid::~CGrid()
{ {
delete [] m_pGrid; delete[] m_pGrid;
} }
void CGrid::Clear() void CGrid::Clear()
@ -126,4 +126,3 @@ unsigned int CGrid::GetSize()
{ {
return m_iWidth * m_iHeight; return m_iWidth * m_iHeight;
} }

View File

@ -4,24 +4,24 @@
class CGrid class CGrid
{ {
public: public:
CGrid(int w, int h); CGrid(int w, int h);
CGrid(CGrid * pkGrid, int w, int h); CGrid(CGrid *pkGrid, int w, int h);
~CGrid(); ~CGrid();
void Clear(); void Clear();
int FindBlank(int w, int h); int FindBlank(int w, int h);
bool IsEmpty(int iPos, int w, int h); bool IsEmpty(int iPos, int w, int h);
bool Put(int iPos, int w, int h); bool Put(int iPos, int w, int h);
void Get(int iPos, int w, int h); void Get(int iPos, int w, int h);
void Print(); void Print();
unsigned int GetSize(); unsigned int GetSize();
protected: protected:
int m_iWidth; int m_iWidth;
int m_iHeight; int m_iHeight;
char * m_pGrid; char *m_pGrid;
}; };
#endif #endif

View File

@ -3,12 +3,7 @@
#include <libthecore/include/stdafx.h> #include <libthecore/include/stdafx.h>
#ifndef __WIN32__
#include <semaphore.h> #include <semaphore.h>
#else
#define isdigit iswdigit
#define isspace iswspace
#endif
#include <common/length.h> #include <common/length.h>
#include <common/tables.h> #include <common/tables.h>

View File

@ -1,8 +1,12 @@
#include <fmt/core.h> #include <fmt/core.h>
#ifndef __INTELLISENSE__
#include <version.h> #include <version.h>
#else
#include <../../../common/version.h>
#endif
void WriteVersion() { void WriteVersion()
{
fmt::println("Metin2 DB Cache version {} (rev. {}, date: {})", __COMMIT_TAG__, __REVISION__, __COMMIT_DATE__); fmt::println("Metin2 DB Cache version {} (rev. {}, date: {})", __COMMIT_TAG__, __REVISION__, __COMMIT_DATE__);
fmt::println("OS: {}, target arch: {}, compiler: {}", __OS_NAME__, __CPU_TARGET__, __COMPILER__); fmt::println("OS: {}, target arch: {}, compiler: {}", __OS_NAME__, __CPU_TARGET__, __COMPILER__);
} }

View File

@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.8) cmake_minimum_required(VERSION 3.12)
project(game CXX) project(game CXX)
@ -26,32 +26,33 @@ target_compile_options(${PROJECT_NAME} PUBLIC -fsigned-char)
# vcpkg dependencies # vcpkg dependencies
# #
# MariaDB # PostgreSQL with libpqxx (stable vcpkg package)
find_package(unofficial-libmariadb REQUIRED) find_package(PostgreSQL REQUIRED)
target_link_libraries(${PROJECT_NAME} unofficial::libmariadb) find_package(libpqxx CONFIG REQUIRED)
target_link_libraries(${PROJECT_NAME} PRIVATE libpqxx::pqxx)
# Argon2 # Argon2
find_package(unofficial-argon2 CONFIG REQUIRED) find_package(unofficial-argon2 CONFIG REQUIRED)
target_link_libraries(${PROJECT_NAME} unofficial::argon2::libargon2) target_link_libraries(${PROJECT_NAME} PRIVATE unofficial::argon2::libargon2)
# Crypto++ # Crypto++
find_package(cryptopp CONFIG REQUIRED) find_package(cryptopp CONFIG REQUIRED)
target_link_libraries(${PROJECT_NAME} cryptopp::cryptopp) target_link_libraries(${PROJECT_NAME} PRIVATE cryptopp::cryptopp)
# Libevent # Libevent
find_package(Libevent CONFIG REQUIRED) find_package(Libevent CONFIG REQUIRED)
target_link_libraries(${PROJECT_NAME} libevent::core libevent::extra libevent::pthreads) target_link_libraries(${PROJECT_NAME} PRIVATE libevent::core libevent::extra libevent::pthreads)
# LZO # LZO
find_package(LZO REQUIRED) find_package(LZO REQUIRED)
if (LZO_FOUND) if (LZO_FOUND)
include_directories(${LZO_INCLUDE_DIR}) include_directories(${LZO_INCLUDE_DIR})
target_link_libraries(${PROJECT_NAME} ${LZO_LIBRARIES}) target_link_libraries(${PROJECT_NAME} PRIVATE ${LZO_LIBRARIES})
endif (LZO_FOUND) endif (LZO_FOUND)
# effolkronium/random # effolkronium/random
find_package(effolkronium_random CONFIG REQUIRED) find_package(effolkronium_random CONFIG REQUIRED)
target_link_libraries(${PROJECT_NAME} effolkronium_random) target_link_libraries(${PROJECT_NAME} PRIVATE effolkronium_random)
# #
# System-provided dependencies # System-provided dependencies
@ -60,18 +61,18 @@ target_link_libraries(${PROJECT_NAME} effolkronium_random)
# DevIL # DevIL
find_package(DevIL REQUIRED) find_package(DevIL REQUIRED)
include_directories(${IL_INCLUDE_DIR}) include_directories(${IL_INCLUDE_DIR})
target_link_libraries(${PROJECT_NAME} ${IL_LIBRARIES}) target_link_libraries(${PROJECT_NAME} PRIVATE ${IL_LIBRARIES})
# Pthreads # Pthreads
set(THREADS_PREFER_PTHREAD_FLAG ON) set(THREADS_PREFER_PTHREAD_FLAG ON)
find_package(Threads REQUIRED) find_package(Threads REQUIRED)
target_link_libraries(${PROJECT_NAME} Threads::Threads) target_link_libraries(${PROJECT_NAME} PRIVATE Threads::Threads)
# LibBSD # LibBSD
target_link_libraries(${PROJECT_NAME} bsd) target_link_libraries(${PROJECT_NAME} PRIVATE bsd)
# #
# Project-provided dependencies # Project-provided dependencies
# #
target_link_libraries(${PROJECT_NAME} libgame libpoly libsql libthecore liblua) target_link_libraries(${PROJECT_NAME} PRIVATE libgame libpoly libsql libthecore liblua)

View File

@ -1,10 +1,6 @@
#include "stdafx.h" #include "stdafx.h"
#include "MarkManager.h" #include "MarkManager.h"
#ifdef __WIN32__
#include <direct.h>
#endif
#define OLD_MARK_INDEX_FILENAME "guild_mark.idx" #define OLD_MARK_INDEX_FILENAME "guild_mark.idx"
#define OLD_MARK_DATA_FILENAME "guild_mark.tga" #define OLD_MARK_DATA_FILENAME "guild_mark.tga"
@ -31,18 +27,10 @@ static Pixel * LoadOldGuildMarkImageFile()
bool GuildMarkConvert(const std::vector<DWORD> & vecGuildID) bool GuildMarkConvert(const std::vector<DWORD> & vecGuildID)
{ {
// 폴더 생성 // 폴더 생성
#ifndef __WIN32__
mkdir("mark", S_IRWXU); mkdir("mark", S_IRWXU);
#else
_mkdir("mark");
#endif
// 인덱스 파일이 있나? // 인덱스 파일이 있나?
#ifndef __WIN32__
if (0 != access(OLD_MARK_INDEX_FILENAME, F_OK)) if (0 != access(OLD_MARK_INDEX_FILENAME, F_OK))
#else
if (0 != _access(OLD_MARK_INDEX_FILENAME, 0))
#endif
return true; return true;
// 인덱스 파일 열기 // 인덱스 파일 열기
@ -120,13 +108,8 @@ bool GuildMarkConvert(const std::vector<DWORD> & vecGuildID)
fclose(fp); fclose(fp);
// 컨버트는 한번만 하면되므로 파일을 옮겨준다. // 컨버트는 한번만 하면되므로 파일을 옮겨준다.
#ifndef __WIN32__
system("mv -f guild_mark.idx guild_mark.idx.removable"); system("mv -f guild_mark.idx guild_mark.idx.removable");
system("mv -f guild_mark.tga guild_mark.tga.removable"); system("mv -f guild_mark.tga guild_mark.tga.removable");
#else
system("move /Y guild_mark.idx guild_mark.idx.removable");
system("move /Y guild_mark.tga guild_mark.tga.removable");
#endif
SPDLOG_INFO("Guild Mark Converting Complete."); SPDLOG_INFO("Guild Mark Converting Complete.");

File diff suppressed because it is too large Load Diff

View File

@ -1,218 +0,0 @@
#ifndef __INC_AUCTION_MANAGER_H
#define __INC_AUCTION_MANAGER_H
#include <libsql/include/AsyncSQL.h>
#include <common/auction_table.h>
#include <unordered_map>
#include <algorithm>
#define GRADE_LOW 30
#define GRADE_MID 60
#define GRADE_HIGH 90
template<>
class hash<std::pair <DWORD, DWORD> >
{ // hash functor
public:
typedef std::pair <DWORD, DWORD> _Kty;
size_t operator()(const _Kty& _Keyval) const
{ // hash _Keyval to size_t value by pseudorandomizing transform
ldiv_t _Qrem = ldiv((size_t)_Keyval.first + (size_t)_Keyval.second, 127773);
_Qrem.rem = 16807 * _Qrem.rem - 2836 * _Qrem.quot;
if (_Qrem.rem < 0)
_Qrem.rem += 2147483647;
return ((size_t)_Qrem.rem);
}
};
bool CompareItemInfoByItemNameAC (TAuctionItemInfo* i, TAuctionItemInfo* j);
bool CompareItemInfoByItemNameDC (TAuctionItemInfo* i, TAuctionItemInfo* j);
bool CompareItemInfoByCategoryAC (TAuctionItemInfo* i, TAuctionItemInfo* j);
bool CompareItemInfoByCategoryDC (TAuctionItemInfo* i, TAuctionItemInfo* j);
bool CompareItemInfoByTimeAC (TAuctionItemInfo* i, TAuctionItemInfo* j);
bool CompareItemInfoByTimeDC (TAuctionItemInfo* i, TAuctionItemInfo* j);
bool CompareItemInfoByCharNameAC (TAuctionItemInfo* i, TAuctionItemInfo* j);
bool CompareItemInfoByCharNameDC (TAuctionItemInfo* i, TAuctionItemInfo* j);
bool CompareItemInfoByPriceAC (TAuctionItemInfo* i, TAuctionItemInfo* j);
bool CompareItemInfoByPriceDC (TAuctionItemInfo* i, TAuctionItemInfo* j);
class AuctionBoard
{
public:
AuctionBoard() {}
~AuctionBoard() {}
TAuctionItemInfo* GetItemInfo (DWORD key);
bool DeleteItemInfo (DWORD key);
bool InsertItemInfo (TAuctionItemInfo* item_info);
bool UpdateItemInfo (TAuctionItemInfo* item_info);
private:
typedef std::unordered_map <DWORD, TAuctionItemInfo*> TItemInfoMap;
TItemInfoMap item_map;
typedef std::map <DWORD, TAuctionItemInfo*> TItemMap;
typedef std::unordered_map <DWORD, TItemMap*> TPCMap;
TPCMap offer_map;
// sorting을 위한 members
public:
typedef std::vector <TAuctionItemInfo*> TItemInfoVec;
private:
typedef std::map <std::string, TItemInfoVec*> SortByItemName;
SortByItemName item_name_map;
void Sort(TItemInfoVec& vec, BYTE order);
public:
void SortedItemInfos (TItemInfoVec& vec, BYTE grade, BYTE category, int start_idx, BYTE size, BYTE order[5]);
// 나의 경매장을 위한 함수.
void YourItemInfoList (TItemInfoVec& vec, DWORD player_id, int start_idx, BYTE size);
};
class SaleBoard
{
private:
typedef std::unordered_map <DWORD, TSaleItemInfo*> TItemInfoMap;
TItemInfoMap item_map;
typedef std::map <DWORD, TSaleItemInfo*> TItemMap;
typedef std::unordered_map <DWORD, TItemMap*> TPCMap;
TPCMap wisher_map;
TPCMap seller_map;
bool DeleteFromPCMap (TPCMap& pc_map, DWORD player_id, DWORD item_id);
bool InsertInPCMap (TPCMap& pc_map, DWORD player_id, TSaleItemInfo* item_info);
public:
SaleBoard() {}
~SaleBoard() {}
typedef std::vector <TSaleItemInfo*> TItemInfoVec;
void WisherItemInfoList (TItemInfoVec& vec, DWORD wisher_id, int start_idx, BYTE size);
TSaleItemInfo* GetItemInfo (DWORD key);
bool DeleteItemInfo (DWORD key);
bool InsertItemInfo (TSaleItemInfo* item_info);
};
class WishBoard
{
private:
typedef std::map <DWORD, TWishItemInfo*> TItemMap;
typedef std::unordered_map <DWORD, TItemMap*> TPCMap;
TPCMap wisher_map;
public:
typedef TWishItemInfo ItemInfo;
WishBoard() {}
~WishBoard() {}
TWishItemInfo* GetItemInfo (DWORD wisher_id, DWORD item_num);
bool DeleteItemInfo (DWORD wisher_id, DWORD item_num);
bool InsertItemInfo (TWishItemInfo* item_info);
};
class MyBidBoard
{
private:
typedef std::pair <int, bool> BidInfo;
typedef std::map <DWORD, BidInfo > TItemMap;
typedef std::unordered_map <DWORD, TItemMap*> TMyBidBoard;
// bidder_id가 key
TMyBidBoard pc_map;
public:
MyBidBoard() {}
~MyBidBoard() {}
typedef std::vector <DWORD> TItemVec;
void YourBidInfo (TItemVec& vec, DWORD bidder_id, int start_idx, int size);
BidInfo GetMoney (DWORD player_id, DWORD item_id);
bool Delete (DWORD player_id, DWORD item_id);
// 이미 있으면 덮어 씌운다.
void Insert (DWORD player_id, DWORD item_id, int money);
void Lock (DWORD player_id, DWORD item_id);
void UnLock (DWORD player_id, DWORD item_id);
};
class AuctionManager : public singleton <AuctionManager>
{
private :
typedef std::unordered_map<DWORD, LPITEM> TItemMap;
TItemMap auction_item_map;
// auction에 등록된 정보 중 가격, 등등 아이템 테이블에 포함되지 않는 정보들을 관리하는 것들
AuctionBoard Auction;
SaleBoard Sale;
WishBoard Wish;
MyBidBoard MyBid;
public:
bool InsertItem (LPITEM item);
bool InsertItem (TPlayerItem* player_item);
LPITEM GetInventoryItem (DWORD item_id);
bool DeleteItem (DWORD item_id);
bool InsertAuctionItemInfo (TAuctionItemInfo* item_info);
TAuctionItemInfo* GetAuctionItemInfo (DWORD item_id)
{
return Auction.GetItemInfo (item_id);
}
bool InsertSaleItemInfo (TSaleItemInfo* item_info);
TSaleItemInfo* GetSaleItemInfo (DWORD item_id)
{
return Sale.GetItemInfo (item_id);
}
bool InsertWishItemInfo (TWishItemInfo* item_info);
TWishItemInfo* GetWishItemInfo (DWORD wisher_id, DWORD item_id)
{
return Wish.GetItemInfo (wisher_id, item_id);
}
void YourBidItemInfoList (AuctionBoard::TItemInfoVec& vec, DWORD bidder_id, int start_idx, int size);
void Boot (const char* &pdata, WORD size);
void get_auction_list (LPCHARACTER ch, int start_idx, int size, int cond);
void get_my_auction_list (LPCHARACTER ch, int start_idx, int size);
void get_my_purchase_list (LPCHARACTER ch, int start_idx, int size);
void enroll_auction (LPCHARACTER ch, LPITEM item, BYTE empire, int bidPrice, int immidiatePurchasePrice);
void recv_result_auction (DWORD commander_id, TPacketDGResultAuction* cmd_result);
void bid (LPCHARACTER ch, DWORD item_id, int price);
void immediate_purchase (LPCHARACTER ch, DWORD item_id);
void enroll_sale (LPCHARACTER ch, LPITEM item, DWORD wisher_id, int salePrice);
void enroll_wish (LPCHARACTER ch, DWORD item_num, BYTE empire, int wishPrice);
void get_auctioned_item (LPCHARACTER ch, DWORD item_id, DWORD item_num);
void buy_sold_item (LPCHARACTER ch, DWORD item_id);
void cancel_auction (LPCHARACTER ch, DWORD item_id);
void cancel_wish (LPCHARACTER ch, DWORD item_num);
void cancel_sale (LPCHARACTER ch, DWORD item_id);
void rebid (LPCHARACTER ch, DWORD item_id, int price);
void bid_cancel (LPCHARACTER ch, DWORD item_id);
/*
void close_auction (LPCHARACTER ch);*/
};
#endif

View File

@ -1,5 +0,0 @@
typedef struct packet_auction_simple_item_info
{
BYTE header;
BYTE size;
} TPacketGCAuctionItemSimpleInfo;

View File

@ -112,6 +112,9 @@ int CHARACTER::ChangeEmpire(BYTE empire)
// 5. 제국 변경 이력을 추가한다. // 5. 제국 변경 이력을 추가한다.
SetChangeEmpireCount(); SetChangeEmpireCount();
SetEmpire(empire);
UpdatePacket();
return 999; return 999;
} }
} }

View File

@ -44,10 +44,6 @@
#include "buff_on_attributes.h" #include "buff_on_attributes.h"
#include "belt_inventory_helper.h" #include "belt_inventory_helper.h"
//auction_temp
#ifdef __AUCTION__
#include "auction_manager.h"
#endif
const int ITEM_BROKEN_METIN_VNUM = 28960; const int ITEM_BROKEN_METIN_VNUM = 28960;
// CHANGE_ITEM_ATTRIBUTES // CHANGE_ITEM_ATTRIBUTES

View File

@ -229,27 +229,6 @@ ACMD(do_click_mall);
ACMD(do_ride); ACMD(do_ride);
ACMD(do_get_item_id_list); ACMD(do_get_item_id_list);
ACMD(do_set_socket); ACMD(do_set_socket);
#ifdef __AUCTION__
// temp_auction 임시
ACMD(do_get_auction_list);
ACMD (do_get_my_auction_list);
ACMD (do_get_my_purchase_list);
ACMD(do_get_item_id_list);
ACMD(do_enroll_auction);
ACMD (do_auction_bid);
ACMD (do_auction_impur);
ACMD (do_enroll_wish);
ACMD (do_enroll_sale);
ACMD (do_get_auctioned_item);
ACMD (do_buy_sold_item);
ACMD (do_cancel_auction);
ACMD (do_cancel_wish);
ACMD (do_cancel_sale);
ACMD (do_rebid);
ACMD (do_bid_cancel);
#endif
// 코스츔 상태보기 및 벗기 // 코스츔 상태보기 및 벗기
ACMD(do_costume); ACMD(do_costume);
ACMD(do_set_stat); ACMD(do_set_stat);
@ -534,27 +513,7 @@ struct command_info cmd_info[] =
{ "item_id_list", do_get_item_id_list, 0, POS_DEAD, GM_LOW_WIZARD }, { "item_id_list", do_get_item_id_list, 0, POS_DEAD, GM_LOW_WIZARD },
{ "set_socket", do_set_socket, 0, POS_DEAD, GM_LOW_WIZARD }, { "set_socket", do_set_socket, 0, POS_DEAD, GM_LOW_WIZARD },
#ifdef __AUCTION__
// auction 임시
{ "auction_list", do_get_auction_list, 0, POS_DEAD, GM_PLAYER },
{ "my_auction_list", do_get_my_auction_list, 0, POS_DEAD, GM_PLAYER },
{ "my_purchase_list", do_get_my_purchase_list, 0, POS_DEAD, GM_PLAYER },
{ "enroll_auction", do_enroll_auction, 0, POS_DEAD, GM_PLAYER },
{ "bid", do_auction_bid, 0, POS_DEAD, GM_PLAYER },
{ "impur", do_auction_impur, 0, POS_DEAD, GM_PLAYER },
{ "enroll_wish", do_enroll_wish, 0, POS_DEAD, GM_PLAYER },
{ "enroll_sale", do_enroll_sale, 0, POS_DEAD, GM_PLAYER },
{ "get_auctioned_item", do_get_auctioned_item, 0, POS_DEAD, GM_PLAYER },
{ "buy_sold_item", do_buy_sold_item, 0, POS_DEAD, GM_PLAYER },
{ "cancel_auction", do_cancel_auction, 0, POS_DEAD, GM_PLAYER },
{ "cancel_wish", do_cancel_wish, 0, POS_DEAD, GM_PLAYER },
{ "cancel_sale", do_cancel_sale, 0, POS_DEAD, GM_PLAYER },
{ "rebid", do_rebid, 0, POS_DEAD, GM_PLAYER },
{ "bid_cancel", do_bid_cancel, 0, POS_DEAD, GM_PLAYER },
#endif
{ "costume", do_costume, 0, POS_DEAD, GM_PLAYER }, { "costume", do_costume, 0, POS_DEAD, GM_PLAYER },
{ "tcon", do_set_stat, POINT_HT, POS_DEAD, GM_LOW_WIZARD }, { "tcon", do_set_stat, POINT_HT, POS_DEAD, GM_LOW_WIZARD },

View File

@ -33,9 +33,6 @@
#include <cryptopp/sha.h> #include <cryptopp/sha.h>
#include <cryptopp/hex.h> #include <cryptopp/hex.h>
#include <cryptopp/filters.h> #include <cryptopp/filters.h>
#ifdef __AUCTION__
#include "auction_manager.h"
#endif
extern int g_server_id; extern int g_server_id;
@ -2377,186 +2374,3 @@ ACMD(do_ride)
// 타거나 내릴 수 없을때 // 타거나 내릴 수 없을때
ch->ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Please call your Horse first.")); ch->ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Please call your Horse first."));
} }
#ifdef __AUCTION__
// temp_auction
ACMD(do_get_item_id_list)
{
for (int i = 0; i < INVENTORY_MAX_NUM; i++)
{
LPITEM item = ch->GetInventoryItem(i);
if (item != NULL)
ch->ChatPacket(CHAT_TYPE_INFO, "name : %s id : %d", item->GetProto()->szName, item->GetID());
}
}
// temp_auction
ACMD(do_enroll_auction)
{
char arg1[256];
char arg2[256];
char arg3[256];
char arg4[256];
two_arguments (two_arguments(argument, arg1, sizeof(arg1), arg2, sizeof(arg2)), arg3, sizeof(arg3), arg4, sizeof(arg4));
DWORD item_id = strtoul(arg1, NULL, 10);
BYTE empire = strtoul(arg2, NULL, 10);
int bidPrice = strtol(arg3, NULL, 10);
int immidiatePurchasePrice = strtol(arg4, NULL, 10);
LPITEM item = ITEM_MANAGER::instance().Find(item_id);
if (item == NULL)
return;
AuctionManager::instance().enroll_auction(ch, item, empire, bidPrice, immidiatePurchasePrice);
}
ACMD(do_enroll_wish)
{
char arg1[256];
char arg2[256];
char arg3[256];
one_argument (two_arguments(argument, arg1, sizeof(arg1), arg2, sizeof(arg2)), arg3, sizeof(arg3));
DWORD item_num = strtoul(arg1, NULL, 10);
BYTE empire = strtoul(arg2, NULL, 10);
int wishPrice = strtol(arg3, NULL, 10);
AuctionManager::instance().enroll_wish(ch, item_num, empire, wishPrice);
}
ACMD(do_enroll_sale)
{
char arg1[256];
char arg2[256];
char arg3[256];
one_argument (two_arguments(argument, arg1, sizeof(arg1), arg2, sizeof(arg2)), arg3, sizeof(arg3));
DWORD item_id = strtoul(arg1, NULL, 10);
DWORD wisher_id = strtoul(arg2, NULL, 10);
int salePrice = strtol(arg3, NULL, 10);
LPITEM item = ITEM_MANAGER::instance().Find(item_id);
if (item == NULL)
return;
AuctionManager::instance().enroll_sale(ch, item, wisher_id, salePrice);
}
// temp_auction
// packet으로 통신하게 하고, 이건 삭제해야한다.
ACMD(do_get_auction_list)
{
char arg1[256];
char arg2[256];
char arg3[256];
two_arguments (one_argument (argument, arg1, sizeof(arg1)), arg2, sizeof(arg2), arg3, sizeof(arg3));
AuctionManager::instance().get_auction_list (ch, strtoul(arg1, NULL, 10), strtoul(arg2, NULL, 10), strtoul(arg3, NULL, 10));
}
//
//ACMD(do_get_wish_list)
//{
// char arg1[256];
// char arg2[256];
// char arg3[256];
// two_arguments (one_argument (argument, arg1, sizeof(arg1)), arg2, sizeof(arg2), arg3, sizeof(arg3));
//
// AuctionManager::instance().get_wish_list (ch, strtoul(arg1, NULL, 10), strtoul(arg2, NULL, 10), strtoul(arg3, NULL, 10));
//}
ACMD (do_get_my_auction_list)
{
char arg1[256];
char arg2[256];
two_arguments (argument, arg1, sizeof(arg1), arg2, sizeof(arg2));
AuctionManager::instance().get_my_auction_list (ch, strtoul(arg1, NULL, 10), strtoul(arg2, NULL, 10));
}
ACMD (do_get_my_purchase_list)
{
char arg1[256];
char arg2[256];
two_arguments (argument, arg1, sizeof(arg1), arg2, sizeof(arg2));
AuctionManager::instance().get_my_purchase_list (ch, strtoul(arg1, NULL, 10), strtoul(arg2, NULL, 10));
}
ACMD (do_auction_bid)
{
char arg1[256];
char arg2[256];
two_arguments (argument, arg1, sizeof(arg1), arg2, sizeof(arg2));
AuctionManager::instance().bid (ch, strtoul(arg1, NULL, 10), strtoul(arg2, NULL, 10));
}
ACMD (do_auction_impur)
{
char arg1[256];
one_argument (argument, arg1, sizeof(arg1));
AuctionManager::instance().immediate_purchase (ch, strtoul(arg1, NULL, 10));
}
ACMD (do_get_auctioned_item)
{
char arg1[256];
char arg2[256];
two_arguments (argument, arg1, sizeof(arg1), arg2, sizeof(arg2));
AuctionManager::instance().get_auctioned_item (ch, strtoul(arg1, NULL, 10), strtoul(arg2, NULL, 10));
}
ACMD (do_buy_sold_item)
{
char arg1[256];
char arg2[256];
one_argument (argument, arg1, sizeof(arg1));
AuctionManager::instance().get_auctioned_item (ch, strtoul(arg1, NULL, 10), strtoul(arg2, NULL, 10));
}
ACMD (do_cancel_auction)
{
char arg1[256];
one_argument (argument, arg1, sizeof(arg1));
AuctionManager::instance().cancel_auction (ch, strtoul(arg1, NULL, 10));
}
ACMD (do_cancel_wish)
{
char arg1[256];
one_argument (argument, arg1, sizeof(arg1));
AuctionManager::instance().cancel_wish (ch, strtoul(arg1, NULL, 10));
}
ACMD (do_cancel_sale)
{
char arg1[256];
one_argument (argument, arg1, sizeof(arg1));
AuctionManager::instance().cancel_sale (ch, strtoul(arg1, NULL, 10));
}
ACMD (do_rebid)
{
char arg1[256];
char arg2[256];
two_arguments (argument, arg1, sizeof(arg1), arg2, sizeof(arg2));
AuctionManager::instance().rebid (ch, strtoul(arg1, NULL, 10), strtoul(arg2, NULL, 10));
}
ACMD (do_bid_cancel)
{
char arg1[256];
char arg2[256];
two_arguments (argument, arg1, sizeof(arg1), arg2, sizeof(arg2));
AuctionManager::instance().bid_cancel (ch, strtoul(arg1, NULL, 10));
}
#endif

View File

@ -1,8 +1,6 @@
#include "stdafx.h" #include "stdafx.h"
#include <sstream> #include <sstream>
#ifndef __WIN32__
#include <ifaddrs.h> #include <ifaddrs.h>
#endif
#include "constants.h" #include "constants.h"
#include "utils.h" #include "utils.h"
@ -47,9 +45,6 @@ DWORD g_dwTrafficProfileFlushCycle = 3600;
int test_server = 0; int test_server = 0;
int speed_server = 0; int speed_server = 0;
#ifdef __AUCTION__
int auction_server = 0;
#endif
bool distribution_test_server = false; bool distribution_test_server = false;
bool china_event_server = false; bool china_event_server = false;
bool guild_mark_server = true; bool guild_mark_server = true;
@ -809,16 +804,7 @@ void config_init(const string& st_localeServiceName)
continue; continue;
} }
#ifdef __AUCTION__
TOKEN("auction_server")
{
printf("-----------------------------------------------\n");
printf("AUCTION_SERVER\n");
printf("-----------------------------------------------\n");
str_to_number(auction_server, value_string);
continue;
}
#endif
TOKEN("distribution_test_server") TOKEN("distribution_test_server")
{ {
str_to_number(distribution_test_server, value_string); str_to_number(distribution_test_server, value_string);

View File

@ -41,13 +41,7 @@
#include "DragonSoul.h" #include "DragonSoul.h"
#ifdef __AUCTION__
#include "auction_manager.h"
#endif
extern BYTE g_bAuthServer; extern BYTE g_bAuthServer;
#ifdef __AUCTION__
extern int auction_server;
#endif
extern void gm_insert(const char * name, BYTE level); extern void gm_insert(const char * name, BYTE level);
extern BYTE gm_get_level(const char * name, const char * host, const char* account ); extern BYTE gm_get_level(const char * name, const char * host, const char* account );
extern void gm_host_insert(const char * host); extern void gm_host_insert(const char * host);
@ -753,10 +747,7 @@ void CInputDB::Boot(const char* data)
for (WORD i = 0; i < size; ++i, ++kObj) for (WORD i = 0; i < size; ++i, ++kObj)
CManager::instance().LoadObject(kObj, true); CManager::instance().LoadObject(kObj, true);
} }
#ifdef __AUCTION__
// Auction
AuctionManager::instance().Boot(data);
#endif
set_global_time(*(time_t *) data); set_global_time(*(time_t *) data);
data += sizeof(time_t); data += sizeof(time_t);
@ -2246,12 +2237,6 @@ int CInputDB::Analyze(LPDESC d, BYTE bHeader, const char * c_pData)
case HEADER_DG_RESPOND_CHANNELSTATUS: case HEADER_DG_RESPOND_CHANNELSTATUS:
RespondChannelStatus(DESC_MANAGER::instance().FindByHandle(m_dwHandle), c_pData); RespondChannelStatus(DESC_MANAGER::instance().FindByHandle(m_dwHandle), c_pData);
break; break;
#ifdef __AUCTION__
case HEADER_DG_AUCTION_RESULT:
if (auction_server)
AuctionManager::instance().recv_result_auction(m_dwHandle, (TPacketDGResultAuction*)c_pData);
break;
#endif
default: default:
return (-1); return (-1);
} }

View File

@ -1901,52 +1901,6 @@ bool CItem::OnAfterCreatedItem()
return true; return true;
} }
#ifdef __AUCTION__
// 경매장
// window를 경매장으로 한다.
bool CItem::MoveToAuction()
{
LPCHARACTER owner = GetOwner();
if (owner == NULL)
{
SPDLOG_ERROR("Item those owner is not exist cannot regist in auction");
return false;
}
if (GetWindow() == AUCTION)
{
SPDLOG_ERROR("Item is already in auction.");
}
SetWindow(AUCTION);
owner->SetItem(m_bCell, NULL);
Save();
ITEM_MANAGER::instance().FlushDelayedSave(this);
return true;
}
void CItem::CopyToRawData (TPlayerItem* new_item)
{
if (new_item != NULL)
return;
new_item->id = m_dwID;
new_item->window = m_bWindow;
new_item->pos = m_bCell;
new_item->count = m_dwCount;
new_item->vnum = GetVnum();
memcpy (new_item->alSockets, m_alSockets, sizeof (m_alSockets));
memcpy (new_item->aAttr, m_aAttr, sizeof (m_aAttr));
new_item->owner = m_pOwner->GetPlayerID();
}
#endif
bool CItem::IsDragonSoul() bool CItem::IsDragonSoul()
{ {
return GetType() == ITEM_DS; return GetType() == ITEM_DS;

View File

@ -234,11 +234,6 @@ class CItem : public CEntity
void ClearMountAttributeAndAffect(); void ClearMountAttributeAndAffect();
bool IsNewMountItem(); bool IsNewMountItem();
#ifdef __AUCTION__
// 경매장
bool MoveToAuction ();
void CopyToRawData (TPlayerItem* item);
#endif
// 독일에서 기존 캐시 아이템과 같지만, 교환 가능한 캐시 아이템을 만든다고 하여, // 독일에서 기존 캐시 아이템과 같지만, 교환 가능한 캐시 아이템을 만든다고 하여,
// 오리지널 아이템에, 교환 금지 플래그만 삭제한 새로운 아이템들을 새로운 아이템 대역에 할당하였다. // 오리지널 아이템에, 교환 금지 플래그만 삭제한 새로운 아이템들을 새로운 아이템 대역에 할당하였다.
// 문제는 새로운 아이템도 오리지널 아이템과 같은 효과를 내야하는데, // 문제는 새로운 아이템도 오리지널 아이템과 같은 효과를 내야하는데,

View File

@ -123,11 +123,6 @@ void LogManager::HackLog(const char * c_pszHackName, LPCHARACTER ch)
} }
} }
void LogManager::HackCRCLog(const char * c_pszHackName, const char * c_pszLogin, const char * c_pszName, const char * c_pszIP, DWORD dwCRC)
{
Query("INSERT INTO hack_crc_log (time, login, name, ip, server, why, crc) VALUES(NOW(), '%s', '%s', '%s', '%s', '%s', %u)", c_pszLogin, c_pszName, c_pszIP, g_stHostname.c_str(), c_pszHackName, dwCRC);
}
void LogManager::GoldBarLog(DWORD dwPID, DWORD dwItemID, GOLDBAR_HOW eHow, const char* c_pszHint) void LogManager::GoldBarLog(DWORD dwPID, DWORD dwItemID, GOLDBAR_HOW eHow, const char* c_pszHint)
{ {
char szHow[32+1]; char szHow[32+1];
@ -294,34 +289,3 @@ void LogManager::DragonSlayLog(DWORD dwGuildID, DWORD dwDragonVnum, DWORD dwStar
get_table_postfix(), get_table_postfix(),
dwGuildID, dwDragonVnum, dwStartTime, dwEndTime); dwGuildID, dwDragonVnum, dwStartTime, dwEndTime);
} }
void LogManager::HackShieldLog(unsigned int ErrorCode, LPCHARACTER ch)
{
struct in_addr st_addr;
#ifndef __WIN32__
if (0 == inet_aton(ch->GetDesc()->GetHostName(), &st_addr))
#else
unsigned int in_address;
in_address = inet_addr(ch->GetDesc()->GetHostName());
st_addr.s_addr = in_address;
if (INADDR_NONE == in_address)
#endif
{
Query( "INSERT INTO hackshield_log(time, account_id, login, pid, name, reason, ip) "
"VALUES(NOW(), %u, '%s', %u, '%s', %u, 0)",
ch->GetDesc()->GetAccountTable().id, ch->GetDesc()->GetAccountTable().login,
ch->GetPlayerID(), ch->GetName(),
ErrorCode);
}
else
{
Query( "INSERT INTO hackshield_log(time, account_id, login, pid, name, reason, ip) "
"VALUES(NOW(), %u, '%s', %u, '%s', %u, inet_aton('%s'))",
ch->GetDesc()->GetAccountTable().id, ch->GetDesc()->GetAccountTable().login,
ch->GetPlayerID(), ch->GetName(),
ErrorCode,
ch->GetDesc()->GetHostName());
}
}

View File

@ -36,7 +36,6 @@ class LogManager : public singleton<LogManager>
void MoneyLog(BYTE type, DWORD vnum, int gold); void MoneyLog(BYTE type, DWORD vnum, int gold);
void HackLog(const char * c_pszHackName, const char * c_pszLogin, const char * c_pszName, const char * c_pszIP); void HackLog(const char * c_pszHackName, const char * c_pszLogin, const char * c_pszName, const char * c_pszIP);
void HackLog(const char * c_pszHackName, LPCHARACTER ch); void HackLog(const char * c_pszHackName, LPCHARACTER ch);
void HackCRCLog(const char * c_pszHackName, const char * c_pszLogin, const char * c_pszName, const char * c_pszIP, DWORD dwCRC);
void GoldBarLog(DWORD dwPID, DWORD dwItemID, GOLDBAR_HOW eHow, const char * c_pszHint); void GoldBarLog(DWORD dwPID, DWORD dwItemID, GOLDBAR_HOW eHow, const char * c_pszHint);
void CubeLog(DWORD dwPID, DWORD x, DWORD y, DWORD item_vnum, DWORD item_uid, int item_count, bool success); void CubeLog(DWORD dwPID, DWORD x, DWORD y, DWORD item_vnum, DWORD item_uid, int item_count, bool success);
void GMCommandLog(DWORD dwPID, const char * szName, const char * szIP, BYTE byChannel, const char * szCommand); void GMCommandLog(DWORD dwPID, const char * szName, const char * szIP, BYTE byChannel, const char * szCommand);
@ -50,7 +49,6 @@ class LogManager : public singleton<LogManager>
void QuestRewardLog(const char * c_pszQuestName, DWORD dwPID, DWORD dwLevel, int iValue1, int iValue2); void QuestRewardLog(const char * c_pszQuestName, DWORD dwPID, DWORD dwLevel, int iValue1, int iValue2);
void DetailLoginLog(bool isLogin, LPCHARACTER ch); void DetailLoginLog(bool isLogin, LPCHARACTER ch);
void DragonSlayLog(DWORD dwGuildID, DWORD dwDragonVnum, DWORD dwStartTime, DWORD dwEndTime); void DragonSlayLog(DWORD dwGuildID, DWORD dwDragonVnum, DWORD dwStartTime, DWORD dwEndTime);
void HackShieldLog(unsigned int ErrorCode, LPCHARACTER ch);
private: private:
void Query(const char * c_pszFormat, ...); void Query(const char * c_pszFormat, ...);

View File

@ -56,59 +56,45 @@
#include "skill_power.h" #include "skill_power.h"
#include "SpeedServer.h" #include "SpeedServer.h"
#include "DragonSoul.h" #include "DragonSoul.h"
#ifndef __INTELLISENSE__
#include <version.h> #include <version.h>
#else
#include <../../../common/version.h>
#endif
#include <event2/event.h> #include <event2/event.h>
#include <event2/listener.h> #include <event2/listener.h>
#include <event2/dns.h> #include <event2/dns.h>
#ifdef __AUCTION__
#include "auction_manager.h"
#endif
#ifdef USE_STACKTRACE #ifdef USE_STACKTRACE
#include <execinfo.h> #include <execinfo.h>
#endif #endif
//extern const char * _malloc_options;
#if defined(__FreeBSD__) && defined(DEBUG_ALLOC)
extern void (*_malloc_message)(const char* p1, const char* p2, const char* p3, const char* p4);
// FreeBSD _malloc_message replacement
void WriteMallocMessage(const char* p1, const char* p2, const char* p3, const char* p4) {
FILE* fp = ::fopen(DBGALLOC_LOG_FILENAME, "a");
if (fp == NULL) {
return;
}
::fprintf(fp, "%s %s %s %s\n", p1, p2, p3, p4);
::fclose(fp);
}
#endif
// TRAFFIC_PROFILER // TRAFFIC_PROFILER
static const DWORD TRAFFIC_PROFILE_FLUSH_CYCLE = 3600; ///< TrafficProfiler 의 Flush cycle. 1시간 간격 static const DWORD TRAFFIC_PROFILE_FLUSH_CYCLE = 3600; ///< TrafficProfiler 의 Flush cycle. 1시간 간격
// END_OF_TRAFFIC_PROFILER // END_OF_TRAFFIC_PROFILER
// 게임과 연결되는 소켓 // 게임과 연결되는 소켓
volatile int num_events_called = 0; volatile int num_events_called = 0;
int max_bytes_written = 0; int max_bytes_written = 0;
int current_bytes_written = 0; int current_bytes_written = 0;
int total_bytes_written = 0; int total_bytes_written = 0;
BYTE g_bLogLevel = 0; BYTE g_bLogLevel = 0;
evconnlistener * tcp_listener = nullptr; evconnlistener *tcp_listener = nullptr;
evconnlistener * p2p_listener = nullptr; evconnlistener *p2p_listener = nullptr;
event_base * ev_base = nullptr; event_base *ev_base = nullptr;
evdns_base * dns_base = nullptr; evdns_base *dns_base = nullptr;
static void AcceptError(evconnlistener *listener, void *ctx); static void AcceptError(evconnlistener *listener, void *ctx);
static void AcceptTCPConnection(evconnlistener* listener, evutil_socket_t fd, sockaddr* address, int socklen, void* ctx); static void AcceptTCPConnection(evconnlistener *listener, evutil_socket_t fd, sockaddr *address, int socklen, void *ctx);
static void AcceptP2PConnection(evconnlistener* listener, evutil_socket_t fd, sockaddr* address, int socklen, void* ctx); static void AcceptP2PConnection(evconnlistener *listener, evutil_socket_t fd, sockaddr *address, int socklen, void *ctx);
int io_loop(event_base * base); int io_loop(event_base *base);
int start(int argc, char **argv); int start(int argc, char **argv);
int idle(); int idle();
void destroy(); void destroy();
enum EProfile enum EProfile
{ {
@ -124,27 +110,25 @@ static DWORD s_dwProfiler[PROF_MAX_NUM];
int g_shutdown_disconnect_pulse; int g_shutdown_disconnect_pulse;
int g_shutdown_disconnect_force_pulse; int g_shutdown_disconnect_force_pulse;
int g_shutdown_core_pulse; int g_shutdown_core_pulse;
bool g_bShutdown=false; bool g_bShutdown = false;
extern int speed_server; extern int speed_server;
#ifdef __AUCTION__
extern int auction_server;
#endif
extern void CancelReloadSpamEvent(); extern void CancelReloadSpamEvent();
void ContinueOnFatalError() void ContinueOnFatalError()
{ {
#ifdef USE_STACKTRACE #ifdef USE_STACKTRACE
void* array[200]; void *array[200];
std::size_t size; std::size_t size;
char** symbols; char **symbols;
size = backtrace(array, 200); size = backtrace(array, 200);
symbols = backtrace_symbols(array, size); symbols = backtrace_symbols(array, size);
std::ostringstream oss; std::ostringstream oss;
oss << std::endl; oss << std::endl;
for (std::size_t i = 0; i < size; ++i) { for (std::size_t i = 0; i < size; ++i)
{
oss << " Stack> " << symbols[i] << std::endl; oss << " Stack> " << symbols[i] << std::endl;
} }
@ -185,7 +169,7 @@ namespace
{ {
struct SendDisconnectFunc struct SendDisconnectFunc
{ {
void operator () (LPDESC d) void operator()(LPDESC d)
{ {
if (d->GetCharacter()) if (d->GetCharacter())
{ {
@ -197,7 +181,7 @@ namespace
struct DisconnectFunc struct DisconnectFunc
{ {
void operator () (LPDESC d) void operator()(LPDESC d)
{ {
if (d->GetType() == DESC_TYPE_CONNECTOR) if (d->GetType() == DESC_TYPE_CONNECTOR)
return; return;
@ -215,7 +199,7 @@ extern std::map<DWORD, CLoginSim *> g_simByPID;
extern std::vector<TPlayerTable> g_vec_save; extern std::vector<TPlayerTable> g_vec_save;
unsigned int save_idx = 0; unsigned int save_idx = 0;
void heartbeat(LPHEART ht, int pulse) void heartbeat(LPHEART ht, int pulse)
{ {
DWORD t; DWORD t;
@ -266,7 +250,7 @@ void heartbeat(LPHEART ht, int pulse)
for (int i = 0; i < count; ++i, ++save_idx) for (int i = 0; i < count; ++i, ++save_idx)
db_clientdesc->DBPacket(HEADER_GD_PLAYER_SAVE, 0, &g_vec_save[save_idx], sizeof(TPlayerTable)); db_clientdesc->DBPacket(HEADER_GD_PLAYER_SAVE, 0, &g_vec_save[save_idx], sizeof(TPlayerTable));
SPDLOG_DEBUG("SAVE_FLUSH {}", count); SPDLOG_DEBUG("SAVE_FLUSH {}", count);
} }
} }
} }
@ -296,13 +280,13 @@ void heartbeat(LPHEART ht, int pulse)
{ {
if (thecore_pulse() > g_shutdown_disconnect_pulse) if (thecore_pulse() > g_shutdown_disconnect_pulse)
{ {
const DESC_MANAGER::DESC_SET & c_set_desc = DESC_MANAGER::instance().GetClientSet(); const DESC_MANAGER::DESC_SET &c_set_desc = DESC_MANAGER::instance().GetClientSet();
std::for_each(c_set_desc.begin(), c_set_desc.end(), ::SendDisconnectFunc()); std::for_each(c_set_desc.begin(), c_set_desc.end(), ::SendDisconnectFunc());
g_shutdown_disconnect_pulse = INT_MAX; g_shutdown_disconnect_pulse = INT_MAX;
} }
else if (thecore_pulse() > g_shutdown_disconnect_force_pulse) else if (thecore_pulse() > g_shutdown_disconnect_force_pulse)
{ {
const DESC_MANAGER::DESC_SET & c_set_desc = DESC_MANAGER::instance().GetClientSet(); const DESC_MANAGER::DESC_SET &c_set_desc = DESC_MANAGER::instance().GetClientSet();
std::for_each(c_set_desc.begin(), c_set_desc.end(), ::DisconnectFunc()); std::for_each(c_set_desc.begin(), c_set_desc.end(), ::DisconnectFunc());
} }
else if (thecore_pulse() > g_shutdown_disconnect_force_pulse + PASSES_PER_SEC(5)) else if (thecore_pulse() > g_shutdown_disconnect_force_pulse + PASSES_PER_SEC(5))
@ -312,7 +296,8 @@ void heartbeat(LPHEART ht, int pulse)
} }
} }
static void CleanUpForEarlyExit() { static void CleanUpForEarlyExit()
{
CancelReloadSpamEvent(); CancelReloadSpamEvent();
} }
@ -325,68 +310,66 @@ int main(int argc, char **argv)
ilInit(); // DevIL Initialize ilInit(); // DevIL Initialize
WriteVersion(); WriteVersion();
log_init(); log_init();
SECTREE_MANAGER sectree_manager;
CHARACTER_MANAGER char_manager;
ITEM_MANAGER item_manager;
CShopManager shop_manager;
CMobManager mob_manager;
CMotionManager motion_manager;
CPartyManager party_manager;
CSkillManager skill_manager;
CPVPManager pvp_manager;
LZOManager lzo_manager;
DBManager db_manager;
AccountDB account_db;
LogManager log_manager; SECTREE_MANAGER sectree_manager;
MessengerManager messenger_manager; CHARACTER_MANAGER char_manager;
P2P_MANAGER p2p_manager; ITEM_MANAGER item_manager;
CGuildManager guild_manager; CShopManager shop_manager;
CMobManager mob_manager;
CMotionManager motion_manager;
CPartyManager party_manager;
CSkillManager skill_manager;
CPVPManager pvp_manager;
LZOManager lzo_manager;
DBManager db_manager;
AccountDB account_db;
LogManager log_manager;
MessengerManager messenger_manager;
P2P_MANAGER p2p_manager;
CGuildManager guild_manager;
CGuildMarkManager mark_manager; CGuildMarkManager mark_manager;
CDungeonManager dungeon_manager; CDungeonManager dungeon_manager;
CRefineManager refine_manager; CRefineManager refine_manager;
CBanwordManager banword_manager; CBanwordManager banword_manager;
CPrivManager priv_manager; CPrivManager priv_manager;
CWarMapManager war_map_manager; CWarMapManager war_map_manager;
building::CManager building_manager; building::CManager building_manager;
CTargetManager target_manager; CTargetManager target_manager;
marriage::CManager marriage_manager; marriage::CManager marriage_manager;
marriage::WeddingManager wedding_manager; marriage::WeddingManager wedding_manager;
CItemAddonManager item_addon_manager; CItemAddonManager item_addon_manager;
CArenaManager arena_manager; CArenaManager arena_manager;
COXEventManager OXEvent_manager; COXEventManager OXEvent_manager;
CMonarch Monarch; CMonarch Monarch;
CHorseNameManager horsename_manager; CHorseNameManager horsename_manager;
DESC_MANAGER desc_manager; DESC_MANAGER desc_manager;
TrafficProfiler trafficProfiler; TrafficProfiler trafficProfiler;
CTableBySkill SkillPowerByLevel; CTableBySkill SkillPowerByLevel;
CPolymorphUtils polymorph_utils; CPolymorphUtils polymorph_utils;
CProfiler profiler; CProfiler profiler;
CBattleArena ba; CBattleArena ba;
COver9RefineManager o9r; COver9RefineManager o9r;
SpamManager spam_mgr; SpamManager spam_mgr;
CThreeWayWar threeway_war; CThreeWayWar threeway_war;
CDragonLairManager dl_manager; CDragonLairManager dl_manager;
CSpeedServerManager SSManager; CSpeedServerManager SSManager;
DSManager dsManager; DSManager dsManager;
#ifdef __AUCTION__ if (!start(argc, argv))
AuctionManager auctionManager; {
#endif
if (!start(argc, argv)) {
CleanUpForEarlyExit(); CleanUpForEarlyExit();
return 0; return 0;
} }
quest::CQuestManager quest_manager; quest::CQuestManager quest_manager;
if (!quest_manager.Initialize()) { if (!quest_manager.Initialize())
{
CleanUpForEarlyExit(); CleanUpForEarlyExit();
return 0; return 0;
} }
@ -402,10 +385,11 @@ int main(int argc, char **argv)
Blend_Item_init(); Blend_Item_init();
ani_init(); ani_init();
if ( g_bTrafficProfileOn ) if (g_bTrafficProfileOn)
TrafficProfiler::instance().Initialize( TRAFFIC_PROFILE_FLUSH_CYCLE, "ProfileLog" ); TrafficProfiler::instance().Initialize(TRAFFIC_PROFILE_FLUSH_CYCLE, "ProfileLog");
while (idle()); while (idle())
;
SPDLOG_INFO("<shutdown> Starting..."); SPDLOG_INFO("<shutdown> Starting...");
g_bShutdown = true; g_bShutdown = true;
@ -467,7 +451,7 @@ int main(int argc, char **argv)
trafficProfiler.Flush(); trafficProfiler.Flush();
destroy(); destroy();
log_destroy(); log_destroy();
#ifdef DEBUG_ALLOC #ifdef DEBUG_ALLOC
DebugAllocator::StaticTearDown(); DebugAllocator::StaticTearDown();
@ -479,83 +463,78 @@ int main(int argc, char **argv)
void usage() void usage()
{ {
printf("Option list\n" printf("Option list\n"
"-p <port> : bind port number (port must be over 1024)\n" "-p <port> : bind port number (port must be over 1024)\n"
"-l <level> : sets log level\n" "-l <level> : sets log level\n"
"-r : do not load regen tables\n" "-r : do not load regen tables\n"
"-t : traffic proflie on\n"); "-t : traffic proflie on\n");
} }
int start(int argc, char **argv) int start(int argc, char **argv)
{ {
std::string st_localeServiceName; std::string st_localeServiceName;
//_malloc_options = "A"; int ch;
#if defined(__FreeBSD__) && defined(DEBUG_ALLOC)
_malloc_message = WriteMallocMessage;
#endif
int ch;
while ((ch = getopt(argc, argv, "n:p:erl:tI:")) != -1) while ((ch = getopt(argc, argv, "n:p:erl:tI:")) != -1)
{ {
char* ep = NULL; char *ep = NULL;
switch (ch) switch (ch)
{ {
case 'I': // IP case 'I': // IP
g_szPublicIP = std::string(optarg); g_szPublicIP = std::string(optarg);
printf("IP %s\n", g_szPublicIP.c_str()); printf("IP %s\n", g_szPublicIP.c_str());
break; break;
case 'p': // port case 'p': // port
mother_port = strtol(optarg, &ep, 10); mother_port = strtol(optarg, &ep, 10);
if (mother_port <= 1024) if (mother_port <= 1024)
{ {
usage(); usage();
return 0; return 0;
} }
printf("port %hu\n", mother_port); printf("port %hu\n", mother_port);
break; break;
case 'l': case 'l':
{ {
int l = strtol(optarg, &ep, 10); int l = strtol(optarg, &ep, 10);
log_set_level(l); log_set_level(l);
} }
break; break;
// LOCALE_SERVICE // LOCALE_SERVICE
case 'n': case 'n':
st_localeServiceName = optarg; st_localeServiceName = optarg;
break; break;
// END_OF_LOCALE_SERVICE // END_OF_LOCALE_SERVICE
case 'r': case 'r':
g_bNoRegen = true; g_bNoRegen = true;
break; break;
// TRAFFIC_PROFILER // TRAFFIC_PROFILER
case 't': case 't':
g_bTrafficProfileOn = true; g_bTrafficProfileOn = true;
break; break;
// END_OF_TRAFFIC_PROFILER // END_OF_TRAFFIC_PROFILER
case '?': case '?':
if (strchr("Ipln", optopt)) if (strchr("Ipln", optopt))
SPDLOG_ERROR("Option -{} requires an argument.", optopt); SPDLOG_ERROR("Option -{} requires an argument.", optopt);
else if (isprint (optopt)) else if (isprint(optopt))
SPDLOG_ERROR("Unknown option `-{}'.", optopt); SPDLOG_ERROR("Unknown option `-{}'.", optopt);
else else
SPDLOG_ERROR("Unknown option character `\\x{}'.", optopt); SPDLOG_ERROR("Unknown option character `\\x{}'.", optopt);
default: default:
usage(); usage();
return 1; return 1;
break; break;
} }
} }
@ -567,7 +546,7 @@ int start(int argc, char **argv)
if (!is_thecore_initialized) if (!is_thecore_initialized)
{ {
SPDLOG_CRITICAL("Could not initialize thecore, check owner of pid, syslog"); SPDLOG_CRITICAL("Could not initialize thecore, check owner of pid, syslog");
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
@ -575,79 +554,84 @@ int start(int argc, char **argv)
{ {
if (false == g_bAuthServer) if (false == g_bAuthServer)
{ {
SPDLOG_CRITICAL("Could not Load ThreeWayWar Setting file"); SPDLOG_CRITICAL("Could not Load ThreeWayWar Setting file");
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
} }
signal_timer_disable(); signal_timer_disable();
// Initialize the network stack // Initialize the network stack
// Check if the public and internal IP addresses were configured // Check if the public and internal IP addresses were configured
if (g_szInternalIP.empty()) { if (g_szInternalIP.empty())
SPDLOG_CRITICAL("Internal IP address could not be automatically detected. Manually set the IP and try again."); {
exit(EXIT_FAILURE); SPDLOG_CRITICAL("Internal IP address could not be automatically detected. Manually set the IP and try again.");
} exit(EXIT_FAILURE);
if (g_szPublicIP.empty()) { }
SPDLOG_CRITICAL("Public IP address could not be automatically detected. Manually set the IP and try again."); if (g_szPublicIP.empty())
exit(EXIT_FAILURE); {
} SPDLOG_CRITICAL("Public IP address could not be automatically detected. Manually set the IP and try again.");
exit(EXIT_FAILURE);
}
// Create a new libevent base and listen for new connections // Create a new libevent base and listen for new connections
ev_base = event_base_new(); ev_base = event_base_new();
if (!ev_base) { if (!ev_base)
SPDLOG_CRITICAL("Libevent base initialization FAILED!"); {
exit(EXIT_FAILURE); SPDLOG_CRITICAL("Libevent base initialization FAILED!");
} exit(EXIT_FAILURE);
}
dns_base = evdns_base_new(ev_base, 1); dns_base = evdns_base_new(ev_base, 1);
if (!dns_base) { if (!dns_base)
SPDLOG_CRITICAL("Libevent DNS base initialization FAILED!"); {
exit(EXIT_FAILURE); SPDLOG_CRITICAL("Libevent DNS base initialization FAILED!");
} exit(EXIT_FAILURE);
}
sockaddr_in sin = {}; sockaddr_in sin = {};
// Main TCP listener // Main TCP listener
sin.sin_family = AF_INET; sin.sin_family = AF_INET;
sin.sin_addr.s_addr = inet_addr(g_szPublicBindIP.c_str()); sin.sin_addr.s_addr = inet_addr(g_szPublicBindIP.c_str());
sin.sin_port = htons(mother_port); sin.sin_port = htons(mother_port);
tcp_listener = evconnlistener_new_bind( tcp_listener = evconnlistener_new_bind(
ev_base, ev_base,
AcceptTCPConnection, nullptr, AcceptTCPConnection, nullptr,
LEV_OPT_CLOSE_ON_FREE|LEV_OPT_REUSEABLE, -1, LEV_OPT_CLOSE_ON_FREE | LEV_OPT_REUSEABLE, -1,
(const sockaddr*)&sin, sizeof(sin) (const sockaddr *)&sin, sizeof(sin));
); if (!tcp_listener)
if (!tcp_listener) { {
SPDLOG_CRITICAL("TCP listener initialization FAILED!"); SPDLOG_CRITICAL("TCP listener initialization FAILED!");
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
SPDLOG_INFO("TCP listening on {}:{}", g_szPublicBindIP, mother_port); SPDLOG_INFO("TCP listening on {}:{}", g_szPublicBindIP, mother_port);
evconnlistener_set_error_cb(tcp_listener, AcceptError); evconnlistener_set_error_cb(tcp_listener, AcceptError);
// Game P2P listener // Game P2P listener
sin.sin_family = AF_INET; sin.sin_family = AF_INET;
sin.sin_addr.s_addr = inet_addr(g_szInternalBindIP.c_str()); sin.sin_addr.s_addr = inet_addr(g_szInternalBindIP.c_str());
sin.sin_port = htons(p2p_port); sin.sin_port = htons(p2p_port);
p2p_listener = evconnlistener_new_bind( p2p_listener = evconnlistener_new_bind(
ev_base, ev_base,
AcceptP2PConnection, nullptr, AcceptP2PConnection, nullptr,
LEV_OPT_CLOSE_ON_FREE|LEV_OPT_REUSEABLE, -1, LEV_OPT_CLOSE_ON_FREE | LEV_OPT_REUSEABLE, -1,
(const sockaddr*)&sin, sizeof(sin) (const sockaddr *)&sin, sizeof(sin));
); if (!p2p_listener)
if (!p2p_listener) { {
SPDLOG_CRITICAL("P2P listener initialization FAILED!"); SPDLOG_CRITICAL("P2P listener initialization FAILED!");
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
SPDLOG_INFO("P2P listening on {}:{}", g_szInternalBindIP, p2p_port); SPDLOG_INFO("P2P listening on {}:{}", g_szInternalBindIP, p2p_port);
evconnlistener_set_error_cb(p2p_listener, AcceptError); evconnlistener_set_error_cb(p2p_listener, AcceptError);
// Create client connections // Create client connections
db_clientdesc = DESC_MANAGER::instance().CreateConnectionDesc(ev_base, dns_base, db_addr, db_port, PHASE_DBCLIENT, true); db_clientdesc = DESC_MANAGER::instance().CreateConnectionDesc(ev_base, dns_base, db_addr, db_port, PHASE_DBCLIENT, true);
if (!g_bAuthServer) { if (!g_bAuthServer)
{
db_clientdesc->UpdateChannelStatus(0, true); db_clientdesc->UpdateChannelStatus(0, true);
} }
@ -655,17 +639,16 @@ int start(int argc, char **argv)
{ {
if (g_stAuthMasterIP.length() != 0) if (g_stAuthMasterIP.length() != 0)
{ {
SPDLOG_INFO("SlaveAuth"); SPDLOG_INFO("SlaveAuth");
g_pkAuthMasterDesc = DESC_MANAGER::instance().CreateConnectionDesc(ev_base, dns_base, g_stAuthMasterIP.c_str(), g_wAuthMasterPort, PHASE_P2P, true); g_pkAuthMasterDesc = DESC_MANAGER::instance().CreateConnectionDesc(ev_base, dns_base, g_stAuthMasterIP.c_str(), g_wAuthMasterPort, PHASE_P2P, true);
P2P_MANAGER::instance().RegisterConnector(g_pkAuthMasterDesc); P2P_MANAGER::instance().RegisterConnector(g_pkAuthMasterDesc);
g_pkAuthMasterDesc->SetP2P(g_wAuthMasterPort, g_bChannel); g_pkAuthMasterDesc->SetP2P(g_wAuthMasterPort, g_bChannel);
} }
else else
{ {
SPDLOG_INFO("MasterAuth"); SPDLOG_INFO("MasterAuth");
} }
} }
/* game server to spam server */ /* game server to spam server */
else else
{ {
@ -673,8 +656,8 @@ int start(int argc, char **argv)
extern unsigned int g_uiSpamBlockScore; extern unsigned int g_uiSpamBlockScore;
extern unsigned int g_uiSpamReloadCycle; extern unsigned int g_uiSpamReloadCycle;
SPDLOG_INFO("SPAM_CONFIG: duration {} score {} reload cycle {}", SPDLOG_INFO("SPAM_CONFIG: duration {} score {} reload cycle {}",
g_uiSpamBlockDuration, g_uiSpamBlockScore, g_uiSpamReloadCycle); g_uiSpamBlockDuration, g_uiSpamBlockScore, g_uiSpamReloadCycle);
extern void LoadSpamDB(); extern void LoadSpamDB();
LoadSpamDB(); LoadSpamDB();
@ -686,51 +669,55 @@ int start(int argc, char **argv)
void destroy() void destroy()
{ {
SPDLOG_INFO("<shutdown> Canceling ReloadSpamEvent..."); SPDLOG_INFO("<shutdown> Canceling ReloadSpamEvent...");
CancelReloadSpamEvent(); CancelReloadSpamEvent();
SPDLOG_INFO("<shutdown> regen_free()..."); SPDLOG_INFO("<shutdown> regen_free()...");
regen_free(); regen_free();
SPDLOG_INFO("<shutdown> Closing network stack..."); SPDLOG_INFO("<shutdown> Closing network stack...");
if (tcp_listener) { if (tcp_listener)
evconnlistener_free(tcp_listener); {
tcp_listener = nullptr; evconnlistener_free(tcp_listener);
} tcp_listener = nullptr;
}
if (p2p_listener) { if (p2p_listener)
evconnlistener_free(p2p_listener); {
evconnlistener_free(p2p_listener);
p2p_listener = nullptr; p2p_listener = nullptr;
} }
if (dns_base) { if (dns_base)
evdns_base_free(dns_base, 0); {
evdns_base_free(dns_base, 0);
dns_base = nullptr; dns_base = nullptr;
} }
if (ev_base) { if (ev_base)
event_base_free(ev_base); {
ev_base = nullptr; event_base_free(ev_base);
} ev_base = nullptr;
}
SPDLOG_INFO("<shutdown> event_destroy()..."); SPDLOG_INFO("<shutdown> event_destroy()...");
event_destroy(); event_destroy();
SPDLOG_INFO("<shutdown> CTextFileLoader::DestroySystem()..."); SPDLOG_INFO("<shutdown> CTextFileLoader::DestroySystem()...");
CTextFileLoader::DestroySystem(); CTextFileLoader::DestroySystem();
SPDLOG_INFO("<shutdown> thecore_destroy()..."); SPDLOG_INFO("<shutdown> thecore_destroy()...");
thecore_destroy(); thecore_destroy();
} }
int idle() int idle()
{ {
static struct timeval pta = { 0, 0 }; static struct timeval pta = {0, 0};
static int process_time_count = 0; static int process_time_count = 0;
struct timeval now; struct timeval now;
if (pta.tv_sec == 0) if (pta.tv_sec == 0)
gettimeofday(&pta, (struct timezone *) 0); gettimeofday(&pta, (struct timezone *)0);
int passed_pulses; int passed_pulses;
@ -741,7 +728,8 @@ int idle()
DWORD t; DWORD t;
while (passed_pulses--) { while (passed_pulses--)
{
heartbeat(thecore_heart, ++thecore_heart->pulse); heartbeat(thecore_heart, ++thecore_heart->pulse);
// To reduce the possibility of abort() in checkpointing // To reduce the possibility of abort() in checkpointing
@ -754,84 +742,72 @@ int idle()
s_dwProfiler[PROF_CHR_UPDATE] += (get_dword_time() - t); s_dwProfiler[PROF_CHR_UPDATE] += (get_dword_time() - t);
t = get_dword_time(); t = get_dword_time();
if (!io_loop(ev_base)) return 0; if (!io_loop(ev_base))
return 0;
s_dwProfiler[PROF_IO] += (get_dword_time() - t); s_dwProfiler[PROF_IO] += (get_dword_time() - t);
gettimeofday(&now, (struct timezone *) 0); gettimeofday(&now, (struct timezone *)0);
++process_time_count; ++process_time_count;
if (now.tv_sec - pta.tv_sec > 0) if (now.tv_sec - pta.tv_sec > 0)
{ {
SPDLOG_TRACE("[{:3}] event {:5}/{:<5} idle {:<4} event {:<4} heartbeat {:<4} I/O {:<4} chrUpate {:<4} | WRITE: {:<7} | PULSE: {}", SPDLOG_TRACE("[{:3}] event {:5}/{:<5} idle {:<4} event {:<4} heartbeat {:<4} I/O {:<4} chrUpate {:<4} | WRITE: {:<7} | PULSE: {}",
process_time_count, process_time_count,
num_events_called, num_events_called,
event_count(), event_count(),
thecore_profiler[PF_IDLE], thecore_profiler[PF_IDLE],
s_dwProfiler[PROF_EVENT], s_dwProfiler[PROF_EVENT],
s_dwProfiler[PROF_HEARTBEAT], s_dwProfiler[PROF_HEARTBEAT],
s_dwProfiler[PROF_IO], s_dwProfiler[PROF_IO],
s_dwProfiler[PROF_CHR_UPDATE], s_dwProfiler[PROF_CHR_UPDATE],
current_bytes_written, current_bytes_written,
thecore_pulse()); thecore_pulse());
num_events_called = 0; num_events_called = 0;
current_bytes_written = 0; current_bytes_written = 0;
process_time_count = 0; process_time_count = 0;
gettimeofday(&pta, (struct timezone *) 0); gettimeofday(&pta, (struct timezone *)0);
memset(&thecore_profiler[0], 0, sizeof(thecore_profiler)); memset(&thecore_profiler[0], 0, sizeof(thecore_profiler));
memset(&s_dwProfiler[0], 0, sizeof(s_dwProfiler)); memset(&s_dwProfiler[0], 0, sizeof(s_dwProfiler));
} }
#ifdef __WIN32__
if (_kbhit()) {
int c = _getch();
switch (c) {
case 0x1b: // Esc
return 0; // shutdown
break;
default:
break;
}
}
#endif
return 1; return 1;
} }
static void AcceptError(evconnlistener *listener, void *ctx) { static void AcceptError(evconnlistener *listener, void *ctx)
struct event_base *base = evconnlistener_get_base(listener); {
int err = EVUTIL_SOCKET_ERROR(); struct event_base *base = evconnlistener_get_base(listener);
SPDLOG_CRITICAL("Got an error {} ({}) on the listener. Shutting down.", err, evutil_socket_error_to_string(err)); int err = EVUTIL_SOCKET_ERROR();
SPDLOG_CRITICAL("Got an error {} ({}) on the listener. Shutting down.", err, evutil_socket_error_to_string(err));
event_base_loopexit(base, nullptr); event_base_loopexit(base, nullptr);
ShutdownOnFatalError(); ShutdownOnFatalError();
} }
static void AcceptTCPConnection(evconnlistener* listener, evutil_socket_t fd, sockaddr* address, int socklen, void* ctx) static void AcceptTCPConnection(evconnlistener *listener, evutil_socket_t fd, sockaddr *address, int socklen, void *ctx)
{ {
// Initialize the peer // Initialize the peer
DESC_MANAGER::instance().AcceptDesc(listener, fd, address); DESC_MANAGER::instance().AcceptDesc(listener, fd, address);
} }
static void AcceptP2PConnection(evconnlistener* listener, evutil_socket_t fd, sockaddr* address, int socklen, void* ctx) static void AcceptP2PConnection(evconnlistener *listener, evutil_socket_t fd, sockaddr *address, int socklen, void *ctx)
{ {
// Initialize the peer // Initialize the peer
DESC_MANAGER::instance().AcceptP2PDesc(listener, fd, address); DESC_MANAGER::instance().AcceptP2PDesc(listener, fd, address);
} }
int io_loop(event_base * base) int io_loop(event_base *base)
{ {
LPDESC d; LPDESC d;
int num_events, event_idx; int num_events, event_idx;
DESC_MANAGER::instance().DestroyClosed(); // PHASE_CLOSE인 접속들을 끊어준다. DESC_MANAGER::instance().DestroyClosed(); // PHASE_CLOSE인 접속들을 끊어준다.
DESC_MANAGER::instance().TryConnect(); DESC_MANAGER::instance().TryConnect();
// Process network events // Process network events
event_base_loop(base, EVLOOP_NONBLOCK); event_base_loop(base, EVLOOP_NONBLOCK);
return 1; return 1;
} }

View File

@ -1630,7 +1630,6 @@ namespace quest
GetCurrentCharacterPtr()->ChatPacket(CHAT_TYPE_PARTY, "LUA_ERROR: quest %s.%s %s", GetCurrentQuestName().c_str(), state_name, event_index_name.c_str() ); GetCurrentCharacterPtr()->ChatPacket(CHAT_TYPE_PARTY, "LUA_ERROR: quest %s.%s %s", GetCurrentQuestName().c_str(), state_name, event_index_name.c_str() );
} }
#ifndef __WIN32__
void CQuestManager::QuestError(const char* func, int line, const char* fmt, ...) void CQuestManager::QuestError(const char* func, int line, const char* fmt, ...)
{ {
char szMsg[4096]; char szMsg[4096];
@ -1651,28 +1650,6 @@ namespace quest
} }
} }
} }
#else
void CQuestManager::QuestError(const char* func, int line, const char* fmt, ...)
{
char szMsg[4096];
va_list args;
va_start(args, fmt);
vsnprintf(szMsg, sizeof(szMsg), fmt, args);
va_end(args);
_SPDLOG_ERROR(func, line, "%s", szMsg);
if (test_server)
{
LPCHARACTER ch = GetCurrentCharacterPtr();
if (ch)
{
ch->ChatPacket(CHAT_TYPE_PARTY, "error occurred on [%s:%d]", func,line);
ch->ChatPacket(CHAT_TYPE_PARTY, "%s", szMsg);
}
}
}
#endif
void CQuestManager::AddServerTimer(const std::string& name, DWORD arg, LPEVENT event) void CQuestManager::AddServerTimer(const std::string& name, DWORD arg, LPEVENT event)
{ {

View File

@ -5,11 +5,7 @@
#include "questnpc.h" #include "questnpc.h"
#ifndef __WIN32__
#define quest_err(fmt, args...) quest::CQuestManager::instance().QuestError(__FUNCTION__, __LINE__, fmt, ##args) #define quest_err(fmt, args...) quest::CQuestManager::instance().QuestError(__FUNCTION__, __LINE__, fmt, ##args)
#else
#define quest_err(fmt, ...) quest::CQuestManager::instance().QuestError(__FUNCTION__, __LINE__, fmt, __VA_ARGS__)
#endif
class ITEM; class ITEM;
class CHARACTER; class CHARACTER;
@ -173,12 +169,7 @@ namespace quest
void ClearError() { m_bError = false; } void ClearError() { m_bError = false; }
bool IsError() { return m_bError; } bool IsError() { return m_bError; }
void WriteRunningStateToSyserr(); void WriteRunningStateToSyserr();
#ifndef __WIN32__
void QuestError(const char* func, int line, const char* fmt, ...); void QuestError(const char* func, int line, const char* fmt, ...);
#else
//void QuestError(const char* fmt, ...);
void QuestError(const char* func, int line, const char* fmt, ...);
#endif
void RegisterNPCVnum(DWORD dwVnum); void RegisterNPCVnum(DWORD dwVnum);

View File

@ -38,12 +38,10 @@ inline int DISTANCE_APPROX(int dx, int dy)
( min << 7 ) - ( min << 5 ) + ( min << 3 ) - ( min << 1 )) >> 8 ); ( min << 7 ) - ( min << 5 ) + ( min << 3 ) - ( min << 1 )) >> 8 );
} }
#ifndef __WIN32__
inline WORD MAKEWORD(BYTE a, BYTE b) inline WORD MAKEWORD(BYTE a, BYTE b)
{ {
return static_cast<WORD>(a) | (static_cast<WORD>(b) << 8); return static_cast<WORD>(a) | (static_cast<WORD>(b) << 8);
} }
#endif
extern void set_global_time(time_t t); extern void set_global_time(time_t t);
extern time_t get_global_time(); extern time_t get_global_time();

View File

@ -1,8 +1,12 @@
#include <fmt/core.h> #include <fmt/core.h>
#ifndef __INTELLISENSE__
#include <version.h> #include <version.h>
#else
#include <../../../common/version.h>
#endif
void WriteVersion() { void WriteVersion()
{
fmt::println("Metin2 Game Server version {} (rev. {}, date: {})", __COMMIT_TAG__, __REVISION__, __COMMIT_DATE__); fmt::println("Metin2 Game Server version {} (rev. {}, date: {})", __COMMIT_TAG__, __REVISION__, __COMMIT_DATE__);
fmt::println("OS: {}, target arch: {}, compiler: {}", __OS_NAME__, __CPU_TARGET__, __COMPILER__); fmt::println("OS: {}, target arch: {}, compiler: {}", __OS_NAME__, __CPU_TARGET__, __COMPILER__);
} }

View File

@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.8) cmake_minimum_required(VERSION 3.12)
project(libgame CXX) project(libgame CXX)
@ -14,6 +14,12 @@ include_directories("include")
# Create shared library # Create shared library
add_library(${PROJECT_NAME} STATIC ${SOURCES}) add_library(${PROJECT_NAME} STATIC ${SOURCES})
# Set the default log level based on the build type
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
message(STATUS "This is a debug build. Log level will be set to 'trace' for target '${PROJECT_NAME}'.")
target_compile_definitions(${PROJECT_NAME} PRIVATE SPDLOG_ACTIVE_LEVEL=SPDLOG_LEVEL_TRACE)
endif()
# Find and link dependencies # Find and link dependencies
# spdlog # spdlog

View File

@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.8) cmake_minimum_required(VERSION 3.12)
project(liblua CXX) project(liblua CXX)

View File

@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.8) cmake_minimum_required(VERSION 3.12)
project(libpoly CXX) project(libpoly CXX)

View File

@ -9,11 +9,7 @@ using namespace std;
double _random() double _random()
{ {
#ifndef __WIN32__
return random() / (2147483648.0); return random() / (2147483648.0);
#else
return rand() / (2147483648.0);
#endif
} }
int CPoly::my_irandom(double start, double end) int CPoly::my_irandom(double start, double end)

View File

@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.8) cmake_minimum_required(VERSION 3.12)
project(libsql CXX) project(libsql CXX)
@ -11,14 +11,21 @@ file(GLOB SOURCES
# Include header files # Include header files
include_directories("include") include_directories("include")
# Create shared library # Create static library
add_library(${PROJECT_NAME} STATIC ${SOURCES}) add_library(${PROJECT_NAME} STATIC ${SOURCES})
# Set the default log level based on the build type
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
message(STATUS "This is a debug build. Log level will be set to 'trace' for target '${PROJECT_NAME}'.")
target_compile_definitions(${PROJECT_NAME} PRIVATE SPDLOG_ACTIVE_LEVEL=SPDLOG_LEVEL_TRACE)
endif()
# Find and link dependencies # Find and link dependencies
# MariaDB # PostgreSQL with libpqxx (stable vcpkg package)
find_package(unofficial-libmariadb REQUIRED) find_package(PostgreSQL REQUIRED)
target_link_libraries(${PROJECT_NAME} PUBLIC unofficial::libmariadb) find_package(libpqxx CONFIG REQUIRED)
target_link_libraries(${PROJECT_NAME} PRIVATE libpqxx::pqxx)
# spdlog # spdlog
find_package(spdlog CONFIG REQUIRED) find_package(spdlog CONFIG REQUIRED)

View File

@ -8,9 +8,8 @@
#include <queue> #include <queue>
#include <vector> #include <vector>
#include <map> #include <map>
#include <mysql/mysql.h> #include <iostream>
#include <mysql/errmsg.h> #include <pqxx/pqxx>
#include <mysql/mysqld_error.h>
#include "CSemaphore.h" #include "CSemaphore.h"
@ -182,15 +181,9 @@ class CAsyncSQL
volatile bool m_bEnd; volatile bool m_bEnd;
#ifndef __WIN32__
pthread_t m_hThread; pthread_t m_hThread;
pthread_mutex_t * m_mtxQuery; pthread_mutex_t * m_mtxQuery;
pthread_mutex_t * m_mtxResult; pthread_mutex_t * m_mtxResult;
#else
HANDLE m_hThread;
CRITICAL_SECTION* m_mtxQuery;
CRITICAL_SECTION* m_mtxResult;
#endif
CSemaphore m_sem; CSemaphore m_sem;

View File

@ -1,41 +0,0 @@
#ifndef __INC_METIN_II_LIBSQL_STATEMENT_H__
#define __INC_METIN_II_LIBSQL_STATEMENT_H__
#include "CAsyncSQL.h"
#include <string>
#include <vector>
class CStmt
{
public:
CStmt();
virtual ~CStmt();
bool Prepare(CAsyncSQL * sql, const char * c_pszQuery);
bool BindParam(enum_field_types type, void * p, int iMaxLen=0);
bool BindResult(enum_field_types type, void * p, int iMaxLen=0);
int Execute();
bool Fetch();
void Error(const char * c_pszMsg);
public:
int iRows;
private:
void Destroy();
MYSQL_STMT * m_pkStmt;
std::string m_stQuery;
std::vector<MYSQL_BIND> m_vec_param;
unsigned int m_uiParamCount;
uint64_t * m_puiParamLen;
std::vector<MYSQL_BIND> m_vec_result;
unsigned int m_uiResultCount;
};
#endif

View File

@ -0,0 +1,26 @@
#pragma once
#include <pqxx/pqxx>
#include <string>
#include <functional>
using AsyncQueryCallback = std::function<void(const pqxx::result &, const std::string &error)>;
class PgAsyncQuery
{
public:
int id;
std::string query;
pqxx::params parameters;
bool hasCallback;
AsyncQueryCallback callback;
// Fire and Forget AsyncQuery
PgAsyncQuery(int msgId, const std::string &sql, const pqxx::params &params = pqxx::params{})
: id(msgId), query(sql), parameters(params), hasCallback(false) {}
// Callback AsyncQuery
PgAsyncQuery(int msgId, const std::string &sql, const pqxx::params &params = pqxx::params{}, AsyncQueryCallback cb)
: id(msgId), query(sql), parameters(params), hasCallback(true), callback(std::move(cb)) {}
};

View File

@ -0,0 +1,175 @@
#pragma once
#include <pqxx/pqxx>
#include <mutex>
#include <condition_variable>
#include <queue>
#include <memory>
#include <string>
#include <vector>
#include <chrono>
#include <future>
#include <thread>
#include <atomic>
#include <map>
class PgConnectionPool
{
public:
PgConnectionPool(const char *db_address, int db_port, const char *db_name,
const char *user, const char *pwd,
size_t pool_size = 10,
std::chrono::seconds idle_timeout = std::chrono::seconds(60))
: db_address_(db_address), db_port_(db_port), db_name_(db_name),
user_(user), pwd_(pwd), max_pool_size_(pool_size),
idle_timeout_(idle_timeout), stop_cleaner_(false)
{
for (size_t i = 0; i < max_pool_size_; ++i)
{
auto conn = createConnection();
pool_.push({std::move(conn), std::chrono::steady_clock::now()});
}
// Start cleanup thread
cleaner_thread_ = std::thread(&PgConnectionPool::cleanupIdleConnections, this);
}
~PgConnectionPool()
{
stop_cleaner_ = true;
cond_.notify_all();
if (cleaner_thread_.joinable())
{
cleaner_thread_.join();
}
std::lock_guard<std::mutex> lock(mutex_);
while (!pool_.empty())
{
auto &entry = pool_.front();
if (entry.conn && entry.conn->is_open())
{
entry.conn->close();
}
pool_.pop();
}
}
// Asynchronous acquire
std::future<std::shared_ptr<pqxx::connection>> acquireAsync()
{
return std::async(std::launch::async, [this]()
{ return this->acquire(); });
}
// Blocking acquire
std::shared_ptr<pqxx::connection> acquire()
{
std::unique_lock<std::mutex> lock(mutex_);
cond_.wait(lock, [this]()
{ return !pool_.empty(); });
ConnectionEntry entry = std::move(pool_.front());
pool_.pop();
if (!entry.conn || !entry.conn->is_open())
{
entry.conn = createConnection(); // Reconnect if needed
}
return std::shared_ptr<pqxx::connection>(
entry.conn.release(),
[this](pqxx::connection *p)
{
std::lock_guard<std::mutex> lock(mutex_);
auto now = std::chrono::steady_clock::now();
if (p->is_open())
{
pool_.push({std::unique_ptr<pqxx::connection>(p), now});
}
else
{
delete p;
pool_.push({createConnection(), now});
}
cond_.notify_one();
});
}
private:
struct ConnectionEntry
{
std::unique_ptr<pqxx::connection> conn;
std::chrono::steady_clock::time_point last_used;
};
std::unique_ptr<pqxx::connection> createConnection()
{
std::string conn_str = "host=" + db_address_ +
" port=" + std::to_string(db_port_) +
" dbname=" + db_name_ +
" user=" + user_ +
" password=" + pwd_;
try
{
auto conn = std::make_unique<pqxx::connection>(conn_str);
if (!conn->is_open())
{
throw std::runtime_error("Failed to open DB connection");
}
return conn;
}
catch (const std::exception &e)
{
throw std::runtime_error(std::string("Connection error: ") + e.what());
}
}
void cleanupIdleConnections()
{
while (!stop_cleaner_)
{
std::this_thread::sleep_for(idle_timeout_ / 2); // Clean more frequently
std::lock_guard<std::mutex> lock(mutex_);
size_t current_size = pool_.size();
std::queue<ConnectionEntry> temp;
auto now = std::chrono::steady_clock::now();
while (!pool_.empty())
{
auto entry = std::move(pool_.front());
pool_.pop();
if (std::chrono::duration_cast<std::chrono::seconds>(
now - entry.last_used) > idle_timeout_)
{
if (entry.conn && entry.conn->is_open())
{
entry.conn->close();
}
}
else
{
temp.push(std::move(entry));
}
}
pool_ = std::move(temp);
cond_.notify_all();
}
}
std::string db_address_, db_name_, user_, pwd_;
int db_port_;
size_t max_pool_size_;
std::chrono::seconds idle_timeout_;
std::queue<ConnectionEntry> pool_;
std::mutex mutex_;
std::condition_variable cond_;
std::thread cleaner_thread_;
std::atomic<bool> stop_cleaner_;
};

View File

@ -1,8 +1,6 @@
#ifndef __INC_METIN_II_TELLWAIT_H__ #ifndef __INC_METIN_II_TELLWAIT_H__
#define __INC_METIN_II_TELLWAIT_H__ #define __INC_METIN_II_TELLWAIT_H__
#ifndef __WIN32__
extern void TELL_WAIT(); extern void TELL_WAIT();
extern void WAIT_CHILD(); extern void WAIT_CHILD();
@ -12,5 +10,3 @@ extern void WAIT_PARENT();
extern void TELL_PARENT(pid_t pid); extern void TELL_PARENT(pid_t pid);
#endif #endif
#endif

View File

@ -1,6 +1,4 @@
#ifndef __WIN32__
#include <sys/time.h> #include <sys/time.h>
#endif
#include <cstdlib> #include <cstdlib>
#include <cstring> #include <cstring>
@ -8,22 +6,13 @@
#include "CAsyncSQL.h" #include "CAsyncSQL.h"
// TODO: Consider providing platform-independent mutex class. // TODO: Consider providing platform-independent mutex class.
#ifndef __WIN32__
#define MUTEX_LOCK(mtx) pthread_mutex_lock(mtx) #define MUTEX_LOCK(mtx) pthread_mutex_lock(mtx)
#define MUTEX_UNLOCK(mtx) pthread_mutex_unlock(mtx) #define MUTEX_UNLOCK(mtx) pthread_mutex_unlock(mtx)
#else
#define MUTEX_LOCK(mtx) ::EnterCriticalSection(mtx)
#define MUTEX_UNLOCK(mtx) ::LeaveCriticalSection(mtx)
#endif
CAsyncSQL::CAsyncSQL() CAsyncSQL::CAsyncSQL()
: m_stHost(""), m_stUser(""), m_stPassword(""), m_stDB(""), m_stLocale(""), : m_stHost(""), m_stUser(""), m_stPassword(""), m_stDB(""), m_stLocale(""),
m_iMsgCount(0), m_bEnd(false), m_iMsgCount(0), m_bEnd(false),
#ifndef __WIN32__
m_hThread(0), m_hThread(0),
#else
m_hThread(INVALID_HANDLE_VALUE),
#endif
m_mtxQuery(NULL), m_mtxResult(NULL), m_mtxQuery(NULL), m_mtxResult(NULL),
m_iQueryFinished(0), m_ulThreadID(0), m_bConnected(false), m_iCopiedQuery(0), m_iQueryFinished(0), m_ulThreadID(0), m_bConnected(false), m_iCopiedQuery(0),
m_iPort(0) m_iPort(0)
@ -51,32 +40,20 @@ void CAsyncSQL::Destroy()
if (m_mtxQuery) if (m_mtxQuery)
{ {
#ifndef __WIN32__
pthread_mutex_destroy(m_mtxQuery); pthread_mutex_destroy(m_mtxQuery);
#else
::DeleteCriticalSection(m_mtxQuery);
#endif
delete m_mtxQuery; delete m_mtxQuery;
m_mtxQuery = NULL; m_mtxQuery = NULL;
} }
if (m_mtxResult) if (m_mtxResult)
{ {
#ifndef __WIN32__
pthread_mutex_destroy(m_mtxResult); pthread_mutex_destroy(m_mtxResult);
#else
::DeleteCriticalSection(m_mtxResult);
#endif
delete m_mtxResult; delete m_mtxResult;
m_mtxQuery = NULL; m_mtxQuery = NULL;
} }
} }
#ifndef __WIN32__
void * AsyncSQLThread(void * arg) void * AsyncSQLThread(void * arg)
#else
unsigned int __stdcall AsyncSQLThread(void* arg)
#endif
{ {
CAsyncSQL * pSQL = ((CAsyncSQL *) arg); CAsyncSQL * pSQL = ((CAsyncSQL *) arg);
@ -198,7 +175,6 @@ bool CAsyncSQL::Setup(const char * c_pszHost, const char * c_pszUser, const char
return false; return false;
} }
*/ */
#ifndef __WIN32__
m_mtxQuery = new pthread_mutex_t; m_mtxQuery = new pthread_mutex_t;
m_mtxResult = new pthread_mutex_t; m_mtxResult = new pthread_mutex_t;
@ -215,19 +191,6 @@ bool CAsyncSQL::Setup(const char * c_pszHost, const char * c_pszUser, const char
} }
pthread_create(&m_hThread, NULL, AsyncSQLThread, this); pthread_create(&m_hThread, NULL, AsyncSQLThread, this);
#else
m_mtxQuery = new CRITICAL_SECTION;
m_mtxResult = new CRITICAL_SECTION;
::InitializeCriticalSection(m_mtxQuery);
::InitializeCriticalSection(m_mtxResult);
m_hThread = (HANDLE)::_beginthreadex(NULL, 0, AsyncSQLThread, this, 0, NULL);
if (m_hThread == INVALID_HANDLE_VALUE) {
perror("CAsyncSQL::Setup");
return false;
}
#endif
return true; return true;
} }
@ -240,18 +203,11 @@ void CAsyncSQL::Quit()
m_bEnd = true; m_bEnd = true;
m_sem.Release(); m_sem.Release();
#ifndef __WIN32__
if (m_hThread) if (m_hThread)
{ {
pthread_join(m_hThread, NULL); pthread_join(m_hThread, NULL);
m_hThread = NULL; m_hThread = NULL;
} }
#else
if (m_hThread != INVALID_HANDLE_VALUE) {
::WaitForSingleObject(m_hThread, INFINITE);
m_hThread = INVALID_HANDLE_VALUE;
}
#endif
} }
SQLMsg * CAsyncSQL::DirectQuery(const char * c_pszQuery) SQLMsg * CAsyncSQL::DirectQuery(const char * c_pszQuery)

View File

@ -1,8 +1,6 @@
#include "stdafx.h" #include "stdafx.h"
#include "CSemaphore.h" #include "CSemaphore.h"
#ifndef __WIN32__
CSemaphore::CSemaphore() : m_hSem(NULL) CSemaphore::CSemaphore() : m_hSem(NULL)
{ {
Initialize(); Initialize();
@ -73,70 +71,3 @@ int CSemaphore::Release(int count)
return true; return true;
} }
#else
CSemaphore::CSemaphore() : m_hSem(NULL)
{
Initialize();
}
CSemaphore::~CSemaphore()
{
Destroy();
}
int CSemaphore::Initialize()
{
Clear();
m_hSem = ::CreateSemaphore(NULL, 0, 32, NULL);
if (m_hSem == NULL) {
return false;
}
return true;
}
void CSemaphore::Destroy()
{
Clear();
}
void CSemaphore::Clear()
{
if (m_hSem == NULL) {
return;
}
::CloseHandle(m_hSem);
m_hSem = NULL;
}
int CSemaphore::Wait()
{
if (!m_hSem)
return true;
DWORD dwWaitResult = ::WaitForSingleObject(m_hSem, INFINITE);
switch (dwWaitResult) {
case WAIT_OBJECT_0:
return true;
default:
break;
}
return false;
}
int CSemaphore::Release(int count)
{
if (!m_hSem)
return false;
::ReleaseSemaphore(m_hSem, count, NULL);
return true;
}
#endif

View File

@ -1,159 +0,0 @@
#include "CStatement.h"
#include <cstdlib>
#include <cstring>
CStmt::CStmt()
{
m_pkStmt = NULL;
m_uiParamCount = 0;
m_uiResultCount = 0;
iRows = 0;
m_puiParamLen = NULL;
}
CStmt::~CStmt()
{
Destroy();
}
void CStmt::Destroy()
{
if (m_pkStmt)
{
mysql_stmt_close(m_pkStmt);
m_pkStmt = NULL;
}
if (m_puiParamLen)
{
free(m_puiParamLen);
m_puiParamLen = NULL;
}
}
void CStmt::Error(const char * c_pszMsg)
{
SPDLOG_ERROR("SYSERR: {}: [{}] {}", c_pszMsg, mysql_stmt_errno(m_pkStmt), mysql_stmt_error(m_pkStmt));
}
bool CStmt::Prepare(CAsyncSQL * sql, const char * c_pszQuery)
{
m_pkStmt = mysql_stmt_init(sql->GetSQLHandle());
m_stQuery = c_pszQuery;
if (mysql_stmt_prepare(m_pkStmt, m_stQuery.c_str(), m_stQuery.length()))
{
Error("mysql_stmt_prepare");
return false;
}
int iParamCount = 0;
for (unsigned int i = 0; i < m_stQuery.length(); ++i)
if (c_pszQuery[i] == '?')
++iParamCount;
if (iParamCount)
{
m_vec_param.resize(iParamCount);
memset(&m_vec_param[0], 0, sizeof(MYSQL_BIND) * iParamCount);
m_puiParamLen = (uint64_t *) calloc(iParamCount, sizeof(uint64_t));
}
m_vec_result.resize(48);
memset(&m_vec_result[0], 0, sizeof(MYSQL_BIND) * 48);
if (mysql_stmt_bind_result(m_pkStmt, &m_vec_result[0]))
{
Error("mysql_stmt_bind_result");
return 0;
}
return true;
}
bool CStmt::BindParam(enum_field_types type, void * p, int iMaxLen)
{
if (m_uiParamCount >= m_vec_param.size())
{
SPDLOG_ERROR("too many parameter in query: {}", m_stQuery);
return false;
}
MYSQL_BIND * bind = &m_vec_param[m_uiParamCount];
bind->buffer_type = type;
bind->buffer = (void *) p;
bind->buffer_length = iMaxLen;
bind->length = m_puiParamLen + m_uiParamCount;
if (++m_uiParamCount == m_vec_param.size())
{
if (mysql_stmt_bind_param(m_pkStmt, &m_vec_param[0]))
{
Error("mysql_stmt_bind_param");
return false;
}
}
return true;
}
bool CStmt::BindResult(enum_field_types type, void * p, int iMaxLen)
{
if (m_uiResultCount >= m_vec_result.size())
{
SPDLOG_ERROR("too many result in query: {}", m_stQuery);
return false;
}
MYSQL_BIND * bind = &m_vec_result[m_uiResultCount++];
bind->buffer_type = type;
bind->buffer = (void *) p;
bind->buffer_length = iMaxLen;
return true;
}
int CStmt::Execute()
{
if (m_uiParamCount != m_vec_param.size())
{
SPDLOG_ERROR("Parameter not enough {}, expected {} query: {}", m_uiParamCount, m_vec_param.size(), m_stQuery);
return 0;
}
for (unsigned int i = 0; i < m_uiParamCount; ++i)
{
MYSQL_BIND * bind = &m_vec_param[i];
if (bind->buffer_type == MYSQL_TYPE_STRING)
{
*(m_puiParamLen + i) = strlen((const char *) bind->buffer);
SPDLOG_TRACE("param {} len {} buf {}", i, *m_puiParamLen, (const char *) bind->buffer);
}
}
if (mysql_stmt_execute(m_pkStmt))
{
Error("mysql_stmt_execute");
return 0;
}
if (mysql_stmt_store_result(m_pkStmt))
{
Error("mysql_store_result");
return 0;
}
iRows = mysql_stmt_num_rows(m_pkStmt);
return true;
}
bool CStmt::Fetch()
{
return !mysql_stmt_fetch(m_pkStmt);
}

View File

@ -1,5 +1,3 @@
#ifndef __WIN32__
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <signal.h> #include <signal.h>
@ -82,6 +80,3 @@ void WAIT_CHILD(void)
exit(1); exit(1);
} }
} }
#endif

View File

@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.8) cmake_minimum_required(VERSION 3.12)
project(libthecore CXX) project(libthecore CXX)
@ -14,6 +14,12 @@ include_directories("include")
# Create shared library # Create shared library
add_library(${PROJECT_NAME} STATIC ${SOURCES}) add_library(${PROJECT_NAME} STATIC ${SOURCES})
# Set the default log level based on the build type
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
message(STATUS "This is a debug build. Log level will be set to 'trace' for target '${PROJECT_NAME}'.")
target_compile_definitions(${PROJECT_NAME} PRIVATE SPDLOG_ACTIVE_LEVEL=SPDLOG_LEVEL_TRACE)
endif()
# Find and link dependencies # Find and link dependencies
# fmt # fmt

View File

@ -8,8 +8,6 @@ typedef uint8_t UBYTE;
typedef int8_t sbyte; typedef int8_t sbyte;
typedef uint16_t sh_int; typedef uint16_t sh_int;
#ifndef __WIN32__
typedef uint32_t DWORD; typedef uint32_t DWORD;
typedef uint32_t BOOL; typedef uint32_t BOOL;
typedef uint8_t BYTE; typedef uint8_t BYTE;
@ -19,40 +17,4 @@ typedef uint32_t ULONG;
typedef int32_t INT; typedef int32_t INT;
typedef uint32_t UINT; typedef uint32_t UINT;
#else
struct timezone
{
int tz_minuteswest; /* minutes west of Greenwich */
int tz_dsttime; /* type of dst correction */
};
typedef SOCKET socket_t;
#if !defined(_W64)
#if !defined(__midl) && (defined(_X86_) || defined(_M_IX86)) && _MSC_VER >= 1300
#define _W64 __w64
#else
#define _W64
#endif
#endif
#ifdef _WIN64
typedef __int64 ssize_t;
#else
typedef _W64 int ssize_t;
#endif
// Fixed-size integer types
#if defined(_MSC_VER) && (_MSC_VER >= 1300)
typedef __int32 int32_t;
typedef unsigned __int32 uint32_t;
typedef __int64 int64_t;
typedef unsigned __int64 uint64_t;
#endif
typedef unsigned int uint;
#endif
#endif // __INC_LIBTHECORE_TYPEDEF_H__ #endif // __INC_LIBTHECORE_TYPEDEF_H__

View File

@ -120,8 +120,4 @@ extern "C++"
#endif #endif
#endif #endif
#ifdef __WIN32__
extern void gettimeofday(struct timeval* t, struct timezone* dummy);
#endif
#endif // __INC_UTILS_H__ #endif // __INC_UTILS_H__

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