Fixed issues with stats.dat files loading (bug am41030)
This commit is contained in:
parent
f3a833dd1b
commit
f5414ff8de
|
@ -220,41 +220,59 @@ void RankSystem::updatePos( RankStats* rr , Stats* s )
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Who put these backwards...
|
||||||
|
*/
|
||||||
|
#define TRYREAD(t_var, t_num, t_size, t_file) \
|
||||||
|
if (fread(t_var, t_size, t_num, t_file) != t_num) { \
|
||||||
|
break; \
|
||||||
|
}
|
||||||
|
|
||||||
void RankSystem::loadRank( const char* filename )
|
void RankSystem::loadRank( const char* filename )
|
||||||
{
|
{
|
||||||
FILE *bfp = fopen( filename , "rb" );
|
FILE *bfp = fopen( filename , "rb" );
|
||||||
|
|
||||||
if ( !bfp ) return;
|
if (!bfp)
|
||||||
|
{
|
||||||
|
MF_Log("Could not load csstats file: %s", filename);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
short int i = 0;
|
short int i = 0;
|
||||||
fread(&i, 1 , sizeof(short int) , bfp);
|
if (fread(&i, sizeof(short int), 1, bfp) != 1)
|
||||||
|
{
|
||||||
|
fclose(bfp);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (i == RANK_VERSION)
|
if (i == RANK_VERSION)
|
||||||
{
|
{
|
||||||
Stats d;
|
Stats d;
|
||||||
char unique[64], name[64];
|
char unique[64], name[64];
|
||||||
fread(&i , 1, sizeof(short int), bfp);
|
if (fread(&i, sizeof(short int), 1, bfp) != 1)
|
||||||
|
|
||||||
while( i )
|
|
||||||
{
|
{
|
||||||
fread(name , i,sizeof(char) , bfp);
|
fclose(bfp);
|
||||||
fread(&i , 1, sizeof(short int), bfp);
|
return;
|
||||||
fread(unique , i,sizeof(char) , bfp);
|
}
|
||||||
fread(&d.tks, 1,sizeof(int), bfp);
|
|
||||||
fread(&d.damage, 1,sizeof(int), bfp);
|
|
||||||
fread(&d.deaths, 1,sizeof(int), bfp);
|
|
||||||
fread(&d.kills, 1,sizeof(int), bfp);
|
|
||||||
fread(&d.shots, 1,sizeof(int), bfp);
|
|
||||||
fread(&d.hits, 1,sizeof(int), bfp);
|
|
||||||
fread(&d.hs, 1,sizeof(int), bfp);
|
|
||||||
|
|
||||||
fread(&d.bDefusions, 1,sizeof(int), bfp);
|
while(i && !feof(bfp))
|
||||||
fread(&d.bDefused, 1,sizeof(int), bfp);
|
{
|
||||||
fread(&d.bPlants, 1,sizeof(int), bfp);
|
TRYREAD(name, i, sizeof(char), bfp);
|
||||||
fread(&d.bExplosions, 1,sizeof(int), bfp);
|
TRYREAD(&i, 1, sizeof(short int), bfp);
|
||||||
|
TRYREAD(unique , i, sizeof(char) , bfp);
|
||||||
fread(d.bodyHits, 1,sizeof(d.bodyHits), bfp);
|
TRYREAD(&d.tks, 1, sizeof(int), bfp);
|
||||||
fread(&i , 1, sizeof(short int), bfp);
|
TRYREAD(&d.damage, 1, sizeof(int), bfp);
|
||||||
|
TRYREAD(&d.deaths, 1, sizeof(int), bfp);
|
||||||
|
TRYREAD(&d.kills, 1, sizeof(int), bfp);
|
||||||
|
TRYREAD(&d.shots, 1, sizeof(int), bfp);
|
||||||
|
TRYREAD(&d.hits, 1, sizeof(int), bfp);
|
||||||
|
TRYREAD(&d.hs, 1, sizeof(int), bfp);
|
||||||
|
TRYREAD(&d.bDefusions, 1, sizeof(int), bfp);
|
||||||
|
TRYREAD(&d.bDefused, 1, sizeof(int), bfp);
|
||||||
|
TRYREAD(&d.bPlants, 1, sizeof(int), bfp);
|
||||||
|
TRYREAD(&d.bExplosions, 1, sizeof(int), bfp);
|
||||||
|
TRYREAD(d.bodyHits, 1, sizeof(d.bodyHits), bfp);
|
||||||
|
TRYREAD(&i, 1, sizeof(short int), bfp);
|
||||||
|
|
||||||
RankSystem::RankStats* a = findEntryInRank( unique , name );
|
RankSystem::RankStats* a = findEntryInRank( unique , name );
|
||||||
|
|
||||||
|
|
|
@ -232,36 +232,57 @@ void RankSystem::updatePos( RankStats* rr , Stats* s )
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Who put these backwards...
|
||||||
|
*/
|
||||||
|
#define TRYREAD(t_var, t_num, t_size, t_file) \
|
||||||
|
if (fread(t_var, t_size, t_num, t_file) != t_num) { \
|
||||||
|
break; \
|
||||||
|
}
|
||||||
|
|
||||||
void RankSystem::loadRank(const char* filename)
|
void RankSystem::loadRank(const char* filename)
|
||||||
{
|
{
|
||||||
FILE *bfp = fopen(filename , "rb");
|
FILE *bfp = fopen(filename , "rb");
|
||||||
|
|
||||||
if ( !bfp ) return;
|
if (!bfp)
|
||||||
|
{
|
||||||
|
MF_Log("Could not load stats file: %s", filename);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
short int i = 0;
|
short int i = 0;
|
||||||
fread(&i, 1 , sizeof(short int) , bfp);
|
if (!fread(&i, sizeof(short int), 1, bfp) != 1)
|
||||||
|
{
|
||||||
|
fclose(bfp);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
if (i == RANK_VERSION)
|
if (i == RANK_VERSION)
|
||||||
{
|
{
|
||||||
Stats d;
|
Stats d;
|
||||||
char unique[64], name[64];
|
char unique[64], name[64];
|
||||||
fread(&i , 1, sizeof(short int), bfp);
|
if (fread(&i, sizeof(short int), 1, bfp) != 1)
|
||||||
|
|
||||||
while( i )
|
|
||||||
{
|
{
|
||||||
fread(name , i,sizeof(char) , bfp);
|
fclose(bfp);
|
||||||
fread(&i , 1, sizeof(short int), bfp);
|
return;
|
||||||
fread(unique , i,sizeof(char) , bfp);
|
}
|
||||||
fread(&d.tks, 1,sizeof(int), bfp);
|
|
||||||
fread(&d.damage, 1,sizeof(int), bfp);
|
while(i && !feof(bfp))
|
||||||
fread(&d.deaths, 1,sizeof(int), bfp);
|
{
|
||||||
fread(&d.kills, 1,sizeof(int), bfp);
|
TRYREAD(name, i, sizeof(char), bfp);
|
||||||
fread(&d.shots, 1,sizeof(int), bfp);
|
TRYREAD(&i, 1, sizeof(short int), bfp);
|
||||||
fread(&d.hits, 1,sizeof(int), bfp);
|
TRYREAD(unique, i, sizeof(char) , bfp);
|
||||||
fread(&d.hs, 1,sizeof(int), bfp);
|
TRYREAD(&d.tks, 1, sizeof(int), bfp);
|
||||||
fread(&d.points, 1,sizeof(int), bfp);
|
TRYREAD(&d.damage, 1, sizeof(int), bfp);
|
||||||
fread(d.bodyHits, 1,sizeof(d.bodyHits), bfp);
|
TRYREAD(&d.deaths, 1, sizeof(int), bfp);
|
||||||
fread(&i , 1, sizeof(short int), bfp);
|
TRYREAD(&d.kills, 1, sizeof(int), bfp);
|
||||||
|
TRYREAD(&d.shots, 1, sizeof(int), bfp);
|
||||||
|
TRYREAD(&d.hits, 1, sizeof(int), bfp);
|
||||||
|
TRYREAD(&d.hs, 1, sizeof(int), bfp);
|
||||||
|
TRYREAD(&d.points, 1, sizeof(int), bfp);
|
||||||
|
TRYREAD(d.bodyHits, 1, sizeof(d.bodyHits), bfp);
|
||||||
|
TRYREAD(&i, 1, sizeof(short int), bfp);
|
||||||
|
|
||||||
RankSystem::RankStats* a = findEntryInRank( unique , name );
|
RankSystem::RankStats* a = findEntryInRank( unique , name );
|
||||||
if ( a ) a->updatePosition( &d );
|
if ( a ) a->updatePosition( &d );
|
||||||
|
|
|
@ -229,35 +229,56 @@ void RankSystem::updatePos( RankStats* rr , Stats* s )
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Who put these backwards...
|
||||||
|
*/
|
||||||
|
#define TRYREAD(t_var, t_num, t_size, t_file) \
|
||||||
|
if (fread(t_var, t_size, t_num, t_file) != t_num) { \
|
||||||
|
break; \
|
||||||
|
}
|
||||||
|
|
||||||
void RankSystem::loadRank(const char* filename)
|
void RankSystem::loadRank(const char* filename)
|
||||||
{
|
{
|
||||||
FILE *bfp = fopen(filename , "rb");
|
FILE *bfp = fopen(filename , "rb");
|
||||||
|
|
||||||
if ( !bfp ) return;
|
if (!bfp)
|
||||||
|
{
|
||||||
|
MF_Log("Could not load stats file: %s", filename);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
short int i = 0;
|
short int i = 0;
|
||||||
fread(&i, 1 , sizeof(short int) , bfp);
|
if (fread(&i, sizeof(short int), 1, bfp) != 1)
|
||||||
|
{
|
||||||
|
fclose(bfp);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (i == RANK_VERSION)
|
if (i == RANK_VERSION)
|
||||||
{
|
{
|
||||||
Stats d;
|
Stats d;
|
||||||
char unique[64], name[64];
|
char unique[64], name[64];
|
||||||
fread(&i , 1, sizeof(short int), bfp);
|
if (fread(&i, sizeof(short int), 1, bfp) != 1)
|
||||||
|
|
||||||
while( i )
|
|
||||||
{
|
{
|
||||||
fread(name , i,sizeof(char) , bfp);
|
fclose(bfp);
|
||||||
fread(&i , 1, sizeof(short int), bfp);
|
return;
|
||||||
fread(unique , i,sizeof(char) , bfp);
|
}
|
||||||
fread(&d.tks, 1,sizeof(int), bfp);
|
|
||||||
fread(&d.damage, 1,sizeof(int), bfp);
|
while(i && !feof(bfp))
|
||||||
fread(&d.deaths, 1,sizeof(int), bfp);
|
{
|
||||||
fread(&d.kills, 1,sizeof(int), bfp);
|
TRYREAD(name, i, sizeof(char), bfp);
|
||||||
fread(&d.shots, 1,sizeof(int), bfp);
|
TRYREAD(&i, 1, sizeof(short int), bfp);
|
||||||
fread(&d.hits, 1,sizeof(int), bfp);
|
TRYREAD(unique, i, sizeof(char), bfp);
|
||||||
fread(&d.hs, 1,sizeof(int), bfp);
|
TRYREAD(&d.tks, 1, sizeof(int), bfp);
|
||||||
fread(d.bodyHits, 1,sizeof(d.bodyHits), bfp);
|
TRYREAD(&d.damage, 1, sizeof(int), bfp);
|
||||||
fread(&i , 1, sizeof(short int), bfp);
|
TRYREAD(&d.deaths, 1, sizeof(int), bfp);
|
||||||
|
TRYREAD(&d.kills, 1, sizeof(int), bfp);
|
||||||
|
TRYREAD(&d.shots, 1, sizeof(int), bfp);
|
||||||
|
TRYREAD(&d.hits, 1, sizeof(int), bfp);
|
||||||
|
TRYREAD(&d.hs, 1, sizeof(int), bfp);
|
||||||
|
TRYREAD(d.bodyHits, 1, sizeof(d.bodyHits), bfp);
|
||||||
|
TRYREAD(&i, 1, sizeof(short int), bfp);
|
||||||
|
|
||||||
RankSystem::RankStats* a = findEntryInRank( unique , name );
|
RankSystem::RankStats* a = findEntryInRank( unique , name );
|
||||||
if ( a ) a->updatePosition( &d );
|
if ( a ) a->updatePosition( &d );
|
||||||
|
|
|
@ -229,35 +229,55 @@ void RankSystem::updatePos( RankStats* rr , Stats* s )
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Who put these backwards...
|
||||||
|
*/
|
||||||
|
#define TRYREAD(t_var, t_num, t_size, t_file) \
|
||||||
|
if (fread(t_var, t_size, t_num, t_file) != t_num) { \
|
||||||
|
break; \
|
||||||
|
}
|
||||||
|
|
||||||
void RankSystem::loadRank(const char* filename)
|
void RankSystem::loadRank(const char* filename)
|
||||||
{
|
{
|
||||||
FILE *bfp = fopen(filename , "rb");
|
FILE *bfp = fopen(filename , "rb");
|
||||||
|
|
||||||
if ( !bfp ) return;
|
if (!bfp)
|
||||||
|
{
|
||||||
|
MF_Log("Could not load stats file: %s", filename);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
short int i = 0;
|
short int i = 0;
|
||||||
fread(&i, 1 , sizeof(short int) , bfp);
|
if (fread(&i, sizeof(short int), 1, bfp) != 1)
|
||||||
|
{
|
||||||
|
fclose(bfp);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (i == RANK_VERSION)
|
if (i == RANK_VERSION)
|
||||||
{
|
{
|
||||||
Stats d;
|
Stats d;
|
||||||
char unique[64], name[64];
|
char unique[64], name[64];
|
||||||
fread(&i , 1, sizeof(short int), bfp);
|
if (fread(&i, sizeof(short int), 1, bfp) != 1)
|
||||||
|
|
||||||
while( i )
|
|
||||||
{
|
{
|
||||||
fread(name , i,sizeof(char) , bfp);
|
fclose(bfp);
|
||||||
fread(&i , 1, sizeof(short int), bfp);
|
return;
|
||||||
fread(unique , i,sizeof(char) , bfp);
|
}
|
||||||
fread(&d.tks, 1,sizeof(int), bfp);
|
|
||||||
fread(&d.damage, 1,sizeof(int), bfp);
|
while(i && !feof(bfp))
|
||||||
fread(&d.deaths, 1,sizeof(int), bfp);
|
{
|
||||||
fread(&d.kills, 1,sizeof(int), bfp);
|
TRYREAD(name, i, sizeof(char), bfp);
|
||||||
fread(&d.shots, 1,sizeof(int), bfp);
|
TRYREAD(&i, 1, sizeof(short int), bfp);
|
||||||
fread(&d.hits, 1,sizeof(int), bfp);
|
TRYREAD(unique, i, sizeof(char), bfp);
|
||||||
fread(&d.hs, 1,sizeof(int), bfp);
|
TRYREAD(&d.tks, 1, sizeof(int), bfp);
|
||||||
fread(d.bodyHits, 1,sizeof(d.bodyHits), bfp);
|
TRYREAD(&d.damage, 1, sizeof(int), bfp);
|
||||||
fread(&i , 1, sizeof(short int), bfp);
|
TRYREAD(&d.deaths, 1, sizeof(int), bfp);
|
||||||
|
TRYREAD(&d.kills, 1, sizeof(int), bfp);
|
||||||
|
TRYREAD(&d.shots, 1, sizeof(int), bfp);
|
||||||
|
TRYREAD(&d.hits, 1, sizeof(int), bfp);
|
||||||
|
TRYREAD(&d.hs, 1, sizeof(int), bfp);
|
||||||
|
TRYREAD(d.bodyHits, 1, sizeof(d.bodyHits), bfp);
|
||||||
|
TRYREAD(&i, 1, sizeof(short int), bfp);
|
||||||
|
|
||||||
RankSystem::RankStats* a = findEntryInRank( unique , name );
|
RankSystem::RankStats* a = findEntryInRank( unique , name );
|
||||||
if ( a ) a->updatePosition( &d );
|
if ( a ) a->updatePosition( &d );
|
||||||
|
|
Loading…
Reference in New Issue
Block a user