-
Notifications
You must be signed in to change notification settings - Fork 17
/
Activity.h
180 lines (166 loc) · 5.43 KB
/
Activity.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
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
/* This file is part of TSRE5.
*
* TSRE5 - train sim game engine and MSTS/OR Editors.
* Copyright (C) 2016 Piotr Gadecki <[email protected]>
*
* Licensed under GNU General Public License 3.0 or later.
*
* See LICENSE.md or https://www.gnu.org/licenses/gpl.html
*/
#ifndef ACTIVITY_H
#define ACTIVITY_H
#include <QString>
#include <QVector>
#include "ActivityEvent.h"
#include "ActivityObject.h"
#include "ActivityTimetable.h"
class FileBuffer;
class Consist;
class Path;
class Service;
class Traffic;
class QTextStream;
class GLUU;
class ActivityServiceDefinition {
public:
QString name;
Service* servicePointer = NULL;
int time = -1;
int uid = -1;
bool player = false;
bool empty = true;
QVector<float> efficiency;
QVector<int> skipCount;
QVector<float> distanceDownPath;
QVector<int> platformStartId;
ActivityTimetable *trafficDefinition = NULL;
void load(FileBuffer* data);
void save(QTextStream* out);
void reloadTimetable();
void reloadDefinition();
bool isModified();
void calculateTimetable();
void setTimetableEfficiency(int id, float val);
void updateSim(float *playerT, float deltaTime);
void render(GLUU *gluu, float* playerT, int renderMode);
QMap<int, QString> getStationStopNameList();
private:
bool modified = false;
};
class Activity {
public:
Activity();
virtual ~Activity();
Activity(QString p, QString n, bool isnew = false);
Activity(QString src, QString p, QString n, bool isnew = false);
struct TrafficDefinition {
QString name;
QVector<ActivityServiceDefinition> service;
};
struct ActivityHeader {
QString routeid;
QString name;
QString description;
QString briefing;
QString pathid;
int completeActivity = 0;
int type = -1;
int mode = -1;
int startTime[3];
int season = -1;
int weather = -1;
int startingSpeed = -1;
int duration[2];
int difficulty = -1;
int animals = -1;
int workers = -1;
int fuelWater = -1;
int fuelCoal = -1;
int fuelDiesel = -1;
int* voltage = NULL;
void load(FileBuffer* data);
void save(QTextStream* out);
ActivityHeader();
ActivityHeader(QString route, QString hname);
};
QString name;
QString nameid;
QString path;
QString pathid;
int loaded = -1;
int ref = 0;
ActivityServiceDefinition *playerServiceDefinition = NULL;
ActivityHeader *header = NULL;
TrafficDefinition *traffic = NULL;
int nextServiceUID = -1;
int nextActivityObjectUID = -1;
int nextEventUID = 0;
int ortsAIHornAtCrossings = -9999;
QVector<ActivityObject*> activityObjects;
QVector<QPair<int, int>> platformNumPassengersWaiting;
QVector<ActivityObject*> restrictedSpeedZone;
QVector<ActivityObject*> activityFailedSignal;
QVector<ActivityEvent> event;
int serial = -1;
void load();
void save();
bool isInitActivityObjects = false;
//void initActivityObjects();
void updateSim(float *playerT, float deltaTime);
void render(GLUU* gluu, float * playerT, float playerRot, int renderMode);
QString editorConListSelected;
ActivityEvent *currentEventSelected = NULL;
void init(QString route, QString name);
//void setRouteContent(QVector<Path*>* p, QVector<Service*>* s, QVector<Traffic*>* t);
//Traffic *getTrafficByName(QString name);
bool isNew();
void initToPlay();
bool isUnSaved();
void setFileName(QString val);
void setDisplayName(QString val);
void setOrtsHornAtCrossigns(bool val);
bool isOrtsHornAtCrossigns();
void setDifficulty(int val);
void setDuration(int h, int m);
void setStartTime(int h, int m, int s);
void setSeason(int val);
void setWeather(int val);
void pickNewEventLocation(float *tdbPos);
void newLooseConsist(float *tdbPos);
void newSpeedZone(float *tdbPos);
bool newFailedSignalFromSelected();
void createNewPlayerService(QString sName, int sTime);
void createNewTrafficService(Traffic *t);
void setFuelCoal(int val);
void setFuelWater(int val);
void setFuelDiesel(int val);
void setHazardWorkers(int val);
void setHazardAnimals(int val);
void setDescription(QString val);
void setBriefing(QString val);
void deleteObject(int id);
void deleteObjectFailedSignal(int id);
void deleteObjectSpeedZone(int id);
void removeAllFailedSignals();
void removeAllSpeedZones();
void deleteCurrentEvent();
void newEvent(ActivityEvent::EventCategory category);
bool isServiceInUse(QString n);
bool isTrafficInUse(QString n);
bool isPlayerServiceInUse(QString n);
QVector<ActivityServiceDefinition*> getServiceList();
unsigned int getSelectedCarId();
bool getCarPosition(int oid, int eid, float *posTW);
QMap<int, QString> getEventIdNameList();
QMap<int, QString> getServiceStationStopNameList();
ActivityObject* getObjectById(int id);
Consist* getServiceConsistById(int id);
void updateService(QString serviceName);
private:
bool modified = false;
bool nowe = false;
//QVector<Service*>* Services;
//QVector<Traffic*>* Traffics;
//QVector<Path*>* Paths;
};
#endif /* ACTIVITY_H */