saving the points and sending to the clients (not the best way to send the data yet)

git-svn-id: svn://svn.code.sf.net/p/actiongame/code/trunk/ac@5107 e016b1c5-ed68-44aa-a2f7-31cac88cffde
This commit is contained in:
Rafael Barreto
2010-05-30 02:54:14 +00:00
parent 1877c8ec53
commit 3d78333df0
4 changed files with 27 additions and 23 deletions
+11 -11
View File
@@ -458,14 +458,14 @@ void parsemessages(int cn, playerent *d, ucharbuf &p)
conoutf(_("connected: %s"), colorname(d, text));
}
copystring(d->name, text, MAXNAMELEN+1);
loopi(2) d->setskin(i, getint(p));
loopi(2) d->setskin(i, getint(p));
d->team = getint(p);
if(m_flags) loopi(2)
{
flaginfo &f = flaginfos[i];
if(!f.actor) f.actor = getclient(f.actor_cn);
}
updateclientname(d);
if(m_flags) loopi(2)
{
flaginfo &f = flaginfos[i];
if(!f.actor) f.actor = getclient(f.actor_cn);
}
updateclientname(d);
break;
}
@@ -474,7 +474,7 @@ void parsemessages(int cn, playerent *d, ucharbuf &p)
int cn = getint(p);
playerent *d = getclient(cn);
if(!d) break;
if(d->name[0]) conoutf(_("player %s disconnected"), colorname(d));
if(d->name[0]) conoutf(_("player %s disconnected"), colorname(d));
zapplayer(players[cn]);
break;
}
@@ -624,7 +624,7 @@ void parsemessages(int cn, playerent *d, ucharbuf &p)
break;
}
case SV_POINTS:
case SV_POINTS:
{
int count = getint(p);
loopi(count){
@@ -632,7 +632,6 @@ void parsemessages(int cn, playerent *d, ucharbuf &p)
playerent *ppl = pcn == getclientnum() ? player1 : getclient(pcn);
if (!ppl) break;
ppl->points = score;
// printf("POINTS RECEIVED: %s %d\n",ppl->name,score);
}
break;
}
@@ -672,7 +671,7 @@ void parsemessages(int cn, playerent *d, ucharbuf &p)
{
int cn = getint(p);
if(p.overread() || cn<0) break;
int state = getint(p), lifesequence = getint(p), primary = getint(p), gunselect = getint(p), flagscore = getint(p), frags = getint(p), deaths = getint(p), health = getint(p), armour = getint(p);
int state = getint(p), lifesequence = getint(p), primary = getint(p), gunselect = getint(p), flagscore = getint(p), frags = getint(p), deaths = getint(p), health = getint(p), armour = getint(p), points = getint(p);
int ammo[NUMGUNS], mag[NUMGUNS];
loopi(NUMGUNS) ammo[i] = getint(p);
loopi(NUMGUNS) mag[i] = getint(p);
@@ -683,6 +682,7 @@ void parsemessages(int cn, playerent *d, ucharbuf &p)
d->flagscore = flagscore;
d->frags = frags;
d->deaths = deaths;
d->points = points;
if(d!=player1)
{
d->setprimary(primary);
+4 -2
View File
@@ -373,7 +373,7 @@ void sendextras()
loopi(count)
{
client &c = *clients[*v];
putint(p,c.clientnum); putint(p,c.md.points); c.md.updated = false; c.md.upmillis = 0;
putint(p,c.clientnum); putint(p,c.state.points); c.md.updated = false; c.md.upmillis = 0;
v++;
}
@@ -2000,7 +2000,7 @@ void sendwhois(int sender, int cn)
void sendresume(client &c, bool broadcast)
{
sendf(broadcast ? -1 : c.clientnum, 1, "ri2i9vvi", SV_RESUME,
sendf(broadcast ? -1 : c.clientnum, 1, "ri3i9vvi", SV_RESUME,
c.clientnum,
c.state.state,
c.state.lifesequence,
@@ -2011,6 +2011,7 @@ void sendresume(client &c, bool broadcast)
c.state.deaths,
c.state.health,
c.state.armour,
c.state.points,
NUMGUNS, c.state.ammo,
NUMGUNS, c.state.mag,
-1);
@@ -2120,6 +2121,7 @@ void welcomepacket(packetbuf &p, int n)
putint(p, c.state.deaths);
putint(p, c.state.health);
putint(p, c.state.armour);
putint(p, c.state.points);
loopi(NUMGUNS) putint(p, c.state.ammo[i]);
loopi(NUMGUNS) putint(p, c.state.mag[i]);
}
+8 -6
View File
@@ -123,7 +123,7 @@ struct clientstate : playerstate
projectilestate<8> grenades;
int akimbomillis;
bool scoped;
int flagscore, frags, teamkills, deaths, shotdamage, damage;
int flagscore, frags, teamkills, deaths, shotdamage, damage, points;
clientstate() : state(CS_DEAD) {}
@@ -146,7 +146,7 @@ struct clientstate : playerstate
grenades.reset();
akimbomillis = 0;
scoped = false;
flagscore = frags = teamkills = deaths = shotdamage = damage = 0;
flagscore = frags = teamkills = deaths = shotdamage = damage = points = 0;
respawn();
}
@@ -167,7 +167,7 @@ struct savedscore
{
string name;
uint ip;
int frags, flagscore, deaths, teamkills, shotdamage, damage, team;
int frags, flagscore, deaths, teamkills, shotdamage, damage, team, points;
bool valid;
void save(clientstate &cs, int t)
@@ -178,6 +178,7 @@ struct savedscore
teamkills = cs.teamkills;
shotdamage = cs.shotdamage;
damage = cs.damage;
points = cs.points;
team = t;
valid = true;
}
@@ -190,17 +191,18 @@ struct savedscore
cs.teamkills = teamkills;
cs.shotdamage = shotdamage;
cs.damage = damage;
cs.points = points;
}
};
struct medals
{
int points, lasthit, lastgun, combohits, combo, combotime, combodamage, ncombos, ncovers, nhs;
int dp, lasthit, lastgun, combohits, combo, combotime, combodamage, ncombos, ncovers, nhs;
int ask, askmillis, linked, linkmillis, linkreason, upmillis;
bool updated, combosend;
void reset()
{
points = lasthit = lastgun = combohits = combo = combotime = combodamage = ncombos = ncovers = nhs = 0;
dp = lasthit = lastgun = combohits = combo = combotime = combodamage = ncombos = ncovers = nhs = 0;
askmillis = linkmillis = upmillis = 0;
linkreason = linked = ask = -1;
updated = combosend = false;
@@ -378,7 +380,7 @@ const char *messagenames[SV_NUM] =
"SV_SWITCHNAME", "SV_SWITCHSKIN", "SV_SWITCHTEAM",
"SV_CLIENT",
"SV_EXTENSION",
"SV_MAPIDENT", "SV_HUDEXTRAS"
"SV_MAPIDENT", "SV_HUDEXTRAS", "SV_POINTS"
};
const char *entnames[MAXENTTYPES] =
+4 -4
View File
@@ -83,7 +83,7 @@ This part is related to medals system. WIP
*/
inline void addpt(client *c, int points) {
c->md.points += points;
c->state.points += points;
c->md.updated = true;
c->md.upmillis = gamemillis + 200;
}
@@ -296,8 +296,8 @@ void checkfrag (client *target, client *actor, int gun, bool gib)
if(!isteam(target->team, actor->team)) {
if (m_teammode) {
if(!m_flags) addpt(actor, 5 * target->md.points / 100);
else addpt(actor, 4 * target->md.points / 100);
if(!m_flags) addpt(actor, 5 * target->state.points / 100);
else addpt(actor, 4 * target->state.points / 100);
checkcover (target, actor);
if ( m_htf && actorhasflag >= 0 ) addpt(actor, clientnumber);
@@ -307,7 +307,7 @@ void checkfrag (client *target, client *actor, int gun, bool gib)
if ( m_htf ) addpt(target, -1 * clientnumber);
}
}
else addpt(actor, 3 * target->md.points / 100);
else addpt(actor, 3 * target->state.points / 100);
if (gib) {
if ( gun == GUN_GRENADE ) addpt(actor, 10);