Compare commits

..

38 Commits

Author SHA1 Message Date
rubidium 363a076979 (svn r24306) -Release: 1.2.1 2012-05-31 20:54:17 +00:00
rubidium 4a031c91db (svn r24305) [1.2] -Backport from trunk:
- Fix: [Script] ScriptTown::GetGrowthRate() returned wrong values after usage of SetGrowthRate() (r24302)
[1.2] -Update: documentation
2012-05-31 20:48:17 +00:00
rubidium 9a04ccdcab (svn r24258) [1.2] -Update: some documentation 2012-05-16 20:11:20 +00:00
rubidium b6549a448d (svn r24254) [1.2] -Backport from trunk:
- Fix: Change the unit of the sprite-cache size setting from megabytes to megapixels, so it depends on the blitter being used. Also increase it from 64 to 128, and change the name in the cfg file, so everyone gets the new default [FS#5162] (r24252)
- Fix: Do not immediately display error messages from parsing the cfg file, but schedule them for displaying after the GUI is prepared for it [FS#5154] (r24250, r24249, r24248, r24247)
- Fix: The object GUI did not draw objects when all objects of a class are disabled (r24176)
2012-05-15 20:54:40 +00:00
rubidium b8abfce71d (svn r24253) [1.2] -Backport: string updates from trunk 2012-05-15 20:48:06 +00:00
rubidium 8dfe4d2dca (svn r24232) [1.2] -Backport from trunk:
- Fix: Dereferencing uninitialised pointer causing a crash [FS#5159] (r24224)
- Fix: Lag counters were not properly reset when switching states making it possible to get disconnected for lagging when you were not lagging [FS#5166] (r24221)
- Fix: Adopt ICU version detection to also deal with the new versioning scheme since ICU 49 (r24220)
2012-05-12 07:47:00 +00:00
rubidium 012871f24c (svn r24231) [1.2] -Backport from trunk:
- Fix: Immediately do the cargo payment on vehicle crashes instead of when they are cleared [FS#5152] (r24219)
- Fix: The confirmation window to abort world generation was hidden during world generation, so actually you could not abort it [FS#5159] (r24214)
- Fix: If a company is taken over or bankrupts, transfer exclusive transport rights to the new owner respectively cancel them (r24204)
2012-05-12 07:46:05 +00:00
rubidium 7f8b41d956 (svn r24230) [1.2] -Backport from trunk:
- Fix: Make the engine name not overdraw the engine count in the autoreplace GUI (r24203)
- Fix: Make the size of the details in the autoreplace GUI match more the size of the details in the purchase list (r24202)
- Fix: Mark group list dirty when setting/clearing autoreplace for an engine type [FS#5170] (r24201)
- Fix: Invalidate build vehicle windows every month, in case they need resorting due to changed reliabilities [FS#5149] (r24200)
2012-05-12 07:42:39 +00:00
rubidium fcaca9f7ee (svn r24229) [1.2] -Backport from trunk:
- Fix: If you consider a settings to potentially cause desyncs via NewGRFs and thus disallow changing it in network games, you should probably also sync it to clients (r24193, r24191)
- Fix: Use default value when reading an invalid setting value [FS#5153] (r24192, r24146)
- Fix: [Windows] When going to fullscreen and back, restore to the resolution you were, not to the fullscreen resolution (r24189)
- Fix: [Windows] When changing the basics of a window (fullscreen, 8bpp/32bpp), and a window already exists, it was forced out of maximize mode, and its resolution/position was reset, often causing unwanted side-effects [FS#5151] (r24188)
2012-05-12 07:37:14 +00:00
rubidium 5ca16c21d3 (svn r24228) [1.2] -Backport from trunk:
- Fix: Town radii were not updated immediatelly after construction/destruction of houses, resulting in desyncs [FS#5169] (r24183)
- Fix: The population of a town was computed incorrectly for overridden houses when loading a game (r24182, r24181, r24179)
- Fix: The object name from property A was not displayed in the object GUI [FS#5110] (r24178)
2012-05-12 07:31:25 +00:00
rubidium 0603cd6efc (svn r24227) [1.2] -Backport from trunk:
- Fix: [Squirrel] Crash when trying to create an array with negative size [FS#5160] (r24153)
- Fix: [NoAI] Do not return the last 'cached' speed of vehicles when they are stopped/crashed [FS#5157] (r24152)
- Fix: [Script] Typo in script documentation (r24151)
- Fix: Glass-sprite of bubble-generator was not drawn anymore for completely constructed tiles [FS#5143] (r24107)
2012-05-12 07:24:11 +00:00
rubidium 4e6310d848 (svn r24226) [1.2] -Backport from trunk:
- Fix: [Squirrel] Crash when trying to create an array with negative size [FS#5160] (r24153)
- Fix: [NoAI] Do not return the last 'cached' speed of vehicles when they are stopped/crashed [FS#5157] (r24152)
- Fix: [Script] Typo in script documentation (r24151)
- Fix: Glass-sprite of bubble-generator was not drawn anymore for completely constructed tiles [FS#5143] (r24107)
2012-05-12 07:22:40 +00:00
rubidium 7549982f12 (svn r24225) [1.2] -Backport from trunk:
- Fix: Conflicting strategies for resizing the main toolbar and statusbar after resizing the main window [FS#5136] (r24089)
- Fix: Significantly reduce the area that is redrawn for text effects [FS#5103] (r24068)
- Fix: Do not redraw up to 25% of the map when making a new vehicle visible for the first time (r24067)
- Fix: Do not redraw the text effect when nothing changed (r24066)
2012-05-12 07:19:47 +00:00
rubidium 87064a39a6 (svn r24120) [1.2] -Fix [FS#5155]: accidental removal of constant definition in Windows installer 2012-04-15 18:51:02 +00:00
rubidium e4efad8374 (svn r24117) [1.2] -Update: some documentation 2012-04-15 11:49:54 +00:00
rubidium 7faff38bfb (svn r24116) [1.2] -Backport from trunk:
- Fix: When starting GS or AI, always use the settings of the game, not the new-game settings [FS#5142] (r24108)
- Fix: Provide translated comments in the desktop file without language name postfix (r24100)
- Fix: Cloning orders of aircraft with limited range failed [FS#5131] (r24086)
2012-04-15 08:50:23 +00:00
rubidium 2b5280bedb (svn r24083) [1.2] -Update: documentation 2012-03-31 21:50:52 +00:00
rubidium dd0bc179be (svn r24082) [1.2] -Backport from trunk:
- Update: languages
- Fix: A fix that breaks all other cases isn't really a fix. Redo it to make sure that reservations of trains entering or exiting depots are properly made and freed-Fix [FS#5093,FS#5130] (r24071): A fix that breaks all other cases isn't really a fix. Redo it to make sure that reservations of trains entering or exiting depots are properly made and freed [FS#5093,FS#5130] (r24078)
2012-03-31 17:55:38 +00:00
rubidium 2a13e8c184 (svn r24075) [1.2] -Backport from trunk:
- Fix: Reversing trains while they were entering or leaving a depot could lead to stuck trains [FS#5093] (r24071)
- Fix: The 'last joined' server was not properly selected anymore [FS#5098] (r24070)
- Fix: Immediately start querying the last joined server instead of waiting for the requery loop [FS#5097] (r24069, r24062)
- Fix: Make the full snowedness level of houses the same as roads and rails [FS#5121] (r24064)
2012-03-26 20:41:21 +00:00
rubidium 557be445af (svn r24074) [1.2] -Backport from trunk:
- Fix: With certain versions of GCC and compiler flags the compiler could reorder some code badly causing the 32bpp depot flag not working [FS#5125] (r24063)
- Fix: Do not freeze aircraft mid-flight when skipping to an out-of-range destination [FS#5123] (r24060)
- Fix: Crash when timetabling a maximum travel speed of 0 [FS#5111] (r24053)
- Fix: [NewGRF] Imported GRF sounds were inserted into the wrong slots [FS#5107] (r24052)
- Fix: [NewGRF] Realsprites inside the action 11 block were not skipped correctly (r24050)
2012-03-26 20:38:53 +00:00
rubidium 12fac2345e (svn r24073) [1.2] -Backport from trunk:
- Fix: Wrong numbering of string parameters causing wrong capacities to be shown [FS#5124] (r24058)
- Fix: Improve error messages for the placement restrictions of banks, water towers and toy shops [FS#5095] (r24040)
2012-03-26 20:36:38 +00:00
planetmaker adcb6aac5a (svn r24049) [1.2] -Doc: Add credits for title game
-Cleanup: Sync credits between readme and ingame information (r24048)
2012-03-19 20:39:55 +00:00
rubidium c70e680e5e (svn r24045) [1.2] -Update: some documentation 2012-03-18 17:08:27 +00:00
rubidium 50fa7f679f (svn r24044) [1.2] -Fix: forgot some languages 2012-03-18 17:04:22 +00:00
rubidium 8545ab9c22 (svn r24043) [1.2] -Backport from trunk: string updates 2012-03-18 17:00:47 +00:00
rubidium 9c36498695 (svn r24041) [1.2] -Backport from trunk:
- Fix: After opening a text window with the monospaced font, all other text started glitching (r24038)
- Feature: Allow display of baseset textfiles (r24037)
2012-03-18 16:47:16 +00:00
rubidium d5e69ff1fa (svn r24036) [1.2] -Change: the title game from the title game competition (sc79). Some changes have been made outside of the view to reduce the file size significantly (chop trees, flatten ground) 2012-03-17 11:49:26 +00:00
rubidium 908ff68459 (svn r24034) [1.2] -Backport from trunk:
- Feature: Increase the station class limit from 32 to 256 (r24031)
- Fix: [NoAI] reset 'is random' status of temporary variable during saveload as it is not always written to when loading an AI which means it wouldd be taking the 'is random' setting of another AI (r24033)
- Fix: [NoAI] Make AIEngine::IsArticulated return true if the articulated callback flag is set, do not try to run the callback (r24029)
- Fix: Pass cases down into the list of cargos [FS#5090] (r24024, r24023, r24022)
2012-03-17 11:20:43 +00:00
rubidium b6d5e4d60c (svn r24014) [1.2] -Prepare for 1.2.0-RC2 2012-03-04 17:16:37 +00:00
rubidium d793f89ec3 (svn r24013) [1.2] -Backport language updates from trunk 2012-03-04 17:12:36 +00:00
rubidium 32aee004c6 (svn r24010) [1.2] -Fix: forgot to backport r23992 2012-03-04 17:01:23 +00:00
rubidium 5814764af9 (svn r24009) [1.2] -Backport from trunk:
- Fix: [Script] AI used in names in API for GSOrder [FS#5088] (r24006)
2012-03-04 16:56:41 +00:00
rubidium e19915d824 (svn r24007) [1.2] -Backport from trunk:
- Fix: Improve rounding when converting display speeds to internal speeds [FS#5079] (r23995)
- Fix: Also reset the font glyph cache when switching blitters (r23992, r23987)
- Fix: [NewGRF] Also display the cargo subtype for vehicles which have no capacity, but a subtype [FS#5076] (r23991)
2012-03-04 16:43:35 +00:00
rubidium 9bcd02e389 (svn r24005) [1.2] -Backport from trunk:
- Fix: Fix the order of lights on the helipad [FS#5082] (r23984)
2012-03-04 16:39:12 +00:00
rubidium 2ab087f31f (svn r24004) [1.2] -Backport from trunk:
- Fix: Zero the offsets of disabled zoomlevels, so they do not influence offset calculations (r23989)
- Fix: Invalid reads when scaling an odd-sized sprite smaller (r23986)
- Fix: Inconsistent quit/abandon/exit game/scenario/editor strings [FS#5074] (r23985)
- Fix: Tarred heightmaps would not be found [FS#5083] (r23983)
2012-03-04 16:38:05 +00:00
rubidium 9d168228e7 (svn r24003) [1.2] -Backport from trunk:
- Fix: Do not load a game during UpdateWindows as that might trigger changing the blitter which triggers re-entrant locking (r23980, r23977)
- Fix: [SDL] Palette update was done too late making switching from 8bpp -> 32bpp look ugly (r23978)
- Fix: Sprites of different zoom levels were not always padded correctly to a common size (r23976)
- Fix: Also save the maximum travel speed for the current vehicle order (r23973)
2012-03-04 16:33:13 +00:00
rubidium 8f8be22bc9 (svn r23970) [1.2] -Prepare: 1.2.0-RC1 2012-02-19 19:53:20 +00:00
rubidium ebb7d2084b (svn r23968) [1.2] -Branch: there we go... 2012-02-19 19:07:09 +00:00
447 changed files with 25749 additions and 38127 deletions
+4
View File
@@ -10,9 +10,13 @@
#
# The revision is needed for the bundle name and creating an OSX application bundle.
ifdef REVISION
REV := $(REVISION)
else
# Detect the revision
VERSIONS := $(shell AWK="$(AWK)" "$(ROOT_DIR)/findversion.sh")
REV := $(shell echo "$(VERSIONS)" | cut -f 1 -d' ')
endif
# Make sure we have something in REV
ifeq ($(REV),)
+1
View File
@@ -41,6 +41,7 @@ TTDS = $(SRC_DIRS:%=%/$(TTD))
OS = !!OS!!
OSXAPP = !!OSXAPP!!
LIPO = !!LIPO!!
REVISION = !!REVISION!!
AWK = !!AWK!!
SORT = !!SORT!!
DISTCC = !!DISTCC!!
+7 -8
View File
@@ -14,7 +14,6 @@ LANGS_SRC = $(shell ls $(LANG_DIR)/*.txt)
LANGS = $(LANGS_SRC:$(LANG_DIR)/%.txt=%.lng)
CXX_BUILD = !!CXX_BUILD!!
CFLAGS_BUILD = !!CFLAGS_BUILD!!
CXXFLAGS_BUILD= !!CXXFLAGS_BUILD!!
LDFLAGS_BUILD = !!LDFLAGS_BUILD!!
STRGEN_FLAGS = !!STRGEN_FLAGS!!
STAGE = !!STAGE!!
@@ -45,23 +44,23 @@ all: table/strings.h $(LANGS)
strgen_base.o: $(SRC_DIR)/strgen/strgen_base.cpp $(SRC_DIR)/strgen/strgen.h endian_host.h $(SRC_DIR)/table/control_codes.h $(SRC_DIR)/table/strgen_tables.h
$(E) '$(STAGE) Compiling $(<:$(SRC_DIR)/%.cpp=%.cpp)'
$(Q)$(CXX_BUILD) $(CFLAGS_BUILD) $(CXXFLAGS_BUILD) -DSTRGEN -c -o $@ $<
$(Q)$(CXX_BUILD) $(CFLAGS_BUILD) -DSTRGEN -c -o $@ $<
strgen.o: $(SRC_DIR)/strgen/strgen.cpp $(SRC_DIR)/strgen/strgen.h endian_host.h $(SRC_DIR)/table/control_codes.h $(SRC_DIR)/table/strgen_tables.h
$(E) '$(STAGE) Compiling $(<:$(SRC_DIR)/%.cpp=%.cpp)'
$(Q)$(CXX_BUILD) $(CFLAGS_BUILD) $(CXXFLAGS_BUILD) -DSTRGEN -c -o $@ $<
$(Q)$(CXX_BUILD) $(CFLAGS_BUILD) -DSTRGEN -c -o $@ $<
string.o: $(SRC_DIR)/string.cpp endian_host.h
$(E) '$(STAGE) Compiling $(<:$(SRC_DIR)/%.cpp=%.cpp)'
$(Q)$(CXX_BUILD) $(CFLAGS_BUILD) $(CXXFLAGS_BUILD) -DSTRGEN -c -o $@ $<
$(Q)$(CXX_BUILD) $(CFLAGS_BUILD) -DSTRGEN -c -o $@ $<
alloc_func.o: $(SRC_DIR)/core/alloc_func.cpp endian_host.h
$(E) '$(STAGE) Compiling $(<:$(SRC_DIR)/%.cpp=%.cpp)'
$(Q)$(CXX_BUILD) $(CFLAGS_BUILD) $(CXXFLAGS_BUILD) -DSTRGEN -c -o $@ $<
$(Q)$(CXX_BUILD) $(CFLAGS_BUILD) -DSTRGEN -c -o $@ $<
getoptdata.o: $(SRC_DIR)/misc/getoptdata.cpp $(SRC_DIR)/misc/getoptdata.h
$(E) '$(STAGE) Compiling $(<:$(SRC_DIR)/misc/%.cpp=%.cpp)'
$(Q)$(CXX_BUILD) $(CFLAGS_BUILD) $(CXXFLAGS_BUILD) -DSTRGEN -c -o $@ $<
$(Q)$(CXX_BUILD) $(CFLAGS_BUILD) -DSTRGEN -c -o $@ $<
lang/english.txt: $(LANG_DIR)/english.txt
$(Q)mkdir -p lang
@@ -69,7 +68,7 @@ lang/english.txt: $(LANG_DIR)/english.txt
$(STRGEN): alloc_func.o string.o strgen_base.o strgen.o getoptdata.o
$(E) '$(STAGE) Compiling and Linking $@'
$(Q)$(CXX_BUILD) $(CFLAGS_BUILD) $(CXXFLAGS_BUILD) $(LDFLAGS_BUILD) $^ -o $@
$(Q)$(CXX_BUILD) $(LDFLAGS_BUILD) $^ -o $@
table/strings.h: lang/english.txt $(STRGEN)
$(E) '$(STAGE) Generating $@'
@@ -88,7 +87,7 @@ endian_host.h: $(ENDIAN_CHECK)
$(ENDIAN_CHECK): $(SRC_DIR)/endian_check.cpp
$(E) '$(STAGE) Compiling and Linking $@'
$(Q)$(CXX_BUILD) $(CFLAGS_BUILD) $(CXXFLAGS_BUILD) $(LDFLAGS_BUILD) $< -o $@
$(Q)$(CXX_BUILD) $(CFLAGS_BUILD) $< -o $@
depend:
+7 -8
View File
@@ -10,7 +10,6 @@ ENDIAN_CHECK = !!ENDIAN_CHECK!!
SRC_DIR = !!SRC_DIR!!
CXX_BUILD = !!CXX_BUILD!!
CFLAGS_BUILD = !!CFLAGS_BUILD!!
CXXFLAGS_BUILD = !!CXXFLAGS_BUILD!!
LDFLAGS_BUILD = !!LDFLAGS_BUILD!!
STAGE = !!STAGE!!
SETTING_OBJS_DIR = !!SETTING_OBJS_DIR!!
@@ -30,27 +29,27 @@ all: table/settings.h
settingsgen.o: $(SRC_DIR)/settingsgen/settingsgen.cpp $(SRC_DIR)/string_func.h $(SRC_DIR)/strings_type.h $(SRC_DIR)/misc/getoptdata.h $(SRC_DIR)/ini_type.h $(SRC_DIR)/core/smallvec_type.hpp
$(E) '$(STAGE) Compiling $(<:$(SRC_DIR)/%.cpp=%.cpp)'
$(Q)$(CXX_BUILD) $(CFLAGS_BUILD) $(CXXFLAGS_BUILD) -DSETTINGSGEN -c -o $@ $<
$(Q)$(CXX_BUILD) $(CFLAGS_BUILD) -DSETTINGSGEN -c -o $@ $<
alloc_func.o: $(SRC_DIR)/core/alloc_func.cpp endian_host.h
$(E) '$(STAGE) Compiling $(<:$(SRC_DIR)/%.cpp=%.cpp)'
$(Q)$(CXX_BUILD) $(CFLAGS_BUILD) $(CXXFLAGS_BUILD) -DSETTINGSGEN -c -o $@ $<
$(Q)$(CXX_BUILD) $(CFLAGS_BUILD) -DSETTINGSGEN -c -o $@ $<
getoptdata.o: $(SRC_DIR)/misc/getoptdata.cpp $(SRC_DIR)/misc/getoptdata.h
$(E) '$(STAGE) Compiling $(<:$(SRC_DIR)/misc/%.cpp=%.cpp)'
$(Q)$(CXX_BUILD) $(CFLAGS_BUILD) $(CXXFLAGS_BUILD) -DSETTINGSGEN -c -o $@ $<
$(Q)$(CXX_BUILD) $(CFLAGS_BUILD) -DSETTINGSGEN -c -o $@ $<
string.o: $(SRC_DIR)/string.cpp endian_host.h
$(E) '$(STAGE) Compiling $(<:$(SRC_DIR)/%.cpp=%.cpp)'
$(Q)$(CXX_BUILD) $(CFLAGS_BUILD) $(CXXFLAGS_BUILD) -DSETTINGSGEN -c -o $@ $<
$(Q)$(CXX_BUILD) $(CFLAGS_BUILD) -DSETTINGSGEN -c -o $@ $<
ini_load.o: $(SRC_DIR)/ini_load.cpp $(SRC_DIR)/core/alloc_func.hpp $(SRC_DIR)/core/mem_func.hpp $(SRC_DIR)/ini_type.h $(SRC_DIR)/string_func.h
$(E) '$(STAGE) Compiling $(<:$(SRC_DIR)/%.cpp=%.cpp)'
$(Q)$(CXX_BUILD) $(CFLAGS_BUILD) $(CXXFLAGS_BUILD) -DSETTINGSGEN -c -o $@ $<
$(Q)$(CXX_BUILD) $(CFLAGS_BUILD) -DSETTINGSGEN -c -o $@ $<
$(SETTINGSGEN): alloc_func.o string.o ini_load.o settingsgen.o getoptdata.o
$(E) '$(STAGE) Compiling and Linking $@'
$(Q)$(CXX_BUILD) $(CFLAGS_BUILD) $(CXXFLAGS_BUILD) $(LDFLAGS_BUILD) $^ -o $@
$(Q)$(CXX_BUILD) $(LDFLAGS_BUILD) $^ -o $@
table/settings.h: $(SETTINGSGEN) $(SRC_DIR)/table/settings.h.preamble $(SRC_DIR)/table/settings.h.postamble $(SRC_DIR)/table/*.ini
$(E) '$(STAGE) Generating $@'
@@ -65,7 +64,7 @@ endian_host.h: $(ENDIAN_CHECK)
$(ENDIAN_CHECK): $(SRC_DIR)/endian_check.cpp
$(E) '$(STAGE) Compiling and Linking $@'
$(Q)$(CXX_BUILD) $(CFLAGS_BUILD) $(CXXFLAGS_BUILD) $(LDFLAGS_BUILD) $< -o $@
$(Q)$(CXX_BUILD) $(CFLAGS_BUILD) $< -o $@
depend:
-2
View File
@@ -6,5 +6,3 @@
* OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* 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/>.
*/
AILog.Info("1.2 API compatability in effect.");
-8
View File
@@ -1,8 +0,0 @@
/* $Id$ */
/*
* This file is part of OpenTTD.
* OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
* OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* 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/>.
*/
+146 -143
View File
@@ -88,9 +88,9 @@
abs( 21): 21
--AIBase--
Rand(): -54346916
Rand(): -937374575
Rand(): 823953997
Rand(): 1259692483
Rand(): -1289244298
Rand(): -1572996668
RandRange(0): 0
RandRange(0): 0
RandRange(0): 0
@@ -98,12 +98,12 @@
RandRange(1): 0
RandRange(1): 0
RandRange(2): 1
RandRange(2): 0
RandRange(2): 1
RandRange(2): 1
RandRange(1000000): 966676
RandRange(1000000): 289525
RandRange(1000000): 170283
Chance(1, 2): false
RandRange(1000000): 36500
RandRange(1000000): 300101
RandRange(1000000): 418369
Chance(1, 2): true
Chance(1, 2): true
Chance(1, 2): false
@@ -420,144 +420,144 @@
1098 => 46116
1099 => 46158
Randomize ListDump:
1 => -200078348
2 => -29799264
1000 => 1630721656
1001 => 959306175
1002 => 1527421791
1003 => 1259692483
1004 => -1289244298
1005 => -1572996668
1006 => -2069479746
1007 => -1819131606
1008 => -1007163964
1009 => -1185394870
1010 => -1471365065
1011 => 364354366
1012 => -1478084253
1013 => 405281367
1014 => -11170062
1015 => 156767750
1016 => 1288924796
1017 => 1796884876
1018 => -1947073702
1019 => -1999614238
1020 => -231292809
1021 => 966621566
1022 => -606766557
1023 => -1138727825
1024 => -749544262
1025 => 2004771271
1026 => 686734186
1027 => 923274744
1028 => -1672035149
1029 => -1642064950
1030 => 1363389551
1031 => -559500928
1032 => 1656196991
1033 => 1655354425
1034 => -1027156689
1035 => 1952644328
1036 => 1217870217
1037 => 242274100
1038 => 201816080
1039 => 2127464758
1040 => 446043650
1041 => -319728455
1042 => 204701002
1043 => -571265398
1044 => -1422217131
1045 => -391208397
1046 => -1822628371
1047 => -1499755350
1048 => -1422137641
1049 => 1621693134
1051 => -1428728134
1052 => -147587573
1053 => 681719500
1054 => 1172011190
1055 => -1834344882
1056 => 1157634586
1057 => 1902133676
1058 => -1967780161
1059 => -1618025531
1060 => -810220453
1061 => 1582854921
1062 => -410004643
1063 => 1159917159
1064 => -1377804984
1065 => -738843914
1066 => -1578756103
1067 => -464090986
1068 => 1711504679
1069 => 545330655
1070 => 379462570
1071 => 514511099
1072 => -1813251176
1073 => 1424958266
1074 => -825255131
1075 => 539054595
1076 => -1764192010
1077 => -1243277769
1078 => 2017874281
1079 => -1972353607
1080 => 1879761467
1081 => 1638986560
1082 => -1832287507
1083 => -492411882
1084 => 658940812
1085 => -1044199400
1086 => 1586504918
1087 => -125492611
1088 => -1562883174
1089 => -1013778441
1090 => 1560228607
1091 => -550265689
1092 => 524767105
1093 => -713387661
1094 => 1425927738
1095 => 942653932
1096 => 1233220698
1097 => 1313602368
1098 => -140318584
1099 => 1199179892
1 => 966621566
2 => -606766557
1000 => -1138727825
1001 => -749544262
1002 => 2004771271
1003 => 686734186
1004 => 923274744
1005 => -1672035149
1006 => -1642064950
1007 => 1363389551
1008 => -559500928
1009 => 1656196991
1010 => 1655354425
1011 => -1027156689
1012 => 1952644328
1013 => 1217870217
1014 => 242274100
1015 => 201816080
1016 => 2127464758
1017 => 446043650
1018 => -319728455
1019 => 204701002
1020 => -571265398
1021 => -1422217131
1022 => -391208397
1023 => -1822628371
1024 => -1499755350
1025 => -1422137641
1026 => 1621693134
1027 => -1428728134
1028 => -147587573
1029 => 681719500
1030 => 1172011190
1031 => -1834344882
1032 => 1157634586
1033 => 1902133676
1034 => -1967780161
1035 => -1618025531
1036 => -810220453
1037 => 1582854921
1038 => -410004643
1039 => 1159917159
1040 => -1377804984
1041 => -738843914
1042 => -1578756103
1043 => -464090986
1044 => 1711504679
1045 => 545330655
1046 => 379462570
1047 => 514511099
1048 => -1813251176
1049 => 1424958266
1051 => -825255131
1052 => 539054595
1053 => -1764192010
1054 => -1243277769
1055 => 2017874281
1056 => -1972353607
1057 => 1879761467
1058 => 1638986560
1059 => -1832287507
1060 => -492411882
1061 => 658940812
1062 => -1044199400
1063 => 1586504918
1064 => -125492611
1065 => -1562883174
1066 => -1013778441
1067 => 1560228607
1068 => -550265689
1069 => 524767105
1070 => -713387661
1071 => 1425927738
1072 => 942653932
1073 => 1233220698
1074 => 1313602368
1075 => -140318584
1076 => 1199179892
1077 => 91450916
1078 => -1471626821
1079 => -552692855
1080 => -801295697
1081 => 1307607393
1082 => -2111765574
1083 => 1773729008
1084 => -81987003
1085 => -1090790034
1086 => -843700327
1087 => -1306436740
1088 => 735656985
1089 => -1933491876
1090 => 642759863
1091 => 255293949
1092 => -1052469001
1093 => -1043605053
1094 => -2080328201
1095 => -1825196581
1096 => -1789181164
1097 => -1636072563
1098 => -111321262
1099 => 1979741000
KeepTop(10):
1 => -200078348
2 => -29799264
1000 => 1630721656
1001 => 959306175
1002 => 1527421791
1003 => 1259692483
1004 => -1289244298
1005 => -1572996668
1006 => -2069479746
1007 => -1819131606
1 => 966621566
2 => -606766557
1000 => -1138727825
1001 => -749544262
1002 => 2004771271
1003 => 686734186
1004 => 923274744
1005 => -1672035149
1006 => -1642064950
1007 => 1363389551
KeepBottom(8):
1000 => 1630721656
1001 => 959306175
1002 => 1527421791
1003 => 1259692483
1004 => -1289244298
1005 => -1572996668
1006 => -2069479746
1007 => -1819131606
1000 => -1138727825
1001 => -749544262
1002 => 2004771271
1003 => 686734186
1004 => 923274744
1005 => -1672035149
1006 => -1642064950
1007 => 1363389551
RemoveBottom(2):
1000 => 1630721656
1001 => 959306175
1002 => 1527421791
1003 => 1259692483
1004 => -1289244298
1005 => -1572996668
1000 => -1138727825
1001 => -749544262
1002 => 2004771271
1003 => 686734186
1004 => 923274744
1005 => -1672035149
RemoveTop(2):
1002 => 1527421791
1003 => 1259692483
1004 => -1289244298
1005 => -1572996668
1002 => 2004771271
1003 => 686734186
1004 => 923274744
1005 => -1672035149
RemoveList({1003, 1004}):
1002 => 1527421791
1005 => -1572996668
1002 => 2004771271
1005 => -1672035149
KeepList({1003, 1004, 1005}):
1005 => -1572996668
1005 => -1672035149
AddList({1005, 4000, 4001, 4002}):
1005 => 1005
4000 => 8000
@@ -588,7 +588,7 @@ ERROR: IsEnd() is invalid as Begin() is never called
SetName(): false
GetLastErrorString(): ERR_NAME_IS_NOT_UNIQUE
GetName(): Regression
GetPresidentName(): P. Sharkey
GetPresidentName(): I. McAlpine
SetPresidentName(): true
GetPresidentName(): Regression AI
GetBankBalance(): 100000
@@ -7384,7 +7384,7 @@ ERROR: IsEnd() is invalid as Begin() is never called
HasRoadType(Road): true
HasRoadType(Tram): false
GetNeighbourRoadCount(): 2
RemoveRoad(): false
RemoveRoad(): true
RemoveRoad(): true
RemoveRoad(): false
RemoveRoad(): true
@@ -8951,7 +8951,7 @@ ERROR: IsEnd() is invalid as Begin() is never called
GetWagonEngineType(): 27
GetWagonAge(): 1
GetWagonEngineType(): 27
GetWagonAge(): 0
GetWagonAge(): 1
GetWagonEngineType(): 65535
GetWagonAge(): -1
--Errors--
@@ -9148,6 +9148,9 @@ ERROR: IsEnd() is invalid as Begin() is never called
GetDestinationType(): 1
GetDestinationIndex(): 7
GetCargoType(): 0
GetNextEvent: instance
GetEventType: 6
Unknown Event
IsEventWaiting: false
--Math--
+1 -1
View File
@@ -6,7 +6,7 @@ class Regression extends AIInfo {
function GetShortName() { return "REGR"; }
function GetDescription() { return "This runs regression-tests on all commands. On the same map the result should always be the same."; }
function GetVersion() { return 1; }
function GetAPIVersion() { return "1.3"; }
function GetAPIVersion() { return "1.2"; }
function GetDate() { return "2007-03-18"; }
function CreateInstance() { return "Regression"; }
}
Binary file not shown.
Binary file not shown.
+1 -1
View File
@@ -55,7 +55,7 @@ TRGI.GRF = da6a6c9dcc451eec88d79211437b76a8
TRGC.GRF = ed446637e034104c5559b32c18afe78d
TRGH.GRF = ee6616fb0e6ef6b24892c58c93d86fc9
TRGT.GRF = e30e8a398ae86c03dc534a8ac7dfb3b6
OPENTTD.GRF = 891f2dc7c81346d8fd5fbf4cf42dc5bd
OPENTTD.GRF = 51f9d2b8a29a079e83486db13509336c
[origin]
default = You can find it on your Transport Tycoon Deluxe CD-ROM.
+1 -1
View File
@@ -55,7 +55,7 @@ TRGI.GRF = da6a6c9dcc451eec88d79211437b76a8
TRGC.GRF = ed446637e034104c5559b32c18afe78d
TRGH.GRF = ee6616fb0e6ef6b24892c58c93d86fc9
TRGT.GRF = fcde1d7e8a74197d72a62695884b909e
OPENTTD.GRF = 891f2dc7c81346d8fd5fbf4cf42dc5bd
OPENTTD.GRF = 51f9d2b8a29a079e83486db13509336c
[origin]
default = You can find it on your Transport Tycoon Deluxe CD-ROM.
+1 -1
View File
@@ -55,7 +55,7 @@ TRGIR.GRF = 0c2484ff6be49fc63a83be6ab5c38f32
TRGCR.GRF = 3668f410c761a050b5e7095a2b14879b
TRGHR.GRF = 06bf2b7a31766f048baac2ebe43457b1
TRGTR.GRF = de53650517fe661ceaa3138c6edb0eb8
OPENTTD.GRF = 891f2dc7c81346d8fd5fbf4cf42dc5bd
OPENTTD.GRF = 51f9d2b8a29a079e83486db13509336c
[origin]
default = You can find it on your Transport Tycoon Deluxe CD-ROM.
-10
View File
@@ -1,10 +0,0 @@
/* $Id$ */
/*
* This file is part of OpenTTD.
* OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
* OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* 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/>.
*/
GSLog.Info("1.2 API compatability in effect.");
-8
View File
@@ -1,8 +0,0 @@
/* $Id$ */
/*
* This file is part of OpenTTD.
* OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
* OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* 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/>.
*/
-207
View File
@@ -1,210 +1,3 @@
1.3.0-beta1 (2012-12-24)
------------------------------------------------------------------------
- Feature: Advanced settings to disable certain sound effects (r24846)
- Feature: [NewGRF] Support oversized purchase list sprites [FS#5271] (r24839)
- Feature: Improve pylon placement around station tiles that display neither pylons nor catenary (r24836)
- Feature: When using a non-release version of OpenTTD and the basegraphics are missing some sprites, also suggest to use a non-release version of the basegraphics (r24821)
- Feature: Consider engine preview windows always sticky, so non-shift mass-closure does not affect them [FS#2632] (r24809)
- Feature: When share-cloning vehicles do not open the vehicle window of the new vehicle [FS#4458] (r24808)
- Feature: Enable usage of 'companies' console command also in singleplayer [FS#2820] (r24807)
- Feature: Ask for confirmation before creating giant screenshots [FS#3148] (r24806)
- Feature: Separate subdirectory for screenshots (r24804)
- Feature: Unify the difficulty settings window with the advanced settings window (r24791, r24792)
- Feature: Various methods to open the OSK (r24785)
- Feature: Add a string filter to the server list [FS#3852] (r24769)
- Feature: Add industry type and cargo dropdown selection for easier navigating in the industry chain window (r24763)
- Feature: Introduce GUI icons for deleting to the left/right (r24749)
- Feature: Add clear button to all editboxes (r24748)
- Feature: Reset the vehicle engine pool when starting a scenario (r24716)
- Feature: Add basic/advanced/expert filters to the advanced settings GUI [FS#5355] (r24671)
- Feature: Draw cargo labels in the station list black or white depending on the background colour [FS#5311] (r24668)
- Feature: Do not display the preview window for disabled vehicle types (r24660)
- Feature: Add new filter option to the advanced settings window to show only changed settings (r24647)
- Feature: Add text filtering to advanced settings (r24632)
- Feature: Add buttons to expand/collapse all to advanced settings GUI (r24631)
- Feature: [GS] Allow GameScripts to construct and prospect industries without having a sponsor (r24623)
- Feature: Pay interest also on a negative cash value (r24618)
- Feature: Sort cargo filter by cargo name/label at the company stations window [FS#5311] (r24615)
- Feature: More options for the auto-scroll setting (r24590)
- Feature: Allow AI/GS script developers to break the execution of their scripts and pause the game using ScriptController::Break() (r24542, r24575)
- Feature: Scripts can be suspended even if the game is still progressing, thus break-on-log now works also for Game Scripts (r24537)
- Feature: Highlight industries on the smallmap when the mouse is over an entry in the legend (r24534)
- Feature: [NewGRF] Allow resolving var 5F via vehicle var 61 (r24527)
- Feature: [OSX] Additional high-resolution icons for the app bundle [FS#4539] (r24525)
- Feature: Ctrl+Backspace/Delete to remove characters up to next word beginning in text edit boxes [FS#5203] (r24521)
- Feature: Ctrl+Arrow keys to move entire words in text edit boxes [FS#5203] (r24520)
- Feature: When using autorefit only load/refit vehicles if other wagons cannot already take all cargo without refitting [FS#5106] (r24497)
- Feature: [GS] Useful behaviour for GSEngine::IsValidEngine and GSEngine::IsBuildable when outside GSCompanyMode scope (r24492)
- Feature: Display GS dead state in AI debug window [FS#5230] (r24489)
- Feature: Add buttons to view textfiles from the online content window [FS#5236] (r24488)
- Feature: Make the pathfinder decide whether ships shall leave depots towards north or south [FS#5127] (r24481)
- Feature: [GS] API compatibility scripts for Goal Scripts [FS#5219] (r24468)
- Feature: Display in the advanced settings description a setting type which explains the scope of changes to a particular setting [FS#5244] (r24411)
- Feature: [GS] Allow game scripts to monitor cargo pickups and deliveries done by companies (r24406)
- Feature: [NewGRF] Allow vehicle variable 61 for callback 2D (recolour) and re-randomisation (r24371)
- Feature: [NewGRF] Customisable signals for rail types (r24367)
- Feature: Allow filtering for multiple words (separated by whitespace resp. quoted) in script breakpoints, the sign list, content and NewGRF-GUIs (r24337, r24342)
- Feature: Add dropdowns to NewGRF configurations, if all values have labels (r24318)
- Feature: Add dropdowns to AI configurations, if all values have labels (r24317)
- Feature: Allow to select advanced settings with limited range with a dropdown list (r24316)
- Feature: Display default values for advanced settings in the settings description (r24298)
- Feature: News item for exclusive transport rights [FS#2688] (r24287)
- Feature: [GS] Additional GSNews::NewsItem::NewsTypes (r24286)
- Feature: [NewGRF] Variable with the current max speed for vehicles [FS#5052] (r24246)
- Feature: Descriptions explaining the meaning of advanced settings (r24237)
- Feature: Split the renew-months setting text in two string values (one before life time and one after) (r24210)
- Feature: Show a hint in the supplies tab of station windows, if the station is affected by exclusive transport rights [FS#5178] (r24205)
- Feature: [NewGRF] Callback to set industry production level on construction (r24186)
- Feature: South Korean and South African currencies [FS#4907] (r24148)
- Feature: Randomise count of passengers killed in a crash [FS#3576] (r24142)
- Feature: Display rating in the town directory window (r24141)
- Feature: Show group name in the replace vehicle window caption [FS#1117] (r24140)
- Feature: Allow to create a new vehicle group by drag and drop (r24139)
- Feature: Ctrl+Drag to add all vehicles with a shared order list to a group (r24138)
- Feature: Draw indicator icon in the replace vehicle window for vehicles which have a replacement set (r24137)
- Feature: Autoreplace vehicles only when they get old [FS#4465] (r24136)
- Feature: Add configurable limits for tree planting, and remove tree drag size limit (r24134, r24135)
- Feature: Lithuanian currency [FS#4984] (r24133)
- Feature: Ctrl+Clicking to change colour of all colour schemes at once [FS#1952] (r24131)
- Feature: Deselect 'remove' button when changing signal types in the GUI [FS#2314] (r24130)
- Feature: Option to minimise signal distance when dragging over obstacles [FS#3660] (r24129)
- Feature: Allow closing airports for incoming aircraft [FS#1497] (r24127)
- Feature: Drag and drop support for the NewGRF list window [FS#3854] (r24126)
- Feature: Drag destination highlighting to the group GUI [FS#3705] (r24125)
- Feature: [NewGRF] Misc engine flag to disable breakdown smoke [FS#4658] (r24124)
- Feature: Be more careful with the population of a small town while placing a statue (r24105)
- Feature: Debug option for showing the redrawn dirty blocks/rectangles [FS#5101] (r24065)
- Change: News display options are now shown in the advanced settings window (r24842, r24843, r24844, r24845)
- Change: Drop 'signal density' from the advanced settings GUI. It is more suited to be only changed via the signal GUI (r24670)
- Change: Check for bankruptcy on a monthly basis (r24619)
- Change: Only bankrupt, if you have negative money considering you took max loan (r24617)
- Change: When building long roads or tramways, only build the roadbits at the beginning and the end if they can connect to something [FS#5228] (r24503)
- Change: Disallow original and better road layouts to build roads under bridges along the bridge direction [FS#5229] (r24391)
- Change: Allow cloning of orders which are unreachable for the destination vehicle if they were already unreachable for the source vehicle [FS#5213] (r24390)
- Change: Allow building/modifying/removing signals even if a train is on the belonging track (r24356)
- Change: [NewGRF] Make bounding boxes of road vehicles change according to the vehicle length to make alignment easier [FS#5204] (r24331)
- Fix: [NewGRF] Consider regearing-like cargos as no-cargo in cargo filters [FS#5386] (r24848)
- Fix: [NewGRF] Draw NewGRF railtypes in NewGRF station previews (r24840)
- Fix: Don't consider blocked rail station tiles that display wires as non-reachable for masking out unnecessary catenary wires (r24837)
- Fix: The autorefit dropdown in the order GUI wasn't always updated when modifying vehicle consists [FS#5396] (r24834)
- Fix: [NewGRF] Incorrect values are better than a crash when a NewGRF queries vehicle variable 4C before vehicle initialisation is completed [FS#5398] (r24831)
- Fix: determineversion.vbs could hang in a git checkout (r24826)
- Fix: Close pending preview windows when the engine is introduced to everyone (r24812)
- Fix: Close engine preview window when another client accepts it (r24811)
- Fix: Make engine preview offers more robust with regard to changes in the company ranking (r24810)
- Fix: When displaying the previous news message, do not consider news which are turned off [FS#4224] (r24802)
- Fix: Glitch in timetable GUI [FS#5327] (r24800)
- Fix: Unify checks for editability of settings (r24787)
- Fix: Invert the focus handling of the OSK. Keep the focus at the OSK and close it on losing focus (r24774)
- Fix: Shift in the OSK behaved like capslock (r24773)
- Fix: [Win32] Do not crash when switching to an unsupported fullscreen display mode (like 8bpp modes in Windows 8) [FS#5359] (r24762)
- Fix: Crash on corrupted savegame [FS#5367] (r24754)
- Fix: Some editboxes had a different colour than the rest of the window (r24747)
- Fix: In various windows the OSK looked shiny but using it had no effect whatsoever (r24727)
- Fix: AI debug GUI crashed when using disabled buttons via hotkeys (r24723)
- Fix: When starting a scenario apply the local company settings to the new company [FS#5139] (r24717)
- Fix: [NewGRF] Allow stations to draw snow/desert aware ground sprites with railtype overlays [FS#5335] (r24715)
- Fix: [NewGRF] Draw default foundations if resolving of custom station foundation sprites fails [FS#5337] (r24714)
- Fix: [NewGRF] Tolerate old NewGRFs returning invalid values via CB 11 [FS#5262] (r24713)
- Fix: [NewGRF] Station variables 61 and 62 returned incorrect values, if no vehicle ever tried loading [FS#5303] (r24712)
- Fix: Check whether to not display a ^ loading indicator at drop stations only worked if there was no other vehicle unloading for 255 ticks (r24711)
- Fix: [NewGRF] Station var 48 should report acceptance, not supply (r24706)
- Fix: Station rating might consider very old vehicles very young (r24705)
- Fix: Disallow closing oilrig airports in the scenario editor (r24703)
- Fix: Workaround for an overoptimisation done by GCC 4.5 [FS#5246] (r24701)
- Fix: Get packing right on MinGW GCC 4.7 (r24573)
- Fix: Make sure all template functions are instantiated by at least one compilation unit [FS#5276] (r24496)
- Fix: Do not load order backups when loading a server-saved game in single player (r24445)
- Fix: Allow overbuilding bridges with the same type when adding a roadtype [FS#5221] (r24413)
- Fix: Cargo lists cannot have genders (mostly because it is very unclear what gender it would have) (r24374)
- Fix: Off by one errors with regard to clicking on setting buttons (r24313)
- Fix: STRING1 probably means STRING1 (r24295)
- Fix: squirrel_export should match key words like 'virtual', 'static' and 'const' only as whole words (r24288)
- Fix: Hide object specs/classes from the GUI, if they will never be available to the user [FS#4967, FS#5120] (r24171)
- Fix: Unify the spacing in 'AI/Game Script' and never just say 'Game' when 'Game Script' is meant [FS#4898] (r24020)
1.2.3 (2012-11-01)
------------------------------------------------------------------------
(None)
1.2.3-RC1 (2012-10-17)
------------------------------------------------------------------------
- Change: [NewGRF] Set the reference brightness of 32bpp mask recolouring to 128 (r24610)
- Fix: Configure script did not properly handle _BUILD flags during reconfigure (r24601)
- Fix: Configure script failed to detect libfontconfig 2.10 as newer than 2.3 (r24598)
- Fix: When fontconfig is not available, the bootstrap download crashed [FS#5336] (r24597)
- Fix: Crash when a gamescript provided too many parameters to a GSText object [FS#5333] (r24593)
- Fix: [Script] API documentation mistakes/omissions (r24584)
- Fix: Do not add duplicates to the ban list [FS#5308] (r24580)
- Fix: Draw the window resize sprite bottom-aligned [FS#5324] (r24577)
- Fix: Vehicle list at buoys did no longer work [FS#5319] (r24576)
- Fix: [Windows] Do not cast away const in OS specific code (r24572, r24571)
- Fix: Naming of bundles was somewhat broken (r24569)
- Fix: Non-train vehicle lists were not resorted when vehicles were renamed [FS#5261] (r24567)
- Fix: Stop both price and payment inflation if either of them has reached MAX_INFLATION (r24565)
- Fix: Limiting the inflation did not quite work [FS#5312] (r24564)
- Fix: Do not show profit from refits as cost in the refit window [FS#5297] (r24544)
- Fix: Do not limit to reading one UDP packet per game loop (r24532)
- Fix: Max script chance was too big (r24531)
- Fix: [NewGRF] RandomAction 84 should interpret register 100 as signed (r24528)
- Fix: [OSX] Some compile problems in mac-only code [FS#5296] (r24524)
- Fix: The gender of an industry name is defined by the industry-type part of the name, not by the town-name part, even if it comes first (r24523, r24522)
- Fix: GStexts were compiled incompletely when containing certain string codes (r24516, r24515)
- Fix: The mousewheel did not work in the build waypoint window [FS#5285] (r24507)
- Fix: [NewGRF] Airport variables 60 to 65 and 69 used the wrong cargo translation table for translations (r24506)
- Fix: Do not show the global goals as company goals for spectators (r24500)
- Fix: Clarify description of command line option -n (r24485)
- Fix: Do not call RebuildSubsidisedSourceAndDestinationCache() before subsidy savegame conversion is finished [FS#5232] (r24482)
- Fix: Trains were unable to reverse in stations when using NPF (r24479)
- Fix: The --xxx yyy format (instead of --xxx=yyy) for configure did not work (r24471)
- Fix: --prefix was not accepted by configure (r24470)
- Fix: Changing auto-refit for a 'goto station' order was inadvertently modifying the full load state [FS#5264] (r24457)
1.2.2 (2012-08-16)
------------------------------------------------------------------------
(None)
1.2.2-RC1 (2012-08-01)
------------------------------------------------------------------------
- Fix: In some cases ships could be covered with land [CVE-2012-3436] [FS#5254] (r24449, r24439)
- Fix: Copy constructor and assignment operator cannot be implicit template specialisations [FS#5255] (r24448)
- Fix: Make (non-refittable) vehicles with invalid default cargo unavailable [FS#5256] (r24438)
- Fix: CFLAGS/CXXFLAGS ignored for helper binaries (r24432, r24429, r24427, r24365)
- Fix: [Windows] Unbreak NewGRF MD5 sum calculation. Macros and side effects do not mix, especially if there is some obscure '#define min' in a windows header that nobody thinks of [FS#5231] (r24416)
- Fix: Disallow removing roadtypes from bridges when not dragging in bridge direction [FS#5221] (r24414)
- Fix: Draw wires under low bridges if the bridge is transparent, not if the wire is transparent (r24403)
- Fix: Station properties 11 and 14 were combined incorrectly [FS#5243] (r24402)
- Fix: [Windows] Changing resolution did not resize the window (r24394)
- Fix: Use the 'all vehicles' group for the autoreplace window from the vehicle list [FS#5239] (r24392)
- Fix: Do not consider not finding a particular base set critical; just load a different one and display an in-game error later on [FS#5233] (r24388)
- Fix: Make IsInDepot() functions behave consistent across vehicle types and add IsChainInDepot instead, if that is what shall be checked [FS#5188] (r24384)
- Fix: Call Vehicle::IsStoppedInDepot only for the first vehicle in a chain (i.e. primary vehicle or free wagon) (r24382)
- Fix: Do not resize the object GUI when selecting objects. Rather clip the object name (r24379)
- Fix: ReInit could crash for windows with NWidgetMatrix widgets [FS#5218] (r24378)
- Fix: [NewGRF] Extended action A1 did not work correctly [FS#5227] (r24369, r24361)
- Fix: [NewGRF] Ship-specific 80+x variables were missing for unknown reason [FS#5224] (r24360)
- Fix: When airport construction was denied due to noise, the error message named the wrong town (r24354)
- Fix: [NoAI] A TileIndex is not a station id, so do not use it as one [FS#5215] (r24353)
- Fix: When highlighting the drop position for vehicles in depots, make space for all articulated parts (r24352)
- Fix: Short vehicles were not properly positioned at the cursor when dragging for RTL languages (r24351)
- Fix: EQUALSIZE widget containers within EQUALSIZE containers were initialised with wrong sizes (r24346)
- Fix: The cursor in the company password window was not blinking due to wrong magic constants (r24335)
- Fix: [NewGRF] Change the length of 8/8 roadvehicles in vehicle lists to 32 pixels; this is in fact the correct length as can be seen in corners for short articulated parts following each other [FS#2553] (r24332)
- Fix: [NewGRF] Group vehicles in the purchase list properly by source GRF, but also consider engine GRFID overrides [FS#4254] (r24330, r24321)
- Fix: Make the AI settings window behave more like the other settings window by closing the query window whenever selecting a different row (r24315)
- Fix: Editing NewGRF parameters using the query window showed wrong values, if there was no direct relation between parameter index and parameter register (r24314)
- Fix: Center object previews in 1- and 2-view selectors based on the 4-view selector layout [FS#5057] (r24299)
- Fix: Increase the left and right margins of the text in the yes/no query window (r24293)
- Fix: [NewGRF] GetReverseCargoTranslation() was unnecessary complicated and also returned the wrong thing for cargos not present in the translation table (r24273)
- Fix: [NewGRF] Load cargo- and railtype-translation during both reservation and activation stage. That way they can be selected using Action7 depending on present cargo- or railtypes (r24272)
- Fix: Use the same colour scheme for the script selection window as in other comparable windows (r24268)
- Fix: Make the oilrig-vehicle list accessible to spectators and colour its caption neutrally grey [FS#5126] (r24260)
1.2.1 (2012-06-01)
------------------------------------------------------------------------
- Fix: [Script] ScriptTown::GetGrowthRate() returned wrong values after usage of SetGrowthRate() (r24302)
+43 -92
View File
@@ -57,8 +57,8 @@ set_default() {
enable_translator="0"
enable_unicode="1"
enable_console="1";
enable_assert="1"
enable_strip="0"
enable_assert="0"
enable_strip="1"
enable_universal="0"
enable_osx_g5="0"
enable_cocoa_quartz="1"
@@ -164,7 +164,7 @@ set_default() {
with_ccache
with_grfcodec
with_nforenum
CC CXX CFLAGS CXXFLAGS LDFLAGS CFLAGS_BUILD CXXFLAGS_BUILD LDFLAGS_BUILD"
CC CXX CFLAGS CXXFLAGS LDFLAGS"
}
detect_params() {
@@ -197,21 +197,21 @@ detect_params() {
--cpu-type) prev_p="cpu_type";;
--cpu-type=*) cpu_type="$optarg";;
--cc-build) prev_p="cc_build";;
--cc-build) prevp_p="cc_build";;
--cc-build=*) cc_build="$optarg";;
--cc-host) prev_p="cc_host";;
--cc-host) prevp_p="cc_host";;
--cc-host=*) cc_host="$optarg";;
--cxx-build) prev_p="cxx_build";;
--cxx-build) prevp_p="cxx_build";;
--cxx-build=*) cxx_build="$optarg";;
--cxx-host) prev_p="cxx_host";;
--cxx-host) prevp_p="cxx_host";;
--cxx-host=*) cxx_host="$optarg";;
--windres) prev_p="windres";;
--windres) prevp_p="windres";;
--windres=*) windres="$optarg";;
--awk) prev_p="awk";;
--awk) prevp_p="awk";;
--awk=*) awk="$optarg";;
--strip) prev_p="strip";;
--strip) prevp_p="strip";;
--strip=*) strip="$optarg";;
--lipo) prev_p="lipo";;
--lipo) prevp_p="lipo";;
--lipo=*) lipo="$optarg";;
--endian) prev_p="endian";;
@@ -219,53 +219,52 @@ detect_params() {
# Alias --prefix with --prefix-dir, for compatibility with GNU autotools
--prefix-dir | --prefix) prev_p="prefix_dir";;
--prefix-dir=* | --prefix=*) prefix_dir="$optarg";;
--prefix-dir) prevp_p="prefix-dir";;
--prefix-dir=*) prefix_dir="$optarg";;
--binary-dir) prev_p="binary_dir";;
--binary-dir) prevp_p="binary-dir";;
--binary-dir=*) binary_dir="$optarg";;
--data-dir) prev_p="data_dir";;
--data-dir) prevp_p="data-dir";;
--data-dir=*) data_dir="$optarg";;
--doc-dir) prev_p="doc_dir";;
--doc-dir) prevp_p="doc-dir";;
--doc-dir=*) doc_dir="$optarg";;
--icon-dir) prev_p="icon_dir";;
--icon-dir) prevp_p="icon-dir";;
--icon-dir=*) icon_dir="$optarg";;
--icon-theme-dir) prev_p="icon_theme_dir";;
--icon-theme-dir) prevp_p="icon-theme-dir";;
--icon-theme-dir=*) icon_theme_dir="$optarg";;
--without-icon-theme) icon_theme_dir="";;
--menu-dir) prev_p="menu_dir";;
--menu-dir) prevp_p="menu_dir";;
--menu-dir=*) menu_dir="$optarg";;
--without-menu-entry) menu_dir="";;
--menu-name) prev_p="menu_name";;
--menu-name) prevp_p="menu_name";;
--menu-name=*) menu_name="$optarg";;
--binary-name) prev_p="binary_name";;
--binary-name) prevp_p="binary_name";;
--binary-name=*) binary_name="$optarg";;
--man-dir) prev_p="man_dir";;
--man-dir) prevp_p="man_dir";;
--man-dir=*) man_dir="$optarg";;
--personal-dir) prev_p="personal_dir";;
--personal-dir) prevp_p="personal-dir";;
--personal-dir=*) personal_dir="$optarg";;
--without-personal-dir) personal_dir="";;
--shared-dir) prev_p="shared_dir";;
--shared-dir) prevp_p="shared-dir";;
--shared-dir=*) shared_dir="$optarg";;
--without-shared-dir) shared_dir="";;
--install-dir) prev_p="install_dir";;
--install-dir) prevp_p="install-dir";;
--install-dir=*) install_dir="$optarg";;
--menu-group) prev_p="menu_group";;
--menu-group) prevp_p="menu_group";;
--menu-group=*) menu_group="$optarg";;
@@ -443,9 +442,6 @@ detect_params() {
CFLAGS=* | --CFLAGS=*) CFLAGS="$optarg";;
CXXFLAGS=* | --CXXFLAGS=*) CXXFLAGS="$optarg";;
LDFLAGS=* | --LDFLAGS=*) LDFLAGS="$optarg";;
CFLAGS_BUILD=* | --CFLAGS_BUILD=* | --CFLAGS-BUILD=*) CFLAGS_BUILD="$optarg";;
CXXFLAGS_BUILD=* | --CXXFLAGS_BUILD=* | --CXXFLAGS-BUILD=*) CXXFLAGS_BUILD="$optarg";;
LDFLAGS_BUILD=* | --LDFLAGS_BUILD=* | --LDFLAGS-BUILD=*) LDFLAGS_BUILD="$optarg";;
--ignore-extra-parameters) ignore_extra_parameters="1";;
@@ -1303,8 +1299,8 @@ make_compiler_cflags() {
flags="$flags -Wall -Wno-multichar -Wsign-compare -Wundef"
flags="$flags -Wwrite-strings -Wpointer-arith"
flags="$flags -W -Wno-unused-parameter -Wredundant-decls"
flags="$flags -Wformat=2 -Wformat-security"
flags="$flags -W -Wno-unused-parameter -Wformat=2"
flags="$flags -Wredundant-decls"
if [ $enable_assert -eq 0 ]; then
# Do not warn about unused variables when building without asserts
@@ -1350,12 +1346,6 @@ make_compiler_cflags() {
cxxflags="$cxxflags -std=gnu++0x"
fi
if [ $cc_version -eq 45 ]; then
# Prevent optimisation supposing enums are in a range specified by the standard
# For details, see http://gcc.gnu.org/PR43680
flags="$flags -fno-tree-vrp"
fi
if [ $cc_version -ge 47 ]; then
# Disable -Wnarrowing which gives many warnings, such as:
# warning: narrowing conversion of '...' from 'unsigned int' to 'int' inside { } [-Wnarrowing]
@@ -1396,11 +1386,11 @@ make_compiler_cflags() {
make_cflags_and_ldflags() {
# General CFlags for BUILD
CFLAGS_BUILD="$CFLAGS_BUILD"
CFLAGS_BUILD=""
# Special CXXFlags for BUILD
CXXFLAGS_BUILD="$CXXFLAGS_BUILD"
CXXFLAGS_BUILD=""
# LDFLAGS for BUILD
LDFLAGS_BUILD="$LDFLAGS_BUILD"
LDFLAGS_BUILD=""
# FEATURES for BUILD (lto)
FEATURES_BUILD=""
# General CFlags for HOST
@@ -1434,6 +1424,12 @@ make_cflags_and_ldflags() {
# Each debug level reduces the optimization by a bit
if [ $enable_debug -ge 1 ]; then
CFLAGS="$CFLAGS -g -D_DEBUG"
if basename "$cc_host" | grep "gcc" &>/dev/null; then
# Define only when compiling with GCC, some
# GLIBC versions use GNU extensions in a way
# that breaks build with at least ICC
CFLAGS="$CFLAGS -D_FORTIFY_SOURCE=2"
fi
if [ "$os" = "PSP" ]; then
CFLAGS="$CFLAGS -G0"
fi
@@ -1448,18 +1444,6 @@ make_cflags_and_ldflags() {
fi
fi
if [ $enable_debug -le 2 ]; then
if basename "$cc_host" | grep "gcc" &>/dev/null; then
# Define only when compiling with GCC. Some GLIBC versions use GNU
# extensions in a way that breaks build with at least ICC.
# This requires -O1 or more, so debug level 3 (-O0) is excluded.
CFLAGS="$CFLAGS -D_FORTIFY_SOURCE=2"
# Just add -O1 to the tools needed for building.
CFLAGS_BUILD="$CFLAGS_BUILD -D_FORTIFY_SOURCE=2 -O1"
fi
fi
if [ "$os" = "OSX" ] && [ $cc_version -eq 40 ]; then
# Apple's GCC 4.0 has a compiler bug for x86_64 with (higher) optimization,
# wrongly optimizing ^= in loops. This disables the failing optimisation.
@@ -1494,9 +1478,6 @@ make_cflags_and_ldflags() {
if [ $cc_version -ge 44 ]; then
LDFLAGS_BUILD="$LDFLAGS_BUILD -static-libgcc -static-libstdc++"
fi
if [ $cc_version -ge 47 ]; then
CFLAGS="$CFLAGS -mno-ms-bitfields"
fi
fi
fi
@@ -1790,7 +1771,6 @@ make_cflags_and_ldflags() {
if [ "$enable_assert" = "0" ]; then
CFLAGS="$CFLAGS -DNDEBUG"
CFLAGS_BUILD="$CFLAGS_BUILD -DNDEBUG"
fi
if [ "$enable_desync_debug" != "0" ]; then
@@ -1826,9 +1806,6 @@ make_cflags_and_ldflags() {
fi
fi
log 1 "using CFLAGS_BUILD... $CFLAGS_BUILD"
log 1 "using CXXFLAGS_BUILD... $CXXFLAGS_BUILD"
log 1 "using LDFLAGS_BUILD... $LDFLAGS_BUILD"
log 1 "using CFLAGS... $CFLAGS"
log 1 "using CXXFLAGS... $CXXFLAGS"
log 1 "using LDFLAGS... $LIBS $LDFLAGS"
@@ -2153,30 +2130,6 @@ check_makedepend() {
log 1 "checking makedepend... $makedepend"
}
check_version() {
# $1 - requested version (major.minor)
# $2 - version we got (major.minor)
if [ -z "$2" ]; then
return 0
fi
req_major=`echo $1 | cut -d. -f1`
got_major=`echo $2 | cut -d. -f1`
if [ $got_major -lt $req_major ]; then
return 0
elif [ $got_major -gt $req_major ]; then
return 1
fi
req_minor=`echo $1 | cut -d. -f2`
got_minor=`echo $2 | cut -d. -f2`
if [ $got_minor -lt $req_minor ]; then
return 0
fi
return 1
}
detect_awk() {
# Not all awks allow gsub(), so we test for that here! It is in fact all we need...
@@ -2862,14 +2815,13 @@ detect_fontconfig() {
version=`$fontconfig_config --modversion 2>/dev/null`
ret=$?
check_version '2.3' "$version"
version_ok=$?
shortversion=`echo $version | cut -c 1,3`
log 2 "executing $fontconfig_config --modversion"
log 2 " returned $version"
log 2 " exit code $ret"
if [ -z "$version" ] || [ "$ret" != "0" ] || [ "$version_ok" != "1" ]; then
if [ -n "$version" ] && [ "$version_ok" != "1" ]; then
if [ -z "$version" ] || [ "$ret" != "0" ] || [ "$shortversion" -le "22" ]; then
if [ -n "$shortversion" ] && [ "$shortversion" -le "22" ]; then
log 1 "checking libfontconfig... needs at least version 2.3.0, fontconfig NOT enabled"
else
log 1 "checking libfontconfig... not found"
@@ -2912,14 +2864,13 @@ detect_icu() {
version=`$icu_config --version 2>/dev/null`
ret=$?
check_version '3.6' "$version"
version_ok=$?
shortversion=`echo $version | cut -d\. -f1,2 | sed "s/\.//g" | cut -c1-2`
log 2 "executing $icu_config --version"
log 2 " returned $version"
log 2 " exit code $ret"
if [ -z "$version" ] || [ "$ret" != "0" ] || [ "$version_ok" != "1" ]; then
if [ -n "$version" ] && [ "$version_ok" != "1" ]; then
if [ -z "$version" ] || [ "$ret" != "0" ] || [ "$shortversion" -lt "36" ]; then
if [ -n "$shortversion" ] && [ "$shortversion" -lt "36" ]; then
log 1 "checking libicu... needs at least version 3.6.0, icu NOT enabled"
else
log 1 "checking libicu... not found"
+1 -7
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/>.
//
-1 * 0 0C "OpenTTD GUI graphics"
-1 * 3 05 15 A8
-1 * 3 05 15 A2
-1 sprites/openttdgui.png 8bpp 66 8 64 31 -31 7 normal
-1 sprites/openttdgui.png 8bpp 146 8 64 31 -31 7 normal
-1 sprites/openttdgui.png 8bpp 226 8 64 31 -31 7 normal
@@ -170,9 +170,3 @@
-1 sprites/openttdgui.png 8bpp 194 440 13 10 0 -2 normal
-1 sprites/openttdgui.png 8bpp 215 440 9 10 0 0 normal
-1 sprites/openttdgui.png 8bpp 232 440 8 10 0 0 normal
-1 sprites/openttdgui.png 8bpp 248 440 8 8 0 0 normal
-1 sprites/openttdgui.png 8bpp 264 440 8 8 0 0 normal
-1 sprites/openttdgui.png 8bpp 280 440 8 8 0 0 normal
-1 sprites/openttdgui.png 8bpp 296 440 8 8 0 0 normal
-1 sprites/openttdgui.png 8bpp 312 440 14 10 0 0 normal
-1 sprites/openttdgui.png 8bpp 328 440 14 10 0 0 normal
Binary file not shown.

Before

Width:  |  Height:  |  Size: 25 KiB

After

Width:  |  Height:  |  Size: 24 KiB

-30
View File
@@ -1,33 +1,3 @@
openttd (1.3.0-beta1) unstable; urgency=low
* New upstream release 1.3.0-beta1
-- Matthijs Kooijman <matthijs@stdin.nl> Mon, 24 Dec 2012 00:00:00 +0100
openttd (1.2.3) unstable; urgency=low
* New upstream release 1.2.3
-- Matthijs Kooijman <matthijs@stdin.nl> Thu, 01 Nov 2012 00:00:00 +0200
openttd (1.2.3~RC1) unstable; urgency=low
* New upstream release 1.2.3-RC1
-- Matthijs Kooijman <matthijs@stdin.nl> Wed, 17 Oct 2012 00:00:00 +0200
openttd (1.2.2) unstable; urgency=low
* New upstream release 1.2.2
-- Matthijs Kooijman <matthijs@stdin.nl> Thu, 16 Aug 2012 20:00:00 +0200
openttd (1.2.2~RC1) unstable; urgency=low
* New upstream release 1.2.2-RC1
-- Matthijs Kooijman <matthijs@stdin.nl> Wed, 01 Aug 2012 00:00:00 +0200
openttd (1.2.1) unstable; urgency=low
* New upstream release 1.2.1
Binary file not shown.
+1 -1
View File
@@ -1,6 +1,6 @@
@echo off
set OPENTTD_VERSION=1.3.0-beta1
set OPENTTD_VERSION=1.2.1
set OPENSFX_VERSION=0.8.0
set NOSOUND_VERSION=0.8.0
set OPENGFX_VERSION=1.2.0
+2 -2
View File
@@ -17,9 +17,9 @@
#
Name: openttd
Version: 1.3.beta1
Version: 1.2.beta4
Release: 0
%define srcver 1.3.0-beta1
%define srcver 1.2.0-beta4
Summary: An open source reimplementation of Chris Sawyer's Transport Tycoon Deluxe
License: GPL-2.0
Group: Amusements/Games/Strategy/Other
+4 -4
View File
@@ -1,9 +1,9 @@
# Version numbers to update
!define APPV_MAJOR 1
!define APPV_MINOR 3
!define APPV_MAINT 0
!define APPV_BUILD 0
!define APPV_EXTRA "-beta1"
!define APPV_MINOR 2
!define APPV_MAINT 1
!define APPV_BUILD 1
!define APPV_EXTRA ""
!define APPNAME "OpenTTD" ; Define application name
!define APPVERSION "${APPV_MAJOR}.${APPV_MINOR}.${APPV_MAINT}${APPV_EXTRA}" ; Define application version
-3
View File
@@ -177,9 +177,6 @@ Function DetermineSVNVersion()
' Make sure index is in sync with disk
Set oExec = WshShell.Exec("git update-index --refresh")
If Err.Number = 0 Then
' StdOut and StdErr share a 4kB buffer so prevent it from filling up as we don't care about the output
oExec.StdOut.Close
oExec.StdErr.Close
' Wait till the application is finished ...
Do While oExec.Status = 0
WScript.Sleep 10
+2 -14
View File
@@ -102,7 +102,7 @@
<FavorSizeOrSpeed>Size</FavorSizeOrSpeed>
<OmitFramePointers>true</OmitFramePointers>
<AdditionalIncludeDirectories>..\objs\langs;..\objs\settings;..\src\3rdparty\squirrel\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;WIN32_ENABLE_DIRECTMUSIC_SUPPORT;WITH_ZLIB;WITH_LZO;WITH_LZMA;LZMA_API_STATIC;WITH_PNG;WITH_FREETYPE;WITH_ICU;U_STATIC_IMPLEMENTATION;ENABLE_NETWORK;WITH_PERSONAL_DIR;PERSONAL_DIR="OpenTTD";WITH_ASSERT;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;WIN32_ENABLE_DIRECTMUSIC_SUPPORT;WITH_ZLIB;WITH_LZO;WITH_LZMA;LZMA_API_STATIC;WITH_PNG;WITH_FREETYPE;WITH_ICU;U_STATIC_IMPLEMENTATION;ENABLE_NETWORK;WITH_PERSONAL_DIR;PERSONAL_DIR="OpenTTD";%(PreprocessorDefinitions)</PreprocessorDefinitions>
<StringPooling>true</StringPooling>
<ExceptionHandling>Sync</ExceptionHandling>
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
@@ -204,7 +204,7 @@
<FavorSizeOrSpeed>Size</FavorSizeOrSpeed>
<OmitFramePointers>true</OmitFramePointers>
<AdditionalIncludeDirectories>..\objs\langs;..\objs\settings;..\src\3rdparty\squirrel\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;WITH_ZLIB;WITH_LZO;WITH_LZMA;LZMA_API_STATIC;WITH_PNG;WITH_FREETYPE;WITH_ICU;U_STATIC_IMPLEMENTATION;ENABLE_NETWORK;WITH_PERSONAL_DIR;PERSONAL_DIR="OpenTTD";_SQ64;WITH_ASSERT;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;WITH_ZLIB;WITH_LZO;WITH_LZMA;LZMA_API_STATIC;WITH_PNG;WITH_FREETYPE;WITH_ICU;U_STATIC_IMPLEMENTATION;ENABLE_NETWORK;WITH_PERSONAL_DIR;PERSONAL_DIR="OpenTTD";_SQ64;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<StringPooling>true</StringPooling>
<ExceptionHandling>Sync</ExceptionHandling>
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
@@ -296,7 +296,6 @@
<ClCompile Include="..\src\articulated_vehicles.cpp" />
<ClCompile Include="..\src\autoreplace.cpp" />
<ClCompile Include="..\src\bmp.cpp" />
<ClCompile Include="..\src\cargomonitor.cpp" />
<ClCompile Include="..\src\cargopacket.cpp" />
<ClCompile Include="..\src\cargotype.cpp" />
<ClCompile Include="..\src\cheat.cpp" />
@@ -317,7 +316,6 @@
<ClCompile Include="..\src\fileio.cpp" />
<ClCompile Include="..\src\fios.cpp" />
<ClCompile Include="..\src\fontcache.cpp" />
<ClCompile Include="..\src\base_consist.cpp" />
<ClCompile Include="..\src\gamelog.cpp" />
<ClCompile Include="..\src\genworld.cpp" />
<ClCompile Include="..\src\gfx.cpp" />
@@ -362,10 +360,8 @@
<ClCompile Include="..\src\station.cpp" />
<ClCompile Include="..\src\strgen\strgen_base.cpp" />
<ClCompile Include="..\src\string.cpp" />
<ClCompile Include="..\src\stringfilter.cpp" />
<ClCompile Include="..\src\strings.cpp" />
<ClCompile Include="..\src\subsidy.cpp" />
<ClCompile Include="..\src\textbuf.cpp" />
<ClCompile Include="..\src\texteff.cpp" />
<ClCompile Include="..\src\tgp.cpp" />
<ClCompile Include="..\src\tile_map.cpp" />
@@ -392,7 +388,6 @@
<ClInclude Include="..\src\bmp.h" />
<ClInclude Include="..\src\bridge.h" />
<ClInclude Include="..\src\cargo_type.h" />
<ClInclude Include="..\src\cargomonitor.h" />
<ClInclude Include="..\src\cargopacket.h" />
<ClInclude Include="..\src\cargotype.h" />
<ClInclude Include="..\src\cheat_func.h" />
@@ -440,7 +435,6 @@
<ClInclude Include="..\src\fileio_type.h" />
<ClInclude Include="..\src\fios.h" />
<ClInclude Include="..\src\fontcache.h" />
<ClInclude Include="..\src\base_consist.h" />
<ClInclude Include="..\src\gamelog.h" />
<ClInclude Include="..\src\gamelog_internal.h" />
<ClInclude Include="..\src\genworld.h" />
@@ -545,7 +539,6 @@
<ClInclude Include="..\src\sound\sdl_s.h" />
<ClInclude Include="..\src\video\sdl_v.h" />
<ClInclude Include="..\src\settings_func.h" />
<ClInclude Include="..\src\settings_gui.h" />
<ClInclude Include="..\src\settings_internal.h" />
<ClInclude Include="..\src\settings_type.h" />
<ClInclude Include="..\src\ship.h" />
@@ -571,7 +564,6 @@
<ClInclude Include="..\src\strgen\strgen.h" />
<ClInclude Include="..\src\string_func.h" />
<ClInclude Include="..\src\string_type.h" />
<ClInclude Include="..\src\stringfilter_type.h" />
<ClInclude Include="..\src\strings_func.h" />
<ClInclude Include="..\src\strings_type.h" />
<ClInclude Include="..\src\subsidy_base.h" />
@@ -580,7 +572,6 @@
<ClInclude Include="..\src\tar_type.h" />
<ClInclude Include="..\src\terraform_gui.h" />
<ClInclude Include="..\src\textbuf_gui.h" />
<ClInclude Include="..\src\textbuf_type.h" />
<ClInclude Include="..\src\texteff.hpp" />
<ClInclude Include="..\src\textfile_gui.h" />
<ClInclude Include="..\src\textfile_type.h" />
@@ -792,7 +783,6 @@
<ClCompile Include="..\src\saveload\airport_sl.cpp" />
<ClCompile Include="..\src\saveload\animated_tile_sl.cpp" />
<ClCompile Include="..\src\saveload\autoreplace_sl.cpp" />
<ClCompile Include="..\src\saveload\cargomonitor_sl.cpp" />
<ClCompile Include="..\src\saveload\cargopacket_sl.cpp" />
<ClCompile Include="..\src\saveload\cheat_sl.cpp" />
<ClCompile Include="..\src\saveload\company_sl.cpp" />
@@ -957,7 +947,6 @@
<ClInclude Include="..\src\script\api\script_bridgelist.hpp" />
<ClInclude Include="..\src\script\api\script_cargo.hpp" />
<ClInclude Include="..\src\script\api\script_cargolist.hpp" />
<ClInclude Include="..\src\script\api\script_cargomonitor.hpp" />
<ClInclude Include="..\src\script\api\script_company.hpp" />
<ClInclude Include="..\src\script\api\script_companymode.hpp" />
<ClInclude Include="..\src\script\api\script_controller.hpp" />
@@ -1019,7 +1008,6 @@
<ClCompile Include="..\src\script\api\script_bridgelist.cpp" />
<ClCompile Include="..\src\script\api\script_cargo.cpp" />
<ClCompile Include="..\src\script\api\script_cargolist.cpp" />
<ClCompile Include="..\src\script\api\script_cargomonitor.cpp" />
<ClCompile Include="..\src\script\api\script_company.cpp" />
<ClCompile Include="..\src\script\api\script_companymode.cpp" />
<ClCompile Include="..\src\script\api\script_controller.cpp" />
-36
View File
@@ -117,9 +117,6 @@
<ClCompile Include="..\src\bmp.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\src\cargomonitor.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\src\cargopacket.cpp">
<Filter>Source Files</Filter>
</ClCompile>
@@ -180,9 +177,6 @@
<ClCompile Include="..\src\fontcache.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\src\base_consist.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\src\gamelog.cpp">
<Filter>Source Files</Filter>
</ClCompile>
@@ -315,18 +309,12 @@
<ClCompile Include="..\src\string.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\src\stringfilter.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\src\strings.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\src\subsidy.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\src\textbuf.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\src\texteff.cpp">
<Filter>Source Files</Filter>
</ClCompile>
@@ -405,9 +393,6 @@
<ClInclude Include="..\src\cargo_type.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\src\cargomonitor.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\src\cargopacket.h">
<Filter>Header Files</Filter>
</ClInclude>
@@ -549,9 +534,6 @@
<ClInclude Include="..\src\fontcache.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\src\base_consist.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\src\gamelog.h">
<Filter>Header Files</Filter>
</ClInclude>
@@ -864,9 +846,6 @@
<ClInclude Include="..\src\settings_func.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\src\settings_gui.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\src\settings_internal.h">
<Filter>Header Files</Filter>
</ClInclude>
@@ -942,9 +921,6 @@
<ClInclude Include="..\src\string_type.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\src\stringfilter_type.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\src\strings_func.h">
<Filter>Header Files</Filter>
</ClInclude>
@@ -969,9 +945,6 @@
<ClInclude Include="..\src\textbuf_gui.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\src\textbuf_type.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\src\texteff.hpp">
<Filter>Header Files</Filter>
</ClInclude>
@@ -1605,9 +1578,6 @@
<ClCompile Include="..\src\saveload\autoreplace_sl.cpp">
<Filter>Save/Load handlers</Filter>
</ClCompile>
<ClCompile Include="..\src\saveload\cargomonitor_sl.cpp">
<Filter>Save/Load handlers</Filter>
</ClCompile>
<ClCompile Include="..\src\saveload\cargopacket_sl.cpp">
<Filter>Save/Load handlers</Filter>
</ClCompile>
@@ -2100,9 +2070,6 @@
<ClInclude Include="..\src\script\api\script_cargolist.hpp">
<Filter>Script API</Filter>
</ClInclude>
<ClInclude Include="..\src\script\api\script_cargomonitor.hpp">
<Filter>Script API</Filter>
</ClInclude>
<ClInclude Include="..\src\script\api\script_company.hpp">
<Filter>Script API</Filter>
</ClInclude>
@@ -2286,9 +2253,6 @@
<ClCompile Include="..\src\script\api\script_cargolist.cpp">
<Filter>Script API Implementation</Filter>
</ClCompile>
<ClCompile Include="..\src\script\api\script_cargomonitor.cpp">
<Filter>Script API Implementation</Filter>
</ClCompile>
<ClCompile Include="..\src\script\api\script_company.cpp">
<Filter>Script API Implementation</Filter>
</ClCompile>
+2 -2
View File
@@ -102,7 +102,7 @@
<FavorSizeOrSpeed>Size</FavorSizeOrSpeed>
<OmitFramePointers>true</OmitFramePointers>
<AdditionalIncludeDirectories>..\objs\langs;..\objs\settings;..\src\3rdparty\squirrel\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;WIN32_ENABLE_DIRECTMUSIC_SUPPORT;WITH_ZLIB;WITH_LZO;WITH_LZMA;LZMA_API_STATIC;WITH_PNG;WITH_FREETYPE;WITH_ICU;U_STATIC_IMPLEMENTATION;ENABLE_NETWORK;WITH_PERSONAL_DIR;PERSONAL_DIR="OpenTTD";WITH_ASSERT;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;WIN32_ENABLE_DIRECTMUSIC_SUPPORT;WITH_ZLIB;WITH_LZO;WITH_LZMA;LZMA_API_STATIC;WITH_PNG;WITH_FREETYPE;WITH_ICU;U_STATIC_IMPLEMENTATION;ENABLE_NETWORK;WITH_PERSONAL_DIR;PERSONAL_DIR="OpenTTD";%(PreprocessorDefinitions)</PreprocessorDefinitions>
<StringPooling>true</StringPooling>
<ExceptionHandling>Sync</ExceptionHandling>
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
@@ -204,7 +204,7 @@
<FavorSizeOrSpeed>Size</FavorSizeOrSpeed>
<OmitFramePointers>true</OmitFramePointers>
<AdditionalIncludeDirectories>..\objs\langs;..\objs\settings;..\src\3rdparty\squirrel\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;WITH_ZLIB;WITH_LZO;WITH_LZMA;LZMA_API_STATIC;WITH_PNG;WITH_FREETYPE;WITH_ICU;U_STATIC_IMPLEMENTATION;ENABLE_NETWORK;WITH_PERSONAL_DIR;PERSONAL_DIR="OpenTTD";_SQ64;WITH_ASSERT;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;WITH_ZLIB;WITH_LZO;WITH_LZMA;LZMA_API_STATIC;WITH_PNG;WITH_FREETYPE;WITH_ICU;U_STATIC_IMPLEMENTATION;ENABLE_NETWORK;WITH_PERSONAL_DIR;PERSONAL_DIR="OpenTTD";_SQ64;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<StringPooling>true</StringPooling>
<ExceptionHandling>Sync</ExceptionHandling>
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
+2 -50
View File
@@ -52,7 +52,7 @@
FavorSizeOrSpeed="2"
OmitFramePointers="true"
AdditionalIncludeDirectories="..\objs\langs;..\objs\settings;..\src\3rdparty\squirrel\include"
PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE;WIN32_ENABLE_DIRECTMUSIC_SUPPORT;WITH_ZLIB;WITH_LZO;WITH_LZMA;LZMA_API_STATIC;WITH_PNG;WITH_FREETYPE;WITH_ICU;U_STATIC_IMPLEMENTATION;ENABLE_NETWORK;WITH_PERSONAL_DIR;PERSONAL_DIR=\&quot;OpenTTD\&quot;;WITH_ASSERT"
PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE;WIN32_ENABLE_DIRECTMUSIC_SUPPORT;WITH_ZLIB;WITH_LZO;WITH_LZMA;LZMA_API_STATIC;WITH_PNG;WITH_FREETYPE;WITH_ICU;U_STATIC_IMPLEMENTATION;ENABLE_NETWORK;WITH_PERSONAL_DIR;PERSONAL_DIR=\&quot;OpenTTD\&quot;"
StringPooling="true"
ExceptionHandling="1"
RuntimeLibrary="0"
@@ -257,7 +257,7 @@
FavorSizeOrSpeed="2"
OmitFramePointers="true"
AdditionalIncludeDirectories="..\objs\langs;..\objs\settings;..\src\3rdparty\squirrel\include"
PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE;WITH_ZLIB;WITH_LZO;WITH_LZMA;LZMA_API_STATIC;WITH_PNG;WITH_FREETYPE;WITH_ICU;U_STATIC_IMPLEMENTATION;ENABLE_NETWORK;WITH_PERSONAL_DIR;PERSONAL_DIR=\&quot;OpenTTD\&quot;;_SQ64;WITH_ASSERT"
PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE;WITH_ZLIB;WITH_LZO;WITH_LZMA;LZMA_API_STATIC;WITH_PNG;WITH_FREETYPE;WITH_ICU;U_STATIC_IMPLEMENTATION;ENABLE_NETWORK;WITH_PERSONAL_DIR;PERSONAL_DIR=\&quot;OpenTTD\&quot;;_SQ64"
StringPooling="true"
ExceptionHandling="1"
RuntimeLibrary="0"
@@ -454,10 +454,6 @@
RelativePath=".\..\src\bmp.cpp"
>
</File>
<File
RelativePath=".\..\src\cargomonitor.cpp"
>
</File>
<File
RelativePath=".\..\src\cargopacket.cpp"
>
@@ -538,10 +534,6 @@
RelativePath=".\..\src\fontcache.cpp"
>
</File>
<File
RelativePath=".\..\src\base_consist.cpp"
>
</File>
<File
RelativePath=".\..\src\gamelog.cpp"
>
@@ -718,10 +710,6 @@
RelativePath=".\..\src\string.cpp"
>
</File>
<File
RelativePath=".\..\src\stringfilter.cpp"
>
</File>
<File
RelativePath=".\..\src\strings.cpp"
>
@@ -730,10 +718,6 @@
RelativePath=".\..\src\subsidy.cpp"
>
</File>
<File
RelativePath=".\..\src\textbuf.cpp"
>
</File>
<File
RelativePath=".\..\src\texteff.cpp"
>
@@ -842,10 +826,6 @@
RelativePath=".\..\src\cargo_type.h"
>
</File>
<File
RelativePath=".\..\src\cargomonitor.h"
>
</File>
<File
RelativePath=".\..\src\cargopacket.h"
>
@@ -1034,10 +1014,6 @@
RelativePath=".\..\src\fontcache.h"
>
</File>
<File
RelativePath=".\..\src\base_consist.h"
>
</File>
<File
RelativePath=".\..\src\gamelog.h"
>
@@ -1454,10 +1430,6 @@
RelativePath=".\..\src\settings_func.h"
>
</File>
<File
RelativePath=".\..\src\settings_gui.h"
>
</File>
<File
RelativePath=".\..\src\settings_internal.h"
>
@@ -1558,10 +1530,6 @@
RelativePath=".\..\src\string_type.h"
>
</File>
<File
RelativePath=".\..\src\stringfilter_type.h"
>
</File>
<File
RelativePath=".\..\src\strings_func.h"
>
@@ -1594,10 +1562,6 @@
RelativePath=".\..\src\textbuf_gui.h"
>
</File>
<File
RelativePath=".\..\src\textbuf_type.h"
>
</File>
<File
RelativePath=".\..\src\texteff.hpp"
>
@@ -2462,10 +2426,6 @@
RelativePath=".\..\src\saveload\autoreplace_sl.cpp"
>
</File>
<File
RelativePath=".\..\src\saveload\cargomonitor_sl.cpp"
>
</File>
<File
RelativePath=".\..\src\saveload\cargopacket_sl.cpp"
>
@@ -3162,10 +3122,6 @@
RelativePath=".\..\src\script\api\script_cargolist.hpp"
>
</File>
<File
RelativePath=".\..\src\script\api\script_cargomonitor.hpp"
>
</File>
<File
RelativePath=".\..\src\script\api\script_company.hpp"
>
@@ -3414,10 +3370,6 @@
RelativePath=".\..\src\script\api\script_cargolist.cpp"
>
</File>
<File
RelativePath=".\..\src\script\api\script_cargomonitor.cpp"
>
</File>
<File
RelativePath=".\..\src\script\api\script_company.cpp"
>
+2 -2
View File
@@ -52,7 +52,7 @@
FavorSizeOrSpeed="2"
OmitFramePointers="true"
AdditionalIncludeDirectories="..\objs\langs;..\objs\settings;..\src\3rdparty\squirrel\include"
PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE;WIN32_ENABLE_DIRECTMUSIC_SUPPORT;WITH_ZLIB;WITH_LZO;WITH_LZMA;LZMA_API_STATIC;WITH_PNG;WITH_FREETYPE;WITH_ICU;U_STATIC_IMPLEMENTATION;ENABLE_NETWORK;WITH_PERSONAL_DIR;PERSONAL_DIR=\&quot;OpenTTD\&quot;;WITH_ASSERT"
PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE;WIN32_ENABLE_DIRECTMUSIC_SUPPORT;WITH_ZLIB;WITH_LZO;WITH_LZMA;LZMA_API_STATIC;WITH_PNG;WITH_FREETYPE;WITH_ICU;U_STATIC_IMPLEMENTATION;ENABLE_NETWORK;WITH_PERSONAL_DIR;PERSONAL_DIR=\&quot;OpenTTD\&quot;"
StringPooling="true"
ExceptionHandling="1"
RuntimeLibrary="0"
@@ -257,7 +257,7 @@
FavorSizeOrSpeed="2"
OmitFramePointers="true"
AdditionalIncludeDirectories="..\objs\langs;..\objs\settings;..\src\3rdparty\squirrel\include"
PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE;WITH_ZLIB;WITH_LZO;WITH_LZMA;LZMA_API_STATIC;WITH_PNG;WITH_FREETYPE;WITH_ICU;U_STATIC_IMPLEMENTATION;ENABLE_NETWORK;WITH_PERSONAL_DIR;PERSONAL_DIR=\&quot;OpenTTD\&quot;;_SQ64;WITH_ASSERT"
PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE;WITH_ZLIB;WITH_LZO;WITH_LZMA;LZMA_API_STATIC;WITH_PNG;WITH_FREETYPE;WITH_ICU;U_STATIC_IMPLEMENTATION;ENABLE_NETWORK;WITH_PERSONAL_DIR;PERSONAL_DIR=\&quot;OpenTTD\&quot;;_SQ64"
StringPooling="true"
ExceptionHandling="1"
RuntimeLibrary="0"
+2 -50
View File
@@ -53,7 +53,7 @@
FavorSizeOrSpeed="2"
OmitFramePointers="true"
AdditionalIncludeDirectories="..\objs\langs;..\objs\settings;..\src\3rdparty\squirrel\include"
PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE;WIN32_ENABLE_DIRECTMUSIC_SUPPORT;WITH_ZLIB;WITH_LZO;WITH_LZMA;LZMA_API_STATIC;WITH_PNG;WITH_FREETYPE;WITH_ICU;U_STATIC_IMPLEMENTATION;ENABLE_NETWORK;WITH_PERSONAL_DIR;PERSONAL_DIR=\&quot;OpenTTD\&quot;;WITH_ASSERT"
PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE;WIN32_ENABLE_DIRECTMUSIC_SUPPORT;WITH_ZLIB;WITH_LZO;WITH_LZMA;LZMA_API_STATIC;WITH_PNG;WITH_FREETYPE;WITH_ICU;U_STATIC_IMPLEMENTATION;ENABLE_NETWORK;WITH_PERSONAL_DIR;PERSONAL_DIR=\&quot;OpenTTD\&quot;"
StringPooling="true"
ExceptionHandling="1"
RuntimeLibrary="0"
@@ -255,7 +255,7 @@
FavorSizeOrSpeed="2"
OmitFramePointers="true"
AdditionalIncludeDirectories="..\objs\langs;..\objs\settings;..\src\3rdparty\squirrel\include"
PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE;WITH_ZLIB;WITH_LZO;WITH_LZMA;LZMA_API_STATIC;WITH_PNG;WITH_FREETYPE;WITH_ICU;U_STATIC_IMPLEMENTATION;ENABLE_NETWORK;WITH_PERSONAL_DIR;PERSONAL_DIR=\&quot;OpenTTD\&quot;;_SQ64;WITH_ASSERT"
PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE;WITH_ZLIB;WITH_LZO;WITH_LZMA;LZMA_API_STATIC;WITH_PNG;WITH_FREETYPE;WITH_ICU;U_STATIC_IMPLEMENTATION;ENABLE_NETWORK;WITH_PERSONAL_DIR;PERSONAL_DIR=\&quot;OpenTTD\&quot;;_SQ64"
StringPooling="true"
ExceptionHandling="1"
RuntimeLibrary="0"
@@ -451,10 +451,6 @@
RelativePath=".\..\src\bmp.cpp"
>
</File>
<File
RelativePath=".\..\src\cargomonitor.cpp"
>
</File>
<File
RelativePath=".\..\src\cargopacket.cpp"
>
@@ -535,10 +531,6 @@
RelativePath=".\..\src\fontcache.cpp"
>
</File>
<File
RelativePath=".\..\src\base_consist.cpp"
>
</File>
<File
RelativePath=".\..\src\gamelog.cpp"
>
@@ -715,10 +707,6 @@
RelativePath=".\..\src\string.cpp"
>
</File>
<File
RelativePath=".\..\src\stringfilter.cpp"
>
</File>
<File
RelativePath=".\..\src\strings.cpp"
>
@@ -727,10 +715,6 @@
RelativePath=".\..\src\subsidy.cpp"
>
</File>
<File
RelativePath=".\..\src\textbuf.cpp"
>
</File>
<File
RelativePath=".\..\src\texteff.cpp"
>
@@ -839,10 +823,6 @@
RelativePath=".\..\src\cargo_type.h"
>
</File>
<File
RelativePath=".\..\src\cargomonitor.h"
>
</File>
<File
RelativePath=".\..\src\cargopacket.h"
>
@@ -1031,10 +1011,6 @@
RelativePath=".\..\src\fontcache.h"
>
</File>
<File
RelativePath=".\..\src\base_consist.h"
>
</File>
<File
RelativePath=".\..\src\gamelog.h"
>
@@ -1451,10 +1427,6 @@
RelativePath=".\..\src\settings_func.h"
>
</File>
<File
RelativePath=".\..\src\settings_gui.h"
>
</File>
<File
RelativePath=".\..\src\settings_internal.h"
>
@@ -1555,10 +1527,6 @@
RelativePath=".\..\src\string_type.h"
>
</File>
<File
RelativePath=".\..\src\stringfilter_type.h"
>
</File>
<File
RelativePath=".\..\src\strings_func.h"
>
@@ -1591,10 +1559,6 @@
RelativePath=".\..\src\textbuf_gui.h"
>
</File>
<File
RelativePath=".\..\src\textbuf_type.h"
>
</File>
<File
RelativePath=".\..\src\texteff.hpp"
>
@@ -2459,10 +2423,6 @@
RelativePath=".\..\src\saveload\autoreplace_sl.cpp"
>
</File>
<File
RelativePath=".\..\src\saveload\cargomonitor_sl.cpp"
>
</File>
<File
RelativePath=".\..\src\saveload\cargopacket_sl.cpp"
>
@@ -3159,10 +3119,6 @@
RelativePath=".\..\src\script\api\script_cargolist.hpp"
>
</File>
<File
RelativePath=".\..\src\script\api\script_cargomonitor.hpp"
>
</File>
<File
RelativePath=".\..\src\script\api\script_company.hpp"
>
@@ -3411,10 +3367,6 @@
RelativePath=".\..\src\script\api\script_cargolist.cpp"
>
</File>
<File
RelativePath=".\..\src\script\api\script_cargomonitor.cpp"
>
</File>
<File
RelativePath=".\..\src\script\api\script_company.cpp"
>
+2 -2
View File
@@ -53,7 +53,7 @@
FavorSizeOrSpeed="2"
OmitFramePointers="true"
AdditionalIncludeDirectories="..\objs\langs;..\objs\settings;..\src\3rdparty\squirrel\include"
PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE;WIN32_ENABLE_DIRECTMUSIC_SUPPORT;WITH_ZLIB;WITH_LZO;WITH_LZMA;LZMA_API_STATIC;WITH_PNG;WITH_FREETYPE;WITH_ICU;U_STATIC_IMPLEMENTATION;ENABLE_NETWORK;WITH_PERSONAL_DIR;PERSONAL_DIR=\&quot;OpenTTD\&quot;;WITH_ASSERT"
PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE;WIN32_ENABLE_DIRECTMUSIC_SUPPORT;WITH_ZLIB;WITH_LZO;WITH_LZMA;LZMA_API_STATIC;WITH_PNG;WITH_FREETYPE;WITH_ICU;U_STATIC_IMPLEMENTATION;ENABLE_NETWORK;WITH_PERSONAL_DIR;PERSONAL_DIR=\&quot;OpenTTD\&quot;"
StringPooling="true"
ExceptionHandling="1"
RuntimeLibrary="0"
@@ -255,7 +255,7 @@
FavorSizeOrSpeed="2"
OmitFramePointers="true"
AdditionalIncludeDirectories="..\objs\langs;..\objs\settings;..\src\3rdparty\squirrel\include"
PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE;WITH_ZLIB;WITH_LZO;WITH_LZMA;LZMA_API_STATIC;WITH_PNG;WITH_FREETYPE;WITH_ICU;U_STATIC_IMPLEMENTATION;ENABLE_NETWORK;WITH_PERSONAL_DIR;PERSONAL_DIR=\&quot;OpenTTD\&quot;;_SQ64;WITH_ASSERT"
PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE;WITH_ZLIB;WITH_LZO;WITH_LZMA;LZMA_API_STATIC;WITH_PNG;WITH_FREETYPE;WITH_ICU;U_STATIC_IMPLEMENTATION;ENABLE_NETWORK;WITH_PERSONAL_DIR;PERSONAL_DIR=\&quot;OpenTTD\&quot;;_SQ64"
StringPooling="true"
ExceptionHandling="1"
RuntimeLibrary="0"
+4 -4
View File
@@ -1,6 +1,6 @@
OpenTTD readme
Last updated: 2012-12-24
Release version: 1.3.0-beta1
Last updated: 2012-06-01
Release version: 1.2.1
------------------------------------------------------------------------
@@ -299,7 +299,7 @@ your operating system:
Different types of data or extensions go into different subdirectories of the
chosen main OpenTTD directory:
Config File: (no subdirectory)
Screenshots: screenshot
Screenshots: (no subdirectory)
Base Graphics: baseset (or a subdirectory thereof)
Sound Sets: baseset (or a subdirectory thereof)
NewGRFs: newgrf (or a subdirectory thereof)
@@ -650,7 +650,6 @@ The OpenTTD team (in alphabetical order):
Zdeněk Sojka (SmatZ) - Bug finder and fixer
José Soler (Terkhen) - General coding
Thijs Marinussen (Yexo) - AI Framework
Leif Linse (Zuu) - AI/Game Script
Inactive Developers:
Bjarni Corfitzen (Bjarni) - MacOSX port, coder and vehicles
@@ -685,6 +684,7 @@ Thanks to:
Andrew Parkhouse (andythenorth) - River graphics
David Dallaston (Pikka) - Tram tracks
Marcin Grzegorczyk - Foundations for tracks on slopes,
Daniel Blödorn (Bluescreen) - Title game
All Translators - For their support to make OpenTTD a truly international game
Bug Reporters - Thanks for all bug reports
Chris Sawyer - For an amazing game!
-12
View File
@@ -4,7 +4,6 @@ animated_tile.cpp
articulated_vehicles.cpp
autoreplace.cpp
bmp.cpp
cargomonitor.cpp
cargopacket.cpp
cargotype.cpp
cheat.cpp
@@ -25,7 +24,6 @@ engine.cpp
fileio.cpp
fios.cpp
fontcache.cpp
base_consist.cpp
gamelog.cpp
genworld.cpp
gfx.cpp
@@ -72,10 +70,8 @@ spritecache.cpp
station.cpp
strgen/strgen_base.cpp
string.cpp
stringfilter.cpp
strings.cpp
subsidy.cpp
textbuf.cpp
texteff.cpp
tgp.cpp
tile_map.cpp
@@ -125,7 +121,6 @@ base_station_base.h
bmp.h
bridge.h
cargo_type.h
cargomonitor.h
cargopacket.h
cargotype.h
cheat_func.h
@@ -173,7 +168,6 @@ fileio_func.h
fileio_type.h
fios.h
fontcache.h
base_consist.h
gamelog.h
gamelog_internal.h
genworld.h
@@ -278,7 +272,6 @@ sdl.h
sound/sdl_s.h
video/sdl_v.h
settings_func.h
settings_gui.h
settings_internal.h
settings_type.h
ship.h
@@ -304,7 +297,6 @@ stdafx.h
strgen/strgen.h
string_func.h
string_type.h
stringfilter_type.h
strings_func.h
strings_type.h
subsidy_base.h
@@ -313,7 +305,6 @@ subsidy_type.h
tar_type.h
terraform_gui.h
textbuf_gui.h
textbuf_type.h
texteff.hpp
textfile_gui.h
textfile_type.h
@@ -550,7 +541,6 @@ saveload/ai_sl.cpp
saveload/airport_sl.cpp
saveload/animated_tile_sl.cpp
saveload/autoreplace_sl.cpp
saveload/cargomonitor_sl.cpp
saveload/cargopacket_sl.cpp
saveload/cheat_sl.cpp
saveload/company_sl.cpp
@@ -735,7 +725,6 @@ script/api/script_bridge.hpp
script/api/script_bridgelist.hpp
script/api/script_cargo.hpp
script/api/script_cargolist.hpp
script/api/script_cargomonitor.hpp
script/api/script_company.hpp
script/api/script_companymode.hpp
script/api/script_controller.hpp
@@ -799,7 +788,6 @@ script/api/script_bridge.cpp
script/api/script_bridgelist.cpp
script/api/script_cargo.cpp
script/api/script_cargolist.cpp
script/api/script_cargomonitor.cpp
script/api/script_company.cpp
script/api/script_companymode.cpp
script/api/script_controller.cpp
+5 -29
View File
@@ -14,7 +14,6 @@
#include "../script/api/script_event_types.hpp"
#include "../core/string_compare_type.hpp"
#include "ai_scanner.hpp"
#include <map>
/** A list that maps AI names to their AIInfo object. */
@@ -68,30 +67,13 @@ public:
static void Stop(CompanyID company);
/**
* Suspend the AI and then pause execution of the script. The script
* will not be resumed from its suspended state until the script has
* been unpaused.
* @param company The company for which the AI should be paused.
* Suspend an AI for the reminder of the current tick. If the AI is
* in a state when it cannot be suspended, it will continue to run
* until it can be suspended.
* @param company The company for which the AI should be suspended.
* @pre Company::IsValidAiID(company)
*/
static void Pause(CompanyID company);
/**
* Resume execution of the AI. This function will not actually execute
* the script, but set a flag so that the script is executed my the usual
* mechanism that executes the script.
* @param company The company for which the AI should be unpaused.
* @pre Company::IsValidAiID(company)
*/
static void Unpause(CompanyID company);
/**
* Checks if the AI is paused.
* @param company The company for which to check if the AI is paused.
* @pre Company::IsValidAiID(company)
* @return true if the AI is paused, otherwise false.
*/
static bool IsPaused(CompanyID company);
static void Suspend(CompanyID company);
/**
* Kill any and all AIs we manage.
@@ -158,12 +140,6 @@ public:
* found it is removed from the config.
*/
static void Rescan();
/** Gets the ScriptScanner instance that is used to find AIs */
static AIScannerInfo *GetScannerInfo();
/** Gets the ScriptScanner instance that is used to find AI Libraries */
static AIScannerLibrary *GetScannerLibrary();
#if defined(ENABLE_NETWORK)
/** Wrapper function for AIScanner::HasAI */
static bool HasAI(const struct ContentInfo *ci, bool md5sum);
+7 -8
View File
@@ -28,8 +28,7 @@ ScriptConfigItem _start_date_config = {
AI::START_NEXT_DEVIATION,
30,
SCRIPTCONFIG_NONE,
NULL,
false
NULL
};
/* static */ AIConfig *AIConfig::GetConfig(CompanyID company, ScriptSettingSource source)
@@ -80,13 +79,13 @@ int AIConfig::GetSetting(const char *name) const
{
if (this->info == NULL) {
SettingValueList::const_iterator it = this->settings.find(name);
if (it == this->settings.end()) {
if (it == this->settings.end() || GetGameSettings().difficulty.diff_level != 3) {
assert(strcmp("start_date", name) == 0);
switch (GetGameSettings().script.settings_profile) {
case SP_EASY: return AI::START_NEXT_EASY;
case SP_MEDIUM: return AI::START_NEXT_MEDIUM;
case SP_HARD: return AI::START_NEXT_HARD;
case SP_CUSTOM: return AI::START_NEXT_MEDIUM;
switch (GetGameSettings().difficulty.diff_level) {
case 0: return AI::START_NEXT_EASY;
case 1: return AI::START_NEXT_MEDIUM;
case 2: return AI::START_NEXT_HARD;
case 3: return AI::START_NEXT_MEDIUM;
default: NOT_REACHED();
}
}
+3 -35
View File
@@ -112,37 +112,16 @@
DeleteWindowById(WC_AI_SETTINGS, company);
}
/* static */ void AI::Pause(CompanyID company)
/* static */ void AI::Suspend(CompanyID company)
{
/* The reason why dedicated servers are forbidden to execute this
* command is not because it is unsafe, but because there is no way
* for the server owner to unpause the script again. */
if (_network_dedicated) return;
if (_networking && !_network_server) return;
Backup<CompanyByte> cur_company(_current_company, company, FILE_LINE);
Company::Get(company)->ai_instance->Pause();
Company::Get(company)->ai_instance->Suspend();
cur_company.Restore();
}
/* static */ void AI::Unpause(CompanyID company)
{
Backup<CompanyByte> cur_company(_current_company, company, FILE_LINE);
Company::Get(company)->ai_instance->Unpause();
cur_company.Restore();
}
/* static */ bool AI::IsPaused(CompanyID company)
{
Backup<CompanyByte> cur_company(_current_company, company, FILE_LINE);
bool paused = Company::Get(company)->ai_instance->IsPaused();
cur_company.Restore();
return paused;
}
/* static */ void AI::KillAll()
{
/* It might happen there are no companies .. than we have nothing to loop */
@@ -373,14 +352,3 @@
}
#endif /* defined(ENABLE_NETWORK) */
/* static */ AIScannerInfo *AI::GetScannerInfo()
{
return AI::scanner_info;
}
/* static */ AIScannerLibrary *AI::GetScannerLibrary()
{
return AI::scanner_library;
}
+101 -275
View File
@@ -12,9 +12,8 @@
#include "../stdafx.h"
#include "../table/sprites.h"
#include "../error.h"
#include "../settings_gui.h"
#include "../gui.h"
#include "../querystring_gui.h"
#include "../stringfilter_type.h"
#include "../company_base.h"
#include "../company_gui.h"
#include "../strings_func.h"
@@ -25,9 +24,6 @@
#include "../settings_func.h"
#include "../network/network_content.h"
#include "../textfile_gui.h"
#include "../widgets/dropdown_type.h"
#include "../widgets/dropdown_func.h"
#include "../hotkeys.h"
#include "ai.hpp"
#include "../script/api/script_log.hpp"
@@ -122,13 +118,13 @@ struct AIListWindow : public Window {
int y = this->GetWidget<NWidgetBase>(WID_AIL_LIST)->pos_y;
/* First AI in the list is hardcoded to random */
if (this->vscroll->IsVisible(0)) {
DrawString(r.left + WD_MATRIX_LEFT, r.right - WD_MATRIX_LEFT, y + WD_MATRIX_TOP, this->slot == OWNER_DEITY ? STR_AI_CONFIG_NONE : STR_AI_CONFIG_RANDOM_AI, this->selected == -1 ? TC_WHITE : TC_ORANGE);
DrawString(r.left + WD_MATRIX_LEFT, r.right - WD_MATRIX_LEFT, y + WD_MATRIX_TOP, this->slot == OWNER_DEITY ? STR_AI_CONFIG_NONE : STR_AI_CONFIG_RANDOM_AI, this->selected == -1 ? TC_WHITE : TC_BLACK);
y += this->line_height;
}
ScriptInfoList::const_iterator it = this->info_list->begin();
for (int i = 1; it != this->info_list->end(); i++, it++) {
if (this->vscroll->IsVisible(i)) {
DrawString(r.left + WD_MATRIX_LEFT, r.right - WD_MATRIX_RIGHT, y + WD_MATRIX_TOP, (*it).second->GetName(), (this->selected == i - 1) ? TC_WHITE : TC_ORANGE);
DrawString(r.left + WD_MATRIX_LEFT, r.right - WD_MATRIX_RIGHT, y + WD_MATRIX_TOP, (*it).second->GetName(), (this->selected == i - 1) ? TC_WHITE : TC_BLACK);
y += this->line_height;
}
}
@@ -155,7 +151,7 @@ struct AIListWindow : public Window {
y += FONT_HEIGHT_NORMAL + WD_PAR_VSEP_NORMAL;
}
SetDParamStr(0, selected_info->GetDescription());
DrawStringMultiLine(r.left + WD_FRAMETEXT_LEFT, r.right - WD_FRAMETEXT_RIGHT, y, r.bottom - WD_FRAMERECT_BOTTOM, STR_JUST_RAW_STRING, TC_WHITE);
DrawStringMultiLine(r.left + WD_FRAMETEXT_LEFT, r.right - WD_FRAMETEXT_RIGHT, y, r.bottom - WD_FRAMERECT_BOTTOM, STR_JUST_RAW_STRING, TC_BLACK);
}
break;
}
@@ -260,7 +256,7 @@ static const NWidgetPart _nested_ai_list_widgets[] = {
static const WindowDesc _ai_list_desc(
WDP_CENTER, 200, 234,
WC_AI_LIST, WC_NONE,
0,
WDF_UNCLICK_BUTTONS,
_nested_ai_list_widgets, lengthof(_nested_ai_list_widgets)
);
@@ -282,8 +278,6 @@ struct AISettingsWindow : public Window {
ScriptConfig *ai_config; ///< The configuration we're modifying.
int clicked_button; ///< The button we clicked.
bool clicked_increase; ///< Whether we clicked the increase or decrease button.
bool clicked_dropdown; ///< Whether the dropdown is open.
bool closing_dropdown; ///< True, if the dropdown list is currently closing.
int timeout; ///< Timeout for unclicking the button.
int clicked_row; ///< The clicked row of settings.
int line_height; ///< Height of a row in the matrix widget.
@@ -299,8 +293,6 @@ struct AISettingsWindow : public Window {
AISettingsWindow(const WindowDesc *desc, CompanyID slot) : Window(),
slot(slot),
clicked_button(-1),
clicked_dropdown(false),
closing_dropdown(false),
timeout(0)
{
this->ai_config = GetConfig(slot);
@@ -363,13 +355,12 @@ struct AISettingsWindow : public Window {
for (; !this->vscroll->IsVisible(i); i++) it++;
bool rtl = _current_text_dir == TD_RTL;
uint buttons_left = rtl ? r.right - SETTING_BUTTON_WIDTH - 3 : r.left + 4;
uint text_left = r.left + (rtl ? WD_FRAMERECT_LEFT : SETTING_BUTTON_WIDTH + 8);
uint text_right = r.right - (rtl ? SETTING_BUTTON_WIDTH + 8 : WD_FRAMERECT_RIGHT);
uint buttons_left = rtl ? r.right - 23 : r.left + 4;
uint text_left = r.left + (rtl ? WD_FRAMERECT_LEFT : 28);
uint text_right = r.right - (rtl ? 28 : WD_FRAMERECT_RIGHT);
int y = r.top;
int button_y_offset = (this->line_height - SETTING_BUTTON_HEIGHT) / 2;
for (; this->vscroll->IsVisible(i) && it != visible_settings.end(); i++, it++) {
const ScriptConfigItem &config_item = **it;
int current_value = config->GetSetting((config_item).name);
@@ -394,14 +385,10 @@ struct AISettingsWindow : public Window {
}
if ((config_item.flags & SCRIPTCONFIG_BOOLEAN) != 0) {
DrawBoolButton(buttons_left, y + button_y_offset, current_value != 0, editable);
DrawBoolButton(buttons_left, y + 2, current_value != 0, editable);
SetDParam(idx++, current_value == 0 ? STR_CONFIG_SETTING_OFF : STR_CONFIG_SETTING_ON);
} else {
if (config_item.complete_labels) {
DrawDropDownButton(buttons_left, y + button_y_offset, COLOUR_YELLOW, this->clicked_row == i && clicked_dropdown, editable);
} else {
DrawArrowButtons(buttons_left, y + button_y_offset, 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);
}
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);
if (config_item.labels != NULL && config_item.labels->Contains(current_value)) {
SetDParam(idx++, STR_JUST_RAW_STRING);
SetDParamStr(idx++, config_item.labels->Find(current_value)->second);
@@ -416,13 +403,19 @@ struct AISettingsWindow : public Window {
}
}
virtual void OnPaint()
/**
* Check whether we modified the difficulty level or not.
*/
void CheckDifficultyLevel()
{
if (this->closing_dropdown) {
this->closing_dropdown = false;
this->clicked_dropdown = false;
if (_game_mode == GM_MENU) {
if (_settings_newgame.difficulty.diff_level != 3) {
_settings_newgame.difficulty.diff_level = 3;
ShowErrorMessage(STR_WARNING_DIFFICULTY_TO_CUSTOM, INVALID_STRING_ID, WL_WARNING);
}
} else if (_settings_game.difficulty.diff_level != 3) {
IConsoleSetSetting("difficulty.diff_level", 3);
}
this->DrawWidgets();
}
virtual void OnClick(Point pt, int widget, int click_count)
@@ -438,55 +431,18 @@ struct AISettingsWindow : public Window {
const ScriptConfigItem config_item = **it;
if (_game_mode == GM_NORMAL && ((this->slot == OWNER_DEITY) || Company::IsValidID(this->slot)) && (config_item.flags & SCRIPTCONFIG_INGAME) == 0) return;
if (this->clicked_row != num) {
DeleteChildWindows(WC_QUERY_STRING);
HideDropDownMenu(this);
this->clicked_row = num;
this->clicked_dropdown = false;
}
bool bool_item = (config_item.flags & SCRIPTCONFIG_BOOLEAN) != 0;
int x = pt.x - wid->pos_x;
if (_current_text_dir == TD_RTL) x = wid->current_x - 1 - x;
if (_current_text_dir == TD_RTL) x = wid->current_x - x;
x -= 4;
/* One of the arrows is clicked (or green/red rect in case of bool value) */
int old_val = this->ai_config->GetSetting(config_item.name);
if (!bool_item && IsInsideMM(x, 0, SETTING_BUTTON_WIDTH) && config_item.complete_labels) {
if (this->clicked_dropdown) {
/* unclick the dropdown */
HideDropDownMenu(this);
this->clicked_dropdown = false;
this->closing_dropdown = false;
} else {
const NWidgetBase *wid = this->GetWidget<NWidgetBase>(WID_AIS_BACKGROUND);
int rel_y = (pt.y - (int)wid->pos_y) % this->line_height;
Rect wi_rect;
wi_rect.left = pt.x - (_current_text_dir == TD_RTL ? SETTING_BUTTON_WIDTH - 1 - x : x);
wi_rect.right = wi_rect.left + SETTING_BUTTON_WIDTH - 1;
wi_rect.top = pt.y - rel_y + (this->line_height - SETTING_BUTTON_HEIGHT) / 2;
wi_rect.bottom = wi_rect.top + SETTING_BUTTON_HEIGHT - 1;
/* For dropdowns we also have to check the y position thoroughly, the mouse may not above the just opening dropdown */
if (pt.y >= wi_rect.top && pt.y <= wi_rect.bottom) {
this->clicked_dropdown = true;
this->closing_dropdown = false;
DropDownList *list = new DropDownList();
for (int i = config_item.min_value; i <= config_item.max_value; i++) {
list->push_back(new DropDownListCharStringItem(config_item.labels->Find(i)->second, i, false));
}
ShowDropDownListAt(this, list, old_val, -1, wi_rect, COLOUR_ORANGE, true);
}
}
} else if (IsInsideMM(x, 0, SETTING_BUTTON_WIDTH)) {
int new_val = old_val;
if (IsInsideMM(x, 0, 21)) {
int new_val = this->ai_config->GetSetting(config_item.name);
int old_val = new_val;
if (bool_item) {
new_val = !new_val;
} else if (x >= SETTING_BUTTON_WIDTH / 2) {
} else if (x >= 10) {
/* Increase button clicked */
new_val += config_item.step_size;
if (new_val > config_item.max_value) new_val = config_item.max_value;
@@ -502,10 +458,13 @@ struct AISettingsWindow : public Window {
this->ai_config->SetSetting(config_item.name, new_val);
this->clicked_button = num;
this->timeout = 5;
this->CheckDifficultyLevel();
}
} else if (!bool_item && !config_item.complete_labels) {
} else if (!bool_item) {
/* Display a query box so users can enter a custom value. */
SetDParam(0, old_val);
this->clicked_row = num;
SetDParam(0, this->ai_config->GetSetting(config_item.name));
ShowQueryString(STR_JUST_INT, STR_CONFIG_SETTING_QUERY_CAPTION, 10, this, CS_NUMERAL, QSF_NONE);
}
this->SetDirty();
@@ -533,27 +492,7 @@ struct AISettingsWindow : public Window {
if (_game_mode == GM_NORMAL && ((this->slot == OWNER_DEITY) || Company::IsValidID(this->slot)) && (it->flags & SCRIPTCONFIG_INGAME) == 0) return;
int32 value = atoi(str);
this->ai_config->SetSetting((*it).name, value);
this->SetDirty();
}
virtual void OnDropdownSelect(int widget, int index)
{
assert(this->clicked_dropdown);
ScriptConfigItemList::const_iterator it = this->ai_config->GetConfigList()->begin();
for (int i = 0; i < this->clicked_row; i++) it++;
if (_game_mode == GM_NORMAL && ((this->slot == OWNER_DEITY) || Company::IsValidID(this->slot)) && (it->flags & SCRIPTCONFIG_INGAME) == 0) return;
this->ai_config->SetSetting((*it).name, index);
this->SetDirty();
}
virtual void OnDropdownClose(Point pt, int widget, int index, bool instant_close)
{
/* We cannot raise the dropdown button just yet. OnClick needs some hint, whether
* the same dropdown button was clicked again, and then not open the dropdown again.
* So, we only remember that it was closed, and process it on the next OnPaint, which is
* after OnClick. */
assert(this->clicked_dropdown);
this->closing_dropdown = true;
this->CheckDifficultyLevel();
this->SetDirty();
}
@@ -606,7 +545,7 @@ static const NWidgetPart _nested_ai_settings_widgets[] = {
static const WindowDesc _ai_settings_desc(
WDP_CENTER, 500, 208,
WC_AI_SETTINGS, WC_NONE,
0,
WDF_UNCLICK_BUTTONS,
_nested_ai_settings_widgets, lengthof(_nested_ai_settings_widgets)
);
@@ -628,6 +567,8 @@ struct ScriptTextfileWindow : public TextfileWindow {
ScriptTextfileWindow(TextfileType file_type, CompanyID slot) : TextfileWindow(file_type), slot(slot)
{
this->GetWidget<NWidgetCore>(WID_TF_CAPTION)->SetDataTip(STR_TEXTFILE_README_CAPTION + file_type, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS);
const char *textfile = GetConfig(slot)->GetTextfile(file_type, slot);
this->LoadTextfile(textfile, (slot == OWNER_DEITY) ? GAME_DIR : AI_DIR);
}
@@ -700,7 +641,7 @@ static const NWidgetPart _nested_ai_config_widgets[] = {
static const WindowDesc _ai_config_desc(
WDP_CENTER, 0, 0,
WC_GAME_OPTIONS, WC_NONE,
0,
WDF_UNCLICK_BUTTONS,
_nested_ai_config_widgets, lengthof(_nested_ai_config_widgets)
);
@@ -938,31 +879,10 @@ void ShowAIConfigWindow()
new AIConfigWindow();
}
/**
* Set the widget colour of a button based on the
* state of the script. (dead or alive)
* @param button the button to update.
* @param dead true if the script is dead, otherwise false.
* @param paused true if the script is paused, otherwise false.
* @return true if the colour was changed and the window need to be marked as dirty.
*/
static bool SetScriptButtonColour(NWidgetCore &button, bool dead, bool paused)
{
/* Dead scripts are indicated with red background and
* paused scripts are indicated with yellow background. */
Colours colour = dead ? COLOUR_RED :
(paused ? COLOUR_YELLOW : COLOUR_GREY);
if (button.colour != colour) {
button.colour = colour;
return true;
}
return false;
}
/**
* Window with everything an AI prints via ScriptLog.
*/
struct AIDebugWindow : public Window {
struct AIDebugWindow : public QueryStringBaseWindow {
static const int top_offset; ///< Offset of the text at the top of the WID_AID_LOG_PANEL.
static const int bottom_offset; ///< Offset of the text at the bottom of the WID_AID_LOG_PANEL.
@@ -975,8 +895,6 @@ struct AIDebugWindow : public Window {
bool show_break_box; ///< Whether the break/debug box is visible.
static bool break_check_enabled; ///< Stop an AI when it prints a matching string
static char break_string[MAX_BREAK_STR_STRING_LENGTH]; ///< The string to match to the AI output
QueryString break_editbox; ///< Break editbox
static StringFilter break_string_filter; ///< Log filter for break.
static bool case_sensitive_break_check; ///< Is the matching done case-sensitive
int highlight_row; ///< The output row that matches the given string, or -1
Scrollbar *vscroll; ///< Cache of the vertical scrollbar.
@@ -992,7 +910,7 @@ struct AIDebugWindow : public Window {
* @param desc The description of the window.
* @param number The window number (actually unused).
*/
AIDebugWindow(const WindowDesc *desc, WindowNumber number) : break_editbox(MAX_BREAK_STR_STRING_LENGTH)
AIDebugWindow(const WindowDesc *desc, WindowNumber number) : QueryStringBaseWindow(MAX_BREAK_STR_STRING_LENGTH)
{
this->CreateNestedTree(desc);
this->vscroll = this->GetScrollbar(WID_AID_SCROLLBAR);
@@ -1013,19 +931,17 @@ struct AIDebugWindow : public Window {
this->last_vscroll_pos = 0;
this->autoscroll = true;
this->highlight_row = -1;
this->querystrings[WID_AID_BREAK_STR_EDIT_BOX] = &this->break_editbox;
InitializeTextBuffer(&this->text, this->edit_str_buf, this->edit_str_size, MAX_BREAK_STR_STRING_LENGTH);
/* Restore the break string value from static variable */
this->break_editbox.text.Assign(this->break_string);
strecpy(this->edit_str_buf, this->break_string, this->edit_str_buf + MAX_BREAK_STR_STRING_LENGTH);
UpdateTextBufferSize(&this->text);
/* Restore button state from static class variables */
if (ai_debug_company == OWNER_DEITY) {
this->LowerWidget(WID_AID_SCRIPT_GAME);
this->SetWidgetDisabledState(WID_AID_CONTINUE_BTN, !Game::IsPaused());
} else if (ai_debug_company != INVALID_COMPANY) {
this->LowerWidget(ai_debug_company + WID_AID_COMPANY_BUTTON_START);
this->SetWidgetDisabledState(WID_AID_CONTINUE_BTN, !AI::IsPaused(ai_debug_company));
}
this->SetWidgetLoweredState(WID_AID_BREAK_STR_ON_OFF_BTN, this->break_check_enabled);
this->SetWidgetLoweredState(WID_AID_MATCH_CASE_BTN, this->case_sensitive_break_check);
@@ -1061,14 +977,6 @@ struct AIDebugWindow : public Window {
break;
}
}
/* If no AI is available, see if there is a game script. */
if (ai_debug_company == INVALID_COMPANY && Game::GetInstance() != NULL) {
/* Lower the widget corresponding to the game script. */
this->LowerWidget(WID_AID_SCRIPT_GAME);
ai_debug_company = OWNER_DEITY;
}
}
/* Update "Reload AI" and "AI settings" buttons */
@@ -1081,6 +989,8 @@ struct AIDebugWindow : public Window {
if (this->IsShaded()) return; // Don't draw anything when the window is shaded.
if (this->show_break_box) this->DrawEditBox(WID_AID_BREAK_STR_EDIT_BOX);
/* Paint the company icons */
for (CompanyID i = COMPANY_FIRST; i < MAX_COMPANIES; i++) {
NWidgetCore *button = this->GetWidget<NWidgetCore>(i + WID_AID_COMPANY_BUTTON_START);
@@ -1094,12 +1004,13 @@ struct AIDebugWindow : public Window {
dirty = true;
}
/* Mark dead/paused AIs by setting the background colour. */
bool dead = valid && Company::Get(i)->ai_instance->IsDead();
bool paused = valid && Company::Get(i)->ai_instance->IsPaused();
/* Re-paint if the button was updated.
* (note that it is intentional that SetScriptButtonColour is always called) */
dirty = SetScriptButtonColour(*button, dead, paused) || dirty;
Colours colour = dead ? COLOUR_RED : COLOUR_GREY;
if (button->colour != colour) {
/* Mark dead AIs by red background */
button->colour = colour;
dirty = true;
}
/* Do we need a repaint? */
if (dirty) this->SetDirty();
@@ -1110,16 +1021,6 @@ struct AIDebugWindow : public Window {
DrawCompanyIcon(i, button->pos_x + button->current_x / 2 - 7 + offset, this->GetWidget<NWidgetBase>(WID_AID_COMPANY_BUTTON_START + i)->pos_y + 2 + offset);
}
/* Set button colour for Game Script. */
GameInstance *game = Game::GetInstance();
bool dead = game != NULL && game->IsDead();
bool paused = game != NULL && game->IsPaused();
NWidgetCore *button = this->GetWidget<NWidgetCore>(WID_AID_SCRIPT_GAME);
if (SetScriptButtonColour(*button, dead, paused)) {
/* Re-paint if the button was updated. */
this->SetWidgetDirty(WID_AID_SCRIPT_GAME);
}
/* If there are no active companies, don't display anything else. */
if (ai_debug_company == INVALID_COMPANY) return;
@@ -1232,13 +1133,10 @@ struct AIDebugWindow : public Window {
if (ai_debug_company == OWNER_DEITY) {
this->LowerWidget(WID_AID_SCRIPT_GAME);
this->SetWidgetDisabledState(WID_AID_CONTINUE_BTN, !Game::IsPaused());
} else {
this->LowerWidget(ai_debug_company + WID_AID_COMPANY_BUTTON_START);
this->SetWidgetDisabledState(WID_AID_CONTINUE_BTN, !AI::IsPaused(ai_debug_company));
}
this->highlight_row = -1; // The highlight of one AI make little sense for another AI.
this->autoscroll = true;
this->last_vscroll_pos = this->vscroll->GetPosition();
this->SetDirty();
@@ -1248,12 +1146,12 @@ struct AIDebugWindow : public Window {
virtual void OnClick(Point pt, int widget, int click_count)
{
/* Also called for hotkeys, so check for disabledness */
if (this->IsWidgetDisabled(widget)) return;
/* Check which button is clicked */
if (IsInsideMM(widget, WID_AID_COMPANY_BUTTON_START, WID_AID_COMPANY_BUTTON_END + 1)) {
ChangeToAI((CompanyID)(widget - WID_AID_COMPANY_BUTTON_START));
/* Is it no on disable? */
if (!this->IsWidgetDisabled(widget)) {
ChangeToAI((CompanyID)(widget - WID_AID_COMPANY_BUTTON_START));
}
}
switch (widget) {
@@ -1281,70 +1179,39 @@ struct AIDebugWindow : public Window {
case WID_AID_MATCH_CASE_BTN:
this->case_sensitive_break_check = !this->case_sensitive_break_check;
this->SetWidgetLoweredState(WID_AID_MATCH_CASE_BTN, this->case_sensitive_break_check);
this->SetWidgetDirty(WID_AID_MATCH_CASE_BTN);
break;
case WID_AID_CONTINUE_BTN:
/* Unpause current AI / game script and mark the corresponding script button dirty. */
if (ai_debug_company == OWNER_DEITY) {
Game::Unpause();
this->SetWidgetDirty(WID_AID_SCRIPT_GAME);
} else {
AI::Unpause(ai_debug_company);
this->SetWidgetDirty(WID_AID_COMPANY_BUTTON_START + ai_debug_company);
}
/* If the last AI/Game Script is unpaused, unpause the game too. */
if ((_pause_mode & PM_PAUSED_NORMAL) == PM_PAUSED_NORMAL) {
bool all_unpaused = !Game::IsPaused();
if (all_unpaused) {
Company *c;
FOR_ALL_COMPANIES(c) {
if (c->is_ai && AI::IsPaused(c->index)) {
all_unpaused = false;
break;
}
}
if (all_unpaused) {
/* All scripts have been unpaused => unpause the game. */
DoCommandP(0, PM_PAUSED_NORMAL, 0, CMD_PAUSE);
}
}
}
this->highlight_row = -1;
this->SetWidgetDirty(WID_AID_LOG_PANEL);
/* Unpause */
DoCommandP(0, PM_PAUSED_NORMAL, 0, CMD_PAUSE);
this->DisableWidget(WID_AID_CONTINUE_BTN);
this->RaiseWidget(WID_AID_CONTINUE_BTN); // Disabled widgets don't raise themself
break;
}
}
virtual void OnTimeout()
{
this->RaiseWidget(WID_AID_RELOAD_TOGGLE);
this->RaiseWidget(WID_AID_SETTINGS);
this->SetDirty();
}
virtual void OnMouseLoop()
{
this->HandleEditBox(WID_AID_BREAK_STR_EDIT_BOX);
}
virtual EventState OnKeyPress(uint16 key, uint16 keycode)
{
EventState state = ES_NOT_HANDLED;
int num = CheckHotkeyMatch(aidebug_hotkeys, keycode, this);
if (num != -1) {
if (this->show_break_box && num == WID_AID_BREAK_STR_EDIT_BOX) {
this->SetFocusedWidget(WID_AID_BREAK_STR_EDIT_BOX);
SetFocusedWindow(this);
state = ES_HANDLED;
} else if (this->show_break_box || num < WID_AID_BREAK_STRING_WIDGETS) {
this->OnClick(Point(), num, 1);
state = ES_HANDLED;
}
if (this->HandleEditBoxKey(WID_AID_BREAK_STR_EDIT_BOX, key, keycode, state) != HEBR_NOT_FOCUSED) {
/* Save the current string to static member so it can be restored next time the window is opened */
strecpy(this->break_string, this->edit_str_buf, lastof(this->break_string));
}
return state;
}
virtual void OnEditboxChanged(int wid)
{
if (wid == WID_AID_BREAK_STR_EDIT_BOX) {
/* Save the current string to static member so it can be restored next time the window is opened. */
strecpy(this->break_string, this->break_editbox.text.buf, lastof(this->break_string));
break_string_filter.SetFilterTerm(this->break_string);
}
}
/**
* Some data on this window has become invalid.
* @param data Information about the changed data.
@@ -1354,35 +1221,39 @@ struct AIDebugWindow : public Window {
{
if (data == -1 || ai_debug_company == data) this->SetDirty();
if (gui_scope && data == -2) {
/* The continue button should be disabled when the game is unpaused and
* it was previously paused by the break string ( = a line in the log
* was highlighted )*/
if ((_pause_mode & PM_PAUSED_NORMAL) == PM_UNPAUSED && this->highlight_row != -1) {
this->DisableWidget(WID_AID_CONTINUE_BTN);
this->SetWidgetDirty(WID_AID_CONTINUE_BTN);
this->SetWidgetDirty(WID_AID_LOG_PANEL);
this->highlight_row = -1;
}
}
/* If the log message is related to the active company tab, check the break string.
* This needs to be done in gameloop-scope, so the AI is suspended immediately. */
if (!gui_scope && data == ai_debug_company && this->break_check_enabled && !this->break_string_filter.IsEmpty()) {
if (ai_debug_company != OWNER_DEITY && !gui_scope && data == ai_debug_company && this->break_check_enabled && !StrEmpty(this->edit_str_buf)) {
/* Get the log instance of the active company */
ScriptLog::LogData *log = this->GetLogPointer();
if (log != NULL) {
this->break_string_filter.ResetState();
this->break_string_filter.AddLine(log->lines[log->pos]);
if (this->break_string_filter.GetState()) {
/* Pause execution of script. */
if (ai_debug_company == OWNER_DEITY) {
Game::Pause();
} else {
AI::Pause(ai_debug_company);
}
if (log != NULL && case_sensitive_break_check?
strstr(log->lines[log->pos], this->edit_str_buf) != 0 :
strcasestr(log->lines[log->pos], this->edit_str_buf) != 0) {
/* Pause the game. */
if ((_pause_mode & PM_PAUSED_NORMAL) == PM_UNPAUSED) {
DoCommandP(0, PM_PAUSED_NORMAL, 1, CMD_PAUSE);
}
/* Make it possible to click on the continue button */
this->EnableWidget(WID_AID_CONTINUE_BTN);
this->SetWidgetDirty(WID_AID_CONTINUE_BTN);
/* Highlight row that matched */
this->highlight_row = log->pos;
AI::Suspend(ai_debug_company);
if ((_pause_mode & PM_PAUSED_NORMAL) == PM_UNPAUSED) {
DoCommandP(0, PM_PAUSED_NORMAL, 1, CMD_PAUSE);
}
/* Make it possible to click on the continue button */
this->EnableWidget(WID_AID_CONTINUE_BTN);
this->SetWidgetDirty(WID_AID_CONTINUE_BTN);
/* Highlight row that matched */
this->highlight_row = log->pos;
}
}
}
@@ -1391,8 +1262,6 @@ struct AIDebugWindow : public Window {
{
this->vscroll->SetCapacityFromWidget(this, WID_AID_LOG_PANEL);
}
static Hotkey<AIDebugWindow> aidebug_hotkeys[];
};
const int AIDebugWindow::top_offset = WD_FRAMERECT_TOP + 2;
@@ -1401,7 +1270,6 @@ CompanyID AIDebugWindow::ai_debug_company = INVALID_COMPANY;
char AIDebugWindow::break_string[MAX_BREAK_STR_STRING_LENGTH] = "";
bool AIDebugWindow::break_check_enabled = true;
bool AIDebugWindow::case_sensitive_break_check = false;
StringFilter AIDebugWindow::break_string_filter(&AIDebugWindow::case_sensitive_break_check);
/** Make a number of rows with buttons for each company for the AI debug window. */
NWidgetBase *MakeCompanyButtonRowsAIDebug(int *biggest_index)
@@ -1409,33 +1277,6 @@ NWidgetBase *MakeCompanyButtonRowsAIDebug(int *biggest_index)
return MakeCompanyButtonRows(biggest_index, WID_AID_COMPANY_BUTTON_START, WID_AID_COMPANY_BUTTON_END, 8, STR_AI_DEBUG_SELECT_AI_TOOLTIP);
}
Hotkey<AIDebugWindow> AIDebugWindow::aidebug_hotkeys[] = {
Hotkey<AIDebugWindow>('1', "company_1", WID_AID_COMPANY_BUTTON_START),
Hotkey<AIDebugWindow>('2', "company_2", WID_AID_COMPANY_BUTTON_START + 1),
Hotkey<AIDebugWindow>('3', "company_3", WID_AID_COMPANY_BUTTON_START + 2),
Hotkey<AIDebugWindow>('4', "company_4", WID_AID_COMPANY_BUTTON_START + 3),
Hotkey<AIDebugWindow>('5', "company_5", WID_AID_COMPANY_BUTTON_START + 4),
Hotkey<AIDebugWindow>('6', "company_6", WID_AID_COMPANY_BUTTON_START + 5),
Hotkey<AIDebugWindow>('7', "company_7", WID_AID_COMPANY_BUTTON_START + 6),
Hotkey<AIDebugWindow>('8', "company_8", WID_AID_COMPANY_BUTTON_START + 7),
Hotkey<AIDebugWindow>('9', "company_9", WID_AID_COMPANY_BUTTON_START + 8),
Hotkey<AIDebugWindow>((uint16)0, "company_10", WID_AID_COMPANY_BUTTON_START + 9),
Hotkey<AIDebugWindow>((uint16)0, "company_11", WID_AID_COMPANY_BUTTON_START + 10),
Hotkey<AIDebugWindow>((uint16)0, "company_12", WID_AID_COMPANY_BUTTON_START + 11),
Hotkey<AIDebugWindow>((uint16)0, "company_13", WID_AID_COMPANY_BUTTON_START + 12),
Hotkey<AIDebugWindow>((uint16)0, "company_14", WID_AID_COMPANY_BUTTON_START + 13),
Hotkey<AIDebugWindow>((uint16)0, "company_15", WID_AID_COMPANY_BUTTON_START + 14),
Hotkey<AIDebugWindow>('S', "settings", WID_AID_SETTINGS),
Hotkey<AIDebugWindow>('0', "game_script", WID_AID_SCRIPT_GAME),
Hotkey<AIDebugWindow>((uint16)0, "reload", WID_AID_RELOAD_TOGGLE),
Hotkey<AIDebugWindow>('B', "break_toggle", WID_AID_BREAK_STR_ON_OFF_BTN),
Hotkey<AIDebugWindow>('F', "break_string", WID_AID_BREAK_STR_EDIT_BOX),
Hotkey<AIDebugWindow>('C', "match_case", WID_AID_MATCH_CASE_BTN),
Hotkey<AIDebugWindow>(WKC_RETURN, "continue", WID_AID_CONTINUE_BTN),
HOTKEY_LIST_END(AIDebugWindow)
};
Hotkey<AIDebugWindow> *_aidebug_hotkeys = AIDebugWindow::aidebug_hotkeys;
/** Widgets for the AI debug window. */
static const NWidgetPart _nested_ai_debug_widgets[] = {
NWidget(NWID_HORIZONTAL),
@@ -1448,7 +1289,7 @@ static const NWidgetPart _nested_ai_debug_widgets[] = {
NWidgetFunction(MakeCompanyButtonRowsAIDebug), SetPadding(0, 2, 1, 2),
EndContainer(),
NWidget(NWID_HORIZONTAL),
NWidget(WWT_TEXTBTN, COLOUR_GREY, WID_AID_SCRIPT_GAME), SetMinimalSize(100, 20), SetResize(1, 0), SetDataTip(STR_AI_GAME_SCRIPT, STR_AI_GAME_SCRIPT_TOOLTIP),
NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, WID_AID_SCRIPT_GAME), SetMinimalSize(100, 20), SetResize(1, 0), SetDataTip(STR_AI_GAME_SCRIPT, STR_AI_GAME_SCRIPT_TOOLTIP),
NWidget(WWT_TEXTBTN, COLOUR_GREY, WID_AID_NAME_TEXT), SetFill(1, 0), SetResize(1, 0), SetDataTip(STR_JUST_STRING, STR_AI_DEBUG_NAME_TOOLTIP),
NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, WID_AID_SETTINGS), SetMinimalSize(100, 20), SetDataTip(STR_AI_DEBUG_SETTINGS, STR_AI_DEBUG_SETTINGS_TOOLTIP),
NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, WID_AID_RELOAD_TOGGLE), SetMinimalSize(100, 20), SetDataTip(STR_AI_DEBUG_RELOAD, STR_AI_DEBUG_RELOAD_TOOLTIP),
@@ -1465,10 +1306,10 @@ static const NWidgetPart _nested_ai_debug_widgets[] = {
NWidget(WWT_PANEL, COLOUR_GREY),
NWidget(NWID_HORIZONTAL),
NWidget(WWT_LABEL, COLOUR_GREY), SetPadding(2, 2, 2, 4), SetDataTip(STR_AI_DEBUG_BREAK_ON_LABEL, 0x0),
NWidget(WWT_EDITBOX, COLOUR_GREY, WID_AID_BREAK_STR_EDIT_BOX), SetFill(1, 1), SetResize(1, 0), SetPadding(2, 2, 2, 2), SetDataTip(STR_AI_DEBUG_BREAK_STR_OSKTITLE, STR_AI_DEBUG_BREAK_STR_TOOLTIP),
NWidget(WWT_EDITBOX, COLOUR_WHITE, WID_AID_BREAK_STR_EDIT_BOX), SetFill(1, 1), SetResize(1, 0), SetPadding(2, 2, 2, 2), SetDataTip(STR_AI_DEBUG_BREAK_STR_OSKTITLE, STR_AI_DEBUG_BREAK_STR_TOOLTIP),
EndContainer(),
EndContainer(),
NWidget(WWT_TEXTBTN, COLOUR_GREY, WID_AID_MATCH_CASE_BTN), SetMinimalSize(100, 0), SetFill(0, 1), SetDataTip(STR_AI_DEBUG_MATCH_CASE, STR_AI_DEBUG_MATCH_CASE_TOOLTIP),
NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, WID_AID_MATCH_CASE_BTN), SetMinimalSize(100, 0), SetFill(0, 1), SetDataTip(STR_AI_DEBUG_MATCH_CASE, STR_AI_DEBUG_MATCH_CASE_TOOLTIP),
NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, WID_AID_CONTINUE_BTN), SetMinimalSize(100, 0), SetFill(0, 1), SetDataTip(STR_AI_DEBUG_CONTINUE, STR_AI_DEBUG_CONTINUE_TOOLTIP),
EndContainer(),
EndContainer(),
@@ -1492,30 +1333,15 @@ static const WindowDesc _ai_debug_desc(
* Open the AI debug window and select the given company.
* @param show_company Display debug information about this AI company.
*/
Window *ShowAIDebugWindow(CompanyID show_company)
void ShowAIDebugWindow(CompanyID show_company)
{
if (!_networking || _network_server) {
AIDebugWindow *w = (AIDebugWindow *)BringWindowToFrontById(WC_AI_DEBUG, 0);
if (w == NULL) w = new AIDebugWindow(&_ai_debug_desc, 0);
if (show_company != INVALID_COMPANY) w->ChangeToAI(show_company);
return w;
} else {
ShowErrorMessage(STR_ERROR_AI_DEBUG_SERVER_ONLY, INVALID_STRING_ID, WL_INFO);
}
return NULL;
}
/**
* Handler for global AI debug window hotkeys.
*/
EventState AIDebugGlobalHotkeys(uint16 key, uint16 keycode)
{
int num = CheckHotkeyMatch<AIDebugWindow>(_aidebug_hotkeys, keycode, NULL, true);
if (num == -1) return ES_NOT_HANDLED;
Window *w = ShowAIDebugWindow(INVALID_COMPANY);
if (w == NULL) return ES_NOT_HANDLED;
return w->OnKeyPress(key, keycode);
}
/**
+1 -1
View File
@@ -14,7 +14,7 @@
#include "../company_type.h"
Window* ShowAIDebugWindow(CompanyID show_company = INVALID_COMPANY);
void ShowAIDebugWindow(CompanyID show_company = INVALID_COMPANY);
void ShowAIConfigWindow();
void ShowAIDebugWindowIfAIError();
void InitializeAIGui();
+1 -1
View File
@@ -23,7 +23,7 @@
*/
static bool CheckAPIVersion(const char *api_version)
{
return strcmp(api_version, "0.7") == 0 || strcmp(api_version, "1.0") == 0 || strcmp(api_version, "1.1") == 0 || strcmp(api_version, "1.2") == 0 || strcmp(api_version, "1.3") == 0;
return strcmp(api_version, "0.7") == 0 || strcmp(api_version, "1.0") == 0 || strcmp(api_version, "1.1") == 0 || strcmp(api_version, "1.2") == 0;
}
#if defined(WIN32)
+24 -4
View File
@@ -81,6 +81,7 @@
#include "../company_base.h"
#include "../company_func.h"
#include "../fileio_func.h"
AIInstance::AIInstance() :
ScriptInstance("AI")
@@ -127,16 +128,13 @@ void AIInstance::RegisterAPI()
SQAIEventCompanyInTrouble_Register(this->engine);
SQAIEventCompanyMerger_Register(this->engine);
SQAIEventCompanyNew_Register(this->engine);
SQAIEventCompanyTown_Register(this->engine);
SQAIEventController_Register(this->engine);
SQAIEventDisasterZeppelinerCleared_Register(this->engine);
SQAIEventDisasterZeppelinerCrashed_Register(this->engine);
SQAIEventEngineAvailable_Register(this->engine);
SQAIEventEnginePreview_Register(this->engine);
SQAIEventExclusiveTransportRights_Register(this->engine);
SQAIEventIndustryClose_Register(this->engine);
SQAIEventIndustryOpen_Register(this->engine);
SQAIEventRoadReconstruction_Register(this->engine);
SQAIEventStationFirstVehicle_Register(this->engine);
SQAIEventSubsidyAwarded_Register(this->engine);
SQAIEventSubsidyExpired_Register(this->engine);
@@ -193,7 +191,29 @@ void AIInstance::RegisterAPI()
SQAIWaypointList_Register(this->engine);
SQAIWaypointList_Vehicle_Register(this->engine);
if (!this->LoadCompatibilityScripts(this->versionAPI, AI_DIR)) this->Died();
if (!this->LoadCompatibilityScripts(this->versionAPI)) this->Died();
}
bool AIInstance::LoadCompatibilityScripts(const char *api_version)
{
char script_name[32];
seprintf(script_name, lastof(script_name), "compat_%s.nut", api_version);
char buf[MAX_PATH];
Searchpath sp;
FOR_ALL_SEARCHPATHS(sp) {
FioAppendDirectory(buf, MAX_PATH, sp, AI_DIR);
ttd_strlcat(buf, script_name, MAX_PATH);
if (!FileExists(buf)) continue;
if (this->engine->LoadScript(buf)) return true;
ScriptLog::Error("Failed to load API compatibility script");
DEBUG(script, 0, "Error compiling / running API compatibility script: %s", buf);
return false;
}
ScriptLog::Warning("API compatibility script not found");
return true;
}
void AIInstance::Died()
+7
View File
@@ -29,10 +29,17 @@ public:
/* virtual */ ScriptInfo *FindLibrary(const char *library, int version);
private:
const char *versionAPI; ///< Current API used by this script.
/* virtual */ void RegisterAPI();
/* virtual */ void Died();
/* virtual */ CommandCallback *GetDoCommandCallback();
/* virtual */ void LoadDummyScript();
/**
* Load squirrel scripts to emulate an older API.
*/
bool LoadCompatibilityScripts(const char *api_version);
};
#endif /* AI_INSTANCE_HPP */
+2 -9
View File
@@ -32,7 +32,7 @@ enum VehicleAirFlags {
void HandleAircraftEnterHangar(Aircraft *v);
void GetAircraftSpriteSize(EngineID engine, uint &width, uint &height, int &xoffs, int &yoffs, EngineImageType image_type);
void GetAircraftSpriteSize(EngineID engine, uint &width, uint &height, EngineImageType image_type);
void UpdateAirplanesOnNewStation(const Station *st);
void UpdateAircraftCache(Aircraft *v, bool update_range = false);
@@ -76,15 +76,8 @@ struct Aircraft FINAL : public SpecializedVehicle<Aircraft, VEH_AIRCRAFT> {
int GetDisplaySpeed() const { return this->cur_speed; }
int GetDisplayMaxSpeed() const { return this->vcache.cached_max_speed; }
int GetSpeedOldUnits() const { return this->vcache.cached_max_speed * 10 / 128; }
int GetCurrentMaxSpeed() const { return this->GetSpeedOldUnits(); }
Money GetRunningCost() const;
bool IsInDepot() const
{
assert(this->IsPrimaryVehicle());
return (this->vehstatus & VS_HIDDEN) != 0 && IsHangarTile(this->tile);
}
bool IsInDepot() const { return (this->vehstatus & VS_HIDDEN) != 0 && IsHangarTile(this->tile); }
bool Tick();
void OnNewDay();
uint Crash(bool flooded = false);
+15 -17
View File
@@ -202,22 +202,17 @@ void DrawAircraftEngine(int left, int right, int preferred_x, int y, EngineID en
}
/**
* Get the size of the sprite of an aircraft sprite heading west (used for lists).
* @param engine The engine to get the sprite from.
* @param[out] width The width of the sprite.
* @param[out] height The height of the sprite.
* @param[out] xoffs Number of pixels to shift the sprite to the right.
* @param[out] yoffs Number of pixels to shift the sprite downwards.
* @param image_type Context the sprite is used in.
* Get the size of the sprite of an aircraft sprite heading west (used for lists)
* @param engine The engine to get the sprite from
* @param width The width of the sprite
* @param height The height of the sprite
*/
void GetAircraftSpriteSize(EngineID engine, uint &width, uint &height, int &xoffs, int &yoffs, EngineImageType image_type)
void GetAircraftSpriteSize(EngineID engine, uint &width, uint &height, EngineImageType image_type)
{
const Sprite *spr = GetSprite(GetAircraftIcon(engine, image_type), ST_NORMAL);
width = UnScaleByZoom(spr->width, ZOOM_LVL_GUI);
height = UnScaleByZoom(spr->height, ZOOM_LVL_GUI);
xoffs = UnScaleByZoom(spr->x_offs, ZOOM_LVL_GUI);
yoffs = UnScaleByZoom(spr->y_offs, ZOOM_LVL_GUI);
}
/**
@@ -370,7 +365,7 @@ bool Aircraft::FindClosestDepot(TileIndex *location, DestinationID *destination,
static void CheckIfAircraftNeedsService(Aircraft *v)
{
if (Company::Get(v->owner)->settings.vehicle.servint_aircraft == 0 || !v->NeedsAutomaticServicing()) return;
if (v->IsChainInDepot()) {
if (v->IsInDepot()) {
VehicleServiceInDepot(v);
return;
}
@@ -1168,10 +1163,13 @@ static void CrashAirplane(Aircraft *v)
AI::NewEvent(v->owner, new ScriptEventVehicleCrashed(v->index, v->tile, st == NULL ? ScriptEventVehicleCrashed::CRASH_AIRCRAFT_NO_AIRPORT : ScriptEventVehicleCrashed::CRASH_PLANE_LANDING));
Game::NewEvent(new ScriptEventVehicleCrashed(v->index, v->tile, st == NULL ? ScriptEventVehicleCrashed::CRASH_AIRCRAFT_NO_AIRPORT : ScriptEventVehicleCrashed::CRASH_PLANE_LANDING));
AddVehicleNewsItem(newsitem, NT_ACCIDENT, v->index, st != NULL ? st->index : INVALID_STATION);
AddVehicleNewsItem(newsitem,
NS_ACCIDENT,
v->index,
st != NULL ? st->index : INVALID_STATION);
ModifyStationRatingAround(v->tile, v->owner, -160, 30);
if (_settings_client.sound.disaster) SndPlayVehicleFx(SND_12_EXPLOSION, v);
SndPlayVehicleFx(SND_12_EXPLOSION, v);
}
/**
@@ -1224,7 +1222,7 @@ static void AircraftEntersTerminal(Aircraft *v)
/* show newsitem of celebrating citizens */
AddVehicleNewsItem(
STR_NEWS_FIRST_AIRCRAFT_ARRIVAL,
(v->owner == _local_company) ? NT_ARRIVAL_COMPANY : NT_ARRIVAL_OTHER,
(v->owner == _local_company) ? NS_ARRIVAL_COMPANY : NS_ARRIVAL_OTHER,
v->index,
st->index
);
@@ -1463,8 +1461,8 @@ static void AircraftEventHandler_Flying(Aircraft *v, const AirportFTAClass *apc)
{
Station *st = Station::Get(v->targetairport);
/* Runway busy, not allowed to use this airstation or closed, circle. */
if (CanVehicleUseStation(v, st) && (st->owner == OWNER_NONE || st->owner == v->owner) && !(st->airport.flags & AIRPORT_CLOSED_block)) {
/* runway busy or not allowed to use this airstation, circle */
if (CanVehicleUseStation(v, st) && (st->owner == OWNER_NONE || st->owner == v->owner)) {
/* {32,FLYING,NOTHING_block,37}, {32,LANDING,N,33}, {32,HELILANDING,N,41},
* if it is an airplane, look for LANDING, for helicopter HELILANDING
* it is possible to choose from multiple landing runways, so loop until a free one is found */
@@ -1864,7 +1862,7 @@ static void AircraftHandleDestTooFar(Aircraft *v, bool too_far)
if (v->owner == _local_company) {
/* Post a news message. */
SetDParam(0, v->index);
AddVehicleAdviceNewsItem(STR_NEWS_AIRCRAFT_DEST_TOO_FAR, v->index);
AddVehicleNewsItem(STR_NEWS_AIRCRAFT_DEST_TOO_FAR, NS_ADVICE, v->index);
}
}
return;
+1 -2
View File
@@ -122,8 +122,7 @@ static const uint64
OUT_WAY_block2 = 1ULL << 31,
/* end of new blocks */
NOTHING_block = 1ULL << 30,
AIRPORT_CLOSED_block = 1ULL << 63; ///< Dummy block for indicating a closed airport.
NOTHING_block = 1ULL << 30;
/** A single location on an airport where aircraft can move to. */
struct AirportMovingData {
+22 -25
View File
@@ -43,7 +43,7 @@ void CcBuildAirport(const CommandCost &result, TileIndex tile, uint32 p1, uint32
{
if (result.Failed()) return;
if (_settings_client.sound.confirm) SndPlayTileFx(SND_1F_SPLAT, tile);
SndPlayTileFx(SND_1F_SPLAT, tile);
if (!_settings_client.gui.persistent_buildingtools) ResetObjectToPlace();
}
@@ -57,7 +57,7 @@ static void PlaceAirport(TileIndex tile)
uint32 p2 = _ctrl_pressed;
SB(p2, 16, 16, INVALID_STATION); // no station to join
uint32 p1 = AirportClass::Get(_selected_airport_class)->GetSpec(_selected_airport_index)->GetIndex();
uint32 p1 = AirportClass::Get(_selected_airport_class, _selected_airport_index)->GetIndex();
p1 |= _selected_airport_layout << 8;
CommandContainer cmdcont = { tile, p1, p2, CMD_BUILD_AIRPORT | CMD_MSG(STR_ERROR_CAN_T_BUILD_AIRPORT_HERE), CcBuildAirport, "" };
ShowSelectStationIfNeeded(cmdcont, TileArea(tile, _thd.size.x / TILE_SIZE, _thd.size.y / TILE_SIZE));
@@ -207,8 +207,8 @@ class BuildAirportWindow : public PickerWindowBase {
{
DropDownList *list = new DropDownList();
for (uint i = 0; i < AirportClass::GetClassCount(); i++) {
list->push_back(new DropDownListStringItem(AirportClass::Get((AirportClassID)i)->name, i, false));
for (uint i = 0; i < AirportClass::GetCount(); i++) {
list->push_back(new DropDownListStringItem(AirportClass::GetName((AirportClassID)i), i, false));
}
return list;
@@ -229,7 +229,7 @@ public:
this->SetWidgetLoweredState(WID_AP_BTN_DOHILIGHT, _settings_client.gui.station_show_coverage);
this->OnInvalidateData();
this->vscroll->SetCount(AirportClass::Get(_selected_airport_class)->GetSpecCount());
this->vscroll->SetCount(AirportClass::GetCount(_selected_airport_class));
this->SelectFirstAvailableAirport(true);
}
@@ -242,13 +242,13 @@ public:
{
switch (widget) {
case WID_AP_CLASS_DROPDOWN:
SetDParam(0, AirportClass::Get(_selected_airport_class)->name);
SetDParam(0, AirportClass::GetName(_selected_airport_class));
break;
case WID_AP_LAYOUT_NUM:
SetDParam(0, STR_EMPTY);
if (_selected_airport_index != -1) {
const AirportSpec *as = AirportClass::Get(_selected_airport_class)->GetSpec(_selected_airport_index);
const AirportSpec *as = AirportClass::Get(_selected_airport_class, _selected_airport_index);
StringID string = GetAirportTextCallback(as, _selected_airport_layout, CBID_AIRPORT_LAYOUT_NAME);
if (string != STR_UNDEFINED) {
SetDParam(0, string);
@@ -268,8 +268,8 @@ public:
switch (widget) {
case WID_AP_CLASS_DROPDOWN: {
Dimension d = {0, 0};
for (uint i = 0; i < AirportClass::GetClassCount(); i++) {
SetDParam(0, AirportClass::Get((AirportClassID)i)->name);
for (uint i = 0; i < AirportClass::GetCount(); i++) {
SetDParam(0, AirportClass::GetName((AirportClassID)i));
d = maxdim(d, GetStringBoundingBox(STR_BLACK_STRING));
}
d.width += padding.width;
@@ -332,9 +332,8 @@ public:
switch (widget) {
case WID_AP_AIRPORT_LIST: {
int y = r.top;
AirportClass *apclass = AirportClass::Get(_selected_airport_class);
for (uint i = this->vscroll->GetPosition(); this->vscroll->IsVisible(i) && i < apclass->GetSpecCount(); i++) {
const AirportSpec *as = apclass->GetSpec(i);
for (uint i = this->vscroll->GetPosition(); this->vscroll->IsVisible(i) && i < AirportClass::GetCount(_selected_airport_class); i++) {
const AirportSpec *as = AirportClass::Get(_selected_airport_class, i);
if (!as->IsAvailable()) {
GfxFillRect(r.left + 1, y + 1, r.right - 1, y + this->line_height - 2, PC_BLACK, FILLRECT_CHECKER);
}
@@ -353,7 +352,7 @@ public:
case WID_AP_EXTRA_TEXT:
if (_selected_airport_index != -1) {
const AirportSpec *as = AirportClass::Get(_selected_airport_class)->GetSpec(_selected_airport_index);
const AirportSpec *as = AirportClass::Get(_selected_airport_class, _selected_airport_index);
StringID string = GetAirportTextCallback(as, _selected_airport_layout, CBID_AIRPORT_ADDITIONAL_TEXT);
if (string != STR_UNDEFINED) {
SetDParam(0, string);
@@ -375,7 +374,7 @@ public:
int bottom = panel_nwi->pos_y + panel_nwi->current_y;
if (_selected_airport_index != -1) {
const AirportSpec *as = AirportClass::Get(_selected_airport_class)->GetSpec(_selected_airport_index);
const AirportSpec *as = AirportClass::Get(_selected_airport_class, _selected_airport_index);
int rad = _settings_game.station.modified_catchment ? as->catchment : (uint)CA_UNMODIFIED;
/* only show the station (airport) noise, if the noise option is activated */
@@ -413,7 +412,7 @@ public:
this->DisableWidget(WID_AP_LAYOUT_DECREASE);
this->DisableWidget(WID_AP_LAYOUT_INCREASE);
} else {
const AirportSpec *as = AirportClass::Get(_selected_airport_class)->GetSpec(_selected_airport_index);
const AirportSpec *as = AirportClass::Get(_selected_airport_class, _selected_airport_index);
int w = as->size_x;
int h = as->size_y;
Direction rotation = as->rotation[_selected_airport_layout];
@@ -440,7 +439,7 @@ public:
case WID_AP_AIRPORT_LIST: {
int num_clicked = this->vscroll->GetPosition() + (pt.y - this->nested_array[widget]->pos_y) / this->line_height;
if (num_clicked >= this->vscroll->GetCount()) break;
const AirportSpec *as = AirportClass::Get(_selected_airport_class)->GetSpec(num_clicked);
const AirportSpec *as = AirportClass::Get(_selected_airport_class, num_clicked);
if (as->IsAvailable()) this->SelectOtherAirport(num_clicked);
break;
}
@@ -450,7 +449,7 @@ public:
this->SetWidgetLoweredState(WID_AP_BTN_DONTHILIGHT, !_settings_client.gui.station_show_coverage);
this->SetWidgetLoweredState(WID_AP_BTN_DOHILIGHT, _settings_client.gui.station_show_coverage);
this->SetDirty();
if (_settings_client.sound.click_beep) SndPlayFx(SND_15_BEEP);
SndPlayFx(SND_15_BEEP);
this->UpdateSelectSize();
break;
@@ -476,9 +475,8 @@ public:
void SelectFirstAvailableAirport(bool change_class)
{
/* First try to select an airport in the selected class. */
AirportClass *sel_apclass = AirportClass::Get(_selected_airport_class);
for (uint i = 0; i < sel_apclass->GetSpecCount(); i++) {
const AirportSpec *as = sel_apclass->GetSpec(i);
for (uint i = 0; i < AirportClass::GetCount(_selected_airport_class); i++) {
const AirportSpec *as = AirportClass::Get(_selected_airport_class, i);
if (as->IsAvailable()) {
this->SelectOtherAirport(i);
return;
@@ -488,9 +486,8 @@ public:
/* If that fails, select the first available airport
* from a random class. */
for (AirportClassID j = APC_BEGIN; j < APC_MAX; j++) {
AirportClass *apclass = AirportClass::Get(j);
for (uint i = 0; i < apclass->GetSpecCount(); i++) {
const AirportSpec *as = apclass->GetSpec(i);
for (uint i = 0; i < AirportClass::GetCount(j); i++) {
const AirportSpec *as = AirportClass::Get(j, i);
if (as->IsAvailable()) {
_selected_airport_class = j;
this->SelectOtherAirport(i);
@@ -507,7 +504,7 @@ public:
{
assert(widget == WID_AP_CLASS_DROPDOWN);
_selected_airport_class = (AirportClassID)index;
this->vscroll->SetCount(AirportClass::Get(_selected_airport_class)->GetSpecCount());
this->vscroll->SetCount(AirportClass::GetCount(_selected_airport_class));
this->SelectFirstAvailableAirport(false);
}
@@ -557,7 +554,7 @@ static const NWidgetPart _nested_build_airport_widgets[] = {
static const WindowDesc _build_airport_desc(
WDP_AUTO, 0, 0,
WC_BUILD_STATION, WC_BUILD_TOOLBAR,
WDF_CONSTRUCTION,
WDF_CONSTRUCTION | WDF_UNCLICK_BUTTONS,
_nested_build_airport_widgets, lengthof(_nested_build_airport_widgets)
);
+2 -6
View File
@@ -57,18 +57,16 @@ void RemoveAllEngineReplacement(EngineRenewList *erl)
* @param erl The renewlist to search in.
* @param engine Engine type to be replaced.
* @param group The group related to this replacement.
* @param[out] replace_when_old Set to true if the replacement should be done when old.
* @return The engine type to replace with, or INVALID_ENGINE if no
* replacement is in the list.
*/
EngineID EngineReplacement(EngineRenewList erl, EngineID engine, GroupID group, bool *replace_when_old)
EngineID EngineReplacement(EngineRenewList erl, EngineID engine, GroupID group)
{
const EngineRenew *er = GetEngineReplacement(erl, engine, group);
if (er == NULL && (group == DEFAULT_GROUP || (Group::IsValidID(group) && !Group::Get(group)->replace_protection))) {
/* We didn't find anything useful in the vehicle's own group so we will try ALL_GROUP */
er = GetEngineReplacement(erl, engine, ALL_GROUP);
}
if (replace_when_old != NULL) *replace_when_old = er == NULL ? false : er->replace_when_old;
return er == NULL ? INVALID_ENGINE : er->to;
}
@@ -78,11 +76,10 @@ EngineID EngineReplacement(EngineRenewList erl, EngineID engine, GroupID group,
* @param old_engine The original engine type.
* @param new_engine The replacement engine type.
* @param group The group related to this replacement.
* @param replace_when_old Replace when old or always?
* @param flags The calling command flags.
* @return 0 on success, CMD_ERROR on failure.
*/
CommandCost AddEngineReplacement(EngineRenewList *erl, EngineID old_engine, EngineID new_engine, GroupID group, bool replace_when_old, DoCommandFlag flags)
CommandCost AddEngineReplacement(EngineRenewList *erl, EngineID old_engine, EngineID new_engine, GroupID group, DoCommandFlag flags)
{
/* Check if the old vehicle is already in the list */
EngineRenew *er = GetEngineReplacement(*erl, old_engine, group);
@@ -96,7 +93,6 @@ CommandCost AddEngineReplacement(EngineRenewList *erl, EngineID old_engine, Engi
if (flags & DC_EXEC) {
er = new EngineRenew(old_engine, new_engine);
er->group_id = group;
er->replace_when_old = replace_when_old;
/* Insert before the first element */
er->next = (EngineRenew *)(*erl);
-1
View File
@@ -37,7 +37,6 @@ struct EngineRenew : EngineRenewPool::PoolItem<&_enginerenew_pool> {
EngineID to;
EngineRenew *next;
GroupID group_id;
bool replace_when_old; ///< Do replacement only when vehicle is old.
EngineRenew(EngineID from = INVALID_ENGINE, EngineID to = INVALID_ENGINE) : from(from), to(to) {}
~EngineRenew() {}
+12 -11
View File
@@ -225,11 +225,10 @@ static CargoID GetNewCargoTypeForReplace(Vehicle *v, EngineID engine_type, bool
* Get the EngineID of the replacement for a vehicle
* @param v The vehicle to find a replacement for
* @param c The vehicle's owner (it's faster to forward the pointer than refinding it)
* @param always_replace Always replace, even if not old.
* @param [out] e the EngineID of the replacement. INVALID_ENGINE if no replacement is found
* @return Error if the engine to build is not available
*/
static CommandCost GetNewEngineType(const Vehicle *v, const Company *c, bool always_replace, EngineID &e)
static CommandCost GetNewEngineType(const Vehicle *v, const Company *c, EngineID &e)
{
assert(v->type != VEH_TRAIN || !v->IsArticulatedPart());
@@ -240,9 +239,7 @@ static CommandCost GetNewEngineType(const Vehicle *v, const Company *c, bool alw
return CommandCost();
}
bool replace_when_old;
e = EngineReplacementForCompany(c, v->engine_type, v->group_id, &replace_when_old);
if (!always_replace && replace_when_old && !v->NeedsAutorenewing(c, false)) e = INVALID_ENGINE;
e = EngineReplacementForCompany(c, v->engine_type, v->group_id);
/* Autoreplace, if engine is available */
if (e != INVALID_ENGINE && IsEngineBuildable(e, v->type, _current_company)) {
@@ -274,7 +271,7 @@ static CommandCost BuildReplacementVehicle(Vehicle *old_veh, Vehicle **new_vehic
/* Shall the vehicle be replaced? */
const Company *c = Company::Get(_current_company);
EngineID e;
CommandCost cost = GetNewEngineType(old_veh, c, true, e);
CommandCost cost = GetNewEngineType(old_veh, c, e);
if (cost.Failed()) return cost;
if (e == INVALID_ENGINE) return CommandCost(); // neither autoreplace is set, nor autorenew is triggered
@@ -357,6 +354,11 @@ static CommandCost CopyHeadSpecificThings(Vehicle *old_head, Vehicle *new_head,
/* Last do those things which do never fail (resp. we do not care about), but which are not undo-able */
if (cost.Succeeded() && old_head != new_head && (flags & DC_EXEC) != 0) {
/* Copy vehicle name */
if (old_head->name != NULL) {
DoCommand(0, new_head->index, 0, DC_EXEC | DC_AUTOREPLACE, CMD_RENAME_VEHICLE, old_head->name);
}
/* Copy other things which cannot be copied by a command and which shall not stay resetted from the build vehicle command */
new_head->CopyVehicleConfigAndStatistics(old_head);
@@ -660,7 +662,7 @@ CommandCost CmdAutoreplaceVehicle(TileIndex tile, DoCommandFlag flags, uint32 p1
CommandCost ret = CheckOwnership(v->owner);
if (ret.Failed()) return ret;
if (!v->IsChainInDepot()) return CMD_ERROR;
if (!v->IsInDepot()) return CMD_ERROR;
if (v->vehstatus & VS_CRASHED) return CMD_ERROR;
bool free_wagon = false;
@@ -681,7 +683,7 @@ CommandCost CmdAutoreplaceVehicle(TileIndex tile, DoCommandFlag flags, uint32 p1
bool any_replacements = false;
while (w != NULL) {
EngineID e;
CommandCost cost = GetNewEngineType(w, c, false, e);
CommandCost cost = GetNewEngineType(w, c, e);
if (cost.Failed()) return cost;
any_replacements |= (e != INVALID_ENGINE);
w = (!free_wagon && w->type == VEH_TRAIN ? Train::From(w)->GetNextUnit() : NULL);
@@ -697,7 +699,7 @@ CommandCost CmdAutoreplaceVehicle(TileIndex tile, DoCommandFlag flags, uint32 p1
if (!was_stopped) cost.AddCost(CmdStartStopVehicle(v, true));
if (cost.Failed()) return cost;
assert(free_wagon || v->IsStoppedInDepot());
assert(v->IsStoppedInDepot());
/* We have to construct the new vehicle chain to test whether it is valid.
* Vehicle construction needs random bits, so we have to save the random seeds
@@ -734,7 +736,6 @@ CommandCost CmdAutoreplaceVehicle(TileIndex tile, DoCommandFlag flags, uint32 p1
* @param tile unused
* @param flags operation to perform
* @param p1 packed data
* - bit 0 = replace when engine gets old?
* - bits 16-31 = engine group
* @param p2 packed data
* - bits 0-15 = old engine type
@@ -759,7 +760,7 @@ CommandCost CmdSetAutoReplace(TileIndex tile, DoCommandFlag flags, uint32 p1, ui
if (!Engine::IsValidID(new_engine_type)) return CMD_ERROR;
if (!CheckAutoreplaceValidity(old_engine_type, new_engine_type, _current_company)) return CMD_ERROR;
cost = AddEngineReplacementForCompany(c, old_engine_type, new_engine_type, id_g, HasBit(p1, 0), flags);
cost = AddEngineReplacementForCompany(c, old_engine_type, new_engine_type, id_g, flags);
} else {
cost = RemoveEngineReplacementForCompany(c, old_engine_type, id_g, flags);
}
+6 -22
View File
@@ -16,8 +16,8 @@
#include "company_base.h"
void RemoveAllEngineReplacement(EngineRenewList *erl);
EngineID EngineReplacement(EngineRenewList erl, EngineID engine, GroupID group, bool *replace_when_old = NULL);
CommandCost AddEngineReplacement(EngineRenewList *erl, EngineID old_engine, EngineID new_engine, GroupID group, bool replace_when_old, DoCommandFlag flags);
EngineID EngineReplacement(EngineRenewList erl, EngineID engine, GroupID group);
CommandCost AddEngineReplacement(EngineRenewList *erl, EngineID old_engine, EngineID new_engine, GroupID group, DoCommandFlag flags);
CommandCost RemoveEngineReplacement(EngineRenewList *erl, EngineID engine, GroupID group, DoCommandFlag flags);
/**
@@ -34,13 +34,12 @@ static inline void RemoveAllEngineReplacementForCompany(Company *c)
* @param c company.
* @param engine Engine type.
* @param group The group related to this replacement.
* @param[out] replace_when_old Set to true if the replacement should be done when old.
* @return The engine type to replace with, or INVALID_ENGINE if no
* replacement is in the list.
*/
static inline EngineID EngineReplacementForCompany(const Company *c, EngineID engine, GroupID group, bool *replace_when_old = NULL)
static inline EngineID EngineReplacementForCompany(const Company *c, EngineID engine, GroupID group)
{
return EngineReplacement(c->engine_renew_list, engine, group, replace_when_old);
return EngineReplacement(c->engine_renew_list, engine, group);
}
/**
@@ -55,33 +54,18 @@ static inline bool EngineHasReplacementForCompany(const Company *c, EngineID eng
return EngineReplacementForCompany(c, engine, group) != INVALID_ENGINE;
}
/**
* Check if a company has a replacement set up for the given engine when it gets old.
* @param c Company.
* @param engine Engine type to be replaced.
* @param group The group related to this replacement.
* @return True if a replacement when old was set up, false otherwise.
*/
static inline bool EngineHasReplacementWhenOldForCompany(const Company *c, EngineID engine, GroupID group)
{
bool replace_when_old;
EngineReplacement(c->engine_renew_list, engine, group, &replace_when_old);
return replace_when_old;
}
/**
* Add an engine replacement for the company.
* @param c Company.
* @param old_engine The original engine type.
* @param new_engine The replacement engine type.
* @param group The group related to this replacement.
* @param replace_when_old Replace when old or always?
* @param flags The calling command flags.
* @return 0 on success, CMD_ERROR on failure.
*/
static inline CommandCost AddEngineReplacementForCompany(Company *c, EngineID old_engine, EngineID new_engine, GroupID group, bool replace_when_old, DoCommandFlag flags)
static inline CommandCost AddEngineReplacementForCompany(Company *c, EngineID old_engine, EngineID new_engine, GroupID group, DoCommandFlag flags)
{
return AddEngineReplacement(&c->engine_renew_list, old_engine, new_engine, group, replace_when_old, flags);
return AddEngineReplacement(&c->engine_renew_list, old_engine, new_engine, group, flags);
}
/**
+29 -82
View File
@@ -24,7 +24,6 @@
#include "settings_func.h"
#include "core/geometry_func.hpp"
#include "rail_gui.h"
#include "widgets/dropdown_func.h"
#include "widgets/autoreplace_widget.h"
@@ -34,7 +33,7 @@ void DrawEngineList(VehicleType type, int x, int r, int y, const GUIEngineList *
static int CDECL EngineNumberSorter(const EngineID *a, const EngineID *b)
{
int r = Engine::Get(*a)->list_position - Engine::Get(*b)->list_position;
int r = ListPositionOfEngine(*a) - ListPositionOfEngine(*b);
return r;
}
@@ -68,12 +67,6 @@ void AddRemoveEngineFromAutoreplaceAndBuildWindows(VehicleType type)
InvalidateWindowClassesData(WC_BUILD_VEHICLE); // The build windows needs updating as well
}
static const StringID _start_replace_dropdown[] = {
STR_REPLACE_VEHICLES_NOW,
STR_REPLACE_VEHICLES_WHEN_OLD,
INVALID_STRING_ID
};
/**
* Window for the autoreplacing of vehicles.
*/
@@ -177,18 +170,6 @@ class ReplaceVehicleWindow : public Window {
this->reset_sel_engine = false;
}
/**
* Handle click on the start replace button.
* @param replace_when_old Replace now or only when old?
*/
void ReplaceClick_StartReplace(bool replace_when_old)
{
EngineID veh_from = this->sel_engine[0];
EngineID veh_to = this->sel_engine[1];
DoCommandP(0, (replace_when_old ? 1 : 0) | (this->sel_group << 16), veh_from + (veh_to << 16), CMD_SET_AUTOREPLACE);
this->SetDirty();
}
public:
ReplaceVehicleWindow(const WindowDesc *desc, VehicleType vehicletype, GroupID id_g) : Window()
{
@@ -289,17 +270,6 @@ public:
*size = maxdim(*size, d);
break;
}
case WID_RV_START_REPLACE: {
Dimension d = GetStringBoundingBox(STR_REPLACE_VEHICLES_START);
for (int i = 0; _start_replace_dropdown[i] != INVALID_STRING_ID; i++) {
d = maxdim(d, GetStringBoundingBox(_start_replace_dropdown[i]));
}
d.width += padding.width;
d.height += padding.height;
*size = maxdim(*size, d);
break;
}
}
}
@@ -308,20 +278,6 @@ public:
switch (widget) {
case WID_RV_CAPTION:
SetDParam(0, STR_REPLACE_VEHICLE_TRAIN + this->window_number);
switch (this->sel_group) {
case ALL_GROUP:
SetDParam(1, STR_GROUP_ALL_TRAINS + this->window_number);
break;
case DEFAULT_GROUP:
SetDParam(1, STR_GROUP_DEFAULT_TRAINS + this->window_number);
break;
default:
SetDParam(1, STR_GROUP_NAME);
SetDParam(2, sel_group);
break;
}
break;
case WID_RV_TRAIN_WAGONREMOVE_TOGGLE: {
@@ -345,10 +301,8 @@ public:
if (!EngineHasReplacementForCompany(c, this->sel_engine[0], this->sel_group)) {
SetDParam(0, STR_REPLACE_NOT_REPLACING);
} else {
bool when_old = false;
EngineID e = EngineReplacementForCompany(c, this->sel_engine[0], this->sel_group, &when_old);
SetDParam(0, when_old ? STR_REPLACE_REPLACING_WHEN_OLD : STR_ENGINE_NAME);
SetDParam(1, e);
SetDParam(0, STR_ENGINE_NAME);
SetDParam(1, EngineReplacementForCompany(c, this->sel_engine[0], this->sel_group));
}
} else {
SetDParam(0, STR_REPLACE_NOT_REPLACING_VEHICLE_SELECTED);
@@ -380,11 +334,13 @@ public:
/* Disable the "Start Replacing" button if:
* Either engines list is empty
* or The selected replacement engine has a replacement (to prevent loops). */
* or The selected replacement engine has a replacement (to prevent loops)
* or The right engines list (new replacement) has the existing replacement vehicle selected */
this->SetWidgetDisabledState(WID_RV_START_REPLACE,
this->sel_engine[0] == INVALID_ENGINE ||
this->sel_engine[1] == INVALID_ENGINE ||
EngineReplacementForCompany(c, this->sel_engine[1], this->sel_group) != INVALID_ENGINE);
EngineReplacementForCompany(c, this->sel_engine[1], this->sel_group) != INVALID_ENGINE ||
EngineReplacementForCompany(c, this->sel_engine[0], this->sel_group) == this->sel_engine[1]);
/* Disable the "Stop Replacing" button if:
* The left engines list (existing vehicle) is empty
@@ -393,6 +349,9 @@ public:
this->sel_engine[0] == INVALID_ENGINE ||
!EngineHasReplacementForCompany(c, this->sel_engine[0], this->sel_group));
/* now the actual drawing of the window itself takes place */
SetDParam(0, STR_REPLACE_VEHICLE_TRAIN + this->window_number);
if (this->window_number == VEH_TRAIN) {
/* sets the colour of that art thing */
this->GetWidget<NWidgetCore>(WID_RV_TRAIN_FLUFF_LEFT)->colour = _company_colours[_local_company];
@@ -442,13 +401,10 @@ public:
break;
case WID_RV_START_REPLACE: { // Start replacing
if (this->GetWidget<NWidgetLeaf>(widget)->ButtonHit(pt)) {
this->HandleButtonClick(WID_RV_START_REPLACE);
ReplaceClick_StartReplace(false);
} else {
bool replacment_when_old = EngineHasReplacementWhenOldForCompany(Company::Get(_local_company), this->sel_engine[0], this->sel_group);
ShowDropDownMenu(this, _start_replace_dropdown, replacment_when_old ? 1 : 0, WID_RV_START_REPLACE, !this->replace_engines ? 1 << 1 : 0, 0);
}
EngineID veh_from = this->sel_engine[0];
EngineID veh_to = this->sel_engine[1];
DoCommandP(0, this->sel_group << 16, veh_from + (veh_to << 16), CMD_SET_AUTOREPLACE);
this->SetDirty();
break;
}
@@ -485,26 +441,17 @@ public:
virtual void OnDropdownSelect(int widget, int index)
{
switch (widget) {
case WID_RV_TRAIN_RAILTYPE_DROPDOWN: {
RailType temp = (RailType)index;
if (temp == sel_railtype) return; // we didn't select a new one. No need to change anything
sel_railtype = temp;
/* Reset scrollbar positions */
this->vscroll[0]->SetPosition(0);
this->vscroll[1]->SetPosition(0);
/* Rebuild the lists */
this->engines[0].ForceRebuild();
this->engines[1].ForceRebuild();
this->reset_sel_engine = true;
this->SetDirty();
break;
}
case WID_RV_START_REPLACE:
this->ReplaceClick_StartReplace(index != 0);
break;
}
RailType temp = (RailType)index;
if (temp == sel_railtype) return; // we didn't select a new one. No need to change anything
sel_railtype = temp;
/* Reset scrollbar positions */
this->vscroll[0]->SetPosition(0);
this->vscroll[1]->SetPosition(0);
/* Rebuild the lists */
this->engines[0].ForceRebuild();
this->engines[1].ForceRebuild();
this->reset_sel_engine = true;
this->SetDirty();
}
virtual void OnResize()
@@ -550,7 +497,7 @@ static const NWidgetPart _nested_replace_rail_vehicle_widgets[] = {
NWidget(WWT_PANEL, COLOUR_GREY, WID_RV_RIGHT_DETAILS), SetMinimalSize(240, 122), SetResize(1, 0), EndContainer(),
EndContainer(),
NWidget(NWID_HORIZONTAL),
NWidget(NWID_PUSHBUTTON_DROPDOWN, COLOUR_GREY, WID_RV_START_REPLACE), SetMinimalSize(139, 12), SetDataTip(STR_REPLACE_VEHICLES_START, STR_REPLACE_HELP_START_BUTTON),
NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, WID_RV_START_REPLACE), SetMinimalSize(139, 12), SetDataTip(STR_REPLACE_VEHICLES_START, STR_REPLACE_HELP_START_BUTTON),
NWidget(WWT_PANEL, COLOUR_GREY, WID_RV_INFO_TAB), SetMinimalSize(167, 12), SetDataTip(0x0, STR_REPLACE_HELP_REPLACE_INFO_TAB), SetResize(1, 0),
EndContainer(),
NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, WID_RV_STOP_REPLACE), SetMinimalSize(150, 12), SetDataTip(STR_REPLACE_VEHICLES_STOP, STR_REPLACE_HELP_STOP_BUTTON),
@@ -568,7 +515,7 @@ static const NWidgetPart _nested_replace_rail_vehicle_widgets[] = {
static const WindowDesc _replace_rail_vehicle_desc(
WDP_AUTO, 500, 140,
WC_REPLACE_VEHICLE, WC_NONE,
WDF_CONSTRUCTION,
WDF_UNCLICK_BUTTONS | WDF_CONSTRUCTION,
_nested_replace_rail_vehicle_widgets, lengthof(_nested_replace_rail_vehicle_widgets)
);
@@ -590,7 +537,7 @@ static const NWidgetPart _nested_replace_vehicle_widgets[] = {
NWidget(WWT_PANEL, COLOUR_GREY, WID_RV_RIGHT_DETAILS), SetMinimalSize(228, 92), SetResize(1, 0), EndContainer(),
EndContainer(),
NWidget(NWID_HORIZONTAL),
NWidget(NWID_PUSHBUTTON_DROPDOWN, COLOUR_GREY, WID_RV_START_REPLACE), SetMinimalSize(139, 12), SetDataTip(STR_REPLACE_VEHICLES_START, STR_REPLACE_HELP_START_BUTTON),
NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, WID_RV_START_REPLACE), SetMinimalSize(139, 12), SetDataTip(STR_REPLACE_VEHICLES_START, STR_REPLACE_HELP_START_BUTTON),
NWidget(WWT_PANEL, COLOUR_GREY, WID_RV_INFO_TAB), SetMinimalSize(167, 12), SetDataTip(0x0, STR_REPLACE_HELP_REPLACE_INFO_TAB), SetResize(1, 0), EndContainer(),
NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, WID_RV_STOP_REPLACE), SetMinimalSize(138, 12), SetDataTip(STR_REPLACE_VEHICLES_STOP, STR_REPLACE_HELP_STOP_BUTTON),
NWidget(WWT_RESIZEBOX, COLOUR_GREY),
@@ -600,7 +547,7 @@ static const NWidgetPart _nested_replace_vehicle_widgets[] = {
static const WindowDesc _replace_vehicle_desc(
WDP_AUTO, 456, 118,
WC_REPLACE_VEHICLE, WC_NONE,
WDF_CONSTRUCTION,
WDF_UNCLICK_BUTTONS | WDF_CONSTRUCTION,
_nested_replace_vehicle_widgets, lengthof(_nested_replace_vehicle_widgets)
);
-44
View File
@@ -1,44 +0,0 @@
/* $Id$ */
/*
* This file is part of OpenTTD.
* OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
* OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* 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 base_consist.cpp Properties for front vehicles/consists. */
#include "stdafx.h"
#include "base_consist.h"
#include "vehicle_base.h"
BaseConsist::~BaseConsist()
{
free(this->name);
}
/**
* Copy properties of other BaseConsist.
* @param src Source for copying
*/
void BaseConsist::CopyConsistPropertiesFrom(const BaseConsist *src)
{
if (this == src) return;
free(this->name);
this->name = src->name != NULL ? strdup(src->name) : NULL;
this->current_order_time = src->current_order_time;
this->lateness_counter = src->lateness_counter;
this->timetable_start = src->timetable_start;
this->service_interval = src->service_interval;
this->cur_real_order_index = src->cur_real_order_index;
this->cur_implicit_order_index = src->cur_implicit_order_index;
if (HasBit(src->vehicle_flags, VF_TIMETABLE_STARTED)) SetBit(this->vehicle_flags, VF_TIMETABLE_STARTED);
if (HasBit(src->vehicle_flags, VF_AUTOFILL_TIMETABLE)) SetBit(this->vehicle_flags, VF_AUTOFILL_TIMETABLE);
if (HasBit(src->vehicle_flags, VF_AUTOFILL_PRES_WAIT_TIME)) SetBit(this->vehicle_flags, VF_AUTOFILL_PRES_WAIT_TIME);
}
-40
View File
@@ -1,40 +0,0 @@
/* $Id$ */
/*
* This file is part of OpenTTD.
* OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
* OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* 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 base_consist.h Properties for front vehicles/consists. */
#ifndef BASE_CONSIST_H
#define BASE_CONSIST_H
#include "order_type.h"
#include "date_type.h"
/** Various front vehicle properties that are preserved when autoreplacing, using order-backup or switching front engines within a consist. */
struct BaseConsist {
char *name; ///< Name of vehicle
/* Used for timetabling. */
uint32 current_order_time; ///< How many ticks have passed since this order started.
int32 lateness_counter; ///< How many ticks late (or early if negative) this vehicle is.
Date timetable_start; ///< When the vehicle is supposed to start the timetable.
Date service_interval; ///< The interval for (automatic) servicing; either in days or %.
VehicleOrderID cur_real_order_index;///< The index to the current real (non-implicit) order
VehicleOrderID cur_implicit_order_index;///< The index to the current implicit order
byte vehicle_flags; ///< Used for gradual loading and other miscellaneous things (@see VehicleFlags enum)
BaseConsist() : name(NULL) {}
virtual ~BaseConsist();
void CopyConsistPropertiesFrom(const BaseConsist *src);
};
#endif /* BASE_CONSIST_H */
-11
View File
@@ -201,8 +201,6 @@ public:
return num + fs.Scan(GetExtension(), BASESET_DIR, Tbase_set::SEARCH_IN_TARS);
}
static Tbase_set *GetAvailableSets();
static bool SetSet(const char *name);
static char *GetSetsList(char *p, const char *last);
static int GetNumSets();
@@ -219,15 +217,6 @@ public:
static bool HasSet(const ContentInfo *ci, bool md5sum);
};
/**
* Check whether there's a base set matching some information.
* @param ci The content info to compare it to.
* @param md5sum Should the MD5 checksum be tested as well?
* @param s The list with sets.
* @return The filename of the first file of the base set, or \c NULL if there is no match.
*/
template <class Tbase_set>
const char *TryGetBaseSetFile(const ContentInfo *ci, bool md5sum, const Tbase_set *s);
/** Types of graphics in the base graphics set */
enum GraphicsFileType {
+15 -29
View File
@@ -7,10 +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 base_media_func.h Generic function implementations for base data (graphics, sounds).
* @note You should _never_ include this file due to the SET_TYPE define.
*/
/** @file base_media_func.h Generic function implementations for base data (graphics, sounds). */
#include "base_media_base.h"
#include "debug.h"
@@ -277,13 +274,19 @@ template <class Tbase_set>
#if defined(ENABLE_NETWORK)
#include "network/network_content.h"
template <class Tbase_set> const char *TryGetBaseSetFile(const ContentInfo *ci, bool md5sum, const Tbase_set *s)
/**
* Check whether there's a base set matching some information.
* @param ci The content info to compare it to.
* @param md5sum Should the MD5 checksum be tested as well?
* @param s The list with sets.
*/
template <class Tbase_set> bool HasBaseSet(const ContentInfo *ci, bool md5sum, const Tbase_set *s)
{
for (; s != NULL; s = s->next) {
if (s->GetNumMissing() != 0) continue;
if (s->shortname != ci->unique_id) continue;
if (!md5sum) return s->files[0].filename;
if (!md5sum) return true;
byte md5[16];
memset(md5, 0, sizeof(md5));
@@ -292,26 +295,21 @@ template <class Tbase_set> const char *TryGetBaseSetFile(const ContentInfo *ci,
md5[j] ^= s->files[i].hash[j];
}
}
if (memcmp(md5, ci->md5sum, sizeof(md5)) == 0) return s->files[0].filename;
if (memcmp(md5, ci->md5sum, sizeof(md5)) == 0) return true;
}
return NULL;
return false;
}
template <class Tbase_set>
/* static */ bool BaseMedia<Tbase_set>::HasSet(const ContentInfo *ci, bool md5sum)
{
return (TryGetBaseSetFile(ci, md5sum, BaseMedia<Tbase_set>::available_sets) != NULL) ||
(TryGetBaseSetFile(ci, md5sum, BaseMedia<Tbase_set>::duplicate_sets) != NULL);
return HasBaseSet(ci, md5sum, BaseMedia<Tbase_set>::available_sets) ||
HasBaseSet(ci, md5sum, BaseMedia<Tbase_set>::duplicate_sets);
}
#else
template <class Tbase_set>
const char *TryGetBaseSetFile(const ContentInfo *ci, bool md5sum, const Tbase_set *s)
{
return NULL;
}
template <class Tbase_set>
/* static */ bool BaseMedia<Tbase_set>::HasSet(const ContentInfo *ci, bool md5sum)
{
@@ -376,16 +374,6 @@ template <class Tbase_set>
return BaseMedia<Tbase_set>::used_set;
}
/**
* Return the available sets.
* @return The available sets.
*/
template <class Tbase_set>
/* static */ Tbase_set *BaseMedia<Tbase_set>::GetAvailableSets()
{
return BaseMedia<Tbase_set>::available_sets;
}
/**
* Force instantiation of methods so we don't get linker errors.
* @param repl_type the type of the BaseMedia to instantiate
@@ -402,7 +390,5 @@ template <class Tbase_set>
template int repl_type::GetIndexOfUsedSet(); \
template const set_type *repl_type::GetSet(int index); \
template const set_type *repl_type::GetUsedSet(); \
template bool repl_type::DetermineBestSet(); \
template set_type *repl_type::GetAvailableSets(); \
template const char *TryGetBaseSetFile(const ContentInfo *ci, bool md5sum, const set_type *s);
template bool repl_type::DetermineBestSet();
+10 -10
View File
@@ -31,13 +31,13 @@ inline void Blitter_32bppAnim::Draw(const Blitter::BlitterParams *bp, ZoomLevel
src_n = (const uint16 *)((const byte *)src_n + *(const uint32 *)src_n);
}
Colour *dst = (Colour *)bp->dst + bp->top * bp->pitch + bp->left;
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;
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++) {
Colour *dst_ln = dst + bp->pitch;
uint32 *dst_ln = dst + bp->pitch;
uint16 *anim_ln = anim + this->anim_buf_width;
const Colour *src_px_ln = (const Colour *)((const byte *)src_px + *(const uint32 *)src_px);
@@ -46,7 +46,7 @@ inline void Blitter_32bppAnim::Draw(const Blitter::BlitterParams *bp, ZoomLevel
const uint16 *src_n_ln = (const uint16 *)((const byte *)src_n + *(const uint32 *)src_n);
src_n += 2;
Colour *dst_end = dst + bp->skip_left;
uint32 *dst_end = dst + bp->skip_left;
uint n;
@@ -219,7 +219,7 @@ void Blitter_32bppAnim::DrawColourMappingRect(void *dst, int width, int height,
return;
}
Colour *udst = (Colour *)dst;
uint32 *udst = (uint32 *)dst;
uint16 *anim;
anim = this->anim_buf + ((uint32 *)dst - (uint32 *)_screen.dst_ptr);
@@ -256,7 +256,7 @@ void Blitter_32bppAnim::DrawColourMappingRect(void *dst, int width, int height,
void Blitter_32bppAnim::SetPixel(void *video, int x, int y, uint8 colour)
{
*((Colour *)video + x + y * _screen.pitch) = LookupColourInPalette(colour);
*((uint32 *)video + x + y * _screen.pitch) = LookupColourInPalette(colour);
/* Set the colour in the anim-buffer too, if we are rendering to the screen */
if (_screen_disable_anim) return;
@@ -271,13 +271,13 @@ void Blitter_32bppAnim::DrawRect(void *video, int width, int height, uint8 colou
return;
}
Colour colour32 = LookupColourInPalette(colour);
uint32 colour32 = LookupColourInPalette(colour);
uint16 *anim_line;
anim_line = ((uint32 *)video - (uint32 *)_screen.dst_ptr) + this->anim_buf;
do {
Colour *dst = (Colour *)video;
uint32 *dst = (uint32 *)video;
uint16 *anim = anim_line;
for (int i = width; i > 0; i--) {
@@ -296,13 +296,13 @@ void Blitter_32bppAnim::CopyFromBuffer(void *video, const void *src, int width,
{
assert(!_screen_disable_anim);
assert(video >= _screen.dst_ptr && video <= (uint32 *)_screen.dst_ptr + _screen.width + _screen.height * _screen.pitch);
Colour *dst = (Colour *)video;
uint32 *dst = (uint32 *)video;
const uint32 *usrc = (const uint32 *)src;
uint16 *anim_line = ((uint32 *)video - (uint32 *)_screen.dst_ptr) + this->anim_buf;
for (; height > 0; height--) {
/* We need to keep those for palette animation. */
Colour *dst_pal = dst;
uint32 *dst_pal = dst;
uint16 *anim_pal = anim_line;
memcpy(dst, usrc, width * sizeof(uint32));
@@ -422,7 +422,7 @@ void Blitter_32bppAnim::PaletteAnimate(const Palette &palette)
assert(this->palette.first_dirty == PALETTE_ANIM_START || this->palette.first_dirty == 0);
const uint16 *anim = this->anim_buf;
Colour *dst = (Colour *)_screen.dst_ptr;
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--) {
+2 -2
View File
@@ -47,9 +47,9 @@ public:
/**
* Look up the colour in the current palette.
*/
inline Colour LookupColourInPalette(uint index)
inline uint32 LookupColourInPalette(uint index)
{
return this->palette.palette[index];
return this->palette.palette[index].data;
}
template <BlitterMode mode> void Draw(const Blitter::BlitterParams *bp, ZoomLevel zoom);
+3 -3
View File
@@ -19,15 +19,15 @@ void *Blitter_32bppBase::MoveTo(void *video, int x, int y)
void Blitter_32bppBase::SetPixel(void *video, int x, int y, uint8 colour)
{
*((Colour *)video + x + y * _screen.pitch) = LookupColourInPalette(colour);
*((uint32 *)video + x + y * _screen.pitch) = LookupColourInPalette(colour);
}
void Blitter_32bppBase::DrawRect(void *video, int width, int height, uint8 colour)
{
Colour colour32 = LookupColourInPalette(colour);
uint32 colour32 = LookupColourInPalette(colour);
do {
Colour *dst = (Colour *)video;
uint32 *dst = (uint32 *)video;
for (int i = width; i > 0; i--) {
*dst = colour32;
dst++;
+42 -38
View File
@@ -33,25 +33,33 @@ public:
/* virtual */ Blitter::PaletteAnimation UsePaletteAnimation();
/* virtual */ int GetBytesPerPixel() { return 4; }
/**
* Compose a colour based on RGB values.
*/
static inline uint32 ComposeColour(uint a, uint r, uint g, uint b)
{
return (((a) << 24) & 0xFF000000) | (((r) << 16) & 0x00FF0000) | (((g) << 8) & 0x0000FF00) | ((b) & 0x000000FF);
}
/**
* Look up the colour in the current palette.
*/
static inline Colour LookupColourInPalette(uint index)
static inline uint32 LookupColourInPalette(uint index)
{
return _cur_palette.palette[index];
return _cur_palette.palette[index].data;
}
/**
* Compose a colour based on RGBA values and the current pixel value.
*/
static inline Colour ComposeColourRGBANoCheck(uint r, uint g, uint b, uint a, Colour current)
static inline uint32 ComposeColourRGBANoCheck(uint r, uint g, uint b, uint a, uint32 current)
{
uint cr = current.r;
uint cg = current.g;
uint cb = current.b;
uint cr = GB(current, 16, 8);
uint cg = GB(current, 8, 8);
uint cb = GB(current, 0, 8);
/* The 256 is wrong, it should be 255, but 256 is much faster... */
return Colour(
return ComposeColour(0xFF,
((int)(r - cr) * a) / 256 + cr,
((int)(g - cg) * a) / 256 + cg,
((int)(b - cb) * a) / 256 + cb);
@@ -61,10 +69,10 @@ public:
* Compose a colour based on RGBA values and the current pixel value.
* Handles fully transparent and solid pixels in a special (faster) way.
*/
static inline Colour ComposeColourRGBA(uint r, uint g, uint b, uint a, Colour current)
static inline uint32 ComposeColourRGBA(uint r, uint g, uint b, uint a, uint32 current)
{
if (a == 0) return current;
if (a >= 255) return Colour(r, g, b);
if (a >= 255) return ComposeColour(0xFF, r, g, b);
return ComposeColourRGBANoCheck(r, g, b, a, current);
}
@@ -72,11 +80,11 @@ public:
/**
* Compose a colour based on Pixel value, alpha value, and the current pixel value.
*/
static inline Colour ComposeColourPANoCheck(Colour colour, uint a, Colour current)
static inline uint32 ComposeColourPANoCheck(uint32 colour, uint a, uint32 current)
{
uint r = colour.r;
uint g = colour.g;
uint b = colour.b;
uint r = GB(colour, 16, 8);
uint g = GB(colour, 8, 8);
uint b = GB(colour, 0, 8);
return ComposeColourRGBANoCheck(r, g, b, a, current);
}
@@ -85,13 +93,10 @@ public:
* Compose a colour based on Pixel value, alpha value, and the current pixel value.
* Handles fully transparent and solid pixels in a special (faster) way.
*/
static inline Colour ComposeColourPA(Colour colour, uint a, Colour current)
static inline uint32 ComposeColourPA(uint32 colour, uint a, uint32 current)
{
if (a == 0) return current;
if (a >= 255) {
colour.a = 255;
return colour;
}
if (a >= 255) return (colour | 0xFF000000);
return ComposeColourPANoCheck(colour, a, current);
}
@@ -103,13 +108,13 @@ public:
* @param denom denominator, makes colour darker.
* @return the new colour for the screen.
*/
static inline Colour MakeTransparent(Colour colour, uint nom, uint denom = 256)
static inline uint32 MakeTransparent(uint32 colour, uint nom, uint denom = 256)
{
uint r = colour.r;
uint g = colour.g;
uint b = colour.b;
uint r = GB(colour, 16, 8);
uint g = GB(colour, 8, 8);
uint b = GB(colour, 0, 8);
return Colour(r * nom / denom, g * nom / denom, b * nom / denom);
return ComposeColour(0xFF, r * nom / denom, g * nom / denom, b * nom / denom);
}
/**
@@ -117,46 +122,45 @@ public:
* @param colour the colour to make grey.
* @return the new colour, now grey.
*/
static inline Colour MakeGrey(Colour colour)
static inline uint32 MakeGrey(uint32 colour)
{
uint r = colour.r;
uint g = colour.g;
uint b = colour.b;
uint r = GB(colour, 16, 8);
uint g = GB(colour, 8, 8);
uint b = GB(colour, 0, 8);
/* 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. See heightmap.cpp for
* information about the formula. */
uint grey = ((r * 19595) + (g * 38470) + (b * 7471)) / 65536;
colour = ((r * 19595) + (g * 38470) + (b * 7471)) / 65536;
return Colour(grey, grey, grey);
return ComposeColour(0xFF, colour, colour, colour);
}
static const int DEFAULT_BRIGHTNESS = 128;
static const int DEFAULT_BRIGHTNESS = 64;
static inline Colour AdjustBrightness(Colour colour, uint8 brightness)
static inline uint32 AdjustBrightness(uint32 colour, uint8 brightness)
{
/* Shortcut for normal brightness */
if (brightness == DEFAULT_BRIGHTNESS) return colour;
uint16 ob = 0;
uint16 r = colour.r * brightness / DEFAULT_BRIGHTNESS;
uint16 g = colour.g * brightness / DEFAULT_BRIGHTNESS;
uint16 b = colour.b * brightness / DEFAULT_BRIGHTNESS;
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 Colour(r, g, b, colour.a);
if (ob == 0) return ComposeColour(GB(colour, 24, 8), r, g, b);
/* Reduce overbright strength */
ob /= 2;
return Colour(
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),
colour.a);
b >= 255 ? 255 : min(b + ob * (255 - b) / 256, 255));
}
};
+8 -8
View File
@@ -44,14 +44,14 @@ inline void Blitter_32bppOptimized::Draw(const Blitter::BlitterParams *bp, ZoomL
}
/* skip lines in dst */
Colour *dst = (Colour *)bp->dst + bp->top * bp->pitch + bp->left;
uint32 *dst = (uint32 *)bp->dst + bp->top * bp->pitch + bp->left;
/* store so we don't have to access it via bp everytime (compiler assumes pointer aliasing) */
const byte *remap = bp->remap;
for (int y = 0; y < bp->height; y++) {
/* next dst line begins here */
Colour *dst_ln = dst + bp->pitch;
uint32 *dst_ln = dst + bp->pitch;
/* next src line begins here */
const Colour *src_px_ln = (const Colour *)((const byte *)src_px + *(const uint32 *)src_px);
@@ -62,7 +62,7 @@ inline void Blitter_32bppOptimized::Draw(const Blitter::BlitterParams *bp, ZoomL
src_n += 2;
/* we will end this line when we reach this point */
Colour *dst_end = dst + bp->skip_left;
uint32 *dst_end = dst + bp->skip_left;
/* number of pixels with the same aplha channel class */
uint n;
@@ -215,7 +215,7 @@ Sprite *Blitter_32bppOptimized::Encode(SpriteLoader::Sprite *sprite, AllocatorPr
Colour *dst_px_orig[ZOOM_LVL_COUNT];
/* interleaved stream of 'm' channel and 'n' channel
* 'n' is number of following pixels with the same alpha channel class
* 'n' is number if following pixels with the same alpha channel class
* there are 3 classes: 0, 255, others
*
* it has to be stored in one stream so fewer registers are used -
@@ -286,10 +286,10 @@ Sprite *Blitter_32bppOptimized::Encode(SpriteLoader::Sprite *sprite, AllocatorPr
*dst_n |= rgb_max << 8;
/* Pre-convert the mapping channel to a RGB value */
Colour colour = this->AdjustBrightness(this->LookupColourInPalette(src->m), rgb_max);
dst_px->r = colour.r;
dst_px->g = colour.g;
dst_px->b = colour.b;
uint32 colour = this->AdjustBrightness(this->LookupColourInPalette(src->m), rgb_max);
dst_px->r = GB(colour, 16, 8);
dst_px->g = GB(colour, 8, 8);
dst_px->b = GB(colour, 0, 8);
} else {
dst_px->r = src->r;
dst_px->g = src->g;
+7 -7
View File
@@ -21,11 +21,11 @@ static FBlitter_32bppSimple iFBlitter_32bppSimple;
void Blitter_32bppSimple::Draw(Blitter::BlitterParams *bp, BlitterMode mode, ZoomLevel zoom)
{
const Blitter_32bppSimple::Pixel *src, *src_line;
Colour *dst, *dst_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);
dst_line = (Colour *)bp->dst + bp->top * bp->pitch + bp->left;
dst_line = (uint32 *)bp->dst + bp->top * bp->pitch + bp->left;
for (int y = 0; y < bp->height; y++) {
dst = dst_line;
@@ -66,7 +66,7 @@ void Blitter_32bppSimple::Draw(Blitter::BlitterParams *bp, BlitterMode mode, Zoo
void Blitter_32bppSimple::DrawColourMappingRect(void *dst, int width, int height, PaletteID pal)
{
Colour *udst = (Colour *)dst;
uint32 *udst = (uint32 *)dst;
if (pal == PALETTE_TO_TRANSPARENT) {
do {
@@ -122,10 +122,10 @@ Sprite *Blitter_32bppSimple::Encode(SpriteLoader::Sprite *sprite, AllocatorProc
dst[i].v = rgb_max;
/* Pre-convert the mapping channel to a RGB value */
Colour colour = this->AdjustBrightness(this->LookupColourInPalette(src->m), dst[i].v);
dst[i].r = colour.r;
dst[i].g = colour.g;
dst[i].b = colour.b;
uint colour = this->AdjustBrightness(this->LookupColourInPalette(src->m), dst[i].v);
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;
}
+2 -2
View File
@@ -118,7 +118,7 @@ static const NWidgetPart _bootstrap_query_widgets[] = {
static const WindowDesc _bootstrap_query_desc(
WDP_CENTER, 0, 0,
WC_CONFIRM_POPUP_QUERY, WC_NONE,
0,
WDF_UNCLICK_BUTTONS,
_bootstrap_query_widgets, lengthof(_bootstrap_query_widgets)
);
@@ -218,7 +218,7 @@ bool HandleBootstrap()
if (BlitterFactoryBase::GetCurrentBlitter()->GetScreenDepth() == 0) goto failure;
/* If there is no network or no freetype, then there is nothing we can do. Go straight to failure. */
#if defined(ENABLE_NETWORK) && defined(WITH_FREETYPE) && !defined(__APPLE__) && (defined(WITH_FONTCONFIG) || defined(WIN32))
#if defined(ENABLE_NETWORK) && defined(WITH_FREETYPE) && !defined(__APPLE__)
if (!_network_available) goto failure;
/* First tell the game we're bootstrapping. */
+1 -1
View File
@@ -59,7 +59,7 @@ typedef GUIList<BuildBridgeData> GUIBridgeList; ///< List of bridges, used in #B
void CcBuildBridge(const CommandCost &result, TileIndex end_tile, uint32 p1, uint32 p2)
{
if (result.Failed()) return;
if (_settings_client.sound.confirm) SndPlayTileFx(SND_27_BLACKSMITH_ANVIL, end_tile);
SndPlayTileFx(SND_27_BLACKSMITH_ANVIL, end_tile);
TransportType transport_type = Extract<TransportType, 15, 2>(p2);
+15 -20
View File
@@ -30,7 +30,6 @@
#include "engine_gui.h"
#include "cargotype.h"
#include "core/geometry_func.hpp"
#include "autoreplace_func.h"
#include "widgets/build_vehicle_widget.h"
@@ -43,7 +42,7 @@
*/
uint GetEngineListHeight(VehicleType type)
{
return max<uint>(FONT_HEIGHT_NORMAL + WD_MATRIX_TOP + WD_MATRIX_BOTTOM, GetVehicleImageCellSize(type, EIT_PURCHASE).height);
return max<uint>(FONT_HEIGHT_NORMAL + WD_MATRIX_TOP + WD_MATRIX_BOTTOM, GetVehicleHeight(type));
}
static const NWidgetPart _nested_build_vehicle_widgets[] = {
@@ -99,7 +98,7 @@ static CargoID _last_filter_criteria[] = {CF_ANY, CF_ANY, CF_ANY, CF_ANY};
*/
static int CDECL EngineNumberSorter(const EngineID *a, const EngineID *b)
{
int r = Engine::Get(*a)->list_position - Engine::Get(*b)->list_position;
int r = ListPositionOfEngine(*a) - ListPositionOfEngine(*b);
return _internal_sort_order ? -r : r;
}
@@ -516,7 +515,7 @@ static const StringID _sort_listing[][12] = {{
static bool CDECL CargoFilter(const EngineID *eid, const CargoID cid)
{
if (cid == CF_ANY) return true;
uint32 refit_mask = GetUnionOfArticulatedRefitMasks(*eid, true) & _standard_cargo_mask;
uint32 refit_mask = GetUnionOfArticulatedRefitMasks(*eid, true);
return (cid == CF_NONE ? refit_mask == 0 : HasBit(refit_mask, cid));
}
@@ -871,37 +870,34 @@ int DrawVehiclePurchaseInfo(int left, int right, int y, EngineID engine_number)
*/
void DrawEngineList(VehicleType type, int l, int r, int y, const GUIEngineList *eng_list, uint16 min, uint16 max, EngineID selected_id, bool show_count, GroupID selected_group)
{
static const int sprite_widths[] = { 60, 60, 76, 67 };
static const int sprite_y_offsets[] = { -1, -1, -2, -2 };
/* Obligatory sanity checks! */
assert((uint)type < lengthof(sprite_widths));
assert_compile(lengthof(sprite_y_offsets) == lengthof(sprite_widths));
assert(max <= eng_list->Length());
bool rtl = _current_text_dir == TD_RTL;
int step_size = GetEngineListHeight(type);
int sprite_left = GetVehicleImageCellSize(type, EIT_PURCHASE).extend_left;
int sprite_right = GetVehicleImageCellSize(type, EIT_PURCHASE).extend_right;
int sprite_width = sprite_left + sprite_right;
int sprite_width = sprite_widths[type];
int sprite_x = rtl ? r - sprite_right - 1 : l + sprite_left + 1;
int sprite_x = (rtl ? r - sprite_width / 2 : l + sprite_width / 2) - 1;
int sprite_y_offset = sprite_y_offsets[type] + step_size / 2;
Dimension replace_icon = {0, 0};
int count_width = 0;
if (show_count) {
replace_icon = GetSpriteSize(SPR_GROUP_REPLACE_ACTIVE);
SetDParamMaxDigits(0, 3);
SetDParam(0, 999);
count_width = GetStringBoundingBox(STR_TINY_BLACK_COMA).width;
}
int text_left = l + (rtl ? WD_FRAMERECT_LEFT + replace_icon.width + 8 + count_width : sprite_width + WD_FRAMETEXT_LEFT);
int text_right = r - (rtl ? sprite_width + WD_FRAMETEXT_RIGHT : WD_FRAMERECT_RIGHT + replace_icon.width + 8 + count_width);
int replace_icon_left = rtl ? l + WD_FRAMERECT_LEFT : r - WD_FRAMERECT_RIGHT - replace_icon.width;
int text_left = l + (rtl ? WD_FRAMERECT_LEFT + count_width : sprite_width);
int text_right = r - (rtl ? sprite_width : WD_FRAMERECT_RIGHT + count_width);
int count_left = l;
int count_right = rtl ? text_left : r - WD_FRAMERECT_RIGHT - replace_icon.width - 8;
int count_right = rtl ? text_left : r - WD_FRAMERECT_RIGHT;
int normal_text_y_offset = (step_size - FONT_HEIGHT_NORMAL) / 2;
int small_text_y_offset = step_size - FONT_HEIGHT_SMALL - WD_FRAMERECT_BOTTOM - 1;
int replace_icon_y_offset = (step_size - replace_icon.height) / 2 - 1;
for (; min < max; min++, y += step_size) {
const EngineID engine = (*eng_list)[min];
@@ -909,12 +905,11 @@ void DrawEngineList(VehicleType type, int l, int r, int y, const GUIEngineList *
const uint num_engines = GetGroupNumEngines(_local_company, selected_group, engine);
SetDParam(0, engine);
DrawString(text_left, text_right, y + normal_text_y_offset, STR_ENGINE_NAME, engine == selected_id ? TC_WHITE : TC_BLACK, SA_STRIP | (rtl ? SA_RIGHT : SA_LEFT));
DrawString(text_left, text_right, y + normal_text_y_offset, STR_ENGINE_NAME, engine == selected_id ? TC_WHITE : TC_BLACK);
DrawVehicleEngine(l, r, sprite_x, y + sprite_y_offset, engine, (show_count && num_engines == 0) ? PALETTE_CRASH : GetEnginePalette(engine, _local_company), EIT_PURCHASE);
if (show_count) {
SetDParam(0, num_engines);
DrawString(count_left, count_right, y + small_text_y_offset, STR_TINY_BLACK_COMA, TC_FROMSTRING, SA_RIGHT | SA_FORCE);
if (EngineHasReplacementForCompany(Company::Get(_local_company), engine, selected_group)) DrawSprite(SPR_GROUP_REPLACE_ACTIVE, num_engines == 0 ? PALETTE_CRASH : PAL_NONE, replace_icon_left, y + replace_icon_y_offset);
}
}
}
@@ -1099,7 +1094,7 @@ struct BuildVehicleWindow : Window {
this->sel_engine = sel_id;
/* make engines first, and then wagons, sorted by selected sort_criteria */
/* make engines first, and then wagons, sorted by ListPositionOfEngine() */
_internal_sort_order = false;
EngList_Sort(&this->eng_list, TrainEnginesThenWagonsSorter);
@@ -1407,7 +1402,7 @@ struct BuildVehicleWindow : Window {
static const WindowDesc _build_vehicle_desc(
WDP_AUTO, 240, 268,
WC_BUILD_VEHICLE, WC_NONE,
WDF_CONSTRUCTION,
WDF_UNCLICK_BUTTONS | WDF_CONSTRUCTION,
_nested_build_vehicle_widgets, lengthof(_nested_build_vehicle_widgets)
);
-125
View File
@@ -1,125 +0,0 @@
/* $Id$ */
/*
* This file is part of OpenTTD.
* OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
* OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* 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 cargomonitor.cpp Implementation of the cargo transport monitoring. */
#include "stdafx.h"
#include "cargomonitor.h"
#include "station_base.h"
CargoMonitorMap _cargo_pickups; ///< Map of monitored pick-ups to the amount since last query/activation.
CargoMonitorMap _cargo_deliveries; ///< Map of monitored deliveries to the amount since last query/activation.
/** Clear all pick-up cargo monitors. */
void ClearCargoPickupMonitoring()
{
_cargo_pickups.clear();
}
/** Clear all delivery cargo monitors. */
void ClearCargoDeliveryMonitoring()
{
_cargo_deliveries.clear();
}
/**
* Get and reset the amount associated with a cargo monitor.
* @param[in,out] monitor_map Monitoring map to search (and reset for the queried entry).
* @oaram monitor Cargo monitor to query/reset.
* @param keep_monitoring After returning from this call, continue monitoring.
* @return Amount collected since last query/activation for the monitored combination.
*/
static uint32 GetAmount(CargoMonitorMap &monitor_map, CargoMonitorID monitor, bool keep_monitoring)
{
CargoMonitorMap::iterator iter = monitor_map.find(monitor);
if (iter == monitor_map.end()) {
if (keep_monitoring) {
std::pair<CargoMonitorID, uint32> p(monitor, 0);
monitor_map.insert(p);
}
return 0;
} else {
uint32 result = iter->second;
iter->second = 0;
if (!keep_monitoring) monitor_map.erase(iter);
return result;
}
}
/**
* Get the amount of cargo delivered for the given cargo monitor since activation or last query.
* @param monitor Cargo monitor to query.
* @param keep_monitoring After returning from this call, continue monitoring.
* @return Amount of delivered cargo for the monitored combination.
*/
uint32 GetDeliveryAmount(CargoMonitorID monitor, bool keep_monitoring)
{
return GetAmount(_cargo_deliveries, monitor, keep_monitoring);
}
/**
* Get the amount of cargo picked up for the given cargo monitor since activation or last query.
* @param monitor Monitoring number to query.
* @param keep_monitoring After returning from this call, continue monitoring.
* @return Amount of picked up cargo for the monitored combination.
* @note Cargo pick up is counted on final delivery, to prevent users getting credit for picking up cargo without delivering it.
*/
uint32 GetPickupAmount(CargoMonitorID monitor, bool keep_monitoring)
{
return GetAmount(_cargo_pickups, monitor, keep_monitoring);
}
/**
* Cargo was delivered to its final destination, update the pickup and delivery maps.
* @param cargo_type type of cargo.
* @param company company delivering the cargo.
* @param amount Amount of cargo delivered.
* @param src_type type of \a src.
* @param src index of source.
* @param st station where the cargo is delivered to.
*/
void AddCargoDelivery(CargoID cargo_type, CompanyID company, uint32 amount, SourceType src_type, SourceID src, const Station *st)
{
if (amount == 0) return;
if (src != INVALID_SOURCE) {
/* Handle pickup update. */
switch (src_type) {
case ST_INDUSTRY: {
CargoMonitorID num = EncodeCargoIndustryMonitor(company, cargo_type, src);
CargoMonitorMap::iterator iter = _cargo_pickups.find(num);
if (iter != _cargo_pickups.end()) iter->second += amount;
break;
}
case ST_TOWN: {
CargoMonitorID num = EncodeCargoTownMonitor(company, cargo_type, src);
CargoMonitorMap::iterator iter = _cargo_pickups.find(num);
if (iter != _cargo_pickups.end()) iter->second += amount;
break;
}
default: break;
}
}
/* Handle delivery.
* Note that delivery in the right area is sufficient to prevent trouble with neighbouring industries or houses. */
/* Town delivery. */
CargoMonitorID num = EncodeCargoTownMonitor(company, cargo_type, st->town->index);
CargoMonitorMap::iterator iter = _cargo_deliveries.find(num);
if (iter != _cargo_deliveries.end()) iter->second += amount;
/* Industry delivery. */
for (const Industry * const *ip = st->industries_near.Begin(); ip != st->industries_near.End(); ip++) {
CargoMonitorID num = EncodeCargoIndustryMonitor(company, cargo_type, (*ip)->index);
CargoMonitorMap::iterator iter = _cargo_deliveries.find(num);
if (iter != _cargo_deliveries.end()) iter->second += amount;
}
}
-148
View File
@@ -1,148 +0,0 @@
/* $Id$ */
/*
* This file is part of OpenTTD.
* OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
* OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* 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 cargomonitor.h Cargo transport monitoring declarations. */
#ifndef CARGOMONITOR_H
#define CARGOMONITOR_H
#include "cargo_type.h"
#include "company_func.h"
#include "industry.h"
#include "town.h"
#include <map>
struct Station;
/**
* Unique number for a company / cargo type / (town or industry).
* Encoding is as follows:
* - bits 0-15 town or industry number
* - bit 16 is set if it is an industry number (else it is a town number).
* - bits 19-23 Cargo type.
* - bits 24-31 %Company number.
*/
typedef uint32 CargoMonitorID; ///< Type of the cargo monitor number.
/** Map type for storing and updating active cargo monitor numbers and their amounts. */
typedef std::map<CargoMonitorID, uint32> CargoMonitorMap;
extern CargoMonitorMap _cargo_pickups;
extern CargoMonitorMap _cargo_deliveries;
/** Constants for encoding and extracting cargo monitors. */
enum CargoCompanyBits {
CCB_TOWN_IND_NUMBER_START = 0, ///< Start bit of the town or industry number.
CCB_TOWN_IND_NUMBER_LENGTH = 16, ///< Number of bits of the town or industry number.
CCB_IS_INDUSTRY_BIT = 16, ///< Bit indicating the town/industry number is an industry.
CCB_IS_INDUSTRY_BIT_VALUE = 1ul << CCB_IS_INDUSTRY_BIT, ///< Value of the #CCB_IS_INDUSTRY_BIT bit.
CCB_CARGO_TYPE_START = 19, ///< Start bit of the cargo type field.
CCB_CARGO_TYPE_LENGTH = 5, ///< Number of bits of the cargo type field.
CCB_COMPANY_START = 24, ///< Start bit of the company field.
CCB_COMPANY_LENGTH = 8, ///< Number of bits of the company field.
};
/**
* Encode a cargo monitor for pickup or delivery at an industry.
* @param company Company performing the transport.
* @param ctype Cargo type being transported.
* @param ind %Industry providing or accepting the cargo.
* @return The encoded cargo/company/industry number.
*/
static inline CargoMonitorID EncodeCargoIndustryMonitor(CompanyID company, CargoID ctype, IndustryID ind)
{
assert(ctype < (1 << CCB_CARGO_TYPE_LENGTH));
uint32 ret = 0;
SB(ret, CCB_TOWN_IND_NUMBER_START, CCB_TOWN_IND_NUMBER_LENGTH, ind);
SetBit(ret, CCB_IS_INDUSTRY_BIT);
SB(ret, CCB_CARGO_TYPE_START, CCB_CARGO_TYPE_LENGTH, ctype);
SB(ret, CCB_COMPANY_START, CCB_COMPANY_LENGTH, company);
return ret;
}
/**
* Encode a cargo monitoring number for pickup or delivery at a town.
* @param company %Company performing the transport.
* @param ctype Cargo type being transported.
* @param town %Town providing or accepting the cargo.
* @return The encoded cargo/company/town number.
*/
static inline CargoMonitorID EncodeCargoTownMonitor(CompanyID company, CargoID ctype, TownID town)
{
assert(ctype < (1 << CCB_CARGO_TYPE_LENGTH));
uint32 ret = 0;
SB(ret, CCB_TOWN_IND_NUMBER_START, CCB_TOWN_IND_NUMBER_LENGTH, town);
SB(ret, CCB_CARGO_TYPE_START, CCB_CARGO_TYPE_LENGTH, ctype);
SB(ret, CCB_COMPANY_START, CCB_COMPANY_LENGTH, company);
return ret;
}
/**
* Extract the company from the cargo monitor.
* @param num Cargo monitoring number to decode.
* @return The extracted company id.
*/
static inline CompanyID DecodeMonitorCompany(CargoMonitorID num)
{
return static_cast<CompanyID>(GB(num, CCB_COMPANY_START, CCB_COMPANY_LENGTH));
}
/**
* Extract the cargo type from the cargo monitor.
* @param num Cargo monitoring number to decode.
* @return The extracted cargo type.
*/
static inline CargoID DecodeMonitorCargoType(CargoMonitorID num)
{
return GB(num, CCB_CARGO_TYPE_START, CCB_CARGO_TYPE_LENGTH);
}
/**
* Does the cargo number monitor an industry or a town?
* @param num Cargo monitoring number to decode.
* @return true if monitoring an industry, false if monitoring a town.
*/
static inline bool MonitorMonitorsIndustry(CargoMonitorID num)
{
return HasBit(num, CCB_IS_INDUSTRY_BIT);
}
/**
* Extract the industry number from the cargo monitor.
* @param num Cargo monitoring number to decode.
* @return The extracted industry id, or #INVALID_INDUSTRY if the number does not monitor an industry.
*/
static inline IndustryID DecodeMonitorIndustry(CargoMonitorID num)
{
if (!MonitorMonitorsIndustry(num)) return INVALID_INDUSTRY;
return GB(num, CCB_TOWN_IND_NUMBER_START, CCB_TOWN_IND_NUMBER_LENGTH);
}
/**
* Extract the town number from the cargo monitor.
* @param num Cargo monitoring number to decode.
* @return The extracted town id, or #INVALID_TOWN if the number does not monitor a town.
*/
static inline TownID DecodeMonitorTown(CargoMonitorID num)
{
if (MonitorMonitorsIndustry(num)) return INVALID_TOWN;
return GB(num, CCB_TOWN_IND_NUMBER_START, CCB_TOWN_IND_NUMBER_LENGTH);
}
void ClearCargoPickupMonitoring();
void ClearCargoDeliveryMonitoring();
uint32 GetDeliveryAmount(CargoMonitorID monitor, bool keep_monitoring);
uint32 GetPickupAmount(CargoMonitorID monitor, bool keep_monitoring);
void AddCargoDelivery(CargoID cargo_type, CompanyID company, uint32 amount, SourceType src_type, SourceID src, const Station *st);
#endif /* CARGOMONITOR_H */
+1 -9
View File
@@ -23,16 +23,11 @@
CargoSpec CargoSpec::array[NUM_CARGO];
/**
* Bitmask of cargo types available. This includes phony cargoes like regearing cargoes.
* Bitmask of cargo types available.
* Initialized during a call to #SetupCargoForClimate.
*/
uint32 _cargo_mask;
/**
* Bitmask of real cargo types available. Phony cargoes like regearing cargoes are excluded.
*/
uint32 _standard_cargo_mask;
/**
* Set up the default cargo types for the given landscape type.
* @param l Landscape
@@ -181,13 +176,10 @@ void InitializeSortedCargoSpecs()
/* Sort cargo specifications by cargo class and name. */
QSortT(_sorted_cargo_specs, _sorted_cargo_specs_size, &CargoSpecClassSorter);
_standard_cargo_mask = 0;
_sorted_standard_cargo_specs_size = 0;
FOR_ALL_SORTED_CARGOSPECS(cargo) {
if (cargo->classes & CC_SPECIAL) break;
_sorted_standard_cargo_specs_size++;
SetBit(_standard_cargo_mask, cargo->Index());
}
}
-11
View File
@@ -130,7 +130,6 @@ private:
};
extern uint32 _cargo_mask;
extern uint32 _standard_cargo_mask;
void SetupCargoForClimate(LandscapeID l);
CargoID GetCargoIDByLabel(CargoLabel cl);
@@ -158,18 +157,8 @@ static inline bool IsCargoInClass(CargoID c, CargoClass cc)
#define FOR_EACH_SET_CARGO_ID(var, cargo_bits) FOR_EACH_SET_BIT_EX(CargoID, var, uint, cargo_bits)
/**
* Loop header for iterating over cargoes, sorted by name. This includes phony cargoes like regearing cargoes.
* @param var Reference getting the cargospec.
* @see CargoSpec
*/
#define FOR_ALL_SORTED_CARGOSPECS(var) for (uint8 index = 0; var = _sorted_cargo_specs[index], index < _sorted_cargo_specs_size; index++)
/**
* Loop header for iterating over 'real' cargoes, sorted by name. Phony cargoes like regearing cargoes are skipped.
* @param var Reference getting the cargospec.
* @see CargoSpec
*/
#define FOR_ALL_SORTED_STANDARD_CARGOSPECS(var) for (uint8 index = 0; var = _sorted_cargo_specs[index], index < _sorted_standard_cargo_specs_size; index++)
#endif /* CARGOTYPE_H */
+10 -10
View File
@@ -22,7 +22,7 @@
#include "strings_func.h"
#include "window_func.h"
#include "rail_gui.h"
#include "settings_gui.h"
#include "gui.h"
#include "company_gui.h"
#include "widgets/cheat_widget.h"
@@ -184,9 +184,9 @@ struct CheatWindow : Window {
bool rtl = _current_text_dir == TD_RTL;
uint box_left = rtl ? r.right - 12 : r.left + 5;
uint button_left = rtl ? r.right - 20 - SETTING_BUTTON_WIDTH : r.left + 20;
uint text_left = r.left + (rtl ? WD_FRAMERECT_LEFT : 30 + SETTING_BUTTON_WIDTH);
uint text_right = r.right - (rtl ? 30 + SETTING_BUTTON_WIDTH : WD_FRAMERECT_RIGHT);
uint button_left = rtl ? r.right - 40 : r.left + 20;
uint text_left = r.left + (rtl ? WD_FRAMERECT_LEFT: 50);
uint text_right = r.right - (rtl ? 50 : WD_FRAMERECT_RIGHT);
for (int i = 0; i != lengthof(_cheats_ui); i++) {
const CheatEntry *ce = &_cheats_ui[i];
@@ -259,7 +259,7 @@ struct CheatWindow : Window {
/* Draw coloured flag for change company cheat */
case STR_CHEAT_CHANGE_COMPANY:
SetDParamMaxValue(0, MAX_COMPANIES);
SetDParam(0, 15);
width = max(width, GetStringBoundingBox(ce->str).width + 10 + 10);
break;
@@ -291,7 +291,7 @@ struct CheatWindow : Window {
int value = (int32)ReadValue(ce->variable, ce->type);
int oldvalue = value;
if (btn == CHT_CHANGE_DATE && x >= 20 + SETTING_BUTTON_WIDTH) {
if (btn == CHT_CHANGE_DATE && x >= 40) {
/* Click at the date text directly. */
SetDParam(0, value);
ShowQueryString(STR_JUST_INT, STR_CHEAT_CHANGE_DATE_QUERY_CAPT, 8, this, CS_NUMERAL, QSF_ACCEPT_UNCHANGED);
@@ -299,7 +299,7 @@ struct CheatWindow : Window {
}
/* Not clicking a button? */
if (!IsInsideMM(x, 20, 20 + SETTING_BUTTON_WIDTH)) return;
if (!IsInsideMM(x, 20, 40)) return;
*ce->been_used = true;
@@ -311,10 +311,10 @@ struct CheatWindow : Window {
default:
/* Take whatever the function returns */
value = ce->proc(value + ((x >= 20 + SETTING_BUTTON_WIDTH / 2) ? 1 : -1), (x >= 20 + SETTING_BUTTON_WIDTH / 2) ? 1 : -1);
value = ce->proc(value + ((x >= 30) ? 1 : -1), (x >= 30) ? 1 : -1);
/* The first cheat (money), doesn't return a different value. */
if (value != oldvalue || btn == CHT_MONEY) this->clicked = btn * 2 + 1 + ((x >= 20 + SETTING_BUTTON_WIDTH / 2) != rtl ? 1 : 0);
if (value != oldvalue || btn == CHT_MONEY) this->clicked = btn * 2 + 1 + ((x >= 30) != rtl ? 1 : 0);
break;
}
@@ -351,7 +351,7 @@ struct CheatWindow : Window {
static const WindowDesc _cheats_desc(
WDP_AUTO, 0, 0,
WC_CHEATS, WC_NONE,
0,
WDF_UNCLICK_BUTTONS,
_nested_cheat_widgets, lengthof(_nested_cheat_widgets)
);
+1 -5
View File
@@ -181,8 +181,6 @@ CommandProc CmdSetVehicleOnTime;
CommandProc CmdAutofillTimetable;
CommandProc CmdSetTimetableStart;
CommandProc CmdOpenCloseAirport;
#define DEF_CMD(proc, flags, type) {proc, #proc, (CommandFlags)flags, type}
/**
@@ -242,7 +240,7 @@ static const Command _command_proc_table[] = {
DEF_CMD(CmdChangeServiceInt, 0, CMDT_VEHICLE_MANAGEMENT ), // CMD_CHANGE_SERVICE_INT
DEF_CMD(CmdBuildIndustry, CMD_DEITY, CMDT_LANDSCAPE_CONSTRUCTION), // CMD_BUILD_INDUSTRY
DEF_CMD(CmdBuildIndustry, 0, CMDT_LANDSCAPE_CONSTRUCTION), // CMD_BUILD_INDUSTRY
DEF_CMD(CmdSetCompanyManagerFace, 0, CMDT_OTHER_MANAGEMENT ), // CMD_SET_COMPANY_MANAGER_FACE
DEF_CMD(CmdSetCompanyColour, 0, CMDT_OTHER_MANAGEMENT ), // CMD_SET_COMPANY_COLOUR
@@ -324,8 +322,6 @@ static const Command _command_proc_table[] = {
DEF_CMD(CmdSetVehicleOnTime, 0, CMDT_ROUTE_MANAGEMENT ), // CMD_SET_VEHICLE_ON_TIME
DEF_CMD(CmdAutofillTimetable, 0, CMDT_ROUTE_MANAGEMENT ), // CMD_AUTOFILL_TIMETABLE
DEF_CMD(CmdSetTimetableStart, 0, CMDT_ROUTE_MANAGEMENT ), // CMD_SET_TIMETABLE_START
DEF_CMD(CmdOpenCloseAirport, 0, CMDT_ROUTE_MANAGEMENT ), // CMD_OPEN_CLOSE_AIRPORT
};
/*!
-1
View File
@@ -91,7 +91,6 @@ CommandCallback CcGame;
/* group_gui.cpp */
CommandCallback CcCreateGroup;
CommandCallback CcAddVehicleNewGroup;
/* industry_gui.cpp */
CommandCallback CcBuildIndustry;
-2
View File
@@ -302,8 +302,6 @@ enum Commands {
CMD_AUTOFILL_TIMETABLE, ///< autofill the timetable
CMD_SET_TIMETABLE_START, ///< set the date that a timetable should start
CMD_OPEN_CLOSE_AIRPORT, ///< open/close an airport to incoming aircraft
CMD_END, ///< Must ALWAYS be on the end of this list!! (period)
};
+1 -2
View File
@@ -78,14 +78,13 @@ struct CompanyProperties {
Year inaugurated_year; ///< Year of starting the company.
byte months_of_bankruptcy; ///< Number of months that the company is unable to pay its debts
byte quarters_of_bankruptcy; ///< Number of quarters (a quarter is 3 months) that the company has a negative balance.
CompanyMask bankrupt_asked; ///< which companies were asked about buying it?
int16 bankrupt_timeout; ///< If bigger than \c 0, amount of time to wait for an answer on an offer to buy this company.
Money bankrupt_value;
uint32 terraform_limit; ///< Amount of tileheights we can (still) terraform (times 65536).
uint32 clear_limit; ///< Amount of tiles we can (still) clear (times 65536).
uint32 tree_limit; ///< Amount of trees we can (still) plant (times 65536).
/**
* If \c true, the company is (also) controlled by the computer (a NoAI program).
+4 -6
View File
@@ -59,7 +59,6 @@ Company::Company(uint16 name_1, bool is_ai)
this->is_ai = is_ai;
this->terraform_limit = _settings_game.construction.terraform_frame_burst << 16;
this->clear_limit = _settings_game.construction.clear_frame_burst << 16;
this->tree_limit = _settings_game.construction.tree_frame_burst << 16;
for (uint j = 0; j < 4; j++) this->share_owners[j] = COMPANY_SPECTATOR;
InvalidateWindowData(WC_PERFORMANCE_DETAIL, 0, INVALID_COMPANY);
@@ -261,7 +260,6 @@ void UpdateLandscapingLimits()
FOR_ALL_COMPANIES(c) {
c->terraform_limit = min(c->terraform_limit + _settings_game.construction.terraform_per_64k_frames, (uint32)_settings_game.construction.terraform_frame_burst << 16);
c->clear_limit = min(c->clear_limit + _settings_game.construction.clear_per_64k_frames, (uint32)_settings_game.construction.clear_frame_burst << 16);
c->tree_limit = min(c->tree_limit + _settings_game.construction.tree_per_64k_frames, (uint32)_settings_game.construction.tree_frame_burst << 16);
}
}
@@ -375,7 +373,7 @@ set_name:;
SetDParam(1, STR_NEWS_COMPANY_LAUNCH_DESCRIPTION);
SetDParamStr(2, cni->company_name);
SetDParam(3, t->index);
AddNewsItem(STR_MESSAGE_NEWS_FORMAT, NT_COMPANY_INFO, NF_COMPANY, NR_TILE, c->last_build_coordinate, NR_NONE, UINT32_MAX, cni);
AddNewsItem(STR_MESSAGE_NEWS_FORMAT, NS_COMPANY_NEW, NR_TILE, c->last_build_coordinate, NR_NONE, UINT32_MAX, cni);
}
return;
}
@@ -725,9 +723,9 @@ void CompaniesYearlyLoop()
ShowCompanyFinances(_local_company);
c = Company::Get(_local_company);
if (c->num_valid_stat_ent > 5 && c->old_economy[0].performance_history < c->old_economy[4].performance_history) {
if (_settings_client.sound.new_year) SndPlayFx(SND_01_BAD_YEAR);
SndPlayFx(SND_01_BAD_YEAR);
} else {
if (_settings_client.sound.new_year) SndPlayFx(SND_00_GOOD_YEAR);
SndPlayFx(SND_00_GOOD_YEAR);
}
}
}
@@ -921,7 +919,7 @@ CommandCost CmdCompanyCtrl(TileIndex tile, DoCommandFlag flags, uint32 p1, uint3
SetDParam(0, STR_NEWS_COMPANY_BANKRUPT_TITLE);
SetDParam(1, STR_NEWS_COMPANY_BANKRUPT_DESCRIPTION);
SetDParamStr(2, cni->company_name);
AddCompanyNewsItem(STR_MESSAGE_NEWS_FORMAT, cni);
AddCompanyNewsItem(STR_MESSAGE_NEWS_FORMAT, NS_COMPANY_BANKRUPT, cni);
/* Remove the company */
ChangeOwnershipOfCompanyItems(c->index, INVALID_OWNER);
+17 -14
View File
@@ -319,7 +319,7 @@ struct CompanyFinancesWindow : Window {
case WID_CF_BALANCE_VALUE:
case WID_CF_LOAN_VALUE:
case WID_CF_TOTAL_VALUE:
SetDParamMaxValue(0, CompanyFinancesWindow::max_money);
SetDParam(0, CompanyFinancesWindow::max_money);
size->width = max(GetStringBoundingBox(STR_FINANCES_NEGATIVE_INCOME).width, GetStringBoundingBox(STR_FINANCES_POSITIVE_INCOME).width) + padding.width;
break;
@@ -466,7 +466,7 @@ Money CompanyFinancesWindow::max_money = INT32_MAX;
static const WindowDesc _company_finances_desc(
WDP_AUTO, 0, 0,
WC_FINANCES, WC_NONE,
0,
WDF_UNCLICK_BUTTONS,
_nested_company_finances_widgets, lengthof(_nested_company_finances_widgets)
);
@@ -781,8 +781,7 @@ public:
virtual void OnDropdownSelect(int widget, int index)
{
for (LiveryScheme scheme = LS_DEFAULT; scheme < LS_END; scheme++) {
/* Changed colour for the selected scheme, or all visible schemes if CTRL is pressed. */
if (HasBit(this->sel, scheme) || (_ctrl_pressed && _livery_class[scheme] == this->livery_class && HasBit(_loaded_newgrf_features.used_liveries, scheme))) {
if (HasBit(this->sel, scheme)) {
DoCommandP(0, scheme | (widget == WID_SCL_PRI_COL_DROPDOWN ? 0 : 256), index, CMD_SET_COMPANY_COLOUR);
}
}
@@ -1281,7 +1280,11 @@ public:
break;
case WID_SCMF_TIE_EARRING:
this->DrawFaceStringLabel(WID_SCMF_TIE_EARRING, GetCompanyManagerFaceBits(this->face, CMFV_TIE_EARRING, this->ge), false);
if (this->is_female) { // Only for female faces
this->DrawFaceStringLabel(WID_SCMF_TIE_EARRING, GetCompanyManagerFaceBits(this->face, CMFV_TIE_EARRING, this->ge), false);
} else { // Only for male faces
this->DrawFaceStringLabel(WID_SCMF_TIE_EARRING, GetCompanyManagerFaceBits(this->face, CMFV_TIE_EARRING, this->ge), false);
}
break;
case WID_SCMF_LIPS_MOUSTACHE:
@@ -1482,7 +1485,7 @@ const StringID SelectCompanyManagerFaceWindow::PART_TEXTS[] = {
static const WindowDesc _select_company_manager_face_desc(
WDP_AUTO, 0, 0,
WC_COMPANY_MANAGER_FACE, WC_NONE,
WDF_CONSTRUCTION,
WDF_UNCLICK_BUTTONS | WDF_CONSTRUCTION,
_nested_select_company_manager_face_widgets, lengthof(_nested_select_company_manager_face_widgets)
);
@@ -1691,12 +1694,12 @@ struct CompanyInfrastructureWindow : Window
max_val = max(max_val, c->infrastructure.airport);
max_cost = max(max_cost, AirportMaintenanceCost(c->index));
SetDParamMaxValue(0, max_val);
SetDParamMaxValue(1, max_cost * 12); // Convert to per year
SetDParam(0, max_val);
SetDParam(1, max_cost * 12); // Convert to per year
size->width = max(size->width, GetStringBoundingBox(_settings_game.economy.infrastructure_maintenance ? STR_COMPANY_INFRASTRUCTURE_VIEW_COST : STR_WHITE_COMMA).width + 20); // Reserve some wiggle room.
if (_settings_game.economy.infrastructure_maintenance) {
SetDParamMaxValue(0, this->GetTotalMaintenanceCost() * 12); // Convert to per year
SetDParam(0, this->GetTotalMaintenanceCost() * 12); // Convert to per year
this->total_width = GetStringBoundingBox(STR_COMPANY_INFRASTRUCTURE_VIEW_TOTAL).width + 20;
size->width = max(size->width, this->total_width);
}
@@ -1836,7 +1839,7 @@ struct CompanyInfrastructureWindow : Window
static const WindowDesc _company_infrastructure_desc(
WDP_AUTO, 0, 0,
WC_COMPANY_INFRASTRUCTURE, WC_NONE,
0,
WDF_UNCLICK_BUTTONS,
_nested_company_infrastructure_widgets, lengthof(_nested_company_infrastructure_widgets)
);
@@ -2095,14 +2098,14 @@ struct CompanyWindow : Window
break;
case WID_C_DESC_VEHICLE_COUNTS:
SetDParamMaxValue(0, 5000); // Maximum number of vehicles
SetDParam(0, 5000); // Maximum number of vehicles
for (uint i = 0; i < lengthof(_company_view_vehicle_count_strings); i++) {
size->width = max(size->width, GetStringBoundingBox(_company_view_vehicle_count_strings[i]).width);
}
break;
case WID_C_DESC_INFRASTRUCTURE_COUNTS:
SetDParamMaxValue(0, UINT_MAX);
SetDParam(0, UINT_MAX);
size->width = max(size->width, GetStringBoundingBox(STR_COMPANY_VIEW_INFRASTRUCTURE_RAIL).width);
size->width = max(size->width, GetStringBoundingBox(STR_COMPANY_VIEW_INFRASTRUCTURE_ROAD).width);
size->width = max(size->width, GetStringBoundingBox(STR_COMPANY_VIEW_INFRASTRUCTURE_WATER).width);
@@ -2115,7 +2118,7 @@ struct CompanyWindow : Window
const Company *c2;
FOR_ALL_COMPANIES(c2) {
SetDParamMaxValue(0, 75);
SetDParam(0, 25);
SetDParam(1, c2->index);
size->width = max(size->width, GetStringBoundingBox(STR_COMPANY_VIEW_SHARES_OWNED_BY).width);
@@ -2401,7 +2404,7 @@ struct CompanyWindow : Window
static const WindowDesc _company_desc(
WDP_AUTO, 0, 0,
WC_COMPANY, WC_NONE,
0,
WDF_UNCLICK_BUTTONS,
_nested_company_widgets, lengthof(_nested_company_widgets)
);
+39 -46
View File
@@ -38,7 +38,10 @@
#include "console_func.h"
#include "engine_base.h"
#include "game/game.hpp"
#include "table/strings.h"
#ifdef ENABLE_NETWORK
#include "table/strings.h"
#endif /* ENABLE_NETWORK */
/* scriptfile handling */
static bool _script_running; ///< Script is running (used to abort execution when #ConReturn is encountered).
@@ -1528,45 +1531,6 @@ DEF_CONSOLE_CMD(ConListAliases)
return true;
}
DEF_CONSOLE_CMD(ConCompanies)
{
if (argc == 0) {
IConsoleHelp("List the details of all companies in the game. Usage 'companies'");
return true;
}
Company *c;
FOR_ALL_COMPANIES(c) {
/* Grab the company name */
char company_name[512];
SetDParam(0, c->index);
GetString(company_name, STR_COMPANY_NAME, lastof(company_name));
const char *password_state = "";
if (c->is_ai) {
password_state = "AI";
}
#ifdef ENABLE_NETWORK
else if (_network_server) {
password_state = StrEmpty(_network_company_states[c->index].password) ? "unprotected" : "protected";
}
#endif
char colour[512];
GetString(colour, STR_COLOUR_DARK_BLUE + _company_colours[c->index], lastof(colour));
IConsolePrintF(CC_INFO, "#:%d(%s) Company Name: '%s' Year Founded: %d Money: " OTTD_PRINTF64 " Loan: " OTTD_PRINTF64 " Value: " OTTD_PRINTF64 " (T:%d, R:%d, P:%d, S:%d) %s",
c->index + 1, colour, company_name,
c->inaugurated_year, (int64)c->money, (int64)c->current_loan, (int64)CalculateCompanyValue(c),
c->group_all[VEH_TRAIN].num_vehicle,
c->group_all[VEH_ROAD].num_vehicle,
c->group_all[VEH_AIRCRAFT].num_vehicle,
c->group_all[VEH_SHIP].num_vehicle,
password_state);
}
return true;
}
#ifdef ENABLE_NETWORK
DEF_CONSOLE_CMD(ConSay)
@@ -1588,6 +1552,38 @@ DEF_CONSOLE_CMD(ConSay)
return true;
}
DEF_CONSOLE_CMD(ConCompanies)
{
if (argc == 0) {
IConsoleHelp("List the in-game details of all clients connected to the server. Usage 'companies'");
return true;
}
NetworkCompanyStats company_stats[MAX_COMPANIES];
NetworkPopulateCompanyStats(company_stats);
Company *c;
FOR_ALL_COMPANIES(c) {
/* Grab the company name */
char company_name[NETWORK_COMPANY_NAME_LENGTH];
SetDParam(0, c->index);
GetString(company_name, STR_COMPANY_NAME, lastof(company_name));
char buffer[512];
const NetworkCompanyStats *stats = &company_stats[c->index];
GetString(buffer, STR_COLOUR_DARK_BLUE + _company_colours[c->index], lastof(buffer));
IConsolePrintF(CC_INFO, "#:%d(%s) Company Name: '%s' Year Founded: %d Money: " OTTD_PRINTF64 " Loan: " OTTD_PRINTF64 " Value: " OTTD_PRINTF64 " (T:%d, R:%d, P:%d, S:%d) %sprotected",
c->index + 1, buffer, company_name, c->inaugurated_year, (int64)c->money, (int64)c->current_loan, (int64)CalculateCompanyValue(c),
/* trains */ stats->num_vehicle[0],
/* lorry + bus */ stats->num_vehicle[1] + stats->num_vehicle[2],
/* planes */ stats->num_vehicle[3],
/* ships */ stats->num_vehicle[4],
/* protected */ StrEmpty(_network_company_states[c->index].password) ? "un" : "");
}
return true;
}
DEF_CONSOLE_CMD(ConSayCompany)
{
if (argc == 0) {
@@ -1780,9 +1776,7 @@ DEF_CONSOLE_CMD(ConContent)
static const TextColour state_to_colour[] = { CC_COMMAND, CC_INFO, CC_INFO, CC_WHITE, CC_ERROR };
const ContentInfo *ci = *iter;
char buf[sizeof(ci->md5sum) * 2 + 1];
md5sumToString(buf, lastof(buf), ci->md5sum);
IConsolePrintF(state_to_colour[ci->state], "%d, %s, %s, %s, %08X, %s", ci->id, types[ci->type - 1], states[ci->state], ci->name, ci->unique_id, buf);
IConsolePrintF(state_to_colour[ci->state], "%d, %s, %s, %s", ci->id, types[ci->type - 1], states[ci->state], ci->name);
}
return true;
}
@@ -1943,9 +1937,6 @@ void IConsoleStdLibRegister()
IConsoleCmdRegister("list_game_libs", ConListGameLibs);
IConsoleCmdRegister("rescan_game", ConRescanGame);
IConsoleCmdRegister("companies", ConCompanies);
IConsoleAliasRegister("players", "companies");
/* networking functions */
#ifdef ENABLE_NETWORK
/* Content downloading is only available with ZLIB */
@@ -1955,6 +1946,8 @@ void IConsoleStdLibRegister()
/*** Networking commands ***/
IConsoleCmdRegister("say", ConSay, ConHookNeedNetwork);
IConsoleCmdRegister("companies", ConCompanies, ConHookServerOnly);
IConsoleAliasRegister("players", "companies");
IConsoleCmdRegister("say_company", ConSayCompany, ConHookNeedNetwork);
IConsoleAliasRegister("say_player", "say_company %+");
IConsoleCmdRegister("say_client", ConSayClient, ConHookNeedNetwork);
+16 -10
View File
@@ -10,7 +10,7 @@
/** @file console_gui.cpp Handling the GUI of the in-game console. */
#include "stdafx.h"
#include "textbuf_type.h"
#include "textbuf_gui.h"
#include "window_gui.h"
#include "console_gui.h"
#include "console_internal.h"
@@ -126,7 +126,7 @@ struct IConsoleLine {
/* ** main console cmd buffer ** */
static Textbuf _iconsole_cmdline(ICON_CMDLN_SIZE);
static Textbuf _iconsole_cmdline;
static char *_iconsole_history[ICON_HISTORY_SIZE];
static int _iconsole_historypos;
IConsoleModes _iconsole_mode;
@@ -233,7 +233,7 @@ struct IConsoleWindow : Window
virtual void OnMouseLoop()
{
if (_iconsole_cmdline.HandleCaret()) this->SetDirty();
if (HandleCaret(&_iconsole_cmdline)) this->SetDirty();
}
virtual EventState OnKeyPress(uint16 key, uint16 keycode)
@@ -294,7 +294,7 @@ struct IConsoleWindow : Window
case (WKC_META | 'V'):
#endif
case (WKC_CTRL | 'V'):
if (_iconsole_cmdline.InsertClipboard()) {
if (InsertTextBufferClipboard(&_iconsole_cmdline)) {
IConsoleResetHistoryPos();
this->SetDirty();
}
@@ -308,19 +308,19 @@ struct IConsoleWindow : Window
case (WKC_META | 'U'):
#endif
case (WKC_CTRL | 'U'):
_iconsole_cmdline.DeleteAll();
DeleteTextBufferAll(&_iconsole_cmdline);
this->SetDirty();
break;
case WKC_BACKSPACE: case WKC_DELETE:
if (_iconsole_cmdline.DeleteChar(keycode)) {
if (DeleteTextBufferChar(&_iconsole_cmdline, keycode)) {
IConsoleResetHistoryPos();
this->SetDirty();
}
break;
case WKC_LEFT: case WKC_RIGHT: case WKC_END: case WKC_HOME:
if (_iconsole_cmdline.MovePos(keycode)) {
if (MoveTextBufferPos(&_iconsole_cmdline, keycode)) {
IConsoleResetHistoryPos();
this->SetDirty();
}
@@ -329,7 +329,7 @@ struct IConsoleWindow : Window
default:
if (IsValidChar(key, CS_ALPHANUMERAL)) {
IConsoleWindow::scroll = 0;
_iconsole_cmdline.InsertChar(key);
InsertTextBufferChar(&_iconsole_cmdline, key);
IConsoleResetHistoryPos();
this->SetDirty();
} else {
@@ -356,6 +356,10 @@ void IConsoleGUIInit()
IConsoleLine::Reset();
memset(_iconsole_history, 0, sizeof(_iconsole_history));
_iconsole_cmdline.buf = CallocT<char>(ICON_CMDLN_SIZE); // create buffer and zero it
_iconsole_cmdline.max_bytes = ICON_CMDLN_SIZE;
_iconsole_cmdline.max_chars = ICON_CMDLN_SIZE;
IConsolePrintF(CC_WARNING, "OpenTTD Game Console Revision 7 - %s", _openttd_revision);
IConsolePrint(CC_WHITE, "------------------------------------");
IConsolePrint(CC_WHITE, "use \"help\" for more information");
@@ -370,6 +374,7 @@ void IConsoleClearBuffer()
void IConsoleGUIFree()
{
free(_iconsole_cmdline.buf);
IConsoleClearBuffer();
}
@@ -451,10 +456,11 @@ static void IConsoleHistoryNavigate(int direction)
if (direction > 0 && _iconsole_history[_iconsole_historypos] == NULL) _iconsole_historypos--;
if (_iconsole_historypos == -1) {
_iconsole_cmdline.DeleteAll();
*_iconsole_cmdline.buf = '\0';
} else {
_iconsole_cmdline.Assign(_iconsole_history[_iconsole_historypos]);
ttd_strlcpy(_iconsole_cmdline.buf, _iconsole_history[_iconsole_historypos], _iconsole_cmdline.max_bytes);
}
UpdateTextBufferSize(&_iconsole_cmdline);
}
/**
+20 -20
View File
@@ -13,18 +13,18 @@
#define BITMATH_FUNC_HPP
/**
* Fetch \a n bits from \a x, started at bit \a s.
* Fetch n bits from x, started at bit s.
*
* This function can be used to fetch \a n bits from the value \a x. The
* \a s value set the start position to read. The start position is
* count from the LSB and starts at \c 0. The result starts at a
* This function can be used to fetch n bits from the value x. The
* s value set the startposition to read. The startposition is
* count from the LSB and starts at 0. The result starts at a
* LSB, as this isn't just an and-bitmask but also some
* bit-shifting operations. GB(0xFF, 2, 1) will so
* return 0x01 (0000 0001) instead of
* 0x04 (0000 0100).
*
* @param x The value to read some bits.
* @param s The start position to read some bits.
* @param s The startposition to read some bits.
* @param n The number of bits to read.
* @return The selected bits, aligned to a LSB.
*/
@@ -44,10 +44,10 @@ static inline uint GB(const T x, const uint8 s, const uint8 n)
* This is not a bug, its a feature.
*
* @note Parameter \a x must be a variable as the result is saved there.
* @note To avoid unexpected results the value of \a d should not use more
* @note To avoid unexpecting results the value of \a d should not use more
* space as the provided space of \a n bits (log2)
* @param x The variable to change some bits
* @param s The start position for the new bits
* @param s The startposition for the new bits
* @param n The size/window for the new bits
* @param d The actually new bits to save in the defined position.
* @return The new value of \a x
@@ -61,19 +61,19 @@ static inline T SB(T &x, const uint8 s, const uint8 n, const U d)
}
/**
* Add \a i to \a n bits of \a x starting at bit \a s.
* Add i to n bits of x starting at bit s.
*
* This adds the value of \a i on \a n bits of \a x starting at bit \a s. The parameters \a x,
* \a s, \a i are similar to #GB. Besides, \ a x must be a variable as the result are
* This add the value of i on n bits of x starting at bit s. The parameters x,
* s, i are similar to #GB besides x must be a variable as the result are
* saved there. An overflow does not affect the following bits of the given
* bit window and is simply ignored.
*
* @note Parameter x must be a variable as the result is saved there.
* @param x The variable to add some bits at some position
* @param s The start position of the addition
* @param s The startposition of the addition
* @param n The size/window for the addition
* @param i The value to add at the given start position in the given window.
* @return The new value of \a x
* @param i The value to add at the given startposition in the given window.
* @return The new value of x
*/
template <typename T, typename U>
static inline T AB(T &x, const uint8 s, const uint8 n, const U i)
@@ -87,8 +87,8 @@ static inline T AB(T &x, const uint8 s, const uint8 n, const U i)
* Checks if a bit in a value is set.
*
* This function checks if a bit inside a value is set or not.
* The \a y value specific the position of the bit, started at the
* LSB and count from \c 0.
* The y value specific the position of the bit, started at the
* LSB and count from 0.
*
* @param x The value to check
* @param y The position of the bit to check, started from the LSB
@@ -165,7 +165,7 @@ static inline T ClrBit(T &x, const uint8 y)
* changed and the value is also returned. Parameter y defines the bit
* to toggle and starts at the LSB with 0.
*
* @param x The variable to toggle the bit
* @param x The varliable to toggle the bit
* @param y The bit position to toggle
* @return The new value of the old value with the bit toggled
*/
@@ -281,11 +281,11 @@ static inline bool HasAtMostOneBit(T value)
}
/**
* ROtate \a x Left by \a n
* ROtate x Left by n
*
* @note Assumes a byte has 8 bits
* @param x The value which we want to rotate
* @param n The number how many we want to rotate
* @param n The number how many we waht to rotate
* @return A bit rotated number
*/
template <typename T>
@@ -295,11 +295,11 @@ static inline T ROL(const T x, const uint8 n)
}
/**
* ROtate \a x Right by \a n
* ROtate x Right by n
*
* @note Assumes a byte has 8 bits
* @param x The value which we want to rotate
* @param n The number how many we want to rotate
* @param n The number how many we waht to rotate
* @return A bit rotated number
*/
template <typename T>
+2 -2
View File
@@ -15,7 +15,7 @@
/**
* Overflow safe template for integers, i.e. integers that will never overflow
* you multiply the maximum value with 2, or add 2, or subtract something from
* you multiply the maximum value with 2, or add 2, or substract somethng from
* the minimum value, etc.
* @param T the type these integers are stored with.
* @param T_MAX the maximum value for the integers.
@@ -54,7 +54,7 @@ public:
return *this;
}
/* Operators for addition and subtraction */
/* Operators for addition and substraction */
inline OverflowSafeInt operator + (const OverflowSafeInt& other) const { OverflowSafeInt result = *this; result += other; return result; }
inline OverflowSafeInt operator + (const int other) const { OverflowSafeInt result = *this; result += (int64)other; return result; }
inline OverflowSafeInt operator + (const uint other) const { OverflowSafeInt result = *this; result += (int64)other; return result; }
+1 -1
View File
@@ -135,7 +135,7 @@ static inline bool Chance16(const uint a, const uint b)
* This function uses the same parameters as Chance16. The third parameter
* must be a variable the randomize-number from Random() is saved in.
*
* The low 16 bits of r will already be used and can therefore not be passed to
* The low 16 bits of r will already be used and can therefor not be passed to
* Chance16I. One can only send the high 16 bits to Chance16I.
*
* @see Chance16I()
+1 -14
View File
@@ -49,19 +49,6 @@ struct SmallMap : SmallVector<SmallPair<T, U>, S> {
/** Data are freed in SmallVector destructor */
inline ~SmallMap() { }
/**
* Finds given key in this map
* @param key key to find
* @return &Pair(key, data) if found, this->End() if not
*/
inline const Pair *Find(const T &key) const
{
for (uint i = 0; i < this->items; i++) {
if (key == this->data[i].first) return &this->data[i];
}
return this->End();
}
/**
* Finds given key in this map
* @param key key to find
@@ -80,7 +67,7 @@ struct SmallMap : SmallVector<SmallPair<T, U>, S> {
* @param key key to test
* @return true iff the item is present
*/
inline bool Contains(const T &key) const
inline bool Contains(const T &key)
{
return this->Find(key) != this->End();
}
+6 -36
View File
@@ -39,39 +39,21 @@ public:
* Copy constructor.
* @param other The other vector to copy.
*/
SmallVector(const SmallVector &other) : data(NULL), items(0), capacity(0)
{
this->Assign(other);
}
/**
* Generic copy constructor.
* @param other The other vector to copy.
*/
template <uint X>
SmallVector(const SmallVector<T, X> &other) : data(NULL), items(0), capacity(0)
{
this->Assign(other);
MemCpyT<T>(this->Append(other.Length()), other.Begin(), other.Length());
}
/**
* Assignment.
* @param other The other vector to assign.
*/
SmallVector &operator=(const SmallVector &other)
{
this->Assign(other);
return *this;
}
/**
* Generic assignment.
* @param other The other vector to assign.
* @param other The new vector that.
*/
template <uint X>
SmallVector &operator=(const SmallVector<T, X> &other)
{
this->Assign(other);
this->Reset();
MemCpyT<T>(this->Append(other.Length()), other.Begin(), other.Length());
return *this;
}
@@ -80,18 +62,6 @@ public:
free(this->data);
}
/**
* Assign items from other vector.
*/
template <uint X>
inline void Assign(const SmallVector<T, X> &other)
{
if ((const void *)&other == (void *)this) return;
this->Clear();
if (other.Length() > 0) MemCpyT<T>(this->Append(other.Length()), other.Begin(), other.Length());
}
/**
* Remove all items from the list.
*/
@@ -178,10 +148,10 @@ public:
* @param item Item to search for
* @return The position of the item, or -1 when not present
*/
inline int FindIndex(const T &item) const
inline int FindIndex(const T &item)
{
int index = 0;
const T *pos = this->Begin();
T *pos = this->Begin();
const T *end = this->End();
while (pos != end && *pos != item) {
pos++;
+1 -1
View File
@@ -388,7 +388,7 @@ bool CrashLog::WriteScreenshot(char *filename, const char *filename_last) const
/* Don't draw when we have invalid screen size */
if (_screen.width < 1 || _screen.height < 1 || _screen.dst_ptr == NULL) return false;
bool res = MakeScreenshot(SC_CRASHLOG, "crash");
bool res = MakeScreenshot(SC_RAW, "crash");
if (res) strecpy(filename, _full_screenshot_name, filename_last);
return res;
}
+1 -5
View File
@@ -52,9 +52,6 @@ static const CurrencySpec origin_currency_specs[NUM_CURRENCY] = {
{ 60, "", 2009, "", NBSP "Sk", 1, STR_GAME_OPTIONS_CURRENCY_SKK }, ///< slovak koruna
{ 4, "", CF_NOEURO, "R$" NBSP, "", 0, STR_GAME_OPTIONS_CURRENCY_BRL }, ///< brazil real
{ 31, "", 2011, "", NBSP "EEK", 1, STR_GAME_OPTIONS_CURRENCY_EEK }, ///< estonian krooni
{ 4, "", 2014, "", NBSP "Lt", 1, STR_GAME_OPTIONS_CURRENCY_LTL }, ///< lithuanian litas
{ 1850, "", CF_NOEURO, "\xE2\x82\xA9", "", 0, STR_GAME_OPTIONS_CURRENCY_KRW }, ///< south korean won
{ 13, "", CF_NOEURO, "R" NBSP, "", 0, STR_GAME_OPTIONS_CURRENCY_ZAR }, ///< south african rand
{ 1, "", CF_NOEURO, "", "", 2, STR_GAME_OPTIONS_CURRENCY_CUSTOM }, ///< custom currency
};
@@ -96,7 +93,6 @@ enum Currencies {
CURR_SKK,
CURR_BRL,
CURR_EEK,
CURR_LTL,
};
/**
@@ -170,7 +166,7 @@ void CheckSwitchToEuro()
_currency_specs[_settings_game.locale.currency].to_euro != CF_ISEURO &&
_cur_year >= _currency_specs[_settings_game.locale.currency].to_euro) {
_settings_game.locale.currency = 2; // this is the index of euro above.
AddNewsItem(STR_NEWS_EURO_INTRODUCTION, NT_ECONOMY, NF_NORMAL);
AddNewsItem(STR_NEWS_EURO_INTRODUCTION, NS_ECONOMY);
}
}
+1 -1
View File
@@ -17,7 +17,7 @@
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 = 32; ///< Number of currencies.
static const uint NUM_CURRENCY = 29; ///< Number of currencies.
static const int CUSTOM_CURRENCY_ID = NUM_CURRENCY - 1; ///< Index of the custom currency.
/** Specification of a currency. */
+14 -18
View File
@@ -277,28 +277,24 @@ void IncreaseDate()
if (_date_fract < DAY_TICKS) return;
_date_fract = 0;
/* increase day counter */
/* increase day counter and call various daily loops */
_date++;
YearMonthDay ymd;
ConvertDateToYMD(_date, &ymd);
/* check if we entered a new month? */
bool new_month = ymd.month != _cur_month;
/* check if we entered a new year? */
bool new_year = ymd.year != _cur_year;
/* update internal variables before calling the daily/monthly/yearly loops */
_cur_month = ymd.month;
_cur_year = ymd.year;
/* yes, call various daily loops */
OnNewDay();
YearMonthDay ymd;
/* check if we entered a new month? */
ConvertDateToYMD(_date, &ymd);
if (ymd.month == _cur_month) return;
/* yes, call various monthly loops */
if (new_month) OnNewMonth();
_cur_month = ymd.month;
OnNewMonth();
/* check if we entered a new year? */
if (ymd.year == _cur_year) return;
/* yes, call various yearly loops */
if (new_year) OnNewYear();
_cur_year = ymd.year;
OnNewYear();
}
+5 -3
View File
@@ -117,8 +117,10 @@ struct SetDateWindow : Window {
break;
case WID_SD_YEAR:
SetDParamMaxValue(0, this->max_year);
d = maxdim(d, GetStringBoundingBox(STR_JUST_INT));
for (Year i = this->min_year; i <= this->max_year; i++) {
SetDParam(0, i);
d = maxdim(d, GetStringBoundingBox(STR_JUST_INT));
}
break;
}
@@ -197,7 +199,7 @@ static const NWidgetPart _nested_set_date_widgets[] = {
static const WindowDesc _set_date_desc(
WDP_CENTER, 0, 0,
WC_SET_DATE, WC_NONE,
0,
WDF_UNCLICK_BUTTONS,
_nested_set_date_widgets, lengthof(_nested_set_date_widgets)
);
-25
View File
@@ -73,31 +73,6 @@ struct DebugLevel {
};
#undef DEBUG_LEVEL
/**
* Dump the available debug facility names in the help text.
* @param buf Start address for storing the output.
* @param last Last valid address for storing the output.
* @return Next free position in the output.
*/
char *DumpDebugFacilityNames(char *buf, char *last)
{
size_t length = 0;
for (const DebugLevel *i = debug_level; i != endof(debug_level); ++i) {
if (length == 0) {
buf = strecpy(buf, "List of debug facility names:\n", last);
} else {
buf = strecpy(buf, ", ", last);
length += 2;
}
buf = strecpy(buf, i->name, last);
length += strlen(i->name);
}
if (length > 0) {
buf = strecpy(buf, "\n\n", last);
}
return buf;
}
#if !defined(NO_DEBUG_MESSAGES)
/**
-1
View File
@@ -58,7 +58,6 @@
void CDECL debug(const char *dbg, const char *format, ...) WARN_FORMAT(2, 3);
#endif /* NO_DEBUG_MESSAGES */
char *DumpDebugFacilityNames(char *buf, char *last);
void SetDebugString(const char *s);
const char *GetDebugString();
+2 -8
View File
@@ -910,10 +910,7 @@ int main(int argc, char *argv[])
size = ftell(src);
rewind(src);
content = (char*)malloc(size * sizeof(*content));
if (fread(content, 1, size, src) != (size_t)size) {
fprintf(stderr, "Could not read %s\n", filename);
exit(-2);
}
fread(content, 1, size, src);
fclose(src);
}
@@ -922,10 +919,7 @@ int main(int argc, char *argv[])
if (size != 0) {
src = fopen(backup, "wb");
if (fwrite(content, 1, size, src) != (size_t)size) {
fprintf(stderr, "Could not write %s\n", filename);
exit(-2);
}
fwrite(content, 1, size, src);
fclose(src);
/* Then append it to the real file. */
+34 -55
View File
@@ -11,7 +11,6 @@
#include "stdafx.h"
#include "train.h"
#include "roadveh.h"
#include "ship.h"
#include "aircraft.h"
#include "gui.h"
@@ -81,28 +80,28 @@ static const NWidgetPart _nested_train_depot_widgets[] = {
static const WindowDesc _train_depot_desc(
WDP_AUTO, 362, 123,
WC_VEHICLE_DEPOT, WC_NONE,
0,
WDF_UNCLICK_BUTTONS,
_nested_train_depot_widgets, lengthof(_nested_train_depot_widgets)
);
static const WindowDesc _road_depot_desc(
WDP_AUTO, 316, 97,
WC_VEHICLE_DEPOT, WC_NONE,
0,
WDF_UNCLICK_BUTTONS,
_nested_train_depot_widgets, lengthof(_nested_train_depot_widgets)
);
static const WindowDesc _ship_depot_desc(
WDP_AUTO, 306, 99,
WC_VEHICLE_DEPOT, WC_NONE,
0,
WDF_UNCLICK_BUTTONS,
_nested_train_depot_widgets, lengthof(_nested_train_depot_widgets)
);
static const WindowDesc _aircraft_depot_desc(
WDP_AUTO, 332, 99,
WC_VEHICLE_DEPOT, WC_NONE,
0,
WDF_UNCLICK_BUTTONS,
_nested_train_depot_widgets, lengthof(_nested_train_depot_widgets)
);
@@ -142,63 +141,41 @@ static void TrainDepotMoveVehicle(const Vehicle *wagon, VehicleID sel, const Veh
DoCommandP(v->tile, v->index | (_ctrl_pressed ? 1 : 0) << 20, wagon == NULL ? INVALID_VEHICLE : wagon->index, CMD_MOVE_RAIL_VEHICLE | CMD_MSG(STR_ERROR_CAN_T_MOVE_VEHICLE));
}
static VehicleCellSize _base_block_sizes_depot[VEH_COMPANY_END]; ///< Cell size for vehicle images in the depot view.
static VehicleCellSize _base_block_sizes_purchase[VEH_COMPANY_END]; ///< Cell size for vehicle images in the purchase list.
/**
* Get the GUI cell size for a vehicle image.
* @param type Vehicle type to get the size for.
* @param image_type Image type to get size for.
* @pre image_type == EIT_IN_DEPOT || image_type == EIT_PURCHASE
* @return Cell dimensions for the vehicle and image type.
* Array containing the cell size in pixels of the #WID_D_MATRIX widget for each vehicle type.
* @note The train vehicle type uses the entire row for each train.
*/
VehicleCellSize GetVehicleImageCellSize(VehicleType type, EngineImageType image_type)
{
switch (image_type) {
case EIT_IN_DEPOT: return _base_block_sizes_depot[type];
case EIT_PURCHASE: return _base_block_sizes_purchase[type];
default: NOT_REACHED();
}
}
static Dimension _base_block_sizes[4];
static void InitBlocksizeForVehicles(VehicleType type, EngineImageType image_type)
static void InitBlocksizeForShipAircraft(VehicleType type)
{
int max_extend_left = 0;
int max_extend_right = 0;
uint max_width = 0;
uint max_height = 0;
const Engine *e;
FOR_ALL_ENGINES_OF_TYPE(e, type) {
EngineID eid = e->index;
uint x, y;
int x_offs, y_offs;
switch (type) {
default: NOT_REACHED();
case VEH_TRAIN: GetTrainSpriteSize( eid, x, y, x_offs, y_offs, image_type); break;
case VEH_ROAD: GetRoadVehSpriteSize( eid, x, y, x_offs, y_offs, image_type); break;
case VEH_SHIP: GetShipSpriteSize( eid, x, y, x_offs, y_offs, image_type); break;
case VEH_AIRCRAFT: GetAircraftSpriteSize(eid, x, y, x_offs, y_offs, image_type); break;
case VEH_SHIP: GetShipSpriteSize( eid, x, y, EIT_IN_DEPOT); break;
case VEH_AIRCRAFT: GetAircraftSpriteSize(eid, x, y, EIT_IN_DEPOT); break;
}
if (x > max_width) max_width = x;
if (y > max_height) max_height = y;
if (-x_offs > max_extend_left) max_extend_left = -x_offs;
if ((int)x + x_offs > max_extend_right) max_extend_right = x + x_offs;
}
switch (image_type) {
case EIT_IN_DEPOT:
_base_block_sizes_depot[type].height = max(GetVehicleHeight(type), max_height);
_base_block_sizes_depot[type].extend_left = Clamp(max_extend_left, 16, 98);
_base_block_sizes_depot[type].extend_right = Clamp(max_extend_right, 16, 98);
break;
case EIT_PURCHASE:
_base_block_sizes_purchase[type].height = max(GetVehicleHeight(type), max_height);
_base_block_sizes_purchase[type].extend_left = Clamp(max_extend_left, 16, 98);
_base_block_sizes_purchase[type].extend_right = Clamp(max_extend_right, 16, 98);
break;
switch (type) {
default: NOT_REACHED();
case VEH_SHIP:
_base_block_sizes[VEH_SHIP].width = max(76U, max_width);
break;
case VEH_AIRCRAFT:
_base_block_sizes[VEH_AIRCRAFT].width = max(67U, max_width);
break;
}
_base_block_sizes[type].height = max(GetVehicleHeight(type), max_height);
}
/**
@@ -207,10 +184,14 @@ static void InitBlocksizeForVehicles(VehicleType type, EngineImageType image_typ
*/
void InitDepotWindowBlockSizes()
{
for (VehicleType vt = VEH_BEGIN; vt < VEH_COMPANY_END; vt++) {
InitBlocksizeForVehicles(vt, EIT_IN_DEPOT);
InitBlocksizeForVehicles(vt, EIT_PURCHASE);
}
_base_block_sizes[VEH_TRAIN].width = 0;
_base_block_sizes[VEH_TRAIN].height = GetVehicleHeight(VEH_TRAIN);
_base_block_sizes[VEH_ROAD].width = 32;
_base_block_sizes[VEH_ROAD].height = GetVehicleHeight(VEH_ROAD);
InitBlocksizeForShipAircraft(VEH_SHIP);
InitBlocksizeForShipAircraft(VEH_AIRCRAFT);
}
static void DepotSellAllConfirmationCallback(Window *w, bool confirmed);
@@ -499,14 +480,13 @@ struct DepotWindow : Window {
this->sel = INVALID_VEHICLE;
TrainDepotMoveVehicle(v, sel, gdvp.head);
} else if (v != NULL) {
bool rtl = _current_text_dir == TD_RTL;
int image = v->GetImage(rtl ? DIR_E : DIR_W, EIT_IN_DEPOT);
int image = v->GetImage(_current_text_dir == TD_RTL ? DIR_E : DIR_W, EIT_IN_DEPOT);
SetObjectToPlaceWnd(image, GetVehiclePalette(v), HT_DRAG, this);
this->sel = v->index;
this->SetDirty();
_cursor.short_vehicle_offset = v->IsGroundVehicle() ? (16 - v->GetGroundVehicleCache()->cached_veh_length * 2) * (rtl ? -1 : 1) : 0;
_cursor.short_vehicle_offset = v->IsGroundVehicle() ? 16 - v->GetGroundVehicleCache()->cached_veh_length * 2 : 0;
_cursor.vehchain = _ctrl_pressed;
}
break;
@@ -598,7 +578,7 @@ struct DepotWindow : Window {
uint min_height = 0;
if (this->type == VEH_TRAIN) {
SetDParamMaxValue(0, 1000);
SetDParam(0, 1000);
SetDParam(1, 1);
this->count_width = GetStringBoundingBox(STR_TINY_BLACK_DECIMAL).width + WD_FRAMERECT_LEFT + WD_FRAMERECT_RIGHT;
} else {
@@ -619,13 +599,13 @@ struct DepotWindow : Window {
}
int base_width = this->count_width + this->header_width;
resize->height = max<uint>(GetVehicleImageCellSize(this->type, EIT_IN_DEPOT).height, min_height);
resize->height = max(_base_block_sizes[this->type].height, min_height);
if (this->type == VEH_TRAIN) {
resize->width = 1;
size->width = base_width + 2 * 29; // about 2 parts
size->height = resize->height * 6;
} else {
resize->width = base_width + GetVehicleImageCellSize(this->type, EIT_IN_DEPOT).extend_left + GetVehicleImageCellSize(this->type, EIT_IN_DEPOT).extend_right;
resize->width = base_width + _base_block_sizes[this->type].width;
size->width = resize->width * (this->type == VEH_ROAD ? 5 : 3);
size->height = resize->height * (this->type == VEH_ROAD ? 5 : 3);
}
@@ -840,8 +820,7 @@ struct DepotWindow : Window {
*/
virtual bool OnVehicleSelect(const Vehicle *v)
{
/* Suppress the vehicle GUI when share-cloning. There is no point to it, starting vehicles can also be done via the depot GUI. */
if (DoCommandP(this->window_number, v->index, _ctrl_pressed ? 1 : 0, CMD_CLONE_VEHICLE | CMD_MSG(STR_ERROR_CAN_T_BUY_TRAIN + v->type), _ctrl_pressed ? NULL : CcCloneVehicle)) {
if (DoCommandP(this->window_number, v->index, _ctrl_pressed ? 1 : 0, CMD_CLONE_VEHICLE | CMD_MSG(STR_ERROR_CAN_T_BUY_TRAIN + v->type), CcCloneVehicle)) {
ResetObjectToPlace();
}
return true;
+17 -9
View File
@@ -218,7 +218,9 @@ static bool DisasterTick_Zeppeliner(DisasterVehicle *v)
v->age = 0;
SetDParam(0, GetStationIndex(v->tile));
AddVehicleNewsItem(STR_NEWS_DISASTER_ZEPPELIN, NT_ACCIDENT, v->index); // Delete the news, when the zeppelin is gone
AddVehicleNewsItem(STR_NEWS_DISASTER_ZEPPELIN,
NS_ACCIDENT,
v->index); // Delete the news, when the zeppelin is gone
AI::NewEvent(GetTileOwner(v->tile), new ScriptEventDisasterZeppelinerCrashed(GetStationIndex(v->tile)));
}
}
@@ -253,7 +255,7 @@ static bool DisasterTick_Zeppeliner(DisasterVehicle *v)
if (++v->age == 1) {
CreateEffectVehicleRel(v, 0, 7, 8, EV_EXPLOSION_LARGE);
if (_settings_client.sound.disaster) SndPlayVehicleFx(SND_12_EXPLOSION, v);
SndPlayVehicleFx(SND_12_EXPLOSION, v);
v->image_override = SPR_BLIMP_CRASHING;
} else if (v->age == 70) {
v->image_override = SPR_BLIMP_CRASHED;
@@ -351,7 +353,9 @@ static bool DisasterTick_Ufo(DisasterVehicle *v)
if (u->crashed_ctr == 0) {
u->Crash();
AddVehicleNewsItem(STR_NEWS_DISASTER_SMALL_UFO, NT_ACCIDENT, u->index); // delete the news, when the roadvehicle is gone
AddVehicleNewsItem(STR_NEWS_DISASTER_SMALL_UFO,
NS_ACCIDENT,
u->index); // delete the news, when the roadvehicle is gone
AI::NewEvent(u->owner, new ScriptEventVehicleCrashed(u->index, u->tile, ScriptEventVehicleCrashed::CRASH_RV_UFO));
Game::NewEvent(new ScriptEventVehicleCrashed(u->index, u->tile, ScriptEventVehicleCrashed::CRASH_RV_UFO));
@@ -361,7 +365,7 @@ static bool DisasterTick_Ufo(DisasterVehicle *v)
/* Destroy? */
if (v->age > 50) {
CreateEffectVehicleRel(v, 0, 7, 8, EV_EXPLOSION_LARGE);
if (_settings_client.sound.disaster) SndPlayVehicleFx(SND_12_EXPLOSION, v);
SndPlayVehicleFx(SND_12_EXPLOSION, v);
delete v;
return false;
}
@@ -430,8 +434,8 @@ static bool DisasterTick_Aircraft(DisasterVehicle *v, uint16 image_override, boo
DestructIndustry(i);
SetDParam(0, i->town->index);
AddIndustryNewsItem(news_message, NT_ACCIDENT, i->index); // delete the news, when the industry closes
if (_settings_client.sound.disaster) SndPlayTileFx(SND_12_EXPLOSION, i->location.tile);
AddIndustryNewsItem(news_message, NS_ACCIDENT, i->index); // delete the news, when the industry closes
SndPlayTileFx(SND_12_EXPLOSION, i->location.tile);
}
} else if (v->current_order.GetDestination() == 0) {
int x = v->x_pos + ((leave_at_top ? -15 : 15) * TILE_SIZE);
@@ -526,7 +530,10 @@ static bool DisasterTick_Big_Ufo(DisasterVehicle *v)
Town *t = ClosestTownFromTile(v->dest_tile, UINT_MAX);
SetDParam(0, t->index);
AddTileNewsItem(STR_NEWS_DISASTER_BIG_UFO, NT_ACCIDENT, v->tile);
AddNewsItem(STR_NEWS_DISASTER_BIG_UFO,
NS_ACCIDENT,
NR_TILE,
v->tile);
if (!Vehicle::CanAllocateItem(2)) {
delete v;
@@ -596,7 +603,7 @@ static bool DisasterTick_Big_Ufo_Destroyer(DisasterVehicle *v)
v->current_order.SetDestination(1);
CreateEffectVehicleRel(u, 0, 7, 8, EV_EXPLOSION_LARGE);
if (_settings_client.sound.disaster) SndPlayVehicleFx(SND_12_EXPLOSION, u);
SndPlayVehicleFx(SND_12_EXPLOSION, u);
delete u;
@@ -871,7 +878,8 @@ static void Disaster_CoalMine_Init()
FOR_ALL_INDUSTRIES(i) {
if ((GetIndustrySpec(i->type)->behaviour & INDUSTRYBEH_CAN_SUBSIDENCE) && --index < 0) {
SetDParam(0, i->town->index);
AddTileNewsItem(STR_NEWS_DISASTER_COAL_MINE_SUBSIDENCE, NT_ACCIDENT, i->location.tile + TileDiffXY(1, 1)); // keep the news, even when the mine closes
AddNewsItem(STR_NEWS_DISASTER_COAL_MINE_SUBSIDENCE,
NS_ACCIDENT, NR_TILE, i->location.tile + TileDiffXY(1, 1)); // keep the news, even when the mine closes
{
TileIndex tile = i->location.tile;
+4 -4
View File
@@ -40,13 +40,13 @@ void CcBuildDocks(const CommandCost &result, TileIndex tile, uint32 p1, uint32 p
{
if (result.Failed()) return;
if (_settings_client.sound.confirm) SndPlayTileFx(SND_02_SPLAT, tile);
SndPlayTileFx(SND_02_SPLAT, tile);
if (!_settings_client.gui.persistent_buildingtools) ResetObjectToPlace();
}
void CcBuildCanal(const CommandCost &result, TileIndex tile, uint32 p1, uint32 p2)
{
if (result.Succeeded() && _settings_client.sound.confirm) SndPlayTileFx(SND_02_SPLAT, tile);
if (result.Succeeded()) SndPlayTileFx(SND_02_SPLAT, tile);
}
@@ -436,7 +436,7 @@ public:
this->RaiseWidget(_settings_client.gui.station_show_coverage + BDSW_LT_OFF);
_settings_client.gui.station_show_coverage = (widget != BDSW_LT_OFF);
this->LowerWidget(_settings_client.gui.station_show_coverage + BDSW_LT_OFF);
if (_settings_client.sound.click_beep) SndPlayFx(SND_15_BEEP);
SndPlayFx(SND_15_BEEP);
this->SetDirty();
break;
}
@@ -514,7 +514,7 @@ public:
this->RaiseWidget(_ship_depot_direction + WID_BDD_X);
_ship_depot_direction = (widget == WID_BDD_X ? AXIS_X : AXIS_Y);
this->LowerWidget(_ship_depot_direction + WID_BDD_X);
if (_settings_client.sound.click_beep) SndPlayFx(SND_15_BEEP);
SndPlayFx(SND_15_BEEP);
UpdateDocksDirection();
this->SetDirty();
break;
+30 -107
View File
@@ -44,7 +44,6 @@
#include "core/backup_type.hpp"
#include "water.h"
#include "game/game.hpp"
#include "cargomonitor.h"
#include "table/strings.h"
#include "table/pricebase.h"
@@ -523,44 +522,33 @@ void ChangeOwnershipOfCompanyItems(Owner old_owner, Owner new_owner)
static void CompanyCheckBankrupt(Company *c)
{
/* If the company has money again, it does not go bankrupt */
if (c->money - c->current_loan >= -_economy.max_loan) {
c->months_of_bankruptcy = 0;
if (c->money >= 0) {
c->quarters_of_bankruptcy = 0;
c->bankrupt_asked = 0;
return;
}
c->months_of_bankruptcy++;
c->quarters_of_bankruptcy++;
switch (c->months_of_bankruptcy) {
/* All the boring cases (months) with a bad balance where no action is taken */
switch (c->quarters_of_bankruptcy) {
case 0:
case 1:
case 2:
case 3:
case 5:
case 6:
case 8:
case 9:
break;
/* Warn about bancruptcy after 3 months */
case 4: {
case 2: {
CompanyNewsInformation *cni = MallocT<CompanyNewsInformation>(1);
cni->FillData(c);
SetDParam(0, STR_NEWS_COMPANY_IN_TROUBLE_TITLE);
SetDParam(1, STR_NEWS_COMPANY_IN_TROUBLE_DESCRIPTION);
SetDParamStr(2, cni->company_name);
AddCompanyNewsItem(STR_MESSAGE_NEWS_FORMAT, cni);
AddCompanyNewsItem(STR_MESSAGE_NEWS_FORMAT, NS_COMPANY_TROUBLE, cni);
AI::BroadcastNewEvent(new ScriptEventCompanyInTrouble(c->index));
Game::NewEvent(new ScriptEventCompanyInTrouble(c->index));
break;
}
/* Offer company for sale after 6 months */
case 7: {
/* Check if the company has any value. If not, declare it bankrupt
case 3: {
/* Check if the company has any value.. if not, declare it bankrupt
* right now */
Money val = CalculateCompanyValue(c, false);
if (val > 0) {
@@ -569,13 +557,10 @@ static void CompanyCheckBankrupt(Company *c)
c->bankrupt_timeout = 0;
break;
}
/* FALL THROUGH to case 10 */
/* FALL THROUGH to case 4... */
}
/* Bancrupt company after 6 months (if the company has no value) or latest
* after 9 months (if it still had value after 6 months) */
default:
case 10: {
case 4:
if (!_networking && _local_company == c->index) {
/* If we are in offline mode, leave the company playing. Eg. there
* is no THE-END, otherwise mark the client as spectator to make sure
@@ -596,7 +581,6 @@ static void CompanyCheckBankrupt(Company *c)
* company and thus we won't be moved. */
if (!_networking || _network_server) DoCommandP(0, 2 | (c->index << 16), CRR_BANKRUPT, CMD_COMPANY_CTRL);
break;
}
}
}
@@ -640,11 +624,6 @@ static void CompaniesGenStatistics()
}
cur_company.Restore();
/* Check for bankruptcy each month */
FOR_ALL_COMPANIES(c) {
CompanyCheckBankrupt(c);
}
/* Only run the economic statics and update company stats every 3rd month (1st of quarter). */
if (!HasBit(1 << 0 | 1 << 3 | 1 << 6 | 1 << 9, _cur_month)) return;
@@ -657,6 +636,7 @@ static void CompaniesGenStatistics()
UpdateCompanyRatingAndValue(c, true);
if (c->block_preview != 0) c->block_preview--;
CompanyCheckBankrupt(c);
}
SetWindowDirty(WC_INCOME_GRAPH, 0);
@@ -670,9 +650,8 @@ static void CompaniesGenStatistics()
/**
* Add monthly inflation
* @param check_year Shall the inflation get stopped after 170 years?
* @return true if inflation is maxed and nothing was changed
*/
bool AddInflation(bool check_year)
void AddInflation(bool check_year)
{
/* The cargo payment inflation differs from the normal inflation, so the
* relative amount of money you make with a transport decreases slowly over
@@ -689,22 +668,15 @@ bool AddInflation(bool check_year)
* inflation doesn't add anything after that either; it even makes playing
* it impossible due to the diverging cost and income rates.
*/
if (check_year && (_cur_year - _settings_game.game_creation.starting_year) >= (ORIGINAL_MAX_YEAR - ORIGINAL_BASE_YEAR)) return true;
if (_economy.inflation_prices == MAX_INFLATION || _economy.inflation_payment == MAX_INFLATION) return true;
if (check_year && (_cur_year - _settings_game.game_creation.starting_year) >= (ORIGINAL_MAX_YEAR - ORIGINAL_BASE_YEAR)) return;
/* Approximation for (100 + infl_amount)% ** (1 / 12) - 100%
* scaled by 65536
* 12 -> months per year
* This is only a good approxiamtion for small values
*/
_economy.inflation_prices += (_economy.inflation_prices * _economy.infl_amount * 54) >> 16;
_economy.inflation_payment += (_economy.inflation_payment * _economy.infl_amount_pr * 54) >> 16;
if (_economy.inflation_prices > MAX_INFLATION) _economy.inflation_prices = MAX_INFLATION;
if (_economy.inflation_payment > MAX_INFLATION) _economy.inflation_payment = MAX_INFLATION;
return false;
_economy.inflation_prices += min((_economy.inflation_prices * _economy.infl_amount * 54) >> 16, MAX_INFLATION);
_economy.inflation_payment += min((_economy.inflation_payment * _economy.infl_amount_pr * 54) >> 16, MAX_INFLATION);
}
/**
@@ -793,14 +765,8 @@ static void CompaniesPayInterest()
* what (total) should have been paid up to this month and you subtract
* whatever has been paid in the previous months. This will mean one month
* it'll be a bit more and the other it'll be a bit less than the average
* monthly fee, but on average it will be exact.
* In order to prevent cheating or abuse (just not paying interest by not
* taking a loan we make companies pay interest on negative cash as well
*/
* monthly fee, but on average it will be exact. */
Money yearly_fee = c->current_loan * _economy.interest_rate / 100;
if (c->money < 0) {
yearly_fee += -c->money *_economy.interest_rate / 100;
}
Money up_to_previous_month = yearly_fee * _cur_month / 12;
Money up_to_this_month = yearly_fee * (_cur_month + 1) / 12;
@@ -826,10 +792,10 @@ static void HandleEconomyFluctuations()
if (_economy.fluct == 0) {
_economy.fluct = -(int)GB(Random(), 0, 2);
AddNewsItem(STR_NEWS_BEGIN_OF_RECESSION, NT_ECONOMY, NF_NORMAL);
AddNewsItem(STR_NEWS_BEGIN_OF_RECESSION, NS_ECONOMY);
} else if (_economy.fluct == -12) {
_economy.fluct = GB(Random(), 0, 8) + 312;
AddNewsItem(STR_NEWS_END_OF_RECESSION, NT_ECONOMY, NF_NORMAL);
AddNewsItem(STR_NEWS_END_OF_RECESSION, NS_ECONOMY);
}
}
@@ -896,8 +862,6 @@ void StartupEconomy()
void InitializeEconomy()
{
_economy.inflation_prices = _economy.inflation_payment = 1 << 16;
ClearCargoPickupMonitoring();
ClearCargoDeliveryMonitoring();
}
/**
@@ -1063,9 +1027,6 @@ static Money DeliverGoods(int num_pieces, CargoID cargo_type, StationID dest, Ti
/* Determine profit */
Money profit = GetTransportedGoodsIncome(accepted, DistanceManhattan(source_tile, st->xy), days_in_transit, cargo_type);
/* Update the cargo monitor. */
AddCargoDelivery(cargo_type, company->index, accepted, src_type, src, st);
/* Modify profit if a subsidy is in effect */
if (CheckSubsidised(cargo_type, company->index, src_type, src, st)) {
switch (_settings_game.difficulty.subsidy_multiplier) {
@@ -1269,16 +1230,6 @@ static void LoadUnloadVehicle(Vehicle *front, int *cargo_left)
return;
}
bool use_autorefit = front->current_order.IsRefit() && front->current_order.GetRefitCargo() == CT_AUTO_REFIT;
CargoArray consist_capleft;
if (use_autorefit) {
/* Sum cargo, that can be loaded without refitting */
for (Vehicle *v = front; v != NULL; v = v->Next()) {
int cap_left = v->cargo_cap - v->cargo.Count();
if (cap_left > 0) consist_capleft[v->cargo_type] += cap_left;
}
}
int unloading_time = 0;
bool dirty_vehicle = false;
bool dirty_station = false;
@@ -1351,8 +1302,8 @@ static void LoadUnloadVehicle(Vehicle *front, int *cargo_left)
if ((front->current_order.GetUnloadType() & (OUFB_UNLOAD | OUFB_TRANSFER)) && (!accepted || v->cargo.Count() == cargo_count)) {
remaining = v->cargo.MoveTo(&ge->cargo, amount_unloaded, front->current_order.GetUnloadType() & OUFB_TRANSFER ? VehicleCargoList::MTA_TRANSFER : VehicleCargoList::MTA_UNLOAD, payment);
if (!HasBit(ge->acceptance_pickup, GoodsEntry::GES_PICKUP)) {
SetBit(ge->acceptance_pickup, GoodsEntry::GES_PICKUP);
InvalidateWindowData(WC_STATION_LIST, last_visited);
SetBit(ge->acceptance_pickup, GoodsEntry::GES_PICKUP);
}
dirty_vehicle = dirty_station = true;
@@ -1395,13 +1346,6 @@ static void LoadUnloadVehicle(Vehicle *front, int *cargo_left)
CargoID new_cid = front->current_order.GetRefitCargo();
byte new_subtype = front->current_order.GetRefitSubtype();
/* Remove old capacity from consist capacity */
consist_capleft[v_start->cargo_type] -= v_start->cargo_cap;
for (Vehicle *w = v_start; w->HasArticulatedPart(); ) {
w = w->GetNextArticulatedPart();
consist_capleft[w->cargo_type] -= w->cargo_cap;
}
Backup<CompanyByte> cur_company(_current_company, front->owner, FILE_LINE);
/* Check if all articulated parts are empty and collect refit mask. */
@@ -1418,15 +1362,13 @@ static void LoadUnloadVehicle(Vehicle *front, int *cargo_left)
int amount = 0;
CargoID cid;
FOR_EACH_SET_CARGO_ID(cid, refit_mask) {
/* Consider refitting to this cargo, if other vehicles of the consist cannot
* already take the cargo without refitting */
if (cargo_left[cid] > (int)consist_capleft[cid] + amount) {
if (cargo_left[cid] > amount) {
/* Try to find out if auto-refitting would succeed. In case the refit is allowed,
* the returned refit capacity will be greater than zero. */
new_subtype = GetBestFittingSubType(v, v, cid);
DoCommand(v_start->tile, v_start->index, cid | 1U << 6 | new_subtype << 8 | 1U << 16, DC_QUERY_COST, GetCmdRefitVeh(v_start)); // Auto-refit and only this vehicle including artic parts.
if (_returned_refit_capacity > 0) {
amount = cargo_left[cid] - consist_capleft[cid];
amount = cargo_left[cid];
new_cid = cid;
}
}
@@ -1440,13 +1382,6 @@ static void LoadUnloadVehicle(Vehicle *front, int *cargo_left)
ge = &st->goods[v->cargo_type];
}
/* Add new capacity to consist capacity */
consist_capleft[v_start->cargo_type] += v_start->cargo_cap;
for (Vehicle *w = v_start; w->HasArticulatedPart(); ) {
w = w->GetNextArticulatedPart();
consist_capleft[w->cargo_type] += w->cargo_cap;
}
cur_company.Restore();
}
@@ -1471,8 +1406,8 @@ static void LoadUnloadVehicle(Vehicle *front, int *cargo_left)
/* if last speed is 0, we treat that as if no vehicle has ever visited the station. */
ge->last_speed = min(t, 255);
ge->last_age = min(_cur_year - front->build_year, 255);
ge->time_since_pickup = 0;
ge->last_age = _cur_year - front->build_year;
ge->days_since_pickup = 0;
/* If there's goods waiting at the station, and the vehicle
* has capacity for it, load it on the vehicle. */
@@ -1497,17 +1432,7 @@ static void LoadUnloadVehicle(Vehicle *front, int *cargo_left)
/* Don't load stuff that is already 'reserved' for other vehicles */
cap = min((uint)cargo_left[v->cargo_type], cap);
count = cargo_left[v->cargo_type];
if (use_autorefit) {
/* When using autorefit, reserve all cargo for this wagon to prevent other wagons
* from feeling the need to refit. */
int total_cap_left = v->cargo_cap - v->cargo.Count();
cargo_left[v->cargo_type] -= total_cap_left;
consist_capleft[v->cargo_type] -= total_cap_left;
} else {
/* Update cargo left; but don't reserve everything yet, so other wagons
* of the same consist load in parallel. */
cargo_left[v->cargo_type] -= cap;
}
cargo_left[v->cargo_type] -= cap;
}
/* Store whether the maximum possible load amount was loaded or not.*/
@@ -1558,13 +1483,11 @@ static void LoadUnloadVehicle(Vehicle *front, int *cargo_left)
/* Only set completely_emptied, if we just unloaded all remaining cargo */
completely_emptied &= anything_unloaded;
/* For consists without autorefit-order we adjust the reserved cargo at the station after loading,
* so that all wagons start loading if the consist is the first consist.
*
* If we use autorefit otoh, we only want to load/refit a vehicle if the other wagons cannot already hold the cargo,
* to keep the option to still refit the vehicle when new cargo of different type shows up.
*/
if (_settings_game.order.improved_load && (front->current_order.GetLoadType() & OLFB_FULL_LOAD) && !use_autorefit) {
/* We update these variables here, so gradual loading still fills
* all wagons at the same time instead of using the same 'improved'
* loading algorithm for the wagons (only fill wagon when there is
* enough to fill the previous wagons) */
if (_settings_game.order.improved_load && (front->current_order.GetLoadType() & OLFB_FULL_LOAD)) {
/* Update left cargo */
for (Vehicle *v = front; v != NULL; v = v->Next()) {
int cap_left = v->cargo_cap - v->cargo.Count();
@@ -1727,7 +1650,7 @@ static void DoAcquireCompany(Company *c)
SetDParamStr(2, cni->company_name);
SetDParamStr(3, cni->other_company_name);
SetDParam(4, c->bankrupt_value);
AddCompanyNewsItem(STR_MESSAGE_NEWS_FORMAT, cni);
AddCompanyNewsItem(STR_MESSAGE_NEWS_FORMAT, NS_COMPANY_MERGER, cni);
AI::BroadcastNewEvent(new ScriptEventCompanyMerger(ci, _current_company));
Game::NewEvent(new ScriptEventCompanyMerger(ci, _current_company));
+1 -1
View File
@@ -40,7 +40,7 @@ Money GetPrice(Price index, uint cost_factor, const struct GRFFile *grf_file, in
void InitializeEconomy();
void RecomputePrices();
bool AddInflation(bool check_year = true);
void AddInflation(bool check_year = true);
/**
* Is the economy in recession?
+2 -2
View File
@@ -498,7 +498,7 @@ static bool BubbleTick(EffectVehicle *v)
if (b->y == 4 && b->x == 1) {
if (v->z_pos > 180 || Chance16I(1, 96, Random())) {
v->spritenum = 5;
if (_settings_client.sound.ambient) SndPlayVehicleFx(SND_2F_POP, v);
SndPlayVehicleFx(SND_2F_POP, v);
}
anim_state = 0;
}
@@ -507,7 +507,7 @@ static bool BubbleTick(EffectVehicle *v)
TileIndex tile;
anim_state++;
if (_settings_client.sound.ambient) SndPlayVehicleFx(SND_31_EXTRACT, v);
SndPlayVehicleFx(SND_31_EXTRACT, v);
tile = TileVirtXY(v->x_pos, v->y_pos);
if (IsTileType(tile, MP_INDUSTRY) && GetIndustryGfx(tile) == GFX_BUBBLE_CATCHER) AddAnimatedTile(tile);
+6 -16
View File
@@ -111,6 +111,7 @@ static TrackBits GetRailTrackBitsUniversal(TileIndex t, byte *override)
case MP_STATION:
if (!HasStationRail(t)) return TRACK_BIT_NONE;
if (!HasCatenary(GetRailType(t))) return TRACK_BIT_NONE;
if (!IsStationTileElectrifiable(t)) return TRACK_BIT_NONE;
return TrackToTrackBits(GetRailStationTrack(t));
default:
@@ -129,13 +130,9 @@ static TrackBits MaskWireBits(TileIndex t, TrackBits tracks)
for (DiagDirection d = DIAGDIR_BEGIN; d < DIAGDIR_END; d++) {
/* If the neighbor tile is either not electrified or has no tracks that can be reached
* from this tile, mark all trackdirs that can be reached from the neighbour tile
* as needing no catenary. We make an exception for blocked station tiles with a matching
* axis that still display wires to preserve visual continuity. */
TileIndex next_tile = TileAddByDiagDir(t, d);
RailType rt = GetTileRailType(next_tile);
if (rt == INVALID_RAILTYPE || !HasCatenary(rt) ||
((TrackStatusToTrackBits(GetTileTrackStatus(next_tile, TRANSPORT_RAIL, 0)) & DiagdirReachesTracks(d)) == TRACK_BIT_NONE &&
(!HasStationTileRail(next_tile) || GetRailStationAxis(next_tile) != DiagDirToAxis(d) || !CanStationTileHaveWires(next_tile)))) {
* as needing no catenary. */
RailType rt = GetTileRailType(TileAddByDiagDir(t, d));
if (rt == INVALID_RAILTYPE || !HasCatenary(rt) || (TrackStatusToTrackBits(GetTileTrackStatus(TileAddByDiagDir(t, d), TRANSPORT_RAIL, 0)) & DiagdirReachesTracks(d)) == TRACK_BIT_NONE) {
neighbour_tdb |= DiagdirReachesTrackdirs(ReverseDiagDir(d));
}
}
@@ -327,9 +324,6 @@ static void DrawCatenaryRailway(const TileInfo *ti)
wireconfig[TS_NEIGHBOUR] = MaskWireBits(neighbour, trackconfig[TS_NEIGHBOUR]);
if (IsTunnelTile(neighbour) && i != GetTunnelBridgeDirection(neighbour)) wireconfig[TS_NEIGHBOUR] = trackconfig[TS_NEIGHBOUR] = TRACK_BIT_NONE;
/* Ignore station tiles that allow neither wires nor pylons. */
if (IsRailStationTile(neighbour) && !CanStationTileHavePylons(neighbour) && !CanStationTileHaveWires(neighbour)) wireconfig[TS_NEIGHBOUR] = trackconfig[TS_NEIGHBOUR] = TRACK_BIT_NONE;
/* If the neighboured tile does not smoothly connect to the current tile (because of a foundation),
* we have to draw all pillars on the current tile. */
if (elevation != GetPCPElevation(neighbour, ReverseDiagDir(i))) wireconfig[TS_NEIGHBOUR] = trackconfig[TS_NEIGHBOUR] = TRACK_BIT_NONE;
@@ -415,8 +409,7 @@ static void DrawCatenaryRailway(const TileInfo *ti)
}
}
if (PPPallowed[i] != 0 && HasBit(PCPstatus, i) && !HasBit(OverridePCP, i) &&
(!IsRailStationTile(ti->tile) || CanStationTileHavePylons(ti->tile))) {
if (PPPallowed[i] != 0 && HasBit(PCPstatus, i) && !HasBit(OverridePCP, i)) {
for (Direction k = DIR_BEGIN; k < DIR_END; k++) {
byte temp = PPPorder[i][GetTLG(ti->tile)][k];
@@ -444,15 +437,12 @@ static void DrawCatenaryRailway(const TileInfo *ti)
if (IsTunnelTile(ti->tile)) return;
/* Don't draw a wire under a low bridge */
if (MayHaveBridgeAbove(ti->tile) && IsBridgeAbove(ti->tile) && !IsTransparencySet(TO_BRIDGES)) {
if (MayHaveBridgeAbove(ti->tile) && IsBridgeAbove(ti->tile) && !IsTransparencySet(TO_CATENARY)) {
int height = GetBridgeHeight(GetNorthernBridgeEnd(ti->tile));
if (height <= GetTileMaxZ(ti->tile) + 1) return;
}
/* Don't draw a wire if the station tile does not want any */
if (IsRailStationTile(ti->tile) && !CanStationTileHaveWires(ti->tile)) return;
SpriteID wire_normal = GetWireBase(ti->tile);
SpriteID wire_halftile = (halftile_corner != CORNER_INVALID) ? GetWireBase(ti->tile, TCX_UPPER_HALFTILE) : wire_normal;
Track halftile_track;
+44 -104
View File
@@ -29,7 +29,6 @@
#include "engine_base.h"
#include "company_base.h"
#include "vehicle_func.h"
#include "articulated_vehicles.h"
#include "table/strings.h"
#include "table/engines.h"
@@ -147,12 +146,12 @@ Engine::~Engine()
}
/**
* Checks whether the engine is a valid (non-articulated part of an) engine.
* Checks whether the engine spec is properly initialised.
* @return true if enabled
*/
bool Engine::IsEnabled() const
{
return this->info.string_id != STR_NEWGRF_INVALID_ENGINE && HasBit(this->info.climates, _settings_game.game_creation.landscape);
return this->info.string_id != STR_NEWGRF_INVALID_ENGINE;
}
/**
@@ -741,8 +740,7 @@ static void AcceptEnginePreview(EngineID eid, CompanyID company)
SetBit(c->avail_roadtypes, HasBit(e->info.misc_flags, EF_ROAD_TRAM) ? ROADTYPE_TRAM : ROADTYPE_ROAD);
}
e->preview_company = INVALID_COMPANY;
e->preview_asked = (CompanyMask)-1;
e->preview_company_rank = 0xFF;
if (company == _local_company) {
AddRemoveEngineFromAutoreplaceAndBuildWindows(e->type);
}
@@ -750,68 +748,39 @@ static void AcceptEnginePreview(EngineID eid, CompanyID company)
/* Update the toolbar. */
if (e->type == VEH_ROAD) InvalidateWindowData(WC_BUILD_TOOLBAR, TRANSPORT_ROAD);
if (e->type == VEH_SHIP) InvalidateWindowData(WC_BUILD_TOOLBAR, TRANSPORT_WATER);
/* Notify preview window, that it might want to close.
* Note: We cannot directly close the window.
* In singleplayer this function is called from the preview window, so
* we have to use the GUI-scope scheduling of InvalidateWindowData.
*/
InvalidateWindowData(WC_ENGINE_PREVIEW, eid);
}
/**
* Get the best company for an engine preview.
* @param e Engine to preview.
* @return Best company if it exists, #INVALID_COMPANY otherwise.
* Get the N-th best company.
* @param pp Value N, 1 means best, 2 means second best, etc.
* @return N-th best company if it exists, #INVALID_COMPANY otherwise.
*/
static CompanyID GetPreviewCompany(Engine *e)
static CompanyID GetBestCompany(uint8 pp)
{
CompanyID best_company = INVALID_COMPANY;
CompanyID best_company;
CompanyMask mask = 0;
/* For trains the cargomask has no useful meaning, since you can attach other wagons */
uint32 cargomask = e->type != VEH_TRAIN ? GetUnionOfArticulatedRefitMasks(e->index, true) : (uint32)-1;
int32 best_hist = -1;
const Company *c;
FOR_ALL_COMPANIES(c) {
if (c->block_preview == 0 && !HasBit(e->preview_asked, c->index) &&
c->old_economy[0].performance_history > best_hist) {
/* Check whether the company uses similar vehicles */
Vehicle *v;
FOR_ALL_VEHICLES(v) {
if (v->owner != c->index || v->type != e->type) continue;
if (!v->GetEngine()->CanCarryCargo() || !HasBit(cargomask, v->cargo_type)) continue;
do {
int32 best_hist = -1;
best_company = INVALID_COMPANY;
const Company *c;
FOR_ALL_COMPANIES(c) {
if (c->block_preview == 0 && !HasBit(mask, c->index) &&
c->old_economy[0].performance_history > best_hist) {
best_hist = c->old_economy[0].performance_history;
best_company = c->index;
break;
}
}
}
if (best_company == INVALID_COMPANY) return INVALID_COMPANY;
SetBit(mask, best_company);
} while (--pp != 0);
return best_company;
}
/**
* Checks if a vehicle type is disabled for all/ai companies.
* @param type The vehicle type which shall be checked.
* @param ai If true, check if the type is disabled for AI companies, otherwise check if
* the vehicle type is disabled for human companies.
* @return Whether or not a vehicle type is disabled.
*/
static bool IsVehicleTypeDisabled(VehicleType type, bool ai)
{
switch (type) {
case VEH_TRAIN: return _settings_game.vehicle.max_trains == 0 || (ai && _settings_game.ai.ai_disable_veh_train);
case VEH_ROAD: return _settings_game.vehicle.max_roadveh == 0 || (ai && _settings_game.ai.ai_disable_veh_roadveh);
case VEH_SHIP: return _settings_game.vehicle.max_ships == 0 || (ai && _settings_game.ai.ai_disable_veh_ship);
case VEH_AIRCRAFT: return _settings_game.vehicle.max_aircraft == 0 || (ai && _settings_game.ai.ai_disable_veh_aircraft);
default: NOT_REACHED();
}
}
/** Daily check to offer an exclusive engine preview to the companies. */
void EnginesDailyLoop()
{
@@ -823,28 +792,24 @@ void EnginesDailyLoop()
FOR_ALL_ENGINES(e) {
EngineID i = e->index;
if (e->flags & ENGINE_EXCLUSIVE_PREVIEW) {
if (e->preview_company != INVALID_COMPANY) {
if (!--e->preview_wait) {
if (e->flags & ENGINE_OFFER_WINDOW_OPEN) {
if (e->preview_company_rank != 0xFF && !--e->preview_wait) {
e->flags &= ~ENGINE_OFFER_WINDOW_OPEN;
DeleteWindowById(WC_ENGINE_PREVIEW, i);
e->preview_company = INVALID_COMPANY;
e->preview_company_rank++;
}
} else if (CountBits(e->preview_asked) < MAX_COMPANIES) {
e->preview_company = GetPreviewCompany(e);
} else if (e->preview_company_rank != 0xFF) {
CompanyID best_company = GetBestCompany(e->preview_company_rank);
if (e->preview_company == INVALID_COMPANY) {
e->preview_asked = (CompanyMask)-1;
if (best_company == INVALID_COMPANY) {
e->preview_company_rank = 0xFF;
continue;
}
SetBit(e->preview_asked, e->preview_company);
e->flags |= ENGINE_OFFER_WINDOW_OPEN;
e->preview_wait = 20;
/* AIs are intentionally not skipped for preview even if they cannot build a certain
* vehicle type. This is done to not give poor performing human companies an "unfair"
* boost that they wouldn't have gotten against other human companies. The check on
* the line below is just to make AIs not notice that they have a preview if they
* cannot build the vehicle. */
if (!IsVehicleTypeDisabled(e->type, true)) AI::NewEvent(e->preview_company, new ScriptEventEnginePreview(i));
if (IsInteractiveCompany(e->preview_company)) ShowEnginePreviewWindow(i);
AI::NewEvent(best_company, new ScriptEventEnginePreview(i));
if (IsInteractiveCompany(best_company)) ShowEnginePreviewWindow(i);
}
}
}
@@ -863,7 +828,7 @@ void EnginesDailyLoop()
CommandCost CmdWantEnginePreview(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
{
Engine *e = Engine::GetIfValid(p1);
if (e == NULL || e->preview_company != _current_company) return CMD_ERROR;
if (e == NULL || GetBestCompany(e->preview_company_rank) != _current_company) return CMD_ERROR;
if (flags & DC_EXEC) AcceptEnginePreview(p1, _current_company);
@@ -924,25 +889,17 @@ static void NewVehicleAvailable(Engine *e)
FOR_ALL_COMPANIES(c) SetBit(c->avail_roadtypes, HasBit(e->info.misc_flags, EF_ROAD_TRAM) ? ROADTYPE_TRAM : ROADTYPE_ROAD);
}
/* Only broadcast event if AIs are able to build this vehicle type. */
if (!IsVehicleTypeDisabled(e->type, true)) AI::BroadcastNewEvent(new ScriptEventEngineAvailable(index));
AI::BroadcastNewEvent(new ScriptEventEngineAvailable(index));
/* Only provide the "New Vehicle available" news paper entry, if engine can be built. */
if (!IsVehicleTypeDisabled(e->type, false)) {
SetDParam(0, GetEngineCategoryName(index));
SetDParam(1, index);
AddNewsItem(STR_NEWS_NEW_VEHICLE_NOW_AVAILABLE_WITH_TYPE, NT_NEW_VEHICLES, NF_VEHICLE, NR_ENGINE, index);
}
SetDParam(0, GetEngineCategoryName(index));
SetDParam(1, index);
AddNewsItem(STR_NEWS_NEW_VEHICLE_NOW_AVAILABLE_WITH_TYPE, NS_NEW_VEHICLES, NR_ENGINE, index);
/* Update the toolbar. */
if (e->type == VEH_ROAD) InvalidateWindowData(WC_BUILD_TOOLBAR, TRANSPORT_ROAD);
if (e->type == VEH_SHIP) InvalidateWindowData(WC_BUILD_TOOLBAR, TRANSPORT_WATER);
/* Close pending preview windows */
DeleteWindowById(WC_ENGINE_PREVIEW, index);
}
/** Monthly update of the availability, reliability, and preview offers of the engines. */
void EnginesMonthlyLoop()
{
if (_cur_year < _year_engine_aging_stops) {
@@ -961,19 +918,13 @@ void EnginesMonthlyLoop()
/* Introduce it to all companies */
NewVehicleAvailable(e);
} else if (!(e->flags & (ENGINE_AVAILABLE | ENGINE_EXCLUSIVE_PREVIEW)) && _date >= e->intro_date) {
/* Introduction date has passed...
* Check if it is allowed to build this vehicle type at all
* based on the current game settings. If not, it does not
* make sense to show the preview dialog to any company. */
if (IsVehicleTypeDisabled(e->type, false)) continue;
/* Introduction date has passed.. show introducing dialog to one companies. */
e->flags |= ENGINE_EXCLUSIVE_PREVIEW;
/* Do not introduce new rail wagons */
if (IsWagon(e->index)) continue;
/* Show preview dialog to one of the companies. */
e->flags |= ENGINE_EXCLUSIVE_PREVIEW;
e->preview_company = INVALID_COMPANY;
e->preview_asked = 0;
if (!IsWagon(e->index)) {
e->preview_company_rank = 1; // Give to the company with the highest rating.
}
}
}
@@ -981,11 +932,6 @@ void EnginesMonthlyLoop()
}
}
/**
* Is \a name still free as name for an engine?
* @param name New name of an engine.
* @return \c false if the name is being used already, else \c true.
*/
static bool IsUniqueEngineName(const char *name)
{
const Engine *e;
@@ -1052,14 +998,8 @@ bool IsEngineBuildable(EngineID engine, VehicleType type, CompanyID company)
/* check if it's an engine of specified type */
if (e->type != type) return false;
/* check if it's available ... */
if (company == OWNER_DEITY) {
/* ... for any company (preview does not count) */
if (!(e->flags & ENGINE_AVAILABLE) || e->company_avail == 0) return false;
} else {
/* ... for this company */
if (!HasBit(e->company_avail, company)) return false;
}
/* check if it's available */
if (company != OWNER_DEITY && !HasBit(e->company_avail, company)) return false;
if (!e->IsEnabled()) return false;
+2 -3
View File
@@ -33,9 +33,8 @@ struct Engine : EnginePool::PoolItem<&_engine_pool> {
uint16 duration_phase_2; ///< Second reliability phase in months, keeping #reliability_max.
uint16 duration_phase_3; ///< Third reliability phase on months, decaying to #reliability_final.
byte flags; ///< Flags of the engine. @see EngineFlags
CompanyMask preview_asked; ///< Bit for each company which has already been offered a preview.
CompanyByte preview_company;///< Company which is currently being offered a preview \c INVALID_COMPANY means no company.
byte preview_wait; ///< Daily countdown timer for timeout of offering the engine to the #preview_company company.
uint8 preview_company_rank; ///< Rank of the company that is offered a preview. \c 0xFF means no company.
byte preview_wait; ///< Daily countdown timer for timeout of offering the engine to the #preview_company_rank company.
CompanyMask company_avail; ///< Bit for each company whether the engine is available for that company.
uint8 original_image_index; ///< Original vehicle image index, thus the image index of the overridden vehicle
VehicleType type; ///< %Vehicle type, ie #VEH_ROAD, #VEH_TRAIN, etc.
-11
View File
@@ -64,9 +64,6 @@ struct EnginePreviewWindow : Window {
EnginePreviewWindow(const WindowDesc *desc, WindowNumber window_number) : Window()
{
this->InitNested(desc, window_number);
/* There is no way to recover the window; so disallow closure via DEL; unless SHIFT+DEL */
this->flags |= WF_STICKY;
}
virtual void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize)
@@ -110,14 +107,6 @@ struct EnginePreviewWindow : Window {
break;
}
}
virtual void OnInvalidateData(int data = 0, bool gui_scope = true)
{
if (!gui_scope) return;
EngineID engine = this->window_number;
if (Engine::Get(engine)->preview_company != _local_company) delete this;
}
};
static const WindowDesc _engine_preview_desc(

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