aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHolden Rohrer <hr@hrhr.dev>2021-09-01 11:17:44 -0400
committerHolden Rohrer <hr@hrhr.dev>2021-09-01 11:17:44 -0400
commit22a340479c17a6d3460b813179aee035a14e4ae2 (patch)
treed3b02c6e85e995c732b6bba471a5a2cc1bbb1835
parent9b80e6eef31b0c852c772ba6552e419856fe0aa9 (diff)
fixed bug where file saving would crash if a portal was unpaired
-rw-r--r--README1
-rw-r--r--source/app.d1
-rw-r--r--source/portals.d11
3 files changed, 7 insertions, 6 deletions
diff --git a/README b/README
index e415782..b5a9eec 100644
--- a/README
+++ b/README
@@ -22,5 +22,4 @@ This code is made available under the GPLv3 license.
## TODO
-Escape key for the save and load text queries
Multiverse!?!?
diff --git a/source/app.d b/source/app.d
index 7faaa75..ec46012 100644
--- a/source/app.d
+++ b/source/app.d
@@ -83,6 +83,7 @@ void main() {
} catch (Exception e) {
}
}
+ disp.print();
break;
case 'l':
auto filename = stdscr.readquery("Load:");
diff --git a/source/portals.d b/source/portals.d
index 7bb5dc2..000e182 100644
--- a/source/portals.d
+++ b/source/portals.d
@@ -23,10 +23,13 @@ struct Portal {
string toString(int[Portal* ] idMap)
in {
- assert(pair in idMap);
+ assert(pair == null || pair in idMap);
}
do {
- return format!`%s, %s: %d`(y, x, idMap[pair]);
+ if (pair == null)
+ return format!`%s, %s: -1`(y, x);
+ else
+ return format!`%s, %s: %d`(y, x, idMap[pair]);
}
void fromString(string s, Portal[int] portalsById) {
@@ -42,9 +45,7 @@ struct Portal {
s.formattedRead!"%d"(id);
auto p = id in portalsById;
if (p) {
- p.pairWith(this); // this is a REALLY big bug. Portal() is
- // being copied by value into the dict,
- // so it's not using its final ref.
+ p.pairWith(this);
}
}