~ubuntu-branches/ubuntu/raring/simutrans/raring-proposed

« back to all changes in this revision

Viewing changes to besch/writer/tree_writer.cc

  • Committer: Package Import Robot
  • Author(s): Ansgar Burchardt
  • Date: 2011-11-03 19:59:02 UTC
  • mfrom: (1.2.7)
  • Revision ID: package-import@ubuntu.com-20111103195902-uopgwf488mfctb75
Tags: 111.0-1
* New upstream release.
* debian/rules: Update get-orig-source target for new upstream release.
* Use xz compression for source and binary packages.
* Use override_* targets to simplify debian/rules.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
#include <string>
2
2
#include <stdlib.h>
3
3
#include "../../dataobj/tabfile.h"
4
 
#include "../baum_besch.h"
5
4
#include "obj_node.h"
6
5
#include "text_writer.h"
7
6
#include "imagelist2d_writer.h"
17
16
 
18
17
        // Hajodoc: Preferred height of this tree type
19
18
        // Hajoval: int (useful range: 0-14)
20
 
        baum_besch_t besch;
 
19
        climate_bits allowed_climates;
21
20
        const char *climate_str = obj.get("climates");
22
21
        if (climate_str) {
23
 
                besch.allowed_climates = get_climate_bits(climate_str);
 
22
                allowed_climates = get_climate_bits(climate_str);
24
23
        } else {
25
24
                printf("WARNING: old syntax without climates!\n");
26
 
                besch.allowed_climates = all_but_arctic_climate;
 
25
                allowed_climates = all_but_arctic_climate;
27
26
        }
28
27
        // seasons = 1: no seasons
29
28
        // seasons = 2: 0=summer, 1=winter
30
29
        // seasons = 4, normal four seasons, starting with summer
31
30
        // seasons = 5, normal for seasons and snowy image
32
 
        besch.number_of_seasons = obj.get_int("seasons", 1);
33
 
        besch.distribution_weight = obj.get_int("distributionweight", 3);
 
31
        uint8 const number_of_seasons   = obj.get_int("seasons", 1);
 
32
        uint8 const distribution_weight = obj.get_int("distributionweight", 3);
34
33
 
35
34
        slist_tpl<slist_tpl<string> > keys;
36
35
        for (unsigned int age = 0; age < 5; age++) {
37
36
                keys.append(slist_tpl<string>());
38
37
 
39
 
                for (int seasons = 0; seasons < besch.number_of_seasons; seasons++) {
 
38
                for (int seasons = 0; seasons < number_of_seasons; seasons++) {
40
39
                        char buf[40];
41
40
 
42
41
                        // Images of the tree
44
43
                        sprintf(buf, "image[%d][%d]", age, seasons);
45
44
 
46
45
                        string str = obj.get(buf);
47
 
                        if (str.size() == 0) {
 
46
                        if (str.empty()) {
48
47
                                // else missing image
49
48
                                printf("*** FATAL ***:\nMissing %s!\n", buf); fflush(NULL);
50
49
                                exit(0);
55
54
        imagelist2d_writer_t::instance()->write_obj(fp, node, keys);
56
55
 
57
56
        // Hajo: write version data
58
 
        node.write_uint16(fp, 0x8002,                             0);
59
 
 
60
 
        node.write_uint16(fp, (uint16) besch.allowed_climates,    2);
61
 
        node.write_uint8 (fp, (uint8)  besch.distribution_weight, 4);
62
 
        node.write_uint8 (fp, (uint8)  besch.number_of_seasons,   5);
 
57
        node.write_uint16(fp, 0x8002,              0);
 
58
        node.write_uint16(fp, allowed_climates,    2);
 
59
        node.write_uint8( fp, distribution_weight, 4);
 
60
        node.write_uint8( fp, number_of_seasons,   5);
63
61
 
64
62
        node.write(fp);
65
63
}