You
wish that was valid.
...
I do too, really.
Here's what I do, instead:
#define MAX_PORTFORMATS 99
#define MAX_OBJECTS 99
#define REF_PORTFORMAT int
#define REF_OBJECT int
struct portformat
{
int x;
int y;
int state;
}
portformat Master_Portformats[MAX_PORTFORMATS];
int Master_Portformats_Count;
struct Object
{
int x;
int y;
int state;
REF_PORTFORMAT port[7];
int port_count;
}
Object Master_Object[MAX_OBJECTS];
int Master_Object_Count;
Assume that there is code that initializes the Master arrays with their values here.
Now, your references between Object and portformat are integer values that plug into the Master_Portformats array.
Assuming you created the stacks properly, this would print out all of the Portformat in a given Object
void log_my_portraits( REF_OBJECT me ) {
int i;
log( "LOGGING THE PORTRAITS IN OBJECT["+str(me)+"]" );
log( "============================================" );
for( i=0; i<Master_Object[me].port_count; i++ ) {
log( " Port["+str(i)+ "].x: " + str( Master_Portformats[Master_Object[me].port[i]].x ) );
log( " Port["+str(i)+ "].y: " + str( Master_Portformats[Master_Object[me].port[i]].y ) );
log( "Port["+str(i)+ "].state: " + str( Master_Portformats[Master_Object[me].port[i]].state ) );
log( "" );
}
}
I would make accessor functions to make that junk a little more tolerable, like so:
//
// This returns the x value of the nth portrait in Object #obj.
//
int get_PortX_from_Obj( REF_OBJECT obj, int n ) {
//harsh error checking!
if( obj >= Master_Object_Count || obj < 0 ) {
exit( "get_PortX_from_Obj( "+str(obj)+", "+str(n)+" ):: your object was out of bounds." );
} else if( n >= Master_Object[obj].port_count || n < 0 ) {
exit( "get_PortX_from_Obj( "+str(obj)+", "+str(n)+" ):: your portrait index was out of bounds." );
}
return Master_Portformats[ Master_Object[obj].port[n] ].x;
}
I hope that helps and I didn't confuse you. I can elaborate more later if needbe. Also, I haven't checked my code here in v3... so there may be inaccuracies, but that's the general gist.
-Grue