skill: bash & VERSIONING

From: Katzlberger Thomas (cat@garfield.Vanderbilt.Edu)
Date: 04/27/95


Hi all,

Circle 3.0 :
The skill bash seems to give exactly 1 hp damage.
I traced it down with gdb. There seems to be missing
something in damage() [fight.c] or do_bash.

====================

To the ASCII/birary discussion I just have to say,I don't care too much.

BUT if the system is going to change, why don't implement
VERSIONING for player (and later object, world & mob)files!

Like that:

int load_char(char *name, struct char_file_u * char_element)
{
   int player_i;
   int find_name(char *name);
   type STHG_OLD;

   if ((player_i = find_name(name)) >= 0)
   {
      fseek(player_fl, wheresoever, SEEK_SET);

      fscanf(player_fl,"%d",&version);
      switch(version)
      {
      case 0: /* original playerfile */
         fread(&(st->sex),sizeof(st->sex), 1, player_fl);
         fread(&(st->class),sizeof(st->class), 1, player_fl);
         fread(&(st->level),sizeof(st->level), 1, player_fl);
	 st->STHG_NEW = some_default;
         fread(&(STHG_OLD),sizeof(STHG_OLD), 1, player_fl);
	 st->STHG_NEW2 = sin(STHG_OLD)*2/4;
	 /* ... */
	 break;
      case 1:
         fread(&(st->sex),sizeof(st->sex), 1, player_fl);
         fread(&(st->class),sizeof(st->class), 1, player_fl);
         fread(&(st->level),sizeof(st->level), 1, player_fl);
         fread(&(st->STHG_NEW),sizeof(st->STHG_NEW), 1, player_fl);
         fread(&(st->STHG_NEW2),sizeof(st->STHG_NEW2), 1, player_fl);
         /* ... */
         break;
      default: mudlog("Version error\n");
      ....
      }
      return (player_i);
   }
   return (-1);
}

This will make sure that playerfiles will get converted on the fly.

It would also be possible if used on obj,mob,wld,zon files to make  
files from different changed muds compatible again, or convert  
different flags from different muds by just inserting & changing a  
version entry. The version needs then only to be read once at the  
beginning of the file.

The write function just writes the newest version out.
Although the db-entries do not have a specific size anymore
[-> fseek() is not that easy to use].
And it is usable for ASCII & binary files with a few changes.

What do you think about that ?

Kilian.



This archive was generated by hypermail 2b30 : 12/07/00 PST