cleaned up client init handling

git-svn-id: svn://svn.code.sf.net/p/actiongame/code/trunk/ac@4763 e016b1c5-ed68-44aa-a2f7-31cac88cffde
This commit is contained in:
Lee Salzman
2010-01-12 01:34:23 +00:00
parent c4227bca8e
commit 2da8c7f8d5
8 changed files with 171 additions and 146 deletions
+2 -12
View File
@@ -8,7 +8,6 @@ VAR(connected, 1, 0, 0);
ENetHost *clienthost = NULL;
ENetPeer *curpeer = NULL, *connpeer = NULL;
int connmillis = 0, connattempts = 0, discmillis = 0;
bool c2sinit = false; // whether we need to tell the other clients our stats
bool watchingdemo = false;
int getclientnum() { return player1 ? player1->clientnum : -1; }
@@ -177,7 +176,6 @@ void disconnect(int onlyclean, int async)
if(cleanup)
{
c2sinit = false;
player1->clientnum = -1;
player1->lifesequence = 0;
player1->clientrole = CR_DEFAULT;
@@ -413,19 +411,10 @@ void c2sinfo(playerent *d) // send update to the server
sendpackettoserv(0, q.finalize());
}
if(sendmapidenttoserver || !c2sinit || messages.length() || totalmillis-lastping>250)
if(sendmapidenttoserver || messages.length() || totalmillis-lastping>250)
{
packetbuf p(MAXTRANS);
if(!c2sinit) // tell other clients who I am
{
p.reliable();
c2sinit = true;
putint(p, SV_INITC2S);
sendstring(player1->name, p);
putint(p, player1->skin(TEAM_CLA));
putint(p, player1->skin(TEAM_RVSF));
}
if(sendmapidenttoserver)
{ // new map
spawnallitems();
@@ -485,6 +474,7 @@ void sendintro()
clientpassword[0] = '\0';
connectrole = CR_DEFAULT;
putint(p, player1->nextprimweap->type);
loopi(2) putint(p, player1->skin(i));
sendpackettoserv(1, p.finalize());
}