Skip to content

Commit

Permalink
more compact position packet
Browse files Browse the repository at this point in the history
  • Loading branch information
greghaynes committed Jul 20, 2010
1 parent 87c5057 commit 025505b
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 11 deletions.
2 changes: 1 addition & 1 deletion src/engine/server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ int getuint(ucharbuf &p)
n += (p.get() << 7) - 0x80;
if(n & (1<<14)) n += (p.get() << 14) - (1<<14);
if(n & (1<<21)) n += (p.get() << 21) - (1<<21);
if(n & (1<<28)) n |= 0xF0000000;
if(n & (1<<28)) n |= -1<<28;
}
return n;
}
Expand Down
29 changes: 19 additions & 10 deletions src/fpsgame/server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1688,17 +1688,26 @@ namespace server
{
case N_POS:
{
int pcn = getint(p);
int pcn = getuint(p);
p.get();
uint flags = getuint(p);
clientinfo *cp = getinfo(pcn);
if(cp && pcn != sender && cp->ownernum != sender) cp = NULL;
vec pos;
loopi(3) pos[i] = getuint(p)/DMF;
getuint(p);
loopi(5) getint(p);
int physstate = getuint(p);
if(physstate&0x20) loopi(2) getint(p);
if(physstate&0x10) getint(p);
getuint(p);
loopk(3)
{
int n = p.get(); n |= p.get()<<8; if(flags&(1<<k)) { n |= p.get()<<16; if(n&0x800000) n |= -1<<24; }
pos[k] = n/DMF;
}
loopk(3) p.get();
int mag = p.get(); if(flags&(1<<3)) mag |= p.get()<<8;
int dir = p.get(); dir |= p.get()<<8;
vec vel = vec((dir%360)*RAD, (clamp(dir/360, 0, 180)-90)*RAD).mul(mag/DVELF);
if(flags&(1<<4))
{
p.get(); if(flags&(1<<5)) p.get();
if(flags&(1<<6)) loopk(2) p.get();
}
if(cp)
{
if((!ci->local || demorecord || hasnonlocalclients()) && (cp->state.state==CS_ALIVE || cp->state.state==CS_EDITING))
Expand All @@ -1713,10 +1722,10 @@ namespace server
cp->active = true;
SbPy::triggerEventInt("player_active", cp->clientnum);
}
if(smode) smode->moved(cp, cp->state.o, cp->gameclip, pos, (physstate&0x80)!=0);
if(smode) smode->moved(cp, cp->state.o, cp->gameclip, pos, (flags&0x80)!=0);
}
cp->state.o = pos;
cp->gameclip = (physstate&0x80)!=0;
cp->gameclip = (flags&0x80)!=0;
}
break;
}
Expand Down

0 comments on commit 025505b

Please sign in to comment.