genworld.c
changeset 5145 4c5761bb0176
parent 5048 0223e3641590
child 5155 64f930853bea
equal deleted inserted replaced
5144:4436139e3b99 5145:4c5761bb0176
   163 {
   163 {
   164 	_gw.proc = proc;
   164 	_gw.proc = proc;
   165 }
   165 }
   166 
   166 
   167 /**
   167 /**
       
   168  * Set here the function, if any, that you want to be called when landscape
       
   169  *  generation is aborted.
       
   170  */
       
   171 void GenerateWorldSetAbortCallback(gw_abort_proc *proc)
       
   172 {
       
   173 	_gw.abortp = proc;
       
   174 }
       
   175 
       
   176 /**
   168  * This will wait for the thread to finish up his work. It will not continue
   177  * This will wait for the thread to finish up his work. It will not continue
   169  *  till the work is done.
   178  *  till the work is done.
   170  */
   179  */
   171 void WaitTillGeneratedWorld(void)
   180 void WaitTillGeneratedWorld(void)
   172 {
   181 {
   198  */
   207  */
   199 void HandleGeneratingWorldAbortion(void)
   208 void HandleGeneratingWorldAbortion(void)
   200 {
   209 {
   201 	/* Clean up - in SE create an empty map, otherwise, go to intro menu */
   210 	/* Clean up - in SE create an empty map, otherwise, go to intro menu */
   202 	_switch_mode = (_game_mode == GM_EDITOR) ? SM_EDITOR : SM_MENU;
   211 	_switch_mode = (_game_mode == GM_EDITOR) ? SM_EDITOR : SM_MENU;
       
   212 
       
   213 	if (_gw.abortp != NULL) _gw.abortp();
   203 
   214 
   204 	if (_cursor.sprite == SPR_CURSOR_ZZZ) SetMouseCursor(SPR_CURSOR_MOUSE);
   215 	if (_cursor.sprite == SPR_CURSOR_ZZZ) SetMouseCursor(SPR_CURSOR_MOUSE);
   205 	/* Show all vital windows again, because we have hidden them */
   216 	/* Show all vital windows again, because we have hidden them */
   206 	if (_gw.threaded && _game_mode != GM_MENU) ShowVitalWindows();
   217 	if (_gw.threaded && _game_mode != GM_MENU) ShowVitalWindows();
   207 	_gw.active   = false;
   218 	_gw.active   = false;
   208 	_gw.thread   = NULL;
   219 	_gw.thread   = NULL;
   209 	_gw.proc     = NULL;
   220 	_gw.proc     = NULL;
       
   221 	_gw.abortp   = NULL;
   210 	_gw.threaded = false;
   222 	_gw.threaded = false;
   211 
   223 
   212 	DeleteWindowById(WC_GENERATE_PROGRESS_WINDOW, 0);
   224 	DeleteWindowById(WC_GENERATE_PROGRESS_WINDOW, 0);
   213 	MarkWholeScreenDirty();
   225 	MarkWholeScreenDirty();
   214 
   226 
   227 	_gw.mode   = mode;
   239 	_gw.mode   = mode;
   228 	_gw.size_x = size_x;
   240 	_gw.size_x = size_x;
   229 	_gw.size_y = size_y;
   241 	_gw.size_y = size_y;
   230 	_gw.active = true;
   242 	_gw.active = true;
   231 	_gw.abort  = false;
   243 	_gw.abort  = false;
       
   244 	_gw.abortp = NULL;
   232 	_gw.lp     = _local_player;
   245 	_gw.lp     = _local_player;
   233 	_gw.wait_for_draw = false;
   246 	_gw.wait_for_draw = false;
   234 	_gw.quit_thread   = false;
   247 	_gw.quit_thread   = false;
   235 	_gw.threaded      = true;
   248 	_gw.threaded      = true;
   236 
   249