Beispiel #1
0
//=====================================================================================
//	Vis_WorldShutdown
//=====================================================================================
void Vis_WorldShutdown(geWorld *World)
{
	World_BSP	*BSP;
	
	assert(World  != NULL);

	if (!World->CurrentBSP)
		return;

	BSP = World->CurrentBSP;
	
	if (BSP->NodeVisFrame)
		geRam_Free(BSP->NodeVisFrame);
	if (BSP->ClusterVisFrame)
		geRam_Free(BSP->ClusterVisFrame);
	if (BSP->AreaVisFrame)
		geRam_Free(BSP->AreaVisFrame);
	if (BSP->NodeParents)
		geRam_Free(BSP->NodeParents);

	BSP->NodeVisFrame = NULL;
	BSP->ClusterVisFrame = NULL;
	BSP->AreaVisFrame = NULL;
	BSP->NodeParents = NULL;
}
// Free all memory allcated by project structure.
void AProject_Destroy (AProject **ppProject)
{
	AProject *pProject;

	assert (ppProject != NULL);
	pProject = *ppProject;
	assert (pProject != NULL);

	while (pProject->Materials.Count > 0)
	{
		AProject_RemoveMaterial (pProject, pProject->Materials.Count-1);
	}

	while (pProject->Motions.Count > 0)
	{
		AProject_RemoveMotion (pProject, pProject->Motions.Count-1);
	}

	if (pProject->Output.Filename != NULL)	geRam_Free (pProject->Output.Filename);
	if (pProject->Paths.Materials != NULL)	geRam_Free (pProject->Paths.Materials);
	if (pProject->Paths.TempFiles != NULL)	geRam_Free (pProject->Paths.TempFiles);
	if (pProject->Body.Filename != NULL)	geRam_Free (pProject->Body.Filename);

	if (pProject->Materials.Items != NULL)	Array_Destroy (&pProject->Materials.Items);
	if (pProject->Motions.Items != NULL)	Array_Destroy (&pProject->Motions.Items);

	geRam_Free (*ppProject);
}
Beispiel #3
0
void DirTree_DestroyFinder(DirTree_Finder *Finder)
{
	assert(Finder);
	assert(Finder->MatchName);
	assert(Finder->MatchExt);

	geRam_Free(Finder->MatchName);
	geRam_Free(Finder->MatchExt);
	geRam_Free(Finder);
}
//=====================================================================================
//	CreateAreas
//=====================================================================================
geBoolean CreateAreas(GBSP_Node *RootNode)
{
	GBSP_Model	*pModel;
	int32		m;

	GHook.Printf(" --- Create Area Leafs --- \n");

	// Clear all model area info
	for (pModel = BSPModels+1, m=1; m < NumBSPModels; m++, pModel++)	// Skip world model
	{
		pModel->Areas[0] = pModel->Areas[1] = 0;
		pModel->IsAreaPortal = GE_FALSE;
	}

	if (GFXAreas)
		geRam_Free(GFXAreas);
	if (GFXAreaPortals)
		geRam_Free(GFXAreaPortals);

	GFXAreas = GE_RAM_ALLOCATE_ARRAY(GFX_Area, MAX_AREAS);

	if (!GFXAreas)
		return GE_FALSE;

	GFXAreaPortals = GE_RAM_ALLOCATE_ARRAY(GFX_AreaPortal, MAX_AREA_PORTALS);

	if (!GFXAreaPortals)
		return GE_FALSE;
	
	NumGFXAreas = 1;			// 0 is invalid 
	NumGFXAreaPortals = 0;

	if (!CreateAreas_r(RootNode))
	{
		GHook.Error("Could not create model areas.\n");
		return GE_FALSE;
	}

	if (!FinishAreaPortals_r(RootNode))
	{
		GHook.Error("CreateAreas: FinishAreaPortals_r failed.\n");
		return GE_FALSE;
	}

	if (!FinishAreas())
	{
		GHook.Error("Could not finalize model areas.\n");
		return GE_FALSE;
	}

	//GHook.Printf("Num Areas            : %5i\n", NumGFXAreas-1);

	return GE_TRUE;
}
Beispiel #5
0
void	DirTree_Destroy(DirTree *Tree)
{
	assert(Tree);
	assert(Tree->Name);

	if	(Tree->Children)
		DirTree_Destroy(Tree->Children);

	if	(Tree->Siblings)
		DirTree_Destroy(Tree->Siblings);

	geRam_Free(Tree->Name);
	geRam_Free(Tree);
}
Beispiel #6
0
//=======================================================================================
//	FreeFileVisData
//=======================================================================================
void FreeFileVisData(void)
{
	if (GFXVisData)
		geRam_Free(GFXVisData);
	GFXVisData = NULL;
	NumGFXVisData = 0;
}
Beispiel #7
0
    // reallocate a block...
    // This acts like the standard realloc
GENESISAPI     void *geRam_Realloc
        (
          void *ptr,
          uint32 newsize
        )
    {
        char *p;
        char * NewPtr;

        if (ptr == NULL)
        {
            return geRam_Allocate (newsize);
        }

        // if newsize is NULL, then it's a free and return NULL
        if (newsize == 0)
        {
            geRam_Free (ptr);
            return NULL;
        }

        p = ptr;
        do
        {
            NewPtr = (char *)realloc (p, newsize);
        } while ((NewPtr == NULL) && (geRam_DoCriticalCallback ()));

        return NewPtr;
    }
Beispiel #8
0
//=====================================================================================
//	geCamera_Destroy
//=====================================================================================
GENESISAPI void GENESISCC geCamera_Destroy(geCamera **pCamera)
{
	assert( pCamera  != NULL );
	assert( *pCamera != NULL );
	geRam_Free(*pCamera);
	*pCamera = NULL;
}
Beispiel #9
0
void Log_Close(LogType **log)
{
	assert(log);
	assert(*log);
	geRam_Free(*log);
	*log=NULL;
}
//=====================================================================================
//	FinalizeFace
//=====================================================================================
geBoolean FinalizeFace(GBSP_Face *Face, int32 Base)
{
	int32	i;

	TotalIndexVerts += NumTempIndexVerts;

	if (NumTempIndexVerts == Face->NumIndexVerts)
		return GE_TRUE;

	if (TexInfo[Face->TexInfo].Flags & TEXINFO_MIRROR)
		return GE_TRUE;

	if (TexInfo[Face->TexInfo].Flags & TEXINFO_SKY)
		return GE_TRUE;

	if (Face->IndexVerts)
		geRam_Free(Face->IndexVerts);

	Face->IndexVerts = GE_RAM_ALLOCATE_ARRAY(int32,NumTempIndexVerts);
		
	for (i=0; i< NumTempIndexVerts; i++)
		Face->IndexVerts[i] = TempIndexVerts[(i+Base)%NumTempIndexVerts];

	Face->NumIndexVerts = NumTempIndexVerts;

	NumFixedFaces++;

	return GE_TRUE;
}
Beispiel #11
0
//=====================================================================================
//	geSound_SystemCreate
//=====================================================================================
GENESISAPI	geSound_System *geSound_CreateSoundSystem(HWND hWnd)
{
	geSound_System		*SoundSystem;

	SoundSystem = GE_RAM_ALLOCATE_STRUCT(geSound_System);

	if (!SoundSystem)
	{
		geErrorLog_Add(GE_ERR_OUT_OF_MEMORY, NULL);
		return NULL;
	}

	memset(SoundSystem, 0, sizeof(geSound_System));
	
	// Initialize the sound system
	SoundSystem->SoundM = CreateSoundManager(hWnd);

	if (!SoundSystem->SoundM)
	{
		geRam_Free(SoundSystem);
		geErrorLog_Add(GE_ERR_CREATE_SOUND_MANAGER_FAILED, NULL);
		return NULL;
	}
	SoundSystem->GlobalVolume = 1.0f;

	return SoundSystem;
}
Beispiel #12
0
void log_close(log_type **log)
{
	assert(log);
	assert(*log);
	geRam_Free(*log);
	*log=NULL;
}
/* ------------------------------------------------------------------------------------ */
void Particles_Destroy(Procedural *Proc)
{
	if(!Proc)
		return;

	if(Proc->Bitmap)
		geBitmap_Destroy(&(Proc->Bitmap)); // we did creatref

	if(Proc->Particles)
		geRam_Free(Proc->Particles);

	if(Proc->Sources)
		geRam_Free(Proc->Sources);

	geRam_Free(Proc);
}
Beispiel #14
0
static	BOOL DupChannel( SoundManager *sm, Channel* channel, Channel** dupChannelPtr )
{
	Channel* dupChannel;
	HRESULT Error;

	*dupChannelPtr = NULL;
//	dupChannel =  malloc( sizeof(Channel ) );
	dupChannel =  geRam_Allocate( sizeof(Channel ) );
	if( dupChannel == NULL )
	{
		geErrorLog_Add(GE_ERR_OUT_OF_MEMORY, NULL );
		return FALSE;
	}
	Error = IDirectSound_DuplicateSoundBuffer( lpDirectSound, channel->buffer, &dupChannel->buffer );
	if( Error != DS_OK )
	{
		geRam_Free(dupChannel);
//		free( dupChannel );
		dupChannel = ReloadData( channel->Data );
		if( dupChannel == NULL )
		{
			geErrorLog_Add(GE_ERR_DS_ERROR, NULL);
			return FALSE;
		}
	}
	dupChannel->ID =  sm->smNextChannelID++;
	dupChannel->next = NULL;
	dupChannel->nextDup = channel->nextDup;
	dupChannel->cfg = channel->cfg;
//	dupChannel->name = NULL;
	dupChannel->Data = channel->Data;
	channel->nextDup = dupChannel;
	*dupChannelPtr = dupChannel;
	return( TRUE );
}
Beispiel #15
0
static	void ClearDupBuffers( Channel* channel )
{
	Channel* dupChannel, *prevChannel;

	if( channel == NULL)
		return;

	dupChannel = channel->nextDup;
	prevChannel = channel;
	while( dupChannel )
	{
		if( !ChannelPlaying( dupChannel ) )
		{
			prevChannel->nextDup = dupChannel->nextDup;
			IDirectSound_Release(dupChannel->buffer);
//			free( dupChannel );
			geRam_Free(dupChannel);
			dupChannel = prevChannel->nextDup;
		}
		else
		{
			prevChannel = dupChannel;
			dupChannel = dupChannel->nextDup;
		}
	}
}
Beispiel #16
0
static	BOOL FreeChannel(SoundManager *sm, Channel* channel)
{
	int Error;
	Channel*prevChannel = NULL, *curChannel;
	if	( channel )
	{
		StopDupBuffers( channel );
		ClearDupBuffers( channel );
		Error = IDirectSoundBuffer_Stop(channel->buffer);
		if (Error != DS_OK)
		{
			geErrorLog_Add(GE_ERR_DS_ERROR, NULL);
			return FALSE;
		}
		Error = IDirectSound_Release(channel->buffer);
		if (Error != DS_OK)
		{
			geErrorLog_Add(GE_ERR_DS_ERROR, NULL);
			return FALSE;
		}
//		if( channel->name )
//			geRam_Free(channel->name);
//			free( channel->name );

		if( channel->Data )
			geRam_Free(channel->Data);

		curChannel = sm->smChannels;
		while( curChannel && curChannel != channel )
		{
			prevChannel = curChannel;
			curChannel = curChannel->next;
		}
		if( curChannel )
		{
			if( prevChannel )
				prevChannel->next = curChannel->next;
			else
				sm->smChannels = curChannel->next;
			geRam_Free(curChannel);
//			free( curChannel );
		}
	}

	return TRUE;
}
/* ------------------------------------------------------------------------------------ */
static void DestroyParticle(Particle_System *ps, Particle *p)
{
	if(p->ptclPoly)
		geWorld_RemovePoly(ps->psWorld, p->ptclPoly);

	geRam_Free(p);

}
Beispiel #18
0
DirTree_Finder * DirTree_CreateFinder(DirTree *Tree, const char *Path)
{
	DirTree_Finder *	Finder;
	DirTree *			SubTree;
	char				Directory[_MAX_PATH];
	char				Name[_MAX_FNAME];
	char				Ext[_MAX_EXT];

	assert(Tree);
	assert(Path);

	_splitpath(Path, NULL, Directory, Name, Ext);

	SubTree = DirTree_FindExact(Tree, Directory);
	if	(!SubTree)
		return NULL;

	Finder = geRam_Allocate(sizeof(*Finder));
	if	(!Finder)
		return Finder;

	Finder->MatchName = DuplicateString(Name);
	if	(!Finder->MatchName)
	{
		geRam_Free(Finder);
		return NULL;
	}

	// The RTL leaves the '.' on there.  That won't do.
	if	(*Ext == '.')
		Finder->MatchExt = DuplicateString(&Ext[1]);
	else
		Finder->MatchExt = DuplicateString(&Ext[0]);

	if	(!Finder->MatchExt)
	{
		geRam_Free(Finder->MatchName);
		geRam_Free(Finder);
		return NULL;
	}

	Finder->Current = SubTree->Children;

	return Finder;
}
Beispiel #19
0
static void TPack_ShutdownAll
	(
	  HWND hwnd,
	  TPack_WindowData *pData
	)
{
	DragAcceptFiles (hwnd, FALSE);

	if (pData != NULL)
	{
		if	(pData->Bitmaps)
			geRam_Free(pData->Bitmaps);

		geRam_Free (pData);
	}

	SetWindowLong (hwnd, GWL_USERDATA, (LPARAM)NULL);
}
Beispiel #20
0
DirTree * DirTree_AddFile(DirTree *Tree, const char *Path, geBoolean IsDirectory)
{
	DirTree *		NewEntry;
	const char *	LeftOvers;

	assert(Tree);
	assert(Path);
	assert(IsDirectory == GE_TRUE || IsDirectory == GE_FALSE);

	assert(strlen(Path) > 0);

	if	(PathHasDir(Path))
	{
		Tree = DirTree_FindPartial(Tree, Path, &LeftOvers);
		if	(!Tree)
			return NULL;
	
		if	(PathHasDir(LeftOvers))
			return NULL;
	
		Path = LeftOvers;
	}

	NewEntry = geRam_Allocate(sizeof(*NewEntry));
	if	(!NewEntry)
		return NULL;

	memset(NewEntry, 0, sizeof(*NewEntry));
	NewEntry->Name = DuplicateString(Path);
	if	(!NewEntry->Name)
	{
		geRam_Free(NewEntry->Name);
		geRam_Free(NewEntry);
		return NULL;
	}

	NewEntry->Siblings = Tree->Children;
						 Tree->Children = NewEntry;

	if	(IsDirectory == GE_TRUE)
		NewEntry->AttributeFlags |= GE_VFILE_ATTRIB_DIRECTORY;

	return NewEntry;
}
Beispiel #21
0
//=====================================================================================
//	geSound_SystemFree
//=====================================================================================
GENESISAPI	void geSound_DestroySoundSystem(geSound_System *Sound)
{
	assert(Sound != NULL);

	// Shutdown the sound system
	DestroySoundManager(Sound->SoundM);

	Sound->SoundM = NULL;

	geRam_Free(Sound);
}
Beispiel #22
0
GENESISAPI geBoolean GENESISCC gePhysicsJoint_Destroy(gePhysicsJoint** ppPhysjnt)
{
	assert(ppPhysjnt != NULL);
	assert(*ppPhysjnt != NULL);

	geRam_Free(*ppPhysjnt);

	*ppPhysjnt = NULL;

	return GE_TRUE;
}
Beispiel #23
0
static	void	GENESISCC FSDos_Close(void *Handle)
{
	DosFile *	File;
	
	File = Handle;
	
	CHECK_HANDLE(File);

	if	(File->IsDirectory == GE_FALSE)
	{
		assert(File->FileHandle != INVALID_HANDLE_VALUE);

		CloseHandle(File->FileHandle);
	}
	
	assert(File->FullPath);
	File->Signature = 0;
	geRam_Free(File->FullPath);
	geRam_Free(File);
}
void Group_SetGroupName (Group *g, const char *pName)
{
	assert (g != NULL);
	assert (pName != NULL);

	if (g->GroupName != NULL)
	{
		geRam_Free (g->GroupName);
	}
	g->GroupName = Util_Strdup (pName);
}
CWadFile::DestroyBitmapArray ()
{
	if( mBitmaps != NULL )
	{
		for (; mBitmapCount > 0; --mBitmapCount)
		{
			WadFileEntry_Free (&mBitmaps[mBitmapCount-1]);
		}
		geRam_Free (mBitmaps);
	}
}
/* ------------------------------------------------------------------------------------ */
static void ActorDestroyParticle(ActorParticle_System *ps, ActorParticle *p)
{
	if(p->Actor)
	{
		CCD->ActorManager()->RemoveActor(p->Actor);
		geActor_Destroy(&p->Actor);
		p->Actor = NULL;
	}

	geRam_Free(p);
}
void Group_Destroy
	(
	  Group **ppGroup
	)
// Sets all brushes and entities GroupId fields to 0,
// and deallocates the list structure
{
	Group *pGroup;

	assert (ppGroup != NULL);
	assert (*ppGroup != NULL);

	pGroup = *ppGroup;

	if (pGroup->GroupName != NULL)
	{
		geRam_Free (pGroup->GroupName);
	}

	geRam_Free (*ppGroup);
	*ppGroup = NULL;
}
Beispiel #28
0
//=====================================================================================
//	geWorld_RemovePoly
//=====================================================================================
GENESISAPI void geWorld_RemovePoly(geWorld *World, gePoly *Poly)
{
	assert(World != NULL);
	assert(Poly != NULL);
	assert(geWorld_PolyIsValid(Poly));

	// Remove the poly from the leaf that it is in (it must be in one. or it would not have been added to the world)
	geWorld_UnLinkPolyFromLeaf(Poly);

	World->ActiveUserPolys--;

	geRam_Free(Poly);
}
void FmtActor_OptionsDestroy(FmtActor_Options** ppOptions)
{
    FmtActor_Options* p;

    assert(ppOptions != NULL);
    assert(*ppOptions != NULL);

    p = *ppOptions;

    geRam_Free(*ppOptions);

    *ppOptions = NULL;
}
Beispiel #30
0
static	BOOL FreeAllChannels(SoundManager *sm)
{
	int Error;
	
	Channel* channel, *nextChannel;

	channel = sm->smChannels;
	while( channel )
	{
		nextChannel = channel->next;
		StopDupBuffers( channel );
		ClearDupBuffers( channel );
		Error = IDirectSoundBuffer_Stop(channel->buffer);
		if (Error != DS_OK)
		{
			geErrorLog_Add(GE_ERR_DS_ERROR, NULL);
			return FALSE;
		}
		Error = IDirectSound_Release(channel->buffer);
		if (Error != DS_OK)
		{
			geErrorLog_Add(GE_ERR_DS_ERROR, NULL);
			return FALSE;
		}
		
//		if( channel->name )
//			geRam_Free(channel->name);
//			free( channel->name );
		if	(channel->Data)
			geRam_Free(channel->Data);
		geRam_Free(channel);
//		free( channel );
		channel = nextChannel;
	}
	sm->smChannels = NULL;
	sm->smChannelCount = 0;

	return TRUE;
}