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 
21 //Filename    : ORAWRES.H
22 //Description : Header file of object RawRes
23 
24 #ifndef __ORAWRES_H
25 #define __ORAWRES_H
26 
27 #ifndef __ORES_H
28 #include <ORES.h>
29 #endif
30 
31 #ifndef __ODYNARR_H
32 #include <ODYNARR.h>
33 #endif
34 
35 //------------- define constant --------------//
36 
37 #define MAX_RAW			 		    3
38 #define MAX_PRODUCT					 3
39 #define MAX_RAW_RESERVE_QTY	20000
40 
41 //------------ define icon size -------------//
42 
43 enum { RAW_SMALL_ICON_WIDTH=10,
44 		 RAW_SMALL_ICON_HEIGHT=10,
45 		 RAW_LARGE_ICON_WIDTH=32,
46 		 RAW_LARGE_ICON_HEIGHT=32
47 	  };
48 
49 //----------- Define raw material types ---------//
50 
51 enum { RAW_CLAY=1,
52 		 RAW_COPPER,
53 		 RAW_IRON,		 };
54 
55 //------------ Define struct RawRec ---------------//
56 
57 struct RawRec
58 {
59 	enum { NAME_LEN=12, TERA_TYPE_LEN=1 };
60 
61 	char name[NAME_LEN];
62 	char tera_type[TERA_TYPE_LEN];
63 };
64 
65 //------------- Define struct RawInfo --------------//
66 
67 struct RawInfo
68 {
69 public:
70 	enum { NAME_LEN=20 };
71 
72 	char	raw_id;
73 	char 	name[NAME_LEN+1];
74 	char  tera_type;
75 
76 	DynArray raw_supply_firm_array;
77 	DynArray product_supply_firm_array;
78 
79 public:
80 	RawInfo();
81 
82 	void 		add_raw_supply_firm(short firmRecno);
83 	void 		add_product_supply_firm(short firmRecno);
84 
get_raw_supply_firmRawInfo85 	short		get_raw_supply_firm(short recNo) 		{ return *( (short*) raw_supply_firm_array.get(recNo) ); }
get_product_supply_firmRawInfo86 	short		get_product_supply_firm(short recNo) 	{ return *( (short*) product_supply_firm_array.get(recNo) ); }
87 };
88 
89 //----------- Define class RawRes ---------------//
90 
91 class RawRes
92 {
93 public:
94 	short    	raw_count;
95 	RawInfo* 	raw_info_array;
96 
97 	char	   	init_flag;
98 
99 	Resource    res_icon;
100 
101 public:
102 	RawRes();
103 
104 	void 		init();
105 	void 		deinit();
106 
107 	void		next_day();
108 	void		update_supply_firm();
109 
110 	void  	put_small_product_icon(int x, int y, int rawId);
111 	void		put_small_raw_icon(int x, int y, int rawId);
112 	const char*	product_name(int rawId);
113 
large_product_icon(int rawId)114 	char* 	large_product_icon(int rawId)	{ return res_icon.read(rawId); }
small_product_icon(int rawId)115 	char* 	small_product_icon(int rawId) { return res_icon.read(MAX_RAW+rawId); }
large_raw_icon(int rawId)116 	char* 	large_raw_icon(int rawId)		{ return res_icon.read(MAX_RAW*2+rawId); }
small_raw_icon(int rawId)117 	char* 	small_raw_icon(int rawId)		{ return res_icon.read(MAX_RAW*3+rawId); }
118 
119 	int  		write_file(File*);
120 	int  		read_file(File*);
121 
122 	RawInfo* operator[](int rawId);      // pass rawId  as recno
123 
124 private:
125 	void 		load_all_info();
126 };
127 
128 extern RawRes raw_res;
129 
130 //----------------------------------------------------//
131 
132 #endif
133