Skip to content

Commit

Permalink
bug: temperature should not be the total of N torches, but that of 1 …
Browse files Browse the repository at this point in the history
…torch
  • Loading branch information
goblinhack committed Jun 16, 2023
1 parent 42bff3f commit 4d171c3
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 5 deletions.
2 changes: 0 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
<!-- Bugs -->
<!-- ------ -->
<!-- Maybe auto-pause when damage taken? (Like walking on lava) -->
<!-- I died by being burn alive by some "beacon of light" / brazier. -->
<!-- crash when falling - try to repro -->
<!-- ------ -->
<!-- -->
<!-- Performance -->
Expand Down
2 changes: 1 addition & 1 deletion build/VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export MYVER="0.0.6"
export MYVER="0.0.7"
2 changes: 1 addition & 1 deletion python/things/dungeon/rock_lava.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ def tp_init(
my.is_very_hard(self, True)
my.is_wall(self, True)
my.noise_blocker(self, True)
my.temperature(self, -100)
my.temperature(self, 100)
my.text_a_or_an(self, "the")
my.text_description_short(self, "Melting rock.")
my.tick_prio(self, my.MAP_TICK_PRIO_NORMAL)
Expand Down
7 changes: 7 additions & 0 deletions src/game_player.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,13 @@ void Game::place_player(void)
auto w = level->thing_new("axe", point(x, y));
t->carry(w, carry_options);
}
level->thing_new("torch", point(x + 1, y));
level->thing_new("torch", point(x + 1, y));
level->thing_new("torch", point(x + 1, y));
{
auto w = level->thing_new("staff_energy", point(x, y));
t->carry(w, carry_options);
}
if (1) {
auto w = level->thing_new("torch", point(x, y));
t->carry(w, carry_options);
Expand Down
18 changes: 17 additions & 1 deletion src/thing_temperature.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ void Thing::temperature_tick(void)
{
TRACE_NO_INDENT();

int location_temp_max = 0;
int location_temp_min = 0;
int location_temp = 0;
bool location_temp_set = false;

Expand Down Expand Up @@ -167,9 +169,23 @@ void Thing::temperature_tick(void)
// consider the torch.
//
if (abs(t->temperature) >= TEMPERATURE_THRESHOLD) {
location_temp += t->temperature;
if (! location_temp_max) {
location_temp_max = t->temperature;
location_temp_min = t->temperature;
} else {
location_temp_max = std::max(location_temp_max, (int) t->temperature);
location_temp_min = std::min(location_temp_min, (int) t->temperature);
}
location_temp_set = true;

if (location_temp_max && location_temp_min) {
location_temp = (location_temp_max + location_temp_min) / 2;
} else if (location_temp_max) {
location_temp = location_temp_max;
} else {
location_temp = location_temp_min;
}

dbg("Location temp now %d due to %s (%d)", location_temp, t->to_short_string().c_str(), t->temperature);

if (location_temp > TEMPERATURE_MAX) {
Expand Down

0 comments on commit 4d171c3

Please sign in to comment.