Permalink
Browse files

Merge branch 'bugfixes' into 3.1

  • Loading branch information...
2 parents fd3dc1d + 0dde269 commit 69c4474e572972e2a73eedab6672e1fe3523e903 automerge committed with cybersphinx Sep 17, 2012
Showing with 85 additions and 80 deletions.
  1. +14 −0 ChangeLog
  2. +1 −0 src/baseobject.h
  3. +1 −1 src/display3d.cpp
  4. +1 −1 src/display3d.h
  5. +8 −6 src/fpath.cpp
  6. +11 −1 src/game.cpp
  7. +1 −1 src/hci.cpp
  8. +7 −22 src/radar.cpp
  9. +41 −48 src/structure.cpp
View
14 ChangeLog
@@ -1,3 +1,17 @@
+2012-09-NN: Version 3.1 rc3
+ * General:
+ * Change: Pathfind to area around queued structure to be built (commit:88c1a3c3703d2ba260a101bb24cde419fe009afe, ticket:3576)
+ * Change: Improve HOMING-INDIRECT terrain avoidance (commit:b256d995b8b23bd4742d7cd8d876d6e0655e6d14)
+ * Change: Allow setting/clearing game password after game is hosted (commit:9575cf93e2a0b39c11d7bd2f51aef100fe4dae57)
+ * Change: Allow researching topics which labs being upgraded are already researching (commit:5bac6e4273fbdbd43acaf4a0042b373d4c9dec7c)
+ * Fix: Crash when placing transporters on the map in a map editor (ticket:3714, commit:508f26a174fd356b778419dd7c4eeaacfd27d8ac)
+ * Fix: Never add completed researches to research menu (ticket:3454, commit:d37f5276a17bbff963e5d59d1fcb2e744b494ac2)
+ * Fix: Don't try to remove unfinished off-world structures (ticket:3653, commit:594b8a6c631b160fda06f9ffca4b9f227c97c3f8)
+ * Fix: Scale logo to fit box (ticket:3667, commit:47011db59eb0c6254ed1626c4b9c8f32ee5a289c)
+ * Fix: Overflow effect creating very long progress bar (ticket:3685, commit:5b3163b9433604a470a9b4b3758081e2cdbb3755)
+ * Fix: Bug where the players list vanishes after we close our nick chooser (commit:11f19fbdb7a8f1ced43fcf24a80857da6eb63225)
+ * Warning: Warn on apparently buggy PhysFS version 2.0.2 (ticket:3700, commits:408be743f017cce1519cd955767abf0e697ab7f7)
+
2012-08-05: Version 3.1 rc1
* General:
* Change: Allow multiple AIs with similar names (commit:ee95d785bdfd72a490863d7cdb3f504f88f9eecd)
View
1 src/baseobject.h
@@ -30,6 +30,7 @@ struct StructureBounds
{
StructureBounds() {}
StructureBounds(Vector2i const &map, Vector2i const &size) : map(map), size(size) {}
+ bool valid() { return size.x >= 0; }
Vector2i map; ///< Map coordinates of upper left corner of structure.
Vector2i size; ///< Size (in map coordinates) of the structure.
View
2 src/display3d.cpp
@@ -204,7 +204,7 @@ static Vector3f alteredPoints[iV_IMD_MAX_POINTS];
/** Number of tiles visible
* \todo This should become dynamic! (A function of resolution, angle and zoom maybe.)
*/
-Vector2i visibleTiles(VISIBLE_XTILES, VISIBLE_YTILES);
+const Vector2i visibleTiles(VISIBLE_XTILES, VISIBLE_YTILES);
/// The tile we use for drawing the bottom of a body of water
static unsigned int underwaterTile = WATER_TILE;
View
2 src/display3d.h
@@ -122,7 +122,7 @@ extern Vector2i mousePos;
extern bool bRender3DOnly;
extern bool showGateways;
extern bool showPath;
-extern Vector2i visibleTiles;
+extern const Vector2i visibleTiles;
/*returns the graphic ID for a droid rank*/
extern UDWORD getDroidRankGraphic(DROID *psDroid);
View
14 src/fpath.cpp
@@ -353,7 +353,7 @@ void fpathRemoveDroidData(int id)
}
static FPATH_RETVAL fpathRoute(MOVE_CONTROL *psMove, int id, int startX, int startY, int tX, int tY, PROPULSION_TYPE propulsionType,
- DROID_TYPE droidType, FPATH_MOVETYPE moveType, int owner, bool acceptNearest, BASE_OBJECT *dstStructure)
+ DROID_TYPE droidType, FPATH_MOVETYPE moveType, int owner, bool acceptNearest, StructureBounds const &dstStructure)
{
objTrace(id, "called(*,id=%d,sx=%d,sy=%d,ex=%d,ey=%d,prop=%d,type=%d,move=%d,owner=%d)", id, startX, startY, tX, tY, (int)propulsionType, (int)droidType, (int)moveType, owner);
@@ -432,7 +432,7 @@ static FPATH_RETVAL fpathRoute(MOVE_CONTROL *psMove, int id, int startX, int sta
job.droidID = id;
job.destX = tX;
job.destY = tY;
- job.dstStructure = getStructureBounds(dstStructure);
+ job.dstStructure = dstStructure;
job.droidType = droidType;
job.propulsion = propulsionType;
job.moveType = moveType;
@@ -481,18 +481,20 @@ FPATH_RETVAL fpathDroidRoute(DROID* psDroid, SDWORD tX, SDWORD tY, FPATH_MOVETYP
// Check whether the start and end points of the route are blocking tiles and find an alternative if they are.
Position startPos = psDroid->pos;
Position endPos = Position(tX, tY, 0);
- BASE_OBJECT *dstStructure = worldTile(endPos)->psObject;
+ StructureBounds dstStructure = getStructureBounds(worldTile(endPos)->psObject);
startPos = findNonblockingPosition(startPos, getPropulsionStats(psDroid)->propulsionType, psDroid->player, moveType);
- if (dstStructure == NULL) // If there's a structure over the destination, ignore it, otherwise pathfind from somewhere around the obstruction.
+ if (!dstStructure.valid()) // If there's a structure over the destination, ignore it, otherwise pathfind from somewhere around the obstruction.
{
endPos = findNonblockingPosition(endPos, getPropulsionStats(psDroid)->propulsionType, psDroid->player, moveType);
}
objTrace(psDroid->id, "Want to go to (%d, %d) -> (%d, %d), going (%d, %d) -> (%d, %d)", map_coord(psDroid->pos.x), map_coord(psDroid->pos.y), map_coord(tX), map_coord(tY), map_coord(startPos.x), map_coord(startPos.y), map_coord(endPos.x), map_coord(endPos.y));
switch (psDroid->order.type)
{
case DORDER_BUILD:
+ case DORDER_LINEBUILD: // build a number of structures in a row (walls + bridges)
+ dstStructure = getStructureBounds(psDroid->order.psStats, psDroid->order.pos, psDroid->order.direction); // Just need to get close enough to build (can be diagonally), do not need to reach the destination tile.
+ // Continue, do not break.
case DORDER_HELPBUILD: // help to build a structure
- case DORDER_LINEBUILD: // 6 - build a number of structures in a row (walls + bridges)
case DORDER_DEMOLISH: // demolish a structure
case DORDER_REPAIR:
acceptNearest = false;
@@ -574,7 +576,7 @@ static int fpathResultQueueLength(void)
// Only used by fpathTest.
static FPATH_RETVAL fpathSimpleRoute(MOVE_CONTROL *psMove, int id, int startX, int startY, int tX, int tY)
{
- return fpathRoute(psMove, id, startX, startY, tX, tY, PROPULSION_TYPE_WHEELED, DROID_WEAPON, FMT_BLOCK, 0, true, NULL);
+ return fpathRoute(psMove, id, startX, startY, tX, tY, PROPULSION_TYPE_WHEELED, DROID_WEAPON, FMT_BLOCK, 0, true, getStructureBounds((BASE_OBJECT *)NULL));
}
void fpathTest(int x, int y, int x2, int y2)
View
12 src/game.cpp
@@ -4284,7 +4284,17 @@ static bool loadSaveDroid(const char *pFileName, DROID **ppsCurrentDroidLists)
}
else
{
- psDroid->psGroup = NULL;
+ if (psDroid->droidType == DROID_TRANSPORTER
+ || psDroid->droidType == DROID_SUPERTRANSPORTER
+ || psDroid->droidType == DROID_COMMAND)
+ {
+ DROID_GROUP *psGroup = grpCreate();
+ psGroup->add(psDroid);
+ }
+ else
+ {
+ psDroid->psGroup = NULL;
+ }
}
psDroid->died = ini.value("died", 0).toInt();
psDroid->lastEmission = ini.value("lastEmission", 0).toInt();
View
2 src/hci.cpp
@@ -5436,7 +5436,7 @@ static BASE_STATS *getResearchStats(BASE_OBJECT *psObj)
psBuilding = (STRUCTURE *)psObj;
psResearchFacility = &psBuilding->pFunctionality->researchFacility;
- if (psResearchFacility->psSubjectPending != NULL)
+ if (psResearchFacility->psSubjectPending != NULL && !IsResearchCompleted(&asPlayerResList[psObj->player][psResearchFacility->psSubjectPending->index]))
{
return psResearchFacility->psSubjectPending;
}
View
29 src/radar.cpp
@@ -253,22 +253,8 @@ void CalcRadarPosition(int mX, int mY, int *PosX, int *PosY)
#endif
// old safety code -- still necessary?
- if (sPosX < scrollMinX)
- {
- sPosX = scrollMinX;
- }
- else if (sPosX > scrollMaxX)
- {
- sPosX = scrollMaxX;
- }
- if (sPosY < scrollMinY)
- {
- sPosY = scrollMinY;
- }
- else if (sPosY > scrollMaxY)
- {
- sPosY = scrollMaxY;
- }
+ sPosX = clip(sPosX, scrollMinX, scrollMaxX);
+ sPosY = clip(sPosY, scrollMinY, scrollMaxY);
*PosX = sPosX;
*PosY = sPosY;
@@ -582,8 +568,7 @@ static void RotateVector2D(Vector3i *Vector, Vector3i *TVector, Vector3i *Pos, i
static SDWORD getDistanceAdjust( void )
{
- UDWORD origDistance = MAXDISTANCE;
- SDWORD dif = MAX(origDistance - getViewDistance(), 0);
+ int dif = std::max<int>(MAXDISTANCE - getViewDistance(), 0);
return dif / 100;
}
@@ -631,8 +616,8 @@ static void drawViewingWindow(float radarX, float radarY, int x, int y, float pi
v[3].x = -shortX;
v[3].y = yDrop;
- centre.x = radarX + x - scrollMinX*pixSizeH/2;
- centre.y = radarY + y - scrollMinY*pixSizeV/2;
+ centre.x = radarX + x - scrollMinX*pixSizeH;
+ centre.y = radarY + y - scrollMinY*pixSizeV;
RotateVector2D(v,tv,&centre,player.r.y,4);
@@ -666,8 +651,8 @@ static void drawViewingWindow(float radarX, float radarY, int x, int y, float pi
static void DrawRadarExtras(float radarX, float radarY, float pixSizeH, float pixSizeV)
{
- int viewX = (player.p.x / TILE_UNITS) * pixSizeH;
- int viewY = (player.p.z / TILE_UNITS) * pixSizeV;
+ int viewX = player.p.x*pixSizeH / TILE_UNITS;
+ int viewY = player.p.z*pixSizeV / TILE_UNITS;
drawViewingWindow(radarX, radarY, viewX, viewY, pixSizeH, pixSizeV);
RenderWindowFrame(FRAME_RADAR, radarX - 1, radarY - 1, radarWidth + 2, radarHeight + 2);
View
89 src/structure.cpp
@@ -341,14 +341,8 @@ void resetFactoryNumFlag(void)
{
for (int type = 0; type < NUM_FLAG_TYPES; type++)
{
- if (factoryNumFlag[i][type].size())
- {
// reset them all to false
- for (int k = 0; k < MAX_FACTORY; k++)
- {
- factoryNumFlag[i][type][k] = false;
- }
- }
+ factoryNumFlag[i][type].clear();
}
//look through the list of structures to see which have been used
for (STRUCTURE *psStruct = apsStructLists[i]; psStruct != NULL; psStruct = psStruct->psNext)
@@ -363,22 +357,28 @@ void resetFactoryNumFlag(void)
default: continue;
}
+ int inc = -1;
if (type == REPAIR_FLAG)
{
REPAIR_FACILITY *psRepair = &psStruct->pFunctionality->repairFacility;
if (psRepair->psDeliveryPoint != NULL)
{
- factoryNumFlag[i][type][psRepair->psDeliveryPoint->factoryInc] = true;
+ inc = psRepair->psDeliveryPoint->factoryInc;
}
}
else
{
FACTORY *psFactory = &psStruct->pFunctionality->factory;
if (psFactory->psAssemblyPoint != NULL)
{
- factoryNumFlag[i][type][psFactory->psAssemblyPoint->factoryInc] = true;
+ inc = psFactory->psAssemblyPoint->factoryInc;
}
}
+ if (inc >= 0)
+ {
+ factoryNumFlag[i][type].resize(std::max<size_t>(factoryNumFlag[i][type].size(), inc + 1), false);
+ factoryNumFlag[i][type][inc] = true;
+ }
}
}
}
@@ -3687,21 +3687,24 @@ void structureUpdate(STRUCTURE *psBuilding, bool mission)
}
}
- if (psBuilding->status == SS_BEING_BUILT && psBuilding->buildRate == 0 && !structureHasModules(psBuilding))
+ if (!mission)
{
- if (psBuilding->pStructureType->powerToBuild == 0)
+ if (psBuilding->status == SS_BEING_BUILT && psBuilding->buildRate == 0 && !structureHasModules(psBuilding))
{
- // Building is free, and not currently being built, so deconstruct slowly over 1 minute.
- psBuilding->currentBuildPts -= std::min<int>(psBuilding->currentBuildPts, gameTimeAdjustedAverage(psBuilding->pStructureType->buildPoints, 60));
- }
+ if (psBuilding->pStructureType->powerToBuild == 0)
+ {
+ // Building is free, and not currently being built, so deconstruct slowly over 1 minute.
+ psBuilding->currentBuildPts -= std::min<int>(psBuilding->currentBuildPts, gameTimeAdjustedAverage(psBuilding->pStructureType->buildPoints, 60));
+ }
- if (psBuilding->currentBuildPts == 0)
- {
- removeStruct(psBuilding, true); // If giving up on building something, remove the structure (and remove it from the power queue).
+ if (psBuilding->currentBuildPts == 0)
+ {
+ removeStruct(psBuilding, true); // If giving up on building something, remove the structure (and remove it from the power queue).
+ }
}
+ psBuilding->lastBuildRate = psBuilding->buildRate;
+ psBuilding->buildRate = 0; // Reset to 0, each truck building us will add to our buildRate.
}
- psBuilding->lastBuildRate = psBuilding->buildRate;
- psBuilding->buildRate = 0; // Reset to 0, each truck building us will add to our buildRate.
/* Only add smoke if they're visible and they can 'burn' */
if (!mission && psBuilding->visible[selectedPlayer] && canSmoke(psBuilding))
@@ -5010,40 +5013,30 @@ void setAssemblyPoint(FLAG_POSITION *psAssemblyPoint, UDWORD x, UDWORD y,
void setFlagPositionInc(FUNCTIONALITY* pFunctionality, UDWORD player, UBYTE factoryType)
{
ASSERT_OR_RETURN( , player < MAX_PLAYERS, "invalid player number");
- if (!factoryNumFlag[player][factoryType].size())
+
+ //find the first vacant slot
+ unsigned inc = std::find(factoryNumFlag[player][factoryType].begin(), factoryNumFlag[player][factoryType].end(), false) - factoryNumFlag[player][factoryType].begin();
+ if (inc == factoryNumFlag[player][factoryType].size())
{
- // first time init for this factory type, set them all to false
- for (int k = 0; k < MAX_FACTORY; k++)
- {
- factoryNumFlag[player][factoryType].push_back(false);
- }
+ // first time init for this factory flag slot, set it to false
+ factoryNumFlag[player][factoryType].push_back(false);
}
- //find the first vacant slot
- for (unsigned inc = 0; inc < factoryNumFlag[player][factoryType].size(); ++inc)
+ if (factoryType == REPAIR_FLAG)
{
- if (!factoryNumFlag[player][factoryType][inc])
- {
- if (factoryType == REPAIR_FLAG)
- {
- // this is a special case, there are no flag numbers for this "factory"
- REPAIR_FACILITY *psRepair = &pFunctionality->repairFacility;
- psRepair->psDeliveryPoint->factoryInc = 0;
- psRepair->psDeliveryPoint->factoryType = factoryType;
- // factoryNumFlag[player][factoryType][inc] = true;
- }
- else
- {
- FACTORY *psFactory = &pFunctionality->factory;
- psFactory->psAssemblyPoint->factoryInc = inc;
- psFactory->psAssemblyPoint->factoryType = factoryType;
- factoryNumFlag[player][factoryType][inc] = true;
- }
- return;
- }
+ // this is a special case, there are no flag numbers for this "factory"
+ REPAIR_FACILITY *psRepair = &pFunctionality->repairFacility;
+ psRepair->psDeliveryPoint->factoryInc = 0;
+ psRepair->psDeliveryPoint->factoryType = factoryType;
+ // factoryNumFlag[player][factoryType][inc] = true;
+ }
+ else
+ {
+ FACTORY *psFactory = &pFunctionality->factory;
+ psFactory->psAssemblyPoint->factoryInc = inc;
+ psFactory->psAssemblyPoint->factoryType = factoryType;
+ factoryNumFlag[player][factoryType][inc] = true;
}
- debug(LOG_ERROR, "We have too many factories of type %d, player %d", factoryType, player);
- ASSERT( false, "Can't set flag!");
}
/*called when a structure has been built - checks through the list of callbacks

0 comments on commit 69c4474

Please sign in to comment.