Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found
Select Git revision

Target

Select target project
  • STJr/SRB2
  • Sryder/SRB2
  • wolfy852/SRB2
  • Alpha2244/SRB2
  • Inuyasha/SRB2
  • yoshibot/SRB2
  • TehRealSalt/SRB2
  • PrisimaTF/SRB2
  • Hatninja/SRB2
  • SteelT/SRB2
  • james/SRB2
  • ShaderWraith/SRB2
  • SinnamonLat/SRB2
  • mazmazz_/SRB2
  • filpAM/SRB2
  • chaoloveicemdboy/SRB2
  • Whooa21/SRB2
  • Machturne/SRB2
  • Golden/SRB2
  • Tatsuru/SRB2
  • Snu/SRB2
  • Zwip-Zwap_Zapony/SRB2
  • fickleheart/SRB2
  • alphaRexJames/SRB2
  • JJK/SRB2
  • diskpoppy/SRB2
  • Hannu_Hanhi/SRB2
  • ZipperQR/SRB2
  • kays/SRB2
  • spherallic/SRB2
  • Zippy_Zolton/SRB2
  • namiishere/SRB2
  • Ors/SRB2
  • SMS_Alfredo/SRB2
  • sonic_edge/SRB2
  • lavla/SRB2
  • ashi/SRB2
  • X.organic/SRB2
  • Fafabis/SRB2
  • Meziu/SRB2
  • v-rob/SRB2
  • tertu/SRB2
  • bitten2up/SRB2
  • flarn2006/SRB2
  • Krabs/SRB2
  • clairebun/SRB2
  • Lactozilla/SRB2
  • thehackstack/SRB2
  • Spice/SRB2
  • win8linux/SRB2
  • JohnFrostFox/SRB2
  • talktoneon726/SRB2
  • Wane/SRB2
  • Lamibe/SRB2
  • spectrumuk2/srb-2
  • nerdyminer18/srb-2
  • 256nil/SRB2
  • ARJr/SRB2
  • Alam/SRB2
  • Zenya/srb-2-marathon-demos
  • Acelite/srb-2-archivedmodifications
  • MIDIMan/SRB2
  • Lach/SRB2
  • Frostiikin/bounce-tweaks
  • Hanicef/SRB2Classic
  • Jaden/SRB2
  • Tyron/SRB2
  • Astronight/SRB2
  • Mari0shi06/SRB2
  • aiire/SRB2
  • Galactice/SRB2
  • srb2-ports/srb2-dreamcast
  • sdasdas/SRB2
  • chreas/srb-2-vr
  • StarManiaKG/the-story-of-sinically-rocketing-and-botching-the-2nd
  • LoganAir/SRB2
  • NepDisk/srb-2
  • alufolie91/SRB2
  • Felicia.iso/SRB2
  • twi/SRB2
  • BarrelsOFun/SRB2
  • Speed2411/SRB2
  • Leather_Realms/SRB2
  • Ayemar/SRB2
  • Acelite/SRB2
  • VladDoc/SRB2
  • kaldrum/model-features
  • strawberryfox417/SRB2
  • Lugent/SRB2
  • Jisk/SRB2
  • Rem/SRB2
  • Refrag/SRB2
  • Henry_3230/srb-3230
  • TehPuertoRicanSpartan2/tprs-srb2
  • Leminn/srb-2-marathon-stuff
  • chromaticpipe2/SRB2
  • MiguelGustavo15/SRB2
  • Maru/srb-2-tests
  • SilicDev/SRB2
  • UnmatchedBracket/SRB2
  • HybridDog/SRB2
  • xordspar0/SRB2
  • jsjhbewfhh/SRB2
  • Fancy2209/SRB2
  • Lorsoen/SRB2
  • shindoukin/SRB2
  • GamerOfDays/SRB2
  • Craftyawesome/SRB2
  • tenshi-tensai-tennoji/SRB2
  • Scarfdudebalder/SRB2
  • luigi-budd/srb-2-fix-interplag-lockon
  • mskluesner/SRB2
  • johnpetersa19/SRB2
  • Pheazant/SRB2
  • chromaticpipe2/srb2classic
  • romoney5/SRB2
  • PAS/SRB2Classic
  • BlueStaggo/SRB2
118 results
Select Git revision
Show changes
Commits on Source (123)
# Find ENet
# Once done, this will define
#
# ENET_FOUND - system has SDL2
# ENET_INCLUDE_DIRS - SDL2 include directories
# ENET_LIBRARIES - link libraries
include(LibFindMacros)
libfind_pkg_check_modules(ENET_PKGCONF ENET)
# includes
find_path(ENET_INCLUDE_DIR
NAMES enet.h
PATHS
${ENET_PKGCONF_INCLUDE_DIRS}
"/usr/include/enet"
"/usr/local/include/enet"
)
# library
find_library(ENET_LIBRARY
NAMES libenet
PATHS
${ENET_PKGCONF_LIBRARY_DIRS}
"/usr/lib"
"/usr/local/lib"
)
# set include dir variables
set(ENET_PROCESS_INCLUDES ENET_INCLUDE_DIR)
set(ENET_PROCESS_LIBS ENET_LIBRARY)
libfind_process(ENET)
...@@ -8,8 +8,9 @@ set(SRB2_CORE_SOURCES ...@@ -8,8 +8,9 @@ set(SRB2_CORE_SOURCES
comptime.c comptime.c
console.c console.c
d_clisrv.c d_clisrv.c
d_datawrap.c
d_enet.c
d_main.c d_main.c
d_net.c
d_netcmd.c d_netcmd.c
d_netfil.c d_netfil.c
dehacked.c dehacked.c
...@@ -19,7 +20,6 @@ set(SRB2_CORE_SOURCES ...@@ -19,7 +20,6 @@ set(SRB2_CORE_SOURCES
g_game.c g_game.c
g_input.c g_input.c
hu_stuff.c hu_stuff.c
i_tcp.c
info.c info.c
lzf.c lzf.c
m_anigif.c m_anigif.c
...@@ -33,7 +33,6 @@ set(SRB2_CORE_SOURCES ...@@ -33,7 +33,6 @@ set(SRB2_CORE_SOURCES
m_queue.c m_queue.c
m_random.c m_random.c
md5.c md5.c
mserv.c
s_sound.c s_sound.c
screen.c screen.c
sounds.c sounds.c
...@@ -53,9 +52,10 @@ set(SRB2_CORE_HEADERS ...@@ -53,9 +52,10 @@ set(SRB2_CORE_HEADERS
command.h command.h
console.h console.h
d_clisrv.h d_clisrv.h
d_datawrap.h
d_enet.h
d_event.h d_event.h
d_main.h d_main.h
d_net.h
d_netcmd.h d_netcmd.h
d_netfil.h d_netfil.h
d_player.h d_player.h
...@@ -75,10 +75,8 @@ set(SRB2_CORE_HEADERS ...@@ -75,10 +75,8 @@ set(SRB2_CORE_HEADERS
g_state.h g_state.h
hu_stuff.h hu_stuff.h
i_joy.h i_joy.h
i_net.h
i_sound.h i_sound.h
i_system.h i_system.h
i_tcp.h
i_video.h i_video.h
info.h info.h
keys.h keys.h
...@@ -96,7 +94,6 @@ set(SRB2_CORE_HEADERS ...@@ -96,7 +94,6 @@ set(SRB2_CORE_HEADERS
m_random.h m_random.h
m_swap.h m_swap.h
md5.h md5.h
mserv.h
p5prof.h p5prof.h
s_sound.h s_sound.h
screen.h screen.h
...@@ -402,6 +399,8 @@ else() ...@@ -402,6 +399,8 @@ else()
add_definitions(-DNOASM -DNONX86) add_definitions(-DNOASM -DNONX86)
endif() endif()
find_package(ENet)
# Targets # Targets
# Compatibility flag with later versions of GCC # Compatibility flag with later versions of GCC
......
...@@ -414,7 +414,6 @@ OBJS:=$(i_main_o) \ ...@@ -414,7 +414,6 @@ OBJS:=$(i_main_o) \
$(OBJDIR)/string.o \ $(OBJDIR)/string.o \
$(OBJDIR)/d_main.o \ $(OBJDIR)/d_main.o \
$(OBJDIR)/d_clisrv.o \ $(OBJDIR)/d_clisrv.o \
$(OBJDIR)/d_net.o \
$(OBJDIR)/d_netfil.o \ $(OBJDIR)/d_netfil.o \
$(OBJDIR)/d_netcmd.o \ $(OBJDIR)/d_netcmd.o \
$(OBJDIR)/dehacked.o \ $(OBJDIR)/dehacked.o \
...@@ -473,13 +472,12 @@ OBJS:=$(i_main_o) \ ...@@ -473,13 +472,12 @@ OBJS:=$(i_main_o) \
$(OBJDIR)/sounds.o \ $(OBJDIR)/sounds.o \
$(OBJDIR)/w_wad.o \ $(OBJDIR)/w_wad.o \
$(OBJDIR)/filesrch.o \ $(OBJDIR)/filesrch.o \
$(OBJDIR)/mserv.o \ $(OBJDIR)/lzf.o \
$(OBJDIR)/i_tcp.o \
$(OBJDIR)/lzf.o \
$(OBJDIR)/vid_copy.o \ $(OBJDIR)/vid_copy.o \
$(OBJDIR)/d_enet.o \
$(OBJDIR)/d_datawrap.o \
$(OBJDIR)/b_bot.o \ $(OBJDIR)/b_bot.o \
$(i_cdmus_o) \ $(i_cdmus_o) \
$(i_net_o) \
$(i_system_o) \ $(i_system_o) \
$(i_sound_o) \ $(i_sound_o) \
$(OBJS) $(OBJS)
......
...@@ -273,11 +273,11 @@ void B_RespawnBot(INT32 playernum) ...@@ -273,11 +273,11 @@ void B_RespawnBot(INT32 playernum)
P_TeleportMove(tails, x, y, z); P_TeleportMove(tails, x, y, z);
if (player->charability == CA_FLY) if (player->charability == CA_FLY)
{ {
P_SetPlayerMobjState(tails, S_PLAY_ABL1); P_SetPlayerMobjState(tails, S_PLAY_FLY);
tails->player->powers[pw_tailsfly] = (UINT16)-1; tails->player->powers[pw_tailsfly] = (UINT16)-1;
} }
else else
P_SetPlayerMobjState(tails, S_PLAY_FALL1); P_SetPlayerMobjState(tails, S_PLAY_FALL);
P_SetScale(tails, sonic->scale); P_SetScale(tails, sonic->scale);
tails->destscale = sonic->destscale; tails->destscale = sonic->destscale;
} }
...@@ -1225,7 +1225,7 @@ static void Got_NetVar(UINT8 **p, INT32 playernum) ...@@ -1225,7 +1225,7 @@ static void Got_NetVar(UINT8 **p, INT32 playernum)
XBOXSTATIC UINT8 buf[2]; XBOXSTATIC UINT8 buf[2];
buf[0] = (UINT8)playernum; buf[0] = (UINT8)playernum;
buf[1] = KICK_MSG_CON_FAIL; buf[1] = KICK_MSG_STOP_HACKING;
SendNetXCmd(XD_KICK, &buf, 2); SendNetXCmd(XD_KICK, &buf, 2);
} }
return; return;
......
...@@ -248,11 +248,11 @@ void CON_ReSetupBackColormap(UINT16 num) ...@@ -248,11 +248,11 @@ void CON_ReSetupBackColormap(UINT16 num)
{ {
j = pal[i] + pal[i+1] + pal[i+2]; j = pal[i] + pal[i+1] + pal[i+2];
cwhitemap[k] = (UINT8)(15 - (j>>6)); cwhitemap[k] = (UINT8)(15 - (j>>6));
corangemap[k] = (UINT8)(95 - (j>>6)); corangemap[k] = (UINT8)(63 - (j>>6));
cbluemap[k] = (UINT8)(239 - (j>>6)); cbluemap[k] = (UINT8)(159 - (j>>6));
cgreenmap[k] = (UINT8)(175 - (j>>6)); cgreenmap[k] = (UINT8)(111 - (j>>6));
cgraymap[k] = (UINT8)(31 - (j>>6)); cgraymap[k] = (UINT8)(31 - (j>>6));
credmap[k] = (UINT8)(143 - (j>>6)); credmap[k] = (UINT8)(47 - (j>>6));
} }
} }
...@@ -283,11 +283,11 @@ static void CON_SetupBackColormap(void) ...@@ -283,11 +283,11 @@ static void CON_SetupBackColormap(void)
{ {
j = pal[i] + pal[i+1] + pal[i+2]; j = pal[i] + pal[i+1] + pal[i+2];
cwhitemap[k] = (UINT8)(15 - (j>>6)); cwhitemap[k] = (UINT8)(15 - (j>>6));
corangemap[k] = (UINT8)(95 - (j>>6)); corangemap[k] = (UINT8)(63 - (j>>6));
cbluemap[k] = (UINT8)(239 - (j>>6)); cbluemap[k] = (UINT8)(159 - (j>>6));
cgreenmap[k] = (UINT8)(175 - (j>>6)); cgreenmap[k] = (UINT8)(111 - (j>>6));
cgraymap[k] = (UINT8)(31 - (j>>6)); cgraymap[k] = (UINT8)(31 - (j>>6));
credmap[k] = (UINT8)(143 - (j>>6)); credmap[k] = (UINT8)(47 - (j>>6));
} }
// setup the other colormaps, for console text // setup the other colormaps, for console text
...@@ -306,20 +306,20 @@ static void CON_SetupBackColormap(void) ...@@ -306,20 +306,20 @@ static void CON_SetupBackColormap(void)
orangemap[i] = (UINT8)i; orangemap[i] = (UINT8)i;
} }
yellowmap[3] = (UINT8)103; yellowmap[3] = (UINT8)73;
yellowmap[9] = (UINT8)115; yellowmap[9] = (UINT8)66;
purplemap[3] = (UINT8)195; purplemap[3] = (UINT8)184;
purplemap[9] = (UINT8)198; purplemap[9] = (UINT8)186;
lgreenmap[3] = (UINT8)162; lgreenmap[3] = (UINT8)98;
lgreenmap[9] = (UINT8)170; lgreenmap[9] = (UINT8)106;
bluemap[3] = (UINT8)228; bluemap[3] = (UINT8)147;
bluemap[9] = (UINT8)238; bluemap[9] = (UINT8)158;
graymap[3] = (UINT8)10; graymap[3] = (UINT8)10;
graymap[9] = (UINT8)15; graymap[9] = (UINT8)15;
redmap[3] = (UINT8)124; redmap[3] = (UINT8)210;
redmap[9] = (UINT8)127; redmap[9] = (UINT8)32;
orangemap[3] = (UINT8)85; orangemap[3] = (UINT8)52;
orangemap[9] = (UINT8)90; orangemap[9] = (UINT8)57;
} }
// Setup the console text buffer // Setup the console text buffer
......
This diff is collapsed.
...@@ -25,56 +25,7 @@ ...@@ -25,56 +25,7 @@
// be transmitted. // be transmitted.
// Networking and tick handling related. // Networking and tick handling related.
#define BACKUPTICS 32
#define MAXTEXTCMD 256 #define MAXTEXTCMD 256
//
// Packet structure
//
typedef enum
{
PT_NOTHING, // To send a nop through the network. ^_~
PT_SERVERCFG, // Server config used in start game
// (must stay 1 for backwards compatibility).
// This is a positive response to a CLIENTJOIN request.
PT_CLIENTCMD, // Ticcmd of the client.
PT_CLIENTMIS, // Same as above with but saying resend from.
PT_CLIENT2CMD, // 2 cmds in the packet for splitscreen.
PT_CLIENT2MIS, // Same as above with but saying resend from
PT_NODEKEEPALIVE, // Same but without ticcmd and consistancy
PT_NODEKEEPALIVEMIS,
PT_SERVERTICS, // All cmds for the tic.
PT_SERVERREFUSE, // Server refuses joiner (reason inside).
PT_SERVERSHUTDOWN,
PT_CLIENTQUIT, // Client closes the connection.
PT_ASKINFO, // Anyone can ask info of the server.
PT_SERVERINFO, // Send game & server info (gamespy).
PT_PLAYERINFO, // Send information for players in game (gamespy).
PT_REQUESTFILE, // Client requests a file transfer
PT_ASKINFOVIAMS, // Packet from the MS requesting info be sent to new client.
// If this ID changes, update masterserver definition.
PT_RESYNCHEND, // Player is now resynched and is being requested to remake the gametic
PT_RESYNCHGET, // Player got resynch packet
// Add non-PT_CANFAIL packet types here to avoid breaking MS compatibility.
PT_CANFAIL, // This is kind of a priority. Anything bigger than CANFAIL
// allows HSendPacket(,true,,) to return false.
// In addition, this packet can't occupy all the available slots.
PT_FILEFRAGMENT = PT_CANFAIL, // A part of a file.
PT_TEXTCMD, // Extra text commands from the client.
PT_TEXTCMD2, // Splitscreen text commands.
PT_CLIENTJOIN, // Client wants to join; used in start game.
PT_NODETIMEOUT, // Packet sent to self if the connection times out.
PT_RESYNCHING, // Packet sent to resync players.
// Blocks game advance until synched.
#ifdef NEWPING
PT_PING, // Packet sent to tell clients the other client's latency to server.
#endif
NUMPACKETTYPE
} packettype_t;
#if defined(_MSC_VER) #if defined(_MSC_VER)
#pragma pack(1) #pragma pack(1)
...@@ -85,7 +36,6 @@ typedef struct ...@@ -85,7 +36,6 @@ typedef struct
{ {
UINT8 client_tic; UINT8 client_tic;
UINT8 resendfrom; UINT8 resendfrom;
INT16 consistancy;
ticcmd_t cmd; ticcmd_t cmd;
} ATTRPACK clientcmd_pak; } ATTRPACK clientcmd_pak;
...@@ -95,7 +45,6 @@ typedef struct ...@@ -95,7 +45,6 @@ typedef struct
{ {
UINT8 client_tic; UINT8 client_tic;
UINT8 resendfrom; UINT8 resendfrom;
INT16 consistancy;
ticcmd_t cmd, cmd2; ticcmd_t cmd, cmd2;
} ATTRPACK client2cmd_pak; } ATTRPACK client2cmd_pak;
...@@ -113,148 +62,6 @@ typedef struct ...@@ -113,148 +62,6 @@ typedef struct
ticcmd_t cmds[45]; // normally [BACKUPTIC][MAXPLAYERS] but too large ticcmd_t cmds[45]; // normally [BACKUPTIC][MAXPLAYERS] but too large
} ATTRPACK servertics_pak; } ATTRPACK servertics_pak;
// sent to client when all consistency data
// for players has been restored
typedef struct
{
UINT32 randomseed;
//ctf flag stuff
SINT8 flagplayer[2];
INT32 flagloose[2];
INT32 flagflags[2];
fixed_t flagx[2];
fixed_t flagy[2];
fixed_t flagz[2];
UINT32 ingame; // spectator bit for each player
UINT32 ctfteam; // if not spectator, then which team?
// Resynch game scores and the like all at once
UINT32 score[MAXPLAYERS]; // Everyone's score.
INT16 numboxes[MAXPLAYERS];
INT16 totalring[MAXPLAYERS];
tic_t realtime[MAXPLAYERS];
UINT8 laps[MAXPLAYERS];
} ATTRPACK resynchend_pak;
typedef struct
{
//player stuff
UINT8 playernum;
// Do not send anything visual related.
// Only send data that we need to know for physics.
UINT8 playerstate; //playerstate_t
UINT32 pflags; //pflags_t
UINT8 panim; //panim_t
angle_t aiming;
INT32 currentweapon;
INT32 ringweapons;
UINT16 powers[NUMPOWERS];
// Score is resynched in the confirm resync packet
INT32 health;
SINT8 lives;
SINT8 continues;
UINT8 scoreadd;
SINT8 xtralife;
SINT8 pity;
UINT8 skincolor;
INT32 skin;
// Just in case Lua does something like
// modify these at runtime
fixed_t normalspeed;
fixed_t runspeed;
UINT8 thrustfactor;
UINT8 accelstart;
UINT8 acceleration;
UINT8 charability;
UINT8 charability2;
UINT32 charflags;
UINT32 thokitem; //mobjtype_t
UINT32 spinitem; //mobjtype_t
UINT32 revitem; //mobjtype_t
fixed_t actionspd;
fixed_t mindash;
fixed_t maxdash;
fixed_t jumpfactor;
fixed_t speed;
UINT8 jumping;
UINT8 secondjump;
UINT8 fly1;
tic_t glidetime;
UINT8 climbing;
INT32 deadtimer;
tic_t exiting;
UINT8 homing;
tic_t skidtime;
fixed_t cmomx;
fixed_t cmomy;
fixed_t rmomx;
fixed_t rmomy;
INT32 weapondelay;
INT32 tossdelay;
INT16 starpostx;
INT16 starposty;
INT16 starpostz;
INT32 starpostnum;
tic_t starposttime;
angle_t starpostangle;
INT32 maxlink;
fixed_t dashspeed;
INT32 dashtime;
angle_t angle_pos;
angle_t old_angle_pos;
tic_t bumpertime;
INT32 flyangle;
tic_t drilltimer;
INT32 linkcount;
tic_t linktimer;
INT32 anotherflyangle;
tic_t nightstime;
INT32 drillmeter;
UINT8 drilldelay;
UINT8 bonustime;
UINT8 mare;
INT16 lastsidehit, lastlinehit;
tic_t losstime;
UINT8 timeshit;
INT32 onconveyor;
//player->mo stuff
UINT8 hasmo; //boolean
angle_t angle;
fixed_t x;
fixed_t y;
fixed_t z;
fixed_t momx;
fixed_t momy;
fixed_t momz;
fixed_t friction;
fixed_t movefactor;
INT32 tics;
statenum_t statenum;
UINT32 flags;
UINT32 flags2;
UINT16 eflags;
fixed_t radius;
fixed_t height;
fixed_t scale;
fixed_t destscale;
fixed_t scalespeed;
} ATTRPACK resynch_pak;
typedef struct typedef struct
{ {
UINT8 version; // different versions don't work UINT8 version; // different versions don't work
...@@ -383,9 +190,6 @@ typedef struct ...@@ -383,9 +190,6 @@ typedef struct
client2cmd_pak client2pak; // 200 bytes client2cmd_pak client2pak; // 200 bytes
servertics_pak serverpak; // 132495 bytes servertics_pak serverpak; // 132495 bytes
serverconfig_pak servercfg; // 773 bytes serverconfig_pak servercfg; // 773 bytes
resynchend_pak resynchend; //
resynch_pak resynchpak; //
UINT8 resynchgot; //
UINT8 textcmd[MAXTEXTCMD+1]; // 66049 bytes UINT8 textcmd[MAXTEXTCMD+1]; // 66049 bytes
filetx_pak filetxpak; // 139 bytes filetx_pak filetxpak; // 139 bytes
clientconfig_pak clientcfg; // 136 bytes clientconfig_pak clientcfg; // 136 bytes
...@@ -395,9 +199,6 @@ typedef struct ...@@ -395,9 +199,6 @@ typedef struct
msaskinfo_pak msaskinfo; // 22 bytes msaskinfo_pak msaskinfo; // 22 bytes
plrinfo playerinfo[MAXPLAYERS]; // 1152 bytes plrinfo playerinfo[MAXPLAYERS]; // 1152 bytes
plrconfig playerconfig[MAXPLAYERS]; // (up to) 896 bytes plrconfig playerconfig[MAXPLAYERS]; // (up to) 896 bytes
#ifdef NEWPING
UINT32 pingtable[MAXPLAYERS]; // 128 bytes
#endif
} u; // this is needed to pack diff packet types data together } u; // this is needed to pack diff packet types data together
} ATTRPACK doomdata_t; } ATTRPACK doomdata_t;
...@@ -406,35 +207,32 @@ typedef struct ...@@ -406,35 +207,32 @@ typedef struct
#endif #endif
#define MAXSERVERLIST 64 // depends only on the display #define MAXSERVERLIST 64 // depends only on the display
typedef struct
{
SINT8 node;
serverinfo_pak info;
} serverelem_t;
extern serverelem_t serverlist[MAXSERVERLIST];
extern UINT32 serverlistcount;
extern INT32 mapchangepending; extern INT32 mapchangepending;
// points inside doomcom
extern doomdata_t *netbuffer;
extern consvar_t cv_playbackspeed; extern consvar_t cv_playbackspeed;
#define BASEPACKETSIZE ((size_t)&(((doomdata_t *)0)->u)) #define BASEPACKETSIZE ((size_t)&(((doomdata_t *)0)->u))
#define FILETXHEADER ((size_t)((filetx_pak *)0)->data) #define FILETXHEADER ((size_t)((filetx_pak *)0)->data)
#define BASESERVERTICSSIZE ((size_t)&(((doomdata_t *)0)->u.serverpak.cmds[0])) #define BASESERVERTICSSIZE ((size_t)&(((doomdata_t *)0)->u.serverpak.cmds[0]))
#define KICK_MSG_GO_AWAY 1 typedef enum {
#define KICK_MSG_CON_FAIL 2 // Player left
#define KICK_MSG_PLAYER_QUIT 3 KICK_MSG_PLAYER_QUIT,
#define KICK_MSG_TIMEOUT 4
#define KICK_MSG_BANNED 5 // Generic kick/ban
#ifdef NEWPING KICK_MSG_GO_AWAY,
#define KICK_MSG_PING_HIGH 6 KICK_MSG_BANNED,
#endif
#define KICK_MSG_CUSTOM_KICK 7 // Custom kick/ban
#define KICK_MSG_CUSTOM_BAN 8 KICK_MSG_CUSTOM_KICK,
KICK_MSG_CUSTOM_BAN,
// Networking errors
KICK_MSG_TIMEOUT,
KICK_MSG_PING_HIGH,
KICK_MSG_XD_FAIL,
KICK_MSG_STOP_HACKING
} kickmsg_e;
extern boolean server; extern boolean server;
extern boolean dedicated; // for dedicated server extern boolean dedicated; // for dedicated server
...@@ -442,15 +240,7 @@ extern UINT16 software_MAXPACKETLENGTH; ...@@ -442,15 +240,7 @@ extern UINT16 software_MAXPACKETLENGTH;
extern boolean acceptnewnode; extern boolean acceptnewnode;
extern SINT8 servernode; extern SINT8 servernode;
void Command_Ping_f(void); extern consvar_t cv_joinnextround, cv_allownewplayer, cv_maxplayers, cv_maxsend;
extern tic_t connectiontimeout;
#ifdef NEWPING
extern UINT16 pingmeasurecount;
extern UINT32 realpingtable[MAXPLAYERS];
extern UINT32 playerpingtable[MAXPLAYERS];
#endif
extern consvar_t cv_joinnextround, cv_allownewplayer, cv_maxplayers, cv_resynchattempts, cv_blamecfail, cv_maxsend;
// used in d_net, the only dependence // used in d_net, the only dependence
tic_t ExpandTics(INT32 low); tic_t ExpandTics(INT32 low);
...@@ -473,6 +263,7 @@ void CL_AddSplitscreenPlayer(void); ...@@ -473,6 +263,7 @@ void CL_AddSplitscreenPlayer(void);
void CL_RemoveSplitscreenPlayer(void); void CL_RemoveSplitscreenPlayer(void);
void CL_Reset(void); void CL_Reset(void);
void CL_ClearPlayer(INT32 playernum); void CL_ClearPlayer(INT32 playernum);
void CL_RemovePlayer(INT32 playernum);
void CL_UpdateServerList(boolean internetsearch, INT32 room); void CL_UpdateServerList(boolean internetsearch, INT32 room);
// is there a game running // is there a game running
boolean Playing(void); boolean Playing(void);
...@@ -504,5 +295,4 @@ void D_ResetTiccmds(void); ...@@ -504,5 +295,4 @@ void D_ResetTiccmds(void);
tic_t GetLag(INT32 node); tic_t GetLag(INT32 node);
UINT8 GetFreeXCmdSize(void); UINT8 GetFreeXCmdSize(void);
extern UINT8 hu_resynching;
#endif #endif
#include "doomdef.h"
#include "doomstat.h"
#include "byteptr.h"
#include "d_datawrap.h"
#include "z_zone.h"
static void CheckEOF(DataWrap dw, size_t l)
{
if (dw->p - dw->data + l > dw->len)
{
Z_Free(dw);
longjmp(*dw->eofjmp, 1);
}
}
UINT8 DW_ReadUINT8(DataWrap dw)
{
CheckEOF(dw, 1);
return READUINT8(dw->p);
}
UINT16 DW_ReadUINT16(DataWrap dw)
{
CheckEOF(dw, 2);
return READUINT16(dw->p);
}
UINT32 DW_ReadUINT32(DataWrap dw)
{
CheckEOF(dw, 4);
return READUINT32(dw->p);
}
SINT8 DW_ReadSINT8(DataWrap dw)
{
CheckEOF(dw, 1);
return READSINT8(dw->p);
}
INT16 DW_ReadINT16(DataWrap dw)
{
CheckEOF(dw, 2);
return READINT16(dw->p);
}
INT32 DW_ReadINT32(DataWrap dw)
{
CheckEOF(dw, 4);
return READINT32(dw->p);
}
fixed_t DW_ReadFixed(DataWrap dw)
{
CheckEOF(dw, 4);
return READFIXED(dw->p);
}
char *DW_ReadStringn(DataWrap dw, size_t n)
{
char *string = ZZ_Alloc(n+1);
char *p = string;
size_t i;
for (i = 0; i < n; i++, p++)
{
CheckEOF(dw,1);
*p = READUINT8(dw->p);
if (!*p)
break;
}
*p = '\0';
return string;
}
DataWrap D_NewDataWrap(const void *data, size_t len, jmp_buf *eofjmp)
{
DataWrap dw = ZZ_Alloc(sizeof(struct DataWrap_s));
dw->data = dw->p = data;
dw->len = len;
dw->eofjmp = eofjmp;
return dw;
}
// Basically SDL_RWops I guess.
#include <setjmp.h>
typedef struct DataWrap_s {
const void *data, *p;
size_t len;
jmp_buf *eofjmp;
} *DataWrap;
UINT8 DW_ReadUINT8(DataWrap);
UINT16 DW_ReadUINT16(DataWrap);
UINT32 DW_ReadUINT32(DataWrap);
SINT8 DW_ReadSINT8(DataWrap);
INT16 DW_ReadINT16(DataWrap);
INT32 DW_ReadINT32(DataWrap);
fixed_t DW_ReadFixed(DataWrap);
char *DW_ReadStringn(DataWrap, size_t n);
DataWrap D_NewDataWrap(const void *data, size_t len, jmp_buf *eofjmp);
This diff is collapsed.
// Make sure we allocate a network node for every player, "server full" denials, the Master server heartbeat, and potential RCON connections.
#define MAXNETNODES MAXPLAYERS+2
extern UINT8 net_nodecount, net_playercount;
extern UINT16 net_ringid;
extern UINT8 playernode[MAXPLAYERS];
extern SINT8 nodetoplayer[MAXNETNODES];
extern SINT8 nodetoplayer2[MAXNETNODES]; // say the numplayer for this node if any (splitscreen)
extern UINT8 playerpernode[MAXNETNODES]; // used specialy for scplitscreen
extern boolean nodeingame[MAXNETNODES]; // set false as nodes leave game
void D_NetOpen(void);
boolean D_NetConnect(const char *hostname, const char *port);
void Net_GetNetStat(UINT8 node, UINT32 *ping, UINT32 *packetLoss);
void Net_AckTicker(void);
void D_CheckNetGame(void);
void D_CloseConnection(void);
void Net_CloseConnection(INT32 node);
void Net_SendJoin(void);
void Net_SendCharacter(void);
void Net_SendClientMove(boolean force);
void Net_SendClientJump(void);
void Net_SpawnPlayer(UINT8 pnum, UINT8 node);
void Net_SendChat(char *line);
void Net_SendPlayerDamage(UINT8 pnum, UINT8 damagetype);
void Net_SendMobjMove(mobj_t *mobj);
void Net_SendRemove(UINT16 id);
void Net_SendKill(UINT16 id, UINT16 kid);
void Net_SendPlayerRings(UINT8 pnum);
void Net_ResetLevel(void);
void Net_AwardPowerup(player_t *player, powertype_t power, UINT16 data);
...@@ -44,7 +44,6 @@ int snprintf(char *str, size_t n, const char *fmt, ...); ...@@ -44,7 +44,6 @@ int snprintf(char *str, size_t n, const char *fmt, ...);
#include "doomdef.h" #include "doomdef.h"
#include "am_map.h" #include "am_map.h"
#include "console.h" #include "console.h"
#include "d_net.h"
#include "f_finale.h" #include "f_finale.h"
#include "g_game.h" #include "g_game.h"
#include "hu_stuff.h" #include "hu_stuff.h"
...@@ -68,11 +67,11 @@ int snprintf(char *str, size_t n, const char *fmt, ...); ...@@ -68,11 +67,11 @@ int snprintf(char *str, size_t n, const char *fmt, ...);
#include "m_cheat.h" #include "m_cheat.h"
#include "y_inter.h" #include "y_inter.h"
#include "p_local.h" // chasecam #include "p_local.h" // chasecam
#include "mserv.h" // ms_RoomId
#include "m_misc.h" // screenshot functionality #include "m_misc.h" // screenshot functionality
#include "dehacked.h" // Dehacked list test #include "dehacked.h" // Dehacked list test
#include "m_cond.h" // condition initialization #include "m_cond.h" // condition initialization
#include "fastcmp.h" #include "fastcmp.h"
#include "d_enet.h"
#ifdef CMAKECONFIG #ifdef CMAKECONFIG
#include "config.h" #include "config.h"
...@@ -100,6 +99,9 @@ int snprintf(char *str, size_t n, const char *fmt, ...); ...@@ -100,6 +99,9 @@ int snprintf(char *str, size_t n, const char *fmt, ...);
#include "lua_script.h" #include "lua_script.h"
#endif #endif
FILE *debugfile;
// platform independant focus loss // platform independant focus loss
UINT8 window_notinfocus = false; UINT8 window_notinfocus = false;
...@@ -465,21 +467,17 @@ static void D_Display(void) ...@@ -465,21 +467,17 @@ static void D_Display(void)
// //
if (!wipe) if (!wipe)
{ {
if (cv_netstat.value) if (cv_netstat.value && netgame && !server)
{ {
char s[50]; char stat[50];
Net_GetNetStat(); UINT32 ping = 0, loss = 0;
s[sizeof s - 1] = '\0'; stat[sizeof stat - 1] = '\0';
Net_GetNetStat(servernode, &ping, &loss);
snprintf(s, sizeof s - 1, "get %d b/s", getbps); snprintf(stat, sizeof stat - 1, "ping: %u ms (%u frames)", ping, ping / (1000/NEWTICRATE));
V_DrawRightAlignedString(BASEVIDWIDTH, BASEVIDHEIGHT-ST_HEIGHT-40, V_YELLOWMAP, s); V_DrawRightAlignedString(BASEVIDWIDTH, BASEVIDHEIGHT-20, V_YELLOWMAP|V_SNAPTORIGHT|V_SNAPTOBOTTOM, stat);
snprintf(s, sizeof s - 1, "send %d b/s", sendbps); snprintf(stat, sizeof stat - 1, "loss: %u", loss);
V_DrawRightAlignedString(BASEVIDWIDTH, BASEVIDHEIGHT-ST_HEIGHT-30, V_YELLOWMAP, s); V_DrawRightAlignedString(BASEVIDWIDTH, BASEVIDHEIGHT-10, V_YELLOWMAP|V_SNAPTORIGHT|V_SNAPTOBOTTOM, stat);
snprintf(s, sizeof s - 1, "GameMiss %.2f%%", gamelostpercent);
V_DrawRightAlignedString(BASEVIDWIDTH, BASEVIDHEIGHT-ST_HEIGHT-20, V_YELLOWMAP, s);
snprintf(s, sizeof s - 1, "SysMiss %.2f%%", lostpercent);
V_DrawRightAlignedString(BASEVIDWIDTH, BASEVIDHEIGHT-ST_HEIGHT-10, V_YELLOWMAP, s);
} }
I_FinishUpdate(); // page flip or blit buffer I_FinishUpdate(); // page flip or blit buffer
...@@ -566,11 +564,6 @@ void D_SRB2Loop(void) ...@@ -566,11 +564,6 @@ void D_SRB2Loop(void)
HW3S_BeginFrameUpdate(); HW3S_BeginFrameUpdate();
#endif #endif
// don't skip more than 10 frames at a time
// (fadein / fadeout cause massive frame skip!)
if (realtics > 8)
realtics = 1;
// process tics (but maybe not if realtic == 0) // process tics (but maybe not if realtic == 0)
TryRunTics(realtics); TryRunTics(realtics);
...@@ -589,14 +582,6 @@ void D_SRB2Loop(void) ...@@ -589,14 +582,6 @@ void D_SRB2Loop(void)
} }
else if (rendertimeout < entertic) // in case the server hang or netsplit else if (rendertimeout < entertic) // in case the server hang or netsplit
{ {
// Lagless camera! Yay!
if (gamestate == GS_LEVEL && netgame)
{
if (splitscreen && camera2.chase)
P_MoveChaseCamera(&players[secondarydisplayplayer], &camera2, false);
if (camera.chase)
P_MoveChaseCamera(&players[displayplayer], &camera, false);
}
D_Display(); D_Display();
if (moviemode) if (moviemode)
...@@ -1206,21 +1191,9 @@ void D_SRB2Main(void) ...@@ -1206,21 +1191,9 @@ void D_SRB2Main(void)
CONS_Printf("ST_Init(): Init status bar.\n"); CONS_Printf("ST_Init(): Init status bar.\n");
ST_Init(); ST_Init();
if (M_CheckParm("-room"))
{
if (!M_IsNextParm())
I_Error("usage: -room <room_id>\nCheck the Master Server's webpage for room ID numbers.\n");
ms_RoomId = atoi(M_GetNextParm());
#ifdef UPDATE_ALERT
GetMODVersion_Console();
#endif
}
// init all NETWORK // init all NETWORK
CONS_Printf("D_CheckNetGame(): Checking network game status.\n"); CONS_Printf("D_CheckNetGame(): Checking network game status.\n");
if (D_CheckNetGame()) D_CheckNetGame();
autostart = true;
// check for a driver that wants intermission stats // check for a driver that wants intermission stats
// start the apropriate game based on parms // start the apropriate game based on parms
......
This diff is collapsed.
// SONIC ROBO BLAST 2
//-----------------------------------------------------------------------------
// Copyright (C) 1993-1996 by id Software, Inc.
// Copyright (C) 1998-2000 by DooM Legacy Team.
// Copyright (C) 1999-2016 by Sonic Team Junior.
//
// This program is free software distributed under the
// terms of the GNU General Public License, version 2.
// See the 'LICENSE' file for more details.
//-----------------------------------------------------------------------------
/// \file d_net.h
/// \brief part of layer 4 (transport) (tp4) of the osi model
/// assure the reception of packet and proceed a checksums
///
/// There is a data struct that stores network communication related
/// stuff, and one that defines the actual packets to be transmitted
#ifndef __D_NET__
#define __D_NET__
// Max computers in a game.
#define MAXNETNODES 32
#define BROADCASTADDR MAXNETNODES
#define MAXSPLITSCREENPLAYERS 2 // max number of players on a single computer
#define STATLENGTH (TICRATE*2)
// stat of net
extern INT32 ticruned, ticmiss;
extern INT32 getbps, sendbps;
extern float lostpercent, duppercent, gamelostpercent;
extern INT32 packetheaderlength;
boolean Net_GetNetStat(void);
extern INT32 getbytes;
extern INT64 sendbytes; // realtime updated
extern SINT8 nodetoplayer[MAXNETNODES];
extern SINT8 nodetoplayer2[MAXNETNODES]; // say the numplayer for this node if any (splitscreen)
extern UINT8 playerpernode[MAXNETNODES]; // used specialy for scplitscreen
extern boolean nodeingame[MAXNETNODES]; // set false as nodes leave game
void Net_AckTicker(void);
boolean Net_AllAckReceived(void);
// if reliable return true if packet sent, 0 else
boolean HSendPacket(INT32 node, boolean reliable, UINT8 acknum,
size_t packetlength);
boolean HGetPacket(void);
void D_SetDoomcom(void);
#ifndef NONET
void D_SaveBan(void);
#endif
boolean D_CheckNetGame(void);
void D_CloseConnection(void);
void Net_UnAcknowledgPacket(INT32 node);
void Net_CloseConnection(INT32 node);
void Net_AbortPacketType(UINT8 packettype);
void Net_SendAcks(INT32 node);
void Net_WaitAllAckReceived(UINT32 timeout);
#endif
This diff is collapsed.
...@@ -20,9 +20,6 @@ ...@@ -20,9 +20,6 @@
// console vars // console vars
extern consvar_t cv_playername; extern consvar_t cv_playername;
extern consvar_t cv_playercolor; extern consvar_t cv_playercolor;
#ifdef SEENAMES
extern consvar_t cv_seenames, cv_allowseenames;
#endif
extern consvar_t cv_usemouse; extern consvar_t cv_usemouse;
extern consvar_t cv_usejoystick; extern consvar_t cv_usejoystick;
extern consvar_t cv_usejoystick2; extern consvar_t cv_usejoystick2;
...@@ -115,10 +112,6 @@ extern consvar_t cv_ringslinger, cv_soundtest; ...@@ -115,10 +112,6 @@ extern consvar_t cv_ringslinger, cv_soundtest;
extern consvar_t cv_specialrings, cv_powerstones, cv_matchboxes, cv_competitionboxes; extern consvar_t cv_specialrings, cv_powerstones, cv_matchboxes, cv_competitionboxes;
#ifdef NEWPING
extern consvar_t cv_maxping;
#endif
extern consvar_t cv_skipmapcheck; extern consvar_t cv_skipmapcheck;
extern consvar_t cv_sleep, cv_screenshot_option, cv_screenshot_folder; extern consvar_t cv_sleep, cv_screenshot_option, cv_screenshot_folder;
......
...@@ -44,12 +44,11 @@ ...@@ -44,12 +44,11 @@
#include "doomdef.h" #include "doomdef.h"
#include "doomstat.h" #include "doomstat.h"
#include "d_enet.h"
#include "d_main.h" #include "d_main.h"
#include "g_game.h" #include "g_game.h"
#include "i_net.h"
#include "i_system.h" #include "i_system.h"
#include "m_argv.h" #include "m_argv.h"
#include "d_net.h"
#include "w_wad.h" #include "w_wad.h"
#include "d_netfil.h" #include "d_netfil.h"
#include "z_zone.h" #include "z_zone.h"
...@@ -62,8 +61,6 @@ ...@@ -62,8 +61,6 @@
#include <errno.h> #include <errno.h>
static void SendFile(INT32 node, const char *filename, UINT8 fileid);
// sender structure // sender structure
typedef struct filetx_s typedef struct filetx_s
{ {
...@@ -103,45 +100,8 @@ INT32 lastfilenum = 0; ...@@ -103,45 +100,8 @@ INT32 lastfilenum = 0;
*/ */
UINT8 *PutFileNeeded(void) UINT8 *PutFileNeeded(void)
{ {
size_t i, count = 0; // NET TODO
UINT8 *p = netbuffer->u.serverinfo.fileneeded; return NULL;
char wadfilename[MAX_WADPATH] = "";
UINT8 filestatus;
size_t bytesused = 0;
for (i = 0; i < numwadfiles; i++)
{
// if it has only music/sound lumps, mark it as unimportant
if (W_VerifyNMUSlumps(wadfiles[i]->filename))
filestatus = 0;
else
filestatus = 1; // important
// Store in the upper four bits
if (!cv_downloading.value)
filestatus += (2 << 4); // won't send
else if ((wadfiles[i]->filesize > (UINT32)cv_maxsend.value * 1024))
filestatus += (0 << 4); // won't send
else
filestatus += (1 << 4); // will send if requested
bytesused += (nameonlylength(wadfilename) + 22);
// Don't write too far...
if (bytesused > sizeof(netbuffer->u.serverinfo.fileneeded))
I_Error("Too many wad files added to host a game. (%s, stopped on %s)\n", sizeu1(bytesused), wadfilename);
WRITEUINT8(p, filestatus);
count++;
WRITEUINT32(p, wadfiles[i]->filesize);
nameonly(strcpy(wadfilename, wadfiles[i]->filename));
WRITESTRINGN(p, wadfilename, MAX_WADPATH);
WRITEMEM(p, wadfiles[i]->md5sum, 16);
}
netbuffer->u.serverinfo.fileneedednum = (UINT8)count;
return p;
} }
// parse the serverinfo packet and fill fileneeded table on client // parse the serverinfo packet and fill fileneeded table on client
...@@ -244,62 +204,8 @@ boolean CL_CheckDownloadable(void) ...@@ -244,62 +204,8 @@ boolean CL_CheckDownloadable(void)
*/ */
boolean CL_SendRequestFile(void) boolean CL_SendRequestFile(void)
{ {
char *p; // NET TODO
INT32 i; return true;
INT64 totalfreespaceneeded = 0, availablefreespace;
#ifdef PARANOIA
if (M_CheckParm("-nodownload"))
I_Error("Attempted to download files in -nodownload mode");
for (i = 0; i < fileneedednum; i++)
if (fileneeded[i].status != FS_FOUND && fileneeded[i].status != FS_OPEN
&& fileneeded[i].important && (fileneeded[i].willsend == 0 || fileneeded[i].willsend == 2))
{
I_Error("Attempted to download files that were not sendable");
}
#endif
netbuffer->packettype = PT_REQUESTFILE;
p = (char *)netbuffer->u.textcmd;
for (i = 0; i < fileneedednum; i++)
if ((fileneeded[i].status == FS_NOTFOUND || fileneeded[i].status == FS_MD5SUMBAD)
&& fileneeded[i].important)
{
totalfreespaceneeded += fileneeded[i].totalsize;
nameonly(fileneeded[i].filename);
WRITEUINT8(p, i); // fileid
WRITESTRINGN(p, fileneeded[i].filename, MAX_WADPATH);
// put it in download dir
strcatbf(fileneeded[i].filename, downloaddir, "/");
fileneeded[i].status = FS_REQUESTED;
}
WRITEUINT8(p, 0xFF);
I_GetDiskFreeSpace(&availablefreespace);
if (totalfreespaceneeded > availablefreespace)
I_Error("To play on this server you must download %s KB,\n"
"but you have only %s KB free space on this drive\n",
sizeu1((size_t)(totalfreespaceneeded>>10)), sizeu2((size_t)(availablefreespace>>10)));
// prepare to download
I_mkdir(downloaddir, 0755);
return HSendPacket(servernode, true, 0, p - (char *)netbuffer->u.textcmd);
}
// get request filepak and put it on the send queue
void Got_RequestFilePak(INT32 node)
{
char wad[MAX_WADPATH+1];
UINT8 *p = netbuffer->u.textcmd;
UINT8 id;
while (p < netbuffer->u.textcmd + MAXTEXTCMD-1) // Don't allow hacked client to overflow
{
id = READUINT8(p);
if (id == 0xFF)
break;
READSTRINGN(p, wad, MAX_WADPATH);
SendFile(node, wad, id);
}
} }
// client check if the fileneeded aren't already loaded or on the disk // client check if the fileneeded aren't already loaded or on the disk
...@@ -431,74 +337,6 @@ void CL_LoadServerFiles(void) ...@@ -431,74 +337,6 @@ void CL_LoadServerFiles(void)
// little optimization to test if there is a file in the queue // little optimization to test if there is a file in the queue
static INT32 filetosend = 0; static INT32 filetosend = 0;
static void SendFile(INT32 node, const char *filename, UINT8 fileid)
{
filetx_t **q;
filetx_t *p;
INT32 i;
char wadfilename[MAX_WADPATH];
q = &transfer[node].txlist;
while (*q)
q = &((*q)->next);
p = *q = (filetx_t *)malloc(sizeof (filetx_t));
if (p)
memset(p, 0, sizeof (filetx_t));
else
I_Error("SendFile: No more ram\n");
p->filename = (char *)malloc(MAX_WADPATH);
if (!p->filename)
I_Error("SendFile: No more ram\n");
// a minimum of security, can get only file in srb2 direcory
strlcpy(p->filename, filename, MAX_WADPATH);
nameonly(p->filename);
// check first in wads loaded the majority of case
for (i = 0; wadfiles[i]; i++)
{
strlcpy(wadfilename, wadfiles[i]->filename, MAX_WADPATH);
nameonly(wadfilename);
if (!stricmp(wadfilename, p->filename))
{
// copy filename with full path
strlcpy(p->filename, wadfiles[i]->filename, MAX_WADPATH);
break;
}
}
if (!wadfiles[i])
{
DEBFILE(va("%s not found in wadfiles\n", filename));
// this formerly checked if (!findfile(p->filename, NULL, true))
// not found
// don't inform client (probably hacker)
DEBFILE(va("Client %d request %s: not found\n", node, filename));
free(p->filename);
free(p);
*q = NULL;
return;
}
if (wadfiles[i]->filesize > (UINT32)cv_maxsend.value * 1024)
{
// too big
// don't inform client (client sucks, man)
DEBFILE(va("Client %d request %s: file too big, not sending\n", node, filename));
free(p->filename);
free(p);
*q = NULL;
return;
}
DEBFILE(va("Sending file %s (id=%d) to %d\n", filename, fileid, node));
p->ram = SF_FILE;
p->fileid = fileid;
p->next = NULL; // end of list
filetosend++;
}
void SendRam(INT32 node, void *data, size_t size, freemethod_t freemethod, UINT8 fileid) void SendRam(INT32 node, void *data, size_t size, freemethod_t freemethod, UINT8 fileid)
{ {
filetx_t **q; filetx_t **q;
...@@ -547,162 +385,7 @@ static void EndSend(INT32 node) ...@@ -547,162 +385,7 @@ static void EndSend(INT32 node)
filetosend--; filetosend--;
} }
#define PACKETPERTIC net_bandwidth/(TICRATE*software_MAXPACKETLENGTH) static void AbortSendFiles(INT32 node)
void FiletxTicker(void)
{
static INT32 currentnode = 0;
filetx_pak *p;
size_t size;
filetx_t *f;
INT32 packetsent = PACKETPERTIC, ram, i;
if (!filetosend)
return;
if (!packetsent)
packetsent++;
// (((sendbytes-nowsentbyte)*TICRATE)/(I_GetTime()-starttime)<(UINT32)net_bandwidth)
while (packetsent-- && filetosend != 0)
{
for (i = currentnode, ram = 0; ram < MAXNETNODES;
i = (i+1) % MAXNETNODES, ram++)
{
if (transfer[i].txlist)
goto found;
}
// no transfer to do
I_Error("filetosend=%d but no filetosend found\n", filetosend);
found:
currentnode = (i+1) % MAXNETNODES;
f = transfer[i].txlist;
ram = f->ram;
if (!transfer[i].currentfile) // file not already open
{
if (!ram)
{
long filesize;
transfer[i].currentfile =
fopen(f->filename, "rb");
if (!transfer[i].currentfile)
I_Error("File %s does not exist",
f->filename);
fseek(transfer[i].currentfile, 0, SEEK_END);
filesize = ftell(transfer[i].currentfile);
// Nobody wants to transfer a file bigger
// than 4GB!
if (filesize >= LONG_MAX)
I_Error("filesize of %s is too large", f->filename);
if (-1 == filesize)
I_Error("Error getting filesize of %s", f->filename);
f->size = (UINT32)filesize;
fseek(transfer[i].currentfile, 0, SEEK_SET);
}
else
transfer[i].currentfile = (FILE *)1;
transfer[i].position = 0;
}
p = &netbuffer->u.filetxpak;
size = software_MAXPACKETLENGTH - (FILETXHEADER + BASEPACKETSIZE);
if (f->size-transfer[i].position < size)
size = f->size-transfer[i].position;
if (ram)
M_Memcpy(p->data, &f->filename[transfer[i].position], size);
else if (fread(p->data, 1, size, transfer[i].currentfile) != size)
I_Error("FiletxTicker: can't read %s byte on %s at %d because %s", sizeu1(size), f->filename, transfer[i].position, strerror(ferror(transfer[i].currentfile)));
p->position = LONG(transfer[i].position);
// put flag so receiver know the totalsize
if (transfer[i].position + size == f->size)
p->position |= LONG(0x80000000);
p->fileid = f->fileid;
p->size = SHORT((UINT16)size);
netbuffer->packettype = PT_FILEFRAGMENT;
if (!HSendPacket(i, true, 0, FILETXHEADER + size)) // reliable SEND
{ // not sent for some odd reason, retry at next call
if (!ram)
fseek(transfer[i].currentfile,transfer[i].position,SEEK_SET);
// exit the while (can't send this one so why should i send the next?)
break;
}
else // success
{
transfer[i].position = (UINT32)(size+transfer[i].position);
if (transfer[i].position == f->size) // finish ?
EndSend(i);
}
}
}
void Got_Filetxpak(void)
{
INT32 filenum = netbuffer->u.filetxpak.fileid;
static INT32 filetime = 0;
if (filenum >= fileneedednum)
{
DEBFILE(va("fileframent not needed %d>%d\n",filenum, fileneedednum));
return;
}
if (fileneeded[filenum].status == FS_REQUESTED)
{
if (fileneeded[filenum].phandle) I_Error("Got_Filetxpak: allready open file\n");
fileneeded[filenum].phandle = fopen(fileneeded[filenum].filename, "wb");
if (!fileneeded[filenum].phandle) I_Error("Can't create file %s: %s",fileneeded[filenum].filename, strerror(errno));
CONS_Printf("\r%s...\n",fileneeded[filenum].filename);
fileneeded[filenum].currentsize = 0;
fileneeded[filenum].status = FS_DOWNLOADING;
}
if (fileneeded[filenum].status == FS_DOWNLOADING)
{
UINT32 pos = LONG(netbuffer->u.filetxpak.position);
UINT16 size = SHORT(netbuffer->u.filetxpak.size);
// use a special tric to know when file is finished (not allways used)
// WARNING: filepak can arrive out of order so don't stop now !
if (pos & 0x80000000)
{
pos &= ~0x80000000;
fileneeded[filenum].totalsize = pos + size;
}
// we can receive packet in the wrong order, anyway all os support gaped file
fseek(fileneeded[filenum].phandle,pos,SEEK_SET);
if (fwrite(netbuffer->u.filetxpak.data,size,1,fileneeded[filenum].phandle)!=1)
I_Error("Can't write to %s: %s\n",fileneeded[filenum].filename, strerror(ferror(fileneeded[filenum].phandle)));
fileneeded[filenum].currentsize += size;
// finished?
if (fileneeded[filenum].currentsize == fileneeded[filenum].totalsize)
{
fclose(fileneeded[filenum].phandle);
fileneeded[filenum].phandle = NULL;
fileneeded[filenum].status = FS_FOUND;
CONS_Printf(M_GetText("Downloading %s...(done)\n"),
fileneeded[filenum].filename);
}
}
else
I_Error("Received a file not requested\n");
// send ack back quickly
if (++filetime == 3)
{
Net_SendAcks(servernode);
filetime = 0;
}
#ifdef CLIENT_LOADINGSCREEN
lastfilenum = filenum;
#endif
}
void AbortSendFiles(INT32 node)
{ {
while (transfer[node].txlist) while (transfer[node].txlist)
EndSend(node); EndSend(node);
...@@ -725,7 +408,7 @@ void CloseNetFile(void) ...@@ -725,7 +408,7 @@ void CloseNetFile(void)
} }
// remove FILEFRAGMENT from acknledge list // remove FILEFRAGMENT from acknledge list
Net_AbortPacketType(PT_FILEFRAGMENT); //Net_AbortPacketType(PT_FILEFRAGMENT);
} }
// functions cut and pasted from doomatic :) // functions cut and pasted from doomatic :)
......
This diff is collapsed.
This diff is collapsed.