Skip to content

Commit 0a664e4

Browse files
author
jK
committed
Merge branch 'release' into develop
2 parents 69252d8 + 646faf8 commit 0a664e4

File tree

12 files changed

+182
-79
lines changed

12 files changed

+182
-79
lines changed

cont/base/springcontent/LuaGadgets/callins.lua

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ CallInsList = {
6969
"DrawInMiniMap",
7070
"DrawUnit",
7171
"DrawFeature",
72+
"DrawShield",
7273

7374
"Explosion",
7475
"ShockFront",

cont/base/springcontent/LuaGadgets/gadgets.lua

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,7 @@ local callInLists = {
159159
-- unsynced
160160
"DrawUnit",
161161
"DrawFeature",
162+
"DrawShield",
162163
"RecvSkirmishAIMessage",
163164

164165
-- COB CallIn (FIXME?)
@@ -1075,6 +1076,15 @@ function gadgetHandler:DrawFeature(featureID, drawMode)
10751076
return false
10761077
end
10771078

1079+
function gadgetHandler:DrawShield(unitID, weaponID, drawMode)
1080+
for _,g in ipairs(self.DrawShieldList) do
1081+
if (g:DrawShield(unitID, weaponID, drawMode)) then
1082+
return true
1083+
end
1084+
end
1085+
return false
1086+
end
1087+
10781088
function gadgetHandler:RecvSkirmishAIMessage(aiTeam, dataStr)
10791089
for _,g in ipairs(self.RecvSkirmishAIMessageList) do
10801090
local dataRet = g:RecvSkirmishAIMessage(aiTeam, dataStr)
@@ -1110,11 +1120,9 @@ function gadgetHandler:AllowCommand(unitID, unitDefID, unitTeam,
11101120
end
11111121

11121122

1113-
function gadgetHandler:AllowUnitCreation(unitDefID, builderID,
1114-
builderTeam, x, y, z)
1123+
function gadgetHandler:AllowUnitCreation(unitDefID, builderID, builderTeam, x, y, z, facing)
11151124
for _,g in ipairs(self.AllowUnitCreationList) do
1116-
if (not g:AllowUnitCreation(unitDefID, builderID,
1117-
builderTeam, x, y, z)) then
1125+
if (not g:AllowUnitCreation(unitDefID, builderID, builderTeam, x, y, z, facing)) then
11181126
return false
11191127
end
11201128
end

doc/changelog.txt

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,21 @@
11
Spring changelog
22
(since 85.0: "!" prefix indicate backward compability broke)
33

4+
5+
-- 87.0 ---------------------------------------------------------
6+
Bugfixes:
7+
! restore pre86.0 maxAngleDif arcs
8+
! remove the following Lua consts: wdef[id].areaOfEffect, wdef[id].maxVelocity & wdef[id].onlyTargetCategories
9+
- fix "LuaUI didn't got unprocessed /xyz commands" (mantis 2982)
10+
- fix shield rendering
11+
- support for zlib 1.2.6 (thx sirmaverick)
12+
- fix crash on start when invalid ai is in script.txt
13+
- fix multiple pathing & collision issues
14+
- some Maven (Java) updates
15+
! removed ArchiveMover
16+
- fix compile for "make tests" on win32
17+
18+
419
-- 86.0 ---------------------------------------------------------
520
Changes:
621
- new commandline argument "--safemode": It turns off all features that are known to cause problems on some system.

rts/Rendering/QTPFSPathDrawer.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,9 @@ void QTPFSPathDrawer::DrawPaths(const MoveData* md) const {
162162

163163
if (typeIt == pm->pathTypes.end() || traceIt == pm->pathTraces.end())
164164
continue;
165+
// this only happens if source-node was equal to target-node
166+
if (traceIt->second == NULL)
167+
continue;
165168

166169
DrawSearchExecution(typeIt->second, traceIt->second);
167170
#endif

rts/Sim/MoveTypes/GroundMoveType.cpp

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ LOG_REGISTER_SECTION_GLOBAL(LOG_SECTION_GMT)
5050
#define ASSERT_SANE_OWNER_SPEED(v) assert(v.SqLength() < (MAX_UNIT_SPEED * MAX_UNIT_SPEED * 1e2));
5151

5252
#define RAD2DEG (180.0f / PI)
53-
#define MIN_WAYPOINT_DISTANCE (SQUARE_SIZE)
53+
#define MIN_WAYPOINT_DISTANCE SQUARE_SIZE
5454
#define MAX_IDLING_SLOWUPDATES 16
5555
#define DEBUG_OUTPUT 0
5656
#define WAIT_FOR_PATH 1
@@ -424,7 +424,21 @@ bool CGroundMoveType::FollowPath()
424424

425425
prevWayPointDist = currWayPointDist;
426426
currWayPointDist = owner->pos.distance2D(currWayPoint);
427-
atGoal = ((owner->pos - goalPos).SqLength2D() < Square(MIN_WAYPOINT_DISTANCE));
427+
428+
{
429+
// NOTE:
430+
// uses owner->pos instead of currWayPoint (ie. not the same as haveFinalWaypoint)
431+
//
432+
// if our first command is a build-order, then goalRadius is set to our build-range
433+
// and we cannot increase tolerance safely (otherwise the unit might stop when still
434+
// outside its range and fail to start construction)
435+
const float curGoalDistSq = (owner->pos - goalPos).SqLength2D();
436+
const float minGoalDistSq = (!owner->commandAI->commandQue.empty() && owner->commandAI->commandQue[0].GetID() < 0)?
437+
Square(goalRadius ):
438+
Square(goalRadius * (numIdlingSlowUpdates + 1));
439+
440+
atGoal |= (curGoalDistSq < minGoalDistSq);
441+
}
428442

429443
if (!atGoal) {
430444
if (!idling) {
@@ -1216,11 +1230,18 @@ void CGroundMoveType::GetNextWayPoint()
12161230
return;
12171231
}
12181232

1219-
if (currWayPoint.SqDistance2D(goalPos) < Square(MIN_WAYPOINT_DISTANCE)) {
1233+
{
1234+
const float curGoalDistSq = (currWayPoint - goalPos).SqLength2D();
1235+
const float minGoalDistSq = (!owner->commandAI->commandQue.empty() && owner->commandAI->commandQue[0].GetID() < 0)?
1236+
Square(goalRadius ):
1237+
Square(goalRadius * (numIdlingSlowUpdates + 1));
1238+
12201239
// trigger Arrived on the next Update (but
12211240
// only if we have non-temporary waypoints)
1222-
haveFinalWaypoint = true;
1241+
haveFinalWaypoint |= (curGoalDistSq < minGoalDistSq);
1242+
}
12231243

1244+
if (haveFinalWaypoint) {
12241245
currWayPoint = goalPos;
12251246
nextWayPoint = goalPos;
12261247
return;

rts/Sim/Path/QTPFS/Node.cpp

Lines changed: 76 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -96,29 +96,39 @@ float3 QTPFS::INode::GetNeighborEdgeTransitionPoint(const INode* ngb, const floa
9696

9797
#ifdef QTPFS_ORTHOPROJECTED_EDGE_TRANSITIONS
9898
#define CAST static_cast<unsigned int>
99-
// clamp <pos> (assumed to be inside <this>) to the shared-edge bounds and ortho-project it
100-
if ((rel & REL_NGB_EDGE_T) != 0) { p.x = WS(Clamp(CAST(pos.x / SQUARE_SIZE), minx, maxx)); p.z = WS(midz); return p; }
101-
if ((rel & REL_NGB_EDGE_B) != 0) { p.x = WS(Clamp(CAST(pos.x / SQUARE_SIZE), minx, maxx)); p.z = WS(midz); return p; }
102-
if ((rel & REL_NGB_EDGE_R) != 0) { p.z = WS(Clamp(CAST(pos.z / SQUARE_SIZE), minz, maxz)); p.x = WS(midx); return p; }
103-
if ((rel & REL_NGB_EDGE_L) != 0) { p.z = WS(Clamp(CAST(pos.z / SQUARE_SIZE), minz, maxz)); p.x = WS(midx); return p; }
99+
switch (rel) {
100+
// corners
101+
case REL_NGB_EDGE_T | REL_NGB_EDGE_L: { p.x = WS(xmin()); p.z = WS(zmin()); } break;
102+
case REL_NGB_EDGE_T | REL_NGB_EDGE_R: { p.x = WS(xmax()); p.z = WS(zmin()); } break;
103+
case REL_NGB_EDGE_B | REL_NGB_EDGE_R: { p.x = WS(xmax()); p.z = WS(zmax()); } break;
104+
case REL_NGB_EDGE_B | REL_NGB_EDGE_L: { p.x = WS(xmin()); p.z = WS(zmax()); } break;
105+
// edges
106+
// clamp <pos> (assumed to be inside <this>) to
107+
// the shared-edge bounds and ortho-project it
108+
case REL_NGB_EDGE_T: { p.x = WS(Clamp(CAST(pos.x / SQUARE_SIZE), minx, maxx)); p.z = WS(minz); } break;
109+
case REL_NGB_EDGE_B: { p.x = WS(Clamp(CAST(pos.x / SQUARE_SIZE), minx, maxx)); p.z = WS(maxz); } break;
110+
case REL_NGB_EDGE_R: { p.z = WS(Clamp(CAST(pos.z / SQUARE_SIZE), minz, maxz)); p.x = WS(maxx); } break;
111+
case REL_NGB_EDGE_L: { p.z = WS(Clamp(CAST(pos.z / SQUARE_SIZE), minz, maxz)); p.x = WS(minx); } break;
112+
113+
// <ngb> had better be an actual neighbor
114+
case 0: { assert(false); } break;
115+
}
104116
#undef CAST
105117
#else
106118
switch (rel) {
107119
// corners
108-
case REL_NGB_EDGE_T | REL_NGB_EDGE_L: { p.x = WS(xmin()); p.z = WS(zmin()); } break;
109-
case REL_NGB_EDGE_T | REL_NGB_EDGE_R: { p.x = WS(xmax()); p.z = WS(zmin()); } break;
110-
case REL_NGB_EDGE_B | REL_NGB_EDGE_R: { p.x = WS(xmax()); p.z = WS(zmax()); } break;
111-
case REL_NGB_EDGE_B | REL_NGB_EDGE_L: { p.x = WS(xmin()); p.z = WS(zmax()); } break;
120+
case REL_NGB_EDGE_T | REL_NGB_EDGE_L: { p.x = WS(xmin()); p.z = WS(zmin()); } break;
121+
case REL_NGB_EDGE_T | REL_NGB_EDGE_R: { p.x = WS(xmax()); p.z = WS(zmin()); } break;
122+
case REL_NGB_EDGE_B | REL_NGB_EDGE_R: { p.x = WS(xmax()); p.z = WS(zmax()); } break;
123+
case REL_NGB_EDGE_B | REL_NGB_EDGE_L: { p.x = WS(xmin()); p.z = WS(zmax()); } break;
112124
// edges
113-
case REL_NGB_EDGE_T: { p.x = WS(midx ); p.z = WS(zmin()); } break;
114-
case REL_NGB_EDGE_R: { p.x = WS(xmax()); p.z = WS(midz ); } break;
115-
case REL_NGB_EDGE_B: { p.x = WS(midx ); p.z = WS(zmax()); } break;
116-
case REL_NGB_EDGE_L: { p.x = WS(xmin()); p.z = WS(midz ); } break;
117-
118-
case 0: {
119-
// <ngb> had better be an actual neighbor
120-
assert(false);
121-
} break;
125+
case REL_NGB_EDGE_T: { p.x = WS(midx ); p.z = WS(zmin()); } break;
126+
case REL_NGB_EDGE_R: { p.x = WS(xmax()); p.z = WS(midz ); } break;
127+
case REL_NGB_EDGE_B: { p.x = WS(midx ); p.z = WS(zmax()); } break;
128+
case REL_NGB_EDGE_L: { p.x = WS(xmin()); p.z = WS(midz ); } break;
129+
130+
// <ngb> had better be an actual neighbor
131+
case 0: { assert(false); } break;
122132
}
123133
#endif
124134

@@ -160,22 +170,26 @@ QTPFS::QTNode::QTNode(
160170
) {
161171
nodeNumber = nn;
162172
heapIndex = -1U;
163-
searchState = 0;
164173

165-
currMagicNum = 0;
174+
searchState = 0;
175+
currMagicNum = 0;
166176
prevMagicNum = -1U;
167177

178+
#ifdef QTPFS_WEIGHTED_HEURISTIC_COST
179+
numPrevNodes = 0;
180+
#endif
181+
168182
_xmin = x1; _xmax = x2;
169183
_zmin = z1; _zmax = z2;
184+
_depth = (parent != NULL)? parent->depth() + 1: 0;
170185

171186
assert(xsize() != 0);
172187
assert(zsize() != 0);
173188

174-
_depth = (parent != NULL)? parent->depth() + 1: 0;
175-
176189
fCost = 0.0f;
177190
gCost = 0.0f;
178191
hCost = 0.0f;
192+
mCost = 0.0f;
179193

180194
speedModSum = 0.0f;
181195
speedModAvg = 0.0f;
@@ -218,6 +232,46 @@ boost::uint64_t QTPFS::QTNode::GetMemFootPrint() const {
218232
return memFootPrint;
219233
}
220234

235+
boost::uint64_t QTPFS::QTNode::GetCheckSum() const {
236+
boost::uint64_t sum = 0;
237+
238+
{
239+
#ifdef QTPFS_WEIGHTED_HEURISTIC_COST
240+
const unsigned char* minByte = reinterpret_cast<const unsigned char*>(&this->nodeNumber);
241+
const unsigned char* maxByte = reinterpret_cast<const unsigned char*>(&this->numPrevNodes) + sizeof(unsigned int);
242+
#else
243+
const unsigned char* minByte = reinterpret_cast<const unsigned char*>(&this->nodeNumber);
244+
const unsigned char* maxByte = reinterpret_cast<const unsigned char*>(&this->mCost) + sizeof(float);
245+
#endif
246+
247+
assert(minByte < maxByte);
248+
249+
// INode bytes (unpadded)
250+
for (const unsigned char* byte = minByte; byte != maxByte; byte++) {
251+
sum ^= ((((byte + 1) - minByte) << 8) * (*byte));
252+
}
253+
}
254+
{
255+
const unsigned char* minByte = reinterpret_cast<const unsigned char*>(&this->_xmin);
256+
const unsigned char* maxByte = reinterpret_cast<const unsigned char*>(&this->prevMagicNum) + sizeof(unsigned int);
257+
258+
assert(minByte < maxByte);
259+
260+
// QTNode bytes (unpadded)
261+
for (const unsigned char* byte = minByte; byte != maxByte; byte++) {
262+
sum ^= ((((byte + 1) - minByte) << 8) * (*byte));
263+
}
264+
}
265+
266+
if (!IsLeaf()) {
267+
for (unsigned int n = 0; n < children.size(); n++) {
268+
sum ^= (((nodeNumber << 8) + 1) * children[n]->GetCheckSum());
269+
}
270+
}
271+
272+
return sum;
273+
}
274+
221275

222276

223277
bool QTPFS::QTNode::IsLeaf() const {

rts/Sim/Path/QTPFS/Node.hpp

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -60,11 +60,6 @@ namespace QTPFS {
6060
virtual void SetMagicNumber(unsigned int) = 0;
6161
virtual unsigned int GetMagicNumber() const = 0;
6262

63-
#ifdef QTPFS_ORTHOPROJECTED_EDGE_TRANSITIONS
64-
virtual const float3& GetEdgeTransitionPoint() const = 0;
65-
virtual void SetEdgeTransitionPoint(const float3& point) = 0;
66-
#endif
67-
6863
void SetPathCost(unsigned int type, float cost);
6964
float GetPathCost(unsigned int type) const;
7065

@@ -109,6 +104,7 @@ namespace QTPFS {
109104
unsigned int GetParentID() const { return ((nodeNumber - 1) >> 2); }
110105

111106
boost::uint64_t GetMemFootPrint() const;
107+
boost::uint64_t GetCheckSum() const;
112108

113109
void Delete();
114110
void PreTesselate(NodeLayer& nl, const SRectangle& r);
@@ -144,11 +140,6 @@ namespace QTPFS {
144140
void SetMagicNumber(unsigned int number) { currMagicNum = number; }
145141
unsigned int GetMagicNumber() const { return currMagicNum; }
146142

147-
#ifdef QTPFS_ORTHOPROJECTED_EDGE_TRANSITIONS
148-
const float3& GetEdgeTransitionPoint() const { return edgeTransitionPoint; }
149-
void SetEdgeTransitionPoint(const float3& point) { edgeTransitionPoint = point; }
150-
#endif
151-
152143
static const unsigned int CHILD_COUNT = 4;
153144
static const unsigned int MIN_SIZE_X = 2;
154145
static const unsigned int MIN_SIZE_Z = 2;
@@ -178,13 +169,6 @@ namespace QTPFS {
178169

179170
std::vector<QTNode*> children;
180171
std::vector<INode*> neighbors;
181-
182-
#ifdef QTPFS_ORTHOPROJECTED_EDGE_TRANSITIONS
183-
// need these as well as the back-pointers
184-
// since we cannot exactly reconstruct the
185-
// found path otherwise
186-
float3 edgeTransitionPoint;
187-
#endif
188172
};
189173
};
190174

rts/Sim/Path/QTPFS/PathManager.cpp

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@
2828
#undef GetTempPathA
2929
#endif
3030

31+
#define NUL_RECTANGLE SRectangle(0, 0, 0, 0)
32+
#define MAP_RECTANGLE SRectangle(0, 0, gs->mapx, gs->mapy)
33+
3134
namespace QTPFS {
3235
const float PathManager::MIN_SPEEDMOD_VALUE = 0.0f;
3336
const float PathManager::MAX_SPEEDMOD_VALUE = 2.0f;
@@ -133,7 +136,7 @@ void QTPFS::PathManager::Load() {
133136
searchStateOffset = NODE_STATE_OFFSET;
134137
numTerrainChanges = 0;
135138
numPathRequests = 0;
136-
maxNumLayerNodes = 0;
139+
maxNumLeafNodes = 0;
137140

138141
nodeTrees.resize(moveinfo->moveData.size(), NULL);
139142
nodeLayers.resize(moveinfo->moveData.size());
@@ -152,26 +155,26 @@ void QTPFS::PathManager::Load() {
152155
// should be sufficient in theory, because if either
153156
// the map or the mod changes then the checksum does
154157
// (should!) as well and we get a cache-miss
155-
// this value can still be combined with the tree-sums
156-
// to make it depend on the tesselation code specifics,
157-
// which are also subject to change (TODO)
158+
// this value is also combined with the tree-sums to
159+
// make it depend on the tesselation code specifics
158160
pfsCheckSum = mapCheckSum ^ modCheckSum;
159161

160-
#ifdef SYNCDEBUG
161-
{ SyncedUint tmp(pfsCheckSum); }
162-
#endif
163-
164162
const std::string& cacheDirName = GetCacheDirName(mapCheckSum, modCheckSum);
165163
const bool haveCacheDir = FileSystem::DirExists(cacheDirName);
166164

167-
InitNodeLayersThreaded(SRectangle(0, 0, gs->mapx, gs->mapy), haveCacheDir);
165+
InitNodeLayersThreaded(MAP_RECTANGLE, haveCacheDir);
168166
Serialize(cacheDirName);
169167

170168
for (unsigned int layerNum = 0; layerNum < nodeLayers.size(); layerNum++) {
171-
maxNumLayerNodes = std::max(nodeLayers[layerNum].GetNumLeafNodes(), maxNumLayerNodes);
169+
pfsCheckSum ^= nodeTrees[layerNum]->GetCheckSum();
170+
maxNumLeafNodes = std::max(nodeLayers[layerNum].GetNumLeafNodes(), maxNumLeafNodes);
172171
}
173172

174-
PathSearch::InitGlobalQueue(maxNumLayerNodes);
173+
#ifdef SYNCDEBUG
174+
{ SyncedUint tmp(pfsCheckSum); }
175+
#endif
176+
177+
PathSearch::InitGlobalQueue(maxNumLeafNodes);
175178
}
176179

177180
{
@@ -530,7 +533,7 @@ void QTPFS::PathManager::ExecuteSearch(
530533
assert(search->GetID() != 0);
531534
assert(path->GetID() == search->GetID());
532535

533-
search->Initialize(&nodeLayer, &pathCache, path->GetSourcePoint(), path->GetTargetPoint());
536+
search->Initialize(&nodeLayer, &pathCache, path->GetSourcePoint(), path->GetTargetPoint(), MAP_RECTANGLE);
534537
path->SetHash(search->GetHash(gs->mapx * gs->mapy, pathType));
535538

536539
{

rts/Sim/Path/QTPFS/PathManager.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ namespace QTPFS {
145145
unsigned int searchStateOffset;
146146
unsigned int numTerrainChanges;
147147
unsigned int numPathRequests;
148-
unsigned int maxNumLayerNodes;
148+
unsigned int maxNumLeafNodes;
149149

150150
boost::uint32_t pfsCheckSum;
151151
};

0 commit comments

Comments
 (0)