OpenClonk
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros
C4Object Class Reference

#include <C4Object.h>

Inheritance diagram for C4Object:
[legend]
Collaboration diagram for C4Object:
[legend]

Public Types

enum  DrawMode { ODM_Normal =0, ODM_Overlay =1, ODM_BaseOnly =2 }
 
enum  { SAC_StartCall = 1, SAC_EndCall = 2, SAC_AbortCall = 4 }
 

Public Member Functions

 C4Object ()
 
 ~C4Object () override
 
void ClearParticleLists ()
 
void Resort ()
 
void SetPlane (int32_t z)
 
int32_t GetPlane () const
 
int32_t GetSolidMaskPlane () const
 
void SetCommand (int32_t iCommand, C4Object *pTarget, C4Value iTx, int32_t iTy=0, C4Object *pTarget2=nullptr, bool fControl=false, C4Value iData=C4VNull, int32_t iRetries=0, C4String *szText=nullptr)
 
void SetCommand (int32_t iCommand, C4Object *pTarget=nullptr, int32_t iTx=0, int32_t iTy=0, C4Object *pTarget2=nullptr, bool fControl=false, C4Value iData=C4VNull, int32_t iRetries=0, C4String *szText=nullptr)
 
bool AddCommand (int32_t iCommand, C4Object *pTarget, C4Value iTx, int32_t iTy=0, int32_t iUpdateInterval=0, C4Object *pTarget2=nullptr, bool fInitEvaluation=true, C4Value iData=C4VNull, bool fAppend=false, int32_t iRetries=0, C4String *szText=nullptr, int32_t iBaseMode=0)
 
bool AddCommand (int32_t iCommand, C4Object *pTarget=nullptr, int32_t iTx=0, int32_t iTy=0, int32_t iUpdateInterval=0, C4Object *pTarget2=nullptr, bool fInitEvaluation=true, C4Value iData=C4VNull, bool fAppend=false, int32_t iRetries=0, C4String *szText=nullptr, int32_t iBaseMode=0)
 
C4CommandFindCommand (int32_t iCommandType) const
 
void ClearCommand (C4Command *pUntil)
 
void ClearCommands ()
 
void DrawSelectMark (C4TargetFacet &cgo) const
 
void UpdateActionFace ()
 
void SyncClearance ()
 
void SetSolidMask (int32_t iX, int32_t iY, int32_t iWdt, int32_t iHgt, int32_t iTX, int32_t iTY)
 
void SetHalfVehicleSolidMask (bool set)
 
bool CheckSolidMaskRect ()
 
bool MenuCommand (const char *szCommand)
 
void Clear ()
 
void ClearInfo (C4ObjectInfo *pInfo)
 
bool AssignInfo ()
 
bool ValidateOwner ()
 
bool AssignLightRange ()
 
void DrawPicture (C4Facet &cgo, bool fSelected=false, C4DrawTransform *transform=nullptr)
 
void Picture2Facet (C4FacetSurface &cgo)
 
void Default ()
 
bool Init (C4PropList *ndef, C4Object *pCreator, int32_t owner, C4ObjectInfo *info, int32_t nx, int32_t ny, int32_t nr, C4Real nxdir, C4Real nydir, C4Real nrdir, int32_t iController)
 
void CompileFunc (StdCompiler *pComp, C4ValueNumbers *)
 
void Denumerate (C4ValueNumbers *) override
 
void DrawLine (C4TargetFacet &cgo, int32_t at_player)
 
bool SetPhase (int32_t iPhase)
 
void AssignRemoval (bool fExitContents=false)
 
void Draw (C4TargetFacet &cgo, int32_t iByPlayer=-1, DrawMode eDrawMode=ODM_Normal, float offX=0, float offY=0)
 
void DrawTopFace (C4TargetFacet &cgo, int32_t iByPlayer=-1, DrawMode eDrawMode=ODM_Normal, float offX=0, float offY=0)
 
void DrawActionFace (C4TargetFacet &cgo, float offX, float offY) const
 
void DrawFace (C4TargetFacet &cgo, float offX, float offY, int32_t iPhaseX=0, int32_t iPhaseY=0) const
 
void DrawFaceImpl (C4TargetFacet &cgo, bool action, float fx, float fy, float fwdt, float fhgt, float tx, float ty, float twdt, float thgt, C4DrawTransform *transform) const
 
void Execute ()
 
void ClearPointers (C4Object *ptr)
 
bool ExecMovement ()
 
void ExecAction ()
 
bool ExecLife ()
 
bool ExecuteCommand ()
 
void AssignDeath (bool fForced)
 
void ContactAction ()
 
void NoAttachAction ()
 
void DoMovement ()
 
void Stabilize ()
 
void SetOCF ()
 
void UpdateOCF ()
 
void UpdateShape (bool bUpdateVertices=true)
 
void UpdatePos ()
 
void UpdateSolidMask (bool fRestoreAttachedObjects)
 
void UpdateMass ()
 
bool ChangeDef (C4ID idNew)
 
void UpdateFace (bool bUpdateShape, bool fTemp=false)
 
void UpdateGraphics (bool fGraphicsChanged, bool fTemp=false)
 
void UpdateFlipDir ()
 
bool At (int32_t ctx, int32_t cty) const
 
bool At (int32_t ctx, int32_t cty, DWORD &ocf) const
 
void GetOCFForPos (int32_t ctx, int32_t cty, DWORD &ocf) const
 
bool CloseMenu (bool fForce)
 
bool ActivateMenu (int32_t iMenu, int32_t iMenuSelect=0, int32_t iMenuData=0, int32_t iMenuPosition=0, C4Object *pTarget=nullptr)
 
int32_t ContactCheck (int32_t atx, int32_t aty, uint32_t *border_hack_contacts=nullptr, bool collide_halfvehic=false)
 
bool Contact (int32_t cnat)
 
void StopAndContact (C4Real &ctco, C4Real limit, C4Real &speed, int32_t cnat)
 
C4PropListGetAction () const
 
bool SetAction (C4PropList *Act, C4Object *pTarget=nullptr, C4Object *pTarget2=nullptr, int32_t iCalls=SAC_StartCall|SAC_AbortCall, bool fForce=false)
 
bool SetActionByName (C4String *ActName, C4Object *pTarget=nullptr, C4Object *pTarget2=nullptr, int32_t iCalls=SAC_StartCall|SAC_AbortCall, bool fForce=false)
 
bool SetActionByName (const char *szActName, C4Object *pTarget=nullptr, C4Object *pTarget2=nullptr, int32_t iCalls=SAC_StartCall|SAC_AbortCall, bool fForce=false)
 
void SetDir (int32_t tdir)
 
void SetCategory (int32_t Category)
 
int32_t GetProcedure () const
 
bool Enter (C4Object *pTarget, bool fCalls=true, bool fCopyMotion=true, bool *pfRejectCollect=nullptr)
 
bool Exit (int32_t iX=0, int32_t iY=0, int32_t iR=0, C4Real iXDir=Fix0, C4Real iYDir=Fix0, C4Real iRDir=Fix0, bool fCalls=true)
 
void CopyMotion (C4Object *from)
 
void ForcePosition (C4Real tx, C4Real ty)
 
void MovePosition (int32_t dx, int32_t dy)
 
void MovePosition (C4Real dx, C4Real dy)
 
void DoMotion (int32_t mx, int32_t my)
 
bool ActivateEntrance (int32_t by_plr, C4Object *by_obj)
 
void DoDamage (int32_t iLevel, int32_t iCausedByPlr, int32_t iCause)
 
void DoEnergy (int32_t iChange, bool fExact, int32_t iCause, int32_t iCausedByPlr)
 
void UpdatLastEnergyLossCause (int32_t iNewCausePlr)
 
void DoBreath (int32_t iChange)
 
void DoCon (int32_t iChange, bool grow_from_center)
 
int32_t GetCon () const
 
void DoExperience (int32_t change)
 
bool Promote (int32_t torank, bool exception, bool fForceRankName)
 
bool Push (C4Real txdir, C4Real dforce, bool fStraighten)
 
bool Lift (C4Real tydir, C4Real dforce)
 
void Fling (C4Real txdir, C4Real tydir, bool fAddSpeed)
 
C4ObjectCreateContents (C4PropList *)
 
bool CreateContentsByList (C4IDList &idlist)
 
BYTE GetArea (int32_t &aX, int32_t &aY, int32_t &aWdt, int32_t &aHgt) const
 
int32_t addtop () const
 
int32_t Left () const
 
int32_t Top () const
 
int32_t Width () const
 
int32_t Height () const
 
int32_t GetX () const
 
int32_t GetY () const
 
int32_t GetR () const
 
C4Real GetFixedX () const
 
C4Real GetFixedY () const
 
C4Real GetFixedR () const
 
BYTE GetEntranceArea (int32_t &aX, int32_t &aY, int32_t &aWdt, int32_t &aHgt) const
 
BYTE GetMomentum (C4Real &rxdir, C4Real &rydir) const
 
C4Real GetSpeed () const
 
StdStrBuf GetDataString ()
 
void SetName (const char *NewName=nullptr) override
 
int32_t GetValue (C4Object *pInBase, int32_t iForPlayer)
 
bool SetOwner (int32_t iOwner)
 
bool SetLightRange (int32_t iToRange, int32_t iToFadeoutRange)
 
uint32_t GetLightColor () const
 
bool SetLightColor (uint32_t iValue)
 
void SetOnFire (bool OnFire) override
 
bool GetOnFire () const
 
void SetAlive (bool Alive)
 
bool GetAlive () const
 
void UpdateLight ()
 
void SetAudibilityAt (C4TargetFacet &cgo, int32_t iX, int32_t iY, int32_t player)
 
bool IsVisible (int32_t iForPlr, bool fAsOverlay) const
 
void SetRotation (int32_t nr)
 
void PrepareDrawing () const
 
void FinishedDrawing () const
 
void DrawSolidMask (C4TargetFacet &cgo) const
 
bool Collect (C4Object *pObj)
 
bool GrabInfo (C4Object *pFrom)
 
bool ShiftContents (bool fShiftBack, bool fDoCalls)
 
void DirectComContents (C4Object *pTarget, bool fDoCalls)
 
void GetParallaxity (int32_t *parX, int32_t *parY) const
 
bool GetDrawPosition (const C4TargetFacet &cgo, float &resultx, float &resulty, float &resultzoom) const
 
bool GetDrawPosition (const C4TargetFacet &cgo, float x, float y, float zoom, float &resultx, float &resulty, float &resultzoom) const
 
bool IsInLiquidCheck () const
 
void UpdateInLiquid ()
 
void GrabContents (C4Object *pFrom)
 
bool GetDragImage (C4Object **drag_object, C4Def **drag_id) const
 
int32_t AddObjectAndContentsToArray (C4ValueArray *target_array, int32_t index=0)
 
void BoundsCheck (C4Real &ctcox, C4Real &ctcoy)
 
bool DoSelect ()
 
void UnSelect ()
 
void GetViewPos (float &riX, float &riY, float tx, float ty, const C4Facet &fctViewport) const
 
void GetViewPosPar (float &riX, float &riY, float tx, float ty, const C4Facet &fctViewport) const
 
bool PutAwayUnusedObject (C4Object *pToMakeRoomForObject)
 
C4DefGraphicsGetGraphics () const
 
bool SetGraphics (const char *szGraphicsName=nullptr, C4Def *pSourceDef=nullptr)
 
bool SetGraphics (C4DefGraphics *pNewGfx, bool fUpdateData)
 
class C4GraphicsOverlayGetGraphicsOverlay (int32_t iForID) const
 
class C4GraphicsOverlayGetGraphicsOverlay (int32_t iForID, bool fCreate)
 
bool RemoveGraphicsOverlay (int32_t iOverlayID)
 
bool HasGraphicsOverlayRecursion (const C4Object *pCheckObj) const
 
void UpdateScriptPointers ()
 
bool StatusActivate ()
 
bool StatusDeactivate (bool fClearPointers)
 
void ClearContentsAndContained (bool fDoCalls=true)
 
bool AdjustWalkRotation (int32_t iRangeX, int32_t iRangeY, int32_t iSpeed)
 
StdStrBuf GetInfoString ()
 
bool CanConcatPictureWith (C4Object *pOtherObject) const
 
bool IsMoveableBySolidMask (int ComparisonPlane) const
 
bool IsPlayerObject (int32_t iPlayerNumber=NO_OWNER) const
 
bool IsUserPlayerObject ()
 
C4ObjectGetObject () override
 
C4Object const * GetObject () const override
 
void SetPropertyByS (C4String *k, const C4Value &to) override
 
void ResetProperty (C4String *k) override
 
bool GetPropertyByS (const C4String *k, C4Value *pResult) const override
 
C4ValueArrayGetProperties () const override
 
C4PropListNumberedGetPropListNumbered () override
 
bool IsNumbered () const override
 
virtual const char * GetName () const
 
virtual C4Def const * GetDef () const
 
virtual C4DefGetDef ()
 
virtual C4EffectGetEffect ()
 
virtual class C4MapScriptLayerGetMapScriptLayer ()
 
virtual class C4MapScriptMapGetMapScriptMap ()
 
C4PropListGetPrototype () const
 
void RemoveCyclicPrototypes ()
 
virtual class C4PropListStaticIsStatic ()
 
const class C4PropListStaticIsStatic () const
 
virtual bool Delete ()
 
bool GetProperty (C4PropertyName k, C4Value *pResult) const
 
C4StringGetPropertyStr (C4PropertyName k) const
 
C4ValueArrayGetPropertyArray (C4PropertyName n) const
 
C4AulFuncGetFunc (C4PropertyName k) const
 
C4AulFuncGetFunc (C4String *k) const
 
C4AulFuncGetFunc (const char *k) const
 
C4StringEnumerateOwnFuncs (C4String *prev=nullptr) const
 
C4Value Call (C4PropertyName k, C4AulParSet *pPars=nullptr, bool fPassErrors=false)
 
C4Value Call (C4String *k, C4AulParSet *pPars=nullptr, bool fPassErrors=false)
 
C4Value Call (const char *k, C4AulParSet *pPars=nullptr, bool fPassErrors=false)
 
C4PropertyName GetPropertyP (C4PropertyName k) const
 
int32_t GetPropertyBool (C4PropertyName n, bool default_val=false) const
 
int32_t GetPropertyInt (C4PropertyName k, int32_t default_val=0) const
 
C4PropListGetPropertyPropList (C4PropertyName k) const
 
bool HasProperty (C4String *k) const
 
void SetProperty (C4PropertyName k, const C4Value &to)
 
void Freeze ()
 
void Thaw ()
 
void ThawRecursively ()
 
bool IsFrozen () const
 
C4PropListStaticFreezeAndMakeStaticRecursively (std::vector< C4Value > *prop_lists, const C4PropListStatic *parent=nullptr, C4String *key=nullptr)
 
void AppendDataString (StdStrBuf *out, const char *delim, int depth=3, bool ignore_reference_parent=false) const
 
StdStrBuf ToJSON (int depth=10, bool ignore_reference_parent=false) const
 
std::vector< C4String * > GetSortedLocalProperties (bool add_prototype=true) const
 
std::vector< C4String * > GetSortedLocalProperties (const char *prefix, const C4PropList *ignore_overridden) const
 
std::vector< C4String * > GetUnsortedProperties (const char *prefix, C4PropList *ignore_parent=nullptr) const
 
std::vector< C4String * > GetSortedProperties (const char *prefix, C4PropList *ignore_parent=nullptr) const
 
bool operator== (const C4PropList &b) const
 
Iterator begin ()
 
Iterator end ()
 

Static Public Member Functions

static C4PropListGetByNumber (int32_t iNumber)
 
static bool CheckPropList (C4PropList *)
 
static void SetEnumerationIndex (int32_t iMaxObjectNumber)
 
static int32_t GetEnumerationIndex ()
 
static void ResetEnumerationIndex ()
 
static void ShelveNumberedPropLists ()
 
static void UnshelveNumberedPropLists ()
 
static void ClearShelve ()
 
static void ClearNumberedPropLists ()
 
static C4PropListNew (C4PropList *prototype=nullptr)
 
static C4PropListStaticNewStatic (C4PropList *prototype, const C4PropListStatic *parent, C4String *key)
 

Public Attributes

C4ID id
 
int32_t RemovalDelay
 
int32_t Owner
 
int32_t Controller
 
int32_t LastEnergyLossCausePlayer
 
int32_t Category
 
int32_t old_x
 
int32_t old_y
 
C4LArea Area
 
int32_t Mass
 
int32_t OwnMass
 
int32_t Damage
 
int32_t Energy
 
int32_t Breath
 
int32_t InMat
 
uint32_t Color
 
int32_t Audible
 
int32_t AudiblePan
 
int32_t AudiblePlayer
 
int32_t lightRange
 
int32_t lightFadeoutRange
 
uint32_t lightColor
 
C4Real fix_x
 
C4Real fix_y
 
C4Real fix_r
 
C4Real xdir
 
C4Real ydir
 
C4Real rdir
 
int32_t iLastAttachMovementFrame
 
bool Mobile
 
bool Unsorted
 
bool Initializing
 
bool InLiquid
 
bool EntranceStatus
 
uint32_t t_contact
 
uint32_t OCF
 
uint32_t Marker
 
C4ObjectPtr Layer
 
C4DrawTransformpDrawTransform
 
class C4ObjectMenuMenu
 
C4Facet TopFace
 
C4DefDef
 
C4ObjectPtr Contained
 
C4ObjectInfoInfo
 
C4Action Action
 
C4Shape Shape
 
bool fOwnVertices
 
C4TargetRect SolidMask
 
C4Rect PictureRect
 
C4NotifyingObjectList Contents
 
C4MaterialListMaterialContents
 
C4DefGraphicspGraphics
 
StdMeshInstancepMeshInstance
 
C4EffectpEffects
 
class C4ParticleListFrontParticles
 
class C4ParticleListBackParticles
 
uint32_t ColorMod
 
uint32_t BlitMode
 
bool CrewDisabled
 
C4CommandCommand
 
StdCopyStrBuf nInfo
 
class C4GraphicsOverlaypGfxOverlay
 
int32_t Number {-1}
 
int32_t Status {1}
 

Protected Member Functions

void SideBounds (C4Real &ctcox)
 
void VerticalBounds (C4Real &ctcoy)
 
void AcquireNumber ()
 
void ClearNumber ()
 
void ClearRefs ()
 

Protected Attributes

bool OnFire
 
int32_t Con
 
int32_t Plane
 
bool Alive
 
C4SolidMaskpSolidMaskData
 

Static Protected Attributes

static C4Set
< C4PropListNumbered * > 
PropLists
 
static std::vector
< C4PropListNumbered * > 
ShelvedPropLists
 
static int32_t EnumerationIndex = 0
 

Detailed Description

Definition at line 100 of file C4Object.h.

Member Enumeration Documentation

anonymous enum
Enumerator
SAC_StartCall 
SAC_EndCall 
SAC_AbortCall 

Definition at line 251 of file C4Object.h.

Enumerator
ODM_Normal 
ODM_Overlay 
ODM_BaseOnly 

Definition at line 216 of file C4Object.h.

Constructor & Destructor Documentation

C4Object::C4Object ( )

Definition at line 85 of file C4Object.cpp.

References BackParticles, Default(), and FrontParticles.

86 {
87  FrontParticles = BackParticles = nullptr;
88  Default();
89 }
class C4ParticleList * BackParticles
Definition: C4Object.h:158
void Default()
Definition: C4Object.cpp:91
class C4ParticleList * FrontParticles
Definition: C4Object.h:158

Here is the call graph for this function:

C4Object::~C4Object ( )
override

Definition at line 235 of file C4Object.cpp.

References C4LSectors::AssertObjectNotInList(), Clear(), Objects, and C4GameObjects::Sectors.

236 {
237  Clear();
238 
239 #if defined(_DEBUG)
240  // debug: mustn't be listed in any list now
242 #endif
243 }
void Clear()
Definition: C4Object.cpp:2432
void AssertObjectNotInList(C4Object *pObj)
Definition: C4Sector.cpp:185
C4LSectors Sectors
Definition: C4GameObjects.h:42
C4GameObjects Objects
Definition: C4Globals.cpp:48

Here is the call graph for this function:

Member Function Documentation

void C4PropListNumbered::AcquireNumber ( )
protectedinherited

Definition at line 155 of file C4PropList.cpp.

References C4Set< T >::Add(), C4PropListNumbered::EnumerationIndex, C4Set< T >::Get(), C4PropListNumbered::Number, and C4PropListNumbered::PropLists.

Referenced by C4Effect::C4Effect(), C4MapScriptLayer::C4MapScriptLayer(), and Init().

156 {
157  // Enumerate object
158  do
160  while (PropLists.Get(Number));
161  // Add to list
162  PropLists.Add(this);
163 }
T * Add(T const &e)
T & Get(H e) const
static C4Set< C4PropListNumbered * > PropLists
Definition: C4PropList.h:236
static int32_t EnumerationIndex
Definition: C4PropList.h:238

Here is the call graph for this function:

Here is the caller graph for this function:

bool C4Object::ActivateEntrance ( int32_t  by_plr,
C4Object by_obj 
)

Definition at line 1348 of file C4Object.cpp.

References C4PropList::Call(), OCF, OCF_Entrance, and PSF_ActivateEntrance.

Referenced by C4Command::Enter(), and C4Command::Exit().

1349 {
1350 
1351  // Try entrance activation
1352  if (OCF & OCF_Entrance)
1353  if (!! Call(PSF_ActivateEntrance,&C4AulParSet(by_obj)))
1354  return true;
1355  // Failure
1356  return false;
1357 }
const uint32_t OCF_Entrance
Definition: C4Constants.h:90
#define PSF_ActivateEntrance
Definition: C4GameScript.h:67
uint32_t OCF
Definition: C4Object.h:134
C4Value Call(C4PropertyName k, C4AulParSet *pPars=nullptr, bool fPassErrors=false)
Definition: C4PropList.h:110

Here is the call graph for this function:

Here is the caller graph for this function:

bool C4Object::ActivateMenu ( int32_t  iMenu,
int32_t  iMenuSelect = 0,
int32_t  iMenuData = 0,
int32_t  iMenuPosition = 0,
C4Object pTarget = nullptr 
)

Definition at line 1476 of file C4Object.cpp.

References C4Menu::Add(), C4MN_Activate, C4MN_Align_Free, C4MN_Buy, C4MN_Contents, C4MN_Extra_None, C4MN_Extra_Value, C4MN_Get, C4MN_Info, C4MN_Item_NoCount, C4MN_Sell, C4MN_Style_Info, C4PictureSize, C4SymbolSize, C4PropList::Call(), C4Menu::ClearItems(), CloseMenu(), Color, Contained, Controller, C4FacetSurface::Create(), Def, C4FacetSurface::Default(), C4Def::Draw(), FormatString(), StdStrBuf::getData(), GetInfoString(), C4PropList::GetName(), C4ViewportList::GetViewport(), C4Viewport::GetViewX(), C4Viewport::GetViewY(), C4Shape::GetX(), GetX(), C4Shape::GetY(), GetY(), C4Viewport::GetZoom(), GfxR, C4ObjectMenu::Init(), C4Menu::IsActive(), LoadResStr(), Menu, Owner, PSF_RejectContents, C4Menu::SetAlignment(), C4Menu::SetLocation(), C4Menu::SetPermanent(), C4ObjectMenu::SetRefillObject(), Shape, C4Menu::TryClose(), Viewports, and C4Rect::Wdt.

Referenced by C4Command::Activate(), C4Command::Get(), ObjectComPutTake(), ObjectComTake(), and ObjectComTake2().

1479 {
1480  // Variables
1481  C4FacetSurface fctSymbol;
1482  C4IDList ListItems;
1483  // Close any other menu
1484  if (Menu && Menu->IsActive()) if (!Menu->TryClose(true, false)) return false;
1485  // Create menu
1486  if (!Menu) Menu = new C4ObjectMenu; else Menu->ClearItems();
1487  // Open menu
1488  switch (iMenu)
1489  {
1490  // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
1491  case C4MN_Activate:
1492  // No target specified: use own container as target
1493  if (!pTarget) if (!(pTarget=Contained)) break;
1494  // Opening contents menu blocked by RejectContents
1495  if (!!pTarget->Call(PSF_RejectContents)) return false;
1496  // Create symbol
1497  fctSymbol.Create(C4SymbolSize,C4SymbolSize);
1498  pTarget->Def->Draw(fctSymbol,false,pTarget->Color,pTarget);
1499  // Init
1500  Menu->Init(fctSymbol,FormatString(LoadResStr("IDS_OBJ_EMPTY"),pTarget->GetName()).getData(),this,C4MN_Extra_None,0,iMenu);
1501  Menu->SetPermanent(true);
1502  Menu->SetRefillObject(pTarget);
1503  // Success
1504  return true;
1505  // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
1506  case C4MN_Buy:
1507  // No target specified: container is base
1508  if (!pTarget) if (!(pTarget=Contained)) break;
1509  // Create symbol
1510  fctSymbol.Create(C4SymbolSize,C4SymbolSize);
1511  DrawMenuSymbol(C4MN_Buy, fctSymbol, pTarget->Owner);
1512  // Init menu
1513  Menu->Init(fctSymbol,LoadResStr("IDS_PLR_NOBUY"),this,C4MN_Extra_Value,0,iMenu);
1514  Menu->SetPermanent(true);
1515  Menu->SetRefillObject(pTarget);
1516  // Success
1517  return true;
1518  // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
1519  case C4MN_Sell:
1520  // No target specified: container is base
1521  if (!pTarget) if (!(pTarget=Contained)) break;
1522  // Create symbol & init
1523  fctSymbol.Create(C4SymbolSize,C4SymbolSize);
1524  DrawMenuSymbol(C4MN_Sell, fctSymbol, pTarget->Owner);
1525  Menu->Init(fctSymbol,FormatString(LoadResStr("IDS_OBJ_EMPTY"),pTarget->GetName()).getData(),this,C4MN_Extra_Value,0,iMenu);
1526  Menu->SetPermanent(true);
1527  Menu->SetRefillObject(pTarget);
1528  // Success
1529  return true;
1530  // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
1531  case C4MN_Get:
1532  case C4MN_Contents:
1533  // No target specified
1534  if (!pTarget) break;
1535  // Opening contents menu blocked by RejectContents
1536  if (!!pTarget->Call(PSF_RejectContents)) return false;
1537  // Create symbol & init
1538  fctSymbol.Create(C4SymbolSize,C4SymbolSize);
1539  pTarget->Def->Draw(fctSymbol,false,pTarget->Color,pTarget);
1540  Menu->Init(fctSymbol,FormatString(LoadResStr("IDS_OBJ_EMPTY"),pTarget->GetName()).getData(),this,C4MN_Extra_None,0,iMenu);
1541  Menu->SetPermanent(true);
1542  Menu->SetRefillObject(pTarget);
1543  // Success
1544  return true;
1545  // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
1546  case C4MN_Info:
1547  // Target by parameter
1548  if (!pTarget) break;
1549  // Create symbol & init menu
1550  fctSymbol.Create(C4SymbolSize, C4SymbolSize); GfxR->fctOKCancel.Draw(fctSymbol,true,0,1);
1551  Menu->Init(fctSymbol, pTarget->GetName(), this, C4MN_Extra_None, 0, iMenu, C4MN_Style_Info);
1552  Menu->SetPermanent(true);
1554  C4Viewport *pViewport = ::Viewports.GetViewport(Controller); // Hackhackhack!!!
1555  if (pViewport) Menu->SetLocation((pTarget->GetX() + pTarget->Shape.GetX() + pTarget->Shape.Wdt + 10 - pViewport->GetViewX()) * pViewport->GetZoom(),
1556  (pTarget->GetY() + pTarget->Shape.GetY() - pViewport->GetViewY()) * pViewport->GetZoom());
1557  // Add info item
1558  fctSymbol.Create(C4PictureSize, C4PictureSize); pTarget->Def->Draw(fctSymbol, false, pTarget->Color, pTarget);
1559  Menu->Add(pTarget->GetName(), fctSymbol, "", C4MN_Item_NoCount, nullptr, pTarget->GetInfoString().getData());
1560  fctSymbol.Default();
1561  // Success
1562  return true;
1563  // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
1564  }
1565  // Invalid menu identification
1566  CloseMenu(true);
1567  return false;
1568 }
const char * getData() const
Definition: StdBuf.h:442
int32_t GetY() const
Definition: C4Object.h:287
bool Add(const char *szCaption, C4FacetSurface &fctSymbol, const char *szCommand, int32_t iCount=C4MN_Item_NoCount, C4Object *pObject=nullptr, const char *szInfoCaption=nullptr, C4ID idID=C4ID::None, const char *szCommand2=nullptr, bool fOwnValue=false, int32_t iValue=0, bool fIsSelectable=true)
Definition: C4Menu.cpp:350
#define GfxR
void SetAlignment(int32_t iAlignment)
Definition: C4Menu.cpp:857
int32_t GetY() const
Definition: C4Shape.h:63
bool Init(C4FacetSurface &fctSymbol, const char *szEmpty, C4Object *pObject, int32_t iExtra=C4MN_Extra_None, int32_t iExtraData=0, int32_t iId=0, int32_t iStyle=C4MN_Style_Normal, bool fUserMenu=false)
C4Viewport * GetViewport(int32_t iPlayer, C4Viewport *pPrev=nullptr)
const char * LoadResStr(const char *id)
Definition: C4Language.h:83
void Default()
Definition: C4FacetEx.h:43
int32_t Wdt
Definition: C4Rect.h:30
class C4ObjectMenu * Menu
Definition: C4Object.h:140
bool CloseMenu(bool fForce)
Definition: C4Object.cpp:1570
C4Def * Def
Definition: C4Object.h:143
bool SetLocation(int32_t iX, int32_t iY)
Definition: C4Menu.cpp:951
void ClearItems()
Definition: C4Menu.cpp:895
virtual const char * GetName() const
Definition: C4PropList.cpp:649
int32_t Owner
Definition: C4Object.h:110
int32_t GetX() const
Definition: C4Shape.h:62
uint32_t Color
Definition: C4Object.h:120
void Draw(C4Facet &cgo, bool fSelected=false, DWORD iColor=0, C4Object *pObj=nullptr, int32_t iPhaseX=0, int32_t iPhaseY=0, C4DrawTransform *trans=nullptr, const char *graphicsName=nullptr)
Definition: C4Def.cpp:597
int32_t GetX() const
Definition: C4Object.h:286
bool IsActive()
Definition: C4Menu.cpp:480
bool TryClose(bool fOK, bool fControl)
Definition: C4Menu.cpp:280
#define PSF_RejectContents
Definition: C4GameScript.h:134
const int C4PictureSize
Definition: C4Constants.h:60
C4ViewportList Viewports
Definition: C4Viewport.cpp:841
float GetViewY()
Definition: C4Viewport.h:75
StdStrBuf GetInfoString()
Definition: C4Object.cpp:4713
const int C4SymbolSize
Definition: C4Constants.h:58
float GetZoom()
Definition: C4Viewport.h:45
bool Create(int iWdt, int iHgt, int iWdt2=C4FCT_Full, int iHgt2=C4FCT_Full)
Definition: C4FacetEx.cpp:54
void SetPermanent(bool fPermanent)
Definition: C4Menu.cpp:862
void SetRefillObject(C4Object *pObj)
C4ObjectPtr Contained
Definition: C4Object.h:144
C4Shape Shape
Definition: C4Object.h:148
float GetViewX()
Definition: C4Viewport.h:73
int32_t Controller
Definition: C4Object.h:111
StdStrBuf FormatString(const char *szFmt,...)
Definition: StdBuf.cpp:270
C4Value Call(C4PropertyName k, C4AulParSet *pPars=nullptr, bool fPassErrors=false)
Definition: C4PropList.h:110

Here is the call graph for this function:

Here is the caller graph for this function:

bool C4Object::AddCommand ( int32_t  iCommand,
C4Object pTarget,
C4Value  iTx,
int32_t  iTy = 0,
int32_t  iUpdateInterval = 0,
C4Object pTarget2 = nullptr,
bool  fInitEvaluation = true,
C4Value  iData = C4VNull,
bool  fAppend = false,
int32_t  iRetries = 0,
C4String szText = nullptr,
int32_t  iBaseMode = 0 
)

Definition at line 2562 of file C4Object.cpp.

References C4CMD_First, C4CMD_Last, Command, Inside(), C4Command::Next, and C4Command::Set().

Referenced by C4Command::Acquire(), C4Command::Activate(), AddCommand(), C4Command::Attack(), C4Command::Dig(), C4Command::Drop(), C4Command::Enter(), C4Command::Execute(), C4Command::Follow(), C4Command::Get(), C4Command::Grab(), C4Command::JumpControl(), C4Command::MoveTo(), ObjectAddWaypoint::operator()(), C4Command::PushTo(), C4Command::Put(), PutAwayUnusedObject(), SetCommand(), StopActionDelayCommand(), C4Command::Throw(), and C4Command::Transfer().

2566 {
2567  // Command stack size safety
2568  const int32_t MaxCommandStack = 35;
2569  C4Command *pCom,*pLast; int32_t iCommands;
2570  for (pCom=Command,iCommands=0; pCom; pCom=pCom->Next,iCommands++) {}
2571  if (iCommands>=MaxCommandStack) return false;
2572  // Valid command safety
2573  if (!Inside(iCommand,C4CMD_First,C4CMD_Last)) return false;
2574  // Allocate and set new command
2575  if (!(pCom=new C4Command)) return false;
2576  pCom->Set(iCommand,this,pTarget,iTx,iTy,pTarget2,iData,
2577  iUpdateInterval,!fInitEvaluation,iRetries,szText,iBaseMode);
2578  // Append to bottom of stack
2579  if (fAppend)
2580  {
2581  for (pLast=Command; pLast && pLast->Next; pLast=pLast->Next) {}
2582  if (pLast) pLast->Next=pCom;
2583  else Command=pCom;
2584  }
2585  // Add to top of command stack
2586  else
2587  {
2588  pCom->Next=Command;
2589  Command=pCom;
2590  }
2591  // Success
2592  return true;
2593 }
C4Command * Next
Definition: C4Command.h:90
C4Command * Command
Definition: C4Object.h:166
const int32_t C4CMD_First
Definition: C4Command.h:56
const int32_t C4CMD_Last
Definition: C4Command.h:57
void Set(int32_t iCommand, C4Object *pObj, C4Object *pTarget, C4Value iTx, int32_t iTy, C4Object *pTarget2, C4Value iData, int32_t iUpdateInterval, bool fEvaluated, int32_t iRetries, C4String *szText, int32_t iBaseMode)
Definition: C4Command.cpp:1810
bool Inside(T ival, U lbound, V rbound)
Definition: Standard.h:43

Here is the call graph for this function:

Here is the caller graph for this function:

bool C4Object::AddCommand ( int32_t  iCommand,
C4Object pTarget = nullptr,
int32_t  iTx = 0,
int32_t  iTy = 0,
int32_t  iUpdateInterval = 0,
C4Object pTarget2 = nullptr,
bool  fInitEvaluation = true,
C4Value  iData = C4VNull,
bool  fAppend = false,
int32_t  iRetries = 0,
C4String szText = nullptr,
int32_t  iBaseMode = 0 
)
inline

Definition at line 186 of file C4Object.h.

References AddCommand(), and C4VInt().

187  { return AddCommand(iCommand, pTarget, C4VInt(iTx), iTy, iUpdateInterval, pTarget2, fInitEvaluation, iData, fAppend, iRetries, szText, iBaseMode); }
C4Value C4VInt(int32_t i)
Definition: C4Value.h:242
bool AddCommand(int32_t iCommand, C4Object *pTarget, C4Value iTx, int32_t iTy=0, int32_t iUpdateInterval=0, C4Object *pTarget2=nullptr, bool fInitEvaluation=true, C4Value iData=C4VNull, bool fAppend=false, int32_t iRetries=0, C4String *szText=nullptr, int32_t iBaseMode=0)
Definition: C4Object.cpp:2562

Here is the call graph for this function:

int32_t C4Object::AddObjectAndContentsToArray ( C4ValueArray target_array,
int32_t  index = 0 
)

Definition at line 4298 of file C4Object.cpp.

References AddObjectAndContentsToArray(), C4VObj(), Contents, and C4ValueArray::SetItem().

Referenced by AddObjectAndContentsToArray(), and C4EditCursor::PerformDuplication().

4299 {
4300  // add self, contents and child contents count recursively to value array. Return index after last added item.
4301  target_array->SetItem(index++, C4VObj(this));
4302  for (C4Object *cobj : Contents)
4303  {
4304  index = cobj->AddObjectAndContentsToArray(target_array, index);
4305  }
4306  return index;
4307 }
void SetItem(int32_t iElemNr, const C4Value &Value)
C4Value C4VObj(C4Object *pObj)
Definition: C4Value.cpp:88
C4NotifyingObjectList Contents
Definition: C4Object.h:152

Here is the call graph for this function:

Here is the caller graph for this function:

int32_t C4Object::addtop ( ) const
inline

Definition at line 281 of file C4Object.h.

References C4Rect::Hgt.

Referenced by At(), Height(), Top(), and C4MouseControl::UpdateCursorTarget().

281 { return std::max<int32_t>(18-Shape.Hgt,0); } // Minimum top action size for build check
int32_t Hgt
Definition: C4Rect.h:30
C4Shape Shape
Definition: C4Object.h:148

Here is the caller graph for this function:

bool C4Object::AdjustWalkRotation ( int32_t  iRangeX,
int32_t  iRangeY,
int32_t  iSpeed 
)

Definition at line 4586 of file C4Object.cpp.

References Abs(), Def, GBackSolid(), GetR(), C4Shape::iAttachVtx, C4Shape::iAttachX, C4Shape::iAttachY, itofix(), rdir, C4Def::Shape, Shape, and C4Shape::VtxX.

Referenced by ExecAction().

4587 {
4588  int32_t iDestAngle;
4589  // attachment at middle (bottom) vertex?
4591  {
4592  // evaluate floor around attachment pos
4593  int32_t iSolidLeft=0, iSolidRight=0;
4594  // left
4595  int32_t iXCheck = Shape.iAttachX-iRangeX;
4596  if (GBackSolid(iXCheck, Shape.iAttachY))
4597  {
4598  // up
4599  while (--iSolidLeft>-iRangeY)
4600  if (GBackSolid(iXCheck, Shape.iAttachY+iSolidLeft))
4601  { ++iSolidLeft; break; }
4602  }
4603  else
4604  // down
4605  while (++iSolidLeft<iRangeY)
4606  if (GBackSolid(iXCheck, Shape.iAttachY+iSolidLeft))
4607  { --iSolidLeft; break; }
4608  // right
4609  iXCheck += 2*iRangeX;
4610  if (GBackSolid(iXCheck, Shape.iAttachY))
4611  {
4612  // up
4613  while (--iSolidRight>-iRangeY)
4614  if (GBackSolid(iXCheck, Shape.iAttachY+iSolidRight))
4615  { ++iSolidRight; break; }
4616  }
4617  else
4618  // down
4619  while (++iSolidRight<iRangeY)
4620  if (GBackSolid(iXCheck, Shape.iAttachY+iSolidRight))
4621  { --iSolidRight; break; }
4622  // calculate destination angle
4623  // 100% accurate for large values of Pi ;)
4624  iDestAngle=(iSolidRight-iSolidLeft)*(35/std::max<int32_t>(iRangeX, 1));
4625  }
4626  else
4627  {
4628  // attachment at other than horizontal middle vertex: get your feet to the ground!
4629  // rotate target to large angle is OK, because rotation will stop once the real
4630  // bottom vertex hits solid ground
4631  if (Shape.VtxX[Shape.iAttachVtx] > 0)
4632  iDestAngle = -50;
4633  else
4634  iDestAngle = 50;
4635  }
4636  // move to destination angle
4637  if (Abs(iDestAngle-GetR())>2)
4638  {
4639  rdir = itofix(Clamp<int32_t>(iDestAngle-GetR(), -15,+15));
4640  rdir/=(10000/iSpeed);
4641  }
4642  else rdir=0;
4643  // done, success
4644  return true;
4645 }
C4Real rdir
Definition: C4Object.h:126
int32_t iAttachY
Definition: C4Shape.h:53
C4Shape Shape
Definition: C4Def.h:104
C4Def * Def
Definition: C4Object.h:143
int32_t GetR() const
Definition: C4Object.h:288
int32_t iAttachX
Definition: C4Shape.h:53
int32_t VtxX[C4D_MaxVertex]
Definition: C4Shape.h:43
C4Fixed itofix(int32_t x)
Definition: C4Real.h:261
int32_t iAttachVtx
Definition: C4Shape.h:53
T Abs(T val)
Definition: Standard.h:42
C4Shape Shape
Definition: C4Object.h:148
bool GBackSolid(int32_t x, int32_t y)
Definition: C4Landscape.h:231

Here is the call graph for this function:

Here is the caller graph for this function:

void C4PropList::AppendDataString ( StdStrBuf out,
const char *  delim,
int  depth = 3,
bool  ignore_reference_parent = false 
) const
inherited

Definition at line 518 of file C4PropList.cpp.

References StdStrBuf::Append(), C4Value::GetDataString(), C4Set< T >::GetSize(), C4Set< T >::GetSortedListOfElementPointers(), and C4PropList::IsStatic().

Referenced by C4Value::GetDataString(), and GetDataString().

519 {
520  StdStrBuf & DataString = *out;
521  if (depth <= 0 && Properties.GetSize())
522  {
523  DataString.Append("...");
524  return;
525  }
526  bool has_elements = false;
527  // Append prototype
528  if (prototype)
529  {
530  DataString.Append("Prototype = ");
531  DataString.Append(prototype.GetDataString(depth - 1, ignore_reference_parent ? IsStatic() : nullptr));
532  has_elements = true;
533  }
534  // Append other properties
535  std::list<const C4Property *> sorted_props = Properties.GetSortedListOfElementPointers();
536  for (std::list<const C4Property *>::const_iterator p = sorted_props.begin(); p != sorted_props.end(); ++p)
537  {
538  if (has_elements) DataString.Append(delim);
539  DataString.Append((*p)->Key->GetData());
540  DataString.Append(" = ");
541  DataString.Append((*p)->Value.GetDataString(depth - 1, ignore_reference_parent ? IsStatic() : nullptr));
542  has_elements = true;
543  }
544 }
std::list< const T * > GetSortedListOfElementPointers() const
virtual class C4PropListStatic * IsStatic()
Definition: C4PropList.h:85
StdStrBuf GetDataString(int depth=10, const class C4PropListStatic *ignore_reference_parent=nullptr) const
Definition: C4Value.cpp:131
unsigned int GetSize() const
void Append(const char *pnData, size_t iChars)
Definition: StdBuf.h:519

Here is the call graph for this function:

Here is the caller graph for this function:

void C4Object::AssignDeath ( bool  fForced)

Definition at line 989 of file C4Object.cpp.

References Alive, C4FxCall_RemoveDeath, C4PropList::Call(), C4Effect::ClearAll(), ClearCommands(), C4Player::ClearPointers(), Contents, C4Player::Crew, C4ObjectInfoCore::DeathCount, Exit(), Game, C4PlayerList::Get(), C4ObjectList::GetObject(), GetX(), GetY(), C4Game::GRBroadcast(), C4ObjectInfo::HasDied, Info, LastEnergyLossCausePlayer, C4ObjectList::ObjectCount(), Owner, pEffects, Players, PSF_Death, PSF_RelaunchPlayer, C4ObjectInfo::Retire(), SetActionByName(), SetLightRange(), SetOCF(), and C4PropList::Status.

Referenced by DoEnergy(), and ExecMovement().

990 {
991  C4Object *thing;
992  // Alive objects only
993  if (!Alive) return;
994  // clear all effects
995  // do not delete effects afterwards, because they might have denied removal
996  // set alive-flag before, so objects know what's up
997  // and prevent recursive death-calls this way
998  // get death causing player before doing effect calls, because those might meddle around with the flags
999  int32_t iDeathCausingPlayer = LastEnergyLossCausePlayer;
1000  Alive=false;
1002  // if the object is alive again, abort here if the kill is not forced
1003  if (Alive && !fForced) return;
1004  // Action
1005  SetActionByName("Dead");
1006  // Values
1007  Alive=false;
1008  ClearCommands();
1009  C4ObjectInfo * pInfo = Info;
1010  if (Info)
1011  {
1012  Info->HasDied=true;
1013  ++Info->DeathCount;
1014  Info->Retire();
1015  }
1016  // Remove from crew/cursor/view
1017  C4Player *pPlr = ::Players.Get(Owner);
1018  if (pPlr) pPlr->ClearPointers(this, true);
1019  // Remove from light sources
1020  SetLightRange(0,0);
1021  // Engine script call
1022  C4AulParSet pars(iDeathCausingPlayer);
1023  Call(PSF_Death, &pars);
1024  // Lose contents
1025  while ((thing=Contents.GetObject())) thing->Exit(thing->GetX(),thing->GetY());
1026  // Update OCF. Done here because previously it would have been done in the next frame
1027  // Whats worse: Having the OCF change because of some unrelated script-call like
1028  // SetCategory, or slightly breaking compatibility?
1029  SetOCF();
1030  // Engine broadcast: relaunch player (in CR, this was called from clonk script.
1031  // Now, it is done for every crew member)
1032  if(pPlr)
1033  if(!pPlr->Crew.ObjectCount())
1035  &C4AulParSet(Owner, iDeathCausingPlayer, Status ? this : nullptr));
1036  if (pInfo)
1037  pInfo->HasDied = false;
1038 }
int32_t GetY() const
Definition: C4Object.h:287
void ClearAll(int32_t iClearFlag)
Definition: C4Effect.cpp:369
#define C4FxCall_RemoveDeath
Definition: C4Effect.h:46
C4Game Game
Definition: C4Globals.cpp:52
bool Alive
Definition: C4Object.h:175
bool SetActionByName(C4String *ActName, C4Object *pTarget=nullptr, C4Object *pTarget2=nullptr, int32_t iCalls=SAC_StartCall|SAC_AbortCall, bool fForce=false)
Definition: C4Object.cpp:2814
void ClearPointers(C4Object *tptr, bool fDeath)
Definition: C4Player.cpp:98
C4ObjectInfo * Info
Definition: C4Object.h:145
C4Player * Get(int iPlayer) const
C4NotifyingObjectList Contents
Definition: C4Object.h:152
#define PSF_Death
Definition: C4GameScript.h:66
int32_t Owner
Definition: C4Object.h:110
C4PlayerList Players
bool Exit(int32_t iX=0, int32_t iY=0, int32_t iR=0, C4Real iXDir=Fix0, C4Real iYDir=Fix0, C4Real iRDir=Fix0, bool fCalls=true)
Definition: C4Object.cpp:1224
int32_t GetX() const
Definition: C4Object.h:286
C4Object * GetObject(int Index=0) const
int32_t Status
Definition: C4PropList.h:168
C4ObjectList Crew
Definition: C4Player.h:125
void ClearCommands()
Definition: C4Object.cpp:2531
#define PSF_RelaunchPlayer
Definition: C4GameScript.h:47
int ObjectCount(C4ID id=C4ID::None) const
bool SetLightRange(int32_t iToRange, int32_t iToFadeoutRange)
Definition: C4Object.cpp:4005
C4Value GRBroadcast(const char *szFunction, C4AulParSet *pPars=nullptr, bool fPassError=false, bool fRejectTest=false)
Definition: C4Game.cpp:3846
C4Effect * pEffects
Definition: C4Object.h:156
void SetOCF()
Definition: C4Object.cpp:667
int32_t DeathCount
Definition: C4InfoCore.h:44
int32_t LastEnergyLossCausePlayer
Definition: C4Object.h:112
C4Value Call(C4PropertyName k, C4AulParSet *pPars=nullptr, bool fPassErrors=false)
Definition: C4PropList.h:110

Here is the call graph for this function:

Here is the caller graph for this function:

bool C4Object::AssignInfo ( )

Definition at line 2386 of file C4Object.cpp.

References Alive, C4Player::ClearPointers(), C4Player::Crew, C4PlayerList::Get(), StdStrBuf::getLength(), C4ObjectList::GetLink(), Info, C4Player::MakeCrewMember(), nInfo, Owner, Players, C4ObjectList::Remove(), and ValidPlr().

Referenced by C4ObjectList::AssignInfo().

2387 {
2388  if (Info || !ValidPlr(Owner)) return false;
2389  // In crew list?
2390  C4Player *pPlr = ::Players.Get(Owner);
2391  if (pPlr->Crew.GetLink(this))
2392  {
2393  // Register with player
2394  if (!::Players.Get(Owner)->MakeCrewMember(this, true, false))
2395  pPlr->Crew.Remove(this);
2396  return true;
2397  }
2398  // Info set, but not in crew list, so
2399  // a) The savegame is old-style (without crew list)
2400  // or b) The clonk is dead
2401  // or c) The clonk belongs to a script player that's restored without Game.txt
2402  else if (nInfo.getLength())
2403  {
2404  if (!::Players.Get(Owner)->MakeCrewMember(this, true, false))
2405  return false;
2406  // Dead and gone (info flags, remove from crew/cursor)
2407  if (!Alive)
2408  {
2409  if (ValidPlr(Owner)) ::Players.Get(Owner)->ClearPointers(this, true);
2410  }
2411  return true;
2412  }
2413  return false;
2414 }
bool MakeCrewMember(C4Object *pObj, bool fForceInfo=true, bool fDoCalls=true)
Definition: C4Player.cpp:1008
bool Alive
Definition: C4Object.h:175
void ClearPointers(C4Object *tptr, bool fDeath)
Definition: C4Player.cpp:98
C4ObjectInfo * Info
Definition: C4Object.h:145
const C4ObjectLink * GetLink(const C4Object *pObj) const
C4Player * Get(int iPlayer) const
int32_t Owner
Definition: C4Object.h:110
C4PlayerList Players
C4ObjectList Crew
Definition: C4Player.h:125
StdCopyStrBuf nInfo
Definition: C4Object.h:168
int32_t ValidPlr(int32_t plr)
size_t getLength() const
Definition: StdBuf.h:445
virtual bool Remove(C4Object *pObj)

Here is the call graph for this function:

Here is the caller graph for this function:

bool C4Object::AssignLightRange ( )

Definition at line 2416 of file C4Object.cpp.

References lightFadeoutRange, lightRange, and UpdateLight().

2417 {
2418  if (!lightRange && !lightFadeoutRange) return true;
2419 
2420  UpdateLight();
2421  return true;
2422 }
int32_t lightFadeoutRange
Definition: C4Object.h:123
int32_t lightRange
Definition: C4Object.h:122
void UpdateLight()
Definition: C4Object.cpp:4028

Here is the call graph for this function:

void C4Object::AssignRemoval ( bool  fExitContents = false)

Definition at line 254 of file C4Object.cpp.

References C4GameObjects::Add(), AddDbgRec(), C4FxCall_RemoveClear, C4OS_INACTIVE, C4OS_NORMAL, C4PropList::Call(), C4Effect::ClearAll(), ClearCommands(), ClearParticleLists(), C4Game::ClearPointers(), C4PropList::ClearRefs(), Config, Contained, Contents, C4Def::Count, C4ConfigGeneral::DebugRec, Def, Enter(), Exit(), Game, C4Config::General, C4PropListStatic::GetName(), GetX(), GetY(), C4RCCreateObj::id, C4GameObjects::InactiveObjects, Info, C4PropListNumbered::Number, Objects, C4RCCreateObj::oei, Owner, C4RCCreateObj::ownr, pEffects, PSF_ContentsDestruction, PSF_Destruction, pSolidMaskData, RCT_DsObj, RemovalDelay, C4ObjectList::Remove(), C4ObjectInfo::Retire(), SetAction(), SetOCF(), SolidMask, C4PropList::Status, UpdateMass(), C4Rect::Wdt, C4RCCreateObj::x, and C4RCCreateObj::y.

Referenced by CreateContents(), C4Landscape::P::DigMaterial2Objects(), DoCon(), ExecAction(), ExecMovement(), and C4Player::RemoveCrewObjects().

255 {
256  // check status
257  if (!Status) return;
258  if (Config.General.DebugRec)
259  {
260  C4RCCreateObj rc;
261  memset(&rc, '\0', sizeof(rc));
262  rc.oei=Number;
263  if (Def && Def->GetName()) strncpy(rc.id, Def->GetName(), 32+1);
264  rc.x=GetX(); rc.y=GetY(); rc.ownr=Owner;
265  AddDbgRec(RCT_DsObj, &rc, sizeof(rc));
266  }
267  // Destruction call in container
268  if (Contained)
269  {
270  C4AulParSet pars(this);
272  if (!Status) return;
273  }
274  // Destruction call
276  // Destruction-callback might have deleted the object already
277  if (!Status) return;
278  // remove all effects (extinguishes as well)
279  if (pEffects)
280  {
282  // Effect-callback might actually have deleted the object already
283  if (!Status) return;
284  }
285  // remove particles
287  // Action idle
288  SetAction(nullptr);
289  // Object system operation
290  if (Status == C4OS_INACTIVE)
291  {
292  // object was inactive: activate first, then delete
295  ::Objects.Add(this);
296  }
297  Status=0;
298  // count decrease
299  Def->Count--;
300 
301  // get container for next actions
302  C4Object *pCont = Contained;
303  // remove or exit contents
304  for (C4Object *cobj : Contents)
305  {
306  if (fExitContents)
307  {
308  // move objects to parent container or exit them completely
309  if (!pCont || !cobj->Enter(pCont, false))
310  cobj->Exit(GetX(), GetY());
311  }
312  else
313  {
314  Contents.Remove(cobj);
315  cobj->Contained = nullptr;
316  cobj->AssignRemoval();
317  }
318  }
319  // remove this object from container *after* its contents have been removed!
320  if (pCont)
321  {
322  pCont->Contents.Remove(this);
323  pCont->UpdateMass();
324  pCont->SetOCF();
325  Contained=nullptr;
326  }
327  // Object info
328  if (Info) Info->Retire();
329  Info = nullptr;
330  // Object system operation
331  ClearRefs();
332  Game.ClearPointers(this);
333  ClearCommands();
334  if (pSolidMaskData)
335  {
336  delete pSolidMaskData;
337  pSolidMaskData = nullptr;
338  }
339  SolidMask.Wdt = 0;
340  RemovalDelay=2;
341 }
int32_t GetY() const
Definition: C4Object.h:287
void ClearAll(int32_t iClearFlag)
Definition: C4Effect.cpp:369
C4Config Config
Definition: C4Config.cpp:833
bool Enter(C4Object *pTarget, bool fCalls=true, bool fCopyMotion=true, bool *pfRejectCollect=nullptr)
Definition: C4Object.cpp:1260
bool Add(C4Object *nObj)
C4Game Game
Definition: C4Globals.cpp:52
C4ConfigGeneral General
Definition: C4Config.h:251
#define C4OS_NORMAL
Definition: C4Object.h:35
#define C4FxCall_RemoveClear
Definition: C4Effect.h:45
int32_t RemovalDelay
Definition: C4Object.h:109
void ClearParticleLists()
Definition: C4Object.cpp:245
C4ObjectInfo * Info
Definition: C4Object.h:145
const char * GetName() const override
Definition: C4PropList.cpp:267
C4ObjectList InactiveObjects
Definition: C4GameObjects.h:43
int32_t Wdt
Definition: C4Rect.h:30
C4NotifyingObjectList Contents
Definition: C4Object.h:152
C4Def * Def
Definition: C4Object.h:143
int32_t Count
Definition: C4Def.h:179
int32_t Owner
Definition: C4Object.h:110
bool SetAction(C4PropList *Act, C4Object *pTarget=nullptr, C4Object *pTarget2=nullptr, int32_t iCalls=SAC_StartCall|SAC_AbortCall, bool fForce=false)
Definition: C4Object.cpp:2681
bool Exit(int32_t iX=0, int32_t iY=0, int32_t iR=0, C4Real iXDir=Fix0, C4Real iYDir=Fix0, C4Real iRDir=Fix0, bool fCalls=true)
Definition: C4Object.cpp:1224
char id[32+1]
Definition: C4Record.h:150
int32_t GetX() const
Definition: C4Object.h:286
void AddDbgRec(C4RecordChunkType eType, const void *pData, int iSize)
Definition: C4Record.cpp:32
#define PSF_ContentsDestruction
Definition: C4GameScript.h:39
int32_t Status
Definition: C4PropList.h:168
void UpdateMass()
Definition: C4Object.cpp:639
void ClearCommands()
Definition: C4Object.cpp:2531
#define C4OS_INACTIVE
Definition: C4Object.h:36
void ClearPointers(C4Object *cobj)
Definition: C4Game.cpp:921
int32_t DebugRec
Definition: C4Config.h:60
C4Effect * pEffects
Definition: C4Object.h:156
#define PSF_Destruction
Definition: C4GameScript.h:38
void SetOCF()
Definition: C4Object.cpp:667
C4ObjectPtr Contained
Definition: C4Object.h:144
C4TargetRect SolidMask
Definition: C4Object.h:150
C4SolidMask * pSolidMaskData
Definition: C4Object.h:176
virtual bool Remove(C4Object *pObj)
C4GameObjects Objects
Definition: C4Globals.cpp:48
void ClearRefs()
Definition: C4PropList.h:156
C4Value Call(C4PropertyName k, C4AulParSet *pPars=nullptr, bool fPassErrors=false)
Definition: C4PropList.h:110

Here is the call graph for this function:

Here is the caller graph for this function:

bool C4Object::At ( int32_t  ctx,
int32_t  cty 
) const

Definition at line 950 of file C4Object.cpp.

References addtop(), Contained, Def, C4Shape::GetX(), GetX(), C4Shape::GetY(), GetY(), C4Rect::Hgt, Shape, C4PropList::Status, and C4Rect::Wdt.

Referenced by C4Command::Enter(), C4Command::Get(), and C4Command::Grab().

951 {
952  if (Status) if (!Contained) if (Def)
953  if (Inside<int32_t>(cty - (GetY() + Shape.GetY() - addtop()), 0, Shape.Hgt - 1 + addtop()))
954  if (Inside<int32_t>(ctx - (GetX() + Shape.GetX()), 0, Shape.Wdt - 1))
955  return true;
956  return false;
957 }
int32_t GetY() const
Definition: C4Object.h:287
int32_t GetY() const
Definition: C4Shape.h:63
int32_t Wdt
Definition: C4Rect.h:30
C4Def * Def
Definition: C4Object.h:143
int32_t GetX() const
Definition: C4Shape.h:62
int32_t GetX() const
Definition: C4Object.h:286
int32_t Status
Definition: C4PropList.h:168
C4ObjectPtr Contained
Definition: C4Object.h:144
int32_t Hgt
Definition: C4Rect.h:30
C4Shape Shape
Definition: C4Object.h:148
int32_t addtop() const
Definition: C4Object.h:281

Here is the call graph for this function:

Here is the caller graph for this function:

bool C4Object::At ( int32_t  ctx,
int32_t  cty,
DWORD ocf 
) const

Definition at line 959 of file C4Object.cpp.

References addtop(), Contained, Def, GetOCFForPos(), C4Shape::GetX(), GetX(), C4Shape::GetY(), GetY(), C4Rect::Hgt, OCF, Shape, C4PropList::Status, and C4Rect::Wdt.

960 {
961  if (Status) if (!Contained) if (Def)
962  if (OCF & ocf)
963  if (Inside<int32_t>(cty - (GetY() + Shape.GetY() - addtop()), 0, Shape.Hgt - 1 + addtop()))
964  if (Inside<int32_t>(ctx - (GetX() + Shape.GetX()), 0, Shape.Wdt - 1))
965  {
966  // Set ocf return value
967  GetOCFForPos(ctx, cty, ocf);
968  return true;
969  }
970  return false;
971 }
int32_t GetY() const
Definition: C4Object.h:287
int32_t GetY() const
Definition: C4Shape.h:63
int32_t Wdt
Definition: C4Rect.h:30
C4Def * Def
Definition: C4Object.h:143
void GetOCFForPos(int32_t ctx, int32_t cty, DWORD &ocf) const
Definition: C4Object.cpp:973
int32_t GetX() const
Definition: C4Shape.h:62
int32_t GetX() const
Definition: C4Object.h:286
int32_t Status
Definition: C4PropList.h:168
C4ObjectPtr Contained
Definition: C4Object.h:144
int32_t Hgt
Definition: C4Rect.h:30
C4Shape Shape
Definition: C4Object.h:148
uint32_t OCF
Definition: C4Object.h:134
int32_t addtop() const
Definition: C4Object.h:281

Here is the call graph for this function:

C4PropList::Iterator C4PropList::begin ( )
inherited

Definition at line 1007 of file C4PropList.cpp.

References C4PropList::begin(), C4Set< T >::First(), C4PropList::GetPrototype(), C4Set< T >::GetSize(), and C4Set< T >::Next().

Referenced by C4PropList::begin(), and C4ParticleProperties::Set().

1008 {
1009  C4PropList::Iterator iter;
1010 
1011  if (GetPrototype())
1012  {
1013  iter = GetPrototype()->begin();
1014  }
1015  else
1016  {
1017  iter.properties = std::make_shared<std::vector<const C4Property*> >();
1018  }
1019  iter.Reserve(Properties.GetSize());
1020 
1021  const C4Property * p = Properties.First();
1022  while (p)
1023  {
1024  iter.AddProperty(p);
1025  p = Properties.Next(p);
1026  }
1027 
1028  iter.Init();
1029  return iter;
1030 }
T const * Next(T const *p) const
unsigned int GetSize() const
Iterator begin()
C4PropList * GetPrototype() const
Definition: C4PropList.h:81
T const * First() const

Here is the call graph for this function:

Here is the caller graph for this function:

void C4Object::BoundsCheck ( C4Real ctcox,
C4Real ctcoy 
)
inline

Definition at line 331 of file C4Object.h.

References SideBounds(), and VerticalBounds().

Referenced by Exit().

332  { SideBounds(ctcox); VerticalBounds(ctcoy); }
void SideBounds(C4Real &ctcox)
Definition: C4Movement.cpp:156
void VerticalBounds(C4Real &ctcoy)
Definition: C4Movement.cpp:179

Here is the call graph for this function:

Here is the caller graph for this function:

C4Value C4PropList::Call ( C4PropertyName  k,
C4AulParSet pPars = nullptr,
bool  fPassErrors = false 
)
inlineinherited

Definition at line 110 of file C4PropList.h.

References C4StringTable::P, and Strings.

Referenced by C4Command::Acquire(), ActivateEntrance(), ActivateMenu(), AssignDeath(), AssignRemoval(), C4Command::Call(), C4GameScriptHost::Call(), C4Effect::CallEffect(), C4Command::CallFailed(), C4Effect::CallStart(), C4Effect::CallStop(), C4Effect::CallTimer(), C4FindObjectFunc::Check(), C4Effect::ClearAll(), Collect(), C4SortObjectFunc::CompareGetValue(), Contact(), C4GameObjects::CrossCheck(), C4Landscape::P::DigMaterial2Objects(), DirectComContents(), DoBreath(), DoCon(), DoDamage(), DoEnergy(), DoMovement(), C4ObjectMenu::DoRefillInternal(), DoSelect(), Enter(), C4RoundResults::EvaluateGame(), C4RoundResults::EvaluateGoals(), ExecAction(), ExecLife(), C4ScriptGuiWindowAction::ExecuteCommand(), ExecuteCommand(), Exit(), C4Command::Fail(), C4Command::GetTryEnter(), C4Def::GetValue(), GetValue(), GrabLost(), C4GameObjects::GRBroadcast(), C4Landscape::Incinerate(), C4Effect::Init(), C4Player::Init(), C4Game::InitGame(), C4ObjectMenu::IsCloseDenied(), C4Effect::Kill(), Lift(), C4Player::MakeCrewMember(), C4Game::NewObject(), ObjectActionJump(), ObjectComGrab(), ObjectComPunch(), ObjectComPut(), ObjectComUnGrab(), C4ObjectMenu::OnSelectionChanged(), C4GameObjects::OnSynchronized(), C4EditCursor::PerformDuplication(), C4EditCursor::PerformDuplicationLegacy(), C4Player::PlaceReadyCrew(), C4Landscape::P::PostFreeShape(), Promote(), Push(), C4Game::SaveData(), SetAction(), C4GUI::FrameDecoration::SetByDef(), SetCommand(), C4Player::SetObjectCrewStatus(), SetOwner(), StatusActivate(), C4Command::Transfer(), and UnSelect().

111  { return Call(&Strings.P[k], pPars, fPassErrors); }
C4String P[P_LAST]
C4StringTable Strings
Definition: C4Globals.cpp:42
C4Value Call(C4PropertyName k, C4AulParSet *pPars=nullptr, bool fPassErrors=false)
Definition: C4PropList.h:110

Here is the caller graph for this function:

C4Value C4PropList::Call ( C4String k,
C4AulParSet pPars = nullptr,
bool  fPassErrors = false 
)
inherited

Definition at line 828 of file C4PropList.cpp.

References C4PropList::C4Value, C4AulFunc::Exec(), C4PropList::GetFunc(), and C4PropList::Status.

829 {
830  if (!Status) return C4Value();
831  C4AulFunc *pFn = GetFunc(k);
832  if (!pFn) return C4Value();
833  return pFn->Exec(this, Pars, fPassErrors);
834 }
C4AulFunc * GetFunc(C4PropertyName k) const
Definition: C4PropList.h:105
friend class C4Value
Definition: C4PropList.h:165
C4Value Exec(C4PropList *p=nullptr, C4AulParSet *pPars=nullptr, bool fPassErrors=false)
Definition: C4AulFunc.h:72
int32_t Status
Definition: C4PropList.h:168

Here is the call graph for this function:

C4Value C4PropList::Call ( const char *  k,
C4AulParSet pPars = nullptr,
bool  fPassErrors = false 
)
inherited

Definition at line 836 of file C4PropList.cpp.

References C4PropList::C4Value, C4AulFunc::Exec(), FormatString(), C4AulScriptEngine::GetErrorHandler(), C4PropList::GetFunc(), C4AulErrorHandler::OnError(), ScriptEngine, C4PropList::Status, and C4AulError::what().

837 {
838  if (!Status) return C4Value();
839  assert(s && s[0]);
840  C4AulFunc *pFn = GetFunc(s);
841  if (!pFn)
842  {
843  if (s[0] != '~')
844  {
845  C4AulExecError err(FormatString("Undefined function: %s", s).getData());
846  if (fPassErrors)
847  throw err;
848  ::ScriptEngine.GetErrorHandler()->OnError(err.what());
849  }
850  return C4Value();
851  }
852  return pFn->Exec(this, Pars, fPassErrors);
853 }
C4AulErrorHandler * GetErrorHandler() const
Definition: C4Aul.h:173
C4AulScriptEngine ScriptEngine
Definition: C4Globals.cpp:43
C4AulFunc * GetFunc(C4PropertyName k) const
Definition: C4PropList.h:105
friend class C4Value
Definition: C4PropList.h:165
C4Value Exec(C4PropList *p=nullptr, C4AulParSet *pPars=nullptr, bool fPassErrors=false)
Definition: C4AulFunc.h:72
int32_t Status
Definition: C4PropList.h:168
virtual void OnError(const char *msg)=0
#define s
StdStrBuf FormatString(const char *szFmt,...)
Definition: StdBuf.cpp:270

Here is the call graph for this function:

bool C4Object::CanConcatPictureWith ( C4Object pOtherObject) const

Definition at line 4751 of file C4Object.cpp.

References C4Def::AllowPictureStack, APS_Color, APS_Graphics, APS_Name, APS_Overlay, BlitMode, Color, C4Def::ColorByOwner, ColorMod, Def, GetGraphicsOverlay(), C4PropList::GetName(), C4GraphicsOverlay::GetNext(), id, pGfxOverlay, pGraphics, and PictureRect.

Referenced by C4ObjectMenu::DoRefillInternal(), and ShiftContents().

4752 {
4753  // check current definition ID
4754  if (id != pOtherObject->id) return false;
4755  // def overwrite of stack conditions
4756  int32_t allow_picture_stack = Def->AllowPictureStack;
4757  if (!(allow_picture_stack & APS_Color))
4758  {
4759  // check color if ColorByOwner (flags)
4760  if (Color != pOtherObject->Color && Def->ColorByOwner) return false;
4761  // check modulation
4762  if (ColorMod != pOtherObject->ColorMod) return false;
4763  if (BlitMode != pOtherObject->BlitMode) return false;
4764  }
4765  if (!(allow_picture_stack & APS_Graphics))
4766  {
4767  // check graphics
4768  if (pGraphics != pOtherObject->pGraphics) return false;
4769  // check any own picture rect
4770  if (PictureRect != pOtherObject->PictureRect) return false;
4771  }
4772  if (!(allow_picture_stack & APS_Name))
4773  {
4774  // check name, so zagabar's sandwiches don't stack
4775  if (GetName() != pOtherObject->GetName()) return false;
4776  }
4777  if (!(allow_picture_stack & APS_Overlay))
4778  {
4779  // check overlay graphics
4780  for (C4GraphicsOverlay *pOwnOverlay = pGfxOverlay; pOwnOverlay; pOwnOverlay = pOwnOverlay->GetNext())
4781  if (pOwnOverlay->IsPicture())
4782  {
4783  C4GraphicsOverlay *pOtherOverlay = pOtherObject->GetGraphicsOverlay(pOwnOverlay->GetID(), false);
4784  if (!pOtherOverlay || !(*pOtherOverlay == *pOwnOverlay)) return false;
4785  }
4786  for (C4GraphicsOverlay *pOtherOverlay = pOtherObject->pGfxOverlay; pOtherOverlay; pOtherOverlay = pOtherOverlay->GetNext())
4787  if (pOtherOverlay->IsPicture())
4788  if (!GetGraphicsOverlay(pOtherOverlay->GetID())) return false;
4789  }
4790  // concat OK
4791  return true;
4792 }
C4ID id
Definition: C4Object.h:108
C4Rect PictureRect
Definition: C4Object.h:151
C4Def * Def
Definition: C4Object.h:143
virtual const char * GetName() const
Definition: C4PropList.cpp:649
uint32_t Color
Definition: C4Object.h:120
C4DefGraphics * pGraphics
Definition: C4Object.h:154
class C4GraphicsOverlay * pGfxOverlay
Definition: C4Object.h:170
int32_t ColorByOwner
Definition: C4Def.h:121
uint32_t ColorMod
Definition: C4Object.h:161
int32_t AllowPictureStack
Definition: C4Def.h:147
int32_t GetID() const
uint32_t BlitMode
Definition: C4Object.h:162
class C4GraphicsOverlay * GetGraphicsOverlay(int32_t iForID) const
Definition: C4Object.cpp:4473
C4GraphicsOverlay * GetNext() const

Here is the call graph for this function:

Here is the caller graph for this function:

bool C4Object::ChangeDef ( C4ID  idNew)

Definition at line 1040 of file C4Object.cpp.

References C4Def::BlitMode, BlitMode, C4GFXBLIT_CUSTOM, C4Id2Def(), C4VPropList(), Color, C4Player::ColorDw, Contained, C4Def::Count, Def, Enter(), Exit(), Fix0, fix_r, GameScript, C4PlayerList::Get(), C4Def::Graphics, C4Def::id, Objects, C4Effect::OnObjectChangedDef(), Owner, C4StringTable::P, P_Action, P_Prototype, C4AulScriptEngine::pGlobalEffects, pGraphics, Players, C4GameScriptHost::pScenarioEffects, pSolidMaskData, rdir, ResetProperty(), C4Def::Rotateable, ScriptEngine, SetAction(), SetDir(), SetOCF(), C4PropList::SetProperty(), C4Def::SolidMask, SolidMask, Strings, Unsorted, UpdateFace(), UpdateGraphics(), UpdateMass(), and ValidPlr().

1041 {
1042  // Get new definition
1043  C4Def *pDef=C4Id2Def(idNew);
1044  if (!pDef) return false;
1045  // Containment storage
1046  C4Object *pContainer=Contained;
1047  // Exit container (no Ejection/Departure)
1048  if (Contained) Exit(0,0,0,Fix0,Fix0,Fix0,false);
1049  // Pre change resets
1050  SetAction(nullptr);
1051  ResetProperty(&Strings.P[P_Action]); // Enforce ActIdle because SetAction may have failed due to NoOtherAction
1052  SetDir(0); // will drop any outdated flipdir
1053  if (pSolidMaskData) { delete pSolidMaskData; pSolidMaskData=nullptr; }
1054  Def->Count--;
1055  // Def change
1056  Def=pDef;
1058  id=pDef->id;
1059  Def->Count++;
1060  // new def: Needs to be resorted
1061  Unsorted=true;
1062  // graphics change
1063  pGraphics = &pDef->Graphics;
1064  // blit mode adjustment
1066  // an object may have newly become an ColorByOwner-object
1067  // if it had been ColorByOwner, but is not now, this will be caught in UpdateGraphics()
1068  if (!Color && ValidPlr(Owner))
1070  if (!Def->Rotateable) { fix_r=rdir=Fix0; }
1071  // Reset solid mask
1073  // Post change updates
1074  UpdateGraphics(true);
1075  UpdateMass();
1076  UpdateFace(true);
1077  SetOCF();
1078  // Any effect callbacks to this object might need to reinitialize their target functions
1079  // This is ugly, because every effect there is must be updated...
1084  for (C4Object *obj : Objects)
1085  if (obj->pEffects) obj->pEffects->OnObjectChangedDef(this);
1086  // Containment (no Entrance)
1087  if (pContainer) Enter(pContainer,false);
1088  // Done
1089  return true;
1090 }
C4String P[P_LAST]
C4ID id
Definition: C4Def.h:101
bool Enter(C4Object *pTarget, bool fCalls=true, bool fCopyMotion=true, bool *pfRejectCollect=nullptr)
Definition: C4Object.cpp:1260
C4GameScriptHost GameScript
void SetDir(int32_t tdir)
Definition: C4Object.cpp:2840
C4AulScriptEngine ScriptEngine
Definition: C4Globals.cpp:43
C4Real rdir
Definition: C4Object.h:126
void SetProperty(C4PropertyName k, const C4Value &to)
Definition: C4PropList.h:120
void ResetProperty(C4String *k) override
Definition: C4Object.cpp:4859
void UpdateGraphics(bool fGraphicsChanged, bool fTemp=false)
Definition: C4Object.cpp:404
uint32_t ColorDw
Definition: C4Player.h:89
int32_t Rotateable
Definition: C4Def.h:119
C4Player * Get(int iPlayer) const
C4Def * Def
Definition: C4Object.h:143
C4StringTable Strings
Definition: C4Globals.cpp:42
C4Value C4VPropList(C4PropList *p)
Definition: C4Value.h:245
int32_t Count
Definition: C4Def.h:179
int32_t Owner
Definition: C4Object.h:110
C4PlayerList Players
bool SetAction(C4PropList *Act, C4Object *pTarget=nullptr, C4Object *pTarget2=nullptr, int32_t iCalls=SAC_StartCall|SAC_AbortCall, bool fForce=false)
Definition: C4Object.cpp:2681
bool Exit(int32_t iX=0, int32_t iY=0, int32_t iR=0, C4Real iXDir=Fix0, C4Real iYDir=Fix0, C4Real iRDir=Fix0, bool fCalls=true)
Definition: C4Object.cpp:1224
uint32_t Color
Definition: C4Object.h:120
Definition: C4Def.h:98
C4DefGraphics * pGraphics
Definition: C4Object.h:154
void UpdateMass()
Definition: C4Object.cpp:639
C4TargetRect SolidMask
Definition: C4Def.h:108
void UpdateFace(bool bUpdateShape, bool fTemp=false)
Definition: C4Object.cpp:378
bool Unsorted
Definition: C4Object.h:129
C4Def * C4Id2Def(C4ID id)
Definition: C4DefList.h:84
#define C4GFXBLIT_CUSTOM
Definition: C4Surface.h:35
C4Real fix_r
Definition: C4Object.h:125
int32_t ValidPlr(int32_t plr)
C4Effect * pScenarioEffects
Definition: C4ScriptHost.h:165
int32_t BlitMode
Definition: C4Def.h:141
uint32_t BlitMode
Definition: C4Object.h:162
void SetOCF()
Definition: C4Object.cpp:667
C4ObjectPtr Contained
Definition: C4Object.h:144
C4TargetRect SolidMask
Definition: C4Object.h:150
C4SolidMask * pSolidMaskData
Definition: C4Object.h:176
C4DefGraphics Graphics
Definition: C4Def.h:191
C4Effect * pGlobalEffects
Definition: C4Aul.h:144
C4GameObjects Objects
Definition: C4Globals.cpp:48
const C4Real Fix0
Definition: C4Real.h:312
void OnObjectChangedDef(C4PropList *pObj)
Definition: C4Effect.cpp:471

Here is the call graph for this function:

bool C4PropListNumbered::CheckPropList ( C4PropList pObj)
staticinherited

Definition at line 80 of file C4PropList.cpp.

References C4Set< T >::First(), C4Set< T >::Next(), and C4PropListNumbered::PropLists.

Referenced by SetOCF(), UpdateOCF(), and C4PropList::~C4PropList().

81 {
82  if (!pObj) return false;
83  C4PropListNumbered * const * p = PropLists.First();
84  while (p)
85  {
86  if (*p == pObj)
87  return true;
88  p = PropLists.Next(p);
89  }
90  return false;
91 }
T const * Next(T const *p) const
static C4Set< C4PropListNumbered * > PropLists
Definition: C4PropList.h:236
T const * First() const

Here is the call graph for this function:

Here is the caller graph for this function:

bool C4Object::CheckSolidMaskRect ( )

Definition at line 2474 of file C4Object.cpp.

References Def, CSurface8::Hgt, C4Rect::Hgt, C4Def::pSolidMask, C4TargetRect::Set(), SolidMask, C4TargetRect::tx, C4TargetRect::ty, CSurface8::Wdt, C4Rect::Wdt, C4Rect::x, and C4Rect::y.

Referenced by Init(), and SetSolidMask().

2475 {
2476  // Ensure SolidMask rect lies within bounds of SolidMask bitmap in definition
2477  CSurface8 *sfcGraphics = Def->pSolidMask;
2478  if (!sfcGraphics)
2479  {
2480  // no graphics to set solid in
2481  SolidMask.Set(0,0,0,0,0,0);
2482  return false;
2483  }
2484  SolidMask.Set(std::max<int32_t>(SolidMask.x,0), std::max<int32_t>(SolidMask.y,0),
2485  std::min<int32_t>(SolidMask.Wdt,sfcGraphics->Wdt-SolidMask.x), std::min<int32_t>(SolidMask.Hgt, sfcGraphics->Hgt-SolidMask.y),
2487  if (SolidMask.Hgt<=0) SolidMask.Wdt=0;
2488  return SolidMask.Wdt>0;
2489 }
int Hgt
Definition: CSurface8.h:28
CSurface8 * pSolidMask
Definition: C4Def.h:192
int32_t Wdt
Definition: C4Rect.h:30
C4Def * Def
Definition: C4Object.h:143
int32_t y
Definition: C4Rect.h:30
int32_t tx
Definition: C4Rect.h:79
int32_t ty
Definition: C4Rect.h:79
int32_t x
Definition: C4Rect.h:30
int Wdt
Definition: CSurface8.h:28
int32_t Hgt
Definition: C4Rect.h:30
void Set(int32_t iX, int32_t iY, int32_t iWdt, int32_t iHgt, int32_t iTX, int32_t iTY)
Definition: C4Rect.cpp:45
C4TargetRect SolidMask
Definition: C4Object.h:150

Here is the call graph for this function:

Here is the caller graph for this function:

void C4Object::Clear ( )

Definition at line 2432 of file C4Object.cpp.

References ClearParticleLists(), Command, MaterialContents, Menu, C4Command::Next, pDrawTransform, pEffects, pGfxOverlay, pMeshInstance, and pSolidMaskData.

Referenced by CompileFunc(), and ~C4Object().

2433 {
2435 
2436  if (pEffects) { delete pEffects; pEffects=nullptr; }
2437  if (pSolidMaskData) { delete pSolidMaskData; pSolidMaskData=nullptr; }
2438  if (Menu) delete Menu; Menu=nullptr;
2439  if (MaterialContents) delete MaterialContents; MaterialContents=nullptr;
2440  // clear commands!
2441  C4Command *pCom, *pNext;
2442  for (pCom=Command; pCom; pCom=pNext)
2443  {
2444  pNext=pCom->Next; delete pCom; pCom=pNext;
2445  }
2446  if (pDrawTransform) { delete pDrawTransform; pDrawTransform=nullptr; }
2447  if (pGfxOverlay) { delete pGfxOverlay; pGfxOverlay=nullptr; }
2448  if (pMeshInstance) { delete pMeshInstance; pMeshInstance = nullptr; }
2449 }
C4DrawTransform * pDrawTransform
Definition: C4Object.h:137
C4Command * Next
Definition: C4Command.h:90
C4MaterialList * MaterialContents
Definition: C4Object.h:153
C4Command * Command
Definition: C4Object.h:166
void ClearParticleLists()
Definition: C4Object.cpp:245
class C4ObjectMenu * Menu
Definition: C4Object.h:140
class C4GraphicsOverlay * pGfxOverlay
Definition: C4Object.h:170
C4Effect * pEffects
Definition: C4Object.h:156
C4SolidMask * pSolidMaskData
Definition: C4Object.h:176
StdMeshInstance * pMeshInstance
Definition: C4Object.h:155

Here is the call graph for this function:

Here is the caller graph for this function:

void C4Object::ClearCommand ( C4Command pUntil)

Definition at line 2545 of file C4Object.cpp.

References Command, C4Command::iExec, and C4Command::Next.

Referenced by ExecuteCommand(), GrabLost(), and ObjectComStopDig().

2546 {
2547  C4Command *pCom,*pNext;
2548  for (pCom=Command; pCom; pCom=pNext)
2549  {
2550  // Last one to clear
2551  if (pCom==pUntil) pNext=nullptr;
2552  // Next one to clear after this
2553  else pNext=pCom->Next;
2554  Command=pCom->Next;
2555  if (!pCom->iExec)
2556  delete pCom;
2557  else
2558  pCom->iExec = 2;
2559  }
2560 }
C4Command * Next
Definition: C4Command.h:90
C4Command * Command
Definition: C4Object.h:166
int32_t iExec
Definition: C4Command.h:91

Here is the caller graph for this function:

void C4Object::ClearCommands ( )

Definition at line 2531 of file C4Object.cpp.

References Command, C4Command::iExec, and C4Command::Next.

Referenced by AssignDeath(), AssignRemoval(), and SetCommand().

2532 {
2533  C4Command *pNext;
2534  while (Command)
2535  {
2536  pNext=Command->Next;
2537  if (!Command->iExec)
2538  delete Command;
2539  else
2540  Command->iExec = 2;
2541  Command=pNext;
2542  }
2543 }
C4Command * Next
Definition: C4Command.h:90
C4Command * Command
Definition: C4Object.h:166
int32_t iExec
Definition: C4Command.h:91

Here is the caller graph for this function:

void C4Object::ClearContentsAndContained ( bool  fDoCalls = true)

Definition at line 4575 of file C4Object.cpp.

References Contained, Contents, Exit(), Fix0, GetX(), and GetY().

Referenced by StatusDeactivate().

4576 {
4577  // exit contents from container
4578  for (C4Object *cobj : Contents)
4579  {
4580  cobj->Exit(GetX(), GetY(), 0,Fix0,Fix0,Fix0, fDoCalls);
4581  }
4582  // remove from container *after* contents have been removed!
4583  if (Contained) Exit(GetX(), GetY(), 0, Fix0, Fix0, Fix0, fDoCalls);
4584 }
int32_t GetY() const
Definition: C4Object.h:287
C4NotifyingObjectList Contents
Definition: C4Object.h:152
bool Exit(int32_t iX=0, int32_t iY=0, int32_t iR=0, C4Real iXDir=Fix0, C4Real iYDir=Fix0, C4Real iRDir=Fix0, bool fCalls=true)
Definition: C4Object.cpp:1224
int32_t GetX() const
Definition: C4Object.h:286
C4ObjectPtr Contained
Definition: C4Object.h:144
const C4Real Fix0
Definition: C4Real.h:312

Here is the call graph for this function:

Here is the caller graph for this function:

void C4Object::ClearInfo ( C4ObjectInfo pInfo)

Definition at line 2424 of file C4Object.cpp.

References Info.

Referenced by C4ObjectList::ClearInfo(), and GrabInfo().

2425 {
2426  if (Info==pInfo)
2427  {
2428  Info=nullptr;
2429  }
2430 }
C4ObjectInfo * Info
Definition: C4Object.h:145

Here is the caller graph for this function:

void C4PropListNumbered::ClearNumber ( )
protectedinherited

Definition at line 165 of file C4PropList.cpp.

References C4PropListNumbered::Number, C4PropListNumbered::PropLists, and C4Set< T >::Remove().

Referenced by C4PropListNumbered::ShelveNumberedPropLists().

166 {
167  // Make proplist invisible during denumeration process
168  if (Number != -1)
169  {
170  PropLists.Remove(this);
171  Number = -1;
172  }
173 }
void Remove(H e)
static C4Set< C4PropListNumbered * > PropLists
Definition: C4PropList.h:236

Here is the call graph for this function:

Here is the caller graph for this function:

void C4PropListNumbered::ClearNumberedPropLists ( )
staticinherited

Definition at line 137 of file C4PropList.cpp.

References C4PropList::Clear(), C4Set< T >::First(), C4Set< T >::Next(), and C4PropListNumbered::PropLists.

Referenced by C4Game::Clear().

138 {
139  // empty all proplists to ensure safe deletion of proplists with circular references
140  // note that this the call to Clear() might delete some prop lists. So it is assumed that
141  // PropLists does not shrink its table as the number of values goes down
142  C4PropListNumbered *const* p_next = PropLists.First(), *const* p;
143  while ((p = p_next))
144  {
145  p_next = PropLists.Next(p);
146  // check *p since it might have been deleted by clearing the previous prop list
147  if (*p) (*p)->Clear();
148  }
149 }
void Clear()
Definition: C4PropList.h:66
T const * Next(T const *p) const
static C4Set< C4PropListNumbered * > PropLists
Definition: C4PropList.h:236
T const * First() const

Here is the call graph for this function:

Here is the caller graph for this function:

void C4Object::ClearParticleLists ( )

Definition at line 245 of file C4Object.cpp.

References BackParticles, FrontParticles, Particles, and C4ParticleSystem::ReleaseParticleList().

Referenced by AssignRemoval(), Clear(), Default(), and StatusDeactivate().

246 {
247  if (FrontParticles != nullptr)
249  if (BackParticles != nullptr)
251  FrontParticles = BackParticles = nullptr;
252 }
C4ParticleSystem Particles
class C4ParticleList * BackParticles
Definition: C4Object.h:158
void ReleaseParticleList(C4ParticleList *first, C4ParticleList *second=nullptr)
class C4ParticleList * FrontParticles
Definition: C4Object.h:158

Here is the call graph for this function:

Here is the caller graph for this function:

void C4Object::ClearPointers ( C4Object ptr)

Definition at line 1735 of file C4Object.cpp.

References Action, C4ObjectMenu::ClearPointers(), C4Command::ClearPointers(), C4Effect::ClearPointers(), StdMeshInstance::ClearPointers(), Command, Contained, Contents, C4GraphicsOverlay::GetNext(), Layer, Menu, C4Command::Next, pEffects, pGfxOverlay, pMeshInstance, C4ObjectList::Remove(), RemoveGraphicsOverlay(), C4Action::Target, and C4Action::Target2.

Referenced by C4Game::ClearObjectPtrs().

1736 {
1737  // mesh attachments and animation nodes
1739  // effects
1740  if (pEffects) pEffects->ClearPointers(pObj);
1741  // contents/contained: although normally not necessery because it's done in AssignRemoval and StatusDeactivate,
1742  // it is also required during game destruction (because ClearPointers might do script callbacks)
1743  // Perform silent exit to avoid additional callbacks
1744  if (Contained == pObj)
1745  {
1746  Contained->Contents.Remove(this);
1747  Contained = nullptr;
1748  }
1749  Contents.Remove(pObj);
1750  // Action targets
1751  if (Action.Target==pObj) Action.Target=nullptr;
1752  if (Action.Target2==pObj) Action.Target2=nullptr;
1753  // Commands
1754  C4Command *cCom;
1755  for (cCom=Command; cCom; cCom=cCom->Next)
1756  cCom->ClearPointers(pObj);
1757  // Menu
1758  if (Menu) Menu->ClearPointers(pObj);
1759  // Layer
1760  if (Layer==pObj) Layer=nullptr;
1761  // gfx overlays
1762  if (pGfxOverlay)
1763  {
1764  C4GraphicsOverlay *pNextGfxOvrl = pGfxOverlay, *pGfxOvrl;
1765  while ((pGfxOvrl = pNextGfxOvrl))
1766  {
1767  pNextGfxOvrl = pGfxOvrl->GetNext();
1768  if (pGfxOvrl->GetOverlayObject() == pObj)
1769  // overlay relying on deleted object: Delete!
1770  RemoveGraphicsOverlay(pGfxOvrl->GetID());
1771  }
1772  }
1773 }
C4Command * Next
Definition: C4Command.h:90
C4Command * Command
Definition: C4Object.h:166
void ClearPointers(C4Object *pObj)
Definition: C4Command.cpp:1289
C4ObjectPtr Target2
Definition: C4Object.h:87
C4ObjectPtr Layer
Definition: C4Object.h:136
void ClearPointers(C4Object *pObj)
class C4ObjectMenu * Menu
Definition: C4Object.h:140
C4NotifyingObjectList Contents
Definition: C4Object.h:152
void ClearPointers(class C4Object *pObj)
Definition: StdMesh.cpp:1681
class C4GraphicsOverlay * pGfxOverlay
Definition: C4Object.h:170
C4ObjectPtr Target
Definition: C4Object.h:87
C4Effect * pEffects
Definition: C4Object.h:156
C4ObjectPtr Contained
Definition: C4Object.h:144
C4Action Action
Definition: C4Object.h:147
bool RemoveGraphicsOverlay(int32_t iOverlayID)
Definition: C4Object.cpp:4501
void ClearPointers(C4PropList *pObj)
Definition: C4Effect.cpp:191
StdMeshInstance * pMeshInstance
Definition: C4Object.h:155
virtual bool Remove(C4Object *pObj)
C4GraphicsOverlay * GetNext() const

Here is the call graph for this function:

Here is the caller graph for this function:

void C4PropList::ClearRefs ( )
inlineprotectedinherited

Definition at line 156 of file C4PropList.h.

References C4Value::Set0().

Referenced by AssignRemoval().

156 { while (FirstRef) FirstRef->Set0(); }
void Set0()
Definition: C4Value.h:336

Here is the call graph for this function:

Here is the caller graph for this function:

void C4PropListNumbered::ClearShelve ( )
staticinherited

Definition at line 131 of file C4PropList.cpp.

References C4PropListNumbered::ShelvedPropLists.

Referenced by C4Game::Clear().

132 {
133  // cleanup shelve - used in game clear, un unsuccessful section load, etc.
134  ShelvedPropLists.clear();
135 }
static std::vector< C4PropListNumbered * > ShelvedPropLists
Definition: C4PropList.h:237

Here is the caller graph for this function:

bool C4Object::CloseMenu ( bool  fForce)

Definition at line 1570 of file C4Object.cpp.

References C4Menu::IsActive(), C4ObjectMenu::IsCloseQuerying(), Menu, and C4Menu::TryClose().

Referenced by ActivateMenu(), Enter(), Exit(), ObjectComUnGrab(), SetCommand(), and SyncClearance().

1571 {
1572  if (Menu)
1573  {
1574  if (Menu->IsActive()) if (!Menu->TryClose(fForce, false)) return false;
1575  if (!Menu->IsCloseQuerying()) { delete Menu; Menu=nullptr; } // protect menu deletion from recursive menu operation calls
1576  }
1577  return true;
1578 }
class C4ObjectMenu * Menu
Definition: C4Object.h:140
bool IsActive()
Definition: C4Menu.cpp:480
bool TryClose(bool fOK, bool fControl)
Definition: C4Menu.cpp:280
bool IsCloseQuerying() const
Definition: C4ObjectMenu.h:74

Here is the call graph for this function:

Here is the caller graph for this function:

bool C4Object::Collect ( C4Object pObj)

Definition at line 4167 of file C4Object.cpp.

References C4PropList::Call(), Contained, CopyMotion(), Enter(), ObjectComCancelAttach(), OCF, OCF_HitSpeed1, OCF_HitSpeed2, OCF_HitSpeed3, PSF_Collection, PSF_Hit, PSF_Hit2, PSF_Hit3, and C4PropList::Status.

Referenced by C4GameObjects::CrossCheck(), and C4Landscape::P::DigMaterial2Objects().

4168 {
4169  // Object enter container
4170  bool fRejectCollect;
4171  if (!pObj->Enter(this, true, false, &fRejectCollect))
4172  return false;
4173  // Cancel attach (hacky)
4174  ObjectComCancelAttach(pObj);
4175  // Container Collection call
4177  // Object Hit call
4178  if (pObj->Status && pObj->OCF & OCF_HitSpeed1) pObj->Call(PSF_Hit);
4179  if (pObj->Status && pObj->OCF & OCF_HitSpeed2) pObj->Call(PSF_Hit2);
4180  if (pObj->Status && pObj->OCF & OCF_HitSpeed3) pObj->Call(PSF_Hit3);
4181  // post-copy the motion of the new container
4182  if (pObj->Contained == this) pObj->CopyMotion(this);
4183  // done, success
4184  return true;
4185 }
const uint32_t OCF_HitSpeed1
Definition: C4Constants.h:84
bool Enter(C4Object *pTarget, bool fCalls=true, bool fCopyMotion=true, bool *pfRejectCollect=nullptr)
Definition: C4Object.cpp:1260
#define PSF_Hit
Definition: C4GameScript.h:49
bool ObjectComCancelAttach(C4Object *cObj)
const uint32_t OCF_HitSpeed2
Definition: C4Constants.h:91
#define PSF_Hit2
Definition: C4GameScript.h:50
int32_t Status
Definition: C4PropList.h:168
void CopyMotion(C4Object *from)
Definition: C4Movement.cpp:503
#define PSF_Hit3
Definition: C4GameScript.h:51
const uint32_t OCF_HitSpeed3
Definition: C4Constants.h:92
#define PSF_Collection
Definition: C4GameScript.h:56
C4ObjectPtr Contained
Definition: C4Object.h:144
uint32_t OCF
Definition: C4Object.h:134
C4Value Call(C4PropertyName k, C4AulParSet *pPars=nullptr, bool fPassErrors=false)
Definition: C4PropList.h:110

Here is the call graph for this function:

Here is the caller graph for this function:

void C4Object::CompileFunc ( StdCompiler pComp,
C4ValueNumbers numbers 
)

Definition at line 2158 of file C4Object.cpp.

References Action, Alive, C4Action::Animation, C4Def::BlitMode, BlitMode, Breath, C4MeshDenumeratorFactory, Category, Clear(), StdStrBuf::Clear(), C4Command::cObj, Color, ColorMod, Command, Con, Contained, Contents, Controller, C4Def::Count, CrewDisabled, Damage, Def, Definitions, Energy, EntranceStatus, StdCompiler::excNotFound(), Fix0, fix_r, fix_x, fix_y, StdCompiler::FollowName(), FormatString(), fOwnVertices, C4Game::fResortAnyObject, FullCon, Game, StdStrBuf::getData(), StdMeshInstance::GetRootAnimationForSlot(), C4Def::Graphics, C4Def::GrowthType, C4DefList::ID2Def(), iLastAttachMovementFrame, Info, InLiquid, StdCompiler::isDeserializer(), LastEnergyLossCausePlayer, Layer, lightColor, lightFadeoutRange, lightRange, LoadResStr(), Mass, mkNamingAdapt(), mkNamingPtrAdapt(), mkParAdapt(), Mobile, C4ObjectInfoCore::Name, C4Command::Next, nInfo, NO_OWNER, C4ID::None, C4ObjectPtr::Null, OCF, OnFire, Owner, OwnMass, pDrawTransform, pEffects, pGfxOverlay, pGraphics, PictureRect, Plane, pMeshInstance, rdir, StdMeshInstance::SetFaceOrderingForClrModulation(), C4Def::Shape, Shape, C4Def::SolidMask, SolidMask, C4PropList::Status, C4Action::Target, C4Action::Target2, toC4CStrBuf, C4DefGraphics::Type, C4DefGraphics::TYPE_Mesh, Unsorted, StdCompiler::Value(), xdir, and ydir.

2159 {
2160  bool deserializing = pComp->isDeserializer();
2161  if (deserializing)
2162  Clear();
2163 
2164  // Compile ID, search definition
2165  pComp->Value(mkNamingAdapt(id, "id", C4ID::None ));
2166  if (deserializing)
2167  {
2168  Def = ::Definitions.ID2Def(id);
2169  if (!Def)
2170  { pComp->excNotFound(LoadResStr("IDS_PRC_UNDEFINEDOBJECT"),id.ToString()); return; }
2171  }
2172 
2173  pComp->Value(mkNamingAdapt( mkParAdapt(static_cast<C4PropListNumbered&>(*this), numbers), "Properties"));
2174  pComp->Value(mkNamingAdapt( Status, "Status", 1 ));
2175  if (Info) nInfo = Info->Name; else nInfo.Clear();
2176  pComp->Value(mkNamingAdapt( toC4CStrBuf(nInfo), "Info", "" ));
2177  pComp->Value(mkNamingAdapt( Owner, "Owner", NO_OWNER ));
2178  pComp->Value(mkNamingAdapt( Controller, "Controller", NO_OWNER ));
2179  pComp->Value(mkNamingAdapt( LastEnergyLossCausePlayer, "LastEngLossPlr", NO_OWNER ));
2180  pComp->Value(mkNamingAdapt( Category, "Category", 0 ));
2181  pComp->Value(mkNamingAdapt( Plane, "Plane", 0 ));
2182 
2183  pComp->Value(mkNamingAdapt( iLastAttachMovementFrame, "LastSolidAtchFrame", -1 ));
2184  pComp->Value(mkNamingAdapt( Con, "Size", 0 ));
2185  pComp->Value(mkNamingAdapt( OwnMass, "OwnMass", 0 ));
2186  pComp->Value(mkNamingAdapt( Mass, "Mass", 0 ));
2187  pComp->Value(mkNamingAdapt( Damage, "Damage", 0 ));
2188  pComp->Value(mkNamingAdapt( Energy, "Energy", 0 ));
2189  pComp->Value(mkNamingAdapt( Alive, "Alive", false ));
2190  pComp->Value(mkNamingAdapt( Breath, "Breath", 0 ));
2191  pComp->Value(mkNamingAdapt( Color, "Color", 0u ));
2192  pComp->Value(mkNamingAdapt( fix_x, "X", Fix0 ));
2193  pComp->Value(mkNamingAdapt( fix_y, "Y", Fix0 ));
2194  pComp->Value(mkNamingAdapt( fix_r, "R", Fix0 ));
2195  pComp->Value(mkNamingAdapt( xdir, "XDir", 0 ));
2196  pComp->Value(mkNamingAdapt( ydir, "YDir", 0 ));
2197  pComp->Value(mkNamingAdapt( rdir, "RDir", 0 ));
2198  pComp->Value(mkParAdapt(Shape, &Def->Shape));
2199  pComp->Value(mkNamingAdapt( fOwnVertices, "OwnVertices", false ));
2200  pComp->Value(mkNamingAdapt( SolidMask, "SolidMask", Def->SolidMask ));
2201  pComp->Value(mkNamingAdapt( PictureRect, "Picture" ));
2202  pComp->Value(mkNamingAdapt( Mobile, "Mobile", false ));
2203  pComp->Value(mkNamingAdapt( OnFire, "OnFire", false ));
2204  pComp->Value(mkNamingAdapt( InLiquid, "InLiquid", false ));
2205  pComp->Value(mkNamingAdapt( EntranceStatus, "EntranceStatus", false ));
2206  pComp->Value(mkNamingAdapt( OCF, "OCF", 0u ));
2207  pComp->Value(Action);
2208  pComp->Value(mkNamingAdapt( Contained, "Contained", C4ObjectPtr::Null ));
2209  pComp->Value(mkNamingAdapt( Action.Target, "ActionTarget1", C4ObjectPtr::Null ));
2210  pComp->Value(mkNamingAdapt( Action.Target2, "ActionTarget2", C4ObjectPtr::Null ));
2211  pComp->Value(mkNamingAdapt( mkParAdapt(Contents, numbers), "Contents" ));
2212  pComp->Value(mkNamingAdapt( lightRange, "LightRange", 0 ));
2213  pComp->Value(mkNamingAdapt( lightFadeoutRange, "LightFadeoutRange", 0 ));
2214  pComp->Value(mkNamingAdapt( lightColor, "lightColor", 0xffffffffu ));
2215  pComp->Value(mkNamingAdapt( ColorMod, "ColorMod", 0xffffffffu ));
2216  pComp->Value(mkNamingAdapt( BlitMode, "BlitMode", 0u ));
2217  pComp->Value(mkNamingAdapt( CrewDisabled, "CrewDisabled", false ));
2218  pComp->Value(mkNamingAdapt( Layer, "Layer", C4ObjectPtr::Null ));
2219  pComp->Value(mkNamingAdapt( C4DefGraphicsAdapt(pGraphics), "Graphics", &Def->Graphics ));
2220  pComp->Value(mkNamingPtrAdapt( pDrawTransform, "DrawTransform" ));
2221  pComp->Value(mkParAdapt(mkNamingPtrAdapt( pEffects, "Effects" ), this, numbers));
2222  pComp->Value(mkNamingAdapt( C4GraphicsOverlayListAdapt(pGfxOverlay),"GfxOverlay", (C4GraphicsOverlay *)nullptr));
2223 
2224  // Serialize mesh instance if we have a mesh graphics
2226  {
2227  if(pComp->isDeserializer())
2228  {
2229  assert(!pMeshInstance);
2230  pMeshInstance = new StdMeshInstance(*pGraphics->Mesh, Def->GrowthType ? 1.0f : static_cast<float>(Con)/static_cast<float>(FullCon));
2231  }
2232 
2234 
2235  // Does not work because unanimated meshes without attached meshes
2236  // do not even write a [Mesh] header so this does not create a mesh instance in that case
2237 /* pComp->Value(mkNamingContextPtrAdapt( pMeshInstance, *pGraphics->Mesh, "Mesh"));
2238  if(!pMeshInstance)
2239  pComp->excCorrupt("Mesh graphics without mesh instance");*/
2240  }
2241 
2242  // TODO: Animations / attached meshes
2243 
2244  // Commands
2245  if (pComp->FollowName("Commands"))
2246  {
2247  if (deserializing)
2248  {
2249  C4Command *pCmd = nullptr;
2250  for (int i = 1; ; i++)
2251  {
2252  // Every command has its own naming environment
2253  StdStrBuf Naming = FormatString("Command%d", i);
2254  pComp->Value(mkParAdapt(mkNamingPtrAdapt(pCmd ? pCmd->Next : Command, Naming.getData()), numbers));
2255  // Last command?
2256  pCmd = (pCmd ? pCmd->Next : Command);
2257  if (!pCmd)
2258  break;
2259  pCmd->cObj = this;
2260  }
2261  }
2262  else
2263  {
2264  C4Command *pCmd = Command;
2265  for (int i = 1; pCmd; i++, pCmd = pCmd->Next)
2266  {
2267  StdStrBuf Naming = FormatString("Command%d", i);
2268  pComp->Value(mkNamingAdapt(mkParAdapt(*pCmd, numbers), Naming.getData()));
2269  }
2270  }
2271  }
2272 
2273  // Compiling? Do initialization.
2274  if (deserializing)
2275  {
2276  // add to def count
2277  Def->Count++;
2278 
2279 
2280  // Set action (override running data)
2281  /* FIXME
2282  int32_t iTime=Action.Time;
2283  int32_t iPhase=Action.Phase;
2284  int32_t iPhaseDelay=Action.PhaseDelay;
2285  if (SetActionByName(Action.pActionDef->GetName(),0,0,false))
2286  {
2287  Action.Time=iTime;
2288  Action.Phase=iPhase; // No checking for valid phase
2289  Action.PhaseDelay=iPhaseDelay;
2290  }*/
2291 
2292  if (pMeshInstance)
2293  {
2294  // Set Action animation by slot 0
2297  }
2298 
2299  // blit mode not assigned? use definition default then
2300  if (!BlitMode) BlitMode = Def->BlitMode;
2301 
2302  // object needs to be resorted? May happen if there's unsorted objects in savegame
2303  if (Unsorted) Game.fResortAnyObject = true;
2304  }
2305 
2306 }
const char * getData() const
Definition: StdBuf.h:442
C4Def * ID2Def(C4ID id)
C4Object * cObj
Definition: C4Command.h:80
C4DrawTransform * pDrawTransform
Definition: C4Object.h:137
C4Game Game
Definition: C4Globals.cpp:52
C4Command * Next
Definition: C4Command.h:90
bool Alive
Definition: C4Object.h:175
void Clear()
Definition: StdBuf.h:466
int32_t Mass
Definition: C4Object.h:115
void SetFaceOrderingForClrModulation(uint32_t clrmod)
Definition: StdMesh.cpp:1133
C4Rect PictureRect
Definition: C4Object.h:151
C4Command * Command
Definition: C4Object.h:166
int32_t OwnMass
Definition: C4Object.h:115
C4Real rdir
Definition: C4Object.h:126
const StdMeshInstance::AttachedMesh::DenumeratorFactoryFunc C4MeshDenumeratorFactory
AnimationNode * GetRootAnimationForSlot(int slot)
Definition: StdMesh.cpp:1251
bool OnFire
Definition: C4Object.h:172
int32_t Breath
Definition: C4Object.h:118
void Clear()
Definition: C4Object.cpp:2432
C4ObjectPtr Target2
Definition: C4Object.h:87
C4ObjectPtr Layer
Definition: C4Object.h:136
StdMeshInstanceAnimationNode * Animation
Definition: C4Object.h:90
C4ObjectInfo * Info
Definition: C4Object.h:145
const char * LoadResStr(const char *id)
Definition: C4Language.h:83
bool Mobile
Definition: C4Object.h:128
const int32_t FullCon
Definition: C4Constants.h:181
StdNamingAdapt< T > mkNamingAdapt(T &&rValue, const char *szName)
Definition: StdAdaptors.h:92
int32_t Energy
Definition: C4Object.h:117
int32_t lightFadeoutRange
Definition: C4Object.h:123
static const C4ObjectPtr Null
Definition: C4ObjectPtr.h:28
bool InLiquid
Definition: C4Object.h:131
C4NotifyingObjectList Contents
Definition: C4Object.h:152
int32_t GrowthType
Definition: C4Def.h:111
C4Shape Shape
Definition: C4Def.h:104
int32_t Plane
Definition: C4Object.h:174
C4Def * Def
Definition: C4Object.h:143
bool CrewDisabled
Definition: C4Object.h:163
int32_t lightRange
Definition: C4Object.h:122
int32_t Count
Definition: C4Def.h:179
static const C4ID None
Definition: C4Id.h:39
int32_t Con
Definition: C4Object.h:173
int32_t Owner
Definition: C4Object.h:110
uint32_t Color
Definition: C4Object.h:120
bool EntranceStatus
Definition: C4Object.h:132
const int NO_OWNER
Definition: C4Constants.h:137
C4DefGraphics * pGraphics
Definition: C4Object.h:154
char Name[C4MaxName+1]
Definition: C4InfoCore.h:37
void excNotFound(const char *szMessage,...)
Definition: StdCompiler.h:233
int32_t Status
Definition: C4PropList.h:168
void Value(const T &rStruct)
Definition: StdCompiler.h:161
C4TargetRect SolidMask
Definition: C4Def.h:108
int32_t Damage
Definition: C4Object.h:116
bool Unsorted
Definition: C4Object.h:129
int32_t Category
Definition: C4Object.h:113
virtual bool isDeserializer()
Definition: StdCompiler.h:53
bool fResortAnyObject
Definition: C4Game.h:138
class C4GraphicsOverlay * pGfxOverlay
Definition: C4Object.h:170
C4ObjectPtr Target
Definition: C4Object.h:87
C4Real fix_r
Definition: C4Object.h:125
C4Real fix_x
Definition: C4Object.h:125
StdCopyStrBuf nInfo
Definition: C4Object.h:168
uint32_t ColorMod
Definition: C4Object.h:161
GraphicsType Type
Definition: C4DefGraphics.h:48
int32_t iLastAttachMovementFrame
Definition: C4Object.h:127
int32_t BlitMode
Definition: C4Def.h:141
StdParameterAdapt< T, P > mkParAdapt(T &&rObj, P &&rPar)
Definition: StdAdaptors.h:458
uint32_t BlitMode
Definition: C4Object.h:162
C4DefList Definitions
Definition: C4Globals.cpp:49
C4Effect * pEffects
Definition: C4Object.h:156
C4Real fix_y
Definition: C4Object.h:125
C4ObjectPtr Contained
Definition: C4Object.h:144
StdPtrAdapt< T > mkNamingPtrAdapt(T *&rpObj, const char *szNaming)
Definition: StdAdaptors.h:604
C4Action Action
Definition: C4Object.h:147
C4Shape Shape
Definition: C4Object.h:148
uint32_t OCF
Definition: C4Object.h:134
#define toC4CStrBuf(rBuf)
Definition: StdAdaptors.h:25
virtual bool FollowName(const char *szName)
Definition: StdCompiler.h:84
C4TargetRect SolidMask
Definition: C4Object.h:150
bool fOwnVertices
Definition: C4Object.h:149
C4Real xdir
Definition: C4Object.h:126
int32_t Controller
Definition: C4Object.h:111
C4DefGraphics Graphics
Definition: C4Def.h:191
StdMeshInstance * pMeshInstance
Definition: C4Object.h:155
C4Real ydir
Definition: C4Object.h:126
int32_t LastEnergyLossCausePlayer
Definition: C4Object.h:112
uint32_t lightColor
Definition: C4Object.h:124
const C4Real Fix0
Definition: C4Real.h:312
StdStrBuf FormatString(const char *szFmt,...)
Definition: StdBuf.cpp:270

Here is the call graph for this function:

bool C4Object::Contact ( int32_t  cnat)

Definition at line 114 of file C4Movement.cpp.

References C4PropList::Call(), CNATName(), FormatString(), C4PropList::GetPropertyInt(), P_ContactCalls, and PSF_Contact.

Referenced by ContactCheck(), and StopAndContact().

115 {
117  {
118  return !! Call(FormatString(PSF_Contact, CNATName(iCNAT)).getData());
119  }
120  return false;
121 }
const char * CNATName(int32_t cnat)
Definition: C4Movement.cpp:100
#define PSF_Contact
Definition: C4GameScript.h:69
int32_t GetPropertyInt(C4PropertyName k, int32_t default_val=0) const
Definition: C4PropList.cpp:886
StdStrBuf FormatString(const char *szFmt,...)
Definition: StdBuf.cpp:270
C4Value Call(C4PropertyName k, C4AulParSet *pPars=nullptr, bool fPassErrors=false)
Definition: C4PropList.h:110

Here is the call graph for this function:

Here is the caller graph for this function:

void C4Object::ContactAction ( )

Definition at line 2917 of file C4Object.cpp.

References Action, C4REAL100(), CNAT_Bottom, CNAT_Left, CNAT_Right, CNAT_Top, COMD_Down, COMD_Left, COMD_Right, COMD_Stop, COMD_Up, C4Action::ComDir, ComDirLike(), Con, Def, DFA_DIG, DFA_FLIGHT, DFA_HANGLE, DFA_SCALE, DFA_SWIM, DFA_WALK, C4Action::Dir, DIR_Left, DIR_Right, fix_x, fix_y, C4Def::Float, ForcePosition(), FullCon, GBackSemiSolid(), GetAction(), C4PropList::GetPropertyInt(), C4PropList::GetPropertyP(), GetX(), GetY(), ObjectActionCornerScale(), ObjectActionFlat(), ObjectActionHangle(), ObjectActionJump(), ObjectActionKneel(), ObjectActionScale(), ObjectActionStand(), ObjectActionTumble(), ObjectActionWalk(), OCF, OCF_HitSpeed3, OCF_HitSpeed4, P_ObjectDisabled, P_Procedure, SetDir(), t_contact, xdir, and ydir.

Referenced by DoMovement().

2918 {
2919  // Take certain action on contact. Evaluate t_contact-CNAT and Procedure.
2920 
2921  // Determine Procedure
2922  C4PropList* pActionDef = GetAction();
2923  if (!pActionDef) return;
2924  int32_t iProcedure=pActionDef->GetPropertyP(P_Procedure);
2925  int32_t fDisabled=pActionDef->GetPropertyInt(P_ObjectDisabled);
2926 
2927  //------------------------------- Hit Bottom ---------------------------------------------
2928  if (t_contact & CNAT_Bottom)
2929  switch (iProcedure)
2930  {
2931  case DFA_FLIGHT:
2932  if (ydir < 0) return;
2933  // Jump: FlatHit / HardHit / Walk
2934  if ((OCF & OCF_HitSpeed4) || fDisabled)
2935  if (ObjectActionFlat(this,Action.Dir)) return;
2936  if (OCF & OCF_HitSpeed3)
2937  if (ObjectActionKneel(this)) return;
2938  ObjectActionWalk(this);
2939  ydir = 0;
2940  return;
2941  case DFA_SCALE:
2942  // Scale down: stand
2944  {
2945  ObjectActionStand(this);
2946  return;
2947  }
2948  break;
2949  case DFA_DIG:
2950  // no special action
2951  break;
2952  case DFA_SWIM:
2953  // Try corner scale out
2954  if (!GBackSemiSolid(GetX(),GetY()-1+Def->Float*Con/FullCon-1))
2955  if (ObjectActionCornerScale(this)) return;
2956  break;
2957  }
2958 
2959  //------------------------------- Hit Ceiling -----------------------------------------
2960  if (t_contact & CNAT_Top)
2961  switch (iProcedure)
2962  {
2963  case DFA_WALK:
2964  // Walk: Stop
2965  ObjectActionStand(this); return;
2966  case DFA_SCALE:
2967  // Scale: Try hangle, else stop if going upward
2969  {
2970  if (ObjectActionHangle(this))
2971  {
2973  return;
2974  }
2976  }
2977  break;
2978  case DFA_FLIGHT:
2979  // Jump: Try hangle, else bounce off
2980  // High Speed Flight: Tumble
2981  if ((OCF & OCF_HitSpeed3) || fDisabled)
2982  { ObjectActionTumble(this, Action.Dir, xdir, ydir); break; }
2983  if (ObjectActionHangle(this)) return;
2984  break;
2985  case DFA_DIG:
2986  // No action
2987  break;
2988  case DFA_HANGLE:
2990  break;
2991  }
2992 
2993  //---------------------------- Hit Left Wall ----------------------------------------
2994  if (t_contact & CNAT_Left)
2995  {
2996  switch (iProcedure)
2997  {
2998  case DFA_FLIGHT:
2999  // High Speed Flight: Tumble
3000  if ((OCF & OCF_HitSpeed3) || fDisabled)
3001  { ObjectActionTumble(this, DIR_Left, xdir, ydir); break; }
3002  // Else
3003  else if (!ComDirLike(Action.ComDir, COMD_Right) && ObjectActionScale(this,DIR_Left)) return;
3004  break;
3005  case DFA_WALK:
3006  // Walk: Try scale
3008  {
3009  if (ObjectActionScale(this,DIR_Left))
3010  {
3011  ydir = C4REAL100(-1);
3012  return;
3013  }
3014  }
3015  // Heading away from solid
3017  {
3018  // Slide off
3019  ObjectActionJump(this,xdir/2,ydir,false);
3020  }
3021  return;
3022  case DFA_SWIM:
3023  // Only scale if swimming at the surface
3024  if (!GBackSemiSolid(GetX(),GetY()-1+Def->Float*Con/FullCon-1))
3025  {
3026  // Try scale, only if swimming at the surface.
3028  if (ObjectActionScale(this,DIR_Left)) return;
3029  // Try corner scale out
3030  if (ObjectActionCornerScale(this)) return;
3031  }
3032  return;
3033  case DFA_HANGLE:
3034  // Hangle: Try scale
3035  if (ObjectActionScale(this,DIR_Left))
3036  {
3037  ydir = C4REAL100(1);
3038  return;
3039  }
3040  return;
3041  case DFA_DIG:
3042  // Dig: no action
3043  break;
3044  }
3045  }
3046 
3047  //------------------------------ Hit Right Wall --------------------------------------
3048  if (t_contact & CNAT_Right)
3049  {
3050  switch (iProcedure)
3051  {
3052  case DFA_FLIGHT:
3053  // High Speed Flight: Tumble
3054  if ((OCF & OCF_HitSpeed3) || fDisabled)
3055  { ObjectActionTumble(this, DIR_Right, xdir, ydir); break; }
3056  // Else Scale
3057  else if (!ComDirLike(Action.ComDir, COMD_Left) && ObjectActionScale(this,DIR_Right)) return;
3058  break;
3059  case DFA_WALK:
3060  // Walk: Try scale
3062  {
3063  if (ObjectActionScale(this,DIR_Right))
3064  {
3065  ydir = C4REAL100(-1);
3066  return;
3067  }
3068  }
3069  // Heading away from solid
3071  {
3072  // Slide off
3073  ObjectActionJump(this,xdir/2,ydir,false);
3074  }
3075  return;
3076  case DFA_SWIM:
3077  // Only scale if swimming at the surface
3078  if (!GBackSemiSolid(GetX(),GetY()-1+Def->Float*Con/FullCon-1))
3079  {
3080  // Try scale
3082  if (ObjectActionScale(this,DIR_Right)) return;
3083  // Try corner scale out
3084  if (ObjectActionCornerScale(this)) return;
3085  }
3086  return;
3087  case DFA_HANGLE:
3088  // Hangle: Try scale
3089  if (ObjectActionScale(this,DIR_Right))
3090  {
3091  ydir = C4REAL100(1);
3092  return;
3093  }
3094  return;
3095  case DFA_DIG:
3096  // Dig: no action
3097  break;
3098  }
3099  }
3100 
3101  //---------------------------- Unresolved Cases ---------------------------------------
3102 
3103  // Flight stuck
3104  if (iProcedure==DFA_FLIGHT)
3105  {
3106  // Enforce slide free (might slide through tiny holes this way)
3107  if (!ydir)
3108  {
3109  int fAllowDown = !(t_contact & CNAT_Bottom);
3110  if (t_contact & CNAT_Right)
3111  {
3112  ForcePosition(fix_x - 1, fix_y + fAllowDown);
3113  xdir=ydir=0;
3114  }
3115  if (t_contact & CNAT_Left)
3116  {
3117  ForcePosition(fix_x + 1, fix_y + fAllowDown);
3118  xdir=ydir=0;
3119  }
3120  }
3121  if (!xdir)
3122  {
3123  if (t_contact & CNAT_Top)
3124  {
3125  ForcePosition(fix_x, fix_y + 1);
3126  xdir=ydir=0;
3127  }
3128  }
3129  }
3130 }
C4PropertyName GetPropertyP(C4PropertyName k) const
Definition: C4PropList.cpp:855
int32_t GetY() const
Definition: C4Object.h:287
void ForcePosition(C4Real tx, C4Real ty)
Definition: C4Movement.cpp:515
#define COMD_Down
Definition: C4Object.h:55
bool ObjectActionKneel(C4Object *cObj)
Definition: C4ObjectCom.cpp:94
int32_t Float
Definition: C4Def.h:120
void SetDir(int32_t tdir)
Definition: C4Object.cpp:2840
C4PropList * GetAction() const
Definition: C4Object.cpp:2674
#define DIR_Right
Definition: C4Object.h:42
C4Real C4REAL100(int x)
Definition: C4Real.h:267
const int32_t FullCon
Definition: C4Constants.h:181
bool ObjectActionWalk(C4Object *cObj)
Definition: C4ObjectCom.cpp:39
C4Def * Def
Definition: C4Object.h:143
#define DIR_Left
Definition: C4Object.h:41
uint32_t t_contact
Definition: C4Object.h:133
int32_t Con
Definition: C4Object.h:173
bool ComDirLike(int32_t iComDir, int32_t iSample)
int32_t GetX() const
Definition: C4Object.h:286
bool ObjectActionCornerScale(C4Object *cObj)
#define COMD_Right
Definition: C4Object.h:53
#define COMD_Stop
Definition: C4Object.h:50
bool ObjectActionStand(C4Object *cObj)
Definition: C4ObjectCom.cpp:45
C4Real fix_x
Definition: C4Object.h:125
const BYTE CNAT_Top
Definition: C4Constants.h:111
#define COMD_Up
Definition: C4Object.h:51
bool GBackSemiSolid(int32_t x, int32_t y)
Definition: C4Landscape.h:236
#define COMD_Left
Definition: C4Object.h:57
bool ObjectActionScale(C4Object *cObj, int32_t dir)
const BYTE CNAT_Right
Definition: C4Constants.h:110
int32_t Dir
Definition: C4Object.h:80
const uint32_t OCF_HitSpeed3
Definition: C4Constants.h:92
int32_t GetPropertyInt(C4PropertyName k, int32_t default_val=0) const
Definition: C4PropList.cpp:886
C4Real fix_y
Definition: C4Object.h:125
bool ObjectActionFlat(C4Object *cObj, int32_t dir)
C4Action Action
Definition: C4Object.h:147
uint32_t OCF
Definition: C4Object.h:134
const uint32_t OCF_HitSpeed4
Definition: C4Constants.h:95
bool ObjectActionHangle(C4Object *cObj)
bool ObjectActionTumble(C4Object *cObj, int32_t dir, C4Real xdir, C4Real ydir)
Definition: C4ObjectCom.cpp:79
C4Real xdir
Definition: C4Object.h:126
const BYTE CNAT_Left
Definition: C4Constants.h:109
const BYTE CNAT_Bottom
Definition: C4Constants.h:112
C4Real ydir
Definition: C4Object.h:126
bool ObjectActionJump(C4Object *cObj, C4Real xdir, C4Real ydir, bool fByCom)
Definition: C4ObjectCom.cpp:52
int32_t ComDir
Definition: C4Object.h:82

Here is the call graph for this function:

Here is the caller graph for this function:

int32_t C4Object::ContactCheck ( int32_t  atx,
int32_t  aty,
uint32_t *  border_hack_contacts = nullptr,
bool  collide_halfvehic = false 
)

Definition at line 136 of file C4Movement.cpp.

References Contact(), C4Shape::ContactCheck(), C4Shape::ContactCNAT, C4Shape::ContactCount, Shape, and t_contact.

Referenced by DoMovement(), Lift(), Push(), and Stabilize().

137 {
138  // Check shape contact at given position
139  Shape.ContactCheck(iAtX,iAtY,border_hack_contacts,collide_halfvehic);
140 
141  // Store shape contact values in object t_contact
143 
144  // Contact script call for the first contacted cnat
145  if (Shape.ContactCNAT)
146  for (int32_t ccnat=0; ccnat<4; ccnat++) // Left, right, top bottom
147  if (Shape.ContactCNAT & (1<<ccnat))
148  if (Contact(1<<ccnat))
149  break; // Will stop on first positive return contact call!
150 
151  // Return shape contact count
152  return Shape.ContactCount;
153 }
int32_t ContactCount
Definition: C4Shape.h:49
uint32_t t_contact
Definition: C4Object.h:133
bool ContactCheck(int32_t cx, int32_t cy, uint32_t *border_hack_contacts=nullptr, bool collide_halfvehic=false)
Definition: C4Shape.cpp:350
int32_t ContactCNAT
Definition: C4Shape.h:48
C4Shape Shape
Definition: C4Object.h:148
bool Contact(int32_t cnat)
Definition: C4Movement.cpp:114

Here is the call graph for this function:

Here is the caller graph for this function:

void C4Object::CopyMotion ( C4Object from)

Definition at line 503 of file C4Movement.cpp.

References fix_x, fix_y, UpdatePos(), xdir, and ydir.

Referenced by Collect(), Enter(), and ExecMovement().

504 {
505  // Designed for contained objects, no static
506  if (fix_x != from->fix_x || fix_y != from->fix_y)
507  {
508  fix_x=from->fix_x; fix_y=from->fix_y;
509  // Resort into sectors
510  UpdatePos();
511  }
512  xdir=from->xdir; ydir=from->ydir;
513 }
void UpdatePos()
Definition: C4Object.cpp:370
C4Real fix_x
Definition: C4Object.h:125
C4Real fix_y
Definition: C4Object.h:125
C4Real xdir
Definition: C4Object.h:126
C4Real ydir
Definition: C4Object.h:126

Here is the call graph for this function:

Here is the caller graph for this function:

C4Object * C4Object::CreateContents ( C4PropList PropList)

Definition at line 1436 of file C4Object.cpp.

References AssignRemoval(), C4Game::CreateObject(), Enter(), Game, and Owner.

Referenced by CreateContentsByList().

1437 {
1438  C4Object *nobj;
1439  if (!(nobj=Game.CreateObject(PropList,this,Owner))) return nullptr;
1440  if (!nobj->Enter(this)) { nobj->AssignRemoval(); return nullptr; }
1441  return nobj;
1442 }
bool Enter(C4Object *pTarget, bool fCalls=true, bool fCopyMotion=true, bool *pfRejectCollect=nullptr)
Definition: C4Object.cpp:1260
C4Game Game
Definition: C4Globals.cpp:52
int32_t Owner
Definition: C4Object.h:110
void AssignRemoval(bool fExitContents=false)
Definition: C4Object.cpp:254
C4Object * CreateObject(C4PropList *type, C4Object *pCreator, int32_t owner=NO_OWNER, int32_t x=50, int32_t y=50, int32_t r=0, bool grow_from_center=false, C4Real xdir=Fix0, C4Real ydir=Fix0, C4Real rdir=Fix0, int32_t iController=NO_OWNER)
Definition: C4Game.cpp:1072

Here is the call graph for this function:

Here is the caller graph for this function:

bool C4Object::CreateContentsByList ( C4IDList idlist)

Definition at line 1444 of file C4Object.cpp.

References C4Id2Def(), CreateContents(), C4IDList::GetCount(), and C4IDList::GetID().

Referenced by C4Player::PlaceReadyMaterial().

1445 {
1446  int32_t cnt,cnt2;
1447  for (cnt=0; idlist.GetID(cnt); cnt++)
1448  for (cnt2=0; cnt2<idlist.GetCount(cnt); cnt2++)
1449  if (!CreateContents(C4Id2Def(idlist.GetID(cnt))))
1450  return false;
1451  return true;
1452 }
int32_t GetCount(size_t index) const
Definition: C4IDList.cpp:111
C4Object * CreateContents(C4PropList *)
Definition: C4Object.cpp:1436
C4Def * C4Id2Def(C4ID id)
Definition: C4DefList.h:84
C4ID GetID(size_t index, int32_t *ipCount=nullptr) const
Definition: C4IDList.cpp:99

Here is the call graph for this function:

Here is the caller graph for this function:

void C4Object::Default ( )

Definition at line 91 of file C4Object.cpp.

References Action, Alive, Audible, AudiblePan, AudiblePlayer, BlitMode, Breath, Category, StdStrBuf::Clear(), ClearParticleLists(), Color, ColorMod, Command, Con, Contained, Contents, Controller, CrewDisabled, Damage, Def, C4Rect::Default(), C4Shape::Default(), C4TargetRect::Default(), C4Action::Default(), C4ObjectList::Default(), C4Facet::Default(), Energy, EntranceStatus, fix_r, fix_x, fix_y, fOwnVertices, iLastAttachMovementFrame, Info, Initializing, InLiquid, InMat, LastEnergyLossCausePlayer, Layer, lightColor, lightFadeoutRange, lightRange, Marker, Mass, MaterialContents, Menu, MNone, Mobile, nInfo, NO_OWNER, C4ID::None, OCF, OnFire, Owner, OwnMass, pDrawTransform, pEffects, pGfxOverlay, pGraphics, PictureRect, pMeshInstance, pSolidMaskData, rdir, RemovalDelay, Shape, SolidMask, t_contact, TopFace, Unsorted, xdir, and ydir.

Referenced by C4Object().

92 {
93  id=C4ID::None;
94  nInfo.Clear();
95  RemovalDelay=0;
99  Category=0;
100  Con=0;
101  Mass=OwnMass=0;
102  Damage=0;
103  Energy=0;
104  Alive=false;
105  Breath=0;
106  InMat=MNone;
107  Color=0;
108  lightRange=0;
110  lightColor=0xffffffff;
111  fix_x=fix_y=fix_r=0;
112  xdir=ydir=rdir=0;
113  Mobile=false;
114  Unsorted=false;
115  Initializing=false;
116  OnFire=false;
117  InLiquid=false;
118  EntranceStatus=false;
121  t_contact=0;
122  OCF=0;
123  Action.Default();
124  Shape.Default();
125  fOwnVertices=false;
126  Contents.Default();
127  SolidMask.Default();
129  Def=nullptr;
130  Info=nullptr;
131  Command=nullptr;
132  Contained=nullptr;
133  TopFace.Default();
134  Menu=nullptr;
135  MaterialContents=nullptr;
136  Marker=0;
137  ColorMod=0xffffffff;
138  BlitMode=0;
139  CrewDisabled=false;
140  Layer=nullptr;
141  pSolidMaskData=nullptr;
142  pGraphics=nullptr;
143  pMeshInstance=nullptr;
144  pDrawTransform=nullptr;
145  pEffects=nullptr;
146  pGfxOverlay=nullptr;
148 
150 }
C4DrawTransform * pDrawTransform
Definition: C4Object.h:137
bool Alive
Definition: C4Object.h:175
void Clear()
Definition: StdBuf.h:466
int32_t Mass
Definition: C4Object.h:115
C4Rect PictureRect
Definition: C4Object.h:151
C4MaterialList * MaterialContents
Definition: C4Object.h:153
uint32_t Marker
Definition: C4Object.h:135
C4Command * Command
Definition: C4Object.h:166
int32_t OwnMass
Definition: C4Object.h:115
C4Real rdir
Definition: C4Object.h:126
bool OnFire
Definition: C4Object.h:172
void Default()
Definition: C4Shape.cpp:36
int32_t Breath
Definition: C4Object.h:118
int32_t InMat
Definition: C4Object.h:119
int32_t RemovalDelay
Definition: C4Object.h:109
C4ObjectPtr Layer
Definition: C4Object.h:136
void ClearParticleLists()
Definition: C4Object.cpp:245
C4ObjectInfo * Info
Definition: C4Object.h:145
bool Mobile
Definition: C4Object.h:128
int32_t Energy
Definition: C4Object.h:117
int32_t lightFadeoutRange
Definition: C4Object.h:123
int32_t AudiblePlayer
Definition: C4Object.h:121
bool InLiquid
Definition: C4Object.h:131
class C4ObjectMenu * Menu
Definition: C4Object.h:140
const int32_t MNone
Definition: C4Constants.h:177
C4NotifyingObjectList Contents
Definition: C4Object.h:152
C4Def * Def
Definition: C4Object.h:143
bool CrewDisabled
Definition: C4Object.h:163
uint32_t t_contact
Definition: C4Object.h:133
int32_t AudiblePan
Definition: C4Object.h:121
void Default()
Definition: C4Facet.cpp:31
int32_t lightRange
Definition: C4Object.h:122
void Default()
Definition: C4Action.cpp:30
static const C4ID None
Definition: C4Id.h:39
int32_t Con
Definition: C4Object.h:173
int32_t Owner
Definition: C4Object.h:110
uint32_t Color
Definition: C4Object.h:120
bool EntranceStatus
Definition: C4Object.h:132
const int NO_OWNER
Definition: C4Constants.h:137
C4DefGraphics * pGraphics
Definition: C4Object.h:154
void Default()
Definition: C4Rect.cpp:26
int32_t Damage
Definition: C4Object.h:116
bool Unsorted
Definition: C4Object.h:129
int32_t Category
Definition: C4Object.h:113
class C4GraphicsOverlay * pGfxOverlay
Definition: C4Object.h:170
C4Real fix_r
Definition: C4Object.h:125
C4Real fix_x
Definition: C4Object.h:125
StdCopyStrBuf nInfo
Definition: C4Object.h:168
uint32_t ColorMod
Definition: C4Object.h:161
int32_t iLastAttachMovementFrame
Definition: C4Object.h:127
virtual void Default()
uint32_t BlitMode
Definition: C4Object.h:162
C4Effect * pEffects
Definition: C4Object.h:156
C4Real fix_y
Definition: C4Object.h:125
C4ObjectPtr Contained
Definition: C4Object.h:144
C4Action Action
Definition: C4Object.h:147
C4Shape Shape
Definition: C4Object.h:148
int32_t Audible
Definition: C4Object.h:121
uint32_t OCF
Definition: C4Object.h:134
void Default()
Definition: C4Rect.cpp:39
C4TargetRect SolidMask
Definition: C4Object.h:150
C4SolidMask * pSolidMaskData
Definition: C4Object.h:176
bool fOwnVertices
Definition: C4Object.h:149
C4Real xdir
Definition: C4Object.h:126
int32_t Controller
Definition: C4Object.h:111
StdMeshInstance * pMeshInstance
Definition: C4Object.h:155
C4Real ydir
Definition: C4Object.h:126
int32_t LastEnergyLossCausePlayer
Definition: C4Object.h:112
uint32_t lightColor
Definition: C4Object.h:124
C4Facet TopFace
Definition: C4Object.h:142
bool Initializing
Definition: C4Object.h:130

Here is the call graph for this function:

Here is the caller graph for this function:

virtual bool C4PropList::Delete ( )
inlinevirtualinherited

Reimplemented in C4PropListStaticMember, C4PropListStatic, C4PropListScript, and C4Def.

Definition at line 90 of file C4PropList.h.

Referenced by C4ScriptHost::DeleteOwnedPropLists().

90 { return false; }

Here is the caller graph for this function:

void C4Object::Denumerate ( C4ValueNumbers numbers)
overridevirtual

Reimplemented from C4PropList.

Definition at line 2308 of file C4Object.cpp.

References Action, Command, Contained, Contents, C4Effect::Denumerate(), C4PropList::Denumerate(), C4ObjectPtr::DenumeratePointers(), C4ObjectList::DenumeratePointers(), StdMeshInstance::DenumeratePointers(), C4GraphicsOverlay::GetNext(), Layer, C4Command::Next, pEffects, pGfxOverlay, pMeshInstance, C4Action::Target, and C4Action::Target2.

Referenced by C4ObjectList::Denumerate().

2309 {
2310  C4PropList::Denumerate(numbers);
2311  // Standard enumerated pointers
2316 
2317  // Post-compile object list
2319 
2320  // Commands
2321  for (C4Command *pCom=Command; pCom; pCom=pCom->Next)
2322  pCom->Denumerate(numbers);
2323 
2324  // effects
2325  if (pEffects) pEffects->Denumerate(numbers);
2326 
2327  // gfx overlays
2328  if (pGfxOverlay)
2329  for (C4GraphicsOverlay *pGfxOvrl = pGfxOverlay; pGfxOvrl; pGfxOvrl = pGfxOvrl->GetNext())
2330  pGfxOvrl->DenumeratePointers();
2331 
2332  // mesh instance
2334 }
bool DenumeratePointers()
C4Command * Next
Definition: C4Command.h:90
C4Command * Command
Definition: C4Object.h:166
void Denumerate(C4ValueNumbers *) override
Definition: C4Effect.cpp:176
C4ObjectPtr Target2
Definition: C4Object.h:87
C4ObjectPtr Layer
Definition: C4Object.h:136
void DenumeratePointers()
Definition: C4ObjectPtr.cpp:47
virtual void Denumerate(C4ValueNumbers *)
Definition: C4PropList.cpp:350
C4NotifyingObjectList Contents
Definition: C4Object.h:152
void DenumeratePointers()
Definition: StdMesh.cpp:1669
class C4GraphicsOverlay * pGfxOverlay
Definition: C4Object.h:170
C4ObjectPtr Target
Definition: C4Object.h:87
C4Effect * pEffects
Definition: C4Object.h:156
C4ObjectPtr Contained
Definition: C4Object.h:144
C4Action Action
Definition: C4Object.h:147
StdMeshInstance * pMeshInstance
Definition: C4Object.h:155
C4GraphicsOverlay * GetNext() const

Here is the call graph for this function:

Here is the caller graph for this function:

void C4Object::DirectComContents ( C4Object pTarget,
bool  fDoCalls 
)

Definition at line 4243 of file C4Object.cpp.

References C4PropList::Call(), Contained, Contents, C4ObjectList::GetObject(), C4Menu::IsActive(), C4Menu::IsContextMenu(), Menu, C4Menu::Refill(), C4ObjectList::ShiftContents(), StartSoundEffect(), and C4PropList::Status.

Referenced by ShiftContents().

4244 {
4245  // safety
4246  if (!pTarget || !pTarget->Status || pTarget->Contained != this) return;
4247  // Desired object already at front?
4248  if (Contents.GetObject() == pTarget) return;
4249  // select object via script?
4250  if (fDoCalls)
4251  if (Call("~ControlContents", &C4AulParSet(pTarget)))
4252  return;
4253  // default action
4254  if (!(Contents.ShiftContents(pTarget))) return;
4255  // Selection sound
4256  if (fDoCalls) if (!Contents.GetObject()->Call("~Selection", &C4AulParSet(this))) StartSoundEffect("Clonk::Action::Grab",false,100,this);
4257  // update menu with the new item in "put" entry
4258  if (Menu && Menu->IsActive() && Menu->IsContextMenu())
4259  {
4260  Menu->Refill();
4261  }
4262  // Done
4263  return;
4264 }
bool IsContextMenu()
Definition: C4Menu.h:164
bool Refill()
Definition: C4Menu.cpp:915
bool ShiftContents(C4Object *pNewFirst)
C4SoundInstance * StartSoundEffect(const char *szSndName, bool fLoop, int32_t iVolume, C4Object *pObj, int32_t iCustomFalloffDistance, int32_t iPitch, C4SoundModifier *modifier)
class C4ObjectMenu * Menu
Definition: C4Object.h:140
C4NotifyingObjectList Contents
Definition: C4Object.h:152
C4Object * GetObject(int Index=0) const
int32_t Status
Definition: C4PropList.h:168
bool IsActive()
Definition: C4Menu.cpp:480
C4ObjectPtr Contained
Definition: C4Object.h:144
C4Value Call(C4PropertyName k, C4AulParSet *pPars=nullptr, bool fPassErrors=false)
Definition: C4PropList.h:110

Here is the call graph for this function:

Here is the caller graph for this function:

void C4Object::DoBreath ( int32_t  iChange)

Definition at line 1143 of file C4Object.cpp.

References Breath, C4PropList::Call(), C4PropList::GetPropertyInt(), P_MaxBreath, and PSF_BreathChange.

Referenced by ExecLife().

1144 {
1145  // Do change
1146  iChange = Clamp<int32_t>(iChange, -Breath, GetPropertyInt(P_MaxBreath) - Breath);
1147  Breath += iChange;
1148  // call to object
1149  Call(PSF_BreathChange,&C4AulParSet(iChange));
1150 }
int32_t Breath
Definition: C4Object.h:118
int32_t GetPropertyInt(C4PropertyName k, int32_t default_val=0) const
Definition: C4PropList.cpp:886
#define PSF_BreathChange
Definition: C4GameScript.h:143
C4Value Call(C4PropertyName k, C4AulParSet *pPars=nullptr, bool fPassErrors=false)
Definition: C4PropList.h:110

Here is the call graph for this function:

Here is the caller graph for this function:

void C4Object::DoCon ( int32_t  iChange,
bool  grow_from_center 
)

Definition at line 1152 of file C4Object.cpp.

References AssignRemoval(), C4PropList::Call(), Con, Contained, Contents, Def, Enter(), Exit(), fix_y, FullCon, C4Shape::GetBottom(), C4ObjectList::GetObject(), GetX(), GetY(), C4Def::GrowthType, C4Def::IncompleteActivity, C4Def::Oversize, pMeshInstance, PSF_Initialize, PSF_OnCompletionChange, SetAction(), StdMeshInstance::SetCompletion(), SetOCF(), Shape, UpdateFace(), UpdateMass(), and UpdateShape().

Referenced by C4Game::NewObject().

1153 {
1154  C4Real strgt_con_b = fix_y + Shape.GetBottom();
1155  bool fWasFull = (Con>=FullCon);
1156  int32_t old_con = Con;
1157 
1158  // Change con
1159  if (Def->Oversize)
1160  Con=std::max<int32_t>(Con+iChange,0);
1161  else
1162  Con=Clamp<int32_t>(Con+iChange,0,FullCon);
1163 
1164  // Update OCF
1165  SetOCF();
1166 
1167  // Mass
1168  UpdateMass();
1169 
1170  // shape and position
1171  UpdateShape();
1172  // make the bottom-most vertex stay in place
1173  if (!grow_from_center)
1174  {
1175  fix_y = strgt_con_b - Shape.GetBottom();
1176  }
1177  // Face (except for the shape)
1178  UpdateFace(false);
1179 
1180  // Do a callback on completion change.
1181  if (iChange != 0)
1182  Call(PSF_OnCompletionChange, &C4AulParSet(old_con, Con));
1183 
1184  // Unfullcon
1185  if (fWasFull && (Con<FullCon))
1186  {
1187  // Lose contents
1188  if (!Def->IncompleteActivity)
1189  {
1190  C4Object *cobj;
1191  while ((cobj=Contents.GetObject()))
1192  if (Contained) cobj->Enter(Contained);
1193  else cobj->Exit(cobj->GetX(),cobj->GetY());
1194  SetAction(nullptr);
1195  }
1196  }
1197 
1198  // Completion
1199  if (!fWasFull && (Con>=FullCon))
1201 
1202  // Con Zero Removal
1203  if (Con<=0)
1204  AssignRemoval();
1205  // Mesh Graphics Update
1206  else if(pMeshInstance)
1207  pMeshInstance->SetCompletion(Def->GrowthType ? 1.0f : static_cast<float>(Con)/static_cast<float>(FullCon));
1208 }
int32_t GetY() const
Definition: C4Object.h:287
bool Enter(C4Object *pTarget, bool fCalls=true, bool fCopyMotion=true, bool *pfRejectCollect=nullptr)
Definition: C4Object.cpp:1260
int GetBottom()
Definition: C4Shape.cpp:468
Definition: C4Real.h:58
const int32_t FullCon
Definition: C4Constants.h:181
#define PSF_Initialize
Definition: C4GameScript.h:34
C4NotifyingObjectList Contents
Definition: C4Object.h:152
int32_t GrowthType
Definition: C4Def.h:111
C4Def * Def
Definition: C4Object.h:143
void UpdateShape(bool bUpdateVertices=true)
Definition: C4Object.cpp:343
int32_t Con
Definition: C4Object.h:173
bool SetAction(C4PropList *Act, C4Object *pTarget=nullptr, C4Object *pTarget2=nullptr, int32_t iCalls=SAC_StartCall|SAC_AbortCall, bool fForce=false)
Definition: C4Object.cpp:2681
bool Exit(int32_t iX=0, int32_t iY=0, int32_t iR=0, C4Real iXDir=Fix0, C4Real iYDir=Fix0, C4Real iRDir=Fix0, bool fCalls=true)
Definition: C4Object.cpp:1224
#define PSF_OnCompletionChange
Definition: C4GameScript.h:103
int32_t GetX() const
Definition: C4Object.h:286
void AssignRemoval(bool fExitContents=false)
Definition: C4Object.cpp:254
C4Object * GetObject(int Index=0) const
void UpdateMass()
Definition: C4Object.cpp:639
int32_t Oversize
Definition: C4Def.h:129
void UpdateFace(bool bUpdateShape, bool fTemp=false)
Definition: C4Object.cpp:378
void SetCompletion(float completion)
Definition: StdMesh.cpp:1150
int32_t IncompleteActivity
Definition: C4Def.h:128
C4Real fix_y
Definition: C4Object.h:125
void SetOCF()
Definition: C4Object.cpp:667
C4ObjectPtr Contained
Definition: C4Object.h:144
C4Shape Shape
Definition: C4Object.h:148
StdMeshInstance * pMeshInstance
Definition: C4Object.h:155
C4Value Call(C4PropertyName k, C4AulParSet *pPars=nullptr, bool fPassErrors=false)
Definition: C4PropList.h:110

Here is the call graph for this function:

Here is the caller graph for this function:

void C4Object::DoDamage ( int32_t  iLevel,
int32_t  iCausedByPlr,
int32_t  iCause 
)

Definition at line 1092 of file C4Object.cpp.

References Alive, C4PropList::Call(), Damage, C4Effect::DoDamage(), pEffects, and PSF_Damage.

1093 {
1094  // non-living: ask effects first
1095  if (pEffects && !Alive)
1096  {
1097  pEffects->DoDamage(iChange, iCause, iCausedBy);
1098  if (!iChange) return;
1099  }
1100  // Change value
1101  Damage = std::max<int32_t>( Damage+iChange, 0 );
1102  // Engine script call
1103  Call(PSF_Damage,&C4AulParSet(iChange, iCause, iCausedBy));
1104 }
bool Alive
Definition: C4Object.h:175
#define PSF_Damage
Definition: C4GameScript.h:63
int32_t Damage
Definition: C4Object.h:116
C4Effect * pEffects
Definition: C4Object.h:156
void DoDamage(int32_t &riDamage, int32_t iDamageType, int32_t iCausePlr)
Definition: C4Effect.cpp:394
C4Value Call(C4PropertyName k, C4AulParSet *pPars=nullptr, bool fPassErrors=false)
Definition: C4PropList.h:110

Here is the call graph for this function:

void C4Object::DoEnergy ( int32_t  iChange,
bool  fExact,
int32_t  iCause,
int32_t  iCausedByPlr 
)

Definition at line 1106 of file C4Object.cpp.

References Alive, AssignDeath(), C4MaxPhysical, C4PropList::Call(), C4Effect::DoDamage(), Energy, C4PropList::GetPropertyInt(), P_MaxEnergy, pEffects, PSF_EnergyChange, and UpdatLastEnergyLossCause().

Referenced by C4GameObjects::CrossCheck(), ExecLife(), and ObjectComPunch().

1107 {
1108  if (!fExact)
1109  {
1110  // Clamp range of change to prevent integer overflow errors
1111  // Do not clamp directly to (0...MaxEnergy)-current_energy, because
1112  // the change value calculated here may be reduced by effect callbacks
1113  int32_t scale = C4MaxPhysical / 100; // iChange 100% = Physical 100000
1114  iChange = Clamp<int32_t>(iChange, std::numeric_limits<int32_t>::min()/scale, std::numeric_limits<int32_t>::max()/scale)*scale;
1115  }
1116  // Was zero?
1117  bool fWasZero=(Energy==0);
1118  // Mark last damage causing player to trace kills
1119  if (iChange < 0) UpdatLastEnergyLossCause(iCausedByPlr);
1120  // Living things: ask effects for change first
1121  if (pEffects && Alive)
1122  pEffects->DoDamage(iChange, iCause, iCausedByPlr);
1123  // Do change
1124  iChange = Clamp<int32_t>(iChange, -Energy, GetPropertyInt(P_MaxEnergy) - Energy);
1125  Energy += iChange;
1126  // call to object
1127  Call(PSF_EnergyChange,&C4AulParSet(iChange, iCause, iCausedByPlr));
1128  // Alive and energy reduced to zero: death
1129  if (Alive) if (Energy==0) if (!fWasZero) AssignDeath(false);
1130 }
const int32_t C4MaxPhysical
Definition: C4InfoCore.h:28
bool Alive
Definition: C4Object.h:175
#define PSF_EnergyChange
Definition: C4GameScript.h:142
void AssignDeath(bool fForced)
Definition: C4Object.cpp:989
void UpdatLastEnergyLossCause(int32_t iNewCausePlr)
Definition: C4Object.cpp:1132
int32_t Energy
Definition: C4Object.h:117
int32_t GetPropertyInt(C4PropertyName k, int32_t default_val=0) const
Definition: C4PropList.cpp:886
C4Effect * pEffects
Definition: C4Object.h:156
void DoDamage(int32_t &riDamage, int32_t iDamageType, int32_t iCausePlr)
Definition: C4Effect.cpp:394
C4Value Call(C4PropertyName k, C4AulParSet *pPars=nullptr, bool fPassErrors=false)
Definition: C4PropList.h:110

Here is the call graph for this function:

Here is the caller graph for this function:

void C4Object::DoExperience ( int32_t  change)

Definition at line 1210 of file C4Object.cpp.

References DefaultRanks, C4ObjectInfoCore::Experience, C4RankSystem::Experience(), Info, Promote(), and C4ObjectInfoCore::Rank.

Referenced by C4Player::CountControl(), and C4Command::Finish().

1211 {
1212  const int32_t MaxExperience = 100000000;
1213 
1214  if (!Info) return;
1215 
1216  Info->Experience=Clamp<int32_t>(Info->Experience+change,0,MaxExperience);
1217 
1218  // Promotion check
1219  if (Info->Experience<MaxExperience)
1221  Promote(Info->Rank+1, false, false);
1222 }
C4RankSystem DefaultRanks
bool Promote(int32_t torank, bool exception, bool fForceRankName)
Definition: C4Object.cpp:1712
C4ObjectInfo * Info
Definition: C4Object.h:145
int32_t Experience
Definition: C4InfoCore.h:43
int Experience(int iRank)

Here is the call graph for this function:

Here is the caller graph for this function:

void C4Object::DoMotion ( int32_t  mx,
int32_t  my 
)

Definition at line 123 of file C4Movement.cpp.

References fix_x, fix_y, pSolidMaskData, and C4SolidMask::Remove().

Referenced by DoMovement().

124 {
126  fix_x += mx; fix_y += my;
127 }
void Remove(bool fBackupAttachment)
C4Real fix_x
Definition: C4Object.h:125
C4Real fix_y
Definition: C4Object.h:125
C4SolidMask * pSolidMaskData
Definition: C4Object.h:176

Here is the call graph for this function:

Here is the caller graph for this function:

void C4Object::DoMovement ( )

Definition at line 202 of file C4Movement.cpp.

References Action, Alive, ApplyFriction(), C4Shape::Attach(), C4PropList::Call(), CNAT_Left, CNAT_Right, Con, ContactAction(), ContactCheck(), ContactVtxCNAT(), ContactVtxFriction(), ContactVtxWeight(), Def, C4Landscape::DigFree(), C4Landscape::DigFreeRect(), DoMotion(), Fix0, fix_r, fix_x, fix_y, FixFullCircle, FixHalfCircle, fixtoi(), FullCon, GetAction(), C4PropList::GetPropertyInt(), C4Shape::GetX(), GetX(), C4Shape::GetY(), GetY(), C4Rect::Hgt, InLiquid, IsInLiquidCheck(), itofix(), Landscape, Mass, NoAttachAction(), C4Def::NoHorizontalMove, OCF, OCF_HitSpeed1, OCF_HitSpeed2, OCF_HitSpeed3, OCF_Rotate, P_DigFree, PSF_Hit, PSF_Hit2, PSF_Hit3, pSolidMaskData, rdir, RedirectForce(), C4SolidMask::Remove(), C4Def::Rotateable, Shape, SideBounds(), Sign(), C4Action::t_attach, t_contact, UpdateFace(), UpdatePos(), UpdateShape(), UpdateSolidMask(), VerticalBounds(), C4Rect::Wdt, xdir, and ydir.

Referenced by ExecMovement().

203 {
204  int32_t iContact=0;
205  bool fAnyContact=false; int iContacts = 0;
206  BYTE fTurned=0,fRedirectYR=0,fNoAttach=0;
207  // Restrictions
208  if (Def->NoHorizontalMove) xdir=0;
209  // Dig free target area
210  C4PropList* pActionDef = GetAction();
211  if (pActionDef)
212  if (pActionDef->GetPropertyInt(P_DigFree))
213  {
214  int ctcox, ctcoy;
215  // Shape size square
216  if (pActionDef->GetPropertyInt(P_DigFree)==1)
217  {
218  ctcox=fixtoi(fix_x+xdir); ctcoy=fixtoi(fix_y+ydir);
219  ::Landscape.DigFreeRect(ctcox+Shape.GetX(),ctcoy+Shape.GetY(),Shape.Wdt,Shape.Hgt,this);
220  }
221  // Free size round (variable size)
222  else
223  {
224  ctcox=fixtoi(fix_x+xdir); ctcoy=fixtoi(fix_y+ydir);
225  int32_t rad = pActionDef->GetPropertyInt(P_DigFree);
226  if (Con<FullCon) rad = rad*6*Con/5/FullCon;
227  ::Landscape.DigFree(ctcox,ctcoy-1,rad,this);
228  }
229  }
230 
231  // store previous movement and ocf
232  C4Real oldxdir(xdir), oldydir(ydir);
233  uint32_t old_ocf = OCF;
234 
235  bool fMoved = false;
236  C4Real new_x = fix_x + xdir;
237  C4Real new_y = fix_y + ydir;
238  SideBounds(new_x);
239 
240  if (!Action.t_attach) // Unattached movement = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
241  {
242  // Horizontal movement - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
243  // Move to target
244  while (fixtoi(new_x) != fixtoi(fix_x))
245  {
246  // Next step
247  int step = Sign(new_x - fix_x);
248  uint32_t border_hack_contacts = 0;
249  iContact=ContactCheck(GetX() + step, GetY(), &border_hack_contacts);
250  if (iContact || border_hack_contacts)
251  {
252  fAnyContact=true; iContacts |= t_contact | border_hack_contacts;
253  }
254  if (iContact)
255  {
256  // Abort horizontal movement
257  new_x = fix_x;
258  // Vertical redirection (always)
259  RedirectForce(xdir,ydir,-1);
260  ApplyFriction(ydir,ContactVtxFriction(this));
261  }
262  else // Free horizontal movement
263  {
264  DoMotion(step, 0);
265  fMoved = true;
266  }
267  }
268  // Vertical movement - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
269  // Movement target
270  new_y = fix_y + ydir;
271  // Movement bounds (vertical)
272  VerticalBounds(new_y);
273  // Move to target
274  while (fixtoi(new_y) != fixtoi(fix_y))
275  {
276  // Next step
277  int step = Sign(new_y - fix_y);
278  if ((iContact=ContactCheck(GetX(), GetY() + step, nullptr, ydir > 0)))
279  {
280  fAnyContact=true; iContacts |= t_contact;
281  new_y = fix_y;
282  // Vertical contact horizontal friction
283  ApplyFriction(xdir,ContactVtxFriction(this));
284  // Redirection slide or rotate
285  if (!ContactVtxCNAT(this,CNAT_Left))
286  RedirectForce(ydir,xdir,-1);
287  else if (!ContactVtxCNAT(this,CNAT_Right))
288  RedirectForce(ydir,xdir,+1);
289  else
290  {
291  // living things are always capable of keeping their rotation
292  if (OCF & OCF_Rotate) if (iContact==1) if (!Alive)
293  {
294  RedirectForce(ydir,rdir,-ContactVtxWeight(this));
295  fRedirectYR=1;
296  }
297  ydir=0;
298  }
299  }
300  else // Free vertical movement
301  {
302  DoMotion(0,step);
303  fMoved = true;
304  }
305  }
306  }
307  if (Action.t_attach) // Attached movement = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
308  {
309  VerticalBounds(new_y);
310  // Move to target
311  do
312  {
313  // Set next step target
314  int step_x = 0, step_y = 0;
315  if (fixtoi(new_x) != GetX())
316  step_x = Sign(fixtoi(new_x) - GetX());
317  else if (fixtoi(new_y) != GetY())
318  step_y = Sign(fixtoi(new_y) - GetY());
319  int32_t ctx = GetX() + step_x;
320  int32_t cty = GetY() + step_y;
321  // Attachment check
322  if (!Shape.Attach(ctx,cty,Action.t_attach))
323  fNoAttach=1;
324  else
325  {
326  // Attachment change to ctx/cty overrides target
327  if (ctx != GetX() + step_x)
328  {
329  xdir = Fix0; new_x = itofix(ctx);
330  }
331  if (cty != GetY() + step_y)
332  {
333  ydir = Fix0; new_y = itofix(cty);
334  }
335  }
336  // Contact check & evaluation
337  uint32_t border_hack_contacts = 0;
338  iContact=ContactCheck(ctx,cty,&border_hack_contacts);
339  if (iContact || border_hack_contacts)
340  {
341  fAnyContact=true; iContacts |= border_hack_contacts | t_contact;
342  }
343  if (iContact)
344  {
345  // Abort movement
346  if (ctx != GetX())
347  {
348  ctx = GetX(); new_x = fix_x;
349  }
350  if (cty != GetY())
351  {
352  cty = GetY(); new_y = fix_y;
353  }
354  }
355  DoMotion(ctx - GetX(), cty - GetY());
356  fMoved = true;
357  }
358  while (fixtoi(new_x) != GetX() || fixtoi(new_y) != GetY());
359  }
360 
361  if(fix_x != new_x || fix_y != new_y)
362  {
363  fMoved = true;
365  fix_x = new_x;
366  fix_y = new_y;
367  }
368  // Rotation - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
369  if (OCF & OCF_Rotate && !!rdir)
370  {
371  C4Real target_r = fix_r + rdir * 5;
372  // Rotation limit
373  if (Def->Rotateable>1)
374  {
375  if (target_r > itofix(Def->Rotateable))
376  { target_r = itofix(Def->Rotateable); rdir=0; }
377  if (target_r < itofix(-Def->Rotateable))
378  { target_r = itofix(-Def->Rotateable); rdir=0; }
379  }
380  int32_t ctx=GetX(); int32_t cty=GetY();
381  // Move to target
382  while (fixtoi(fix_r) != fixtoi(target_r))
383  {
384  // Save step undos
385  C4Real lcobjr = fix_r; C4Shape lshape=Shape;
386  // Try next step
387  fix_r += Sign(target_r - fix_r);
388  UpdateShape();
389  // attached rotation: rotate around attachment pos
390  if (Action.t_attach && !fNoAttach)
391  {
392  // more accurately, attachment should be evaluated by a rotation around the attachment vertex
393  // however, as long as this code is only used for some surfaces adjustment for large vehicles,
394  // it's enough to assume rotation around the center
395  ctx=GetX(); cty=GetY();
396  // evaluate attachment, but do not bother about attachment loss
397  // that will then be done in next execution cycle
398  Shape.Attach(ctx,cty,Action.t_attach);
399  }
400  // check for contact
401  if ((iContact=ContactCheck(ctx,cty))) // Contact
402  {
403  fAnyContact=true; iContacts |= t_contact;
404  // Undo step and abort movement
405  Shape=lshape;
406  target_r = fix_r = lcobjr;
407  // last UpdateShape-call might have changed sector lists!
408  UpdatePos();
409  // Redirect to GetY()
410  if (iContact==1) if (!fRedirectYR)
411  RedirectForce(rdir,ydir,-1);
412  // Stop rotation
413  rdir=0;
414  }
415  else
416  {
417  fTurned=1;
418  if (ctx != GetX() || cty != GetY())
419  {
420  fix_x = itofix(ctx); fix_y = itofix(cty);
421  }
422  }
423  }
424  // Circle bounds
425  if (target_r < -FixHalfCircle) { target_r += FixFullCircle; }
426  if (target_r > +FixHalfCircle) { target_r -= FixFullCircle; }
427  fix_r = target_r;
428  }
429  // Reput solid mask if moved by motion
430  if (fMoved || fTurned) UpdateSolidMask(true);
431  // Misc checks ===========================================================================================
432  // InLiquid check
433  // this equals C4Object::UpdateLiquid, but the "fNoAttach=false;"-line
434  if (IsInLiquidCheck()) // In Liquid
435  {
436  if (!InLiquid) // Enter liquid
437  {
438  if (OCF & OCF_HitSpeed2)
439  if (Mass>3) Splash();
440  fNoAttach=false;
441  InLiquid=true;
442  }
443  }
444  else // Out of liquid
445  {
446  if (InLiquid) // Leave liquid
447  InLiquid=false;
448  }
449  // Contact Action
450  if (fAnyContact)
451  {
452  t_contact = iContacts;
453  ContactAction();
454  }
455  // Attachment Loss Action
456  if (fNoAttach)
457  NoAttachAction();
458  // Movement Script Execution
459  if (fAnyContact)
460  {
461  C4AulParSet pars(fixtoi(oldxdir, 100), fixtoi(oldydir, 100));
462  if (old_ocf & OCF_HitSpeed1) Call(PSF_Hit, &pars);
463  if (old_ocf & OCF_HitSpeed2) Call(PSF_Hit2, &pars);
464  if (old_ocf & OCF_HitSpeed3) Call(PSF_Hit3, &pars);
465  }
466  // Rotation gfx
467  if (fTurned)
468  UpdateFace(true);
469  else
470  // pos changed?
471  if (fMoved) UpdatePos();
472 }
int32_t GetY() const
Definition: C4Object.h:287
const uint32_t OCF_HitSpeed1
Definition: C4Constants.h:84
int32_t ContactCheck(int32_t atx, int32_t aty, uint32_t *border_hack_contacts=nullptr, bool collide_halfvehic=false)
Definition: C4Movement.cpp:136
#define PSF_Hit
Definition: C4GameScript.h:49
int32_t GetY() const
Definition: C4Shape.h:63
bool Alive
Definition: C4Object.h:175
int32_t DigFree(int32_t tx, int32_t ty, int32_t rad, C4Object *by_object=nullptr, bool no_dig2objects=false, bool no_instability_check=false)
int32_t Mass
Definition: C4Object.h:115
void Remove(bool fBackupAttachment)
C4PropList * GetAction() const
Definition: C4Object.cpp:2674
C4Real rdir
Definition: C4Object.h:126
int32_t DigFreeRect(int32_t tx, int32_t ty, int32_t wdt, int32_t hgt, C4Object *by_object=nullptr, bool no_dig2objects=false, bool no_instability_check=false)
uint8_t BYTE
int Sign(T val)
Definition: Standard.h:45
int32_t NoHorizontalMove
Definition: C4Def.h:122
Definition: C4Real.h:58
const int32_t FullCon
Definition: C4Constants.h:181
void UpdatePos()
Definition: C4Object.cpp:370
int32_t Rotateable
Definition: C4Def.h:119
int32_t Wdt
Definition: C4Rect.h:30
bool InLiquid
Definition: C4Object.h:131
const uint32_t OCF_HitSpeed2
Definition: C4Constants.h:91
void SideBounds(C4Real &ctcox)
Definition: C4Movement.cpp:156
C4Def * Def
Definition: C4Object.h:143
int32_t t_attach
Definition: C4Object.h:86
void ApplyFriction(C4Real &tval, int32_t percent)
Definition: C4Movement.cpp:52
void RedirectForce(C4Real &from, C4Real &to, int32_t tdir)
Definition: C4Movement.cpp:44
void UpdateShape(bool bUpdateVertices=true)
Definition: C4Object.cpp:343
#define PSF_Hit2
Definition: C4GameScript.h:50
uint32_t t_contact
Definition: C4Object.h:133
int32_t ContactVtxFriction(C4Object *cobj)
Definition: C4Movement.cpp:91
C4Landscape Landscape
void ContactAction()
Definition: C4Object.cpp:2917
void NoAttachAction()
Definition: C4Object.cpp:2882
int32_t Con
Definition: C4Object.h:173
int32_t GetX() const
Definition: C4Shape.h:62
int32_t GetX() const
Definition: C4Object.h:286
C4Fixed itofix(int32_t x)
Definition: C4Real.h:261
const C4Real FixFullCircle
Definition: C4Movement.cpp:33
const uint32_t OCF_Rotate
Definition: C4Constants.h:88
void UpdateFace(bool bUpdateShape, bool fTemp=false)
Definition: C4Object.cpp:378
bool IsInLiquidCheck() const
Definition: C4Object.cpp:4101
void VerticalBounds(C4Real &ctcoy)
Definition: C4Movement.cpp:179
int32_t ContactVtxWeight(C4Object *cobj)
Definition: C4Movement.cpp:76
C4Real fix_r
Definition: C4Object.h:125
C4Real fix_x
Definition: C4Object.h:125
const BYTE CNAT_Right
Definition: C4Constants.h:110
#define PSF_Hit3
Definition: C4GameScript.h:51
const uint32_t OCF_HitSpeed3
Definition: C4Constants.h:92
int32_t GetPropertyInt(C4PropertyName k, int32_t default_val=0) const
Definition: C4PropList.cpp:886
C4Real fix_y
Definition: C4Object.h:125
int32_t Hgt
Definition: C4Rect.h:30
C4Action Action
Definition: C4Object.h:147
C4Shape Shape
Definition: C4Object.h:148
uint32_t OCF
Definition: C4Object.h:134
void UpdateSolidMask(bool fRestoreAttachedObjects)
Definition: C4Object.cpp:4141
bool ContactVtxCNAT(C4Object *cobj, BYTE cnat_dir)
Definition: C4Movement.cpp:63
C4SolidMask * pSolidMaskData
Definition: C4Object.h:176
int fixtoi(const C4Fixed &x)
Definition: C4Real.h:259
C4Real xdir
Definition: C4Object.h:126
const C4Real FixHalfCircle
Definition: C4Movement.cpp:33
const BYTE CNAT_Left
Definition: C4Constants.h:109
bool Attach(int32_t &cx, int32_t &cy, BYTE cnat_pos)
Definition: C4Shape.cpp:183
C4Real ydir
Definition: C4Object.h:126
void DoMotion(int32_t mx, int32_t my)
Definition: C4Movement.cpp:123
const C4Real Fix0
Definition: C4Real.h:312
C4Value Call(C4PropertyName k, C4AulParSet *pPars=nullptr, bool fPassErrors=false)
Definition: C4PropList.h:110

Here is the call graph for this function:

Here is the caller graph for this function:

bool C4Object::DoSelect ( )

Definition at line 4309 of file C4Object.cpp.

References C4PropList::Call(), CrewDisabled, and PSF_CrewSelection.

Referenced by C4Player::SetCursor().

4310 {
4311  // selection allowed?
4312  if (CrewDisabled) return false;
4313  // do callback
4315  // done
4316  return true;
4317 }
#define PSF_CrewSelection
Definition: C4GameScript.h:86
bool CrewDisabled
Definition: C4Object.h:163
C4Value Call(C4PropertyName k, C4AulParSet *pPars=nullptr, bool fPassErrors=false)
Definition: C4PropList.h:110

Here is the call graph for this function:

Here is the caller graph for this function:

void C4Object::Draw ( C4TargetFacet cgo,
int32_t  iByPlayer = -1,
DrawMode  eDrawMode = ODM_Normal,
float  offX = 0,
float  offY = 0 
)

Definition at line 1785 of file C4Object.cpp.

References C4Value::_getInt(), ACenter, Action, Angle(), StdStrBuf::Append(), StdStrBuf::AppendChar(), StdStrBuf::AppendFormat(), BackParticles, C4Draw::Blit(), BlitMode, C4CMD_Acquire, C4CMD_Buy, C4CMD_Call, C4CMD_MoveTo, C4CMD_None, C4CMD_Put, C4CMD_Sell, C4CMD_Transfer, C4D_IgnoreFoW, C4D_Parallax, C4RGB, Category, CNAT_NoCollision, C4Def::Collection, Color, ColorMod, C4Command::Command, Command, CommandName(), Con, Contained, C4Command::Data, Def, C4Draw::DEFAULT_MESSAGE_COLOR, C4ParticleList::Draw(), DrawActionFace(), C4Action::DrawDir, DrawFace(), C4Draw::DrawFrameDw(), DrawLine(), C4Draw::DrawLineDw(), C4Def::Entrance, C4Action::Facet, C4Action::FacetX, C4Action::FacetY, C4Command::Finished, FinishedDrawing(), Fix0, fix_r, fix_y, fixtof(), C4GraphicsResource::FontRegular, StdStrBuf::Format(), FrontParticles, FullCon, GetAction(), C4String::GetCStr(), StdStrBuf::getData(), C4Value::GetDataString(), GetDrawPosition(), C4Draw::GetFoW(), GetGraphics(), C4PropList::GetName(), C4GraphicsOverlay::GetNext(), C4PropList::GetPropertyInt(), CStdFont::GetTextExtent(), C4Shape::GetX(), GetX(), C4Shape::GetY(), GetY(), GraphicsResource, GraphicsSystem, C4Rect::Hgt, C4Facet::Hgt, InLiquid, IsVisible(), C4Def::Line, Mobile, C4Command::Next, OCF, OCF_Collection, OCF_Entrance, ODM_BaseOnly, ODM_Overlay, P_FacetBase, P_FacetTargetStretch, pDraw, pGfxOverlay, C4Action::Phase, PrepareDrawing(), C4ScriptUniform::Push(), C4Draw::scriptUniform, SetAudibilityAt(), C4Draw::SetFoW(), Shape, C4GraphicsSystem::Show8BitSurface, C4GraphicsSystem::ShowAction, C4GraphicsSystem::ShowCommand, C4GraphicsSystem::ShowEntrance, C4GraphicsSystem::ShowVertices, SolidMask, sprintf, C4PropList::Status, C4Facet::Surface, C4Command::Target, C4Action::Target, C4Command::Target2, C4Command::Text, C4Draw::TextOut(), C4Command::Tx, C4Command::Ty, C4DefGraphics::Type, C4DefGraphics::TYPE_Bitmap, C4Shape::VtxCNAT, C4Shape::VtxContactCNAT, C4Shape::VtxNum, C4Shape::VtxX, C4Shape::VtxY, C4Rect::Wdt, C4Facet::Wdt, C4Rect::x, C4Facet::X, C4Rect::y, C4Facet::Y, and C4TargetFacet::Zoom.

Referenced by C4ObjectList::Draw(), C4GraphicsOverlay::Draw(), C4ObjectList::DrawIfCategory(), and C4EditCursor::DrawObject().

1786 {
1787 #ifndef USE_CONSOLE
1788  C4Facet ccgo;
1789 
1790  // Status
1791  if (!Status || !Def) return;
1792 
1793  // visible?
1794  if (!IsVisible(iByPlayer, !!eDrawMode)) return;
1795 
1796  // Set up custom uniforms.
1797  auto uniform_popper = pDraw->scriptUniform.Push(this);
1798 
1799  // Line
1800  if (Def->Line) { DrawLine(cgo, iByPlayer); return; }
1801 
1802  // background particles (bounds not checked)
1803  if (BackParticles) BackParticles->Draw(cgo, this);
1804 
1805  // Object output position
1806  float newzoom = cgo.Zoom;
1807  if (eDrawMode!=ODM_Overlay)
1808  {
1809  if (!GetDrawPosition(cgo, offX, offY, newzoom)) return;
1810  }
1811  ZoomDataStackItem zdsi(newzoom);
1812 
1813  bool fYStretchObject=false;
1814  C4PropList* pActionDef = GetAction();
1815  if (pActionDef)
1816  if (pActionDef->GetPropertyInt(P_FacetTargetStretch))
1817  fYStretchObject=true;
1818 
1819  // Set audibility
1820  if (!eDrawMode) SetAudibilityAt(cgo, GetX(), GetY(), iByPlayer);
1821 
1822  // Output boundary
1823  if (!fYStretchObject && !eDrawMode && !(Category & C4D_Parallax))
1824  {
1825  // For actions with a custom facet set, check against that action facet. Otherwise (or with oversize objects), just check against shape.
1826  if (pActionDef && fix_r == Fix0 && !pActionDef->GetPropertyInt(P_FacetBase) && Con <= FullCon && Action.Facet.Wdt)
1827  {
1828  // active
1829  if ( !Inside<float>(offX+Shape.GetX()+Action.FacetX,cgo.X-Action.Facet.Wdt,cgo.X+cgo.Wdt)
1830  || (!Inside<float>(offY+Shape.GetY()+Action.FacetY,cgo.Y-Action.Facet.Hgt,cgo.Y+cgo.Hgt)) )
1831  {
1832  if (FrontParticles && !Contained) FrontParticles->Draw(cgo, this);
1833  return;
1834  }
1835  }
1836  else
1837  // idle
1838  if ( !Inside<float>(offX+Shape.GetX(),cgo.X-Shape.Wdt,cgo.X+cgo.Wdt)
1839  || (!Inside<float>(offY+Shape.GetY(),cgo.Y-Shape.Hgt,cgo.Y+cgo.Hgt)) )
1840  {
1841  if (FrontParticles && !Contained) FrontParticles->Draw(cgo, this);
1842  return;
1843  }
1844  }
1845 
1846  // ensure correct color is set
1847  if (GetGraphics()->Type == C4DefGraphics::TYPE_Bitmap)
1848  if (GetGraphics()->Bmp.BitmapClr) GetGraphics()->Bmp.BitmapClr->SetClr(Color);
1849 
1850  // Debug Display //////////////////////////////////////////////////////////////////////
1851  if (::GraphicsSystem.ShowCommand && !eDrawMode)
1852  {
1853  C4Command *pCom;
1854  int32_t ccx=GetX(),ccy=GetY();
1855  float offX1, offY1, offX2, offY2, newzoom;
1856  char szCommand[200];
1857  StdStrBuf Cmds;
1858  int32_t iMoveTos=0;
1859  for (pCom=Command; pCom; pCom=pCom->Next)
1860  {
1861  switch (pCom->Command)
1862  {
1863  case C4CMD_MoveTo:
1864  // Angle
1865  int32_t iAngle; iAngle=Angle(ccx,ccy,pCom->Tx._getInt(),pCom->Ty); while (iAngle>180) iAngle-=360;
1866  // Path
1867  if(GetDrawPosition(cgo, ccx, ccy, cgo.Zoom, offX1, offY1, newzoom) &&
1868  GetDrawPosition(cgo, pCom->Tx._getInt(), pCom->Ty, cgo.Zoom, offX2, offY2, newzoom))
1869  {
1870  ZoomDataStackItem zdsi(newzoom);
1871  pDraw->DrawLineDw(cgo.Surface,offX1,offY1,offX2,offY2,C4RGB(0xca,0,0));
1872  pDraw->DrawFrameDw(cgo.Surface,offX2-1,offY2-1,offX2+1,offY2+1,C4RGB(0xca,0,0));
1873  }
1874 
1875  ccx=pCom->Tx._getInt(); ccy=pCom->Ty;
1876  // Message
1877  iMoveTos++; szCommand[0]=0;
1878  break;
1879  case C4CMD_Put:
1880  sprintf(szCommand,"%s %s to %s",CommandName(pCom->Command),pCom->Target2 ? pCom->Target2->GetName() : pCom->Data ? pCom->Data.GetDataString().getData() : "Content",pCom->Target ? pCom->Target->GetName() : "");
1881  break;
1882  case C4CMD_Buy: case C4CMD_Sell:
1883  sprintf(szCommand,"%s %s at %s",CommandName(pCom->Command),pCom->Data.GetDataString().getData(),pCom->Target ? pCom->Target->GetName() : "closest base");
1884  break;
1885  case C4CMD_Acquire:
1886  sprintf(szCommand,"%s %s",CommandName(pCom->Command),pCom->Data.GetDataString().getData());
1887  break;
1888  case C4CMD_Call:
1889  sprintf(szCommand,"%s %s in %s",CommandName(pCom->Command),pCom->Text->GetCStr(),pCom->Target ? pCom->Target->GetName() : "(null)");
1890  break;
1891  case C4CMD_None:
1892  szCommand[0]=0;
1893  break;
1894  case C4CMD_Transfer:
1895  // Path
1896  if(GetDrawPosition(cgo, ccx, ccy, cgo.Zoom, offX1, offY1, newzoom) &&
1897  GetDrawPosition(cgo, pCom->Tx._getInt(), pCom->Ty, cgo.Zoom, offX2, offY2, newzoom))
1898  {
1899  ZoomDataStackItem zdsi(newzoom);
1900  pDraw->DrawLineDw(cgo.Surface,offX1,offY1,offX2,offY2,C4RGB(0,0xca,0));
1901  pDraw->DrawFrameDw(cgo.Surface,offX2-1,offY2-1,offX2+1,offY2+1,C4RGB(0,0xca,0));
1902  }
1903 
1904  ccx=pCom->Tx._getInt(); ccy=pCom->Ty;
1905  // Message
1906  sprintf(szCommand,"%s %s",CommandName(pCom->Command),pCom->Target ? pCom->Target->GetName() : "");
1907  break;
1908  default:
1909  sprintf(szCommand,"%s %s",CommandName(pCom->Command),pCom->Target ? pCom->Target->GetName() : "");
1910  break;
1911  }
1912  // Compose command stack message
1913  if (szCommand[0])
1914  {
1915  // End MoveTo stack first
1916  if (iMoveTos) { Cmds.AppendChar('|'); Cmds.AppendFormat("%dx MoveTo",iMoveTos); iMoveTos=0; }
1917  // Current message
1918  Cmds.AppendChar('|');
1919  if (pCom->Finished) Cmds.Append("<i>");
1920  Cmds.Append(szCommand);
1921  if (pCom->Finished) Cmds.Append("</i>");
1922  }
1923  }
1924  // Open MoveTo stack
1925  if (iMoveTos) { Cmds.AppendChar('|'); Cmds.AppendFormat("%dx MoveTo",iMoveTos); iMoveTos=0; }
1926  // Draw message
1927  int32_t cmwdt,cmhgt; ::GraphicsResource.FontRegular.GetTextExtent(Cmds.getData(),cmwdt,cmhgt,true);
1929  }
1930  // Debug Display ///////////////////////////////////////////////////////////////////////////////
1931 
1932  // Don't draw (show solidmask)