diff --git a/.gitignore b/.gitignore
index cb1e9d1599..2b298a14a9 100644
--- a/.gitignore
+++ b/.gitignore
@@ -7,6 +7,7 @@ bin/ai/*
bin/baseset/*
!bin/baseset/openttd.grf
!bin/baseset/opntitle.dat
+!bin/baseset/orig_extra.grf
!bin/baseset/orig_*.obg
!bin/baseset/orig_*.obs
!bin/baseset/no_sound.obs
diff --git a/Makefile.grf.in b/Makefile.grf.in
index 1cc2642320..1625b9e4c0 100644
--- a/Makefile.grf.in
+++ b/Makefile.grf.in
@@ -44,22 +44,18 @@ PNG_FILES := $(GRF_DIR)/*.png $(GRF_DIR)/rivers/*.png
# Build the GRF.
ifdef GRFCODEC
-all: $(BIN_DIR)/openttd.grf $(BIN_DIR)/orig_dos.obg $(BIN_DIR)/orig_dos_de.obg $(BIN_DIR)/orig_win.obg $(BIN_DIR)/orig_dos.obs $(BIN_DIR)/orig_win.obs $(BIN_DIR)/no_sound.obs $(BIN_DIR)/orig_win.obm $(BIN_DIR)/no_music.obm
+all: $(BIN_DIR)/openttd.grf $(BIN_DIR)/orig_extra.grf $(BIN_DIR)/orig_dos.obg $(BIN_DIR)/orig_dos_de.obg $(BIN_DIR)/orig_win.obg $(BIN_DIR)/orig_dos.obs $(BIN_DIR)/orig_win.obs $(BIN_DIR)/no_sound.obs $(BIN_DIR)/orig_win.obm $(BIN_DIR)/no_music.obm
else
all:
endif
-# Make sure the sprites directory exists.
-$(OBJS_DIR)/sprites:
- $(Q)-mkdir "$@"
-
$(OBJS_DIR)/langfiles.tmp: $(LANG_DIR)/*.txt
$(E) '$(STAGE) Collecting baseset translations'
$(Q) cat $^ > $@
-$(BIN_DIR)/%.obg: $(BASESET_DIR)/%.obg $(BIN_DIR)/openttd.grf $(OBJS_DIR)/langfiles.tmp $(BASESET_DIR)/translations.awk
+$(BIN_DIR)/%.obg: $(BASESET_DIR)/%.obg $(BIN_DIR)/orig_extra.grf $(OBJS_DIR)/langfiles.tmp $(BASESET_DIR)/translations.awk
$(E) '$(STAGE) Updating $(notdir $@)'
- $(Q) sed 's/^OPENTTD.GRF = *[0-9a-f]*$$/OPENTTD.GRF = '`$(MD5SUM) $(BIN_DIR)/openttd.grf | sed 's@ .*@@'`'/' $< > $@.tmp
+ $(Q) sed 's/^ORIG_EXTRA.GRF = *[0-9a-f]*$$/ORIG_EXTRA.GRF = '`$(MD5SUM) $(BIN_DIR)/orig_extra.grf | sed 's@ .*@@'`'/' $< > $@.tmp
$(Q) awk -v langfiles='$(OBJS_DIR)/langfiles.tmp' -f $(BASESET_DIR)/translations.awk $@.tmp >$@
$(Q) rm $@.tmp
@@ -72,8 +68,9 @@ $(BIN_DIR)/%.obm: $(BASESET_DIR)/%.obm $(OBJS_DIR)/langfiles.tmp $(BASESET_DIR)/
$(Q) awk -v langfiles='$(OBJS_DIR)/langfiles.tmp' -f $(BASESET_DIR)/translations.awk $< >$@
# Compile extra grf
-$(BIN_DIR)/openttd.grf: $(PNG_FILES) $(NFO_FILES) $(OBJS_DIR)/sprites $(GRF_DIR)/assemble_nfo.awk
+$(BIN_DIR)/openttd.grf: $(PNG_FILES) $(NFO_FILES) $(GRF_DIR)/assemble_nfo.awk
$(E) '$(STAGE) Assembling openttd.nfo'
+ $(Q)-mkdir -p $(OBJS_DIR)/sprites
$(Q)-cp $(PNG_FILES) $(OBJS_DIR)/sprites 2> /dev/null
$(Q) awk -f $(GRF_DIR)/assemble_nfo.awk $(GRF_DIR)/openttd.nfo > $(OBJS_DIR)/sprites/openttd.nfo
$(Q) $(NFORENUM) -s $(OBJS_DIR)/sprites/openttd.nfo
@@ -81,6 +78,17 @@ $(BIN_DIR)/openttd.grf: $(PNG_FILES) $(NFO_FILES) $(OBJS_DIR)/sprites $(GRF_DIR)
$(Q) $(GRFCODEC) -n -s -e -p1 $(OBJS_DIR)/openttd.grf
$(Q)cp $(OBJS_DIR)/openttd.grf $(BIN_DIR)/openttd.grf
+# The copy operation of PNG_FILES is duplicated from the target 'openttd.grf', thus those targets may not run in parallel.
+$(BIN_DIR)/orig_extra.grf: $(PNG_FILES) $(NFO_FILES) $(GRF_DIR)/assemble_nfo.awk | $(BIN_DIR)/openttd.grf
+ $(E) '$(STAGE) Assembling orig_extra.nfo'
+ $(Q)-mkdir -p $(OBJS_DIR)/sprites
+ $(Q)-cp $(PNG_FILES) $(OBJS_DIR)/sprites 2> /dev/null
+ $(Q) awk -f $(GRF_DIR)/assemble_nfo.awk $(GRF_DIR)/orig_extra.nfo > $(OBJS_DIR)/sprites/orig_extra.nfo
+ $(Q) $(NFORENUM) -s $(OBJS_DIR)/sprites/orig_extra.nfo
+ $(E) '$(STAGE) Compiling orig_extra.grf'
+ $(Q) $(GRFCODEC) -n -s -e -p1 $(OBJS_DIR)/orig_extra.grf
+ $(Q)cp $(OBJS_DIR)/orig_extra.grf $(BIN_DIR)/orig_extra.grf
+
# Clean up temporary files.
clean:
$(Q)rm -f *.bak *.grf
diff --git a/Makefile.in b/Makefile.in
index 0d50fc1b1e..d33d8a0d2a 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -152,7 +152,7 @@ mrproper:
distclean: mrproper
maintainer-clean: distclean
- $(Q)rm -f $(BIN_DIR)/baseset/openttd.grf $(BIN_DIR)/baseset/*.obg $(BIN_DIR)/baseset/*.obs $(BIN_DIR)/baseset/*.obm
+ $(Q)rm -f $(BIN_DIR)/baseset/openttd.grf $(BIN_DIR)/baseset/orig_extra.grf $(BIN_DIR)/baseset/*.obg $(BIN_DIR)/baseset/*.obs $(BIN_DIR)/baseset/*.obm
depend:
@for dir in $(SRC_DIRS); do \
diff --git a/bin/baseset/openttd.grf b/bin/baseset/openttd.grf
index efe35ffd38..168d00fbd8 100644
Binary files a/bin/baseset/openttd.grf and b/bin/baseset/openttd.grf differ
diff --git a/bin/baseset/orig_dos.obg b/bin/baseset/orig_dos.obg
index 3eb8c0ff97..ad3b35c49f 100644
--- a/bin/baseset/orig_dos.obg
+++ b/bin/baseset/orig_dos.obg
@@ -63,21 +63,21 @@ description.zh_CN = 运输大亨DOS豪华版原版图形包.
description.zh_TW = 原版 Transport Tycoon Deluxe DOS 版的圖形。
[files]
-base = TRG1.GRF
-logos = TRGI.GRF
-arctic = TRGC.GRF
-tropical = TRGH.GRF
-toyland = TRGT.GRF
-extra = OPENTTD.GRF
+base = TRG1.GRF
+logos = TRGI.GRF
+arctic = TRGC.GRF
+tropical = TRGH.GRF
+toyland = TRGT.GRF
+extra = ORIG_EXTRA.GRF
[md5s]
-TRG1.GRF = 9311676280e5b14077a8ee41c1b42192
-TRGI.GRF = da6a6c9dcc451eec88d79211437b76a8
-TRGC.GRF = ed446637e034104c5559b32c18afe78d
-TRGH.GRF = ee6616fb0e6ef6b24892c58c93d86fc9
-TRGT.GRF = e30e8a398ae86c03dc534a8ac7dfb3b6
-OPENTTD.GRF = 505d96061556d3bb5cec6234096ec5bc
+TRG1.GRF = 9311676280e5b14077a8ee41c1b42192
+TRGI.GRF = da6a6c9dcc451eec88d79211437b76a8
+TRGC.GRF = ed446637e034104c5559b32c18afe78d
+TRGH.GRF = ee6616fb0e6ef6b24892c58c93d86fc9
+TRGT.GRF = e30e8a398ae86c03dc534a8ac7dfb3b6
+ORIG_EXTRA.GRF = 73b921a42814c47a84945b7e9add5d9f
[origin]
-default = You can find it on your Transport Tycoon Deluxe CD-ROM.
-OPENTTD.GRF = This file was part of your OpenTTD installation.
+default = You can find it on your Transport Tycoon Deluxe CD-ROM.
+ORIG_EXTRA.GRF = This file was part of your OpenTTD installation.
diff --git a/bin/baseset/orig_dos_de.obg b/bin/baseset/orig_dos_de.obg
index b081e4bc2f..676840f788 100644
--- a/bin/baseset/orig_dos_de.obg
+++ b/bin/baseset/orig_dos_de.obg
@@ -62,21 +62,21 @@ description.zh_CN = 运输大亨DOS豪华德语版原版图形包.
description.zh_TW = 原版 Transport Tycoon Deluxe DOS 版 (德國版) 的圖形。
[files]
-base = TRG1.GRF
-logos = TRGI.GRF
-arctic = TRGC.GRF
-tropical = TRGH.GRF
-toyland = TRGT.GRF
-extra = OPENTTD.GRF
+base = TRG1.GRF
+logos = TRGI.GRF
+arctic = TRGC.GRF
+tropical = TRGH.GRF
+toyland = TRGT.GRF
+extra = ORIG_EXTRA.GRF
[md5s]
-TRG1.GRF = 9311676280e5b14077a8ee41c1b42192
-TRGI.GRF = da6a6c9dcc451eec88d79211437b76a8
-TRGC.GRF = ed446637e034104c5559b32c18afe78d
-TRGH.GRF = ee6616fb0e6ef6b24892c58c93d86fc9
-TRGT.GRF = fcde1d7e8a74197d72a62695884b909e
-OPENTTD.GRF = 505d96061556d3bb5cec6234096ec5bc
+TRG1.GRF = 9311676280e5b14077a8ee41c1b42192
+TRGI.GRF = da6a6c9dcc451eec88d79211437b76a8
+TRGC.GRF = ed446637e034104c5559b32c18afe78d
+TRGH.GRF = ee6616fb0e6ef6b24892c58c93d86fc9
+TRGT.GRF = fcde1d7e8a74197d72a62695884b909e
+ORIG_EXTRA.GRF = 73b921a42814c47a84945b7e9add5d9f
[origin]
-default = You can find it on your Transport Tycoon Deluxe CD-ROM.
-OPENTTD.GRF = This file was part of your OpenTTD installation.
+default = You can find it on your Transport Tycoon Deluxe CD-ROM.
+ORIG_EXTRA.GRF = This file was part of your OpenTTD installation.
diff --git a/bin/baseset/orig_extra.grf b/bin/baseset/orig_extra.grf
new file mode 100644
index 0000000000..168c415a5d
Binary files /dev/null and b/bin/baseset/orig_extra.grf differ
diff --git a/bin/baseset/orig_win.obg b/bin/baseset/orig_win.obg
index 65a97c4770..049a3dca9b 100644
--- a/bin/baseset/orig_win.obg
+++ b/bin/baseset/orig_win.obg
@@ -63,21 +63,21 @@ description.zh_CN = 运输大亨Windows豪华版原版图形包.
description.zh_TW = 原版 Transport Tycoon Deluxe Windows 版的圖形。
[files]
-base = TRG1R.GRF
-logos = TRGIR.GRF
-arctic = TRGCR.GRF
-tropical = TRGHR.GRF
-toyland = TRGTR.GRF
-extra = OPENTTD.GRF
+base = TRG1R.GRF
+logos = TRGIR.GRF
+arctic = TRGCR.GRF
+tropical = TRGHR.GRF
+toyland = TRGTR.GRF
+extra = ORIG_EXTRA.GRF
[md5s]
-TRG1R.GRF = b04ce593d8c5016e07473a743d7d3358
-TRGIR.GRF = 0c2484ff6be49fc63a83be6ab5c38f32
-TRGCR.GRF = 3668f410c761a050b5e7095a2b14879b
-TRGHR.GRF = 06bf2b7a31766f048baac2ebe43457b1
-TRGTR.GRF = de53650517fe661ceaa3138c6edb0eb8
-OPENTTD.GRF = 505d96061556d3bb5cec6234096ec5bc
+TRG1R.GRF = b04ce593d8c5016e07473a743d7d3358
+TRGIR.GRF = 0c2484ff6be49fc63a83be6ab5c38f32
+TRGCR.GRF = 3668f410c761a050b5e7095a2b14879b
+TRGHR.GRF = 06bf2b7a31766f048baac2ebe43457b1
+TRGTR.GRF = de53650517fe661ceaa3138c6edb0eb8
+ORIG_EXTRA.GRF = 73b921a42814c47a84945b7e9add5d9f
[origin]
-default = You can find it on your Transport Tycoon Deluxe CD-ROM.
-OPENTTD.GRF = This file was part of your OpenTTD installation.
+default = You can find it on your Transport Tycoon Deluxe CD-ROM.
+ORIG_EXTRA.GRF = This file was part of your OpenTTD installation.
diff --git a/config.lib b/config.lib
index 961e5eae8c..8d88eb4145 100644
--- a/config.lib
+++ b/config.lib
@@ -1407,11 +1407,14 @@ make_compiler_cflags() {
flags="$flags -fno-tree-vrp"
fi
- if [ $cc_version -ge 407 ]; then
+ if [ $cc_version -eq 407 ]; then
# Disable -Wnarrowing which gives many warnings, such as:
# warning: narrowing conversion of '...' from 'unsigned int' to 'int' inside { } [-Wnarrowing]
# They are valid according to the C++ standard, but useless.
cxxflags="$cxxflags -Wno-narrowing"
+ fi
+
+ if [ $cc_version -ge 407 ]; then
# Disable bogus 'attempt to free a non-heap object' warning
flags="$flags -Wno-free-nonheap-object"
else
@@ -1524,8 +1527,11 @@ make_cflags_and_ldflags() {
cc_build_is_gcc=`basename "$cc_build" | grep "gcc" 2>/dev/null`
if [ -n "$cc_build_is_gcc" ]; then
- # Just add -O1 to the tools needed for building.
+ # Add -O1 and fortify source to the tools needed for building, on gcc
CFLAGS_BUILD="$CFLAGS_BUILD -D_FORTIFY_SOURCE=2 -O1"
+ elif [ -n "`basename "$cc_build" | grep "clang" 2>/dev/null`" ]; then
+ # Add -O1 to the tools needed for building, on clang
+ CFLAGS_BUILD="$CFLAGS_BUILD -O1"
fi
fi
@@ -1619,23 +1625,6 @@ make_cflags_and_ldflags() {
CFLAGS="$OSX_SYSROOT $CFLAGS"
LDFLAGS="$OSX_LD_SYSROOT $LDFLAGS"
fi
-
- if [ "$enable_universal" = "0" ] && [ $cc_version -gt 400 ]; then
- # Only set the min version when not doing an universal build.
- # Universal builds set the version elsewhere.
- if [ "$cpu_type" = "64" ]; then
- CFLAGS="$CFLAGS -mmacosx-version-min=10.5"
- else
- gcc_cpu=`$cc_host -dumpmachine`
- if [ "`echo $gcc_cpu | cut -c 1-3`" = "ppc" -o "`echo $gcc_cpu | cut -c 1-7`" = "powerpc" ]; then
- # PowerPC build can run on 10.3
- CFLAGS="$CFLAGS -mmacosx-version-min=10.3"
- else
- # Intel is only available starting from 10.4
- CFLAGS="$CFLAGS -mmacosx-version-min=10.4"
- fi
- fi
- fi
fi
if [ "$os" = "BEOS" ] || [ "$os" = "HAIKU" ]; then
diff --git a/media/baseset/orig_dos.obg b/media/baseset/orig_dos.obg
index b4cde64007..f9db843af1 100644
--- a/media/baseset/orig_dos.obg
+++ b/media/baseset/orig_dos.obg
@@ -11,21 +11,21 @@ palette = DOS
!! description STR_BASEGRAPHICS_DOS_DESCRIPTION
[files]
-base = TRG1.GRF
-logos = TRGI.GRF
-arctic = TRGC.GRF
-tropical = TRGH.GRF
-toyland = TRGT.GRF
-extra = OPENTTD.GRF
+base = TRG1.GRF
+logos = TRGI.GRF
+arctic = TRGC.GRF
+tropical = TRGH.GRF
+toyland = TRGT.GRF
+extra = ORIG_EXTRA.GRF
[md5s]
-TRG1.GRF = 9311676280e5b14077a8ee41c1b42192
-TRGI.GRF = da6a6c9dcc451eec88d79211437b76a8
-TRGC.GRF = ed446637e034104c5559b32c18afe78d
-TRGH.GRF = ee6616fb0e6ef6b24892c58c93d86fc9
-TRGT.GRF = e30e8a398ae86c03dc534a8ac7dfb3b6
-OPENTTD.GRF =
+TRG1.GRF = 9311676280e5b14077a8ee41c1b42192
+TRGI.GRF = da6a6c9dcc451eec88d79211437b76a8
+TRGC.GRF = ed446637e034104c5559b32c18afe78d
+TRGH.GRF = ee6616fb0e6ef6b24892c58c93d86fc9
+TRGT.GRF = e30e8a398ae86c03dc534a8ac7dfb3b6
+ORIG_EXTRA.GRF =
[origin]
-default = You can find it on your Transport Tycoon Deluxe CD-ROM.
-OPENTTD.GRF = This file was part of your OpenTTD installation.
+default = You can find it on your Transport Tycoon Deluxe CD-ROM.
+ORIG_EXTRA.GRF = This file was part of your OpenTTD installation.
diff --git a/media/baseset/orig_dos_de.obg b/media/baseset/orig_dos_de.obg
index 8cfcc27074..4e12582727 100644
--- a/media/baseset/orig_dos_de.obg
+++ b/media/baseset/orig_dos_de.obg
@@ -11,21 +11,21 @@ palette = DOS
!! description STR_BASEGRAPHICS_DOS_DE_DESCRIPTION
[files]
-base = TRG1.GRF
-logos = TRGI.GRF
-arctic = TRGC.GRF
-tropical = TRGH.GRF
-toyland = TRGT.GRF
-extra = OPENTTD.GRF
+base = TRG1.GRF
+logos = TRGI.GRF
+arctic = TRGC.GRF
+tropical = TRGH.GRF
+toyland = TRGT.GRF
+extra = ORIG_EXTRA.GRF
[md5s]
-TRG1.GRF = 9311676280e5b14077a8ee41c1b42192
-TRGI.GRF = da6a6c9dcc451eec88d79211437b76a8
-TRGC.GRF = ed446637e034104c5559b32c18afe78d
-TRGH.GRF = ee6616fb0e6ef6b24892c58c93d86fc9
-TRGT.GRF = fcde1d7e8a74197d72a62695884b909e
-OPENTTD.GRF =
+TRG1.GRF = 9311676280e5b14077a8ee41c1b42192
+TRGI.GRF = da6a6c9dcc451eec88d79211437b76a8
+TRGC.GRF = ed446637e034104c5559b32c18afe78d
+TRGH.GRF = ee6616fb0e6ef6b24892c58c93d86fc9
+TRGT.GRF = fcde1d7e8a74197d72a62695884b909e
+ORIG_EXTRA.GRF =
[origin]
-default = You can find it on your Transport Tycoon Deluxe CD-ROM.
-OPENTTD.GRF = This file was part of your OpenTTD installation.
+default = You can find it on your Transport Tycoon Deluxe CD-ROM.
+ORIG_EXTRA.GRF = This file was part of your OpenTTD installation.
diff --git a/media/baseset/orig_win.obg b/media/baseset/orig_win.obg
index 82a5c2a616..393b5d3013 100644
--- a/media/baseset/orig_win.obg
+++ b/media/baseset/orig_win.obg
@@ -11,21 +11,21 @@ palette = Windows
!! description STR_BASEGRAPHICS_WIN_DESCRIPTION
[files]
-base = TRG1R.GRF
-logos = TRGIR.GRF
-arctic = TRGCR.GRF
-tropical = TRGHR.GRF
-toyland = TRGTR.GRF
-extra = OPENTTD.GRF
+base = TRG1R.GRF
+logos = TRGIR.GRF
+arctic = TRGCR.GRF
+tropical = TRGHR.GRF
+toyland = TRGTR.GRF
+extra = ORIG_EXTRA.GRF
[md5s]
-TRG1R.GRF = b04ce593d8c5016e07473a743d7d3358
-TRGIR.GRF = 0c2484ff6be49fc63a83be6ab5c38f32
-TRGCR.GRF = 3668f410c761a050b5e7095a2b14879b
-TRGHR.GRF = 06bf2b7a31766f048baac2ebe43457b1
-TRGTR.GRF = de53650517fe661ceaa3138c6edb0eb8
-OPENTTD.GRF =
+TRG1R.GRF = b04ce593d8c5016e07473a743d7d3358
+TRGIR.GRF = 0c2484ff6be49fc63a83be6ab5c38f32
+TRGCR.GRF = 3668f410c761a050b5e7095a2b14879b
+TRGHR.GRF = 06bf2b7a31766f048baac2ebe43457b1
+TRGTR.GRF = de53650517fe661ceaa3138c6edb0eb8
+ORIG_EXTRA.GRF =
[origin]
-default = You can find it on your Transport Tycoon Deluxe CD-ROM.
-OPENTTD.GRF = This file was part of your OpenTTD installation.
+default = You can find it on your Transport Tycoon Deluxe CD-ROM.
+ORIG_EXTRA.GRF = This file was part of your OpenTTD installation.
diff --git a/media/extra_grf/canals.nfo b/media/extra_grf/canals.nfo
index c0d0275f35..e464762ee6 100644
--- a/media/extra_grf/canals.nfo
+++ b/media/extra_grf/canals.nfo
@@ -6,7 +6,7 @@
// 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 .
//
- -1 * 0 0C "Canal graphics by George / PaulC"
+ -1 * 0 0C "Canal graphics by George"
-1 * 3 05 08 41
// Canal slopes
-1 sprites/canal_locks.png 8bpp 66 8 64 23 -31 0 normal
@@ -77,95 +77,3 @@
-1 sprites/canals.png 8bpp 446 10 24 16 -11 -6 normal
// Canal icon
-1 sprites/canal_locks.png 8bpp 50 232 20 20 0 0 normal
-
-// Differentiation for the climates starts here
-
-// Canal edges (arctic snowy)
- -1 * 4 01 05 01 \b12
- -1 sprites/canals.png 8bpp 30 40 45 22 -11 -1 normal
- -1 sprites/canals.png 8bpp 94 40 41 21 -8 10 normal
- -1 sprites/canals.png 8bpp 142 40 42 21 -31 10 normal
- -1 sprites/canals.png 8bpp 190 40 43 22 -31 -1 normal
- -1 sprites/canals.png 8bpp 238 40 22 22 11 4 normal
- -1 sprites/canals.png 8bpp 270 40 24 16 -11 15 normal
- -1 sprites/canals.png 8bpp 302 40 23 23 -31 4 normal
- -1 sprites/canals.png 8bpp 334 40 24 18 -11 -1 normal
- -1 sprites/canals.png 8bpp 366 40 12 11 21 10 normal
- -1 sprites/canals.png 8bpp 398 40 19 10 -8 21 normal
- -1 sprites/canals.png 8bpp 430 40 11 10 -31 10 normal
- -1 sprites/canals.png 8bpp 446 40 24 16 -11 -6 normal
- -1 * 7 02 05 10 01 00 00 00
-
-// Canal edges (arctic normal)
- -1 * 4 01 05 01 \b12
- -1 sprites/canals.png 8bpp 30 70 45 22 -11 -1 normal
- -1 sprites/canals.png 8bpp 94 70 41 21 -8 10 normal
- -1 sprites/canals.png 8bpp 142 70 42 21 -31 10 normal
- -1 sprites/canals.png 8bpp 190 70 43 22 -31 -1 normal
- -1 sprites/canals.png 8bpp 238 70 22 22 11 4 normal
- -1 sprites/canals.png 8bpp 270 70 24 16 -11 15 normal
- -1 sprites/canals.png 8bpp 302 70 23 23 -31 4 normal
- -1 sprites/canals.png 8bpp 334 70 24 18 -11 -1 normal
- -1 sprites/canals.png 8bpp 366 70 12 11 21 10 normal
- -1 sprites/canals.png 8bpp 398 70 19 10 -8 21 normal
- -1 sprites/canals.png 8bpp 430 70 11 10 -31 10 normal
- -1 sprites/canals.png 8bpp 446 70 24 16 -11 -6 normal
- -1 * 7 02 05 11 01 00 00 00
-// Choose the right arctic canal edges
- -1 * 14 02 05 12 81 81 00 FF 01 10 00 04 04 11 00
- -1 * 6 07 83 01 \7! 01 01
- -1 * 7 03 05 01 02 00 12 00
-
-// Canal edges (tropic desert)
- -1 * 4 01 05 01 \b12
- -1 sprites/canals.png 8bpp 30 100 45 22 -11 -1 normal
- -1 sprites/canals.png 8bpp 94 100 41 21 -8 10 normal
- -1 sprites/canals.png 8bpp 142 100 42 21 -31 10 normal
- -1 sprites/canals.png 8bpp 190 100 43 22 -31 -1 normal
- -1 sprites/canals.png 8bpp 238 100 22 22 11 4 normal
- -1 sprites/canals.png 8bpp 270 100 24 16 -11 15 normal
- -1 sprites/canals.png 8bpp 302 100 23 23 -31 4 normal
- -1 sprites/canals.png 8bpp 334 100 24 18 -11 -1 normal
- -1 sprites/canals.png 8bpp 366 100 12 11 21 10 normal
- -1 sprites/canals.png 8bpp 398 100 19 10 -8 21 normal
- -1 sprites/canals.png 8bpp 430 100 11 10 -31 10 normal
- -1 sprites/canals.png 8bpp 446 100 24 16 -11 -6 normal
- -1 * 7 02 05 13 01 00 00 00
-
-// Canal edges (tropic rainforest)
- -1 * 4 01 05 01 \b12
- -1 sprites/canals.png 8bpp 30 130 45 22 -11 -1 normal
- -1 sprites/canals.png 8bpp 94 130 41 21 -8 10 normal
- -1 sprites/canals.png 8bpp 142 130 42 21 -31 10 normal
- -1 sprites/canals.png 8bpp 190 130 43 22 -31 -1 normal
- -1 sprites/canals.png 8bpp 238 130 22 22 11 4 normal
- -1 sprites/canals.png 8bpp 270 130 24 16 -11 15 normal
- -1 sprites/canals.png 8bpp 302 130 23 23 -31 4 normal
- -1 sprites/canals.png 8bpp 334 130 24 18 -11 -1 normal
- -1 sprites/canals.png 8bpp 366 130 12 11 21 10 normal
- -1 sprites/canals.png 8bpp 398 130 19 10 -8 21 normal
- -1 sprites/canals.png 8bpp 430 130 11 10 -31 10 normal
- -1 sprites/canals.png 8bpp 446 130 24 16 -11 -6 normal
- -1 * 7 02 05 14 01 00 00 00
-// Choose the right tropic canal edges
- -1 * 14 02 05 15 81 81 00 FF 01 13 00 01 01 14 00
- -1 * 6 07 83 01 \7! 02 01
- -1 * 7 03 05 01 02 00 15 00
-
-// Canal edges (toyland)
- -1 * 4 01 05 01 \b12
- -1 sprites/canals.png 8bpp 30 160 45 22 -11 -1 normal
- -1 sprites/canals.png 8bpp 94 160 41 21 -8 10 normal
- -1 sprites/canals.png 8bpp 142 160 42 21 -31 10 normal
- -1 sprites/canals.png 8bpp 190 160 43 22 -31 -1 normal
- -1 sprites/canals.png 8bpp 238 160 22 22 11 4 normal
- -1 sprites/canals.png 8bpp 270 160 24 16 -11 15 normal
- -1 sprites/canals.png 8bpp 302 160 23 23 -31 4 normal
- -1 sprites/canals.png 8bpp 334 160 24 18 -11 -1 normal
- -1 sprites/canals.png 8bpp 366 160 12 11 21 10 normal
- -1 sprites/canals.png 8bpp 398 160 19 10 -8 21 normal
- -1 sprites/canals.png 8bpp 430 160 11 10 -31 10 normal
- -1 sprites/canals.png 8bpp 446 160 24 16 -11 -6 normal
- -1 * 7 02 05 16 01 00 00 00
- -1 * 6 07 83 01 \7! 03 01
- -1 * 7 03 05 01 02 00 16 00
diff --git a/media/extra_grf/canals_extra.nfo b/media/extra_grf/canals_extra.nfo
new file mode 100644
index 0000000000..3103886233
--- /dev/null
+++ b/media/extra_grf/canals_extra.nfo
@@ -0,0 +1,101 @@
+//
+// $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 .
+//
+ -1 * 0 0C "Extra canal graphics by PaulC"
+
+// Differentiation for the climates starts here
+
+// Canal edges (arctic snowy)
+ -1 * 4 01 05 01 \b12
+ -1 sprites/canals.png 8bpp 30 40 45 22 -11 -1 normal
+ -1 sprites/canals.png 8bpp 94 40 41 21 -8 10 normal
+ -1 sprites/canals.png 8bpp 142 40 42 21 -31 10 normal
+ -1 sprites/canals.png 8bpp 190 40 43 22 -31 -1 normal
+ -1 sprites/canals.png 8bpp 238 40 22 22 11 4 normal
+ -1 sprites/canals.png 8bpp 270 40 24 16 -11 15 normal
+ -1 sprites/canals.png 8bpp 302 40 23 23 -31 4 normal
+ -1 sprites/canals.png 8bpp 334 40 24 18 -11 -1 normal
+ -1 sprites/canals.png 8bpp 366 40 12 11 21 10 normal
+ -1 sprites/canals.png 8bpp 398 40 19 10 -8 21 normal
+ -1 sprites/canals.png 8bpp 430 40 11 10 -31 10 normal
+ -1 sprites/canals.png 8bpp 446 40 24 16 -11 -6 normal
+ -1 * 7 02 05 10 01 00 00 00
+
+// Canal edges (arctic normal)
+ -1 * 4 01 05 01 \b12
+ -1 sprites/canals.png 8bpp 30 70 45 22 -11 -1 normal
+ -1 sprites/canals.png 8bpp 94 70 41 21 -8 10 normal
+ -1 sprites/canals.png 8bpp 142 70 42 21 -31 10 normal
+ -1 sprites/canals.png 8bpp 190 70 43 22 -31 -1 normal
+ -1 sprites/canals.png 8bpp 238 70 22 22 11 4 normal
+ -1 sprites/canals.png 8bpp 270 70 24 16 -11 15 normal
+ -1 sprites/canals.png 8bpp 302 70 23 23 -31 4 normal
+ -1 sprites/canals.png 8bpp 334 70 24 18 -11 -1 normal
+ -1 sprites/canals.png 8bpp 366 70 12 11 21 10 normal
+ -1 sprites/canals.png 8bpp 398 70 19 10 -8 21 normal
+ -1 sprites/canals.png 8bpp 430 70 11 10 -31 10 normal
+ -1 sprites/canals.png 8bpp 446 70 24 16 -11 -6 normal
+ -1 * 7 02 05 11 01 00 00 00
+// Choose the right arctic canal edges
+ -1 * 14 02 05 12 81 81 00 FF 01 10 00 04 04 11 00
+ -1 * 6 07 83 01 \7! 01 01
+ -1 * 7 03 05 01 02 00 12 00
+
+// Canal edges (tropic desert)
+ -1 * 4 01 05 01 \b12
+ -1 sprites/canals.png 8bpp 30 100 45 22 -11 -1 normal
+ -1 sprites/canals.png 8bpp 94 100 41 21 -8 10 normal
+ -1 sprites/canals.png 8bpp 142 100 42 21 -31 10 normal
+ -1 sprites/canals.png 8bpp 190 100 43 22 -31 -1 normal
+ -1 sprites/canals.png 8bpp 238 100 22 22 11 4 normal
+ -1 sprites/canals.png 8bpp 270 100 24 16 -11 15 normal
+ -1 sprites/canals.png 8bpp 302 100 23 23 -31 4 normal
+ -1 sprites/canals.png 8bpp 334 100 24 18 -11 -1 normal
+ -1 sprites/canals.png 8bpp 366 100 12 11 21 10 normal
+ -1 sprites/canals.png 8bpp 398 100 19 10 -8 21 normal
+ -1 sprites/canals.png 8bpp 430 100 11 10 -31 10 normal
+ -1 sprites/canals.png 8bpp 446 100 24 16 -11 -6 normal
+ -1 * 7 02 05 13 01 00 00 00
+
+// Canal edges (tropic rainforest)
+ -1 * 4 01 05 01 \b12
+ -1 sprites/canals.png 8bpp 30 130 45 22 -11 -1 normal
+ -1 sprites/canals.png 8bpp 94 130 41 21 -8 10 normal
+ -1 sprites/canals.png 8bpp 142 130 42 21 -31 10 normal
+ -1 sprites/canals.png 8bpp 190 130 43 22 -31 -1 normal
+ -1 sprites/canals.png 8bpp 238 130 22 22 11 4 normal
+ -1 sprites/canals.png 8bpp 270 130 24 16 -11 15 normal
+ -1 sprites/canals.png 8bpp 302 130 23 23 -31 4 normal
+ -1 sprites/canals.png 8bpp 334 130 24 18 -11 -1 normal
+ -1 sprites/canals.png 8bpp 366 130 12 11 21 10 normal
+ -1 sprites/canals.png 8bpp 398 130 19 10 -8 21 normal
+ -1 sprites/canals.png 8bpp 430 130 11 10 -31 10 normal
+ -1 sprites/canals.png 8bpp 446 130 24 16 -11 -6 normal
+ -1 * 7 02 05 14 01 00 00 00
+// Choose the right tropic canal edges
+ -1 * 14 02 05 15 81 81 00 FF 01 13 00 01 01 14 00
+ -1 * 6 07 83 01 \7! 02 01
+ -1 * 7 03 05 01 02 00 15 00
+
+// Canal edges (toyland)
+ -1 * 4 01 05 01 \b12
+ -1 sprites/canals.png 8bpp 30 160 45 22 -11 -1 normal
+ -1 sprites/canals.png 8bpp 94 160 41 21 -8 10 normal
+ -1 sprites/canals.png 8bpp 142 160 42 21 -31 10 normal
+ -1 sprites/canals.png 8bpp 190 160 43 22 -31 -1 normal
+ -1 sprites/canals.png 8bpp 238 160 22 22 11 4 normal
+ -1 sprites/canals.png 8bpp 270 160 24 16 -11 15 normal
+ -1 sprites/canals.png 8bpp 302 160 23 23 -31 4 normal
+ -1 sprites/canals.png 8bpp 334 160 24 18 -11 -1 normal
+ -1 sprites/canals.png 8bpp 366 160 12 11 21 10 normal
+ -1 sprites/canals.png 8bpp 398 160 19 10 -8 21 normal
+ -1 sprites/canals.png 8bpp 430 160 11 10 -31 10 normal
+ -1 sprites/canals.png 8bpp 446 160 24 16 -11 -6 normal
+ -1 * 7 02 05 16 01 00 00 00
+ -1 * 6 07 83 01 \7! 03 01
+ -1 * 7 03 05 01 02 00 16 00
diff --git a/media/extra_grf/openttd.nfo b/media/extra_grf/openttd.nfo
index 66149a37e5..7ece5c7149 100644
--- a/media/extra_grf/openttd.nfo
+++ b/media/extra_grf/openttd.nfo
@@ -60,10 +60,11 @@
00
// GRF ID, must start with FF so it gets ignored
- -1 * 0 08 08 FF "OTT"
+//@@WARNING DISABLE 101
+ -1 * 0 08 08 FF FF FF FE
// Name of the GRF
- "OpenTTD's base graphics " 00
+ "OpenTTD's default and fallback extra graphics" 00
// Description of the GRF.
"License: GNU General Public License version 2" 0D
@@ -86,7 +87,6 @@
#include "canals.nfo"
#include "oneway.nfo"
#include "tramtracks.nfo"
-#include "shore.nfo"
#include "sloped_tracks.nfo"
#include "airports.nfo"
#include "roadstops.nfo"
@@ -97,11 +97,5 @@
#include "airport_preview.nfo"
#include "chars.nfo"
#include "mono.nfo"
-#include "fix_graphics.nfo"
-#include "rivers/rapids.nfo"
-#include "rivers/temperate.nfo"
-#include "rivers/arctic.nfo"
-#include "rivers/tropic.nfo"
-#include "rivers/toyland.nfo"
#include "tunnel_portals.nfo"
#include "palette.nfo"
diff --git a/media/extra_grf/orig_extra.nfo b/media/extra_grf/orig_extra.nfo
new file mode 100644
index 0000000000..03a8ff6741
--- /dev/null
+++ b/media/extra_grf/orig_extra.nfo
@@ -0,0 +1,85 @@
+// Automatically generated by GRFCODEC. Do not modify!
+// (Info version 32)
+// Format: spritenum imagefile depth xpos ypos xsize ysize xrel yrel zoom flags
+//
+// $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 .
+//
+// Sources for extra graphics to complement the original graphics.
+// Checks whether the correct version of OpenTTD is used before
+// allowing it to be used.
+//
+
+//
+// Number of sprites, it is wrong, but GRFcodec automagically gets it right.
+//
+ 0 * 4 00 00 00 00
+
+
+//
+// Check whether we are running OTTD or not.
+//
+ -1 * 0 07 9D 04 \7= 01 00 00 00 01
+ -1 * 0 0B 03 7F FF 80 " is not for TTDPatch. Use ttdpatch(w).grf." 00
+
+
+//
+// Check for OTTD's version number
+//
+
+// First step... Variable A1 might not exist. If that's the case it always
+// skips. As we do not want to skip out of the whole testing, we skip over
+// the real version check.
+ -1 * 0 07 A1 04 \7= FF FF FF FF 02
+
+// Real version check.
+ -1 * 0 07 A1 04 \7> \w20304 01 01 03
+
+// If the version check is supported, the string is translateable via OpenTTD
+// itself. Use it!.
+
+ -1 * 0 0B 03 7F 06 "1.1 (or trunk r20304)" 00
+
+// Some OTTD versions before r11130 did support Action B, so use the English
+// phrase there
+ -1 * 0 0B 03 7F FF "Requires OpenTTD version 1.1 (or trunk r20304) or better." 00
+
+// Final fallback. No Action B support, just skip to the end of the file.
+ -1 * 0 07 A1 04 \7= FF FF FF FF 00
+
+// We are a DOS paletted NewGRF, so tell OpenTTD that. Then it can actually
+// do the right thing. Yay for that feature as that means no duplicate NewGRF!
+ -1 * 0 14
+ "C" "INFO"
+ "B" "PALS" \w1 "D"
+ 00
+ 00
+
+// GRF ID, must start with FF so it gets ignored
+//@@WARNING DISABLE 101
+ -1 * 0 08 08 FF "OTT"
+
+// Name of the GRF
+ "Original baseset extra graphics" 00
+
+// Description of the GRF.
+ "License: GNU General Public License version 2" 0D
+ "Andrew Parkhouse: rivers" 0D
+ "Addi and PaulC: original graphics fixes" 0D
+ "OpenTTD developers: other graphics" 00
+
+//
+// The real data of the GRF is acquired from several subfiles.
+//
+#include "shore.nfo"
+#include "fix_graphics.nfo"
+#include "canals_extra.nfo"
+#include "rivers/rapids.nfo"
+#include "rivers/temperate.nfo"
+#include "rivers/arctic.nfo"
+#include "rivers/tropic.nfo"
+#include "rivers/toyland.nfo"
diff --git a/os/windows/installer/install.nsi b/os/windows/installer/install.nsi
index 9eb869f2d3..c7b8c82af4 100644
--- a/os/windows/installer/install.nsi
+++ b/os/windows/installer/install.nsi
@@ -408,6 +408,7 @@ Section "Uninstall"
; Baseset files
Delete "$INSTDIR\baseset\opntitle.dat"
Delete "$INSTDIR\baseset\openttd.grf"
+ Delete "$INSTDIR\baseset\orig_extra.grf"
Delete "$INSTDIR\baseset\orig_win.obg"
Delete "$INSTDIR\baseset\orig_dos.obg"
Delete "$INSTDIR\baseset\orig_dos_de.obg"
diff --git a/source.list b/source.list
index 7824ff8e9d..2b177a0889 100644
--- a/source.list
+++ b/source.list
@@ -423,6 +423,7 @@ core/alloc_type.hpp
core/backup_type.hpp
core/bitmath_func.cpp
core/bitmath_func.hpp
+core/container_func.hpp
core/endian_func.hpp
core/endian_type.hpp
core/enum_type.hpp
diff --git a/src/aircraft.h b/src/aircraft.h
index 0805ae8ec6..f0ca1c4abb 100644
--- a/src/aircraft.h
+++ b/src/aircraft.h
@@ -93,7 +93,7 @@ struct Aircraft FINAL : public SpecializedVehicle {
void UpdateDeltaXY(Direction direction);
ExpensesType GetExpenseType(bool income) const { return income ? EXPENSES_AIRCRAFT_INC : EXPENSES_AIRCRAFT_RUN; }
bool IsPrimaryVehicle() const { return this->IsNormalAircraft(); }
- SpriteID GetImage(Direction direction, EngineImageType image_type) const;
+ void GetImage(Direction direction, EngineImageType image_type, VehicleSpriteSeq *result) const;
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; }
@@ -141,7 +141,7 @@ struct Aircraft FINAL : public SpecializedVehicle {
*/
#define FOR_ALL_AIRCRAFT(var) FOR_ALL_VEHICLES_OF_TYPE(Aircraft, var)
-SpriteID GetRotorImage(const Aircraft *v, EngineImageType image_type);
+void GetRotorImage(const Aircraft *v, EngineImageType image_type, VehicleSpriteSeq *result);
Station *GetTargetAirportIfValid(const Aircraft *v);
diff --git a/src/aircraft_cmd.cpp b/src/aircraft_cmd.cpp
index edb10af327..c9cddbf97d 100644
--- a/src/aircraft_cmd.cpp
+++ b/src/aircraft_cmd.cpp
@@ -152,64 +152,69 @@ static StationID FindNearestHangar(const Aircraft *v)
return index;
}
-SpriteID Aircraft::GetImage(Direction direction, EngineImageType image_type) const
+void Aircraft::GetImage(Direction direction, EngineImageType image_type, VehicleSpriteSeq *result) const
{
uint8 spritenum = this->spritenum;
if (is_custom_sprite(spritenum)) {
- SpriteID sprite = GetCustomVehicleSprite(this, direction, image_type);
- if (sprite != 0) return sprite;
+ GetCustomVehicleSprite(this, direction, image_type, result);
+ if (result->IsValid()) return;
spritenum = this->GetEngine()->original_image_index;
}
assert(IsValidImageIndex(spritenum));
- return direction + _aircraft_sprite[spritenum];
+ result->Set(direction + _aircraft_sprite[spritenum]);
}
-SpriteID GetRotorImage(const Aircraft *v, EngineImageType image_type)
+void GetRotorImage(const Aircraft *v, EngineImageType image_type, VehicleSpriteSeq *result)
{
assert(v->subtype == AIR_HELICOPTER);
const Aircraft *w = v->Next()->Next();
if (is_custom_sprite(v->spritenum)) {
- SpriteID sprite = GetCustomRotorSprite(v, false, image_type);
- if (sprite != 0) return sprite;
+ GetCustomRotorSprite(v, false, image_type, result);
+ if (result->IsValid()) return;
}
/* Return standard rotor sprites if there are no custom sprites for this helicopter */
- return SPR_ROTOR_STOPPED + w->state;
+ result->Set(SPR_ROTOR_STOPPED + w->state);
}
-static SpriteID GetAircraftIcon(EngineID engine, EngineImageType image_type)
+static void GetAircraftIcon(EngineID engine, EngineImageType image_type, VehicleSpriteSeq *result)
{
const Engine *e = Engine::Get(engine);
uint8 spritenum = e->u.air.image_index;
if (is_custom_sprite(spritenum)) {
- SpriteID sprite = GetCustomVehicleIcon(engine, DIR_W, image_type);
- if (sprite != 0) return sprite;
+ GetCustomVehicleIcon(engine, DIR_W, image_type, result);
+ if (result->IsValid()) return;
spritenum = e->original_image_index;
}
assert(IsValidImageIndex(spritenum));
- return DIR_W + _aircraft_sprite[spritenum];
+ result->Set(DIR_W + _aircraft_sprite[spritenum]);
}
void DrawAircraftEngine(int left, int right, int preferred_x, int y, EngineID engine, PaletteID pal, EngineImageType image_type)
{
- SpriteID sprite = GetAircraftIcon(engine, image_type);
- const Sprite *real_sprite = GetSprite(sprite, ST_NORMAL);
+ VehicleSpriteSeq seq;
+ GetAircraftIcon(engine, image_type, &seq);
+
+ Rect rect;
+ seq.GetBounds(&rect);
preferred_x = Clamp(preferred_x,
- left - UnScaleGUI(real_sprite->x_offs),
- right - UnScaleGUI(real_sprite->width) - UnScaleGUI(real_sprite->x_offs));
- DrawSprite(sprite, pal, preferred_x, y);
+ left - UnScaleGUI(rect.left),
+ right - UnScaleGUI(rect.right));
+
+ seq.Draw(preferred_x, y, pal, pal == PALETTE_CRASH);
if (!(AircraftVehInfo(engine)->subtype & AIR_CTOL)) {
- SpriteID rotor_sprite = GetCustomRotorIcon(engine, image_type);
- if (rotor_sprite == 0) rotor_sprite = SPR_ROTOR_STOPPED;
- DrawSprite(rotor_sprite, PAL_NONE, preferred_x, y - ScaleGUITrad(5));
+ VehicleSpriteSeq rotor_seq;
+ GetCustomRotorIcon(engine, image_type, &rotor_seq);
+ if (!rotor_seq.IsValid()) rotor_seq.Set(SPR_ROTOR_STOPPED);
+ rotor_seq.Draw(preferred_x, y - ScaleGUITrad(5), PAL_NONE, false);
}
}
@@ -224,12 +229,16 @@ void DrawAircraftEngine(int left, int right, int preferred_x, int y, EngineID en
*/
void GetAircraftSpriteSize(EngineID engine, uint &width, uint &height, int &xoffs, int &yoffs, EngineImageType image_type)
{
- const Sprite *spr = GetSprite(GetAircraftIcon(engine, image_type), ST_NORMAL);
+ VehicleSpriteSeq seq;
+ GetAircraftIcon(engine, image_type, &seq);
- width = UnScaleGUI(spr->width);
- height = UnScaleGUI(spr->height);
- xoffs = UnScaleGUI(spr->x_offs);
- yoffs = UnScaleGUI(spr->y_offs);
+ Rect rect;
+ seq.GetBounds(&rect);
+
+ width = UnScaleGUI(rect.right - rect.left + 1);
+ height = UnScaleGUI(rect.bottom - rect.top + 1);
+ xoffs = UnScaleGUI(rect.left);
+ yoffs = UnScaleGUI(rect.top);
}
/**
@@ -317,7 +326,8 @@ CommandCost CmdBuildAircraft(TileIndex tile, DoCommandFlag flags, const Engine *
v->date_of_last_service = _date;
v->build_year = u->build_year = _cur_year;
- v->cur_image = u->cur_image = SPR_IMG_QUERY;
+ v->sprite_seq.Set(SPR_IMG_QUERY);
+ u->sprite_seq.Set(SPR_IMG_QUERY);
v->random_bits = VehicleRandomBits();
u->random_bits = VehicleRandomBits();
@@ -349,7 +359,7 @@ CommandCost CmdBuildAircraft(TileIndex tile, DoCommandFlag flags, const Engine *
w->vehstatus = VS_HIDDEN | VS_UNCLICKABLE;
w->spritenum = 0xFF;
w->subtype = AIR_ROTOR;
- w->cur_image = SPR_ROTOR_STOPPED;
+ w->sprite_seq.Set(SPR_ROTOR_STOPPED);
w->random_bits = VehicleRandomBits();
/* Use rotor's air.state to store the rotor animation frame */
w->state = HRS_ROTOR_STOPPED;
@@ -468,21 +478,21 @@ static void HelicopterTickHandler(Aircraft *v)
int tick = ++u->tick_counter;
int spd = u->cur_speed >> 4;
- SpriteID img;
+ VehicleSpriteSeq seq;
if (spd == 0) {
u->state = HRS_ROTOR_STOPPED;
- img = GetRotorImage(v, EIT_ON_MAP);
- if (u->cur_image == img) return;
+ GetRotorImage(v, EIT_ON_MAP, &seq);
+ if (u->sprite_seq == seq) return;
} else if (tick >= spd) {
u->tick_counter = 0;
u->state++;
if (u->state > HRS_ROTOR_MOVING_3) u->state = HRS_ROTOR_MOVING_1;
- img = GetRotorImage(v, EIT_ON_MAP);
+ GetRotorImage(v, EIT_ON_MAP, &seq);
} else {
return;
}
- u->cur_image = img;
+ u->sprite_seq = seq;
u->UpdatePositionAndViewport();
}
@@ -502,7 +512,9 @@ void SetAircraftPosition(Aircraft *v, int x, int y, int z)
v->UpdatePosition();
v->UpdateViewport(true, false);
- if (v->subtype == AIR_HELICOPTER) v->Next()->Next()->cur_image = GetRotorImage(v, EIT_ON_MAP);
+ if (v->subtype == AIR_HELICOPTER) {
+ GetRotorImage(v, EIT_ON_MAP, &v->Next()->Next()->sprite_seq);
+ }
Aircraft *u = v->Next();
@@ -513,7 +525,7 @@ void SetAircraftPosition(Aircraft *v, int x, int y, int z)
safe_y = Clamp(u->y_pos, 0, MapMaxY() * TILE_SIZE);
u->z_pos = GetSlopePixelZ(safe_x, safe_y);
- u->cur_image = v->cur_image;
+ u->sprite_seq.CopyWithoutPalette(v->sprite_seq); // the shadow is never coloured
u->UpdatePositionAndViewport();
@@ -1237,7 +1249,9 @@ void Aircraft::MarkDirty()
{
this->colourmap = PAL_NONE;
this->UpdateViewport(true, false);
- if (this->subtype == AIR_HELICOPTER) this->Next()->Next()->cur_image = GetRotorImage(this, EIT_ON_MAP);
+ if (this->subtype == AIR_HELICOPTER) {
+ GetRotorImage(this, EIT_ON_MAP, &this->Next()->Next()->sprite_seq);
+ }
}
diff --git a/src/aircraft_gui.cpp b/src/aircraft_gui.cpp
index c3379d3951..6693b1f8ad 100644
--- a/src/aircraft_gui.cpp
+++ b/src/aircraft_gui.cpp
@@ -83,11 +83,14 @@ void DrawAircraftImage(const Vehicle *v, int left, int right, int y, VehicleID s
{
bool rtl = _current_text_dir == TD_RTL;
- SpriteID sprite = v->GetImage(rtl ? DIR_E : DIR_W, image_type);
- const Sprite *real_sprite = GetSprite(sprite, ST_NORMAL);
+ VehicleSpriteSeq seq;
+ v->GetImage(rtl ? DIR_E : DIR_W, image_type, &seq);
- int width = UnScaleGUI(real_sprite->width);
- int x_offs = UnScaleGUI(real_sprite->x_offs);
+ Rect rect;
+ seq.GetBounds(&rect);
+
+ int width = UnScaleGUI(rect.right - rect.left + 1);
+ int x_offs = UnScaleGUI(rect.left);
int x = rtl ? right - width - x_offs : left - x_offs;
bool helicopter = v->subtype == AIR_HELICOPTER;
@@ -95,17 +98,18 @@ void DrawAircraftImage(const Vehicle *v, int left, int right, int y, VehicleID s
int heli_offs = 0;
PaletteID pal = (v->vehstatus & VS_CRASHED) ? PALETTE_CRASH : GetVehiclePalette(v);
- DrawSprite(sprite, pal, x, y + y_offs);
+ seq.Draw(x, y + y_offs, pal, (v->vehstatus & VS_CRASHED) != 0);
if (helicopter) {
const Aircraft *a = Aircraft::From(v);
- SpriteID rotor_sprite = GetCustomRotorSprite(a, true, image_type);
- if (rotor_sprite == 0) rotor_sprite = SPR_ROTOR_STOPPED;
+ VehicleSpriteSeq rotor_seq;
+ GetCustomRotorSprite(a, true, image_type, &rotor_seq);
+ if (!rotor_seq.IsValid()) rotor_seq.Set(SPR_ROTOR_STOPPED);
heli_offs = ScaleGUITrad(5);
- DrawSprite(rotor_sprite, PAL_NONE, x, y + y_offs - heli_offs);
+ rotor_seq.Draw(x, y + y_offs - heli_offs, PAL_NONE, false);
}
if (v->index == selection) {
x += x_offs;
- y += UnScaleGUI(real_sprite->y_offs) + y_offs - heli_offs;
- DrawFrameRect(x - 1, y - 1, x + width + 1, y + UnScaleGUI(real_sprite->height) + heli_offs + 1, COLOUR_WHITE, FR_BORDERONLY);
+ y += UnScaleGUI(rect.top) + y_offs - heli_offs;
+ DrawFrameRect(x - 1, y - 1, x + width + 1, y + UnScaleGUI(rect.bottom - rect.top + 1) + heli_offs + 1, COLOUR_WHITE, FR_BORDERONLY);
}
}
diff --git a/src/articulated_vehicles.cpp b/src/articulated_vehicles.cpp
index 8c372e7eae..04c9f95a97 100644
--- a/src/articulated_vehicles.cpp
+++ b/src/articulated_vehicles.cpp
@@ -441,7 +441,7 @@ void AddArticulatedParts(Vehicle *first)
v->max_age = 0;
v->engine_type = engine_type;
v->value = 0;
- v->cur_image = SPR_IMG_QUERY;
+ v->sprite_seq.Set(SPR_IMG_QUERY);
v->random_bits = VehicleRandomBits();
if (flip_image) v->spritenum++;
diff --git a/src/autoreplace_gui.cpp b/src/autoreplace_gui.cpp
index 691042a1d5..1074d1dd78 100644
--- a/src/autoreplace_gui.cpp
+++ b/src/autoreplace_gui.cpp
@@ -87,7 +87,7 @@ class ReplaceVehicleWindow : public Window {
byte sort_criteria; ///< Criteria of sorting vehicles.
bool descending_sort_order; ///< Order of sorting vehicles.
bool show_hidden_engines; ///< Whether to show the hidden engines.
- RailType sel_railtype; ///< Type of rail tracks selected.
+ RailType sel_railtype; ///< Type of rail tracks selected. #INVALID_RAILTYPE to show all.
Scrollbar *vscroll[2];
/**
@@ -104,7 +104,7 @@ class ReplaceVehicleWindow : public Window {
/* Ensure that the wagon/engine selection fits the engine. */
if ((rvi->railveh_type == RAILVEH_WAGON) == show_engines) return false;
- if (draw_left && show_engines) {
+ if (draw_left && this->sel_railtype != INVALID_RAILTYPE) {
/* Ensure that the railtype is specific to the selected one */
if (rvi->railtype != this->sel_railtype) return false;
}
@@ -211,24 +211,7 @@ class ReplaceVehicleWindow : public Window {
public:
ReplaceVehicleWindow(WindowDesc *desc, VehicleType vehicletype, GroupID id_g) : Window(desc)
{
- if (vehicletype == VEH_TRAIN) {
- /* For rail vehicles find the most used vehicle type, which is usually
- * better than 'just' the first/previous vehicle type. */
- uint type_count[RAILTYPE_END];
- memset(type_count, 0, sizeof(type_count));
-
- const Engine *e;
- FOR_ALL_ENGINES_OF_TYPE(e, VEH_TRAIN) {
- if (e->u.rail.railveh_type == RAILVEH_WAGON) continue;
- type_count[e->u.rail.railtype] += GetGroupNumEngines(_local_company, id_g, e->index);
- }
-
- this->sel_railtype = RAILTYPE_BEGIN;
- for (RailType rt = RAILTYPE_BEGIN; rt < RAILTYPE_END; rt++) {
- if (type_count[this->sel_railtype] < type_count[rt]) this->sel_railtype = rt;
- }
- }
-
+ this->sel_railtype = INVALID_RAILTYPE;
this->replace_engines = true; // start with locomotives (all other vehicles will not read this bool)
this->engines[0].ForceRebuild();
this->engines[1].ForceRebuild();
@@ -288,12 +271,9 @@ public:
break;
}
- case WID_RV_TRAIN_ENGINEWAGON_TOGGLE: {
- StringID str = this->GetWidget(widget)->widget_data;
- SetDParam(0, STR_REPLACE_ENGINES);
- Dimension d = GetStringBoundingBox(str);
- SetDParam(0, STR_REPLACE_WAGONS);
- d = maxdim(d, GetStringBoundingBox(str));
+ case WID_RV_TRAIN_ENGINEWAGON_DROPDOWN: {
+ Dimension d = GetStringBoundingBox(STR_REPLACE_ENGINES);
+ d = maxdim(d, GetStringBoundingBox(STR_REPLACE_WAGONS));
d.width += padding.width;
d.height += padding.height;
*size = maxdim(*size, d);
@@ -367,7 +347,7 @@ public:
break;
}
- case WID_RV_TRAIN_ENGINEWAGON_TOGGLE:
+ case WID_RV_TRAIN_ENGINEWAGON_DROPDOWN:
SetDParam(0, this->replace_engines ? STR_REPLACE_ENGINES : STR_REPLACE_WAGONS);
break;
}
@@ -432,12 +412,8 @@ public:
this->SetWidgetDisabledState(WID_RV_STOP_REPLACE, this->sel_engine[0] == INVALID_ENGINE || !EngineHasReplacementForCompany(c, this->sel_engine[0], this->sel_group));
if (this->window_number == VEH_TRAIN) {
- /* sets the colour of that art thing */
- this->GetWidget(WID_RV_TRAIN_FLUFF_LEFT)->colour = _company_colours[_local_company];
- this->GetWidget(WID_RV_TRAIN_FLUFF_RIGHT)->colour = _company_colours[_local_company];
-
/* Show the selected railtype in the pulldown menu */
- this->GetWidget(WID_RV_TRAIN_RAILTYPE_DROPDOWN)->widget_data = GetRailTypeInfo(sel_railtype)->strings.replace_text;
+ this->GetWidget(WID_RV_TRAIN_RAILTYPE_DROPDOWN)->widget_data = sel_railtype == INVALID_RAILTYPE ? STR_REPLACE_ALL_RAILTYPE : GetRailTypeInfo(sel_railtype)->strings.replace_text;
}
this->DrawWidgets();
@@ -483,15 +459,16 @@ public:
DisplayVehicleSortDropDown(this, static_cast(this->window_number), this->sort_criteria, WID_RV_SORT_DROPDOWN);
break;
- case WID_RV_TRAIN_ENGINEWAGON_TOGGLE:
- this->replace_engines = !(this->replace_engines);
- this->engines[0].ForceRebuild();
- this->reset_sel_engine = true;
- this->SetDirty();
+ case WID_RV_TRAIN_ENGINEWAGON_DROPDOWN: {
+ DropDownList *list = new DropDownList();
+ *list->Append() = new DropDownListStringItem(STR_REPLACE_ENGINES, 1, false);
+ *list->Append() = new DropDownListStringItem(STR_REPLACE_WAGONS, 0, false);
+ ShowDropDownList(this, list, this->replace_engines ? 1 : 0, WID_RV_TRAIN_ENGINEWAGON_DROPDOWN);
break;
+ }
case WID_RV_TRAIN_RAILTYPE_DROPDOWN: // Railtype selection dropdown menu
- ShowDropDownList(this, GetRailTypeDropDownList(true), sel_railtype, WID_RV_TRAIN_RAILTYPE_DROPDOWN);
+ ShowDropDownList(this, GetRailTypeDropDownList(true, true), sel_railtype, WID_RV_TRAIN_RAILTYPE_DROPDOWN);
break;
case WID_RV_TRAIN_WAGONREMOVE_TOGGLE: // toggle renew_keep_length
@@ -566,6 +543,14 @@ public:
break;
}
+ case WID_RV_TRAIN_ENGINEWAGON_DROPDOWN: {
+ this->replace_engines = index != 0;
+ this->engines[0].ForceRebuild();
+ this->reset_sel_engine = true;
+ this->SetDirty();
+ break;
+ }
+
case WID_RV_START_REPLACE:
this->ReplaceClick_StartReplace(index != 0);
break;
@@ -611,7 +596,13 @@ static const NWidgetPart _nested_replace_rail_vehicle_widgets[] = {
EndContainer(),
EndContainer(),
NWidget(NWID_HORIZONTAL, NC_EQUALSIZE),
- NWidget(WWT_PANEL, COLOUR_GREY), SetResize(1, 0), EndContainer(),
+ NWidget(NWID_VERTICAL),
+ NWidget(NWID_HORIZONTAL),
+ NWidget(WWT_DROPDOWN, COLOUR_GREY, WID_RV_TRAIN_RAILTYPE_DROPDOWN), SetMinimalSize(136, 12), SetDataTip(0x0, STR_REPLACE_HELP_RAILTYPE), SetFill(1, 0), SetResize(1, 0),
+ NWidget(WWT_DROPDOWN, COLOUR_GREY, WID_RV_TRAIN_ENGINEWAGON_DROPDOWN), SetDataTip(STR_BLACK_STRING, STR_REPLACE_ENGINE_WAGON_SELECT_HELP),
+ EndContainer(),
+ NWidget(WWT_PANEL, COLOUR_GREY), SetResize(1, 0), EndContainer(),
+ EndContainer(),
NWidget(NWID_VERTICAL),
NWidget(NWID_HORIZONTAL),
NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, WID_RV_SORT_ASCENDING_DESCENDING), SetDataTip(STR_BUTTON_SORT_BY, STR_TOOLTIP_SORT_ORDER), SetFill(1, 1),
@@ -631,20 +622,16 @@ static const NWidgetPart _nested_replace_rail_vehicle_widgets[] = {
EndContainer(),
NWidget(NWID_HORIZONTAL, NC_EQUALSIZE),
NWidget(WWT_PANEL, COLOUR_GREY, WID_RV_LEFT_DETAILS), SetMinimalSize(240, 122), SetResize(1, 0), EndContainer(),
- NWidget(WWT_PANEL, COLOUR_GREY, WID_RV_RIGHT_DETAILS), SetMinimalSize(240, 122), SetResize(1, 0), EndContainer(),
+ NWidget(NWID_VERTICAL),
+ NWidget(WWT_PANEL, COLOUR_GREY, WID_RV_RIGHT_DETAILS), SetMinimalSize(240, 122), SetResize(1, 0), EndContainer(),
+ NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, WID_RV_TRAIN_WAGONREMOVE_TOGGLE), SetMinimalSize(138, 12), SetDataTip(STR_REPLACE_REMOVE_WAGON, STR_REPLACE_REMOVE_WAGON_HELP), SetFill(1, 0), 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_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),
- EndContainer(),
- NWidget(NWID_HORIZONTAL),
- NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, WID_RV_TRAIN_ENGINEWAGON_TOGGLE), SetMinimalSize(139, 12), SetDataTip(STR_REPLACE_ENGINE_WAGON_SELECT, STR_REPLACE_ENGINE_WAGON_SELECT_HELP),
- NWidget(WWT_PANEL, COLOUR_GREY, WID_RV_TRAIN_FLUFF_LEFT), SetMinimalSize(15, 12), EndContainer(),
- NWidget(WWT_DROPDOWN, COLOUR_GREY, WID_RV_TRAIN_RAILTYPE_DROPDOWN), SetMinimalSize(136, 12), SetDataTip(0x0, STR_REPLACE_HELP_RAILTYPE), SetResize(1, 0),
- NWidget(WWT_PANEL, COLOUR_GREY, WID_RV_TRAIN_FLUFF_RIGHT), SetMinimalSize(16, 12), EndContainer(),
- NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, WID_RV_TRAIN_WAGONREMOVE_TOGGLE), SetMinimalSize(138, 12), SetDataTip(STR_REPLACE_REMOVE_WAGON, STR_REPLACE_REMOVE_WAGON_HELP),
NWidget(WWT_RESIZEBOX, COLOUR_GREY),
EndContainer(),
};
diff --git a/src/clear_cmd.cpp b/src/clear_cmd.cpp
index 2e9589aee2..f9eb88df54 100644
--- a/src/clear_cmd.cpp
+++ b/src/clear_cmd.cpp
@@ -56,7 +56,7 @@ void DrawHillyLandTile(const TileInfo *ti)
if (ti->tileh != SLOPE_FLAT) {
DrawGroundSprite(SPR_FLAT_ROUGH_LAND + SlopeToSpriteOffset(ti->tileh), PAL_NONE);
} else {
- DrawGroundSprite(_landscape_clear_sprites_rough[GB(ti->x ^ ti->y, 4, 3)], PAL_NONE);
+ DrawGroundSprite(_landscape_clear_sprites_rough[GB(TileHash(ti->x, ti->y), 0, 3)], PAL_NONE);
}
}
diff --git a/src/core/container_func.hpp b/src/core/container_func.hpp
new file mode 100644
index 0000000000..1b8e8ad847
--- /dev/null
+++ b/src/core/container_func.hpp
@@ -0,0 +1,35 @@
+/* $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 .
+ */
+
+/** @file container_func.hpp Functions related to use of containers. */
+
+template unsigned int container_unordered_remove_if (C &container, UP predicate) {
+ unsigned int removecount = 0;
+ for (auto it = container.begin(); it != container.end();) {
+ if (predicate(*it)) {
+ removecount++;
+ if (std::next(it) != container.end()) {
+ *it = std::move(container.back());
+ container.pop_back();
+ } else {
+ container.pop_back();
+ break;
+ }
+ } else {
+ ++it;
+ }
+ }
+ return removecount;
+}
+
+template unsigned int container_unordered_remove(C &container, const V &value) {
+ return container_unordered_remove_if (container, [&](const typename C::value_type &v) {
+ return v == value;
+ });
+}
diff --git a/src/core/multimap.hpp b/src/core/multimap.hpp
index e906677141..da6a33ef45 100644
--- a/src/core/multimap.hpp
+++ b/src/core/multimap.hpp
@@ -15,7 +15,7 @@
#include