Inexor
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
gamemode.hpp
Go to the documentation of this file.
1 #pragma once
3 
4 
5 // game mode specific code
6 
9 enum
10 {
11  M_TEAM = 1<<0,
12  M_NOITEMS = 1<<1,
13  M_NOAMMO = 1<<2,
14  M_INSTA = 1<<3,
15  M_EFFICIENCY = 1<<4,
16  M_TACTICS = 1<<5,
17  M_CAPTURE = 1<<6,
18  M_REGEN = 1<<7,
19  M_CTF = 1<<8,
20  M_PROTECT = 1<<9,
21  M_HOLD = 1<<10,
22  M_OVERTIME = 1<<11,
23  M_EDIT = 1<<12,
24  M_DEMO = 1<<13,
25  // old: M_LOCAL = 1<<14, /// game mode is played in singleplayer only (locally)
26  M_LOBBY = 1<<15,
27  M_DMSP = 1<<16,
28  M_CLASSICSP = 1<<17,
29  M_SLOWMO = 1<<18,
30  M_COLLECT = 1<<19,
31 
32  M_LMS = 1<<20,
33  M_BOMB = 1<<21,
34  M_TIMEFORWARD= 1<<22,
35  M_OBSTACLES = 1<<23,
37 };
38 
39 
41 static struct gamemodeinfo
42 {
43  const char *name;
44  int flags;
45 } gamemodes[] =
46 {
47  {"demo", M_DEMO},
48  {"ffa", M_LOBBY},
49  {"coop edit", M_EDIT},
50  {"teamplay", M_TEAM},
51  {"instagib", M_NOITEMS | M_INSTA},
52  {"insta team", M_NOITEMS | M_INSTA | M_TEAM},
53  {"efficiency", M_NOITEMS | M_EFFICIENCY},
54  {"effic team", M_NOITEMS | M_EFFICIENCY | M_TEAM},
55  {"tactics", M_NOITEMS | M_TACTICS},
56  {"tac team", M_NOITEMS | M_TACTICS | M_TEAM},
57  {"capture", M_NOAMMO | M_TACTICS | M_CAPTURE | M_TEAM},
58  {"regen capture", M_NOITEMS | M_CAPTURE | M_REGEN | M_TEAM},
59  {"ctf", M_CTF | M_TEAM},
60  {"insta ctf", M_NOITEMS | M_INSTA | M_CTF | M_TEAM},
61  {"protect", M_CTF | M_PROTECT | M_TEAM},
62  {"insta protect", M_NOITEMS | M_INSTA | M_CTF | M_PROTECT | M_TEAM},
63  {"hold", M_CTF | M_HOLD | M_TEAM},
64  {"insta hold", M_NOITEMS | M_INSTA | M_CTF | M_HOLD | M_TEAM},
65  {"effic ctf", M_NOITEMS | M_EFFICIENCY | M_CTF | M_TEAM},
66  {"effic protect", M_NOITEMS | M_EFFICIENCY | M_CTF | M_PROTECT | M_TEAM},
67  {"effic hold", M_NOITEMS | M_EFFICIENCY | M_CTF | M_HOLD | M_TEAM},
68  {"collect", M_COLLECT | M_TEAM},
69  {"insta collect", M_NOITEMS | M_INSTA | M_COLLECT | M_TEAM},
70  {"effic collect", M_NOITEMS | M_EFFICIENCY | M_COLLECT | M_TEAM},
71  {"bomberman", M_LMS | M_BOMB | M_OBSTACLES},
72  {"bomberman team", M_LMS | M_BOMB | M_TEAM | M_OBSTACLES},
73  {"hideandseek"}
74 };
75 
76 // game mode validation and attribute handling
77 
79 #define NUMGAMEMODES ((int)(sizeof(gamemodes)/sizeof(gamemodes[0])))
80 
82 #define m_valid(mode) ((mode) >= 0 && (mode) < NUMGAMEMODES)
83 #define m_check(mode, flag) (m_valid(mode) && gamemodes[(mode)].flags&(flag))
85 #define m_checknot(mode, flag) (m_valid(mode) && !(gamemodes[(mode)].flags&(flag)))
87 #define m_checkall(mode, flag) (m_valid(mode) && (gamemodes[(mode)].flags&(flag)) == (flag))
90 
92 #define m_noitems (m_check(gamemode, M_NOITEMS))
93 #define m_noammo (m_check(gamemode, M_NOAMMO|M_NOITEMS))
94 #define m_insta (m_check(gamemode, M_INSTA))
95 #define m_tactics (m_check(gamemode, M_TACTICS))
96 #define m_efficiency (m_check(gamemode, M_EFFICIENCY))
97 #define m_capture (m_check(gamemode, M_CAPTURE))
98 #define m_regencapture (m_checkall(gamemode, M_CAPTURE | M_REGEN))
99 #define m_ctf (m_check(gamemode, M_CTF))
100 #define m_protect (m_checkall(gamemode, M_CTF | M_PROTECT))
101 #define m_hold (m_checkall(gamemode, M_CTF | M_HOLD))
102 #define m_collect (m_check(gamemode, M_COLLECT))
103 #define m_teammode (m_check(gamemode, M_TEAM))
104 #define m_overtime (m_check(gamemode, M_OVERTIME))
105 #define isteam(a,b) (m_teammode && strcmp(a, b)==0)
106 
107 #define m_lms (m_check(gamemode, M_LMS))
108 #define m_bomb (m_check(gamemode, M_BOMB))
109 #define m_hideandseek (m_check(gamemode, M_HIDEANDSEEK))
110 
111 #define m_obstacles (m_check(gamemode, M_OBSTACLES))
112 #define m_timeforward (m_check(gamemode, M_TIMEFORWARD))
113 
114 #define m_demo (m_check(gamemode, M_DEMO))
115 #define m_edit (m_check(gamemode, M_EDIT))
116 #define m_lobby (m_check(gamemode, M_LOBBY))
117 #define m_timed (m_checknot(gamemode, M_DEMO|M_EDIT))
118 #define m_botmode (m_checknot(gamemode, M_DEMO))
119 
121 extern int gamemode;
122 
130 extern int genmodemask(vector<char *> &modes);
131 
134 extern const char *modename(int n, const char *unknown = "unknown");
time counts onward (instead of from full time to zero)
Definition: gamemode.hpp:35
death match single player
Definition: gamemode.hpp:28
game mode is about capturing supply bases (see regencapture mode)
Definition: gamemode.hpp:19
game mode is a demo playback
Definition: gamemode.hpp:26
Definition: gamemode.hpp:11
structure for game mode description
Definition: gamemode.hpp:41
int gamemode
The currently set gamemode.
Definition: gamemode.cpp:11
int flags
game mode's name
Definition: gamemode.hpp:44
classic singleplayer
Definition: gamemode.hpp:29
bomberman
Definition: gamemode.hpp:34
game mode has longer matches
Definition: gamemode.hpp:23
game mode has an instagib modifier
Definition: gamemode.hpp:15
game mode is about protecting a flag
Definition: gamemode.hpp:21
game mode has no items
Definition: gamemode.hpp:13
game mode is about capturing a flag
Definition: gamemode.hpp:20
const char * modename(int n, const char *unknown="unknown")
Returns the name of the gamemode number n.
Definition: gamemode.cpp:74
last man standing
Definition: gamemode.hpp:33
game mode has an efficiency modifier
Definition: gamemode.hpp:16
game mode allows cooperative editing (coopedit)
Definition: gamemode.hpp:24
static struct gamemodeinfo gamemodes[]
game mode is about collecting skulls
Definition: gamemode.hpp:32
game mode is about capturing bases
Definition: gamemode.hpp:18
game mode is played in slow motion
Definition: gamemode.hpp:30
game mode is about holding a flag (for 20 seconds)
Definition: gamemode.hpp:22
game mode has obstacles which can be destroyed dynamically
Definition: gamemode.hpp:36
game mode does not imply certain (good vs evil) grouped gameplay but also allows to built lobbys (pse...
Definition: gamemode.hpp:27
game mode has no ammo?
Definition: gamemode.hpp:14
game mode offers random spawn weapons (see tactics mode)
Definition: gamemode.hpp:17
game mode contains teams
Definition: gamemode.hpp:12
int genmodemask(vector< char * > &modes)
shortens a list of mode groups ("[<operator>]<modetype>") into a bitmask.
Definition: gamemode.cpp:36
const char * name
Definition: gamemode.hpp:43