mirror of
https://github.com/zenorogue/hyperrogue.git
synced 2025-04-29 06:03:11 +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) {
|
while(c1 != c2) {
|
||||||
p.push_back(c1);
|
p.push_back(c1);
|
||||||
forCellCM(c, c1) if(celldist(c) < celldist(c1)) { c1 = c; goto next1; }
|
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: ;
|
next1: ;
|
||||||
}
|
}
|
||||||
p.push_back(c1);
|
p.push_back(c1);
|
||||||
@ -921,7 +921,7 @@ vector<cell*> build_shortest_path(cell *c1, cell *c2) {
|
|||||||
while(c1 != c2) {
|
while(c1 != c2) {
|
||||||
p.push_back(c1);
|
p.push_back(c1);
|
||||||
forCellCM(c, c1) if(celldistance(c, c2) < celldistance(c1, c2)) { c1 = c; goto next; }
|
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: ;
|
next: ;
|
||||||
}
|
}
|
||||||
p.push_back(c1);
|
p.push_back(c1);
|
||||||
|
5
hyper.h
5
hyper.h
@ -79,6 +79,9 @@ using std::asinh;
|
|||||||
using std::acosh;
|
using std::acosh;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
struct hr_exception: std::exception { hr_exception() {} };
|
||||||
|
struct hr_shortest_path_exception: hr_exception { };
|
||||||
|
|
||||||
// genus (in grammar)
|
// genus (in grammar)
|
||||||
#define GEN_M 0
|
#define GEN_M 0
|
||||||
#define GEN_F 1
|
#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 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...); }
|
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 {
|
struct fhstream : hstream {
|
||||||
FILE *f;
|
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));
|
transmatrix At = spin(hrand(1000));
|
||||||
|
Loading…
x
Reference in New Issue
Block a user