Skip to content

Commit

Permalink
General code quality / formatting fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
tobbi committed Dec 26, 2023
1 parent e6a9af2 commit 7ca670c
Show file tree
Hide file tree
Showing 10 changed files with 26 additions and 27 deletions.
2 changes: 1 addition & 1 deletion src/object/moving_sprite.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ MovingSprite::on_type_change(int old_type)
}

bool
MovingSprite::matches_sprite(const std::string& sprite_file)
MovingSprite::matches_sprite(const std::string& sprite_file) const
{
return m_sprite_name == sprite_file || m_sprite_name == "/" + sprite_file;
}
Expand Down
2 changes: 1 addition & 1 deletion src/object/moving_sprite.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ class MovingSprite : public MovingObject
const std::string& get_sprite_name() const { return m_sprite_name; }
virtual std::string get_default_sprite_name() const { return m_default_sprite_name; }

bool matches_sprite(const std::string& sprite_file);
bool matches_sprite(const std::string& sprite_file) const;
bool change_sprite(const std::string& new_sprite_name);
void spawn_explosion_sprites(int count, const std::string& sprite_path);

Expand Down
2 changes: 1 addition & 1 deletion src/object/portable.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class Portable : public GameObjectComponent
virtual void ungrab(MovingObject& other, Direction ) { m_owner = nullptr; }

virtual MovingObject* get_owner() const { return m_owner; }
virtual bool is_grabbed() const {return m_owner != nullptr; }
virtual bool is_grabbed() const { return m_owner != nullptr; }
virtual bool is_portable() const { return true; }

/** Is the object so heavy/bulky/fragile that Tux can't run while
Expand Down
2 changes: 1 addition & 1 deletion src/object/smoke_cloud.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ SmokeCloud::update(float dt_sec)
void
SmokeCloud::draw(DrawingContext& context)
{
sprite->draw(context.color(), position, LAYER_OBJECTS+1);
sprite->draw(context.color(), position, LAYER_OBJECTS + 1);
}

/* EOF */
2 changes: 1 addition & 1 deletion src/object/snow_particle_system.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ void SnowParticleSystem::update(float dt_sec)
// stop wind
gust_current_velocity = 0;
// new wind strength
gust_onset = graphicsRandom.randf(-SNOW::WIND_SPEED, SNOW::WIND_SPEED);
gust_onset = graphicsRandom.randf(-SNOW::WIND_SPEED, SNOW::WIND_SPEED);
}
timer.start(graphicsRandom.randf(SNOW::STATE_LENGTH));
}
Expand Down
3 changes: 1 addition & 2 deletions src/object/sprite_particle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,6 @@ SpriteParticle::update(float dt_sec)
Camera& camera = Sector::get().get_camera();
if (!camera.get_rect().contains(position)) {
remove_me();
return;
}
}

Expand All @@ -106,7 +105,7 @@ SpriteParticle::draw(DrawingContext& context)
if (glow)
{
sprite->draw(context.light(), position, drawing_layer);
lightsprite->draw(context.light(), position + Vector(12,12), 0);
lightsprite->draw(context.light(), position + Vector(12, 12), 0);
}

}
Expand Down
2 changes: 1 addition & 1 deletion src/object/text_array_object.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ TextArrayObject::next_text()
if (m_isDone)
return;

if (m_curTextIndex+1 >= m_texts.size()) {
if (m_curTextIndex + 1 >= m_texts.size()) {
m_isDone = true;
return;
}
Expand Down
20 changes: 10 additions & 10 deletions src/object/tilemap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ TileMap::TileMap(const TileSet *new_tileset) :
m_height(0),
m_z_pos(0),
m_offset(Vector(0,0)),
m_movement(0,0),
m_movement(0, 0),
m_objects_hit_bottom(),
m_ground_movement_manager(nullptr),
m_flip(NO_FLIP),
Expand Down Expand Up @@ -86,8 +86,8 @@ TileMap::TileMap(const TileSet *tileset_, const ReaderMapping& reader) :
m_width(-1),
m_height(-1),
m_z_pos(0),
m_offset(Vector(0,0)),
m_movement(Vector(0,0)),
m_offset(Vector(0, 0)),
m_movement(Vector(0, 0)),
m_objects_hit_bottom(),
m_ground_movement_manager(nullptr),
m_flip(NO_FLIP),
Expand Down Expand Up @@ -354,9 +354,9 @@ TileMap::update(float dt_sec)
}
}

m_movement = Vector(0,0);
// if we have a path to follow, follow it
if (get_walker()) {
m_movement = Vector(0, 0);
get_walker()->update(dt_sec);
Vector v = get_walker()->get_pos(get_size() * 32, m_path_handle);
if (get_path() && get_path()->is_valid()) {
Expand Down Expand Up @@ -404,7 +404,7 @@ TileMap::on_flip(float height)
for (int x = 0; x < get_width(); ++x) {
for (int y = 0; y < get_height()/2; ++y) {
// swap tiles
int y2 = get_height()-1-y;
int y2 = get_height() - 1 - y;
uint32_t t1 = get_tile_id(x, y);
uint32_t t2 = get_tile_id(x, y2);
change(x, y, t2);
Expand Down Expand Up @@ -812,10 +812,9 @@ TileMap::autotile_corner(int x, int y, uint32_t tile, AutotileCornerOperation op
}

bool
TileMap::is_corner(uint32_t tile)
TileMap::is_corner(uint32_t tile) const
{
auto* ats = m_tileset->get_autotileset_from_tile(tile);

return ats && ats->is_corner();
}

Expand Down Expand Up @@ -954,11 +953,12 @@ TileMap::update_effective_solid()
else if (!m_effective_solid && (m_current_alpha >= 0.75f))
m_effective_solid = true;

if(Sector::current() != nullptr && old != m_effective_solid)
{
if(old != m_effective_solid) {
if(Sector::current() != nullptr) {
Sector::get().update_solid(this);
} else if(worldmap::WorldMap::current() != nullptr && old != m_effective_solid) {
} else if(worldmap::WorldMap::current() != nullptr) {
worldmap::WorldMapSector::current()->update_solid(this);
}
}
}

Expand Down
10 changes: 5 additions & 5 deletions src/object/tilemap.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -111,15 +111,15 @@ class TileMap final :
{
if (actual) {
return m_movement;
} else {
return Vector(m_movement.x, std::max(0.0f, m_movement.y));
}

return Vector(m_movement.x, std::max(0.0f, m_movement.y));
}

/** Returns the position of the upper-left corner of tile (x, y) in
the sector. */
Vector get_tile_position(int x, int y) const
{ return m_offset + Vector(static_cast<float>(x), static_cast<float>(y)) * 32.0f; }
{ return m_offset + Vector(x * 1.0f, y * 1.0f) * 32.0f; }

Rectf get_bbox() const {
return Rectf(get_tile_position(0, 0),
Expand All @@ -141,7 +141,7 @@ class TileMap final :
void notify_object_removal(CollisionObject* other);

int get_layer() const { return m_z_pos; }
void set_layer(int layer_) { m_z_pos = layer_; }
void set_layer(int layer) { m_z_pos = layer; }

bool is_solid() const { return m_real_solid && m_effective_solid; }

Expand Down Expand Up @@ -215,7 +215,7 @@ class TileMap final :
void update_effective_solid();
void float_channel(float target, float &current, float remaining_time, float dt_sec);

bool is_corner(uint32_t tile);
bool is_corner(uint32_t tile) const;

void apply_offset_x(int fill_id, int xoffset);
void apply_offset_y(int fill_id, int yoffset);
Expand Down
8 changes: 4 additions & 4 deletions src/object/water_drop.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,17 +53,17 @@ WaterDrop::collision_solid(const CollisionHit& hit)

// spawn water particles
for (int i = 50; i; i--) {
int pa = graphicsRandom.rand(0,3);
int pa = graphicsRandom.rand(0, 3);
float px = graphicsRandom.randf(m_col.m_bbox.get_left(), m_col.m_bbox.get_right());
float py = graphicsRandom.randf(m_col.m_bbox.get_top(), m_col.m_bbox.get_bottom());
Vector ppos = Vector(px, py);
Vector pspeed = ppos - m_col.m_bbox.get_middle();
pspeed.x *= 12;
pspeed.y *= 12;
Sector::get().add<SpriteParticle>(sprite_path, "particle_" + std::to_string(pa),
ppos, ANCHOR_MIDDLE,
pspeed, Vector(0, 100 * Sector::get().get_gravity()),
LAYER_OBJECTS+1);
ppos, ANCHOR_MIDDLE,
pspeed, Vector(0, 100 * Sector::get().get_gravity()),
LAYER_OBJECTS + 1);
}
}
}
Expand Down

0 comments on commit 7ca670c

Please sign in to comment.