diff --git a/computer.cpp b/computer.cpp index bbd849f5af250..4541dc72a4b93 100644 --- a/computer.cpp +++ b/computer.cpp @@ -441,7 +441,7 @@ void computer::activate_function(game *g, computer_action action) tmp_om = g->cur_om; g->cur_om = overmap(g, tmp_om.posx, tmp_om.posy, level); tinymap tmpmap(&g->itypes, &g->mapitems, &g->traps); - tmpmap.load(g, g->levx, g->levy); + tmpmap.load(g, g->levx, g->levy, false); tmpmap.translate(t_missile, t_hole); tmpmap.save(&tmp_om, g->turn, g->levx, g->levy); } diff --git a/game.cpp b/game.cpp index 5c24611dd2dc9..5a116e25c299b 100644 --- a/game.cpp +++ b/game.cpp @@ -540,7 +540,7 @@ bool game::do_turn() for (int i = 0; i < z.size(); i++) { if (z[i].spawnmapx != -1) { // Static spawn, move them back there tinymap tmp(&itypes, &mapitems, &traps); - tmp.load(this, z[i].spawnmapx, z[i].spawnmapy); + tmp.load(this, z[i].spawnmapx, z[i].spawnmapy, false); tmp.add_spawn(&(z[i])); tmp.save(&cur_om, turn, z[i].spawnmapx, z[i].spawnmapy); } else { // Absorb them back into a group @@ -6388,7 +6388,7 @@ void game::vertical_move(int movez, bool force) //m.save(&cur_om, turn, levx, levy); cur_om = overmap(this, cur_om.posx, cur_om.posy, cur_om.posz + movez); map tmpmap(&itypes, &mapitems, &traps); - tmpmap.load(this, levx, levy); + tmpmap.load(this, levx, levy, false); cur_om = overmap(this, cur_om.posx, cur_om.posy, original_z); // Find the corresponding staircase int stairx = -1, stairy = -1; @@ -6447,12 +6447,12 @@ void game::vertical_move(int movez, bool force) coming_to_stairs.push_back( monster_and_count(z[i], 1 + turns) ); } else if (z[i].spawnmapx != -1) { // Static spawn, move them back there tinymap tmp(&itypes, &mapitems, &traps); - tmp.load(this, z[i].spawnmapx, z[i].spawnmapy); + tmp.load(this, z[i].spawnmapx, z[i].spawnmapy, false); tmp.add_spawn(&(z[i])); tmp.save(&cur_om, turn, z[i].spawnmapx, z[i].spawnmapy); } else if (z[i].friendly < 0) { // Friendly, make it into a static spawn tinymap tmp(&itypes, &mapitems, &traps); - tmp.load(this, levx, levy); + tmp.load(this, levx, levy, false); int spawnx = z[i].posx, spawny = z[i].posy; while (spawnx < 0) spawnx += SEEX; @@ -6593,7 +6593,7 @@ void game::update_map(int &x, int &y) // Despawn; we're out of bounds if (z[i].spawnmapx != -1) { // Static spawn, move them back there map tmp(&itypes, &mapitems, &traps); - tmp.load(this, z[i].spawnmapx, z[i].spawnmapy); + tmp.load(this, z[i].spawnmapx, z[i].spawnmapy, false); tmp.add_spawn(&(z[i])); tmp.save(&cur_om, turn, z[i].spawnmapx, z[i].spawnmapy); } else { // Absorb them back into a group @@ -7209,7 +7209,7 @@ void game::nuke(int x, int y) return; int mapx = x * 2, mapy = y * 2; map tmpmap(&itypes, &mapitems, &traps); - tmpmap.load(this, mapx, mapy); + tmpmap.load(this, mapx, mapy, false); for (int i = 0; i < SEEX * 2; i++) { for (int j = 0; j < SEEY * 2; j++) { if (!one_in(10)) diff --git a/map.cpp b/map.cpp index 9c33f0020e0ae..c132461c0c493 100644 --- a/map.cpp +++ b/map.cpp @@ -2184,12 +2184,12 @@ void map::save(overmap *om, unsigned int turn, int x, int y) } } -void map::load(game *g, int wx, int wy) +void map::load(game *g, int wx, int wy, bool update_vehicle) { for (int gridx = 0; gridx < my_MAPSIZE; gridx++) { for (int gridy = 0; gridy < my_MAPSIZE; gridy++) { if (!loadn(g, wx, wy, gridx, gridy)) - loadn(g, wx, wy, gridx, gridy); + loadn(g, wx, wy, gridx, gridy, update_vehicle); } } } @@ -2304,7 +2304,7 @@ void map::saven(overmap *om, unsigned int turn, int worldx, int worldy, // 0,0 1,0 2,0 // 0,1 1,1 2,1 // 0,2 1,2 2,2 etc -bool map::loadn(game *g, int worldx, int worldy, int gridx, int gridy) +bool map::loadn(game *g, int worldx, int worldy, int gridx, int gridy, bool update_vehicles) { int absx = g->cur_om.posx * OMAPX * 2 + worldx + gridx, absy = g->cur_om.posy * OMAPY * 2 + worldy + gridy, @@ -2312,7 +2312,7 @@ bool map::loadn(game *g, int worldx, int worldy, int gridx, int gridy) submap *tmpsub = MAPBUFFER.lookup_submap(absx, absy, g->cur_om.posz); if (tmpsub) { grid[gridn] = tmpsub; - for (int i = 0; i < grid[gridn]->vehicles.size(); i++) { + for (int i = 0; update_vehicles && i < grid[gridn]->vehicles.size(); i++) { grid[gridn]->vehicles[i].smx = gridx; grid[gridn]->vehicles[i].smy = gridy; } @@ -2339,9 +2339,8 @@ void map::copy_grid(int to, int from) { grid[to] = grid[from]; for (int i = 0; i < grid[to]->vehicles.size(); i++) { - int ind = grid[to]->vehicles.size() - 1; - grid[to]->vehicles[ind].smx = to % my_MAPSIZE; - grid[to]->vehicles[ind].smy = to / my_MAPSIZE; + grid[to]->vehicles[i].smx = to % my_MAPSIZE; + grid[to]->vehicles[i].smy = to / my_MAPSIZE; } } diff --git a/map.h b/map.h index 0d27e08b174ca..b27b963922fe4 100644 --- a/map.h +++ b/map.h @@ -42,7 +42,7 @@ class map // File I/O virtual void save(overmap *om, unsigned int turn, int x, int y); - virtual void load(game *g, int wx, int wy); + virtual void load(game *g, int wx, int wy, bool update_vehicles = true); void shift(game *g, int wx, int wy, int x, int y); void spawn_monsters(game *g); void clear_spawns(); @@ -158,7 +158,7 @@ class map protected: void saven(overmap *om, unsigned int turn, int x, int y, int gridx, int gridy); - bool loadn(game *g, int x, int y, int gridx, int gridy); + bool loadn(game *g, int x, int y, int gridx, int gridy, bool update_vehicles = true); void copy_grid(int to, int from); void draw_map(oter_id terrain_type, oter_id t_north, oter_id t_east, oter_id t_south, oter_id t_west, oter_id t_above, int turn, diff --git a/mission_start.cpp b/mission_start.cpp index a24a136d636e7..8ad4a9fe5880d 100644 --- a/mission_start.cpp +++ b/mission_start.cpp @@ -47,7 +47,7 @@ void mission_start::place_dog(game *g, mission *miss) } tinymap doghouse(&(g->itypes), &(g->mapitems), &(g->traps)); - doghouse.load(g, house.x * 2, house.y * 2); + doghouse.load(g, house.x * 2, house.y * 2, false); doghouse.add_spawn(mon_dog, 1, SEEX, SEEY, true, -1, miss->uid); doghouse.save(&(g->cur_om), int(g->turn), house.x * 2, house.y * 2); } @@ -65,7 +65,7 @@ void mission_start::place_zombie_mom(game *g, mission *miss) } tinymap zomhouse(&(g->itypes), &(g->mapitems), &(g->traps)); - zomhouse.load(g, house.x * 2, house.y * 2); + zomhouse.load(g, house.x * 2, house.y * 2, false); zomhouse.add_spawn(mon_zombie, 1, SEEX, SEEY, false, -1, miss->uid, random_first_name(false)); zomhouse.save(&(g->cur_om), int(g->turn), house.x * 2, house.y * 2); @@ -113,7 +113,7 @@ void mission_start::place_npc_software(game *g, mission *miss) g->cur_om.seen(x, y) = true; } tinymap compmap(&(g->itypes), &(g->mapitems), &(g->traps)); - compmap.load(g, place.x * 2, place.y * 2); + compmap.load(g, place.x * 2, place.y * 2, false); point comppoint; switch (g->cur_om.ter(place.x, place.y)) {