File: groundobj.h

package info (click to toggle)
simutrans 111.2.2-1
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd, wheezy
  • size: 13,504 kB
  • ctags: 12,645
  • sloc: cpp: 101,849; ansic: 3,466; makefile: 694; sh: 44
file content (74 lines) | stat: -rw-r--r-- 1,792 bytes parent folder | download
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
/*
 * Copyright (c) 1997 - 2001 Hansjrg Malthaner
 *
 * This file is part of the Simutrans project under the artistic licence.
 * (see licence.txt)
 */

#ifndef dings_groundobj_h
#define dings_groundobj_h

#include "../tpl/stringhashtable_tpl.h"
#include "../tpl/vector_tpl.h"
#include "../besch/groundobj_besch.h"
#include "../simcolor.h"
#include "../dataobj/umgebung.h"

/**
 * Bume in Simutrans.
 * @author Hj. Malthaner
 */
class groundobj_t : public ding_t
{
private:
	// type of tree
	uint16 groundobjtype:12;
	uint16 season:4;

	image_id bild;
	uint16 age;	// in month

	// static for administration
	static stringhashtable_tpl<groundobj_besch_t *> besch_names;
	static vector_tpl<const groundobj_besch_t *> groundobj_typen;

public:
	static bool register_besch(groundobj_besch_t *besch);
	static bool alles_geladen();

	static const groundobj_besch_t *random_groundobj_for_climate(climate cl, hang_t::typ slope );

	// only the load save constructor should be called outside
	// otherwise I suggest use the plant tree function (see below)
	groundobj_t(karte_t *welt, loadsave_t *file);
	groundobj_t(karte_t *welt, koord3d pos, const groundobj_besch_t *);

	void rdwr(loadsave_t *file);

	// since the lookup of slopes is slow, image is cached
	image_id get_bild() const { return bild; }

	/**
	 * Berechnet Alter und Bild abhngig vom Alter
	 * @author Hj. Malthaner
	 */
	void calc_bild();

	const char *get_name() const {return "Groundobj";}
	typ get_typ() const { return groundobj; }

	bool check_season(const long delta_t);

	void zeige_info();

	void info(cbuffer_t & buf) const;

	void entferne(spieler_t *sp);

	const groundobj_besch_t* get_besch() const { return groundobj_typen[groundobjtype]; }

	void * operator new(size_t s);
	void operator delete(void *p);
};

#endif