Fixed Bug : Building cursor over hidden building

This commit is contained in:
wizzard 2004-01-31 06:57:26 +00:00
parent 3a52711a06
commit ddbcd6cdf8
5 changed files with 24 additions and 6 deletions

View file

@ -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).

View file

@ -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);

View file

@ -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);

View file

@ -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;

View file

@ -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 {