void ServerClass::SaveStat() {
FILE* fil;
fil = fopen("stat.dat", "wb");
if (fil == NULL) return;
std::vector<PlayerStat>::iterator it;
PlayerStat* tps;
tps = (PlayerStat*)calloc(1, sizeof(PlayerStat));
for (it = PS.begin(); it != PS.end(); it++) {
if (it->Name[0] != 0) {
strcpy(tps->Name, it->Name);
tps->Rating_All = it->Rating_All;
tps->Wins_All = it->Wins_All;
tps->Loses_All = it->Loses_All;
tps->Disc_All = it->Disc_All;
tps->REP_All = it->REP_All;
tps->OppsREP_All = it->OppsREP_All;
tps->OppsRating_All = it->OppsRating_All;
tps->Rating_Circ = it->Rating_Circ;
tps->Wins_Circ = it->Wins_Circ;
tps->Loses_Circ = it->Loses_Circ;
tps->Disc_Circ = it->Disc_Circ;
tps->REP_Circ = it->REP_Circ;
tps->OppsREP_Circ = it->OppsREP_Circ;
tps->OppsRating_Circ = it->OppsRating_Circ;
tps->Rating_Sprint = it->Rating_Sprint;
tps->Wins_Sprint = it->Wins_Sprint;
tps->Loses_Sprint = it->Loses_Sprint;
tps->Disc_Sprint = it->Disc_Sprint;
tps->REP_Sprint = it->REP_Sprint;
tps->OppsREP_Sprint = it->OppsREP_Sprint;
tps->OppsRating_Sprint = it->OppsRating_Sprint;
tps->Rating_Drag = it->Rating_Drag;
tps->Wins_Drag = it->Wins_Drag;
tps->Loses_Drag = it->Loses_Drag;
tps->Disc_Drag = it->Disc_Drag;
tps->REP_Drag = it->REP_Drag;
tps->OppsREP_Drag = it->OppsREP_Drag;
tps->OppsRating_Drag = it->OppsRating_Drag;
tps->Rating_Drift = it->Rating_Drift;
tps->Wins_Drift = it->Wins_Drift;
tps->Loses_Drift = it->Loses_Drift;
tps->Disc_Drift = it->Disc_Drift;
tps->REP_Drift = it->REP_Drift;
tps->OppsREP_Drift = it->OppsREP_Drift;
tps->OppsRating_Drift = it->OppsRating_Drift;
fwrite(tps, 1, sizeof(PlayerStat), fil);
}
}
fclose(fil);
};
void ServerClass::LoadStat() {
FILE* fil;
fil = fopen("stat.dat", "rb");
if (fil == NULL) return;
PlayerStat* tps;
while (!feof(fil)) {
tps = (PlayerStat*)calloc(1, sizeof(PlayerStat));
fread(tps, 1, sizeof(PlayerStat), fil);
if (tps->Name[0] != 0) {
PS.push_back(PlayerStat(tps->Name,
tps->Rating_All, tps->Wins_All, tps->Loses_All, tps->Disc_All, tps->REP_All, tps->OppsREP_All, tps->OppsRating_All,
tps->Rating_Circ, tps->Wins_Circ, tps->Loses_Circ, tps->Disc_Circ, tps->REP_Circ, tps->OppsREP_Circ, tps->OppsRating_Circ,
tps->Rating_Sprint, tps->Wins_Sprint, tps->Loses_Sprint, tps->Disc_Sprint, tps->REP_Sprint, tps->OppsREP_Sprint, tps->OppsRating_Sprint,
tps->Rating_Drag, tps->Wins_Drag, tps->Loses_Drag, tps->Disc_Drag, tps->REP_Drag, tps->OppsREP_Drag, tps->OppsRating_Drag,
tps->Rating_Drift, tps->Wins_Drift, tps->Loses_Drift, tps->Disc_Drift, tps->REP_Drift, tps->OppsREP_Drift, tps->OppsRating_Drift));
}
}
fclose(fil);
};
struct PlayerStat {
char Name[16];
int Rating_All;
int Wins_All;
int Loses_All;
int Disc_All;
int REP_All;
int OppsREP_All; // average opponents REP
int OppsRating_All; // average opponents Rating
int Rating_Circ;
int Wins_Circ;
int Loses_Circ;
int Disc_Circ;
int REP_Circ;
int OppsREP_Circ;
int OppsRating_Circ;
int Rating_Sprint;
int Wins_Sprint;
int Loses_Sprint;
int Disc_Sprint;
int REP_Sprint;
int OppsREP_Sprint;
int OppsRating_Sprint;
int Rating_Drag;
int Wins_Drag;
int Loses_Drag;
int Disc_Drag;
int REP_Drag;
int OppsREP_Drag;
int OppsRating_Drag;
int Rating_Drift;
int Wins_Drift;
int Loses_Drift;
int Disc_Drift;
int REP_Drift;
int OppsREP_Drift;
int OppsRating_Drift;
<?php
$file = fopen("stat.dat", "rb");
$seq = fread($file, 4);
echo $seq;
while(!feof($file)){
fseek($file, 4, SEEK_CUR);
$seq = fread($file, 4);
echo $seq."<br>";
}
fclose($file);