Forum

Smooth Rotation Single Player "Cheat"

Discuss programming topics for the various GPL'd game engine sources.

Moderator: InsideQC Admins

Smooth Rotation Single Player "Cheat"

Postby Baker » Tue Jun 22, 2010 11:36 am

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.

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? 8) Inquisitive minds want to know ! And if they don't -- well like that ever has stopped me before ..
User avatar
Baker
 
Posts: 3666
Joined: Tue Mar 14, 2006 5:15 am

Postby Spike » Tue Jun 22, 2010 12:10 pm

:)

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

Postby mh » Tue Jun 22, 2010 12:17 pm

Baker wrote:"if no one is looking, do whatever you want"


:D :D :D
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
User avatar
mh
 
Posts: 2292
Joined: Sat Jan 12, 2008 1:38 am

Postby Baker » Tue Jun 22, 2010 12:32 pm

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? 8) Inquisitive minds want to know ! And if they don't -- well like that ever has stopped me before ..
User avatar
Baker
 
Posts: 3666
Joined: Tue Mar 14, 2006 5:15 am

Postby frag.machine » Tue Jun 22, 2010 1:58 pm

IIRC ReadChar() is just a wrapper to ReadByte() without any cast at all, so again, who cares ? :lol:
I know FrikaC made a cgi-bin version of the quakec interpreter once and wrote part of his website in QuakeC :) (LordHavoc)
User avatar
frag.machine
 
Posts: 2090
Joined: Sat Nov 25, 2006 1:49 pm

Postby mh » Tue Jun 22, 2010 3:41 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
User avatar
mh
 
Posts: 2292
Joined: Sat Jan 12, 2008 1:38 am

Postby Spike » Tue Jun 22, 2010 4:21 pm

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.
Spike
 
Posts: 2892
Joined: Fri Nov 05, 2004 3:12 am
Location: UK

Postby r00k » Wed Jun 23, 2010 5:19 pm

frag.machine wrote:IIRC ReadChar() is just a wrapper to ReadByte() without any cast at all, so again, who cares ? :lol:


ReadChar returns signed char
ReadByte returns unsigned char

if that matters...?
r00k
 
Posts: 1110
Joined: Sat Nov 13, 2004 10:39 pm


Return to Engine Programming

Who is online

Users browsing this forum: No registered users and 1 guest