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
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
SteelT
SRB2
Commits
ec5db89e
Commit
ec5db89e
authored
5 years ago
by
LJ Sonic
Browse files
Options
Downloads
Patches
Plain Diff
Cleanup chat code a little
parent
9504ba96
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/hu_stuff.c
+17
-37
17 additions, 37 deletions
src/hu_stuff.c
with
17 additions
and
37 deletions
src/hu_stuff.c
+
17
−
37
View file @
ec5db89e
...
...
@@ -501,37 +501,31 @@ static void DoSayCommand(SINT8 target, size_t usedargs, UINT8 flags)
// what we're gonna do now is check if the player exists
// with that logic, characters 4 and 5 are our numbers:
const
char
*
newmsg
;
char
*
playernum
=
(
char
*
)
malloc
(
3
)
;
char
playernum
[
3
]
;
INT32
spc
=
1
;
// used if playernum[1] is a space.
strncpy
(
playernum
,
msg
+
3
,
3
);
// check for undesirable characters in our "number"
if
(((
playernum
[
0
]
<
'0'
)
||
(
playernum
[
0
]
>
'9'
))
||
((
playernum
[
1
]
<
'0'
)
||
(
playernum
[
1
]
>
'9'
)))
if
(((
playernum
[
0
]
<
'0'
)
||
(
playernum
[
0
]
>
'9'
))
||
((
playernum
[
1
]
<
'0'
)
||
(
playernum
[
1
]
>
'9'
)))
{
// check if playernum[1] is a space
if
(
playernum
[
1
]
==
' '
)
spc
=
0
;
// let it slide
// let it slide
else
{
HU_AddChatText
(
"
\x82
NOTICE:
\x80
Invalid command format. Correct format is
\'
/pm<playernum>
\'
."
,
false
);
free
(
playernum
);
return
;
}
}
// I'm very bad at C, I swear I am, additional checks eww!
if
(
spc
!=
0
)
{
if
(
msg
[
5
]
!=
' '
)
{
HU_AddChatText
(
"
\x82
NOTICE:
\x80
Invalid command format. Correct format is
\'
/pm<playernum>
\'
."
,
false
);
free
(
playernum
);
return
;
}
}
if
(
spc
!=
0
&&
msg
[
5
]
!=
' '
)
{
HU_AddChatText
(
"
\x82
NOTICE:
\x80
Invalid command format. Correct format is
\'
/pm<playernum>
\'
."
,
false
);
return
;
}
target
=
atoi
((
const
char
*
)
playernum
);
// turn that into a number
free
(
playernum
);
target
=
atoi
(
playernum
);
// turn that into a number
//CONS_Printf("%d\n", target);
// check for target player, if it doesn't exist then we can't send the message!
...
...
@@ -1021,9 +1015,6 @@ void HU_Ticker(void)
#ifndef NONET
static
boolean
teamtalk
=
false
;
/*static char chatchars[QUEUESIZE];
static INT32 head = 0, tail = 0;*/
// WHY DO YOU OVERCOMPLICATE EVERYTHING?????????
// Clear spaces so we don't end up with messages only made out of emptiness
static
boolean
HU_clearChatSpaces
(
void
)
...
...
@@ -1083,7 +1074,7 @@ static void HU_queueChatChar(char c)
if
(
strlen
(
msg
)
>
4
&&
strnicmp
(
msg
,
"/pm"
,
3
)
==
0
)
// used /pm
{
INT32
spc
=
1
;
// used if nodenum[1] is a space.
char
*
nodenum
=
(
char
*
)
malloc
(
3
)
;
char
nodenum
[
3
]
;
const
char
*
newmsg
;
// what we're gonna do now is check if the node exists
...
...
@@ -1098,7 +1089,7 @@ static void HU_queueChatChar(char c)
strncpy
(
nodenum
,
msg
+
3
,
3
);
// check for undesirable characters in our "number"
if
(((
nodenum
[
0
]
<
'0'
)
||
(
nodenum
[
0
]
>
'9'
))
||
((
nodenum
[
1
]
<
'0'
)
||
(
nodenum
[
1
]
>
'9'
)))
if
(((
nodenum
[
0
]
<
'0'
)
||
(
nodenum
[
0
]
>
'9'
))
||
((
nodenum
[
1
]
<
'0'
)
||
(
nodenum
[
1
]
>
'9'
)))
{
// check if nodenum[1] is a space
if
(
nodenum
[
1
]
==
' '
)
...
...
@@ -1107,7 +1098,6 @@ static void HU_queueChatChar(char c)
else
{
HU_AddChatText
(
"
\x82
NOTICE:
\x80
Invalid command format. Correct format is
\'
/pm<node>
\'
."
,
false
);
free
(
nodenum
);
return
;
}
}
...
...
@@ -1117,13 +1107,11 @@ static void HU_queueChatChar(char c)
if
(
msg
[
5
]
!=
' '
)
{
HU_AddChatText
(
"
\x82
NOTICE:
\x80
Invalid command format. Correct format is
\'
/pm<node>
\'
."
,
false
);
free
(
nodenum
);
return
;
}
}
target
=
atoi
((
const
char
*
)
nodenum
);
// turn that into a number
free
(
nodenum
);
target
=
atoi
(
nodenum
);
// turn that into a number
//CONS_Printf("%d\n", target);
// check for target player, if it doesn't exist then we can't send the message!
...
...
@@ -1648,12 +1636,9 @@ static void HU_drawChatLog(INT32 offset)
}
chat_scrollmedown
=
false
;
// getmaxscroll through a lazy hack. We do all these loops, so let's not do more loops that are gonna lag the game more. :P
chat_maxscroll
=
(
dy
/
charheight
);
// welcome to C, we don't know what min() and max() are.
if
(
chat_maxscroll
<=
(
UINT32
)
cv_chatheight
.
value
)
chat_maxscroll
=
0
;
else
chat_maxscroll
-=
cv_chatheight
.
value
;
// getmaxscroll through a lazy hack. We do all these loops,
// so let's not do more loops that are gonna lag the game more. :P
chat_maxscroll
=
max
(
dy
/
charheight
-
cv_chatheight
.
value
,
0
);
// if we're not bound by the time, autoscroll for next frame:
if
(
atbottom
)
...
...
@@ -1794,21 +1779,17 @@ static void HU_DrawChat(void)
i
=
0
;
for
(
i
=
0
;
(
i
<
MAXPLAYERS
);
i
++
)
{
// filter: (code needs optimization pls help I'm bad with C)
if
(
w_chat
[
3
])
{
char
*
nodenum
;
char
nodenum
[
3
]
;
UINT32
n
;
// right, that's half important: (w_chat[4] may be a space since /pm0 msg is perfectly acceptable!)
if
(
(
((
w_chat
[
3
]
!=
0
)
&&
((
w_chat
[
3
]
<
'0'
)
||
(
w_chat
[
3
]
>
'9'
)))
||
((
w_chat
[
4
]
!=
0
)
&&
(((
w_chat
[
4
]
<
'0'
)
||
(
w_chat
[
4
]
>
'9'
)))))
&&
(
w_chat
[
4
]
!=
' '
))
break
;
nodenum
=
(
char
*
)
malloc
(
3
);
strncpy
(
nodenum
,
w_chat
+
3
,
3
);
n
=
atoi
((
const
char
*
)
nodenum
);
// turn that into a number
free
(
nodenum
);
n
=
atoi
(
nodenum
);
// turn that into a number
// special cases:
if
((
n
==
0
)
&&
!
(
w_chat
[
4
]
==
'0'
))
...
...
@@ -1855,7 +1836,6 @@ static void HU_DrawChat(void)
}
HU_drawChatLog
(
typelines
-
1
);
// typelines is the # of lines we're typing. If there's more than 1 then the log should scroll up to give us more space.
}
...
...
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