no message
git-svn-id: svn://svn.code.sf.net/p/actiongame/code/trunk/ac@806 e016b1c5-ed68-44aa-a2f7-31cac88cffde
This commit is contained in:
@@ -48,7 +48,6 @@ extern void throw_nade(playerent *d, const vec &vel, bounceent *p);
|
||||
void deathstate(playerent *pl)
|
||||
{
|
||||
pl->lastaction = lastmillis;
|
||||
pl->lifesequence++;
|
||||
pl->attacking = false;
|
||||
pl->state = CS_DEAD;
|
||||
pl->oldpitch = pl->pitch;
|
||||
@@ -473,24 +472,18 @@ void selfdamage(int damage, int actor, playerent *act, bool gib, playerent *pl)
|
||||
}
|
||||
else if(act)
|
||||
{
|
||||
if(isteam(act->team, player1->team))
|
||||
{
|
||||
conoutf("\f2you got fragged by a teammate (%s)", act->name);
|
||||
}
|
||||
else
|
||||
{
|
||||
conoutf("\f2you got fragged by %s", act->name);
|
||||
};
|
||||
if(isteam(act->team, player1->team)) conoutf("\f2you got fragged by a teammate (%s)", act->name);
|
||||
else conoutf("\f2you got fragged by %s", act->name);
|
||||
};
|
||||
if(pl==player1)
|
||||
if(pl==player1)
|
||||
{
|
||||
if(m_ctf) tryflagdrop();
|
||||
showscores(true);
|
||||
setscope(false);
|
||||
addmsg(gib ? SV_GIBDIED : SV_DIED, "ri", actor);
|
||||
if(m_ctf) tryflagdrop();
|
||||
};
|
||||
deathstate(pl);
|
||||
//spawnstate(pl); TESTME
|
||||
pl->lifesequence++;
|
||||
playsound(S_DIE1+rnd(2), pl!=player1 ? &pl->o : NULL);
|
||||
if(gib) addgib(pl);
|
||||
if(pl!=player1 || act->type==ENT_BOT) act->frags++;
|
||||
|
||||
+17
-17
@@ -102,7 +102,7 @@ void parsemessages(int cn, playerent *d, ucharbuf &p)
|
||||
{
|
||||
static char text[MAXTRANS];
|
||||
int type;
|
||||
bool mapchanged = false, c2si = false, gib = false, joining = false;
|
||||
bool mapchanged = false, c2si = false, gib = false, joining = false, firstplayer = false;
|
||||
|
||||
while(p.remaining()) switch(type = getint(p))
|
||||
{
|
||||
@@ -116,10 +116,10 @@ void parsemessages(int cn, playerent *d, ucharbuf &p)
|
||||
return;
|
||||
};
|
||||
clientnum = mycn; // we are now fully connected
|
||||
bool firstplayer = !getint(p);
|
||||
firstplayer = !getint(p);
|
||||
if(getint(p) > 0) conoutf("INFO: this server is password protected");
|
||||
if(!firstplayer) joining = true;
|
||||
else if(getclientmap()[0]) changemap(getclientmap()); // we are the first client on this server, set map
|
||||
if(firstplayer && getclientmap()[0]) changemap(getclientmap()); // we are the first client on this server, set map
|
||||
joining = true;
|
||||
break;
|
||||
};
|
||||
|
||||
@@ -144,7 +144,7 @@ void parsemessages(int cn, playerent *d, ucharbuf &p)
|
||||
case SV_MAPCHANGE:
|
||||
getstring(text, p);
|
||||
changemapserv(text, getint(p));
|
||||
if(joining && m_arena) deathstate(player1);
|
||||
if(joining && m_arena && !firstplayer) deathstate(player1);
|
||||
mapchanged = true;
|
||||
break;
|
||||
|
||||
@@ -187,6 +187,11 @@ void parsemessages(int cn, playerent *d, ucharbuf &p)
|
||||
setskin(d, getint(p));
|
||||
d->lifesequence = getint(p);
|
||||
c2si = true;
|
||||
if(m_ctf) loopi(2)
|
||||
{
|
||||
flaginfo &f = flaginfos[i];
|
||||
if(!f.actor) f.actor = getclient(f.actor_cn);
|
||||
};
|
||||
break;
|
||||
};
|
||||
|
||||
@@ -260,7 +265,7 @@ void parsemessages(int cn, playerent *d, ucharbuf &p)
|
||||
if(m_ctf)
|
||||
{
|
||||
flaginfo &flag = flaginfos[team_opposite(team_int(d->team))];
|
||||
if(flag.state == CTFF_STOLEN && flag.actor == d) deathstate(player1); // punish for ctf TK
|
||||
if(flag.state == CTFF_DROPPED && flag.actor == d && d->lifesequence == d->flagdroplifesequence) deathstate(player1);
|
||||
};
|
||||
}
|
||||
else
|
||||
@@ -288,7 +293,7 @@ void parsemessages(int cn, playerent *d, ucharbuf &p)
|
||||
};
|
||||
};
|
||||
playsound(S_DIE1+rnd(2), &d->o);
|
||||
if(!c2si) d->lifesequence++;
|
||||
if(!c2si) d->lifesequence++;
|
||||
gib = false;
|
||||
break;
|
||||
};
|
||||
@@ -415,7 +420,7 @@ void parsemessages(int cn, playerent *d, ucharbuf &p)
|
||||
case SV_FLAGINFO:
|
||||
{
|
||||
int flag = getint(p);
|
||||
if(flag<0||flag>1) return;
|
||||
if(flag<0 || flag>1) return;
|
||||
flaginfo &f = flaginfos[flag];
|
||||
f.state = getint(p);
|
||||
int action = getint(p);
|
||||
@@ -424,8 +429,7 @@ void parsemessages(int cn, playerent *d, ucharbuf &p)
|
||||
{
|
||||
case CTFF_STOLEN:
|
||||
{
|
||||
int actor = getint(p);
|
||||
flagstolen(flag, action, actor == getclientnum() ? player1 : getclient(actor));
|
||||
flagstolen(flag, action, getint(p));
|
||||
break;
|
||||
};
|
||||
case CTFF_DROPPED:
|
||||
@@ -438,12 +442,8 @@ void parsemessages(int cn, playerent *d, ucharbuf &p)
|
||||
};
|
||||
case CTFF_INBASE:
|
||||
{
|
||||
playerent *actor = NULL;
|
||||
if(action == SV_FLAGRETURN)
|
||||
{
|
||||
int a = getint(p);
|
||||
actor = a == getclientnum() ? player1 : getclient(a);
|
||||
};
|
||||
int actor = -1;
|
||||
if(action == SV_FLAGRETURN) actor = getint(p);
|
||||
flaginbase(flag, action, actor);
|
||||
break;
|
||||
};
|
||||
@@ -497,7 +497,7 @@ void parsemessages(int cn, playerent *d, ucharbuf &p)
|
||||
break;
|
||||
|
||||
case MCMD_AUTOTEAM:
|
||||
autoteambalance = getint(p) == 1;
|
||||
autoteambalance = arg == 1;
|
||||
if(!joining) conoutf("autoteam is %s", autoteambalance ? "enabled" : "disabled");
|
||||
break;
|
||||
};
|
||||
|
||||
+14
-8
@@ -38,11 +38,12 @@ void renderentities()
|
||||
if(!&mmi) continue;
|
||||
rendermodel(mmi.name, ANIM_MAPMODEL|ANIM_LOOP, e.attr4, mmi.rad ? (float)mmi.rad : 1.1f, e.x, (float)S(e.x, e.y)->floor+mmi.zoff+e.attr3, e.y, (float)((e.attr1+7)-(e.attr1+7)%15), 0, 10.0f);
|
||||
}
|
||||
else if(m_ctf && e.type==CTF_FLAG) // EDIT: AH
|
||||
else if(m_ctf && e.type==CTF_FLAG)
|
||||
{
|
||||
flaginfo &f = flaginfos[e.attr2];
|
||||
if(f.state==CTFF_STOLEN && f.actor == player1)
|
||||
if(f.state==CTFF_STOLEN)
|
||||
{
|
||||
if(!f.actor || f.actor == player1) continue;
|
||||
s_sprintfd(path)("pickups/flags/small_%s", team_string(e.attr2));
|
||||
rendermodel(path, ANIM_FLAG|ANIM_START, 0, 1.1f, f.actor->o.x, f.actor->o.z+0.3f+(sinf(lastmillis/100.0f)+1)/10, f.actor->o.y, lastmillis/2.5f, 0, 120.0f);
|
||||
}
|
||||
@@ -347,7 +348,7 @@ bool intersect(entity *e, vec &from, vec &to, vec *end) // if lineseg hits entit
|
||||
};
|
||||
// End add by Ricks
|
||||
|
||||
// ctf flag actions done by the local player
|
||||
// flag ent actions done by the local player
|
||||
|
||||
void flagpickup()
|
||||
{
|
||||
@@ -355,6 +356,7 @@ void flagpickup()
|
||||
f.flag->spawned = false;
|
||||
f.state = CTFF_STOLEN;
|
||||
f.actor = player1; // do this although we don't know if we picked the flag to avoid getting it after a possible respawn
|
||||
f.actor_cn = getclientnum();
|
||||
f.ack = false;
|
||||
addmsg(SV_FLAGPICKUP, "ri", f.team);
|
||||
};
|
||||
@@ -386,13 +388,15 @@ void flagscore()
|
||||
addmsg(SV_FLAGSCORE, "ri", f.team);
|
||||
};
|
||||
|
||||
// flag actions from the net
|
||||
// flag ent actions from the net
|
||||
|
||||
void flagstolen(int flag, int action, playerent *actor)
|
||||
void flagstolen(int flag, int action, int act)
|
||||
{
|
||||
playerent *actor = act == getclientnum() ? player1 : getclient(act);
|
||||
if(!actor) return;
|
||||
flaginfo &f = flaginfos[flag];
|
||||
f.actor = actor;
|
||||
f.actor_cn = act;
|
||||
f.flag->spawned = false;
|
||||
f.ack = true;
|
||||
flagmsg(flag, action);
|
||||
@@ -411,19 +415,21 @@ void flagdropped(int flag, int action, short x, short y, short z)
|
||||
if(floor < hdr.waterlevel) z = hdr.waterlevel; // avoid dropping into water
|
||||
else z = (short) floor;
|
||||
};
|
||||
|
||||
|
||||
f.flag->x = x;
|
||||
f.flag->y = y;
|
||||
f.flag->z = z;
|
||||
f.flag->spawned = true;
|
||||
f.ack = true;
|
||||
if(f.actor) f.actor->flagdroplifesequence = f.actor->lifesequence;
|
||||
flagmsg(flag, action);
|
||||
};
|
||||
|
||||
void flaginbase(int flag, int action, playerent *actor)
|
||||
void flaginbase(int flag, int action, int act)
|
||||
{
|
||||
flaginfo &f = flaginfos[flag];
|
||||
if(actor) f.actor = actor;
|
||||
playerent *actor = act == getclientnum() ? player1 : getclient(act);
|
||||
if(actor) { f.actor = actor; f.actor_cn = act; };
|
||||
f.flag->x = (ushort) f.originalpos.x;
|
||||
f.flag->y = (ushort) f.originalpos.y;
|
||||
f.flag->z = (ushort) f.originalpos.z;
|
||||
|
||||
+5
-4
@@ -143,6 +143,7 @@ struct playerent : dynent
|
||||
float oldpitch;
|
||||
int lastupdate, plag, ping;
|
||||
int lifesequence; // sequence id for each respawn, used in damage test
|
||||
int flagdroplifesequence;
|
||||
int frags, flagscore;
|
||||
int health, armour;
|
||||
int gunselect, gunwait;
|
||||
@@ -152,7 +153,6 @@ struct playerent : dynent
|
||||
int ammo[NUMGUNS];
|
||||
int mag[NUMGUNS];
|
||||
string name, team;
|
||||
//int startheight;
|
||||
int shots; //keeps track of shots from auto weapons
|
||||
bool reloading, hasarmour, weaponchanging;
|
||||
int nextweapon; // weapon we switch to
|
||||
@@ -168,7 +168,7 @@ struct playerent : dynent
|
||||
|
||||
poshist history; // Previous stored locations of this player
|
||||
|
||||
playerent() : plag(0), ping(0), lifesequence(0), frags(0), flagscore(0), lastpain(0), ismaster(false),
|
||||
playerent() : plag(0), ping(0), lifesequence(0), flagdroplifesequence(0), frags(0), flagscore(0), lastpain(0), ismaster(false),
|
||||
shots(0), reloading(false), primary(GUN_ASSAULT), nextprimary(GUN_ASSAULT),
|
||||
skin(0), nextskin(0), inhandnade(NULL)
|
||||
{
|
||||
@@ -226,10 +226,11 @@ struct flaginfo
|
||||
{
|
||||
int team;
|
||||
entity *flag;
|
||||
playerent *actor;
|
||||
int actor_cn;
|
||||
playerent *actor;
|
||||
vec originalpos;
|
||||
int state; // one of CTFF_*
|
||||
bool ack; // data is ackd
|
||||
bool ack;
|
||||
flaginfo() : flag(0), actor(0), state(CTFF_INBASE), ack(false) {};
|
||||
};
|
||||
|
||||
|
||||
+2
-2
@@ -118,9 +118,9 @@ extern void flagpickup();
|
||||
extern void tryflagdrop();
|
||||
extern void flagreturn();
|
||||
extern void flagscore();
|
||||
extern void flagstolen(int flag, int action, playerent *thief);
|
||||
extern void flagstolen(int flag, int action, int act);
|
||||
extern void flagdropped(int flag, int action, short x, short y, short z);
|
||||
extern void flaginbase(int flag, int action, playerent *actor);
|
||||
extern void flaginbase(int flag, int action, int act);
|
||||
extern void flagmsg(int flag, int action);
|
||||
extern void arenarespawn();
|
||||
extern void respawn();
|
||||
|
||||
+19
-19
@@ -289,24 +289,24 @@ void sendservmsg(char *msg, int client=-1)
|
||||
sendf(client, 1, "ris", SV_SERVMSG, msg);
|
||||
};
|
||||
|
||||
struct ctfflag
|
||||
struct sflaginfo
|
||||
{
|
||||
int state;
|
||||
int actor_cn;
|
||||
int pos[3];
|
||||
int lastupdate;
|
||||
} ctfflags[2];
|
||||
} sflaginfos[2];
|
||||
|
||||
void sendflaginfo(int flag, int action, int cn = -1)
|
||||
{
|
||||
ctfflag &f = ctfflags[flag];
|
||||
sflaginfo &f = sflaginfos[flag];
|
||||
ENetPacket *packet = enet_packet_create(NULL, MAXTRANS, ENET_PACKET_FLAG_RELIABLE);
|
||||
ucharbuf p(packet->data, packet->dataLength);
|
||||
putint(p, SV_FLAGINFO);
|
||||
putint(p, flag);
|
||||
putint(p, f.state);
|
||||
putint(p, action);
|
||||
if(f.state==CTFF_STOLEN || action==SV_FLAGRETURN) putint(p, f.actor_cn);
|
||||
if(action==SV_FLAGPICKUP || action==SV_FLAGRETURN) putint(p, f.actor_cn);
|
||||
else if(f.state==CTFF_DROPPED) loopi(3) putint(p, f.pos[i]);
|
||||
enet_packet_resize(packet, p.length());
|
||||
if(cn<0) multicast(packet, -1, 1);
|
||||
@@ -317,7 +317,7 @@ void sendflaginfo(int flag, int action, int cn = -1)
|
||||
void flagaction(int flag, int action, int sender)
|
||||
{
|
||||
if(!valid_flag(flag)) return;
|
||||
ctfflag &f = ctfflags[flag];
|
||||
sflaginfo &f = sflaginfos[flag];
|
||||
|
||||
switch(action)
|
||||
{
|
||||
@@ -326,14 +326,12 @@ void flagaction(int flag, int action, int sender)
|
||||
if(f.state == CTFF_STOLEN) return;
|
||||
f.state = CTFF_STOLEN;
|
||||
f.actor_cn = sender;
|
||||
f.lastupdate = lastsec;
|
||||
break;
|
||||
};
|
||||
case SV_FLAGDROP:
|
||||
{
|
||||
if(f.state!=CTFF_STOLEN || (sender != -1 && f.actor_cn != sender)) return;
|
||||
f.state = CTFF_DROPPED;
|
||||
f.lastupdate = lastsec;
|
||||
loopi(3) f.pos[i] = clients[sender]->pos[i];
|
||||
break;
|
||||
};
|
||||
@@ -342,15 +340,18 @@ void flagaction(int flag, int action, int sender)
|
||||
if(f.state!=CTFF_DROPPED) return;
|
||||
f.state = CTFF_INBASE;
|
||||
f.actor_cn = sender;
|
||||
f.lastupdate = lastsec;
|
||||
break;
|
||||
};
|
||||
case SV_FLAGSCORE:
|
||||
case SV_FLAGRESET:
|
||||
{
|
||||
if(f.state != CTFF_DROPPED || sender != -1) return;
|
||||
f.state = CTFF_INBASE;
|
||||
break;
|
||||
}
|
||||
case SV_FLAGSCORE:
|
||||
{
|
||||
if(f.state != CTFF_STOLEN) return;
|
||||
f.state = CTFF_INBASE;
|
||||
f.actor_cn = sender;
|
||||
break;
|
||||
};
|
||||
default: return;
|
||||
@@ -364,9 +365,9 @@ void ctfreset()
|
||||
{
|
||||
loopi(2)
|
||||
{
|
||||
ctfflags[i].actor_cn = 0;
|
||||
ctfflags[i].state = CTFF_INBASE;
|
||||
ctfflags[i].lastupdate = -1;
|
||||
sflaginfos[i].actor_cn = 0;
|
||||
sflaginfos[i].state = CTFF_INBASE;
|
||||
sflaginfos[i].lastupdate = -1;
|
||||
};
|
||||
};
|
||||
|
||||
@@ -375,7 +376,7 @@ char *disc_reasons[] = { "normal", "end of packet", "client num", "kicked by mas
|
||||
void disconnect_client(int n, int reason = -1)
|
||||
{
|
||||
if(!clients.inrange(n) || clients[n]->type!=ST_TCPIP) return;
|
||||
if(m_ctf) loopi(2) if(ctfflags[i].state==CTFF_STOLEN && ctfflags[i].actor_cn==n) flagaction(i, SV_FLAGDROP, -1);
|
||||
if(m_ctf) loopi(2) if(sflaginfos[i].state==CTFF_STOLEN && sflaginfos[i].actor_cn==n) flagaction(i, SV_FLAGDROP, n);
|
||||
client &c = *clients[n];
|
||||
clientscore *sc = findscore(c, true);
|
||||
if(sc) *sc = c.score;
|
||||
@@ -621,7 +622,7 @@ void mastercmd(int sender, int cmd, int a)
|
||||
case MCMD_AUTOTEAM:
|
||||
{
|
||||
if(a < 0 || a > 1) return;
|
||||
if((autoteam = a != 0) == 1 && m_teammode) shuffleteams();
|
||||
if((autoteam = a == 1) == true && m_teammode) shuffleteams();
|
||||
break;
|
||||
};
|
||||
};
|
||||
@@ -782,7 +783,7 @@ void process(ENetPacket *packet, int sender, int chan) // sender may be -1
|
||||
else sendservmsg("no map to get", sender);
|
||||
break;
|
||||
};
|
||||
|
||||
|
||||
case SV_FLAGPICKUP:
|
||||
case SV_FLAGDROP:
|
||||
case SV_FLAGRETURN:
|
||||
@@ -811,7 +812,6 @@ void process(ENetPacket *packet, int sender, int chan) // sender may be -1
|
||||
{
|
||||
int cmd = getint(p);
|
||||
int arg = getint(p);
|
||||
//mastercmd(sender, cmd, arg) && cmd != MCMD_AUTOTEAM) QUEUE_MSG;
|
||||
mastercmd(sender, cmd, arg);
|
||||
break;
|
||||
};
|
||||
@@ -968,8 +968,8 @@ void serverslice(int seconds, unsigned int timeout) // main server update, cal
|
||||
|
||||
if(m_ctf) loopi(2)
|
||||
{
|
||||
ctfflag &f = ctfflags[i];
|
||||
if(f.state==CTFF_DROPPED && seconds-f.lastupdate>30) flagaction(i, SV_FLAGRESET, f.actor_cn);
|
||||
sflaginfo &f = sflaginfos[i];
|
||||
if(f.state==CTFF_DROPPED && seconds-f.lastupdate>30) flagaction(i, SV_FLAGRESET, -1);
|
||||
};
|
||||
|
||||
lastsec = seconds;
|
||||
|
||||
Reference in New Issue
Block a user