Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
SRB2
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Terraform modules
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Skydusk
SRB2
Commits
d38c15c7
Commit
d38c15c7
authored
2 months ago
by
LJ Sonic
Browse files
Options
Downloads
Plain Diff
Merge branch 'revert-
74df6cf5
' into 'next'
Revert "Merge branch 'lift-netxcmd-limits' into 'next'" See merge request
!2661
parents
2a6af5db
3c738631
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/netcode/net_command.c
+16
-106
16 additions, 106 deletions
src/netcode/net_command.c
with
16 additions
and
106 deletions
src/netcode/net_command.c
+
16
−
106
View file @
d38c15c7
...
@@ -21,16 +21,6 @@
...
@@ -21,16 +21,6 @@
#include
"../z_zone.h"
#include
"../z_zone.h"
#include
"../doomtype.h"
#include
"../doomtype.h"
typedef
struct
textcmdbuf_s
textcmdbuf_t
;
struct
textcmdbuf_s
{
textcmdbuf_t
*
next
;
UINT8
cmd
[
MAXTEXTCMD
];
};
static
textcmdbuf_t
*
textcmdbuf
;
static
textcmdbuf_t
*
textcmdbuf2
;
textcmdtic_t
*
textcmds
[
TEXTCMD_HASH_SIZE
]
=
{
NULL
};
textcmdtic_t
*
textcmds
[
TEXTCMD_HASH_SIZE
]
=
{
NULL
};
UINT8
localtextcmd
[
MAXTEXTCMD
];
UINT8
localtextcmd
[
MAXTEXTCMD
];
UINT8
localtextcmd2
[
MAXTEXTCMD
];
// splitscreen
UINT8
localtextcmd2
[
MAXTEXTCMD
];
// splitscreen
...
@@ -47,57 +37,21 @@ void RegisterNetXCmd(netxcmd_t id, void (*cmd_f)(UINT8 **p, INT32 playernum))
...
@@ -47,57 +37,21 @@ void RegisterNetXCmd(netxcmd_t id, void (*cmd_f)(UINT8 **p, INT32 playernum))
listnetxcmd
[
id
]
=
cmd_f
;
listnetxcmd
[
id
]
=
cmd_f
;
}
}
static
void
WriteNetXCmd
(
UINT8
*
cmd
,
netxcmd_t
id
,
const
void
*
param
,
size_t
nparam
)
{
cmd
[
0
]
++
;
cmd
[
cmd
[
0
]]
=
(
UINT8
)
id
;
if
(
param
&&
nparam
)
{
M_Memcpy
(
&
cmd
[
cmd
[
0
]
+
1
],
param
,
nparam
);
cmd
[
0
]
=
(
UINT8
)(
cmd
[
0
]
+
(
UINT8
)
nparam
);
}
}
void
SendNetXCmd
(
netxcmd_t
id
,
const
void
*
param
,
size_t
nparam
)
void
SendNetXCmd
(
netxcmd_t
id
,
const
void
*
param
,
size_t
nparam
)
{
{
if
(
localtextcmd
[
0
]
+
2
+
nparam
>
MAXTEXTCMD
)
if
(
localtextcmd
[
0
]
+
2
+
nparam
>
MAXTEXTCMD
)
{
{
textcmdbuf_t
*
buf
=
textcmdbuf
;
if
(
2
+
nparam
>
MAXTEXTCMD
)
{
CONS_Alert
(
CONS_ERROR
,
M_GetText
(
"packet too large to fit NetXCmd, cannot add netcmd %d! (size: %s, max: %d)
\n
"
),
id
,
sizeu1
(
2
+
nparam
),
MAXTEXTCMD
);
return
;
}
// for future reference: if (cv_debug) != debug disabled.
// for future reference: if (cv_debug) != debug disabled.
CONS_Alert
(
CONS_NOTICE
,
M_GetText
(
"NetXCmd buffer full, delaying netcmd %d... (size: %d, needed: %s)
\n
"
),
id
,
localtextcmd
[
0
],
sizeu1
(
nparam
));
CONS_Alert
(
CONS_ERROR
,
M_GetText
(
"NetXCmd buffer full, cannot add netcmd %d! (size: %d, needed: %s)
\n
"
),
id
,
localtextcmd
[
0
],
sizeu1
(
nparam
));
if
(
buf
==
NULL
)
{
textcmdbuf
=
Z_Malloc
(
sizeof
(
textcmdbuf_t
),
PU_STATIC
,
NULL
);
textcmdbuf
->
cmd
[
0
]
=
0
;
textcmdbuf
->
next
=
NULL
;
WriteNetXCmd
(
textcmdbuf
->
cmd
,
id
,
param
,
nparam
);
return
;
return
;
}
}
localtextcmd
[
0
]
++
;
while
(
buf
->
next
!=
NULL
)
localtextcmd
[
localtextcmd
[
0
]]
=
(
UINT8
)
id
;
buf
=
buf
->
next
;
if
(
param
&&
nparam
)
if
(
buf
->
cmd
[
0
]
+
2
+
nparam
>
MAXTEXTCMD
)
{
buf
->
next
=
Z_Malloc
(
sizeof
(
textcmdbuf_t
),
PU_STATIC
,
NULL
);
buf
->
next
->
cmd
[
0
]
=
0
;
buf
->
next
->
next
=
NULL
;
WriteNetXCmd
(
buf
->
next
->
cmd
,
id
,
param
,
nparam
);
}
else
{
{
WriteNetXCmd
(
buf
->
cmd
,
id
,
param
,
nparam
);
M_Memcpy
(
&
localtextcmd
[
localtextcmd
[
0
]
+
1
],
param
,
nparam
);
}
localtextcmd
[
0
]
=
(
UINT8
)(
localtextcmd
[
0
]
+
(
UINT8
)
nparam
);
return
;
}
}
WriteNetXCmd
(
localtextcmd
,
id
,
param
,
nparam
);
}
}
// splitscreen player
// splitscreen player
...
@@ -105,42 +59,16 @@ void SendNetXCmd2(netxcmd_t id, const void *param, size_t nparam)
...
@@ -105,42 +59,16 @@ void SendNetXCmd2(netxcmd_t id, const void *param, size_t nparam)
{
{
if
(
localtextcmd2
[
0
]
+
2
+
nparam
>
MAXTEXTCMD
)
if
(
localtextcmd2
[
0
]
+
2
+
nparam
>
MAXTEXTCMD
)
{
{
textcmdbuf_t
*
buf
=
textcmdbuf2
;
I_Error
(
"No more place in the buffer for netcmd %d
\n
"
,
id
);
if
(
2
+
nparam
>
MAXTEXTCMD
)
{
CONS_Alert
(
CONS_ERROR
,
M_GetText
(
"packet too large to fit NetXCmd, cannot add netcmd %d! (size: %s, max: %d)
\n
"
),
id
,
sizeu1
(
2
+
nparam
),
MAXTEXTCMD
);
return
;
}
// for future reference: if (cv_debug) != debug disabled.
CONS_Alert
(
CONS_NOTICE
,
M_GetText
(
"NetXCmd buffer full, delaying netcmd %d... (size: %d, needed: %s)
\n
"
),
id
,
localtextcmd2
[
0
],
sizeu1
(
nparam
));
if
(
buf
==
NULL
)
{
textcmdbuf2
=
Z_Malloc
(
sizeof
(
textcmdbuf_t
),
PU_STATIC
,
NULL
);
textcmdbuf2
->
cmd
[
0
]
=
0
;
textcmdbuf2
->
next
=
NULL
;
WriteNetXCmd
(
textcmdbuf2
->
cmd
,
id
,
param
,
nparam
);
return
;
return
;
}
}
localtextcmd2
[
0
]
++
;
while
(
buf
->
next
!=
NULL
)
localtextcmd2
[
localtextcmd2
[
0
]]
=
(
UINT8
)
id
;
buf
=
buf
->
next
;
if
(
param
&&
nparam
)
if
(
buf
->
cmd
[
0
]
+
2
+
nparam
>
MAXTEXTCMD
)
{
buf
->
next
=
Z_Malloc
(
sizeof
(
textcmdbuf_t
),
PU_STATIC
,
NULL
);
buf
->
next
->
cmd
[
0
]
=
0
;
buf
->
next
->
next
=
NULL
;
WriteNetXCmd
(
buf
->
next
->
cmd
,
id
,
param
,
nparam
);
}
else
{
{
WriteNetXCmd
(
buf
->
cmd
,
id
,
param
,
nparam
);
M_Memcpy
(
&
localtextcmd2
[
localtextcmd2
[
0
]
+
1
],
param
,
nparam
);
}
localtextcmd2
[
0
]
=
(
UINT8
)(
localtextcmd2
[
0
]
+
(
UINT8
)
nparam
);
return
;
}
}
WriteNetXCmd
(
localtextcmd2
,
id
,
param
,
nparam
);
}
}
UINT8
GetFreeXCmdSize
(
void
)
UINT8
GetFreeXCmdSize
(
void
)
...
@@ -417,16 +345,7 @@ void CL_SendNetCommands(void)
...
@@ -417,16 +345,7 @@ void CL_SendNetCommands(void)
M_Memcpy
(
netbuffer
->
u
.
textcmd
,
localtextcmd
,
localtextcmd
[
0
]
+
1
);
M_Memcpy
(
netbuffer
->
u
.
textcmd
,
localtextcmd
,
localtextcmd
[
0
]
+
1
);
// All extra data have been sent
// All extra data have been sent
if
(
HSendPacket
(
servernode
,
true
,
0
,
localtextcmd
[
0
]
+
1
))
// Send can fail...
if
(
HSendPacket
(
servernode
,
true
,
0
,
localtextcmd
[
0
]
+
1
))
// Send can fail...
{
localtextcmd
[
0
]
=
0
;
localtextcmd
[
0
]
=
0
;
if
(
textcmdbuf
!=
NULL
)
{
textcmdbuf_t
*
buf
=
textcmdbuf
;
M_Memcpy
(
localtextcmd
,
textcmdbuf
->
cmd
,
textcmdbuf
->
cmd
[
0
]
+
1
);
textcmdbuf
=
textcmdbuf
->
next
;
Z_Free
(
buf
);
}
}
}
}
// Send extra data if needed for player 2 (splitscreen)
// Send extra data if needed for player 2 (splitscreen)
...
@@ -436,16 +355,7 @@ void CL_SendNetCommands(void)
...
@@ -436,16 +355,7 @@ void CL_SendNetCommands(void)
M_Memcpy
(
netbuffer
->
u
.
textcmd
,
localtextcmd2
,
localtextcmd2
[
0
]
+
1
);
M_Memcpy
(
netbuffer
->
u
.
textcmd
,
localtextcmd2
,
localtextcmd2
[
0
]
+
1
);
// All extra data have been sent
// All extra data have been sent
if
(
HSendPacket
(
servernode
,
true
,
0
,
localtextcmd2
[
0
]
+
1
))
// Send can fail...
if
(
HSendPacket
(
servernode
,
true
,
0
,
localtextcmd2
[
0
]
+
1
))
// Send can fail...
{
localtextcmd2
[
0
]
=
0
;
localtextcmd2
[
0
]
=
0
;
if
(
textcmdbuf2
!=
NULL
)
{
textcmdbuf_t
*
buf
=
textcmdbuf2
;
M_Memcpy
(
localtextcmd2
,
textcmdbuf2
->
cmd
,
textcmdbuf2
->
cmd
[
0
]
+
1
);
textcmdbuf2
=
textcmdbuf2
->
next
;
Z_Free
(
buf
);
}
}
}
}
}
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment