1
0
mirror of https://github.com/zenorogue/hyperrogue.git synced 2025-02-01 03:39:16 +00:00

fixup cgi timestamps

This commit is contained in:
Zeno Rogue 2019-06-18 16:16:09 +02:00
parent 99aeb04185
commit c289345c79

View File

@ -434,6 +434,8 @@ map<string, geometry_information> cgis;
int last_texture_step; int last_texture_step;
int ntimestamp;
void check_cgi() { void check_cgi() {
string s; string s;
auto V = [&] (string a, string b) { s += a; s += ": "; s += b; s += "; "; }; auto V = [&] (string a, string b) { s += a; s += ": "; s += b; s += "; "; };
@ -475,13 +477,14 @@ void check_cgi() {
V("LQ", its(vid.linequality)); V("LQ", its(vid.linequality));
cgip = &cgis[s]; cgip = &cgis[s];
cgi.timestamp = ++ntimestamp;
if(isize(cgis) > 2) { if(isize(cgis) > 4) {
cgi.timestamp = ticks; cgi.timestamp = ticks;
vector<pair<int, string>> timestamps; vector<pair<int, string>> timestamps;
for(auto& t: cgis) timestamps.emplace_back(-t.second.timestamp, t.first); for(auto& t: cgis) timestamps.emplace_back(-t.second.timestamp, t.first);
sort(timestamps.begin(), timestamps.end()); sort(timestamps.begin(), timestamps.end());
while(isize(timestamps) > 2) { while(isize(timestamps) > 4) {
println(hlog, "erasing geometry ", timestamps.back().second); println(hlog, "erasing geometry ", timestamps.back().second);
cgis.erase(timestamps.back().second); cgis.erase(timestamps.back().second);
timestamps.pop_back(); timestamps.pop_back();