00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
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
00059
00060
00061
00062
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
00081 Uint32 inventory_count;
00082 ItemInfo *inventory[MAX_INVENTORY_SIZE];
00083
00084 Uint32 equipped[Constants::INVENTORY_COUNT];
00085
00086
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