File diff r1961:7949b074d614 → r1962:cc4c06e3f6b5
openttd.c
Show inline comments
 
@@ -988,97 +988,97 @@ void StateGameLoop(void)
 
	//  Sidenote: _frame_counter is ONLY used for _savedump in non-MP-games
 
	//    Should that not be deleted? If so, the next 2 lines can also be deleted
 
	if (!_networking)
 
		_frame_counter++;
 

	
 
	if (_savedump_path[0] && (uint)_frame_counter >= _savedump_first && (uint)(_frame_counter -_savedump_first) % _savedump_freq == 0 ) {
 
		char buf[100];
 
		sprintf(buf, "%s%.5d.sav", _savedump_path, _frame_counter);
 
		SaveOrLoad(buf, SL_SAVE);
 
		if ((uint)_frame_counter >= _savedump_last) exit(1);
 
	}
 

	
 
	if (_game_mode == GM_EDITOR) {
 
		RunTileLoop();
 
		CallVehicleTicks();
 
		CallLandscapeTick();
 
		CallWindowTickEvent();
 
		NewsLoop();
 
	} else {
 
		// All these actions has to be done from OWNER_NONE
 
		//  for multiplayer compatibility
 
		uint p = _current_player;
 
		_current_player = OWNER_NONE;
 

	
 
		AnimateAnimatedTiles();
 
		IncreaseDate();
 
		RunTileLoop();
 
		CallVehicleTicks();
 
		CallLandscapeTick();
 

	
 
		// To bad the AI does not work in multiplayer, because states are not saved
 
		//  perfectly
 
		if (!disable_computer && !_networking)
 
			RunOtherPlayersLoop();
 

	
 
		CallWindowTickEvent();
 
		NewsLoop();
 
		_current_player = p;
 
	}
 

	
 
	_in_state_game_loop = false;
 
}
 

	
 
static void DoAutosave(void)
 
{
 
	char buf[200];
 

	
 
	if (_patches.keep_all_autosave && _local_player != OWNER_SPECTATOR) {
 
		const Player *p = DEREF_PLAYER(_local_player);
 
		const Player *p = GetPlayer(_local_player);
 
		char *s;
 
		sprintf(buf, "%s%s", _path.autosave_dir, PATHSEP);
 

	
 
		SetDParam(0, p->name_1);
 
		SetDParam(1, p->name_2);
 
		SetDParam(2, _date);
 
		s = (char*)GetString(buf + strlen(_path.autosave_dir) + strlen(PATHSEP), STR_4004);
 
		strcpy(s, ".sav");
 
	} else { /* Save a maximum of 15 autosaves */
 
		int n = _autosave_ctr;
 
		_autosave_ctr = (_autosave_ctr + 1) & 15;
 
		sprintf(buf, "%s%sautosave%d.sav", _path.autosave_dir, PATHSEP, n);
 
	}
 

	
 
	DEBUG(misc, 2) ("Autosaving to %s", buf);
 
	if (SaveOrLoad(buf, SL_SAVE) != SL_OK)
 
		ShowErrorMessage(INVALID_STRING_ID, STR_AUTOSAVE_FAILED, 0, 0);
 
}
 

	
 
static void ScrollMainViewport(int x, int y)
 
{
 
	if (_game_mode != GM_MENU) {
 
		Window *w = FindWindowById(WC_MAIN_WINDOW, 0);
 
		assert(w);
 

	
 
		WP(w,vp_d).scrollpos_x += x << w->viewport->zoom;
 
		WP(w,vp_d).scrollpos_y += y << w->viewport->zoom;
 
	}
 
}
 

	
 
static const int8 scrollamt[16][2] = {
 
	{ 0, 0},
 
	{-2, 0}, // 1:left
 
	{ 0,-2}, // 2:up
 
	{-2,-1}, // 3:left + up
 
	{ 2, 0}, // 4:right
 
	{ 0, 0}, // 5:left + right
 
	{ 2,-1}, // 6:right + up
 
	{ 0,-2}, // 7:left + right + up = up
 
	{ 0 ,2}, // 8:down
 
	{-2 ,1}, // 9:down+left
 
	{ 0, 0}, // 10:impossible
 
	{-2, 0}, // 11:left + up + down = left
 
	{ 2, 1}, // 12:down+right
 
	{ 0, 2}, // 13:left + right + down = down
 
	{ 0,-2}, // 14:left + right + up = up
 
	{ 0, 0}, // 15:impossible
 
};