Skip to content

Commit

Permalink
Added put*int methods, and addplayerstate synced
Browse files Browse the repository at this point in the history
  • Loading branch information
greghaynes committed Jul 20, 2010
1 parent dca02ed commit 388f0ef
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 11 deletions.
2 changes: 2 additions & 0 deletions src/engine/server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ static inline void putint_(T &p, int n)
}
void putint(ucharbuf &p, int n) { putint_(p, n); }
void putint(packetbuf &p, int n) { putint_(p, n); }
void putint(vector<uchar> &p, int n) { putint_(p, n); }

int getint(ucharbuf &p)
{
Expand Down Expand Up @@ -93,6 +94,7 @@ static inline void putuint_(T &p, int n)
}
void putuint(ucharbuf &p, int n) { putuint_(p, n); }
void putuint(packetbuf &p, int n) { putuint_(p, n); }
void putuint(vector<uchar> &p, int n) { putuint_(p, n); }

int getuint(ucharbuf &p)
{
Expand Down
30 changes: 19 additions & 11 deletions src/fpsgame/server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -720,20 +720,18 @@ namespace server
else
{
ci.posoff = ws.positions.length();
loopvj(ci.position) ws.positions.add(ci.position[j]);
ws.positions.put(ci.position.getbuf(), ci.position.length());
ci.poslen = ws.positions.length() - ci.posoff;
ci.position.setsize(0);
}
if(ci.messages.empty()) ci.msgoff = -1;
else
{
ci.msgoff = ws.messages.length();
ucharbuf p = ws.messages.reserve(16);
putint(p, N_CLIENT);
putint(p, ci.clientnum);
putuint(p, ci.messages.length());
ws.messages.addbuf(p);
loopvj(ci.messages) ws.messages.add(ci.messages[j]);
putint(ws.messages, N_CLIENT);
putint(ws.messages, ci.clientnum);
putuint(ws.messages, ci.messages.length());
ws.messages.put(ci.messages.getbuf(), ci.messages.length());
ci.msglen = ws.messages.length() - ci.msgoff;
ci.messages.setsize(0);
}
Expand Down Expand Up @@ -765,10 +763,20 @@ namespace server
}
}
int psize = ws.positions.length(), msize = ws.messages.length();
if(psize) recordpacket(0, ws.positions.getbuf(), psize);
if(msize) recordpacket(1, ws.messages.getbuf(), msize);
loopi(psize) { uchar c = ws.positions[i]; ws.positions.add(c); }
loopi(msize) { uchar c = ws.messages[i]; ws.messages.add(c); }
if(psize)
{
recordpacket(0, ws.positions.getbuf(), psize);
ucharbuf p = ws.positions.reserve(psize);
p.put(ws.positions.getbuf(), psize);
ws.positions.addbuf(p);
}
if(msize)
{
recordpacket(1, ws.messages.getbuf(), msize);
ucharbuf p = ws.messages.reserve(msize);
p.put(ws.messages.getbuf(), msize);
ws.messages.addbuf(p);
}
ws.uses = 0;
if(psize || msize) loopv(clients)
{
Expand Down
2 changes: 2 additions & 0 deletions src/shared/iengine.h
Original file line number Diff line number Diff line change
Expand Up @@ -306,9 +306,11 @@ extern int getnumclients();
extern uint getclientip(int n);
extern void putint(ucharbuf &p, int n);
extern void putint(packetbuf &p, int n);
extern void putint(vector<uchar> &p, int n);
extern int getint(ucharbuf &p);
extern void putuint(ucharbuf &p, int n);
extern void putuint(packetbuf &p, int n);
extern void putuint(vector<uchar> &p, int n);
extern int getuint(ucharbuf &p);
extern void putfloat(ucharbuf &p, float f);
extern void putfloat(packetbuf &p, float f);
Expand Down

0 comments on commit 388f0ef

Please sign in to comment.