forked from Mirrors/openclonk
block construction sites based on Exclusive and not on planes (#1534)
This makes more sense, exclusive object block all other construction sites, irrespective of their planes.stable-7
parent
8d63ddfdef
commit
46b977e506
|
@ -128,7 +128,7 @@
|
|||
<row>
|
||||
<literal_col>Exclusive</literal_col>
|
||||
<col>Integer</col>
|
||||
<col>0 or 1. Determines whether the object blocks objects behind it.</col>
|
||||
<col>0 or 1. Determines whether the object blocks objects behind it. Exclusive objects also block the placement of a construction site at an overlapping location.</col>
|
||||
</row>
|
||||
<row>
|
||||
<literal_col>Line</literal_col>
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
<subcat>OCF</subcat>
|
||||
<version>5.1 OC</version>
|
||||
<syntax><rtype>int</rtype></syntax>
|
||||
<desc>Object character flag: the object blocks (covers) objects behind it and prevents other objects from being built in front. This flag is set by <emlink href="definition/defcore.html">DefCore</emlink> entry "Exclusive".</desc>
|
||||
<desc>Object character flag: the object blocks (covers) objects behind it and prevents construction sites from being built in front of it. This flag is set by <emlink href="definition/defcore.html">DefCore</emlink> entry "Exclusive".</desc>
|
||||
<remark>For more information and examples regarding these constants see <emlink href="definition/ocf.html">object character flags</emlink>.</remark>
|
||||
<related>
|
||||
<funclink>GetOCF</funclink>
|
||||
|
|
|
@ -1113,7 +1113,8 @@ C4Object* C4Game::CreateObjectConstruction(C4PropList * PropList,
|
|||
return pObj;
|
||||
}
|
||||
|
||||
C4Object* C4Game::OverlapObject(int32_t tx, int32_t ty, int32_t wdt, int32_t hgt, int32_t Plane)
|
||||
// Finds an object (OCF_Exclusive) that blocks a potential construction site in the given rectangle
|
||||
C4Object* C4Game::FindConstuctionSiteBlock(int32_t tx, int32_t ty, int32_t wdt, int32_t hgt)
|
||||
{
|
||||
C4Rect rect1,rect2;
|
||||
rect1.x=tx; rect1.y=ty; rect1.Wdt=wdt; rect1.Hgt=hgt;
|
||||
|
@ -1121,7 +1122,7 @@ C4Object* C4Game::OverlapObject(int32_t tx, int32_t ty, int32_t wdt, int32_t hgt
|
|||
for (C4ObjectList *pObjs = Area.FirstObjectShapes(&pSector); pSector; pObjs = Area.NextObjectShapes(pObjs, &pSector))
|
||||
for (C4Object *cObj : *pObjs)
|
||||
if (cObj->Status && !cObj->Contained)
|
||||
if (cObj->GetPlane() == Plane)
|
||||
if (cObj->OCF & OCF_Exclusive)
|
||||
{
|
||||
rect2=cObj->Shape; rect2.x+=cObj->GetX(); rect2.y+=cObj->GetY();
|
||||
if (rect1.Overlap(rect2)) return cObj;
|
||||
|
|
|
@ -191,7 +191,7 @@ public:
|
|||
int32_t con=1, bool terrain=false);
|
||||
C4Object *CreateInfoObject(C4ObjectInfo *cinf, int32_t owner,
|
||||
int32_t tx=50, int32_t ty=50);
|
||||
C4Object *OverlapObject(int32_t tx, int32_t ty, int32_t wdt, int32_t hgt, int32_t Plane);
|
||||
C4Object *FindConstuctionSiteBlock(int32_t tx, int32_t ty, int32_t wdt, int32_t hgt);
|
||||
C4Object *FindObject(C4Def * pDef,
|
||||
int32_t iX=0, int32_t iY=0, int32_t iWdt=0, int32_t iHgt=0,
|
||||
DWORD ocf=OCF_All,
|
||||
|
|
|
@ -219,10 +219,7 @@ static C4ValueArray *FnFindConstructionSite(C4PropList * _this, C4PropList * Pro
|
|||
if (ConstructionCheck(PropList,v1,v2))
|
||||
return NULL;
|
||||
// Search for real
|
||||
bool result = !!FindConSiteSpot(v1, v2,
|
||||
pDef->Shape.Wdt,pDef->Shape.Hgt,
|
||||
pDef->GetPlane(),
|
||||
20);
|
||||
bool result = !!FindConSiteSpot(v1, v2, pDef->Shape.Wdt,pDef->Shape.Hgt, 20);
|
||||
if(!result) return 0;
|
||||
C4ValueArray *pArray = new C4ValueArray(2);
|
||||
pArray->SetItem(0, C4VInt(v1));
|
||||
|
|
|
@ -2709,8 +2709,7 @@ bool FindLevelGround(int32_t &rx, int32_t &ry, int32_t width, int32_t hrange)
|
|||
|
||||
// Starting from rx/ry, searches for a width of solid level ground with
|
||||
// structure clearance (category). Returns bottom center of surface found.
|
||||
bool FindConSiteSpot(int32_t &rx, int32_t &ry, int32_t wdt, int32_t hgt,
|
||||
int32_t Plane, int32_t hrange)
|
||||
bool FindConSiteSpot(int32_t &rx, int32_t &ry, int32_t wdt, int32_t hgt, int32_t hrange)
|
||||
{
|
||||
bool fFound=false;
|
||||
|
||||
|
@ -2762,10 +2761,10 @@ bool FindConSiteSpot(int32_t &rx, int32_t &ry, int32_t wdt, int32_t hgt,
|
|||
|
||||
// Check runs & object overlap
|
||||
if (rl1>=wdt) if (cx1>0)
|
||||
if (!Game.OverlapObject(cx1,cy1-hgt-10,wdt,hgt+40,Plane))
|
||||
if (!Game.FindConstuctionSiteBlock(cx1,cy1-hgt-10,wdt,hgt+40))
|
||||
{ rx=cx1+wdt/2; ry=cy1; fFound=true; break; }
|
||||
if (rl2>=wdt) if (cx2<GBackWdt)
|
||||
if (!Game.OverlapObject(cx2-wdt,cy2-hgt-10,wdt,hgt+40,Plane))
|
||||
if (!Game.FindConstuctionSiteBlock(cx2-wdt,cy2-hgt-10,wdt,hgt+40))
|
||||
{ rx=cx2-wdt/2; ry=cy2; fFound=true; break; }
|
||||
}
|
||||
|
||||
|
@ -2992,7 +2991,7 @@ bool ConstructionCheck(C4PropList * PropList, int32_t iX, int32_t iY, C4Object *
|
|||
}
|
||||
// Check other structures
|
||||
C4Object *other;
|
||||
if ((other=Game.OverlapObject(rtx,rty,wdt,hgt,ndef->GetPlane())))
|
||||
if ((other=Game.FindConstuctionSiteBlock(rtx,rty,wdt,hgt)))
|
||||
{
|
||||
if (pByObj) GameMsgObjectError(FormatString(LoadResStr("IDS_OBJ_NOOTHER"),other->GetName ()).getData(),pByObj);
|
||||
return false;
|
||||
|
|
|
@ -352,7 +352,7 @@ bool FindLiquid(int32_t &rx, int32_t &ry, int32_t width, int32_t height);
|
|||
bool FindTunnel(int32_t &rx, int32_t &ry, int32_t width, int32_t height);
|
||||
bool FindSurfaceLiquid(int32_t &rx, int32_t &ry, int32_t width, int32_t height);
|
||||
bool FindLevelGround(int32_t &rx, int32_t &ry, int32_t width, int32_t hrange);
|
||||
bool FindConSiteSpot(int32_t &rx, int32_t &ry, int32_t wdt, int32_t hgt, int32_t Plane, int32_t hrange=-1);
|
||||
bool FindConSiteSpot(int32_t &rx, int32_t &ry, int32_t wdt, int32_t hgt, int32_t hrange=-1);
|
||||
bool FindThrowingPosition(int32_t iTx, int32_t iTy, C4Real fXDir, C4Real fYDir, int32_t iHeight, int32_t &rX, int32_t &rY);
|
||||
bool PathFree(int32_t x1, int32_t y1, int32_t x2, int32_t y2);
|
||||
bool PathFree(int32_t x1, int32_t y1, int32_t x2, int32_t y2, int32_t *ix, int32_t *iy);
|
||||
|
|
|
@ -517,7 +517,7 @@ void C4Player::PlaceReadyBase(int32_t &tx, int32_t &ty, C4Object **pFirstBase)
|
|||
{
|
||||
ctx=tx; cty=ty;
|
||||
if (Game.C4S.PlrStart[PlrStartIndex].EnforcePosition
|
||||
|| FindConSiteSpot(ctx,cty,def->Shape.Wdt,def->Shape.Hgt,def->GetPlane(),20))
|
||||
|| FindConSiteSpot(ctx,cty,def->Shape.Wdt,def->Shape.Hgt,20))
|
||||
if ((cbase=Game.CreateObjectConstruction(C4Id2Def(cid),NULL,Number,ctx,cty,FullCon,true)))
|
||||
{
|
||||
// FirstBase
|
||||
|
@ -644,7 +644,7 @@ bool C4Player::ScenarioInit()
|
|||
// Use nearest above-ground...
|
||||
FindSolidGround(ptx,pty,30);
|
||||
// Might have hit a small lake, or similar: Seach a real site spot from here
|
||||
FindConSiteSpot(ptx, pty, 30,50,C4Plane_Structure, 400);
|
||||
FindConSiteSpot(ptx, pty, 30, 50, 400);
|
||||
}
|
||||
|
||||
// Place Readies
|
||||
|
|
Loading…
Reference in New Issue