forked from Mirrors/openclonk
+ HasCNAT() in Commits.c, prevent endless loop in plant
parent
b00a192a61
commit
e8447f4133
|
@ -11,13 +11,16 @@
|
|||
*/
|
||||
global func RootSurface()
|
||||
{
|
||||
while(GetContact(-1) & CNAT_Center) SetPosition(GetX(),GetY()-1); //Move up if too far underground
|
||||
if (HasCNAT(CNAT_Center)) while(GetContact(-1) & CNAT_Center) SetPosition(GetX(),GetY()-1); //Move up if too far underground
|
||||
if (HasCNAT(CNAT_Bottom))
|
||||
{
|
||||
var moved_down = false;
|
||||
if (!(GetContact(-1) & CNAT_Bottom)) moved_down = true;
|
||||
while(!(GetContact(-1) & CNAT_Bottom)) SetPosition(GetX(),GetY()+1); //Move down if in midair
|
||||
|
||||
if (moved_down) SetPosition(GetX(),GetY()+1); // make the plant stuck, not just contact with surface (in case it was moved down)
|
||||
}
|
||||
}
|
||||
|
||||
/* Local */
|
||||
|
||||
|
|
|
@ -112,6 +112,15 @@ global func VerticesStuck()
|
|||
return vertices;
|
||||
}
|
||||
|
||||
// Returns whether the object has a vertex with the given CNAT value
|
||||
global func HasCNAT(int cnat)
|
||||
{
|
||||
for(var i = -1; i < GetVertexNum(); i++)
|
||||
if (GetVertex(i, VTX_CNAT) == cnat)
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
// Creates amount objects of type id inside the indicated rectangle(optional) in the indicated material.
|
||||
// Returns the number of iterations needed, or -1 when the placement failed.
|
||||
global func PlaceObjects(id id, int amount, string mat_str, int x, int y, int wdt, int hgt, bool onsf, bool nostuck)
|
||||
|
|
Loading…
Reference in New Issue