Skip to content

Commit

Permalink
Don't index world_data->region_map beyond its bounds
Browse files Browse the repository at this point in the history
  • Loading branch information
quietust committed Jun 27, 2012
1 parent 9046fed commit f0d4d79
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions plugins/probe.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -221,10 +221,11 @@ command_result df_probe (color_ostream &out, vector <string> & parameters)
out.print("temperature2: %d U\n",mc.temperature2At(cursor));

int offset = block.region_offset[des.bits.biome];
df::coord2d region_pos = block.region_pos + df::coord2d ((offset % 3) - 1, (offset / 3) -1);
int bx = clip_range(block.region_pos.x + (offset % 3) - 1, 0, world->world_data->world_width-1);
int by = clip_range(block.region_pos.y + (offset / 3) - 1, 0, world->world_data->world_height-1);

df::world_data::T_region_map* biome =
&world->world_data->region_map[region_pos.x][region_pos.y];
&world->world_data->region_map[bx][by];

int sav = biome->savagery;
int evi = biome->evilness;
Expand Down

0 comments on commit f0d4d79

Please sign in to comment.