no message
git-svn-id: svn://svn.code.sf.net/p/actiongame/code/trunk/ac@1312 e016b1c5-ed68-44aa-a2f7-31cac88cffde
This commit is contained in:
@@ -554,8 +554,6 @@ void startmap(char *name) // called just after a map load
|
||||
if(*clientmap) conoutf("game mode is \"%s\"", modestr(gamemode));
|
||||
}
|
||||
|
||||
COMMANDN(map, changemap, ARG_1STR);
|
||||
|
||||
void suicide()
|
||||
{
|
||||
if(player1->state!=CS_ALIVE) return;
|
||||
@@ -650,6 +648,9 @@ votedisplayinfo *newvotedisplayinfo(playerent *owner, int type, char *arg1, char
|
||||
case SA_AUTOTEAM:
|
||||
s_sprintf(v->desc)(msg, atoi(arg1) == 0 ? "disable" : "enable");
|
||||
break;
|
||||
case SA_MAP:
|
||||
s_sprintf(v->desc)(msg, arg1, modestr(atoi(arg2)));
|
||||
break;
|
||||
default:
|
||||
s_sprintf(v->desc)(msg, arg1, arg2);
|
||||
break;
|
||||
@@ -684,11 +685,13 @@ void callvote(char *type, char *arg1, char *arg2)
|
||||
enet_packet_resize(packet, p.length());
|
||||
sendpackettoserv(1, packet);
|
||||
}
|
||||
else conoutf("\f3invalid vote");
|
||||
}
|
||||
|
||||
void vote(int v)
|
||||
{
|
||||
if(!curvote || v < 0 || v >= VOTE_NUM) return;
|
||||
if(curvote->localplayervoted) { conoutf("\f3you voted already"); return; }
|
||||
ENetPacket *packet = enet_packet_create(NULL, MAXTRANS, ENET_PACKET_FLAG_RELIABLE);
|
||||
ucharbuf p(packet->data, packet->dataLength);
|
||||
putint(p, SV_VOTE);
|
||||
@@ -696,6 +699,7 @@ void vote(int v)
|
||||
enet_packet_resize(packet, p.length());
|
||||
sendpackettoserv(1, packet);
|
||||
curvote->stats[v]++;
|
||||
curvote->localplayervoted = true;
|
||||
}
|
||||
|
||||
void displayvote(votedisplayinfo *v)
|
||||
@@ -703,8 +707,9 @@ void displayvote(votedisplayinfo *v)
|
||||
if(!v) return;
|
||||
DELETEP(curvote);
|
||||
curvote = v;
|
||||
conoutf("%s called a vote: %s", colorname(v->owner), curvote->desc);
|
||||
conoutf("%s called a vote: %s", v->owner ? colorname(v->owner) : "", curvote->desc);
|
||||
playsound(S_CALLVOTE);
|
||||
curvote->localplayervoted = false;
|
||||
}
|
||||
|
||||
void callvotesuc()
|
||||
@@ -752,6 +757,18 @@ void setadmin(char *claim, char *password)
|
||||
COMMAND(setmaster, ARG_1INT);
|
||||
COMMAND(setadmin, ARG_2STR);
|
||||
|
||||
void changemap(char *name) // request map change, server may ignore. silent vote
|
||||
{
|
||||
ENetPacket *packet = enet_packet_create(NULL, MAXTRANS, ENET_PACKET_FLAG_RELIABLE);
|
||||
ucharbuf p(packet->data, packet->dataLength);
|
||||
putint(p, SV_CALLVOTE);
|
||||
putint(p, SA_MAP);
|
||||
sendstring(name, p);
|
||||
putint(p, nextmode);
|
||||
enet_packet_resize(packet, p.length());
|
||||
sendpackettoserv(1, packet);
|
||||
}
|
||||
|
||||
struct mline { string name, cmd; };
|
||||
static vector<mline> mlines;
|
||||
|
||||
|
||||
@@ -18,18 +18,6 @@ void changemapserv(char *name, int mode) // forced map change from the se
|
||||
load_world(name);
|
||||
}
|
||||
|
||||
void changemap(char *name) // request map change, server may ignore
|
||||
{
|
||||
ENetPacket *packet = enet_packet_create(NULL, MAXTRANS, ENET_PACKET_FLAG_RELIABLE);
|
||||
ucharbuf p(packet->data, packet->dataLength);
|
||||
putint(p, SV_CALLVOTE);
|
||||
putint(p, SA_MAP);
|
||||
sendstring(name, p);
|
||||
putint(p, nextmode);
|
||||
enet_packet_resize(packet, p.length());
|
||||
sendpackettoserv(1, packet);
|
||||
}
|
||||
|
||||
// update the position of other clients in the game in our world
|
||||
// don't care if he's in the scenery or other players,
|
||||
// just don't overlap with our client
|
||||
@@ -561,52 +549,6 @@ void parsemessages(int cn, playerent *d, ucharbuf &p)
|
||||
break;
|
||||
}
|
||||
|
||||
/* fixme,ah
|
||||
case SV_SERVOPCMD:
|
||||
{
|
||||
int cmd = getint(p), arg = getint(p);
|
||||
playerent *pl = (arg == getclientnum() ? NULL : getclient(arg));
|
||||
switch(cmd)
|
||||
{
|
||||
case SA_KICK:
|
||||
case SA_BAN:
|
||||
{
|
||||
if(pl) conoutf("%s has been %s", colorname(pl), cmd == SA_KICK ? "kicked" : "banned");
|
||||
break;
|
||||
}
|
||||
case SA_REMBANS:
|
||||
conoutf("bans removed");
|
||||
break;
|
||||
|
||||
case SA_MASTERMODE:
|
||||
conoutf("mastermode set to \"%s\"", arg ? "private" : "open");
|
||||
break;
|
||||
|
||||
case SA_AUTOTEAM:
|
||||
autoteambalance = arg == 1;
|
||||
if(!joining) conoutf("autoteam is %s", autoteambalance ? "enabled" : "disabled");
|
||||
break;
|
||||
|
||||
case SA_GIVEMASTER:
|
||||
if(pl) conoutf("the admin gave master state to %s", colorname(pl));
|
||||
break;
|
||||
|
||||
case SA_FORCETEAM:
|
||||
if(pl) conoutf("player %s was forced to change the team", colorname(pl));
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
*/
|
||||
|
||||
/*fixme,ah
|
||||
case SV_SERVOPCMDDENIED:
|
||||
{
|
||||
conoutf("\f3denied. you have to be at least %s to perform this action", getint(p) == CR_ADMIN ? "admin" : "master");
|
||||
break;
|
||||
}
|
||||
*/
|
||||
|
||||
case SV_FORCETEAM:
|
||||
{
|
||||
changeteam(getint(p), true);
|
||||
|
||||
@@ -344,8 +344,8 @@ void gl_drawhud(int w, int h, int curfps, int nquads, int curvert, bool underwat
|
||||
if(curvote && curvote->millis >= lastmillis)
|
||||
{
|
||||
const int left = 20*2, top = VIRTH;
|
||||
draw_textf("%s called a vote", left, top+240, colorname(curvote->owner, 10));
|
||||
draw_textf("\f3§ %s", left, top+320, curvote->desc);
|
||||
draw_textf("%s called a vote", left, top+240, curvote->owner ? colorname(curvote->owner) : "");
|
||||
draw_textf("> %s", left, top+320);
|
||||
glColor3f(1,1,1);
|
||||
switch(curvote->result)
|
||||
{
|
||||
|
||||
@@ -1277,7 +1277,7 @@ voteinfo *curvote = NULL;
|
||||
void checkvotes(bool forceend = false)
|
||||
{
|
||||
if(!curvote) return;
|
||||
int stats[3] = {0};
|
||||
int stats[VOTE_NUM] = {0};
|
||||
loopv(clients) if(clients[i]->type!=ST_EMPTY) { stats[clients[i]->vote]++; };
|
||||
int total = stats[VOTE_NO]+stats[VOTE_YES]+stats[VOTE_NEUTRAL];
|
||||
const float requiredcount = 0.51f;
|
||||
@@ -1286,15 +1286,17 @@ void checkvotes(bool forceend = false)
|
||||
sendf(-1, 1, "ri2", SV_VOTERESULT, VOTE_YES);
|
||||
curvote->pass();
|
||||
}
|
||||
else if(forceend || stats[VOTE_YES]/(float)total > requiredcount)
|
||||
else if(forceend || stats[VOTE_NO]/(float)total > requiredcount)
|
||||
{
|
||||
sendf(-1, 1, "ri2", SV_VOTERESULT, VOTE_NO);
|
||||
}
|
||||
else return;
|
||||
|
||||
resetvotes();
|
||||
DELETEP(curvote);
|
||||
}
|
||||
|
||||
bool vote(int sender, int vote) // true the vote was placed successfull
|
||||
bool vote(int sender, int vote) // true if the vote was placed successfully
|
||||
{
|
||||
if(!curvote || !valid_client(sender) || vote < VOTE_YES || vote > VOTE_NO) return false;
|
||||
if(clients[sender]->vote != VOTE_NEUTRAL)
|
||||
@@ -1818,8 +1820,8 @@ void process(ENetPacket *packet, int sender, int chan) // sender may be -1
|
||||
|
||||
case SV_VOTE:
|
||||
{
|
||||
vote(sender, getint(p));
|
||||
return;
|
||||
if(vote(sender, getint(p))) QUEUE_MSG;
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
|
||||
+2
-1
@@ -3,5 +3,6 @@ struct votedisplayinfo
|
||||
playerent *owner;
|
||||
int type, stats[VOTE_NUM], result, millis;
|
||||
string desc;
|
||||
votedisplayinfo() : owner(NULL), result(VOTE_NEUTRAL), millis(0) { loopi(VOTE_NUM) stats[i] = VOTE_NEUTRAL; }
|
||||
bool localplayervoted;
|
||||
votedisplayinfo() : owner(NULL), result(VOTE_NEUTRAL), millis(0), localplayervoted(false) { loopi(VOTE_NUM) stats[i] = VOTE_NEUTRAL; }
|
||||
};
|
||||
Reference in New Issue
Block a user