LCOV - code coverage report
Current view: top level - omega-rpg-0.90-pa9 - pdump.c (source / functions) Hit Total Coverage
Test: lcov.info Lines: 0 608 0.0 %
Date: 2017-09-08 22:00:26 Functions: 0 28 0.0 %
Branches: 0 432 0.0 %

           Branch data     Line data    Source code
       1                 :            : /* omega copyright (c) 1987,1988,1989 by Laurence Raphael Brothers */
       2                 :            : /* pdump.c */
       3                 :            : 
       4                 :            : #include <ctype.h>
       5                 :            : #include "glob.h"
       6                 :            : 
       7                 :            : char *monk_rank_string(int rank);
       8                 :            : char *legion_rank_string( int rank );
       9                 :            : char *arena_rank_string( int rank );
      10                 :            : char *college_rank_string( int rank );
      11                 :            : char *nobility_rank_string( int rank );
      12                 :            : char *circle_rank_string( int rank );
      13                 :            : char *order_rank_string( int rank );
      14                 :            : char *thieves_rank_string( int rank );
      15                 :            : char *priesthood_rank_string( int rank, int patron );
      16                 :            : char *elapsed_time_string( long minutes );
      17                 :            : char *alignment_string( int alignment );
      18                 :            : int alignment_level_index( int alignment );
      19                 :            : short build_check( long *check, char *s );
      20                 :            : short dump( FILE *dumpfile, char *s, short do_check );
      21                 :            : short dump_basic( FILE *dumpfile );
      22                 :            : short dump_options( FILE *dumpfile );
      23                 :            : short dump_stati( FILE *dumpfile );
      24                 :            : short dump_immunities( FILE *dumpfile );
      25                 :            : short dump_in_columns( FILE *dumpfile, int col_width, char *s );
      26                 :            : short end_dump_in_columns( FILE *dumpfile );
      27                 :            : short dump_ranks( FILE *dumpfile );
      28                 :            : char *fill_rank_field( char *buf );
      29                 :            : void strcat_carry_item( char *buf, int slotnum );
      30                 :            : short dump_carried( FILE *dumpfile );
      31                 :            : short dump_pack( FILE *dumpfile );
      32                 :            : short dump_condo( FILE *dumpfile );
      33                 :            : short dump_possessions( FILE *dumpfile );
      34                 :            : void player_dump( void );
      35                 :            : 
      36                 :            : long dumpcheck;
      37                 :            : char *why;
      38                 :            : char dump_buf[ 100 ];
      39                 :            : char spaces[] = "                                             "
      40                 :            : "                                             ";
      41                 :            : 
      42                 :            : short do_dump_stat_imm = TRUE;
      43                 :            : 
      44                 :            : char *legion_ranks[ 6 ] =
      45                 :            : {
      46                 :            :   "",
      47                 :            :   "Legionaire",
      48                 :            :   "Centurion of the Legion",
      49                 :            :   "Force Leader of the Legion",
      50                 :            :   "Colonel of the Legion",
      51                 :            :   "Commandant of the Legion"
      52                 :            : };
      53                 :            : 
      54                 :            : char *arena_ranks[ 6 ] =
      55                 :            : {
      56                 :            :   "Ex-gladiator",
      57                 :            :   "Gladiator Trainee of the Arena",
      58                 :            :   "Bestiarius of the Arena",
      59                 :            :   "Retiarius of the Arena",
      60                 :            :   "Gladiator of the Arena",
      61                 :            :   "Gladiator Champion of the Arena"
      62                 :            : };
      63                 :            : 
      64                 :            : char *college_ranks[ 6 ] =
      65                 :            : {
      66                 :            :   "",
      67                 :            :   "Collegium Magii: Novice",
      68                 :            :   "Collegium Magii: Student",
      69                 :            :   "Collegium Magii: Preceptor",
      70                 :            :   "Collegium Magii: Mage",
      71                 :            :   "Archmage of the Collegium Magii"
      72                 :            : };
      73                 :            : 
      74                 :            : char *nobility_ranks[ 6 ] =
      75                 :            : {
      76                 :            :   "Lowly Commoner",
      77                 :            :   "Commoner",
      78                 :            :   "Squire of Rampart",
      79                 :            :   "Order of the Knights of Rampart",
      80                 :            :   "Peer of the Realm",
      81                 :            :   "Duke of Rampart"
      82                 :            : };
      83                 :            : 
      84                 :            : char *circle_ranks[ 6 ] =
      85                 :            : {
      86                 :            :   "Former member of the Circle",
      87                 :            :   "Member of the Circle of Initiates",
      88                 :            :   "Member of the Circle of Enchanters",
      89                 :            :   "Member of the Circle of Sorcerors",
      90                 :            :   "High Sorceror of the Inner Circle",
      91                 :            :   "Prime Sorceror of the Inner Circle"
      92                 :            : };
      93                 :            : 
      94                 :            : char *order_ranks[ 6 ] =
      95                 :            : {
      96                 :            :   "Washout from the Order of Paladins",
      97                 :            :   "Gallant of the Order",
      98                 :            :   "Guardian of the Order",
      99                 :            :   "Chevalier of the Order",
     100                 :            :   "Paladin of the Order",
     101                 :            :   "Justiciar of the Order of Paladins"
     102                 :            : };
     103                 :            : 
     104                 :            : char *thieves_ranks[ 6 ] =
     105                 :            : {
     106                 :            :   "",
     107                 :            :   "Guild of Thieves: Candidate Member",
     108                 :            :   "Guild of Thieves: Apprentice Thief",
     109                 :            :   "Guild of Thieves: Thief",
     110                 :            :   "Guild of Thieves: Master Thief",
     111                 :            :   "Guild of Thieves: Shadowlord"
     112                 :            : };
     113                 :            : 
     114                 :            : char *priesthood_ranks[ 6 ] =
     115                 :            : {
     116                 :            :   "",
     117                 :            :   "A lay devotee of ",
     118                 :            :   "An Acolyte of ",
     119                 :            :   "A Priest of ",
     120                 :            :   "A Senior Priest of ",
     121                 :            :   "The High Priest of "
     122                 :            : };
     123                 :            : 
     124                 :            : char *patron_names[ 7 ] =
     125                 :            : {
     126                 :            :   "",
     127                 :            :   "Odin",
     128                 :            :   "Set",
     129                 :            :   "Athena",
     130                 :            :   "Hecate",
     131                 :            :   "Druidism",
     132                 :            :   "the Lords of Destiny"
     133                 :            : };
     134                 :            : 
     135                 :            : char *monk_ranks[8] =
     136                 :            : {
     137                 :            :   "",
     138                 :            :   "Monk Trainee",
     139                 :            :   "Monk",
     140                 :            :   "Monk Master",
     141                 :            :   "Monk Master of Sighs",
     142                 :            :   "Monk Master of Pain",
     143                 :            :   "Monk Master of Tears",
     144                 :            :   "Monk Grandmaster"
     145                 :            : };
     146                 :            : 
     147                 :          0 : void player_dump( void )
     148                 :            : {
     149                 :            :   FILE *dumpfile;
     150                 :            :   char dump_name[ 32 ];
     151                 :            :         
     152                 :            :   /* build player dump file name as "charactername.txt" */
     153                 :          0 :   strncpy( dump_name, Player.name, 27 );
     154                 :          0 :   strcat( dump_name, ".txt" );
     155                 :            :         
     156                 :            :   /* try to open dump file for writing, not using checkfopen() */
     157                 :            :   /* (file.c) because there is no need to quit the program if */
     158                 :            :   /* fopen fails. */
     159                 :          0 :   dumpfile = fopen( dump_name, "w" );
     160         [ #  # ]:          0 :   if ( !dumpfile )
     161                 :            :     {
     162                 :          0 :       why = "couldn't open file";
     163                 :          0 :       goto dump_failed;
     164                 :            :     }
     165                 :            :                 
     166                 :            :   /* dump name, stats, etc. */
     167         [ #  # ]:          0 :   if ( !dump_basic( dumpfile ) )
     168                 :          0 :     goto dump_failed;
     169                 :            :                 
     170                 :            :   /* dump options */
     171         [ #  # ]:          0 :   if ( !dump_options( dumpfile ) )
     172                 :          0 :     goto dump_failed;
     173                 :            :                 
     174         [ #  # ]:          0 :   if ( do_dump_stat_imm )
     175                 :            :     {
     176                 :            :       /* dump stati */
     177         [ #  # ]:          0 :       if ( !dump_stati( dumpfile ) )
     178                 :          0 :         goto dump_failed;
     179                 :            :                         
     180                 :            :       /* dump immunities */
     181         [ #  # ]:          0 :       if ( !dump_immunities( dumpfile ) )
     182                 :          0 :         goto dump_failed;
     183                 :            :     }
     184                 :            :         
     185                 :            :   /* dump ranks */
     186         [ #  # ]:          0 :   if ( !dump_ranks( dumpfile ) )
     187                 :          0 :     goto dump_failed;
     188                 :            :         
     189                 :            :   /* dump possessions */
     190         [ #  # ]:          0 :   if ( !dump_possessions( dumpfile ) )
     191                 :          0 :     goto dump_failed;
     192                 :            :                 
     193                 :          0 :   fclose( dumpfile );
     194                 :            :   /*_ftype = 'odat';*/
     195                 :            :         
     196                 :          0 :   clearmsg();
     197                 :          0 :   print1( "Character dump successful" );
     198                 :          0 :   morewait();
     199                 :          0 :   return;
     200                 :            :         
     201                 :            :  dump_failed:
     202                 :          0 :   clearmsg();
     203                 :          0 :   sprintf( Str3, "Character dump unsuccessful (%s)", why );
     204                 :          0 :   print1( Str3 );
     205                 :          0 :   morewait();
     206                 :          0 :   return;
     207                 :            : }
     208                 :            : 
     209                 :          0 : void strcat_carry_item( char *buf, int slot )
     210                 :            : {
     211         [ #  # ]:          0 :   if ( Player.possessions[ slot ] == NULL )
     212                 :          0 :     strcat( buf, "(nothing)\n" );
     213                 :            :   else
     214                 :            :     {
     215                 :          0 :       strcat( buf, itemid( Player.possessions[ slot ] ));
     216                 :          0 :       strcat( buf, "\n" );
     217                 :            :     }
     218                 :          0 : }
     219                 :            : 
     220                 :          0 : short dump_carried( FILE *dumpfile )
     221                 :            : {
     222                 :            :   /* reset "checksum" */
     223                 :          0 :   dumpcheck = 0;
     224                 :            : 
     225         [ #  # ]:          0 :   if ( !dump( dumpfile, "-- Possessions (Carried) --\n\n", FALSE ) )
     226                 :          0 :     return FALSE;
     227                 :            :                 
     228                 :          0 :   strcpy( dump_buf, "a) Ready hand     : " );
     229                 :          0 :   strcat_carry_item( dump_buf, O_READY_HAND );
     230         [ #  # ]:          0 :   if ( !dump( dumpfile, dump_buf, TRUE ) )
     231                 :          0 :     return FALSE;
     232                 :            :                 
     233                 :          0 :   strcpy( dump_buf, "b) Weapon hand    : " );
     234                 :          0 :   strcat_carry_item( dump_buf, O_WEAPON_HAND );
     235         [ #  # ]:          0 :   if ( !dump( dumpfile, dump_buf, TRUE ) )
     236                 :          0 :     return FALSE;
     237                 :            :         
     238                 :          0 :   strcpy( dump_buf, "c) Left shoulder  : " );
     239                 :          0 :   strcat_carry_item( dump_buf, O_LEFT_SHOULDER );
     240         [ #  # ]:          0 :   if ( !dump( dumpfile, dump_buf, TRUE ) )
     241                 :          0 :     return FALSE;
     242                 :            :         
     243                 :          0 :   strcpy( dump_buf, "d) Right shoulder : " );
     244                 :          0 :   strcat_carry_item( dump_buf, O_RIGHT_SHOULDER );
     245         [ #  # ]:          0 :   if ( !dump( dumpfile, dump_buf, TRUE ) )
     246                 :          0 :     return FALSE;
     247                 :            :         
     248                 :          0 :   strcpy( dump_buf, "e) Belt           : " );
     249                 :          0 :   strcat_carry_item( dump_buf, O_BELT1 );
     250         [ #  # ]:          0 :   if ( !dump( dumpfile, dump_buf, TRUE ) )
     251                 :          0 :     return FALSE;
     252                 :            :         
     253                 :          0 :   strcpy( dump_buf, "f) Belt           : " );
     254                 :          0 :   strcat_carry_item( dump_buf, O_BELT2 );
     255         [ #  # ]:          0 :   if ( !dump( dumpfile, dump_buf, TRUE ) )
     256                 :          0 :     return FALSE;
     257                 :            :         
     258                 :          0 :   strcpy( dump_buf, "g) Belt           : " );
     259                 :          0 :   strcat_carry_item( dump_buf, O_BELT3 );
     260         [ #  # ]:          0 :   if ( !dump( dumpfile, dump_buf, TRUE ) )
     261                 :          0 :     return FALSE;
     262                 :            :         
     263                 :          0 :   strcpy( dump_buf, "h) Shield         : " );
     264                 :          0 :   strcat_carry_item( dump_buf, O_SHIELD );
     265         [ #  # ]:          0 :   if ( !dump( dumpfile, dump_buf, TRUE ) )
     266                 :          0 :     return FALSE;
     267                 :            :         
     268                 :          0 :   strcpy( dump_buf, "i) Armor          : " );
     269                 :          0 :   strcat_carry_item( dump_buf, O_ARMOR );
     270         [ #  # ]:          0 :   if ( !dump( dumpfile, dump_buf, TRUE ) )
     271                 :          0 :     return FALSE;
     272                 :            :         
     273                 :          0 :   strcpy( dump_buf, "j) Boots          : " );
     274                 :          0 :   strcat_carry_item( dump_buf, O_BOOTS );
     275         [ #  # ]:          0 :   if ( !dump( dumpfile, dump_buf, TRUE ) )
     276                 :          0 :     return FALSE;
     277                 :            :         
     278                 :          0 :   strcpy( dump_buf, "k) Cloak          : " );
     279                 :          0 :   strcat_carry_item( dump_buf, O_CLOAK );
     280         [ #  # ]:          0 :   if ( !dump( dumpfile, dump_buf, TRUE ) )
     281                 :          0 :     return FALSE;
     282                 :            :         
     283                 :          0 :   strcpy( dump_buf, "l) Finger         : " );
     284                 :          0 :   strcat_carry_item( dump_buf, O_RING1 );
     285         [ #  # ]:          0 :   if ( !dump( dumpfile, dump_buf, TRUE ) )
     286                 :          0 :     return FALSE;
     287                 :            :         
     288                 :          0 :   strcpy( dump_buf, "m) Finger         : " );
     289                 :          0 :   strcat_carry_item( dump_buf, O_RING2 );
     290         [ #  # ]:          0 :   if ( !dump( dumpfile, dump_buf, TRUE ) )
     291                 :          0 :     return FALSE;
     292                 :            :         
     293                 :          0 :   strcpy( dump_buf, "n) Finger         : " );
     294                 :          0 :   strcat_carry_item( dump_buf, O_RING3 );
     295         [ #  # ]:          0 :   if ( !dump( dumpfile, dump_buf, TRUE ) )
     296                 :          0 :     return FALSE;
     297                 :            :         
     298                 :          0 :   strcpy( dump_buf, "o) Finger         : " );
     299                 :          0 :   strcat_carry_item( dump_buf, O_RING4 );
     300         [ #  # ]:          0 :   if ( !dump( dumpfile, dump_buf, TRUE ) )
     301                 :          0 :     return FALSE;
     302                 :            :                 
     303                 :          0 :   sprintf( dump_buf, "\n[Verification: %8.8lx]\n\n", dumpcheck );
     304         [ #  # ]:          0 :   if ( !dump( dumpfile, dump_buf, FALSE ) )
     305                 :          0 :     return FALSE;
     306                 :            :                         
     307                 :          0 :   return TRUE;
     308                 :            : }
     309                 :            : 
     310                 :          0 : short dump_pack( FILE *dumpfile )
     311                 :            : {
     312                 :            :   int i;
     313                 :            :         
     314         [ #  # ]:          0 :   if ( Player.packptr > 0 )
     315                 :            :     {
     316                 :            :       /* reset "checksum" */
     317                 :          0 :       dumpcheck = 0;
     318                 :            :         
     319         [ #  # ]:          0 :       if ( !dump( dumpfile, "-- Possessions (In Pack) --\n\n", FALSE ) )
     320                 :          0 :         return FALSE;
     321                 :            :                 
     322         [ #  # ]:          0 :       for( i = 0; i < Player.packptr; i++ )
     323                 :            :         {
     324                 :          0 :           sprintf( dump_buf, "%c) %s\n", i + 'A', itemid( Player.pack[ i ] ) );
     325         [ #  # ]:          0 :           if ( !dump( dumpfile, dump_buf, TRUE ) )
     326                 :          0 :             return FALSE;
     327                 :            :         }
     328                 :            :                         
     329                 :          0 :       sprintf( dump_buf, "\n[Verification: %8.8lx]\n\n", dumpcheck );
     330         [ #  # ]:          0 :       if ( !dump( dumpfile, dump_buf, FALSE ) )
     331                 :          0 :         return FALSE;
     332                 :            :     }
     333                 :            :                         
     334                 :          0 :   return TRUE;
     335                 :            : }
     336                 :            : 
     337                 :          0 : short dump_condo( FILE *dumpfile )
     338                 :            : {
     339                 :            :   pol ol;
     340                 :            :         
     341         [ #  # ]:          0 :   if ( Condoitems )
     342                 :            :     {
     343                 :            :       /* reset "checksum" */
     344                 :          0 :       dumpcheck = 0;
     345                 :            :         
     346         [ #  # ]:          0 :       if ( !dump( dumpfile, "-- Possessions (In Condo) --\n\n", FALSE ) )
     347                 :          0 :         return FALSE;
     348                 :            :                         
     349         [ #  # ]:          0 :       for( ol = Condoitems; ol; ol = ol->next )
     350                 :            :         {
     351                 :          0 :           sprintf( dump_buf, "%s\n", itemid( ol->thing ) );
     352         [ #  # ]:          0 :           if ( !dump( dumpfile, dump_buf, TRUE ) )
     353                 :          0 :             return FALSE;
     354                 :            :         }
     355                 :            :                         
     356                 :          0 :       sprintf( dump_buf, "\n[Verification: %8.8lx]\n\n", dumpcheck );
     357         [ #  # ]:          0 :       if ( !dump( dumpfile, dump_buf, FALSE ) )
     358                 :          0 :         return FALSE;
     359                 :            :     }
     360                 :            :                         
     361                 :          0 :   return TRUE;
     362                 :            : }
     363                 :            : 
     364                 :          0 : short dump_possessions( FILE *dumpfile )
     365                 :            : {
     366         [ #  # ]:          0 :   if ( !dump_carried( dumpfile ) )
     367                 :          0 :     return FALSE;
     368                 :            :                 
     369         [ #  # ]:          0 :   if ( !dump_pack( dumpfile ) )
     370                 :          0 :     return FALSE;
     371                 :            :         
     372         [ #  # ]:          0 :   if ( gamestatusp( SOLD_CONDO ) )
     373                 :            :     {
     374         [ #  # ]:          0 :       if ( !dump_condo( dumpfile ) )
     375                 :          0 :         return FALSE;
     376                 :            :     }
     377                 :            :                 
     378                 :          0 :   return TRUE;
     379                 :            : }
     380                 :            : 
     381                 :            : #define RANK_FIELD_WIDTH 41
     382                 :          0 : char *fill_rank_field( char *buf )
     383                 :            : {
     384                 :            :   int slen;
     385                 :            :   char *cp;
     386                 :            :         
     387                 :          0 :   slen = strlen( buf );
     388                 :          0 :   cp = buf + slen;
     389         [ #  # ]:          0 :   while( slen < RANK_FIELD_WIDTH )
     390                 :            :     {
     391                 :          0 :       *cp++ = ' ';
     392                 :          0 :       slen++;
     393                 :            :     }
     394                 :            :         
     395                 :          0 :   return cp;
     396                 :            : }
     397                 :            : 
     398                 :          0 : short dump_ranks( FILE *dumpfile )
     399                 :            : {
     400                 :            :   char *cp;
     401                 :            :         
     402                 :            :   /* reset "checksum" */
     403                 :          0 :   dumpcheck = 0;
     404                 :            : 
     405         [ #  # ]:          0 :   if ( !dump( dumpfile, "-- Current Ranks --\n\n", FALSE ) )
     406                 :          0 :     return FALSE;
     407                 :            :         
     408         [ #  # ]:          0 :   if ( Player.rank[ LEGION ] > 0 )
     409                 :            :     {
     410                 :          0 :       strcpy( dump_buf, legion_rank_string( Player.rank[ LEGION ] ) );
     411                 :          0 :       cp = fill_rank_field( dump_buf );
     412                 :          0 :       sprintf( cp, "Exp: %ld\n", Player.guildxp[ LEGION ] );
     413         [ #  # ]:          0 :       if ( !dump( dumpfile, dump_buf, TRUE ) )
     414                 :          0 :         return FALSE;
     415                 :            :     }
     416                 :            :         
     417         [ #  # ]:          0 :   if ( Player.rank[ ARENA ] != 0 )
     418                 :            :     {
     419                 :          0 :       strcpy( dump_buf, arena_rank_string( Player.rank[ ARENA ] ) );
     420         [ #  # ]:          0 :       if ( Player.rank[ ARENA ] > 0 )
     421                 :            :         {
     422                 :          0 :           cp = fill_rank_field( dump_buf );
     423                 :          0 :           sprintf( cp, "%d opponents defeated\n", Arena_Opponent - 3 );
     424                 :            :         }
     425                 :            :       else
     426                 :            :         {
     427                 :          0 :           strcat( dump_buf, "\n" );
     428                 :            :         }
     429         [ #  # ]:          0 :       if ( !dump( dumpfile, dump_buf, TRUE ) )
     430                 :          0 :         return FALSE;
     431                 :            :     }
     432                 :            :         
     433         [ #  # ]:          0 :   if ( Player.rank[ COLLEGE ] > 0 )
     434                 :            :     {
     435                 :          0 :       strcpy( dump_buf, college_rank_string( Player.rank[ COLLEGE ] ) );
     436                 :          0 :       cp = fill_rank_field( dump_buf );
     437                 :          0 :       sprintf( cp, "Exp: %ld\n", Player.guildxp[ COLLEGE ] );
     438         [ #  # ]:          0 :       if ( !dump( dumpfile, dump_buf, TRUE ) )
     439                 :          0 :         return FALSE;
     440                 :            :     }
     441                 :            :         
     442                 :          0 :   strcpy( dump_buf, nobility_rank_string( Player.rank[ NOBILITY ] ) );
     443                 :          0 :   cp = fill_rank_field( dump_buf );
     444         [ #  # ]:          0 :   if ( Player.rank[ NOBILITY ] == 0 )
     445                 :            :     {
     446                 :          0 :       *cp++ = '\n';
     447                 :          0 :       *cp = '\0';
     448                 :            :     }
     449         [ #  # ]:          0 :   else if ( Player.rank[ NOBILITY ] == 1 )
     450                 :            :     {
     451                 :          0 :       sprintf( cp, "1st quest undertaken\n" );
     452                 :            :     }
     453         [ #  # ]:          0 :   else if ( Player.rank[ NOBILITY ] > 1 )
     454                 :            :     {
     455                 :          0 :       sprintf( cp, "%d%s quest completed\n", Player.rank[ NOBILITY ] - 1,
     456                 :          0 :                ordinal( Player.rank[ NOBILITY ] - 1 ) );
     457                 :            :     }
     458         [ #  # ]:          0 :   if ( !dump( dumpfile, dump_buf, TRUE ) )
     459                 :          0 :     return FALSE;
     460                 :            :         
     461         [ #  # ]:          0 :   if ( Player.rank[ CIRCLE ] != 0 )
     462                 :            :     {
     463                 :          0 :       strcpy( dump_buf, circle_rank_string( Player.rank[ CIRCLE ] ) );
     464         [ #  # ]:          0 :       if ( Player.rank[ CIRCLE ] > 0 )
     465                 :            :         {
     466                 :          0 :           cp = fill_rank_field( dump_buf );
     467                 :          0 :           sprintf( cp, "Exp: %ld\n", Player.guildxp[ CIRCLE ] );
     468                 :            :         }
     469                 :            :       else
     470                 :            :         {
     471                 :          0 :           strcat( dump_buf, "\n" );
     472                 :            :         }
     473         [ #  # ]:          0 :       if ( !dump( dumpfile, dump_buf, TRUE ) )
     474                 :          0 :         return FALSE;
     475                 :            :     }
     476                 :            :         
     477         [ #  # ]:          0 :   if ( Player.rank[ ORDER ] != 0 )
     478                 :            :     {
     479                 :          0 :       strcpy( dump_buf, order_rank_string( Player.rank[ ORDER ] ) );
     480         [ #  # ]:          0 :       if ( Player.rank[ ORDER ] > 0 )
     481                 :            :         {
     482                 :          0 :           cp = fill_rank_field( dump_buf );
     483                 :          0 :           sprintf( cp, "Exp: %ld\n", Player.guildxp[ ORDER ] );
     484                 :            :         }
     485                 :            :       else
     486                 :            :         {
     487                 :          0 :           strcat( dump_buf, "\n" );
     488                 :            :         }
     489         [ #  # ]:          0 :       if ( !dump( dumpfile, dump_buf, TRUE ) )
     490                 :          0 :         return FALSE;
     491                 :            :     }
     492                 :            :         
     493         [ #  # ]:          0 :   if ( Player.rank[ THIEVES ] > 0 )
     494                 :            :     {
     495                 :          0 :       strcpy( dump_buf, thieves_rank_string( Player.rank[ THIEVES ] ) );
     496                 :          0 :       cp = fill_rank_field( dump_buf );
     497                 :          0 :       sprintf( cp, "Exp: %ld\n", Player.guildxp[ THIEVES ] );
     498         [ #  # ]:          0 :       if ( !dump( dumpfile, dump_buf, TRUE ) )
     499                 :          0 :         return FALSE;
     500                 :            :     }
     501                 :            :         
     502         [ #  # ]:          0 :   if ( Player.rank[ PRIESTHOOD ] > 0 )
     503                 :            :     {
     504                 :          0 :       strcpy( dump_buf, priesthood_rank_string( Player.rank[ PRIESTHOOD ], Player.patron ) );
     505                 :          0 :       cp = fill_rank_field( dump_buf );
     506                 :          0 :       sprintf( cp, "Exp: %ld\n", Player.guildxp[ PRIESTHOOD ] );
     507         [ #  # ]:          0 :       if ( !dump( dumpfile, dump_buf, TRUE ) )
     508                 :          0 :         return FALSE;
     509                 :            :     }
     510                 :            :                 
     511         [ #  # ]:          0 :   if ( Player.rank[ MONKS ] > 0 )
     512                 :            :     {
     513                 :          0 :       strcpy(dump_buf, monk_rank_string(Player.rank[MONKS]));
     514                 :          0 :       cp = fill_rank_field(dump_buf);
     515                 :          0 :       sprintf(cp, "Exp: %ld\n", Player.guildxp[MONKS]);
     516         [ #  # ]:          0 :       if (!dump(dumpfile, dump_buf, TRUE)) return FALSE;
     517                 :            :     }
     518                 :            :                 
     519         [ #  # ]:          0 :   if ( Player.rank[ ADEPT ] > 0 ) 
     520                 :            :     {
     521         [ #  # ]:          0 :       if ( !dump( dumpfile, "********** An Adept of Omega **********\n", TRUE ) )
     522                 :          0 :         return FALSE;
     523                 :            :     }
     524                 :            :                 
     525                 :          0 :   sprintf( dump_buf, "\n[Verification: %8.8lx]\n\n", dumpcheck );
     526         [ #  # ]:          0 :   if ( !dump( dumpfile, dump_buf, FALSE ) )
     527                 :          0 :     return FALSE;
     528                 :            :                         
     529                 :          0 :   return TRUE;
     530                 :            : }
     531                 :            : 
     532                 :            : int dump_col;
     533                 :            : 
     534                 :          0 : short dump_in_columns( FILE *dumpfile, int col_width, char *s )
     535                 :            : {
     536                 :            :   int i, slen;
     537                 :            :         
     538                 :          0 :   slen = strlen( s );
     539         [ #  # ]:          0 :   if (( dump_col + slen ) > ( 80 - col_width ))
     540                 :            :     {
     541                 :          0 :       strcat( dump_buf, s );
     542                 :          0 :       strcat( dump_buf, "\n" );
     543         [ #  # ]:          0 :       if ( !dump( dumpfile, dump_buf, TRUE ) )
     544                 :          0 :         return FALSE;
     545                 :            :                         
     546                 :          0 :       dump_col = 0;
     547                 :            :     }
     548         [ #  # ]:          0 :   else if ( dump_col == 0 )
     549                 :            :     {
     550                 :          0 :       strcpy( dump_buf, s );
     551         [ #  # ]:          0 :       for( dump_col = slen; dump_col < col_width; dump_col++ )
     552                 :          0 :         dump_buf[ dump_col ] = ' ';
     553                 :          0 :       dump_buf[ dump_col ] = '\0';
     554                 :            :     }
     555                 :            :   else
     556                 :            :     {
     557                 :          0 :       strcat( dump_buf, s );
     558         [ #  # ]:          0 :       for( i = dump_col + slen; i < dump_col + col_width; i++ )
     559                 :          0 :         dump_buf[ i ] = ' ';
     560                 :          0 :       dump_col = i;
     561                 :          0 :       dump_buf[ dump_col ] = '\0';
     562                 :            :     }
     563                 :            :         
     564                 :          0 :   return TRUE;
     565                 :            : }
     566                 :            : 
     567                 :          0 : short end_dump_in_columns( FILE *dumpfile )
     568                 :            : {
     569         [ #  # ]:          0 :   if ( dump_col > 0 )
     570                 :            :     {
     571                 :          0 :       strcat( dump_buf, "\n" );
     572         [ #  # ]:          0 :       if ( !dump( dumpfile, dump_buf, TRUE ) )
     573                 :          0 :         return FALSE;
     574                 :            :     }
     575                 :            :         
     576         [ #  # ]:          0 :   if ( !dump( dumpfile, "\n", FALSE ) )
     577                 :          0 :     return FALSE;
     578                 :            :                 
     579                 :          0 :   return TRUE;
     580                 :            : }
     581                 :            : 
     582                 :          0 : short dump_stati( FILE *dumpfile )
     583                 :            : {
     584                 :          0 :   int numstati = 0;
     585                 :            :         
     586                 :            :   /* reset "checksum" */
     587                 :          0 :   dumpcheck = 0;
     588                 :          0 :   dump_col = 0;
     589                 :            : 
     590         [ #  # ]:          0 :   if ( !dump( dumpfile, "-- Current Stati --\n\n", FALSE ) )
     591                 :          0 :     return FALSE;
     592                 :            :         
     593         [ #  # ]:          0 :   if ( Player.status[ BLINDED ] )
     594                 :            :     {
     595                 :          0 :       numstati++;
     596         [ #  # ]:          0 :       if ( !dump_in_columns( dumpfile, 20, "Blinded" ) )
     597                 :          0 :         return FALSE;
     598                 :            :     }
     599                 :            :                 
     600         [ #  # ]:          0 :   if ( Player.status[ SLOWED ] )
     601                 :            :     {
     602                 :          0 :       numstati++;
     603         [ #  # ]:          0 :       if ( !dump_in_columns( dumpfile, 20, "Slowed" ) )
     604                 :          0 :         return FALSE;
     605                 :            :     }
     606                 :            :                 
     607         [ #  # ]:          0 :   if ( Player.status[ HASTED ] )
     608                 :            :     {
     609                 :          0 :       numstati++;
     610         [ #  # ]:          0 :       if ( !dump_in_columns( dumpfile, 20, "Hasted" ) )
     611                 :          0 :         return FALSE;
     612                 :            :     }
     613                 :            :                 
     614         [ #  # ]:          0 :   if ( Player.status[ DISPLACED ] )
     615                 :            :     {
     616                 :          0 :       numstati++;
     617         [ #  # ]:          0 :       if ( !dump_in_columns( dumpfile, 20, "Displaced" ) )
     618                 :          0 :         return FALSE;
     619                 :            :     }
     620                 :            :                 
     621         [ #  # ]:          0 :   if ( Player.status[ SLEPT ] )
     622                 :            :     {
     623                 :          0 :       numstati++;
     624         [ #  # ]:          0 :       if ( !dump_in_columns( dumpfile, 20, "Slept" ) )
     625                 :          0 :         return FALSE;
     626                 :            :     }
     627                 :            :                 
     628         [ #  # ]:          0 :   if ( Player.status[ DISEASED ] )
     629                 :            :     {
     630                 :          0 :       numstati++;
     631         [ #  # ]:          0 :       if ( !dump_in_columns( dumpfile, 20, "Diseased" ) )
     632                 :          0 :         return FALSE;
     633                 :            :     }
     634                 :            :                 
     635         [ #  # ]:          0 :   if ( Player.status[ POISONED ] )
     636                 :            :     {
     637                 :          0 :       numstati++;
     638         [ #  # ]:          0 :       if ( !dump_in_columns( dumpfile, 20, "Poisoned" ) )
     639                 :          0 :         return FALSE;
     640                 :            :     }
     641                 :            :                 
     642         [ #  # ]:          0 :   if ( Player.status[ BREATHING ] )
     643                 :            :     {
     644                 :          0 :       numstati++;
     645         [ #  # ]:          0 :       if ( !dump_in_columns( dumpfile, 20, "Breathing" ) )
     646                 :          0 :         return FALSE;
     647                 :            :     }
     648                 :            :                 
     649         [ #  # ]:          0 :   if ( Player.status[ INVISIBLE ] )
     650                 :            :     {
     651                 :          0 :       numstati++;
     652         [ #  # ]:          0 :       if ( !dump_in_columns( dumpfile, 20, "Invisible" ) )
     653                 :          0 :         return FALSE;
     654                 :            :     }
     655                 :            :                 
     656         [ #  # ]:          0 :   if ( Player.status[ REGENERATING ] )
     657                 :            :     {
     658                 :          0 :       numstati++;
     659         [ #  # ]:          0 :       if ( !dump_in_columns( dumpfile, 20, "Regenerating" ) )
     660                 :          0 :         return FALSE;
     661                 :            :     }
     662                 :            :                 
     663         [ #  # ]:          0 :   if ( Player.status[ VULNERABLE ] )
     664                 :            :     {
     665                 :          0 :       numstati++;
     666         [ #  # ]:          0 :       if ( !dump_in_columns( dumpfile, 20, "Vulnerable" ) )
     667                 :          0 :         return FALSE;
     668                 :            :     }
     669                 :            :                 
     670         [ #  # ]:          0 :   if ( Player.status[ BERSERK ] )
     671                 :            :     {
     672                 :          0 :       numstati++;
     673         [ #  # ]:          0 :       if ( !dump_in_columns( dumpfile, 20, "Berserk" ) )
     674                 :          0 :         return FALSE;
     675                 :            :     }
     676                 :            :                 
     677         [ #  # ]:          0 :   if ( Player.status[ IMMOBILE ] )
     678                 :            :     {
     679                 :          0 :       numstati++;
     680         [ #  # ]:          0 :       if ( !dump_in_columns( dumpfile, 20, "Immobile" ) )
     681                 :          0 :         return FALSE;
     682                 :            :     }
     683                 :            :                 
     684         [ #  # ]:          0 :   if ( Player.status[ ALERT ] )
     685                 :            :     {
     686                 :          0 :       numstati++;
     687         [ #  # ]:          0 :       if ( !dump_in_columns( dumpfile, 20, "Alert" ) )
     688                 :          0 :         return FALSE;
     689                 :            :     }
     690                 :            :                 
     691         [ #  # ]:          0 :   if ( Player.status[ AFRAID ] )
     692                 :            :     {
     693                 :          0 :       numstati++;
     694         [ #  # ]:          0 :       if ( !dump_in_columns( dumpfile, 20, "Afraid" ) )
     695                 :          0 :         return FALSE;
     696                 :            :     }
     697                 :            :                 
     698         [ #  # ]:          0 :   if ( Player.status[ ACCURATE ] )
     699                 :            :     {
     700                 :          0 :       numstati++;
     701         [ #  # ]:          0 :       if ( !dump_in_columns( dumpfile, 20, "Accurate" ) )
     702                 :          0 :         return FALSE;
     703                 :            :     }
     704                 :            :                 
     705         [ #  # ]:          0 :   if ( Player.status[ HERO ] )
     706                 :            :     {
     707                 :          0 :       numstati++;
     708         [ #  # ]:          0 :       if ( !dump_in_columns( dumpfile, 20, "Heroic" ) )
     709                 :          0 :         return FALSE;
     710                 :            :     }
     711                 :            :                 
     712         [ #  # ]:          0 :   if ( Player.status[ LEVITATING ] )
     713                 :            :     {
     714                 :          0 :       numstati++;
     715         [ #  # ]:          0 :       if ( !dump_in_columns( dumpfile, 20, "Levitating" ) )
     716                 :          0 :         return FALSE;
     717                 :            :     }
     718                 :            :         
     719         [ #  # ]:          0 :   if ( numstati )
     720                 :            :     {
     721                 :            :       /* dump last row of stati */
     722         [ #  # ]:          0 :       if ( !end_dump_in_columns( dumpfile ) )
     723                 :          0 :         return FALSE;
     724                 :            :                         
     725                 :          0 :       sprintf( dump_buf, "[Verification: %8.8lx]\n\n", dumpcheck );
     726         [ #  # ]:          0 :       if ( !dump( dumpfile, dump_buf, FALSE ) )
     727                 :          0 :         return FALSE;
     728                 :            :     }
     729                 :            :   else
     730                 :            :     {
     731                 :          0 :       sprintf( dump_buf, "(None)\n\n" );
     732         [ #  # ]:          0 :       if ( !dump( dumpfile, dump_buf, FALSE ) )
     733                 :          0 :         return FALSE;
     734                 :            :     }
     735                 :            :                 
     736                 :          0 :   return TRUE;
     737                 :            : }
     738                 :            : 
     739                 :          0 : short dump_immunities( FILE *dumpfile )
     740                 :            : {
     741                 :          0 :   int numimmunities = 0;
     742                 :            :         
     743                 :            :   /* reset "checksum" */
     744                 :          0 :   dumpcheck = 0;
     745                 :          0 :   dump_col = 0;
     746                 :            : 
     747         [ #  # ]:          0 :   if ( !dump( dumpfile, "-- Current Immunities --\n\n", FALSE ) )
     748                 :          0 :     return FALSE;
     749                 :            :                 
     750         [ #  # ]:          0 :   if ( p_immune( NORMAL_DAMAGE ) )
     751                 :            :     {
     752                 :          0 :       numimmunities++;
     753         [ #  # ]:          0 :       if ( !dump_in_columns( dumpfile, 26, "Normal Damage" ) )
     754                 :          0 :         return FALSE;
     755                 :            :     }
     756                 :            :                 
     757         [ #  # ]:          0 :   if ( p_immune( FLAME ) )
     758                 :            :     {
     759                 :          0 :       numimmunities++;
     760         [ #  # ]:          0 :       if ( !dump_in_columns( dumpfile, 26, "Flame" ) )
     761                 :          0 :         return FALSE;
     762                 :            :     }
     763                 :            :                 
     764         [ #  # ]:          0 :   if ( p_immune( ELECTRICITY ) )
     765                 :            :     {
     766                 :          0 :       numimmunities++;
     767         [ #  # ]:          0 :       if ( !dump_in_columns( dumpfile, 26, "Electricity" ) )
     768                 :          0 :         return FALSE;
     769                 :            :     }
     770                 :            :                 
     771         [ #  # ]:          0 :   if ( p_immune( COLD ) )
     772                 :            :     {
     773                 :          0 :       numimmunities++;
     774         [ #  # ]:          0 :       if ( !dump_in_columns( dumpfile, 26, "Cold" ) )
     775                 :          0 :         return FALSE;
     776                 :            :     }
     777                 :            :                 
     778         [ #  # ]:          0 :   if ( p_immune( POISON ) )
     779                 :            :     {
     780                 :          0 :       numimmunities++;
     781         [ #  # ]:          0 :       if ( !dump_in_columns( dumpfile, 26, "Poison" ) )
     782                 :          0 :         return FALSE;
     783                 :            :     }
     784                 :            :                 
     785         [ #  # ]:          0 :   if ( p_immune( ACID ) )
     786                 :            :     {
     787                 :          0 :       numimmunities++;
     788         [ #  # ]:          0 :       if ( !dump_in_columns( dumpfile, 26, "Acid" ) )
     789                 :          0 :         return FALSE;
     790                 :            :     }
     791                 :            :                 
     792         [ #  # ]:          0 :   if ( p_immune( FEAR ) )
     793                 :            :     {
     794                 :          0 :       numimmunities++;
     795         [ #  # ]:          0 :       if ( !dump_in_columns( dumpfile, 26, "Fear" ) )
     796                 :          0 :         return FALSE;
     797                 :            :     }
     798                 :            :                 
     799         [ #  # ]:          0 :   if ( p_immune( SLEEP ) )
     800                 :            :     {
     801                 :          0 :       numimmunities++;
     802         [ #  # ]:          0 :       if ( !dump_in_columns( dumpfile, 26, "Sleep" ) )
     803                 :          0 :         return FALSE;
     804                 :            :     }
     805                 :            :                 
     806         [ #  # ]:          0 :   if ( p_immune( NEGENERGY ) )
     807                 :            :     {
     808                 :          0 :       numimmunities++;
     809         [ #  # ]:          0 :       if ( !dump_in_columns( dumpfile, 26, "Negative Energies" ) )
     810                 :          0 :         return FALSE;
     811                 :            :     }
     812                 :            :                 
     813         [ #  # ]:          0 :   if ( p_immune( THEFT ) )
     814                 :            :     {
     815                 :          0 :       numimmunities++;
     816         [ #  # ]:          0 :       if ( !dump_in_columns( dumpfile, 26, "Theft" ) )
     817                 :          0 :         return FALSE;
     818                 :            :     }
     819                 :            :                 
     820         [ #  # ]:          0 :   if ( p_immune( GAZE ) )
     821                 :            :     {
     822                 :          0 :       numimmunities++;
     823         [ #  # ]:          0 :       if ( !dump_in_columns( dumpfile, 26, "Gaze" ) )
     824                 :          0 :         return FALSE;
     825                 :            :     }
     826                 :            :                 
     827         [ #  # ]:          0 :   if ( p_immune( INFECTION ) )
     828                 :            :     {
     829                 :          0 :       numimmunities++;
     830         [ #  # ]:          0 :       if ( !dump_in_columns( dumpfile, 26, "Infection" ) )
     831                 :          0 :         return FALSE;
     832                 :            :     }
     833                 :            :         
     834         [ #  # ]:          0 :   if ( numimmunities )
     835                 :            :     {
     836                 :            :       /* dump last row of immunities */
     837         [ #  # ]:          0 :       if ( !end_dump_in_columns( dumpfile ) )
     838                 :          0 :         return FALSE;
     839                 :            :                         
     840                 :          0 :       sprintf( dump_buf, "[Verification: %8.8lx]\n\n", dumpcheck );
     841         [ #  # ]:          0 :       if ( !dump( dumpfile, dump_buf, FALSE ) )
     842                 :          0 :         return FALSE;
     843                 :            :     }
     844                 :            :   else
     845                 :            :     {
     846                 :          0 :       sprintf( dump_buf, "(None)\n\n" );
     847         [ #  # ]:          0 :       if ( !dump( dumpfile, dump_buf, FALSE ) )
     848                 :          0 :         return FALSE;
     849                 :            :     }
     850                 :            :                 
     851                 :          0 :   return TRUE;
     852                 :            : }
     853                 :            : 
     854                 :            : short cheated_death;
     855                 :            : short cheated_savegame;
     856                 :            : 
     857                 :          0 : short dump_options( FILE *dumpfile )
     858                 :            : {
     859 [ #  # ][ #  # ]:          0 :   if ( cheated_death || cheated_savegame )
     860                 :            :     {
     861                 :            :       /* reset "checksum" */
     862                 :          0 :       dumpcheck = 0;
     863                 :            :         
     864         [ #  # ]:          0 :       if ( !dump( dumpfile, "\n-- Cheats --\n\n", FALSE ) )
     865                 :          0 :         return FALSE;
     866                 :            :                         
     867         [ #  # ]:          0 :       if ( gamestatusp( CHEATED ) )
     868                 :            :         {
     869         [ #  # ]:          0 :           if ( !dump( dumpfile, "Entered Wizard Mode\n", TRUE ) )
     870                 :          0 :             return FALSE;
     871                 :            :         }
     872                 :            :                                 
     873         [ #  # ]:          0 :       if ( cheated_death )
     874                 :            :         {
     875         [ #  # ]:          0 :           if ( !dump( dumpfile, "Refused to die\n", TRUE ) )
     876                 :          0 :             return FALSE;
     877                 :            :         }
     878                 :            :                                 
     879         [ #  # ]:          0 :       if ( cheated_savegame )
     880                 :            :         {
     881         [ #  # ]:          0 :           if ( !dump( dumpfile, "Restored from save file after death\n", TRUE ) )
     882                 :          0 :             return FALSE;
     883                 :            :         }
     884                 :            :                         
     885                 :          0 :       sprintf( dump_buf, "[Verification: %8.8lx]\n\n", dumpcheck );
     886         [ #  # ]:          0 :       if ( !dump( dumpfile, dump_buf, FALSE ) )
     887                 :          0 :         return FALSE;
     888                 :            :     }
     889                 :            :                         
     890                 :          0 :   return TRUE;
     891                 :            : }
     892                 :            : 
     893                 :          0 : short dump_basic( FILE *dumpfile )
     894                 :            : {
     895                 :            :   int curcol;
     896                 :            :   long total_balance;
     897                 :            :   char *cp;
     898                 :            :   bank_account *account;
     899                 :            :         
     900                 :            :   /* reset "checksum" */
     901                 :          0 :   dumpcheck = 0;
     902                 :            : 
     903                 :          0 :   strcpy( dump_buf, "[*] " );
     904                 :          0 :   strcat( dump_buf, VERSIONSTRING );
     905                 :          0 :   strcat( dump_buf, " character dump [*]\n\n" );
     906         [ #  # ]:          0 :   if ( !dump( dumpfile, dump_buf, FALSE ) )
     907                 :          0 :     return FALSE;
     908                 :            :                 
     909                 :          0 :   curcol = sprintf( dump_buf, "Name      : %s\n", Player.name );
     910         [ #  # ]:          0 :   if ( gamestatusp( CHEATED ) )
     911                 :            :     {
     912         [ #  # ]:          0 :       if ( 72 > strlen( dump_buf ) )
     913                 :          0 :         cp = strrchr( dump_buf, '\n' );
     914                 :            :       else
     915                 :          0 :         cp = &(dump_buf[ 70 ]);
     916                 :          0 :       strcpy( cp, " (WIZARD)\n" );
     917                 :            :     }
     918         [ #  # ]:          0 :   if ( !dump( dumpfile, dump_buf, TRUE ) )
     919                 :          0 :     return FALSE;
     920                 :            :                 
     921                 :          0 :   sprintf( dump_buf, "Level     : %s [%d]\n", levelname( Player.level ), Player.level );
     922         [ #  # ]:          0 :   if ( !dump( dumpfile, dump_buf, TRUE ) )
     923                 :          0 :     return FALSE;
     924                 :            :                 
     925                 :          0 :   sprintf( dump_buf, "Alignment : %s\n\n", alignment_string( Player.alignment ) );
     926         [ #  # ]:          0 :   if ( !dump( dumpfile, dump_buf, TRUE ) )
     927                 :          0 :     return FALSE;
     928                 :            :         
     929                 :            :   /*
     930                 :            :     sprintf( dump_buf, "Str : %5d [%d]%n%*sHP       : %5d [%d]%n%*sHit     : %d\n",
     931                 :            :     Player.str, Player.maxstr, &curcol, 26 - curcol, spaces,
     932                 :            :     Player.hp,  Player.maxhp,  &curcol, 57 - curcol, spaces,
     933                 :            :     Player.hit );
     934                 :            :     if ( !dump( dumpfile, dump_buf, TRUE ) )
     935                 :            :     return FALSE;
     936                 :            :   */
     937                 :            :                 
     938                 :          0 :   curcol = sprintf( dump_buf, "Str : %5d [%d]", Player.str, Player.maxstr );
     939                 :          0 :   cp = strrchr( dump_buf, '\0' );
     940         [ #  # ]:          0 :   for ( ; curcol < 26; curcol++ )
     941                 :          0 :     *cp++ = ' ';
     942                 :          0 :   curcol += sprintf( cp, "HP       : %5d [%d]", Player.hp,  Player.maxhp );
     943                 :          0 :   cp = strrchr( dump_buf, '\0' );
     944         [ #  # ]:          0 :   for ( ; curcol < 57; curcol++ )
     945                 :          0 :     *cp++ = ' ';
     946                 :          0 :   sprintf( cp, "Hit     : %d\n", Player.hit );
     947         [ #  # ]:          0 :   if ( !dump( dumpfile, dump_buf, TRUE ) )
     948                 :          0 :     return FALSE;
     949                 :            :                 
     950                 :          0 :   curcol = sprintf( dump_buf, "Con : %5d [%d]", Player.con, Player.maxcon );
     951                 :          0 :   cp = strrchr( dump_buf, '\0' );
     952         [ #  # ]:          0 :   for ( ; curcol < 26; curcol++ )
     953                 :          0 :     *cp++ = ' ';
     954                 :          0 :   curcol += sprintf( cp, "Mana     : %5ld [%ld]", Player.mana,  Player.maxmana );
     955                 :          0 :   cp = strrchr( dump_buf, '\0' );
     956         [ #  # ]:          0 :   for ( ; curcol < 57; curcol++ )
     957                 :          0 :     *cp++ = ' ';
     958                 :          0 :   sprintf( cp, "Damage  : %d\n", Player.dmg );
     959         [ #  # ]:          0 :   if ( !dump( dumpfile, dump_buf, TRUE ) )
     960                 :          0 :     return FALSE;
     961                 :            :                 
     962                 :          0 :   curcol = sprintf( dump_buf, "Dex : %5d [%d]", Player.dex, Player.maxdex );
     963                 :          0 :   cp = strrchr( dump_buf, '\0' );
     964         [ #  # ]:          0 :   for ( ; curcol < 57; curcol++ )
     965                 :          0 :     *cp++ = ' ';
     966                 :          0 :   sprintf( cp, "Defense : %d\n", Player.defense );
     967         [ #  # ]:          0 :   if ( !dump( dumpfile, dump_buf, TRUE ) )
     968                 :          0 :     return FALSE;
     969                 :            :                 
     970                 :          0 :   curcol = sprintf( dump_buf, "Agi : %5d [%d]", Player.agi, Player.maxagi );
     971                 :          0 :   cp = strrchr( dump_buf, '\0' );
     972         [ #  # ]:          0 :   for ( ; curcol < 26; curcol++ )
     973                 :          0 :     *cp++ = ' ';
     974                 :          0 :   sprintf( cp, "Exp      : %-10ld          Armor   : %d\n", Player.xp,  Player.absorption );
     975         [ #  # ]:          0 :   if ( !dump( dumpfile, dump_buf, TRUE ) )
     976                 :          0 :     return FALSE;
     977                 :            :                 
     978                 :          0 :   curcol = sprintf( dump_buf, "Int : %5d [%d]", Player.iq, Player.maxiq );
     979                 :          0 :   cp = strrchr( dump_buf, '\0' );
     980         [ #  # ]:          0 :   for ( ; curcol < 26; curcol++ )
     981                 :          0 :     *cp++ = ' ';
     982                 :          0 :   sprintf( cp, "Carry    : %-10d          Speed   : %d.%d\n",
     983                 :          0 :            Player.itemweight, 5 / Player.speed, 500 / Player.speed % 100 );
     984         [ #  # ]:          0 :   if ( !dump( dumpfile, dump_buf, TRUE ) )
     985                 :          0 :     return FALSE;
     986                 :            :                 
     987                 :          0 :   curcol = sprintf( dump_buf, "Pow : %5d [%d]", Player.pow, Player.maxpow );
     988                 :          0 :   cp = strrchr( dump_buf, '\0' );
     989         [ #  # ]:          0 :   for ( ; curcol < 26; curcol++ )
     990                 :          0 :     *cp++ = ' ';
     991                 :          0 :   sprintf( cp, "Capacity : %d\n\n", Player.maxweight );
     992         [ #  # ]:          0 :   if ( !dump( dumpfile, dump_buf, TRUE ) )
     993                 :          0 :     return FALSE;
     994                 :            :                 
     995                 :          0 :   total_balance = 0;
     996         [ #  # ]:          0 :   for( account = bank; account; account = account->next_account )
     997                 :            :     {
     998         [ #  # ]:          0 :       if ( account->player )
     999                 :          0 :         total_balance += account->balance;
    1000                 :            :     }
    1001                 :            :                 
    1002                 :          0 :   sprintf( dump_buf, "Cash (carried/bank) : %ld / %ld\n", Player.cash, total_balance );
    1003         [ #  # ]:          0 :   if ( !dump( dumpfile, dump_buf, TRUE ) )
    1004                 :          0 :     return FALSE;
    1005                 :            :                 
    1006                 :          0 :   sprintf( dump_buf, "Current Point Total : %ld\n", calc_points() );
    1007         [ #  # ]:          0 :   if ( !dump( dumpfile, dump_buf, TRUE ) )
    1008                 :          0 :     return FALSE;
    1009                 :            :                 
    1010                 :          0 :   sprintf( dump_buf, "Elapsed Game Time   : %s\n\n", elapsed_time_string( Time ) );
    1011         [ #  # ]:          0 :   if ( !dump( dumpfile, dump_buf, TRUE ) )
    1012                 :          0 :     return FALSE;
    1013                 :            :                 
    1014                 :          0 :   sprintf( dump_buf, "[Verification: %8.8lx]\n\n", dumpcheck );
    1015         [ #  # ]:          0 :   if ( !dump( dumpfile, dump_buf, FALSE ) )
    1016                 :          0 :     return FALSE;
    1017                 :            :                 
    1018                 :          0 :   return TRUE;
    1019                 :            : }
    1020                 :            : 
    1021                 :          0 : short dump( FILE *dumpfile, char *s, short do_check )
    1022                 :            : {
    1023         [ #  # ]:          0 :   if ( do_check )
    1024                 :            :     {
    1025         [ #  # ]:          0 :       if( !build_check( &dumpcheck, s ) )
    1026                 :          0 :         return FALSE;
    1027                 :            :     }
    1028                 :            :                 
    1029         [ #  # ]:          0 :   if ( EOF == fputs( s, dumpfile ) )
    1030                 :            :     {
    1031                 :          0 :       fclose( dumpfile );
    1032                 :          0 :       why = "failed write";
    1033                 :          0 :       return FALSE;
    1034                 :            :     }
    1035                 :            :         
    1036                 :          0 :   return TRUE;
    1037                 :            : }
    1038                 :            : 
    1039                 :          0 : short build_check( long *check, char *s )
    1040                 :            : {
    1041                 :          0 :   int count = 0;
    1042                 :          0 :   char *cp = s;
    1043                 :            :         
    1044                 :            :   /* build checksum of all printing characters in s, while rotating */
    1045                 :            :   /* the partial checksum left one bit for each character added */
    1046         [ #  # ]:          0 :   while ( *cp )
    1047                 :            :     {
    1048         [ #  # ]:          0 :       if ( isgraph( *cp ) )
    1049                 :            :         {
    1050         [ #  # ]:          0 :           if ( *check < 0 )
    1051                 :            :             {
    1052                 :          0 :               (*check) <<= 1;
    1053                 :          0 :               (*check)++;
    1054                 :            :             }
    1055                 :            :           else
    1056                 :            :             {
    1057                 :          0 :               (*check) <<= 1;
    1058                 :            :             }
    1059                 :          0 :           (*check) += ( (long)(*cp) & 0xff );
    1060                 :            :         }
    1061                 :            :                 
    1062                 :          0 :       cp++;
    1063         [ #  # ]:          0 :       if ( ++count > 80 )
    1064                 :            :         {
    1065                 :          0 :           why = "checksum unterminated string";
    1066                 :          0 :           return FALSE;
    1067                 :            :         }
    1068                 :            :     }
    1069                 :            :         
    1070                 :          0 :   return TRUE;
    1071                 :            : }
    1072                 :            : 
    1073                 :          0 : int alignment_level_index( int alignment )
    1074                 :            : {
    1075                 :          0 :   alignment = abs( alignment );
    1076                 :            :         
    1077         [ #  # ]:          0 :   if ( !alignment )
    1078                 :          0 :     return 0;
    1079         [ #  # ]:          0 :   else if ( alignment < 10 )
    1080                 :          0 :     return 1;
    1081         [ #  # ]:          0 :   else if ( alignment < 50 )
    1082                 :          0 :     return 2;
    1083         [ #  # ]:          0 :   else if ( alignment < 100 )
    1084                 :          0 :     return 3;
    1085         [ #  # ]:          0 :   else if ( alignment < 200 )
    1086                 :          0 :     return 4;
    1087         [ #  # ]:          0 :   else if ( alignment < 400 )
    1088                 :          0 :     return 5;
    1089         [ #  # ]:          0 :   else if ( alignment < 800 )
    1090                 :          0 :     return 6;
    1091                 :            :   else
    1092                 :          0 :     return 7;
    1093                 :            : }
    1094                 :            : 
    1095                 :            : char *alignment_level[ 8 ] =
    1096                 :            : {
    1097                 :            :   "Neutral, embodying the Cosmic Balance",
    1098                 :            :   "Neutral, tending toward ",
    1099                 :            :   "Neutral-",
    1100                 :            :   "",
    1101                 :            :   "Servant of ",
    1102                 :            :   "Master of ",
    1103                 :            :   "The Essence of ",
    1104                 :            :   "The Ultimate Avatar of "
    1105                 :            : };
    1106                 :            : 
    1107                 :          0 : char *alignment_string( int alignment )
    1108                 :            : {
    1109                 :          0 :   strcpy( Str3, alignment_level[ alignment_level_index( alignment ) ] );
    1110                 :            :                 
    1111         [ #  # ]:          0 :   if ( alignment < 0 )
    1112                 :          0 :     strcat( Str3, "Chaos" );
    1113         [ #  # ]:          0 :   else if ( alignment > 0 )
    1114                 :          0 :     strcat( Str3, "Law" );
    1115                 :            :                 
    1116                 :          0 :   return Str3;
    1117                 :            : }
    1118                 :            : 
    1119                 :          0 : char *elapsed_time_string( long minutes )
    1120                 :            : {
    1121                 :            :   long hours, days, months, years;
    1122                 :            :         
    1123                 :          0 :   hours = minutes / 60;
    1124                 :          0 :   days = hours / 24;
    1125                 :          0 :   months = days / 30;
    1126                 :          0 :   years = months / 12;
    1127                 :            :         
    1128                 :          0 :   minutes %= 60;
    1129                 :          0 :   hours %= 24;
    1130                 :          0 :   days %= 30;
    1131                 :          0 :   months %= 12;
    1132                 :            :         
    1133                 :          0 :   Str3[ 0 ] = '\0';
    1134                 :            :         
    1135         [ #  # ]:          0 :   if ( years )
    1136                 :            :     {
    1137                 :          0 :       sprintf( Str2, "%ld years, ", years );
    1138                 :          0 :       strcat( Str3, Str2 );
    1139                 :            :     }
    1140                 :            :         
    1141 [ #  # ][ #  # ]:          0 :   if ( years || months )
    1142                 :            :     {
    1143                 :          0 :       sprintf( Str2, "%ld months, ", months );
    1144                 :          0 :       strcat( Str3, Str2 );
    1145                 :            :     }
    1146                 :            :         
    1147 [ #  # ][ #  # ]:          0 :   if ( years || months || days )
                 [ #  # ]
    1148                 :            :     {
    1149                 :          0 :       sprintf( Str2, "%ld days, ", days );
    1150                 :          0 :       strcat( Str3, Str2 );
    1151                 :            :     }
    1152                 :            :         
    1153 [ #  # ][ #  # ]:          0 :   if ( years || months || days || hours )
         [ #  # ][ #  # ]
    1154                 :            :     {
    1155                 :          0 :       sprintf( Str2, "%ld hours, ", hours );
    1156                 :          0 :       strcat( Str3, Str2 );
    1157                 :            :     }
    1158                 :            :         
    1159 [ #  # ][ #  # ]:          0 :   if ( years || months || days || hours || minutes )
         [ #  # ][ #  # ]
                 [ #  # ]
    1160                 :            :     {
    1161                 :          0 :       sprintf( Str2, "%ld minutes", minutes );
    1162                 :          0 :       strcat( Str3, Str2 );
    1163                 :            :     }
    1164                 :            :         
    1165                 :          0 :   return Str3;
    1166                 :            : }
    1167                 :            : 
    1168                 :          0 : char *legion_rank_string( int rank )
    1169                 :            : {
    1170                 :          0 :   return legion_ranks[ rank ];
    1171                 :            : }
    1172                 :            : 
    1173                 :          0 : char *arena_rank_string( int rank )
    1174                 :            : {
    1175         [ #  # ]:          0 :   if ( rank < 0 )
    1176                 :          0 :     return arena_ranks[ 0 ];
    1177                 :            :   else
    1178                 :          0 :     return arena_ranks[ rank ];
    1179                 :            : }
    1180                 :            : 
    1181                 :          0 : char *college_rank_string( int rank )
    1182                 :            : {
    1183                 :          0 :   return college_ranks[ rank ];
    1184                 :            : }
    1185                 :            : 
    1186                 :          0 : char *nobility_rank_string( int rank )
    1187                 :            : {
    1188                 :          0 :   return nobility_ranks[ rank ];
    1189                 :            : }
    1190                 :            : 
    1191                 :          0 : char *circle_rank_string( int rank )
    1192                 :            : {
    1193         [ #  # ]:          0 :   if ( rank < 0 )
    1194                 :          0 :     return circle_ranks[ 0 ];
    1195                 :            :   else
    1196                 :          0 :     return circle_ranks[ rank ];
    1197                 :            : }
    1198                 :            : 
    1199                 :          0 : char *order_rank_string( int rank )
    1200                 :            : {
    1201         [ #  # ]:          0 :   if ( rank < 0 )
    1202                 :          0 :     return order_ranks[ 0 ];
    1203                 :            :   else
    1204                 :          0 :     return order_ranks[ rank ];
    1205                 :            : }
    1206                 :            : 
    1207                 :          0 : char *thieves_rank_string( int rank )
    1208                 :            : {
    1209                 :          0 :   return thieves_ranks[ rank ];
    1210                 :            : }
    1211                 :            : 
    1212                 :          0 : char *priesthood_rank_string( int rank, int patron )
    1213                 :            : {
    1214                 :          0 :   strcpy( Str3, priesthood_ranks[ rank ] );
    1215                 :          0 :   strcat( Str3, patron_names[ patron ] );
    1216                 :          0 :   return Str3;
    1217                 :            : }
    1218                 :            : 
    1219                 :          0 : char *monk_rank_string(int rank)
    1220                 :            : {
    1221                 :          0 :   return monk_ranks[rank];
    1222                 :            : }
    1223                 :            : 

Generated by: LCOV version 1.11