OpenClonk
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 exit_contents=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 at_x, int32_t at_y, 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 target_x, C4Real target_y)
 
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 &target_x, C4Real &target_y)
 
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
 
bool HalfVehicleSolidMask
 
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 &target_x)
 
void VerticalBounds (C4Real &target_y)
 
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 96 of file C4Object.h.

Member Enumeration Documentation

◆ anonymous enum

anonymous enum
Enumerator
SAC_StartCall 
SAC_EndCall 
SAC_AbortCall 

Definition at line 250 of file C4Object.h.

250 { SAC_StartCall = 1, SAC_EndCall = 2, SAC_AbortCall = 4 };
@ SAC_StartCall
Definition: C4Object.h:250
@ SAC_EndCall
Definition: C4Object.h:250
@ SAC_AbortCall
Definition: C4Object.h:250

◆ DrawMode

Enumerator
ODM_Normal 
ODM_Overlay 
ODM_BaseOnly 

Definition at line 215 of file C4Object.h.

@ ODM_Overlay
Definition: C4Object.h:215
@ ODM_Normal
Definition: C4Object.h:215
@ ODM_BaseOnly
Definition: C4Object.h:215

Constructor & Destructor Documentation

◆ C4Object()

C4Object::C4Object ( )

Definition at line 44 of file C4Object.cpp.

45 {
46  FrontParticles = BackParticles = nullptr;
47  Default();
48 }
class C4ParticleList * BackParticles
Definition: C4Object.h:157
void Default()
Definition: C4Object.cpp:50
class C4ParticleList * FrontParticles
Definition: C4Object.h:157

References BackParticles, Default(), and FrontParticles.

Here is the call graph for this function:

◆ ~C4Object()

C4Object::~C4Object ( )
override

Definition at line 195 of file C4Object.cpp.

196 {
197  Clear();
198 
199 #if defined(_DEBUG)
200  // debug: mustn't be listed in any list now
202 #endif
203 }
C4GameObjects Objects
Definition: C4Globals.cpp:48
C4LSectors Sectors
Definition: C4GameObjects.h:42
void AssertObjectNotInList(C4Object *pObj)
Definition: C4Sector.cpp:185
void Clear()
Definition: C4Object.cpp:1083

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

Here is the call graph for this function:

Member Function Documentation

◆ AcquireNumber()

void C4PropListNumbered::AcquireNumber ( )
protectedinherited

Definition at line 131 of file C4PropList.cpp.

132 {
133  // Enumerate object
134  do
136  while (PropLists.Get(Number));
137  // Add to list
138  PropLists.Add(this);
139 }
static C4Set< C4PropListNumbered * > PropLists
Definition: C4PropList.h:241
static int32_t EnumerationIndex
Definition: C4PropList.h:243
T & Get(H e) const
T * Add(T const &e)

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

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

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ActivateEntrance()

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

Definition at line 689 of file C4Object.cpp.

690 {
691 
692  // Try entrance activation
693  if (OCF & OCF_Entrance)
694  if (!! Call(PSF_ActivateEntrance,&C4AulParSet(by_obj)))
695  return true;
696  // Failure
697  return false;
698 }
const uint32_t OCF_Entrance
Definition: C4Constants.h:90
#define PSF_ActivateEntrance
Definition: C4GameScript.h:67
uint32_t OCF
Definition: C4Object.h:132
C4Value Call(C4PropertyName k, C4AulParSet *pPars=nullptr, bool fPassErrors=false)
Definition: C4PropList.h:114

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

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

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ActivateMenu()

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

Definition at line 57 of file C4ObjectMenuLogic.cpp.

60 {
61  // Variables
62  C4FacetSurface fctSymbol;
63  C4IDList ListItems;
64  // Close any other menu
65  if (Menu && Menu->IsActive()) if (!Menu->TryClose(true, false)) return false;
66  // Create menu
67  if (!Menu) Menu = new C4ObjectMenu; else Menu->ClearItems();
68  // Open menu
69  switch (iMenu)
70  {
71  // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
72  case C4MN_Activate:
73  // No target specified: use own container as target
74  if (!pTarget) if (!(pTarget=Contained)) break;
75  // Opening contents menu blocked by RejectContents
76  if (!!pTarget->Call(PSF_RejectContents)) return false;
77  // Create symbol
78  fctSymbol.Create(C4SymbolSize,C4SymbolSize);
79  pTarget->Def->Draw(fctSymbol,false,pTarget->Color,pTarget);
80  // Init
81  Menu->Init(fctSymbol,FormatString(LoadResStr("IDS_OBJ_EMPTY"),pTarget->GetName()).getData(),this,C4MN_Extra_None,0,iMenu);
82  Menu->SetPermanent(true);
83  Menu->SetRefillObject(pTarget);
84  // Success
85  return true;
86  // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
87  case C4MN_Buy:
88  // No target specified: container is base
89  if (!pTarget) if (!(pTarget=Contained)) break;
90  // Create symbol
91  fctSymbol.Create(C4SymbolSize,C4SymbolSize);
92  DrawMenuSymbol(C4MN_Buy, fctSymbol, pTarget->Owner);
93  // Init menu
94  Menu->Init(fctSymbol,LoadResStr("IDS_PLR_NOBUY"),this,C4MN_Extra_Value,0,iMenu);
95  Menu->SetPermanent(true);
96  Menu->SetRefillObject(pTarget);
97  // Success
98  return true;
99  // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
100  case C4MN_Sell:
101  // No target specified: container is base
102  if (!pTarget) if (!(pTarget=Contained)) break;
103  // Create symbol & init
104  fctSymbol.Create(C4SymbolSize,C4SymbolSize);
105  DrawMenuSymbol(C4MN_Sell, fctSymbol, pTarget->Owner);
106  Menu->Init(fctSymbol,FormatString(LoadResStr("IDS_OBJ_EMPTY"),pTarget->GetName()).getData(),this,C4MN_Extra_Value,0,iMenu);
107  Menu->SetPermanent(true);
108  Menu->SetRefillObject(pTarget);
109  // Success
110  return true;
111  // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
112  case C4MN_Get:
113  case C4MN_Contents:
114  // No target specified
115  if (!pTarget) break;
116  // Opening contents menu blocked by RejectContents
117  if (!!pTarget->Call(PSF_RejectContents)) return false;
118  // Create symbol & init
119  fctSymbol.Create(C4SymbolSize,C4SymbolSize);
120  pTarget->Def->Draw(fctSymbol,false,pTarget->Color,pTarget);
121  Menu->Init(fctSymbol,FormatString(LoadResStr("IDS_OBJ_EMPTY"),pTarget->GetName()).getData(),this,C4MN_Extra_None,0,iMenu);
122  Menu->SetPermanent(true);
123  Menu->SetRefillObject(pTarget);
124  // Success
125  return true;
126  // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
127  case C4MN_Info:
128  // Target by parameter
129  if (!pTarget) break;
130  // Create symbol & init menu
131  fctSymbol.Create(C4SymbolSize, C4SymbolSize); GfxR->fctOKCancel.Draw(fctSymbol,true,0,1);
132  Menu->Init(fctSymbol, pTarget->GetName(), this, C4MN_Extra_None, 0, iMenu, C4MN_Style_Info);
133  Menu->SetPermanent(true);
135  C4Viewport *pViewport = ::Viewports.GetViewport(Controller); // Hackhackhack!!!
136  if (pViewport) Menu->SetLocation((pTarget->GetX() + pTarget->Shape.GetX() + pTarget->Shape.Wdt + 10 - pViewport->GetViewX()) * pViewport->GetZoom(),
137  (pTarget->GetY() + pTarget->Shape.GetY() - pViewport->GetViewY()) * pViewport->GetZoom());
138  // Add info item
139  fctSymbol.Create(C4PictureSize, C4PictureSize); pTarget->Def->Draw(fctSymbol, false, pTarget->Color, pTarget);
140  Menu->Add(pTarget->GetName(), fctSymbol, "", C4MN_Item_NoCount, nullptr, pTarget->GetInfoString().getData());
141  fctSymbol.Default();
142  // Success
143  return true;
144  // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
145  }
146  // Invalid menu identification
147  CloseMenu(true);
148  return false;
149 }
const int C4PictureSize
Definition: C4Constants.h:60
const int C4SymbolSize
Definition: C4Constants.h:58
#define PSF_RejectContents
Definition: C4GameScript.h:134
#define GfxR
const char * LoadResStr(const char *id)
Definition: C4Language.h:83
@ C4MN_Extra_Value
Definition: C4Menu.h:45
@ C4MN_Extra_None
Definition: C4Menu.h:44
@ C4MN_Item_NoCount
Definition: C4Menu.h:58
@ C4MN_Style_Info
Definition: C4Menu.h:37
@ C4MN_Align_Free
Definition: C4Menu.h:54
@ C4MN_Sell
Definition: C4ObjectMenu.h:32
@ C4MN_Buy
Definition: C4ObjectMenu.h:31
@ C4MN_Activate
Definition: C4ObjectMenu.h:33
@ C4MN_Get
Definition: C4ObjectMenu.h:39
@ C4MN_Contents
Definition: C4ObjectMenu.h:44
@ C4MN_Info
Definition: C4ObjectMenu.h:41
C4ViewportList Viewports
StdStrBuf FormatString(const char *szFmt,...)
Definition: StdBuf.cpp:270
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:607
bool Create(int iWdt, int iHgt, int iWdt2=C4FCT_Full, int iHgt2=C4FCT_Full)
Definition: C4FacetEx.cpp:54
void Default()
Definition: C4FacetEx.h:43
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
void SetPermanent(bool fPermanent)
Definition: C4Menu.cpp:862
bool TryClose(bool fOK, bool fControl)
Definition: C4Menu.cpp:280
bool SetLocation(int32_t iX, int32_t iY)
Definition: C4Menu.cpp:951
void SetAlignment(int32_t iAlignment)
Definition: C4Menu.cpp:857
void ClearItems()
Definition: C4Menu.cpp:895
bool IsActive()
Definition: C4Menu.cpp:480
int32_t Owner
Definition: C4Object.h:108
int32_t GetX() const
Definition: C4Object.h:285
class C4ObjectMenu * Menu
Definition: C4Object.h:138
int32_t Controller
Definition: C4Object.h:109
bool CloseMenu(bool fForce)
int32_t GetY() const
Definition: C4Object.h:286
C4ObjectPtr Contained
Definition: C4Object.h:142
C4Def * Def
Definition: C4Object.h:141
uint32_t Color
Definition: C4Object.h:118
StdStrBuf GetInfoString()
Definition: C4Object.cpp:1244
C4Shape Shape
Definition: C4Object.h:146
void SetRefillObject(C4Object *pObj)
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)
virtual const char * GetName() const
Definition: C4PropList.cpp:618
int32_t Wdt
Definition: C4Rect.h:30
int32_t GetX() const
Definition: C4Shape.h:62
int32_t GetY() const
Definition: C4Shape.h:63
float GetViewY()
Definition: C4Viewport.h:78
float GetViewX()
Definition: C4Viewport.h:76
float GetZoom()
Definition: C4Viewport.h:48
C4Viewport * GetViewport(int32_t player_nr, C4Viewport *prev=nullptr)
const char * getData() const
Definition: StdBuf.h:442

References C4MN_Activate, C4MN_Buy, C4MN_Extra_None, C4SymbolSize, C4PropList::Call(), C4Menu::ClearItems(), Color, Contained, C4FacetSurface::Create(), Def, C4Def::Draw(), FormatString(), StdStrBuf::getData(), C4PropList::GetName(), C4ObjectMenu::Init(), C4Menu::IsActive(), LoadResStr(), Menu, PSF_RejectContents, C4Menu::SetPermanent(), C4ObjectMenu::SetRefillObject(), and C4Menu::TryClose().

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

Here is the call graph for this function:
Here is the caller graph for this function:

◆ AddCommand() [1/2]

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 60 of file C4ObjectCommand.cpp.

64 {
65  // Command stack size safety
66  const int32_t MaxCommandStack = 35;
67  C4Command *pCom,*pLast; int32_t iCommands;
68  for (pCom=Command,iCommands=0; pCom; pCom=pCom->Next,iCommands++) {}
69  if (iCommands>=MaxCommandStack) return false;
70  // Valid command safety
71  if (!Inside(iCommand,C4CMD_First,C4CMD_Last)) return false;
72  // Allocate and set new command
73  if (!(pCom=new C4Command)) return false;
74  pCom->Set(iCommand,this,pTarget,iTx,iTy,pTarget2,iData,
75  iUpdateInterval,!fInitEvaluation,iRetries,szText,iBaseMode);
76  // Append to bottom of stack
77  if (fAppend)
78  {
79  for (pLast=Command; pLast && pLast->Next; pLast=pLast->Next) {}
80  if (pLast) pLast->Next=pCom;
81  else Command=pCom;
82  }
83  // Add to top of command stack
84  else
85  {
86  pCom->Next=Command;
87  Command=pCom;
88  }
89  // Success
90  return true;
91 }
const int32_t C4CMD_Last
Definition: C4Command.h:57
const int32_t C4CMD_First
Definition: C4Command.h:56
bool Inside(T ival, U lbound, V rbound)
Definition: Standard.h:43
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
C4Command * Next
Definition: C4Command.h:90
C4Command * Command
Definition: C4Object.h:165

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().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ AddCommand() [2/2]

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 185 of file C4Object.h.

186  { return AddCommand(iCommand, pTarget, C4VInt(iTx), iTy, iUpdateInterval, pTarget2, fInitEvaluation, iData, fAppend, iRetries, szText, iBaseMode); }
C4Value C4VInt(int32_t i)
Definition: C4Value.h:239
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)

References AddCommand(), and C4VInt().

Here is the call graph for this function:

◆ AddObjectAndContentsToArray()

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

Definition at line 229 of file C4ObjectContents.cpp.

230 {
231  // add self, contents and child contents count recursively to value array. Return index after last added item.
232  target_array->SetItem(index++, C4VObj(this));
233  for (C4Object *cobj : Contents)
234  {
235  index = cobj->AddObjectAndContentsToArray(target_array, index);
236  }
237  return index;
238 }
C4Value C4VObj(C4Object *pObj)
Definition: C4Value.cpp:88
C4NotifyingObjectList Contents
Definition: C4Object.h:151
void SetItem(int32_t iElemNr, const C4Value &Value)

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

Referenced by C4EditCursor::PerformDuplication().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ addtop()

int32_t C4Object::addtop ( ) const
inline

Definition at line 280 of file C4Object.h.

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

References C4Rect::Hgt, and Shape.

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

Here is the caller graph for this function:

◆ AdjustWalkRotation()

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

Definition at line 376 of file C4ObjectPhysics.cpp.

377 {
378  int32_t dest_angle;
379  // Attachment at middle (bottom) vertex?
380  if (Shape.iAttachVtx < 0 || !Def->Shape.VtxX[Shape.iAttachVtx])
381  {
382  // Evaluate floor around attachment pos
383  int32_t y_solid_left = 0;
384  int32_t y_solid_right = 0;
385  // Left
386  int32_t check_x = Shape.iAttachX - range_x;
387  if (GBackSolid(check_x, Shape.iAttachY))
388  {
389  // Up
390  while (--y_solid_left > -range_y)
391  {
392  if (GBackSolid(check_x, Shape.iAttachY + y_solid_left))
393  {
394  ++y_solid_left;
395  break;
396  }
397  }
398  }
399  else
400  {
401  // Down
402  while (++y_solid_left < range_y)
403  {
404  if (GBackSolid(check_x, Shape.iAttachY + y_solid_left))
405  {
406  --y_solid_left;
407  break;
408  }
409  }
410  }
411  // Right
412  check_x += 2 * range_x;
413  if (GBackSolid(check_x, Shape.iAttachY))
414  {
415  // Up
416  while (--y_solid_right > -range_y)
417  {
418  if (GBackSolid(check_x, Shape.iAttachY + y_solid_right))
419  {
420  ++y_solid_right;
421  break;
422  }
423  }
424  }
425  else
426  {
427  // Down
428  while (++y_solid_right < range_y)
429  {
430  if (GBackSolid(check_x, Shape.iAttachY + y_solid_right))
431  {
432  --y_solid_right;
433  break;
434  }
435  }
436  }
437  // Calculate destination angle
438  // 100% accurate for large values of Pi ;)
439  dest_angle = (y_solid_right - y_solid_left) * (35 / std::max<int32_t>(range_x, 1));
440  }
441  else
442  {
443  // Attachment at other than horizontal middle vertex: get your feet to the ground!
444  // Rotate target to large angle is OK, because rotation will stop once the real
445  // bottom vertex hits solid ground
446  if (Shape.VtxX[Shape.iAttachVtx] > 0)
447  {
448  dest_angle = -50;
449  }
450  else
451  {
452  dest_angle = 50;
453  }
454  }
455  // Move to destination angle
456  if (Abs(dest_angle - GetR()) > 2)
457  {
458  rdir = itofix(Clamp<int32_t>(dest_angle-GetR(), -15, +15));
459  rdir /= (10000 / speed);
460  }
461  else
462  {
463  rdir = 0;
464  }
465  // Done, success
466  return true;
467 }
bool GBackSolid(int32_t x, int32_t y)
Definition: C4Landscape.h:229
C4Fixed itofix(int32_t x)
Definition: C4Real.h:261
T Abs(T val)
Definition: Standard.h:42
C4Shape Shape
Definition: C4Def.h:104
int32_t GetR() const
Definition: C4Object.h:287
C4Real rdir
Definition: C4Object.h:124
int32_t iAttachY
Definition: C4Shape.h:53
int32_t iAttachX
Definition: C4Shape.h:53
int32_t iAttachVtx
Definition: C4Shape.h:53
int32_t VtxX[C4D_MaxVertex]
Definition: C4Shape.h:43

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

Here is the call graph for this function:

◆ AppendDataString()

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

Definition at line 487 of file C4PropList.cpp.

488 {
489  StdStrBuf & DataString = *out;
490  if (depth <= 0 && Properties.GetSize())
491  {
492  DataString.Append("...");
493  return;
494  }
495  bool has_elements = false;
496  // Append prototype
497  if (prototype)
498  {
499  DataString.Append("Prototype = ");
500  DataString.Append(prototype.GetDataString(depth - 1, ignore_reference_parent ? IsStatic() : nullptr));
501  has_elements = true;
502  }
503  // Append other properties
504  std::list<const C4Property *> sorted_props = Properties.GetSortedListOfElementPointers();
505  for (std::list<const C4Property *>::const_iterator p = sorted_props.begin(); p != sorted_props.end(); ++p)
506  {
507  if (has_elements) DataString.Append(delim);
508  DataString.Append((*p)->Key->GetData());
509  DataString.Append(" = ");
510  DataString.Append((*p)->Value.GetDataString(depth - 1, ignore_reference_parent ? IsStatic() : nullptr));
511  has_elements = true;
512  }
513 }
virtual class C4PropListStatic * IsStatic()
Definition: C4PropList.h:89
std::list< const T * > GetSortedListOfElementPointers() const
unsigned int GetSize() const
StdStrBuf GetDataString(int depth=10, const class C4PropListStatic *ignore_reference_parent=nullptr) const
Definition: C4Value.cpp:131
void Append(const char *pnData, size_t iChars)
Definition: StdBuf.h:519

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

Referenced by GetDataString().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ AssignDeath()

void C4Object::AssignDeath ( bool  fForced)

Definition at line 467 of file C4Object.cpp.

468 {
469  C4Object *thing;
470  // Alive objects only
471  if (!Alive) return;
472  // clear all effects
473  // do not delete effects afterwards, because they might have denied removal
474  // set alive-flag before, so objects know what's up
475  // and prevent recursive death-calls this way
476  // get death causing player before doing effect calls, because those might meddle around with the flags
477  int32_t iDeathCausingPlayer = LastEnergyLossCausePlayer;
478  Alive=false;
480  // if the object is alive again, abort here if the kill is not forced
481  if (Alive && !fForced) return;
482  // Action
483  SetActionByName("Dead");
484  // Values
485  Alive=false;
486  ClearCommands();
487  C4ObjectInfo * pInfo = Info;
488  if (Info)
489  {
490  Info->HasDied=true;
491  ++Info->DeathCount;
492  Info->Retire();
493  }
494  // Remove from crew/cursor/view
495  C4Player *pPlr = ::Players.Get(Owner);
496  if (pPlr) pPlr->ClearPointers(this, true);
497  // Remove from light sources
498  SetLightRange(0,0);
499  // Engine script call
500  C4AulParSet pars(iDeathCausingPlayer);
501  Call(PSF_Death, &pars);
502  // Lose contents
503  while ((thing=Contents.GetObject())) thing->Exit(thing->GetX(),thing->GetY());
504  // Update OCF. Done here because previously it would have been done in the next frame
505  // Whats worse: Having the OCF change because of some unrelated script-call like
506  // SetCategory, or slightly breaking compatibility?
507  SetOCF();
508  // Engine broadcast: relaunch player (in CR, this was called from clonk script.
509  // Now, it is done for every crew member)
510  if(pPlr)
511  if(!pPlr->Crew.ObjectCount())
513  &C4AulParSet(Owner, iDeathCausingPlayer, Status ? this : nullptr));
514  if (pInfo)
515  pInfo->HasDied = false;
516 }
#define C4FxCall_RemoveDeath
Definition: C4Effect.h:46
#define PSF_Death
Definition: C4GameScript.h:66
#define PSF_RelaunchPlayer
Definition: C4GameScript.h:47
C4Game Game
Definition: C4Globals.cpp:52
C4PlayerList Players
void ClearAll(int32_t iClearFlag)
Definition: C4Effect.cpp:369
C4Value GRBroadcast(const char *function, C4AulParSet *pars=nullptr, bool pass_error=false, bool reject_test=false)
Definition: C4Game.cpp:4761
C4ObjectInfo * Info
Definition: C4Object.h:143
void ClearCommands()
bool SetActionByName(C4String *ActName, C4Object *pTarget=nullptr, C4Object *pTarget2=nullptr, int32_t iCalls=SAC_StartCall|SAC_AbortCall, bool fForce=false)
C4Effect * pEffects
Definition: C4Object.h:155
bool SetLightRange(int32_t iToRange, int32_t iToFadeoutRange)
bool Alive
Definition: C4Object.h:174
int32_t LastEnergyLossCausePlayer
Definition: C4Object.h:110
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 SetOCF()
Definition: C4ObjectOCF.cpp:30
int32_t DeathCount
Definition: C4InfoCore.h:44
int ObjectCount(C4ID id=C4ID::None) const
C4Object * GetObject(int index=0) const
C4ObjectList Crew
Definition: C4Player.h:125
void ClearPointers(C4Object *tptr, bool fDeath)
Definition: C4Player.cpp:98
C4Player * Get(int iPlayer) const
int32_t Status
Definition: C4PropList.h:173

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().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ AssignInfo()

bool C4Object::AssignInfo ( )

Definition at line 1045 of file C4Object.cpp.

1046 {
1047  if (Info || !ValidPlr(Owner)) return false;
1048  // In crew list?
1049  C4Player *pPlr = ::Players.Get(Owner);
1050  if (pPlr->Crew.GetLink(this))
1051  {
1052  // Register with player
1053  if (!::Players.Get(Owner)->MakeCrewMember(this, true, false))
1054  pPlr->Crew.Remove(this);
1055  return true;
1056  }
1057  // Info set, but not in crew list, so
1058  // a) The savegame is old-style (without crew list)
1059  // or b) The clonk is dead
1060  // or c) The clonk belongs to a script player that's restored without Game.txt
1061  else if (nInfo.getLength())
1062  {
1063  if (!::Players.Get(Owner)->MakeCrewMember(this, true, false))
1064  return false;
1065  // Dead and gone (info flags, remove from crew/cursor)
1066  if (!Alive)
1067  {
1068  if (ValidPlr(Owner)) ::Players.Get(Owner)->ClearPointers(this, true);
1069  }
1070  return true;
1071  }
1072  return false;
1073 }
int32_t ValidPlr(int32_t plr)
StdCopyStrBuf nInfo
Definition: C4Object.h:167
const C4ObjectLink * GetLink(const C4Object *obj) const
virtual bool Remove(C4Object *obj)
bool MakeCrewMember(C4Object *pObj, bool fForceInfo=true, bool fDoCalls=true)
Definition: C4Player.cpp:1008
size_t getLength() const
Definition: StdBuf.h:445

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().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ AssignLightRange()

bool C4Object::AssignLightRange ( )

Definition at line 29 of file C4ObjectVisibility.cpp.

30 {
31  if (!lightRange && !lightFadeoutRange) return true;
32 
33  UpdateLight();
34  return true;
35 }
int32_t lightRange
Definition: C4Object.h:120
int32_t lightFadeoutRange
Definition: C4Object.h:121

References lightFadeoutRange, lightRange, and UpdateLight().

Here is the call graph for this function:

◆ AssignRemoval()

void C4Object::AssignRemoval ( bool  exit_contents = false)

Definition at line 215 of file C4Object.cpp.

216 {
217  // Multiple calls to this functions can cause really bad problems, so we have to cancel
218  // in case the object is deleted or being deleted (final deletion happens after removal delay):
219  // - the def count may be decreased several times. This is really hard to notice if there
220  // are a lot of objects, because you have to delete at least half of them to get to a
221  // negative count, and even then it will only have an effect for functions that
222  // actually evaluate the def count.
223  // - object status and effects must be updated before the object is removed,
224  // but at the same time a lot if functions rely on the object being properly
225  // deleted when the status of an object is C4OS_DELETED.
226  if (Status == C4OS_DELETED || RemovalDelay > 0)
227  {
228  return;
229  }
230  // Set status to deleting, so that callbacks in this function that might delete
231  // the object do not delete it a second time.
232  RemovalDelay = 2;
233 
234  // Debugging
235  if (Config.General.DebugRec)
236  {
237  C4RCCreateObj rc;
238  memset(&rc, '\0', sizeof(rc));
239  rc.oei = Number;
240  if (Def && Def->GetName())
241  {
242  strncpy(rc.id, Def->GetName(), 32+1);
243  }
244  rc.x = GetX();
245  rc.y = GetY();
246  rc.ownr = Owner;
247  AddDbgRec(RCT_DsObj, &rc, sizeof(rc));
248  }
249 
250  // Destruction call notification for container
251  if (Contained)
252  {
253  C4AulParSet pars(this);
255  }
256 
257  // Destruction call
259 
260  // Remove all effects (extinguishes as well)
261  if (pEffects)
262  {
264  }
265 
266  // Remove particles
268 
269  // Action idle
270  SetAction(nullptr);
271 
272  // Object system operation
273  if (Status == C4OS_INACTIVE)
274  {
275  // Object was inactive: activate first, then delete
278  ::Objects.Add(this);
279  }
280 
282  // count decrease
283  Def->Count--;
284 
285  // get container for next actions
286  C4Object *pCont = Contained;
287  // remove or exit contents
288  for (C4Object *cobj : Contents)
289  {
290  if (exit_contents)
291  {
292  // move objects to parent container or exit them completely
293  bool fRejectCollect;
294  if (!pCont || !cobj->Enter(pCont, true, false, &fRejectCollect))
295  cobj->Exit(GetX(), GetY());
296  }
297  else
298  {
299  Contents.Remove(cobj);
300  cobj->Contained = nullptr;
301  cobj->AssignRemoval();
302  }
303  }
304  // remove this object from container *after* its contents have been removed!
305  if (pCont)
306  {
307  pCont->Contents.Remove(this);
308  pCont->UpdateMass();
309  pCont->SetOCF();
310  Contained=nullptr;
311  }
312  // Object info
313  if (Info) Info->Retire();
314  Info = nullptr;
315  // Object system operation
316  ClearRefs();
317  Game.ClearPointers(this);
318  ClearCommands();
319  if (pSolidMaskData)
320  {
321  delete pSolidMaskData;
322  pSolidMaskData = nullptr;
323  }
324  SolidMask.Wdt = 0;
325 }
C4Config Config
Definition: C4Config.cpp:930
#define C4FxCall_RemoveClear
Definition: C4Effect.h:45
#define PSF_Destruction
Definition: C4GameScript.h:38
#define PSF_ContentsDestruction
Definition: C4GameScript.h:39
#define C4OS_INACTIVE
Definition: C4Object.h:36
#define C4OS_NORMAL
Definition: C4Object.h:35
#define C4OS_DELETED
Definition: C4Object.h:34
void AddDbgRec(C4RecordChunkType eType, const void *pData, int iSize)
Definition: C4Record.cpp:32
@ RCT_DsObj
Definition: C4Record.h:63
char id[32+1]
Definition: C4Record.h:150
int32_t DebugRec
Definition: C4Config.h:63
C4ConfigGeneral General
Definition: C4Config.h:255
int32_t Count
Definition: C4Def.h:179
void ClearPointers(C4Object *obj)
Definition: C4Game.cpp:1125
bool Add(C4Object *game_object)
C4ObjectList InactiveObjects
Definition: C4GameObjects.h:43
void UpdateMass()
C4TargetRect SolidMask
Definition: C4Object.h:148
void ClearParticleLists()
Definition: C4Object.cpp:205
C4SolidMask * pSolidMaskData
Definition: C4Object.h:175
int32_t RemovalDelay
Definition: C4Object.h:107
bool SetAction(C4PropList *Act, C4Object *pTarget=nullptr, C4Object *pTarget2=nullptr, int32_t iCalls=SAC_StartCall|SAC_AbortCall, bool fForce=false)
void ClearRefs()
Definition: C4PropList.h:160
const char * GetName() const override
Definition: C4PropList.cpp:243

References C4GameObjects::Add(), AddDbgRec(), C4FxCall_RemoveClear, C4OS_DELETED, 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(), ExecMovement(), and C4Player::RemoveCrewObjects().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ At() [1/2]

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

Definition at line 82 of file C4ObjectPhysics.cpp.

83 {
84  return Status
85  && !Contained
86  && Def
87  // TODO: Do a separate check in C4Shape
88  && Inside<int32_t>(cty - (GetY() + Shape.GetY() - addtop()), 0, Shape.Hgt - 1 + addtop())
89  && Inside<int32_t>(ctx - (GetX() + Shape.GetX()), 0, Shape.Wdt - 1);
90 }
int32_t addtop() const
Definition: C4Object.h:280

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

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

Here is the call graph for this function:
Here is the caller graph for this function:

◆ At() [2/2]

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

Definition at line 92 of file C4ObjectPhysics.cpp.

93 {
94  if (Status
95  && !Contained
96  && Def
97  && (OCF & ocf)
98  // TODO: Do a separate check in C4Shape
99  && Inside<int32_t>(cty - (GetY() + Shape.GetY() - addtop()), 0, Shape.Hgt - 1 + addtop())
100  && Inside<int32_t>(ctx - (GetX() + Shape.GetX()), 0, Shape.Wdt - 1))
101  {
102  // Set ocf return value
103  GetOCFForPos(ctx, cty, ocf);
104  return true;
105  }
106  return false;
107 }
void GetOCFForPos(int32_t ctx, int32_t cty, DWORD &ocf) const

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

Here is the call graph for this function:

◆ begin()

C4PropList::Iterator C4PropList::begin ( )
inherited

Definition at line 995 of file C4PropList.cpp.

996 {
998 
999  if (GetPrototype())
1000  {
1001  iter = GetPrototype()->begin();
1002  }
1003  else
1004  {
1005  iter.properties = std::make_shared<std::vector<const C4Property*> >();
1006  }
1007  iter.Reserve(Properties.GetSize());
1008 
1009  const C4Property * p = Properties.First();
1010  while (p)
1011  {
1012  iter.AddProperty(p);
1013  p = Properties.Next(p);
1014  }
1015 
1016  iter.Init();
1017  return iter;
1018 }
C4PropList * GetPrototype() const
Definition: C4PropList.h:85
Iterator begin()
Definition: C4PropList.cpp:995
T const * Next(T const *p) const
T const * First() const

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

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

Here is the call graph for this function:
Here is the caller graph for this function:

◆ BoundsCheck()

void C4Object::BoundsCheck ( C4Real target_x,
C4Real target_y 
)
inline

Definition at line 330 of file C4Object.h.

331  { SideBounds(target_x); VerticalBounds(target_y); }
void VerticalBounds(C4Real &target_y)
Definition: C4Movement.cpp:217
void SideBounds(C4Real &target_x)
Definition: C4Movement.cpp:184

References SideBounds(), and VerticalBounds().

Referenced by Exit().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ Call() [1/3]

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

Definition at line 114 of file C4PropList.h.

115  { return Call(&Strings.P[k], pPars, fPassErrors); }
C4StringTable Strings
Definition: C4Globals.cpp:42
C4String P[P_LAST]

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(), ExecLife(), ExecuteCommand(), C4ScriptGuiWindowAction::ExecuteCommand(), Exit(), C4Command::Fail(), C4Command::GetTryEnter(), C4Def::GetValue(), GetValue(), GrabLost(), C4Landscape::Incinerate(), C4Effect::Init(), C4Player::Init(), C4ObjectMenu::IsCloseDenied(), C4Effect::Kill(), Lift(), C4Game::NewObject(), ObjectActionJump(), ObjectComGrab(), ObjectComPunch(), ObjectComPut(), ObjectComUnGrab(), C4ObjectMenu::OnSelectionChanged(), C4EditCursor::PerformDuplication(), C4EditCursor::PerformDuplicationLegacy(), C4Landscape::P::PostFreeShape(), Promote(), Push(), C4Game::SaveData(), SetAction(), C4GUI::FrameDecoration::SetByDef(), SetCommand(), C4Player::SetObjectCrewStatus(), SetOwner(), StatusActivate(), C4Command::Transfer(), and UnSelect().

Here is the caller graph for this function:

◆ Call() [2/3]

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

Definition at line 797 of file C4PropList.cpp.

798 {
799  if (!Status) return C4Value();
800  C4AulFunc *pFn = GetFunc(k);
801  if (!pFn) return C4Value();
802  return pFn->Exec(this, Pars, fPassErrors);
803 }
C4Value Exec(C4PropList *p=nullptr, C4AulParSet *pPars=nullptr, bool fPassErrors=false)
Definition: C4AulFunc.h:72
C4AulFunc * GetFunc(C4PropertyName k) const
Definition: C4PropList.h:109
friend class C4Value
Definition: C4PropList.h:170

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

Here is the call graph for this function:

◆ Call() [3/3]

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

Definition at line 805 of file C4PropList.cpp.

806 {
807  if (!Status) return C4Value();
808  assert(s && s[0]);
809  C4AulFunc *pFn = GetFunc(s);
810  if (!pFn)
811  {
812  if (s[0] != '~')
813  {
814  C4AulExecError err(FormatString("Undefined function: %s", s).getData());
815  if (fPassErrors)
816  throw err;
817  ::ScriptEngine.GetErrorHandler()->OnError(err.what());
818  }
819  return C4Value();
820  }
821  return pFn->Exec(this, Pars, fPassErrors);
822 }
#define s
C4AulScriptEngine ScriptEngine
Definition: C4Globals.cpp:43
virtual void OnError(const char *msg)=0
C4AulErrorHandler * GetErrorHandler() const
Definition: C4Aul.h:173

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

Here is the call graph for this function:

◆ CanConcatPictureWith()

bool C4Object::CanConcatPictureWith ( C4Object pOtherObject) const

Definition at line 895 of file C4ObjectGraphics.cpp.

896 {
897  // check current definition ID
898  if (id != pOtherObject->id) return false;
899  // def overwrite of stack conditions
900  int32_t allow_picture_stack = Def->AllowPictureStack;
901  if (!(allow_picture_stack & APS_Color))
902  {
903  // check color if ColorByOwner (flags)
904  if (Color != pOtherObject->Color && Def->ColorByOwner) return false;
905  // check modulation
906  if (ColorMod != pOtherObject->ColorMod) return false;
907  if (BlitMode != pOtherObject->BlitMode) return false;
908  }
909  if (!(allow_picture_stack & APS_Graphics))
910  {
911  // check graphics
912  if (pGraphics != pOtherObject->pGraphics) return false;
913  // check any own picture rect
914  if (PictureRect != pOtherObject->PictureRect) return false;
915  }
916  if (!(allow_picture_stack & APS_Name))
917  {
918  // check name, so zagabar's sandwiches don't stack
919  if (GetName() != pOtherObject->GetName()) return false;
920  }
921  if (!(allow_picture_stack & APS_Overlay))
922  {
923  // check overlay graphics
924  for (C4GraphicsOverlay *pOwnOverlay = pGfxOverlay; pOwnOverlay; pOwnOverlay = pOwnOverlay->GetNext())
925  if (pOwnOverlay->IsPicture())
926  {
927  C4GraphicsOverlay *pOtherOverlay = pOtherObject->GetGraphicsOverlay(pOwnOverlay->GetID(), false);
928  if (!pOtherOverlay || !(*pOtherOverlay == *pOwnOverlay)) return false;
929  }
930  for (C4GraphicsOverlay *pOtherOverlay = pOtherObject->pGfxOverlay; pOtherOverlay; pOtherOverlay = pOtherOverlay->GetNext())
931  if (pOtherOverlay->IsPicture())
932  if (!GetGraphicsOverlay(pOtherOverlay->GetID())) return false;
933  }
934  // concat OK
935  return true;
936 }
@ APS_Color
Definition: C4Constants.h:162
@ APS_Graphics
Definition: C4Constants.h:163
@ APS_Name
Definition: C4Constants.h:164
@ APS_Overlay
Definition: C4Constants.h:165
int32_t AllowPictureStack
Definition: C4Def.h:147
int32_t ColorByOwner
Definition: C4Def.h:121
int32_t GetID() const
C4GraphicsOverlay * GetNext() const
class C4GraphicsOverlay * pGfxOverlay
Definition: C4Object.h:169
C4Rect PictureRect
Definition: C4Object.h:150
C4ID id
Definition: C4Object.h:106
uint32_t BlitMode
Definition: C4Object.h:161
uint32_t ColorMod
Definition: C4Object.h:160
class C4GraphicsOverlay * GetGraphicsOverlay(int32_t iForID) const
C4DefGraphics * pGraphics
Definition: C4Object.h:153

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().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ChangeDef()

bool C4Object::ChangeDef ( C4ID  idNew)

Definition at line 518 of file C4Object.cpp.

519 {
520  // Get new definition
521  C4Def *pDef=C4Id2Def(idNew);
522  if (!pDef) return false;
523  // Containment storage
524  C4Object *pContainer=Contained;
525  // Exit container (no Ejection/Departure)
526  if (Contained) Exit(0,0,0,Fix0,Fix0,Fix0,false);
527  // Pre change resets
528  SetAction(nullptr);
529  ResetProperty(&Strings.P[P_Action]); // Enforce ActIdle because SetAction may have failed due to NoOtherAction
530  SetDir(0); // will drop any outdated flipdir
531  if (pSolidMaskData) { delete pSolidMaskData; pSolidMaskData=nullptr; }
532  Def->Count--;
533  // Def change
534  Def=pDef;
536  id=pDef->id;
537  Def->Count++;
538  // new def: Needs to be resorted
539  Unsorted=true;
540  // graphics change
541  pGraphics = &pDef->Graphics;
542  // blit mode adjustment
544  // an object may have newly become an ColorByOwner-object
545  // if it had been ColorByOwner, but is not now, this will be caught in UpdateGraphics()
546  if (!Color && ValidPlr(Owner))
548  if (!Def->Rotateable) { fix_r=rdir=Fix0; }
549  // Reset solid mask
551  HalfVehicleSolidMask=false;
552  // Post change updates
553  UpdateGraphics(true);
554  UpdateMass();
555  UpdateFace(true);
556  SetOCF();
557  // Any effect callbacks to this object might need to reinitialize their target functions
558  // This is ugly, because every effect there is must be updated...
563  for (C4Object *obj : Objects)
564  if (obj->pEffects) obj->pEffects->OnObjectChangedDef(this);
565  // Containment (no Entrance)
566  if (pContainer) Enter(pContainer,false);
567  // Done
568  return true;
569 }
C4Def * C4Id2Def(C4ID id)
Definition: C4DefList.h:84
const C4Real Fix0
Definition: C4Real.h:312
C4GameScriptHost GameScript
@ P_Action
@ P_Prototype
#define C4GFXBLIT_CUSTOM
Definition: C4Surface.h:35
C4Value C4VPropList(C4PropList *p)
Definition: C4Value.h:242
C4Effect * pGlobalEffects
Definition: C4Aul.h:144
Definition: C4Def.h:99
C4DefGraphics Graphics
Definition: C4Def.h:191
C4ID id
Definition: C4Def.h:101
C4TargetRect SolidMask
Definition: C4Def.h:108
int32_t Rotateable
Definition: C4Def.h:119
int32_t BlitMode
Definition: C4Def.h:141
void OnObjectChangedDef(C4PropList *pObj)
Definition: C4Effect.cpp:482
C4Effect * pScenarioEffects
Definition: C4ScriptHost.h:166
bool Enter(C4Object *pTarget, bool fCalls=true, bool fCopyMotion=true, bool *pfRejectCollect=nullptr)
bool HalfVehicleSolidMask
Definition: C4Object.h:149
void UpdateFace(bool bUpdateShape, bool fTemp=false)
void SetDir(int32_t tdir)
C4Real fix_r
Definition: C4Object.h:123
bool Unsorted
Definition: C4Object.h:127
void UpdateGraphics(bool fGraphicsChanged, bool fTemp=false)
void ResetProperty(C4String *k) override
Definition: C4Object.cpp:1328
uint32_t ColorDw
Definition: C4Player.h:89
void SetProperty(C4PropertyName k, const C4Value &to)
Definition: C4PropList.h:124

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, HalfVehicleSolidMask, 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().

Here is the call graph for this function:

◆ CheckPropList()

bool C4PropListNumbered::CheckPropList ( C4PropList pObj)
staticinherited

Definition at line 56 of file C4PropList.cpp.

57 {
58  if (!pObj) return false;
59  C4PropListNumbered * const * p = PropLists.First();
60  while (p)
61  {
62  if (*p == pObj)
63  return true;
64  p = PropLists.Next(p);
65  }
66  return false;
67 }

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

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

Here is the call graph for this function:
Here is the caller graph for this function:

◆ CheckSolidMaskRect()

bool C4Object::CheckSolidMaskRect ( )

Definition at line 287 of file C4ObjectPhysics.cpp.

288 {
289  // Ensure SolidMask rect lies within bounds of SolidMask bitmap in definition
290  CSurface8 *mask = Def->pSolidMask;
291  if (!mask)
292  {
293  // No graphics to set solid in
294  SolidMask.Set(0, 0, 0, 0, 0, 0);
295  return false;
296  }
297  SolidMask.Set(std::max<int32_t>(SolidMask.x,0), std::max<int32_t>(SolidMask.y, 0),
298  std::min<int32_t>(SolidMask.Wdt, mask->Wdt - SolidMask.x), std::min<int32_t>(SolidMask.Hgt, mask->Hgt-SolidMask.y),
300  if (SolidMask.Hgt <= 0)
301  {
302  SolidMask.Wdt = 0;
303  }
304  return SolidMask.Wdt > 0;
305 }
CSurface8 * pSolidMask
Definition: C4Def.h:192
int32_t y
Definition: C4Rect.h:30
int32_t x
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
int32_t tx
Definition: C4Rect.h:79
int32_t ty
Definition: C4Rect.h:79
int Wdt
Definition: CSurface8.h:28
int Hgt
Definition: CSurface8.h:28

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().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ Clear()

void C4Object::Clear ( )

Definition at line 1083 of file C4Object.cpp.

1084 {
1086 
1087  delete pEffects; pEffects = nullptr;
1088  delete pSolidMaskData; pSolidMaskData = nullptr;
1089  delete Menu; Menu = nullptr;
1090  delete MaterialContents; MaterialContents = nullptr;
1091  // clear commands!
1092  C4Command *pCom, *pNext;
1093  for (pCom=Command; pCom; pCom=pNext)
1094  {
1095  pNext=pCom->Next; delete pCom; pCom=pNext;
1096  }
1097  delete pDrawTransform; pDrawTransform = nullptr;
1098  delete pGfxOverlay; pGfxOverlay = nullptr;
1099  delete pMeshInstance; pMeshInstance = nullptr;
1100 }
C4DrawTransform * pDrawTransform
Definition: C4Object.h:135
C4MaterialList * MaterialContents
Definition: C4Object.h:152
StdMeshInstance * pMeshInstance
Definition: C4Object.h:154

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

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

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ClearCommand()

void C4Object::ClearCommand ( C4Command pUntil)

Definition at line 43 of file C4ObjectCommand.cpp.

44 {
45  C4Command *pCom,*pNext;
46  for (pCom=Command; pCom; pCom=pNext)
47  {
48  // Last one to clear
49  if (pCom==pUntil) pNext=nullptr;
50  // Next one to clear after this
51  else pNext=pCom->Next;
52  Command=pCom->Next;
53  if (!pCom->iExec)
54  delete pCom;
55  else
56  pCom->iExec = 2;
57  }
58 }
int32_t iExec
Definition: C4Command.h:91

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

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

Here is the caller graph for this function:

◆ ClearCommands()

void C4Object::ClearCommands ( )

Definition at line 29 of file C4ObjectCommand.cpp.

30 {
31  C4Command *pNext;
32  while (Command)
33  {
34  pNext=Command->Next;
35  if (!Command->iExec)
36  delete Command;
37  else
38  Command->iExec = 2;
39  Command=pNext;
40  }
41 }

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

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

Here is the caller graph for this function:

◆ ClearContentsAndContained()

void C4Object::ClearContentsAndContained ( bool  fDoCalls = true)

Definition at line 240 of file C4ObjectContents.cpp.

241 {
242  // exit contents from container
243  for (C4Object *cobj : Contents)
244  {
245  cobj->Exit(GetX(), GetY(), 0,Fix0,Fix0,Fix0, fDoCalls);
246  }
247  // remove from container *after* contents have been removed!
248  if (Contained) Exit(GetX(), GetY(), 0, Fix0, Fix0, Fix0, fDoCalls);
249 }

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

Referenced by StatusDeactivate().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ClearInfo()

void C4Object::ClearInfo ( C4ObjectInfo pInfo)

Definition at line 1075 of file C4Object.cpp.

1076 {
1077  if (Info==pInfo)
1078  {
1079  Info=nullptr;
1080  }
1081 }

References Info.

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

Here is the caller graph for this function:

◆ ClearNumber()

void C4PropListNumbered::ClearNumber ( )
protectedinherited

Definition at line 141 of file C4PropList.cpp.

142 {
143  // Make proplist invisible during denumeration process
144  if (Number != -1)
145  {
146  PropLists.Remove(this);
147  Number = -1;
148  }
149 }
void Remove(H e)

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

Referenced by C4PropListNumbered::ShelveNumberedPropLists().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ClearNumberedPropLists()

void C4PropListNumbered::ClearNumberedPropLists ( )
staticinherited

Definition at line 113 of file C4PropList.cpp.

114 {
115  // empty all proplists to ensure safe deletion of proplists with circular references
116  // note that this the call to Clear() might delete some prop lists. So it is assumed that
117  // PropLists does not shrink its table as the number of values goes down
118  C4PropListNumbered *const* p_next = PropLists.First(), *const* p;
119  while ((p = p_next))
120  {
121  p_next = PropLists.Next(p);
122  // check *p since it might have been deleted by clearing the previous prop list
123  if (*p) (*p)->Clear();
124  }
125 }
void Clear()
Definition: C4PropList.h:70

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

Referenced by C4Game::Clear().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ClearParticleLists()

void C4Object::ClearParticleLists ( )

Definition at line 205 of file C4Object.cpp.

206 {
207  if (FrontParticles != nullptr)
209  if (BackParticles != nullptr)
211  FrontParticles = BackParticles = nullptr;
212 }
C4ParticleSystem Particles
void ReleaseParticleList(C4ParticleList *first, C4ParticleList *second=nullptr)

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

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

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ClearPointers()

void C4Object::ClearPointers ( C4Object ptr)

Definition at line 816 of file C4Object.cpp.

817 {
818  // mesh attachments and animation nodes
820  // effects
821  if (pEffects) pEffects->ClearPointers(pObj);
822  // contents/contained: although normally not necessery because it's done in AssignRemoval and StatusDeactivate,
823  // it is also required during game destruction (because ClearPointers might do script callbacks)
824  // Perform silent exit to avoid additional callbacks
825  if (Contained == pObj)
826  {
827  Contained->Contents.Remove(this);
828  Contained = nullptr;
829  }
830  Contents.Remove(pObj);
831  // Action targets
832  if (Action.Target==pObj) Action.Target=nullptr;
833  if (Action.Target2==pObj) Action.Target2=nullptr;
834  // Commands
835  C4Command *cCom;
836  for (cCom=Command; cCom; cCom=cCom->Next)
837  cCom->ClearPointers(pObj);
838  // Menu
839  if (Menu) Menu->ClearPointers(pObj);
840  // Layer
841  if (Layer==pObj) Layer=nullptr;
842  // gfx overlays
843  if (pGfxOverlay)
844  {
845  C4GraphicsOverlay *pNextGfxOvrl = pGfxOverlay, *pGfxOvrl;
846  while ((pGfxOvrl = pNextGfxOvrl))
847  {
848  pNextGfxOvrl = pGfxOvrl->GetNext();
849  if (pGfxOvrl->GetOverlayObject() == pObj)
850  // overlay relying on deleted object: Delete!
851  RemoveGraphicsOverlay(pGfxOvrl->GetID());
852  }
853  }
854 }
C4ObjectPtr Target2
Definition: C4Object.h:87
C4ObjectPtr Target
Definition: C4Object.h:87
void ClearPointers(C4Object *pObj)
Definition: C4Command.cpp:1288
void ClearPointers(C4PropList *pObj)
Definition: C4Effect.cpp:191
bool RemoveGraphicsOverlay(int32_t iOverlayID)
C4ObjectPtr Layer
Definition: C4Object.h:134
C4Action Action
Definition: C4Object.h:145
void ClearPointers(C4Object *pObj)
void ClearPointers(class C4Object *pObj)
Definition: StdMesh.cpp:1686

References Action, C4Command::ClearPointers(), C4ObjectMenu::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(), and C4ObjectList::ClearPointers().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ClearRefs()

void C4PropList::ClearRefs ( )
inlineprotectedinherited

Definition at line 160 of file C4PropList.h.

160 { for( C4Value * ref: RefSet{Refs}) ref->Set0(); assert(Refs.empty()); }

Referenced by AssignRemoval().

Here is the caller graph for this function:

◆ ClearShelve()

void C4PropListNumbered::ClearShelve ( )
staticinherited

Definition at line 107 of file C4PropList.cpp.

108 {
109  // cleanup shelve - used in game clear, un unsuccessful section load, etc.
110  ShelvedPropLists.clear();
111 }
static std::vector< C4PropListNumbered * > ShelvedPropLists
Definition: C4PropList.h:242

References C4PropListNumbered::ShelvedPropLists.

Referenced by C4Game::Clear().

Here is the caller graph for this function:

◆ CloseMenu()

bool C4Object::CloseMenu ( bool  fForce)

Definition at line 151 of file C4ObjectMenuLogic.cpp.

152 {
153  if (Menu)
154  {
155  if (Menu->IsActive()) if (!Menu->TryClose(fForce, false)) return false;
156  if (!Menu->IsCloseQuerying()) { delete Menu; Menu=nullptr; } // protect menu deletion from recursive menu operation calls
157  }
158  return true;
159 }
bool IsCloseQuerying() const
Definition: C4ObjectMenu.h:74

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

Referenced by C4ObjectList::CloseMenus(), Enter(), Exit(), ObjectComUnGrab(), SetCommand(), and SyncClearance().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ Collect()

bool C4Object::Collect ( C4Object pObj)

Definition at line 162 of file C4ObjectContents.cpp.

163 {
164  // Object enter container
165  bool fRejectCollect;
166  if (!pObj->Enter(this, true, false, &fRejectCollect))
167  return false;
168  // Cancel attach (hacky)
169  ObjectComCancelAttach(pObj);
170  // Container Collection call
172  // Object Hit call
173  if (pObj->Status && pObj->OCF & OCF_HitSpeed1) pObj->Call(PSF_Hit);
174  if (pObj->Status && pObj->OCF & OCF_HitSpeed2) pObj->Call(PSF_Hit2);
175  if (pObj->Status && pObj->OCF & OCF_HitSpeed3) pObj->Call(PSF_Hit3);
176  // post-copy the motion of the new container
177  if (pObj->Contained == this) pObj->CopyMotion(this);
178  // done, success
179  return true;
180 }
const uint32_t OCF_HitSpeed1
Definition: C4Constants.h:84
const uint32_t OCF_HitSpeed3
Definition: C4Constants.h:92
const uint32_t OCF_HitSpeed2
Definition: C4Constants.h:91
#define PSF_Hit
Definition: C4GameScript.h:49
#define PSF_Hit2
Definition: C4GameScript.h:50
#define PSF_Hit3
Definition: C4GameScript.h:51
#define PSF_Collection
Definition: C4GameScript.h:56
bool ObjectComCancelAttach(C4Object *cObj)
void CopyMotion(C4Object *from)
Definition: C4Movement.cpp:653

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().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ CompileFunc()

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

Definition at line 856 of file C4Object.cpp.

857 {
858  bool deserializing = pComp->isDeserializer();
859  if (deserializing)
860  Clear();
861 
862  // Compile ID, search definition
863  pComp->Value(mkNamingAdapt(id, "id", C4ID::None ));
864  if (deserializing)
865  {
866  Def = ::Definitions.ID2Def(id);
867  if (!Def)
868  { pComp->excNotFound(LoadResStr("IDS_PRC_UNDEFINEDOBJECT"),id.ToString()); return; }
869  }
870 
871  pComp->Value(mkNamingAdapt( mkParAdapt(static_cast<C4PropListNumbered&>(*this), numbers), "Properties"));
872  pComp->Value(mkNamingAdapt( Status, "Status", 1 ));
873  if (Info) nInfo = Info->Name; else nInfo.Clear();
874  pComp->Value(mkNamingAdapt( toC4CStrBuf(nInfo), "Info", "" ));
875  pComp->Value(mkNamingAdapt( Owner, "Owner", NO_OWNER ));
876  pComp->Value(mkNamingAdapt( Controller, "Controller", NO_OWNER ));
877  pComp->Value(mkNamingAdapt( LastEnergyLossCausePlayer, "LastEngLossPlr", NO_OWNER ));
878  pComp->Value(mkNamingAdapt( Category, "Category", 0 ));
879  pComp->Value(mkNamingAdapt( Plane, "Plane", 0 ));
880 
881  pComp->Value(mkNamingAdapt( iLastAttachMovementFrame, "LastSolidAtchFrame", -1 ));
882  pComp->Value(mkNamingAdapt( Con, "Size", 0 ));
883  pComp->Value(mkNamingAdapt( OwnMass, "OwnMass", 0 ));
884  pComp->Value(mkNamingAdapt( Mass, "Mass", 0 ));
885  pComp->Value(mkNamingAdapt( Damage, "Damage", 0 ));
886  pComp->Value(mkNamingAdapt( Energy, "Energy", 0 ));
887  pComp->Value(mkNamingAdapt( Alive, "Alive", false ));
888  pComp->Value(mkNamingAdapt( Breath, "Breath", 0 ));
889  pComp->Value(mkNamingAdapt( Color, "Color", 0u ));
890  pComp->Value(mkNamingAdapt( fix_x, "X", Fix0 ));
891  pComp->Value(mkNamingAdapt( fix_y, "Y", Fix0 ));
892  pComp->Value(mkNamingAdapt( fix_r, "R", Fix0 ));
893  pComp->Value(mkNamingAdapt( xdir, "XDir", 0 ));
894  pComp->Value(mkNamingAdapt( ydir, "YDir", 0 ));
895  pComp->Value(mkNamingAdapt( rdir, "RDir", 0 ));
896  pComp->Value(mkParAdapt(Shape, &Def->Shape));
897  pComp->Value(mkNamingAdapt( fOwnVertices, "OwnVertices", false ));
898  pComp->Value(mkNamingAdapt( SolidMask, "SolidMask", Def->SolidMask ));
899  pComp->Value(mkNamingAdapt( HalfVehicleSolidMask, "HalfVehicleSolidMask", false ));
900  pComp->Value(mkNamingAdapt( PictureRect, "Picture" ));
901  pComp->Value(mkNamingAdapt( Mobile, "Mobile", false ));
902  pComp->Value(mkNamingAdapt( OnFire, "OnFire", false ));
903  pComp->Value(mkNamingAdapt( InLiquid, "InLiquid", false ));
904  pComp->Value(mkNamingAdapt( EntranceStatus, "EntranceStatus", false ));
905  pComp->Value(mkNamingAdapt( OCF, "OCF", 0u ));
906  pComp->Value(Action);
907  pComp->Value(mkNamingAdapt( Contained, "Contained", C4ObjectPtr::Null ));
908  pComp->Value(mkNamingAdapt( Action.Target, "ActionTarget1", C4ObjectPtr::Null ));
909  pComp->Value(mkNamingAdapt( Action.Target2, "ActionTarget2", C4ObjectPtr::Null ));
910  pComp->Value(mkNamingAdapt( mkParAdapt(Contents, numbers), "Contents" ));
911  pComp->Value(mkNamingAdapt( lightRange, "LightRange", 0 ));
912  pComp->Value(mkNamingAdapt( lightFadeoutRange, "LightFadeoutRange", 0 ));
913  pComp->Value(mkNamingAdapt( lightColor, "lightColor", 0xffffffffu ));
914  pComp->Value(mkNamingAdapt( ColorMod, "ColorMod", 0xffffffffu ));
915  pComp->Value(mkNamingAdapt( BlitMode, "BlitMode", 0u ));
916  pComp->Value(mkNamingAdapt( CrewDisabled, "CrewDisabled", false ));
917  pComp->Value(mkNamingAdapt( Layer, "Layer", C4ObjectPtr::Null ));
918  pComp->Value(mkNamingAdapt( C4DefGraphicsAdapt(pGraphics), "Graphics", &Def->Graphics ));
919  pComp->Value(mkNamingPtrAdapt( pDrawTransform, "DrawTransform" ));
920  pComp->Value(mkParAdapt(mkNamingPtrAdapt( pEffects, "Effects" ), this, numbers));
921  pComp->Value(mkNamingAdapt( C4GraphicsOverlayListAdapt(pGfxOverlay),"GfxOverlay", (C4GraphicsOverlay *)nullptr));
922 
923  // Serialize mesh instance if we have a mesh graphics
925  {
926  if(pComp->isDeserializer())
927  {
928  assert(!pMeshInstance);
929  pMeshInstance = new StdMeshInstance(*pGraphics->Mesh, Def->GrowthType ? 1.0f : static_cast<float>(Con)/static_cast<float>(FullCon));
930  }
931 
933 
934  // Does not work because unanimated meshes without attached meshes
935  // do not even write a [Mesh] header so this does not create a mesh instance in that case
936 /* pComp->Value(mkNamingContextPtrAdapt( pMeshInstance, *pGraphics->Mesh, "Mesh"));
937  if(!pMeshInstance)
938  pComp->excCorrupt("Mesh graphics without mesh instance");*/
939  }
940 
941  // TODO: Animations / attached meshes
942 
943  // Commands
944  if (pComp->FollowName("Commands"))
945  {
946  if (deserializing)
947  {
948  C4Command *pCmd = nullptr;
949  for (int i = 1; ; i++)
950  {
951  // Every command has its own naming environment
952  StdStrBuf Naming = FormatString("Command%d", i);
953  pComp->Value(mkParAdapt(mkNamingPtrAdapt(pCmd ? pCmd->Next : Command, Naming.getData()), numbers));
954  // Last command?
955  pCmd = (pCmd ? pCmd->Next : Command);
956  if (!pCmd)
957  break;
958  pCmd->cObj = this;
959  }
960  }
961  else
962  {
963  C4Command *pCmd = Command;
964  for (int i = 1; pCmd; i++, pCmd = pCmd->Next)
965  {
966  StdStrBuf Naming = FormatString("Command%d", i);
967  pComp->Value(mkNamingAdapt(mkParAdapt(*pCmd, numbers), Naming.getData()));
968  }
969  }
970  }
971 
972  // Compiling? Do initialization.
973  if (deserializing)
974  {
975  // add to def count
976  Def->Count++;
977 
978 
979  // Set action (override running data)
980  /* FIXME
981  int32_t iTime=Action.Time;
982  int32_t iPhase=Action.Phase;
983  int32_t iPhaseDelay=Action.PhaseDelay;
984  if (SetActionByName(Action.pActionDef->GetName(),0,0,false))
985  {
986  Action.Time=iTime;
987  Action.Phase=iPhase; // No checking for valid phase
988  Action.PhaseDelay=iPhaseDelay;
989  }*/
990 
991  if (pMeshInstance)
992  {
993  // Set Action animation by slot 0
996  }
997 
998  // blit mode not assigned? use definition default then
999  if (!BlitMode) BlitMode = Def->BlitMode;
1000 
1001  // object needs to be resorted? May happen if there's unsorted objects in savegame
1002  if (Unsorted) Game.fResortAnyObject = true;
1003  }
1004 
1005 }
const int32_t FullCon
Definition: C4Constants.h:181
const int NO_OWNER
Definition: C4Constants.h:137
C4DefList Definitions
Definition: C4Globals.cpp:49
const StdMeshInstance::AttachedMesh::DenumeratorFactoryFunc C4MeshDenumeratorFactory
StdPtrAdapt< T > mkNamingPtrAdapt(T *&rpObj, const char *szNaming)
Definition: StdAdaptors.h:636
StdParameterAdapt< T, P > mkParAdapt(T &&rObj, P &&rPar)
Definition: StdAdaptors.h:490
#define toC4CStrBuf(rBuf)
Definition: StdAdaptors.h:25
StdNamingAdapt< T > mkNamingAdapt(T &&rValue, const char *szName)
Definition: StdAdaptors.h:92
StdMeshInstanceAnimationNode * Animation
Definition: C4Object.h:90
C4Object * cObj
Definition: C4Command.h:80
GraphicsType Type
Definition: C4DefGraphics.h:48
int32_t GrowthType
Definition: C4Def.h:111
C4Def * ID2Def(C4ID id)
bool fResortAnyObject
Definition: C4Game.h:139
static const C4ID None
Definition: C4Id.h:39
int32_t OwnMass
Definition: C4Object.h:113
bool OnFire
Definition: C4Object.h:171
bool EntranceStatus
Definition: C4Object.h:130
C4Real ydir
Definition: C4Object.h:124
C4Real fix_y
Definition: C4Object.h:123
C4Real xdir
Definition: C4Object.h:124
C4Real fix_x
Definition: C4Object.h:123
bool CrewDisabled
Definition: C4Object.h:162
int32_t Category
Definition: C4Object.h:111
uint32_t lightColor
Definition: C4Object.h:122
bool Mobile
Definition: C4Object.h:126
int32_t Con
Definition: C4Object.h:172
int32_t Damage
Definition: C4Object.h:114
int32_t Breath
Definition: C4Object.h:116
bool fOwnVertices
Definition: C4Object.h:147
int32_t iLastAttachMovementFrame
Definition: C4Object.h:125
int32_t Energy
Definition: C4Object.h:115
int32_t Mass
Definition: C4Object.h:113
int32_t Plane
Definition: C4Object.h:173
bool InLiquid
Definition: C4Object.h:129
char Name[C4MaxName+1]
Definition: C4InfoCore.h:37
static const C4ObjectPtr Null
Definition: C4ObjectPtr.h:28
void Value(const T &rStruct)
Definition: StdCompiler.h:161
virtual bool FollowName(const char *szName)
Definition: StdCompiler.h:84
void excNotFound(const char *szMessage,...)
Definition: StdCompiler.h:233
virtual bool isDeserializer()
Definition: StdCompiler.h:53
AnimationNode * GetRootAnimationForSlot(int slot)
Definition: StdMesh.cpp:1253
void SetFaceOrderingForClrModulation(uint32_t clrmod)
Definition: StdMesh.cpp:1135
void Clear()
Definition: StdBuf.h:466

References Action, Alive, C4Action::Animation, C4Def::BlitMode, BlitMode, Breath, C4MeshDenumeratorFactory, Category, StdStrBuf::Clear(), 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, HalfVehicleSolidMask, 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.

Here is the call graph for this function:

◆ Contact()

bool C4Object::Contact ( int32_t  cnat)

Definition at line 135 of file C4Movement.cpp.

136 {
138  {
139  return !! Call(FormatString(PSF_Contact, CNATName(iCNAT)).getData());
140  }
141  return false;
142 }
#define PSF_Contact
Definition: C4GameScript.h:69
const char * CNATName(int32_t cnat)
Definition: C4Movement.cpp:121
@ P_ContactCalls
int32_t GetPropertyInt(C4PropertyName k, int32_t default_val=0) const
Definition: C4PropList.cpp:855

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

Referenced by ContactCheck(), and StopAndContact().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ContactAction()

void C4Object::ContactAction ( )

Definition at line 404 of file C4ObjectAction.cpp.

405 {
406  // Take certain action on contact. Evaluate t_contact-CNAT and Procedure.
407 
408  // Determine Procedure
409  C4PropList* pActionDef = GetAction();
410  if (!pActionDef) return;
411  int32_t iProcedure=pActionDef->GetPropertyP(P_Procedure);
412  int32_t fDisabled=pActionDef->GetPropertyInt(P_ObjectDisabled);
413 
414  //------------------------------- Hit Bottom ---------------------------------------------
415  if (t_contact & CNAT_Bottom)
416  switch (iProcedure)
417  {
418  case DFA_FLIGHT:
419  if (ydir < 0) return;
420  // Jump: FlatHit / HardHit / Walk
421  if ((OCF & OCF_HitSpeed4) || fDisabled)
422  if (ObjectActionFlat(this,Action.Dir)) return;
423  if (OCF & OCF_HitSpeed3)
424  if (ObjectActionKneel(this)) return;
425  ObjectActionWalk(this);
426  ydir = 0;
427  return;
428  case DFA_SCALE:
429  // Scale down: stand
431  {
432  ObjectActionStand(this);
433  return;
434  }
435  break;
436  case DFA_DIG:
437  // no special action
438  break;
439  case DFA_SWIM:
440  // Try corner scale out
441  if (!GBackSemiSolid(GetX(),GetY()-1+Def->Float*Con/FullCon-1))
442  if (ObjectActionCornerScale(this)) return;
443  break;
444  }
445 
446  //------------------------------- Hit Ceiling -----------------------------------------
447  if (t_contact & CNAT_Top)
448  switch (iProcedure)
449  {
450  case DFA_WALK:
451  // Walk: Stop
452  ObjectActionStand(this); return;
453  case DFA_SCALE:
454  // Scale: Try hangle, else stop if going upward
456  {
457  if (ObjectActionHangle(this))
458  {
460  return;
461  }
463  }
464  break;
465  case DFA_FLIGHT:
466  // Jump: Try hangle, else bounce off
467  // High Speed Flight: Tumble
468  if ((OCF & OCF_HitSpeed3) || fDisabled)
469  { ObjectActionTumble(this, Action.Dir, xdir, ydir); break; }
470  if (ObjectActionHangle(this)) return;
471  break;
472  case DFA_DIG:
473  // No action
474  break;
475  case DFA_HANGLE:
477  break;
478  }
479 
480  //---------------------------- Hit Left Wall ----------------------------------------
481  if (t_contact & CNAT_Left)
482  {
483  switch (iProcedure)
484  {
485  case DFA_FLIGHT:
486  // High Speed Flight: Tumble
487  if ((OCF & OCF_HitSpeed3) || fDisabled)
488  { ObjectActionTumble(this, DIR_Left, xdir, ydir); break; }
489  // Else
490  else if (!ComDirLike(Action.ComDir, COMD_Right) && ObjectActionScale(this,DIR_Left)) return;
491  break;
492  case DFA_WALK:
493  // Walk: Try scale
495  {
496  if (ObjectActionScale(this,DIR_Left))
497  {
498  ydir = C4REAL100(-1);
499  return;
500  }
501  }
502  // Heading away from solid
504  {
505  // Slide off
506  ObjectActionJump(this,xdir/2,ydir,false);
507  }
508  return;
509  case DFA_SWIM:
510  // Only scale if swimming at the surface
511  if (!GBackSemiSolid(GetX(),GetY()-1+Def->Float*Con/FullCon-1))
512  {
513  // Try scale, only if swimming at the surface.
515  if (ObjectActionScale(this,DIR_Left)) return;
516  // Try corner scale out
517  if (ObjectActionCornerScale(this)) return;
518  }
519  return;
520  case DFA_HANGLE:
521  // Hangle: Try scale
522  if (ObjectActionScale(this,DIR_Left))
523  {
524  ydir = C4REAL100(1);
525  return;
526  }
527  return;
528  case DFA_DIG:
529  // Dig: no action
530  break;
531  }
532  }
533 
534  //------------------------------ Hit Right Wall --------------------------------------
535  if (t_contact & CNAT_Right)
536  {
537  switch (iProcedure)
538  {
539  case DFA_FLIGHT:
540  // High Speed Flight: Tumble
541  if ((OCF & OCF_HitSpeed3) || fDisabled)
542  { ObjectActionTumble(this, DIR_Right, xdir, ydir); break; }
543  // Else Scale
544  else if (!ComDirLike(Action.ComDir, COMD_Left) && ObjectActionScale(this,DIR_Right)) return;
545  break;
546  case DFA_WALK:
547  // Walk: Try scale
549  {
550  if (ObjectActionScale(this,DIR_Right))
551  {
552  ydir = C4REAL100(-1);
553  return;
554  }
555  }
556  // Heading away from solid
558  {
559  // Slide off
560  ObjectActionJump(this,xdir/2,ydir,false);
561  }
562  return;
563  case DFA_SWIM:
564  // Only scale if swimming at the surface
565  if (!GBackSemiSolid(GetX(),GetY()-1+Def->Float*Con/FullCon-1))
566  {
567  // Try scale
569  if (ObjectActionScale(this,DIR_Right)) return;
570  // Try corner scale out
571  if (ObjectActionCornerScale(this)) return;
572  }
573  return;
574  case DFA_HANGLE:
575  // Hangle: Try scale
576  if (ObjectActionScale(this,DIR_Right))
577  {
578  ydir = C4REAL100(1);
579  return;
580  }
581  return;
582  case DFA_DIG:
583  // Dig: no action
584  break;
585  }
586  }
587 
588  //---------------------------- Unresolved Cases ---------------------------------------
589 
590  // Flight stuck
591  if (iProcedure==DFA_FLIGHT)
592  {
593  // Enforce slide free (might slide through tiny holes this way)
594  if (!ydir)
595  {
596  int fAllowDown = !(t_contact & CNAT_Bottom);
597  if (t_contact & CNAT_Right)
598  {
599  ForcePosition(fix_x - 1, fix_y + fAllowDown);
600  xdir=ydir=0;
601  }
602  if (t_contact & CNAT_Left)
603  {
604  ForcePosition(fix_x + 1, fix_y + fAllowDown);
605  xdir=ydir=0;
606  }
607  }
608  if (!xdir)
609  {
610  if (t_contact & CNAT_Top)
611  {
612  ForcePosition(fix_x, fix_y + 1);
613  xdir=ydir=0;
614  }
615  }
616  }
617 }
const BYTE CNAT_Bottom
Definition: C4Constants.h:112
const uint32_t OCF_HitSpeed4
Definition: C4Constants.h:95
const BYTE CNAT_Right
Definition: C4Constants.h:110
const BYTE CNAT_Top
Definition: C4Constants.h:111
const BYTE CNAT_Left
Definition: C4Constants.h:109
bool GBackSemiSolid(int32_t x, int32_t y)
Definition: C4Landscape.h:234
#define COMD_Down
Definition: C4Object.h:55
#define DIR_Right
Definition: C4Object.h:42
#define DIR_Left
Definition: C4Object.h:41
#define COMD_Right
Definition: C4Object.h:53
#define COMD_Left
Definition: C4Object.h:57
#define COMD_Stop
Definition: C4Object.h:50
#define COMD_Up
Definition: C4Object.h:51
bool ObjectActionScale(C4Object *cObj, int32_t dir)
bool ObjectActionWalk(C4Object *cObj)
Definition: C4ObjectCom.cpp:39
bool ObjectActionFlat(C4Object *cObj, int32_t dir)
bool ObjectActionJump(C4Object *cObj, C4Real xdir, C4Real ydir, bool fByCom)
Definition: C4ObjectCom.cpp:50
bool ObjectActionHangle(C4Object *cObj)
bool ObjectActionKneel(C4Object *cObj)
bool ObjectActionTumble(C4Object *cObj, int32_t dir, C4Real xdir, C4Real ydir)
Definition: C4ObjectCom.cpp:88
bool ComDirLike(int32_t iComDir, int32_t iSample)
bool ObjectActionStand(C4Object *cObj)
Definition: C4ObjectCom.cpp:44
bool ObjectActionCornerScale(C4Object *cObj)
C4Real C4REAL100(int x)
Definition: C4Real.h:267
@ DFA_SWIM
@ DFA_HANGLE
@ DFA_WALK
@ DFA_DIG
@ DFA_FLIGHT
@ P_Procedure
@ DFA_SCALE
@ P_ObjectDisabled
int32_t ComDir
Definition: C4Object.h:82
int32_t Dir
Definition: C4Object.h:80
int32_t Float
Definition: C4Def.h:120
C4PropList * GetAction() const
uint32_t t_contact
Definition: C4Object.h:131
void ForcePosition(C4Real target_x, C4Real target_y)
Definition: C4Movement.cpp:667
C4PropertyName GetPropertyP(C4PropertyName k) const
Definition: C4PropList.cpp:824

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().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ContactCheck()

int32_t C4Object::ContactCheck ( int32_t  at_x,
int32_t  at_y,
uint32_t *  border_hack_contacts = nullptr,
bool  collide_halfvehic = false 
)

Definition at line 158 of file C4Movement.cpp.

159 {
160  // Check shape contact at given position
161  Shape.ContactCheck(at_x, at_y, border_hack_contacts, collide_halfvehic);
162 
163  // Store shape contact values in object t_contact
165 
166  // Contact script call for the first contacted cnat
167  if (Shape.ContactCNAT)
168  {
169  for (int32_t ccnat = 0; ccnat < 4; ccnat++) // Left, right, top bottom
170  {
171  // Will stop on first positive return contact call!
172  if ((Shape.ContactCNAT & (1 << ccnat)) && Contact(1 << ccnat))
173  {
174  break;
175  }
176  }
177  }
178 
179  // Return shape contact count
180  return Shape.ContactCount;
181 }
bool Contact(int32_t cnat)
Definition: C4Movement.cpp:135
bool ContactCheck(int32_t cx, int32_t cy, uint32_t *border_hack_contacts=nullptr, bool collide_halfvehic=false)
Definition: C4Shape.cpp:432
int32_t ContactCNAT
Definition: C4Shape.h:48
int32_t ContactCount
Definition: C4Shape.h:49

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

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

Here is the call graph for this function:
Here is the caller graph for this function:

◆ CopyMotion()

void C4Object::CopyMotion ( C4Object from)

Definition at line 653 of file C4Movement.cpp.

654 {
655  // Designed for contained objects, no static
656  if (fix_x != from_object->fix_x || fix_y != from_object->fix_y)
657  {
658  fix_x = from_object->fix_x;
659  fix_y = from_object->fix_y;
660  // Resort into sectors
661  UpdatePos();
662  }
663  xdir = from_object->xdir;
664  ydir = from_object->ydir;
665 }
void UpdatePos()

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

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

Here is the call graph for this function:
Here is the caller graph for this function:

◆ CreateContents()

C4Object * C4Object::CreateContents ( C4PropList PropList)

Definition at line 144 of file C4ObjectContents.cpp.

145 {
146  C4Object *nobj;
147  if (!(nobj=Game.CreateObject(PropList,this,Owner))) return nullptr;
148  if (!nobj->Enter(this)) { nobj->AssignRemoval(); return nullptr; }
149  return nobj;
150 }
C4Object * CreateObject(C4PropList *type, C4Object *creator, 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 controller=NO_OWNER)
Definition: C4Game.cpp:1334
void AssignRemoval(bool exit_contents=false)
Definition: C4Object.cpp:215

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

Referenced by CreateContentsByList().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ CreateContentsByList()

bool C4Object::CreateContentsByList ( C4IDList idlist)

Definition at line 152 of file C4ObjectContents.cpp.

153 {
154  int32_t cnt,cnt2;
155  for (cnt=0; idlist.GetID(cnt); cnt++)
156  for (cnt2=0; cnt2<idlist.GetCount(cnt); cnt2++)
157  if (!CreateContents(C4Id2Def(idlist.GetID(cnt))))
158  return false;
159  return true;
160 }
int32_t GetCount(size_t index) const
Definition: C4IDList.cpp:125
C4ID GetID(size_t index, int32_t *ipCount=nullptr) const
Definition: C4IDList.cpp:103
C4Object * CreateContents(C4PropList *)

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

Referenced by C4Player::PlaceReadyMaterial().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ Default()

void C4Object::Default ( )

Definition at line 50 of file C4Object.cpp.

51 {
52  id=C4ID::None;
53  nInfo.Clear();
54  RemovalDelay=0;
58  Category=0;
59  Con=0;
60  Mass=OwnMass=0;
61  Damage=0;
62  Energy=0;
63  Alive=false;
64  Breath=0;
65  InMat=MNone;
66  Color=0;
67  lightRange=0;
69  lightColor=0xffffffff;
70  fix_x=fix_y=fix_r=0;
71  xdir=ydir=rdir=0;
72  Mobile=false;
73  Unsorted=false;
74  Initializing=false;
75  OnFire=false;
76  InLiquid=false;
77  EntranceStatus=false;
80  t_contact=0;
81  OCF=0;
82  Action.Default();
83  Shape.Default();
84  fOwnVertices=false;
85  Contents.Default();
89  Def=nullptr;
90  Info=nullptr;
91  Command=nullptr;
92  Contained=nullptr;
93  TopFace.Default();
94  Menu=nullptr;
95  MaterialContents=nullptr;
96  Marker=0;
97  ColorMod=0xffffffff;
98  BlitMode=0;
99  CrewDisabled=false;
100  Layer=nullptr;
101  pSolidMaskData=nullptr;
102  pGraphics=nullptr;
103  pMeshInstance=nullptr;
104  pDrawTransform=nullptr;
105  pEffects=nullptr;
106  pGfxOverlay=nullptr;
108 
110 }
const int32_t MNone
Definition: C4Constants.h:177
void Default()
Definition: C4Action.cpp:30
void Default()
Definition: C4Facet.cpp:31
uint32_t Marker
Definition: C4Object.h:133
int32_t Audible
Definition: C4Object.h:119
bool Initializing
Definition: C4Object.h:128
int32_t AudiblePan
Definition: C4Object.h:119
int32_t InMat
Definition: C4Object.h:117
int32_t AudiblePlayer
Definition: C4Object.h:119
C4Facet TopFace
Definition: C4Object.h:140
virtual void Default()
void Default()
Definition: C4Rect.cpp:26
void Default()
Definition: C4Shape.cpp:40
void Default()
Definition: C4Rect.cpp:39

References Action, Alive, Audible, AudiblePan, AudiblePlayer, BlitMode, Breath, Category, StdStrBuf::Clear(), ClearParticleLists(), Color, ColorMod, Command, Con, Contained, Contents, Controller, CrewDisabled, Damage, Def, C4Facet::Default(), C4Rect::Default(), C4TargetRect::Default(), C4Action::Default(), C4ObjectList::Default(), C4Shape::Default(), Energy, EntranceStatus, fix_r, fix_x, fix_y, fOwnVertices, HalfVehicleSolidMask, 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().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ Delete()

virtual bool C4PropList::Delete ( )
inlinevirtualinherited

Reimplemented in C4PropListStaticMember, C4PropListStatic, C4PropListScript, and C4Def.

Definition at line 94 of file C4PropList.h.

94 { return false; }

Referenced by C4AulScriptEngine::Clear(), and C4ScriptHost::DeleteOwnedPropLists().

Here is the caller graph for this function:

◆ Denumerate()

void C4Object::Denumerate ( C4ValueNumbers numbers)
overridevirtual

Reimplemented from C4PropList.

Definition at line 1007 of file C4Object.cpp.

1008 {
1009  C4PropList::Denumerate(numbers);
1010  // Standard enumerated pointers
1015 
1016  // Post-compile object list
1018 
1019  // Commands
1020  for (C4Command *pCom=Command; pCom; pCom=pCom->Next)
1021  pCom->Denumerate(numbers);
1022 
1023  // effects
1024  if (pEffects) pEffects->Denumerate(numbers);
1025 
1026  // gfx overlays
1027  if (pGfxOverlay)
1028  for (C4GraphicsOverlay *pGfxOvrl = pGfxOverlay; pGfxOvrl; pGfxOvrl = pGfxOvrl->GetNext())
1029  pGfxOvrl->DenumeratePointers();
1030 
1031  // mesh instance
1033 }
void Denumerate(C4ValueNumbers *) override
Definition: C4Effect.cpp:176
bool DenumeratePointers()
void DenumeratePointers()
Definition: C4ObjectPtr.cpp:49
virtual void Denumerate(C4ValueNumbers *)
Definition: C4PropList.cpp:321
void DenumeratePointers()
Definition: StdMesh.cpp:1674

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

Referenced by C4ObjectList::Denumerate().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ DirectComContents()

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

Definition at line 206 of file C4ObjectContents.cpp.

207 {
208  // safety
209  if (!pTarget || !pTarget->Status || pTarget->Contained != this) return;
210  // Desired object already at front?
211  if (Contents.GetObject() == pTarget) return;
212  // select object via script?
213  if (fDoCalls)
214  if (Call("~ControlContents", &C4AulParSet(pTarget)))
215  return;
216  // default action
217  if (!(Contents.ShiftContents(pTarget))) return;
218  // Selection sound
219  if (fDoCalls) if (!Contents.GetObject()->Call("~Selection", &C4AulParSet(this))) StartSoundEffect("Clonk::Action::Grab",false,100,this);
220  // update menu with the new item in "put" entry
221  if (Menu && Menu->IsActive() && Menu->IsContextMenu())
222  {
223  Menu->Refill();
224  }
225  // Done
226  return;
227 }
C4SoundInstance * StartSoundEffect(const char *szSndName, bool fLoop, int32_t iVolume, C4Object *pObj, int32_t iCustomFalloffDistance, int32_t iPitch, C4SoundModifier *modifier)
bool Refill()
Definition: C4Menu.cpp:915
bool IsContextMenu()
Definition: C4Menu.h:164
bool ShiftContents(C4Object *new_first)

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

Referenced by ShiftContents().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ DoBreath()

void C4Object::DoBreath ( int32_t  iChange)

Definition at line 622 of file C4Object.cpp.

623 {
624  // Do change
625  iChange = Clamp<int32_t>(iChange, -Breath, GetPropertyInt(P_MaxBreath) - Breath);
626  Breath += iChange;
627  // call to object
628  Call(PSF_BreathChange,&C4AulParSet(iChange));
629 }
#define PSF_BreathChange
Definition: C4GameScript.h:143
@ P_MaxBreath

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

Referenced by ExecLife().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ DoCon()

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

Definition at line 631 of file C4Object.cpp.

632 {
633  C4Real strgt_con_b = fix_y + Shape.GetBottom();
634  bool fWasFull = (Con>=FullCon);
635  int32_t old_con = Con;
636 
637  // Change con
638  if (Def->Oversize)
639  Con=std::max<int32_t>(Con+iChange,0);
640  else
641  Con=Clamp<int32_t>(Con+iChange,0,FullCon);
642 
643  // Update OCF
644  SetOCF();
645 
646  // Mass
647  UpdateMass();
648 
649  // shape and position
650  UpdateShape();
651  // make the bottom-most vertex stay in place
652  if (!grow_from_center)
653  {
654  fix_y = strgt_con_b - Shape.GetBottom();
655  }
656  // Face (except for the shape)
657  UpdateFace(false);
658 
659  // Do a callback on completion change.
660  if (iChange != 0)
662 
663  // Unfullcon
664  if (fWasFull && (Con<FullCon))
665  {
666  // Lose contents
667  if (!Def->IncompleteActivity)
668  {
669  C4Object *cobj;
670  while ((cobj=Contents.GetObject()))
671  if (Contained) cobj->Enter(Contained);
672  else cobj->Exit(cobj->GetX(),cobj->GetY());
673  SetAction(nullptr);
674  }
675  }
676 
677  // Completion
678  if (!fWasFull && (Con>=FullCon))
680 
681  // Con Zero Removal
682  if (Con<=0)
683  AssignRemoval();
684  // Mesh Graphics Update
685  else if(pMeshInstance)
686  pMeshInstance->SetCompletion(Def->GrowthType ? 1.0f : static_cast<float>(Con)/static_cast<float>(FullCon));
687 }
#define PSF_Initialize
Definition: C4GameScript.h:34
#define PSF_OnCompletionChange
Definition: C4GameScript.h:103
int32_t IncompleteActivity
Definition: C4Def.h:128
int32_t Oversize
Definition: C4Def.h:129
Definition: C4Real.h:59
void UpdateShape(bool bUpdateVertices=true)
Definition: C4Object.cpp:327
int GetBottom()
Definition: C4Shape.cpp:575
void SetCompletion(float completion)
Definition: StdMesh.cpp:1152

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().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ DoDamage()

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

Definition at line 571 of file C4Object.cpp.

572 {
573  // non-living: ask effects first
574  if (pEffects && !Alive)
575  {
576  pEffects->DoDamage(iChange, iCause, iCausedBy);
577  if (!iChange) return;
578  }
579  // Change value
580  Damage = std::max<int32_t>( Damage+iChange, 0 );
581  // Engine script call
582  Call(PSF_Damage,&C4AulParSet(iChange, iCause, iCausedBy));
583 }
#define PSF_Damage
Definition: C4GameScript.h:63
void DoDamage(int32_t &riDamage, int32_t iDamageType, int32_t iCausePlr)
Definition: C4Effect.cpp:394

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

Here is the call graph for this function:

◆ DoEnergy()

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

Definition at line 585 of file C4Object.cpp.

586 {
587  if (!fExact)
588  {
589  // Clamp range of change to prevent integer overflow errors
590  // Do not clamp directly to (0...MaxEnergy)-current_energy, because
591  // the change value calculated here may be reduced by effect callbacks
592  int32_t scale = C4MaxPhysical / 100; // iChange 100% = Physical 100000
593  iChange = Clamp<int32_t>(iChange, std::numeric_limits<int32_t>::min()/scale, std::numeric_limits<int32_t>::max()/scale)*scale;
594  }
595  // Was zero?
596  bool fWasZero=(Energy==0);
597  // Mark last damage causing player to trace kills
598  if (iChange < 0) UpdatLastEnergyLossCause(iCausedByPlr);
599  // Living things: ask effects for change first
600  if (pEffects && Alive)
601  pEffects->DoDamage(iChange, iCause, iCausedByPlr);
602  // Do change
603  iChange = Clamp<int32_t>(iChange, -Energy, GetPropertyInt(P_MaxEnergy) - Energy);
604  Energy += iChange;
605  // call to object
606  Call(PSF_EnergyChange,&C4AulParSet(iChange, iCause, iCausedByPlr));
607  // Alive and energy reduced to zero: death
608  if (Alive) if (Energy==0) if (!fWasZero) AssignDeath(false);
609 }
#define PSF_EnergyChange
Definition: C4GameScript.h:142
const int32_t C4MaxPhysical
Definition: C4InfoCore.h:28
@ P_MaxEnergy
void UpdatLastEnergyLossCause(int32_t iNewCausePlr)
Definition: C4Object.cpp:611
void AssignDeath(bool fForced)
Definition: C4Object.cpp:467

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().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ DoExperience()

void C4Object::DoExperience ( int32_t  change)

Definition at line 32 of file C4ObjectRank.cpp.

33 {
34  const int32_t MaxExperience = 100000000;
35 
36  if (!Info) return;
37 
38  Info->Experience=Clamp<int32_t>(Info->Experience+change,0,MaxExperience);
39 
40  // Promotion check
41  if (Info->Experience<MaxExperience)
43  Promote(Info->Rank+1, false, false);
44 }
C4RankSystem DefaultRanks
bool Promote(int32_t torank, bool exception, bool fForceRankName)
int32_t Experience
Definition: C4InfoCore.h:43
int Experience(int iRank)

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

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

Here is the call graph for this function:
Here is the caller graph for this function:

◆ DoMotion()

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

Definition at line 144 of file C4Movement.cpp.

145 {
146  RemoveSolidMask(true);
147  fix_x += distance_x;
148  fix_y += distance_y;
149 }

References fix_x, and fix_y.

Referenced by DoMovement().

Here is the caller graph for this function:

◆ DoMovement()

void C4Object::DoMovement ( )

Definition at line 250 of file C4Movement.cpp.

251 {
252  int contact_bits = 0;
253  bool has_moved = false;
254  bool has_contact = false;
255  bool has_turned = false;
256  bool lost_attachment = false;
257  bool redirected_force_from_ydir_to_rdir = false;
258  // Restrictions
259  if (Def->NoHorizontalMove)
260  {
261  xdir = 0;
262  }
263 
264  // Dig free target area
265  MovementDigFreeTargetArea();
266 
267  // Store previous movement and ocf
268  C4Real old_xdir(xdir);
269  C4Real old_ydir(ydir);
270  uint32_t old_ocf = OCF;
271 
272  // Store new target x and y
273  C4Real new_x = fix_x + xdir;
274  C4Real new_y = fix_y + ydir;
275 
276  // Apply bounds
277  SideBounds(new_x);
278  VerticalBounds(new_y);
279 
280  // Create a heuristic for moving diagonally, according to the initial speed.
281  // Motivation: At high velocities it will make a difference if you move
282  // horizontally at first exclusively (one might argue, that if you move e.g.
283  // 50 pixels horizontally first and then down one pixel it you not make
284  // much of a difference, but it does make a difference...).
285  // Idea: You have a major velocity component, which is the one
286  // with greater absolute value (after taking the boundaries into account).
287  // Instead of moving horizontally first and then vertically, you do
288  // a movement step in the minor velocity direction every n-th step,
289  // and step into major velocity direction the rest of the time.
290  int steps_x = Abs(fixtoi(new_x - fix_x));
291  int steps_y = Abs(fixtoi(new_y - fix_y));
292  int steps_total = steps_x + steps_y;
293  // Divide total steps by lower amount of steps, to find
294  // out when to do a step in the minor velocity component.
295  // Minimum value is 2, which means alternating steps
296  int step_mod;
297  bool prefer_vertical_movement = steps_y > steps_x;
298  if (prefer_vertical_movement)
299  {
300  step_mod = std::max(2, (1 + steps_total) / std::max(1, steps_x));
301  }
302  else
303  {
304  step_mod = std::max(2, (1 + steps_total) / std::max(1, steps_y));
305  }
306 
307 
308  // Move to target
309  int step_counter = 0;
310  do
311  {
312  step_counter = (step_counter + 1) % step_mod;
313 
314  // Set next step target
315  int step_x = 0;
316  int step_y = 0;
317 
318  // Do a step in the major velocity component direction
319  if (step_counter > 0)
320  {
321  if (prefer_vertical_movement)
322  {
323  step_y = Sign(fixtoi(new_y) - GetY());
324  }
325  else
326  {
327  step_x = Sign(fixtoi(new_x) - GetX());
328  }
329  }
330  else // Do a step in the minor velocity component direction
331  {
332  if (prefer_vertical_movement)
333  {
334  step_x = Sign(fixtoi(new_x) - GetX());
335  }
336  else
337  {
338  step_y = Sign(fixtoi(new_y) - GetY());
339  }
340  }
341 
342  if (Action.t_attach) // Attached movement = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
343  {
344  int32_t step_target_x = GetX() + step_x;
345  int32_t step_target_y = GetY() + step_y;
346  // Attachment check
347  if (!Shape.Attach(step_target_x, step_target_y, Action.t_attach))
348  {
349  lost_attachment = true;
350  }
351  else
352  {
353  // Attachment change to step_target_x/step_target_y overrides target
354  if (step_target_x != GetX() + step_x)
355  {
356  xdir = Fix0;
357  new_x = itofix(step_target_x);
358  }
359  if (step_target_y != GetY() + step_y)
360  {
361  ydir = Fix0;
362  new_y = itofix(step_target_y);
363  }
364  }
365  // Contact check & evaluation
366  uint32_t border_hack_contacts = 0;
367  int32_t current_contacts = ContactCheck(step_target_x, step_target_y, &border_hack_contacts);
368  if (current_contacts || border_hack_contacts)
369  {
370  has_contact = true;
371  contact_bits |= border_hack_contacts | t_contact;
372  }
373  if (current_contacts)
374  {
375  // Abort movement
376  if (step_target_x != GetX())
377  {
378  step_target_x = GetX();
379  new_x = fix_x;
380  }
381  if (step_target_y != GetY())
382  {
383  step_target_y = GetY();
384  new_y = fix_y;
385  }
386  }
387  DoMotion(step_target_x - GetX(), step_target_y - GetY());
388  }
389  else // Unattached movement = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
390  {
391  if (step_x != 0)
392  {
393  uint32_t border_hack_contacts = 0;
394  int32_t current_contacts = ContactCheck(GetX() + step_x, GetY(), &border_hack_contacts, false);
395  if (current_contacts || border_hack_contacts)
396  {
397  has_contact = true;
398  contact_bits |= t_contact | border_hack_contacts;
399  }
400  if (current_contacts)
401  {
402  // Abort horizontal movement
403  new_x = fix_x;
404  // Vertical redirection (always), this is important for pushing vehicles over bumps in the landscape
405  RedirectForce(xdir, ydir, -1);
407  // Update direction
408  new_y = fix_y + ydir;
409  VerticalBounds(new_y);
410  }
411  else // Free horizontal movement
412  {
413  DoMotion(step_x, 0);
414  has_moved = true;
415  }
416  }
417  if (step_y != 0)
418  {
419  int32_t current_contacts = ContactCheck(GetX(), GetY() + step_y, nullptr, ydir > 0);
420  if (current_contacts)
421  {
422  has_contact = true;
423  contact_bits |= t_contact;
424  new_y = fix_y;
425  // Vertical contact horizontal friction
427  // Redirection slide or rotate
428  if (!ContactVtxCNAT(this, CNAT_Left))
429  {
430  RedirectForce(ydir, xdir, -1);
431  }
432  else if (!ContactVtxCNAT(this, CNAT_Right))
433  {
434  RedirectForce(ydir, xdir, +1);
435  }
436  else
437  {
438  // Living things are always capable of keeping their rotation
439  if ((OCF & OCF_Rotate) && current_contacts == 1 && !Alive)
440  {
442  redirected_force_from_ydir_to_rdir = true;
443  }
444  ydir = 0;
445  }
446  }
447  else // Free vertical movement
448  {
449  DoMotion(0, step_y);
450  has_moved = true;
451  }
452  }
453  }
454  has_moved = true;
455  }
456  while (fixtoi(new_x) != GetX() || fixtoi(new_y) != GetY());
457 
458  if (fix_x != new_x || fix_y != new_y)
459  {
460  has_moved = true;
461  RemoveSolidMask(true);
462  fix_x = new_x;
463  fix_y = new_y;
464  }
465  // Rotation - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
466  if ((OCF & OCF_Rotate) && !!rdir)
467  {
468  C4Real target_r = fix_r + rdir * 5;
469  // Rotation limit
470  if (Def->Rotateable > 1)
471  {
472  if (target_r > itofix(Def->Rotateable))
473  {
474  target_r = itofix(Def->Rotateable);
475  rdir = 0;
476  }
477  if (target_r < itofix(-Def->Rotateable))
478  {
479  target_r = itofix(-Def->Rotateable);
480  rdir = 0;
481  }
482  }
483  int32_t current_x = GetX();
484  int32_t current_y = GetY();
485  // Move to target
486  while (fixtoi(fix_r) != fixtoi(target_r))
487  {
488  // Save step undos
489  C4Real old_rotation = fix_r;
490  C4Shape old_shape = Shape;
491  // Try next step
492  fix_r += Sign(target_r - fix_r);
493  UpdateShape();
494  // Attached rotation: rotate around attachment pos
495  if (Action.t_attach && !lost_attachment)
496  {
497  // More accurately, attachment should be evaluated by a rotation around the attachment vertex
498  // however, as long as this code is only used for some surfaces adjustment for large vehicles,
499  // it's enough to assume rotation around the center
500  current_x = GetX();
501  current_y = GetY();
502  // Evaluate attachment, but do not bother about attachment loss
503  // that will then be done in next execution cycle
504  Shape.Attach(current_x, current_y, Action.t_attach);
505  }
506  // Check for contact
507  int32_t current_contacts = ContactCheck(current_x, current_y);
508  if (current_contacts) // Contact
509  {
510  has_contact = true;
511  contact_bits |= t_contact;
512  // Undo step and abort movement
513  Shape = old_shape;
514  target_r = fix_r = old_rotation;
515  // Last UpdateShape-call might have changed sector lists!
516  UpdatePos();
517  // Redirect to GetY()
518  if (current_contacts == 1 && !redirected_force_from_ydir_to_rdir)
519  {
520  RedirectForce(rdir, ydir, -1);
521  }
522  // Stop rotation
523  rdir = 0;
524  }
525  else
526  {
527  has_turned = true;
528  if (current_x != GetX() || current_y != GetY())
529  {
530  fix_x = itofix(current_x);
531  fix_y = itofix(current_y);
532  }
533  }
534  }
535  // Circle bounds
536  if (target_r < -FixHalfCircle)
537  {
538  target_r += FixFullCircle;
539  }
540  if (target_r > +FixHalfCircle)
541  {
542  target_r -= FixFullCircle;
543  }
544  fix_r = target_r;
545  }
546  // Reput solid mask if moved by motion
547  if (has_moved || has_turned)
548  {
549  UpdateSolidMask(true);
550  }
551  // Misc checks ===========================================================================================
552  // InLiquid check
553  // this equals C4Object::UpdateLiquid, but the "fNoAttach = false;"-line
554  if (IsInLiquidCheck()) // In Liquid
555  {
556  if (!InLiquid) // Enter liquid
557  {
558  if ((OCF & OCF_HitSpeed2) && (Mass > 3))
559  {
560  Splash();
561  }
562  lost_attachment = false;
563  InLiquid = true;
564  }
565  }
566  else // Out of liquid
567  {
568  if (InLiquid) // Leave liquid
569  {
570  InLiquid = false;
571  }
572  }
573  // Contact Action
574  if (has_contact)
575  {
576  t_contact = contact_bits;
577  ContactAction();
578  }
579  // Attachment Loss Action
580  if (lost_attachment)
581  {
582  NoAttachAction();
583  }
584  // Movement Script Execution
585  if (has_contact)
586  {
587  C4AulParSet pars(fixtoi(old_xdir, 100), fixtoi(old_ydir, 100));
588  if (old_ocf & OCF_HitSpeed1)
589  {
590  Call(PSF_Hit, &pars);
591  }
592  if (old_ocf & OCF_HitSpeed2)
593  {
594  Call(PSF_Hit2, &pars);
595  }
596  if (old_ocf & OCF_HitSpeed3)
597  {
598  Call(PSF_Hit3, &pars);
599  }
600  }
601  // Update graphics to rotation
602  if (has_turned)
603  {
604  UpdateFace(true);
605  }
606  else
607  {
608  // Position has changed?
609  if (has_moved)
610  {
611  UpdatePos();
612  }
613  }
614 }
const uint32_t OCF_Rotate
Definition: C4Constants.h:88
bool ContactVtxCNAT(C4Object *object, BYTE cnat_dir)
Definition: C4Movement.cpp:72
void RedirectForce(C4Real &from, C4Real &to, int32_t tdir)
Definition: C4Movement.cpp:45
const C4Real FixHalfCircle
Definition: C4Movement.cpp:34
void ApplyFriction(C4Real &tval, int32_t percent)
Definition: C4Movement.cpp:52
int32_t ContactVtxWeight(C4Object *object)
Definition: C4Movement.cpp:87
const C4Real FixFullCircle
Definition: C4Movement.cpp:33
int32_t ContactVtxFriction(C4Object *object)
Definition: C4Movement.cpp:109
int fixtoi(const C4Fixed &x)
Definition: C4Real.h:259
int Sign(T val)
Definition: Standard.h:45
int32_t t_attach
Definition: C4Object.h:86
int32_t NoHorizontalMove
Definition: C4Def.h:122
void UpdateSolidMask(bool fRestoreAttachedObjects)
int32_t ContactCheck(int32_t at_x, int32_t at_y, uint32_t *border_hack_contacts=nullptr, bool collide_halfvehic=false)
Definition: C4Movement.cpp:158
void ContactAction()
void NoAttachAction()
bool IsInLiquidCheck() const
void DoMotion(int32_t mx, int32_t my)
Definition: C4Movement.cpp:144
bool Attach(int32_t &cx, int32_t &cy, BYTE cnat_pos)
Definition: C4Shape.cpp:215

References Abs(), Action, Alive, ApplyFriction(), C4Shape::Attach(), C4PropList::Call(), CNAT_Left, CNAT_Right, ContactAction(), ContactCheck(), ContactVtxCNAT(), ContactVtxFriction(), ContactVtxWeight(), Def, DoMotion(), Fix0, fix_r, fix_x, fix_y, FixFullCircle, FixHalfCircle, fixtoi(), GetX(), GetY(), InLiquid, IsInLiquidCheck(), itofix(), Mass, NoAttachAction(), C4Def::NoHorizontalMove, OCF, OCF_HitSpeed1, OCF_HitSpeed2, OCF_HitSpeed3, OCF_Rotate, PSF_Hit, PSF_Hit2, PSF_Hit3, rdir, RedirectForce(), C4Def::Rotateable, Shape, SideBounds(), Sign(), C4Action::t_attach, t_contact, UpdateFace(), UpdatePos(), UpdateShape(), UpdateSolidMask(), VerticalBounds(), xdir, and ydir.

Referenced by ExecMovement().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ DoSelect()

bool C4Object::DoSelect ( )

Definition at line 1186 of file C4Object.cpp.

1187 {
1188  // selection allowed?
1189  if (CrewDisabled) return false;
1190  // do callback
1192  // done
1193  return true;
1194 }
#define PSF_CrewSelection
Definition: C4GameScript.h:86

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

Referenced by C4Player::SetCursor().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ Draw()

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

Definition at line 246 of file C4ObjectGraphics.cpp.

247 {
248 #ifndef USE_CONSOLE
249  C4Facet ccgo;
250 
251  // Status
252  if (!Status || !Def) return;
253 
254  // visible?
255  if (!IsVisible(iByPlayer, !!eDrawMode)) return;
256 
257  // Set up custom uniforms.
258  auto uniform_popper = pDraw->scriptUniform.Push(this);
259 
260  // Line
261  if (Def->Line) { DrawLine(cgo, iByPlayer); return; }
262 
263  // background particles (bounds not checked)
264  if (BackParticles) BackParticles->Draw(cgo, this);
265 
266  // Object output position
267  float newzoom = cgo.Zoom;
268  if (eDrawMode!=ODM_Overlay)
269  {
270  if (!GetDrawPosition(cgo, offX, offY, newzoom)) return;
271  }
272  ZoomDataStackItem zdsi(newzoom);
273 
274  bool fYStretchObject=false;
275  C4PropList* pActionDef = GetAction();
276  if (pActionDef)
277  if (pActionDef->GetPropertyInt(P_FacetTargetStretch))
278  fYStretchObject=true;
279 
280  // Set audibility
281  if (!eDrawMode) SetAudibilityAt(cgo, GetX(), GetY(), iByPlayer);
282 
283  // Output boundary
284  if (!fYStretchObject && !eDrawMode && !(Category & C4D_Parallax))
285  {
286  // For actions with a custom facet set, check against that action facet. Otherwise (or with oversize objects), just check against shape.
287  if (pActionDef && fix_r == Fix0 && !pActionDef->GetPropertyInt(P_FacetBase) && Con <= FullCon && Action.Facet.Wdt)
288  {
289  // active
290  if ( !Inside<float>(offX+Shape.GetX()+Action.FacetX,cgo.X-Action.Facet.Wdt,cgo.X+cgo.Wdt)
291  || (!Inside<float>(offY+Shape.GetY()+Action.FacetY,cgo.Y-Action.Facet.Hgt,cgo.Y+cgo.Hgt)) )
292  {
293  if (FrontParticles && !Contained) FrontParticles->Draw(cgo, this);
294  return;
295  }
296  }
297  else
298  // idle
299  if ( !Inside<float>(offX+Shape.GetX(),cgo.X-Shape.Wdt,cgo.X+cgo.Wdt)
300  || (!Inside<float>(offY+Shape.GetY(),cgo.Y-Shape.Hgt,cgo.Y+cgo.Hgt)) )
301  {
302  if (FrontParticles && !Contained) FrontParticles->Draw(cgo, this);
303  return;
304  }
305  }
306 
307  // ensure correct color is set
309  if (GetGraphics()->Bmp.BitmapClr) GetGraphics()->Bmp.BitmapClr->SetClr(Color);
310 
311  // Debug Display //////////////////////////////////////////////////////////////////////
312  if (::GraphicsSystem.ShowCommand && !eDrawMode)
313  {
314  C4Command *pCom;
315  int32_t ccx=GetX(),ccy=GetY();
316  float offX1, offY1, offX2, offY2, newzoom;
317  char szCommand[200];
318  StdStrBuf Cmds;
319  int32_t iMoveTos=0;
320  for (pCom=Command; pCom; pCom=pCom->Next)
321  {
322  switch (pCom->Command)
323  {
324  case C4CMD_MoveTo:
325  // Angle
326  int32_t iAngle; iAngle=Angle(ccx,ccy,pCom->Tx._getInt(),pCom->Ty); while (iAngle>180) iAngle-=360;
327  // Path
328  if(GetDrawPosition(cgo, ccx, ccy, cgo.Zoom, offX1, offY1, newzoom) &&
329  GetDrawPosition(cgo, pCom->Tx._getInt(), pCom->Ty, cgo.Zoom, offX2, offY2, newzoom))
330  {
331  ZoomDataStackItem zdsi(newzoom);
332  pDraw->DrawLineDw(cgo.Surface,offX1,offY1,offX2,offY2,C4RGB(0xca,0,0));
333  pDraw->DrawFrameDw(cgo.Surface,offX2-1,offY2-1,offX2+1,offY2+1,C4RGB(0xca,0,0));
334  }
335 
336  ccx=pCom->Tx._getInt(); ccy=pCom->Ty;
337  // Message
338  iMoveTos++; szCommand[0]=0;
339  break;
340  case C4CMD_Put:
341  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() : "");
342  break;
343  case C4CMD_Buy: case C4CMD_Sell:
344  sprintf(szCommand,"%s %s at %s",CommandName(pCom->Command),pCom->Data.GetDataString().getData(),pCom->Target ? pCom->Target->GetName() : "closest base");
345  break;
346  case C4CMD_Acquire:
347  sprintf(szCommand,"%s %s",CommandName(pCom->Command),pCom->Data.GetDataString().getData());
348  break;
349  case C4CMD_Call:
350  sprintf(szCommand,"%s %s in %s",CommandName(pCom->Command),pCom->Text->GetCStr(),pCom->Target ? pCom->Target->GetName() : "(null)");
351  break;
352  case C4CMD_None:
353  szCommand[0]=0;
354  break;
355  case C4CMD_Transfer:
356  // Path
357  if(GetDrawPosition(cgo, ccx, ccy, cgo.Zoom, offX1, offY1, newzoom) &&
358  GetDrawPosition(cgo, pCom->Tx._getInt(), pCom->Ty, cgo.Zoom, offX2, offY2, newzoom))
359  {
360  ZoomDataStackItem zdsi(newzoom);
361  pDraw->DrawLineDw(cgo.Surface,offX1,offY1,offX2,offY2,C4RGB(0,0xca,0));
362  pDraw->DrawFrameDw(cgo.Surface,offX2-1,offY2-1,offX2+1,offY2+1,C4RGB(0,0xca,0));
363  }
364 
365  ccx=pCom->Tx._getInt(); ccy=pCom->Ty;
366  // Message
367  sprintf(szCommand,"%s %s",CommandName(pCom->Command),pCom->Target ? pCom->Target->GetName() : "");
368  break;
369  default:
370  sprintf(szCommand,"%s %s",CommandName(pCom->Command),pCom->Target ? pCom->Target->GetName() : "");
371  break;
372  }
373  // Compose command stack message
374  if (szCommand[0])
375  {
376  // End MoveTo stack first
377  if (iMoveTos) { Cmds.AppendChar('|'); Cmds.AppendFormat("%dx MoveTo",iMoveTos); iMoveTos=0; }
378  // Current message
379  Cmds.AppendChar('|');
380  if (pCom->Finished) Cmds.Append("<i>");
381  Cmds.Append(szCommand);
382  if (pCom->Finished) Cmds.Append("</i>");
383  }
384  }
385  // Open MoveTo stack
386  if (iMoveTos) { Cmds.AppendChar('|'); Cmds.AppendFormat("%dx MoveTo",iMoveTos); iMoveTos=0; }
387  // Draw message
388  int32_t cmwdt,cmhgt; ::GraphicsResource.FontRegular.GetTextExtent(Cmds.getData(),cmwdt,cmhgt,true);
390  }
391  // Debug Display ///////////////////////////////////////////////////////////////////////////////
392 
393  // Don't draw (show solidmask)
394  if (::GraphicsSystem.Show8BitSurface != 0)
395  if (SolidMask.Wdt)
396  {
397  // DrawSolidMask(cgo); - no need to draw it, because the 8bit-surface will be shown
398  return;
399  }
400 
401  // Contained check
402  if (Contained && !eDrawMode) return;
403 
404  // Visibility inside FoW
405  const C4FoWRegion* pOldFoW = pDraw->GetFoW();
406  if(pOldFoW && (Category & C4D_IgnoreFoW))
407  pDraw->SetFoW(nullptr);
408 
409  // color modulation (including construction sign...)
410  if (ColorMod != 0xffffffff || BlitMode) if (!eDrawMode) PrepareDrawing();
411 
412  // Not active or rotated: BaseFace only
413  if (!pActionDef)
414  {
415  DrawFace(cgo, offX, offY);
416  }
417 
418  // Active
419  else
420  {
421  // FacetBase
422  if (pActionDef->GetPropertyInt(P_FacetBase) || GetGraphics()->Type != C4DefGraphics::TYPE_Bitmap)
423  DrawFace(cgo, offX, offY, 0, Action.DrawDir);
424 
425  // Special: stretched action facet
427  {
428  if (Action.Target)
430  float(Action.Facet.X),float(Action.Facet.Y),float(Action.Facet.Wdt),float(Action.Facet.Hgt),
431  cgo.Surface,
432  offX + Shape.GetX() + Action.FacetX, offY + Shape.GetY() + Action.FacetY,Action.Facet.Wdt,
434  true);
435  }
436  else if (Action.Facet.Surface)
437  DrawActionFace(cgo, offX, offY);
438  }
439 
440  // end of color modulation
441  if (ColorMod != 0xffffffff || BlitMode) if (!eDrawMode) FinishedDrawing();
442 
443  // draw overlays - after blit mode changes, because overlay gfx set their own
444  if (pGfxOverlay) if (eDrawMode!=ODM_BaseOnly)
445  for (C4GraphicsOverlay *pGfxOvrl = pGfxOverlay; pGfxOvrl; pGfxOvrl = pGfxOvrl->GetNext())
446  if (!pGfxOvrl->IsPicture())
447  pGfxOvrl->Draw(cgo, this, iByPlayer);
448 
449  // local particles in front of the object
450  if (eDrawMode!=ODM_BaseOnly)
451  {
452  if (FrontParticles)
453  FrontParticles->Draw(cgo, this);
454  }
455 
456  // Debug Display ////////////////////////////////////////////////////////////////////////
457  if (::GraphicsSystem.ShowVertices) if (eDrawMode!=ODM_BaseOnly)
458  {
459  int32_t cnt;
460  if (Shape.VtxNum>1)
461  for (cnt=0; cnt<Shape.VtxNum; cnt++)
462  {
463  DrawVertex(cgo,
464  offX+Shape.VtxX[cnt],
465  offY+Shape.VtxY[cnt],
466  (Shape.VtxCNAT[cnt] & CNAT_NoCollision) ? C4RGB(0, 0, 0xff) : (Mobile ? C4RGB(0xff, 0, 0) : C4RGB(0xef, 0xef, 0)),
467  Shape.VtxContactCNAT[cnt]);
468  }
469  }
470 
471  if (::GraphicsSystem.ShowEntrance) if (eDrawMode!=ODM_BaseOnly)
472  {
473  if (OCF & OCF_Entrance)
474  pDraw->DrawFrameDw(cgo.Surface,offX+Def->Entrance.x,
475  offY+Def->Entrance.y,
476  offX+Def->Entrance.x+Def->Entrance.Wdt-1,
477  offY+Def->Entrance.y+Def->Entrance.Hgt-1,
478  C4RGB(0, 0, 0xff));
479  if (OCF & OCF_Collection)
481  offY+Def->Collection.y,
482  offX+Def->Collection.x+Def->Collection.Wdt-1,
483  offY+Def->Collection.y+Def->Collection.Hgt-1,
484  C4RGB(0xca, 0, 0));
485  }
486 
487  if (::GraphicsSystem.ShowAction) if (eDrawMode!=ODM_BaseOnly)
488  {
489  if (pActionDef)
490  {
491  StdStrBuf str;
492  str.Format("%s (%d)",pActionDef->GetName(),Action.Phase);
493  int32_t cmwdt,cmhgt; ::GraphicsResource.FontRegular.GetTextExtent(str.getData(),cmwdt,cmhgt,true);
495  1.0, cgo.Surface, offX, offY + Shape.GetY() - cmhgt,
497  }
498  }
499  // Debug Display ///////////////////////////////////////////////////////////////////////
500 
501  // Restore visibility inside FoW
502  if (pOldFoW) pDraw->SetFoW(pOldFoW);
503 #endif
504 }
const char * CommandName(int32_t iCommand)
Definition: C4Command.cpp:46
@ C4CMD_Acquire
Definition: C4Command.h:48
@ C4CMD_Call
Definition: C4Command.h:51
@ C4CMD_Sell
Definition: C4Command.h:47
@ C4CMD_Transfer
Definition: C4Command.h:44
@ C4CMD_None
Definition: C4Command.h:28
@ C4CMD_MoveTo
Definition: C4Command.h:30
@ C4CMD_Put
Definition: C4Command.h:39
@ C4CMD_Buy
Definition: C4Command.h:46
const uint32_t OCF_Collection
Definition: C4Constants.h:93
const BYTE CNAT_NoCollision
Definition: C4Constants.h:116
const int32_t C4D_IgnoreFoW
Definition: C4Def.h:55
const int32_t C4D_Parallax
Definition: C4Def.h:51
C4Draw * pDraw
Definition: C4Draw.cpp:42
C4GraphicsSystem GraphicsSystem
Definition: C4Globals.cpp:51
C4GraphicsResource GraphicsResource
float fixtof(const C4Fixed &x)
Definition: C4Real.h:257
@ P_FacetTargetStretch
@ P_FacetBase
const int ACenter
Definition: C4Surface.h:41
int32_t Angle(int32_t iX1, int32_t iY1, int32_t iX2, int32_t iY2, int32_t iPrec)
Definition: Standard.cpp:37
#define sprintf
Definition: Standard.h:162
#define C4RGB(r, g, b)
Definition: StdColors.h:26
C4Facet Facet
Definition: C4Object.h:88
int32_t Phase
Definition: C4Object.h:85
int32_t FacetY
Definition: C4Object.h:89
int32_t DrawDir
Definition: C4Object.h:81
int32_t FacetX
Definition: C4Object.h:89
C4Value Data
Definition: C4Command.h:85
int32_t Finished
Definition: C4Command.h:87
C4Value Tx
Definition: C4Command.h:82
C4ObjectPtr Target
Definition: C4Command.h:84
C4ObjectPtr Target2
Definition: C4Command.h:84
int32_t Ty
Definition: C4Command.h:83
int32_t Command
Definition: C4Command.h:81
C4String * Text
Definition: C4Command.h:89
int32_t Line
Definition: C4Def.h:126
C4Rect Collection
Definition: C4Def.h:106
C4Rect Entrance
Definition: C4Def.h:105
void SetFoW(const C4FoWRegion *fow)
Definition: C4Draw.h:193
bool Blit(C4Surface *sfcSource, float fx, float fy, float fwdt, float fhgt, C4Surface *sfcTarget, float tx, float ty, float twdt, float thgt, bool fSrcColKey=false, const C4BltTransform *pTransform=nullptr)
Definition: C4Draw.cpp:301
void DrawFrameDw(C4Surface *sfcDest, int x1, int y1, int x2, int y2, DWORD dwClr, float width=1.0f)
Definition: C4Draw.cpp:635
@ DEFAULT_MESSAGE_COLOR
Definition: C4Draw.h:167
const C4FoWRegion * GetFoW() const
Definition: C4Draw.h:194
void DrawLineDw(C4Surface *sfcTarget, float x1, float y1, float x2, float y2, DWORD dwClr, float width=1.0f)
Definition: C4Draw.cpp:608
C4ScriptUniform scriptUniform
Definition: C4Draw.h:100
bool TextOut(const char *szText, CStdFont &rFont, float fZoom, C4Surface *sfcDest, float iTx, float iTy, DWORD dwFCol=0xffffffff, BYTE byForm=ALeft, bool fDoMarkup=true)
Definition: C4Draw.cpp:561
C4Surface * Surface
Definition: C4Facet.h:117
float Hgt
Definition: C4Facet.h:118
float Wdt
Definition: C4Facet.h:118
float Y
Definition: C4Facet.h:118
float X
Definition: C4Facet.h:118
bool GetDrawPosition(const C4TargetFacet &cgo, float &resultx, float &resulty, float &resultzoom) const
void DrawLine(C4TargetFacet &cgo, int32_t at_player)
void SetAudibilityAt(C4TargetFacet &cgo, int32_t iX, int32_t iY, int32_t player)
void PrepareDrawing() const
bool IsVisible(int32_t iForPlr, bool fAsOverlay) const
void DrawActionFace(C4TargetFacet &cgo, float offX, float offY) const
void FinishedDrawing() const
void DrawFace(C4TargetFacet &cgo, float offX, float offY, int32_t iPhaseX=0, int32_t iPhaseY=0) const
C4DefGraphics * GetGraphics() const
Definition: C4Object.h:339
void Draw(C4TargetFacet cgo, C4Object *obj)
std::unique_ptr< Popper > Push(C4PropList *proplist)
Definition: C4Shader.cpp:757
int32_t VtxCNAT[C4D_MaxVertex]
Definition: C4Shape.h:45
int32_t VtxContactCNAT[C4D_MaxVertex]
Definition: C4Shape.h:51
int32_t VtxNum
Definition: C4Shape.h:42
int32_t VtxY[C4D_MaxVertex]
Definition: C4Shape.h:44
const char * GetCStr() const
Definition: C4StringTable.h:49
float Zoom
Definition: C4Facet.h:165
int32_t _getInt() const
Definition: C4Value.h:122
bool GetTextExtent(const char *szText, int32_t &rsx, int32_t &rsy, bool fCheckMarkup=true)
void AppendFormat(const char *szFmt,...) GNUC_FORMAT_ATTRIBUTE_O
Definition: StdBuf.cpp:190
void AppendChar(char cChar)
Definition: StdBuf.h:588
void Format(const char *szFmt,...) GNUC_FORMAT_ATTRIBUTE_O
Definition: StdBuf.cpp:174

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, 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(), C4Action::Facet, C4Action::FacetX, C4Action::FacetY, C4Command::Finished, FinishedDrawing(), Fix0, fix_r, fix_y, fixtof(), C4GraphicsResource::FontRegular, FrontParticles, FullCon, GetAction(), C4String::GetCStr(), StdStrBuf::getData(), C4Value::GetDataString(), GetDrawPosition(), C4Draw::GetFoW(), GetGraphics(), C4PropList::GetName(), C4GraphicsOverlay::GetNext(), C4PropList::GetPropertyInt(), CStdFont::GetTextExtent(), GetX(), C4Shape::GetX(), GetY(), C4Shape::GetY(), GraphicsResource, GraphicsSystem, C4Facet::Hgt, C4Rect::Hgt, IsVisible(), C4Def::Line, C4Command::Next, ODM_BaseOnly, ODM_Overlay, P_FacetBase, P_FacetTargetStretch, pDraw, pGfxOverlay, PrepareDrawing(), C4ScriptUniform::Push(), C4Draw::scriptUniform, SetAudibilityAt(), C4Draw::SetFoW(), Shape, C4GraphicsSystem::Show8BitSurface, C4GraphicsSystem::ShowCommand, C4GraphicsSystem::ShowVertices, SolidMask, sprintf, C4PropList::Status, C4Facet::Surface, C4Command::Target, C4Action::Target, C4Command::Target2, C4Command::Text, C4Draw::TextOut(), C4Command::Tx, C4Command::Ty, C4DefGraphics::TYPE_Bitmap, C4Shape::VtxNum, C4Facet::Wdt, C4Rect::Wdt, C4Facet::X, C4Facet::Y, and C4TargetFacet::Zoom.

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

Here is the call graph for this function:
Here is the caller graph for this function:

◆ DrawActionFace()

void C4Object::DrawActionFace ( C4TargetFacet cgo,
float  offX,
float  offY 
) const

Definition at line 182 of file C4ObjectGraphics.cpp.

183 {
184  // This should not be called for meshes since Facet has no meaning
185  // for them. Only use DrawFace() with meshes!
186  assert(GetGraphics()->Type == C4DefGraphics::TYPE_Bitmap);
187  C4PropList* pActionDef = GetAction();
188 
189  // Regular action facet
190  const auto swdt = float(Action.Facet.Wdt);
191  const auto shgt = float(Action.Facet.Hgt);
192  int32_t iPhase = Action.Phase;
193  if (pActionDef->GetPropertyInt(P_Reverse)) iPhase = pActionDef->GetPropertyInt(P_Length) - 1 - Action.Phase;
194 
195  // Grow Type Display
196  auto fx = float(Action.Facet.X + swdt * iPhase);
197  auto fy = float(Action.Facet.Y + shgt * Action.DrawDir);
198  auto fwdt = float(swdt);
199  auto fhgt = float(shgt);
200 
201  // draw stretched towards shape center with transform
202  float stretch_factor = static_cast<float>(Con) / FullCon;
203  float tx = (Def->Shape.GetX() + Action.FacetX) * stretch_factor + offX;
204  float ty = (Def->Shape.GetY() + Action.FacetY) * stretch_factor + offY;
205  float twdt = swdt * stretch_factor;
206  float thgt = shgt * stretch_factor;
207 
208  // Construction Type Display
209  if (!Def->GrowthType)
210  {
211  // FIXME
212  if (Con != FullCon)
213  {
214  // incomplete constructions do not show actions
215  DrawFace(cgo, offX, offY);
216  return;
217  }
218  tx = Def->Shape.GetX() + Action.FacetX + offX;
219  twdt = swdt;
220  float offset_from_top = shgt * std::max(FullCon - Con, 0) / FullCon;
221  fy += offset_from_top;
222  fhgt -= offset_from_top;
223  }
224 
225  C4DrawTransform transform;
226  bool transform_active = false;
227  if (pDrawTransform)
228  {
229  transform.SetTransformAt(*pDrawTransform, offX, offY);
230  transform_active = true;
231  }
232 
233  // Meshes aren't rotated via DrawTransform to ensure lighting is applied correctly.
234  if (GetGraphics()->Type != C4DefGraphics::TYPE_Mesh && Def->Rotateable && fix_r != Fix0)
235  {
236  if (pDrawTransform)
237  transform.Rotate(fixtof(fix_r), offX, offY);
238  else
239  transform.SetRotate(fixtof(fix_r), offX, offY);
240  transform_active = true;
241  }
242 
243  DrawFaceImpl(cgo, true, fx, fy, fwdt, fhgt, tx, ty, twdt, thgt, transform_active ? &transform : nullptr);
244 }
@ P_Length
@ P_Reverse
void SetRotate(float iAngle, float fOffX, float fOffY)
void Rotate(float Angle, float fOffX, float fOffY)
void SetTransformAt(C4DrawTransform &rCopy, float iOffX, float iOffY)
Definition: C4Facet.cpp:541
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

References Action, Con, Def, C4Action::DrawDir, DrawFace(), DrawFaceImpl(), C4Action::Facet, C4Action::FacetX, C4Action::FacetY, Fix0, fix_r, fixtof(), FullCon, GetAction(), GetGraphics(), C4PropList::GetPropertyInt(), C4Shape::GetX(), C4Shape::GetY(), C4Def::GrowthType, C4Facet::Hgt, P_Length, P_Reverse, pDrawTransform, C4Action::Phase, C4BltTransform::Rotate(), C4Def::Rotateable, C4BltTransform::SetRotate(), C4DrawTransform::SetTransformAt(), C4Def::Shape, C4DefGraphics::TYPE_Bitmap, C4DefGraphics::TYPE_Mesh, C4Facet::Wdt, C4Facet::X, and C4Facet::Y.

Referenced by Draw().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ DrawFace()

void C4Object::DrawFace ( C4TargetFacet cgo,
float  offX,
float  offY,
int32_t  iPhaseX = 0,
int32_t  iPhaseY = 0 
) const

Definition at line 135 of file C4ObjectGraphics.cpp.

136 {
137  const auto swdt = float(Def->Shape.Wdt);
138  const auto shgt = float(Def->Shape.Hgt);
139  // Grow Type Display
140  auto fx = float(swdt * iPhaseX);
141  auto fy = float(shgt * iPhaseY);
142  auto fwdt = float(swdt);
143  auto fhgt = float(shgt);
144 
145  float stretch_factor = static_cast<float>(Con) / FullCon;
146  float tx = offX + Def->Shape.GetX() * stretch_factor;
147  float ty = offY + Def->Shape.GetY() * stretch_factor;
148  float twdt = swdt * stretch_factor;
149  float thgt = shgt * stretch_factor;
150 
151  // Construction Type Display
152  if (!Def->GrowthType)
153  {
154  tx = offX + Def->Shape.GetX();
155  twdt = swdt;
156 
157  fy += fhgt - thgt;
158  fhgt = thgt;
159  }
160 
161  C4DrawTransform transform;
162  bool transform_active = false;
163  if (pDrawTransform)
164  {
165  transform.SetTransformAt(*pDrawTransform, offX, offY);
166  transform_active = true;
167  }
168 
169  // Meshes aren't rotated via DrawTransform to ensure lighting is applied correctly.
171  {
172  if (pDrawTransform)
173  transform.Rotate(fixtof(fix_r), offX, offY);
174  else
175  transform.SetRotate(fixtof(fix_r), offX, offY);
176  transform_active = true;
177  }
178 
179  DrawFaceImpl(cgo, false, fx, fy, fwdt, fhgt, tx, ty, twdt, thgt, transform_active ? &transform : nullptr);
180 }

References Con, Def, DrawFaceImpl(), Fix0, fix_r, fixtof(), FullCon, GetGraphics(), C4Shape::GetX(), C4Shape::GetY(), C4Def::GrowthType, C4Rect::Hgt, pDrawTransform, C4BltTransform::Rotate(), C4Def::Rotateable, C4BltTransform::SetRotate(), C4DrawTransform::SetTransformAt(), C4Def::Shape, C4DefGraphics::Type, C4DefGraphics::TYPE_Mesh, and C4Rect::Wdt.

Referenced by Draw(), and DrawActionFace().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ DrawFaceImpl()

void C4Object::DrawFaceImpl ( C4TargetFacet cgo,
bool  action,
float  fx,
float  fy,
float  fwdt,
float  fhgt,
float  tx,
float  ty,
float  twdt,
float  thgt,
C4DrawTransform transform 
) const

Definition at line 85 of file C4ObjectGraphics.cpp.

86 {
87  C4Surface* sfc;
88  switch (GetGraphics()->Type)
89  {
91  // no graphics.
92  break;
94  sfc = action ? Action.Facet.Surface : GetGraphics()->GetBitmap(Color);
95 
96  pDraw->Blit(sfc,
97  fx, fy, fwdt, fhgt,
98  cgo.Surface, tx, ty, twdt, thgt,
99  true, transform);
100  break;
102  C4Value value;
104  StdMeshMatrix matrix;
105  if (!C4ValueToMatrix(value, &matrix))
106  matrix = StdMeshMatrix::Identity();
107 
108  if (fix_r != Fix0)
109  {
110  // Rotation should happen around the mesh center after application of any mesh transformation
111  // So translate back by the transformed mesh center before rotation
112  auto mesh_center = pMeshInstance->GetMesh().GetBoundingBox().GetCenter();
113  mesh_center = matrix * mesh_center;
114  matrix = StdMeshMatrix::Translate(-mesh_center.x, -mesh_center.y, -mesh_center.z) * matrix;
115  matrix = StdMeshMatrix::Rotate(fixtof(fix_r) * (M_PI / 180.0f), 0.0f, 0.0f, 1.0f) * matrix;
116  matrix = StdMeshMatrix::Translate(mesh_center.x, mesh_center.y, mesh_center.z) * matrix;
117  }
118 
119  if(twdt != fwdt || thgt != fhgt)
120  {
121  // Also scale Z so that the mesh is not totally distorted and
122  // so that normals halfway keep pointing into sensible directions.
123  // We don't have a better guess so use the geometric mean for Z scale.
124  matrix = StdMeshMatrix::Scale(twdt/fwdt,thgt/fhgt,std::sqrt(twdt*thgt/(fwdt*fhgt))) * matrix;
125  }
126 
127  pDraw->SetMeshTransform(&matrix);
128 
129  pDraw->RenderMesh(*pMeshInstance, cgo.Surface, tx, ty, twdt, thgt, Color, transform);
130  pDraw->SetMeshTransform(nullptr);
131  break;
132  }
133 }
bool C4ValueToMatrix(C4Value &value, StdMeshMatrix *matrix)
@ P_MeshTransformation
C4Surface * GetBitmap(DWORD dwClr=0)
bool RenderMesh(StdMeshInstance &instance, C4Surface *sfcTarget, float tx, float ty, float twdt, float thgt, DWORD dwPlayerColor, C4BltTransform *pTransform)
Definition: C4Draw.cpp:397
void SetMeshTransform(const StdMeshMatrix *Transform)
Definition: C4Draw.h:200
bool GetProperty(C4PropertyName k, C4Value *pResult) const
Definition: C4PropList.h:105
const StdMeshBox & GetBoundingBox() const
Definition: StdMesh.h:206
const StdMesh & GetMesh() const
Definition: StdMesh.h:622
static StdMeshMatrix Identity()
static StdMeshMatrix Rotate(float angle, float rx, float ry, float rz)
static StdMeshMatrix Scale(float sx, float sy, float sz)
static StdMeshMatrix Translate(float dx, float dy, float dz)
StdMeshVector GetCenter() const
Definition: StdMesh.h:149

References Action, C4Draw::Blit(), C4ValueToMatrix(), Color, C4Action::Facet, Fix0, fix_r, fixtof(), C4DefGraphics::GetBitmap(), StdMesh::GetBoundingBox(), StdMeshBox::GetCenter(), GetGraphics(), StdMeshInstance::GetMesh(), C4PropList::GetProperty(), StdMeshMatrix::Identity(), P_MeshTransformation, pDraw, pMeshInstance, C4Draw::RenderMesh(), StdMeshMatrix::Rotate(), StdMeshMatrix::Scale(), C4Draw::SetMeshTransform(), C4Facet::Surface, StdMeshMatrix::Translate(), C4DefGraphics::TYPE_Bitmap, C4DefGraphics::TYPE_Mesh, and C4DefGraphics::TYPE_None.

Referenced by DrawActionFace(), and DrawFace().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ DrawLine()

void C4Object::DrawLine ( C4TargetFacet cgo,
int32_t  at_player 
)

Definition at line 578 of file C4ObjectGraphics.cpp.

579 {
580  // Nothing to draw if the object has less than two vertices
581  if (Shape.VtxNum < 2)
582  return;
583 #ifndef USE_CONSOLE
584  // Audibility
585  SetAudibilityAt(cgo, Shape.VtxX[0], Shape.VtxY[0], at_player);
586  SetAudibilityAt(cgo, Shape.VtxX[Shape.VtxNum - 1], Shape.VtxY[Shape.VtxNum - 1], at_player);
587  // additive mode?
588  PrepareDrawing();
589  // Draw line segments
590  C4Value colorsV; GetProperty(P_LineColors, &colorsV);
591  C4ValueArray *colors = colorsV.getArray();
592  // TODO: Edge color (color1) is currently ignored.
593  int32_t color0 = 0xFFFF00FF;// , color1 = 0xFFFF00FF; // use bright colors so author notices
594  if (colors)
595  {
596  color0 = colors->GetItem(0).getInt();
597  }
598 
599  std::vector<C4BltVertex> vertices;
600  vertices.resize( (Shape.VtxNum - 1) * 2);
601  for (int32_t vtx=0; vtx+1<Shape.VtxNum; vtx++)
602  {
603  DwTo4UB(color0, vertices[2*vtx].color);
604  DwTo4UB(color0, vertices[2*vtx+1].color);
605 
606  vertices[2*vtx].ftx = Shape.VtxX[vtx] + cgo.X - cgo.TargetX;
607  vertices[2*vtx].fty = Shape.VtxY[vtx] + cgo.Y - cgo.TargetY;
608  vertices[2*vtx+1].ftx = Shape.VtxX[vtx+1] + cgo.X - cgo.TargetX;
609  vertices[2*vtx+1].fty = Shape.VtxY[vtx+1] + cgo.Y - cgo.TargetY;
610  }
611 
612  pDraw->PerformMultiLines(cgo.Surface, &vertices[0], vertices.size(), 1.0f, nullptr);
613 
614  // reset blit mode
615  FinishedDrawing();
616 #endif
617 }
void DwTo4UB(DWORD dwClr, unsigned char(&r)[4])
Definition: C4Draw.h:29
@ P_LineColors
virtual void PerformMultiLines(C4Surface *sfcTarget, const C4BltVertex *vertices, unsigned int n_vertices, float width, C4ShaderCall *shader_call)=0
float TargetY
Definition: C4Facet.h:165
float TargetX
Definition: C4Facet.h:165
const C4Value & GetItem(int32_t iElem) const
Definition: C4ValueArray.h:38
C4ValueArray * getArray() const
Definition: C4Value.h:118
int32_t getInt() const
Definition: C4Value.h:112

References DwTo4UB(), FinishedDrawing(), C4Value::getArray(), C4Value::getInt(), C4ValueArray::GetItem(), C4PropList::GetProperty(), P_LineColors, pDraw, C4Draw::PerformMultiLines(), PrepareDrawing(), SetAudibilityAt(), Shape, C4Facet::Surface, C4TargetFacet::TargetX, C4TargetFacet::TargetY, C4Shape::VtxNum, C4Shape::VtxX, C4Shape::VtxY, C4Facet::X, and C4Facet::Y.

Referenced by Draw().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ DrawPicture()

void C4Object::DrawPicture ( C4Facet cgo,
bool  fSelected = false,
C4DrawTransform transform = nullptr 
)

Definition at line 619 of file C4ObjectGraphics.cpp.

620 {
621  // Draw def picture with object color
622  Def->Draw(cgo,fSelected,Color,this,0,0,transform);
623 }

References Color, Def, and C4Def::Draw().

Referenced by C4GraphicsOverlay::Draw(), C4MouseControl::Draw(), C4GameMessage::Draw(), and C4MenuItem::DrawElement().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ DrawSelectMark()

void C4Object::DrawSelectMark ( C4TargetFacet cgo) const

Definition at line 659 of file C4ObjectGraphics.cpp.

660 {
661  // Status
662  if (!Status) return;
663  // No select marks in film playback
664  if (Game.C4S.Head.Film && Game.C4S.Head.Replay) return;
665  // target pos (parallax)
666  float offX, offY, newzoom;
667  GetDrawPosition(cgo, offX, offY, newzoom);
668  // Output boundary
669  if (!Inside<float>(offX, cgo.X, cgo.X + cgo.Wdt)
670  || !Inside<float>(offY, cgo.Y, cgo.Y + cgo.Hgt)) return;
671  // Draw select marks
672  float cox = offX + Shape.GetX() - cgo.X + cgo.X - 2;
673  float coy = offY + Shape.GetY() - cgo.Y + cgo.Y - 2;
674  GfxR->fctSelectMark.Draw(cgo.Surface,cox,coy,0);
675  GfxR->fctSelectMark.Draw(cgo.Surface,cox+Shape.Wdt,coy,1);
676  GfxR->fctSelectMark.Draw(cgo.Surface,cox,coy+Shape.Hgt,2);
677  GfxR->fctSelectMark.Draw(cgo.Surface,cox+Shape.Wdt,coy+Shape.Hgt,3);
678 }
C4Scenario C4S
Definition: C4Game.h:74
bool Replay
Definition: C4Scenario.h:72
int32_t Film
Definition: C4Scenario.h:73
C4SHead Head
Definition: C4Scenario.h:232

References C4Game::C4S, C4SHead::Film, Game, GetDrawPosition(), C4Shape::GetX(), C4Shape::GetY(), GfxR, C4Scenario::Head, C4Facet::Hgt, C4Rect::Hgt, C4SHead::Replay, Shape, C4PropList::Status, C4Facet::Surface, C4Facet::Wdt, C4Rect::Wdt, C4Facet::X, and C4Facet::Y.

Referenced by C4ObjectList::DrawSelectMark().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ DrawSolidMask()

void C4Object::DrawSolidMask ( C4TargetFacet cgo) const

Definition at line 327 of file C4ObjectPhysics.cpp.

328 {
329  if (pSolidMaskData)
330  {
331  pSolidMaskData->Draw(cgo);
332  }
333 }
void Draw(C4TargetFacet &cgo)

References C4SolidMask::Draw(), and pSolidMaskData.

Here is the call graph for this function:

◆ DrawTopFace()

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

Definition at line 506 of file C4ObjectGraphics.cpp.

507 {
508 #ifndef USE_CONSOLE
509  // Status
510  if (!Status || !Def) return;
511  // visible?
512  if (!IsVisible(iByPlayer, eDrawMode==ODM_Overlay)) return;
513  // target pos (parallax)
514  float newzoom = cgo.Zoom;
515  if (eDrawMode!=ODM_Overlay) GetDrawPosition(cgo, offX, offY, newzoom);
516  ZoomDataStackItem zdsi(newzoom);
517  // TopFace
518  if (!(TopFace.Surface || (OCF & OCF_Construct))) return;
519  // Output bounds check
520  if (!Inside<float>(offX, cgo.X - Shape.Wdt, cgo.X + cgo.Wdt)
521  || !Inside<float>(offY, cgo.Y - Shape.Hgt, cgo.Y + cgo.Hgt))
522  return;
523  // Don't draw (show solidmask)
524  if (::GraphicsSystem.Show8BitSurface != 0 && SolidMask.Wdt) return;
525  // Contained
526  if (Contained) if (eDrawMode!=ODM_Overlay) return;
527  // Construction sign
528  if (OCF & OCF_Construct && fix_r == Fix0)
529  if (eDrawMode!=ODM_BaseOnly)
530  {
532  pDraw->Blit(fctConSign.Surface,
533  fctConSign.X, fctConSign.Y,
534  fctConSign.Wdt, fctConSign.Hgt,
535  cgo.Surface,
536  offX + Shape.GetX(), offY + Shape.GetY() + Shape.Hgt - fctConSign.Hgt,
537  fctConSign.Wdt, fctConSign.Hgt, true);
538  }
539  if(TopFace.Surface)
540  {
541  // FacetTopFace: Override TopFace.GetX()/GetY()
542  C4PropList* pActionDef = GetAction();
543  if (pActionDef && pActionDef->GetPropertyInt(P_FacetTopFace))
544  {
545  int32_t iPhase = Action.Phase;
546  if (pActionDef->GetPropertyInt(P_Reverse)) iPhase = pActionDef->GetPropertyInt(P_Length) - 1 - Action.Phase;
547  TopFace.X = pActionDef->GetPropertyInt(P_X) + Def->TopFace.x + pActionDef->GetPropertyInt(P_Wdt) * iPhase;
548  TopFace.Y = pActionDef->GetPropertyInt(P_Y) + Def->TopFace.y + pActionDef->GetPropertyInt(P_Hgt) * Action.DrawDir;
549  }
550  // ensure correct color is set
551  if (GetGraphics()->Bmp.BitmapClr) GetGraphics()->Bmp.BitmapClr->SetClr(Color);
552  // color modulation
553  if (!eDrawMode) PrepareDrawing();
554  // Draw top face bitmap
555  if (Con!=FullCon && Def->GrowthType)
556  // stretched
559  cgo.Surface,
560  offX + Shape.GetX() + float(Def->TopFace.tx * Con) / FullCon, offY + Shape.GetY() + float(Def->TopFace.ty * Con) / FullCon,
561  float(TopFace.Wdt * Con) / FullCon, float(TopFace.Hgt * Con) / FullCon,
562  true, pDrawTransform ? &C4DrawTransform(*pDrawTransform, offX, offY) : nullptr);
563  else
564  // normal
566  TopFace.X,TopFace.Y,
568  cgo.Surface,
569  offX + Shape.GetX() + Def->TopFace.tx, offY + Shape.GetY() + Def->TopFace.ty,
571  true, pDrawTransform ? &C4DrawTransform(*pDrawTransform, offX, offY) : nullptr);
572  }
573  // end of color modulation
574  if (!eDrawMode) FinishedDrawing();
575 #endif
576 }
const uint32_t OCF_Construct
Definition: C4Constants.h:80
@ P_FacetTopFace
@ P_Wdt
@ P_Y
@ P_Hgt
@ P_X
C4TargetRect TopFace
Definition: C4Def.h:109

References Action, C4Draw::Blit(), Color, Con, Contained, Def, C4Action::DrawDir, C4GraphicsResource::fctConstruction, FinishedDrawing(), Fix0, fix_r, FullCon, GetAction(), GetDrawPosition(), GetGraphics(), C4PropList::GetPropertyInt(), C4Shape::GetX(), C4Shape::GetY(), GraphicsResource, GraphicsSystem, C4Def::GrowthType, C4Facet::Hgt, C4Rect::Hgt, IsVisible(), OCF, OCF_Construct, ODM_BaseOnly, ODM_Overlay, P_FacetTopFace, P_Hgt, P_Length, P_Reverse, P_Wdt, P_X, P_Y, pDraw, pDrawTransform, C4Action::Phase, PrepareDrawing(), Shape, C4GraphicsSystem::Show8BitSurface, SolidMask, C4PropList::Status, C4Facet::Surface, C4Def::TopFace, TopFace, C4TargetRect::tx, C4TargetRect::ty, C4Facet::Wdt, C4Rect::Wdt, C4Facet::X, C4Rect::x, C4Facet::Y, C4Rect::y, and C4TargetFacet::Zoom.

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

Here is the call graph for this function:
Here is the caller graph for this function:

◆ end()

Iterator C4PropList::end ( )
inlineinherited

Definition at line 211 of file C4PropList.h.

211 { return Iterator(); }

Referenced by C4PropList::AppendDataString(), C4ParticleProperties::Set(), and C4PropList::ToJSON().

Here is the caller graph for this function:

◆ Enter()

bool C4Object::Enter ( C4Object pTarget,
bool  fCalls = true,
bool  fCopyMotion = true,
bool *  pfRejectCollect = nullptr 
)

Definition at line 68 of file C4ObjectContents.cpp.

69 {
70  // 0. Query entrance and collection
71  // 1. Exit if contained.
72  // 2. Set new container.
73  // 3. Update Contents and mass of the new container.
74  // 4. Call collection for container
75  // 5. Call entrance for object.
76 
77  // No valid target or target is self
78  if (!pTarget || (pTarget==this)) return false;
79  // check if entrance is allowed
80  if (!! Call(PSF_RejectEntrance, &C4AulParSet(pTarget))) return false;
81  // check if we end up in an endless container-recursion
82  for (C4Object *pCnt=pTarget->Contained; pCnt; pCnt=pCnt->Contained)
83  if (pCnt==this) return false;
84  // Check RejectCollect, if desired
85  if (pfRejectCollect)
86  {
87  if (!!pTarget->Call(PSF_RejectCollection,&C4AulParSet(Def, this)))
88  {
89  *pfRejectCollect = true;
90  return false;
91  }
92  *pfRejectCollect = false;
93  }
94  // Exit if contained
95  if (Contained) if (!Exit(GetX(),GetY())) return false;
96  if (Contained || !Status || !pTarget->Status) return false;
97  // Failsafe updates
98  if (Menu)
99  {
100  CloseMenu(true);
101  // CloseMenu might do bad stuff
102  if (Contained || !Status || !pTarget->Status) return false;
103  }
104  SetOCF();
105  // Set container
106  Contained=pTarget;
107  // Enter
109  {
110  Contained=nullptr;
111  return false;
112  }
113  // Assume that the new container controls this object, if it cannot control itself (i.e.: Alive)
114  // So it can be traced back who caused the damage, if a projectile hits its target
115  if (!Alive)
116  Controller = pTarget->Controller;
117  // Misc updates
118  // motion must be copied immediately, so the position will be correct when OCF is set, and
119  // OCF_Available will be set for newly bought items, even if 50/50 is solid in the landscape
120  // however, the motion must be preserved sometimes to keep flags like OCF_HitSpeed upon collection
121  if (fCopyMotion)
122  {
123  // remove any solidmask before copying the motion...
124  UpdateSolidMask(false);
126  }
127  SetOCF();
128  UpdateFace(true);
129  // Update container
131  Contained->SetOCF();
132  // Object list callback (before script callbacks, because script callbacks may exit again)
134  // Collection call
135  if (fCalls) pTarget->Call(PSF_Collection2,&C4AulParSet(this));
136  if (!Contained || !Contained->Status || !pTarget->Status) return true;
137  // Entrance call
138  if (fCalls) Call(PSF_Entrance,&C4AulParSet(Contained));
139  if (!Contained || !Contained->Status || !pTarget->Status) return true;
140  // Success
141  return true;
142 }
#define PSF_Entrance
Definition: C4GameScript.h:59
#define PSF_RejectCollection
Definition: C4GameScript.h:133
#define PSF_RejectEntrance
Definition: C4GameScript.h:132
#define PSF_Collection2
Definition: C4GameScript.h:57
C4ObjectListChangeListener & ObjectListChangeListener
virtual void OnObjectContainerChanged(C4Object *obj, C4Object *old_container, C4Object *new_container)
Definition: C4ObjectList.h:38
virtual bool Add(C4Object *new_obj, SortType sort_type, C4ObjectList *sorted_list=nullptr)

References C4ObjectList::Add(), Alive, C4PropList::Call(), CloseMenu(), Contained, Contents, Controller, CopyMotion(), Def, Exit(), GetX(), GetY(), Menu, ObjectListChangeListener, C4ObjectListChangeListener::OnObjectContainerChanged(), PSF_Collection2, PSF_Entrance, PSF_RejectCollection, PSF_RejectEntrance, SetOCF(), C4PropList::Status, C4ObjectList::stContents, UpdateFace(), UpdateMass(), and UpdateSolidMask().

Referenced by AssignRemoval(), ChangeDef(), Collect(), CreateContents(), DoCon(), C4Command::Enter(), C4Command::Exit(), C4Command::GetTryEnter(), ObjectComPut(), and C4Player::PlaceReadyVehic().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ EnumerateOwnFuncs()

C4String * C4PropList::EnumerateOwnFuncs ( C4String prev = nullptr) const
inherited

Definition at line 928 of file C4PropList.cpp.

929 {
930  const C4Property * p = prev ? Properties.Next(&Properties.Get(prev)) : Properties.First();
931  while (p)
932  {
933  if (p->Value.getFunction())
934  return p->Key;
935  p = Properties.Next(p);
936  }
937  return nullptr;
938 }
C4Value Value
Definition: C4PropList.h:54
C4String * Key
Definition: C4PropList.h:53
C4AulFunc * getFunction() const
Definition: C4Value.h:119

References C4Set< T >::First(), C4Set< T >::Get(), C4Value::getFunction(), C4Property::Key, C4Set< T >::Next(), and C4Property::Value.

Here is the call graph for this function:

◆ ExecAction()

void C4Object::ExecAction ( )

Definition at line 619 of file C4ObjectAction.cpp.

620 {
621  C4Real iTXDir;
622  C4Real lftspeed,tydir;
623  int32_t iTargetX;
624  int32_t iPushRange,iPushDistance;
625 
626  // Standard phase advance
627  int32_t iPhaseAdvance=1;
628 
629  // Upright attachment check
630  if (!Mobile)
631  if (Def->UprightAttach)
632  if (Inside<int32_t>(GetR(),-StableRange,+StableRange))
633  {
635  Mobile=true;
636  }
637 
638  C4PropList* pActionDef = GetAction();
639  // No IncompleteActivity? Reset action if there was one
640  if (!(OCF & OCF_FullCon) && !Def->IncompleteActivity && pActionDef)
641  {
642  SetAction(nullptr);
643  pActionDef = nullptr;
644  }
645 
646  // InLiquidAction check
647  if (InLiquid)
648  if (pActionDef && pActionDef->GetPropertyStr(P_InLiquidAction))
649  {
651  pActionDef = GetAction();
652  }
653 
654  // Idle objects do natural gravity only
655  if (!pActionDef)
656  {
658  if (Mobile) DoGravity(this);
659  return;
660  }
661 
662  C4Real fWalk,fMove;
663 
664  // Action time advance
665  Action.Time++;
666 
667  C4Value Attach;
668  pActionDef->GetProperty(P_Attach, &Attach);
669  if (Attach.GetType() != C4V_Nil)
670  {
671  Action.t_attach = Attach.getInt();
672  }
673  else switch (pActionDef->GetPropertyP(P_Procedure))
674  {
675  case DFA_SCALE:
678  break;
679  case DFA_HANGLE:
681  break;
682  case DFA_WALK:
683  case DFA_KNEEL:
684  case DFA_THROW:
685  case DFA_PUSH:
686  case DFA_PULL:
687  case DFA_DIG:
689  break;
690  default:
692  }
693 
694  // if an object is in controllable state, so it can be assumed that if it dies later because of NO_OWNER's cause,
695  // it has been its own fault and not the fault of the last one who threw a flint on it
696  // do not reset for burning objects to make sure the killer is set correctly if they fall out of the map while burning
697  if (!pActionDef->GetPropertyInt(P_ObjectDisabled) && pActionDef->GetPropertyP(P_Procedure) != DFA_FLIGHT && !OnFire)
699 
700  // Handle Default Action Procedure: evaluates Procedure and Action.ComDir
701  // Update xdir,ydir,Action.Dir,attachment,iPhaseAdvance
702  int32_t dir = Action.Dir;
703  C4Real accel = C4REAL100(pActionDef->GetPropertyInt(P_Accel));
704  C4Real decel = accel;
705  {
706  C4Value decel_val;
707  pActionDef->GetProperty(P_Decel, &decel_val);
708  if (decel_val.GetType() != C4V_Nil)
709  decel = C4REAL100(decel_val.getInt());
710  }
711  C4Real limit = C4REAL100(pActionDef->GetPropertyInt(P_Speed));
712 
713  switch (pActionDef->GetPropertyP(P_Procedure))
714  {
715  // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
716  case DFA_WALK:
717  switch (Action.ComDir)
718  {
719  case COMD_Left: case COMD_UpLeft: case COMD_DownLeft:
720  // breaaak!!!
721  if (dir == DIR_Right)
722  xdir-=decel;
723  else
724  xdir-=accel;
725  if (xdir<-limit) xdir=-limit;
726  break;
727  case COMD_Right: case COMD_UpRight: case COMD_DownRight:
728  if (dir == DIR_Left)
729  xdir+=decel;
730  else
731  xdir+=accel;
732  if (xdir>+limit) xdir=+limit;
733  break;
734  case COMD_Stop: case COMD_Up: case COMD_Down:
735  if (xdir<0) xdir+=decel;
736  if (xdir>0) xdir-=decel;
737  if ((xdir>-decel) && (xdir<+decel)) xdir=0;
738  break;
739  }
740  iPhaseAdvance=0;
741  if (xdir<0)
742  {
743  if (dir != DIR_Left) { SetDir(DIR_Left); xdir = -1; }
744  iPhaseAdvance=-fixtoi(xdir*10);
745  }
746  if (xdir>0)
747  {
748  if (dir != DIR_Right) { SetDir(DIR_Right); xdir = 1; }
749  iPhaseAdvance=+fixtoi(xdir*10);
750  }
751 
752  Mobile=true;
753  // object is rotateable? adjust to ground, if in horizontal movement or not attached to the center vertex
755  AdjustWalkRotation(20, 20, 100);
756  else
757  rdir=0;
758  break;
759  // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
760  case DFA_KNEEL:
761  ydir=0;
762  Mobile=true;
763  break;
764  // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
765  case DFA_SCALE:
766  {
767  int ComDir = Action.ComDir;
768  if (Shape.CheckScaleToWalk(GetX(), GetY()))
769  {
770  ObjectActionWalk(this);
771  return;
772  }
773  if ((Action.Dir == DIR_Left && ComDir == COMD_Left) || (Action.Dir == DIR_Right && ComDir == COMD_Right))
774  {
775  ComDir = COMD_Up;
776  }
777  switch (ComDir)
778  {
779  case COMD_Up: case COMD_UpRight: case COMD_UpLeft:
780  if (ydir > 0) ydir -= decel;
781  else ydir -= accel;
782  if (ydir < -limit) ydir = -limit;
783  break;
784  case COMD_Down: case COMD_DownRight: case COMD_DownLeft:
785  if (ydir < 0) ydir += decel;
786  else ydir += accel;
787  if (ydir > +limit) ydir = +limit;
788  break;
789  case COMD_Left: case COMD_Right: case COMD_Stop:
790  if (ydir < 0) ydir += decel;
791  if (ydir > 0) ydir -= decel;
792  if ((ydir > -decel) && (ydir < +decel)) ydir = 0;
793  break;
794  }
795  iPhaseAdvance=0;
796  if (ydir<0) iPhaseAdvance=-fixtoi(ydir*14);
797  if (ydir>0) iPhaseAdvance=+fixtoi(ydir*14);
798  xdir=0;
799  Mobile=true;
800  break;
801  }
802  // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
803  case DFA_HANGLE:
804  switch (Action.ComDir)
805  {
806  case COMD_Left: case COMD_UpLeft: case COMD_DownLeft:
807  if (xdir > 0) xdir -= decel;
808  else xdir -= accel;
809  if (xdir < -limit) xdir = -limit;
810  break;
811  case COMD_Right: case COMD_UpRight: case COMD_DownRight:
812  if (xdir < 0) xdir += decel;
813  else xdir += accel;
814  if (xdir > +limit) xdir = +limit;
815  break;
816  case COMD_Up:
817  if (Action.Dir == DIR_Left)
818  if (xdir > 0) xdir -= decel;
819  else xdir -= accel;
820  else
821  if (xdir < 0) xdir += decel;
822  else xdir += accel;
823  if (xdir < -limit) xdir = -limit;
824  if (xdir > +limit) xdir = +limit;
825  break;
826  case COMD_Stop: case COMD_Down:
827  if (xdir < 0) xdir += decel;
828  if (xdir > 0) xdir -= decel;
829  if ((xdir > -decel) && (xdir < +decel)) xdir = 0;
830  break;
831  }
832  iPhaseAdvance=0;
833  if (xdir<0) { iPhaseAdvance=-fixtoi(xdir*10); SetDir(DIR_Left); }
834  if (xdir>0) { iPhaseAdvance=+fixtoi(xdir*10); SetDir(DIR_Right); }
835  ydir=0;
836  Mobile=true;
837  break;
838  // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
839  case DFA_FLIGHT:
840  // Contained: fall out (one try only)
841  if (!::Game.iTick10)
842  if (Contained)
843  {
846  }
847 
848  switch (Action.ComDir)
849  {
850  case COMD_Left: case COMD_UpLeft: case COMD_DownLeft:
851  xdir -= std::max(std::min(limit + xdir, xdir > 0 ? decel : accel), itofix(0));
852  break;
853  case COMD_Right: case COMD_UpRight: case COMD_DownRight:
854  xdir += std::max(std::min(limit - xdir, xdir < 0 ? decel : accel), itofix(0));
855  break;
856  }
857 
858  // Gravity/mobile
859  DoGravity(this);
860  Mobile=true;
861  break;
862  // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
863  case DFA_DIG:
864  {
865  int32_t smpx = GetX(), smpy = GetY();
866  bool fAttachOK = false;
867  if (Action.t_attach & CNAT_Bottom && Shape.Attach(smpx,smpy,CNAT_Bottom)) fAttachOK = true;
868  else if (Action.t_attach & CNAT_Left && Shape.Attach(smpx,smpy,CNAT_Left)) { fAttachOK = true; }
869  else if (Action.t_attach & CNAT_Right && Shape.Attach(smpx,smpy,CNAT_Right)) { fAttachOK = true; }
870  else if (Action.t_attach & CNAT_Top && Shape.Attach(smpx,smpy,CNAT_Top)) fAttachOK = true;
871  if (!fAttachOK)
872  { ObjectComStopDig(this); return; }
873  iPhaseAdvance=fixtoi(itofix(40)*limit);
874 
875  if (xdir < 0) SetDir(DIR_Left); else if (xdir > 0) SetDir(DIR_Right);
877  Mobile=true;
878  break;
879  }
880  // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
881  case DFA_SWIM:
882  // ComDir changes xdir/ydir
883  switch (Action.ComDir)
884  {
885  case COMD_Up: ydir-=accel; break;
886  case COMD_UpRight: ydir-=accel; xdir+=accel; break;
887  case COMD_Right: xdir+=accel; break;
888  case COMD_DownRight:ydir+=accel; xdir+=accel; break;
889  case COMD_Down: ydir+=accel; break;
890  case COMD_DownLeft: ydir+=accel; xdir-=accel; break;
891  case COMD_Left: xdir-=accel; break;
892  case COMD_UpLeft: ydir-=accel; xdir-=accel; break;
893  case COMD_Stop:
894  if (xdir<0) xdir+=decel;
895  if (xdir>0) xdir-=decel;
896  if ((xdir>-decel) && (xdir<+decel)) xdir=0;
897  if (ydir<0) ydir+=decel;
898  if (ydir>0) ydir-=decel;
899  if ((ydir>-decel) && (ydir<+decel)) ydir=0;
900  break;
901  }
902 
903  // Out of liquid check
904  if (!InLiquid)
905  {
906  // Just above liquid: move down
907  if (GBackLiquid(GetX(),GetY()+1+Def->Float*Con/FullCon-1)) ydir=+accel;
908  // Free fall: walk
909  else { ObjectActionWalk(this); return; }
910  }
911 
912  // xdir/ydir bounds, don't apply if COMD_None
913  if (Action.ComDir != COMD_None)
914  {
915  ydir = Clamp(ydir, -limit, limit);
916  xdir = Clamp(xdir, -limit, limit);
917  }
918  // Surface dir bound
919  if (!GBackLiquid(GetX(),GetY()-1+Def->Float*Con/FullCon-1)) if (ydir<0) ydir=0;
920  // Dir, Phase, Attach
921  if (xdir<0) SetDir(DIR_Left);
922  if (xdir>0) SetDir(DIR_Right);
923  iPhaseAdvance=fixtoi(limit*10);
924  Mobile=true;
925 
926  break;
927  // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
928  case DFA_THROW:
929  Mobile=true;
930  break;
931  // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
932  case DFA_PUSH:
933  // No target
934  if (!Action.Target) { StopActionDelayCommand(this); return; }
935  // Inside target
936  if (Contained==Action.Target) { StopActionDelayCommand(this); return; }
937  // Target pushing force
938  bool fStraighten;
939  iTXDir=0; fStraighten=false;
940  switch (Action.ComDir)
941  {
942  case COMD_Left: case COMD_DownLeft: iTXDir=-limit; break;
943  case COMD_UpLeft: fStraighten=true; iTXDir=-limit; break;
944  case COMD_Right: case COMD_DownRight: iTXDir=+limit; break;
945  case COMD_UpRight: fStraighten=true; iTXDir=+limit; break;
946  case COMD_Up: fStraighten=true; break;
947  case COMD_Stop: case COMD_Down: iTXDir=0; break;
948  }
949  // Push object
950  if (!Action.Target->Push(iTXDir,accel,fStraighten))
951  { StopActionDelayCommand(this); return; }
952  // Set target controller
954  // ObjectAction got hold check
955  iPushDistance = std::max(Shape.Wdt/2-8,0);
956  iPushRange = iPushDistance + 10;
957  int32_t sax,say,sawdt,sahgt;
958  Action.Target->GetArea(sax,say,sawdt,sahgt);
959  // Object lost
960  if (!Inside(GetX()-sax,-iPushRange,sawdt-1+iPushRange)
961  || !Inside(GetY()-say,-iPushRange,sahgt-1+iPushRange))
962  {
963  C4Object *prev_target = Action.Target;
964  // Wait command (why, anyway?)
966  // Grab lost action
967  GrabLost(this, prev_target);
968  // Done
969  return;
970  }
971  // Follow object (full xdir reset)
972  // Vertical follow: If object moves out at top, assume it's being pushed upwards and the Clonk must run after it
973  if (GetY()-iPushDistance > say+sahgt && iTXDir) { if (iTXDir>0) sax+=sawdt/2; sawdt/=2; }
974  // Horizontal follow
975  iTargetX=Clamp(GetX(),sax-iPushDistance,sax+sawdt-1+iPushDistance);
976  if (GetX()==iTargetX)
977  {
978  xdir=0;
979  }
980  else
981  {
982  if (GetX()<iTargetX)
983  xdir=+limit;
984  else if (GetX()>iTargetX)
985  xdir=-limit;
986  }
987  // Phase by XDir
988  iPhaseAdvance=0;
989  if (xdir<0) { iPhaseAdvance=-fixtoi(xdir*10); SetDir(DIR_Left); }
990  if (xdir>0) { iPhaseAdvance=+fixtoi(xdir*10); SetDir(DIR_Right); }
991  // No YDir
992  ydir=0;
993  Mobile=true;
994  break;
995  // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
996  case DFA_PULL:
997  // No target
998  if (!Action.Target) { StopActionDelayCommand(this); return; }
999  // Inside target
1000  if (Contained==Action.Target) { StopActionDelayCommand(this); return; }
1001  // Target contained
1002  if (Action.Target->Contained) { StopActionDelayCommand(this); return; }
1003 
1004  int32_t iPullDistance;
1005  int32_t iPullX;
1006 
1007  iPullDistance = Action.Target->Shape.Wdt/2 + Shape.Wdt/2;
1008 
1009  iTargetX=GetX();
1010  if (Action.ComDir==COMD_Right) iTargetX = Action.Target->GetX()+iPullDistance;
1011  if (Action.ComDir==COMD_Left) iTargetX = Action.Target->GetX()-iPullDistance;
1012 
1013  iPullX=Action.Target->GetX();
1014  if (Action.ComDir==COMD_Right) iPullX = GetX()-iPullDistance;
1015  if (Action.ComDir==COMD_Left) iPullX = GetX()+iPullDistance;
1016 
1017  fWalk = limit;
1018 
1019  fMove = 0;
1020  if (Action.ComDir==COMD_Right) fMove = +fWalk;
1021  if (Action.ComDir==COMD_Left) fMove = -fWalk;
1022 
1023  iTXDir = fMove + fWalk * Clamp<int32_t>(iPullX-Action.Target->GetX(),-10,+10) / 10;
1024 
1025  // Push object
1026  if (!Action.Target->Push(iTXDir,accel,false))
1027  { StopActionDelayCommand(this); return; }
1028  // Set target controller
1030 
1031  // Train pulling: com dir transfer
1032  if ( (Action.Target->GetProcedure()==DFA_WALK)
1033  || (Action.Target->GetProcedure()==DFA_PULL) )
1034  {
1036  if (iTXDir<0) Action.Target->Action.ComDir=COMD_Left;
1037  if (iTXDir>0) Action.Target->Action.ComDir=COMD_Right;
1038  }
1039 
1040  // Pulling range
1041  iPushDistance = std::max(Shape.Wdt/2-8,0);
1042  iPushRange = iPushDistance + 20;
1043  Action.Target->GetArea(sax,say,sawdt,sahgt);
1044  // Object lost
1045  if (!Inside(GetX()-sax,-iPushRange,sawdt-1+iPushRange)
1046  || !Inside(GetY()-say,-iPushRange,sahgt-1+iPushRange))
1047  {
1048  // Remember target. Will be lost on changing action.
1049  C4Object *prev_target = Action.Target;
1050  // Wait command (why, anyway?)
1051  StopActionDelayCommand(this);
1052  // Grab lost action
1053  GrabLost(this, prev_target);
1054  // Lose target
1055  Action.Target=nullptr;
1056  // Done
1057  return;
1058  }
1059 
1060  // Move to pulling position
1061  xdir = fMove + fWalk * Clamp<int32_t>(iTargetX-GetX(),-10,+10) / 10;
1062 
1063  // Phase by XDir
1064  iPhaseAdvance=0;
1065  if (xdir<0) { iPhaseAdvance=-fixtoi(xdir*10); SetDir(DIR_Left); }
1066  if (xdir>0) { iPhaseAdvance=+fixtoi(xdir*10); SetDir(DIR_Right); }
1067  // No YDir
1068  ydir=0;
1069  Mobile=true;
1070 
1071  break;
1072  // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
1073  case DFA_LIFT:
1074  // Valid check
1075  if (!Action.Target) { SetAction(nullptr); return; }
1076  // Target lifting force
1077  lftspeed=itofix(2); tydir=0;
1078  switch (Action.ComDir)
1079  {
1080  case COMD_Up: tydir=-lftspeed; break;
1081  case COMD_Stop: tydir=-GravAccel; break;
1082  case COMD_Down: tydir=+lftspeed; break;
1083  }
1084  // Lift object
1085  if (!Action.Target->Lift(tydir,C4REAL100(50)))
1086  { SetAction(nullptr); return; }
1087  // Check LiftTop
1088  if (Def->LiftTop)
1089  if (Action.Target->GetY()<=(GetY()+Def->LiftTop))
1090  if (Action.ComDir==COMD_Up)
1091  Call(PSF_LiftTop);
1092  // General
1093  DoGravity(this);
1094  break;
1095  // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
1096  case DFA_FLOAT:
1097  // ComDir changes xdir/ydir
1098  switch (Action.ComDir)
1099  {
1100  case COMD_Up:
1101  ydir-=accel;
1102  if (xdir<0) xdir+=decel;
1103  if (xdir>0) xdir-=decel;
1104  if ((xdir>-decel) && (xdir<+decel)) xdir=0;
1105  break;
1106  case COMD_UpRight:
1107  ydir-=accel; xdir+=accel; break;
1108  case COMD_Right:
1109  xdir+=accel;
1110  if (ydir<0) ydir+=decel;
1111  if (ydir>0) ydir-=decel;
1112  if ((ydir>-decel) && (ydir<+decel)) ydir=0;
1113  break;
1114  case COMD_DownRight:
1115  ydir+=accel; xdir+=accel; break;
1116  case COMD_Down:
1117  ydir+=accel;
1118  if (xdir<0) xdir+=decel;
1119  if (xdir>0) xdir-=decel;
1120  if ((xdir>-decel) && (xdir<+decel)) xdir=0;
1121  break;
1122  case COMD_DownLeft:
1123  ydir+=accel; xdir-=accel; break;
1124  case COMD_Left:
1125  xdir-=accel;
1126  if (ydir<0) ydir+=decel;
1127  if (ydir>0) ydir-=decel;
1128  if ((ydir>-decel) && (ydir<+decel)) ydir=0;
1129  break;
1130  case COMD_UpLeft:
1131  ydir-=accel; xdir-=accel; break;
1132  case COMD_Stop:
1133  if (xdir<0) xdir+=decel;
1134  if (xdir>0) xdir-=decel;
1135  if ((xdir>-decel) && (xdir<+decel)) xdir=0;
1136  if (ydir<0) ydir+=decel;
1137  if (ydir>0) ydir-=decel;
1138  if ((ydir>-decel) && (ydir<+decel)) ydir=0;
1139  break;
1140  }
1141  // xdir/ydir bounds, don't apply if COMD_None
1142  if (Action.ComDir != COMD_None)
1143  {
1144  ydir = Clamp(ydir, -limit, limit);
1145  xdir = Clamp(xdir, -limit, limit);
1146  }
1147 
1148  Mobile=true;
1149  break;
1150  // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
1151  // ATTACH: Force position to target object
1152  // own vertex index is determined by high-order byte of action data
1153  // target vertex index is determined by low-order byte of action data
1154  case DFA_ATTACH:
1155 
1156  // No target
1157  if (!Action.Target)
1158  {
1159  if (Status)
1160  {
1161  SetAction(nullptr);
1163  }
1164  return;
1165  }
1166 
1167  // Target incomplete and no incomplete activity
1168  if (!(Action.Target->OCF & OCF_FullCon))
1170  { SetAction(nullptr); return; }
1171 
1172  // Force containment
1174  {
1175  if (Action.Target->Contained)
1177  else
1178  Exit(GetX(),GetY(),GetR());
1179  }
1180 
1181  // Object might have detached in Enter/Exit call
1182  if (!Action.Target) break;
1183 
1184  // Move position (so objects on solidmask move)
1186  -Shape.VtxX[Action.Data>>8] - fix_x,
1188  -Shape.VtxY[Action.Data>>8] - fix_y);
1189  // must zero motion...
1190  xdir=ydir=0;
1191 
1192  break;
1193  // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
1194  case DFA_CONNECT:
1195  {
1196  bool fBroke=false;
1197  bool fLineChange = false;
1198 
1199  // Line destruction check: Target missing or incomplete
1200  if (!Action.Target || (Action.Target->Con<FullCon)) fBroke=true;
1201  if (!Action.Target2 || (Action.Target2->Con<FullCon)) fBroke=true;
1202  if (fBroke)
1203  {
1205  AssignRemoval();
1206  return;
1207  }
1208 
1209  // Movement by Target
1210  // Connect to attach vertex
1211  C4Value lineAttachV; C4ValueArray *lineAttach;
1212  Action.Target->GetProperty(P_LineAttach, &lineAttachV);
1213  lineAttach = lineAttachV.getArray();
1214  int32_t iConnectX1, iConnectY1;
1215  iConnectX1 = Action.Target->GetX();
1216  iConnectY1 = Action.Target->GetY();
1217  if (lineAttach)
1218  {
1219  iConnectX1 += lineAttach->GetItem(0).getInt();
1220  iConnectY1 += lineAttach->GetItem(1).getInt();
1221  }
1222  if ((iConnectX1!=Shape.VtxX[0]) || (iConnectY1!=Shape.VtxY[0]))
1223  {
1224  // Regular wrapping line
1225  if (Def->LineIntersect == 0)
1226  if (!Shape.LineConnect(iConnectX1,iConnectY1,0,+1,
1227  Shape.VtxX[0],Shape.VtxY[0])) fBroke=true;
1228  // No-intersection line
1229  if (Def->LineIntersect == 1)
1230  { Shape.VtxX[0]=iConnectX1; Shape.VtxY[0]=iConnectY1; }
1231 
1232  fLineChange = true;
1233  }
1234 
1235  // Movement by Target2
1236  // Connect to attach vertex
1237  Action.Target2->GetProperty(P_LineAttach, &lineAttachV);
1238  lineAttach = lineAttachV.getArray();
1239  int32_t iConnectX2, iConnectY2;
1240  iConnectX2 = Action.Target2->GetX();
1241  iConnectY2 = Action.Target2->GetY();
1242  if (lineAttach)
1243  {
1244  iConnectX2 += lineAttach->GetItem(0).getInt();
1245  iConnectY2 += lineAttach->GetItem(1).getInt();
1246  }
1247  if ((iConnectX2!=Shape.VtxX[Shape.VtxNum-1]) || (iConnectY2!=Shape.VtxY[Shape.VtxNum-1]))
1248  {
1249  // Regular wrapping line
1250  if (Def->LineIntersect == 0)
1251  if (!Shape.LineConnect(iConnectX2,iConnectY2,Shape.VtxNum-1,-1,
1252  Shape.VtxX[Shape.VtxNum-1],Shape.VtxY[Shape.VtxNum-1])) fBroke=true;
1253  // No-intersection line
1254  if (Def->LineIntersect == 1)
1255  { Shape.VtxX[Shape.VtxNum-1]=iConnectX2; Shape.VtxY[Shape.VtxNum-1]=iConnectY2; }
1256 
1257  fLineChange = true;
1258  }
1259 
1260  // Line fBroke
1261  if (fBroke)
1262  {
1263  Call(PSF_OnLineBreak,nullptr);
1264  AssignRemoval();
1265  return;
1266  }
1267 
1268  // Reduce line segments
1269  if (!::Game.iTick35)
1271  fLineChange = true;
1272 
1273  // Line change callback
1274  if (fLineChange)
1276  }
1277  break;
1278  // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
1279  default:
1280  // Attach
1281  if (Action.t_attach)
1282  {
1283  xdir = ydir = 0;
1284  Mobile = true;
1285  }
1286  // Free gravity
1287  else
1288  DoGravity(this);
1289  break;
1290  // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
1291  }
1292 
1293  // Phase Advance (zero delay means no phase advance)
1294  if (pActionDef->GetPropertyInt(P_Delay))
1295  {
1296  Action.PhaseDelay+=iPhaseAdvance;
1297  if (Action.PhaseDelay >= pActionDef->GetPropertyInt(P_Delay))
1298  {
1299  // Advance Phase
1300  Action.PhaseDelay=0;
1301  Action.Phase += pActionDef->GetPropertyInt(P_Step);
1302  // Phase call
1303  if (pActionDef->GetPropertyStr(P_PhaseCall))
1304  {
1305  Call(pActionDef->GetPropertyStr(P_PhaseCall)->GetCStr());
1306  }
1307  // Phase end
1308  if (Action.Phase>=pActionDef->GetPropertyInt(P_Length))
1309  {
1310  C4String *next_action = pActionDef->GetPropertyStr(P_NextAction);
1311  // Keep current action if there is no NextAction
1312  if (!next_action)
1313  Action.Phase = 0;
1314  // set new action if it's not Hold
1315  else if (next_action == &Strings.P[P_Hold])
1316  {
1317  Action.Phase = pActionDef->GetPropertyInt(P_Length)-1;
1318  Action.PhaseDelay = pActionDef->GetPropertyInt(P_Delay)-1;
1319  }
1320  else
1321  {
1322  // Set new action
1323  SetActionByName(next_action, nullptr, nullptr, SAC_StartCall | SAC_EndCall);
1324  }
1325  }
1326  }
1327  }
1328 
1329  return;
1330 }
@ C4CMD_Exit
Definition: C4Command.h:32
const uint32_t OCF_FullCon
Definition: C4Constants.h:85
const BYTE CNAT_None
Definition: C4Constants.h:108
#define PSF_OnLineBreak
Definition: C4GameScript.h:76
#define PSF_OnLineChange
Definition: C4GameScript.h:77
#define PSF_LiftTop
Definition: C4GameScript.h:68
#define PSF_AttachTargetLost
Definition: C4GameScript.h:85
bool GBackLiquid(int32_t x, int32_t y)
Definition: C4Landscape.h:239
#define COMD_UpLeft
Definition: C4Object.h:58
#define COMD_DownRight
Definition: C4Object.h:54
#define COMD_DownLeft
Definition: C4Object.h:56
#define COMD_UpRight
Definition: C4Object.h:52
#define COMD_None
Definition: C4Object.h:49
void GrabLost(C4Object *cObj, C4Object *prev_target)
bool ReduceLineSegments(C4Shape &rShape, bool fAlternate)
void StopActionDelayCommand(C4Object *cobj)
void ObjectComStopDig(C4Object *cObj)
const int StableRange
Definition: C4Physics.h:23
#define GravAccel
Definition: C4Physics.h:27
@ DFA_FLOAT
@ P_Accel
@ P_Delay
@ P_Step
@ P_Attach
@ P_NextAction
@ P_Speed
@ DFA_PULL
@ P_Hold
@ DFA_KNEEL
@ P_PhaseCall
@ DFA_LIFT
@ DFA_THROW
@ DFA_ATTACH
@ P_LineAttach
@ DFA_PUSH
@ P_Decel
@ DFA_CONNECT
@ P_InLiquidAction
@ C4V_Nil
Definition: C4Value.h:25
T Clamp(T bval, T lbound, T rbound)
Definition: Standard.h:44
int32_t Data
Definition: C4Object.h:84
int32_t Time
Definition: C4Object.h:83
int32_t PhaseDelay
Definition: C4Object.h:85
int32_t UprightAttach
Definition: C4Def.h:125
int32_t LineIntersect
Definition: C4Def.h:127
int32_t LiftTop
Definition: C4Def.h:123
int32_t iTick2
Definition: C4Game.h:130
int32_t iTick35
Definition: C4Game.h:130
int32_t iTick10
Definition: C4Game.h:130
BYTE GetArea(int32_t &aX, int32_t &aY, int32_t &aWdt, int32_t &aHgt) const
Definition: C4Object.cpp:700
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)
bool AdjustWalkRotation(int32_t iRangeX, int32_t iRangeY, int32_t iSpeed)
int32_t GetProcedure() const
bool Push(C4Real txdir, C4Real dforce, bool fStraighten)
bool Lift(C4Real tydir, C4Real dforce)
void MovePosition(int32_t dx, int32_t dy)
Definition: C4Movement.cpp:675
C4String * GetPropertyStr(C4PropertyName k) const
Definition: C4PropList.cpp:744
int32_t AttachMat
Definition: C4Shape.h:50
bool CheckScaleToWalk(int x, int y)
Definition: C4Shape.cpp:482
bool LineConnect(int32_t tx, int32_t ty, int32_t cvtx, int32_t ld, int32_t oldx, int32_t oldy)
Definition: C4Shape.cpp:295
C4V_Type GetType() const
Definition: C4Value.h:161

References Action, CNAT_None, Def, GetAction(), C4PropList::GetPropertyStr(), GetR(), C4Def::IncompleteActivity, InLiquid, Mobile, OCF, OCF_FullCon, P_InLiquidAction, SetAction(), SetActionByName(), StableRange, C4Action::t_attach, and C4Def::UprightAttach.

Referenced by Execute().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ExecLife()

bool C4Object::ExecLife ( )

Definition at line 354 of file C4Object.cpp.

355 {
356  // Breathing
357  if (!::Game.iTick5)
358  if (Alive && !Def->NoBreath)
359  {
360  // Supply check
361  bool Breathe=false;
362  // Forcefields are breathable.
363  if (GBackMat(GetX(), GetY()+Shape.GetY()/2)==MVehic)
364  { Breathe=true; }
365  else if (GetPropertyInt(P_BreatheWater))
366  { if (GBackMat(GetX(), GetY())==MWater) Breathe=true; }
367  else
368  { if (!GBackSemiSolid(GetX(), GetY()+Shape.GetY()/2)) Breathe=true; }
369  if (Contained) Breathe=true;
370  // No supply
371  if (!Breathe)
372  {
373  // Reduce breath, then energy, bubble
374  if (Breath > 0) DoBreath(-5);
376  }
377  // Supply
378  else
379  {
380  // Take breath
381  int32_t takebreath = GetPropertyInt(P_MaxBreath) - Breath;
382  if (takebreath > 0) DoBreath(takebreath);
383  }
384  }
385 
386  // Corrosion energy loss
387  if (!::Game.iTick10)
388  if (Alive)
389  if (InMat!=MNone)
393 
394  // InMat incineration
395  if (!::Game.iTick10)
396  if (InMat!=MNone)
399  {
401  }
402 
403  // birthday
404  if (!::Game.iTick255)
405  if (Alive)
406  if (Info)
407  {
408  int32_t iPlayingTime = Info->TotalPlayingTime + (Game.Time - Info->InActionTime);
409 
410  int32_t iNewAge = iPlayingTime / 3600 / 5;
411 
412  if (Info->Age != iNewAge && Info->Age)
413  {
414  // message
415  GameMsgObject(FormatString(LoadResStr("IDS_OBJ_BIRTHDAY"),GetName (), Info->TotalPlayingTime / 3600 / 5).getData(),this);
416  StartSoundEffect("UI::Trumpet",false,100,this);
417  }
418 
419  Info->Age = iNewAge;
420 
421 
422  }
423 
424  return true;
425 }
#define C4FxCall_EngAsphyxiation
Definition: C4Effect.h:60
#define C4FxCall_EngCorrosion
Definition: C4Effect.h:61
void GameMsgObject(const char *szText, C4Object *pTarget)
#define PSF_OnInIncendiaryMaterial
Definition: C4GameScript.h:95
int32_t GBackMat(int32_t x, int32_t y)
Definition: C4Landscape.h:219
int32_t MWater
Definition: C4Material.cpp:36
int32_t MVehic
Definition: C4Material.cpp:36
C4MaterialMap MaterialMap
Definition: C4Material.cpp:974
@ P_ContactIncinerate
@ P_BreatheWater
@ P_CorrosionResist
@ P_MaterialIncinerate
int32_t NoBreath
Definition: C4Def.h:142
int32_t iTick255
Definition: C4Game.h:130
int32_t Time
Definition: C4Game.h:132
int32_t iTick5
Definition: C4Game.h:130
int32_t Incendiary
Definition: C4Material.h:107
int32_t Corrosive
Definition: C4Material.h:109
C4Material * Map
Definition: C4Material.h:169
void DoBreath(int32_t iChange)
Definition: C4Object.cpp:622
void DoEnergy(int32_t iChange, bool fExact, int32_t iCause, int32_t iCausedByPlr)
Definition: C4Object.cpp:585
int32_t TotalPlayingTime
Definition: C4InfoCore.h:46
int32_t InActionTime
Definition: C4ObjectInfo.h:36
int32_t GetPropertyBool(C4PropertyName n, bool default_val=false) const
Definition: C4PropList.cpp:841

References C4ObjectInfoCore::Age, Alive, Breath, C4FxCall_EngAsphyxiation, C4FxCall_EngCorrosion, C4PropList::Call(), Contained, C4MaterialCore::Corrosive, Def, DoBreath(), DoEnergy(), FormatString(), Game, GameMsgObject(), GBackMat(), GBackSemiSolid(), StdStrBuf::getData(), C4PropList::GetName(), C4PropList::GetPropertyBool(), C4PropList::GetPropertyInt(), GetX(), GetY(), C4Shape::GetY(), C4ObjectInfo::InActionTime, C4MaterialCore::Incendiary, Info, InMat, C4Game::iTick10, C4Game::iTick255, C4Game::iTick5, LoadResStr(), C4MaterialMap::Map, MaterialMap, MNone, MVehic, MWater, NO_OWNER, C4Def::NoBreath, P_BreatheWater, P_ContactIncinerate, P_CorrosionResist, P_MaterialIncinerate, P_MaxBreath, PSF_OnInIncendiaryMaterial, Shape, StartSoundEffect(), C4Game::Time, and C4ObjectInfoCore::TotalPlayingTime.

Referenced by Execute().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ExecMovement()

bool C4Object::ExecMovement ( )

Definition at line 691 of file C4Movement.cpp.

692 {
693  // Update in which material this object is
694  UpdateInMat();
695 
696  // Containment check
697  if (Contained)
698  {
700 
701  return true;
702  }
703 
704  // General mobility check
705  if (Category & C4D_StaticBack)
706  {
707  return false;
708  }
709 
710  // Movement execution
711  if (Mobile) // Object is moving
712  {
713  // Move object
714  DoMovement();
715  // Demobilization check
716  if ((xdir == 0) && (ydir == 0) && (rdir == 0))
717  {
718  Mobile = false;
719  }
720  // Check for stabilization
721  if (rdir == 0)
722  {
723  Stabilize();
724  }
725  }
726  else // Object is static
727  {
728  // Check for stabilization
729  Stabilize();
730  // Check for mobilization
731  if (!::Game.iTick10)
732  {
733  // Gravity mobilization
734  xdir = ydir = rdir = 0;
735  Mobile = true;
736  }
737  }
738 
739  // Enforce zero rotation
740  if (!Def->Rotateable)
741  {
742  fix_r = Fix0;
743  }
744 
745  // Out of bounds check
746  if ((!Inside<int32_t>(GetX() + Shape.GetX(), -Shape.Wdt, ::Landscape.GetWidth()) && !(GetPropertyInt(P_BorderBound) & C4D_Border_Sides))
748  {
749  C4PropList* current_action = GetAction();
750  // Never remove attached objects: If they are truly outside landscape, their target will be removed,
751  // and the attached objects follow one frame later
752  if (!current_action || !Action.Target || current_action->GetPropertyP(P_Procedure) != DFA_ATTACH)
753  {
754  bool should_remove = true;
755  // Never remove HUD objects
756  if (Category & C4D_Parallax)
757  {
758  int parallaxity_x, parallaxity_y;
759  GetParallaxity(&parallaxity_x, &parallaxity_y);
760 
761  should_remove = false;
762  if (GetX() > ::Landscape.GetWidth() || GetY() > ::Landscape.GetHeight())
763  {
764  should_remove = true; // except if they are really out of the viewport to the right...
765  }
766  else if (GetX() < 0 && !!parallaxity_x)
767  {
768  should_remove = true; // ...or it's not HUD horizontally and it's out to the left
769  }
770  else if (!parallaxity_x && GetX() < -::Landscape.GetWidth())
771  {
772  should_remove = true; // ...or it's HUD horizontally and it's out to the left
773  }
774  }
775  if (should_remove)
776  {
777  AssignDeath(true);
778  AssignRemoval();
779  }
780  }
781  }
782  return true;
783 }
const int32_t C4D_Border_Bottom
Definition: C4Def.h:67
const int32_t C4D_StaticBack
Definition: C4Def.h:40
const int32_t C4D_Border_Sides
Definition: C4Def.h:65
C4Landscape Landscape
@ P_BorderBound
int32_t GetWidth() const
int32_t GetHeight() const
void GetParallaxity(int32_t *parX, int32_t *parY) const
void DoMovement()
Definition: C4Movement.cpp:250
void Stabilize()
Definition: C4Movement.cpp:616

References Action, AssignDeath(), AssignRemoval(), C4D_Border_Bottom, C4D_Border_Sides, C4D_Parallax, C4D_StaticBack, Category, Contained, CopyMotion(), Def, DFA_ATTACH, DoMovement(), Fix0, fix_r, Game, GetAction(), C4Landscape::GetHeight(), GetParallaxity(), C4PropList::GetPropertyInt(), C4PropList::GetPropertyP(), C4Landscape::GetWidth(), GetX(), C4Shape::GetX(), GetY(), C4Shape::GetY(), C4Game::iTick10, Landscape, Mobile, P_BorderBound, P_Procedure, rdir, C4Def::Rotateable, Shape, Stabilize(), C4Action::Target, C4Rect::Wdt, xdir, and ydir.

Referenced by Execute().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ Execute()

void C4Object::Execute ( )

Definition at line 427 of file C4Object.cpp.

428 {
429  if (Config.General.DebugRec)
430  {
431  // record debug
432  C4RCExecObj rc;
433  rc.Number=Number;
434  rc.fx=fix_x;
435  rc.fy=fix_y;
436  rc.fr=fix_r;
437  AddDbgRec(RCT_ExecObj, &rc, sizeof(rc));
438  }
439  // OCF
440  UpdateOCF();
441  // Command
442  ExecuteCommand();
443  // Action
444  // need not check status, because dead objects have lost their action
445  ExecAction();
446  // commands and actions are likely to have removed the object, and movement
447  // *must not* be executed for dead objects (SolidMask-errors)
448  if (!Status) return;
449  // Movement
450  ExecMovement();
451  if (!Status) return;
452  // effects
453  if (pEffects)
454  {
456  if (!Status) return;
457  }
458  // Life
459  ExecLife();
460  // Animation. If the mesh is attached, then don't execute animation here but let the parent object do it to make sure it is only executed once a frame.
462  pMeshInstance->ExecuteAnimation(1.0f/37.0f /* play smoothly at 37 FPS */);
463  // Menu
464  if (Menu) Menu->Execute();
465 }
@ RCT_ExecObj
Definition: C4Record.h:57
C4Real fy
Definition: C4Record.h:132
C4Real fx
Definition: C4Record.h:132
C4Real fr
Definition: C4Record.h:132
int Number
Definition: C4Record.h:131
static void Execute(C4Effect **ppEffectList)
Definition: C4Effect.cpp:297
bool ExecLife()
Definition: C4Object.cpp:354
bool ExecMovement()
Definition: C4Movement.cpp:691
bool ExecuteCommand()
void UpdateOCF()
void ExecAction()
AttachedMesh * GetAttachParent() const
Definition: StdMesh.h:586
void ExecuteAnimation(float dt)
Definition: StdMesh.cpp:1288

References AddDbgRec(), Config, C4ConfigGeneral::DebugRec, ExecAction(), ExecLife(), ExecMovement(), C4ObjectMenu::Execute(), C4Effect::Execute(), StdMeshInstance::ExecuteAnimation(), ExecuteCommand(), fix_r, fix_x, fix_y, C4RCExecObj::fr, C4RCExecObj::fx, C4RCExecObj::fy, C4Config::General, StdMeshInstance::GetAttachParent(), Menu, C4RCExecObj::Number, C4PropListNumbered::Number, pEffects, pMeshInstance, RCT_ExecObj, C4PropList::Status, and UpdateOCF().

Here is the call graph for this function:

◆ ExecuteCommand()

bool C4Object::ExecuteCommand ( )

Definition at line 151 of file C4ObjectCommand.cpp.

152 {
153  // Execute first command
154  if (Command) Command->Execute();
155  // Command finished: engine call
156  if (Command && Command->Finished)
158  // Clear finished commands
160  // Done
161  return true;
162 }
#define PSF_ControlCommandFinished
Definition: C4GameScript.h:71
void Execute()
Definition: C4Command.cpp:1295
void ClearCommand(C4Command *pUntil)

References C4PropList::Call(), ClearCommand(), C4Command::Command, Command, CommandName(), C4Command::Data, C4Command::Execute(), C4Command::Finished, PSF_ControlCommandFinished, C4Command::Target, C4Command::Target2, C4Command::Tx, and C4Command::Ty.

Referenced by Execute().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ Exit()

bool C4Object::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 at line 32 of file C4ObjectContents.cpp.

33 {
34  // 1. Exit the current container.
35  // 2. Update Contents of container object and set Contained to nullptr.
36  // 3. Set offset position/motion if desired.
37  // 4. Call Ejection for container and Departure for object.
38 
39  // Not contained
40  C4Object *pContainer=Contained;
41  if (!pContainer) return false;
42  // Remove object from container
43  pContainer->Contents.Remove(this);
44  pContainer->UpdateMass();
45  pContainer->SetOCF();
46  // No container
47  Contained=nullptr;
48  // Position/motion
49  fix_x=itofix(iX); fix_y=itofix(iY);
50  fix_r=itofix(iR);
52  xdir=iXDir; ydir=iYDir; rdir=iRDir;
53  // Misc updates
54  Mobile=true;
55  InLiquid=false;
56  CloseMenu(true);
57  UpdateFace(true);
58  SetOCF();
59  // Object list callback (before script callbacks, because script callbacks may enter again)
60  ObjectListChangeListener.OnObjectContainerChanged(this, pContainer, nullptr);
61  // Engine calls
62  if (fCalls) pContainer->Call(PSF_Ejection,&C4AulParSet(this));
63  if (fCalls) Call(PSF_Departure,&C4AulParSet(pContainer));
64  // Success (if the obj wasn't "re-entered" by script)
65  return !Contained;
66 }
#define PSF_Ejection
Definition: C4GameScript.h:58
#define PSF_Departure
Definition: C4GameScript.h:60
void BoundsCheck(C4Real &target_x, C4Real &target_y)
Definition: C4Object.h:330

References BoundsCheck(), C4PropList::Call(), CloseMenu(), Contained, Contents, fix_r, fix_x, fix_y, InLiquid, itofix(), Mobile, ObjectListChangeListener, C4ObjectListChangeListener::OnObjectContainerChanged(), PSF_Departure, PSF_Ejection, rdir, C4ObjectList::Remove(), SetOCF(), UpdateFace(), UpdateMass(), xdir, and ydir.

Referenced by AssignDeath(), AssignRemoval(), ChangeDef(), ClearContentsAndContained(), DoCon(), Enter(), C4Command::Exit(), ObjectActionThrow(), and ObjectComDrop().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ FindCommand()

C4Command * C4Object::FindCommand ( int32_t  iCommandType) const

Definition at line 142 of file C4ObjectCommand.cpp.

143 {
144  // seek all commands
145  for (C4Command *pCom = Command; pCom; pCom=pCom->Next)
146  if (pCom->Command == iCommandType) return pCom;
147  // nothing found
148  return nullptr;
149 }

References Command, and C4Command::Next.

◆ FinishedDrawing()

void C4Object::FinishedDrawing ( ) const

Definition at line 688 of file C4ObjectGraphics.cpp.

689 {
690  // color modulation
692  // extra blitting flags
693  pDraw->ResetBlitMode();
694 }
void DeactivateBlitModulation()
Definition: C4Draw.h:189
void ResetBlitMode()
Definition: C4Draw.h:192

References C4Draw::DeactivateBlitModulation(), pDraw, and C4Draw::ResetBlitMode().

Referenced by C4DefGraphics::Draw(), Draw(), DrawLine(), C4GraphicsOverlay::DrawPicture(), DrawTopFace(), and Picture2Facet().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ Fling()

void C4Object::Fling ( C4Real  txdir,
C4Real  tydir,
bool  fAddSpeed 
)

Definition at line 109 of file C4ObjectPhysics.cpp.

110 {
111  if (add_speed)
112  {
113  fling_xdir += xdir / 2;
114  fling_ydir += ydir / 2;
115  }
116  if (!ObjectActionTumble(this, (fling_xdir < 0), fling_xdir, fling_ydir)
117  && !ObjectActionJump(this, fling_xdir, fling_ydir, false))
118  {
119  xdir = fling_xdir;
120  ydir = fling_ydir;
121  Mobile = true;
123  }
124 }

References Action, CNAT_Bottom, Mobile, ObjectActionJump(), ObjectActionTumble(), C4Action::t_attach, xdir, and ydir.

Referenced by C4GameObjects::CrossCheck().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ForcePosition()

void C4Object::ForcePosition ( C4Real  target_x,
C4Real  target_y 
)

Definition at line 667 of file C4Movement.cpp.

668 {
669  fix_x = target_x;
670  fix_y = target_y;
671  UpdatePos();
672  UpdateSolidMask(false);
673 }

References fix_x, fix_y, UpdatePos(), and UpdateSolidMask().

Referenced by ContactAction().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ Freeze()

void C4PropList::Freeze ( )
inlineinherited

Definition at line 132 of file C4PropList.h.

132 { constant = true; }

Referenced by C4PropList::FreezeAndMakeStaticRecursively().

Here is the caller graph for this function:

◆ FreezeAndMakeStaticRecursively()

C4PropListStatic * C4PropList::FreezeAndMakeStaticRecursively ( std::vector< C4Value > *  prop_lists,
const C4PropListStatic parent = nullptr,
C4String key = nullptr 
)
inherited

Definition at line 279 of file C4PropList.cpp.

280 {
281  Freeze();
282  // Already static?
283  C4PropListStatic *this_static = IsStatic();
284  if (!this_static)
285  {
286  // Make self static by creating a copy and replacing all references
287  this_static = NewStatic(GetPrototype(), parent, key);
288  this_static->Properties.Swap(&Properties); // grab properties
289  this_static->Status = Status;
290  RefSet pre_freeze_refs{Refs}; // copy to avoid iterator validity headaches
291  C4Value holder = C4VPropList(this); // add another reference to prevent premature deletion
292  for (C4Value * ref : pre_freeze_refs)
293  ref->SetPropList(this_static);
294  // store reference
295  if (prop_lists)
296  prop_lists->push_back(C4VPropList(this_static));
297  // "this" should be deleted as holder goes out of scope
298  }
299  // Iterate over sorted list of elements to make static
300  // Must iterate over sorted list because the order must be defined, just in case it's a network game
301  // and a non-static child proplist is available through different paths it should still get the same name
302  auto prop_names = this_static->GetSortedLocalProperties(false);
303  for (auto prop_name : prop_names)
304  {
305  C4Value child_val;
306  this_static->GetPropertyByS(prop_name, &child_val);
307  C4PropList *child_proplist = child_val.getPropList();
308  if (child_proplist)
309  {
310  // Avoid infinite recursion: Only freeze into unfrozen children and "true" static children
311  C4PropListStatic *child_static = child_proplist->IsStatic();
312  if (!child_static || (child_static->GetParent() == this_static && child_static->GetParentKeyName() == prop_name))
313  {
314  child_proplist->FreezeAndMakeStaticRecursively(prop_lists, this_static, prop_name);
315  }
316  }
317  }
318  return this_static;
319 }
virtual bool GetPropertyByS(const C4String *k, C4Value *pResult) const
Definition: C4PropList.cpp:726
C4PropListStatic * FreezeAndMakeStaticRecursively(std::vector< C4Value > *prop_lists, const C4PropListStatic *parent=nullptr, C4String *key=nullptr)
Definition: C4PropList.cpp:279
std::vector< C4String * > GetSortedLocalProperties(bool add_prototype=true) const
Definition: C4PropList.cpp:545
void Freeze()
Definition: C4PropList.h:132
static C4PropListStatic * NewStatic(C4PropList *prototype, const C4PropListStatic *parent, C4String *key)
Definition: C4PropList.cpp:46
C4String * GetParentKeyName()
Definition: C4PropList.h:276
const C4PropListStatic * GetParent() const
Definition: C4PropList.h:275
C4PropList * getPropList() const
Definition: C4Value.h:116

References C4VPropList(), C4PropList::Freeze(), C4PropList::FreezeAndMakeStaticRecursively(), C4PropListStatic::GetParent(), C4PropListStatic::GetParentKeyName(), C4PropList::GetPropertyByS(), C4Value::getPropList(), C4PropList::GetPrototype(), C4PropList::GetSortedLocalProperties(), C4PropList::IsStatic(), C4PropList::NewStatic(), and C4PropList::Status.

Referenced by C4PropList::FreezeAndMakeStaticRecursively(), and C4AulScriptEngine::Link().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetAction()

C4PropList * C4Object::GetAction ( ) const

Definition at line 166 of file C4ObjectAction.cpp.

167 {
168  C4Value value;
169  GetProperty(P_Action, &value);
170  return value.getPropList();
171 }

References C4PropList::GetProperty(), C4Value::getPropList(), and P_Action.

Referenced by C4FindObjectAction::Check(), C4FindObjectActionTarget::Check(), C4FindObjectProcedure::Check(), ContactAction(), C4GameObjects::CrossCheck(), Draw(), DrawActionFace(), DrawTopFace(), ExecAction(), ExecMovement(), C4ValueProviderAction::Execute(), C4Command::FlightControl(), GetDataString(), GetProcedure(), C4Command::MoveTo(), NoAttachAction(), ObjectComDrop(), ObjectComJump(), SetDir(), SetOCF(), SetPhase(), SideBounds(), UpdateActionFace(), UpdateFlipDir(), UpdateOCF(), and VerticalBounds().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetAlive()

bool C4Object::GetAlive ( ) const
inline

Definition at line 304 of file C4Object.h.

304 { return Alive; }

References Alive.

◆ GetArea()

BYTE C4Object::GetArea ( int32_t &  aX,
int32_t &  aY,
int32_t &  aWdt,
int32_t &  aHgt 
) const

Definition at line 700 of file C4Object.cpp.

701 {
702  if (!Status || !Def) return 0;
703  aX = GetX() + Shape.GetX(); aY = GetY() + Shape.GetY();
704  aWdt=Shape.Wdt; aHgt=Shape.Hgt;
705  return 1;
706 }

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

Here is the call graph for this function:

◆ GetByNumber()

C4PropList * C4PropListNumbered::GetByNumber ( int32_t  iNumber)
staticinherited

Definition at line 51 of file C4PropList.cpp.

52 {
53  return PropLists.Get(iNumber);
54 }

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

Referenced by C4Value::Denumerate(), and C4GameObjects::ObjectPointer().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetCon()

int32_t C4Object::GetCon ( ) const
inline

Definition at line 271 of file C4Object.h.

271 { return Con; }

References Con.

Referenced by C4EditCursor::HasTransformMarker(), C4EditCursor::LeftButtonDown(), and ObjectComJump().

Here is the caller graph for this function:

◆ GetDataString()

StdStrBuf C4Object::GetDataString ( )

Definition at line 729 of file C4Object.cpp.

730 {
731  StdStrBuf Output;
732  // Type
733  Output.AppendFormat(LoadResStr("IDS_CNS_TYPE"),GetName(),Def->id.ToString());
734  // Owner
735  if (ValidPlr(Owner))
736  {
737  Output.Append("\n");
738  Output.AppendFormat(LoadResStr("IDS_CNS_OWNER"),::Players.Get(Owner)->GetName());
739  }
740  // Contents
741  if (Contents.ObjectCount())
742  {
743  Output.Append("\n");
744  Output.Append(LoadResStr("IDS_CNS_CONTENTS"));
746  }
747  // Action
748  if (GetAction())
749  {
750  Output.Append("\n");
751  Output.Append(LoadResStr("IDS_CNS_ACTION"));
752  Output.Append(GetAction()->GetName());
753  }
754  // Properties
755  Output.Append("\n");
756  Output.Append(LoadResStr("IDS_CNS_PROPERTIES"));
757  Output.Append("\n ");
758  AppendDataString(&Output, "\n ");
759  // Effects
760  if (pEffects)
761  {
762  Output.Append("\n");
763  Output.Append(LoadResStr("IDS_CNS_EFFECTS"));
764  Output.Append(": ");
765  }
766  for (C4Effect *pEffect = pEffects; pEffect; pEffect = pEffect->pNext)
767  {
768  Output.Append("\n");
769  // Effect name
770  Output.AppendFormat(" %s: Priority %d, Interval %d", pEffect->GetName(), pEffect->iPriority, pEffect->iInterval);
771  }
772 
773  StdStrBuf Output2;
774  C4ValueNumbers numbers;
775  DecompileToBuf_Log<StdCompilerINIWrite>(mkNamingAdapt(mkInsertAdapt(mkParAdapt(*this, &numbers),
776  mkNamingAdapt(numbers, "Values"), false),
777  "Object"), &Output2, "C4Object::GetDataString");
778  Output.Append("\n");
779  Output.Append(Output2);
780  return Output;
781 }
StdInsertAdapt< T, I > mkInsertAdapt(T &&rObj, I &&rIns, bool fBefore=true)
Definition: StdAdaptors.h:469
C4Effect * pNext
Definition: C4Effect.h:75
const char * ToString() const
Definition: C4Id.h:56
StdStrBuf GetNameList(C4DefList &defs) const
const char * GetName() const
Definition: C4Player.h:151
void AppendDataString(StdStrBuf *out, const char *delim, int depth=3, bool ignore_reference_parent=false) const
Definition: C4PropList.cpp:487

References StdStrBuf::Append(), C4PropList::AppendDataString(), StdStrBuf::AppendFormat(), Contents, Def, Definitions, C4PlayerList::Get(), GetAction(), C4Player::GetName(), C4PropList::GetName(), C4ObjectList::GetNameList(), C4Def::id, LoadResStr(), mkInsertAdapt(), mkNamingAdapt(), mkParAdapt(), C4ObjectList::ObjectCount(), Owner, pEffects, Players, C4Effect::pNext, C4ID::ToString(), and ValidPlr().

Referenced by C4EditCursorSelection::GetDataString().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetDef() [1/2]

C4Def * C4PropList::GetDef ( )
virtualinherited

Reimplemented in C4Def.

Definition at line 648 of file C4PropList.cpp.

649 {
650  if (GetPrototype()) return GetPrototype()->GetDef();
651  return nullptr;
652 }
virtual C4Def const * GetDef() const
Definition: C4PropList.cpp:654

References C4PropList::GetDef(), and C4PropList::GetPrototype().

Here is the call graph for this function:

◆ GetDef() [2/2]

C4Def const * C4PropList::GetDef ( ) const
virtualinherited

Reimplemented in C4Def.

Definition at line 654 of file C4PropList.cpp.

655 {
656  if (GetPrototype()) return GetPrototype()->GetDef();
657  return nullptr;
658 }

References C4PropList::GetDef(), and C4PropList::GetPrototype().

Referenced by C4Value::_getDef(), ConstructionCheck(), C4Game::CreateObject(), C4Game::CreateObjectConstruction(), C4AulExec::DirectExec(), C4GameMessage::Draw(), C4Game::DrawPropListSpecImage(), C4AulExec::FnTranslate(), C4PropList::GetDef(), C4Value::getDef(), Init(), C4GameMessage::Init(), C4FindObjectDef::IsImpossible(), C4PropList::operator==(), C4ScriptHost::Parse(), C4AulParse::Parse_Script(), C4Game::PlaceAnimal(), C4Game::PlaceVegetation(), and C4ScriptGuiWindowProperty::Set().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetDragImage()

bool C4Object::GetDragImage ( C4Object **  drag_object,
C4Def **  drag_id 
) const

Definition at line 713 of file C4ObjectGraphics.cpp.

714 {
715  // drag is possible if MouseDragImage is assigned
716  C4Value parV; GetProperty(P_MouseDragImage, &parV);
717  if (!parV) return false;
718  // determine drag object/id
719  C4Object *obj = parV.getObj();
720  C4Def * def = nullptr;
721  if (!obj) def = parV.getDef();
722  if (drag_object) *drag_object = obj;
723  if (drag_def) *drag_def = def;
724  // drag possible, even w./o image
725  return true;
726 }
@ P_MouseDragImage
C4Object * getObj() const
Definition: C4Value.cpp:68
C4Def * getDef() const
Definition: C4Value.cpp:78

References C4Value::getDef(), C4Value::getObj(), C4PropList::GetProperty(), and P_MouseDragImage.

Referenced by C4MouseControl::DragNone().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetDrawPosition() [1/2]

bool C4Object::GetDrawPosition ( const C4TargetFacet cgo,
float &  resultx,
float &  resulty,
float &  resultzoom 
) const

Definition at line 733 of file C4ObjectGraphics.cpp.

735 {
736  return GetDrawPosition(cgo, fixtof(fix_x), fixtof(fix_y), cgo.Zoom, resultx, resulty, resultzoom);
737 }

References fix_x, fix_y, fixtof(), and C4TargetFacet::Zoom.

Referenced by C4GraphicsOverlay::Draw(), Draw(), C4GameMessage::Draw(), C4EditCursor::DrawObject(), DrawSelectMark(), DrawTopFace(), and SetAudibilityAt().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetDrawPosition() [2/2]

bool C4Object::GetDrawPosition ( const C4TargetFacet cgo,
float  x,
float  y,
float  zoom,
float &  resultx,
float &  resulty,
float &  resultzoom 
) const

Definition at line 739 of file C4ObjectGraphics.cpp.

740 {
741  // for HUD
743  {
744  resultzoom = zoom;
745 
746  if(fix_x < 0)
747  resultx = cgo.X + objx + cgo.Wdt;
748  else
749  resultx = cgo.X + objx;
750 
751  if(fix_y < 0)
752  resulty = cgo.Y + objy + cgo.Hgt;
753  else
754  resulty = cgo.Y + objy;
755 
756  return true;
757  }
758 
759  // zoom with parallaxity
760  int iParX, iParY;
761  GetParallaxity(&iParX, &iParY);
762  float targetx = cgo.TargetX; float targety = cgo.TargetY;
763  float parx = iParX / 100.0f; float pary = iParY / 100.0f;
764  float par = parx; // and pary?
765 
766  // Step 1: project to landscape coordinates
767  resultzoom = 1.0 / (1.0 - (par - par/zoom));
768  // it would be par / (1.0 - (par - par/zoom)) if objects would get smaller farther away
769  if (resultzoom <= 0 || resultzoom > 100) // FIXME: optimize treshhold
770  return false;
771 
772  float rx = ((1 - parx) * cgo.ParRefX) * resultzoom + objx / (parx + zoom - parx * zoom);
773  float ry = ((1 - pary) * cgo.ParRefY) * resultzoom + objy / (pary + zoom - pary * zoom);
774 
775  // Step 2: convert to screen coordinates
776  if(parx == 0 && fix_x < 0)
777  resultx = cgo.X + (objx + cgo.Wdt) * zoom / resultzoom;
778  else
779  resultx = cgo.X + (rx - targetx) * zoom / resultzoom;
780 
781  if(pary == 0 && fix_y < 0)
782  resulty = cgo.Y + (objy + cgo.Hgt) * zoom / resultzoom;
783  else
784  resulty = cgo.Y + (ry - targety) * zoom / resultzoom;
785 
786  return true;
787 }
const int32_t C4D_Foreground
Definition: C4Def.h:53
float ParRefY
Definition: C4Facet.h:177
float ParRefX
Definition: C4Facet.h:177

References C4D_Foreground, Category, fix_x, fix_y, GetParallaxity(), C4Facet::Hgt, C4TargetFacet::ParRefX, C4TargetFacet::ParRefY, C4TargetFacet::TargetX, C4TargetFacet::TargetY, C4Facet::Wdt, C4Facet::X, and C4Facet::Y.

Here is the call graph for this function:

◆ GetEffect()

C4Effect * C4PropList::GetEffect ( )
virtualinherited

Reimplemented in C4Effect.

Definition at line 678 of file C4PropList.cpp.

679 {
680  if (GetPrototype()) return GetPrototype()->GetEffect();
681  return nullptr;
682 }
virtual C4Effect * GetEffect()
Definition: C4PropList.cpp:678

References C4PropList::GetEffect(), and C4PropList::GetPrototype().

Referenced by C4ValueConv< C4Effect * >::_FromC4V(), and C4PropList::GetEffect().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetEntranceArea()

BYTE C4Object::GetEntranceArea ( int32_t &  aX,
int32_t &  aY,
int32_t &  aWdt,
int32_t &  aHgt 
) const

Definition at line 708 of file C4Object.cpp.

709 {
710  if (!Status || !Def) return 0;
711  // Return actual entrance
712  if (OCF & OCF_Entrance)
713  {
714  aX=GetX() + Def->Entrance.x;
715  aY=GetY() + Def->Entrance.y;
716  aWdt=Def->Entrance.Wdt;
717  aHgt=Def->Entrance.Hgt;
718  }
719  // Return object center
720  else
721  {
722  aX=GetX(); aY=GetY();
723  aWdt=0; aHgt=0;
724  }
725  // Done
726  return 1;
727 }

References Def, C4Def::Entrance, GetX(), GetY(), C4Rect::Hgt, OCF, OCF_Entrance, C4PropList::Status, C4Rect::Wdt, C4Rect::x, and C4Rect::y.

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

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetEnumerationIndex()

static int32_t C4PropListNumbered::GetEnumerationIndex ( )
inlinestaticinherited

Definition at line 230 of file C4PropList.h.

230 { return EnumerationIndex; }

References C4PropListNumbered::EnumerationIndex.

Referenced by C4Game::NewObject(), C4EditCursor::PerformDuplication(), and C4ControlSyncCheck::Set().

Here is the caller graph for this function:

◆ GetFixedR()

C4Real C4Object::GetFixedR ( ) const
inline

Definition at line 290 of file C4Object.h.

290 { return fix_r; }

References fix_r.

◆ GetFixedX()

C4Real C4Object::GetFixedX ( ) const
inline

Definition at line 288 of file C4Object.h.

288 { return fix_x; }

References fix_x.

Referenced by C4ParticleChunk::Draw(), C4SolidMask::Put(), and C4SolidMask::Remove().

Here is the caller graph for this function:

◆ GetFixedY()

C4Real C4Object::GetFixedY ( ) const
inline

Definition at line 289 of file C4Object.h.

289 { return fix_y; }

References fix_y.

Referenced by C4ParticleChunk::Draw(), and C4SolidMask::Put().

Here is the caller graph for this function:

◆ GetFunc() [1/3]

C4AulFunc* C4PropList::GetFunc ( C4PropertyName  k) const
inlineinherited

◆ GetFunc() [2/3]

C4AulFunc * C4PropList::GetFunc ( C4String k) const
inherited

Definition at line 772 of file C4PropList.cpp.

773 {
774  assert(k);
775  if (Properties.Has(k))
776  {
777  return Properties.Get(k).Value.getFunction();
778  }
779  if (GetPrototype())
780  {
781  return GetPrototype()->GetFunc(k);
782  }
783  return nullptr;
784 }
bool Has(H e) const

References C4Set< T >::Get(), C4PropList::GetFunc(), C4Value::getFunction(), C4PropList::GetPrototype(), C4Set< T >::Has(), and C4Property::Value.

Here is the call graph for this function:

◆ GetFunc() [3/3]

C4AulFunc * C4PropList::GetFunc ( const char *  k) const
inherited

Definition at line 786 of file C4PropList.cpp.

787 {
788  assert(s);
789  if (s[0] == '~') ++s;
790  C4String * k = Strings.FindString(s);
791  // this string is entirely unused
792  if (!k)
793  return nullptr;
794  return GetFunc(k);
795 }
C4String * FindString(const char *strString) const

References C4StringTable::FindString(), C4PropList::GetFunc(), s, and Strings.

Here is the call graph for this function:

◆ GetGraphics()

C4DefGraphics* C4Object::GetGraphics ( ) const
inline

Definition at line 339 of file C4Object.h.

339 { return pGraphics; } // return current object graphics

References pGraphics.

Referenced by C4Def::Draw(), C4SolidMask::Draw(), C4GraphicsOverlay::Draw(), C4MouseControl::Draw(), Draw(), DrawActionFace(), DrawFace(), DrawFaceImpl(), DrawTopFace(), Picture2Facet(), SetOwner(), UpdateActionFace(), and UpdateFace().

Here is the caller graph for this function:

◆ GetGraphicsOverlay() [1/2]

C4GraphicsOverlay * C4Object::GetGraphicsOverlay ( int32_t  iForID) const

Definition at line 835 of file C4ObjectGraphics.cpp.

836 {
837  // search in list until ID is found or passed
838  C4GraphicsOverlay *pOverlay = pGfxOverlay;
839  while (pOverlay && pOverlay->GetID() < iForID) pOverlay = pOverlay->GetNext();
840  // exact match found?
841  if (pOverlay && pOverlay->GetID() == iForID) return pOverlay;
842  // none found
843  return nullptr;
844 }

References C4GraphicsOverlay::GetID(), C4GraphicsOverlay::GetNext(), and pGfxOverlay.

Referenced by CanConcatPictureWith().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetGraphicsOverlay() [2/2]

C4GraphicsOverlay * C4Object::GetGraphicsOverlay ( int32_t  iForID,
bool  fCreate 
)

Definition at line 846 of file C4ObjectGraphics.cpp.

847 {
848  // search in list until ID is found or passed
849  C4GraphicsOverlay *pOverlay = pGfxOverlay, *pPrevOverlay = nullptr;
850  while (pOverlay && pOverlay->GetID() < iForID) { pPrevOverlay = pOverlay; pOverlay = pOverlay->GetNext(); }
851  // exact match found?
852  if (pOverlay && pOverlay->GetID() == iForID) return pOverlay;
853  // ID has been passed: Create new if desired
854  if (!fCreate) return nullptr;
855  C4GraphicsOverlay *pNewOverlay = new C4GraphicsOverlay();
856  pNewOverlay->SetID(iForID);
857  pNewOverlay->SetNext(pOverlay);
858  if (pPrevOverlay) pPrevOverlay->SetNext(pNewOverlay); else pGfxOverlay = pNewOverlay;
859  // return newly created overlay
860  return pNewOverlay;
861 }
void SetNext(C4GraphicsOverlay *paNext)
void SetID(int32_t aID)

References C4GraphicsOverlay::GetID(), C4GraphicsOverlay::GetNext(), pGfxOverlay, C4GraphicsOverlay::SetID(), and C4GraphicsOverlay::SetNext().

Here is the call graph for this function:

◆ GetInfoString()

StdStrBuf C4Object::GetInfoString ( )

Definition at line 1244 of file C4Object.cpp.

1245 {
1246  StdStrBuf sResult;
1247  // no info for invalid objects
1248  if (!Status) return sResult;
1249  // go through all effects and add their desc
1250  for (C4Effect *pEff = pEffects; pEff; pEff = pEff->pNext)
1251  {
1252  C4Value par[7];
1253  C4Value vInfo = pEff->DoCall(this, PSFS_FxInfo, par[0], par[1], par[2], par[3], par[4], par[5], par[6]);
1254  if (!vInfo) continue;
1255  // debug: warn for wrong return types
1256  if (vInfo.GetType() != C4V_String)
1257  DebugLogF("Effect %s(#%d) on object %s (#%d) returned wrong info type %d.", pEff->GetName(), pEff->Number, GetName(), Number, vInfo.GetType());
1258  // get string val
1259  C4String *psInfo = vInfo.getStr(); const char *szEffInfo;
1260  if (psInfo && (szEffInfo = psInfo->GetCStr()))
1261  if (*szEffInfo)
1262  {
1263  // OK; this effect has a desc. Add it!
1264  if (sResult.getLength()) sResult.AppendChar('|');
1265  sResult.Append(szEffInfo);
1266  }
1267  }
1268  // done
1269  return sResult;
1270 }
#define PSFS_FxInfo
Definition: C4GameScript.h:157
bool DebugLogF(const char *strMessage ...)
Definition: C4Log.cpp:290
@ C4V_String
Definition: C4Value.h:29
C4String * getStr() const
Definition: C4Value.h:117

References StdStrBuf::Append(), StdStrBuf::AppendChar(), C4V_String, DebugLogF(), C4String::GetCStr(), StdStrBuf::getLength(), C4PropList::GetName(), C4Value::getStr(), C4Value::GetType(), C4PropListNumbered::Number, pEffects, C4Effect::pNext, PSFS_FxInfo, and C4PropList::Status.

Here is the call graph for this function:

◆ GetLightColor()

uint32_t C4Object::GetLightColor ( ) const
inline

Definition at line 299 of file C4Object.h.

299 { return lightColor; }

References lightColor.

◆ GetMapScriptLayer()

class C4MapScriptLayer * C4PropList::GetMapScriptLayer ( )
virtualinherited

Reimplemented in C4MapScriptLayer.

Definition at line 660 of file C4PropList.cpp.

661 {
662  if (GetPrototype()) return GetPrototype()->GetMapScriptLayer();
663  return nullptr;
664 }
virtual class C4MapScriptLayer * GetMapScriptLayer()
Definition: C4PropList.cpp:660

References C4PropList::GetMapScriptLayer(), and C4PropList::GetPrototype().

Referenced by C4MapScriptAlgoLayer::C4MapScriptAlgoLayer(), and C4PropList::GetMapScriptLayer().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetMapScriptMap()

class C4MapScriptMap * C4PropList::GetMapScriptMap ( )
virtualinherited

Reimplemented in C4MapScriptMap.

Definition at line 666 of file C4PropList.cpp.

667 {
668  if (GetPrototype()) return GetPrototype()->GetMapScriptMap();
669  return nullptr;
670 }
virtual class C4MapScriptMap * GetMapScriptMap()
Definition: C4PropList.cpp:666

References C4PropList::GetMapScriptMap(), and C4PropList::GetPrototype().

Referenced by C4PropList::GetMapScriptMap().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetMomentum()

BYTE C4Object::GetMomentum ( C4Real rxdir,
C4Real rydir 
) const

Definition at line 238 of file C4ObjectPhysics.cpp.

239 {
240  rxdir = rydir = 0;
241  if (!Status || !Def)
242  {
243  return 0;
244  }
245  rxdir = xdir;
246  rydir = ydir;
247  return 1;
248 }

References Def, C4PropList::Status, xdir, and ydir.

◆ GetName()

const char * C4PropList::GetName ( ) const
virtualinherited

Reimplemented in C4PropListStatic.

Definition at line 618 of file C4PropList.cpp.

619 {
621  if (!s) return "";
622  return s->GetCStr();
623 }
@ P_Name

References C4PropList::GetPropertyStr(), P_Name, and s.

Referenced by ActivateMenu(), C4Effect::AssignCallbackFunctions(), C4Effect::C4Effect(), C4PropertyPath::C4PropertyPath(), CanConcatPictureWith(), C4FindObjectAction::Check(), C4Game::CheckObjectEnumeration(), C4Effect::ClearAll(), ConstructionCheck(), C4Effect::DoCall(), C4EditCursor::DoContextMenu(), C4ObjectMenu::DoRefillInternal(), Draw(), C4ScriptGuiWindow::Draw(), C4Game::DrawCrewOverheadText(), ExecLife(), C4Effect::Get(), C4Effect::GetCount(), GetDataString(), GetInfoString(), C4Effect::Init(), C4Effect::Kill(), Lift(), C4Game::NewObject(), ObjectComDig(), Promote(), Push(), SetAction(), SetOCF(), C4Effect::TempRemoveUpperEffects(), UpdateOCF(), and C4EditCursor::UpdateStatusBar().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetObject() [1/2]

C4Object const* C4Object::GetObject ( ) const
inlineoverridevirtual

Reimplemented from C4PropList.

Definition at line 373 of file C4Object.h.

373 { return this; }

◆ GetObject() [2/2]

C4Object* C4Object::GetObject ( )
inlineoverridevirtual

Reimplemented from C4PropList.

Definition at line 372 of file C4Object.h.

372 { return this; }

◆ GetOCFForPos()

void C4Object::GetOCFForPos ( int32_t  ctx,
int32_t  cty,
DWORD ocf 
) const

Definition at line 199 of file C4ObjectOCF.cpp.

200 {
201  DWORD rocf=OCF;
202  // Verify entrance area OCF return
203  if (rocf & OCF_Entrance)
204  if (!Inside<int32_t>(cty - (GetY() + Def->Entrance.y), 0, Def->Entrance.Hgt - 1)
205  || !Inside<int32_t>(ctx - (GetX() + Def->Entrance.x), 0, Def->Entrance.Wdt - 1))
206  rocf &= (~OCF_Entrance);
207  // Verify collection area OCF return
208  if (rocf & OCF_Collection)
209  if (!Inside<int32_t>(cty - (GetY() + Def->Collection.y), 0, Def->Collection.Hgt - 1)
210  || !Inside<int32_t>(ctx - (GetX() + Def->Collection.x), 0, Def->Collection.Wdt - 1))
211  rocf &= (~OCF_Collection);
212  ocf=rocf;
213 }
uint32_t DWORD

References C4Def::Collection, Def, C4Def::Entrance, GetX(), GetY(), C4Rect::Hgt, OCF, OCF_Collection, OCF_Entrance, C4Rect::Wdt, C4Rect::x, and C4Rect::y.

Referenced by At().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetOnFire()

bool C4Object::GetOnFire ( ) const
inline

Definition at line 302 of file C4Object.h.

302 { return OnFire; }

References OnFire.

Referenced by C4Command::Acquire().

Here is the caller graph for this function:

◆ GetParallaxity()

void C4Object::GetParallaxity ( int32_t *  parX,
int32_t *  parY 
) const

Definition at line 696 of file C4ObjectGraphics.cpp.

697 {
698  assert(parX); assert(parY);
699  *parX = 100; *parY = 100;
700  if (Category & C4D_Foreground)
701  {
702  *parX = 0; *parY = 0;
703  return;
704  }
705  if (!(Category & C4D_Parallax)) return;
706  C4Value parV; GetProperty(P_Parallaxity, &parV);
707  C4ValueArray *par = parV.getArray();
708  if (!par) return;
709  *parX = par->GetItem(0).getInt();
710  *parY = par->GetItem(1).getInt();
711 }
@ P_Parallaxity

References C4D_Foreground, C4D_Parallax, Category, C4Value::getArray(), C4Value::getInt(), C4ValueArray::GetItem(), C4PropList::GetProperty(), and P_Parallaxity.

Referenced by ExecMovement(), GetDrawPosition(), and GetViewPosPar().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetPlane()

int32_t C4Object::GetPlane ( ) const
inline

Definition at line 179 of file C4Object.h.

179 { return Plane; }

References Plane.

Referenced by C4ObjectList::Add(), C4ObjectList::CheckCategorySort(), C4ObjectList::Draw(), C4GameObjects::FixObjectOrder(), GetSolidMaskPlane(), and IsMoveableBySolidMask().

Here is the caller graph for this function:

◆ GetProcedure()

int32_t C4Object::GetProcedure ( ) const

Definition at line 362 of file C4ObjectAction.cpp.

363 {
364  C4PropList* pActionDef = GetAction();
365  if (!pActionDef) return -1;
366  return pActionDef->GetPropertyP(P_Procedure);
367 }

References GetAction(), C4PropList::GetPropertyP(), and P_Procedure.

Referenced by C4Command::Activate(), C4Command::Dig(), C4Command::Drop(), C4Command::Enter(), C4Command::Follow(), FreeMoveTo(), C4Command::Get(), C4Command::Grab(), C4Command::Jump(), C4Command::MoveTo(), NoAttachAction(), ObjectComCancelAttach(), ObjectComGrab(), ObjectComJump(), ObjectComThrow(), ObjectComUnGrab(), C4Command::PushTo(), C4Command::Put(), PutAwayUnusedObject(), SetCommand(), C4Command::Throw(), and C4Command::Wait().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetProperties()

C4ValueArray * C4Object::GetProperties ( ) const
overridevirtual

Reimplemented from C4PropList.

Definition at line 1354 of file C4Object.cpp.

1355 {
1357  int i;
1358  i = a->GetSize();
1359  a->SetSize(i + 1);
1360  (*a)[i++] = C4VString(&::Strings.P[P_Plane]);
1361  return a;
1362 }
#define a
@ P_Plane
C4Value C4VString(C4String *pStr)
Definition: C4Value.h:243
virtual C4ValueArray * GetProperties() const
Definition: C4PropList.cpp:883

References a, C4VString(), C4PropList::GetProperties(), C4StringTable::P, P_Plane, and Strings.

Here is the call graph for this function:

◆ GetProperty()

bool C4PropList::GetProperty ( C4PropertyName  k,
C4Value pResult 
) const
inlineinherited

Definition at line 105 of file C4PropList.h.

106  { return GetPropertyByS(&Strings.P[k], pResult); }

References C4PropList::GetPropertyByS(), C4StringTable::P, and Strings.

Referenced by C4MapScriptAlgoFilter::C4MapScriptAlgoFilter(), C4MapScriptAlgoModifier::C4MapScriptAlgoModifier(), C4MapScriptAlgoPolygon::C4MapScriptAlgoPolygon(), C4MapScriptAlgoRndChecker::C4MapScriptAlgoRndChecker(), C4FindObjectProcedure::Check(), C4DefGraphics::Draw(), C4GraphicsOverlay::Draw(), DrawFaceImpl(), DrawLine(), GetAction(), C4Def::GetActionByName(), GetDragImage(), GetParallaxity(), C4MapScriptAlgo::GetXYProps(), C4GameMessage::Init(), IsVisible(), C4ScriptUniform::Push(), SetAction(), SetActionByName(), and C4GraphicsOverlay::UpdateFacet().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetPropertyArray()

C4ValueArray * C4PropList::GetPropertyArray ( C4PropertyName  n) const
inherited

Definition at line 758 of file C4PropList.cpp.

759 {
760  C4String * k = &Strings.P[n];
761  if (Properties.Has(k))
762  {
763  return Properties.Get(k).Value.getArray();
764  }
765  if (GetPrototype())
766  {
767  return GetPrototype()->GetPropertyArray(n);
768  }
769  return nullptr;
770 }
C4ValueArray * GetPropertyArray(C4PropertyName n) const
Definition: C4PropList.cpp:758

References C4Set< T >::Get(), C4Value::getArray(), C4PropList::GetPropertyArray(), C4PropList::GetPrototype(), C4Set< T >::Has(), C4StringTable::P, Strings, and C4Property::Value.

Referenced by C4EditCursor::DoContextMenu(), C4PropList::GetPropertyArray(), and C4FoWLight::Update().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetPropertyBool()

int32_t C4PropList::GetPropertyBool ( C4PropertyName  n,
bool  default_val = false 
) const
inherited

Definition at line 841 of file C4PropList.cpp.

842 {
843  C4String * k = &Strings.P[n];
844  if (Properties.Has(k))
845  {
846  return Properties.Get(k).Value.getBool();
847  }
848  if (GetPrototype())
849  {
850  return GetPrototype()->GetPropertyBool(n, default_val);
851  }
852  return default_val;
853 }
bool getBool() const
Definition: C4Value.h:113

References C4Set< T >::Get(), C4Value::getBool(), C4PropList::GetPropertyBool(), C4PropList::GetPrototype(), C4Set< T >::Has(), C4StringTable::P, Strings, and C4Property::Value.

Referenced by ExecLife(), and C4PropList::GetPropertyBool().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetPropertyByS()

bool C4Object::GetPropertyByS ( const C4String k,
C4Value pResult 
) const
overridevirtual

Reimplemented from C4PropList.

Definition at line 1342 of file C4Object.cpp.

1343 {
1344  if (k >= &Strings.P[0] && k < &Strings.P[P_LAST])
1345  {
1346  switch(k - &Strings.P[0])
1347  {
1348  case P_Plane: *pResult = C4VInt(Plane); return true;
1349  }
1350  }
1351  return C4PropListNumbered::GetPropertyByS(k, pResult);
1352 }
@ P_LAST

References C4VInt(), C4PropList::GetPropertyByS(), C4StringTable::P, P_LAST, P_Plane, Plane, and Strings.

Referenced by C4FindObjectProperty::Check().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetPropertyInt()

int32_t C4PropList::GetPropertyInt ( C4PropertyName  k,
int32_t  default_val = 0 
) const
inherited

Definition at line 855 of file C4PropList.cpp.

856 {
857  C4String * k = &Strings.P[n];
858  if (Properties.Has(k))
859  {
860  return Properties.Get(k).Value.getInt();
861  }
862  if (GetPrototype())
863  {
864  return GetPrototype()->GetPropertyInt(n, default_val);
865  }
866  return default_val;
867 }

References C4Set< T >::Get(), C4Value::getInt(), C4PropList::GetPropertyInt(), C4PropList::GetPrototype(), C4Set< T >::Has(), C4StringTable::P, Strings, and C4Property::Value.

Referenced by C4MouseControl::ButtonUpDragScript(), C4MapScriptAlgoEllipse::C4MapScriptAlgoEllipse(), C4MapScriptAlgoLines::C4MapScriptAlgoLines(), C4MapScriptAlgoOffset::C4MapScriptAlgoOffset(), C4MapScriptAlgoPolygon::C4MapScriptAlgoPolygon(), C4MapScriptAlgoRect::C4MapScriptAlgoRect(), C4MapScriptAlgoRndChecker::C4MapScriptAlgoRndChecker(), C4MapScriptAlgoRotate::C4MapScriptAlgoRotate(), C4MapScriptAlgoScale::C4MapScriptAlgoScale(), C4MapScriptAlgoTurbulence::C4MapScriptAlgoTurbulence(), Contact(), ContactAction(), DoBreath(), DoEnergy(), C4MouseControl::DragNone(), Draw(), DrawActionFace(), C4Game::DrawPropListSpecImage(), DrawTopFace(), C4Command::Enter(), ExecLife(), ExecMovement(), C4ValueProviderAction::Execute(), C4Command::Exit(), C4Command::FlightControl(), C4SoundModifierList::Get(), C4SoundModifier::GetBoolProp(), C4SoundModifier::GetFloatProp(), C4Def::GetPlane(), C4PropList::GetPropertyInt(), GetSolidMaskPlane(), Init(), IsVisible(), C4Command::MoveTo(), ObjectActionThrow(), ObjectComDrop(), ObjectComJump(), C4Game::PlaceAnimal(), C4Game::PlaceVegetation(), Push(), C4Command::Put(), ResetProperty(), SetAction(), SetDir(), SetOCF(), SetPhase(), SideBounds(), C4Command::Throw(), UpdateActionFace(), C4MouseControl::UpdateCursorTarget(), C4GraphicsOverlay::UpdateFacet(), UpdateFlipDir(), UpdateOCF(), and VerticalBounds().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetPropertyP()

C4PropertyName C4PropList::GetPropertyP ( C4PropertyName  k) const
inherited

Definition at line 824 of file C4PropList.cpp.

825 {
826  C4String * k = &Strings.P[n];
827  if (Properties.Has(k))
828  {
829  C4String * v = Properties.Get(k).Value.getStr();
830  if (v >= &Strings.P[0] && v < &Strings.P[P_LAST])
831  return C4PropertyName(v - &Strings.P[0]);
832  return P_LAST;
833  }
834  if (GetPrototype())
835  {
836  return GetPrototype()->GetPropertyP(n);
837  }
838  return P_LAST;
839 }
C4PropertyName

References C4Set< T >::Get(), C4PropList::GetPropertyP(), C4PropList::GetPrototype(), C4Value::getStr(), C4Set< T >::Has(), C4StringTable::P, P_LAST, Strings, and C4Property::Value.

Referenced by ContactAction(), C4GameObjects::CrossCheck(), ExecMovement(), GetProcedure(), C4PropList::GetPropertyP(), ObjectComDrop(), SetAction(), SideBounds(), and VerticalBounds().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetPropertyPropList()

C4PropList * C4PropList::GetPropertyPropList ( C4PropertyName  k) const
inherited

Definition at line 869 of file C4PropList.cpp.

870 {
871  C4String * k = &Strings.P[n];
872  if (Properties.Has(k))
873  {
874  return Properties.Get(k).Value.getPropList();
875  }
876  if (GetPrototype())
877  {
878  return GetPrototype()->GetPropertyPropList(n);
879  }
880  return nullptr;
881 }
C4PropList * GetPropertyPropList(C4PropertyName k) const
Definition: C4PropList.cpp:869

References C4Set< T >::Get(), C4PropList::GetPropertyPropList(), C4Value::getPropList(), C4PropList::GetPrototype(), C4Set< T >::Has(), C4StringTable::P, Strings, and C4Property::Value.

Referenced by C4MapScriptAlgoLayer::C4MapScriptAlgoLayer(), C4Game::DrawPropListSpecImage(), C4PropList::GetPropertyPropList(), and C4GameMessage::Init().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetPropertyStr()

C4String * C4PropList::GetPropertyStr ( C4PropertyName  k) const
inherited

Definition at line 744 of file C4PropList.cpp.

745 {
746  C4String * k = &Strings.P[n];
747  if (Properties.Has(k))
748  {
749  return Properties.Get(k).Value.getStr();
750  }
751  if (GetPrototype())
752  {
753  return GetPrototype()->GetPropertyStr(n);
754  }
755  return nullptr;
756 }

References C4Set< T >::Get(), C4PropList::GetPropertyStr(), C4PropList::GetPrototype(), C4Value::getStr(), C4Set< T >::Has(), C4StringTable::P, Strings, and C4Property::Value.

Referenced by C4Game::DrawPropListSpecImage(), ExecAction(), C4PropList::GetName(), C4PropListStatic::GetName(), C4PropList::GetPropertyStr(), C4Game::GetTranslatedString(), SetAction(), SetDir(), C4MouseControl::UpdateCursorTarget(), and C4GraphicsOverlay::UpdateFacet().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetPropListNumbered()

C4PropListNumbered * C4PropListNumbered::GetPropListNumbered ( )
overridevirtualinherited

Reimplemented from C4PropList.

Definition at line 151 of file C4PropList.cpp.

152 {
153  return this;
154 }

◆ GetPrototype()

C4PropList* C4PropList::GetPrototype ( ) const
inlineinherited

◆ GetR()

int32_t C4Object::GetR ( ) const
inline

Definition at line 287 of file C4Object.h.

287 { return fixtoi(fix_r); }

References fix_r, and fixtoi().

Referenced by AdjustWalkRotation(), ExecAction(), C4EditCursor::LeftButtonDown(), Push(), C4SolidMask::Put(), SetOCF(), and UpdateOCF().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetSolidMaskPlane()

int32_t C4Object::GetSolidMaskPlane ( ) const

Definition at line 563 of file C4ObjectPhysics.cpp.

564 {
565  // Use SolidMaskPlane property. Fallback to object plane if unassigned.
566  int32_t plane = GetPropertyInt(P_SolidMaskPlane);
567  return plane ? plane : GetPlane();
568 }
@ P_SolidMaskPlane
int32_t GetPlane() const
Definition: C4Object.h:179

References GetPlane(), C4PropList::GetPropertyInt(), and P_SolidMaskPlane.

Referenced by C4SolidMask::Put(), and C4SolidMask::Remove().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetSortedLocalProperties() [1/2]

std::vector< C4String * > C4PropList::GetSortedLocalProperties ( bool  add_prototype = true) const
inherited

Definition at line 545 of file C4PropList.cpp.

546 {
547  // return property list without descending into prototype
548  std::list<const C4Property *> sorted_props = Properties.GetSortedListOfElementPointers();
549  std::vector< C4String * > result;
550  result.reserve(sorted_props.size() + add_prototype);
551  if (add_prototype) result.push_back(&::Strings.P[P_Prototype]); // implicit prototype for every prop list
552  for (auto p : sorted_props) result.push_back(p->Key);
553  return result;
554 }

References C4Set< T >::GetSortedListOfElementPointers(), C4StringTable::P, P_Prototype, and Strings.

Referenced by C4PropList::FreezeAndMakeStaticRecursively(), and C4Game::GetTranslatedString().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetSortedLocalProperties() [2/2]

std::vector< C4String * > C4PropList::GetSortedLocalProperties ( const char *  prefix,
const C4PropList ignore_overridden 
) const
inherited

Definition at line 556 of file C4PropList.cpp.

557 {
558  // return property list without descending into prototype
559  // ignore properties that have been overridden by proplist given in ignore_overridden or any of its prototypes up to and excluding this
560  std::vector< C4String * > result;
561  for (const C4Property *pp = Properties.First(); pp; pp = Properties.Next(pp))
562  if (pp->Key != &::Strings.P[P_Prototype])
563  if (!prefix || pp->Key->GetData().BeginsWith(prefix))
564  {
565  // Override check
566  const C4PropList *check = ignore_overridden;
567  bool overridden = false;
568  if (check && check != this)
569  {
570  if (check->HasProperty(pp->Key)) { overridden = true; break; }
571  check = check->GetPrototype();
572  }
573  result.push_back(pp->Key);
574  }
575  // Sort
576  std::sort(result.begin(), result.end(), [](const C4String *a, const C4String *b) -> bool
577  {
578  return strcmp(a->GetCStr(), b->GetCStr()) < 0;
579  });
580  return result;
581 }
#define b
bool HasProperty(C4String *k) const
Definition: C4PropList.h:122

References a, b, C4Set< T >::First(), C4PropList::GetPrototype(), C4PropList::HasProperty(), C4Set< T >::Next(), C4StringTable::P, P_Prototype, and Strings.

Here is the call graph for this function:

◆ GetSortedProperties()

std::vector< C4String * > C4PropList::GetSortedProperties ( const char *  prefix,
C4PropList ignore_parent = nullptr 
) const
inherited

Definition at line 601 of file C4PropList.cpp.

602 {
603  struct sort_cmp {
604  bool operator() (const C4String *a, const C4String *b) const
605  {
606  return strcmp(a->GetCStr(), b->GetCStr()) < 0;
607  }
608  };
609  // Return property list with descending into prototype
610  // But do not include Prototype property
611  std::vector< C4String * > result = GetUnsortedProperties(prefix, ignore_parent);
612  // Sort and remove duplicates
613  std::set< C4String *, sort_cmp > result_set(result.begin(), result.end());
614  result.assign(result_set.begin(), result_set.end());
615  return result;
616 }
std::vector< C4String * > GetUnsortedProperties(const char *prefix, C4PropList *ignore_parent=nullptr) const
Definition: C4PropList.cpp:583

References a, b, and C4PropList::GetUnsortedProperties().

Here is the call graph for this function:

◆ GetSpeed()

C4Real C4Object::GetSpeed ( ) const

Definition at line 250 of file C4ObjectPhysics.cpp.

251 {
252  // TODO: This is actually not the real speed of the object,
253  // it is actually a "Manhattan" speed :)
254  // Note: Relevant for OCF calculation only...
255  C4Real speed = Fix0;
256  if (xdir < 0) speed -= xdir; else speed += xdir;
257  if (ydir < 0) speed -= ydir; else speed += ydir;
258  return speed;
259 }

References Fix0, xdir, and ydir.

Referenced by SetOCF(), and UpdateOCF().

Here is the caller graph for this function:

◆ GetUnsortedProperties()

std::vector< C4String * > C4PropList::GetUnsortedProperties ( const char *  prefix,
C4PropList ignore_parent = nullptr 
) const
inherited

Definition at line 583 of file C4PropList.cpp.

584 {
585  // Return property list with descending into prototype
586  // But do not include Prototype property
587  std::vector< C4String * > result;
588  const C4PropList *p = this;
589  do
590  {
591  for (const C4Property *pp = p->Properties.First(); pp; pp = p->Properties.Next(pp))
592  if (pp->Key != &::Strings.P[P_Prototype])
593  if (!prefix || pp->Key->GetData().BeginsWith(prefix))
594  result.push_back(pp->Key);
595  p = p->GetPrototype();
596  if (p == ignore_parent) break;
597  } while (p);
598  return result;
599 }

References C4Set< T >::First(), C4PropList::GetPrototype(), C4Set< T >::Next(), C4StringTable::P, P_Prototype, and Strings.

Referenced by C4PropList::GetSortedProperties(), and C4PropList::ThawRecursively().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetValue()

int32_t C4Object::GetValue ( C4Object pInBase,
int32_t  iForPlayer 
)

Definition at line 791 of file C4Object.cpp.

792 {
793  C4Value r = Call(PSF_CalcValue, &C4AulParSet(pInBase, iForPlayer));
794  int32_t iValue;
795  if (r != C4VNull)
796  iValue = r.getInt();
797  else
798  {
799  // get value of def
800  // Caution: Do not pass pInBase here, because the def base value is to be queried
801  // - and not the value if you had to buy the object in this particular base
802  iValue = Def->GetValue(nullptr, iForPlayer);
803  }
804  // Con percentage
805  iValue = iValue * Con / FullCon;
806  // do any adjustments based on where the item is bought
807  if (pInBase)
808  {
809  r = pInBase->Call(PSF_CalcSellValue, &C4AulParSet(this, iValue));
810  if (r != C4VNull)
811  iValue = r.getInt();
812  }
813  return iValue;
814 }
#define PSF_CalcValue
Definition: C4GameScript.h:80
#define PSF_CalcSellValue
Definition: C4GameScript.h:92
const C4Value C4VNull
Definition: C4Value.cpp:30
int32_t GetValue(C4Object *pInBase, int32_t iBuyPlayer)
Definition: C4Def.cpp:621

References C4VNull, C4PropList::Call(), Con, Def, FullCon, C4Value::getInt(), C4Def::GetValue(), PSF_CalcSellValue, and PSF_CalcValue.

Referenced by C4SortObjectValue::CompareGetValue(), and C4ObjectMenu::DoRefillInternal().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetViewPos()

void C4Object::GetViewPos ( float &  riX,
float &  riY,
float  tx,
float  ty,
const C4Facet fctViewport 
) const

Definition at line 728 of file C4ObjectGraphics.cpp.

729 {
730  if (Category & C4D_Parallax) GetViewPosPar(riX, riY, tx, ty, fctViewport); else { riX = float(GetX()); riY = float(GetY()); }
731 }
void GetViewPosPar(float &riX, float &riY, float tx, float ty, const C4Facet &fctViewport) const

References C4D_Parallax.

Referenced by C4MouseControl::UpdateCursorTarget().

Here is the caller graph for this function:

◆ GetViewPosPar()

void C4Object::GetViewPosPar ( float &  riX,
float &  riY,
float  tx,
float  ty,
const C4Facet fctViewport 
) const

Definition at line 789 of file C4ObjectGraphics.cpp.

790 {
791  int iParX, iParY;
792  GetParallaxity(&iParX, &iParY);
793  // get drawing pos, then subtract original target pos to get drawing pos on landscape
794  if (!iParX && GetX()<0)
795  // HUD element at right viewport pos
796  riX=fixtof(fix_x)+tx+fctViewport.Wdt;
797  else
798  // regular parallaxity
799  riX=fixtof(fix_x)-(tx*(iParX-100)/100);
800  if (!iParY && GetY()<0)
801  // HUD element at bottom viewport pos
802  riY=fixtof(fix_y)+ty+fctViewport.Hgt;
803  else
804  // regular parallaxity
805  riY=fixtof(fix_y)-(ty*(iParY-100)/100);
806 }

References fix_x, fix_y, fixtof(), GetParallaxity(), GetX(), GetY(), C4Facet::Hgt, and C4Facet::Wdt.

Here is the call graph for this function:

◆ GetX()

int32_t C4Object::GetX ( ) const
inline

Definition at line 285 of file C4Object.h.

285 { return fixtoi(fix_x); }

References fix_x, and fixtoi().

Referenced by C4Command::Acquire(), C4LSectors::Add(), AssignDeath(), AssignRemoval(), At(), C4Command::Attack(), C4FindObjectInRect::Check(), C4FindObjectAtPoint::Check(), C4FindObjectAtRect::Check(), C4FindObjectOnLine::Check(), C4FindObjectDistance::Check(), C4FindObjectCone::Check(), C4Game::CheckObjectEnumeration(), C4SoundInstance::CheckStart(), ClearContentsAndContained(), C4SoundInstance::ClearPointers(), C4SortObjectDistance::CompareGetValue(), ContactAction(), C4FindObject::CreateByValue(), C4SortObject::CreateByValue(), C4GameObjects::CrossCheck(), C4Command::Dig(), DoCon(), C4EditCursor::DoContextMenu(), DoMovement(), C4EditCursor::Draw(), C4SolidMask::Draw(), Draw(), C4Command::Drop(), C4Command::Enter(), Enter(), ExecLife(), ExecMovement(), C4Command::Exit(), C4Game::FindObject(), C4Command::FlightControl(), C4Command::Follow(), C4Command::Get(), GetArea(), C4EditCursor::GetCurrentSelectionPosition(), GetEntranceArea(), GetOCFForPos(), GetViewPosPar(), C4Command::Grab(), Init(), C4Command::InitEvaluation(), C4SoundInstance::Inside(), C4EditCursor::IsHoveringTransformMarker(), IsInLiquidCheck(), C4Command::Jump(), C4Command::JumpControl(), Left(), Lift(), MakeAbsCoordinates(), C4Command::MoveTo(), ObjectActionThrow(), ObjectComDrop(), C4EditCursor::PerformDuplicationLegacy(), C4Player::PlaceReadyBase(), C4Landscape::P::PostFreeShape(), Push(), C4Command::PushTo(), C4Command::Put(), C4SolidMask::Put(), SetOCF(), SideBounds(), Stabilize(), C4Command::Throw(), C4Command::Transfer(), C4LSectors::Update(), UpdateOCF(), and C4Player::UpdateView().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetY()

int32_t C4Object::GetY ( ) const
inline

Definition at line 286 of file C4Object.h.

286 { return fixtoi(fix_y); }

References fix_y, and fixtoi().

Referenced by C4Command::Acquire(), C4LSectors::Add(), AssignDeath(), AssignRemoval(), At(), C4Command::Attack(), C4FindObjectInRect::Check(), C4FindObjectAtPoint::Check(), C4FindObjectAtRect::Check(), C4FindObjectOnLine::Check(), C4FindObjectDistance::Check(), C4FindObjectCone::Check(), C4SoundInstance::CheckStart(), ClearContentsAndContained(), C4SoundInstance::ClearPointers(), C4SortObjectDistance::CompareGetValue(), ContactAction(), C4FindObject::CreateByValue(), C4SortObject::CreateByValue(), C4GameObjects::CrossCheck(), C4Command::Dig(), DoCon(), C4EditCursor::DoContextMenu(), DoMovement(), C4EditCursor::Draw(), C4SolidMask::Draw(), Draw(), C4Command::Drop(), C4Command::Enter(), Enter(), ExecLife(), ExecMovement(), C4Command::Exit(), C4Game::FindObject(), C4Command::FlightControl(), C4Command::Follow(), C4Command::Get(), GetArea(), C4EditCursor::GetCurrentSelectionPosition(), GetEntranceArea(), GetOCFForPos(), GetViewPosPar(), C4Command::Grab(), Init(), C4Command::InitEvaluation(), C4SoundInstance::Inside(), C4EditCursor::IsHoveringTransformMarker(), IsInLiquidCheck(), C4Command::JumpControl(), Lift(), MakeAbsCoordinates(), C4Command::MoveTo(), ObjectActionThrow(), ObjectComDrop(), C4EditCursor::PerformDuplicationLegacy(), C4Landscape::P::PostFreeShape(), Push(), C4Command::PushTo(), C4Command::Put(), C4SolidMask::Put(), C4SolidMask::Remove(), SetOCF(), Stabilize(), C4Command::Throw(), Top(), C4Command::Transfer(), C4LSectors::Update(), UpdateOCF(), C4Player::UpdateView(), and VerticalBounds().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GrabContents()

void C4Object::GrabContents ( C4Object pFrom)

Definition at line 251 of file C4ObjectContents.cpp.

252 {
253  // create a temp list of all objects and transfer it
254  // this prevents nasty deadlocks caused by RejectEntrance-scripts
255  C4ObjectList tmpList; tmpList.Copy(pFrom->Contents);
256  for (C4Object *obj : tmpList)
257  if (obj->Status)
258  obj->Enter(this);
259 }
void Copy(const C4ObjectList &list)

References Contents, and C4ObjectList::Copy().

Here is the call graph for this function:

◆ GrabInfo()

bool C4Object::GrabInfo ( C4Object pFrom)

Definition at line 1153 of file C4Object.cpp.

1154 {
1155  // safety
1156  if (!pFrom) return false;
1157  if (!Status || !pFrom->Status) return false;
1158  // even more safety (own info: success)
1159  if (pFrom == this) return true;
1160  // only if other object has info
1161  if (!pFrom->Info) return false;
1162  // clear own info object
1163  if (Info)
1164  {
1165  Info->Retire();
1166  ClearInfo (Info);
1167  }
1168  // remove objects from any owning crews
1169  ::Players.ClearPointers(pFrom);
1170  ::Players.ClearPointers(this);
1171  // set info
1172  Info = pFrom->Info; pFrom->ClearInfo (pFrom->Info);
1173  // set name
1174  SetName(Info->Name);
1175  // retire from old crew
1176  Info->Retire();
1177  // if alive, recruit to new crew
1178  if (Alive) Info->Recruit();
1179  // make new crew member
1180  C4Player *pPlr = ::Players.Get(Owner);
1181  if (pPlr) pPlr->MakeCrewMember(this);
1182  // done, success
1183  return true;
1184 }
void SetName(const char *NewName=nullptr) override
Definition: C4Object.cpp:783
void ClearInfo(C4ObjectInfo *pInfo)
Definition: C4Object.cpp:1075
void ClearPointers(C4Object *pObj)

References Alive, ClearInfo(), C4PlayerList::ClearPointers(), C4PlayerList::Get(), Info, C4Player::MakeCrewMember(), C4ObjectInfoCore::Name, Owner, Players, C4ObjectInfo::Recruit(), C4ObjectInfo::Retire(), SetName(), and C4PropList::Status.

Here is the call graph for this function:

◆ HasGraphicsOverlayRecursion()

bool C4Object::HasGraphicsOverlayRecursion ( const C4Object pCheckObj) const

Definition at line 882 of file C4ObjectGraphics.cpp.

883 {
884  C4Object *pGfxOvrlObj;
885  if (pGfxOverlay)
886  for (C4GraphicsOverlay *pGfxOvrl = pGfxOverlay; pGfxOvrl; pGfxOvrl = pGfxOvrl->GetNext())
887  if ((pGfxOvrlObj = pGfxOvrl->GetOverlayObject()))
888  {
889  if (pGfxOvrlObj == pCheckObj) return true;
890  if (pGfxOvrlObj->HasGraphicsOverlayRecursion(pCheckObj)) return true;
891  }
892  return false;
893 }
bool HasGraphicsOverlayRecursion(const C4Object *pCheckObj) const

References C4GraphicsOverlay::GetNext(), HasGraphicsOverlayRecursion(), and pGfxOverlay.

Referenced by HasGraphicsOverlayRecursion(), and C4GraphicsOverlay::IsValid().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ HasProperty()

bool C4PropList::HasProperty ( C4String k) const
inlineinherited

Definition at line 122 of file C4PropList.h.

122 { return Properties.Has(k); }

References C4Set< T >::Has().

Referenced by C4AulScriptEngine::GetFunctionNames(), C4PropList::GetSortedLocalProperties(), C4MapScriptAlgo::GetXYProps(), and C4AulCompiler::ConstantResolver::visit().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ Height()

int32_t C4Object::Height ( ) const
inline

Definition at line 284 of file C4Object.h.

284 { return Shape.Hgt+addtop(); } // height of shape (+build-top)

References addtop(), C4Rect::Hgt, and Shape.

Referenced by C4LArea::Set().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ Init()

bool C4Object::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 
)

Definition at line 112 of file C4Object.cpp.

116 {
118  // currently initializing
119  Initializing=true;
120 
121  // Def & basics
122  Owner=iOwner;
123  if (iController > NO_OWNER) Controller = iController; else Controller=iOwner;
125  Info=pInfo;
126  Def=pDef->GetDef(); assert(Def);
128  id=Def->id;
129  if (Info) SetName(pInfo->Name);
131  Plane = Def->GetPlane(); assert(Plane);
132  Def->Count++;
133  if (pCreator) Layer=pCreator->Layer;
134 
135  // graphics
136  pGraphics = &Def->Graphics;
138  {
139  pMeshInstance = new StdMeshInstance(*pGraphics->Mesh, Def->GrowthType ? 1.0f : static_cast<float>(Con)/static_cast<float>(FullCon));
141  }
142  else
143  {
144  pMeshInstance = nullptr;
145  }
146  BlitMode = Def->BlitMode;
147 
148  // Position
149  if (!Def->Rotateable) { nr=0; nrdir=0; }
150  fix_x=itofix(nx);
151  fix_y=itofix(ny);
152  fix_r=itofix(nr);
153  xdir=nxdir; ydir=nydir; rdir=nrdir;
154 
155  // Initial mobility
156  if (!!xdir || !!ydir || !!rdir)
157  Mobile=true;
158 
159  // Mass
160  Mass=std::max<int32_t>(Def->Mass*Con/FullCon,1);
161 
162  // Life, energy, breath
163  if (Category & C4D_Living) Alive=true;
166 
167  // Color
168  if (Def->ColorByOwner)
169  {
170  if (ValidPlr(Owner))
172  else
173  Color=0xff; // no-owner color: blue
174  }
175 
176  // Shape & face
177  Shape=Def->Shape;
180  UpdateGraphics(false);
181  UpdateFace(true);
182 
183  // Initial audibility
185 
186  // Initial OCF
187  SetOCF();
188 
189  // finished initializing
190  Initializing=false;
191 
192  return true;
193 }
const int32_t C4D_Living
Definition: C4Def.h:43
int32_t Mass
Definition: C4Def.h:114
int32_t Category
Definition: C4Def.h:117
int32_t GetPlane()
Definition: C4Def.h:211
C4Def const * GetDef() const override
Definition: C4Def.h:214
bool CheckSolidMaskRect()
int32_t GetAudibility(int32_t x, int32_t y, int32_t *pan, int32_t audibility_radius=0, int32_t *out_player=nullptr)

References C4PropListNumbered::AcquireNumber(), Alive, Audible, AudiblePan, AudiblePlayer, C4Def::BlitMode, BlitMode, Breath, C4D_Living, C4VPropList(), C4Def::Category, Category, CheckSolidMaskRect(), Color, C4Def::ColorByOwner, C4Player::ColorDw, ColorMod, Con, Controller, C4Def::Count, Def, Energy, fix_r, fix_x, fix_y, FullCon, C4PlayerList::Get(), C4ViewportList::GetAudibility(), C4PropList::GetDef(), C4Def::GetPlane(), C4PropList::GetPropertyInt(), GetX(), GetY(), C4Def::Graphics, C4Def::GrowthType, C4Def::id, Info, Initializing, itofix(), LastEnergyLossCausePlayer, Layer, C4Def::Mass, Mass, Mobile, C4ObjectInfoCore::Name, NO_OWNER, Owner, P_MaxBreath, P_MaxEnergy, P_Prototype, pGraphics, Plane, Players, pMeshInstance, rdir, C4Def::Rotateable, StdMeshInstance::SetFaceOrderingForClrModulation(), SetName(), SetOCF(), C4PropList::SetProperty(), C4Def::Shape, Shape, C4Def::SolidMask, SolidMask, C4DefGraphics::Type, C4DefGraphics::TYPE_Mesh, UpdateFace(), UpdateGraphics(), ValidPlr(), Viewports, xdir, and ydir.

Referenced by C4Game::NewObject().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ IsFrozen()

bool C4PropList::IsFrozen ( ) const
inlineinherited

Definition at line 135 of file C4PropList.h.

135 { return constant; }

Referenced by C4PropList::ThawRecursively().

Here is the caller graph for this function:

◆ IsInLiquidCheck()

bool C4Object::IsInLiquidCheck ( ) const

Definition at line 307 of file C4ObjectPhysics.cpp.

308 {
309  return GBackLiquid(GetX(), GetY() + Def->Float * Con / FullCon - 1);
310 }

References Con, Def, C4Def::Float, FullCon, GBackLiquid(), GetX(), and GetY().

Referenced by DoMovement(), and UpdateInLiquid().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ IsMoveableBySolidMask()

bool C4Object::IsMoveableBySolidMask ( int  ComparisonPlane) const

Definition at line 555 of file C4ObjectPhysics.cpp.

556 {
557  return (Status == C4OS_NORMAL)
558  && !(Category & C4D_StaticBack)
559  && (ComparisonPlane < GetPlane())
560  && !Contained;
561 }

References C4D_StaticBack, C4OS_NORMAL, Category, Contained, GetPlane(), and C4PropList::Status.

Referenced by C4SolidMask::Put(), and C4SolidMask::Remove().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ IsNumbered()

bool C4PropListNumbered::IsNumbered ( ) const
inlineoverridevirtualinherited

Reimplemented from C4PropList.

Definition at line 225 of file C4PropList.h.

225 { return true; }

◆ IsPlayerObject()

bool C4Object::IsPlayerObject ( int32_t  iPlayerNumber = NO_OWNER) const

Definition at line 1278 of file C4Object.cpp.

1279 {
1280  bool fAnyPlr = (iPlayerNumber == NO_OWNER);
1281  // if an owner is specified: only owned objects
1282  if (fAnyPlr && !ValidPlr(Owner)) return false;
1283  // and crew objects
1284  if (fAnyPlr || Owner == iPlayerNumber)
1285  {
1286  C4Player *pOwner = ::Players.Get(Owner);
1287  if (pOwner)
1288  {
1289  if (pOwner && pOwner->Crew.IsContained(this)) return true;
1290  }
1291  else
1292  {
1293  // Do not force that the owner exists because the function must work for unjoined players (savegame resume)
1294  if (Def->CrewMember)
1295  return true;
1296  }
1297  }
1298  // otherwise, not a player object
1299  return false;
1300 }
int32_t CrewMember
Definition: C4Def.h:112
bool IsContained(const C4Object *obj) const

References C4Player::Crew, C4Def::CrewMember, Def, C4PlayerList::Get(), C4ObjectList::IsContained(), NO_OWNER, Owner, Players, and ValidPlr().

Referenced by IsUserPlayerObject().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ IsStatic() [1/2]

virtual class C4PropListStatic* C4PropList::IsStatic ( )
inlinevirtualinherited

◆ IsStatic() [2/2]

const class C4PropListStatic* C4PropList::IsStatic ( ) const
inlineinherited

Definition at line 90 of file C4PropList.h.

90 { return const_cast<C4PropList*>(this)->IsStatic(); }

References C4PropList::IsStatic().

Referenced by C4PropList::IsStatic().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ IsUserPlayerObject()

bool C4Object::IsUserPlayerObject ( )

Definition at line 1302 of file C4Object.cpp.

1303 {
1304  // must be a player object at all
1305  if (!IsPlayerObject()) return false;
1306  // and the owner must not be a script player
1307  C4Player *pOwner = ::Players.Get(Owner);
1308  if (!pOwner || pOwner->GetType() != C4PT_User) return false;
1309  // otherwise, it's a user playeer object
1310  return true;
1311 }
@ C4PT_User
Definition: C4Constants.h:154
bool IsPlayerObject(int32_t iPlayerNumber=NO_OWNER) const
Definition: C4Object.cpp:1278
C4PlayerType GetType() const
Definition: C4Player.cpp:1727

References C4PT_User, C4PlayerList::Get(), C4Player::GetType(), IsPlayerObject(), Owner, and Players.

Referenced by C4ObjectList::CompileFunc().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ IsVisible()

bool C4Object::IsVisible ( int32_t  iForPlr,
bool  fAsOverlay 
) const

Definition at line 77 of file C4ObjectVisibility.cpp.

78 {
79  bool fDraw;
80  C4Value vis;
81  if (!GetProperty(P_Visibility, &vis))
82  return true;
83 
84  int32_t Visibility;
85  C4ValueArray *parameters = vis.getArray();
86  if (parameters && parameters->GetSize())
87  {
88  Visibility = parameters->GetItem(0).getInt();
89  }
90  else
91  {
92  Visibility = vis.getInt();
93  }
94  // check layer
95  if (Layer && Layer != this && !fAsOverlay)
96  {
97  fDraw = Layer->IsVisible(iForPlr, false);
98  if (Layer->GetPropertyInt(P_Visibility) & VIS_LayerToggle) fDraw = !fDraw;
99  if (!fDraw) return false;
100  }
101  // no flags set?
102  if (!Visibility) return true;
103  // check overlay
104  if (Visibility & VIS_OverlayOnly)
105  {
106  if (!fAsOverlay) return false;
107  if (Visibility == VIS_OverlayOnly) return true;
108  }
109  // editor visibility
110  if (::Application.isEditor)
111  {
112  if (Visibility & VIS_Editor) return true;
113  }
114  // check visibility
115  fDraw=false;
116  if (Visibility & VIS_Owner) fDraw = fDraw || (iForPlr==Owner);
117  if (iForPlr!=NO_OWNER)
118  {
119  // check all
120  if (Visibility & VIS_Allies) fDraw = fDraw || (iForPlr!=Owner && !Hostile(iForPlr, Owner));
121  if (Visibility & VIS_Enemies) fDraw = fDraw || (iForPlr!=Owner && Hostile(iForPlr, Owner));
122  if (parameters)
123  {
124  if (Visibility & VIS_Select) fDraw = fDraw || parameters->GetItem(1+iForPlr).getBool();
125  }
126  }
127  else fDraw = fDraw || (Visibility & VIS_God);
128  return fDraw;
129 }
C4Application Application
Definition: C4Globals.cpp:44
#define VIS_God
Definition: C4Object.h:68
#define VIS_Owner
Definition: C4Object.h:64
#define VIS_Select
Definition: C4Object.h:67
#define VIS_Enemies
Definition: C4Object.h:66
#define VIS_OverlayOnly
Definition: C4Object.h:70
#define VIS_LayerToggle
Definition: C4Object.h:69
#define VIS_Editor
Definition: C4Object.h:71
#define VIS_Allies
Definition: C4Object.h:65
int32_t Hostile(int32_t plr1, int32_t plr2)
@ P_Visibility
int32_t GetSize() const
Definition: C4ValueArray.h:36

References Application, C4Value::getArray(), C4Value::getBool(), C4Value::getInt(), C4ValueArray::GetItem(), C4PropList::GetProperty(), C4PropList::GetPropertyInt(), C4ValueArray::GetSize(), Hostile(), C4Application::isEditor, IsVisible(), Layer, NO_OWNER, Owner, P_Visibility, VIS_Allies, VIS_Editor, VIS_Enemies, VIS_God, VIS_LayerToggle, VIS_OverlayOnly, VIS_Owner, and VIS_Select.

Referenced by Draw(), C4GameMessage::Draw(), C4Game::DrawCrewOverheadText(), DrawTopFace(), IsVisible(), and C4ScriptGuiWindow::IsVisibleTo().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ Left()

int32_t C4Object::Left ( ) const
inline

Definition at line 281 of file C4Object.h.

281 { return GetX()+Shape.x; } // left border of shape

References GetX(), Shape, and C4Rect::x.

Referenced by C4LArea::Set().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ Lift()

bool C4Object::Lift ( C4Real  tydir,
C4Real  dforce 
)

Definition at line 203 of file C4ObjectPhysics.cpp.

204 {
205  // Valid check
206  if (!Status || !Def || Contained)
207  {
208  return false;
209  }
210  // Mobilization check
211  if (!Mobile)
212  {
213  xdir = ydir = Fix0;
214  Mobile = true;
215  }
216  // General pushing force vs. object mass
217  dforce = dforce * 100 / Mass;
218  // If close enough, set tydir
219  if (Abs(tydir - ydir) <= Abs(dforce))
220  {
221  ydir = tydir;
222  }
223  else // Work towards tydir
224  {
225  if (ydir<tydir) ydir+=dforce;
226  if (ydir>tydir) ydir-=dforce;
227  }
228  // Stuck check
229  if (tydir != -GravAccel
230  && ContactCheck(GetX(), GetY())) // Resets t_contact
231  {
232  GameMsgObjectError(FormatString(LoadResStr("IDS_OBJ_STUCK"), GetName()).getData(), this);
233  Call(PSF_Stuck);
234  }
235  return true;
236 }
void GameMsgObjectError(const char *szText, C4Object *pTarget, bool Red)
#define PSF_Stuck
Definition: C4GameScript.h:74

References Abs(), C4PropList::Call(), ContactCheck(), Contained, Def, Fix0, FormatString(), GameMsgObjectError(), C4PropList::GetName(), GetX(), GetY(), GravAccel, LoadResStr(), Mass, Mobile, PSF_Stuck, C4PropList::Status, xdir, and ydir.

Here is the call graph for this function:

◆ MenuCommand()

bool C4Object::MenuCommand ( const char *  szCommand)

Definition at line 161 of file C4ObjectMenuLogic.cpp.

162 {
163  // Native script execution
164  if (!Def || !Status) return false;
165  return !! ::AulExec.DirectExec(this, szCommand, "MenuCommand");
166 }
C4AulExec AulExec
Definition: C4AulExec.cpp:29
C4Value DirectExec(C4PropList *p, const char *szScript, const char *szContext, bool fPassErrors=false, C4AulScriptContext *context=nullptr, bool parse_function=false)
Definition: C4AulExec.cpp:1012

References AulExec, Def, C4AulExec::DirectExec(), and C4PropList::Status.

Referenced by C4ObjectMenu::MenuCommand().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ MovePosition() [1/2]

void C4Object::MovePosition ( C4Real  dx,
C4Real  dy 
)

Definition at line 680 of file C4Movement.cpp.

681 {
682  // Move object position; repositions SolidMask
683  RemoveSolidMask(true);
684  fix_x += distance_x;
685  fix_y += distance_y;
686  UpdatePos();
687  UpdateSolidMask(true);
688 }

References fix_x, fix_y, UpdatePos(), and UpdateSolidMask().

Here is the call graph for this function:

◆ MovePosition() [2/2]

void C4Object::MovePosition ( int32_t  dx,
int32_t  dy 
)

Definition at line 675 of file C4Movement.cpp.

676 {
677  MovePosition(itofix(distance_x), itofix(distance_y));
678 }

References itofix().

Referenced by C4SolidMask::Put().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ New()

C4PropList * C4PropList::New ( C4PropList prototype = nullptr)
staticinherited

Definition at line 40 of file C4PropList.cpp.

41 {
42  C4PropList * r = new C4PropListScript(prototype);
43  return r;
44 }

Referenced by CompileNewFunc(), FnPlaceVegetation(), C4ScriptGuiWindowProperty::ToC4Value(), C4ScriptGuiWindow::ToC4Value(), and C4AulCompiler::ConstexprEvaluator::visit().

Here is the caller graph for this function:

◆ NewStatic()

C4PropListStatic * C4PropList::NewStatic ( C4PropList prototype,
const C4PropListStatic parent,
C4String key 
)
staticinherited

Definition at line 46 of file C4PropList.cpp.

47 {
48  return new C4PropListStatic(prototype, parent, key);
49 }

Referenced by C4PropListScen::C4PropListScen(), C4ScriptHost::CopyPropList(), C4PropList::FreezeAndMakeStaticRecursively(), C4ScenarioParameterDefs::RegisterScriptConstants(), and C4AulCompiler::ConstexprEvaluator::visit().

Here is the caller graph for this function:

◆ NoAttachAction()

void C4Object::NoAttachAction ( )

Definition at line 369 of file C4ObjectAction.cpp.

370 {
371  // Active objects
372  if (GetAction())
373  {
374  int32_t iProcedure = GetProcedure();
375  C4Object *prev_target = Action.Target;
376  // Scaling upwards: corner scale
377  if (iProcedure == DFA_SCALE && Action.ComDir != COMD_Stop && ComDirLike(Action.ComDir, COMD_Up))
378  if (ObjectActionCornerScale(this)) return;
379  if (iProcedure == DFA_SCALE && Action.ComDir == COMD_Left && Action.Dir == DIR_Left)
380  if (ObjectActionCornerScale(this)) return;
381  if (iProcedure == DFA_SCALE && Action.ComDir == COMD_Right && Action.Dir == DIR_Right)
382  if (ObjectActionCornerScale(this)) return;
383  // Scaling and stopped: fall off to side (avoid zuppel)
384  if ((iProcedure == DFA_SCALE) && (Action.ComDir == COMD_Stop))
385  {
386  if (Action.Dir == DIR_Left)
387  { if (ObjectActionJump(this,itofix(1),Fix0,false)) return; }
388  else
389  { if (ObjectActionJump(this,itofix(-1),Fix0,false)) return; }
390  }
391  // Pushing: grab loss
392  if (iProcedure==DFA_PUSH) GrabLost(this, prev_target);
393  // Else jump
394  ObjectActionJump(this,xdir,ydir,false);
395  }
396  // Inactive objects, simple mobile natural gravity
397  else
398  {
399  DoGravity(this);
400  Mobile=true;
401  }
402 }

References Action, COMD_Left, COMD_Right, COMD_Stop, COMD_Up, C4Action::ComDir, ComDirLike(), DFA_PUSH, DFA_SCALE, C4Action::Dir, DIR_Left, DIR_Right, Fix0, GetAction(), GetProcedure(), GrabLost(), itofix(), ObjectActionCornerScale(), ObjectActionJump(), C4Action::Target, xdir, and ydir.

Referenced by DoMovement().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ operator==()

bool C4PropList::operator== ( const C4PropList b) const
inherited

Definition at line 348 of file C4PropList.cpp.

349 {
350  // every numbered proplist has a unique number and is only identical to itself
351  if (this == &b) return true;
352  if (IsNumbered() || b.IsNumbered()) return false;
353  if (Properties.GetSize() != b.Properties.GetSize()) return false;
354  if (GetDef() != b.GetDef()) return false;
355  const C4Property * p = Properties.First();
356  while (p)
357  {
358  const C4Property & bp = b.Properties.Get(p->Key);
359  if (!bp) return false;
360  if (p->Value != bp.Value) return false;
361  p = Properties.Next(p);
362  }
363  return true;
364 }
virtual bool IsNumbered() const
Definition: C4PropList.h:92

References b, C4Set< T >::First(), C4PropList::GetDef(), C4Set< T >::GetSize(), C4PropList::IsNumbered(), C4Property::Key, C4Set< T >::Next(), and C4Property::Value.

Here is the call graph for this function:

◆ Picture2Facet()

void C4Object::Picture2Facet ( C4FacetSurface cgo)

Definition at line 625 of file C4ObjectGraphics.cpp.

626 {
627  // set picture rect to facet
628  C4Rect fctPicRect = PictureRect;
629  if (!fctPicRect.Wdt) fctPicRect = Def->PictureRect;
630  C4Facet fctPicture;
631  fctPicture.Set(GetGraphics()->GetBitmap(Color),fctPicRect.x,fctPicRect.y,fctPicRect.Wdt,fctPicRect.Hgt);
632 
633  // use direct facet w/o own data if possible
634  if (ColorMod == 0xffffffff && BlitMode == C4GFXBLIT_NORMAL && !pGfxOverlay)
635  {
636  cgo.Set(fctPicture);
637  return;
638  }
639 
640  // otherwise, draw to picture facet
641  if (!cgo.Create(cgo.Wdt, cgo.Hgt)) return;
642 
643  // specific object color?
644  PrepareDrawing();
645 
646  // draw picture itself
647  fctPicture.Draw(cgo,true);
648 
649  // draw overlays
650  if (pGfxOverlay)
651  for (C4GraphicsOverlay *pGfxOvrl = pGfxOverlay; pGfxOvrl; pGfxOvrl = pGfxOvrl->GetNext())
652  if (pGfxOvrl->IsPicture())
653  pGfxOvrl->DrawPicture(cgo, this, nullptr);
654 
655  // done; reset drawing states
656  FinishedDrawing();
657 }
#define C4GFXBLIT_NORMAL
Definition: C4Surface.h:25
C4Rect PictureRect
Definition: C4Def.h:107
void Set(C4Surface &rSfc)
Definition: C4Facet.cpp:459
void Draw(C4Facet &cgo, bool fAspect=true, int32_t iPhaseX=0, int32_t iPhaseY=0, bool fTransparent=true)
Definition: C4Facet.cpp:154
void Set(const C4Facet &cpy)
Definition: C4FacetEx.h:46
Definition: C4Rect.h:28

References BlitMode, C4GFXBLIT_NORMAL, Color, ColorMod, C4FacetSurface::Create(), Def, C4Facet::Draw(), FinishedDrawing(), GetGraphics(), C4GraphicsOverlay::GetNext(), C4Facet::Hgt, C4Rect::Hgt, pGfxOverlay, C4Def::PictureRect, PictureRect, PrepareDrawing(), C4Facet::Set(), C4FacetSurface::Set(), C4Facet::Wdt, C4Rect::Wdt, C4Rect::x, and C4Rect::y.

Referenced by C4ObjectMenu::DoRefillInternal().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ PrepareDrawing()

void C4Object::PrepareDrawing ( ) const

Definition at line 680 of file C4ObjectGraphics.cpp.

681 {
682  // color modulation
684  // other blit modes
686 }
#define C4GFXBLIT_MOD2
Definition: C4Surface.h:27
#define C4GFXBLIT_CLRSFC_MOD2
Definition: C4Surface.h:29
void SetBlitMode(DWORD dwBlitMode)
Definition: C4Draw.h:191
void ActivateBlitModulation(DWORD dwWithClr)
Definition: C4Draw.h:188

References C4Draw::ActivateBlitModulation(), BlitMode, C4GFXBLIT_CLRSFC_MOD2, C4GFXBLIT_MOD2, ColorMod, pDraw, and C4Draw::SetBlitMode().

Referenced by C4DefGraphics::Draw(), Draw(), DrawLine(), C4GraphicsOverlay::DrawPicture(), DrawTopFace(), and Picture2Facet().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ Promote()

bool C4Object::Promote ( int32_t  torank,
bool  exception,
bool  fForceRankName 
)

Definition at line 46 of file C4ObjectRank.cpp.

47 {
48  if (!Info) return false;
49  // get rank system
50  C4Def *pUseDef = C4Id2Def(Info->id);
51  C4RankSystem *pRankSys;
52  if (pUseDef && pUseDef->pRankNames)
53  pRankSys = pUseDef->pRankNames;
54  else
55  pRankSys = &::DefaultRanks;
56  // always promote info
57  Info->Promote(torank,*pRankSys, fForceRankName);
58  // silent update?
59  if (!pRankSys->GetRankName(torank,false)) return false;
60  GameMsgObject(FormatString(LoadResStr("IDS_OBJ_PROMOTION"),GetName (),Info->sRankName.getData()).getData(),this);
61 
62  // call to object
64 
65  StartSoundEffect("UI::Trumpet",false,100,this);
66  return true;
67 }
#define PSF_Promotion
Definition: C4GameScript.h:147
C4RankSystem * pRankNames
Definition: C4Def.h:188
void Promote(int32_t iRank, C4RankSystem &rRanks, bool fForceRankName)
Definition: C4InfoCore.cpp:252
StdStrBuf sRankName
Definition: C4InfoCore.h:40
StdStrBuf GetRankName(int iRank, bool fReturnLastIfOver)

References C4Id2Def(), C4PropList::Call(), DefaultRanks, FormatString(), GameMsgObject(), StdStrBuf::getData(), C4PropList::GetName(), C4RankSystem::GetRankName(), C4ObjectInfoCore::id, Info, LoadResStr(), C4Def::pRankNames, C4ObjectInfoCore::Promote(), PSF_Promotion, C4ObjectInfoCore::sRankName, and StartSoundEffect().

Referenced by C4Player::CheckCrewExPromotion(), and DoExperience().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ Push()

bool C4Object::Push ( C4Real  txdir,
C4Real  dforce,
bool  fStraighten 
)

Definition at line 126 of file C4ObjectPhysics.cpp.

127 {
128  // Valid check
129  if (!Status || !Def || Contained || !(OCF & OCF_Grab))
130  {
131  return false;
132  }
133  // Grabbing okay, no pushing
134  if (GetPropertyInt(P_Touchable) == 2)
135  {
136  return true;
137  }
138  // Mobilization check (pre-mobilization zero)
139  if (!Mobile)
140  {
141  xdir = ydir = Fix0;
142  }
143  // General pushing force vs. object mass
144  dforce = dforce * 100 / Mass;
145  // Set dir
146  if (xdir < 0) SetDir(DIR_Left);
147  if (xdir > 0) SetDir(DIR_Right);
148  // Work towards txdir
149  if (Abs(xdir - txdir) <= dforce) // Close-enough-set
150  {
151  xdir = txdir;
152  }
153  else // Work towards
154  {
155  if (xdir < txdir) xdir += dforce;
156  if (xdir > txdir) xdir -= dforce;
157  }
158  // Straighten
159  if (fStraighten)
160  {
161  if (Inside<int32_t>(GetR(), -StableRange, +StableRange))
162  {
163  rdir = 0; // Cheap way out
164  }
165  else
166  {
167  if (fix_r > Fix0)
168  {
169  if (rdir > -RotateAccel)
170  {
171  rdir -= dforce;
172  }
173  }
174  else
175  {
176  if (rdir < +RotateAccel)
177  {
178  rdir += dforce;
179  }
180  }
181  }
182  }
183 
184  // Mobilization check
185  if (!!xdir || !!ydir || !!rdir)
186  {
187  Mobile = true;
188  }
189 
190  // Stuck check
191  if (!::Game.iTick35
192  && txdir
193  && !Def->NoHorizontalMove
194  && ContactCheck(GetX(), GetY())) // Resets t_contact
195  {
196  GameMsgObjectError(FormatString(LoadResStr("IDS_OBJ_STUCK"), GetName()).getData(), this);
197  Call(PSF_Stuck);
198  }
199 
200  return true;
201 }
const uint32_t OCF_Grab
Definition: C4Constants.h:81
const C4Real RotateAccel
Definition: C4Movement.cpp:36
@ P_Touchable

References Abs(), C4PropList::Call(), ContactCheck(), Contained, Def, DIR_Left, DIR_Right, Fix0, fix_r, FormatString(), Game, GameMsgObjectError(), C4PropList::GetName(), C4PropList::GetPropertyInt(), GetR(), GetX(), GetY(), C4Game::iTick35, LoadResStr(), Mass, Mobile, C4Def::NoHorizontalMove, OCF, OCF_Grab, P_Touchable, PSF_Stuck, rdir, RotateAccel, SetDir(), StableRange, C4PropList::Status, xdir, and ydir.

Here is the call graph for this function:

◆ PutAwayUnusedObject()

bool C4Object::PutAwayUnusedObject ( C4Object pToMakeRoomForObject)

Definition at line 164 of file C4ObjectCommand.cpp.

165 {
166  // get unused object
167  C4Object *pUnusedObject;
168  C4AulFunc *pFnObj2Drop = GetFunc(PSF_GetObject2Drop);
169  if (pFnObj2Drop)
170  pUnusedObject = pFnObj2Drop->Exec(this, &C4AulParSet(pToMakeRoomForObject)).getObj();
171  else
172  {
173  // is there any unused object to put away?
174  if (!Contents.GetLastObject()) return false;
175  // defaultly, it's the last object in the list
176  // (contents list cannot have invalid status-objects)
177  pUnusedObject = Contents.GetLastObject();
178  }
179  // no object to put away? fail
180  if (!pUnusedObject) return false;
181  // grabbing something?
182  bool fPushing = (GetProcedure()==DFA_PUSH);
183  if (fPushing)
184  // try to put it in there
185  if (ObjectComPut(this, Action.Target, pUnusedObject))
186  return true;
187  // in container? put in there
188  if (Contained)
189  {
190  // try to put it in directly
191  // note that this works too, if an object is grabbed inside the container
192  if (ObjectComPut(this, Contained, pUnusedObject))
193  return true;
194  // now putting didn't work - drop it outside
195  AddCommand(C4CMD_Drop, pUnusedObject);
197  return true;
198  }
199  else
200  // if uncontained, simply try to drop it
201  // if this doesn't work, it won't ever
202  return !!ObjectComDrop(this, pUnusedObject);
203 }
@ C4CMD_Drop
Definition: C4Command.h:40
#define PSF_GetObject2Drop
Definition: C4GameScript.h:87
bool ObjectComPut(C4Object *cObj, C4Object *pTarget, C4Object *pThing)
bool ObjectComDrop(C4Object *cObj, C4Object *pThing)
C4Object * GetLastObject() const
Definition: C4ObjectList.h:142

References Action, AddCommand(), C4CMD_Drop, C4CMD_Exit, Contained, Contents, DFA_PUSH, C4AulFunc::Exec(), C4PropList::GetFunc(), C4ObjectList::GetLastObject(), C4Value::getObj(), GetProcedure(), ObjectComDrop(), ObjectComPut(), PSF_GetObject2Drop, and C4Action::Target.

Referenced by C4Command::GetTryEnter().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ RemoveCyclicPrototypes()

void C4PropList::RemoveCyclicPrototypes ( )
inherited

Definition at line 399 of file C4PropList.cpp.

400 {
401  // clear any cyclic prototype chains
402  // Use prototype.getPropList() instead of GetPrototype() because denumeration might not be completed yet
403  for(C4PropList * it = prototype.getPropList(); it; it = it->prototype.getPropList())
404  if(it == this)
405  {
406  prototype.Set0();
407  }
408 }
void Set0()
Definition: C4Value.h:332

References C4Value::getPropList(), and C4Value::Set0().

Referenced by C4PropList::Denumerate().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ RemoveGraphicsOverlay()

bool C4Object::RemoveGraphicsOverlay ( int32_t  iOverlayID)

Definition at line 863 of file C4ObjectGraphics.cpp.

864 {
865  // search in list until ID is found or passed
866  C4GraphicsOverlay *pOverlay = pGfxOverlay, *pPrevOverlay = nullptr;
867  while (pOverlay && pOverlay->GetID() < iOverlayID) { pPrevOverlay = pOverlay; pOverlay = pOverlay->GetNext(); }
868  // exact match found?
869  if (pOverlay && pOverlay->GetID() == iOverlayID)
870  {
871  // remove it
872  if (pPrevOverlay) pPrevOverlay->SetNext(pOverlay->GetNext()); else pGfxOverlay = pOverlay->GetNext();
873  pOverlay->SetNext(nullptr); // prevents deletion of following overlays
874  delete pOverlay;
875  // removed
876  return true;
877  }
878  // no match found
879  return false;
880 }

References C4GraphicsOverlay::GetID(), C4GraphicsOverlay::GetNext(), pGfxOverlay, and C4GraphicsOverlay::SetNext().

Referenced by ClearPointers().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ResetEnumerationIndex()

void C4PropListNumbered::ResetEnumerationIndex ( )
staticinherited

Definition at line 75 of file C4PropList.cpp.

76 {
77  assert(!PropLists.GetSize());
78  EnumerationIndex = 0;
79 }

References C4PropListNumbered::EnumerationIndex, C4Set< T >::GetSize(), and C4PropListNumbered::PropLists.

Referenced by C4Game::Clear().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ResetProperty()

void C4Object::ResetProperty ( C4String k)
overridevirtual

Reimplemented from C4PropList.

Definition at line 1328 of file C4Object.cpp.

1329 {
1330  if (k >= &Strings.P[0] && k < &Strings.P[P_LAST])
1331  {
1332  switch(k - &Strings.P[0])
1333  {
1334  case P_Plane:
1336  return;
1337  }
1338  }
1340 }
void SetPlane(int32_t z)
Definition: C4Object.h:178
virtual void ResetProperty(C4String *k)
Definition: C4PropList.cpp:961

References C4PropList::GetPropertyInt(), C4StringTable::P, P_LAST, P_Plane, C4PropList::ResetProperty(), SetPlane(), and Strings.

Referenced by ChangeDef().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ Resort()

void C4Object::Resort ( )

Definition at line 1121 of file C4Object.cpp.

1122 {
1123  // Flag resort
1124  Unsorted=true;
1125  Game.fResortAnyObject = true;
1126  // Must not immediately resort - link change/removal would crash Game::ExecObjects
1127 }

References C4Game::fResortAnyObject, Game, and Unsorted.

Referenced by SetCategory(), and SetPlane().

Here is the caller graph for this function:

◆ SetAction()

bool C4Object::SetAction ( C4PropList Act,
C4Object pTarget = nullptr,
C4Object pTarget2 = nullptr,
int32_t  iCalls = SAC_StartCall | SAC_AbortCall,
bool  fForce = false 
)

Definition at line 173 of file C4ObjectAction.cpp.

174 {
175  C4Value vLastAction;
176  GetProperty(P_Action, &vLastAction);
177  C4PropList * LastAction = vLastAction.getPropList();
178  int32_t iLastPhase=Action.Phase;
179  C4Object *pLastTarget = Action.Target;
180  C4Object *pLastTarget2 = Action.Target2;
181  // No other action
182  if (LastAction)
183  if (LastAction->GetPropertyInt(P_NoOtherAction) && !fForce)
184  if (Act != LastAction)
185  return false;
186  // Set animation on instance. Abort if the mesh does not have
187  // such an animation.
188  if (pMeshInstance)
189  {
191  Action.Animation = nullptr;
192 
193  C4String* Animation = Act ? Act->GetPropertyStr(P_Animation) : nullptr;
194  if (Animation)
195  {
196  // note that weight is ignored
197  Action.Animation = pMeshInstance->PlayAnimation(Animation->GetData(), 0, nullptr, new C4ValueProviderAction(this), new C4ValueProviderConst(itofix(1)), true);
198  }
199  }
200  // Stop previous act sound
201  if (LastAction)
202  if (Act != LastAction)
203  if (LastAction->GetPropertyStr(P_Sound))
204  StopSoundEffect(LastAction->GetPropertyStr(P_Sound)->GetCStr(),this);
205  // Unfullcon objects no action
206  if (Con<FullCon)
207  if (!Def->IncompleteActivity)
208  Act = nullptr;
209  // Reset action time on change
210  if (Act!=LastAction)
211  {
212  Action.Time=0;
213  // reset action data and targets if procedure is changed
214  if ((Act ? Act->GetPropertyP(P_Procedure) : -1)
215  != (LastAction ? LastAction->GetPropertyP(P_Procedure) : -1))
216  {
217  Action.Data = 0;
218  Action.Target = nullptr;
219  Action.Target2 = nullptr;
220  }
221  }
222  // Set new action
225  // Set target if specified
226  if (pTarget) Action.Target=pTarget;
227  if (pTarget2) Action.Target2=pTarget2;
228  // Set Action Facet
230  // update flipdir
231  if ((LastAction ? LastAction->GetPropertyInt(P_FlipDir) : 0)
232  != (Act ? Act->GetPropertyInt(P_FlipDir) : 0)) UpdateFlipDir();
233  // Start act sound
234  if (Act)
235  if (Act != LastAction)
236  if (Act->GetPropertyStr(P_Sound))
237  StartSoundEffect(Act->GetPropertyStr(P_Sound)->GetCStr(),+1,100,this);
238  // Reset OCF
239  SetOCF();
240  // issue calls
241  // Execute EndCall for last action
242  if (iCalls & SAC_EndCall && !fForce)
243  if (LastAction)
244  {
245  if (LastAction->GetPropertyStr(P_EndCall))
246  {
247  C4Def *pOldDef = Def;
248  Call(LastAction->GetPropertyStr(P_EndCall)->GetCStr());
249  // abort exeution if def changed
250  if (Def != pOldDef || !Status) return true;
251  }
252  }
253  // Execute AbortCall for last action
254  if (iCalls & SAC_AbortCall && !fForce)
255  if (LastAction)
256  {
257  if (LastAction->GetPropertyStr(P_AbortCall))
258  {
259  C4Def *pOldDef = Def;
260  if (pLastTarget && !pLastTarget->Status) pLastTarget = nullptr;
261  if (pLastTarget2 && !pLastTarget2->Status) pLastTarget2 = nullptr;
262  Call(LastAction->GetPropertyStr(P_AbortCall)->GetCStr(), &C4AulParSet(iLastPhase, pLastTarget, pLastTarget2));
263  // abort exeution if def changed
264  if (Def != pOldDef || !Status) return true;
265  }
266  }
267  // Execute StartCall for new action
268  if (iCalls & SAC_StartCall)
269  if (Act)
270  {
271  if (Act->GetPropertyStr(P_StartCall))
272  {
273  C4Def *pOldDef = Def;
275  // abort exeution if def changed
276  if (Def != pOldDef || !Status) return true;
277  }
278  }
279 
280  C4Def *pOldDef = Def;
281  Call(PSF_OnActionChanged, &C4AulParSet(LastAction ? LastAction->GetName() : "Idle"));
282  if (Def != pOldDef || !Status) return true;
283 
284  return true;
285 }
#define PSF_OnActionChanged
Definition: C4GameScript.h:152
void StopSoundEffect(const char *szSndName, C4Object *pObj)
@ P_EndCall
@ P_NoOtherAction
@ P_FlipDir
@ P_AbortCall
@ P_StartCall
@ P_Animation
@ P_Sound
void UpdateFlipDir()
void UpdateActionFace()
StdStrBuf GetData() const
Definition: C4StringTable.h:50
AnimationNode * PlayAnimation(const StdStrBuf &animation_name, int slot, AnimationNode *sibling, ValueProvider *position, ValueProvider *weight, bool stop_previous_animation)
Definition: StdMesh.cpp:1167
void StopAnimation(AnimationNode *node)
Definition: StdMesh.cpp:1190

References Action, C4Action::Animation, C4VPropList(), C4PropList::Call(), Con, C4Action::Data, Def, FullCon, C4String::GetCStr(), C4String::GetData(), C4PropList::GetName(), C4PropList::GetProperty(), C4PropList::GetPropertyInt(), C4PropList::GetPropertyP(), C4PropList::GetPropertyStr(), C4Value::getPropList(), C4Def::IncompleteActivity, itofix(), P_AbortCall, P_Action, P_Animation, P_EndCall, P_FlipDir, P_NoOtherAction, P_Procedure, P_Sound, P_StartCall, C4Action::Phase, C4Action::PhaseDelay, StdMeshInstance::PlayAnimation(), pMeshInstance, PSF_OnActionChanged, SAC_AbortCall, SAC_EndCall, SAC_StartCall, SetOCF(), C4PropList::SetProperty(), StartSoundEffect(), C4PropList::Status, StdMeshInstance::StopAnimation(), StopSoundEffect(), C4Action::Target, C4Action::Target2, C4Action::Time, UpdateActionFace(), and UpdateFlipDir().

Referenced by AssignRemoval(), ChangeDef(), DoCon(), ExecAction(), ObjectComCancelAttach(), and SetActionByName().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ SetActionByName() [1/2]

bool C4Object::SetActionByName ( C4String ActName,
C4Object pTarget = nullptr,
C4Object pTarget2 = nullptr,
int32_t  iCalls = SAC_StartCall | SAC_AbortCall,
bool  fForce = false 
)

Definition at line 306 of file C4ObjectAction.cpp.

309 {
310  assert(ActName);
311  // If we get the null string or ActIdle by name, set ActIdle
312  if (!ActName || ActName == &Strings.P[P_Idle])
313  return SetAction(nullptr,nullptr,nullptr,iCalls,fForce);
314  C4Value ActMap; GetProperty(P_ActMap, &ActMap);
315  if (!ActMap.getPropList()) return false;
316  C4Value Action; ActMap.getPropList()->GetPropertyByS(ActName, &Action);
317  if (!Action.getPropList()) return false;
318  return SetAction(Action.getPropList(),pTarget,pTarget2,iCalls,fForce);
319 }
@ P_Idle
@ P_ActMap

References Action, C4PropList::GetProperty(), C4PropList::GetPropertyByS(), C4Value::getPropList(), C4StringTable::P, P_ActMap, P_Idle, SetAction(), and Strings.

Referenced by AssignDeath(), ExecAction(), C4Command::FlightControl(), ObjectActionDig(), ObjectActionDive(), ObjectActionFlat(), ObjectActionGetPunched(), ObjectActionHangle(), ObjectActionJump(), ObjectActionKneel(), ObjectActionPush(), ObjectActionScale(), ObjectActionThrow(), ObjectActionTumble(), ObjectActionWalk(), ObjectComStop(), SetActionByName(), and SetDir().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ SetActionByName() [2/2]

bool C4Object::SetActionByName ( const char *  szActName,
C4Object pTarget = nullptr,
C4Object pTarget2 = nullptr,
int32_t  iCalls = SAC_StartCall | SAC_AbortCall,
bool  fForce = false 
)

Definition at line 321 of file C4ObjectAction.cpp.

324 {
325  C4String * ActName = Strings.RegString(szActName);
326  ActName->IncRef();
327  bool r = SetActionByName(ActName, pTarget, pTarget2, iCalls, fForce);
328  ActName->DecRef();
329  return r;
330 }
void DecRef()
Definition: C4StringTable.h:28
void IncRef()
Definition: C4StringTable.h:27
C4String * RegString(StdStrBuf String)

References C4RefCnt::DecRef(), C4RefCnt::IncRef(), C4StringTable::RegString(), SetActionByName(), and Strings.

Here is the call graph for this function:

◆ SetAlive()

void C4Object::SetAlive ( bool  Alive)
inline

Definition at line 303 of file C4Object.h.

303 { this->Alive = Alive; SetOCF(); }

References Alive, and SetOCF().

Here is the call graph for this function:

◆ SetAudibilityAt()

void C4Object::SetAudibilityAt ( C4TargetFacet cgo,
int32_t  iX,
int32_t  iY,
int32_t  player 
)

Definition at line 63 of file C4ObjectVisibility.cpp.

64 {
65  // target pos (parallax)
66  float offX, offY, newzoom;
67  GetDrawPosition(cgo, iX, iY, cgo.Zoom, offX, offY, newzoom);
68  int32_t audible_at_pos = Clamp(100 - 100 * Distance(cgo.X + cgo.Wdt / 2, cgo.Y + cgo.Hgt / 2, offX, offY) / 700, 0, 100);
69  if (audible_at_pos > Audible)
70  {
71  Audible = audible_at_pos;
72  AudiblePan = Clamp<int>(200 * (offX - cgo.X - (cgo.Wdt / 2)) / cgo.Wdt, -100, 100);
74  }
75 }
int32_t Distance(int32_t iX1, int32_t iY1, int32_t iX2, int32_t iY2)
Definition: Standard.cpp:25

References Audible, AudiblePan, AudiblePlayer, Clamp(), Distance(), GetDrawPosition(), C4Facet::Hgt, C4ScriptGuiWindowPropertyName::player, C4Facet::Wdt, C4Facet::X, C4Facet::Y, and C4TargetFacet::Zoom.

Referenced by Draw(), and DrawLine().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ SetCategory()

void C4Object::SetCategory ( int32_t  Category)
inline

Definition at line 256 of file C4Object.h.

256 { this->Category = Category; Resort(); SetOCF(); }
void Resort()
Definition: C4Object.cpp:1121

References Category, Resort(), and SetOCF().

Here is the call graph for this function:

◆ SetCommand() [1/2]

void C4Object::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 
)

Definition at line 93 of file C4ObjectCommand.cpp.

96 {
97  // Clear stack
98  ClearCommands();
99  // Close menu
100  if (fControl)
101  if (!CloseMenu(false)) return;
102  // Script overload
103  if (fControl)
105  pTarget,
106  iTx,
107  iTy,
108  pTarget2,
109  iData)))
110  return;
111  // Inside vehicle control overload
112  if (Contained)
114  {
117  pTarget,
118  iTx,
119  iTy,
120  pTarget2,
121  iData,
122  this)))
123  return;
124  }
125  // Outside vehicle control overload
126  if (GetProcedure()==DFA_PUSH)
128  {
131  pTarget,
132  iTx,
133  iTy,
134  pTarget2,
135  iData)))
136  return;
137  }
138  // Add new command
139  AddCommand(iCommand,pTarget,iTx,iTy,0,pTarget2,true,iData,false,iRetries,szText,C4CMD_Mode_Base);
140 }
const int32_t C4CMD_Mode_Base
Definition: C4Command.h:60
const int32_t C4D_VehicleControl_Outside
Definition: C4Def.h:77
const int32_t C4D_VehicleControl_Inside
Definition: C4Def.h:78
#define PSF_ControlCommand
Definition: C4GameScript.h:70
int32_t VehicleControl
Definition: C4Def.h:133

References Action, AddCommand(), C4CMD_Mode_Base, C4D_VehicleControl_Inside, C4D_VehicleControl_Outside, C4PropList::Call(), ClearCommands(), CloseMenu(), CommandName(), Contained, Controller, Def, DFA_PUSH, GetProcedure(), PSF_ControlCommand, C4Action::Target, and C4Def::VehicleControl.

Referenced by C4Command::Activate(), C4Command::Enter(), C4Player::PlaceReadyVehic(), and SetCommand().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ SetCommand() [2/2]

void C4Object::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 
)
inline

Definition at line 182 of file C4Object.h.

183  { SetCommand(iCommand, pTarget, C4VInt(iTx), iTy, pTarget2, fControl, iData, iRetries, szText); }

References C4VInt(), and SetCommand().

Here is the call graph for this function:

◆ SetDir()

void C4Object::SetDir ( int32_t  tdir)

Definition at line 332 of file C4ObjectAction.cpp.

333 {
334  // Not active
335  C4PropList* pActionDef = GetAction();
336  if (!pActionDef) return;
337  // Invalid direction
338  if (!Inside<int32_t>(iDir,0,pActionDef->GetPropertyInt(P_Directions)-1)) return;
339  // Execute turn action
340  if (iDir != Action.Dir)
341  if (pActionDef->GetPropertyStr(P_TurnAction))
342  { SetActionByName(pActionDef->GetPropertyStr(P_TurnAction)); }
343  // Set dir
344  Action.Dir=iDir;
345  // update by flipdir?
346  if (pActionDef->GetPropertyInt(P_FlipDir))
347  UpdateFlipDir();
348  else
349  Action.DrawDir=iDir;
350 }
@ P_Directions
@ P_TurnAction

References Action, C4Action::Dir, C4Action::DrawDir, GetAction(), C4PropList::GetPropertyInt(), C4PropList::GetPropertyStr(), P_Directions, P_FlipDir, P_TurnAction, SetActionByName(), and UpdateFlipDir().

Referenced by ChangeDef(), ContactAction(), C4Command::InitEvaluation(), ObjectActionFlat(), ObjectActionScale(), ObjectActionTumble(), Push(), and C4Command::Throw().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ SetEnumerationIndex()

void C4PropListNumbered::SetEnumerationIndex ( int32_t  iMaxObjectNumber)
staticinherited

Definition at line 69 of file C4PropList.cpp.

70 {
71  // update object enumeration index now, because calls like OnSynchronized might create objects
72  EnumerationIndex = std::max(EnumerationIndex, iMaxObjectNumber);
73 }

References C4PropListNumbered::EnumerationIndex.

Referenced by C4Game::CheckObjectEnumeration(), and C4GameObjects::PostLoad().

Here is the caller graph for this function:

◆ SetGraphics() [1/2]

bool C4Object::SetGraphics ( C4DefGraphics pNewGfx,
bool  fUpdateData 
)

Definition at line 825 of file C4ObjectGraphics.cpp.

826 {
827  // safety
828  if (!pNewGfx) return false;
829  // set it and update related stuff
830  pGraphics = pNewGfx;
831  UpdateGraphics(true, fTemp);
832  return true;
833 }

References pGraphics, and UpdateGraphics().

Here is the call graph for this function:

◆ SetGraphics() [2/2]

bool C4Object::SetGraphics ( const char *  szGraphicsName = nullptr,
C4Def pSourceDef = nullptr 
)

Definition at line 808 of file C4ObjectGraphics.cpp.

809 {
810  // safety
811  if (!Status) return false;
812  // default def
813  if (!pSourceDef) pSourceDef = Def;
814  // get graphics
815  C4DefGraphics *pGrp = pSourceDef->Graphics.Get(szGraphicsName);
816  if (!pGrp) return false;
817  // set new graphics
818  pGraphics = pGrp;
819  // update Color, etc.
820  UpdateGraphics(true);
821  // success
822  return true;
823 }
C4DefGraphics * Get(const char *szGrpName)

References Def, C4DefGraphics::Get(), C4Def::Graphics, pGraphics, C4PropList::Status, and UpdateGraphics().

Referenced by C4GraphicsOverlay::Draw().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ SetHalfVehicleSolidMask()

void C4Object::SetHalfVehicleSolidMask ( bool  set)

Definition at line 278 of file C4ObjectPhysics.cpp.

279 {
280  if (pSolidMaskData)
281  {
282  HalfVehicleSolidMask = set;
284  }
285 }
void SetHalfVehicle(bool set)

References HalfVehicleSolidMask, pSolidMaskData, and C4SolidMask::SetHalfVehicle().

Referenced by UpdateSolidMask().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ SetLightColor()

bool C4Object::SetLightColor ( uint32_t  iValue)

Definition at line 48 of file C4ObjectVisibility.cpp.

49 {
50  // set new color value
51  lightColor = iValue;
52  // resort into player's FoW-repeller-list
53  UpdateLight();
54  // success
55  return true;
56 }

References lightColor, and UpdateLight().

Here is the call graph for this function:

◆ SetLightRange()

bool C4Object::SetLightRange ( int32_t  iToRange,
int32_t  iToFadeoutRange 
)

Definition at line 37 of file C4ObjectVisibility.cpp.

38 {
39  // set new range
40  lightRange = iToRange;
41  lightFadeoutRange = iToFadeoutRange;
42  // resort into player's FoW-repeller-list
43  UpdateLight();
44  // success
45  return true;
46 }

References lightFadeoutRange, lightRange, and UpdateLight().

Referenced by AssignDeath(), C4Player::MakeCrewMember(), and C4Player::PlaceReadyCrew().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ SetName()

void C4Object::SetName ( const char *  NewName = nullptr)
overridevirtual

Reimplemented from C4PropList.

Definition at line 783 of file C4Object.cpp.

784 {
785  if (!NewName && Info)
787  else
788  C4PropList::SetName(NewName);
789 }
virtual void SetName(const char *NewName=nullptr)
Definition: C4PropList.cpp:625

References Info, C4ObjectInfoCore::Name, and C4PropList::SetName().

Referenced by GrabInfo(), Init(), and C4Player::MakeCrewMember().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ SetOCF()

void C4Object::SetOCF ( )

Definition at line 30 of file C4ObjectOCF.cpp.

31 {
32  C4PropList* pActionDef = GetAction();
33  uint32_t dwOCFOld = OCF;
34  // Update the object character flag according to the object's current situation
35  C4Real cspeed=GetSpeed();
36 #ifdef _DEBUG
38  { LogF("Warning: contained in wild object %p!", static_cast<void*>(Contained)); }
39  else if (Contained && !Contained->Status)
40  { LogF("Warning: contained in deleted object (#%d) (%s)!", Contained->Number, Contained->GetName()); }
41 #endif
42  // OCF_Normal: The OCF is never zero
44  // OCF_Construct: Can be built outside
45  if (Def->Constructable && (Con<FullCon)
46  && (fix_r==Fix0) && !OnFire)
48  // OCF_Grab: Can be pushed
50  OCF|=OCF_Grab;
51  // OCF_Carryable: Can be picked up
54  // OCF_OnFire: Is burning
55  if (OnFire)
56  OCF|=OCF_OnFire;
57  // OCF_Inflammable: Is not burning and is inflammable
60  // OCF_FullCon: Is fully completed/grown
61  if (Con>=FullCon)
63  // OCF_Rotate: Can be rotated
64  if (Def->Rotateable)
65  // Don't rotate minimum (invisible) construction sites
66  if (Con>100)
67  OCF|=OCF_Rotate;
68  // OCF_Exclusive: No action through this, no construction in front of this
69  if (Def->Exclusive)
71  // OCF_Entrance: Can currently be entered/activated
72  if ((Def->Entrance.Wdt>0) && (Def->Entrance.Hgt>0))
73  if ((OCF & OCF_FullCon) && ((Def->RotatedEntrance == 1) || (GetR() <= Def->RotatedEntrance)))
75  // HitSpeeds
76  if (cspeed>=HitSpeed1) OCF|=OCF_HitSpeed1;
77  if (cspeed>=HitSpeed2) OCF|=OCF_HitSpeed2;
78  if (cspeed>=HitSpeed3) OCF|=OCF_HitSpeed3;
79  if (cspeed>=HitSpeed4) OCF|=OCF_HitSpeed4;
80  // OCF_Collection
82  if ((Def->Collection.Wdt>0) && (Def->Collection.Hgt>0))
83  if (!pActionDef || (!pActionDef->GetPropertyInt(P_ObjectDisabled)))
85  // OCF_Alive
86  if (Alive) OCF|=OCF_Alive;
87  // OCF_CrewMember
88  if (Def->CrewMember)
89  if (Alive)
91  // OCF_NotContained
92  if (!Contained)
94  // OCF_InLiquid
95  if (InLiquid)
96  if (!Contained)
98  // OCF_InSolid
99  if (!Contained)
100  if (GBackSolid(GetX(), GetY()))
101  OCF|=OCF_InSolid;
102  // OCF_InFree
103  if (!Contained)
104  if (!GBackSemiSolid(GetX(), GetY()-1))
105  OCF|=OCF_InFree;
106  // OCF_Available
108  if (!GBackSemiSolid(GetX(), GetY()-1) || (!GBackSolid(GetX(), GetY()-1) && !GBackSemiSolid(GetX(), GetY()-8)))
110  // OCF_Container
114  {
115  C4RCOCF rc = { dwOCFOld, OCF, false };
116  AddDbgRec(RCT_OCF, &rc, sizeof(rc));
117  }
118 }
const uint32_t OCF_Carryable
Definition: C4Constants.h:82
const uint32_t OCF_Inflammable
Definition: C4Constants.h:86
const uint32_t OCF_InFree
Definition: C4Constants.h:100
const uint32_t OCF_Normal
Definition: C4Constants.h:79
const uint32_t OCF_OnFire
Definition: C4Constants.h:83
const uint32_t OCF_Alive
Definition: C4Constants.h:103
const uint32_t OCF_Container
Definition: C4Constants.h:102
const uint32_t OCF_Available
Definition: C4Constants.h:101
const uint32_t OCF_Exclusive
Definition: C4Constants.h:89
const uint32_t OCF_InSolid
Definition: C4Constants.h:99
const uint32_t OCF_NotContained
Definition: C4Constants.h:96
const uint32_t OCF_CrewMember
Definition: C4Constants.h:97
const uint32_t OCF_InLiquid
Definition: C4Constants.h:98
const int32_t C4D_Grab_Put
Definition: C4Def.h:62
const int32_t C4D_Grab_Get
Definition: C4Def.h:63
constexpr bool DEBUGREC_OCF
Definition: C4Include.h:35
bool LogF(const char *strMessage,...)
Definition: C4Log.cpp:262
const C4Real HitSpeed3
Definition: C4Physics.h:29
const C4Real HitSpeed1
Definition: C4Movement.cpp:37
const C4Real HitSpeed2
Definition: C4Physics.h:29
const C4Real HitSpeed4
Definition: C4Physics.h:29
@ RCT_OCF
Definition: C4Record.h:83
@ P_Collectible
int32_t RotatedEntrance
Definition: C4Def.h:145
int32_t Constructable
Definition: C4Def.h:118
int32_t GrabPutGet
Definition: C4Def.h:124
int32_t Exclusive
Definition: C4Def.h:116
C4Real GetSpeed() const
static bool CheckPropList(C4PropList *)
Definition: C4PropList.cpp:56

References AddDbgRec(), Alive, C4D_Grab_Get, C4D_Grab_Put, C4PropListNumbered::CheckPropList(), C4Def::Collection, Con, Config, C4Def::Constructable, Contained, C4Def::CrewMember, C4ConfigGeneral::DebugRec, DEBUGREC_OCF, Def, C4Def::Entrance, C4Def::Exclusive, Fix0, fix_r, FullCon, GBackSemiSolid(), GBackSolid(), C4Config::General, GetAction(), C4PropList::GetName(), C4PropList::GetPropertyInt(), GetR(), GetSpeed(), GetX(), GetY(), C4Def::GrabPutGet, C4Rect::Hgt, HitSpeed1, HitSpeed2, HitSpeed3, HitSpeed4, C4Def::IncompleteActivity, InLiquid, LogF(), C4PropListNumbered::Number, OCF, OCF_Alive, OCF_Available, OCF_Carryable, OCF_Collection, OCF_Construct, OCF_Container, OCF_CrewMember, OCF_Entrance, OCF_Exclusive, OCF_FullCon, OCF_Grab, OCF_HitSpeed1, OCF_HitSpeed2, OCF_HitSpeed3, OCF_HitSpeed4, OCF_Inflammable, OCF_InFree, OCF_InLiquid, OCF_InSolid, OCF_Normal, OCF_NotContained, OCF_OnFire, OCF_Rotate, OnFire, P_Collectible, P_ContactIncinerate, P_ObjectDisabled, P_Touchable, RCT_OCF, C4Def::Rotateable, C4Def::RotatedEntrance, C4PropList::Status, and C4Rect::Wdt.

Referenced by AssignDeath(), AssignRemoval(), ChangeDef(), DoCon(), Enter(), Exit(), Init(), ObjectComDrop(), SetAction(), SetAlive(), SetCategory(), SetOnFire(), SyncClearance(), and UpdateOCF().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ SetOnFire()

void C4Object::SetOnFire ( bool  OnFire)
inlineoverridevirtual

Reimplemented from C4PropList.

Definition at line 301 of file C4Object.h.

301 { this->OnFire = OnFire; SetOCF(); }

References OnFire, and SetOCF().

Here is the call graph for this function:

◆ SetOwner()

bool C4Object::SetOwner ( int32_t  iOwner)

Definition at line 1129 of file C4Object.cpp.

1130 {
1131  // Check valid owner
1132  if (!(ValidPlr(iOwner) || iOwner == NO_OWNER)) return false;
1133  // always set color, even if no owner-change is done
1134  if (iOwner != NO_OWNER)
1135  if (GetGraphics()->IsColorByOwner())
1136  {
1137  Color=::Players.Get(iOwner)->ColorDw;
1138  UpdateFace(false);
1139  }
1140  // no change?
1141  if (Owner == iOwner) return true;
1142  // set new owner
1143  int32_t iOldOwner=Owner;
1144  Owner=iOwner;
1145  // this automatically updates controller
1146  Controller = Owner;
1147  // script callback
1148  Call(PSF_OnOwnerChanged, &C4AulParSet(Owner, iOldOwner));
1149  // done
1150  return true;
1151 }
#define PSF_OnOwnerChanged
Definition: C4GameScript.h:141

References C4PropList::Call(), Color, C4Player::ColorDw, Controller, C4PlayerList::Get(), GetGraphics(), NO_OWNER, Owner, Players, PSF_OnOwnerChanged, UpdateFace(), and ValidPlr().

Here is the call graph for this function:

◆ SetPhase()

bool C4Object::SetPhase ( int32_t  iPhase)

Definition at line 352 of file C4ObjectAction.cpp.

353 {
354  C4PropList* pActionDef = GetAction();
355  if (!pActionDef) return false;
356  const int32_t length = pActionDef->GetPropertyInt(P_Length);
357  Action.Phase=Clamp<int32_t>(iPhase,0,length);
358  Action.PhaseDelay = 0;
359  return true;
360 }

References Action, GetAction(), C4PropList::GetPropertyInt(), P_Length, C4Action::Phase, and C4Action::PhaseDelay.

Here is the call graph for this function:

◆ SetPlane()

void C4Object::SetPlane ( int32_t  z)
inline

Definition at line 178 of file C4Object.h.

178 { if (z) Plane = z; Resort(); }
#define z

References Plane, Resort(), and z.

Referenced by C4GameObjects::FixObjectOrder(), ResetProperty(), and SetPropertyByS().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ SetProperty()

void C4PropList::SetProperty ( C4PropertyName  k,
const C4Value to 
)
inlineinherited

Definition at line 124 of file C4PropList.h.

125  { SetPropertyByS(&Strings.P[k], to); }
virtual void SetPropertyByS(C4String *k, const C4Value &to)
Definition: C4PropList.cpp:940

References C4StringTable::P, C4PropList::SetPropertyByS(), and Strings.

Referenced by C4Game::AllocateTranslatedString(), C4Effect::C4Effect(), ChangeDef(), Init(), C4DefScriptHost::Parse(), C4ScriptHost::Preparse(), SetAction(), C4PropList::SetName(), C4ScriptGuiWindow::ToC4Value(), C4ScriptHost::UnLink(), and C4MapScriptLayer::UpdateSurfaceSize().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ SetPropertyByS()

void C4Object::SetPropertyByS ( C4String k,
const C4Value to 
)
overridevirtual

Reimplemented from C4PropList.

Definition at line 1313 of file C4Object.cpp.

1314 {
1315  if (k >= &Strings.P[0] && k < &Strings.P[P_LAST])
1316  {
1317  switch(k - &Strings.P[0])
1318  {
1319  case P_Plane:
1320  if (!to.getInt()) throw C4AulExecError("invalid Plane 0");
1321  SetPlane(to.getInt());
1322  return;
1323  }
1324  }
1326 }

References C4Value::getInt(), C4StringTable::P, P_LAST, P_Plane, SetPlane(), C4PropList::SetPropertyByS(), and Strings.

Here is the call graph for this function:

◆ SetRotation()

void C4Object::SetRotation ( int32_t  nr)

Definition at line 312 of file C4ObjectPhysics.cpp.

313 {
314  while (new_rotation < 0)
315  {
316  new_rotation += 360;
317  }
318  new_rotation %= 360;
319  // Remove solid mask
320  RemoveSolidMask(false);
321  // Set rotation
322  fix_r = itofix(new_rotation);
323  // Update face
324  UpdateFace(true);
325 }

References fix_r, itofix(), and UpdateFace().

Here is the call graph for this function:

◆ SetSolidMask()

void C4Object::SetSolidMask ( int32_t  iX,
int32_t  iY,
int32_t  iWdt,
int32_t  iHgt,
int32_t  iTX,
int32_t  iTY 
)

Definition at line 261 of file C4ObjectPhysics.cpp.

262 {
263  // Remove old
264  if (pSolidMaskData)
265  {
266  delete pSolidMaskData;
267  pSolidMaskData = nullptr;
268  }
269  // Set new data
270  SolidMask.Set(x, y, wdt, hgt, tx, ty);
271  // Re-put if valid
272  if (CheckSolidMaskRect())
273  {
274  UpdateSolidMask(false);
275  }
276 }

References CheckSolidMaskRect(), pSolidMaskData, C4TargetRect::Set(), SolidMask, and UpdateSolidMask().

Here is the call graph for this function:

◆ ShelveNumberedPropLists()

void C4PropListNumbered::ShelveNumberedPropLists ( )
staticinherited

Definition at line 81 of file C4PropList.cpp.

82 {
83  // unnumber all proplists and put them on the shelve. To be used on remaining objects before a savegame load.
84  assert(ShelvedPropLists.empty());
86  C4PropListNumbered *const* p_next = PropLists.First(), *const* p;
87  while ((p = p_next))
88  {
89  p_next = PropLists.Next(p);
90  C4PropListNumbered *pl = *p;
91  if (pl->Number != -1)
92  {
93  pl->ClearNumber();
94  ShelvedPropLists.push_back(pl);
95  }
96  }
97 }

References C4PropListNumbered::ClearNumber(), C4Set< T >::First(), C4Set< T >::GetSize(), C4Set< T >::Next(), C4PropListNumbered::Number, C4PropListNumbered::PropLists, and C4PropListNumbered::ShelvedPropLists.

Referenced by C4Game::CompileFunc().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ShiftContents()

bool C4Object::ShiftContents ( bool  fShiftBack,
bool  fDoCalls 
)

Definition at line 182 of file C4ObjectContents.cpp.

183 {
184  // get current object
185  C4Object *c_obj = Contents.GetObject();
186  if (!c_obj) return false;
187  // get next/previous
188  auto it = fShiftBack ? Contents.reverse().begin() : ++Contents.begin();
189  while (!it.atEnd())
190  {
191  auto pObj = (*it);
192  // check object
193  if (pObj->Status)
194  if (!c_obj->CanConcatPictureWith(pObj))
195  {
196  // object different: shift to this
197  DirectComContents(pObj, !!fDoCalls);
198  return true;
199  }
200  // next/prev item
201  it++;
202  }
203  return false;
204 }
void DirectComContents(C4Object *pTarget, bool fDoCalls)
bool CanConcatPictureWith(C4Object *pOtherObject) const
iterator begin() const
const ReverseView reverse() const
Definition: C4ObjectList.h:104

References C4ObjectList::begin(), C4ObjectList::ReverseView::begin(), CanConcatPictureWith(), Contents, DirectComContents(), C4ObjectList::GetObject(), and C4ObjectList::reverse().

Here is the call graph for this function:

◆ SideBounds()

void C4Object::SideBounds ( C4Real target_x)
protected

Definition at line 184 of file C4Movement.cpp.

185 {
186  // Layer bounds
188  {
189  C4PropList* pActionDef = GetAction();
190  if (!pActionDef || pActionDef->GetPropertyP(P_Procedure) != DFA_ATTACH)
191  {
192  C4Real lbound = itofix(Layer->GetX() + Layer->Shape.GetX() - Shape.GetX());
193  C4Real rbound = itofix(Layer->GetX() + Layer->Shape.GetX() + Layer->Shape.Wdt - (Shape.GetX() + Shape.Wdt));
194  if (target_x < lbound)
195  {
196  StopAndContact(target_x, lbound, xdir, CNAT_Left);
197  }
198  if (target_x > rbound)
199  {
200  StopAndContact(target_x, rbound, xdir, CNAT_Right);
201  }
202  }
203  }
204  // Landscape bounds
205  C4Real lbound = itofix(0 - Shape.GetX());
206  C4Real rbound = itofix(::Landscape.GetWidth() - (Shape.GetX() + Shape.Wdt));
207  if (target_x < lbound && (GetPropertyInt(P_BorderBound) & C4D_Border_Sides))
208  {
209  StopAndContact(target_x, lbound, xdir, CNAT_Left);
210  }
211  if (target_x > rbound && (GetPropertyInt(P_BorderBound) & C4D_Border_Sides))
212  {
213  StopAndContact(target_x, rbound, xdir, CNAT_Right);
214  }
215 }
const int32_t C4D_Border_Layer
Definition: C4Def.h:68
void StopAndContact(C4Real &ctco, C4Real limit, C4Real &speed, int32_t cnat)
Definition: C4Movement.cpp:151

References C4D_Border_Layer, C4D_Border_Sides, CNAT_Left, CNAT_Right, DFA_ATTACH, GetAction(), C4PropList::GetPropertyInt(), C4PropList::GetPropertyP(), C4Landscape::GetWidth(), GetX(), C4Shape::GetX(), itofix(), Landscape, Layer, P_BorderBound, P_Procedure, Shape, StopAndContact(), C4Rect::Wdt, and xdir.

Referenced by BoundsCheck(), and DoMovement().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ Stabilize()

void C4Object::Stabilize ( )

Definition at line 616 of file C4Movement.cpp.

617 {
618  // Definition allows stabilization?
619  if (Def->NoStabilize)
620  {
621  return;
622  }
623  // Normalize angle
624  C4Real normalized_rotation = fix_r;
625  while (normalized_rotation < itofix(-180))
626  {
627  normalized_rotation += 360;
628  }
629  while (normalized_rotation > itofix(180))
630  {
631  normalized_rotation -= 360;
632  }
633  if ((normalized_rotation != Fix0) && Inside<C4Real>(normalized_rotation, itofix(-StableRange), itofix(+StableRange)))
634  {
635  // Save step undos
636  C4Real old_rotation = fix_r;
637  C4Shape old_shape = Shape;
638  // Try rotation
639  fix_r = Fix0;
640  UpdateShape();
641  if (ContactCheck(GetX(), GetY()))
642  { // Undo rotation
643  Shape = old_shape;
644  fix_r = old_rotation;
645  }
646  else
647  { // Stabilization okay
648  UpdateFace(true);
649  }
650  }
651 }
int32_t NoStabilize
Definition: C4Def.h:137

References ContactCheck(), Def, Fix0, fix_r, GetX(), GetY(), itofix(), C4Def::NoStabilize, Shape, StableRange, UpdateFace(), and UpdateShape().

Referenced by ExecMovement().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ StatusActivate()

bool C4Object::StatusActivate ( )

Definition at line 1202 of file C4Object.cpp.

1203 {
1204  // readd to main list
1206  Status = C4OS_NORMAL;
1207  ::Objects.Add(this);
1208  // update some values
1209  UpdateGraphics(false);
1210  UpdateFace(true);
1211  UpdatePos();
1212  UpdateLight();
1214  // done, success
1215  return true;
1216 }
#define PSF_OnSynchronized
Definition: C4GameScript.h:79

References C4GameObjects::Add(), C4OS_NORMAL, C4PropList::Call(), C4GameObjects::InactiveObjects, Objects, PSF_OnSynchronized, C4ObjectList::Remove(), C4PropList::Status, UpdateFace(), UpdateGraphics(), UpdateLight(), and UpdatePos().

Here is the call graph for this function:

◆ StatusDeactivate()

bool C4Object::StatusDeactivate ( bool  fClearPointers)

Definition at line 1218 of file C4Object.cpp.

1219 {
1220  // clear particles
1222 
1223  // put into inactive list
1224  ::Objects.Remove(this);
1226  if (Landscape.HasFoW()) Landscape.GetFoW()->Remove(this);
1228  // if desired, clear game pointers
1229  if (fClearPointers)
1230  {
1231  // in this case, the object must also exit any container, and any contained objects must be exited
1233  Game.ClearPointers(this);
1234  }
1235  else
1236  {
1237  // always clear transfer
1239  }
1240  // done, success
1241  return true;
1242 }
void Remove(C4Object *pObj)
Definition: C4FoW.cpp:201
C4TransferZones TransferZones
Definition: C4Game.h:85
bool Remove(C4Object *game_object) override
bool HasFoW() const
class C4FoW * GetFoW()
void ClearContentsAndContained(bool fDoCalls=true)
void ClearPointers(C4Object *pObj)

References C4ObjectList::Add(), C4OS_INACTIVE, ClearContentsAndContained(), ClearParticleLists(), C4Game::ClearPointers(), C4TransferZones::ClearPointers(), Game, C4Landscape::GetFoW(), C4Landscape::HasFoW(), C4GameObjects::InactiveObjects, Landscape, Objects, C4GameObjects::Remove(), C4FoW::Remove(), C4PropList::Status, C4ObjectList::stMain, and C4Game::TransferZones.

Here is the call graph for this function:

◆ StopAndContact()

void C4Object::StopAndContact ( C4Real ctco,
C4Real  limit,
C4Real speed,
int32_t  cnat 
)

Definition at line 151 of file C4Movement.cpp.

152 {
153  contact_coordinate = limit;
154  speed = 0;
155  Contact(cnat);
156 }

References Contact().

Referenced by SideBounds(), and VerticalBounds().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ SyncClearance()

void C4Object::SyncClearance ( )

Definition at line 1102 of file C4Object.cpp.

1103 {
1104  // Misc. no-save safeties
1106  InMat = MNone;
1107  t_contact = 0;
1108  // Update OCF
1109  SetOCF();
1110  // Menu
1111  CloseMenu(true);
1112  // Material contents
1113  delete MaterialContents; MaterialContents=nullptr;
1114  // reset speed of staticback-objects
1115  if (Category & C4D_StaticBack)
1116  {
1117  xdir = ydir = 0;
1118  }
1119 }

References Action, C4D_StaticBack, Category, CloseMenu(), CNAT_None, InMat, MaterialContents, MNone, SetOCF(), C4Action::t_attach, t_contact, xdir, and ydir.

Here is the call graph for this function:

◆ Thaw()

void C4PropList::Thaw ( )
inlineinherited

Definition at line 133 of file C4PropList.h.

133 { constant = false; }

Referenced by C4PropList::ThawRecursively(), and C4ScriptHost::UnlinkOwnedFunctions().

Here is the caller graph for this function:

◆ ThawRecursively()

void C4PropList::ThawRecursively ( )
inherited

Definition at line 259 of file C4PropList.cpp.

260 {
261  //thaw self and all owned properties
262  Thaw();
263  //C4PropListStatic *s = IsStatic();
264  //if (s) LogF("Thaw: %s", s->GetDataString().getData());
265  auto prop_names = GetUnsortedProperties(nullptr, ::ScriptEngine.GetPropList());
266  for (auto prop_name : prop_names)
267  {
268  C4Value child_val;
269  GetPropertyByS(prop_name, &child_val);
270  //LogF(" %s=%s", prop_name->GetCStr(), child_val.GetDataString(1).getData());
271  C4PropList *child_proplist = child_val.getPropList();
272  if (child_proplist && child_proplist->IsFrozen())
273  {
274  child_proplist->ThawRecursively();
275  }
276  }
277 }
C4PropListStatic * GetPropList()
Definition: C4Aul.h:151
bool IsFrozen() const
Definition: C4PropList.h:135
void Thaw()
Definition: C4PropList.h:133
void ThawRecursively()
Definition: C4PropList.cpp:259

References C4PropList::GetPropertyByS(), C4AulScriptEngine::GetPropList(), C4Value::getPropList(), C4PropList::GetUnsortedProperties(), C4PropList::IsFrozen(), ScriptEngine, C4PropList::Thaw(), and C4PropList::ThawRecursively().

Referenced by C4PropList::ThawRecursively(), and C4AulScriptEngine::UnLink().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ToJSON()

StdStrBuf C4PropList::ToJSON ( int  depth = 10,
bool  ignore_reference_parent = false 
) const
inherited

Definition at line 515 of file C4PropList.cpp.

516 {
517  if (depth <= 0 && Properties.GetSize())
518  {
519  throw new C4JSONSerializationError("maximum depth reached");
520  }
521  StdStrBuf DataString;
522  DataString = "{";
523  bool has_elements = false;
524  // Append prototype
525  if (prototype)
526  {
527  DataString.Append("Prototype:");
528  DataString.Append(prototype.ToJSON(depth - 1, ignore_reference_parent ? IsStatic() : nullptr));
529  has_elements = true;
530  }
531  // Append other properties
532  std::list<const C4Property *> sorted_props = Properties.GetSortedListOfElementPointers();
533  for (std::list<const C4Property *>::const_iterator p = sorted_props.begin(); p != sorted_props.end(); ++p)
534  {
535  if (has_elements) DataString.Append(",");
536  DataString.Append(C4Value((*p)->Key).ToJSON());
537  DataString.Append(":");
538  DataString.Append((*p)->Value.ToJSON(depth - 1, ignore_reference_parent ? IsStatic() : nullptr));
539  has_elements = true;
540  }
541  DataString.Append("}");
542  return DataString;
543 }
StdStrBuf ToJSON(int depth=10, const class C4PropListStatic *ignore_reference_parent=nullptr) const
Definition: C4Value.cpp:189

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

Referenced by C4Value::ToJSON().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ Top()

int32_t C4Object::Top ( ) const
inline

Definition at line 282 of file C4Object.h.

282 { return GetY()+Shape.y-addtop(); } // top border of shape (+build-top)

References addtop(), GetY(), Shape, and C4Rect::y.

Referenced by C4LArea::Set().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ UnSelect()

void C4Object::UnSelect ( )

Definition at line 1196 of file C4Object.cpp.

1197 {
1198  // do callback
1200 }

References C4PropList::Call(), and PSF_CrewSelection.

Referenced by C4Player::SetCursor().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ UnshelveNumberedPropLists()

void C4PropListNumbered::UnshelveNumberedPropLists ( )
staticinherited

Definition at line 99 of file C4PropList.cpp.

100 {
101  // re-insert shelved proplists into main list and give them a number
102  for (auto & ShelvedPropList : ShelvedPropLists)
103  ShelvedPropList->AcquireNumber();
104  ShelvedPropLists.clear();
105 }

References C4PropListNumbered::ShelvedPropLists.

Referenced by C4Game::LoadScenarioSection(), and C4GameObjects::PostLoad().

Here is the caller graph for this function:

◆ UpdateActionFace()

void C4Object::UpdateActionFace ( )

Definition at line 287 of file C4ObjectAction.cpp.

288 {
289  // Default: no action face
290  Action.Facet.Default();
291  // Active: get action facet from action definition
292  C4PropList* pActionDef = GetAction();
293  if (pActionDef)
294  {
295  if (pActionDef->GetPropertyInt(P_Wdt)>0)
296  {
297  Action.Facet.Set(GetGraphics()->GetBitmap(Color),
298  pActionDef->GetPropertyInt(P_X),pActionDef->GetPropertyInt(P_Y),
299  pActionDef->GetPropertyInt(P_Wdt),pActionDef->GetPropertyInt(P_Hgt));
300  Action.FacetX=pActionDef->GetPropertyInt(P_OffX);
301  Action.FacetY=pActionDef->GetPropertyInt(P_OffY);
302  }
303  }
304 }
@ P_OffX
@ P_OffY

References Action, Color, C4Facet::Default(), C4Action::Facet, C4Action::FacetX, C4Action::FacetY, GetAction(), GetGraphics(), C4PropList::GetPropertyInt(), P_Hgt, P_OffX, P_OffY, P_Wdt, P_X, P_Y, and C4Facet::Set().

Referenced by SetAction(), and UpdateFace().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ UpdateFace()

void C4Object::UpdateFace ( bool  bUpdateShape,
bool  fTemp = false 
)

Definition at line 103 of file C4ObjectAction.cpp.

104 {
105 
106  // Update shape - NOT for temp call, because temnp calls are done in drawing routine
107  // must not change sync relevant data here (although the shape and pos *should* be updated at that time anyway,
108  // because a runtime join would desync otherwise)
109  if (!fTemp) { if (bUpdateShape) UpdateShape(); else UpdatePos(); }
110 
111  // SolidMask
112  if (!fTemp) UpdateSolidMask(false);
113 
114  // Null defaults
115  TopFace.Default();
116 
117  // newgfx: TopFace only
118  if (Con>=FullCon || Def->GrowthType)
119  if (!Def->Rotateable || (fix_r == Fix0))
120  if (Def->TopFace.Wdt>0) // Fullcon & no rotation
121  TopFace.Set(GetGraphics()->GetBitmap(Color),
122  Def->TopFace.x,Def->TopFace.y,
124 
125  // Active face
127 }

References Color, Con, Def, C4Facet::Default(), Fix0, fix_r, FullCon, GetGraphics(), C4Def::GrowthType, C4Rect::Hgt, C4Def::Rotateable, C4Facet::Set(), C4Def::TopFace, TopFace, UpdateActionFace(), UpdatePos(), UpdateShape(), UpdateSolidMask(), C4Rect::Wdt, C4Rect::x, and C4Rect::y.

Referenced by ChangeDef(), DoCon(), DoMovement(), Enter(), Exit(), Init(), SetOwner(), SetRotation(), Stabilize(), StatusActivate(), C4ObjectList::UpdateFaces(), and UpdateGraphics().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ UpdateFlipDir()

void C4Object::UpdateFlipDir ( )

Definition at line 129 of file C4ObjectAction.cpp.

130 {
131  int32_t iFlipDir;
132  // We're active
133  C4PropList* pActionDef = GetAction();
134  if (pActionDef)
135  // Get flipdir value from action
136  if ((iFlipDir = pActionDef->GetPropertyInt(P_FlipDir)))
137  // Action dir is in flipdir range
138  if (Action.Dir >= iFlipDir)
139  {
140  // Calculate flipped drawing dir (from the flipdir direction going backwards)
141  Action.DrawDir = (iFlipDir - 1 - (Action.Dir - iFlipDir));
142  // Set draw transform, creating one if necessary
143  if (pDrawTransform)
145  else
147  // Done setting flipdir
148  return;
149  }
150  // No flipdir necessary
152  // Draw transform present?
153  if (pDrawTransform)
154  {
155  // reset flip dir
157  // if it's identity now, remove the matrix
158  if (pDrawTransform->IsIdentity())
159  {
160  delete pDrawTransform;
161  pDrawTransform=nullptr;
162  }
163  }
164 }
bool IsIdentity() const
Definition: C4Facet.h:90
void SetFlipDir(int32_t iNewFlipDir)
Definition: C4Facet.h:82

References Action, C4Action::Dir, C4Action::DrawDir, GetAction(), C4PropList::GetPropertyInt(), C4DrawTransform::IsIdentity(), P_FlipDir, pDrawTransform, and C4DrawTransform::SetFlipDir().

Referenced by SetAction(), and SetDir().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ UpdateGraphics()

void C4Object::UpdateGraphics ( bool  fGraphicsChanged,
bool  fTemp = false 
)

Definition at line 48 of file C4ObjectGraphics.cpp.

49 {
50  // check color
51  if (!fTemp) if (!pGraphics->IsColorByOwner()) Color=0;
52  // new grafics: update face
53  if (fGraphicsChanged)
54  {
55  // Keep mesh instance if it uses the same underlying mesh
57  &pMeshInstance->GetMesh() != pGraphics->Mesh)
58  {
59  // If this mesh is attached somewhere, detach it before deletion
60  if(pMeshInstance && pMeshInstance->GetAttachParent() != nullptr)
61  {
62  // TODO: If the new mesh has a bone with the same name, we could try updating...
64  attach_parent->Parent->DetachMesh(attach_parent->Number);
65  }
66 
67  delete pMeshInstance;
68 
70  {
71  pMeshInstance = new StdMeshInstance(*pGraphics->Mesh, Def->GrowthType ? 1.0f : static_cast<float>(Con)/static_cast<float>(FullCon));
73  }
74  else
75  {
76  pMeshInstance = nullptr;
77  }
78  }
79 
80  // update face - this also puts any SolidMask
81  UpdateFace(false);
82  }
83 }
bool IsColorByOwner()
Definition: C4DefGraphics.h:74
StdMeshInstance * Parent
Definition: StdMesh.h:510
bool DetachMesh(unsigned int number)
Definition: StdMesh.cpp:1395

References Color, ColorMod, Con, Def, StdMeshInstance::DetachMesh(), FullCon, StdMeshInstance::GetAttachParent(), StdMeshInstance::GetMesh(), C4Def::GrowthType, C4DefGraphics::IsColorByOwner(), StdMeshInstance::AttachedMesh::Number, StdMeshInstance::AttachedMesh::Parent, pGraphics, pMeshInstance, StdMeshInstance::SetFaceOrderingForClrModulation(), C4DefGraphics::Type, C4DefGraphics::TYPE_Mesh, and UpdateFace().

Referenced by ChangeDef(), Init(), SetGraphics(), StatusActivate(), and C4ObjectList::UpdateGraphics().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ UpdateInLiquid()

void C4Object::UpdateInLiquid ( )

Definition at line 535 of file C4ObjectPhysics.cpp.

536 {
537  // InLiquid check
538  if (IsInLiquidCheck()) // In Liquid
539  {
540  if (!InLiquid) // Enter liquid
541  {
542  if ((OCF & OCF_HitSpeed2) && Mass > 3)
543  {
544  Splash();
545  }
546  InLiquid = true;
547  }
548  }
549  else if (InLiquid) // Leave liquid
550  {
551  InLiquid = false;
552  }
553 }

References InLiquid, IsInLiquidCheck(), Mass, OCF, and OCF_HitSpeed2.

Here is the call graph for this function:

◆ UpdateLight()

void C4Object::UpdateLight ( )

Definition at line 58 of file C4ObjectVisibility.cpp.

59 {
60  if (Landscape.HasFoW()) Landscape.GetFoW()->Add(this);
61 }
void Add(C4Object *pObj)
Definition: C4FoW.cpp:165

References C4FoW::Add(), C4Landscape::GetFoW(), C4Landscape::HasFoW(), and Landscape.

Referenced by AssignLightRange(), SetLightColor(), SetLightRange(), and StatusActivate().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ UpdateMass()

void C4Object::UpdateMass ( )

Definition at line 47 of file C4ObjectPhysics.cpp.

48 {
49  Mass = std::max<int32_t>((Def->Mass + OwnMass) * Con / FullCon, 1);
50  if (!Def->NoMassFromContents)
51  {
52  Mass += Contents.Mass;
53  }
54  if (Contained)
55  {
58  }
59 }
int32_t NoMassFromContents
Definition: C4Def.h:136

References Con, Contained, Contents, Def, FullCon, C4Def::Mass, Mass, C4ObjectList::Mass, C4ObjectList::MassCount(), C4Def::NoMassFromContents, OwnMass, and UpdateMass().

Referenced by AssignRemoval(), ChangeDef(), DoCon(), Enter(), Exit(), and UpdateMass().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ UpdateOCF()

void C4Object::UpdateOCF ( )

Definition at line 121 of file C4ObjectOCF.cpp.

122 {
123  C4PropList* pActionDef = GetAction();
124  uint32_t dwOCFOld = OCF;
125  // Update the object character flag according to the object's current situation
126  C4Real cspeed=GetSpeed();
127 #ifdef _DEBUG
129  { LogF("Warning: contained in wild object %p!", static_cast<void*>(Contained)); }
130  else if (Contained && !Contained->Status)
131  { LogF("Warning: contained in deleted object %p (%s)!", static_cast<void*>(Contained), Contained->GetName()); }
132 #endif
133  // Keep the bits that only have to be updated with SetOCF (def, category, con, alive, onfire)
136  // OCF_inflammable: can catch fire and is not currently burning.
138  OCF |= OCF_Inflammable;
139  // OCF_Carryable: Can be picked up
142  // OCF_Grab: Can be grabbed.
144  OCF |= OCF_Grab;
145  // OCF_Construct: Can be built outside
146  if (Def->Constructable && (Con<FullCon)
147  && (fix_r == Fix0) && !OnFire)
149  // OCF_Entrance: Can currently be entered/activated
150  if ((Def->Entrance.Wdt>0) && (Def->Entrance.Hgt>0))
151  if ((OCF & OCF_FullCon) && ((Def->RotatedEntrance == 1) || (GetR() <= Def->RotatedEntrance)))
152  OCF|=OCF_Entrance;
153  // HitSpeeds
154  if (cspeed>=HitSpeed1) OCF|=OCF_HitSpeed1;
155  if (cspeed>=HitSpeed2) OCF|=OCF_HitSpeed2;
156  if (cspeed>=HitSpeed3) OCF|=OCF_HitSpeed3;
157  if (cspeed>=HitSpeed4) OCF|=OCF_HitSpeed4;
158  // OCF_Collection
160  if ((Def->Collection.Wdt>0) && (Def->Collection.Hgt>0))
161  if (!pActionDef || (!pActionDef->GetPropertyInt(P_ObjectDisabled)))
163  // OCF_NotContained
164  if (!Contained)
166  // OCF_InLiquid
167  if (InLiquid)
168  if (!Contained)
169  OCF|=OCF_InLiquid;
170  // OCF_InSolid
171  if (!Contained)
172  if (GBackSolid(GetX(), GetY()))
173  OCF|=OCF_InSolid;
174  // OCF_InFree
175  if (!Contained)
176  if (!GBackSemiSolid(GetX(), GetY()-1))
177  OCF|=OCF_InFree;
178  // OCF_Available
180  if (!GBackSemiSolid(GetX(), GetY()-1) || (!GBackSolid(GetX(), GetY()-1) && !GBackSemiSolid(GetX(), GetY()-8)))
182  // OCF_Container
186  {
187  C4RCOCF rc = { dwOCFOld, OCF, true };
188  AddDbgRec(RCT_OCF, &rc, sizeof(rc));
189  }
190 #ifdef _DEBUG
192  uint32_t updateOCF = OCF;
193  SetOCF();
194  assert (updateOCF == OCF);
196 #endif
197 }
#define DEBUGREC_ON
Definition: C4Record.h:29
#define DEBUGREC_OFF
Definition: C4Record.h:28

References AddDbgRec(), C4D_Grab_Get, C4D_Grab_Put, C4PropListNumbered::CheckPropList(), C4Def::Collection, Con, Config, C4Def::Constructable, Contained, C4ConfigGeneral::DebugRec, DEBUGREC_OCF, DEBUGREC_OFF, DEBUGREC_ON, Def, C4Def::Entrance, Fix0, fix_r, FullCon, GBackSemiSolid(), GBackSolid(), C4Config::General, GetAction(), C4PropList::GetName(), C4PropList::GetPropertyInt(), GetR(), GetSpeed(), GetX(), GetY(), C4Def::GrabPutGet, C4Rect::Hgt, HitSpeed1, HitSpeed2, HitSpeed3, HitSpeed4, C4Def::IncompleteActivity, InLiquid, LogF(), OCF, OCF_Alive, OCF_Available, OCF_Carryable, OCF_Collection, OCF_Construct, OCF_Container, OCF_CrewMember, OCF_Entrance, OCF_Exclusive, OCF_FullCon, OCF_Grab, OCF_HitSpeed1, OCF_HitSpeed2, OCF_HitSpeed3, OCF_HitSpeed4, OCF_Inflammable, OCF_InFree, OCF_InLiquid, OCF_InSolid, OCF_Normal, OCF_NotContained, OCF_OnFire, OCF_Rotate, OnFire, P_Collectible, P_ContactIncinerate, P_ObjectDisabled, P_Touchable, RCT_OCF, C4Def::RotatedEntrance, SetOCF(), C4PropList::Status, and C4Rect::Wdt.

Referenced by Execute().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ UpdatePos()

void C4Object::UpdatePos ( )

Definition at line 37 of file C4ObjectPhysics.cpp.

38 {
39  // Get new area covered:
40  // Do *NOT* do this while initializing, because object cannot be sorted by main list
41  if (!Initializing && Status == C4OS_NORMAL)
42  {
43  ::Objects.UpdatePos(this);
44  }
45 }
void UpdatePos(C4Object *game_object)

References C4OS_NORMAL, Initializing, Objects, C4PropList::Status, and C4GameObjects::UpdatePos().

Referenced by CopyMotion(), DoMovement(), ForcePosition(), MovePosition(), StatusActivate(), UpdateFace(), and UpdateShape().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ UpdateScriptPointers()

void C4Object::UpdateScriptPointers ( )

Definition at line 1272 of file C4Object.cpp.

1273 {
1274  if (pEffects)
1276 }
void ReAssignAllCallbackFunctions()
Definition: C4Effect.h:129

References pEffects, and C4Effect::ReAssignAllCallbackFunctions().

Referenced by C4ObjectList::UpdateScriptPointers().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ UpdateShape()

void C4Object::UpdateShape ( bool  bUpdateVertices = true)

Definition at line 327 of file C4Object.cpp.

328 {
329 
330  // Line shape independent
331  if (Def->Line) return;
332 
333  // Copy shape from def
334  Shape.CopyFrom(Def->Shape, bUpdateVertices, !!fOwnVertices);
335 
336  // Construction zoom
337  if (Con!=FullCon)
338  {
339  if (Def->GrowthType)
340  Shape.Stretch(Con, bUpdateVertices);
341  else
342  Shape.Jolt(Con, bUpdateVertices);
343  }
344 
345  // Rotation
346  if (Def->Rotateable)
347  if (fix_r != Fix0)
348  Shape.Rotate(fix_r, bUpdateVertices);
349 
350  // covered area changed? to be on the save side, update pos
351  UpdatePos();
352 }
void Stretch(int32_t iCon, bool bUpdateVertices)
Definition: C4Shape.cpp:142
void Jolt(int32_t iCon, bool bUpdateVertices)
Definition: C4Shape.cpp:158
void CopyFrom(C4Shape rFrom, bool bCpyVertices, bool fCopyVerticesFromSelf)
Definition: C4Shape.cpp:532
void Rotate(C4Real Angle, bool bUpdateVertices)
Definition: C4Shape.cpp:45

References Con, C4Shape::CopyFrom(), Def, Fix0, fix_r, fOwnVertices, FullCon, C4Def::GrowthType, C4Shape::Jolt(), C4Def::Line, C4Shape::Rotate(), C4Def::Rotateable, C4Def::Shape, Shape, C4Shape::Stretch(), and UpdatePos().

Referenced by DoCon(), DoMovement(), Stabilize(), and UpdateFace().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ UpdateSolidMask()

void C4Object::UpdateSolidMask ( bool  fRestoreAttachedObjects)

Definition at line 343 of file C4ObjectPhysics.cpp.

344 {
345  // Solidmask doesn't make sense with non-existant objects
346  // (the solidmask has already been destroyed in AssignRemoval -
347  // do not reset it!)
348  if (!Status)
349  {
350  return;
351  }
352  // Determine necessity, update cSolidMask, put or remove mask
353  // Mask if enabled, fullcon, not contained
354  if (SolidMask.Wdt > 0 && Con >= FullCon && !Contained)
355  {
356  // Recheck and put mask
357  if (!pSolidMaskData)
358  {
359  pSolidMaskData = new C4SolidMask(this);
360  }
361  else
362  {
363  pSolidMaskData->Remove(false);
364  }
365  pSolidMaskData->Put(true, nullptr, fRestoreAttachedObjects);
367  }
368  // Otherwise, remove and destroy mask
369  else if (pSolidMaskData)
370  {
371  delete pSolidMaskData;
372  pSolidMaskData = nullptr;
373  }
374 }
void SetHalfVehicleSolidMask(bool set)
void Put(bool fCauseInstability, C4TargetRect *pClipRect, bool fRestoreAttachment)
Definition: C4SolidMask.cpp:32
void Remove(bool fBackupAttachment)

References Con, Contained, FullCon, HalfVehicleSolidMask, pSolidMaskData, C4SolidMask::Put(), C4SolidMask::Remove(), SetHalfVehicleSolidMask(), SolidMask, C4PropList::Status, and C4Rect::Wdt.

Referenced by DoMovement(), Enter(), ForcePosition(), MovePosition(), SetSolidMask(), and UpdateFace().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ UpdatLastEnergyLossCause()

void C4Object::UpdatLastEnergyLossCause ( int32_t  iNewCausePlr)

Definition at line 611 of file C4Object.cpp.

612 {
613  // Mark last damage causing player to trace kills
614  // do not regard self-administered damage if there was a previous damage causing player, because that would steal kills
615  // if people tumble themselves via stop-stop-(left/right)-throw while falling into teh abyss
616  if (iNewCausePlr != Controller || LastEnergyLossCausePlayer < 0)
617  {
618  LastEnergyLossCausePlayer = iNewCausePlr;
619  }
620 }

References Controller, and LastEnergyLossCausePlayer.

Referenced by DoEnergy().

Here is the caller graph for this function:

◆ ValidateOwner()

bool C4Object::ValidateOwner ( )

Definition at line 1035 of file C4Object.cpp.

1036 {
1037  // Check owner and controller
1038  if (!ValidPlr(Owner)) Owner=NO_OWNER;
1040  // Color is not reset any more, because many scripts change colors to non-owner-colors these days
1041  // Additionally, player colors are now guarantueed to remain the same in savegame resumes
1042  return true;
1043 }

References Controller, NO_OWNER, Owner, and ValidPlr().

Referenced by C4ObjectList::ValidateOwners().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ VerticalBounds()

void C4Object::VerticalBounds ( C4Real target_y)
protected

Definition at line 217 of file C4Movement.cpp.

218 {
219  // Layer bounds
221  {
222  C4PropList* pActionDef = GetAction();
223  if (!pActionDef || pActionDef->GetPropertyP(P_Procedure) != DFA_ATTACH)
224  {
225  C4Real tbound = itofix(Layer->GetY() + Layer->Shape.GetY() - Shape.GetY());
226  C4Real bbound = itofix(Layer->GetY() + Layer->Shape.GetY() + Layer->Shape.Hgt - (Shape.GetY() + Shape.Hgt));
227  if (target_y < tbound)
228  {
229  StopAndContact(target_y, tbound, ydir, CNAT_Top);
230  }
231  if (target_y > bbound)
232  {
233  StopAndContact(target_y, bbound, ydir, CNAT_Bottom);
234  }
235  }
236  }
237  // Landscape bounds
238  C4Real tbound = itofix(0 - Shape.GetY());
239  C4Real bbound = itofix(::Landscape.GetHeight() - (Shape.GetY() + Shape.Hgt));
240  if (target_y < tbound && (GetPropertyInt(P_BorderBound) & C4D_Border_Top))
241  {
242  StopAndContact(target_y, tbound, ydir, CNAT_Top);
243  }
244  if (target_y > bbound && (GetPropertyInt(P_BorderBound) & C4D_Border_Bottom))
245  {
246  StopAndContact(target_y, bbound, ydir, CNAT_Bottom);
247  }
248 }
const int32_t C4D_Border_Top
Definition: C4Def.h:66

References C4D_Border_Bottom, C4D_Border_Layer, C4D_Border_Top, CNAT_Bottom, CNAT_Top, DFA_ATTACH, GetAction(), C4Landscape::GetHeight(), C4PropList::GetPropertyInt(), C4PropList::GetPropertyP(), GetY(), C4Shape::GetY(), C4Rect::Hgt, itofix(), Landscape, Layer, P_BorderBound, P_Procedure, Shape, StopAndContact(), and ydir.

Referenced by BoundsCheck(), and DoMovement().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ Width()

int32_t C4Object::Width ( ) const
inline

Definition at line 283 of file C4Object.h.

283 { return Shape.Wdt; } // width of shape

References Shape, and C4Rect::Wdt.

Referenced by C4LArea::Set().

Here is the caller graph for this function:

Member Data Documentation

◆ Action

◆ Alive

bool C4Object::Alive
protected

◆ Area

C4LArea C4Object::Area

◆ Audible

int32_t C4Object::Audible

Definition at line 119 of file C4Object.h.

Referenced by Default(), C4SoundInstance::Execute(), Init(), and SetAudibilityAt().

◆ AudiblePan

int32_t C4Object::AudiblePan

Definition at line 119 of file C4Object.h.

Referenced by Default(), C4SoundInstance::Execute(), Init(), and SetAudibilityAt().

◆ AudiblePlayer

int32_t C4Object::AudiblePlayer

Definition at line 119 of file C4Object.h.

Referenced by Default(), C4SoundInstance::Execute(), Init(), and SetAudibilityAt().

◆ BackParticles

class C4ParticleList * C4Object::BackParticles

Definition at line 157 of file C4Object.h.

Referenced by C4Object(), ClearParticleLists(), C4ParticleSystem::Create(), and Draw().

◆ BlitMode

◆ Breath

int32_t C4Object::Breath

Definition at line 116 of file C4Object.h.

Referenced by CompileFunc(), Default(), DoBreath(), ExecLife(), and Init().

◆ Category

◆ Color

◆ ColorMod

◆ Command

◆ Con

◆ Contained

◆ Contents

◆ Controller

◆ CrewDisabled

bool C4Object::CrewDisabled

◆ Damage

int32_t C4Object::Damage

Definition at line 114 of file C4Object.h.

Referenced by CompileFunc(), Default(), and DoDamage().

◆ Def

C4Def* C4Object::Def

◆ Energy

int32_t C4Object::Energy

Definition at line 115 of file C4Object.h.

Referenced by CompileFunc(), Default(), DoEnergy(), and Init().

◆ EntranceStatus

bool C4Object::EntranceStatus

Definition at line 130 of file C4Object.h.

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

◆ EnumerationIndex

int32_t C4PropListNumbered::EnumerationIndex = 0
staticprotectedinherited

◆ fix_r

◆ fix_x

◆ fix_y

◆ fOwnVertices

bool C4Object::fOwnVertices

Definition at line 147 of file C4Object.h.

Referenced by CompileFunc(), Default(), and UpdateShape().

◆ FrontParticles

class C4ParticleList* C4Object::FrontParticles

Definition at line 157 of file C4Object.h.

Referenced by C4Object(), ClearParticleLists(), C4ParticleSystem::Create(), and Draw().

◆ HalfVehicleSolidMask

bool C4Object::HalfVehicleSolidMask

Definition at line 149 of file C4Object.h.

Referenced by ChangeDef(), CompileFunc(), Default(), SetHalfVehicleSolidMask(), and UpdateSolidMask().

◆ id

◆ iLastAttachMovementFrame

int32_t C4Object::iLastAttachMovementFrame

Definition at line 125 of file C4Object.h.

Referenced by CompileFunc(), Default(), and C4SolidMask::Put().

◆ Info

◆ Initializing

bool C4Object::Initializing

Definition at line 128 of file C4Object.h.

Referenced by Default(), Init(), and UpdatePos().

◆ InLiquid

bool C4Object::InLiquid

◆ InMat

int32_t C4Object::InMat

Definition at line 117 of file C4Object.h.

Referenced by Default(), ExecLife(), and SyncClearance().

◆ LastEnergyLossCausePlayer

int32_t C4Object::LastEnergyLossCausePlayer

Definition at line 110 of file C4Object.h.

Referenced by AssignDeath(), CompileFunc(), Default(), Init(), and UpdatLastEnergyLossCause().

◆ Layer

◆ lightColor

uint32_t C4Object::lightColor

Definition at line 122 of file C4Object.h.

Referenced by C4FoW::Add(), CompileFunc(), Default(), GetLightColor(), and SetLightColor().

◆ lightFadeoutRange

int32_t C4Object::lightFadeoutRange

Definition at line 121 of file C4Object.h.

Referenced by C4FoW::Add(), AssignLightRange(), CompileFunc(), Default(), and SetLightRange().

◆ lightRange

int32_t C4Object::lightRange

◆ Marker

uint32_t C4Object::Marker

Definition at line 133 of file C4Object.h.

Referenced by Default().

◆ Mass

◆ MaterialContents

C4MaterialList* C4Object::MaterialContents

Definition at line 152 of file C4Object.h.

Referenced by Clear(), Default(), and SyncClearance().

◆ Menu

class C4ObjectMenu* C4Object::Menu

◆ Mobile

bool C4Object::Mobile

◆ nInfo

StdCopyStrBuf C4Object::nInfo

Definition at line 167 of file C4Object.h.

Referenced by AssignInfo(), CompileFunc(), Default(), and C4Player::MakeCrewMember().

◆ Number

◆ OCF

◆ old_x

int32_t C4Object::old_x

Definition at line 112 of file C4Object.h.

Referenced by C4LSectors::Add(), C4LSectors::Remove(), and C4LSectors::Update().

◆ old_y

int32_t C4Object::old_y

Definition at line 112 of file C4Object.h.

Referenced by C4LSectors::Add(), C4LSectors::Remove(), and C4LSectors::Update().

◆ OnFire

bool C4Object::OnFire
protected

Definition at line 171 of file C4Object.h.

Referenced by CompileFunc(), Default(), GetOnFire(), SetOCF(), SetOnFire(), and UpdateOCF().

◆ Owner

◆ OwnMass

int32_t C4Object::OwnMass

Definition at line 113 of file C4Object.h.

Referenced by CompileFunc(), Default(), and UpdateMass().

◆ pDrawTransform

C4DrawTransform* C4Object::pDrawTransform

◆ pEffects

◆ pGfxOverlay

◆ pGraphics

C4DefGraphics* C4Object::pGraphics

◆ PictureRect

C4Rect C4Object::PictureRect

◆ Plane

int32_t C4Object::Plane
protected

Definition at line 173 of file C4Object.h.

Referenced by CompileFunc(), GetPlane(), GetPropertyByS(), Init(), and SetPlane().

◆ pMeshInstance

◆ PropLists

◆ pSolidMaskData

C4SolidMask* C4Object::pSolidMaskData
protected

◆ rdir

◆ RemovalDelay

int32_t C4Object::RemovalDelay

Definition at line 107 of file C4Object.h.

Referenced by AssignRemoval(), and Default().

◆ Shape

◆ ShelvedPropLists

std::vector< C4PropListNumbered * > C4PropListNumbered::ShelvedPropLists
staticprotectedinherited

◆ SolidMask

◆ Status

int32_t C4PropList::Status {1}
inherited

Definition at line 173 of file C4PropList.h.

Referenced by C4Command::Acquire(), C4Command::Activate(), C4GameObjects::Add(), C4ObjectList::Add(), C4FoW::Add(), C4EditCursor::AddToSelection(), AssignDeath(), C4ObjectList::AssignInfo(), AssignRemoval(), At(), C4PropList::Call(), C4Game::CastObjects(), C4ObjectList::CheckCategorySort(), C4ObjectList::CheckSort(), C4Effect::ClearAll(), C4ObjectList::ClearInfo(), Collect(), C4ObjectList::CompileFunc(), CompileFunc(), C4GameObjects::CrossCheck(), C4ObjectList::DeleteObjects(), C4ObjectList::Denumerate(), C4Landscape::P::DigMaterial2Objects(), DirectComContents(), C4Effect::DoDamage(), Draw(), C4Game::DrawCrewOverheadText(), DrawSelectMark(), DrawTopFace(), C4EditCursor::EMMoveObject(), Enter(), Execute(), C4SoundInstance::Execute(), C4Effect::Execute(), C4ScriptGuiWindowAction::ExecuteCommand(), C4Command::Fail(), C4ObjectList::Find(), C4FindObject::Find(), C4ObjectList::FindOther(), C4GameObjects::FixObjectOrder(), C4PropList::FreezeAndMakeStaticRecursively(), GetArea(), C4EditCursor::GetCurrentSelectionPosition(), GetEntranceArea(), GetInfoString(), C4ObjectList::GetListID(), GetMomentum(), C4ObjectList::GetObject(), GrabInfo(), GrabLost(), C4GameObjects::GRBroadcast(), C4Effect::Init(), C4GameMessage::Init(), IsMoveableBySolidMask(), C4GraphicsOverlay::IsValid(), Lift(), C4Player::MakeCrewMember(), C4ObjectList::MassCount(), MenuCommand(), C4GameMessageList::New(), C4Game::NewObject(), ObjectComGrab(), ObjectComUnGrab(), C4ObjectList::ObjectCount(), C4EditCursor::PerformDuplicationLegacy(), C4Landscape::P::PostFreeShape(), C4GameObjects::PostLoad(), Push(), C4GameObjects::Remove(), C4EditCursor::RemoveFromSelection(), C4AulScriptContext::ReturnDump(), C4GameObjects::SafeObjectPointer(), SetAction(), SetGraphics(), C4GameObjects::SetOCF(), SetOCF(), StatusActivate(), StatusDeactivate(), C4Effect::TempReaddUpperEffects(), C4Effect::TempRemoveUpperEffects(), C4ObjectList::UpdateFaces(), C4ObjectList::UpdateGraphics(), UpdateOCF(), UpdatePos(), UpdateSolidMask(), C4GameObjects::UpdateSolidMasks(), C4ObjectList::ValidateOwners(), and C4ObjectList::Write().

◆ t_contact

uint32_t C4Object::t_contact

◆ TopFace

C4Facet C4Object::TopFace

Definition at line 140 of file C4Object.h.

Referenced by Default(), DrawTopFace(), and UpdateFace().

◆ Unsorted

◆ xdir

◆ ydir


The documentation for this class was generated from the following files: