root / branches / cpp-ode / src / libmmpong / netgame_ode_pong.h @ 542

Revision 542, 2.0 kB (checked in by gaul@…, 6 months ago)
  • move code from .h into .cc files
  • prepare ODEObj for enable()/disable() in order to retrieve corresponding ODEObjs in collision detection
Line 
1#ifndef __NETGAME_ODE_PONG_H__
2#define __NETGAME_ODE_PONG_H__
3
4#include "netgame_ode.h"
5#include "ode_box.h"
6#include "ode_sphere.h"
7
8namespace mmp {
9
10class NetGameODEPong : public NetGameODE {
11                //a similar block has to appear in every "leaf" game
12                //<-- Begin
13        friend class NetGameCreator;
14        private:
15                enum { classid = NetGame::ODEPong };
16        public:
17                static pointer create(NetCon::pointer cln_con_=NetCon::pointer()) {
18                        return pointer(new NetGameODEPong(cln_con_));
19                };
20                virtual NetGame::Class get_classid() { return (NetGame::Class)classid; };
21                //End -->
22        public:
23                NetGameODEPong(NetCon::pointer cln_con) : NetGameODE(cln_con) {
24                        classname="NetGameODEPong";
25                       
26                        //create 2 teams
27                        srv_teamid_cur=0;
28                        team2players[srv_teamid_cur++]=std::set<uint16_t>();
29                        team2players[srv_teamid_cur++]=std::set<uint16_t>();
30                       
31                        mypadpos=0.5;
32                       
33                        //ATTENTION: do not perform server-specific actions here
34                        //           => use srv_init() instead
35                };
36
37                typedef enum {
38                        PlayerEnter=0,
39                        PlayerId,
40                        PlayerLeave,
41                        PlayerPadPos
42                } CmdCustom;
43               
44                //client
45                virtual NetEnt::pointer cln_ent_update(NetMsg::pointer msg);
46                virtual void cln_msg_custom(NetMsg::pointer msg);
47                void cln_set_paddlepos(float pos); //0.0 <= pos <= 1.0
48
49                //server
50                virtual void srv_init();
51                virtual void srv_con_start(NetCon::pointer con);
52                virtual void srv_con_end(NetCon::pointer con);
53                virtual bool srv_msg_process(NetCon::pointer con, NetMsg::pointer msg);
54
55                void print_playerlist(); //mainly for debugging perposes :)
56        protected:
57                std::map<uint16_t, std::set<uint16_t> > team2players; //team2players[teamid] is a set of all playerids in team teamid;
58                std::map<uint16_t, uint16_t> player2team; //player2team[playerid] is teamid
59                std::map<uint16_t, uint16_t> player2pad; //player2pad[playerid] is entid
60
61                //server stuff
62                uint16_t srv_teamid_cur;
63                std::map<NetCon::pointer, uint16_t> srv_con2player; //srv_con2player[con]
64
65                //client stuff
66                uint16_t myplayerid, myteamid, mypadid;
67                float mypadpos;
68};
69
70}
71
72#endif
Note: See TracBrowser for help on using the browser.