Пример #1
0
///////////////////////////////////////////////////////////////////////////////
// Descripcion:
// - Recorre un script.
// Parametros:
// - pScript. Script a imprimir
// Devuelve:
// Notas:
///////////////////////////////////////////////////////////////////////////////
void 
ReleaseScript(sScript* pScript)
{
  // ¿Hay script a imprimir?
  if (pScript) {
	switch(pScript->ScriptType) {
	  case SCRIPT_SEQ: {
		ReleaseScript(pScript->ScriptSeq.pFirst);
		ReleaseScript(pScript->ScriptSeq.pSecond);
	  } break;

	  case SCRIPT_DECL: {
		ReleaseScriptType(pScript->ScriptDecl.pType);		
		ReleaseImport(pScript->ScriptDecl.pImport);		
	    ReleaseConst(pScript->ScriptDecl.pConst);
		ReleaseVar(pScript->ScriptDecl.pVar);
		ReleaseFunc(pScript->ScriptDecl.pFunc);
		ReleaseStm(pScript->ScriptDecl.pStm);				
		ReleaseLabelList(pScript->ScriptDecl.pLabelList, 
						 pScript->ScriptDecl.unNumLabels);
		ReleaseOpcodeList(pScript->ScriptDecl.pOpcodeList);
		Mem_Free(pScript->ScriptDecl.szFileName);
		SymTableRelease(pScript->ScriptDecl.pSymTable);		
	  } break;	
	}; // ~ switch	

	// Borra nodo
	Mem_Free(pScript);
  }  
}
Пример #2
0
	int  SScriptObject::InitScript()
	{
		ReleaseScript();

		lua_State* pLua = m_pObjRef->pLua;
		if(!m_scriptHandle.Init(pLua))
		{
			return 0;
		}

		return 1;
	}
Пример #3
0
///////////////////////////////////////////////////////////////////////////////
// Descripcion:
// - Inicia el recorrido por el arbol AST para borrar los datos y para
//   coordinar el borrado de elementos localizados en otros modulos.
// Parametros:
// - pGlobal. Direccion a la estructura global.
// Devuelve:
// Notas:
///////////////////////////////////////////////////////////////////////////////
void 
Release(sGlobal* pGlobal)
{
  // ¿Hay datos?
  if (pGlobal) {
	// Recorrido y demas borrados
	ReleaseConst(pGlobal->pConst);
	ReleaseVar(pGlobal->pVar);
	ReleaseStm(pGlobal->pReturnStm);
	ReleaseScript(pGlobal->pScript);
	ReleaseOpcodeList(pGlobal->pOpcodeList);	
	Mem_Free(pGlobal->szFileName);
	SymTableRelease(pGlobal->pSymTable);

	// Se borra direccion a estructura global
	Mem_Free(pGlobal);

	// Se llama a las funciones de liberacion de otros modulos
	EndAuxTypes();
  }
}
Пример #4
0
Entity::~Entity() {
	
	cleanReferences();
	
	if(g_cameraEntity == this) {
		g_cameraEntity = NULL;
	}
	
	// Releases ToBeDrawn Transparent Polys linked to this object !
	tweaks.clear();
	
	if(obj && !(ioflags & IO_CAMERA) && !(ioflags & IO_MARKER) && !(ioflags & IO_GOLD)) {
		delete obj, obj = NULL;
	}
	
	spells.removeTarget(this);
	
	delete tweakerinfo;
	delete tweaky, tweaky = NULL;
	
	ReleaseScript(&script);
	ReleaseScript(&over_script);
	
	for(size_t n = 0; n < MAX_ANIMS; n++) {
		if(anims[n]) {
			EERIE_ANIMMANAGER_ReleaseHandle(anims[n]);
			anims[n] = NULL;
		}
	}
	
	lightHandleDestroy(dynlight);
	
	delete usepath;
	
	delete symboldraw;
	symboldraw = NULL;
	
	if(ioflags & IO_NPC) {
		delete _npcdata;
	} else if(ioflags & IO_ITEM) {
		free(_itemdata->equipitem);
		delete _itemdata;
	} else if(ioflags & IO_FIX) {
		delete _fixdata;
	} else if(ioflags & IO_CAMERA && _camdata) {
		if(g_camera == &_camdata->cam) {
			SetActiveCamera(&g_playerCamera);
		}
		delete _camdata;
	}
	
	if(SecondaryInventory && SecondaryInventory->io == this) {
		SecondaryInventory = NULL;
	}
	
	if(TSecondaryInventory && TSecondaryInventory->io == this) {
		TSecondaryInventory = NULL;
	}
	
	delete inventory;
	
	if(m_index != size_t(-1)) {
		entities.remove(m_index);
	}
	
}
Пример #5
0
Entity::~Entity() {
	
	cleanReferences();
	
	if(!FAST_RELEASE) {
		TREATZONE_RemoveIO(this);
	}
	
	if(ignit_light > -1) {
		DynLight[ignit_light].exist = 0, ignit_light = -1;
	}
	
	if(ignit_sound != audio::INVALID_ID) {
		ARX_SOUND_Stop(ignit_sound), ignit_sound = audio::INVALID_ID;
	}
	
	if(FlyingOverIO == this) {
		FlyingOverIO = NULL;
	}
	
	if((MasterCamera.exist & 1) && MasterCamera.io == this) {
		MasterCamera.exist = 0;
	}
	
	if((MasterCamera.exist & 2) && MasterCamera.want_io == this) {
		MasterCamera.exist = 0;
	}
	
	ARX_INTERACTIVE_DestroyDynamicInfo(this);
	IO_UnlinkAllLinkedObjects(this);
	
	// Releases ToBeDrawn Transparent Polys linked to this object !
	tweaks.clear();
	ARX_SCRIPT_Timer_Clear_For_IO(this);
	
	if(obj && !(ioflags & IO_CAMERA) && !(ioflags & IO_MARKER) && !(ioflags & IO_GOLD)) {
		delete obj, obj = NULL;
	}
	
	ARX_SPELLS_RemoveAllSpellsOn(this);
	
	delete tweakerinfo;
	delete tweaky, tweaky = NULL;
	
	RemoveFromAllInventories(this);
	
	ReleaseScript(&script);
	ReleaseScript(&over_script);
	
	for(long n = 0; n < MAX_ANIMS; n++) {
		if(anims[n]) {
			EERIE_ANIMMANAGER_ReleaseHandle(anims[n]);
			anims[n] = NULL;
		}
	}
	
	if(damagedata >= 0) {
		damages[damagedata].exist = 0;
	}
	
	if(ValidDynLight(dynlight)) {
		DynLight[dynlight].exist = 0, dynlight = -1;
	}
	
	if(ValidDynLight(halo.dynlight)) {
		DynLight[halo.dynlight].exist = 0, halo.dynlight = -1;
	}
	
	free(usepath);
	free(symboldraw), symboldraw = NULL;
	
	if(ioflags & IO_NPC) {
		delete _npcdata;
		
	} else if(ioflags & IO_ITEM) {
		free(_itemdata->equipitem);
		free(_itemdata);
		
	} else if(ioflags & IO_FIX) {
		free(_fixdata);
		
	} else if(ioflags & IO_CAMERA && _camdata) {
		if(ACTIVECAM == &_camdata->cam) {
			ACTIVECAM = &subj;
		}
		free(_camdata);
	}
	
	if(TSecondaryInventory && TSecondaryInventory->io == this) {
		TSecondaryInventory = NULL;
	}
	
	free(inventory);
	
	if(m_index != size_t(-1)) {
		entities.remove(m_index);
	}
	
	if(pIOChangeWeapon == this) {
		pIOChangeWeapon = NULL; // TODO we really need a proper weak_ptr
	}
}