no message
git-svn-id: svn://svn.code.sf.net/p/actiongame/code/trunk/ac@777 e016b1c5-ed68-44aa-a2f7-31cac88cffde
This commit is contained in:
+10
-14
@@ -69,13 +69,13 @@ int smallerteam()
|
||||
void changeteam(int team) // force team and respawn
|
||||
{
|
||||
c2sinit = false;
|
||||
if(m_ctf) dropctfflags();
|
||||
if(m_ctf) dropctfflag();
|
||||
s_strncpy(player1->team, team_string(team), MAXTEAMLEN+1);
|
||||
player1->lastaction = lastmillis;
|
||||
player1->state = CS_DEAD;
|
||||
};
|
||||
|
||||
void newteam(char *name) // save team changing
|
||||
void newteam(char *name)
|
||||
{
|
||||
if(name[0])
|
||||
{
|
||||
@@ -86,22 +86,18 @@ void newteam(char *name) // save team changing
|
||||
|
||||
if(!strcmp(name, "RVSF") || !strcmp(name, "CLA"))
|
||||
{
|
||||
if(strcmp(name, player1->team))
|
||||
{
|
||||
int team = team_int(name);
|
||||
if(checkteamsize && team != freeteam)
|
||||
{
|
||||
conoutf("\f3the %s team is already full", name);
|
||||
return;
|
||||
};
|
||||
changeteam(team);
|
||||
}
|
||||
else return; // same team
|
||||
if(!strcmp(name, player1->team)) return; // same team
|
||||
int team = team_int(name);
|
||||
if(checkteamsize && team != freeteam)
|
||||
{
|
||||
conoutf("\f3the %s team is already full", name);
|
||||
return;
|
||||
};
|
||||
changeteam(team);
|
||||
}
|
||||
else changeteam(checkteamsize ? (uint)freeteam : rnd(2)); // random assignement
|
||||
}
|
||||
else return;
|
||||
//else { c2sinit = false; s_strncpy(player1->team, name, MAXTEAMLEN+1); };
|
||||
}
|
||||
else conoutf("your team is: %s", player1->team);
|
||||
};
|
||||
|
||||
@@ -94,7 +94,7 @@ void freebotent(botent *d)
|
||||
};
|
||||
};
|
||||
|
||||
void dropctfflags()
|
||||
void dropctfflag()
|
||||
{
|
||||
int flag = team_opposite(team_int(player1->team));
|
||||
flaginfo &f = flaginfos[flag];
|
||||
@@ -106,6 +106,18 @@ void dropctfflags()
|
||||
};
|
||||
};
|
||||
|
||||
void resetctfflag()
|
||||
{
|
||||
int flag = team_opposite(team_int(player1->team));
|
||||
flaginfo &f = flaginfos[flag];
|
||||
if(f.state==CTFF_STOLEN && f.actor==player1)
|
||||
{
|
||||
addmsg(SV_FLAGRESET, "ri", flag);
|
||||
f.flag->spawned = false;
|
||||
f.state = CTFF_INBASE;
|
||||
};
|
||||
};
|
||||
|
||||
void respawnself()
|
||||
{
|
||||
spawnplayer(player1);
|
||||
@@ -482,7 +494,7 @@ void selfdamage(int damage, int actor, playerent *act, bool gib, playerent *pl)
|
||||
};
|
||||
if(pl==player1)
|
||||
{
|
||||
if(m_ctf) dropctfflags();
|
||||
if(m_ctf) dropctfflag();
|
||||
showscores(true);
|
||||
setscope(false);
|
||||
addmsg(gib ? SV_GIBDIED : SV_DIED, "ri", actor);
|
||||
@@ -656,6 +668,12 @@ void flagaction(int flag, int action)
|
||||
else conoutf("\f2%s scored for %s team", f.actor->name, (ownflag ? "the enemy" : "your"));
|
||||
break;
|
||||
};
|
||||
case SV_FLAGRESET:
|
||||
{
|
||||
playsound(S_FLAGRETURN);
|
||||
conoutf("the server reset the flag");
|
||||
break;
|
||||
};
|
||||
default: break;
|
||||
};
|
||||
};
|
||||
|
||||
+42
-36
@@ -418,42 +418,48 @@ void parsemessages(int cn, playerent *d, ucharbuf &p)
|
||||
flaginfo &f = flaginfos[flag];
|
||||
f.state = getint(p);
|
||||
int action = getint(p);
|
||||
if(f.state==CTFF_STOLEN)
|
||||
{
|
||||
int actor_cn = getint(p);
|
||||
f.actor = actor_cn == getclientnum() ? player1 : getclient(actor_cn);
|
||||
f.flag->spawned = false;
|
||||
}
|
||||
else if(f.state==CTFF_DROPPED)
|
||||
{
|
||||
f.flag->x = (ushort) (getint(p)/DMF);
|
||||
f.flag->y = (ushort) (getint(p)/DMF);
|
||||
f.flag->z = (ushort) (getint(p)/DMF);
|
||||
f.flag->z -= 4;
|
||||
sqr *dropplace = S_SECURE(f.flag->x, f.flag->y);
|
||||
if(!dropplace) return;
|
||||
float floor = (float)dropplace->floor;
|
||||
if(f.flag->z > hdr.waterlevel) // above water
|
||||
{
|
||||
if(floor < hdr.waterlevel)
|
||||
f.flag->z = hdr.waterlevel; // avoid dropping into water
|
||||
else
|
||||
f.flag->z = (short)floor;
|
||||
};
|
||||
f.flag->spawned = true;
|
||||
}
|
||||
else if(f.state==CTFF_INBASE)
|
||||
{
|
||||
if(action==SV_FLAGRETURN)
|
||||
{
|
||||
int returnerer_cn = getint(p);
|
||||
f.actor = returnerer_cn == getclientnum() ? player1 : getclient(returnerer_cn);
|
||||
}
|
||||
f.flag->x = (ushort) f.originalpos.x;
|
||||
f.flag->y = (ushort) f.originalpos.y;
|
||||
f.flag->z = (ushort) f.originalpos.z;
|
||||
f.flag->spawned = true;
|
||||
};
|
||||
switch(f.state)
|
||||
{
|
||||
case CTFF_STOLEN:
|
||||
{
|
||||
int actor_cn = getint(p);
|
||||
f.actor = actor_cn == getclientnum() ? player1 : getclient(actor_cn);
|
||||
f.flag->spawned = false;
|
||||
break;
|
||||
};
|
||||
case CTFF_DROPPED:
|
||||
{
|
||||
f.flag->x = (ushort) (getint(p)/DMF);
|
||||
f.flag->y = (ushort) (getint(p)/DMF);
|
||||
f.flag->z = (ushort) (getint(p)/DMF);
|
||||
f.flag->z -= 4;
|
||||
sqr *dropplace = S_SECURE(f.flag->x, f.flag->y);
|
||||
if(!dropplace) return;
|
||||
float floor = (float)dropplace->floor;
|
||||
if(f.flag->z > hdr.waterlevel) // above water
|
||||
{
|
||||
if(floor < hdr.waterlevel)
|
||||
f.flag->z = hdr.waterlevel; // avoid dropping into water
|
||||
else
|
||||
f.flag->z = (short)floor;
|
||||
};
|
||||
f.flag->spawned = true;
|
||||
break;
|
||||
};
|
||||
case CTFF_INBASE:
|
||||
{
|
||||
if(action==SV_FLAGRETURN)
|
||||
{
|
||||
int returnerer_cn = getint(p);
|
||||
f.actor = returnerer_cn == getclientnum() ? player1 : getclient(returnerer_cn);
|
||||
};
|
||||
f.flag->x = (ushort) f.originalpos.x;
|
||||
f.flag->y = (ushort) f.originalpos.y;
|
||||
f.flag->z = (ushort) f.originalpos.z;
|
||||
f.flag->spawned = true;
|
||||
break;
|
||||
};
|
||||
};
|
||||
flagaction(flag, action);
|
||||
break;
|
||||
};
|
||||
|
||||
@@ -207,7 +207,15 @@ void pickup(int n, playerent *d)
|
||||
f.state = CTFF_STOLEN;
|
||||
f.pick_ack = false;
|
||||
}
|
||||
else if(isownflag && f.state == CTFF_INBASE && flaginfos[team_opposite(team)].state == CTFF_STOLEN && flaginfos[team_opposite(team)].actor == d) addmsg(SV_FLAGSCORE, "ri", team_opposite(team));
|
||||
else if(isownflag && f.state == CTFF_INBASE)
|
||||
{
|
||||
flaginfo &ef = flaginfos[team_opposite(team)];
|
||||
if(ef.state == CTFF_STOLEN && ef.actor == d)
|
||||
{
|
||||
addmsg(SV_FLAGSCORE, "ri", team_opposite(team));
|
||||
ef.state = CTFF_INBASE;
|
||||
};
|
||||
};
|
||||
break;
|
||||
};
|
||||
};
|
||||
|
||||
@@ -17,7 +17,7 @@ enum
|
||||
SV_EDITH, SV_EDITT, SV_EDITS, SV_EDITD, SV_EDITE,
|
||||
SV_SENDMAP, SV_RECVMAP, SV_SERVMSG, SV_ITEMLIST, SV_WEAPCHANGE,
|
||||
SV_MODELSKIN,
|
||||
SV_FLAGPICKUP, SV_FLAGDROP, SV_FLAGRETURN, SV_FLAGSCORE, SV_FLAGINFO, SV_FLAGS, //EDIT: AH
|
||||
SV_FLAGPICKUP, SV_FLAGDROP, SV_FLAGRETURN, SV_FLAGSCORE, SV_FLAGRESET, SV_FLAGINFO, SV_FLAGS, //EDIT: AH
|
||||
SV_SETMASTER, SV_SETMASTERLOGIN, SV_MASTERINFO, SV_MASTERCMD,
|
||||
SV_FORCETEAM, SV_AUTOTEAM,
|
||||
SV_PWD,
|
||||
|
||||
+1
-1
@@ -111,7 +111,7 @@ extern playerent *newclient(int cn);
|
||||
extern void timeupdate(int timeremain);
|
||||
extern void fixcamerarange(physent *cam = camera1);
|
||||
extern void respawnself();
|
||||
extern void dropctfflags();
|
||||
extern void dropctfflag();
|
||||
extern void setskin(playerent *pl, int skin);
|
||||
//game mode extras
|
||||
extern void arenarespawn();
|
||||
|
||||
+27
-33
@@ -284,6 +284,11 @@ void sendf(int cn, int chan, const char *format, ...)
|
||||
if(packet->referenceCount==0) enet_packet_destroy(packet);
|
||||
};
|
||||
|
||||
void sendservmsg(char *msg, int client=-1)
|
||||
{
|
||||
sendf(client, 1, "ris", SV_SERVMSG, msg);
|
||||
};
|
||||
|
||||
struct ctfflag
|
||||
{
|
||||
int state;
|
||||
@@ -298,9 +303,9 @@ void sendflaginfo(int flag, int action, int cn = -1)
|
||||
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);
|
||||
putint(p, flag);
|
||||
putint(p, f.state);
|
||||
putint(p, action);
|
||||
if(f.state==CTFF_STOLEN || 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());
|
||||
@@ -309,6 +314,19 @@ void sendflaginfo(int flag, int action, int cn = -1)
|
||||
if(packet->referenceCount==0) enet_packet_destroy(packet);
|
||||
};
|
||||
|
||||
void sendflagreset(uint sender, int flag, int action)
|
||||
{
|
||||
if(!valid_flag(flag)) return;
|
||||
ctfflag &f = ctfflags[flag];
|
||||
if(f.state==CTFF_STOLEN)
|
||||
{
|
||||
f.state = CTFF_INBASE;
|
||||
f.actor_cn = sender;
|
||||
f.lastupdate = lastsec;
|
||||
sendflaginfo(flag, action);
|
||||
};
|
||||
};
|
||||
|
||||
void ctfreset()
|
||||
{
|
||||
loopi(2)
|
||||
@@ -319,11 +337,6 @@ void ctfreset()
|
||||
};
|
||||
};
|
||||
|
||||
void sendservmsg(char *msg, int client=-1)
|
||||
{
|
||||
sendf(client, 1, "ris", SV_SERVMSG, msg);
|
||||
};
|
||||
|
||||
char *disc_reasons[] = { "normal", "end of packet", "client num", "kicked by master", "banned by master", "tag type", "connection refused due to ban", "wrong password", "failed master login", "server FULL (maxclients)", "server mastermode is \"private\"" };
|
||||
|
||||
void disconnect_client(int n, int reason = -1)
|
||||
@@ -750,7 +763,6 @@ void process(ENetPacket *packet, int sender, int chan) // sender may be -1
|
||||
break;
|
||||
};
|
||||
|
||||
// EDIT: AH
|
||||
case SV_FLAGPICKUP:
|
||||
{
|
||||
int flag = getint(p);
|
||||
@@ -797,20 +809,12 @@ void process(ENetPacket *packet, int sender, int chan) // sender may be -1
|
||||
};
|
||||
|
||||
case SV_FLAGSCORE:
|
||||
case SV_FLAGRESET:
|
||||
{
|
||||
int flag = getint(p);
|
||||
if(!valid_flag(flag)) return;
|
||||
ctfflag &f = ctfflags[flag];
|
||||
if(f.state==CTFF_STOLEN)
|
||||
{
|
||||
f.state = CTFF_INBASE;
|
||||
f.actor_cn = sender;
|
||||
f.lastupdate = lastsec;
|
||||
sendflaginfo(flag, SV_FLAGSCORE);
|
||||
};
|
||||
sendflagreset(sender, getint(p), type);
|
||||
break;
|
||||
};
|
||||
|
||||
|
||||
case SV_SETMASTER:
|
||||
{
|
||||
setmaster(sender, getint(p) != 0);
|
||||
@@ -982,20 +986,10 @@ void serverslice(int seconds, unsigned int timeout) // main server update, cal
|
||||
};
|
||||
};
|
||||
|
||||
if(m_ctf)
|
||||
if(m_ctf) loopi(2)
|
||||
{
|
||||
loopi(2)
|
||||
{
|
||||
ctfflag &f = ctfflags[i];
|
||||
if(f.state==CTFF_DROPPED && seconds-f.lastupdate>30)
|
||||
{
|
||||
f.state=CTFF_INBASE;
|
||||
sendflaginfo(i, -1);
|
||||
s_sprintfd(msg)("the server reset the %s flag", team_string(i));
|
||||
sendservmsg(msg);
|
||||
sendf(-1, 1, "rii", SV_SOUND, S_FLAGRETURN);
|
||||
};
|
||||
};
|
||||
ctfflag &f = ctfflags[i];
|
||||
if(f.state==CTFF_DROPPED && seconds-f.lastupdate>30) sendflagreset(0, i, SV_FLAGRESET);
|
||||
};
|
||||
|
||||
lastsec = seconds;
|
||||
|
||||
Reference in New Issue
Block a user