2008-08-14 18:42:47 +00:00
|
|
|
#ifndef GAME_SERVER_GAMECONTEXT_H
|
|
|
|
#define GAME_SERVER_GAMECONTEXT_H
|
2008-08-14 18:25:44 +00:00
|
|
|
|
|
|
|
#include "eventhandler.hpp"
|
|
|
|
#include "gamecontroller.hpp"
|
|
|
|
#include "gameworld.hpp"
|
2008-08-14 18:42:47 +00:00
|
|
|
#include "player.hpp"
|
|
|
|
|
|
|
|
/*
|
|
|
|
Tick
|
|
|
|
Game Context (GAMECONTEXT::tick)
|
|
|
|
Game World (GAMEWORLD::tick)
|
|
|
|
Reset world if requested (GAMEWORLD::reset)
|
|
|
|
All entities in the world (ENTITY::tick)
|
|
|
|
All entities in the world (ENTITY::tick_defered)
|
|
|
|
Remove entities marked for deletion (GAMEWORLD::remove_entities)
|
|
|
|
Game Controller (GAMECONTROLLER::tick)
|
|
|
|
All players (PLAYER::tick)
|
|
|
|
|
|
|
|
|
|
|
|
Snap
|
|
|
|
Game Context (GAMECONTEXT::snap)
|
|
|
|
Game World (GAMEWORLD::snap)
|
|
|
|
All entities in the world (ENTITY::snap)
|
|
|
|
Game Controller (GAMECONTROLLER::snap)
|
|
|
|
Events handler (EVENT_HANDLER::snap)
|
|
|
|
All players (PLAYER::snap)
|
|
|
|
|
|
|
|
*/
|
2008-08-14 18:25:44 +00:00
|
|
|
class GAMECONTEXT
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
GAMECONTEXT();
|
2008-09-23 07:43:41 +00:00
|
|
|
~GAMECONTEXT();
|
|
|
|
|
2008-08-14 18:25:44 +00:00
|
|
|
void clear();
|
|
|
|
|
|
|
|
EVENTHANDLER events;
|
2008-09-23 18:08:19 +00:00
|
|
|
PLAYER *players[MAX_CLIENTS];
|
2008-08-14 18:25:44 +00:00
|
|
|
|
|
|
|
GAMECONTROLLER *controller;
|
|
|
|
GAMEWORLD world;
|
|
|
|
|
|
|
|
void tick();
|
|
|
|
void snap(int client_id);
|
2008-09-24 14:47:03 +00:00
|
|
|
|
|
|
|
// voting
|
|
|
|
void start_vote(const char *desc, const char *command);
|
2008-09-25 12:41:37 +00:00
|
|
|
void end_vote();
|
2008-09-24 14:47:03 +00:00
|
|
|
void send_vote_set(int cid);
|
|
|
|
void send_vote_status(int cid);
|
2008-09-25 14:04:02 +00:00
|
|
|
int vote_creator;
|
2008-09-24 14:47:03 +00:00
|
|
|
int64 vote_closetime;
|
|
|
|
char vote_description[512];
|
|
|
|
char vote_command[512];
|
2008-08-14 18:25:44 +00:00
|
|
|
|
|
|
|
// helper functions
|
|
|
|
void create_damageind(vec2 p, float angle_mod, int amount);
|
|
|
|
void create_explosion(vec2 p, int owner, int weapon, bool bnodamage);
|
|
|
|
void create_smoke(vec2 p);
|
|
|
|
void create_playerspawn(vec2 p);
|
|
|
|
void create_death(vec2 p, int who);
|
|
|
|
void create_sound(vec2 pos, int sound, int mask=-1);
|
|
|
|
void create_sound_global(int sound, int target=-1);
|
|
|
|
|
2008-08-14 18:42:47 +00:00
|
|
|
|
|
|
|
enum
|
|
|
|
{
|
|
|
|
CHAT_ALL=-2,
|
|
|
|
CHAT_SPEC=-1,
|
|
|
|
CHAT_RED=0,
|
|
|
|
CHAT_BLUE=1
|
|
|
|
};
|
|
|
|
|
2008-08-14 18:25:44 +00:00
|
|
|
// network
|
|
|
|
void send_chat(int cid, int team, const char *text);
|
|
|
|
void send_emoticon(int cid, int emoticon);
|
|
|
|
void send_weapon_pickup(int cid, int weapon);
|
|
|
|
void send_broadcast(const char *text, int cid);
|
|
|
|
void send_info(int who, int to_who);
|
2008-09-24 14:47:03 +00:00
|
|
|
|
2008-08-14 18:25:44 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
extern GAMECONTEXT game;
|
2008-08-14 18:42:47 +00:00
|
|
|
|
|
|
|
// MISC stuff, move to a better place later on
|
|
|
|
|
|
|
|
extern TUNING_PARAMS tuning;
|
|
|
|
inline int cmask_all() { return -1; }
|
|
|
|
inline int cmask_one(int cid) { return 1<<cid; }
|
|
|
|
inline int cmask_all_except_one(int cid) { return 0x7fffffff^cmask_one(cid); }
|
|
|
|
inline bool cmask_is_set(int mask, int cid) { return (mask&cmask_one(cid)) != 0; }
|
|
|
|
#endif
|