Inexor
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Classes | Macros | Enumerations | Functions | Variables
gamemode.hpp File Reference
#include "inexor/shared/cube_vector.hpp"

Go to the source code of this file.

Classes

struct  gamemodeinfo
 structure for game mode description More...
 

Macros

#define NUMGAMEMODES   ((int)(sizeof(gamemodes)/sizeof(gamemodes[0])))
 macro to determine the amount of available game modes More...
 
#define m_valid(mode)   ((mode) >= 0 && (mode) < NUMGAMEMODES)
 validate game mode number (array index) More...
 
#define m_check(mode, flag)   (m_valid(mode) && gamemodes[(mode)].flags&(flag))
 validate game mode number and attribute (to check if this gamemode has items or bases e.g.) More...
 
#define m_checknot(mode, flag)   (m_valid(mode) && !(gamemodes[(mode)].flags&(flag)))
 validate game mode number and check if game mode does NOT have these attribuges More...
 
#define m_checkall(mode, flag)   (m_valid(mode) && (gamemodes[(mode)].flags&(flag)) == (flag))
 validate game mode number and check if game mode supports parameter flag bit masks to check if this game mode supports multiple attributes (EFFICIENCY | CTF e.g.) More...
 
#define m_noitems   (m_check(gamemode, M_NOITEMS))
 those game mode check macros are built on top of the layer above More...
 
#define m_noammo   (m_check(gamemode, M_NOAMMO|M_NOITEMS))
 
#define m_insta   (m_check(gamemode, M_INSTA))
 
#define m_tactics   (m_check(gamemode, M_TACTICS))
 
#define m_efficiency   (m_check(gamemode, M_EFFICIENCY))
 
#define m_capture   (m_check(gamemode, M_CAPTURE))
 
#define m_regencapture   (m_checkall(gamemode, M_CAPTURE | M_REGEN))
 
#define m_ctf   (m_check(gamemode, M_CTF))
 
#define m_protect   (m_checkall(gamemode, M_CTF | M_PROTECT))
 
#define m_hold   (m_checkall(gamemode, M_CTF | M_HOLD))
 
#define m_collect   (m_check(gamemode, M_COLLECT))
 
#define m_teammode   (m_check(gamemode, M_TEAM))
 
#define m_overtime   (m_check(gamemode, M_OVERTIME))
 
#define isteam(a, b)   (m_teammode && strcmp(a, b)==0)
 
#define m_lms   (m_check(gamemode, M_LMS))
 
#define m_bomb   (m_check(gamemode, M_BOMB))
 
#define m_hideandseek   (m_check(gamemode, M_HIDEANDSEEK))
 
#define m_obstacles   (m_check(gamemode, M_OBSTACLES))
 
#define m_timeforward   (m_check(gamemode, M_TIMEFORWARD))
 
#define m_demo   (m_check(gamemode, M_DEMO))
 
#define m_edit   (m_check(gamemode, M_EDIT))
 
#define m_lobby   (m_check(gamemode, M_LOBBY))
 
#define m_timed   (m_checknot(gamemode, M_DEMO|M_EDIT))
 
#define m_botmode   (m_checknot(gamemode, M_DEMO))
 

Enumerations

enum  {
  M_TEAM = 1<<0, M_NOITEMS = 1<<1, M_NOAMMO = 1<<2, M_INSTA = 1<<3,
  M_EFFICIENCY = 1<<4, M_TACTICS = 1<<5, M_CAPTURE = 1<<6, M_REGEN = 1<<7,
  M_CTF = 1<<8, M_PROTECT = 1<<9, M_HOLD = 1<<10, M_OVERTIME = 1<<11,
  M_EDIT = 1<<12, M_DEMO = 1<<13, M_LOBBY = 1<<15, M_DMSP = 1<<16,
  M_CLASSICSP = 1<<17, M_SLOWMO = 1<<18, M_COLLECT = 1<<19, M_LMS = 1<<20,
  M_BOMB = 1<<21, M_TIMEFORWARD = 1<<22, M_OBSTACLES = 1<<23, M_HIDEANDSEEK = 1<<24
}
 basic game mode bitmask "FLAGS" (NOT game modes but attributes of game modes) More...
 

Functions

int genmodemask (vector< char * > &modes)
 shortens a list of mode groups ("[<operator>]<modetype>") into a bitmask. More...
 
const char * modename (int n, const char *unknown="unknown")
 Returns the name of the gamemode number n. More...
 

Variables

static struct gamemodeinfo gamemodes []
 
int gamemode
 The currently set gamemode. More...
 

Class Documentation

struct gamemodeinfo

structure for game mode description

Class Members
int flags game mode's name
const char * name

Macro Definition Documentation

#define isteam (   a,
 
)    (m_teammode && strcmp(a, b)==0)
#define m_bomb   (m_check(gamemode, M_BOMB))
#define m_botmode   (m_checknot(gamemode, M_DEMO))

Referenced by aiman::checkai().

#define m_capture   (m_check(gamemode, M_CAPTURE))
#define m_check (   mode,
  flag 
)    (m_valid(mode) && gamemodes[(mode)].flags&(flag))

validate game mode number and attribute (to check if this gamemode has items or bases e.g.)

Referenced by server::addmaprotation(), and server::vote().

#define m_checkall (   mode,
  flag 
)    (m_valid(mode) && (gamemodes[(mode)].flags&(flag)) == (flag))

validate game mode number and check if game mode supports parameter flag bit masks to check if this game mode supports multiple attributes (EFFICIENCY | CTF e.g.)

#define m_checknot (   mode,
  flag 
)    (m_valid(mode) && !(gamemodes[(mode)].flags&(flag)))

validate game mode number and check if game mode does NOT have these attribuges

Referenced by genmodemask().

#define m_collect   (m_check(gamemode, M_COLLECT))
#define m_ctf   (m_check(gamemode, M_CTF))
#define m_demo   (m_check(gamemode, M_DEMO))
#define m_edit   (m_check(gamemode, M_EDIT))
#define m_efficiency   (m_check(gamemode, M_EFFICIENCY))
#define m_hideandseek   (m_check(gamemode, M_HIDEANDSEEK))
#define m_hold   (m_checkall(gamemode, M_CTF | M_HOLD))
#define m_insta   (m_check(gamemode, M_INSTA))
#define m_lms   (m_check(gamemode, M_LMS))
#define m_lobby   (m_check(gamemode, M_LOBBY))
#define m_noammo   (m_check(gamemode, M_NOAMMO|M_NOITEMS))
#define m_noitems   (m_check(gamemode, M_NOITEMS))
#define m_obstacles   (m_check(gamemode, M_OBSTACLES))
#define m_overtime   (m_check(gamemode, M_OVERTIME))

Referenced by server::changemap().

#define m_protect   (m_checkall(gamemode, M_CTF | M_PROTECT))
#define m_regencapture   (m_checkall(gamemode, M_CAPTURE | M_REGEN))
#define m_tactics   (m_check(gamemode, M_TACTICS))

Referenced by fpsstate::spawnstate().

#define m_teammode   (m_check(gamemode, M_TEAM))
#define m_timed   (m_checknot(gamemode, M_DEMO|M_EDIT))
#define m_timeforward   (m_check(gamemode, M_TIMEFORWARD))
#define m_valid (   mode)    ((mode) >= 0 && (mode) < NUMGAMEMODES)
#define NUMGAMEMODES   ((int)(sizeof(gamemodes)/sizeof(gamemodes[0])))

macro to determine the amount of available game modes

Referenced by server::addmaprotation(), server::maprotation::calcmodemask(), server::maprotation::findmode(), and genmodemask().

Enumeration Type Documentation

anonymous enum

basic game mode bitmask "FLAGS" (NOT game modes but attributes of game modes)

Enumerator
M_TEAM 
M_NOITEMS 

game mode contains teams

M_NOAMMO 

game mode has no items

M_INSTA 

game mode has no ammo?

M_EFFICIENCY 

game mode has an instagib modifier

M_TACTICS 

game mode has an efficiency modifier

M_CAPTURE 

game mode offers random spawn weapons (see tactics mode)

M_REGEN 

game mode is about capturing bases

M_CTF 

game mode is about capturing supply bases (see regencapture mode)

M_PROTECT 

game mode is about capturing a flag

M_HOLD 

game mode is about protecting a flag

M_OVERTIME 

game mode is about holding a flag (for 20 seconds)

M_EDIT 

game mode has longer matches

M_DEMO 

game mode allows cooperative editing (coopedit)

M_LOBBY 

game mode is a demo playback

M_DMSP 

game mode does not imply certain (good vs evil) grouped gameplay but also allows to built lobbys (pseudoteams working against each other)

M_CLASSICSP 

death match single player

M_SLOWMO 

classic singleplayer

M_COLLECT 

game mode is played in slow motion

M_LMS 

game mode is about collecting skulls

M_BOMB 

last man standing

M_TIMEFORWARD 

bomberman

M_OBSTACLES 

time counts onward (instead of from full time to zero)

M_HIDEANDSEEK 

game mode has obstacles which can be destroyed dynamically

Function Documentation

int genmodemask ( vector< char * > &  modes)

shortens a list of mode groups ("[<operator>]<modetype>") into a bitmask.

Input may be "?ctf" "!?collect" "*capture" which would do: operator ? adds this to the bitmask (so ctf modes are added) operator !? means AND (so after the second entry got evaluated only modes which are ctf AND collect modes are left) operator * is equivalent to add this if its not edit mode or anything local. operator ! means REVERT (so "?ctf", "!instactf" means all ctf-gamemodes but instactf) Input could also be the gamemode number (e.g. "21", "3") or the gamemode name ("ctf", "collect")

References gamemodes, loopk, loopv, m_checknot, M_DEMO, M_EDIT, m_valid, NUMGAMEMODES, and searchmodename().

Referenced by server::addmaprotations(), and server::addteamkillkick().

const char* modename ( int  n,
const char *  unknown = "unknown" 
)

Returns the name of the gamemode number n.

If n does not specify a correct gamemode, it returns the "unknown" string.

References gamemodes, m_valid, and gamemodeinfo::name.

Referenced by server::adddemo(), game::getclientmode(), game::renderscoreboard(), game::startgame(), and server::vote().

Variable Documentation

int gamemode
struct gamemodeinfo gamemodes[]
static
Initial value:
=
{
{"demo", M_DEMO},
{"ffa", M_LOBBY},
{"coop edit", M_EDIT},
{"teamplay", M_TEAM},
{"instagib", M_NOITEMS | M_INSTA},
{"insta team", M_NOITEMS | M_INSTA | M_TEAM},
{"efficiency", M_NOITEMS | M_EFFICIENCY},
{"effic team", M_NOITEMS | M_EFFICIENCY | M_TEAM},
{"tactics", M_NOITEMS | M_TACTICS},
{"tac team", M_NOITEMS | M_TACTICS | M_TEAM},
{"capture", M_NOAMMO | M_TACTICS | M_CAPTURE | M_TEAM},
{"regen capture", M_NOITEMS | M_CAPTURE | M_REGEN | M_TEAM},
{"ctf", M_CTF | M_TEAM},
{"insta ctf", M_NOITEMS | M_INSTA | M_CTF | M_TEAM},
{"protect", M_CTF | M_PROTECT | M_TEAM},
{"insta protect", M_NOITEMS | M_INSTA | M_CTF | M_PROTECT | M_TEAM},
{"hold", M_CTF | M_HOLD | M_TEAM},
{"insta hold", M_NOITEMS | M_INSTA | M_CTF | M_HOLD | M_TEAM},
{"effic ctf", M_NOITEMS | M_EFFICIENCY | M_CTF | M_TEAM},
{"effic protect", M_NOITEMS | M_EFFICIENCY | M_CTF | M_PROTECT | M_TEAM},
{"effic hold", M_NOITEMS | M_EFFICIENCY | M_CTF | M_HOLD | M_TEAM},
{"collect", M_COLLECT | M_TEAM},
{"insta collect", M_NOITEMS | M_INSTA | M_COLLECT | M_TEAM},
{"effic collect", M_NOITEMS | M_EFFICIENCY | M_COLLECT | M_TEAM},
{"bomberman", M_LMS | M_BOMB | M_OBSTACLES},
{"bomberman team", M_LMS | M_BOMB | M_TEAM | M_OBSTACLES},
{"hideandseek"}
}
time counts onward (instead of from full time to zero)
Definition: gamemode.hpp:35
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
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
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
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 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

Referenced by genmodemask(), and modename().