[SCM] advanced 3D real time strategy game engine branch, experimental, updated. debian/0.81.2.1+dfsg1-6-23-gc9e2b12
Jan Dittberner
jandd at debian.org
Sun Aug 15 18:08:28 UTC 2010
The following commit has been merged in the experimental branch:
commit 98670b4cec77610d91e45c71ffab2a9ca3d6cc51
Merge: adcd9f1156c5509e92ad3ea8140ed78fb27630fa 05d92050af1902f8b33b5b7cd280bbe7ee441e98
Author: Jan Dittberner <jandd at debian.org>
Date: Sun Aug 15 15:55:58 2010 +0200
Merge commit 'upstream/0.82.3+dfsg1' into experimental
diff --combined AI/Skirmish/E323AI/CThreatMap.cpp
index 71671af,1103df5..afc1056
--- a/AI/Skirmish/E323AI/CThreatMap.cpp
+++ b/AI/Skirmish/E323AI/CThreatMap.cpp
@@@ -46,8 -46,9 +46,9 @@@ CThreatMap::~CThreatMap()
void CThreatMap::reset() {
float *map;
std::map<ThreatMapType,float*>::iterator i;
+ // NOTE: no threat value equals to ONE, not ZERO!
for (i = maps.begin(); i != maps.end(); i++) {
- maxPower[i->first] = 0.0f;
+ maxPower[i->first] = 1.0f;
map = i->second;
for (int i = 0; i < X*Z; i++)
map[i] = 1.0f;
@@@ -69,6 -70,7 +70,7 @@@ float CThreatMap::getThreat(float3 &cen
if (radius < EPS)
return map[ID(j,i)];
+ int sectorsProcessed = 0;
int R = ceil(radius / REAL);
float power = 0.0f;
for (int z = -R; z <= R; z++) {
@@@ -79,13 -81,22 +81,22 @@@
for (int x = -R; x <= R; x++) {
int xx = x+j;
- if (xx < X-1 && xx >= 0)
+ if (xx < X-1 && xx >= 0) {
power += map[ID(xx,zz)];
+ sectorsProcessed++;
+ }
}
}
+
+ // calculate number of sectors in R x R...
+ R = 2 * R + 1;
+ R *= R;
+
+ // fixing area threat for map edges...
+ if (sectorsProcessed < R)
+ power += (R - sectorsProcessed);
- //return power/(2.0f*R*M_PI);
- return power / (R*R*M_PI);
+ return power / R;
}
float CThreatMap::getThreat(float3 ¢er, float radius, CGroup *group) {
@@@ -166,7 -177,7 +177,7 @@@ void CThreatMap::update(int frame)
}
}
- for (tmi = activeTypes.begin(); tmi != activeTypes.end(); tmi++) {
+ for (tmi = activeTypes.begin(); tmi != activeTypes.end(); ++tmi) {
maxPower[*tmi] = std::max<float>(power, maxPower[*tmi]);
}
}
@@@ -219,4 -230,4 +230,4 @@@ bool CThreatMap::switchDebugMode()
if (drawMap >= TMT_LAST)
drawMap = TMT_NONE;
return drawMap != TMT_NONE;
-}
+}
--
advanced 3D real time strategy game engine
More information about the Pkg-games-commits
mailing list