source: abuse/trunk/src/net/gserver.h @ 671

Last change on this file since 671 was 481, checked in by Sam Hocevar, 12 years ago

Fuck the history, I'm renaming all .hpp files to .h for my own sanity.

  • Property svn:keywords set to Id
File size: 2.1 KB
Line 
1#ifndef __GSERVER_HPP_
2#define __GSERVER_HPP_
3
4#define MAX_JOINERS 32  // maximum clients that can join at the same time
5
6#include "sock.h"
7#include "ghandler.h"
8
9class game_server : public game_handler
10{
11  class player_client
12  {
13    unsigned char flags;
14    enum { Has_joined=1,
15       Wait_reload=2,
16       Wait_input=4,
17       Need_reload_start_ok=8,
18       Delete_me=16 };
19    int get_flag(int flag)         { return flags&flag; }
20    void set_flag(int flag, int x) { if (x) flags|=flag; else flags&=~flag; }
21
22    public :
23    int has_joined() { return get_flag(Has_joined); }
24    void set_has_joined(int x) { set_flag(Has_joined,x); }
25
26    int wait_input() { return get_flag(Wait_input); }
27    void set_wait_input(int x) { set_flag(Wait_input,x); }
28
29    int wait_reload() { return get_flag(Wait_reload); }
30    void set_wait_reload(int x) { set_flag(Wait_reload,x); }
31
32    int delete_me() { return get_flag(Delete_me); }
33    void set_delete_me(int x) { set_flag(Delete_me,x); }
34
35    int need_reload_start_ok() { return get_flag(Need_reload_start_ok); }
36    void set_need_reload_start_ok(int x) { set_flag(Need_reload_start_ok,x); }
37
38    int client_id;
39    net_socket *comm;
40    net_address *data_address;
41    player_client *next;
42    player_client(int client_id, net_socket *comm, net_address *data_address, player_client *next) :
43      client_id(client_id), comm(comm), data_address(data_address), next(next)
44      {
45    flags=0;
46    set_wait_input(1);
47    comm->read_selectable();
48      };
49    ~player_client();
50  } ;
51
52  player_client *player_list;
53  int waiting_server_input, reload_state;
54
55  void add_client_input(char *buf, int size, player_client *c);
56  void check_collection_complete();
57  void check_reload_wait();
58  int process_client_command(player_client *c);
59  int isa_client(int client_id);
60  public :
61  virtual void game_start_wait();
62  int total_players();
63  int process_net();
64  void add_engine_input();
65  int input_missing();
66  virtual int start_reload();
67  virtual int end_reload(int disconnect=0);
68  virtual int add_client(int type, net_socket *sock, net_address *from);
69  virtual int kill_slackers();
70  virtual int quit();
71  game_server();
72  ~game_server();
73} ;
74
75#endif
Note: See TracBrowser for help on using the repository browser.