Main Page | Class Hierarchy | Alphabetical List | Data Structures | Directories | File List | Data Fields

persist.h

00001 /***************************************************************************
00002                           persist.h  -  description
00003                              -------------------
00004     begin                : Sat May 3 2003
00005     copyright            : (C) 2003 by Gabor Torok
00006     email                : cctorok@yahoo.com
00007  ***************************************************************************/
00008 
00009 /***************************************************************************
00010  *                                                                         *
00011  *   This program is free software; you can redistribute it and/or modify  *
00012  *   it under the terms of the GNU General Public License as published by  *
00013  *   the Free Software Foundation; either version 2 of the License, or     *
00014  *   (at your option) any later version.                                   *
00015  *                                                                         *
00016  ***************************************************************************/
00017 
00018 #ifndef PERSIST_H
00019 #define PERSIST_H
00020 
00021 #include "constants.h"
00022 
00023 class Session;
00024 
00025 #define PERSIST_VERSION 7
00026 
00027 typedef struct _DiceInfo {
00028   Uint32 version;
00029   Uint32 count, sides, mod;
00030 } DiceInfo;
00031 
00032 typedef struct _ItemInfo {
00033   Uint32 version;
00034   Uint32 level;
00035   Uint8 rpgItem_name[255];
00036   Uint8 shape_name[255];
00037   Uint32 blocking, currentCharges, weight;
00038   Uint32 quality;
00039   Uint32 price;
00040   Uint32 action;
00041   Uint32 speed;
00042   Uint32 distance;
00043   Uint32 maxCharges;
00044   Uint32 duration;
00045   Uint8 spell_name[255];
00046   Uint32 containedItemCount;
00047   struct _ItemInfo *containedItems[MAX_CONTAINED_ITEMS];
00048 
00049   Uint32 bonus, damageMultiplier, cursed, magicLevel;
00050   Uint8 monster_type[255];
00051   Uint8 magic_school_name[255];
00052   DiceInfo *magicDamage;
00053   Uint8 stateMod[Constants::STATE_MOD_COUNT];
00054   Uint8 skillBonus[Constants::SKILL_COUNT];
00055 
00056 } ItemInfo;
00057 /*
00058 typedef struct _ContainedItemInfo {
00059   Uint32 version;
00060   Uint32 containedItemCount;
00061   ItemInfo containedItems[MAX_CONTAINED_ITEMS];
00062 } ContainedItemInfo;
00063 */
00064 
00065 typedef struct _CreatureInfo {
00066   Uint32 version;
00067   Uint8 name[255];
00068   Uint8 character_name[255];
00069   Uint32 character_model_info_index;
00070   Uint32 deityIndex;
00071   Uint8 monster_name[255];
00072   Uint32 hp, mp, exp, level, money, stateMod, protStateMod, x, y, z, dir;
00073   Uint32 speed, motion, armor, bonusArmor, thirst, hunger;
00074   Uint32 availableSkillPoints;
00075   Uint32 skills[Constants::SKILL_COUNT];
00076   Uint32 skillMod[Constants::SKILL_COUNT];
00077   Uint32 skillBonus[Constants::SKILL_COUNT];
00078   Uint32 portraitTextureIndex;
00079 
00080   // inventory
00081   Uint32 inventory_count;
00082   ItemInfo *inventory[MAX_INVENTORY_SIZE];
00083   //ContainedItemInfo containedItems[MAX_INVENTORY_SIZE];
00084   Uint32 equipped[Constants::INVENTORY_COUNT];
00085 
00086   // spells memorized ([school][spell]
00087   Uint32 spell_count;
00088   Uint8 spell_name[100][255];
00089   Uint8 quick_spell[12][255];
00090 } CreatureInfo;
00091 
00092 class Persist {
00093 public:
00094   static bool doesSaveGameExist(Session *session);
00095   static bool saveGame(Session *session);
00096   static bool loadGame(Session *session);
00097 
00098 protected:
00099   static void saveCreature(FILE *fp, CreatureInfo *info);
00100   static CreatureInfo *loadCreature(FILE *fp);
00101   static void deleteCreatureInfo( CreatureInfo *info );
00102 
00103   static void saveItem(FILE *fp, ItemInfo *item);
00104   static ItemInfo *loadItem(FILE *fp);
00105   static void deleteItemInfo( ItemInfo *info );
00106 
00107   static void saveDice( FILE *fp, DiceInfo *info );
00108   static DiceInfo *loadDice(FILE *fp);
00109   static void deleteDiceInfo( DiceInfo *info );
00110 };
00111 
00112 #endif

Generated on Thu Jun 16 21:50:43 2005 for scourge by  doxygen 1.4.0