1
0
mirror of https://github.com/zenorogue/hyperrogue.git synced 2024-12-29 19:40:35 +00:00

illegal ghosts are now cleared after the race, not before

This commit is contained in:
Zeno Rogue 2019-01-14 23:00:03 +01:00
parent 20f7e8ff6d
commit 6cea3c7378

View File

@ -613,20 +613,6 @@ void generate_track() {
track_ready = true;
race_checksum = hrand(1000000);
auto& gh = ghostset() [specialland];
int ngh = 0;
for(int i=0; i<isize(gh); i++) {
if(gh[i].checksum != race_checksum) {
println(hlog, format("wrong checksum: %x, should be %x", gh[i].checksum, race_checksum));
}
else {
if(i != ngh)
gh[ngh] = move(gh[i]);
ngh++;
}
}
gh.resize(ngh);
race_start_tick = 0;
for(int i=0; i<MAXPLAYER; i++) race_finish_tick[i] = 0;
@ -1157,6 +1143,19 @@ void race_won() {
auto &subtrack = ghostset() [specialland];
int ngh = 0;
for(int i=0; i<isize(subtrack); i++) {
if(subtrack[i].checksum != race_checksum) {
println(hlog, format("wrong checksum: %x, should be %x", subtrack[i].checksum, race_checksum));
}
else {
if(i != ngh)
subtrack[ngh] = move(subtrack[i]);
ngh++;
}
}
subtrack.resize(ngh);
subtrack.emplace_back(ghost{gcs, result, race_checksum, time(NULL), current_history[current_player]});
sort(subtrack.begin(), subtrack.end(), [] (const ghost &g1, const ghost &g2) { return g1.result < g2.result; });
if(isize(subtrack) > ghosts_to_save && ghosts_to_save > 0)