1 #include "api.h"
2 
3 /** @file api_obj_desc.cc exports goods descriptors - *_desc_t. */
4 
5 #include "api_obj_desc_base.h"
6 #include "api_simple.h"
7 #include "export_desc.h"
8 #include "get_next.h"
9 #include "../api_class.h"
10 #include "../api_function.h"
11 #include "../../descriptor/bridge_desc.h"
12 #include "../../descriptor/building_desc.h"
13 #include "../../descriptor/vehicle_desc.h"
14 #include "../../descriptor/goods_desc.h"
15 #include "../../descriptor/roadsign_desc.h"
16 #include "../../bauer/brueckenbauer.h"
17 #include "../../bauer/hausbauer.h"
18 #include "../../bauer/tunnelbauer.h"
19 #include "../../bauer/vehikelbauer.h"
20 #include "../../bauer/goods_manager.h"
21 #include "../../bauer/wegbauer.h"
22 #include "../../obj/roadsign.h"
23 #include "../../simhalt.h"
24 #include "../../simware.h"
25 #include "../../simworld.h"
26 
27 #define begin_enum(name)
28 #define end_enum()
29 #define enum_slot create_slot
30 
31 
32 using namespace script_api;
33 
34 
get_next_ware_desc(HSQUIRRELVM vm)35 SQInteger get_next_ware_desc(HSQUIRRELVM vm)
36 {
37 	return generic_get_next(vm, goods_manager_t::get_count());
38 }
39 
40 
get_goods_desc_index(HSQUIRRELVM vm)41 SQInteger get_goods_desc_index(HSQUIRRELVM vm)
42 {
43 	uint32 index = param<uint32>::get(vm, -1);
44 
45 	const char* name = "None"; // fall-back
46 	if (index < goods_manager_t::get_count()) {
47 		name = goods_manager_t::get_info(index)->get_name();
48 	}
49 	return push_instance(vm, "good_desc_x",  name);
50 }
51 
52 
are_equal(const obj_named_desc_t * a,const obj_named_desc_t * b)53 bool are_equal(const obj_named_desc_t* a, const obj_named_desc_t* b)
54 {
55 	return (a==b);
56 }
57 
58 
get_scaled_maintenance(const obj_desc_transport_related_t * desc)59 sint64 get_scaled_maintenance(const obj_desc_transport_related_t* desc)
60 {
61 	return desc ? welt->scale_with_month_length(desc->get_maintenance()) : 0;
62 }
63 
get_scaled_maintenance_vehicle(const vehicle_desc_t * desc)64 sint64 get_scaled_maintenance_vehicle(const vehicle_desc_t* desc)
65 {
66 	return desc ? welt->scale_with_month_length(desc->vehicle_desc_t::get_maintenance()) : 0;
67 }
68 
get_scaled_maintenance_building(const building_desc_t * desc)69 sint64 get_scaled_maintenance_building(const building_desc_t* desc)
70 {
71 	return desc ? welt->scale_with_month_length(desc->get_maintenance(welt)) : 0;
72 }
73 
74 
building_enables(const building_desc_t * desc,uint8 which)75 bool building_enables(const building_desc_t* desc, uint8 which)
76 {
77 	return desc ? desc->get_enabled() & which : 0;
78 }
79 
building_get_size(HSQUIRRELVM vm)80 SQInteger building_get_size(HSQUIRRELVM vm)
81 {
82 	const building_desc_t* desc = param<const building_desc_t*>::get(vm, 1);
83 	uint8 rotation = param<uint8>::get(vm, 2);
84 	if (desc) {
85 		koord size = desc->get_size(rotation);
86 		// no automatic coordinate transform please
87 		return push_instance(vm, "coord", size.x, size.y);
88 	}
89 	return -1;
90 }
91 
get_intro_retire(const obj_desc_timelined_t * desc,bool intro)92 mytime_t get_intro_retire(const obj_desc_timelined_t* desc, bool intro)
93 {
94 	return (uint32)(desc ? ( intro ? desc->get_intro_year_month() : desc->get_retire_year_month() ) : 1);
95 }
96 
97 
is_obsolete_future(const obj_desc_timelined_t * desc,mytime_t time,uint8 what)98 bool is_obsolete_future(const obj_desc_timelined_t* desc, mytime_t time, uint8 what)
99 {
100 	if (desc) {
101 		switch(what) {
102 			case 0: return desc->is_future(time.raw);
103 			case 1: return desc->is_retired(time.raw);
104 			case 2: return desc->is_available(time.raw);
105 			default: ;
106 		}
107 	}
108 	return false;
109 }
110 
111 
get_building_list(building_desc_t::btype type)112 const vector_tpl<const building_desc_t*>& get_building_list(building_desc_t::btype type)
113 {
114 	const vector_tpl<const building_desc_t*>* p = hausbauer_t::get_list(type);
115 
116 	static const vector_tpl<const building_desc_t*> dummy;
117 
118 	return p ? *p : dummy;
119 }
120 
121 
get_available_stations(building_desc_t::btype type,waytype_t wt,const goods_desc_t * freight)122 const vector_tpl<const building_desc_t*>& get_available_stations(building_desc_t::btype type, waytype_t wt, const goods_desc_t *freight)
123 {
124 	static vector_tpl<const building_desc_t*> dummy;
125 	dummy.clear();
126 
127 	switch(type) {
128 		case building_desc_t::depot:
129 		case building_desc_t::generic_stop:
130 		case building_desc_t::generic_extension:
131 		case building_desc_t::dock:
132 		case building_desc_t::flat_dock:
133 			break;
134 		default:
135 			return dummy;
136 	}
137 
138 	const vector_tpl<const building_desc_t*>* p = hausbauer_t::get_list(type);
139 
140 	// translate freight to enables-flags
141 	uint8 enables = 0;
142 	if (freight  &&  type != building_desc_t::depot) {
143 		switch(freight->get_catg_index()) {
144 			case goods_manager_t::INDEX_PAS:  enables = haltestelle_t::PAX;  break;
145 			case goods_manager_t::INDEX_MAIL: enables = haltestelle_t::POST; break;
146 			default:                          enables = haltestelle_t::WARE;
147 		}
148 	}
149 
150 	uint16 time = welt->get_timeline_year_month();
151 	FOR(vector_tpl<building_desc_t const*>, const desc, *p) {
152 		if(  desc->get_type()==type  &&  desc->get_extra()==(uint32)wt  &&  (enables==0  ||  (desc->get_enabled()&enables)!=0)  &&  desc->is_available(time)) {
153 			dummy.append(desc);
154 		}
155 	}
156 	return dummy;
157 }
158 
building_get_cost(const building_desc_t * desc)159 sint64 building_get_cost(const building_desc_t* desc)
160 {
161 	return desc->get_price(welt) * desc->get_x() * desc->get_y();
162 }
163 
building_is_terminus(const building_desc_t * desc)164 bool building_is_terminus(const building_desc_t *desc)
165 {
166 	return desc  &&  desc->get_type() == building_desc_t::generic_stop  &&  desc->get_all_layouts() == 4;
167 }
168 
can_be_first(const vehicle_desc_t * desc)169 bool can_be_first(const vehicle_desc_t *desc)
170 {
171 	return desc->can_follow(NULL);
172 }
173 
can_be_last(const vehicle_desc_t * desc)174 bool can_be_last(const vehicle_desc_t *desc)
175 {
176 	return desc->can_lead(NULL);
177 }
178 
is_coupling_allowed(const vehicle_desc_t * desc1,const vehicle_desc_t * desc2)179 bool is_coupling_allowed(const vehicle_desc_t *desc1, const vehicle_desc_t *desc2)
180 {
181 	return desc1->can_lead(desc2)  &&  desc2->can_follow(desc1);
182 }
183 
get_predecessors(const vehicle_desc_t * desc)184 const vector_tpl<const vehicle_desc_t*>& get_predecessors(const vehicle_desc_t *desc)
185 {
186 	static vector_tpl<const vehicle_desc_t*> dummy;
187 	dummy.clear();
188 	for(int i=0; i<desc->get_leader_count(); i++) {
189 		if (desc->get_leader(i)) {
190 			dummy.append(desc->get_leader(i));
191 		}
192 	}
193 	return dummy;
194 }
195 
get_successors(const vehicle_desc_t * desc)196 const vector_tpl<const vehicle_desc_t*>& get_successors(const vehicle_desc_t *desc)
197 {
198 	static vector_tpl<const vehicle_desc_t*> dummy;
199 	dummy.clear();
200 	for(int i=0; i<desc->get_trailer_count(); i++) {
201 		if (desc->get_trailer(i)) {
202 			dummy.append(desc->get_trailer(i));
203 		}
204 	}
205 	return dummy;
206 }
207 
get_available_vehicles(waytype_t wt)208 const vector_tpl<const vehicle_desc_t*>& get_available_vehicles(waytype_t wt)
209 {
210 	static vector_tpl<const vehicle_desc_t*> dummy;
211 
212 	bool use_obsolete = welt->get_settings().get_allow_buying_obsolete_vehicles();
213 	uint16 time = welt->get_timeline_year_month();
214 
215 	dummy.clear();
216 	slist_tpl<vehicle_desc_t const*> const& list = vehicle_builder_t::get_info(wt);
217 
218 	FOR(slist_tpl<vehicle_desc_t const*> const, i, list) {
219 		if (!i->is_retired(time)  ||  use_obsolete) {
220 			if (!i->is_future(time)) {
221 				dummy.append(i);
222 			}
223 		}
224 	}
225 	return dummy;
226 }
227 
get_power(const vehicle_desc_t * desc)228 uint32 get_power(const vehicle_desc_t *desc)
229 {
230 	return desc->get_power() * desc->get_gear();
231 }
232 
233 // export of building_desc_t::btype only here
234 namespace script_api {
235 	declare_enum_param(building_desc_t::btype, uint16, "building_desc_x::building_type");
236 };
237 
is_traffic_light(const roadsign_desc_t * d)238 bool is_traffic_light(const roadsign_desc_t *d)
239 {
240 	return !d->is_signal_type()  &&  d->is_traffic_light();
241 }
242 
243 
export_goods_desc(HSQUIRRELVM vm)244 void export_goods_desc(HSQUIRRELVM vm)
245 {
246 	/**
247 	 * Base class of all object descriptors.
248 	 */
249 	create_class<const obj_named_desc_t*>(vm, "obj_desc_x", "extend_get");
250 
251 	/**
252 	 * @return raw (untranslated) name
253 	 * @typemask string()
254 	 */
255 	register_method(vm, &obj_named_desc_t::get_name, "get_name");
256 	/**
257 	 * Checks if two object descriptor are equal.
258 	 * @param other
259 	 * @return true if this==other
260 	 */
261 	register_method(vm, &are_equal, "is_equal", true);
262 	/**
263 	 * @returns if object is still valid.
264 	 */
265 	export_is_valid<const obj_named_desc_t*>(vm); //register_function("is_valid")
266 	end_class(vm);
267 
268 	/**
269 	 * Base class of object descriptors with intro / retire dates.
270 	 */
271 	create_class<const obj_desc_timelined_t*>(vm, "obj_desc_time_x", "obj_desc_x");
272 
273 	/**
274 	 * @return introduction date of this object
275 	 */
276 	register_method_fv(vm, &get_intro_retire, "get_intro_date", freevariable<bool>(true), true);
277 	/**
278 	 * @return retirement date of this object
279 	 */
280 	register_method_fv(vm, &get_intro_retire, "get_retire_date", freevariable<bool>(false), true);
281 	/**
282 	 * @param time to test (0 means no timeline game)
283 	 * @return true if not available as intro date is in future
284 	 */
285 	register_method_fv(vm, &is_obsolete_future, "is_future", freevariable<uint8>(0), true);
286 	/**
287 	 * @param time to test (0 means no timeline game)
288 	 * @return true if not available as retirement date already passed
289 	 */
290 	register_method_fv(vm, &is_obsolete_future, "is_retired", freevariable<uint8>(1), true);
291 	/**
292 	 * @param time to test (0 means no timeline game)
293 	 * @return true if available: introduction and retirement date checked
294 	 */
295 	register_method_fv(vm, &is_obsolete_future, "is_available", freevariable<uint8>(2), true);
296 	end_class(vm);
297 
298 	/**
299 	 * Base class of object descriptors for transport related stuff.
300 	 */
301 	create_class<const obj_desc_transport_related_t*>(vm, "obj_desc_transport_x", "obj_desc_time_x");
302 	/**
303 	 * @returns monthly maintenance cost [in 1/100 credits] of one object of this type.
304 	 */
305 	register_local_method(vm, &get_scaled_maintenance, "get_maintenance");
306 	/**
307 	 * @returns cost [in 1/100 credits] to buy or build on piece or tile of this thing.
308 	 */
309 	register_method(vm, &obj_desc_transport_related_t::get_price, "get_cost");
310 	/**
311 	 * @returns way type, can be @ref wt_invalid.
312 	 */
313 	register_method(vm, &obj_desc_transport_related_t::get_waytype, "get_waytype");
314 	/**
315 	 * @returns top speed: maximal possible or allowed speed, in km/h.
316 	 */
317 	register_method(vm, &obj_desc_transport_related_t::get_topspeed, "get_topspeed");
318 
319 	end_class(vm);
320 
321 	/**
322 	 * Vehicle descriptors
323 	 */
324 	begin_desc_class(vm, "vehicle_desc_x", "obj_desc_transport_x", (GETDESCFUNC)param<const vehicle_desc_t*>::getfunc());
325 	/**
326 	 * @returns true if this vehicle can lead a convoy
327 	 */
328 	register_method(vm, &can_be_first, "can_be_first", true);
329 	/**
330 	 * @returns true if this vehicle can be the last of a convoy
331 	 */
332 	register_method(vm, &can_be_last, "can_be_last", true);
333 	/**
334 	 * @returns list of possible successors, if all are allowed then list is empty
335 	 */
336 	register_method(vm, &get_successors, "get_successors", true);
337 	/**
338 	 * @returns list of possible predecessors, if all are allowed then list is empty
339 	 */
340 	register_method(vm, &get_predecessors, "get_predecessors", true);
341 	/**
342 	 * @returns a list of all available vehicles at the current in-game-time
343 	 */
344 	STATIC register_method(vm, &get_available_vehicles, "get_available_vehicles", false, true);
345 	/**
346 	 * @returns the power of the vehicle (takes power and gear from pak-files into account)
347 	 */
348 	register_method(vm, &get_power, "get_power", true);
349 	/**
350 	 * @returns freight that can be transported (or null)
351 	 */
352 	register_method(vm, &vehicle_desc_t::get_freight_type, "get_freight");
353 	/**
354 	 * @returns capacity
355 	 */
356 	register_method(vm, &vehicle_desc_t::get_capacity, "get_capacity");
357 	/**
358 	 * @returns running cost in 1/100 credits per tile
359 	 */
360 	register_method(vm, &vehicle_desc_t::get_running_cost, "get_running_cost");
361 	/**
362 	 * @returns fixed cost in 1/100 credits per month
363 	 */
364 	register_method(vm, &get_scaled_maintenance_vehicle, "get_maintenance", true);
365 	/**
366 	 * @returns weight of the empty vehicle
367 	 */
368 	register_method(vm, &vehicle_desc_t::get_weight, "get_weight"); // in kg
369 	/**
370 	 * @returns lengths in @ref units::CARUNITS_PER_TILE
371 	 */
372 	register_method(vm, &vehicle_desc_t::get_length, "get_length"); // in CAR_UNITS_PER_TILE
373 	/**
374 	 * Checks if the coupling of @p first and @p second is possible in this order.
375 	 * @param first
376 	 * @param second
377 	 * @returns true if coupling is possible
378 	 */
379 	STATIC register_method(vm, is_coupling_allowed, "is_coupling_allowed", false, true);
380 	end_class(vm);
381 
382 	/**
383 	 * Object descriptors for trees.
384 	 */
385 	begin_desc_class(vm, "tree_desc_x", "obj_desc_x", (GETDESCFUNC)param<const tree_desc_t*>::getfunc());
386 	end_class(vm);
387 
388 	/**
389 	 * Object descriptors for buildings: houses, attractions, stations and extensions, depots, harbours.
390 	 */
391 	begin_desc_class(vm, "building_desc_x", "obj_desc_time_x", (GETDESCFUNC)param<const building_desc_t*>::getfunc());
392 
393 	/**
394 	 * @returns whether building is an attraction
395 	 */
396 	register_method(vm, &building_desc_t::is_attraction, "is_attraction");
397 	/**
398 	 * @param rotation
399 	 * @return size of building in the given @p rotation
400 	 * @typemask coord(integer)
401 	 */
402 	register_function(vm, building_get_size, "get_size", 2,  "x i");
403 	/**
404 	 * @return monthly maintenance cost
405 	 */
406 	register_method(vm, &get_scaled_maintenance_building, "get_maintenance", true);
407 	/**
408 	 * Price to build this building, takes size, level, and type into account.
409 	 * @return price [in 1/100 credits] to build this building
410 	 */
411 	register_method(vm, &building_get_cost, "get_cost", true);
412 	/**
413 	 * @return capacity
414 	 */
415 	register_method(vm, &building_desc_t::get_capacity, "get_capacity");
416 	/**
417 	 * @return whether building can be built underground
418 	 */
419 	register_method(vm, &building_desc_t::can_be_built_underground, "can_be_built_underground");
420 	/**
421 	 * @return whether building can be built above ground
422 	 */
423 	register_method(vm, &building_desc_t::can_be_built_aboveground, "can_be_built_aboveground");
424 	/**
425 	 * @return whether this station building can handle passengers
426 	 */
427 	register_method_fv(vm, &building_enables, "enables_pax", freevariable<uint8>(1), true);
428 	/**
429 	 * @return whether this station building can handle mail
430 	 */
431 	register_method_fv(vm, &building_enables, "enables_mail", freevariable<uint8>(2), true);
432 	/**
433 	 * @return whether this station building can handle freight
434 	 */
435 	register_method_fv(vm, &building_enables, "enables_freight", freevariable<uint8>(4), true);
436 	/// building types
437 	begin_enum("building_type")
438 	/// tourist attraction to be built in cities
439 	enum_slot(vm, "attraction_city", (uint8)building_desc_t::attraction_city, true);
440 	/// tourist attraction to be built outside cities
441 	enum_slot(vm, "attraction_land", (uint8)building_desc_t::attraction_land, true);
442 	/// monument, built only once per map
443 	enum_slot(vm, "monument", (uint8)building_desc_t::monument, true);
444 	/// factory
445 	enum_slot(vm, "factory", (uint8)building_desc_t::factory, true);
446 	/// townhall
447 	enum_slot(vm, "townhall", (uint8)building_desc_t::townhall, true);
448 	/// company headquarters
449 	enum_slot(vm, "headquarter", (uint8)building_desc_t::headquarters, true);
450 	/// harbour
451 	enum_slot(vm, "harbour", (uint8)building_desc_t::dock, true);
452 	/// harbour without a slope (buildable on flat ground beaches)
453 	enum_slot(vm, "flat_harbour", (uint8)building_desc_t::flat_dock, true);
454 	/// depot
455 	enum_slot(vm, "depot", (uint8)building_desc_t::depot, true);
456 	/// station
457 	enum_slot(vm, "station", (uint8)building_desc_t::generic_stop, true);
458 	/// station extension
459 	enum_slot(vm, "station_extension", (uint8)building_desc_t::generic_extension, true);
460 	end_enum();
461 	/**
462 	 * @returns building type
463 	 */
464 	register_method(vm, &building_desc_t::get_type, "get_type");
465 
466 	/**
467 	 * @returns way type, can be @ref wt_invalid.
468 	 */
469 	register_method(vm, &building_desc_t::get_finance_waytype, "get_waytype");
470 
471 	/**
472 	 * @returns headquarter level (or -1 if building is not headquarter)
473 	 */
474 	register_method(vm, &building_desc_t::get_headquarters_level, "get_headquarter_level");
475 
476 	/**
477 	 * Returns an array with all buildings of the given type.
478 	 * @warning If @p type is one of building_desc_x::harbour, building_desc_x::depot, building_desc_x::station, building_desc_x::station_extension then always the same list is generated.
479 	 *          You have to filter out e.g. station buildings yourself.
480 	 */
481 	STATIC register_method(vm, &get_building_list, "get_building_list", false, true);
482 	/**
483 	 * Returns an array of available station/extension/depot buildings.
484 	 * Entries are of type @ref building_desc_x.
485 	 * @param type building type from @ref building_desc_x::building_type
486 	 * @param wt waytype
487 	 * @param freight station should accept this freight (if null then return all buildings)
488 	 * @returns the list
489 	 */
490 	STATIC register_method(vm, &get_available_stations, "get_available_stations", false, true);
491 
492 	/**
493 	 * @returns true if this is a station building that can be used as terminus
494 	 */
495 	register_method(vm, &building_is_terminus, "is_terminus", true);
496 
497 	end_class(vm);
498 
499 	/**
500 	 * Object descriptors for ways.
501 	 */
502 	begin_desc_class(vm, "way_desc_x", "obj_desc_transport_x", (GETDESCFUNC)param<const way_desc_t*>::getfunc());
503 	/**
504 	 * @returns true if this way can be build on the steeper (double) slopes.
505 	 */
506 	register_method(vm, &way_desc_t::has_double_slopes, "has_double_slopes");
507 	/**
508 	 * @returns system type of the way, see @ref way_system_types.
509 	 */
510 	register_method(vm, &way_desc_t::get_styp, "get_system_type");
511 
512 	/**
513 	 * Generates a list of all ways available for building.
514 	 * @param wt waytype
515 	 * @param st system type of way
516 	 * @returns the list
517 	 */
518 	STATIC register_method(vm, way_builder_t::get_way_list, "get_available_ways", false, true);
519 
520 	end_class(vm);
521 
522 	/**
523 	 * Object descriptors for tunnels.
524 	 */
525 	begin_desc_class(vm, "tunnel_desc_x", "obj_desc_transport_x", (GETDESCFUNC)param<const tunnel_desc_t*>::getfunc());
526 	/**
527 	 * Returns a list with available tunnel types.
528 	 */
529 	STATIC register_method(vm, tunnel_builder_t::get_available_tunnels, "get_available_tunnels", false, true);
530 	end_class(vm);
531 
532 	/**
533 	 * Object descriptors for bridges.
534 	 */
535 	begin_desc_class(vm, "bridge_desc_x", "obj_desc_transport_x", (GETDESCFUNC)param<const bridge_desc_t*>::getfunc());
536 	/**
537 	 * @return true if this bridge can raise two level from flat terrain
538 	 */
539 	register_method(vm, &bridge_desc_t::has_double_ramp, "has_double_ramp");
540 	/**
541 	 * @return true if this bridge can start or end on a double slope
542 	 */
543 	register_method(vm, &bridge_desc_t::has_double_start, "has_double_start");
544 	/**
545 	 * @return maximal bridge length in tiles
546 	 */
547 	register_method(vm, &bridge_desc_t::get_max_length, "get_max_length");
548 	/**
549 	 * @return maximal bridge height
550 	 */
551 	register_method(vm, &bridge_desc_t::get_max_height, "get_max_height");
552 	/**
553 	 * Returns a list with available bridge types.
554 	 */
555 	STATIC register_method(vm, bridge_builder_t::get_available_bridges, "get_available_bridges", false, true);
556 
557 	end_class(vm);
558 
559 	/**
560 	 * Implements iterator to iterate through the list of all good types.
561 	 *
562 	 * Usage:
563 	 * @code
564 	 * local list = good_desc_list_x()
565 	 * foreach(good_desc in list) {
566 	 *     ... // good_desc is an instance of the good_desc_x class
567 	 * }
568 	 * @endcode
569 	 */
570 	create_class(vm, "good_desc_list_x", 0);
571 	/**
572 	 * Meta-method to be used in foreach loops. Do not call them directly.
573 	 */
574 	register_function(vm, get_next_ware_desc,  "_nexti",  2, "x o|i");
575 	/**
576 	 * Meta-method to be used in foreach loops. Do not call them directly.
577 	 */
578 	register_function(vm, get_goods_desc_index, "_get",    2, "xi");
579 
580 	end_class(vm);
581 
582 	/**
583 	 * Descriptor of goods and freight types.
584 	 */
585 	begin_desc_class(vm, "good_desc_x", "obj_desc_x", (GETDESCFUNC)param<const goods_desc_t*>::getfunc());
586 
587 	// dummy entry to create documentation of constructor
588 	/**
589 	 * Constructor.
590 	 * @param name raw name of the freight type.
591 	 * @typemask (string)
592 	 */
593 	// register_function( .., "constructor", .. )
594 
595 	create_slot(vm, "passenger", goods_manager_t::passengers, true);
596 	create_slot(vm, "mail",      goods_manager_t::mail,       true);
597 #ifdef DOXYGEN
598 	static good_desc_x passenger; ///< descriptor for passenger
599 	static good_desc_x mail;      ///< descriptor for mail
600 #endif
601 	/**
602 	 * @return freight category. 0=Passengers, 1=Mail, 2=None, >=3 anything else
603 	 */
604 	register_method(vm, &goods_desc_t::get_catg_index, "get_catg_index");
605 
606 	/**
607 	 * Checks if this good can be interchanged with the other, in terms of
608 	 * transportability.
609 	 */
610 	register_method(vm, &goods_desc_t::is_interchangeable, "is_interchangeable");
611 	/**
612 	 * @returns weight of one unit of this freight
613 	 */
614 	register_method(vm, &goods_desc_t::get_weight_per_unit, "get_weight_per_unit"); // in kg
615 
616 	/**
617 	 * Calculates transport revenue per tile and freight unit.
618 	 * Takes speedbonus into account.
619 	 * @param wt waytype of vehicle
620 	 * @param speedkmh actual achieved speed in km/h
621 	 * @returns revenue
622 	 */
623 	register_method(vm, &ware_t::calc_revenue, "calc_revenue", true);
624 	end_class(vm);
625 
626 	/**
627 	 * Descriptor of roadsigns and signals.
628 	 */
629 	begin_desc_class(vm, "sign_desc_x", "obj_desc_transport_x", (GETDESCFUNC)param<const roadsign_desc_t*>::getfunc());
630 
631 	/**
632 	 * @returns true if sign is one-way sign
633 	 */
634 	register_method(vm, &roadsign_desc_t::is_single_way, "is_one_way");
635 	/**
636 	 * @returns true if sign is private-way sign
637 	 */
638 	register_method(vm, &roadsign_desc_t::is_private_way, "is_private_way");
639 	/**
640 	 * @returns true if sign is traffic light
641 	 */
642 	register_method(vm, &is_traffic_light, "is_traffic_light", true);
643 	/**
644 	 * @returns true if sign is choose sign
645 	 */
646 	register_method(vm, &roadsign_desc_t::is_choose_sign, "is_choose_sign");
647 	/**
648 	 * @returns true if sign is signal
649 	 */
650 	register_method(vm, &roadsign_desc_t::is_simple_signal, "is_signal");
651 	/**
652 	 * @returns true if sign is pre signal (distant signal)
653 	 */
654 	register_method(vm, &roadsign_desc_t::is_pre_signal, "is_pre_signal");
655 	/**
656 	 * @returns true if sign is priority signal
657 	 */
658 	register_method(vm, &roadsign_desc_t::is_priority_signal, "is_priority_signal");
659 	/**
660 	 * @returns true if sign is long-block signal
661 	 */
662 	register_method(vm, &roadsign_desc_t::is_longblock_signal, "is_longblock_signal");
663 	/**
664 	 * @returns true if sign is end-of-choose sign
665 	 */
666 	register_method(vm, &roadsign_desc_t::is_end_choose_signal, "is_end_choose_signal");
667 	/**
668 	 * Returns a list with available bridge types.
669 	 * @param wt waytype
670 	 */
671 	STATIC register_method(vm, roadsign_t::get_available_signs, "get_available_signs", false, true);
672 
673 	end_class(vm);
674 
675 }
676