Learn how easy it is to sync an existing GitHub or Google Code repo to a SourceForge project! See Demo

Close

[dcf4db]: creature.h Maximize Restore History

Download this file

creature.h    164 lines (150 with data), 3.4 kB

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
// creature.h: interface for the Ccreature class.
//
//////////////////////////////////////////////////////////////////////
#if !defined(AFX_CREATURE_H__540165B6_9B90_4BAC_8102_2D3C0FA0C672__INCLUDED_)
#define AFX_CREATURE_H__540165B6_9B90_4BAC_8102_2D3C0FA0C672__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
#include "structs.h"
#define IWD2_SPELLCOUNT (IWD2_SPSLOTNUM*9+9+3)
extern CString iwd2_spell_levels[IWD2_SPELLCOUNT];
typedef struct
{
long unknown;
long free;
} iwd2_trail;
class Ccreature
{
private:
int fhandle;
int startpoint;
int maxlen;
int fullsize;
public:
int ischr;
int revision;
int slotcount;
creature_header header;
creature_iwd2_header iwd2header;
creature_iwd_header iwdheader;
creature_pst_header pstheader;
character_header chrheader;
character_iwd2_header chriwd2header;
creature_itemslots itemslots;
creature_book *books;
creature_select *selects;
creature_memory *memos;
creature_effect *effects;
feat_block *oldeffects;
creature_item *items;
char *pst_overlay_data;
creature_iwd2_spell *iwd2_spells[IWD2_SPELLCOUNT]; //7*9 spell, 9 domain, innates, shapes, songs
long iwd2_counts[IWD2_SPELLCOUNT];
iwd2_trail iwd2_free[IWD2_SPELLCOUNT];
int bookcount;
int selectcount;
int memocount;
int pst_overlay_size;
int effectcount;
int itemcount;
int m_changed;
int m_savechanges;
Ccreature();
virtual ~Ccreature();
int ReadCreatureFromFile(int fhandle, long maxlen);
long RetrieveNameRef(int fh);
int RetrieveCreData(int fh, creature_data &credata);
void SetupCharacter(int fullsize);
int WriteCreatureToFile(int fhandle, int calculate);
//int WriteCharacterToFile(int fhandle, int calculate);
inline void KillBooks()
{
if(books)
{
delete[] books;
books=NULL;
bookcount=0;
}
}
inline void KillSelects()
{
if(selects)
{
delete[] selects;
selects=NULL;
selectcount=0;
}
}
inline void KillMemos()
{
if(memos)
{
delete[] memos;
memos=NULL;
memocount=0;
}
}
inline void KillEffects()
{
if(effects)
{
delete[] effects;
}
if(oldeffects)
{
delete [] oldeffects;
}
effects=NULL;
oldeffects=NULL;
effectcount=0;
}
inline void KillItems()
{
if(items)
{
delete[] items;
items=NULL;
itemcount=0;
}
}
inline void KillPstOverlay()
{
if(pst_overlay_data)
{
delete[] pst_overlay_data;
pst_overlay_data = NULL;
pst_overlay_size = 0;
}
}
inline void KillIwd2Spells()
{
int i;
for(i=0;i<IWD2_SPELLCOUNT;i++)
{
if(iwd2_spells[i])
{
delete [] iwd2_spells[i];
iwd2_spells[i]=NULL;
iwd2_counts[i]=0;
}
}
}
private:
int fix_items();
int adjust_actpoint(long offset);
int handle_iwd2_spells(int position, long offset, long count);
int handle_iwd2();
int write_iwd2_spells();
int calculate_iwd2_spells(int position, long &offset, long &maxcount);
int calculate_iwd2();
inline long myseek(long pos)
{
return lseek(fhandle, pos+startpoint,SEEK_SET)-startpoint;
}
inline long actpoint()
{
return tell(fhandle)-startpoint;
}
};
#endif // !defined(AFX_CREATURE_H__540165B6_9B90_4BAC_8102_2D3C0FA0C672__INCLUDED_)