Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 301 lines (215 sloc) 7.965 kb
4fc59837 »
2009-10-15 Add Enlight copyright notice.
1 /*
2 * Seven Kingdoms: Ancient Adversaries
3 *
4 * Copyright 1997,1998 Enlight Software Ltd.
5 *
6 * This program is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation, either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
18 *
19 */
20
6dfe1552 »
2009-09-20 Switch files to unix format.
21 //Filename : OFIRMRES.H
22 //Description : Header file of object FirmRes
23
24 #ifndef __OFIRMRES_H
25 #define __OFIRMRES_H
26
27 #ifndef __GAMEDEF_H
43eb76fb »
2009-09-15 Fix case sensitivity of all include files.
28 #include <GAMEDEF.h>
6dfe1552 »
2009-09-20 Switch files to unix format.
29 #endif
30
31 #ifndef __OFIRM_H
43eb76fb »
2009-09-15 Fix case sensitivity of all include files.
32 #include <OFIRM.h>
6dfe1552 »
2009-09-20 Switch files to unix format.
33 #endif
34
35 #ifndef __ORESDB_H
43eb76fb »
2009-09-15 Fix case sensitivity of all include files.
36 #include <ORESDB.h>
6dfe1552 »
2009-09-20 Switch files to unix format.
37 #endif
38
39 //------- Define constant ----------//
40
41 #define MAX_FIRM_FRAME 11 // Maximum frames for firm animation
42
43 #define MAX_FIRM_LOC_WIDTH 4 // Maximum no. of locations a firm can occupy
44 #define MAX_FIRM_LOC_HEIGHT 4
45
46 //------------- Firm Mode ------------//
47
48 enum { FIRM_UNDER_CONSTRUCTION='U', // definitions of FirmBuild::mode
49 FIRM_IDLE='I',
50 FIRM_ACTIVE='A',
51 };
52
53 //------------ Define struct FirmRec ---------------//
54
55 struct FirmRec
56 {
57 enum { CODE_LEN=8, NAME_LEN=20, SHORT_NAME_LEN=12, TITLE_LEN=10, FIRST_BUILD_LEN=3, BUILD_COUNT_LEN=3,
58 HIT_POINTS_LEN=5, COST_LEN=5 };
59
60 char code[CODE_LEN];
61 char name[NAME_LEN];
62 char short_name[SHORT_NAME_LEN];
63
64 char overseer_title[TITLE_LEN];
65 char worker_title[TITLE_LEN];
66
67 char tera_type;
68 char all_know; // whether all nations know how to build this firm in the beginning of the game
69 char live_in_town; // whether the workers of the firm lives in towns or not.
70
71 char hit_points[HIT_POINTS_LEN];
72
73 char is_linkable_to_town;
74
75 char setup_cost[COST_LEN];
76 char year_cost[COST_LEN];
77
78 char first_build[FIRST_BUILD_LEN];
79 char build_count[BUILD_COUNT_LEN];
80 };
81
82 //------------ Define struct FirmBuildRec ---------------//
83
84 struct FirmBuildRec
85 {
86 enum { FIRM_CODE_LEN=8, RACE_CODE_LEN=8, BITMAP_RECNO_LEN=5, FIRST_FRAME_LEN=5, FRAME_COUNT_LEN=2, RACE_ID_LEN=3 };
87
88 char firm_code[FIRM_CODE_LEN];
89 char race_code[RACE_CODE_LEN];
90
91 char animate_full_size;
92
93 char under_construction_bitmap_recno[BITMAP_RECNO_LEN];
94 // ##### begin Gilbert 18/10 ########//
95 char under_construction_bitmap_count[FRAME_COUNT_LEN];
96 // ##### end Gilbert 18/10 ########//
97 char idle_bitmap_recno[BITMAP_RECNO_LEN];
98 char ground_bitmap_recno[BITMAP_RECNO_LEN];
99
100 char first_frame[FIRST_FRAME_LEN];
101 char frame_count[FRAME_COUNT_LEN];
102
103 char race_id[RACE_ID_LEN];
104 };
105
106 //------------ Define struct FirmFrameRec ---------------//
107
108 struct FirmFrameRec
109 {
110 enum { FIRM_CODE_LEN=8, RACE_CODE_LEN=8, FRAME_ID_LEN=2, DELAY_LEN=2, FIRST_BITMAP_LEN=5, BITMAP_COUNT_LEN=2 };
111
112 char firm_code[FIRM_CODE_LEN];
113 char race_code[RACE_CODE_LEN];
114
115 char frame_id[FRAME_ID_LEN];
116
117 char delay[DELAY_LEN]; // unit: 1/10 second
118
119 char first_bitmap[FIRST_BITMAP_LEN];
120 char bitmap_count[BITMAP_COUNT_LEN];
121 };
122
123 //------------ Define struct FirmBitmapRec ---------------//
124
125 struct FirmBitmapRec
126 {
127 enum { FIRM_CODE_LEN=8, RACE_CODE_LEN=8, FRAME_ID_LEN=2, LOC_LEN=3, OFFSET_LEN=3, DELAY_LEN=2, FILE_NAME_LEN=8, BITMAP_PTR_LEN=4 };
128
129 char firm_code[FIRM_CODE_LEN];
130 char race_code[RACE_CODE_LEN];
131 char mode;
132
133 char frame_id[FRAME_ID_LEN];
134
135 char loc_width[LOC_LEN];
136 char loc_height[LOC_LEN];
137 char layer;
138
139 char offset_x[OFFSET_LEN];
140 char offset_y[OFFSET_LEN];
141
142 char delay[DELAY_LEN]; // unit: 1/10 second
143
144 char file_name[FILE_NAME_LEN];
145 char bitmap_ptr[BITMAP_PTR_LEN];
146 };
147
148 //------------- Define struct FirmInfo --------------//
149
e5fcbef3 »
2009-10-01 GameFile: Pack structures for saves, scenarios, and tutorials.
150 #pragma pack(1)
6dfe1552 »
2009-09-20 Switch files to unix format.
151 struct FirmInfo
152 {
153 enum { NAME_LEN=20, SHORT_NAME_LEN=12, TITLE_LEN=10 };
154
155 char firm_id;
156 char name[NAME_LEN+1];
157 char short_name[SHORT_NAME_LEN+1];
158
159 char overseer_title[TITLE_LEN+1];
160 char worker_title[TITLE_LEN+1];
161
162 char tera_type;
163 char buildable; // whether this building can be built by the player or it exists in the game since the beginning of the game. If setup_cost==0, this firm is not buildable
164 char live_in_town; // whether the workers of the firm lives in towns or not.
165 short max_hit_points;
166
167 char need_overseer;
168 char need_worker;
169 char need_unit() { return need_overseer || need_worker; }
170
171 short setup_cost;
172 short year_cost;
173
174 short first_build_id;
175 short build_count;
176
177 short loc_width;
178 short loc_height;
179
180 char firm_skill_id; // the id. of the skill that fits this firm
181 char firm_race_id; // only can be built and operated by this race
182
183 int can_build(int unitRecno);
184
185 char is_linkable_to_town;
186 int is_linkable_to_firm(int linkFirmId);
187
188 int default_link_status(int linkFirmId);
189
190 //---------- game vars -----------//
191
192 short total_firm_count; // total no. of this firm type on the map
193 short nation_firm_count_array[MAX_NATION];
194
195 char nation_tech_level_array[MAX_NATION];
196 int get_nation_tech_level(int nationRecno) { return nation_tech_level_array[nationRecno-1]; }
197 void set_nation_tech_level(int nationRecno, char techLevel) { nation_tech_level_array[nationRecno-1] = techLevel; }
198
199 public:
38becf2a »
2010-03-13 Fix method Firm::init for deprecated const char conversion.
200 int get_build_id(const char* buildCode);
6dfe1552 »
2009-09-20 Switch files to unix format.
201
202 void inc_nation_firm_count(int nationRecno);
203 void dec_nation_firm_count(int nationRecno);
204 };
e5fcbef3 »
2009-10-01 GameFile: Pack structures for saves, scenarios, and tutorials.
205 #pragma pack()
6dfe1552 »
2009-09-20 Switch files to unix format.
206
207 //------------- Define struct FirmBuild --------------//
208
209 struct FirmBuild
210 {
211 enum { BUILD_CODE_LEN=8 };
212
213 char build_code[BUILD_CODE_LEN+1]; // building code, either a race code or a custom code for each firm's own use, it is actually read from FirmBuildRec::race_code[]
214 char race_id;
215 char animate_full_size;
216
217 //----- info of the first frame -----//
218
219 char loc_width; // no. of locations it takes horizontally and vertically
220 char loc_height;
221
222 char min_offset_x, min_offset_y;
223 short max_bitmap_width, max_bitmap_height;
224
225 //----------- frame info ------------//
226
227 short frame_count;
228
229 short first_bitmap_array[MAX_FIRM_FRAME];
230 short bitmap_count_array[MAX_FIRM_FRAME];
231 short frame_delay_array[MAX_FIRM_FRAME]; // unit: 1/10 second
232
233 short under_construction_bitmap_recno; // bitmap recno of the firm that is under construction
234 // ##### begin Gilbert 18/10 ########//
235 short under_construction_bitmap_count;
236 // ##### end Gilbert 18/10 ########//
237 short idle_bitmap_recno; // bitmap recno of the firm that is idle
238 short ground_bitmap_recno;
239
240 short first_bitmap(int frameId) { return first_bitmap_array[frameId-1]; }
241 short bitmap_count(int frameId) { return bitmap_count_array[frameId-1]; }
242 short frame_delay(int frameId) { return frame_delay_array[frameId-1]; }
243 };
244
245 //------------- Define struct FirmBitmap --------------//
246
247 struct FirmBitmap
248 {
249 char* bitmap_ptr;
250 short width, height;
251
252 char loc_width; // no. of locations it takes horizontally and vertically
253 char loc_height;
254 char offset_x, offset_y;
255 char display_layer;
256
257 void draw_at(int absX, int absY, char *colorTable, int displayLayer);
258 };
259
260 //----------- Define class FirmRes ---------------//
261
262 class FirmRes
263 {
264 public:
265 short firm_count;
266 short firm_build_count;
267 short firm_bitmap_count;
268
269 FirmInfo* firm_info_array;
270 FirmBuild* firm_build_array;
271 FirmBitmap* firm_bitmap_array;
272
273 char init_flag;
274 ResourceDb res_bitmap;
275
276 public:
277 FirmRes();
278
279 void init();
280 void deinit();
281
282 int write_file(File* filePtr);
283 int read_file(File* filePtr);
284
285 FirmBitmap* get_bitmap(int bitmapId) { return firm_bitmap_array+bitmapId-1; }
286 FirmBuild* get_build(int buildId) { return firm_build_array+buildId-1; }
287 FirmInfo* operator[](int firmId);
288
289 private:
290 void load_firm_info();
291 void load_firm_build();
292 void load_firm_bitmap();
293 void process_firm_info();
294 };
295
296 extern FirmRes firm_res;
297
298 //----------------------------------------------------//
299
300 #endif
Something went wrong with that request. Please try again.