At 06:40 AM 6/11/02 -0700, you wrote:
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

Thanks! That worked. You guys here on the list are a godsend. Thanks to all who replied. You all have given me insight into this.
Keith


Reply via email to