ref: 81463bbba664e4557bf242870ebbfff82efc1aa9
parent: 4eee9384335369b90b6311c1b2ddfa0cc25fa477
author: Sigrid Haflínudóttir <ftrvxmtrx@gmail.com>
date: Fri May 1 05:55:37 EDT 2020
help: correctly deal with empty/locked cells
--- a/sim.c
+++ b/sim.c
@@ -774,9 +774,9 @@
extras.oevent_list = oevent_list;
extras.random_seed = random_seed;
- const char *name = "empty", *description = "";
- strcpy(help->name, name);
- strcpy(help->description, description);
+ const char *name = NULL, *description = NULL;
+ help->name[0] = 0;
+ help->description[0] = 0;
for (Usz iy = 0; iy < height; ++iy) {
Glyph const *glyph_row = gbuf + iy * width;
@@ -810,10 +810,21 @@
#undef UNIQUE_CASE
#undef ALPHA_CASE
}
+
if (ix == help->x && iy == help->y) {
strcpy(help->name, name);
strcpy(help->description, description);
}
+ }
+ }
+
+ if (help->name[0] == 0) {
+ Mark const *mark_row = mbuf + help->y * width;
+ Mark cell_flags = mark_row[help->x];
+ if (cell_flags & (Mark_flag_lock | Mark_flag_sleep)) {
+ strcpy(help->name, "locked");
+ } else {
+ strcpy(help->name, "empty");
}
}
}