Keith,
Assuming that you magic.h file contains only lines like
DECLARE_SPELL_FUN( spell_fireball);
This might work for you, just remember when ever you add a new line to
magic.h be sure to recompile the file where ever you put this.
char *spell_name( SPELL_FUN *spell )
{
#undef DECLARE_SPELL_FUN
#define DECLARE_SPELL_FUN(spell1) \
if ( spell == spell1 ) return #spell1;
#include "magic.h"
#undef DECLARE_SPELL_FUN
return "reserved";
}
SPELL_FUN *spell_function( char *name )
{
#define DECLARE_SPELL_FUN(spell1) \
if ( !str_cmp( name, #spell1 )) return spell1;
#include "magic.h"
#undef DECLARE_SPELL_FUN
#define DECLARE_SPELL_FUN( fun ) SPELL_FUN fun
return spell_notfound;
}
/* To save it */
fprintf(fp, "spell_fun %s\n",spell_name(skill_table[i].spell_fun));
to read it simply call spell_function and pass the spell_name string to
it
spell_fun = spell_name(fread_word(fp)); /* or something */
kermit
-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Keith
Mervine
Sent: Tuesday, June 11, 2002 4:43 AM
To: Josh
Cc: Rom
Subject: Re: Writing spell_fun to a file that can be read back in....
Unfortunatly that is what I'm trying to do. I need to take the entry
from
the const.c file and convert it to a text file that can be modded via
olc.
Everything except the pointers converts nicely.
I have no idea on how to make it translate into what it actually is,
which
is, for example, &spell_acid_blast.
All I need it to do is save it so it actually says &spell_acid_blast
rather than it looking like 08x325234 when I print the pointer.
Is there a simple way of doing this? Keep in mind the process will
become a dynamic file.
Many thanks to those who have responded, the advice is appreciated.
Keith