In plyr_save_stats setting filename to size of PATH_MAX to have enough space to also hold the player directory prefix which would otherwise create a memory corruption and crash the game
This commit is contained in:
parent
17a18b5512
commit
88b5205135
|
@ -1,5 +1,9 @@
|
||||||
D1X-Rebirth Changelog
|
D1X-Rebirth Changelog
|
||||||
|
|
||||||
|
20101113
|
||||||
|
--------
|
||||||
|
main/playsave.c: In plyr_save_stats setting filename to size of PATH_MAX to have enough space to also hold the player directory prefix which would otherwise create a memory corruption and crash the game
|
||||||
|
|
||||||
20101109
|
20101109
|
||||||
--------
|
--------
|
||||||
main/multi.c: In multi_consistency_error check for Game_wind before trying to set it in/visible - just for safety
|
main/multi.c: In multi_consistency_error check for Game_wind before trying to set it in/visible - just for safety
|
||||||
|
|
|
@ -410,31 +410,32 @@ void plyr_read_stats()
|
||||||
|
|
||||||
void plyr_save_stats()
|
void plyr_save_stats()
|
||||||
{
|
{
|
||||||
int kills,deaths,neg;
|
int kills = PlayerCfg.NetlifeKills,deaths = PlayerCfg.NetlifeKilled, neg, i;
|
||||||
char filename[14];
|
char filename[PATH_MAX];
|
||||||
unsigned char buf[16],buf2[16],a;
|
unsigned char buf[16],buf2[16],a;
|
||||||
int i;
|
|
||||||
PHYSFS_file *f;
|
PHYSFS_file *f;
|
||||||
kills=0;
|
|
||||||
deaths=0;
|
memset(filename, '\0', PATH_MAX);
|
||||||
|
snprintf(filename, PATH_MAX, GameArg.SysUsePlayersDir?"Players/%s.eff":"%s.eff", Players[Player_num].callsign);
|
||||||
kills=PlayerCfg.NetlifeKills;
|
|
||||||
deaths=PlayerCfg.NetlifeKilled;
|
|
||||||
|
|
||||||
sprintf(filename,GameArg.SysUsePlayersDir?"Players/%s.eff":"%s.eff",Players[Player_num].callsign);
|
|
||||||
f = PHYSFSX_openWriteBuffered(filename);
|
f = PHYSFSX_openWriteBuffered(filename);
|
||||||
|
|
||||||
if(!f)
|
if(!f)
|
||||||
return; //broken!
|
return; //broken!
|
||||||
|
|
||||||
PHYSFSX_printf(f,"kills:%i\n",kills);
|
PHYSFSX_printf(f,"kills:%i\n",kills);
|
||||||
PHYSFSX_printf(f,"deaths:%i\n",deaths);
|
PHYSFSX_printf(f,"deaths:%i\n",deaths);
|
||||||
PHYSFSX_printf(f,"key:01 ");
|
PHYSFSX_printf(f,"key:01 ");
|
||||||
if (kills<0){
|
|
||||||
|
if (kills<0)
|
||||||
|
{
|
||||||
neg=1;
|
neg=1;
|
||||||
kills*=-1;
|
kills*=-1;
|
||||||
}else neg=0;
|
}
|
||||||
for (i=0;kills;i++){
|
else
|
||||||
|
neg=0;
|
||||||
|
|
||||||
|
for (i=0;kills;i++)
|
||||||
|
{
|
||||||
a=(kills & 0xFF) ^ effcode1[i+neg];
|
a=(kills & 0xFF) ^ effcode1[i+neg];
|
||||||
buf[i*2]=(a&0xF)+33;
|
buf[i*2]=(a&0xF)+33;
|
||||||
buf[i*2+1]=(a>>4)+33;
|
buf[i*2+1]=(a>>4)+33;
|
||||||
|
@ -443,17 +444,26 @@ void plyr_save_stats()
|
||||||
buf2[i*2+1]=(a>>4)+33;
|
buf2[i*2+1]=(a>>4)+33;
|
||||||
kills>>=8;
|
kills>>=8;
|
||||||
}
|
}
|
||||||
|
|
||||||
buf[i*2]=0;
|
buf[i*2]=0;
|
||||||
buf2[i*2]=0;
|
buf2[i*2]=0;
|
||||||
if (neg)i+='a';
|
|
||||||
else i+='A';
|
if (neg)
|
||||||
|
i+='a';
|
||||||
|
else
|
||||||
|
i+='A';
|
||||||
|
|
||||||
PHYSFSX_printf(f,"%c%s %c%s ",i,buf,i,buf2);
|
PHYSFSX_printf(f,"%c%s %c%s ",i,buf,i,buf2);
|
||||||
|
|
||||||
if (deaths<0){
|
if (deaths<0)
|
||||||
|
{
|
||||||
neg=1;
|
neg=1;
|
||||||
deaths*=-1;
|
deaths*=-1;
|
||||||
}else neg=0;
|
}else
|
||||||
for (i=0;deaths;i++){
|
neg=0;
|
||||||
|
|
||||||
|
for (i=0;deaths;i++)
|
||||||
|
{
|
||||||
a=(deaths & 0xFF) ^ effcode3[i+neg];
|
a=(deaths & 0xFF) ^ effcode3[i+neg];
|
||||||
buf[i*2]=(a&0xF)+33;
|
buf[i*2]=(a&0xF)+33;
|
||||||
buf[i*2+1]=(a>>4)+33;
|
buf[i*2+1]=(a>>4)+33;
|
||||||
|
@ -462,10 +472,15 @@ void plyr_save_stats()
|
||||||
buf2[i*2+1]=(a>>4)+33;
|
buf2[i*2+1]=(a>>4)+33;
|
||||||
deaths>>=8;
|
deaths>>=8;
|
||||||
}
|
}
|
||||||
|
|
||||||
buf[i*2]=0;
|
buf[i*2]=0;
|
||||||
buf2[i*2]=0;
|
buf2[i*2]=0;
|
||||||
if (neg)i+='a';
|
|
||||||
else i+='A';
|
if (neg)
|
||||||
|
i+='a';
|
||||||
|
else
|
||||||
|
i+='A';
|
||||||
|
|
||||||
PHYSFSX_printf(f,"%c%s %c%s\n",i,buf,i,buf2);
|
PHYSFSX_printf(f,"%c%s %c%s\n",i,buf,i,buf2);
|
||||||
|
|
||||||
PHYSFS_close(f);
|
PHYSFS_close(f);
|
||||||
|
|
Loading…
Reference in a new issue