File: ORAWRES.h

package info (click to toggle)
7kaa 2.15.6%2Bds-2
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 131,312 kB
  • sloc: cpp: 134,790; asm: 3,523; ansic: 1,949; perl: 1,665; makefile: 1,181; sh: 126; pascal: 27
file content (132 lines) | stat: -rw-r--r-- 3,082 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
/*
 * Seven Kingdoms: Ancient Adversaries
 *
 * Copyright 1997,1998 Enlight Software Ltd.
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 */

//Filename    : ORAWRES.H
//Description : Header file of object RawRes

#ifndef __ORAWRES_H
#define __ORAWRES_H

#ifndef __ORES_H
#include <ORES.h>
#endif

#ifndef __ODYNARR_H
#include <ODYNARR.h>
#endif

//------------- define constant --------------//

#define MAX_RAW			 		    3
#define MAX_PRODUCT					 3
#define MAX_RAW_RESERVE_QTY	20000

//------------ define icon size -------------//

enum { RAW_SMALL_ICON_WIDTH=10,
		 RAW_SMALL_ICON_HEIGHT=10,
		 RAW_LARGE_ICON_WIDTH=32,
		 RAW_LARGE_ICON_HEIGHT=32
	  };

//----------- Define raw material types ---------//

enum { RAW_CLAY=1,
		 RAW_COPPER,
		 RAW_IRON,		 };

//------------ Define struct RawRec ---------------//

struct RawRec
{
	enum { NAME_LEN=12, TERA_TYPE_LEN=1 };

	char name[NAME_LEN];
	char tera_type[TERA_TYPE_LEN];
};

//------------- Define struct RawInfo --------------//

struct RawInfo
{
public:
	enum { NAME_LEN=20 };

	char	raw_id;
	char 	name[NAME_LEN+1];
	char  tera_type;

	DynArray raw_supply_firm_array;
	DynArray product_supply_firm_array;

public:
	RawInfo();

	void 		add_raw_supply_firm(short firmRecno);
	void 		add_product_supply_firm(short firmRecno);

	short		get_raw_supply_firm(short recNo) 		{ return *( (short*) raw_supply_firm_array.get(recNo) ); }
	short		get_product_supply_firm(short recNo) 	{ return *( (short*) product_supply_firm_array.get(recNo) ); }
};

//----------- Define class RawRes ---------------//

class RawRes
{
public:
	short    	raw_count;
	RawInfo* 	raw_info_array;

	char	   	init_flag;

	Resource    res_icon;

public:
	RawRes();

	void 		init();
	void 		deinit();

	void		next_day();
	void		update_supply_firm();

	void  	put_small_product_icon(int x, int y, int rawId);
	void		put_small_raw_icon(int x, int y, int rawId);
	const char*	product_name(int rawId);

	char* 	large_product_icon(int rawId)	{ return res_icon.read(rawId); }
	char* 	small_product_icon(int rawId) { return res_icon.read(MAX_RAW+rawId); }
	char* 	large_raw_icon(int rawId)		{ return res_icon.read(MAX_RAW*2+rawId); }
	char* 	small_raw_icon(int rawId)		{ return res_icon.read(MAX_RAW*3+rawId); }

	int  		write_file(File*);
	int  		read_file(File*);

	RawInfo* operator[](int rawId);      // pass rawId  as recno

private:
	void 		load_all_info();
};

extern RawRes raw_res;

//----------------------------------------------------//

#endif