Skip to content

Commit

Permalink
Merge branch 'fix-vehicle-warp' into bugfix-rollup
Browse files Browse the repository at this point in the history
  • Loading branch information
kevingranade committed Oct 16, 2012
2 parents 7ae1820 + 30b6287 commit e228af3
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 19 deletions.
2 changes: 1 addition & 1 deletion computer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
12 changes: 6 additions & 6 deletions game.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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))
Expand Down
13 changes: 6 additions & 7 deletions map.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
}
Expand Down Expand Up @@ -2304,15 +2304,15 @@ 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,
gridn = gridx + gridy * my_MAPSIZE;
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;
}
Expand All @@ -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;
}
}

Expand Down
4 changes: 2 additions & 2 deletions map.h
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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,
Expand Down
6 changes: 3 additions & 3 deletions mission_start.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand All @@ -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);
Expand Down Expand Up @@ -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)) {
Expand Down

0 comments on commit e228af3

Please sign in to comment.