Skip to content

Commit

Permalink
no message
Browse files Browse the repository at this point in the history
git-svn-id: svn://svn.code.sf.net/p/actiongame/code/trunk/ac@734 e016b1c5-ed68-44aa-a2f7-31cac88cffde
  • Loading branch information
drian0 committed Nov 25, 2006
1 parent fb2e043 commit ecab191
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
4 changes: 2 additions & 2 deletions source/src/clients2c.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -470,9 +470,9 @@ void parsemessages(int cn, playerent *d, ucharbuf &p)
if(pl)
{
pl->ismaster = true;
conoutf("%s claimed master status", pl->name);
conoutf("%s claimed master status", pl == player1 ? "you" : pl->name);
};
}
};
break;
};

Expand Down
13 changes: 10 additions & 3 deletions source/src/server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ struct client // server side version of "dynent" type
score.reset();
position.setsizenodelete(0);
messages.setsizenodelete(0);
ismaster = isauthed = false;
};
};

Expand Down Expand Up @@ -496,15 +497,21 @@ int master()
return -1;
};

void sendmasterinfo(int receiver)
{
sendf(receiver, 1, "rii", SV_MASTERINFO, master());
};

void setmaster(int client, bool claim, char *pwd = NULL)
{
if(!isdedicated || !valid_client(client)) return;

int curmaster = master();
if((curmaster == -1 || curmaster == client) || (pwd && pwd[0] && masterpasswd && !strcmp(masterpasswd, pwd)))
{
loopv(clients) if(clients[i]->type!=ST_EMPTY) clients[i]->ismaster = (i == client);
sendf(-1, 1, "rii", SV_MASTERINFO, client);
if(claim) loopv(clients) if(clients[i]->type!=ST_EMPTY) clients[i]->ismaster = false;
clients[client]->ismaster = claim;
sendmasterinfo(-1);
}
else if(pwd && pwd[0])
{
Expand Down Expand Up @@ -841,6 +848,7 @@ void send_welcome(int n)
putint(p, -1);
};
};
if(clients[n]->type == ST_TCPIP && master() != -1) sendmasterinfo(n);
loopv(clients)
{
client &c = *clients[i];
Expand Down Expand Up @@ -1001,7 +1009,6 @@ void serverslice(int seconds, unsigned int timeout) // main server update, cal
c.type = ST_TCPIP;
c.peer = event.peer;
c.peer->data = (void *)(size_t)c.clientnum;
c.ismaster = c.isauthed = false;
char hn[1024];
s_strcpy(c.hostname, (enet_address_get_host(&c.peer->address, hn, sizeof(hn))==0) ? hn : "unknown");
printf("client connected (%s)\n", c.hostname);
Expand Down

0 comments on commit ecab191

Please sign in to comment.