Changeset - r11222:f66b1fc27a15
[Not reviewed]
master
0 6 0
yexo - 15 years ago 2009-02-25 00:14:46
yexo@openttd.org
(svn r15575) -Codechange: Rename GameModes to GameMode and store _game_mode as GameMode instead of as byte.
6 files changed with 11 insertions and 10 deletions:
0 comments (0 inline, 0 general)
src/genworld_gui.cpp
Show inline comments
 
@@ -567,57 +567,57 @@ struct GenerateLandscapeWindow : public 
 
		switch (widget) {
 
			case GLAND_MAPSIZE_X_PULLDOWN:     _settings_newgame.game_creation.map_x = index; break;
 
			case GLAND_MAPSIZE_Y_PULLDOWN:     _settings_newgame.game_creation.map_y = index; break;
 
			case GLAND_TREE_PULLDOWN:          _settings_newgame.game_creation.tree_placer = index; break;
 
			case GLAND_SMOOTHNESS_PULLDOWN:    _settings_newgame.game_creation.tgen_smoothness = index;  break;
 

	
 
			case GLAND_TOWN_PULLDOWN:
 
				IConsoleSetSetting("difficulty.number_towns", index);
 
				break;
 

	
 
			case GLAND_INDUSTRY_PULLDOWN:
 
				IConsoleSetSetting("difficulty.number_industries", index);
 
				break;
 

	
 
			case GLAND_LANDSCAPE_PULLDOWN:
 
			/* case GLAND_HEIGHTMAP_PULLDOWN: */
 
				if (mode == GLWP_HEIGHTMAP) {
 
					_settings_newgame.game_creation.heightmap_rotation = index;
 
				} else {
 
					_settings_newgame.game_creation.land_generator = index;
 
				}
 
				break;
 

	
 
			case GLAND_TERRAIN_PULLDOWN: {
 
				byte old_gm = _game_mode;
 
				GameMode old_gm = _game_mode;
 
				_game_mode = GM_MENU;
 
				IConsoleSetSetting("difficulty.terrain_type", index);
 
				_game_mode = old_gm;
 
				break;
 
			}
 

	
 
			case GLAND_WATER_PULLDOWN: {
 
				byte old_gm = _game_mode;
 
				GameMode old_gm = _game_mode;
 
				_game_mode = GM_MENU;
 
				IConsoleSetSetting("difficulty.quantity_sea_lakes", index);
 
				_game_mode = old_gm;
 
				break;
 
			}
 
		}
 
		this->SetDirty();
 
	}
 

	
 
	virtual void OnQueryTextFinished(char *str)
 
	{
 
		if (!StrEmpty(str)) {
 
			int32 value = atoi(str);
 

	
 
			switch (this->widget_id) {
 
				case GLAND_START_DATE_TEXT:
 
					this->InvalidateWidget(GLAND_START_DATE_TEXT);
 
					_settings_newgame.game_creation.starting_year = Clamp(value, MIN_YEAR, MAX_YEAR);
 
					break;
 

	
 
				case GLAND_SNOW_LEVEL_TEXT:
 
					this->InvalidateWidget(GLAND_SNOW_LEVEL_TEXT);
 
					_settings_newgame.game_creation.snow_line_height = Clamp(value, 2, MAX_SNOWLINE_HEIGHT);
 
					break;
src/gfx.cpp
Show inline comments
 
/* $Id$ */
 

	
 
/** @file gfx.cpp Handling of drawing text and other gfx related stuff. */
 

	
 
#include "stdafx.h"
 
#include "openttd.h"
 
#include "gfx_func.h"
 
#include "variables.h"
 
#include "spritecache.h"
 
#include "fontcache.h"
 
#include "genworld.h"
 
#include "zoom_func.h"
 
#include "blitter/factory.hpp"
 
#include "video/video_driver.hpp"
 
#include "strings_func.h"
 
#include "settings_type.h"
 
#include "core/alloc_func.hpp"
 
#include "core/sort_func.hpp"
 
#include "landscape_type.h"
 
#include "network/network_func.h"
 

	
 
#include "table/palettes.h"
 
#include "table/sprites.h"
 
#include "table/control_codes.h"
 

	
 
byte _dirkeys;        ///< 1 = left, 2 = up, 4 = right, 8 = down
 
bool _fullscreen;
 
CursorVars _cursor;
 
bool _ctrl_pressed;   ///< Is Ctrl pressed?
 
bool _shift_pressed;  ///< Is Shift pressed?
 
byte _fast_forward;
 
bool _left_button_down;     ///< Is left mouse button pressed?
 
bool _left_button_clicked;  ///< Is left mouse button clicked?
 
bool _right_button_down;    ///< Is right mouse button pressed?
 
bool _right_button_clicked; ///< Is right mouse button clicked?
 
DrawPixelInfo _screen;
 
bool _screen_disable_anim = false;   ///< Disable palette animation (important for 32bpp-anim blitter during giant screenshot)
 
bool _exit_game;
 
bool _networking;         ///< are we in networking mode?
 
byte _game_mode;
 
GameMode _game_mode;
 
int8 _pause_game;
 
int _pal_first_dirty;
 
int _pal_count_dirty;
 

	
 
Colour _cur_palette[256];
 
byte _stringwidth_table[FS_END][224]; ///< Cache containing width of often used characters. @see GetCharacterWidth()
 
DrawPixelInfo *_cur_dpi;
 
byte _colour_gradient[COLOUR_END][8];
 

	
 
static void GfxMainBlitter(const Sprite *sprite, int x, int y, BlitterMode mode, const SubSprite *sub = NULL);
 
static int ReallyDoDrawString(const char *string, int x, int y, TextColour colour, bool parse_string_also_when_clipped = false);
 

	
 
FontSize _cur_fontsize;
 
static FontSize _last_fontsize;
 
static uint8 _cursor_backup[64 * 64 * 4];
 

	
 
/**
 
 * The rect for repaint.
 
 *
 
 * This rectangle defines the area which should be repaint by the video driver.
 
 *
 
 * @ingroup dirty
 
 */
 
static Rect _invalid_rect;
src/network/network_client.cpp
Show inline comments
 
@@ -313,49 +313,49 @@ DEF_CLIENT_SEND_COMMAND_PARAM(PACKET_CLI
 
}
 

	
 
DEF_CLIENT_SEND_COMMAND_PARAM(PACKET_CLIENT_RCON)(const char *pass, const char *command)
 
{
 
	Packet *p = NetworkSend_Init(PACKET_CLIENT_RCON);
 
	p->Send_string(pass);
 
	p->Send_string(command);
 
	MY_CLIENT->Send_Packet(p);
 
}
 

	
 
DEF_CLIENT_SEND_COMMAND_PARAM(PACKET_CLIENT_MOVE)(CompanyID company, const char *pass)
 
{
 
	Packet *p = NetworkSend_Init(PACKET_CLIENT_MOVE);
 
	p->Send_uint8(company);
 
	p->Send_string(GenerateCompanyPasswordHash(pass));
 
	MY_CLIENT->Send_Packet(p);
 
}
 

	
 

	
 
// **********
 
// Receiving functions
 
//   DEF_CLIENT_RECEIVE_COMMAND has parameter: Packet *p
 
// **********
 

	
 
extern bool SafeSaveOrLoad(const char *filename, int mode, int newgm, Subdirectory subdir);
 
extern bool SafeSaveOrLoad(const char *filename, int mode, GameMode newgm, Subdirectory subdir);
 
extern StringID _switch_mode_errorstr;
 

	
 
DEF_CLIENT_RECEIVE_COMMAND(PACKET_SERVER_FULL)
 
{
 
	// We try to join a server which is full
 
	_switch_mode_errorstr = STR_NETWORK_ERR_SERVER_FULL;
 
	DeleteWindowById(WC_NETWORK_STATUS_WINDOW, 0);
 

	
 
	return NETWORK_RECV_STATUS_SERVER_FULL;
 
}
 

	
 
DEF_CLIENT_RECEIVE_COMMAND(PACKET_SERVER_BANNED)
 
{
 
	// We try to join a server where we are banned
 
	_switch_mode_errorstr = STR_NETWORK_ERR_SERVER_BANNED;
 
	DeleteWindowById(WC_NETWORK_STATUS_WINDOW, 0);
 

	
 
	return NETWORK_RECV_STATUS_SERVER_BANNED;
 
}
 

	
 
DEF_CLIENT_RECEIVE_COMMAND(PACKET_SERVER_COMPANY_INFO)
 
{
 
	byte company_info_version = p->Recv_uint8();
 

	
src/openttd.cpp
Show inline comments
 
@@ -823,51 +823,51 @@ static void StartScenario()
 

	
 
	_settings_game.difficulty = _settings_newgame.difficulty;
 

	
 
	/* Inititalize data */
 
	StartupEconomy();
 
	StartupCompanies();
 
	StartupEngines();
 
	StartupDisasters();
 

	
 
	SetLocalCompany(COMPANY_FIRST);
 
	_current_company = _local_company;
 
	DoCommandP(0, (_settings_client.gui.autorenew << 15 ) | (_settings_client.gui.autorenew_months << 16) | 4, _settings_client.gui.autorenew_money, CMD_SET_AUTOREPLACE);
 

	
 
	MarkWholeScreenDirty();
 
}
 

	
 
/** Load the specified savegame but on error do different things.
 
 * If loading fails due to corrupt savegame, bad version, etc. go back to
 
 * a previous correct state. In the menu for example load the intro game again.
 
 * @param filename file to be loaded
 
 * @param mode mode of loading, either SL_LOAD or SL_OLD_LOAD
 
 * @param newgm switch to this mode of loading fails due to some unknown error
 
 * @param subdir default directory to look for filename, set to 0 if not needed
 
 */
 
bool SafeSaveOrLoad(const char *filename, int mode, int newgm, Subdirectory subdir)
 
bool SafeSaveOrLoad(const char *filename, int mode, GameMode newgm, Subdirectory subdir)
 
{
 
	byte ogm = _game_mode;
 
	GameMode ogm = _game_mode;
 

	
 
	_game_mode = newgm;
 
	assert(mode == SL_LOAD || mode == SL_OLD_LOAD);
 
	switch (SaveOrLoad(filename, mode, subdir)) {
 
		case SL_OK: return true;
 

	
 
		case SL_REINIT:
 
			switch (ogm) {
 
				default:
 
				case GM_MENU:   LoadIntroGame();      break;
 
				case GM_EDITOR: MakeNewEditorWorld(); break;
 
			}
 
			return false;
 

	
 
		default:
 
			_game_mode = ogm;
 
			return false;
 
	}
 
}
 

	
 
void SwitchMode(int new_mode)
 
{
 
#ifdef ENABLE_NETWORK
 
	/* If we are saving something, the network stays in his current state */
src/openttd.h
Show inline comments
 
/* $Id$ */
 

	
 
/** @file openttd.h Some generic types. */
 

	
 
#ifndef OPENTTD_H
 
#define OPENTTD_H
 

	
 
enum GameModes {
 
enum GameMode {
 
	GM_MENU,
 
	GM_NORMAL,
 
	GM_EDITOR
 
	GM_EDITOR,
 
};
 

	
 
enum SwitchModes {
 
	SM_NONE            =  0,
 
	SM_NEWGAME         =  1,
 
	SM_EDITOR          =  2,
 
	SM_LOAD            =  3,
 
	SM_MENU            =  4,
 
	SM_SAVE            =  5,
 
	SM_GENRANDLAND     =  6,
 
	SM_LOAD_SCENARIO   =  9,
 
	SM_START_SCENARIO  = 10,
 
	SM_START_HEIGHTMAP = 11,
 
	SM_LOAD_HEIGHTMAP  = 12,
 
};
 

	
 
/* Display Options */
 
enum {
 
	DO_SHOW_TOWN_NAMES    = 0,
 
	DO_SHOW_STATION_NAMES = 1,
 
	DO_SHOW_SIGNS         = 2,
 
	DO_FULL_ANIMATION     = 3,
 
	DO_FULL_DETAIL        = 5,
 
	DO_WAYPOINTS          = 6,
 
};
 

	
 
extern byte _game_mode;
 
extern GameMode _game_mode;
 
extern bool _exit_game;
 
extern int8 _pause_game;
 

	
 
#endif /* OPENTTD_H */
src/video/dedicated_v.cpp
Show inline comments
 
@@ -104,49 +104,49 @@ static void CreateWindowsConsoleThread()
 
	/* Create event to signal when console input is ready */
 
	_hInputReady = CreateEvent(NULL, false, false, NULL);
 
	_hWaitForInputHandling = CreateEvent(NULL, false, false, NULL);
 
	if (_hInputReady == NULL || _hWaitForInputHandling == NULL) usererror("Cannot create console event!");
 

	
 
	_hThread = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)CheckForConsoleInput, NULL, 0, &dwThreadId);
 
	if (_hThread == NULL) usererror("Cannot create console thread!");
 

	
 
	DEBUG(driver, 2, "Windows console thread started");
 
}
 

	
 
static void CloseWindowsConsoleThread()
 
{
 
	CloseHandle(_hThread);
 
	CloseHandle(_hInputReady);
 
	CloseHandle(_hWaitForInputHandling);
 
	DEBUG(driver, 2, "Windows console thread shut down");
 
}
 

	
 
#endif
 

	
 

	
 
static void *_dedicated_video_mem;
 

	
 
extern bool SafeSaveOrLoad(const char *filename, int mode, int newgm, Subdirectory subdir);
 
extern bool SafeSaveOrLoad(const char *filename, int mode, GameMode newgm, Subdirectory subdir);
 
extern void SwitchMode(int new_mode);
 

	
 
static FVideoDriver_Dedicated iFVideoDriver_Dedicated;
 

	
 

	
 
const char *VideoDriver_Dedicated::Start(const char * const *parm)
 
{
 
	int bpp = BlitterFactoryBase::GetCurrentBlitter()->GetScreenDepth();
 
	if (bpp == 0) _dedicated_video_mem = NULL;
 
	else          _dedicated_video_mem = MallocT<byte>(_cur_resolution.width * _cur_resolution.height * (bpp / 8));
 

	
 
	_screen.width  = _screen.pitch = _cur_resolution.width;
 
	_screen.height = _cur_resolution.height;
 
	ScreenSizeChanged();
 

	
 
#if defined(WINCE)
 
	/* WinCE doesn't support console stuff */
 
#elif defined(WIN32)
 
	// For win32 we need to allocate a console (debug mode does the same)
 
	CreateConsole();
 
	CreateWindowsConsoleThread();
 
	SetConsoleTitle(_T("OpenTTD Dedicated Server"));
 
#endif
 

	
0 comments (0 inline, 0 general)