From ddbcd6cdf8fab1aefa152e929c9aa7edc3cc3ec7 Mon Sep 17 00:00:00 2001 From: wizzard <> Date: Sat, 31 Jan 2004 06:57:26 +0000 Subject: [PATCH] Fixed Bug #7294: Building cursor over hidden building --- doc/ChangeLog.html | 1 + src/include/unit.h | 2 ++ src/ui/mouse.cpp | 3 ++- src/unit/unit.cpp | 19 ++++++++++++++++--- src/video/cursor.cpp | 5 +++-- 5 files changed, 24 insertions(+), 6 deletions(-) diff --git a/doc/ChangeLog.html b/doc/ChangeLog.html index b41d8360d..2a2667286 100644 --- a/doc/ChangeLog.html +++ b/doc/ChangeLog.html @@ -36,6 +36,7 @@ <li>Future 2.00 Release<p> <ul> <li>++ + <li>Fixed Bug #7294: Building cursor over hidden building (from Russell Smith). <li>Fixed Bug #7411: crash when loading this saved game(Magnant) (from Russell Smith). <li>Drawing mirror images for units and missiles facing left is optional (from Jimmy Salmon). <li>Moved cheat codes out of the engine and into ccl (from Jimmy Salmon). diff --git a/src/include/unit.h b/src/include/unit.h index 2497d06de..dab102aeb 100644 --- a/src/include/unit.h +++ b/src/include/unit.h @@ -840,6 +840,8 @@ extern int CanBuildHere(const UnitType* type, int x, int y); extern int CanBuildOn(int x, int y, int mask); /// FIXME: more docu extern int CanBuildUnitType(const Unit* unit,const UnitType* type, int x, int y); + /// FIXME: more docu +extern int CanBuildUnitTypeMask(const Unit* unit,const UnitType* type, int x, int y, int mask); /// Find resource extern Unit* FindResource(const Unit* unit, int x, int y, int range, int resource); diff --git a/src/ui/mouse.cpp b/src/ui/mouse.cpp index ef789616f..8cc2186e2 100644 --- a/src/ui/mouse.cpp +++ b/src/ui/mouse.cpp @@ -1447,7 +1447,8 @@ global void UIHandleButtonDown(unsigned button) } } } - if (CanBuildUnitType(Selected[0], CursorBuilding, x, y) && + if (CanBuildUnitTypeMask(Selected[0], CursorBuilding, x, y, + Selected[0]->Type->MovementMask & ~(MapFieldBuilding | MapFieldLandUnit | MapFieldSeaUnit)) && (explored || ReplayRevealMap)) { PlayGameSound(GameSounds.PlacementSuccess.Sound, MaxSampleVolume); diff --git a/src/unit/unit.cpp b/src/unit/unit.cpp index 2ec50872f..f8e96160e 100644 --- a/src/unit/unit.cpp +++ b/src/unit/unit.cpp @@ -2086,11 +2086,26 @@ global int CanBuildOn(int x, int y, int mask) ** @todo can't handle building units !1x1, needs a rewrite. */ global int CanBuildUnitType(const Unit* unit, const UnitType* type, int x, int y) +{ + return CanBuildUnitTypeMask(unit, type, x, y, type->MovementMask); +} +/** +** Can build unit-type on this point. +** +** @param unit Worker that want to build the building or NULL. +** @param type Building unit-type. +** @param x X tile map position. +** @param y Y tile map position. +** @param mask movement mask to check +** @return True if the building could be build.. +** +** @todo can't handle building units !1x1, needs a rewrite. +*/ +global int CanBuildUnitTypeMask(const Unit* unit, const UnitType* type, int x, int y, int mask) { int w; int h; int j; - int mask; Player* player; // Terrain Flags don't matter. @@ -2184,8 +2199,6 @@ global int CanBuildUnitType(const Unit* unit, const UnitType* type, int x, int y } #else - mask = type->MovementMask; - #endif player = NULL; diff --git a/src/video/cursor.cpp b/src/video/cursor.cpp index 3ab410027..6f6f06d0f 100644 --- a/src/video/cursor.cpp +++ b/src/video/cursor.cpp @@ -546,12 +546,13 @@ local void DrawBuildingCursor(void) w = w0; while (w--) { - // FIXME: The field is covered by fog of war! if (f && (CursorBuilding->MustBuildOnTop || CanBuildOn(mx + w, my + h, mask & ((NumSelected && !CursorBuilding->BuilderOutside && Selected[0]->X == mx + w && Selected[0]->Y == my + h) ? - ~(MapFieldLandUnit | MapFieldSeaUnit) : -1))) + ~(MapFieldLandUnit | MapFieldSeaUnit) : -1) & + (IsTileVisible(ThisPlayer, mx + w, my + h) == 1 ? + ~(MapFieldLandUnit | MapFieldSeaUnit | MapFieldBuilding) : -1))) && IsMapFieldExplored(ThisPlayer, mx + w, my + h)) { color = ColorGreen; } else {