1
0
mirror of https://github.com/OpenTTD/OpenTTD.git synced 2025-08-13 09:39:10 +00:00

Compare commits

..

1 Commits

Author SHA1 Message Date
rubidium
c522789b9b (svn r23667) -Release: 1.2.0-beta1 2011-12-24 09:12:37 +00:00
373 changed files with 3720 additions and 12012 deletions

View File

@@ -93,7 +93,7 @@ FILE_PATTERNS = *.c \
RECURSIVE = YES
EXCLUDE =
EXCLUDE_SYMLINKS = NO
EXCLUDE_PATTERNS = */3rdparty */.svn */script/api
EXCLUDE_PATTERNS = */3rdparty */.svn
EXAMPLE_PATH =
EXAMPLE_PATTERNS = *
EXAMPLE_RECURSIVE = NO

View File

@@ -37,6 +37,7 @@ STAGE = !!STAGE!!
MAKEDEPEND = !!MAKEDEPEND!!
CFLAGS_MAKEDEP = !!CFLAGS_MAKEDEP!!
SORT = !!SORT!!
REVISION = !!REVISION!!
AWK = !!AWK!!
CONFIG_CACHE_COMPILER = $(SRC_OBJS_DIR)/!!CONFIG_CACHE_COMPILER!!
CONFIG_CACHE_LINKER = $(SRC_OBJS_DIR)/!!CONFIG_CACHE_LINKER!!
@@ -93,9 +94,15 @@ $(LANG_OBJS_DIR)/table/strings.h: $(LANG_DIR)/english.txt $(LANG_OBJS_DIR)/$(STR
VERSIONS := $(shell AWK="$(AWK)" "$(ROOT_DIR)/findversion.sh")
MODIFIED := $(shell echo "$(VERSIONS)" | cut -f 3 -d' ')
ifdef REVISION
# Use specified revision (which should be of the form "r000").
REV := $(REVISION)
REV_NR := $(shell echo $(REVISION) | sed "s@[^0-9]@@g")
else
# Use autodetected revisions
REV := $(shell echo "$(VERSIONS)" | cut -f 1 -d' ')
REV_NR := $(shell echo "$(VERSIONS)" | cut -f 2 -d' ')
endif
# Make sure we have something in REV and REV_NR
ifeq ($(REV),)

View File

@@ -1,66 +1,3 @@
1.2.0-beta3 (2012-01-21)
------------------------------------------------------------------------
- Feature: [NoGo] Allow to chose the goal question window's title from a (small) set of options [FS#4992] (r23827)
- Feature: [NewGRF] Enhance some fatal NewGRF errors with the spritenumber that caused the problem (r23809)
- Fix: Loading empty GS strings/translations failed [FS#4996] (r23829)
- Fix: Return early from SlString() for empty strings, before doing invalid things which surprisingly do not break everything. (r23828)
- Fix: The detailed performance rating window showed the cargo count of the current quarter instead of the last quarter like the tooltip says [FS#4972] (r23826)
- Fix: Removal of towns with 0 population failed during map generation [FS#4951] (r23819)
- Fix: [Network] Desync due to different NewGRF version at client and server [FS#4962] (r23817)
- Fix: [NewGRF] Textstack was not properly used when storing parameters for the error message window [FS#4969] (r23803)
- Fix: Game lobby gui not updated when new company information becomes available [FS#4968] (r23802)
- Fix: Reading the UTF-8 BOM from AI/GS files on big-endian machines failed (r23801)
- Fix: Move 'refitable to' text above custom newgrf text in build vehicle gui [FS#4958] (r23792)
- Fix: [NewGRF] Resize text panel for parameter description if it does not fit in 4 lines [FS#4960] (r23791)
- Fix: [NewGRF] While we can only show one error per NewGRF, fatal errors should always disable the GRF. Also give those errors precedence over other information (r23789)
- Fix: [NewGRF] Failure to load newgrf files that use action 0 general prop 15 with a missing language file (r23788)
- Fix: Crash due to genders used for station name in hangar string of Italian translation [FS#4965] (r23782)
- Fix: Under certain circumstances, e.g. a single invalid order, trying to determine the next order state could end up in an infinite loop [FS#4964] (r23781)
- Fix: [Network] Missing naming of some errors[FS#4963] (r23780)
- Fix: Trim all control codes and the likes from strings being passed into the AI. If the AI would be displaying them later we would be showing those control codes as question marks [FS#4957] (r23778)
- Fix: Hide the PCX screenshot format from the options window, if a 32bpp blitter is used (r23775)
- Fix: [NewGRF] Update all cached train properties if a train vehicle enters a new railtype (r23773)
1.2.0-beta2 (2012-01-07)
------------------------------------------------------------------------
- Feature: [NewGRF] Allow read-only display of NewGRF parameters, if GRF list may not be edited (r23760)
- Feature: [NewGRF] Alternate rail type label list (r23758)
- Feature: Make the default secondary sort method for the server list the number of clients instead of the name (r23710)
- Feature: Try harder to sort text instead of fancy characters in the server names (r23709)
- Feature: Make a distinction between fully zoomed in and default zoomed in screenshots [FS#4916] (r23695)
- Feature: Add ability to adjust brightness of colour after remapping for 32bpp sprites (r23670)
- Feature: [GS] GSGoal::Question(), to ask a question to a(ll) company(ies). It can contain random text, and at most 3 buttons from a collection of 17 (r23731)
- Feature: Australian translation (r23730)
- Fix: Make default timeouts for certain network states lower and configurable [CVE-2012-0049] [FS#4955] (r23764)
- Fix: Check whether a water tile is really empty when overbuilding it with an object [FS#4956] (r23763)
- Fix: The check for duplicate town names was not really working [FS#4951] (r23759)
- Fix: Missing locking causing crash is extreme case when being in the MP lobby [FS#4938] (r23752)
- Fix: [Win32] Work around a possible deadlock when initialising threaded drawing (r23749)
- Fix: Make vehicle variables A8 and A9 always return 0. Returning cur_image is a potential desyncer due to Action1 in static NewGRFs (r23748)
- Fix: Also set 'info' to NULL if 'instance' dies (for both AI and GS); avoids invalid memory reads (r23746)
- Fix: If autorefit fails, count the vehicle capacity nevertheless, if it is already carrying the right thing (r23745)
- Fix: [NewGRF] Check the version of the right GRF [FS#4923] (r23744)
- Fix: [NewGRF] Call CB 15E for all vehicles before actually executing any refit [FS#4906] (r23743)
- Fix: Cheating to different climates messes things even more up than changing NewGRFs in-game so it was removed [FS#4939] (r23733)
- Fix: When cheating into another company, the SignList was not updated [FS#4942] (r23728)
- Fix: Reading memory of a temporary (already deconstructed) object is invalid (r23721)
- Fix: [Script] Show the script debug window also when the game script crashes [FS#4935] (r23720)
- Fix: Extraction of music packs failed [FS#4930] (r23719)
- Fix: [AI] Rescanai caused crash when the AI settings of an AI was opened [FS#4936] (r23718)
- Fix: Ships going to wrong dock location when moving the dock while the game is paused [FS#4927] (r23717)
- Fix: The amount of goals was too low [FS#4928] (r23699)
- Fix: Hardcode the original defaults for loading old savegames if they could totally mess with the game's behaviour [FS#4859] (r23693)
- Fix: Infrastructure count of canals/locks/ship depots was not updated properly when a company went into bankruptcy or was taken over [FS#4921] (r23686)
- Fix: When fitting another engine the cargo capacity of wagons could become lower, causing them to contain more than they should. This caused the cargo transfer from the replaced parts to put even more stuff in the already full wagon. Prevent this from happening by reducing the amount of cargo in the vehicle to the capacity when moving vehicles/wagons around, or when autoreplacing [FS#4912] (r23683)
- Fix: Vehicle numbers got misaccounted when autoreplacing failed due to length checks [FS#4914] (r23681)
- Fix: [AI] Prevent removal of the (AI) company the local player is in [FS#4915] (r23680)
- Fix: [Script] Close the editbox of settings when changing an AI, to avoid invalid memory read/write (r23678)
- Fix: [Script] Invalidate AI Parameters window when changing AI [FS#4909] (r23677)
- Fix: When removing road stops the wrong tile was checked for updating the infrastructure cache [FS#4913] (r23676)
- Fix: [Script] The 'Configure' button in the 'AI / Game Configuration' window did not get enabled when activating a GameScript (r23668)
1.2.0-beta1 (2011-12-24)
------------------------------------------------------------------------
- Feature: Ability to run a game script; a script that controls some of the logic of the game, e.g. to implement goals or tutorials (r23637)
@@ -211,15 +148,6 @@
- Fix: Change the centre of train vehicles to depend on the vehicle length instead of being fixed at 4/8th of the original vehicle length to make sure shortened vehicles do not block tiles they should not block [FS#2379,FS#3569] (r23290)
1.1.5 (2012-01-14)
------------------------------------------------------------------------
- Fix: Make default timeouts for certain network states lower and configurable [CVE-2012-0049] [FS#4955] (r23764)
- Fix: Check whether a water tile is really empty when overbuilding it with an object [FS#4956] (r23763)
- Fix: Missing locking causing crash in extreme case when being in the MP lobby [FS#4938] (r23752)
- Fix: Clear the backed up orders of a removed station as well, otherwise one could create orders to a station that was never in the original backupped orders. For example a road vehicle trying to go to a buoy [FS#4876] (r23464)
- Fix: Do not assume all industries that cut trees have tile (0,0) and wait until all tiles of an industry are completed before starting to cut trees (r23458)
1.1.4 (2011-12-05)
------------------------------------------------------------------------
- Fix: Savegames made with the Catalan town name generator would trigger a 'savegame corrupt' exception [FS#4866] (r23418)

View File

@@ -32,6 +32,7 @@ set_default() {
os="DETECT"
endian="AUTO"
cpu_type="DETECT"
revision=""
config_log="config.log"
prefix_dir="/usr/local"
binary_dir="games"
@@ -106,6 +107,7 @@ set_default() {
os
endian
cpu_type
revision
config_log
prefix_dir
binary_dir
@@ -197,6 +199,8 @@ detect_params() {
--cpu-type) prev_p="cpu_type";;
--cpu-type=*) cpu_type="$optarg";;
--revision=*) revision="$optarg";;
--cc-build) prevp_p="cc_build";;
--cc-build=*) cc_build="$optarg";;
--cc-host) prevp_p="cc_host";;
@@ -1006,15 +1010,31 @@ check_params() {
fi
fi
if [ -d "$ROOT_DIR/.svn" ] && [ -n "`svn help 2>/dev/null`" ]; then
if [ -n "$revision" ]; then
log 1 "checking revision... $revision"
log 1 "WARNING: we do not advise you to use this setting"
log 1 "WARNING: in most cases it is not safe for network use"
log 1 "WARNING: USE WITH CAUTION!"
sleep 5
elif [ -f "$ROOT_DIR/version" ]; then
revision="`cat $ROOT_DIR/version`"
log 1 "checking revision... $revision"
elif [ -d "$ROOT_DIR/.svn" ] && [ -n "`svn help 2>/dev/null`" ]; then
revision=""
log 1 "checking revision... svn detection"
elif [ -d "$ROOT_DIR/.git" ] && [ -n "`git help 2>/dev/null`" ]; then
revision=""
log 1 "checking revision... git detection"
elif [ -d "$ROOT_DIR/.hg" ] && [ -n "`hg help 2>/dev/null`" ]; then
revision=""
log 1 "checking revision... hg detection"
elif [ -f "$ROOT_DIR/.ottdrev" ]; then
revision=""
log 1 "checking revision... source tarball"
else
revision=""
log 1 "checking revision... no detection"
log 1 "WARNING: there is no means to determine the version."
log 1 "WARNING: please use a subversion, mercurial, or git checkout of OpenTTD."
@@ -3225,6 +3245,7 @@ make_sed() {
s@!!SRCS!!@$SRCS@g;
s@!!OS!!@$os@g;
s@!!CONFIGURE_FILES!!@$CONFIGURE_FILES@g;
s@!!REVISION!!@$revision@g;
s@!!AWK!!@$awk@g;
s@!!DISTCC!!@$distcc@g;
s@!!NFORENUM!!@$nforenum@g;
@@ -3447,6 +3468,8 @@ showhelp() {
echo " MORPHOS/HPUX/BEOS/SUNOS/CYGWIN/MINGW/OS2/"
echo " DOS/WINCE/PSP/HAIKU"
echo " --endian=ENDIAN set the endian of the HOST (AUTO/LE/BE)"
echo " --revision=rXXXX overwrite the revision detection."
echo " Use with care!"
echo ""
echo "Paths:"
echo " --prefix-dir=dir specifies the prefix for all installed"

View File

@@ -1,6 +1,6 @@
OpenTTD's known bugs
Last updated: 2012-01-07
Release version: 1.2.0-beta2
Last updated: 2011-12-24
Release version: 1.2.0-beta1
------------------------------------------------------------------------

View File

@@ -1,20 +1,8 @@
openttd (1.2.0~beta3) unstable; urgency=low
* New upstream release 1.2.0-beta3
-- Matthijs Kooijman <matthijs@stdin.nl> Sat, 21 Jan 2012 16:00:00 +0100
openttd (1.2.0~beta2) unstable; urgency=low
* New upstream release 1.2.0-beta2
-- Matthijs Kooijman <matthijs@stdin.nl> Sat, 07 Jan 2012 00:00:00 +0100
openttd (1.2.0~beta1) unstable; urgency=low
* New upstream release 1.2.0-beta1
-- Matthijs Kooijman <matthijs@stdin.nl> Sat, 24 Dec 2011 00:00:00 +0100
-- Matthijs Kooijman <matthijs@stdin.nl> Fri, 24 Dec 2011 00:00:00 +0100
openttd (1.1.4) unstable; urgency=low

View File

@@ -1,9 +1,9 @@
@echo off
set OPENTTD_VERSION=1.2.0-beta3
set OPENTTD_VERSION=1.2.0-beta1
set OPENSFX_VERSION=0.8.0
set NOSOUND_VERSION=0.8.0
set OPENGFX_VERSION=1.2.0
set OPENGFX_VERSION=0.7.0
echo To make the installer, you must have the WarpIN compiler (wic) installed and in
echo your path, as well as wget and unzip. This file will download the various DLLs

View File

@@ -2,8 +2,8 @@
!define APPV_MAJOR 1
!define APPV_MINOR 2
!define APPV_MAINT 0
!define APPV_BUILD 2
!define APPV_EXTRA "-beta3"
!define APPV_BUILD 0
!define APPV_EXTRA "-beta1"
!define APPNAME "OpenTTD" ; Define application name
!define APPVERSION "${APPV_MAJOR}.${APPV_MINOR}.${APPV_MAINT}${APPV_EXTRA}" ; Define application version
@@ -14,7 +14,7 @@
!define APPURLLINK "http://www.openttd.org"
!define APPNAMEANDVERSION "${APPNAME} ${APPVERSION}"
!define OPENGFX_BASE_VERSION "1.2.0"
!define OPENGFX_BASE_VERSION "0.7.0"
!define OPENSFX_BASE_VERSION "0.8.0"
!define OPENMSX_BASE_VERSION "1.0.0"

View File

@@ -107,12 +107,6 @@
<AdditionalInputs Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">..\src\lang\english.txt;..\objs\strgen\strgen.exe;%(AdditionalInputs)</AdditionalInputs>
<Outputs Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">..\bin\lang\dutch.lng;%(Outputs)</Outputs>
</CustomBuild>
<CustomBuild Include="..\src\lang\english_AU.txt">
<Message Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Generating english_AU language file</Message>
<Command Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">..\objs\strgen\strgen.exe -s ..\src\lang -d ..\bin\lang "%(FullPath)"</Command>
<AdditionalInputs Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">..\src\lang\english.txt;..\objs\strgen\strgen.exe;%(AdditionalInputs)</AdditionalInputs>
<Outputs Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">..\bin\lang\english_AU.lng;%(Outputs)</Outputs>
</CustomBuild>
<CustomBuild Include="..\src\lang\english_US.txt">
<Message Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Generating english_US language file</Message>
<Command Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">..\objs\strgen\strgen.exe -s ..\src\lang -d ..\bin\lang "%(FullPath)"</Command>

View File

@@ -37,9 +37,6 @@
<CustomBuild Include="..\src\lang\dutch.txt">
<Filter>Translations</Filter>
</CustomBuild>
<CustomBuild Include="..\src\lang\english_AU.txt">
<Filter>Translations</Filter>
</CustomBuild>
<CustomBuild Include="..\src\lang\english_US.txt">
<Filter>Translations</Filter>
</CustomBuild>

View File

@@ -213,21 +213,6 @@
/>
</FileConfiguration>
</File>
<File
RelativePath="..\src\lang\english_AU.txt"
>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCustomBuildTool"
Description="Generating english_AU language file"
CommandLine="..\objs\strgen\strgen.exe -s ..\src\lang -d ..\bin\lang &quot;$(InputPath)&quot;&#x0D;&#x0A;exit 0&#x0D;&#x0A;"
AdditionalDependencies="..\src\lang\english.txt;..\objs\strgen\strgen.exe"
Outputs="..\bin\lang\english_AU.lng"
/>
</FileConfiguration>
</File>
<File
RelativePath="..\src\lang\english_US.txt"
>

View File

@@ -214,21 +214,6 @@
/>
</FileConfiguration>
</File>
<File
RelativePath="..\src\lang\english_AU.txt"
>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCustomBuildTool"
Description="Generating english_AU language file"
CommandLine="..\objs\strgen\strgen.exe -s ..\src\lang -d ..\bin\lang &quot;$(InputPath)&quot;&#x0D;&#x0A;exit 0&#x0D;&#x0A;"
AdditionalDependencies="..\src\lang\english.txt;..\objs\strgen\strgen.exe"
Outputs="..\bin\lang\english_AU.lng"
/>
</FileConfiguration>
</File>
<File
RelativePath="..\src\lang\english_US.txt"
>

View File

@@ -1,6 +1,6 @@
OpenTTD readme
Last updated: 2012-01-21
Release version: 1.2.0-beta3
Last updated: 2011-12-24
Release version: 1.2.0-beta1
------------------------------------------------------------------------
@@ -262,7 +262,7 @@ system:
directory if it is your personal directory, i.e. "~/", or when it is the
root directory, i.e. "/".
2. Your personal directory
Windows: C:\My Documents\OpenTTD (95, 98, ME)
Windows: C:\My Documents (95, 98, ME)
C:\Documents and Settings\<username>\My Documents\OpenTTD (2000, XP)
C:\Users\<username>\Documents\OpenTTD (Vista, 7)
Mac OSX: ~/Documents/OpenTTD
@@ -292,8 +292,6 @@ OpenTTD directory:
Music Sets: baseset (or a subdirectory thereof)
AIs: ai (or a subdirectory thereof)
AI Libraries: ai/libraries (or a subdirectory thereof)
Game Scripts (GS): game (or a subdirectory thereof)
GS Libraries: game/libraries (or a subdirectory thereof)
Savegames: save
Automatic Savegames: save/autosave
Scenarios: scenario

View File

@@ -183,7 +183,7 @@ typedef char SQChar;
#define scstrdup strdup
#define scstrrchr strrchr
#define scstrcat strcat
#define MAX_CHAR 0xFFFF
#define MAX_CHAR 0xFF
#endif
#define SQUIRREL_VERSION _SC("Squirrel 2.2.5 stable - With custom OpenTTD modifications")

View File

@@ -2,7 +2,11 @@
#ifndef _SQLEXER_H_
#define _SQLEXER_H_
typedef unsigned short LexChar;
#ifdef SQUNICODE
typedef SQChar LexChar;
#else
typedef unsigned char LexChar;
#endif
struct SQLexer
{

View File

@@ -13,6 +13,7 @@
#define AI_HPP
#include "../script/api/script_event_types.hpp"
#include "../date_type.h"
#include "../core/string_compare_type.hpp"
#include <map>

View File

@@ -11,6 +11,7 @@
#include "../stdafx.h"
#include "../settings_type.h"
#include "../core/random_func.hpp"
#include "ai.hpp"
#include "ai_config.hpp"
#include "ai_info.hpp"

View File

@@ -13,7 +13,6 @@
#define AI_CONFIG_HPP
#include "../script/script_config.hpp"
#include "../company_type.h"
class AIConfig : public ScriptConfig {
public:

View File

@@ -16,11 +16,15 @@
#include "../company_func.h"
#include "../network/network.h"
#include "../window_func.h"
#include "../command_func.h"
#include "../fileio_func.h"
#include "ai_scanner.hpp"
#include "ai_instance.hpp"
#include "ai_config.hpp"
#include "ai_info.hpp"
#include "ai.hpp"
#include "../script/script_storage.hpp"
#include "../script/api/script_error.hpp"
/* static */ uint AI::frame_counter = 0;
/* static */ AIScannerInfo *AI::scanner_info = NULL;
@@ -104,7 +108,6 @@
delete c->ai_instance;
c->ai_instance = NULL;
c->ai_info = NULL;
cur_company.Restore();
@@ -330,7 +333,7 @@
InvalidateWindowData(WC_AI_LIST, 0, 1);
SetWindowClassesDirty(WC_AI_DEBUG);
InvalidateWindowClassesData(WC_AI_SETTINGS);
SetWindowDirty(WC_AI_SETTINGS, 0);
}
#if defined(ENABLE_NETWORK)

View File

@@ -7,13 +7,14 @@
* See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
*/
/** @file ai_gui.cpp %Window for configuring the AIs */
/** @file ai_gui.cpp Window for configuring the AIs */
#include "../stdafx.h"
#include "../table/sprites.h"
#include "../error.h"
#include "../gui.h"
#include "../querystring_gui.h"
#include "../company_func.h"
#include "../company_base.h"
#include "../company_gui.h"
#include "../strings_func.h"
@@ -23,6 +24,7 @@
#include "../network/network.h"
#include "../settings_func.h"
#include "../network/network_content.h"
#include "../core/backup_type.hpp"
#include "ai.hpp"
#include "../script/api/script_log.hpp"
@@ -34,6 +36,7 @@
#include "../game/game_info.hpp"
#include "../game/game_instance.hpp"
#include "../widgets/ai_widget.h"
#include "table/strings.h"
@@ -169,9 +172,7 @@ struct AIListWindow : public Window {
for (int i = 0; i < this->selected; i++) it++;
GetConfig(slot)->Change((*it).second->GetName(), (*it).second->GetVersion());
}
InvalidateWindowData(WC_GAME_OPTIONS, WN_GAME_OPTIONS_AI);
InvalidateWindowClassesData(WC_AI_SETTINGS);
DeleteWindowByClass(WC_QUERY_STRING);
SetWindowDirty(WC_GAME_OPTIONS, WN_GAME_OPTIONS_AI);
}
virtual void OnClick(Point pt, int widget, int click_count)
@@ -384,7 +385,7 @@ struct AISettingsWindow : public Window {
}
if ((config_item.flags & SCRIPTCONFIG_BOOLEAN) != 0) {
DrawBoolButton(buttons_left, y + 2, current_value != 0, editable);
DrawFrameRect(buttons_left, y + 2, buttons_left + 19, y + 10, (current_value != 0) ? COLOUR_GREEN : COLOUR_RED, (current_value != 0) ? FR_LOWERED : FR_NONE);
SetDParam(idx++, current_value == 0 ? STR_CONFIG_SETTING_OFF : STR_CONFIG_SETTING_ON);
} else {
DrawArrowButtons(buttons_left, y + 2, COLOUR_YELLOW, (this->clicked_button == i) ? 1 + (this->clicked_increase != rtl) : 0, editable && current_value > config_item.min_value, editable && current_value < config_item.max_value);
@@ -1318,9 +1319,4 @@ void ShowAIDebugWindowIfAIError()
break;
}
}
GameInstance *g = Game::GetGameInstance();
if (g != NULL && g->IsDead()) {
ShowAIDebugWindow(OWNER_DEITY);
}
}

View File

@@ -7,7 +7,7 @@
* See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
*/
/** @file ai_gui.hpp %Window for configuring the AIs */
/** @file ai_gui.hpp Window for configuring the AIs */
#ifndef AI_GUI_HPP
#define AI_GUI_HPP

View File

@@ -11,11 +11,14 @@
#include "../stdafx.h"
#include "../script/squirrel_helper.hpp"
#include "../script/squirrel_class.hpp"
#include "ai_info.hpp"
#include "ai_scanner.hpp"
#include "../settings_type.h"
#include "../debug.h"
#include "../rev.h"
#include "ai.hpp"
/**
* Check if the API version provided by the AI is supported.

View File

@@ -13,6 +13,7 @@
#define AI_INFO_HPP
#include "../script/script_info.hpp"
#include "../script/script_config.hpp"
/** All static information from an AI like name, version, etc. */
class AIInfo : public ScriptInfo {

View File

@@ -11,6 +11,7 @@
#include "../stdafx.h"
#include "../debug.h"
#include "../saveload/saveload.h"
#include "../error.h"
#include "../script/squirrel_class.hpp"
@@ -19,6 +20,8 @@
#include "ai_gui.hpp"
#include "ai.hpp"
#include "../script/script_fatalerror.hpp"
#include "../script/script_suspend.hpp"
#include "../script/script_storage.hpp"
#include "ai_info.hpp"
#include "ai_instance.hpp"

View File

@@ -12,6 +12,7 @@
#ifndef AI_INSTANCE_HPP
#define AI_INSTANCE_HPP
#include <squirrel.h>
#include "../script/script_instance.hpp"
/** Runtime information about an AI like a pointer to the squirrel vm and the current state. */

View File

@@ -11,12 +11,14 @@
#include "../stdafx.h"
#include "../debug.h"
#include "../fileio_func.h"
#include "../network/network.h"
#include "../core/random_func.hpp"
#include "../script/squirrel_class.hpp"
#include "ai_info.hpp"
#include "ai_scanner.hpp"
#include "../script/api/script_controller.hpp"
AIScannerInfo::AIScannerInfo() :

View File

@@ -16,6 +16,7 @@
#include "aircraft.h"
#include "landscape.h"
#include "news_func.h"
#include "vehicle_gui.h"
#include "newgrf_engine.h"
#include "newgrf_sound.h"
#include "spritecache.h"
@@ -313,8 +314,8 @@ CommandCost CmdBuildAircraft(TileIndex tile, DoCommandFlag flags, const Engine *
UpdateAircraftCache(v, true);
VehicleUpdatePosition(v);
VehicleUpdatePosition(u);
VehicleMove(v, false);
VehicleMove(u, false);
/* Aircraft with 3 vehicles (chopper)? */
if (v->subtype == AIR_HELICOPTER) {
@@ -335,7 +336,7 @@ CommandCost CmdBuildAircraft(TileIndex tile, DoCommandFlag flags, const Engine *
w->UpdateDeltaXY(INVALID_DIR);
u->SetNext(w);
VehicleUpdatePosition(w);
VehicleMove(w, false);
}
}
@@ -463,7 +464,7 @@ static void HelicopterTickHandler(Aircraft *v)
u->cur_image = img;
VehicleUpdatePositionAndViewport(u);
VehicleMove(u, true);
}
/**
@@ -479,7 +480,6 @@ void SetAircraftPosition(Aircraft *v, int x, int y, int z)
v->y_pos = y;
v->z_pos = z;
VehicleUpdatePosition(v);
v->UpdateViewport(true, false);
if (v->subtype == AIR_HELICOPTER) v->Next()->Next()->cur_image = GetRotorImage(v, EIT_ON_MAP);
@@ -494,7 +494,7 @@ void SetAircraftPosition(Aircraft *v, int x, int y, int z)
u->z_pos = GetSlopePixelZ(safe_x, safe_y);
u->cur_image = v->cur_image;
VehicleUpdatePositionAndViewport(u);
VehicleMove(u, true);
u = u->Next();
if (u != NULL) {
@@ -502,7 +502,7 @@ void SetAircraftPosition(Aircraft *v, int x, int y, int z)
u->y_pos = y;
u->z_pos = z + ROTOR_Z_OFFSET;
VehicleUpdatePositionAndViewport(u);
VehicleMove(u, true);
}
}

View File

@@ -201,7 +201,7 @@ static AirportFTA *AirportBuildAutomata(uint nofelements, const AirportFTAbuildu
/**
* Get the finite state machine of an airport type.
* @param airport_type %Airport type to query FTA from. @see AirportTypes
* @param airport_type Airport type to query FTA from. @see AirportTypes
* @return Finite state machine of the airport.
*/
const AirportFTAClass *GetAirport(const byte airport_type)

View File

@@ -71,7 +71,7 @@ enum AirportMovementStates {
STARTTAKEOFF = 11, ///< Airplane has arrived at a runway for take-off.
ENDTAKEOFF = 12, ///< Airplane has reached end-point of the take-off runway.
HELITAKEOFF = 13, ///< Helicopter wants to leave the airport.
FLYING = 14, ///< %Vehicle is flying in the air.
FLYING = 14, ///< Vehicle is flying in the air.
LANDING = 15, ///< Airplane wants to land.
ENDLANDING = 16, ///< Airplane wants to finish landing.
HELILANDING = 17, ///< Helicopter wants to land.
@@ -172,7 +172,7 @@ public:
const AirportMovingData *moving_data; ///< Movement data.
struct AirportFTA *layout; ///< state machine for airport
const byte *terminals; ///< %Array with the number of terminal groups, followed by the number of terminals in each group.
const byte *terminals; ///< Array with the number of terminal groups, followed by the number of terminals in each group.
const byte num_helipads; ///< Number of helipads on this airport. When 0 helicopters will go to normal terminals.
Flags flags; ///< Flags for this airport type.
byte nofelements; ///< number of positions the airport consists of

View File

@@ -27,9 +27,11 @@
#include "core/geometry_func.hpp"
#include "hotkeys.h"
#include "vehicle_func.h"
#include "sprite.h"
#include "widgets/airport_widget.h"
#include "table/strings.h"
static AirportClassID _selected_airport_class; ///< the currently visible airport class
static int _selected_airport_index; ///< the index of the selected airport in the current class or -1

View File

@@ -7,7 +7,7 @@
* See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
*/
/** @file animated_tile_func.h %Tile animation! */
/** @file animated_tile_func.h Tile animation! */
#ifndef ANIMATED_TILE_FUNC_H
#define ANIMATED_TILE_FUNC_H

View File

@@ -18,6 +18,7 @@
#include "newgrf.h"
#include "table/strings.h"
#include "table/sprites.h"
static const uint MAX_ARTICULATED_PARTS = 100; ///< Maximum of articulated parts per vehicle, i.e. when to abort calling the articulated vehicle callback.
@@ -396,6 +397,6 @@ void AddArticulatedParts(Vehicle *first)
if (flip_image) v->spritenum++;
VehicleUpdatePosition(v);
VehicleMove(v, false);
}
}

View File

@@ -17,6 +17,7 @@
#include "vehicle_func.h"
#include "autoreplace_func.h"
#include "autoreplace_gui.h"
#include "group.h"
#include "articulated_vehicles.h"
#include "core/random_func.hpp"
@@ -88,33 +89,6 @@ bool CheckAutoreplaceValidity(EngineID from, EngineID to, CompanyID company)
return EnginesHaveCargoInCommon(from, to);
}
/**
* Check the capacity of all vehicles in a chain and spread cargo if needed.
* @param v The vehicle to check.
*/
void CheckCargoCapacity(Vehicle *v)
{
assert(v == NULL || v->First() == v);
for (Vehicle *src = v; src != NULL; src = src->Next()) {
/* Do we need to more cargo away? */
if (src->cargo.Count() <= src->cargo_cap) continue;
/* We need to move a particular amount. Try that on the other vehicles. */
uint to_spread = src->cargo.Count() - src->cargo_cap;
for (Vehicle *dest = v; dest != NULL && to_spread != 0; dest = dest->Next()) {
if (dest->cargo.Count() >= dest->cargo_cap || dest->cargo_type != src->cargo_type) continue;
uint amount = min(to_spread, dest->cargo_cap - dest->cargo.Count());
src->cargo.MoveTo(&dest->cargo, amount, VehicleCargoList::MTA_UNLOAD, NULL);
to_spread -= amount;
}
/* Any left-overs will be thrown away, but not their feeder share. */
src->cargo.Truncate(src->cargo_cap);
}
}
/**
* Transfer cargo from a single (articulated )old vehicle to the new vehicle chain
* @param old_veh Old vehicle that will be sold
@@ -323,7 +297,7 @@ static inline CommandCost CmdStartStopVehicle(const Vehicle *v, bool evaluate_ca
*/
static inline CommandCost CmdMoveVehicle(const Vehicle *v, const Vehicle *after, DoCommandFlag flags, bool whole_chain)
{
return DoCommand(0, v->index | (whole_chain ? 1 : 0) << 20, after != NULL ? after->index : INVALID_VEHICLE, flags | DC_NO_CARGO_CAP_CHECK, CMD_MOVE_RAIL_VEHICLE);
return DoCommand(0, v->index | (whole_chain ? 1 : 0) << 20, after != NULL ? after->index : INVALID_VEHICLE, flags, CMD_MOVE_RAIL_VEHICLE);
}
/**
@@ -577,8 +551,6 @@ static CommandCost ReplaceChain(Vehicle **chain, DoCommandFlag flags, bool wagon
if (i == 0) old_head = NULL;
}
}
if ((flags & DC_EXEC) != 0) CheckCargoCapacity(new_head);
}
/* If we are not in DC_EXEC undo everything, i.e. rearrange old vehicles.

View File

@@ -14,6 +14,8 @@
#include "command_type.h"
#include "company_base.h"
#include "engine_type.h"
#include "group_type.h"
void RemoveAllEngineReplacement(EngineRenewList *erl);
EngineID EngineReplacement(EngineRenewList erl, EngineID engine, GroupID group);

View File

@@ -13,6 +13,7 @@
#include "command_func.h"
#include "vehicle_gui.h"
#include "newgrf_engine.h"
#include "group.h"
#include "rail.h"
#include "strings_func.h"
#include "window_func.h"
@@ -27,6 +28,7 @@
#include "widgets/autoreplace_widget.h"
#include "table/strings.h"
uint GetEngineListHeight(VehicleType type);
void DrawEngineList(VehicleType type, int x, int r, int y, const GUIEngineList *eng_list, uint16 min, uint16 max, EngineID selected_id, bool show_count, GroupID selected_group);

View File

@@ -14,6 +14,7 @@
#include "company_func.h"
#include "depot_func.h"
#include "slope_func.h"
#include "tile_map.h"
/**

View File

@@ -10,6 +10,7 @@
/** @file 32bpp_anim.cpp Implementation of the optimized 32 bpp blitter with animation support. */
#include "../stdafx.h"
#include "../core/math_func.hpp"
#include "../video/video_driver.hpp"
#include "32bpp_anim.hpp"
@@ -24,27 +25,27 @@ inline void Blitter_32bppAnim::Draw(const Blitter::BlitterParams *bp, ZoomLevel
const SpriteData *src = (const SpriteData *)bp->sprite;
const Colour *src_px = (const Colour *)(src->data + src->offset[zoom][0]);
const uint16 *src_n = (const uint16 *)(src->data + src->offset[zoom][1]);
const uint8 *src_n = (const uint8 *)(src->data + src->offset[zoom][1]);
for (uint i = bp->skip_top; i != 0; i--) {
src_px = (const Colour *)((const byte *)src_px + *(const uint32 *)src_px);
src_n = (const uint16 *)((const byte *)src_n + *(const uint32 *)src_n);
src_n += *(const uint32 *)src_n;
}
uint32 *dst = (uint32 *)bp->dst + bp->top * bp->pitch + bp->left;
uint16 *anim = this->anim_buf + ((uint32 *)bp->dst - (uint32 *)_screen.dst_ptr) + bp->top * this->anim_buf_width + bp->left;
uint8 *anim = this->anim_buf + ((uint32 *)bp->dst - (uint32 *)_screen.dst_ptr) + bp->top * this->anim_buf_width + bp->left;
const byte *remap = bp->remap; // store so we don't have to access it via bp everytime
for (int y = 0; y < bp->height; y++) {
uint32 *dst_ln = dst + bp->pitch;
uint16 *anim_ln = anim + this->anim_buf_width;
uint8 *anim_ln = anim + this->anim_buf_width;
const Colour *src_px_ln = (const Colour *)((const byte *)src_px + *(const uint32 *)src_px);
src_px++;
const uint16 *src_n_ln = (const uint16 *)((const byte *)src_n + *(const uint32 *)src_n);
src_n += 2;
const uint8 *src_n_ln = src_n + *(const uint32 *)src_n;
src_n += 4;
uint32 *dst_end = dst + bp->skip_left;
@@ -105,9 +106,9 @@ inline void Blitter_32bppAnim::Draw(const Blitter::BlitterParams *bp, ZoomLevel
*dst = src_px->data;
*anim = 0;
} else {
uint r = remap[GB(m, 0, 8)];
*anim = r | (m & 0xFF00);
if (r != 0) *dst = this->AdjustBrightness(this->LookupColourInPalette(r), GB(m, 8, 8));
uint r = remap[m];
*anim = r;
if (r != 0) *dst = this->LookupColourInPalette(r);
}
anim++;
dst++;
@@ -121,9 +122,9 @@ inline void Blitter_32bppAnim::Draw(const Blitter::BlitterParams *bp, ZoomLevel
*dst = ComposeColourRGBANoCheck(src_px->r, src_px->g, src_px->b, src_px->a, *dst);
*anim = 0;
} else {
uint r = remap[GB(m, 0, 8)];
uint r = remap[m];
*anim = 0;
if (r != 0) *dst = ComposeColourPANoCheck(this->AdjustBrightness(this->LookupColourInPalette(r), GB(m, 8, 8)), src_px->a, *dst);
if (r != 0) *dst = ComposeColourPANoCheck(this->LookupColourInPalette(r), src_px->a, *dst);
}
anim++;
dst++;
@@ -144,14 +145,14 @@ inline void Blitter_32bppAnim::Draw(const Blitter::BlitterParams *bp, ZoomLevel
src_px += n;
do {
*dst = MakeTransparent(*dst, 3, 4);
*anim = 0;
*anim = remap[*anim];
anim++;
dst++;
} while (--n != 0);
} else {
do {
*dst = MakeTransparent(*dst, (256 * 4 - src_px->a), 256 * 4);
*anim = 0;
*anim = remap[*anim];
anim++;
dst++;
src_px++;
@@ -163,25 +164,23 @@ inline void Blitter_32bppAnim::Draw(const Blitter::BlitterParams *bp, ZoomLevel
if (src_px->a == 255) {
do {
/* Compiler assumes pointer aliasing, can't optimise this on its own */
uint m = GB(*src_n, 0, 8);
uint m = *src_n++;
/* Above PALETTE_ANIM_START is palette animation */
*anim++ = *src_n;
*dst++ = (m >= PALETTE_ANIM_START) ? this->AdjustBrightness(this->LookupColourInPalette(m), GB(*src_n, 8, 8)) : src_px->data;
*anim++ = m;
*dst++ = (m >= PALETTE_ANIM_START) ? this->LookupColourInPalette(m) : src_px->data;
src_px++;
src_n++;
} while (--n != 0);
} else {
do {
uint m = GB(*src_n, 0, 8);
uint m = *src_n++;
*anim++ = 0;
if (m >= PALETTE_ANIM_START) {
*dst = ComposeColourPANoCheck(this->AdjustBrightness(this->LookupColourInPalette(m), GB(*src_n, 8, 8)), src_px->a, *dst);
*dst = ComposeColourPANoCheck(this->LookupColourInPalette(m), src_px->a, *dst);
} else {
*dst = ComposeColourRGBANoCheck(src_px->r, src_px->g, src_px->b, src_px->a, *dst);
}
dst++;
src_px++;
src_n++;
} while (--n != 0);
}
break;
@@ -220,7 +219,7 @@ void Blitter_32bppAnim::DrawColourMappingRect(void *dst, int width, int height,
}
uint32 *udst = (uint32 *)dst;
uint16 *anim;
uint8 *anim;
anim = this->anim_buf + ((uint32 *)dst - (uint32 *)_screen.dst_ptr);
@@ -260,7 +259,7 @@ void Blitter_32bppAnim::SetPixel(void *video, int x, int y, uint8 colour)
/* Set the colour in the anim-buffer too, if we are rendering to the screen */
if (_screen_disable_anim) return;
this->anim_buf[((uint32 *)video - (uint32 *)_screen.dst_ptr) + x + y * this->anim_buf_width] = colour | (DEFAULT_BRIGHTNESS << 8);
this->anim_buf[((uint32 *)video - (uint32 *)_screen.dst_ptr) + x + y * this->anim_buf_width] = colour;
}
void Blitter_32bppAnim::DrawRect(void *video, int width, int height, uint8 colour)
@@ -272,18 +271,18 @@ void Blitter_32bppAnim::DrawRect(void *video, int width, int height, uint8 colou
}
uint32 colour32 = LookupColourInPalette(colour);
uint16 *anim_line;
uint8 *anim_line;
anim_line = ((uint32 *)video - (uint32 *)_screen.dst_ptr) + this->anim_buf;
do {
uint32 *dst = (uint32 *)video;
uint16 *anim = anim_line;
uint8 *anim = anim_line;
for (int i = width; i > 0; i--) {
*dst = colour32;
/* Set the colour in the anim-buffer too */
*anim = colour | (DEFAULT_BRIGHTNESS << 8);
*anim = colour;
dst++;
anim++;
}
@@ -298,19 +297,19 @@ void Blitter_32bppAnim::CopyFromBuffer(void *video, const void *src, int width,
assert(video >= _screen.dst_ptr && video <= (uint32 *)_screen.dst_ptr + _screen.width + _screen.height * _screen.pitch);
uint32 *dst = (uint32 *)video;
const uint32 *usrc = (const uint32 *)src;
uint16 *anim_line = ((uint32 *)video - (uint32 *)_screen.dst_ptr) + this->anim_buf;
uint8 *anim_line = ((uint32 *)video - (uint32 *)_screen.dst_ptr) + this->anim_buf;
for (; height > 0; height--) {
/* We need to keep those for palette animation. */
uint32 *dst_pal = dst;
uint16 *anim_pal = anim_line;
uint8 *anim_pal = anim_line;
memcpy(dst, usrc, width * sizeof(uint32));
usrc += width;
dst += _screen.pitch;
/* Copy back the anim-buffer */
memcpy(anim_line, usrc, width * sizeof(uint16));
usrc = (const uint32 *)((const uint16 *)usrc + width);
memcpy(anim_line, usrc, width * sizeof(uint8));
usrc = (const uint32 *)((const uint8 *)usrc + width);
anim_line += this->anim_buf_width;
/* Okay, it is *very* likely that the image we stored is using
@@ -321,10 +320,10 @@ void Blitter_32bppAnim::CopyFromBuffer(void *video, const void *src, int width,
* for just the cursor. This just copies the implementation of
* palette animation, much cheaper though slightly nastier. */
for (int i = 0; i < width; i++) {
uint colour = GB(*anim_pal, 0, 8);
if (colour >= PALETTE_ANIM_START) {
uint colour = *anim_pal;
if (IsInsideBS(colour, PALETTE_ANIM_START, PALETTE_ANIM_SIZE)) {
/* Update this pixel */
*dst_pal = this->AdjustBrightness(LookupColourInPalette(colour), GB(*anim_pal, 8, 8));
*dst_pal = LookupColourInPalette(colour);
}
dst_pal++;
anim_pal++;
@@ -338,7 +337,7 @@ void Blitter_32bppAnim::CopyToBuffer(const void *video, void *dst, int width, in
assert(video >= _screen.dst_ptr && video <= (uint32 *)_screen.dst_ptr + _screen.width + _screen.height * _screen.pitch);
uint32 *udst = (uint32 *)dst;
const uint32 *src = (const uint32 *)video;
const uint16 *anim_line;
const uint8 *anim_line;
if (this->anim_buf == NULL) return;
@@ -349,8 +348,8 @@ void Blitter_32bppAnim::CopyToBuffer(const void *video, void *dst, int width, in
src += _screen.pitch;
udst += width;
/* Copy the anim-buffer */
memcpy(udst, anim_line, width * sizeof(uint16));
udst = (uint32 *)((uint16 *)udst + width);
memcpy(udst, anim_line, width * sizeof(uint8));
udst = (uint32 *)((uint8 *)udst + width);
anim_line += this->anim_buf_width;
}
}
@@ -359,7 +358,7 @@ void Blitter_32bppAnim::ScrollBuffer(void *video, int &left, int &top, int &widt
{
assert(!_screen_disable_anim);
assert(video >= _screen.dst_ptr && video <= (uint32 *)_screen.dst_ptr + _screen.width + _screen.height * _screen.pitch);
uint16 *dst, *src;
uint8 *dst, *src;
/* We need to scroll the anim-buffer too */
if (scroll_y > 0) {
@@ -376,7 +375,7 @@ void Blitter_32bppAnim::ScrollBuffer(void *video, int &left, int &top, int &widt
uint tw = width + (scroll_x >= 0 ? -scroll_x : scroll_x);
uint th = height - scroll_y;
for (; th > 0; th--) {
memcpy(dst, src, tw * sizeof(uint16));
memcpy(dst, src, tw * sizeof(uint8));
src -= this->anim_buf_width;
dst -= this->anim_buf_width;
}
@@ -397,7 +396,7 @@ void Blitter_32bppAnim::ScrollBuffer(void *video, int &left, int &top, int &widt
uint tw = width + (scroll_x >= 0 ? -scroll_x : scroll_x);
uint th = height + scroll_y;
for (; th > 0; th--) {
memmove(dst, src, tw * sizeof(uint16));
memmove(dst, src, tw * sizeof(uint8));
src += this->anim_buf_width;
dst += this->anim_buf_width;
}
@@ -408,7 +407,7 @@ void Blitter_32bppAnim::ScrollBuffer(void *video, int &left, int &top, int &widt
int Blitter_32bppAnim::BufferSize(int width, int height)
{
return width * height * (sizeof(uint32) + sizeof(uint16));
return width * height * (sizeof(uint32) + sizeof(uint8));
}
void Blitter_32bppAnim::PaletteAnimate(const Palette &palette)
@@ -416,22 +415,22 @@ void Blitter_32bppAnim::PaletteAnimate(const Palette &palette)
assert(!_screen_disable_anim);
this->palette = palette;
/* If first_dirty is 0, it is for 8bpp indication to send the new
* palette. As we dont do that for 32bpp, ignore that request
* completely */
if (this->palette.first_dirty == 0) return;
assert(this->palette.first_dirty == PALETTE_ANIM_START);
/* Never repaint the transparency pixel */
if (this->palette.first_dirty == 0) {
this->palette.first_dirty++;
this->palette.count_dirty--;
}
const uint16 *anim = this->anim_buf;
const uint8 *anim = this->anim_buf;
uint32 *dst = (uint32 *)_screen.dst_ptr;
/* Let's walk the anim buffer and try to find the pixels */
for (int y = this->anim_buf_height; y != 0 ; y--) {
for (int x = this->anim_buf_width; x != 0 ; x--) {
uint colour = GB(*anim, 0, 8);
if (colour >= PALETTE_ANIM_START) {
uint colour = *anim;
if (IsInsideBS(colour, this->palette.first_dirty, this->palette.count_dirty)) {
/* Update this pixel */
*dst = this->AdjustBrightness(LookupColourInPalette(colour), GB(*anim, 8, 8));
*dst = LookupColourInPalette(colour);
}
dst++;
anim++;
@@ -453,7 +452,7 @@ void Blitter_32bppAnim::PostResize()
if (_screen.width != this->anim_buf_width || _screen.height != this->anim_buf_height) {
/* The size of the screen changed; we can assume we can wipe all data from our buffer */
free(this->anim_buf);
this->anim_buf = CallocT<uint16>(_screen.width * _screen.height);
this->anim_buf = CallocT<uint8>(_screen.width * _screen.height);
this->anim_buf_width = _screen.width;
this->anim_buf_height = _screen.height;
}

View File

@@ -17,7 +17,7 @@
/** The optimised 32 bpp blitter with palette animation. */
class Blitter_32bppAnim FINAL : public Blitter_32bppOptimized {
private:
uint16 *anim_buf; ///< In this buffer we keep track of the 8bpp indexes so we can do palette animation
uint8 *anim_buf; ///< In this buffer we keep track of the 8bpp indexes so we can do palette animation
int anim_buf_width; ///< The width of the animation buffer.
int anim_buf_height; ///< The height of the animation buffer.
Palette palette; ///< The current palette.
@@ -41,7 +41,7 @@ public:
/* virtual */ Blitter::PaletteAnimation UsePaletteAnimation();
/* virtual */ const char *GetName() { return "32bpp-anim"; }
/* virtual */ int GetBytesPerPixel() { return 6; }
/* virtual */ int GetBytesPerPixel() { return 5; }
/* virtual */ void PostResize();
/**

View File

@@ -14,7 +14,6 @@
#include "base.hpp"
#include "../core/bitmath_func.hpp"
#include "../core/math_func.hpp"
#include "../gfx_func.h"
/** Base for all 32bpp blitters. */
@@ -135,33 +134,6 @@ public:
return ComposeColour(0xFF, colour, colour, colour);
}
static const int DEFAULT_BRIGHTNESS = 64;
static inline uint32 AdjustBrightness(uint32 colour, uint8 brightness)
{
/* Shortcut for normal brightness */
if (brightness == DEFAULT_BRIGHTNESS) return colour;
uint16 ob = 0;
uint16 r = GB(colour, 16, 8) * brightness / DEFAULT_BRIGHTNESS;
uint16 g = GB(colour, 8, 8) * brightness / DEFAULT_BRIGHTNESS;
uint16 b = GB(colour, 0, 8) * brightness / DEFAULT_BRIGHTNESS;
/* Sum overbright */
if (r > 255) ob += r - 255;
if (g > 255) ob += g - 255;
if (b > 255) ob += b - 255;
if (ob == 0) return ComposeColour(GB(colour, 24, 8), r, g, b);
/* Reduce overbright strength */
ob /= 2;
return ComposeColour(GB(colour, 24, 8),
r >= 255 ? 255 : min(r + ob * (255 - r) / 256, 255),
g >= 255 ? 255 : min(g + ob * (255 - g) / 256, 255),
b >= 255 ? 255 : min(b + ob * (255 - b) / 256, 255));
}
};
#endif /* BLITTER_32BPP_BASE_HPP */

View File

@@ -12,6 +12,7 @@
#include "../stdafx.h"
#include "../zoom_func.h"
#include "../settings_type.h"
#include "../core/math_func.hpp"
#include "32bpp_optimized.hpp"
/** Instantiation of the optimized 32bpp blitter factory. */
@@ -35,12 +36,12 @@ inline void Blitter_32bppOptimized::Draw(const Blitter::BlitterParams *bp, ZoomL
/* src_n : each line begins with uint32 n = 'number of bytes in this line',
* then interleaved stream of 'm' and 'n' channels. 'm' is remap,
* 'n' is number of bytes with the same alpha channel class */
const uint16 *src_n = (const uint16 *)(src->data + src->offset[zoom][1]);
const uint8 *src_n = (const uint8 *)(src->data + src->offset[zoom][1]);
/* skip upper lines in src_px and src_n */
for (uint i = bp->skip_top; i != 0; i--) {
src_px = (const Colour *)((const byte *)src_px + *(const uint32 *)src_px);
src_n = (const uint16 *)((const byte *)src_n + *(const uint32 *)src_n);
src_n += *(const uint32 *)src_n;
}
/* skip lines in dst */
@@ -58,8 +59,8 @@ inline void Blitter_32bppOptimized::Draw(const Blitter::BlitterParams *bp, ZoomL
src_px++;
/* next src_n line begins here */
const uint16 *src_n_ln = (const uint16 *)((const byte *)src_n + *(const uint32 *)src_n);
src_n += 2;
const uint8 *src_n_ln = src_n + *(const uint32 *)src_n;
src_n += 4;
/* we will end this line when we reach this point */
uint32 *dst_end = dst + bp->skip_left;
@@ -118,8 +119,8 @@ inline void Blitter_32bppOptimized::Draw(const Blitter::BlitterParams *bp, ZoomL
if (m == 0) {
*dst = src_px->data;
} else {
uint r = remap[GB(m, 0, 8)];
if (r != 0) *dst = this->AdjustBrightness(this->LookupColourInPalette(r), GB(m, 8, 8));
uint r = remap[m];
if (r != 0) *dst = this->LookupColourInPalette(r);
}
dst++;
src_px++;
@@ -131,8 +132,8 @@ inline void Blitter_32bppOptimized::Draw(const Blitter::BlitterParams *bp, ZoomL
if (m == 0) {
*dst = ComposeColourRGBANoCheck(src_px->r, src_px->g, src_px->b, src_px->a, *dst);
} else {
uint r = remap[GB(m, 0, 8)];
if (r != 0) *dst = ComposeColourPANoCheck(this->AdjustBrightness(this->LookupColourInPalette(r), GB(m, 8, 8)), src_px->a, *dst);
uint r = remap[m];
if (r != 0) *dst = ComposeColourPANoCheck(this->LookupColourInPalette(r), src_px->a, *dst);
}
dst++;
src_px++;
@@ -269,7 +270,7 @@ Sprite *Blitter_32bppOptimized::Encode(SpriteLoader::Sprite *sprite, AllocatorPr
*
* it has to be stored in one stream so fewer registers are used -
* x86 has problems with register allocation even with this solution */
uint16 *dst_n_orig[ZOOM_LVL_COUNT];
uint8 *dst_n_orig[ZOOM_LVL_COUNT];
/* lengths of streams */
uint32 lengths[ZOOM_LVL_COUNT][2];
@@ -292,7 +293,7 @@ Sprite *Blitter_32bppOptimized::Encode(SpriteLoader::Sprite *sprite, AllocatorPr
uint size = src_orig->height * src_orig->width;
dst_px_orig[z] = CallocT<Colour>(size + src_orig->height * 2);
dst_n_orig[z] = CallocT<uint16>(size * 2 + src_orig->height * 4 * 2);
dst_n_orig[z] = CallocT<uint8>(size * 2 + src_orig->height * 4 * 2);
uint32 *dst_px_ln = (uint32 *)dst_px_orig[z];
uint32 *dst_n_ln = (uint32 *)dst_n_orig[z];
@@ -301,9 +302,9 @@ Sprite *Blitter_32bppOptimized::Encode(SpriteLoader::Sprite *sprite, AllocatorPr
for (uint y = src_orig->height; y > 0; y--) {
Colour *dst_px = (Colour *)(dst_px_ln + 1);
uint16 *dst_n = (uint16 *)(dst_n_ln + 1);
uint8 *dst_n = (uint8 *)(dst_n_ln + 1);
uint16 *dst_len = dst_n++;
uint8 *dst_len = dst_n++;
uint last = 3;
int len = 0;
@@ -312,7 +313,7 @@ Sprite *Blitter_32bppOptimized::Encode(SpriteLoader::Sprite *sprite, AllocatorPr
uint8 a = src->a;
uint t = a > 0 && a < 255 ? 1 : a;
if (last != t || len == 65535) {
if (last != t || len == 255) {
if (last != 3) {
*dst_len = len;
dst_len = dst_n++;
@@ -327,15 +328,8 @@ Sprite *Blitter_32bppOptimized::Encode(SpriteLoader::Sprite *sprite, AllocatorPr
dst_px->a = a;
*dst_n = src->m;
if (src->m != 0) {
/* Get brightest value */
uint8 rgb_max = max(src->r, max(src->g, src->b));
/* Black pixel (8bpp or old 32bpp image), so use default value */
if (rgb_max == 0) rgb_max = DEFAULT_BRIGHTNESS;
*dst_n |= rgb_max << 8;
/* Pre-convert the mapping channel to a RGB value */
uint32 colour = this->AdjustBrightness(this->LookupColourInPalette(src->m), rgb_max);
uint32 colour = this->LookupColourInPalette(src->m);
dst_px->r = GB(colour, 16, 8);
dst_px->g = GB(colour, 8, 8);
dst_px->b = GB(colour, 0, 8);
@@ -360,7 +354,7 @@ Sprite *Blitter_32bppOptimized::Encode(SpriteLoader::Sprite *sprite, AllocatorPr
}
dst_px = (Colour *)AlignPtr(dst_px, 4);
dst_n = (uint16 *)AlignPtr(dst_n, 4);
dst_n = (uint8 *)AlignPtr(dst_n, 4);
*dst_px_ln = (uint8 *)dst_px - (uint8 *)dst_px_ln;
*dst_n_ln = (uint8 *)dst_n - (uint8 *)dst_n_ln;

View File

@@ -20,11 +20,11 @@ static FBlitter_32bppSimple iFBlitter_32bppSimple;
void Blitter_32bppSimple::Draw(Blitter::BlitterParams *bp, BlitterMode mode, ZoomLevel zoom)
{
const Blitter_32bppSimple::Pixel *src, *src_line;
const SpriteLoader::CommonPixel *src, *src_line;
uint32 *dst, *dst_line;
/* Find where to start reading in the source sprite */
src_line = (const Blitter_32bppSimple::Pixel *)bp->sprite + (bp->skip_top * bp->sprite_width + bp->skip_left) * ScaleByZoom(1, zoom);
src_line = (const SpriteLoader::CommonPixel *)bp->sprite + (bp->skip_top * bp->sprite_width + bp->skip_left) * ScaleByZoom(1, zoom);
dst_line = (uint32 *)bp->dst + bp->top * bp->pitch + bp->left;
for (int y = 0; y < bp->height; y++) {
@@ -41,7 +41,7 @@ void Blitter_32bppSimple::Draw(Blitter::BlitterParams *bp, BlitterMode mode, Zoo
if (src->m == 0) {
if (src->a != 0) *dst = ComposeColourRGBA(src->r, src->g, src->b, src->a, *dst);
} else {
if (bp->remap[src->m] != 0) *dst = ComposeColourPA(this->AdjustBrightness(this->LookupColourInPalette(bp->remap[src->m]), src->v), src->a, *dst);
if (bp->remap[src->m] != 0) *dst = ComposeColourPA(this->LookupColourInPalette(bp->remap[src->m]), src->a, *dst);
}
break;
@@ -94,42 +94,26 @@ void Blitter_32bppSimple::DrawColourMappingRect(void *dst, int width, int height
Sprite *Blitter_32bppSimple::Encode(SpriteLoader::Sprite *sprite, AllocatorProc *allocator)
{
Blitter_32bppSimple::Pixel *dst;
Sprite *dest_sprite = (Sprite *)allocator(sizeof(*dest_sprite) + sprite->height * sprite->width * sizeof(*dst));
Sprite *dest_sprite;
SpriteLoader::CommonPixel *dst;
dest_sprite = (Sprite *)allocator(sizeof(*dest_sprite) + sprite->height * sprite->width * sizeof(SpriteLoader::CommonPixel));
dest_sprite->height = sprite->height;
dest_sprite->width = sprite->width;
dest_sprite->x_offs = sprite->x_offs;
dest_sprite->y_offs = sprite->y_offs;
dst = (Blitter_32bppSimple::Pixel *)dest_sprite->data;
SpriteLoader::CommonPixel *src = (SpriteLoader::CommonPixel *)sprite->data;
dst = (SpriteLoader::CommonPixel *)dest_sprite->data;
memcpy(dst, sprite->data, sprite->height * sprite->width * sizeof(SpriteLoader::CommonPixel));
for (int i = 0; i < sprite->height * sprite->width; i++) {
if (src->m == 0) {
dst[i].r = src->r;
dst[i].g = src->g;
dst[i].b = src->b;
dst[i].a = src->a;
dst[i].m = 0;
dst[i].v = 0;
} else {
/* Get brightest value */
uint8 rgb_max = max(src->r, max(src->g, src->b));
/* Black pixel (8bpp or old 32bpp image), so use default value */
if (rgb_max == 0) rgb_max = DEFAULT_BRIGHTNESS;
dst[i].v = rgb_max;
if (dst[i].m != 0) {
/* Pre-convert the mapping channel to a RGB value */
uint colour = this->AdjustBrightness(this->LookupColourInPalette(src->m), dst[i].v);
uint colour = this->LookupColourInPalette(dst[i].m);
dst[i].r = GB(colour, 16, 8);
dst[i].g = GB(colour, 8, 8);
dst[i].b = GB(colour, 0, 8);
dst[i].a = src->a;
dst[i].m = src->m;
}
src++;
}
return dest_sprite;

View File

@@ -17,14 +17,6 @@
/** The most trivial 32 bpp blitter (without palette animation). */
class Blitter_32bppSimple : public Blitter_32bppBase {
struct Pixel {
uint8 r; ///< Red-channel
uint8 g; ///< Green-channel
uint8 b; ///< Blue-channel
uint8 a; ///< Alpha-channel
uint8 m; ///< Remap-channel
uint8 v; ///< Brightness-channel
};
public:
/* virtual */ void Draw(Blitter::BlitterParams *bp, BlitterMode mode, ZoomLevel zoom);
/* virtual */ void DrawColourMappingRect(void *dst, int width, int height, PaletteID pal);

View File

@@ -16,6 +16,7 @@
#if defined(ENABLE_NETWORK) && defined(WITH_FREETYPE)
#include "core/geometry_func.hpp"
#include "fileio_func.h"
#include "fontcache.h"
#include "gfx_func.h"
#include "network/network.h"
@@ -24,6 +25,7 @@
#include "strings_func.h"
#include "video/video_driver.hpp"
#include "window_func.h"
#include "window_gui.h"
#include "widgets/bootstrap_widget.h"

View File

@@ -847,10 +847,9 @@ int DrawVehiclePurchaseInfo(int left, int right, int y, EngineID engine_number)
y += FONT_HEIGHT_NORMAL;
}
if (refittable) y = ShowRefitOptionsList(left, right, y, engine_number);
/* Additional text from NewGRF */
y = ShowAdditionalText(left, right, y, engine_number);
if (refittable) y = ShowRefitOptionsList(left, right, y, engine_number);
return y;
}

View File

@@ -105,33 +105,6 @@ public:
{
return this->amount[cargo];
}
/**
* Get the sum of all cargo amounts.
* @return The sum.
*/
template <typename T>
inline const T GetSum() const
{
T ret = 0;
for (size_t i = 0; i < lengthof(this->amount); i++) {
ret += this->amount[i];
}
return ret;
}
/**
* Get the amount of cargos that have an amount.
* @return The amount.
*/
inline byte GetCount() const
{
byte count = 0;
for (size_t i = 0; i < lengthof(this->amount); i++) {
if (this->amount[i] != 0) count++;
}
return count;
}
};

View File

@@ -11,6 +11,7 @@
#include "stdafx.h"
#include "cargotype.h"
#include "core/bitmath_func.hpp"
#include "newgrf_cargo.h"
#include "string_func.h"
#include "strings_func.h"

View File

@@ -18,15 +18,18 @@
#include "saveload/saveload.h"
#include "textbuf_gui.h"
#include "window_gui.h"
#include "newgrf.h"
#include "string_func.h"
#include "strings_func.h"
#include "window_func.h"
#include "rail_gui.h"
#include "gui.h"
#include "company_gui.h"
#include "gamelog.h"
#include "widgets/cheat_widget.h"
#include "table/strings.h"
#include "table/sprites.h"
@@ -84,6 +87,26 @@ static int32 ClickSetProdCheat(int32 p1, int32 p2)
return _cheats.setup_prod.value;
}
/**
* Handle changing of climate.
* @param p1 New climate.
* @param p2 Unused.
* @return New climate.
*/
static int32 ClickChangeClimateCheat(int32 p1, int32 p2)
{
if (p1 == -1) p1 = 3;
if (p1 == 4) p1 = 0;
_settings_game.game_creation.landscape = p1;
GamelogStartAction(GLAT_CHEAT);
GamelogTestMode();
ReloadNewGRFData();
GamelogStopAction();
return _settings_game.game_creation.landscape;
}
extern void EnginesMonthlyLoop();
/**
@@ -117,6 +140,7 @@ enum CheatNumbers {
CHT_CROSSINGTUNNELS, ///< Allow tunnels to cross each other.
CHT_NO_JETCRASH, ///< Disable jet-airplane crashes.
CHT_SETUP_PROD, ///< Allow manually editing of industry production.
CHT_SWITCH_CLIMATE, ///< Switch climate.
CHT_CHANGE_DATE, ///< Do time traveling.
CHT_NUM_CHEATS, ///< Number of cheats.
@@ -149,6 +173,7 @@ static const CheatEntry _cheats_ui[] = {
{SLE_BOOL, STR_CHEAT_CROSSINGTUNNELS, &_cheats.crossing_tunnels.value, &_cheats.crossing_tunnels.been_used, NULL },
{SLE_BOOL, STR_CHEAT_NO_JETCRASH, &_cheats.no_jetcrash.value, &_cheats.no_jetcrash.been_used, NULL },
{SLE_BOOL, STR_CHEAT_SETUP_PROD, &_cheats.setup_prod.value, &_cheats.setup_prod.been_used, &ClickSetProdCheat },
{SLE_UINT8, STR_CHEAT_SWITCH_CLIMATE, &_settings_game.game_creation.landscape, &_cheats.switch_climate.been_used, &ClickChangeClimateCheat },
{SLE_INT32, STR_CHEAT_CHANGE_DATE, &_cur_year, &_cheats.change_date.been_used, &ClickChangeDateCheat },
};
@@ -197,7 +222,7 @@ struct CheatWindow : Window {
case SLE_BOOL: {
bool on = (*(bool*)ce->variable);
DrawBoolButton(button_left, y, on, true);
DrawFrameRect(button_left, y + 1, button_left + 20 - 1, y + FONT_HEIGHT_NORMAL - 1, on ? COLOUR_GREEN : COLOUR_RED, on ? FR_LOWERED : FR_NONE);
SetDParam(0, on ? STR_CONFIG_SETTING_ON : STR_CONFIG_SETTING_OFF);
break;
}
@@ -222,6 +247,10 @@ struct CheatWindow : Window {
break;
}
/* Set correct string for switch climate cheat */
case STR_CHEAT_SWITCH_CLIMATE: val += STR_CHEAT_SWITCH_CLIMATE_TEMPERATE_LANDSCAPE;
/* FALL THROUGH */
default: SetDParam(0, val);
}
break;
@@ -263,6 +292,14 @@ struct CheatWindow : Window {
width = max(width, GetStringBoundingBox(ce->str).width + 10 + 10);
break;
/* Set correct string for switch climate cheat */
case STR_CHEAT_SWITCH_CLIMATE:
for (StringID i = STR_CHEAT_SWITCH_CLIMATE_TEMPERATE_LANDSCAPE; i <= STR_CHEAT_SWITCH_CLIMATE_TOYLAND_LANDSCAPE; i++) {
SetDParam(0, i);
width = max(width, GetStringBoundingBox(ce->str).width);
}
break;
default:
SetDParam(0, INT64_MAX);
width = max(width, GetStringBoundingBox(ce->str).width);

View File

@@ -32,10 +32,10 @@ struct Cheats {
Cheat crossing_tunnels; ///< allow tunnels that cross each other
Cheat dummy1; ///< empty cheat (build while in pause mode)
Cheat no_jetcrash; ///< no jet will crash on small airports anymore
Cheat dummy2; ///< empty cheat (change the climate of the map)
Cheat switch_climate; ///< change the climate of the map
Cheat change_date; ///< changes date ingame
Cheat setup_prod; ///< setup raw-material production in game
Cheat dummy3; ///< empty cheat (enable running el-engines on normal rail)
Cheat dummy2; ///< empty cheat (enable running el-engines on normal rail)
};
extern Cheats _cheats;

View File

@@ -14,6 +14,9 @@
#include "command_func.h"
#include "landscape.h"
#include "genworld.h"
#include "landscape_type.h"
#include "clear_func.h"
#include "economy_func.h"
#include "viewport_func.h"
#include "water.h"
#include "core/random_func.hpp"
@@ -256,7 +259,7 @@ static void TileLoop_Clear(TileIndex tile)
return;
}
}
AmbientSoundEffect(tile);
AmbientSoundEffectCallback(tile);
switch (_settings_game.game_creation.landscape) {
case LT_TROPIC: TileLoopClearDesert(tile); break;

View File

@@ -17,7 +17,9 @@
#include "network/network_type.h"
#include "network/network.h"
#include "genworld.h"
#include "newgrf_storage.h"
#include "strings_func.h"
#include "gfx_func.h"
#include "texteff.hpp"
#include "town.h"
#include "date_func.h"
@@ -150,8 +152,6 @@ CommandProc CmdCompanyCtrl;
CommandProc CmdCustomNewsItem;
CommandProc CmdCreateGoal;
CommandProc CmdRemoveGoal;
CommandProc CmdGoalQuestion;
CommandProc CmdGoalQuestionAnswer;
CommandProc CmdLevelLand;
@@ -290,8 +290,6 @@ static const Command _command_proc_table[] = {
DEF_CMD(CmdCustomNewsItem, CMD_STR_CTRL | CMD_DEITY, CMDT_OTHER_MANAGEMENT ), // CMD_CUSTOM_NEWS_ITEM
DEF_CMD(CmdCreateGoal, CMD_STR_CTRL | CMD_DEITY, CMDT_OTHER_MANAGEMENT ), // CMD_CREATE_GOAL
DEF_CMD(CmdRemoveGoal, CMD_DEITY, CMDT_OTHER_MANAGEMENT ), // CMD_REMOVE_GOAL
DEF_CMD(CmdGoalQuestion, CMD_STR_CTRL | CMD_DEITY, CMDT_OTHER_MANAGEMENT ), // CMD_GOAL_QUESTION
DEF_CMD(CmdGoalQuestionAnswer, CMD_DEITY, CMDT_OTHER_MANAGEMENT ), // CMD_GOAL_QUESTION_ANSWER
DEF_CMD(CmdLevelLand, CMD_ALL_TILES | CMD_NO_TEST | CMD_AUTO, CMDT_LANDSCAPE_CONSTRUCTION), // CMD_LEVEL_LAND; test run might clear tiles multiple times, in execution that only happens once
@@ -633,31 +631,40 @@ CommandCost DoCommandPInternal(TileIndex tile, uint32 p1, uint32 p2, uint32 cmd,
if (exec_as_spectator) cur_company.Change(COMPANY_SPECTATOR);
bool test_and_exec_can_differ = (cmd_flags & CMD_NO_TEST) != 0;
bool skip_test = _networking && (cmd & CMD_NO_TEST_IF_IN_NETWORK) != 0;
/* Test the command. */
_cleared_object_areas.Clear();
SetTownRatingTestMode(true);
ClearStorageChanges(false);
CommandCost res = proc(tile, flags, p1, p2, text);
SetTownRatingTestMode(false);
/* Do we need to do a test run?
* Basically we need to always do this, except when
* the no-test-in-network flag is giving and we're
* in a network game (e.g. restoring orders would
* fail this test because the first order does not
* exist yet when inserting the second, giving that
* a wrong insert location and ignoring the command
* and thus breaking restoring). However, when we
* just want to do cost estimation we don't care
* because it's only done once anyway. */
CommandCost res;
if (estimate_only || !skip_test) {
/* Test the command. */
_cleared_object_areas.Clear();
SetTownRatingTestMode(true);
ClearStorageChanges(false);
res = proc(tile, flags, p1, p2, text);
SetTownRatingTestMode(false);
/* Make sure we're not messing things up here. */
assert(exec_as_spectator ? _current_company == COMPANY_SPECTATOR : cur_company.Verify());
/* Make sure we're not messing things up here. */
assert(exec_as_spectator ? _current_company == COMPANY_SPECTATOR : cur_company.Verify());
/* If the command fails, we're doing an estimate
* or the player does not have enough money
* (unless it's a command where the test and
* execution phase might return different costs)
* we bail out here. */
if (res.Failed() || estimate_only ||
(!test_and_exec_can_differ && !CheckCompanyHasMoney(res))) {
if (!_networking || _generating_world || (cmd & CMD_NETWORK_COMMAND) != 0) {
/* Log the failed command as well. Just to be able to be find
* causes of desyncs due to bad command test implementations. */
DEBUG(desync, 1, "cmdf: %08x; %02x; %02x; %06x; %08x; %08x; %08x; \"%s\" (%s)", _date, _date_fract, (int)_current_company, tile, p1, p2, cmd & ~CMD_NETWORK_COMMAND, text, GetCommandName(cmd));
/* If the command fails, we're doing an estimate
* or the player does not have enough money
* (unless it's a command where the test and
* execution phase might return different costs)
* we bail out here. */
if (res.Failed() || estimate_only ||
(!test_and_exec_can_differ && !CheckCompanyHasMoney(res))) {
cur_company.Restore();
return_dcpi(res, false);
}
cur_company.Restore();
return_dcpi(res, false);
}
#ifdef ENABLE_NETWORK
@@ -696,11 +703,11 @@ CommandCost DoCommandPInternal(TileIndex tile, uint32 p1, uint32 p2, uint32 cmd,
cur_company.Restore();
}
/* If the test and execution can differ we have to check the
* return of the command. Otherwise we can check whether the
* test and execution have yielded the same result,
* i.e. cost and error state are the same. */
if (!test_and_exec_can_differ) {
/* If the test and execution can differ, or we skipped the test
* we have to check the return of the command. Otherwise we can
* check whether the test and execution have yielded the same
* result, i.e. cost and error state are the same. */
if (!test_and_exec_can_differ && !skip_test) {
assert(res.GetCost() == res2.GetCost() && res.Failed() == res2.Failed()); // sanity check
} else if (res2.Failed()) {
return_dcpi(res2, false);

View File

@@ -266,8 +266,6 @@ enum Commands {
CMD_CUSTOM_NEWS_ITEM, ///< create a custom news message
CMD_CREATE_GOAL, ///< create a new goal
CMD_REMOVE_GOAL, ///< remove a goal
CMD_GOAL_QUESTION, ///< ask a goal related question
CMD_GOAL_QUESTION_ANSWER, ///< answer(s) to CMD_GOAL_QUESTION
CMD_LEVEL_LAND, ///< level land
CMD_BUILD_LOCK, ///< build a lock
@@ -320,10 +318,9 @@ enum DoCommandFlag {
DC_NO_TEST_TOWN_RATING = 0x020, ///< town rating does not disallow you from building
DC_BANKRUPT = 0x040, ///< company bankrupts, skip money check, skip vehicle on tile check in some cases
DC_AUTOREPLACE = 0x080, ///< autoreplace/autorenew is in progress, this shall disable vehicle limits when building, and ignore certain restrictions when undoing things (like vehicle attach callback)
DC_NO_CARGO_CAP_CHECK = 0x100, ///< when autoreplace/autorenew is in progress, this shall prevent truncating the amount of cargo in the vehicle to prevent testing the command to remove cargo
DC_ALL_TILES = 0x200, ///< allow this command also on MP_VOID tiles
DC_NO_MODIFY_TOWN_RATING = 0x400, ///< do not change town rating
DC_FORCE_CLEAR_TILE = 0x800, ///< do not only remove the object on the tile, but also clear any water left on it
DC_ALL_TILES = 0x100, ///< allow this command also on MP_VOID tiles
DC_NO_MODIFY_TOWN_RATING = 0x200, ///< do not change town rating
DC_FORCE_CLEAR_TILE = 0x400, ///< do not only remove the object on the tile, but also clear any water left on it
};
DECLARE_ENUM_AS_BIT_SET(DoCommandFlag)
@@ -345,6 +342,7 @@ DECLARE_ENUM_AS_BIT_SET(DoCommandFlag)
*/
enum FlaggedCommands {
CMD_NETWORK_COMMAND = 0x0100, ///< execute the command without sending it on the network
CMD_NO_TEST_IF_IN_NETWORK = 0x0200, ///< When enabled, the command will bypass the no-DC_EXEC round if in network
CMD_FLAGS_MASK = 0xFF00, ///< mask for all command flags
CMD_ID_MASK = 0x00FF, ///< mask for the command ID
};

View File

@@ -12,20 +12,22 @@
#ifndef COMPANY_BASE_H
#define COMPANY_BASE_H
#include "core/pool_type.hpp"
#include "road_type.h"
#include "rail_type.h"
#include "livery.h"
#include "autoreplace_type.h"
#include "economy_type.h"
#include "tile_type.h"
#include "settings_type.h"
#include "group.h"
/** Statistics about the economy. */
struct CompanyEconomyEntry {
Money income; ///< The amount of income.
Money expenses; ///< The amount of expenses.
CargoArray delivered_cargo; ///< The amount of delivered cargo.
int32 performance_history; ///< Company score (scale 0-1000)
Money company_value; ///< The value of the company.
Money income;
Money expenses;
int32 delivered_cargo;
int32 performance_history; ///< company score (scale 0-1000)
Money company_value;
};
struct CompanyInfrastructure {
@@ -63,6 +65,8 @@ struct CompanyProperties {
byte block_preview; ///< Number of quarters that the company is not allowed to get new exclusive engine previews (see CompaniesGenStatistics).
uint32 cargo_types; ///< Which cargo types were transported the last year.
TileIndex location_of_HQ; ///< Northern tile of HQ; #INVALID_TILE when there is none.
TileIndex last_build_coordinate; ///< Coordinate of the last build thing by this company.

View File

@@ -10,6 +10,7 @@
/** @file company_cmd.cpp Handling of companies. */
#include "stdafx.h"
#include "engine_base.h"
#include "company_base.h"
#include "company_func.h"
#include "company_gui.h"
@@ -32,6 +33,7 @@
#include "settings_func.h"
#include "vehicle_base.h"
#include "vehicle_func.h"
#include "sprite.h"
#include "smallmap_gui.h"
#include "game/game.hpp"
@@ -110,7 +112,6 @@ void SetLocalCompany(CompanyID new_company)
/* ... and redraw the whole screen. */
MarkWholeScreenDirty();
InvalidateWindowClassesData(WC_SIGN_LIST, -1);
}
/**
@@ -810,13 +811,7 @@ CommandCost CmdCompanyCtrl(TileIndex tile, DoCommandFlag flags, uint32 p1, uint3
/* Has the network client a correct ClientIndex? */
if (!(flags & DC_EXEC)) return CommandCost();
NetworkClientInfo *ci = NetworkClientInfo::GetByClientID(client_id);
#ifndef DEBUG_DUMP_COMMANDS
/* When replaying the client ID is not a valid client; there
* are actually no clients at all. However, the company has to
* be created, otherwise we cannot rerun the game properly.
* So only allow a NULL client info in that case. */
if (ci == NULL) return CommandCost();
#endif /* NOT DEBUG_DUMP_COMMANDS */
/* Delete multiplayer progress bar */
DeleteWindowById(WC_NETWORK_STATUS_WINDOW, WN_NETWORK_STATUS_WINDOW_JOIN);
@@ -848,17 +843,13 @@ CommandCost CmdCompanyCtrl(TileIndex tile, DoCommandFlag flags, uint32 p1, uint3
}
if (_network_server) {
if (ci != NULL) {
/* ci is only NULL when replaying.
* When replaying no client is actually in need of an update. */
ci->client_playas = c->index;
NetworkUpdateClientInfo(ci->client_id);
}
ci->client_playas = c->index;
NetworkUpdateClientInfo(ci->client_id);
if (Company::IsValidID(c->index)) {
if (Company::IsValidID(ci->client_playas)) {
_network_company_states[c->index].months_empty = 0;
_network_company_states[c->index].password[0] = '\0';
NetworkServerUpdateCompanyPassworded(c->index, false);
NetworkServerUpdateCompanyPassworded(ci->client_playas, false);
/* XXX - When a client joins, we automatically set its name to the
* client's name (for some reason). As it stands now only the server
@@ -871,24 +862,12 @@ CommandCost CmdCompanyCtrl(TileIndex tile, DoCommandFlag flags, uint32 p1, uint3
* TODO: Perhaps this could be improved by when the client is ready
* with joining to let it send itself the command, and not the server?
* For example in network_client.c:534? */
if (ci != NULL) {
/* ci is only NULL when replaying.
* When replaying, the command to rename the president will
* automatically be ran, so this is not even needed to get
* the exact same state. */
NetworkSendCommand(0, 0, 0, CMD_RENAME_PRESIDENT, NULL, ci->client_name, c->index);
}
NetworkSendCommand(0, 0, 0, CMD_RENAME_PRESIDENT, NULL, ci->client_name, ci->client_playas);
}
/* Announce new company on network. */
NetworkAdminCompanyInfo(c, true);
if (ci != NULL) {
/* ci is only NULL when replaying.
* When replaying, the message that someone started a new company
* is not interesting at all. */
NetworkServerSendChat(NETWORK_ACTION_COMPANY_NEW, DESTTYPE_BROADCAST, 0, "", ci->client_id, c->index + 1);
}
NetworkServerSendChat(NETWORK_ACTION_COMPANY_NEW, DESTTYPE_BROADCAST, 0, "", ci->client_id, ci->client_playas + 1);
}
#endif /* ENABLE_NETWORK */
break;

View File

@@ -14,6 +14,7 @@
#include "command_type.h"
#include "company_type.h"
#include "tile_type.h"
#include "gfx_type.h"
bool MayCompanyTakeOver(CompanyID cbig, CompanyID small);

View File

@@ -7,7 +7,7 @@
* See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
*/
/** @file company_gui.cpp %Company related GUIs. */
/** @file company_gui.cpp Company related GUIs. */
#include "stdafx.h"
#include "error.h"
@@ -20,14 +20,17 @@
#include "network/network.h"
#include "network/network_gui.h"
#include "network/network_func.h"
#include "vehicle_func.h"
#include "newgrf.h"
#include "company_manager_face.h"
#include "strings_func.h"
#include "date_func.h"
#include "widgets/dropdown_type.h"
#include "tilehighlight_func.h"
#include "sprite.h"
#include "company_base.h"
#include "core/geometry_func.hpp"
#include "economy_func.h"
#include "object_type.h"
#include "rail.h"
#include "engine_base.h"
@@ -38,6 +41,7 @@
#include "widgets/company_widget.h"
#include "table/strings.h"
/** Company GUI constants. */
static const uint EXP_LINESPACE = 2; ///< Amount of vertical space for a horizontal (sub-)total line.

View File

@@ -1245,7 +1245,7 @@ DEF_CONSOLE_CMD(ConStopAI)
return true;
}
if (Company::IsHumanID(company_id) || company_id == _local_company) {
if (Company::IsHumanID(company_id)) {
IConsoleWarning("Company is not controlled by an AI.");
return true;
}

View File

@@ -63,17 +63,11 @@ void SetRandomSeed(uint32 seed)
#include "../network/network_server.h"
#include "../network/network_internal.h"
#include "../company_func.h"
#include "../fileio_func.h"
#include "../date_func.h"
uint32 DoRandom(int line, const char *file)
{
if (_networking && (!_network_server || (NetworkClientSocket::IsValidID(0) && NetworkClientSocket::Get(0)->status != NetworkClientSocket::STATUS_INACTIVE))) {
static FILE *f = FioFOpenFile("random-out.log", "wb", AUTOSAVE_DIR);
if (f != NULL) {
fprintf(f, "%08x; %02x; %04x; %02x; %s:%d\n", _date, _date_fract, _frame_counter, (byte)_current_company, file, line);
fflush(f);
}
printf("Random [%d/%d] %s:%d\n", _frame_counter, (byte)_current_company, file, line);
}
return _random.Next();

View File

@@ -17,8 +17,8 @@
/**
* Simple pair of data. Both types have to be POD ("Plain Old Data")!
* @tparam T Key type.
* @tparam U Value type.
* @tvar T Key type.
* @tvar U Value type.
*/
template <typename T, typename U>
struct SmallPair {
@@ -32,9 +32,9 @@ struct SmallPair {
/**
* Implementation of simple mapping class. Both types have to be POD ("Plain Old Data")!
* It has inherited accessors from SmallVector().
* @tparam T Key type.
* @tparam U Value type.
* @tparam S Unit of allocation.
* @tvar T Key type.
* @tvar U Value type.
* @tvar S Unit of allocation.
*
* @see SmallVector
*/

View File

@@ -15,26 +15,25 @@
#include "date_type.h"
#include "strings_type.h"
static const int CF_NOEURO = 0; ///< Currency never switches to the Euro (as far as known).
static const int CF_ISEURO = 1; ///< Currency _is_ the Euro.
static const uint NUM_CURRENCY = 29; ///< Number of currencies.
static const int CUSTOM_CURRENCY_ID = NUM_CURRENCY - 1; ///< Index of the custom currency.
static const int CF_NOEURO = 0;
static const int CF_ISEURO = 1;
static const uint NUM_CURRENCY = 29;
static const int CUSTOM_CURRENCY_ID = NUM_CURRENCY - 1;
/** Specification of a currency. */
struct CurrencySpec {
uint16 rate;
char separator[8];
Year to_euro; ///< %Year of switching to the Euro. May also be #CF_NOEURO or #CF_ISEURO.
Year to_euro;
char prefix[16];
char suffix[16];
/**
* The currency symbol is represented by two possible values, prefix and suffix
* Usage of one or the other is determined by #symbol_pos.
* Usage of one or the other is determined by symbol_pos.
* 0 = prefix
* 1 = suffix
* 2 = both : Special case only for custom currency.
* It is not a spec from Newgrf,
* rather a way to let users do what they want with custom currency
* rather a way to let users do what they want with custom curency
*/
byte symbol_pos;
StringID name;

View File

@@ -20,6 +20,7 @@
#include "widgets/dropdown_type.h"
#include "widgets/date_widget.h"
#include "table/strings.h"
/** Window to select a date graphically by using dropdowns */
struct SetDateWindow : Window {

View File

@@ -149,13 +149,13 @@ enum Token {
TOKEN_ELSE, ///< (#)else in code
TOKEN_ENDIF, ///< (#)endif in code
TOKEN_UNDEF, ///< (#)undef in code
TOKEN_OR, ///< '||' within <tt>#if</tt> expression
TOKEN_AND, ///< '&&' within <tt>#if</tt> expression
TOKEN_DEFINED, ///< 'defined' within <tt>#if</tt> expression
TOKEN_OPEN, ///< '(' within <tt>#if</tt> expression
TOKEN_CLOSE, ///< ')' within <tt>#if</tt> expression
TOKEN_NOT, ///< '!' within <tt>#if</tt> expression
TOKEN_ZERO, ///< '0' within <tt>#if</tt> expression
TOKEN_OR, ///< '||' within #if expression
TOKEN_AND, ///< '&&' within #if expression
TOKEN_DEFINED, ///< 'defined' within #if expression
TOKEN_OPEN, ///< '(' within #if expression
TOKEN_CLOSE, ///< ')' within #if expression
TOKEN_NOT, ///< '!' within #if expression
TOKEN_ZERO, ///< '0' within #if expression
TOKEN_INCLUDE, ///< (#)include in code
};

View File

@@ -7,7 +7,7 @@
* See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
*/
/** @file depot_cmd.cpp %Command Handling for depots. */
/** @file depot_cmd.cpp Command Handling for depots. */
#include "stdafx.h"
#include "command_func.h"

View File

@@ -12,8 +12,10 @@
#ifndef DEPOT_FUNC_H
#define DEPOT_FUNC_H
#include "tile_type.h"
#include "vehicle_type.h"
#include "slope_func.h"
#include "direction_type.h"
#include "slope_type.h"
void ShowDepotWindow(TileIndex tile, VehicleType type);

View File

@@ -18,8 +18,10 @@
#include "viewport_func.h"
#include "command_func.h"
#include "depot_base.h"
#include "vehicle_gui.h"
#include "spritecache.h"
#include "strings_func.h"
#include "window_func.h"
#include "vehicle_func.h"
#include "company_func.h"
#include "tilehighlight_func.h"

View File

@@ -149,7 +149,8 @@ static void InitializeDisasterVehicle(DisasterVehicle *v, int x, int y, int z, D
v->current_order.Free();
DisasterVehicleUpdateImage(v);
VehicleUpdatePositionAndViewport(v);
VehicleMove(v, false);
MarkSingleVehicleDirty(v);
}
static void SetDisasterVehiclePos(DisasterVehicle *v, int x, int y, int z)
@@ -160,7 +161,7 @@ static void SetDisasterVehiclePos(DisasterVehicle *v, int x, int y, int z)
v->tile = TileVirtXY(x, y);
DisasterVehicleUpdateImage(v);
VehicleUpdatePositionAndViewport(v);
VehicleMove(v, true);
DisasterVehicle *u = v->Next();
if (u != NULL) {
@@ -174,13 +175,13 @@ static void SetDisasterVehiclePos(DisasterVehicle *v, int x, int y, int z)
u->direction = v->direction;
DisasterVehicleUpdateImage(u);
VehicleUpdatePositionAndViewport(u);
VehicleMove(u, true);
if ((u = u->Next()) != NULL) {
u->x_pos = x;
u->y_pos = y;
u->z_pos = z + 5;
VehicleUpdatePositionAndViewport(u);
VehicleMove(u, true);
}
}
}
@@ -478,7 +479,7 @@ static bool DisasterTick_Helicopter_Rotors(DisasterVehicle *v)
if (++v->cur_image > SPR_ROTOR_MOVING_3) v->cur_image = SPR_ROTOR_MOVING_1;
VehicleUpdatePositionAndViewport(v);
VehicleMove(v, true);
return true;
}

View File

@@ -15,6 +15,7 @@
#include "station_gui.h"
#include "command_func.h"
#include "water.h"
#include "water_map.h"
#include "window_func.h"
#include "vehicle_func.h"
#include "sound_func.h"
@@ -24,7 +25,9 @@
#include "slope_func.h"
#include "tilehighlight_func.h"
#include "company_base.h"
#include "station_type.h"
#include "hotkeys.h"
#include "bridge.h"
#include "widgets/dock_widget.h"

View File

@@ -17,6 +17,7 @@
#include "news_func.h"
#include "network/network.h"
#include "network/network_func.h"
#include "vehicle_gui.h"
#include "ai/ai.hpp"
#include "aircraft.h"
#include "newgrf_engine.h"
@@ -28,7 +29,9 @@
#include "newgrf_station.h"
#include "newgrf_airporttiles.h"
#include "object.h"
#include "group.h"
#include "strings_func.h"
#include "window_func.h"
#include "date_func.h"
#include "vehicle_func.h"
#include "sound_func.h"
@@ -41,6 +44,7 @@
#include "waypoint_base.h"
#include "economy_base.h"
#include "core/pool_func.hpp"
#include "newgrf.h"
#include "core/backup_type.hpp"
#include "water.h"
#include "game/game.hpp"
@@ -214,21 +218,27 @@ int UpdateCompanyRatingAndValue(Company *c, bool update)
/* Generate score depending on amount of transported cargo */
{
int numec = min(c->num_valid_stat_ent, 4);
const CompanyEconomyEntry *cee;
int numec;
uint32 total_delivered;
numec = min(c->num_valid_stat_ent, 4);
if (numec != 0) {
const CompanyEconomyEntry *cee = c->old_economy;
OverflowSafeInt64 total_delivered = 0;
cee = c->old_economy;
total_delivered = 0;
do {
total_delivered += cee->delivered_cargo.GetSum<OverflowSafeInt64>();
total_delivered += cee->delivered_cargo;
} while (++cee, --numec);
_score_part[owner][SCORE_DELIVERED] = ClampToI32(total_delivered);
_score_part[owner][SCORE_DELIVERED] = total_delivered;
}
}
/* Generate score for variety of cargo */
{
_score_part[owner][SCORE_CARGO] = c->old_economy->delivered_cargo.GetCount();
uint num = CountBits(c->cargo_types);
_score_part[owner][SCORE_CARGO] = num;
if (update) c->cargo_types = 0;
}
/* Generate score for company's money */
@@ -1001,7 +1011,8 @@ static Money DeliverGoods(int num_pieces, CargoID cargo_type, StationID dest, Ti
}
/* Update company statistics */
company->cur_economy.delivered_cargo[cargo_type] += accepted;
company->cur_economy.delivered_cargo += accepted;
if (accepted > 0) SetBit(company->cargo_types, cargo_type);
/* Increase town's counter for town effects */
const CargoSpec *cs = CargoSpec::Get(cargo_type);

View File

@@ -19,6 +19,7 @@
#include "effectvehicle_func.h"
#include "effectvehicle_base.h"
#include "table/sprites.h"
static void ChimneySmokeInit(EffectVehicle *v)
{
@@ -44,7 +45,7 @@ static bool ChimneySmokeTick(EffectVehicle *v)
v->cur_image = SPR_CHIMNEY_SMOKE_0;
}
v->progress = 7;
VehicleUpdatePositionAndViewport(v);
VehicleMove(v, true);
}
return true;
@@ -77,7 +78,7 @@ static bool SteamSmokeTick(EffectVehicle *v)
moved = true;
}
if (moved) VehicleUpdatePositionAndViewport(v);
if (moved) VehicleMove(v, true);
return true;
}
@@ -94,11 +95,11 @@ static bool DieselSmokeTick(EffectVehicle *v)
if ((v->progress & 3) == 0) {
v->z_pos++;
VehicleUpdatePositionAndViewport(v);
VehicleMove(v, true);
} else if ((v->progress & 7) == 1) {
if (v->cur_image != SPR_DIESEL_SMOKE_5) {
v->cur_image++;
VehicleUpdatePositionAndViewport(v);
VehicleMove(v, true);
} else {
delete v;
return false;
@@ -122,7 +123,7 @@ static bool ElectricSparkTick(EffectVehicle *v)
v->progress = 0;
if (v->cur_image != SPR_ELECTRIC_SPARK_5) {
v->cur_image++;
VehicleUpdatePositionAndViewport(v);
VehicleMove(v, true);
} else {
delete v;
return false;
@@ -159,7 +160,7 @@ static bool SmokeTick(EffectVehicle *v)
moved = true;
}
if (moved) VehicleUpdatePositionAndViewport(v);
if (moved) VehicleMove(v, true);
return true;
}
@@ -176,7 +177,7 @@ static bool ExplosionLargeTick(EffectVehicle *v)
if ((v->progress & 3) == 0) {
if (v->cur_image != SPR_EXPLOSION_LARGE_F) {
v->cur_image++;
VehicleUpdatePositionAndViewport(v);
VehicleMove(v, true);
} else {
delete v;
return false;
@@ -201,7 +202,7 @@ static bool BreakdownSmokeTick(EffectVehicle *v)
} else {
v->cur_image = SPR_BREAKDOWN_SMOKE_0;
}
VehicleUpdatePositionAndViewport(v);
VehicleMove(v, true);
}
v->animation_state--;
@@ -225,7 +226,7 @@ static bool ExplosionSmallTick(EffectVehicle *v)
if ((v->progress & 3) == 0) {
if (v->cur_image != SPR_EXPLOSION_SMALL_B) {
v->cur_image++;
VehicleUpdatePositionAndViewport(v);
VehicleMove(v, true);
} else {
delete v;
return false;
@@ -302,7 +303,7 @@ static bool BulldozerTick(EffectVehicle *v)
return false;
}
}
VehicleUpdatePositionAndViewport(v);
VehicleMove(v, true);
}
return true;
@@ -475,7 +476,7 @@ static bool BubbleTick(EffectVehicle *v)
if (v->spritenum == 0) {
v->cur_image++;
if (v->cur_image < SPR_BUBBLE_GENERATE_3) {
VehicleUpdatePositionAndViewport(v);
VehicleMove(v, true);
return true;
}
if (v->animation_substate != 0) {
@@ -521,7 +522,7 @@ static bool BubbleTick(EffectVehicle *v)
v->z_pos += b->z;
v->cur_image = SPR_BUBBLE_0 + b->image;
VehicleUpdatePositionAndViewport(v);
VehicleMove(v, true);
return true;
}
@@ -605,7 +606,8 @@ EffectVehicle *CreateEffectVehicle(int x, int y, int z, EffectVehicleType type)
_effect_init_procs[type](v);
VehicleUpdatePositionAndViewport(v);
VehicleMove(v, false);
MarkSingleVehicleDirty(v);
return v;
}

View File

@@ -13,7 +13,6 @@
#define EFFECTVEHICLE_BASE_H
#include "vehicle_base.h"
#include "transparency.h"
/**
* A special vehicle is one of the following:

View File

@@ -16,6 +16,7 @@
#include "aircraft.h"
#include "newgrf.h"
#include "newgrf_engine.h"
#include "group.h"
#include "strings_func.h"
#include "core/random_func.hpp"
#include "window_func.h"

View File

@@ -12,9 +12,11 @@
#ifndef ENGINE_BASE_H
#define ENGINE_BASE_H
#include "company_type.h"
#include "engine_type.h"
#include "vehicle_type.h"
#include "core/pool_type.hpp"
#include "core/smallvec_type.hpp"
#include "newgrf_commons.h"
typedef Pool<Engine, EngineID, 64, 64000> EnginePool;

View File

@@ -11,6 +11,7 @@
#include "stdafx.h"
#include "window_gui.h"
#include "gfx_func.h"
#include "engine_base.h"
#include "command_func.h"
#include "strings_func.h"

View File

@@ -7,7 +7,7 @@
* See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
*/
/** @file engine_gui.h %Engine GUI functions, used by build_vehicle_gui and autoreplace_gui */
/** @file engine_gui.h Engine GUI functions, used by build_vehicle_gui and autoreplace_gui */
#ifndef ENGINE_GUI_H
#define ENGINE_GUI_H
@@ -15,13 +15,12 @@
#include "engine_type.h"
#include "sortlist_type.h"
#include "gfx_type.h"
#include "vehicle_type.h"
typedef GUIList<EngineID, CargoID> GUIEngineList;
typedef int CDECL EngList_SortTypeFunction(const EngineID*, const EngineID*); ///< argument type for #EngList_Sort.
void EngList_Sort(GUIEngineList *el, EngList_SortTypeFunction compare);
void EngList_SortPartial(GUIEngineList *el, EngList_SortTypeFunction compare, uint begin, uint num_items);
typedef int CDECL EngList_SortTypeFunction(const EngineID*, const EngineID*); ///< argument type for EngList_Sort()
void EngList_Sort(GUIEngineList *el, EngList_SortTypeFunction compare); ///< sort of the engine list
void EngList_SortPartial(GUIEngineList *el, EngList_SortTypeFunction compare, uint begin, uint num_items); ///< sort of specified portion of the engine list
StringID GetEngineCategoryName(EngineID engine);
StringID GetEngineInfoString(EngineID engine);

View File

@@ -119,10 +119,8 @@ public:
{
this->position.x = x;
this->position.y = y;
if (textref_stack_size > 0) StartTextRefStackUsage(textref_stack_size, textref_stack);
CopyOutDParam(this->decode_params, this->strings, detailed_msg == INVALID_STRING_ID ? summary_msg : detailed_msg, lengthof(this->decode_params));
if (textref_stack_size > 0) {
StopTextRefStackUsage();
MemCpyT(this->textref_stack, textref_stack, textref_stack_size);
}

View File

@@ -28,8 +28,8 @@ enum Subdirectory {
BASESET_DIR, ///< Subdirectory for all base data (base sets, intro game)
NEWGRF_DIR, ///< Subdirectory for all NewGRFs
LANG_DIR, ///< Subdirectory for all translation files
AI_DIR, ///< Subdirectory for all %AI files
AI_LIBRARY_DIR,///< Subdirectory for all %AI libraries
AI_DIR, ///< Subdirectory for all AI files
AI_LIBRARY_DIR,///< Subdirectory for all AI libraries
GAME_DIR, ///< Subdirectory for all game scripts
GAME_LIBRARY_DIR, ///< Subdirectory for all GS libraries
NUM_SUBDIRS, ///< Number of subdirectories

View File

@@ -11,6 +11,7 @@
#include "../stdafx.h"
#include "../settings_type.h"
#include "../core/random_func.hpp"
#include "game.hpp"
#include "game_config.hpp"
#include "game_info.hpp"

View File

@@ -10,11 +10,14 @@
/** @file game_core.cpp Implementation of Game. */
#include "../stdafx.h"
#include "../command_func.h"
#include "../core/backup_type.hpp"
#include "../core/bitmath_func.hpp"
#include "../company_base.h"
#include "../company_func.h"
#include "../network/network.h"
#include "../window_func.h"
#include "../fileio_func.h"
#include "game.hpp"
#include "game_scanner.hpp"
#include "game_config.hpp"
@@ -94,7 +97,6 @@
delete Game::instance;
Game::instance = NULL;
Game::info = NULL;
cur_company.Restore();
@@ -153,7 +155,6 @@
if (Game::instance != NULL) {
delete Game::instance;
Game::instance = NULL;
Game::info = NULL;
}
} else if (Game::instance != NULL) {
Game::info = _settings_game.game_config->GetInfo();
@@ -177,7 +178,7 @@
InvalidateWindowData(WC_AI_LIST, 0, 1);
SetWindowClassesDirty(WC_AI_DEBUG);
InvalidateWindowClassesData(WC_AI_SETTINGS);
SetWindowDirty(WC_AI_SETTINGS, 0);
}

View File

@@ -11,10 +11,14 @@
#include "../stdafx.h"
#include "../script/squirrel_helper.hpp"
#include "../script/squirrel_class.hpp"
#include "game_info.hpp"
#include "game_scanner.hpp"
#include "../settings_type.h"
#include "../debug.h"
#include "../rev.h"
#include "game.hpp"
/**
* Check if the API version provided by the Game is supported.

View File

@@ -13,6 +13,7 @@
#define GAME_INFO_HPP
#include "../script/script_info.hpp"
#include "../script/script_config.hpp"
/** All static information from an Game like name, version, etc. */
class GameInfo : public ScriptInfo {

View File

@@ -10,12 +10,12 @@
/** @file game_instance.cpp Implementation of GameInstance. */
#include "../stdafx.h"
#include "../error.h"
#include "../debug.h"
#include "../saveload/saveload.h"
#include "../script/squirrel_class.hpp"
#include "../script/script_storage.hpp"
#include "../ai/ai_gui.hpp"
#include "game_config.hpp"
#include "game_info.hpp"
#include "game_instance.hpp"
@@ -126,7 +126,6 @@ void GameInstance::RegisterAPI()
SQGSEventCompanyMerger_Register(this->engine);
SQGSEventCompanyNew_Register(this->engine);
SQGSEventController_Register(this->engine);
SQGSEventGoalQuestionAnswer_Register(this->engine);
SQGSEventIndustryClose_Register(this->engine);
SQGSEventIndustryOpen_Register(this->engine);
SQGSEventStationFirstVehicle_Register(this->engine);
@@ -197,23 +196,6 @@ ScriptInfo *GameInstance::FindLibrary(const char *library, int version)
return (ScriptInfo *)Game::FindLibrary(library, version);
}
void GameInstance::Died()
{
ScriptInstance::Died();
ShowAIDebugWindow(OWNER_DEITY);
const GameInfo *info = Game::GetInfo();
if (info != NULL) {
ShowErrorMessage(STR_ERROR_AI_PLEASE_REPORT_CRASH, INVALID_STRING_ID, WL_WARNING);
if (info->GetURL() != NULL) {
ScriptLog::Info("Please report the error to the following URL:");
ScriptLog::Info(info->GetURL());
}
}
}
/**
* DoCommand callback function for all commands executed by Game Scripts.
* @param result The result of the command.

View File

@@ -30,7 +30,6 @@ public:
private:
/* virtual */ void RegisterAPI();
/* virtual */ void Died();
/* virtual */ CommandCallback *GetDoCommandCallback();
/* virtual */ void LoadDummyScript() {}
};

View File

@@ -10,10 +10,15 @@
/** @file game_scanner.cpp allows scanning Game scripts */
#include "../stdafx.h"
#include "../debug.h"
#include "../fileio_func.h"
#include "../network/network.h"
#include "../core/random_func.hpp"
#include "../script/squirrel_class.hpp"
#include "game_info.hpp"
#include "game_scanner.hpp"
#include "../script/api/script_controller.hpp"
void GameScannerInfo::Initialize()

View File

@@ -10,6 +10,7 @@
/** @file game_text.cpp Implementation of handling translated strings. */
#include "../stdafx.h"
#include "../language.h"
#include "../strgen/strgen.h"
#include "../debug.h"
#include "../fileio_func.h"
@@ -20,6 +21,7 @@
#include "table/strings.h"
#include <exception>
#include <stdarg.h>
void CDECL strgen_warning(const char *s, ...)

View File

@@ -18,8 +18,10 @@
#include "network/network.h"
#include "heightmap.h"
#include "viewport_func.h"
#include "gfx_func.h"
#include "date_func.h"
#include "engine_func.h"
#include "newgrf_storage.h"
#include "water.h"
#include "video/video_driver.hpp"
#include "tilehighlight_func.h"
@@ -34,6 +36,7 @@
#include "game/game.hpp"
#include "game/game_instance.hpp"
#include "table/sprites.h"
void GenerateClearTile();
void GenerateIndustries();

View File

@@ -22,6 +22,7 @@
#include "string_func.h"
#include "widgets/dropdown_type.h"
#include "widgets/dropdown_func.h"
#include "landscape_type.h"
#include "querystring_gui.h"
#include "town.h"
#include "settings_func.h"
@@ -32,6 +33,8 @@
#include "widgets/genworld_widget.h"
#include "table/strings.h"
#include "table/sprites.h"
extern void MakeNewgameSettingsLive();

View File

@@ -20,6 +20,7 @@
#include "settings_type.h"
#include "network/network.h"
#include "network/network_func.h"
#include "thread/thread.h"
#include "window_func.h"
#include "newgrf_debug.h"
@@ -821,36 +822,6 @@ Dimension GetStringMultiLineBoundingBox(StringID str, const Dimension &suggestio
return box;
}
/**
* Calculates height of string (in pixels). The string is changed to a multiline string if needed.
* @param str string to check
* @param maxw maximum string width
* @return height of pixels of string when it is drawn
*/
int GetStringHeight(const char *str, int maxw)
{
char buffer[DRAW_STRING_BUFFER];
strecpy(buffer, str, lastof(buffer));
uint32 tmp = FormatStringLinebreaks(buffer, lastof(buffer), maxw);
return GetMultilineStringHeight(buffer, GB(tmp, 0, 16), FS_NORMAL);
}
/**
* Calculate string bounding box for multi-line strings.
* @param str String to check.
* @param suggestion Suggested bounding box.
* @return Bounding box for the multi-line string, may be bigger than \a suggestion.
*/
Dimension GetStringMultiLineBoundingBox(const char *str, const Dimension &suggestion)
{
Dimension box = {suggestion.width, GetStringHeight(str, suggestion.width)};
return box;
}
/**
* Draw string, possibly over multiple lines.
*

View File

@@ -125,7 +125,6 @@ Dimension GetStringBoundingBox(StringID strid);
uint32 FormatStringLinebreaks(char *str, const char *last, int maxw, FontSize start_fontsize = FS_NORMAL);
int GetStringHeight(StringID str, int maxw);
Dimension GetStringMultiLineBoundingBox(StringID str, const Dimension &suggestion);
Dimension GetStringMultiLineBoundingBox(const char *str, const Dimension &suggestion);
void LoadStringWidthTable(bool monospace = false);
void DrawDirtyBlocks();

View File

@@ -23,6 +23,7 @@
#include "base_media_func.h"
#include "table/sprites.h"
#include "table/strings.h"
/** Whether the given NewGRFs must get a palette remap from windows to DOS or not. */
bool _palette_remap_grf[MAX_FILE_SLOTS];

View File

@@ -13,16 +13,21 @@
#include "company_func.h"
#include "industry.h"
#include "town.h"
#include "news_func.h"
#include "ai/ai.hpp"
#include "station_base.h"
#include "cargotype.h"
#include "strings_func.h"
#include "window_func.h"
#include "goal_base.h"
#include "core/pool_func.hpp"
#include "core/random_func.hpp"
#include "game/game.hpp"
#include "command_func.h"
#include "company_base.h"
#include "string_func.h"
#include "gui.h"
#include "network/network.h"
#include "table/strings.h"
GoalID _new_goal_id;
@@ -113,68 +118,3 @@ CommandCost CmdRemoveGoal(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32
return CommandCost();
}
/**
* Ask a goal related question
* @param tile unused.
* @param flags type of operation
* @param p1 various bitstuffed elements
* - p1 = (bit 0 - 15) - Unique ID to use for this question.
* - p1 = (bit 16 - 23) - Company for which this question is.
* @param p2 Buttons of the question.
* @param text Text of the question.
* @return the cost of this operation or an error
*/
CommandCost CmdGoalQuestion(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
{
uint16 uniqueid = (GoalType)GB(p1, 0, 16);
CompanyID company = (CompanyID)GB(p1, 16, 8);
byte type = GB(p1, 24, 8);
if (_current_company != OWNER_DEITY) return CMD_ERROR;
if (StrEmpty(text)) return CMD_ERROR;
if (company != INVALID_COMPANY && !Company::IsValidID(company)) return CMD_ERROR;
if (CountBits(p2) < 1 || CountBits(p2) > 3) return CMD_ERROR;
if (p2 >= (1 << GOAL_QUESTION_BUTTON_COUNT)) return CMD_ERROR;
if (type >= GOAL_QUESTION_TYPE_COUNT) return CMD_ERROR;
if (flags & DC_EXEC) {
if (company == _local_company || (company == INVALID_COMPANY && Company::IsValidID(_local_company))) ShowGoalQuestion(uniqueid, type, p2, text);
}
return CommandCost();
}
/**
* Reply to a goal question.
* @param tile unused.
* @param flags type of operation
* @param p1 Unique ID to use for this question.
* @param p2 Button the company pressed
* @param text Text of the question.
* @return the cost of this operation or an error
*/
CommandCost CmdGoalQuestionAnswer(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
{
if (p1 > UINT16_MAX) return CMD_ERROR;
if (p2 >= GOAL_QUESTION_BUTTON_COUNT) return CMD_ERROR;
if (_current_company == OWNER_DEITY) {
/* It has been requested to close this specific question on all clients */
if (flags & DC_EXEC) DeleteWindowById(WC_GOAL_QUESTION, p1);
return CommandCost();
}
if (_networking && _local_company == _current_company) {
/* Somebody in the same company answered the question. Close the window */
if (flags & DC_EXEC) DeleteWindowById(WC_GOAL_QUESTION, p1);
if (!_network_server) return CommandCost();
}
if (flags & DC_EXEC) {
Game::NewEvent(new ScriptEventGoalQuestionAnswer(p1, (ScriptCompany::CompanyID)(byte)_current_company, (ScriptGoal::QuestionButton)(1 << p2)));
}
return CommandCost();
}

View File

@@ -7,16 +7,17 @@
* See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
*/
/** @file goal_base.h %Goal base class. */
/** @file goal_base.h Goal base class. */
#ifndef GOAL_BASE_H
#define GOAL_BASE_H
#include "cargo_type.h"
#include "company_type.h"
#include "goal_type.h"
#include "core/pool_type.hpp"
typedef Pool<Goal, GoalID, 1, 256> GoalPool;
typedef Pool<Goal, GoalID, 1, MAX_COMPANIES> GoalPool;
extern GoalPool _goal_pool;
/** Struct about subsidies, offered and awarded */

View File

@@ -16,11 +16,11 @@
#include "strings_func.h"
#include "date_func.h"
#include "viewport_func.h"
#include "gfx_func.h"
#include "gui.h"
#include "goal_base.h"
#include "core/geometry_func.hpp"
#include "company_func.h"
#include "command_func.h"
#include "widgets/goal_widget.h"
@@ -247,137 +247,8 @@ static const WindowDesc _goals_list_desc(
_nested_goals_list_widgets, lengthof(_nested_goals_list_widgets)
);
void ShowGoalsList()
{
AllocateWindowDescFront<GoalListWindow>(&_goals_list_desc, 0);
}
struct GoalQuestionWindow : Window {
char *question;
int buttons;
int button[3];
byte type;
GoalQuestionWindow(const WindowDesc *desc, WindowNumber window_number, byte type, uint32 button_mask, const char *question) : Window(), type(type)
{
assert(type < GOAL_QUESTION_TYPE_COUNT);
this->question = strdup(question);
/* Figure out which buttons we have to enable */
uint bit;
int n = 0;
FOR_EACH_SET_BIT(bit, button_mask) {
if (bit >= GOAL_QUESTION_BUTTON_COUNT) break;
this->button[n++] = bit;
if (n == 3) break;
}
this->buttons = n;
assert(this->buttons > 0 && this->buttons < 4);
this->CreateNestedTree(desc);
this->GetWidget<NWidgetStacked>(WID_GQ_BUTTONS)->SetDisplayedPlane(this->buttons - 1);
this->FinishInitNested(desc, window_number);
}
~GoalQuestionWindow()
{
free(this->question);
}
virtual void SetStringParameters(int widget) const
{
switch (widget) {
case WID_GQ_CAPTION:
SetDParam(0, STR_GOAL_QUESTION_CAPTION_QUESTION + this->type);
break;
case WID_GQ_BUTTON_1:
SetDParam(0, STR_GOAL_QUESTION_BUTTON_CANCEL + this->button[0]);
break;
case WID_GQ_BUTTON_2:
SetDParam(0, STR_GOAL_QUESTION_BUTTON_CANCEL + this->button[1]);
break;
case WID_GQ_BUTTON_3:
SetDParam(0, STR_GOAL_QUESTION_BUTTON_CANCEL + this->button[2]);
break;
}
}
virtual void OnClick(Point pt, int widget, int click_count)
{
switch (widget) {
case WID_GQ_BUTTON_1:
DoCommandP(0, this->window_number, this->button[0], CMD_GOAL_QUESTION_ANSWER);
delete this;
break;
case WID_GQ_BUTTON_2:
DoCommandP(0, this->window_number, this->button[1], CMD_GOAL_QUESTION_ANSWER);
delete this;
break;
case WID_GQ_BUTTON_3:
DoCommandP(0, this->window_number, this->button[2], CMD_GOAL_QUESTION_ANSWER);
delete this;
break;
}
}
virtual void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize)
{
if (widget != WID_GQ_QUESTION) return;
SetDParamStr(0, this->question);
size->height = GetStringHeight(STR_JUST_RAW_STRING, size->width) + WD_PAR_VSEP_WIDE;
}
virtual void DrawWidget(const Rect &r, int widget) const
{
if (widget != WID_GQ_QUESTION) return;
SetDParamStr(0, this->question);
DrawStringMultiLine(r.left, r.right, r.top, UINT16_MAX, STR_JUST_RAW_STRING, TC_BLACK, SA_TOP | SA_HOR_CENTER);
}
};
static const NWidgetPart _nested_goal_question_widgets[] = {
NWidget(NWID_HORIZONTAL),
NWidget(WWT_CLOSEBOX, COLOUR_LIGHT_BLUE),
NWidget(WWT_CAPTION, COLOUR_LIGHT_BLUE, WID_GQ_CAPTION), SetDataTip(STR_WHITE_STRING, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS),
EndContainer(),
NWidget(WWT_PANEL, COLOUR_LIGHT_BLUE),
NWidget(WWT_EMPTY, INVALID_COLOUR, WID_GQ_QUESTION), SetMinimalSize(300, 0), SetPadding(8, 8, 8, 8), SetFill(1, 0),
NWidget(NWID_SELECTION, INVALID_COLOUR, WID_GQ_BUTTONS),
NWidget(NWID_HORIZONTAL, NC_EQUALSIZE), SetPIP(85, 10, 85),
NWidget(WWT_PUSHTXTBTN, COLOUR_LIGHT_BLUE, WID_GQ_BUTTON_1), SetDataTip(STR_BLACK_STRING, STR_NULL), SetFill(1, 0),
EndContainer(),
NWidget(NWID_HORIZONTAL, NC_EQUALSIZE), SetPIP(65, 10, 65),
NWidget(WWT_PUSHTXTBTN, COLOUR_LIGHT_BLUE, WID_GQ_BUTTON_1), SetDataTip(STR_BLACK_STRING, STR_NULL), SetFill(1, 0),
NWidget(WWT_PUSHTXTBTN, COLOUR_LIGHT_BLUE, WID_GQ_BUTTON_2), SetDataTip(STR_BLACK_STRING, STR_NULL), SetFill(1, 0),
EndContainer(),
NWidget(NWID_HORIZONTAL, NC_EQUALSIZE), SetPIP(25, 10, 25),
NWidget(WWT_PUSHTXTBTN, COLOUR_LIGHT_BLUE, WID_GQ_BUTTON_1), SetDataTip(STR_BLACK_STRING, STR_NULL), SetFill(1, 0),
NWidget(WWT_PUSHTXTBTN, COLOUR_LIGHT_BLUE, WID_GQ_BUTTON_2), SetDataTip(STR_BLACK_STRING, STR_NULL), SetFill(1, 0),
NWidget(WWT_PUSHTXTBTN, COLOUR_LIGHT_BLUE, WID_GQ_BUTTON_3), SetDataTip(STR_BLACK_STRING, STR_NULL), SetFill(1, 0),
EndContainer(),
EndContainer(),
NWidget(NWID_SPACER), SetMinimalSize(0, 8),
EndContainer(),
};
static const WindowDesc _goal_question_list_desc(
WDP_CENTER, 0, 0,
WC_GOAL_QUESTION, WC_NONE,
WDF_CONSTRUCTION,
_nested_goal_question_widgets, lengthof(_nested_goal_question_widgets)
);
void ShowGoalQuestion(uint16 id, byte type, uint32 button_mask, const char *question)
{
new GoalQuestionWindow(&_goal_question_list_desc, id, type, button_mask, question);
}

View File

@@ -12,11 +12,6 @@
#ifndef GOAL_TYPE_H
#define GOAL_TYPE_H
#include "core/enum_type.hpp"
static const uint32 GOAL_QUESTION_BUTTON_COUNT = 18; ///< Amount of buttons available.
static const byte GOAL_QUESTION_TYPE_COUNT = 4; ///< Amount of question types.
/** Types of goal destinations */
enum GoalType {
GT_NONE, ///< Destination is not linked

View File

@@ -22,13 +22,13 @@
#include "gfx_func.h"
#include "sortlist_type.h"
#include "core/geometry_func.hpp"
#include "math.h"
#include "currency.h"
#include "widgets/graph_widget.h"
#include "table/strings.h"
#include "table/sprites.h"
#include <math.h>
/* Bitmasks of company and cargo indices that shouldn't be drawn. */
static uint _legend_excluded_companies;
@@ -717,7 +717,7 @@ struct DeliveredCargoGraphWindow : BaseGraphWindow {
virtual OverflowSafeInt64 GetGraphData(const Company *c, int j)
{
return c->old_economy[j].delivered_cargo.GetSum<OverflowSafeInt64>();
return c->old_economy[j].delivered_cargo;
}
};

View File

@@ -12,6 +12,8 @@
#include "stdafx.h"
#include "train.h"
#include "roadveh.h"
#include "vehicle_gui.h"
#include "window_func.h"
/**
* Recalculates the cached total power of a vehicle. Should be called when the consist is changed.

View File

@@ -16,7 +16,6 @@
#include "vehicle_gui.h"
#include "landscape.h"
#include "window_func.h"
#include "widgets/vehicle_widget.h"
/** What is the status of our acceleration? */
enum AccelStatus {
@@ -227,10 +226,10 @@ struct GroundVehicle : public SpecializedVehicle<T, Type> {
/**
* Checks if the vehicle is in a slope and sets the required flags in that case.
* @param new_tile True if the vehicle reached a new tile.
* @param update_delta Indicates to also update the delta.
* @param turned Indicates if the vehicle has turned.
* @return Old height of the vehicle.
*/
inline byte UpdateInclination(bool new_tile, bool update_delta)
inline byte UpdateInclination(bool new_tile, bool turned)
{
byte old_z = this->z_pos;
@@ -240,7 +239,7 @@ struct GroundVehicle : public SpecializedVehicle<T, Type> {
this->UpdateZPosition();
}
this->UpdateViewport(true, update_delta);
this->UpdateViewport(true, turned);
return old_z;
}

View File

@@ -12,8 +12,11 @@
#include "stdafx.h"
#include "cmd_helper.h"
#include "command_func.h"
#include "group.h"
#include "train.h"
#include "vehicle_gui.h"
#include "vehiclelist.h"
#include "window_func.h"
#include "vehicle_func.h"
#include "autoreplace_base.h"
#include "autoreplace_func.h"

View File

@@ -14,6 +14,7 @@
#include "command_func.h"
#include "vehicle_gui.h"
#include "vehicle_base.h"
#include "group.h"
#include "string_func.h"
#include "strings_func.h"
#include "window_func.h"
@@ -28,6 +29,7 @@
#include "widgets/group_widget.h"
#include "table/strings.h"
#include "table/sprites.h"
typedef GUIList<const Group*> GUIGroupList;

View File

@@ -16,6 +16,7 @@
#include "gfx_type.h"
#include "economy_type.h"
#include "tile_type.h"
#include "strings_type.h"
#include "transport_type.h"
struct Window;
@@ -29,7 +30,6 @@ void ShowGameOptions();
void ShowGameDifficulty();
void ShowGameSettings();
void DrawArrowButtons(int x, int y, Colours button_colour, byte state, bool clickable_left, bool clickable_right);
void DrawBoolButton(int x, int y, bool state, bool clickable);
/* train_gui.cpp */
void ShowOrdersWindow(const Vehicle *v);
@@ -53,7 +53,6 @@ void ShowTownDirectory();
void ShowIndustryDirectory();
void ShowSubsidiesList();
void ShowGoalsList();
void ShowGoalQuestion(uint16 id, byte type, uint32 button_mask, const char *question);
void ShowEstimatedCostOrIncome(Money cost, int x, int y);

View File

@@ -28,7 +28,7 @@
*/
static inline byte RGBToGrayscale(byte red, byte green, byte blue)
{
/* To avoid doubles and stuff, multiply it with a total of 65536 (16bits), then
/* To avoid doubles and stuff, multiple it with a total of 65536 (16bits), then
* divide by it to normalize the value to a byte again. */
return ((red * 19595) + (green * 38470) + (blue * 7471)) / 65536;
}

View File

@@ -7,7 +7,7 @@
* See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
*/
/** @file hotkeys.h %Hotkey related functions. */
/** @file hotkeys.h Hotkey related functions. */
#ifndef HOTKEYS_H
#define HOTKEYS_H

Some files were not shown because too many files have changed in this diff Show More