1
0
mirror of https://github.com/zenorogue/hyperrogue.git synced 2025-09-06 12:27:57 +00:00

last_bowpath changed to more efficient bowpath_map

This commit is contained in:
Zeno Rogue
2023-10-28 08:33:18 +02:00
parent c36da1985c
commit 4f82c3eb8e
3 changed files with 73 additions and 57 deletions

View File

@@ -54,7 +54,7 @@ struct bowscore {
EX vector<bowpoint> bowpath;
EX vector<bowpoint> last_bowpath;
EX map<cell*, vector<bowpoint>> bowpath_map;
EX map<int, cell*> target_at;
@@ -170,6 +170,15 @@ EX int create_path() {
return best_score;
}
EX void clear_bowpath() {
bowpath_map.clear();
}
EX void gen_bowpath_map() {
bowpath_map = {};
for(auto& b: bowpath) bowpath_map[b.next.at].push_back(b);
}
EX bool auto_path() {
target_at = {};
target_at[1] = cwt.cpeek();
@@ -184,13 +193,13 @@ EX void switch_fire_mode() {
if(!fire_mode) {
addMessage(XLAT("Double-click tile to fire."));
fire_mode = true;
last_bowpath = {};
clear_bowpath();
targets = {};
}
else if(fire_mode) {
addMessage(XLAT("Firing cancelled."));
fire_mode = false;
last_bowpath = {};
clear_bowpath();
}
}
@@ -198,7 +207,7 @@ EX void add_fire(cell *c) {
bool emp = target_at.empty();
auto& t = target_at[c->cpdist];
if(t == c && !bow::bowpath.empty()) {
bow::last_bowpath.clear();
clear_bowpath();
checked_move_issue = miVALID;
pcmove pcm;
pcm.checkonly = false;
@@ -220,7 +229,7 @@ EX void add_fire(cell *c) {
bow::bowpath = {};
}
}
bow::last_bowpath = bow::bowpath;
gen_bowpath_map();
}
}
@@ -282,9 +291,10 @@ EX void shoot() {
}
}
}
last_bowpath = bowpath;
reverse(bowpath.begin(), bowpath.end());
gen_bowpath_map();
}
EX void showMenu() {