mirror of
https://github.com/kevinbentley/Descent3.git
synced 2026-04-05 05:00:06 -04:00
clang-format on everything.
This commit is contained in:
@@ -6,119 +6,106 @@
|
||||
#include "mono.h"
|
||||
#include "mem.h"
|
||||
|
||||
int Num_of_bumpmaps=0;
|
||||
int Num_of_bumpmaps = 0;
|
||||
static ushort Free_bumpmap_list[MAX_BUMPMAPS];
|
||||
|
||||
bms_bumpmap GameBumpmaps[MAX_BUMPMAPS];
|
||||
int Bumpmap_mem_used=0;
|
||||
int Bumpmap_mem_used = 0;
|
||||
|
||||
// Sets all the bumpmaps to unused
|
||||
void bump_InitBumpmaps()
|
||||
{
|
||||
int i;
|
||||
void bump_InitBumpmaps() {
|
||||
int i;
|
||||
|
||||
for (i=0;i<MAX_BUMPMAPS;i++)
|
||||
{
|
||||
GameBumpmaps[i].flags=0;
|
||||
GameBumpmaps[i].data=NULL;
|
||||
GameBumpmaps[i].cache_slot=-1;
|
||||
Free_bumpmap_list[i]=i;
|
||||
}
|
||||
|
||||
atexit (bump_ShutdownBumpmaps);
|
||||
for (i = 0; i < MAX_BUMPMAPS; i++) {
|
||||
GameBumpmaps[i].flags = 0;
|
||||
GameBumpmaps[i].data = NULL;
|
||||
GameBumpmaps[i].cache_slot = -1;
|
||||
Free_bumpmap_list[i] = i;
|
||||
}
|
||||
|
||||
atexit(bump_ShutdownBumpmaps);
|
||||
}
|
||||
void bump_ShutdownBumpmaps (void)
|
||||
{
|
||||
int i;
|
||||
void bump_ShutdownBumpmaps(void) {
|
||||
int i;
|
||||
|
||||
mprintf ((0,"Freeing all bumpmap memory.\n"));
|
||||
mprintf((0, "Freeing all bumpmap memory.\n"));
|
||||
|
||||
for (i=0;i<MAX_BUMPMAPS;i++)
|
||||
{
|
||||
while (GameBumpmaps[i].flags & BUMPF_USED)
|
||||
bump_FreeBumpmap (i);
|
||||
}
|
||||
|
||||
for (i = 0; i < MAX_BUMPMAPS; i++) {
|
||||
while (GameBumpmaps[i].flags & BUMPF_USED)
|
||||
bump_FreeBumpmap(i);
|
||||
}
|
||||
}
|
||||
|
||||
// Allocs a bumpmap of w*h size
|
||||
// Returns bumpmap handle if successful, -1 if otherwise
|
||||
|
||||
int bump_AllocBumpmap (int w,int h)
|
||||
{
|
||||
int n; //,i;
|
||||
int bump_AllocBumpmap(int w, int h) {
|
||||
int n; //,i;
|
||||
|
||||
if (Num_of_bumpmaps==MAX_BUMPMAPS)
|
||||
Int3(); // Ran out of bumpmaps!
|
||||
|
||||
n=Free_bumpmap_list[Num_of_bumpmaps++];
|
||||
ASSERT (!(GameBumpmaps[n].flags & BUMPF_USED));
|
||||
if (Num_of_bumpmaps == MAX_BUMPMAPS)
|
||||
Int3(); // Ran out of bumpmaps!
|
||||
|
||||
// If no go on the malloc, bail out with -1
|
||||
|
||||
memset (&GameBumpmaps[n],0,sizeof(bms_bumpmap));
|
||||
n = Free_bumpmap_list[Num_of_bumpmaps++];
|
||||
ASSERT(!(GameBumpmaps[n].flags & BUMPF_USED));
|
||||
|
||||
GameBumpmaps[n].data=(ushort *)mem_malloc (w*h*2);
|
||||
if (!GameBumpmaps[n].data)
|
||||
{
|
||||
mprintf ((0,"NOT ENOUGHT MEMORY FOR BUMPMAP!\n"));
|
||||
Int3();
|
||||
return BAD_BUMP_INDEX;
|
||||
}
|
||||
|
||||
GameBumpmaps[n].cache_slot=-1;
|
||||
GameBumpmaps[n].flags=BUMPF_USED|BUMPF_CHANGED;
|
||||
GameBumpmaps[n].width=w;
|
||||
GameBumpmaps[n].height=h;
|
||||
// If no go on the malloc, bail out with -1
|
||||
|
||||
Bumpmap_mem_used+=(w*h*2);
|
||||
|
||||
return n;
|
||||
memset(&GameBumpmaps[n], 0, sizeof(bms_bumpmap));
|
||||
|
||||
GameBumpmaps[n].data = (ushort *)mem_malloc(w * h * 2);
|
||||
if (!GameBumpmaps[n].data) {
|
||||
mprintf((0, "NOT ENOUGHT MEMORY FOR BUMPMAP!\n"));
|
||||
Int3();
|
||||
return BAD_BUMP_INDEX;
|
||||
}
|
||||
|
||||
GameBumpmaps[n].cache_slot = -1;
|
||||
GameBumpmaps[n].flags = BUMPF_USED | BUMPF_CHANGED;
|
||||
GameBumpmaps[n].width = w;
|
||||
GameBumpmaps[n].height = h;
|
||||
|
||||
Bumpmap_mem_used += (w * h * 2);
|
||||
|
||||
return n;
|
||||
}
|
||||
|
||||
// Given a handle, frees the bumpmap memory and flags this bumpmap as unused
|
||||
void bump_FreeBumpmap (int handle)
|
||||
{
|
||||
ASSERT (GameBumpmaps[handle].flags & BUMPF_USED);
|
||||
void bump_FreeBumpmap(int handle) {
|
||||
ASSERT(GameBumpmaps[handle].flags & BUMPF_USED);
|
||||
|
||||
if (GameBumpmaps[handle].data!=NULL)
|
||||
mem_free (GameBumpmaps[handle].data);
|
||||
if (GameBumpmaps[handle].data != NULL)
|
||||
mem_free(GameBumpmaps[handle].data);
|
||||
|
||||
Bumpmap_mem_used-=(GameBumpmaps[handle].width*GameBumpmaps[handle].height*2);
|
||||
|
||||
GameBumpmaps[handle].data=NULL;
|
||||
GameBumpmaps[handle].flags &=~BUMPF_USED;
|
||||
|
||||
Free_bumpmap_list[--Num_of_bumpmaps]=handle;
|
||||
Bumpmap_mem_used -= (GameBumpmaps[handle].width * GameBumpmaps[handle].height * 2);
|
||||
|
||||
GameBumpmaps[handle].data = NULL;
|
||||
GameBumpmaps[handle].flags &= ~BUMPF_USED;
|
||||
|
||||
Free_bumpmap_list[--Num_of_bumpmaps] = handle;
|
||||
}
|
||||
|
||||
// returns a bumpmaps data else NULL if something is wrong
|
||||
ushort *bump_data (int handle)
|
||||
{
|
||||
ushort *d;
|
||||
ushort *bump_data(int handle) {
|
||||
ushort *d;
|
||||
|
||||
if (!(GameBumpmaps[handle].flags & BUMPF_USED))
|
||||
{
|
||||
Int3();
|
||||
return NULL;
|
||||
}
|
||||
|
||||
d=GameBumpmaps[handle].data;
|
||||
if (!(GameBumpmaps[handle].flags & BUMPF_USED)) {
|
||||
Int3();
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return (d);
|
||||
d = GameBumpmaps[handle].data;
|
||||
|
||||
return (d);
|
||||
}
|
||||
|
||||
// returns width of bumpmap
|
||||
ubyte bump_w (int handle)
|
||||
{
|
||||
ASSERT (GameBumpmaps[handle].flags & BUMPF_USED);
|
||||
return GameBumpmaps[handle].width;
|
||||
ubyte bump_w(int handle) {
|
||||
ASSERT(GameBumpmaps[handle].flags & BUMPF_USED);
|
||||
return GameBumpmaps[handle].width;
|
||||
}
|
||||
|
||||
// returns height of bumpmap
|
||||
ubyte bump_h (int handle)
|
||||
{
|
||||
ASSERT (GameBumpmaps[handle].flags & BUMPF_USED);
|
||||
return GameBumpmaps[handle].height;
|
||||
ubyte bump_h(int handle) {
|
||||
ASSERT(GameBumpmaps[handle].flags & BUMPF_USED);
|
||||
return GameBumpmaps[handle].height;
|
||||
}
|
||||
Reference in New Issue
Block a user