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    : OPLANT.H
22 //Description : Header file of object PlantRes
23 //Owner       : Gilbert
24 
25 #ifndef __OPLANT_H
26 #define __OPLANT_H
27 
28 #ifndef __ORESDB_H
29 #include <ORESDB.h>
30 #endif
31 
32 //------------- Define climate zone ------------//
33 
34 enum { ZONE_TROPICAL =1,
35 		 ZONE_TEMPERATE=2
36 	  };
37 
38 //------------ Define struct PlantRec ---------------//
39 
40 struct PlantRec
41 {
42 	enum { CODE_LEN=8, ZONE_LEN=1, TERA_TYPE_LEN=2, FIRST_BITMAP_LEN=3, BITMAP_COUNT_LEN=3 };
43 
44 	char code[CODE_LEN];
45 	char climate_zone[ZONE_LEN];
46 
47 	char tera_type1[TERA_TYPE_LEN];
48 	char tera_type2[TERA_TYPE_LEN];
49 	char tera_type3[TERA_TYPE_LEN];
50 
51 	char first_bitmap[FIRST_BITMAP_LEN];
52 	char bitmap_count[BITMAP_COUNT_LEN];
53 };
54 
55 //------------ Define struct PlantBitmapRec ---------------//
56 
57 struct PlantBitmapRec
58 {
59 	enum { PLANT_LEN=8, SIZE_LEN=2, OFFSET_LEN=3, FILE_NAME_LEN=8, BITMAP_PTR_LEN=4 };
60 
61 	char plant[PLANT_LEN];
62 	char size[SIZE_LEN];
63 
64 	char offset_x[OFFSET_LEN];
65 	char offset_y[OFFSET_LEN];
66 
67 	char town_age;
68 
69 	char file_name[FILE_NAME_LEN];
70 	char bitmap_ptr[BITMAP_PTR_LEN];
71 };
72 
73 //------------- Define struct PlantInfo --------------//
74 
75 struct PlantInfo
76 {
77 	char	climate_zone;
78 	char	tera_type[3];
79 
80 	short first_bitmap;
81 	short bitmap_count;
82 };
83 
84 //------------- Define struct PlantBitmap -------------//
85 
86 struct PlantBitmap
87 {
88 public:
89 	char  size;
90 	short offset_x, offset_y;
91 	char	town_age;
92 
93 	short bitmap_width, bitmap_height;
94 	char* bitmap_ptr;
95 
96 public:
97 	void	draw(int xLoc, int yLoc);
98 	void 	draw_at(int xLoc, int yLoc);
99 };
100 
101 //----------- Define class PlantRes ---------------//
102 
103 class PlantRes
104 {
105 public:
106 	short    	 plant_count;
107 	short			 plant_bitmap_count;
108 
109 	PlantInfo* 	 plant_info_array;
110 	PlantBitmap* plant_bitmap_array;
111 	short*		 scan_id_array;				// a buffer for scaning
112 
113 	char			 plant_map_color;
114 
115 	char	   	 init_flag;
116 	ResourceDb	 res_bitmap;
117 
118 public:
119 	PlantRes();
120 
121 	void 		 	 init();
122 	void 		 	 deinit();
123 
124 	int 			 scan(int climateZone, int teraType, int townAge);
125 
126 	short			 plant_recno(short bitmapId);
127 
128 	#ifdef DYNARRAY_DEBUG_ELEMENT_ACCESS
129 		PlantBitmap* get_bitmap(int bitmapId);
130 		PlantInfo*   operator[](int plantId);
131 	#else
get_bitmap(int bitmapId)132 		PlantBitmap* get_bitmap(int bitmapId) 	{ return plant_bitmap_array+bitmapId-1; }
133 		PlantInfo*   operator[](int plantId)	{ return plant_info_array+plantId-1; }
134 	#endif
135 
136 private:
137 	void 		    load_plant_info();
138 	void 		    load_plant_bitmap();
139 };
140 
141 extern PlantRes plant_res;
142 
143 //----------------------------------------------------//
144 
145 #endif
146