Skip to content

Commit

Permalink
Merge pull request #30 from zpmorgan/master
Browse files Browse the repository at this point in the history
bounds checking for veh_exists_at.
  • Loading branch information
TheDarklingWolf committed Feb 1, 2013
2 parents cbca4f0 + b735c8a commit a209c72
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions map.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,11 @@ void map::update_vehicle_cache(vehicle * veh, const bool brand_new)
if( it->second.first == veh ) {
int x = it->first.first;
int y = it->first.second;
veh_exists_at[x][y] = false;
if ((x > 0) && (y > 0) &&
x < SEEX*MAPSIZE &&
y < SEEY*MAPSIZE){
veh_exists_at[x][y] = false;
}
tmp = it;
++it;
veh_cached_parts.erase( tmp );
Expand All @@ -152,7 +156,11 @@ void map::update_vehicle_cache(vehicle * veh, const bool brand_new)
const int py = gy + it->precalc_dy[0];
veh_cached_parts.insert( std::make_pair( std::make_pair(px,py),
std::make_pair(veh,partid) ));
veh_exists_at[px][py] = true;
if ((px > 0) && (py > 0) &&
px < SEEX*MAPSIZE &&
py < SEEY*MAPSIZE){
veh_exists_at[px][py] = true;
}
}
}

Expand All @@ -163,7 +171,11 @@ void map::clear_vehicle_cache()
part = veh_cached_parts.begin();
int x = part->first.first;
int y = part->first.second;
veh_exists_at[x][y] = false;
if ((x > 0) && (y > 0) &&
x < SEEX*MAPSIZE &&
y < SEEY*MAPSIZE){
veh_exists_at[x][y] = false;
}
veh_cached_parts.erase(part);
}
}
Expand Down

0 comments on commit a209c72

Please sign in to comment.