Smooth Rotation Single Player "Cheat"
Moderator: InsideQC Admins
8 posts
• Page 1 of 1
Smooth Rotation Single Player "Cheat"
Rotating brush models look great until you walk on them and the default bytes indicating angles makes everything jerky --- almost as bad as hipnotic rotating brushes.
Rather than reinvent a protocol or do something annoying, I've found the easiest fix is the "if no one is looking, do whatever you want" theory of protocols.
In single player, if you aren't recording a demo or playing a demo and you aren't connected to a server or hosting one ... who cares whether your "protocol" is standard as it is operating in absolute isolation.
Smooth as imaginable.
Rather than reinvent a protocol or do something annoying, I've found the easiest fix is the "if no one is looking, do whatever you want" theory of protocols.
In single player, if you aren't recording a demo or playing a demo and you aren't connected to a server or hosting one ... who cares whether your "protocol" is standard as it is operating in absolute isolation.
- Code: Select all
#define PRIVATE_PROTOCOL_OK (sv.active && cls.state != ca_dedicated && !cls.demoplayback && !cls.demorecording && svs.maxclients == 1)
void MSG_WriteAngle (sizebuf_t *sb, float f)
{
#ifdef SMOOTH_SINGLEPLAYER_TEST
if (PRIVATE_PROTOCOL_OK)
MSG_WriteFloat (sb, f);
else
#endif
MSG_WriteByte (sb, ((int)f*256/360) & 255);
}
.
.
.
float MSG_ReadAngle (void)
{
#ifdef SMOOTH_SINGLEPLAYER_TEST
if (PRIVATE_PROTOCOL_OK)
return MSG_ReadFloat();
else
#endif
return MSG_ReadChar() * (360.0/256);
}
Smooth as imaginable.
Last edited by Baker on Tue Jun 22, 2010 12:37 pm, edited 1 time in total.
The night is young. How else can I annoy the world before sunsrise?
Inquisitive minds want to know ! And if they don't -- well like that ever has stopped me before ..
-

Baker - Posts: 3666
- Joined: Tue Mar 14, 2006 5:15 am
:)
but does still contribute to packet overflows, a significant problem with spammy mods.
also, you forgot to test for recording demos.
Also, as an extra side-note, your existing code rounds towards 0, meaning the angle is 1/512th to the left, which is easily noticable when zoomed and spamming the sng.
Also sent as a byte and read as a char, but whatever.
but does still contribute to packet overflows, a significant problem with spammy mods.
also, you forgot to test for recording demos.
Also, as an extra side-note, your existing code rounds towards 0, meaning the angle is 1/512th to the left, which is easily noticable when zoomed and spamming the sng.
Also sent as a byte and read as a char, but whatever.
- Spike
- Posts: 2892
- Joined: Fri Nov 05, 2004 3:12 am
- Location: UK
Spike wrote:but does still contribute to packet overflows, a significant problem with spammy mods.
Worthy of road testing testing, hence the #ifdef
also, you forgot to test for recording demos.
Thanks, nice catch! Actually I did have that in there and lost it upon messing around with the definition.
Add: "&& !cls.demorecording"
(Edited first post for completeness ...)
Also, as an extra side-note, your existing code rounds towards 0, meaning the angle is 1/512th to the left, which is easily noticable when zoomed and spamming the sng.
Original Quake code. Not really actually used in practice by me (ProQuake, JoeQuake, Qrack use the ProQuake "ReadPreciseAngle" short).
Ironically, I can feel the difference in single player enough that fixing the bad rounding gets on my nerves because rockets shoot too "straight" forward.
Also sent as a byte and read as a char, but whatever.
I just opened the original source to see if it was like that or if I otherwise somehow inherited that from some other engine.
But actually that is original Q1 Carmack-written code.
The night is young. How else can I annoy the world before sunsrise?
Inquisitive minds want to know ! And if they don't -- well like that ever has stopped me before ..
-

Baker - Posts: 3666
- Joined: Tue Mar 14, 2006 5:15 am
IIRC ReadChar() is just a wrapper to ReadByte() without any cast at all, so again, who cares ? 
I know FrikaC made a cgi-bin version of the quakec interpreter once and wrote part of his website in QuakeC
(LordHavoc)
-

frag.machine - Posts: 2090
- Joined: Sat Nov 25, 2006 1:49 pm
If you're worried about packet overflow you could quantize to unsigned shorts instead of to bytes. That would be accurate to about 0.005 degrees, which I reckon is enough for anyone.
We had the power, we had the space, we had a sense of time and place
We knew the words, we knew the score, we knew what we were fighting for
We knew the words, we knew the score, we knew what we were fighting for
-

mh - Posts: 2292
- Joined: Sat Jan 12, 2008 1:38 am
0.005?
you need 0.0005 in order to be enough for anyone.
640k graduations.
okay, bad joke. :s
but yeah, increasing the number of graduations by a mere 25500% is probably enough that noone would notice.
you need 0.0005 in order to be enough for anyone.
640k graduations.
okay, bad joke. :s
but yeah, increasing the number of graduations by a mere 25500% is probably enough that noone would notice.
- Spike
- Posts: 2892
- Joined: Fri Nov 05, 2004 3:12 am
- Location: UK
8 posts
• Page 1 of 1
Who is online
Users browsing this forum: No registered users and 1 guest