67b50dd928a87af7ac0e0ac768a39f61e64da93c
1 (* Copyright (C) DooM 2D:Forever Developers
3 * This program is free software: you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation, either version 3 of the License, or
6 * (at your option) any later version.
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
16 {$INCLUDE g_amodes.inc}
21 uses g_net
, g_netmsg
, ENet
;
23 procedure g_Net_ClientMsgHandler(P
: pENetPacket
);
24 procedure g_Net_ClientLightMsgHandler(P
: pENetPacket
);
25 procedure g_Net_HostMsgHandler(S
: pTNetClient
; P
: pENetPacket
);
29 uses e_fixedbuffer
, e_log
, StrUtils
, SysUtils
;
31 procedure g_Net_ClientMsgHandler(P
: pENetPacket
);
42 while RawPos
< P
^.dataLength
do
44 Len
:= e_Raw_Read_Word(B
);
45 if Len
= 0 then break
;
47 MID
:= e_Raw_Read_Byte(B
);
49 NET_MSG_CHAT
: MC_RECV_Chat(B
);
50 NET_MSG_GFX
: MC_RECV_Effect(B
);
51 NET_MSG_SND
: MC_RECV_Sound(B
);
52 NET_MSG_SCORE
: MC_RECV_GameStats(B
);
53 NET_MSG_COOP
: MC_RECV_CoopStats(B
);
54 NET_MSG_GEVENT
: MC_RECV_GameEvent(B
);
55 NET_MSG_FLAG
: MC_RECV_FlagEvent(B
);
56 NET_MSG_GSET
: MC_RECV_GameSettings(B
);
58 NET_MSG_PLR
: MC_RECV_PlayerCreate(B
);
59 NET_MSG_PLRPOS
: MC_RECV_PlayerPos(B
);
60 NET_MSG_PLRSTA
: MC_RECV_PlayerStats(B
);
61 NET_MSG_PLRDEL
: MC_RECV_PlayerDelete(B
);
62 NET_MSG_PLRDMG
: MC_RECV_PlayerDamage(B
);
63 NET_MSG_PLRDIE
: MC_RECV_PlayerDeath(B
);
64 NET_MSG_PLRFIRE
:MC_RECV_PlayerFire(B
);
65 NET_MSG_PLRSET
: MC_RECV_PlayerSettings(B
);
67 NET_MSG_MSPAWN
: MC_RECV_MonsterSpawn(B
);
68 NET_MSG_MPOS
: MC_RECV_MonsterPos(B
);
69 NET_MSG_MSTATE
: MC_RECV_MonsterState(B
);
70 NET_MSG_MSHOT
: MC_RECV_MonsterShot(B
);
71 NET_MSG_MDEL
: MC_RECV_MonsterDelete(B
);
73 NET_MSG_SHADD
: MC_RECV_CreateShot(B
);
74 NET_MSG_SHPOS
: MC_RECV_UpdateShot(B
);
75 NET_MSG_SHDEL
: MC_RECV_DeleteShot(B
);
77 NET_MSG_ISPAWN
: MC_RECV_ItemSpawn(B
);
78 NET_MSG_IDEL
: MC_RECV_ItemDestroy(B
);
80 NET_MSG_PSTATE
: MC_RECV_PanelState(B
);
81 NET_MSG_PTEX
: MC_RECV_PanelTexture(B
);
83 NET_MSG_TSOUND
: MC_RECV_TriggerSound(B
);
84 NET_MSG_TMUSIC
: MC_RECV_TriggerMusic(B
);
86 NET_MSG_TIME_SYNC
: MC_RECV_TimeSync(B
);
87 NET_MSG_VOTE_EVENT
: MC_RECV_VoteEvent(B
);
91 enet_packet_destroy(P
);
94 procedure g_Net_ClientLightMsgHandler(P
: pENetPacket
);
103 if B
= nil then Exit
;
105 while RawPos
< P
^.dataLength
do
107 Len
:= e_Raw_Read_Word(B
);
108 if Len
= 0 then break
;
110 MID
:= e_Raw_Read_Byte(B
);
112 NET_MSG_GEVENT
: MC_RECV_GameEvent(B
);
113 NET_MSG_GSET
: MC_RECV_GameSettings(B
);
116 if NetState
<> NET_STATE_AUTH
then MC_RECV_PlayerCreate(B
)
117 else RawPos
:= RawPos
+ Len
-1;
119 if NetState
<> NET_STATE_AUTH
then MC_RECV_PlayerDelete(B
)
120 else RawPos
:= RawPos
+ Len
-1;
122 else RawPos
:= RawPos
+ Len
-1;
126 enet_packet_destroy(P
);
129 procedure g_Net_HostMsgHandler(S
: pTNetClient
; P
: pENetPacket
);
138 if B
= nil then Exit
;
140 while RawPos
< P
^.dataLength
do
142 Len
:= e_Raw_Read_Word(B
);
143 if Len
= 0 then break
;
145 MID
:= e_Raw_Read_Byte(B
);
147 NET_MSG_INFO
: MH_RECV_Info(S
, B
);
148 NET_MSG_CHAT
: MH_RECV_Chat(S
, B
);
149 NET_MSG_REQFST
: MH_RECV_FullStateRequest(S
, B
);
151 NET_MSG_PLRPOS
: MH_RECV_PlayerPos(S
, B
);
152 NET_MSG_PLRSET
: MH_RECV_PlayerSettings(S
, B
);
153 NET_MSG_CHEAT
: MH_RECV_CheatRequest(S
, B
);
155 NET_MSG_RCON_AUTH
: MH_RECV_RCONPassword(S
, B
);
156 NET_MSG_RCON_CMD
: MH_RECV_RCONCommand(S
, B
);
158 NET_MSG_MAP_REQUEST
: MH_RECV_MapRequest(S
, B
);
159 NET_MSG_RES_REQUEST
: MH_RECV_ResRequest(S
, B
);
161 NET_MSG_VOTE_EVENT
: MH_RECV_Vote(S
, B
);
165 enet_packet_destroy(P
);