I'd completely forgotten about unions. Unless I'm missing something, which is possible, it wouldn't be a problem...
Here's how the structs presently look:
Code:
typedef struct sGFX_ENTRY
{
int n;
char* name;
char* filename;
struct sGFX_ENTRY* next;
struct sGFX_ENTRY* prev;
} GFX_ENTRY;
enum {sU,sD,sL,sR};
typedef struct sTILEDEF
{
char *gfxname;
char *name;
char *message; // message to display when moving at tile
int prob; // probability of tile appearing after conclusive scan
short int pain; // degree of damage caused: 0-5
short int spawntile; // tile number to spawn
short int spawndir[4]; // size of tilespawn area: up, down, left, right
short int block; // 0 - allow passage, non-0 - block passage
short int cost; // base price to remove this tile
short int wear; // base wear on digging instruments (spade, pickaxe)
struct sTILEDEF* next;
struct sTILEDEF* prev;
} TILEDEF;
typedef struct sSPRITEDEF
{
int nframes;
char **gfxname;
char *name;
struct sSPRITEDEF* next;
struct sSPRITEDEF* prev;
} SPRITEDEF;
I assume I can can drop next, prev and name from each of the structs and do something inelegant like this:
Code:
typedef struct sLIST
{
union
{
GFX_ENTRY* gfx_entry;
TILEDEF* tiledef;
SPRITEDEF* spritedef;
}
char *name;
struct sLIST* next;
struct sLIST* prev;
} LIST;
I'm not sure if that's what you were suggesting. It appears to make things even more complicated, unless there's a simpler way of managing that union than I'm aware.
As a backup plan, I can just merge all the data into one generic struct and set the new entry function to take a parameter determining whether it's a GFX, SPRITE or TILE and leave unnecessary variables blank.