18
17
// Hajodoc: Preferred height of this tree type
19
18
// Hajoval: int (useful range: 0-14)
20
groundobj_besch_t besch;
19
climate_bits allowed_climates;
21
20
const char *climate_str = obj.get("climates");
23
besch.allowed_climates = get_climate_bits(climate_str);
22
allowed_climates = get_climate_bits(climate_str);
25
24
printf("WARNING: without climates!\n");
26
besch.allowed_climates = all_but_arctic_climate;
25
allowed_climates = all_but_arctic_climate;
28
27
// seasons = 1: no seasons
29
28
// otherwise the year will be devided by the (number_of_seasons-1)
30
29
// The last image is alsway the snow image!
31
besch.number_of_seasons = obj.get_int("seasons", 1);
30
uint8 const number_of_seasons = obj.get_int("seasons", 1);
33
32
// distribution probabiltion for all of this set
34
besch.distribution_weight = obj.get_int("distributionweight", 3);
33
uint16 const distribution_weight = obj.get_int("distributionweight", 3);
36
35
// how much for removal
37
besch.cost_removal = obj.get_int("cost", 0);
36
sint32 const cost_removal = obj.get_int("cost", 0);
39
38
// !=0 for moving objects (sheeps, birds)
40
besch.speed = obj.get_int("speed", 0);
39
uint16 const speed = obj.get_int("speed", 0);
42
41
// 1 for to allow trees on this objects
43
besch.trees_on_top = obj.get_int("trees_on_top", 1)!=0;
42
bool const trees_on_top = obj.get_int("trees_on_top", 1) != 0;
45
44
// waytype for moving stuff; meaningful air for birds, water for fish, does not matter for everything else
46
const char* waytype = obj.get("waytype");
47
besch.waytype = (waytype==0 || waytype[0]==0) ? ignore_wt : (waytype_t)get_waytype(waytype);
45
char const* const waytype_txt = obj.get("waytype");
46
waytype_t const waytype = waytype_txt && waytype_txt[0] != '\0' ? get_waytype(waytype_txt) : ignore_wt;
49
48
// now for the images
50
49
slist_tpl<slist_tpl<string> > keys;
53
52
for (unsigned int phase = 0; 1; phase++) {
54
53
keys.append(slist_tpl<string>());
56
for (int seasons = 0; seasons < besch.number_of_seasons; seasons++) {
55
for (int seasons = 0; seasons < number_of_seasons; seasons++) {
59
58
// Images of the tree
60
59
// age is 1..5 (usually five stages, seasons is the seaons
61
60
sprintf(buf, "image[%d][%d]", phase, seasons);
62
61
string str = obj.get(buf);
63
if (str.size() == 0) {
65
64
goto finish_images;
80
79
for (unsigned int dir = 0; dir<8; dir++) {
81
80
keys.append(slist_tpl<string>());
83
for (int seasons = 0; seasons < besch.number_of_seasons; seasons++) {
82
for (int seasons = 0; seasons < number_of_seasons; seasons++) {
86
85
// Images of the tree
87
86
// age is 1..5 (usually five stages, seasons is the seaons
88
87
sprintf(buf, "image[%s][%d]", dir_codes[dir], seasons);
89
88
string str = obj.get(buf);
90
if (str.size() == 0) {
91
90
printf("Missing images in moving groundobj (expected %s)!\n", buf );
92
91
dbg->fatal("groundobj_writer_t","Season image for season %i missing (%s)!",seasons);
99
98
imagelist2d_writer_t::instance()->write_obj(fp, node, keys);
101
100
// Hajo: write version data
102
node.write_uint16(fp, 0x8001, 0);
104
node.write_uint16(fp, (uint16) besch.allowed_climates, 2);
105
node.write_uint16(fp, (uint16) besch.distribution_weight, 4);
106
node.write_uint8 (fp, (uint8) besch.number_of_seasons, 6);
107
node.write_uint8 (fp, (uint8) besch.trees_on_top, 7);
108
node.write_uint16(fp, (uint16) besch.speed, 8);
109
node.write_uint16(fp, (uint16) besch.waytype, 10);
110
node.write_sint32(fp, (sint32) besch.cost_removal, 12);
101
node.write_uint16(fp, 0x8001, 0);
102
node.write_uint16(fp, allowed_climates, 2);
103
node.write_uint16(fp, distribution_weight, 4);
104
node.write_uint8 (fp, number_of_seasons, 6);
105
node.write_uint8 (fp, trees_on_top, 7);
106
node.write_uint16(fp, speed, 8);
107
node.write_uint16(fp, waytype, 10);
108
node.write_sint32(fp, cost_removal, 12);