Skip to content

Commit

Permalink
Move component management from CEntityClass to CDLLEntityClass.
Browse files Browse the repository at this point in the history
  • Loading branch information
DreamyCecil committed Jun 12, 2024
1 parent 4c9318b commit 5bf6327
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 17 deletions.
26 changes: 14 additions & 12 deletions Sources/Engine/Entities/EntityClass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,11 +81,13 @@ void CEntityClass::Clear(void)
{
// if the DLL is loaded
if (ec_hiClassDLL != NULL) {
// detach the DLL
ec_pdecDLLClass->dec_OnEndClass();
// [Cecil] Free the class if it's been loaded
if (ec_pdecDLLClass != NULL) {
ec_pdecDLLClass->dec_OnEndClass();

// release all components needed by the DLL
ReleaseComponents();
// Release all components needed by the DLL
ec_pdecDLLClass->ReleaseComponents();
}

/* The dll is never released from memory, because declared shell symbols
* must stay avaliable, since they cannot be undeclared.
Expand Down Expand Up @@ -174,14 +176,14 @@ CEntity *CEntityClass::New(void)
/*
* Obtain all components from component table.
*/
void CEntityClass::ObtainComponents_t(void)
void CDLLEntityClass::ObtainComponents_t(void)
{
// for each component
for (INDEX iComponent=0; iComponent<ec_pdecDLLClass->dec_ctComponents; iComponent++) {
for (INDEX iComponent = 0; iComponent < dec_ctComponents; iComponent++) {
// if not precaching all
if( gam_iPrecachePolicy<PRECACHE_ALL) {
// if component is not class
CEntityComponent &ec = ec_pdecDLLClass->dec_aecComponents[iComponent];
CEntityComponent &ec = dec_aecComponents[iComponent];
if (ec.ec_ectType!=ECT_CLASS) {
// skip it
continue;
Expand All @@ -191,7 +193,7 @@ void CEntityClass::ObtainComponents_t(void)
// try to
try {
// obtain the component
ec_pdecDLLClass->dec_aecComponents[iComponent].Obtain_t();
dec_aecComponents[iComponent].Obtain_t();
// if failed
} catch (char *) {
// if in paranoia mode
Expand All @@ -210,12 +212,12 @@ void CEntityClass::ObtainComponents_t(void)
/*
* Release all components from component table.
*/
void CEntityClass::ReleaseComponents(void)
void CDLLEntityClass::ReleaseComponents(void)
{
// for each component
for (INDEX iComponent=0; iComponent<ec_pdecDLLClass->dec_ctComponents; iComponent++) {
for (INDEX iComponent = 0; iComponent < dec_ctComponents; iComponent++) {
// release the component
ec_pdecDLLClass->dec_aecComponents[iComponent].Release();
dec_aecComponents[iComponent].Release();
}
}

Expand Down Expand Up @@ -266,7 +268,7 @@ void CEntityClass::Read_t( CTStream *istr) // throw char *
// obtain all components needed by the DLL
{
CTmpPrecachingNow tpn;
ObtainComponents_t();
ec_pdecDLLClass->ObtainComponents_t();
}

// attach the DLL
Expand Down
5 changes: 0 additions & 5 deletions Sources/Engine/Entities/EntityClass.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,6 @@ with this program; if not, write to the Free Software Foundation, Inc.,
* General structure of an entity class.
*/
class ENGINE_API CEntityClass : public CSerial {
public:
/* Obtain all components from component table. */
void ObtainComponents_t(void); // throw char *
/* Release all components from component table. */
void ReleaseComponents(void);
public:
CTFileName ec_fnmClassDLL; // filename of the DLL with the class
HINSTANCE ec_hiClassDLL; // handle to the DLL with the class
Expand Down
8 changes: 8 additions & 0 deletions Sources/Engine/Entities/EntityProperties.h
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,14 @@ class ENGINE_API CDLLEntityClass {
void PrecacheTexture(SLONG slID);
void PrecacheSound(SLONG slID);
void PrecacheClass(SLONG slID, INDEX iUser = -1);

// [Cecil] Moved from CEntityClass

// Obtain all components from component table
void ObtainComponents_t(void);

// Release all components from component table
void ReleaseComponents(void);
};

/* rcg10062001 */
Expand Down

0 comments on commit 5bf6327

Please sign in to comment.