Reformatting code style

This commit is contained in:
legatt 2026-02-20 13:02:33 +03:00
parent b94a44c7a4
commit 9e6c5ab38b
32 changed files with 519 additions and 765 deletions

24
.idea/codeStyles/Project.xml generated Normal file
View File

@ -0,0 +1,24 @@
<component name="ProjectCodeStyleConfiguration">
<code_scheme name="Project" version="173">
<option name="AUTODETECT_INDENTS" value="false" />
<RiderCodeStyleSettings>
<option name="/Default/CodeStyle/Naming/CppNamingOptions/Rules/=0B82708A1BA7774EB13D27F245698A56/@EntryIndexedValue" value="&lt;NamingElement Priority=&quot;1&quot; Title=&quot;Classes and structs&quot;&gt;&lt;Descriptor Static=&quot;Indeterminate&quot; Constexpr=&quot;Indeterminate&quot; Const=&quot;Indeterminate&quot; Volatile=&quot;Indeterminate&quot; Accessibility=&quot;NOT_APPLICABLE&quot;&gt;&lt;type Name=&quot;__interface&quot; /&gt;&lt;type Name=&quot;class&quot; /&gt;&lt;type Name=&quot;struct&quot; /&gt;&lt;/Descriptor&gt;&lt;Policy Inspect=&quot;True&quot; WarnAboutPrefixesAndSuffixes=&quot;False&quot; Prefix=&quot;&quot; Suffix=&quot;&quot; Style=&quot;AaBb&quot; /&gt;&lt;/NamingElement&gt;" type="string" />
<option name="/Default/CodeStyle/Naming/CppNamingOptions/Rules/=A42D627FA43B054F91D1E1C4281D8896/@EntryIndexedValue" value="&lt;NamingElement Priority=&quot;2&quot; Title=&quot;Concepts&quot;&gt;&lt;Descriptor Static=&quot;Indeterminate&quot; Constexpr=&quot;Indeterminate&quot; Const=&quot;Indeterminate&quot; Volatile=&quot;Indeterminate&quot; Accessibility=&quot;NOT_APPLICABLE&quot;&gt;&lt;type Name=&quot;concept&quot; /&gt;&lt;/Descriptor&gt;&lt;Policy Inspect=&quot;True&quot; WarnAboutPrefixesAndSuffixes=&quot;False&quot; Prefix=&quot;&quot; Suffix=&quot;&quot; Style=&quot;AaBb&quot; /&gt;&lt;/NamingElement&gt;" type="string" />
<option name="/Default/CodeStyle/Naming/CppNamingOptions/Rules/=A7EBF16DA3BDCB42A0B710704BC8A053/@EntryIndexedValue" value="&lt;NamingElement Priority=&quot;3&quot; Title=&quot;Enums&quot;&gt;&lt;Descriptor Static=&quot;Indeterminate&quot; Constexpr=&quot;Indeterminate&quot; Const=&quot;Indeterminate&quot; Volatile=&quot;Indeterminate&quot; Accessibility=&quot;NOT_APPLICABLE&quot;&gt;&lt;type Name=&quot;enum&quot; /&gt;&lt;/Descriptor&gt;&lt;Policy Inspect=&quot;True&quot; WarnAboutPrefixesAndSuffixes=&quot;False&quot; Prefix=&quot;&quot; Suffix=&quot;&quot; Style=&quot;AaBb&quot; /&gt;&lt;/NamingElement&gt;" type="string" />
<option name="/Default/CodeStyle/Naming/CppNamingOptions/Rules/=2229A2BE1AA9214483A51F028530E042/@EntryIndexedValue" value="&lt;NamingElement Priority=&quot;4&quot; Title=&quot;Unions&quot;&gt;&lt;Descriptor Static=&quot;Indeterminate&quot; Constexpr=&quot;Indeterminate&quot; Const=&quot;Indeterminate&quot; Volatile=&quot;Indeterminate&quot; Accessibility=&quot;NOT_APPLICABLE&quot;&gt;&lt;type Name=&quot;union&quot; /&gt;&lt;/Descriptor&gt;&lt;Policy Inspect=&quot;True&quot; WarnAboutPrefixesAndSuffixes=&quot;False&quot; Prefix=&quot;&quot; Suffix=&quot;&quot; Style=&quot;AaBb&quot; /&gt;&lt;/NamingElement&gt;" type="string" />
<option name="/Default/CodeStyle/Naming/CppNamingOptions/Rules/=1350D079A82E0740947E85445B5AF47C/@EntryIndexedValue" value="&lt;NamingElement Priority=&quot;6&quot; Title=&quot;Parameters&quot;&gt;&lt;Descriptor Static=&quot;Indeterminate&quot; Constexpr=&quot;Indeterminate&quot; Const=&quot;Indeterminate&quot; Volatile=&quot;Indeterminate&quot; Accessibility=&quot;NOT_APPLICABLE&quot;&gt;&lt;type Name=&quot;function parameter&quot; /&gt;&lt;type Name=&quot;lambda parameter&quot; /&gt;&lt;/Descriptor&gt;&lt;Policy Inspect=&quot;True&quot; WarnAboutPrefixesAndSuffixes=&quot;False&quot; Prefix=&quot;&quot; Suffix=&quot;&quot; Style=&quot;aaBb&quot; /&gt;&lt;/NamingElement&gt;" type="string" />
<option name="/Default/CodeStyle/Naming/CppNamingOptions/Rules/=0AFB7787612DF743B09AD9412E48D4CC/@EntryIndexedValue" value="&lt;NamingElement Priority=&quot;7&quot; Title=&quot;Local variables&quot;&gt;&lt;Descriptor Static=&quot;Indeterminate&quot; Constexpr=&quot;Indeterminate&quot; Const=&quot;Indeterminate&quot; Volatile=&quot;Indeterminate&quot; Accessibility=&quot;NOT_APPLICABLE&quot;&gt;&lt;type Name=&quot;local variable&quot; /&gt;&lt;/Descriptor&gt;&lt;Policy Inspect=&quot;True&quot; WarnAboutPrefixesAndSuffixes=&quot;False&quot; Prefix=&quot;&quot; Suffix=&quot;&quot; Style=&quot;aaBb&quot; /&gt;&lt;/NamingElement&gt;" type="string" />
<option name="/Default/CodeStyle/Naming/CppNamingOptions/Rules/=72514D5DF422D442B71A277F97B72887/@EntryIndexedValue" value="&lt;NamingElement Priority=&quot;8&quot; Title=&quot;Global variables&quot;&gt;&lt;Descriptor Static=&quot;Indeterminate&quot; Constexpr=&quot;Indeterminate&quot; Const=&quot;Indeterminate&quot; Volatile=&quot;Indeterminate&quot; Accessibility=&quot;NOT_APPLICABLE&quot;&gt;&lt;type Name=&quot;global variable&quot; /&gt;&lt;/Descriptor&gt;&lt;Policy Inspect=&quot;True&quot; WarnAboutPrefixesAndSuffixes=&quot;False&quot; Prefix=&quot;&quot; Suffix=&quot;&quot; Style=&quot;aaBb&quot; /&gt;&lt;/NamingElement&gt;" type="string" />
<option name="/Default/CodeStyle/Naming/CppNamingOptions/Rules/=8F69F48E2532F54CBAA0039D4557825E/@EntryIndexedValue" value="&lt;NamingElement Priority=&quot;10&quot; Title=&quot;Global functions&quot;&gt;&lt;Descriptor Static=&quot;Indeterminate&quot; Constexpr=&quot;Indeterminate&quot; Const=&quot;Indeterminate&quot; Volatile=&quot;Indeterminate&quot; Accessibility=&quot;NOT_APPLICABLE&quot;&gt;&lt;type Name=&quot;global function&quot; /&gt;&lt;/Descriptor&gt;&lt;Policy Inspect=&quot;True&quot; WarnAboutPrefixesAndSuffixes=&quot;False&quot; Prefix=&quot;&quot; Suffix=&quot;&quot; Style=&quot;AaBb&quot; /&gt;&lt;/NamingElement&gt;" type="string" />
<option name="/Default/CodeStyle/Naming/CppNamingOptions/Rules/=B6E900853D6D05429D8C57765B2E546A/@EntryIndexedValue" value="&lt;NamingElement Priority=&quot;11&quot; Title=&quot;Class and struct methods&quot;&gt;&lt;Descriptor Static=&quot;Indeterminate&quot; Constexpr=&quot;Indeterminate&quot; Const=&quot;Indeterminate&quot; Volatile=&quot;Indeterminate&quot; Accessibility=&quot;NOT_APPLICABLE&quot;&gt;&lt;type Name=&quot;member function&quot; /&gt;&lt;/Descriptor&gt;&lt;Policy Inspect=&quot;True&quot; WarnAboutPrefixesAndSuffixes=&quot;False&quot; Prefix=&quot;&quot; Suffix=&quot;&quot; Style=&quot;AaBb&quot; /&gt;&lt;/NamingElement&gt;" type="string" />
<option name="/Default/CodeStyle/Naming/CppNamingOptions/Rules/=B82A063F0DDD98498A70D8D7EBB97F8D/@EntryIndexedValue" value="&lt;NamingElement Priority=&quot;12&quot; Title=&quot;Class and struct fields&quot;&gt;&lt;Descriptor Static=&quot;Indeterminate&quot; Constexpr=&quot;Indeterminate&quot; Const=&quot;Indeterminate&quot; Volatile=&quot;Indeterminate&quot; Accessibility=&quot;NOT_APPLICABLE&quot;&gt;&lt;type Name=&quot;class field&quot; /&gt;&lt;type Name=&quot;struct field&quot; /&gt;&lt;/Descriptor&gt;&lt;Policy Inspect=&quot;True&quot; WarnAboutPrefixesAndSuffixes=&quot;False&quot; Prefix=&quot;&quot; Suffix=&quot;_&quot; Style=&quot;aaBb&quot; /&gt;&lt;/NamingElement&gt;" type="string" />
<option name="/Default/CodeStyle/Naming/CppNamingOptions/Rules/=BBE8AA08E662BF409B2CB08EC597C493/@EntryIndexedValue" value="&lt;NamingElement Priority=&quot;13&quot; Title=&quot;Class and struct public fields&quot;&gt;&lt;Descriptor Static=&quot;Indeterminate&quot; Constexpr=&quot;Indeterminate&quot; Const=&quot;Indeterminate&quot; Volatile=&quot;Indeterminate&quot; Accessibility=&quot;PUBLIC&quot;&gt;&lt;type Name=&quot;class field&quot; /&gt;&lt;type Name=&quot;struct field&quot; /&gt;&lt;/Descriptor&gt;&lt;Policy Inspect=&quot;True&quot; WarnAboutPrefixesAndSuffixes=&quot;False&quot; Prefix=&quot;&quot; Suffix=&quot;&quot; Style=&quot;aaBb&quot; /&gt;&lt;/NamingElement&gt;" type="string" />
<option name="/Default/CodeStyle/Naming/CppNamingOptions/Rules/=5653BA7B6222F349B94149A2A53C35B8/@EntryIndexedValue" value="&lt;NamingElement Priority=&quot;14&quot; Title=&quot;Union members&quot;&gt;&lt;Descriptor Static=&quot;Indeterminate&quot; Constexpr=&quot;Indeterminate&quot; Const=&quot;Indeterminate&quot; Volatile=&quot;Indeterminate&quot; Accessibility=&quot;NOT_APPLICABLE&quot;&gt;&lt;type Name=&quot;union member&quot; /&gt;&lt;/Descriptor&gt;&lt;Policy Inspect=&quot;True&quot; WarnAboutPrefixesAndSuffixes=&quot;False&quot; Prefix=&quot;&quot; Suffix=&quot;&quot; Style=&quot;aaBb&quot; /&gt;&lt;/NamingElement&gt;" type="string" />
<option name="/Default/CodeStyle/Naming/CppNamingOptions/Rules/=4203BE6F332C5149B409B4D5F7197E54/@EntryIndexedValue" value="&lt;NamingElement Priority=&quot;15&quot; Title=&quot;Enumerators&quot;&gt;&lt;Descriptor Static=&quot;Indeterminate&quot; Constexpr=&quot;Indeterminate&quot; Const=&quot;Indeterminate&quot; Volatile=&quot;Indeterminate&quot; Accessibility=&quot;NOT_APPLICABLE&quot;&gt;&lt;type Name=&quot;scoped enumerator&quot; /&gt;&lt;type Name=&quot;unscoped enumerator&quot; /&gt;&lt;/Descriptor&gt;&lt;Policy Inspect=&quot;True&quot; WarnAboutPrefixesAndSuffixes=&quot;False&quot; Prefix=&quot;&quot; Suffix=&quot;&quot; Style=&quot;AA_BB&quot; /&gt;&lt;/NamingElement&gt;" type="string" />
<option name="/Default/CodeStyle/Naming/CppNamingOptions/Rules/=2B232F1067F0324F8FF4B9D63ACECDB2/@EntryIndexedValue" value="&lt;NamingElement Priority=&quot;16&quot; Title=&quot;Other constants&quot;&gt;&lt;Descriptor Static=&quot;True&quot; Constexpr=&quot;Indeterminate&quot; Const=&quot;True&quot; Volatile=&quot;Indeterminate&quot; Accessibility=&quot;NOT_APPLICABLE&quot;&gt;&lt;type Name=&quot;class field&quot; /&gt;&lt;type Name=&quot;local variable&quot; /&gt;&lt;type Name=&quot;struct field&quot; /&gt;&lt;/Descriptor&gt;&lt;Policy Inspect=&quot;True&quot; WarnAboutPrefixesAndSuffixes=&quot;False&quot; Prefix=&quot;&quot; Suffix=&quot;&quot; Style=&quot;AA_BB&quot; /&gt;&lt;/NamingElement&gt;" type="string" />
<option name="/Default/CodeStyle/Naming/CppNamingOptions/Rules/=BF0D1AE66D64FE4FAF613448A12051A0/@EntryIndexedValue" value="&lt;NamingElement Priority=&quot;17&quot; Title=&quot;Global constants&quot;&gt;&lt;Descriptor Static=&quot;Indeterminate&quot; Constexpr=&quot;Indeterminate&quot; Const=&quot;True&quot; Volatile=&quot;Indeterminate&quot; Accessibility=&quot;NOT_APPLICABLE&quot;&gt;&lt;type Name=&quot;global variable&quot; /&gt;&lt;/Descriptor&gt;&lt;Policy Inspect=&quot;True&quot; WarnAboutPrefixesAndSuffixes=&quot;False&quot; Prefix=&quot;&quot; Suffix=&quot;&quot; Style=&quot;AA_BB&quot; /&gt;&lt;/NamingElement&gt;" type="string" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_AFTER_PTR_IN_DATA_MEMBER/@EntryValue" value="false" type="bool" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_BEFORE_PTR_IN_DATA_MEMBER/@EntryValue" value="true" type="bool" />
</RiderCodeStyleSettings>
</code_scheme>
</component>

View File

@ -1,5 +1,5 @@
<component name="ProjectCodeStyleConfiguration"> <component name="ProjectCodeStyleConfiguration">
<state> <state>
<option name="PREFERRED_PROJECT_CODE_STYLE" value="Default" /> <option name="PREFERRED_PROJECT_CODE_STYLE" value="EtrediaEmpires" />
</state> </state>
</component> </component>

108
.idea/editor.xml generated
View File

@ -245,101 +245,31 @@
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=IfStdIsConstantEvaluatedCanBeReplaced/@EntryIndexedValue" value="SUGGESTION" type="string" /> <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/=StdIsConstantEvaluatedWillAlwaysEvaluateToConstant/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=StringLiteralTypo/@EntryIndexedValue" value="DO_NOT_SHOW" type="string" /> <option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=StringLiteralTypo/@EntryIndexedValue" value="DO_NOT_SHOW" type="string" />
<option name="/Default/CodeStyle/CodeFormatting/CppClangFormat/EnableClangFormatSupport/@EntryValue" value="false" type="bool" /> <option name="/Default/CodeStyle/CodeFormatting/CppFormatting/ALLOW_COMMENT_AFTER_LBRACE/@EntryValue" value="true" type="bool" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/ALIGN_MULTILINE_ARGUMENT/@EntryValue" value="true" 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_EXTENDS_LIST/@EntryValue" value="true" type="bool" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/ALIGN_MULTILINE_FOR_STMT/@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/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/ANONYMOUS_METHOD_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/BLANK_LINES_AROUND_CLASS_DEFINITION/@EntryValue" value="1" type="int" /> <option name="/Default/CodeStyle/CodeFormatting/CppFormatting/CASE_BLOCK_BRACES/@EntryValue" value="NEXT_LINE" type="string" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/BLANK_LINES_AROUND_DECLARATIONS/@EntryValue" value="0" type="int" /> <option name="/Default/CodeStyle/CodeFormatting/CppFormatting/EMPTY_BLOCK_STYLE/@EntryValue" value="TOGETHER_SAME_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/BREAK_TEMPLATE_DECLARATION/@EntryValue" value="LINE_BREAK" type="string" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/CASE_BLOCK_BRACES/@EntryValue" value="END_OF_LINE" type="string" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/CONTINUOUS_LINE_INDENT/@EntryValue" value="Double" type="string" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/INDENT_ACCESS_SPECIFIERS_FROM_CLASS/@EntryValue" value="false" type="bool" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/INDENT_CASE_FROM_SWITCH/@EntryValue" value="true" 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/INDENT_COMMENT/@EntryValue" value="true" type="bool" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/INDENT_SIZE/@EntryValue" value="4" type="int" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/INDENT_STYLE/@EntryValue" value="Space" 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/INT_ALIGN_EQ/@EntryValue" value="false" type="bool" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/INVOCABLE_DECLARATION_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/KEEP_BLANK_LINES_IN_CODE/@EntryValue" value="2" 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_USER_LINEBREAKS/@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/NAMESPACE_DECLARATION_BRACES/@EntryValue" value="END_OF_LINE" type="string" /> <option name="/Default/CodeStyle/CodeFormatting/CppFormatting/NAMESPACE_DECLARATION_BRACES/@EntryValue" value="END_OF_LINE" type="string" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/NAMESPACE_INDENTATION/@EntryValue" value="All" type="string" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/OTHER_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/PLACE_CATCH_ON_NEW_LINE/@EntryValue" value="false" type="bool" /> <option name="/Default/CodeStyle/CodeFormatting/CppFormatting/REQUIRES_EXPRESSION_BRACES/@EntryValue" value="END_OF_LINE" type="string" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/PLACE_ELSE_ON_NEW_LINE/@EntryValue" value="false" type="bool" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/PLACE_NAMESPACE_DEFINITIONS_ON_SAME_LINE/@EntryValue" value="false" type="bool" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/PLACE_WHILE_ON_NEW_LINE/@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_CAST_EXPRESSION_PARENTHESES/@EntryValue" value="true" 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_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_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_AFTER_FOR_SEMICOLON/@EntryValue" value="true" 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_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_AFTER_UNARY_OPERATOR/@EntryValue" value="false" 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_BEFORE_EXTENDS_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_BEFORE_FOR_SEMICOLON/@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_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_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_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/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_EMPTY_TEMPLATE_PARAMS/@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/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/SPECIAL_ELSE_IF_TREATMENT/@EntryValue" value="true" type="bool" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/TAB_WIDTH/@EntryValue" value="4" type="int" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/TYPE_DECLARATION_BRACES/@EntryValue" value="END_OF_LINE" type="string" /> <option name="/Default/CodeStyle/CodeFormatting/CppFormatting/TYPE_DECLARATION_BRACES/@EntryValue" value="END_OF_LINE" type="string" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/WRAP_AFTER_BINARY_OPSIGN/@EntryValue" value="true" type="bool" /> <option name="/Default/CodeStyle/Naming/CppNamingOptions/Rules/=0AFB7787612DF743B09AD9412E48D4CC/@EntryIndexedValue" value="&lt;NamingElement Priority=&quot;7&quot; Title=&quot;Local variables&quot;&gt;&lt;Descriptor Static=&quot;Indeterminate&quot; Constexpr=&quot;Indeterminate&quot; Const=&quot;Indeterminate&quot; Volatile=&quot;Indeterminate&quot; Accessibility=&quot;NOT_APPLICABLE&quot;&gt;&lt;type Name=&quot;local variable&quot; /&gt;&lt;/Descriptor&gt;&lt;Policy Inspect=&quot;True&quot; WarnAboutPrefixesAndSuffixes=&quot;False&quot; Prefix=&quot;&quot; Suffix=&quot;&quot; Style=&quot;aaBb&quot; /&gt;&lt;/NamingElement&gt;" type="string" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/WRAP_AFTER_DECLARATION_LPAR/@EntryValue" value="false" type="bool" /> <option name="/Default/CodeStyle/Naming/CppNamingOptions/Rules/=0B82708A1BA7774EB13D27F245698A56/@EntryIndexedValue" value="&lt;NamingElement Priority=&quot;1&quot; Title=&quot;Classes and structs&quot;&gt;&lt;Descriptor Static=&quot;Indeterminate&quot; Constexpr=&quot;Indeterminate&quot; Const=&quot;Indeterminate&quot; Volatile=&quot;Indeterminate&quot; Accessibility=&quot;NOT_APPLICABLE&quot;&gt;&lt;type Name=&quot;__interface&quot; /&gt;&lt;type Name=&quot;class&quot; /&gt;&lt;type Name=&quot;struct&quot; /&gt;&lt;/Descriptor&gt;&lt;Policy Inspect=&quot;True&quot; WarnAboutPrefixesAndSuffixes=&quot;False&quot; Prefix=&quot;&quot; Suffix=&quot;&quot; Style=&quot;AaBb&quot; /&gt;&lt;/NamingElement&gt;" type="string" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/WRAP_AFTER_INVOCATION_LPAR/@EntryValue" value="false" type="bool" /> <option name="/Default/CodeStyle/Naming/CppNamingOptions/Rules/=1350D079A82E0740947E85445B5AF47C/@EntryIndexedValue" value="&lt;NamingElement Priority=&quot;6&quot; Title=&quot;Parameters&quot;&gt;&lt;Descriptor Static=&quot;Indeterminate&quot; Constexpr=&quot;Indeterminate&quot; Const=&quot;Indeterminate&quot; Volatile=&quot;Indeterminate&quot; Accessibility=&quot;NOT_APPLICABLE&quot;&gt;&lt;type Name=&quot;function parameter&quot; /&gt;&lt;type Name=&quot;lambda parameter&quot; /&gt;&lt;/Descriptor&gt;&lt;Policy Inspect=&quot;True&quot; WarnAboutPrefixesAndSuffixes=&quot;False&quot; Prefix=&quot;&quot; Suffix=&quot;&quot; Style=&quot;aaBb&quot; /&gt;&lt;/NamingElement&gt;" type="string" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/WRAP_ARGUMENTS_STYLE/@EntryValue" value="WRAP_IF_LONG" type="string" /> <option name="/Default/CodeStyle/Naming/CppNamingOptions/Rules/=2229A2BE1AA9214483A51F028530E042/@EntryIndexedValue" value="&lt;NamingElement Priority=&quot;4&quot; Title=&quot;Unions&quot;&gt;&lt;Descriptor Static=&quot;Indeterminate&quot; Constexpr=&quot;Indeterminate&quot; Const=&quot;Indeterminate&quot; Volatile=&quot;Indeterminate&quot; Accessibility=&quot;NOT_APPLICABLE&quot;&gt;&lt;type Name=&quot;union&quot; /&gt;&lt;/Descriptor&gt;&lt;Policy Inspect=&quot;True&quot; WarnAboutPrefixesAndSuffixes=&quot;False&quot; Prefix=&quot;&quot; Suffix=&quot;&quot; Style=&quot;AaBb&quot; /&gt;&lt;/NamingElement&gt;" type="string" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/WRAP_BEFORE_DECLARATION_LPAR/@EntryValue" value="false" type="bool" /> <option name="/Default/CodeStyle/Naming/CppNamingOptions/Rules/=2B232F1067F0324F8FF4B9D63ACECDB2/@EntryIndexedValue" value="&lt;NamingElement Priority=&quot;16&quot; Title=&quot;Other constants&quot;&gt;&lt;Descriptor Static=&quot;True&quot; Constexpr=&quot;Indeterminate&quot; Const=&quot;True&quot; Volatile=&quot;Indeterminate&quot; Accessibility=&quot;NOT_APPLICABLE&quot;&gt;&lt;type Name=&quot;class field&quot; /&gt;&lt;type Name=&quot;local variable&quot; /&gt;&lt;type Name=&quot;struct field&quot; /&gt;&lt;/Descriptor&gt;&lt;Policy Inspect=&quot;True&quot; WarnAboutPrefixesAndSuffixes=&quot;False&quot; Prefix=&quot;&quot; Suffix=&quot;&quot; Style=&quot;AA_BB&quot; /&gt;&lt;/NamingElement&gt;" type="string" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/WRAP_BEFORE_DECLARATION_RPAR/@EntryValue" value="false" type="bool" /> <option name="/Default/CodeStyle/Naming/CppNamingOptions/Rules/=4203BE6F332C5149B409B4D5F7197E54/@EntryIndexedValue" value="&lt;NamingElement Priority=&quot;15&quot; Title=&quot;Enumerators&quot;&gt;&lt;Descriptor Static=&quot;Indeterminate&quot; Constexpr=&quot;Indeterminate&quot; Const=&quot;Indeterminate&quot; Volatile=&quot;Indeterminate&quot; Accessibility=&quot;NOT_APPLICABLE&quot;&gt;&lt;type Name=&quot;scoped enumerator&quot; /&gt;&lt;type Name=&quot;unscoped enumerator&quot; /&gt;&lt;/Descriptor&gt;&lt;Policy Inspect=&quot;True&quot; WarnAboutPrefixesAndSuffixes=&quot;False&quot; Prefix=&quot;&quot; Suffix=&quot;&quot; Style=&quot;AA_BB&quot; /&gt;&lt;/NamingElement&gt;" type="string" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/WRAP_BEFORE_INVOCATION_LPAR/@EntryValue" value="false" type="bool" /> <option name="/Default/CodeStyle/Naming/CppNamingOptions/Rules/=5653BA7B6222F349B94149A2A53C35B8/@EntryIndexedValue" value="&lt;NamingElement Priority=&quot;14&quot; Title=&quot;Union members&quot;&gt;&lt;Descriptor Static=&quot;Indeterminate&quot; Constexpr=&quot;Indeterminate&quot; Const=&quot;Indeterminate&quot; Volatile=&quot;Indeterminate&quot; Accessibility=&quot;NOT_APPLICABLE&quot;&gt;&lt;type Name=&quot;union member&quot; /&gt;&lt;/Descriptor&gt;&lt;Policy Inspect=&quot;True&quot; WarnAboutPrefixesAndSuffixes=&quot;False&quot; Prefix=&quot;&quot; Suffix=&quot;&quot; Style=&quot;aaBb&quot; /&gt;&lt;/NamingElement&gt;" type="string" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/WRAP_BEFORE_INVOCATION_RPAR/@EntryValue" value="false" type="bool" /> <option name="/Default/CodeStyle/Naming/CppNamingOptions/Rules/=72514D5DF422D442B71A277F97B72887/@EntryIndexedValue" value="&lt;NamingElement Priority=&quot;8&quot; Title=&quot;Global variables&quot;&gt;&lt;Descriptor Static=&quot;Indeterminate&quot; Constexpr=&quot;Indeterminate&quot; Const=&quot;Indeterminate&quot; Volatile=&quot;Indeterminate&quot; Accessibility=&quot;NOT_APPLICABLE&quot;&gt;&lt;type Name=&quot;global variable&quot; /&gt;&lt;/Descriptor&gt;&lt;Policy Inspect=&quot;True&quot; WarnAboutPrefixesAndSuffixes=&quot;False&quot; Prefix=&quot;&quot; Suffix=&quot;&quot; Style=&quot;aaBb&quot; /&gt;&lt;/NamingElement&gt;" type="string" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/WRAP_BEFORE_TERNARY_OPSIGNS/@EntryValue" value="true" type="bool" /> <option name="/Default/CodeStyle/Naming/CppNamingOptions/Rules/=8F69F48E2532F54CBAA0039D4557825E/@EntryIndexedValue" value="&lt;NamingElement Priority=&quot;10&quot; Title=&quot;Global functions&quot;&gt;&lt;Descriptor Static=&quot;Indeterminate&quot; Constexpr=&quot;Indeterminate&quot; Const=&quot;Indeterminate&quot; Volatile=&quot;Indeterminate&quot; Accessibility=&quot;NOT_APPLICABLE&quot;&gt;&lt;type Name=&quot;global function&quot; /&gt;&lt;/Descriptor&gt;&lt;Policy Inspect=&quot;True&quot; WarnAboutPrefixesAndSuffixes=&quot;False&quot; Prefix=&quot;&quot; Suffix=&quot;&quot; Style=&quot;AaBb&quot; /&gt;&lt;/NamingElement&gt;" type="string" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/WRAP_PARAMETERS_STYLE/@EntryValue" value="WRAP_IF_LONG" type="string" /> <option name="/Default/CodeStyle/Naming/CppNamingOptions/Rules/=A42D627FA43B054F91D1E1C4281D8896/@EntryIndexedValue" value="&lt;NamingElement Priority=&quot;2&quot; Title=&quot;Concepts&quot;&gt;&lt;Descriptor Static=&quot;Indeterminate&quot; Constexpr=&quot;Indeterminate&quot; Const=&quot;Indeterminate&quot; Volatile=&quot;Indeterminate&quot; Accessibility=&quot;NOT_APPLICABLE&quot;&gt;&lt;type Name=&quot;concept&quot; /&gt;&lt;/Descriptor&gt;&lt;Policy Inspect=&quot;True&quot; WarnAboutPrefixesAndSuffixes=&quot;False&quot; Prefix=&quot;&quot; Suffix=&quot;&quot; Style=&quot;AaBb&quot; /&gt;&lt;/NamingElement&gt;" type="string" />
<option name="/Default/CodeStyle/EditorConfig/EnableClangFormatSupport/@EntryValue" value="false" type="bool" /> <option name="/Default/CodeStyle/Naming/CppNamingOptions/Rules/=A7EBF16DA3BDCB42A0B710704BC8A053/@EntryIndexedValue" value="&lt;NamingElement Priority=&quot;3&quot; Title=&quot;Enums&quot;&gt;&lt;Descriptor Static=&quot;Indeterminate&quot; Constexpr=&quot;Indeterminate&quot; Const=&quot;Indeterminate&quot; Volatile=&quot;Indeterminate&quot; Accessibility=&quot;NOT_APPLICABLE&quot;&gt;&lt;type Name=&quot;enum&quot; /&gt;&lt;/Descriptor&gt;&lt;Policy Inspect=&quot;True&quot; WarnAboutPrefixesAndSuffixes=&quot;False&quot; Prefix=&quot;&quot; Suffix=&quot;&quot; Style=&quot;AaBb&quot; /&gt;&lt;/NamingElement&gt;" type="string" />
<option name="/Default/CodeStyle/Naming/CppNamingOptions/Rules/=B6E900853D6D05429D8C57765B2E546A/@EntryIndexedValue" value="&lt;NamingElement Priority=&quot;11&quot; Title=&quot;Class and struct methods&quot;&gt;&lt;Descriptor Static=&quot;Indeterminate&quot; Constexpr=&quot;Indeterminate&quot; Const=&quot;Indeterminate&quot; Volatile=&quot;Indeterminate&quot; Accessibility=&quot;NOT_APPLICABLE&quot;&gt;&lt;type Name=&quot;member function&quot; /&gt;&lt;/Descriptor&gt;&lt;Policy Inspect=&quot;True&quot; WarnAboutPrefixesAndSuffixes=&quot;False&quot; Prefix=&quot;&quot; Suffix=&quot;&quot; Style=&quot;AaBb&quot; /&gt;&lt;/NamingElement&gt;" type="string" />
<option name="/Default/CodeStyle/Naming/CppNamingOptions/Rules/=B82A063F0DDD98498A70D8D7EBB97F8D/@EntryIndexedValue" value="&lt;NamingElement Priority=&quot;12&quot; Title=&quot;Class and struct fields&quot;&gt;&lt;Descriptor Static=&quot;Indeterminate&quot; Constexpr=&quot;Indeterminate&quot; Const=&quot;Indeterminate&quot; Volatile=&quot;Indeterminate&quot; Accessibility=&quot;NOT_APPLICABLE&quot;&gt;&lt;type Name=&quot;class field&quot; /&gt;&lt;type Name=&quot;struct field&quot; /&gt;&lt;/Descriptor&gt;&lt;Policy Inspect=&quot;True&quot; WarnAboutPrefixesAndSuffixes=&quot;False&quot; Prefix=&quot;&quot; Suffix=&quot;_&quot; Style=&quot;aaBb&quot; /&gt;&lt;/NamingElement&gt;" type="string" />
<option name="/Default/CodeStyle/Naming/CppNamingOptions/Rules/=BBE8AA08E662BF409B2CB08EC597C493/@EntryIndexedValue" value="&lt;NamingElement Priority=&quot;13&quot; Title=&quot;Class and struct public fields&quot;&gt;&lt;Descriptor Static=&quot;Indeterminate&quot; Constexpr=&quot;Indeterminate&quot; Const=&quot;Indeterminate&quot; Volatile=&quot;Indeterminate&quot; Accessibility=&quot;PUBLIC&quot;&gt;&lt;type Name=&quot;class field&quot; /&gt;&lt;type Name=&quot;struct field&quot; /&gt;&lt;/Descriptor&gt;&lt;Policy Inspect=&quot;True&quot; WarnAboutPrefixesAndSuffixes=&quot;False&quot; Prefix=&quot;&quot; Suffix=&quot;&quot; Style=&quot;aaBb&quot; /&gt;&lt;/NamingElement&gt;" type="string" />
<option name="/Default/CodeStyle/Naming/CppNamingOptions/Rules/=BF0D1AE66D64FE4FAF613448A12051A0/@EntryIndexedValue" value="&lt;NamingElement Priority=&quot;17&quot; Title=&quot;Global constants&quot;&gt;&lt;Descriptor Static=&quot;Indeterminate&quot; Constexpr=&quot;Indeterminate&quot; Const=&quot;True&quot; Volatile=&quot;Indeterminate&quot; Accessibility=&quot;NOT_APPLICABLE&quot;&gt;&lt;type Name=&quot;global variable&quot; /&gt;&lt;/Descriptor&gt;&lt;Policy Inspect=&quot;True&quot; WarnAboutPrefixesAndSuffixes=&quot;False&quot; Prefix=&quot;&quot; Suffix=&quot;&quot; Style=&quot;AA_BB&quot; /&gt;&lt;/NamingElement&gt;" type="string" />
</component> </component>
</project> </project>

View File

@ -3,13 +3,12 @@ import GameData;
import views; import views;
import std; import std;
export namespace ee_assets export namespace ee_assets {
{
struct AssetData {}; struct AssetData {};
template<typename T> concept Asset = std::is_base_of_v<AssetData, T>;
enum AssetType template <typename T> concept Asset = std::is_base_of_v<AssetData, T>;
{
enum AssetType {
BINARY, BINARY,
MAP_MESH, MAP_MESH,
@ -20,37 +19,33 @@ export namespace ee_assets
IMAGE IMAGE
}; };
struct AssetBinary : public AssetData struct AssetBinary : public AssetData {
{ std::uint8_t *content = nullptr;
std::uint8_t* content = nullptr;
std::size_t size = 0; std::size_t size = 0;
AssetBinary(std::uint8_t* &source, const std::size_t sourceSize); AssetBinary(std::uint8_t * & source, const std::size_t sourceSize);
~AssetBinary(); ~AssetBinary();
}; };
struct AssetMapMesh : public AssetData struct AssetMapMesh : public AssetData {
{
ee_engine::MapMesh content; ee_engine::MapMesh content;
std::uint8_t* Serialize(std::size_t &size); std::uint8_t* Serialize(std::size_t& size);
AssetMapMesh() {}; AssetMapMesh() {};
AssetMapMesh(std::uint8_t* &source, const std::size_t sourceSize); AssetMapMesh(std::uint8_t * & source, const std::size_t sourceSize);
}; };
struct AssetSave : public AssetData struct AssetSave : public AssetData {
{
ee_data::GameState content; ee_data::GameState content;
std::uint8_t* Serialize(std::size_t &size); std::uint8_t* Serialize(std::size_t& size);
AssetSave() {}; AssetSave() {};
AssetSave(std::uint8_t* &source, const std::size_t sourceSize); AssetSave(std::uint8_t * & source, const std::size_t sourceSize);
}; };
using AssetShader = AssetBinary; using AssetShader = AssetBinary;
struct AssetMaterial : public AssetData struct AssetMaterial : public AssetData {
{
std::uint32_t vertexShaderAssetID; std::uint32_t vertexShaderAssetID;
std::uint32_t fragmentShaderAssetID; std::uint32_t fragmentShaderAssetID;
}; };

View File

@ -1,16 +1,13 @@
export module Input; export module Input;
import std; import std;
export namespace ee_engine export namespace ee_engine {
{ struct InputHandlers {
struct InputHandlers
{
std::function<void(float dx, float dy)> zooming; std::function<void(float dx, float dy)> zooming;
std::function<void(float x, float y, float lastX, float lastY)> mapScroll; std::function<void(float x, float y, float lastX, float lastY)> mapScroll;
}; };
class IInput class IInput {
{
public: public:
virtual ~IInput() {}; virtual ~IInput() {};
virtual void Poll() = 0; virtual void Poll() = 0;
@ -21,6 +18,6 @@ export namespace ee_engine
float mouseX = 0.0f, mouseY = 0.0f; float mouseX = 0.0f, mouseY = 0.0f;
float lastMouseX = 0.0f, lastMouseY = 0.0f; float lastMouseX = 0.0f, lastMouseY = 0.0f;
explicit IInput(const InputHandlers &handlers) {this->handlers = handlers;}; explicit IInput(const InputHandlers& handlers) { this->handlers = handlers; };
}; };
} }

View File

@ -9,31 +9,25 @@ import views;
import AssetData; import AssetData;
import std; import std;
export namespace ee_engine export namespace ee_engine {
{ struct ShaderRefs {
struct ShaderRefs
{
ee_assets::AssetShader *vertProvinces; ee_assets::AssetShader *vertProvinces;
ee_assets::AssetShader *fragProvinces; ee_assets::AssetShader *fragProvinces;
}; };
struct CameraTransform struct CameraTransform {
{ glm::vec2 position{0.0f, 0.0f};
glm::vec2 position {0.0f, 0.0f};
float zoom = 1.0f; float zoom = 1.0f;
}; };
struct MeshTransform struct MeshTransform {
{ glm::vec2 position{0.0f, 0.0f};
glm::vec2 position {0.0f, 0.0f}; glm::vec2 scale{1.0f, 1.0f};
glm::vec2 scale {1.0f, 1.0f};
float rotation; float rotation;
}; };
struct RendererCommand : public ee_utils::WorkerCommand struct RendererCommand : public ee_utils::WorkerCommand {
{ enum Type : std::uint8_t {
enum Type : std::uint8_t
{
NONE, NONE,
UPDATE_REGION, UPDATE_REGION,
@ -41,21 +35,23 @@ export namespace ee_engine
COMPLETED COMPLETED
}; };
struct RegionPayload { std::uint32_t id; ProvinceSSBO data; }; struct RegionPayload {
std::uint32_t id;
ProvinceSSBO data;
};
union { union {
RegionPayload region; RegionPayload region;
}; };
}; };
class IRenderer : public ee_utils::Worker<RendererCommand, RendererCommand::COMPLETED> class IRenderer : public ee_utils::Worker<RendererCommand, RendererCommand::COMPLETED> {
{
public: public:
virtual ~IRenderer(); virtual ~IRenderer();
constexpr bool isReady() const noexcept {return _isReady;} constexpr bool isReady() const noexcept { return _isReady; }
void RegisterMaterials(const ShaderRefs &shaders); void RegisterMaterials(const ShaderRefs& shaders);
void RegisterMapMesh(MapMesh *mapMesh); void RegisterMapMesh(MapMesh *mapMesh);
virtual void Init() = 0; virtual void Init() = 0;
@ -63,12 +59,11 @@ export namespace ee_engine
void Draw(); void Draw();
virtual void ResizeWindow(int width, int height); virtual void ResizeWindow(int width, int height);
void SetCamera(const CameraTransform &camera); void SetCamera(const CameraTransform& camera);
constexpr CameraTransform getCamera() const noexcept {return camera;}; constexpr CameraTransform getCamera() const noexcept { return camera; };
glm::vec2 ScreenToWorld(const float screenx, const float screenY); glm::vec2 ScreenToWorld(const float screenx, const float screenY);
glm::vec2 ScreenToWorld(const glm::vec2 &screenPos); glm::vec2 ScreenToWorld(const glm::vec2& screenPos);
protected: protected:
bool _isReady; bool _isReady;
@ -82,7 +77,11 @@ export namespace ee_engine
MapMesh *mapMesh; MapMesh *mapMesh;
ShaderRefs shaders; ShaderRefs shaders;
struct RegionIndecies {std::size_t startIndex; std::size_t provincesCount;}; struct RegionIndecies {
std::size_t startIndex;
std::size_t provincesCount;
};
std::unordered_map<std::uint32_t /*id*/, RegionIndecies> regionsMapping; std::unordered_map<std::uint32_t /*id*/, RegionIndecies> regionsMapping;
explicit IRenderer(GLFWwindow *window); explicit IRenderer(GLFWwindow *window);
@ -93,9 +92,9 @@ export namespace ee_engine
virtual void ApplyCamera() = 0; virtual void ApplyCamera() = 0;
virtual void UpdateProvinces(const std::size_t index, const std::vector<ee_engine::ProvinceSSBO> &data) = 0; virtual void UpdateProvinces(const std::size_t index, const std::vector<ee_engine::ProvinceSSBO>& data) = 0;
private: private:
void UpdateRegionCmd(RendererCommand &command); void UpdateRegionCmd(RendererCommand& command);
}; };
} }

View File

@ -5,20 +5,17 @@ module;
export module views:MapView; export module views:MapView;
import std; import std;
export namespace ee_engine export namespace ee_engine {
{ struct MapMesh {
struct MapMesh struct Province {
{
struct Province
{
std::vector<glm::vec2> vertices; std::vector<glm::vec2> vertices;
std::vector<std::uint16_t> indices; std::vector<std::uint16_t> indices;
}; };
std::unordered_map<std::uint32_t, std::vector<Province>> regions; std::unordered_map<std::uint32_t, std::vector<Province>> regions;
}; };
struct ProvinceSSBO struct ProvinceSSBO {
{
std::uint32_t regionId; std::uint32_t regionId;
std::uint32_t color; std::uint32_t color;
}; };

View File

@ -14,46 +14,40 @@ TODO: make universal binary format, think about flatbuffers or msgpacks
*/ */
ee_assets::AssetBinary::AssetBinary(std::uint8_t* &source, const std::size_t sourceSize) ee_assets::AssetBinary::AssetBinary(std::uint8_t * & source, const std::size_t sourceSize) {
{
content = source; content = source;
size = sourceSize; size = sourceSize;
source = nullptr; source = nullptr;
} }
ee_assets::AssetBinary::~AssetBinary() ee_assets::AssetBinary::~AssetBinary() {
{
if (content != nullptr) if (content != nullptr)
DeallocateArray(content); DeallocateArray(content);
} }
ee_assets::AssetMapMesh::AssetMapMesh(std::uint8_t * & source, const std::size_t sourceSize) {
ee_assets::AssetMapMesh::AssetMapMesh(std::uint8_t* &source, const std::size_t sourceSize) std::uint8_t *buffer = source;
{ std::uint8_t *pointer = source;
std::uint8_t* buffer = source;
std::uint8_t* pointer = source;
std::size_t leftoverSize = sourceSize; std::size_t leftoverSize = sourceSize;
source = nullptr; source = nullptr;
std::uint32_t regionsCount = 0; std::uint32_t regionsCount = 0;
ee_utils::readNext(&regionsCount, pointer, leftoverSize, sizeof(std::uint32_t)); ee_utils::readNext(&regionsCount, pointer, leftoverSize, sizeof(std::uint32_t));
for (std::uint32_t region = 0; region < regionsCount; region++) for (std::uint32_t region = 0; region < regionsCount; region++) {
{
std::uint32_t id = 0; std::uint32_t id = 0;
glm::u8vec3 color {}; glm::u8vec3 color{};
if (!ee_utils::readNext(&color, pointer, leftoverSize, sizeof(glm::u8vec3))) if (!ee_utils::readNext(&color, pointer, leftoverSize, sizeof(glm::u8vec3)))
break; break;
id = static_cast<std::uint32_t>(color.r) << 16 | id = static_cast<std::uint32_t>(color.r) << 16 |
static_cast<std::uint32_t>(color.g) << 8 | static_cast<std::uint32_t>(color.g) << 8 |
static_cast<std::uint32_t>(color.b); static_cast<std::uint32_t>(color.b);
std::uint32_t provincesCount = 0; std::uint32_t provincesCount = 0;
ee_utils::readNext(&provincesCount, pointer, leftoverSize, sizeof(std::uint32_t)); ee_utils::readNext(&provincesCount, pointer, leftoverSize, sizeof(std::uint32_t));
for (std::uint32_t pi = 0; pi < provincesCount; pi++) for (std::uint32_t pi = 0; pi < provincesCount; pi++) {
{
ee_engine::MapMesh::Province prov; ee_engine::MapMesh::Province prov;
std::uint32_t verticesCount = 0; std::uint32_t verticesCount = 0;
@ -61,8 +55,7 @@ ee_assets::AssetMapMesh::AssetMapMesh(std::uint8_t* &source, const std::size_t s
break; break;
prov.vertices.reserve(verticesCount); prov.vertices.reserve(verticesCount);
for (std::uint32_t vi = 0; vi < verticesCount; vi++) for (std::uint32_t vi = 0; vi < verticesCount; vi++) {
{
glm::vec2 vertex; glm::vec2 vertex;
if (!ee_utils::readNext(&vertex, pointer, leftoverSize, sizeof(glm::vec2))) if (!ee_utils::readNext(&vertex, pointer, leftoverSize, sizeof(glm::vec2)))
break; break;
@ -75,8 +68,7 @@ ee_assets::AssetMapMesh::AssetMapMesh(std::uint8_t* &source, const std::size_t s
break; break;
prov.indices.reserve(indicesCount); prov.indices.reserve(indicesCount);
for(std::uint32_t ii = 0; ii < indicesCount; ii++) for (std::uint32_t ii = 0; ii < indicesCount; ii++) {
{
std::uint16_t index = 0; std::uint16_t index = 0;
if (!ee_utils::readNext(&index, pointer, leftoverSize, sizeof(std::uint16_t))) if (!ee_utils::readNext(&index, pointer, leftoverSize, sizeof(std::uint16_t)))
break; break;
@ -92,18 +84,16 @@ ee_assets::AssetMapMesh::AssetMapMesh(std::uint8_t* &source, const std::size_t s
} }
ee_assets::AssetSave::AssetSave(std::uint8_t* &source, const std::size_t sourceSize) ee_assets::AssetSave::AssetSave(std::uint8_t * & source, const std::size_t sourceSize) {
{ std::uint8_t *buffer = source;
std::uint8_t* buffer = source; std::uint8_t *pointer = source;
std::uint8_t* pointer = source;
std::size_t leftoverSize = sourceSize; std::size_t leftoverSize = sourceSize;
source = nullptr; source = nullptr;
std::uint16_t subjectsCount = static_cast<std::uint16_t>(content.subjects.size()); std::uint16_t subjectsCount = static_cast<std::uint16_t>(content.subjects.size());
ee_utils::readNext(&subjectsCount, pointer, leftoverSize, sizeof(std::uint16_t)); ee_utils::readNext(&subjectsCount, pointer, leftoverSize, sizeof(std::uint16_t));
for (std::uint16_t i = 0; i < subjectsCount; i++) for (std::uint16_t i = 0; i < subjectsCount; i++) {
{
ee_data::Subject subject; ee_data::Subject subject;
ee_utils::readNext(&subject.tag, pointer, leftoverSize, sizeof(subject.tag)); ee_utils::readNext(&subject.tag, pointer, leftoverSize, sizeof(subject.tag));
@ -113,10 +103,10 @@ ee_assets::AssetSave::AssetSave(std::uint8_t* &source, const std::size_t sourceS
ee_utils::readNext(&regionsCount, pointer, leftoverSize, sizeof(std::uint16_t)); ee_utils::readNext(&regionsCount, pointer, leftoverSize, sizeof(std::uint16_t));
subject.regions.resize(regionsCount); subject.regions.resize(regionsCount);
ee_utils::readNext( ee_utils::readNext(
subject.regions.data(), subject.regions.data(),
pointer, pointer,
leftoverSize, leftoverSize,
subject.regions.size() * sizeof(std::uint32_t) subject.regions.size() * sizeof(std::uint32_t)
); );
content.subjects.push_back(subject); content.subjects.push_back(subject);
@ -126,16 +116,11 @@ ee_assets::AssetSave::AssetSave(std::uint8_t* &source, const std::size_t sourceS
} }
// SERIALIZERS // SERIALIZERS
std::uint8_t* ee_assets::AssetSave::Serialize(std::size_t &size) std::uint8_t* ee_assets::AssetSave::Serialize(std::size_t& size) {
{
size = sizeof(std::uint16_t); size = sizeof(std::uint16_t);
for (ee_data::Subject &subject : content.subjects) for (ee_data::Subject& subject : content.subjects) {
{
size += sizeof(subject.tag); size += sizeof(subject.tag);
size += sizeof(subject.color); size += sizeof(subject.color);
size += sizeof(std::uint16_t) + subject.regions.size() * sizeof(std::uint32_t); size += sizeof(std::uint16_t) + subject.regions.size() * sizeof(std::uint32_t);
@ -148,18 +133,17 @@ std::uint8_t* ee_assets::AssetSave::Serialize(std::size_t &size)
std::uint16_t subjectsCount = static_cast<std::uint16_t>(content.subjects.size()); std::uint16_t subjectsCount = static_cast<std::uint16_t>(content.subjects.size());
ee_utils::writeNext(pointer, &subjectsCount, leftover, sizeof(std::uint16_t)); ee_utils::writeNext(pointer, &subjectsCount, leftover, sizeof(std::uint16_t));
for (ee_data::Subject &subject : content.subjects) for (ee_data::Subject& subject : content.subjects) {
{
ee_utils::writeNext(pointer, &subject.tag, leftover, sizeof(subject.tag)); ee_utils::writeNext(pointer, &subject.tag, leftover, sizeof(subject.tag));
ee_utils::writeNext(pointer, &subject.color, leftover, sizeof(subject.color)); ee_utils::writeNext(pointer, &subject.color, leftover, sizeof(subject.color));
std::uint16_t regionsCount = static_cast<std::uint16_t>(subject.regions.size()); std::uint16_t regionsCount = static_cast<std::uint16_t>(subject.regions.size());
ee_utils::writeNext(pointer, &regionsCount, leftover, sizeof(std::uint16_t)); ee_utils::writeNext(pointer, &regionsCount, leftover, sizeof(std::uint16_t));
ee_utils::writeNext( ee_utils::writeNext(
pointer, pointer,
subject.regions.data(), subject.regions.data(),
leftover, leftover,
subject.regions.size() * sizeof(std::uint32_t) subject.regions.size() * sizeof(std::uint32_t)
); );
} }

View File

@ -7,8 +7,7 @@ module Render;
import std; import std;
import utils; import utils;
ee_engine::IRenderer::IRenderer(GLFWwindow *window) ee_engine::IRenderer::IRenderer(GLFWwindow *window) {
{
commandsMapping[RendererCommand::UPDATE_REGION] = std::bind_front(&IRenderer::UpdateRegionCmd, this); commandsMapping[RendererCommand::UPDATE_REGION] = std::bind_front(&IRenderer::UpdateRegionCmd, this);
this->window = window; this->window = window;
@ -16,39 +15,30 @@ ee_engine::IRenderer::IRenderer(GLFWwindow *window)
screenAspect = static_cast<float>(screenWidth) / static_cast<float>(screenHeight); screenAspect = static_cast<float>(screenWidth) / static_cast<float>(screenHeight);
} }
ee_engine::IRenderer::~IRenderer() ee_engine::IRenderer::~IRenderer() {}
{
} void ee_engine::IRenderer::RegisterMaterials(const ShaderRefs& shaders) {
void ee_engine::IRenderer::RegisterMaterials(const ShaderRefs &shaders)
{
this->shaders = shaders; this->shaders = shaders;
} }
void ee_engine::IRenderer::RegisterMapMesh(MapMesh* mapMesh) void ee_engine::IRenderer::RegisterMapMesh(MapMesh *mapMesh) {
{
this->mapMesh = mapMesh; this->mapMesh = mapMesh;
} }
void ee_engine::IRenderer::Draw() void ee_engine::IRenderer::Draw() {
{
Clear(); Clear();
DrawMap(); DrawMap();
DrawUI(); DrawUI();
} }
void ee_engine::IRenderer::ResizeWindow(int width, int height) void ee_engine::IRenderer::ResizeWindow(int width, int height) {
{
screenWidth = width; screenWidth = width;
screenHeight = height; screenHeight = height;
screenAspect = static_cast<float>(screenWidth) / static_cast<float>(screenHeight); screenAspect = static_cast<float>(screenWidth) / static_cast<float>(screenHeight);
} }
void ee_engine::IRenderer::SetCamera(const CameraTransform &camera) void ee_engine::IRenderer::SetCamera(const CameraTransform& camera) {
{ if (camera.zoom <= 0) {
if (camera.zoom <= 0)
{
LOG(WARNING, "Camera zoom cannot be zero or less!"); LOG(WARNING, "Camera zoom cannot be zero or less!");
return; return;
} }
@ -59,13 +49,13 @@ void ee_engine::IRenderer::SetCamera(const CameraTransform &camera)
float halfWidth = camera.zoom * screenAspect; float halfWidth = camera.zoom * screenAspect;
glm::mat4 P = glm::ortho( glm::mat4 P = glm::ortho(
-halfWidth, +halfWidth, -halfWidth, +halfWidth,
-halfHeight, +halfHeight -halfHeight, +halfHeight
); );
glm::mat4 V = glm::translate( glm::mat4 V = glm::translate(
glm::mat4(1.0f), glm::mat4(1.0f),
glm::vec3(-camera.position, 0.0f) glm::vec3(-camera.position, 0.0f)
); );
viewProjection = P * V; viewProjection = P * V;
@ -74,13 +64,11 @@ void ee_engine::IRenderer::SetCamera(const CameraTransform &camera)
ApplyCamera(); ApplyCamera();
} }
glm::vec2 ee_engine::IRenderer::ScreenToWorld(const float screenX, const float screenY) glm::vec2 ee_engine::IRenderer::ScreenToWorld(const float screenX, const float screenY) {
{
return ScreenToWorld(glm::vec2(screenX, screenY)); return ScreenToWorld(glm::vec2(screenX, screenY));
} }
glm::vec2 ee_engine::IRenderer::ScreenToWorld(const glm::vec2 &screenPos) glm::vec2 ee_engine::IRenderer::ScreenToWorld(const glm::vec2& screenPos) {
{
float x = 2.0f * screenPos.x / screenWidth - 1.0f; float x = 2.0f * screenPos.x / screenWidth - 1.0f;
float y = -2.0f * screenPos.y / screenHeight + 1.0f; float y = -2.0f * screenPos.y / screenHeight + 1.0f;
@ -91,16 +79,13 @@ glm::vec2 ee_engine::IRenderer::ScreenToWorld(const glm::vec2 &screenPos)
return glm::vec2(world) / world.w; return glm::vec2(world) / world.w;
} }
void ee_engine::IRenderer::UpdateRegionCmd(ee_engine::RendererCommand &command) void ee_engine::IRenderer::UpdateRegionCmd(ee_engine::RendererCommand& command) {
{ if (!regionsMapping.contains(command.region.id)) {
if (!regionsMapping.contains(command.region.id))
{
LOG(WARNING, "Updating unregistered region with id: %d", command.region.id); LOG(WARNING, "Updating unregistered region with id: %d", command.region.id);
return; return;
} }
if (command.region.id != command.region.data.regionId) if (command.region.id != command.region.data.regionId) {
{
LOG(ERROR, "Updating regions ID is not supported! Region: %d Changed ID: %d", LOG(ERROR, "Updating regions ID is not supported! Region: %d Changed ID: %d",
command.region.id, command.region.data.regionId); command.region.id, command.region.data.regionId);
} }
@ -108,8 +93,7 @@ void ee_engine::IRenderer::UpdateRegionCmd(ee_engine::RendererCommand &command)
RegionIndecies mapping = regionsMapping[command.region.id]; RegionIndecies mapping = regionsMapping[command.region.id];
std::vector<ProvinceSSBO> buffer; std::vector<ProvinceSSBO> buffer;
buffer.reserve(mapping.provincesCount); buffer.reserve(mapping.provincesCount);
for (std::size_t i = 0; i < mapping.provincesCount; i++) for (std::size_t i = 0; i < mapping.provincesCount; i++) {
{
buffer.push_back(command.region.data); buffer.push_back(command.region.data);
} }

View File

@ -3,8 +3,7 @@ import Input;
export export
{ {
class Actions class Actions {
{
public: public:
static ee_engine::InputHandlers mappings; static ee_engine::InputHandlers mappings;

View File

@ -4,7 +4,7 @@ module;
#include <xxhash.h> #include <xxhash.h>
export module AssetManager; export module AssetManager;
export import AssetData; export import AssetData;
import utils; import utils;
import FileSystem; import FileSystem;
@ -12,28 +12,24 @@ import std;
export export
{ {
struct AssetAddress struct AssetAddress {
{
std::atomic<void*> resource; std::atomic<void*> resource;
}; };
struct AssetHandle struct AssetHandle {
{
static constexpr std::uint32_t INVALID_ASSET_ID = UINT32_MAX; static constexpr std::uint32_t INVALID_ASSET_ID = UINT32_MAX;
std::size_t slot = 0; std::size_t slot = 0;
std::uint32_t id = 0; std::uint32_t id = 0;
}; };
class AssetInfo class AssetInfo {
{
public: public:
ee_assets::AssetType type = ee_assets::BINARY; ee_assets::AssetType type = ee_assets::BINARY;
std::atomic<bool> isReady; std::atomic<bool> isReady;
AssetAddress* resourceAddress; AssetAddress *resourceAddress;
AssetInfo(void *resource) AssetInfo(void *resource) {
{
this->resourceAddress = Allocate<AssetAddress>(); this->resourceAddress = Allocate<AssetAddress>();
this->resourceAddress->resource.store(resource); this->resourceAddress->resource.store(resource);
} }
@ -43,18 +39,15 @@ export
AssetInfo(AssetInfo&& other) noexcept : AssetInfo(AssetInfo&& other) noexcept :
type(other.type), type(other.type),
resourceAddress(other.resourceAddress) resourceAddress(other.resourceAddress) {
{
isReady.store(other.isReady.load(std::memory_order_relaxed), std::memory_order_relaxed); isReady.store(other.isReady.load(std::memory_order_relaxed), std::memory_order_relaxed);
other.resourceAddress = nullptr; other.resourceAddress = nullptr;
other.isReady.store(false, std::memory_order_relaxed); other.isReady.store(false, std::memory_order_relaxed);
} }
AssetInfo& operator=(AssetInfo&& other) noexcept AssetInfo& operator=(AssetInfo&& other) noexcept {
{ if (this != &other) {
if (this != &other)
{
type = other.type; type = other.type;
resourceAddress = other.resourceAddress; resourceAddress = other.resourceAddress;
isReady.store(other.isReady.load(std::memory_order_relaxed), std::memory_order_relaxed); isReady.store(other.isReady.load(std::memory_order_relaxed), std::memory_order_relaxed);
@ -66,17 +59,14 @@ export
} }
}; };
struct AssetLoadingEntry struct AssetLoadingEntry {
{
AssetHandle handle; AssetHandle handle;
FileHandle* file; FileHandle *file;
IFileSystem* fileOwner; IFileSystem *fileOwner;
}; };
struct AssetStreamCommand : ee_utils::WorkerCommand struct AssetStreamCommand : ee_utils::WorkerCommand {
{ enum Type : std::uint8_t {
enum Type : std::uint8_t
{
NONE, NONE,
LOAD, LOAD,
@ -90,14 +80,12 @@ export
std::uint32_t targetId = AssetHandle::INVALID_ASSET_ID; std::uint32_t targetId = AssetHandle::INVALID_ASSET_ID;
std::filesystem::path targetPath; std::filesystem::path targetPath;
ee_assets::AssetType targetType = ee_assets::BINARY; ee_assets::AssetType targetType = ee_assets::BINARY;
std::atomic<void*>* out = nullptr; std::atomic<void*> *out = nullptr;
}; };
class AssetManager final : public ee_utils::ThreadedWorker<AssetStreamCommand, AssetStreamCommand::COMPLETED> class AssetManager final : public ee_utils::ThreadedWorker<AssetStreamCommand, AssetStreamCommand::COMPLETED> {
{
public: public:
AssetManager() : ThreadedWorker(L"Assets Stream", 250) AssetManager() : ThreadedWorker(L"Assets Stream", 250) {
{
commandsMapping[AssetStreamCommand::LOAD] = std::bind_front(&AssetManager::LoadCmd, this); commandsMapping[AssetStreamCommand::LOAD] = std::bind_front(&AssetManager::LoadCmd, this);
commandsMapping[AssetStreamCommand::FIND] = std::bind_front(&AssetManager::FindCmd, this); commandsMapping[AssetStreamCommand::FIND] = std::bind_front(&AssetManager::FindCmd, this);
commandsMapping[AssetStreamCommand::GET] = std::bind_front(&AssetManager::GetCmd, this); commandsMapping[AssetStreamCommand::GET] = std::bind_front(&AssetManager::GetCmd, this);
@ -105,22 +93,18 @@ export
diskSystem = Allocate<NativeFileSystem>(); diskSystem = Allocate<NativeFileSystem>();
} }
~AssetManager() override ~AssetManager() override {
{
Deallocate(diskSystem); Deallocate(diskSystem);
} }
void LoadDir(ee_assets::AssetType type, const std::filesystem::path &path) void LoadDir(ee_assets::AssetType type, const std::filesystem::path& path) {
{ for (const std::filesystem::directory_entry& entry : std::filesystem::directory_iterator(path)) {
for (const std::filesystem::directory_entry &entry : std::filesystem::directory_iterator(path))
{
if (entry.is_directory()) continue; if (entry.is_directory()) continue;
LoadAsync(type, entry.path()); LoadAsync(type, entry.path());
} }
} }
void LoadAsync(ee_assets::AssetType type, const std::filesystem::path &path) void LoadAsync(ee_assets::AssetType type, const std::filesystem::path& path) {
{
AssetStreamCommand command; AssetStreamCommand command;
command.type = AssetStreamCommand::LOAD; command.type = AssetStreamCommand::LOAD;
command.targetPath = path; command.targetPath = path;
@ -129,8 +113,7 @@ export
Request(command); Request(command);
} }
AssetHandle& Find(const std::filesystem::path &path) AssetHandle& Find(const std::filesystem::path& path) {
{
std::atomic<void*> result; std::atomic<void*> result;
AssetStreamCommand command; AssetStreamCommand command;
command.type = AssetStreamCommand::FIND; command.type = AssetStreamCommand::FIND;
@ -142,8 +125,7 @@ export
return *reinterpret_cast<AssetHandle*>(command.out->load()); return *reinterpret_cast<AssetHandle*>(command.out->load());
} }
AssetHandle& Find(const std::uint32_t id) AssetHandle& Find(const std::uint32_t id) {
{
std::atomic<void*> result; std::atomic<void*> result;
AssetStreamCommand command; AssetStreamCommand command;
command.type = AssetStreamCommand::FIND; command.type = AssetStreamCommand::FIND;
@ -156,40 +138,37 @@ export
} }
// Returned resource reference should not be stored // Returned resource reference should not be stored
template <ee_assets::Asset T> T& FindOnce(const std::filesystem::path &path) template <ee_assets::Asset T>
{ T& FindOnce(const std::filesystem::path& path) {
return Get<T>(Find(path)); return Get<T>(Find(path));
} }
// Returned resource reference should not be stored // Returned resource reference should not be stored
template <ee_assets::Asset T> T& FindOnce(const std::uint32_t id) template <ee_assets::Asset T>
{ T& FindOnce(const std::uint32_t id) {
return Get<T>(Find(id)); return Get<T>(Find(id));
} }
void Redirect(const AssetHandle &handle, void *resource) void Redirect(const AssetHandle& handle, void *resource) {
{ const AssetInfo& asset = activeAssets[handle.slot];
const AssetInfo &asset = activeAssets[handle.slot]; if (asset.resourceAddress == nullptr) {
if (asset.resourceAddress == nullptr)
{
LOG(WARNING, "Attempt to redirect empty handle"); LOG(WARNING, "Attempt to redirect empty handle");
return; return;
} }
// TODO: LEAK! Free old resource after redirecting handler to other resource // TODO: LEAK! Free old resource after redirecting handler to other resource
if (asset.resourceAddress->resource.load() != nullptr) if (asset.resourceAddress->resource.load() != nullptr) {
{ void *oldResource = asset.resourceAddress->resource.exchange(nullptr, std::memory_order_acq_rel);
void* oldResource = asset.resourceAddress->resource.exchange(nullptr, std::memory_order_acq_rel);
//if (oldResource) //if (oldResource)
//Deallocate(oldResource); //Deallocate(oldResource);
} }
asset.resourceAddress->resource.store(resource); asset.resourceAddress->resource.store(resource);
} }
// Returned resource reference should not be stored // Returned resource reference should not be stored
template <ee_assets::Asset T> T& Get(const AssetHandle &handle) template <ee_assets::Asset T>
{ T& Get(const AssetHandle& handle) {
std::atomic<void*> result; std::atomic<void*> result;
AssetStreamCommand command; AssetStreamCommand command;
command.type = AssetStreamCommand::GET; command.type = AssetStreamCommand::GET;
@ -201,9 +180,8 @@ export
return *reinterpret_cast<T*>(command.out->load()); return *reinterpret_cast<T*>(command.out->load());
} }
void Free(AssetHandle &handle) void Free(AssetHandle& handle) {
{ AssetInfo& asset = activeAssets[handle.slot];
AssetInfo &asset = activeAssets[handle.slot];
Redirect(handle, nullptr); Redirect(handle, nullptr);
Deallocate(asset.resourceAddress); Deallocate(asset.resourceAddress);
asset.resourceAddress = nullptr; asset.resourceAddress = nullptr;
@ -212,62 +190,55 @@ export
} }
protected: protected:
void Update() override void Update() override {
{
// TODO: FinishLoadTasks() // TODO: FinishLoadTasks()
for (AssetLoadingEntry &entry : loadingEntries) for (AssetLoadingEntry& entry : loadingEntries) {
{
bool isReady = entry.fileOwner->PollReady(*entry.file); bool isReady = entry.fileOwner->PollReady(*entry.file);
if (isReady) if (isReady) {
{
AssetInfo& asset = activeAssets[entry.handle.slot]; AssetInfo& asset = activeAssets[entry.handle.slot];
switch (asset.type) switch (asset.type) {
{ case ee_assets::MAP_MESH:
case ee_assets::MAP_MESH: FinishLoadConstruct(entry, mapMeshesStorage);
FinishLoadConstruct(entry, mapMeshesStorage); break;
break; case ee_assets::SAVE:
case ee_assets::SAVE: FinishLoadConstruct(entry, savesStorage);
FinishLoadConstruct(entry, savesStorage); break;
break;
case ee_assets::SHADER: case ee_assets::SHADER:
FinishLoadConstruct(entry, shadersStorage); FinishLoadConstruct(entry, shadersStorage);
break; break;
case ee_assets::MATERIAL: case ee_assets::MATERIAL:
FinishLoadPlain(entry, materialsStorage); FinishLoadPlain(entry, materialsStorage);
break; break;
case ee_assets::IMAGE: case ee_assets::IMAGE:
break; break;
case ee_assets::BINARY: case ee_assets::BINARY:
default: default:
FinishLoadConstruct(entry, binaryStorage); FinishLoadConstruct(entry, binaryStorage);
break; break;
} }
entry.fileOwner->Close(*entry.file); entry.fileOwner->Close(*entry.file);
#ifndef NDEBUG #ifndef NDEBUG
LOG(INFO, "Asset loaded: [%hs]", entry.file->debugPath.generic_u8string().c_str()); LOG(INFO, "Asset loaded: [%hs]", entry.file->debugPath.generic_u8string().c_str());
#endif #endif
entry.file = nullptr; entry.file = nullptr;
asset.isReady.store(true); asset.isReady.store(true);
} }
} }
std::erase_if(loadingEntries, [](const AssetLoadingEntry &entry) { std::erase_if(loadingEntries, [](const AssetLoadingEntry& entry) {
return entry.file == nullptr; return entry.file == nullptr;
}); });
} }
void Release() override void Release() override {
{ for (const AssetInfo& asset : activeAssets) {
for (const AssetInfo &asset : activeAssets)
{
//TODO: LEAK! Free resource //TODO: LEAK! Free resource
if (asset.resourceAddress->resource.load() != nullptr) if (asset.resourceAddress->resource.load() != nullptr) {
{ void *resource = asset.resourceAddress->resource.exchange(nullptr, std::memory_order_acq_rel);
void* resource = asset.resourceAddress->resource.exchange(nullptr, std::memory_order_acq_rel);
//if (resource) //if (resource)
//Deallocate(resource); //Deallocate(resource);
} }
@ -275,7 +246,7 @@ export
} }
activeAssets.clear(); activeAssets.clear();
for (AssetHandle *&handle: assetsMapping | std::views::values) for (AssetHandle *& handle : assetsMapping | std::views::values)
Deallocate(handle); Deallocate(handle);
assetsMapping.clear(); assetsMapping.clear();
@ -300,58 +271,54 @@ export
std::vector<ee_assets::AssetShader*> shadersStorage; std::vector<ee_assets::AssetShader*> shadersStorage;
std::vector<ee_assets::AssetMaterial*> materialsStorage; std::vector<ee_assets::AssetMaterial*> materialsStorage;
void LoadCmd(AssetStreamCommand &command) void LoadCmd(AssetStreamCommand& command) {
{
LOG(INFO, "LOAD command: [%hs]", command.targetPath.generic_u8string().c_str()); LOG(INFO, "LOAD command: [%hs]", command.targetPath.generic_u8string().c_str());
/* TODO: process path to select FS */ /* TODO: process path to select FS */
/* TODO: select between async load and sync job task */ /* TODO: select between async load and sync job task */
//Async load of full file without mmap in one thread //Async load of full file without mmap in one thread
FileHandle &file = diskSystem->Open(command.targetPath, IFileSystem::FILE_OPEN_READ); FileHandle& file = diskSystem->Open(command.targetPath, IFileSystem::FILE_OPEN_READ);
diskSystem->ReadAsync(file, static_cast<std::uint32_t>(file.size), IFileSystem::FILE_READ_SEQUENTIAL); diskSystem->ReadAsync(file, static_cast<std::uint32_t>(file.size), IFileSystem::FILE_READ_SEQUENTIAL);
AssetHandle* handle = Allocate<AssetHandle>(); AssetHandle *handle = Allocate<AssetHandle>();
AssetInfo asset(nullptr); AssetInfo asset(nullptr);
asset.type = command.targetType; asset.type = command.targetType;
std::size_t assetPos = 0; std::size_t assetPos = 0;
if (freeAssetSlots.size() > 0) if (freeAssetSlots.size() > 0) {
{
assetPos = freeAssetSlots.back(); assetPos = freeAssetSlots.back();
Deallocate(activeAssets[assetPos].resourceAddress); Deallocate(activeAssets[assetPos].resourceAddress);
activeAssets[assetPos] = std::move(asset); activeAssets[assetPos] = std::move(asset);
freeAssetSlots.pop_back(); freeAssetSlots.pop_back();
} }
else else {
{
activeAssets.push_back(std::move(asset)); activeAssets.push_back(std::move(asset));
assetPos = activeAssets.size() - 1; assetPos = activeAssets.size() - 1;
} }
handle->slot = assetPos; handle->slot = assetPos;
auto assetPath = command.targetPath.generic_u8string(); auto assetPath = command.targetPath.generic_u8string();
std::uint32_t assetId = assetsIdMapping[command.targetPath] = std::uint32_t assetId = assetsIdMapping[command.targetPath] =
XXH32(assetPath.data(), assetPath.size(), ASSETS_HASH_SPACE); XXH32(assetPath.data(), assetPath.size(), ASSETS_HASH_SPACE);
handle->id = assetId; handle->id = assetId;
assetsMapping[assetId] = handle; assetsMapping[assetId] = handle;
AssetLoadingEntry loadingEntry { AssetLoadingEntry loadingEntry{
.handle = *handle, .handle = *handle,
.file = &file, .file = &file,
.fileOwner = diskSystem .fileOwner = diskSystem
}; };
loadingEntries.push_back(loadingEntry); loadingEntries.push_back(loadingEntry);
command.type = AssetStreamCommand::COMPLETED; command.type = AssetStreamCommand::COMPLETED;
} }
void FindCmd(AssetStreamCommand &command) void FindCmd(AssetStreamCommand& command) {
{
std::uint32_t id = command.targetId; std::uint32_t id = command.targetId;
if (id == AssetHandle::INVALID_ASSET_ID) if (id == AssetHandle::INVALID_ASSET_ID) {
{ std::unordered_map<std::filesystem::path, std::uint32_t>::iterator idMapping = assetsIdMapping.find(
std::unordered_map<std::filesystem::path, std::uint32_t>::iterator idMapping = assetsIdMapping.find(command.targetPath); command.targetPath);
if (idMapping == assetsIdMapping.end()) if (idMapping == assetsIdMapping.end())
return; return;
id = idMapping->second; id = idMapping->second;
@ -368,8 +335,7 @@ export
command.type = AssetStreamCommand::COMPLETED; command.type = AssetStreamCommand::COMPLETED;
} }
void GetCmd(AssetStreamCommand &command) void GetCmd(AssetStreamCommand& command) {
{
if (activeAssets.size() <= command.target.slot) if (activeAssets.size() <= command.target.slot)
return; return;
if (!activeAssets[command.target.slot].isReady) if (!activeAssets[command.target.slot].isReady)
@ -381,16 +347,16 @@ export
command.type = AssetStreamCommand::COMPLETED; command.type = AssetStreamCommand::COMPLETED;
} }
template<ee_assets::Asset T> void FinishLoadConstruct(AssetLoadingEntry &loaded, std::vector<T*> &storage) template <ee_assets::Asset T>
{ void FinishLoadConstruct(AssetLoadingEntry& loaded, std::vector<T*>& storage) {
T* resource = Allocate<T>(loaded.file->data, loaded.file->size); T *resource = Allocate<T>(loaded.file->data, loaded.file->size);
storage.push_back(resource); storage.push_back(resource);
Redirect(loaded.handle, storage.back()); Redirect(loaded.handle, storage.back());
} }
template<ee_assets::Asset T> void FinishLoadPlain(AssetLoadingEntry &loaded, std::vector<T*> &storage) template <ee_assets::Asset T>
{ void FinishLoadPlain(AssetLoadingEntry& loaded, std::vector<T*>& storage) {
T* resource = Allocate<T>(); T *resource = Allocate<T>();
if (loaded.file->size < sizeof(T)) if (loaded.file->size < sizeof(T))
LOG(CRITICAL, "File size is less than needed for asset of type: %d", typeid(T).name()); LOG(CRITICAL, "File size is less than needed for asset of type: %d", typeid(T).name());
std::memcpy(resource, loaded.file->data, sizeof(T)); std::memcpy(resource, loaded.file->data, sizeof(T));
@ -398,10 +364,9 @@ export
Redirect(loaded.handle, storage.back()); Redirect(loaded.handle, storage.back());
} }
template<ee_assets::Asset T> void ClearStorage(std::vector<T*> &storage) template <ee_assets::Asset T>
{ void ClearStorage(std::vector<T*>& storage) {
for (T* &resource : storage) for (T * & resource : storage) {
{
if (resource != nullptr) if (resource != nullptr)
Deallocate(resource); Deallocate(resource);
} }

View File

@ -7,10 +7,8 @@ import std;
export export
{ {
struct ClientCommand : public ee_utils::WorkerCommand struct ClientCommand : public ee_utils::WorkerCommand {
{ enum Type : std::uint8_t {
enum Type : std::uint8_t
{
NONE, NONE,
SEND, SEND,
@ -19,8 +17,7 @@ export
}; };
}; };
class Client final : public ee_utils::ThreadedWorker<ClientCommand, ClientCommand::COMPLETED> class Client final : public ee_utils::ThreadedWorker<ClientCommand, ClientCommand::COMPLETED> {
{
public: public:
Client(); Client();
~Client() override; ~Client() override;
@ -41,7 +38,7 @@ export
NetworkChannel *networkConnection = nullptr; NetworkChannel *networkConnection = nullptr;
AssetHandle save; AssetHandle save;
void SendCmd(ClientCommand &command); void SendCmd(ClientCommand& command);
void ViewModelSubject(ee_data::Subject subject); void ViewModelSubject(ee_data::Subject subject);
}; };

View File

@ -4,21 +4,14 @@ export module DataChannel;
export export
{ {
class IDataChannel class IDataChannel {
{
public: public:
// virtual void Request() = 0; // virtual void Request() = 0;
// virtual void Listen() = 0; // virtual void Listen() = 0;
// virtual void Mute() = 0; // virtual void Mute() = 0;
}; };
class NetworkChannel final : public IDataChannel class NetworkChannel final : public IDataChannel {};
{
}; class ThreadChannel final : public IDataChannel {};
class ThreadChannel final : public IDataChannel
{
};
} }

View File

@ -3,17 +3,16 @@ module;
#include <GLFW/glfw3.h> #include <GLFW/glfw3.h>
export module Engine; export module Engine;
export import Render; export import Render;
export import Input; export import Input;
export import AssetManager; export import AssetManager;
export import Client; export import Client;
import utils; import utils;
export export
{ {
class Engine class Engine {
{
public: public:
inline static GLFWwindow *window; inline static GLFWwindow *window;
inline static ee_engine::IInput *input; inline static ee_engine::IInput *input;
@ -21,13 +20,11 @@ export
inline static ee_engine::IRenderer *renderer; inline static ee_engine::IRenderer *renderer;
inline static Client *client; inline static Client *client;
static void Shutdown() static void Shutdown() {
{
if (input != nullptr) if (input != nullptr)
Deallocate(input); Deallocate(input);
if (renderer != nullptr) if (renderer != nullptr) {
{
renderer->Shutdown(); renderer->Shutdown();
Deallocate(renderer); Deallocate(renderer);
} }
@ -41,12 +38,10 @@ export
} }
template <ee_utils::IThreadedWorker T> template <ee_utils::IThreadedWorker T>
static void WaitThreadShutdown(T* &thread) static void WaitThreadShutdown(T * & thread) {
{ if (thread != nullptr) {
if (thread != nullptr)
{
thread->Shutdown(); thread->Shutdown();
while(thread->isRunning.load()) {} while (thread->isRunning.load()) {}
Deallocate(thread); Deallocate(thread);
} }
thread = nullptr; thread = nullptr;

View File

@ -15,17 +15,17 @@ export
std::uint8_t *data = nullptr; std::uint8_t *data = nullptr;
std::uint8_t *buffer = nullptr; std::uint8_t *buffer = nullptr;
#ifndef NDEBUG #ifndef NDEBUG
std::filesystem::path debugPath; std::filesystem::path debugPath;
#endif #endif
#ifdef _WIN32 #ifdef _WIN32
HANDLE win32Handle = INVALID_HANDLE_VALUE; HANDLE win32Handle = INVALID_HANDLE_VALUE;
OVERLAPPED overlapped; OVERLAPPED overlapped;
#endif #endif
#ifdef __linux__ #ifdef __linux__
#endif #endif
}; };
class IFileSystem { class IFileSystem {
@ -37,33 +37,32 @@ export
inline static constexpr std::uint32_t FILE_READ_SEQUENTIAL = 0; inline static constexpr std::uint32_t FILE_READ_SEQUENTIAL = 0;
inline static constexpr std::uint32_t FILE_READ_RANDOM_ACCESS = (1 << 0); inline static constexpr std::uint32_t FILE_READ_RANDOM_ACCESS = (1 << 0);
virtual FileHandle &Open(const std::filesystem::path &path, const std::uint32_t flags) = 0; virtual FileHandle& Open(const std::filesystem::path& path, const std::uint32_t flags) = 0;
virtual void ReadAsync(FileHandle &file, const std::uint32_t bufferSize, const std::uint32_t flags) = 0; virtual void ReadAsync(FileHandle& file, const std::uint32_t bufferSize, const std::uint32_t flags) = 0;
virtual bool PollReady(FileHandle &file) = 0; virtual bool PollReady(FileHandle& file) = 0;
virtual void Close(FileHandle &file) = 0; virtual void Close(FileHandle& file) = 0;
virtual ~IFileSystem(); virtual ~IFileSystem();
protected: protected:
std::vector<FileHandle *> activeFiles; std::vector<FileHandle*> activeFiles;
std::vector<FileHandle *> failedFiles; std::vector<FileHandle*> failedFiles;
std::vector<std::size_t> freeFileSlots; std::vector<std::size_t> freeFileSlots;
}; };
class NativeFileSystem final : public IFileSystem { class NativeFileSystem final : public IFileSystem {
public: public:
FileHandle &Open(const std::filesystem::path &path, const std::uint32_t flags) override; FileHandle& Open(const std::filesystem::path& path, const std::uint32_t flags) override;
void ReadAsync(FileHandle &file, const std::uint32_t bufferSize, std::uint32_t flags) override; void ReadAsync(FileHandle& file, const std::uint32_t bufferSize, std::uint32_t flags) override;
bool PollReady(FileHandle &file) override; bool PollReady(FileHandle& file) override;
void Close(FileHandle &file) override; void Close(FileHandle& file) override;
private: private:
}; };
} }

View File

@ -5,9 +5,9 @@ module;
export module GLFWInput; export module GLFWInput;
import Input; import Input;
export { export
class GLFWInput final : public ee_engine::IInput {
{ class GLFWInput final : public ee_engine::IInput {
public: public:
GLFWInput(ee_engine::InputHandlers handlers); GLFWInput(ee_engine::InputHandlers handlers);

View File

@ -5,20 +5,18 @@ module;
module Actions; module Actions;
import Engine; import Engine;
ee_engine::InputHandlers Actions::mappings { ee_engine::InputHandlers Actions::mappings{
.zooming = Zoom, .zooming = Zoom,
.mapScroll = MapScroll .mapScroll = MapScroll
}; };
void Actions::Zoom(float dx, float dy) void Actions::Zoom(float dx, float dy) {
{
ee_engine::CameraTransform cam = Engine::renderer->getCamera(); ee_engine::CameraTransform cam = Engine::renderer->getCamera();
cam.zoom *= pow(1.1f, -dy); cam.zoom *= pow(1.1f, -dy);
Engine::renderer->SetCamera(cam); Engine::renderer->SetCamera(cam);
} }
void Actions::MapScroll(float x, float y, float lastX, float lastY) void Actions::MapScroll(float x, float y, float lastX, float lastY) {
{
ee_engine::CameraTransform cam = Engine::renderer->getCamera(); ee_engine::CameraTransform cam = Engine::renderer->getCamera();
glm::vec2 pos = Engine::renderer->ScreenToWorld(x, y); glm::vec2 pos = Engine::renderer->ScreenToWorld(x, y);

View File

@ -3,67 +3,50 @@ import utils;
import views; import views;
import Engine; import Engine;
Client::Client() : ThreadedWorker(L"Client", 0) Client::Client() : ThreadedWorker(L"Client", 0) {
{
commandsMapping[ClientCommand::SEND] = std::bind_front(&Client::SendCmd, this); commandsMapping[ClientCommand::SEND] = std::bind_front(&Client::SendCmd, this);
} }
void Client::Init() void Client::Init() {
{ if (Engine::renderer == nullptr || !Engine::renderer->isReady()) {
if (Engine::renderer == nullptr || !Engine::renderer->isReady())
{
LOG(CRITICAL, "Renderer is not ready. Client cannot be created"); LOG(CRITICAL, "Renderer is not ready. Client cannot be created");
throw std::logic_error("Renderer is not ready"); throw std::logic_error("Renderer is not ready");
} }
// TEST // TEST
ee_assets::AssetSave &asset = Engine::assetManager->Get<ee_assets::AssetSave>(save); ee_assets::AssetSave& asset = Engine::assetManager->Get<ee_assets::AssetSave>(save);
ViewModelSubject(asset.content.subjects[0]); ViewModelSubject(asset.content.subjects[0]);
ViewModelSubject(asset.content.subjects[1]); ViewModelSubject(asset.content.subjects[1]);
} }
const IDataChannel* Client::GetConnection() const IDataChannel* Client::GetConnection() {
{
return networkConnection; return networkConnection;
} }
void Client::ConnectServer() void Client::ConnectServer() {
{
if (networkConnection != nullptr) if (networkConnection != nullptr)
Deallocate(networkConnection); Deallocate(networkConnection);
networkConnection = Allocate<NetworkChannel>(); networkConnection = Allocate<NetworkChannel>();
} }
void Client::LoadSave(const AssetHandle save) void Client::LoadSave(const AssetHandle save) {
{
this->save = save; this->save = save;
} }
void Client::Update() void Client::Update() {}
{
} void Client::Release() {}
void Client::Release()
{
}
void Client::SendCmd(ClientCommand &command)
{
void Client::SendCmd(ClientCommand& command) {
command.type = ClientCommand::COMPLETED; command.type = ClientCommand::COMPLETED;
} }
void Client::ViewModelSubject(ee_data::Subject subject) void Client::ViewModelSubject(ee_data::Subject subject) {
{ for (const std::uint32_t region : subject.regions) {
for (const std::uint32_t region : subject.regions) ee_engine::ProvinceSSBO vm{
{
ee_engine::ProvinceSSBO vm {
.regionId = region, .regionId = region,
.color = subject.color .color = subject.color
}; };
@ -77,9 +60,7 @@ void Client::ViewModelSubject(ee_data::Subject subject)
} }
Client::~Client() {
Client::~Client()
{
if (networkConnection != nullptr) if (networkConnection != nullptr)
Deallocate(networkConnection); Deallocate(networkConnection);
} }

View File

@ -7,19 +7,17 @@ import utils;
//TOO: REWORK WITH IOCP //TOO: REWORK WITH IOCP
IFileSystem::~IFileSystem() IFileSystem::~IFileSystem() {
{ for (FileHandle *handle : activeFiles)
for (FileHandle* handle : activeFiles)
Deallocate(handle); Deallocate(handle);
for (FileHandle* handle : failedFiles) for (FileHandle *handle : failedFiles)
Deallocate(handle); Deallocate(handle);
} }
#ifdef _WIN32 #ifdef _WIN32
FileHandle& NativeFileSystem::Open(const std::filesystem::path &path, const std::uint32_t flags) FileHandle& NativeFileSystem::Open(const std::filesystem::path& path, const std::uint32_t flags) {
{ FileHandle *result = Allocate<FileHandle>();
FileHandle* result = Allocate<FileHandle>();
#ifndef NDEBUG #ifndef NDEBUG
result->debugPath = path; result->debugPath = path;
@ -33,17 +31,16 @@ FileHandle& NativeFileSystem::Open(const std::filesystem::path &path, const std:
createFileMode |= GENERIC_WRITE; createFileMode |= GENERIC_WRITE;
HANDLE file = CreateFileW( HANDLE file = CreateFileW(
path.c_str(), path.c_str(),
createFileMode, createFileMode,
NULL, NULL,
NULL, NULL,
OPEN_EXISTING, OPEN_EXISTING,
FILE_FLAG_OVERLAPPED, FILE_FLAG_OVERLAPPED,
NULL NULL
); );
if (file == INVALID_HANDLE_VALUE) if (file == INVALID_HANDLE_VALUE) {
{
LOG(ERROR, "Failed to open file %s. Error: %d", path.c_str(), GetLastError()); LOG(ERROR, "Failed to open file %s. Error: %d", path.c_str(), GetLastError());
failedFiles.push_back(result); failedFiles.push_back(result);
return *result; return *result;
@ -54,15 +51,13 @@ FileHandle& NativeFileSystem::Open(const std::filesystem::path &path, const std:
if (result->size == INVALID_FILE_SIZE) if (result->size == INVALID_FILE_SIZE)
LOG(ERROR, "Failed to get size of file %s. Error: %d", path.c_str(), GetLastError()); LOG(ERROR, "Failed to get size of file %s. Error: %d", path.c_str(), GetLastError());
if (freeFileSlots.size() > 0) if (freeFileSlots.size() > 0) {
{
std::size_t pos = freeFileSlots.back(); std::size_t pos = freeFileSlots.back();
result->id = pos; result->id = pos;
activeFiles[pos] = result; activeFiles[pos] = result;
freeFileSlots.pop_back(); freeFileSlots.pop_back();
} }
else else {
{
result->id = activeFiles.size(); result->id = activeFiles.size();
activeFiles.push_back(result); activeFiles.push_back(result);
} }
@ -70,79 +65,70 @@ FileHandle& NativeFileSystem::Open(const std::filesystem::path &path, const std:
return *result; return *result;
} }
void NativeFileSystem::ReadAsync(FileHandle &file, const std::uint32_t bufferSize, const std::uint32_t flags) void NativeFileSystem::ReadAsync(FileHandle& file, const std::uint32_t bufferSize, const std::uint32_t flags) {
{
file.overlapped = { file.overlapped = {
.hEvent = CreateEvent(nullptr, TRUE, FALSE, nullptr) .hEvent = CreateEvent(nullptr, TRUE, FALSE, nullptr)
}; };
file.buffer = AllocateArray<std::uint8_t>(bufferSize); file.buffer = AllocateArray<std::uint8_t>(bufferSize);
file.bufferSize = bufferSize; file.bufferSize = bufferSize;
BOOL isSync = ReadFile( BOOL isSync = ReadFile(
file.win32Handle, file.win32Handle,
file.buffer, file.buffer,
bufferSize, bufferSize,
NULL, NULL,
&file.overlapped &file.overlapped
); );
if (isSync || GetLastError() != ERROR_IO_PENDING) if (isSync || GetLastError() != ERROR_IO_PENDING)
LOG(ERROR, "File reading is synchronious while asynchronious is awaited"); LOG(ERROR, "File reading is synchronious while asynchronious is awaited");
} }
bool NativeFileSystem::PollReady(FileHandle &file) bool NativeFileSystem::PollReady(FileHandle& file) {
{
DWORD status = WaitForSingleObject(file.overlapped.hEvent, 0); DWORD status = WaitForSingleObject(file.overlapped.hEvent, 0);
switch (status) switch (status) {
case WAIT_OBJECT_0:
{ {
case WAIT_OBJECT_0: if (file.size == file.bufferSize) {
{ file.data = file.buffer;
if (file.size == file.bufferSize) file.buffer = nullptr;
{ }
file.data = file.buffer; else {
file.buffer = nullptr; /* TODO: reserve size for data, shift and move */
}
else
{
/* TODO: reserve size for data, shift and move */
}
break;
} }
case WAIT_ABANDONED: break;
case WAIT_TIMEOUT: }
return false;
default: case WAIT_ABANDONED:
{ case WAIT_TIMEOUT:
LOG(CRITICAL, "Failed to get file status. Error: %d", GetLastError()); return false;
return false;
} default:
{
LOG(CRITICAL, "Failed to get file status. Error: %d", GetLastError());
return false;
}
} }
return true; return true;
} }
void NativeFileSystem::Close(FileHandle &file) void NativeFileSystem::Close(FileHandle& file) {
{
if (file.overlapped.hEvent) if (file.overlapped.hEvent)
CloseHandle(file.overlapped.hEvent); CloseHandle(file.overlapped.hEvent);
if (file.buffer != nullptr) if (file.buffer != nullptr) {
{
DeallocateArray(file.buffer); DeallocateArray(file.buffer);
file.buffer = nullptr; file.buffer = nullptr;
} }
if (file.data != nullptr) if (file.data != nullptr) {
{
DeallocateArray(file.data); DeallocateArray(file.data);
file.data = nullptr; file.data = nullptr;
} }
if (file.win32Handle != INVALID_HANDLE_VALUE) if (file.win32Handle != INVALID_HANDLE_VALUE) {
{
CloseHandle(file.win32Handle); CloseHandle(file.win32Handle);
file.win32Handle = INVALID_HANDLE_VALUE; file.win32Handle = INVALID_HANDLE_VALUE;
} }
@ -154,5 +140,4 @@ void NativeFileSystem::Close(FileHandle &file)
#ifdef __linux__ #ifdef __linux__
#endif #endif

View File

@ -9,8 +9,7 @@ module GLFWInput;
import Engine; import Engine;
import utils; import utils;
GLFWInput::GLFWInput(ee_engine::InputHandlers handlers) : ee_engine::IInput(handlers) GLFWInput::GLFWInput(ee_engine::InputHandlers handlers) : ee_engine::IInput(handlers) {
{
glfwSetWindowUserPointer(Engine::window, this); glfwSetWindowUserPointer(Engine::window, this);
glfwSetScrollCallback(Engine::window, [](GLFWwindow *window, double dx, double dy) { glfwSetScrollCallback(Engine::window, [](GLFWwindow *window, double dx, double dy) {
GLFW_CALLBACK(zooming, static_cast<float>(dx), static_cast<float>(dy)); GLFW_CALLBACK(zooming, static_cast<float>(dx), static_cast<float>(dy));
@ -19,8 +18,7 @@ GLFWInput::GLFWInput(ee_engine::InputHandlers handlers) : ee_engine::IInput(hand
LOG(INFO, "Input mappings initialized"); LOG(INFO, "Input mappings initialized");
} }
void GLFWInput::Poll() void GLFWInput::Poll() {
{
double mouseX, mouseY; double mouseX, mouseY;
glfwGetCursorPos(Engine::window, &mouseX, &mouseY); glfwGetCursorPos(Engine::window, &mouseX, &mouseY);
this->mouseX = static_cast<float>(mouseX); this->mouseX = static_cast<float>(mouseX);
@ -38,22 +36,20 @@ void GLFWInput::Poll()
lastMouseY = this->mouseY; lastMouseY = this->mouseY;
} }
void GLFWInput::OnLeftMouseButton(int state){} void GLFWInput::OnLeftMouseButton(int state) {}
void GLFWInput::OnRightMouseButton(int state){} void GLFWInput::OnRightMouseButton(int state) {}
void GLFWInput::OnMiddleMouseButton(int state) void GLFWInput::OnMiddleMouseButton(int state) {
{ switch (state) {
switch(state) case GLFW_PRESS:
{ {
case GLFW_PRESS: handlers.mapScroll(mouseX, mouseY, lastMouseX, lastMouseY);
{ break;
handlers.mapScroll(mouseX, mouseY, lastMouseX, lastMouseY); }
break;
}
case GLFW_RELEASE: case GLFW_RELEASE:
{ {
break; break;
} }
} }
} }

View File

@ -9,8 +9,7 @@ import MagnumRender;
import GLFWInput; import GLFWInput;
import std; import std;
int main(int argc, char **argv) int main(int argc, char **argv) {
{
// Setup P7 logger // Setup P7 logger
Logger::Init(P7_SINK P7_LOGS_PATH); Logger::Init(P7_SINK P7_LOGS_PATH);
Logger::RegisterThread(L"Main"); Logger::RegisterThread(L"Main");
@ -48,23 +47,25 @@ int main(int argc, char **argv)
// Setup renderer TODO: builder // Setup renderer TODO: builder
Engine::renderer = reinterpret_cast<ee_engine::IRenderer*>(Allocate<ee_magnum::MagnumRenderer>(window)); Engine::renderer = reinterpret_cast<ee_engine::IRenderer*>(Allocate<ee_magnum::MagnumRenderer>(window));
ee_assets::AssetMapMesh &regions = Engine::assetManager->FindOnce<ee_assets::AssetMapMesh>("assets/map/ET.map"); ee_assets::AssetMapMesh& regions = Engine::assetManager->FindOnce<ee_assets::AssetMapMesh>("assets/map/ET.map");
Engine::renderer->RegisterMapMesh(&regions.content); Engine::renderer->RegisterMapMesh(&regions.content);
//TODO: ShaderRefs builder from set of AssetMaterial //TODO: ShaderRefs builder from set of AssetMaterial
ee_assets::AssetMaterial &provincesMaterial = ee_assets::AssetMaterial& provincesMaterial =
Engine::assetManager->FindOnce<ee_assets::AssetMaterial>("assets/materials/provinces.mat"); Engine::assetManager->FindOnce<ee_assets::AssetMaterial>("assets/materials/provinces.mat");
ee_assets::AssetShader &vertProv = Engine::assetManager->FindOnce<ee_assets::AssetShader>(provincesMaterial.vertexShaderAssetID); ee_assets::AssetShader& vertProv = Engine::assetManager->FindOnce<ee_assets::AssetShader>(
ee_assets::AssetShader &fragProv = Engine::assetManager->FindOnce<ee_assets::AssetShader>(provincesMaterial.fragmentShaderAssetID); provincesMaterial.vertexShaderAssetID);
ee_assets::AssetShader& fragProv = Engine::assetManager->FindOnce<ee_assets::AssetShader>(
provincesMaterial.fragmentShaderAssetID);
Engine::renderer->RegisterMaterials({ Engine::renderer->RegisterMaterials({
.vertProvinces = &vertProv, .vertProvinces = &vertProv,
.fragProvinces = &fragProv .fragProvinces = &fragProv
}); });
Engine::renderer->Init(); Engine::renderer->Init();
Engine::renderer->SetCamera({ Engine::renderer->SetCamera({
//.position = {1000.0f, 1000.0f}, //.position = {1000.0f, 1000.0f},
.zoom = 2000.0f .zoom = 2000.0f
}); });
glfwSetFramebufferSizeCallback(window, [](GLFWwindow *window, int width, int height) { glfwSetFramebufferSizeCallback(window, [](GLFWwindow *window, int width, int height) {
@ -73,15 +74,14 @@ int main(int argc, char **argv)
// Setup Client TODO: builder // Setup Client TODO: builder
Engine::client = Allocate<Client>(); Engine::client = Allocate<Client>();
// AssetHandle save = Engine::assetManager->Find("assets/scenarios/empires.save"); // AssetHandle save = Engine::assetManager->Find("assets/scenarios/empires.save");
// Engine::client->LoadSave(save); // Engine::client->LoadSave(save);
// Engine::client->Init(); // Engine::client->Init();
Engine::client->Start(); Engine::client->Start();
// Game loop // Game loop
ee_engine::RendererCommand renderCmdBuffer; ee_engine::RendererCommand renderCmdBuffer;
while(!glfwWindowShouldClose(window)) while (!glfwWindowShouldClose(window)) {
{
Engine::renderer->ProcessQueue(renderCmdBuffer); Engine::renderer->ProcessQueue(renderCmdBuffer);
Engine::renderer->Draw(); Engine::renderer->Draw();

View File

@ -12,29 +12,26 @@ import std;
using namespace Magnum; using namespace Magnum;
export namespace ee_magnum export namespace ee_magnum {
{ class BaseMaterial : public GL::AbstractShaderProgram {
class BaseMaterial : public GL::AbstractShaderProgram
{
public: public:
inline static constexpr std::int32_t CAMERA_BINDING = 1; inline static constexpr std::int32_t CAMERA_BINDING = 1;
//TODO: push constant //TODO: push constant
inline static constexpr std::int32_t TRANSFORM_BINDING = 2; inline static constexpr std::int32_t TRANSFORM_BINDING = 2;
void setModel(const Matrix4 &model); void setModel(const Matrix4& model);
void setViewProjection(const Matrix4 &vewProjection); void setViewProjection(const Matrix4& vewProjection);
protected: protected:
explicit BaseMaterial(const std::string &vertSrc, const std::string &fragSrc); explicit BaseMaterial(const std::string& vertSrc, const std::string& fragSrc);
}; };
class ProvinceMaterial final : public BaseMaterial class ProvinceMaterial final : public BaseMaterial {
{
public: public:
inline static constexpr std::int32_t PROVINCES_DATA_BINDING = 0; inline static constexpr std::int32_t PROVINCES_DATA_BINDING = 0;
inline static constexpr std::int32_t PROVINCES_ID_BINDING = 3; inline static constexpr std::int32_t PROVINCES_ID_BINDING = 3;
explicit ProvinceMaterial(const std::string &vertSrc, const std::string &fragSrc); explicit ProvinceMaterial(const std::string& vertSrc, const std::string& fragSrc);
void setId(const std::uint32_t id); void setId(const std::uint32_t id);
}; };

View File

@ -8,17 +8,15 @@ module;
#include <GLFW/glfw3.h> #include <GLFW/glfw3.h>
export module MagnumRender; export module MagnumRender;
import :Materials; import :Materials;
import views; import views;
import Render; import Render;
import std; import std;
using namespace Magnum; using namespace Magnum;
export namespace ee_magnum export namespace ee_magnum {
{ class MagnumRenderer final : public ee_engine::IRenderer {
class MagnumRenderer final : public ee_engine::IRenderer
{
public: public:
MagnumRenderer(GLFWwindow *window); MagnumRenderer(GLFWwindow *window);
~MagnumRenderer(); ~MagnumRenderer();
@ -33,7 +31,8 @@ export namespace ee_magnum
void ApplyCamera() override; void ApplyCamera() override;
virtual void UpdateProvinces(const std::size_t index, const std::vector<ee_engine::ProvinceSSBO> &data) override; virtual void
UpdateProvinces(const std::size_t index, const std::vector<ee_engine::ProvinceSSBO>& data) override;
private: private:
Platform::GLContext context; Platform::GLContext context;

View File

@ -9,13 +9,12 @@ module;
module MagnumRender; module MagnumRender;
import :Materials; import :Materials;
import utils; import utils;
ee_magnum::BaseMaterial::BaseMaterial(const std::string &vertSrc, const std::string &fragSrc) ee_magnum::BaseMaterial::BaseMaterial(const std::string& vertSrc, const std::string& fragSrc) {
{ GL::Shader vert{GL::Version::GL430, GL::Shader::Type::Vertex};
GL::Shader vert {GL::Version::GL430, GL::Shader::Type::Vertex}; GL::Shader frag{GL::Version::GL430, GL::Shader::Type::Fragment};
GL::Shader frag {GL::Version::GL430, GL::Shader::Type::Fragment};
vert.addSource(vertSrc); vert.addSource(vertSrc);
frag.addSource(fragSrc); frag.addSource(fragSrc);
@ -31,22 +30,17 @@ ee_magnum::BaseMaterial::BaseMaterial(const std::string &vertSrc, const std::str
link(); link();
} }
void ee_magnum::BaseMaterial::setModel(const Matrix4 &m) void ee_magnum::BaseMaterial::setModel(const Matrix4& m) {
{
setUniform(TRANSFORM_BINDING, m); setUniform(TRANSFORM_BINDING, m);
} }
void ee_magnum::BaseMaterial::setViewProjection(const Matrix4 &vp) void ee_magnum::BaseMaterial::setViewProjection(const Matrix4& vp) {
{
setUniform(CAMERA_BINDING, vp); setUniform(CAMERA_BINDING, vp);
} }
ee_magnum::ProvinceMaterial::ProvinceMaterial(const std::string &vertSrc, const std::string &fragSrc): BaseMaterial(vertSrc, fragSrc) ee_magnum::ProvinceMaterial::ProvinceMaterial(const std::string& vertSrc, const std::string& fragSrc) : BaseMaterial(
{ vertSrc, fragSrc) {}
} void ee_magnum::ProvinceMaterial::setId(const uint32_t id) {
void ee_magnum::ProvinceMaterial::setId(const uint32_t id)
{
setUniform(PROVINCES_ID_BINDING, id); setUniform(PROVINCES_ID_BINDING, id);
} }

View File

@ -18,15 +18,13 @@ import utils;
using namespace Math::Literals; using namespace Math::Literals;
ee_magnum::MagnumRenderer::MagnumRenderer(GLFWwindow *window) : IRenderer(window) ee_magnum::MagnumRenderer::MagnumRenderer(GLFWwindow *window) : IRenderer(window) {
{
ValidateSupport(); ValidateSupport();
LOG(INFO, "Renderer created"); LOG(INFO, "Renderer created");
} }
void ee_magnum::MagnumRenderer::Init() void ee_magnum::MagnumRenderer::Init() {
{
LOG(INFO, "GLSL version: %d", GL::Context::current().version()); LOG(INFO, "GLSL version: %d", GL::Context::current().version());
LoadShaders(); LoadShaders();
@ -36,76 +34,62 @@ void ee_magnum::MagnumRenderer::Init()
LOG(INFO, "Renderer initialized"); LOG(INFO, "Renderer initialized");
} }
void ee_magnum::MagnumRenderer::Clear() void ee_magnum::MagnumRenderer::Clear() {
{
GL::defaultFramebuffer.clear(GL::FramebufferClear::Color); GL::defaultFramebuffer.clear(GL::FramebufferClear::Color);
} }
void ee_magnum::MagnumRenderer::DrawMap() void ee_magnum::MagnumRenderer::DrawMap() {
{
ApplyCamera(); ApplyCamera();
for (std::uint32_t i = 0; i < provinceMeshes.size(); i++) for (std::uint32_t i = 0; i < provinceMeshes.size(); i++) {
{
provinceMaterial->setId(i); provinceMaterial->setId(i);
provinceMaterial->draw(provinceMeshes[i]); provinceMaterial->draw(provinceMeshes[i]);
} }
} }
void ee_magnum::MagnumRenderer::DrawUI() void ee_magnum::MagnumRenderer::DrawUI() {}
{
} void ee_magnum::MagnumRenderer::ValidateSupport() {}
void ee_magnum::MagnumRenderer::ValidateSupport() void ee_magnum::MagnumRenderer::ApplyCamera() {
{ Matrix4 viewProjection{Magnum::NoInit};
}
void ee_magnum::MagnumRenderer::ApplyCamera()
{
Matrix4 viewProjection {Magnum::NoInit};
std::memcpy(viewProjection.data(), glm::value_ptr(this->viewProjection), sizeof(float) * 16); std::memcpy(viewProjection.data(), glm::value_ptr(this->viewProjection), sizeof(float) * 16);
provinceMaterial->setViewProjection(viewProjection); provinceMaterial->setViewProjection(viewProjection);
} }
void ee_magnum::MagnumRenderer::LoadShaders() void ee_magnum::MagnumRenderer::LoadShaders() {
{
provinceMaterial = Allocate<ProvinceMaterial>(std::string( provinceMaterial = Allocate<ProvinceMaterial>(std::string(
reinterpret_cast<const char*>(shaders.vertProvinces->content), reinterpret_cast<const char*>(shaders.vertProvinces->content),
shaders.vertProvinces->size shaders.vertProvinces->size
) + '\0', std::string( ) + '\0', std::string(
reinterpret_cast<const char*>(shaders.fragProvinces->content), reinterpret_cast<const char*>(shaders.fragProvinces->content),
shaders.fragProvinces->size shaders.fragProvinces->size
)) + '\0'; )) + '\0';
LOG(INFO, "Shaders loaded"); LOG(INFO, "Shaders loaded");
} }
void ee_magnum::MagnumRenderer::LoadProvinces() void ee_magnum::MagnumRenderer::LoadProvinces() {
{
std::vector<ee_engine::ProvinceSSBO> provincesData; std::vector<ee_engine::ProvinceSSBO> provincesData;
std::size_t regionIndex = 0; std::size_t regionIndex = 0;
for (auto& [region, provs]: mapMesh->regions) for (auto& [region, provs] : mapMesh->regions) {
{ for (ee_engine::MapMesh::Province& province : provs) {
for (ee_engine::MapMesh::Province &province: provs)
{
GL::Mesh regionMesh; GL::Mesh regionMesh;
Containers::ArrayView provinceVertices(province.vertices.data(), province.vertices.size()); Containers::ArrayView provinceVertices(province.vertices.data(), province.vertices.size());
Containers::ArrayView provinceIndices(province.indices.data(), province.indices.size()); Containers::ArrayView provinceIndices(province.indices.data(), province.indices.size());
regionMesh.setPrimitive(GL::MeshPrimitive::Triangles) regionMesh.setPrimitive(GL::MeshPrimitive::Triangles)
.setCount(static_cast<Magnum::Int>(province.indices.size())) .setCount(static_cast<Magnum::Int>(province.indices.size()))
.addVertexBuffer(GL::Buffer{provinceVertices}, 0, GL::Attribute<0, Magnum::Vector2>{}) .addVertexBuffer(GL::Buffer{provinceVertices}, 0, GL::Attribute<0, Magnum::Vector2>{})
.setIndexBuffer(GL::Buffer{provinceIndices}, 0, GL::MeshIndexType::UnsignedShort); .setIndexBuffer(GL::Buffer{provinceIndices}, 0, GL::MeshIndexType::UnsignedShort);
provinceMeshes.push_back(std::move(regionMesh)); provinceMeshes.push_back(std::move(regionMesh));
ee_engine::ProvinceSSBO data { ee_engine::ProvinceSSBO data{
.regionId = region, .regionId = region,
.color = 0xFFFFFF .color = 0xFFFFFF
}; };
provincesData.push_back(data); provincesData.push_back(data);
@ -121,17 +105,15 @@ void ee_magnum::MagnumRenderer::LoadProvinces()
Containers::ArrayView provincesDataView(provincesData.data(), provincesData.size()); Containers::ArrayView provincesDataView(provincesData.data(), provincesData.size());
provinceSSBO.setData(provincesDataView, GL::BufferUsage::DynamicDraw); provinceSSBO.setData(provincesDataView, GL::BufferUsage::DynamicDraw);
provinceSSBO.bind(GL::Buffer::Target::ShaderStorage, ProvinceMaterial::PROVINCES_DATA_BINDING); provinceSSBO.bind(GL::Buffer::Target::ShaderStorage, ProvinceMaterial::PROVINCES_DATA_BINDING);
} }
void ee_magnum::MagnumRenderer::UpdateProvinces(const std::size_t index, const std::vector<ee_engine::ProvinceSSBO> &data) void ee_magnum::MagnumRenderer::UpdateProvinces(const std::size_t index,
{ const std::vector<ee_engine::ProvinceSSBO>& data) {
Containers::ArrayView provincesData(data.data(), data.size()); Containers::ArrayView provincesData(data.data(), data.size());
provinceSSBO.setSubData(index, provincesData); provinceSSBO.setSubData(index, provincesData);
} }
void ee_magnum::MagnumRenderer::Shutdown() void ee_magnum::MagnumRenderer::Shutdown() {
{
provinceMeshes.clear(); provinceMeshes.clear();
provinceSSBO = GL::Buffer{NoCreate}; provinceSSBO = GL::Buffer{NoCreate};
if (provinceMaterial != nullptr) if (provinceMaterial != nullptr)
@ -139,7 +121,4 @@ void ee_magnum::MagnumRenderer::Shutdown()
provinceMaterial = nullptr; provinceMaterial = nullptr;
} }
ee_magnum::MagnumRenderer::~MagnumRenderer() ee_magnum::MagnumRenderer::~MagnumRenderer() {}
{
}

View File

@ -1,24 +1,25 @@
export module utils:allocator; export module utils:allocator;
import std; import std;
export { export
template<typename T, typename... Args> T* Allocate(Args&&... args) {
{ template <typename T, typename... Args>
T* Allocate(Args&&... args) {
return new T(std::forward<Args>(args)...); return new T(std::forward<Args>(args)...);
} }
template<typename T> void Deallocate(T* obj) template <typename T>
{ void Deallocate(T *obj) {
delete obj; delete obj;
} }
template<typename T> T* AllocateArray(std::size_t size) template <typename T>
{ T* AllocateArray(std::size_t size) {
return new T[size]; return new T[size];
} }
template<typename T> void DeallocateArray(T* obj) template <typename T>
{ void DeallocateArray(T *obj) {
delete[] obj; delete[] obj;
} }
} }

View File

@ -1,8 +1,7 @@
export module utils:buffers; export module utils:buffers;
import std; import std;
export namespace ee_utils export namespace ee_utils {
{ bool readNext(void *dst, std::uint8_t * & srcPointer, std::size_t& srcLeftoverSize, const std::size_t readSize);
bool readNext(void* dst, std::uint8_t* &srcPointer, std::size_t &srcLeftoverSize, const std::size_t readSize); bool writeNext(std::uint8_t * & dstPointer, void *src, std::size_t& dstLeftoverSize, const std::size_t writeSize);
bool writeNext(std::uint8_t* &dstPointer, void* src, std::size_t &dstLeftoverSize, const std::size_t writeSize);
} }

View File

@ -5,8 +5,7 @@ module;
export module utils:lockfree; export module utils:lockfree;
export namespace boost export namespace boost {
{
using lockfree::capacity; using lockfree::capacity;
using lockfree::queue; using lockfree::queue;

View File

@ -7,29 +7,24 @@ module;
export module utils:logger; export module utils:logger;
import std; import std;
namespace logger namespace logger {
{
template <std::size_t length> template <std::size_t length>
struct wstring struct wstring {
{
wchar_t content[length]; wchar_t content[length];
constexpr operator const wchar_t*() const {return content;} constexpr operator const wchar_t*() const { return content; }
explicit constexpr wstring(const char (&str)[length]) : content{} explicit constexpr wstring(const char (&str)[length]) : content{} {
{
for (std::size_t i = 0; i < length; i++) for (std::size_t i = 0; i < length; i++)
content[i] = static_cast<wchar_t>(str[i]); content[i] = static_cast<wchar_t>(str[i]);
} }
}; };
template <std::size_t length> template <std::size_t length>
constexpr wstring<length> TM(const char (&str)[length]) constexpr wstring<length> TM(const char (&str)[length]) {
{
return wstring<length>(str); return wstring<length>(str);
} }
enum LogLevel : std::uint8_t enum LogLevel : std::uint8_t {
{
TRACE, TRACE,
DEBUG, DEBUG,
INFO, INFO,
@ -41,15 +36,13 @@ namespace logger
class Logger; class Logger;
template <typename... Args> template <typename... Args>
struct LOG_WCHAR struct LOG_WCHAR {
{
LOG_WCHAR( LOG_WCHAR(
LogLevel level, LogLevel level,
const wchar_t* format, const wchar_t *format,
Args&&... args, Args&&... args,
const std::source_location &location = std::source_location::current() const std::source_location& location = std::source_location::current()
) ) {
{
Logger::trace->Trace( Logger::trace->Trace(
0, 0,
static_cast<eP7Trace_Level>(level), static_cast<eP7Trace_Level>(level),
@ -65,15 +58,13 @@ namespace logger
// Notice: logging char string supports only ASCII, use LOG_WCHAR with wchar string for UTF-8 // Notice: logging char string supports only ASCII, use LOG_WCHAR with wchar string for UTF-8
template <std::size_t length, typename... Args> template <std::size_t length, typename... Args>
struct LOG struct LOG {
{
LOG( LOG(
LogLevel level, LogLevel level,
const char (&format)[length], const char (&format)[length],
Args&&... args, Args&&... args,
const std::source_location &location = std::source_location::current() const std::source_location& location = std::source_location::current()
) ) {
{
Logger::trace->Trace( Logger::trace->Trace(
0, 0,
static_cast<eP7Trace_Level>(level), static_cast<eP7Trace_Level>(level),
@ -87,18 +78,17 @@ namespace logger
} }
}; };
template <typename... Args> LOG_WCHAR(LogLevel, const wchar_t*, Args&&...) -> LOG_WCHAR<Args...>; template <typename... Args>
template <std::size_t length, typename... Args> LOG(LogLevel, const char (&)[length], Args&&...) -> LOG<length, Args...>; LOG_WCHAR(LogLevel, const wchar_t *, Args&&...) -> LOG_WCHAR<Args...>;
template <std::size_t length, typename... Args>
LOG(LogLevel, const char (&)[length], Args&&...) -> LOG<length, Args...>;
class Logger class Logger {
{
public: public:
Logger() = delete; Logger() = delete;
static void Init(const wchar_t *options) static void Init(const wchar_t *options) {
{ if (isReady) {
if (isReady)
{
LOG_WCHAR(WARNING, L"Logger already initialized."); LOG_WCHAR(WARNING, L"Logger already initialized.");
return; return;
} }
@ -110,18 +100,16 @@ namespace logger
isReady = true; isReady = true;
} }
static void Release() static void Release() {
{
trace->Release(); trace->Release();
client->Release(); client->Release();
} }
static void RegisterThread(const wchar_t *name) static void RegisterThread(const wchar_t *name) {
{
trace->Register_Thread(name, 0); trace->Register_Thread(name, 0);
} }
static void UnregisterThread()
{ static void UnregisterThread() {
trace->Unregister_Thread(0); trace->Unregister_Thread(0);
} }
@ -131,10 +119,11 @@ namespace logger
inline static bool isReady = false; inline static bool isReady = false;
template <typename... Args> friend struct LOG_WCHAR; template <typename... Args>
template <std::size_t length, typename... Args> friend struct LOG; friend struct LOG_WCHAR;
template <std::size_t length, typename... Args>
friend struct LOG;
}; };
} }
export using logger::Logger; export using logger::Logger;

View File

@ -1,68 +1,58 @@
export module utils:worker; export module utils:worker;
import :lockfree; import :lockfree;
import :logger; import :logger;
import std; import std;
export namespace ee_utils export namespace ee_utils {
{ struct WorkerCommand {
struct WorkerCommand
{
std::uint8_t type = 0; std::uint8_t type = 0;
}; };
template <typename T> concept IWorkerCommand = std::is_base_of_v<WorkerCommand, T>; template <typename T> concept IWorkerCommand = std::is_base_of_v<WorkerCommand, T>;
template <IWorkerCommand TCommand, std::size_t MaxCmdTypeId, bool IdleDetection = false> template <IWorkerCommand TCommand, std::size_t MaxCmdTypeId, bool IdleDetection = false>
class Worker class Worker {
{
public: public:
void Request(const TCommand &command) void Request(const TCommand& command) {
{
commands.push(command); //TODO: filled queue case commands.push(command); //TODO: filled queue case
} }
void Request(const std::uint8_t type) void Request(const std::uint8_t type) {
{ commands.push(TCommand{.type = type}); //TODO: filled queue case
commands.push(TCommand {.type = type}); //TODO: filled queue case
} }
void ProcessQueue(TCommand &buffer) requires !IdleDetection void ProcessQueue(TCommand& buffer) requires !IdleDetection {
{ while (this->commands.pop(buffer)) {
while (this->commands.pop(buffer))
{
ProcessCommand(buffer); ProcessCommand(buffer);
} }
} }
std::uint32_t ProcessQueue(TCommand &buffer) requires IdleDetection std::uint32_t ProcessQueue(TCommand& buffer) requires IdleDetection {
{
thread_local std::uint32_t idleCounter = 0; thread_local std::uint32_t idleCounter = 0;
if (!this->commands.pop(buffer)) if (!this->commands.pop(buffer)) {
{
idleCounter++; idleCounter++;
return idleCounter; return idleCounter;
} }
idleCounter = 0; idleCounter = 0;
do do {
{
ProcessCommand(buffer); ProcessCommand(buffer);
} while (this->commands.pop(buffer)); }
while (this->commands.pop(buffer));
return 0; return 0;
} }
protected: protected:
// TODO: replace std::function with more optimized ref // TODO: replace std::function with more optimized ref
std::array<std::function<void(TCommand &command)>, MaxCmdTypeId + 1> commandsMapping; std::array<std::function<void(TCommand& command)>, MaxCmdTypeId + 1> commandsMapping;
// TODO: maybe I should use lockfree::queue ? Otherwise make consumer thread explicit for safety // TODO: maybe I should use lockfree::queue ? Otherwise make consumer thread explicit for safety
boost::lockfree::spsc_queue<TCommand, boost::lockfree::capacity<512>> commands; boost::lockfree::spsc_queue<TCommand, boost::lockfree::capacity<512>> commands;
Worker() {}; Worker() {};
void ProcessCommand(TCommand &command) void ProcessCommand(TCommand& command) {
{ if (command.type > MaxCmdTypeId || !commandsMapping[command.type]) {
if (command.type > MaxCmdTypeId || !commandsMapping[command.type])
{
LOG(WARNING, "Unhandled command. Type id: %d", command.type); LOG(WARNING, "Unhandled command. Type id: %d", command.type);
command.type = MaxCmdTypeId; command.type = MaxCmdTypeId;
return; return;
@ -78,10 +68,8 @@ export namespace ee_utils
virtual ~ThreadedWorkerBase() {} virtual ~ThreadedWorkerBase() {}
void Start() void Start() {
{ if (isRunning.load()) {
if (isRunning.load())
{
LOG(CRITICAL, "Thread can be started only once before stop"); LOG(CRITICAL, "Thread can be started only once before stop");
throw std::logic_error("Thread can be started only once before stop"); throw std::logic_error("Thread can be started only once before stop");
} }
@ -93,8 +81,7 @@ export namespace ee_utils
}); });
} }
void Shutdown() void Shutdown() {
{
if (isRunning.load()) if (isRunning.load())
thread.request_stop(); thread.request_stop();
else LOG(WARNING, "Tried to shutdown stopped thread"); else LOG(WARNING, "Tried to shutdown stopped thread");
@ -106,28 +93,27 @@ export namespace ee_utils
virtual void Threading() = 0; virtual void Threading() = 0;
}; };
template<typename T> concept IThreadedWorker = std::is_base_of_v<ThreadedWorkerBase, T>;
enum class IdleBackoffMode : std::uint8_t template <typename T> concept IThreadedWorker = std::is_base_of_v<ThreadedWorkerBase, T>;
{
enum class IdleBackoffMode : std::uint8_t {
DISABLED, DISABLED,
YIELD YIELD
}; };
template <IWorkerCommand TCommand, std::size_t MaxCmdType, IdleBackoffMode IdleBackoffMode = IdleBackoffMode::DISABLED> template <IWorkerCommand TCommand, std::size_t MaxCmdType, IdleBackoffMode IdleBackoffMode =
class ThreadedWorker : public Worker<TCommand, MaxCmdType, static_cast<bool>(IdleBackoffMode)>, public ThreadedWorkerBase IdleBackoffMode::DISABLED>
{ class ThreadedWorker : public Worker<TCommand, MaxCmdType, static_cast<bool>(IdleBackoffMode)>,
public ThreadedWorkerBase {
protected: protected:
const wchar_t *threadName; const wchar_t *threadName;
explicit ThreadedWorker(const wchar_t *threadName, std::uint32_t yieldIdleTime = 0) explicit ThreadedWorker(const wchar_t *threadName, std::uint32_t yieldIdleTime = 0) {
{
this->threadName = threadName; this->threadName = threadName;
this->yieldIdleTime = yieldIdleTime; this->yieldIdleTime = yieldIdleTime;
} }
void Threading() void Threading() {
{
Logger::RegisterThread(threadName); Logger::RegisterThread(threadName);
LOG(INFO, "Thread started"); LOG(INFO, "Thread started");
@ -136,17 +122,13 @@ export namespace ee_utils
ReleaseStop(); ReleaseStop();
} }
void Loop() void Loop() {
{
TCommand commandBuffer{}; TCommand commandBuffer{};
while (!stoken->stop_requested()) while (!stoken->stop_requested()) {
{ if constexpr (IdleBackoffMode == IdleBackoffMode::DISABLED) {
if constexpr (IdleBackoffMode == IdleBackoffMode::DISABLED)
{
this->ProcessQueue(commandBuffer); this->ProcessQueue(commandBuffer);
} }
else else {
{
const std::uint32_t idleCounter = this->ProcessQueue(commandBuffer); const std::uint32_t idleCounter = this->ProcessQueue(commandBuffer);
if (idleCounter > yieldIdleTime) if (idleCounter > yieldIdleTime)
@ -163,8 +145,7 @@ export namespace ee_utils
private: private:
std::uint32_t yieldIdleTime; std::uint32_t yieldIdleTime;
void ReleaseStop() void ReleaseStop() {
{
Release(); Release();
LOG(INFO, "Thread is released"); LOG(INFO, "Thread is released");
Logger::UnregisterThread(); Logger::UnregisterThread();

View File

@ -1,10 +1,9 @@
module utils; module utils;
import :buffers; import :buffers;
bool ee_utils::readNext(void* dst, std::uint8_t* &srcPointer, std::size_t &srcLeftoverSize, const std::size_t readSize) bool ee_utils::readNext(void *dst, std::uint8_t * & srcPointer, std::size_t& srcLeftoverSize,
{ const std::size_t readSize) {
if (srcLeftoverSize >= readSize) if (srcLeftoverSize >= readSize) {
{
srcLeftoverSize -= readSize; srcLeftoverSize -= readSize;
std::memcpy(dst, srcPointer, readSize); std::memcpy(dst, srcPointer, readSize);
srcPointer += readSize; srcPointer += readSize;
@ -15,10 +14,9 @@ bool ee_utils::readNext(void* dst, std::uint8_t* &srcPointer, std::size_t &srcLe
return false; return false;
} }
bool ee_utils::writeNext(std::uint8_t* &dstPointer, void* src, std::size_t &dstLeftoverSize, const std::size_t writeSize) bool ee_utils::writeNext(std::uint8_t * & dstPointer, void *src, std::size_t& dstLeftoverSize,
{ const std::size_t writeSize) {
if (dstLeftoverSize >= writeSize) if (dstLeftoverSize >= writeSize) {
{
dstLeftoverSize -= writeSize; dstLeftoverSize -= writeSize;
std::memcpy(dstPointer, src, writeSize); std::memcpy(dstPointer, src, writeSize);
dstPointer += writeSize; dstPointer += writeSize;