2008-08-14 18:25:44 +00:00
|
|
|
#ifndef GAME_SERVER_GAMECONTROLLER_H
|
|
|
|
#define GAME_SERVER_GAMECONTROLLER_H
|
|
|
|
|
|
|
|
#include <base/vmath.hpp>
|
|
|
|
|
|
|
|
/*
|
|
|
|
Class: Game Controller
|
|
|
|
Controls the main game logic. Keeping track of team and player score,
|
|
|
|
winning conditions and specific game logic.
|
|
|
|
*/
|
|
|
|
class GAMECONTROLLER
|
|
|
|
{
|
2008-08-27 15:48:50 +00:00
|
|
|
vec2 spawn_points[3][64];
|
|
|
|
int num_spawn_points[3];
|
2008-08-14 18:25:44 +00:00
|
|
|
protected:
|
2008-08-27 15:48:50 +00:00
|
|
|
struct SPAWNEVAL
|
|
|
|
{
|
|
|
|
SPAWNEVAL()
|
|
|
|
{
|
|
|
|
got = false;
|
|
|
|
friendly_team = -1;
|
|
|
|
pos = vec2(100,100);
|
|
|
|
}
|
|
|
|
|
|
|
|
vec2 pos;
|
|
|
|
bool got;
|
|
|
|
int friendly_team;
|
|
|
|
float score;
|
|
|
|
};
|
|
|
|
|
|
|
|
float evaluate_spawn_pos(SPAWNEVAL *eval, vec2 pos);
|
|
|
|
void evaluate_spawn_type(SPAWNEVAL *eval, int type);
|
|
|
|
bool evaluate_spawn(class PLAYER *p, vec2 *pos);
|
|
|
|
|
2008-08-14 18:25:44 +00:00
|
|
|
void cyclemap();
|
|
|
|
void resetgame();
|
2008-10-22 14:31:46 +00:00
|
|
|
|
|
|
|
char map_wish[128];
|
2008-09-07 08:10:56 +00:00
|
|
|
|
2008-08-31 14:37:35 +00:00
|
|
|
const char *gametype;
|
|
|
|
|
2008-08-14 18:25:44 +00:00
|
|
|
int round_start_tick;
|
|
|
|
int game_over_tick;
|
|
|
|
int sudden_death;
|
|
|
|
|
|
|
|
int teamscore[2];
|
|
|
|
|
|
|
|
int warmup;
|
|
|
|
int round_count;
|
|
|
|
|
2008-08-31 14:37:35 +00:00
|
|
|
int game_flags;
|
2008-09-07 08:57:59 +00:00
|
|
|
int unbalanced_tick;
|
|
|
|
bool force_balanced;
|
2008-08-14 18:25:44 +00:00
|
|
|
|
|
|
|
public:
|
2008-08-31 14:37:35 +00:00
|
|
|
bool is_teamplay() const;
|
2008-08-27 15:48:50 +00:00
|
|
|
|
2008-08-14 18:25:44 +00:00
|
|
|
GAMECONTROLLER();
|
2008-10-02 14:44:35 +00:00
|
|
|
virtual ~GAMECONTROLLER();
|
2008-08-14 18:25:44 +00:00
|
|
|
|
|
|
|
void do_team_score_wincheck();
|
|
|
|
void do_player_score_wincheck();
|
|
|
|
|
|
|
|
void do_warmup(int seconds);
|
|
|
|
|
|
|
|
void startround();
|
|
|
|
void endround();
|
2008-10-22 14:31:46 +00:00
|
|
|
void change_map(const char *to_map);
|
2008-08-14 18:25:44 +00:00
|
|
|
|
|
|
|
bool is_friendly_fire(int cid1, int cid2);
|
2008-09-07 08:57:59 +00:00
|
|
|
|
|
|
|
bool is_force_balanced();
|
2008-08-14 18:25:44 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
|
|
|
|
*/
|
|
|
|
virtual void tick();
|
|
|
|
|
|
|
|
virtual void snap(int snapping_client);
|
|
|
|
|
|
|
|
/*
|
|
|
|
Function: on_entity
|
|
|
|
Called when the map is loaded to process an entity
|
|
|
|
in the map.
|
|
|
|
|
|
|
|
Arguments:
|
|
|
|
index - Entity index.
|
|
|
|
pos - Where the entity is located in the world.
|
|
|
|
|
|
|
|
Returns:
|
|
|
|
bool?
|
|
|
|
*/
|
|
|
|
virtual bool on_entity(int index, vec2 pos);
|
|
|
|
|
|
|
|
/*
|
|
|
|
Function: on_character_spawn
|
|
|
|
Called when a character spawns into the game world.
|
|
|
|
|
|
|
|
Arguments:
|
|
|
|
chr - The character that was spawned.
|
|
|
|
*/
|
2008-08-27 20:04:07 +00:00
|
|
|
virtual void on_character_spawn(class CHARACTER *chr);
|
2008-08-14 18:25:44 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
Function: on_character_death
|
|
|
|
Called when a character in the world dies.
|
|
|
|
|
|
|
|
Arguments:
|
|
|
|
victim - The character that died.
|
|
|
|
killer - The player that killed it.
|
|
|
|
weapon - What weapon that killed it. Can be -1 for undefined
|
|
|
|
weapon when switching team or player suicides.
|
|
|
|
*/
|
|
|
|
virtual int on_character_death(class CHARACTER *victim, class PLAYER *killer, int weapon);
|
|
|
|
|
2008-08-27 15:48:50 +00:00
|
|
|
|
2008-08-14 18:25:44 +00:00
|
|
|
virtual void on_player_info_change(class PLAYER *p);
|
|
|
|
|
2008-08-27 15:48:50 +00:00
|
|
|
//
|
|
|
|
virtual bool can_spawn(class PLAYER *p, vec2 *pos);
|
|
|
|
|
2008-08-14 18:25:44 +00:00
|
|
|
/*
|
|
|
|
|
|
|
|
*/
|
|
|
|
virtual const char *get_team_name(int team);
|
|
|
|
virtual int get_auto_team(int notthisid);
|
|
|
|
virtual bool can_join_team(int team, int notthisid);
|
2008-09-07 08:10:56 +00:00
|
|
|
bool check_team_balance();
|
|
|
|
bool can_change_team(PLAYER *pplayer, int jointeam);
|
2008-08-14 18:25:44 +00:00
|
|
|
int clampteam(int team);
|
|
|
|
|
|
|
|
virtual void post_reset();
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|