OpenClonk
C4Object.cpp
Go to the documentation of this file.
1 /*
2  * OpenClonk, http://www.openclonk.org
3  *
4  * Copyright (c) 1998-2000, Matthes Bender
5  * Copyright (c) 2001-2009, RedWolf Design GmbH, http://www.clonk.de/
6  * Copyright (c) 2009-2016, The OpenClonk Team and contributors
7  *
8  * Distributed under the terms of the ISC license; see accompanying file
9  * "COPYING" for details.
10  *
11  * "Clonk" is a registered trademark of Matthes Bender, used with permission.
12  * See accompanying file "TRADEMARK" for details.
13  *
14  * To redistribute this file separately, substitute the full license texts
15  * for the above references.
16  */
17 
18 /* That which fills the world with life */
19 
20 #include "C4Include.h"
22 #include "object/C4Object.h"
23 
24 #include "control/C4Record.h"
25 #include "game/C4Viewport.h"
26 #include "gui/C4GameMessage.h"
28 #include "landscape/C4PXS.h"
29 #include "landscape/C4Particles.h"
30 #include "landscape/C4SolidMask.h"
31 #include "landscape/fow/C4FoW.h"
32 #include "object/C4Command.h"
33 #include "object/C4Def.h"
34 #include "object/C4DefList.h"
35 #include "object/C4GameObjects.h"
37 #include "object/C4ObjectInfo.h"
38 #include "object/C4ObjectMenu.h"
39 #include "platform/C4SoundSystem.h"
40 #include "player/C4Player.h"
41 #include "player/C4PlayerList.h"
42 #include "script/C4Effect.h"
43 
45 {
46  FrontParticles = BackParticles = nullptr;
47  Default();
48 }
49 
51 {
52  id=C4ID::None;
53  nInfo.Clear();
54  RemovalDelay=0;
58  Category=0;
59  Con=0;
60  Mass=OwnMass=0;
61  Damage=0;
62  Energy=0;
63  Alive=false;
64  Breath=0;
65  InMat=MNone;
66  Color=0;
67  lightRange=0;
69  lightColor=0xffffffff;
70  fix_x=fix_y=fix_r=0;
71  xdir=ydir=rdir=0;
72  Mobile=false;
73  Unsorted=false;
74  Initializing=false;
75  OnFire=false;
76  InLiquid=false;
77  EntranceStatus=false;
80  t_contact=0;
81  OCF=0;
82  Action.Default();
83  Shape.Default();
84  fOwnVertices=false;
85  Contents.Default();
89  Def=nullptr;
90  Info=nullptr;
91  Command=nullptr;
92  Contained=nullptr;
93  TopFace.Default();
94  Menu=nullptr;
95  MaterialContents=nullptr;
96  Marker=0;
97  ColorMod=0xffffffff;
98  BlitMode=0;
99  CrewDisabled=false;
100  Layer=nullptr;
101  pSolidMaskData=nullptr;
102  pGraphics=nullptr;
103  pMeshInstance=nullptr;
104  pDrawTransform=nullptr;
105  pEffects=nullptr;
106  pGfxOverlay=nullptr;
108 
110 }
111 
112 bool C4Object::Init(C4PropList *pDef, C4Object *pCreator,
113  int32_t iOwner, C4ObjectInfo *pInfo,
114  int32_t nx, int32_t ny, int32_t nr,
115  C4Real nxdir, C4Real nydir, C4Real nrdir, int32_t iController)
116 {
118  // currently initializing
119  Initializing=true;
120 
121  // Def & basics
122  Owner=iOwner;
123  if (iController > NO_OWNER) Controller = iController; else Controller=iOwner;
125  Info=pInfo;
126  Def=pDef->GetDef(); assert(Def);
128  id=Def->id;
129  if (Info) SetName(pInfo->Name);
131  Plane = Def->GetPlane(); assert(Plane);
132  Def->Count++;
133  if (pCreator) Layer=pCreator->Layer;
134 
135  // graphics
136  pGraphics = &Def->Graphics;
138  {
139  pMeshInstance = new StdMeshInstance(*pGraphics->Mesh, Def->GrowthType ? 1.0f : static_cast<float>(Con)/static_cast<float>(FullCon));
141  }
142  else
143  {
144  pMeshInstance = nullptr;
145  }
146  BlitMode = Def->BlitMode;
147 
148  // Position
149  if (!Def->Rotateable) { nr=0; nrdir=0; }
150  fix_x=itofix(nx);
151  fix_y=itofix(ny);
152  fix_r=itofix(nr);
153  xdir=nxdir; ydir=nydir; rdir=nrdir;
154 
155  // Initial mobility
156  if (!!xdir || !!ydir || !!rdir)
157  Mobile=true;
158 
159  // Mass
160  Mass=std::max<int32_t>(Def->Mass*Con/FullCon,1);
161 
162  // Life, energy, breath
163  if (Category & C4D_Living) Alive=true;
166 
167  // Color
168  if (Def->ColorByOwner)
169  {
170  if (ValidPlr(Owner))
172  else
173  Color=0xff; // no-owner color: blue
174  }
175 
176  // Shape & face
177  Shape=Def->Shape;
180  UpdateGraphics(false);
181  UpdateFace(true);
182 
183  // Initial audibility
185 
186  // Initial OCF
187  SetOCF();
188 
189  // finished initializing
190  Initializing=false;
191 
192  return true;
193 }
194 
196 {
197  Clear();
198 
199 #if defined(_DEBUG)
200  // debug: mustn't be listed in any list now
202 #endif
203 }
204 
206 {
207  if (FrontParticles != nullptr)
209  if (BackParticles != nullptr)
211  FrontParticles = BackParticles = nullptr;
212 }
213 
214 // Start removing the object and do all the callbacks; See also FinishRemoval
215 void C4Object::AssignRemoval(bool exit_contents)
216 {
217  // Multiple calls to this functions can cause really bad problems, so we have to cancel
218  // in case the object is deleted or being deleted (final deletion happens after removal delay):
219  // - the def count may be decreased several times. This is really hard to notice if there
220  // are a lot of objects, because you have to delete at least half of them to get to a
221  // negative count, and even then it will only have an effect for functions that
222  // actually evaluate the def count.
223  // - object status and effects must be updated before the object is removed,
224  // but at the same time a lot if functions rely on the object being properly
225  // deleted when the status of an object is C4OS_DELETED.
226  if (Status == C4OS_DELETED || RemovalDelay > 0)
227  {
228  return;
229  }
230  // Set status to deleting, so that callbacks in this function that might delete
231  // the object do not delete it a second time.
232  RemovalDelay = 2;
233 
234  // Debugging
235  if (Config.General.DebugRec)
236  {
237  C4RCCreateObj rc;
238  memset(&rc, '\0', sizeof(rc));
239  rc.oei = Number;
240  if (Def && Def->GetName())
241  {
242  strncpy(rc.id, Def->GetName(), 32+1);
243  }
244  rc.x = GetX();
245  rc.y = GetY();
246  rc.ownr = Owner;
247  AddDbgRec(RCT_DsObj, &rc, sizeof(rc));
248  }
249 
250  // Destruction call notification for container
251  if (Contained)
252  {
253  C4AulParSet pars(this);
255  }
256 
257  // Destruction call
259 
260  // Remove all effects (extinguishes as well)
261  if (pEffects)
262  {
264  }
265 
266  // Remove particles
268 
269  // Action idle
270  SetAction(nullptr);
271 
272  // Object system operation
273  if (Status == C4OS_INACTIVE)
274  {
275  // Object was inactive: activate first, then delete
278  ::Objects.Add(this);
279  }
280 
282  // count decrease
283  Def->Count--;
284 
285  // get container for next actions
286  C4Object *pCont = Contained;
287  // remove or exit contents
288  for (C4Object *cobj : Contents)
289  {
290  if (exit_contents)
291  {
292  // move objects to parent container or exit them completely
293  bool fRejectCollect;
294  if (!pCont || !cobj->Enter(pCont, true, false, &fRejectCollect))
295  cobj->Exit(GetX(), GetY());
296  }
297  else
298  {
299  Contents.Remove(cobj);
300  cobj->Contained = nullptr;
301  cobj->AssignRemoval();
302  }
303  }
304  // remove this object from container *after* its contents have been removed!
305  if (pCont)
306  {
307  pCont->Contents.Remove(this);
308  pCont->UpdateMass();
309  pCont->SetOCF();
310  Contained=nullptr;
311  }
312  // Object info
313  if (Info) Info->Retire();
314  Info = nullptr;
315  // Object system operation
316  ClearRefs();
317  Game.ClearPointers(this);
318  ClearCommands();
319  if (pSolidMaskData)
320  {
321  delete pSolidMaskData;
322  pSolidMaskData = nullptr;
323  }
324  SolidMask.Wdt = 0;
325 }
326 
327 void C4Object::UpdateShape(bool bUpdateVertices)
328 {
329 
330  // Line shape independent
331  if (Def->Line) return;
332 
333  // Copy shape from def
334  Shape.CopyFrom(Def->Shape, bUpdateVertices, !!fOwnVertices);
335 
336  // Construction zoom
337  if (Con!=FullCon)
338  {
339  if (Def->GrowthType)
340  Shape.Stretch(Con, bUpdateVertices);
341  else
342  Shape.Jolt(Con, bUpdateVertices);
343  }
344 
345  // Rotation
346  if (Def->Rotateable)
347  if (fix_r != Fix0)
348  Shape.Rotate(fix_r, bUpdateVertices);
349 
350  // covered area changed? to be on the save side, update pos
351  UpdatePos();
352 }
353 
355 {
356  // Breathing
357  if (!::Game.iTick5)
358  if (Alive && !Def->NoBreath)
359  {
360  // Supply check
361  bool Breathe=false;
362  // Forcefields are breathable.
363  if (GBackMat(GetX(), GetY()+Shape.GetY()/2)==MVehic)
364  { Breathe=true; }
365  else if (GetPropertyInt(P_BreatheWater))
366  { if (GBackMat(GetX(), GetY())==MWater) Breathe=true; }
367  else
368  { if (!GBackSemiSolid(GetX(), GetY()+Shape.GetY()/2)) Breathe=true; }
369  if (Contained) Breathe=true;
370  // No supply
371  if (!Breathe)
372  {
373  // Reduce breath, then energy, bubble
374  if (Breath > 0) DoBreath(-5);
376  }
377  // Supply
378  else
379  {
380  // Take breath
381  int32_t takebreath = GetPropertyInt(P_MaxBreath) - Breath;
382  if (takebreath > 0) DoBreath(takebreath);
383  }
384  }
385 
386  // Corrosion energy loss
387  if (!::Game.iTick10)
388  if (Alive)
389  if (InMat!=MNone)
393 
394  // InMat incineration
395  if (!::Game.iTick10)
396  if (InMat!=MNone)
399  {
401  }
402 
403  // birthday
404  if (!::Game.iTick255)
405  if (Alive)
406  if (Info)
407  {
408  int32_t iPlayingTime = Info->TotalPlayingTime + (Game.Time - Info->InActionTime);
409 
410  int32_t iNewAge = iPlayingTime / 3600 / 5;
411 
412  if (Info->Age != iNewAge && Info->Age)
413  {
414  // message
415  GameMsgObject(FormatString(LoadResStr("IDS_OBJ_BIRTHDAY"),GetName (), Info->TotalPlayingTime / 3600 / 5).getData(),this);
416  StartSoundEffect("UI::Trumpet",false,100,this);
417  }
418 
419  Info->Age = iNewAge;
420 
421 
422  }
423 
424  return true;
425 }
426 
428 {
429  if (Config.General.DebugRec)
430  {
431  // record debug
432  C4RCExecObj rc;
433  rc.Number=Number;
434  rc.fx=fix_x;
435  rc.fy=fix_y;
436  rc.fr=fix_r;
437  AddDbgRec(RCT_ExecObj, &rc, sizeof(rc));
438  }
439  // OCF
440  UpdateOCF();
441  // Command
442  ExecuteCommand();
443  // Action
444  // need not check status, because dead objects have lost their action
445  ExecAction();
446  // commands and actions are likely to have removed the object, and movement
447  // *must not* be executed for dead objects (SolidMask-errors)
448  if (!Status) return;
449  // Movement
450  ExecMovement();
451  if (!Status) return;
452  // effects
453  if (pEffects)
454  {
456  if (!Status) return;
457  }
458  // Life
459  ExecLife();
460  // Animation. If the mesh is attached, then don't execute animation here but let the parent object do it to make sure it is only executed once a frame.
462  pMeshInstance->ExecuteAnimation(1.0f/37.0f /* play smoothly at 37 FPS */);
463  // Menu
464  if (Menu) Menu->Execute();
465 }
466 
467 void C4Object::AssignDeath(bool fForced)
468 {
469  C4Object *thing;
470  // Alive objects only
471  if (!Alive) return;
472  // clear all effects
473  // do not delete effects afterwards, because they might have denied removal
474  // set alive-flag before, so objects know what's up
475  // and prevent recursive death-calls this way
476  // get death causing player before doing effect calls, because those might meddle around with the flags
477  int32_t iDeathCausingPlayer = LastEnergyLossCausePlayer;
478  Alive=false;
480  // if the object is alive again, abort here if the kill is not forced
481  if (Alive && !fForced) return;
482  // Action
483  SetActionByName("Dead");
484  // Values
485  Alive=false;
486  ClearCommands();
487  C4ObjectInfo * pInfo = Info;
488  if (Info)
489  {
490  Info->HasDied=true;
491  ++Info->DeathCount;
492  Info->Retire();
493  }
494  // Remove from crew/cursor/view
495  C4Player *pPlr = ::Players.Get(Owner);
496  if (pPlr) pPlr->ClearPointers(this, true);
497  // Remove from light sources
498  SetLightRange(0,0);
499  // Engine script call
500  C4AulParSet pars(iDeathCausingPlayer);
501  Call(PSF_Death, &pars);
502  // Lose contents
503  while ((thing=Contents.GetObject())) thing->Exit(thing->GetX(),thing->GetY());
504  // Update OCF. Done here because previously it would have been done in the next frame
505  // Whats worse: Having the OCF change because of some unrelated script-call like
506  // SetCategory, or slightly breaking compatibility?
507  SetOCF();
508  // Engine broadcast: relaunch player (in CR, this was called from clonk script.
509  // Now, it is done for every crew member)
510  if(pPlr)
511  if(!pPlr->Crew.ObjectCount())
513  &C4AulParSet(Owner, iDeathCausingPlayer, Status ? this : nullptr));
514  if (pInfo)
515  pInfo->HasDied = false;
516 }
517 
519 {
520  // Get new definition
521  C4Def *pDef=C4Id2Def(idNew);
522  if (!pDef) return false;
523  // Containment storage
524  C4Object *pContainer=Contained;
525  // Exit container (no Ejection/Departure)
526  if (Contained) Exit(0,0,0,Fix0,Fix0,Fix0,false);
527  // Pre change resets
528  SetAction(nullptr);
529  ResetProperty(&Strings.P[P_Action]); // Enforce ActIdle because SetAction may have failed due to NoOtherAction
530  SetDir(0); // will drop any outdated flipdir
531  if (pSolidMaskData) { delete pSolidMaskData; pSolidMaskData=nullptr; }
532  Def->Count--;
533  // Def change
534  Def=pDef;
536  id=pDef->id;
537  Def->Count++;
538  // new def: Needs to be resorted
539  Unsorted=true;
540  // graphics change
541  pGraphics = &pDef->Graphics;
542  // blit mode adjustment
544  // an object may have newly become an ColorByOwner-object
545  // if it had been ColorByOwner, but is not now, this will be caught in UpdateGraphics()
546  if (!Color && ValidPlr(Owner))
548  if (!Def->Rotateable) { fix_r=rdir=Fix0; }
549  // Reset solid mask
551  HalfVehicleSolidMask=false;
552  // Post change updates
553  UpdateGraphics(true);
554  UpdateMass();
555  UpdateFace(true);
556  SetOCF();
557  // Any effect callbacks to this object might need to reinitialize their target functions
558  // This is ugly, because every effect there is must be updated...
563  for (C4Object *obj : Objects)
564  if (obj->pEffects) obj->pEffects->OnObjectChangedDef(this);
565  // Containment (no Entrance)
566  if (pContainer) Enter(pContainer,false);
567  // Done
568  return true;
569 }
570 
571 void C4Object::DoDamage(int32_t iChange, int32_t iCausedBy, int32_t iCause)
572 {
573  // non-living: ask effects first
574  if (pEffects && !Alive)
575  {
576  pEffects->DoDamage(iChange, iCause, iCausedBy);
577  if (!iChange) return;
578  }
579  // Change value
580  Damage = std::max<int32_t>( Damage+iChange, 0 );
581  // Engine script call
582  Call(PSF_Damage,&C4AulParSet(iChange, iCause, iCausedBy));
583 }
584 
585 void C4Object::DoEnergy(int32_t iChange, bool fExact, int32_t iCause, int32_t iCausedByPlr)
586 {
587  if (!fExact)
588  {
589  // Clamp range of change to prevent integer overflow errors
590  // Do not clamp directly to (0...MaxEnergy)-current_energy, because
591  // the change value calculated here may be reduced by effect callbacks
592  int32_t scale = C4MaxPhysical / 100; // iChange 100% = Physical 100000
593  iChange = Clamp<int32_t>(iChange, std::numeric_limits<int32_t>::min()/scale, std::numeric_limits<int32_t>::max()/scale)*scale;
594  }
595  // Was zero?
596  bool fWasZero=(Energy==0);
597  // Mark last damage causing player to trace kills
598  if (iChange < 0) UpdatLastEnergyLossCause(iCausedByPlr);
599  // Living things: ask effects for change first
600  if (pEffects && Alive)
601  pEffects->DoDamage(iChange, iCause, iCausedByPlr);
602  // Do change
603  iChange = Clamp<int32_t>(iChange, -Energy, GetPropertyInt(P_MaxEnergy) - Energy);
604  Energy += iChange;
605  // call to object
606  Call(PSF_EnergyChange,&C4AulParSet(iChange, iCause, iCausedByPlr));
607  // Alive and energy reduced to zero: death
608  if (Alive) if (Energy==0) if (!fWasZero) AssignDeath(false);
609 }
610 
611 void C4Object::UpdatLastEnergyLossCause(int32_t iNewCausePlr)
612 {
613  // Mark last damage causing player to trace kills
614  // do not regard self-administered damage if there was a previous damage causing player, because that would steal kills
615  // if people tumble themselves via stop-stop-(left/right)-throw while falling into teh abyss
616  if (iNewCausePlr != Controller || LastEnergyLossCausePlayer < 0)
617  {
618  LastEnergyLossCausePlayer = iNewCausePlr;
619  }
620 }
621 
622 void C4Object::DoBreath(int32_t iChange)
623 {
624  // Do change
625  iChange = Clamp<int32_t>(iChange, -Breath, GetPropertyInt(P_MaxBreath) - Breath);
626  Breath += iChange;
627  // call to object
628  Call(PSF_BreathChange,&C4AulParSet(iChange));
629 }
630 
631 void C4Object::DoCon(int32_t iChange, bool grow_from_center)
632 {
633  C4Real strgt_con_b = fix_y + Shape.GetBottom();
634  bool fWasFull = (Con>=FullCon);
635  int32_t old_con = Con;
636 
637  // Change con
638  if (Def->Oversize)
639  Con=std::max<int32_t>(Con+iChange,0);
640  else
641  Con=Clamp<int32_t>(Con+iChange,0,FullCon);
642 
643  // Update OCF
644  SetOCF();
645 
646  // Mass
647  UpdateMass();
648 
649  // shape and position
650  UpdateShape();
651  // make the bottom-most vertex stay in place
652  if (!grow_from_center)
653  {
654  fix_y = strgt_con_b - Shape.GetBottom();
655  }
656  // Face (except for the shape)
657  UpdateFace(false);
658 
659  // Do a callback on completion change.
660  if (iChange != 0)
662 
663  // Unfullcon
664  if (fWasFull && (Con<FullCon))
665  {
666  // Lose contents
667  if (!Def->IncompleteActivity)
668  {
669  C4Object *cobj;
670  while ((cobj=Contents.GetObject()))
671  if (Contained) cobj->Enter(Contained);
672  else cobj->Exit(cobj->GetX(),cobj->GetY());
673  SetAction(nullptr);
674  }
675  }
676 
677  // Completion
678  if (!fWasFull && (Con>=FullCon))
680 
681  // Con Zero Removal
682  if (Con<=0)
683  AssignRemoval();
684  // Mesh Graphics Update
685  else if(pMeshInstance)
686  pMeshInstance->SetCompletion(Def->GrowthType ? 1.0f : static_cast<float>(Con)/static_cast<float>(FullCon));
687 }
688 
689 bool C4Object::ActivateEntrance(int32_t by_plr, C4Object *by_obj)
690 {
691 
692  // Try entrance activation
693  if (OCF & OCF_Entrance)
694  if (!! Call(PSF_ActivateEntrance,&C4AulParSet(by_obj)))
695  return true;
696  // Failure
697  return false;
698 }
699 
700 BYTE C4Object::GetArea(int32_t &aX, int32_t &aY, int32_t &aWdt, int32_t &aHgt) const
701 {
702  if (!Status || !Def) return 0;
703  aX = GetX() + Shape.GetX(); aY = GetY() + Shape.GetY();
704  aWdt=Shape.Wdt; aHgt=Shape.Hgt;
705  return 1;
706 }
707 
708 BYTE C4Object::GetEntranceArea(int32_t &aX, int32_t &aY, int32_t &aWdt, int32_t &aHgt) const
709 {
710  if (!Status || !Def) return 0;
711  // Return actual entrance
712  if (OCF & OCF_Entrance)
713  {
714  aX=GetX() + Def->Entrance.x;
715  aY=GetY() + Def->Entrance.y;
716  aWdt=Def->Entrance.Wdt;
717  aHgt=Def->Entrance.Hgt;
718  }
719  // Return object center
720  else
721  {
722  aX=GetX(); aY=GetY();
723  aWdt=0; aHgt=0;
724  }
725  // Done
726  return 1;
727 }
728 
730 {
731  StdStrBuf Output;
732  // Type
733  Output.AppendFormat(LoadResStr("IDS_CNS_TYPE"),GetName(),Def->id.ToString());
734  // Owner
735  if (ValidPlr(Owner))
736  {
737  Output.Append("\n");
738  Output.AppendFormat(LoadResStr("IDS_CNS_OWNER"),::Players.Get(Owner)->GetName());
739  }
740  // Contents
741  if (Contents.ObjectCount())
742  {
743  Output.Append("\n");
744  Output.Append(LoadResStr("IDS_CNS_CONTENTS"));
746  }
747  // Action
748  if (GetAction())
749  {
750  Output.Append("\n");
751  Output.Append(LoadResStr("IDS_CNS_ACTION"));
752  Output.Append(GetAction()->GetName());
753  }
754  // Properties
755  Output.Append("\n");
756  Output.Append(LoadResStr("IDS_CNS_PROPERTIES"));
757  Output.Append("\n ");
758  AppendDataString(&Output, "\n ");
759  // Effects
760  if (pEffects)
761  {
762  Output.Append("\n");
763  Output.Append(LoadResStr("IDS_CNS_EFFECTS"));
764  Output.Append(": ");
765  }
766  for (C4Effect *pEffect = pEffects; pEffect; pEffect = pEffect->pNext)
767  {
768  Output.Append("\n");
769  // Effect name
770  Output.AppendFormat(" %s: Priority %d, Interval %d", pEffect->GetName(), pEffect->iPriority, pEffect->iInterval);
771  }
772 
773  StdStrBuf Output2;
774  C4ValueNumbers numbers;
775  DecompileToBuf_Log<StdCompilerINIWrite>(mkNamingAdapt(mkInsertAdapt(mkParAdapt(*this, &numbers),
776  mkNamingAdapt(numbers, "Values"), false),
777  "Object"), &Output2, "C4Object::GetDataString");
778  Output.Append("\n");
779  Output.Append(Output2);
780  return Output;
781 }
782 
783 void C4Object::SetName(const char * NewName)
784 {
785  if (!NewName && Info)
787  else
788  C4PropList::SetName(NewName);
789 }
790 
791 int32_t C4Object::GetValue(C4Object *pInBase, int32_t iForPlayer)
792 {
793  C4Value r = Call(PSF_CalcValue, &C4AulParSet(pInBase, iForPlayer));
794  int32_t iValue;
795  if (r != C4VNull)
796  iValue = r.getInt();
797  else
798  {
799  // get value of def
800  // Caution: Do not pass pInBase here, because the def base value is to be queried
801  // - and not the value if you had to buy the object in this particular base
802  iValue = Def->GetValue(nullptr, iForPlayer);
803  }
804  // Con percentage
805  iValue = iValue * Con / FullCon;
806  // do any adjustments based on where the item is bought
807  if (pInBase)
808  {
809  r = pInBase->Call(PSF_CalcSellValue, &C4AulParSet(this, iValue));
810  if (r != C4VNull)
811  iValue = r.getInt();
812  }
813  return iValue;
814 }
815 
817 {
818  // mesh attachments and animation nodes
820  // effects
821  if (pEffects) pEffects->ClearPointers(pObj);
822  // contents/contained: although normally not necessery because it's done in AssignRemoval and StatusDeactivate,
823  // it is also required during game destruction (because ClearPointers might do script callbacks)
824  // Perform silent exit to avoid additional callbacks
825  if (Contained == pObj)
826  {
827  Contained->Contents.Remove(this);
828  Contained = nullptr;
829  }
830  Contents.Remove(pObj);
831  // Action targets
832  if (Action.Target==pObj) Action.Target=nullptr;
833  if (Action.Target2==pObj) Action.Target2=nullptr;
834  // Commands
835  C4Command *cCom;
836  for (cCom=Command; cCom; cCom=cCom->Next)
837  cCom->ClearPointers(pObj);
838  // Menu
839  if (Menu) Menu->ClearPointers(pObj);
840  // Layer
841  if (Layer==pObj) Layer=nullptr;
842  // gfx overlays
843  if (pGfxOverlay)
844  {
845  C4GraphicsOverlay *pNextGfxOvrl = pGfxOverlay, *pGfxOvrl;
846  while ((pGfxOvrl = pNextGfxOvrl))
847  {
848  pNextGfxOvrl = pGfxOvrl->GetNext();
849  if (pGfxOvrl->GetOverlayObject() == pObj)
850  // overlay relying on deleted object: Delete!
851  RemoveGraphicsOverlay(pGfxOvrl->GetID());
852  }
853  }
854 }
855 
857 {
858  bool deserializing = pComp->isDeserializer();
859  if (deserializing)
860  Clear();
861 
862  // Compile ID, search definition
863  pComp->Value(mkNamingAdapt(id, "id", C4ID::None ));
864  if (deserializing)
865  {
866  Def = ::Definitions.ID2Def(id);
867  if (!Def)
868  { pComp->excNotFound(LoadResStr("IDS_PRC_UNDEFINEDOBJECT"),id.ToString()); return; }
869  }
870 
871  pComp->Value(mkNamingAdapt( mkParAdapt(static_cast<C4PropListNumbered&>(*this), numbers), "Properties"));
872  pComp->Value(mkNamingAdapt( Status, "Status", 1 ));
873  if (Info) nInfo = Info->Name; else nInfo.Clear();
874  pComp->Value(mkNamingAdapt( toC4CStrBuf(nInfo), "Info", "" ));
875  pComp->Value(mkNamingAdapt( Owner, "Owner", NO_OWNER ));
876  pComp->Value(mkNamingAdapt( Controller, "Controller", NO_OWNER ));
877  pComp->Value(mkNamingAdapt( LastEnergyLossCausePlayer, "LastEngLossPlr", NO_OWNER ));
878  pComp->Value(mkNamingAdapt( Category, "Category", 0 ));
879  pComp->Value(mkNamingAdapt( Plane, "Plane", 0 ));
880 
881  pComp->Value(mkNamingAdapt( iLastAttachMovementFrame, "LastSolidAtchFrame", -1 ));
882  pComp->Value(mkNamingAdapt( Con, "Size", 0 ));
883  pComp->Value(mkNamingAdapt( OwnMass, "OwnMass", 0 ));
884  pComp->Value(mkNamingAdapt( Mass, "Mass", 0 ));
885  pComp->Value(mkNamingAdapt( Damage, "Damage", 0 ));
886  pComp->Value(mkNamingAdapt( Energy, "Energy", 0 ));
887  pComp->Value(mkNamingAdapt( Alive, "Alive", false ));
888  pComp->Value(mkNamingAdapt( Breath, "Breath", 0 ));
889  pComp->Value(mkNamingAdapt( Color, "Color", 0u ));
890  pComp->Value(mkNamingAdapt( fix_x, "X", Fix0 ));
891  pComp->Value(mkNamingAdapt( fix_y, "Y", Fix0 ));
892  pComp->Value(mkNamingAdapt( fix_r, "R", Fix0 ));
893  pComp->Value(mkNamingAdapt( xdir, "XDir", 0 ));
894  pComp->Value(mkNamingAdapt( ydir, "YDir", 0 ));
895  pComp->Value(mkNamingAdapt( rdir, "RDir", 0 ));
896  pComp->Value(mkParAdapt(Shape, &Def->Shape));
897  pComp->Value(mkNamingAdapt( fOwnVertices, "OwnVertices", false ));
898  pComp->Value(mkNamingAdapt( SolidMask, "SolidMask", Def->SolidMask ));
899  pComp->Value(mkNamingAdapt( HalfVehicleSolidMask, "HalfVehicleSolidMask", false ));
900  pComp->Value(mkNamingAdapt( PictureRect, "Picture" ));
901  pComp->Value(mkNamingAdapt( Mobile, "Mobile", false ));
902  pComp->Value(mkNamingAdapt( OnFire, "OnFire", false ));
903  pComp->Value(mkNamingAdapt( InLiquid, "InLiquid", false ));
904  pComp->Value(mkNamingAdapt( EntranceStatus, "EntranceStatus", false ));
905  pComp->Value(mkNamingAdapt( OCF, "OCF", 0u ));
906  pComp->Value(Action);
907  pComp->Value(mkNamingAdapt( Contained, "Contained", C4ObjectPtr::Null ));
908  pComp->Value(mkNamingAdapt( Action.Target, "ActionTarget1", C4ObjectPtr::Null ));
909  pComp->Value(mkNamingAdapt( Action.Target2, "ActionTarget2", C4ObjectPtr::Null ));
910  pComp->Value(mkNamingAdapt( mkParAdapt(Contents, numbers), "Contents" ));
911  pComp->Value(mkNamingAdapt( lightRange, "LightRange", 0 ));
912  pComp->Value(mkNamingAdapt( lightFadeoutRange, "LightFadeoutRange", 0 ));
913  pComp->Value(mkNamingAdapt( lightColor, "lightColor", 0xffffffffu ));
914  pComp->Value(mkNamingAdapt( ColorMod, "ColorMod", 0xffffffffu ));
915  pComp->Value(mkNamingAdapt( BlitMode, "BlitMode", 0u ));
916  pComp->Value(mkNamingAdapt( CrewDisabled, "CrewDisabled", false ));
917  pComp->Value(mkNamingAdapt( Layer, "Layer", C4ObjectPtr::Null ));
918  pComp->Value(mkNamingAdapt( C4DefGraphicsAdapt(pGraphics), "Graphics", &Def->Graphics ));
919  pComp->Value(mkNamingPtrAdapt( pDrawTransform, "DrawTransform" ));
920  pComp->Value(mkParAdapt(mkNamingPtrAdapt( pEffects, "Effects" ), this, numbers));
921  pComp->Value(mkNamingAdapt( C4GraphicsOverlayListAdapt(pGfxOverlay),"GfxOverlay", (C4GraphicsOverlay *)nullptr));
922 
923  // Serialize mesh instance if we have a mesh graphics
925  {
926  if(pComp->isDeserializer())
927  {
928  assert(!pMeshInstance);
929  pMeshInstance = new StdMeshInstance(*pGraphics->Mesh, Def->GrowthType ? 1.0f : static_cast<float>(Con)/static_cast<float>(FullCon));
930  }
931 
933 
934  // Does not work because unanimated meshes without attached meshes
935  // do not even write a [Mesh] header so this does not create a mesh instance in that case
936 /* pComp->Value(mkNamingContextPtrAdapt( pMeshInstance, *pGraphics->Mesh, "Mesh"));
937  if(!pMeshInstance)
938  pComp->excCorrupt("Mesh graphics without mesh instance");*/
939  }
940 
941  // TODO: Animations / attached meshes
942 
943  // Commands
944  if (pComp->FollowName("Commands"))
945  {
946  if (deserializing)
947  {
948  C4Command *pCmd = nullptr;
949  for (int i = 1; ; i++)
950  {
951  // Every command has its own naming environment
952  StdStrBuf Naming = FormatString("Command%d", i);
953  pComp->Value(mkParAdapt(mkNamingPtrAdapt(pCmd ? pCmd->Next : Command, Naming.getData()), numbers));
954  // Last command?
955  pCmd = (pCmd ? pCmd->Next : Command);
956  if (!pCmd)
957  break;
958  pCmd->cObj = this;
959  }
960  }
961  else
962  {
963  C4Command *pCmd = Command;
964  for (int i = 1; pCmd; i++, pCmd = pCmd->Next)
965  {
966  StdStrBuf Naming = FormatString("Command%d", i);
967  pComp->Value(mkNamingAdapt(mkParAdapt(*pCmd, numbers), Naming.getData()));
968  }
969  }
970  }
971 
972  // Compiling? Do initialization.
973  if (deserializing)
974  {
975  // add to def count
976  Def->Count++;
977 
978 
979  // Set action (override running data)
980  /* FIXME
981  int32_t iTime=Action.Time;
982  int32_t iPhase=Action.Phase;
983  int32_t iPhaseDelay=Action.PhaseDelay;
984  if (SetActionByName(Action.pActionDef->GetName(),0,0,false))
985  {
986  Action.Time=iTime;
987  Action.Phase=iPhase; // No checking for valid phase
988  Action.PhaseDelay=iPhaseDelay;
989  }*/
990 
991  if (pMeshInstance)
992  {
993  // Set Action animation by slot 0
996  }
997 
998  // blit mode not assigned? use definition default then
999  if (!BlitMode) BlitMode = Def->BlitMode;
1000 
1001  // object needs to be resorted? May happen if there's unsorted objects in savegame
1002  if (Unsorted) Game.fResortAnyObject = true;
1003  }
1004 
1005 }
1006 
1008 {
1009  C4PropList::Denumerate(numbers);
1010  // Standard enumerated pointers
1015 
1016  // Post-compile object list
1018 
1019  // Commands
1020  for (C4Command *pCom=Command; pCom; pCom=pCom->Next)
1021  pCom->Denumerate(numbers);
1022 
1023  // effects
1024  if (pEffects) pEffects->Denumerate(numbers);
1025 
1026  // gfx overlays
1027  if (pGfxOverlay)
1028  for (C4GraphicsOverlay *pGfxOvrl = pGfxOverlay; pGfxOvrl; pGfxOvrl = pGfxOvrl->GetNext())
1029  pGfxOvrl->DenumeratePointers();
1030 
1031  // mesh instance
1033 }
1034 
1036 {
1037  // Check owner and controller
1038  if (!ValidPlr(Owner)) Owner=NO_OWNER;
1040  // Color is not reset any more, because many scripts change colors to non-owner-colors these days
1041  // Additionally, player colors are now guarantueed to remain the same in savegame resumes
1042  return true;
1043 }
1044 
1046 {
1047  if (Info || !ValidPlr(Owner)) return false;
1048  // In crew list?
1049  C4Player *pPlr = ::Players.Get(Owner);
1050  if (pPlr->Crew.GetLink(this))
1051  {
1052  // Register with player
1053  if (!::Players.Get(Owner)->MakeCrewMember(this, true, false))
1054  pPlr->Crew.Remove(this);
1055  return true;
1056  }
1057  // Info set, but not in crew list, so
1058  // a) The savegame is old-style (without crew list)
1059  // or b) The clonk is dead
1060  // or c) The clonk belongs to a script player that's restored without Game.txt
1061  else if (nInfo.getLength())
1062  {
1063  if (!::Players.Get(Owner)->MakeCrewMember(this, true, false))
1064  return false;
1065  // Dead and gone (info flags, remove from crew/cursor)
1066  if (!Alive)
1067  {
1068  if (ValidPlr(Owner)) ::Players.Get(Owner)->ClearPointers(this, true);
1069  }
1070  return true;
1071  }
1072  return false;
1073 }
1074 
1076 {
1077  if (Info==pInfo)
1078  {
1079  Info=nullptr;
1080  }
1081 }
1082 
1084 {
1086 
1087  delete pEffects; pEffects = nullptr;
1088  delete pSolidMaskData; pSolidMaskData = nullptr;
1089  delete Menu; Menu = nullptr;
1090  delete MaterialContents; MaterialContents = nullptr;
1091  // clear commands!
1092  C4Command *pCom, *pNext;
1093  for (pCom=Command; pCom; pCom=pNext)
1094  {
1095  pNext=pCom->Next; delete pCom; pCom=pNext;
1096  }
1097  delete pDrawTransform; pDrawTransform = nullptr;
1098  delete pGfxOverlay; pGfxOverlay = nullptr;
1099  delete pMeshInstance; pMeshInstance = nullptr;
1100 }
1101 
1103 {
1104  // Misc. no-save safeties
1106  InMat = MNone;
1107  t_contact = 0;
1108  // Update OCF
1109  SetOCF();
1110  // Menu
1111  CloseMenu(true);
1112  // Material contents
1113  delete MaterialContents; MaterialContents=nullptr;
1114  // reset speed of staticback-objects
1115  if (Category & C4D_StaticBack)
1116  {
1117  xdir = ydir = 0;
1118  }
1119 }
1120 
1122 {
1123  // Flag resort
1124  Unsorted=true;
1125  Game.fResortAnyObject = true;
1126  // Must not immediately resort - link change/removal would crash Game::ExecObjects
1127 }
1128 
1129 bool C4Object::SetOwner(int32_t iOwner)
1130 {
1131  // Check valid owner
1132  if (!(ValidPlr(iOwner) || iOwner == NO_OWNER)) return false;
1133  // always set color, even if no owner-change is done
1134  if (iOwner != NO_OWNER)
1135  if (GetGraphics()->IsColorByOwner())
1136  {
1137  Color=::Players.Get(iOwner)->ColorDw;
1138  UpdateFace(false);
1139  }
1140  // no change?
1141  if (Owner == iOwner) return true;
1142  // set new owner
1143  int32_t iOldOwner=Owner;
1144  Owner=iOwner;
1145  // this automatically updates controller
1146  Controller = Owner;
1147  // script callback
1148  Call(PSF_OnOwnerChanged, &C4AulParSet(Owner, iOldOwner));
1149  // done
1150  return true;
1151 }
1152 
1154 {
1155  // safety
1156  if (!pFrom) return false;
1157  if (!Status || !pFrom->Status) return false;
1158  // even more safety (own info: success)
1159  if (pFrom == this) return true;
1160  // only if other object has info
1161  if (!pFrom->Info) return false;
1162  // clear own info object
1163  if (Info)
1164  {
1165  Info->Retire();
1166  ClearInfo (Info);
1167  }
1168  // remove objects from any owning crews
1169  ::Players.ClearPointers(pFrom);
1170  ::Players.ClearPointers(this);
1171  // set info
1172  Info = pFrom->Info; pFrom->ClearInfo (pFrom->Info);
1173  // set name
1174  SetName(Info->Name);
1175  // retire from old crew
1176  Info->Retire();
1177  // if alive, recruit to new crew
1178  if (Alive) Info->Recruit();
1179  // make new crew member
1180  C4Player *pPlr = ::Players.Get(Owner);
1181  if (pPlr) pPlr->MakeCrewMember(this);
1182  // done, success
1183  return true;
1184 }
1185 
1187 {
1188  // selection allowed?
1189  if (CrewDisabled) return false;
1190  // do callback
1192  // done
1193  return true;
1194 }
1195 
1197 {
1198  // do callback
1200 }
1201 
1203 {
1204  // readd to main list
1206  Status = C4OS_NORMAL;
1207  ::Objects.Add(this);
1208  // update some values
1209  UpdateGraphics(false);
1210  UpdateFace(true);
1211  UpdatePos();
1212  UpdateLight();
1214  // done, success
1215  return true;
1216 }
1217 
1218 bool C4Object::StatusDeactivate(bool fClearPointers)
1219 {
1220  // clear particles
1222 
1223  // put into inactive list
1224  ::Objects.Remove(this);
1226  if (Landscape.HasFoW()) Landscape.GetFoW()->Remove(this);
1228  // if desired, clear game pointers
1229  if (fClearPointers)
1230  {
1231  // in this case, the object must also exit any container, and any contained objects must be exited
1233  Game.ClearPointers(this);
1234  }
1235  else
1236  {
1237  // always clear transfer
1239  }
1240  // done, success
1241  return true;
1242 }
1243 
1245 {
1246  StdStrBuf sResult;
1247  // no info for invalid objects
1248  if (!Status) return sResult;
1249  // go through all effects and add their desc
1250  for (C4Effect *pEff = pEffects; pEff; pEff = pEff->pNext)
1251  {
1252  C4Value par[7];
1253  C4Value vInfo = pEff->DoCall(this, PSFS_FxInfo, par[0], par[1], par[2], par[3], par[4], par[5], par[6]);
1254  if (!vInfo) continue;
1255  // debug: warn for wrong return types
1256  if (vInfo.GetType() != C4V_String)
1257  DebugLogF("Effect %s(#%d) on object %s (#%d) returned wrong info type %d.", pEff->GetName(), pEff->Number, GetName(), Number, vInfo.GetType());
1258  // get string val
1259  C4String *psInfo = vInfo.getStr(); const char *szEffInfo;
1260  if (psInfo && (szEffInfo = psInfo->GetCStr()))
1261  if (*szEffInfo)
1262  {
1263  // OK; this effect has a desc. Add it!
1264  if (sResult.getLength()) sResult.AppendChar('|');
1265  sResult.Append(szEffInfo);
1266  }
1267  }
1268  // done
1269  return sResult;
1270 }
1271 
1273 {
1274  if (pEffects)
1276 }
1277 
1278 bool C4Object::IsPlayerObject(int32_t iPlayerNumber) const
1279 {
1280  bool fAnyPlr = (iPlayerNumber == NO_OWNER);
1281  // if an owner is specified: only owned objects
1282  if (fAnyPlr && !ValidPlr(Owner)) return false;
1283  // and crew objects
1284  if (fAnyPlr || Owner == iPlayerNumber)
1285  {
1286  C4Player *pOwner = ::Players.Get(Owner);
1287  if (pOwner)
1288  {
1289  if (pOwner && pOwner->Crew.IsContained(this)) return true;
1290  }
1291  else
1292  {
1293  // Do not force that the owner exists because the function must work for unjoined players (savegame resume)
1294  if (Def->CrewMember)
1295  return true;
1296  }
1297  }
1298  // otherwise, not a player object
1299  return false;
1300 }
1301 
1303 {
1304  // must be a player object at all
1305  if (!IsPlayerObject()) return false;
1306  // and the owner must not be a script player
1307  C4Player *pOwner = ::Players.Get(Owner);
1308  if (!pOwner || pOwner->GetType() != C4PT_User) return false;
1309  // otherwise, it's a user playeer object
1310  return true;
1311 }
1312 
1314 {
1315  if (k >= &Strings.P[0] && k < &Strings.P[P_LAST])
1316  {
1317  switch(k - &Strings.P[0])
1318  {
1319  case P_Plane:
1320  if (!to.getInt()) throw C4AulExecError("invalid Plane 0");
1321  SetPlane(to.getInt());
1322  return;
1323  }
1324  }
1326 }
1327 
1329 {
1330  if (k >= &Strings.P[0] && k < &Strings.P[P_LAST])
1331  {
1332  switch(k - &Strings.P[0])
1333  {
1334  case P_Plane:
1336  return;
1337  }
1338  }
1340 }
1341 
1342 bool C4Object::GetPropertyByS(const C4String *k, C4Value *pResult) const
1343 {
1344  if (k >= &Strings.P[0] && k < &Strings.P[P_LAST])
1345  {
1346  switch(k - &Strings.P[0])
1347  {
1348  case P_Plane: *pResult = C4VInt(Plane); return true;
1349  }
1350  }
1351  return C4PropListNumbered::GetPropertyByS(k, pResult);
1352 }
1353 
1355 {
1357  int i;
1358  i = a->GetSize();
1359  a->SetSize(i + 1);
1360  (*a)[i++] = C4VString(&::Strings.P[P_Plane]);
1361  return a;
1362 }
C4Config Config
Definition: C4Config.cpp:930
const int32_t FullCon
Definition: C4Constants.h:181
const int32_t MNone
Definition: C4Constants.h:177
const uint32_t OCF_Entrance
Definition: C4Constants.h:90
@ C4PT_User
Definition: C4Constants.h:154
const BYTE CNAT_None
Definition: C4Constants.h:108
const int NO_OWNER
Definition: C4Constants.h:137
const int32_t C4D_Living
Definition: C4Def.h:43
const int32_t C4D_StaticBack
Definition: C4Def.h:40
C4Def * C4Id2Def(C4ID id)
Definition: C4DefList.h:84
#define C4FxCall_EngAsphyxiation
Definition: C4Effect.h:60
#define C4FxCall_RemoveDeath
Definition: C4Effect.h:46
#define C4FxCall_EngCorrosion
Definition: C4Effect.h:61
#define C4FxCall_RemoveClear
Definition: C4Effect.h:45
void GameMsgObject(const char *szText, C4Object *pTarget)
#define PSF_EnergyChange
Definition: C4GameScript.h:142
#define PSF_CrewSelection
Definition: C4GameScript.h:86
#define PSF_Initialize
Definition: C4GameScript.h:34
#define PSF_Death
Definition: C4GameScript.h:66
#define PSF_RelaunchPlayer
Definition: C4GameScript.h:47
#define PSFS_FxInfo
Definition: C4GameScript.h:157
#define PSF_OnCompletionChange
Definition: C4GameScript.h:103
#define PSF_Destruction
Definition: C4GameScript.h:38
#define PSF_OnSynchronized
Definition: C4GameScript.h:79
#define PSF_OnInIncendiaryMaterial
Definition: C4GameScript.h:95
#define PSF_OnOwnerChanged
Definition: C4GameScript.h:141
#define PSF_Damage
Definition: C4GameScript.h:63
#define PSF_CalcValue
Definition: C4GameScript.h:80
#define PSF_CalcSellValue
Definition: C4GameScript.h:92
#define PSF_ContentsDestruction
Definition: C4GameScript.h:39
#define PSF_BreathChange
Definition: C4GameScript.h:143
#define PSF_ActivateEntrance
Definition: C4GameScript.h:67
C4Game Game
Definition: C4Globals.cpp:52
C4AulScriptEngine ScriptEngine
Definition: C4Globals.cpp:43
C4GameObjects Objects
Definition: C4Globals.cpp:48
C4DefList Definitions
Definition: C4Globals.cpp:49
C4StringTable Strings
Definition: C4Globals.cpp:42
const int32_t C4MaxPhysical
Definition: C4InfoCore.h:28
C4Landscape Landscape
bool GBackSemiSolid(int32_t x, int32_t y)
Definition: C4Landscape.h:234
int32_t GBackMat(int32_t x, int32_t y)
Definition: C4Landscape.h:219
const char * LoadResStr(const char *id)
Definition: C4Language.h:83
bool DebugLogF(const char *strMessage ...)
Definition: C4Log.cpp:290
#define a
int32_t MWater
Definition: C4Material.cpp:36
int32_t MVehic
Definition: C4Material.cpp:36
C4MaterialMap MaterialMap
Definition: C4Material.cpp:974
const StdMeshInstance::AttachedMesh::DenumeratorFactoryFunc C4MeshDenumeratorFactory
#define C4OS_INACTIVE
Definition: C4Object.h:36
#define C4OS_NORMAL
Definition: C4Object.h:35
#define C4OS_DELETED
Definition: C4Object.h:34
C4ParticleSystem Particles
C4PlayerList Players
int32_t ValidPlr(int32_t plr)
C4Fixed itofix(int32_t x)
Definition: C4Real.h:261
const C4Real Fix0
Definition: C4Real.h:312
void AddDbgRec(C4RecordChunkType eType, const void *pData, int iSize)
Definition: C4Record.cpp:32
@ RCT_DsObj
Definition: C4Record.h:63
@ RCT_ExecObj
Definition: C4Record.h:57
char id[32+1]
Definition: C4Record.h:150
C4Real fy
Definition: C4Record.h:132
C4Real fx
Definition: C4Record.h:132
C4Real fr
Definition: C4Record.h:132
int Number
Definition: C4Record.h:131
C4GameScriptHost GameScript
C4SoundInstance * StartSoundEffect(const char *szSndName, bool fLoop, int32_t iVolume, C4Object *pObj, int32_t iCustomFalloffDistance, int32_t iPitch, C4SoundModifier *modifier)
@ P_MaxEnergy
@ P_ContactIncinerate
@ P_MaxBreath
@ P_Plane
@ P_Action
@ P_Prototype
@ P_BreatheWater
@ P_CorrosionResist
@ P_MaterialIncinerate
@ P_LAST
#define C4GFXBLIT_CUSTOM
Definition: C4Surface.h:35
const C4Value C4VNull
Definition: C4Value.cpp:30
@ C4V_String
Definition: C4Value.h:29
C4Value C4VInt(int32_t i)
Definition: C4Value.h:239
C4Value C4VPropList(C4PropList *p)
Definition: C4Value.h:242
C4Value C4VString(C4String *pStr)
Definition: C4Value.h:243
C4ViewportList Viewports
uint8_t BYTE
StdInsertAdapt< T, I > mkInsertAdapt(T &&rObj, I &&rIns, bool fBefore=true)
Definition: StdAdaptors.h:469
StdPtrAdapt< T > mkNamingPtrAdapt(T *&rpObj, const char *szNaming)
Definition: StdAdaptors.h:636
StdParameterAdapt< T, P > mkParAdapt(T &&rObj, P &&rPar)
Definition: StdAdaptors.h:490
#define toC4CStrBuf(rBuf)
Definition: StdAdaptors.h:25
StdNamingAdapt< T > mkNamingAdapt(T &&rValue, const char *szName)
Definition: StdAdaptors.h:92
StdStrBuf FormatString(const char *szFmt,...)
Definition: StdBuf.cpp:270
int32_t t_attach
Definition: C4Object.h:86
void Default()
Definition: C4Action.cpp:30
C4ObjectPtr Target2
Definition: C4Object.h:87
StdMeshInstanceAnimationNode * Animation
Definition: C4Object.h:90
C4ObjectPtr Target
Definition: C4Object.h:87
C4Effect * pGlobalEffects
Definition: C4Aul.h:144
void ClearPointers(C4Object *pObj)
Definition: C4Command.cpp:1288
C4Object * cObj
Definition: C4Command.h:80
C4Command * Next
Definition: C4Command.h:90
int32_t DebugRec
Definition: C4Config.h:63
C4ConfigGeneral General
Definition: C4Config.h:255
GraphicsType Type
Definition: C4DefGraphics.h:48
Definition: C4Def.h:99
int32_t CrewMember
Definition: C4Def.h:112
int32_t Mass
Definition: C4Def.h:114
C4DefGraphics Graphics
Definition: C4Def.h:191
int32_t IncompleteActivity
Definition: C4Def.h:128
int32_t Line
Definition: C4Def.h:126
int32_t ColorByOwner
Definition: C4Def.h:121
C4ID id
Definition: C4Def.h:101
C4TargetRect SolidMask
Definition: C4Def.h:108
int32_t Rotateable
Definition: C4Def.h:119
int32_t Category
Definition: C4Def.h:117
int32_t Oversize
Definition: C4Def.h:129
int32_t GetPlane()
Definition: C4Def.h:211
int32_t GrowthType
Definition: C4Def.h:111
C4Shape Shape
Definition: C4Def.h:104
int32_t NoBreath
Definition: C4Def.h:142
int32_t Count
Definition: C4Def.h:179
int32_t BlitMode
Definition: C4Def.h:141
C4Rect Entrance
Definition: C4Def.h:105
int32_t GetValue(C4Object *pInBase, int32_t iBuyPlayer)
Definition: C4Def.cpp:621
C4Def * ID2Def(C4ID id)
void DoDamage(int32_t &riDamage, int32_t iDamageType, int32_t iCausePlr)
Definition: C4Effect.cpp:394
void ReAssignAllCallbackFunctions()
Definition: C4Effect.h:129
C4Effect * pNext
Definition: C4Effect.h:75
void Denumerate(C4ValueNumbers *) override
Definition: C4Effect.cpp:176
void ClearPointers(C4PropList *pObj)
Definition: C4Effect.cpp:191
void OnObjectChangedDef(C4PropList *pObj)
Definition: C4Effect.cpp:482
static void Execute(C4Effect **ppEffectList)
Definition: C4Effect.cpp:297
void ClearAll(int32_t iClearFlag)
Definition: C4Effect.cpp:369
void Default()
Definition: C4Facet.cpp:31
Definition: C4Real.h:59
void Remove(C4Object *pObj)
Definition: C4FoW.cpp:201
C4TransferZones TransferZones
Definition: C4Game.h:85
int32_t iTick255
Definition: C4Game.h:130
void ClearPointers(C4Object *obj)
Definition: C4Game.cpp:1125
bool fResortAnyObject
Definition: C4Game.h:139
int32_t iTick10
Definition: C4Game.h:130
int32_t Time
Definition: C4Game.h:132
C4Value GRBroadcast(const char *function, C4AulParSet *pars=nullptr, bool pass_error=false, bool reject_test=false)
Definition: C4Game.cpp:4761
int32_t iTick5
Definition: C4Game.h:130
bool Remove(C4Object *game_object) override
bool Add(C4Object *game_object)
C4LSectors Sectors
Definition: C4GameObjects.h:42
C4ObjectList InactiveObjects
Definition: C4GameObjects.h:43
C4Effect * pScenarioEffects
Definition: C4ScriptHost.h:166
C4GraphicsOverlay * GetNext() const
Definition: C4Id.h:26
const char * ToString() const
Definition: C4Id.h:56
static const C4ID None
Definition: C4Id.h:39
void AssertObjectNotInList(C4Object *pObj)
Definition: C4Sector.cpp:185
bool HasFoW() const
class C4FoW * GetFoW()
int32_t Incendiary
Definition: C4Material.h:107
int32_t Corrosive
Definition: C4Material.h:109
C4Material * Map
Definition: C4Material.h:169
int32_t OwnMass
Definition: C4Object.h:113
bool Enter(C4Object *pTarget, bool fCalls=true, bool fCopyMotion=true, bool *pfRejectCollect=nullptr)
bool OnFire
Definition: C4Object.h:171
bool EntranceStatus
Definition: C4Object.h:130
C4ValueArray * GetProperties() const override
Definition: C4Object.cpp:1354
C4ObjectInfo * Info
Definition: C4Object.h:143
BYTE GetArea(int32_t &aX, int32_t &aY, int32_t &aWdt, int32_t &aHgt) const
Definition: C4Object.cpp:700
void Resort()
Definition: C4Object.cpp:1121
C4Real ydir
Definition: C4Object.h:124
int32_t lightRange
Definition: C4Object.h:120
C4Real fix_y
Definition: C4Object.h:123
uint32_t Marker
Definition: C4Object.h:133
C4PropList * GetAction() const
void UpdatLastEnergyLossCause(int32_t iNewCausePlr)
Definition: C4Object.cpp:611
bool HalfVehicleSolidMask
Definition: C4Object.h:149
void UpdateMass()
C4Real xdir
Definition: C4Object.h:124
void UpdateScriptPointers()
Definition: C4Object.cpp:1272
void UpdateFace(bool bUpdateShape, bool fTemp=false)
class C4GraphicsOverlay * pGfxOverlay
Definition: C4Object.h:169
C4Rect PictureRect
Definition: C4Object.h:150
bool GrabInfo(C4Object *pFrom)
Definition: C4Object.cpp:1153
bool ActivateEntrance(int32_t by_plr, C4Object *by_obj)
Definition: C4Object.cpp:689
int32_t GetValue(C4Object *pInBase, int32_t iForPlayer)
Definition: C4Object.cpp:791
bool ExecLife()
Definition: C4Object.cpp:354
void ClearCommands()
C4TargetRect SolidMask
Definition: C4Object.h:148
bool ExecMovement()
Definition: C4Movement.cpp:691
C4Real fix_x
Definition: C4Object.h:123
uint32_t t_contact
Definition: C4Object.h:131
bool GetPropertyByS(const C4String *k, C4Value *pResult) const override
Definition: C4Object.cpp:1342
bool DoSelect()
Definition: C4Object.cpp:1186
bool SetActionByName(C4String *ActName, C4Object *pTarget=nullptr, C4Object *pTarget2=nullptr, int32_t iCalls=SAC_StartCall|SAC_AbortCall, bool fForce=false)
int32_t Audible
Definition: C4Object.h:119
C4Effect * pEffects
Definition: C4Object.h:155
int32_t lightFadeoutRange
Definition: C4Object.h:121
void SetPlane(int32_t z)
Definition: C4Object.h:178
C4DrawTransform * pDrawTransform
Definition: C4Object.h:135
bool Initializing
Definition: C4Object.h:128
C4Command * Command
Definition: C4Object.h:165
bool StatusActivate()
Definition: C4Object.cpp:1202
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)
Definition: C4Object.cpp:112
int32_t Owner
Definition: C4Object.h:108
bool CrewDisabled
Definition: C4Object.h:162
void SetName(const char *NewName=nullptr) override
Definition: C4Object.cpp:783
bool IsPlayerObject(int32_t iPlayerNumber=NO_OWNER) const
Definition: C4Object.cpp:1278
StdStrBuf GetDataString()
Definition: C4Object.cpp:729
int32_t GetX() const
Definition: C4Object.h:285
int32_t Category
Definition: C4Object.h:111
void ClearPointers(C4Object *ptr)
Definition: C4Object.cpp:816
class C4ObjectMenu * Menu
Definition: C4Object.h:138
int32_t Controller
Definition: C4Object.h:109
void SetDir(int32_t tdir)
int32_t AudiblePan
Definition: C4Object.h:119
uint32_t OCF
Definition: C4Object.h:132
uint32_t lightColor
Definition: C4Object.h:122
bool ValidateOwner()
Definition: C4Object.cpp:1035
C4Real fix_r
Definition: C4Object.h:123
void SyncClearance()
Definition: C4Object.cpp:1102
bool Mobile
Definition: C4Object.h:126
int32_t Con
Definition: C4Object.h:172
bool SetLightRange(int32_t iToRange, int32_t iToFadeoutRange)
bool ExecuteCommand()
int32_t Damage
Definition: C4Object.h:114
void UpdateOCF()
C4MaterialList * MaterialContents
Definition: C4Object.h:152
void Clear()
Definition: C4Object.cpp:1083
bool CloseMenu(bool fForce)
int32_t InMat
Definition: C4Object.h:117
void ClearParticleLists()
Definition: C4Object.cpp:205
int32_t Breath
Definition: C4Object.h:116
bool RemoveGraphicsOverlay(int32_t iOverlayID)
C4SolidMask * pSolidMaskData
Definition: C4Object.h:175
C4ObjectPtr Layer
Definition: C4Object.h:134
void ExecAction()
bool fOwnVertices
Definition: C4Object.h:147
void Execute()
Definition: C4Object.cpp:427
int32_t GetY() const
Definition: C4Object.h:286
int32_t iLastAttachMovementFrame
Definition: C4Object.h:125
StdMeshInstance * pMeshInstance
Definition: C4Object.h:154
void AssignDeath(bool fForced)
Definition: C4Object.cpp:467
void DoCon(int32_t iChange, bool grow_from_center)
Definition: C4Object.cpp:631
bool Alive
Definition: C4Object.h:174
int32_t LastEnergyLossCausePlayer
Definition: C4Object.h:110
bool Unsorted
Definition: C4Object.h:127
void AssignRemoval(bool exit_contents=false)
Definition: C4Object.cpp:215
C4Object()
Definition: C4Object.cpp:44
void ClearInfo(C4ObjectInfo *pInfo)
Definition: C4Object.cpp:1075
void ClearContentsAndContained(bool fDoCalls=true)
C4NotifyingObjectList Contents
Definition: C4Object.h:151
class C4ParticleList * BackParticles
Definition: C4Object.h:157
int32_t AudiblePlayer
Definition: C4Object.h:119
void Denumerate(C4ValueNumbers *) override
Definition: C4Object.cpp:1007
C4ObjectPtr Contained
Definition: C4Object.h:142
StdCopyStrBuf nInfo
Definition: C4Object.h:167
~C4Object() override
Definition: C4Object.cpp:195
bool CheckSolidMaskRect()
C4Real rdir
Definition: C4Object.h:124
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)
bool StatusDeactivate(bool fClearPointers)
Definition: C4Object.cpp:1218
C4Action Action
Definition: C4Object.h:145
int32_t Energy
Definition: C4Object.h:115
void SetOCF()
Definition: C4ObjectOCF.cpp:30
int32_t Mass
Definition: C4Object.h:113
int32_t Plane
Definition: C4Object.h:173
bool IsUserPlayerObject()
Definition: C4Object.cpp:1302
BYTE GetEntranceArea(int32_t &aX, int32_t &aY, int32_t &aWdt, int32_t &aHgt) const
Definition: C4Object.cpp:708
bool InLiquid
Definition: C4Object.h:129
void CompileFunc(StdCompiler *pComp, C4ValueNumbers *)
Definition: C4Object.cpp:856
bool ChangeDef(C4ID idNew)
Definition: C4Object.cpp:518
uint32_t BlitMode
Definition: C4Object.h:161
void Default()
Definition: C4Object.cpp:50
void UnSelect()
Definition: C4Object.cpp:1196
uint32_t ColorMod
Definition: C4Object.h:160
int32_t RemovalDelay
Definition: C4Object.h:107
void DoDamage(int32_t iLevel, int32_t iCausedByPlr, int32_t iCause)
Definition: C4Object.cpp:571
C4Def * Def
Definition: C4Object.h:141
void UpdatePos()
uint32_t Color
Definition: C4Object.h:118
StdStrBuf GetInfoString()
Definition: C4Object.cpp:1244
void UpdateShape(bool bUpdateVertices=true)
Definition: C4Object.cpp:327
C4Facet TopFace
Definition: C4Object.h:140
bool SetAction(C4PropList *Act, C4Object *pTarget=nullptr, C4Object *pTarget2=nullptr, int32_t iCalls=SAC_StartCall|SAC_AbortCall, bool fForce=false)
void SetPropertyByS(C4String *k, const C4Value &to) override
Definition: C4Object.cpp:1313
bool SetOwner(int32_t iOwner)
Definition: C4Object.cpp:1129
C4Shape Shape
Definition: C4Object.h:146
C4DefGraphics * pGraphics
Definition: C4Object.h:153
C4DefGraphics * GetGraphics() const
Definition: C4Object.h:339
bool AssignInfo()
Definition: C4Object.cpp:1045
void UpdateGraphics(bool fGraphicsChanged, bool fTemp=false)
void ResetProperty(C4String *k) override
Definition: C4Object.cpp:1328
void DoBreath(int32_t iChange)
Definition: C4Object.cpp:622
class C4ParticleList * FrontParticles
Definition: C4Object.h:157
void DoEnergy(int32_t iChange, bool fExact, int32_t iCause, int32_t iCausedByPlr)
Definition: C4Object.cpp:585
int32_t DeathCount
Definition: C4InfoCore.h:44
int32_t TotalPlayingTime
Definition: C4InfoCore.h:46
char Name[C4MaxName+1]
Definition: C4InfoCore.h:37
int32_t InActionTime
Definition: C4ObjectInfo.h:36
bool DenumeratePointers()
virtual void Default()
const C4ObjectLink * GetLink(const C4Object *obj) const
virtual bool Add(C4Object *new_obj, SortType sort_type, C4ObjectList *sorted_list=nullptr)
virtual bool Remove(C4Object *obj)
int ObjectCount(C4ID id=C4ID::None) const
StdStrBuf GetNameList(C4DefList &defs) const
bool IsContained(const C4Object *obj) const
C4Object * GetObject(int index=0) const
void ClearPointers(C4Object *pObj)
void DenumeratePointers()
Definition: C4ObjectPtr.cpp:49
static const C4ObjectPtr Null
Definition: C4ObjectPtr.h:28
void ReleaseParticleList(C4ParticleList *first, C4ParticleList *second=nullptr)
uint32_t ColorDw
Definition: C4Player.h:89
const char * GetName() const
Definition: C4Player.h:151
C4PlayerType GetType() const
Definition: C4Player.cpp:1727
C4ObjectList Crew
Definition: C4Player.h:125
bool MakeCrewMember(C4Object *pObj, bool fForceInfo=true, bool fDoCalls=true)
Definition: C4Player.cpp:1008
void ClearPointers(C4Object *tptr, bool fDeath)
Definition: C4Player.cpp:98
void ClearPointers(C4Object *pObj)
C4Player * Get(int iPlayer) const
virtual void SetName(const char *NewName=nullptr)
Definition: C4PropList.cpp:625
int32_t GetPropertyInt(C4PropertyName k, int32_t default_val=0) const
Definition: C4PropList.cpp:855
int32_t GetPropertyBool(C4PropertyName n, bool default_val=false) const
Definition: C4PropList.cpp:841
virtual const char * GetName() const
Definition: C4PropList.cpp:618
virtual C4ValueArray * GetProperties() const
Definition: C4PropList.cpp:883
int32_t Status
Definition: C4PropList.h:173
virtual bool GetPropertyByS(const C4String *k, C4Value *pResult) const
Definition: C4PropList.cpp:726
virtual void ResetProperty(C4String *k)
Definition: C4PropList.cpp:961
void AppendDataString(StdStrBuf *out, const char *delim, int depth=3, bool ignore_reference_parent=false) const
Definition: C4PropList.cpp:487
void ClearRefs()
Definition: C4PropList.h:160
virtual void Denumerate(C4ValueNumbers *)
Definition: C4PropList.cpp:321
virtual C4Def const * GetDef() const
Definition: C4PropList.cpp:654
C4Value Call(C4PropertyName k, C4AulParSet *pPars=nullptr, bool fPassErrors=false)
Definition: C4PropList.h:114
virtual void SetPropertyByS(C4String *k, const C4Value &to)
Definition: C4PropList.cpp:940
void SetProperty(C4PropertyName k, const C4Value &to)
Definition: C4PropList.h:124
const char * GetName() const override
Definition: C4PropList.cpp:243
int32_t y
Definition: C4Rect.h:30
int32_t Hgt
Definition: C4Rect.h:30
int32_t Wdt
Definition: C4Rect.h:30
void Default()
Definition: C4Rect.cpp:26
int32_t x
Definition: C4Rect.h:30
int GetBottom()
Definition: C4Shape.cpp:575
int32_t GetX() const
Definition: C4Shape.h:62
void Stretch(int32_t iCon, bool bUpdateVertices)
Definition: C4Shape.cpp:142
void Jolt(int32_t iCon, bool bUpdateVertices)
Definition: C4Shape.cpp:158
void CopyFrom(C4Shape rFrom, bool bCpyVertices, bool fCopyVerticesFromSelf)
Definition: C4Shape.cpp:532
int32_t GetY() const
Definition: C4Shape.h:63
void Rotate(C4Real Angle, bool bUpdateVertices)
Definition: C4Shape.cpp:45
void Default()
Definition: C4Shape.cpp:40
const char * GetCStr() const
Definition: C4StringTable.h:49
C4String P[P_LAST]
void Default()
Definition: C4Rect.cpp:39
void ClearPointers(C4Object *pObj)
int32_t getInt() const
Definition: C4Value.h:112
C4String * getStr() const
Definition: C4Value.h:117
C4V_Type GetType() const
Definition: C4Value.h:161
int32_t GetAudibility(int32_t x, int32_t y, int32_t *pan, int32_t audibility_radius=0, int32_t *out_player=nullptr)
void Value(const T &rStruct)
Definition: StdCompiler.h:161
virtual bool FollowName(const char *szName)
Definition: StdCompiler.h:84
void excNotFound(const char *szMessage,...)
Definition: StdCompiler.h:233
virtual bool isDeserializer()
Definition: StdCompiler.h:53
void SetCompletion(float completion)
Definition: StdMesh.cpp:1152
AttachedMesh * GetAttachParent() const
Definition: StdMesh.h:586
AnimationNode * GetRootAnimationForSlot(int slot)
Definition: StdMesh.cpp:1253
void ClearPointers(class C4Object *pObj)
Definition: StdMesh.cpp:1686
void SetFaceOrderingForClrModulation(uint32_t clrmod)
Definition: StdMesh.cpp:1135
void DenumeratePointers()
Definition: StdMesh.cpp:1674
void ExecuteAnimation(float dt)
Definition: StdMesh.cpp:1288
void AppendFormat(const char *szFmt,...) GNUC_FORMAT_ATTRIBUTE_O
Definition: StdBuf.cpp:190
const char * getData() const
Definition: StdBuf.h:442
void AppendChar(char cChar)
Definition: StdBuf.h:588
void Append(const char *pnData, size_t iChars)
Definition: StdBuf.h:519
void Clear()
Definition: StdBuf.h:466
size_t getLength() const
Definition: StdBuf.h:445