mirror of
https://github.com/zenorogue/hyperrogue.git
synced 2025-10-27 11:57:40 +00:00
refactored check_timeout
This commit is contained in:
12
rulegen.cpp
12
rulegen.cpp
@@ -1632,9 +1632,16 @@ void clear_all() {
|
|||||||
|
|
||||||
EX int origin_id;
|
EX int origin_id;
|
||||||
|
|
||||||
|
EX unsigned start_time;
|
||||||
|
|
||||||
|
EX void check_timeout() {
|
||||||
|
if(SDL_GetTicks() > start_time + 1000 * rulegen_timeout)
|
||||||
|
throw rulegen_surrender("timeout");
|
||||||
|
}
|
||||||
|
|
||||||
EX void generate_rules() {
|
EX void generate_rules() {
|
||||||
|
|
||||||
auto t = SDL_GetTicks();
|
start_time = SDL_GetTicks();
|
||||||
delete_tmap();
|
delete_tmap();
|
||||||
|
|
||||||
if(!arb::in()) try {
|
if(!arb::in()) try {
|
||||||
@@ -1687,8 +1694,7 @@ EX void generate_rules() {
|
|||||||
important = t_origin;
|
important = t_origin;
|
||||||
|
|
||||||
while(true) {
|
while(true) {
|
||||||
if(SDL_GetTicks() > t + 1000 * rulegen_timeout)
|
check_timeout();
|
||||||
throw rulegen_surrender("timeout");
|
|
||||||
try {
|
try {
|
||||||
rules_iteration();
|
rules_iteration();
|
||||||
break;
|
break;
|
||||||
|
|||||||
Reference in New Issue
Block a user