mirror of
https://github.com/zenorogue/hyperrogue.git
synced 2025-02-22 05:50:09 +00:00
hr_exception, currently used for build_shortest_path
This commit is contained in:
parent
a179a2b80d
commit
44495852ad
4
cell.cpp
4
cell.cpp
@ -908,7 +908,7 @@ vector<cell*> build_shortest_path(cell *c1, cell *c2) {
|
||||
while(c1 != c2) {
|
||||
p.push_back(c1);
|
||||
forCellCM(c, c1) if(celldist(c) < celldist(c1)) { c1 = c; goto next1; }
|
||||
println(hlog, "could not build_shortest_path"); exit(1);
|
||||
throw hr_shortest_path_exception();
|
||||
next1: ;
|
||||
}
|
||||
p.push_back(c1);
|
||||
@ -921,7 +921,7 @@ vector<cell*> build_shortest_path(cell *c1, cell *c2) {
|
||||
while(c1 != c2) {
|
||||
p.push_back(c1);
|
||||
forCellCM(c, c1) if(celldistance(c, c2) < celldistance(c1, c2)) { c1 = c; goto next; }
|
||||
println(hlog, "could not build_shortest_path"); exit(1);
|
||||
throw hr_shortest_path_exception();
|
||||
next: ;
|
||||
}
|
||||
p.push_back(c1);
|
||||
|
5
hyper.h
5
hyper.h
@ -79,6 +79,9 @@ using std::asinh;
|
||||
using std::acosh;
|
||||
#endif
|
||||
|
||||
struct hr_exception: std::exception { hr_exception() {} };
|
||||
struct hr_shortest_path_exception: hr_exception { };
|
||||
|
||||
// genus (in grammar)
|
||||
#define GEN_M 0
|
||||
#define GEN_F 1
|
||||
@ -4547,7 +4550,7 @@ template<class T, class U> void hread(hstream& hs, map<T,U>& a) {
|
||||
template<class C, class C1, class... CS> void hwrite(hstream& hs, const C& c, const C1& c1, const CS&... cs) { hwrite(hs, c); hwrite(hs, c1, cs...); }
|
||||
template<class C, class C1, class... CS> void hread(hstream& hs, C& c, C1& c1, CS&... cs) { hread(hs, c); hread(hs, c1, cs...); }
|
||||
|
||||
struct hstream_exception : std::exception { hstream_exception() {} };
|
||||
struct hstream_exception : hr_exception { hstream_exception() {} };
|
||||
|
||||
struct fhstream : hstream {
|
||||
FILE *f;
|
||||
|
11
racing.cpp
11
racing.cpp
@ -301,8 +301,15 @@ void generate_track() {
|
||||
}
|
||||
}
|
||||
|
||||
track = build_shortest_path(s, goal);
|
||||
|
||||
try {
|
||||
track = build_shortest_path(s, goal);
|
||||
}
|
||||
catch(hr_shortest_path_exception&) {
|
||||
addMessage("error: could not build path");
|
||||
gamegen_failure = true;
|
||||
racing::on = false;
|
||||
return;
|
||||
}
|
||||
|
||||
/*
|
||||
transmatrix At = spin(hrand(1000));
|
||||
|
Loading…
x
Reference in New Issue
Block a user