void Graph_Dtor(Graph *inGraph) { //scprintf("->Graph_Dtor %d\n", inGraph->mNode.mID); World *world = inGraph->mNode.mWorld; uint32 numUnits = inGraph->mNumUnits; Unit** graphUnits = inGraph->mUnits; if (inGraph->mNode.mCalcFunc != (NodeCalcFunc)Graph_FirstCalc) { // the above test insures that dtors are not called if ctors have not been called. for (uint32 i = 0; i<numUnits; ++i) { Unit *unit = graphUnits[i]; UnitDtorFunc dtor = unit->mUnitDef->mUnitDtorFunc; if (dtor) (dtor)(unit); } } world->mNumUnits -= numUnits; world->mNumGraphs --; GraphDef* def = GRAPHDEF(inGraph); if (--def->mRefCount <= 0) { if (world->mRealTime) GraphDef_DeleteMsg(world, def); else GraphDef_Free(def); } Node_Dtor(&inGraph->mNode); //scprintf("<-Graph_Dtor\n"); }
void World_FreeAllGraphDefs(World *inWorld) { GrafDefTable* lib = inWorld->hw->mGraphDefLib; int size = lib->TableSize(); for (int i=0; i<size; ++i) { GraphDef *def = lib->AtIndex(i); if (def) GraphDef_Free(def); } lib->MakeEmpty(); }
void DeleteGraphDefMsg::Perform() { GraphDef_Free(mDef); }