forked from aburch/simutrans
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathware_besch.h
142 lines (119 loc) · 2.73 KB
/
ware_besch.h
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
133
134
135
136
137
138
139
140
141
142
/*
* Copyright (c) 1997 - 2002 by Volker Meyer & Hansjörg Malthaner
*
* This file is part of the Simutrans project under the artistic licence.
*/
#ifndef __WARE_BESCH_H
#define __WARE_BESCH_H
#include "obj_besch_std_name.h"
#include "../simcolor.h"
#include "../utils/checksum.h"
class checksum_t;
/*
* Autor:
* Volker Meyer
*
* Kindknoten:
* 0 Name
* 1 Copyright
* 2 Text Maßeinheit
*/
class ware_besch_t : public obj_besch_std_name_t {
friend class good_reader_t;
friend class warenbauer_t;
/*
* The base value is the one for multiplier 1000.
*/
uint16 value;
uint16 base_value;
/**
* Category of the good
* @author Hj. Malthaner
*/
uint8 catg;
/**
* total index, all ware with same catg_index will be compatible,
* including special freight
* assigned during registration
* @author prissi
*/
uint8 catg_index;
// used for inderect index (saves 3 bytes per ware_t!)
// assinged during registration
uint8 ware_index;
COLOR_VAL color;
/**
* Bonus for fast transport given in percent!
* @author Hj. Malthaner
*/
uint16 speed_bonus;
/**
* Weight in KG per unit of this good
* @author Hj. Malthaner
*/
uint16 weight_per_unit;
public:
// the measure for that good (crates, people, bags ... )
const char *get_mass() const
{
return get_child<text_besch_t>(2)->get_text();
}
uint16 get_preis() const { return value; }
/**
* @return speed bonus value of the good
* @author Hj. Malthaner
*/
uint16 get_speed_bonus() const { return speed_bonus; }
/**
* @return Category of the good
* @author Hj. Malthaner
*/
uint8 get_catg() const { return catg; }
/**
* @return Category of the good
* @author Hj. Malthaner
*/
uint8 get_catg_index() const { return catg_index; }
/**
* @return internal index (just a number, passenger, then mail, then something ... )
* @author prissi
*/
uint8 get_index() const { return ware_index; }
/**
* @return weight in KG per unit of the good
* @author Hj. Malthaner
*/
uint16 get_weight_per_unit() const { return weight_per_unit; }
/**
* @return Name of the category of the good
* @author Hj. Malthaner
*/
const char * get_catg_name() const;
/**
* Checks if this good can be interchanged with the other, in terms of
* transportability.
*
* Inline because called very often
*
* @author Hj. Malthaner
*/
bool is_interchangeable(const ware_besch_t *other) const
{
return catg_index == other->get_catg_index();
}
/**
* @return color for good table and waiting bars
* @author Hj. Malthaner
*/
COLOR_VAL get_color() const { return color; }
void calc_checksum(checksum_t *chk) const
{
chk->input(value);
chk->input(base_value);
chk->input(catg);
chk->input(catg_index);
chk->input(speed_bonus);
chk->input(weight_per_unit);
}
};
#endif