summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--crawl-ref/source/travel.cc59
-rw-r--r--crawl-ref/source/travel.h14
2 files changed, 68 insertions, 5 deletions
diff --git a/crawl-ref/source/travel.cc b/crawl-ref/source/travel.cc
index 663a83009c..04a8800126 100644
--- a/crawl-ref/source/travel.cc
+++ b/crawl-ref/source/travel.cc
@@ -3016,6 +3016,44 @@ void TravelCache::update_waypoints() const
}
}
+void TravelCache::delete_waypoint()
+{
+ if (!get_waypoint_count())
+ return;
+
+ while (get_waypoint_count())
+ {
+ mesclr();
+ mpr("Existing waypoints:");
+ list_waypoints();
+ mpr("Delete which waypoint? (* - delete all, Esc - exit) ",
+ MSGCH_PROMPT);
+
+ int key = getch();
+ if (key >= '0' && key <= '9')
+ {
+ key -= '0';
+ if (waypoints[key].is_valid())
+ {
+ waypoints[key].reset();
+ continue;
+ }
+ }
+ else if (key == '*')
+ {
+ for (int i = 0; i < TRAVEL_WAYPOINT_COUNT; ++i)
+ waypoints[i].reset();
+ break;
+ }
+
+ canned_msg(MSG_OK);
+ return;
+ }
+
+ mesclr();
+ mpr("All waypoints deleted. Have a nice day!");
+}
+
void TravelCache::add_waypoint(int x, int y)
{
if (you.level_type == LEVEL_LABYRINTH || you.level_type == LEVEL_ABYSS
@@ -3026,16 +3064,27 @@ void TravelCache::add_waypoint(int x, int y)
}
mesclr();
- if (get_waypoint_count())
+
+ const bool waypoints_exist = get_waypoint_count();
+ if (waypoints_exist)
{
- mpr("Existing waypoints");
+ mpr("Existing waypoints:");
list_waypoints();
}
- mpr("Assign waypoint to what number? (0-9) ", MSGCH_PROMPT);
- int keyin = get_ch();
+ mprf(MSGCH_PROMPT, "Assign waypoint to what number? (0-9%s) ",
+ waypoints_exist? ", D - delete waypoint" : "");
- if (keyin < '0' || keyin > '9') return;
+ int keyin = tolower(get_ch());
+
+ if (waypoints_exist && keyin == 'd')
+ {
+ delete_waypoint();
+ return;
+ }
+
+ if (keyin < '0' || keyin > '9')
+ return;
int waynum = keyin - '0';
diff --git a/crawl-ref/source/travel.h b/crawl-ref/source/travel.h
index 53ba304588..ebb49b69a6 100644
--- a/crawl-ref/source/travel.h
+++ b/crawl-ref/source/travel.h
@@ -162,6 +162,13 @@ public:
unsigned short packed_place() const;
std::string describe(bool long_name = false, bool with_number = true) const;
+ void reset()
+ {
+ branch = 0;
+ depth = -1;
+ level_type = LEVEL_DUNGEON;
+ }
+
bool is_valid() const
{
return (branch != -1 && depth != -1) || level_type != LEVEL_DUNGEON;
@@ -234,6 +241,12 @@ struct level_pos
return id.depth > -1 && pos.x != -1 && pos.y != -1;
}
+ void reset()
+ {
+ id.reset();
+ pos = coord_def(-1, -1);
+ }
+
void save(FILE *) const;
void load(FILE *);
};
@@ -404,6 +417,7 @@ public:
void set_level_excludes();
void add_waypoint(int x = -1, int y = -1);
+ void delete_waypoint();
unsigned char is_waypoint(const level_pos &lp) const;
void list_waypoints() const;
void travel_to_waypoint(int number);