mirror of
https://github.com/Team-Resurgent/halo.git
synced 2026-04-30 10:48:22 -07:00
commit 89560cfc28a2a32499f47ce2c91469f95af19b61 Author: punpckhdq <121350336+punpckhdq@users.noreply.github.com> Date: Wed Dec 31 19:00:05 2025 +0000 wip5 commit d45c3bc25b9265823ee8b0517e07b66164cbeb6a Author: punpckhdq <121350336+punpckhdq@users.noreply.github.com> Date: Wed Dec 31 18:48:51 2025 +0000 wip4 commit 70e247008a227ba0454e7e45a0f849e3dc0c3fb1 Author: punpckhdq <121350336+punpckhdq@users.noreply.github.com> Date: Wed Dec 31 05:40:55 2025 +0000 wip3 commit f26f7e1117add7e5ef13f7e033185e1bffedeb77 Author: punpckhdq <121350336+punpckhdq@users.noreply.github.com> Date: Wed Dec 31 05:40:50 2025 +0000 Formatting + many includes commit aea053c98d5553354a56ccd889f70c45f622293a Author: punpckhdq <121350336+punpckhdq@users.noreply.github.com> Date: Wed Dec 31 00:20:03 2025 +0000 wip2 commit 74728f5e3a6f2a978d0a5d43383ed4c1931a875c Author: punpckhdq <121350336+punpckhdq@users.noreply.github.com> Date: Tue Dec 30 22:48:12 2025 +0000 game_state WIP
105 lines
2.0 KiB
C
105 lines
2.0 KiB
C
/*
|
|
REFERENCE_LISTS.H
|
|
|
|
file has inline function assertions.
|
|
*/
|
|
|
|
#ifndef __REFERENCE_LISTS_H
|
|
#define __REFERENCE_LISTS_H
|
|
#pragma once
|
|
|
|
/* ---------- headers */
|
|
|
|
#include "game_state.h"
|
|
|
|
/* ---------- constants */
|
|
|
|
/* ---------- macros */
|
|
|
|
/* ---------- structures */
|
|
|
|
struct data_reference
|
|
{
|
|
short identifier;
|
|
unsigned short pad;
|
|
long datum_index;
|
|
long next_reference_index;
|
|
};
|
|
|
|
/* ---------- prototypes/EXAMPLE.C */
|
|
|
|
/* ---------- globals */
|
|
|
|
/* ---------- public code */
|
|
|
|
__inline struct data_array *reference_list_new(
|
|
const char *name,
|
|
short maximum_count)
|
|
{
|
|
char buffer[256];
|
|
|
|
sprintf(buffer, "%s reference", name);
|
|
return game_state_data_new(buffer, maximum_count, sizeof(struct data_reference));
|
|
}
|
|
|
|
__inline long reference_list_get_next_datum_index(
|
|
struct data_array *array,
|
|
long *reference_index)
|
|
{
|
|
long result;
|
|
struct data_reference *reference;
|
|
|
|
if (*reference_index!=NONE)
|
|
{
|
|
reference= (struct data_reference *)datum_get(array, *reference_index);
|
|
*reference_index= reference->next_reference_index;
|
|
result= reference->datum_index;
|
|
}
|
|
else
|
|
{
|
|
result= NONE;
|
|
}
|
|
|
|
return result;
|
|
}
|
|
|
|
__inline void reference_list_add(
|
|
struct data_array *array,
|
|
long *first_reference_index,
|
|
long datum_index)
|
|
{
|
|
long reference_index= datum_new(array);
|
|
|
|
if (reference_index!=NONE)
|
|
{
|
|
struct data_reference *reference= (struct data_reference*)datum_get(array, reference_index);
|
|
reference->datum_index= datum_index;
|
|
reference->next_reference_index= *first_reference_index;
|
|
*first_reference_index= reference_index;
|
|
}
|
|
else
|
|
{
|
|
error(_error_silent, "WARNING: maximum %ss per map (%d) exceeded.", array->name, array->maximum_count);
|
|
}
|
|
|
|
return;
|
|
}
|
|
|
|
__inline void reference_list_delete(
|
|
struct data_array *array,
|
|
long first_reference_index)
|
|
{
|
|
long i;
|
|
struct data_reference *reference;
|
|
|
|
for (i= first_reference_index; i!=NONE; i= reference->next_reference_index)
|
|
{
|
|
reference= (struct data_reference*)datum_get(array, i);
|
|
datum_delete(array, i);
|
|
}
|
|
|
|
return;
|
|
}
|
|
|
|
#endif // __REFERENCE_LISTS_H
|