37 if (!pArray)
return nullptr;
40 int32_t iType = Data[0].getInt();
45 if (!ppSortObj)
return nullptr;
58 if (!pCond)
return nullptr;
71 for (i = 0; i < Data.
GetSize() - 1; i++)
75 for (i = 0; i < Data.
GetSize() - 1; i++)
78 ppConds[
iSize-1] = ppConds[i];
89 if (!obj)
return nullptr;
101 int32_t x = Data[1].getInt();
102 int32_t y = Data[2].getInt();
103 int32_t w = Data[3].getInt();
104 int32_t h = Data[4].getInt();
107 x += context->
GetX();
108 y += context->
GetY();
115 int32_t x = Data[1].getInt();
116 int32_t y = Data[2].getInt();
119 x += context->
GetX();
120 y += context->
GetY();
127 int32_t x = Data[1].getInt();
128 int32_t y = Data[2].getInt();
129 int32_t w = Data[3].getInt();
130 int32_t h = Data[4].getInt();
133 x += context->
GetX();
134 y += context->
GetY();
141 int32_t x1 = Data[1].getInt();
142 int32_t y1 = Data[2].getInt();
143 int32_t x2 = Data[3].getInt();
144 int32_t y2 = Data[4].getInt();
147 x1 += context->
GetX();
148 x2 += context->
GetX();
149 y1 += context->
GetY();
150 y2 += context->
GetY();
157 int32_t x = Data[1].getInt();
158 int32_t y = Data[2].getInt();
161 x += context->
GetX();
162 y += context->
GetY();
169 int32_t x = Data[1].getInt();
170 int32_t y = Data[2].getInt();
173 x += context->
GetX();
174 y += context->
GetY();
176 return new C4FindObjectCone(x, y, Data[3].getInt(), Data[4].getInt(), Data[5].getInt(), Data[6].getInt());
188 if (!pStr)
return nullptr;
197 if (!pStr)
return nullptr;
201 for (
int i = 2; i < Data.
GetSize(); i++)
202 pFO->
SetPar(i - 2, Data[i]);
211 index =
Clamp(Data[2].getInt(), 0, 1);
232 if (has_layer_check) *has_layer_check =
true;
242 if (!pStr)
return nullptr;
253 if (has_layer_check) *has_layer_check =
true;
270 if (obj->Status &&
Check(obj))
289 if (!pSort)
return obj;
291 if (!pBestResult || pSort->
Compare(obj, pBestResult) > 0)
321 CheckObjectStatus(pArray);
344 if (!Area.
Next(pSct))
352 if (obj->Marker != iMarker)
354 obj->Marker = iMarker;
366 iCount +=
Count(*pLst);
387 if ((pObj =
Find(*pLst)))
391 else if (!pBestResult || pSort->
Compare(pObj, pBestResult) > 0)
402 if ((pObj =
Find(*pLst)))
406 else if (!pBestResult || pSort->
Compare(pObj, pBestResult) > 0)
433 if (!Area.
Next(pSct))
442 if (obj->Marker != iMarker)
444 obj->Marker = iMarker;
476 CheckObjectStatus(pArray);
482 void C4FindObject::CheckObjectStatus(
C4ValueArray *pArray)
485 for (int32_t i = 0; i < pArray->
GetSize(); i++)
490 for (; i < pArray->
GetSize(); i++)
492 (*pArray)[j++] = pArray->
GetItem(i);
515 return !pCond->
Check(pObj);
521 :
iCnt(inCnt), ppConds(ppConds), fFreeArray(fFreeArray), fUseShapes(false), fHasBounds(false)
525 for (i = 0; i < iCnt; )
530 for (int32_t j = i; j <
iCnt; j++)
531 ppConds[j] = ppConds[j + 1];
536 for (i = 0; i <
iCnt; i++)
544 Bounds = *pChildBounds;
549 else if (fUseShapes == ppConds[i]->
UseShapes())
559 for (int32_t i = 0; i < iCnt; i++)
567 for (int32_t i = 0; i < iCnt; i++)
568 if (!ppConds[i]->
Check(pObj))
575 for (int32_t i = 0; i < iCnt; i++)
584 :
iCnt(inCnt), ppConds(ppConds), fHasBounds(false)
588 for (i = 0; i < iCnt; )
593 for (int32_t j = i; j <
iCnt; j++)
594 ppConds[j] = ppConds[j + 1];
599 for (i = 0; i <
iCnt; i++)
602 if (!pChildBounds) { fHasBounds =
false;
break; }
605 if (fHasBounds && fUseShapes != ppConds[i]->
UseShapes())
606 { fHasBounds =
false;
break; }
608 Bounds.
Add(*pChildBounds);
612 Bounds = *pChildBounds;
620 for (int32_t i = 0; i < iCnt; i++)
627 for (int32_t i = 0; i < iCnt; i++)
628 if (ppConds[i]->
Check(pObj))
635 for (int32_t i = 0; i < iCnt; i++)
645 return pObj != pExclude;
665 return !rect.
Wdt || !rect.
Hgt;
676 rcShapeBounds.
x += pObj->
GetX(); rcShapeBounds.
y += pObj->
GetY();
677 return !!rcShapeBounds.
Overlap(bounds);
687 return (pObj->
GetX() - x) * (pObj->
GetX() - x) + (pObj->
GetY() - y) * (pObj->
GetY() - y) <= r2;
692 bool in_circle = (pObj->
GetX() - x) * (pObj->
GetX() - x) + (pObj->
GetY() - y) * (pObj->
GetY() - y) <= r2;
693 int32_t obj_angle =
Angle(x, y, pObj->
GetX(), pObj->
GetY(), prec_angle);
694 bool in_cone =
Inside(obj_angle, cone_angle - cone_width, cone_angle + cone_width) ||
695 Inside(obj_angle - 360 * prec_angle, cone_angle - cone_width, cone_angle + cone_width) ||
696 Inside(obj_angle + 360 * prec_angle, cone_angle - cone_width, cone_angle + cone_width);
697 return in_circle && in_cone;
702 return !! (pObj->
OCF & ocf);
712 return !! (pObj->
Category & iCategory);
729 assert(index >= 0 && index <= 1);
766 return pObj->
Owner == iOwner;
810 return pObj->
Layer == pLayer;
823 if (!pArray)
return false;
824 int32_t sz = pArray->
GetSize();
825 for (
int i=0; i<sz; ++i)
833 return !pArray || !pArray->
GetSize();
857 if (!pArray)
return nullptr;
859 int32_t iType = Data[0].getInt();
871 if (!pChildSort)
return nullptr;
886 for (i = 0; i < Data.
GetSize() - 1; i++)
892 for (i = 0; i < Data.
GetSize() - 1; i++)
895 ppSorts[
iSize-1] = ppSorts[i];
902 int32_t x = Data[1].getInt();
903 int32_t y = Data[2].getInt();
906 x += context->
GetX();
907 y += context->
GetY();
928 if (!pStr)
return nullptr;
932 for (
int i = 2; i < Data.
GetSize(); i++)
933 pSO->
SetPar(i - 2, Data[i]);
956 delete [] pVals; pVals =
nullptr;
962 delete [] pVals; pVals =
nullptr; iSize = 0;
964 iSize = pObjs->
GetSize(); pVals =
new int32_t [iSize];
965 for (int32_t i = 0; i < iSize; i++)
978 return iValue2 - iValue1;
983 assert(pVals); assert(iObj1 >= 0 && iObj1 < iSize); assert(iObj2 >= 0 && iObj2 < iSize);
985 return pVals[iObj2] - pVals[iObj1];
995 return pSort->
Compare(pObj2, pObj1);
1005 return pSort->
CompareCache(iObj2, iObj1, pObj2, pObj1);
1010 for (int32_t i=0; i<iCnt; ++i)
delete ppSorts[i];
1011 if (fFreeArray)
delete [] ppSorts;
1018 for (int32_t i=0; i<iCnt; ++i)
1019 if ((iCmp = ppSorts[i]->
Compare(pObj1, pObj2)))
1027 bool fCaches =
false;
1028 for (int32_t i=0; i<iCnt; ++i)
1038 for (int32_t i=0; i<iCnt; ++i)
1039 if ((iCmp = ppSorts[i]->
CompareCache(iObj1, iObj2, pObj1, pObj2)))
1047 int32_t dx=pFor->
GetX()-iX, dy=pFor->
GetY()-iY;
1081 if (!Name)
return false;
int32_t ValidPlr(int32_t plr)
int fixtoi(const C4Fixed &x)
C4Value C4VObj(C4Object *pObj)
int32_t Angle(int32_t iX1, int32_t iY1, int32_t iX2, int32_t iY2, int32_t iPrec)
T Clamp(T bval, T lbound, T rbound)
bool SEqual(const char *szStr1, const char *szStr2)
bool Inside(T ival, U lbound, V rbound)
bool Check(C4Object *pObj) override
bool Check(C4Object *pObj) override
bool Check(C4Object *pObj) override
bool UseShapes() override
~C4FindObjectAnd() override
bool IsEnsured() override
bool IsImpossible() override
bool Check(C4Object *pObj) override
bool Check(C4Object *pObj) override
bool Check(C4Object *pObj) override
bool IsEnsured() override
bool Check(C4Object *pObj) override
bool Check(C4Object *pObj) override
bool Check(C4Object *pObj) override
bool Check(C4Object *pObj) override
bool IsImpossible() override
bool IsImpossible() override
bool Check(C4Object *pObj) override
bool Check(C4Object *pObj) override
bool Check(C4Object *pObj) override
bool IsImpossible() override
void SetPar(int i, const C4Value &val)
bool Check(C4Object *pObj) override
friend class C4FindObjectNot
friend class C4FindObjectAnd
C4ValueArray * FindMany(const C4ObjectList &Objs)
C4Object * Find(const C4ObjectList &Objs)
virtual bool IsImpossible()
virtual bool Check(C4Object *pObj)=0
int32_t Count(const C4ObjectList &Objs)
friend class C4FindObjectOr
static C4FindObject * CreateByValue(const C4Value &Data, C4SortObject **ppSortObj=nullptr, const C4Object *context=nullptr, bool *has_layer_check=nullptr)
void SetSort(C4SortObject *pToSort)
virtual C4Rect * GetBounds()
bool IsImpossible() override
bool Check(C4Object *pObj) override
bool Check(C4Object *pObj) override
bool IsImpossible() override
bool Check(C4Object *pObj) override
bool IsImpossible() override
bool Check(C4Object *pObj) override
~C4FindObjectNot() override
bool Check(C4Object *pObj) override
bool IsImpossible() override
bool Check(C4Object *pObj) override
bool IsImpossible() override
bool UseShapes() override
~C4FindObjectOr() override
bool IsEnsured() override
bool Check(C4Object *pObj) override
bool IsImpossible() override
bool Check(C4Object *pObj) override
bool Check(C4Object *pObj) override
bool IsImpossible() override
bool IsImpossible() override
bool Check(C4Object *pObj) override
C4ObjectList * NextObjectShapes(C4ObjectList *pPrev, C4LSector **ppSct)
C4ObjectList * NextObjects(C4ObjectList *pPrev, C4LSector **ppSct)
C4ObjectList * FirstObjectShapes(C4LSector **ppSct)
C4LSector * Next(C4LSector *pPrev) const
C4ObjectList * FirstObjects(C4LSector **ppSct)
C4ObjectList ObjectShapes
C4PropList * GetAction() const
int32_t GetValue(C4Object *pInBase, int32_t iForPlayer)
bool GetPropertyByS(const C4String *k, C4Value *pResult) const override
int ObjectCount(C4ID id=C4ID::None) const
virtual const char * GetName() const
C4PropList * GetPrototype() const
virtual C4Def const * GetDef() const
C4Value Call(C4PropertyName k, C4AulParSet *pPars=nullptr, bool fPassErrors=false)
bool GetProperty(C4PropertyName k, C4Value *pResult) const
bool Overlap(C4Rect &rTarget)
bool IntersectsLine(int32_t iX, int32_t iY, int32_t iX2, int32_t iY2)
void Intersect(const C4Rect &r2)
void Add(const C4Rect &r2)
bool Contains(int32_t iX, int32_t iY) const
int32_t Compare(C4Object *pObj1, C4Object *pObj2) override
~C4SortObjectByValue() override
virtual int32_t CompareGetValue(C4Object *pOf)=0
bool PrepareCache(const C4ValueArray *pObjs) override
int32_t CompareCache(int32_t iObj1, int32_t iObj2, C4Object *pObj1, C4Object *pObj2) override
int32_t CompareGetValue(C4Object *pFor) override
void SetPar(int i, const C4Value &val)
int32_t CompareGetValue(C4Object *pFor) override
virtual int32_t Compare(C4Object *pObj1, C4Object *pObj2)=0
virtual bool PrepareCache(const C4ValueArray *pObjs)
virtual int32_t CompareCache(int32_t iObj1, int32_t iObj2, C4Object *pObj1, C4Object *pObj2)
static C4SortObject * CreateByValue(const C4Value &Data, const C4Object *context=nullptr)
void SortObjects(C4ValueArray *pArray)
int32_t CompareGetValue(C4Object *pFor) override
int32_t Compare(C4Object *pObj1, C4Object *pObj2) override
~C4SortObjectMultiple() override
int32_t CompareCache(int32_t iObj1, int32_t iObj2, C4Object *pObj1, C4Object *pObj2) override
bool PrepareCache(const C4ValueArray *pObjs) override
int32_t CompareGetValue(C4Object *pFor) override
~C4SortObjectReverse() override
bool PrepareCache(const C4ValueArray *pObjs) override
int32_t Compare(C4Object *pObj1, C4Object *pObj2) override
int32_t CompareCache(int32_t iObj1, int32_t iObj2, C4Object *pObj1, C4Object *pObj2) override
int32_t CompareGetValue(C4Object *pFor) override
int32_t CompareGetValue(C4Object *pFor) override
const char * GetCStr() const
const C4Value & GetItem(int32_t iElem) const
void Sort(class C4SortObject &rSort)
const C4Value & _GetItem(int32_t iElem) const
void SetSize(int32_t inSize)
C4ValueArray * getArray() const
C4Object * getObj() const
C4String * getStr() const
C4Object * _getObj() const