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
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Skydusk
SRB2
Commits
369c327e
Commit
369c327e
authored
6 months ago
by
Hanicef
Browse files
Options
Downloads
Patches
Plain Diff
Clean up d_net.c and push back missed acks to acktosend
parent
7b6bf976
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/netcode/d_net.c
+13
-47
13 additions, 47 deletions
src/netcode/d_net.c
src/netcode/d_net.h
+0
-1
0 additions, 1 deletion
src/netcode/d_net.h
with
13 additions
and
48 deletions
src/netcode/d_net.c
+
13
−
47
View file @
369c327e
...
...
@@ -200,10 +200,9 @@ FUNCMATH static INT32 cmpack(UINT8 a, UINT8 b)
/** Sets freeack to a free acknum and copies the netbuffer in the ackpak table
*
* \param freeack The address to store the free acknum at
* \param lowtimer ???
* \return True if a free acknum was found
*/
static
boolean
GetFreeAcknum
(
UINT8
*
freeack
,
boolean
lowtimer
)
static
boolean
GetFreeAcknum
(
UINT8
*
freeack
)
{
node_t
*
node
=
&
nodes
[
doomcom
->
remotenode
];
INT32
numfreeslot
=
0
;
...
...
@@ -232,17 +231,8 @@ static boolean GetFreeAcknum(UINT8 *freeack, boolean lowtimer)
node
->
nextacknum
++
;
ackpak
[
i
].
destinationnode
=
(
UINT8
)(
node
-
nodes
);
ackpak
[
i
].
length
=
doomcom
->
datalength
;
if
(
lowtimer
)
{
// Lowtime means can't be sent now so try it as soon as possible
ackpak
[
i
].
senttime
=
0
;
ackpak
[
i
].
resentnum
=
1
;
}
else
{
ackpak
[
i
].
senttime
=
I_GetTime
();
ackpak
[
i
].
resentnum
=
0
;
}
M_Memcpy
(
ackpak
[
i
].
pak
.
raw
,
netbuffer
,
ackpak
[
i
].
length
);
*
freeack
=
ackpak
[
i
].
acknum
;
...
...
@@ -259,38 +249,6 @@ static boolean GetFreeAcknum(UINT8 *freeack, boolean lowtimer)
return
false
;
}
/** Counts how many acks are free
*
* \param urgent True if the type of the packet meant to
* use an ack is lower than PT_CANFAIL
* If for some reason you don't want use it
* for any packet type in particular,
* just set to false
* \return The number of free acks
*
*/
INT32
Net_GetFreeAcks
(
boolean
urgent
)
{
INT32
numfreeslot
=
0
;
INT32
n
=
0
;
// Number of free acks found
for
(
INT32
i
=
0
;
i
<
MAXACKPACKETS
;
i
++
)
if
(
!
ackpak
[
i
].
acknum
)
{
// For low priority packets, make sure to let freeslots so urgent packets can be sent
if
(
!
urgent
)
{
numfreeslot
++
;
if
(
numfreeslot
<=
URGENTFREESLOTNUM
)
continue
;
}
n
++
;
}
return
n
;
}
// Get a ack to send in the queue of this node
static
UINT8
GetAcktosend
(
INT32
node
)
{
...
...
@@ -319,7 +277,7 @@ static int Processackpak(void)
node
->
remotefirstack
=
netbuffer
->
ackreturn
;
// Search the ackbuffer and free it
for
(
INT32
i
=
0
;
i
<
MAXACKPACKETS
;
i
++
)
if
(
ackpak
[
i
].
acknum
&&
ackpak
[
i
].
destinationnode
==
node
-
node
s
if
(
ackpak
[
i
].
acknum
&&
ackpak
[
i
].
destinationnode
==
doomcom
->
remote
node
&&
cmpack
(
ackpak
[
i
].
acknum
,
netbuffer
->
ackreturn
)
<=
0
)
{
RemoveAck
(
i
);
...
...
@@ -333,7 +291,15 @@ static int Processackpak(void)
getackpacket
++
;
if
(
cmpack
(
ack
,
node
->
firstacktosend
)
<=
0
)
{
UINT8
newhead
=
(
UINT8
)((
node
->
acktosend_head
+
1
)
%
MAXACKTOSEND
);
DEBFILE
(
va
(
"Discard(1) ack %d (duplicated)
\n
"
,
ack
));
if
(
newhead
!=
node
->
acktosend_tail
)
{
// push the ack back onto the acktosend list to make sure it's responded to
node
->
acktosend
[
node
->
acktosend_head
]
=
ack
;
node
->
acktosend_head
=
newhead
;
}
duppacket
++
;
goodpacket
=
1
;
// Discard packet (duplicate)
}
...
...
@@ -991,7 +957,7 @@ boolean HSendPacket(INT32 node, boolean reliable, UINT8 acknum, size_t packetlen
netbuffer
->
ackreturn
=
0
;
if
(
reliable
)
{
if
(
!
GetFreeAcknum
(
&
netbuffer
->
ack
,
false
))
if
(
!
GetFreeAcknum
(
&
netbuffer
->
ack
))
return
false
;
}
else
...
...
This diff is collapsed.
Click to expand it.
src/netcode/d_net.h
+
0
−
1
View file @
369c327e
...
...
@@ -60,7 +60,6 @@ extern netnode_t netnodes[MAXNETNODES];
extern
boolean
serverrunning
;
INT32
Net_GetFreeAcks
(
boolean
urgent
);
void
Net_AckTicker
(
void
);
// If reliable return true if packet sent, 0 else
...
...
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