diff --git a/geometry.cpp b/geometry.cpp index 0e115431..60666931 100644 --- a/geometry.cpp +++ b/geometry.cpp @@ -524,8 +524,8 @@ hpcshape /** contains the texture point coordinates for 3D models */ basic_textureinfo models_texture; - - geometry_information() { last = NULL; } + + geometry_information() { last = NULL; use_count = 0; } void require_basics() { if(state & 1) return; state |= 1; prepare_basics(); } void require_shapes() { if(state & 2) return; state |= 2; prepare_shapes(); } @@ -535,6 +535,9 @@ hpcshape hpcshape& generate_pipe(ld length, ld width, ePipeEnd endtype = ePipeEnd::sharp); map> ext; + + /** prevent from being destroyed */ + int use_count; }; #endif @@ -1238,9 +1241,11 @@ EX void check_cgi() { if(arcm::alt_cgip) arcm::alt_cgip->timestamp = ntimestamp; #endif - if(isize(cgis) > 4 && IFINTRA(intra::data.empty(), true)) { + int limit = 4; + for(auto& t: cgis) if(t.second.use_count) limit++; + if(isize(cgis) > limit) { vector> timestamps; - for(auto& t: cgis) timestamps.emplace_back(-t.second.timestamp, t.first); + for(auto& t: cgis) if(!t.second.use_count) timestamps.emplace_back(-t.second.timestamp, t.first); sort(timestamps.begin(), timestamps.end()); while(isize(timestamps) > 4) { DEBB(DF_GEOM, ("erasing geometry ", timestamps.back().second)); diff --git a/multigame.cpp b/multigame.cpp index e5bd98e0..ecfca214 100644 --- a/multigame.cpp +++ b/multigame.cpp @@ -60,8 +60,14 @@ void gamedata_all(gamedata& gd) { gd.store(land_structure); gd.store(*current_display); gd.store(cgip); + if(gd.mode == 0) cgip->use_count++; + if(gd.mode != 0) cgip->use_count--; gd.store(hybrid::underlying); gd.store(hybrid::csteps); + if(hybri && hybrid::underlying_cgip) { + if(gd.mode == 0) hybrid::underlying_cgip->use_count++; + if(gd.mode != 0) hybrid::underlying_cgip->use_count--; + } gd.store(hybrid::underlying_cgip); gd.store_ptr(vid.projection_config); gd.store_ptr(vid.rug_config);