DEADSOFTWARE

put "{$MODE ...}" directive in each source file; removed trailing spaces, and convert...
[d2df-sdl.git] / src / game / g_nethandler.pas
1 {$MODE DELPHI}
2 unit g_nethandler;
4 interface
6 uses g_net, g_netmsg, ENet;
8 procedure g_Net_ClientMsgHandler(P: pENetPacket);
9 procedure g_Net_ClientLightMsgHandler(P: pENetPacket);
10 procedure g_Net_HostMsgHandler(S: pTNetClient; P: pENetPacket);
12 implementation
14 uses e_fixedbuffer;
16 procedure g_Net_ClientMsgHandler(P: pENetPacket);
17 var
18 MID: Byte;
19 B: Pointer;
20 begin
21 e_Raw_Seek(0);
23 B := P^.data;
24 if B = nil then Exit;
26 MID := e_Raw_Read_Byte(B);
28 case MID of
29 NET_MSG_CHAT: MC_RECV_Chat(B);
30 NET_MSG_GFX: MC_RECV_Effect(B);
31 NET_MSG_SND: MC_RECV_Sound(B);
32 NET_MSG_SCORE: MC_RECV_GameStats(B);
33 NET_MSG_COOP: MC_RECV_CoopStats(B);
34 NET_MSG_GEVENT: MC_RECV_GameEvent(B);
35 NET_MSG_FLAG: MC_RECV_FlagEvent(B);
36 NET_MSG_GSET: MC_RECV_GameSettings(B);
38 NET_MSG_PLR: MC_RECV_PlayerCreate(B);
39 NET_MSG_PLRPOS: MC_RECV_PlayerPos(B);
40 NET_MSG_PLRSTA: MC_RECV_PlayerStats(B);
41 NET_MSG_PLRDEL: MC_RECV_PlayerDelete(B);
42 NET_MSG_PLRDMG: MC_RECV_PlayerDamage(B);
43 NET_MSG_PLRDIE: MC_RECV_PlayerDeath(B);
44 NET_MSG_PLRFIRE:MC_RECV_PlayerFire(B);
45 NET_MSG_PLRSET: MC_RECV_PlayerSettings(B);
47 NET_MSG_MSPAWN: MC_RECV_MonsterSpawn(B);
48 NET_MSG_MPOS: MC_RECV_MonsterPos(B);
49 NET_MSG_MSTATE: MC_RECV_MonsterState(B);
50 NET_MSG_MSHOT: MC_RECV_MonsterShot(B);
51 NET_MSG_MDEL: MC_RECV_MonsterDelete(B);
53 NET_MSG_SHADD: MC_RECV_CreateShot(B);
54 NET_MSG_SHPOS: MC_RECV_UpdateShot(B);
55 NET_MSG_SHDEL: MC_RECV_DeleteShot(B);
57 NET_MSG_ISPAWN: MC_RECV_ItemSpawn(B);
58 NET_MSG_IDEL: MC_RECV_ItemDestroy(B);
60 NET_MSG_PSTATE: MC_RECV_PanelState(B);
61 NET_MSG_PTEX: MC_RECV_PanelTexture(B);
63 NET_MSG_TSOUND: MC_RECV_TriggerSound(B);
64 NET_MSG_TMUSIC: MC_RECV_TriggerMusic(B);
66 NET_MSG_TIME_SYNC: MC_RECV_TimeSync(B);
67 NET_MSG_VOTE_EVENT: MC_RECV_VoteEvent(B);
68 end;
70 enet_packet_destroy(P);
71 end;
73 procedure g_Net_ClientLightMsgHandler(P: pENetPacket);
74 var
75 MID: Byte;
76 B: Pointer;
77 begin
78 e_Raw_Seek(0);
80 B := P^.data;
81 if B = nil then Exit;
83 MID := e_Raw_Read_Byte(B);
85 case MID of
86 NET_MSG_GEVENT: MC_RECV_GameEvent(B);
87 NET_MSG_GSET: MC_RECV_GameSettings(B);
89 NET_MSG_PLR: if NetState <> NET_STATE_AUTH then MC_RECV_PlayerCreate(B);
90 NET_MSG_PLRDEL: if NetState <> NET_STATE_AUTH then MC_RECV_PlayerDelete(B);
91 end;
93 enet_packet_destroy(P);
94 end;
96 procedure g_Net_HostMsgHandler(S: pTNetClient; P: pENetPacket);
97 var
98 MID: Byte;
99 B: Pointer;
100 begin
101 e_Raw_Seek(0);
103 B := P^.data;
104 if B = nil then Exit;
106 MID := e_Raw_Read_Byte(B);
108 case MID of
109 NET_MSG_INFO: MH_RECV_Info(S, B);
110 NET_MSG_CHAT: MH_RECV_Chat(S, B);
111 NET_MSG_REQFST: MH_RECV_FullStateRequest(S, B);
113 NET_MSG_PLRPOS: MH_RECV_PlayerPos(S, B);
114 NET_MSG_PLRSET: MH_RECV_PlayerSettings(S, B);
115 NET_MSG_CHEAT: MH_RECV_CheatRequest(S, B);
117 NET_MSG_RCON_AUTH: MH_RECV_RCONPassword(S, B);
118 NET_MSG_RCON_CMD: MH_RECV_RCONCommand(S, B);
120 NET_MSG_MAP_REQUEST: MH_RECV_MapRequest(S, B);
121 NET_MSG_RES_REQUEST: MH_RECV_ResRequest(S, B);
123 NET_MSG_VOTE_EVENT: MH_RECV_Vote(S, B);
124 end;
126 enet_packet_destroy(P);
127 end;
129 end.