Skip to content

Commit

Permalink
add tp flag enums
Browse files Browse the repository at this point in the history
  • Loading branch information
goblinhack committed May 19, 2024
1 parent c147bf9 commit e075dfa
Show file tree
Hide file tree
Showing 13 changed files with 81 additions and 256 deletions.
2 changes: 1 addition & 1 deletion src/level_tiles.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ void level_assign_tiles(Levelp l, int z)
//
// Switch the door direction if next to walls
//
if (tp_flag(tp, is_door)) {
if (tp_is_door(tp)) {
if (level_flag(l, is_wall, x, y - 1, z) && level_flag(l, is_wall, x, y + 1, z)) {
block_type = IS_JOIN_TOP;
}
Expand Down
56 changes: 51 additions & 5 deletions src/my_enums.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,60 @@ enum {
enum { MONST_CLASS_A, MONST_CLASS_MAX };

/* clang-format off */
#define THING_FLAG_ENUM(list_macro) \
list_macro(is_wall, "is_wall"), \
list_macro(is_door, "is_door"), \
list_macro(is_cursor_hazard, "is_cursor_hazard"), \
list_macro(THING_FLAG_MAX, "THING_FLAG_MAX"),
#define THING_FLAG_ENUM(list_macro) \
list_macro(is_able_to_walk_through_walls, "is_able_to_walk_through_walls"), \
list_macro(is_animated_can_hflip, "is_animated_can_hflip"), \
list_macro(is_animated_no_dir, "is_animated_no_dir"), \
list_macro(is_blit_centered, "is_blit_centered"), \
list_macro(is_blit_on_ground, "is_blit_on_ground"), \
list_macro(is_blit_outlined, "is_blit_outlined"), \
list_macro(is_blit_square_outlined, "is_blit_square_outlined"), \
list_macro(is_cursor, "is_cursor"), \
list_macro(is_cursor_hazard, "is_cursor_hazard"), \
list_macro(is_cursor_path_blocker, "is_cursor_path_blocker"), \
list_macro(is_cursor_path_hazard, "is_cursor_path_hazard"), \
list_macro(is_cursor_path, "is_cursor_path"), \
list_macro(is_door, "is_door"), \
list_macro(is_dungeon_entrance, "is_dungeon_entrance"), \
list_macro(is_exit, "is_exit"), \
list_macro(is_floor, "is_floor"), \
list_macro(is_key, "is_key"), \
list_macro(is_monst, "is_monst"), \
list_macro(is_obs_monst, "is_obs_monst"), \
list_macro(is_obs_player, "is_obs_player"), \
list_macro(is_obs_wall_or_door, "is_obs_wall_or_door"), \
list_macro(is_player, "is_player"), \
list_macro(is_tiled, "is_tiled"), \
list_macro(is_wall, "is_wall"), \
list_macro(THING_FLAG_MAX, "THING_FLAG_MAX"),

/* clang-format on */

#define tp_is_able_to_walk_through_walls(tp) tp_flag(tp, is_able_to_walk_through_walls)
#define tp_is_animated_can_hflip(tp) tp_flag(tp, is_animated_can_hflip)
#define tp_is_animated_no_dir(tp) tp_flag(tp, is_animated_no_dir)
#define tp_is_blit_centered(tp) tp_flag(tp, is_blit_centered)
#define tp_is_blit_on_ground(tp) tp_flag(tp, is_blit_on_ground)
#define tp_is_blit_outlined(tp) tp_flag(tp, is_blit_outlined)
#define tp_is_blit_square_outlined(tp) tp_flag(tp, is_blit_square_outlined)
#define tp_is_cursor(tp) tp_flag(tp, is_cursor)
#define tp_is_cursor_hazard(tp) tp_flag(tp, is_cursor_hazard)
#define tp_is_cursor_path_blocker(tp) tp_flag(tp, is_cursor_path_blocker)
#define tp_is_cursor_path_hazard(tp) tp_flag(tp, is_cursor_path_hazard)
#define tp_is_cursor_path(tp) tp_flag(tp, is_cursor_path)
#define tp_is_door(tp) tp_flag(tp, is_door)
#define tp_is_dungeon_entrance(tp) tp_flag(tp, is_dungeon_entrance)
#define tp_is_exit(tp) tp_flag(tp, is_exit)
#define tp_is_floor(tp) tp_flag(tp, is_floor)
#define tp_is_key(tp) tp_flag(tp, is_key)
#define tp_is_monst(tp) tp_flag(tp, is_monst)
#define tp_is_obs_monst(tp) tp_flag(tp, is_obs_monst)
#define tp_is_obs_player(tp) tp_flag(tp, is_obs_player)
#define tp_is_obs_wall_or_door(tp) tp_flag(tp, is_obs_wall_or_door)
#define tp_is_player(tp) tp_flag(tp, is_player)
#define tp_is_tiled(tp) tp_flag(tp, is_tiled)
#define tp_is_wall(tp) tp_flag(tp, is_wall)

ENUM_DEF_H(THING_FLAG_ENUM, ThingFlag)

#endif
57 changes: 0 additions & 57 deletions src/my_tp.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,63 +63,6 @@ void tp_random_dungeon_init(void);
bool tp_flag(Tpp tp, ThingFlag);
void tp_flag_set(Tpp tp, ThingFlag, bool val);

bool tp_is_animated_can_hflip(Tpp tp);
void tp_is_animated_can_hflip_set(Tpp tp, bool val);

bool tp_is_animated_no_dir(Tpp tp);
void tp_is_animated_no_dir_set(Tpp tp, bool val);

bool tp_is_blit_centered(Tpp tp);
void tp_is_blit_centered_set(Tpp tp, bool val);

bool tp_is_blit_on_ground(Tpp tp);
void tp_is_blit_on_ground_set(Tpp tp, bool val);

bool tp_is_blit_outlined(Tpp tp);
void tp_is_blit_outlined_set(Tpp tp, bool val);

bool tp_is_blit_square_outlined(Tpp tp);
void tp_is_blit_square_outlined_set(Tpp tp, bool val);

bool tp_is_tiled(Tpp tp);
void tp_is_tiled_set(Tpp tp, bool val);

bool tp_is_cursor(Tpp tp);
void tp_is_cursor_set(Tpp tp, bool val);

bool tp_is_dungeon_entrance(Tpp tp);
void tp_is_dungeon_entrance_set(Tpp tp, bool val);

bool tp_is_exit(Tpp tp);
void tp_is_exit_set(Tpp tp, bool val);

bool tp_is_floor(Tpp tp);
void tp_is_floor_set(Tpp tp, bool val);

bool tp_is_cursor_at(Tpp tp);
void tp_is_cursor_at_set(Tpp tp, bool val);

bool tp_is_cursor_path(Tpp tp);
void tp_is_cursor_path_set(Tpp tp, bool val);

bool tp_is_key(Tpp tp);
void tp_is_key_set(Tpp tp, bool val);

bool tp_is_monst(Tpp tp);
void tp_is_monst_set(Tpp tp, bool val);

bool tp_is_monst_class(Tpp tp, int val);
void tp_is_monst_class_set(Tpp tp, bool val);

bool tp_is_obs_monst(Tpp tp);
void tp_is_obs_monst_set(Tpp tp, bool val);

bool tp_is_obs_player(Tpp tp);
void tp_is_obs_player_set(Tpp tp, bool val);

bool tp_is_player(Tpp tp);
void tp_is_player_set(Tpp tp, bool val);

uint8_t tp_player_index_get(Tpp tp);
void tp_player_index_set(Tpp tp, uint8_t val);

Expand Down
6 changes: 4 additions & 2 deletions src/thing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,10 @@ Thingp level_thing_init(Levelp l, Tpp tp, int x, int y, int z)
//
// Assign the player
//
if (tp_player_index_get(tp) == l->player_index) {
l->player = t->id;
if (tp_is_player(tp)) {
if (tp_player_index_get(tp) == l->player_index) {
l->player = t->id;
}
}

level_thing_update(l, t);
Expand Down
8 changes: 4 additions & 4 deletions src/things/dungeon/tp_door.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ bool tp_load_door(void)
{
auto tp = tp_load("door");
// begin sort marker1 {
tp_is_blit_centered_set(tp, true);
tp_is_tiled_set(tp, true);
tp_flag_set(tp, is_blit_centered, true);
tp_flag_set(tp, is_tiled, true);
tp_flag_set(tp, is_door, true);
tp_is_obs_monst_set(tp, true);
tp_is_obs_player_set(tp, true);
tp_flag_set(tp, is_obs_monst, true);
tp_flag_set(tp, is_obs_player, true);
tp_z_depth_set(tp, MAP_DEPTH_DOOR);
// end sort marker1 }

Expand Down
4 changes: 2 additions & 2 deletions src/things/dungeon/tp_exit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ bool tp_load_exit(void)
{
auto tp = tp_load("exit");
// begin sort marker1 {
tp_is_blit_on_ground_set(tp, true);
tp_is_exit_set(tp, true);
tp_flag_set(tp, is_blit_on_ground, true);
tp_flag_set(tp, is_exit, true);
tp_z_depth_set(tp, MAP_DEPTH_OBJ1);
// end sort marker1 }

Expand Down
6 changes: 3 additions & 3 deletions src/things/dungeon/tp_floor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ bool tp_load_floor(void)
{
auto tp = tp_load("floor");
// begin sort marker1 {
tp_is_blit_centered_set(tp, true);
tp_is_blit_on_ground_set(tp, true);
tp_is_floor_set(tp, true);
tp_flag_set(tp, is_blit_centered, true);
tp_flag_set(tp, is_blit_on_ground, true);
tp_flag_set(tp, is_floor, true);
tp_z_depth_set(tp, MAP_DEPTH_FLOOR);
// end sort marker1 }

Expand Down
4 changes: 2 additions & 2 deletions src/things/dungeon/tp_key.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ bool tp_load_key(void)
{
auto tp = tp_load("key");
// begin sort marker1 {
tp_is_blit_on_ground_set(tp, true);
tp_is_key_set(tp, true);
tp_flag_set(tp, is_blit_on_ground, true);
tp_flag_set(tp, is_key, true);
tp_z_depth_set(tp, MAP_DEPTH_OBJ2);
// end sort marker1 }

Expand Down
8 changes: 4 additions & 4 deletions src/things/dungeon/tp_wall.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ bool tp_load_wall(void)
auto name = "wall" + std::to_string(variant);
auto tp = tp_load(name.c_str());
// begin sort marker1 {
tp_is_blit_centered_set(tp, true);
tp_is_tiled_set(tp, true);
tp_is_obs_monst_set(tp, true);
tp_is_obs_player_set(tp, true);
tp_flag_set(tp, is_blit_centered, true);
tp_flag_set(tp, is_tiled, true);
tp_flag_set(tp, is_obs_monst, true);
tp_flag_set(tp, is_obs_player, true);
tp_flag_set(tp, is_wall, true);
tp_z_depth_set(tp, MAP_DEPTH_WALL);
// end sort marker1 }
Expand Down
8 changes: 4 additions & 4 deletions src/things/internal/tp_cursor_at.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ bool tp_load_cursor_at(void)
{
auto tp = tp_load("cursor_at");
// begin sort marker1 {
tp_is_blit_centered_set(tp, true);
tp_is_blit_on_ground_set(tp, true);
tp_is_blit_square_outlined_set(tp, true);
tp_is_cursor_at_set(tp, true);
tp_flag_set(tp, is_blit_centered, true);
tp_flag_set(tp, is_blit_on_ground, true);
tp_flag_set(tp, is_blit_square_outlined, true);
tp_flag_set(tp, is_cursor, true);
tp_z_depth_set(tp, MAP_DEPTH_CURSOR);
// end sort marker1 }

Expand Down
6 changes: 3 additions & 3 deletions src/things/internal/tp_cursor_path.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ bool tp_load_cursor_path(void)
{
auto tp = tp_load("cursor_path");
// begin sort marker1 {
tp_is_blit_centered_set(tp, true);
tp_is_blit_on_ground_set(tp, true);
tp_is_cursor_path_set(tp, true);
tp_flag_set(tp, is_blit_centered, true);
tp_flag_set(tp, is_blit_on_ground, true);
tp_flag_set(tp, is_cursor_path, true);
tp_z_depth_set(tp, MAP_DEPTH_CURSOR);
// end sort marker1 }

Expand Down
6 changes: 3 additions & 3 deletions src/things/player/tp_player.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ bool tp_load_player(void)
auto tp = tp_load(name.c_str());

// begin sort marker1 {
tp_is_animated_can_hflip_set(tp, true);
tp_is_blit_on_ground_set(tp, true);
tp_is_player_set(tp, true);
tp_flag_set(tp, is_animated_can_hflip, true);
tp_flag_set(tp, is_blit_on_ground, true);
tp_flag_set(tp, is_player, true);
tp_player_index_set(tp, player - 1);
tp_z_depth_set(tp, MAP_DEPTH_PLAYER);
// end sort marker1 }
Expand Down
Loading

0 comments on commit e075dfa

Please sign in to comment.