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

#include <C4Object.h>

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

Public Types

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

Public Member Functions

 C4Object ()
 
 ~C4Object ()
 
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 *)
 
virtual void Denumerate (C4ValueNumbers *)
 
void DrawLine (C4TargetFacet &cgo, int32_t at_player)
 
bool SetPhase (int32_t iPhase)
 
void AssignRemoval (bool fExitContents=false)
 
void Draw (C4TargetFacet &cgo, int32_t iByPlayer=-1, DrawMode eDrawMode=ODM_Normal, float offX=0, float offY=0)
 
void DrawTopFace (C4TargetFacet &cgo, int32_t iByPlayer=-1, DrawMode eDrawMode=ODM_Normal, float offX=0, float offY=0)
 
void DrawActionFace (C4TargetFacet &cgo, float offX, float offY) const
 
void DrawFace (C4TargetFacet &cgo, float offX, float offY, int32_t iPhaseX=0, int32_t iPhaseY=0) const
 
void DrawFaceImpl (C4TargetFacet &cgo, bool action, float fx, float fy, float fwdt, float fhgt, float tx, float ty, float twdt, float thgt, C4DrawTransform *transform) const
 
void Execute ()
 
void ClearPointers (C4Object *ptr)
 
bool ExecMovement ()
 
void ExecAction ()
 
bool ExecLife ()
 
bool ExecuteCommand ()
 
void AssignDeath (bool fForced)
 
void ContactAction ()
 
void NoAttachAction ()
 
void DoMovement ()
 
void Stabilize ()
 
void SetOCF ()
 
void UpdateOCF ()
 
void UpdateShape (bool bUpdateVertices=true)
 
void UpdatePos ()
 
void UpdateSolidMask (bool fRestoreAttachedObjects)
 
void UpdateMass ()
 
bool ChangeDef (C4ID idNew)
 
void UpdateFace (bool bUpdateShape, bool fTemp=false)
 
void UpdateGraphics (bool fGraphicsChanged, bool fTemp=false)
 
void UpdateFlipDir ()
 
bool At (int32_t ctx, int32_t cty) const
 
bool At (int32_t ctx, int32_t cty, DWORD &ocf) const
 
void GetOCFForPos (int32_t ctx, int32_t cty, DWORD &ocf) const
 
bool CloseMenu (bool fForce)
 
bool ActivateMenu (int32_t iMenu, int32_t iMenuSelect=0, int32_t iMenuData=0, int32_t iMenuPosition=0, C4Object *pTarget=nullptr)
 
int32_t ContactCheck (int32_t atx, int32_t aty, uint32_t *border_hack_contacts=0, bool collide_halfvehic=false)
 
bool Contact (int32_t cnat)
 
void StopAndContact (C4Real &ctco, C4Real limit, C4Real &speed, int32_t cnat)
 
C4PropListGetAction () const
 
bool SetAction (C4PropList *Act, C4Object *pTarget=nullptr, C4Object *pTarget2=nullptr, int32_t iCalls=SAC_StartCall|SAC_AbortCall, bool fForce=false)
 
bool SetActionByName (C4String *ActName, C4Object *pTarget=nullptr, C4Object *pTarget2=nullptr, int32_t iCalls=SAC_StartCall|SAC_AbortCall, bool fForce=false)
 
bool SetActionByName (const char *szActName, C4Object *pTarget=nullptr, C4Object *pTarget2=nullptr, int32_t iCalls=SAC_StartCall|SAC_AbortCall, bool fForce=false)
 
void SetDir (int32_t tdir)
 
void SetCategory (int32_t Category)
 
int32_t GetProcedure () const
 
bool Enter (C4Object *pTarget, bool fCalls=true, bool fCopyMotion=true, bool *pfRejectCollect=nullptr)
 
bool Exit (int32_t iX=0, int32_t iY=0, int32_t iR=0, C4Real iXDir=Fix0, C4Real iYDir=Fix0, C4Real iRDir=Fix0, bool fCalls=true)
 
void CopyMotion (C4Object *from)
 
void ForcePosition (C4Real tx, C4Real ty)
 
void MovePosition (int32_t dx, int32_t dy)
 
void MovePosition (C4Real dx, C4Real dy)
 
void DoMotion (int32_t mx, int32_t my)
 
bool ActivateEntrance (int32_t by_plr, C4Object *by_obj)
 
void DoDamage (int32_t iLevel, int32_t iCausedByPlr, int32_t iCause)
 
void DoEnergy (int32_t iChange, bool fExact, int32_t iCause, int32_t iCausedByPlr)
 
void UpdatLastEnergyLossCause (int32_t iNewCausePlr)
 
void DoBreath (int32_t iChange)
 
void DoCon (int32_t iChange, bool grow_from_center)
 
int32_t GetCon () const
 
void DoExperience (int32_t change)
 
bool Promote (int32_t torank, bool exception, bool fForceRankName)
 
bool Push (C4Real txdir, C4Real dforce, bool fStraighten)
 
bool Lift (C4Real tydir, C4Real dforce)
 
void Fling (C4Real txdir, C4Real tydir, bool fAddSpeed)
 
C4ObjectCreateContents (C4PropList *)
 
bool CreateContentsByList (C4IDList &idlist)
 
BYTE GetArea (int32_t &aX, int32_t &aY, int32_t &aWdt, int32_t &aHgt) const
 
int32_t addtop () const
 
int32_t Left () const
 
int32_t Top () const
 
int32_t Width () const
 
int32_t Height () const
 
int32_t GetX () const
 
int32_t GetY () const
 
int32_t GetR () const
 
C4Real GetFixedX () const
 
C4Real GetFixedY () const
 
C4Real GetFixedR () const
 
BYTE GetEntranceArea (int32_t &aX, int32_t &aY, int32_t &aWdt, int32_t &aHgt) const
 
BYTE GetMomentum (C4Real &rxdir, C4Real &rydir) const
 
C4Real GetSpeed () const
 
StdStrBuf GetDataString ()
 
void SetName (const char *NewName=0)
 
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)
 
bool GetOnFire () const
 
void SetAlive (bool Alive)
 
bool GetAlive () const
 
void UpdateLight ()
 
void SetAudibilityAt (C4TargetFacet &cgo, int32_t iX, int32_t iY, int32_t player)
 
bool IsVisible (int32_t iForPlr, bool fAsOverlay) const
 
void SetRotation (int32_t nr)
 
void PrepareDrawing () const
 
void FinishedDrawing () const
 
void DrawSolidMask (C4TargetFacet &cgo) const
 
bool Collect (C4Object *pObj)
 
bool GrabInfo (C4Object *pFrom)
 
bool ShiftContents (bool fShiftBack, bool fDoCalls)
 
void DirectComContents (C4Object *pTarget, bool fDoCalls)
 
void GetParallaxity (int32_t *parX, int32_t *parY) const
 
bool GetDrawPosition (const C4TargetFacet &cgo, float &resultx, float &resulty, float &resultzoom) const
 
bool GetDrawPosition (const C4TargetFacet &cgo, float x, float y, float zoom, float &resultx, float &resulty, float &resultzoom) const
 
bool IsInLiquidCheck () const
 
void UpdateInLiquid ()
 
void GrabContents (C4Object *pFrom)
 
bool GetDragImage (C4Object **drag_object, C4Def **drag_id) const
 
int32_t AddObjectAndContentsToArray (C4ValueArray *target_array, int32_t index=0)
 
void BoundsCheck (C4Real &ctcox, C4Real &ctcoy)
 
bool DoSelect ()
 
void UnSelect ()
 
void GetViewPos (float &riX, float &riY, float tx, float ty, const C4Facet &fctViewport) const
 
void GetViewPosPar (float &riX, float &riY, float tx, float ty, const C4Facet &fctViewport) const
 
bool PutAwayUnusedObject (C4Object *pToMakeRoomForObject)
 
C4DefGraphicsGetGraphics () const
 
bool SetGraphics (const char *szGraphicsName=nullptr, C4Def *pSourceDef=nullptr)
 
bool SetGraphics (C4DefGraphics *pNewGfx, bool fUpdateData)
 
class C4GraphicsOverlayGetGraphicsOverlay (int32_t iForID) const
 
class C4GraphicsOverlayGetGraphicsOverlay (int32_t iForID, bool fCreate)
 
bool RemoveGraphicsOverlay (int32_t iOverlayID)
 
bool HasGraphicsOverlayRecursion (const C4Object *pCheckObj) const
 
void UpdateScriptPointers ()
 
bool StatusActivate ()
 
bool StatusDeactivate (bool fClearPointers)
 
void ClearContentsAndContained (bool fDoCalls=true)
 
bool AdjustWalkRotation (int32_t iRangeX, int32_t iRangeY, int32_t iSpeed)
 
StdStrBuf GetInfoString ()
 
bool CanConcatPictureWith (C4Object *pOtherObject) const
 
bool IsMoveableBySolidMask (int ComparisonPlane) const
 
bool IsPlayerObject (int32_t iPlayerNumber=NO_OWNER) const
 
bool IsUserPlayerObject ()
 
virtual C4ObjectGetObject ()
 
virtual C4Object const * GetObject () const
 
virtual void SetPropertyByS (C4String *k, const C4Value &to)
 
virtual void ResetProperty (C4String *k)
 
virtual bool GetPropertyByS (const C4String *k, C4Value *pResult) const
 
virtual C4ValueArrayGetProperties () const
 
virtual C4PropListNumberedGetPropListNumbered ()
 
virtual bool IsNumbered () const
 
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=0) const
 
C4Value Call (C4PropertyName k, C4AulParSet *pPars=0, bool fPassErrors=false)
 
C4Value Call (C4String *k, C4AulParSet *pPars=0, bool fPassErrors=false)
 
C4Value Call (const char *k, C4AulParSet *pPars=0, 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 ()
 
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=0)
 
static C4PropListStaticNewStatic (C4PropList *prototype, const C4PropListStatic *parent, C4String *key)
 

Public Attributes

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

Protected Member Functions

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

Protected Attributes

bool OnFire
 
int32_t Con
 
int32_t Plane
 
bool Alive
 
C4SolidMaskpSolidMaskData
 

Static Protected Attributes

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

Detailed Description

Definition at line 100 of file C4Object.h.

Member Enumeration Documentation

anonymous enum
Enumerator
SAC_StartCall 
SAC_EndCall 
SAC_AbortCall 

Definition at line 251 of file C4Object.h.

Enumerator
ODM_Normal 
ODM_Overlay 
ODM_BaseOnly 

Definition at line 216 of file C4Object.h.

Constructor & Destructor Documentation

C4Object::C4Object ( )

Definition at line 88 of file C4Object.cpp.

References BackParticles, Default(), and FrontParticles.

89 {
91  Default();
92 }
class C4ParticleList * BackParticles
Definition: C4Object.h:158
void Default()
Definition: C4Object.cpp:94
class C4ParticleList * FrontParticles
Definition: C4Object.h:158

Here is the call graph for this function:

C4Object::~C4Object ( )

Definition at line 238 of file C4Object.cpp.

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

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

Here is the call graph for this function:

Member Function Documentation

void C4PropListNumbered::AcquireNumber ( )
protectedinherited

Definition at line 155 of file C4PropList.cpp.

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

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

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

Here is the call graph for this function:

Here is the caller graph for this function:

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

Definition at line 1363 of file C4Object.cpp.

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

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

1364 {
1365 
1366  // Try entrance activation
1367  if (OCF & OCF_Entrance)
1368  if (!! Call(PSF_ActivateEntrance,&C4AulParSet(by_obj)))
1369  return true;
1370  // Failure
1371  return false;
1372 }
const uint32_t OCF_Entrance
Definition: C4Constants.h:90
#define PSF_ActivateEntrance
Definition: C4GameScript.h:67
uint32_t OCF
Definition: C4Object.h:134
C4Value Call(C4PropertyName k, C4AulParSet *pPars=0, bool fPassErrors=false)
Definition: C4PropList.h:112

Here is the call graph for this function:

Here is the caller graph for this function:

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

Definition at line 1491 of file C4Object.cpp.

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

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

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

Here is the call graph for this function:

Here is the caller graph for this function:

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

Definition at line 2577 of file C4Object.cpp.

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

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

2581 {
2582  // Command stack size safety
2583  const int32_t MaxCommandStack = 35;
2584  C4Command *pCom,*pLast; int32_t iCommands;
2585  for (pCom=Command,iCommands=0; pCom; pCom=pCom->Next,iCommands++) {}
2586  if (iCommands>=MaxCommandStack) return false;
2587  // Valid command safety
2588  if (!Inside(iCommand,C4CMD_First,C4CMD_Last)) return false;
2589  // Allocate and set new command
2590  if (!(pCom=new C4Command)) return false;
2591  pCom->Set(iCommand,this,pTarget,iTx,iTy,pTarget2,iData,
2592  iUpdateInterval,!fInitEvaluation,iRetries,szText,iBaseMode);
2593  // Append to bottom of stack
2594  if (fAppend)
2595  {
2596  for (pLast=Command; pLast && pLast->Next; pLast=pLast->Next) {}
2597  if (pLast) pLast->Next=pCom;
2598  else Command=pCom;
2599  }
2600  // Add to top of command stack
2601  else
2602  {
2603  pCom->Next=Command;
2604  Command=pCom;
2605  }
2606  // Success
2607  return true;
2608 }
C4Command * Next
Definition: C4Command.h:90
C4Command * Command
Definition: C4Object.h:166
const int32_t C4CMD_First
Definition: C4Command.h:56
const int32_t C4CMD_Last
Definition: C4Command.h:57
void Set(int32_t iCommand, C4Object *pObj, C4Object *pTarget, C4Value iTx, int32_t iTy, C4Object *pTarget2, C4Value iData, int32_t iUpdateInterval, bool fEvaluated, int32_t iRetries, C4String *szText, int32_t iBaseMode)
Definition: C4Command.cpp:1811
bool Inside(T ival, U lbound, V rbound)
Definition: Standard.h:45

Here is the call graph for this function:

Here is the caller graph for this function:

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

Definition at line 186 of file C4Object.h.

References AddCommand(), and C4VInt().

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

Here is the call graph for this function:

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

Definition at line 4313 of file C4Object.cpp.

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

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

4314 {
4315  // add self, contents and child contents count recursively to value array. Return index after last added item.
4316  target_array->SetItem(index++, C4VObj(this));
4317  for (C4Object *cobj : Contents)
4318  {
4319  index = cobj->AddObjectAndContentsToArray(target_array, index);
4320  }
4321  return index;
4322 }
void SetItem(int32_t iElemNr, const C4Value &Value)
C4Value C4VObj(C4Object *pObj)
Definition: C4Value.cpp:90
C4NotifyingObjectList Contents
Definition: C4Object.h:152

Here is the call graph for this function:

Here is the caller graph for this function:

int32_t C4Object::addtop ( ) const
inline

Definition at line 281 of file C4Object.h.

References C4Rect::Hgt.

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

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

Here is the caller graph for this function:

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

Definition at line 4601 of file C4Object.cpp.

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

Referenced by ExecAction().

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

Here is the call graph for this function:

Here is the caller graph for this function:

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

Definition at line 497 of file C4PropList.cpp.

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

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

498 {
499  StdStrBuf & DataString = *out;
500  if (depth <= 0 && Properties.GetSize())
501  {
502  DataString.Append("...");
503  return;
504  }
505  std::list<const C4Property *> sorted_props = Properties.GetSortedListOfElementPointers();
506  for (std::list<const C4Property *>::const_iterator p = sorted_props.begin(); p != sorted_props.end(); ++p)
507  {
508  if (p != sorted_props.begin()) DataString.Append(delim);
509  DataString.Append((*p)->Key->GetData());
510  DataString.Append(" = ");
511  DataString.Append((*p)->Value.GetDataString(depth - 1, ignore_reference_parent ? IsStatic() : nullptr));
512  }
513 }
std::list< const T * > GetSortedListOfElementPointers() const
virtual class C4PropListStatic * IsStatic()
Definition: C4PropList.h:87
unsigned int GetSize() const
void Append(const char *pnData, size_t iChars)
Definition: StdBuf.h:527

Here is the call graph for this function:

Here is the caller graph for this function:

void C4Object::AssignDeath ( bool  fForced)

Definition at line 1004 of file C4Object.cpp.

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

Referenced by DoEnergy(), and ExecMovement().

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

Here is the call graph for this function:

Here is the caller graph for this function:

bool C4Object::AssignInfo ( )

Definition at line 2401 of file C4Object.cpp.

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

Referenced by C4ObjectList::AssignInfo().

2402 {
2403  if (Info || !ValidPlr(Owner)) return false;
2404  // In crew list?
2405  C4Player *pPlr = ::Players.Get(Owner);
2406  if (pPlr->Crew.GetLink(this))
2407  {
2408  // Register with player
2409  if (!::Players.Get(Owner)->MakeCrewMember(this, true, false))
2410  pPlr->Crew.Remove(this);
2411  return true;
2412  }
2413  // Info set, but not in crew list, so
2414  // a) The savegame is old-style (without crew list)
2415  // or b) The clonk is dead
2416  // or c) The clonk belongs to a script player that's restored without Game.txt
2417  else if (nInfo.getLength())
2418  {
2419  if (!::Players.Get(Owner)->MakeCrewMember(this, true, false))
2420  return false;
2421  // Dead and gone (info flags, remove from crew/cursor)
2422  if (!Alive)
2423  {
2424  if (ValidPlr(Owner)) ::Players.Get(Owner)->ClearPointers(this, true);
2425  }
2426  return true;
2427  }
2428  return false;
2429 }
bool MakeCrewMember(C4Object *pObj, bool fForceInfo=true, bool fDoCalls=true)
Definition: C4Player.cpp:1012
bool Alive
Definition: C4Object.h:175
void ClearPointers(C4Object *tptr, bool fDeath)
Definition: C4Player.cpp:100
C4ObjectInfo * Info
Definition: C4Object.h:145
const C4ObjectLink * GetLink(const C4Object *pObj) const
C4Player * Get(int iPlayer) const
int32_t Owner
Definition: C4Object.h:110
C4PlayerList Players
C4ObjectList Crew
Definition: C4Player.h:127
StdCopyStrBuf nInfo
Definition: C4Object.h:168
int32_t ValidPlr(int32_t plr)
size_t getLength() const
Definition: StdBuf.h:453
virtual bool Remove(C4Object *pObj)

Here is the call graph for this function:

Here is the caller graph for this function:

bool C4Object::AssignLightRange ( )

Definition at line 2431 of file C4Object.cpp.

References lightFadeoutRange, lightRange, and UpdateLight().

2432 {
2433  if (!lightRange && !lightFadeoutRange) return true;
2434 
2435  UpdateLight();
2436  return true;
2437 }
int32_t lightFadeoutRange
Definition: C4Object.h:123
int32_t lightRange
Definition: C4Object.h:122
void UpdateLight()
Definition: C4Object.cpp:4043

Here is the call graph for this function:

void C4Object::AssignRemoval ( bool  fExitContents = false)

Definition at line 257 of file C4Object.cpp.

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

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

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

Here is the call graph for this function:

Here is the caller graph for this function:

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

Definition at line 965 of file C4Object.cpp.

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

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

966 {
967  if (Status) if (!Contained) if (Def)
968  if (Inside<int32_t>(cty - (GetY() + Shape.GetY() - addtop()), 0, Shape.Hgt - 1 + addtop()))
969  if (Inside<int32_t>(ctx - (GetX() + Shape.GetX()), 0, Shape.Wdt - 1))
970  return true;
971  return false;
972 }
int32_t GetY() const
Definition: C4Object.h:287
int32_t GetY() const
Definition: C4Shape.h:64
int32_t Wdt
Definition: C4Rect.h:32
C4Def * Def
Definition: C4Object.h:143
int32_t GetX() const
Definition: C4Shape.h:63
int32_t GetX() const
Definition: C4Object.h:286
int32_t Status
Definition: C4PropList.h:169
C4ObjectPtr Contained
Definition: C4Object.h:144
int32_t Hgt
Definition: C4Rect.h:32
C4Shape Shape
Definition: C4Object.h:148
int32_t addtop() const
Definition: C4Object.h:281

Here is the call graph for this function:

Here is the caller graph for this function:

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

Definition at line 974 of file C4Object.cpp.

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

975 {
976  if (Status) if (!Contained) if (Def)
977  if (OCF & ocf)
978  if (Inside<int32_t>(cty - (GetY() + Shape.GetY() - addtop()), 0, Shape.Hgt - 1 + addtop()))
979  if (Inside<int32_t>(ctx - (GetX() + Shape.GetX()), 0, Shape.Wdt - 1))
980  {
981  // Set ocf return value
982  GetOCFForPos(ctx, cty, ocf);
983  return true;
984  }
985  return false;
986 }
int32_t GetY() const
Definition: C4Object.h:287
int32_t GetY() const
Definition: C4Shape.h:64
int32_t Wdt
Definition: C4Rect.h:32
C4Def * Def
Definition: C4Object.h:143
void GetOCFForPos(int32_t ctx, int32_t cty, DWORD &ocf) const
Definition: C4Object.cpp:988
int32_t GetX() const
Definition: C4Shape.h:63
int32_t GetX() const
Definition: C4Object.h:286
int32_t Status
Definition: C4PropList.h:169
C4ObjectPtr Contained
Definition: C4Object.h:144
int32_t Hgt
Definition: C4Rect.h:32
C4Shape Shape
Definition: C4Object.h:148
uint32_t OCF
Definition: C4Object.h:134
int32_t addtop() const
Definition: C4Object.h:281

Here is the call graph for this function:

C4PropList::Iterator C4PropList::begin ( )
inherited

Definition at line 962 of file C4PropList.cpp.

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

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

963 {
965 
966  if (GetPrototype())
967  {
968  iter = GetPrototype()->begin();
969  }
970  else
971  {
972  iter.properties = std::make_shared<std::vector<const C4Property*> >();
973  }
974  iter.Reserve(Properties.GetSize());
975 
976  const C4Property * p = Properties.First();
977  while (p)
978  {
979  iter.AddProperty(p);
980  p = Properties.Next(p);
981  }
982 
983  iter.Init();
984  return iter;
985 }
T const * Next(T const *p) const
unsigned int GetSize() const
Iterator begin()
Definition: C4PropList.cpp:962
C4PropList * GetPrototype() const
Definition: C4PropList.h:83
T const * First() const

Here is the call graph for this function:

Here is the caller graph for this function:

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

Definition at line 331 of file C4Object.h.

References SideBounds(), and VerticalBounds().

Referenced by Exit().

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

Here is the call graph for this function:

Here is the caller graph for this function:

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

Definition at line 112 of file C4PropList.h.

References C4StringTable::P, and Strings.

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

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

Here is the caller graph for this function:

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

Definition at line 783 of file C4PropList.cpp.

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

784 {
785  if (!Status) return C4Value();
786  C4AulFunc *pFn = GetFunc(k);
787  if (!pFn) return C4Value();
788  return pFn->Exec(this, Pars, fPassErrors);
789 }
C4AulFunc * GetFunc(C4PropertyName k) const
Definition: C4PropList.h:107
friend class C4Value
Definition: C4PropList.h:166
C4Value Exec(C4PropList *p=nullptr, C4AulParSet *pPars=nullptr, bool fPassErrors=false)
Definition: C4AulFunc.h:73
int32_t Status
Definition: C4PropList.h:169

Here is the call graph for this function:

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

Definition at line 791 of file C4PropList.cpp.

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

792 {
793  if (!Status) return C4Value();
794  assert(s && s[0]);
795  C4AulFunc *pFn = GetFunc(s);
796  if (!pFn)
797  {
798  if (s[0] != '~')
799  {
800  C4AulExecError err(FormatString("Undefined function: %s", s).getData());
801  if (fPassErrors)
802  throw err;
803  ::ScriptEngine.GetErrorHandler()->OnError(err.what());
804  }
805  return C4Value();
806  }
807  return pFn->Exec(this, Pars, fPassErrors);
808 }
C4AulErrorHandler * GetErrorHandler() const
Definition: C4Aul.h:175
C4AulScriptEngine ScriptEngine
Definition: C4Globals.cpp:43
C4AulFunc * GetFunc(C4PropertyName k) const
Definition: C4PropList.h:107
friend class C4Value
Definition: C4PropList.h:166
C4Value Exec(C4PropList *p=nullptr, C4AulParSet *pPars=nullptr, bool fPassErrors=false)
Definition: C4AulFunc.h:73
int32_t Status
Definition: C4PropList.h:169
virtual void OnError(const char *msg)=0
#define s
StdStrBuf FormatString(const char *szFmt,...)
Definition: StdBuf.cpp:277

Here is the call graph for this function:

bool C4Object::CanConcatPictureWith ( C4Object pOtherObject) const

Definition at line 4766 of file C4Object.cpp.

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

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

4767 {
4768  // check current definition ID
4769  if (id != pOtherObject->id) return false;
4770  // def overwrite of stack conditions
4771  int32_t allow_picture_stack = Def->AllowPictureStack;
4772  if (!(allow_picture_stack & APS_Color))
4773  {
4774  // check color if ColorByOwner (flags)
4775  if (Color != pOtherObject->Color && Def->ColorByOwner) return false;
4776  // check modulation
4777  if (ColorMod != pOtherObject->ColorMod) return false;
4778  if (BlitMode != pOtherObject->BlitMode) return false;
4779  }
4780  if (!(allow_picture_stack & APS_Graphics))
4781  {
4782  // check graphics
4783  if (pGraphics != pOtherObject->pGraphics) return false;
4784  // check any own picture rect
4785  if (PictureRect != pOtherObject->PictureRect) return false;
4786  }
4787  if (!(allow_picture_stack & APS_Name))
4788  {
4789  // check name, so zagabar's sandwiches don't stack
4790  if (GetName() != pOtherObject->GetName()) return false;
4791  }
4792  if (!(allow_picture_stack & APS_Overlay))
4793  {
4794  // check overlay graphics
4795  for (C4GraphicsOverlay *pOwnOverlay = pGfxOverlay; pOwnOverlay; pOwnOverlay = pOwnOverlay->GetNext())
4796  if (pOwnOverlay->IsPicture())
4797  {
4798  C4GraphicsOverlay *pOtherOverlay = pOtherObject->GetGraphicsOverlay(pOwnOverlay->GetID(), false);
4799  if (!pOtherOverlay || !(*pOtherOverlay == *pOwnOverlay)) return false;
4800  }
4801  for (C4GraphicsOverlay *pOtherOverlay = pOtherObject->pGfxOverlay; pOtherOverlay; pOtherOverlay = pOtherOverlay->GetNext())
4802  if (pOtherOverlay->IsPicture())
4803  if (!GetGraphicsOverlay(pOtherOverlay->GetID())) return false;
4804  }
4805  // concat OK
4806  return true;
4807 }
C4ID id
Definition: C4Object.h:108
C4Rect PictureRect
Definition: C4Object.h:151
C4Def * Def
Definition: C4Object.h:143
virtual const char * GetName() const
Definition: C4PropList.cpp:604
uint32_t Color
Definition: C4Object.h:120
C4DefGraphics * pGraphics
Definition: C4Object.h:154
class C4GraphicsOverlay * pGfxOverlay
Definition: C4Object.h:170
int32_t ColorByOwner
Definition: C4Def.h:123
uint32_t ColorMod
Definition: C4Object.h:161
int32_t AllowPictureStack
Definition: C4Def.h:150
int32_t GetID() const
uint32_t BlitMode
Definition: C4Object.h:162
class C4GraphicsOverlay * GetGraphicsOverlay(int32_t iForID) const
Definition: C4Object.cpp:4488
C4GraphicsOverlay * GetNext() const

Here is the call graph for this function:

Here is the caller graph for this function:

bool C4Object::ChangeDef ( C4ID  idNew)

Definition at line 1055 of file C4Object.cpp.

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

1056 {
1057  // Get new definition
1058  C4Def *pDef=C4Id2Def(idNew);
1059  if (!pDef) return false;
1060  // Containment storage
1061  C4Object *pContainer=Contained;
1062  // Exit container (no Ejection/Departure)
1063  if (Contained) Exit(0,0,0,Fix0,Fix0,Fix0,false);
1064  // Pre change resets
1065  SetAction(0);
1066  ResetProperty(&Strings.P[P_Action]); // Enforce ActIdle because SetAction may have failed due to NoOtherAction
1067  SetDir(0); // will drop any outdated flipdir
1068  if (pSolidMaskData) { delete pSolidMaskData; pSolidMaskData=nullptr; }
1069  Def->Count--;
1070  // Def change
1071  Def=pDef;
1073  id=pDef->id;
1074  Def->Count++;
1075  // new def: Needs to be resorted
1076  Unsorted=true;
1077  // graphics change
1078  pGraphics = &pDef->Graphics;
1079  // blit mode adjustment
1081  // an object may have newly become an ColorByOwner-object
1082  // if it had been ColorByOwner, but is not now, this will be caught in UpdateGraphics()
1083  if (!Color && ValidPlr(Owner))
1085  if (!Def->Rotateable) { fix_r=rdir=Fix0; }
1086  // Reset solid mask
1088  // Post change updates
1089  UpdateGraphics(true);
1090  UpdateMass();
1091  UpdateFace(true);
1092  SetOCF();
1093  // Any effect callbacks to this object might need to reinitialize their target functions
1094  // This is ugly, because every effect there is must be updated...
1099  for (C4Object *obj : Objects)
1100  if (obj->pEffects) obj->pEffects->OnObjectChangedDef(this);
1101  // Containment (no Entrance)
1102  if (pContainer) Enter(pContainer,false);
1103  // Done
1104  return true;
1105 }
C4String P[P_LAST]
C4ID id
Definition: C4Def.h:103
bool Enter(C4Object *pTarget, bool fCalls=true, bool fCopyMotion=true, bool *pfRejectCollect=nullptr)
Definition: C4Object.cpp:1275
C4GameScriptHost GameScript
void SetDir(int32_t tdir)
Definition: C4Object.cpp:2855
C4AulScriptEngine ScriptEngine
Definition: C4Globals.cpp:43
C4Real rdir
Definition: C4Object.h:126
void SetProperty(C4PropertyName k, const C4Value &to)
Definition: C4PropList.h:122
void UpdateGraphics(bool fGraphicsChanged, bool fTemp=false)
Definition: C4Object.cpp:407
uint32_t ColorDw
Definition: C4Player.h:91
int32_t Rotateable
Definition: C4Def.h:121
C4Player * Get(int iPlayer) const
C4Def * Def
Definition: C4Object.h:143
C4StringTable Strings
Definition: C4Globals.cpp:42
C4Value C4VPropList(C4PropList *p)
Definition: C4Value.h:245
int32_t Count
Definition: C4Def.h:182
int32_t Owner
Definition: C4Object.h:110
C4PlayerList Players
bool SetAction(C4PropList *Act, C4Object *pTarget=nullptr, C4Object *pTarget2=nullptr, int32_t iCalls=SAC_StartCall|SAC_AbortCall, bool fForce=false)
Definition: C4Object.cpp:2696
bool Exit(int32_t iX=0, int32_t iY=0, int32_t iR=0, C4Real iXDir=Fix0, C4Real iYDir=Fix0, C4Real iRDir=Fix0, bool fCalls=true)
Definition: C4Object.cpp:1239
uint32_t Color
Definition: C4Object.h:120
Definition: C4Def.h:100
C4DefGraphics * pGraphics
Definition: C4Object.h:154
void UpdateMass()
Definition: C4Object.cpp:642
C4TargetRect SolidMask
Definition: C4Def.h:110
void UpdateFace(bool bUpdateShape, bool fTemp=false)
Definition: C4Object.cpp:381
bool Unsorted
Definition: C4Object.h:129
C4Def * C4Id2Def(C4ID id)
Definition: C4DefList.h:80
#define C4GFXBLIT_CUSTOM
Definition: C4Surface.h:37
C4Real fix_r
Definition: C4Object.h:125
int32_t ValidPlr(int32_t plr)
C4Effect * pScenarioEffects
Definition: C4ScriptHost.h:165
int32_t BlitMode
Definition: C4Def.h:144
uint32_t BlitMode
Definition: C4Object.h:162
void SetOCF()
Definition: C4Object.cpp:670
C4ObjectPtr Contained
Definition: C4Object.h:144
C4TargetRect SolidMask
Definition: C4Object.h:150
C4SolidMask * pSolidMaskData
Definition: C4Object.h:176
virtual void ResetProperty(C4String *k)
Definition: C4Object.cpp:4874
C4DefGraphics Graphics
Definition: C4Def.h:194
C4Effect * pGlobalEffects
Definition: C4Aul.h:146
C4GameObjects Objects
Definition: C4Globals.cpp:48
const C4Real Fix0
Definition: C4Real.h:312
void OnObjectChangedDef(C4PropList *pObj)
Definition: C4Effect.cpp:471

Here is the call graph for this function:

bool C4PropListNumbered::CheckPropList ( C4PropList pObj)
staticinherited

Definition at line 80 of file C4PropList.cpp.

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

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

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

Here is the call graph for this function:

Here is the caller graph for this function:

bool C4Object::CheckSolidMaskRect ( )

Definition at line 2489 of file C4Object.cpp.

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

Referenced by Init(), and SetSolidMask().

2490 {
2491  // Ensure SolidMask rect lies within bounds of SolidMask bitmap in definition
2492  CSurface8 *sfcGraphics = Def->pSolidMask;
2493  if (!sfcGraphics)
2494  {
2495  // no graphics to set solid in
2496  SolidMask.Set(0,0,0,0,0,0);
2497  return false;
2498  }
2499  SolidMask.Set(std::max<int32_t>(SolidMask.x,0), std::max<int32_t>(SolidMask.y,0),
2500  std::min<int32_t>(SolidMask.Wdt,sfcGraphics->Wdt-SolidMask.x), std::min<int32_t>(SolidMask.Hgt, sfcGraphics->Hgt-SolidMask.y),
2502  if (SolidMask.Hgt<=0) SolidMask.Wdt=0;
2503  return SolidMask.Wdt>0;
2504 }
int Hgt
Definition: CSurface8.h:28
CSurface8 * pSolidMask
Definition: C4Def.h:195
int32_t Wdt
Definition: C4Rect.h:32
C4Def * Def
Definition: C4Object.h:143
int32_t y
Definition: C4Rect.h:32
int32_t tx
Definition: C4Rect.h:81
int32_t ty
Definition: C4Rect.h:81
int32_t x
Definition: C4Rect.h:32
int Wdt
Definition: CSurface8.h:28
int32_t Hgt
Definition: C4Rect.h:32
void Set(int32_t iX, int32_t iY, int32_t iWdt, int32_t iHgt, int32_t iTX, int32_t iTY)
Definition: C4Rect.cpp:45
C4TargetRect SolidMask
Definition: C4Object.h:150

Here is the call graph for this function:

Here is the caller graph for this function:

void C4Object::Clear ( )

Definition at line 2447 of file C4Object.cpp.

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

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

2448 {
2450 
2451  if (pEffects) { delete pEffects; pEffects=nullptr; }
2452  if (pSolidMaskData) { delete pSolidMaskData; pSolidMaskData=nullptr; }
2453  if (Menu) delete Menu; Menu=nullptr;
2454  if (MaterialContents) delete MaterialContents; MaterialContents=nullptr;
2455  // clear commands!
2456  C4Command *pCom, *pNext;
2457  for (pCom=Command; pCom; pCom=pNext)
2458  {
2459  pNext=pCom->Next; delete pCom; pCom=pNext;
2460  }
2461  if (pDrawTransform) { delete pDrawTransform; pDrawTransform=nullptr; }
2462  if (pGfxOverlay) { delete pGfxOverlay; pGfxOverlay=nullptr; }
2463  if (pMeshInstance) { delete pMeshInstance; pMeshInstance = nullptr; }
2464 }
C4DrawTransform * pDrawTransform
Definition: C4Object.h:137
C4Command * Next
Definition: C4Command.h:90
C4MaterialList * MaterialContents
Definition: C4Object.h:153
C4Command * Command
Definition: C4Object.h:166
void ClearParticleLists()
Definition: C4Object.cpp:248
class C4ObjectMenu * Menu
Definition: C4Object.h:140
class C4GraphicsOverlay * pGfxOverlay
Definition: C4Object.h:170
C4Effect * pEffects
Definition: C4Object.h:156
C4SolidMask * pSolidMaskData
Definition: C4Object.h:176
StdMeshInstance * pMeshInstance
Definition: C4Object.h:155

Here is the call graph for this function:

Here is the caller graph for this function:

void C4Object::ClearCommand ( C4Command pUntil)

Definition at line 2560 of file C4Object.cpp.

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

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

2561 {
2562  C4Command *pCom,*pNext;
2563  for (pCom=Command; pCom; pCom=pNext)
2564  {
2565  // Last one to clear
2566  if (pCom==pUntil) pNext=nullptr;
2567  // Next one to clear after this
2568  else pNext=pCom->Next;
2569  Command=pCom->Next;
2570  if (!pCom->iExec)
2571  delete pCom;
2572  else
2573  pCom->iExec = 2;
2574  }
2575 }
C4Command * Next
Definition: C4Command.h:90
C4Command * Command
Definition: C4Object.h:166
int32_t iExec
Definition: C4Command.h:91

Here is the caller graph for this function:

void C4Object::ClearCommands ( )

Definition at line 2546 of file C4Object.cpp.

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

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

2547 {
2548  C4Command *pNext;
2549  while (Command)
2550  {
2551  pNext=Command->Next;
2552  if (!Command->iExec)
2553  delete Command;
2554  else
2555  Command->iExec = 2;
2556  Command=pNext;
2557  }
2558 }
C4Command * Next
Definition: C4Command.h:90
C4Command * Command
Definition: C4Object.h:166
int32_t iExec
Definition: C4Command.h:91

Here is the caller graph for this function:

void C4Object::ClearContentsAndContained ( bool  fDoCalls = true)

Definition at line 4590 of file C4Object.cpp.

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

Referenced by StatusDeactivate().

4591 {
4592  // exit contents from container
4593  for (C4Object *cobj : Contents)
4594  {
4595  cobj->Exit(GetX(), GetY(), 0,Fix0,Fix0,Fix0, fDoCalls);
4596  }
4597  // remove from container *after* contents have been removed!
4598  if (Contained) Exit(GetX(), GetY(), 0, Fix0, Fix0, Fix0, fDoCalls);
4599 }
int32_t GetY() const
Definition: C4Object.h:287
C4NotifyingObjectList Contents
Definition: C4Object.h:152
bool Exit(int32_t iX=0, int32_t iY=0, int32_t iR=0, C4Real iXDir=Fix0, C4Real iYDir=Fix0, C4Real iRDir=Fix0, bool fCalls=true)
Definition: C4Object.cpp:1239
int32_t GetX() const
Definition: C4Object.h:286
C4ObjectPtr Contained
Definition: C4Object.h:144
const C4Real Fix0
Definition: C4Real.h:312

Here is the call graph for this function:

Here is the caller graph for this function:

void C4Object::ClearInfo ( C4ObjectInfo pInfo)

Definition at line 2439 of file C4Object.cpp.

References Info.

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

2440 {
2441  if (Info==pInfo)
2442  {
2443  Info=nullptr;
2444  }
2445 }
C4ObjectInfo * Info
Definition: C4Object.h:145

Here is the caller graph for this function:

void C4PropListNumbered::ClearNumber ( )
protectedinherited

Definition at line 165 of file C4PropList.cpp.

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

Referenced by C4PropListNumbered::ShelveNumberedPropLists().

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

Here is the call graph for this function:

Here is the caller graph for this function:

void C4PropListNumbered::ClearNumberedPropLists ( )
staticinherited

Definition at line 137 of file C4PropList.cpp.

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

Referenced by C4Game::Clear().

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

Here is the call graph for this function:

Here is the caller graph for this function:

void C4Object::ClearParticleLists ( )

Definition at line 248 of file C4Object.cpp.

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

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

249 {
250  if (FrontParticles != 0)
252  if (BackParticles != 0)
255 }
C4ParticleSystem Particles
class C4ParticleList * BackParticles
Definition: C4Object.h:158
void ReleaseParticleList(C4ParticleList *first, C4ParticleList *second=0)
class C4ParticleList * FrontParticles
Definition: C4Object.h:158

Here is the call graph for this function:

Here is the caller graph for this function:

void C4Object::ClearPointers ( C4Object ptr)

Definition at line 1750 of file C4Object.cpp.

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

Referenced by C4Game::ClearObjectPtrs().

1751 {
1752  // mesh attachments and animation nodes
1754  // effects
1755  if (pEffects) pEffects->ClearPointers(pObj);
1756  // contents/contained: although normally not necessery because it's done in AssignRemoval and StatusDeactivate,
1757  // it is also required during game destruction (because ClearPointers might do script callbacks)
1758  // Perform silent exit to avoid additional callbacks
1759  if (Contained == pObj)
1760  {
1761  Contained->Contents.Remove(this);
1762  Contained = nullptr;
1763  }
1764  Contents.Remove(pObj);
1765  // Action targets
1766  if (Action.Target==pObj) Action.Target=nullptr;
1767  if (Action.Target2==pObj) Action.Target2=nullptr;
1768  // Commands
1769  C4Command *cCom;
1770  for (cCom=Command; cCom; cCom=cCom->Next)
1771  cCom->ClearPointers(pObj);
1772  // Menu
1773  if (Menu) Menu->ClearPointers(pObj);
1774  // Layer
1775  if (Layer==pObj) Layer=nullptr;
1776  // gfx overlays
1777  if (pGfxOverlay)
1778  {
1779  C4GraphicsOverlay *pNextGfxOvrl = pGfxOverlay, *pGfxOvrl;
1780  while ((pGfxOvrl = pNextGfxOvrl))
1781  {
1782  pNextGfxOvrl = pGfxOvrl->GetNext();
1783  if (pGfxOvrl->GetOverlayObject() == pObj)
1784  // overlay relying on deleted object: Delete!
1785  RemoveGraphicsOverlay(pGfxOvrl->GetID());
1786  }
1787  }
1788 }
C4Command * Next
Definition: C4Command.h:90
C4Command * Command
Definition: C4Object.h:166
void ClearPointers(C4Object *pObj)
Definition: C4Command.cpp:1290
C4ObjectPtr Target2
Definition: C4Object.h:87
C4ObjectPtr Layer
Definition: C4Object.h:136
void ClearPointers(C4Object *pObj)
class C4ObjectMenu * Menu
Definition: C4Object.h:140
C4NotifyingObjectList Contents
Definition: C4Object.h:152
void ClearPointers(class C4Object *pObj)
Definition: StdMesh.cpp:1697
class C4GraphicsOverlay * pGfxOverlay
Definition: C4Object.h:170
C4ObjectPtr Target
Definition: C4Object.h:87
C4Effect * pEffects
Definition: C4Object.h:156
C4ObjectPtr Contained
Definition: C4Object.h:144
C4Action Action
Definition: C4Object.h:147
bool RemoveGraphicsOverlay(int32_t iOverlayID)
Definition: C4Object.cpp:4516
void ClearPointers(C4PropList *pObj)
Definition: C4Effect.cpp:191
StdMeshInstance * pMeshInstance
Definition: C4Object.h:155
virtual bool Remove(C4Object *pObj)
C4GraphicsOverlay * GetNext() const

Here is the call graph for this function:

Here is the caller graph for this function:

void C4PropList::ClearRefs ( )
inlineprotectedinherited

Definition at line 157 of file C4PropList.h.

References C4Value::Set0().

Referenced by AssignRemoval().

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

Here is the call graph for this function:

Here is the caller graph for this function:

void C4PropListNumbered::ClearShelve ( )
staticinherited

Definition at line 131 of file C4PropList.cpp.

References C4PropListNumbered::ShelvedPropLists.

Referenced by C4Game::Clear().

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

Here is the caller graph for this function:

bool C4Object::CloseMenu ( bool  fForce)

Definition at line 1585 of file C4Object.cpp.

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

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

1586 {
1587  if (Menu)
1588  {
1589  if (Menu->IsActive()) if (!Menu->TryClose(fForce, false)) return false;
1590  if (!Menu->IsCloseQuerying()) { delete Menu; Menu=nullptr; } // protect menu deletion from recursive menu operation calls
1591  }
1592  return true;
1593 }
class C4ObjectMenu * Menu
Definition: C4Object.h:140
bool IsActive()
Definition: C4Menu.cpp:483
bool TryClose(bool fOK, bool fControl)
Definition: C4Menu.cpp:281
bool IsCloseQuerying() const
Definition: C4ObjectMenu.h:74

Here is the call graph for this function:

Here is the caller graph for this function:

bool C4Object::Collect ( C4Object pObj)

Definition at line 4182 of file C4Object.cpp.

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

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

4183 {
4184  // Object enter container
4185  bool fRejectCollect;
4186  if (!pObj->Enter(this, true, false, &fRejectCollect))
4187  return false;
4188  // Cancel attach (hacky)
4189  ObjectComCancelAttach(pObj);
4190  // Container Collection call
4192  // Object Hit call
4193  if (pObj->Status && pObj->OCF & OCF_HitSpeed1) pObj->Call(PSF_Hit);
4194  if (pObj->Status && pObj->OCF & OCF_HitSpeed2) pObj->Call(PSF_Hit2);
4195  if (pObj->Status && pObj->OCF & OCF_HitSpeed3) pObj->Call(PSF_Hit3);
4196  // post-copy the motion of the new container
4197  if (pObj->Contained == this) pObj->CopyMotion(this);
4198  // done, success
4199  return true;
4200 }
const uint32_t OCF_HitSpeed1
Definition: C4Constants.h:84
bool Enter(C4Object *pTarget, bool fCalls=true, bool fCopyMotion=true, bool *pfRejectCollect=nullptr)
Definition: C4Object.cpp:1275
#define PSF_Hit
Definition: C4GameScript.h:49
bool ObjectComCancelAttach(C4Object *cObj)
const uint32_t OCF_HitSpeed2
Definition: C4Constants.h:91
#define PSF_Hit2
Definition: C4GameScript.h:50
int32_t Status
Definition: C4PropList.h:169
void CopyMotion(C4Object *from)
Definition: C4Movement.cpp:504
#define PSF_Hit3
Definition: C4GameScript.h:51
const uint32_t OCF_HitSpeed3
Definition: C4Constants.h:92
#define PSF_Collection
Definition: C4GameScript.h:56
C4ObjectPtr Contained
Definition: C4Object.h:144
uint32_t OCF
Definition: C4Object.h:134
C4Value Call(C4PropertyName k, C4AulParSet *pPars=0, bool fPassErrors=false)
Definition: C4PropList.h:112

Here is the call graph for this function:

Here is the caller graph for this function:

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

Definition at line 2173 of file C4Object.cpp.

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

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

Here is the call graph for this function:

bool C4Object::Contact ( int32_t  cnat)

Definition at line 115 of file C4Movement.cpp.

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

Referenced by ContactCheck(), and StopAndContact().

116 {
118  {
119  return !! Call(FormatString(PSF_Contact, CNATName(iCNAT)).getData());
120  }
121  return false;
122 }
const char * CNATName(int32_t cnat)
Definition: C4Movement.cpp:101
#define PSF_Contact
Definition: C4GameScript.h:69
int32_t GetPropertyInt(C4PropertyName k, int32_t default_val=0) const
Definition: C4PropList.cpp:841
C4Value Call(C4PropertyName k, C4AulParSet *pPars=0, bool fPassErrors=false)
Definition: C4PropList.h:112
StdStrBuf FormatString(const char *szFmt,...)
Definition: StdBuf.cpp:277

Here is the call graph for this function:

Here is the caller graph for this function:

void C4Object::ContactAction ( )

Definition at line 2932 of file C4Object.cpp.

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

Referenced by DoMovement().

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

Here is the call graph for this function:

Here is the caller graph for this function:

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

Definition at line 137 of file C4Movement.cpp.

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

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

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

Here is the call graph for this function:

Here is the caller graph for this function:

void C4Object::CopyMotion ( C4Object from)

Definition at line 504 of file C4Movement.cpp.

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

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

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

Here is the call graph for this function:

Here is the caller graph for this function:

C4Object * C4Object::CreateContents ( C4PropList PropList)

Definition at line 1451 of file C4Object.cpp.

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

Referenced by CreateContentsByList().

1452 {
1453  C4Object *nobj;
1454  if (!(nobj=Game.CreateObject(PropList,this,Owner))) return nullptr;
1455  if (!nobj->Enter(this)) { nobj->AssignRemoval(); return nullptr; }
1456  return nobj;
1457 }
bool Enter(C4Object *pTarget, bool fCalls=true, bool fCopyMotion=true, bool *pfRejectCollect=nullptr)
Definition: C4Object.cpp:1275
C4Game Game
Definition: C4Globals.cpp:52
int32_t Owner
Definition: C4Object.h:110
void AssignRemoval(bool fExitContents=false)
Definition: C4Object.cpp:257
C4Object * CreateObject(C4PropList *type, C4Object *pCreator, int32_t owner=NO_OWNER, int32_t x=50, int32_t y=50, int32_t r=0, bool grow_from_center=false, C4Real xdir=Fix0, C4Real ydir=Fix0, C4Real rdir=Fix0, int32_t iController=NO_OWNER)
Definition: C4Game.cpp:1076

Here is the call graph for this function:

Here is the caller graph for this function:

bool C4Object::CreateContentsByList ( C4IDList idlist)

Definition at line 1459 of file C4Object.cpp.

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

Referenced by C4Player::PlaceReadyMaterial().

1460 {
1461  int32_t cnt,cnt2;
1462  for (cnt=0; idlist.GetID(cnt); cnt++)
1463  for (cnt2=0; cnt2<idlist.GetCount(cnt); cnt2++)
1464  if (!CreateContents(C4Id2Def(idlist.GetID(cnt))))
1465  return false;
1466  return true;
1467 }
int32_t GetCount(size_t index) const
Definition: C4IDList.cpp:111
C4Object * CreateContents(C4PropList *)
Definition: C4Object.cpp:1451
C4Def * C4Id2Def(C4ID id)
Definition: C4DefList.h:80
C4ID GetID(size_t index, int32_t *ipCount=nullptr) const
Definition: C4IDList.cpp:99

Here is the call graph for this function:

Here is the caller graph for this function:

void C4Object::Default ( )

Definition at line 94 of file C4Object.cpp.

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

Referenced by C4Object().

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

Here is the call graph for this function:

Here is the caller graph for this function:

virtual bool C4PropList::Delete ( )
inlinevirtualinherited

Reimplemented in C4PropListStaticMember, C4PropListStatic, C4PropListScript, and C4Def.

Definition at line 92 of file C4PropList.h.

Referenced by C4ScriptHost::DeleteOwnedPropLists().

92 { return false; }

Here is the caller graph for this function:

void C4Object::Denumerate ( C4ValueNumbers numbers)
virtual

Reimplemented from C4PropList.

Definition at line 2323 of file C4Object.cpp.

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

Referenced by C4ObjectList::Denumerate().

2324 {
2325  C4PropList::Denumerate(numbers);
2326  // Standard enumerated pointers
2331 
2332  // Post-compile object list
2334 
2335  // Commands
2336  for (C4Command *pCom=Command; pCom; pCom=pCom->Next)
2337  pCom->Denumerate(numbers);
2338 
2339  // effects
2340  if (pEffects) pEffects->Denumerate(numbers);
2341 
2342  // gfx overlays
2343  if (pGfxOverlay)
2344  for (C4GraphicsOverlay *pGfxOvrl = pGfxOverlay; pGfxOvrl; pGfxOvrl = pGfxOvrl->GetNext())
2345  pGfxOvrl->DenumeratePointers();
2346 
2347  // mesh instance
2349 }
bool DenumeratePointers()
C4Command * Next
Definition: C4Command.h:90
C4Command * Command
Definition: C4Object.h:166
C4ObjectPtr Target2
Definition: C4Object.h:87
C4ObjectPtr Layer
Definition: C4Object.h:136
void DenumeratePointers()
Definition: C4ObjectPtr.cpp:46
virtual void Denumerate(C4ValueNumbers *)
Definition: C4PropList.cpp:329
C4NotifyingObjectList Contents
Definition: C4Object.h:152
void DenumeratePointers()
Definition: StdMesh.cpp:1685
class C4GraphicsOverlay * pGfxOverlay
Definition: C4Object.h:170
C4ObjectPtr Target
Definition: C4Object.h:87
void Denumerate(C4ValueNumbers *)
Definition: C4Effect.cpp:176
C4Effect * pEffects
Definition: C4Object.h:156
C4ObjectPtr Contained
Definition: C4Object.h:144
C4Action Action
Definition: C4Object.h:147
StdMeshInstance * pMeshInstance
Definition: C4Object.h:155
C4GraphicsOverlay * GetNext() const

Here is the call graph for this function:

Here is the caller graph for this function:

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

Definition at line 4258 of file C4Object.cpp.

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

Referenced by ShiftContents().

4259 {
4260  // safety
4261  if (!pTarget || !pTarget->Status || pTarget->Contained != this) return;
4262  // Desired object already at front?
4263  if (Contents.GetObject() == pTarget) return;
4264  // select object via script?
4265  if (fDoCalls)
4266  if (Call("~ControlContents", &C4AulParSet(pTarget)))
4267  return;
4268  // default action
4269  if (!(Contents.ShiftContents(pTarget))) return;
4270  // Selection sound
4271  if (fDoCalls) if (!Contents.GetObject()->Call("~Selection", &C4AulParSet(this))) StartSoundEffect("Clonk::Action::Grab",false,100,this);
4272  // update menu with the new item in "put" entry
4273  if (Menu && Menu->IsActive() && Menu->IsContextMenu())
4274  {
4275  Menu->Refill();
4276  }
4277  // Done
4278  return;
4279 }
bool IsContextMenu()
Definition: C4Menu.h:164
bool Refill()
Definition: C4Menu.cpp:918
bool ShiftContents(C4Object *pNewFirst)
C4SoundInstance * StartSoundEffect(const char *szSndName, bool fLoop, int32_t iVolume, C4Object *pObj, int32_t iCustomFalloffDistance, int32_t iPitch, C4SoundModifier *modifier)
class C4ObjectMenu * Menu
Definition: C4Object.h:140
C4NotifyingObjectList Contents
Definition: C4Object.h:152
C4Object * GetObject(int Index=0) const
int32_t Status
Definition: C4PropList.h:169
bool IsActive()
Definition: C4Menu.cpp:483
C4ObjectPtr Contained
Definition: C4Object.h:144
C4Value Call(C4PropertyName k, C4AulParSet *pPars=0, bool fPassErrors=false)
Definition: C4PropList.h:112

Here is the call graph for this function:

Here is the caller graph for this function:

void C4Object::DoBreath ( int32_t  iChange)

Definition at line 1158 of file C4Object.cpp.

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

Referenced by ExecLife().

1159 {
1160  // Do change
1161  iChange = Clamp<int32_t>(iChange, -Breath, GetPropertyInt(P_MaxBreath) - Breath);
1162  Breath += iChange;
1163  // call to object
1164  Call(PSF_BreathChange,&C4AulParSet(iChange));
1165 }
int32_t Breath
Definition: C4Object.h:118
int32_t GetPropertyInt(C4PropertyName k, int32_t default_val=0) const
Definition: C4PropList.cpp:841
#define PSF_BreathChange
Definition: C4GameScript.h:143
C4Value Call(C4PropertyName k, C4AulParSet *pPars=0, bool fPassErrors=false)
Definition: C4PropList.h:112

Here is the call graph for this function:

Here is the caller graph for this function:

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

Definition at line 1167 of file C4Object.cpp.

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

Referenced by C4Game::NewObject().

1168 {
1169  C4Real strgt_con_b = fix_y + Shape.GetBottom();
1170  bool fWasFull = (Con>=FullCon);
1171  int32_t old_con = Con;
1172 
1173  // Change con
1174  if (Def->Oversize)
1175  Con=std::max<int32_t>(Con+iChange,0);
1176  else
1177  Con=Clamp<int32_t>(Con+iChange,0,FullCon);
1178 
1179  // Update OCF
1180  SetOCF();
1181 
1182  // Mass
1183  UpdateMass();
1184 
1185  // shape and position
1186  UpdateShape();
1187  // make the bottom-most vertex stay in place
1188  if (!grow_from_center)
1189  {
1190  fix_y = strgt_con_b - Shape.GetBottom();
1191  }
1192  // Face (except for the shape)
1193  UpdateFace(false);
1194 
1195  // Do a callback on completion change.
1196  if (iChange != 0)
1197  Call(PSF_OnCompletionChange, &C4AulParSet(old_con, Con));
1198 
1199  // Unfullcon
1200  if (fWasFull && (Con<FullCon))
1201  {
1202  // Lose contents
1203  if (!Def->IncompleteActivity)
1204  {
1205  C4Object *cobj;
1206  while ((cobj=Contents.GetObject()))
1207  if (Contained) cobj->Enter(Contained);
1208  else cobj->Exit(cobj->GetX(),cobj->GetY());
1209  SetAction(0);
1210  }
1211  }
1212 
1213  // Completion
1214  if (!fWasFull && (Con>=FullCon))
1216 
1217  // Con Zero Removal
1218  if (Con<=0)
1219  AssignRemoval();
1220  // Mesh Graphics Update
1221  else if(pMeshInstance)
1222  pMeshInstance->SetCompletion(Def->GrowthType ? 1.0f : static_cast<float>(Con)/static_cast<float>(FullCon));
1223 }
int32_t GetY() const
Definition: C4Object.h:287
bool Enter(C4Object *pTarget, bool fCalls=true, bool fCopyMotion=true, bool *pfRejectCollect=nullptr)
Definition: C4Object.cpp:1275
int GetBottom()
Definition: C4Shape.cpp:471
Definition: C4Real.h:58
const int32_t FullCon
Definition: C4Constants.h:182
#define PSF_Initialize
Definition: C4GameScript.h:34
C4NotifyingObjectList Contents
Definition: C4Object.h:152
int32_t GrowthType
Definition: C4Def.h:113
C4Def * Def
Definition: C4Object.h:143
void UpdateShape(bool bUpdateVertices=true)
Definition: C4Object.cpp:346
int32_t Con
Definition: C4Object.h:173
bool SetAction(C4PropList *Act, C4Object *pTarget=nullptr, C4Object *pTarget2=nullptr, int32_t iCalls=SAC_StartCall|SAC_AbortCall, bool fForce=false)
Definition: C4Object.cpp:2696
bool Exit(int32_t iX=0, int32_t iY=0, int32_t iR=0, C4Real iXDir=Fix0, C4Real iYDir=Fix0, C4Real iRDir=Fix0, bool fCalls=true)
Definition: C4Object.cpp:1239
#define PSF_OnCompletionChange
Definition: C4GameScript.h:103
int32_t GetX() const
Definition: C4Object.h:286
void AssignRemoval(bool fExitContents=false)
Definition: C4Object.cpp:257
C4Object * GetObject(int Index=0) const
void UpdateMass()
Definition: C4Object.cpp:642
int32_t Oversize
Definition: C4Def.h:132
void UpdateFace(bool bUpdateShape, bool fTemp=false)
Definition: C4Object.cpp:381
void SetCompletion(float completion)
Definition: StdMesh.cpp:1165
int32_t IncompleteActivity
Definition: C4Def.h:130
C4Real fix_y
Definition: C4Object.h:125
void SetOCF()
Definition: C4Object.cpp:670
C4ObjectPtr Contained
Definition: C4Object.h:144
C4Shape Shape
Definition: C4Object.h:148
C4Value Call(C4PropertyName k, C4AulParSet *pPars=0, bool fPassErrors=false)
Definition: C4PropList.h:112
StdMeshInstance * pMeshInstance
Definition: C4Object.h:155

Here is the call graph for this function:

Here is the caller graph for this function:

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

Definition at line 1107 of file C4Object.cpp.

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

1108 {
1109  // non-living: ask effects first
1110  if (pEffects && !Alive)
1111  {
1112  pEffects->DoDamage(iChange, iCause, iCausedBy);
1113  if (!iChange) return;
1114  }
1115  // Change value
1116  Damage = std::max<int32_t>( Damage+iChange, 0 );
1117  // Engine script call
1118  Call(PSF_Damage,&C4AulParSet(iChange, iCause, iCausedBy));
1119 }
bool Alive
Definition: C4Object.h:175
#define PSF_Damage
Definition: C4GameScript.h:63
int32_t Damage
Definition: C4Object.h:116
C4Effect * pEffects
Definition: C4Object.h:156
C4Value Call(C4PropertyName k, C4AulParSet *pPars=0, bool fPassErrors=false)
Definition: C4PropList.h:112
void DoDamage(int32_t &riDamage, int32_t iDamageType, int32_t iCausePlr)
Definition: C4Effect.cpp:394

Here is the call graph for this function:

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

Definition at line 1121 of file C4Object.cpp.

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

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

1122 {
1123  if (!fExact)
1124  {
1125  // Clamp range of change to prevent integer overflow errors
1126  // Do not clamp directly to (0...MaxEnergy)-current_energy, because
1127  // the change value calculated here may be reduced by effect callbacks
1128  int32_t scale = C4MaxPhysical / 100; // iChange 100% = Physical 100000
1129  iChange = Clamp<int32_t>(iChange, std::numeric_limits<int32_t>::min()/scale, std::numeric_limits<int32_t>::max()/scale)*scale;
1130  }
1131  // Was zero?
1132  bool fWasZero=(Energy==0);
1133  // Mark last damage causing player to trace kills
1134  if (iChange < 0) UpdatLastEnergyLossCause(iCausedByPlr);
1135  // Living things: ask effects for change first
1136  if (pEffects && Alive)
1137  pEffects->DoDamage(iChange, iCause, iCausedByPlr);
1138  // Do change
1139  iChange = Clamp<int32_t>(iChange, -Energy, GetPropertyInt(P_MaxEnergy) - Energy);
1140  Energy += iChange;
1141  // call to object
1142  Call(PSF_EnergyChange,&C4AulParSet(iChange, iCause, iCausedByPlr));
1143  // Alive and energy reduced to zero: death
1144  if (Alive) if (Energy==0) if (!fWasZero) AssignDeath(false);
1145 }
const int32_t C4MaxPhysical
Definition: C4InfoCore.h:29
bool Alive
Definition: C4Object.h:175
#define PSF_EnergyChange
Definition: C4GameScript.h:142
void AssignDeath(bool fForced)
Definition: C4Object.cpp:1004
void UpdatLastEnergyLossCause(int32_t iNewCausePlr)
Definition: C4Object.cpp:1147
int32_t Energy
Definition: C4Object.h:117
int32_t GetPropertyInt(C4PropertyName k, int32_t default_val=0) const
Definition: C4PropList.cpp:841
C4Effect * pEffects
Definition: C4Object.h:156
C4Value Call(C4PropertyName k, C4AulParSet *pPars=0, bool fPassErrors=false)
Definition: C4PropList.h:112
void DoDamage(int32_t &riDamage, int32_t iDamageType, int32_t iCausePlr)
Definition: C4Effect.cpp:394

Here is the call graph for this function:

Here is the caller graph for this function:

void C4Object::DoExperience ( int32_t  change)

Definition at line 1225 of file C4Object.cpp.

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

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

1226 {
1227  const int32_t MaxExperience = 100000000;
1228 
1229  if (!Info) return;
1230 
1231  Info->Experience=Clamp<int32_t>(Info->Experience+change,0,MaxExperience);
1232 
1233  // Promotion check
1234  if (Info->Experience<MaxExperience)
1236  Promote(Info->Rank+1, false, false);
1237 }
C4RankSystem DefaultRanks
bool Promote(int32_t torank, bool exception, bool fForceRankName)
Definition: C4Object.cpp:1727
C4ObjectInfo * Info
Definition: C4Object.h:145
int32_t Experience
Definition: C4InfoCore.h:44
int Experience(int iRank)

Here is the call graph for this function:

Here is the caller graph for this function:

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

Definition at line 124 of file C4Movement.cpp.

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

Referenced by DoMovement().

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

Here is the call graph for this function:

Here is the caller graph for this function:

void C4Object::DoMovement ( )

Definition at line 203 of file C4Movement.cpp.

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

Referenced by ExecMovement().

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

Here is the call graph for this function:

Here is the caller graph for this function:

bool C4Object::DoSelect ( )

Definition at line 4324 of file C4Object.cpp.

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

Referenced by C4Player::SetCursor().

4325 {
4326  // selection allowed?
4327  if (CrewDisabled) return false;
4328  // do callback
4330  // done
4331  return true;
4332 }
#define PSF_CrewSelection
Definition: C4GameScript.h:86
bool CrewDisabled
Definition: C4Object.h:163
C4Value Call(C4PropertyName k, C4AulParSet *pPars=0, bool fPassErrors=false)
Definition: C4PropList.h:112

Here is the call graph for this function:

Here is the caller graph for this function:

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

Definition at line 1800 of file C4Object.cpp.

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

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

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