File: level.h

package info (click to toggle)
openmohaa 0.82.1%2Bdfsg-1
  • links: PTS, VCS
  • area: contrib
  • in suites: forky, sid
  • size: 34,192 kB
  • sloc: cpp: 315,720; ansic: 275,789; sh: 312; xml: 246; asm: 141; makefile: 7
file content (396 lines) | stat: -rw-r--r-- 10,356 bytes parent folder | download | duplicates (2)
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
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
/*
===========================================================================
Copyright (C) 2015 the OpenMoHAA team

This file is part of OpenMoHAA source code.

OpenMoHAA source code is free software; you can redistribute it
and/or modify it under the terms of the GNU General Public License as
published by the Free Software Foundation; either version 2 of the License,
or (at your option) any later version.

OpenMoHAA source code is distributed in the hope that it will be
useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with OpenMoHAA source code; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
===========================================================================
*/

// level.h: General Level Info

#pragma once

#include "listener.h"
#include "g_public.h"
#include "bg_voteoptions.h"

#define MAX_HEAD_SENTIENTS 2
#define MAX_EARTHQUAKES    10

enum INTTYPE_e {
    TRANS_BSP,
    TRANS_LEVEL,
    TRANS_MISSION,
    TRANS_MISSION_FAILED
};

enum fadetype_t {
    fadein,
    fadeout
};

enum fadestyle_t {
    alphablend,
    additive
};

enum letterboxdir_t {
    letterbox_in,
    letterbox_out
};

typedef struct earthquake_s {
    int   duration;
    float magnitude;
    bool  no_rampup;
    bool  no_rampdown;

    int                   starttime;
    int                   endtime;
    SafePtr<ScriptThread> m_Thread;
} earthquake_t;

struct badplace_t {
    const_str m_name;
    int       m_iTeamSide;
    Vector    m_vOrigin;
    float     m_fRadius;
    float     m_fLifespan;

public:
    badplace_t();
};

typedef struct {
    str    m_sName;
    Vector m_vOrigin;
} landmark_t;

extern gclient_t *spawn_client;

class Camera;
class SimpleArchivedEntity;
class Actor;

class Level : public Listener
{
public:
    char *current_map;

    int mHealthPopCount;

    // Map name stuff
    str m_mapscript;
    str m_precachescript;
    str m_pathfile;
    str m_mapfile;

    // Spawning variables
    int spawn_entnum;
    int spawnflags;

    // Level time
    int framenum;
    int inttime;
    int intframetime;

    float time;
    float frametime;

    // Server time
    int   svsTime;
    float svsFloatTime;
    int   svsStartTime;
    int   svsEndTime;
    float svsStartFloatTime; // Added in 2.0

    // Level name variables
    str level_name;
    str mapname;
    str spawnpoint;
    str nextmap;

    // AI variables
    int m_iCuriousVoiceTime;
    int m_iAttackEntryAnimTime;

    // Global players variables
    qboolean playerfrozen;

    // Intermission variables
    float     intermissiontime;
    INTTYPE_e intermissiontype;
    int       exitintermission;

    // Secrets
    int total_secrets;
    int found_secrets;

    // Trace
    trace_t impact_trace;

    // Earthquake stuff
    float earthquake_magnitude;

    // Cinematic
    qboolean cinematic;

    // AI variables
    qboolean ai_on;
    qboolean m_bAlarm;
    qboolean mbNoDropHealth;
    qboolean mbNoDropWeapons; // Added in 2.0
    int      m_iPapersLevel;

    // Mission state
    qboolean mission_failed;
    qboolean died_already;
    qboolean near_exit;

    // Water variables
    Vector water_color;
    Vector lava_color;
    float  water_alpha;
    float  lava_alpha;

    // Soundtrack variables
    str current_soundtrack;
    str saved_soundtrack;

    // Screen state
    Vector      m_fade_color;
    float       m_fade_alpha;
    float       m_fade_time;
    float       m_fade_time_start;
    fadetype_t  m_fade_type;
    fadestyle_t m_fade_style;

    // Letterbox state
    float          m_letterbox_fraction;
    float          m_letterbox_time;
    float          m_letterbox_time_start;
    letterboxdir_t m_letterbox_dir;

    // Added in 2.0
    // Bad places
    Container<badplace_t> m_badPlaces;

    Container<Camera *> automatic_cameras;

    // Quake remnants ?
    int m_numArenas;

    // Voting variables
    int m_voteTime;
    int m_nextVoteTime;
    int m_voteYes;
    int m_voteNo;
    int m_numVoters;
    // Added in 2.0
    str         m_voteString;
    str         m_voteName;
    VoteOptions m_voteOptions;

    // Intermission locations
    Vector m_intermission_origin;
    Vector m_intermission_angle;

    // Skeleton variables
    int frame_skel_index;
    int skel_index[MAX_GENTITIES];

    // script variables
    qboolean m_LoopProtection;
    qboolean m_LoopDrop; // kill the server in loop exception

    Container<SimpleArchivedEntity *> m_SimpleArchivedEntities;
    class Sentient                   *m_HeadSentient[MAX_HEAD_SENTIENTS];

    // Earthquake stuff
    earthquake_t earthquakes[MAX_EARTHQUAKES];
    int          num_earthquakes;

    // Objective stuff
    Vector m_vObjectiveLocation;
    Vector m_vAlliedObjectiveLocation; // Added in 2.0
    Vector m_vAxisObjectiveLocation;   // Added in 2.0
    // Added in OPM
    //  Forces axis/allied objectives location to be used
    //  even if the gametype is not TOW
    bool m_bForceTeamObjectiveLocation;

    // Current level state
    bool spawning;
    bool m_bIgnoreClock;
    //====
    // Added in 2.30
    // Landmarks
    float        m_fLandmarkYDistMax;
    float        m_fLandmarkYDistMin;
    float        m_fLandmarkXDistMin;
    float        m_fLandmarkXDistMax;
    landmark_t **m_pLandmarks;
    int          m_iMaxLandmarks;
    int          m_iLandmarksCount;
    //====
    void *m_pAIStats;

    // New Stuff

    // Script stuff
    bool m_bScriptSpawn;
    bool m_bRejectSpawn;

public:
    CLASS_PROTOTYPE(Level);

    Level();
    virtual ~Level();

    void       Init();
    void       CleanUp(qboolean samemap = qfalse, qboolean resetConfigStrings = qfalse);
    void       ResetEdicts();
    gentity_t *AllocEdict(Entity *ent);
    void       FreeEdict(gentity_t *ent);
    void       InitEdict(gentity_t *ent);
    void       LoadAllScripts(const char *name, const char *extension);
    void       Precache();
    void       SetMap(const char *themapname);
    void       FindTeams();

    void SpawnEntities(char *entities, int _svsTime_);
    //====
    // Added in 2.30
    void ComputeDMWaypoints();
    void AddLandmarkOrigin(const Vector& origin);
    void AddLandmarkName(const str& name, const Vector& origin);
    void FreeLandmarks();
    str  GetDynamicDMLocations(const Vector& origin);
    str  GetDMLocation(const Vector& origin);
    //====
    void     PreSpawnSentient(Event *ev);
    void     ServerSpawned();
    qboolean inhibitEntity(int spawnflags);

    void setSkill(int value);
    void setTime(int _svsTime_);
    void setFrametime(int frameTime);

    void AddAutomaticCamera(Camera *cam);

    void GetTime(Event *ev);
    void GetTotalSecrets(Event *ev);
    void GetFoundSecrets(Event *ev);

    //====
    // Added in 2.0
    void InitVoteOptions();
    void SendVoteOptionsFile(gentity_t *ent);
    bool GetVoteOptionMain(int index, str *outOptionCommand, voteoptiontype_t *outOptionType);
    bool GetVoteOptionSub(int index, int listIndex, str *outCommand);
    bool GetVoteOptionMainName(int index, str *outVoteName);
    bool GetVoteOptionSubName(int index, int listIndex, str *outName);
    //====
    void CheckVote();
    void SetupMaplist(); // Added in 2.0

    void GetAlarm(Event *ev);
    void SetAlarm(Event *ev);
    void SetNoDropHealth(Event *ev);
    void SetNoDropWeapons(Event *ev); // Added in 2.0
    void GetLoopProtection(Event *ev);
    void SetLoopProtection(Event *ev);
    void GetPapersLevel(Event *ev);
    void SetPapersLevel(Event *ev);
    void EventGetRoundStarted(Event *ev);
    void EventGetDMRespawning(Event *ev);
    void EventSetDMRespawning(Event *ev);
    void EventGetDMRoundLimit(Event *ev);
    void EventSetDMRoundLimit(Event *ev);
    void EventGetClockSide(Event *ev);
    void EventSetClockSide(Event *ev);
    void EventGetBombPlantTeam(Event *ev);
    void EventSetBombPlantTeam(Event *ev);
    void EventGetTargetsToDestroy(Event *ev);
    void EventSetTargetsToDestroy(Event *ev);
    void EventGetTargetsDestroyed(Event *ev);
    void EventSetTargetsDestroyed(Event *ev);
    void EventGetBombsPlanted(Event *ev);
    void EventSetBombsPlanted(Event *ev);
    void EventGetRoundBased(Event *ev);
    void EventGetObjectiveBased(Event *ev);
    void EventRainDensitySet(Event *ev);
    void EventRainDensityGet(Event *ev);
    void EventRainSpeedSet(Event *ev);
    void EventRainSpeedGet(Event *ev);
    void EventRainSpeedVarySet(Event *ev);
    void EventRainSpeedVaryGet(Event *ev);
    void EventRainSlantSet(Event *ev);
    void EventRainSlantGet(Event *ev);
    void EventRainLengthSet(Event *ev);
    void EventRainLengthGet(Event *ev);
    void EventRainMin_DistSet(Event *ev);
    void EventRainMin_DistGet(Event *ev);
    void EventRainWidthSet(Event *ev);
    void EventRainWidthGet(Event *ev);
    void EventRainShaderSet(Event *ev);
    void EventRainShaderGet(Event *ev);
    void EventRainNumShadersSet(Event *ev);
    void EventRainNumShadersGet(Event *ev);
    //====
    // Added in 2.0
    void EventAddBadPlace(Event *ev);
    void EventRemoveBadPlace(Event *ev);
    void EventIgnoreClock(Event *ev);
    void UpdateBadPlaces();
    int  GetNearestBadPlace(const Vector& org, float radius, int team) const;
    //====
    str GetRandomHeadModel(const char *model);
    str GetRandomHeadSkin(const char *model);

    bool RoundStarted();
    bool PreSpawned(void);
    bool Spawned(void);

    void AddEarthquake(earthquake_t *);
    void DoEarthquakes(void);

    void OpenActorStats();
    void WriteActorStats(Actor *actor);

    //====
    // Added in OPM
    void SetForceTeamObjectiveLocation(Event *ev);
    void GetForceTeamObjectiveLocation(Event *ev);
    //====

    void Archive(Archiver& arc) override;
};

// Called when a restart/change was issued
void G_BeginIntermission2(void);

// Change the current map to the specified map with the possibility to fade the screen with fadetime.
void G_BeginIntermission(const char *map_name, INTTYPE_e transtype, bool no_fade = false);

//Exit the intermission screen.
void G_ExitIntermission(void);

// Exits the level
void G_ExitLevel(void);

extern Level level;