OpenClonk
C4MaterialMap Class Reference

#include <C4Material.h>

Collaboration diagram for C4MaterialMap:
[legend]

Public Member Functions

 C4MaterialMap ()
 
 ~C4MaterialMap ()
 
void Default ()
 
void Clear ()
 
int32_t Load (C4Group &hGroup)
 
bool HasMaterials (C4Group &hGroup) const
 
int32_t Get (const char *szMaterial)
 
bool SaveEnumeration (C4Group &hGroup)
 
bool LoadEnumeration (C4Group &hGroup)
 
C4MaterialReactionGetReactionUnsafe (int32_t iPXSMat, int32_t iLandscapeMat)
 
C4MaterialReactionGetReaction (int32_t iPXSMat, int32_t iLandscapeMat)
 
void UpdateScriptPointers ()
 
bool CrossMapMaterials (const char *szEarthMaterial)
 

Static Public Member Functions

static bool mrfConvert (C4MaterialReaction *pReaction, int32_t &iX, int32_t &iY, int32_t iLSPosX, int32_t iLSPosY, C4Real &fXDir, C4Real &fYDir, int32_t &iPxsMat, int32_t iLsMat, MaterialInteractionEvent evEvent, bool *pfPosChanged)
 
static bool mrfPoof (C4MaterialReaction *pReaction, int32_t &iX, int32_t &iY, int32_t iLSPosX, int32_t iLSPosY, C4Real &fXDir, C4Real &fYDir, int32_t &iPxsMat, int32_t iLsMat, MaterialInteractionEvent evEvent, bool *pfPosChanged)
 
static bool mrfCorrode (C4MaterialReaction *pReaction, int32_t &iX, int32_t &iY, int32_t iLSPosX, int32_t iLSPosY, C4Real &fXDir, C4Real &fYDir, int32_t &iPxsMat, int32_t iLsMat, MaterialInteractionEvent evEvent, bool *pfPosChanged)
 
static bool mrfIncinerate (C4MaterialReaction *pReaction, int32_t &iX, int32_t &iY, int32_t iLSPosX, int32_t iLSPosY, C4Real &fXDir, C4Real &fYDir, int32_t &iPxsMat, int32_t iLsMat, MaterialInteractionEvent evEvent, bool *pfPosChanged)
 
static bool mrfInsert (C4MaterialReaction *pReaction, int32_t &iX, int32_t &iY, int32_t iLSPosX, int32_t iLSPosY, C4Real &fXDir, C4Real &fYDir, int32_t &iPxsMat, int32_t iLsMat, MaterialInteractionEvent evEvent, bool *pfPosChanged)
 
static bool mrfScript (C4MaterialReaction *pReaction, int32_t &iX, int32_t &iY, int32_t iLSPosX, int32_t iLSPosY, C4Real &fXDir, C4Real &fYDir, int32_t &iPxsMat, int32_t iLsMat, MaterialInteractionEvent evEvent, bool *pfPosChanged)
 

Public Attributes

int32_t Num
 
C4MaterialMap
 
C4MaterialReaction ** ppReactionMap
 
int32_t max_shape_width
 
int32_t max_shape_height
 
C4MaterialReaction DefReactConvert
 
C4MaterialReaction DefReactPoof
 
C4MaterialReaction DefReactCorrode
 
C4MaterialReaction DefReactIncinerate
 
C4MaterialReaction DefReactInsert
 

Protected Member Functions

void SetMatReaction (int32_t iPXSMat, int32_t iLSMat, C4MaterialReaction *pReact)
 
bool SortEnumeration (int32_t iMat, const char *szMatName)
 

Detailed Description

Definition at line 162 of file C4Material.h.

Constructor & Destructor Documentation

◆ C4MaterialMap()

C4MaterialMap::C4MaterialMap ( )

Definition at line 302 of file C4Material.cpp.

303 {
304  Default();
305 }
C4MaterialReaction DefReactConvert
Definition: C4Material.h:173
C4MaterialReaction DefReactPoof
Definition: C4Material.h:173
C4MaterialReaction DefReactIncinerate
Definition: C4Material.h:173
static bool mrfPoof(C4MaterialReaction *pReaction, int32_t &iX, int32_t &iY, int32_t iLSPosX, int32_t iLSPosY, C4Real &fXDir, C4Real &fYDir, int32_t &iPxsMat, int32_t iLsMat, MaterialInteractionEvent evEvent, bool *pfPosChanged)
Definition: C4Material.cpp:790
static bool mrfConvert(C4MaterialReaction *pReaction, int32_t &iX, int32_t &iY, int32_t iLSPosX, int32_t iLSPosY, C4Real &fXDir, C4Real &fYDir, int32_t &iPxsMat, int32_t iLsMat, MaterialInteractionEvent evEvent, bool *pfPosChanged)
Definition: C4Material.cpp:753
static bool mrfInsert(C4MaterialReaction *pReaction, int32_t &iX, int32_t &iY, int32_t iLSPosX, int32_t iLSPosY, C4Real &fXDir, C4Real &fYDir, int32_t &iPxsMat, int32_t iLsMat, MaterialInteractionEvent evEvent, bool *pfPosChanged)
Definition: C4Material.cpp:908
static bool mrfIncinerate(C4MaterialReaction *pReaction, int32_t &iX, int32_t &iY, int32_t iLSPosX, int32_t iLSPosY, C4Real &fXDir, C4Real &fYDir, int32_t &iPxsMat, int32_t iLsMat, MaterialInteractionEvent evEvent, bool *pfPosChanged)
Definition: C4Material.cpp:882
C4MaterialReaction DefReactInsert
Definition: C4Material.h:173
C4MaterialReaction DefReactCorrode
Definition: C4Material.h:173
static bool mrfCorrode(C4MaterialReaction *pReaction, int32_t &iX, int32_t &iY, int32_t iLSPosX, int32_t iLSPosY, C4Real &fXDir, C4Real &fYDir, int32_t &iPxsMat, int32_t iLsMat, MaterialInteractionEvent evEvent, bool *pfPosChanged)
Definition: C4Material.cpp:819

References Default().

Here is the call graph for this function:

◆ ~C4MaterialMap()

C4MaterialMap::~C4MaterialMap ( )

Definition at line 308 of file C4Material.cpp.

309 {
310  Clear();
311 }

References Clear().

Here is the call graph for this function:

Member Function Documentation

◆ Clear()

void C4MaterialMap::Clear ( )

Definition at line 313 of file C4Material.cpp.

314 {
315  delete [] Map; Map=nullptr; Num=0;
316  delete [] ppReactionMap; ppReactionMap = nullptr;
317 }
int32_t Num
Definition: C4Material.h:168
C4Material * Map
Definition: C4Material.h:169
C4MaterialReaction ** ppReactionMap
Definition: C4Material.h:170

References Map, Num, and ppReactionMap.

Referenced by c4_material_map_handle_new(), C4Game::Clear(), C4Game::InitMaterialTexture(), and ~C4MaterialMap().

Here is the caller graph for this function:

◆ CrossMapMaterials()

bool C4MaterialMap::CrossMapMaterials ( const char *  szEarthMaterial)

Definition at line 375 of file C4Material.cpp.

376 {
377  // Check material number
379  { LogFatal(LoadResStr("IDS_PRC_TOOMANYMATS")); return false; }
380  // build reaction function map
381  delete [] ppReactionMap;
382  typedef C4MaterialReaction * C4MaterialReactionPtr;
383  ppReactionMap = new C4MaterialReactionPtr[(Num+1)*(Num+1)];
384  for (int32_t iMatPXS=-1; iMatPXS<Num; iMatPXS++)
385  {
386  C4Material *pMatPXS = (iMatPXS+1) ? Map+iMatPXS : nullptr;
387  for (int32_t iMatLS=-1; iMatLS<Num; iMatLS++)
388  {
389  C4MaterialReaction *pReaction = nullptr;
390  C4Material *pMatLS = ( iMatLS+1) ? Map+ iMatLS : nullptr;
391  // natural stuff: material conversion here?
392  if (pMatPXS && pMatPXS->sInMatConvert.getLength() && SEqualNoCase(pMatPXS->sInMatConvert.getData(), pMatLS ? pMatLS->Name : C4TLS_MatSky))
393  pReaction = &DefReactConvert;
394  // non-sky reactions
395  else if (pMatPXS && pMatLS)
396  {
397  // incindiary vs extinguisher
398  if ((pMatPXS->Incendiary && pMatLS->Extinguisher) || (pMatPXS->Extinguisher && pMatLS->Incendiary))
399  pReaction = &DefReactPoof;
400  // incindiary vs inflammable
401  else if ((pMatPXS->Incendiary && pMatLS->Inflammable) || (pMatPXS->Inflammable && pMatLS->Incendiary))
402  pReaction = &DefReactIncinerate;
403  // corrosive vs corrode
404  else if (pMatPXS->Corrosive && pMatLS->Corrode)
405  pReaction = &DefReactCorrode;
406  // liquid hitting liquid or solid: Material insertion
407  else if (DensityLiquid(MatDensity(iMatPXS)) && DensitySemiSolid(MatDensity(iMatLS)))
408  pReaction = &DefReactInsert;
409  // solid hitting solid: Material insertion
410  else if (DensitySolid(MatDensity(iMatPXS)) && DensitySolid(MatDensity(iMatLS)))
411  pReaction = &DefReactInsert;
412  }
413  // assign the function; or nullptr for no reaction
414  SetMatReaction(iMatPXS, iMatLS, pReaction);
415  }
416  }
417  // reset max shape size
419  // material-specific initialization
420  int32_t cnt;
421  for (cnt=0; cnt<Num; cnt++)
422  {
423  C4Material *pMat = Map+cnt;
424  const char *szTextureOverlay = nullptr;
425  // newgfx: init pattern
426  if (Map[cnt].sTextureOverlay.getLength())
428  {
429  szTextureOverlay = Map[cnt].sTextureOverlay.getData();
430  // backwards compatibility: if a pattern was specified although the no-pattern flag was set, overwrite that flag
431  if (Map[cnt].OverlayType & C4MatOv_None)
432  {
433  DebugLogF("Error in overlay of material %s: Flag C4MatOv_None ignored because a custom overlay (%s) was specified!", Map[cnt].Name, szTextureOverlay);
434  Map[cnt].OverlayType &= ~C4MatOv_None;
435  }
436  }
437  // default to first texture in texture map
438  int iTexMapIx;
439  if (!szTextureOverlay && (iTexMapIx = ::TextureMap.GetIndex(Map[cnt].Name, nullptr, false)))
440  szTextureOverlay = TextureMap.GetEntry(iTexMapIx)->GetTextureName();
441  // default to smooth
442  if (!szTextureOverlay)
443  szTextureOverlay = "none";
444  // search/create entry in texmap
445  Map[cnt].DefaultMatTex = ::TextureMap.GetIndex(Map[cnt].Name, szTextureOverlay, true,
446  FormatString("DefaultMatTex of mat %s", Map[cnt].Name).getData());
447  // init PXS facet
448  C4Surface * sfcTexture;
449  C4Texture * Texture;
450  if (Map[cnt].sPXSGfx.getLength())
451  if ((Texture=::TextureMap.GetTexture(Map[cnt].sPXSGfx.getData())))
452  if ((sfcTexture=Texture->Surface32))
453  Map[cnt].PXSFace.Set(sfcTexture, Map[cnt].PXSGfxRt.x, Map[cnt].PXSGfxRt.y, Map[cnt].PXSGfxRt.Wdt, Map[cnt].PXSGfxRt.Hgt);
454  // evaluate reactions for that material
455  for (auto & iRCnt : pMat->CustomReactionList)
456  {
457  C4MaterialReaction *pReact = &iRCnt;
458  if (pReact->sConvertMat.getLength()) pReact->iConvertMat = Get(pReact->sConvertMat.getData()); else pReact->iConvertMat = -1;
459  // evaluate target spec
460  int32_t tmat;
461  if (MatValid(tmat=Get(pReact->TargetSpec.getData())))
462  {
463  // single material target
464  if (pReact->fInverseSpec)
465  for (int32_t cnt2=-1; cnt2<Num; cnt2++) {
466  if (cnt2!=tmat)
467  SetMatReaction(cnt, cnt2, pReact);
468  else
469  SetMatReaction(cnt, tmat, pReact);
470  }
471  }
472  else if (SEqualNoCase(pReact->TargetSpec.getData(), "All"))
473  {
474  // add to all materials, including sky
475  if (!pReact->fInverseSpec) for (int32_t cnt2=-1; cnt2<Num; cnt2++) SetMatReaction(cnt, cnt2, pReact);
476  }
477  else if (SEqualNoCase(pReact->TargetSpec.getData(), "Solid"))
478  {
479  // add to all solid materials
480  if (pReact->fInverseSpec) SetMatReaction(cnt, -1, pReact);
481  for (int32_t cnt2=0; cnt2<Num; cnt2++) if (DensitySolid(Map[cnt2].Density) != pReact->fInverseSpec) SetMatReaction(cnt, cnt2, pReact);
482  }
483  else if (SEqualNoCase(pReact->TargetSpec.getData(), "SemiSolid"))
484  {
485  // add to all semisolid materials
486  if (pReact->fInverseSpec) SetMatReaction(cnt, -1, pReact);
487  for (int32_t cnt2=0; cnt2<Num; cnt2++) if (DensitySemiSolid(Map[cnt2].Density) != pReact->fInverseSpec) SetMatReaction(cnt, cnt2, pReact);
488  }
489  else if (SEqualNoCase(pReact->TargetSpec.getData(), "Background"))
490  {
491  // add to all BG materials, including sky
492  if (!pReact->fInverseSpec) SetMatReaction(cnt, -1, pReact);
493  for (int32_t cnt2=0; cnt2<Num; cnt2++) if (!Map[cnt2].Density != pReact->fInverseSpec) SetMatReaction(cnt, cnt2, pReact);
494  }
495  else if (SEqualNoCase(pReact->TargetSpec.getData(), "Sky"))
496  {
497  // add to sky
498  if (!pReact->fInverseSpec)
499  SetMatReaction(cnt, -1, pReact);
500  else
501  for (int32_t cnt2=0; cnt2<Num; cnt2++) SetMatReaction(cnt, cnt2, pReact);
502  }
503  else if (SEqualNoCase(pReact->TargetSpec.getData(), "Incendiary") || SEqualNoCase(pReact->TargetSpec.getData(), "Incindiary"))
504  {
505  // add to all incendiary materials
506  if (pReact->fInverseSpec) SetMatReaction(cnt, -1, pReact);
507  for (int32_t cnt2=0; cnt2<Num; cnt2++) if (!Map[cnt2].Incendiary == pReact->fInverseSpec) SetMatReaction(cnt, cnt2, pReact);
508  }
509  else if (SEqualNoCase(pReact->TargetSpec.getData(), "Extinguisher"))
510  {
511  // add to all incendiary materials
512  if (pReact->fInverseSpec) SetMatReaction(cnt, -1, pReact);
513  for (int32_t cnt2=0; cnt2<Num; cnt2++) if (!Map[cnt2].Extinguisher == pReact->fInverseSpec) SetMatReaction(cnt, cnt2, pReact);
514  }
515  else if (SEqualNoCase(pReact->TargetSpec.getData(), "Inflammable"))
516  {
517  // add to all incendiary materials
518  if (pReact->fInverseSpec) SetMatReaction(cnt, -1, pReact);
519  for (int32_t cnt2=0; cnt2<Num; cnt2++) if (!Map[cnt2].Inflammable == pReact->fInverseSpec) SetMatReaction(cnt, cnt2, pReact);
520  }
521  else if (SEqualNoCase(pReact->TargetSpec.getData(), "Corrosive"))
522  {
523  // add to all incendiary materials
524  if (pReact->fInverseSpec) SetMatReaction(cnt, -1, pReact);
525  for (int32_t cnt2=0; cnt2<Num; cnt2++) if (!Map[cnt2].Corrosive == pReact->fInverseSpec) SetMatReaction(cnt, cnt2, pReact);
526  }
527  else if (SEqualNoCase(pReact->TargetSpec.getData(), "Corrode"))
528  {
529  // add to all incendiary materials
530  if (pReact->fInverseSpec) SetMatReaction(cnt, -1, pReact);
531  for (int32_t cnt2=0; cnt2<Num; cnt2++) if (!Map[cnt2].Corrode == pReact->fInverseSpec) SetMatReaction(cnt, cnt2, pReact);
532  }
533  }
534  }
535  // second loop (DefaultMatTex is needed by GetIndexMatTex)
536  for (cnt=0; cnt<Num; cnt++)
537  {
538  if (Map[cnt].sBlastShiftTo.getLength())
539  Map[cnt].BlastShiftTo=::TextureMap.GetIndexMatTex(Map[cnt].sBlastShiftTo.getData(), nullptr, true, FormatString("BlastShiftTo of mat %s", Map[cnt].Name).getData());
540  if (Map[cnt].sInMatConvertTo.getLength())
541  Map[cnt].InMatConvertTo=Get(Map[cnt].sInMatConvertTo.getData());
542  if (Map[cnt].sBelowTempConvertTo.getLength())
543  Map[cnt].BelowTempConvertTo=::TextureMap.GetIndexMatTex(Map[cnt].sBelowTempConvertTo.getData(), nullptr, true, FormatString("BelowTempConvertTo of mat %s", Map[cnt].Name).getData());
544  if (Map[cnt].sAboveTempConvertTo.getLength())
545  Map[cnt].AboveTempConvertTo=::TextureMap.GetIndexMatTex(Map[cnt].sAboveTempConvertTo.getData(), nullptr, true, FormatString("AboveTempConvertTo of mat %s", Map[cnt].Name).getData());
546  }
547 
548  // Get hardcoded system material indices
549  const C4TexMapEntry* earth_entry = ::TextureMap.GetEntry(::TextureMap.GetIndexMatTex(szEarthMaterial));
550  if(!earth_entry)
551  { LogFatal(FormatString(R"(Earth material "%s" not found!)", szEarthMaterial).getData()); return false; }
552 
553  MVehic = Get("Vehicle"); MCVehic = Mat2PixColDefault(MVehic);
555  MTunnel = Get("Tunnel");
556  MWater = Get("Water");
557  MEarth = Get(earth_entry->GetMaterialName());
558 
559  if ((MVehic==MNone) || (MTunnel==MNone))
560  { LogFatal(LoadResStr("IDS_PRC_NOSYSMATS")); return false; }
561 
562  return true;
563 }
const int32_t MNone
Definition: C4Constants.h:177
bool DensitySolid(int32_t dens)
Definition: C4Landscape.h:196
const int32_t C4MaxMaterial
Definition: C4Landscape.h:25
bool DensitySemiSolid(int32_t dens)
Definition: C4Landscape.h:201
bool DensityLiquid(int32_t dens)
Definition: C4Landscape.h:206
const char * LoadResStr(const char *id)
Definition: C4Language.h:83
bool LogFatal(const char *szMessage)
Definition: C4Log.cpp:239
bool DebugLogF(const char *strMessage ...)
Definition: C4Log.cpp:290
BYTE MCVehic
Definition: C4Material.cpp:37
int32_t MEarth
Definition: C4Material.cpp:36
int32_t MWater
Definition: C4Material.cpp:36
int32_t MVehic
Definition: C4Material.cpp:36
int32_t MTunnel
Definition: C4Material.cpp:36
C4MaterialMap MaterialMap
Definition: C4Material.cpp:974
int32_t MHalfVehic
Definition: C4Material.cpp:36
BYTE MCHalfVehic
Definition: C4Material.cpp:38
bool MatValid(int32_t mat)
Definition: C4Material.h:210
#define C4MatOv_None
Definition: C4Material.h:31
BYTE Mat2PixColDefault(int32_t mat)
Definition: C4Material.h:235
int32_t MatDensity(int32_t mat)
Definition: C4Material.h:240
C4TextureMap TextureMap
Definition: C4Texture.cpp:576
#define C4TLS_MatSky
Definition: C4ToolsDlg.h:39
bool SEqualNoCase(const char *szStr1, const char *szStr2, int iLen)
Definition: Standard.cpp:213
StdStrBuf FormatString(const char *szFmt,...)
Definition: StdBuf.cpp:270
void Set(C4Surface &rSfc)
Definition: C4Facet.cpp:459
int32_t Incendiary
Definition: C4Material.h:107
int32_t Corrode
Definition: C4Material.h:110
char Name[C4M_MaxName+1]
Definition: C4Material.h:89
int32_t Corrosive
Definition: C4Material.h:109
C4TargetRect PXSGfxRt
Definition: C4Material.h:117
std::vector< C4MaterialReaction > CustomReactionList
Definition: C4Material.h:87
int32_t Extinguisher
Definition: C4Material.h:108
StdCopyStrBuf sTextureOverlay
Definition: C4Material.h:114
int32_t OverlayType
Definition: C4Material.h:115
int32_t Inflammable
Definition: C4Material.h:106
StdCopyStrBuf sInMatConvert
Definition: C4Material.h:120
StdCopyStrBuf sPXSGfx
Definition: C4Material.h:116
int32_t AboveTempConvertTo
Definition: C4Material.h:154
C4Facet PXSFace
Definition: C4Material.h:157
int32_t InMatConvertTo
Definition: C4Material.h:152
int32_t BelowTempConvertTo
Definition: C4Material.h:153
int32_t BlastShiftTo
Definition: C4Material.h:151
int32_t DefaultMatTex
Definition: C4Material.h:155
int32_t max_shape_height
Definition: C4Material.h:171
void SetMatReaction(int32_t iPXSMat, int32_t iLSMat, C4MaterialReaction *pReact)
Definition: C4Material.cpp:566
int32_t Get(const char *szMaterial)
Definition: C4Material.cpp:365
int32_t max_shape_width
Definition: C4Material.h:171
int32_t y
Definition: C4Rect.h:30
int32_t Hgt
Definition: C4Rect.h:30
int32_t Wdt
Definition: C4Rect.h:30
Definition: C4Texture.h:49
const char * GetTextureName() const
Definition: C4Texture.h:61
const char * GetMaterialName() const
Definition: C4Texture.h:60
C4Surface * Surface32
Definition: C4Texture.h:35
int32_t GetIndex(const char *szMaterial, const char *szTexture, bool fAddIfNotExist=true, const char *szErrorIfFailed=nullptr)
Definition: C4Texture.cpp:414
int32_t GetIndexMatTex(const char *szMaterialTexture, const char *szDefaultTexture=nullptr, bool fAddIfNotExist=true, const char *szErrorIfFailed=nullptr)
Definition: C4Texture.cpp:441
const char * GetTexture(int32_t iIndex)
Definition: C4Texture.cpp:494
const C4TexMapEntry * GetEntry(int32_t iIndex) const
Definition: C4Texture.h:85
const char * getData() const
Definition: StdBuf.h:442
size_t getLength() const
Definition: StdBuf.h:445
StdCopyStrBuf sConvertMat
Definition: C4Material.h:57
int32_t iConvertMat
Definition: C4Material.h:58
StdCopyStrBuf TargetSpec
Definition: C4Material.h:49

References C4Material::AboveTempConvertTo, C4Material::BelowTempConvertTo, C4Material::BlastShiftTo, C4MatOv_None, C4MaxMaterial, C4TLS_MatSky, C4MaterialCore::Corrode, C4MaterialCore::Corrosive, C4MaterialCore::CustomReactionList, DebugLogF(), C4Material::DefaultMatTex, DefReactConvert, DefReactCorrode, DefReactIncinerate, DefReactInsert, DefReactPoof, DensityLiquid(), DensitySemiSolid(), DensitySolid(), C4MaterialCore::Extinguisher, C4MaterialReaction::fInverseSpec, FormatString(), Get(), StdStrBuf::getData(), C4TextureMap::GetEntry(), C4TextureMap::GetIndex(), C4TextureMap::GetIndexMatTex(), StdStrBuf::getLength(), C4TexMapEntry::GetMaterialName(), C4TextureMap::GetTexture(), C4TexMapEntry::GetTextureName(), C4Rect::Hgt, C4MaterialReaction::iConvertMat, C4MaterialCore::Incendiary, C4MaterialCore::Inflammable, C4Material::InMatConvertTo, LoadResStr(), LogFatal(), Map, Mat2PixColDefault(), MatDensity(), MaterialMap, MatValid(), max_shape_height, max_shape_width, MCHalfVehic, MCVehic, MEarth, MHalfVehic, MNone, MTunnel, MVehic, MWater, C4MaterialCore::Name, Num, C4MaterialCore::OverlayType, ppReactionMap, C4Material::PXSFace, C4MaterialCore::PXSGfxRt, C4MaterialReaction::sConvertMat, SEqualNoCase(), C4Facet::Set(), SetMatReaction(), C4MaterialCore::sInMatConvert, C4MaterialCore::sPXSGfx, C4MaterialCore::sTextureOverlay, C4Texture::Surface32, C4MaterialReaction::TargetSpec, TextureMap, C4Rect::Wdt, and C4Rect::y.

Referenced by C4Game::InitMaterialTexture().

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

◆ Default()

void C4MaterialMap::Default ( )

Definition at line 641 of file C4Material.cpp.

642 {
643  Num=0;
644  Map=nullptr;
645  ppReactionMap=nullptr;
647 }

References Map, max_shape_height, max_shape_width, Num, and ppReactionMap.

Referenced by C4MaterialMap(), and C4Game::Default().

Here is the caller graph for this function:

◆ Get()

int32_t C4MaterialMap::Get ( const char *  szMaterial)

Definition at line 365 of file C4Material.cpp.

366 {
367  int32_t cnt;
368  for (cnt=0; cnt<Num; cnt++)
369  if (SEqualNoCase(szMaterial,Map[cnt].Name))
370  return cnt;
371  return MNone;
372 }

References Map, MNone, Num, and SEqualNoCase().

Referenced by CrossMapMaterials(), C4Landscape::DrawChunks(), C4TextureMap::GetIndexMatTex(), C4TexMapEntry::Init(), Load(), C4MCOverlay::SetField(), and C4ToolsDlg::SetTexture().

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

◆ GetReaction()

C4MaterialReaction * C4MaterialMap::GetReaction ( int32_t  iPXSMat,
int32_t  iLandscapeMat 
)

Definition at line 649 of file C4Material.cpp.

650 {
651  // safety
652  if (!ppReactionMap) return nullptr;
653  if (!Inside<int32_t>(iPXSMat, -1, Num-1)) return nullptr;
654  if (!Inside<int32_t>(iLandscapeMat, -1, Num-1)) return nullptr;
655  // values OK; get func!
656  return GetReactionUnsafe(iPXSMat, iLandscapeMat);
657 }
C4MaterialReaction * GetReactionUnsafe(int32_t iPXSMat, int32_t iLandscapeMat)
Definition: C4Material.h:191

References GetReactionUnsafe(), Num, and ppReactionMap.

Here is the call graph for this function:

◆ GetReactionUnsafe()

C4MaterialReaction* C4MaterialMap::GetReactionUnsafe ( int32_t  iPXSMat,
int32_t  iLandscapeMat 
)
inline

Definition at line 191 of file C4Material.h.

192  {
193  assert(ppReactionMap); assert(Inside<int32_t>(iPXSMat,-1,Num-1)); assert(Inside<int32_t>(iLandscapeMat,-1,Num-1));
194  return ppReactionMap[(iLandscapeMat+1)*(Num+1) + iPXSMat+1];
195  }

References Num, and ppReactionMap.

Referenced by C4MassMover::Corrosion(), C4PXS::Execute(), GetReaction(), and C4Landscape::InsertMaterial().

Here is the caller graph for this function:

◆ HasMaterials()

bool C4MaterialMap::HasMaterials ( C4Group hGroup) const

Definition at line 360 of file C4Material.cpp.

361 {
362  return !!hGroup.EntryCount(C4CFN_MaterialFiles);
363 }
#define C4CFN_MaterialFiles
Definition: C4Components.h:169
int EntryCount(const char *wildcard=nullptr)
Definition: C4Group.cpp:2314

References C4CFN_MaterialFiles, and C4Group::EntryCount().

Here is the call graph for this function:

◆ Load()

int32_t C4MaterialMap::Load ( C4Group hGroup)

Definition at line 319 of file C4Material.cpp.

320 {
321  char entryname[256+1];
322 
323  // Determine number of materials in files
324  int32_t mat_num=hGroup.EntryCount(C4CFN_MaterialFiles);
325 
326  // Allocate new map
327  C4Material *pNewMap = new C4Material [mat_num + Num];
328  if (!pNewMap) return 0;
329 
330  // Load material cores to map
331  hGroup.ResetSearch(); int32_t cnt=0;
332  while (hGroup.FindNextEntry(C4CFN_MaterialFiles,entryname))
333  {
334  if (cnt >= mat_num) {
335  Log("Internal Error: More materials loaded than expected. Make sure your material file names are unique (ignoring case).");
336  break;
337  }
338  // Load mat
339  if (!pNewMap[cnt].Load(hGroup,entryname))
340  { delete [] pNewMap; return 0; }
341  // A new material?
342  if (Get(pNewMap[cnt].Name) == MNone)
343  cnt++;
344  }
345 
346  // Take over old materials.
347  for (int32_t i = 0; i < Num; i++)
348  {
349  pNewMap[cnt+i] = Map[i];
350  }
351  delete [] Map;
352  Map = pNewMap;
353 
354  // set material number
355  Num+=cnt;
356 
357  return cnt;
358 }
bool Log(const char *szMessage)
Definition: C4Log.cpp:204
bool FindNextEntry(const char *wildcard, StdStrBuf *filename=nullptr, size_t *size=nullptr, bool start_at_filename=false)
Definition: C4Group.cpp:2217
void ResetSearch(bool reload_contents=false)
Definition: C4Group.cpp:1316
int32_t Load(C4Group &hGroup)
Definition: C4Material.cpp:319

References C4CFN_MaterialFiles, C4Group::EntryCount(), C4Group::FindNextEntry(), Get(), Log(), Map, MNone, Num, and C4Group::ResetSearch().

Referenced by C4Game::InitMaterialTexture().

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

◆ LoadEnumeration()

bool C4MaterialMap::LoadEnumeration ( C4Group hGroup)

Definition at line 587 of file C4Material.cpp.

588 {
589  // Load enumeration map (from savegame), succeed if not present
590  StdStrBuf mapbuf;
591  if (!hGroup.LoadEntryString(C4CFN_MatMap, &mapbuf)) return true;
592 
593  // Sort material array by enumeration map, fail if some missing
594  const char *csearch;
595  char cmatname[C4M_MaxName+1];
596  int32_t cmat=0;
597  if (!(csearch = SSearch(mapbuf.getData(),"[Enumeration]"))) { return false; }
598  csearch=SAdvanceSpace(csearch);
599  while (IsIdentifier(*csearch))
600  {
601  SCopyIdentifier(csearch,cmatname,C4M_MaxName);
602  if (!SortEnumeration(cmat,cmatname))
603  {
604  // Output error message!
605  return false;
606  }
607  cmat++;
608  csearch+=SLen(cmatname);
609  csearch=SAdvanceSpace(csearch);
610  }
611 
612  return true;
613 }
#define C4CFN_MatMap
Definition: C4Components.h:81
const int C4M_MaxName
Definition: C4Constants.h:49
const char * SSearch(const char *szString, const char *szIndex)
Definition: Standard.cpp:369
bool IsIdentifier(char cChar)
Definition: Standard.cpp:90
const char * SAdvanceSpace(const char *szSPos)
Definition: Standard.cpp:420
void SCopyIdentifier(const char *szSource, char *sTarget, int iMaxL)
Definition: Standard.cpp:449
size_t SLen(const char *sptr)
Definition: Standard.h:74
bool LoadEntryString(const char *entry_name, StdStrBuf *buffer)
Definition: C4Group.cpp:2430
bool SortEnumeration(int32_t iMat, const char *szMatName)
Definition: C4Material.cpp:615

References C4CFN_MatMap, C4M_MaxName, StdStrBuf::getData(), IsIdentifier(), C4Group::LoadEntryString(), SAdvanceSpace(), SCopyIdentifier(), SLen(), SortEnumeration(), and SSearch().

Referenced by C4Game::InitMaterialTexture().

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

◆ mrfConvert()

bool C4MaterialMap::mrfConvert ( C4MaterialReaction pReaction,
int32_t &  iX,
int32_t &  iY,
int32_t  iLSPosX,
int32_t  iLSPosY,
C4Real fXDir,
C4Real fYDir,
int32_t &  iPxsMat,
int32_t  iLsMat,
MaterialInteractionEvent  evEvent,
bool *  pfPosChanged 
)
static

Definition at line 753 of file C4Material.cpp.

754 {
755  if (pReaction->fUserDefined) if (!mrfUserCheck(pReaction, iX, iY, iLSPosX, iLSPosY, fXDir, fYDir, iPxsMat, iLsMat, evEvent, pfPosChanged)) return false;
756  switch (evEvent)
757  {
758  case meePXSMove: // PXS movement
759  // for hardcoded stuff: only InMatConvert is Snow in Water, which does not have any collision proc
760  if (!pReaction->fUserDefined) break;
761  // user-defined conversions may also convert upon hitting materials
762 
763  case meePXSPos: // PXS check before movement
764  {
765  // Check depth
766  int32_t iDepth = pReaction->fUserDefined ? pReaction->iDepth : ::MaterialMap.Map[iPxsMat].InMatConvertDepth;
767  if (!iDepth || GBackMat(iX, iY - iDepth) == iLsMat)
768  {
769  // Convert
770  iPxsMat = pReaction->fUserDefined ? pReaction->iConvertMat : ::MaterialMap.Map[iPxsMat].InMatConvertTo;
771  if (!MatValid(iPxsMat))
772  // Convert failure (target mat not be loaded, or target may be C4TLS_MatSky): Kill Pix
773  return true;
774  // stop movement after conversion
775  fXDir = fYDir = 0;
776  if (pfPosChanged) *pfPosChanged = true;
777  }
778  }
779  break;
780 
781  case meeMassMove: // MassMover-movement
782  // Conversion-transfer to PXS
783  ::PXS.Create(iPxsMat,itofix(iX),itofix(iY));
784  return true;
785  }
786  // not handled
787  return false;
788 }
int32_t GBackMat(int32_t x, int32_t y)
Definition: C4Landscape.h:219
bool mrfUserCheck(C4MaterialReaction *pReaction, int32_t &iX, int32_t &iY, int32_t iLSPosX, int32_t iLSPosY, C4Real &fXDir, C4Real &fYDir, int32_t &iPxsMat, int32_t iLsMat, MaterialInteractionEvent evEvent, bool *pfPosChanged)
Definition: C4Material.cpp:741
@ meePXSPos
Definition: C4Material.h:36
@ meeMassMove
Definition: C4Material.h:38
@ meePXSMove
Definition: C4Material.h:37
C4PXSSystem PXS
Definition: C4PXS.cpp:423
C4Fixed itofix(int32_t x)
Definition: C4Real.h:261
int32_t InMatConvertDepth
Definition: C4Material.h:122
bool Create(int32_t mat, C4Real ix, C4Real iy, C4Real ixdir=Fix0, C4Real iydir=Fix0)
Definition: C4PXS.cpp:175

References C4PXSSystem::Create(), C4MaterialReaction::fUserDefined, GBackMat(), C4MaterialReaction::iConvertMat, C4MaterialReaction::iDepth, C4MaterialCore::InMatConvertDepth, C4Material::InMatConvertTo, itofix(), Map, MaterialMap, MatValid(), meeMassMove, meePXSMove, meePXSPos, mrfUserCheck(), and PXS.

Here is the call graph for this function:

◆ mrfCorrode()

bool C4MaterialMap::mrfCorrode ( C4MaterialReaction pReaction,
int32_t &  iX,
int32_t &  iY,
int32_t  iLSPosX,
int32_t  iLSPosY,
C4Real fXDir,
C4Real fYDir,
int32_t &  iPxsMat,
int32_t  iLsMat,
MaterialInteractionEvent  evEvent,
bool *  pfPosChanged 
)
static

Definition at line 819 of file C4Material.cpp.

820 {
821  if (pReaction->fUserDefined) if (!mrfUserCheck(pReaction, iX, iY, iLSPosX, iLSPosY, fXDir, fYDir, iPxsMat, iLsMat, evEvent, pfPosChanged)) return false;
822  switch (evEvent)
823  {
824  case meePXSPos: // PXS check before movement
825  // No corrosion - it would make acid incredibly effective
826  break;
827  case meeMassMove: // MassMover-movement
828  {
829  // evaluate corrosion percentage
830  bool fDoCorrode; int d100 = Random(100);
831  if (pReaction->fUserDefined)
832  fDoCorrode = (d100 < pReaction->iCorrosionRate);
833  else
834  fDoCorrode = (d100 < ::MaterialMap.Map[iPxsMat].Corrosive) && (d100 < ::MaterialMap.Map[iLsMat].Corrode);
835  if (fDoCorrode)
836  {
837  ::Landscape.ClearPix(iLSPosX,iLSPosY);
838  //::Landscape.CheckInstabilityRange(iLSPosX,iLSPosY); - more correct, but makes acid too effective as well
839  if (!Random(5))
840  {
841  Smoke(iX, iY, 3 + Random(3));
842  }
843  if (!Random(20)) StartSoundEffectAt("Liquids::Corrode", iX, iY);
844  return true;
845  }
846  }
847  break;
848 
849  case meePXSMove: // PXS movement
850  {
851  // corrodes to corrosives are always same density proc; so do insertion check first
852  if (!pReaction->fUserDefined)
853  if (!mrfInsertCheck(iX, iY, fXDir, fYDir, iPxsMat, iLsMat, pfPosChanged))
854  // either splash or slide prevented interaction
855  return false;
856  // evaluate corrosion percentage
857  bool fDoCorrode; int d100 = Random(100);
858  if (pReaction->fUserDefined)
859  fDoCorrode = (d100 < pReaction->iCorrosionRate);
860  else
861  fDoCorrode = (d100 < ::MaterialMap.Map[iPxsMat].Corrosive) && (d100 < ::MaterialMap.Map[iLsMat].Corrode);
862  if (fDoCorrode)
863  {
864  ::Landscape.ClearPix(iLSPosX,iLSPosY);
865  ::Landscape.CheckInstabilityRange(iLSPosX,iLSPosY);
866  if (!Random(5))
867  {
868  Smoke(iX,iY,3+Random(3));
869  }
870  if (!Random(20)) StartSoundEffectAt("Liquids::Corrode", iX, iY);
871  return true;
872  }
873  // Else: dead. Insert material here
874  ::Landscape.InsertMaterial(iPxsMat,&iX,&iY);
875  return true;
876  }
877  }
878  // not handled
879  return false;
880 }
C4Landscape Landscape
bool mrfInsertCheck(int32_t &iX, int32_t &iY, C4Real &fXDir, C4Real &fYDir, int32_t &iPxsMat, int32_t iLsMat, bool *pfPosChanged, bool no_slide=false)
Definition: C4Material.cpp:667
uint32_t Random()
Definition: C4Random.cpp:43
void CheckInstabilityRange(int32_t tx, int32_t ty)
bool InsertMaterial(int32_t mat, int32_t *tx, int32_t *ty, int32_t vx=0, int32_t vy=0, bool query_only=false)
bool ClearPix(int32_t tx, int32_t ty)
int32_t iCorrosionRate
Definition: C4Material.h:59
class C4SoundInstance * StartSoundEffectAt(const char *, int32_t, int32_t, int32_t, int32_t, int32_t, class C4SoundModifier *)
Definition: stub-handle.cpp:41

References C4Landscape::ClearPix(), C4MaterialCore::Corrode, C4MaterialCore::Corrosive, C4MaterialReaction::fUserDefined, C4MaterialReaction::iCorrosionRate, Landscape, Map, MaterialMap, meeMassMove, meePXSPos, mrfUserCheck(), and Random().

Here is the call graph for this function:

◆ mrfIncinerate()

bool C4MaterialMap::mrfIncinerate ( C4MaterialReaction pReaction,
int32_t &  iX,
int32_t &  iY,
int32_t  iLSPosX,
int32_t  iLSPosY,
C4Real fXDir,
C4Real fYDir,
int32_t &  iPxsMat,
int32_t  iLsMat,
MaterialInteractionEvent  evEvent,
bool *  pfPosChanged 
)
static

Definition at line 882 of file C4Material.cpp.

883 {
884  // not available as user reaction
885  assert(!pReaction->fUserDefined);
886  switch (evEvent)
887  {
888  case meeMassMove: // MassMover-movement
889  case meePXSPos: // PXS check before movement
890  if (::Landscape.Incinerate(iX, iY, NO_OWNER)) return true;
891  break;
892 
893  case meePXSMove: // PXS movement
894  // incinerate to inflammables are always same density proc; so do insertion check first
895  if (!mrfInsertCheck(iX, iY, fXDir, fYDir, iPxsMat, iLsMat, pfPosChanged))
896  // either splash or slide prevented interaction
897  return false;
898  // evaluate inflammation (should always succeed)
899  if (::Landscape.Incinerate(iX, iY, NO_OWNER)) return true;
900  // Else: dead. Insert material here
901  ::Landscape.InsertMaterial(iPxsMat,&iX,&iY);
902  return true;
903  }
904  // not handled
905  return false;
906 }
const int NO_OWNER
Definition: C4Constants.h:137
bool Incinerate(int32_t x, int32_t y, int32_t cause_player)

References C4MaterialReaction::fUserDefined, C4Landscape::Incinerate(), C4Landscape::InsertMaterial(), Landscape, meeMassMove, meePXSMove, meePXSPos, mrfInsertCheck(), and NO_OWNER.

Here is the call graph for this function:

◆ mrfInsert()

bool C4MaterialMap::mrfInsert ( C4MaterialReaction pReaction,
int32_t &  iX,
int32_t &  iY,
int32_t  iLSPosX,
int32_t  iLSPosY,
C4Real fXDir,
C4Real fYDir,
int32_t &  iPxsMat,
int32_t  iLsMat,
MaterialInteractionEvent  evEvent,
bool *  pfPosChanged 
)
static

Definition at line 908 of file C4Material.cpp.

909 {
910  if (pReaction->fUserDefined) if (!mrfUserCheck(pReaction, iX, iY, iLSPosX, iLSPosY, fXDir, fYDir, iPxsMat, iLsMat, evEvent, pfPosChanged)) return false;
911  switch (evEvent)
912  {
913  case meePXSPos: // PXS check before movement
914  break;
915 
916  case meePXSMove: // PXS movement
917  {
918  // check for bounce/slide
919  if (!pReaction->fUserDefined)
920  if (!mrfInsertCheck(iX, iY, fXDir, fYDir, iPxsMat, iLsMat, pfPosChanged))
921  // continue existing
922  return false;
923  // Else: dead. Insert material here
924  ::Landscape.InsertMaterial(iPxsMat,&iX,&iY);
925  return true;
926  }
927 
928  case meeMassMove: // MassMover-movement
929  break;
930  }
931  // not handled
932  return false;
933 }

References C4MaterialReaction::fUserDefined, C4Landscape::InsertMaterial(), Landscape, meeMassMove, meePXSMove, meePXSPos, mrfInsertCheck(), and mrfUserCheck().

Here is the call graph for this function:

◆ mrfPoof()

bool C4MaterialMap::mrfPoof ( C4MaterialReaction pReaction,
int32_t &  iX,
int32_t &  iY,
int32_t  iLSPosX,
int32_t  iLSPosY,
C4Real fXDir,
C4Real fYDir,
int32_t &  iPxsMat,
int32_t  iLsMat,
MaterialInteractionEvent  evEvent,
bool *  pfPosChanged 
)
static

Definition at line 790 of file C4Material.cpp.

791 {
792  if (pReaction->fUserDefined) if (!mrfUserCheck(pReaction, iX, iY, iLSPosX, iLSPosY, fXDir, fYDir, iPxsMat, iLsMat, evEvent, pfPosChanged)) return false;
793  switch (evEvent)
794  {
795  case meeMassMove: // MassMover-movement
796  case meePXSPos: // PXS check before movement: Kill both landscape and PXS mat
797  ::Landscape.ExtractMaterial(iLSPosX,iLSPosY,false);
798  if (!Random(3)) Smoke(iX,iY,3);
799  if (!Random(3)) StartSoundEffectAt("Liquids::Pshshsh", iX, iY);
800  return true;
801 
802  case meePXSMove: // PXS movement
803  // incindiary/extinguisher/corrosives are always same density proc; so do insertion check first
804  // Do not allow sliding though (e.g. water on lava).
805  if (!pReaction->fUserDefined)
806  if (!mrfInsertCheck(iX, iY, fXDir, fYDir, iPxsMat, iLsMat, pfPosChanged, true))
807  // either splash or slide prevented interaction
808  return false;
809  // Always kill both landscape and PXS mat
810  ::Landscape.ExtractMaterial(iLSPosX,iLSPosY,false);
811  if (!Random(3)) Smoke(iX,iY,3);
812  if (!Random(3)) StartSoundEffectAt("Liquids::Pshshsh", iX, iY);
813  return true;
814  }
815  // not handled
816  return false;
817 }
int32_t ExtractMaterial(int32_t fx, int32_t fy, bool distant_first)

References C4Landscape::ExtractMaterial(), C4MaterialReaction::fUserDefined, Landscape, meeMassMove, meePXSPos, mrfUserCheck(), and Random().

Here is the call graph for this function:

◆ mrfScript()

bool C4MaterialMap::mrfScript ( C4MaterialReaction pReaction,
int32_t &  iX,
int32_t &  iY,
int32_t  iLSPosX,
int32_t  iLSPosY,
C4Real fXDir,
C4Real fYDir,
int32_t &  iPxsMat,
int32_t  iLsMat,
MaterialInteractionEvent  evEvent,
bool *  pfPosChanged 
)
static

Definition at line 935 of file C4Material.cpp.

936 {
937  // do generic checks for user-defined reactions
938  if (!mrfUserCheck(pReaction, iX, iY, iLSPosX, iLSPosY, fXDir, fYDir, iPxsMat, iLsMat, evEvent, pfPosChanged))
939  return false;
940 
941  // check script func
942  if (!pReaction->pScriptFunc) return false;
943  // OK - let's call it!
944  // 0 1 2 3 4 5 6 7 8
945  int32_t iXDir1, iYDir1, iXDir2, iYDir2;
946  C4AulParSet pars(iX, iY, iLSPosX, iLSPosY, iXDir1 = fixtoi(fXDir, 100), iYDir1 = fixtoi(fYDir, 100), iPxsMat, iLsMat, int(evEvent));
947  if (!!pReaction->pScriptFunc->Exec(nullptr, &pars, false))
948  {
949  // PXS shall be killed!
950  return true;
951  }
952  // PXS shall exist further: write back parameters
953  iPxsMat = pars[6].getInt();
954  int32_t iX2 = pars[0].getInt(), iY2 = pars[1].getInt();
955  iXDir2 = pars[4].getInt(); iYDir2 = pars[5].getInt();
956  if (iX!=iX2 || iY!=iY2 || iXDir1!=iXDir2 || iYDir1!=iYDir2)
957  {
958  // changes to pos/speed detected
959  if (pfPosChanged) *pfPosChanged = true;
960  iX=iX2; iY=iY2;
961  fXDir = C4REAL100(iXDir2);
962  fYDir = C4REAL100(iYDir2);
963  }
964  // OK; done
965  return false;
966 }
int fixtoi(const C4Fixed &x)
Definition: C4Real.h:259
C4Real C4REAL100(int x)
Definition: C4Real.h:267
C4Value Exec(C4PropList *p=nullptr, C4AulParSet *pPars=nullptr, bool fPassErrors=false)
Definition: C4AulFunc.h:72
C4AulFunc * pScriptFunc
Definition: C4Material.h:51

References C4REAL100(), C4AulFunc::Exec(), fixtoi(), mrfUserCheck(), and C4MaterialReaction::pScriptFunc.

Referenced by C4MaterialReaction::ResolveScriptFuncs().

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

◆ SaveEnumeration()

bool C4MaterialMap::SaveEnumeration ( C4Group hGroup)

Definition at line 574 of file C4Material.cpp.

575 {
576  char *mapbuf = new char [1000];
577  mapbuf[0]=0;
578  SAppend("[Enumeration]",mapbuf); SAppend("\n",mapbuf);
579  for (int32_t cnt=0; cnt<Num; cnt++)
580  {
581  SAppend(Map[cnt].Name,mapbuf);
582  SAppend("\n",mapbuf);
583  }
584  return hGroup.Add(C4CFN_MatMap,mapbuf,SLen(mapbuf),false,true);
585 }
void SAppend(const char *szSource, char *szTarget, int iMaxL)
Definition: Standard.cpp:263
bool Add(const char *filename, const char *entry_name)
Definition: C4Group.cpp:1621

References C4Group::Add(), C4CFN_MatMap, Map, Num, SAppend(), and SLen().

Here is the call graph for this function:

◆ SetMatReaction()

void C4MaterialMap::SetMatReaction ( int32_t  iPXSMat,
int32_t  iLSMat,
C4MaterialReaction pReact 
)
protected

Definition at line 566 of file C4Material.cpp.

567 {
568  // evaluate reaction swap
569  if (pReact && pReact->fReverse) std::swap(iPXSMat, iLSMat);
570  // set it
571  ppReactionMap[(iLSMat+1)*(Num+1) + iPXSMat+1] = pReact;
572 }

References C4MaterialReaction::fReverse, Num, and ppReactionMap.

Referenced by CrossMapMaterials().

Here is the caller graph for this function:

◆ SortEnumeration()

bool C4MaterialMap::SortEnumeration ( int32_t  iMat,
const char *  szMatName 
)
protected

Definition at line 615 of file C4Material.cpp.

616 {
617 
618  // Not enough materials loaded
619  if (iMat>=Num) return false;
620 
621  // Find requested mat
622  int32_t cmat;
623  for (cmat=iMat; cmat<Num; cmat++)
624  if (SEqual(szMatName,Map[cmat].Name))
625  break;
626  // Not found
627  if (cmat>=Num) return false;
628 
629  // already the same?
630  if (cmat == iMat) return true;
631 
632  // Move requested mat to indexed position
633  C4Material mswap;
634  mswap = Map[iMat];
635  Map[iMat] = Map[cmat];
636  Map[cmat] = mswap;
637 
638  return true;
639 }
bool SEqual(const char *szStr1, const char *szStr2)
Definition: Standard.h:93

References Map, Num, and SEqual().

Referenced by LoadEnumeration().

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

◆ UpdateScriptPointers()

void C4MaterialMap::UpdateScriptPointers ( )

Definition at line 968 of file C4Material.cpp.

969 {
970  // update in all materials
971  for (int32_t i=0; i<Num; ++i) Map[i].UpdateScriptPointers();
972 }
void UpdateScriptPointers()
Definition: C4Material.cpp:968

References Map, and Num.

Referenced by C4Game::InitMaterialTexture(), C4Game::LinkScriptEngine(), and C4Game::ReLinkScriptEngine().

Here is the caller graph for this function:

Member Data Documentation

◆ DefReactConvert

C4MaterialReaction C4MaterialMap::DefReactConvert

Definition at line 173 of file C4Material.h.

Referenced by CrossMapMaterials().

◆ DefReactCorrode

C4MaterialReaction C4MaterialMap::DefReactCorrode

Definition at line 173 of file C4Material.h.

Referenced by CrossMapMaterials().

◆ DefReactIncinerate

C4MaterialReaction C4MaterialMap::DefReactIncinerate

Definition at line 173 of file C4Material.h.

Referenced by CrossMapMaterials().

◆ DefReactInsert

C4MaterialReaction C4MaterialMap::DefReactInsert

Definition at line 173 of file C4Material.h.

Referenced by CrossMapMaterials().

◆ DefReactPoof

C4MaterialReaction C4MaterialMap::DefReactPoof

Definition at line 173 of file C4Material.h.

Referenced by CrossMapMaterials().

◆ Map

◆ max_shape_height

int32_t C4MaterialMap::max_shape_height

Definition at line 171 of file C4Material.h.

Referenced by CrossMapMaterials(), Default(), and C4Landscape::P::MapToSurface().

◆ max_shape_width

int32_t C4MaterialMap::max_shape_width

Definition at line 171 of file C4Material.h.

Referenced by CrossMapMaterials(), Default(), and C4Landscape::P::MapToSurface().

◆ Num

◆ ppReactionMap

C4MaterialReaction** C4MaterialMap::ppReactionMap

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