tcledit/libwld: cosmetic naming fixes
This commit is contained in:
parent
58adf727c3
commit
ae89057270
@ -53,28 +53,29 @@
|
||||
|
||||
void wld_add_plane(rect_list_t * newRect, rect_head_t * list)
|
||||
{
|
||||
rect_list_t *nextRect, *prevRect;
|
||||
rect_list_t *next;
|
||||
rect_list_t *prev;
|
||||
|
||||
/* Search the list to find the location to insert the new rectangle. Each
|
||||
* list is maintained in ascending plane order.
|
||||
*/
|
||||
|
||||
for (nextRect = list->head;
|
||||
((nextRect) && (nextRect->d.plane < newRect->d.plane));
|
||||
nextRect = nextRect->flink);
|
||||
for (next = list->head;
|
||||
((next) && (next->d.plane < newRect->d.plane));
|
||||
next = next->flink);
|
||||
|
||||
/* Add the newRect to the spot found in the list. Check if the newRect goes
|
||||
* at the end of the list.
|
||||
*/
|
||||
|
||||
if (!nextRect)
|
||||
if (!next)
|
||||
{
|
||||
/* No rectangle with plane larger than the one to be added was found in
|
||||
* the list. The newRect goes at the end of the list.
|
||||
*/
|
||||
|
||||
prevRect = list->tail;
|
||||
if (!prevRect)
|
||||
prev = list->tail;
|
||||
if (!prev)
|
||||
{
|
||||
/* Special case: The list is empty */
|
||||
|
||||
@ -86,33 +87,33 @@ void wld_add_plane(rect_list_t * newRect, rect_head_t * list)
|
||||
else
|
||||
{
|
||||
newRect->flink = NULL;
|
||||
newRect->blink = prevRect;
|
||||
prevRect->flink = newRect;
|
||||
newRect->blink = prev;
|
||||
prev->flink = newRect;
|
||||
list->tail = newRect;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
/* The newRect goes just before nextRect */
|
||||
/* The newRect goes just before next */
|
||||
|
||||
prevRect = nextRect->blink;
|
||||
if (!prevRect)
|
||||
prev = next->blink;
|
||||
if (!prev)
|
||||
{
|
||||
/* Special case: Insert at the head of the list */
|
||||
|
||||
newRect->flink = nextRect;
|
||||
newRect->flink = next;
|
||||
newRect->blink = NULL;
|
||||
nextRect->blink = newRect;
|
||||
next->blink = newRect;
|
||||
list->head = newRect;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Insert in the middle of the list */
|
||||
|
||||
newRect->flink = nextRect;
|
||||
newRect->blink = prevRect;
|
||||
prevRect->flink = newRect;
|
||||
nextRect->blink = newRect;
|
||||
newRect->flink = next;
|
||||
newRect->blink = prev;
|
||||
prev->flink = newRect;
|
||||
next->blink = newRect;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -82,6 +82,6 @@ void wld_discard_planes(void)
|
||||
g_yplane_list.head = g_yplane_list.tail = NULL;
|
||||
wld_discard_worldplane(g_zplane_list.head);
|
||||
g_zplane_list.head = g_zplane_list.tail = NULL;
|
||||
wld_discard_worldplane(freeList);
|
||||
freeList = NULL;
|
||||
wld_discard_worldplane(g_free_planes);
|
||||
g_free_planes = NULL;
|
||||
}
|
||||
|
@ -57,7 +57,7 @@ uint8_t wld_initialize_planes(void)
|
||||
g_xplane_list.head = g_xplane_list.tail = NULL;
|
||||
g_yplane_list.head = g_yplane_list.tail = NULL;
|
||||
g_zplane_list.head = g_zplane_list.tail = NULL;
|
||||
freeList = NULL;
|
||||
g_free_planes = NULL;
|
||||
|
||||
return PLANE_SUCCESS;
|
||||
}
|
||||
|
@ -51,13 +51,13 @@
|
||||
* This function loads the world data for one plane
|
||||
************************************************************************/
|
||||
|
||||
static uint8_t wld_load_worldplane(FILE * fp, rect_head_t * list,
|
||||
uint8_t numRects)
|
||||
static uint8_t wld_load_worldplane(FILE *fp, rect_head_t *list,
|
||||
uint8_t nrects)
|
||||
{
|
||||
rect_list_t *rect;
|
||||
int i;
|
||||
|
||||
for (i = 0; i < numRects; i++)
|
||||
for (i = 0; i < nrects; i++)
|
||||
{
|
||||
/* Allocate space for the next rectangle */
|
||||
|
||||
@ -72,7 +72,7 @@ static uint8_t wld_load_worldplane(FILE * fp, rect_head_t * list,
|
||||
if (fread((char *)&rect->d, SIZEOF_RECTDATATYPE, 1, fp) != 1)
|
||||
{
|
||||
fprintf(stderr, "ERROR: read of rectangle %d (of %d) failed! ",
|
||||
i, numRects);
|
||||
i, nrects);
|
||||
fprintf(stderr, "feof=%d ferror=%d\n", feof(fp), ferror(fp));
|
||||
return PLANE_DATA_READ_ERROR;
|
||||
}
|
||||
@ -95,23 +95,32 @@ static uint8_t wld_load_worldplane(FILE * fp, rect_head_t * list,
|
||||
* This function loads the world data from the opened file
|
||||
************************************************************************/
|
||||
|
||||
uint8_t wld_load_planes(FILE * fp)
|
||||
uint8_t wld_load_planes(FILE *fp)
|
||||
{
|
||||
plane_file_header_t fileHeader;
|
||||
plane_file_header_t fileheader;
|
||||
uint8_t result;
|
||||
|
||||
/* Read the plane file header */
|
||||
|
||||
if (fread((char *)&fileHeader, SIZEOF_PLANEFILEHEADERTYPE, 1, fp) != 1)
|
||||
return PLANE_HEADER_READ_ERROR;
|
||||
if (fread((char *)&fileheader, SIZEOF_PLANEFILEHEADERTYPE, 1, fp) != 1)
|
||||
{
|
||||
return PLANE_HEADER_READ_ERROR;
|
||||
}
|
||||
|
||||
/* Then load each grid, performing run length (rle) decoding */
|
||||
|
||||
result = wld_load_worldplane(fp, &g_xplane_list, fileHeader.num_xrects);
|
||||
result = wld_load_worldplane(fp, &g_xplane_list, fileheader.num_xrects);
|
||||
if (!result)
|
||||
result = wld_load_worldplane(fp, &g_yplane_list, fileHeader.num_yrects);
|
||||
{
|
||||
result = wld_load_worldplane(fp, &g_yplane_list,
|
||||
fileheader.num_yrects);
|
||||
}
|
||||
|
||||
if (!result)
|
||||
result = wld_load_worldplane(fp, &g_zplane_list, fileHeader.num_zrects);
|
||||
{
|
||||
result = wld_load_worldplane(fp, &g_zplane_list,
|
||||
fileheader.num_zrects);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
@ -58,18 +58,18 @@ rect_list_t *wld_new_plane(void)
|
||||
|
||||
/* Try to get the new structure from the free list */
|
||||
|
||||
rect = freeList;
|
||||
rect = g_free_planes;
|
||||
if (rect)
|
||||
{
|
||||
/* Got get... remove it from the freeList; */
|
||||
/* Got get... remove it from the g_free_planes; */
|
||||
|
||||
freeList = rect->flink;
|
||||
g_free_planes = rect->flink;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Nothing on the free list. Allocate a new one */
|
||||
|
||||
rect = (rect_list_t *) wld_malloc(sizeof(rect_list_t));
|
||||
rect = (rect_list_t *)wld_malloc(sizeof(rect_list_t));
|
||||
}
|
||||
|
||||
return rect;
|
||||
|
@ -53,7 +53,7 @@
|
||||
rect_head_t g_xplane_list; /* list of X=plane rectangles */
|
||||
rect_head_t g_yplane_list; /* list of Y=plane rectangles */
|
||||
rect_head_t g_zplane_list; /* list of Z=plane rectangles */
|
||||
rect_list_t *freeList;
|
||||
rect_list_t *g_free_planes;
|
||||
|
||||
/*************************************************************************
|
||||
* Private Variables
|
||||
|
@ -171,7 +171,7 @@ extern uint8_t maxTextureCode;
|
||||
|
||||
/* "Deallocated" planes are retained in a free list */
|
||||
|
||||
extern rect_list_t *freeList;
|
||||
extern rect_list_t *g_free_planes;
|
||||
|
||||
/*************************************************************************
|
||||
* Public Function Prototypes
|
||||
|
@ -79,6 +79,6 @@ void wld_remove_plane(rect_list_t * rect, rect_head_t * list)
|
||||
|
||||
/* Then put the rect on the free list */
|
||||
|
||||
rect->flink = freeList;
|
||||
freeList = rect;
|
||||
rect->flink = g_free_planes;
|
||||
g_free_planes = rect;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user