Skip to content

Commit

Permalink
bug: do not reveal hazards if not seen yet
Browse files Browse the repository at this point in the history
  • Loading branch information
goblinhack committed Jul 13, 2023
1 parent 146df46 commit 257bf49
Show file tree
Hide file tree
Showing 6 changed files with 52 additions and 38 deletions.
6 changes: 1 addition & 5 deletions src/level_create.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -109,11 +109,7 @@ void Level::create(point3d world_at, point grid_at, uint32_t seed, int difficult
things_gc_force();

if (! cursor && player) {
if (is_hazard(player->curr_at)) {
cursor = thing_new("cursor_hazard", player->curr_at);
} else {
cursor = thing_new("cursor", player->curr_at);
}
cursor = cursor_thing_new(player->curr_at);
if (cursor) {
cursor->hide();
}
Expand Down
6 changes: 1 addition & 5 deletions src/level_cursor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -201,11 +201,7 @@ void Level::cursor_recreate(point curr_at)
game->request_destination_ok = true;
}
} else {
if (is_hazard(curr_at)) {
cursor = thing_new("cursor_hazard", curr_at);
} else {
cursor = thing_new("cursor", curr_at);
}
cursor = cursor_thing_new(curr_at);
game->request_destination_ok = true;
}

Expand Down
30 changes: 12 additions & 18 deletions src/level_cursor_path.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -269,12 +269,10 @@ bool Level::cursor_path_draw_line(Thingp it, point start, point end)
}
}

point curr_at(c.x, c.y);
if (is_hazard(curr_at)) {
thing_new("cursor_hazard_path", curr_at);
} else {
thing_new("cursor_path", curr_at);
}
//
// Create the cursor
//
cursor_path_thing_new(c);
}

pcg_random_allowed--;
Expand Down Expand Up @@ -307,12 +305,10 @@ void Level::cursor_path_draw_straight_line(Thingp it, point start, point end)
}
}

point curr_at(c.x, c.y);
if (is_hazard(curr_at)) {
thing_new("cursor_hazard_path", curr_at);
} else {
thing_new("cursor_path", curr_at);
}
//
// Create the cursor
//
cursor_path_thing_new(c);
}
pcg_random_allowed--;
}
Expand All @@ -334,12 +330,10 @@ bool Level::cursor_path_draw_line(Thingp it, const std::vector< point > &move_pa
}
}

point curr_at(c.x, c.y);
if (is_hazard(curr_at)) {
thing_new("cursor_hazard_path", curr_at);
} else {
thing_new("cursor_path", curr_at);
}
//
// Create the cursor
//
cursor_path_thing_new(c);
}
pcg_random_allowed--;
return true;
Expand Down
6 changes: 1 addition & 5 deletions src/level_tick.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -157,11 +157,7 @@ void Level::tick_(void)
// Create the cursor if not yet.
//
if (! cursor) {
if (is_hazard(player->curr_at)) {
cursor = thing_new("cursor_hazard", player->curr_at);
} else {
cursor = thing_new("cursor", player->curr_at);
}
cursor = cursor_thing_new(player->curr_at);
}

//
Expand Down
11 changes: 6 additions & 5 deletions src/my_level.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -660,6 +660,8 @@ class Level

Thingp buffbox_describe(const int slot);
Thingp buffbox_get(const int slot);
Thingp cursor_path_thing_new(point p);
Thingp cursor_thing_new(point p);
Thingp debuffbox_describe(const int slot);
Thingp debuffbox_get(const int slot);
Thingp inventory_describe(const int slot);
Expand All @@ -673,10 +675,10 @@ class Level
Thingp spellbox_get(void);
Thingp thing_find(const ThingId id);
Thingp thing_find_optional(const ThingId id);
Thingp thing_new(Tpp, const point at, Thingp owner = nullptr);
Thingp thing_new(const std::string &tp_name, Thingp owner = nullptr);
Thingp thing_new(const std::string &tp_name, const point at, Thingp owner = nullptr);
Thingp thing_find_portal_at(point at);
Thingp thing_new(const std::string &tp_name, const point at, Thingp owner = nullptr);
Thingp thing_new(const std::string &tp_name, Thingp owner = nullptr);
Thingp thing_new(Tpp, const point at, Thingp owner = nullptr);

Tpp tp_random_mob(const point p);
Tpp tp_random_mob_challenge_class_A(const point p);
Expand Down Expand Up @@ -789,12 +791,11 @@ class Level
int total_monst_dmg_level(void);
int total_loot_level(void);
int total_food_level(void);
int inventory_slot(Thingp item);

float wobble_curr(void) const;
float update_wobble(void);

int inventory_slot(Thingp item);

std::string to_string(void);

uint32_t num(void);
Expand Down
31 changes: 31 additions & 0 deletions src/thing_cursor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,42 @@
// Copyright Neil McGill, goblinhack@gmail.com
//

#include "my_array_bounds_check.hpp"
#include "my_game.hpp"
#include "my_sdl_event.hpp"
#include "my_thing.hpp"
#include "my_wid_rightbar.hpp"

//
// Highlight the cursor differently if over hazards
//
Thingp Level::cursor_path_thing_new(point p)
{
if (is_hazard(p)) {
if (get(can_see_ever.can_see, p.x, p.y)) {
return thing_new("cursor_hazard_path", p);
} else {
return thing_new("cursor_path", p);
}
}
return thing_new("cursor_path", p);
}

//
// Highlight the cursor differently if over hazards
//
Thingp Level::cursor_thing_new(point p)
{
if (is_hazard(p)) {
if (get(can_see_ever.can_see, p.x, p.y)) {
return thing_new("cursor_hazard", p);
} else {
return thing_new("cursor", p);
}
}
return thing_new("cursor", p);
}

void Thing::cursor_hover_over_check(void)
{
if (! is_blitted) {
Expand Down

0 comments on commit 257bf49

Please sign in to comment.