[-] Fixed bug with forest regeneration

[-] Fixed bug when ordering an order to worker if it have done its work near depot
This commit is contained in:
cybermind 2015-03-13 23:39:49 +05:00
parent 6837d4d02c
commit 47ca183ee7
7 changed files with 27 additions and 7 deletions

View file

@ -940,6 +940,10 @@ int COrder_Resource::MoveToDepot(CUnit &unit)
CPlayer &player = *unit.Player;
Assert(&goal);
if (this->Finished) {
return 0; // Could happen when mining near to depot
}
switch (DoActionMove(unit)) { // reached end-point?
case PF_UNREACHABLE:
return -1;

View file

@ -88,8 +88,8 @@ public:
*enemy = AttackUnitsInDistance(*unit, MaxMapWidth);
} else if (FIND_TYPE == AIATTACK_BUILDING) {
*enemy = AttackUnitsInDistance(*unit, MaxMapWidth, IsBuildingType());
Assert(!*enemy || (*enemy)->Type->Building);
if (*enemy == NULL) {
Assert(!*enemy);
if (*enemy == NULL || !(*enemy)->Type->Building) {
*enemy = AttackUnitsInDistance(*unit, MaxMapWidth);
}
} else if (FIND_TYPE == AIATTACK_AGRESSIVE) {

View file

@ -94,7 +94,7 @@ static unsigned QuadFromTile(const Vec2i &pos)
** @param tileIndex Tile type to edit.
** @param d Fix direction flag 8 up, 4 down, 2 left, 1 right.
*/
static void EditorChangeTile(const Vec2i &pos, int tileIndex, int d)
void EditorChangeTile(const Vec2i &pos, int tileIndex, int d)
{
Assert(Map.Info.IsPointOnMap(pos));

View file

@ -132,6 +132,7 @@ extern void EditorCclRegister();
/// Update surroundings for tile changes
extern void EditorTileChanged(const Vec2i &pos);
extern void EditorChangeTile(const Vec2i &pos, int tileIndex, int d);
//@}

View file

@ -135,6 +135,7 @@ public:
unsigned getRemovedTreeTile() const { return removedTreeTile; }
unsigned getBottomOneTreeTile() const { return botOneTreeTile; }
unsigned getTopOneTreeTile() const { return topOneTreeTile; }
unsigned getMidOneTreeTile() const { return midOneTreeTile; }
unsigned getHumanWallTileIndex(int dirFlag) const;
unsigned getOrcWallTileIndex(int dirFlag) const;

View file

@ -583,25 +583,36 @@ void CMap::RegenerateForestTile(const Vec2i &pos)
if ((mf.Flags & occupedFlag) || pos.y == 0) {
return;
}
const Vec2i offset(0, -1);
CMapField &topMf = *(&mf - this->Info.MapWidth);
if (topMf.getGraphicTile() == this->Tileset->getRemovedTreeTile()
&& topMf.Value >= ForestRegeneration
&& !(topMf.Flags & occupedFlag)) {
DebugPrint("Real place wood\n");
topMf.setGraphicTile(this->Tileset->getTopOneTreeTile());
topMf.setTileIndex(*Map.Tileset, Map.Tileset->getTopOneTreeTile(), 0);
topMf.setGraphicTile(Map.Tileset->getTopOneTreeTile());
topMf.playerInfo.SeenTile = topMf.getGraphicTile();
topMf.Value = 0;
topMf.Flags |= MapFieldForest | MapFieldUnpassable;
UI.Minimap.UpdateSeenXY(pos + offset);
UI.Minimap.UpdateXY(pos + offset);
mf.setGraphicTile(this->Tileset->getBottomOneTreeTile());
mf.setTileIndex(*Map.Tileset, Map.Tileset->getBottomOneTreeTile(), 0);
mf.setGraphicTile(Map.Tileset->getBottomOneTreeTile());
mf.playerInfo.SeenTile = mf.getGraphicTile();
mf.Value = 0;
mf.Flags |= MapFieldForest | MapFieldUnpassable;
UI.Minimap.UpdateSeenXY(pos);
UI.Minimap.UpdateXY(pos);
if (mf.playerInfo.IsTeamVisible(*ThisPlayer)) {
MarkSeenTile(mf);
}
const Vec2i offset(0, -1);
if (Map.Field(pos + offset)->playerInfo.IsTeamVisible(*ThisPlayer)) {
MarkSeenTile(mf);
MarkSeenTile(topMf);
}
FixNeighbors(MapFieldForest, 0, pos + offset);
FixNeighbors(MapFieldForest, 0, pos);
}
}

View file

@ -495,6 +495,9 @@ static void DoRightButton_ForSelectedUnit(CUnit &unit, CUnit *dest, const Vec2i
if (dest == &unit) {
return;
}
if (unit.Removed) {
return;
}
const CUnitType &type = *unit.Type;
const int action = type.MouseAction;
// Right mouse with SHIFT appends command to old commands.