/*========================================================================= * * SECTobj.cpp : Implementation of Sector Object * * * Version 1.0 * Creation date * Revision date * * Shaitan *=======================================================================*/ #include "stdafx.h" #include "acp_base.h" #include "SECTint.hpp" //Shaitan Clean Env //#include "SEClEnvs.hpp" #include "DPT.h" #include "OGD.h" /*============================================================================= Defines =============================================================================*/ #define C_szSectorActionName "Sector" /*============================================================================= Engine struct =============================================================================*/ DeclareTemplateStatic(SECT_tdxHandleOfSectorObject); void del(SECT_tdxHandleOfSectorObject h) { }; //Shaitan Clean Env /* void del(ENV_tdxHandleToEnvironment h) { }; void del(DNM_tdxHandleToMecEnvironment h) { }; void del(ACP_tdxHandleToVisualEnvironment h) { }; void del(SRF_tdxHandleToSurface h) { }; */ void del(SECT_tdxHandleOfElementLstCollisionInteraction h) { }; void del(SECT_tdxHandleOfElementLstActivityInteraction h) { }; void del(SECT_tdxHandleOfElementLstGraphicInteraction h) { }; void del(SECT_tdxHandleOfElementLstSoundInteraction h) { }; void del(SCT_tdxHandleOfLstSoundEvent h) { }; //Shaitan Clean Env /* void del(SECT_tdxHandleOfElementLstEnvironment h) { }; void del(SCT_tdxHandleOfElementLstSurface h) { }; */ //################################################################################# // CONSTRUCTOR & DESTRUCTOR //################################################################################# /*=========================================================================== * Description: Constructor * Creation date: * Author: Shaitan *--------------------------------------------------------------------------- * Revision date: Author: *=========================================================================*/ Sector_Object::Sector_Object(CPA_ObjectDLLBase *p_oDLL, SECT_tdxHandleOfSectorObject hObj, CString csName, CString csFileName ) : CPA_SaveObject (p_oDLL, // owner editor C_szSectorTypeName, // type E_ss_Responsible, // status NULL, // owner TRUE, // validity fn_szGetLevelsDataPath(), // data path Sector_Object::CallBackSaveName // callback for save ), CPA_EdMot (hObj) { char szSectionName[SCR_CV_ui_Cfg_MaxLenName]; // section object SetSectionData(this); // section name SCR_fn_v_RdL0_ComputeSectionName(szSectionName, (char *)(LPCSTR)csFileName, C_szSectorActionName, " "); SetReferencedSectionName(szSectionName); // name if (fn_eRename(csName ) != E_mc_None) SetDefaultValidName(); fn_vUpdateSectionName(); // existence SetExistingSection(TRUE); // init superobject m_pSuperObject = NULL; m_pBorder = NULL; m_pBorderSection = NULL; m_pVirtualSection = new SECT_ElementBase(this); m_pCameraSection = new SECT_ElementBase(this); m_pPrioritySection = new SECT_ElementBase(this); // init lists fn_vInitEngineAnchors(); m_oCollisionList.SetOwnerSector(this); m_oActivityList.SetOwnerSector(this); m_oGraphicList.SetOwnerSector(this); m_oSoundList.SetOwnerSector(this); m_oSoundEventList.SetOwnerSector(this); //Shaitan Clean Env /* m_oEnvironmentList.SetOwnerSector(this); m_oSurfaceList.SetOwnerSector(this); */ // RAZ all lists m_oGraphicList.fn_vRemoveAllElements(FALSE); m_oCollisionList.fn_vRemoveAllElements(FALSE); m_oActivityList.fn_vRemoveAllElements(FALSE); m_oSoundList.fn_vRemoveAllElements(FALSE); m_oSoundEventList.fn_vRemoveAllElements(FALSE); //Shaitan Clean Env /* m_oEnvironmentList.fn_vRemoveAllElements(FALSE); m_lNbEnvironments = 0; m_oSurfaceList.fn_vRemoveAllElements(FALSE); m_lNbSurfaces = 0; */ // raz sections m_bHasSectorsLinkSection = FALSE; //Shaitan Clean Env // m_bHasEnvAndSurfSection = FALSE; // fill all lists fn_vInitSortedLists(); //Shaitan Clean Env // fn_vInitEnvironments(); // fn_vInitSurfaces(); fn_vInitBorder(); // init param for Rename m_bWasRenamed = FALSE; }; /*=========================================================================== * Description: Destructor * Creation date: * Author: Shaitan *--------------------------------------------------------------------------- * Revision date: Author: *=========================================================================*/ Sector_Object::~Sector_Object() { // clear all list /* while (m_oGraphicList.GetCount()) delete (m_oGraphicList.RemoveTail()); while (m_oCollisionList.GetCount()) delete (m_oCollisionList.RemoveTail()); while (m_oActivityList.GetCount()) delete (m_oActivityList.RemoveTail()); while (m_oSoundList.GetCount()) delete (m_oSoundList.RemoveTail()); while (m_oSoundEventList.GetCount()) delete (m_oSoundEventList.RemoveTail()); */ } /*=========================================================================== * Description: Set Struct * Creation date: * Author: Shaitan *--------------------------------------------------------------------------- * Revision date: Author: *=========================================================================*/ void Sector_Object::SetEngineStruct (SECT_tdxHandleOfSectorObject hObj) { // set engine struct SetStruct(hObj); fn_vInitEngineAnchors(); // raz all lists m_oGraphicList.fn_vRemoveAllElements(FALSE); m_oCollisionList.fn_vRemoveAllElements(FALSE); m_oActivityList.fn_vRemoveAllElements(FALSE); m_oSoundList.fn_vRemoveAllElements(FALSE); m_oSoundEventList.fn_vRemoveAllElements(FALSE); //Shaitan Clean Env /* m_oEnvironmentList.fn_vRemoveAllElements(FALSE); m_lNbEnvironments = 0; m_oSurfaceList.fn_vRemoveAllElements(FALSE); m_lNbSurfaces = 0; */ // raz sections m_bHasSectorsLinkSection = FALSE; //Shaitan Clean Env // m_bHasEnvAndSurfSection = FALSE; // fill all lists fn_vInitSortedLists(); //Shaitan Clean Env // fn_vInitEnvironments(); // fn_vInitSurfaces(); fn_vInitBorder(); } /*=========================================================================== * Description: Engine struct : inits for lists * Creation date: * Author: Shaitan *--------------------------------------------------------------------------- * Revision date: Author: *=========================================================================*/ void Sector_Object::fn_vInitEngineAnchors (void) { if (GetStruct()) { m_oGraphicList.SetEngineAnchor(&GetStruct()->stListOfSectorsInGraphicInteraction); m_oCollisionList.SetEngineAnchor(&GetStruct()->stListOfSectorsInCollisionInteraction); m_oActivityList.SetEngineAnchor(&GetStruct()->stListOfSectorsInActivityInteraction); m_oSoundList.SetEngineAnchor(&GetStruct()->stListOfSectorsInSoundInteraction); m_oSoundEventList.SetEngineAnchor(&GetStruct()->stListOfSoundEvent); //Shaitan Clean Env /* m_oEnvironmentList.SetEngineAnchor(&GetStruct()->stListOfEnvironment); m_oSurfaceList.SetEngineAnchor(&GetStruct()->stListOfSurface); */ } else { m_oGraphicList.SetEngineAnchor(NULL); m_oCollisionList.SetEngineAnchor(NULL); m_oActivityList.SetEngineAnchor(NULL); m_oSoundList.SetEngineAnchor(NULL); m_oSoundEventList.SetEngineAnchor(NULL); //Shaitan Clean Env /* m_oEnvironmentList.SetEngineAnchor(NULL); m_oSurfaceList.SetEngineAnchor(NULL); */ } } //################################################################################# // INITS //################################################################################# /*=========================================================================== * Description: Init for scripts * Creation date: * Author: Shaitan *--------------------------------------------------------------------------- * Revision date: Author: *=========================================================================*/ void Sector_Object::StaticInit() { CPA_EdMot::Init(NULL,NULL,del); //Shaitan Clean Env /* CPA_EdMot::Init(ENV_fn_hCreateEnvironment,ENV_fn_vCopyEnvironment,del); CPA_EdMot::Init(DNM_fn_xEnvironmentCreate,NULL,del); CPA_EdMot::Init(GLI_fn_hCreateVisualEnvironment,NULL,del); CPA_EdMot::Init(SRF_fn_hCreatesSurface,NULL,del); */ CPA_EdMot::Init(SECT_fn_hCreateElementLstCollisionInteraction,NULL,del); CPA_EdMot::Init(SECT_fn_hCreateElementLstActivityInteraction,NULL,del); CPA_EdMot::Init(SECT_fn_hCreateElementLstGraphicInteraction,NULL,del); CPA_EdMot::Init(SECT_fn_hCreateElementLstSoundInteraction,NULL,del); CPA_EdMot::Init(SCT_fn_hCreateElementLstSoundEvent,NULL,del); //Shaitan Clean Env /* CPA_EdMot::Init(SECT_fn_hCreateElementLstEnvironment,NULL,del); CPA_EdMot::Init(SCT_fn_hCreateElementLstSurface,NULL,del); */ } /*=========================================================================== * Description: Fill sorted lists from engine struct * Creation date: * Author: Shaitan *--------------------------------------------------------------------------- * Revision date: Author: *=========================================================================*/ void Sector_Object::fn_vInitSortedLists (void) { SECT_tdxHandleOfElementLstSoundInteraction hSoundElem; SECT_tdxHandleOfElementLstGraphicInteraction hGraphicElem; SECT_tdxHandleOfElementLstActivityInteraction hActivityElem; SECT_tdxHandleOfElementLstCollisionInteraction hCollisionElem; SCT_tdxHandleOfLstSoundEvent hSoundEventElem; HIE_tdxHandleToSuperObject hSupObj; SECT_SndEvtEngineElem *pSoundEventElem; SECT_CollisionElement *pCollisionElem; SECT_ActivityElement *pActivityElem; SECT_GraphicElement *pGraphicElem; SECT_SoundElement *pSoundElem; long lCount = 0; // get engine super-object if (!GetSuperObject()) return; // only if lists are not initialised lCount += m_oGraphicList.GetCount(); lCount += m_oCollisionList.GetCount(); lCount += m_oActivityList.GetCount(); lCount += m_oSoundList.GetCount(); lCount += m_oSoundEventList.GetCount(); if (lCount > 0) return; hSupObj = (HIE_tdxHandleToSuperObject) GetSuperObject()->GetSuperObjectStruct(); // graphic hGraphicElem = SECT_fn_hGetFirstGraphicNodeInGraphicList(hSupObj); while (hGraphicElem) { // there is at least an element => section exists ! SetExistingSectorsLinkSection(TRUE); // create element pGraphicElem = new SECT_GraphicElement(hGraphicElem, this); // update list m_oGraphicList.fn_bAddAnElement(pGraphicElem, FALSE); // next elem hGraphicElem = SECT_fn_hGetNextGraphicNodeInGraphicList(hGraphicElem); } // collision hCollisionElem = SECT_fn_hGetFirstCollisionNodeInCollisionList(hSupObj); while (hCollisionElem) { // there is at least an element => section exists ! SetExistingSectorsLinkSection(TRUE); // create element pCollisionElem = new SECT_CollisionElement(hCollisionElem, this); // update list m_oCollisionList.fn_bAddAnElement(pCollisionElem, FALSE); // next elem hCollisionElem = SECT_fn_hGetNextCollisionNodeInCollisionList(hCollisionElem); } // activity hActivityElem = SECT_fn_hGetFirstActivityNodeInActivityList(hSupObj); while (hActivityElem) { // there is at least an element => section exists ! SetExistingSectorsLinkSection(TRUE); // create element pActivityElem = new SECT_ActivityElement(hActivityElem, this); // update list m_oActivityList.fn_bAddAnElement(pActivityElem, FALSE); // next elem hActivityElem = SECT_fn_hGetNextActivityNodeInActivityList(hActivityElem); } // sound hSoundElem = SECT_fn_hGetFirstSoundNodeInSoundList(hSupObj); while (hSoundElem) { // there is at least an element => section exists ! SetExistingSectorsLinkSection(TRUE); // create element pSoundElem = new SECT_SoundElement(hSoundElem, this); // update list m_oSoundList.fn_bAddAnElement(pSoundElem, FALSE); // next elem hSoundElem = SECT_fn_hGetNextSoundNodeInSoundList(hSoundElem); } // sound event hSoundEventElem = SCT_fn_hGetFirstSoundEventNodeInSoundEventList(hSupObj); while (hSoundEventElem) { // there is at least an element => section exists ! SetExistingSectorsLinkSection(TRUE); // create element pSoundEventElem = new SECT_SndEvtEngineElem(hSoundEventElem, this); // update list m_oSoundEventList.fn_bAddAnElement(pSoundEventElem); // next elem hSoundEventElem = SCT_fn_hGetNextSoundEventNodeInSoundEventList(hSoundEventElem); } } /*=========================================================================== * Description: Init environement parameters * Creation date: * Author: Shaitan *--------------------------------------------------------------------------- * Revision date: Author: *=========================================================================*/ //Shaitan Clean Env /* void Sector_Object::fn_vInitEnvironments (void) { SECT_tdxHandleOfElementLstEnvironment hEnvElem; HIE_tdxHandleToSuperObject hSupObj; SECT_EnvElem *pNewEnvElem, *pPrevEnvElem; // only if list is empty if (m_lNbEnvironments > 0) return; // get engine super-object if (!GetSuperObject()) return; hSupObj = (HIE_tdxHandleToSuperObject) GetSuperObject()->GetSuperObjectStruct(); // init env hEnvElem = SECT_fn_hGetFirstEnvironmentListInSector(hSupObj); pPrevEnvElem = NULL; // fill list of environments while (hEnvElem) { // there is at least an element => section exists ! SetExistingEnvAndSurfSection(TRUE); // create element pNewEnvElem = new SECT_EnvElem(hEnvElem, this); // add it to the list m_oEnvironmentList.fn_bAddAnElement(pNewEnvElem, pPrevEnvElem, FALSE); m_lNbEnvironments++; // next elem hEnvElem = SECT_fn_hGetNextEnvironmentListInSector(hEnvElem); pPrevEnvElem = pNewEnvElem; } } */ /*=========================================================================== * Description: Init surface parameters * Creation date: * Author: Shaitan *--------------------------------------------------------------------------- * Revision date: Author: *=========================================================================*/ //Shaitan Clean Env /* void Sector_Object::fn_vInitSurfaces (void) { SCT_tdxHandleOfElementLstSurface hSurfElem; HIE_tdxHandleToSuperObject hSupObj; SECT_SurfElem *pNewSurfElem, *pPrevSurfElem; // only if list is empty if (m_lNbSurfaces > 0) return; // get engine super-object if (!GetSuperObject()) return; hSupObj = (HIE_tdxHandleToSuperObject) GetSuperObject()->GetSuperObjectStruct(); // init surface hSurfElem = SCT_fn_hGetFirstSurfaceListInSector(hSupObj); pPrevSurfElem = NULL; // fill list of surfaces while (hSurfElem) { // there is at least an element => section exists ! SetExistingEnvAndSurfSection(TRUE); // create element pNewSurfElem = new SECT_SurfElem(hSurfElem, this); // add it to the list m_oSurfaceList.fn_bAddAnElement(pNewSurfElem, pPrevSurfElem, FALSE); m_lNbSurfaces++; // next elem hSurfElem = SCT_fn_hGetNextSurfaceListInSector(hSurfElem); pPrevSurfElem = pNewSurfElem; } } */ /*=========================================================================== * Description: init editor border * Creation date: * Author: Shaitan *--------------------------------------------------------------------------- * Revision date: Author: *=========================================================================*/ void Sector_Object::fn_vInitBorder (void) { MTH3D_tdstVector stPoint; CPA_DLLBase *pOGD; CString csName; Box3D *pBorderBox; long lMask; // if necessary, create border if (m_pBorder == NULL) { // init super-object csName = GetSectorInterface()->GetInterface()->GetPrefixedName(GetName() + "_BorderSO"); m_pBorder = GetSectorInterface()->GetInterface()->GetNewSuperObject(E_ss_NoSave, C_Protected, csName); lMask = HIE_fn_lGetSuperObjectDrawMask(m_pBorder->GetStruct()); HIE_fn_vSetSuperObjectDrawMask(m_pBorder->GetStruct(), lMask - GLI_C_lIsNotDrawCollideInformation - GLI_C_lIsNotDrawCollideInformationLight); HIE_fn_SO_vSetFlags(m_pBorder->GetStruct(), HIE_C_Flag_ulNotPickable); HIE_fn_vSetSuperObjectTransparenceLevel(m_pBorder->GetStruct(), 100); // init box 3D pOGD = GetMainWorld()->GetObjectDLLWithName(C_szDLLGeometryName); csName = GetSectorInterface()->GetInterface()->GetPrefixedName(GetName() + "_BorderSO"); pBorderBox = new Box3D(TRUE, pOGD, csName, E_ss_NoSave); m_pBorder->SetObject(pBorderBox); m_pBorder->SetSuperObjectOwner(GetSuperObject()); } else pBorderBox = (Box3D *) m_pBorder->GetObject(); // update border coordinates SECT_fn_vGetMinPointInBorder(GetStruct(), &stPoint); pBorderBox->SetMinPoint(&stPoint); SECT_fn_vGetMaxPointInBorder(GetStruct(), &stPoint); pBorderBox->SetMaxPoint(&stPoint); // if necessary, create section if (!m_pBorderSection) m_pBorderSection = new CPA_SectionObject (GetSectorBorderSection(), fn_szGetLevelsDataPath(), Sector_Object::CallBackSaveSectorBorder, this, TRUE); } /*=========================================================================== * Description: get real Zmax of the sector * Creation date: * Author: Shaitan *--------------------------------------------------------------------------- * Revision date: Author: *=========================================================================*/ MTH_tdxReal Sector_Object::GetZmaxOfSector (void) { return SECT_fn_xGetRealZmax(GetStruct()); } /*=========================================================================== * Description: get Zmax of the border * Creation date: * Author: Shaitan *--------------------------------------------------------------------------- * Revision date: Author: *=========================================================================*/ MTH_tdxReal Sector_Object::GetZmaxOfBorder (void) { return SECT_fn_xGetZmaxOfBorder(GetStruct()); } /*=========================================================================== * Description: update Zmax of the border * Creation date: * Author: Shaitan *--------------------------------------------------------------------------- * Revision date: Author: *=========================================================================*/ void Sector_Object::SetZmaxOfBorder (MTH_tdxReal xZmax) { MTH3D_tdstVector stMaxPoint; Box3D *pBorderBox; // update engine parameter SECT_fn_vSetZmaxOfBorder(GetStruct(), xZmax); // update border if (xZmax > MTH_C_InfinitMinus) { // update engine border SECT_fn_vGetMaxPointInBorder(GetStruct(), &stMaxPoint); stMaxPoint.xZ = xZmax; SECT_fn_vSetMaxPointInBorder(GetStruct(), &stMaxPoint); // update editor border pBorderBox = (Box3D *) m_pBorder->GetObject(); pBorderBox->SetMaxPoint(&stMaxPoint); } // notify for save fn_vNotifyBorderSection((xZmax > MTH_C_InfinitMinus)); } /*=========================================================================== * Description: get min point of border * Creation date: * Author: Shaitan *--------------------------------------------------------------------------- * Revision date: Author: *=========================================================================*/ void Sector_Object::GetMinPointInBorder (MTH3D_tdstVector *p_stMinPoint) { Box3D *pBorderBox; if (m_pBorder) { pBorderBox = (Box3D *) m_pBorder->GetObject(); *p_stMinPoint = pBorderBox->GetMinPoint(); } else { p_stMinPoint->xX = MTH_C_InfinitPlus; p_stMinPoint->xY = MTH_C_InfinitPlus; p_stMinPoint->xZ = MTH_C_InfinitPlus; } } /*=========================================================================== * Description: get max point of border * Creation date: * Author: Shaitan *--------------------------------------------------------------------------- * Revision date: Author: *=========================================================================*/ void Sector_Object::GetMaxPointInBorder (MTH3D_tdstVector *p_stMaxPoint) { Box3D *pBorderBox; if (m_pBorder) { pBorderBox = (Box3D *) m_pBorder->GetObject(); *p_stMaxPoint = pBorderBox->GetMaxPoint(); } else { p_stMaxPoint->xX = MTH_C_InfinitMinus; p_stMaxPoint->xY = MTH_C_InfinitMinus; p_stMaxPoint->xZ = MTH_C_InfinitMinus; } } /*=========================================================================== * Description: get center of border * Creation date: * Author: Shaitan *--------------------------------------------------------------------------- * Revision date: Author: *=========================================================================*/ void Sector_Object::GetCenterInBorder (MTH3D_tdstVector *p_stCenter) { SECT_fn_vGetCenterOfBorder(GetStruct(), p_stCenter); } /*=========================================================================== * Description: get maximal dimension of border * Creation date: * Author: Shaitan *--------------------------------------------------------------------------- * Revision date: Author: *=========================================================================*/ MTH_tdxReal Sector_Object::GetMaxDimension (void) { MTH3D_tdstVector stMin, stMax; MTH_tdxReal xDimension = 0; GetMinPointInBorder(&stMin); GetMaxPointInBorder(&stMax); xDimension = ((stMax.xX - stMin.xX) > xDimension) ? stMax.xX - stMin.xX : xDimension; xDimension = ((stMax.xY - stMin.xY) > xDimension) ? stMax.xY - stMin.xY : xDimension; xDimension = ((stMax.xZ - stMin.xZ) > xDimension) ? stMax.xZ - stMin.xZ : xDimension; return xDimension; } //################################################################################# // FAR CLIPPING //################################################################################# /*=========================================================================== * Description: get Zfar * Creation date: * Author: Shaitan *--------------------------------------------------------------------------- * Revision date: Author: *=========================================================================*/ MTH_tdxReal Sector_Object::GetZfarInSector (void) { return fn_xGetSectorZFar(GetSuperObject()->GetStruct()); } /*=========================================================================== * Description: update Zmax of the border * Creation date: * Author: Shaitan *--------------------------------------------------------------------------- * Revision date: Author: *=========================================================================*/ void Sector_Object::SetZfarInSector (MTH_tdxReal xZfar) { // update engine parameter fn_vSetSectorZFar(GetSuperObject()->GetStruct(), xZfar); m_pVirtualSection->fn_vWriteSection(); } //################################################################################# // VIRTUAL & GOTHROUGH //################################################################################# /*=========================================================================== * Description: check virtual status * Creation date: * Author: Shaitan *--------------------------------------------------------------------------- * Revision date: Author: *=========================================================================*/ BOOL Sector_Object::fn_bIsVirtual (void) { return (GetStruct()->xVirtual); } /*=========================================================================== * Description: update virtual status * Creation date: * Author: Shaitan *--------------------------------------------------------------------------- * Revision date: Author: *=========================================================================*/ void Sector_Object::fn_vSetVirtual (BOOL bVirtual, CPA_SuperObject *pBorder) { if (bVirtual) { // update engine status SECT_fn_vSetOnVirtualSector(GetStruct()); } else { // update engine status SECT_fn_vSetOffVirtualSector(GetStruct()); } // notify for save m_pVirtualSection->fn_vWriteSection(); } //################################################################################# // SECTOR LINKS //################################################################################# /*=========================================================================== * Description: add sector to the corresponding list * Creation date: * Author: Shaitan *--------------------------------------------------------------------------- * Revision date: Author: *=========================================================================*/ BOOL Sector_Object::fn_bAddSectorInList (SECT_ElementBase *pNewElem, tdeTypeList eType) { SECT_ElementBase *pElem; SECT_ListBase *pCurrentList; // corresponding list pCurrentList = GetCurrentList(eType); if (!pCurrentList) return FALSE; // check if element already exist pElem = pCurrentList->GetElementWithSector(pNewElem->GetSector()); if (pElem) return FALSE; if (pNewElem->GetSector() && (pNewElem->GetSector()->GetObject() == this)) return FALSE; // add it to the list pCurrentList->fn_bAddAnElement(pNewElem); // notify change if (g_bCanSave) pNewElem->fn_vWriteSection(); return TRUE; } /*=========================================================================== * Description: remove sector from the corresponding list * Creation date: * Author: Shaitan *--------------------------------------------------------------------------- * Revision date: Author: *=========================================================================*/ BOOL Sector_Object::fn_bRemoveSectorInList (SECT_ElementBase *pOldElem, tdeTypeList eType) { SECT_ElementBase *pElem; SECT_ListBase *pCurrentList; // corresponding list pCurrentList = GetCurrentList(eType); if (!pCurrentList) return FALSE; // check if element already exist pElem = pCurrentList->GetElementWithSector(pOldElem->GetSector()); if (pElem != pOldElem) return FALSE; // remove it from the list pCurrentList->fn_vRemoveAnElement(pOldElem); // notify change if (g_bCanSave) pOldElem->fn_vWriteSection(); return TRUE; } /*=========================================================================== * Description: Get list from type * Creation date: * Author: Shaitan *--------------------------------------------------------------------------- * Revision date: Author: *=========================================================================*/ SECT_ListBase * Sector_Object::GetCurrentList (tdeTypeList eType) { switch (eType) { case E_Graphic: return &m_oGraphicList; case E_Collision: return &m_oCollisionList; case E_Activity: return &m_oActivityList; case E_Sound: return &m_oSoundList; case E_SoundEvent: return &m_oSoundEventList; } return NULL; } /*=========================================================================== * Description: Build new element of corresponding type * Creation date: * Author: Shaitan *--------------------------------------------------------------------------- * Revision date: Author: *=========================================================================*/ SECT_ElementBase * Sector_Object::GetNewElement (tdeTypeList eType, CPA_SuperObject *pSector) { SECT_ElementBase *pElem; SECT_ListBase *pCurrentList; // corresponding list pCurrentList = GetCurrentList(eType); if (!pCurrentList) return NULL; switch (eType) { case E_Graphic: pElem = new SECT_GraphicElement(pSector, this); break; case E_Collision: pElem = new SECT_CollisionElement(pSector, this); break; case E_Activity: pElem = new SECT_ActivityElement(pSector, this); break; case E_Sound: pElem = new SECT_SoundElement(pSector, this); break; case E_SoundEvent: pElem = new SECT_SoundEventElement(pSector, this); break; } return pElem; } /*=========================================================================== * Description: check if sector is linked with all other sectors * Creation date: * Author: Shaitan *--------------------------------------------------------------------------- * Revision date: Author: *=========================================================================*/ BOOL Sector_Object::fn_bHasFullLink (tdeTypeList eType) { CPA_BaseObjectList *pListSectors; SECT_ListBase *pCurrentList; // get list of all sectors pListSectors = GetSectorInterface()->GetBaseObjectList(C_szSectorTypeName); // get list of linked sectors pCurrentList = GetCurrentList(eType); // check elements return (pCurrentList->GetNbElements() == (pListSectors->GetCount() - 1)); } //################################################################################# // ENVIRONMENT ELEMENT //################################################################################# /*=========================================================================== * Description: add an environment element to the lists * Creation date: * Author: Shaitan *--------------------------------------------------------------------------- * Revision date: Author: *=========================================================================*/ //Shaitan Clean Env /* BOOL Sector_Object::fn_bAddEnvironmentElement (SECT_EnvElem *pEnvElem, SECT_SurfElem *pSurfElem) { SECT_SurfElem *pPreviousSurf; SECT_EnvElem *pPreviousEnv; long lNumEnvElem; // get insert position lNumEnvElem = m_oSurfaceList.GetInsertPosition(pSurfElem); // get previous elements pPreviousEnv = GetEnvironment(lNumEnvElem-1); pPreviousSurf = GetSurface(lNumEnvElem-1); // insert new elements m_oEnvironmentList.fn_bAddAnElement(pEnvElem, pPreviousEnv); m_lNbEnvironments++; m_oSurfaceList.fn_bAddAnElement(pSurfElem, pPreviousSurf); m_lNbSurfaces++; // reinit dialog if (GetSuperObject() == GetSectorInterface()->GetEditedSector()) { GetSectorInterface()->GetDialogEnvList()->fn_vInitEnvList(GetSuperObject()); GetSectorInterface()->GetDialogEnvList()->fn_vInitEnvElem(lNumEnvElem); } // notify change if (g_bCanSave) { pEnvElem->fn_vWriteSection(); pSurfElem->fn_vWriteSection(); } return TRUE; } */ /*=========================================================================== * Description: remove given element from the lists * Creation date: * Author: Shaitan *--------------------------------------------------------------------------- * Revision date: Author: *=========================================================================*/ //Shaitan Clean Env /* BOOL Sector_Object::fn_bDelEnvironmentElement (SECT_EnvElem *pEnvElem, SECT_SurfElem *pSurfElem) { POSITION posEnv, posSurf; // check if elements exist in the list posSurf = m_oSurfaceList.Find(pSurfElem, NULL); posEnv = m_oEnvironmentList.Find(pEnvElem, NULL); if ((!posSurf)||(!posEnv)) return FALSE; // notify change if (g_bCanSave) { pEnvElem->fn_vWriteSection(); pSurfElem->fn_vWriteSection(); } // remove element m_oSurfaceList.fn_vRemoveAnElement(pSurfElem); m_lNbSurfaces--; // remove element m_oEnvironmentList.fn_vRemoveAnElement(pEnvElem); m_lNbEnvironments--; // update dialog if (GetSuperObject() == GetSectorInterface()->GetEditedSector()) GetSectorInterface()->GetDialogEnvList()->fn_vInitEnvList(GetSuperObject()); return TRUE; } */ /*=========================================================================== * Description: get environment in list * Creation date: * Author: Shaitan *--------------------------------------------------------------------------- * Revision date: Author: *=========================================================================*/ //Shaitan Clean Env /* SECT_EnvElem * Sector_Object::GetEnvironment (long lNumEnv) { SECT_EnvElem *pEnvElem; POSITION pos; long lCurNum = 0; for (pEnvElem = m_oEnvironmentList.GetHeadElement(pos); pEnvElem; pEnvElem = m_oEnvironmentList.GetNextElement(pos)) { if (lNumEnv == lCurNum++) return pEnvElem; } // element was not found return NULL; } */ /*=========================================================================== * Description: get surface in list * Creation date: * Author: Shaitan *--------------------------------------------------------------------------- * Revision date: Author: *=========================================================================*/ //Shaitan Clean Env /* SECT_SurfElem * Sector_Object::GetSurface (long lNumEnv) { SECT_SurfElem *pSurfElem; POSITION pos; long lCurNum = 0; for (pSurfElem = m_oSurfaceList.GetHeadElement(pos); pSurfElem; pSurfElem = m_oSurfaceList.GetNextElement(pos)) { if (lNumEnv == lCurNum++) return pSurfElem; } // element was not found return NULL; } */ /*=========================================================================== * Description: update given element when surface or height has changed * Creation date: * Author: Shaitan *--------------------------------------------------------------------------- * Revision date: Author: *=========================================================================*/ //Shaitan Clean Env /* long Sector_Object::fn_lUpdateEnvironmentElement (long lNumEnvElem) { SECT_SurfElem *pSurfElem, *pPreviousSurf; SECT_EnvElem *pEnvElem, *pPreviousEnv; long lNewNum; // get corresponding elements in the list pEnvElem = GetEnvironment(lNumEnvElem); pSurfElem = GetSurface(lNumEnvElem); // remove elements from the list m_oSurfaceList.fn_vRemoveAnElement(pSurfElem); m_oEnvironmentList.fn_vRemoveAnElement(pEnvElem); // check new element lNewNum = m_oSurfaceList.GetInsertPosition(pSurfElem); // get previous elements pPreviousEnv = GetEnvironment(lNewNum-1); pPreviousSurf = GetSurface(lNewNum-1); // insert new elements m_oEnvironmentList.fn_bAddAnElement(pEnvElem, pPreviousEnv); m_oSurfaceList.fn_bAddAnElement(pSurfElem, pPreviousSurf); // reinit dialog if (GetSuperObject() == GetSectorInterface()->GetEditedSector()) { GetSectorInterface()->GetDialogEnvList()->fn_vInitEnvList(GetSuperObject()); GetSectorInterface()->GetDialogEnvList()->fn_vInitEnvElem(lNewNum); } // notify change if (g_bCanSave) { pEnvElem->fn_vWriteSection(); pSurfElem->fn_vWriteSection(); } return lNewNum; } */ /*=========================================================================== * Description: apply same environment as given lists * Creation date: * Author: Shaitan *--------------------------------------------------------------------------- * Revision date: Author: *=========================================================================*/ //Shaitan Clean Env /* void Sector_Object::fn_vApplySameEnvironment (CPA_List *pListEnv, CPA_List *pListSrf) { SECT_Environment *pEnv; SECT_SurfElem *pNewSurfElem, *pPrevSurfElem; SECT_EnvElem *pNewEnvElem, *pPrevEnvElem; SECT_Surface *pSurf; POSITION pos; // RAZ sector lists m_oEnvironmentList.fn_vRemoveAllElements(); m_oSurfaceList.fn_vRemoveAllElements(); // copy environment list pPrevEnvElem = NULL; for (pEnv = pListEnv->GetHeadElement(pos); pEnv; pEnv = pListEnv->GetNextElement(pos)) { // build new envelem and add it pNewEnvElem = new SECT_EnvElem(pEnv, this); m_oEnvironmentList.fn_bAddAnElement(pNewEnvElem, pPrevEnvElem); // next element pPrevEnvElem = pNewEnvElem; } if ((g_bCanSave)&&(pPrevEnvElem)) pPrevEnvElem->fn_vWriteSection(); // copy surface list pPrevSurfElem = NULL; for (pSurf = pListSrf->GetHeadElement(pos); pSurf; pSurf = pListSrf->GetNextElement(pos)) { // build new envelem and add it pNewSurfElem = new SECT_SurfElem(pSurf, this); m_oSurfaceList.fn_bAddAnElement(pNewSurfElem, pPrevSurfElem); // next element pPrevSurfElem = pNewSurfElem; } if ((g_bCanSave)&&(pPrevSurfElem)) pPrevSurfElem->fn_vWriteSection(); } */ //################################################################################# // SAVES //################################################################################# /*=========================================================================== * Description: compute sectorlinks subsection name * Creation date: * Author: Shaitan *--------------------------------------------------------------------------- * Revision date: Author: *=========================================================================*/ CString Sector_Object::GetSectorsLinkSection (void) { CString csSectionName; char szSectionName[SCR_CV_ui_Cfg_MaxLenName]; // get corresponding section SCR_fn_v_RdL0_ComputeSectionName(szSectionName, (char *)(LPCSTR)GetReferencedSectionName(), C_szSectorsLinkSubSection, NULL); csSectionName = szSectionName; return csSectionName; } /*=========================================================================== * Description: compute env&srf subsection name * Creation date: * Author: Shaitan *--------------------------------------------------------------------------- * Revision date: Author: *=========================================================================*/ //Shaitan Clean Env /* CString Sector_Object::GetEnvAndSurfSection (void) { CString csSectionName; char szSectionName[SCR_CV_ui_Cfg_MaxLenName]; // get corresponding section SCR_fn_v_RdL0_ComputeSectionName(szSectionName, (char *)(LPCSTR)GetReferencedSectionName(), C_szEnvAndSurfSubSection, NULL); csSectionName = szSectionName; return csSectionName; } */ /*=========================================================================== * Description: callback for modify name * Creation date: * Author: Shaitan *--------------------------------------------------------------------------- * Revision date: Author: *=========================================================================*/ void Sector_Object::CallBackSaveName (SCR_tdst_File_Description *p_stFile, char *szSectionName, void *p_vData, SCR_tde_Ntfy_Action eAction) { Sector_Object *pSector; char szNewSectionName[SCR_CV_ui_Cfg_MaxLenName]; // get sector pSector = (Sector_Object *) p_vData; switch (eAction) { case SCR_EA_Ntfy_ModifySection: // delete previous section name SCR_fn_v_SvL1_ToPrevLine(p_stFile); SCR_fn_v_SvL1_DeleteLine(p_stFile); // save new section name SCR_fn_v_RdL0_ComputeSectionName(szNewSectionName, NULL, C_szSectorTypeName, (char*)(LPCSTR) pSector->GetName()); SCR_M_SvL0_SaveBeginSection(p_stFile, szNewSectionName, SCR_CC_C_Cfg_EOL); SCR_g_ui_SvL0_IndentationLevel--; break; } } /*=========================================================================== * Description: build the name of the border subsection * Creation date: * Author: Shaitan *--------------------------------------------------------------------------- * Revision date: Author: *=========================================================================*/ CString Sector_Object::GetSectorBorderSection (void) { CString csSectionName; char szSectionName[SCR_CV_ui_Cfg_MaxLenName]; // get corresponding section SCR_fn_v_RdL0_ComputeSectionName(szSectionName, (char *)(LPCSTR)GetReferencedSectionName(), C_szSectorBorderSubSection, NULL); csSectionName = szSectionName; return csSectionName; } /*=========================================================================== * Description: notify border subsection * Creation date: * Author: Shaitan *--------------------------------------------------------------------------- * Revision date: Author: *=========================================================================*/ void Sector_Object::fn_vNotifyBorderSection (BOOL bWrite) { if (bWrite) { if (m_pBorderSection->GetCurrentNotification() == SCR_EA_Ntfy_DeleteSection) m_pBorderSection->fn_vRestoreSection(); m_pBorderSection->fn_vWriteSection(); } else m_pBorderSection->fn_vDeleteSection(); } /*=========================================================================== * Description: callback for save * Creation date: * Author: Shaitan *--------------------------------------------------------------------------- * Revision date: Author: *=========================================================================*/ void Sector_Object::CallBackSaveSectorBorder (SCR_tdst_File_Description *p_stFile, char *szSectionName, void *p_vData, SCR_tde_Ntfy_Action eAction) { MTH3D_tdstVector stMinPoint, stMaxPoint; Sector_Object *pSector; char szNewSectionName[SCR_CV_ui_Cfg_MaxLenName]; int iSaveIndentLevel; // get sector pSector = (Sector_Object *) p_vData; switch (eAction) { case SCR_EA_Ntfy_AddSection: case SCR_EA_Ntfy_RebuildSection: // indent level iSaveIndentLevel = SCR_g_ui_SvL0_IndentationLevel; SCR_g_ui_SvL0_IndentationLevel = 1; // save begin section SCR_fn_v_RdL0_ComputeSectionName(szNewSectionName, NULL, C_szSectorBorderSubSection, " "); SCR_M_SvL0_SaveBeginSection(p_stFile, szNewSectionName, SCR_CC_C_Cfg_EOL); // min point pSector->GetMinPointInBorder(&stMinPoint); SCR_M_SvL0_SaveEntry(p_stFile, "MinPointOfBorder", SCR_CC_C_Cfg_NoChar); SCR_fn_v_SvL0_SaveParameters_MP(p_stFile, SCR_EF_SvL0_Scanf, 4, "%0.3f,%0.3f,%0.3f", stMinPoint.xX, stMinPoint.xY, stMinPoint.xZ); // max point pSector->GetMinPointInBorder(&stMaxPoint); SCR_M_SvL0_SaveEntry(p_stFile, "MaxPointOfBorder", SCR_CC_C_Cfg_NoChar); SCR_fn_v_SvL0_SaveParameters_MP(p_stFile, SCR_EF_SvL0_Scanf, 4, "%0.3f,%0.3f,%0.3f", stMaxPoint.xX, stMaxPoint.xY, stMaxPoint.xZ); // Zmax if (pSector->GetZmaxOfBorder() > MTH_C_InfinitMinus) { SCR_M_SvL0_SaveEntry(p_stFile, "ZmaxOfBorder", SCR_CC_C_Cfg_NoChar); SCR_fn_v_SvL0_SaveParameters_MP(p_stFile, SCR_EF_SvL0_Scanf, 1, "%f", GLI_M_ValueToFloat(pSector->GetZmaxOfBorder())); } // end section SCR_M_SvL0_SaveEndSection (p_stFile, SCR_CC_C_Cfg_EOL); if (eAction == SCR_EA_Ntfy_AddSection) SCR_M_SvL0_SaveBlankLine (p_stFile); // indent level SCR_g_ui_SvL0_IndentationLevel = iSaveIndentLevel; pSector->GetBorderSection()->fn_vSectionSaved(); break; case SCR_EA_Ntfy_DeleteSection: pSector->GetBorderSection()->fn_vSectionDeleted(); break; } } /*=========================================================================== * Description: get camera type * Creation date: * Author: Shaitan *--------------------------------------------------------------------------- * Revision date: Author: *=========================================================================*/ char Sector_Object::GetCameraType (void) { return fn_cGetSectorCameraType(GetSuperObject()->GetStruct()); } /*=========================================================================== * Description: set camera type * Creation date: * Author: Shaitan *--------------------------------------------------------------------------- * Revision date: Author: *=========================================================================*/ void Sector_Object::SetCameraType (char cType) { fn_vSetSectorCameraType(GetSuperObject()->GetStruct(), cType); m_pCameraSection->fn_vWriteSection(); } /*=========================================================================== * Description: get priority * Creation date: * Author: Shaitan *--------------------------------------------------------------------------- * Revision date: Author: *=========================================================================*/ char Sector_Object::GetPriority (void) { return SECT_fn_cGetSectorPriority(GetStruct()); } /*=========================================================================== * Description: set priority * Creation date: * Author: Shaitan *--------------------------------------------------------------------------- * Revision date: Author: *=========================================================================*/ void Sector_Object::SetPriority (char cPriority) { CPA_BaseObjectList *pListSector; SECT_ElementBase *pElement; CPA_BaseObject *pElem; Sector_Object *pSectObj; Position Pos; SECT_fn_vSetSectorPriority(GetStruct(), cPriority); m_pPrioritySection->fn_vWriteSection(); // update position in all lists of all sectors pListSector = GetSectorInterface()->GetBaseObjectList(C_szSectorTypeName); for (pElem = pListSector->GetHeadElement(Pos); pElem; pElem = pListSector->GetNextElement(Pos)) { // get sector pSectObj = (Sector_Object *) pElem; // check if element exists if (pSectObj != this) { // graphic list pElement = pSectObj->GetGraphicList()->GetElementWithSector(GetSuperObject()); if (pElement) { // remove element from list and reinsert it at the right place pSectObj->fn_bRemoveSectorInList(pElement, E_Graphic); pSectObj->fn_bAddSectorInList(pElement, E_Graphic); } // collision list pElement = pSectObj->GetCollisionList()->GetElementWithSector(GetSuperObject()); if (pElement) { // remove element from list and reinsert it at the right place pSectObj->fn_bRemoveSectorInList(pElement, E_Collision); pSectObj->fn_bAddSectorInList(pElement, E_Collision); } // activity list pElement = pSectObj->GetActivityList()->GetElementWithSector(GetSuperObject()); if (pElement) { // remove element from list and reinsert it at the right place pSectObj->fn_bRemoveSectorInList(pElement, E_Activity); pSectObj->fn_bAddSectorInList(pElement, E_Activity); } // sound list pElement = pSectObj->GetSoundList()->GetElementWithSector(GetSuperObject()); if (pElement) { // remove element from list and reinsert it at the right place pSectObj->fn_bRemoveSectorInList(pElement, E_Sound); pSectObj->fn_bAddSectorInList(pElement, E_Sound); } } } }