Skip to content

Commit 1ad7261

Browse files
committed
tidy
1 parent 14b2ec7 commit 1ad7261

16 files changed

Lines changed: 55 additions & 53 deletions

TODO

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
bugs
22
----
3+
dead argusul over chasm should fall
34
item thrown onto exit
45
item thrown onto chasm
56
item thrown onto lava

src/ascii.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
#include "my_types.hpp"
2121
#include "my_ui.hpp"
2222

23-
#include <OpenGL/gl.h>
2423
#include <algorithm>
2524
#include <array>
2625
#include <cstdarg>

src/cave_gen.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
static const int MAP_LEVEL_BLOB_CENTERING = MAP_WIDTH / 4;
1818

19-
void cave_dump(Gamep /*g*/, Cave *c)
19+
void cave_dump(Gamep g, Cave *c)
2020
{
2121
uint8_t x = 0;
2222
uint8_t y = 0;
@@ -129,7 +129,7 @@ static void cave_generation(Cave *c, uint32_t fill_prob, uint8_t r1, uint8_t r2,
129129
//
130130
// Iterate the generations for cellular automata
131131
//
132-
void cave_create(Gamep /*g*/, Cave *c, uint32_t fill_prob, uint8_t r1, uint8_t r2, int map_generations)
132+
void cave_create(Gamep g, Cave *c, uint32_t fill_prob, uint8_t r1, uint8_t r2, int map_generations)
133133
{
134134
for (auto gen = 0; gen < map_generations; gen++) {
135135
cave_generation(c, fill_prob, r1, r2, gen);
@@ -244,7 +244,7 @@ void cave_generation_keep_largest_blob(Gamep g, Cave *c)
244244
//
245245
// Post generation of the cave, keep all but the largest blob
246246
//
247-
void cave_generation_center_blob(Gamep /*g*/, Cave *c)
247+
void cave_generation_center_blob(Gamep g, Cave *c)
248248
{
249249
int x = 0;
250250
int y = 0;

src/level_tick.cpp

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
#include "my_types.hpp"
1818
#include "my_wids.hpp"
1919
#include <algorithm>
20+
#include <cmath>
2021
#include <cstdint>
2122
#include <vector>
2223

@@ -328,7 +329,7 @@ static void level_tick_check_running_time(Gamep g, Levelsp v, Levelp l)
328329
// before the lower level can complete!
329330
//
330331
Levelp player_level = thing_player_level(g);
331-
if (player_level) {
332+
if (player_level != nullptr) {
332333
if (level_tick_is_in_progress(g, v, player_level)) {
333334
LEVEL_DBG(g, v, l, "Tick %u: delay end, waiting for player level", v->tick);
334335
return;
@@ -398,7 +399,7 @@ static void level_tick_body(Gamep g, Levelsp v, Levelp l, float dt, bool tick_is
398399

399400
float t_speed = thing_speed(t);
400401
if (t_speed == 0) {
401-
t_speed = (float) player_speed;
402+
t_speed = static_cast< float >(player_speed);
402403
}
403404

404405
auto old_thing_dt = t->thing_dt;
@@ -417,12 +418,12 @@ static void level_tick_body(Gamep g, Levelsp v, Levelp l, float dt, bool tick_is
417418

418419
if (compiler_unused) {
419420
THING_DBG(t, "level dt %f old_thing_dt %f thing_dt %f thing_dt_change %f speed %d v %d",
420-
dt, //
421-
old_thing_dt, //
422-
t->thing_dt, //
423-
thing_dt_change, //
424-
(int) t_speed, //
425-
player_speed //
421+
dt, //
422+
old_thing_dt, //
423+
t->thing_dt, //
424+
thing_dt_change, //
425+
static_cast< int >(t_speed), //
426+
player_speed //
426427
);
427428
}
428429

@@ -836,7 +837,7 @@ void level_tick_reset_frame_counter(Gamep g)
836837
{
837838
auto *v = game_levels_get(g);
838839

839-
if (! v) {
840+
if (v == nullptr) {
840841
return;
841842
}
842843

@@ -865,9 +866,7 @@ static void level_tick_time_step(Gamep g, Levelsp v, Levelp current_level)
865866
v->last_time_step = v->time_step;
866867
v->time_step = (static_cast< float >(v->frame - v->frame_begin)) / static_cast< float >(duration_ms);
867868

868-
if (v->time_step >= 1.0) {
869-
v->time_step = 1.0;
870-
}
869+
v->time_step = std::min< double >(v->time_step, 1.0);
871870

872871
IF_DEBUG2
873872
{ //

src/my_thing.hpp

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -621,7 +621,7 @@ using Thing = struct Thing {
621621
[[nodiscard]] auto thing_and_tp_get_at_safe(Gamep g, Levelsp v, Levelp l, const bpoint &p, int slot, Tpp *out) -> Thingp;
622622
[[nodiscard]] auto thing_and_tp_get_at(Gamep g, Levelsp v, Levelp l, const bpoint &p, int slot, Tpp *out) -> Thingp;
623623
[[nodiscard]] auto thing_at(Thingp t) -> bpoint;
624-
[[nodiscard]] auto thing_attack_at(Gamep g, Levelsp v, Levelp l, Thingp me, const bpoint &attack_at, ThingEvent *e = nullptr) -> bool;
624+
[[nodiscard]] auto thing_attack_at(Gamep g, Levelsp v, Levelp l, Thingp attacker, const bpoint &attack_at, ThingEvent *e = nullptr) -> bool;
625625
[[nodiscard]] auto thing_attack_count_per_tick_decr(Gamep g, Levelsp v, Levelp l, Thingp t, int val = 1) -> int;
626626
[[nodiscard]] auto thing_attack_count_per_tick_incr(Gamep g, Levelsp v, Levelp l, Thingp t, int val = 1) -> int;
627627
[[nodiscard]] auto thing_attack_count_per_tick_set(Gamep g, Levelsp v, Levelp l, Thingp t, int val) -> int;
@@ -669,11 +669,11 @@ using Thing = struct Thing {
669669
[[nodiscard]] auto thing_distance_jump(Gamep g, Levelsp v, Levelp l, Thingp me) -> int;
670670
[[nodiscard]] auto thing_distance_minion_from_mob_max_set(Gamep g, Levelsp v, Levelp l, Thingp t, int val) -> int;
671671
[[nodiscard]] auto thing_distance_minion_from_mob_max(Gamep g, Levelsp v, Levelp l, Thingp t) -> int;
672-
[[nodiscard]] auto thing_distance_throw_decr(Gamep g, Levelsp v, Levelp l, Thingp me, int val = 1) -> int;
673-
[[nodiscard]] auto thing_distance_throw_incr(Gamep g, Levelsp v, Levelp l, Thingp me, int val = 1) -> int;
674-
[[nodiscard]] auto thing_distance_throw_max(Gamep g, Levelsp v, Levelp l, Thingp me) -> int;
675-
[[nodiscard]] auto thing_distance_throw_set(Gamep g, Levelsp v, Levelp l, Thingp me, int val) -> int;
676-
[[nodiscard]] auto thing_distance_throw(Gamep g, Levelsp v, Levelp l, Thingp me) -> int;
672+
[[nodiscard]] auto thing_distance_throw_decr(Gamep g, Levelsp v, Levelp l, Thingp thrower, int val = 1) -> int;
673+
[[nodiscard]] auto thing_distance_throw_incr(Gamep g, Levelsp v, Levelp l, Thingp thrower, int val = 1) -> int;
674+
[[nodiscard]] auto thing_distance_throw_max(Gamep g, Levelsp v, Levelp l, Thingp thrower) -> int;
675+
[[nodiscard]] auto thing_distance_throw_set(Gamep g, Levelsp v, Levelp l, Thingp thrower, int val) -> int;
676+
[[nodiscard]] auto thing_distance_throw(Gamep g, Levelsp v, Levelp l, Thingp thrower) -> int;
677677
[[nodiscard]] auto thing_distance_vision_decr(Gamep g, Levelsp v, Levelp l, Thingp t, int val = 1) -> int;
678678
[[nodiscard]] auto thing_distance_vision_incr(Gamep g, Levelsp v, Levelp l, Thingp t, int val = 1) -> int;
679679
[[nodiscard]] auto thing_distance_vision_set(Gamep g, Levelsp v, Levelp l, Thingp t, int val) -> int;
@@ -1056,7 +1056,7 @@ using Thing = struct Thing {
10561056
[[nodiscard]] auto thing_temperature_incr(Gamep g, Levelsp v, Levelp l, Thingp t, int val = 1) -> int;
10571057
[[nodiscard]] auto thing_temperature_set(Gamep g, Levelsp v, Levelp l, Thingp t, int val) -> int;
10581058
[[nodiscard]] auto thing_temperature(Thingp t) -> int;
1059-
[[nodiscard]] auto thing_throw_to(Gamep g, Levelsp v, Levelp l, Thingp me, Thingp what, bpoint to) -> bool;
1059+
[[nodiscard]] auto thing_throw_to(Gamep g, Levelsp v, Levelp l, Thingp thrower, Thingp item, bpoint to) -> bool;
10601060
[[nodiscard]] auto thing_unwield(Gamep g, Levelsp v, Levelp l, Thingp me, ThingEvent & /*e*/) -> bool;
10611061
[[nodiscard]] auto thing_use(Gamep g, Levelsp v, Levelp l, Thingp me, Thingp item, ThingEvent &e) -> bool;
10621062
[[nodiscard]] auto thing_value1_decr(Gamep g, Levelsp v, Levelp l, Thingp t, int val = 1) -> int;
@@ -1185,9 +1185,9 @@ void thing_dump_missiles(Gamep g, Levelsp v, Levelp l, Thingp me);
11851185
void thing_enhance(Gamep g, Levelsp v, Levelp l, Thingp t, Tpp tp);
11861186
void thing_err(Thingp t, const char *fmt, ...) CHECK_FORMAT_STR(printf, 2, 3);
11871187
void thing_explosion_handle(Gamep g, Levelsp v, Levelp l, Thingp t);
1188-
void thing_fall_end_check(Gamep g, Levelsp v, Levelp l, Thingp t);
1189-
void thing_fall_time_step(Gamep g, Levelsp v, Levelp l, Thingp t, int time_step);
1190-
void thing_fall(Gamep g, Levelsp v, Levelp l, Thingp t);
1188+
void thing_fall_end_check(Gamep g, Levelsp v, Levelp l, Thingp me);
1189+
void thing_fall_time_step(Gamep g, Levelsp v, Levelp l, Thingp me, int time_step);
1190+
void thing_fall(Gamep g, Levelsp v, Levelp l, Thingp me);
11911191
void thing_fini(Gamep g, Levelsp v, Levelp l, Thingp t);
11921192
void thing_free(Gamep g, Levelsp v, Levelp l, Thingp t);
11931193
void thing_group_join(Gamep g, Levelsp v, Levelp l, Thingp t, Thingp group);
@@ -1226,8 +1226,8 @@ void thing_is_spawned_set(Gamep g, Levelsp v, Levelp l, Thingp t, bool val = tru
12261226
void thing_is_spawned_unset(Gamep g, Levelsp v, Levelp l, Thingp t);
12271227
void thing_is_teleporting_set(Gamep g, Levelsp v, Levelp l, Thingp me, bool val = true);
12281228
void thing_is_teleporting_unset(Gamep g, Levelsp v, Levelp l, Thingp me);
1229-
void thing_is_thrown_set(Gamep g, Levelsp v, Levelp l, Thingp me, Thingp thrower, bool val = true);
1230-
void thing_is_thrown_unset(Gamep g, Levelsp v, Levelp l, Thingp me, Thingp thrower);
1229+
void thing_is_thrown_set(Gamep g, Levelsp v, Levelp l, Thingp item, Thingp thrower, bool val = true);
1230+
void thing_is_thrown_unset(Gamep g, Levelsp v, Levelp l, Thingp item, Thingp thrower);
12311231
void thing_is_unlocked_set(Gamep g, Levelsp v, Levelp l, Thingp t, bool val = true);
12321232
void thing_is_unlocked_unset(Gamep g, Levelsp v, Levelp l, Thingp t);
12331233
void thing_level_warp_to_entrance(Gamep g, Levelsp v, Levelp new_level, Thingp t);

src/my_thing_callbacks.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,15 +54,15 @@ void thing_on_level_populated(Gamep g, Levelsp v, Levelp l, Thingp me);
5454

5555
using thing_on_carry_request_t = bool (*)(Gamep, Levelsp, Levelp, Thingp me, Thingp owner, ThingEvent &);
5656
void thing_on_carry_request_set(Tpp tp, thing_on_carry_request_t callback);
57-
[[nodiscard]] auto thing_on_carry_request(Gamep g, Levelsp v, Levelp l, Thingp me, Thingp owner, ThingEvent & /*e*/) -> bool;
57+
[[nodiscard]] auto thing_on_carry_request(Gamep g, Levelsp v, Levelp l, Thingp me, Thingp user, ThingEvent & /*e*/) -> bool;
5858

5959
using thing_on_drop_request_t = bool (*)(Gamep, Levelsp, Levelp, Thingp me, Thingp dropper, ThingEvent &);
6060
void thing_on_drop_request_set(Tpp tp, thing_on_drop_request_t callback);
6161
[[nodiscard]] auto thing_on_drop_request(Gamep g, Levelsp v, Levelp l, Thingp me, Thingp user, ThingEvent & /*e*/) -> bool;
6262

6363
using thing_on_carry_success_t = bool (*)(Gamep, Levelsp, Levelp, Thingp me, Thingp owner, ThingEvent &);
6464
void thing_on_carry_success_set(Tpp tp, thing_on_carry_success_t callback);
65-
[[nodiscard]] auto thing_on_carry_success(Gamep g, Levelsp v, Levelp l, Thingp me, Thingp owner, ThingEvent & /*e*/) -> bool;
65+
[[nodiscard]] auto thing_on_carry_success(Gamep g, Levelsp v, Levelp l, Thingp me, Thingp user, ThingEvent & /*e*/) -> bool;
6666

6767
using thing_on_drop_success_t = bool (*)(Gamep, Levelsp, Levelp, Thingp me, Thingp dropper, ThingEvent &);
6868
void thing_on_drop_success_set(Tpp tp, thing_on_drop_success_t callback);

src/thing_carry.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55
#include "my_callstack.hpp"
66
#include "my_game.hpp"
7-
#include "my_level.hpp"
87
#include "my_main.hpp"
98
#include "my_thing.hpp"
109
#include "my_thing_callbacks.hpp"

src/thing_damage.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -269,9 +269,7 @@ static void thing_damage_cap_for_this_tick(Gamep g, Levelsp v, Levelp l, Thingp
269269
if (d_total > max_damage_per_tick) {
270270
auto old_d = e.damage;
271271
e.damage -= d_total - max_damage_per_tick;
272-
if (e.damage < 0) {
273-
e.damage = 0;
274-
}
272+
e.damage = std::max(e.damage, 0);
275273
THING_DBG(me, "%s: limit per tick damage %d -> %d", to_string(g, v, l, e).c_str(), old_d, e.damage);
276274
}
277275
}

src/thing_drop.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,17 +78,17 @@ static auto thing_drop_item(Gamep g, Levelsp v, Levelp l, Thingp item, Thingp us
7878

7979
FOR_ALL_INVENTORY_SLOTS(g, v, l, owner, slot, an_item)
8080
{
81-
if (! an_item) {
81+
if (an_item == nullptr) {
8282
continue;
8383
}
8484

8585
//
8686
// Replace the thing dropped with a new thing
8787
//
8888
if (thing_tp(an_item) == thing_tp(item)) {
89-
auto thing_copy = thing_spawn(g, v, l, thing_tp(item), user);
89+
auto *thing_copy = thing_spawn(g, v, l, thing_tp(item), user);
9090

91-
if (thing_copy) {
91+
if (thing_copy != nullptr) {
9292
THING_DBG(thing_copy, "drop: %s (thing copy)", s.c_str());
9393
TRACE_INDENT();
9494

src/thing_fall.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -269,12 +269,12 @@ static void thing_fall_end(Gamep g, Levelsp v, Levelp l, Thingp me)
269269
//
270270
// Splash!
271271
//
272-
if (level_is_deep_water(g, v, l, thing_at(me))) {
272+
if (level_is_deep_water(g, v, l, thing_at(me)) != nullptr) {
273273
thing_sound_play(g, v, l, me, "splash");
274274
if (thing_is_player(me)) {
275275
topcon(UI_GOOD_FMT_STR "The deep water dampened your fall!" UI_RESET_FMT);
276276
}
277-
} else if (level_is_water(g, v, l, thing_at(me))) {
277+
} else if (level_is_water(g, v, l, thing_at(me)) != nullptr) {
278278
thing_sound_play(g, v, l, me, "splash");
279279
if (thing_is_player(me)) {
280280
topcon(UI_GOOD_FMT_STR "The water dampened your fall!" UI_RESET_FMT);

0 commit comments

Comments
 (0)