index afc88a72944396474173303e5852c5e486a88afa..bc7d4ae30aaa7e19d9d8671d5e32106ab5166b1f 100644 (file)
--- a/src/game/g_netmaster.pas
+++ b/src/game/g_netmaster.pas
-{$MODE DELPHI}
+(* Copyright (C) DooM 2D:Forever Developers
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *)
+{$INCLUDE g_amodes.inc}
unit g_netmaster;
interface
uses
SysUtils, e_fixedbuffer, e_input, e_graphics, e_log, g_window, g_net, g_console,
- g_map, g_game, g_sound, g_textures, g_gui, g_menu, g_options, g_language, wadreader,
- ENetPlatform;
+ g_map, g_game, g_sound, g_textures, g_gui, g_menu, g_options, g_language, wadreader;
var
NetMEvent: ENetEvent;
e_Buffer_Clear(@NetOut);
e_Buffer_Write(@NetOut, Byte(NET_MMSG_GET));
- P := enet_packet_create(Addr(NetOut.Data), NetOut.Len, Cardinal(ENET_PACKET_FLAG_RELIABLE));
+ P := enet_packet_create(Addr(NetOut.Data), NetOut.WritePos, Cardinal(ENET_PACKET_FLAG_RELIABLE));
enet_peer_send(NetMPeer, NET_MCHAN_MAIN, P);
enet_host_flush(NetMHost);
Cnt := e_Raw_Read_Byte(NetMEvent.packet^.data);
e_WriteLog('Retrieved ' + IntToStr(Cnt) + ' server(s).', MSG_NOTIFY);
g_Console_Add(_lc[I_NET_MSG] + Format(_lc[I_NET_SLIST_RETRIEVED], [Cnt]), True);
+ //writeln('BOO!');
if Cnt > 0 then
begin
RX := enet_socket_receive(Sock, @SvAddr, @Buf, 1);
if RX <= 0 then continue;
- NetIn.Len := RX + 1;
+ NetIn.Cap := RX + 1;
NetIn.ReadPos := 0;
if e_Buffer_Read_Char(@NetIn) <> 'D' then continue;
g_Net_Slist_WriteInfo();
- P := enet_packet_create(Addr(NetOut.Data), NetOut.Len, Cardinal(ENET_PACKET_FLAG_RELIABLE));
+ P := enet_packet_create(Addr(NetOut.Data), NetOut.WritePos, Cardinal(ENET_PACKET_FLAG_RELIABLE));
enet_peer_send(NetMPeer, NET_MCHAN_UPD, P);
enet_host_flush(NetMHost);
e_Buffer_Write(@NetOut, Byte(NET_MMSG_DEL));
e_Buffer_Write(@NetOut, NetAddr.port);
- P := enet_packet_create(Addr(NetOut.Data), NetOut.Len, Cardinal(ENET_PACKET_FLAG_RELIABLE));
+ P := enet_packet_create(Addr(NetOut.Data), NetOut.WritePos, Cardinal(ENET_PACKET_FLAG_RELIABLE));
enet_peer_send(NetMPeer, NET_MCHAN_MAIN, P);
enet_host_flush(NetMHost);