/*recursive*/ void DisposeList(List *L) { if (NULL == *L) { return; } else { DisposeList(&((*L)->next)); } free (*L); *L = NULL; }
int test_DisposeList() { solved=TRUE; DisposeList(&TEMPLIST); if (!solved) { printf("Operace DisposeList() nebyla implementována!\n"); return(FALSE); } print_elements_of_list(TEMPLIST); return(TRUE); }
BOOL _XObjectManager::LoadObjectList( FILE* Fileptr, LPSTR Filename ) { _XMEMORYUSECHECKREADY _XMEMORYUSECHECKSTART assert( Fileptr ); if( !Fileptr ) { _XFatalError( "LoadObjectList(%s) : Invalid file pointer", Filename ); return FALSE; } int objectcount = 0; if( fread( &objectcount, sizeof(int), 1, Fileptr ) < 1 ) { _XFatalError( "LoadObjectList(%s) Read object count", Filename ); return FALSE; } DisposeList(); _LPXObject pobjectarray = NULL; _EXT_Object* pExtObject = NULL; // 생활 이벤트쪽 테스트용으로 쓰기 위해.. // 우선 임시로 이름으로 비교한다. /* if (_stricmp(Filename, "map_noklim.xtg") == 0) { pExtObject = new _EXT_Object[objectcount]; if( fread( pExtObject, sizeof(_EXT_Object)*objectcount, 1, Fileptr ) < 1 ) { _XFatalError( "LoadTerrain(%s) Read object data", Filename ); delete[] pExtObject; return FALSE; } } else */ { pobjectarray = new _XObject[objectcount]; if( !pobjectarray ) { _XFatalError( "LoadObjectList(%s) Allocation object temporary array", Filename ); return FALSE; } if( fread( pobjectarray, sizeof(_XObject)*objectcount, 1, Fileptr ) < 1 ) { _XFatalError( "LoadTerrain(%s) Read object data", Filename ); delete[] pobjectarray; return FALSE; } } m_ObjectCount = objectcount; m_pObjectArray = new _XOctreeObject[ objectcount ]; if( !m_pObjectArray ) { _XFatalError( "LoadObjectList(%s) Allocation object array", Filename ); delete[] pobjectarray; return FALSE; } //memset( m_pObjectArray, 0, sizeof(_XOctreeObject) * objectcount ); _XMeshContainer* model = NULL; for( int i=0; i<objectcount; i++ ) { // 생활 이벤트쪽 때문에 테스트 데이타용으로 쓰기 위해서.. /* if (_stricmp(Filename, "map_noklim.xtg") == 0) { m_pObjectArray[i].m_matWorldPosition = pExtObject[i].m_matWorldPosition; m_pObjectArray[i].m_ObjectIndex = pExtObject[i].m_ObjectIndex; m_pObjectArray[i].m_nEventType = pExtObject[i].m_nEventType; m_pObjectArray[i].m_nEventValue = pExtObject[i].m_nEventValue; } else */ { m_pObjectArray[i].m_matWorldPosition = pobjectarray[i].m_matWorldPosition; m_pObjectArray[i].m_ObjectIndex = pobjectarray[i].m_ObjectIndex; } model = (_XMeshContainer*)g_LodTerrain.m_MeshObjectManager.GetModelContainer(m_pObjectArray[i].m_ObjectIndex); if( model ) { if (!model->m_strName.empty()) { _XMeshObjectManager::smdef_BipedController::iterator it = g_LodTerrain.m_MeshObjectManager.m_smBipedController.find(model->m_strName.c_str()); if (it != g_LodTerrain.m_MeshObjectManager.m_smBipedController.end()) { m_pObjectArray[i].m_pBipedController = (*it).second; _LPXM_MOTION lpMotion = m_pObjectArray[i].m_pBipedController->GetMotion(0); if (lpMotion) { m_pObjectArray[i].m_fAniTime = rand() % static_cast<int>(lpMotion->EndFrame); } } /* // 대소문자를 구별하지 않는 find문을 이용해야 하나 지금 책이 없어 기억이 안 나므로 // 우선 이렇게 체크 한다. 차후 수정하기로 한다. _XMeshObjectManager::smdef_BipedController::iterator it; for (it = g_LodTerrain.m_MeshObjectManager.m_smBipedController.begin(); it != g_LodTerrain.m_MeshObjectManager.m_smBipedController.end(); ++ it) { if (_stricmp(it->first.c_str(), model->m_strName.c_str()) == 0) { m_pObjectArray[i].m_pBipedController = (*it).second; _LPXM_MOTION lpMotion = m_pObjectArray[i].m_pBipedController->GetMotion(0); if (lpMotion) { m_pObjectArray[i].m_fAniTime = rand() % static_cast<int>(lpMotion->EndFrame); } break; } } */ } m_pObjectArray[i].m_Radius = model->m_ObjectRadius; } } delete[] pobjectarray; _XDWINPRINT( "%d Object loaded", objectcount ); _XMEMORYUSECHECKEND( "World object list" ); return TRUE; }
_XObjectManager::~_XObjectManager() { DisposeList(); }