Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
cpp-project
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
David Maul
cpp-project
Commits
bcb02eab
Commit
bcb02eab
authored
5 months ago
by
Lorenz Martin Diel
Browse files
Options
Downloads
Patches
Plain Diff
Removed UnitID Unkown
parent
819aece6
No related branches found
No related tags found
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
.clang-format
+187
-0
187 additions, 0 deletions
.clang-format
src/config.cpp
+129
-113
129 additions, 113 deletions
src/config.cpp
src/unit.hpp
+0
-2
0 additions, 2 deletions
src/unit.hpp
with
316 additions
and
115 deletions
.clang-format
0 → 100644
+
187
−
0
View file @
bcb02eab
---
BasedOnStyle: LLVM
AccessModifierOffset: -2
AlignAfterOpenBracket: AlwaysBreak
AlignArrayOfStructures: Right
AlignConsecutiveAssignments: None
AlignConsecutiveBitFields: None
AlignConsecutiveDeclarations: Consecutive
AlignConsecutiveMacros: None
AlignEscapedNewlines: Right
AlignOperands: Align
AlignTrailingComments: true
AllowAllArgumentsOnNextLine: true
AllowAllConstructorInitializersOnNextLine: true
AllowAllParametersOfDeclarationOnNextLine: true
AllowShortBlocksOnASingleLine: Never
AllowShortCaseLabelsOnASingleLine: false
AllowShortEnumsOnASingleLine: true
AllowShortFunctionsOnASingleLine: Inline
AllowShortIfStatementsOnASingleLine: Never
AllowShortLambdasOnASingleLine: All
AllowShortLoopsOnASingleLine: false
AlwaysBreakAfterDefinitionReturnType: None
AlwaysBreakAfterReturnType: None
AlwaysBreakBeforeMultilineStrings: false
AlwaysBreakTemplateDeclarations: Yes
AttributeMacros:
- __capability
BinPackArguments: true
BinPackParameters: true
BitFieldColonSpacing: Both
BraceWrapping:
AfterCaseLabel: false
AfterClass: false
AfterControlStatement: Never
AfterEnum: false
AfterFunction: false
AfterNamespace: false
AfterObjCDeclaration: false
AfterStruct: false
AfterUnion: false
AfterExternBlock: false
BeforeCatch: false
BeforeElse: false
BeforeLambdaBody: false
BeforeWhile: false
IndentBraces: false
SplitEmptyFunction: true
SplitEmptyRecord: true
SplitEmptyNamespace: true
BreakAfterJavaFieldAnnotations: false
BreakBeforeBinaryOperators: None
BreakBeforeBraces: Allman
BreakBeforeConceptDeclarations: true
BreakBeforeTernaryOperators: true
BreakConstructorInitializers: BeforeColon
BreakInheritanceList: BeforeColon
BreakStringLiterals: true
ColumnLimit: 100
CommentPragmas: "^ IWYU pragma:"
CompactNamespaces: false
ConstructorInitializerAllOnOneLineOrOnePerLine: false
ConstructorInitializerIndentWidth: 4
ContinuationIndentWidth: 4
Cpp11BracedListStyle: true
DeriveLineEnding: true
DerivePointerAlignment: false
DisableFormat: false
EmptyLineAfterAccessModifier: Never
EmptyLineBeforeAccessModifier: LogicalBlock
ExperimentalAutoDetectBinPacking: false
FixNamespaceComments: true
ForEachMacros:
- foreach
- Q_FOREACH
- BOOST_FOREACH
IfMacros:
- KJ_IF_MAYBE
IncludeBlocks: Preserve
IncludeCategories:
- Regex: ^"(llvm|llvm-c|clang|clang-c)/
Priority: 2
SortPriority: 0
CaseSensitive: false
- Regex: ^(<|"(gtest|gmock|isl|json)/)
Priority: 3
SortPriority: 0
CaseSensitive: false
- Regex: .*
Priority: 1
SortPriority: 0
CaseSensitive: false
IncludeIsMainRegex: (Test)?$
IncludeIsMainSourceRegex: ""
IndentAccessModifiers: true
IndentCaseBlocks: true
IndentCaseLabels: false
IndentExternBlock: AfterExternBlock
IndentGotoLabels: true
IndentPPDirectives: None
IndentRequires: false
IndentWidth: 4
IndentWrappedFunctionNames: false
InsertTrailingCommas: None
JavaScriptQuotes: Leave
JavaScriptWrapImports: true
KeepEmptyLinesAtTheStartOfBlocks: true
LambdaBodyIndentation: Signature
Language: Cpp
MacroBlockBegin: ""
MacroBlockEnd: ""
MaxEmptyLinesToKeep: 1
NamespaceIndentation: None
ObjCBinPackProtocolList: Auto
ObjCBlockIndentWidth: 2
ObjCBreakBeforeNestedBlockParam: true
ObjCSpaceAfterProperty: false
ObjCSpaceBeforeProtocolList: true
PPIndentWidth: -1
PackConstructorInitializers: BinPack
PenaltyBreakAssignment: 2
PenaltyBreakBeforeFirstCallParameter: 19
PenaltyBreakComment: 300
PenaltyBreakFirstLessLess: 120
PenaltyBreakOpenParenthesis: 0
PenaltyBreakString: 1000
PenaltyBreakTemplateDeclaration: 10
PenaltyExcessCharacter: 1000000
PenaltyIndentedWhitespace: 0
PenaltyReturnTypeOnItsOwnLine: 60
PointerAlignment: Left
QualifierAlignment: Leave
ReferenceAlignment: Pointer
ReflowComments: true
RemoveBracesLLVM: false
SeparateDefinitionBlocks: Leave
ShortNamespaceLines: 1
SortIncludes: CaseSensitive
SortJavaStaticImport: Before
SortUsingDeclarations: true
SpaceAfterCStyleCast: false
SpaceAfterLogicalNot: false
SpaceAfterTemplateKeyword: true
SpaceAroundPointerQualifiers: Default
SpaceBeforeAssignmentOperators: true
SpaceBeforeCaseColon: false
SpaceBeforeCpp11BracedList: false
SpaceBeforeCtorInitializerColon: true
SpaceBeforeInheritanceColon: true
SpaceBeforeParens: ControlStatements
SpaceBeforeParensOptions:
AfterControlStatements: true
AfterForeachMacros: true
AfterFunctionDeclarationName: false
AfterFunctionDefinitionName: false
AfterIfMacros: true
AfterOverloadedOperator: false
BeforeNonEmptyParentheses: false
SpaceBeforeRangeBasedForLoopColon: true
SpaceBeforeSquareBrackets: false
SpaceInEmptyBlock: false
SpaceInEmptyParentheses: false
SpacesBeforeTrailingComments: 1
SpacesInAngles: Never
SpacesInCStyleCastParentheses: false
SpacesInConditionalStatement: false
SpacesInContainerLiterals: true
SpacesInLineCommentPrefix:
Minimum: 1
Maximum: -1
SpacesInParentheses: false
SpacesInSquareBrackets: false
Standard: Latest
StatementAttributeLikeMacros:
- Q_EMIT
StatementMacros:
- Q_UNUSED
- QT_REQUIRE_VERSION
TabWidth: 4
UseCRLF: false
UseTab: Never
WhitespaceSensitiveMacros:
- STRINGIZE
- PP_STRINGIZE
- BOOST_PP_STRINGIZE
- NS_SWIFT_NAME
- CF_SWIFT_NAME
This diff is collapsed.
Click to expand it.
src/config.cpp
+
129
−
113
View file @
bcb02eab
...
@@ -23,18 +23,26 @@ namespace advanced_wars
...
@@ -23,18 +23,26 @@ namespace advanced_wars
const
auto
&
unitData
=
unit
.
second
;
const
auto
&
unitData
=
unit
.
second
;
std
::
string
unit_key
=
unitData
.
get
<
std
::
string
>
(
"<xmlattr>.key"
);
std
::
string
unit_key
=
unitData
.
get
<
std
::
string
>
(
"<xmlattr>.key"
);
UnitId
unitId
=
map_unit_key_to_id
(
unit_key
);
try
if
(
unitId
==
UnitId
::
UNKNOWN
)
{
{
continue
;
UnitId
unitId
=
map_unit_key_to_id
(
unit_key
);
}
unit_costs
[
unitId
]
=
unitData
.
get
<
int
>
(
"Cost"
);
unit_costs
[
unitId
]
=
unitData
.
get
<
int
>
(
"Cost"
);
unit_movement_points
[
unitId
]
=
unitData
.
get
<
int
>
(
"MovementPoints"
);
unit_movement_points
[
unitId
]
=
unitData
.
get
<
int
>
(
"MovementPoints"
);
unit_ammo
[
unitId
]
=
unitData
.
get
<
int
>
(
"Ammo"
);
unit_ammo
[
unitId
]
=
unitData
.
get
<
int
>
(
"Ammo"
);
unit_min_range
[
unitId
]
=
unitData
.
get
<
int
>
(
"minRange"
,
0
);
unit_min_range
[
unitId
]
=
unitData
.
get
<
int
>
(
"minRange"
,
0
);
unit_max_range
[
unitId
]
=
unitData
.
get
<
int
>
(
"maxRange"
,
0
);
unit_max_range
[
unitId
]
=
unitData
.
get
<
int
>
(
"maxRange"
,
0
);
unit_movement_type
[
unitId
]
=
map_movement_type
(
unitData
.
get
<
std
::
string
>
(
"MovementType"
));
std
::
string
movement_type_str
=
unitData
.
get
<
std
::
string
>
(
"MovementType"
);
try
{
unit_movement_type
[
unitId
]
=
map_movement_type
(
movement_type_str
);
}
catch
(
const
std
::
out_of_range
&
e
)
{
std
::
cerr
<<
"Unknown movement type: "
<<
movement_type_str
<<
" for unit key: "
<<
unit_key
<<
std
::
endl
;
continue
;
}
for
(
const
auto
&
weapon
:
unitData
.
get_child
(
"Weapons"
))
for
(
const
auto
&
weapon
:
unitData
.
get_child
(
"Weapons"
))
{
{
...
@@ -49,9 +57,6 @@ namespace advanced_wars
...
@@ -49,9 +57,6 @@ namespace advanced_wars
std
::
string
target_key
=
damage
.
second
.
get
<
std
::
string
>
(
"<xmlattr>.unitId"
);
std
::
string
target_key
=
damage
.
second
.
get
<
std
::
string
>
(
"<xmlattr>.unitId"
);
UnitId
targetId
=
map_unit_key_to_id
(
target_key
);
UnitId
targetId
=
map_unit_key_to_id
(
target_key
);
if
(
targetId
==
UnitId
::
UNKNOWN
)
continue
;
primary_weapon_damage
[
unitId
][
targetId
]
=
damage
.
second
.
get
<
int
>
(
"<xmlattr>.value"
);
primary_weapon_damage
[
unitId
][
targetId
]
=
damage
.
second
.
get
<
int
>
(
"<xmlattr>.value"
);
}
}
}
}
...
@@ -66,14 +71,17 @@ namespace advanced_wars
...
@@ -66,14 +71,17 @@ namespace advanced_wars
std
::
string
target_key
=
damage
.
second
.
get
<
std
::
string
>
(
"<xmlattr>.unitId"
);
std
::
string
target_key
=
damage
.
second
.
get
<
std
::
string
>
(
"<xmlattr>.unitId"
);
UnitId
targetId
=
map_unit_key_to_id
(
target_key
);
UnitId
targetId
=
map_unit_key_to_id
(
target_key
);
if
(
targetId
==
UnitId
::
UNKNOWN
)
continue
;
secondary_weapon_damage
[
unitId
][
targetId
]
=
damage
.
second
.
get
<
int
>
(
"<xmlattr>.value"
);
secondary_weapon_damage
[
unitId
][
targetId
]
=
damage
.
second
.
get
<
int
>
(
"<xmlattr>.value"
);
}
}
}
}
}
}
}
}
catch
(
const
std
::
out_of_range
&
e
)
{
//std::cerr << "Unknown unit key: " << unit_key << std::endl;
continue
;
}
}
}
}
UnitId
Config
::
map_unit_key_to_id
(
const
std
::
string
&
unit_key
)
const
UnitId
Config
::
map_unit_key_to_id
(
const
std
::
string
&
unit_key
)
const
...
@@ -100,7 +108,11 @@ namespace advanced_wars
...
@@ -100,7 +108,11 @@ namespace advanced_wars
{
"bomber"
,
UnitId
::
BOMBER
}};
{
"bomber"
,
UnitId
::
BOMBER
}};
auto
it
=
unit_map
.
find
(
unit_key
);
auto
it
=
unit_map
.
find
(
unit_key
);
return
it
!=
unit_map
.
end
()
?
it
->
second
:
UnitId
::
UNKNOWN
;
if
(
it
!=
unit_map
.
end
())
{
return
it
->
second
;
}
throw
std
::
out_of_range
(
"Unknown unit key: "
+
unit_key
);
}
}
MovementType
Config
::
map_movement_type
(
const
std
::
string
&
movementTypeStr
)
const
MovementType
Config
::
map_movement_type
(
const
std
::
string
&
movementTypeStr
)
const
...
@@ -111,13 +123,17 @@ namespace advanced_wars
...
@@ -111,13 +123,17 @@ namespace advanced_wars
{
"Tread"
,
MovementType
::
TREAD
},
{
"Tread"
,
MovementType
::
TREAD
},
{
"Air"
,
MovementType
::
AIR
},
{
"Air"
,
MovementType
::
AIR
},
{
"Sea"
,
MovementType
::
SEA
},
{
"Sea"
,
MovementType
::
SEA
},
{
"Lander"
,
MovementType
::
LANDER
}
{
"Lander"
,
MovementType
::
LANDER
}
};
};
auto
it
=
movement_map
.
find
(
movementTypeStr
);
auto
it
=
movement_map
.
find
(
movementTypeStr
);
return
it
!=
movement_map
.
end
()
?
it
->
second
:
MovementType
::
UNKNOWN
;
if
(
it
!=
movement_map
.
end
())
{
return
it
->
second
;
}
throw
std
::
out_of_range
(
"Unknown movement type: "
+
movementTypeStr
);
}
}
int
Config
::
get_unit_cost
(
UnitId
id
)
const
int
Config
::
get_unit_cost
(
UnitId
id
)
const
{
{
auto
it
=
unit_costs
.
find
(
id
);
auto
it
=
unit_costs
.
find
(
id
);
...
...
This diff is collapsed.
Click to expand it.
src/unit.hpp
+
0
−
2
View file @
bcb02eab
...
@@ -40,7 +40,6 @@ enum class UnitId {
...
@@ -40,7 +40,6 @@ enum class UnitId {
LANDER
=
17
,
LANDER
=
17
,
//Diese Einheit kann tauchen, und ist somit für einige Einheiten nicht sichtbar und kann zum Teil auch im Tauchen nicht angegriffen werden
//Diese Einheit kann tauchen, und ist somit für einige Einheiten nicht sichtbar und kann zum Teil auch im Tauchen nicht angegriffen werden
SUBMARINE
=
18
,
SUBMARINE
=
18
,
UNKNOWN
=
19
};
};
/*
/*
...
@@ -82,7 +81,6 @@ enum class MovementType {
...
@@ -82,7 +81,6 @@ enum class MovementType {
AIR
=
3
,
AIR
=
3
,
SEA
=
4
,
SEA
=
4
,
LANDER
=
5
,
LANDER
=
5
,
UNKNOWN
=
6
};
};
//Fill the MatchupTabel
//Fill the MatchupTabel
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment