forked from aburch/simutrans
-
Notifications
You must be signed in to change notification settings - Fork 1
/
simlinemgmt.h
130 lines (101 loc) · 2.24 KB
/
simlinemgmt.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
/*
* simroutemgmt.h
* part of the Simutrans project
* @author hsiegeln
* 01/12/2003
*/
#ifndef simlinemgmt_h
#define simlinemgmt_h
#include <string.h>
#include "simtypes.h"
#include "simline.h"
#include "linehandle_t.h"
#include "dataobj/loadsave.h"
#include "dataobj/translator.h"
#include "tpl/slist_tpl.h"
#include "simconvoi.h"
#include "simdebug.h"
class fahrplan_t;
#define UNVALID_LINE_ID ((uint16)(-1))
class simlinemgmt_t
{
public:
simlinemgmt_t(karte_t * welt, spieler_t *besitzer);
void destroy_all();
/*
* add a line
* @author hsiegeln
*/
void add_line(linehandle_t new_line);
/*
* delete a line
* @author hsiegeln
*/
void delete_line(int iroute);
void delete_line(linehandle_t line);
/*
* update a line -> apply updated fahrplan to all convoys
* @author hsiegeln
*/
void update_line(int iroute);
void update_line(linehandle_t line);
/*
* return number off lines
* @author hsiegeln
*/
sint32 count_lines() { return all_managed_lines.get_count(); }
/*
* return a line
* @author hsiegeln
*/
linehandle_t get_line(uint16 i) const {return i<all_managed_lines.get_count() ? all_managed_lines.at(i) : NULL; }
linehandle_t get_line(fahrplan_t *fpl);
/*
* return a line by its ID
* @author hsiegeln
*/
linehandle_t get_line_by_id(uint16 line);
/*
* load or save the linemanagement
*/
void rdwr(karte_t * welt, loadsave_t * file);
/*
* sort the lines by name
*/
void sort_lines();
/*
* will register all stops for all lines
*/
void register_all_stops();
/*
* called after game is fully loaded;
*/
void laden_abschliessen();
/**
* Creates a unique line id.
* @author Hj. Malthaner
*/
static uint16 get_unique_line_id();
static void init_line_ids();
void new_month();
/**
* @author hsiegeln
*/
linehandle_t create_line(int ltype);
linehandle_t create_line(int ltype, fahrplan_t * fpl);
/**
* @author hsiegeln
*/
void build_line_list(int type, slist_tpl<linehandle_t> * list);
/*
* @author prissi
*/
spieler_t *gib_besitzer() const { return besitzer; }
private:
static uint8 used_ids[8192];
vector_tpl<linehandle_t> all_managed_lines;
static int compare_lines(const void *p1, const void *p2);
karte_t * welt;
spieler_t *besitzer;
};
#endif