Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
PyCommandCenter
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Erik Ahlroth
PyCommandCenter
Commits
6e037119
Commit
6e037119
authored
6 years ago
by
David Bergström
Browse files
Options
Downloads
Patches
Plain Diff
Patch TechTree data with information from TechTreeImproved
parent
434179bd
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/TechTree.cpp
+29
-0
29 additions, 0 deletions
src/TechTree.cpp
src/TechTreeImproved.cpp
+15
-2
15 additions, 2 deletions
src/TechTreeImproved.cpp
src/TechTreeImproved.h
+4
-2
4 additions, 2 deletions
src/TechTreeImproved.h
with
48 additions
and
4 deletions
src/TechTree.cpp
+
29
−
0
View file @
6e037119
...
...
@@ -41,16 +41,45 @@ void TechTree::onStart()
for
(
const
BuildDescription
&
description
:
howToBuild
)
{
data
.
whatBuilds
.
push_back
(
UnitType
(
description
.
producer_type
,
m_bot
));
for
(
sc2
::
UNIT_TYPEID
unit_typeid
:
description
.
buildings_needed
)
{
data
.
requiredUnits
.
push_back
(
UnitType
(
unit_typeid
,
m_bot
));
}
for
(
sc2
::
UNIT_TYPEID
unit_typeid
:
description
.
addons_needed
)
{
data
.
requiredAddons
.
push_back
(
UnitType
(
unit_typeid
,
m_bot
));
}
}
}
for
(
std
::
pair
<
const
sc2
::
UpgradeID
,
TypeData
>
&
pair
:
m_upgradeData
)
{
const
sc2
::
UpgradeID
id
=
pair
.
first
;
TypeData
&
data
=
pair
.
second
;
data
.
whatBuilds
.
clear
();
data
.
requiredUnits
.
clear
();
data
.
requiredUpgrades
.
clear
();
for
(
const
ResearchDescription
&
description
:
tree
.
HowToResearch
(
id
))
{
data
.
buildAbility
=
description
.
ability_used
;
data
.
whatBuilds
.
push_back
(
UnitType
(
description
.
producer_type
,
m_bot
));
for
(
sc2
::
UNIT_TYPEID
unit_typeid
:
description
.
buildings_needed
)
{
data
.
requiredUnits
.
push_back
(
UnitType
(
unit_typeid
,
m_bot
));
}
for
(
sc2
::
UPGRADE_ID
upgrade_id
:
description
.
upgrades_needed
)
{
data
.
requiredUpgrades
.
push_back
(
upgrade_id
);
}
}
}
}
...
...
This diff is collapsed.
Click to expand it.
src/TechTreeImproved.cpp
+
15
−
2
View file @
6e037119
...
...
@@ -224,6 +224,19 @@ const std::vector<BuildDescription> & TechTreeImproved::HowToBuild(sc2::UnitType
else
{
std
::
cout
<<
"No information about unit type "
<<
sc2
::
UnitTypeToName
(
unit
)
<<
" ("
<<
static_cast
<
int
>
(
unit
)
<<
")"
<<
std
::
endl
;
return
empty
;
return
empty
_build
;
}
}
\ No newline at end of file
}
const
std
::
vector
<
ResearchDescription
>
&
TechTreeImproved
::
HowToResearch
(
sc2
::
UpgradeID
upgrade
)
const
{
if
(
upgrade_to_data
.
count
(
upgrade
))
{
return
upgrade_to_data
.
at
(
upgrade
);
}
else
{
std
::
cout
<<
"No information about upgrade type "
<<
sc2
::
UpgradeIDToName
(
upgrade
)
<<
" ("
<<
static_cast
<
int
>
(
upgrade
)
<<
")"
<<
std
::
endl
;
return
empty_research
;
}
}
This diff is collapsed.
Click to expand it.
src/TechTreeImproved.h
+
4
−
2
View file @
6e037119
...
...
@@ -26,8 +26,8 @@ struct ResearchDescription
sc2
::
UNIT_TYPEID
producer_type
;
sc2
::
AbilityID
ability_used
;
std
::
vector
<
sc2
::
UPGRADE_ID
>
upgrades_needed
;
std
::
vector
<
sc2
::
UNIT_TYPEID
>
buildings_needed
;
std
::
vector
<
sc2
::
UPGRADE_ID
>
upgrades_needed
;
};
class
TechTreeImproved
...
...
@@ -36,7 +36,8 @@ class TechTreeImproved
std
::
map
<
sc2
::
UPGRADE_ID
,
std
::
vector
<
ResearchDescription
>>
upgrade_to_data
;
// If there is no BuildDescription for a given type, a reference to tihs list is returned.
const
std
::
vector
<
BuildDescription
>
empty
{};
const
std
::
vector
<
BuildDescription
>
empty_build
{};
const
std
::
vector
<
ResearchDescription
>
empty_research
{};
void
parse_unit
(
nlohmann
::
json
::
iterator
it
);
public
:
...
...
@@ -44,4 +45,5 @@ public:
bool
LoadData
();
// Given a unit, how can we build it?
const
std
::
vector
<
BuildDescription
>
&
HowToBuild
(
sc2
::
UnitTypeID
unit
)
const
;
const
std
::
vector
<
ResearchDescription
>
&
HowToResearch
(
sc2
::
UpgradeID
upgrade
)
const
;
};
\ No newline at end of file
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