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
5feb27d1
Commit
5feb27d1
authored
6 months ago
by
Max Cherris
Browse files
Options
Downloads
Patches
Plain Diff
Refactor simple issues
Such as typos, unused includes and unnecessary comments
parent
1c234b83
Branches
Branches containing commit
No related tags found
1 merge request
!15
Merge units into main
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/unit.cpp
+1
-59
1 addition, 59 deletions
src/unit.cpp
src/unit.hpp
+6
-8
6 additions, 8 deletions
src/unit.hpp
with
7 additions
and
67 deletions
src/unit.cpp
+
1
−
59
View file @
5feb27d1
#include
"unit.hpp"
#include
<tinyxml2.h>
#include
<iostream>
namespace
advanced_wars
...
...
@@ -70,9 +69,6 @@ namespace advanced_wars
}
}
MatchupTabel
damageMatrix
;
std
::
vector
<
Unit
*>
units
;
void
Unit
::
attack
(
Unit
&
enemy
)
{
int
offDamage
=
50
;
...
...
@@ -119,17 +115,8 @@ Features:
this
->
is_selected
=
true
;
std
::
cout
<<
"I am selected!!"
<<
std
::
endl
;
/*
for (Unit *unit : units)
{
if (!inRange(unit))
{
unit->state = advanced_wars::UnitState::UNAVAILABLE;
};
}
*/
//make move range calc
break
;
case
SDL_BUTTON_RIGHT
:
...
...
@@ -180,50 +167,5 @@ Features:
}
return
false
;
}
/*
void Unit::loadXML(const char *filename)
{
tinyxml2::XMLDocument doc;
if (doc.LoadFile(filename) != tinyxml2::XML_SUCCESS)
{
std::cerr << "Fehler beim Laden der XML-Datei!" << std::endl;
return;
}
MatchupTabel damageMatrix;
tinyxml2::XMLElement *unitElement = doc.FirstChildElement("Units")->FirstChildElement("Unit");
// get all Units
while (unitElement)
{
const u_int8_t UnitId = unitElement->Attribute("id");
std::unordered_map<u_int8_t, int> attackValues;
tinyxml2::XMLElement *attackElement = unitElement->FirstChildElement("Attack");
// get all attack-values
while (attackElement)
{
tinyxml2::XMLElement *attackTypeElement = attackElement->FirstChildElement();
while (attackTypeElement)
{
UnitId Unit_Id = static_cast<UnitId> attackTypeElement->Name(); // wenn das geht kauf ich maggus sein kochbuch
int attackValue = attackTypeElement->IntText();
attackValues[Unit_Id] = attackValue;
attackTypeElement = attackTypeElement->NextSiblingElement();
}
}
damageMatrix[unitElement][attackValues];
unitElement = unitElement->NextSiblingElement("Unit");
}
}
*/
}
// namespace advanced_wars
\ No newline at end of file
This diff is collapsed.
Click to expand it.
src/unit.hpp
+
6
−
8
View file @
5feb27d1
...
...
@@ -55,8 +55,7 @@ enum class MovementType {
LANDER
=
5
,
};
//Fill the MatchupTabel
using
MatchupTabel
=
std
::
unordered_map
<
u_int8_t
,
std
::
unordered_map
<
u_int8_t
,
int
>>
;
using
MatchupTable
=
std
::
unordered_map
<
u_int8_t
,
std
::
unordered_map
<
u_int8_t
,
int
>>
;
class
Unit
{
public:
...
...
@@ -104,13 +103,12 @@ public:
*/
void
calculate_movement
();
/*
Load the XML and iterate over the entire datastructur
e
For every Unit, get Unit_Id and create a map for Unit_Id -> {Unit_Id -> damageType}
This function fills the MatchupTabl
e
It would be better if this table would be placed in the level
*/
void
loadXML
(
const
char
*
filename
);
void
fill_matchupTable
();
/*
This function will be called by an external event-handler, eventually.
...
...
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