| 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 | |
|---|
| 8 | namespace mmp { |
|---|
| 9 | |
|---|
| 10 | class NetGameODEPong : public NetGameODE { |
|---|
| 11 | |
|---|
| 12 | |
|---|
| 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 | |
|---|
| 22 | public: |
|---|
| 23 | NetGameODEPong(NetCon::pointer cln_con) : NetGameODE(cln_con) { |
|---|
| 24 | classname="NetGameODEPong"; |
|---|
| 25 | |
|---|
| 26 | |
|---|
| 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 | |
|---|
| 34 | |
|---|
| 35 | }; |
|---|
| 36 | |
|---|
| 37 | typedef enum { |
|---|
| 38 | PlayerEnter=0, |
|---|
| 39 | PlayerId, |
|---|
| 40 | PlayerLeave, |
|---|
| 41 | PlayerPadPos |
|---|
| 42 | } CmdCustom; |
|---|
| 43 | |
|---|
| 44 | |
|---|
| 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); |
|---|
| 48 | |
|---|
| 49 | |
|---|
| 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(); |
|---|
| 56 | protected: |
|---|
| 57 | std::map<uint16_t, std::set<uint16_t> > team2players; |
|---|
| 58 | std::map<uint16_t, uint16_t> player2team; |
|---|
| 59 | std::map<uint16_t, uint16_t> player2pad; |
|---|
| 60 | |
|---|
| 61 | |
|---|
| 62 | uint16_t srv_teamid_cur; |
|---|
| 63 | std::map<NetCon::pointer, uint16_t> srv_con2player; |
|---|
| 64 | |
|---|
| 65 | |
|---|
| 66 | uint16_t myplayerid, myteamid, mypadid; |
|---|
| 67 | float mypadpos; |
|---|
| 68 | }; |
|---|
| 69 | |
|---|
| 70 | } |
|---|
| 71 | |
|---|
| 72 | #endif |
|---|