Skip to content

Commit

Permalink
Fix namespace clash on round()
Browse files Browse the repository at this point in the history
  • Loading branch information
AMDmi3 committed Sep 17, 2013
1 parent d263585 commit 8c8cb34
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 11 deletions.
10 changes: 5 additions & 5 deletions src/Hazard.cpp
Expand Up @@ -92,17 +92,17 @@ void Hazard::logic() {
activeAnimation->advanceFrame();

// handle movement
if (!(round(speed.x) == 0 && round(speed.y) == 0)) {
if (!(float_round(speed.x) == 0 && float_round(speed.y) == 0)) {
pos.x += speed.x;
pos.y += speed.y;

// very simplified collider, could skim around corners
// or even pass through thin walls if speed > tilesize
if (collider->is_wall(round(pos.x), round(pos.y))) {
if (collider->is_wall(float_round(pos.x), float_round(pos.y))) {
lifespan = 0;
hit_wall = true;

if (collider->is_outside_map(round(pos.x) >> TILE_SHIFT, round(pos.y) >> TILE_SHIFT))
if (collider->is_outside_map(float_round(pos.x) >> TILE_SHIFT, float_round(pos.y) >> TILE_SHIFT))
remove_now = true;
}
}
Expand Down Expand Up @@ -141,8 +141,8 @@ void Hazard::addEntity(Entity *ent) {
void Hazard::addRenderable(vector<Renderable> &r, vector<Renderable> &r_dead) {
if (delay_frames == 0 && activeAnimation) {
Renderable re = activeAnimation->getCurrentFrame(animationKind);
re.map_pos.x = round(pos.x);
re.map_pos.y = round(pos.y);
re.map_pos.x = float_round(pos.x);
re.map_pos.y = float_round(pos.y);
(floor ? r_dead : r).push_back(re);
}
}
4 changes: 2 additions & 2 deletions src/MapCollision.cpp
Expand Up @@ -249,15 +249,15 @@ bool MapCollision::line_check(int x1, int y1, int x2, int y2, int check_type, MO
for (int i=0; i<steps; i++) {
x += step_x;
y += step_y;
if (is_wall(round(x), round(y)))
if (is_wall(float_round(x), float_round(y)))
return false;
}
}
else if (check_type == CHECK_MOVEMENT) {
for (int i=0; i<steps; i++) {
x += step_x;
y += step_y;
if (!is_valid_position(round(x), round(y), movement_type, false))
if (!is_valid_position(float_round(x), float_round(y), movement_type, false))
return false;
}
}
Expand Down
6 changes: 3 additions & 3 deletions src/Utils.cpp
Expand Up @@ -26,14 +26,14 @@ FLARE. If not, see http://www.gnu.org/licenses/
using namespace std;


int round(float f) {
int float_round(float f) {
return (int)(f + 0.5);
}

Point round(FPoint fp) {
Point result;
result.x = round(fp.x);
result.y = round(fp.y);
result.x = float_round(fp.x);
result.y = float_round(fp.y);
return result;
}

Expand Down
2 changes: 1 addition & 1 deletion src/Utils.h
Expand Up @@ -82,7 +82,7 @@ class Event_Component {
};

// Utility Functions
int round(float f);
int float_round(float f);
Point round(FPoint fp);
Point screen_to_map(int x, int y, int camx, int camy);
Point map_to_screen(int x, int y, int camx, int camy);
Expand Down

0 comments on commit 8c8cb34

Please sign in to comment.