My Hopeful final attempt to fix placement on buildings under fog
This commit is contained in:
parent
20a82a800e
commit
9d6c6fb682
4 changed files with 10 additions and 26 deletions
src
|
@ -143,8 +143,9 @@ global void HandleActionBuild(Unit* unit)
|
|||
|
||||
//
|
||||
// Check if the building could be build there.
|
||||
// 1 really attempt to build here
|
||||
//
|
||||
if (!CanBuildUnitType(unit, type, x, y)) {
|
||||
if (!CanBuildUnitType(unit, type, x, y, 1)) {
|
||||
//
|
||||
// Some tries to build the building.
|
||||
//
|
||||
|
|
|
@ -839,9 +839,7 @@ extern int CanBuildHere(const UnitType* type, int x, int y);
|
|||
/// FIXME: more docu
|
||||
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);
|
||||
extern int CanBuildUnitType(const Unit* unit,const UnitType* type, int x, int y, int real);
|
||||
|
||||
/// Find resource
|
||||
extern Unit* FindResource(const Unit* unit, int x, int y, int range, int resource);
|
||||
|
|
|
@ -1447,8 +1447,8 @@ global void UIHandleButtonDown(unsigned button)
|
|||
}
|
||||
}
|
||||
}
|
||||
if (CanBuildUnitTypeMask(Selected[0], CursorBuilding, x, y,
|
||||
Selected[0]->Type->MovementMask) &&
|
||||
// 0 Test build, don't really build
|
||||
if (CanBuildUnitType(Selected[0], CursorBuilding, x, y, 0) &&
|
||||
(explored || ReplayRevealMap)) {
|
||||
PlayGameSound(GameSounds.PlacementSuccess.Sound,
|
||||
MaxSampleVolume);
|
||||
|
|
|
@ -2081,27 +2081,12 @@ global int CanBuildOn(int x, int y, int mask)
|
|||
** @param type Building unit-type.
|
||||
** @param x X tile map position.
|
||||
** @param y Y tile map position.
|
||||
** @param real Really build, or just placement
|
||||
** @return True if the building could be build..
|
||||
**
|
||||
** @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)
|
||||
global int CanBuildUnitType(const Unit* unit, const UnitType* type, int x, int y, int real)
|
||||
{
|
||||
int w;
|
||||
int h;
|
||||
|
@ -2210,10 +2195,10 @@ global int CanBuildUnitTypeMask(const Unit* unit, const UnitType* type, int x, i
|
|||
|
||||
for (h = type->TileHeight; h--;) {
|
||||
for (w = type->TileWidth; w--;) {
|
||||
if (player) {
|
||||
testmask = MapFogFilterFlags(player, x + w, y + h, mask);
|
||||
if (player && !real) {
|
||||
testmask = MapFogFilterFlags(player, x + w, y + h, type->MovementMask);
|
||||
} else {
|
||||
testmask = mask;
|
||||
testmask = type->MovementMask;
|
||||
}
|
||||
if (!CanBuildOn(x + w, y + h, testmask)) {
|
||||
if (unit) {
|
||||
|
|
Loading…
Add table
Reference in a new issue