Skip to content

Commit 8c8cb34

Browse files
committed
Fix namespace clash on round()
1 parent d263585 commit 8c8cb34

File tree

4 files changed

+11
-11
lines changed

4 files changed

+11
-11
lines changed

src/Hazard.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -92,17 +92,17 @@ void Hazard::logic() {
9292
activeAnimation->advanceFrame();
9393

9494
// handle movement
95-
if (!(round(speed.x) == 0 && round(speed.y) == 0)) {
95+
if (!(float_round(speed.x) == 0 && float_round(speed.y) == 0)) {
9696
pos.x += speed.x;
9797
pos.y += speed.y;
9898

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

105-
if (collider->is_outside_map(round(pos.x) >> TILE_SHIFT, round(pos.y) >> TILE_SHIFT))
105+
if (collider->is_outside_map(float_round(pos.x) >> TILE_SHIFT, float_round(pos.y) >> TILE_SHIFT))
106106
remove_now = true;
107107
}
108108
}
@@ -141,8 +141,8 @@ void Hazard::addEntity(Entity *ent) {
141141
void Hazard::addRenderable(vector<Renderable> &r, vector<Renderable> &r_dead) {
142142
if (delay_frames == 0 && activeAnimation) {
143143
Renderable re = activeAnimation->getCurrentFrame(animationKind);
144-
re.map_pos.x = round(pos.x);
145-
re.map_pos.y = round(pos.y);
144+
re.map_pos.x = float_round(pos.x);
145+
re.map_pos.y = float_round(pos.y);
146146
(floor ? r_dead : r).push_back(re);
147147
}
148148
}

src/MapCollision.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -249,15 +249,15 @@ bool MapCollision::line_check(int x1, int y1, int x2, int y2, int check_type, MO
249249
for (int i=0; i<steps; i++) {
250250
x += step_x;
251251
y += step_y;
252-
if (is_wall(round(x), round(y)))
252+
if (is_wall(float_round(x), float_round(y)))
253253
return false;
254254
}
255255
}
256256
else if (check_type == CHECK_MOVEMENT) {
257257
for (int i=0; i<steps; i++) {
258258
x += step_x;
259259
y += step_y;
260-
if (!is_valid_position(round(x), round(y), movement_type, false))
260+
if (!is_valid_position(float_round(x), float_round(y), movement_type, false))
261261
return false;
262262
}
263263
}

src/Utils.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,14 @@ FLARE. If not, see http://www.gnu.org/licenses/
2626
using namespace std;
2727

2828

29-
int round(float f) {
29+
int float_round(float f) {
3030
return (int)(f + 0.5);
3131
}
3232

3333
Point round(FPoint fp) {
3434
Point result;
35-
result.x = round(fp.x);
36-
result.y = round(fp.y);
35+
result.x = float_round(fp.x);
36+
result.y = float_round(fp.y);
3737
return result;
3838
}
3939

src/Utils.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ class Event_Component {
8282
};
8383

8484
// Utility Functions
85-
int round(float f);
85+
int float_round(float f);
8686
Point round(FPoint fp);
8787
Point screen_to_map(int x, int y, int camx, int camy);
8888
Point map_to_screen(int x, int y, int camx, int camy);

0 commit comments

Comments
 (0)