> if you want it in english you can make a spell_fun table
>
> {   "spell_acid_blast",       spell_acid_blast   }
>

'ello,

its much more fun with trickery and madness aforethought...

=====>begin file snippet<=====
#define IN_DYNAMICS_C
#include "include.h"
#undef  IN_DYNAMICS_C


struct gsn_type
{
 char *name;
 sh_int *pgsn;
};

struct spell_type
{
 char *name;
 SPELL_FUN *fun;
};

#define GSN(value)  { #value,  &value  },
#define SPELL(spell) { #spell,  spell  },

struct gsn_type gsn_table [] =
{
#include "gsn.h"
 { NULL,   NULL   }
};

struct spell_type spell_table [] =
{
#include "magic.h"
 { NULL, NULL }
};

#undef GSN
#undef SPELL

=====>End file snippet<=====

much more fun way of making said table :)

course it does require that you actually _have_
GSN's and SPELL's for _everything_ which can be done quite
handily with a little perl script that I found on Erwin's site

 -evil grin-

> course if your trying to make these dynamic that doesnt really work
either;)


True, but the following might make it easier...
the below is _very_ conditional on using the above correctly :)
anything that you pass _must_ have a valid entry in the table
or it will get assigned a null by default..

===========Code Follows===============

// used to assign GSN's to skills being read in from a file
sh_int *gsn_assign( char *gsn_name, sh_int value )
{
 int i = 0;
 for ( i = 0; gsn_table[i].name; i++ )
 {
  if ( !str_infix(gsn_table[i].name, gsn_name) )
  {
   *gsn_table[i].pgsn = value;
   return gsn_table[i].pgsn;
  }
 }
 return gsn_table[0].pgsn;
}


// Used to take a GSN and give a name for said to be saved to a file
char *gsn_name( sh_int *pgsn )
{
 int i = 0;
 for ( i = 0; gsn_table[i].name != NULL; i++ )
  if ( gsn_table[i].pgsn == pgsn )
   return gsn_table[i].name;
  
  return gsn_table[0].name;
}


// Returns a pointer to be used in creating a skill table
// args: spell_name
SPELL_FUN *spell_function( char *argument )
{
 int i;
 for ( i = 0; spell_table[i].name; i++ )
 {
  if ( !str_infix(spell_table[i].name, argument) )
   return spell_table[i].fun;
 }
 return spell_table[0].fun;
}


// Returns a name for a passed spell pointer, used to save skills to file
char *spell_fun_name( SPELL_FUN *argument )
{
 int i;
 for ( i = 0; spell_table[i].name; i++ )
 {
  if ( spell_table[i].fun == argument)
   return spell_table[i].name;
 }
 return "spell_null";
}

===============Code Ends===================
 

have fun,

 /-------------------------------------------------------------\
|  Steve Boleware               |  Beginning Coder              |
|  [EMAIL PROTECTED]          |  Student of Life              |
|  ICQ: 11120901                |                               |
 \-------------------------------------------------------------/


Reply via email to