2008-08-27 15:48:50 +00:00
|
|
|
|
|
|
|
#include <base/vmath.hpp>
|
|
|
|
#include <game/gamecore.hpp>
|
2008-10-20 23:46:39 +00:00
|
|
|
#include "render.hpp"
|
2008-08-27 15:48:50 +00:00
|
|
|
|
|
|
|
class GAMECLIENT
|
|
|
|
{
|
|
|
|
class STACK
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
enum
|
|
|
|
{
|
|
|
|
MAX_COMPONENTS = 64,
|
|
|
|
};
|
|
|
|
|
|
|
|
STACK();
|
|
|
|
void add(class COMPONENT *component);
|
|
|
|
|
|
|
|
class COMPONENT *components[MAX_COMPONENTS];
|
|
|
|
int num;
|
|
|
|
};
|
|
|
|
|
|
|
|
STACK all;
|
|
|
|
STACK input;
|
|
|
|
|
|
|
|
void dispatch_input();
|
|
|
|
void process_events();
|
|
|
|
void update_local_character_pos();
|
|
|
|
|
|
|
|
int predicted_tick;
|
|
|
|
int last_new_predicted_tick;
|
|
|
|
|
2008-08-31 13:36:30 +00:00
|
|
|
static void con_team(void *result, void *user_data);
|
|
|
|
static void con_kill(void *result, void *user_data);
|
|
|
|
|
2008-08-27 15:48:50 +00:00
|
|
|
public:
|
|
|
|
|
2008-08-29 05:34:18 +00:00
|
|
|
// TODO: move this
|
|
|
|
TUNING_PARAMS tuning;
|
|
|
|
|
2008-08-27 15:48:50 +00:00
|
|
|
vec2 local_character_pos;
|
|
|
|
vec2 local_target_pos;
|
|
|
|
|
2008-08-30 21:09:13 +00:00
|
|
|
// predicted players
|
|
|
|
CHARACTER_CORE predicted_prev_char;
|
|
|
|
CHARACTER_CORE predicted_char;
|
|
|
|
|
2008-08-27 15:48:50 +00:00
|
|
|
// snap pointers
|
|
|
|
struct SNAPSTATE
|
|
|
|
{
|
|
|
|
const NETOBJ_CHARACTER *local_character;
|
|
|
|
const NETOBJ_CHARACTER *local_prev_character;
|
|
|
|
const NETOBJ_PLAYER_INFO *local_info;
|
|
|
|
const NETOBJ_FLAG *flags[2];
|
|
|
|
const NETOBJ_GAME *gameobj;
|
|
|
|
|
|
|
|
const NETOBJ_PLAYER_INFO *player_infos[MAX_CLIENTS];
|
|
|
|
const NETOBJ_PLAYER_INFO *info_by_score[MAX_CLIENTS];
|
2008-09-23 07:43:41 +00:00
|
|
|
|
|
|
|
int local_cid;
|
2008-08-27 15:48:50 +00:00
|
|
|
int num_players;
|
2008-09-01 18:17:01 +00:00
|
|
|
int team_size[2];
|
2008-09-09 15:50:41 +00:00
|
|
|
bool spectate;
|
2008-09-23 07:43:41 +00:00
|
|
|
|
|
|
|
//
|
|
|
|
struct CHARACTERINFO
|
|
|
|
{
|
|
|
|
bool active;
|
|
|
|
|
|
|
|
// snapshots
|
|
|
|
NETOBJ_CHARACTER prev;
|
|
|
|
NETOBJ_CHARACTER cur;
|
|
|
|
|
|
|
|
// interpolated position
|
|
|
|
vec2 position;
|
|
|
|
};
|
|
|
|
|
|
|
|
CHARACTERINFO characters[MAX_CLIENTS];
|
2008-08-27 15:48:50 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
SNAPSTATE snap;
|
|
|
|
|
|
|
|
// client data
|
|
|
|
struct CLIENT_DATA
|
|
|
|
{
|
2008-10-06 18:05:01 +00:00
|
|
|
int use_custom_color;
|
|
|
|
int color_body;
|
|
|
|
int color_feet;
|
|
|
|
|
2008-08-27 15:48:50 +00:00
|
|
|
char name[64];
|
|
|
|
char skin_name[64];
|
|
|
|
int skin_id;
|
|
|
|
int skin_color;
|
|
|
|
int team;
|
|
|
|
int emoticon;
|
|
|
|
int emoticon_start;
|
|
|
|
CHARACTER_CORE predicted;
|
|
|
|
|
|
|
|
TEE_RENDER_INFO skin_info; // this is what the server reports
|
|
|
|
TEE_RENDER_INFO render_info; // this is what we use
|
|
|
|
|
|
|
|
float angle;
|
|
|
|
|
|
|
|
void update_render_info();
|
|
|
|
};
|
|
|
|
|
|
|
|
CLIENT_DATA clients[MAX_CLIENTS];
|
|
|
|
|
|
|
|
void on_reset();
|
|
|
|
|
|
|
|
// hooks
|
|
|
|
void on_connected();
|
|
|
|
void on_render();
|
|
|
|
void on_init();
|
2008-09-04 21:36:44 +00:00
|
|
|
void on_save();
|
|
|
|
void on_console_init();
|
2008-08-27 15:48:50 +00:00
|
|
|
void on_statechange(int new_state, int old_state);
|
|
|
|
void on_message(int msgtype);
|
|
|
|
void on_snapshot();
|
|
|
|
void on_predict();
|
|
|
|
int on_snapinput(int *data);
|
|
|
|
|
|
|
|
// actions
|
|
|
|
// TODO: move these
|
|
|
|
void send_switch_team(int team);
|
|
|
|
void send_info(bool start);
|
|
|
|
void send_kill(int client_id);
|
|
|
|
|
|
|
|
// pointers to all systems
|
|
|
|
class CONSOLE *console;
|
|
|
|
class BINDS *binds;
|
|
|
|
class PARTICLES *particles;
|
|
|
|
class MENUS *menus;
|
|
|
|
class SKINS *skins;
|
|
|
|
class FLOW *flow;
|
|
|
|
class CHAT *chat;
|
|
|
|
class DAMAGEIND *damageind;
|
|
|
|
class CAMERA *camera;
|
|
|
|
class CONTROLS *controls;
|
|
|
|
class EFFECTS *effects;
|
2008-08-29 05:34:18 +00:00
|
|
|
class SOUNDS *sounds;
|
2008-08-30 08:26:36 +00:00
|
|
|
class MOTD *motd;
|
2008-09-01 05:54:00 +00:00
|
|
|
class MAPIMAGES *mapimages;
|
2008-09-24 14:47:03 +00:00
|
|
|
class VOTING *voting;
|
2008-08-27 15:48:50 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
extern GAMECLIENT gameclient;
|
|
|
|
|