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
John Peter Sa
SRB2
Commits
a7a3f97c
Commit
a7a3f97c
authored
2 years ago
by
LJ Sonic
Browse files
Options
Downloads
Patches
Plain Diff
Split PT_ClientCmd into functions
parent
0859a159
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/netcode/tic_command.c
+51
-44
51 additions, 44 deletions
src/netcode/tic_command.c
with
51 additions
and
44 deletions
src/netcode/tic_command.c
+
51
−
44
View file @
a7a3f97c
...
...
@@ -103,6 +103,55 @@ void D_ResetTiccmds(void)
D_Clearticcmd
(
textcmds
[
i
]
->
tic
);
}
// Check ticcmd for "speed hacks"
static
void
CheckTiccmdHacks
(
INT32
playernum
)
{
ticcmd_t
*
cmd
=
&
netcmds
[
maketic
%
BACKUPTICS
][
playernum
];
if
(
cmd
->
forwardmove
>
MAXPLMOVE
||
cmd
->
forwardmove
<
-
MAXPLMOVE
||
cmd
->
sidemove
>
MAXPLMOVE
||
cmd
->
sidemove
<
-
MAXPLMOVE
)
{
CONS_Alert
(
CONS_WARNING
,
M_GetText
(
"Illegal movement value received from node %d
\n
"
),
playernum
);
SendKick
(
playernum
,
KICK_MSG_CON_FAIL
);
}
}
// Check player consistancy during the level
static
void
CheckConsistancy
(
SINT8
nodenum
,
tic_t
tic
)
{
netnode_t
*
node
=
&
netnodes
[
nodenum
];
INT16
neededconsistancy
=
consistancy
[
tic
%
BACKUPTICS
];
INT16
clientconsistancy
=
SHORT
(
netbuffer
->
u
.
clientpak
.
consistancy
);
if
(
tic
>
gametic
||
tic
+
BACKUPTICS
-
1
<=
gametic
||
gamestate
!=
GS_LEVEL
||
neededconsistancy
==
clientconsistancy
||
SV_ResendingSavegameToAnyone
()
||
node
->
resendingsavegame
||
node
->
savegameresendcooldown
>
I_GetTime
())
return
;
if
(
cv_resynchattempts
.
value
)
{
// Tell the client we are about to resend them the gamestate
netbuffer
->
packettype
=
PT_WILLRESENDGAMESTATE
;
HSendPacket
(
nodenum
,
true
,
0
,
0
);
node
->
resendingsavegame
=
true
;
if
(
cv_blamecfail
.
value
)
CONS_Printf
(
M_GetText
(
"Synch failure for player %d (%s); expected %hd, got %hd
\n
"
),
node
->
player
+
1
,
player_names
[
node
->
player
],
neededconsistancy
,
clientconsistancy
);
DEBFILE
(
va
(
"Restoring player %d (synch failure) [%update] %d!=%d
\n
"
,
node
->
player
,
tic
,
neededconsistancy
,
clientconsistancy
));
}
else
{
SendKick
(
node
->
player
,
KICK_MSG_CON_FAIL
|
KICK_MSG_KEEP_BODY
);
DEBFILE
(
va
(
"player %d kicked (synch failure) [%u] %d!=%d
\n
"
,
node
->
player
,
tic
,
neededconsistancy
,
clientconsistancy
));
}
}
void
PT_ClientCmd
(
SINT8
node
,
INT32
netconsole
)
{
tic_t
realend
,
realstart
;
...
...
@@ -143,56 +192,14 @@ void PT_ClientCmd(SINT8 node, INT32 netconsole)
// Copy ticcmd
G_MoveTiccmd
(
&
netcmds
[
maketic
%
BACKUPTICS
][
netconsole
],
&
netbuffer
->
u
.
clientpak
.
cmd
,
1
);
// Check ticcmd for "speed hacks"
if
(
netcmds
[
maketic
%
BACKUPTICS
][
netconsole
].
forwardmove
>
MAXPLMOVE
||
netcmds
[
maketic
%
BACKUPTICS
][
netconsole
].
forwardmove
<
-
MAXPLMOVE
||
netcmds
[
maketic
%
BACKUPTICS
][
netconsole
].
sidemove
>
MAXPLMOVE
||
netcmds
[
maketic
%
BACKUPTICS
][
netconsole
].
sidemove
<
-
MAXPLMOVE
)
{
CONS_Alert
(
CONS_WARNING
,
M_GetText
(
"Illegal movement value received from node %d
\n
"
),
netconsole
);
//D_Clearticcmd(k);
SendKick
(
netconsole
,
KICK_MSG_CON_FAIL
);
return
;
}
// Splitscreen cmd
if
((
netbuffer
->
packettype
==
PT_CLIENT2CMD
||
netbuffer
->
packettype
==
PT_CLIENT2MIS
)
&&
netnodes
[
node
].
player2
>=
0
)
G_MoveTiccmd
(
&
netcmds
[
maketic
%
BACKUPTICS
][(
UINT8
)
netnodes
[
node
].
player2
],
&
netbuffer
->
u
.
client2pak
.
cmd2
,
1
);
// Check player consistancy during the level
if
(
realstart
<=
gametic
&&
realstart
+
BACKUPTICS
-
1
>
gametic
&&
gamestate
==
GS_LEVEL
&&
consistancy
[
realstart
%
BACKUPTICS
]
!=
SHORT
(
netbuffer
->
u
.
clientpak
.
consistancy
)
&&
!
SV_ResendingSavegameToAnyone
()
&&
!
netnodes
[
node
].
resendingsavegame
&&
netnodes
[
node
].
savegameresendcooldown
<=
I_GetTime
())
{
if
(
cv_resynchattempts
.
value
)
{
// Tell the client we are about to resend them the gamestate
netbuffer
->
packettype
=
PT_WILLRESENDGAMESTATE
;
HSendPacket
(
node
,
true
,
0
,
0
);
netnodes
[
node
].
resendingsavegame
=
true
;
if
(
cv_blamecfail
.
value
)
CONS_Printf
(
M_GetText
(
"Synch failure for player %d (%s); expected %hd, got %hd
\n
"
),
netconsole
+
1
,
player_names
[
netconsole
],
consistancy
[
realstart
%
BACKUPTICS
],
SHORT
(
netbuffer
->
u
.
clientpak
.
consistancy
));
DEBFILE
(
va
(
"Restoring player %d (synch failure) [%update] %d!=%d
\n
"
,
netconsole
,
realstart
,
consistancy
[
realstart
%
BACKUPTICS
],
SHORT
(
netbuffer
->
u
.
clientpak
.
consistancy
)));
return
;
}
else
{
SendKick
(
netconsole
,
KICK_MSG_CON_FAIL
|
KICK_MSG_KEEP_BODY
);
DEBFILE
(
va
(
"player %d kicked (synch failure) [%u] %d!=%d
\n
"
,
netconsole
,
realstart
,
consistancy
[
realstart
%
BACKUPTICS
],
SHORT
(
netbuffer
->
u
.
clientpak
.
consistancy
)));
return
;
}
}
CheckTiccmdHacks
(
netconsole
);
CheckConsistancy
(
node
,
realstart
);
}
void
PT_ServerTics
(
SINT8
node
,
INT32
netconsole
)
...
...
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