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 : OTOWNRES.H 22 //Description : Town town resource 23 24 #ifndef __OTOWNRES_H 25 #define __OTOWNRES_H 26 27 #ifndef __ALL_H 28 #include <ALL.h> 29 #endif 30 31 #ifndef __ORESDB_H 32 #include <ORESDB.h> 33 #endif 34 35 #ifndef __OTOWNREC_H 36 #include <OTOWNREC.h> 37 #endif 38 39 //--------- define game constants --------// 40 41 #define MAX_TOWN_LAYOUT_SLOT 25 42 #define POPULATION_PER_HOUSE 6 // no. of people per building 43 44 #define EFFECTIVE_TOWN_TOWN_DISTANCE 8 // The minimum distance between 2 towns 45 #define EFFECTIVE_FIRM_TOWN_DISTANCE 8 // maximum distance between the town and the base until it's no longer considered as command base of the town 46 #define EFFECTIVE_FIRM_FIRM_DISTANCE 8 // maximum distance between the town and the base until it's no longer considered as command base of the town 47 #define EFFECTIVE_POWER_DISTANCE 3 48 49 // population range of each building levels: 50 // level 1 building: 1-3, level 2 building: 4-6, level 3 building: 7-9 51 52 //------- values of TownSlot::build_type -------// 53 54 enum { TOWN_OBJECT_HOUSE=1, 55 TOWN_OBJECT_PLANT, 56 TOWN_OBJECT_FARM, 57 TOWN_OBJECT_FLAG, 58 }; 59 60 //------ define struct TownLayout --------// 61 62 struct TownLayout 63 { 64 char build_count; // no. of building in this layout 65 66 short first_slot_recno; 67 char slot_count; 68 69 char* ground_bitmap_ptr; 70 }; 71 72 //------ define struct TownSlot --------// 73 74 struct TownSlot 75 { 76 short base_x, base_y; 77 char build_type; // id. of the building type 78 char build_code; // building direction 79 }; 80 81 //------ define struct TownBuildType --------// 82 83 struct TownBuildType 84 { 85 short first_build_recno; 86 int build_count; 87 }; 88 89 //------ define struct TownName --------// 90 91 struct TownName 92 { 93 enum { NAME_LEN=15 }; 94 char name[NAME_LEN+1]; 95 }; 96 97 //------ define struct TownBuild --------// 98 99 struct TownBuild 100 { 101 public: 102 char build_type; // building type. e.g. house, wind mill, church 103 104 char race_id; 105 char build_code; 106 107 char* bitmap_ptr; 108 short bitmap_width; 109 short bitmap_height; 110 111 public: 112 void draw(int townRecno, int absBaseX, int absBaseY); 113 }; 114 115 //--------- Define class TownRes ----------// 116 117 class TownRes 118 { 119 public: 120 char init_flag; 121 int town_layout_count, town_slot_count; 122 int town_build_type_count, town_build_count, town_name_count; 123 124 TownLayout* town_layout_array; 125 TownSlot* town_slot_array; 126 TownBuildType* town_build_type_array; 127 TownBuild* town_build_array; 128 TownName* town_name_array; 129 unsigned char* town_name_used_array; // store the used_count separately from town_name_array to faciliate file saving 130 131 ResourceDb res_bitmap; 132 133 public: 134 TownRes(); 135 136 void init(); 137 void deinit(); 138 139 int scan_build(int slotId, int raceId); 140 141 char* get_name(int recNo); 142 int get_new_name_id(int raceId); 143 void free_name_id(int townNameId); 144 145 int write_file(File*); 146 int read_file(File*); 147 148 #ifdef DEBUG 149 TownLayout* get_layout(int recNo); 150 TownSlot* get_slot(int recNo); 151 TownBuildType* get_build_type(int recNo); 152 TownBuild* get_build(int recNo); 153 #else get_layout(int recNo)154 TownLayout* get_layout(int recNo) { return town_layout_array +recNo-1; }; get_slot(int recNo)155 TownSlot* get_slot(int recNo) { return town_slot_array +recNo-1; }; get_build_type(int recNo)156 TownBuildType* get_build_type(int recNo) { return town_build_type_array+recNo-1; }; get_build(int recNo)157 TownBuild* get_build(int recNo) { return town_build_array +recNo-1; }; 158 #endif 159 160 private: 161 void load_town_layout(); 162 void load_town_slot(); 163 void load_town_build_type(); 164 void load_town_build(); 165 void load_town_name(); 166 }; 167 168 extern TownRes town_res; 169 170 //------------------------------------------// 171 172 #endif 173