Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
SRB2
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
244
Issues
244
List
Board
Labels
Milestones
Merge Requests
67
Merge Requests
67
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
STJr
SRB2
Commits
6acd99c0
Commit
6acd99c0
authored
Jun 05, 2020
by
LJ Sonic
1
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix "Variables X and Y have same netid" happening way too often
parent
71d4eb01
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
4 additions
and
23 deletions
+4
-23
command.c
src/command.c
+4
-23
No files found.
src/command.c
View file @
6acd99c0
...
...
@@ -1121,32 +1121,10 @@ consvar_t *CV_FindVar(const char *name)
return
NULL
;
}
/** Builds a unique Net Variable identifier number, which is used
* in network packets instead of the full name.
*
* \param s Name of the variable.
* \return A new unique identifier.
* \sa CV_FindNetVar
*/
static
inline
UINT16
CV_ComputeNetid
(
const
char
*
s
)
{
UINT16
ret
=
0
,
i
=
0
;
static
UINT16
premiers
[
16
]
=
{
2
,
3
,
5
,
7
,
11
,
13
,
17
,
19
,
23
,
29
,
31
,
37
,
41
,
43
,
47
,
53
};
while
(
*
s
)
{
ret
=
(
UINT16
)(
ret
+
(
*
s
)
*
premiers
[
i
]);
s
++
;
i
=
(
UINT16
)((
i
+
1
)
%
16
);
}
return
ret
;
}
/** Finds a net variable based on its identifier number.
*
* \param netid The variable's identifier number.
* \return A pointer to the variable itself if found, or NULL.
* \sa CV_ComputeNetid
*/
static
consvar_t
*
CV_FindNetVar
(
UINT16
netid
)
{
...
...
@@ -1167,6 +1145,8 @@ static void Setvalue(consvar_t *var, const char *valstr, boolean stealth);
*/
void
CV_RegisterVar
(
consvar_t
*
variable
)
{
static
UINT16
id
=
1
;
// first check to see if it has already been defined
if
(
CV_FindVar
(
variable
->
name
))
{
...
...
@@ -1185,7 +1165,8 @@ void CV_RegisterVar(consvar_t *variable)
if
(
variable
->
flags
&
CV_NETVAR
)
{
const
consvar_t
*
netvar
;
variable
->
netid
=
CV_ComputeNetid
(
variable
->
name
);
variable
->
netid
=
id
;
id
++
;
netvar
=
CV_FindNetVar
(
variable
->
netid
);
if
(
netvar
)
I_Error
(
"Variables %s and %s have same netid
\n
"
,
variable
->
name
,
netvar
->
name
);
...
...
James R.
@james
mentioned in commit
32773b71
Jun 20, 2020
mentioned in commit
32773b71
mentioned in commit 32773b71e0fafd620d08c9847b79d25941af449d
Toggle commit list
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment