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    : ONATIONA.H
22 //Description : Object nation array
23 
24 #ifndef __ONATIONA_H
25 #define __ONATIONA_H
26 
27 #ifndef __ODYNARRB_H
28 #include <ODYNARRB.h>
29 #endif
30 
31 #ifndef __ONATION_H
32 #include <ONATION.h>
33 #endif
34 
35 #include <storage_constants.h>
36 
37 //---- at least wait for 1 year after a nation is deleted before setting up a new nation. ---//
38 
39 #define NEW_NATION_INTERVAL_DAYS		365
40 
41 struct NewNationPara;
42 
43 //---------- Define class NationArray -----------//
44 
45 #pragma pack(1)
46 class NationArray : public DynArrayB
47 {
48 public:
49 	short  	nation_count;    // no. of nations, it's different from nation_array.size() which is a DynArrayB
50 	short  	ai_nation_count;
51 	int		last_del_nation_date;
52 	int		last_new_nation_date;
53 
54 	int		max_nation_population;		// the maximum population in a nation
55 	int		all_nation_population;		// total population of all nations.
56 
57    short		independent_town_count;
58 	short		independent_town_count_race_array[MAX_RACE];	// the no. of independent towns each race has
59 
60 	int		max_nation_units;
61 	int		max_nation_humans;
62 	int		max_nation_generals;
63 	int		max_nation_weapons;
64 	int		max_nation_ships;
65 	int		max_nation_spies;
66 
67 	int		max_nation_firms;
68 	int		max_nation_tech_level;
69 
70 	int		max_population_rating;
71 	int		max_military_rating;
72 	int		max_economic_rating;
73 	int		max_reputation;
74 	int		max_kill_monster_score;
75 	int		max_overall_rating;
76 
77 	short		max_population_nation_recno;
78 	short		max_military_nation_recno;
79 	short		max_economic_nation_recno;
80 	short		max_reputation_nation_recno;
81 	short		max_kill_monster_nation_recno;
82 	short		max_overall_nation_recno;
83 
84 	int  	   last_alliance_id;
85 	int  		nation_peace_days;			// continuous peace among nations
86 
87 	short  	player_recno;
88 	Nation* 	player_ptr;
89 
90 	char		nation_color_array[MAX_NATION+1];
91 	char		nation_power_color_array[MAX_NATION+2];
92 
93 	char		human_name_array[MAX_NATION][HUMAN_NAME_LEN+1];
94 
95 public:
96 	NationArray();
97 	~NationArray();
98 
99 	void		init();
100 	void 		deinit();
101 	int  		nation_class_size();
102 
103 	int  		new_nation(int,int,int,uint32_t=0);
104 	int		new_nation(NewNationPara &);
105 	int  		create_nation();
106 	void 		del_nation(int);
107 
108 	void 		disp_nation_color(int x, int y, int nationColor);
109 
110 	int 		can_form_new_ai_nation();
111 	void		update_statistic();
112 	void 		update_military_rating();
113 	void 		update_total_human_count();
114 
115 	void 		process();
116 	void 		next_month();
117 	void 		next_year();
118 
119 	int 		random_unused_race();
120 	int 		random_unused_color();
121 
122 	int  		write_file(File*);
123 	int  		read_file(File*);
124 
125 	void		set_human_name(int nationRecno, char* nameStr);
126 	char*		get_human_name(int nationNameId, int firstWordOnly=0);
127 
128 	//--------------------------------------//
129 
130 	#ifdef DYNARRAY_DEBUG_ELEMENT_ACCESS
131 		Nation* operator[](int recNo);
132 		Nation* operator~();
133 	#else
134 		Nation* operator[](int recNo)	{ return (Nation*) get_ptr(recNo); }
135 		Nation* operator~()				{ return player_ptr; }
136 	#endif
137 
is_deleted(int recNo)138 	int   	is_deleted(int recNo)    { return get_ptr(recNo) == NULL; }
139 
140 	Nation* get_unpacked_nation(int recNo);   // given a packed recno and return the unpacked nation ptr
141 	// ##### begin Gilbert 3/9 ######//
142 	char		should_attack(short attackingNation, short attackedNation);
143 	// ##### end Gilbert 3/9 ######//
144 	//### begin alex 12/9 ###//
145 	void			draw_profile();
146 	//#### end alex 12/9 ####//
147 };
148 #pragma pack()
149 
150 
151 // --------- define struct NewNationPara ----------//
152 
153 struct NewNationPara
154 {
155 	short nation_recno;
156 	uint32_t dp_player_id;
157 	short color_scheme;
158 	short race_id;
159 	char  player_name[HUMAN_NAME_LEN+1];
160 
initNewNationPara161 	void init(short n, uint32_t playerId, short scheme, short race, char *playerName)
162 	{
163 		nation_recno = n;
164 		dp_player_id = playerId;
165 		color_scheme = scheme;
166 		race_id = race;
167 		strcpy(player_name, playerName);
168 	}
169 };
170 
171 extern NationArray nation_array;
172 
173 //---------------------------------------------//
174 
175 #endif
176